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 : #ifndef DataEnvironment_hh_INCLUDED
49 : #define DataEnvironment_hh_INCLUDED
50 :
51 : // ObjexxFCL Headers
52 : #include <ObjexxFCL/Array1D.hh>
53 : #include <ObjexxFCL/Vector3.hh>
54 :
55 : using ObjexxFCL::Vector3;
56 :
57 : // EnergyPlus Headers
58 : #include <EnergyPlus/Data/BaseData.hh>
59 : #include <EnergyPlus/EnergyPlus.hh>
60 : #include <EnergyPlus/ScheduleManager.hh>
61 :
62 : namespace EnergyPlus {
63 :
64 : // Forward declarations
65 : struct EnergyPlusData;
66 :
67 : namespace DataEnvironment {
68 :
69 : enum class GroundTempType
70 : {
71 : Invalid = -1,
72 : BuildingSurface,
73 : Shallow,
74 : Deep,
75 : FCFactorMethod,
76 : Num
77 : };
78 :
79 : Real64 constexpr EarthRadius(6356000.0); // Radius of the Earth (m)
80 : Real64 constexpr AtmosphericTempGradient(0.0065); // Standard atmospheric air temperature gradient (K/m)
81 : Real64 constexpr SunIsUpValue(0.00001); // if Cos Zenith Angle of the sun is >= this value, the sun is "up"
82 : Real64 constexpr StdPressureSeaLevel(101325.0); // Standard barometric pressure at sea level (Pa)
83 :
84 : Real64 OutDryBulbTempAt(EnergyPlusData &state, Real64 Z); // Height above ground (m)
85 :
86 : Real64 OutWetBulbTempAt(EnergyPlusData &state, Real64 Z); // Height above ground (m)
87 :
88 : Real64 WindSpeedAt(const EnergyPlusData &state, Real64 Z); // Height above ground (m)
89 :
90 : Real64 OutBaroPressAt(EnergyPlusData &state, Real64 Z); // Height above ground (m)
91 :
92 : void SetOutBulbTempAt_error(EnergyPlusData &state, std::string const &Settings, Real64 max_height, std::string const &SettingsName);
93 :
94 : } // namespace DataEnvironment
95 :
96 : struct EnvironmentData : BaseGlobalStruct
97 : {
98 : Real64 BeamSolarRad = 0.0; // Current beam normal solar irradiance
99 : bool EMSBeamSolarRadOverrideOn = false; // EMS flag for beam normal solar irradiance
100 : Real64 EMSBeamSolarRadOverrideValue = 0.0; // EMS override value for beam normal solar irradiance
101 : int DayOfMonth = 0; // Current day of the month
102 : int DayOfMonthTomorrow = 0; // Tomorrow's day of the month
103 : int DayOfWeek = 0; // Current day of the week (Sunday=1, Monday=2, ...)
104 : int DayOfWeekTomorrow = 0; // Tomorrow's day of the week (Sunday=1, Monday=2, ...)
105 : int DayOfYear = 0; // Current day of the year (01JAN=1, 02JAN=2, ...)
106 : int DayOfYear_Schedule = 0; // Schedule manager always assumes leap years...
107 : Real64 DifSolarRad = 0.0; // Current sky diffuse solar horizontal irradiance
108 : bool EMSDifSolarRadOverrideOn = false; // EMS flag for sky diffuse solar horizontal irradiance
109 : Real64 EMSDifSolarRadOverrideValue = 0.0; // EMS override value for sky diffuse solar horizontal irradiance
110 : int DSTIndicator = 0; // Daylight Saving Time Indicator (1=yes, 0=no) for Today
111 : Real64 Elevation = 0.0; // Elevation of this building site
112 : bool EndMonthFlag = false; // Set to true on last day of month
113 : bool EndYearFlag = false; // Set to true on the last day of year
114 : Real64 GndReflectanceForDayltg = 0.0; // Ground visible reflectance for use in daylighting calc
115 : Real64 GndReflectance = 0.0; // Ground visible reflectance from input
116 : Real64 GndSolarRad = 0.0; // Current ground reflected radiation
117 : Real64 GroundTempKelvin = 0.0; // Current ground temperature {K}
118 : std::array<Real64, (int)DataEnvironment::GroundTempType::Num> GroundTemp = {0.0, 0.0, 0.0, 0.0};
119 :
120 : int HolidayIndex = 0; // Indicates whether current day is a holiday and if so what type - HolidayIndex=(0-no holiday, 1-holiday type 1, ...)
121 : int HolidayIndexTomorrow = 0; // Tomorrow's Holiday Index
122 : bool IsRain = false; // Surfaces are wet for this time interval
123 : bool IsSnow = false; // Snow on the ground for this time interval
124 : Real64 Latitude = 0.0; // Latitude of building location
125 : Real64 Longitude = 0.0; // Longitude of building location
126 : int Month = 0; // Current calendar month
127 : int MonthTomorrow = 0; // Tomorrow's calendar month
128 : Real64 OutBaroPress = 0.0; // Current outdoor air barometric pressure
129 : Real64 OutDryBulbTemp = 0.0; // Current outdoor air dry bulb temperature
130 : bool EMSOutDryBulbOverrideOn = false; // EMS flag for outdoor air dry bulb temperature
131 : Real64 EMSOutDryBulbOverrideValue = 0.0; // EMS override value for outdoor air dry bulb temperature
132 : Real64 OutHumRat = 0.0; // Current outdoor air humidity ratio
133 : Real64 OutRelHum = 0.0; // Current outdoor relative humidity [%]
134 : Real64 OutRelHumValue = 0.0; // Current outdoor relative humidity value [0.0-1.0]
135 : bool EMSOutRelHumOverrideOn = false; // EMS flag for outdoor relative humidity value
136 : Real64 EMSOutRelHumOverrideValue = 0.0; // EMS override value for outdoor relative humidity value
137 : Real64 OutEnthalpy = 0.0; // Current outdoor enthalpy
138 : Real64 OutAirDensity = 0.0; // Current outdoor air density
139 : Real64 OutWetBulbTemp = 0.0; // Current outdoor air wet bulb temperature
140 : Real64 OutDewPointTemp = 0.0; // Current outdoor dewpoint temperature
141 : bool EMSOutDewPointTempOverrideOn = false; // EMS flag for outdoor dewpoint temperature
142 : Real64 EMSOutDewPointTempOverrideValue = 0.0; // EMS override value for outdoor dewpoint temperature
143 : Real64 SkyTemp = 0.0; // Current sky temperature {C}
144 : Real64 SkyTempKelvin = 0.0; // Current sky temperature {K}
145 : Real64 LiquidPrecipitation = 0.0; // Current liquid precipitation amount (rain) {m}
146 : bool SunIsUp = false; // True when Sun is over horizon, False when not
147 : bool SunIsUpPrevTS = false; // True when Sun is over horizon in the previous timestep, False when not in the previous timestep
148 : bool PreviousSolRadPositive = false; // True when Sun is over horizon at the previous timestep, and BeamSolarRad + GndSolarRad + DifSolarRad > 0.0
149 : Real64 WindDir = 0.0; // Current outdoor air wind direction
150 : bool EMSWindDirOverrideOn = false; // EMS flag for outdoor air wind direction
151 : Real64 EMSWindDirOverrideValue = 0.0; // EMS override value for outdoor air wind direction
152 : Real64 WindSpeed = 0.0; // Current outdoor air wind speed
153 : bool EMSWindSpeedOverrideOn = false; // EMS flag for outdoor air wind speed
154 : Real64 EMSWindSpeedOverrideValue = false; // EMS override value for outdoor air wind speed
155 : Real64 WaterMainsTemp = 0.0; // Current water mains temperature
156 : int Year = 0; // Current calendar year of the simulation from the weather file
157 : int YearTomorrow = 0; // Tomorrow's calendar year of the simulation
158 : Vector3<Real64> SOLCOS = {0.0, 0.0, 0.0}; // Solar direction cosines at current time step
159 : Real64 CloudFraction = 0.0; // Fraction of sky covered by clouds
160 : Real64 HISKF = 0.0; // Exterior horizontal illuminance from sky (lux).
161 : Real64 HISUNF = 0.0; // Exterior horizontal beam illuminance (lux)
162 : Real64 HISUNFnorm = 0.0; // Exterior beam normal illuminance (lux)
163 : Real64 PDIRLW = 0.0; // Luminous efficacy (lum/W) of beam solar radiation
164 : Real64 PDIFLW = 0.0; // Luminous efficacy (lum/W) of sky diffuse solar radiation
165 : Real64 SkyClearness = 0.0; // Sky clearness (see subr. DayltgLuminousEfficacy)
166 : Real64 SkyBrightness = 0.0; // Sky brightness (see subr. DayltgLuminousEfficacy)
167 : Real64 TotalCloudCover = 5.0; // Total Sky Cover (tenth of sky)
168 : Real64 OpaqueCloudCover = 5.0; // Opaque Sky Cover (tenth of sky)
169 : Real64 StdBaroPress = DataEnvironment::StdPressureSeaLevel; // Standard "atmospheric pressure" based on elevation (ASHRAE HOF p6.1)
170 : Real64 StdRhoAir = 0.0; // Standard "rho air" set in WeatherManager - based on StdBaroPress
171 : Real64 rhoAirSTP = 0.0; // Standard density of dry air at 101325 Pa, 20.0C temperature
172 : Real64 TimeZoneNumber = 0.0; // Time Zone Number of building location
173 : Real64 TimeZoneMeridian = 0.0; // Standard Meridian of TimeZone
174 : std::string EnvironmentName; // Current environment name (longer for weather file names)
175 : std::string WeatherFileLocationTitle; // Location Title from Weather File
176 : std::string CurMnDyHr; // Current Month/Day/Hour timestamp info
177 : std::string CurMnDy; // Current Month/Day timestamp info
178 : std::string CurMnDyYr; // Current Month/Day/Year timestamp info
179 : int CurEnvirNum = 0; // current environment number
180 : int TotDesDays = 0; // Total number of Design days to Setup
181 : int TotRunDesPersDays = 0; // Total number of Run Design Periods [Days] (Weather data) to Setup
182 : int CurrentOverallSimDay = 0; // Count of current simulation day in total of all sim days
183 : int TotalOverallSimDays = 0; // Count of all possible simulation days in all environments
184 : int MaxNumberSimYears = 0; // Maximum number of simulation years requested in all RunPeriod statements
185 : int RunPeriodStartDayOfWeek = 0; // Day of week of the first day of the run period. (or design day - day of week)
186 : Real64 CosSolarDeclinAngle = 0.0; // Cosine of the solar declination angle
187 : Real64 EquationOfTime = 0.0; // Value of the equation of time formula
188 : Real64 SinLatitude = 0.0; // Sine of Latitude
189 : Real64 CosLatitude = 0.0; // Cosine of Latitude
190 : Real64 SinSolarDeclinAngle = 0.0; // Sine of the solar declination angle
191 : Real64 TS1TimeOffset = -0.5; // offset when TS=1 for solar calculations
192 : Real64 WeatherFileWindModCoeff = 1.5863; // =(WindBLHeight/WindSensorHeight)**WindExp for conditions at the weather station
193 : Real64 WeatherFileTempModCoeff = 0.0; // =AtmosphericTempGradient*EarthRadius*SensorHeight/(EarthRadius+SensorHeight)
194 : Real64 SiteWindExp = 0.22; // Exponent for the wind velocity profile at the site
195 : Real64 SiteWindBLHeight = 370.0; // Boundary layer height for the wind velocity profile at the site (m)
196 : Real64 SiteTempGradient = 0.0065; // Air temperature gradient coefficient (K/m)
197 :
198 : std::array<bool, (int)DataEnvironment::GroundTempType::Num> GroundTempInputs = {false, false, false, false}; // Ground temperature object input
199 :
200 : bool DisplayWeatherMissingDataWarnings = false; // Display missing/out of range weather warnings
201 : bool IgnoreSolarRadiation = false; // TRUE if all solar radiation is to be ignored
202 : bool IgnoreBeamRadiation = false; // TRUE if beam (aka direct normal) radiation is to be ignored
203 : bool IgnoreDiffuseRadiation = false; // TRUE if diffuse horizontal radiation is to be ignored
204 : bool PrintEnvrnStampWarmup = false;
205 : bool PrintEnvrnStampWarmupPrinted = false;
206 : bool RunPeriodEnvironment = false; // True if Run Period, False if DesignDay
207 : int StartYear = 0; // Start year for Environment
208 : int EndYear = 0; // End year for Environment
209 : std::string EnvironmentStartEnd; // Start/End dates for Environment
210 : bool CurrentYearIsLeapYear =
211 : false; // true when current year is leap year (convoluted logic dealing with whether weather file allows leap years, runperiod inputs.
212 : Sched::Schedule *varyingLocationLatSched = nullptr;
213 : Sched::Schedule *varyingLocationLongSched = nullptr;
214 : Sched::Schedule *varyingOrientationSched = nullptr;
215 : bool forceBeginEnvResetSuppress = false; // for PerformancePrecisionTradeoffs
216 : bool oneTimeCompRptHeaderFlag = true;
217 :
218 2126 : void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
219 : {
220 2126 : }
221 :
222 1152 : void init_state([[maybe_unused]] EnergyPlusData &state) override
223 : {
224 1152 : }
225 :
226 2100 : void clear_state() override
227 : {
228 2100 : new (this) EnvironmentData();
229 2100 : }
230 : };
231 :
232 : } // namespace EnergyPlus
233 :
234 : #endif
|