LCOV - code coverage report
Current view: top level - EnergyPlus - SolarCollectors.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 100.0 % 7 7
Test Date: 2025-05-22 16:09:37 Functions: 100.0 % 3 3

            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 SolarCollectors_hh_INCLUDED
      49              : #define SolarCollectors_hh_INCLUDED
      50              : 
      51              : // ObjexxFCL Headers
      52              : #include <ObjexxFCL/Array1D.hh>
      53              : #include <ObjexxFCL/Optional.hh>
      54              : 
      55              : // EnergyPlus Headers
      56              : #include <EnergyPlus/DataGlobals.hh>
      57              : #include <EnergyPlus/EPVector.hh>
      58              : #include <EnergyPlus/EnergyPlus.hh>
      59              : #include <EnergyPlus/Plant/DataPlant.hh>
      60              : #include <EnergyPlus/PlantComponent.hh>
      61              : 
      62              : namespace EnergyPlus {
      63              : 
      64              : // Forward declarations
      65              : struct EnergyPlusData;
      66              : 
      67              : namespace SolarCollectors {
      68              : 
      69              :     enum struct TestTypeEnum
      70              :     {
      71              :         INVALID = -1,
      72              :         INLET,
      73              :         AVERAGE,
      74              :         OUTLET,
      75              :         NUM
      76              :     };
      77              :     constexpr std::array<std::string_view, static_cast<int>(TestTypeEnum::NUM)> testTypesUC = {"INLET", "AVERAGE", "OUTLET"};
      78              : 
      79              :     struct ParametersData
      80              :     {
      81              :         std::string Name;                                    // Name of solar collector parameters
      82              :         Real64 Area = 0.0;                                   // Gross area of collector (m2)
      83              :         Real64 TestMassFlowRate = 0.0;                       // Test volumetric flow rate (m3/s)
      84              :         TestTypeEnum TestType = TestTypeEnum::INLET;         // Test correlation type (INLET | AVERAGE | OUTLET)
      85              :         Real64 eff0 = 0.0;                                   // Coefficient 1 of efficiency equation (Y-intercept)
      86              :         Real64 eff1 = 0.0;                                   // Coefficient 2 of efficiency equation (1st order)
      87              :         Real64 eff2 = 0.0;                                   // Coefficient 3 of efficiency equation (2nd order)
      88              :         Real64 iam1 = 0.0;                                   // Coefficient 2 of incident angle modifier (1st order)
      89              :         Real64 iam2 = 0.0;                                   // Coefficient 3 of incident angle modifier (2nd order)
      90              :         Real64 Volume = 0.0;                                 // collector water net volume (m3)
      91              :         Real64 SideHeight = 0.0;                             // collector side height (m)
      92              :         Real64 ThermalMass = 0.0;                            // thermal mass of the absorber plate (J/m2C)
      93              :         Real64 ULossSide = 0.0;                              // heat loss conductance for collector side (W/m2C)
      94              :         Real64 ULossBottom = 0.0;                            // heat loss conductance for collector bottom (W/m2C)
      95              :         Real64 AspectRatio = 0.0;                            // collector aspect ratio (dimensionless)
      96              :         int NumOfCovers = 0;                                 // number of transparent collector covers
      97              :         Real64 CoverSpacing = 0.0;                           // collector cover spacings (m)
      98              :         std::array<Real64, 2> RefractiveIndex = {0.0};       // refractive index of inner and outer covers (dimensionless)
      99              :         std::array<Real64, 2> ExtCoefTimesThickness = {0.0}; // extinction coefficient times thickness of covers (dimensionless)
     100              :         std::array<Real64, 2> EmissOfCover = {0.0};          // emissivity of inner and outer covers (dimensionless)
     101              :         Real64 EmissOfAbsPlate = 0.0;                        // emissivity Of absorber plate (dimensionless)
     102              :         Real64 AbsorOfAbsPlate = 0.0;                        // absorptance of the absorber plate (dimensionless)
     103              : 
     104              :         Real64 IAM(EnergyPlusData &state, Real64 IncidentAngle);
     105              :     };
     106              : 
     107              :     struct CollectorData : PlantComponent
     108              :     {
     109              :         std::string Name;                                                            // Name of solar collector
     110              :         std::string BCType;                                                          // Boundary condition Type
     111              :         std::string OSCMName;                                                        // OtherSideConditionsModel
     112              :         int VentCavIndex = 0;                                                        // index of ventilated cavity object
     113              :         DataPlant::PlantEquipmentType Type = DataPlant::PlantEquipmentType::Invalid; // Plant Side Connection: 'Type' assigned in DataPlant
     114              :         PlantLocation plantLoc;                                                      // Water plant loop component location object
     115              :         bool Init = true;                                                            // Flag for initialization:  TRUE means do the init
     116              :         bool InitSizing = true;                                                      // Flag for initialization of plant sizing
     117              :         int Parameters = 0;                                                          // Parameters object number
     118              :         int Surface = 0;                                                             // Surface object number
     119              :         int InletNode = 0;                                                           // Inlet node
     120              :         Real64 InletTemp = 0.0;                                                      // Inlet temperature from plant (C)
     121              :         int OutletNode = 0;                                                          // Outlet node
     122              :         Real64 OutletTemp = 0.0;      // Outlet temperature or stagnation temperature in the collector (C)
     123              :         Real64 MassFlowRate = 0.0;    // Mass flow rate through the collector (kg/s)
     124              :         Real64 MassFlowRateMax = 0.0; // Maximum mass flow rate through the collector (kg/s)
     125              :         Real64 VolFlowRateMax = 0.0;  // Maximum volumetric flow rate through the collector (m3/s)
     126              :         int ErrIndex = 0;             // Error index for recurring error
     127              :         int IterErrIndex = 0;         // Error index for recurring error (iteration - did not converge)
     128              :         // Report variables
     129              :         Real64 IncidentAngleModifier = 0.0; // Net incident angle modifier
     130              :         Real64 Efficiency = 0.0;            // Thermal efficiency of solar energy conversion
     131              :         Real64 Power = 0.0;                 // Heat gain or loss to collector fluid (W)
     132              :         Real64 HeatGain = 0.0;              // Heat gain to collector fluid (W)
     133              :         Real64 HeatLoss = 0.0;              // Heat loss from collector fluid (W)
     134              :         Real64 Energy = 0.0;                // Energy gained (or lost) to collector fluid (J)
     135              :         // Report variables
     136              :         Real64 HeatRate = 0.0;           // Collector useful Heat gain rate [W]
     137              :         Real64 HeatEnergy = 0.0;         // Collector useful Heat gain energy [J]
     138              :         Real64 StoredHeatRate = 0.0;     // net heat gain or loss rate of the collector fluid [W]
     139              :         Real64 StoredHeatEnergy = 0.0;   // net heat gain or loss energy of the collector fluid [J]
     140              :         Real64 HeatGainRate = 0.0;       // Collector useful Heat gain rate [W]
     141              :         Real64 SkinHeatLossRate = 0.0;   // collector skin heat loss rate [W]
     142              :         Real64 CollHeatLossEnergy = 0.0; // collector skin heat loss energy[J]
     143              :         Real64 TauAlpha = 0.0;           // Transmittance-absorptance product total radiation
     144              :         Real64 UTopLoss = 0.0;           // Over all top loss coefficient [W/m2.C]
     145              :         Real64 TempOfWater = 0.0;        // average temperature of the collector water [C]
     146              :         Real64 TempOfAbsPlate = 0.0;     // average temperature of the abs plate [C]
     147              :         Real64 TempOfInnerCover = 0.0;   // temperature of the collector inner cover [C]
     148              :         Real64 TempOfOuterCover = 0.0;   // temperature of the collector inner cover [C]
     149              :         // Data from elsewhere and calculated
     150              :         Real64 TauAlphaSkyDiffuse = 0.0;                   // Transmittance-absorptance product sky diffuse radiation
     151              :         Real64 TauAlphaGndDiffuse = 0.0;                   // Transmittance-absorptance product grn diffuse radiation
     152              :         Real64 TauAlphaBeam = 0.0;                         // Transmittance-absorptance product beam radiation
     153              :         std::array<Real64, 2> CoversAbsSkyDiffuse = {0.0}; // sky diffuse solar absorptance of cover
     154              :         std::array<Real64, 2> CoversAbsGndDiffuse = {0.0}; // ground diffuse solar absorptance of cover
     155              :         std::array<Real64, 2> CoverAbs = {0.0};            // solar rad weighted covers absorptance
     156              :         Real64 TimeElapsed = 0.0;                          // Fraction of the current hour that has elapsed (h)
     157              :         // Saved in order to identify the beginning of a new system time
     158              :         Real64 UbLoss = 0.0;                 // Over all bottom loss coefficient [W/m2C]
     159              :         Real64 UsLoss = 0.0;                 // Over all side loss coefficient [W/m2C]
     160              :         Real64 AreaRatio = 0.0;              // Side area to collector area ratio [-]
     161              :         Real64 RefDiffInnerCover = 0.0;      // diffuse reflectance of the inner cover (cover 1) from bottom
     162              :         Real64 SavedTempOfWater = 0.0;       // water temp carried from time step to time step [C]
     163              :         Real64 SavedTempOfAbsPlate = 0.0;    // abs plate temp carried from time step to time step [C]
     164              :         Real64 SavedTempOfInnerCover = 0.0;  // inner cover temp carried from time step to time step [C]
     165              :         Real64 SavedTempOfOuterCover = 0.0;  // outer cover temp carried from time step to time step [C]
     166              :         Real64 SavedTempCollectorOSCM = 0.0; // Temperature of collector back from OSCM at previous time step [C]
     167              :         Real64 Length = 0.0;                 // characteristic length of the abs plate
     168              :         Real64 TiltR2V = 0.0;                // collector tilt angle from the vertical [degree]
     169              :         Real64 Tilt = 0.0;                   // collector tilt angle from the horizontal [degree]
     170              :         Real64 CosTilt = 0.0;                // cosine of collector tilt angle [-]
     171              :         Real64 SinTilt = 0.0;                // sine of 1.8 times collector tilt angle [-]
     172              :         Real64 SideArea = 0.0;               // weighted collector side area (m2)
     173              :         Real64 Area = 0.0;                   // collector area (m2)
     174              :         Real64 Volume = 0.0;                 // collector net volume (m3)
     175              :         bool OSCM_ON = false;                // Boundary condition is OSCM
     176              :         bool InitICS = false;                // used to initialize ICS variables only
     177              :         bool SetLoopIndexFlag = true;
     178              :         bool SetDiffRadFlag = true;
     179              : 
     180              :         static PlantComponent *factory(EnergyPlusData &state, std::string const &objectName);
     181              : 
     182              :         void setupOutputVars(EnergyPlusData &state);
     183              : 
     184              :         void initialize(EnergyPlusData &state);
     185              : 
     186              :         void simulate([[maybe_unused]] EnergyPlusData &state,
     187              :                       const PlantLocation &calledFromLocation,
     188              :                       bool FirstHVACIteration,
     189              :                       Real64 &CurLoad,
     190              :                       bool RunFlag) override;
     191              : 
     192              :         void CalcTransRefAbsOfCover(EnergyPlusData &state,
     193              :                                     Real64 IncidentAngle,                         // Angle of incidence (radians)
     194              :                                     Real64 &TransSys,                             // cover system solar transmittance
     195              :                                     Real64 &ReflSys,                              // cover system solar reflectance
     196              :                                     Real64 &AbsCover1,                            // Inner cover solar absorptance
     197              :                                     Real64 &AbsCover2,                            // Outer cover solar absorptance
     198              :                                     ObjexxFCL::Optional_bool_const InOUTFlag = _, // flag for calc. diffuse solar refl of cover from inside out
     199              :                                     ObjexxFCL::Optional<Real64> RefSysDiffuse = _ // cover system solar reflectance from inner to outer cover
     200              :         ) const;
     201              : 
     202              :         void CalcSolarCollector(EnergyPlusData &state);
     203              : 
     204              :         void CalcICSSolarCollector(EnergyPlusData &state);
     205              : 
     206              :         void CalcTransAbsorProduct(EnergyPlusData &state, Real64 IncidAngle);
     207              : 
     208              :         void CalcHeatTransCoeffAndCoverTemp(EnergyPlusData &state);
     209              : 
     210              :         static void ICSCollectorAnalyticalSolution(EnergyPlusData &state,
     211              :                                                    Real64 SecInTimeStep,     // seconds in a time step
     212              :                                                    Real64 a1,                // coefficient of ODE for Tp
     213              :                                                    Real64 a2,                // coefficient of ODE for Tp
     214              :                                                    Real64 a3,                // coefficient of ODE for Tp
     215              :                                                    Real64 b1,                // coefficient of ODE for TW
     216              :                                                    Real64 b2,                // coefficient of ODE for TW
     217              :                                                    Real64 b3,                // coefficient of ODE for TW
     218              :                                                    Real64 TempAbsPlateOld,   // absorber plate temperature at previous time step [C]
     219              :                                                    Real64 TempWaterOld,      // collector water temperature at previous time step [C]
     220              :                                                    Real64 &TempAbsPlate,     // absorber plate temperature at current time step [C]
     221              :                                                    Real64 &TempWater,        // collector water temperature at current time step [C]
     222              :                                                    bool AbsorberPlateHasMass // flag for absorber thermal mass
     223              :         );
     224              : 
     225              :         static Real64 CalcConvCoeffBetweenPlates(Real64 TempSurf1, // temperature of surface 1
     226              :                                                  Real64 TempSurf2, // temperature of surface 1
     227              :                                                  Real64 AirGap,    // characteristic length [m]
     228              :                                                  Real64 CosTilt,   // cosine of surface tilt angle relative to the horizontal
     229              :                                                  Real64 SinTilt    // sine of surface tilt angle relative to the horizontal
     230              :         );
     231              : 
     232              :         static Real64 CalcConvCoeffAbsPlateAndWater(EnergyPlusData &state,
     233              :                                                     Real64 TAbsorber, // temperature of absorber plate [C]
     234              :                                                     Real64 TWater,    // temperature of water [C]
     235              :                                                     Real64 Lc,        // characteristic length [m]
     236              :                                                     Real64 TiltR2V    // collector tilt angle relative to the vertical [degree]
     237              :         );
     238              : 
     239              :         static void GetExtVentedCavityIndex(EnergyPlusData &state, int SurfacePtr, int &VentCavIndex);
     240              : 
     241              :         void update(EnergyPlusData &state);
     242              : 
     243              :         void report(EnergyPlusData &state);
     244              : 
     245              :         void oneTimeInit_new(EnergyPlusData &state) override;
     246              : 
     247              :         void oneTimeInit(EnergyPlusData &state) override;
     248              :     };
     249              : 
     250              :     void GetSolarCollectorInput(EnergyPlusData &state);
     251              : 
     252              : } // namespace SolarCollectors
     253              : 
     254              : struct SolarCollectorsData : BaseGlobalStruct
     255              : {
     256              :     int NumOfCollectors = 0;
     257              :     int NumOfParameters = 0;
     258              :     bool GetInputFlag = true;
     259              :     EPVector<SolarCollectors::ParametersData> Parameters;
     260              :     EPVector<SolarCollectors::CollectorData> Collector;
     261              :     std::unordered_map<std::string, std::string> UniqueParametersNames;
     262              :     std::unordered_map<std::string, std::string> UniqueCollectorNames;
     263              : 
     264         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     265              :     {
     266         2126 :     }
     267              : 
     268         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     269              :     {
     270         1152 :     }
     271              : 
     272         2100 :     void clear_state() override
     273              :     {
     274         2100 :         new (this) SolarCollectorsData();
     275         2100 :     }
     276              : };
     277              : 
     278              : } // namespace EnergyPlus
     279              : 
     280              : #endif
        

Generated by: LCOV version 2.0-1