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 Kiva foundation heat transfer calculations #5901

Merged
merged 46 commits into from
Feb 23, 2017
Merged

Add Kiva foundation heat transfer calculations #5901

merged 46 commits into from
Feb 23, 2017

Conversation

nealkruis
Copy link
Member

@nealkruis nealkruis commented Oct 5, 2016

Pull request overview

Integration of Kiva into EnergyPlus as described in this NFP.

Work completed for:

  • Task Order No. KAGN-4-42502-04 under Task Ordering Agreement No. KAGN-4-42502-00: "2016 EnergyPlus Foundation Heat Transfer Algorithm Evaluation and Model Development" and
  • Subcontract AEU-7-70112-01: “2017 EnergyPlus Foundation Heat Transfer Algorithm Model Development”

Work Checklist

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • At least one of the following appropriate labels must be added to this PR to be consumed into the changelog:
    • Defect: This pull request repairs a github defect issue. The github issue should be referenced in the PR description
    • Refactoring: This pull request includes code changes that don't change the functionality of the program, just perform refactoring
    • NewFeature: This pull request includes code to add a new feature to EnergyPlus
    • Performance: This pull request includes code changes that are directed at improving the runtime performance of EnergyPlus
    • DoNoPublish: This pull request includes changes that shouldn't be included in the changelog

Review Checklist

This will not be exhaustively relevant to every PR.

  • Code style (parentheses padding, variable names)
  • Functional code review (it has to work!)
  • CI status: all green or justified
  • Performance: CI Linux results include performance check -- verify this
  • Unit Test(s)
  • C++ checks:
    • Argument types
    • If any virtual classes, ensure virtual destructor included, other things
  • IDD changes:
    • Verify naming conventions and styles, memos and notes and defaults
    • Open windows IDF Editor with modified IDD to check for errors
    • If transition, add rules to spreadsheet
    • If transition, add transition source
    • If transition, update idfs
  • If new idf included, locally check the err file and other outputs
  • Documentation changes in place
  • Changed docs build successfully

@nealkruis nealkruis added the NewFeature Includes code to add a new feature to EnergyPlus label Oct 5, 2016
@nealkruis nealkruis added this to the EnergyPlus 8.7.0 milestone Oct 5, 2016
@nealkruis nealkruis self-assigned this Oct 5, 2016
Copy link
Contributor

@mbadams5 mbadams5 left a comment

Choose a reason for hiding this comment

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

@nealkruis This is my first pass at an (impromptu) review. I may have other comments later. You may want to check indention and coding style to make sure it follows EnergyPlus guidelines.

if (wallSurfaces.size() != 0) {
wallHeight = Surfaces(wallSurfaces[0]).Height; // TODO Kiva: each wall with different height gets its own instance.
for (auto& wl : wallSurfaces) {
if (Surfaces(wl).Height != wallHeight) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@nealkruis Why not put this conditional check in the same loop on line 218? That would eliminate searching all wall surfaces a second time.


// polygon
if (DataSurfaces::CCW) {
for (size_t i = 0; i < surface.Vertex.size_; ++i ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why use surface.Vertex.size_ instead of surface.Vertex.size()? The latter seems more standard with STL since i'd imagine the size member variable would normally be private.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do objexx arrays have a size method?


// TODO Kiva: Add wall surfaces to EIO
gio::write( DataGlobals::OutputFileInits, "(A)" ) << "! <Kiva Foundation Name>, Horizontal Cells, Vertical Cells, Total Cells, Floor Surface, Wall Surface(s)";
gio::write( DataGlobals::OutputFileInits, "(A,',',I5',',I5',',I5',',A)" ) << foundationInputs[DataSurfaces::Surface(kv.floorSurface).OSCPtr].name << grnd.nX << grnd.nZ << grnd.nX*grnd.nZ << DataSurfaces::Surface(kv.floorSurface).Name;
Copy link
Contributor

Choose a reason for hiding this comment

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

Misaligned indention.

if (DataEnvironment::Month == 1 && DataEnvironment::DayOfMonth == 2 && DataGlobals::HourOfDay == 2 && DataGlobals::TimeStep == 1) {
Kiva::SnapshotSettings ss;
ss.dir = DataStringGlobals::outDirPathName + "/snapshot";
double& l = ground.foundation.reductionLength2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why get the value by reference? You don't seem to be updating it anywhere. You do this in quite a few places...

Copy link
Member Author

Choose a reason for hiding this comment

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

Is there anything wrong with this? I'm using "l" as an alias so I don't have to type out "ground.foundation.reductionLength2" everywhere.

Kiva::Foundation defFnd;

defFnd.hasWall = true;
defFnd.hasWall = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

assigned twice, same for two below.

include_directories( SYSTEM "${CMAKE_BINARY_DIR}/third_party/kiva/vendor/mathgl-2.3.5.1/include/")
add_subdirectory("${CMAKE_SOURCE_DIR}/third_party/kiva/vendor/zlib-1.2.8/")
add_subdirectory("${CMAKE_SOURCE_DIR}/third_party/kiva/vendor/libpng-1.6.23/")
add_subdirectory("${CMAKE_SOURCE_DIR}/third_party/kiva/vendor/mathgl-2.3.5.1/")
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to make sure MathGL has a compatible license with EnergyPlus since it can be either GPL or LGPL. @jasondegraw

Copy link
Member Author

Choose a reason for hiding this comment

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

MathGL is used only for debugging purposes. It won't be in the final release.

@@ -1,8 +1,9 @@

INCLUDE_DIRECTORIES( "${CMAKE_SOURCE_DIR}/third_party/Expat/lib")
INCLUDE_DIRECTORIES( "${CMAKE_SOURCE_DIR}/third_party/")
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/third_party/zlib )
Copy link
Contributor

Choose a reason for hiding this comment

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

Why include this now? It seemed to be working before? I'm just curious.

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved it from the top CMakeLists.txt file. It is only used in the FMI/FMU stuff and conflicted with the zlib I'm using for the ground plot library.

int count = 0;
std::string WeatherDataLine;

while (! ReadStatus) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised this can't be part of the existing file read somewhere else. It seems like we might be reading the weather file twice now, correct? Is AnnualAverageDrybulbTemp the only useful statistic?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think there is a whole lot of information we can gather from one pass of the weather file instead of asking the users to input weather information. I'm starting with annual temperature, but this will likely expand to other purposes as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

There are other places that are currently reading the .stat file or requiring user input which all could get the info directly from a pre-read of the epw file (water mains temperature, adaptive comfort values, FCfactor ground temps, other ground models). So, this is something good to get in place in some way or another.

} else if ( SameString( cAlphaArgs( ArgPointer ), "OtherSideConditionsModel" ) ) {
Found = FindItemInList( SurfaceTmp( SurfNum ).ExtBoundCondName, OSCM, TotOSCM );
if ( Found == 0 ) {
ShowSevereError( cCurrentModuleObject + "=\"" + SurfaceTmp( SurfNum ).Name + "\", invalid " + cAlphaFieldNames( ArgPointer ) + "=\"" + cAlphaArgs( ArgPointer ) + "\"." );
ShowSevereError( cCurrentModuleObject + "=\"" + SurfaceTmp( SurfNum ).Name + "\", invalid " + cAlphaFieldNames( ArgPointer + 1 ) + "=\"" + cAlphaArgs( ArgPointer + 1 ) + "\"." );
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this a bug? Why the ArgPointer + 1?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was a small bug that I fixed while I was writing the similar line above.

defaultFoundation.foundation = defFnd;
defaultFoundation.name = "<Default Foundation>";

foundationInputs.push_back(defaultFoundation);
Copy link
Contributor

Choose a reason for hiding this comment

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

Where do you add other foundations other than default foundation? I can't seem to find any other spots, especially since you have a function to find a foundation by name.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is coming...

@EnergyArchmage
Copy link
Contributor

What is the status of the problem of warm up for design days, discussed in the NFP here?

https://gist.github.com/nealkruis/fde60b564425e1b10a5d3a8ec179df51#warm-up-and-design-days

Most EnergyPlus models in practice are autosizing the HVAC system based on building loads. If a ground model cannot be used for design days it will not be of much practical use. I hope this can be addressed somehow.

@nealkruis
Copy link
Member Author

@EnergyArchmage The current plan is to use a steady-state initialization for design days. It is a conservative estimate of load through foundations since the actual peak load will likely be damped and lagged relative to the design day.

@EnergyArchmage
Copy link
Contributor

@nealkruis So does that mean a long soak at design day conditions or a multi-year steady periodic description for a year?

Current sizing design practice, using the "Ground" boundary condition with Site:GroundTemperature:BuildingSurface filled by slab.exe, essentially uses a year descripton of the ground condition, as it would develop over many years. The date of the design day indicates when within the year the load calculations are being done at and it just uses the ground boundary condition for that date, well the month anyway.

So I think the precendent is to do sizing with annual-type ground conditions and I fear doing something very different is risky without some study of the implications on sizing results.

@nealkruis
Copy link
Member Author

I would prefer to build up a better thermal history. Kiva has an effective method to do so, but there are a couple of EnergyPlus limitations we'd have to get around:

  • Much of the thermal history of the ground will be erased by the repeating warmup day anyway (we can possibly override the ground temperatures after warmup?)
  • Warmup of the ground independent of the building simulation would require a separate read of the weather file. I've already made some changes to enable this. However, there are still cases where a building is simulated with only design days and no weather file is defined.
  • Warmup of the ground requires an assumption of the adjacent zone temperature, which may not be controlled--i.e. setpoints aren't always reliable assumptions.

@nrel-bot-3
Copy link

@nealkruis @lgentile it has been 14 days since this pull request was last updated.

@mjwitte
Copy link
Contributor

mjwitte commented Feb 16, 2017

Whoa, and over 5000 new files. I thought based on the NFP that we would be linking in a Kiva library "The computational core of Kiva can be compiled as an independent library and linked to the EnergyPlus executable." So, where's all the baggage from?

@nealkruis
Copy link
Member Author

@Myoldmopar I've been looking into ground init stuff today and making some progress. I don't think I'll have something figured out in time for interface freeze, so if anything changes it'll be behind the scenes. I'll try to address the formatting and remaining @mbadams5 comments today or tomorrow.

@mjwitte word from above was to vendor Kiva instead of an using an external clone, hence the additional files (most of them are third(fourth?)-party boost geometry header files). I'd love to replace boost geometry with something slimmer, but that option was ruled out in discussions. We can chat privately if you'd like more details.

@mjwitte
Copy link
Contributor

mjwitte commented Feb 16, 2017

@nealkruis OK. That's all I need to know. I'll yield to @Myoldmopar and @jasondegraw on that front. BTW, this branch has some small conflicts.

Copy link
Contributor

@mjwitte mjwitte left a comment

Choose a reason for hiding this comment

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

@nealkruis Just a few comments/question mainly on the IDD.

@@ -16057,6 +16064,372 @@ SurfaceProperty:OtherSideConditionsModel,
\note in contact with GroundDomain objects
\default GapConvectionRadiation

Foundation:Kiva,
\memo Refined definition of the foundation surface construction used to
\memo infrom two-diemensional heat transfer calculated using the Kiva
Copy link
Contributor

Choose a reason for hiding this comment

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

Typos here

\note Extent of insulation as measured from the wall interior
\units m
\type real
\minimum> 0.0
Copy link
Contributor

Choose a reason for hiding this comment

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

This cannot be zero? Same question for N3, N6, and N9.

Copy link
Member Author

Choose a reason for hiding this comment

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

If a material is assigned, a zero value would imply no insulation. If a material is not assigned, a zero value is implicit. Do you think allowing zero would be better? I already have an error if a value (including zero) is defined here and no material is defined.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a fine point. If someone wants to run some parametrics, the way it currently is, you'd have to change both fields in order to add or remove the insulation. Instead of having the material name there and simply running this value from zero to whatever. When you say error here, do you mean a warning or fatals out? Again, it's a fine point.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it fatals out...though of course a value of zero won't even get past the input processor.

I don't have a strong opinion on this. I see you point, but there are also many places in the program where you can't use a value of zero (e.g., material thickness) and requires much more than changing two fields.

I can probably change this in about 20 min. So let me know if you think it's worthwhile.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nah, just let it ride. If it causes frustrations, then we'll hear about it later.

Copy link
Contributor

@mjwitte mjwitte Feb 17, 2017

Choose a reason for hiding this comment

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

Oh, but you should make it clear here with a \note, that if the material name is blank, then this field must also be blank. And in the I/O Ref if it's not there already. Same for similar fields.

Copy link
Member Author

@nealkruis nealkruis Feb 17, 2017

Choose a reason for hiding this comment

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

I misspoke (mistyped?). It gives only a warning if you provide values without specifying a material.


Foundation:Kiva:Settings,
\memo Settings applied across all Kiva foundation calculations.
\memo Object is not required. If not defined, defaults will applied.
Copy link
Contributor

Choose a reason for hiding this comment

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

. . . defaults will be applied.

\key ZeroFlux
\key GroundWater
\key Autocalculate
\default Autocalculate
Copy link
Contributor

Choose a reason for hiding this comment

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

lower case on Autocalculate. (EnergyPlus doesn't care, but other IDD validators do.)

Copy link
Member Author

Choose a reason for hiding this comment

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

The key, the default, or both?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh - this is a key choice "Autocalculate", not an autocalculatable field. This would be the only place in the entire IDD with "\key Autocalculate". I guess there's no rule against using it, but "autocalculate" does have special meaning in numeric fields. Is there a different word that would convey the same intent?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just "Auto"?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, or "Autoselect"? It's really not calculating a value here, it's just making a choice between the two models if I'm following the docs correctly.

SetupOutputVariable( "Surface Heat Storage Loss Rate [W]", OpaqSurfStorageCondLossRep( loop ), "Zone", "State", Surface( loop ).Name );
SetupOutputVariable( "Surface Heat Storage Rate per Area [W/m2]", OpaqSurfStorageConductionFlux( loop ), "Zone", "State", Surface( loop ).Name );
SetupOutputVariable( "Surface Heat Storage Energy [J]", OpaqSurfStorageConductionEnergy( loop ), "Zone", "Sum", Surface( loop ).Name );
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remind me (briefly) how the Kiva model connects to the surface and why these output can't be calculated?

Copy link
Member Author

Choose a reason for hiding this comment

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

Kiva simulates both the floor and the walls in the same two-dimensional model and they can exchange heat with deep ground, or the exterior grade. Heat stored in the ground can be come from any boundary. There are no set of "inside face" and "outside face" connected with the ground that can be used to calculate the storage for a specific surface.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, got it, I fogot the surfaces are included in the Kiva domain. But the usual Inside Face outputs (temperature and flux) will still be available and calculated appropriately?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. These are demonstrated in the example files.

@mjwitte
Copy link
Contributor

mjwitte commented Feb 20, 2017

@nealkruis FYI - I merged in latest develop to get a clean set of CI tests, and resolved minor conflict in yaml file. Put the --suppress="*:*eigen*" at the end of the line after the new re2 flag.

@mjwitte
Copy link
Contributor

mjwitte commented Feb 20, 2017

@nealkruis This is showing -8% performance improvement. What's changing that would impact runs that don't use the kiva model?

@nealkruis
Copy link
Member Author

@mjwitte It's likely the SetWeatherStatistics() call that reads the weather file to set AverageAnnualDrybulbTemp. I can probably pull this into the Kiva manager to avoid the extra read for every simulation. I'll need to do it again for initialization anyway. We might want to consider reading the whole weather file once into memory to improve capability without increasing I/O time.

@mjwitte
Copy link
Contributor

mjwitte commented Feb 20, 2017

@nealkruis Let's move it for now and then after this release, we can consider an initial read into memory for runs that use the weather file.

@Myoldmopar
Copy link
Member

Appears there are still lots of CI problems on this branch.

Note we are five days past feature freeze.

@nealkruis
Copy link
Member Author

nealkruis commented Feb 22, 2017

@Myoldmopar I think the CI problems on Linux are the same we were seeing earlier--something screwy with the Linux machine. I'll double check locally, but I don't think it is a problem with the branch.

@mbadams5
Copy link
Contributor

@nealkruis It is a problem with kiva...

Linking CXX shared library ../../Products/libenergyplusapi.so
/usr/bin/ld: ../../Products/libkiva.a(Foundation.cpp.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
../../Products/libkiva.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [Products/libenergyplusapi.so.8.7.0] Error 1
make[1]: *** [src/EnergyPlus/CMakeFiles/energyplusapi.dir/all] Error 2
make: *** [all] Error 2

This is the same issue I had with re2 before, basically you need to compile on linux with -fPIC

@nealkruis
Copy link
Member Author

Yep, just seeing this now. Thanks @mbadams5

@mjwitte
Copy link
Contributor

mjwitte commented Feb 22, 2017

@nealkruis Going to wait for CI to catch up to the latest commit on develop. If that's clean, then will re-merge develop here and wait for CI again.

@Myoldmopar
Copy link
Member

Not sure it's worth another pass here. The warnings and failures are from other known issues. This should be good as far as i can tell from my mobile here.

@mjwitte
Copy link
Contributor

mjwitte commented Feb 23, 2017

@Myoldmopar That's your call. Develop is looking clean now, so I was going to merge develop in here shortly and let it run overnight.

@mjwitte
Copy link
Contributor

mjwitte commented Feb 23, 2017

@Myoldmopar There's a problem in the IDD. I'll fix it here.

@mjwitte mjwitte merged commit ae053ca into develop Feb 23, 2017
@nmerket
Copy link
Member

nmerket commented Feb 23, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IDDChange Code changes impact the IDD file (cannot be merged after IO freeze) NewFeature Includes code to add a new feature to EnergyPlus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants