LCOV - code coverage report
Current view: top level - EnergyPlus - PlantLoopHeatPumpEIR.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 100.0 % 24 24
Test Date: 2025-05-22 16:09:37 Functions: 100.0 % 13 13

            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 ENERGYPLUS_PLANTLOOPHEATPUMPEIR_HH
      49              : #define ENERGYPLUS_PLANTLOOPHEATPUMPEIR_HH
      50              : 
      51              : // C++ headers
      52              : #include <functional>
      53              : #include <string>
      54              : #include <vector>
      55              : 
      56              : // EnergyPlus headers
      57              : #include <EnergyPlus/Data/BaseData.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 EIRPlantLoopHeatPumps {
      67              : 
      68              :     // control heat pump on load or set point
      69              :     enum class ControlType
      70              :     {
      71              :         Invalid = -1,
      72              :         Setpoint,
      73              :         Load,
      74              :         Num
      75              :     };
      76              : 
      77              :     // Method of sizing heating capacity
      78              :     enum class HeatSizingType
      79              :     {
      80              :         Invalid = -1,
      81              :         Heating,
      82              :         Cooling,
      83              :         GreaterOfCoolingOrHeating,
      84              :         Num
      85              :     };
      86              : 
      87              :     // Defrost strategy
      88              :     enum class DefrostControl
      89              :     {
      90              :         Invalid = -1,
      91              :         None,
      92              :         Timed,          // uses fixed time reverse cycle defrost strategy
      93              :         OnDemand,       // uses outdoor humidity defrost timing
      94              :         TimedEmpirical, // uses outdoor temperature defrost timing
      95              :         Num,
      96              :     };
      97              : 
      98              :     struct InOutNodePair
      99              :     {
     100              :         int inlet;
     101              :         int outlet;
     102              : 
     103          213 :         InOutNodePair() : inlet(0), outlet(0)
     104              :         {
     105          213 :         }
     106              :     };
     107              : 
     108              :     struct EIRPlantLoopHeatPump : public EnergyPlus::PlantComponent
     109              :     {
     110              : 
     111              :         // fixed configuration parameters
     112              :         std::string name;
     113              :         DataPlant::PlantEquipmentType EIRHPType = DataPlant::PlantEquipmentType::Invalid;
     114              :         std::string companionCoilName;
     115              :         EIRPlantLoopHeatPump *companionHeatPumpCoil = nullptr;
     116              :         Real64 sizingFactor = 1.0;
     117              :         bool waterSource = false;
     118              :         bool airSource = false;
     119              :         bool heatRecoveryAvailable = false;
     120              :         bool heatRecoveryIsActive = false;
     121              :         int heatRecoveryOperatingStatus = 0;
     122              :         ControlType sysControlType = ControlType::Invalid;
     123              :         DataPlant::FlowMode flowControl = DataPlant::FlowMode::Invalid;
     124              : 
     125              :         // sizing data
     126              :         Real64 heatSizingRatio = 1.0;
     127              :         HeatSizingType heatSizingMethod = HeatSizingType::Invalid;
     128              : 
     129              :         // reference data
     130              :         Real64 referenceCapacity = 0.0;
     131              :         bool referenceCapacityWasAutoSized = false;
     132              :         Real64 referenceCOP = 0.0;
     133              :         Real64 minimumPLR = 0.0;
     134              :         Real64 partLoadRatio = 0.0;
     135              :         Real64 cyclingRatio = 0.0;
     136              :         Real64 minSourceTempLimit = -999.0;
     137              :         Real64 maxSourceTempLimit = 999.0;
     138              :         Real64 minHeatRecoveryTempLimit = 4.5;
     139              :         Real64 maxHeatRecoveryTempLimit = 60.0;
     140              : 
     141              :         // curve references
     142              :         int capFuncTempCurveIndex = 0;
     143              :         int powerRatioFuncTempCurveIndex = 0;
     144              :         int powerRatioFuncPLRCurveIndex = 0;
     145              :         int capacityDryAirCurveIndex = 0;
     146              :         int minSupplyWaterTempCurveIndex = 0;
     147              :         int maxSupplyWaterTempCurveIndex = 0;
     148              :         int heatRecoveryCapFTempCurveIndex = 0;
     149              :         int heatRecoveryEIRFTempCurveIndex = 0;
     150              : 
     151              :         // flow rate terms
     152              :         Real64 loadSideDesignVolFlowRate = 0.0;
     153              :         bool loadSideDesignVolFlowRateWasAutoSized = false;
     154              :         Real64 sourceSideDesignVolFlowRate = 0.0;
     155              :         bool sourceSideDesignVolFlowRateWasAutoSized = false;
     156              :         Real64 loadSideDesignMassFlowRate = 0.0;
     157              :         Real64 sourceSideDesignMassFlowRate = 0.0;
     158              :         Real64 loadSideMassFlowRate = 0.0;
     159              :         Real64 sourceSideMassFlowRate = 0.0;
     160              :         Real64 loadVSPumpMinLimitMassFlow = 0.0;
     161              :         Real64 sourceVSPumpMinLimitMassFlow = 0.0;
     162              :         bool loadVSBranchPump = false;
     163              :         bool loadVSLoopPump = false;
     164              :         bool sourceVSBranchPump = false;
     165              :         bool sourceVSLoopPump = false;
     166              :         bool heatRecoveryDesignVolFlowRateWasAutoSized = false;
     167              :         Real64 heatRecoveryDesignVolFlowRate = 0.0;
     168              :         Real64 heatRecoveryDesignMassFlowRate = 0.0;
     169              :         Real64 heatRecoveryMassFlowRate = 0.0;
     170              : 
     171              :         // simulation variables
     172              :         Real64 loadSideHeatTransfer = 0.0;
     173              :         Real64 sourceSideHeatTransfer = 0.0;
     174              :         Real64 loadSideInletTemp = 0.0;
     175              :         Real64 loadSideOutletTemp = 0.0;
     176              :         Real64 sourceSideInletTemp = 0.0;
     177              :         Real64 sourceSideOutletTemp = 0.0;
     178              :         Real64 heatRecoveryInletTemp = 0.0;
     179              :         Real64 heatRecoveryOutletTemp = 0.0;
     180              :         Real64 powerUsage = 0.0;
     181              :         Real64 loadSideEnergy = 0.0;
     182              :         Real64 sourceSideEnergy = 0.0;
     183              :         Real64 powerEnergy = 0.0;
     184              :         Real64 heatRecoveryRate = 0.0;
     185              :         Real64 heatRecoveryEnergy = 0.0;
     186              :         // Real64 sourceSideCp = 0.0; // debugging variable
     187              :         bool running = false;
     188              : 
     189              :         // topology variables
     190              :         PlantLocation loadSidePlantLoc;
     191              :         PlantLocation sourceSidePlantLoc;
     192              :         InOutNodePair loadSideNodes;
     193              :         InOutNodePair sourceSideNodes;
     194              :         PlantLocation heatRecoveryPlantLoc;
     195              :         InOutNodePair heatRecoveryNodes;
     196              :         bool heatRecoveryHeatPump = false; // HP that transfers heat between plants and should not increase plant size
     197              : 
     198              :         // counters and indexes
     199              :         int condMassFlowRateTriggerIndex = 0;
     200              :         int recurringConcurrentOperationWarningIndex = 0;
     201              : 
     202              :         // logic flags
     203              :         bool oneTimeInitFlag = true;
     204              :         bool envrnInit = true;
     205              : 
     206              :         // recurrent warning messages index integers
     207              :         int capModFTErrorIndex = 0;
     208              :         int eirModFTErrorIndex = 0;
     209              :         int eirModFPLRErrorIndex = 0;
     210              :         int heatRecCapModFTErrorIndex = 0;
     211              :         int heatRecEIRModFTErrorIndex = 0;
     212              : 
     213              :         // defrost
     214              :         DefrostControl defrostStrategy = DefrostControl::Invalid;
     215              :         Real64 defrostTime = 0.0;
     216              :         int defrostFreqCurveIndex = 0;
     217              :         int defrostHeatLoadCurveIndex = 0;
     218              :         int defrostHeatEnergyCurveIndex = 0;
     219              :         int defrostLoadCurveDims = 0;
     220              :         int defrostEnergyCurveDims = 0;
     221              :         int defrostEIRFTIndex = 0;
     222              :         bool defrostAvailable = false;
     223              :         Real64 loadDueToDefrost = 0.0;
     224              :         Real64 defrostEnergyRate = 0.0;
     225              :         Real64 defrostEnergy = 0.0;
     226              :         Real64 fractionalDefrostTime = 0.0;
     227              :         Real64 maxOutdoorTemperatureDefrost = 0.0;
     228              :         Real64 defrostPowerMultiplier = 1.0; // defrost power adjustment factor
     229              : 
     230              :         // thermosiphon model
     231              :         int thermosiphonTempCurveIndex = 0;
     232              :         Real64 thermosiphonMinTempDiff = 0.0;
     233              :         int thermosiphonStatus = 0;
     234              : 
     235              :         // a couple worker functions to easily allow merging of cooling and heating operations
     236              :         std::function<Real64(Real64, Real64)> calcLoadOutletTemp;
     237              :         std::function<Real64(Real64, Real64)> calcQsource;
     238              :         std::function<Real64(Real64, Real64)> calcSourceOutletTemp;
     239              :         std::function<Real64(Real64, Real64)> calcQheatRecovery;
     240              :         std::function<Real64(Real64, Real64)> calcHROutletTemp;
     241              : 
     242           80 :         virtual ~EIRPlantLoopHeatPump() = default;
     243              : 
     244           71 :         EIRPlantLoopHeatPump() = default;
     245              : 
     246              :         void
     247              :         simulate(EnergyPlusData &state, const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override;
     248              : 
     249              :         void onInitLoopEquip([[maybe_unused]] EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation) override;
     250              : 
     251              :         void getDesignCapacities(EnergyPlusData &state,
     252              :                                  [[maybe_unused]] const PlantLocation &calledFromLocation,
     253              :                                  [[maybe_unused]] Real64 &MaxLoad,
     254              :                                  [[maybe_unused]] Real64 &MinLoad,
     255              :                                  [[maybe_unused]] Real64 &OptLoad) override;
     256              : 
     257              :         virtual void doPhysics(EnergyPlusData &state, Real64 currentLoad);
     258              : 
     259              :         void doPhysicsWSHP(EnergyPlusData &state, Real64 currentLoad);
     260              : 
     261              :         void doPhysicsASHP(EnergyPlusData &state, Real64 currentLoad);
     262              : 
     263              :         void calcAvailableCapacity(EnergyPlusData &state, Real64 const currentLoad, Real64 &availableCapacity, Real64 &partLoadRatio);
     264              : 
     265              :         Real64 heatingCapacityModifierASHP(EnergyPlusData &state) const;
     266              : 
     267              :         void setPartLoadAndCyclingRatio(EnergyPlusData &state, Real64 &partLoadRatio);
     268              : 
     269              :         void calcLoadSideHeatTransfer(EnergyPlusData &state, Real64 const availableCapacity);
     270              : 
     271              :         void calcPowerUsage(EnergyPlusData &state);
     272              : 
     273              :         void calcSourceSideHeatTransferWSHP(EnergyPlusData &state);
     274              : 
     275              :         void calcSourceSideHeatTransferASHP(EnergyPlusData &state);
     276              : 
     277              :         void calcHeatRecoveryHeatTransferASHP(EnergyPlusData &state);
     278              : 
     279              :         void setHeatRecoveryOperatingStatusASHP(EnergyPlusData &state, bool FirstHVACIteration);
     280              : 
     281              :         virtual void report(EnergyPlusData &state);
     282              : 
     283              :         void sizeLoadSide(EnergyPlusData &state);
     284              : 
     285              :         void sizeSrcSideWSHP(EnergyPlusData &state);
     286              : 
     287              :         void sizeSrcSideASHP(EnergyPlusData &state);
     288              : 
     289              :         void sizeHeatRecoveryASHP(EnergyPlusData &state);
     290              : 
     291              :         void doDefrost(EnergyPlusData &state, Real64 &AvailableCapacity);
     292              : 
     293              :         void capModFTCurveCheck(EnergyPlusData &state, const Real64 loadSideOutletSPTemp, Real64 &capModFTemp);
     294              : 
     295              :         void heatRecoveryCapModFTCurveCheck(EnergyPlusData &state, const Real64 loadSideOutletSPTemp, Real64 &capModFTemp);
     296              : 
     297              :         void eirModCurveCheck(EnergyPlusData &state, Real64 &eirModFTemp);
     298              : 
     299              :         void eirModFPLRCurveCheck(EnergyPlusData &state, Real64 &eirModFPLR);
     300              : 
     301              :         void heatRecoveryEIRModCurveCheck(EnergyPlusData &state, Real64 &eirModFTemp);
     302              : 
     303              :         Real64 getLoadSideOutletSetPointTemp(EnergyPlusData &state) const;
     304              : 
     305              :         void setOperatingFlowRatesASHP(EnergyPlusData &state, bool FirstHVACIteration);
     306              : 
     307              :         void setOperatingFlowRatesWSHP(EnergyPlusData &state, bool FirstHVACIteration);
     308              : 
     309              :         virtual void resetReportingVariables();
     310              : 
     311              :         static PlantComponent *factory(EnergyPlusData &state, DataPlant::PlantEquipmentType hp_type, const std::string &hp_name);
     312              : 
     313              :         static void pairUpCompanionCoils(EnergyPlusData &state);
     314              : 
     315              :         static void processInputForEIRPLHP(EnergyPlusData &state);
     316              : 
     317              :         static void checkConcurrentOperation(EnergyPlusData &state);
     318              : 
     319           47 :         static Real64 add(Real64 const a, Real64 const b)
     320              :         {
     321           47 :             return a + b;
     322              :         }
     323              : 
     324           42 :         static Real64 subtract(Real64 const a, Real64 const b)
     325              :         {
     326           42 :             return a - b;
     327              :         }
     328              : 
     329              :         void isPlantInletOrOutlet(EnergyPlusData &state);
     330              : 
     331              :         void oneTimeInit(EnergyPlusData &state) override;
     332              : 
     333              :         bool thermosiphonDisabled(EnergyPlusData &state);
     334              : 
     335              :         Real64 getDynamicMaxCapacity(EnergyPlusData &state) override;
     336              :     };
     337              : 
     338              :     struct EIRFuelFiredHeatPump : public EIRPlantLoopHeatPump
     339              :     {
     340              :         // fixed configuration parameters
     341              :         // reference data
     342              :         // curve references
     343              :         // flow rate terms
     344              :         // simulation variables
     345              :         // topology variables
     346              :         // counters and indexes
     347              :         // logic flags
     348              :         // a couple worker functions to easily allow merging of cooling and heating operations
     349              : 
     350              :         // enum definitions for Fuel Fired only
     351              :         enum class OATempCurveVar
     352              :         {
     353              :             Invalid = -1,
     354              :             DryBulb,
     355              :             WetBulb,
     356              :             Num
     357              :         };
     358              : 
     359              :         enum class WaterTempCurveVar
     360              :         {
     361              :             Invalid = -1,
     362              :             EnteringCondenser,
     363              :             LeavingCondenser,
     364              :             EnteringEvaporator,
     365              :             LeavingEvaporator,
     366              :             Num
     367              :         };
     368              : 
     369              :         enum class DefrostType
     370              :         {
     371              :             Invalid = -1,
     372              :             Timed,
     373              :             OnDemand,
     374              :             Num
     375              :         };
     376              : 
     377              :         // New additions for GAHP only
     378              :         Constant::eFuel fuelType = Constant::eFuel::Invalid; // Fuel type assignment
     379              :         std::string endUseSubcat = "";
     380              :         DataPlant::FlowMode flowMode = DataPlant::FlowMode::Invalid;
     381              :         Real64 desSupplyTemp = 60.0;
     382              :         Real64 desTempLift = 11.1;
     383              :         OATempCurveVar oaTempCurveInputVar = OATempCurveVar::DryBulb;
     384              :         WaterTempCurveVar waterTempCurveInputVar = WaterTempCurveVar::EnteringCondenser;
     385              :         // int capFuncTempCurveIndex = 0;
     386              :         // int powerRatioFuncTempCurveIndex = 0;
     387              :         //  int powerRatioFuncPLRCurveIndex = 0;
     388              :         Real64 minPLR = 0.1;
     389              :         Real64 maxPLR = 1.0;
     390              : 
     391              :         int defrostEIRCurveIndex = 0;
     392              :         DefrostType defrostType = DefrostType::OnDemand;
     393              :         Real64 defrostOpTimeFrac = 0.0;
     394              :         Real64 defrostResistiveHeaterCap = 0.0;
     395              :         Real64 defrostMaxOADBT = 5.0;
     396              : 
     397              :         int cycRatioCurveIndex = 0;
     398              :         Real64 nominalAuxElecPower = 0.0;
     399              :         int auxElecEIRFoTempCurveIndex = 0;
     400              :         int auxElecEIRFoPLRCurveIndex = 0;
     401              :         Real64 standbyElecPower = 0.0;
     402              : 
     403              :         // new output variables for derived class only
     404              :         Real64 loadSideVolumeFlowRate = 0.0;
     405              :         Real64 fuelRate = 0.0;   // Unit in W
     406              :         Real64 fuelEnergy = 0.0; // Unit in J
     407              :         int capModFTErrorIndex = 0;
     408              :         int eirModFTErrorIndex = 0;
     409              :         int eirModFPLRErrorIndex = 0;
     410              :         int eirDefrostFTErrorIndex = 0;
     411              :         int eirAuxElecFTErrorIndex = 0;
     412              :         int eirAuxElecFPLRErrorIndex = 0;
     413              : 
     414              :         // Override parent methods to be declared
     415              :         void doPhysics(EnergyPlusData &state, Real64 currentLoad) override;
     416              :         void sizeSrcSideASHP(EnergyPlusData &state); // 2022-05-18: may not need this one
     417              :         void resetReportingVariables() override;
     418              :         static PlantComponent *factory(EnergyPlusData &state, DataPlant::PlantEquipmentType hp_type, const std::string &hp_name);
     419              :         static void pairUpCompanionCoils(EnergyPlusData &state);
     420              :         static void processInputForEIRPLHP(EnergyPlusData &state);
     421              :         void oneTimeInit(EnergyPlusData &state) override;
     422              :         void report(EnergyPlusData &state) override;
     423              :         Real64 getDynamicMaxCapacity(EnergyPlusData &state) override;
     424              : 
     425              :         // New or specialized functions for derived struct
     426            8 :         virtual ~EIRFuelFiredHeatPump() = default;
     427           21 :         EIRFuelFiredHeatPump() = default;
     428              :     };
     429              : } // namespace EIRPlantLoopHeatPumps
     430              : 
     431              : struct EIRPlantLoopHeatPumpsData : BaseGlobalStruct
     432              : {
     433              :     std::vector<EIRPlantLoopHeatPumps::EIRPlantLoopHeatPump> heatPumps;
     434              :     bool getInputsPLHP = true;
     435              : 
     436         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     437              :     {
     438         2126 :     }
     439              : 
     440         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     441              :     {
     442         1152 :     }
     443              : 
     444         2101 :     void clear_state() override
     445              :     {
     446         2101 :         new (this) EIRPlantLoopHeatPumpsData();
     447         2101 :     }
     448              : };
     449              : 
     450              : struct EIRFuelFiredHeatPumpsData : BaseGlobalStruct
     451              : {
     452              :     std::vector<EIRPlantLoopHeatPumps::EIRFuelFiredHeatPump> heatPumps;
     453              :     bool getInputsFFHP = true;
     454              : 
     455         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     456              :     {
     457         2126 :     }
     458              : 
     459         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     460              :     {
     461         1152 :     }
     462              : 
     463         2100 :     void clear_state() override
     464              :     {
     465         2100 :         new (this) EIRFuelFiredHeatPumpsData();
     466         2100 :     }
     467              : };
     468              : 
     469              : } // namespace EnergyPlus
     470              : 
     471              : #endif // ENERGYPLUS_PLANTLOOPHEATPUMPEIR_HH
        

Generated by: LCOV version 2.0-1