private void btnCalculate_Click(object sender, EventArgs e) { try { var temp = GetTempInCorrectUnits(); var pressure = GetPressureValueInCorrectUnits(); var volume = GetVolumeValueInCorrectUnits(); var physApi = new PhysInterface(); var mass = physApi.ComputeTankMass(temp, pressure, volume); if (mass != null) { var correctedMass = ddMass.ConvertValue(MassUnit.Kilogram, _mActiveMassUnit, (double)mass); tbMass.Text = correctedMass.ToString(); } else { tbMass.Text = "Error"; } } catch (Exception ex) { MessageBox.Show("An error occurred when attempting to perform the calculation: " + ex.Message); } }
/// <summary> /// Compute missing parameter via python call /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCalculate_Click(object sender, EventArgs e) { double?temp = null; double?pressure = null; double?density = null; switch (_mCalculationOption) { case CalculationOption.CalculateDensity: temp = GetTempInCorrectUnits(); pressure = GetPressureValueInCorrectUnits(); break; case CalculationOption.CalculatePressure: density = GetDensityInCorrectUnits(); temp = GetTempInCorrectUnits(); break; case CalculationOption.CalculateTemperature: density = GetDensityInCorrectUnits(); pressure = GetPressureValueInCorrectUnits(); break; default: throw new Exception("Calculation option of " + _mCalculationOption + " unknown."); } try { var physApi = new PhysInterface(); var result = (double)physApi.ComputeTpd(temp, pressure, density); var valueToUse = double.NaN; switch (_mCalculationOption) { case CalculationOption.CalculateDensity: valueToUse = dd_Density.ConvertValue(DensityUnit.KilogramCubicMeter, _mActiveDensityUnit, result); break; case CalculationOption.CalculatePressure: valueToUse = dd_Pressure.ConvertValue(PressureUnit.Pa, _mActivePressureUnit, result); break; case CalculationOption.CalculateTemperature: valueToUse = dd_Temperature.ConvertValue(TempUnit.Kelvin, _mActiveTempUnit, result); break; } var resultContainer = GetResultContainer(); resultContainer.Text = Parsing.DoubleToString(valueToUse); } catch (Exception ex) { MessageBox.Show("An error occurred when attempting to perform the calculation: " + ex.Message); } }
private void Execute() { // Blanket try block to help catch deployed issue Brian encountered Trace.TraceInformation("Gathering parameters for radiative flux analysis..."); try { var ambTemp = QraStateContainer.GetNdValue("SysParam.ExternalTempC", TempUnit.Kelvin); var ambPressure = QraStateContainer.GetNdValue("SysParam.ExternalPresMPA", PressureUnit.Pa); var h2Temp = QraStateContainer.GetNdValue("FlameWrapper.T_H2", TempUnit.Kelvin); var h2Pressure = QraStateContainer.GetNdValue("FlameWrapper.P_H2", PressureUnit.Pa); var orificeDiam = QraStateContainer.GetNdValue("FlameWrapper.d_orifice", DistanceUnit.Meter); var leakHeight = QraStateContainer.GetNdValue("FlameWrapper.ReleaseHeight", DistanceUnit.Meter); _radHeatFluxX = QraStateContainer.GetNdValueList("FlameWrapper.radiative_heat_flux_point:x", DistanceUnit.Meter); _radHeatFluxY = QraStateContainer.GetNdValueList("FlameWrapper.radiative_heat_flux_point:y", DistanceUnit.Meter); _radHeatFluxZ = QraStateContainer.GetNdValueList("FlameWrapper.radiative_heat_flux_point:z", DistanceUnit.Meter); var contourLevels = QraStateContainer.GetNdValueList("FlameWrapper.contour_levels", UnitlessUnit.Unitless); var relativeHumidity = QraStateContainer.GetNdValue("FlameWrapper.RH", UnitlessUnit.Unitless); var notionalNozzleModel = QraStateContainer.GetValue <NozzleModel>("NozzleModel"); var releaseAngle = QraStateContainer.GetNdValue("OpWrapper.ReleaseAngle", AngleUnit.Radians); var radiativeSourceModel = QraStateContainer.GetValue <RadiativeSourceModels>("RadiativeSourceModel"); Trace.TraceInformation("Creating PhysInterface for python call"); var physInt = new PhysInterface(); physInt.AnalyzeRadiativeHeatFlux(ambTemp, ambPressure, h2Temp, h2Pressure, orificeDiam, leakHeight, releaseAngle, notionalNozzleModel, _radHeatFluxX, _radHeatFluxY, _radHeatFluxZ, relativeHumidity, radiativeSourceModel, contourLevels, out _fluxData, out _fluxPlotFilepath, out _tempPlotFilepath); Trace.TraceInformation("PhysInterface call complete"); } catch (Exception ex) { Trace.TraceError(ex.ToString()); MessageBox.Show(@"Heat flux analysis failed, please try again. Check log for details."); } }
private void Execute() { var ambPressure = QraStateContainer.GetNdValue("SysParam.ExternalPresMPA", PressureUnit.Pa); var ambTemp = QraStateContainer.GetNdValue("SysParam.ExternalTempC", TempUnit.Kelvin); var h2Pressure = QraStateContainer.GetNdValue("FlameWrapper.P_H2", PressureUnit.Pa); var h2Temp = QraStateContainer.GetNdValue("FlameWrapper.T_H2", TempUnit.Kelvin); var orificeDiam = QraStateContainer.GetNdValue("FlameWrapper.d_orifice", DistanceUnit.Meter); var dischargeCoeff = QraStateContainer.GetNdValue("OpWrapper.Cd0", UnitlessUnit.Unitless); var xMin = QraStateContainer.GetNdValue("PlumeWrapper.XMin", DistanceUnit.Meter); var xMax = QraStateContainer.GetNdValue("PlumeWrapper.XMax", DistanceUnit.Meter); var yMin = QraStateContainer.GetNdValue("PlumeWrapper.YMin", DistanceUnit.Meter); var yMax = QraStateContainer.GetNdValue("PlumeWrapper.YMax", DistanceUnit.Meter); var contours = QraStateContainer.GetNdValue("PlumeWrapper.Contours", UnitlessUnit.Unitless); var jetAngle = QraStateContainer.GetNdValue("PlumeWrapper.jet_angle", AngleUnit.Radians); var plotTitle = QraStateContainer.GetValue <string>("PlumeWrapper.PlotTitle"); var physInt = new PhysInterface(); _plotFilename = physInt.CreatePlumePlot( ambPressure, ambTemp, h2Pressure, h2Temp, orificeDiam, dischargeCoeff, xMin, xMax, yMin, yMax, contours, jetAngle, plotTitle); }
private void Execute() { var ambTemp = QraStateContainer.Instance.GetStateDefinedValueObject("SysParam.ExternalTempC") .GetValue(TempUnit.Kelvin)[0]; var ambPres = QraStateContainer.Instance.GetStateDefinedValueObject("SysParam.ExternalPresMPA") .GetValue(PressureUnit.Pa)[0]; var h2Temp = QraStateContainer.Instance.GetStateDefinedValueObject("FlameWrapper.T_H2") .GetValue(TempUnit.Kelvin)[0]; var h2Pres = QraStateContainer.Instance.GetStateDefinedValueObject("FlameWrapper.P_H2") .GetValue(PressureUnit.Pa)[0]; var orificeDiam = QraStateContainer.Instance.GetStateDefinedValueObject("FlameWrapper.d_orifice") .GetValue(DistanceUnit.Meter)[0]; var y0 = QraStateContainer.Instance.GetStateDefinedValueObject("FlameWrapper.ReleaseHeight") .GetValue(DistanceUnit.Meter)[0]; var releaseAngle = QraStateContainer.Instance.GetStateDefinedValueObject("OpWrapper.ReleaseAngle") .GetValue(AngleUnit.Radians)[0]; var nozzleModel = QraStateContainer.GetValue <NozzleModel>("NozzleModel"); var physInt = new PhysInterface(); _resultImageFilepath = physInt.CreateFlameTemperaturePlot(ambTemp, ambPres, h2Temp, h2Pres, orificeDiam, y0, releaseAngle, nozzleModel.GetKey()); }
private void Execute() { var ambPressure = QraStateContainer.GetNdValue("SysParam.ExternalPresMPA", PressureUnit.Pa); var ambTemp = QraStateContainer.GetNdValue("SysParam.ExternalTempC", TempUnit.Kelvin); var h2Pressure = QraStateContainer.GetNdValue("FlameWrapper.P_H2", PressureUnit.Pa); var h2Temp = QraStateContainer.GetNdValue("FlameWrapper.T_H2", TempUnit.Kelvin); var orificeDiam = QraStateContainer.GetNdValue("FlameWrapper.d_orifice", DistanceUnit.Meter); var orificeDischargeCoeff = QraStateContainer.GetNdValue("OpWrapper.Cd0", UnitlessUnit.Unitless); var tankVolume = QraStateContainer.GetNdValue("OpWrapper.TankVolume", VolumeUnit.CubicMeter); var releaseDischargeCoeff = QraStateContainer.GetNdValue("OpWrapper.CdR", UnitlessUnit.Unitless); var releaseArea = QraStateContainer.GetNdValue("OpWrapper.SecondaryArea", AreaUnit.SqMeters); var releaseHeight = QraStateContainer.GetNdValue("OpWrapper.S0", DistanceUnit.Meter); var enclosureHeight = QraStateContainer.GetNdValue("OpWrapper.H", DistanceUnit.Meter); var floorCeilingArea = QraStateContainer.GetNdValue("OpWrapper.FCA", AreaUnit.SqMeters); var distReleaseToWall = QraStateContainer.GetNdValue("OpWrapper.Xwall", DistanceUnit.Meter); var ceilVentXArea = QraStateContainer.GetNdValue("OpWrapper.Av_ceil", AreaUnit.SqMeters); var ceilVentHeight = QraStateContainer.GetNdValue("OpWrapper.CVHF", DistanceUnit.Meter); var floorVentXArea = QraStateContainer.GetNdValue("OpWrapper.Av_floor", AreaUnit.SqMeters); var floorVentHeight = QraStateContainer.GetNdValue("OpWrapper.FVHF", DistanceUnit.Meter); var flowRate = QraStateContainer.GetNdValue("OpWrapper.VolumeFlowRate", VolumetricFlowUnit.CubicMetersPerSecond); var releaseAngle = QraStateContainer.GetNdValue("OpWrapper.ReleaseAngle", AngleUnit.Radians); // Blanket try block to catch odd Win8 VM issue try { Trace.TraceInformation("Primitive overpressure parameters gathered. Extracting advanced..."); _timesToPlot = QraStateContainer.GetNdValueList("OpWrapper.SecondsToPlot", ElapsingTimeConversionUnit.Second); // Whether to mark pressures on chart. Gets custom time-pressure objects NdPressureAtTime[] pressuresAtTimes = { }; if (cbMarkChartWithPTDots.Checked) { pressuresAtTimes = QraStateContainer.GetValue <NdPressureAtTime[]>("OpWrapper.PlotDotsPressureAtTimes"); var numPressures = pressuresAtTimes.Length; _dotMarkPressures = new double[numPressures]; _dotMarkTimes = new double[numPressures]; for (var i = 0; i < numPressures; i++) { _dotMarkPressures[i] = pressuresAtTimes[i].Pressure; _dotMarkTimes[i] = pressuresAtTimes[i].Time; } } else { _dotMarkPressures = new double[0]; _dotMarkTimes = new double[0]; } // WHether to plot line pressures var llp = QraStateContainer.GetNdValueList("OPWRAPPER.LIMITLINEPRESSURES", PressureUnit.KPa); double[] limitLinePressures = { }; if (cbHorizontalLines.Checked) { limitLinePressures = llp; } var maxSimTime = QraStateContainer.GetNdValue("OpWrapper.MaxSimTime", ElapsingTimeConversionUnit.Second); // prep vars to hold results var numTimes = pressuresAtTimes.Length; _pressuresPerTime = new double[numTimes]; _depths = new double[numTimes]; _concentrations = new double[numTimes]; Trace.TraceInformation("Initializing PhysInterface..."); var physInt = new PhysInterface(); var status = physInt.ExecuteOverpressureAnalysis( ambPressure, ambTemp, h2Pressure, h2Temp, orificeDiam, orificeDischargeCoeff, tankVolume, releaseDischargeCoeff, releaseArea, releaseHeight, enclosureHeight, floorCeilingArea, distReleaseToWall, ceilVentXArea, ceilVentHeight, floorVentXArea, floorVentHeight, flowRate, releaseAngle, _timesToPlot, _dotMarkPressures, _dotMarkTimes, limitLinePressures, maxSimTime, out _pressuresPerTime, out _depths, out _concentrations, out _overpressure, out _timeOfOverpressure, out _pressurePlotFilepath, out _massPlotFilepath, out _layerPlotFilepath, out _trajectoryPlotFilepath ); Trace.TraceInformation("PhysInterface call complete. Displaying results.."); } catch (Exception ex) { Trace.TraceError(ex.Message); } }