Skip to content

Commit

Permalink
Space HVAC - equip config inits
Browse files Browse the repository at this point in the history
  • Loading branch information
mjwitte committed Sep 22, 2023
1 parent 394d7e7 commit db5518e
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 91 deletions.
95 changes: 95 additions & 0 deletions src/EnergyPlus/DataZoneEquipment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1979,4 +1979,99 @@ void ZoneEquipmentSplitter::distributeOutput(EnergyPlusData &state,
}
}

void EquipConfiguration::beginEnvirnInit(EnergyPlusData &state)
{
auto &zoneNode = state.dataLoopNodes->Node(this->ZoneNode);
zoneNode.Temp = 20.0;
zoneNode.MassFlowRate = 0.0;
zoneNode.Quality = 1.0;
zoneNode.Press = state.dataEnvrn->OutBaroPress;
zoneNode.HumRat = state.dataEnvrn->OutHumRat;
zoneNode.Enthalpy = Psychrometrics::PsyHFnTdbW(zoneNode.Temp, zoneNode.HumRat);
if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
zoneNode.CO2 = state.dataContaminantBalance->OutdoorCO2;
}
if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
zoneNode.GenContam = state.dataContaminantBalance->OutdoorGC;
}

for (int const nodeNum : this->InletNode) {
auto &inNode = state.dataLoopNodes->Node(nodeNum);
inNode.Temp = 20.0;
inNode.MassFlowRate = 0.0;
inNode.Quality = 1.0;
inNode.Press = state.dataEnvrn->OutBaroPress;
inNode.HumRat = state.dataEnvrn->OutHumRat;
inNode.Enthalpy = Psychrometrics::PsyHFnTdbW(inNode.Temp, inNode.HumRat);
if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
inNode.CO2 = state.dataContaminantBalance->OutdoorCO2;
}
if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
inNode.GenContam = state.dataContaminantBalance->OutdoorGC;
}
}

for (int const nodeNum : this->ExhaustNode) {
auto &exhNode = state.dataLoopNodes->Node(nodeNum);
exhNode.Temp = 20.0;
exhNode.MassFlowRate = 0.0;
exhNode.Quality = 1.0;
exhNode.Press = state.dataEnvrn->OutBaroPress;
exhNode.HumRat = state.dataEnvrn->OutHumRat;
exhNode.Enthalpy = Psychrometrics::PsyHFnTdbW(exhNode.Temp, exhNode.HumRat);
if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
exhNode.CO2 = state.dataContaminantBalance->OutdoorCO2;
}
if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
exhNode.GenContam = state.dataContaminantBalance->OutdoorGC;
}
}

// BG CR 7122 following resets return air node.
int NumRetNodes = this->NumReturnNodes;
if (NumRetNodes > 0) {
for (int const nodeNum : this->ReturnNode) {
auto &returnNode = state.dataLoopNodes->Node(nodeNum);
returnNode.Temp = 20.0;
returnNode.MassFlowRate = 0.0;
returnNode.Quality = 1.0;
returnNode.Press = state.dataEnvrn->OutBaroPress;
returnNode.HumRat = state.dataEnvrn->OutHumRat;
returnNode.Enthalpy = Psychrometrics::PsyHFnTdbW(returnNode.Temp, returnNode.HumRat);
if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
returnNode.CO2 = state.dataContaminantBalance->OutdoorCO2;
}
if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
returnNode.GenContam = state.dataContaminantBalance->OutdoorGC;
}
}
}
}

void EquipConfiguration::hvacTimeStepInit(EnergyPlusData &state, bool FirstHVACIteration)
{
auto &zoneNode = state.dataLoopNodes->Node(this->ZoneNode);
this->ExcessZoneExh = 0.0;

if (FirstHVACIteration) {
for (int const nodeNum : this->ExhaustNode) {
auto &exhNode = state.dataLoopNodes->Node(nodeNum);
exhNode.Temp = zoneNode.Temp;
exhNode.HumRat = zoneNode.HumRat;
exhNode.Enthalpy = zoneNode.Enthalpy;
exhNode.Press = zoneNode.Press;
exhNode.Quality = zoneNode.Quality;
exhNode.MassFlowRate = 0.0;
exhNode.MassFlowRateMaxAvail = 0.0;
exhNode.MassFlowRateMinAvail = 0.0;
if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
exhNode.CO2 = zoneNode.CO2;
}
if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
exhNode.GenContam = zoneNode.GenContam;
}
}
}
}

} // namespace EnergyPlus::DataZoneEquipment
4 changes: 4 additions & 0 deletions src/EnergyPlus/DataZoneEquipment.hh
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ namespace DataZoneEquipment {
}

void setTotalInletFlows(EnergyPlusData &state);

void beginEnvirnInit(EnergyPlusData &state);

void hvacTimeStepInit(EnergyPlusData &state, bool FirstHVACIteration);
};

struct EquipmentData // data for an individual component
Expand Down
107 changes: 16 additions & 91 deletions src/EnergyPlus/ZoneEquipmentManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,74 +264,14 @@ void InitZoneEquipment(EnergyPlusData &state, bool const FirstHVACIteration) //
}
}
}
for (int ControlledZoneNum = 1; ControlledZoneNum <= state.dataGlobal->NumOfZones; ++ControlledZoneNum) {
if (!state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).IsControlled) continue;

auto &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).ZoneNode);
zoneNode.Temp = 20.0;
zoneNode.MassFlowRate = 0.0;
zoneNode.Quality = 1.0;
zoneNode.Press = state.dataEnvrn->OutBaroPress;
zoneNode.HumRat = state.dataEnvrn->OutHumRat;
zoneNode.Enthalpy = PsyHFnTdbW(zoneNode.Temp, zoneNode.HumRat);
if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
zoneNode.CO2 = state.dataContaminantBalance->OutdoorCO2;
}
if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
zoneNode.GenContam = state.dataContaminantBalance->OutdoorGC;
}

for (int ZoneInNode = 1; ZoneInNode <= state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).NumInletNodes; ++ZoneInNode) {
auto &inNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).InletNode(ZoneInNode));
inNode.Temp = 20.0;
inNode.MassFlowRate = 0.0;
inNode.Quality = 1.0;
inNode.Press = state.dataEnvrn->OutBaroPress;
inNode.HumRat = state.dataEnvrn->OutHumRat;
inNode.Enthalpy = PsyHFnTdbW(inNode.Temp, inNode.HumRat);
if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
inNode.CO2 = state.dataContaminantBalance->OutdoorCO2;
}
if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
inNode.GenContam = state.dataContaminantBalance->OutdoorGC;
}
}

for (int ZoneExhNode = 1; ZoneExhNode <= state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).NumExhaustNodes; ++ZoneExhNode) {

auto &exhNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).ExhaustNode(ZoneExhNode));
exhNode.Temp = 20.0;
exhNode.MassFlowRate = 0.0;
exhNode.Quality = 1.0;
exhNode.Press = state.dataEnvrn->OutBaroPress;
exhNode.HumRat = state.dataEnvrn->OutHumRat;
exhNode.Enthalpy = PsyHFnTdbW(exhNode.Temp, exhNode.HumRat);
if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
exhNode.CO2 = state.dataContaminantBalance->OutdoorCO2;
}
if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
exhNode.GenContam = state.dataContaminantBalance->OutdoorGC;
}
}

// BG CR 7122 following resets return air node.
int NumRetNodes = state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).NumReturnNodes;
if (NumRetNodes > 0) {
for (int nodeCount = 1; nodeCount <= NumRetNodes; ++nodeCount) {
auto &returnNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).ReturnNode(nodeCount));
returnNode.Temp = 20.0;
returnNode.MassFlowRate = 0.0;
returnNode.Quality = 1.0;
returnNode.Press = state.dataEnvrn->OutBaroPress;
returnNode.HumRat = state.dataEnvrn->OutHumRat;
returnNode.Enthalpy = PsyHFnTdbW(returnNode.Temp, returnNode.HumRat);
if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
returnNode.CO2 = state.dataContaminantBalance->OutdoorCO2;
}
if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
returnNode.GenContam = state.dataContaminantBalance->OutdoorGC;
}
}
for (auto &thisZoneEquipConfig : state.dataZoneEquip->ZoneEquipConfig) {
if (!thisZoneEquipConfig.IsControlled) continue;
thisZoneEquipConfig.beginEnvirnInit(state);
}
if (state.dataHeatBal->doSpaceHeatBalanceSimulation) {
for (auto &thisSpaceEquipConfig : state.dataZoneEquip->spaceEquipConfig) {
if (!thisSpaceEquipConfig.IsControlled) continue;
thisSpaceEquipConfig.beginEnvirnInit(state);
}
}

Expand All @@ -344,29 +284,14 @@ void InitZoneEquipment(EnergyPlusData &state, bool const FirstHVACIteration) //

// do the HVAC time step initializations

for (int ControlledZoneNum = 1; ControlledZoneNum <= state.dataGlobal->NumOfZones; ++ControlledZoneNum) {
if (!state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).IsControlled) continue;
auto &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).ZoneNode);
state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).ExcessZoneExh = 0.0;

if (FirstHVACIteration) {
for (int ZoneExhNode = 1; ZoneExhNode <= state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).NumExhaustNodes; ++ZoneExhNode) {
auto &exhNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).ExhaustNode(ZoneExhNode));
exhNode.Temp = zoneNode.Temp;
exhNode.HumRat = zoneNode.HumRat;
exhNode.Enthalpy = zoneNode.Enthalpy;
exhNode.Press = zoneNode.Press;
exhNode.Quality = zoneNode.Quality;
exhNode.MassFlowRate = 0.0;
exhNode.MassFlowRateMaxAvail = 0.0;
exhNode.MassFlowRateMinAvail = 0.0;
if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
exhNode.CO2 = zoneNode.CO2;
}
if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
exhNode.GenContam = zoneNode.GenContam;
}
}
for (auto &thisZoneEquipConfig : state.dataZoneEquip->ZoneEquipConfig) {
if (!thisZoneEquipConfig.IsControlled) continue;
thisZoneEquipConfig.hvacTimeStepInit(state, FirstHVACIteration);
}
if (state.dataHeatBal->doSpaceHeatBalanceSimulation) {
for (auto &thisSpaceEquipConfig : state.dataZoneEquip->spaceEquipConfig) {
if (!thisSpaceEquipConfig.IsControlled) continue;
thisSpaceEquipConfig.hvacTimeStepInit(state, FirstHVACIteration);
}
}

Expand Down

4 comments on commit db5518e

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

SpaceSizingHVACFollowup (mjwitte) - Win64-Windows-10-VisualStudio-16: Build Failed

Failures:\n

API Test Summary

  • Failed: 10
  • notrun: 5

ConvertInputFormat Test Summary

  • Failed: 4
  • notrun: 1

integration Test Summary

  • Passed: 2
  • Failed: 786

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

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

SpaceSizingHVACFollowup (mjwitte) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3575 of 3576 tests passed, 0 test warnings)

Messages:\n

  • 1 test had: AUD diffs.
  • 1 test had: EIO diffs.
  • 1 test had: ESO big diffs.
  • 1 test had: MTD diffs.
  • 1 test had: MTR big diffs.
  • 1 test had: Table big diffs.

Failures:\n

regression Test Summary

  • Passed: 804
  • Failed: 1

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

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

SpaceSizingHVACFollowup (mjwitte) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (1963 of 1963 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

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

SpaceSizingHVACFollowup (mjwitte) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (789 of 789 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.