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 18239836 : 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 18239836 : this->InletNodeFlowrate = state.dataLoopNodes->Node(this->LoopSide(DataPlant::LoopSideLocation::Supply).NodeNumIn).MassFlowRate;
71 18239836 : this->InletNodeTemperature = state.dataLoopNodes->Node(this->LoopSide(DataPlant::LoopSideLocation::Supply).NodeNumIn).Temp;
72 18239836 : this->OutletNodeFlowrate = state.dataLoopNodes->Node(this->LoopSide(DataPlant::LoopSideLocation::Supply).NodeNumOut).MassFlowRate;
73 18239836 : 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 18239836 : if (OtherSideDemand < 0.0) {
77 4902218 : this->CoolingDemand = std::abs(OtherSideDemand);
78 4902218 : this->HeatingDemand = 0.0;
79 4902218 : this->DemandNotDispatched = -LocalRemLoopDemand; // Setting sign based on old logic for now
80 : } else {
81 13337618 : this->HeatingDemand = OtherSideDemand;
82 13337618 : this->CoolingDemand = 0.0;
83 13337618 : this->DemandNotDispatched = LocalRemLoopDemand; // Setting sign based on old logic for now
84 : }
85 :
86 18239836 : this->CalcUnmetPlantDemand(state);
87 18239836 : }
88 :
89 18239836 : 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 18239836 : LoadToLoopSetPoint = 0.0;
129 :
130 : // Get temperature at loop setpoint node.
131 18239836 : TargetTemp = state.dataLoopNodes->Node(this->TempSetPointNodeNum).Temp;
132 18239836 : MassFlowRate = state.dataLoopNodes->Node(this->TempSetPointNodeNum).MassFlowRate;
133 :
134 18239836 : if (this->FluidType == DataLoopNode::NodeFluidType::Water) {
135 :
136 18178702 : Cp = this->glycol->getSpecificHeat(state, TargetTemp, RoutineName);
137 :
138 18178702 : switch (this->LoopDemandCalcScheme) {
139 18005486 : case DataPlant::LoopDemandCalcScheme::SingleSetPoint: {
140 :
141 : // Pick up the loop setpoint temperature
142 18005486 : LoopSetPointTemperature = this->LoopSide(DataPlant::LoopSideLocation::Supply).TempSetPoint;
143 : // Calculate the delta temperature
144 18005486 : DeltaTemp = LoopSetPointTemperature - TargetTemp;
145 :
146 : // Calculate the demand on the loop
147 18005486 : LoadToLoopSetPoint = MassFlowRate * Cp * DeltaTemp;
148 18005486 : } break;
149 173216 : case DataPlant::LoopDemandCalcScheme::DualSetPointDeadBand: {
150 : // Get the range of setpoints
151 173216 : LoopSetPointTemperatureHi = state.dataLoopNodes->Node(this->TempSetPointNodeNum).TempSetPointHi;
152 173216 : LoopSetPointTemperatureLo = state.dataLoopNodes->Node(this->TempSetPointNodeNum).TempSetPointLo;
153 :
154 : // Calculate the demand on the loop
155 173216 : if (MassFlowRate > 0.0) {
156 164741 : LoadToHeatingSetPoint = MassFlowRate * Cp * (LoopSetPointTemperatureLo - TargetTemp);
157 164741 : 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 164741 : if (LoadToHeatingSetPoint > 0.0 && LoadToCoolingSetPoint > 0.0) {
164 25442 : LoadToLoopSetPoint = LoadToHeatingSetPoint;
165 139299 : } else if (LoadToHeatingSetPoint < 0.0 && LoadToCoolingSetPoint < 0.0) {
166 38403 : LoadToLoopSetPoint = LoadToCoolingSetPoint;
167 100896 : } else if (LoadToHeatingSetPoint <= 0.0 && LoadToCoolingSetPoint >= 0.0) { // deadband includes zero loads
168 100896 : LoadToLoopSetPoint = 0.0;
169 : }
170 : } else {
171 8475 : LoadToLoopSetPoint = 0.0;
172 : }
173 173216 : } break;
174 0 : default:
175 0 : break;
176 : }
177 :
178 61134 : } else if (this->FluidType == DataLoopNode::NodeFluidType::Steam) {
179 :
180 61134 : Cp = this->glycol->getSpecificHeat(state, TargetTemp, RoutineName);
181 :
182 61134 : switch (this->LoopDemandCalcScheme) {
183 61134 : case DataPlant::LoopDemandCalcScheme::SingleSetPoint: {
184 :
185 : // Pick up the loop setpoint temperature
186 61134 : LoopSetPointTemperature = this->LoopSide(DataPlant::LoopSideLocation::Supply).TempSetPoint;
187 :
188 : // Calculate the delta temperature
189 61134 : DeltaTemp = LoopSetPointTemperature - TargetTemp;
190 :
191 61134 : EnthalpySteamSatVapor = this->steam->getSatEnthalpy(state, LoopSetPointTemperature, 1.0, RoutineNameAlt);
192 61134 : EnthalpySteamSatLiquid = this->steam->getSatEnthalpy(state, LoopSetPointTemperature, 0.0, RoutineNameAlt);
193 :
194 61134 : LatentHeatSteam = EnthalpySteamSatVapor - EnthalpySteamSatLiquid;
195 :
196 : // Calculate the demand on the loop
197 61134 : LoadToLoopSetPoint = MassFlowRate * (Cp * DeltaTemp + LatentHeatSteam);
198 61134 : } 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 18239836 : if (std::abs(LoadToLoopSetPoint) < LoopDemandTol) {
208 13462821 : LoadToLoopSetPoint = 0.0;
209 : }
210 :
211 18239836 : this->UnmetDemand = LoadToLoopSetPoint;
212 18239836 : }
213 :
214 18239836 : void PlantLoopData::CheckLoopExitNode(EnergyPlusData &state, bool const FirstHVACIteration)
215 : {
216 :
217 : // SUBROUTINE INFORMATION:
218 : // AUTHOR Dan Fisher
219 : // DATE WRITTEN October 1998
220 : // MODIFIED na
221 : // RE-ENGINEERED na
222 :
223 : // PURPOSE OF THIS SUBROUTINE:
224 : // This subroutine sets the temperature
225 : // and mass flow rate of the plant loop supply side exit
226 : // node. As written, the routine calculates the exit
227 : // temperature based on the fraction of loop demand met
228 : // by the plant equipment. This assumes that each piece
229 : // of operating plant equipment produced chilled/hot water
230 : // at the loop setpoint temperature.
231 :
232 : // Using/Aliasing
233 :
234 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
235 : int LoopInlet; // plant loop inlet node num.
236 : int LoopOutlet; // plant loop outlet node num.
237 :
238 : // set local variables: loop inlet and outlet nodes
239 18239836 : auto &Supply = this->LoopSide(DataPlant::LoopSideLocation::Supply);
240 18239836 : LoopInlet = Supply.NodeNumIn;
241 18239836 : LoopOutlet = Supply.NodeNumOut;
242 : // Check continuity invalid...loop pumps now turned on and off
243 18239836 : if (!FirstHVACIteration && !state.dataGlobal->WarmupFlag) {
244 1726387 : if (std::abs(state.dataLoopNodes->Node(LoopOutlet).MassFlowRate - state.dataLoopNodes->Node(LoopInlet).MassFlowRate) >
245 : DataBranchAirLoopPlant::MassFlowTolerance) {
246 0 : if (this->MFErrIndex == 0) {
247 0 : ShowWarningError(state,
248 0 : "PlantSupplySide: PlantLoop=\"" + this->Name +
249 : "\", Error (CheckLoopExitNode) -- Mass Flow Rate Calculation. Outlet and Inlet differ by more than tolerance.");
250 0 : ShowContinueErrorTimeStamp(state, "");
251 0 : ShowContinueError(state,
252 0 : format("Loop inlet node={}, flowrate={:.4R} kg/s",
253 0 : state.dataLoopNodes->NodeID(LoopInlet),
254 0 : state.dataLoopNodes->Node(LoopInlet).MassFlowRate));
255 0 : ShowContinueError(state,
256 0 : format("Loop outlet node={}, flowrate={:.4R} kg/s",
257 0 : state.dataLoopNodes->NodeID(LoopOutlet),
258 0 : state.dataLoopNodes->Node(LoopOutlet).MassFlowRate));
259 0 : ShowContinueError(state, "This loop might be helped by a bypass.");
260 : }
261 0 : ShowRecurringWarningErrorAtEnd(
262 0 : state, "PlantSupplySide: PlantLoop=\"" + this->Name + "\", Error -- Mass Flow Rate Calculation -- continues ** ", this->MFErrIndex);
263 : }
264 : }
265 : // Reset Max loop flow rate based on pump performance
266 18239836 : state.dataLoopNodes->Node(LoopOutlet).MassFlowRateMax = state.dataLoopNodes->Node(LoopInlet).MassFlowRateMax;
267 18239836 : }
268 :
269 : } // namespace EnergyPlus::DataPlant
|