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

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2024, The Board of Trustees of the University of Illinois,
       2             : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3             : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4             : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5             : // contributors. All rights reserved.
       6             : //
       7             : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8             : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9             : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10             : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11             : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12             : //
      13             : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14             : // provided that the following conditions are met:
      15             : //
      16             : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17             : //     conditions and the following disclaimer.
      18             : //
      19             : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20             : //     conditions and the following disclaimer in the documentation and/or other materials
      21             : //     provided with the distribution.
      22             : //
      23             : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24             : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25             : //     used to endorse or promote products derived from this software without specific prior
      26             : //     written permission.
      27             : //
      28             : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29             : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30             : //     reference solely to the software portion of its product, Licensee must refer to the
      31             : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32             : //     obtained under this License and may not use a different name for the software. Except as
      33             : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34             : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35             : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36             : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37             : //
      38             : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39             : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40             : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41             : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42             : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43             : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44             : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45             : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46             : // POSSIBILITY OF SUCH DAMAGE.
      47             : 
      48             : #ifndef PhotovoltaicThermalCollectors_hh_INCLUDED
      49             : #define PhotovoltaicThermalCollectors_hh_INCLUDED
      50             : 
      51             : // ObjexxFCL Headers
      52             : #include <ObjexxFCL/Array1D.hh>
      53             : 
      54             : // EnergyPlus Headers
      55             : #include <EnergyPlus/ConvectionCoefficients.hh>
      56             : #include <EnergyPlus/Data/BaseData.hh>
      57             : #include <EnergyPlus/Plant/Enums.hh>
      58             : #include <EnergyPlus/Plant/PlantLocation.hh>
      59             : #include <EnergyPlus/PlantComponent.hh>
      60             : 
      61             : namespace EnergyPlus {
      62             : 
      63             : // Forward declarations
      64             : struct EnergyPlusData;
      65             : 
      66             : namespace PhotovoltaicThermalCollectors {
      67             : 
      68             :     enum class PVTMode
      69             :     {
      70             :         Invalid = -1,
      71             :         Heating,
      72             :         Cooling,
      73             :         Num
      74             :     };
      75             : 
      76             :     enum struct WorkingFluidEnum
      77             :     {
      78             :         Invalid = -1,
      79             :         LIQUID,
      80             :         AIR,
      81             :         Num
      82             :     };
      83             : 
      84             :     enum struct ThermEfficEnum
      85             :     {
      86             :         Invalid = -1,
      87             :         SCHEDULED,
      88             :         FIXED,
      89             :         Num
      90             :     };
      91             : 
      92             :     constexpr std::array<std::string_view, static_cast<int>(ThermEfficEnum::Num)> ThermEfficTypeNamesUC = {"SCHEDULED", "FIXED"};
      93             : 
      94             :     struct SimplePVTModelStruct
      95             :     {
      96             :         std::string Name;
      97             :         Real64 ThermalActiveFract = 0.0;                       // fraction of surface area with active thermal collection
      98             :         ThermEfficEnum ThermEfficMode = ThermEfficEnum::FIXED; // setting for how therm effic is determined
      99             :         Real64 ThermEffic = 0.0;                               // fixed or current Therm efficiency
     100             :         int ThermEffSchedNum = 0;                              // pointer to schedule for therm effic (if any)
     101             :         Real64 SurfEmissivity = 0.0;                           // surface emittance in long wave IR
     102             :         Real64 LastCollectorTemp = 0.0;                        // store previous temperature
     103             :     };
     104             : 
     105             :     struct BIPVTModelStruct
     106             :     {
     107             :         std::string Name;
     108             :         std::string OSCMName;               // OtherSideConditionsModel
     109             :         int OSCMPtr = 0;                    // OtherSideConditionsModel index
     110             :         int SchedPtr = 0;                   // Availablity schedule
     111             :         Real64 PVEffGapWidth = 0.0;         // Effective Gap Plenum Behind PV modules (m)
     112             :         Real64 PVCellTransAbsProduct = 0.0; // PV cell Transmittance-Absorptance prodiuct
     113             :         Real64 BackMatTranAbsProduct = 0.0; // Backing Material Normal Transmittance-Absorptance Product
     114             :         Real64 CladTranAbsProduct = 0.0;    // Cladding Normal Transmittance-Absorptance Product
     115             :         Real64 PVAreaFract = 0.0;           // Fraction of collector gross area covered by PV module
     116             :         Real64 PVCellAreaFract = 0.0;       // Fraction of PV cell area to module area
     117             :         Real64 PVRTop = 0.0;                // PV module top thermal resistance (m2-DegC/W)
     118             :         Real64 PVRBot = 0.0;                // PV module bottom thermal resistance (m2-DegC/W)
     119             :         Real64 PVGEmiss = 0.0;              // Emissivity PV modules
     120             :         Real64 BackMatEmiss = 0.0;          // Emissivity of backing material
     121             :         Real64 ThGlass = 0.0;               // Glass thickness (m)
     122             :         Real64 RIndGlass = 0.0;             // Glass refraction index
     123             :         Real64 ECoffGlass = 0.0;            // Glass extinction coefficient
     124             :         Real64 LastCollectorTemp = 0.0;     // store previous temperature (DegC)
     125             :         Real64 Tplen = 20.0;                // modeled drybulb temperature for air through BIPVT channel (DegC)
     126             :         Real64 Tcoll = 20.0;                // modeled temperature of BIPVT channel surface on PV side (DegC)
     127             :         Real64 HrPlen = 1.0;                // Modeled radiation coef for OSCM (W/m2-C)
     128             :         Real64 HcPlen = 10.0;               // Modeled Convection coef for OSCM (W/m2-C)
     129             :     };
     130             : 
     131             :     struct PVTReportStruct
     132             :     {
     133             :         Real64 ThermPower = 0.0;       // Heat gain or loss to collector fluid (W)
     134             :         Real64 ThermHeatGain = 0.0;    // Heat gain to collector fluid (W)
     135             :         Real64 ThermHeatLoss = 0.0;    // Heat loss from collector fluid (W)
     136             :         Real64 ThermEnergy = 0.0;      // Energy gained (or lost) to collector fluid (J)
     137             :         Real64 MdotWorkFluid = 0.0;    // working fluid mass flow rate (kg/s)
     138             :         Real64 TinletWorkFluid = 0.0;  // working fluid inlet temp (C)
     139             :         Real64 ToutletWorkFluid = 0.0; // working fluid outlet temp (C)
     140             :         Real64 BypassStatus = 0.0;     // 0 = no bypass, 1=full bypass
     141             :     };
     142             : 
     143             :     enum class PVTModelType
     144             :     {
     145             :         Invalid = -1,
     146             :         Simple = 1001,
     147             :         BIPVT = 1002,
     148             :         Num
     149             :     };
     150             : 
     151             :     struct PVTCollectorStruct : PlantComponent
     152             :     {
     153             :         std::string Name;                                                            // Name of PVT collector
     154             :         DataPlant::PlantEquipmentType Type = DataPlant::PlantEquipmentType::Invalid; // Plant Side Connection: 'Type' assigned in DataPlant
     155             :         PlantLocation WPlantLoc;                                                     // Water plant loop component location
     156             :         bool EnvrnInit = true;                                                       // manage begin environment inits
     157             :         bool SizingInit = true;                                                      // manage when sizing is complete
     158             :         std::string PVTModelName;                                                    // Name of PVT performance object
     159             :         PVTModelType ModelType = PVTModelType::Invalid;                              // model type indicator
     160             :         PVTMode OperatingMode = PVTMode::Invalid;                                    // PVT operating mode (heating or cooling)
     161             :         int SurfNum = 0;                                                             // surface index
     162             :         std::string PVname;                                                          // named Generator:Photovoltaic object
     163             :         int PVnum = 0;                                                               // PV index
     164             :         bool PVfound = false;                                                        // init, need to delay get input until PV gotten
     165             :         SimplePVTModelStruct Simple;                                                 // Simple performance data structure.
     166             :         BIPVTModelStruct BIPVT;                                                      // BIPVT performance data structure.
     167             :         WorkingFluidEnum WorkingFluidType = WorkingFluidEnum::LIQUID;
     168             :         int PlantInletNodeNum = 0;
     169             :         int PlantOutletNodeNum = 0;
     170             :         int HVACInletNodeNum = 0;
     171             :         int HVACOutletNodeNum = 0;
     172             :         Real64 DesignVolFlowRate = 0.0;
     173             :         bool DesignVolFlowRateWasAutoSized = false; // true if design volume flow rate was autosize on input
     174             :         Real64 MaxMassFlowRate = 0.0;
     175             :         Real64 MassFlowRate = 0.0;
     176             :         Real64 AreaCol = 0.0;
     177             :         bool BypassDamperOff = true;
     178             :         bool CoolingUseful = false;
     179             :         bool HeatingUseful = false;
     180             :         PVTReportStruct Report;
     181             :         bool MySetPointCheckFlag = true;
     182             :         bool MyOneTimeFlag = true;
     183             :         bool SetLoopIndexFlag = true;
     184             :         Real64 QdotSource = 0.0; // Source/sink term
     185             : 
     186             :         static PlantComponent *factory(EnergyPlusData &state, std::string_view objectName);
     187             : 
     188             :         void onInitLoopEquip([[maybe_unused]] EnergyPlusData &state, const PlantLocation &calledFromLocation) override;
     189             : 
     190             :         void simulate([[maybe_unused]] EnergyPlusData &state,
     191             :                       const PlantLocation &calledFromLocation,
     192             :                       bool FirstHVACIteration,
     193             :                       Real64 &CurLoad,
     194             :                       bool RunFlag) override;
     195             : 
     196             :         void setupReportVars(EnergyPlusData &state);
     197             : 
     198             :         void initialize(EnergyPlusData &state, bool FirstHVACIteration);
     199             : 
     200             :         void size(EnergyPlusData &state);
     201             : 
     202             :         void control(EnergyPlusData &state);
     203             : 
     204             :         void calculate(EnergyPlusData &state);
     205             : 
     206             :         void calculateSimplePVT(EnergyPlusData &state);
     207             : 
     208             :         void calculateBIPVT(EnergyPlusData &state);
     209             : 
     210             :         void calculateBIPVTMaxHeatGain(EnergyPlusData &state, Real64 tsp, Real64 &bfr, Real64 &q, Real64 &tmixed, Real64 &ThEff, Real64 &tpv);
     211             : 
     212             :         void solveLinSysBackSub(std::array<Real64, 9> &jj, std::array<Real64, 3> &f, std::array<Real64, 3> &y);
     213             : 
     214             :         Real64 calc_k_taoalpha(Real64 theta, Real64 glass_thickness, Real64 refrac_index_glass, Real64 k_glass);
     215             : 
     216             :         Real64 calc_taoalpha(Real64 theta, Real64 glass_thickness, Real64 refrac_index_glass, Real64 k_glass);
     217             : 
     218             :         void update(EnergyPlusData &state);
     219             : 
     220             :         void oneTimeInit(EnergyPlusData &state) override;
     221             :     };
     222             : 
     223             :     void GetPVTcollectorsInput(EnergyPlusData &state);
     224             : 
     225             :     void GetPVTSimpleCollectorsInput(EnergyPlusData &state, int NumSimplePVTPerform, Array1D<SimplePVTModelStruct> &tmpSimplePVTperf);
     226             : 
     227             :     void GetBIPVTCollectorsInput(EnergyPlusData &state, int NumBIPVTPerform, Array1D<BIPVTModelStruct> &tmpBIPVTperf);
     228             : 
     229             :     void GetMainPVTInput(EnergyPlusData &state,
     230             :                          int NumPVT,
     231             :                          Array1D<PVTCollectorStruct> &PVT,
     232             :                          Array1D<SimplePVTModelStruct> const &tmpSimplePVTperf,
     233             :                          Array1D<BIPVTModelStruct> const &tmpBIPVTperf);
     234             : 
     235             :     void simPVTfromOASys(EnergyPlusData &state, int index, bool FirstHVACIteration);
     236             : 
     237             :     int getPVTindexFromName(EnergyPlusData &state, std::string_view name);
     238             : 
     239             :     void GetPVTThermalPowerProduction(EnergyPlusData &state, int PVindex, Real64 &ThermalPower, Real64 &ThermalEnergy);
     240             : 
     241             :     int GetAirInletNodeNum(EnergyPlusData &state, std::string_view PVTName, bool &ErrorsFound);
     242             : 
     243             :     int GetAirOutletNodeNum(EnergyPlusData &state, std::string_view PVTName, bool &ErrorsFound);
     244             : 
     245             :     int GetPVTmodelIndex(EnergyPlusData &state, int SurfacePtr);
     246             : 
     247             :     void SetPVTQdotSource(EnergyPlusData &state, int PVTNum, Real64 QSource);
     248             : 
     249             :     void GetPVTTsColl(EnergyPlusData &state, int PVTNum, Real64 &TsColl);
     250             : 
     251             : } // namespace PhotovoltaicThermalCollectors
     252             : 
     253             : struct PhotovoltaicThermalCollectorsData : BaseGlobalStruct
     254             : {
     255             :     bool GetInputFlag = true; // First time, input is "gotten"
     256             :     int NumPVT = 0;           // count of all types of PVT in input file
     257             :     Array1D<PhotovoltaicThermalCollectors::PVTCollectorStruct> PVT;
     258             : 
     259         796 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     260             :     {
     261         796 :     }
     262             : 
     263           0 :     void clear_state() override
     264             :     {
     265           0 :         new (this) PhotovoltaicThermalCollectorsData();
     266           0 :     }
     267             : };
     268             : 
     269             : } // namespace EnergyPlus
     270             : 
     271             : #endif

Generated by: LCOV version 1.14