LCOV - code coverage report
Current view: top level - EnergyPlus - PlantLoopHeatPumpEIR.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 14 20 70.0 %
Date: 2024-08-24 18:31:18 Functions: 9 13 69.2 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2024, 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          78 :         InOutNodePair() : inlet(0), outlet(0)
     104             :         {
     105          78 :         }
     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          68 :         virtual ~EIRPlantLoopHeatPump() = default;
     243             : 
     244          26 :         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      587322 :         static Real64 add(Real64 const a, Real64 const b)
     320             :         {
     321      587322 :             return a + b;
     322             :         }
     323             : 
     324      315744 :         static Real64 subtract(Real64 const a, Real64 const b)
     325             :         {
     326      315744 :             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             : 
     336             :     struct EIRFuelFiredHeatPump : public EIRPlantLoopHeatPump
     337             :     {
     338             :         // fixed configuration parameters
     339             :         // reference data
     340             :         // curve references
     341             :         // flow rate terms
     342             :         // simulation variables
     343             :         // topology variables
     344             :         // counters and indexes
     345             :         // logic flags
     346             :         // a couple worker functions to easily allow merging of cooling and heating operations
     347             : 
     348             :         // enum definitions for Fuel Fired only
     349             :         enum class OATempCurveVar
     350             :         {
     351             :             Invalid = -1,
     352             :             DryBulb,
     353             :             WetBulb,
     354             :             Num
     355             :         };
     356             : 
     357             :         enum class WaterTempCurveVar
     358             :         {
     359             :             Invalid = -1,
     360             :             EnteringCondenser,
     361             :             LeavingCondenser,
     362             :             EnteringEvaporator,
     363             :             LeavingEvaporator,
     364             :             Num
     365             :         };
     366             : 
     367             :         enum class DefrostType
     368             :         {
     369             :             Invalid = -1,
     370             :             Timed,
     371             :             OnDemand,
     372             :             Num
     373             :         };
     374             : 
     375             :         // New additions for GAHP only
     376             :         Constant::eFuel fuelType = Constant::eFuel::Invalid; // Fuel type assignment
     377             :         std::string endUseSubcat = "";
     378             :         DataPlant::FlowMode flowMode = DataPlant::FlowMode::Invalid;
     379             :         Real64 desSupplyTemp = 60.0;
     380             :         Real64 desTempLift = 11.1;
     381             :         OATempCurveVar oaTempCurveInputVar = OATempCurveVar::DryBulb;
     382             :         WaterTempCurveVar waterTempCurveInputVar = WaterTempCurveVar::EnteringCondenser;
     383             :         // int capFuncTempCurveIndex = 0;
     384             :         // int powerRatioFuncTempCurveIndex = 0;
     385             :         //  int powerRatioFuncPLRCurveIndex = 0;
     386             :         Real64 minPLR = 0.1;
     387             :         Real64 maxPLR = 1.0;
     388             : 
     389             :         int defrostEIRCurveIndex = 0;
     390             :         DefrostType defrostType = DefrostType::OnDemand;
     391             :         Real64 defrostOpTimeFrac = 0.0;
     392             :         Real64 defrostResistiveHeaterCap = 0.0;
     393             :         Real64 defrostMaxOADBT = 5.0;
     394             : 
     395             :         int cycRatioCurveIndex = 0;
     396             :         Real64 nominalAuxElecPower = 0.0;
     397             :         int auxElecEIRFoTempCurveIndex = 0;
     398             :         int auxElecEIRFoPLRCurveIndex = 0;
     399             :         Real64 standbyElecPower = 0.0;
     400             : 
     401             :         // new output variables for derived class only
     402             :         Real64 loadSideVolumeFlowRate = 0.0;
     403             :         Real64 fuelRate = 0.0;   // Unit in W
     404             :         Real64 fuelEnergy = 0.0; // Unit in J
     405             :         int capModFTErrorIndex = 0;
     406             :         int eirModFTErrorIndex = 0;
     407             :         int eirModFPLRErrorIndex = 0;
     408             :         int eirDefrostFTErrorIndex = 0;
     409             :         int eirAuxElecFTErrorIndex = 0;
     410             :         int eirAuxElecFPLRErrorIndex = 0;
     411             : 
     412             :         // Override parent methods to be declared
     413             :         void doPhysics(EnergyPlusData &state, Real64 currentLoad);
     414             :         void sizeSrcSideASHP(EnergyPlusData &state); // 2022-05-18: may not need this one
     415             :         void resetReportingVariables();
     416             :         static PlantComponent *factory(EnergyPlusData &state, DataPlant::PlantEquipmentType hp_type, const std::string &hp_name);
     417             :         static void pairUpCompanionCoils(EnergyPlusData &state);
     418             :         static void processInputForEIRPLHP(EnergyPlusData &state);
     419             :         void oneTimeInit(EnergyPlusData &state);
     420             :         void report(EnergyPlusData &state);
     421             : 
     422             :         // New or specialized functions for derived struct
     423           5 :         virtual ~EIRFuelFiredHeatPump() = default;
     424           2 :         EIRFuelFiredHeatPump() = default;
     425             :     };
     426             : } // namespace EIRPlantLoopHeatPumps
     427             : 
     428             : struct EIRPlantLoopHeatPumpsData : BaseGlobalStruct
     429             : {
     430             :     std::vector<EIRPlantLoopHeatPumps::EIRPlantLoopHeatPump> heatPumps;
     431             :     bool getInputsPLHP = true;
     432             : 
     433         796 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     434             :     {
     435         796 :     }
     436             : 
     437           0 :     void clear_state() override
     438             :     {
     439           0 :         new (this) EIRPlantLoopHeatPumpsData();
     440           0 :     }
     441             : };
     442             : 
     443             : struct EIRFuelFiredHeatPumpsData : BaseGlobalStruct
     444             : {
     445             :     std::vector<EIRPlantLoopHeatPumps::EIRFuelFiredHeatPump> heatPumps;
     446             :     bool getInputsFFHP = true;
     447             : 
     448         796 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     449             :     {
     450         796 :     }
     451             : 
     452           0 :     void clear_state() override
     453             :     {
     454           0 :         new (this) EIRFuelFiredHeatPumpsData();
     455           0 :     }
     456             : };
     457             : 
     458             : } // namespace EnergyPlus
     459             : 
     460             : #endif // ENERGYPLUS_PLANTLOOPHEATPUMPEIR_HH

Generated by: LCOV version 1.14