New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #8599 - Incorrect psychrometric calculation causes error #8833
Changes from all commits
f710d20
8b432be
03f018b
eb4613c
e05a4c8
bdbaff2
3608395
62cc2cb
b4f7e83
7d40fa2
3118219
e1f21d6
c8d9d54
77bd925
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -971,7 +971,9 @@ void Iterate(Real64 &ResultX, // ResultX is the final Iteration result passed b | |
|
||
// New guess calculated from LINEAR FIT of most recent two points | ||
DY = Y0 - Y1; | ||
if (std::abs(DY) < small) DY = small; | ||
if (std::abs(DY) < small) { | ||
DY = small; | ||
} | ||
Comment on lines
+974
to
+976
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated, but it's handy to put a debugger breakpoint... (We should have clang-format do that everywhere IMHO) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. It's standard practice but not enforced. |
||
// new estimation | ||
|
||
ResultX = (Y0 * X1 - Y1 * X0) / DY; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ | |
#include <EnergyPlus/CommandLineInterface.hh> | ||
#include <EnergyPlus/Data/EnergyPlusData.hh> | ||
#include <EnergyPlus/DataEnvironment.hh> | ||
#include <EnergyPlus/DataGlobalConstants.hh> | ||
#include <EnergyPlus/General.hh> | ||
#include <EnergyPlus/Psychrometrics.hh> | ||
#include <EnergyPlus/UtilityRoutines.hh> | ||
|
@@ -498,7 +499,9 @@ namespace Psychrometrics { | |
for (iter = 1; iter <= itmax; ++iter) { | ||
|
||
// Assigning a value to WBT | ||
if (WBT >= (tBoil - 0.09)) WBT = tBoil - 0.1; | ||
if (WBT >= (tBoil - 0.09)) { | ||
WBT = tBoil - 0.1; | ||
} | ||
|
||
// Determine the saturation pressure for wet bulb temperature | ||
PSatstar = | ||
|
@@ -523,10 +526,9 @@ namespace Psychrometrics { | |
WBT = ResultX; | ||
|
||
// If converged, leave iteration loop. | ||
if (icvg == 1) break; | ||
|
||
// Error Trap for the Discontinuous nature of PsyPsatFnTemp function (Sat Press Curve) at ~0 Deg C. | ||
if ((PSatstar > 611.000) && (PSatstar < 611.25) && (std::abs(error) <= 0.0001) && (iter > 4)) break; | ||
if (icvg == 1) { | ||
break; | ||
} | ||
Comment on lines
+529
to
+531
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the "Error Trap for the Discontinuous nature of PsyPsatFnTemp function (Sat Press Curve) at ~0 Deg C." since it's no longer discontinuous. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I vaguely remember this. It looks like the unit tests hits this so good there. Gotta check it though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I remember this now, this is a check for where this used to have a problem. Now that the problem is corrected, this check is no longer needed. |
||
|
||
} // End of Iteration Loop | ||
|
||
|
@@ -682,6 +684,11 @@ namespace Psychrometrics { | |
// Compared to Table 3 values (August 2007) with average error of 0.00%, max .30%, | ||
// min -.39%. (Spreadsheet available on request - Lawrie). | ||
|
||
// Note: the ASHRAE Handbook of Fundamentals is being slightly inaccurate in its wording, | ||
// and referring to Eq 5 applying to -100°C to 0°C and Eq 6 applying to 0°C to 200°C | ||
// In fact, it is **not** 0°C, but the triple-point of water, which is 0.01°C. Evaluating the Eq 5 and 6 up to and from the triple-point | ||
// is removing the discontinuity altogether. | ||
Comment on lines
+687
to
+690
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New note There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you were actually the one that found this critical point. Nice! |
||
|
||
// USE STATEMENTS: | ||
|
||
// Return value | ||
|
@@ -734,29 +741,34 @@ namespace Psychrometrics { | |
|
||
// If below -100C,set value of Pressure corresponding to Saturation Temperature of -100C. | ||
if (Tkel < 173.15) { | ||
Pascal = 0.0017; | ||
Pascal = 0.001405102123874164; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rraustad and I noted that the value below -100°C does not match the evaluation of the equation at -100°C. So align. |
||
|
||
// If below freezing, calculate saturation pressure over ice. | ||
} else if (Tkel < DataGlobalConstants::KelvinConv) { // Tkel >= 173.15 | ||
Real64 constexpr C1(-5674.5359); // Coefficient for TKel < KelvinConvK | ||
Real64 constexpr C2(6.3925247); // Coefficient for TKel < KelvinConvK | ||
Real64 constexpr C3(-0.9677843e-2); // Coefficient for TKel < KelvinConvK | ||
Real64 constexpr C4(0.62215701e-6); // Coefficient for TKel < KelvinConvK | ||
Real64 constexpr C5(0.20747825e-8); // Coefficient for TKel < KelvinConvK | ||
Real64 constexpr C6(-0.9484024e-12); // Coefficient for TKel < KelvinConvK | ||
Real64 constexpr C7(4.1635019); // Coefficient for TKel < KelvinConvK | ||
} else if (Tkel < DataGlobalConstants::TriplePointOfWaterTempKelvin) { // Tkel >= 173.15, Tkel < 273.16 (0.01°C) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The actual fix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
jmarrec marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Real64 constexpr C1(-5674.5359); | ||
Real64 constexpr C2(6.3925247); | ||
Real64 constexpr C3(-0.9677843e-2); | ||
Real64 constexpr C4(0.62215701e-6); | ||
Real64 constexpr C5(0.20747825e-8); | ||
Real64 constexpr C6(-0.9484024e-12); | ||
Real64 constexpr C7(4.1635019); | ||
Pascal = std::exp(C1 / Tkel + C2 + Tkel * (C3 + Tkel * (C4 + Tkel * (C5 + C6 * Tkel))) + C7 * std::log(Tkel)); | ||
|
||
// If above freezing, calculate saturation pressure over liquid water. | ||
} else if (Tkel <= 473.15) { // Tkel >= 173.15 // Tkel >= KelvinConv | ||
} else if (Tkel <= 473.15) { // Tkel >= 173.15 // Tkel >= TriplePointOfWaterTempKelvin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The else if above is Tkel < Real64 constexpr TriplePointOfWaterTempKelvin = 273.16; and this is <= 473.15 ... oh yeah, this is the top end so comment is wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These comments are a little confusing but a second looks shows they say what they said before with updates to what was changed. I'd say this is OK. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the comments provide little value overall here, but there were pre-existing. and they should be correct. |
||
#ifndef EP_IF97 | ||
Real64 constexpr C8(-5800.2206); // Coefficient for TKel >= KelvinConvK | ||
Real64 constexpr C9(1.3914993); // Coefficient for TKel >= KelvinConvK | ||
Real64 constexpr C10(-0.048640239); // Coefficient for TKel >= KelvinConvK | ||
Real64 constexpr C11(0.41764768e-4); // Coefficient for TKel >= KelvinConvK | ||
Real64 constexpr C12(-0.14452093e-7); // Coefficient for TKel >= KelvinConvK | ||
Real64 constexpr C13(6.5459673); // Coefficient for TKel >= KelvinConvK | ||
Real64 constexpr C8(-5800.2206); | ||
Real64 constexpr C9(1.3914993); | ||
Real64 constexpr C10(-0.048640239); | ||
Real64 constexpr C11(0.41764768e-4); | ||
Real64 constexpr C12(-0.14452093e-7); | ||
Real64 constexpr C13(6.5459673); | ||
Pascal = std::exp(C8 / Tkel + C9 + Tkel * (C10 + Tkel * (C11 + Tkel * C12)) + C13 * std::log(Tkel)); | ||
|
||
// If above 200C, set value of Pressure corresponding to Saturation Temperature of 200C. | ||
} else { // Tkel >= 173.15 // Tkel >= TriplePointOfWaterTempKelvin // Tkel > 473.15 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So shouldn't this be the top end? 473.15 ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, it's only a comment issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for this comment, these are each true and true as a whole. |
||
Pascal = 1555073.745636215; | ||
} | ||
#else | ||
// Table 34 in IF97 | ||
Real64 constexpr N1(0.11670521452767e04); | ||
|
@@ -776,12 +788,12 @@ namespace Psychrometrics { | |
Real64 const B = N3 * phi2 + N4 * phi + N5; | ||
Real64 const C = N6 * phi2 + N7 * phi + N8; | ||
Pascal = 1000000.0 * pow_4((2.0 * C) / (-B + std::sqrt((B * B) - 4.0 * A * C))); | ||
#endif | ||
|
||
// If above 200C, set value of Pressure corresponding to Saturation Temperature of 200C. | ||
} else { // Tkel >= 173.15 // Tkel >= KelvinConv // Tkel > 473.15 | ||
Pascal = 1555000.0; | ||
Pascal = 1554671.8682698254; | ||
} | ||
|
||
#endif | ||
return Pascal; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New constant