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 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 14 : 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 : int ElecEffCurveID; // index for TriQuadratic for electrical efficiency
75 : int ThermalEffCurveID; // index for TriQuadric for thermal efficiency
76 : bool InternalFlowControl; // Plant or Internal Flow rate control?
77 : bool PlantFlowControl; // default is plant control
78 : int WaterFlowCurveID; // index for BiQuadratic for water flow rate internal control
79 : int AirFlowCurveID; // 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 8 : MicroCHPParamsNonNormalized()
145 8 : : MaxElecPower(0.0), MinElecPower(0.0), MinWaterMdot(0.0), MaxWaterTemp(0.0), ElecEffCurveID(0), ThermalEffCurveID(0),
146 : InternalFlowControl(false), PlantFlowControl(true), WaterFlowCurveID(0), AirFlowCurveID(0), DeltaPelMax(0.0), DeltaFuelMdotMax(0.0),
147 : UAhx(0.0), UAskin(0.0), RadiativeFraction(0.0), MCeng(0.0), MCcw(0.0), Pstandby(0.0), WarmUpByTimeDelay(false),
148 : WarmUpByEngineTemp(true), kf(0.0), TnomEngOp(0.0), kp(0.0), Rfuelwarmup(0.0), WarmUpDelay(0.0), PcoolDown(0.0), CoolDownDelay(0.0),
149 : MandatoryFullCoolDown(false), WarmRestartOkay(true), TimeElapsed(0.0), OpMode(DataGenerators::OperatingMode::Invalid), OffModeTime(0.0),
150 : StandyByModeTime(0.0), WarmUpModeTime(0.0), NormalModeTime(0.0), CoolDownModeTime(0.0), TengLast(20.0), TempCWOutLast(20.0), Pnet(0.0),
151 : ElecEff(0.0), Qgross(0.0), ThermEff(0.0), Qgenss(0.0), NdotFuel(0.0), MdotFuel(0.0), Teng(20.0), TcwIn(20.0), TcwOut(20.0),
152 : MdotAir(0.0), QdotSkin(0.0), QdotConvZone(0.0), QdotRadZone(0.0), ACPowerGen(0.0), ACEnergyGen(0.0), QdotHX(0.0), QdotHR(0.0),
153 : TotalHeatEnergyRec(0.0), FuelEnergyLHV(0.0), FuelEnergyUseRateLHV(0.0), FuelEnergyHHV(0.0), FuelEnergyUseRateHHV(0.0),
154 : HeatRecInletTemp(0.0), HeatRecOutletTemp(0.0), FuelCompressPower(0.0), FuelCompressEnergy(0.0), FuelCompressSkinLoss(0.0),
155 8 : SkinLossPower(0.0), SkinLossEnergy(0.0), SkinLossConvect(0.0), SkinLossRadiat(0.0)
156 : {
157 8 : }
158 : };
159 :
160 6 : struct MicroCHPDataStruct : PlantComponent
161 : {
162 : std::string Name; // name of this Micro CHP Generator
163 : std::string ParamObjName; // name of parameter object
164 : MicroCHPParamsNonNormalized A42Model; // Nested parameter data structure
165 : Real64 NomEff; // nominal efficiency
166 : std::string ZoneName;
167 : int ZoneID;
168 : std::string PlantInletNodeName;
169 : int PlantInletNodeID;
170 : std::string PlantOutletNodeName;
171 : int PlantOutletNodeID;
172 : Real64 PlantMassFlowRate; // only if internal control
173 : Real64 PlantMassFlowRateMax; // hardware limit for node%massflowrateMax
174 : bool PlantMassFlowRateMaxWasAutoSized; // true if mass flow rate was autosized on input
175 : std::string AirInletNodeName;
176 : int AirInletNodeID;
177 : std::string AirOutletNodeName;
178 : int AirOutletNodeID;
179 : int FuelSupplyID; // index for fuel supply data structure
180 : int DynamicsControlID; // index in GeneratorDynamics data where control issues are handled
181 : int AvailabilitySchedID; // index for availability schedule
182 : PlantLocation CWPlantLoc; // cooling water plant loop component index
183 : bool CheckEquipName;
184 : bool MySizeFlag;
185 : bool MyEnvrnFlag;
186 : bool MyPlantScanFlag;
187 : bool myFlag;
188 :
189 : // Default Constructor
190 4 : MicroCHPDataStruct()
191 4 : : NomEff(0.0), ZoneID(0), PlantInletNodeID(0), PlantOutletNodeID(0), PlantMassFlowRate(0.0), PlantMassFlowRateMax(0.0),
192 : PlantMassFlowRateMaxWasAutoSized(false), AirInletNodeID(0), AirOutletNodeID(0), FuelSupplyID(0), DynamicsControlID(0),
193 4 : AvailabilitySchedID(0), CWPlantLoc{}, CheckEquipName(true), MySizeFlag(true), MyEnvrnFlag(true), MyPlantScanFlag(true), myFlag(true)
194 : {
195 4 : }
196 :
197 : void simulate([[maybe_unused]] EnergyPlusData &state,
198 : const PlantLocation &calledFromLocation,
199 : bool FirstHVACIteration,
200 : Real64 &CurLoad,
201 : bool RunFlag) override;
202 :
203 : void getDesignCapacities(EnergyPlusData &state,
204 : [[maybe_unused]] const PlantLocation &calledFromLocation,
205 : Real64 &MaxLoad,
206 : Real64 &MinLoad,
207 : Real64 &OptLoad) override;
208 :
209 : void onInitLoopEquip(EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation) override;
210 :
211 : void setupOutputVars(EnergyPlusData &state);
212 :
213 : void InitMicroCHPNoNormalizeGenerators(EnergyPlusData &state);
214 :
215 : void CalcUpdateHeatRecovery(EnergyPlusData &state) const;
216 :
217 : void CalcMicroCHPNoNormalizeGeneratorModel(EnergyPlusData &state,
218 : bool RunFlagElectCenter, // TRUE when Generator operating
219 : bool RunFlagPlant,
220 : Real64 MyElectricLoad, // Generator demand
221 : Real64 MyThermalLoad,
222 : bool FirstHVACIteration);
223 :
224 : void UpdateMicroCHPGeneratorRecords(EnergyPlusData &state);
225 :
226 : static PlantComponent *factory(EnergyPlusData &state, std::string const &objectName);
227 :
228 : void oneTimeInit(EnergyPlusData &state) override;
229 : };
230 :
231 : void GetMicroCHPGeneratorInput(EnergyPlusData &state);
232 :
233 : Real64 FuncDetermineEngineTemp(Real64 TcwOut, // hot water leaving temp
234 : Real64 MCeng, // Fictitious mass and heat capacity of engine
235 : Real64 UAHX, // Heat exchanger UA
236 : Real64 UAskin, // Skin losses UA
237 : Real64 Troom, // surrounding zone temperature C
238 : Real64 Qgenss, // steady state generator heat generation
239 : Real64 TengLast, // engine temp at previous time step
240 : Real64 time // elapsed time since previous evaluation
241 : );
242 :
243 : Real64 FuncDetermineCoolantWaterExitTemp(Real64 TcwIn, // hot water inlet temp
244 : Real64 MCcw, // Fictitious mass and heat capacity of coolant hx
245 : Real64 UAHX, // Heat exchanger UA
246 : Real64 MdotCpcw, // mass flow and specific heat of coolant water
247 : Real64 Teng, // engine mass temperature C
248 : Real64 TcwoutLast, // coolant water leaving temp at previous time step
249 : Real64 time // elapsed time since previous evaluation
250 : );
251 :
252 : bool CheckMicroCHPThermalBalance(Real64 NomHeatGen, // nominal heat generation rate for scaling
253 : Real64 TcwIn, // hot water inlet temp
254 : Real64 TcwOut, // hot water leaving temp
255 : Real64 Teng, // engine mass temperature C
256 : Real64 Troom, // surrounding zone temperature C
257 : Real64 UAHX, // Heat exchanger UA
258 : Real64 UAskin, // Skin losses UA
259 : Real64 Qgenss, // steady state generator heat generation
260 : Real64 MCeng, // Fictitious mass and heat capacity of engine
261 : Real64 MCcw, // Fictitious mass and heat capacity of coolant hx
262 : Real64 MdotCpcw // mass flow and specific heat of coolant water
263 : );
264 :
265 : void FigureMicroCHPZoneGains(EnergyPlusData &state);
266 :
267 : } // namespace MicroCHPElectricGenerator
268 :
269 1542 : struct MicroCHPElectricGeneratorData : BaseGlobalStruct
270 : {
271 :
272 : int NumMicroCHPs = 0;
273 : int NumMicroCHPParams = 0;
274 : EPVector<MicroCHPElectricGenerator::MicroCHPDataStruct> MicroCHP;
275 : EPVector<MicroCHPElectricGenerator::MicroCHPParamsNonNormalized> MicroCHPParamInput;
276 : bool getMicroCHPInputFlag = true;
277 : bool MyOneTimeFlag = true;
278 : bool MyEnvrnFlag = true;
279 :
280 0 : void clear_state() override
281 : {
282 0 : this->NumMicroCHPs = 0;
283 0 : this->NumMicroCHPParams = 0;
284 0 : this->getMicroCHPInputFlag = true;
285 0 : this->MicroCHP.deallocate();
286 0 : this->MicroCHPParamInput.deallocate();
287 0 : this->MyOneTimeFlag = true;
288 0 : this->MyEnvrnFlag = true;
289 0 : }
290 : };
291 :
292 : } // namespace EnergyPlus
293 :
294 : #endif
|