LCOV - code coverage report
Current view: top level - EnergyPlus - SolarCollectors.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 3 6 50.0 %
Date: 2023-01-17 19:17:23 Functions: 8 12 66.7 %

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

Generated by: LCOV version 1.13