Пример #1
0
        protected GasSolidSeparatorRatingModel(IGasSolidSeparator owner) : base()
        {
            this.owner       = owner;
            this.ownerUnitOp = owner.MyUnitOperation;
            DryingGasStream     dgs = owner.GasInlet as DryingGasStream;
            DryingGasComponents dgc = dgs.GasComponents;
            SolidPhase          sp  = dgc.SolidPhase;

            if (sp == null)
            {
                particleProperties = new ParticleProperties();
            }
            else
            {
                ParticleSizeFractionAndEfficiency sfe;
                particleProperties = sp.ParticleProperties;
                ArrayList sizeAndFractionList = particleProperties.ParticleSizeAndFractionList;
                if (particleProperties.IsParticleDistributionsCalculated)
                {
                    foreach (ParticleSizeAndFraction psf in sizeAndFractionList)
                    {
                        sfe = new ParticleSizeFractionAndEfficiency(psf);
                        particleSizeFractionAndEfficiencyList.Add(sfe);
                    }
                }
            }

            this.ParticleDensity.Owner     = ownerUnitOp;
            this.ParticleBulkDensity.Owner = ownerUnitOp;
        }
Пример #2
0
        internal void PostBalanceCalculation()
        {
            DryingGasStream gasInlet           = owner.GasInlet as DryingGasStream;
            DryingGasStream gasOutlet          = owner.GasOutlet as DryingGasStream;
            double          gasOutMassFlow     = gasOutlet.MassFlowRate.Value;
            double          gasMoistureContent = gasOutlet.Humidity.Value;
            double          wg = gasOutlet.MassFlowRateDryBase.Value;

            if (gasOutMassFlow == Constants.NO_VALUE && gasMoistureContent != Constants.NO_VALUE && wg != Constants.NO_VALUE)
            {
                gasOutMassFlow = wg * (1.0 + gasMoistureContent);
            }

            if (gasOutMassFlow != Constants.NO_VALUE)
            {
                SolidPhase          sp        = null;
                DryingGasComponents inletDgc  = gasInlet.GasComponents;
                DryingGasComponents outletDgc = gasOutlet.GasComponents;
                double massFlowRateOfEntrainedMaterial;
                sp = outletDgc.SolidPhase;
                if (sp == null)
                {
                    if (inletDgc.NumberOfPhases <= 1)
                    {
                        ArrayList         solidCompList = new ArrayList();
                        MaterialComponent mc            = new MaterialComponent(inletDgc.AbsoluteDryMaterial.Substance);
                        solidCompList.Add(mc);
                        mc = new MaterialComponent(inletDgc.Moisture.Substance);
                        solidCompList.Add(mc);
                        sp = new SolidPhase("Cyclone Outlet Solid Phase", solidCompList);
                    }
                    else
                    {
                        sp = (SolidPhase)inletDgc.SolidPhase.Clone();
                    }

                    outletDgc.AddPhase(sp);
                }

                double volumeFlow   = gasInlet.VolumeFlowRate.Value;
                double inletLoading = inletParticleLoading.Value;
                double efficiency   = collectionEfficiency.Value;
                if (volumeFlow != Constants.NO_VALUE && inletLoading != Constants.NO_VALUE && efficiency != Constants.NO_VALUE)
                {
                    massFlowRateOfEntrainedMaterial = volumeFlow * inletLoading * (1.0 - efficiency);
                    Calculate(massFlowRateOfParticleLostToGasOutlet, massFlowRateOfEntrainedMaterial);
                    sp.MassFraction = massFlowRateOfEntrainedMaterial / gasOutMassFlow;
                }
            }
        }
Пример #3
0
        internal double CalculateParticleLoading(ProcessStreamBase psb)
        {
            DryingGasStream     stream = psb as DryingGasStream;
            DryingGasComponents dgc    = stream.GasComponents;
            SolidPhase          sp     = dgc.SolidPhase;
            double massFlow            = stream.MassFlowRate.Value;
            double volumeFlow          = stream.VolumeFlowRate.Value;
            double loading             = Constants.NO_VALUE;

            if (massFlow != Constants.NO_VALUE && volumeFlow != Constants.NO_VALUE)
            {
                double massFlowOfParticle = sp.MassFraction * massFlow;
                loading = massFlowOfParticle / volumeFlow;
            }
            return(loading);
        }
Пример #4
0
        private static DryingGasComponents CreateDryingGasComponents(double flueGasMoistureContentDryBase, CompositeSubstance flueGas)
        {
            ArrayList compList = new ArrayList();

            compList.Add(new MaterialComponent(flueGas, 1 / (1 + flueGasMoistureContentDryBase)));
            compList.Add(new MaterialComponent(water, flueGasMoistureContentDryBase / (1 + flueGasMoistureContentDryBase)));

            DryingGasComponents flueGasComponents = new DryingGasComponents(compList);

            ArrayList         gasCompList = new ArrayList();
            MaterialComponent pc          = new MaterialComponent(flueGas);

            gasCompList.Add(pc);
            pc = new MaterialComponent(water);
            gasCompList.Add(pc);
            GasPhase gp = new GasPhase("Drying Gas Gas Phase", gasCompList);

            flueGasComponents.AddPhase(gp);

            return(flueGasComponents);
        }
Пример #5
0
 protected void BalanceStreamComponents(ProcessStreamBase inlet, ProcessStreamBase outlet)
 {
     if (inlet is DryingGasStream)
     {
         DryingGasStream     dsInlet          = inlet as DryingGasStream;
         DryingGasStream     dsOutlet         = outlet as DryingGasStream;
         DryingGasComponents inletDgc         = dsInlet.GasComponents;
         DryingGasComponents outletDgc        = dsOutlet.GasComponents;
         SolidPhase          inletSolidPhase  = inletDgc.SolidPhase;
         SolidPhase          outletSolidPhase = outletDgc.SolidPhase;
         if (inletSolidPhase != null)
         {
             if (outletSolidPhase != null)
             {
                 outletSolidPhase.MassFraction = inletSolidPhase.MassFraction;
             }
             else
             {
                 outletDgc.AddPhase(inletSolidPhase);
             }
         }
     }
 }
Пример #6
0
        internal void DoBalanceCalculation()
        {
            DryingGasStream gasInlet         = owner.GasInlet as DryingGasStream;
            DryingGasStream gasOutlet        = owner.GasOutlet as DryingGasStream;
            double          inletVolumeFlow  = gasInlet.VolumeFlowRate.Value;
            double          outletVolumeFlow = gasOutlet.VolumeFlowRate.Value;
            double          inletLoading     = inletParticleLoading.Value;
            double          outletLoading    = outletParticleLoading.Value;
            double          collectionRate   = particleCollectionRate.Value;
            double          lossRate         = massFlowRateOfParticleLostToGasOutlet.Value;
            double          efficiency       = collectionEfficiency.Value;

            double inletMassFlow        = gasInlet.MassFlowRate.Value;
            double inletMoistureContent = gasInlet.Humidity.Value;
            double wg = gasInlet.MassFlowRateDryBase.Value;

            if (inletMassFlow == Constants.NO_VALUE && inletMoistureContent != Constants.NO_VALUE &&
                wg != Constants.NO_VALUE)
            {
                inletMassFlow = wg * (1.0 + inletMoistureContent);
            }

            DryingGasComponents dgc = gasInlet.GasComponents;
            SolidPhase          sp  = dgc.SolidPhase;

            //if (inletVolumeFlow != Constants.NO_VALUE && outletVolumeFlow != Constants.NO_VALUE) {
            if (inletVolumeFlow != Constants.NO_VALUE)
            {
                if (sp != null && inletMassFlow != Constants.NO_VALUE)
                {
                    inletLoading = CalculateParticleLoading(gasInlet);
                    Calculate(inletParticleLoading, inletLoading);
                    //ownerUnitOp.SolveState = SolveState.PartiallySolved;
                }

                if (inletLoading != Constants.NO_VALUE && efficiency != Constants.NO_VALUE)
                {
                    collectionRate = inletLoading * inletVolumeFlow * efficiency;
                    Calculate(particleCollectionRate, collectionRate);

                    lossRate = inletLoading * inletVolumeFlow * (1.0 - efficiency);
                    Calculate(massFlowRateOfParticleLostToGasOutlet, lossRate);

                    if (outletVolumeFlow != Constants.NO_VALUE)
                    {
                        outletLoading = lossRate / outletVolumeFlow;
                        Calculate(outletParticleLoading, outletLoading);
                    }

                    //ownerUnitOp.SolveState = SolveState.PartiallySolved;
                }
                else if (inletLoading != Constants.NO_VALUE && outletLoading != Constants.NO_VALUE &&
                         outletVolumeFlow != Constants.NO_VALUE)
                {
                    collectionRate = inletLoading * inletVolumeFlow - outletLoading * outletVolumeFlow;
                    Calculate(particleCollectionRate, collectionRate);

                    efficiency = collectionRate / (inletLoading * inletVolumeFlow);
                    Calculate(collectionEfficiency, efficiency);

                    lossRate = outletLoading * outletVolumeFlow;
                    Calculate(massFlowRateOfParticleLostToGasOutlet, lossRate);

                    //ownerUnitOp.SolveState = SolveState.PartiallySolved;
                }
                else if (outletLoading != Constants.NO_VALUE && efficiency != Constants.NO_VALUE &&
                         outletVolumeFlow != Constants.NO_VALUE)
                {
                    lossRate = outletLoading * outletVolumeFlow;
                    Calculate(massFlowRateOfParticleLostToGasOutlet, lossRate);

                    inletLoading = lossRate / (inletVolumeFlow * (1.0 - efficiency));
                    Calculate(inletParticleLoading, inletLoading);

                    collectionRate = inletLoading * inletVolumeFlow * efficiency;
                    Calculate(particleCollectionRate, collectionRate);

                    //ownerUnitOp.SolveState = SolveState.PartiallySolved;
                }
                else if (lossRate != Constants.NO_VALUE && collectionRate != Constants.NO_VALUE)
                {
                    inletLoading = (lossRate + collectionRate) / inletVolumeFlow;
                    Calculate(inletParticleLoading, inletLoading);

                    efficiency = collectionRate / (lossRate + collectionRate);
                    Calculate(collectionEfficiency, efficiency);

                    if (outletVolumeFlow != Constants.NO_VALUE)
                    {
                        outletLoading = lossRate / outletVolumeFlow;
                        Calculate(outletParticleLoading, outletLoading);
                    }
                    //ownerUnitOp.SolveState = SolveState.PartiallySolved;
                }
                else if (lossRate != Constants.NO_VALUE && efficiency != Constants.NO_VALUE && efficiency < 1.0)
                {
                    inletLoading = lossRate / (inletVolumeFlow * (1.0 - efficiency));
                    Calculate(inletParticleLoading, inletLoading);

                    collectionRate = lossRate * efficiency / (1.0 - efficiency);
                    Calculate(particleCollectionRate, collectionRate);

                    if (outletVolumeFlow != Constants.NO_VALUE)
                    {
                        outletLoading = lossRate / outletVolumeFlow;
                        Calculate(outletParticleLoading, outletLoading);
                    }

                    //ownerUnitOp.SolveState = SolveState.PartiallySolved;
                }
            }
        }
Пример #7
0
        private void Solve()
        {
            double            totalFraction           = 0.0;
            double            totalFlow               = 0.0;
            double            totalFlowDryBase        = 0.0;
            double            fractionValue           = 0.0;
            int               numOfUnknownFraction    = 0;
            int               numOfUnknownFlow        = 0;
            int               numOfUnknownFlowDryBase = 0;
            int               numOfKnown              = 0;
            int               j                     = -1;
            int               k                     = -1;
            int               l                     = -1;
            int               fractionIndex         = -1;
            int               numOfKnownPressure    = 0;
            int               numOfKnownEnthalpy    = 0;
            int               numOfKnownTemperature = 0;
            ProcessStreamBase psb;
            int               unknownFlowIndex        = -1;
            int               unknownFlowDryBaseIndex = -1;
            double            temp;
            StreamAndFraction saf;
            DryingStream      dsInlet = null;
            DryingStream      dsOutlet;

            if (inlet is DryingStream)
            {
                dsInlet = inlet as DryingStream;
            }

            for (int i = 0; i < outletStreamAndFractions.Count; i++)
            {
                saf           = outletStreamAndFractions[i] as StreamAndFraction;
                fractionValue = saf.Fraction.Value;
                if (fractionValue != Constants.NO_VALUE)
                {
                    totalFraction += fractionValue;
                    if (inlet.MassFlowRate.HasValue)
                    {
                        Calculate(saf.Stream.MassFlowRate, inlet.MassFlowRate.Value * fractionValue);
                    }
                    else if (saf.Stream.MassFlowRate.HasValue && fractionValue > 1.0e-6)
                    {
                        Calculate(inlet.MassFlowRate, saf.Stream.MassFlowRate.Value / fractionValue);
                    }
                    //inlet mass flow rate dry base is known
                    else if (inlet is DryingStream)
                    {
                        dsOutlet = saf.Stream as DryingStream;
                        if (dsInlet.MassFlowRateDryBase.HasValue)
                        {
                            Calculate(dsOutlet.MassFlowRateDryBase, dsInlet.MassFlowRateDryBase.Value * fractionValue);
                        }
                        else if (dsOutlet.MassFlowRateDryBase.HasValue && fractionValue > 1.0e-6)
                        {
                            Calculate(dsInlet.MassFlowRateDryBase, dsOutlet.MassFlowRateDryBase.Value / fractionValue);
                        }
                    }
                }
                else
                {
                    bool fractionCalculated = false;
                    if (inlet.MassFlowRate.HasValue && saf.Stream.MassFlowRate.HasValue)
                    {
                        fractionCalculated = true;
                        fractionValue      = saf.Stream.MassFlowRate.Value / inlet.MassFlowRate.Value;
                        if (fractionValue <= 1.0 && fractionValue >= 0.0)
                        {
                            Calculate(saf.Fraction, fractionValue);
                            totalFraction += fractionValue;
                        }
                    }
                    else if (inlet is DryingStream)
                    {
                        dsOutlet = saf.Stream as DryingStream;
                        if (dsInlet.MassFlowRateDryBase.HasValue && dsOutlet.MassFlowRateDryBase.HasValue)
                        {
                            fractionCalculated = true;
                            fractionValue      = dsOutlet.MassFlowRateDryBase.Value / dsInlet.MassFlowRateDryBase.Value;
                            if (fractionValue <= 1.0 && fractionValue >= 0.0)
                            {
                                Calculate(saf.Fraction, fractionValue);
                                totalFraction += fractionValue;
                            }
                        }
                    }
                    if (!fractionCalculated)
                    {
                        fractionIndex = i;
                        numOfUnknownFraction++;
                    }
                }

                if (saf.Stream.MassFlowRate.HasValue)
                {
                    totalFlow += saf.Stream.MassFlowRate.Value;
                }
                else
                {
                    unknownFlowIndex = i;
                    numOfUnknownFlow++;
                }

                if (inlet is DryingStream)
                {
                    dsOutlet = saf.Stream as DryingStream;
                    if (dsOutlet.MassFlowRateDryBase.HasValue)
                    {
                        totalFlowDryBase += dsOutlet.MassFlowRateDryBase.Value;
                    }
                    else
                    {
                        unknownFlowDryBaseIndex = i;
                        numOfUnknownFlowDryBase++;
                    }
                }
            }

            //all fractions specified except one to be calculated
            if (numOfUnknownFraction == 1)
            {
                saf           = outletStreamAndFractions[fractionIndex] as StreamAndFraction;
                fractionValue = (1.0 - totalFraction);
                Calculate(saf.Fraction, fractionValue);
                //if (inlet.MassFlowRate.HasValue && saf.Stream.MassFlowRate.IsSpecifiedAndHasNoValue) {
                if (inlet.MassFlowRate.HasValue && !saf.Stream.MassFlowRate.HasValue)
                {
                    Calculate(saf.Stream.MassFlowRate, inlet.MassFlowRate.Value * fractionValue);
                }
                //else if (saf.Stream.MassFlowRate.HasValue && fractionValue > 1.0e-6 && inlet.MassFlowRate.IsSpecifiedAndHasNoValue) {
                else if (saf.Stream.MassFlowRate.HasValue && fractionValue > 1.0e-6 && !inlet.MassFlowRate.HasValue)
                {
                    Calculate(inlet.MassFlowRate, saf.Stream.MassFlowRate.Value / fractionValue);
                }
                //inlet mass flow rate dry base is known
                else if (inlet is DryingStream)
                {
                    dsOutlet = saf.Stream as DryingStream;
                    //if (dsInlet.MassFlowRateDryBase.HasValue && dsOutlet.MassFlowRateDryBase.IsSpecifiedAndHasNoValue) {
                    if (dsInlet.MassFlowRateDryBase.HasValue && !dsOutlet.MassFlowRateDryBase.HasValue)
                    {
                        Calculate(dsOutlet.MassFlowRateDryBase, dsInlet.MassFlowRateDryBase.Value * fractionValue);
                    }
                    //else if (dsOutlet.MassFlowRateDryBase.HasValue && fractionValue > 1.0e-6 && dsInlet.MassFlowRateDryBase.IsSpecifiedAndHasNoValue) {
                    else if (dsOutlet.MassFlowRateDryBase.HasValue && fractionValue > 1.0e-6 && !dsInlet.MassFlowRateDryBase.HasValue)
                    {
                        Calculate(dsInlet.MassFlowRateDryBase, dsOutlet.MassFlowRateDryBase.Value / fractionValue);
                    }
                }
            }

            if (numOfUnknownFlow == 1)
            {
                saf = outletStreamAndFractions[unknownFlowIndex] as StreamAndFraction;
                if (inlet.MassFlowRate.HasValue && inlet.MassFlowRate.Value > totalFlow)
                {
                    //if (saf.Stream.MassFlowRate.IsSpecifiedAndHasNoValue) {
                    if (!saf.Stream.MassFlowRate.HasValue)
                    {
                        Calculate(saf.Stream.MassFlowRate, (inlet.MassFlowRate.Value - totalFlow));
                    }
                    //if (saf.Fraction.IsSpecifiedAndHasNoValue) {
                    if (!saf.Fraction.HasValue)
                    {
                        Calculate(saf.Fraction, saf.Stream.MassFlowRate.Value / inlet.MassFlowRate.Value);
                    }
                }
            }
            else if (numOfUnknownFlow == 0)
            {
                Calculate(inlet.MassFlowRate, totalFlow);
                foreach (StreamAndFraction sf in outletStreamAndFractions)
                {
                    Calculate(sf.Fraction, sf.Stream.MassFlowRate.Value / inlet.MassFlowRate.Value);
                }
            }
            else if (numOfUnknownFlowDryBase == 1 && dsInlet.MassFlowRateDryBase.HasValue)
            {
                saf      = outletStreamAndFractions[unknownFlowDryBaseIndex] as StreamAndFraction;
                dsOutlet = saf.Stream as DryingStream;
                if (dsInlet.MassFlowRateDryBase.Value > totalFlowDryBase)
                {
                    //if (dsOutlet.MassFlowRateDryBase.IsSpecifiedAndHasNoValue) {
                    if (!dsOutlet.MassFlowRateDryBase.HasValue)
                    {
                        Calculate(dsOutlet.MassFlowRateDryBase, (dsInlet.MassFlowRateDryBase.Value - totalFlowDryBase));
                    }
                    //if (saf.Fraction.IsSpecifiedAndHasNoValue) {
                    if (!saf.Fraction.HasValue)
                    {
                        Calculate(saf.Fraction, dsOutlet.MassFlowRateDryBase.Value / dsInlet.MassFlowRateDryBase.Value);
                    }
                }
            }
            else if (numOfUnknownFlowDryBase == 0)
            {
                Calculate(dsInlet.MassFlowRateDryBase, totalFlowDryBase);
                foreach (StreamAndFraction sf in outletStreamAndFractions)
                {
                    dsOutlet = sf.Stream as DryingStream;
                    Calculate(sf.Fraction, dsOutlet.MassFlowRateDryBase.Value / dsInlet.MassFlowRateDryBase.Value);
                }
            }

            for (int i = 0; i < InOutletStreams.Count; i++)
            {
                psb = InOutletStreams[i] as ProcessStreamBase;
                if (psb.Pressure.HasValue)
                {
                    numOfKnownPressure++;
                    j = i;
                }
                if (psb.SpecificEnthalpy.HasValue)
                {
                    numOfKnownEnthalpy++;
                    k = i;
                }

                if (psb.Temperature.HasValue)
                {
                    numOfKnownTemperature++;
                    l = i;
                }
            }

            if (numOfKnownPressure == 1)
            {
                psb  = InOutletStreams[j] as ProcessStreamBase;
                temp = psb.Pressure.Value;
                for (int i = 0; i < InOutletStreams.Count; i++)
                {
                    if (i != j)
                    {
                        psb = InOutletStreams[i] as ProcessStreamBase;
                        Calculate(psb.Pressure, temp);
                    }
                }
            }

            if (numOfKnownEnthalpy == 1)
            {
                psb  = InOutletStreams[k] as ProcessStreamBase;
                temp = psb.SpecificEnthalpy.Value;
                for (int i = 0; i < InOutletStreams.Count; i++)
                {
                    if (i != k)
                    {
                        psb = InOutletStreams[i] as ProcessStreamBase;
                        Calculate(psb.SpecificEnthalpy, temp);
                    }
                }
            }
            else if (numOfKnownTemperature == 1)
            {
                psb  = InOutletStreams[l] as ProcessStreamBase;
                temp = psb.Temperature.Value;
                for (int i = 0; i < InOutletStreams.Count; i++)
                {
                    if (i != l)
                    {
                        psb = InOutletStreams[i] as ProcessStreamBase;
                        Calculate(psb.Temperature, temp);
                    }
                }
            }

            //dry gas flow balance
            if (inlet is DryingGasStream)
            {
                DryingStream dsStream;
                for (int i = 0; i < InOutletStreams.Count; i++)
                {
                    dsStream = InOutletStreams[i] as DryingStream;
                    if (dsStream.MoistureContentDryBase.HasValue)
                    {
                        numOfKnown++;
                        j = i;
                    }
                }
                if (numOfKnown == 1)
                {
                    dsStream = InOutletStreams[j] as DryingStream;
                    temp     = dsStream.MoistureContentDryBase.Value;
                    for (int i = 0; i < InOutletStreams.Count; i++)
                    {
                        if (i != j)
                        {
                            dsStream = InOutletStreams[i] as DryingStream;
                            Calculate(dsStream.MoistureContentDryBase, temp);
                        }
                    }
                }

                DryingGasComponents inletDgc = (inlet as DryingGasStream).GasComponents;
                SolidPhase          inletSp  = inletDgc.SolidPhase;
                DryingGasComponents outletDgc;
                foreach (DryingGasStream outlet in outletStreams)
                {
                    outletDgc            = outlet.GasComponents;
                    outletDgc.SolidPhase = inletDgc.SolidPhase;
                }
            }

            //density for drying material stream
            if (inlet is DryingMaterialStream)
            {
                DryingStream dsStream;
                for (int i = 0; i < InOutletStreams.Count; i++)
                {
                    dsStream = InOutletStreams[i] as DryingStream;
                    if (dsStream.MoistureContentWetBase.HasValue)
                    {
                        numOfKnown++;
                        j = i;
                    }
                }
                if (numOfKnown == 1)
                {
                    dsStream = InOutletStreams[j] as DryingStream;
                    temp     = dsStream.MoistureContentWetBase.Value;
                    for (int i = 0; i < InOutletStreams.Count; i++)
                    {
                        if (i != j)
                        {
                            dsStream = InOutletStreams[i] as DryingStream;
                            Calculate(dsStream.MoistureContentWetBase, temp);
                        }
                    }
                }

                numOfKnown = 0;
                for (int i = 0; i < InOutletStreams.Count; i++)
                {
                    dsStream = InOutletStreams[i] as DryingMaterialStream;
                    if (dsStream.Density.HasValue)
                    {
                        numOfKnown++;
                        j = i;
                    }
                }
                if (numOfKnown == 1)
                {
                    dsStream = InOutletStreams[j] as DryingMaterialStream;
                    temp     = dsStream.Density.Value;
                    for (int i = 0; i < InOutletStreams.Count; i++)
                    {
                        if (i != j)
                        {
                            dsStream = InOutletStreams[i] as DryingMaterialStream;
                            Calculate(dsStream.Density, temp);
                        }
                    }
                }
            }

            //balanced gas stream solid phase
            //if (inlet is DryingGasStream) {
            //   DryingGasComponents inletDgc = (inlet as DryingGasStream).GasComponents;
            //   SolidPhase inletSp = inletDgc.SolidPhase;
            //   DryingGasComponents outletDgc;
            //   foreach (DryingGasStream outlet in outletStreams) {
            //      outletDgc = outlet.GasComponents;
            //      outletDgc.SolidPhase = inletDgc.SolidPhase;
            //   }
            //}

            DryingStream dryingStream;
            int          numOfKnownMassFlow        = 0;
            int          numOfKnownMoistureContent = 0;

            numOfKnownPressure = 0;
            numOfKnownEnthalpy = 0;
            int numOfStrms = InOutletStreams.Count;

            for (int i = 0; i < numOfStrms; i++)
            {
                psb = InOutletStreams[i] as ProcessStreamBase;
                psb.Execute(false);
                if (psb.MassFlowRate.HasValue)
                {
                    numOfKnownMassFlow++;
                }
                if (psb.Pressure.HasValue)
                {
                    numOfKnownPressure++;
                }
                if (psb.Temperature.HasValue)
                {
                    numOfKnownEnthalpy++;
                }
                if (inlet is DryingGasStream)
                {
                    dryingStream = psb as DryingStream;
                    if (dryingStream.MoistureContentDryBase.HasValue)
                    {
                        numOfKnownMoistureContent++;
                    }
                }
                else if (inlet is DryingMaterialStream)
                {
                    dryingStream = psb as DryingStream;
                    if (dryingStream.MoistureContentWetBase.HasValue)
                    {
                        numOfKnownMoistureContent++;
                    }
                }
            }

            if (numOfKnownMassFlow == numOfStrms && numOfKnownEnthalpy == numOfStrms)
            {
                if (inlet is ProcessStream && numOfKnownPressure == numOfStrms)
                {
                    currentSolveState = SolveState.Solved;
                }
                else if (inlet is DryingGasStream && numOfKnownPressure == numOfStrms && numOfKnownMoistureContent == numOfStrms)
                {
                    currentSolveState = SolveState.Solved;
                }
                else if (inlet is DryingMaterialStream && numOfKnownMoistureContent == numOfStrms)
                {
                    currentSolveState = SolveState.Solved;
                }
            }
        }
Пример #8
0
        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);
            }
        }