Skip to content
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

Space Sizing and HVAC Part 3 #10205

Merged
merged 52 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
208abe7
InitInternalHeatGains shortcuts and remove excess loop
mjwitte Aug 31, 2023
dbc3788
Merge remote-tracking branch 'remotes/origin/develop' into SpaceSizin…
mjwitte Sep 6, 2023
c5c95f3
Space - Set space temps to zone temps if no spaceHB
mjwitte Sep 6, 2023
dd5e82b
Space - Move internal gains to space conditions
mjwitte Sep 6, 2023
d3b014b
remove unused
mjwitte Sep 7, 2023
7d80e78
Merge remote-tracking branch 'remotes/origin/develop' into SpaceSizin…
mjwitte Sep 7, 2023
9cb97fc
InternalHeatGains merge cleanup
mjwitte Sep 7, 2023
dc204b9
Space - More space conditions to zone conditions if no spaceHB
mjwitte Sep 7, 2023
2d87d47
InternalHeatGains refactor reporting and fix BBHeat space fraction
mjwitte Sep 8, 2023
6f45e07
Eliminate duplicate internal gain reporting variables
mjwitte Sep 8, 2023
ce03c1b
Use Space conditions - HAMT surface balance
mjwitte Sep 8, 2023
1e922e0
Use Space conditions - DataSurfaces.cc
mjwitte Sep 8, 2023
c653a79
Use Space conditions - ConvectionCoefficients.cc part 1
mjwitte Sep 8, 2023
c5cb1de
InternalHeatGains refactor more zeroing
mjwitte Sep 9, 2023
055112f
Use Space conditions - update spaces ZTAV and airHumRatAvg
mjwitte Sep 9, 2023
4c20979
Use Space conditions - ConvectionCoefficients.cc part 2
mjwitte Sep 9, 2023
b5b90cc
InternalHeatGains refactor revert ITEq zeroing
mjwitte Sep 9, 2023
7e58b2e
Merge remote-tracking branch 'remotes/origin/develop' into SpaceSizin…
mjwitte Sep 11, 2023
a7da5f0
Revert-Use Space conditions - DataSurfaces.cc
mjwitte Sep 11, 2023
6038695
Use Space conditions - ConvectionCoefficients.cc part 3
mjwitte Sep 12, 2023
1a65499
Merge remote-tracking branch 'remotes/origin/develop' into SpaceSizin…
mjwitte Sep 13, 2023
313ebc6
Use Space conditions - HeatBalanceSurfaceManager
mjwitte Sep 13, 2023
cde8ee5
Space HB - Calc space air report variables
mjwitte Sep 13, 2023
6c25a00
Merge remote-tracking branch 'remotes/origin/develop' into SpaceSizin…
mjwitte Sep 14, 2023
8a88ca4
Merge remote-tracking branch 'remotes/origin/develop' into SpaceSizin…
mjwitte Sep 14, 2023
52d936e
cleanup
mjwitte Sep 14, 2023
83a1093
Use Space conditions - DataSurfaces.cc
mjwitte Sep 14, 2023
261354f
Space HVAC - More ZoneEquipmentManager space fractions
mjwitte Sep 14, 2023
c7b5d57
Space - Revert CalcZoneComponentLoadSums
mjwitte Sep 14, 2023
9a30402
Merge remote-tracking branch 'remotes/origin/develop' into SpaceSizin…
mjwitte Sep 15, 2023
685faeb
Space HVAC - CalcZoneComponentLoadSums and more
mjwitte Sep 15, 2023
190833a
Use Space conditions - EcoRoofManager.cc
mjwitte Sep 15, 2023
6c4e433
Use Space conditions - EcoRoofManager.cc
mjwitte Sep 15, 2023
bf96c6b
Use Space conditions - ReportInfiltrations
mjwitte Sep 15, 2023
d1bdc21
Space HVAC - Zone equipment splitter functions
mjwitte Sep 18, 2023
6ed3628
Merge remote-tracking branch 'remotes/origin/develop' into SpaceSizin…
mjwitte Sep 18, 2023
3a596f0
Space HVAC - Zone equipment mixer functions
mjwitte Sep 18, 2023
650ec35
Merge remote-tracking branch 'remotes/origin/develop' into SpaceSizin…
mjwitte Sep 18, 2023
77fb542
Space HVAC - Zone equipment splitter mixer sizing
mjwitte Sep 18, 2023
c04c63c
SpaceHVAC - Address comment
mjwitte Sep 18, 2023
ee658e2
cleanup
mjwitte Sep 18, 2023
2f24479
Space HVAC - Zone equipment splitter repairs
mjwitte Sep 19, 2023
110349b
Space HVAC - more Zone equipment splitter mixer sizing
mjwitte Sep 19, 2023
ce75bbd
Delete duplicate dimensions
mjwitte Sep 20, 2023
6708113
Space Sizing - repairs
mjwitte Sep 20, 2023
36b76ca
Merge remote-tracking branch 'remotes/origin/develop' into SpaceSizin…
mjwitte Sep 20, 2023
c012e8c
Space HVAC - address comments
mjwitte Sep 20, 2023
3af26a9
Merge remote-tracking branch 'remotes/origin/develop' into SpaceSizin…
mjwitte Sep 20, 2023
06941cf
Merge repairs
mjwitte Sep 20, 2023
60fa04e
Merge remote-tracking branch 'remotes/origin/develop' into SpaceSizin…
mjwitte Sep 20, 2023
fd0a91f
Merge remote-tracking branch 'remotes/origin/develop' into SpaceSizin…
mjwitte Sep 20, 2023
96076f8
Space HVAC - Fix supply nodes
mjwitte Sep 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions src/EnergyPlus/ConvectionCoefficients.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ void InitIntConvCoeff(EnergyPlusData &state,
auto const &zone = state.dataHeatBal->Zone(ZoneNum);
for (int spaceNum : zone.spaceIndexes) {
auto const &thisSpace = state.dataHeatBal->space(spaceNum);
Real64 spaceMAT = state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).MAT;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change to make this a bit more readable. It's not a functional change, is it? I can't tell from here if that argument is marked INTENT(INOUT) -- I mean as a reference :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Key thing here is changing from zone MAT to space MAT.

for (int SurfNum = thisSpace.HTSurfaceFirst; SurfNum <= thisSpace.HTSurfaceLast; ++SurfNum) {

if (present(ZoneToResimulate)) {
Expand Down Expand Up @@ -309,20 +310,17 @@ void InitIntConvCoeff(EnergyPlusData &state,
} break;

case HcInt::ASHRAESimple: {
CalcASHRAESimpleIntConvCoeff(
state, SurfNum, SurfaceTemperatures(SurfNum), state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum).MAT);
CalcASHRAESimpleIntConvCoeff(state, SurfNum, SurfaceTemperatures(SurfNum), spaceMAT);
// Establish some lower limit to avoid a zero convection coefficient (and potential divide by zero problems)
if (state.dataHeatBalSurf->SurfHConvInt(SurfNum) < state.dataHeatBal->LowHConvLimit)
state.dataHeatBalSurf->SurfHConvInt(SurfNum) = state.dataHeatBal->LowHConvLimit;
} break;

case HcInt::ASHRAETARP: {
if (!state.dataConstruction->Construct(Surface(SurfNum).Construction).TypeIsWindow) {
CalcASHRAEDetailedIntConvCoeff(
state, SurfNum, SurfaceTemperatures(SurfNum), state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum).MAT);
CalcASHRAEDetailedIntConvCoeff(state, SurfNum, SurfaceTemperatures(SurfNum), spaceMAT);
} else {
CalcISO15099WindowIntConvCoeff(
state, SurfNum, SurfaceTemperatures(SurfNum), state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum).MAT);
CalcISO15099WindowIntConvCoeff(state, SurfNum, SurfaceTemperatures(SurfNum), spaceMAT);
}

// Establish some lower limit to avoid a zero convection coefficient (and potential divide by zero problems)
Expand All @@ -340,8 +338,7 @@ void InitIntConvCoeff(EnergyPlusData &state,
} break;

case HcInt::ASTMC1340: {
CalcASTMC1340ConvCoeff(
state, SurfNum, SurfaceTemperatures(SurfNum), state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum).MAT);
CalcASTMC1340ConvCoeff(state, SurfNum, SurfaceTemperatures(SurfNum), spaceMAT);
} break;

default: {
Expand Down Expand Up @@ -2256,10 +2253,10 @@ void CalcCeilingDiffuserInletCorr(EnergyPlusData &state,
if (ACH <= 3.0) { // Use the other convection algorithm
if (!state.dataConstruction->Construct(state.dataSurface->Surface(SurfNum).Construction).TypeIsWindow) {
CalcASHRAEDetailedIntConvCoeff(
state, SurfNum, SurfaceTemperatures(SurfNum), state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum).MAT);
state, SurfNum, SurfaceTemperatures(SurfNum), state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).MAT);
} else {
CalcISO15099WindowIntConvCoeff(
state, SurfNum, SurfaceTemperatures(SurfNum), state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum).MAT);
state, SurfNum, SurfaceTemperatures(SurfNum), state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).MAT);
}
} else { // Use forced convection correlations
Real64 Tilt = state.dataSurface->Surface(SurfNum).Tilt;
Expand Down Expand Up @@ -2391,7 +2388,7 @@ void CalcTrombeWallIntConvCoeff(EnergyPlusData &state,
auto const &surface = state.dataSurface->Surface(SurfNum);
// Use ASHRAESimple correlation to give values for all the minor surfaces
CalcASHRAESimpleIntConvCoeff(
state, SurfNum, SurfaceTemperatures(SurfNum), state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum).MAT);
state, SurfNum, SurfaceTemperatures(SurfNum), state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).MAT);

// assign the convection coefficent to the major surfaces and any subsurfaces on them
if ((surface.BaseSurf == Surf1) || (surface.BaseSurf == Surf2)) {
Expand Down Expand Up @@ -2726,7 +2723,7 @@ void CalcISO15099WindowIntConvCoeff(EnergyPlusData &state,

// Get humidity ratio
Real64 AirHumRat =
(surface.Zone > 0) ? state.dataZoneTempPredictorCorrector->zoneHeatBalance(surface.Zone).airHumRatAvg : state.dataEnvrn->OutHumRat;
(surface.spaceNum > 0) ? state.dataZoneTempPredictorCorrector->spaceHeatBalance(surface.spaceNum).airHumRatAvg : state.dataEnvrn->OutHumRat;

Real64 Height = surface.Height;
Real64 TiltDeg = surface.Tilt;
Expand Down Expand Up @@ -3152,8 +3149,9 @@ Real64 EvaluateIntHcModels(EnergyPlusData &state, int const SurfNum, HcInt const
auto const &surfIntConv = state.dataSurface->surfIntConv(SurfNum);

int const ZoneNum = thisSurface.Zone;
int const spaceNum = thisSurface.spaceNum;
Real64 const Tsurface = state.dataHeatBalSurf->SurfInsideTempHist(1)(SurfNum);
Real64 const Tzone = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum).MAT;
Real64 const Tzone = state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).MAT;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, got the zone temp from the space structure now...is that just a renamed struct or a different struct entirely?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different struct entirely.


auto &HnFn = state.dataSurfaceGeometry->kivaManager.surfaceConvMap[SurfNum].in;
// now call appropriate function to calculate Hc
Expand Down Expand Up @@ -3977,6 +3975,7 @@ void DynamicIntConvSurfaceClassification(EnergyPlusData &state, int const SurfNu

auto &surface = state.dataSurface->Surface(SurfNum);
int zoneNum = surface.Zone;
int spaceNum = surface.spaceNum;
auto &zone = state.dataHeatBal->Zone(zoneNum);

EquipOnCount = 0;
Expand Down Expand Up @@ -4068,7 +4067,7 @@ void DynamicIntConvSurfaceClassification(EnergyPlusData &state, int const SurfNu
if (surface.Class != SurfaceClass::Floor) continue;

Real64 DeltaTemp = state.dataHeatBalSurf->SurfInsideTempHist(1)(SurfLoop) -
state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).MAT;
state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).MAT;
if (DeltaTemp > ActiveDelTempThreshold) { // assume heating with floor
// system ON is not enough because floor surfaces can continue to heat because of thermal capacity
EquipOnCount = min(EquipOnCount + 1, MaxZoneEquipmentIdx);
Expand All @@ -4091,7 +4090,7 @@ void DynamicIntConvSurfaceClassification(EnergyPlusData &state, int const SurfNu
if (surface.Class != SurfaceClass::Roof) continue;

Real64 DeltaTemp = state.dataHeatBalSurf->SurfInsideTempHist(1)(SurfLoop) -
state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).MAT;
state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).MAT;
if (DeltaTemp < ActiveDelTempThreshold) { // assume cooling with ceiling
// system ON is not enough because surfaces can continue to cool because of thermal capacity
EquipOnCount = min(EquipOnCount + 1, MaxZoneEquipmentIdx);
Expand All @@ -4114,7 +4113,7 @@ void DynamicIntConvSurfaceClassification(EnergyPlusData &state, int const SurfNu
if (surface.Class != SurfaceClass::Wall && surface.Class != SurfaceClass::Door) continue;

DeltaTemp = state.dataHeatBalSurf->SurfInsideTempHist(1)(SurfLoop) -
state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).MAT;
state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).MAT;
if (DeltaTemp > ActiveDelTempThreshold) { // assume heating with wall panel
// system ON is not enough because surfaces can continue to heat because of thermal capacity
EquipOnCount = min(EquipOnCount + 1, MaxZoneEquipmentIdx);
Expand Down Expand Up @@ -4321,7 +4320,7 @@ void DynamicIntConvSurfaceClassification(EnergyPlusData &state, int const SurfNu
// now finish out specific model eq for this surface

int iDeltaTemp =
DeltaTempLambda(state.dataHeatBalSurf->SurfInsideTempHist(1)(SurfNum), state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).MAT);
DeltaTempLambda(state.dataHeatBalSurf->SurfInsideTempHist(1)(SurfNum), state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).MAT);
int iConvOrient = int(surface.convOrientation);

auto &surfIntConv = state.dataSurface->surfIntConv(SurfNum);
Expand Down Expand Up @@ -4499,7 +4498,8 @@ void DynamicIntConvSurfaceClassification(EnergyPlusData &state, int const SurfNu
} break; // D

case InConvFlowRegime::E: {
Real64 deltaTemp = state.dataHeatBalSurf->SurfInsideTempHist(1)(SurfNum) - state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).MAT;
Real64 deltaTemp =
state.dataHeatBalSurf->SurfInsideTempHist(1)(SurfNum) - state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).MAT;

switch (surface.Class) {
case SurfaceClass::Wall:
Expand Down Expand Up @@ -4657,6 +4657,7 @@ Real64 CalcUserDefinedIntHcModel(EnergyPlusData &state, int const SurfNum, int c

auto const &surface = state.dataSurface->Surface(SurfNum);
int zoneNum = state.dataSurface->Surface(SurfNum).Zone;
int spaceNum = state.dataSurface->Surface(SurfNum).spaceNum;
auto const &zone = state.dataHeatBal->Zone(zoneNum);

Real64 SumMdotTemp = 0.0;
Expand Down Expand Up @@ -4692,7 +4693,7 @@ Real64 CalcUserDefinedIntHcModel(EnergyPlusData &state, int const SurfNum, int c

switch (userCurve.refTempType) {
case RefTemp::MeanAirTemp:
tmpAirTemp = state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).MAT;
tmpAirTemp = state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).MAT;
state.dataSurface->SurfTAirRef(SurfNum) = DataSurfaces::RefAirTemp::ZoneMeanAirTemp;
break;
case RefTemp::AdjacentAirTemp:
Expand Down
36 changes: 2 additions & 34 deletions src/EnergyPlus/DataHeatBalance.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1325,40 +1325,8 @@ namespace DataHeatBalance {

struct SpaceZoneSimData // Calculated data by Space or Zone during each time step/hour
{
// Members
Real64 NOFOCC = 0.0; // Number of Occupants
Real64 QOCTOT = 0.0; // Total Energy from Occupants
Real64 QOCSEN = 0.0; // Sensible Energy from Occupants
Real64 QOCCON = 0.0; // ENERGY CONVECTED FROM OCCUPANTS (WH)
Real64 QOCRAD = 0.0; // ENERGY RADIATED FROM OCCUPANTS
Real64 QOCLAT = 0.0; // LATENT ENERGY FROM OCCUPANTS
Real64 QLTTOT = 0.0; // TOTAL ENERGY INTO LIGHTS (WH)
Real64 QLTCON = 0.0; // ENERGY CONVECTED TO SPACE AIR FROM LIGHTS
Real64 QLTRAD = 0.0; // ENERGY RADIATED TO SPACE FROM LIGHTS
Real64 QLTCRA = 0.0; // ENERGY CONVECTED TO RETURN AIR FROM LIGHTS
Real64 QLTSW = 0.0; // VISIBLE ENERGY FROM LIGHTS
Real64 QEECON = 0.0; // ENERGY CONVECTED FROM ELECTRIC EQUIPMENT
Real64 QEERAD = 0.0; // ENERGY RADIATED FROM ELECTRIC EQUIPMENT
Real64 QEELost = 0.0; // Energy from Electric Equipment (lost)
Real64 QEELAT = 0.0; // LATENT ENERGY FROM Electric Equipment
Real64 QGECON = 0.0; // ENERGY CONVECTED FROM GAS EQUIPMENT
Real64 QGERAD = 0.0; // ENERGY RADIATED FROM GAS EQUIPMENT
Real64 QGELost = 0.0; // Energy from Gas Equipment (lost)
Real64 QGELAT = 0.0; // LATENT ENERGY FROM Gas Equipment
Real64 QOECON = 0.0; // ENERGY CONVECTED FROM OTHER EQUIPMENT
Real64 QOERAD = 0.0; // ENERGY RADIATED FROM OTHER EQUIPMENT
Real64 QOELost = 0.0; // Energy from Other Equipment (lost)
Real64 QOELAT = 0.0; // LATENT ENERGY FROM Other Equipment
Real64 QHWCON = 0.0; // ENERGY CONVECTED FROM Hot Water EQUIPMENT
Real64 QHWRAD = 0.0; // ENERGY RADIATED FROM Hot Water EQUIPMENT
Real64 QHWLost = 0.0; // Energy from Hot Water Equipment (lost)
Real64 QHWLAT = 0.0; // LATENT ENERGY FROM Hot Water Equipment
Real64 QSECON = 0.0; // ENERGY CONVECTED FROM Steam EQUIPMENT
Real64 QSERAD = 0.0; // ENERGY RADIATED FROM Steam EQUIPMENT
Real64 QSELost = 0.0; // Energy from Steam Equipment (lost)
Real64 QSELAT = 0.0; // LATENT ENERGY FROM Steam Equipment
Real64 QBBCON = 0.0; // ENERGY CONVECTED FROM BASEBOARD HEATING
Real64 QBBRAD = 0.0; // ENERGY RADIATED FROM BASEBOARD HEATING
Real64 NOFOCC = 0.0; // Number of Occupants
Real64 QLTSW = 0.0; // VISIBLE ENERGY FROM LIGHTS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so, none of these deleted variables were actually being used in the heat balance. I suspect they once were before the more general internal heat gains functions were added.

};

struct SpaceIntGainDeviceData
Expand Down
21 changes: 11 additions & 10 deletions src/EnergyPlus/DataSurfaces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ Real64 SurfaceData::getInsideAirTemperature(EnergyPlusData &state, const int t_S
Real64 RefAirTemp = 0;

// determine reference air temperature for this surface
auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(this->Zone);
auto &thisSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(this->spaceNum);
switch (state.dataSurface->SurfTAirRef(t_SurfNum)) {
case RefAirTemp::ZoneMeanAirTemp: {
RefAirTemp = thisZoneHB.MAT;
RefAirTemp = thisSpaceHB.MAT;
} break;
case RefAirTemp::AdjacentAirTemp: {
RefAirTemp = state.dataHeatBal->SurfTempEffBulkAir(t_SurfNum);
Expand All @@ -248,24 +248,25 @@ Real64 SurfaceData::getInsideAirTemperature(EnergyPlusData &state, const int t_S
// determine supply air conditions
Real64 SumSysMCp = 0;
Real64 SumSysMCpT = 0;
for (int NodeNum = 1; NodeNum <= state.dataZoneEquip->ZoneEquipConfig(Zone).NumInletNodes; ++NodeNum) {
Real64 NodeTemp = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(Zone).InletNode(NodeNum)).Temp;
Real64 MassFlowRate = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(Zone).InletNode(NodeNum)).MassFlowRate;
Real64 CpAir = PsyCpAirFnW(thisZoneHB.airHumRat);
SumSysMCp += MassFlowRate * CpAir;
SumSysMCpT += MassFlowRate * CpAir * NodeTemp;
auto &inletNodes = (state.dataHeatBal->doSpaceHeatBalance) ? state.dataZoneEquip->spaceEquipConfig(this->spaceNum).InletNode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see! I guess the ternary could be slightly more readable if you had a reference like auto &thisSpace and auto &thisZone, but that's OK.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used this form because a normal if block restricts the scope of the reference. Is there a better way to do this?

Copy link
Member

@Myoldmopar Myoldmopar Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just mean before:

auto &inletNodes = (state.dataHeatBal->doSpaceHeatBalance) ? state.dataZoneEquip->spaceEquipConfig(this->spaceNum).InletNode
                                                           : state.dataZoneEquip->ZoneEquipConfig(Zone).InletNode;

after:

auto & spaceEquip = state.dataZoneEquip->spaceEquipConfig(this->spaceNum);
auto & zoneEquip = state.dataZoneEquip->ZoneEquipConfig(Zone);
auto & inletNodes = state.dataHeatBal->doSpaceHeatBalance ? spaceEquip.InletNode : zoneEquip.InletNode;

No functional change, the ternary is just quite long and looks a little funny with the dangling indentation on the second line. Feel free to ignore this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, there is a unit test that covers this, and it blew up with the suggested change, because spaceEquipConfig isn't allocated if there isn't any doSpaceHeatBalance, so, I'm keeping this code as-is (but fixing the line below). If there's a way to assign a reference in an if block and have it live outside the if context, I'd love to know how to do that.

: state.dataZoneEquip->ZoneEquipConfig(Zone).InletNode;
for (int nodeNum : inletNodes) {
auto &inNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(Zone).InletNode(nodeNum));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the comment above, I realize this line is incorrect and should have caused a subscript error, but this code is not covered in the integration tests, how is that? Nothing in the integration tests ever sets
state.dataSurface->SurfTAirRef(SurfNum) = DataSurfaces::RefAirTemp::ZoneSupplyAirTemp

Anyways, will address this shortly along with other comments.

Real64 CpAir = PsyCpAirFnW(thisSpaceHB.airHumRat);
SumSysMCp += inNode.MassFlowRate * CpAir;
SumSysMCpT += inNode.MassFlowRate * CpAir * inNode.Temp;
}
// a weighted average of the inlet temperatures.
if (SumSysMCp > 0.0) {
// a weighted average of the inlet temperatures.
RefAirTemp = SumSysMCpT / SumSysMCp;
} else {
RefAirTemp = thisZoneHB.MAT;
RefAirTemp = thisSpaceHB.MAT;
}
} break;
default: {
// currently set to mean air temp but should add error warning here
RefAirTemp = thisZoneHB.MAT;
RefAirTemp = thisSpaceHB.MAT;
} break;
}

Expand Down
Loading