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; }
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; } } }
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); }
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); } } } }
private void Solve() { double totalFlow = 0.0; double temp; int numOfUnknownFlow = 0; int unknownFlowIndex = -1; DryingStream dryingStream; DryingStream dsInlet; DryingStream dsOutlet = null; if (outlet is DryingStream) { dsOutlet = outlet as DryingStream; } ////flow balance //for (int i = 0; i < inletStreams.Count; i++) { // inletStream = inletStreams[i] as ProcessStreamBase; // if (inletStream.MassFlowRate.HasValue) { // totalFlow += inletStream.MassFlowRate.Value; // } // else { // unknownFlowIndex = i; // numOfUnknownFlow++; // } //} //if (numOfUnknownFlow == 1 && outlet.MassFlowRate.HasValue) { // inletStream = inletStreams[unknownFlowIndex] as ProcessStreamBase; // //if (outlet.MassFlowRate.Value > totalFlow && inletStream.MassFlowRate.IsSpecifiedAndHasNoValue) // if (outlet.MassFlowRate.Value > totalFlow && !inletStream.MassFlowRate.HasValue) { // Calculate(inletStream.MassFlowRate, (outlet.MassFlowRate.Value - totalFlow)); // } //} //else if (numOfUnknownFlow == 0) { // Calculate(outlet.MassFlowRate, totalFlow); //} //double inletTotal = 0.0; //int numOfUnknownInlet = 0; //int unknownInletIndex = -1; //moisture content balance //if (outlet is DryingStream) { // double mcDryBase; // double mcWetBase; // for (int i = 0; i < inletStreams.Count; i++) { // dsInlet = inletStreams[i] as DryingStream; // mcWetBase = Constants.NO_VALUE; // if (dsInlet.MoistureContentWetBase.HasValue) { // mcWetBase = dsInlet.MoistureContentWetBase.Value; // } // else if (dsInlet.MoistureContentDryBase.HasValue) { // mcDryBase = dsInlet.MoistureContentDryBase.Value; // mcWetBase = mcDryBase/(1.0 + mcDryBase); // } // if (dsInlet.MassFlowRate.HasValue && mcWetBase != Constants.NO_VALUE) { // //inletTotal += dsInlet.MassFlowRate.Value * mcDryBase/(1.0 + mcDryBase); // inletTotal += dsInlet.MassFlowRate.Value * mcWetBase; // } // else { // unknownInletIndex = i; // numOfUnknownInlet++; // } // } // mcDryBase = dsOutlet.MoistureContentDryBase.Value; // if (numOfUnknownInlet == 1 && dsOutlet.MassFlowRate.HasValue && mcDryBase != Constants.NO_VALUE) { // dsInlet = inletStreams[unknownInletIndex] as DryingStream; // double outletMoisture = dsOutlet.MassFlowRate.Value * mcDryBase/(1.0 + mcDryBase); // if (outletMoisture > inletTotal) { // //if (dsInlet.MassFlowRate.HasValue && dsInlet.MoistureContentWetBase.IsSpecifiedAndHasNoValue) { // if (dsInlet.MassFlowRate.HasValue && !dsInlet.MoistureContentWetBase.HasValue) { // mcWetBase = (outletMoisture - inletTotal)/dsInlet.MassFlowRate.Value; // Calculate(dsInlet.MoistureContentWetBase, mcWetBase); // } // //else if (dsInlet.MassFlowRate.HasValue && dsInlet.MoistureContentDryBase.IsSpecifiedAndHasNoValue) { // else if (dsInlet.MassFlowRate.HasValue && !dsInlet.MoistureContentDryBase.HasValue) { // mcWetBase = (outletMoisture - inletTotal)/dsInlet.MassFlowRate.Value; // Calculate(dsInlet.MoistureContentDryBase, mcWetBase/(1.0 - mcWetBase)); // } // //else if (dsInlet.MassFlowRateDryBase.HasValue && dsInlet.MoistureContentDryBase.IsSpecifiedAndHasNoValue) { // else if (dsInlet.MassFlowRateDryBase.HasValue && !dsInlet.MoistureContentDryBase.HasValue) { // mcDryBase = (outletMoisture - inletTotal)/dsInlet.MassFlowRateDryBase.Value; // Calculate(dsInlet.MoistureContentDryBase, mcDryBase); // } // //else if (dsInlet.MoistureContentDryBase.HasValue && dsInlet.MassFlowRateDryBase.IsSpecifiedAndHasNoValue) { // else if (dsInlet.MoistureContentDryBase.HasValue && !dsInlet.MassFlowRateDryBase.HasValue) { // double massFlowDryBase = (outletMoisture - inletTotal)/dsInlet.MoistureContentDryBase.Value; // Calculate(dsInlet.MassFlowRateDryBase, massFlowDryBase); // } // //else if (dsInlet.MoistureContentDryBase.HasValue && dsInlet.MassFlowRate.IsSpecifiedAndHasNoValue) { // else if (dsInlet.MoistureContentDryBase.HasValue && !dsInlet.MassFlowRate.HasValue) { // mcDryBase = dsInlet.MoistureContentDryBase.Value; // double massFlow = (outletMoisture - inletTotal)/mcDryBase * (1.0 + mcDryBase); // Calculate(dsInlet.MassFlowRate, massFlow); // } // } // } // else if (numOfUnknownInlet == 0) { // //if (dsOutlet.MassFlowRate.HasValue && dsOutlet.MoistureContentWetBase.IsSpecifiedAndHasNoValue) { // if (dsOutlet.MassFlowRate.HasValue && !dsOutlet.MoistureContentWetBase.HasValue) { // mcWetBase = inletTotal/dsOutlet.MassFlowRate.Value; // Calculate(dsOutlet.MoistureContentWetBase, mcWetBase); // } // //else if (dsOutlet.MassFlowRate.HasValue && dsOutlet.MoistureContentDryBase.IsSpecifiedAndHasNoValue) { // else if (dsOutlet.MassFlowRate.HasValue && !dsOutlet.MoistureContentDryBase.HasValue) { // mcWetBase = inletTotal/dsOutlet.MassFlowRate.Value; // Calculate(dsOutlet.MoistureContentDryBase, mcWetBase/(1.0 - mcWetBase)); // } // //else if (dsOutlet.MassFlowRateDryBase.HasValue && dsOutlet.MoistureContentDryBase.IsSpecifiedAndHasNoValue) { // else if (dsOutlet.MassFlowRateDryBase.HasValue && !dsOutlet.MoistureContentDryBase.HasValue) { // mcDryBase = inletTotal/dsOutlet.MassFlowRateDryBase.Value; // Calculate(dsOutlet.MoistureContentDryBase, mcDryBase); // } // //else if (dsOutlet.MoistureContentDryBase.HasValue && dsOutlet.MassFlowRateDryBase.IsSpecifiedAndHasNoValue) { // else if (dsOutlet.MoistureContentDryBase.HasValue && !dsOutlet.MassFlowRateDryBase.HasValue) { // double massFlowDryBase = inletTotal/dsOutlet.MoistureContentDryBase.Value; // Calculate(dsOutlet.MassFlowRateDryBase, massFlowDryBase); // } // //else if (dsOutlet.MoistureContentDryBase.HasValue && dsOutlet.MassFlowRate.IsSpecifiedAndHasNoValue) { // else if (dsOutlet.MoistureContentDryBase.HasValue && !dsOutlet.MassFlowRate.HasValue) { // mcDryBase = dsOutlet.MoistureContentDryBase.Value; // double massFlow = inletTotal/mcDryBase * (1.0 + mcDryBase); // Calculate(dsOutlet.MassFlowRate, massFlow); // } // } //} double inletTotal = 0.0; int numOfUnknownInlet = 0; int unknownInletIndex = -1; if (outlet is DryingGasStream) { DryingGasStream dgsInlet; for (int i = 0; i < inletStreams.Count; i++) { dgsInlet = inletStreams[i] as DryingGasStream; if (dgsInlet.MassFlowRateDryBase.HasValue) { totalFlow += dgsInlet.MassFlowRateDryBase.Value; } else { unknownFlowIndex = i; numOfUnknownFlow++; } } if (numOfUnknownFlow == 1 && dsOutlet.MassFlowRateDryBase.HasValue) { dsInlet = inletStreams[unknownFlowIndex] as DryingGasStream; if (dsOutlet.MassFlowRateDryBase.Value > totalFlow && !dsInlet.MassFlowRateDryBase.HasValue) { Calculate(dsInlet.MassFlowRateDryBase, (dsOutlet.MassFlowRateDryBase.Value - totalFlow)); } } else if (numOfUnknownFlow == 0) { Calculate(dsOutlet.MassFlowRateDryBase, totalFlow); } for (int i = 0; i < inletStreams.Count; i++) { dgsInlet = inletStreams[i] as DryingGasStream; if (dgsInlet.MoistureContentDryBase.HasValue && dgsInlet.MassFlowRateDryBase.HasValue) { inletTotal += dgsInlet.MassFlowRateDryBase.Value * dgsInlet.MoistureContentDryBase.Value; } else { unknownInletIndex = i; numOfUnknownInlet++; } } if (numOfUnknownInlet == 1 && dsOutlet.MassFlowRateDryBase.HasValue && dsOutlet.MoistureContentDryBase.HasValue) { dgsInlet = inletStreams[unknownInletIndex] as DryingGasStream; double outletMoisture = dsOutlet.MassFlowRateDryBase.Value * dsOutlet.MoistureContentDryBase.Value; if (outletMoisture > inletTotal) { if (dgsInlet.MassFlowRateDryBase.HasValue && !dgsInlet.MoistureContentDryBase.HasValue) { double mcDryBase = (outletMoisture - inletTotal) / dgsInlet.MassFlowRateDryBase.Value; Calculate(dgsInlet.MoistureContentDryBase, mcDryBase); } else if (dgsInlet.MoistureContentDryBase.HasValue && !dgsInlet.MassFlowRateDryBase.HasValue) { double massFlowDryBase = (outletMoisture - inletTotal) / dgsInlet.MoistureContentDryBase.Value; Calculate(dgsInlet.MassFlowRateDryBase, massFlowDryBase); } } else { throw new CalculationFailedException(this.name + "Total mositure content from inlets is greater than that of the outlet"); } } else if (numOfUnknownInlet == 0) { if (dsOutlet.MassFlowRateDryBase.HasValue && !dsOutlet.MoistureContentDryBase.HasValue) { double mcDryBase = inletTotal / dsOutlet.MassFlowRateDryBase.Value; Calculate(dsOutlet.MoistureContentDryBase, mcDryBase); } else if (dsOutlet.MoistureContentDryBase.HasValue && !dsOutlet.MassFlowRateDryBase.HasValue) { double massFlowDryBase = inletTotal / dsOutlet.MoistureContentDryBase.Value; Calculate(dsOutlet.MassFlowRateDryBase, massFlowDryBase); } } } else if (outlet is DryingMaterialStream) { DryingMaterialStream dmsInlet; for (int i = 0; i < inletStreams.Count; i++) { dmsInlet = inletStreams[i] as DryingMaterialStream; if (dmsInlet.MassFlowRate.HasValue) { totalFlow += dmsInlet.MassFlowRate.Value; } else { unknownFlowIndex = i; numOfUnknownFlow++; } } if (numOfUnknownFlow == 1 && outlet.MassFlowRate.HasValue) { dmsInlet = inletStreams[unknownFlowIndex] as DryingMaterialStream; if (outlet.MassFlowRate.Value > totalFlow && !dmsInlet.MassFlowRate.HasValue) { Calculate(dmsInlet.MassFlowRate, (outlet.MassFlowRate.Value - totalFlow)); } } else if (numOfUnknownFlow == 0) { Calculate(outlet.MassFlowRate, totalFlow); } for (int i = 0; i < inletStreams.Count; i++) { dmsInlet = inletStreams[i] as DryingMaterialStream; if (dmsInlet.MassFlowRate.HasValue && dmsInlet.MoistureContentWetBase.HasValue) { inletTotal += dmsInlet.MassFlowRate.Value * dmsInlet.MoistureContentWetBase.Value; } else { unknownInletIndex = i; numOfUnknownInlet++; } } if (numOfUnknownInlet == 1 && dsOutlet.MassFlowRate.HasValue && dsOutlet.MoistureContentWetBase.HasValue) { dmsInlet = inletStreams[unknownInletIndex] as DryingMaterialStream; double outletMoisture = dsOutlet.MassFlowRate.Value * dsOutlet.MoistureContentWetBase.Value; if (outletMoisture > inletTotal) { if (dmsInlet.MassFlowRate.HasValue && !dmsInlet.MoistureContentWetBase.HasValue) { double mcWetBase = (outletMoisture - inletTotal) / dmsInlet.MassFlowRate.Value; Calculate(dmsInlet.MoistureContentWetBase, mcWetBase); } else if (dmsInlet.MoistureContentWetBase.HasValue && !dmsInlet.MassFlowRate.HasValue) { double massFlow = (outletMoisture - inletTotal) / dmsInlet.MoistureContentWetBase.Value; Calculate(dmsInlet.MassFlowRate, massFlow); } } else { throw new CalculationFailedException(this.name + "Total mositure content from inlets is greater than that of the outlet"); } } else if (numOfUnknownInlet == 0) { if (dsOutlet.MassFlowRate.HasValue && !dsOutlet.MoistureContentWetBase.HasValue) { double mcWetBase = inletTotal / dsOutlet.MassFlowRate.Value; Calculate(dsOutlet.MoistureContentWetBase, mcWetBase); } else if (dsOutlet.MoistureContentWetBase.HasValue && !dsOutlet.MassFlowRate.HasValue) { double massFlow = inletTotal / dsOutlet.MoistureContentWetBase.Value; Calculate(dsOutlet.MassFlowRate, massFlow); } } } //have to recalculate the streams so that the following balance calcualtion //can have all the latest balance calculated values taken into account UpdateStreamsIfNecessary(); inletTotal = 0.0; numOfUnknownInlet = 0; unknownInletIndex = -1; double inletTotalDryBase = 0.0; int numOfUnknownInletDryBase = 0; int unknownInletIndexDryBase = -1; ProcessStreamBase inletStream; for (int i = 0; i < inletStreams.Count; i++) { inletStream = inletStreams[i] as ProcessStreamBase; if (inletStream.MassFlowRate.HasValue && inletStream.SpecificEnthalpy.HasValue) { inletTotal += inletStream.MassFlowRate.Value * inletStream.SpecificEnthalpy.Value; } else { unknownInletIndex = i; numOfUnknownInlet++; } if (outlet is DryingStream) { dsInlet = inletStream as DryingStream; if (dsInlet.MassFlowRateDryBase.HasValue && dsInlet.SpecificEnthalpyDryBase.HasValue) { inletTotalDryBase += dsInlet.MassFlowRateDryBase.Value * dsInlet.SpecificEnthalpyDryBase.Value; } else { unknownInletIndexDryBase = i; numOfUnknownInletDryBase++; } } } HumidGasCalculator humidGasCalculator = GetHumidGasCalculator(); if (numOfUnknownInletDryBase == 1 && (dsOutlet.MassFlowRate.HasValue && dsOutlet.SpecificEnthalpy.HasValue)) { dsInlet = inletStreams[unknownInletIndexDryBase] as DryingStream; double outletEnergy = dsOutlet.MassFlowRate.Value * dsOutlet.SpecificEnthalpy.Value; if (outletEnergy > inletTotalDryBase) { if (dsInlet.MassFlowRate.HasValue && !dsInlet.SpecificEnthalpy.HasValue) { temp = (outletEnergy - inletTotalDryBase) / dsInlet.MassFlowRate.Value; Calculate(dsInlet.SpecificEnthalpy, temp); } else if (dsInlet.MassFlowRateDryBase.HasValue && !dsInlet.SpecificEnthalpyDryBase.HasValue) { temp = (outletEnergy - inletTotalDryBase) / dsInlet.MassFlowRateDryBase.Value; Calculate(dsInlet.SpecificEnthalpyDryBase, temp); } else if (dsInlet.SpecificEnthalpy.HasValue && !dsInlet.MassFlowRate.HasValue) { temp = (outletEnergy - inletTotalDryBase) / dsInlet.SpecificEnthalpy.Value; Calculate(dsInlet.MassFlowRate, temp); } else if (dsInlet.SpecificEnthalpyDryBase.HasValue && !dsInlet.MassFlowRateDryBase.HasValue) { temp = (outletEnergy - inletTotalDryBase) / dsInlet.SpecificEnthalpyDryBase.Value; Calculate(dsInlet.MassFlowRateDryBase, temp); } } } else if (numOfUnknownInletDryBase == 0) { if (dsOutlet.MassFlowRate.HasValue && !dsOutlet.SpecificEnthalpy.HasValue) { temp = inletTotalDryBase / dsOutlet.MassFlowRate.Value; Calculate(dsOutlet.SpecificEnthalpy, temp); } if (dsOutlet.MassFlowRateDryBase.HasValue && !dsOutlet.SpecificEnthalpyDryBase.HasValue) { temp = inletTotalDryBase / dsOutlet.MassFlowRateDryBase.Value; Calculate(dsOutlet.SpecificEnthalpyDryBase, temp); } else if (dsOutlet.SpecificEnthalpy.HasValue && !dsOutlet.MassFlowRate.HasValue) { temp = inletTotalDryBase / dsOutlet.SpecificEnthalpy.Value; Calculate(dsOutlet.MassFlowRate, temp); } else if (dsOutlet.SpecificEnthalpyDryBase.HasValue && !dsOutlet.MassFlowRateDryBase.HasValue) { temp = inletTotalDryBase / dsOutlet.SpecificEnthalpyDryBase.Value; Calculate(dsOutlet.MassFlowRateDryBase, temp); } } else if (numOfUnknownInlet == 1 && outlet.MassFlowRate.HasValue && outlet.SpecificEnthalpy.HasValue && outlet.SpecificHeat.HasValue) { inletStream = inletStreams[unknownInletIndex] as ProcessStreamBase; double outletEnergy = outlet.MassFlowRate.Value * outlet.Temperature.Value * outlet.SpecificHeat.Value; if (outletEnergy > inletTotal) { if (inletStream.MassFlowRate.HasValue && !inletStream.SpecificEnthalpy.HasValue) { temp = (outletEnergy - inletTotal) / inletStream.MassFlowRate.Value; Calculate(inletStream.SpecificEnthalpy, temp); } else if (inletStream.SpecificEnthalpy.HasValue && !inletStream.MassFlowRate.HasValue) { temp = (outletEnergy - inletTotal) / inletStream.SpecificEnthalpy.Value; Calculate(inletStream.MassFlowRate, temp); } } } else if (numOfUnknownInlet == 0) { if (outlet.MassFlowRate.HasValue && !outlet.SpecificEnthalpy.HasValue) { temp = inletTotal / outlet.MassFlowRate.Value; Calculate(outlet.SpecificEnthalpy, temp); } else if (outlet.SpecificEnthalpy.HasValue && !outlet.MassFlowRate.HasValue) { temp = inletTotal / outlet.SpecificEnthalpy.Value; Calculate(outlet.MassFlowRate, temp); } } ProcessStreamBase stream; int numOfKnownMassFlow = 0; int numOfKnownPressure = 0; int numOfKnownTemperature = 0; int numOfKnownMoistureContent = 0; int numOfStrms = InOutletStreams.Count; for (int i = 0; i < numOfStrms; i++) { stream = InOutletStreams[i] as ProcessStreamBase; if (stream.MassFlowRate.HasValue) { numOfKnownMassFlow++; } if (stream.Pressure.HasValue) { numOfKnownPressure++; } if (stream.SpecificEnthalpy.HasValue) { numOfKnownTemperature++; } if (outlet is DryingStream) { dryingStream = stream as DryingStream; if (dryingStream.MoistureContentDryBase.HasValue || dryingStream.MoistureContentWetBase.HasValue) { numOfKnownMoistureContent++; } } } if (numOfKnownMassFlow == numOfStrms && numOfKnownTemperature == numOfStrms) { if (outlet is ProcessStream && numOfKnownPressure == numOfStrms) { solveState = SolveState.Solved; } else if (outlet is DryingGasStream && numOfKnownPressure == numOfStrms && numOfKnownMoistureContent == numOfStrms) { solveState = SolveState.Solved; } else if (outlet is DryingMaterialStream && numOfKnownMoistureContent == numOfStrms) { solveState = SolveState.Solved; } } if (solveState == SolveState.Solved && outlet is DryingGasStream) { double totalSolidPhaseMass = 0.0; SolidPhase solidPhase = null; SolidPhase lastSolidPhase = null; foreach (DryingGasStream gasStream in inletStreams) { solidPhase = gasStream.GasComponents.SolidPhase; if (solidPhase != null) { totalSolidPhaseMass += solidPhase.MassFraction * gasStream.MassFlowRate.Value; lastSolidPhase = solidPhase; } } if (lastSolidPhase != null) { double outletSolidPhaseMassFraction = totalSolidPhaseMass / outlet.MassFlowRate.Value; DryingGasStream dgsOutlet = outlet as DryingGasStream; SolidPhase outletSolidPhase = dgsOutlet.GasComponents.SolidPhase; if (outletSolidPhase != null) { outletSolidPhase.MassFraction = outletSolidPhaseMassFraction; } else { outletSolidPhase = lastSolidPhase.Clone(); outletSolidPhase.MassFraction = outletSolidPhase.MassFraction; dgsOutlet.GasComponents.SolidPhase = outletSolidPhase; } } } }
private void Solve() { //Mass Transfer--gas moisture and material particles transfer from gas stream to liquid stream DryingMaterialStream dmsOutlet = liquidOutlet as DryingMaterialStream; DryingGasStream dgsInlet = gasInlet as DryingGasStream; DryingGasStream dgsOutlet = gasOutlet as DryingGasStream; //if (dgsInlet.DewPoint.HasValue && dgsOutlet.Temperature.HasValue && dgsOutlet.Temperature.Value > dgsInlet.DewPoint.Value) { // throw new InappropriateSpecifiedValueException("Gas outlet temperature is not low enough to reach satuation"); //} Calculate(dgsOutlet.RelativeHumidity, 0.9999999); //have to recalculate the streams so that the following balance calcualtion //can have all the latest balance calculated values taken into account if (dgsOutlet.Temperature.HasValue || dgsOutlet.WetBulbTemperature.HasValue) { UpdateStreamsIfNecessary(); } balanceModel.DoBalanceCalculation(); double inletDustMassFlowRate = Constants.NO_VALUE; double outletDustMassFlowRate = Constants.NO_VALUE; double inletDustMoistureFraction = 0.0; double outletDustMoistureFraction = 0.0; DryingGasComponents dgc; if (InletParticleLoading.HasValue && gasInlet.VolumeFlowRate.HasValue) { inletDustMassFlowRate = InletParticleLoading.Value * gasInlet.VolumeFlowRate.Value; dgc = dgsInlet.GasComponents; if (dgc.SolidPhase != null) { SolidPhase sp = dgc.SolidPhase; MaterialComponent mc = sp[1]; inletDustMoistureFraction = mc.GetMassFractionValue(); } } if (OutletParticleLoading.HasValue && gasOutlet.VolumeFlowRate.HasValue) { outletDustMassFlowRate = OutletParticleLoading.Value * gasOutlet.VolumeFlowRate.Value; dgc = dgsOutlet.GasComponents; if (dgc.SolidPhase != null) { SolidPhase sp = dgc.SolidPhase; MaterialComponent mc = sp[1]; inletDustMoistureFraction = mc.GetMassFractionValue(); } } double materialFromGas = ParticleCollectionRate.Value; if (inletDustMassFlowRate != Constants.NO_VALUE && materialFromGas != Constants.NO_VALUE && outletDustMassFlowRate == Constants.NO_VALUE) { outletDustMassFlowRate = inletDustMassFlowRate - materialFromGas; } MoistureProperties moistureProperties = (this.unitOpSystem as EvaporationAndDryingSystem).GetMoistureProperties(((DryingGasStream)gasInlet).GasComponents.Moisture.Substance); double materialEnthalpyLoss; double gasEnthalpyLoss; double gatTempValue; double matTempValue; double liquidCp; double specificHeatOfSolidPhase; double totalEnthapyLoss; if (waterInlet != null && waterOutlet != null) { if (waterInlet.MassFlowRate.HasValue) { Calculate(waterOutlet.MassFlowRate, waterInlet.MassFlowRate.Value); } else if (waterOutlet.MassFlowRate.HasValue) { Calculate(waterInlet.MassFlowRate, waterOutlet.MassFlowRate.Value); } if (waterInlet.SpecificEnthalpy.HasValue && waterInlet.MassFlowRate.HasValue && waterOutlet.SpecificEnthalpy.HasValue) { double waterEnthalpyGain = waterInlet.MassFlowRate.Value * (waterOutlet.SpecificEnthalpy.Value - waterInlet.SpecificEnthalpy.Value); Calculate(coolingDuty, waterEnthalpyGain); } } if (dmsOutlet.Temperature.HasValue && dgsInlet.SpecificEnthalpyDryBase.HasValue && coolingDuty.HasValue && dgsInlet.MassFlowRateDryBase.HasValue && inletDustMoistureFraction != Constants.NO_VALUE && materialFromGas != Constants.NO_VALUE) { gatTempValue = gasInlet.Temperature.Value; matTempValue = dmsOutlet.Temperature.Value; liquidCp = moistureProperties.GetSpecificHeatOfLiquid(MathUtility.Average(gatTempValue, matTempValue)); specificHeatOfSolidPhase = (1.0 - inletDustMoistureFraction) * dmsOutlet.GetCpOfAbsoluteDryMaterial() + inletDustMoistureFraction * liquidCp; materialEnthalpyLoss = materialFromGas * specificHeatOfSolidPhase * (matTempValue - gatTempValue); gasEnthalpyLoss = coolingDuty.Value - materialEnthalpyLoss; //double outletEnthalpy = gasInlet.SpecificEnthalpy.Value - gasEnthalpyLoss; //Calculate(gasOutlet.SpecificEnthalpy, outletEnthalpy); double outletEnthalpy = dgsInlet.SpecificEnthalpyDryBase.Value - gasEnthalpyLoss / dgsInlet.MassFlowRateDryBase.Value; Calculate(dgsOutlet.SpecificEnthalpyDryBase, outletEnthalpy); UpdateStreamsIfNecessary(); if (dgsOutlet.VolumeFlowRate.HasValue) { double outletLoading = outletDustMassFlowRate / dgsOutlet.VolumeFlowRate.Value; Calculate(OutletParticleLoading, outletLoading); } } else if (dmsOutlet.Temperature.HasValue && dgsInlet.SpecificEnthalpyDryBase.HasValue && dgsOutlet.Temperature.HasValue && dgsInlet.MassFlowRateDryBase.HasValue && dgsOutlet.SpecificEnthalpyDryBase.HasValue && inletDustMoistureFraction != Constants.NO_VALUE) { gatTempValue = dgsInlet.Temperature.Value; matTempValue = dmsOutlet.Temperature.Value; liquidCp = moistureProperties.GetSpecificHeatOfLiquid(MathUtility.Average(gatTempValue, matTempValue)); specificHeatOfSolidPhase = (1.0 - inletDustMoistureFraction) * dmsOutlet.GetCpOfAbsoluteDryMaterial() + inletDustMoistureFraction * liquidCp; materialEnthalpyLoss = materialFromGas * specificHeatOfSolidPhase * (matTempValue - gatTempValue); gasEnthalpyLoss = dgsInlet.MassFlowRateDryBase.Value * (dgsInlet.SpecificEnthalpyDryBase.Value - dgsOutlet.SpecificEnthalpyDryBase.Value); totalEnthapyLoss = materialEnthalpyLoss + gasEnthalpyLoss; Calculate(coolingDuty, totalEnthapyLoss); if (waterInlet != null && waterOutlet != null) { if (waterInlet.SpecificEnthalpy.HasValue && waterInlet.MassFlowRate.HasValue) { double waterOutletSpecificEnthanlpy = totalEnthapyLoss / waterInlet.MassFlowRate.Value + waterInlet.SpecificEnthalpy.Value; Calculate(waterOutlet.SpecificEnthalpy, waterOutletSpecificEnthanlpy); } else if (waterOutlet.SpecificEnthalpy.HasValue && waterInlet.MassFlowRate.HasValue) { double waterInletSpecificEnthanlpy = waterOutlet.SpecificEnthalpy.Value - totalEnthapyLoss / waterInlet.MassFlowRate.Value; Calculate(waterOutlet.SpecificEnthalpy, waterInletSpecificEnthanlpy); } } } //else if (gasInlet.SpecificEnthalpy.HasValue && gasOutlet.SpecificEnthalpy.HasValue && coolingDuty.HasValue // && gasInlet.MassFlowRate.HasValue && inletDustMoistureFraction != Constants.NO_VALUE) { // gasEnthalpyLoss = gasInlet.SpecificEnthalpy.Value * gasInlet.MassFlowRate.Value - gasOutlet.SpecificEnthalpy.Value * gasOutlet.MassFlowRate.Value; // materialEnthalpyLoss = coolingDuty.Value - gasEnthalpyLoss; // gatTempValue = gasInlet.Temperature.Value; // //double matTempValue = dmsOutlet.Temperature.Value; // liquidCp = moistureProperties.GetSpecificHeatOfLiquid(gatTempValue); // specificHeatOfSolidPhase = (1.0 - inletDustMoistureFraction) * dmsOutlet.GetCpOfAbsoluteDryMaterial() + inletDustMoistureFraction * liquidCp; // matTempValue = gatTempValue + materialEnthalpyLoss / (materialFromGas * specificHeatOfSolidPhase); // Calculate(liquidOutlet.Temperature, matTempValue); //} double inletMoistureFlowRate = Constants.NO_VALUE; double outletMoistureFlowRate = Constants.NO_VALUE; if (dgsInlet.MassFlowRateDryBase.HasValue && dgsInlet.MoistureContentDryBase.HasValue) { inletMoistureFlowRate = dgsInlet.MassFlowRateDryBase.Value * dgsInlet.MoistureContentDryBase.Value; } if (dgsOutlet.MassFlowRateDryBase.HasValue && dgsOutlet.MoistureContentDryBase.HasValue) { outletMoistureFlowRate = dgsOutlet.MassFlowRateDryBase.Value * dgsOutlet.MoistureContentDryBase.Value; } if (materialFromGas != Constants.NO_VALUE && inletMoistureFlowRate != Constants.NO_VALUE && outletMoistureFlowRate != Constants.NO_VALUE) { double moistureFromGas = inletMoistureFlowRate - outletMoistureFlowRate; // materialFromGas = inletDustMassFlowRate - outletDustMassFlowRate; double moistureOfMaterialFromGas = inletDustMassFlowRate * inletDustMoistureFraction - outletDustMassFlowRate * outletDustMoistureFraction; double outletMassFlowRate = materialFromGas + moistureFromGas; Calculate(dmsOutlet.MassFlowRate, outletMassFlowRate); double outletMaterialMoistureFlowRate = moistureFromGas + moistureOfMaterialFromGas; double outletMoistureContentWetBase = outletMaterialMoistureFlowRate / outletMassFlowRate; Calculate(dmsOutlet.MoistureContentWetBase, outletMoistureContentWetBase); //solveState = SolveState.Solved; } if (liquidToGasVolumeRatio.HasValue && gasInlet.VolumeFlowRate.HasValue) { double recirculationVolumeFlow = liquidToGasVolumeRatio.Value * gasInlet.VolumeFlowRate.Value; Calculate(liquidRecirculationVolumeFlowRate, recirculationVolumeFlow); if (liquidOutlet.Density.HasValue) { double recirculationMassFlow = recirculationVolumeFlow / liquidOutlet.Density.Value; Calculate(liquidRecirculationMassFlowRate, recirculationMassFlow); } } if (dgsInlet.DewPoint.HasValue && dgsOutlet.Temperature.HasValue && dgsOutlet.Temperature.Value > dgsInlet.DewPoint.Value) { solveState = SolveState.SolvedWithWarning; } //else if (gasInlet.Pressure.HasValue && gasOutlet.Pressure.HasValue // && gasInlet.Temperature.HasValue && gasOutlet.Temperature.HasValue // && gasInlet.SpecificEnthalpy.HasValue && gasOutlet.SpecificEnthalpy.HasValue // && waterInlet.Pressure.HasValue && waterOutlet.Pressure.HasValue // && waterInlet.Temperature.HasValue && waterOutlet.Temperature.HasValue // && waterInlet.SpecificEnthalpy.HasValue && waterOutlet.SpecificEnthalpy.HasValue // && liquidOutlet.Pressure.HasValue && liquidOutlet.Temperature.HasValue // && dmsOutlet.MoistureContentWetBase.HasValue) { else if (gasInlet.SolveState == SolveState.Solved && gasOutlet.SolveState == SolveState.Solved && coolingDuty.HasValue && ((waterInlet == null || waterOutlet == null) || (waterInlet != null && waterOutlet != null) && (waterInlet.SolveState == SolveState.Solved && waterOutlet.SpecificEnthalpy.HasValue || waterOutlet.SolveState == SolveState.Solved && waterInlet.SpecificEnthalpy.HasValue))) { solveState = SolveState.Solved; } }
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; } } }
private void Solve() { //Mass Transfer--material particles transfer from gas stream to liquid stream //Mass Transfer--moisture transfers from liquid stream to gas stream //by an adiabaitc saturation process if ScrubberType is General. DryingMaterialStream dmsInlet = liquidInlet as DryingMaterialStream; DryingMaterialStream dmsOutlet = liquidOutlet as DryingMaterialStream; DryingGasStream dgsInlet = gasInlet as DryingGasStream; DryingGasStream dgsOutlet = gasOutlet as DryingGasStream; //gas stream goes through an adiabatic saturation process double tg1 = dgsInlet.Temperature.Value; double y1 = dgsInlet.Humidity.Value; double tw1 = dgsInlet.WetBulbTemperature.Value; double td1 = dgsInlet.DewPoint.Value; double fy1 = dgsInlet.RelativeHumidity.Value; double tg2 = dgsOutlet.Temperature.Value; double y2 = dgsOutlet.Humidity.Value; double tw2 = dgsOutlet.WetBulbTemperature.Value; double td2 = dgsOutlet.DewPoint.Value; double fy2 = dgsOutlet.RelativeHumidity.Value; double ih = 0; double p1 = dgsInlet.Pressure.Value; double p2 = dgsOutlet.Pressure.Value; if (p1 == Constants.NO_VALUE || p2 == Constants.NO_VALUE) { return; } HumidGasCalculator humidGasCalculator = GetHumidGasCalculator(); if (tg1 != Constants.NO_VALUE && y1 != Constants.NO_VALUE) { ih = humidGasCalculator.GetHumidEnthalpyFromDryBulbHumidityAndPressure(tg1, y1, p1); if (tg2 != Constants.NO_VALUE) { y2 = humidGasCalculator.GetHumidityFromHumidEnthalpyTemperatureAndPressure(ih, tg2, p2); if (y2 <= 0.0) { y2 = 1.0e-6; } Calculate(dgsOutlet.MoistureContentDryBase, y2); solveState = SolveState.Solved; } else if (y2 != Constants.NO_VALUE) { tg2 = humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(ih, y2, p2); Calculate(dgsOutlet.Temperature, tg2); solveState = SolveState.Solved; } else if (td2 != Constants.NO_VALUE) { y2 = humidGasCalculator.GetHumidityFromDewPointAndPressure(td2, p2); tg2 = humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(ih, y2, p2); Calculate(dgsOutlet.Temperature, tg2); solveState = SolveState.Solved; } else if (fy2 != Constants.NO_VALUE) { double fy_temp = 0; double delta = 10.0; double totalDelta = delta; tg2 = tg1 - delta; bool negativeLastTime = false; int counter = 0; do { counter++; y2 = humidGasCalculator.GetHumidityFromHumidEnthalpyTemperatureAndPressure(ih, tg2, p2); fy_temp = humidGasCalculator.GetRelativeHumidityFromDryBulbHumidityAndPressure(tg2, y2, p2); if (fy2 > fy_temp) { if (negativeLastTime) { delta /= 2.0; //testing finds delta/2.0 is almost optimal } totalDelta += delta; negativeLastTime = false; } else if (fy2 < fy_temp) { delta /= 2.0; //testing finds delta/2.0 is almost optimal totalDelta -= delta; negativeLastTime = true; } tg2 = tg1 - totalDelta; } while (Math.Abs(fy2 - fy_temp) > 1.0e-6 && counter <= 200); if (counter < 200) { Calculate(dgsOutlet.Temperature, tg2); solveState = SolveState.Solved; } } if (solveState == SolveState.Solved) { double fy = humidGasCalculator.GetRelativeHumidityFromDryBulbHumidityAndPressure(tg2, y2, p2); if (fy > 1.0) { solveState = SolveState.NotSolved; string msg = "Specified gas inlet state makes the relative humidity of the outlet greater than 1.0."; throw new InappropriateSpecifiedValueException(msg); } } } else if (tg2 != Constants.NO_VALUE && y2 != Constants.NO_VALUE) { ih = humidGasCalculator.GetHumidEnthalpyFromDryBulbHumidityAndPressure(tg2, y2, p2); if (tg1 != Constants.NO_VALUE) { y1 = humidGasCalculator.GetHumidityFromHumidEnthalpyTemperatureAndPressure(ih, tg1, p1); Calculate(dgsInlet.MoistureContentDryBase, y1); solveState = SolveState.Solved; } else if (y1 != Constants.NO_VALUE) { tg1 = humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(ih, y1, p1); Calculate(dgsInlet.Temperature, tg1); solveState = SolveState.Solved; } else if (td1 != Constants.NO_VALUE) { y1 = humidGasCalculator.GetHumidityFromDewPointAndPressure(td1, p1); tg1 = humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(ih, y1, p1); Calculate(dgsInlet.Temperature, tg1); solveState = SolveState.Solved; } else if (fy1 != Constants.NO_VALUE) { double fy_temp = 0; double delta = 10.0; double totalDelta = delta; tg1 = tg2 + delta; bool negativeLastTime = false; int counter = 0; do { counter++; y1 = humidGasCalculator.GetHumidityFromHumidEnthalpyTemperatureAndPressure(ih, tg1, p1); fy_temp = humidGasCalculator.GetRelativeHumidityFromDryBulbHumidityAndPressure(tg1, y1, p1); if (fy1 < fy_temp) { if (negativeLastTime) { delta /= 2.0; //testing finds delta/2.0 is almost optimal } totalDelta += delta; negativeLastTime = false; } else if (fy1 > fy_temp) { delta /= 2.0; //testing finds delta/2.0 is almost optimal totalDelta -= delta; negativeLastTime = true; } tg1 = tg2 + totalDelta; } while (Math.Abs(fy1 - fy_temp) > 1.0e-6 && counter <= 200); if (counter < 200) { Calculate(dgsInlet.Temperature, tg1); solveState = SolveState.Solved; } } } //end of adiabatic saturation process calculatioin //have to recalculate the streams so that the following balance calcualtion //can have all the latest balance calculated values taken into account //PostSolve(false); UpdateStreamsIfNecessary(); balanceModel.DoBalanceCalculation(); double inletDustMassFlowRate = Constants.NO_VALUE; double outletDustMassFlowRate = Constants.NO_VALUE; double inletDustMoistureFraction = 0.0; double outletDustMoistureFraction = 0.0; DryingGasComponents dgc; if (InletParticleLoading.HasValue && gasInlet.VolumeFlowRate.HasValue) { inletDustMassFlowRate = InletParticleLoading.Value * gasInlet.VolumeFlowRate.Value; dgc = dgsInlet.GasComponents; if (dgc.SolidPhase != null) { SolidPhase sp = dgc.SolidPhase; MaterialComponent mc = sp[1]; inletDustMoistureFraction = mc.GetMassFractionValue(); } } if (OutletParticleLoading.HasValue && gasOutlet.VolumeFlowRate.HasValue) { outletDustMassFlowRate = OutletParticleLoading.Value * gasOutlet.VolumeFlowRate.Value; dgc = dgsOutlet.GasComponents; if (dgc.SolidPhase != null) { SolidPhase sp = dgc.SolidPhase; MaterialComponent mc = sp[1]; inletDustMoistureFraction = mc.GetMassFractionValue(); } } double inletMoistureFlowRate = Constants.NO_VALUE; double outletMoistureFlowRate = Constants.NO_VALUE; if (dgsInlet.MassFlowRateDryBase.HasValue && dgsInlet.MoistureContentDryBase.HasValue) { inletMoistureFlowRate = dgsInlet.MassFlowRateDryBase.Value * dgsInlet.MoistureContentDryBase.Value; } if (dgsOutlet.MassFlowRateDryBase.HasValue && dgsOutlet.MoistureContentDryBase.HasValue) { outletMoistureFlowRate = dgsOutlet.MassFlowRateDryBase.Value * dgsOutlet.MoistureContentDryBase.Value; } double materialFromGas = 0.0; if (inletDustMassFlowRate != Constants.NO_VALUE && outletDustMassFlowRate != Constants.NO_VALUE && inletMoistureFlowRate != Constants.NO_VALUE && outletMoistureFlowRate != Constants.NO_VALUE) { double moistureToGas = outletMoistureFlowRate - inletMoistureFlowRate; materialFromGas = inletDustMassFlowRate - outletDustMassFlowRate; double moistureOfMaterialFromGas = inletDustMassFlowRate * inletDustMoistureFraction - outletDustMassFlowRate * outletDustMoistureFraction; if (dmsInlet.MassFlowRate.HasValue) { double outletMassFlowRate = dmsInlet.MassFlowRate.Value + materialFromGas - moistureToGas; Calculate(dmsOutlet.MassFlowRate, outletMassFlowRate); if (dmsInlet.MoistureContentWetBase.HasValue) { double inletMaterialMoistureFlowRate = dmsInlet.MassFlowRate.Value * dmsInlet.MoistureContentWetBase.Value; double outletMaterialMoistureFlowRate = inletMaterialMoistureFlowRate - moistureToGas + moistureOfMaterialFromGas; double outletMoistureContentWetBase = outletMaterialMoistureFlowRate / outletMassFlowRate; Calculate(dmsOutlet.MoistureContentWetBase, outletMoistureContentWetBase); solveState = SolveState.Solved; } else if (dmsOutlet.MoistureContentWetBase.HasValue) { double outletMaterialMoistureFlowRate = dmsOutlet.MassFlowRate.Value * dmsInlet.MoistureContentWetBase.Value; double inletMaterialMoistureFlowRate = outletMaterialMoistureFlowRate + moistureToGas - moistureOfMaterialFromGas; double inletMoistureContentWetBase = inletMaterialMoistureFlowRate / dmsInlet.MassFlowRate.Value; Calculate(dmsInlet.MoistureContentWetBase, inletMoistureContentWetBase); solveState = SolveState.Solved; } } else if (dmsOutlet.MassFlowRate.HasValue) { double inletMassFlowRate = dmsOutlet.MassFlowRate.Value - materialFromGas + moistureToGas; Calculate(dmsInlet.MassFlowRate, inletMassFlowRate); if (dmsInlet.MoistureContentWetBase.HasValue) { double inletMaterialMoistureFlowRate = dmsInlet.MassFlowRate.Value * dmsInlet.MoistureContentWetBase.Value; double outletMaterialMoistureFlowRate = inletMaterialMoistureFlowRate - moistureToGas + moistureOfMaterialFromGas; double outletMoistureContentWetBase = outletMaterialMoistureFlowRate / dmsOutlet.MassFlowRate.Value; Calculate(dmsOutlet.MoistureContentWetBase, outletMoistureContentWetBase); solveState = SolveState.Solved; } else if (dmsOutlet.MoistureContentWetBase.HasValue) { double outletMaterialMoistureFlowRate = dmsOutlet.MassFlowRate.Value * dmsInlet.MoistureContentWetBase.Value; double inletMaterialMoistureFlowRate = outletMaterialMoistureFlowRate + moistureToGas - moistureOfMaterialFromGas; double inletMoistureContentWetBase = inletMaterialMoistureFlowRate / inletMassFlowRate; Calculate(dmsInlet.MoistureContentWetBase, inletMoistureContentWetBase); solveState = SolveState.Solved; } } else if (dmsOutlet.MassConcentration.HasValue) { double cValue = dmsOutlet.MassConcentration.Value; double inletMassFlowRate = (materialFromGas * (1 - cValue) + moistureToGas * cValue) / cValue; Calculate(dmsInlet.MassFlowRate, inletMassFlowRate); double outletMassFlowRate = inletMassFlowRate + materialFromGas - moistureToGas; Calculate(dmsOutlet.MassFlowRate, outletMassFlowRate); solveState = SolveState.Solved; } } MoistureProperties moistureProperties = (this.unitOpSystem as EvaporationAndDryingSystem).GetMoistureProperties(((DryingMaterialStream)liquidInlet).MaterialComponents.Moisture.Substance); double enthalpyOfMaterialFromGas = 0.0; if (dmsOutlet.GetCpOfAbsoluteDryMaterial() != Constants.NO_VALUE && inletDustMoistureFraction != Constants.NO_VALUE && gasInlet.Temperature.HasValue) { double tempValue = gasInlet.Temperature.Value; double liquidCp = moistureProperties.GetSpecificHeatOfLiquid(tempValue); double specificHeatOfSolidPhase = (1.0 - inletDustMoistureFraction) * dmsOutlet.GetCpOfAbsoluteDryMaterial() + inletDustMoistureFraction * liquidCp; enthalpyOfMaterialFromGas = materialFromGas * specificHeatOfSolidPhase * (tempValue - 273.15); } if (gasInlet.SpecificEnthalpy.HasValue && gasInlet.MassFlowRate.HasValue && gasOutlet.SpecificEnthalpy.HasValue && gasOutlet.MassFlowRate.HasValue) { double gasEnthalpyLoss = gasInlet.SpecificEnthalpy.Value * gasInlet.MassFlowRate.Value - gasOutlet.SpecificEnthalpy.Value * gasOutlet.MassFlowRate.Value; if (liquidInlet.SpecificEnthalpy.HasValue && liquidInlet.MassFlowRate.HasValue && liquidOutlet.MassFlowRate.HasValue) { double totalLiquidOutletEnthalpy = gasEnthalpyLoss + enthalpyOfMaterialFromGas + liquidInlet.SpecificEnthalpy.Value * liquidInlet.MassFlowRate.Value; double specificLiquidOutletEnthalpy = totalLiquidOutletEnthalpy / liquidOutlet.MassFlowRate.Value; Calculate(liquidOutlet.SpecificEnthalpy, specificLiquidOutletEnthalpy); } //else if (gasInlet.SpecificEnthalpy.HasValue && gasInlet.MassFlowRate.HasValue && // gasOutlet.SpecificEnthalpy.HasValue && gasOutlet.MassFlowRate.HasValue && // liquidOutlet.SpecificEnthalpy.HasValue && liquidOutlet.MassFlowRate.HasValue && // liquidInlet.MassFlowRate.HasValue) { // double totalLiquidInletEnthalpy = liquidOutlet.SpecificEnthalpy.Value * liquidOutlet.MassFlowRate.Value - gasEnthalpyLoss - enthalpyOfMaterialFromGas; // double specificLiquidInletEnthalpy = totalLiquidInletEnthalpy / liquidInlet.MassFlowRate.Value; // Calculate(liquidInlet.SpecificEnthalpy, specificLiquidInletEnthalpy); //} } else if (liquidInlet.SpecificEnthalpy.HasValue && liquidInlet.MassFlowRate.HasValue && liquidOutlet.SpecificEnthalpy.HasValue && liquidOutlet.MassFlowRate.HasValue) { double liquidEnthalpyLoss = liquidInlet.SpecificEnthalpy.Value * liquidInlet.MassFlowRate.Value - liquidOutlet.SpecificEnthalpy.Value * liquidOutlet.MassFlowRate.Value; if (gasInlet.SpecificEnthalpy.HasValue && gasInlet.MassFlowRate.HasValue && gasOutlet.MassFlowRate.HasValue) { double totalGasOutletEnthalpy = liquidEnthalpyLoss + gasInlet.SpecificEnthalpy.Value * gasInlet.MassFlowRate.Value + enthalpyOfMaterialFromGas; double specificGasOutletEnthalpy = totalGasOutletEnthalpy / gasOutlet.MassFlowRate.Value; Calculate(gasOutlet.SpecificEnthalpy, specificGasOutletEnthalpy); } //else if (gasOutlet.SpecificEnthalpy.HasValue && gasOutlet.MassFlowRate.HasValue && // gasInlet.MassFlowRate.HasValue) { // double totalGasInletEnthalpy = gasOutlet.SpecificEnthalpy.Value * gasOutlet.MassFlowRate.Value - liquidEnthalpyLoss; // double specificGasInletEnthalpy = totalGasInletEnthalpy / gasInlet.MassFlowRate.Value; // Calculate(gasInlet.SpecificEnthalpy, specificGasInletEnthalpy); //} } if (liquidToGasVolumeRatio.HasValue && gasInlet.VolumeFlowRate.HasValue) { //double recirculationVolumeFlow = liquidToGasVolumeRatio.Value * gasInlet.VolumeFlowRate.Value; //Calculate(liquidRecirculationVolumeFlowRate, recirculationVolumeFlow); //if (liquidOutlet.Density.HasValue) { // double recirculationMassFlow = recirculationVolumeFlow / liquidOutlet.Density.Value; // Calculate(liquidRecirculationMassFlowRate, recirculationMassFlow); //} } }
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; } } }