LCOV - code coverage report
Current view: top level - EnergyPlus - Pumps.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 100.0 % 17 17
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 Pumps_hh_INCLUDED
      49              : #define Pumps_hh_INCLUDED
      50              : 
      51              : // EnergyPlus Headers
      52              : #include <EnergyPlus/Data/BaseData.hh>
      53              : #include <EnergyPlus/DataGlobals.hh>
      54              : #include <EnergyPlus/EnergyPlus.hh>
      55              : // #include <EnergyPlus/FluidProperties.hh>
      56              : 
      57              : namespace EnergyPlus {
      58              : 
      59              : // Forward declarations
      60              : struct EnergyPlusData;
      61              : 
      62              : namespace Pumps {
      63              : 
      64              :     // Using/Aliasing
      65              : 
      66              :     // Data
      67              :     // MODULE PARAMETER DEFINITIONS:
      68              : 
      69              :     enum class PumpControlType
      70              :     {
      71              :         Invalid = -1,
      72              :         Continuous,   // Pump control type (pump always running)
      73              :         Intermittent, // Pump control type (pump runs only when there is a demand)
      74              :         Num
      75              :     };
      76              : 
      77              :     enum class ControlTypeVFD
      78              :     {
      79              :         Invalid = -1,
      80              :         VFDManual,    // VFD control type (Scheduled RPM)
      81              :         VFDAutomatic, // VFD control type (Variable RPM according to flow request)
      82              :         Num
      83              :     };
      84              : 
      85              :     enum class PumpBankControlSeq
      86              :     {
      87              :         Invalid = -1,
      88              :         OptimalScheme,    // Control sequencing for pump bank
      89              :         SequentialScheme, // Control sequencing for pump bank
      90              :         UserDefined,      // Control sequencing for pump bank
      91              :         Num
      92              :     };
      93              : 
      94              :     enum class PumpType : int
      95              :     {
      96              :         Invalid = -1,
      97              :         VarSpeed,
      98              :         ConSpeed,
      99              :         Cond,
     100              :         Bank_VarSpeed,
     101              :         Bank_ConSpeed,
     102              :         Num
     103              :     };
     104              : 
     105              :     enum class PowerSizingMethod
     106              :     {
     107              :         Invalid = -1,
     108              :         SizePowerPerFlow,
     109              :         SizePowerPerFlowPerPressure,
     110              :         Num
     111              :     };
     112              : 
     113              :     struct PumpVFDControlData
     114              :     {
     115              :         // Members
     116              :         std::string Name;
     117              :         Sched::Schedule *manualRPMSched = nullptr;
     118              :         Sched::Schedule *lowerPsetSched = nullptr;
     119              :         Sched::Schedule *upperPsetSched = nullptr;
     120              :         Sched::Schedule *minRPMSched = nullptr;
     121              :         Sched::Schedule *maxRPMSched = nullptr;
     122              :         ControlTypeVFD VFDControlType = ControlTypeVFD::Invalid; // VFDControlType
     123              :         Real64 MaxRPM = 0.0;                                     // Maximum RPM range value - schedule limit
     124              :         Real64 MinRPM = 0.0;                                     // Minimum RPM range value - schedule limit
     125              :         Real64 PumpActualRPM = 0.0;                              // RPM recalculated from final flow through the loop
     126              :     };
     127              : 
     128              :     struct PumpSpecs
     129              :     {
     130              :         // Members
     131              :         std::string Name;                      // user identifier
     132              :         PumpType pumpType = PumpType::Invalid; // pump type enumerator, based on local parameter values, used to identify
     133              :         // index in the cPumpTypes string array to do error reporting
     134              :         DataPlant::PlantEquipmentType TypeOf_Num = DataPlant::PlantEquipmentType::Invalid; // pump type of number in reference to the dataplant values
     135              :         PlantLocation plantLoc = {0, DataPlant::LoopSideLocation::Invalid, 0, 0};
     136              :         PumpControlType PumpControl = PumpControlType::Invalid;            // Integer equivalent of PumpControlType
     137              :         Sched::Schedule *flowRateSched = nullptr;                          // Flow rate modifier schedule, blank/missing --> AlwaysOn
     138              :         int InletNodeNum = 0;                                              // Node number on the inlet side of the plant
     139              :         int OutletNodeNum = 0;                                             // Node number on the outlet side of the plant
     140              :         PumpBankControlSeq SequencingScheme = PumpBankControlSeq::Invalid; // Optimal, Sequential, User-Defined
     141              :         // Fluid::RefrigProps *fluid = nullptr;                                                // Index for Fluid Properties
     142              :         int NumPumpsInBank = 0;                       // Node number on the inlet side of the plant
     143              :         int PowerErrIndex1 = 0;                       // for recurring errors
     144              :         int PowerErrIndex2 = 0;                       // for recurring errors
     145              :         Real64 MinVolFlowRateFrac = 0.0;              // minimum schedule value fraction modifier
     146              :         Real64 NomVolFlowRate = 0.0;                  // design nominal capacity of Pump
     147              :         bool NomVolFlowRateWasAutoSized = false;      // true if previous was autosize on input
     148              :         Real64 MassFlowRateMax = 0.0;                 // design nominal capacity of Pump
     149              :         bool EMSMassFlowOverrideOn = false;           // if true, then EMS is calling to override flow requests.
     150              :         Real64 EMSMassFlowValue = 0.0;                // EMS value to use for mass flow rate [kg/s]
     151              :         Real64 NomSteamVolFlowRate = 0.0;             // For Steam Pump
     152              :         bool NomSteamVolFlowRateWasAutoSized = false; // true if steam volume flow rate was autosize on input
     153              :         Real64 MinVolFlowRate = 0.0;                  // For a Variable Flow Pump this is the minimum capacity during operation.
     154              :         bool minVolFlowRateWasAutosized = false;      // true if minimum flow rate was autosize on input
     155              :         Real64 MassFlowRateMin = 0.0;                 // For a Variable Flow Pump this is the minimum capacity during operation.
     156              :         Real64 NomPumpHead = 0.0;                     // design nominal head pressure of Pump, [Pa]
     157              :         bool EMSPressureOverrideOn = false;           // if true, EMS is calling to override pump pressure
     158              :         Real64 EMSPressureOverrideValue = 0.0;        // EMS value to use for pressure [Pa]
     159              :         Real64 NomPowerUse = 0.0;                     // design nominal capacity of Pump
     160              :         bool NomPowerUseWasAutoSized = false;         // true if power was autosize on input
     161              :         PowerSizingMethod powerSizingMethod = PowerSizingMethod::SizePowerPerFlowPerPressure; // which method is used for sizing nominal power use
     162              :         Real64 powerPerFlowScalingFactor = 348701.1;                                          // design electric power per unit flow rate (22 W/gpm)
     163              :         Real64 powerPerFlowPerPressureScalingFactor = (1 / .78);   // design shaft power per unit flow rate per unit head (legacy impeller efficiency)
     164              :         Real64 MotorEffic = 0.0;                                   // efficiency of the motor
     165              :         Real64 PumpEffic = 0.0;                                    // efficiency of the pump
     166              :         Real64 FracMotorLossToFluid = 0.0;                         // ?????
     167              :         Real64 Energy = 0.0;                                       // Energy consumed
     168              :         Real64 Power = 0.0;                                        // Power used
     169              :         std::array<Real64, 4> PartLoadCoef = {0.0, 0.0, 0.0, 0.0}; // Pump Curve Coefficients
     170              :         int PressureCurve_Index = 0;                               // Pointer to a pump coefficient curve
     171              :         Real64 PumpMassFlowRateMaxRPM = 0.0;                       // Mass flow rate calculated from maximum rpm
     172              :         Real64 PumpMassFlowRateMinRPM = 0.0;                       // Mass flow rate calculated from minimum rpm
     173              :         Real64 MinPhiValue = 0.0;                                  // Minimum value of Phi (from CurveManager)
     174              :         Real64 MaxPhiValue = 0.0;                                  // Maximum value of Phi (from CurveManager)
     175              :         Real64 ImpellerDiameter = 0.0;                             // Pump Impeller Diameter [m]
     176              :         Real64 RotSpeed_RPM = 0.0;                                 // Rotational speed used for input in revs/min
     177              :         Real64 RotSpeed = 0.0;                                     // Rotational speed for calculations in revs/sec
     178              :         bool PumpInitFlag = true;
     179              :         bool PumpOneTimeFlag = true;
     180              :         bool CheckEquipName = true;
     181              :         bool HasVFD = false;
     182              :         PumpVFDControlData VFD;
     183              :         bool OneTimePressureWarning = true;
     184              :         bool HeatLossesToZone = false;        // if true then pump losses added to surrounding zone
     185              :         int ZoneNum = 0;                      // index for zone surrounding pump
     186              :         Real64 SkinLossRadFraction = 0.0;     // radiative split for skin losses to zone
     187              :         bool LoopSolverOverwriteFlag = false; // loop solver overwrite for determining pump minimum flow rate
     188              :         std::string EndUseSubcategoryName;
     189              :     };
     190              : 
     191              :     struct ReportVars
     192              :     {
     193              :         // Members
     194              :         int NumPumpsOperating = 0;          // Used in pump bank. reports how many pumps are ON
     195              :         Real64 PumpMassFlowRate = 0.0;      // Mass flow rate of the pump
     196              :         Real64 PumpHeattoFluid = 0.0;       // Heat transfer from pump to fluid (W)
     197              :         Real64 PumpHeattoFluidEnergy = 0.0; // Pump Energy dissipated into fluid stream
     198              :         Real64 OutletTemp = 0.0;            // Pump outlet temperature
     199              :         Real64 ShaftPower = 0.0;            // Power input at the shaft
     200              :         Real64 ZoneTotalGainRate = 0.0;     // total pump skin losses to zone (W)
     201              :         Real64 ZoneTotalGainEnergy = 0.0;   // total pump skin losses to zone energy (J)
     202              :         Real64 ZoneConvGainRate = 0.0;      // pump skin losses convecting to zone air (W)
     203              :         Real64 ZoneRadGainRate = 0.0;       // pump skin losses radiating to inside of zone (W)
     204              :     };
     205              : 
     206              :     void SimPumps(EnergyPlusData &state,
     207              :                   std::string const &PumpName, // Name of pump to be managed
     208              :                   int const LoopNum,           // Plant loop number
     209              :                   Real64 const FlowRequest,    // requested flow from adjacent demand side
     210              :                   bool &PumpRunning,           // .TRUE. if the loop pump is actually operating
     211              :                   int &PumpIndex,
     212              :                   Real64 &PumpHeat);
     213              : 
     214              :     void GetPumpInput(EnergyPlusData &state);
     215              : 
     216              :     void InitializePumps(EnergyPlusData &state, int const PumpNum);
     217              : 
     218              :     void SetupPumpMinMaxFlows(EnergyPlusData &state, int const LoopNum, int const PumpNum);
     219              : 
     220              :     void CalcPumps(EnergyPlusData &state, int const PumpNum, Real64 const FlowRequest, bool &PumpRunning);
     221              : 
     222              :     void SizePump(EnergyPlusData &state, int const PumpNum);
     223              : 
     224              :     void ReportPumps(EnergyPlusData &state, int const PumpNum);
     225              : 
     226              :     void PumpDataForTable(EnergyPlusData &state, int const NumPump);
     227              : 
     228              :     void GetRequiredMassFlowRate(EnergyPlusData &state,
     229              :                                  int const LoopNum,
     230              :                                  int const PumpNum,
     231              :                                  Real64 const InletNodeMassFlowRate,
     232              :                                  Real64 &ActualFlowRate,
     233              :                                  Real64 &PumpMinMassFlowRateVFDRange,
     234              :                                  Real64 &PumpMaxMassFlowRateVFDRange);
     235              : 
     236              : } // namespace Pumps
     237              : 
     238              : struct PumpsData : BaseGlobalStruct
     239              : {
     240              : 
     241              :     int NumPumps = 0;         // Num Pumps (used in pump bank)
     242              :     int NumPumpsRunning = 0;  // Num of pumps ON (used in pump bank)
     243              :     int NumPumpsFullLoad = 0; // Num pumps running at full load (used in pump bank)
     244              :     bool GetInputFlag = true;
     245              :     Real64 PumpMassFlowRate = 0.0; // mass flow rate at pump inlet node
     246              :     Real64 PumpHeattoFluid = 0.0;  // Pump Power dissipated in fluid stream
     247              :     Real64 Power = 0.0;            // Pump Electric power
     248              :     Real64 ShaftPower = 0.0;       // Power passing through pump shaft
     249              :     EPVector<Pumps::PumpSpecs> PumpEquip;
     250              :     EPVector<Pumps::ReportVars> PumpEquipReport;
     251              :     std::unordered_map<std::string, std::string> PumpUniqueNames;
     252              : 
     253         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     254              :     {
     255         2126 :     }
     256              : 
     257         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     258              :     {
     259         1152 :     }
     260              : 
     261         2100 :     void clear_state() override
     262              :     {
     263         2100 :         this->NumPumps = 0;
     264         2100 :         this->NumPumpsRunning = 0;
     265         2100 :         this->NumPumpsFullLoad = 0;
     266         2100 :         this->GetInputFlag = true;
     267         2100 :         this->PumpMassFlowRate = 0.0;
     268         2100 :         this->PumpHeattoFluid = 0.0;
     269         2100 :         this->Power = 0.0;
     270         2100 :         this->ShaftPower = 0.0;
     271         2100 :         this->PumpEquip.deallocate();
     272         2100 :         this->PumpEquipReport.deallocate();
     273         2100 :         this->PumpUniqueNames.clear();
     274         2100 :     }
     275              : };
     276              : 
     277              : } // namespace EnergyPlus
     278              : 
     279              : #endif
        

Generated by: LCOV version 2.0-1