Automatic Import of Shading from a CSV File#6388
Conversation
|
@XuanLuoLBL @hongtz68
|
For diffused solar gain: Wondering if that's right. |
|
@XuanLuoLBL. Yes, that is the right section for diffuse solar shading (though a more up-to-date version is here). In order to cache shading for a surface, you'll need:
There's also an additional question about whether you'll need to handle exterior reflections (though I'd suggest continue performing those calculations internally). For the large models where caching would be really beneficial, you'll potentially need to cache on the order of 52 million double precision values (1,000 exterior surfaces x 144 diffuse shading fractions + 1,000 surfaces x ~50,000 timestep solar fractions). I would like to have a better sense of the storage and IO read performance implications of different file storage formats (namely CSV vs. binary) for this magnitude of data. |
|
@nealkruis For those huge cases, where you are talking on the order of 50 million values to be stored, the storage doesn't bother me too much. Users should understand that when they do big models, they will need storage. I guess we could try to warn them by estimating the size of the cached file and checking available file system capacity... Processing that file makes me cringe a little, but not to the point of requiring a binary format. By using the cached shading values, the user should experience a major improvement in runtime compared to recalculation. Any additional gains from a switch to binary during reading should pale in comparison to the overall gain. And I really don't want EnergyPlus to have to manage our own binary files when it's not a necessary step. My main concern is when you mentioned standardizing. @XuanLuoLBL, yeah E+ does currently read schedules from CSV. But we are trying to move forward in the world, with the impending JSON input format, and now the JSON-based G-Function caching for ground heat exchangers. My strong preference here would be to create a nicely structured JSON format for these values, such that we don't have to rely on a predetermined column order in a huge csv file during export/import. I do understand that raw JSON will carry some additional burden over CSV, but as long as we are smart with the JSON structure, the read time penalty should still be small compared to the overall massive gains of this project. |
|
@XuanLuoLBL @lgentile it has been 14 days since this pull request was last updated. |
|
@XuanLuoLBL @lgentile it has been 16 days since this pull request was last updated. |
|
@XuanLuoLBL @lgentile it has been 17 days since this pull request was last updated. |
Myoldmopar
left a comment
There was a problem hiding this comment.
@XuanLuoLBL This is pretty close, but I made a few comments that should be addressed. The main one is the JSON comments. I was hoping the code would be set up so that we could easily add JSON to this at a later date. It is added to the IDD and docs in this pull request, appearing to indicate it is already available and implemented, which I don't think it is. We should remove it from those user-facing interfaces until we actually have JSON available. If you can clean that up and address my other comments, this should be good to go in. Testing now...
idd/Energy+.idd.in
Outdated
| A2 ; \field File Format | ||
| \type choice | ||
| \key CSV | ||
| \key JSON |
There was a problem hiding this comment.
Wait, what? Can this do JSON?? If this is just a placeholder option for later that isn't implemented, then it needs to go away.
There was a problem hiding this comment.
Yes. It's a placeholder as we discussed for the NFP. I can remove it.
There was a problem hiding this comment.
During the NFP stage, I wanted the code to be written so that later it would be easy to add JSON. We can't have things in the IDD that the user sees that aren't true. Sorry for the confusion.
idd/Energy+.idd.in
Outdated
|
|
||
| Schedule:File:Shading, | ||
| \min-fields 1 | ||
| \memo A Schedule:File:Shading points to a text computer file that has |
There was a problem hiding this comment.
Probably want to reword this, don't need to say "computer file". And instead of text file, how about CSV file?
There was a problem hiding this comment.
That is word for Schedule:File object and confused me as well... Modified.
idd/Energy+.idd.in
Outdated
| Schedule:File:Shading, | ||
| \min-fields 1 | ||
| \memo A Schedule:File:Shading points to a text computer file that has | ||
| \memo hourly/sub-hourly sunlit fraction data for all exterior surfaces. |
There was a problem hiding this comment.
It's not really for "all" exterior surfaces though, right? In the design/documentation it says that if surfaces are missing, they are simply not shaded.
There was a problem hiding this comment.
@XuanLuoLBL If sub-hourly data are allowed, do you force fixed time interval step or allow flexible time interval. Please specify it clearly.
There was a problem hiding this comment.
@lgu1234 Sorry not sub-hourly... Not necessary for sunlit fraction. Modified the text.
| ShowContinueError( "Try again with putting full path and file name in the field." ); | ||
| ErrorsFound = true; | ||
| } else { | ||
| SchdFile = GetNewUnitNumber(); |
There was a problem hiding this comment.
I know this is how it's done in other places of the code, but I wish I would've seen this earlier and directed to not use this approach. This file reading approach is simply a carryover from the Fortran days, and using C++ file streams would've been a nice thing to do instead. But it's a bit late now and not worth holding this up.
There was a problem hiding this comment.
Okay. I wish I could see this earlier. I thought I should use familiar code to keep the same pattern, as we do everything else.
There was a problem hiding this comment.
@XuanLuoLBL @Myoldmopar See #6482 followup issue to revise this.
| } | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Yeah I didn't see in there where you actually added JSON. What I had requested previously was for the code to be set up so that once we added JSON, it would be very easy to modify this code to also read JSON inputs. But as the JSON world isn't in here yet, we need to remove the option from the IDD and docs. (Unless I somehow missed the JSON reading in here and it actually does work...)
There was a problem hiding this comment.
No. Not ready. My misunderstanding. But yes here it is for when we can actually add JSON in the future.
src/EnergyPlus/ScheduleManager.hh
Outdated
|
|
||
| // C++ Headers | ||
| #include <map> | ||
|
|
There was a problem hiding this comment.
Was there a reason you needed to include this here? I don't see any of your changes needing it. If you need it in the .cc file, go ahead and put it over there, not in the .hh file.
src/EnergyPlus/ScheduleManager.cc
Outdated
| using DataSystemVariables::iUnicode_end; | ||
| using DataSystemVariables::TempFullFileName; | ||
| using DataSystemVariables::CheckForActualFileName; | ||
| using DataSystemVariables::UseImportedSunlitFrac; |
There was a problem hiding this comment.
This isn't being used in this function and is throwing the build warning. That will clean up CI some.
|
Regarding CI:
Also, I built locally, and just ran the ExternalShading example file, and my eplusshading.csv is empty. Is that normal? |
idd/Energy+.idd.in
Outdated
| Schedule:File:Shading, | ||
| \min-fields 1 | ||
| \memo A Schedule:File:Shading points to a text computer file that has | ||
| \memo hourly/sub-hourly sunlit fraction data for all exterior surfaces. |
There was a problem hiding this comment.
@XuanLuoLBL If sub-hourly data are allowed, do you force fixed time interval step or allow flexible time interval. Please specify it clearly.
| // create string of which day of year | ||
| ++iDay; | ||
| ++hDay; | ||
| if ( iDay > 366 ) break; |
There was a problem hiding this comment.
@XuanLuoLBL Do you allow data with 6 month? For example, the run period is from Jan. 1 to Jun 60. Can I have a data file with hourly values in 6 months?
There was a problem hiding this comment.
No... Not specified here. I added in the doc it has to be 8760-8764.
|
@XuanLuoLBL @lgu1234 and myself made a number of requested changes to this branch 3 days ago. You have not responded to any of them. Considering we are so late, this is in danger of not making the cutoff unless you address them right away. |
|
@Myoldmopar I'm not very familiar with the this CI CMake. Would you mind using some more specific word for "bring in that external file dependency". I don't see any chunk does similar things. |
|
The example file for this PR is _ImportShading. Not ExternalShading. |
…ExtShading Conflicts: src/EnergyPlus/DataSystemVariables.cc src/EnergyPlus/DataSystemVariables.hh src/EnergyPlus/SolarShading.cc testfiles/CMakeLists.txt
mjwitte
left a comment
There was a problem hiding this comment.
This should be ready to merge if CI comes back clean.
| ShowContinueError( "Try again with putting full path and file name in the field." ); | ||
| ErrorsFound = true; | ||
| } else { | ||
| SchdFile = GetNewUnitNumber(); |
There was a problem hiding this comment.
@XuanLuoLBL @Myoldmopar See #6482 followup issue to revise this.
src/EnergyPlus/ScheduleManager.cc
Outdated
| ErrorsFound = true; | ||
| } else { | ||
| SchdFile = GetNewUnitNumber(); | ||
| { IOFlags flags; flags.ACTION( "read" ); gio::open( SchdFile, ShadingSunlitFracFileName, flags ); read_stat = flags.ios(); } |
There was a problem hiding this comment.
@XuanLuoLBL This needs to use TempFullFileName here because the file could be in a number of different places. I'll fix this.
|
This needs a clear_state (well, the other shading thing need it, but adding it here). Will push shortly. Then this should be ready to drop in. |
|
👍 Thanks @mjwitte |
|
And develop just moved with the other PRs. I considered saying just push your changes and we'll merge it but I think since |
|
Thanks so much! @mjwitte |
|
@XuanLuoLBL If you can, please review the file diffs on this PR. I had to resolve some merge conflicts after the other shading feature dropped in. It would be good if you can make sure I didn't break anything when resolving the conflicts. |
|
@mjwitte Sure. |
|
@mjwitte Seems good. I don't see anything missed conflict in IDD and code. All data sys vars are still there. |
|
Thanks for checking. This will drop in once CI finishes. |
|
Ack - the new test file is failing on linux debug. @Myoldmopar please run on linux and see what's up. |
|
@Myoldmopar @XuanLuoLBL Found the problem - nan's when checking the file max/min. Leap year logic needs review - see #6482 . For now, data file lengthened to 8784 data rows. |
|
All good now, merging. |
Pull request overview
EnergyPlus version 8.8 added features to export the calculated shading results to an external CSV file, and allow to use shading schedules to replace internal shading calculations for exterior surfaces.
Although the shading schedules can be imported from external CSV files, there needs to define all these schedules in IDF files explicitly as well as adding SurfaceProperty:LocalEnvironment objects for all exterior surfaces, which can be a significant burden for users especially for a model with many exterior surfaces. The proposed new feature will fully automate the process.
Work Checklist
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
Review Checklist
This will not be exhaustively relevant to every PR.