LCOV - code coverage report
Current view: top level - EnergyPlus - HVACFourPipeBeam.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 88.5 % 26 23
Test Date: 2025-05-22 16:09:37 Functions: 80.0 % 5 4

            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 HVACFourPipeBeam_hh_INCLUDED
      49              : #define HVACFourPipeBeam_hh_INCLUDED
      50              : 
      51              : #include <memory>
      52              : // ObjexxFCL Headers
      53              : #include <ObjexxFCL/Array1.hh>
      54              : 
      55              : // EnergyPlus Headers
      56              : #include <EnergyPlus/AirTerminalUnit.hh>
      57              : #include <EnergyPlus/Data/BaseData.hh>
      58              : #include <EnergyPlus/DataGlobals.hh>
      59              : #include <EnergyPlus/EnergyPlus.hh>
      60              : #include <EnergyPlus/GlobalNames.hh>
      61              : #include <EnergyPlus/Plant/PlantLocation.hh>
      62              : 
      63              : namespace EnergyPlus {
      64              : 
      65              : // Forward declarations
      66              : struct EnergyPlusData;
      67              : 
      68              : namespace FourPipeBeam {
      69              : 
      70              :     class HVACFourPipeBeam : public AirTerminalUnit
      71              :     {
      72              : 
      73              :     private: // Creation
      74              :         // Default Constructor
      75            4 :         HVACFourPipeBeam()
      76            8 :             : coolingAvailable(false), heatingAvailable(false), totBeamLength(0.0), totBeamLengthWasAutosized(false), vDotNormRatedPrimAir(0.0),
      77            4 :               mDotNormRatedPrimAir(0.0), beamCoolingPresent(false), vDotDesignCW(0.0), vDotDesignCWWasAutosized(false), mDotDesignCW(0.0),
      78            4 :               qDotNormRatedCooling(0.0), deltaTempRatedCooling(0.0), vDotNormRatedCW(0.0), mDotNormRatedCW(0.0), modCoolingQdotDeltaTFuncNum(0),
      79            4 :               modCoolingQdotAirFlowFuncNum(0), modCoolingQdotCWFlowFuncNum(0), mDotCW(0.0), cWTempIn(0.0), cWTempOut(0.0), cWTempOutErrorCount(0),
      80            8 :               cWInNodeNum(0), cWOutNodeNum(0), cWplantLoc(PlantLocation(0, DataPlant::LoopSideLocation::Invalid, 0, 0)), beamHeatingPresent(false),
      81            4 :               vDotDesignHW(0.0), vDotDesignHWWasAutosized(false), mDotDesignHW(0.0), qDotNormRatedHeating(0.0), deltaTempRatedHeating(0.0),
      82            4 :               vDotNormRatedHW(0.0), mDotNormRatedHW(0.0), modHeatingQdotDeltaTFuncNum(0), modHeatingQdotAirFlowFuncNum(0),
      83            4 :               modHeatingQdotHWFlowFuncNum(0), mDotHW(0.0), hWTempIn(0.0), hWTempOut(0.0), hWTempOutErrorCount(0), hWInNodeNum(0), hWOutNodeNum(0),
      84            4 :               hWplantLoc(PlantLocation(0, DataPlant::LoopSideLocation::Invalid, 0, 0)), beamCoolingEnergy(0.0), beamCoolingRate(0.0),
      85            4 :               beamHeatingEnergy(0.0), beamHeatingRate(0.0), supAirCoolingEnergy(0.0), supAirCoolingRate(0.0), supAirHeatingEnergy(0.0),
      86            4 :               supAirHeatingRate(0.0), primAirFlow(0.0), OutdoorAirFlowRate(0.0), myEnvrnFlag(true), mySizeFlag(true), plantLoopScanFlag(true),
      87            4 :               zoneEquipmentListChecked(false), tDBZoneAirTemp(0.0), tDBSystemAir(0.0), mDotSystemAir(0.0), cpZoneAir(0.0), cpSystemAir(0.0),
      88            4 :               qDotSystemAir(0.0), qDotBeamCoolingMax(0.0), qDotBeamHeatingMax(0.0), qDotTotalDelivered(0.0), qDotBeamCooling(0.0),
      89            4 :               qDotBeamHeating(0.0), qDotZoneReq(0.0), qDotBeamReq(0.0), qDotZoneToHeatSetPt(0.0), qDotZoneToCoolSetPt(0.0)
      90              :         {
      91            4 :         }
      92              : 
      93              :     public:
      94              :         // Destructor
      95            0 :         virtual ~HVACFourPipeBeam()
      96            0 :         {
      97            0 :         }
      98              : 
      99              :     public: // Methods        MARK ANY THAT DON'T ALTER STATE const !!!
     100              :         ///// Note use of shared_ptr here is not a good pattern, not to be replicated without further discussion.
     101              :         static std::shared_ptr<AirTerminalUnit> fourPipeBeamFactory(EnergyPlusData &state, std::string objectName);
     102              :         void simulate(EnergyPlusData &state,
     103              :                       bool const FirstHVACIteration, // TRUE if first HVAC iteration in time step
     104              :                       Real64 &NonAirSysOutput        // convective cooling by the beam system [W]
     105              :         );
     106              : 
     107              :         int getZoneIndex();
     108              : 
     109              :         int getAirLoopNum();
     110              : 
     111              :         Real64 getPrimAirDesignVolFlow();
     112              : 
     113              :         int getTermUnitSizingIndex();
     114              : 
     115              :         void reportTerminalUnit(EnergyPlusData &state);
     116              : 
     117              :     private: // Methods
     118              :         void
     119              :         init(EnergyPlusData &state,
     120              :              bool const FirstHVACIteration // TRUE if first air loop solution this HVAC step         MAYBE THIS SHOULD HAVE A DEFAULT ARG OF = false
     121              :         );
     122              : 
     123              :         void set_size(EnergyPlusData &state);
     124              : 
     125              :         void control(EnergyPlusData &state,
     126              :                      bool const FirstHVACIteration, // TRUE if 1st HVAC simulation of system timestep
     127              :                      Real64 &NonAirSysOutput        // convective cooling by the beam system [W]
     128              :         );
     129              : 
     130              :         void calc(EnergyPlusData &state);
     131              : 
     132              :         void update(EnergyPlusData &state) const;
     133              : 
     134              :         void report(EnergyPlusData &state);
     135              : 
     136              :         void CalcOutdoorAirVolumeFlowRate(EnergyPlusData &state);
     137              : 
     138              :     private:                                          // data
     139              :         Sched::Schedule *coolingAvailSched = nullptr; // schedule for cooling availability
     140              :         bool coolingAvailable;                        // true if beam cooling is available
     141              :         Sched::Schedule *heatingAvailSched = nullptr; // schedule for heating availability
     142              :         bool heatingAvailable;                        // true if beam heating is available
     143              : 
     144              :         Real64 totBeamLength;           // length of all the beams in the zone (autosizable) (m)
     145              :         bool totBeamLengthWasAutosized; // true if beam length was autosized on input
     146              :         Real64 vDotNormRatedPrimAir;    // normalized primary air volume flow rate at rating point (m3/s-m)
     147              :         Real64 mDotNormRatedPrimAir;    // normalized primary air mass flow rate at rating point (kg/s-m)
     148              :         // cooling
     149              :         bool beamCoolingPresent;          // true if chilled water system is connected to beam
     150              :         Real64 vDotDesignCW;              // Design chilled water volume flow rate (autosizable) (m3/s)
     151              :         bool vDotDesignCWWasAutosized;    // true if use input for chilled water flow was autosized
     152              :         Real64 mDotDesignCW;              // Design chilled water mass flow rate (kg/s)
     153              :         Real64 qDotNormRatedCooling;      // normalized cooling capacity at rating point (W/m)
     154              :         Real64 deltaTempRatedCooling;     // temperature difference between zone air and entering chilled water at rating point (delta C)
     155              :         Real64 vDotNormRatedCW;           // normalized chilled water volume flow rate at rating point (m3/s-m)
     156              :         Real64 mDotNormRatedCW;           // normalized chilled water mass flow rate at rating point (kg/s-m)
     157              :         int modCoolingQdotDeltaTFuncNum;  // index to curve or table modifying cooling capacity as a function of delta T ratio
     158              :         int modCoolingQdotAirFlowFuncNum; // index to curve or table modifying cooling capacity as a function of air flow ratio
     159              :         int modCoolingQdotCWFlowFuncNum;  // index to curve or table modifying cooling capacity as a function of chilled water flow ratio
     160              :         Real64 mDotCW;                    // current chilled water mass flow rate (kg/s)
     161              :         Real64 cWTempIn;                  // current inlet chilled water temperature [C]
     162              :         Real64 cWTempOut;                 // current outlet chilled water temperature [C]
     163              :         int cWTempOutErrorCount;          // counter for recurring errors in chilled water outlet temperature
     164              :         int cWInNodeNum;                  // chilled water inlet node
     165              :         int cWOutNodeNum;                 // chilled water outlet nod
     166              :         PlantLocation cWplantLoc;         // chilled water plant loop location
     167              :         // heating
     168              :         bool beamHeatingPresent;          // true if hot water system is connected to beam
     169              :         Real64 vDotDesignHW;              // Design hot water volume flow rate (autosizable) (m3/s)
     170              :         bool vDotDesignHWWasAutosized;    // true if user input for hot water flow was autosized
     171              :         Real64 mDotDesignHW;              // Design hot water mass flow rate (kg/s)
     172              :         Real64 qDotNormRatedHeating;      // normalized heating capacity at rating point (W/m)
     173              :         Real64 deltaTempRatedHeating;     // temperature difference between zone air and entering hot water at rating point (delta C)
     174              :         Real64 vDotNormRatedHW;           // normalized hot water volume flow rate at rating point (m3/s-m)
     175              :         Real64 mDotNormRatedHW;           // normalized hot water mass flow rate at rating point (kg/s-m)
     176              :         int modHeatingQdotDeltaTFuncNum;  // index to curve or table modifying heating capacity as a function of delta T ratio
     177              :         int modHeatingQdotAirFlowFuncNum; // index to curve or table modifying heating capacity as a function of air flow ratio
     178              :         int modHeatingQdotHWFlowFuncNum;  // index to curve or table modifying heating capacity as a function of chilled water flow ratio
     179              :         Real64 mDotHW;                    // current hot water mass flow rate (kg/s)
     180              :         Real64 hWTempIn;                  // current inlet hot water temperature (C)
     181              :         Real64 hWTempOut;                 // current outlet hot water temperature (C)
     182              :         int hWTempOutErrorCount;          // counter for recurring errors in hot water outlet temperature
     183              :         int hWInNodeNum;                  // hot water inlet node
     184              :         int hWOutNodeNum;                 // hot water outlet node
     185              :         PlantLocation hWplantLoc;         // hot water connection location structure
     186              : 
     187              :         // output variables
     188              :         Real64 beamCoolingEnergy;   // beam sensible cooling energy of all beams in the zone [J]
     189              :         Real64 beamCoolingRate;     // beam sensible cooling rate of all beams in the zone (positive convention) [W]
     190              :         Real64 beamHeatingEnergy;   // beam heating energy of all beams in the zone [J]
     191              :         Real64 beamHeatingRate;     // beam heating rate of all beams in the zone [W]
     192              :         Real64 supAirCoolingEnergy; // Total cooling energy from supply air [J]
     193              :         Real64 supAirCoolingRate;   // Total cooling rate from supply air [W]
     194              :         Real64 supAirHeatingEnergy; // Total cooling energy from supply air [J]
     195              :         Real64 supAirHeatingRate;   // Total cooling rate from supply air [W]
     196              :         Real64 primAirFlow;         // supply air flow per zone at standard elevation-adjusted density [m3/s]
     197              :         Real64 OutdoorAirFlowRate;  // zone outdoor air volume flow rate
     198              : 
     199              :         bool myEnvrnFlag;              // control when to re initialize for new environment period
     200              :         bool mySizeFlag;               // control when to run sizing method
     201              :         bool plantLoopScanFlag;        // control when to look up plant locations for water connections
     202              :         bool zoneEquipmentListChecked; // control when to check zone equipment list was input correctly
     203              : 
     204              :         Real64 tDBZoneAirTemp;      // current drybulb temperature of zone air, C
     205              :         Real64 tDBSystemAir;        // current drybulb temperature of primary supply air, C
     206              :         Real64 mDotSystemAir;       // current mass flow of primary supply air,kg/s
     207              :         Real64 cpZoneAir;           // current specific heat of zone air
     208              :         Real64 cpSystemAir;         // current specific heat of primary supply air
     209              :         Real64 qDotSystemAir;       // current heat transfer rate of primary supply air wrt zone, W
     210              :         Real64 qDotBeamCoolingMax;  // current beam cooling rate at maximum chilled water flow rate, W
     211              :         Real64 qDotBeamHeatingMax;  // curent beam heating rate at maximum hot water flow rate, W
     212              :         Real64 qDotTotalDelivered;  // current combined heat transfer rate of primary supply air and beam, W
     213              :         Real64 qDotBeamCooling;     // current beam cooling rate, W
     214              :         Real64 qDotBeamHeating;     // current beam heating rate, W
     215              :         Real64 qDotZoneReq;         // current zone sensible requested load to setpoint, W
     216              :         Real64 qDotBeamReq;         // current load requested of beam, W
     217              :         Real64 qDotZoneToHeatSetPt; // current zone sensible load to heating setpoint, W
     218              :         Real64 qDotZoneToCoolSetPt; // current zone sensible load to cooling setpoint, W
     219              : 
     220              :     }; // HVACFourPipeBeam
     221              : 
     222              : } // namespace FourPipeBeam
     223              : 
     224              : struct FourPipeBeamData : BaseGlobalStruct
     225              : {
     226              : 
     227              :     ///// Note use of shared_ptr here is not a good pattern, not to be replicated without further discussion.
     228              :     Array1D<std::shared_ptr<FourPipeBeam::HVACFourPipeBeam>> FourPipeBeams; // dimension to number of machines
     229              : 
     230         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     231              :     {
     232         2126 :     }
     233              : 
     234         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     235              :     {
     236         1152 :     }
     237              : 
     238         2100 :     void clear_state() override
     239              :     {
     240         2100 :         FourPipeBeams.clear();
     241         2100 :     }
     242              : };
     243              : 
     244              : } // namespace EnergyPlus
     245              : 
     246              : #endif // HVACFourPipeBeam_hh_INCLUDED
        

Generated by: LCOV version 2.0-1