-
Notifications
You must be signed in to change notification settings - Fork 393
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
GHE Updates #8491
GHE Updates #8491
Conversation
…GLHEVertProps constructor to a JSON constructor
this->verticalConfig = false; | ||
} | ||
|
||
this->coilDiameter = j["coil_diameter"]; |
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.
@mitchute This is an interesting direction to move in.
- What happens if the field name string is misspelled? Will it throw an error or simply return a zero or blank?
- What happens if the field isn't present in the incoming object? Will it be present in the object data with it's default if it has one?
I still feel that we need an input fetching utility to manage this as suggested in Add helper functions to validate and get an epJSON object and field value #7632 .
Or maybe fields with defaults are already populated in the JSON data structure when the input is read in? I've never been sure about that.
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.
Re 1. I just tested this by misspelling one field, depth_of_top_of_borehole
. The following is the error message thrown.
** Severe ** [json.exception.type_error.302] type must be number, but is number
Not super helpful, but one would hope that these sort of errors never make it past the developer/reviewer since the model likely would never run. We should give this a little more thought.
Re 2. We handle fields that could be missing and which do NOT have default values like the following:
if (j.find("ghe_vertical_responsefactors_object_name") != j.end())
In this case, the field will not be present if it's not present in the input. I'd assume that fields with default values will have the default filled in automatically, but I have not tested that.
FFR, some issues I had with this transition are listed here:
- The string fields come in as-is from the input. I found myself needing to upper case everything before comparing strings, whereas before I think some of this was done automatically. We'll need a way to keep some fields case sensitive, such as paths. However, the majority of strings don't need that, so when we go to scale this up we'll need to decide how to best handle it.
- Currently, we have
cAlphaFieldNames
andcNumericFieldNames
which allows us to programmatically get the field names. I didn't figure out a way to get these using JSON, but it probably exists. Either way, the names are likely to come in as the JSON key names. We may want a way to provide the user with the IDF-like field names? I.e. "inlet_node_name" vs. "Inlet Node Name".
This was my first real attempt at using the JSON inputs, so perhaps these issues were just due to my inexperience.
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 am really excited about this pattern. And one of my favorite reasons is that unit testing the input processing and catching casing/other issues will be easy. Just call the constructor will different JSON objects and verify the created object matches the expectation. No need to do any other setup (unless the constructor is accessing something that needs to be set up).
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 really like this. Having the input processor routine rewritten as an object constructor that accepts JSON input is something we've wanted for quite some time. We can critique this moving forward and optimize it as we improve more and more components.
this->verticalConfig = false; | ||
} | ||
|
||
this->coilDiameter = j["coil_diameter"]; |
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 am really excited about this pattern. And one of my favorite reasons is that unit testing the input processing and catching casing/other issues will be easy. Just call the constructor will different JSON objects and verify the created object matches the expectation. No need to do any other setup (unless the constructor is accessing something that needs to be set up).
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.
All good here! Let me make sure the branch is up to date with develop and if not I'll just build it locally anyway prior to merging. Thanks @mitchute
sqrtDistDepth = std::sqrt(pow_2(distance1) + 4 * pow_2(coilDepth)); | ||
errFunc1 = std::erfc(0.5 * distance1 / sqrtAlphaT); | ||
errFunc2 = std::erfc(0.5 * sqrtDistDepth / sqrtAlphaT); | ||
Real64 sqrtDistDepth = std::sqrt(pow_2(distance1) + 4 * pow_2(this->coilDepth)); |
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.
Localized variables, great.
// if the ring(n1, m1) is the near-field ring of the ring(n,m) | ||
if (disRing <= 2.5 + coilDiameter) { | ||
if (disRing <= 2.5 + this->coilDiameter) { |
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.
Member variables, awesome.
this->pipe.cp = j["pipe_specific_heat"]; | ||
this->pipe.outDia = j["pipe_outer_diameter"]; | ||
this->pipe.outRadius = this->pipe.outDia / 2.0; | ||
this->pipe.thickness = j["pipe_thickness"]; |
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.
Once again, really excited about this.
} | ||
} | ||
} | ||
|
||
//****************************************************************************** | ||
|
||
void GLHEBase::setupOutput(EnergyPlusData &state) |
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.
Reorganization, causing rdd diffs. OK.
|
||
void calcShortTimestepGFunctions(EnergyPlusData &state); | ||
|
||
void calcLongTimestepGFunctions(EnergyPlusData &state); | ||
|
||
void calcGFunctions(EnergyPlusData &state); | ||
void calcGFunctions(EnergyPlusData &state) override; |
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.
Proper override specification. Good.
@@ -183,7 +182,6 @@ void EnergyPlus::clearAllStates(EnergyPlusData &state) | |||
Furnaces::clear_state(); | |||
General::clear_state(); | |||
GeneralRoutines_clear_state(); // GeneralRoutines does not have a namespace | |||
GroundHeatExchangers::clear_state(); |
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.
One less state, woohoo!
Branch is 36 commits ahead of develop so the latest CI results are still good. Windows failures are unrelated, and otherwise everything seems happy. Good to go, thanks @mitchute ! |
Pull request overview
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.