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); }
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); }
//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); }
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(); }