-
Notifications
You must be signed in to change notification settings - Fork 392
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
Fill object defaults for blank or missing fields and fix Site:GroundReflectance:SnowModifier defaults #10295
Conversation
@mjwitte @yujiex this appears to fill numeric defaults past min-fields. The #10282 defect file reads in 21 C as the default. If this field is entered then that value is used instead of the defaut. I'm not saying all getInputs are set up to read this correctly but in the case of the TUs, the default value is read in correctly. If the user enters a value for that field (in this case 17 C) that value will be used instead. |
For the case of the HeatBalanceAlgorithm, which has no min-fields and this defect file does not have any of the numeric fields, the defaults are filled (just not used since getInput for this object is not set up to read them in unless they are present).
In this case the defaults don't need to be read in since these data are initialized to the defaults in the constructor.
|
Diff for GroundTempOSCCompactSched:
|
@rraustad @Myoldmopar it has been 28 days since this pull request was last updated. |
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.
And we may as well do this for alphas, too?
} else { | ||
Numbers(numeric_index) = 0; | ||
} | ||
findDefault(Numbers(numeric_index), schema_field_obj); |
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.
findDefault
is a bool function. Should check here and set the value to 0 if it returns false.
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.
No need to check, Numbers(numeric_index) is set to 0 at top of function and if default does not exist for that field will return false and a 0 for that field.
bool InputProcessor::findDefault(Real64 &default_value, json const &schema_field_obj)
{
auto const find_default = schema_field_obj.find("default");
default_value = 0;
if (find_default != schema_field_obj.end()) {
// get default for autosize, int or real
}
return false;
}
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'm not always inclined to use the latest fancy C++, but I will just note that C++23 will have std::expected, and it has the potential to be deployed throughout our code some day in the future. We're years from anything like that, so no reason to discuss it, but feel free to look it up if you are an interested student.
For alpha fields I don't think it's an issue, at least not the same issue we see with Real fields. It's either a required-field or it's not. And if it's not and is a key choice then there should be a default. If there is no default I think that's an issue with the idd not the alpha findDefault function. If it's not a key choice then a non-required field blank should return a blank string (and getInput needs to handle that case?). Worst case here is to add an else at the bottom to "set" default_value to a null string but I don't think that's necessary, because the string passed to this function should already be blank.
|
For alpha fields, it looks like the code won't fill in the default unless it's
|
Given the changes to unit tests I'd say this is working as expected. |
@@ -3416,7 +3421,7 @@ TEST_F(InputProcessorFixture, getObjectItem_fan_on_off) | |||
|
|||
EXPECT_EQ(4, NumAlphas); | |||
EXPECT_TRUE(compare_containers( | |||
std::vector<std::string>({"SUPPLY FAN 1", "FANANDCOILAVAILSCHED", "ZONE EXHAUST NODE", "DX COOLING COIL AIR INLET NODE", "", "", ""}), | |||
std::vector<std::string>({"SUPPLY FAN 1", "FANANDCOILAVAILSCHED", "ZONE EXHAUST NODE", "DX COOLING COIL AIR INLET NODE", "", "", "General"}), |
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.
Retain case on this last alpha field:
Fan:OnOff,
A7 ; \field End-Use Subcategory
\note Any text may be used here to categorize the end-uses in the ABUPS End Uses by Subcategory table.
\type alpha
\retaincase
\default General
These eio diffs are significant.
There are no results diffs on CI, because the weather file doesn't have any times with snow on the ground and the winter design day has no sun and no snow. But if you change the winter design day to have snow and solar, then there's a difference in the daylighting illuminance. |
The dxf diffs also reveal a bug:
In this case, the drawing is correct, just the info line is wrong, because this line of code is wrong: EnergyPlus/src/EnergyPlus/OutputReports.cc Lines 532 to 533 in 6fafbb7
The drawing action is correctly set to the default Triangulate3DFace, but the print statement is writing the wrong string. With the changes in this branch, |
Re: DXF diffs: maybe the default used to be ThickPolyline? I did wonder why there were DXF diffs, thanks for checking. |
The impact of this change will be on getInput syntax. json has a similar issue getting defaults for missing fields. For example:
should change to:
because:
|
I wouldn't worry about removing code that sets hard-wired defaults like the absorption chiller. That can go away when |
@rraustad @mjwitte this is a really exciting change. I am super happy to see the removal of default values duplicated in both the IDD and the get-input routines. From the comments above, it seems the EIO diffs are still an issue? Let me know if I can do anything to help spur this along, as I'd love to get this in. |
I posted a new issue regarding the eio diffs, #10360 . This PR fixes that issue, no further changes required here. For the dxf diff, it's fixed here and has minimal impact, but it would be good to clean up the offending code per this comment. Otherwise, this is good to go. |
I'm OK with the eio diffs, as expected. And @mjwitte has added to the description as necessary for unanticipated changes revealed by this branch. This looks ready to merge. |
@Myoldmopar Assuming CI comes back same as for d6cfeba#comments this is ready to merge. Do you want to review anymore? |
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, let's get this in.
} else { | ||
Numbers(numeric_index) = 0; | ||
} | ||
findDefault(Numbers(numeric_index), schema_field_obj); |
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'm not always inclined to use the latest fancy C++, but I will just note that C++23 will have std::expected, and it has the potential to be deployed throughout our code some day in the future. We're years from anything like that, so no reason to discuss it, but feel free to look it up if you are an interested student.
Note (to self mostly) this could cause diffs in some of this morning's other merges. I'll run regressions locally as needed. |
Pull request overview
Report Specifications 1
the dxf file is written using the correct default methodTriangulate3DFace
but the tag in the dxf file wasThickPolyline
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.