-
Notifications
You must be signed in to change notification settings - Fork 393
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
Round2 init state use #10662
base: develop
Are you sure you want to change the base?
Round2 init state use #10662
Changes from 4 commits
f6e0e8a
758b5e1
4dbd4c4
5aefd65
167a8bb
339fe3b
f7ba56c
5774851
85a2ef2
de455d7
0dafbab
730845a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,6 @@ | |
|
||
// EnergyPlus Headers | ||
#include <EnergyPlus/CurveManager.hh> | ||
#include <EnergyPlus/Data/EnergyPlusData.hh> | ||
#include <EnergyPlus/DataBranchAirLoopPlant.hh> | ||
#include <EnergyPlus/DataIPShortCuts.hh> | ||
#include <EnergyPlus/DataLoopNode.hh> | ||
|
@@ -572,7 +571,6 @@ namespace Curve { | |
bool GetInputErrorsFound = false; | ||
|
||
GetCurveInputData(state, GetInputErrorsFound); | ||
state.dataCurveManager->GetCurvesInputFlag = false; | ||
|
||
if (GetInputErrorsFound) { | ||
ShowFatalError(state, "GetCurveInput: Errors found in getting Curve Objects. Preceding condition(s) cause termination."); | ||
|
@@ -611,6 +609,8 @@ namespace Curve { | |
int IOStatus; // Used in GetObjectItem | ||
std::string CurrentModuleObject; // for ease in renaming. | ||
|
||
if (!state.dataCurveManager->GetCurvesInputFlag) return; | ||
state.dataCurveManager->GetCurvesInputFlag = false; | ||
// Find the number of each type of curve (note: Current Module object not used here, must rename manually) | ||
|
||
int const NumBiQuad = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Curve:Biquadratic"); | ||
|
@@ -653,6 +653,7 @@ namespace Curve { | |
// initialize the array | ||
|
||
int CurveNum = 0; // keep track of the current curve index in the main curve array | ||
state.dataCurveManager->UniqueCurveNames.clear(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only change needed to allow curve manager getInput to be called more than once. It will likely not be called more than once but if it does it will give the same answer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably better to set a flag and make sure the body is not called twice. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, the outer getInput call does protect from the second call. If a unit test calls the root function multiple times it would need to give the same answer. I think I did this before removing init_state from the unit test fixture (last thing I did) so maybe I can fix this and not have to change any unit tests. I'll just move that flag down into GetCurveInputData.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a general practice in EnergyPlus of "protecting functions from bad inputs or bad calling contexts". This is actually counter-productive because it hides bad uses of the function. It's better programming to assert good inputs and good context (to the extent possible) within a function and then use those to progressively clean up the calling contexts. |
||
|
||
// Loop over biquadratic curves and load data | ||
CurrentModuleObject = "Curve:Biquadratic"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -572,14 +572,18 @@ void EnergyPlusData::clear_state() | |
void EnergyPlusData::init_state(EnergyPlusData &state) | ||
{ | ||
if (this->init_state_called) return; | ||
|
||
state.dataGlobal->InputsFlag = true; | ||
this->init_state_called = true; | ||
// The order in which we do this matters. We're going to try to | ||
// do this in "topological" order meaning the first to go are the | ||
// objects that do not reference any other objects, like fluids, | ||
// schedules, curves, etc. | ||
this->dataSimulationManager->init_state(state); // GetProjectData | ||
this->dataSimulationManager->init_state(state); // OpenOutputFiles, GetProjectData, SetPreConstructionInputParameters | ||
this->dataFluidProps->init_state(state); // GetFluidPropertiesData | ||
this->dataPsychrometrics->init_state(state); // InitializePsychRoutines | ||
this->dataScheduleMgr->init_state(state); // ProcessScheduleInput - requires NumOfTimeStepInHour and AnyEnergyManagementSystemInModel | ||
this->dataCurveManager->init_state(state); // GetCurveInput, GetPressureSystemInput | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added schedules and curves to init_state |
||
|
||
this->dataAirLoop->init_state(state); | ||
this->dataAirLoopHVACDOAS->init_state(state); | ||
|
@@ -614,7 +618,6 @@ void EnergyPlusData::init_state(EnergyPlusData &state) | |
this->dataCoolTower->init_state(state); | ||
this->dataCostEstimateManager->init_state(state); | ||
this->dataCrossVentMgr->init_state(state); | ||
this->dataCurveManager->init_state(state); | ||
this->dataDXCoils->init_state(state); | ||
this->dataDXFEarClipping->init_state(state); | ||
this->dataDaylightingDevices->init_state(state); | ||
|
@@ -758,7 +761,6 @@ void EnergyPlusData::init_state(EnergyPlusData &state) | |
this->dataRuntimeLang->init_state(state); | ||
this->dataRuntimeLangProcessor->init_state(state); | ||
this->dataSQLiteProcedures->init_state(state); | ||
this->dataScheduleMgr->init_state(state); | ||
this->dataSetPointManager->init_state(state); | ||
this->dataShadowComb->init_state(state); | ||
this->dataSimAirServingZones->init_state(state); | ||
|
@@ -826,6 +828,8 @@ void EnergyPlusData::init_state(EnergyPlusData &state) | |
this->dataZoneEquipmentManager->init_state(state); | ||
this->dataZonePlenum->init_state(state); | ||
this->dataZoneTempPredictorCorrector->init_state(state); | ||
|
||
state.dataGlobal->InputsFlag = false; | ||
} | ||
|
||
} // namespace EnergyPlus |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,7 +87,7 @@ namespace EnergyPlus { | |
TEST_F(EnergyPlusFixture, SetVSHPAirFlowTest_VSFurnaceFlowTest) | ||
{ | ||
|
||
state->init_state(*state); | ||
state->init_state(*state); // get FluidProperties | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, why did I have to leave this here when FluidProperties is called in the fixture? Maybe this unit test needed something else now in init_state? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, that's right. If the unit test does not have an idf snippet then process_idf will not be called and default fluids will not be set up yet. So this is correct. |
||
int FurnaceNum(1); | ||
Real64 OnOffAirFlowRatio; // This is a return value | ||
Real64 PartLoadRatio(1.0); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6563,10 +6563,10 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOARateTest) | |
" ** ~~~ ** This may be overriding desired ventilation controls. Check inputs for Minimum Outdoor Air Flow Rate, Minimum Outdoor Air " | ||
"Schedule Name and Controller:MechanicalVentilation", | ||
" ** ~~~ ** Minimum OA fraction = 2.9412E-003, Mech Vent OA fraction = 1.5603E-003", | ||
" ** ~~~ ** Environment=, at Simulation time= 00:00 - 00:00", | ||
" ** ~~~ ** Environment=, at Simulation time= 00:15 - 00:15", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that Timestep is processed in process_idf the time stamp is the first time step of the simulation. Before, NumTimeStepInHour = 0, now it is non-zero and Timestep defaults to 4. |
||
}); | ||
|
||
EXPECT_TRUE(compare_err_stream_substring(error_string, true)); | ||
EXPECT_TRUE(compare_err_stream(error_string, true)); | ||
|
||
state->dataAirLoop->AirLoopControlInfo.deallocate(); | ||
state->dataSize->OARequirements.deallocate(); | ||
|
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.
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.
😆 🤣 😄 This is excellent @rraustad !
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.
Wow.