LCOV - code coverage report
Current view: top level - EnergyPlus - ICEngineElectricGenerator.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 6 11 54.5 %
Date: 2023-01-17 19:17:23 Functions: 5 7 71.4 %

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

Generated by: LCOV version 1.13