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 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 GenerateSpecificVolumeDryAirCurve() { double temperature; double specificVolumeDryAir; PointF[] dataPoints = new PointF[10]; HumidGasCalculator humidGasCalculator = GetHumidGasCalculator(); for (int i = 0; i < 10; i++) { temperature = (xVar.Max - xVar.Min) / 10.0 * i; specificVolumeDryAir = humidGasCalculator.GetHumidVolume(temperature, 0.0, (double)pressure.Value); dataPoints[i] = new PointF((float)temperature, (float)specificVolumeDryAir); } return(new CurveF(StringConstants.GetTypeName(StringConstants.SPECIFIC_VOLUME_DRY_AIR), 0.1f, dataPoints)); }
private CurveF GenerateEvaporationHeatCurve() { double temperature; double evapHeat; PointF[] dataPoints = new PointF[10]; HumidGasCalculator humidGasCalculator = GetHumidGasCalculator(); for (int i = 0; i < 10; i++) { temperature = (xVar.Max - xVar.Min) / 10.0 * i; evapHeat = humidGasCalculator.GetEvaporationHeat(temperature); dataPoints[i] = new PointF((float)temperature, (float)evapHeat); } return(new CurveF(StringConstants.GetTypeName(StringConstants.EVAPORATION_HEAT), 0.1f, dataPoints)); }
private CurveF GenerateHumidHeatCurve() { double humidity; double humidHeat; PointF[] dataPoints = new PointF[10]; HumidGasCalculator humidGasCalculator = GetHumidGasCalculator(); for (int i = 0; i < 10; i++) { humidity = yVar.Min + (yVar.Max - yVar.Min) / 10.0 * i; humidHeat = humidGasCalculator.GetHumidHeat(humidity); dataPoints[i] = new PointF((float)humidity, (float)humidHeat); } return(new CurveF(StringConstants.GetTypeName(StringConstants.HUMID_HEAT), 273.15f, dataPoints)); }
internal override ErrorMessage CheckSpecifiedValueInContext(ProcessVarDouble pv, double aValue) { ErrorMessage retValue = null; if (pv.VarTypeName == StringConstants.GetTypeName(StringConstants.VAPOR_FRACTION) && aValue < 0.9999) { retValue = CreateSimpleGenericInappropriateSpecifiedValueErrorMessage(pv.VarTypeName + " of an inlet or outlet in a steam jet ejector cannot be less than 1.0."); } else if (pv == dischargeOutlet.Pressure) { if (motiveInlet.Pressure.IsSpecifiedAndHasValue && aValue >= motiveInlet.Pressure.Value) { retValue = CreateSimpleGenericInappropriateSpecifiedValueErrorMessage(pv.VarTypeName + " of discharge outlet cannot be greater than that of motive inlet."); } else if (suctionInlet.Pressure.IsSpecifiedAndHasValue && aValue <= suctionInlet.Pressure.Value) { retValue = CreateSimpleGenericInappropriateSpecifiedValueErrorMessage(pv.VarTypeName + " of discharge outlet cannot be smaller than that of suction inlet."); } } else if (pv == suctionInlet.Pressure) { if (motiveInlet.Pressure.IsSpecifiedAndHasValue && aValue >= motiveInlet.Pressure.Value) { retValue = CreateSimpleGenericInappropriateSpecifiedValueErrorMessage(pv.VarTypeName + " of suction inlet cannot be greater than that of motive inlet."); } else if (dischargeOutlet.Pressure.IsSpecifiedAndHasValue && aValue <= dischargeOutlet.Pressure.Value) { retValue = CreateSimpleGenericInappropriateSpecifiedValueErrorMessage(pv.VarTypeName + " of suction inlet cannot be greater than that of discharge outlet."); } } else if (pv == motiveInlet.Pressure) { if (dischargeOutlet.Pressure.IsSpecifiedAndHasValue && aValue <= dischargeOutlet.Pressure.Value) { retValue = CreateSimpleGenericInappropriateSpecifiedValueErrorMessage(pv.VarTypeName + " of motive inlet cannot be smaller than that of discharge outlet."); } else if (suctionInlet.Pressure.IsSpecifiedAndHasValue && aValue <= suctionInlet.Pressure.Value) { retValue = CreateSimpleGenericInappropriateSpecifiedValueErrorMessage(pv.VarTypeName + " of motive inlet cannot be smaller than that of suction inlet."); } } return(retValue); }
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)); }
protected override ErrorMessage CheckSpecifiedValueRange(ProcessVarDouble pv, double aValue) { ErrorMessage retValue = base.CheckSpecifiedValueRange(pv, aValue); if (retValue != null) { return(retValue); } if (pv == massConcentration) { if (materialStateType != MaterialStateType.Liquid) { throw new IllegalFunctionCallException("Solid material stream should not have its mass concentration variable specified."); } if (aValue != Constants.NO_VALUE && !vaporFraction.HasValue && (aValue < 0 || aValue > 1.0)) { retValue = CreateOutOfRangeZeroToOneErrorMessage(pv); } else if (aValue != Constants.NO_VALUE && vaporFraction.HasValue && (aValue < 0 || aValue > (1.0 - vaporFraction.Value))) { retValue = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, StringConstants.GetTypeName(StringConstants.MASS_CONCENTRATION) + " can not be out of the range of 0 to " + (1.0 - vaporFraction.Value) + " under current conditions"); } } else if (pv == vaporFraction) { if (materialStateType != MaterialStateType.Liquid) { throw new IllegalFunctionCallException("Solid material stream should not have its vapor fraction variable specified."); } if (aValue != Constants.NO_VALUE && massConcentration.HasValue && aValue > (1.0 - massConcentration.Value)) { retValue = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, StringConstants.GetTypeName(StringConstants.VAPOR_FRACTION) + " must be less than " + StringConstants.GetTypeName(StringConstants.MOISTURE_CONTENT_WET) + " under current conditions"); } } return(retValue); }
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); }