LCOV - code coverage report
Current view: top level - EnergyPlus - DualDuct.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 100.0 % 7 7
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 DualDuct_hh_INCLUDED
      49              : #define DualDuct_hh_INCLUDED
      50              : 
      51              : // ObjexxFCL Headers
      52              : #include <ObjexxFCL/Array1D.hh>
      53              : #include <ObjexxFCL/Optional.hh>
      54              : 
      55              : // EnergyPlus Headers
      56              : #include <EnergyPlus/Data/BaseData.hh>
      57              : #include <EnergyPlus/DataGlobals.hh>
      58              : #include <EnergyPlus/EnergyPlus.hh>
      59              : 
      60              : namespace EnergyPlus {
      61              : 
      62              : // Forward declarations
      63              : struct EnergyPlusData;
      64              : 
      65              : namespace DualDuct {
      66              : 
      67              :     enum class DualDuctDamper
      68              :     {
      69              :         Invalid = -1,
      70              :         ConstantVolume,
      71              :         VariableVolume,
      72              :         OutdoorAir,
      73              :         Num
      74              :     };
      75              : 
      76              :     static constexpr std::array<std::string_view, static_cast<int>(DualDuctDamper::Num)> dualDuctDamperNames = {
      77              :         "ConstantVolume", "VariableVolume", "OutdoorAir"};
      78              : 
      79              :     enum class PerPersonMode
      80              :     {
      81              :         Invalid = -1,
      82              :         ModeNotSet,
      83              :         DCVByCurrentLevel,
      84              :         ByDesignLevel,
      85              :         Num
      86              :     };
      87              : 
      88              :     struct DualDuctAirTerminalFlowConditions
      89              :     {
      90              :         Real64 AirMassFlowRate = 0.0;         // MassFlow through the Damper being Simulated [kg/Sec]
      91              :         Real64 AirMassFlowRateMaxAvail = 0.0; // MassFlow through the Damper being Simulated [kg/Sec]
      92              :         Real64 AirMassFlowRateMinAvail = 0.0; // MassFlow through the Damper being Simulated [kg/Sec]
      93              :         Real64 AirMassFlowRateMax = 0.0;      // Max Mass Flow Rate or the Design Mass Flow Rate
      94              :         Real64 AirTemp = 0.0;
      95              :         Real64 AirHumRat = 0.0;
      96              :         Real64 AirEnthalpy = 0.0;
      97              :         Real64 AirMassFlowRateHist1 = 0.0; // flow history back 1 iteration kg/s
      98              :         Real64 AirMassFlowRateHist2 = 0.0; // flow history back 2 iteration kg/s
      99              :         Real64 AirMassFlowRateHist3 = 0.0; // flow history back 3 iteration kg/s
     100              :         Real64 AirMassFlowDiffMag = 0.0;   // flow difference scale, kg/s
     101              :     };
     102              : 
     103              :     struct DualDuctAirTerminal
     104              :     {
     105              :         std::string Name;                                    // Name of the Damper
     106              :         DualDuctDamper DamperType = DualDuctDamper::Invalid; // Type of Damper ie. VAV, Mixing, Inducing, etc.
     107              :         Sched::Schedule *availSched = nullptr; // Pointer to the correct schedule // brazenly assume that this is an availability schedule
     108              :         Real64 MaxAirVolFlowRate = 0.0;        // Max Specified Volume Flow Rate of Damper [m3/sec]
     109              :         Real64 MaxAirMassFlowRate = 0.0;       // Max Specified MAss Flow Rate of Damper [kg/s]
     110              :         int HotAirInletNodeNum = 0;
     111              :         int ColdAirInletNodeNum = 0;
     112              :         int OutletNodeNum = 0;
     113              :         Real64 ZoneMinAirFracDes = 0.0; // Fraction of supply air used as design minimum flow
     114              :         Real64 ZoneMinAirFrac = 0.0;    // Fraction of supply air used as current minimum flow
     115              :         Real64 ColdAirDamperPosition = 0.0;
     116              :         Real64 HotAirDamperPosition = 0.0;
     117              :         int OAInletNodeNum = 0;                                    // Alternate Node for VAV:OutdoorAir for Outdoor Air
     118              :         int RecircAirInletNodeNum = 0;                             // Alternate Node for VAV:OutdoorAir for Recirc Air
     119              :         bool RecircIsUsed = true;                                  // if true. then not using recirc duct, which is okay
     120              :         Real64 DesignOAFlowRate = 0.0;                             // Terminal Outdoor Air Design Flow Rate for VAV:OutdoorAir, m3/s
     121              :         Real64 DesignRecircFlowRate = 0.0;                         // Terminal Recirc Air Design Flow Rate for VAV:OutdoorAir, m3/s
     122              :         Real64 RecircAirDamperPosition = 0.0;                      // Alternate Damper Pos Output for VAV:OutdoorAir for Recirc Air
     123              :         Real64 OADamperPosition = 0.0;                             // Alternate Damper Pos Output for VAV:OutdoorAir for Recirc Air
     124              :         Real64 OAFraction = 0.0;                                   // Outdoor Air Fraction for VAV:OutdoorAir
     125              :         int ADUNum = 0;                                            // index of corresponding air distribution unit ZoneHVAC:AirdistributionUnit
     126              :         int CtrlZoneNum = 0;                                       // Pointer to CtrlZone data structure
     127              :         int CtrlZoneInNodeIndex = 0;                               // which controlled zone inlet node number corresponds with this unit
     128              :         Real64 OutdoorAirFlowRate = 0.0;                           // report variable for TU outdoor air flow rate
     129              :         bool NoOAFlowInputFromUser = true;                         // avoids OA calculation if no input specified by user
     130              :         int OARequirementsPtr = 0;                                 // - Index to DesignSpecification:OutdoorAir object
     131              :         PerPersonMode OAPerPersonMode = PerPersonMode::ModeNotSet; // mode for how per person rates are determined, DCV or design.
     132              :         int AirLoopNum = 0;                                        // index to airloop that this terminal unit is connected to
     133              :         Sched::Schedule *zoneTurndownMinAirFracSched = nullptr;    // pointer to the schedule for turndown minimum airflow fraction
     134              :         Real64 ZoneTurndownMinAirFrac = 1.0; // turndown minimum airflow fraction value, multiplier of zone design minimum air flow
     135              :         bool MyEnvrnFlag = true;             // environment flag
     136              :         bool MySizeFlag = true;              // sizing flag
     137              :         bool MyAirLoopFlag = true;           // airloop flag
     138              :         bool CheckEquipName = true;
     139              :         DualDuctAirTerminalFlowConditions dd_airterminalHotAirInlet;
     140              :         DualDuctAirTerminalFlowConditions dd_airterminalColdAirInlet;
     141              :         DualDuctAirTerminalFlowConditions dd_airterminalOutlet;
     142              :         DualDuctAirTerminalFlowConditions dd_airterminalOAInlet;
     143              :         DualDuctAirTerminalFlowConditions dd_airterminalRecircAirInlet;
     144              : 
     145              :         void InitDualDuct(EnergyPlusData &state, bool FirstHVACIteration);
     146              : 
     147              :         void SizeDualDuct(EnergyPlusData &state);
     148              : 
     149              :         void SimDualDuctConstVol(EnergyPlusData &state, int ZoneNum, int ZoneNodeNum);
     150              : 
     151              :         void SimDualDuctVarVol(EnergyPlusData &state, int ZoneNum, int ZoneNodeNum);
     152              : 
     153              :         void SimDualDuctVAVOutdoorAir(EnergyPlusData &state, int ZoneNum, int ZoneNodeNum);
     154              : 
     155              :         void CalcOAMassFlow(EnergyPlusData &state,
     156              :                             Real64 &SAMassFlow,   // outside air based on optional user input
     157              :                             Real64 &AirLoopOAFrac // outside air based on optional user input
     158              :         );
     159              : 
     160              :         void CalcOAOnlyMassFlow(EnergyPlusData &state,
     161              :                                 Real64 &OAMassFlow,                          // outside air flow from user input kg/s
     162              :                                 ObjexxFCL::Optional<Real64> MaxOAVolFlow = _ // design level for outside air m3/s
     163              :         );
     164              : 
     165              :         void CalcOutdoorAirVolumeFlowRate(EnergyPlusData &state);
     166              : 
     167              :         void UpdateDualDuct(EnergyPlusData &state);
     168              : 
     169              :         void reportTerminalUnit(EnergyPlusData &state);
     170              :     };
     171              : 
     172              :     void SimulateDualDuct(EnergyPlusData &state, std::string_view CompName, bool FirstHVACIteration, int ZoneNum, int ZoneNodeNum, int &CompIndex);
     173              : 
     174              :     void GetDualDuctInput(EnergyPlusData &state);
     175              : 
     176              :     void ReportDualDuctConnections(EnergyPlusData &state);
     177              : 
     178              :     void GetDualDuctOutdoorAirRecircUse(EnergyPlusData &state, std::string const &CompTypeName, std::string_view CompName, bool &RecircIsUsed);
     179              : 
     180              : } // namespace DualDuct
     181              : 
     182              : struct DualDuctData : BaseGlobalStruct
     183              : {
     184              :     int NumDDAirTerminal = 0; // The Number of Dampers found in the Input //Autodesk Poss used uninitialized in ReportDualDuctConnections
     185              :     int NumDualDuctVarVolOA = 0;
     186              :     bool GetDualDuctInputFlag = true; // Flag set to make sure you get input once
     187              :     Array1D<DualDuct::DualDuctAirTerminal> dd_airterminal;
     188              :     std::unordered_map<std::string, std::string> UniqueDualDuctAirTerminalNames;
     189              :     bool ZoneEquipmentListChecked = false; // True after the Zone Equipment List has been checked for items
     190              :     bool GetDualDuctOutdoorAirRecircUseFirstTimeOnly = true;
     191              :     Array1D_bool RecircIsUsedARR;
     192              :     Array1D_string DamperNamesARR;
     193              : 
     194         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     195              :     {
     196         2126 :     }
     197              : 
     198         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     199              :     {
     200         1152 :     }
     201              : 
     202         2100 :     void clear_state() override
     203              :     {
     204         2100 :         new (this) DualDuctData();
     205         2100 :     }
     206              : };
     207              : 
     208              : } // namespace EnergyPlus
     209              : 
     210              : #endif
        

Generated by: LCOV version 2.0-1