Line data Source code
1 : // EnergyPlus, Copyright (c) 1996-2024, 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 : #ifndef HeatBalFiniteDiffManager_hh_INCLUDED
49 : #define HeatBalFiniteDiffManager_hh_INCLUDED
50 :
51 : // ObjexxFCL Headers
52 : #include <ObjexxFCL/Array1D.hh>
53 : #include <ObjexxFCL/Array2D.hh>
54 :
55 : // EnergyPlus Headers
56 : #include <EnergyPlus/Data/BaseData.hh>
57 : #include <EnergyPlus/DataGlobals.hh>
58 : #include <EnergyPlus/DataHeatBalance.hh>
59 : #include <EnergyPlus/EnergyPlus.hh>
60 : #include <EnergyPlus/Material.hh>
61 :
62 : namespace EnergyPlus {
63 :
64 : // Forward declarations
65 : struct EnergyPlusData;
66 :
67 : namespace HeatBalFiniteDiffManager {
68 :
69 : Real64 constexpr TempInitValue(23.0); // Initialization value for Temperature
70 : Real64 constexpr RhovInitValue(0.0115); // Initialization value for Rhov
71 : Real64 constexpr EnthInitValue(100.0); // Initialization value for Enthalpy
72 : constexpr Real64 smalldiff(1.e-8); // Used in places where "equality" tests should not be used.
73 : constexpr Real64 MinTempLimit = -100.0; // lower limit check, degree C
74 : constexpr Real64 MaxTempLimit = 100.0; // upper limit check, degree C
75 :
76 : enum class CondFDScheme
77 : {
78 : Invalid = -1,
79 : CrankNicholsonSecondOrder, // original CondFD scheme. semi implicit, second order in time
80 : FullyImplicitFirstOrder, // fully implicit scheme, first order in time.
81 : Num
82 : };
83 :
84 : static constexpr std::array<std::string_view, static_cast<int>(CondFDScheme::Num)> CondFDSchemeTypeNamesCC = {"CrankNicholsonSecondOrder",
85 : "FullyImplicitFirstOrder"};
86 : static constexpr std::array<std::string_view, static_cast<int>(CondFDScheme::Num)> CondFDSchemeTypeNamesUC = {"CRANKNICHOLSONSECONDORDER",
87 : "FULLYIMPLICITFIRSTORDER"};
88 :
89 : struct ConstructionDataFD
90 : {
91 : // Members
92 : Array1D_string Name; // Name of construction
93 : Array1D<Real64> DelX;
94 : Array1D<Real64> TempStability;
95 : Array1D<Real64> MoistStability;
96 : Array1D_int NodeNumPoint;
97 : Array1D<Real64> Thickness;
98 : Array1D<Real64> NodeXlocation; // sized to TotNode, contains X distance in m from outside face
99 : int TotNodes;
100 : int DeltaTime;
101 :
102 : // Default Constructor
103 12 : ConstructionDataFD() : TotNodes(0), DeltaTime(0)
104 : {
105 12 : }
106 : };
107 :
108 : struct MaterialActuatorData
109 : {
110 : std::string actuatorName;
111 : bool isActuated;
112 : Real64 actuatedValue;
113 :
114 411 : MaterialActuatorData() : isActuated(false), actuatedValue(0.0)
115 : {
116 411 : }
117 : };
118 :
119 : struct SurfaceDataFD
120 : {
121 : // Members
122 : Array1D<Real64> T;
123 : Array1D<Real64> TOld;
124 : Array1D<Real64> TT;
125 : Array1D<Real64> Rhov;
126 : Array1D<Real64> RhovOld;
127 : Array1D<Real64> RhoT;
128 : Array1D<Real64> TD;
129 : Array1D<Real64> TDT;
130 : Array1D<Real64> TDTLast;
131 : Array1D<Real64> TDOld;
132 : Array1D<Real64> TDreport; // Node temperatures for reporting [C]
133 : Array1D<Real64> RH;
134 : Array1D<Real64> RHreport;
135 : Array1D<Real64> EnthOld; // Current node enthalpy
136 : Array1D<Real64> EnthNew; // Node enthalpy at new time
137 : Array1D<Real64> EnthLast;
138 : Array1D<Real64> QDreport; // Node heat flux for reporting [W/m2] positive is flow towards inside face of surface
139 : Array1D<Real64> CpDelXRhoS1; // Current outer half-node Cp * DelX * RhoS / Delt
140 : Array1D<Real64> CpDelXRhoS2; // Current inner half-node Cp * DelX * RhoS / Delt
141 : Array1D<Real64> TDpriortimestep; // Node temperatures from previous timestep
142 : int SourceNodeNum; // Node number for internal source layer (zero if no source)
143 : Real64 QSource; // Internal source flux [W/m2]
144 : int GSloopCounter; // count of inner loop iterations
145 : Real64 MaxNodeDelTemp; // largest change in node temps after calc
146 : int indexNodeMaxTempLimit = 0; // index for recurring error message if node temperature exceeds maximum node temperature for this surface
147 : int indexNodeMinTempLimit = 0; // index for recurring error message if node temperature is below minimum node temperature for this surfac
148 : Real64 EnthalpyM; // Melting enthalpy at a particular temperature
149 : Real64 EnthalpyF; // Freezing enthalpy at a particular temperature
150 : Array1D<int> PhaseChangeState;
151 : Array1D<int> PhaseChangeStateOld;
152 : Array1D<int> PhaseChangeStateOldOld;
153 : Array1D<Real64> PhaseChangeTemperatureReverse;
154 : Array1D<MaterialActuatorData> condMaterialActuators;
155 : Array1D<MaterialActuatorData> specHeatMaterialActuators;
156 : Array1D<MaterialActuatorData> heatSourceFluxMaterialActuators;
157 : Array1D<Real64> condNodeReport;
158 : Array1D<Real64> specHeatNodeReport;
159 : // Includes the internal heat source
160 : Array1D<Real64> heatSourceInternalFluxLayerReport;
161 : Array1D<Real64> heatSourceInternalFluxEnergyLayerReport;
162 : // Includes the EMS heat source
163 : Array1D<Real64> heatSourceEMSFluxLayerReport;
164 : Array1D<Real64> heatSourceEMSFluxEnergyLayerReport;
165 :
166 : // Default Constructor
167 12 : SurfaceDataFD() : SourceNodeNum(0), QSource(0.0), GSloopCounter(0), MaxNodeDelTemp(0.0), EnthalpyM(0.0), EnthalpyF(0.0), PhaseChangeState(0)
168 : {
169 12 : }
170 :
171 1654326 : inline void UpdateMoistureBalance()
172 : {
173 : // Based on UpdateMoistureBalanceFD by Richard Liesen
174 : // Brought into class for performance
175 1654326 : TOld = T;
176 1654326 : RhovOld = Rhov;
177 1654326 : TDOld = TDreport;
178 1654326 : }
179 : };
180 :
181 : struct MaterialDataFD
182 : {
183 : // Members
184 : Real64 tk1; // Temperature coefficient for thermal conductivity
185 : int numTempEnth; // number of Temperature/Enthalpy pairs
186 : int numTempCond; // number of Temperature/Conductivity pairs
187 : Array2D<Real64> TempEnth; // Temperature enthalpy Function Pairs,
188 : // TempEnth(1,1)= first Temp, TempEnth(1,2) = First Enthalpy,
189 : // TempEnth(2,1) = secomd Temp, etc.
190 : Array2D<Real64> TempCond; // Temperature thermal conductivity Function Pairs,
191 : // TempCond(1,1)= first Temp, Tempcond(1,2) = First conductivity,
192 : // TempEnth(2,1) = secomd Temp, etc.
193 :
194 : // Default Constructor
195 12 : MaterialDataFD() : tk1(0.0), numTempEnth(0), numTempCond(0)
196 : {
197 12 : }
198 : };
199 :
200 : void ManageHeatBalFiniteDiff(EnergyPlusData &state,
201 : int SurfNum,
202 : Real64 &SurfTempInTmp, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
203 : Real64 &TempSurfOutTmp // Outside Surface Temperature of each Heat Transfer Surface
204 : );
205 :
206 : void GetCondFDInput(EnergyPlusData &state);
207 :
208 : int setSizeMaxProperties(EnergyPlusData &state);
209 :
210 : void InitHeatBalFiniteDiff(EnergyPlusData &state);
211 :
212 : void InitialInitHeatBalFiniteDiff(EnergyPlusData &state);
213 :
214 : int numNodesInMaterialLayer(EnergyPlusData &state, std::string const &surfName, std::string const &matName);
215 :
216 : void CalcHeatBalFiniteDiff(EnergyPlusData &state,
217 : int Surf,
218 : Real64 &SurfTempInTmp, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
219 : Real64 &TempSurfOutTmp // Outside Surface Temperature of each Heat Transfer Surface
220 : );
221 :
222 : void ReportFiniteDiffInits(EnergyPlusData &state);
223 :
224 : void CalcNodeHeatFlux(EnergyPlusData &state,
225 : int Surf, // surface number
226 : int TotNodes // number of nodes in surface
227 : );
228 :
229 : Real64 terpld(Array2<Real64> const &a, Real64 x1, int nind, int ndep);
230 :
231 : void ExteriorBCEqns(EnergyPlusData &state,
232 : int Delt, // Time Increment
233 : int i, // Node Index
234 : int Lay, // Layer Number for Construction
235 : int Surf, // Surface number
236 : Array1D<Real64> const &T, // Old node Temperature in MFD finite difference solution
237 : Array1D<Real64> &TT, // New node Temperature in MFD finite difference solution.
238 : Array1D<Real64> const &Rhov, // MFD Nodal Vapor Density[kg/m3] and is the old or last time step result.
239 : Array1D<Real64> &RhoT, // MFD vapor density for the new time step.
240 : Array1D<Real64> &RH, // Nodal relative humidity
241 : Array1D<Real64> const &TD, // The old dry Temperature at each node for the CondFD algorithm..
242 : Array1D<Real64> &TDT, // The current or new Temperature at each node location for the CondFD solution..
243 : Array1D<Real64> &EnthOld, // Old Nodal enthalpy
244 : Array1D<Real64> &EnthNew, // New Nodal enthalpy
245 : int TotNodes, // Total nodes in layer
246 : Real64 HMovInsul // Conductance of movable(transparent) insulation.
247 : );
248 :
249 : void InteriorNodeEqns(EnergyPlusData &state,
250 : int Delt, // Time Increment
251 : int i, // Node Index
252 : int Lay, // Layer Number for Construction
253 : int Surf, // Surface number
254 : Array1D<Real64> const &T, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
255 : Array1D<Real64> &TT, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
256 : Array1D<Real64> const &Rhov, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
257 : Array1D<Real64> &RhoT, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
258 : Array1D<Real64> &RH, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
259 : Array1D<Real64> const &TD, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
260 : Array1D<Real64> &TDT, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
261 : Array1D<Real64> &EnthOld, // Old Nodal enthalpy
262 : Array1D<Real64> &EnthNew // New Nodal enthalpy
263 : );
264 :
265 : void IntInterfaceNodeEqns(EnergyPlusData &state,
266 : int Delt, // Time Increment
267 : int i, // Node Index
268 : int Lay, // Layer Number for Construction
269 : int Surf, // Surface number
270 : Array1D<Real64> const &T, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
271 : Array1D<Real64> &TT, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
272 : Array1D<Real64> const &Rhov, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
273 : Array1D<Real64> &RhoT, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
274 : Array1D<Real64> &RH, // RELATIVE HUMIDITY.
275 : Array1D<Real64> const &TD, // OLD NODE TEMPERATURES OF EACH HEAT TRANSFER SURF IN CONDFD.
276 : Array1D<Real64> &TDT, // NEW NODE TEMPERATURES OF EACH HEAT TRANSFER SURF IN CONDFD.
277 : Array1D<Real64> const &EnthOld, // Old Nodal enthalpy
278 : Array1D<Real64> &EnthNew, // New Nodal enthalpy
279 : int GSiter // Iteration number of Gauss Seidell iteration
280 : );
281 :
282 : void InteriorBCEqns(EnergyPlusData &state,
283 : int Delt, // Time Increment
284 : int i, // Node Index
285 : int Lay, // Layer Number for Construction
286 : int Surf, // Surface number
287 : Array1D<Real64> const &T, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF (Old).
288 : Array1D<Real64> &TT, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF (New).
289 : Array1D<Real64> const &Rhov, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
290 : Array1D<Real64> &RhoT, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
291 : Array1D<Real64> &RH, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
292 : Array1D<Real64> const &TD, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
293 : Array1D<Real64> &TDT, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
294 : Array1D<Real64> &EnthOld, // Old Nodal enthalpy
295 : Array1D<Real64> &EnthNew, // New Nodal enthalpy
296 : Array1D<Real64> &TDreport // Temperature value from previous HeatSurfaceHeatManager titeration's value
297 : );
298 :
299 : void CheckFDSurfaceTempLimits(EnergyPlusData &state,
300 : int SurfNum, // surface number
301 : Real64 CheckTemperature // calculated temperature, not reset
302 : );
303 :
304 : void CheckFDNodeTempLimits(EnergyPlusData &state,
305 : int surfNum, // surface number
306 : int nodeNum, // node number
307 : Real64 &nodeTemp // calculated temperature, not reset
308 : );
309 :
310 : void adjustPropertiesForPhaseChange(EnergyPlusData &state,
311 : int finiteDifferenceLayerIndex,
312 : int surfaceIndex,
313 : const Material::MaterialBase *materialDefinition,
314 : Real64 temperaturePrevious,
315 : Real64 temperatureUpdated,
316 : Real64 &updatedSpecificHeat,
317 : Real64 &updatedDensity,
318 : Real64 &updatedThermalConductivity);
319 :
320 : bool findAnySurfacesUsingConstructionAndCondFD(EnergyPlusData const &state, int const constructionNum);
321 :
322 : } // namespace HeatBalFiniteDiffManager
323 :
324 : struct HeatBalFiniteDiffMgr : BaseGlobalStruct
325 : {
326 : Array1D<Real64> SigmaR; // Total Resistance of construction layers
327 : Array1D<Real64> SigmaC; // Total Capacitance of construction layers
328 :
329 : Array1D<Real64> QHeatInFlux; // HeatFlux on Surface for reporting
330 : Array1D<Real64> QHeatOutFlux; // HeatFlux on Surface for reporting
331 :
332 : HeatBalFiniteDiffManager::CondFDScheme CondFDSchemeType =
333 : HeatBalFiniteDiffManager::CondFDScheme::FullyImplicitFirstOrder; // solution scheme for CondFD - default
334 : Real64 SpaceDescritConstant = 3.0; // spatial descritization constant,
335 : int MaxGSiter = 30; // maximum number of Gauss Seidel iterations
336 : Real64 fracTimeStepZone_Hour = 0.0;
337 : bool GetHBFiniteDiffInputFlag = true;
338 : int WarmupSurfTemp = 0;
339 :
340 : // Object Data
341 : Array1D<HeatBalFiniteDiffManager::ConstructionDataFD> ConstructFD;
342 : Array1D<HeatBalFiniteDiffManager::SurfaceDataFD> SurfaceFD;
343 : Array1D<HeatBalFiniteDiffManager::MaterialDataFD> MaterialFD;
344 : bool MyEnvrnFlag = true;
345 :
346 796 : void init_state([[maybe_unused]] EnergyPlusData &state) override
347 : {
348 796 : }
349 :
350 0 : void clear_state() override
351 : {
352 0 : this->SigmaR.deallocate();
353 0 : this->SigmaC.deallocate();
354 0 : this->QHeatInFlux.deallocate();
355 0 : this->QHeatOutFlux.deallocate();
356 0 : this->CondFDSchemeType = HeatBalFiniteDiffManager::CondFDScheme::FullyImplicitFirstOrder;
357 0 : this->SpaceDescritConstant = 3.0;
358 0 : this->MaxGSiter = 30;
359 0 : this->fracTimeStepZone_Hour = 0.0;
360 0 : this->GetHBFiniteDiffInputFlag = true;
361 0 : this->WarmupSurfTemp = 0;
362 0 : this->ConstructFD.deallocate();
363 0 : this->SurfaceFD.deallocate();
364 0 : this->MaterialFD.deallocate();
365 0 : this->MyEnvrnFlag = true;
366 0 : }
367 : };
368 :
369 : } // namespace EnergyPlus
370 :
371 : #endif
|