Skip to content

Commit

Permalink
Merge pull request #10535 from NREL/10524_SetpointManagerReturnTemper…
Browse files Browse the repository at this point in the history
…ature_FluidIndex

#10524 - SetpointManager:ReturnTemperature:Chilled/HotWater (useless) warnings from GetSpecificHeatGlycol
  • Loading branch information
Myoldmopar authored Jun 12, 2024
2 parents b0a82c1 + 3fc239f commit 517cb2d
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 18 deletions.
22 changes: 10 additions & 12 deletions src/EnergyPlus/SetPointManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3856,14 +3856,12 @@ void SPMReturnWaterTemp::calculate(EnergyPlusData &state)
// we need to know the plant to get the fluid ID in case it is glycol
// but we have to wait in case plant isn't initialized yet
// if plant isn't initialized, assume index=1 (water)
int fluidIndex = 1;
if (this->plantLoopNum == 0) {
for (int LoopNum = 1; LoopNum <= state.dataPlnt->TotNumLoops; ++LoopNum) {
auto &plantLoop = state.dataPlnt->PlantLoop(LoopNum);
if (this->supplyNodeNum == plantLoop.LoopSide(DataPlant::LoopSideLocation::Supply).NodeNumOut) {
this->plantLoopNum = LoopNum;
this->plantSetPtNodeNum = plantLoop.TempSetPointNodeNum;
fluidIndex = plantLoop.FluidIndex;
// now that we've found the plant populated, let's verify that the nodes match
if (!PlantUtilities::verifyTwoNodeNumsOnSamePlantLoop(state, this->supplyNodeNum, this->returnNodeNum)) {
ShowSevereError(state, "Node problem for SetpointManager:ReturnTemperature:ChilledWater.");
Expand All @@ -3874,19 +3872,19 @@ void SPMReturnWaterTemp::calculate(EnergyPlusData &state)
}
}

// we don't need fluid names since we have a real index, so just pass in the temperature and get properties
Real64 avgTemp = (returnNode.Temp + supplyNode.Temp) / 2;
Real64 cp = FluidProperties::GetSpecificHeatGlycol(state, "", avgTemp, fluidIndex, "ReturnWaterChWSetPointManager::calculate");

// get the operating flow rate
Real64 mdot = supplyNode.MassFlowRate;
Real64 const mdot = supplyNode.MassFlowRate;
Real64 const deltaT = (this->type == SPMType::ChilledWaterReturnTemp) ? (returnNode.Temp - supplyNode.Temp) : (supplyNode.Temp - returnNode.Temp);

// calculate the current demand
Real64 Qdemand =
mdot * cp * ((this->type == SPMType::ChilledWaterReturnTemp) ? (returnNode.Temp - supplyNode.Temp) : (supplyNode.Temp - returnNode.Temp));
// // calculate the current demand
// fluidIndex = state.dataPlnt->PlantLoop(this->plantLoopNum).FluidIndex;
// // we don't need fluid names since we have a real index, so just pass in the temperature and get properties
// Real64 const avgTemp = (returnNode.Temp + supplyNode.Temp) / 2;
// Real64 const cp = FluidProperties::GetSpecificHeatGlycol(state, "", avgTemp, fluidIndex, "ReturnWaterChWSetPointManager::calculate");
// Real64 const Qdemand = mdot * cp * deltaT;

// check for strange conditions
if (Qdemand < 0) {
if (deltaT < 0) {
this->currentSupplySetPt = (this->type == SPMType::ChilledWaterReturnTemp) ? this->minSetTemp : this->maxSetTemp;
return;
}
Expand Down Expand Up @@ -3917,7 +3915,7 @@ void SPMReturnWaterTemp::calculate(EnergyPlusData &state)
// calculate the supply setpoint to use, default to the design value if flow is zero
Real64 T_supply_setpoint = (this->type == SPMType::ChilledWaterReturnTemp) ? this->minSetTemp : this->maxSetTemp;
if (mdot > DataConvergParams::PlantFlowRateToler) {
T_supply_setpoint = T_return_target + ((this->type == SPMType::ChilledWaterReturnTemp) ? -Qdemand : Qdemand) / (mdot * cp);
T_supply_setpoint = T_return_target + ((this->type == SPMType::ChilledWaterReturnTemp) ? -deltaT : deltaT);
}

this->currentSupplySetPt = std::clamp(T_supply_setpoint, this->minSetTemp, this->maxSetTemp);
Expand Down
86 changes: 80 additions & 6 deletions tst/EnergyPlus/unit/SetPointManager.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include <EnergyPlus/DataLoopNode.hh>
#include <EnergyPlus/DataZoneEnergyDemands.hh>
#include <EnergyPlus/DataZoneEquipment.hh>
#include <EnergyPlus/FluidProperties.hh>
#include <EnergyPlus/HeatBalanceManager.hh>
#include <EnergyPlus/MixedAir.hh>
#include <EnergyPlus/NodeInputManager.hh>
Expand Down Expand Up @@ -175,9 +176,83 @@ TEST_F(EnergyPlusFixture, SetPointManager_DefineReturnWaterChWSetPointManager)
state->dataPlnt->PlantLoop.deallocate();
}

TEST_F(EnergyPlusFixture, SetPointManager_DefineReturnWaterHWSetPointManager)
TEST_F(EnergyPlusFixture, SetPointManager_DefineReturnWaterChWSetPointManager_FluidIndex)
{

std::string const idf_objects = delimited_string({
"FluidProperties:GlycolConcentration,",
" EthyleneGlycol40Percent, !- Name",
" EthyleneGlycol, !- Glycol Type",
" , !- User Defined Glycol Name",
" 0.4; !- Glycol Concentration",
});

ASSERT_TRUE(process_idf(idf_objects));

EXPECT_EQ(2, state->dataFluidProps->NumOfGlycols);
const auto &thisGlycol = state->dataFluidProps->GlycolData(2);
EXPECT_EQ("ETHYLENEGLYCOL40PERCENT", thisGlycol.Name);
EXPECT_EQ("ETHYLENEGLYCOL", thisGlycol.GlycolName);

// Set up the required plant loop data
state->dataPlnt->TotNumLoops = 1;
state->dataPlnt->PlantLoop.allocate(1);
state->dataPlnt->PlantLoop(1).FluidIndex = 2;

state->dataPlnt->PlantLoop(1).LoopSide(DataPlant::LoopSideLocation::Supply).NodeNumIn = 1; // Supply inlet, return
state->dataPlnt->PlantLoop(1).LoopSide(DataPlant::LoopSideLocation::Supply).NodeNumOut = 2; // Supply outlet, supply
state->dataPlnt->PlantLoop(1).LoopSide(DataPlant::LoopSideLocation::Demand).Branch.allocate(1);
state->dataPlnt->PlantLoop(1).LoopSide(DataPlant::LoopSideLocation::Demand).Branch(1).Comp.allocate(1);
state->dataPlnt->PlantLoop(1).LoopSide(DataPlant::LoopSideLocation::Supply).Branch.allocate(1);
state->dataPlnt->PlantLoop(1).LoopSide(DataPlant::LoopSideLocation::Supply).Branch(1).Comp.allocate(1);
state->dataPlnt->PlantLoop(1).LoopSide(DataPlant::LoopSideLocation::Demand).Branch(1).Comp(1).NodeNumIn = 0;
state->dataPlnt->PlantLoop(1).LoopSide(DataPlant::LoopSideLocation::Demand).Branch(1).Comp(1).NodeNumOut = 0;
state->dataPlnt->PlantLoop(1).LoopSide(DataPlant::LoopSideLocation::Supply).Branch(1).Comp(1).NodeNumIn = 1;
state->dataPlnt->PlantLoop(1).LoopSide(DataPlant::LoopSideLocation::Supply).Branch(1).Comp(1).NodeNumOut = 2;

// Set up the required node data
state->dataLoopNodes->Node.allocate(2);
state->dataLoopNodes->Node(2).MassFlowRate = 1.0;

// Set up a cooling setpoint manager
SetPointManager::SPMReturnWaterTemp mySPM;
mySPM.type = SetPointManager::SPMType::ChilledWaterReturnTemp;
mySPM.returnTempType = SetPointManager::ReturnTempType::Constant;
mySPM.returnNodeNum = 1;
mySPM.supplyNodeNum = 2;
mySPM.plantLoopNum = 0;
mySPM.minSetTemp = 7;
mySPM.maxSetTemp = 10;
mySPM.returnTempConstantTarget = 12;

// test 1: normal, in range
state->dataLoopNodes->Node(1).Temp = 11;
state->dataLoopNodes->Node(2).Temp = 7;
mySPM.calculate(*state);
// on the first pass through it should detect the plant loop it manages
EXPECT_EQ(1, mySPM.plantLoopNum);
// with a delta T of 4, and a target return of 12, it should produce 8
EXPECT_EQ(8, mySPM.currentSupplySetPt);

compare_err_stream("");

// Avg temp will be < 0, and before fix it throws this error
// ** Warning ** GetSpecificHeatGlycol: Temperature is out of range (too low) for fluid [WATER] specific heat supplied values **
// ** ~~~ ** ..Called From:ReturnWaterChWSetPointManager::calculate,Temperature=[-1.00], supplied data range=[0.00,125.00]
// ** ~~~ ** Environment=, at Simulation time= 00:00 - 00:00
state->dataLoopNodes->Node(1).Temp = 1;
state->dataLoopNodes->Node(2).Temp = -3;
// Calling it a second time, ensure #10524 is fixed
mySPM.calculate(*state);
// on the first pass through it should detect the plant loop it manages
EXPECT_EQ(1, mySPM.plantLoopNum);
// with a delta T of 4, and a target return of 12, it should produce 8
EXPECT_EQ(8, mySPM.currentSupplySetPt);
compare_err_stream("");
}

TEST_F(EnergyPlusFixture, SetPointManager_DefineReturnWaterHWSetPointManager)
{
// Set up the required plant loop data
state->dataPlnt->TotNumLoops = 1;
state->dataPlnt->PlantLoop.allocate(1);
Expand Down Expand Up @@ -427,7 +502,6 @@ TEST_F(EnergyPlusFixture, SetPointManager_DefineCondEntSetPointManager)

TEST_F(EnergyPlusFixture, SetPointManager_setupSetPointAndFlags)
{

Real64 totEnergy = 0.0;
Real64 totEnergyPrevious = 0.0;
Real64 condenserWaterSetPoint = 0.0;
Expand Down Expand Up @@ -516,7 +590,8 @@ TEST_F(EnergyPlusFixture, SetPointManager_setupSetPointAndFlags)
EXPECT_FALSE(statusRunSubOptimalCondenserEnteringTemp);
EXPECT_TRUE(statusRunFinalOptimalCondenserEnteringTemp);

// and finally, the sixth pass through when it is set to run final; totEnergy doesn't matter when that flag is true, and the sp shouldn't change
// and finally, the sixth pass through when it is set to run final; totEnergy doesn't matter when that flag is true, and the sp shouldn't
// change
thisSPM.setupSetPointAndFlags(totEnergy,
totEnergyPrevious,
condenserWaterSetPoint,
Expand Down Expand Up @@ -834,7 +909,6 @@ TEST_F(EnergyPlusFixture, SetPointManager_CalcSetPointLinInt)

TEST_F(EnergyPlusFixture, DefineMixedAirSetPointManager)
{

// Set up the required node data
state->dataLoopNodes->Node.allocate(5);
state->dataLoopNodes->Node(1).MassFlowRate = 1.0;
Expand Down Expand Up @@ -886,7 +960,6 @@ TEST_F(EnergyPlusFixture, DefineMixedAirSetPointManager)

TEST_F(EnergyPlusFixture, MixedAirSetPointManager_SameRefAndSPNodeName)
{

std::string const idf_objects = delimited_string({
"SetpointManager:MixedAir,",
" Mixed Air Temp, !- Name",
Expand Down Expand Up @@ -1517,7 +1590,8 @@ TEST_F(EnergyPlusFixture, SingZoneCoolHeatSetPtMgrZoneInletNodeTest)
" ** Fatal ** InitSetPointManagers: Errors found in getting SetPointManager input.",
" ...Summary of Errors that led to program termination:",
" ..... Reference severe error count=2",
" ..... Last severe error=SetpointManager:SingleZone:Cooling=\"COOLING SUPPLY AIR TEMP MANAGER 1\", The zone inlet node of ZNF1 INLET NODE",
" ..... Last severe error=SetpointManager:SingleZone:Cooling=\"COOLING SUPPLY AIR TEMP MANAGER 1\", The zone inlet node of ZNF1 INLET "
"NODE",
});

EXPECT_TRUE(compare_err_stream(error_string, true));
Expand Down

10 comments on commit 517cb2d

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

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

develop (Myoldmopar) - x86_64-MacOS-10.18-clang-15.0.0: OK (2809 of 2809 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

develop (Myoldmopar) - Win64-Windows-10-VisualStudio-16: OK (2808 of 2808 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

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

10552EnclosureOutputVariableNameCorrection (Myoldmopar) - x86_64-MacOS-10.18-clang-15.0.0: OK (3597 of 3597 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

10552EnclosureOutputVariableNameCorrection (Myoldmopar) - Win64-Windows-10-VisualStudio-16: OK (2808 of 2808 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

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

develop (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (2830 of 2830 tests passed, 0 test warnings)

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.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (792 of 792 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

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

develop (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (2019 of 2019 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

10552EnclosureOutputVariableNameCorrection (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3638 of 3638 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

10552EnclosureOutputVariableNameCorrection (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (2019 of 2019 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

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

10552EnclosureOutputVariableNameCorrection (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (792 of 792 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.