-
Notifications
You must be signed in to change notification settings - Fork 473
Catch EMS variables initialized after reference, follow-up #11551
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
base: develop
Are you sure you want to change the base?
Changes from all commits
61e5c90
9b10cb2
43c9a0c
59eccab
5d77fd3
5e47cca
87ab677
d7762f4
74c3b6e
e97ca01
44cb5eb
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 |
|---|---|---|
|
|
@@ -310,6 +310,10 @@ void BeginEnvrnInitializeRuntimeLanguage(EnergyPlusData &state) | |
| if (state.dataRuntimeLang->ErlVariable(ErlVariableNum).Value.initialized) { | ||
| state.dataRuntimeLang->ErlVariable(ErlVariableNum).Value = | ||
| SetErlValueNumber(0.0, state.dataRuntimeLang->ErlVariable(ErlVariableNum).Value); | ||
|
|
||
| if (!state.dataRuntimeLang->ErlVariable(ErlVariableNum).Value.SetupInit) { | ||
| state.dataRuntimeLang->ErlVariable(ErlVariableNum).Value.initialized = false; | ||
| } | ||
| } | ||
| } | ||
| // reinitialize state of actuators | ||
|
|
@@ -976,7 +980,7 @@ void WriteTrace(EnergyPlusData &state, int const StackNum, int const Instruction | |
| std::string LineString; | ||
| std::string cValueString; | ||
| std::string TimeString; | ||
| std::string DuringWarmup; | ||
| std::string OccurrenceTimingInfo; | ||
|
|
||
| if ((!state.dataRuntimeLang->OutputFullEMSTrace) && (!state.dataRuntimeLang->OutputEMSErrors) && (!seriousErrorFound)) { | ||
| return; | ||
|
|
@@ -1004,19 +1008,27 @@ void WriteTrace(EnergyPlusData &state, int const StackNum, int const Instruction | |
|
|
||
| // put together timestamp info | ||
| if (state.dataGlobal->WarmupFlag) { | ||
| if (!state.dataGlobal->DoingSizing) { | ||
| DuringWarmup = " During Warmup, Occurrence info="; | ||
| if (!state.dataGlobal->SetupFlag) { | ||
| if (!state.dataGlobal->DoingSizing) { | ||
| OccurrenceTimingInfo = " During Warmup, Occurrence info="; | ||
| } else { | ||
| OccurrenceTimingInfo = " During Warmup & Sizing, Occurrence info="; | ||
| } | ||
| } else { | ||
| DuringWarmup = " During Warmup & Sizing, Occurrence info="; | ||
| if (!state.dataGlobal->DoingSizing) { | ||
| OccurrenceTimingInfo = " During Setup, Occurrence info="; | ||
| } else { | ||
| OccurrenceTimingInfo = " During Setup & Sizing, Occurrence info="; | ||
| } | ||
| } | ||
| } else { | ||
| if (!state.dataGlobal->DoingSizing) { | ||
| DuringWarmup = " Occurrence info="; | ||
| OccurrenceTimingInfo = " Occurrence info="; | ||
| } else { | ||
| DuringWarmup = " During Sizing, Occurrence info="; | ||
| OccurrenceTimingInfo = " During Sizing, Occurrence info="; | ||
| } | ||
| } | ||
| TimeString = DuringWarmup + state.dataEnvrn->EnvironmentName + ", " + state.dataEnvrn->CurMnDy + ' ' + CreateSysTimeIntervalString(state); | ||
| TimeString = OccurrenceTimingInfo + state.dataEnvrn->EnvironmentName + ", " + state.dataEnvrn->CurMnDy + ' ' + CreateSysTimeIntervalString(state); | ||
|
|
||
| if (state.dataRuntimeLang->OutputFullEMSTrace || (state.dataRuntimeLang->OutputEMSErrors && (ReturnValue.Type == Value::Error))) { | ||
| print(state.files.edd, "{},Line {},{},{},{}\n", NameString, LineNumString, LineString, cValueString, TimeString); | ||
|
|
@@ -1806,19 +1818,17 @@ ErlValueType EvaluateExpression(EnergyPlusData &state, int const ExpressionNum, | |
| } | ||
|
|
||
| } else if (thisOperand.Type == Value::Variable) { | ||
| auto const &thisErlVar = state.dataRuntimeLang->ErlVariable(thisOperand.Variable); | ||
| auto &thisErlVar = state.dataRuntimeLang->ErlVariable(thisOperand.Variable); | ||
|
Collaborator
Author
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. Remove const since we may be updating |
||
| if (thisErlVar.Value.initialized) { // check that value has been initialized | ||
| thisOperand = thisErlVar.Value; | ||
| } else { // value has never been set | ||
| // During setup (before simulation), we want to avoid initializing variables to zero without throwing an error. | ||
| // Throw the error, and write it to edd file, if variable is uninitialized and is *not* a global or internal variable. | ||
| // The assumption is that if we made it here for a global variable, it is initialized in another program. | ||
| // E.g., if it's initialized in a program with BeginNewEnvironment calling point, setup won't set it but simulation will. | ||
| if ((!state.dataGlobal->DoingSizing && !state.dataGlobal->KickOffSimulation && !state.dataEMSMgr->FinishProcessingUserInput) || | ||
| (!(thisErlVar.SetByGlobalVariable || thisErlVar.SetByInternalVariable))) { | ||
|
|
||
| ReturnValue.Type = Value::Error; | ||
| ReturnValue.Error = "EvaluateExpression: Variable = '" + thisErlVar.Name + "' used in expression has not been initialized!"; | ||
| ReturnValue.Type = Value::Error; | ||
| ReturnValue.Error = "EvaluateExpression: Variable = '" + thisErlVar.Name + "' used in expression has not been initialized!"; | ||
| // Use SetupInit in BeginEnvrnInitializeRuntimeLanguage for "un-initializing" Erl variables that may have been | ||
| // initialized to zero during setup. This can happen since SetupSimulation does not call BeginNewEnvironment. | ||
| thisErlVar.Value.SetupInit = false; | ||
|
Collaborator
Author
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. Revert the change from #11409, and instead just add this single line. |
||
| if (!state.dataGlobal->DoingSizing && !state.dataGlobal->KickOffSimulation && !state.dataEMSMgr->FinishProcessingUserInput) { | ||
|
|
||
| // check if this is an arg in CurveValue, | ||
| if (thisErlExpression.Operator != | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -905,10 +905,18 @@ void ShowContinueErrorTimeStamp(EnergyPlusData &state, std::string const &Messag | |
| std::string cEnvHeader; | ||
|
|
||
| if (state.dataGlobal->WarmupFlag) { | ||
| if (!state.dataGlobal->DoingSizing) { | ||
| cEnvHeader = " During Warmup, Environment="; | ||
| if (!state.dataGlobal->SetupFlag) { | ||
| if (!state.dataGlobal->DoingSizing) { | ||
| cEnvHeader = " During Warmup, Environment="; | ||
| } else { | ||
| cEnvHeader = " During Warmup & Sizing, Environment="; | ||
| } | ||
| } else { | ||
| cEnvHeader = " During Warmup & Sizing, Environment="; | ||
| if (!state.dataGlobal->DoingSizing) { | ||
| cEnvHeader = " During Setup, Environment="; | ||
| } else { | ||
| cEnvHeader = " During Setup & Sizing, Environment="; | ||
| } | ||
|
Comment on lines
+915
to
+919
Collaborator
Author
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. This is entered during |
||
| } | ||
| } else { | ||
| if (!state.dataGlobal->DoingSizing) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77655,43 +77655,6 @@ | |
| Flr_1_Stor_DT2, !- <none> | ||
| Flr_1_Waiting_DT2; !- <none> | ||
|
|
||
| EnergyManagementSystem:GlobalVariable, | ||
| A, !- Erl Variable 1 Name | ||
| B, !- Erl Variable 2 Name | ||
| C, !- Erl Variable 3 Name | ||
| D, !- <none> | ||
| E, !- <none> | ||
| F, !- <none> | ||
| G, !- <none> | ||
| H, !- <none> | ||
| I, !- <none> | ||
| J, !- <none> | ||
| K, !- <none> | ||
| L, !- <none> | ||
| M, !- <none> | ||
| N, !- <none> | ||
| O, !- <none> | ||
| P, !- <none> | ||
| Q, !- <none> | ||
| R, !- <none> | ||
| S, !- <none> | ||
| T, !- <none> | ||
| U, !- <none> | ||
| V, !- <none> | ||
| W, !- <none> | ||
| X, !- <none> | ||
| Y, !- <none> | ||
| Z, !- <none> | ||
| AA, !- <none> | ||
| BB, !- <none> | ||
| CC, !- <none> | ||
| DD, !- <none> | ||
| EE, !- <none> | ||
| FF, !- <none> | ||
| GG, !- <none> | ||
| HH, !- <none> | ||
| II; !- <none> | ||
|
Comment on lines
-77658
to
-77693
Collaborator
Author
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. This reverts the IDF additions from #11409. |
||
|
|
||
| !- =========== ALL OBJECTS IN CLASS: ENERGYMANAGEMENTSYSTEM:OUTPUTVARIABLE =========== | ||
|
|
||
| EnergyManagementSystem:OutputVariable, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7948,6 +7948,10 @@ | |
| SET SumReliefMCT = SumReliefMCT + (h_Relief_3 * mdotRelief_3 ), !- <none> | ||
| SET SumReliefMCT = SumReliefMCT + (h_Relief_4 * mdotRelief_4 ); !- <none> | ||
|
|
||
| EnergyManagementSystem:Program, | ||
| InitializeRoofTemperature, !- Name | ||
| Set Troof = 0.0; !- Program Line 1 | ||
|
|
||
| EnergyManagementSystem:Program, | ||
| InitializeParameters, !- Name | ||
| Set CV_Height = 1.0, !- Program Line 1 | ||
|
|
@@ -8066,10 +8070,8 @@ | |
|
|
||
| EnergyManagementSystem:GlobalVariable, | ||
| Troof, !- Erl Variable 1 Name | ||
| DeltaT, !- Erl Variable 2 Name | ||
| ratioT, !- Erl Variable 3 Name | ||
|
Comment on lines
-8069
to
-8070
Collaborator
Author
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. This reverts the IDF additions from #11409. |
||
| CV_Height, !- <none> | ||
| CV_crossSectArea, !- <none> | ||
| CV_Height, !- Erl Variable 2 Name | ||
| CV_crossSectArea, !- Erl Variable 3 Name | ||
| C_v, !- <none> | ||
| rhoAir, !- <none> | ||
| CpAir, !- <none> | ||
|
|
@@ -8100,6 +8102,11 @@ | |
| Set NatBouyMC = rhoAir * C_d * A_roof * temp2 * CpAir, !- <none> | ||
| Set NatBouyMCT = NatBouyMC * Ta; !- <none> | ||
|
|
||
| EnergyManagementSystem:ProgramCallingManager, | ||
| InitializeRoofTemperatureOnBeginNewEnvironment, !- Name | ||
| BeginNewEnvironment, !- EnergyPlus Model Calling Point | ||
| InitializeRoofTemperature; !- Program Name 1 | ||
|
|
||
| EnergyManagementSystem:ProgramCallingManager, | ||
| Model Flat Roof Microclimate, !- Name | ||
| BeginTimestepBeforePredictor, !- EnergyPlus Model Calling Point | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7279,6 +7279,11 @@ | |
|
|
||
| !- =========== ALL OBJECTS IN CLASS: ENERGYMANAGEMENTSYSTEM:PROGRAMCALLINGMANAGER =========== | ||
|
|
||
| EnergyManagementSystem:ProgramCallingManager, | ||
| init calling manager, !- Name | ||
| BeginNewEnvironment, !- EnergyPlus Model Calling Point | ||
| init; !- Program Name 1 | ||
|
|
||
| EnergyManagementSystem:ProgramCallingManager, | ||
| attic_unvented_1_duct_leakage_imbalance_infil_program calling manager, !- Name | ||
| BeginZoneTimestepAfterInitHeatBalance, !- EnergyPlus Model Calling Point | ||
|
|
@@ -7336,6 +7341,13 @@ | |
|
|
||
| !- =========== ALL OBJECTS IN CLASS: ENERGYMANAGEMENTSYSTEM:PROGRAM =========== | ||
|
|
||
| EnergyManagementSystem:Program, | ||
| init, !- Name | ||
| Set CENTRAL_AC_AND_FURNACE_AIRLOOP_0_DUCTIMBALLKSUPFANEQUIVDZ = 0.0, !- Program Line 1 | ||
| Set CENTRAL_AC_AND_FURNACE_AIRLOOP_0_DUCTIMBALLKEXHFANEQUIVDZ = 0.0, !- Program Line 2 | ||
| Set CENTRAL_AC_AND_FURNACE_AIRLOOP_0_DUCTIMBALLKSUPFANEQUIVCOND = 0.0, !- <none> | ||
| Set CENTRAL_AC_AND_FURNACE_AIRLOOP_0_DUCTIMBALLKEXHFANEQUIVCOND = 0.0; !- <none> | ||
|
|
||
| EnergyManagementSystem:Program, | ||
| attic_unvented_1_duct_leakage_imbalance_infil_program, !- Name | ||
| Set Qducts = 0, !- Program Line 1 | ||
|
|
@@ -7785,11 +7797,6 @@ | |
| EnergyManagementSystem:GlobalVariable, | ||
| natural_vent_program_Qwhf; !- Erl Variable 1 Name | ||
|
|
||
| EnergyManagementSystem:GlobalVariable, | ||
| Qducts, !- Erl Variable 1 Name | ||
| Qsupply, !- Erl Variable 2 Name | ||
| Qexhaust; !- Erl Variable 3 Name | ||
|
Comment on lines
-7788
to
-7791
Collaborator
Author
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. This reverts the IDF additions from #11409. |
||
|
|
||
| !- =========== ALL OBJECTS IN CLASS: ENERGYMANAGEMENTSYSTEM:OUTPUTVARIABLE =========== | ||
|
|
||
| EnergyManagementSystem:OutputVariable, | ||
|
|
||
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.
Right before BeginNewEnvironment, "un-initialize" any Erl variables that had originally hit the
EvaluateExpression: Variable = 'xyz' used in expression has not been initialized!error. If BeginNewEnvironment initializes them, theninitializedis set back to true and we're good; if it doesn't, or there are other legitimate Erl variable initialization errors, theEvaluateExpression ...will throw.