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

            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 DataPhotovoltaics_hh_INCLUDED
      49              : #define DataPhotovoltaics_hh_INCLUDED
      50              : 
      51              : // ObjexxFCL Headers
      52              : #include <ObjexxFCL/Array1D.hh>
      53              : 
      54              : // EnergyPlus Headers
      55              : #include <EnergyPlus/Data/BaseData.hh>
      56              : #include <EnergyPlus/DataGlobals.hh>
      57              : #include <EnergyPlus/EnergyPlus.hh>
      58              : 
      59              : namespace EnergyPlus {
      60              : 
      61              : namespace DataPhotovoltaics {
      62              : 
      63              :     Real64 constexpr MinIrradiance = 0.3; // [W/m2] Assume no operation if Ic is below this number (W/m2)
      64              : 
      65              :     enum class PVModel
      66              :     {
      67              :         Invalid = -1,
      68              :         Simple,
      69              :         TRNSYS,
      70              :         Sandia,
      71              :         Num
      72              :     };
      73              : 
      74              :     enum class CellIntegration
      75              :     {
      76              :         Invalid = -1,             // cell temp method not set
      77              :         Decoupled,                // cell temp method based on energy balance
      78              :         DecoupledUllebergDynamic, // cell temp method based on energy bal with capacity
      79              :         SurfaceOutsideFace,       // cell temp method based on coupling to E+'s heat balance
      80              :         TranspiredCollector,      // cell temp method based on coupling to unglazed transpired co
      81              :         ExteriorVentedCavity,     // cell temp method based on coupling to nat vent exterior cavi
      82              :         PVTSolarCollector,        // cell temp method based on coupling to PVT model
      83              :         Num
      84              :     };
      85              : 
      86              :     enum class Efficiency
      87              :     {
      88              :         Invalid = -1,
      89              :         Fixed,     // simple PV, constant efficiency
      90              :         Scheduled, // simple PV, scheduled efficiency
      91              :         Num
      92              :     };
      93              : 
      94              :     enum class SiPVCells
      95              :     {
      96              :         Invalid = -1,
      97              :         Crystalline,
      98              :         Amorphous,
      99              :         Num
     100              :     };
     101              : 
     102              :     struct SimplePVParamsStruct
     103              :     {
     104              :         // Members
     105              :         std::string Name;                    // name as identified in Sandia database
     106              :         Real64 AreaCol;                      // effective area of solar collection
     107              :         Real64 ActiveFraction;               // fraction of parent surface that has active solar cells
     108              :         Efficiency EfficencyInputMode;       // to schedule or not
     109              :         Sched::Schedule *effSched = nullptr; // index pointer for efficiency schedule
     110              :         Real64 PVEfficiency;                 // fixed or current PV efficiency
     111              : 
     112              :         // Default Constructor
     113            6 :         SimplePVParamsStruct() : AreaCol(0.0), ActiveFraction(0.0), EfficencyInputMode(Efficiency::Invalid), PVEfficiency(0.0)
     114              :         {
     115            6 :         }
     116              :     };
     117              : 
     118              :     struct TRNSYSPVModuleParamsStruct // for  GENERATOR:PV:Equivalent One-Diode Model
     119              :     {
     120              :         // Members
     121              :         std::string Name;
     122              :         int CellsInSeries;           // cells in series [-]
     123              :         SiPVCells CellType;          // type of PV cell (crystalline, amorphous )
     124              :         Real64 Area;                 // module area [m2]
     125              :         Real64 TauAlpha;             // tau alpha product at normal incidence [-]
     126              :         Real64 SemiConductorBandgap; // electron bandgap [eV]
     127              :         Real64 ShuntResistance;      // shunt resistance [ohms]
     128              :         Real64 RefIsc;               // short circuit current at reference conditions [A/K]
     129              :         Real64 RefVoc;               // open circuit voltage at reference conditions [V/K]
     130              :         Real64 RefTemperature;       // temperature at reference conditions
     131              :         Real64 RefInsolation;        // radiation at reference conditions [W/m2]
     132              :         Real64 Imp;                  // current at max power [A]
     133              :         Real64 Vmp;                  // voltage at max power [V]
     134              :         Real64 TempCoefIsc;          // temperature coefficient of short circuit current
     135              :         Real64 TempCoefVoc;          // temperature coefficient of open circuit voltage
     136              :         Real64 NOCTAmbTemp;          // ambient temperature at NOCT [C]
     137              :         Real64 NOCTCellTemp;         // cell temperature at NOCT [C]
     138              :         Real64 NOCTInsolation;       // radiation at NOCT [W/m2]
     139              :         Real64 HeatLossCoef;         // heat loss coefficient [W/m2.K]
     140              :         Real64 HeatCapacity;         // total heat capacity (only used in TC mode 1)
     141              : 
     142              :         // Default Constructor
     143            6 :         TRNSYSPVModuleParamsStruct()
     144           12 :             : CellsInSeries(0), CellType(SiPVCells::Invalid), Area(0.0), TauAlpha(0.0), SemiConductorBandgap(0.0), ShuntResistance(0.0), RefIsc(0.0),
     145            6 :               RefVoc(0.0), RefTemperature(0.0), RefInsolation(0.0), Imp(0.0), Vmp(0.0), TempCoefIsc(0.0), TempCoefVoc(0.0), NOCTAmbTemp(0.0),
     146            6 :               NOCTCellTemp(0.0), NOCTInsolation(0.0), HeatLossCoef(0.0), HeatCapacity(0.0)
     147              :         {
     148            6 :         }
     149              :     };
     150              : 
     151              :     struct TRNSYSPVCalcStruct
     152              :     {
     153              :         // Members
     154              :         Real64 Insolation;      // radiation [W/m2]
     155              :         Real64 ArrayCurrent;    // array current at current conditions [A]
     156              :         Real64 ArrayVoltage;    // array voltage at current conditions [V]
     157              :         Real64 ArrayPower;      // array power at current conditions [W]
     158              :         Real64 ArrayEfficiency; // array efficiency at current conditions [0..1]
     159              :         Real64 CellTemp;        // array cell temperature at current conditions [C]
     160              :         Real64 CellTempK;       // array cell temperature (for setting last cell temp) [K]
     161              :         Real64 TimeElapsed;     // time previous update of last cell temp
     162              :         Real64 LastCellTempK;   // array cell temperature at previous conditions [K]
     163              :         Real64 ArrayIsc;        // array short circuit current at current conditions [A]
     164              :         Real64 ArrayVoc;        // array open circuit voltage at current conditions [V]
     165              : 
     166              :         // Default Constructor
     167            5 :         TRNSYSPVCalcStruct()
     168            5 :             : Insolation(0.0), ArrayCurrent(0.0), ArrayVoltage(0.0), ArrayPower(0.0), ArrayEfficiency(0.0), CellTemp(0.0), CellTempK(0.0),
     169            5 :               TimeElapsed(0.0), LastCellTempK(0.0), ArrayIsc(0.0), ArrayVoc(0.0)
     170              :         {
     171            5 :         }
     172              :     };
     173              : 
     174              :     struct SNLModuleParamsStuct // for PV MODULE:SANDIA PARAMETERS
     175              :     {
     176              :         // Members
     177              :         std::string name;    // name as identified in Sandia database
     178              :         Real64 Acoll;        // Active collector area (m2, single module)
     179              :         Real64 NcellSer;     // Number of cells in series in a module's cell-string (unitless)
     180              :         Real64 NparSerCells; // Number of cell-strings in parallel in module (unitless)
     181              :         Real64 Isc0;         // Short circuit current at reference conditions (Amps)
     182              :         Real64 Voc0;         // Open circuit voltage at reference conditions (Volts)
     183              :         Real64 Imp0;         // Max power point current at reference conditions (Amps)
     184              :         Real64 Vmp0;         // Voltage at max power at reference conditions (Volts)
     185              :         Real64 aIsc;         // Normalized temperature coefficient for Isc (Amps/degC) Isc temperature coeff
     186              :         Real64 aImp;         // Normalized temperature coefficient for Imp (1/degC) Imp temperature coeff
     187              :         Real64 c_0;          // Empirical coefficients relating Imp to Ee (unitless)
     188              :         //   coefficient relating Imp to irradiance
     189              :         Real64 c_1; // Empirical coefficients relating Imp to Ee (unitless)
     190              :         //   coefficient relating Voc to irradiance
     191              :         Real64 BVoc0; // Temperature coefficient for module open-circuit-voltage at reference conditions
     192              :         //   (Volts/degC)
     193              :         Real64 mBVoc; // Coefficient for irradiance dependence of open-circuit-voltage-temperature
     194              :         //  coefficient  (V/°C)
     195              :         Real64 BVmp0; // Temperature coefficient for module maximum-power-voltage at reference conditions
     196              :         //   (V/°C)
     197              :         Real64 mBVmp; // Cofficient for irradiance dependence of maximum-power-voltage-temperature
     198              :         //   coefficient (V/°C)
     199              :         Real64 DiodeFactor; // Empirically determined 'diode factor' for individual cells (unitless)
     200              :         Real64 c_2;         // Empirical coefficients relating Vmp to Ee (unitless)
     201              :         //   (coefficient relating Vmp to irradiance)
     202              :         Real64 c_3; // Empirical coefficients relating Vmp to Ee (unitless)
     203              :         //   (coefficient relating Vmp to irradiance)
     204              :         Real64 a_0; // Empirical coefficients for f1(AMa) polynomial (unitless)
     205              :         Real64 a_1; // Empirical coefficients for f1(AMa) polynomial (unitless)
     206              :         Real64 a_2; // Empirical coefficients for f1(AMa) polynomial (unitless)
     207              :         Real64 a_3; // Empirical coefficients for f1(AMa) polynomial (unitless)
     208              :         Real64 a_4; // Empirical coefficients for f1(AMa) polynomial (unitless)
     209              :         Real64 b_0; // Empirical coefficients for f1(AOI) polynomial (unitless)
     210              :         Real64 b_1; // Empirical coefficients for f1(AOI) polynomial (unitless)
     211              :         Real64 b_2; // Empirical coefficients for f1(AOI) polynomial (unitless)
     212              :         Real64 b_3; // Empirical coefficients for f1(AOI) polynomial (unitless)
     213              :         Real64 b_4; // Empirical coefficients for f1(AOI) polynomial (unitless)
     214              :         Real64 b_5; // Empirical coefficients for f1(AOI) polynomial (unitless)
     215              :         Real64 DT0; // Temperature difference between Tc and Tm at Eo (°C),
     216              :         // (This is d(Tc) in Sandia database)
     217              :         Real64 fd; // Fraction of diffuse irradiance used by module (unitless)
     218              :         Real64 a;  // Empirical coefficient for module temp.at low wind,
     219              :         // high solar irradiance (unitless)
     220              :         Real64 b; // Empirical coefficient relating module temp.
     221              :         // decrease with increasing wind speed (unitless)
     222              :         Real64 c_4;  // Empirical coefficients relating Ix to Ee (unitless)
     223              :         Real64 c_5;  // Empirical coefficients relating Ix to Ee (unitless)
     224              :         Real64 Ix0;  // Current at V = 0.5 Voc and at reference conditions (Amps)
     225              :         Real64 Ixx0; // Current at V = 0.5 (Vmp + Voc) and at reference conditions (Amps)
     226              :         Real64 c_6;  // Empirical coefficients relating Ixx to Ee (unitless)
     227              :         Real64 c_7;  // Empirical coefficients relating Ixx to Ee (unitless)
     228              : 
     229              :         // Default Constructor
     230            5 :         SNLModuleParamsStuct()
     231           10 :             : Acoll(0.0), NcellSer(0.0), NparSerCells(0.0), Isc0(0.0), Voc0(0.0), Imp0(0.0), Vmp0(0.0), aIsc(0.0), aImp(0.0), c_0(0.0), c_1(0.0),
     232            5 :               BVoc0(0.0), mBVoc(0.0), BVmp0(0.0), mBVmp(0.0), DiodeFactor(0.0), c_2(0.0), c_3(0.0), a_0(0.0), a_1(0.0), a_2(0.0), a_3(0.0), a_4(0.0),
     233            5 :               b_0(0.0), b_1(0.0), b_2(0.0), b_3(0.0), b_4(0.0), b_5(0.0), DT0(0.0), fd(0.0), a(0.0), b(0.0), c_4(0.0), c_5(0.0), Ix0(0.0), Ixx0(0.0),
     234            5 :               c_6(0.0), c_7(0.0)
     235              :         {
     236            5 :         }
     237              :     };
     238              : 
     239              :     struct SNLPVInputStruct // for data obtained elsewhere in EnergyPlus
     240              :     {
     241              :         // Members
     242              :         Real64 IcBeam;         // incident beam solar (W/m2)
     243              :         Real64 IcDiffuse;      // incident diffuse solar (W/m2)
     244              :         Real64 IncidenceAngle; // angle from normal for beam (deg)
     245              :         Real64 ZenithAngle;    // solar zenith angle (deg)
     246              :         Real64 Tamb;           // outdoor drybulb temperature (C)
     247              :         Real64 WindSpeed;      // outdoor windspeed. (m/s)
     248              :         Real64 Altitude;       // elevation above sea level. (m)
     249              : 
     250              :         // Default Constructor
     251            5 :         SNLPVInputStruct() : IcBeam(0.0), IcDiffuse(0.0), IncidenceAngle(0.0), ZenithAngle(0.0), Tamb(0.0), WindSpeed(0.0), Altitude(0.0)
     252              :         {
     253            5 :         }
     254              :     };
     255              : 
     256              :     struct SNLPVCalcStruct // hold calculated results from PV modeling.
     257              :     {
     258              :         // Members
     259              :         Real64 Vmp;         // (Volts) maximum power voltage
     260              :         Real64 Imp;         // (Amps) maximum power current
     261              :         Real64 Pmp;         // (W) (was kJ/hr) maximum power point power
     262              :         Real64 EffMax;      // (unitless) conversion efficiency at max power point
     263              :         Real64 Isc;         // (Amps) short circuit current
     264              :         Real64 Voc;         // (Volts) open circuit voltage
     265              :         Real64 Tcell;       // (deg C) solar cell operating temperature
     266              :         Real64 Tback;       // (deg C) solar module operation temp, at back of module
     267              :         Real64 AMa;         // (unitless) Absolute Air mass
     268              :         Real64 F1;          // (unitless) holds result of "AMa-Function" for solar spectrum influence
     269              :         Real64 F2;          // (unitless) holds result of AOI-Function for angle-of-incidence
     270              :         Real64 Ix;          // (Amps) Current at V = 0.5 Voc
     271              :         Real64 Vx;          // (Volts) Voltage at 0.5 Voc
     272              :         Real64 Ixx;         // (Amps) current at V = 0.5(Vmpp + Voc)
     273              :         Real64 Vxx;         // (Volts) voltage at 0.5(Vmpp + Voc)
     274              :         Real64 SurfaceSink; // (Watts) energy balance term to account for electricity leaving
     275              : 
     276              :         // Default Constructor
     277            5 :         SNLPVCalcStruct()
     278            5 :             : Vmp(0.0), Imp(0.0), Pmp(0.0), EffMax(0.0), Isc(0.0), Voc(0.0), Tcell(0.0), Tback(0.0), AMa(0.0), F1(0.0), F2(0.0), Ix(0.0), Vx(0.0),
     279            5 :               Ixx(0.0), Vxx(0.0), SurfaceSink(0.0)
     280              :         {
     281            5 :         }
     282              :     };
     283              : 
     284              :     struct PVReportVariables // for  GENERATOR:PV:EQUIVALENT ONE-DIODE MODEL
     285              :     {
     286              :         // Members
     287              :         Real64 DCPower;         // Direct Current power from PV array
     288              :         Real64 DCEnergy;        // Direct Current energy from PV array
     289              :         Real64 ArrayEfficiency; // array efficiency at current conditions [0..1]
     290              :         Real64 CellTemp;        // array cell temperature at current conditions [C]
     291              :         Real64 ArrayIsc;        // array short circuit current at current conditions [A]
     292              :         Real64 ArrayVoc;        // array open circuit voltage at current conditions [V]
     293              :         Real64 ArrayCurrent;
     294              :         Real64 ArrayVoltage;
     295              : 
     296              :         // Default Constructor
     297            5 :         PVReportVariables()
     298            5 :             : DCPower(0.0), DCEnergy(0.0), ArrayEfficiency(0.0), CellTemp(0.0), ArrayIsc(0.0), ArrayVoc(0.0), ArrayCurrent(0.0), ArrayVoltage(0.0)
     299              :         {
     300            5 :         }
     301              :     };
     302              : 
     303              :     struct PVArrayStruct
     304              :     {
     305              :         // Members
     306              :         std::string Name;
     307              :         std::string SurfaceName; // named surface in heat balance domain
     308              :         std::string PerfObjName;
     309              :         int SurfacePtr;                      // index for named surface
     310              :         int Zone;                            // index for zone (for getting any zone multipliers)
     311              :         PVModel PVModelType;                 // type of performance modeling, Simple, TRNSYS or Equivalent 1-diode, or Sandia/King model
     312              :         CellIntegration CellIntegrationMode; // how are PV cells integrated with other E+ modeling
     313              :         Real64 NumModNSeries;                // number of modules in series in one string
     314              :         Real64 NumSeriesNParall;             // number of series strings in parallel
     315              :         int UTSCPtr;                         // pointer to UTSC number for INTEGRATED TRANSPIRED COLLECTOR mode
     316              :         int ExtVentCavPtr;                   // pointer to Exterior Vented Cavity EXTERIOR VENTED CAVITY
     317              :         int PVTPtr;                          // pointer to PVT model
     318              :         Real64 SurfaceSink;                  // PV power "sink" for integration
     319              :         PVReportVariables Report;            // report variables
     320              :         // nested structs for user input parameters
     321              :         SimplePVParamsStruct SimplePVModule;       // simple model input params
     322              :         TRNSYSPVModuleParamsStruct TRNSYSPVModule; // equivalent one-diode input params
     323              :         SNLModuleParamsStuct SNLPVModule;          // Sandia/King model input parameter data
     324              :         // nested structs for model input from elsewhere and calculations
     325              :         TRNSYSPVCalcStruct TRNSYSPVcalc;
     326              :         SNLPVInputStruct SNLPVinto; // model input from elsewhere in EnergyPlus
     327              :         SNLPVCalcStruct SNLPVCalc;  // calc'd data for GENERATOR:PV:Sandia model
     328              : 
     329              :         // Default Constructor
     330            5 :         PVArrayStruct()
     331           10 :             : SurfacePtr(0), Zone(0), PVModelType(PVModel::Invalid), CellIntegrationMode(CellIntegration::Invalid), NumModNSeries(1.0),
     332            5 :               NumSeriesNParall(1.0), UTSCPtr(0), ExtVentCavPtr(0), PVTPtr(0), SurfaceSink(0.0)
     333              :         {
     334            5 :         }
     335              :     };
     336              : } // namespace DataPhotovoltaics
     337              : 
     338              : struct PhotovoltaicsData : BaseGlobalStruct
     339              : {
     340              : 
     341              :     int NumPVs = 0;                 // count of number of PV generators
     342              :     int Num1DiodePVModuleTypes = 0; // count for Equivalent one-diode model
     343              :     int NumSimplePVModuleTypes = 0; // count of number of input objs for simple model
     344              :     int NumSNLPVModuleTypes = 0;    // count of number of input objs for Sandia model
     345              :     Real64 ShuntResistance = 0.0;   // old "RSH" in common block of trnsys code
     346              :     Array1D<DataPhotovoltaics::PVArrayStruct> PVarray;
     347              : 
     348         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     349              :     {
     350         2126 :     }
     351              : 
     352         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     353              :     {
     354         1152 :     }
     355              : 
     356         2100 :     void clear_state() override
     357              :     {
     358         2100 :         NumPVs = 0;
     359         2100 :         Num1DiodePVModuleTypes = 0;
     360         2100 :         NumSimplePVModuleTypes = 0;
     361         2100 :         NumSNLPVModuleTypes = 0;
     362         2100 :         ShuntResistance = 0.0;
     363         2100 :         PVarray.deallocate();
     364         2100 :     }
     365              : };
     366              : 
     367              : } // namespace EnergyPlus
     368              : 
     369              : #endif
        

Generated by: LCOV version 2.0-1