Ejemplo n.º 1
0
        private double CalculateBoilingPointLiquidOutlet(double massConcentration)
        {
            double retValue = 0;

            if (inlet is DryingMaterialStream)
            {
                DryingMaterialStream dmsLiquidOutlet = liquidOutlet as DryingMaterialStream;
                retValue = dmsLiquidOutlet.GetBoilingPoint(dmsLiquidOutlet.Pressure.Value, (1.0 - massConcentration));
            }
            return(retValue);
        }
Ejemplo n.º 2
0
        public MaterialStreamControl(Flowsheet flowsheet, Point location, DryingMaterialStream materialStream) :
            base(flowsheet, location, materialStream)
        {
            InitializeComponent();

            this.Size = new System.Drawing.Size(UI.STREAM_CTRL_W, UI.STREAM_CTRL_H);
            UI.SetStatusColor(this, this.MaterialStream.SolveState);
            this.Orientation = StreamOrientation.Right;
            this.UpdateBackImage();
            this.flowsheet.ConnectionManager.UpdateConnections(this);
        }
Ejemplo n.º 3
0
        private double CalculateSpecificEnthalpyLiquidOutlet(double massConcentration)
        {
            double retValue = 0;

            if (inlet is DryingMaterialStream)
            {
                DryingMaterialStream dmsLiquidOutlet = liquidOutlet as DryingMaterialStream;
                retValue = dmsLiquidOutlet.GetBubblePointEnthalpy(dmsLiquidOutlet.Pressure.Value, (1.0 - massConcentration));
            }
            return(retValue);
        }
Ejemplo n.º 4
0
 public MaterialStreamControl(Flowsheet flowsheet, Point location, DryingMaterialStream materialStream, StreamOrientation orientation)
     : base(flowsheet, location, materialStream, orientation)
 {
     if (materialStream.MaterialStateType == MaterialStateType.Liquid)
     {
         this.Name = "Material Stream (Liquid): " + materialStream.Name;
     }
     else if (materialStream.MaterialStateType == MaterialStateType.Solid)
     {
         this.Name = "Material Stream (Solid): " + materialStream.Name;
     }
 }
Ejemplo n.º 5
0
 public void InitializeVariableLabels(DryingMaterialStream stream)
 {
     this.labelMassFlowRateDryBase.InitializeVariable(stream.MassFlowRateDryBase);
     this.labelMassFlowRate.InitializeVariable(stream.MassFlowRate);
     this.labelVolumeFlowRate.InitializeVariable(stream.VolumeFlowRate);
     this.labelPressure.InitializeVariable(stream.Pressure);
     this.labelTemperature.InitializeVariable(stream.Temperature);
     this.labelMoistureContentDryBase.InitializeVariable(stream.MoistureContentDryBase);
     this.labelMoistureContentWetBase.InitializeVariable(stream.MoistureContentWetBase);
     this.labelConcentration.InitializeVariable(stream.MassConcentration);
     this.labelSpecificHeat.InitializeVariable(stream.SpecificHeat);
     this.labelSpecificHeatDryBase.InitializeVariable(stream.SpecificHeatDryBase);
     this.labelDensity.InitializeVariable(stream.Density);
     this.labelSpecificEnthalpy.InitializeVariable(stream.SpecificEnthalpy);
     this.labelVaporFraction.InitializeVariable(stream.VaporFraction);
 }
Ejemplo n.º 6
0
        private void EvaporationAndDryingSystem_StreamAdded(ProcessStreamBase processStreamBase)
        {
            Point location = new System.Drawing.Point(this.flowsheet.X, this.flowsheet.Y);
            ProcessStreamBaseControl control = null;

            if (processStreamBase is DryingGasStream)
            {
                DryingGasStream stream = (DryingGasStream)processStreamBase;
                control = new GasStreamControl(this.flowsheet, location, stream);
            }
            else if (processStreamBase is DryingMaterialStream)
            {
                DryingMaterialStream stream = (DryingMaterialStream)processStreamBase;
                control = new MaterialStreamControl(this.flowsheet, location, stream);
            }
            else if (processStreamBase is WaterStream)
            {
                WaterStream stream = (WaterStream)processStreamBase;
                control = new WaterStreamControl(this.flowsheet, location, stream);
            }
            else if (processStreamBase is DetailedFuelStream)
            {
                DetailedFuelStream stream = (DetailedFuelStream)processStreamBase;
                control = new DetailedFuelStreamControl(this.flowsheet, location, stream);
            }


            // adjust the location if at the limit of the flowsheet
            if (this.flowsheet.X > this.flowsheet.Width - control.Width / 2)
            {
                int   newX        = this.flowsheet.Width - control.Width;
                Point newLocation = new Point(newX, control.Location.Y);
                control.Location = newLocation;
            }
            if (this.flowsheet.Y > this.flowsheet.Height - control.Height / 2)
            {
                int   newY        = this.flowsheet.Height - control.Height;
                Point newLocation = new Point(control.Location.X, newY);
                control.Location = newLocation;
            }

            this.flowsheet.Controls.Add(control);
            this.flowsheet.IsDirty = true;
        }
Ejemplo n.º 7
0
        public override void Execute(bool propagate)
        {
            PreSolve();
            BalancePressure(inlet, outlet, pressureDrop);

            //dry gas flow balance
            if (inlet is DryingGasStream)
            {
                DryingGasStream dsInlet  = inlet as DryingGasStream;
                DryingGasStream dsOutlet = outlet as DryingGasStream;

                //BalanceAdiabaticProcess(inlet, outlet);
                BalanceSpecificEnthalpy(inlet, outlet);
                //balance gas stream flow
                BalanceDryingStreamMoistureContent(dsInlet, dsOutlet);
                BalanceDryingGasStreamFlow(dsInlet, dsOutlet);
                AdjustVarsStates(dsInlet, dsOutlet);
            }

            else if (inlet is DryingMaterialStream)
            {
                DryingMaterialStream dsInlet  = inlet as DryingMaterialStream;
                DryingMaterialStream dsOutlet = outlet as DryingMaterialStream;

                //balance gas stream flow
                BalanceDryingStreamMoistureContent(dsInlet, dsOutlet);
                BalanceDryingMaterialStreamFlow(dsInlet, dsOutlet);
                BalanceSpecificEnthalpy(inlet, outlet);
                AdjustVarsStates(dsInlet, dsOutlet);
            }
            else if (inlet is ProcessStream)
            {
                BalanceProcessStreamFlow(inlet, outlet);
            }

            if (inlet.Pressure.HasValue && outlet.Pressure.HasValue &&
                inlet.SpecificEnthalpy.HasValue && outlet.SpecificEnthalpy.HasValue)
            {
                solveState = SolveState.Solved;
            }

            PostSolve();
        }
Ejemplo n.º 8
0
        protected virtual void BalanceDryingMaterialStreamFlow(DryingMaterialStream inlet, DryingMaterialStream outlet)
        {
            //dry materail flow balance
            if (inlet.MaterialStateType == MaterialStateType.Liquid && outlet.MaterialStateType == MaterialStateType.Liquid)
            {
                if (inlet.MassFlowRate.HasValue && !outlet.MassFlowRate.HasValue)
                {
                    Calculate(outlet.MassFlowRate, inlet.MassFlowRate.Value);
                }
                else if (outlet.MassFlowRate.HasValue && !inlet.MassFlowRate.HasValue)
                {
                    Calculate(inlet.MassFlowRate, outlet.MassFlowRate.Value);
                }

                if (inlet.MassFlowRateDryBase.HasValue && !outlet.MassFlowRateDryBase.HasValue)
                {
                    Calculate(outlet.MassFlowRateDryBase, inlet.MassFlowRateDryBase.Value);
                }
                else if (outlet.MassFlowRateDryBase.HasValue && !inlet.MassFlowRateDryBase.HasValue)
                {
                    Calculate(inlet.MassFlowRateDryBase, outlet.MassFlowRateDryBase.Value);
                }
            }
            else
            {
                if (inlet.MassFlowRateDryBase.HasValue && !outlet.MassFlowRateDryBase.HasValue)
                {
                    Calculate(outlet.MassFlowRateDryBase, inlet.MassFlowRateDryBase.Value);
                }
                else if (outlet.MassFlowRateDryBase.HasValue && !inlet.MassFlowRateDryBase.HasValue)
                {
                    Calculate(inlet.MassFlowRateDryBase, outlet.MassFlowRateDryBase.Value);
                }
                else if (inlet.MassFlowRate.HasValue && inlet.MoistureContentDryBase.HasValue && !outlet.MassFlowRateDryBase.HasValue)
                {
                    Calculate(outlet.MassFlowRateDryBase, inlet.MassFlowRate.Value / (1.0 + inlet.MoistureContentDryBase.Value));
                }
                else if (outlet.MassFlowRate.HasValue && outlet.MoistureContentDryBase.HasValue && !inlet.MassFlowRateDryBase.HasValue)
                {
                    Calculate(inlet.MassFlowRateDryBase, outlet.MassFlowRate.Value / (1.0 + outlet.MoistureContentDryBase.Value));
                }
            }
        }
Ejemplo n.º 9
0
        public override void Execute(bool propagate)
        {
            PreSolve();
            BalanceSpecificEnthalpy(inlet, outlet);

            if (inlet.Density.HasValue && !outlet.Density.HasValue)
            {
                Calculate(outlet.Density, inlet.Density.Value);
            }
            else if (outlet.Density.HasValue && !inlet.Density.HasValue)
            {
                Calculate(inlet.Density, outlet.Density.Value);
            }

            //dry gas flow balance
            if (inlet is DryingMaterialStream)
            {
                DryingMaterialStream dmsInlet  = inlet as DryingMaterialStream;
                DryingMaterialStream dmsOutlet = outlet as DryingMaterialStream;

                //balance gas stream flow
                BalanceDryingStreamMoistureContent(dmsInlet, dmsOutlet);
                BalanceDryingMaterialStreamFlow(dmsInlet, dmsOutlet);
                //BalanceDryingMaterialStreamSpecificHeat(dmsInlet, dmsOutlet);
                //have to recalculate the streams so that the following balance calcualtion
                //can have all the latest balance calculated values taken into account
                UpdateStreamsIfNecessary();

                AdjustVarsStates(dmsInlet, dmsOutlet);
            }
            else if (inlet is ProcessStream)
            {
                BalanceProcessStreamFlow(inlet, outlet);
            }

            Solve();
            PostSolve();
        }
Ejemplo n.º 10
0
        private double CalculateSpecificEnthalpyVaporOutlet(double tBoilingPointOutlet)
        {
            //SteamTable steamTable = SteamTable.GetInstance();
            //SubstanceStatesAndProperties props = steamTable.GetPropertiesFromPressureAndTemperature(vaporOutlet.Pressure.Value, tBoilingPointOutlet);
            //return props.enthalpy;
            double hValue = 0;

            if (inlet is DryingMaterialStream)
            {
                DryingMaterialStream dmsVaporOutlet = vaporOutlet as DryingMaterialStream;
                double pValue        = vaporOutlet.Pressure.Value;
                double hBubble       = dmsVaporOutlet.GetBubblePointEnthalpy(pValue, 1.0);
                double tBoilingPoint = dmsVaporOutlet.GetBoilingPoint(pValue, 0);
                double evapHeat      = vaporOutlet.GetEvaporationHeat(tBoilingPoint);

                SteamTable steamTable = SteamTable.GetInstance();
                SubstanceStatesAndProperties props = steamTable.GetPropertiesFromPressureAndVaporFraction(pValue, 1.0);
                double hVapor1 = props.enthalpy;
                props = steamTable.GetPropertiesFromPressureAndTemperature(pValue, tBoilingPointOutlet + 1.0e-6);
                double hVapor2 = props.enthalpy;
                hValue = hBubble + evapHeat + (hVapor2 - hVapor1);
            }
            return(hValue);
        }
Ejemplo n.º 11
0
        private void Solve()
        {
            //flow balance
            if (slurryInlet.MassFlowRate.HasValue)
            {
                if (cakeOutlet.MassFlowRate.HasValue)
                {
                    Calculate(filtrateOutlet.MassFlowRate, slurryInlet.MassFlowRate.Value - cakeOutlet.MassFlowRate.Value);
                }
                else if (filtrateOutlet.MassFlowRate.HasValue)
                {
                    Calculate(cakeOutlet.MassFlowRate, slurryInlet.MassFlowRate.Value - filtrateOutlet.MassFlowRate.Value);
                }
            }
            else if (cakeOutlet.MassFlowRate.HasValue)
            {
                if (filtrateOutlet.MassFlowRate.HasValue)
                {
                    Calculate(slurryInlet.MassFlowRate, cakeOutlet.MassFlowRate.Value + filtrateOutlet.MassFlowRate.Value);
                }
            }

            if (slurryInlet.Temperature.HasValue)
            {
                Calculate(filtrateOutlet.Temperature, slurryInlet.Temperature.Value);
                Calculate(cakeOutlet.Temperature, slurryInlet.Temperature.Value);
            }
            else if (filtrateOutlet.Temperature.HasValue)
            {
                Calculate(slurryInlet.Temperature, filtrateOutlet.Temperature.Value);
                Calculate(cakeOutlet.Temperature, filtrateOutlet.Temperature.Value);
            }
            else if (cakeOutlet.Temperature.HasValue)
            {
                Calculate(slurryInlet.Temperature, cakeOutlet.Temperature.Value);
                Calculate(filtrateOutlet.Temperature, cakeOutlet.Temperature.Value);
            }

            if (slurryInlet is DryingMaterialStream)
            {
                DryingMaterialStream dmsInlet          = slurryInlet as DryingMaterialStream;
                DryingMaterialStream dmsFiltrateOutlet = filtrateOutlet as DryingMaterialStream;
                DryingMaterialStream dmsCakeOutlet     = cakeOutlet as DryingMaterialStream;
                if (dmsInlet.MassFlowRate.HasValue && dmsInlet.MoistureContentWetBase.HasValue)
                {
                    double totalSolid = dmsInlet.MassFlowRate.Value * dmsInlet.MoistureContentWetBase.Value;
                    if (dmsCakeOutlet.MassFlowRate.HasValue && dmsCakeOutlet.MoistureContentWetBase.HasValue)
                    {
                        double cakeSolid = dmsCakeOutlet.MassFlowRate.Value * dmsCakeOutlet.MoistureContentWetBase.Value;
                        if (dmsFiltrateOutlet.MassFlowRate.HasValue)
                        {
                            double filtrateMassConcentration = (totalSolid - cakeSolid) / dmsFiltrateOutlet.MassFlowRate.Value;
                            Calculate(dmsFiltrateOutlet.MassConcentration, filtrateMassConcentration);
                        }
                        else if (dmsFiltrateOutlet.MassConcentration.HasValue)
                        {
                            double filtrateFlowRate = (totalSolid - cakeSolid) / dmsFiltrateOutlet.MassConcentration.Value;
                            Calculate(dmsFiltrateOutlet.MassFlowRate, filtrateFlowRate);
                        }
                    }
                    else if (dmsFiltrateOutlet.MassFlowRate.HasValue && dmsFiltrateOutlet.MoistureContentWetBase.HasValue)
                    {
                        double filtrateSolid = dmsFiltrateOutlet.MassFlowRate.Value * dmsFiltrateOutlet.MoistureContentWetBase.Value;
                        if (dmsCakeOutlet.MassFlowRate.HasValue)
                        {
                            double cakeMassConcentration = (totalSolid - filtrateSolid) / dmsCakeOutlet.MassFlowRate.Value;
                            Calculate(dmsCakeOutlet.MassConcentration, cakeMassConcentration);
                        }
                        else if (dmsCakeOutlet.MassConcentration.HasValue)
                        {
                            double cakeFlowRate = (totalSolid - filtrateSolid) / dmsCakeOutlet.MassConcentration.Value;
                            Calculate(dmsCakeOutlet.MassFlowRate, cakeFlowRate);
                        }
                    }
                }
                else if (dmsCakeOutlet.MassFlowRate.HasValue && dmsCakeOutlet.MoistureContentWetBase.HasValue)
                {
                    double cakeSolid = dmsCakeOutlet.MassFlowRate.Value * dmsCakeOutlet.MoistureContentWetBase.Value;
                    if (dmsFiltrateOutlet.MassFlowRate.HasValue && dmsFiltrateOutlet.MoistureContentWetBase.HasValue)
                    {
                        double filtrateSolid = dmsFiltrateOutlet.MassFlowRate.Value * dmsFiltrateOutlet.MoistureContentWetBase.Value;
                        if (dmsInlet.MassFlowRate.HasValue)
                        {
                            double slurryMassConcentration = (cakeSolid + filtrateSolid) / dmsInlet.MassFlowRate.Value;
                            Calculate(dmsInlet.MassConcentration, slurryMassConcentration);
                        }
                        else if (dmsInlet.MassConcentration.HasValue)
                        {
                            double slurryFlowRate = (cakeSolid + filtrateSolid) / dmsInlet.MassConcentration.Value;
                            Calculate(dmsInlet.MassFlowRate, slurryFlowRate);
                        }
                    }
                }
            }
        }
Ejemplo n.º 12
0
        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);
                //}
            }
        }
Ejemplo n.º 13
0
        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);
            }
        }
Ejemplo n.º 14
0
        private void Solve()
        {
            //flow balance
            if (entrainmentRatio.HasValue)
            {
                if (motiveInlet.MassFlowRate.HasValue)
                {
                    Calculate(suctionInlet.MassFlowRate, motiveInlet.MassFlowRate.Value * entrainmentRatio.Value);
                    Calculate(dischargeOutlet.MassFlowRate, (motiveInlet.MassFlowRate.Value + suctionInlet.MassFlowRate.Value));
                }
                else if (suctionInlet.MassFlowRate.HasValue)
                {
                    Calculate(motiveInlet.MassFlowRate, suctionInlet.MassFlowRate.Value / entrainmentRatio.Value);
                    Calculate(dischargeOutlet.MassFlowRate, (motiveInlet.MassFlowRate.Value + suctionInlet.MassFlowRate.Value));
                }
                else if (dischargeOutlet.MassFlowRate.HasValue)
                {
                    Calculate(motiveInlet.MassFlowRate, dischargeOutlet.MassFlowRate.Value / (1.0 + entrainmentRatio.Value));
                    Calculate(suctionInlet.MassFlowRate, motiveInlet.MassFlowRate.Value * entrainmentRatio.Value);
                }
            }
            else if (motiveInlet.MassFlowRate.HasValue)
            {
                if (suctionInlet.MassFlowRate.HasValue)
                {
                    Calculate(entrainmentRatio, suctionInlet.MassFlowRate.Value / motiveInlet.MassFlowRate.Value);
                    Calculate(dischargeOutlet.MassFlowRate, (motiveInlet.MassFlowRate.Value + suctionInlet.MassFlowRate.Value));
                }
                else if (dischargeOutlet.MassFlowRate.HasValue)
                {
                    Calculate(suctionInlet.MassFlowRate, dischargeOutlet.MassFlowRate.Value - motiveInlet.MassFlowRate.Value);
                    Calculate(entrainmentRatio, suctionInlet.MassFlowRate.Value / motiveInlet.MassFlowRate.Value);
                }
            }
            else if (suctionInlet.MassFlowRate.HasValue)
            {
                if (dischargeOutlet.MassFlowRate.HasValue)
                {
                    Calculate(motiveInlet.MassFlowRate, dischargeOutlet.MassFlowRate.Value - suctionInlet.MassFlowRate.Value);
                    Calculate(entrainmentRatio, suctionInlet.MassFlowRate.Value / motiveInlet.MassFlowRate.Value);
                }
            }

            //material balance if necessary
            if (motiveInlet is DryingMaterialStream)
            {
                DryingMaterialStream mInlet  = motiveInlet as DryingMaterialStream;
                DryingMaterialStream sInlet  = suctionInlet as DryingMaterialStream;
                DryingMaterialStream dOutlet = dischargeOutlet as DryingMaterialStream;
                if (mInlet.MassFlowRate.HasValue && mInlet.MassConcentration.HasValue &&
                    sInlet.MassFlowRate.HasValue && sInlet.MassConcentration.HasValue && dOutlet.MassFlowRate.HasValue)
                {
                    double dOutletConcentration = (mInlet.MassFlowRate.Value * mInlet.MassConcentration.Value +
                                                   sInlet.MassFlowRate.Value * sInlet.MassConcentration.Value) / dOutlet.MassFlowRate.Value;
                    Calculate(dOutlet.MassConcentration, dOutletConcentration);
                }
                else if (mInlet.MassFlowRate.HasValue && mInlet.MassConcentration.HasValue &&
                         dOutlet.MassFlowRate.HasValue && dOutlet.MassConcentration.HasValue && sInlet.MassFlowRate.HasValue)
                {
                    double sInletConcentration = (dOutlet.MassFlowRate.Value * dOutlet.MassConcentration.Value -
                                                  mInlet.MassFlowRate.Value * mInlet.MassConcentration.Value) / sInlet.MassFlowRate.Value;
                    Calculate(sInlet.MassConcentration, sInletConcentration);
                }
                else if (sInlet.MassFlowRate.HasValue && sInlet.MassConcentration.HasValue &&
                         dOutlet.MassFlowRate.HasValue && dOutlet.MassConcentration.HasValue && mInlet.MassFlowRate.HasValue)
                {
                    double sInletConcentration = (dOutlet.MassFlowRate.Value * dOutlet.MassConcentration.Value -
                                                  sInlet.MassFlowRate.Value * sInlet.MassConcentration.Value) / sInlet.MassFlowRate.Value;
                    Calculate(mInlet.MassConcentration, sInletConcentration);
                }
            }

            //pressure balance
            if (suctionInlet.Pressure.HasValue)
            {
                if (compressionRatio.HasValue)
                {
                    Calculate(dischargeOutlet.Pressure, suctionInlet.Pressure.Value * compressionRatio.Value);
                }
                else if (dischargeOutlet.Pressure.HasValue)
                {
                    Calculate(compressionRatio, dischargeOutlet.Pressure.Value / suctionInlet.Pressure.Value);
                }

                if (suctionMotivePressureRatio.HasValue)
                {
                    Calculate(motiveInlet.Pressure, suctionInlet.Pressure.Value / suctionMotivePressureRatio.Value);
                }
                else if (motiveInlet.Pressure.HasValue)
                {
                    Calculate(suctionMotivePressureRatio, suctionInlet.Pressure.Value / motiveInlet.Pressure.Value);
                }
            }
            else if (motiveInlet.Pressure.HasValue)
            {
                if (suctionMotivePressureRatio.HasValue)
                {
                    Calculate(suctionInlet.Pressure, motiveInlet.Pressure.Value * suctionMotivePressureRatio.Value);
                }
                else if (suctionInlet.Pressure.HasValue)
                {
                    Calculate(suctionMotivePressureRatio, suctionInlet.Pressure.Value / motiveInlet.Pressure.Value);
                }
            }
            else if (dischargeOutlet.Pressure.HasValue)
            {
                if (compressionRatio.HasValue && dischargeOutlet.Pressure.HasValue)
                {
                    Calculate(suctionInlet.Pressure, dischargeOutlet.Pressure.Value / compressionRatio.Value);
                }
            }

            //energy balance
            if (motiveInlet.SpecificEnthalpy.HasValue && motiveInlet.MassFlowRate.HasValue &&
                suctionInlet.SpecificEnthalpy.HasValue && suctionInlet.MassFlowRate.HasValue &&
                dischargeOutlet.MassFlowRate.HasValue)
            {
                double dischargeSpecificEnthalpy = (motiveInlet.SpecificEnthalpy.Value * motiveInlet.MassFlowRate.Value +
                                                    suctionInlet.SpecificEnthalpy.Value * suctionInlet.MassFlowRate.Value) / dischargeOutlet.MassFlowRate.Value;
                Calculate(dischargeOutlet.SpecificEnthalpy, dischargeSpecificEnthalpy);
            }
            else if (motiveInlet.SpecificEnthalpy.HasValue && motiveInlet.MassFlowRate.HasValue &&
                     dischargeOutlet.SpecificEnthalpy.HasValue && dischargeOutlet.MassFlowRate.HasValue &&
                     suctionInlet.MassFlowRate.HasValue)
            {
                double suctionSpecificEnthalpy = (dischargeOutlet.SpecificEnthalpy.Value * dischargeOutlet.MassFlowRate.Value -
                                                  motiveInlet.SpecificEnthalpy.Value * motiveInlet.MassFlowRate.Value) / suctionInlet.MassFlowRate.Value;
                Calculate(suctionInlet.SpecificEnthalpy, suctionSpecificEnthalpy);
            }
            else if (suctionInlet.SpecificEnthalpy.HasValue && suctionInlet.MassFlowRate.HasValue &&
                     dischargeOutlet.SpecificEnthalpy.HasValue && dischargeOutlet.MassFlowRate.HasValue &&
                     motiveInlet.MassFlowRate.HasValue)
            {
                double motiveSpecificEnthalpy = (dischargeOutlet.SpecificEnthalpy.Value * dischargeOutlet.MassFlowRate.Value -
                                                 suctionInlet.SpecificEnthalpy.Value * suctionInlet.MassFlowRate.Value) / motiveInlet.MassFlowRate.Value;
                Calculate(motiveInlet.SpecificEnthalpy, motiveSpecificEnthalpy);
            }

            if (motiveInlet.MassFlowRate.HasValue && suctionInlet.MassFlowRate.HasValue &&
                dischargeOutlet.MassFlowRate.HasValue && motiveInlet.Pressure.HasValue &&
                suctionInlet.Pressure.HasValue && dischargeOutlet.Pressure.HasValue &&
                motiveInlet.SpecificEnthalpy.HasValue && suctionInlet.SpecificEnthalpy.HasValue &&
                dischargeOutlet.SpecificEnthalpy.HasValue)
            {
                currentSolveState = SolveState.Solved;
            }
        }
Ejemplo n.º 15
0
        //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);
            }
        }
Ejemplo n.º 16
0
 public MaterialStreamControl(Flowsheet flowsheet, Point location, DryingMaterialStream materialStream)
     : base(flowsheet, location, materialStream)
 {
 }
Ejemplo n.º 17
0
 public MaterialStreamControl(Flowsheet flowsheet, Point location, DryingMaterialStream materialStream)
     : this(flowsheet, location, materialStream, StreamOrientation.Right)
 {
 }
Ejemplo n.º 18
0
        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;
            }
        }
Ejemplo n.º 19
0
        private void Solve()
        {
            if (vaporOutlet.Pressure.HasValue)
            {
                Calculate(liquidOutlet.Pressure, vaporOutlet.Pressure.Value);
            }
            else if (liquidOutlet.Pressure.HasValue)
            {
                Calculate(vaporOutlet.Pressure, liquidOutlet.Pressure.Value);
            }

            //if (vaporOutlet.Temperature.HasValue) {
            //   Calculate(liquidOutlet.Temperature, vaporOutlet.Temperature.Value);
            //}
            //else if (liquidOutlet.Temperature.HasValue) {
            //   Calculate(vaporOutlet.Temperature, liquidOutlet.Temperature.Value);
            //}

            //drying material
            if (inlet is DryingMaterialStream)
            {
                DryingMaterialStream dmsInlet        = inlet as DryingMaterialStream;
                DryingMaterialStream dmsVaporOutlet  = vaporOutlet as DryingMaterialStream;
                DryingMaterialStream dmsLiquidOutlet = liquidOutlet as DryingMaterialStream;

                if (inlet.VaporFraction.HasValue && inlet.MassFlowRate.HasValue)
                {
                    //double vaporFraction = inlet.VaporFraction.Value;
                    //double tBoilingPoint1 = inlet.GetBoilingPoint(inlet.Pressure.Value);
                    //double tBoilingPoint2 = inlet.GetBoilingPoint(vaporOutlet.Pressure.Value);
                    //double evapHeat = inlet.GetEvaporationHeat(tBoilingPoint);
                    //double cpLiquid = inlet.SpecificHeat.Value;
                    //double hBoilingPoint = cpLiquid * (tBoilingPoint - 273.15);
                    //double h = inlet.SpecificEnthalpy.Value;
                    //double vaporFraction = (h - hBoilingPoint)/evapHeat;
                    double inletSpecificEnthalpyValue = inlet.SpecificEnthalpy.Value;
                    double tBoilingPointOfSolution    = dmsInlet.GetBoilingPoint(inlet.Pressure.Value);
                    double tBoilingPointOfOutlet      = dmsInlet.GetBoilingPoint(vaporOutlet.Pressure.Value);
                    double cpOfInletLiquid            = dmsInlet.GetLiquidCp(tBoilingPointOfSolution);
                    double evapHeat = dmsInlet.GetEvaporationHeat(tBoilingPointOfSolution);
                    //double hBubble = dmsInlet.GetBubblePointEnthalpy(inlet.Pressure.Value, dmsInlet.MoistureContentWetBase.Value);
                    //double h = hBubble + inlet.VaporFraction.Value * evapHeat;
                    //inletSpecificEnthalpyValue = h;

                    double vaporFractionInlet      = inlet.VaporFraction.Value;
                    double selfEvaporationFraction = cpOfInletLiquid * (tBoilingPointOfSolution - tBoilingPointOfOutlet) / evapHeat;

                    double massFlowRateInlet = inlet.MassFlowRate.Value;
                    double massFlowRateVapor = massFlowRateInlet * (vaporFractionInlet + selfEvaporationFraction);
                    double totalSolidContent = massFlowRateInlet * dmsInlet.MassConcentration.Value;
                    double massFlowRateVaporOld;
                    double massFlowRateLiquid;
                    double massConcentrationLiquidOutlet;
                    double specificEnthalpyLiquid;
                    double specificEnthalpyVapor;
                    double tBoilingPointOutlet;
                    int    counter = 0;
                    do
                    {
                        counter++;
                        massFlowRateLiquid            = massFlowRateInlet - massFlowRateVapor;
                        massConcentrationLiquidOutlet = totalSolidContent / massFlowRateLiquid;
                        specificEnthalpyLiquid        = CalculateSpecificEnthalpyLiquidOutlet(massConcentrationLiquidOutlet);
                        tBoilingPointOutlet           = CalculateBoilingPointLiquidOutlet(massConcentrationLiquidOutlet);
                        specificEnthalpyVapor         = CalculateSpecificEnthalpyVaporOutlet(tBoilingPointOutlet);
                        massFlowRateVaporOld          = massFlowRateVapor;
                        massFlowRateVapor             = massFlowRateInlet * (inletSpecificEnthalpyValue - specificEnthalpyLiquid) / (specificEnthalpyVapor - specificEnthalpyLiquid);
                    } while (Math.Abs(massFlowRateVapor - massFlowRateVaporOld) > 1.0e-6 && counter < 200);

                    if (counter == 200)
                    {
                        throw new CalculationFailedException(this.name + ": Flash tank calculation failed.");
                    }

                    Calculate(vaporOutlet.MassFlowRate, massFlowRateVapor);
                    Calculate(liquidOutlet.MassFlowRate, massFlowRateLiquid);
                    //Calculate(vaporOutlet.VaporFraction, 1.0);
                    Calculate(liquidOutlet.VaporFraction, 0.0);
                    //Calculate(liquidOutlet.Temperature, tBoilingPointOutlet);
                    Calculate(vaporOutlet.Temperature, tBoilingPointOutlet);
                    Calculate(dmsVaporOutlet.MassConcentration, 0);
                    Calculate(dmsLiquidOutlet.MassConcentration, massConcentrationLiquidOutlet);

                    //if (dmsInlet.MassConcentration.HasValue) {
                    //   double liquidConcentration = (massFlowRate * dmsInlet.MassConcentration.Value)/liquidMassFlowRate;
                    //   Calculate(dmsLiquidOutlet.MassConcentration, liquidConcentration);
                    //   Calculate(dmsVaporOutlet.MassConcentration, 0);
                    //}

                    if (dmsLiquidOutlet.MassConcentration.HasValue && dmsVaporOutlet.MassConcentration.HasValue &&
                        dmsLiquidOutlet.Pressure.HasValue)
                    {
                        solveState = SolveState.Solved;
                    }
                }
            }
        }
Ejemplo n.º 20
0
 protected void BalanceDryingMaterialStreamSpecificHeat(DryingMaterialStream inlet, DryingMaterialStream outlet)
 {
     if (inlet.SpecificHeatAbsDry.HasValue && !outlet.SpecificHeatAbsDry.HasValue)
     {
         Calculate(outlet.SpecificHeatAbsDry, inlet.SpecificHeatAbsDry.Value);
     }
     else if (outlet.SpecificHeatAbsDry.HasValue && !inlet.SpecificHeatAbsDry.HasValue)
     {
         Calculate(inlet.SpecificHeatAbsDry, outlet.SpecificHeatAbsDry.Value);
     }
 }
Ejemplo n.º 21
0
        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);
        }
Ejemplo n.º 22
0
 public MaterialStreamLabelsControl(DryingMaterialStream stream) : this()
 {
     this.InitializeVariableLabels(stream);
 }
Ejemplo n.º 23
0
        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);
            }
        }