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); }
private string CheckPointInRange(PointF pt) { bool retValue = true; string retMsg = null; if (pt.X < xVar.Min || pt.X > xVar.Max || pt.Y < yVar.Min || pt.Y > yVar.Max) { retValue = false; } else { double p = pressure.Value; double temperature = (double)pt.X; double humidity = (double)pt.Y; HumidGasCalculator humidGasCalculator = GetHumidGasCalculator(); double dewPoint = humidGasCalculator.GetDewPointFromDryBulbAndRelativeHumidity(temperature, 1.0); double humiditySat = humidGasCalculator.GetHumidityFromDewPointAndPressure(dewPoint, p); if (humidity > humiditySat) { retValue = false; } } if (retValue == false) { retMsg = "Specified state is out of range. It is reverted back to the original state"; } return(retMsg); }
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); }
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)); }
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(); }