Пример #1
0
        private static double CalculateTotalEntalpyOfProduct(double moleFractionCarbon, double moleFractionHydrogen, double moleFractionSulfur, double t)
        {
            ThermalPropCalculator propCalculator        = ThermalPropCalculator.Instance;
            double totalEenthalpyOfProductCarbonDioxide = moleFractionCarbon * propCalculator.CalculateEnthalpyOfFormation(t, carbonDioxide);
            double totalEenthalpyOfProductWater         = moleFractionHydrogen * propCalculator.CalculateEnthalpyOfFormation(t, water);
            double totalEenthalpyOfProductSulfer        = moleFractionSulfur * propCalculator.CalculateEnthalpyOfFormation(t, sulfurDioxide);
            double totalEenthalpyOfProduct = totalEenthalpyOfProductCarbonDioxide + totalEenthalpyOfProductWater + totalEenthalpyOfProductSulfer;

            return(totalEenthalpyOfProduct);
        }
Пример #2
0
        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);
            }
        }