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

Add plant worker function to get current equipment capacity #10804

Merged
merged 4 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
75 changes: 75 additions & 0 deletions src/EnergyPlus/CondenserLoopTowers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6474,6 +6474,81 @@ namespace CondenserLoopTowers {
}
}

Real64 CoolingTower::getDynamicMaxCapacity(EnergyPlusData &state)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tower calculations for current maximum capacity

{
// TODO: does not include faults object impact
static constexpr std::string_view routineName("getDynamicMaxCapacity");
Real64 outletWaterTemp = 0.0;
Real64 constexpr designWetBulb = 25.56;
Real64 constexpr airFlowRateRatio = 1.0;
Real64 constexpr waterFlowRateRatio = 1.0;
Real64 const CpWater = FluidProperties::GetSpecificHeatGlycol(state,
state.dataPlnt->PlantLoop(this->plantLoc.loopNum).FluidName,
state.dataLoopNodes->Node(this->WaterInletNodeNum).Temp,
state.dataPlnt->PlantLoop(this->plantLoc.loopNum).FluidIndex,
routineName);
// use operating max (i.e., at current plant flow rates, could be 0 if plant is off) or max available capacity?
// Real64 waterMassFlowRate = state.dataLoopNodes->Node(this->WaterInletNodeNum).MassFlowRateMaxAvail;
Real64 waterMassFlowRate = this->DesWaterMassFlowRate;
this->AirWetBulb = (this->OutdoorAirInletNodeNum > 0) ? state.dataLoopNodes->Node(this->OutdoorAirInletNodeNum).OutAirWetBulb
: state.dataEnvrn->OutWetBulbTemp;

switch (this->TowerType) {
case DataPlant::PlantEquipmentType::CoolingTower_SingleSpd:
case DataPlant::PlantEquipmentType::CoolingTower_TwoSpd: {
// only needed for calculateSimpleTowerOutletTemp
this->AirTemp =
(this->OutdoorAirInletNodeNum > 0) ? state.dataLoopNodes->Node(this->OutdoorAirInletNodeNum).Temp : state.dataEnvrn->OutDryBulbTemp;
Real64 WaterMassFlowRatePerCell = waterMassFlowRate / this->NumCell;
Real64 UAdesign = this->HighSpeedTowerUA / this->NumCell; // could save these calculations in e.g., this->DesUAPerCell
Real64 AirFlowRate = this->HighSpeedAirFlowRate / this->NumCell;
outletWaterTemp = this->calculateSimpleTowerOutletTemp(state, WaterMassFlowRatePerCell, AirFlowRate, UAdesign);
} break;
case DataPlant::PlantEquipmentType::CoolingTower_VarSpd: {
Real64 TrCapped; // range temp passed to VS tower model
Real64 TaCapped; // approach temp passed to VS tower model
Real64 Twb = this->AirWetBulb;
Real64 TwbCapped = this->AirWetBulb;
// water temperature setpoint
Real64 TempSetPoint(0.0); // Outlet water temperature setpoint (C)
switch (state.dataPlnt->PlantLoop(this->plantLoc.loopNum).LoopDemandCalcScheme) {
case DataPlant::LoopDemandCalcScheme::SingleSetPoint: {
TempSetPoint = state.dataPlnt->PlantLoop(this->plantLoc.loopNum).LoopSide(this->plantLoc.loopSideNum).TempSetPoint;
} break;
case DataPlant::LoopDemandCalcScheme::DualSetPointDeadBand: {
TempSetPoint = state.dataPlnt->PlantLoop(this->plantLoc.loopNum).LoopSide(this->plantLoc.loopSideNum).TempSetPointHi;
} break;
default: {
assert(false);
} break;
}
Real64 Tr = state.dataLoopNodes->Node(this->WaterInletNodeNum).Temp - TempSetPoint;
Real64 Ta = TempSetPoint - this->AirWetBulb;
Real64 waterFlowRateRatioCapped = 0.0; // Water flow rate ratio passed to VS tower model
// check independent inputs with respect to model boundaries
this->checkModelBounds(state, Twb, Tr, Ta, waterFlowRateRatio, TwbCapped, TrCapped, TaCapped, waterFlowRateRatioCapped);
outletWaterTemp = this->calculateVariableTowerOutletTemp(state, waterFlowRateRatioCapped, airFlowRateRatio, TwbCapped);
} break;
case DataPlant::PlantEquipmentType::CoolingTower_VarSpdMerkel: {
// only needed for calculateSimpleTowerOutletTemp
this->AirTemp =
(this->OutdoorAirInletNodeNum > 0) ? state.dataLoopNodes->Node(this->OutdoorAirInletNodeNum).Temp : state.dataEnvrn->OutDryBulbTemp;
Real64 const UAdesignPerCell = this->HighSpeedTowerUA / this->NumCell;
Real64 const airFlowRatePerCell = this->HighSpeedAirFlowRate / this->NumCell;
Real64 const waterMassFlowRatePerCell = waterMassFlowRate / this->NumCell;
Real64 const WaterFlowRateRatio = waterMassFlowRatePerCell / this->DesWaterMassFlowRatePerCell; // this should always be 1 ?
Real64 const UAwetbulbAdjFac = Curve::CurveValue(state, this->UAModFuncWetBulbDiffCurvePtr, (designWetBulb - this->AirWetBulb));
Real64 const UAairflowAdjFac = Curve::CurveValue(state, this->UAModFuncAirFlowRatioCurvePtr, airFlowRateRatio);
Real64 const UAwaterflowAdjFac = Curve::CurveValue(state, this->UAModFuncWaterFlowRatioCurvePtr, WaterFlowRateRatio);
Real64 const UAadjustedPerCell = UAdesignPerCell * UAwetbulbAdjFac * UAairflowAdjFac * UAwaterflowAdjFac;
outletWaterTemp = this->calculateSimpleTowerOutletTemp(state, waterMassFlowRatePerCell, airFlowRatePerCell, UAadjustedPerCell);
} break;
default:
assert(false);
}
return waterMassFlowRate * CpWater * (state.dataLoopNodes->Node(this->WaterInletNodeNum).Temp - outletWaterTemp);
}

} // namespace CondenserLoopTowers

} // namespace EnergyPlus
2 changes: 2 additions & 0 deletions src/EnergyPlus/CondenserLoopTowers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ namespace CondenserLoopTowers {
void checkMassFlowAndLoad(EnergyPlusData &state, Real64 MyLoad, bool RunFlag, bool &returnFlagSet);

static CoolingTower *factory(EnergyPlusData &state, std::string_view objectName);

Real64 getDynamicMaxCapacity(EnergyPlusData &state) override;
};

void GetTowerInput(EnergyPlusData &state);
Expand Down
6 changes: 6 additions & 0 deletions src/EnergyPlus/Plant/Component.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,11 @@ namespace DataPlant {
return state.dataPlnt->PlantLoop(plantLoc.loopNum).LoopSide(plantLoc.loopSideNum).Branch(plantLoc.branchNum).Comp(plantLoc.compNum);
}

Real64 CompData::getDynamicMaxCapacity(EnergyPlusData &state) const
{
if (this->compPtr == NULL) return this->MaxLoad;
Real64 possibleLoad = this->compPtr->getDynamicMaxCapacity(state);
return (possibleLoad == 0) ? this->MaxLoad : possibleLoad;
}
Copy link
Contributor Author

@rraustad rraustad Oct 25, 2024

Choose a reason for hiding this comment

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

This function will call the virtual function in PlantComponent.hh if a model does not have the override function (if that equipment's maximum capacity does not change this function is not needed) or will call the override function in the equipment model. If this function does not exist in an equipment model the virtual function will return 0 and MaxLoad will be used just as it is now. Otherwise the equipment model will return the current max capacity and that value will be used instead.

} // namespace DataPlant
} // namespace EnergyPlus
2 changes: 2 additions & 0 deletions src/EnergyPlus/Plant/Component.hh
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ namespace DataPlant {
void oneTimeInit(EnergyPlusData &state) const;

static CompData &getPlantComponent(EnergyPlusData &state, PlantLocation const &plantLoc);

Real64 getDynamicMaxCapacity(EnergyPlusData &state) const;
};
} // namespace DataPlant
} // namespace EnergyPlus
Expand Down
5 changes: 5 additions & 0 deletions src/EnergyPlus/PlantComponent.hh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public:
{
}

virtual Real64 getDynamicMaxCapacity([[maybe_unused]] EnergyPlusData &state)
{
return 0.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.

Virtual function returns 0 if equipment model does not have an override function.


virtual void getCurrentPower([[maybe_unused]] EnergyPlusData &state, [[maybe_unused]] Real64 &power)
{
}
Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/PlantCondLoopOperation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ using HVAC::SmallLoad;

void ManagePlantLoadDistribution(EnergyPlusData &state,
PlantLocation const &plantLoc, // PlantLoop data structure Location struct
Real64 &LoopDemand,
Real64 const LoopDemand,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

CppCheck suggestion

Real64 &RemLoopDemand,
bool const FirstHVACIteration,
bool &LoopShutDownFlag, // EMS flag to tell loop solver to shut down pumps
Expand Down Expand Up @@ -3673,7 +3673,7 @@ void FindCompSPLoad(EnergyPlusData &state,

// load local variables from the data structures
CompMinLoad = this_component.MinLoad;
CompMaxLoad = this_component.MaxLoad;
CompMaxLoad = this_component.getDynamicMaxCapacity(state);
Copy link
Contributor Author

@rraustad rraustad Oct 25, 2024

Choose a reason for hiding this comment

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

Down at line 3763 is code that will cap MyLoad if the component design capacity cannot meet the load. Calling this function provides a more accurate full load capacity for use in plant manager calculations.

    // Check bounds on MyLoad
    if (std::abs(this_component.MyLoad) > CompMaxLoad) {
        this_component.MyLoad = sign(CompMaxLoad, this_component.MyLoad);
    }

CompOptLoad = this_component.OptLoad;
DemandNode = state.dataPlnt->PlantLoop(plantLoc.loopNum).OpScheme(OpSchemePtr).EquipList(ListPtr).Comp(CompPtr).DemandNodeNum;
SetPtNode = state.dataPlnt->PlantLoop(plantLoc.loopNum).OpScheme(OpSchemePtr).EquipList(ListPtr).Comp(CompPtr).SetPointNodeNum;
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/PlantCondLoopOperation.hh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace PlantCondLoopOperation {

void ManagePlantLoadDistribution(EnergyPlusData &state,
PlantLocation const &plantLoc, // PlantLoop data structure Location struct
Real64 &LoopDemand,
Real64 const LoopDemand,
Real64 &RemLoopDemand,
bool const FirstHVACIteration,
bool &LoopShutDownFlag, // EMS flag to tell loop solver to shut down pumps
Expand Down
Loading