Skip to content
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

Merged
merged 19 commits into from
Feb 5, 2021
Merged

GHE Updates #8491

merged 19 commits into from
Feb 5, 2021

Conversation

mitchute
Copy link
Collaborator

@mitchute mitchute commented Jan 29, 2021

Pull request overview

  • Moves GHE data to state
  • Moves GHE SetupOutputVars to shared member method. Note that this causes rdd, mdd, and aud diffs. See here for the offending commit: 68ab73f
  • Moves GHE input processing to ctor's that accept JSON input. This is a potential prototype for future refactoring when moving away from the traditional input processing methods.
  • Cleans up local variables
  • Add some missing unit test support

Pull Request Author

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies

Reviewer

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

@mitchute mitchute added the Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring label Jan 29, 2021
@mitchute mitchute added this to the EnergyPlus 9.5.0 milestone Jan 29, 2021
@mitchute mitchute requested a review from Myoldmopar January 29, 2021 17:14
@mitchute mitchute self-assigned this Jan 29, 2021
this->verticalConfig = false;
}

this->coilDiameter = j["coil_diameter"];
Copy link
Contributor

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.

  1. What happens if the field name string is misspelled? Will it throw an error or simply return a zero or blank?
  2. 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.

Copy link
Collaborator Author

@mitchute mitchute Jan 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjwitte

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 and cNumericFieldNames 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.

Copy link
Member

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).

Copy link
Member

@Myoldmopar Myoldmopar left a 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"];
Copy link
Member

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).

Copy link
Member

@Myoldmopar Myoldmopar left a 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));
Copy link
Member

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) {
Copy link
Member

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"];
Copy link
Member

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)
Copy link
Member

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;
Copy link
Member

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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One less state, woohoo!

@Myoldmopar
Copy link
Member

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 !

@Myoldmopar Myoldmopar merged commit 883e5bc into NREL:develop Feb 5, 2021
@Myoldmopar Myoldmopar deleted the ghe_mods branch February 5, 2021 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants