LCOV - code coverage report
Current view: top level - EnergyPlus - Photovoltaics.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 100.0 % 11 11
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 Photovoltaics_hh_INCLUDED
      49              : #define Photovoltaics_hh_INCLUDED
      50              : 
      51              : // C++ Headers
      52              : #include <functional>
      53              : 
      54              : // ObjexxFCL Headers
      55              : #include <ObjexxFCL/Array1D.hh>
      56              : 
      57              : // EnergyPlus Headers
      58              : #include <EnergyPlus/Data/BaseData.hh>
      59              : #include <EnergyPlus/ElectricPowerServiceManager.hh>
      60              : #include <EnergyPlus/EnergyPlus.hh>
      61              : 
      62              : namespace EnergyPlus {
      63              : 
      64              : // Forward declarations
      65              : struct EnergyPlusData;
      66              : 
      67              : namespace Photovoltaics {
      68              : 
      69              :     // Data
      70              :     // MODULE PARAMETER DEFINITIONS:
      71              :     // na
      72              : 
      73              :     // DERIVED TYPE DEFINITIONS:
      74              :     //   see DataPhotovoltaics.cc
      75              : 
      76              :     void SimPVGenerator(EnergyPlusData &state,
      77              :                         GeneratorType const GeneratorType, // type of Generator
      78              :                         std::string const &GeneratorName,  // user specified name of Generator
      79              :                         int &GeneratorIndex,
      80              :                         bool const RunFlag, // is PV ON or OFF as determined by schedules in ElecLoadCenter
      81              :                         Real64 const PVLoad // electrical load on the PV (not really used... PV models assume "full on"
      82              :     );
      83              : 
      84              :     void GetPVGeneratorResults(EnergyPlusData &state,
      85              :                                GeneratorType const GeneratorType, // type of Generator
      86              :                                int const GeneratorIndex,
      87              :                                Real64 &GeneratorPower,  // electrical power
      88              :                                Real64 &GeneratorEnergy, // electrical energy
      89              :                                Real64 &ThermalPower,
      90              :                                Real64 &ThermalEnergy);
      91              : 
      92              :     // *************
      93              : 
      94              :     void GetPVInput(EnergyPlusData &state);
      95              : 
      96              :     int GetPVZone(EnergyPlusData &state, int const SurfNum);
      97              : 
      98              :     // **************************************
      99              : 
     100              :     void CalcSimplePV(EnergyPlusData &state, int const thisPV);
     101              : 
     102              :     void ReportPV(EnergyPlusData &state, int const PVnum);
     103              : 
     104              :     // *************
     105              : 
     106              :     void CalcSandiaPV(EnergyPlusData &state,
     107              :                       int const PVnum,   // ptr to current PV system
     108              :                       bool const RunFlag // controls if generator is scheduled *ON*
     109              :     );
     110              : 
     111              :     // ********************
     112              :     // begin routines for Equivalent one-diode model by Bradley/Ulleberg
     113              : 
     114              :     void InitTRNSYSPV(EnergyPlusData &state, int const PVnum); // the number of the GENERATOR:PHOTOVOLTAICS (passed in)
     115              : 
     116              :     // *************
     117              : 
     118              :     void CalcTRNSYSPV(EnergyPlusData &state,
     119              :                       int const PVnum,   // BTG added intent
     120              :                       bool const RunFlag // BTG added intent    !flag tells whether the PV is ON or OFF
     121              :     );
     122              : 
     123              :     void POWER(EnergyPlusData &state,
     124              :                Real64 const IO,   // passed in from CalcPV
     125              :                Real64 const IL,   // passed in from CalcPV
     126              :                Real64 const RSER, // passed in from CalcPV
     127              :                Real64 const AA,   // passed in from CalcPV
     128              :                Real64 const EPS,  // passed in from CalcPV
     129              :                Real64 &II,        // current [A]
     130              :                Real64 const VV,   // voltage [V]
     131              :                Real64 &PP         // power [W]
     132              :     );
     133              : 
     134              :     void NEWTON(EnergyPlusData &state,
     135              :                 Real64 &XX,
     136              :                 std::function<Real64(EnergyPlusData &state, Real64 const, Real64 const, Real64 const, Real64 const, Real64 const, Real64 const)> FXX,
     137              :                 std::function<Real64(EnergyPlusData &state, Real64 const, Real64 const, Real64 const, Real64 const, Real64 const)> DER,
     138              :                 Real64 const &II, // Autodesk Aliased to XX in some calls, this is absolutely wacky and needs to go
     139              :                 Real64 const &VV, // Autodesk Aliased to XX in some calls, this too
     140              :                 Real64 const IO,
     141              :                 Real64 const IL,
     142              :                 Real64 const RSER,
     143              :                 Real64 const AA,
     144              :                 Real64 const XS,
     145              :                 Real64 const EPS);
     146              : 
     147              :     void SEARCH(EnergyPlusData &state,
     148              :                 Real64 &A,
     149              :                 Real64 &B,
     150              :                 Real64 &P,
     151              :                 int &K,
     152              :                 Real64 const IO,
     153              :                 Real64 const IL,
     154              :                 Real64 const RSER,
     155              :                 Real64 const AA,
     156              :                 Real64 const EPS,
     157              :                 int const KMAX);
     158              : 
     159              :     Real64 FUN(EnergyPlusData &state, Real64 const II, Real64 const VV, Real64 const IL, Real64 const IO, Real64 const RSER, Real64 const AA);
     160              : 
     161              :     Real64 FI(EnergyPlusData &state, Real64 const II, Real64 const VV, Real64 const IO, Real64 const RSER, Real64 const AA);
     162              : 
     163              :     Real64 FV(EnergyPlusData &state, Real64 const II, Real64 const VV, Real64 const IO, Real64 const RSER, Real64 const AA);
     164              : 
     165              :     // End routines for Equivalent One-Diode model as implemented by Bradley
     166              :     //************************************************************************
     167              : 
     168              :     // Begin supporting routines for Sandia PV model
     169              :     // -------------------------------------------------------------------------------
     170              : 
     171              :     Real64 SandiaModuleTemperature(Real64 const Ibc, // beam radiation on collector plane, W/m2
     172              :                                    Real64 const Idc, // Diffuse radiation on collector plane, W/m2
     173              :                                    Real64 const Ws,  // wind speed, m/s
     174              :                                    Real64 const Ta,  // ambient temperature, degC
     175              :                                    Real64 const fd,  // fraction of Idc used (empirical constant)
     176              :                                    Real64 const a,   // empirical constant
     177              :                                    Real64 const b    // empirical constant
     178              :     );
     179              : 
     180              :     // -------------------------------------------------------------------------------
     181              :     // -------------------------------------------------------------------------------
     182              : 
     183              :     Real64 SandiaTcellFromTmodule(Real64 const Tm,  // module temperature (deg C)
     184              :                                   Real64 const Ibc, // beam radiation on collector plane, W/m2
     185              :                                   Real64 const Idc, // Diffuse radiation on collector plane, W/m2
     186              :                                   Real64 const fd,  // fraction of Idc used (empirical constant)
     187              :                                   Real64 const DT0  // (Tc-Tm) at E=1000 W/m2 (empirical constant known as delta T), deg C
     188              :     );
     189              : 
     190              :     // -------------------------------------------------------------------------------
     191              : 
     192              :     Real64 SandiaCellTemperature(Real64 const Ibc, // beam radiation on collector plane W/m2
     193              :                                  Real64 const Idc, // Diffuse radiation on collector plane W/m2
     194              :                                  Real64 const Ws,  // wind speed, m/s
     195              :                                  Real64 const Ta,  // ambient temperature, degC
     196              :                                  Real64 const fd,  // fraction of Idc used (empirical constant)
     197              :                                  Real64 const a,   // empirical constant
     198              :                                  Real64 const b,   // empirical constant
     199              :                                  Real64 const DT0  // (Tc-Tm) at E=1000 W/m2 (empirical constant known as dTc), deg C
     200              :     );
     201              : 
     202              :     // -------------------------------------------------------------------------------
     203              : 
     204              :     Real64 SandiaEffectiveIrradiance(Real64 const Tc,   // cell temperature (deg C)
     205              :                                      Real64 const Isc,  // short-circuit current under operating conditions (A)
     206              :                                      Real64 const Isc0, // reference Isc at Tc=25 C, Ic=1000 W/m2 (A)
     207              :                                      Real64 const aIsc  // Isc temperature coefficient (degC^-1)
     208              :     );
     209              : 
     210              :     // -------------------------------------------------------------------------------
     211              : 
     212              :     Real64 AbsoluteAirMass(Real64 const SolZen,  // solar zenith angle (deg)
     213              :                            Real64 const Altitude // site altitude (m)
     214              :     );
     215              : 
     216              :     // -------------------------------------------------------------------------------
     217              : 
     218              :     Real64 SandiaF1(Real64 const AMa, // absolute air mass
     219              :                     Real64 const a0,  // empirical constant, module-specific
     220              :                     Real64 const a1,  // empirical constant, module-specific
     221              :                     Real64 const a2,  // empirical constant, module-specific
     222              :                     Real64 const a3,  // empirical constant, module-specific
     223              :                     Real64 const a4   // empirical constant, module-specific
     224              :     );
     225              : 
     226              :     // -------------------------------------------------------------------------------
     227              : 
     228              :     Real64 SandiaF2(Real64 const IncAng, // incidence angle (deg)
     229              :                     Real64 const b0,     // empirical module-specific constants
     230              :                     Real64 const b1,     // empirical module-specific constants
     231              :                     Real64 const b2,     // empirical module-specific constants
     232              :                     Real64 const b3,     // empirical module-specific constants
     233              :                     Real64 const b4,     // empirical module-specific constants
     234              :                     Real64 const b5      // empirical module-specific constants
     235              :     );
     236              : 
     237              :     // -------------------------------------------------------------------------------
     238              : 
     239              :     Real64 SandiaImp(Real64 const Tc,   // cell temperature (degC)
     240              :                      Real64 const Ee,   // effective irradiance (W/m2)
     241              :                      Real64 const Imp0, // current at MPP at SRC (1000 W/m2, 25 C) (A)
     242              :                      Real64 const aImp, // Imp temperature coefficient (degC^-1)
     243              :                      Real64 const C0,   // empirical module-specific constants
     244              :                      Real64 const C1    // empirical module-specific constants
     245              :     );
     246              : 
     247              :     // -------------------------------------------------------------------------------
     248              : 
     249              :     Real64 SandiaIsc(Real64 const Tc,   // cell temperature (deg C)
     250              :                      Real64 const Isc0, // Isc at Tc=25 C, Ic=1000 W/m2 (A)
     251              :                      Real64 const Ibc,  // beam radiation on collector plane (W/m2)
     252              :                      Real64 const Idc,  // Diffuse radiation on collector plane (W/m2)
     253              :                      Real64 const F1,   // Sandia F1 function for air mass effects
     254              :                      Real64 const F2,   // Sandia F2 function of incidence angle
     255              :                      Real64 const fd,   // module-specific empirical constant
     256              :                      Real64 const aIsc  // Isc temperature coefficient (degC^-1)
     257              :     );
     258              : 
     259              :     // -------------------------------------------------------------------------------
     260              : 
     261              :     Real64 SandiaIx(Real64 const Tc,   // cell temperature (deg C)
     262              :                     Real64 const Ee,   // effective irradiance
     263              :                     Real64 const Ix0,  // Ix at SRC (1000 W/m2, 25 C) (A)
     264              :                     Real64 const aIsc, // Isc temp coefficient (/C)
     265              :                     Real64 const aImp, // Imp temp coefficient (/C)
     266              :                     Real64 const C4,   // empirical module-specific constants
     267              :                     Real64 const C5    // empirical module-specific constants
     268              :     );
     269              : 
     270              :     // -------------------------------------------------------------------------------
     271              : 
     272              :     Real64 SandiaIxx(Real64 const Tc,   // cell temperature (deg C)
     273              :                      Real64 const Ee,   // effective irradiance (W/m2 ?)
     274              :                      Real64 const Ixx0, // Ixx at SRC (1000 W/m2, 25 C) (A)
     275              :                      Real64 const aImp, // Imp temp coefficient (/C)
     276              :                      Real64 const C6,   // empirical module-specific constants
     277              :                      Real64 const C7    // empirical module-specific constants
     278              :     );
     279              : 
     280              :     // -------------------------------------------------------------------------------
     281              : 
     282              :     Real64 SandiaVmp(Real64 const Tc,          // cell temperature (deg C)
     283              :                      Real64 const Ee,          // effective irradiance
     284              :                      Real64 const Vmp0,        // Vmp at SRC (1000 W/m2, 25 C) (V)
     285              :                      Real64 const NcellSer,    // # cells in series
     286              :                      Real64 const DiodeFactor, // module-specIFic empirical constant
     287              :                      Real64 const BVmp0,       // Vmp temperature coefficient (V/C)
     288              :                      Real64 const mBVmp,       // change in BVmp with irradiance
     289              :                      Real64 const C2,          // empirical module-specific constants
     290              :                      Real64 const C3           // empirical module-specific constants
     291              :     );
     292              : 
     293              :     // -------------------------------------------------------------------------------
     294              : 
     295              :     Real64 SandiaVoc(Real64 const Tc,          // cell temperature (deg C)
     296              :                      Real64 const Ee,          // effective irradiance
     297              :                      Real64 const Voc0,        // Voc at SRC (1000 W/m2, 25 C) (V)
     298              :                      Real64 const NcellSer,    // # cells in series
     299              :                      Real64 const DiodeFactor, // module-specIFic empirical constant
     300              :                      Real64 const BVoc0,       // Voc temperature coefficient (V/C)
     301              :                      Real64 const mBVoc        // change in BVoc with irradiance
     302              :     );
     303              : 
     304              :     void SetVentedModuleQdotSource(EnergyPlusData &state,
     305              :                                    int const VentModNum,
     306              :                                    Real64 const QSource // source term in Watts
     307              :     );
     308              : 
     309              :     void GetExtVentedCavityIndex(EnergyPlusData &state, int const SurfacePtr, int &VentCavIndex);
     310              : 
     311              :     void GetExtVentedCavityTsColl(EnergyPlusData &state, int const VentModNum, Real64 &TsColl);
     312              : 
     313              :     // -------------------------------------------------------------------------------
     314              : 
     315              :     //     EnergyPlus V1.2 and beyond include models for photovoltaic calculations called
     316              :     //     Generator:Photovoltaic:Simple and Generator:PV:Sandia implemented by the Center for
     317              :     //     Buildings and Thermal Systems, National Renewable Energy Laboratory, 1617 Cole Blvd
     318              :     //     MS 2722, Golden, CO, 80401
     319              : 
     320              :     //     EnergyPlus v1.1.1 and beyond includes model for Photovoltaic calculations, now
     321              :     //     referred to as the Generator:PV:Equivalent One-Diode model developed by Thermal Energy
     322              :     //     System Specialists, 2916 Marketplace Drive, Suite 104, Madison, WI 53719;
     323              :     //     Tel: (608) 274-2577
     324              : 
     325              : } // namespace Photovoltaics
     326              : 
     327              : struct PhotovoltaicStateData : BaseGlobalStruct
     328              : {
     329              : 
     330              :     Array1D_bool CheckEquipName;
     331              :     bool GetInputFlag = true; // one time get input flag
     332              :     bool MyOneTimeFlag = true;
     333              :     bool firstTime = true;
     334              :     Real64 PVTimeStep; // internal timestep (in seconds) for cell temperature mode 3
     335              :     Array1D_bool MyEnvrnFlag;
     336              : 
     337         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     338              :     {
     339         2126 :     }
     340              : 
     341         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     342              :     {
     343         1152 :     }
     344              : 
     345         2100 :     void clear_state() override
     346              :     {
     347         2100 :         CheckEquipName.clear();
     348         2100 :         GetInputFlag = true;
     349         2100 :         MyOneTimeFlag = true;
     350         2100 :         firstTime = true;
     351         2100 :         MyEnvrnFlag.clear();
     352         2100 :     }
     353              : };
     354              : 
     355              : } // namespace EnergyPlus
     356              : 
     357              : #endif
        

Generated by: LCOV version 2.0-1