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

Absorption chillerheater plant loop fixes #8556

Merged
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
108 changes: 77 additions & 31 deletions src/EnergyPlus/ChillerExhaustAbsorption.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,47 @@ namespace EnergyPlus::ChillerExhaustAbsorption {

void ExhaustAbsorberSpecs::simulate(EnergyPlusData &state, const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The changes are applied to both the Exhaust fired absorption chiller heater, and the gas fired absorption chiller heater. For each types of absorption chiller heater, the getDesignCapacities() and the simulate() functions would be check to identity the loop/branch type (chilled water, hot water, or condenser water).

{
DataPlant::BrLoopType brIdentity(DataPlant::BrLoopType::NoMatch);

int branchTotalComp = state.dataPlnt->PlantLoop(calledFromLocation.loopNum)
.LoopSide(calledFromLocation.loopSideNum)
.Branch(calledFromLocation.branchNum)
.TotalComponents;

for (int iComp = 1; iComp <= branchTotalComp; iComp++) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The revised code checks all the elements in an (exhaust or gas-fired) absorption chiller heat plant loop branch, to identity which (chilled water, hot water, or condensing water) branch it is simulating. This is in contrast to the original code where only head branch component is checked.

// kind of a hacky way to find the location of this, but it's what plantloopequip was doing
int compInletNodeNum = state.dataPlnt->PlantLoop(calledFromLocation.loopNum)
.LoopSide(calledFromLocation.loopSideNum)
.Branch(calledFromLocation.branchNum)
.Comp(iComp)
.NodeNumIn;

// Match inlet node name of calling branch to determine if this call is for heating or cooling
if (compInletNodeNum == this->ChillReturnNodeNum) { // Operate as chiller
brIdentity = DataPlant::BrLoopType::Chiller; // chiller
break;
} else if (compInletNodeNum == this->HeatReturnNodeNum) { // Operate as heater
brIdentity = DataPlant::BrLoopType::Heater; // heater
break;
} else if (compInletNodeNum == this->CondReturnNodeNum) { // called from condenser loop
brIdentity = DataPlant::BrLoopType::Condenser; // condenser
break;
} else {
brIdentity = DataPlant::BrLoopType::NoMatch;
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use an integer number (brIndentity) to identify the loop branch property: 1 for chilled water; 2 for hot water; 3 for condensing water; 0 indicates problem (no match).

Copy link
Member

Choose a reason for hiding this comment

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

This is kinda odd. If it is just an identifier and the value doesn't matter, this should be an enum class. I would like to see that changed before this is merged. I can make the change if needed, just let me know.

Copy link
Member

Choose a reason for hiding this comment

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

Much nicer than the magic numbers, thank you!


// kind of a hacky way to find the location of this, but it's what plantloopequip was doing
int BranchInletNodeNum =
state.dataPlnt->PlantLoop(calledFromLocation.loopNum).LoopSide(calledFromLocation.loopSideNum).Branch(calledFromLocation.branchNum).NodeNumIn;

// Match inlet node name of calling branch to determine if this call is for heating or cooling
if (BranchInletNodeNum == this->ChillReturnNodeNum) { // Operate as chiller
if (brIdentity == DataPlant::BrLoopType::Chiller) {
this->InCoolingMode = RunFlag != 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

After the current branch is identified, run the corresponding functions/code blocks to execute the simulation. Slightly reorganized from the original code.

this->initialize(state);
this->calcChiller(state, CurLoad);
this->updateCoolRecords(state, CurLoad, RunFlag);
} else if (BranchInletNodeNum == this->HeatReturnNodeNum) { // Operate as heater
} else if (brIdentity == DataPlant::BrLoopType::Heater) {
this->InHeatingMode = RunFlag != 0;
this->initialize(state);
this->calcHeater(state, CurLoad, RunFlag);
this->updateHeatRecords(state, CurLoad, RunFlag);
} else if (BranchInletNodeNum == this->CondReturnNodeNum) { // called from condenser loop
} else if (brIdentity == DataPlant::BrLoopType::Condenser) {
if (this->CDLoopNum > 0) {
PlantUtilities::UpdateChillerComponentCondenserSide(state,
this->CDLoopNum,
Expand All @@ -161,8 +185,8 @@ namespace EnergyPlus::ChillerExhaustAbsorption {
this->CondWaterFlowRate,
FirstHVACIteration);
}

} else { // Error, nodes do not match
} else {
// Error, nodes do not match
ShowSevereError(state, "Invalid call to Exhaust Absorber Chiller " + this->Name);
ShowContinueError(state, "Node connections in branch are not consistent with object nodes.");
ShowFatalError(state, "Preceding conditions cause termination.");
Expand All @@ -171,26 +195,48 @@ namespace EnergyPlus::ChillerExhaustAbsorption {

void ExhaustAbsorberSpecs::getDesignCapacities(EnergyPlusData &state, const PlantLocation &calledFromLocation, Real64 &MaxLoad, Real64 &MinLoad, Real64 &OptLoad)
{

// kind of a hacky way to find the location of this, but it's what plantloopequip was doing
int BranchInletNodeNum =
state.dataPlnt->PlantLoop(calledFromLocation.loopNum).LoopSide(calledFromLocation.loopSideNum).Branch(calledFromLocation.branchNum).NodeNumIn;

// Match inlet node name of calling branch to determine if this call is for heating or cooling
if (BranchInletNodeNum == this->ChillReturnNodeNum) { // Operate as chiller
MinLoad = this->NomCoolingCap * this->MinPartLoadRat;
MaxLoad = this->NomCoolingCap * this->MaxPartLoadRat;
OptLoad = this->NomCoolingCap * this->OptPartLoadRat;
} else if (BranchInletNodeNum == this->HeatReturnNodeNum) { // Operate as heater
Real64 Sim_HeatCap = this->NomCoolingCap * this->NomHeatCoolRatio; // W - nominal heating capacity
MinLoad = Sim_HeatCap * this->MinPartLoadRat;
MaxLoad = Sim_HeatCap * this->MaxPartLoadRat;
OptLoad = Sim_HeatCap * this->OptPartLoadRat;
} else if (BranchInletNodeNum == this->CondReturnNodeNum) { // called from condenser loop
MinLoad = 0.0;
MaxLoad = 0.0;
OptLoad = 0.0;
} else { // Error, nodes do not match
bool matchfound(false);

int branchTotalComp = state.dataPlnt->PlantLoop(calledFromLocation.loopNum)
.LoopSide(calledFromLocation.loopSideNum)
.Branch(calledFromLocation.branchNum)
.TotalComponents;

for (int iComp = 1; iComp <= branchTotalComp; iComp++) {
// kind of a hacky way to find the location of this, but it's what plantloopequip was doing
int compInletNodeNum = state.dataPlnt->PlantLoop(calledFromLocation.loopNum)
.LoopSide(calledFromLocation.loopSideNum)
.Branch(calledFromLocation.branchNum)
.Comp(iComp)
.NodeNumIn;

// Match inlet node name of calling branch to determine if this call is for heating or cooling
if (compInletNodeNum == this->ChillReturnNodeNum) { // Operate as chiller
MinLoad = this->NomCoolingCap * this->MinPartLoadRat;
MaxLoad = this->NomCoolingCap * this->MaxPartLoadRat;
OptLoad = this->NomCoolingCap * this->OptPartLoadRat;
matchfound = true;
break;
} else if (compInletNodeNum == this->HeatReturnNodeNum) { // Operate as heater
Real64 Sim_HeatCap = this->NomCoolingCap * this->NomHeatCoolRatio; // W - nominal heating capacity
MinLoad = Sim_HeatCap * this->MinPartLoadRat;
MaxLoad = Sim_HeatCap * this->MaxPartLoadRat;
OptLoad = Sim_HeatCap * this->OptPartLoadRat;
matchfound = true;
break;
} else if (compInletNodeNum == this->CondReturnNodeNum) { // called from condenser loop
MinLoad = 0.0;
MaxLoad = 0.0;
OptLoad = 0.0;
matchfound = true;
break;
} else {
matchfound = false;
}
}

if(!matchfound) {
// Error, nodes do not match
ShowSevereError(state, "SimExhaustAbsorber: Invalid call to Exhaust Absorbtion Chiller-Heater " + this->Name);
ShowContinueError(state, "Node connections in branch are not consistent with object nodes.");
ShowFatalError(state, "Preceding conditions cause termination.");
Expand Down Expand Up @@ -1629,7 +1675,7 @@ namespace EnergyPlus::ChillerExhaustAbsorption {
} else {
ShowSevereError(state, "CalcExhaustAbsorberChillerModel: Condenser flow = 0, for Exhaust Absorber Chiller=" + this->Name);
ShowContinueErrorTimeStamp(state, "");
ShowFatalError(state, "Program Terminates due to previous error condition.");
// ShowFatalError(state, "Program Terminates due to previous error condition.");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now do not show the fatal message and terminate any more--this is aligned with the kind of common treatment used in other type of chiller (electric or absorption) models.

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm.... OK, so if we show a severe then we need to fatal. If we aren't going to fatal then this needs to be a warning. But if it's a warning that could occur multiple times should we do a recurring warning message to avoid huge error files?

}
} else {
lCondSupplyTemp = lCondReturnTemp; // if air cooled condenser just set supply and return to same temperature
Expand Down
101 changes: 74 additions & 27 deletions src/EnergyPlus/ChillerGasAbsorption.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,50 @@ namespace EnergyPlus::ChillerGasAbsorption {

void GasAbsorberSpecs::simulate(EnergyPlusData &state, const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag)
{
DataPlant::BrLoopType brIdentity(DataPlant::BrLoopType::NoMatch);

int branchTotalComp = state.dataPlnt->PlantLoop(calledFromLocation.loopNum)
.LoopSide(calledFromLocation.loopSideNum)
.Branch(calledFromLocation.branchNum)
.TotalComponents;

for (int iComp = 1; iComp <= branchTotalComp; iComp++) {
// kind of a hacky way to find the location of this, but it's what plantloopequip was doing
int compInletNodeNum = state.dataPlnt->PlantLoop(calledFromLocation.loopNum)
.LoopSide(calledFromLocation.loopSideNum)
.Branch(calledFromLocation.branchNum)
.Comp(iComp)
.NodeNumIn;
// Match inlet node name of calling branch to determine if this call is for heating or cooling
if (compInletNodeNum == this->ChillReturnNodeNum) { // Operate as chiller
brIdentity = DataPlant::BrLoopType::Chiller;
break;
} else if (compInletNodeNum == this->HeatReturnNodeNum) { // Operate as heater
brIdentity = DataPlant::BrLoopType::Heater;
break;
} else if (compInletNodeNum == this->CondReturnNodeNum) { // called from condenser loop
brIdentity = DataPlant::BrLoopType::Condenser;
break;
} else {
brIdentity = DataPlant::BrLoopType::NoMatch;
}
}

// kind of a hacky way to find the location of this, but it's what plantloopequip was doing
int BranchInletNodeNum =
state.dataPlnt->PlantLoop(calledFromLocation.loopNum).LoopSide(calledFromLocation.loopSideNum).Branch(calledFromLocation.branchNum).NodeNumIn;

// Match inlet node name of calling branch to determine if this call is for heating or cooling
if (BranchInletNodeNum == this->ChillReturnNodeNum) { // Operate as chiller
if (brIdentity == DataPlant::BrLoopType::Chiller) {
// Calculate Node Values
// Calculate Equipment and Update Variables
this->InCoolingMode = RunFlag != 0;
this->initialize(state);
this->calculateChiller(state, CurLoad);
this->updateCoolRecords(state, CurLoad, RunFlag);
} else if (BranchInletNodeNum == this->HeatReturnNodeNum) { // Operate as heater
} else if (brIdentity == DataPlant::BrLoopType::Heater) {
// Calculate Node Values
// Calculate Equipment and Update Variables
this->InHeatingMode = RunFlag != 0;
this->initialize(state);
this->calculateHeater(state, CurLoad, RunFlag);
this->updateHeatRecords(state, CurLoad, RunFlag);
} else if (BranchInletNodeNum == this->CondReturnNodeNum) { // called from condenser loop
} else if (brIdentity == DataPlant::BrLoopType::Condenser) {
if (this->CDLoopNum > 0) {
PlantUtilities::UpdateChillerComponentCondenserSide(state,
this->CDLoopNum,
Expand All @@ -164,7 +187,8 @@ namespace EnergyPlus::ChillerGasAbsorption {
this->CondWaterFlowRate,
FirstHVACIteration);
}
} else { // Error, nodes do not match
} else {
// Error, nodes do not match
ShowSevereError(state, "Invalid call to Gas Absorber Chiller " + this->Name);
ShowContinueError(state, "Node connections in branch are not consistent with object nodes.");
ShowFatalError(state, "Preceding conditions cause termination.");
Expand All @@ -173,24 +197,47 @@ namespace EnergyPlus::ChillerGasAbsorption {

void GasAbsorberSpecs::getDesignCapacities(EnergyPlusData &state, const PlantLocation &calledFromLocation, Real64 &MaxLoad, Real64 &MinLoad, Real64 &OptLoad)
{
// kind of a hacky way to find the location of this, but it's what plantloopequip was doing
int BranchInletNodeNum =
state.dataPlnt->PlantLoop(calledFromLocation.loopNum).LoopSide(calledFromLocation.loopSideNum).Branch(calledFromLocation.branchNum).NodeNumIn;
bool matchfound(false);

int branchTotalComp = state.dataPlnt->PlantLoop(calledFromLocation.loopNum)
.LoopSide(calledFromLocation.loopSideNum)
.Branch(calledFromLocation.branchNum)
.TotalComponents;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The revised code will check all components in a branch, rather than just checking the branch head element as before.

for (int iComp = 1; iComp <= branchTotalComp; iComp++) {
// kind of a hacky way to find the location of this, but it's what plantloopequip was doing
int compInletNodeNum = state.dataPlnt->PlantLoop(calledFromLocation.loopNum)
.LoopSide(calledFromLocation.loopSideNum)
.Branch(calledFromLocation.branchNum)
.Comp(iComp)
.NodeNumIn;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still using the `hacky' way, but applied to all the components in the loop branch.

if (compInletNodeNum == this->ChillReturnNodeNum) { // Operate as chiller
MinLoad = this->NomCoolingCap * this->MinPartLoadRat;
MaxLoad = this->NomCoolingCap * this->MaxPartLoadRat;
OptLoad = this->NomCoolingCap * this->OptPartLoadRat;
matchfound = true;
break;
} else if (compInletNodeNum == this->HeatReturnNodeNum) { // Operate as heater
Real64 Sim_HeatCap = this->NomCoolingCap * this->NomHeatCoolRatio;
MinLoad = Sim_HeatCap * this->MinPartLoadRat;
MaxLoad = Sim_HeatCap * this->MaxPartLoadRat;
OptLoad = Sim_HeatCap * this->OptPartLoadRat;
matchfound = true;
break;
} else if (compInletNodeNum == this->CondReturnNodeNum) { // called from condenser loop
MinLoad = 0.0;
MaxLoad = 0.0;
OptLoad = 0.0;
matchfound = true;
break;
} else {
matchfound = false;
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If match found, update the loads values accordingly, break and return. Otherwise, continue to the next component check.


if (BranchInletNodeNum == this->ChillReturnNodeNum) { // Operate as chiller
MinLoad = this->NomCoolingCap * this->MinPartLoadRat;
MaxLoad = this->NomCoolingCap * this->MaxPartLoadRat;
OptLoad = this->NomCoolingCap * this->OptPartLoadRat;
} else if (BranchInletNodeNum == this->HeatReturnNodeNum) { // Operate as heater
Real64 Sim_HeatCap = this->NomCoolingCap * this->NomHeatCoolRatio;
MinLoad = Sim_HeatCap * this->MinPartLoadRat;
MaxLoad = Sim_HeatCap * this->MaxPartLoadRat;
OptLoad = Sim_HeatCap * this->OptPartLoadRat;
} else if (BranchInletNodeNum == this->CondReturnNodeNum) { // called from condenser loop
MinLoad = 0.0;
MaxLoad = 0.0;
OptLoad = 0.0;
} else { // Error, nodes do not match
if (!matchfound) {
// Error, nodes do not match
ShowSevereError(state, "SimGasAbsorber: Invalid call to Gas Absorbtion Chiller-Heater " + this->Name);
ShowContinueError(state, "Node connections in branch are not consistent with object nodes.");
ShowFatalError(state, "Preceding conditions cause termination.");
Expand Down Expand Up @@ -1565,7 +1612,7 @@ namespace EnergyPlus::ChillerGasAbsorption {
} else {
ShowSevereError(state, "CalcGasAbsorberChillerModel: Condenser flow = 0, for Gas Absorber Chiller=" + this->Name);
ShowContinueErrorTimeStamp(state, "");
ShowFatalError(state, "Program Terminates due to previous error condition.");
// ShowFatalError(state, "Program Terminates due to previous error condition.");
}
} else {
lCondSupplyTemp = lCondReturnTemp; // if air cooled condenser just set supply and return to same temperature
Expand Down
9 changes: 9 additions & 0 deletions src/EnergyPlus/Plant/Enums.hh
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ namespace EnergyPlus::DataPlant {
DualOp, // Constant for Cooling or Heating Operation
};

// branch loop type for absorption chillerheater models
enum class BrLoopType
{
Chiller,
Heater,
Condenser,
NoMatch
};
Copy link
Member

Choose a reason for hiding this comment

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

Yup, great! In a future set of changes the actual type name might be tailored a little more to the actual application, but this is fine for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Myoldmopar Thanks! Yes, the warnings are usually recurring. So it makes sense to condense them.


} // namespace EnergyPlus

#endif
Loading