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 : // C++ Headers
49 : #include <cmath>
50 :
51 : // EnergyPlus Headers
52 : #include <EnergyPlus/Data/EnergyPlusData.hh>
53 : #include <EnergyPlus/DataEnvironment.hh>
54 : #include <EnergyPlus/DataGlobals.hh>
55 : #include <EnergyPlus/UtilityRoutines.hh>
56 :
57 : namespace EnergyPlus::DataEnvironment {
58 :
59 : // MODULE INFORMATION:
60 : // AUTHOR Rick Strand, Dan Fisher, Linda Lawrie
61 : // DATE WRITTEN December 1997
62 : // MODIFIED November 1998, Fred Winkelmann
63 : // MODIFIED June 1999,June 2000, Linda Lawrie
64 : // RE-ENGINEERED na
65 :
66 : // PURPOSE OF THIS MODULE:
67 : // This data-only module is a repository for the variables that relate specifically
68 : // to the "environment" (i.e. current date data, tomorrow's date data, and
69 : // current weather variables)
70 :
71 21337591 : Real64 OutDryBulbTempAt(EnergyPlusData &state, Real64 const Z) // Height above ground (m)
72 : {
73 :
74 : // FUNCTION INFORMATION:
75 : // AUTHOR Peter Graham Ellis
76 : // DATE WRITTEN January 2006
77 : // MODIFIED na
78 : // RE-ENGINEERED na
79 :
80 : // PURPOSE OF THIS FUNCTION:
81 : // Calculates outdoor dry bulb temperature at a given altitude.
82 :
83 : // METHODOLOGY EMPLOYED:
84 : // 1976 U.S. Standard Atmosphere.
85 :
86 : // REFERENCES:
87 : // 1976 U.S. Standard Atmosphere. 1976. U.S. Government Printing Office, Washington, D.C.
88 :
89 : // Using/Aliasing
90 :
91 : // Return value
92 : Real64 LocalOutDryBulbTemp; // Return result for function (C)
93 :
94 : // Locals
95 : // FUNCTION ARGUMENT DEFINITIONS:
96 :
97 : // FUNCTION LOCAL VARIABLE DECLARATIONS:
98 : Real64 BaseTemp; // Base temperature at Z = 0 (C)
99 :
100 21337591 : BaseTemp = state.dataEnvrn->OutDryBulbTemp + state.dataEnvrn->WeatherFileTempModCoeff;
101 :
102 21337591 : if (state.dataEnvrn->SiteTempGradient == 0.0) {
103 0 : LocalOutDryBulbTemp = state.dataEnvrn->OutDryBulbTemp;
104 21337591 : } else if (Z <= 0.0) {
105 13175207 : LocalOutDryBulbTemp = BaseTemp;
106 : } else {
107 8162384 : LocalOutDryBulbTemp = BaseTemp - state.dataEnvrn->SiteTempGradient * DataEnvironment::EarthRadius * Z / (DataEnvironment::EarthRadius + Z);
108 : }
109 :
110 21337591 : if (LocalOutDryBulbTemp < -100.0) {
111 0 : ShowSevereError(state, "OutDryBulbTempAt: outdoor drybulb temperature < -100 C");
112 0 : ShowContinueError(state, format("...check heights, this height=[{:.0R}].", Z));
113 0 : ShowFatalError(state, "Program terminates due to preceding condition(s).");
114 : }
115 :
116 21337591 : return LocalOutDryBulbTemp;
117 : }
118 :
119 769955 : Real64 OutWetBulbTempAt(EnergyPlusData &state, Real64 const Z) // Height above ground (m)
120 : {
121 :
122 : // FUNCTION INFORMATION:
123 : // AUTHOR Peter Graham Ellis
124 : // DATE WRITTEN January 2006
125 : // MODIFIED na
126 : // RE-ENGINEERED na
127 :
128 : // PURPOSE OF THIS FUNCTION:
129 : // Calculates outdoor wet bulb temperature at a given altitude.
130 :
131 : // METHODOLOGY EMPLOYED:
132 : // 1976 U.S. Standard Atmosphere.
133 :
134 : // REFERENCES:
135 : // 1976 U.S. Standard Atmosphere. 1976. U.S. Government Printing Office, Washington, D.C.
136 :
137 : // Return value
138 : Real64 LocalOutWetBulbTemp; // Return result for function (C)
139 :
140 : // FUNCTION LOCAL VARIABLE DECLARATIONS:
141 : Real64 BaseTemp; // Base temperature at Z = 0 (C)
142 :
143 769955 : BaseTemp = state.dataEnvrn->OutWetBulbTemp + state.dataEnvrn->WeatherFileTempModCoeff;
144 :
145 769955 : if (state.dataEnvrn->SiteTempGradient == 0.0) {
146 0 : LocalOutWetBulbTemp = state.dataEnvrn->OutWetBulbTemp;
147 769955 : } else if (Z <= 0.0) {
148 497414 : LocalOutWetBulbTemp = BaseTemp;
149 : } else {
150 272541 : LocalOutWetBulbTemp = BaseTemp - state.dataEnvrn->SiteTempGradient * DataEnvironment::EarthRadius * Z / (DataEnvironment::EarthRadius + Z);
151 : }
152 :
153 769955 : if (LocalOutWetBulbTemp < -100.0) {
154 0 : ShowSevereError(state, "OutWetBulbTempAt: outdoor wetbulb temperature < -100 C");
155 0 : ShowContinueError(state, format("...check heights, this height=[{:.0R}].", Z));
156 0 : ShowFatalError(state, "Program terminates due to preceding condition(s).");
157 : }
158 :
159 769955 : return LocalOutWetBulbTemp;
160 : }
161 :
162 4644575 : Real64 WindSpeedAt(const EnergyPlusData &state, Real64 const Z) // Height above ground (m)
163 : {
164 :
165 : // FUNCTION INFORMATION:
166 : // AUTHOR Peter Graham Ellis
167 : // DATE WRITTEN January 2006
168 :
169 : // PURPOSE OF THIS FUNCTION:
170 : // Calculates local wind speed at a given altitude.
171 :
172 : // METHODOLOGY EMPLOYED:
173 : // 2005 ASHRAE Fundamentals, Chapter 16, Equation 4. (Different depending on terrain).
174 :
175 : // REFERENCES:
176 : // 2005 ASHRAE Fundamentals, Chapter 16, Equation 4. (Different depending on terrain).
177 : // Terrain variables are set in HeatBalanceManager or entered by the user.
178 :
179 4644575 : if (Z <= 0.0) {
180 497414 : return 0.0;
181 4147161 : } else if (state.dataEnvrn->SiteWindExp == 0.0) {
182 0 : return state.dataEnvrn->WindSpeed;
183 : } else {
184 : // [Met] - at meterological Station, Height of measurement is usually 10m above ground
185 : // LocalWindSpeed = Windspeed [Met] * (Wind Boundary LayerThickness [Met]/Height [Met])**Wind Exponent[Met] &
186 : // * (Height above ground / Site Wind Boundary Layer Thickness) ** Site Wind Exponent
187 4147161 : return state.dataEnvrn->WindSpeed * state.dataEnvrn->WeatherFileWindModCoeff *
188 4147161 : std::pow(Z / state.dataEnvrn->SiteWindBLHeight, state.dataEnvrn->SiteWindExp);
189 : }
190 : }
191 :
192 16236 : Real64 OutBaroPressAt(EnergyPlusData &state, Real64 const Z) // Height above ground (m)
193 : {
194 :
195 : // FUNCTION INFORMATION:
196 : // AUTHOR Daeho Kang
197 : // DATE WRITTEN August 2009
198 : // MODIFIED na
199 : // RE-ENGINEERED na
200 :
201 : // PURPOSE OF THIS FUNCTION:
202 : // Calculates local air barometric pressure at a given altitude.
203 :
204 : // METHODOLOGY EMPLOYED:
205 : // U.S. Standard Atmosphere1976, Part 1, Chapter 1.3, Equation 33b.
206 :
207 : // REFERENCES:
208 : // U.S. Standard Atmosphere1976, Part 1, Chapter 1.3, Equation 33b.
209 :
210 : // Return value
211 : Real64 LocalAirPressure; // Return result for function (Pa)
212 :
213 : // FNCTION PARAMETER DEFINITIONS:
214 16236 : Real64 constexpr StdGravity(9.80665); // The acceleration of gravity at the sea level (m/s2)
215 16236 : Real64 constexpr AirMolarMass(0.028964); // Molar mass of Earth's air (kg/mol)
216 16236 : Real64 constexpr GasConstant(8.31432); // Molar gas constant (J/Mol-K)
217 16236 : Real64 constexpr TempGradient(-0.0065); // Molecular-scale temperature gradient (K/m)
218 16236 : Real64 constexpr GeopotentialH(0.0); // Geopotential height (zero within 11km from the sea level) (m)
219 :
220 : // FUNCTION LOCAL VARIABLE DECLARATIONS:
221 : Real64 BaseTemp; // Base temperature at Z
222 :
223 16236 : BaseTemp = OutDryBulbTempAt(state, Z) + Constant::Kelvin;
224 :
225 16236 : if (Z <= 0.0) {
226 0 : LocalAirPressure = 0.0;
227 16236 : } else if (state.dataEnvrn->SiteTempGradient == 0.0) {
228 0 : LocalAirPressure = state.dataEnvrn->OutBaroPress;
229 : } else {
230 16236 : LocalAirPressure = state.dataEnvrn->StdBaroPress * std::pow(BaseTemp / (BaseTemp + TempGradient * (Z - GeopotentialH)),
231 : (StdGravity * AirMolarMass) / (GasConstant * TempGradient));
232 : }
233 :
234 16236 : return LocalAirPressure;
235 : }
236 :
237 0 : void SetOutBulbTempAt_error(EnergyPlusData &state, std::string const &Settings, Real64 const max_height, std::string const &SettingsName)
238 : {
239 : // Using/Aliasing
240 :
241 0 : ShowSevereError(state, format("SetOutBulbTempAt: {} Outdoor Temperatures < -100 C", Settings));
242 0 : ShowContinueError(state, format("...check {} Heights - Maximum {} Height=[{:.0R}].", Settings, Settings, max_height));
243 0 : if (max_height >= 20000.0) {
244 0 : ShowContinueError(state, "...according to your maximum Z height, your building is somewhere in the Stratosphere.");
245 0 : ShowContinueError(state, format("...look at {} Name= {}", Settings, SettingsName));
246 : }
247 0 : ShowFatalError(state, "Program terminates due to preceding condition(s).");
248 0 : }
249 :
250 0 : void SetWindSpeedAt(EnergyPlusData const &state,
251 : int const NumItems,
252 : const Array1D<Real64> &Heights,
253 : Array1D<Real64> &LocalWindSpeed,
254 : [[maybe_unused]] std::string const &Settings)
255 : {
256 :
257 : // SUBROUTINE INFORMATION:
258 : // AUTHOR Linda Lawrie
259 : // DATE WRITTEN June 2013
260 :
261 : // PURPOSE OF THIS SUBROUTINE:
262 : // Routine provides facility for doing bulk Set Windspeed at Height.
263 :
264 0 : if (state.dataEnvrn->SiteWindExp == 0.0) {
265 0 : LocalWindSpeed = state.dataEnvrn->WindSpeed;
266 : } else {
267 0 : Real64 const fac(state.dataEnvrn->WindSpeed * state.dataEnvrn->WeatherFileWindModCoeff *
268 0 : std::pow(state.dataEnvrn->SiteWindBLHeight, -state.dataEnvrn->SiteWindExp));
269 : Real64 Z; // Centroid value
270 0 : for (int i = 1; i <= NumItems; ++i) {
271 0 : Z = Heights(i);
272 0 : if (Z <= 0.0) {
273 0 : LocalWindSpeed(i) = 0.0;
274 : } else {
275 : // [Met] - at meterological Station, Height of measurement is usually 10m above ground
276 : // LocalWindSpeed = Windspeed [Met] * (Wind Boundary LayerThickness [Met]/Height [Met])**Wind Exponent[Met] &
277 : // * (Height above ground / Site Wind Boundary Layer Thickness) ** Site Wind Exponent
278 0 : LocalWindSpeed(i) = fac * std::pow(Z, state.dataEnvrn->SiteWindExp);
279 : }
280 : }
281 : }
282 0 : }
283 :
284 : } // namespace EnergyPlus::DataEnvironment
|