LCOV - code coverage report
Current view: top level - EnergyPlus - DaylightingManager.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 2 48 4.2 %
Date: 2024-08-24 18:31:18 Functions: 1 2 50.0 %

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

Generated by: LCOV version 1.14