コード例 #1
0
        private double CalculateTemperatureFromEnthalpyForSolid(double hValue, double moistureContentValue)
        {
            double     cpLiquid = specificHeat.Value;
            double     tValue   = hValue / cpLiquid + 273.15;
            double     tValueOld;
            double     moistureDeltaH;
            SteamTable steamTable = SteamTable.GetInstance();
            SubstanceStatesAndProperties props;
            double moistureRefEnthalpy = steamTable.GetPropertiesFromPressureAndTemperature(Constants.ONE_ATM, 273.15).enthalpy;
            double cs      = GetCpOfAbsoluteDryMaterial();
            int    counter = 0;

            do
            {
                counter++;
                tValueOld      = tValue;
                props          = steamTable.GetPropertiesFromPressureAndTemperature(Constants.ONE_ATM, tValue);
                moistureDeltaH = props.enthalpy - moistureRefEnthalpy;
                tValue         = (hValue - moistureContentValue * moistureDeltaH) / ((1.0 - moistureContentValue) * cs) + 273.15;
                tValue         = tValueOld + 0.5 * (tValue - tValueOld);
            } while (Math.Abs(tValue - tValueOld) > 1.0e-6 && counter < 200);

            if (counter == 200)
            {
                throw new CalculationFailedException(this.name + ": Calculate of temperature from enthalpy failed.");
            }

            return(tValue);
        }
コード例 #2
0
        private double CalculateLiquidEnthalpy(double pValue, double tValue, double moistureContentValue)
        {
            double     tBoilingPointOfSolvent  = MoistureProperties.GetSaturationTemperature(pValue);
            double     tBoilingPointOfSolution = GetBoilingPoint(pValue, (1 - moistureContentValue));
            SteamTable steamTable = SteamTable.GetInstance();
            SubstanceStatesAndProperties props;
            double cs = GetCpOfAbsoluteDryMaterial();
            //double mc = moistureContentWetBase.Value;
            double hValue = Constants.NO_VALUE;

            if (tValue < tBoilingPointOfSolvent)
            {
                props  = steamTable.GetPropertiesFromPressureAndTemperature(pValue, tValue);
                hValue = moistureContentValue * props.enthalpy + (1.0 - moistureContentValue) * cs * (tValue - 273.15);
            }
            else if (tValue <= tBoilingPointOfSolution)
            {
                //props = steamTable.GetPropertiesFromPressureAndTemperature(pValue, tBoilingPointOfSolvent - 0.01);
                props = steamTable.GetPropertiesFromPressureAndVaporFraction(pValue, 0); //P-V flash is more appropriate for buble point enthalpy of pure moisture
                double hBoilingPointOfSolvent = moistureContentValue * props.enthalpy + (1.0 - moistureContentValue) * cs * (tValue - 273.15);
                double moistureLiquidCp       = MoistureProperties.GetSpecificHeatOfLiquid(MathUtility.Average(tBoilingPointOfSolvent, tBoilingPointOfSolution));
                hValue = hBoilingPointOfSolvent + (moistureContentValue * moistureLiquidCp + (1.0 - moistureContentValue) * cs) * (tValue - tBoilingPointOfSolvent);
            }

            return(hValue);
        }
コード例 #3
0
        private void CalculateEnthalpyFromTemperature(double pValue, double tValue, double moistureContentValue)
        {
            //double tBoilingPointOfSolvent = MoistureProperties.GetSaturationTemperature(pValue);
            double tBoilingPointOfSolution = GetBoilingPoint(pValue);
            double hValue;

            if (tValue <= tBoilingPointOfSolution)
            {
                hValue = CalculateLiquidEnthalpy(pValue, tValue, moistureContentValue);
                Calculate(specificEnthalpy, hValue);
                Calculate(vaporFraction, 0.0);
            }
            else if (tValue > tBoilingPointOfSolution)
            {
                double hBubble  = GetBubblePointEnthalpy(pValue, moistureContentValue);
                double evapHeat = GetEvaporationHeat(tBoilingPointOfSolution);

                SteamTable steamTable = SteamTable.GetInstance();
                SubstanceStatesAndProperties props = steamTable.GetPropertiesFromPressureAndTemperature(pValue, tBoilingPointOfSolution + 1.0e-6);
                double hVapor1 = props.enthalpy;
                props = steamTable.GetPropertiesFromPressureAndTemperature(pValue, tValue);
                double hVapor2 = props.enthalpy;
                double cs      = GetCpOfAbsoluteDryMaterial(tValue);
                hValue = hBubble + moistureContentValue * (evapHeat + (hVapor2 - hVapor1)) + (1.0 - moistureContentValue) * cs * (tValue - tBoilingPointOfSolution);

                Calculate(specificEnthalpy, hValue);
                Calculate(vaporFraction, moistureContentValue);
            }
        }
コード例 #4
0
        //Steam Table
        //calculated value unit is J/kg.K, t unit is K
        public static double CalculateWaterEnthalpy(double p, double t)
        {
            SteamTable steamTable = SteamTable.GetInstance();
            double     h          = steamTable.GetEnthalpyFromPressureAndTemperature(p, t);

            return(h);
        }
コード例 #5
0
        //Steam Table
        //calculated value unit is kmol/m3, t unit is K
        public static double CalculateWaterDensity(double p, double t)
        {
            SteamTable steamTable = SteamTable.GetInstance();
            double     density    = steamTable.GetDensityFromPressureAndTemperature(p, t);

            return(density);
        }
コード例 #6
0
        public static double CalculateWaterSaturationPressure(double temperature)
        {
            double pSaturation = 1.0;

            //if (temperature >= 253.15 && temperature <= 283.15) {
            //   pSaturation = 8.8365E-10 * Math.Pow((temperature -193.03), 6.2145);
            //}
            //else if (temperature <= 453.15) {
            //   pSaturation = Math.Exp(23.197 - 3816.44/(temperature - 46.13));
            //}
            if (temperature <= 273.33) //temperature belown which steam table can not deal
            //double t = temperature - 273.15;
            //pSaturation = 100.0 * 6.1121 * Math.Exp(17.502 * t/(240.97 + t));
            //To Do: When system is not air-water, need to change!!!
            {
                pSaturation = ThermalPropCalculator.CalculateWaterSaturationPressureBelowFreezingPoint(temperature);
            }
            else
            {
                //formulation coming from Perry's Chemical Engineer's Handbook
                //pSaturation = Math.Exp(73.649 - 7258.2/temperature - 7.3037 * Math.Log(temperature)
                //   + 4.1653e-6 * temperature * temperature);
                //pSaturation = ThermalPropCalculator.CalculateVaporPressure(temperature, vapPressureCoeffs);
                SteamTable steamTable = SteamTable.GetInstance();
                pSaturation = steamTable.GetSaturationPressure(temperature);
            }

            return(pSaturation);
        }
コード例 #7
0
        //Steam Table
        //calculated value unit is J/kg.K, t unit is K
        public static double CalculateWaterMeanHeatCapacity(double p, double t1, double t2)
        {
            SteamTable steamTable = SteamTable.GetInstance();
            double     h1         = steamTable.GetEnthalpyFromPressureAndTemperature(p, t1);
            double     h2         = steamTable.GetEnthalpyFromPressureAndTemperature(p, t2);
            double     cp         = (h2 - h1) / (t2 - t1);

            return(cp);
        }
コード例 #8
0
        //Steam Table
        //calculated value unit is J/kg.K, t unit is K
        public double CalculateEnthalpy(double p, double t, Substance s)
        {
            double h = 0;

            if (s.Name.Equals("water"))
            {
                SteamTable steamTable = SteamTable.GetInstance();
                h = steamTable.GetEnthalpyFromPressureAndTemperature(p, t);
            }
            return(h);
        }
コード例 #9
0
        public static double CalculateWaterSaturationTemperature(double pressure)
        {
            double temperature = 1.0e-6;

            if (pressure < 1.0e-6)
            {
                pressure = 1.0e-6;
            }

            if (pressure <= 611.22) //temperature below the steam table can deal with
            //temperature = 193.03 + 28.633 * Math.Pow(pressure, 0.1609);
            {
                double a = Math.Log(pressure / 611.21);
                temperature = a * 240.97 / (17.502 - a) + 273.15;
            }
            else if (pressure > 611.22)
            {
                SteamTable steamTable = SteamTable.GetInstance();
                temperature = steamTable.GetSaturationTemperature(pressure);
            }

            /*//use correlation from Perry's to finalize
             * else {
             * //use simple correlation to do a rough estimation
             * temperature = 3816.44/(23.197 - Math.Log(pressure)) + 46.13;
             * double old_temp;
             * double fx;
             * double dfx;
             * int i = 0;
             * do {
             *    i++;
             *    old_temp = temperature;
             *    //direct iterative method
             *    //temperature = -7258.2/(Math.Log(pressure) - 73.649 + 7.3037 * Math.Log(old_temp)
             *    //   - 4.1653e-6 * old_temp * old_temp);
             *    //Newton iterative method--much better convergence speed
             *    fx = 73.649 - 7258.2/old_temp - 7.3037 * Math.Log(old_temp) + 4.1653e-6 * old_temp * old_temp - Math.Log(pressure);
             *    dfx = 7258.2/(old_temp * old_temp) - 7.3037/old_temp + 2.0 * 4.1653e-6 * old_temp;
             *    temperature = old_temp - fx/dfx;
             * } while (i < 500 && Math.Abs(temperature - old_temp) > 1.0e-6);
             * }*/

            return(temperature);
        }
コード例 #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);
        }
コード例 #11
0
        private void CalculateTemperatureFromEnthalpy(double pValue, double hValue, double moistureContentValue)
        {
            double tValue    = Constants.NO_VALUE;
            double tValueOld = Constants.NO_VALUE;
            double vfValue   = Constants.NO_VALUE;

            double tBoilingPointOfSolvent  = MoistureProperties.GetSaturationTemperature(pValue);
            double tBoilingPointOfSolution = GetBoilingPoint(pValue);
            double cpLiquid = specificHeat.Value;

            if (cpLiquid == Constants.NO_VALUE)
            {
                cpLiquid = GetLiquidCp(MathUtility.Average(273.15, tBoilingPointOfSolution));
            }

            if (cpLiquid == Constants.NO_VALUE)
            {
                return;
            }

            SteamTable steamTable = SteamTable.GetInstance();
            SubstanceStatesAndProperties props;

            double hBoilingPointOfSolvent = CalculateLiquidEnthalpy(pValue, tBoilingPointOfSolvent, moistureContentValue);
            double hBubble = GetBubblePointEnthalpy(pValue, moistureContentValue);
            double hDew    = GetDewPointEnthalpy(pValue, moistureContentValue);

            double cs      = GetCpOfAbsoluteDryMaterial();
            int    counter = 0;

            if (hValue <= hBoilingPointOfSolvent)
            {
                double tempH;
                tValue = hValue / cpLiquid + 273.15;
                do
                {
                    counter++;
                    tValueOld = tValue;
                    tempH     = (hValue - (1.0 - moistureContentValue) * cs * (tValue - 273.15)) / moistureContentValue;
                    props     = steamTable.GetPropertiesFromPressureAndEnthalpy(pValue, tempH);
                    tValue    = props.temperature;
                } while (Math.Abs(tValue - tValueOld) > 1.0e-6 && counter < 200);

                if (counter == 200)
                {
                    throw new CalculationFailedException(this.name + ": Calculate of temperature from enthalpy failed.");
                }
                vfValue = 0.0;
            }
            else if (hValue <= hBubble)
            {
                double moistureLiquidCp;
                //double hBoilingPointOfSolvent = CalculateLiquidEnthalpy(pValue, tBoilingPointOfSolvent - 1.0e-6);
                tValue = hValue / cpLiquid + 273.15;
                do
                {
                    counter++;
                    tValueOld        = tValue;
                    moistureLiquidCp = MoistureProperties.GetSpecificHeatOfLiquid(MathUtility.Average(tBoilingPointOfSolvent, tValue));
                    tValue           = (hValue - hBoilingPointOfSolvent) / (moistureContentValue * moistureLiquidCp + (1.0 - moistureContentValue) * cs) + tBoilingPointOfSolvent;
                } while (Math.Abs(tValue - tValueOld) > 1.0e-6 && counter < 200);

                if (counter == 200)
                {
                    throw new CalculationFailedException(this.name + ": Calculate of temperature from enthalpy failed.");
                }
                vfValue = 0.0;
            }
            else if (hValue <= hDew)
            {
                double tBoilingPointOfSolutionFinal = tBoilingPointOfSolution;
                double evapHeat  = GetEvaporationHeat(tBoilingPointOfSolution);
                double extraHeat = (hValue - hBubble);
                if (moistureContentValue > 0.9999)
                {
                    vfValue = extraHeat / evapHeat;
                }
                else
                {
                    vfValue = 0;
                    double vfValueOld;
                    double massConcentrationValue = 1.0 - moistureContentValue;
                    do
                    {
                        counter++;
                        vfValueOld                   = vfValue;
                        vfValue                      = extraHeat / evapHeat;
                        massConcentrationValue       = (1.0 - moistureContentValue) / (1.0 - vfValue);
                        tBoilingPointOfSolutionFinal = GetBoilingPoint(pValue, massConcentrationValue);
                        evapHeat                     = GetEvaporationHeat(MathUtility.Average(tBoilingPointOfSolution, tBoilingPointOfSolutionFinal));
                        double moistureLiquidCp = MoistureProperties.GetSpecificHeatOfLiquid(MathUtility.Average(tBoilingPointOfSolution, tBoilingPointOfSolutionFinal));
                        extraHeat = hValue - hBubble - (moistureContentValue * moistureLiquidCp + (1.0 - moistureContentValue) * cs) * (tBoilingPointOfSolutionFinal - tBoilingPointOfSolution);
                    } while (Math.Abs(vfValue - vfValueOld) > 1.0e-6 && counter < 200);

                    if (counter == 200)
                    {
                        throw new CalculationFailedException(this.name + ": Calculation of temperature from enthalpy failed.");
                    }
                }

                if (vfValue < 0.0)
                {
                    vfValue = 0.0;
                }

                tValue = tBoilingPointOfSolutionFinal;
            }
            else if (hValue > hDew)
            {
                double apparentHeat;
                double hVapor;
                double cpGas = GetGasCp(tBoilingPointOfSolution);
                tValue = (hValue - hDew) / cpGas + tBoilingPointOfSolution;

                do
                {
                    apparentHeat = (hValue - hDew - (1.0 - moistureContentValue) * cs * (tValue - tBoilingPointOfSolution)) / moistureContentValue;
                    props        = steamTable.GetPropertiesFromPressureAndTemperature(pValue, tBoilingPointOfSolution + 1.0e-6);
                    hVapor       = props.enthalpy + apparentHeat;
                    props        = steamTable.GetPropertiesFromPressureAndEnthalpy(pressure.Value, hVapor);
                    tValueOld    = tValue;
                    tValue       = props.temperature;
                } while (Math.Abs(tValue - tValueOld) > 1.0e-6 && counter < 200);

                if (counter == 200)
                {
                    throw new CalculationFailedException(this.name + ": Calculate of temperature from enthalpy failed.");
                }

                vfValue = moistureContentValue;
            }

            Calculate(temperature, tValue);
            Calculate(vaporFraction, vfValue);

            if (!specificHeat.HasValue)
            {
                double cp;
                if (hValue <= hBubble)
                {
                    cp = GetLiquidCp(tValue);
                }
                else
                {
                    cp = GetGasCp(tValue);
                }
                Calculate(specificHeat, cp);
            }
        }
コード例 #12
0
        //protected override bool IsSolveReady() {
        //   if (HasSolvedAlready) {
        //      return false;
        //   }

        //   bool retValue = false;

        //   if ((moistureContentDryBase.HasValue && !moistureContentWetBase.IsSpecifiedAndHasValue)
        //      || (moistureContentWetBase.HasValue && !moistureContentDryBase.IsSpecifiedAndHasValue)
        //      || concentration.HasValue && (!moistureContentDryBase.IsSpecifiedAndHasValue || !moistureContentWetBase.IsSpecifiedAndHasValue)) {
        //      retValue = true;
        //   }

        //   if (moistureContentDryBase.HasValue || moistureContentWetBase.HasValue || concentration.HasValue) {
        //      if ((specificHeatDryBase.HasValue && !specificHeat.IsSpecifiedAndHasValue)
        //         || (specificHeatAbsDry.HasValue && !specificHeat.IsSpecifiedAndHasValue)
        //         || (specificHeat.HasValue && !specificHeatDryBase.IsSpecifiedAndHasValue)) {
        //         retValue = true;
        //      }

        //      if ((massFlowRateDryBase.HasValue && !massFlowRate.IsSpecifiedAndHasValue)
        //         || (massFlowRate.HasValue && !massFlowRateDryBase.IsSpecifiedAndHasValue)) {
        //         retValue = true;
        //      }

        //      if ((massFlowRateDryBase.HasValue || massFlowRate.HasValue)
        //         && (density.HasValue && !volumeFlowRate.IsSpecifiedAndHasValue)) {
        //         retValue = true;
        //      }
        //   }

        //   return retValue;
        //}

        public override void Execute(bool propagate)
        {
            if (HasSolvedAlready)
            {
                return;
            }

            if (moistureContentDryBase.HasValue && !moistureContentWetBase.IsSpecifiedAndHasValue)
            {
                Calculate(moistureContentWetBase, moistureContentDryBase.Value / (1.0 + moistureContentDryBase.Value));
            }
            else if (moistureContentWetBase.HasValue && !moistureContentDryBase.IsSpecifiedAndHasValue)
            {
                if (moistureContentWetBase.Value != 1.0)
                {
                    Calculate(moistureContentDryBase, moistureContentWetBase.Value / (1.0 - moistureContentWetBase.Value));
                }
                else
                {
                    Calculate(moistureContentDryBase, Constants.NO_VALUE);
                }
            }

            if (materialStateType == MaterialStateType.Liquid)
            {
                if (massConcentration.HasValue && massConcentration.Value > 1.0e-6)
                {
                    if (!moistureContentDryBase.IsSpecifiedAndHasValue)
                    {
                        Calculate(moistureContentDryBase, (1.0 - massConcentration.Value) / massConcentration.Value);
                    }
                    if (!moistureContentWetBase.IsSpecifiedAndHasValue)
                    {
                        Calculate(moistureContentWetBase, 1.0 - massConcentration.Value);
                    }
                }
                else if (massConcentration.HasValue && massConcentration.Value <= 1.0e-6)
                {
                    Calculate(moistureContentDryBase, Constants.NO_VALUE);
                    Calculate(moistureContentWetBase, 1.0);
                    Calculate(massFlowRateDryBase, Constants.NO_VALUE);
                }
                else if (moistureContentDryBase.HasValue && !massConcentration.IsSpecifiedAndHasValue)
                {
                    Calculate(massConcentration, 1.0 / (1.0 + moistureContentDryBase.Value));
                }
                else if (moistureContentWetBase.HasValue && !massConcentration.IsSpecifiedAndHasValue)
                {
                    Calculate(massConcentration, 1.0 - moistureContentWetBase.Value);
                }
            }

            if (moistureContentWetBase.HasValue)
            {
                DryingMaterialComponents dmc = MaterialComponents;
                dmc.Moisture.SetMassFractionValue(moistureContentWetBase.Value);
                dmc.AbsoluteDryMaterial.SetMassFractionValue(1.0 - moistureContentWetBase.Value);
                dmc.ComponentsFractionsChanged();
            }

            //if it is a known meterial in the material database, specific heat can be calculated
            double moistureLiquidCp = MoistureProperties.GetSpecificHeatOfLiquid();

            if (temperature.HasValue)
            {
                moistureLiquidCp = MoistureProperties.GetSpecificHeatOfLiquid(temperature.Value);
            }

            double cs = GetCpOfAbsoluteDryMaterial();

            if (temperature.HasValue && moistureContentWetBase.HasValue)
            {
                double cp = CalculateCp(temperature.Value);
                if (cp != Constants.NO_VALUE)
                {
                    Calculate(specificHeat, cp);

                    if (moistureContentDryBase.HasValue)
                    {
                        Calculate(specificHeatDryBase, cp * (1.0 + moistureContentDryBase.Value));
                    }
                }
                else if (specificHeat.HasValue && moistureContentDryBase.HasValue)
                {
                    Calculate(specificHeatDryBase, specificHeat.Value * (1.0 + moistureContentDryBase.Value));
                }
            }
            //need this when temperature is not not known
            //else if (cs != Constants.NO_VALUE && moistureContentDryBase.HasValue && !specificHeat.IsSpecifiedAndHasValue) {
            else if (specificEnthalpy.HasValue && cs != Constants.NO_VALUE && moistureContentDryBase.HasValue && !specificHeat.IsSpecifiedAndHasValue)
            {
                double cpMaterialDryBase = cs + moistureContentDryBase.Value * moistureLiquidCp;
                Calculate(specificHeatDryBase, cpMaterialDryBase);
                Calculate(specificHeat, cpMaterialDryBase / (1.0 + moistureContentDryBase.Value));
            }
            //else if (moistureContentWetBase.Value == 1.0 && !specificHeat.IsSpecifiedAndHasValue) {
            //   Calculate(specificHeatDryBase, Constants.NO_VALUE);
            //   if (temperature.HasValue && moistureContentWetBase.HasValue) {
            //      moistureLiquidCp = CalculateCp(temperature.Value);
            //      Calculate(specificHeat, moistureLiquidCp);
            //   }
            //}

            if (materialStateType == MaterialStateType.Solid && specificHeat.HasValue)
            {
                if (temperature.HasValue)
                {
                    //Calculate(specificEnthalpy, specificHeat.Value * (temperature.Value - 273.15));
                    CalculateEnthalpyFromTemperature(Constants.ONE_ATM, temperature.Value, moistureContentWetBase.Value);
                }
                else if (specificEnthalpy.HasValue && !temperature.IsSpecifiedAndHasValue)
                {
                    //Calculate(temperature, specificEnthalpy.Value / specificHeat.Value + 273.15);
                    double tValue = CalculateTemperatureFromEnthalpyForSolid(specificEnthalpy.Value, moistureContentWetBase.Value);
                    Calculate(temperature, tValue);
                }
            }
            else if (materialStateType == MaterialStateType.Liquid && pressure.HasValue && moistureContentWetBase.HasValue)
            {
                if (massConcentration.Value > 1.0e-6)
                {
                    if (specificEnthalpy.HasValue && !temperature.IsSpecifiedAndHasValue)
                    {
                        CalculateTemperatureFromEnthalpy(pressure.Value, specificEnthalpy.Value, moistureContentWetBase.Value);
                    }
                    else if (temperature.HasValue)
                    {
                        CalculateEnthalpyFromTemperature(pressure.Value, temperature.Value, moistureContentWetBase.Value);
                    }
                    else if (vaporFraction.HasValue)
                    {
                        CalculateEnthalpyFromVaporFraction(pressure.Value, vaporFraction.Value, moistureContentWetBase.Value);
                    }
                }
                else
                {
                    SteamTable steamTable = SteamTable.GetInstance();
                    SubstanceStatesAndProperties props;
                    if (specificEnthalpy.HasValue && !temperature.IsSpecifiedAndHasValue)
                    {
                        try {
                            props = steamTable.GetPropertiesFromPressureAndEnthalpy(pressure.Value, specificEnthalpy.Value);
                        }
                        catch (CalculationFailedException) {
                            throw new CalculationFailedException("Calculation of temperature from pressure and enthalpy failed in " + this.name + ".");
                        }

                        Calculate(temperature, props.temperature);
                        Calculate(vaporFraction, props.vaporFraction);
                    }
                    else if (temperature.HasValue)
                    {
                        try {
                            props = steamTable.GetPropertiesFromPressureAndTemperature(pressure.Value, temperature.Value);
                        }
                        catch (CalculationFailedException) {
                            throw new CalculationFailedException("Calculation of enthalpy from pressure and temperature failed in " + this.name + ".");
                        }

                        Calculate(specificEnthalpy, props.enthalpy);
                        Calculate(vaporFraction, props.vaporFraction);
                    }
                    else if (vaporFraction.HasValue)
                    {
                        try {
                            props = steamTable.GetPropertiesFromPressureAndVaporFraction(pressure.Value, vaporFraction.Value);
                        }
                        catch (CalculationFailedException) {
                            throw new CalculationFailedException("Calculation of enthalpy from pressure and vapor fraction failed in " + this.name + ".");
                        }
                        Calculate(temperature, props.temperature);
                        Calculate(specificEnthalpy, props.enthalpy);
                    }
                    CalculateCpOfPureMoisture();
                }
            }

            if (massFlowRateDryBase.HasValue && moistureContentDryBase.HasValue && !massFlowRate.IsSpecifiedAndHasValue)
            {
                Calculate(massFlowRate, massFlowRateDryBase.Value * (1.0 + moistureContentDryBase.Value));
            }
            else if (massFlowRate.HasValue && moistureContentDryBase.HasValue && !massFlowRateDryBase.IsSpecifiedAndHasValue)
            {
                Calculate(massFlowRateDryBase, massFlowRate.Value / (1.0 + moistureContentDryBase.Value));
            }

            if (temperature.HasValue && massConcentration.HasValue)
            {
                CalculateDensity();
            }

            if (massFlowRate.HasValue && density.HasValue)
            {
                Calculate(volumeFlowRate, massFlowRate.Value / density.Value);
            }

            if (materialStateType == MaterialStateType.Solid && temperature.HasValue && massFlowRate.HasValue &&
                moistureContentWetBase.HasValue && specificHeat.HasValue && specificEnthalpy.HasValue)
            {
                currentSolveState = SolveState.Solved;
            }
            else if (materialStateType == MaterialStateType.Liquid && pressure.HasValue && temperature.HasValue &&
                     massFlowRate.HasValue && moistureContentWetBase.HasValue && specificEnthalpy.HasValue &&
                     vaporFraction.HasValue)
            {
                currentSolveState = SolveState.Solved;
            }

            AdjustVarsStates();
            //if (HasSolvedAlready) {
            //   DryingMaterialComponents dmc = MaterialComponents;
            //   dmc.Moisture.SetMassFractionValue(moistureContentWetBase.Value);
            //   dmc.AbsoluteDryMaterial.SetMassFractionValue(1.0 - moistureContentWetBase.Value);
            //   dmc.ComponentsFractionsChanged();
            //}
            OnSolveComplete(currentSolveState);
        }
コード例 #13
0
        public override void Execute(bool propagate)
        {
            if (HasSolvedAlready)
            {
                return;
            }

            SteamTable steamTable = SteamTable.GetInstance();
            SubstanceStatesAndProperties props;

            if (pressure.HasValue)
            {
                if (specificEnthalpy.HasValue && !temperature.IsSpecifiedAndHasValue)
                {
                    try {
                        props = steamTable.GetPropertiesFromPressureAndEnthalpy(pressure.Value, specificEnthalpy.Value);
                    }
                    catch (CalculationFailedException) {
                        string msg = BuildProperErrorMessage(this.name + ": Calculation of temperature from pressure and enthalpy failed.\nPlease make sure each specified value in this stream");
                        throw new CalculationFailedException(msg);
                    }

                    Calculate(temperature, props.temperature);
                    Calculate(vaporFraction, props.vaporFraction);
                }
                else if (temperature.HasValue)
                {
                    try {
                        props = steamTable.GetPropertiesFromPressureAndTemperature(pressure.Value, temperature.Value);
                    }
                    catch (CalculationFailedException) {
                        string msg = BuildProperErrorMessage(this.name + ": Calculation of enthalpy from pressure and temperature failed.\nPlease make sure each specified value in this stream");
                        throw new CalculationFailedException(msg);
                    }

                    Calculate(specificEnthalpy, props.enthalpy);
                    Calculate(vaporFraction, props.vaporFraction);
                }
                else if (vaporFraction.HasValue)
                {
                    try {
                        props = steamTable.GetPropertiesFromPressureAndVaporFraction(pressure.Value, vaporFraction.Value);
                    }
                    catch (CalculationFailedException) {
                        string msg = BuildProperErrorMessage(this.name + "Calculation of enthalpy from pressure and vapor fraction failed.\nPlease make sure each specified value in this stream");
                        throw new CalculationFailedException(msg);
                    }
                    Calculate(temperature, props.temperature);
                    Calculate(specificEnthalpy, props.enthalpy);
                }
            }
            CalculateCpOfPureMoisture();

            if (temperature.HasValue)
            {
                CalculateDensity();
            }

            if (massFlowRate.HasValue && density.HasValue)
            {
                Calculate(volumeFlowRate, massFlowRate.Value / density.Value);
            }

            if (pressure.HasValue && temperature.HasValue && specificEnthalpy.HasValue && vaporFraction.HasValue)
            {
                solveState = SolveState.Solved;
            }

            AdjustVarsStates();
            OnSolveComplete();
        }