Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/develop' into fixup_late…
Browse files Browse the repository at this point in the history
…x_indoor_living_wall
  • Loading branch information
mjwitte committed May 28, 2024
2 parents 6259ee9 + 9a34ab8 commit d765b5a
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/EnergyPlus/DataZoneEquipment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1802,20 +1802,31 @@ void ZoneEquipmentMixer::setOutletConditions(EnergyPlusData &state)
Real64 sumEnthalpy = 0.0;
Real64 sumHumRat = 0.0;
Real64 sumCO2 = 0.0;
Real64 sumGenContam = 0.0;
Real64 sumPressure = 0.0;
Real64 sumFractions = 0.0;
auto &equipInletNode = state.dataLoopNodes->Node(this->zoneEquipInletNodeNum);
for (auto &mixerSpace : this->spaces) {
auto &spaceOutletNode = state.dataLoopNodes->Node(mixerSpace.spaceNodeNum);
sumEnthalpy += spaceOutletNode.Enthalpy * mixerSpace.fraction;
sumHumRat += spaceOutletNode.HumRat * mixerSpace.fraction;
sumCO2 += spaceOutletNode.CO2 * mixerSpace.fraction;
if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
sumCO2 += spaceOutletNode.CO2 * mixerSpace.fraction;
}
if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
sumGenContam += spaceOutletNode.GenContam * mixerSpace.fraction;
}
sumPressure += spaceOutletNode.Press * mixerSpace.fraction;
sumFractions += mixerSpace.fraction;
}
equipInletNode.Enthalpy = sumEnthalpy / sumFractions;
equipInletNode.HumRat = sumHumRat / sumFractions;
equipInletNode.CO2 = sumCO2 / sumFractions;
if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
equipInletNode.CO2 = sumCO2 / sumFractions;
}
if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
equipInletNode.GenContam = sumGenContam / sumFractions;
}
equipInletNode.Press = sumPressure / sumFractions;

// Use Enthalpy and humidity ratio to get outlet temperature from psych chart
Expand Down
2 changes: 0 additions & 2 deletions src/EnergyPlus/HeatBalanceManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1142,8 +1142,6 @@ namespace HeatBalanceManager {
if (state.dataHeatBal->ZoneAirMassFlow.InfiltrationTreatment == DataHeatBalance::InfiltrationFlow::Add ||
state.dataHeatBal->ZoneAirMassFlow.InfiltrationTreatment == DataHeatBalance::InfiltrationFlow::Adjust) {
state.dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance = true;
if (!state.dataContaminantBalance->Contaminant.CO2Simulation)
state.dataContaminantBalance->Contaminant.SimulateContaminants = true;
} else if (state.dataHeatBal->ZoneAirMassFlow.InfiltrationTreatment == DataHeatBalance::InfiltrationFlow::Invalid) {
state.dataHeatBal->ZoneAirMassFlow.InfiltrationTreatment = DataHeatBalance::InfiltrationFlow::Add;
state.dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance = true;
Expand Down
4 changes: 4 additions & 0 deletions src/EnergyPlus/VariableSpeedCoils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8337,6 +8337,10 @@ namespace VariableSpeedCoils {
state.dataLoopNodes->Node(AirOutletNode).CO2 = state.dataLoopNodes->Node(AirInletNode).CO2;
}

if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
state.dataLoopNodes->Node(AirOutletNode).GenContam = state.dataLoopNodes->Node(AirInletNode).GenContam;
}

if (varSpeedCoil.reportCoilFinalSizes) {
if (!state.dataGlobal->WarmupFlag && !state.dataGlobal->DoingHVACSizingSimulations && !state.dataGlobal->DoingSizing) {
if (varSpeedCoil.VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit ||
Expand Down
75 changes: 75 additions & 0 deletions tst/EnergyPlus/unit/VariableSpeedCoils.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
// EnergyPlus Headers
#include "Fixtures/EnergyPlusFixture.hh"
#include <EnergyPlus/Data/EnergyPlusData.hh>
#include <EnergyPlus/DataContaminantBalance.hh>
#include <EnergyPlus/DataEnvironment.hh>
#include <EnergyPlus/DataLoopNode.hh>
#include <EnergyPlus/InputProcessing/InputProcessor.hh>
Expand Down Expand Up @@ -7135,4 +7136,78 @@ TEST_F(EnergyPlusFixture, VariableSpeedCoils_ZeroRatedCoolingCapacity_Test)
state->dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirEnthalpy);
}

TEST_F(EnergyPlusFixture, VariableSpeedCoils_UpdateVarSpeedCoil_Test)
{
int coilNum = 1;
Real64 constexpr closeEnough = 0.001;
state->dataVariableSpeedCoils->VarSpeedCoil.allocate(1);
auto &thisVarSpeedCoil = state->dataVariableSpeedCoils->VarSpeedCoil(1);
state->dataLoopNodes->Node.allocate(2);
auto &thisInletNode = state->dataLoopNodes->Node(1);
auto &thisOutletNode = state->dataLoopNodes->Node(2);

// Set up test data
state->dataHVACGlobal->TimeStepSysSec = 60.0;
thisVarSpeedCoil.SimFlag = false; // not running (doesn't matter if it's running or not, this is mostly to test the GenContam fix)
thisVarSpeedCoil.InletAirDBTemp = 21.0;
thisVarSpeedCoil.InletAirHumRat = 0.003;
thisVarSpeedCoil.InletAirEnthalpy = 28.743;
thisVarSpeedCoil.InletWaterTemp = 0.0;
thisVarSpeedCoil.InletWaterEnthalpy = 0.0;
thisVarSpeedCoil.AirInletNodeNum = 1;
thisVarSpeedCoil.WaterInletNodeNum = 0;
thisVarSpeedCoil.AirOutletNodeNum = 2;
thisVarSpeedCoil.WaterOutletNodeNum = 0;
state->dataLoopNodes->Node(1).MassFlowRate = 0.123;
state->dataLoopNodes->Node(2).MassFlowRate = 0.0;
thisVarSpeedCoil.OutletAirDBTemp = 0.0;
thisVarSpeedCoil.OutletAirHumRat = 0.0;
thisVarSpeedCoil.OutletAirEnthalpy = 0.0;
thisVarSpeedCoil.OutletWaterTemp = -1.0;
thisVarSpeedCoil.OutletWaterEnthalpy = -10.0;
thisInletNode.Quality = 0.1;
thisInletNode.Press = 101234.;
thisInletNode.MassFlowRateMin = 0.1;
thisInletNode.MassFlowRateMax = 1.0;
thisInletNode.MassFlowRateMinAvail = 0.2;
thisInletNode.MassFlowRateMaxAvail = 0.9;
thisOutletNode.Quality = 0.0;
thisOutletNode.Press = 0.0;
thisOutletNode.MassFlowRateMin = 0.0;
thisOutletNode.MassFlowRateMax = 0.0;
thisOutletNode.MassFlowRateMinAvail = 0.0;
thisOutletNode.MassFlowRateMaxAvail = 0.0;
state->dataContaminantBalance->Contaminant.CO2Simulation = true;
thisInletNode.CO2 = 55.5;
thisOutletNode.CO2 = 0.0;
state->dataContaminantBalance->Contaminant.GenericContamSimulation = true;
thisInletNode.GenContam = 12.345;
thisOutletNode.GenContam = 0.0;
thisVarSpeedCoil.reportCoilFinalSizes = false;
thisVarSpeedCoil.VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed;

// Run the test
VariableSpeedCoils::UpdateVarSpeedCoil(*state, coilNum);

// Check the results
EXPECT_NEAR(thisVarSpeedCoil.Energy, 0.0, closeEnough);
EXPECT_NEAR(thisVarSpeedCoil.OutletAirDBTemp, thisVarSpeedCoil.InletAirDBTemp, closeEnough);
EXPECT_NEAR(thisVarSpeedCoil.OutletAirHumRat, thisVarSpeedCoil.InletAirHumRat, closeEnough);
EXPECT_NEAR(thisVarSpeedCoil.OutletAirEnthalpy, thisVarSpeedCoil.InletAirEnthalpy, closeEnough);
EXPECT_NEAR(thisVarSpeedCoil.OutletWaterTemp, thisVarSpeedCoil.InletWaterTemp, closeEnough);
EXPECT_NEAR(thisVarSpeedCoil.OutletWaterEnthalpy, thisVarSpeedCoil.InletWaterEnthalpy, closeEnough);
EXPECT_NEAR(thisOutletNode.MassFlowRate, thisInletNode.MassFlowRate, closeEnough);
EXPECT_NEAR(thisOutletNode.Temp, thisVarSpeedCoil.OutletAirDBTemp, closeEnough);
EXPECT_NEAR(thisOutletNode.HumRat, thisVarSpeedCoil.OutletAirHumRat, closeEnough);
EXPECT_NEAR(thisOutletNode.Enthalpy, thisVarSpeedCoil.OutletAirEnthalpy, closeEnough);
EXPECT_NEAR(thisOutletNode.Quality, thisInletNode.Quality, closeEnough);
EXPECT_NEAR(thisOutletNode.Press, thisInletNode.Press, closeEnough);
EXPECT_NEAR(thisOutletNode.MassFlowRateMin, thisInletNode.MassFlowRateMin, closeEnough);
EXPECT_NEAR(thisOutletNode.MassFlowRateMax, thisInletNode.MassFlowRateMax, closeEnough);
EXPECT_NEAR(thisOutletNode.MassFlowRateMinAvail, thisInletNode.MassFlowRateMinAvail, closeEnough);
EXPECT_NEAR(thisOutletNode.MassFlowRateMaxAvail, thisInletNode.MassFlowRateMaxAvail, closeEnough);
EXPECT_NEAR(thisOutletNode.CO2, thisInletNode.CO2, closeEnough);
EXPECT_NEAR(thisOutletNode.GenContam, thisInletNode.GenContam, closeEnough);
}

} // namespace EnergyPlus
9 changes: 9 additions & 0 deletions tst/EnergyPlus/unit/ZoneEquipmentManager.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5222,6 +5222,8 @@ TEST_F(EnergyPlusFixture, SpaceHVACMixerTest)
auto &mixSpace1Node = state->dataLoopNodes->Node(mixSpace1.spaceNodeNum);
auto &mixSpace2Node = state->dataLoopNodes->Node(mixSpace2.spaceNodeNum);
auto &mixSpace3Node = state->dataLoopNodes->Node(mixSpace3.spaceNodeNum);
state->dataContaminantBalance->Contaminant.CO2Simulation = true;
state->dataContaminantBalance->Contaminant.GenericContamSimulation = true;

// Case 1

Expand All @@ -5240,6 +5242,10 @@ TEST_F(EnergyPlusFixture, SpaceHVACMixerTest)
mixSpace2Node.Press = 100020.0;
mixSpace3Node.Press = 99400.0;

mixSpace1Node.GenContam = 10.0;
mixSpace2Node.GenContam = 20.0;
mixSpace3Node.GenContam = 30.0;

equipInletNode.Temp = 19.2;
equipInletNode.HumRat = 0.005;
equipInletNode.CO2 = 100.0;
Expand All @@ -5251,6 +5257,8 @@ TEST_F(EnergyPlusFixture, SpaceHVACMixerTest)
mixSpace1Node.HumRat * mixSpace1.fraction + mixSpace2Node.HumRat * mixSpace2.fraction + mixSpace3Node.HumRat * mixSpace3.fraction;
Real64 expectedInletCO2 =
mixSpace1Node.CO2 * mixSpace1.fraction + mixSpace2Node.CO2 * mixSpace2.fraction + mixSpace3Node.CO2 * mixSpace3.fraction;
Real64 expectedInletGenContam =
mixSpace1Node.GenContam * mixSpace1.fraction + mixSpace2Node.GenContam * mixSpace2.fraction + mixSpace3Node.GenContam * mixSpace3.fraction;
Real64 expectedInletPress =
mixSpace1Node.Press * mixSpace1.fraction + mixSpace2Node.Press * mixSpace2.fraction + mixSpace3Node.Press * mixSpace3.fraction;
Real64 expectedInletTemp = Psychrometrics::PsyTdbFnHW(expectedInletEnthalpy, expectedInletHumRat);
Expand All @@ -5259,6 +5267,7 @@ TEST_F(EnergyPlusFixture, SpaceHVACMixerTest)
EXPECT_NEAR(expectedInletTemp, equipInletNode.Temp, 0.0001);
EXPECT_NEAR(expectedInletHumRat, equipInletNode.HumRat, 0.0001);
EXPECT_NEAR(expectedInletCO2, equipInletNode.CO2, 0.0001);
EXPECT_NEAR(expectedInletGenContam, equipInletNode.GenContam, 0.0001);
EXPECT_NEAR(expectedInletPress, equipInletNode.Press, 0.0001);

equipInletNode.MassFlowRate = 0.1;
Expand Down

0 comments on commit d765b5a

Please sign in to comment.