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

            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 ICEngineElectricGenerator_hh_INCLUDED
      49              : #define ICEngineElectricGenerator_hh_INCLUDED
      50              : 
      51              : // ObjexxFCL Headers
      52              : #include <ObjexxFCL/Array1D.hh>
      53              : 
      54              : // EnergyPlus Headers
      55              : #include <EnergyPlus/Data/BaseData.hh>
      56              : #include <EnergyPlus/DataGlobalConstants.hh>
      57              : #include <EnergyPlus/DataGlobals.hh>
      58              : #include <EnergyPlus/ElectricPowerServiceManager.hh>
      59              : #include <EnergyPlus/EnergyPlus.hh>
      60              : #include <EnergyPlus/PlantComponent.hh>
      61              : #include <EnergyPlus/UtilityRoutines.hh>
      62              : 
      63              : namespace EnergyPlus {
      64              : 
      65              : // Forward declarations
      66              : struct EnergyPlusData;
      67              : 
      68              : namespace Curve {
      69              :     struct Curve;
      70              : }
      71              : 
      72              : namespace ICEngineElectricGenerator {
      73              : 
      74              :     Real64 constexpr ReferenceTemp(25.0); // Reference temperature by which lower heating
      75              :     // value is reported.  This should be subtracted
      76              :     // off of when calculated exhaust energies.
      77              : 
      78              :     struct ICEngineGeneratorSpecs : PlantComponent
      79              :     {
      80              :         // Members
      81              :         std::string Name;   // user identifier
      82              :         std::string TypeOf; // Type of Generator
      83              :         GeneratorType CompType_Num;
      84              :         Constant::eFuel FuelType;                      // Type of Fuel - DIESEL, GASOLINE, GAS
      85              :         Real64 RatedPowerOutput;                       // W - design nominal capacity of Generator
      86              :         int ElectricCircuitNode;                       // Electric Circuit Node
      87              :         Real64 MinPartLoadRat;                         // (IC ENGINE MIN) min allowed operating frac full load
      88              :         Real64 MaxPartLoadRat;                         // (IC ENGINE MAX) max allowed operating frac full load
      89              :         Real64 OptPartLoadRat;                         // (IC ENGINE BEST) optimal operating frac full load
      90              :         Real64 ElecOutputFuelRat;                      // (RELDC) Ratio of Generator output to Fuel Energy Input
      91              :         Curve::Curve *ElecOutputFuelCurve = nullptr;   // Curve for generator output to Fuel Energy Input Coeff Poly Fit
      92              :         Real64 RecJacHeattoFuelRat;                    // (RJACDC) Ratio of Recoverable Jacket Heat to Fuel Energy Input
      93              :         Curve::Curve *RecJacHeattoFuelCurve = nullptr; // Curve for Ratio of Recoverable Jacket Heat to
      94              :         // Fuel Energy Input Coeff Poly Fit
      95              :         Real64 RecLubeHeattoFuelRat;                    // (RLUBDC) Ratio of Recoverable Lube Oil Heat to Fuel Energy Input
      96              :         Curve::Curve *RecLubeHeattoFuelCurve = nullptr; // Curve for Ratio of Recoverable Lube Oil Heat to
      97              :         // Fuel Energy Input Coef Poly Fit
      98              :         Real64 TotExhausttoFuelRat;                    // (REXDC) Total Exhaust heat Input to Fuel Energy Input
      99              :         Curve::Curve *TotExhausttoFuelCurve = nullptr; // Curve for Total Exhaust heat Input to Fuel Energy Input
     100              :         // Coeffs Poly Fit
     101              :         Real64 ExhaustTemp;                       // (TEXDC) Exhaust Gas Temp to Fuel Energy Input
     102              :         Curve::Curve *ExhaustTempCurve = nullptr; // Curve for Exhaust Gas Temp to Fuel Energy Input Coeffs Poly Fit
     103              :         int ErrExhaustTempIndex;                  // error index for temp curve
     104              :         Real64 UA;                                // (UACDC) exhaust gas Heat Exchanger UA to Capacity
     105              :         Array1D<Real64> UACoef;                   // Heat Exchanger UA Coeffs Poly Fit
     106              :         Real64 MaxExhaustperPowerOutput;          // MAX EXHAUST FLOW PER W DSL POWER OUTPUT COEFF
     107              :         Real64 DesignMinExitGasTemp;              // Steam Saturation Temperature
     108              :         Real64 FuelHeatingValue;                  // Heating Value of Fuel in kJ/kg
     109              :         Real64 DesignHeatRecVolFlowRate;          // m3/s, Design Water mass flow rate through heat recovery loop
     110              :         Real64 DesignHeatRecMassFlowRate;         // kg/s, Design Water mass flow rate through heat recovery loop
     111              :         bool HeatRecActive;                       // True if Heat Rec Design Vol Flow Rate > 0
     112              :         int HeatRecInletNodeNum;                  // Node number on the heat recovery inlet side of the condenser
     113              :         int HeatRecOutletNodeNum;                 // Node number on the heat recovery outlet side of the condenser
     114              :         Real64 HeatRecInletTemp;                  // Inlet Temperature of the heat recovery fluid
     115              :         Real64 HeatRecOutletTemp;                 // Outlet Temperature of the heat recovery fluid
     116              :         Real64 HeatRecMdotDesign;                 // reporting: Heat Recovery Loop Mass flow rate
     117              :         Real64 HeatRecMdotActual;
     118              :         Real64 QTotalHeatRecovered; // total heat recovered (W)
     119              :         Real64 QJacketRecovered;    // heat recovered from jacket (W)
     120              :         Real64 QLubeOilRecovered;   // heat recovered from lube (W)
     121              :         Real64 QExhaustRecovered;   // exhaust gas heat recovered (W)
     122              :         Real64 FuelEnergyUseRate;   // Fuel Energy used (W)
     123              :         Real64 TotalHeatEnergyRec;  // total heat recovered (J)
     124              :         Real64 JacketEnergyRec;     // heat recovered from jacket (J)
     125              :         Real64 LubeOilEnergyRec;    // heat recovered from lube (J)
     126              :         Real64 ExhaustEnergyRec;    // exhaust gas heat recovered (J)
     127              :         Real64 FuelEnergy;          // Fuel Energy used (J)
     128              :         Real64 FuelMdot;            // Fuel Amount used (Kg/s)
     129              :         Real64 ExhaustStackTemp;    // Exhaust Stack Temperature (C)
     130              :         Real64 ElecPowerGenerated;  // Electric Power Generated (W)
     131              :         Real64 ElecEnergyGenerated; // Amount of Electric Energy Generated (J)
     132              :         Real64 HeatRecMaxTemp;      // Max Temp that can be produced in heat recovery
     133              :         PlantLocation HRPlantLoc;   // cooling water plant loop component index, for heat recovery
     134              :         bool MyEnvrnFlag;
     135              :         bool MyPlantScanFlag;
     136              :         bool MySizeAndNodeInitFlag;
     137              :         bool CheckEquipName;
     138              :         bool myFlag;
     139              : 
     140              :         // Default Constructor
     141            1 :         ICEngineGeneratorSpecs()
     142            2 :             : TypeOf("Generator:InternalCombustionEngine"), CompType_Num(GeneratorType::ICEngine), RatedPowerOutput(0.0), ElectricCircuitNode(0),
     143            1 :               MinPartLoadRat(0.0), MaxPartLoadRat(0.0), OptPartLoadRat(0.0), ElecOutputFuelRat(0.0), RecJacHeattoFuelRat(0.0),
     144            1 :               RecLubeHeattoFuelRat(0.0), TotExhausttoFuelRat(0.0), ExhaustTemp(0.0), ErrExhaustTempIndex(0), UA(0.0), UACoef(2, 0.0),
     145            1 :               MaxExhaustperPowerOutput(0.0), DesignMinExitGasTemp(0.0), FuelHeatingValue(0.0), DesignHeatRecVolFlowRate(0.0),
     146            1 :               DesignHeatRecMassFlowRate(0.0), HeatRecActive(false), HeatRecInletNodeNum(0), HeatRecOutletNodeNum(0), HeatRecInletTemp(0.0),
     147            1 :               HeatRecOutletTemp(0.0), HeatRecMdotDesign(0.0), HeatRecMdotActual(0.0), QTotalHeatRecovered(0.0), QJacketRecovered(0.0),
     148            1 :               QLubeOilRecovered(0.0), QExhaustRecovered(0.0), FuelEnergyUseRate(0.0), TotalHeatEnergyRec(0.0), JacketEnergyRec(0.0),
     149            1 :               LubeOilEnergyRec(0.0), ExhaustEnergyRec(0.0), FuelEnergy(0.0), FuelMdot(0.0), ExhaustStackTemp(0.0), ElecPowerGenerated(0.0),
     150            1 :               ElecEnergyGenerated(0.0), HeatRecMaxTemp(0.0), HRPlantLoc{}, MyEnvrnFlag(true), MyPlantScanFlag(true), MySizeAndNodeInitFlag(true),
     151            2 :               CheckEquipName(true), myFlag(true)
     152              :         {
     153            1 :         }
     154              : 
     155              :         void simulate([[maybe_unused]] EnergyPlusData &state,
     156              :                       const PlantLocation &calledFromLocation,
     157              :                       bool FirstHVACIteration,
     158              :                       Real64 &CurLoad,
     159              :                       bool RunFlag) override;
     160              : 
     161              :         void InitICEngineGenerators(EnergyPlusData &state, bool RunFlag, bool FirstHVACIteration);
     162              : 
     163              :         void CalcICEngineGeneratorModel(EnergyPlusData &state, bool RunFlag, Real64 MyLoad);
     164              : 
     165              :         void CalcICEngineGenHeatRecovery(EnergyPlusData &state, Real64 EnergyRecovered, Real64 HeatRecMdot, Real64 &HRecRatio);
     166              : 
     167              :         void update(EnergyPlusData &state);
     168              : 
     169              :         void setupOutputVars(EnergyPlusData &state);
     170              : 
     171              :         void getDesignCapacities(EnergyPlusData &state,
     172              :                                  [[maybe_unused]] const PlantLocation &calledFromLocation,
     173              :                                  Real64 &MaxLoad,
     174              :                                  Real64 &MinLoad,
     175              :                                  Real64 &OptLoad) override;
     176              : 
     177              :         static PlantComponent *factory(EnergyPlusData &state, std::string const &objectName);
     178              : 
     179              :         void oneTimeInit(EnergyPlusData &state) override;
     180              :     };
     181              : 
     182              :     void GetICEngineGeneratorInput(EnergyPlusData &state);
     183              : 
     184              : } // namespace ICEngineElectricGenerator
     185              : 
     186              : struct ICEngineElectricGeneratorData : BaseGlobalStruct
     187              : {
     188              : 
     189              :     int NumICEngineGenerators = 0;                                                // number of IC ENGINE Generators specified in input
     190              :     bool getICEInput = true;                                                      // When TRUE, calls subroutine to read input file.
     191              :     Array1D<ICEngineElectricGenerator::ICEngineGeneratorSpecs> ICEngineGenerator; // dimension to number of machines
     192              : 
     193         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     194              :     {
     195         2126 :     }
     196              : 
     197         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     198              :     {
     199         1152 :     }
     200              : 
     201         2100 :     void clear_state() override
     202              :     {
     203         2100 :         this->getICEInput = true;
     204         2100 :         this->NumICEngineGenerators = 0;
     205         2100 :         this->ICEngineGenerator.deallocate();
     206         2100 :     }
     207              : };
     208              : 
     209              : } // namespace EnergyPlus
     210              : 
     211              : #endif
        

Generated by: LCOV version 2.0-1