-
Notifications
You must be signed in to change notification settings - Fork 394
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
Add the cubic spline interpolation option for PerformancePrecisionTradeoffs #8946
Conversation
src/EnergyPlus/Psychrometrics.hh
Outdated
@@ -129,7 +129,405 @@ namespace Psychrometrics { | |||
// 14 - HR | 15 - max iter | 16 - HR | 17 - max iter | 18 - | |||
// PsyTwbFnTdbWPb_raw (raw calc) | 19 - PsyPsatFnTemp_raw | |||
// (raw calc) | |||
|
|||
// sample bin size =64 Pa; sample size =1651 (continous) | |||
constexpr std::array<Real64, 1651> tsat_fn_pb_x = { |
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.
I don't think this array is necessary since the contents are just index * 64, right?
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.
Good point, the array is just 64x an integer so we can probably either populate it with a for loop or eliminate it.
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.
There is no point in populating it with a loop. If you are going to do that, you may as well leave it as is. Just replace the lookup with a multiplication.
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.
@amirroth @JasonGlazer Thanks a lot for your comments! I will update the code to eliminate the pressure input array and replace it with a multiplication.
src/EnergyPlus/PsychCacheData.hh
Outdated
@@ -100,7 +100,7 @@ constexpr Int64 psatcache_mask = psatcache_size - 1; | |||
#endif | |||
#ifdef EP_cache_PsyTsatFnPb | |||
constexpr int tsatcache_size = 1024 * 1024; | |||
constexpr int tsatprecision_bits = 24; | |||
constexpr int tsatprecision_bits = 20; |
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.
I think if convTol is set to 0.01C, this can go down to 16.
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.
I asked @LipingWang to look at this earlier and we found that while it increases speed slightly to go from 20 to 16, it also increases the differences in energy, so we decided to stick with 20. This was on a small set of buildings and we can evaluate that with a larger set of buildings to get a more accurate picture if you want.
Is this actually planned for 9.6 IO Freeze or is it just a sandbox to evaluate the approach? |
It is for the 9.6.0 IO freeze. |
I think this is ready for review and merge so I'm taking it out of draft state. At this point, only the MacOS CI tests have run but I expect that it just that the CI machines are backed up with jobs. I am putting myself down as a reviewer. |
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.
This looks generally fine. I will tweak the fortran file to fix the indentation, but otherwise the implementation is fine. The unit test seems ... odd. I'm not going to hold the PR for a different unit test at this point, but I would like a comment about it and most likely a modification to the unit test soon so we don't have a huge array just duplicated out in the unit test that becomes a maintenance problem if something changes.
16 & FALSE & CarrollMRT & MODE05 & 1 & 1 & TRUE & 60 & Normal & 0.30 & 0.002 & 47.31 \tabularnewline | ||
17 & FALSE & CarrollMRT & MODE06 & 1 & 1 & TRUE & 60 & Interpolate & 0.30 & 0.002 & 45.62 \tabularnewline | ||
18 & FALSE & CarrollMRT & MODE07 & 1 & 1 & TRUE & 60 & Interpolate & 1.00 & 0.002 & 45.23 \tabularnewline | ||
19 & FALSE & CarrollMRT & MODE08 & 1 & 1 & TRUE & 60 & Interpolate & 1.00 & 0.1 & 44.09 \tabularnewline |
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.
👍
Advanced& Allow direct input of convergence field values\tabularnewline | ||
|
||
\bottomrule | ||
\end{longtable} | ||
|
||
The increasing mode number roughly corresponds with increased speed. Mode01 to Mode05 are overriding inputs in other parts of the IDF/epJSON file and is equivalent to changing those input directly. Mode06 and Mode07 are changing convergence parameters previously not available to be modified by the user. | ||
The increasing mode number roughly corresponds with increased speed. Mode01 to Mode05 are overriding inputs in other parts of the IDF/epJSON file and is equivalent to changing those input directly. Mode06 offers an alternative method to calculate saturated temperature given pressure in replacement of the psychrometric function PsyTsatFnPb. Mode07 and Mode08 are changing convergence parameters previously not available to be modified by the user. |
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.
👍
@@ -483,6 +483,7 @@ PerformancePrecisionTradeoffs, | |||
\key Mode05 | |||
\key Mode06 | |||
\key Mode07 | |||
\key Mode08 |
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.
OK, so Mode06 was inserted, making a new 08 one. Transition rules to follow I see. 👍
-1.9E-09, -2.8E-09, -2E-10, -0.000000004, -2.5E-09, -1E-10, -4.6E-09, -3E-10, -2.5E-09, -3.8E-09, | ||
-3E-10, -2.6E-09, -2.3E-09, -2.1E-09, -2.2E-09, -2.1E-09, -2.4E-09, -2.1E-09, -2.2E-09, -0.000000002, | ||
-2.4E-09, -9E-10, -3.3E-09, -2.2E-09, -4E-10, -4.1E-09, -1.4E-09, -2.9E-09, 4E-10, -5.5E-09, | ||
2.7E-09}; // namespace Psychrometrics |
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.
OK
@@ -426,7 +426,16 @@ SUBROUTINE CreateNewIDFUsingRules(EndOfFile,DiffOnly,InLfn,AskForInput,InputFile | |||
! If your original object starts with R, insert the rules here | |||
|
|||
! If your original object starts with S, insert the rules here | |||
|
|||
CASE('PERFORMANCEPRECISIONTRADEOFFS') |
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.
Mixed tab/space here causing weird indent, I'll fix it since I need to resolve a tiny conflict anyway.
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.
@Myoldmopar thank you!
Summary: A new override option including cubic spline interpolations in replacement of original psychrometric function PsyTsatFnPb was added as Mode06 in this object. The previous options for the override mode of the object including Mode06 and Mode07 in version 9.5 were switched to Mode07 and Mode08 in version 9.6, respectively. | ||
|
||
Fields 1-2 remains the same. | ||
Fields 3 has been updated by adding a new override mode option. |
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.
Could be described a bit better in this line, but I guess the paragraph above basically says it.
100.6190344, 100.636391, 100.6537386, 100.6710809, 100.6884104, 100.7057304, 100.7230452, 100.7403472, 100.7576436, 100.7749305, | ||
100.7922053, 100.809475, 100.8267359, 100.8439874, 100.8612302, 100.8784641, 100.8956893, 100.9129053, 100.9301125, 100.947311, | ||
100.9645009, 100.9816821, 100.9988569, 101.0160203, 101.0331752, 101.0503248, 101.067462, 101.0845908, 101.101711, 101.1188265, | ||
101.1359293}; |
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.
Is this just the same array as inside the code? I'm not sure I understand what this unit test is doing then.
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.
@Myoldmopar I should have added more details for this unit test. Yes, this sample array tsat_fn_pb_tsat
is the same sample array for saturated temperature as inside the code tsat_fn_pb_y
. The purpose of this unit test is to test the correctness of the sample data array. The sample data were extracted from the original psychrometric function PsyTsatFnPb
every 64 Pa in the range of 64 Pa to 105,664 Pa. The sample data for saturated temperature from tsat_fn_pb_tsat
was compared to the results from the original psychrometric function PsyTsatFnPb
. So we can double-check the correctness of the sample data inside the code.
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.
@LipingWang the idea of the unit test is good but instead of repeating the array, we should be testing the array that is created in the header file and used by the interpolation function.
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.
@JasonGlazer @Myoldmopar sounds great!
Tested out the branch, everything built and tested just fine. Played with the transition rules and it transitions objects as expected, whether they don't have that field at all, have a field value that should stay the same, or have a field value that should be converted. This seems good to go in, but would like to follow-up with at least commentary about the unit test later. Thanks @LipingWang and thanks @JasonGlazer for the review. |
@@ -1439,6 +1444,26 @@ namespace Psychrometrics { | |||
|
|||
return Temp; | |||
} | |||
Real64 CSplineint(int const n, // sample data size | |||
const Real64 &x) // given value of x |
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.
There is no reason to pass scalars by const &
. If this is only an input, it should be passed by value. The only parameters that should be passed by reference are output parameters (passing by reference is the only) and objects (passing by value will trigger the copy constructor which 99% of the time you don't want to do).
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.
@amirroth Many thanks for your comments and the details! I will drop the const &
.
Pull request overview
A new override option was added as Mode06 for the field
Override Mode
of thePerformancePrecisionTradeoffs
object. Mode06 offers an alternative method to calculate saturated temperature given pressure in replacement of the psychrometric functionPsyTsatFnPb
. The previous options for theOverride Mode
of the object including Mode06 and Mode07 in version 9.5 were switched to Mode07 and Mode08 in version 9.6, respectively.Code Changes
Override Mode
of thePerformancePrecisionTradeoffs
object inSimulationManager.cc
;SimulationManager.cc
;CSplineint
) toPsychrometrics.cc
;PsyTsatFnPb
with the option to use cubic spline interpolation for calculating saturated temperature;Energy+.idd
;CreatNewIDFUsingRulesV9_6_0.f90
andRules9-5-0-to9-6-0.md
;InputOutputReference
;PsychTsatFnPb
.NOTE: ENHANCEMENTS MUST FOLLOW A SUBMISSION PROCESS INCLUDING A FEATURE PROPOSAL AND DESIGN DOCUMENT PRIOR TO SUBMITTING CODE
Pull Request Author
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
Reviewer
This will not be exhaustively relevant to every PR.