Line data Source code
1 : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
2 : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
3 : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
4 : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
5 : // contributors. All rights reserved.
6 : //
7 : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
8 : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
9 : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
10 : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
11 : // derivative works, and perform publicly and display publicly, and to permit others to do so.
12 : //
13 : // Redistribution and use in source and binary forms, with or without modification, are permitted
14 : // provided that the following conditions are met:
15 : //
16 : // (1) Redistributions of source code must retain the above copyright notice, this list of
17 : // conditions and the following disclaimer.
18 : //
19 : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
20 : // conditions and the following disclaimer in the documentation and/or other materials
21 : // provided with the distribution.
22 : //
23 : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
24 : // the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
25 : // used to endorse or promote products derived from this software without specific prior
26 : // written permission.
27 : //
28 : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
29 : // without changes from the version obtained under this License, or (ii) Licensee makes a
30 : // reference solely to the software portion of its product, Licensee must refer to the
31 : // software as "EnergyPlus version X" software, where "X" is the version number Licensee
32 : // obtained under this License and may not use a different name for the software. Except as
33 : // specifically required in this Section (4), Licensee shall not use in a company name, a
34 : // product name, in advertising, publicity, or other promotional activities any name, trade
35 : // name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
36 : // similar designation, without the U.S. Department of Energy's prior written consent.
37 : //
38 : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
39 : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
40 : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
41 : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
43 : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44 : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
45 : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46 : // POSSIBILITY OF SUCH DAMAGE.
47 :
48 : #include <EnergyPlus/Data/EnergyPlusData.hh>
49 : #include <EnergyPlus/DataBranchAirLoopPlant.hh>
50 : #include <EnergyPlus/FluidProperties.hh>
51 : #include <EnergyPlus/General.hh>
52 : #include <EnergyPlus/Plant/DataPlant.hh>
53 : #include <EnergyPlus/Plant/Loop.hh>
54 : #include <EnergyPlus/UtilityRoutines.hh>
55 :
56 : namespace EnergyPlus::DataPlant {
57 :
58 88208 : void PlantLoopData::UpdateLoopSideReportVars(EnergyPlusData &state,
59 : Real64 const OtherSideDemand, // This is the 'other side' demand, based on other side flow
60 : Real64 const LocalRemLoopDemand // Unmet Demand after equipment has been simulated (report variable)
61 : )
62 : {
63 :
64 : // SUBROUTINE INFORMATION:
65 : // AUTHOR Dan Fisher
66 : // DATE WRITTEN July 1998
67 : // MODIFIED Aug 2010 Edwin Lee -- add per LoopSide variable support
68 : // RE-ENGINEERED na
69 :
70 88208 : this->InletNodeFlowrate = state.dataLoopNodes->Node(this->LoopSide(DataPlant::LoopSideLocation::Supply).NodeNumIn).MassFlowRate;
71 88208 : this->InletNodeTemperature = state.dataLoopNodes->Node(this->LoopSide(DataPlant::LoopSideLocation::Supply).NodeNumIn).Temp;
72 88208 : this->OutletNodeFlowrate = state.dataLoopNodes->Node(this->LoopSide(DataPlant::LoopSideLocation::Supply).NodeNumOut).MassFlowRate;
73 88208 : this->OutletNodeTemperature = state.dataLoopNodes->Node(this->LoopSide(DataPlant::LoopSideLocation::Supply).NodeNumOut).Temp;
74 :
75 : // In the baseline code, only reported supply side demand. so putting in "SupplySide" IF block for now but might expand later
76 88208 : if (OtherSideDemand < 0.0) {
77 21773 : this->CoolingDemand = std::abs(OtherSideDemand);
78 21773 : this->HeatingDemand = 0.0;
79 21773 : this->DemandNotDispatched = -LocalRemLoopDemand; // Setting sign based on old logic for now
80 : } else {
81 66435 : this->HeatingDemand = OtherSideDemand;
82 66435 : this->CoolingDemand = 0.0;
83 66435 : this->DemandNotDispatched = LocalRemLoopDemand; // Setting sign based on old logic for now
84 : }
85 :
86 88208 : this->CalcUnmetPlantDemand(state);
87 88208 : }
88 :
89 88208 : void PlantLoopData::CalcUnmetPlantDemand(EnergyPlusData &state)
90 : {
91 :
92 : // SUBROUTINE INFORMATION:
93 : // AUTHOR Brent Griffith
94 : // DATE WRITTEN June 2011
95 : // MODIFIED na
96 : // RE-ENGINEERED na
97 :
98 : // PURPOSE OF THIS SUBROUTINE:
99 : // determine the magnitude of unmet plant loads after the half loop simulation is done
100 :
101 : // METHODOLOGY EMPLOYED:
102 : // using the loop setpoint node, look at target vs current and
103 : // calculate a demand based on mass flow times specific heat times delta T
104 :
105 : // Using/Aliasing
106 : using DataPlant::LoopDemandTol;
107 :
108 : // SUBROUTINE PARAMETER DEFINITIONS:
109 : static constexpr std::string_view RoutineName("PlantLoopSolver::EvaluateLoopSetPointLoad");
110 : static constexpr std::string_view RoutineNameAlt("PlantSupplySide:EvaluateLoopSetPointLoad");
111 :
112 : //~ General variables
113 : Real64 MassFlowRate;
114 : Real64 TargetTemp;
115 : Real64 LoopSetPointTemperature;
116 : Real64 LoopSetPointTemperatureHi;
117 : Real64 LoopSetPointTemperatureLo;
118 : Real64 LoadToHeatingSetPoint;
119 : Real64 LoadToCoolingSetPoint;
120 : Real64 DeltaTemp;
121 : Real64 Cp;
122 : Real64 EnthalpySteamSatVapor; // Enthalpy of saturated vapor
123 : Real64 EnthalpySteamSatLiquid; // Enthalpy of saturated liquid
124 : Real64 LatentHeatSteam; // Latent heat of steam
125 : Real64 LoadToLoopSetPoint;
126 :
127 : // Initialize
128 88208 : LoadToLoopSetPoint = 0.0;
129 :
130 : // Get temperature at loop setpoint node.
131 88208 : TargetTemp = state.dataLoopNodes->Node(this->TempSetPointNodeNum).Temp;
132 88208 : MassFlowRate = state.dataLoopNodes->Node(this->TempSetPointNodeNum).MassFlowRate;
133 :
134 88208 : if (this->FluidType == DataLoopNode::NodeFluidType::Water) {
135 :
136 88208 : Cp = this->glycol->getSpecificHeat(state, TargetTemp, RoutineName);
137 :
138 88208 : switch (this->LoopDemandCalcScheme) {
139 85302 : case DataPlant::LoopDemandCalcScheme::SingleSetPoint: {
140 :
141 : // Pick up the loop setpoint temperature
142 85302 : LoopSetPointTemperature = this->LoopSide(DataPlant::LoopSideLocation::Supply).TempSetPoint;
143 : // Calculate the delta temperature
144 85302 : DeltaTemp = LoopSetPointTemperature - TargetTemp;
145 :
146 : // Calculate the demand on the loop
147 85302 : LoadToLoopSetPoint = MassFlowRate * Cp * DeltaTemp;
148 85302 : } break;
149 2906 : case DataPlant::LoopDemandCalcScheme::DualSetPointDeadBand: {
150 : // Get the range of setpoints
151 2906 : LoopSetPointTemperatureHi = state.dataLoopNodes->Node(this->TempSetPointNodeNum).TempSetPointHi;
152 2906 : LoopSetPointTemperatureLo = state.dataLoopNodes->Node(this->TempSetPointNodeNum).TempSetPointLo;
153 :
154 : // Calculate the demand on the loop
155 2906 : if (MassFlowRate > 0.0) {
156 2880 : LoadToHeatingSetPoint = MassFlowRate * Cp * (LoopSetPointTemperatureLo - TargetTemp);
157 2880 : LoadToCoolingSetPoint = MassFlowRate * Cp * (LoopSetPointTemperatureHi - TargetTemp);
158 : // Possible combinations:
159 : // 1 LoadToHeatingSetPoint > 0 & LoadToCoolingSetPoint > 0 --> Heating required
160 : // 2 LoadToHeatingSetPoint < 0 & LoadToCoolingSetPoint < 0 --> Cooling Required
161 : // 3 LoadToHeatingSetPoint <=0 & LoadToCoolingSetPoint >=0 --> Dead Band Operation - includes zero load cases
162 : // 4 LoadToHeatingSetPoint > LoadToCoolingSetPoint --> Not Feasible if LoopSetPointHi >= LoopSetPointLo
163 2880 : if (LoadToHeatingSetPoint > 0.0 && LoadToCoolingSetPoint > 0.0) {
164 1439 : LoadToLoopSetPoint = LoadToHeatingSetPoint;
165 1441 : } else if (LoadToHeatingSetPoint < 0.0 && LoadToCoolingSetPoint < 0.0) {
166 1439 : LoadToLoopSetPoint = LoadToCoolingSetPoint;
167 2 : } else if (LoadToHeatingSetPoint <= 0.0 && LoadToCoolingSetPoint >= 0.0) { // deadband includes zero loads
168 2 : LoadToLoopSetPoint = 0.0;
169 : }
170 : } else {
171 26 : LoadToLoopSetPoint = 0.0;
172 : }
173 2906 : } break;
174 0 : default:
175 0 : break;
176 : }
177 :
178 0 : } else if (this->FluidType == DataLoopNode::NodeFluidType::Steam) {
179 :
180 0 : Cp = this->glycol->getSpecificHeat(state, TargetTemp, RoutineName);
181 :
182 0 : switch (this->LoopDemandCalcScheme) {
183 0 : case DataPlant::LoopDemandCalcScheme::SingleSetPoint: {
184 :
185 : // Pick up the loop setpoint temperature
186 0 : LoopSetPointTemperature = this->LoopSide(DataPlant::LoopSideLocation::Supply).TempSetPoint;
187 :
188 : // Calculate the delta temperature
189 0 : DeltaTemp = LoopSetPointTemperature - TargetTemp;
190 :
191 0 : EnthalpySteamSatVapor = this->steam->getSatEnthalpy(state, LoopSetPointTemperature, 1.0, RoutineNameAlt);
192 0 : EnthalpySteamSatLiquid = this->steam->getSatEnthalpy(state, LoopSetPointTemperature, 0.0, RoutineNameAlt);
193 :
194 0 : LatentHeatSteam = EnthalpySteamSatVapor - EnthalpySteamSatLiquid;
195 :
196 : // Calculate the demand on the loop
197 0 : LoadToLoopSetPoint = MassFlowRate * (Cp * DeltaTemp + LatentHeatSteam);
198 0 : } break;
199 0 : default:
200 0 : break;
201 : }
202 :
203 : } else { // only have two types, water serves for glycol.
204 : }
205 :
206 : // Trim the demand to zero if it is very small
207 88208 : if (std::abs(LoadToLoopSetPoint) < LoopDemandTol) LoadToLoopSetPoint = 0.0;
208 :
209 88208 : this->UnmetDemand = LoadToLoopSetPoint;
210 88208 : }
211 :
212 88208 : void PlantLoopData::CheckLoopExitNode(EnergyPlusData &state, bool const FirstHVACIteration)
213 : {
214 :
215 : // SUBROUTINE INFORMATION:
216 : // AUTHOR Dan Fisher
217 : // DATE WRITTEN October 1998
218 : // MODIFIED na
219 : // RE-ENGINEERED na
220 :
221 : // PURPOSE OF THIS SUBROUTINE:
222 : // This subroutine sets the temperature
223 : // and mass flow rate of the plant loop supply side exit
224 : // node. As written, the routine calculates the exit
225 : // temperature based on the fraction of loop demand met
226 : // by the plant equipment. This assumes that each piece
227 : // of operating plant equipment produced chilled/hot water
228 : // at the loop setpoint temperature.
229 :
230 : // Using/Aliasing
231 :
232 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
233 : int LoopInlet; // plant loop inlet node num.
234 : int LoopOutlet; // plant loop outlet node num.
235 :
236 : // set local variables: loop inlet and outlet nodes
237 88208 : auto &Supply = this->LoopSide(DataPlant::LoopSideLocation::Supply);
238 88208 : LoopInlet = Supply.NodeNumIn;
239 88208 : LoopOutlet = Supply.NodeNumOut;
240 : // Check continuity invalid...loop pumps now turned on and off
241 88208 : if (!FirstHVACIteration && !state.dataGlobal->WarmupFlag) {
242 8818 : if (std::abs(state.dataLoopNodes->Node(LoopOutlet).MassFlowRate - state.dataLoopNodes->Node(LoopInlet).MassFlowRate) >
243 : DataBranchAirLoopPlant::MassFlowTolerance) {
244 0 : if (this->MFErrIndex == 0) {
245 0 : ShowWarningError(state,
246 0 : "PlantSupplySide: PlantLoop=\"" + this->Name +
247 : "\", Error (CheckLoopExitNode) -- Mass Flow Rate Calculation. Outlet and Inlet differ by more than tolerance.");
248 0 : ShowContinueErrorTimeStamp(state, "");
249 0 : ShowContinueError(state,
250 0 : format("Loop inlet node={}, flowrate={:.4R} kg/s",
251 0 : state.dataLoopNodes->NodeID(LoopInlet),
252 0 : state.dataLoopNodes->Node(LoopInlet).MassFlowRate));
253 0 : ShowContinueError(state,
254 0 : format("Loop outlet node={}, flowrate={:.4R} kg/s",
255 0 : state.dataLoopNodes->NodeID(LoopOutlet),
256 0 : state.dataLoopNodes->Node(LoopOutlet).MassFlowRate));
257 0 : ShowContinueError(state, "This loop might be helped by a bypass.");
258 : }
259 0 : ShowRecurringWarningErrorAtEnd(
260 0 : state, "PlantSupplySide: PlantLoop=\"" + this->Name + "\", Error -- Mass Flow Rate Calculation -- continues ** ", this->MFErrIndex);
261 : }
262 : }
263 : // Reset Max loop flow rate based on pump performance
264 88208 : state.dataLoopNodes->Node(LoopOutlet).MassFlowRateMax = state.dataLoopNodes->Node(LoopInlet).MassFlowRateMax;
265 88208 : }
266 :
267 : } // namespace EnergyPlus::DataPlant
|