-
Notifications
You must be signed in to change notification settings - Fork 400
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
Room Air Cleanup -- Part 1 #10092
Room Air Cleanup -- Part 1 #10092
Conversation
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.
Walkthru annotations.
@@ -225,8 +225,8 @@ namespace AirLoopHVACDOAS { | |||
++AirLoopMixerNum; | |||
AirLoopMixer thisMixer; | |||
|
|||
thisMixer.name = UtilityRoutines::MakeUPPERCase(thisObjectName); | |||
thisMixer.OutletNodeName = UtilityRoutines::MakeUPPERCase(fields.at("outlet_node_name").get<std::string>()); | |||
thisMixer.name = UtilityRoutines::makeUPPER(thisObjectName); |
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.
Just did a global sed
to shorten this name. You're welcome. I have another fun name shortener here also.
// TODO: Refactor this away by passing in enums | ||
DataLoopNode::ConnectionObjectType ParentTypeEnum = | ||
static_cast<DataLoopNode::ConnectionObjectType>(getEnumerationValue(ConnectionObjectTypeNamesUC, ParentTypeUC)); | ||
static_cast<DataLoopNode::ConnectionObjectType>(getEnumValue(ConnectionObjectTypeNamesUC, ParentTypeUC)); |
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 it is. Should have named it that from the beginning. Sorry.
@@ -64,7 +64,6 @@ | |||
#include <EnergyPlus/DataHeatBalance.hh> | |||
#include <EnergyPlus/DataRoomAirModel.hh> | |||
#include <EnergyPlus/DataSurfaces.hh> | |||
#include <EnergyPlus/DataUCSDSharedData.hh> |
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 module has been incorporated into DataRoomAirModel.hh
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 file name is still in a CMake file, somewhere (probably ..\src\EnergyPlus), as shown by the Custom Check results.
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.
Thanks, I'll get rid of it.
@@ -98,7 +96,7 @@ namespace CrossVentMgr { | |||
Real64 constexpr CrecFlow1(0.415); // First correlation constant for the recirculation flow rate | |||
Real64 constexpr CrecFlow2(0.466); // Second correlation constant for the recirculation flow rate | |||
|
|||
void ManageUCSDCVModel(EnergyPlusData &state, | |||
void ManageCrossVent(EnergyPlusData &state, |
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.
With all due respect to UCSD, there is no need to embed UCSD
into variable and function names. I don't add Roth
to names.
for (int Ctd = state.dataUCSDShared->PosZ_Wall((ZoneNum - 1) * 2 + 1); Ctd <= state.dataUCSDShared->PosZ_Wall((ZoneNum - 1) * 2 + 2); | ||
++Ctd) { | ||
int SurfNum = state.dataUCSDShared->APos_Wall(Ctd); | ||
for (int Ctd = state.dataRoomAir->PosZ_Wall(ZoneNum).beg; Ctd <= state.dataRoomAir->PosZ_Wall(ZoneNum).end; ++Ctd) { |
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 cannot tell you how much I hate the pattern of faking what should be an array of structs or even multiple arrays in a single array by, e.g., putting one of the elements in the odd positions in the array and another element in the even positions. It's not cute. It's brittle and opaque and evil.
|
||
// Data | ||
class RAFNData |
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.
Buh-bye.
ShowSevereError(state, format("{}{}=\"{}\", invalid data.", RoutineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); | ||
ShowContinueError( | ||
state, format("Invalid-not found {}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); | ||
ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(2), ipsc->cAlphaArgs(2)); |
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.
Shortcuts for common errors.
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 like that.
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 are five shortcuts so far: DuplicateName
, EmptyField
, InvalidKey
, ItemNotFound
, and OutOfRange
but they cover nearly 50% of all input errors.
} | ||
} | ||
} | ||
} // if |
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 like to add these annotations. They help me remember where I am in the current nesting level.
bool GetUCSDDVDataFlag = true; // UCSD | ||
bool GetAirModelData = true; // Used to "get" all air model data | ||
bool MyOneTimeFlag = true; | ||
int CompNum = 0; |
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 of these were local variables that migrated into state somehow and now went back where they belong.
int Loop = 0; // counter | ||
int Loop2 = 0; // counter | ||
int Loop3 = 0; // counter | ||
int i = 0; // counter |
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.
Really, i
is a state variable?
int SurfNum = state.dataRoomAir->APos_Wall(Ctd); | ||
if (SurfNum == 0) continue; | ||
|
||
auto const &surf = state.dataSurface->Surface(SurfNum); | ||
state.dataSurface->SurfTAirRef(SurfNum) = DataSurfaces::RefAirTemp::AdjacentAirTemp; |
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 function is called from the CalcUCSDCV (now CalcCrossVent) function. Do we need to set this (line 177) enum each iteration? This will not change for a specific surface will it?
SurfaceConvectionAlgorithm:Inside:UserCurve,
A2 , \field Reference Temperature for Convection Heat Transfer
\note Controls which temperature is differenced from surface temperature when using the Hc value
\type choice
\key MeanAirTemperature
\key AdjacentAirTemperature
\key SupplyAirTemperature
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 don't know.
src/EnergyPlus/DataRoomAirModel.hh
Outdated
Real64 ZoneVolumeFraction; // portion of zone air volume associated with this node | ||
std::string Name = ""; // name | ||
std::string ZoneName = ""; | ||
int ZonePtr = 0; // Pointer to the zone number for this statement |
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.
Maybe for a different pass since this PR is rather intense, I see ZoneName and ZonePtr in these and other structs. If we know the zone index we also know the name.
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.
Yeah.
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 started as good clean up and ended up very good clean up. Nice job!
std::string ZoneName = ""; // Name of zone | ||
int ZonePtr = 0; // Pointer to the zone number for this statement | ||
int SchedGainsPtr = -1; // Schedule for internal gain fraction to occupied zone | ||
std::string SchedGainsName = ""; // Gains Schedule name |
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.
You can delete this now.
src/EnergyPlus/DataRoomAirModel.hh
Outdated
std::string ZoneName = ""; // Name of zone | ||
int ZonePtr = 0; // Pointer to the zone number for this statement | ||
int SchedGainsPtr = 0; // Schedule for internal gain fraction to occupied zone | ||
std::string SchedGainsName = ""; // Gains Schedule name |
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.
You can delete this now.
@@ -64,7 +64,6 @@ | |||
#include <EnergyPlus/DataHeatBalance.hh> | |||
#include <EnergyPlus/DataRoomAirModel.hh> | |||
#include <EnergyPlus/DataSurfaces.hh> | |||
#include <EnergyPlus/DataUCSDSharedData.hh> |
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 file name is still in a CMake file, somewhere (probably ..\src\EnergyPlus), as shown by the Custom Check results.
ShowSevereError(state, format("{}{}=\"{}\", invalid data.", RoutineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); | ||
ShowContinueError( | ||
state, format("Invalid-not found {}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); | ||
ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(2), ipsc->cAlphaArgs(2)); |
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 like that.
ShowContinueError(state, format("Entered in {} = {}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); | ||
zoneUI.DiffuserType = static_cast<Diffuser>(getEnumValue(diffuserNamesUC, UtilityRoutines::makeUPPER(ipsc->cAlphaArgs(2)))); | ||
if (zoneUI.DiffuserType == Diffuser::Invalid) { | ||
ShowSevereInvalidKey(state, eoh, ipsc->cAlphaFieldNames(2), ipsc->cAlphaArgs(2)); | ||
ErrorsFound = true; | ||
} |
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.
Not possible since this field is within min-fields. Usually when I do this and see an else
I'll check the idd.
RoomAirSettings:UnderFloorAirDistributionInterior,
\min-fields 15
N7 , \field Temperature Difference Threshold for Reporting
A2 , \field Floor Diffuser Type
\type choice
\key Custom
\key Swirl
\key VariableArea
\key HorizontalSwirl
\key LinearBarGrille
\default Swirl
@@ -7114,11 +7114,11 @@ namespace UnitarySystems { | |||
if (sysNum == -1) { | |||
// zone equipment require a 1-n index for access to zone availability managers | |||
switch (getPTUnitType) { | |||
case 1: | |||
case 1: // Excuse me? |
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.
Maybe I'll change these to constexpr next time I'm in here.
@@ -1172,7 +1172,7 @@ TEST_F(ConvectionCoefficientsFixture, EvaluateHnModels) | |||
SurfNum = 1; | |||
state->dataSurface->Surface.allocate(SurfNum); | |||
state->dataSurface->Surface(SurfNum).Zone = 1; | |||
state->dataRoomAirMod->AirModel.allocate(1); | |||
state->dataRoomAir->AirModel.allocate(1); |
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.
Stopping at unit tests since changes will only be class names.
Good thing there are no diffs! That's the only way to guage these massive changes. |
The changes to |
Fixed the format and custom check issues, deleting the now empty source file along the way. It's testing happily here, but I'll let at least some of the CI runs do their work on it before final review/merge. |
Pulled develop one more quick time this morning and everything is still happy as expected, merging. Thanks @amirroth ! |
This started as a small effort to replace the
ZoneEquipTypeOf_
integers inDataHVACGlobals.hh
with an enumeration. It ended up with eliminating that group of constants in favor of theZoneEquip
enumeration inDataZoneEquipment.hh
and then doing some cleanup in theRoomAirModel
modules where that enumeration was most heavily used.Some highlights:
DataRoomAirModel
,RoomAirModelManager
,RoomAirModelAirflowNetwork
,RoomAirModelUserTempPattern
,DisplacementVentManager
,CrossVentManager
,UFADManager
, andMundtSimManager
are unified into a singleRoomAir
namespace.state.dataX
objects were heavily pruned. This is something I noticed when working on the daylighting module. At some point, whole tranches of local variables migrated intostate.dataX
objects. In some cases even loop induction variables! I don't know why or when this happened, whether it happened automatically (e.g., variables were mistakenly labeled asstatic
and all static variables were moved tostate.dataX
) or manually, but it needs to be undone and it can only be undone manually. The general rule is thatstate.dataX
objects should only contain data that persists across time steps. There are two major exceptions to this rule: i) data that is passed among a large number of functions within a single time step, and ii) large temporary data structures that are only used in one function but that have high set-up and tear-down overheads. Either way, I will be doing this aggressively going forward.state.dataX
were largely unified into a singlestate.dataRoomAir
object. There are a few stragglers left, but they will be taken care of in a separate pass in the near future.std::array
, this primarily applies to history variables.Array1D
objects were conveted tostd::array
.struct
s (looking at you,UFADInt
andUFADExt
) and their containers were unified.getEnumerationValue
, shortcuts, and scope reduction.This should be a zero diff PR.