예제 #1
0
        private CurveFamilyF GenerateAdiabaticSaturationFamily()
        {
            double             dewPoint;
            double             ysat;
            double             wetBulb;
            double             temperature;
            double             ih;
            double             tsat;
            double             maxTemp;
            HumidGasCalculator humidGasCalculator = GetHumidGasCalculator();
            double             p           = (double)pressure.Value;
            double             cg          = humidGasCalculator.GetSpecificHeatOfDryGas();
            double             cv          = humidGasCalculator.GetSpecificHeatOfVapor();
            double             r0          = humidGasCalculator.GetEvaporationHeat(273.15);
            double             dewPoint1   = humidGasCalculator.GetDewPointFromDryBulbAndRelativeHumidity(xVar.Max, 1.0);
            double             dewPoint2   = humidGasCalculator.GetDewPointFromHumidityAndPressure(yVar.Max, p);
            double             dewPointMin = Math.Min(dewPoint1, dewPoint2);
            int numOfCurves = (int)((dewPointMin - xVar.Min) / 5.0) + 1;

            CurveF[] curves = new CurveF[numOfCurves];
            double   y;

            for (int i = 0; i < numOfCurves; i++)
            {
                tsat     = xVar.Min + i * 5.0;
                dewPoint = humidGasCalculator.GetDewPointFromDryBulbAndRelativeHumidity(tsat, 1.0);
                ysat     = humidGasCalculator.GetHumidityFromDewPointAndPressure(dewPoint, p);
                wetBulb  = humidGasCalculator.GetWetBulbFromDryBulbHumidityAndPressure(tsat, ysat, p);
                PointF[] dataPoints = new PointF[11];
                maxTemp = humidGasCalculator.GetDryBulbFromWetBulbHumidityAndPressure(wetBulb, 0.0, p);
                if (maxTemp > xVar.Max)
                {
                    maxTemp = xVar.Max;
                }
                if (ysat > yVar.Max)
                {
                    tsat = humidGasCalculator.GetDryBulbFromWetBulbHumidityAndPressure(wetBulb, yVar.Max, p);
                }
                ih = (cg + cv * ysat) * (tsat - 273.15) + r0 * ysat;
                for (int j = 0; j <= 10; j++)
                {
                    temperature = tsat + (maxTemp - tsat) / 10.0 * j;
                    //iso-enthalpy line
                    y             = (ih - cg * (temperature - 273.15)) / (r0 + cv * (temperature - 273.15));
                    dataPoints[j] = new PointF((float)temperature, (float)y);
                }
                curves[i] = new CurveF(StringConstants.GetTypeName(StringConstants.ADIABATIC_SATURATION), (float)tsat, dataPoints);
            }

            CurveFamilyF curveFamily = new CurveFamilyF(StringConstants.GetTypeName(StringConstants.ADIABATIC_SATURATION), PhysicalQuantity.Temperature, curves);

            return(curveFamily);
        }
예제 #2
0
        private CurveFamilyF GenerateRelativeHumidityFamily()
        {
            double dewPoint;
            double humidity;
            double temperature;
            double maxTemp;

            CurveF[]           curves = new CurveF[16];
            double             relativeHumidity;
            HumidGasCalculator humidGasCalculator = GetHumidGasCalculator();

            for (int i = 0; i < 16; i++)
            {
                //from 0.0% to 10%--interval 2%
                if (i < 5)
                {
                    relativeHumidity = (i + 1) * 0.02;
                }
                //from 10 to 50%--interval 5%
                else if (i < 9)
                {
                    relativeHumidity = 0.1 + (i - 4) * 0.05;
                }
                //from 30 to 100%--interval 10%
                else
                {
                    relativeHumidity = 0.3 + (i - 8) * 0.1;
                }

                dewPoint = humidGasCalculator.GetDewPointFromHumidityAndPressure(yVar.Max, pressure.Value);
                maxTemp  = humidGasCalculator.GetDryBulbFromDewPointAndRelativeHumidity(dewPoint, relativeHumidity);
                if (maxTemp > xVar.Max)
                {
                    maxTemp = xVar.Max;
                }
                PointF[] dataPoints = new PointF[101];
                for (int j = 0; j <= 100; j++)
                {
                    temperature   = xVar.Min + j * (maxTemp - xVar.Min) / 100;
                    dewPoint      = humidGasCalculator.GetDewPointFromDryBulbAndRelativeHumidity(temperature, relativeHumidity);
                    humidity      = humidGasCalculator.GetHumidityFromDewPointAndPressure(dewPoint, (double)pressure.Value);
                    dataPoints[j] = new PointF((float)temperature, (float)humidity);
                }
                curves[i] = new CurveF(StringConstants.GetTypeName(StringConstants.RELATIVE_HUMIDITY), (float)relativeHumidity, dataPoints);
            }

            CurveFamilyF curveFamily = new CurveFamilyF(StringConstants.GetTypeName(StringConstants.RELATIVE_HUMIDITY), PhysicalQuantity.Fraction, curves);

            return(curveFamily);
        }
예제 #3
0
        private CurveF GenerateSaturationVolumeCurve()
        {
            double             temperature;
            double             dewPoint;
            double             humidity;
            double             saturationVolume;
            HumidGasCalculator humidGasCalculator = GetHumidGasCalculator();

            PointF[] dataPoints = new PointF[10];
            for (int i = 0; i < 10; i++)
            {
                temperature      = (xVar.Max - xVar.Min) / 10.0 * i;
                dewPoint         = humidGasCalculator.GetDewPointFromDryBulbAndRelativeHumidity(temperature, 1.0);
                humidity         = humidGasCalculator.GetHumidityFromDewPointAndPressure(dewPoint, (double)pressure.Value);
                saturationVolume = humidGasCalculator.GetHumidVolume(temperature, humidity, (double)pressure.Value);
                dataPoints[i]    = new PointF((float)temperature, (float)saturationVolume);
            }
            return(new CurveF(StringConstants.GetTypeName(StringConstants.SATURATION_VOLUME), 0.1f, dataPoints));
        }
예제 #4
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);
                //}
            }
        }
예제 #5
0
        private void Solve()
        {
            double p   = pressure.Value;
            double tg1 = inputStream.Temperature.Value;
            double y1  = inputStream.Humidity.Value;
            double tw1 = inputStream.WetBulbTemperature.Value;
            double td1 = inputStream.DewPoint.Value;
            double fy1 = inputStream.RelativeHumidity.Value;

            double tg2 = outputStream.Temperature.Value;
            double y2  = outputStream.Humidity.Value;
            double tw2 = outputStream.WetBulbTemperature.Value;
            double td2 = outputStream.DewPoint.Value;
            double fy2 = outputStream.RelativeHumidity.Value;

            double ih = 0;

            if (inputStream.Pressure.Value != p)
            {
                Calculate(inputStream.Pressure, p);
            }
            if (outputStream.Pressure.Value != p)
            {
                Calculate(outputStream.Pressure, p);
            }

            HumidGasCalculator humidGasCalculator = GetHumidGasCalculator();

            if (tg1 != Constants.NO_VALUE && y1 != Constants.NO_VALUE)
            {
                //wetBulb = humidGasCalculator.GetWetBulbFromDryBulbHumidityAndPressure(tg1, y1, p);
                ih = humidGasCalculator.GetHumidEnthalpyFromDryBulbHumidityAndPressure(tg1, y1, p);
                if (tg2 != Constants.NO_VALUE)
                {
                    y2 = humidGasCalculator.GetHumidityFromHumidEnthalpyTemperatureAndPressure(ih, tg2, p);
                    if (y2 <= 0.0)
                    {
                        y2 = 1.0e-6;
                    }

                    Calculate(outputStream.MoistureContentDryBase, y2);
                    solveState = SolveState.Solved;
                }
                else if (y2 != Constants.NO_VALUE)
                {
                    tg2 = humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(ih, y2, p);
                    Calculate(outputStream.Temperature, tg2);
                    solveState = SolveState.Solved;
                }
                else if (td2 != Constants.NO_VALUE)
                {
                    y2  = humidGasCalculator.GetHumidityFromDewPointAndPressure(td2, p);
                    tg2 = humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(ih, y2, p);
                    Calculate(outputStream.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, p);
                        fy_temp = humidGasCalculator.GetRelativeHumidityFromDryBulbHumidityAndPressure(tg2, y2, p);
                        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(outputStream.Temperature, tg2);
                        solveState = SolveState.Solved;
                    }
                }

                double fy = humidGasCalculator.GetRelativeHumidityFromDryBulbHumidityAndPressure(tg2, y2, p);
                if (fy > 1.0)
                {
                    solveState = SolveState.NotSolved;
                    string msg = "Specified input state makes the relative humidity of the output greater than 1.0.";
                    throw new InappropriateSpecifiedValueException(msg);
                }
            }
            else if (tg2 != Constants.NO_VALUE && y2 != Constants.NO_VALUE)
            {
                ih = humidGasCalculator.GetHumidEnthalpyFromDryBulbHumidityAndPressure(tg2, y2, p);
                if (tg1 != Constants.NO_VALUE)
                {
                    y1 = humidGasCalculator.GetHumidityFromHumidEnthalpyTemperatureAndPressure(ih, tg1, p);
                    Calculate(inputStream.MoistureContentDryBase, y1);
                    solveState = SolveState.Solved;
                }
                else if (y1 != Constants.NO_VALUE)
                {
                    tg1 = humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(ih, y1, p);
                    Calculate(inputStream.Temperature, tg1);
                    solveState = SolveState.Solved;
                }
                else if (td1 != Constants.NO_VALUE)
                {
                    y1  = humidGasCalculator.GetHumidityFromDewPointAndPressure(td1, p);
                    tg1 = humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(ih, y1, p);
                    Calculate(inputStream.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, p);
                        fy_temp = humidGasCalculator.GetRelativeHumidityFromDryBulbHumidityAndPressure(tg1, y1, p);
                        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(inputStream.Temperature, tg1);
                        solveState = SolveState.Solved;
                    }
                }
            }
        }
예제 #6
0
        public override void Execute(bool propagate)
        {
            //if dew point is known
            //HumidGasCalculator humidGasCalculator = GetHumidGasCalculator();
            if (dewPoint.HasValue)
            {
                if (relativeHumidity.HasValue && !temperature.IsSpecifiedAndHasValue)
                {
                    Calculate(temperature, HumidGasCalculator.GetDryBulbFromDewPointAndRelativeHumidity(dewPoint.Value, relativeHumidity.Value));
                }
                else if (pressure.HasValue)
                {
                    if (dewPoint.Value <= 1.0e-10 && !moistureContentDryBase.IsSpecifiedAndHasValue)
                    {
                        Calculate(moistureContentDryBase, 0);
                    }
                    else if (!moistureContentDryBase.IsSpecifiedAndHasValue)
                    {
                        Calculate(moistureContentDryBase, HumidGasCalculator.GetHumidityFromDewPointAndPressure(dewPoint.Value, pressure.Value));
                    }
                }
                //Pressure should always be known. So it should not be calculated
                else if (moistureContentDryBase.HasValue)
                {
                    //Calculate(pressure, humidGasCalculator.GetPressureFromDewPointAndHumidity(dewPoint.Value, humidity.Value));
                }
            }

            //if humidity is known
            if (moistureContentDryBase.HasValue)
            {
                if (pressure.HasValue && !dewPoint.IsSpecifiedAndHasValue)
                {
                    Calculate(dewPoint, HumidGasCalculator.GetDewPointFromHumidityAndPressure(moistureContentDryBase.Value, pressure.Value));
                }

                //to prevent repeated calculation of the same variable
                //if (relativeHumidity.HasValue && dewPoint.HasValue && !temperature.IsSpecifiedAndHasValue) {
                if (relativeHumidity.HasValue && dewPoint.HasValue && !temperature.HasValue)
                {
                    Calculate(temperature, HumidGasCalculator.GetDryBulbFromDewPointAndRelativeHumidity(dewPoint.Value, relativeHumidity.Value));
                }

                //to prevent repeated calculation of the same variable
                //if (wetBulbTemperature.HasValue && pressure.HasValue && !temperature.IsSpecifiedAndHasValue) {
                if (wetBulbTemperature.HasValue && pressure.HasValue && !temperature.HasValue)
                {
                    Calculate(temperature, HumidGasCalculator.GetDryBulbFromWetBulbHumidityAndPressure(wetBulbTemperature.Value, moistureContentDryBase.Value, pressure.Value));
                }
            }

            //to prevent repeated calculation of the same variable
            //if (wetBulbTemperature.HasValue && relativeHumidity.HasValue && pressure.HasValue
            //   && !temperature.IsSpecifiedAndHasValue) {
            if (wetBulbTemperature.HasValue && relativeHumidity.HasValue && pressure.HasValue &&
                !temperature.HasValue)
            {
                Calculate(temperature, HumidGasCalculator.GetDryBulbFromWetBulbRelativeHumidityAndPressure(wetBulbTemperature.Value, relativeHumidity.Value, pressure.Value));
            }

            double humidEnthalpyValue;
            double mcDryBase = moistureContentDryBase.Value;

            if (specificEnthalpy.HasValue && moistureContentDryBase.HasValue && !specificEnthalpyDryBase.HasValue)
            {
                Calculate(specificEnthalpyDryBase, specificEnthalpy.Value * (1.0 + mcDryBase));
            }

            //if (specificEnthalpyDryBase.HasValue && pressure.HasValue && !temperature.IsSpecifiedAndHasValue) {
            if (specificEnthalpyDryBase.HasValue && pressure.HasValue && !temperature.HasValue)
            {
                if (moistureContentDryBase.HasValue)
                {
                    Calculate(temperature, HumidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(specificEnthalpyDryBase.Value, moistureContentDryBase.Value, pressure.Value));
                }
                else if (relativeHumidity.HasValue)
                {
                    Calculate(temperature, HumidGasCalculator.GetDryBulbFromHumidEnthalpyRelativeHumidityAndPressure(specificEnthalpyDryBase.Value, relativeHumidity.Value, pressure.Value));
                }
                else if (dewPoint.HasValue)
                {
                    Calculate(temperature, HumidGasCalculator.GetDryBulbFromHumidEnthalpyDewPointAndPressure(specificEnthalpyDryBase.Value, relativeHumidity.Value, pressure.Value));
                }
                else if (wetBulbTemperature.HasValue)
                {
                    Calculate(temperature, HumidGasCalculator.GetDryBulbFromHumidEnthalpyWetBulbAndPressure(specificEnthalpyDryBase.Value, wetBulbTemperature.Value, pressure.Value));
                }
            }

            //if temperature is first known
            if (temperature.HasValue)
            {
                if (dewPoint.HasValue || relativeHumidity.HasValue)
                {
                    if (dewPoint.HasValue && !relativeHumidity.IsSpecifiedAndHasValue)
                    {
                        Calculate(relativeHumidity, HumidGasCalculator.GetRelativeHumidityFromDryBulbAndDewPoint(temperature.Value, dewPoint.Value));
                    }
                    else if (relativeHumidity.HasValue && !dewPoint.IsSpecifiedAndHasValue)
                    {
                        Calculate(dewPoint, HumidGasCalculator.GetDewPointFromDryBulbAndRelativeHumidity(temperature.Value, relativeHumidity.Value));
                    }

                    if (pressure.HasValue)
                    {
                        if (!moistureContentDryBase.IsSpecifiedAndHasValue)
                        {
                            Calculate(moistureContentDryBase, HumidGasCalculator.GetHumidityFromDewPointAndPressure(dewPoint.Value, pressure.Value));
                        }
                        if (!wetBulbTemperature.IsSpecifiedAndHasValue)
                        {
                            Calculate(wetBulbTemperature, HumidGasCalculator.GetWetBulbFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value));
                            //double satTemp = humidGasCalculator.GetSatTempFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value);
                        }
                    }
                    else if (moistureContentDryBase.HasValue)
                    {
                        if (!pressure.IsSpecifiedAndHasValue)
                        {
                            Calculate(pressure, HumidGasCalculator.GetPressureFromDewPointAndHumidity(dewPoint.Value, moistureContentDryBase.Value));
                        }
                        if (!wetBulbTemperature.IsSpecifiedAndHasValue)
                        {
                            Calculate(wetBulbTemperature, HumidGasCalculator.GetWetBulbFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value));
                            //double satTemp = humidGasCalculator.GetSatTempFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value);
                        }
                    }
                }
                else if (wetBulbTemperature.HasValue && pressure.HasValue)
                {
                    if (!moistureContentDryBase.IsSpecifiedAndHasValue)
                    {
                        Calculate(moistureContentDryBase, HumidGasCalculator.GetHumidityFromDryBulbWetBulbAndPressure(temperature.Value, wetBulbTemperature.Value, pressure.Value));
                    }
                    if (!relativeHumidity.IsSpecifiedAndHasValue)
                    {
                        Calculate(relativeHumidity, HumidGasCalculator.GetRelativeHumidityFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value));
                    }
                    if (!dewPoint.IsSpecifiedAndHasValue)
                    {
                        Calculate(dewPoint, HumidGasCalculator.GetDewPointFromDryBulbAndRelativeHumidity(temperature.Value, relativeHumidity.Value));
                    }
                }

                else if (moistureContentDryBase.HasValue && pressure.HasValue)
                {
                    if (!wetBulbTemperature.IsSpecifiedAndHasValue)
                    {
                        Calculate(wetBulbTemperature, HumidGasCalculator.GetWetBulbFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value));
                        //double satTemp = humidGasCalculator.GetSatTempFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value);
                    }

                    if (!relativeHumidity.IsSpecifiedAndHasValue)
                    {
                        Calculate(relativeHumidity, HumidGasCalculator.GetRelativeHumidityFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value));
                    }
                    if (!dewPoint.IsSpecifiedAndHasValue)
                    {
                        Calculate(dewPoint, HumidGasCalculator.GetDewPointFromDryBulbAndRelativeHumidity(temperature.Value, relativeHumidity.Value));
                    }
                }

                else if (wetBulbTemperature.HasValue && moistureContentDryBase.HasValue)
                {
                    //if (!pressure.IsSpecifiedAndHasValue) {
                    //   Calculate(pressure, humidGasCalculator.GetPressureFromDryBulbWetBulbAndHumidity(temperature.Value, wetBulbTemperature.Value, moistureContentDryBase.Value));
                    //}
                    if (!dewPoint.IsSpecifiedAndHasValue)
                    {
                        Calculate(dewPoint, HumidGasCalculator.GetDewPointFromHumidityAndPressure(temperature.Value, pressure.Value));
                    }
                    if (!relativeHumidity.IsSpecifiedAndHasValue)
                    {
                        Calculate(relativeHumidity, HumidGasCalculator.GetRelativeHumidityFromDryBulbAndDewPoint(temperature.Value, dewPoint.Value));
                    }
                }
            }

            mcDryBase = moistureContentDryBase.Value;
            if (moistureContentDryBase.HasValue && temperature.HasValue)
            {
                double cpDryBase = HumidGasCalculator.GetHumidHeat(moistureContentDryBase.Value, temperature.Value);
                Calculate(specificHeatDryBase, cpDryBase);
                Calculate(specificHeat, cpDryBase / (1.0 + mcDryBase));
                if (pressure.HasValue)
                {
                    double humidVolumeValue = HumidGasCalculator.GetHumidVolume(temperature.Value, moistureContentDryBase.Value, pressure.Value);
                    Calculate(humidVolume, humidVolumeValue);
                    humidEnthalpyValue = HumidGasCalculator.GetHumidEnthalpyFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value);
                    Calculate(specificEnthalpyDryBase, humidEnthalpyValue);
                    Calculate(specificEnthalpy, humidEnthalpyValue / (1.0 + mcDryBase));
                    Calculate(density, (1.0 + mcDryBase) / humidVolumeValue);
                }
            }

            CalculateFlow();

            //if (temperature.HasValue && pressure.HasValue && massFlowRate.HasValue &&
            //   volumeFlowRate.HasValue && massFlowRateDryBase.HasValue && wetBulbTemperature.HasValue &&
            //   dewPoint.HasValue && moistureContentDryBase.HasValue && relativeHumidity.HasValue &&
            //   density.HasValue && specificEnthalpy.HasValue && specificHeatDryBase.HasValue) {
            //   solveState = SolveState.Solved;
            //}

            bool hasUnsolvedVar = false;

            foreach (ProcessVarDouble pv in varList)
            {
                if (!pv.HasValue)
                {
                    hasUnsolvedVar = true;
                    break;
                }
            }
            if (!hasUnsolvedVar)
            {
                solveState = SolveState.Solved;
            }
            //else
            //{
            //   foreach (ProcessVarDouble pv in varList)
            //   {
            //      if (!pv.IsSpecified && pv.HasValue)
            //      {
            //         solveState = SolveState.PartiallySolved;
            //         break;
            //      }
            //   }
            //}

            if (HasSolvedAlready)
            {
                DryingGasComponents dgc = (DryingGasComponents)materialComponents;
                //we cannot do a calculate operation since these variables are not in the
                //varList and they cannot be erased after they are initially calculated
                dgc.DryMedium.SetMassFractionValue(1.0 / (1.0 + Humidity.Value));
                dgc.Moisture.SetMassFractionValue(Humidity.Value / (1.0 + Humidity.Value));
                dgc.ComponentsFractionsChanged();
            }
            AdjustVarsStates();
            OnSolveComplete();
        }
예제 #7
0
        protected override ErrorMessage CheckSpecifiedValueRange(ProcessVarDouble pv, double aValue)
        {
            ErrorMessage retValue = base.CheckSpecifiedValueRange(pv, aValue);

            if (retValue != null)
            {
                return(retValue);
            }

            string valueString = aValue.ToString();

            if (pv == temperature)
            {
                if (wetBulbTemperature.IsSpecifiedAndHasValue && aValue < wetBulbTemperature.Value)
                {
                    retValue = CreateSimpleGenericInappropriateSpecifiedValueErrorMessage("Specified " + pv.VarTypeName + " value is less than " + wetBulbTemperature.VarTypeName + " and therefore cannot be committed.");
                }
                else if (dewPoint.IsSpecifiedAndHasValue && aValue < dewPoint.Value)
                {
                    retValue = CreateSimpleGenericInappropriateSpecifiedValueErrorMessage("Specified " + pv.VarTypeName + " value is less than " + dewPoint.VarTypeName + " and therefore cannot be committed.");
                }
            }
            else if (pv == wetBulbTemperature)
            {
                if (temperature.IsSpecifiedAndHasValue && aValue > temperature.Value)
                {
                    retValue = CreateSimpleGenericInappropriateSpecifiedValueErrorMessage("Specified " + pv.VarTypeName + " value is greater than " + temperature.VarTypeName + " and therefore cannot be committed.");
                }
                else if (dewPoint.IsSpecifiedAndHasValue && aValue < dewPoint.Value)
                {
                    retValue = CreateSimpleGenericInappropriateSpecifiedValueErrorMessage("Specified " + pv.VarTypeName + " value is less than than " + dewPoint.VarTypeName + " and therefore cannot be committed.");
                }
            }
            else if (pv == dewPoint)
            {
                if (temperature.IsSpecifiedAndHasValue && aValue > temperature.Value)
                {
                    retValue = CreateSimpleGenericInappropriateSpecifiedValueErrorMessage("Specified " + pv.VarTypeName + " value is greater than " + temperature.VarTypeName + " and therefore cannot be committed.");
                }
                else if (wetBulbTemperature.IsSpecifiedAndHasValue && aValue > wetBulbTemperature.Value)
                {
                    retValue = CreateSimpleGenericInappropriateSpecifiedValueErrorMessage("Specified " + pv.VarTypeName + " value is greater than " + wetBulbTemperature.VarTypeName + " and therefore cannot be committed.");
                }
            }
            else if (pv == Humidity)
            {
                if (aValue < 0)
                {
                    retValue = CreateLessThanZeroErrorMessage(pv);
                }
                else if (pressure.HasValue)
                {
                    double maxHumidity = 1000.0;

                    //HumidGasCalculator humidGasCalculator = GetHumidGasCalculator();
                    if (temperature.HasValue)
                    {
                        maxHumidity = HumidGasCalculator.GetHumidityFromDewPointAndPressure(temperature.Value, pressure.Value);
                    }
                    else if (wetBulbTemperature.HasValue)
                    {
                        maxHumidity = HumidGasCalculator.GetHumidityFromDewPointAndPressure(wetBulbTemperature.Value, pressure.Value);
                    }
                    else if (dewPoint.HasValue)
                    {
                        maxHumidity = HumidGasCalculator.GetHumidityFromDewPointAndPressure(dewPoint.Value, pressure.Value);
                    }

                    if (aValue > maxHumidity)
                    {
                        aValue   = maxHumidity;
                        retValue = CreateSimpleGenericInappropriateSpecifiedValueErrorMessage("The maximum " + pv.VarTypeName + " value under current conditions is " + aValue.ToString() + ".\n Specified value " + valueString + " is greater than the maximum and therefore cannot be committed.");
                    }
                }
            }
            else if (pv == relativeHumidity)
            {
                if (aValue < 0 || aValue > 1.0)
                {
                    retValue = CreateOutOfRangeZeroToOneErrorMessage(pv);
                }
            }

            if (retValue == null)
            {
                retValue = CheckSpecifiedValueInContextOfOwner(pv, aValue);
            }

            return(retValue);
        }
예제 #8
0
        protected override ErrorMessage CheckSpecifiedValueRange(ProcessVarDouble pv, double aValue)
        {
            ErrorMessage retValue = base.CheckSpecifiedValueRange(pv, aValue);

            if (retValue != null)
            {
                return(retValue);
            }

            //if (pv.VarTypeName == StringConstants.GetTypeName(StringConstants.DRY_BULB_TEMPERATURE)) {
            if (pv == temperature)
            {
                if (aValue != Constants.NO_VALUE && wetBulbTemperature.HasValue && aValue < wetBulbTemperature.Value)
                {
                    retValue = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, pv.VarTypeName + " can not be less than " + StringConstants.GetTypeName(StringConstants.WET_BULB_TEMPERATURE));
                }
                else if (aValue != Constants.NO_VALUE && dewPoint.HasValue && aValue < dewPoint.Value)
                {
                    retValue = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, pv.VarTypeName + " can not be less than " + StringConstants.GetTypeName(StringConstants.DEW_POINT));
                }
            }
            //else if (pv.VarTypeName == StringConstants.GetTypeName(StringConstants.WET_BULB_TEMPERATURE))
            else if (pv == wetBulbTemperature)
            {
                if (aValue != Constants.NO_VALUE && temperature.HasValue && aValue > temperature.Value)
                {
                    retValue = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, pv.VarTypeName + " can not be greater than " + StringConstants.GetTypeName(StringConstants.DRY_BULB_TEMPERATURE));
                }
                else if (aValue != Constants.NO_VALUE && dewPoint.HasValue && aValue < dewPoint.Value)
                {
                    retValue = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, pv.VarTypeName + " can not be less than than " + StringConstants.GetTypeName(StringConstants.DEW_POINT));
                }
            }
            //else if (pv.VarTypeName == StringConstants.GetTypeName(StringConstants.DEW_POINT))
            else if (pv == dewPoint)
            {
                if (aValue != Constants.NO_VALUE && temperature.HasValue && aValue > temperature.Value)
                {
                    retValue = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, pv.VarTypeName + " can not be greater than " + StringConstants.GetTypeName(StringConstants.DRY_BULB_TEMPERATURE));
                }
                else if (aValue != Constants.NO_VALUE && wetBulbTemperature.HasValue && aValue > wetBulbTemperature.Value)
                {
                    retValue = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, pv.VarTypeName + " can not be greater than " + StringConstants.GetTypeName(StringConstants.WET_BULB_TEMPERATURE));
                }
            }
            //else if (pv.VarTypeName == StringConstants.GetTypeName(StringConstants.HUMIDITY))
            else if (pv == Humidity)
            {
                if (aValue != Constants.NO_VALUE && aValue < 0)
                {
                    retValue = CreateLessThanZeroErrorMessage(pv);
                }
                else if (aValue != Constants.NO_VALUE && pressure.HasValue)
                {
                    double maxHumidity = 1000.0;

                    HumidGasCalculator humidGasCalculator = GetHumidGasCalculator();
                    if (temperature.HasValue)
                    {
                        maxHumidity = humidGasCalculator.GetHumidityFromDewPointAndPressure(temperature.Value, pressure.Value);
                    }
                    else if (wetBulbTemperature.HasValue)
                    {
                        maxHumidity = humidGasCalculator.GetHumidityFromDewPointAndPressure(wetBulbTemperature.Value, pressure.Value);
                    }
                    else if (dewPoint.HasValue)
                    {
                        maxHumidity = humidGasCalculator.GetHumidityFromDewPointAndPressure(dewPoint.Value, pressure.Value);
                    }

                    if (aValue > maxHumidity)
                    {
                        aValue   = maxHumidity;
                        retValue = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, "The maximum humidity under current conditions is " + aValue.ToString());
                    }
                }
            }
            //else if (pv.VarTypeName == StringConstants.GetTypeName(StringConstants.RELATIVE_HUMIDITY))
            else if (pv == relativeHumidity)
            {
                if (aValue != Constants.NO_VALUE && (aValue < 0 || aValue > 1.0))
                {
                    retValue = CreateOutOfRangeZeroToOneErrorMessage(pv);
                }
            }

            return(retValue);
        }