protected override void OnCreate() { base.OnCreate(); MaterialComponents.Init(DirectoryInfo.Resource); NativeParent = MainWindow; LoadApplication(new App()); }
protected override void OnCreate() { base.OnCreate(); MaterialComponents.Init(DirectoryInfo.Resource); LoadApplication(formsApp ??= new App()); }
protected override void OnCreate() { base.OnCreate(); MaterialComponents.Init(DirectoryInfo.Resource); Microsoft.Maui.Essentials.Platform.Init(MainWindow); LoadApplication(formsApp ??= new App()); }
void Initialize() { ResourceDir = DirectoryInfo.Resource; MaterialGallery.ResourceDir = DirectoryInfo.Resource; MaterialComponents.Init(ResourceDir, new InitializationOptions { ThrowOnValidateComponentErrors = false }); _window = new Window("WatchMaterialGallery") { AvailableRotations = DisplayRotation.Degree_0 | DisplayRotation.Degree_180 | DisplayRotation.Degree_270 | DisplayRotation.Degree_90 }; _window.BackButtonPressed += (s, e) => { Exit(); }; _window.Show(); _screenWidth = _window.ScreenSize.Width; CreateTestPage(_window); }
void Initialize() { ResourceDir = DirectoryInfo.Resource; MaterialComponents.Init(ResourceDir, new InitializationOptions { ThrowOnValidateComponentErrors = false }); _mainWindow = new Window("MaterialGallery"); _mainWindow.Show(); _mainWindow.BackButtonPressed += (s, e) => { UIExit(); }; var conformant = new Conformant(_mainWindow); conformant.Show(); var box = new Box(_mainWindow) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; box.Show(); var bg = new Background(_mainWindow) { Color = Color.White }; bg.SetContent(box); conformant.SetContent(bg); GenList list = new GenList(_mainWindow) { Homogeneous = true, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1 }; GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (data, part) => { BaseGalleryPage page = data as BaseGalleryPage; return(page == null ? "" : page.Name); } }; foreach (var page in GetGalleryPage()) { list.Append(defaultClass, page); } if (MaterialComponents.Profile == TargetProfile.Wearable) { list.Prepend(defaultClass, null); list.Append(defaultClass, null); } list.ItemSelected += (s, e) => { BaseGalleryPage page = e.Item.Data as BaseGalleryPage; RunGalleryPage(page); }; list.Show(); box.PackEnd(list); }
private void Solve() { SubstanceCatalog catalog = SubstanceCatalog.GetInstance(); Substance carbon = catalog.GetSubstance("carbon"); Substance hydrogen = catalog.GetSubstance("hydrogen"); Substance oxygen = catalog.GetSubstance("oxygen"); Substance sulfur = catalog.GetSubstance("sulfur"); Substance air = catalog.GetSubstance("air"); Substance carbonDioxide = catalog.GetSubstance("carbon dioxide"); Substance sulfurDioxide = catalog.GetSubstance("sulfur dioxide"); Substance water = catalog.GetSubstance("water"); Substance nitrogen = catalog.GetSubstance("nitrogen"); Substance argon = catalog.GetSubstance("argon"); //Substance ash = SubstanceCatalog.GetInstance().GetSubstance("ash"); double totalEenthalpyOfReactantInFuelInlet = 0; double moleFractionCarbon = 0; double moleFractionHydrogen = 0; double moleFractionSulfur = 0; double moleFractionOxygen = 0; //double massAsh = 0; double moleFractionCarbonDioxide = 0; double moleFractionNitrogen = 0; MaterialComponents components = fuelInlet.Components; MaterialComponent component; Substance mySubstance; double myMassFraction; if (fuelInlet is GenericFuelStream) { for (int i = 0; i < components.Count; i++) { component = components[i]; mySubstance = component.Substance; myMassFraction = component.MassFraction.Value; if (mySubstance == carbon) { moleFractionCarbon = myMassFraction / carbon.MolarWeight; } else if (mySubstance == hydrogen) { moleFractionHydrogen = 0.5 * myMassFraction / hydrogen.MolarWeight; } else if (mySubstance == oxygen) { moleFractionOxygen = myMassFraction / oxygen.MolarWeight; } else if (mySubstance == sulfur) { moleFractionSulfur = myMassFraction / sulfur.MolarWeight; } //else if (component.Substance == ash) { // massAsh = myMassFraction; //} } } else if (fuelInlet is DetailedFuelStream) { totalEenthalpyOfReactantInFuelInlet = 0; moleFractionCarbon = 0; moleFractionHydrogen = 0; moleFractionOxygen = 0; moleFractionSulfur = 0; SubstanceFormula formula; string[] elements; int elementCount; double t = fuelInlet.Temperature.Value; for (int i = 0; i < components.Count; i++) { component = components[i]; mySubstance = component.Substance; myMassFraction = component.MassFraction.Value; if (mySubstance == carbonDioxide) { moleFractionCarbonDioxide = myMassFraction / carbonDioxide.MolarWeight; } else if (mySubstance == nitrogen) { moleFractionNitrogen = myMassFraction / nitrogen.MolarWeight; } else { totalEenthalpyOfReactantInFuelInlet += myMassFraction * ThermalPropCalculator.Instance.CalculateEnthalpyOfFormation(t, mySubstance); formula = mySubstance.Formula; elements = formula.Elements; foreach (string element in elements) { elementCount = formula.GetElementCount(element); if (element == "C") { moleFractionCarbon += elementCount * myMassFraction / carbon.MolarWeight; } else if (element == "H") { moleFractionHydrogen += elementCount * 0.25 * myMassFraction / hydrogen.MolarWeight; } else if (element == "O") { moleFractionOxygen = elementCount * 0.5 * myMassFraction / oxygen.MolarWeight; } else if (element == "S") { moleFractionSulfur += elementCount * myMassFraction / sulfur.MolarWeight; } } } } } double fuelMassFlowRate = fuelInlet.MassFlowRate.Value; double moleFractionOxygenNeeded = moleFractionCarbon + moleFractionHydrogen + moleFractionSulfur - moleFractionOxygen; double totalExactOxygenMassNeeded = fuelMassFlowRate * moleFractionOxygenNeeded * oxygen.MolarWeight; double totalOxygenMoleNeeded = fuelMassFlowRate * moleFractionOxygenNeeded * (1.0 + excessAir.Value); double totalDryAirMassNeeded = totalOxygenMoleNeeded * air.MolarWeight / 0.21; double totalMoistureMassCarriedByInletAir = totalDryAirMassNeeded * airInlet.Humidity.Value; double totalAirMassNeeded = totalDryAirMassNeeded + totalMoistureMassCarriedByInletAir; Calculate(airInlet.MassFlowRate, totalAirMassNeeded); double totalMoitureGeneratedByReaction = fuelMassFlowRate * moleFractionHydrogen * water.MolarWeight; double totalMoistureInFlueGas = totalMoitureGeneratedByReaction + totalMoistureMassCarriedByInletAir; double totalDryFlueGas = totalDryAirMassNeeded + fuelMassFlowRate - totalMoitureGeneratedByReaction; double totalFlueGasGenerated = totalDryFlueGas + totalMoistureInFlueGas; Calculate(flueGasOutlet.MassFlowRate, totalFlueGasGenerated); double flueGasMoistureContentDryBase = totalMoistureInFlueGas / totalDryFlueGas; Calculate(flueGasOutlet.Humidity, flueGasMoistureContentDryBase); ArrayList componentList = new ArrayList(); double massFractionCarbonDioxide = fuelMassFlowRate * (moleFractionCarbon + moleFractionCarbonDioxide) * carbonDioxide.MolarWeight / totalDryFlueGas; componentList.Add(new MaterialComponent(carbonDioxide, massFractionCarbonDioxide)); double massFractionNitrogen = (totalDryAirMassNeeded * 0.78 + fuelMassFlowRate * moleFractionNitrogen) / totalDryFlueGas; componentList.Add(new MaterialComponent(nitrogen, massFractionNitrogen)); double massFractionSulfurDioxide = fuelMassFlowRate * moleFractionSulfur * sulfurDioxide.MolarWeight / totalDryFlueGas; componentList.Add(new MaterialComponent(sulfurDioxide, massFractionSulfurDioxide)); double massFractionOxygen = fuelMassFlowRate * moleFractionOxygenNeeded * excessAir.Value * oxygen.MolarWeight / totalDryFlueGas; componentList.Add(new MaterialComponent(oxygen, massFractionOxygen)); double massFractionArgon = totalDryAirMassNeeded * 0.01 / totalDryFlueGas; componentList.Add(new MaterialComponent(argon, massFractionArgon)); CompositeSubstance flueGas = new CompositeSubstance("Flue Gas", componentList); MaterialComponents flueGasComponents = new MaterialComponents(); flueGasComponents.Add(new MaterialComponent(flueGas, 1 / (1 + flueGasMoistureContentDryBase))); flueGasComponents.Add(new MaterialComponent(water, flueGasMoistureContentDryBase / (1 + flueGasMoistureContentDryBase))); flueGasOutlet.Components = flueGasComponents; double fuelInletEnthalpy = fuelMassFlowRate * fuelInlet.SpecificEnthalpy.Value; double airInletEnthalpy = totalAirMassNeeded * airInlet.SpecificEnthalpy.Value; double totalHeatGenerated = Constants.NO_VALUE; if (fuelInlet is GenericFuelStream) { GenericFuelStream gfs = fuelInlet as GenericFuelStream; if (gfs.HeatValue.HasValue) { //total heat genrate eaquls to heat value of the fuel times fuelMassFlowRate totalHeatGenerated = gfs.HeatValue.Value * fuelMassFlowRate; double totalFlueGasSpecificEnthalpy = (fuelInletEnthalpy + airInletEnthalpy + totalHeatGenerated) / totalFlueGasGenerated; Calculate(flueGasOutlet.SpecificEnthalpy, totalFlueGasSpecificEnthalpy); } } else if (fuelInlet is DetailedFuelStream) { HumidGasCalculator humidGasCalculator = new HumidGasCalculator(flueGas, water); ThermalPropCalculator propCalculator = ThermalPropCalculator.Instance; double totalEenthalpyOfProductCarbonDioxide; double totalEenthalpyOfProductWater; double totalEenthalpyOfProductSulfer; double totalEenthalpyOfProduct; double totalFlueGasSpecificEnthalpy; double t = fuelInlet.Temperature.Value;; totalEenthalpyOfReactantInFuelInlet *= fuelMassFlowRate; double totalEnthalpyOfReactantOxygen = totalExactOxygenMassNeeded * propCalculator.CalculateEnthalpyOfFormation(t, oxygen); double totalEenthalpyOfReactants = totalEenthalpyOfReactantInFuelInlet + totalEnthalpyOfReactantOxygen; double p = flueGasOutlet.Pressure.Value; double tNew = t; int counter = 0; do { counter++; t = tNew; totalEenthalpyOfProductCarbonDioxide = fuelMassFlowRate * moleFractionCarbon * propCalculator.CalculateEnthalpyOfFormation(t, carbonDioxide); totalEenthalpyOfProductWater = fuelMassFlowRate * moleFractionHydrogen * propCalculator.CalculateEnthalpyOfFormation(t, water); totalEenthalpyOfProductSulfer = fuelMassFlowRate * moleFractionSulfur * propCalculator.CalculateEnthalpyOfFormation(t, sulfurDioxide); totalEenthalpyOfProduct = totalEenthalpyOfProductCarbonDioxide + totalEenthalpyOfProductWater + totalEenthalpyOfProductSulfer; totalHeatGenerated = totalEenthalpyOfProduct - totalEenthalpyOfReactants; totalFlueGasSpecificEnthalpy = (fuelInletEnthalpy + airInletEnthalpy + totalHeatGenerated) / totalFlueGasGenerated; tNew = humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(totalFlueGasSpecificEnthalpy, flueGasMoistureContentDryBase, p); } while (Math.Abs(tNew - t) < 1.0e-6 && counter < 100); if (counter == 100) { } Calculate(flueGasOutlet.Temperature, tNew); } }
protected override void OnCreate() { base.OnCreate(); MaterialComponents.Init(DirectoryInfo.Resource); }
private void Solve() { double totalEenthalpyOfReactantInFuelInlet = 0; double moleFractionCarbon = 0; double moleFractionHydrogen = 0; double moleFractionSulfur = 0; double moleFractionOxygen = 0; //double massAsh = 0; double moleFractionCarbonDioxide = 0; double moleFractionNitrogen = 0; //mole fraction of nitrogen in original gas fuel MaterialComponents components = fuelInlet.Components; if (fuelInlet is GenericFuelStream) { for (int i = 0; i < components.Count; i++) { MaterialComponent component = components[i]; Substance mySubstance = component.Substance; //myMassFraction = component.MassFraction.Value; double myMoleFraction = component.MoleFraction.Value; if (mySubstance == carbon) { moleFractionCarbon = myMoleFraction; } else if (mySubstance == hydrogen) { moleFractionHydrogen = myMoleFraction; } else if (mySubstance == oxygen) { moleFractionOxygen = myMoleFraction; } else if (mySubstance == sulfur) { moleFractionSulfur = myMoleFraction; } //else if (component.Substance == ash) { // massAsh = myMassFraction; //} } } else if (fuelInlet is DetailedFuelStream) { totalEenthalpyOfReactantInFuelInlet = 0; moleFractionCarbon = 0; moleFractionHydrogen = 0; moleFractionOxygen = 0; moleFractionSulfur = 0; double t = fuelInlet.Temperature.Value; for (int i = 0; i < components.Count; i++) { MaterialComponent component = components[i]; Substance mySubstance = component.Substance; double myMoleFraction = component.MoleFraction.Value; if (mySubstance == carbonDioxide) { moleFractionCarbonDioxide = myMoleFraction; } else if (mySubstance == nitrogen) { moleFractionNitrogen = myMoleFraction; } else { totalEenthalpyOfReactantInFuelInlet += myMoleFraction * propCalculator.CalculateEnthalpyOfFormation(t, mySubstance); SubstanceFormula formula = mySubstance.Formula; string[] elements = formula.Elements; foreach (string element in elements) { int elementCount = formula.GetElementCount(element); if (element == "C") { moleFractionCarbon += elementCount * myMoleFraction; } else if (element == "H") { moleFractionHydrogen += elementCount * myMoleFraction; } else if (element == "O") { moleFractionOxygen += elementCount * myMoleFraction; } else if (element == "S") { moleFractionSulfur += elementCount * myMoleFraction; } } } } } moleFractionHydrogen = 0.5 * moleFractionHydrogen; //convert from H to H2 moleFractionOxygen = 0.5 * moleFractionOxygen; //convert from O to O2 //multiply 0.5 for moleFractionHydrogen because 1 mole of H2 only needs 0.5 mole of O2 double moleFractionOxygenNeeded = moleFractionCarbon + 0.5 * moleFractionHydrogen + moleFractionSulfur - moleFractionOxygen; double exactDryAirMassNeeded = moleFractionOxygenNeeded / OXYGEN_MOLE_FRACTION_IN_AIR * air.MolarWeight; double excessAirValue = excessAir.HasValue ? excessAir.Value / 100 : 0; double excessDryAirNeeded = exactDryAirMassNeeded * excessAirValue; double dryAirMassNeeded = exactDryAirMassNeeded + excessDryAirNeeded; double moistureMassCarriedByInletAir = dryAirMassNeeded * airInlet.Humidity.Value; double airMassNeeded = dryAirMassNeeded + moistureMassCarriedByInletAir; double moitureGeneratedByReaction = moleFractionHydrogen * water.MolarWeight; //since 1 mole of H2 generates 1 mole of water double totalMoistureInFlueGas = moitureGeneratedByReaction + moistureMassCarriedByInletAir; double flueGasTotal = airMassNeeded + fuelInlet.Components.MolarWeight; double dryFlueGas = flueGasTotal - totalMoistureInFlueGas; double flueGasMoistureContentDryBase = totalMoistureInFlueGas / dryFlueGas; CompositeSubstance flueGas = CreateDryFlueGasSubstance(moleFractionCarbon, moleFractionSulfur, moleFractionCarbonDioxide, moleFractionNitrogen, moleFractionOxygenNeeded, dryAirMassNeeded, dryFlueGas, excessAirValue); DryingGasComponents flueGasComponents = CreateDryingGasComponents(flueGasMoistureContentDryBase, flueGas); flueGasOutlet.GasComponents = flueGasComponents; double fuelMoleFlowRate = fuelInlet.MoleFlowRate.Value; if (excessAir.HasValue) { Calculate(flueGasOutlet.Humidity, flueGasMoistureContentDryBase); if (fuelInlet.MoleFlowRate.HasValue) { Calculate(airInlet.MassFlowRateDryBase, dryAirMassNeeded * fuelMoleFlowRate); Calculate(flueGasOutlet.MassFlowRate, flueGasTotal * fuelMoleFlowRate); } else if (flueGasOutlet.MassFlowRate.HasValue) { fuelMoleFlowRate = flueGasOutlet.MassFlowRate.Value / flueGasTotal; Calculate(fuelInlet.MoleFlowRate, fuelMoleFlowRate); Calculate(airInlet.MassFlowRateDryBase, dryAirMassNeeded * fuelMoleFlowRate); } } double fuelInletEnthalpy = fuelInlet.SpecificEnthalpy.Value; double airInletEnthalpy = airMassNeeded * airInlet.SpecificEnthalpy.Value; double totalHeatGenerated = Constants.NO_VALUE; double heatLossValue = 0; if (fuelInlet is GenericFuelStream) { //GenericFuelStream gfs = fuelInlet as GenericFuelStream; //if (gfs.HeatValue.HasValue) { // //total heat genrate eaquls to heat value of the fuel times fuelMassFlowRate // totalHeatGenerated = gfs.HeatValue.Value * fuelMoleFlowRate; // heatLossValue = totalHeatGenerated * percentageHeatLoss.Value / 100; // double totalFlueGasSpecificEnthalpy = (fuelInletEnthalpy + airInletEnthalpy + totalHeatGenerated - heatLossValue) / flueGasTotal; // Calculate(flueGasOutlet.SpecificEnthalpy, totalFlueGasSpecificEnthalpy); //} } else if (fuelInlet is DetailedFuelStream) { HumidGasCalculator humidGasCalculator = new HumidGasCalculator(flueGas, water); //evaporation heat of 2 moles of water double evaporationHeat = 2.0 * water.MolarWeight * humidGasCalculator.GetEvaporationHeat(273.15); double p = flueGasOutlet.Pressure.Value; //double originalTemperature = airInlet.Temperature.Value; //double initialHumidEnthalpy = humidGasCalculator.GetHumidEnthalpyFromDryBulbHumidityAndPressure(originalTemperature, flueGasMoistureContentDryBase, p); double initialHumidEnthalpy = airInlet.SpecificEnthalpyDryBase.Value; initialHumidEnthalpy = initialHumidEnthalpy * dryAirMassNeeded / dryFlueGas; double t = airInlet.Temperature.Value; double totalEnthalpyOfReactantOxygen = moleFractionOxygenNeeded * propCalculator.CalculateEnthalpyOfFormation(t, oxygen); double totalEenthalpyOfReactants = totalEenthalpyOfReactantInFuelInlet + totalEnthalpyOfReactantOxygen; double tNew = t; int counter = 0; if (excessAir.HasValue && percentageHeatLoss.IsSpecifiedAndHasValue) { do { counter++; t = tNew; double totalEenthalpyOfProduct = CalculateTotalEntalpyOfProduct(moleFractionCarbon, moleFractionHydrogen, moleFractionSulfur, t); totalHeatGenerated = totalEenthalpyOfReactants - totalEenthalpyOfProduct + evaporationHeat; heatLossValue = totalHeatGenerated * percentageHeatLoss.Value / 100; double flueGasHumidEnthalpy = initialHumidEnthalpy + (totalHeatGenerated - heatLossValue) / dryFlueGas; tNew = humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(flueGasHumidEnthalpy, flueGasMoistureContentDryBase, p); } while (Math.Abs(tNew - t) / tNew > 1.0e-8 && counter < 100); if (counter == 100) { throw new CalculationFailedException("Calculation of flame temperature failed."); } Calculate(flueGasOutlet.Temperature, tNew); totalHeatGenerated *= fuelMoleFlowRate; Calculate(heatLoss, totalHeatGenerated * percentageHeatLoss.Value / 100); } else if (excessAir.HasValue && flueGasOutlet.Temperature.IsSpecifiedAndHasValue) { double flueGasTemp = flueGasOutlet.Temperature.Value; double totalEenthalpyOfProduct = CalculateTotalEntalpyOfProduct(moleFractionCarbon, moleFractionHydrogen, moleFractionSulfur, flueGasTemp); totalHeatGenerated = totalEenthalpyOfReactants - totalEenthalpyOfProduct + evaporationHeat; heatLossValue = totalHeatGenerated * percentageHeatLoss.Value / 100; double flueGasHumidEnthalpy = initialHumidEnthalpy + (totalHeatGenerated - heatLossValue) / dryFlueGas; tNew = humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(flueGasHumidEnthalpy, flueGasMoistureContentDryBase, p); if (tNew < flueGasTemp) { throw new CalculationFailedException("Specified flue gas temperature cannot be reached."); } counter = 0; double humidEnthanlpy0 = humidGasCalculator.GetHumidEnthalpyFromDryBulbHumidityAndPressure(flueGasTemp, flueGasMoistureContentDryBase, p); do { counter++; double humidEnthanlpy1 = humidGasCalculator.GetHumidEnthalpyFromDryBulbHumidityAndPressure(tNew, flueGasMoistureContentDryBase, p); heatLossValue += dryFlueGas * (humidEnthanlpy1 - humidEnthanlpy0); flueGasHumidEnthalpy = initialHumidEnthalpy + (totalHeatGenerated - heatLossValue) / dryFlueGas; tNew = humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(flueGasHumidEnthalpy, flueGasMoistureContentDryBase, p); } while (Math.Abs(tNew - flueGasTemp) / flueGasTemp > 1.0e-8 && counter < 100); if (counter == 100) { throw new CalculationFailedException("Calculation of flame temperature failed."); } totalHeatGenerated *= fuelMoleFlowRate; heatLossValue *= fuelMoleFlowRate; Calculate(heatLoss, heatLossValue); Calculate(percentageHeatLoss, heatLossValue / totalHeatGenerated * 100); } else if (flueGasOutlet.Temperature.IsSpecifiedAndHasValue && percentageHeatLoss.IsSpecifiedAndHasValue) { double flueGasTemp = flueGasOutlet.Temperature.Value; double totalEenthalpyOfProduct = CalculateTotalEntalpyOfProduct(moleFractionCarbon, moleFractionHydrogen, moleFractionSulfur, flueGasTemp); totalHeatGenerated = totalEenthalpyOfReactants - totalEenthalpyOfProduct + evaporationHeat; heatLossValue = totalHeatGenerated * percentageHeatLoss.Value / 100; double flueGasHumidEnthalpy = initialHumidEnthalpy + (totalHeatGenerated - heatLossValue) / dryFlueGas; tNew = humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(flueGasHumidEnthalpy, flueGasMoistureContentDryBase, p); if (tNew < flueGasTemp) { throw new CalculationFailedException("Specified flue gas temperature cannot be reached."); } //double excessDryAirNeededOld; do { counter++; t = tNew; //excessDryAirNeededOld = excessDryAirNeeded; //initialHumidEnthalpy = humidGasCalculator.GetHumidEnthalpyFromDryBulbHumidityAndPressure(originalTemperature, flueGasMoistureContentDryBase, p); flueGasHumidEnthalpy = humidGasCalculator.GetHumidEnthalpyFromDryBulbHumidityAndPressure(flueGasTemp, flueGasMoistureContentDryBase, p); dryFlueGas = (totalHeatGenerated - heatLossValue) / (flueGasHumidEnthalpy - initialHumidEnthalpy); flueGasTotal = dryFlueGas + totalMoistureInFlueGas; airMassNeeded = flueGasTotal - fuelInlet.Components.MolarWeight; dryAirMassNeeded = airMassNeeded / (1 + airInlet.Humidity.Value); totalMoistureInFlueGas = moitureGeneratedByReaction + dryAirMassNeeded * airInlet.Humidity.Value; excessDryAirNeeded = dryAirMassNeeded - exactDryAirMassNeeded; excessAirValue = excessDryAirNeeded / exactDryAirMassNeeded; flueGasMoistureContentDryBase = totalMoistureInFlueGas / dryFlueGas; flueGas = CreateDryFlueGasSubstance(moleFractionCarbon, moleFractionSulfur, moleFractionCarbonDioxide, moleFractionNitrogen, moleFractionOxygenNeeded, dryAirMassNeeded, dryFlueGas, excessAirValue); humidGasCalculator = new HumidGasCalculator(flueGas, water); tNew = humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(flueGasHumidEnthalpy, flueGasMoistureContentDryBase, p); } while (Math.Abs(tNew - flueGasTemp) / flueGasTemp > 1.0e-8 && counter < 100); //} while (Math.Abs(excessDryAirNeeded - excessDryAirNeededOld) > 1.0e-6 && counter < 100); if (counter == 100) { throw new CalculationFailedException("Calculation of flame temperature failed."); } Calculate(flueGasOutlet.Humidity, flueGasMoistureContentDryBase); Calculate(excessAir, excessAirValue * 100); flueGasComponents = CreateDryingGasComponents(flueGasMoistureContentDryBase, flueGas); flueGasOutlet.GasComponents = flueGasComponents; if (flueGasOutlet.MassFlowRate.IsSpecifiedAndHasValue) { fuelMoleFlowRate = flueGasOutlet.MassFlowRate.Value / flueGasTotal; Calculate(fuelInlet.MoleFlowRate, fuelMoleFlowRate); } else { Calculate(flueGasOutlet.MassFlowRate, flueGasTotal * fuelMoleFlowRate); } Calculate(airInlet.MassFlowRateDryBase, dryAirMassNeeded * fuelMoleFlowRate); Calculate(heatLoss, heatLossValue * fuelMoleFlowRate); totalHeatGenerated *= fuelMoleFlowRate; } Calculate(totalHeatGeneration, totalHeatGenerated); } if (flueGasOutlet.Temperature.HasValue && totalHeatGeneration.HasValue) { solveState = SolveState.Solved; double oxygenMassFraction = moleFractionOxygenNeeded * excessAirValue * oxygen.MolarWeight / flueGasTotal; double oxygenMoleFraction = moleFractionOxygenNeeded * excessAirValue / (1 + airMassNeeded / air.MolarWeight); Calculate(oxygenMassFractionFlueGas, oxygenMassFraction); Calculate(oxygenMoleFractionFlueGas, oxygenMoleFraction); } }