private void CalculateDensity() { double densityValue = Constants.NO_VALUE; if (materialStateType == MaterialStateType.Liquid && pressure.HasValue && massConcentration.Value < 1.0e-3) { double tempValue = temperature.Value; if (vaporFraction.HasValue && vaporFraction.Value >= 0.999999) { tempValue += TOLERANCE; } else if (vaporFraction.HasValue && vaporFraction.Value <= TOLERANCE) { tempValue -= TOLERANCE; } densityValue = MoistureProperties.GetDensity(pressure.Value, tempValue); } else { densityValue = CalculateDensity(temperature.Value); } if (densityValue != Constants.NO_VALUE) { Calculate(density, densityValue); } }
private double CalculateTemperatureFromEnthalpyForSolid(double hValue, double moistureContentValue) { double cpLiquid = specificHeat.Value; double tValue = hValue / cpLiquid + 273.15; double tValueOld; double moistureDeltaH; double cs = GetCpOfAbsoluteDryMaterial(); //SteamTable steamTable = SteamTable.GetInstance(); //SubstanceStatesAndProperties props; //double moistureRefEnthalpy = steamTable.GetPropertiesFromPressureAndTemperature(Constants.ONE_ATM, 273.15).enthalpy; double moistureRefEnthalpy = MoistureProperties.GetEnthalpyFromPressureAndTemperature(Constants.ONE_ATM, 273.15); int counter = 0; do { counter++; tValueOld = tValue; //props = steamTable.GetPropertiesFromPressureAndTemperature(Constants.ONE_ATM, tValue); //moistureDeltaH = props.enthalpy - moistureRefEnthalpy; moistureDeltaH = MoistureProperties.GetEnthalpyFromPressureAndTemperature(Constants.ONE_ATM, tValue) - moistureRefEnthalpy; tValue = (hValue - moistureContentValue * moistureDeltaH) / ((1.0 - moistureContentValue) * cs) + 273.15; tValue = tValueOld + 0.5 * (tValue - tValueOld); } while (Math.Abs(tValue - tValueOld) > TOLERANCE && counter < 200); if (counter == 200) { string msg = BuildProperErrorMessage(this.name + ": Calculation of temperature from enthalpy failed.\nPlease make sure each specified value in this stream"); throw new CalculationFailedException(msg); } return(tValue); }
internal double GetCpOfAbsoluteDryMaterial(double tempValue) { EvaporationAndDryingSystem mySystem = this.unitOpSystem as EvaporationAndDryingSystem; DryingMaterial dryingMat = mySystem.DryingMaterial; double cs = Constants.NO_VALUE; if (dryingMat.MaterialType == MaterialType.GenericMaterial) { cs = dryingMat.SpecificHeatOfAbsoluteDryMaterial; } else if (dryingMat.MaterialType == MaterialType.GenericFood) { cs = GenericFoodPropCalculator.GetAbsoluteDryCp((CompositeSubstance)dryingMat.AbsoluteDryMaterial, tempValue); } else { throw new ApplicationException("Material Type has not been supported yet!"); } if (cs == Constants.NO_VALUE && specificHeat.HasValue && moistureContentDryBase.HasValue) { double x = moistureContentDryBase.Value; double cw = MoistureProperties.GetSpecificHeatOfLiquid(); if (tempValue != Constants.NO_VALUE) { cw = MoistureProperties.GetSpecificHeatOfLiquid(tempValue); } cs = (specificHeat.Value * (1.0 + x) - x * cw); } return(cs); }
private double CalculateCp(double tempValue) { double cp = Constants.NO_VALUE; if (massConcentration.HasValue) { if (massConcentration.Value < 1.0e-6) { cp = MoistureProperties.GetSpecificHeatOfLiquid(tempValue); } else if (massConcentration.Value > 1.0e-6 && specificHeatDryBase.HasValue) { //double cm = specificHeatAbsDry.Value + moistureContentDryBase.Value * liquidCp; cp = specificHeatDryBase.Value / (1.0 + moistureContentDryBase.Value); } } else if (DryingMaterial.MaterialType == MaterialType.GenericFood) { cp = GenericFoodPropCalculator.GetCp(materialComponents.Components, tempValue); } else if (DryingMaterial.MaterialType == MaterialType.SpecialFood && massConcentration.HasValue) { cp = SpecialFoodPropCalculator.GetCp(DryingMaterial.Name, massConcentration.Value, tempValue); } return(cp); }
private double CalculateDensity(double tempValue) { double densityValue = Constants.NO_VALUE; if (DryingMaterial.MaterialType == MaterialType.GenericFood) { densityValue = GenericFoodPropCalculator.GetDensity(materialComponents.Components, tempValue); } else if (DryingMaterial.MaterialType == MaterialType.SpecialFood) { densityValue = SpecialFoodPropCalculator.GetDensity(DryingMaterial.Name, massConcentration.Value, tempValue); } else { if (density.IsSpecifiedAndHasValue) { densityValue = density.Value; } else if (massConcentration.Value <= TOLERANCE && pressure.HasValue) { densityValue = MoistureProperties.GetDensity(pressure.Value, tempValue); } } return(densityValue); }
private void CalculateEnthalpyFromVaporFraction(double pValue, double vfValue, double moistureContentValue) { double massConcentrationValue = 1.0 - moistureContentValue; double tBoilingPointOfSolution = GetBoilingPoint(pValue, massConcentrationValue); massConcentrationValue = massConcentrationValue / (1.0 - vfValue); double tBoilingPointOfSolutionFinal = GetBoilingPoint(pValue, massConcentrationValue); double evapHeat = GetEvaporationHeat(MathUtility.Average(tBoilingPointOfSolution, tBoilingPointOfSolutionFinal)); double moistureLiquidCp = MoistureProperties.GetSpecificHeatOfLiquid(MathUtility.Average(tBoilingPointOfSolution, tBoilingPointOfSolutionFinal)); double cs = GetCpOfAbsoluteDryMaterial(); double hBubble = GetBubblePointEnthalpy(pValue, moistureContentValue); double hBoilingPointRise = (moistureContentValue * moistureLiquidCp + (1.0 - moistureContentValue) * cs) * (tBoilingPointOfSolutionFinal - tBoilingPointOfSolution); double h = hBubble + hBoilingPointRise + vfValue * evapHeat; Calculate(specificEnthalpy, h); Calculate(temperature, tBoilingPointOfSolution); if (!specificHeat.HasValue) { double cp; if (Math.Abs(vfValue - 1.0) < 1.0e-5) { cp = GetGasCp(tBoilingPointOfSolution); } else { cp = CalculateCp(tBoilingPointOfSolution); } Calculate(specificHeat, cp); } }
private double CalculateLiquidEnthalpy(double pValue, double tValue, double moistureContentValue) { double tBoilingPointOfSolvent = MoistureProperties.GetSaturationTemperature(pValue); double tBoilingPointOfSolution = GetBoilingPoint(pValue, (1 - moistureContentValue)); double cs = GetCpOfAbsoluteDryMaterial(); double hValue = Constants.NO_VALUE; double hMoisture = Constants.NO_VALUE; //SteamTable steamTable = SteamTable.GetInstance(); //SubstanceStatesAndProperties props; //double mc = moistureContentWetBase.Value; if (tValue < tBoilingPointOfSolvent) { //props = steamTable.GetPropertiesFromPressureAndTemperature(pValue, tValue); hMoisture = MoistureProperties.GetEnthalpyFromPressureAndTemperature(pValue, tValue); hValue = moistureContentValue * hMoisture + (1.0 - moistureContentValue) * cs * (tValue - 273.15); } else if (tValue <= tBoilingPointOfSolution) { //props = steamTable.GetPropertiesFromPressureAndVaporFraction(pValue, 0); //P-V flash is more appropriate for buble point enthalpy of pure moisture hMoisture = MoistureProperties.GetEnthalpyFromPressureAndTemperature(pValue, tBoilingPointOfSolvent - TOLERANCE); double hBoilingPointOfSolvent = moistureContentValue * hMoisture + (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); }
internal override double GetGasDensity(double temperature, double pressure) { //DryingMaterialStreamComponents dmsc = streamComponents as DryingMaterialStreamComponents; //Substance s = dmsc.Moisture.Substance; //double molarWt = s.MolarWeight; //double density = (molarWt * pressure/1000)/(8.314*tempValue); double density = MoistureProperties.GetDensity(pressure, temperature + 0.001); return(density); }
internal override double GetEvaporationHeat(double temperature) { //if (materialStateType != MaterialStateType.Liquid) { // throw new IllegalFunctionCallException("Only liquid material type can have a boiling point."); //} double evapHeat = MoistureProperties.GetEvaporationHeat(temperature); return(evapHeat); }
private void CalculateVaporFractionIfNeeded() { if (!vaporFraction.IsSpecifiedAndHasValue) { double vf = 0; if (temperature.Value > MoistureProperties.GetSaturationTemperature(pressure.Value)) { vf = 1.0; } Calculate(vaporFraction, vf); } }
private double CalculateCp(double temperature) { double cp = Constants.NO_VALUE; if (massConcentration.HasValue && massConcentration.Value <= 1.0e-6) { if (vaporFraction.HasValue && vaporFraction.Value > 0.9999) { cp = GetGasCp(temperature); } else if (temperature != Constants.NO_VALUE && pressure.HasValue) { if (temperature < GetBoilingPoint(pressure.Value)) { cp = MoistureProperties.GetSpecificHeatOfLiquid(temperature); } else if (temperature > GetBoilingPoint(pressure.Value)) { cp = MoistureProperties.GetSpecificHeatOfVapor(temperature); } } } // else if (massConcentration.Value > 1.0e-6 && specificHeatDryBase.HasValue) { // //double cm = specificHeatAbsDry.Value + moistureContentDryBase.Value * liquidCp; // cp = specificHeatDryBase.Value / (1.0 + moistureContentDryBase.Value); // } //} else if (DryingMaterial.MaterialType == MaterialType.GenericFood) { //if (DryingMaterial.MaterialType == MaterialType.GenericFood) { cp = GenericFoodPropCalculator.GetCp(materialComponents.Components, temperature); } else if (DryingMaterial.MaterialType == MaterialType.SpecialFood && massConcentration.HasValue) { cp = SpecialFoodPropCalculator.GetCp(DryingMaterial.Name, massConcentration.Value, temperature); } if (cp == Constants.NO_VALUE && moistureContentDryBase.HasValue) { EvaporationAndDryingSystem mySystem = this.unitOpSystem as EvaporationAndDryingSystem; DryingMaterial dryingMat = mySystem.DryingMaterial; if (dryingMat.SpecificHeatOfAbsoluteDryMaterial != Constants.NO_VALUE) { double moistureLiquidCp = MoistureProperties.GetSpecificHeatOfLiquid(temperature); cp = dryingMat.SpecificHeatOfAbsoluteDryMaterial + moistureContentDryBase.Value * moistureLiquidCp; cp = cp / (1.0 + moistureContentDryBase.Value); } } return(cp); }
internal override double GetLiquidDensity(double temperature) { DryingMaterialComponents dmc = MaterialComponents; Substance s = dmc.Moisture.Substance; double molarWt = s.MolarWeight; double densityValue = Constants.NO_VALUE; if (density.IsSpecifiedAndHasValue) { densityValue = density.Value; } else if (massConcentration.Value <= TOLERANCE && pressure.HasValue) { densityValue = MoistureProperties.GetDensity(pressure.Value, temperature); } return(densityValue); }
private void CalculateCpOfPureMoisture() { double cp = Constants.NO_VALUE; double tempValue = temperature.Value; if (vaporFraction.HasValue && vaporFraction.Value >= 0.999999) { //tempValue += 0.001; cp = MoistureProperties.GetSpecificHeatOfVapor(tempValue); } else if (vaporFraction.HasValue && vaporFraction.Value <= 0.000001) { //tempValue -= 0.001; cp = MoistureProperties.GetSpecificHeatOfLiquid(tempValue); } Calculate(specificHeat, cp); }
private void CalculateVaporFractionIfNeeded() { if (!vaporFraction.IsSpecifiedAndHasValue) { double vf = 0; double bolingPoint = MoistureProperties.GetSaturationTemperature(pressure.Value); //if (specificEnthalpy.HasValue && specificEnthalpy.Value >= MoistureProperties.GetEnthalpyFromPressureAndTemperature(pressure.Value, bolingPoint)) { // vf = 1.0; //} //else if (temperature.HasValue && temperature.Value > bolingPoint) { if (temperature.HasValue && temperature.Value > bolingPoint) { vf = 1.0; } Calculate(vaporFraction, vf); } }
private double CalculateCp(double temperature) { double cp = Constants.NO_VALUE; if (massConcentration.HasValue && massConcentration.Value <= TOLERANCE) { if (vaporFraction.HasValue && vaporFraction.Value > 0.9999) { cp = GetGasCp(temperature); } else if (temperature != Constants.NO_VALUE && pressure.HasValue) { if (temperature < GetBoilingPoint(pressure.Value)) { cp = MoistureProperties.GetSpecificHeatOfLiquid(temperature); } else if (temperature > GetBoilingPoint(pressure.Value)) { cp = MoistureProperties.GetSpecificHeatOfVapor(temperature); } } } else if (DryingMaterial.MaterialType == MaterialType.GenericFood) { //if (DryingMaterial.MaterialType == MaterialType.GenericFood) { cp = GenericFoodPropCalculator.GetCp(materialComponents.Components, temperature); } else if (DryingMaterial.MaterialType == MaterialType.SpecialFood && massConcentration.HasValue) { cp = SpecialFoodPropCalculator.GetCp(DryingMaterial.Name, massConcentration.Value, temperature); } if (cp == Constants.NO_VALUE && moistureContentDryBase.HasValue) { if (DryingMaterial.SpecificHeatOfAbsoluteDryMaterial != Constants.NO_VALUE) { double moistureLiquidCp = MoistureProperties.GetSpecificHeatOfLiquid(temperature); cp = DryingMaterial.SpecificHeatOfAbsoluteDryMaterial + moistureContentDryBase.Value * moistureLiquidCp; cp = cp / (1.0 + moistureContentDryBase.Value); } } return(cp); }
internal double GetCpOfAbsoluteDryMaterial(double tempValue) { EvaporationAndDryingSystem mySystem = this.unitOpSystem as EvaporationAndDryingSystem; DryingMaterial dryingMat = mySystem.DryingMaterial; double cs = dryingMat.SpecificHeatOfAbsoluteDryMaterial; if (cs == Constants.NO_VALUE && specificHeat.HasValue && moistureContentDryBase.HasValue) { double x = moistureContentDryBase.Value; double cw = MoistureProperties.GetSpecificHeatOfLiquid(); if (tempValue != Constants.NO_VALUE) { cw = MoistureProperties.GetSpecificHeatOfLiquid(tempValue); } cs = (specificHeat.Value * (1.0 + x) - x * cw); } return(cs); }
internal double GetBoilingPoint(double pressureValue, double massConcentrationValue) { //if (materialStateType != MaterialStateType.Liquid) { // throw new IllegalFunctionCallException("Only liquid material type can have a boiling point."); //} double tEvap = MoistureProperties.GetSaturationTemperature(pressureValue); //modify boiling point for concentration effect double bpe = 0; if (massConcentrationValue > 1.0e-4) { DryingMaterial dm = (unitOpSystem as EvaporationAndDryingSystem).DryingMaterial; bpe = BoilingPointRiseCalculator.CalculateBoilingPointElevation(dm, massConcentrationValue, pressureValue); } return(tEvap + bpe); }
private void CalculateEnthalpyFromTemperature(double pValue, double tValue, double moistureContentValue) { //double tBoilingPointOfSolvent = MoistureProperties.GetSaturationTemperature(pValue); double tBoilingPointOfSolution = GetBoilingPoint(pValue); double hValue; if (tValue <= tBoilingPointOfSolution) { hValue = CalculateLiquidEnthalpy(pValue, tValue, moistureContentValue); Calculate(specificEnthalpy, hValue); Calculate(vaporFraction, 0.0); } else if (tValue > tBoilingPointOfSolution) { double hBubble = GetBubblePointEnthalpy(pValue, moistureContentValue); double evapHeat = GetEvaporationHeat(tBoilingPointOfSolution); double hVapor1 = MoistureProperties.GetEnthalpyFromPressureAndTemperature(pValue, tBoilingPointOfSolution + TOLERANCE); double hVapor2 = hVapor2 = MoistureProperties.GetEnthalpyFromPressureAndTemperature(pValue, tValue); //if (DryingMaterial.Moisture.IsWater) { // SteamTable steamTable = SteamTable.GetInstance(); // SubstanceStatesAndProperties props = steamTable.GetPropertiesFromPressureAndTemperature(pValue, tBoilingPointOfSolution + TOLERANCE); // hVapor1 = props.enthalpy; // props = steamTable.GetPropertiesFromPressureAndTemperature(pValue, tValue); // hVapor2 = props.enthalpy; //} //else { // hVapor1 = MoistureProperties.GetEnthalpy(pValue, tBoilingPointOfSolution + TOLERANCE); // hVapor2 = MoistureProperties.GetEnthalpy(pValue, tValue); //} double cs = GetCpOfAbsoluteDryMaterial(tValue); hValue = hBubble + moistureContentValue * (evapHeat + (hVapor2 - hVapor1)) + (1.0 - moistureContentValue) * cs * (tValue - tBoilingPointOfSolution); Calculate(specificEnthalpy, hValue); if (materialStateType == MaterialStateType.Liquid) { Calculate(vaporFraction, moistureContentValue); } } }
internal override double GetGasDensity(double temperature, double pressure) { return(MoistureProperties.GetDensity(pressure, temperature + 0.001)); }
//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) // || (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 (volumeFlowRate.IsSpecifiedAndHasValue && density.IsSpecifiedAndHasValue) { Calculate(massFlowRate, volumeFlowRate.Value * density.Value); } if (materialStateType == MaterialStateType.Liquid) { if (massConcentration.HasValue && massConcentration.Value > TOLERANCE) { 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 <= TOLERANCE) { 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 > TOLERANCE) { 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 { double h = Constants.NO_VALUE; if (specificEnthalpy.HasValue && !temperature.IsSpecifiedAndHasValue) { double t = MoistureProperties.GetTemperatureFromPressureAndEnthalpy(pressure.Value, specificEnthalpy.Value); Calculate(temperature, t); CalculateVaporFractionIfNeeded(); } else if (temperature.HasValue) { h = MoistureProperties.GetEnthalpyFromPressureAndTemperature(pressure.Value, temperature.Value); Calculate(specificEnthalpy, h); CalculateVaporFractionIfNeeded(); } else if (vaporFraction.HasValue) { double boilingPoint = MoistureProperties.GetSaturationTemperature(pressure.Value); h = MoistureProperties.GetEnthalpyFromPressureAndVaporFraction(pressure.Value, vaporFraction.Value); Calculate(temperature, boilingPoint); Calculate(specificEnthalpy, h); } //CalculateCpOfPureMoisture(); if (specificEnthalpy.HasValue) { 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 (!volumeFlowRate.IsSpecifiedAndHasValue && massFlowRate.HasValue && density.HasValue) { Calculate(volumeFlowRate, massFlowRate.Value / density.Value); } if (materialStateType == MaterialStateType.Solid && temperature.HasValue && massFlowRate.HasValue && moistureContentWetBase.HasValue && specificHeat.HasValue && specificEnthalpy.HasValue) { solveState = SolveState.Solved; } else if (materialStateType == MaterialStateType.Liquid && pressure.HasValue && temperature.HasValue && massFlowRate.HasValue && moistureContentWetBase.HasValue && specificEnthalpy.HasValue && vaporFraction.HasValue) { solveState = SolveState.Solved; } AdjustVarsStates(); //if (HasSolvedAlready) { // DryingMaterialComponents dmc = MaterialComponents; // dmc.Moisture.SetMassFractionValue(moistureContentWetBase.Value); // dmc.AbsoluteDryMaterial.SetMassFractionValue(1.0 - moistureContentWetBase.Value); // dmc.ComponentsFractionsChanged(); //} OnSolveComplete(); }
// 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 it is a known meterial in the material database, specific heat can be calculated double moistureLiquidCp = Constants.NO_VALUE; if (temperature.HasValue && moistureContentWetBase.HasValue) { double cp = CalculateCp(temperature.Value); moistureLiquidCp = MoistureProperties.GetSpecificHeatOfLiquid(temperature.Value); if (cp != Constants.NO_VALUE) { Calculate(specificHeat, cp); if (moistureContentDryBase.HasValue) { Calculate(specificHeatDryBase, cp * (1.0 + moistureContentDryBase.Value)); double cpAbsDry = specificHeatDryBase.Value - moistureContentDryBase.Value * moistureLiquidCp; Calculate(specificHeatAbsDry, cpAbsDry); } } else if (specificHeatAbsDry.HasValue && !specificHeat.IsSpecifiedAndHasValue) { double cpMaterialDryBase = specificHeatAbsDry.Value + moistureContentDryBase.Value * moistureLiquidCp; Calculate(specificHeatDryBase, cpMaterialDryBase); Calculate(specificHeat, cpMaterialDryBase / (1.0 + moistureContentDryBase.Value)); } else if (specificHeat.HasValue && moistureContentDryBase.HasValue && temperature.HasValue && !specificHeatAbsDry.IsSpecifiedAndHasValue) { Calculate(specificHeatDryBase, specificHeat.Value / (1.0 - moistureContentWetBase.Value)); Calculate(specificHeatAbsDry, specificHeatDryBase.Value - moistureContentDryBase.Value * moistureLiquidCp); } } else if (moistureContentWetBase.Value == 1.0 && !specificHeat.IsSpecifiedAndHasValue) { Calculate(specificHeatDryBase, Constants.NO_VALUE); Calculate(specificHeatAbsDry, 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)); } else if (specificEnthalpy.HasValue && !temperature.IsSpecifiedAndHasValue) { Calculate(temperature, specificEnthalpy.Value / specificHeat.Value + 273.15); } } else if (materialStateType == MaterialStateType.Liquid && pressure.HasValue) { if (specificEnthalpy.HasValue && !temperature.IsSpecifiedAndHasValue) { CalculateTemperatureFromEnthalpy(); } else if (temperature.HasValue && massConcentration.HasValue) { double tBoilingPoint = GetBoilingPoint(pressure.Value); if (temperature.Value < tBoilingPoint) { Calculate(vaporFraction, 0.0); if (specificHeat.HasValue) { Calculate(specificEnthalpy, specificHeat.Value * (temperature.Value - 273.15)); } } else if (temperature.Value > tBoilingPoint) { Calculate(vaporFraction, 1.0); if (specificHeat.HasValue) { double evapHeat = GetEvaporationHeat(tBoilingPoint); double gasCp = GetLiquidCp(tBoilingPoint); double h = moistureLiquidCp * (tBoilingPoint - 273.15) + evapHeat + gasCp * (temperature.Value - tBoilingPoint); Calculate(specificEnthalpy, h); } } else if (vaporFraction.HasValue) { double liquidCp = specificHeat.Value; if (!specificHeat.HasValue) { liquidCp = CalculateCp(tBoilingPoint); } double evapHeat = GetEvaporationHeat(tBoilingPoint); double h = liquidCp * (tBoilingPoint - 273.15) + vaporFraction.Value * evapHeat; Calculate(specificEnthalpy, h); } } else if (vaporFraction.HasValue && massConcentration.HasValue) { double tBoilingPoint = GetBoilingPoint(pressure.Value); Calculate(temperature, tBoilingPoint); double liquidCp = specificHeat.Value; if (!specificHeat.HasValue) { liquidCp = CalculateCp(tBoilingPoint); } double evapHeat = GetEvaporationHeat(tBoilingPoint); double h = liquidCp * (tBoilingPoint - 273.15) + vaporFraction.Value * evapHeat; Calculate(specificEnthalpy, h); if (Math.Abs(vaporFraction.Value - 1.0) < 1.0e-5) { Calculate(specificHeat, GetGasCp(tBoilingPoint)); } else if (Math.Abs(vaporFraction.Value - 0.0) < 1.0e-5) { Calculate(specificHeat, liquidCp); } } } 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) { solveState = SolveState.Solved; } else if (materialStateType == MaterialStateType.Liquid && pressure.HasValue && temperature.HasValue && massFlowRate.HasValue && moistureContentWetBase.HasValue && specificEnthalpy.HasValue && vaporFraction.HasValue) { solveState = SolveState.Solved; } else if ((!massFlowRate.IsSpecified && massFlowRate.HasValue) || (!massFlowRateDryBase.IsSpecified && massFlowRateDryBase.HasValue) || (!moistureContentWetBase.IsSpecified && moistureContentWetBase.HasValue) || (!moistureContentDryBase.IsSpecified && moistureContentDryBase.HasValue) || (!massConcentration.IsSpecified && massConcentration.HasValue) || (!specificHeat.IsSpecified && specificHeat.HasValue) || (!specificHeatAbsDry.IsSpecified && specificHeatAbsDry.HasValue) || (!specificEnthalpy.IsSpecified && specificEnthalpy.HasValue)) { solveState = SolveState.PartiallySolved; } AdjustVarsStates(); if (HasSolvedAlready) { DryingMaterialComponents dmc = MaterialComponents; dmc.Moisture.SetMassFractionValue(moistureContentWetBase.Value); dmc.AbsoluteDryMaterial.SetMassFractionValue(1.0 - moistureContentWetBase.Value); dmc.ComponentsFractionsChanged(); } OnSolveComplete(solveState); }
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); //} } }
//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); }
private void CalculateTemperatureFromEnthalpy(double pValue, double hValue, double moistureContentValue) { double tValue = Constants.NO_VALUE; double tValueOld = Constants.NO_VALUE; double vfValue = Constants.NO_VALUE; double tBoilingPointOfSolvent = MoistureProperties.GetSaturationTemperature(pValue); double tBoilingPointOfSolution = GetBoilingPoint(pValue); double cpLiquid = specificHeat.Value; if (cpLiquid == Constants.NO_VALUE) { cpLiquid = GetLiquidCp(MathUtility.Average(273.15, tBoilingPointOfSolution)); } if (cpLiquid == Constants.NO_VALUE) { return; } //SteamTable steamTable = SteamTable.GetInstance(); //SubstanceStatesAndProperties props; double hBoilingPointOfSolvent = CalculateLiquidEnthalpy(pValue, tBoilingPointOfSolvent, moistureContentValue); double hBubble = GetBubblePointEnthalpy(pValue, moistureContentValue); double hDew = GetDewPointEnthalpy(pValue, moistureContentValue); double cs = GetCpOfAbsoluteDryMaterial(); int counter = 0; if (hValue <= hBoilingPointOfSolvent) { double tempH; //tValue = hValue / cpLiquid + 273.15; tValue = tBoilingPointOfSolvent - (hBoilingPointOfSolvent - hValue) / cpLiquid; do { counter++; tValueOld = tValue; tempH = (hValue - (1.0 - moistureContentValue) * cs * (tValue - 273.15)) / moistureContentValue; //props = steamTable.GetPropertiesFromPressureAndEnthalpy(pValue, tempH); //tValue = props.temperature; tValue = MoistureProperties.GetTemperatureFromPressureAndEnthalpy(pValue, tempH); } while (Math.Abs(tValue - tValueOld) > TOLERANCE && counter < 200); if (counter == 200) { string msg = BuildProperErrorMessage(this.name + ": Calculation of temperature from enthalpy failed.\nPlease make sure each specified value in this stream"); throw new CalculationFailedException(msg); } vfValue = 0.0; } else if (hValue <= hBubble) { double moistureLiquidCp; //double hBoilingPointOfSolvent = CalculateLiquidEnthalpy(pValue, tBoilingPointOfSolvent - TOLERANCE); //tValue = hValue / cpLiquid + 273.15; tValue = (hValue - hBoilingPointOfSolvent) / cpLiquid + tBoilingPointOfSolvent; do { counter++; tValueOld = tValue; moistureLiquidCp = MoistureProperties.GetSpecificHeatOfLiquid(MathUtility.Average(tBoilingPointOfSolvent, tValue)); tValue = (hValue - hBoilingPointOfSolvent) / (moistureContentValue * moistureLiquidCp + (1.0 - moistureContentValue) * cs) + tBoilingPointOfSolvent; } while (Math.Abs(tValue - tValueOld) > TOLERANCE && counter < 200); if (counter == 200) { string msg = BuildProperErrorMessage(this.name + ": Calculation of temperature from enthalpy failed.\nPlease make sure each specified value in this stream"); throw new CalculationFailedException(msg); } vfValue = 0.0; } else if (hValue <= hDew) { double tBoilingPointOfSolutionFinal = tBoilingPointOfSolution; double evapHeat = GetEvaporationHeat(tBoilingPointOfSolution); double extraHeat = (hValue - hBubble); if (moistureContentValue > 0.9999) { vfValue = extraHeat / evapHeat; } else { vfValue = 0; double vfValueOld; double moistureLiquidCp; double massConcentrationValue = 1.0 - moistureContentValue; do { counter++; vfValueOld = vfValue; vfValue = extraHeat / evapHeat; massConcentrationValue = (1.0 - moistureContentValue) / (1.0 - vfValue); tBoilingPointOfSolutionFinal = GetBoilingPoint(pValue, massConcentrationValue); evapHeat = GetEvaporationHeat(MathUtility.Average(tBoilingPointOfSolution, tBoilingPointOfSolutionFinal)); moistureLiquidCp = MoistureProperties.GetSpecificHeatOfLiquid(MathUtility.Average(tBoilingPointOfSolution, tBoilingPointOfSolutionFinal)); extraHeat = hValue - hBubble - (moistureContentValue * moistureLiquidCp + (1.0 - moistureContentValue) * cs) * (tBoilingPointOfSolutionFinal - tBoilingPointOfSolution); } while (Math.Abs(vfValue - vfValueOld) > TOLERANCE && counter < 200); if (counter == 200) { string msg = BuildProperErrorMessage(this.name + ": Calculation of temperature from enthalpy failed.\nPlease make sure each specified value in this stream"); throw new CalculationFailedException(msg); } } if (vfValue < 0.0) { vfValue = 0.0; } tValue = tBoilingPointOfSolutionFinal; } else if (hValue > hDew) { double apparentHeat; double hVapor; double cpGas = GetGasCp(tBoilingPointOfSolution); tValue = (hValue - hDew) / cpGas + tBoilingPointOfSolution; do { apparentHeat = (hValue - hDew - (1.0 - moistureContentValue) * cs * (tValue - tBoilingPointOfSolution)) / moistureContentValue; //props = steamTable.GetPropertiesFromPressureAndTemperature(pValue, tBoilingPointOfSolution + TOLERANCE); //hVapor = props.enthalpy + apparentHeat; hVapor = apparentHeat + MoistureProperties.GetEnthalpyFromPressureAndTemperature(pValue, tBoilingPointOfSolution + TOLERANCE); //props = steamTable.GetPropertiesFromPressureAndEnthalpy(pressure.Value, hVapor); tValueOld = tValue; //tValue = props.temperature; tValue = MoistureProperties.GetTemperatureFromPressureAndEnthalpy(pressure.Value, hVapor); } while (Math.Abs(tValue - tValueOld) > TOLERANCE && counter < 200); if (counter == 200) { string msg = BuildProperErrorMessage(this.name + ": Calculation of temperature from enthalpy failed.\nPlease make sure each specified value in this stream"); throw new CalculationFailedException(msg); } vfValue = moistureContentValue; } Calculate(temperature, tValue); Calculate(vaporFraction, vfValue); if (!specificHeat.HasValue) { double cp; if (hValue <= hBubble) { cp = GetLiquidCp(tValue); } else { cp = GetGasCp(tValue); } Calculate(specificHeat, cp); } }
internal override double GetGasCp(double tempValue) { double cp = MoistureProperties.GetSpecificHeatOfVapor(tempValue); return(cp); }
internal override double GetLiquidDensity(double temperature) { return(MoistureProperties.GetDensity(pressure.Value, temperature)); }
internal override double GetEvaporationHeat(double temperature) { return(MoistureProperties.GetEvaporationHeat(temperature)); }
internal override double GetLiquidCp(double tempValue) { return(MoistureProperties.GetSpecificHeatOfLiquid(tempValue)); }
private void Solve() { //Mass Transfer--gas moisture and material particles transfer from gas stream to liquid stream DryingMaterialStream dmsOutlet = liquidOutlet as DryingMaterialStream; DryingGasStream dgsInlet = gasInlet as DryingGasStream; DryingGasStream dgsOutlet = gasOutlet as DryingGasStream; //if (dgsInlet.DewPoint.HasValue && dgsOutlet.Temperature.HasValue && dgsOutlet.Temperature.Value > dgsInlet.DewPoint.Value) { // throw new InappropriateSpecifiedValueException("Gas outlet temperature is not low enough to reach satuation"); //} Calculate(dgsOutlet.RelativeHumidity, 0.9999999); //have to recalculate the streams so that the following balance calcualtion //can have all the latest balance calculated values taken into account if (dgsOutlet.Temperature.HasValue || dgsOutlet.WetBulbTemperature.HasValue) { 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 materialFromGas = ParticleCollectionRate.Value; if (inletDustMassFlowRate != Constants.NO_VALUE && materialFromGas != Constants.NO_VALUE && outletDustMassFlowRate == Constants.NO_VALUE) { outletDustMassFlowRate = inletDustMassFlowRate - materialFromGas; } MoistureProperties moistureProperties = (this.unitOpSystem as EvaporationAndDryingSystem).GetMoistureProperties(((DryingGasStream)gasInlet).GasComponents.Moisture.Substance); double materialEnthalpyLoss; double gasEnthalpyLoss; double gatTempValue; double matTempValue; double liquidCp; double specificHeatOfSolidPhase; double totalEnthapyLoss; if (waterInlet != null && waterOutlet != null) { if (waterInlet.MassFlowRate.HasValue) { Calculate(waterOutlet.MassFlowRate, waterInlet.MassFlowRate.Value); } else if (waterOutlet.MassFlowRate.HasValue) { Calculate(waterInlet.MassFlowRate, waterOutlet.MassFlowRate.Value); } if (waterInlet.SpecificEnthalpy.HasValue && waterInlet.MassFlowRate.HasValue && waterOutlet.SpecificEnthalpy.HasValue) { double waterEnthalpyGain = waterInlet.MassFlowRate.Value * (waterOutlet.SpecificEnthalpy.Value - waterInlet.SpecificEnthalpy.Value); Calculate(coolingDuty, waterEnthalpyGain); } } if (dmsOutlet.Temperature.HasValue && dgsInlet.SpecificEnthalpyDryBase.HasValue && coolingDuty.HasValue && dgsInlet.MassFlowRateDryBase.HasValue && inletDustMoistureFraction != Constants.NO_VALUE && materialFromGas != Constants.NO_VALUE) { gatTempValue = gasInlet.Temperature.Value; matTempValue = dmsOutlet.Temperature.Value; liquidCp = moistureProperties.GetSpecificHeatOfLiquid(MathUtility.Average(gatTempValue, matTempValue)); specificHeatOfSolidPhase = (1.0 - inletDustMoistureFraction) * dmsOutlet.GetCpOfAbsoluteDryMaterial() + inletDustMoistureFraction * liquidCp; materialEnthalpyLoss = materialFromGas * specificHeatOfSolidPhase * (matTempValue - gatTempValue); gasEnthalpyLoss = coolingDuty.Value - materialEnthalpyLoss; //double outletEnthalpy = gasInlet.SpecificEnthalpy.Value - gasEnthalpyLoss; //Calculate(gasOutlet.SpecificEnthalpy, outletEnthalpy); double outletEnthalpy = dgsInlet.SpecificEnthalpyDryBase.Value - gasEnthalpyLoss / dgsInlet.MassFlowRateDryBase.Value; Calculate(dgsOutlet.SpecificEnthalpyDryBase, outletEnthalpy); UpdateStreamsIfNecessary(); if (dgsOutlet.VolumeFlowRate.HasValue) { double outletLoading = outletDustMassFlowRate / dgsOutlet.VolumeFlowRate.Value; Calculate(OutletParticleLoading, outletLoading); } } else if (dmsOutlet.Temperature.HasValue && dgsInlet.SpecificEnthalpyDryBase.HasValue && dgsOutlet.Temperature.HasValue && dgsInlet.MassFlowRateDryBase.HasValue && dgsOutlet.SpecificEnthalpyDryBase.HasValue && inletDustMoistureFraction != Constants.NO_VALUE) { gatTempValue = dgsInlet.Temperature.Value; matTempValue = dmsOutlet.Temperature.Value; liquidCp = moistureProperties.GetSpecificHeatOfLiquid(MathUtility.Average(gatTempValue, matTempValue)); specificHeatOfSolidPhase = (1.0 - inletDustMoistureFraction) * dmsOutlet.GetCpOfAbsoluteDryMaterial() + inletDustMoistureFraction * liquidCp; materialEnthalpyLoss = materialFromGas * specificHeatOfSolidPhase * (matTempValue - gatTempValue); gasEnthalpyLoss = dgsInlet.MassFlowRateDryBase.Value * (dgsInlet.SpecificEnthalpyDryBase.Value - dgsOutlet.SpecificEnthalpyDryBase.Value); totalEnthapyLoss = materialEnthalpyLoss + gasEnthalpyLoss; Calculate(coolingDuty, totalEnthapyLoss); if (waterInlet != null && waterOutlet != null) { if (waterInlet.SpecificEnthalpy.HasValue && waterInlet.MassFlowRate.HasValue) { double waterOutletSpecificEnthanlpy = totalEnthapyLoss / waterInlet.MassFlowRate.Value + waterInlet.SpecificEnthalpy.Value; Calculate(waterOutlet.SpecificEnthalpy, waterOutletSpecificEnthanlpy); } else if (waterOutlet.SpecificEnthalpy.HasValue && waterInlet.MassFlowRate.HasValue) { double waterInletSpecificEnthanlpy = waterOutlet.SpecificEnthalpy.Value - totalEnthapyLoss / waterInlet.MassFlowRate.Value; Calculate(waterOutlet.SpecificEnthalpy, waterInletSpecificEnthanlpy); } } } //else if (gasInlet.SpecificEnthalpy.HasValue && gasOutlet.SpecificEnthalpy.HasValue && coolingDuty.HasValue // && gasInlet.MassFlowRate.HasValue && inletDustMoistureFraction != Constants.NO_VALUE) { // gasEnthalpyLoss = gasInlet.SpecificEnthalpy.Value * gasInlet.MassFlowRate.Value - gasOutlet.SpecificEnthalpy.Value * gasOutlet.MassFlowRate.Value; // materialEnthalpyLoss = coolingDuty.Value - gasEnthalpyLoss; // gatTempValue = gasInlet.Temperature.Value; // //double matTempValue = dmsOutlet.Temperature.Value; // liquidCp = moistureProperties.GetSpecificHeatOfLiquid(gatTempValue); // specificHeatOfSolidPhase = (1.0 - inletDustMoistureFraction) * dmsOutlet.GetCpOfAbsoluteDryMaterial() + inletDustMoistureFraction * liquidCp; // matTempValue = gatTempValue + materialEnthalpyLoss / (materialFromGas * specificHeatOfSolidPhase); // Calculate(liquidOutlet.Temperature, matTempValue); //} 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; } if (materialFromGas != Constants.NO_VALUE && inletMoistureFlowRate != Constants.NO_VALUE && outletMoistureFlowRate != Constants.NO_VALUE) { double moistureFromGas = inletMoistureFlowRate - outletMoistureFlowRate; // materialFromGas = inletDustMassFlowRate - outletDustMassFlowRate; double moistureOfMaterialFromGas = inletDustMassFlowRate * inletDustMoistureFraction - outletDustMassFlowRate * outletDustMoistureFraction; double outletMassFlowRate = materialFromGas + moistureFromGas; Calculate(dmsOutlet.MassFlowRate, outletMassFlowRate); double outletMaterialMoistureFlowRate = moistureFromGas + moistureOfMaterialFromGas; double outletMoistureContentWetBase = outletMaterialMoistureFlowRate / outletMassFlowRate; Calculate(dmsOutlet.MoistureContentWetBase, outletMoistureContentWetBase); //solveState = SolveState.Solved; } 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); } } if (dgsInlet.DewPoint.HasValue && dgsOutlet.Temperature.HasValue && dgsOutlet.Temperature.Value > dgsInlet.DewPoint.Value) { solveState = SolveState.SolvedWithWarning; } //else if (gasInlet.Pressure.HasValue && gasOutlet.Pressure.HasValue // && gasInlet.Temperature.HasValue && gasOutlet.Temperature.HasValue // && gasInlet.SpecificEnthalpy.HasValue && gasOutlet.SpecificEnthalpy.HasValue // && waterInlet.Pressure.HasValue && waterOutlet.Pressure.HasValue // && waterInlet.Temperature.HasValue && waterOutlet.Temperature.HasValue // && waterInlet.SpecificEnthalpy.HasValue && waterOutlet.SpecificEnthalpy.HasValue // && liquidOutlet.Pressure.HasValue && liquidOutlet.Temperature.HasValue // && dmsOutlet.MoistureContentWetBase.HasValue) { else if (gasInlet.SolveState == SolveState.Solved && gasOutlet.SolveState == SolveState.Solved && coolingDuty.HasValue && ((waterInlet == null || waterOutlet == null) || (waterInlet != null && waterOutlet != null) && (waterInlet.SolveState == SolveState.Solved && waterOutlet.SpecificEnthalpy.HasValue || waterOutlet.SolveState == SolveState.Solved && waterInlet.SpecificEnthalpy.HasValue))) { solveState = SolveState.Solved; } }
internal override double GetBoilingPoint(double pressureValue) { return(MoistureProperties.GetSaturationTemperature(pressureValue)); }