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

Add Vertical (1-D) Solution to Earth Tube Object #10138

Merged
merged 23 commits into from
Aug 15, 2023

Conversation

RKStrand
Copy link
Contributor

@RKStrand RKStrand commented Aug 7, 2023

Pull request overview

  • Fixes Enhance ZoneEarthtube object capabilities #6627 (first phase--vertical solution)
  • This pull request contains the code, unit tests, IDD changes, new test file, and documentation for the earth tube enhancement that implements a 1-D solution simulating the vertical temperature variation resulting from the presence of an earth tube. The implementation follows as closely as possible the NFP/design document that went through a thorough review spanning several technicalities calls. Evidence that the solution is correctly integrated and producing expected results will be attached to this pull request. Also, a "virtual walkthrough" explaining the code changes will also be attached.

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.

  • 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

Initial submission of the new feature proposal for the 1-D (vertical) earth tube enhancement to EnergyPlus.
Changes were made to the NFP to include the comments made during the 5/3/23 technicalities meeting regarding the assumptions made about the earth tube node and contacting an expert on earth tubes from outside the development team.
Changes made to the NFP based on comments/conversation that took place over Slack on 5/11/23.
Modifications as a result of last technicalities call.
First drafts of the documentation in both the IO Ref and Eng Ref.  Change of a variable name to better reflect what it actually is.  Additions to the IDD.
this doesn't work, but i need to merge in other things
First successful build!
Correction of minor issue
Fixed an issue with a blank solution type.  It should now interpret the input when solution type is blank correctly (default back to Basic).  There should be no diffs in the ci results (hopefully).
Various minor issues fixed.  This now runs but the results are not correct for the vertical solution.
Working code with results that look like one would expect.  More testing and then unit tests and docs final edits to come.
Addition of two unit tests and a new regression test.  Minor documentation additions and tweaks.
@RKStrand RKStrand added the NewFeature Includes code to add a new feature to EnergyPlus label Aug 7, 2023
@RKStrand RKStrand added this to the EnergyPlus 23.2 IOFreeze milestone Aug 7, 2023
@RKStrand RKStrand self-assigned this Aug 7, 2023
@RKStrand
Copy link
Contributor Author

RKStrand commented Aug 7, 2023

Supporting graphs:
EarthTubeSupportingGraphs.pdf

@RKStrand
Copy link
Contributor Author

RKStrand commented Aug 7, 2023

"Virtual" Walkthrough Notes:
Earth Tube Enhancement.pdf

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.

This is really great, and looks to be in good shape. I had a few comments, so I'll hold from marking it approve/reject right now. Let me know what you think about my comments.

@@ -89,3 +89,4 @@ dist
# if you generate sphinx docs, it builds a dummy version of the schema in the idd folder, just ignore it
/idd/Energy+.schema.epJSON
/idd/Energy+.schema.epJSON.in
design/FY2023/earth_tube_solution_space_diagram.pdf
Copy link
Member

Choose a reason for hiding this comment

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

Why would this file be ignored? I don't anticipate it changing, so it shouldn't matter much, but I think it should be included.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. I had to go back and look up what was going on here. It's essentially a duplicate file. I created the diagram in MS Powerpoint, saved it as a PDF, then opened in Preview and saved it as a .png to match the file type of other documents. Since it was a duplicate and just a transition file, I didn't think it was worth cluttering the GitHub space. It's essentially the same as the file of the same name with a .png extension. You still want this? I'm ok either way.

@@ -1884,6 +1931,22 @@ \subsubsection{Outputs}\label{zoneearthtube-outputs}

This is the humidity ratio of the air entering the zone after passing through the earth tube {[}kgWater/kgDryAir{]}.

\paragraph{Earth Tube Node Temperature <X> {[}C{]}}\label{earth-tube-node-temperatures-c}

This will generate the internal node temperatures {[}C{]} for the earth tube as a result of the 1-D finite difference model. This is only valid for the 1-D (Vertical) model.
Copy link
Member

Choose a reason for hiding this comment

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

This will report the internal node temperatures...

Right? I don't think this will trigger the generation of anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, correct--it just triggers the reporting. These always get calculated. And before I forget, thanks for reviewing this!


This will report the theoretical undisturbed ground temperature at the upper boundary for the 1-D finite difference model. This is only valid for the 1-D (Vertical) model.

\paragraph{Earth Tube Lower Boundary Ground Temperature {[}C{]}}\label{earth-tube-upper-boundary-temperature-c}
Copy link
Member

Choose a reason for hiding this comment

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

GitHub's doc build is complaining about the multiply defined label here. Need the relabel as -lower-boundary ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, rats. Copied and pasted and then forgot to update that part of the statement. I'll fix that (hopefully first thing tomorrow).

\note "D" in Equation
\type real
\default 0
A5, \field Earth Tube Model Type
Copy link
Member

Choose a reason for hiding this comment

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

Yay for no transition! Right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, correct. Intentionally done that way. The old model is still the default (notice that the existing earth tube idf in the test suite did not get changed and it runs with no diffs).

\object-list EarthTubeParameterNames

ZoneEarthtube:Parameters,
\memo Parameters that apply to the vertical model for an earth tube
Copy link
Member

Choose a reason for hiding this comment

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

Should we do a min-fields here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I guess that technically everything has a default so if the user just gave a name and ignored the rest it would just take all the defaults? I wasn't sure so I just left that out. I can put it in if you feel like this is important.

@@ -543,6 +631,188 @@ void CheckEarthTubesInZones(EnergyPlusData &state,
}
}

void initEarthTubeVertical(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.

It would be really great if this function did not loop over all the earth tubes. If this could just be a one-time init flag on each earth tube, it would be preferable. I actually don't think it's too much of an effort to change, but I'm open to discussion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That could be done. The loop over all earth tubes could happen one level up with the continue for a non-vertical model one happening at that point. It would eliminate the need for the multiple "continues" in every loop and would probably eliminate the need for loops in the initEarthTubeVertical subroutine. I'll take a look at this when I make other changes requested above.

Copy link
Member

Choose a reason for hiding this comment

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

Honestly, if it's working, I would just leave it alone. We have a new way to call each plant object "one time". This is nice because then the components can avoid having to constantly check "if one time ... if one time". As such, plant components definitely shouldn't be looping over each plant instance to do one time inits. I am a little foggy it seems, and I wanted to apply that same plant logic here to the earth tubes. But it's not necessary. Just leave this, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. It is working so I'm also happy to leave it alone.

thisEarthTube.tUndist[nodeNum] = thisEarthTube.calcUndisturbedGroundTemperature(state, thisEarthTube.depthNode[nodeNum]);
}
}
} // ...end of BeginDayFlag block
Copy link
Member

Choose a reason for hiding this comment

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

Will this get hit multiple times while BeginDayFlag is true? Do you need a second flag like "MyBeginDayFlag" so that it only happens once per day?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll double check. I was trying to avoid a duplicate calculation but I may have missed something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this was a problem. I took a page out of the ElectricPowerServiceManager.cc and decided to use "timeElapsed" to avoid duplicate initializations and improper updates. Will be testing this out here shortly.

{
// Calculate c' for when effectiveness is zero. Will use these values when there is no air flow through the earth tube
// and also use the values in the top portion of the solution (before the earth tube node) since these will not change.
this->cPrime0[0] = this->cCoeff0[0] / this->bCoeff[0];
Copy link
Member

Choose a reason for hiding this comment

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

Nice little member method!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! 😀

Comment on lines 861 to 865
bool tempShutDown = false;
// Don't simulate for Basic Solution if the zone is below the minimum temperature limit
if (thisZoneHB.MAT < thisEarthTube.MinTemperature) tempShutDown = true;
// Don't simulate for Basic Solution if the zone is above the maximum temperature limit
if (thisZoneHB.MAT > thisEarthTube.MaxTemperature) tempShutDown = true;
Copy link
Member

Choose a reason for hiding this comment

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

Can this section just be:

bool tempShutDown = thisZoneHB.MAT > earthTube.MaxTemperature || thisZoneHB.MAT < earthTube.MinTemperature;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oooo, I guess I hadn't thought about such an assignment being possible and was trying to maintain as much similarity to the old code. But this looks slick (or as the kids say these days "sick"), so I'll implement this also. This "old dog" (me) needs to learn a few new tricks...

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, in Python it could just use an interval comparison 😱

tempShutDown = not (earthTube.MinTemperature < thisZoneHB.MAT < earthTube.MaxTemperature)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had such grand hopes last school year. My now 16 yo was still doing homeschooling and so we were working through a Python intro course together. Unfortunately I had too much to do to keep up with him. Anyway, that sounds cool!

@@ -85,7 +93,7 @@ namespace EarthTube {
Real64 FanPressure = 0.0;
Real64 FanEfficiency = 0.0;
Real64 FanPower = 0.0;
Real64 GroundTempz1z2t = 0.0; // ground temp between z1 and z2 at time t
Real64 GroundTempt = 0.0; // ground temp at the depth of the earth tube midpoint at time t
Copy link
Member

Choose a reason for hiding this comment

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

Lead us not to GroundTempt-ation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤣🤣🤣...great comment! Yeah, I noticed the "tempt" part and chucked before just deciding that it was at least consistent with what the old name was. Well, maybe it should have been GroundTempzt then...but since it was a single temperature and I wanted that to be very clear.

Modifications to address review comments.
@RKStrand
Copy link
Contributor Author

RKStrand commented Aug 8, 2023

@Myoldmopar Just pushed code mods that will hopefully address the comments you had. Should come back all green unless I missed something. And if I missed a comment, let me know. Thanks!

Used the wrong term to size vectors.  Should fix the issues with Linux debug errors.
Found a problem with one of the loops in the vertical algorithm, resulted from bad job moving stuff around.  Xcode was very forgiving, Ubuntu not so much.  This should make them both happy.
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.

Thanks for addressing my comments! I'll do a quick build/test now but I assume this will merge shortly.

@Myoldmopar
Copy link
Member

All good here locally, merging this one in. Thanks for this enhancement @RKStrand !

@Myoldmopar Myoldmopar merged commit 2a89af7 into develop Aug 15, 2023
10 checks passed
@Myoldmopar Myoldmopar deleted the 5114327-EarthTube1DVerticalEnhancement branch August 15, 2023 20:20
Comment on lines +24561 to +24574
N3, \field Earth Tube Dimensionless Boundary Above
\note When set to 1.0, the upper boundary is one earth tube radius below ground.
\type real
\units dimensionless
\minimum 0.25
\maximum 1.0
\default 1.0
N4, \field Earth Tube Dimensionless Boundary Above
\note When set to 1.0, the upper boundary is one earth tube radius below ground.
\type real
\units dimensionless
\minimum 0.25
\maximum 1.0
\default 0.25
Copy link
Contributor

Choose a reason for hiding this comment

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

N4 is below. Note should be updated too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are correct--N4 should say below. Sorry!

@Myoldmopar Any chance we can slide in a typo correction to the field name in the IDD or is that not allowed. Sorry about the bad cut/paste/non-edit.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is an outdated document compared to the Design-Document one no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the design document is more up-to-date.

jmarrec added a commit that referenced this pull request Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NewFeature Includes code to add a new feature to EnergyPlus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance ZoneEarthtube object capabilities
9 participants