LCOV - code coverage report
Current view: top level - EnergyPlus - PlantUtilities.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 PlantUtilities_hh_INCLUDED
      49              : #define PlantUtilities_hh_INCLUDED
      50              : 
      51              : // ObjexxFCL Headers
      52              : #include <ObjexxFCL/Optional.hh>
      53              : 
      54              : // EnergyPlus Headers
      55              : #include <EnergyPlus/Data/BaseData.hh>
      56              : #include <EnergyPlus/EnergyPlus.hh>
      57              : #include <EnergyPlus/Plant/Enums.hh>
      58              : #include <EnergyPlus/Plant/PlantLocation.hh>
      59              : 
      60              : namespace EnergyPlus {
      61              : 
      62              : // Forward declarations
      63              : struct EnergyPlusData;
      64              : 
      65              : namespace PlantUtilities {
      66              : 
      67              :     // Functions
      68              :     void InitComponentNodes(EnergyPlusData &state, Real64 const MinCompMdot, Real64 const MaxCompMdot, int const InletNode, int const OutletNode);
      69              : 
      70              :     void SetComponentFlowRate(EnergyPlusData &state,
      71              :                               Real64 &CompFlow,             // [kg/s]
      72              :                               int InletNode,                // component's inlet node index in node structure
      73              :                               int OutletNode,               // component's outlet node index in node structure
      74              :                               PlantLocation const &plantLoc // component location for PlantLoop
      75              :     );
      76              : 
      77              :     void SetActuatedBranchFlowRate(EnergyPlusData &state,
      78              :                                    Real64 &CompFlow,
      79              :                                    int ActuatedNode,
      80              :                                    PlantLocation const &plantLoc,
      81              :                                    bool ResetMode // flag to indicate if this is a real flow set, or a reset flow setting.
      82              :     );
      83              : 
      84              :     Real64 RegulateCondenserCompFlowReqOp(EnergyPlusData &state, PlantLocation const &plantLoc, Real64 TentativeFlowRequest);
      85              : 
      86              :     bool AnyPlantSplitterMixerLacksContinuity(EnergyPlusData &state);
      87              : 
      88              :     void CheckPlantMixerSplitterConsistency(EnergyPlusData &state,
      89              :                                             const int LoopNum,
      90              :                                             const DataPlant::LoopSideLocation LoopSideNum,
      91              :                                             const bool FirstHVACIteration);
      92              : 
      93              :     void CheckForRunawayPlantTemps(EnergyPlusData &state, int LoopNum, const DataPlant::LoopSideLocation LoopSideNum);
      94              : 
      95              :     void SetAllFlowLocks(EnergyPlusData &state, DataPlant::FlowLock Value);
      96              : 
      97              :     void ResetAllPlantInterConnectFlags(EnergyPlusData &state);
      98              : 
      99              :     void PullCompInterconnectTrigger(EnergyPlusData &state,
     100              :                                      const PlantLocation &plantLoc,              // Component Location
     101              :                                      int &UniqueCriteriaCheckIndex,              // An integer given to this particular check
     102              :                                      const PlantLocation &ConnectedPlantLoc,     // Interconnected Component's Location
     103              :                                      const DataPlant::CriteriaType CriteriaType, // The criteria check to use, see DataPlant: SimFlagCriteriaTypes
     104              :                                      const Real64 CriteriaValue                  // The value of the criteria check to evaluate
     105              :     );
     106              : 
     107              :     void UpdateChillerComponentCondenserSide(EnergyPlusData &state,
     108              :                                              int LoopNum,                          // component's loop index
     109              :                                              DataPlant::LoopSideLocation LoopSide, // component's loop side number
     110              :                                              DataPlant::PlantEquipmentType Type,   // Component's type index
     111              :                                              int InletNodeNum,                     // Component's inlet node pointer
     112              :                                              int OutletNodeNum,                    // Component's outlet node pointer
     113              :                                              Real64 ModelCondenserHeatRate,        // model's heat rejection rate at condenser (W)
     114              :                                              Real64 ModelInletTemp,                // model's inlet temperature (C)
     115              :                                              Real64 ModelOutletTemp,               // model's outlet temperature (C)
     116              :                                              Real64 ModelMassFlowRate,             // model's condenser water mass flow rate (kg/s)
     117              :                                              bool FirstHVACIteration);
     118              : 
     119              :     void UpdateComponentHeatRecoverySide(EnergyPlusData &state,
     120              :                                          int LoopNum,                          // component's loop index
     121              :                                          DataPlant::LoopSideLocation LoopSide, // component's loop side number
     122              :                                          DataPlant::PlantEquipmentType Type,   // Component's type index
     123              :                                          int InletNodeNum,                     // Component's inlet node pointer
     124              :                                          int OutletNodeNum,                    // Component's outlet node pointer
     125              :                                          Real64 ModelRecoveryHeatRate,         // model's heat rejection rate at recovery (W)
     126              :                                          Real64 ModelInletTemp,                // model's inlet temperature (C)
     127              :                                          Real64 ModelOutletTemp,               // model's outlet temperature (C)
     128              :                                          Real64 ModelMassFlowRate,             // model's condenser water mass flow rate (kg/s)
     129              :                                          bool FirstHVACIteration);
     130              : 
     131              :     void UpdateAbsorberChillerComponentGeneratorSide(EnergyPlusData &state,
     132              :                                                      int LoopNum,                                // component's loop index
     133              :                                                      DataPlant::LoopSideLocation LoopSide,       // component's loop side number
     134              :                                                      DataPlant::PlantEquipmentType Type,         // Component's type index
     135              :                                                      int InletNodeNum,                           // Component's inlet node pointer
     136              :                                                      int OutletNodeNum,                          // Component's outlet node pointer
     137              :                                                      DataLoopNode::NodeFluidType HeatSourceType, // Type of fluid in Generator loop
     138              :                                                      Real64 ModelGeneratorHeatRate,              // model's generator heat rate (W)
     139              :                                                      Real64 ModelMassFlowRate,                   // model's generator mass flow rate (kg/s)
     140              :                                                      bool FirstHVACIteration);
     141              : 
     142              :     void InterConnectTwoPlantLoopSides(EnergyPlusData &state,
     143              :                                        PlantLocation const &Loop1PlantLoc,
     144              :                                        PlantLocation const &Loop2PlantLoc,
     145              :                                        DataPlant::PlantEquipmentType ComponentType,
     146              :                                        bool Loop1DemandsOnLoop2);
     147              : 
     148              :     void ShiftPlantLoopSideCallingOrder(EnergyPlusData &state, int OldIndex, int NewIndex);
     149              : 
     150              :     void RegisterPlantCompDesignFlow(EnergyPlusData &state,
     151              :                                      int ComponentInletNodeNum, // the component's water inlet node number
     152              :                                      Real64 DesPlantFlow        // the component's design fluid volume flow rate [m3/s]
     153              :     );
     154              : 
     155              :     void SafeCopyPlantNode(EnergyPlusData &state,
     156              :                            int InletNodeNum,
     157              :                            int OutletNodeNum,
     158              :                            ObjexxFCL::Optional_int_const LoopNum = _,
     159              :                            ObjexxFCL::Optional<Real64 const> OutletTemp = _ // set on outlet node if present and water.
     160              :     );
     161              : 
     162              :     Real64 BoundValueToNodeMinMaxAvail(EnergyPlusData &state, Real64 ValueToBound, int NodeNumToBoundWith);
     163              : 
     164              :     void TightenNodeMinMaxAvails(EnergyPlusData &state, int NodeNum, Real64 NewMinAvail, Real64 NewMaxAvail);
     165              : 
     166              :     Real64 BoundValueToWithinTwoValues(Real64 ValueToBound, Real64 LowerBound, Real64 UpperBound);
     167              : 
     168              :     bool IntegerIsWithinTwoValues(int ValueToCheck, int LowerBound, int UpperBound);
     169              : 
     170              :     void LogPlantConvergencePoints(EnergyPlusData &state, bool FirstHVACIteration);
     171              : 
     172              :     void SetPlantLocationLinks(EnergyPlusData &state, PlantLocation &plantLoc);
     173              : 
     174              :     void ScanPlantLoopsForObject(EnergyPlusData &state,
     175              :                                  std::string_view CompName,
     176              :                                  DataPlant::PlantEquipmentType CompType,
     177              :                                  PlantLocation &plantLoc,
     178              :                                  bool &errFlag,
     179              :                                  ObjexxFCL::Optional<Real64 const> LowLimitTemp = _,
     180              :                                  ObjexxFCL::Optional<Real64 const> HighLimitTemp = _,
     181              :                                  ObjexxFCL::Optional_int CountMatchPlantLoops = _,
     182              :                                  ObjexxFCL::Optional_int_const InletNodeNumber = _,
     183              :                                  ObjexxFCL::Optional_int_const SingleLoopSearch = _,
     184              :                                  ObjexxFCL::Optional_bool_const suppressErrors = _);
     185              : 
     186              :     void ScanPlantLoopsForNodeNum(EnergyPlusData &state,
     187              :                                   std::string_view const CallerName, // really used for error messages
     188              :                                   int NodeNum,                       // index in Node structure of node to be scanned
     189              :                                   PlantLocation &pLantLoc,           // return value for location
     190              :                                   ObjexxFCL::Optional_int CompNum = _);
     191              : 
     192              :     bool AnyPlantLoopSidesNeedSim(EnergyPlusData &state);
     193              : 
     194              :     void SetAllPlantSimFlagsToValue(EnergyPlusData &state, bool Value);
     195              : 
     196              :     void ShowBranchesOnLoop(EnergyPlusData &state, int LoopNum); // Loop number of loop
     197              : 
     198              :     int MyPlantSizingIndex(EnergyPlusData &state,
     199              :                            std::string_view CompType,       // component description
     200              :                            std::string_view CompName,       // user name of component
     201              :                            int NodeNumIn,                   // component water inlet node
     202              :                            int NodeNumOut,                  // component water outlet node
     203              :                            bool &ErrorsFound,               // set to true if there's an error
     204              :                            bool const PrintErrorFlag = true // used for WSHP's where condenser loop may not be on a plant loop
     205              :     );
     206              : 
     207              :     bool verifyTwoNodeNumsOnSamePlantLoop(EnergyPlusData &state, int nodeIndexA, int nodeIndexB);
     208              : 
     209              :     Real64 MinFlowIfBranchHasVSPump(
     210              :         EnergyPlusData &state, PlantLocation const &pLantLoc, bool &foundBranchPump, bool &foundLoopPump, bool const setFlowStatus);
     211              : 
     212              :     struct CriteriaData
     213              :     {
     214              :         // Members
     215              :         int CallingCompLoopNum = 0;                                                                // for debug error handling
     216              :         DataPlant::LoopSideLocation CallingCompLoopSideNum = DataPlant::LoopSideLocation::Invalid; // for debug error handling
     217              :         Real64 ThisCriteriaCheckValue = 0.0;                                                       // the previous value, to check the current against
     218              :     };
     219              : 
     220              : } // namespace PlantUtilities
     221              : 
     222              : struct PlantUtilitiesData : BaseGlobalStruct
     223              : {
     224              : 
     225              :     Array1D<PlantUtilities::CriteriaData> CriteriaChecks; // stores criteria information
     226              : 
     227         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     228              :     {
     229         2126 :     }
     230              : 
     231         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     232              :     {
     233         1152 :     }
     234              : 
     235         2100 :     void clear_state() override
     236              :     {
     237         2100 :         this->CriteriaChecks.deallocate();
     238         2100 :     }
     239              : };
     240              : 
     241              : } // namespace EnergyPlus
     242              : 
     243              : #endif
        

Generated by: LCOV version 2.0-1