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

Remove duplicate code with surface reference air temperature #8944

Merged
merged 12 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion src/EnergyPlus/DataSurfaces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,12 @@ Real64 SurfaceData::getInsideAirTemperature(EnergyPlusData &state, const int t_S
SumSysMCpT += MassFlowRate * CpAir * NodeTemp;
}
// a weighted average of the inlet temperatures.
RefAirTemp = SumSysMCpT / SumSysMCp;
if (SumSysMCp > 0.0) {
// a weighted average of the inlet temperatures.
RefAirTemp = SumSysMCpT / SumSysMCp;
} else {
RefAirTemp = state.dataHeatBalFanSys->MAT(Zone);
}
} else {
// currently set to mean air temp but should add error warning here
RefAirTemp = state.dataHeatBalFanSys->MAT(Zone);
Expand Down
91 changes: 6 additions & 85 deletions src/EnergyPlus/HeatBalanceSurfaceManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6614,54 +6614,12 @@ void CalcHeatBalanceInsideSurf2(EnergyPlusData &state,

// determine reference air temperatures
for (int SurfNum : HTSurfs) {
int ZoneNum = Surface(SurfNum).Zone;

// These conditions are not used in every SurfNum loop here so we don't use them to skip surfaces
if (Surface(SurfNum).Class == SurfaceClass::TDD_Dome) continue; // Skip TDD:DOME objects. Inside temp is handled by TDD:DIFFUSER.

{
auto const SELECT_CASE_var(state.dataSurface->SurfTAirRef(SurfNum));
if (SELECT_CASE_var == ZoneMeanAirTemp) {
state.dataHeatBalSurfMgr->RefAirTemp(SurfNum) = state.dataHeatBalFanSys->MAT(ZoneNum);
state.dataHeatBal->SurfTempEffBulkAir(SurfNum) = state.dataHeatBalFanSys->MAT(ZoneNum); // for reporting surf adjacent air temp
} else if (SELECT_CASE_var == AdjacentAirTemp) {
state.dataHeatBalSurfMgr->RefAirTemp(SurfNum) = state.dataHeatBal->SurfTempEffBulkAir(SurfNum);
} else if (SELECT_CASE_var == ZoneSupplyAirTemp) {
// determine ZoneEquipConfigNum for this zone
int ZoneEquipConfigNum = ZoneNum;
// check whether this zone is a controlled zone or not
if (!state.dataHeatBal->Zone(ZoneNum).IsControlled) {
ShowFatalError(state,
"Zones must be controlled for Ceiling-Diffuser Convection model. No system serves zone " +
state.dataHeatBal->Zone(ZoneNum).Name);
return;
}
// determine supply air conditions
Real64 SumSysMCp = 0.0;
Real64 SumSysMCpT = 0.0;
Real64 const CpAir = Psychrometrics::PsyCpAirFnW(state.dataHeatBalFanSys->ZoneAirHumRat(ZoneNum));
for (int NodeNum = 1; NodeNum <= state.dataZoneEquip->ZoneEquipConfig(ZoneEquipConfigNum).NumInletNodes; ++NodeNum) {
Real64 NodeTemp = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ZoneEquipConfigNum).InletNode(NodeNum)).Temp;
Real64 MassFlowRate =
state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ZoneEquipConfigNum).InletNode(NodeNum)).MassFlowRate;
// Real64 CpAir2 = PsyCpAirFnW(ZoneAirHumRat(ZoneNum), NodeTemp);
SumSysMCp += MassFlowRate * CpAir;
SumSysMCpT += MassFlowRate * CpAir * NodeTemp;
}
// a weighted average of the inlet temperatures.
if (SumSysMCp > 0.0) { // protect div by zero
state.dataHeatBalSurfMgr->RefAirTemp(SurfNum) = SumSysMCpT / SumSysMCp; // BG changed 02-16-2005 to add index (SurfNum)
} else {
state.dataHeatBalSurfMgr->RefAirTemp(SurfNum) = state.dataHeatBalFanSys->MAT(ZoneNum);
}
state.dataHeatBal->SurfTempEffBulkAir(SurfNum) =
state.dataHeatBalSurfMgr->RefAirTemp(SurfNum); // for reporting surf adjacent air temp
} else {
// currently set to mean air temp but should add error warning here
state.dataHeatBalSurfMgr->RefAirTemp(SurfNum) = state.dataHeatBalFanSys->MAT(ZoneNum);
state.dataHeatBal->SurfTempEffBulkAir(SurfNum) = state.dataHeatBalFanSys->MAT(ZoneNum); // for reporting surf adjacent air temp
}
}
Real64 RefAirTemp = state.dataSurface->Surface(SurfNum).getInsideAirTemperature(state, SurfNum);
state.dataHeatBalSurfMgr->RefAirTemp(SurfNum) = RefAirTemp;
state.dataHeatBal->SurfTempEffBulkAir(SurfNum) = state.dataHeatBalSurfMgr->RefAirTemp(SurfNum);
}

// Following variables must be reset due to possible recall of this routine by radiant and Resimulate routines.
Expand Down Expand Up @@ -7544,46 +7502,9 @@ void CalcHeatBalanceInsideSurf2CTFOnly(EnergyPlusData &state,
state.dataHeatBalSurf->SurfIsOperatingPool(surfNum) = 0;
}
}
auto const SELECT_CASE_var(state.dataSurface->SurfTAirRef(surfNum));
if (SELECT_CASE_var == ZoneMeanAirTemp) {
state.dataHeatBalSurfMgr->RefAirTemp(surfNum) = state.dataHeatBalFanSys->MAT(zoneNum);
state.dataHeatBal->SurfTempEffBulkAir(surfNum) = state.dataHeatBalFanSys->MAT(zoneNum); // for reporting surf adjacent air temp
} else if (SELECT_CASE_var == AdjacentAirTemp) {
state.dataHeatBalSurfMgr->RefAirTemp(surfNum) = state.dataHeatBal->SurfTempEffBulkAir(surfNum);
} else if (SELECT_CASE_var == ZoneSupplyAirTemp) {
// determine ZoneEquipConfigNum for this zone
int ZoneEquipConfigNum = zoneNum;
// check whether this zone is a controlled zone or not
if (!state.dataHeatBal->Zone(zoneNum).IsControlled) {
ShowFatalError(state,
"Zones must be controlled for Ceiling-Diffuser Convection model. No system serves zone " +
state.dataHeatBal->Zone(zoneNum).Name);
return;
}
// determine supply air conditions
Real64 SumSysMCp = 0.0;
Real64 SumSysMCpT = 0.0;
Real64 const CpAir = Psychrometrics::PsyCpAirFnW(state.dataHeatBalFanSys->ZoneAirHumRat(zoneNum));
for (int NodeNum = 1; NodeNum <= state.dataZoneEquip->ZoneEquipConfig(ZoneEquipConfigNum).NumInletNodes; ++NodeNum) {
Real64 NodeTemp = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ZoneEquipConfigNum).InletNode(NodeNum)).Temp;
Real64 MassFlowRate =
state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ZoneEquipConfigNum).InletNode(NodeNum)).MassFlowRate;
SumSysMCp += MassFlowRate * CpAir;
SumSysMCpT += MassFlowRate * CpAir * NodeTemp;
}
// a weighted average of the inlet temperatures.
if (SumSysMCp > 0.0) { // protect div by zero
state.dataHeatBalSurfMgr->RefAirTemp(surfNum) = SumSysMCpT / SumSysMCp; // BG changed 02-16-2005 to add index (SurfNum)
} else {
state.dataHeatBalSurfMgr->RefAirTemp(surfNum) = state.dataHeatBalFanSys->MAT(zoneNum);
}
state.dataHeatBal->SurfTempEffBulkAir(surfNum) =
state.dataHeatBalSurfMgr->RefAirTemp(surfNum); // for reporting surf adjacent air temp
} else {
// currently set to mean air temp but should add error warning here
state.dataHeatBalSurfMgr->RefAirTemp(surfNum) = state.dataHeatBalFanSys->MAT(zoneNum);
state.dataHeatBal->SurfTempEffBulkAir(surfNum) = state.dataHeatBalFanSys->MAT(zoneNum); // for reporting surf adjacent air temp
}
Real64 RefAirTemp = state.dataSurface->Surface(surfNum).getInsideAirTemperature(state, surfNum);
state.dataHeatBalSurfMgr->RefAirTemp(surfNum) = RefAirTemp;
state.dataHeatBal->SurfTempEffBulkAir(surfNum) = state.dataHeatBalSurfMgr->RefAirTemp(surfNum);
}

// Following variables must be reset due to possible recall of this routine by radiant and Resimulate routines.
Expand Down
109 changes: 8 additions & 101 deletions src/EnergyPlus/WindowComplexManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#include <EnergyPlus/DataSurfaces.hh>
#include <EnergyPlus/DataSystemVariables.hh>
#include <EnergyPlus/DataZoneEquipment.hh>
#include <EnergyPlus/HeatBalanceSurfaceManager.hh>
#include <EnergyPlus/Material.hh>
#include <EnergyPlus/PierceSurface.hh>
#include <EnergyPlus/Psychrometrics.hh>
Expand Down Expand Up @@ -2617,19 +2618,11 @@ namespace WindowComplexManager {

int TotLay; // Total number of layers in a construction
// (sum of solid layers and gap layers)
int Lay; // Layer number
int LayPtr; // Material number for a layer
int IGlass; // glass layer number (1,2,3,...)
int IGap; // Gap layer number (1,2,...)
int TotGlassLay; // Total number of glass layers in a construction
int ZoneEquipConfigNum;
int NodeNum;
Real64 SumSysMCp; // Zone sum of air system MassFlowRate*Cp
Real64 SumSysMCpT; // Zone sum of air system MassFlowRate*Cp*T
Real64 MassFlowRate;
Real64 NodeTemp;
Real64 CpAir;
Real64 RefAirTemp; // reference air temperatures
int Lay; // Layer number
int LayPtr; // Material number for a layer
int IGlass; // glass layer number (1,2,3,...)
int IGap; // Gap layer number (1,2,...)
int TotGlassLay; // Total number of glass layers in a construction
int k; // Layer counter
int SurfNumAdj; // An interzone surface's number in the adjacent zone
int ZoneNumAdj; // An interzone surface's adjacent zone number
Expand Down Expand Up @@ -2736,100 +2729,14 @@ namespace WindowComplexManager {

if (CalcCondition == DataBSDFWindow::Condition::Unassigned) {
ZoneNum = state.dataSurface->Surface(SurfNum).Zone;

// determine reference air temperature for this surface
{
auto const SELECT_CASE_var(state.dataSurface->SurfTAirRef(SurfNum));
if (SELECT_CASE_var == ZoneMeanAirTemp) {
RefAirTemp = state.dataHeatBalFanSys->MAT(ZoneNum);
} else if (SELECT_CASE_var == AdjacentAirTemp) {
RefAirTemp = state.dataHeatBal->SurfTempEffBulkAir(SurfNum);
} else if (SELECT_CASE_var == ZoneSupplyAirTemp) {
// determine ZoneEquipConfigNum for this zone
// ControlledZoneAirFlag = .FALSE.
ZoneEquipConfigNum = ZoneNum;
// DO ZoneEquipConfigNum = 1, NumOfControlledZones
// IF (ZoneEquipConfig(ZoneEquipConfigNum)%ActualZoneNum /= ZoneNum) CYCLE
// ControlledZoneAirFlag = .TRUE.
// EXIT
// END DO ! ZoneEquipConfigNum
// check whether this zone is a controlled zone or not
if (!state.dataHeatBal->Zone(ZoneNum).IsControlled) {
ShowFatalError(state,
"Zones must be controlled for Ceiling-Diffuser Convection model. No system serves zone " +
state.dataHeatBal->Zone(ZoneNum).Name);
return;
}
// determine supply air conditions
SumSysMCp = 0.0;
SumSysMCpT = 0.0;
for (NodeNum = 1; NodeNum <= state.dataZoneEquip->ZoneEquipConfig(ZoneEquipConfigNum).NumInletNodes; ++NodeNum) {
NodeTemp = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ZoneEquipConfigNum).InletNode(NodeNum)).Temp;
MassFlowRate =
state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ZoneEquipConfigNum).InletNode(NodeNum)).MassFlowRate;
CpAir = PsyCpAirFnW(state.dataHeatBalFanSys->ZoneAirHumRat(ZoneNum));
SumSysMCp += MassFlowRate * CpAir;
SumSysMCpT += MassFlowRate * CpAir * NodeTemp;
}
// a weighted average of the inlet temperatures.
if (SumSysMCp > 0.0) {
RefAirTemp = SumSysMCpT / SumSysMCp;
} else {
RefAirTemp = state.dataHeatBalFanSys->MAT(ZoneNum);
}
} else {
// currently set to mean air temp but should add error warning here
RefAirTemp = state.dataHeatBalFanSys->MAT(ZoneNum);
}
}

Real64 RefAirTemp = state.dataSurface->Surface(SurfNum).getInsideAirTemperature(state, SurfNum);
tind = RefAirTemp + DataGlobalConstants::KelvinConv; // Inside air temperature

// now get "outside" air temperature
if (SurfNumAdj > 0) { // Interzone window

ZoneNumAdj = state.dataSurface->Surface(SurfNumAdj).Zone;

// determine reference air temperature for this surface
{
auto const SELECT_CASE_var(state.dataSurface->SurfTAirRef(SurfNumAdj));
if (SELECT_CASE_var == ZoneMeanAirTemp) {
RefAirTemp = state.dataHeatBalFanSys->MAT(ZoneNumAdj);
} else if (SELECT_CASE_var == AdjacentAirTemp) {
RefAirTemp = state.dataHeatBal->SurfTempEffBulkAir(SurfNumAdj);
} else if (SELECT_CASE_var == ZoneSupplyAirTemp) {
// determine ZoneEquipConfigNum for this zone
ZoneEquipConfigNum = ZoneNum;
// check whether this zone is a controlled zone or not
if (!state.dataHeatBal->Zone(ZoneNum).IsControlled) {
ShowFatalError(state,
"Zones must be controlled for Ceiling-Diffuser Convection model. No system serves zone " +
state.dataHeatBal->Zone(ZoneNum).Name);
return;
}
// determine supply air conditions
SumSysMCp = 0.0;
SumSysMCpT = 0.0;
for (NodeNum = 1; NodeNum <= state.dataZoneEquip->ZoneEquipConfig(ZoneEquipConfigNum).NumInletNodes; ++NodeNum) {
NodeTemp = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ZoneEquipConfigNum).InletNode(NodeNum)).Temp;
MassFlowRate =
state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ZoneEquipConfigNum).InletNode(NodeNum)).MassFlowRate;
CpAir = PsyCpAirFnW(state.dataHeatBalFanSys->ZoneAirHumRat(ZoneNumAdj));
SumSysMCp += MassFlowRate * CpAir;
SumSysMCpT += MassFlowRate * CpAir * NodeTemp;
}
// a weighted average of the inlet temperatures.
if (SumSysMCp > 0.0) {
RefAirTemp = SumSysMCpT / SumSysMCp;
} else {
RefAirTemp = state.dataHeatBalFanSys->MAT(ZoneNumAdj);
}
} else {
// currently set to mean air temp but should add error warning here
RefAirTemp = state.dataHeatBalFanSys->MAT(ZoneNumAdj);
}
}

RefAirTemp = state.dataSurface->Surface(SurfNumAdj).getInsideAirTemperature(state, SurfNumAdj);
tout = RefAirTemp + DataGlobalConstants::KelvinConv; // outside air temperature

tsky = state.dataHeatBal->ZoneMRT(ZoneNumAdj) +
Expand Down
Loading