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 DaylightingManager_hh_INCLUDED
49 : #define DaylightingManager_hh_INCLUDED
50 :
51 : // ObjexxFCL Headers
52 : #include <ObjexxFCL/Array1A.hh>
53 : #include <ObjexxFCL/Array2A.hh>
54 : #include <ObjexxFCL/Array2S.hh>
55 : #include <ObjexxFCL/Vector3.fwd.hh>
56 :
57 : // EnergyPlus Headers
58 : #include <EnergyPlus/DataBSDFWindow.hh>
59 : #include <EnergyPlus/DataDaylighting.hh>
60 : #include <EnergyPlus/DataSurfaces.hh>
61 : #include <EnergyPlus/EnergyPlus.hh>
62 :
63 : namespace EnergyPlus {
64 :
65 : // Forward declarations
66 : struct EnergyPlusData;
67 :
68 : namespace Dayltg {
69 :
70 : // Surface count crossover for using octree algorithm
71 : // The octree gives lower computational complexity for much higher performance
72 : // as the surface count increases but has some overhead such that the direct
73 : // algorithm can be more efficient at small surface counts.
74 : // Testing to date shows that the octree performance is close to that of the
75 : // direct algorithm even with small surface counts and that there is no single
76 : // crossover that is ideal for all models: some cases with 10-30 surfaces were
77 : // faster with the octree but another with 80 surfaces was faster with the
78 : // direct algorithm.
79 : // A reasonable, conservative crossover is selected but may be refined as more
80 : // experience is gained.
81 : constexpr int octreeCrossover(100); // Octree surface count crossover
82 : constexpr int NTH(18); // Number of azimuth steps for sky integration
83 : constexpr int NPH(8); // Number of altitude steps for sky integration
84 :
85 : // It's crazy having both NPH and NPHMAX
86 : constexpr int NPHMAX(10); // Number of sky/ground integration steps in altitude
87 : constexpr int NTHMAX(16); // Number of sky/ground integration steps in azimuth
88 :
89 : struct SunAngles
90 : {
91 : Real64 phi = 0.0; // Solar altitude (radians)
92 : Real64 sinPhi = 0.0;
93 : Real64 cosPhi = 0.0;
94 : Real64 theta = 0.0; // Solar azimuth (rad) in Absolute Coordinate System (azimuth=0 along east)
95 : };
96 :
97 : void DayltgAveInteriorReflectance(EnergyPlusData &state, int const enclNum); // Enclosure number
98 :
99 : void CalcDayltgCoefficients(EnergyPlusData &state);
100 :
101 : void CalcDayltgCoeffsRefMapPoints(EnergyPlusData &state);
102 :
103 : void CalcDayltgCoeffsRefPoints(EnergyPlusData &state, int const daylightCtrlNum);
104 :
105 : void CalcDayltgCoeffsMapPoints(EnergyPlusData &state, int const mapNum);
106 :
107 : void FigureDayltgCoeffsAtPointsSetupForWindow(EnergyPlusData &state,
108 : int const daylightCtrlNum, // zero if called for map points
109 : int const iRefPoint,
110 : int const loopwin,
111 : CalledFor const CalledFrom, // indicate which type of routine called this routine
112 : Vector3<Real64> const &RREF, // Location of a reference point in absolute coordinate system
113 : Vector3<Real64> const &VIEWVC, // View vector in absolute coordinate system
114 : int &IWin,
115 : int &IWin2,
116 : int &NWX,
117 : int &NWY,
118 : Vector3<Real64> &W2, // Second vertex of window
119 : Vector3<Real64> &W3, // Third vertex of window
120 : Vector3<Real64> &W21, // Vector from window vertex 2 to window vertex 1
121 : Vector3<Real64> &W23, // Vector from window vertex 2 to window vertex 3
122 : int &LSHCAL, // Interior shade calculation flag: 0=not yet calculated, 1=already calculated
123 : int &InShelfSurf, // Inside daylighting shelf surface number
124 : int &ICtrl, // Window control counter
125 : DataSurfaces::WinShadingType &ShType, // Window shading type
126 : int &BlNum, // Window blind number
127 : Vector3<Real64> &WNORM2, // Unit vector normal to window
128 : ExtWinType &ExtWinType, // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin)
129 : int &IConst, // Construction counter
130 : Vector3<Real64> &RREF2, // Location of virtual reference point in absolute coordinate system
131 : Real64 &DWX, // Horizontal dimension of window element (m)
132 : Real64 &DWY, // Vertical dimension of window element (m)
133 : Real64 &DAXY, // Area of window element
134 : Vector3<Real64> &U2, // Second vertex of window for TDD:DOME (if exists)
135 : Vector3<Real64> &U23, // Vector from window vertex 2 to window vertex 3 for TDD:DOME (if exists)
136 : Vector3<Real64> &U21, // Vector from window vertex 2 to window vertex 1 for TDD:DOME (if exists)
137 : Vector3<Real64> &VIEWVC2, // Virtual view vector in absolute coordinate system
138 : bool &Rectangle, // True if window is rectangular
139 : bool &Triangle, // True if window is triangular
140 : int const MapNum = 0);
141 :
142 : void FigureDayltgCoeffsAtPointsForWindowElements(
143 : EnergyPlusData &state,
144 : int const daylightCtrlNum, // Current daylighting control number (only used when called from RefPoint)
145 : int const iRefPoint,
146 : int const loopwin,
147 : CalledFor const CalledFrom, // indicate which type of routine called this routine
148 : int const WinEl, // Current window element number
149 : int const IWin,
150 : int const IWin2,
151 : int const iXelement,
152 : int const iYelement,
153 : Real64 &SkyObstructionMult,
154 : Vector3<Real64> const &W2, // Second vertex of window
155 : Vector3<Real64> const &W21, // Vector from window vertex 2 to window vertex 1
156 : Vector3<Real64> const &W23, // Vector from window vertex 2 to window vertex 3
157 : Vector3<Real64> const &RREF, // Location of a reference point in absolute coordinate system
158 : int const NWYlim, // For triangle, largest NWY for a given IX
159 : Vector3<Real64> const &VIEWVC2, // Virtual view vector in absolute coordinate system
160 : Real64 const DWX, // Horizontal dimension of window element (m)
161 : Real64 const DWY, // Vertical dimension of window element (m)
162 : Real64 const DAXY, // Area of window element
163 : Vector3<Real64> const &U2, // Second vertex of window for TDD:DOME (if exists)
164 : Vector3<Real64> const &U23, // Vector from window vertex 2 to window vertex 3 for TDD:DOME (if exists)
165 : Vector3<Real64> const &U21, // Vector from window vertex 2 to window vertex 1 for TDD:DOME (if exists)
166 : Vector3<Real64> &RWIN, // Center of a window element for TDD:DOME (if exists) in abs coord sys
167 : Vector3<Real64> &RWIN2, // Center of a window element for TDD:DOME (if exists) in abs coord sys
168 : Vector3<Real64> &Ray, // Unit vector along ray from reference point to window element
169 : Real64 &PHRAY, // Altitude of ray from reference point to window element (radians)
170 : int &LSHCAL, // Interior shade calculation flag: 0=not yet calculated, 1=already calculated
171 : Real64 &COSB, // Cosine of angle between window outward normal and ray from reference point to window element
172 : Real64 &ObTrans, // Product of solar transmittances of exterior obstructions hit by ray
173 : Real64 &TVISB, // Visible transmittance of window for COSB angle of incidence (times light well
174 : Real64 &DOMEGA, // Solid angle subtended by window element wrt reference point (steradians)
175 : Real64 &THRAY, // Azimuth of ray from reference point to window element (radians)
176 : bool &hitIntObs, // True iff interior obstruction hit
177 : bool &hitExtObs, // True iff ray from ref pt to ext win hits an exterior obstruction
178 : Vector3<Real64> const &WNORM2, // Unit vector normal to window
179 : ExtWinType const ExtWinType, // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin)
180 : int const IConst, // Construction counter
181 : Vector3<Real64> const &RREF2, // Location of virtual reference point in absolute coordinate system
182 : bool const Triangle,
183 : Real64 &TVISIntWin, // Visible transmittance of int win at COSBIntWin for light from ext win
184 : Real64 &TVISIntWinDisk, // Visible transmittance of int win at COSBIntWin for sun
185 : int const MapNum = 0);
186 :
187 : void InitializeCFSDaylighting(EnergyPlusData &state,
188 : int const daylightCtrlNum, // Current daylighting control number
189 : int const IWin, // Complex fenestration number
190 : int const NWX, // Number of horizontal divisions
191 : int const NWY, // Number of vertical divisions
192 : Vector3<Real64> const &RefPoint, // reference point coordinates
193 : int const NRefPts, // Number of reference points
194 : int const iRefPoint, // Reference points counter
195 : CalledFor const CalledFrom,
196 : int const MapNum = 0);
197 :
198 : void InitializeCFSStateData(EnergyPlusData &state,
199 : DataBSDFWindow::BSDFRefPoints &StateRefPoint,
200 : DataBSDFWindow::BSDFRefPointsGeomDescr &DaylghtGeomDescr,
201 : int const daylightCtrlNum, // Current daylighting control number
202 : int const iWin,
203 : Vector3<Real64> const &RefPoint, // reference point
204 : int const CurFenState,
205 : int const NBasis,
206 : int const NTrnBasis,
207 : Real64 const AZVIEW,
208 : int const NWX,
209 : int const NWY,
210 : Vector3<Real64> const &W2,
211 : Vector3<Real64> const &W21,
212 : Vector3<Real64> const &W23,
213 : Real64 const DWX,
214 : Real64 const DWY,
215 : Vector3<Real64> const &WNorm, // unit vector from window (point towards outside)
216 : Real64 const WinElArea);
217 :
218 : void AllocateForCFSRefPointsState(
219 : EnergyPlusData &state, DataBSDFWindow::BSDFRefPoints &StateRefPoint, int const NumOfWinEl, int const NBasis, int const NTrnBasis);
220 :
221 : void AllocateForCFSRefPointsGeometry(DataBSDFWindow::BSDFRefPointsGeomDescr &RefPointsGeomDescr, int const NumOfWinEl);
222 :
223 : void CFSRefPointSolidAngle(EnergyPlusData &state,
224 : Vector3<Real64> const &RefPoint,
225 : Vector3<Real64> const &RWin,
226 : Vector3<Real64> const &WNorm,
227 : DataBSDFWindow::BSDFRefPoints &RefPointMap,
228 : DataBSDFWindow::BSDFRefPointsGeomDescr &RefPointGeomMap,
229 : int const iWin,
230 : int const CurFenState,
231 : int const NTrnBasis,
232 : int const curWinEl,
233 : Real64 const WinElArea);
234 :
235 : void CFSRefPointPosFactor(EnergyPlusData &state,
236 : Vector3<Real64> const &RefPoint,
237 : DataBSDFWindow::BSDFRefPoints &RefPointMap,
238 : int const iWin,
239 : int const CurFenState,
240 : int const NTrnBasis,
241 : Real64 const AZVIEW);
242 :
243 : Real64 CalcObstrMultiplier(EnergyPlusData &state,
244 : Vector3<Real64> const &GroundHitPt, // Coordinates of point that ray hits ground (m)
245 : int const AltSteps, // Number of steps in altitude angle for solar reflection calc
246 : int const AzimSteps // Number of steps in azimuth angle of solar reflection calc
247 : );
248 :
249 : void FigureDayltgCoeffsAtPointsForSunPosition(
250 : EnergyPlusData &state,
251 : int const daylightCtrlNum, // Current daylighting control number
252 : int const iRefPoint,
253 : int const iXelement,
254 : int const NWX, // Number of window elements in x direction for dayltg calc
255 : int const iYelement,
256 : int const NWY, // Number of window elements in y direction for dayltg calc
257 : int const WinEl, // Current window element counter
258 : int const IWin,
259 : int const IWin2,
260 : int const iHour,
261 : int &ISunPos,
262 : Real64 const SkyObstructionMult,
263 : Vector3<Real64> const &RWIN2, // Center of a window element for TDD:DOME (if exists) in abs coord sys
264 : Vector3<Real64> const &Ray, // Unit vector along ray from reference point to window element
265 : Real64 const PHRAY, // Altitude of ray from reference point to window element (radians)
266 : int const LSHCAL, // Interior shade calculation flag: 0=not yet calculated, 1=already calculated
267 : int const InShelfSurf, // Inside daylighting shelf surface number
268 : Real64 const COSB, // Cosine of angle between window outward normal and ray from reference point to window element
269 : Real64 const ObTrans, // Product of solar transmittances of exterior obstructions hit by ray from reference point through a window element
270 : Real64 const TVISB, // Visible transmittance of window for COSB angle of incidence (times light well efficiency, if appropriate)
271 : Real64 const DOMEGA, // Solid angle subtended by window element wrt reference point (steradians)
272 : int const ICtrl, // Window control counter
273 : DataSurfaces::WinShadingType const ShType, // Window shading type
274 : int const BlNum, // Window blind number
275 : Real64 const THRAY, // Azimuth of ray from reference point to window element (radians)
276 : Vector3<Real64> const &WNORM2, // Unit vector normal to window
277 : ExtWinType const ExtWinType, // Exterior window type (InZoneExtWin, AdjZoneExtWin, NotInOrAdjZoneExtWin)
278 : int const IConst, // Construction counter
279 : Real64 const AZVIEW, // Azimuth of view vector in absolute coord system for glare calculation (radians)
280 : Vector3<Real64> const &RREF2, // Location of virtual reference point in absolute coordinate system
281 : bool const hitIntObs, // True iff interior obstruction hit
282 : bool const hitExtObs, // True iff ray from ref pt to ext win hits an exterior obstruction
283 : CalledFor const CalledFrom, // indicate which type of routine called this routine
284 : Real64 TVISIntWin, // Visible transmittance of int win at COSBIntWin for light from ext win
285 : Real64 &TVISIntWinDisk, // Visible transmittance of int win at COSBIntWin for sun
286 : int const MapNum = 0);
287 :
288 : void FigureRefPointDayltgFactorsToAddIllums(EnergyPlusData &state,
289 : int const daylightCtrlNum, // Current daylighting control number
290 : int const iRefPoint,
291 : int const iHour,
292 : int &ISunPos,
293 : int const IWin,
294 : int const loopwin,
295 : int const NWX, // Number of window elements in x direction for dayltg calc
296 : int const NWY, // Number of window elements in y direction for dayltg calc
297 : int const ICtrl // Window control counter
298 : );
299 :
300 : void FigureMapPointDayltgFactorsToAddIllums(EnergyPlusData &state,
301 : int const MapNum,
302 : int const iMapPoint,
303 : int const iHour,
304 : int const IWin,
305 : int const loopwin,
306 : int const ICtrl // Window control counter
307 : );
308 :
309 : void GetDaylightingParametersInput(EnergyPlusData &state);
310 :
311 : void GetInputIlluminanceMap(EnergyPlusData &state, bool &ErrorsFound);
312 :
313 : void GetDaylightingControls(EnergyPlusData &state, bool &ErrorsFound);
314 :
315 : void GeometryTransformForDaylighting(EnergyPlusData &state);
316 :
317 : void GetInputDayliteRefPt(EnergyPlusData &state, bool &ErrorsFound);
318 :
319 : bool doesDayLightingUseDElight(EnergyPlusData const &state);
320 :
321 : void CheckTDDsAndLightShelvesInDaylitZones(EnergyPlusData &state);
322 :
323 : void AssociateWindowShadingControlWithDaylighting(EnergyPlusData &state);
324 :
325 : void GetLightWellData(EnergyPlusData &state, bool &ErrorsFound); // If errors found in input
326 :
327 : int findWinShadingStatus(int const IWin);
328 :
329 : Real64 DayltgGlare(EnergyPlusData &state,
330 : int IL, // Reference point index: 1=first ref pt, 2=second ref pt
331 : Real64 BLUM, // Window background (surround) luminance (cd/m2)
332 : int const daylightCtrlNum // Current daylighting control number
333 : );
334 :
335 : void DayltgGlareWithIntWins(EnergyPlusData &state,
336 : int const daylightCtrlNum // Current daylighting control number
337 : );
338 :
339 : void DayltgExtHorizIllum(EnergyPlusData &state,
340 : Illums &HI // Horizontal illuminance from sky for different sky types
341 : );
342 :
343 : // Product of solar transmittances of exterior obstructions
344 : Real64 DayltgHitObstruction(EnergyPlusData &state,
345 : int const IHOUR, // Hour number
346 : int const IWin, // Window index
347 : Vector3<Real64> const &R1, // Origin of ray (m)
348 : Vector3<Real64> const &RN // Destination of ray (m)
349 : );
350 :
351 : bool DayltgHitInteriorObstruction(EnergyPlusData &state,
352 : int const IWin, // Window index
353 : Vector3<Real64> const &R1, // Origin of ray (m)
354 : Vector3<Real64> const &R2 // Destination of ray (m)
355 : );
356 :
357 : bool DayltgHitBetWinObstruction(EnergyPlusData &state,
358 : int const IWin1, // Surface number of origin window
359 : int const IWin2, // Surface number of destination window
360 : Vector3<Real64> const &R1, // Origin of ray (on IWin1) (m)
361 : Vector3<Real64> const &R2 // Destination of ray (on IWin2) (m)
362 : );
363 :
364 : void initDaylighting(EnergyPlusData &state, bool const initSurfaceHeatBalancefirstTime);
365 :
366 : void manageDaylighting(EnergyPlusData &state);
367 :
368 : void DayltgInteriorIllum(EnergyPlusData &state, int const daylightCtrlNum); // Daylighting:Controls number
369 :
370 : void DayltgInteriorTDDIllum(EnergyPlusData &state);
371 :
372 : void DayltgElecLightingControl(EnergyPlusData &state);
373 :
374 : Real64 DayltgGlarePositionFactor(Real64 X, // Lateral and vertical distance of luminous window element from
375 : Real64 Y);
376 :
377 : void DayltgInterReflectedIllum(EnergyPlusData &state,
378 : int const ISunPos, // Sun position counter; used to avoid calculating various
379 : int const IHR, // Hour of day
380 : int const enclNum, // Daylighting enclosure index
381 : int const IWin // Window index
382 : );
383 :
384 : void ComplexFenestrationLuminances(EnergyPlusData &state,
385 : int const IWin,
386 : int const WinEl,
387 : int const NBasis,
388 : int const IHR,
389 : int const iRefPoint,
390 : Array1D<Illums> &ElementLuminanceSky, // sky related luminance at window element (exterior side)
391 : CalledFor const CalledFrom,
392 : int const MapNum = 0);
393 :
394 : void DayltgInterReflectedIllumComplexFenestration(EnergyPlusData &state,
395 : int const IWin, // Window index
396 : int const WinEl, // Current window element counter
397 : int const IHR, // Hour of day
398 : int const daylightCtrlNum, // Daylighting control number
399 : int const iRefPoint, // reference point counter
400 : CalledFor const CalledFrom,
401 : int const MapNum = 0);
402 :
403 : void DayltgDirectIllumComplexFenestration(EnergyPlusData &state,
404 : int const IWin, // Window index
405 : int const WinEl, // Current window element counter
406 : int const IHR, // Hour of day
407 : int const iRefPoint, // reference point index
408 : CalledFor const CalledFrom,
409 : int const MapNum = 0);
410 :
411 : void DayltgDirectSunDiskComplexFenestration(EnergyPlusData &state,
412 : int const iWin, // Window index
413 : int const iHour, // Hour of day
414 : int const iRefPoint,
415 : int const NumEl, // Total number of window elements
416 : Real64 const AZVIEW, // Azimuth of view vector in absolute coord system for
417 : CalledFor const CalledFrom, // indicate which type of routine called this routine
418 : int const MapNum = 0);
419 :
420 : Real64 DayltgSkyLuminance(EnergyPlusData const &state,
421 : SkyType sky, // Sky type: 1=clear, 2=clear turbid, 3=intermediate, 4=overcast
422 : Real64 const THSKY, // Azimuth and altitude of sky element (radians)
423 : Real64 const PHSKY);
424 :
425 : // Solar profile angle (radians).
426 : Real64 ProfileAngle(EnergyPlusData &state,
427 : int const SurfNum, // Surface number
428 : Vector3<Real64> const &CosDirSun, // Solar direction cosines
429 : DataWindowEquivalentLayer::Orientation const HorOrVert // If HORIZONTAL, calculates ProfileAngHor
430 : );
431 :
432 : void DayltgClosestObstruction(EnergyPlusData &state,
433 : Vector3<Real64> const &RecPt, // Point on window from which ray emanates (m)
434 : Vector3<Real64> const &RayVec, // Unit vector along ray pointing away from window (m)
435 : int &NearestHitSurfNum, // Surface number of nearest obstruction that is hit by ray;
436 : Vector3<Real64> &NearestHitPt // Ray's hit point on nearest obstruction (m)
437 : );
438 :
439 : // Luminance at ReflHitPt from beam solar reflection for unit
440 : Real64 DayltgSurfaceLumFromSun(EnergyPlusData &state,
441 : int const IHR, // Hour number
442 : Vector3<Real64> const &Ray, // Ray from window to reflecting surface (m)
443 : int const ReflSurfNum, // Number of surface for which luminance is being calculated
444 : Vector3<Real64> const &ReflHitPt // Point on ReflSurfNum for luminance calculation (m)
445 : );
446 :
447 : void DayltgInteriorMapIllum(EnergyPlusData &state);
448 :
449 : void ReportIllumMap(EnergyPlusData &state, int const MapNum);
450 :
451 : void CloseReportIllumMaps(EnergyPlusData &state);
452 :
453 : void CloseDFSFile(EnergyPlusData &state);
454 :
455 : void DayltgSetupAdjZoneListsAndPointers(EnergyPlusData &state);
456 :
457 : void CreateShadeDeploymentOrder(EnergyPlusData &state, int const enclNum);
458 :
459 : void MapShadeDeploymentOrderToLoopNumber(EnergyPlusData &state, int const enclNum);
460 :
461 : void DayltgInterReflIllFrIntWins(EnergyPlusData &state, int const enclNum);
462 :
463 : void CalcMinIntWinSolidAngs(EnergyPlusData &state);
464 :
465 : void CheckForGeometricTransform(EnergyPlusData &state, bool &doTransform, Real64 &OldAspectRatio, Real64 &NewAspectRatio);
466 :
467 : void WriteDaylightMapTitle(EnergyPlusData &state,
468 : int const mapNum,
469 : InputOutputFile &mapFile,
470 : std::string const &mapName,
471 : std::string const &environmentName,
472 : int const ZoneNum,
473 : std::string const &refPts,
474 : Real64 const zcoord);
475 :
476 : } // namespace Dayltg
477 :
478 : struct DaylightingData : BaseGlobalStruct
479 : {
480 : int maxControlRefPoints = 0;
481 : int maxShadeDeployOrderExtWins = 0;
482 : int maxDayltgExtWins = 0;
483 : int maxEnclSubSurfaces = 0;
484 :
485 : bool mapResultsToReport = false; // used when only partial hour has "sun up"
486 : bool mapResultsReported = false; // when no map results are ever reported this will still be false
487 : char MapColSep; // Character for separating map columns (tab, space, comma)
488 : bool DFSReportSizingDays = false;
489 : bool DFSReportAllShadowCalculationDays = false;
490 :
491 : Array1D<Dayltg::EnclDaylightCalc> enclDaylight;
492 : Array1D<Dayltg::ZoneDaylightCalc> ZoneDaylight;
493 : Array1D<Dayltg::DaylightingControl> daylightControl;
494 : Array1D<Dayltg::IllumMap> illumMaps;
495 : Array1D<Dayltg::RefPointData> DaylRefPt;
496 : Array1D<Dayltg::DElightComplexFeneData> DElightComplexFene;
497 : Array1D<Real64> spacePowerReductionFactor; // Average electric power reduction factor for space due to daylighting
498 :
499 : bool CalcDayltghCoefficients_firstTime = true;
500 : bool getDaylightingParametersInputFlag = true;
501 : bool refFirstTime = true;
502 : bool DayltgInteriorIllum_firstTime = true; // true first time routine is called
503 : bool FirstTimeDaylFacCalc = true;
504 : bool VeryFirstTime = true;
505 : bool mapFirstTime = true;
506 : bool CheckTDDs_firstTime = true;
507 : bool DayltgExtHorizIllum_firstTime = true; // flag for first time thru to initialize
508 : bool DayltgInteriorMapIllum_FirstTimeFlag = true;
509 : bool ReportIllumMap_firstTime = true;
510 : bool SQFirstTime = true;
511 : bool doSkyReporting = true;
512 : bool CreateDFSReportFile = true;
513 :
514 : int TotWindowsWithDayl = 0; // Total number of exterior windows in all daylit zones
515 : Array1D<Real64> DaylIllum; // Daylight illuminance at reference points (lux)
516 : int maxNumRefPtInAnyDaylCtrl = 0; // The most number of reference points that any single daylighting control has
517 : int maxNumRefPtInAnyEncl = 0; // The most number of reference points that any single enclosure has
518 :
519 : Dayltg::SunAngles sunAngles = Dayltg::SunAngles();
520 : std::array<Dayltg::SunAngles, (int)Constant::iHoursInDay + 1> sunAnglesHr = {Dayltg::SunAngles()};
521 :
522 : // In the following I,J,K arrays:
523 : // I = 1 for clear sky, 2 for clear turbid, 3 for intermediate, 4 for overcast;
524 : // J = 1 for bare window, 2 - 12 for shaded;
525 : // K = sun position index.
526 : std::array<Dayltg::Illums, (int)Constant::iHoursInDay + 1> horIllum = {
527 : Dayltg::Illums()}; // Horizontal illuminance from sky, by sky type, for each hour of the day
528 : Array1D<std::array<Dayltg::Illums, (int)DataSurfaces::WinCover::Num>> dirIllum; // Sky-related component of direct illuminance
529 : Array1D<std::array<Dayltg::Illums, (int)DataSurfaces::WinCover::Num>> reflIllum; // Sky-related portion of internally reflected illuminance
530 : Array1D<std::array<Dayltg::Illums, (int)DataSurfaces::WinCover::Num>> winLum; // Sky-related window luminance
531 :
532 : Array1D<std::array<Dayltg::Illums, (int)DataSurfaces::WinCover::Num>> avgWinLum; // Sky-related average window luminance
533 : // Allocatable daylight factor arrays -- are in the ZoneDaylight Structure
534 :
535 : Array2D<Real64> TDDTransVisBeam;
536 : Array2D<Dayltg::Illums> TDDFluxInc;
537 : Array2D<Dayltg::Illums> TDDFluxTrans;
538 :
539 : Array2D_int MapErrIndex;
540 : Array2D_int RefErrIndex;
541 :
542 : bool MySunIsUpFlag = false;
543 : bool CalcDayltgCoeffsMapPointsMySunIsUpFlag = false;
544 : int AltSteps_last = 0;
545 : std::array<Real64, DataSurfaces::AltAngStepsForSolReflCalc / 2 + 1> cos_Phi = {0.0}; // cos( Phi ) table
546 : std::array<Real64, DataSurfaces::AltAngStepsForSolReflCalc / 2 + 1> sin_Phi = {0.0}; // sin( Phi ) table
547 : int AzimSteps_last = 0;
548 : std::array<Real64, 2 *DataSurfaces::AzimAngStepsForSolReflCalc + 1> cos_Theta = {0.0}; // cos( Theta ) table
549 : std::array<Real64, 2 *DataSurfaces::AzimAngStepsForSolReflCalc + 1> sin_Theta = {0.0}; // sin( Theta ) table
550 :
551 : std::array<Real64, Dayltg::NPH + 1> PH; // Altitude of sky element (radians)
552 :
553 : // Ratio of obstructed to unobstructed sky diffuse at a ground point for each (TH,PH) direction
554 : std::array<Real64, Dayltg::NTH + 1> TH; // Azimuth of sky element (radians)
555 : std::array<Real64, Dayltg::NPH + 1> SPHCPH; // Sine times cosine of altitude of sky element
556 :
557 : // Not sure why these need to be state variables and can't local
558 : // variable of DayltgInterReflectIllum(), but some EMS tests break
559 : // if they are made local
560 : std::array<std::array<Real64, Dayltg::NTHMAX + 1>, Dayltg::NPHMAX + 1> SkyObstructionMult;
561 : std::array<std::array<Real64, Dayltg::NTHMAX + 1>, Dayltg::NPHMAX + 1> ObTransM; // ObTrans value for each (TH,PH) direction
562 :
563 : Array1D_bool FirstTimeMaps;
564 : Array1D_bool EnvrnPrint;
565 : Array1D_string SavedMnDy;
566 : Array1D<Real64> XValue;
567 : Array1D<Real64> YValue;
568 : Array2D<Real64> IllumValue;
569 :
570 2126 : void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
571 : {
572 2126 : }
573 :
574 1152 : void init_state([[maybe_unused]] EnergyPlusData &state) override
575 : {
576 1152 : }
577 :
578 2100 : void clear_state() override
579 : {
580 2100 : this->CalcDayltghCoefficients_firstTime = true;
581 2100 : this->getDaylightingParametersInputFlag = true;
582 2100 : this->refFirstTime = true;
583 2100 : this->DayltgInteriorIllum_firstTime = true;
584 2100 : this->FirstTimeDaylFacCalc = true;
585 2100 : this->VeryFirstTime = true;
586 2100 : this->mapFirstTime = true;
587 2100 : this->CheckTDDs_firstTime = true;
588 2100 : this->DayltgExtHorizIllum_firstTime = true;
589 2100 : this->DayltgInteriorMapIllum_FirstTimeFlag = true;
590 2100 : this->ReportIllumMap_firstTime = true;
591 2100 : this->SQFirstTime = true;
592 2100 : this->doSkyReporting = true;
593 2100 : this->CreateDFSReportFile = true;
594 2100 : this->TotWindowsWithDayl = 0;
595 2100 : this->DaylIllum.deallocate();
596 2100 : this->maxNumRefPtInAnyDaylCtrl = 0;
597 2100 : this->maxNumRefPtInAnyEncl = 0;
598 2100 : this->sunAngles = Dayltg::SunAngles();
599 2100 : this->sunAnglesHr = {Dayltg::SunAngles()};
600 :
601 2100 : this->horIllum = {Dayltg::Illums()};
602 2100 : this->dirIllum.deallocate();
603 2100 : this->reflIllum.deallocate();
604 2100 : this->winLum.deallocate();
605 2100 : this->avgWinLum.deallocate();
606 :
607 2100 : this->TDDTransVisBeam.deallocate();
608 2100 : this->TDDFluxInc.deallocate();
609 2100 : this->TDDFluxTrans.deallocate();
610 2100 : this->MapErrIndex.deallocate();
611 2100 : this->RefErrIndex.deallocate();
612 2100 : this->MySunIsUpFlag = false;
613 2100 : this->CalcDayltgCoeffsMapPointsMySunIsUpFlag = false;
614 2100 : this->AltSteps_last = 0;
615 2100 : this->AzimSteps_last = 0;
616 2100 : this->cos_Phi = {0.0};
617 2100 : this->sin_Phi = {0.0};
618 2100 : this->cos_Theta = {0.0};
619 2100 : this->sin_Theta = {0.0};
620 2100 : this->FirstTimeMaps.clear();
621 2100 : this->EnvrnPrint.clear();
622 2100 : this->SavedMnDy.clear();
623 2100 : this->XValue.clear();
624 2100 : this->YValue.clear();
625 2100 : this->IllumValue.clear();
626 2100 : }
627 : };
628 :
629 : } // namespace EnergyPlus
630 :
631 : #endif
|