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 MicroCHPElectricGenerator_hh_INCLUDED
49 : #define MicroCHPElectricGenerator_hh_INCLUDED
50 :
51 : // ObjexxFCL Headers
52 : #include <ObjexxFCL/Array1D.hh>
53 :
54 : // EnergyPlus Headers
55 : #include <EnergyPlus/Data/BaseData.hh>
56 : #include <EnergyPlus/DataGenerators.hh>
57 : #include <EnergyPlus/EnergyPlus.hh>
58 : #include <EnergyPlus/PlantComponent.hh>
59 :
60 : namespace EnergyPlus {
61 :
62 : // Forward declarations
63 : struct EnergyPlusData;
64 :
65 : namespace MicroCHPElectricGenerator {
66 :
67 : struct MicroCHPParamsNonNormalized
68 : {
69 : std::string Name; // name of this PowerModule data
70 : Real64 MaxElecPower; // net electric power [W]
71 : Real64 MinElecPower; // net electric power [W]
72 : Real64 MinWaterMdot; // minimum cooling water flow [kg/s]
73 : Real64 MaxWaterTemp; // limit temp for inlet cooling water [C]
74 : Curve::Curve *ElecEffCurve = nullptr; // index for TriQuadratic for electrical efficiency
75 : Curve::Curve *ThermalEffCurve = nullptr; // index for TriQuadric for thermal efficiency
76 : bool InternalFlowControl; // Plant or Internal Flow rate control?
77 : bool PlantFlowControl; // default is plant control
78 : Curve::Curve *WaterFlowCurve = nullptr; // index for BiQuadratic for water flow rate internal control
79 : Curve::Curve *AirFlowCurve = nullptr; // index for Quadratic for generator air flow
80 : Real64 DeltaPelMax; // max rate of change in net electric power [W/s}
81 : Real64 DeltaFuelMdotMax; // Maximum Rate of change in fuel flow rate [kmol/s2]
82 : Real64 UAhx; // heat exchanger UA [W/K]
83 : Real64 UAskin; // skin loss UA [W/K]
84 : Real64 RadiativeFraction; // skin loss fraction to radiant energy []
85 : Real64 MCeng; // aggregated thermal mass of engine [J/K]
86 : Real64 MCcw; // aggregated thermal mass of heat recovery [J/k]
87 : Real64 Pstandby; // standby power [w]
88 : bool WarmUpByTimeDelay; // Warm up mode control
89 : bool WarmUpByEngineTemp; // Warm up mode control
90 : Real64 kf; // coefficient k_f for warmup fuel flow rate
91 : Real64 TnomEngOp; // nominal engine operating temperature [C]
92 : Real64 kp; // coefficient k_p for warmup power
93 : Real64 Rfuelwarmup; // Warm Up Fuel Flow Rate Limit Ratio
94 : Real64 WarmUpDelay; // time for warm up delay [s]
95 : Real64 PcoolDown; // power during cool down
96 : Real64 CoolDownDelay; // time for cool down delay [s]
97 : bool MandatoryFullCoolDown;
98 : bool WarmRestartOkay;
99 : // calculated and from elsewhere
100 : Real64 TimeElapsed; // Fraction of the current hour that has elapsed (h)
101 : // Saved in order to identify the beginning of a new system time
102 : DataGenerators::OperatingMode OpMode;
103 : Real64 OffModeTime; // amount of time generator spent in Off mode
104 : Real64 StandyByModeTime; // amount of time generator spent in standby mode
105 : Real64 WarmUpModeTime; // amount of time generator spent in warm up mode
106 : Real64 NormalModeTime; // amount of time generator spent in normal mode
107 : Real64 CoolDownModeTime; // amount of time generator spent in Cool down mode
108 : Real64 TengLast; // last timestep's value for engine temperature
109 : Real64 TempCWOutLast; // last timestep's value for cooling water outlet temperature
110 : Real64 Pnet;
111 : Real64 ElecEff;
112 : Real64 Qgross;
113 : Real64 ThermEff;
114 : Real64 Qgenss;
115 : Real64 NdotFuel;
116 : Real64 MdotFuel;
117 : Real64 Teng;
118 : Real64 TcwIn;
119 : Real64 TcwOut;
120 : Real64 MdotAir;
121 : Real64 QdotSkin; // rate of heat loss to zone
122 : Real64 QdotConvZone;
123 : Real64 QdotRadZone;
124 : Real64 ACPowerGen; // reporting: power (W)
125 : Real64 ACEnergyGen; // reporting: energy (J)
126 : Real64 QdotHX; // reporting: rate of heat exchange from engine to coolant (W)
127 : Real64 QdotHR; // reporting: rate of heat recovered (W)
128 : Real64 TotalHeatEnergyRec; // reporting: total heat recovered (J)
129 : Real64 FuelEnergyLHV; // reporting: Fuel Energy used in Lower Heating Value(J)
130 : Real64 FuelEnergyUseRateLHV; // reporting: Fuel Energy used in Lower Heating Value(W)
131 : Real64 FuelEnergyHHV; // reporting: Fuel Energy used in Higher Heating Value(J)
132 : Real64 FuelEnergyUseRateHHV; // reporting: Fuel Energy used in Higher Heating Value(W)
133 : Real64 HeatRecInletTemp; // reporting: Heat Recovery Loop Inlet Temperature (C)
134 : Real64 HeatRecOutletTemp; // reporting: Heat Recovery Loop Outlet Temperature (C)
135 : Real64 FuelCompressPower; // electrical power used by fuel supply compressor [W]
136 : Real64 FuelCompressEnergy; // electrical energy used by fuel supply compressor [J]
137 : Real64 FuelCompressSkinLoss; // heat rate of losses.by fuel supply compressor [W]
138 : Real64 SkinLossPower; // heat loss to surrounding zone [W]
139 : Real64 SkinLossEnergy; // heat loss to surround zone [J]
140 : Real64 SkinLossConvect; // convective heat loss to zone [W]
141 : Real64 SkinLossRadiat; // radiative heat loss to zone [W]
142 :
143 : // Default Constructor
144 5 : MicroCHPParamsNonNormalized()
145 10 : : MaxElecPower(0.0), MinElecPower(0.0), MinWaterMdot(0.0), MaxWaterTemp(0.0), InternalFlowControl(false), PlantFlowControl(true),
146 5 : DeltaPelMax(0.0), DeltaFuelMdotMax(0.0), UAhx(0.0), UAskin(0.0), RadiativeFraction(0.0), MCeng(0.0), MCcw(0.0), Pstandby(0.0),
147 5 : WarmUpByTimeDelay(false), WarmUpByEngineTemp(true), kf(0.0), TnomEngOp(0.0), kp(0.0), Rfuelwarmup(0.0), WarmUpDelay(0.0),
148 5 : PcoolDown(0.0), CoolDownDelay(0.0), MandatoryFullCoolDown(false), WarmRestartOkay(true), TimeElapsed(0.0),
149 5 : OpMode(DataGenerators::OperatingMode::Invalid), OffModeTime(0.0), StandyByModeTime(0.0), WarmUpModeTime(0.0), NormalModeTime(0.0),
150 5 : CoolDownModeTime(0.0), TengLast(20.0), TempCWOutLast(20.0), Pnet(0.0), ElecEff(0.0), Qgross(0.0), ThermEff(0.0), Qgenss(0.0),
151 5 : NdotFuel(0.0), MdotFuel(0.0), Teng(20.0), TcwIn(20.0), TcwOut(20.0), MdotAir(0.0), QdotSkin(0.0), QdotConvZone(0.0), QdotRadZone(0.0),
152 5 : ACPowerGen(0.0), ACEnergyGen(0.0), QdotHX(0.0), QdotHR(0.0), TotalHeatEnergyRec(0.0), FuelEnergyLHV(0.0), FuelEnergyUseRateLHV(0.0),
153 5 : FuelEnergyHHV(0.0), FuelEnergyUseRateHHV(0.0), HeatRecInletTemp(0.0), HeatRecOutletTemp(0.0), FuelCompressPower(0.0),
154 5 : FuelCompressEnergy(0.0), FuelCompressSkinLoss(0.0), SkinLossPower(0.0), SkinLossEnergy(0.0), SkinLossConvect(0.0), SkinLossRadiat(0.0)
155 : {
156 5 : }
157 : };
158 :
159 : struct MicroCHPDataStruct : PlantComponent
160 : {
161 : std::string Name; // name of this Micro CHP Generator
162 : std::string ParamObjName; // name of parameter object
163 : MicroCHPParamsNonNormalized A42Model; // Nested parameter data structure
164 : Real64 NomEff; // nominal efficiency
165 : std::string ZoneName;
166 : int ZoneID;
167 : std::string PlantInletNodeName;
168 : int PlantInletNodeID;
169 : std::string PlantOutletNodeName;
170 : int PlantOutletNodeID;
171 : Real64 PlantMassFlowRate; // only if internal control
172 : Real64 PlantMassFlowRateMax; // hardware limit for node%massflowrateMax
173 : bool PlantMassFlowRateMaxWasAutoSized; // true if mass flow rate was autosized on input
174 : std::string AirInletNodeName;
175 : int AirInletNodeID;
176 : std::string AirOutletNodeName;
177 : int AirOutletNodeID;
178 : int FuelSupplyID; // index for fuel supply data structure
179 : int DynamicsControlID; // index in GeneratorDynamics data where control issues are handled
180 : Sched::Schedule *availSched = nullptr; // index for availability schedule
181 : PlantLocation CWPlantLoc; // cooling water plant loop component index
182 : bool CheckEquipName;
183 : bool MySizeFlag;
184 : bool MyEnvrnFlag;
185 : bool MyPlantScanFlag;
186 : bool myFlag;
187 :
188 : // Default Constructor
189 3 : MicroCHPDataStruct()
190 15 : : NomEff(0.0), ZoneID(0), PlantInletNodeID(0), PlantOutletNodeID(0), PlantMassFlowRate(0.0), PlantMassFlowRateMax(0.0),
191 9 : PlantMassFlowRateMaxWasAutoSized(false), AirInletNodeID(0), AirOutletNodeID(0), FuelSupplyID(0), DynamicsControlID(0), CWPlantLoc{},
192 3 : CheckEquipName(true), MySizeFlag(true), MyEnvrnFlag(true), MyPlantScanFlag(true), myFlag(true)
193 : {
194 3 : }
195 :
196 : void simulate([[maybe_unused]] EnergyPlusData &state,
197 : const PlantLocation &calledFromLocation,
198 : bool FirstHVACIteration,
199 : Real64 &CurLoad,
200 : bool RunFlag) override;
201 :
202 : void getDesignCapacities(EnergyPlusData &state,
203 : [[maybe_unused]] const PlantLocation &calledFromLocation,
204 : Real64 &MaxLoad,
205 : Real64 &MinLoad,
206 : Real64 &OptLoad) override;
207 :
208 : void onInitLoopEquip(EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation) override;
209 :
210 : void setupOutputVars(EnergyPlusData &state);
211 :
212 : void InitMicroCHPNoNormalizeGenerators(EnergyPlusData &state);
213 :
214 : void CalcUpdateHeatRecovery(EnergyPlusData &state) const;
215 :
216 : void CalcMicroCHPNoNormalizeGeneratorModel(EnergyPlusData &state,
217 : bool RunFlagElectCenter, // TRUE when Generator operating
218 : bool RunFlagPlant,
219 : Real64 MyElectricLoad, // Generator demand
220 : Real64 MyThermalLoad);
221 :
222 : void UpdateMicroCHPGeneratorRecords(EnergyPlusData &state);
223 :
224 : static PlantComponent *factory(EnergyPlusData &state, std::string const &objectName);
225 :
226 : void oneTimeInit(EnergyPlusData &state) override;
227 : };
228 :
229 : void GetMicroCHPGeneratorInput(EnergyPlusData &state);
230 :
231 : Real64 FuncDetermineEngineTemp(Real64 TcwOut, // hot water leaving temp
232 : Real64 MCeng, // Fictitious mass and heat capacity of engine
233 : Real64 UAHX, // Heat exchanger UA
234 : Real64 UAskin, // Skin losses UA
235 : Real64 Troom, // surrounding zone temperature C
236 : Real64 Qgenss, // steady state generator heat generation
237 : Real64 TengLast, // engine temp at previous time step
238 : Real64 time // elapsed time since previous evaluation
239 : );
240 :
241 : Real64 FuncDetermineCoolantWaterExitTemp(Real64 TcwIn, // hot water inlet temp
242 : Real64 MCcw, // Fictitious mass and heat capacity of coolant hx
243 : Real64 UAHX, // Heat exchanger UA
244 : Real64 MdotCpcw, // mass flow and specific heat of coolant water
245 : Real64 Teng, // engine mass temperature C
246 : Real64 TcwoutLast, // coolant water leaving temp at previous time step
247 : Real64 time // elapsed time since previous evaluation
248 : );
249 :
250 : bool CheckMicroCHPThermalBalance(Real64 NomHeatGen, // nominal heat generation rate for scaling
251 : Real64 TcwIn, // hot water inlet temp
252 : Real64 TcwOut, // hot water leaving temp
253 : Real64 Teng, // engine mass temperature C
254 : Real64 Troom, // surrounding zone temperature C
255 : Real64 UAHX, // Heat exchanger UA
256 : Real64 UAskin, // Skin losses UA
257 : Real64 Qgenss, // steady state generator heat generation
258 : Real64 MCeng, // Fictitious mass and heat capacity of engine
259 : Real64 MCcw, // Fictitious mass and heat capacity of coolant hx
260 : Real64 MdotCpcw // mass flow and specific heat of coolant water
261 : );
262 :
263 : void FigureMicroCHPZoneGains(EnergyPlusData &state);
264 :
265 : } // namespace MicroCHPElectricGenerator
266 :
267 : struct MicroCHPElectricGeneratorData : BaseGlobalStruct
268 : {
269 :
270 : int NumMicroCHPs = 0;
271 : int NumMicroCHPParams = 0;
272 : EPVector<MicroCHPElectricGenerator::MicroCHPDataStruct> MicroCHP;
273 : EPVector<MicroCHPElectricGenerator::MicroCHPParamsNonNormalized> MicroCHPParamInput;
274 : bool getMicroCHPInputFlag = true;
275 : bool MyOneTimeFlag = true;
276 : bool MyEnvrnFlag = true;
277 :
278 2126 : void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
279 : {
280 2126 : }
281 :
282 1152 : void init_state([[maybe_unused]] EnergyPlusData &state) override
283 : {
284 1152 : }
285 :
286 2100 : void clear_state() override
287 : {
288 2100 : this->NumMicroCHPs = 0;
289 2100 : this->NumMicroCHPParams = 0;
290 2100 : this->getMicroCHPInputFlag = true;
291 2100 : this->MicroCHP.deallocate();
292 2100 : this->MicroCHPParamInput.deallocate();
293 2100 : this->MyOneTimeFlag = true;
294 2100 : this->MyEnvrnFlag = true;
295 2100 : }
296 : };
297 :
298 : } // namespace EnergyPlus
299 :
300 : #endif
|