internal override bool DoDetach(ProcessStreamBase ps) { bool detached = true; if (ps == fuelInlet) { fuelInlet = null; ps.DownStreamOwner = null; inletStreams.Remove(ps); } else if (ps == airInlet) { airInlet = null; ps.UpStreamOwner = null; inletStreams.Remove(ps); } else if (ps == flueGasOutlet) { flueGasOutlet = null; ps.UpStreamOwner = null; outletStreams.Remove(ps); } else { detached = false; } if (detached) { HasBeenModified(true); ps.HasBeenModified(true); OnStreamDetached(this, ps); } return(detached); }
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 UpdateStreamsUI() { // clear the stream group-boxes and start again this.groupBoxDryingMedium.Controls.Clear(); this.groupBoxMaterial.Controls.Clear(); Dryer dryer = this.DryerCtrl.Dryer; bool hasGasIn = false; bool hasGasOut = false; bool hasMaterialIn = false; bool hasMaterialOut = false; DryingGasStream gasIn = dryer.GasInlet; if (gasIn != null) { hasGasIn = true; } DryingGasStream gasOut = dryer.GasOutlet; if (gasOut != null) { hasGasOut = true; } DryingMaterialStream materialIn = dryer.MaterialInlet; if (materialIn != null) { hasMaterialIn = true; } DryingMaterialStream materialOut = dryer.MaterialOutlet; if (materialOut != null) { hasMaterialOut = true; } if (hasGasIn || hasGasOut) { DryingGasStream labelsStream = null; if (hasGasIn) { labelsStream = gasIn; } else if (hasGasOut) { labelsStream = gasOut; } gasLabelsCtrl = new GasStreamLabelsControl(labelsStream); this.groupBoxDryingMedium.Controls.Add(gasLabelsCtrl); gasLabelsCtrl.Location = new Point(4, 12 + 20 + 2); } if (hasGasIn) { GasStreamControl gasInCtrl = (GasStreamControl)this.DryerCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(this.DryerCtrl.Dryer.GasInlet.Name); gasValuesInCtrl = new GasStreamValuesControl(gasInCtrl); this.groupBoxDryingMedium.Controls.Add(gasValuesInCtrl); gasValuesInCtrl.Location = new Point(196, 12 + 20 + 2); this.textBoxGasInName.SetSolvable(dryer.GasInlet); this.groupBoxDryingMedium.Controls.Add(this.textBoxGasInName); this.textBoxGasInName.Text = dryer.GasInlet.Name; UI.SetStatusColor(this.textBoxGasInName, dryer.GasInlet.SolveState); } if (hasGasOut) { GasStreamControl gasOutCtrl = (GasStreamControl)this.DryerCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(this.DryerCtrl.Dryer.GasOutlet.Name); gasValuesOutCtrl = new GasStreamValuesControl(gasOutCtrl); this.groupBoxDryingMedium.Controls.Add(gasValuesOutCtrl); gasValuesOutCtrl.Location = new Point(276, 12 + 20 + 2); this.textBoxGasOutName.SetSolvable(dryer.GasOutlet); this.groupBoxDryingMedium.Controls.Add(this.textBoxGasOutName); this.textBoxGasOutName.Text = dryer.GasOutlet.Name; UI.SetStatusColor(this.textBoxGasOutName, dryer.GasOutlet.SolveState); } if (hasMaterialIn || hasMaterialOut) { DryingMaterialStream labelsStream = null; if (hasMaterialIn) { labelsStream = materialIn; } else if (hasMaterialOut) { labelsStream = materialOut; } materialLabelsCtrl = new MaterialStreamLabelsControl(labelsStream); this.groupBoxMaterial.Controls.Add(materialLabelsCtrl); materialLabelsCtrl.Location = new Point(4, 12 + 20 + 2); } if (hasMaterialIn) { MaterialStreamControl materialInCtrl = (MaterialStreamControl)this.DryerCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(this.DryerCtrl.Dryer.MaterialInlet.Name); materialValuesInCtrl = new MaterialStreamValuesControl(materialInCtrl); this.groupBoxMaterial.Controls.Add(materialValuesInCtrl); materialValuesInCtrl.Location = new Point(196, 12 + 20 + 2); this.textBoxMaterialInName.SetSolvable(dryer.MaterialInlet); this.groupBoxMaterial.Controls.Add(this.textBoxMaterialInName); this.textBoxMaterialInName.Text = dryer.MaterialInlet.Name; UI.SetStatusColor(this.textBoxMaterialInName, dryer.MaterialInlet.SolveState); } if (hasMaterialOut) { MaterialStreamControl materialOutCtrl = (MaterialStreamControl)this.DryerCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(this.DryerCtrl.Dryer.MaterialOutlet.Name); materialValuesOutCtrl = new MaterialStreamValuesControl(materialOutCtrl); this.groupBoxMaterial.Controls.Add(materialValuesOutCtrl); materialValuesOutCtrl.Location = new Point(276, 12 + 20 + 2); this.textBoxMaterialOutName.SetSolvable(dryer.MaterialOutlet); this.groupBoxMaterial.Controls.Add(this.textBoxMaterialOutName); this.textBoxMaterialOutName.Text = dryer.MaterialOutlet.Name; UI.SetStatusColor(this.textBoxMaterialOutName, dryer.MaterialOutlet.SolveState); } }
public HumidityChartStreamValuesControl(Flowsheet flowsheet, DryingGasStream gasStream) : this() { this.InitializeVariableTextBoxes(flowsheet, gasStream); }
public HumidityChartProcessEditor(Flowsheet flowsheet, DryingGasStream gasIn, DryingGasStream gasOut) { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); this.UpdateStreamsUI(flowsheet, gasIn, gasOut); }
//private void Dryer_StreamAttached(UnitOperation uo, ProcessStreamBase ps, int desc) { // this.UpdateStreamsUI(); //} //private void Dryer_StreamDetached(UnitOperation uo, ProcessStreamBase ps) { // this.UpdateStreamsUI(); //} protected override void UpdateStreamsUI() { // clear the stream group-boxes and start again this.groupBoxDryingMedium.Controls.Clear(); this.groupBoxMaterial.Controls.Clear(); Dryer dryer = this.DryerCtrl.Dryer; bool hasGasIn = false; bool hasGasOut = false; bool hasMaterialIn = false; bool hasMaterialOut = false; DryingGasStream gasIn = dryer.GasInlet; hasGasIn = gasIn != null; DryingGasStream gasOut = dryer.GasOutlet; hasGasOut = gasOut != null; DryingMaterialStream materialIn = dryer.MaterialInlet; hasMaterialIn = materialIn != null; DryingMaterialStream materialOut = dryer.MaterialOutlet; hasMaterialOut = materialOut != null; if (hasGasIn || hasGasOut) { DryingGasStream labelsStream = hasGasIn ? gasIn : gasOut; //gasLabelsCtrl = new ProcessVarLabelsControl(labelsStream.VarList); gasLabelsCtrl = new GasStreamLabelsControl(labelsStream); this.groupBoxDryingMedium.Controls.Add(gasLabelsCtrl); gasLabelsCtrl.Location = new Point(4, 12 + 20 + 2); } if (hasGasIn) { ProcessStreamBaseControl gasInCtrl = this.DryerCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(this.DryerCtrl.Dryer.GasInlet.Name); //gasValuesInCtrl = new ProcessVarValuesControl(gasInCtrl); gasValuesInCtrl = new GasStreamValuesControl((GasStreamControl)gasInCtrl); this.groupBoxDryingMedium.Controls.Add(gasValuesInCtrl); gasValuesInCtrl.Location = new Point(196, 12 + 20 + 2); this.textBoxGasInName.SetSolvable(dryer.GasInlet); this.groupBoxDryingMedium.Controls.Add(this.textBoxGasInName); this.textBoxGasInName.Text = dryer.GasInlet.Name; UI.SetStatusColor(this.textBoxGasInName, dryer.GasInlet.SolveState); } if (hasGasOut) { ProcessStreamBaseControl gasOutCtrl = this.DryerCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(this.DryerCtrl.Dryer.GasOutlet.Name); //gasValuesOutCtrl = new ProcessVarValuesControl(gasOutCtrl); gasValuesOutCtrl = new GasStreamValuesControl((GasStreamControl)gasOutCtrl); this.groupBoxDryingMedium.Controls.Add(gasValuesOutCtrl); gasValuesOutCtrl.Location = new Point(276, 12 + 20 + 2); this.textBoxGasOutName.SetSolvable(dryer.GasOutlet); this.groupBoxDryingMedium.Controls.Add(this.textBoxGasOutName); this.textBoxGasOutName.Text = dryer.GasOutlet.Name; UI.SetStatusColor(this.textBoxGasOutName, dryer.GasOutlet.SolveState); } if (hasMaterialIn || hasMaterialOut) { DryingMaterialStream labelsStream = hasMaterialIn ? materialIn : materialOut; //materialLabelsCtrl = new ProcessVarLabelsControl(labelsStream.VarList); materialLabelsCtrl = new MaterialStreamLabelsControl(labelsStream); this.groupBoxMaterial.Controls.Add(materialLabelsCtrl); materialLabelsCtrl.Location = new Point(4, 12 + 20 + 2); } if (hasMaterialIn) { ProcessStreamBaseControl materialInCtrl = this.DryerCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(this.DryerCtrl.Dryer.MaterialInlet.Name); //materialValuesInCtrl = new ProcessVarValuesControl(materialInCtrl); materialValuesInCtrl = new MaterialStreamValuesControl((MaterialStreamControl)materialInCtrl); this.groupBoxMaterial.Controls.Add(materialValuesInCtrl); materialValuesInCtrl.Location = new Point(196, 12 + 20 + 2); this.textBoxMaterialInName.SetSolvable(dryer.MaterialInlet); this.groupBoxMaterial.Controls.Add(this.textBoxMaterialInName); this.textBoxMaterialInName.Text = dryer.MaterialInlet.Name; UI.SetStatusColor(this.textBoxMaterialInName, dryer.MaterialInlet.SolveState); } if (hasMaterialOut) { ProcessStreamBaseControl materialOutCtrl = this.DryerCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(this.DryerCtrl.Dryer.MaterialOutlet.Name); //materialValuesOutCtrl = new ProcessVarValuesControl(materialOutCtrl); materialValuesOutCtrl = new MaterialStreamValuesControl((MaterialStreamControl)materialOutCtrl); this.groupBoxMaterial.Controls.Add(materialValuesOutCtrl); materialValuesOutCtrl.Location = new Point(276, 12 + 20 + 2); this.textBoxMaterialOutName.SetSolvable(dryer.MaterialOutlet); this.groupBoxMaterial.Controls.Add(this.textBoxMaterialOutName); this.textBoxMaterialOutName.Text = dryer.MaterialOutlet.Name; UI.SetStatusColor(this.textBoxMaterialOutName, dryer.MaterialOutlet.SolveState); } }
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; } }
public GasStreamLabelsControl(DryingGasStream stream) : this() { this.InitializeVariableLabels(stream); }
private Flowsheet SetFlowsheetContent(NewProcessSettings newProcessSettings, ApplicationPreferences appPrefs, ArrayList items, string flowsheetName) { Flowsheet flowsheet = null; IEnumerator e = items.GetEnumerator(); while (e.MoveNext()) { object obj = e.Current; if (obj is EvaporationAndDryingSystem) { EvaporationAndDryingSystem persisted = (EvaporationAndDryingSystem)obj; persisted.SetSystemFileName(flowsheetName); // call this before SetObjectData() persisted.SetObjectData(); flowsheet = new Flowsheet(newProcessSettings, appPrefs, persisted); } else if (obj is GasStreamControl) { GasStreamControl persistedCtrl = (GasStreamControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); DryingGasStream stream = flowsheet.EvaporationAndDryingSystem.GetGasStream(solvableName); GasStreamControl newCtrl = new GasStreamControl(flowsheet, new Point(0, 0), stream); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is MaterialStreamControl) { MaterialStreamControl persistedCtrl = (MaterialStreamControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); DryingMaterialStream stream = flowsheet.EvaporationAndDryingSystem.GetMaterialStream(solvableName); MaterialStreamControl newCtrl = new MaterialStreamControl(flowsheet, new Point(0, 0), stream); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is DryerControl) { DryerControl persistedCtrl = (DryerControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); Dryer uo = flowsheet.EvaporationAndDryingSystem.GetDryer(solvableName); DryerControl newCtrl = new DryerControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is HeatExchangerControl) { HeatExchangerControl persistedCtrl = (HeatExchangerControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); HeatExchanger uo = flowsheet.EvaporationAndDryingSystem.GetHeatExchanger(solvableName); HeatExchangerControl newCtrl = new HeatExchangerControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is CycloneControl) { CycloneControl persistedCtrl = (CycloneControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); Cyclone uo = flowsheet.EvaporationAndDryingSystem.GetCyclone(solvableName); CycloneControl newCtrl = new CycloneControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is EjectorControl) { EjectorControl persistedCtrl = (EjectorControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); Ejector uo = flowsheet.EvaporationAndDryingSystem.GetEjector(solvableName); EjectorControl newCtrl = new EjectorControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is WetScrubberControl) { WetScrubberControl persistedCtrl = (WetScrubberControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); WetScrubber uo = flowsheet.EvaporationAndDryingSystem.GetWetScrubber(solvableName); WetScrubberControl newCtrl = new WetScrubberControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is ScrubberCondenserControl) { ScrubberCondenserControl persistedCtrl = (ScrubberCondenserControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); ScrubberCondenser uo = flowsheet.EvaporationAndDryingSystem.GetScrubberCondenser(solvableName); ScrubberCondenserControl newCtrl = new ScrubberCondenserControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is MixerControl) { MixerControl persistedCtrl = (MixerControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); Mixer uo = flowsheet.EvaporationAndDryingSystem.GetMixer(solvableName); MixerControl newCtrl = new MixerControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is TeeControl) { TeeControl persistedCtrl = (TeeControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); Tee uo = flowsheet.EvaporationAndDryingSystem.GetTee(solvableName); TeeControl newCtrl = new TeeControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is FlashTankControl) { FlashTankControl persistedCtrl = (FlashTankControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); FlashTank uo = flowsheet.EvaporationAndDryingSystem.GetFlashTank(solvableName); FlashTankControl newCtrl = new FlashTankControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is FanControl) { FanControl persistedCtrl = (FanControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); Fan uo = flowsheet.EvaporationAndDryingSystem.GetFan(solvableName); FanControl newCtrl = new FanControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is ValveControl) { ValveControl persistedCtrl = (ValveControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); Valve uo = flowsheet.EvaporationAndDryingSystem.GetValve(solvableName); ValveControl newCtrl = new ValveControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is BagFilterControl) { BagFilterControl persistedCtrl = (BagFilterControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); BagFilter uo = flowsheet.EvaporationAndDryingSystem.GetBagFilter(solvableName); BagFilterControl newCtrl = new BagFilterControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is AirFilterControl) { AirFilterControl persistedCtrl = (AirFilterControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); AirFilter uo = flowsheet.EvaporationAndDryingSystem.GetAirFilter(solvableName); AirFilterControl newCtrl = new AirFilterControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is CompressorControl) { CompressorControl persistedCtrl = (CompressorControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); Compressor uo = flowsheet.EvaporationAndDryingSystem.GetCompressor(solvableName); CompressorControl newCtrl = new CompressorControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is HeaterControl) { HeaterControl persistedCtrl = (HeaterControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); Heater uo = flowsheet.EvaporationAndDryingSystem.GetHeater(solvableName); HeaterControl newCtrl = new HeaterControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is CoolerControl) { CoolerControl persistedCtrl = (CoolerControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); Cooler uo = flowsheet.EvaporationAndDryingSystem.GetCooler(solvableName); CoolerControl newCtrl = new CoolerControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is ElectrostaticPrecipitatorControl) { ElectrostaticPrecipitatorControl persistedCtrl = (ElectrostaticPrecipitatorControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); ElectrostaticPrecipitator uo = flowsheet.EvaporationAndDryingSystem.GetElectrostaticPrecipitator(solvableName); ElectrostaticPrecipitatorControl newCtrl = new ElectrostaticPrecipitatorControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is PumpControl) { PumpControl persistedCtrl = (PumpControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); Pump uo = flowsheet.EvaporationAndDryingSystem.GetPump(solvableName); PumpControl newCtrl = new PumpControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is RecycleControl) { RecycleControl persistedCtrl = (RecycleControl)obj; string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string)); Recycle uo = flowsheet.EvaporationAndDryingSystem.GetRecycle(solvableName); RecycleControl newCtrl = new RecycleControl(flowsheet, new Point(0, 0), uo); newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext); flowsheet.Controls.Add(newCtrl); } else if (obj is SolvableConnection) { SolvableConnection persistedDc = (SolvableConnection)obj; SolvableConnection dc = new SolvableConnection(flowsheet); dc.SetObjectData(persistedDc.SerializationInfo, persistedDc.StreamingContext); flowsheet.ConnectionManager.Connections.Add(dc); } else if (obj is FlowsheetPreferences) { FlowsheetPreferences flowsheetPrefs = obj as FlowsheetPreferences; flowsheetPrefs.SetObjectData(flowsheetPrefs.SerializationInfo, flowsheetPrefs.StreamingContext); flowsheet.BackColor = flowsheetPrefs.BackColor; } else if (obj is ProsimoUI.CustomEditor.CustomEditor) { ProsimoUI.CustomEditor.CustomEditor persistedEditor = (ProsimoUI.CustomEditor.CustomEditor)obj; flowsheet.CustomEditor.SetObjectData(persistedEditor.SerializationInfo, persistedEditor.StreamingContext); } } if (this.CheckFlowsheetVersion(items, flowsheet)) { flowsheet.IsDirty = false; } else { flowsheet = null; } return(flowsheet); }
protected HumidGasCalculator GetHumidGasCalculator(DryingGasStream gasStream) { return((unitOpSystem as EvaporationAndDryingSystem).GetHumidGasCalculator(gasStream.GasComponents.DryMedium.Substance)); }
public GasStreamControl(Flowsheet flowsheet, Point location, DryingGasStream gasStream, StreamOrientation orientation) : base(flowsheet, location, gasStream, orientation) { InitializeComponent(); this.Name = "Gas Stream: " + gasStream.Name; }
public GasStreamControl(Flowsheet flowsheet, Point location, DryingGasStream gasStream) : base(flowsheet, location, gasStream) { InitializeComponent(); }
public override void Execute(bool propagate) { PreSolve(); //BalanceSpecificEnthalpy(gasInlet, gasOutlet); BalanceAdiabaticProcess(gasInlet, gasOutlet); //dry gas flow balance if (gasInlet is DryingGasStream) { DryingGasStream inlet = gasInlet as DryingGasStream; DryingGasStream outlet = gasOutlet as DryingGasStream; //balance gas stream flow BalanceDryingStreamMoistureContent(inlet, outlet); BalanceDryingGasStreamFlow(inlet, outlet); AdjustVarsStates(inlet, outlet); } else if (gasInlet is ProcessStream) { BalanceProcessStreamFlow(gasInlet, gasOutlet); } if (calculationType == UnitOpCalculationType.Balance) { //balance presssure BalancePressure(gasInlet, gasOutlet, GasPressureDrop); UpdateStreamsIfNecessary(); balanceModel.DoBalanceCalculation(); if (solveState == SolveState.PartiallySolved && GasPressureDrop.HasValue && gasInlet.Pressure.HasValue && gasOutlet.Pressure.HasValue) { solveState = SolveState.Solved; } if (solveState == SolveState.Solved) { Calculate(particleOutlet.MassFlowRate, ParticleCollectionRate.Value); balanceModel.PostBalanceCalculation(); } } else if (calculationType == UnitOpCalculationType.Rating) { if (currentRatingModel.IsRatingCalcReady()) { currentRatingModel.DoRatingCalculation(); //balance presssure BalancePressure(gasInlet, gasOutlet, GasPressureDrop); if (solveState == SolveState.PartiallySolved && GasPressureDrop.HasValue && gasInlet.Pressure.HasValue && gasOutlet.Pressure.HasValue) { solveState = SolveState.Solved; } if (HasSolvedAlready) { UpdateStreamsIfNecessary(); balanceModel.DoBalanceCalculation(); } balanceModel.PostBalanceCalculation(); } } PostSolve(); }
public ErrorMessage SetState(DryingGasStream gasStream, PointF pt) { double p = pressure.Value; double temperature = (double)pt.X; double humidity = (double)pt.Y; double wetBulb; double dewPoint; double relativeHumidity; HumidGasCalculator humidGasCalculator = GetHumidGasCalculator(); Hashtable varAndValueTable = new Hashtable(); if (gasStream.Temperature.IsSpecified) { if (gasStream.Humidity.IsSpecified) { varAndValueTable.Add(gasStream.MoistureContentDryBase, humidity); } else if (gasStream.WetBulbTemperature.IsSpecified) { wetBulb = humidGasCalculator.GetWetBulbFromDryBulbHumidityAndPressure(temperature, humidity, p); varAndValueTable.Add(gasStream.WetBulbTemperature, wetBulb); } else if (gasStream.DewPoint.IsSpecified) { dewPoint = humidGasCalculator.GetDewPointFromHumidityAndPressure(humidity, p); varAndValueTable.Add(gasStream.DewPoint, dewPoint); } else if (gasStream.RelativeHumidity.IsSpecified) { relativeHumidity = humidGasCalculator.GetRelativeHumidityFromDryBulbHumidityAndPressure(temperature, humidity, p); varAndValueTable.Add(gasStream.RelativeHumidity, relativeHumidity); } varAndValueTable.Add(gasStream.Temperature, temperature); } else if (gasStream.WetBulbTemperature.IsSpecified) { if (outputStream.DewPoint.IsSpecified) { dewPoint = humidGasCalculator.GetDewPointFromHumidityAndPressure(humidity, p); varAndValueTable.Add(gasStream.DewPoint, dewPoint); } else if (gasStream.RelativeHumidity.IsSpecified) { relativeHumidity = humidGasCalculator.GetRelativeHumidityFromDryBulbHumidityAndPressure(temperature, humidity, p); varAndValueTable.Add(currentStream.RelativeHumidity, relativeHumidity); } wetBulb = humidGasCalculator.GetWetBulbFromDryBulbHumidityAndPressure(temperature, humidity, p); varAndValueTable.Add(gasStream.WetBulbTemperature, wetBulb); } else if (gasStream.DewPoint.IsSpecified) { if (gasStream.RelativeHumidity.IsSpecified) { relativeHumidity = humidGasCalculator.GetRelativeHumidityFromDryBulbHumidityAndPressure(temperature, humidity, pressure.Value); varAndValueTable.Add(outputStream.RelativeHumidity, relativeHumidity); } dewPoint = humidGasCalculator.GetDewPointFromHumidityAndPressure(humidity, pressure.Value); varAndValueTable.Add(gasStream.DewPoint, dewPoint); } return(gasStream.Specify(varAndValueTable)); }
//implement interface IGasSolidSeparator public double CalculateParticleLoading(ProcessStreamBase psb) { DryingGasStream stream = psb as DryingGasStream; return(balanceModel.CalculateParticleLoading(stream)); }
public PsychrometricChartModel(string name, DryingGasStream input, DryingGasStream output, DryingGasStream current, UnitOperationSystem uoSys) : base(name, uoSys) { this.inputStream = input; inputStream.DownStreamOwner = this; this.outputStream = output; outputStream.UpStreamOwner = this; pressure = new ProcessVarDouble(StringConstants.PRESSURE, PhysicalQuantity.Pressure, 1.0132685e5, VarState.Specified, this); this.currentStream = current; currentStream.DownStreamOwner = this; inputStream.Pressure = pressure; outputStream.Pressure = pressure; currentStream.Pressure = pressure; ProcessVarDouble dryBulbTemp = new ProcessVarDouble(StringConstants.DRY_BULB_TEMPERATURE, PhysicalQuantity.Temperature, 293.15, VarState.Specified, this); xVar = new PlotVariable(dryBulbTemp, 283.15, 373.15); ProcessVarDouble humidity = new ProcessVarDouble(StringConstants.ABSOLUTE_HUMIDITY, PhysicalQuantity.MoistureContent, 0.1, VarState.Specified, this); string moistureName = ((EvaporationAndDryingSystem)(unitOpSystem)).DryingMaterial.Moisture.Name; double humidityScale = humidityScaleTable[moistureName]; //yVar = new PlotVariable(humidity, 0.0, 0.3); yVar = new PlotVariable(humidity, 0.0, humidityScale); GenerateHumidityChartData(); inletStreams.Add(inputStream); outletStreams.Add(outputStream); InitializeStreams(); this.hcType = HCType.GasState; }
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 UpdateStreamsUI() { // clear the stream group-boxes and start again //this.groupBoxDryingMedium.Controls.Clear(); //this.groupBoxMaterial.Controls.Clear(); Dryer dryer = this.DryerCtrl.Dryer; bool hasGasIn = false; bool hasGasOut = false; bool hasMaterialIn = false; bool hasMaterialOut = false; DryingGasStream gasIn = dryer.GasInlet; if (gasIn != null) { hasGasIn = true; } DryingGasStream gasOut = dryer.GasOutlet; if (gasOut != null) { hasGasOut = true; } DryingMaterialStream materialIn = dryer.MaterialInlet; if (materialIn != null) { hasMaterialIn = true; } DryingMaterialStream materialOut = dryer.MaterialOutlet; if (materialOut != null) { hasMaterialOut = true; } GasStreamControl gasInCtrl, gasOutCtrl; MaterialStreamControl materialInCtrl, materialOutCtrl; if (hasGasIn) { gasInCtrl = (GasStreamControl)this.DryerCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(this.DryerCtrl.Dryer.GasInlet.Name); initializeGrid(gasInCtrl, columnIndex, false, "Drying Medium Inlet/Outlet"); columnIndex += 2; if (hasGasOut) { gasOutCtrl = (GasStreamControl)this.DryerCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(this.DryerCtrl.Dryer.GasOutlet.Name); initializeGrid(gasOutCtrl, columnIndex, true, "Drying Medium Inlet/Outlet"); columnIndex++; } UI.SetStatusColor(this.statusBar, dryer.GasInlet.SolveState); } else if (hasGasOut) { gasOutCtrl = (GasStreamControl)this.DryerCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(this.DryerCtrl.Dryer.GasOutlet.Name); initializeGrid(gasOutCtrl, columnIndex, false, "Drying Medium Inlet/Outlet"); columnIndex += 2; UI.SetStatusColor(this.statusBar, dryer.GasOutlet.SolveState); } if (hasMaterialIn) { materialInCtrl = (MaterialStreamControl)this.DryerCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(this.DryerCtrl.Dryer.MaterialInlet.Name); initializeGrid(materialInCtrl, columnIndex, false, "Material Inlet/Outlet"); columnIndex += 2; if (hasMaterialOut) { materialOutCtrl = (MaterialStreamControl)this.DryerCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(this.DryerCtrl.Dryer.MaterialOutlet.Name); initializeGrid(materialOutCtrl, columnIndex, true, "Material Inlet/Outlet"); columnIndex++; } UI.SetStatusColor(this.statusBar, dryer.MaterialInlet.SolveState); } else if (hasMaterialOut) { materialOutCtrl = (MaterialStreamControl)this.DryerCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(this.DryerCtrl.Dryer.MaterialOutlet.Name); initializeGrid(materialOutCtrl, columnIndex, true, "Material Inlet/Outlet"); columnIndex += 2; UI.SetStatusColor(this.statusBar, dryer.MaterialOutlet.SolveState); } }