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 ElectricPowerServiceManager_hh_INCLUDED
49 : #define ElectricPowerServiceManager_hh_INCLUDED
50 :
51 : // C++ Headers
52 : #include <memory>
53 : #include <string>
54 : #include <vector>
55 :
56 : // EnergyPlus Headers
57 : #include <EnergyPlus/Data/BaseData.hh>
58 : #include <EnergyPlus/DataGlobalConstants.hh>
59 : #include <EnergyPlus/DataHeatBalance.hh>
60 : #include <EnergyPlus/EMSManager.hh>
61 : #include <EnergyPlus/EnergyPlus.hh>
62 : #include <EnergyPlus/OutputProcessor.hh>
63 : #include <EnergyPlus/PVWatts.hh>
64 : #include <EnergyPlus/Plant/Enums.hh>
65 : #include <EnergyPlus/Plant/PlantLocation.hh>
66 :
67 : // SSC Headers
68 : #include <../third_party/ssc/shared/lib_battery.h>
69 :
70 : namespace EnergyPlus {
71 :
72 : enum class GeneratorType
73 : {
74 : Invalid = -1,
75 : ICEngine,
76 : CombTurbine,
77 : PV,
78 : FuelCell,
79 : MicroCHP,
80 : Microturbine,
81 : WindTurbine,
82 : PVWatts,
83 : Num
84 : };
85 :
86 : static constexpr std::array<std::string_view, static_cast<int>(GeneratorType::Num)> GeneratorTypeNames{"Generator:InternalCombustionEngine",
87 : "Generator:CombustionTurbine",
88 : "Generator:Photovoltaic",
89 : "Generator:FuelCell",
90 : "Generator:MicroCHP",
91 : "Generator:MicroTurbine",
92 : "Generator:WindTurbine",
93 : "Generator:PVWatts"};
94 :
95 : static constexpr std::array<std::string_view, static_cast<int>(GeneratorType::Num)> GeneratorTypeNamesUC{"GENERATOR:INTERNALCOMBUSTIONENGINE",
96 : "GENERATOR:COMBUSTIONTURBINE",
97 : "GENERATOR:PHOTOVOLTAIC",
98 : "GENERATOR:FUELCELL",
99 : "GENERATOR:MICROCHP",
100 : "GENERATOR:MICROTURBINE",
101 : "GENERATOR:WINDTURBINE",
102 : "GENERATOR:PVWATTS"};
103 :
104 : enum class ThermalLossDestination
105 : {
106 : Invalid = -1,
107 : ZoneGains, // device thermal losses are added to a zone as internal gains
108 : LostToOutside, // device thermal losses have no destination
109 : Num
110 : };
111 :
112 : void initializeElectricPowerServiceZoneGains(EnergyPlusData &state);
113 :
114 11 : class DCtoACInverter
115 : // This class is for modelling a power conversion device that takes DC power in and produces AC power out.
116 : // This class combines three separate input objects that have different methods of determining efficiency.
117 : {
118 :
119 : public: // Methods
120 : enum class InverterModelType
121 : {
122 : Invalid = -1,
123 : CECLookUpTableModel,
124 : CurveFuncOfPower,
125 : SimpleConstantEff,
126 : PVWatts,
127 : Num
128 : };
129 :
130 : // Constructor
131 : DCtoACInverter(EnergyPlusData &state, std::string const &objectName);
132 :
133 : void simulate(EnergyPlusData &state, Real64 const powerIntoInverter);
134 :
135 : void reinitAtBeginEnvironment();
136 :
137 : void reinitZoneGainsAtBeginEnvironment();
138 :
139 : void setPVWattsDCCapacity(EnergyPlusData &state, Real64 const dcCapacity);
140 :
141 : Real64 pvWattsDCCapacity();
142 :
143 : Real64 pvWattsInverterEfficiency();
144 :
145 : Real64 pvWattsDCtoACSizeRatio();
146 :
147 : Real64 thermLossRate() const;
148 :
149 : Real64 getLossRateForOutputPower(EnergyPlusData &state, Real64 const powerOutOfInverter);
150 :
151 : Real64 aCPowerOut() const;
152 :
153 : Real64 aCEnergyOut() const;
154 :
155 : InverterModelType modelType() const;
156 :
157 : std::string const &name() const;
158 :
159 : private: // Methods
160 : void calcEfficiency(EnergyPlusData &state);
161 :
162 : private: // data
163 : std::string name_; // user identifier
164 : Real64 aCPowerOut_;
165 : Real64 aCEnergyOut_;
166 : Real64 efficiency_;
167 : Real64 dCPowerIn_;
168 : Real64 dCEnergyIn_;
169 : Real64 conversionLossPower_;
170 : Real64 conversionLossEnergy_;
171 : Real64 conversionLossEnergyDecrement_;
172 : Real64 thermLossRate_;
173 : Real64 thermLossEnergy_;
174 : Real64 qdotConvZone_;
175 : Real64 qdotRadZone_;
176 : Real64 ancillACuseRate_;
177 : Real64 ancillACuseEnergy_;
178 : InverterModelType modelType_; // type of inverter model used
179 : int availSchedPtr_; // number for availability schedule.
180 : ThermalLossDestination heatLossesDestination_;
181 : int zoneNum_; // destination zone for heat losses from inverter.
182 : Real64 zoneRadFract_; // radiative fraction for thermal losses to zone
183 : Real64 nominalVoltage_; // CEC lookup table model
184 : std::vector<Real64> nomVoltEfficiencyARR_; // eff at 10, 20, 30, 50, 75, & 100% CEC lookup table model
185 : int curveNum_; // curve index for eff as func of power
186 : Real64 ratedPower_; // rated, max continuous power output level for inverter
187 : Real64 minPower_;
188 : Real64 maxPower_;
189 : Real64 minEfficiency_;
190 : Real64 maxEfficiency_;
191 : Real64 standbyPower_;
192 : Real64 pvWattsDCtoACSizeRatio_;
193 : Real64 pvWattsInverterEfficiency_;
194 :
195 : }; // DCtoACInverter
196 :
197 4 : class ACtoDCConverter
198 : // This class is for modelling a power conversion device that takes AC power in and produces DC power out.
199 :
200 : {
201 :
202 : public: // Methods
203 : // Constructor
204 : ACtoDCConverter(EnergyPlusData &state, std::string const &objectName);
205 :
206 : void simulate(EnergyPlusData &state, Real64 const powerOutFromConverter);
207 :
208 : void reinitAtBeginEnvironment();
209 :
210 : void reinitZoneGainsAtBeginEnvironment();
211 :
212 : Real64 thermLossRate() const;
213 :
214 : Real64 dCPowerOut() const;
215 :
216 : Real64 dCEnergyOut() const;
217 :
218 : Real64 aCPowerIn() const;
219 :
220 : Real64 getLossRateForInputPower(EnergyPlusData &state, Real64 const powerIntoConverter); // AC power going into inverter
221 :
222 : std::string const &name() const;
223 :
224 : private: // methods
225 : void calcEfficiency(EnergyPlusData &state);
226 :
227 : private: // data
228 : enum class ConverterModelType
229 : {
230 : Invalid = -1,
231 : CurveFuncOfPower,
232 : SimpleConstantEff,
233 : Num
234 : };
235 :
236 : std::string name_; // user identifier
237 : Real64 efficiency_;
238 : Real64 aCPowerIn_;
239 : Real64 aCEnergyIn_;
240 : Real64 dCPowerOut_;
241 : Real64 dCEnergyOut_;
242 : Real64 conversionLossPower_;
243 : Real64 conversionLossEnergy_;
244 : Real64 conversionLossEnergyDecrement_;
245 : Real64 thermLossRate_;
246 : Real64 thermLossEnergy_;
247 : Real64 qdotConvZone_;
248 : Real64 qdotRadZone_;
249 : Real64 ancillACuseRate_;
250 : Real64 ancillACuseEnergy_;
251 : int availSchedPtr_; // number for availability schedule.
252 : ConverterModelType modelType_; // type of inverter model used
253 : int curveNum_; // performance curve or table index
254 : ThermalLossDestination heatLossesDestination_;
255 : int zoneNum_; // destination zone for heat losses from inverter.
256 : Real64 zoneRadFract_; // radiative fraction for thermal losses to zone
257 : Real64 standbyPower_;
258 : Real64 maxPower_;
259 : };
260 :
261 8 : class ElectricStorage
262 : // This class is for modeling a device for storing electric power over time.
263 : // This class combines two separate input objects that have different models.
264 : {
265 :
266 : public: // methods
267 : // Constructor
268 : ElectricStorage(EnergyPlusData &state, std::string const &objectName);
269 :
270 : void timeCheckAndUpdate(EnergyPlusData &state);
271 :
272 : void simulate(EnergyPlusData &state,
273 : Real64 &powerCharge,
274 : Real64 &powerDischarge,
275 : bool &charging,
276 : bool &discharging,
277 : Real64 const controlSOCMaxFracLimit,
278 : Real64 const controlSOCMinFracLimit);
279 :
280 : // void calcAndReportSimpleBucketModel();
281 :
282 : // void calcAndReportKineticBatteryModel();
283 :
284 : void reinitAtBeginEnvironment();
285 :
286 : void reinitZoneGainsAtBeginEnvironment();
287 :
288 : void reinitAtEndWarmup();
289 :
290 : Real64 drawnPower() const;
291 :
292 : Real64 storedPower() const;
293 :
294 : Real64 drawnEnergy() const;
295 :
296 : Real64 storedEnergy() const;
297 :
298 : Real64 stateOfChargeFraction() const;
299 :
300 : Real64 batteryTemperature() const;
301 :
302 : bool determineCurrentForBatteryDischarge(EnergyPlusData &state,
303 : Real64 &curI0,
304 : Real64 &curT0,
305 : Real64 &curVolt,
306 : Real64 const Pw,
307 : Real64 const q0,
308 : int const CurveNum,
309 : Real64 const k,
310 : Real64 const c,
311 : Real64 const qmax,
312 : Real64 const E0c,
313 : Real64 const InternalR);
314 :
315 : std::string const &name() const;
316 :
317 : private: // methods
318 : void simulateSimpleBucketModel( // request charge discharge and
319 : EnergyPlusData &state,
320 : Real64 &powerCharge,
321 : Real64 &powerDischarge,
322 : bool &charging,
323 : bool &discharging,
324 : Real64 const controlSOCMaxFracLimit,
325 : Real64 const controlSOCMinFracLimit);
326 :
327 : void simulateKineticBatteryModel(EnergyPlusData &state,
328 : Real64 &powerCharge,
329 : Real64 &powerDischarge,
330 : bool &charging,
331 : bool &discharging,
332 : Real64 const controlSOCMaxFracLimit,
333 : Real64 const controlSOCMinFracLimit);
334 :
335 : void simulateLiIonNmcBatteryModel(EnergyPlusData &state,
336 : Real64 &powerCharge,
337 : Real64 &powerDischarge,
338 : bool &charging,
339 : bool &discharging,
340 : Real64 const controlSOCMaxFracLimit,
341 : Real64 const controlSOCMinFracLimit);
342 :
343 : void rainflow(int const numbin, // numbin = constant value
344 : Real64 const input, // input = input value from other object (battery model)
345 : std::vector<Real64> &B1, // stores values of points, calculated here - stored for next timestep
346 : std::vector<Real64> &X, // stores values of two data point difference, calculated here - stored for next timestep
347 : int &count, // calculated here - stored for next timestep in main loop
348 : std::vector<Real64> &Nmb, // calculated here - stored for next timestep in main loop
349 : std::vector<Real64> &OneNmb // calculated here - stored for next timestep in main loop
350 : // int const dim // end dimension of array
351 : );
352 :
353 : void shift(std::vector<Real64> &A, int const m, int const n, std::vector<Real64> &B
354 : // int const dim // end dimension of arrays
355 : );
356 :
357 : private: // data
358 : enum class StorageModelType
359 : {
360 : Invalid = -1,
361 : SimpleBucketStorage,
362 : KIBaMBattery,
363 : LiIonNmcBattery,
364 : Num
365 : };
366 :
367 : enum class BatteryDegradationModelType
368 : {
369 : Invalid = -1,
370 : LifeCalculationYes,
371 : LifeCalculationNo,
372 : Num
373 : };
374 :
375 : std::string name_; // name of this electrical storage module
376 : Real64 storedPower_; // [W]
377 : Real64 storedEnergy_; // [J]
378 : Real64 drawnPower_; // [W]
379 : Real64 drawnEnergy_; // [J]
380 : Real64 decrementedEnergyStored_; // [J] this is the negative of StoredEnergy
381 : int maxRainflowArrayBounds_;
382 : bool myWarmUpFlag_;
383 : StorageModelType storageModelMode_; // type of model parameter, SimpleBucketStorage
384 : int availSchedPtr_; // availability schedule index.
385 : ThermalLossDestination heatLossesDestination_; // mode for where thermal losses go
386 : int zoneNum_; // destination zone for heat losses from inverter.
387 : Real64 zoneRadFract_; // radiative fraction for thermal losses to zone
388 : Real64 startingEnergyStored_; // [J] joules inside at beginning of environment period
389 : Real64 energeticEfficCharge_; // [ ] efficiency of charging
390 : Real64 energeticEfficDischarge_; // [ ] efficiency of discharging
391 : Real64 maxPowerDraw_; // [W] max rate of discharge
392 : Real64 maxPowerStore_; // [W] max rate of charge
393 : Real64 maxEnergyCapacity_; // [J] max storage capacity
394 : int parallelNum_; // [ ] number of battery modules in parallel
395 : int seriesNum_; // [ ] number of battery modules in series
396 : int numBattery_; // total number of batteries all together
397 : int chargeCurveNum_; // [ ] voltage change curve index number for charging
398 : int dischargeCurveNum_; // [ ] voltage change curve index number for discharging
399 : int cycleBinNum_; // [ ] number of cycle bins
400 : Real64 startingSOC_; // [ ] initial fractional state of charge
401 : Real64 maxAhCapacity_; // [Ah]maximum capacity
402 : Real64 availableFrac_; // [ ] maximum fraction of available charge capacity
403 : Real64 chargeConversionRate_; // [1/h]change rate from bound charge energy to available charge
404 : Real64 chargedOCV_; // [V] fully charged open circuit voltage
405 : Real64 dischargedOCV_; // [V] fully discharged open circuit voltage
406 : Real64 internalR_; // [ohm]internal electric resistance
407 : Real64 maxDischargeI_; // [A] maximum discharging current
408 : Real64 cutoffV_; // [V] cut-off voltage
409 : Real64 maxChargeRate_; // [1/h] charge rate limit
410 : BatteryDegradationModelType lifeCalculation_; // [ ] battery life calculation: Yes or No
411 : int lifeCurveNum_; // [ ] battery life curve name index number
412 : Real64 liIon_dcToDcChargingEff_; // [ ] DC to DC Charging Efficiency (Li-ion NMC model)
413 : Real64 liIon_mass_; // [kg] mass of battery (Li-ion NMC model)
414 : Real64 liIon_surfaceArea_; // [m2] battery surface area (Li-ion NMC model)
415 : Real64 liIon_Cp_; // [J/kg-K] battery specific heat capacity (Li-ion NMC model)
416 : Real64 liIon_heatTransferCoef_; // [W/m2-K] Heat Transfer Coefficient Between Battery and Ambient (Li-ion NMC model)
417 : Real64 liIon_Vfull_; // [V] Fully charged cell voltage (Li-ion NMC model)
418 : Real64 liIon_Vexp_; // [V] Cell Voltage at End of Exponential Zone (Li-ion NMC model)
419 : Real64 liIon_Vnom_; // [V] Cell voltage at end of nominal zone (Li-ion NMC model)
420 : Real64 liIon_Vnom_default_; // [V] Default nominal cell voltage (Li-ion NMC model)
421 : Real64 liIon_Qfull_; // [A-h] Fully charged cell capacity (Li-ion NMC model)
422 : Real64 liIon_Qexp_; // [A-h] Cell capacity at end of exponential zone (Li-ion NMC model)
423 : Real64 liIon_Qnom_; // [A-h] Cell capacity at end of nominal zone (Li-ion NMC model)
424 : Real64 liIon_C_rate_; // [ ] Rate at which voltage vs capacity curve input (Li-ion NMC model)
425 : // calculated and from elsewhere vars
426 : Real64 thisTimeStepStateOfCharge_; // [J]
427 : Real64 lastTimeStepStateOfCharge_; // [J]
428 : Real64 pelNeedFromStorage_; // [W]
429 : Real64 pelFromStorage_; // [W]
430 : Real64 pelIntoStorage_; // [W]
431 : Real64 qdotConvZone_; // [W]
432 : Real64 qdotRadZone_; // [W]
433 : Real64 timeElapsed_; // [h]
434 : Real64 thisTimeStepAvailable_; // [Ah] available charge at the current timestep
435 : Real64 thisTimeStepBound_; // [Ah] bound charge at the current timestep
436 : Real64 lastTimeStepAvailable_; // [Ah] available charge at the previous timestep
437 : Real64 lastTimeStepBound_; // [Ah] bound charge at the previous timestep
438 : Real64 lastTwoTimeStepAvailable_; // [Ah] available charge at the previous two timesteps
439 : Real64 lastTwoTimeStepBound_; // [Ah] bound charge at the previous two timesteps
440 : // Li-ion NMC battery objects from SAM Simulation Core lib_battery
441 : std::unique_ptr<battery_t> ssc_battery_;
442 : std::unique_ptr<battery_state> ssc_lastBatteryState_;
443 : std::unique_ptr<battery_state> ssc_initBatteryState_;
444 : // battery life calculation variables
445 : int count0_;
446 : std::vector<Real64> b10_;
447 : std::vector<Real64> x0_;
448 : std::vector<Real64> nmb0_;
449 : std::vector<Real64> oneNmb0_;
450 : // report
451 : Real64 electEnergyinStorage_; // [J] state of charge
452 : Real64 thermLossRate_; // [W]
453 : Real64 thermLossEnergy_; // [J]
454 : int storageMode_; // [ ] mode of operation 0 for idle, 1 for discharging, 2 for charging
455 : Real64 absoluteSOC_; // [Ah] total state of charge
456 : Real64 fractionSOC_; // [ ] fractional state of charge
457 : Real64 batteryCurrent_; // [A] total current
458 : Real64 batteryVoltage_; // [V] total voltage
459 : Real64 batteryDamage_; // [ ] fractional battery damage
460 : Real64 batteryTemperature_; // [C] battery temperature (only used in Li-ion batteries)
461 :
462 : }; // ElectricStorage
463 :
464 13 : class ElectricTransformer
465 : // This class is for modeling a power conversion device that changes from one voltage to another, or serves as an isolation transformer
466 : {
467 :
468 : public: // methods
469 : // Constructor
470 : ElectricTransformer(EnergyPlusData &state, std::string const &objectName);
471 :
472 : Real64 getLossRateForOutputPower(EnergyPlusData &state, Real64 const powerOutOfTransformer);
473 :
474 : Real64 getLossRateForInputPower(EnergyPlusData &state, Real64 const powerIntoTransformer);
475 :
476 : void manageTransformers(EnergyPlusData &state, Real64 const surplusPowerOutFromLoadCenters);
477 :
478 : void setupMeterIndices(EnergyPlusData &state);
479 :
480 : void reinitAtBeginEnvironment();
481 :
482 : void reinitZoneGainsAtBeginEnvironment();
483 :
484 : std::string const &name() const;
485 :
486 : private: // data
487 : enum class TransformerUse
488 : {
489 : Invalid = -1,
490 : PowerInFromGrid, // condition power from grid going into building buss
491 : PowerOutFromBldgToGrid, // condition power from building buss going out to grid
492 : PowerBetweenLoadCenterAndBldg, // condition power from a load center going into building buss, or from building buss into load center for
493 : // draws
494 : Num
495 : };
496 : enum class TransformerPerformanceInput
497 : {
498 : Invalid = -1,
499 : LossesMethod,
500 : EfficiencyMethod,
501 : Num
502 : };
503 :
504 : std::string name_; // user identifier
505 : bool myOneTimeFlag_;
506 : int availSchedPtr_; // availability schedule index.
507 : TransformerUse usageMode_; // mode for transformer usage
508 : ThermalLossDestination heatLossesDestination_; // mode for where thermal losses go
509 : int zoneNum_; // destination zone for heat losses from inverter.
510 : Real64 zoneRadFrac_; // radiative fraction for thermal losses to zone
511 : Real64 ratedCapacity_; // rated capacity [VA]
512 : int phase_; // phase
513 : Real64 factorTempCoeff_; // thermal coefficient of resistance for winding material
514 : Real64 tempRise_; // full load temperature rise [C]
515 : Real64 eddyFrac_; // fraction of eddy current losses []
516 : TransformerPerformanceInput performanceInputMode_; // performance input method
517 : Real64 ratedEfficiency_; // nameplate efficiency []
518 : Real64 ratedPUL_; // per unit load for nameplate efficiency []
519 : Real64 ratedTemp_; // reference temperature for nameplate efficiency [C]
520 : Real64 maxPUL_; // per unit load for maximum efficiency []
521 : bool considerLosses_; // if true, consider transformer lossses in metering
522 : std::vector<std::string> wiredMeterNames_; // names of the meters wired to transformer
523 : std::vector<int> wiredMeterPtrs_; // array of "pointers" to meters wired to transformer
524 : std::vector<bool> specialMeter_; // indicates whether a meter needs special consideration
525 : // Electricity:Facility and Electricity:HVAC are two special
526 : // meters because tranformer loss is part of them
527 : // calculated and from elsewhere vars
528 : Real64 ratedNL_; // rated no load losses, user input or calculated [W]
529 : Real64 ratedLL_; // rated load losses, user input or calculated [W]
530 : int overloadErrorIndex_; // used for warning message when transformer is overloaded
531 : // results and reporting
532 : Real64 efficiency_; // transformer efficiency
533 : Real64 powerIn_; // [W]
534 : Real64 energyIn_; // [J]
535 : Real64 powerOut_; // [W]
536 : Real64 energyOut_; // [J]
537 : Real64 noLoadLossRate_; // [W]
538 : Real64 noLoadLossEnergy_; // [J]
539 : Real64 loadLossRate_; // [W]
540 : Real64 loadLossEnergy_; // [J]
541 : Real64 totalLossRate_; // [W]
542 : Real64 totalLossEnergy_; // [J]
543 : Real64 thermalLossRate_; // [W]
544 : Real64 thermalLossEnergy_; // [J]
545 : Real64 elecUseMeteredUtilityLosses_; // [J] Energy consumption for a utility transformer (power in)
546 : // Positive values
547 : Real64 powerConversionMeteredLosses_; // [J] Energy consumption for a (cogeneration )transformer (power out from building to grid)
548 : // Negative values
549 : Real64 qdotConvZone_; // [W]
550 : Real64 qdotRadZone_; // [W]
551 : }; // ElectricTransformer
552 :
553 75 : class GeneratorController
554 : // this class is used as part of the supervisory control and calling of electric power generators. Each instances is for one generator
555 : {
556 :
557 : public: // Method
558 : // Constructor
559 : GeneratorController(EnergyPlusData &state,
560 : std::string const &objectName,
561 : std::string const &objectType,
562 : Real64 ratedElecPowerOutput,
563 : std::string const &availSchedName,
564 : Real64 thermalToElectRatio);
565 :
566 : void simGeneratorGetPowerOutput(EnergyPlusData &state,
567 : bool const runFlag, // true if generator is on
568 : Real64 const myElecLoadRequest, // target electric power production request
569 : bool const FirstHVACIteration, //
570 : Real64 &electricPowerOutput, // Actual generator electric power output
571 : Real64 &thermalPowerOutput // Actual generator thermal power output
572 : );
573 :
574 : void reinitAtBeginEnvironment();
575 :
576 : public: // data // might make this class a friend of ElectPowerLoadCenter?
577 : std::string name; // user identifier
578 : GeneratorType generatorType; // Numeric designator for generator CompType (TypeOf), in DataGlobalConstants
579 : DataPlant::PlantEquipmentType compPlantType{DataPlant::PlantEquipmentType::Invalid}; // numeric designator for plant component, in DataPlant
580 : std::string compPlantName; // name of plant component if heat recovery
581 : int generatorIndex; // index in generator model data struct
582 : Real64 maxPowerOut; // Maximum Power Output (W)
583 : std::string availSched; // Operation Schedule.
584 : int availSchedPtr; // pointer to operation schedule
585 : Real64 powerRequestThisTimestep; // Current Demand on Equipment (W)
586 : bool onThisTimestep; // Indicator whether Generator on
587 : Real64 eMSPowerRequest; // EMS actuator for current demand on equipment (W)
588 : bool eMSRequestOn; // EMS actuating On if true.
589 : bool plantInfoFound;
590 : PlantLocation cogenLocation;
591 : Real64 nominalThermElectRatio; // Cogen: nominal ratio of thermal to elect production
592 : // results of component models for load center reporting
593 : Real64 dCElectricityProd; // Current DC Electric Produced from Equipment (J)
594 : Real64 dCElectProdRate; // Current DC Electric Production Rate from Equipment (W)
595 : Real64 electricityProd; // Current AC Electric Produced from Equipment (J)
596 : Real64 electProdRate; // Current AC Electric Production Rate from Equipment (W)
597 : Real64 thermalProd; // Current Thermal energy Produced from Equipment (J)
598 : Real64 thermProdRate; // Current Thermal energy Production Rate from Equipment (W)
599 :
600 : std::unique_ptr<PVWatts::PVWattsGenerator> pvwattsGenerator; // PVWattsGenerator object pointer
601 :
602 : private:
603 : int errCountNegElectProd_; // error count for reccuring error when generators produce negative electric power
604 :
605 : }; // class GeneratorController
606 :
607 705 : class ElectPowerLoadCenter
608 : // This class if for modeling a load center which can be thought of as a kind of subpanel that connects power equipment to a main panel
609 : // multiple subpanels can be connected to the main panel and each ElectPowerLoadCenter object is a subpanel
610 : // Each load center will contain other power conversion devices and/or generator(s).
611 : {
612 :
613 : public: // Methods
614 : // Constructor
615 : ElectPowerLoadCenter(EnergyPlusData &state, int const objectNum);
616 :
617 : void manageElecLoadCenter(EnergyPlusData &state, bool const firstHVACIteration, Real64 &remainingPowerDemand);
618 :
619 : void setupLoadCenterMeterIndices(EnergyPlusData &state);
620 :
621 : void reinitAtBeginEnvironment();
622 :
623 : void reinitZoneGainsAtBeginEnvironment();
624 :
625 : std::string const &transformerName() const;
626 :
627 : std::string const &generatorListName() const;
628 :
629 : void updateLoadCenterGeneratorRecords(EnergyPlusData &state);
630 :
631 : private: // Methods
632 : void dispatchGenerators(EnergyPlusData &state, bool const firstHVACIteration, Real64 &remainingPowerDemand);
633 :
634 : void dispatchStorage(EnergyPlusData &state, Real64 const remainingPowerDemand);
635 :
636 : Real64 calcLoadCenterThermalLoad(EnergyPlusData &state); // returns heat rate called for from cogenerator(watts)
637 :
638 : public: // data public for unit test
639 : enum class ElectricBussType
640 : {
641 : Invalid = -1,
642 : ACBuss,
643 : DCBussInverter,
644 : ACBussStorage,
645 : DCBussInverterDCStorage,
646 : DCBussInverterACStorage,
647 : Num
648 : };
649 :
650 : std::unique_ptr<ElectricStorage> storageObj;
651 : std::unique_ptr<ACtoDCConverter> converterObj;
652 : std::unique_ptr<ElectricTransformer> transformerObj;
653 : int numGenerators; // Number of Generators
654 : std::vector<std::unique_ptr<GeneratorController>> elecGenCntrlObj; // generator controller objects
655 : ElectricBussType bussType; // is this load center powered by AC or DC generators
656 : Real64 thermalProd; // Current thermal energy Produced from generators in load center (J)
657 : Real64 thermalProdRate; // Current thermal energy production rate from generators in load center (W)
658 : bool inverterPresent;
659 : std::string inverterName; // hold name for verificaton and error messages
660 : std::unique_ptr<DCtoACInverter> inverterObj;
661 : Real64 subpanelFeedInRequest;
662 : // subpanel terms, interact with main panel
663 : Real64 subpanelFeedInRate; // Current AC electric power fed into main panel by load center, adjusted by inverter if any (W)
664 : Real64 subpanelDrawRate; // Current AC electric power draw from main panel into load center (W)
665 : // storage operation terms,
666 : Real64 genElectricProd; // Current electric produced by generators in the load center, DC or AC (J)
667 : Real64 genElectProdRate; // Current electric power produced by generators in the load center, DC or AC (W)
668 : Real64 storOpCVGenRate; // power from generators (and maybe inverter) going into storage operation control volume, DC or AC ( W )
669 : Real64 storOpCVDrawRate; // power drawn from main panel into storage operation control volume after any converter, DC or AC ( W )
670 : Real64 storOpCVFeedInRate; // power fed toward main panel from storage operation control volume before any inverter, DC or AC ( W )
671 : Real64 storOpCVChargeRate; // power fed into storage device from storage operation control volume, before any storage losses, DC or AC ( W )
672 : Real64 storOpCVDischargeRate; // power drawn from storage device into storage operation control volume, after any storage losses, DC or AC ( W )
673 : bool storOpIsCharging; // true if storage operation scheme is trying to charge
674 : bool storOpIsDischarging; // true if storage operation scheme is trying to discharge
675 :
676 : private: // data
677 : enum class GeneratorOpScheme : int
678 : {
679 : Invalid = -1,
680 : BaseLoad,
681 : DemandLimit,
682 : TrackElectrical,
683 : TrackSchedule,
684 : TrackMeter,
685 : ThermalFollow,
686 : ThermalFollowLimitElectrical,
687 : Num
688 : };
689 :
690 : enum class StorageOpScheme : int
691 : {
692 : Invalid = -1,
693 : FacilityDemandStoreExcessOnSite, // legacy control behavior
694 : MeterDemandStoreExcessOnSite,
695 : ChargeDischargeSchedules,
696 : FacilityDemandLeveling,
697 : Num
698 : };
699 :
700 : std::string name_; // user identifier
701 : std::string generatorListName_; // List name of available generators
702 : GeneratorOpScheme genOperationScheme_; // Name of Operation Scheme
703 : std::string demandMeterName_; // Name of Demand Energy Meter for "on demand" operation
704 : int demandMeterPtr_; // "pointer" to Meter for electrical Demand to meet
705 : std::string generationMeterName_; // Name of Generated Energy Meter for "on demand" operation
706 : bool generatorsPresent_; // true if any generators
707 : bool myCoGenSetupFlag_;
708 : Real64 demandLimit_; // Demand Limit in Watts(W) which the generator will operate above
709 : int trackSchedPtr_; // "pointer" to schedule for electrical demand to meet.
710 : Real64 dCElectricityProd_; // Current DC Elect produced (J) (if buss type DCbussInverter)
711 : Real64 dCElectProdRate_; // Current DC Elect power produced (W) (if buss type DCbussInverter)
712 : Real64 dCpowerConditionLosses_; // current DC to AC inverter losses (W) (if DCbussInverter)
713 : bool storagePresent_;
714 : std::string storageName_; // hold name for verificaton and error messages
715 : bool transformerPresent_; // should only be transformers for on-site load center, not facility service
716 : std::string transformerName_; // hold name for verificaton and error messages
717 : Real64 totalPowerRequest_; // Total electric power request from the load center (W)
718 : Real64 totalThermalPowerRequest_; // Total thermal power request from the load center (W)
719 : StorageOpScheme storageScheme_; // what options are available for charging storage.
720 : std::string trackSorageOpMeterName_; // user name for a specific meter
721 : int trackStorageOpMeterIndex_; // points to meter being
722 : bool converterPresent_;
723 : std::string converterName_;
724 : Real64 maxStorageSOCFraction_; // Fraction of storage capacity used as upper limit for controlling charging (don't overcharge the batteries)
725 : Real64 minStorageSOCFraction_; // Fraction of storage capacity used as lower limit for controlling discharging (dont drain the batteries too far)
726 : Real64 designStorageChargePower_; // rate of electric power drawn from grid to go into storage
727 : bool designStorageChargePowerWasSet_; // true if a value was input
728 : Real64 designStorageDischargePower_; // rate of electric power exported to grid by being drawn from storage
729 : bool designStorageDischargePowerWasSet_; // true if value was input
730 : int storageChargeModSchedIndex_; // index of fraction schedule for controlling charge rate over time
731 : int storageDischargeModSchedIndex_; // index of fraction schedule for controlling discharge rate over time.
732 : Real64 facilityDemandTarget_; // target utility demand level in Watts
733 : int facilityDemandTargetModSchedIndex_; // index of fracton schedule for controlling target demand over time.
734 : bool eMSOverridePelFromStorage_; // if true, EMS calling for override
735 : Real64 eMSValuePelFromStorage_; // value EMS is directing to use, power from storage [W]
736 : bool eMSOverridePelIntoStorage_; // if true, EMS calling for override
737 : Real64 eMSValuePelIntoStorage_; // value EMS is directing to use, power into storage [W]
738 :
739 : }; // class ElectPowerLoadCenter
740 :
741 771 : class ElectricPowerServiceManager //
742 : // This class if the top level object for modeling complex electric power service. It contains transformers and/or
743 : // load center(s).
744 : {
745 :
746 : public: // Creation
747 : // Default Constructor
748 771 : ElectricPowerServiceManager()
749 771 : : newEnvironmentInternalGainsFlag(true), numElecStorageDevices(0), getInputFlag_(true), newEnvironmentFlag_(true), numLoadCenters_(0),
750 : numTransformers_(0), setupMeterIndexFlag_(true), elecFacilityIndex_(0), elecProducedCoGenIndex_(0), elecProducedPVIndex_(0),
751 : elecProducedWTIndex_(0), elecProducedStorageIndex_(0), elecProducedPowerConversionIndex_(0), name_("Whole Building"),
752 : facilityPowerInTransformerPresent_(false), numPowerOutTransformers_(0), wholeBldgRemainingLoad_(0.0), electricityProd_(0.0),
753 : electProdRate_(0.0), electricityPurch_(0.0), electPurchRate_(0.0), electSurplusRate_(0.0), electricitySurplus_(0.0),
754 : electricityNetRate_(0.0), electricityNet_(0.0), totalBldgElecDemand_(0.0), totalHVACElecDemand_(0.0), totalElectricDemand_(0.0),
755 : elecProducedPVRate_(0.0), elecProducedWTRate_(0.0), elecProducedStorageRate_(0.0), elecProducedPowerConversionRate_(0.0),
756 771 : elecProducedCoGenRate_(0.0)
757 : {
758 771 : }
759 :
760 : public: // Methods
761 : void manageElectricPowerService(EnergyPlusData &state,
762 : bool const FirstHVACIteration,
763 : bool &SimElecCircuits, // simulation convergence flag
764 : bool const UpdateMetersOnly // if true then don't resimulate generators, just update meters.
765 : );
766 :
767 : void reinitZoneGainsAtBeginEnvironment();
768 :
769 : void verifyCustomMetersElecPowerMgr(EnergyPlusData &state);
770 :
771 : private: // Methods
772 : void getPowerManagerInput(EnergyPlusData &state);
773 :
774 : void setupMeterIndices(EnergyPlusData &state);
775 :
776 : void reinitAtBeginEnvironment();
777 :
778 : void updateWholeBuildingRecords(EnergyPlusData &state);
779 :
780 : void reportPVandWindCapacity(EnergyPlusData &state);
781 :
782 : void sumUpNumberOfStorageDevices();
783 :
784 : void checkLoadCenters(EnergyPlusData &state);
785 :
786 : public: // data
787 : bool newEnvironmentInternalGainsFlag;
788 : int numElecStorageDevices;
789 : std::vector<std::unique_ptr<ElectPowerLoadCenter>> elecLoadCenterObjs;
790 :
791 : private: // data
792 : bool getInputFlag_; // control if object needs to get input and call factory methods
793 : bool newEnvironmentFlag_; // control if object needs to reinit at beginning of a new environment period
794 : int numLoadCenters_;
795 : int numTransformers_;
796 : bool setupMeterIndexFlag_; // control if object needs to make calls to GetMeterIndex
797 : int elecFacilityIndex_;
798 : int elecProducedCoGenIndex_;
799 : int elecProducedPVIndex_;
800 : int elecProducedWTIndex_;
801 : int elecProducedStorageIndex_;
802 : int elecProducedPowerConversionIndex_;
803 : std::string name_;
804 : bool facilityPowerInTransformerPresent_;
805 : std::string facilityPowerInTransformerName_; // hold name for verificaton and error messages
806 : std::unique_ptr<ElectricTransformer> facilityPowerInTransformerObj_;
807 : int numPowerOutTransformers_;
808 : std::string powerOutTransformerName_;
809 : std::unique_ptr<ElectricTransformer> powerOutTransformerObj_;
810 : Real64 wholeBldgRemainingLoad_;
811 : Real64 electricityProd_; // Current Electric Produced from Equipment (J)
812 : Real64 electProdRate_; // Current Electric Production Rate from Equipment (W)
813 : Real64 electricityPurch_; // Current Purchased Electric (J)
814 : Real64 electPurchRate_; // Current Electric Purhcased Rate (W)
815 : Real64 electSurplusRate_; // Current excess power (W)
816 : Real64 electricitySurplus_; // Current excess energy (J)
817 : Real64 electricityNetRate_; // Net elect rate, + is Purchased, - is Surplus (W)
818 : Real64 electricityNet_; // Net energy, + is Purchased, - is Surplus (J)
819 : Real64 totalBldgElecDemand_; // Current Total Building Electric Demand (W)
820 : Real64 totalHVACElecDemand_; // Current Total HVAC Electric Demand (W)
821 : Real64 totalElectricDemand_; // Current Total Electric Demand (W)
822 : Real64 elecProducedPVRate_; // Current Rate of PV Produced from the Arrays (W)
823 : Real64 elecProducedWTRate_; // Current Rate of Wind Turbine Produced (W)
824 : Real64 elecProducedStorageRate_; // Current Rate of power to(-)/from(+) storage
825 : Real64 elecProducedPowerConversionRate_; // Current rate of power loss from power conversion, negative (W)
826 : Real64 elecProducedCoGenRate_; // Current Rate of Cogeneration generators produced ( W )
827 : Real64 pvTotalCapacity_; // for LEED report, total installed PV capacity
828 : Real64 windTotalCapacity_; // for LEED report, total installed wind capacity
829 :
830 : }; // class ElectricPowerServiceManager
831 :
832 : void createFacilityElectricPowerServiceObject(EnergyPlusData &state);
833 :
834 : Real64 checkUserEfficiencyInput(EnergyPlusData &state, Real64 userInputValue, std::string whichType, std::string deviceName, bool &errorsFound);
835 :
836 1542 : struct ElectPwrSvcMgrData : BaseGlobalStruct
837 : {
838 :
839 : std::unique_ptr<ElectricPowerServiceManager> facilityElectricServiceObj;
840 :
841 0 : void clear_state() override
842 : {
843 0 : this->facilityElectricServiceObj.release();
844 0 : }
845 : };
846 :
847 : } // namespace EnergyPlus
848 : #endif // ElectricPowerServiceManager_hh_INCLUDED
|