Exemplo n.º 1
0
        /// <summary>
        ///     Parse selected string into Deflagration Model, store it, and update CFD input display.
        /// </summary>
        private void cbDeflagrationModel_SelectionChangeCommitted(object sender, EventArgs e)
        {
            var model = (DeflagrationModel)cbDeflagrationModel.SelectedItem;

            QraStateContainer.SetValue("DeflagrationModel", model);
            UpdateCfdInput(model);
        }
Exemplo n.º 2
0
        private void WriteImpulse(PressureUnit unit, double[] values)
        {
            var valueObj = new NdConvertibleValue(StockConverters.PressureConverter, unit, values);

            QraStateContainer.SetValue("impulse", valueObj);
            //QraStateContainer.Instance.Parameters["impulse"] = ValueObj;
        }
Exemplo n.º 3
0
        private void cbRadiativeSourceModel_OnValueChanged(object sender, EventArgs e)
        {
            var newValue =
                (RadiativeSourceModels)((AnyEnumComboSelector)sender).SelectedItem;

            QraStateContainer.SetValue("RadiativeSourceModel", newValue);
        }
Exemplo n.º 4
0
 private void tbPlotTitle_TextChanged(object sender, EventArgs e)
 {
     if (tbPlotTitle.Text != null)
     {
         QraStateContainer.SetValue("PlumeWrapper.PlotTitle", tbPlotTitle.Text);
     }
     else
     {
         QraStateContainer.SetValue("PlumeWrapper.PlotTitle", "");
     }
 }
Exemplo n.º 5
0
        private void btnIgnitionProbabilitiesDelete_Click(object sender, EventArgs e)
        {
            var thresholdToRemove = Convert.ToDouble(lbIgnitionProbabilities.SelectedItem);

            if (lbIgnitionProbabilities.Items.Count > 1)
            {
                var ignitionThresholds = QraStateContainer.GetValue <double[]>("IgnitionThresholds");
                var immedIgnitionProbs = QraStateContainer.GetValue <double[]>("ImmedIgnitionProbs");
                var delayIgnitionProbs = QraStateContainer.GetValue <double[]>("DelayIgnitionProbs");

                var newIgnitionThresholds = new double[ignitionThresholds.Length - 1];
                var newImmediate = new double[immedIgnitionProbs.Length - 1];
                var newDelayed = new double[delayIgnitionProbs.Length - 1];
                int offset = 0, index = 0;
                for (var i = 0; i < ignitionThresholds.Length; ++i) //Insert new ignition threshold in order
                {
                    if (ignitionThresholds[i] == thresholdToRemove)
                    {
                        index = i;
                        ++offset;
                    }
                    else
                    {
                        newIgnitionThresholds[i - offset] = ignitionThresholds[i];
                    }
                }

                offset = 0;
                for (var i = 0; i < immedIgnitionProbs.Length; ++i)
                {
                    if (i == index)
                    {
                        ++offset;
                    }
                    else
                    {
                        newDelayed[i - offset]   = delayIgnitionProbs[i];
                        newImmediate[i - offset] = immedIgnitionProbs[i];
                    }
                }

                QraStateContainer.SetValue("IgnitionThresholds", newIgnitionThresholds);
                QraStateContainer.SetValue("ImmedIgnitionProbs", newImmediate);
                QraStateContainer.SetValue("DelayIgnitionProbs", newDelayed);
                lbIgnitionProbabilities.Items.Clear();
                dgIgnitionProbabilities.Rows.Clear();
                UpdateIgnitionProbablitiesList();
                FillIgnitionProbabilitiesTable();
            }
            else
            {
                MessageBox.Show("Error: At least one ignition threshold is required.");
            }
        }
Exemplo n.º 6
0
        private void HarvestIgnitionProbabilitiesTable()
        {
            if (!_mIgnoringChangeEvents)
            {
                var immedIgnitionProbs = HarvestDatagridColumn(dgIgnitionProbabilities, ColImmed);
                var delayIgnitionProbs = HarvestDatagridColumn(dgIgnitionProbabilities, ColDelayed);
                var ignitionThresholds = new double[lbIgnitionProbabilities.Items.Count];
                var lbItems            = new object[lbIgnitionProbabilities.Items.Count];
                lbIgnitionProbabilities.Items.CopyTo(lbItems, 0);

                for (var i = 0; i < ignitionThresholds.Length; ++i)
                {
                    ignitionThresholds[i] = (double)lbItems[i];
                }

                for (var i = 0; i < delayIgnitionProbs.Length; ++i)
                {
                    if (delayIgnitionProbs[i] < 0)
                    {
                        delayIgnitionProbs[i] = 0;
                    }

                    if (delayIgnitionProbs[i] > 1)
                    {
                        delayIgnitionProbs[i] = 1;
                    }
                }

                for (var i = 0; i < immedIgnitionProbs.Length; ++i)
                {
                    if (immedIgnitionProbs[i] < 0)
                    {
                        immedIgnitionProbs[i] = 0;
                    }

                    if (immedIgnitionProbs[i] > 1)
                    {
                        immedIgnitionProbs[i] = 1;
                    }
                }

                if (delayIgnitionProbs.Length != 0 && immedIgnitionProbs.Length != 0)
                {
                    QraStateContainer.SetValue("ImmedIgnitionProbs", immedIgnitionProbs);
                    QraStateContainer.SetValue("DelayIgnitionProbs", delayIgnitionProbs);
                    QraStateContainer.SetValue("IgnitionThresholds", ignitionThresholds);
                    //CalculateIgnitionProbabilities.Execute(ImmedIgnitionProbs, DelayIgnitionProbs, IgnitionThresholds);
                    _mIgnoringChangeEvents = true;
                    FillIgnitionProbabilitiesTableFromMemory();
                    _mIgnoringChangeEvents = false;
                }
            }
        }
Exemplo n.º 7
0
        void IQraBaseNotify.Notify_LoadComplete()
        {
            //SetNarrative();
            ContentPanel.SetNarrative(this, Narratives.DP__Data_Probabilities);
            SetDischargeCoefficient();

            UpdateIgnitionProbablitiesList();
            FillIgnitionProbabilitiesTable();

            QraStateContainer.SetValue("ResultsAreStale", true);
            _mIgnoringChangeEvents = false;
        }
Exemplo n.º 8
0
 private void ExtractAndSaveXyzValues()
 {
     if (!_mIgnoreXyzChangeEvent)
     {
         var xValues =
             ArrayFunctions.ExtractFloatArrayFromDelimitedString(tbRadiativeHeatFluxPointsX.Text, ',');
         var yValues =
             ArrayFunctions.ExtractFloatArrayFromDelimitedString(tbRadiativeHeatFluxPointsY.Text, ',');
         var zValues =
             ArrayFunctions.ExtractFloatArrayFromDelimitedString(tbRadiativeHeatFluxPointsZ.Text, ',');
         if (xValues.Length == yValues.Length && yValues.Length == zValues.Length && zValues.Length > 0)
         {
             QraStateContainer.SetValue("FlameWrapper.radiative_heat_flux_point:x",
                                        new NdConvertibleValue(StockConverters.DistanceConverter, DistanceUnit.Meter, xValues));
             QraStateContainer.SetValue("FlameWrapper.radiative_heat_flux_point:y",
                                        new NdConvertibleValue(StockConverters.DistanceConverter, DistanceUnit.Meter, yValues));
             QraStateContainer.SetValue("FlameWrapper.radiative_heat_flux_point:z",
                                        new NdConvertibleValue(StockConverters.DistanceConverter, DistanceUnit.Meter, zValues));
         }
     }
 }
Exemplo n.º 9
0
        private void cbNotionalNozzleModel_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }

            var newModel = NozzleModel.ParseNozzleModelName(cbNotionalNozzleModel.SelectedItem.ToString());

            QraStateContainer.SetValue("NozzleModel", newModel);
            //QraStateContainer.Instance.SetNozzleModel((string)cbNotionalNozzleModel.SelectedItem);
            var oldValue = _mNozzleModelSelected;

            //string NozzleName = QraStateContainer.Instance.GetObject("NotionalNozzleModel").ToString();
            //mNozzleModelSelected = QraStateContainer.Instance.GetNozzleModel();
            var oldModel = QraStateContainer.GetValue <NozzleModel>("NozzleModel");

            if (_mNozzleModelSelected != oldValue)
            {
                SpawnNotionalNozzleModelChangedEvent();
            }
        }
Exemplo n.º 10
0
 void IQraBaseNotify.Notify_LoadComplete()
 {
     SetNarrative();
     QraStateContainer.SetValue("ResultsAreStale", true);
 }
Exemplo n.º 11
0
 private void fuelTypeQra_SelectionChangeCommitted(object sender, EventArgs e)
 {
     QraStateContainer.SetValue("FuelType", fuelTypePhys.SelectedItem);
 }
Exemplo n.º 12
0
        /// <summary>
        ///     Parse selected string into Notional Nozzle Model and store it.
        /// </summary>
        private void cbNotionalNozzleModel_SelectionChangeCommitted(object sender, EventArgs e)
        {
            var model = (NozzleModel)cbNotionalNozzleModel.SelectedItem;

            QraStateContainer.SetValue("NozzleModel", model);
        }
Exemplo n.º 13
0
        private void btnIgnitionProbabilitiesAdd_Click(object sender, EventArgs e)
        {
            double newThreshold = -1;

            Parsing.TryParseDouble(tbIgnitionProbabilitiesAdd.Text, out newThreshold);
            if (newThreshold > 0.0)
            {
                var ignitionThresholds = QraStateContainer.GetValue <double[]>("IgnitionThresholds");
                var immedIgnitionProbs = QraStateContainer.GetValue <double[]>("ImmedIgnitionProbs");
                var delayIgnitionProbs = QraStateContainer.GetValue <double[]>("DelayIgnitionProbs");
                if (!ignitionThresholds.Contains(newThreshold))
                {
                    var newIgnitionThresholds = new double[ignitionThresholds.Length + 1];
                    var newImmediate = new double[immedIgnitionProbs.Length + 1];
                    var newDelayed = new double[delayIgnitionProbs.Length + 1];
                    int offset = 0, index = 0;
                    for (var i = 0; i < newIgnitionThresholds.Length; ++i) //Insert new ignition threshold in order
                    {
                        if (offset == 0 && (i == newIgnitionThresholds.Length - 1 ||
                                            ignitionThresholds[i] > newThreshold))
                        {
                            newIgnitionThresholds[i] = newThreshold;
                            index = i;
                            ++offset;
                        }
                        else
                        {
                            newIgnitionThresholds[i] = ignitionThresholds[i - offset];
                        }
                    }

                    offset = 0;
                    for (var i = 0; i < newImmediate.Length; ++i)
                    {
                        if (i == index)
                        {
                            newImmediate[i] = 0.0;
                            newDelayed[i]   = 0.0;
                            ++offset;
                        }
                        else
                        {
                            newDelayed[i]   = delayIgnitionProbs[i - offset];
                            newImmediate[i] = immedIgnitionProbs[i - offset];
                        }
                    }

                    QraStateContainer.SetValue("IgnitionThresholds", newIgnitionThresholds);
                    QraStateContainer.SetValue("ImmedIgnitionProbs", newImmediate);
                    QraStateContainer.SetValue("DelayIgnitionProbs", newDelayed);
                    lbIgnitionProbabilities.Items.Clear();
                    dgIgnitionProbabilities.Rows.Clear();
                    UpdateIgnitionProbablitiesList();
                    FillIgnitionProbabilitiesTable();
                }
                else
                {
                    MessageBox.Show(newThreshold + " is already in the list of ignition thresholds.");
                }
            }
            else
            {
                MessageBox.Show("Error: ignition threshold must be greater than zero");
            }
        }
Exemplo n.º 14
0
        void IQraBaseNotify.Notify_LoadComplete()
        {
            StartIgnoringGridChangeEvents();

            // TODO (Cianan): Can simplify all this setup by using one-way binding to objects
            ContentPanel.SetNarrative(this, Narratives.SD__System_Description);
            // Set up component grid
            var vdColl = new ParameterWrapperCollection(new[]
            {
                new ParameterWrapper("Components.NrCompressors", "# Compressors"),
                new ParameterWrapper("Components.NrCylinders", "# Cylinders"),
                new ParameterWrapper("Components.NrValves", "# Valves"),
                new ParameterWrapper("Components.NrInstruments", "# Instruments"),
                new ParameterWrapper("Components.NrJoints", "# Joints"),
                new ParameterWrapper("Components.NrHoses", "# Hoses"),
                new ParameterWrapper("Components.PipeLength", "Pipes (length)", DistanceUnit.Meter,
                                     StockConverters.DistanceConverter),
                new ParameterWrapper("Components.NrFilters", "# Filters"),
                new ParameterWrapper("Components.NrFlanges", "# Flanges"),
                new ParameterWrapper("Components.NrExtraComp1", "# Extra Component 1"),
                new ParameterWrapper("Components.NrExtraComp2", "# Extra Component 2")
            });

            StaticGridHelperRoutines.InitInteractiveGrid(dgComponents, vdColl, false);

            // Set up system params grid
            var vdColl2 = new ParameterWrapperCollection(
                new[]
            {
                new ParameterWrapper("SysParam.PipeOD", "Pipe Outer Diameter", DistanceUnit.Inch,
                                     StockConverters.DistanceConverter),
                new ParameterWrapper("SysParam.PipeWallThick", "Pipe Wall Thickness", DistanceUnit.Inch,
                                     StockConverters.DistanceConverter),
                new ParameterWrapper("SysParam.InternalTempC", "Hydrogen Temperature", TempUnit.Celsius,
                                     StockConverters.TemperatureConverter),
                new ParameterWrapper("SysParam.InternalPresMPA", "Hydrogen Pressure", PressureUnit.MPa,
                                     StockConverters.PressureConverter),
                new ParameterWrapper("SysParam.ExternalTempC", "Ambient Temperature", TempUnit.Celsius,
                                     StockConverters.TemperatureConverter),
                new ParameterWrapper("SysParam.ExternalPresMPA", "Ambient Pressure", PressureUnit.MPa,
                                     StockConverters.PressureConverter)
            }
                );

            StaticGridHelperRoutines.InitInteractiveGrid(dgSystemParameters_Piping, vdColl2, false);
            dgSystemParameters_Piping.Columns[0].Width = 200;

            // Vehicle grid
            StaticGridHelperRoutines.InitInteractiveGrid(dgSystemParameters_Vehicles, new ParameterWrapperCollection(
                                                             new[]
            {
                new ParameterWrapper("nVehicles", "Number of Vehicles"),
                new ParameterWrapper("nFuelingsPerVehicleDay", "Number of Fuelings Per Vehicle Day"),
                new ParameterWrapper("nVehicleOperatingDays", "Number of Vehicle Operating Days per Year"),
                new ParameterWrapper("nDemands", "Annual Demands (calculated)", UnitlessUnit.Unitless,
                                     StockConverters.UnitlessConverter)
            }
                                                             ), false);

            dgSystemParameters_Vehicles.Columns[0].Width = 300;
            dgSystemParameters_Vehicles.Columns[1].Width = 100;

            // Set up facility grid
            StaticGridHelperRoutines.InitInteractiveGrid(dgFacilityParameters, new ParameterWrapperCollection(
                                                             new[]
            {
                new ParameterWrapper("Facility.Length", "Length (x-direction)", DistanceUnit.Meter,
                                     StockConverters.DistanceConverter),
                new ParameterWrapper("Facility.Width", "Width (z-direction)", DistanceUnit.Meter,
                                     StockConverters.DistanceConverter),
                new ParameterWrapper("Facility.Height", "Height (y-direction)", DistanceUnit.Meter,
                                     StockConverters.DistanceConverter)
            }
                                                             ), false);

            SetOccupantInputsGrid();

            // Set up enclosure grid
            StaticGridHelperRoutines.InitInteractiveGrid(dgEnclosure, new ParameterWrapperCollection(
                                                             new[]
            {
                new ParameterWrapper("Enclosure.Height", "Height", DistanceUnit.Meter,
                                     StockConverters.DistanceConverter),
                new ParameterWrapper("Enclosure.AreaOfFloorAndCeiling", "Area (floor and ceiling)",
                                     AreaUnit.SqMeters, StockConverters.AreaConverter),
                new ParameterWrapper("Enclosure.HeightOfRelease", "Height of release", DistanceUnit.Meter,
                                     StockConverters.DistanceConverter),
                new ParameterWrapper("Enclosure.XWall", "Distance from release to wall (perpendicular)",
                                     DistanceUnit.Meter, StockConverters.DistanceConverter)
            }
                                                             ));

            // Override grid
            var overrideColl = new ParameterWrapperCollection(new[]
            {
                new ParameterWrapper("H2Release.000d01", "0.01% H2 Release"),
                new ParameterWrapper("H2Release.000d10", "0.10% H2 Release"),
                new ParameterWrapper("H2Release.001d00", "1% H2 Release"),
                new ParameterWrapper("H2Release.010d00", "10% H2 Release"),
                new ParameterWrapper("H2Release.100d00", "100% H2 Release"),
                new ParameterWrapper("Failure.ManualOverride", "100% H2 Release (accidents and shutdown failures)"),
                new ParameterWrapper("Pdetectisolate", "Gas detection credit")
            });

            StaticGridHelperRoutines.InitInteractiveGrid(dgManualOverrides, overrideColl, false);


            var ceilingVentDgv = dgCeilingVent;

            SetVentGrid(ceilingVentDgv, WhichVent.Ceiling);
            ceilingVentDgv.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);

            var floorVentDgv = dgFloorVent;

            SetVentGrid(floorVentDgv, WhichVent.Floor);

            // Set up random seed textbox
            var saveIgnoreValue = _ignoreRandomSeedChangeEvent;

            _ignoreRandomSeedChangeEvent = true;
            try
            {
                var cv = GetRandomSeedFromDatabase();
                cv.EnsureBaseValueIsTruncatedInt();
                var newValue = Math.Truncate(cv.GetValue(UnitlessUnit.Unitless)[0]);
                tbRandomSeed.Text = Parsing.DoubleToString(Math.Truncate(newValue));
            }
            finally
            {
                _ignoreRandomSeedChangeEvent = saveIgnoreValue;
            }

            // Set up exclusion textbox
            var exclusionRadius = QraStateContainer.GetNdValue("QRAD:EXCLUSIONRADIUS");

            tbExclusionRadius.Text = Parsing.DoubleToString(exclusionRadius);

            SetXLocParamAndModifyCellVisibilityInOccupantsGrid();

            StopIgnoringGridChangeEvents();
            // If check is enabled in analysis, this ensures analysis will be re-run
            QraStateContainer.SetValue("ResultsAreStale", true);

            // Remove a page that's not yet used.
            tcFacilityParameters.TabPages.Remove(tpEnclosure);
        }
Exemplo n.º 15
0
        private void WritePs(PressureUnit unit, double[] values)
        {
            var valueObj = new NdConvertibleValue(StockConverters.PressureConverter, unit, values);

            QraStateContainer.SetValue("P_s", valueObj);
        }
Exemplo n.º 16
0
 private void cbRadiativeSourceModel_OnValueChanged(object sender, EventArgs e)
 {
     QraStateContainer.SetValue("RadiativeSourceModel", cbRadiativeSourceModel.SelectedItem);
 }
Exemplo n.º 17
0
 private void cbOverpressureProbitModel_SelectionChangeCommotted(object sender, EventArgs e)
 {
     QraStateContainer.SetValue("OverpressureProbit", cbOverpressureProbitModel.SelectedItem);
 }
Exemplo n.º 18
0
        public void Execute()
        {
            var inst = QraStateContainer.Instance;

            var resultsAreStale = QraStateContainer.GetValue <bool>("ResultsAreStale");

            // Just return stored result if no inputs have changed
            if (!resultsAreStale)
            {
                return;
            }

            // Gather inputs
            var pipeLength     = QraStateContainer.GetNdValue("Components.PipeLength", DistanceUnit.Meter);
            var numCompressors = (int)QraStateContainer.GetNdValue("Components.NrCompressors");
            var numCylinders   = (int)QraStateContainer.GetNdValue("Components.NrCylinders");
            var numValves      = (int)QraStateContainer.GetNdValue("Components.NrValves");
            var numInstruments = (int)QraStateContainer.GetNdValue("Components.NrInstruments");
            var numJoints      = (int)QraStateContainer.GetNdValue("Components.NrJoints");
            var numHoses       = (int)QraStateContainer.GetNdValue("Components.NrHoses");
            var numFilters     = (int)QraStateContainer.GetNdValue("Components.NrFilters");
            var numFlanges     = (int)QraStateContainer.GetNdValue("Components.NrFlanges");
            var numExtraComp1  = (int)QraStateContainer.GetNdValue("Components.NrExtraComp1");
            var numExtraComp2  = (int)QraStateContainer.GetNdValue("Components.NrExtraComp2");

            var facilLength = QraStateContainer.GetNdValue("Facility.Length", DistanceUnit.Meter);
            var facilWidth  = QraStateContainer.GetNdValue("Facility.Width", DistanceUnit.Meter);
            var facilHeight = QraStateContainer.GetNdValue("Facility.Height", DistanceUnit.Meter);

            var pipeOuterD    = QraStateContainer.GetNdValue("SysParam.PipeOD", DistanceUnit.Meter);
            var pipeThickness = QraStateContainer.GetNdValue("SysParam.PipeWallThick", DistanceUnit.Meter);
            var h2Temp        = QraStateContainer.GetNdValue("SysParam.InternalTempC", TempUnit.Kelvin);
            var h2Pres        = QraStateContainer.GetNdValue("SysParam.InternalPresMPA", PressureUnit.Pa);
            var ambTemp       = QraStateContainer.GetNdValue("SysParam.ExternalTempC", TempUnit.Kelvin);
            var ambPres       = QraStateContainer.GetNdValue("SysParam.ExternalPresMPa", PressureUnit.Pa);

            var dischargeCoeff   = QraStateContainer.GetNdValue("DischargeCoefficient");
            var numVehicles      = QraStateContainer.GetNdValue("nVehicles");
            var numFuelingPerDay = QraStateContainer.GetNdValue("nFuelingsPerVehicleDay");
            var numVehicleOpDays = QraStateContainer.GetNdValue("nVehicleOperatingDays");

            var immediateIgnitionProbs = (double[])inst.Parameters["ImmedIgnitionProbs"];
            var delayedIgnitionProbs   = (double[])inst.Parameters["DelayIgnitionProbs"];
            var ignitionThresholds     = (double[])inst.Parameters["IgnitionThresholds"];

            var h2Release000d01       = QraStateContainer.GetNdValue("H2Release.000d01");
            var h2Release000d10       = QraStateContainer.GetNdValue("H2Release.000d10");
            var h2Release001d00       = QraStateContainer.GetNdValue("H2Release.001d00");
            var h2Release010d00       = QraStateContainer.GetNdValue("H2Release.010d00");
            var h2Release100d00       = QraStateContainer.GetNdValue("H2Release.100d00");
            var failureManualOverride = QraStateContainer.GetNdValue("Failure.ManualOverride");
            //double? FailureManualOverride = QraStateContainer.GetValue<double?>("Failure.ManualOverride");

            // Note (Cianan): this is currently always true
            var detectGasAndFlame = inst.GasAndFlameDetectionOn;
            var gasDetectCredit   = QraStateContainer.GetNdValue("PdetectIsolate");

            var probitThermalModelId = QraStateContainer.GetValue <ThermalProbitModel>("ThermalProbit").GetKey();
            var thermalExposureTime  =
                QraStateContainer.GetNdValue("t_expose_thermal", ElapsingTimeConversionUnit.Second);

            var probitOverpModelId =
                QraStateContainer.GetValue <OverpressureProbitModel>("OverpressureProbit").GetKey();
            var peakOverpressures = QraStateContainer.GetNdValueList("P_s", PressureUnit.Pa);
            var overpImpulses     = QraStateContainer.GetNdValueList("impulse", PressureUnit.Pa);
            // NOTE (Cianan): These aren't used yet
            double overpFragMass  = 0;
            double overpVelocity  = 0;
            double overpTotalMass = 0;

            var radSourceModel =
                QraStateContainer.GetValue <RadiativeSourceModels>("RadiativeSourceModel").ToString();
            var notionalNozzleModel = QraStateContainer.GetValue <NozzleModel>("NozzleModel").GetKey();
            var leakHeight          = QraStateContainer.GetNdValue("LeakHeight", DistanceUnit.Meter);
            var releaseAngle        = QraStateContainer.GetNdValue("ReleaseAngle", AngleUnit.Degrees);

            var exclusionRadius = QraStateContainer.GetNdValue("QRAD:EXCLUSIONRADIUS");
            var randomSeed      = (int)QraStateContainer.GetNdValue("RANDOMSEED");
            var relativeHumid   = QraStateContainer.GetNdValue("FlameWrapper.RH");

            var occupantDistributions =
                (OccupantDistributionInfoCollection)inst.Parameters["OccupantDistributions"];
            var occupantJson = JsonConvert.SerializeObject(occupantDistributions);

            // Massage component probabilities into double[][]
            var compList =
                QraStateContainer.GetValue <List <ComponentProbability> >("Prob.Compressor");
            var
                cylList    = QraStateContainer.GetValue <List <ComponentProbability> >("Prob.Cylinder");
            var filterList =
                QraStateContainer.GetValue <List <ComponentProbability> >("Prob.Filter");
            var flangeList =
                QraStateContainer.GetValue <List <ComponentProbability> >("Prob.Flange");
            var hoseList  = QraStateContainer.GetValue <List <ComponentProbability> >("Prob.Hose");
            var jointList = QraStateContainer.GetValue <List <ComponentProbability> >("Prob.Joint");
            var pipeList  = QraStateContainer.GetValue <List <ComponentProbability> >("Prob.Pipe");
            var valveList = QraStateContainer.GetValue <List <ComponentProbability> >("Prob.Valve");
            var instrList =
                QraStateContainer.GetValue <List <ComponentProbability> >("Prob.Instrument");
            var ex1List = QraStateContainer.GetValue <List <ComponentProbability> >("Prob.Extra1");
            var ex2List = QraStateContainer.GetValue <List <ComponentProbability> >("Prob.Extra2");

            // TODO (Cianan): Clean this up
            // NOTE (Cianan): Python.NET can't convert nullable list (e.g. double?) into numpy arr so  mu/sigma or mean/variance are set to -1000D if null
            double[][] compressorProbs =
            {
                compList[0].GetDataForPython(), compList[1].GetDataForPython(),
                compList[2].GetDataForPython(), compList[3].GetDataForPython(),
                compList[4].GetDataForPython()
            };

            double[][] cylinderProbs =
            {
                cylList[0].GetDataForPython(), cylList[1].GetDataForPython(),
                cylList[2].GetDataForPython(), cylList[3].GetDataForPython(),
                cylList[4].GetDataForPython()
            };

            double[][] filterProbs =
            {
                filterList[0].GetDataForPython(), filterList[1].GetDataForPython(),
                filterList[2].GetDataForPython(), filterList[3].GetDataForPython(),
                filterList[4].GetDataForPython()
            };

            double[][] flangeProbs =
            {
                flangeList[0].GetDataForPython(), flangeList[1].GetDataForPython(),
                flangeList[2].GetDataForPython(), flangeList[3].GetDataForPython(),
                flangeList[4].GetDataForPython()
            };

            double[][] hoseProbs =
            {
                hoseList[0].GetDataForPython(), hoseList[1].GetDataForPython(),
                hoseList[2].GetDataForPython(), hoseList[3].GetDataForPython(),
                hoseList[4].GetDataForPython()
            };

            double[][] jointProbs =
            {
                jointList[0].GetDataForPython(), jointList[1].GetDataForPython(),
                jointList[2].GetDataForPython(), jointList[3].GetDataForPython(),
                jointList[4].GetDataForPython()
            };

            double[][] pipeProbs =
            {
                pipeList[0].GetDataForPython(), pipeList[1].GetDataForPython(),
                pipeList[2].GetDataForPython(), pipeList[3].GetDataForPython(),
                pipeList[4].GetDataForPython()
            };

            double[][] valveProbs =
            {
                valveList[0].GetDataForPython(), valveList[1].GetDataForPython(),
                valveList[2].GetDataForPython(), valveList[3].GetDataForPython(),
                valveList[4].GetDataForPython()
            };

            double[][] instrumentProbs =
            {
                instrList[0].GetDataForPython(), instrList[1].GetDataForPython(),
                instrList[2].GetDataForPython(), instrList[3].GetDataForPython(),
                instrList[4].GetDataForPython()
            };

            double[][] extraComp1Probs =
            {
                ex1List[0].GetDataForPython(), ex1List[1].GetDataForPython(),
                ex1List[2].GetDataForPython(), ex1List[3].GetDataForPython(),
                ex1List[4].GetDataForPython()
            };

            double[][] extraComp2Probs =
            {
                ex2List[0].GetDataForPython(), ex2List[1].GetDataForPython(),
                ex2List[2].GetDataForPython(), ex2List[3].GetDataForPython(),
                ex2List[4].GetDataForPython()
            };

            var nozPo     = QraStateContainer.GetValue <FailureMode>("Failure.NozPO");
            var nozFtc    = QraStateContainer.GetValue <FailureMode>("Failure.NozFTC");
            var mValveFtc = QraStateContainer.GetValue <FailureMode>("Failure.MValveFTC");
            var sValveFtc = QraStateContainer.GetValue <FailureMode>("Failure.SValveFTC");
            var sValveCcf = QraStateContainer.GetValue <FailureMode>("Failure.SValveCCF");

            var overpFail    = QraStateContainer.GetValue <FailureMode>("Failure.Overp");
            var pValveFto    = QraStateContainer.GetValue <FailureMode>("Failure.PValveFTO");
            var driveoffFail = QraStateContainer.GetValue <FailureMode>("Failure.Driveoff");
            var couplingFtc  = QraStateContainer.GetValue <FailureMode>("Failure.CouplingFTC");

            var nozPoDist   = nozPo.Dist.ToString();
            var nozPoParamA = nozPo.ParamA;
            var nozPoParamB = nozPo.ParamB;

            var nozFtcDist   = nozFtc.Dist.ToString();
            var nozFtcParamA = nozFtc.ParamA;
            var nozFtcParamB = nozFtc.ParamB;

            var mValveFtcDist   = mValveFtc.Dist.ToString();
            var mValveFtcParamA = mValveFtc.ParamA;
            var mValveFtcParamB = mValveFtc.ParamB;

            var sValveFtcDist   = sValveFtc.Dist.ToString();
            var sValveFtcParamA = sValveFtc.ParamA;
            var sValveFtcParamB = sValveFtc.ParamB;

            var sValveCcfDist   = sValveCcf.Dist.ToString();
            var sValveCcfParamA = sValveCcf.ParamA;
            var sValveCcfParamB = sValveCcf.ParamB;

            var overpDist   = overpFail.Dist.ToString();
            var overpParamA = overpFail.ParamA;
            var overpParamB = overpFail.ParamB;

            var pValveFtoDist   = pValveFto.Dist.ToString();
            var pValveFtoParamA = pValveFto.ParamA;
            var pValveFtoParamB = pValveFto.ParamB;

            var driveoffDist   = driveoffFail.Dist.ToString();
            var driveoffParamA = driveoffFail.ParamA;
            var driveoffParamB = driveoffFail.ParamB;

            var couplingFtcDist   = couplingFtc.Dist.ToString();
            var couplingFtcParamA = couplingFtc.ParamA;
            var couplingFtcParamB = couplingFtc.ParamB;

            // Derive path to data dir for temp and data files, e.g. pickling
            var dataDirLoc = QraStateContainer.UserDataDir;

            QraResult result;

            using (Py.GIL())
            {
                //var lck = PythonEngine.AcquireLock();
                dynamic pyQraLib = Py.Import("hyram");

                try
                {
                    // Execute python analysis. Will return PyObject which is parsed in QRAResult.
                    var resultPyObj = pyQraLib.qra.capi.conduct_analysis(
                        pipeLength, numCompressors, numCylinders, numValves, numInstruments, numJoints, numHoses,
                        numFilters, numFlanges, numExtraComp1, numExtraComp2,
                        facilLength, facilWidth, facilHeight,
                        pipeOuterD, pipeThickness,
                        h2Temp, h2Pres, ambTemp, ambPres, dischargeCoeff,
                        numVehicles, numFuelingPerDay, numVehicleOpDays,
                        immediateIgnitionProbs, delayedIgnitionProbs, ignitionThresholds,
                        detectGasAndFlame, gasDetectCredit,
                        probitThermalModelId, thermalExposureTime,
                        probitOverpModelId, peakOverpressures, overpImpulses, overpFragMass, overpVelocity,
                        overpTotalMass,
                        radSourceModel, notionalNozzleModel,
                        leakHeight, releaseAngle,
                        exclusionRadius, randomSeed, relativeHumid,
                        occupantJson,
                        compressorProbs, cylinderProbs, valveProbs, instrumentProbs, pipeProbs, jointProbs, hoseProbs,
                        filterProbs, flangeProbs, extraComp1Probs, extraComp2Probs,
                        nozPoDist, nozPoParamA, nozPoParamB,
                        nozFtcDist, nozFtcParamA, nozFtcParamB,
                        mValveFtcDist, mValveFtcParamA, mValveFtcParamB,
                        sValveFtcDist, sValveFtcParamA, sValveFtcParamB,
                        sValveCcfDist, sValveCcfParamA, sValveCcfParamB,
                        overpDist, overpParamA, overpParamB,
                        pValveFtoDist, pValveFtoParamA, pValveFtoParamB,
                        driveoffDist, driveoffParamA, driveoffParamB,
                        couplingFtcDist, couplingFtcParamA, couplingFtcParamB,
                        h2Release000d01, h2Release000d10, h2Release001d00, h2Release010d00, h2Release100d00,
                        failureManualOverride,
                        dataDirLoc
                        );

                    result = new QraResult(resultPyObj);
                    QraStateContainer.SetValue("ResultsAreStale", false);
                    QraStateContainer.SetValue("Result", result);
                }
                catch (PythonException ex)
                {
                    QraStateContainer.SetValue("ResultsAreStale", true);
                    Trace.TraceError(ex.Message);
                    Debug.WriteLine(ex.Message);
                    throw new InvalidOperationException(
                              "Something went wrong during PyQRA execution. Check log for details.");
                }
                catch (Exception ex)
                {
                    Trace.TraceError(ex.Message);
                    QraStateContainer.SetValue("ResultsAreStale", true);
                    throw ex;
                }
                finally
                {
                    // Force display of stderr, stdout. This includes print statements from python
                    Console.Out.Flush();
                    Console.Error.Flush();

                    // Unload imports
                    pyQraLib.Dispose();
                    //PythonEngine.ReleaseLock(lck);
                }
            }
        }