Line data Source code
1 : // EnergyPlus, Copyright (c) 1996-2024, 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 OutputProcessor_hh_INCLUDED
49 : #define OutputProcessor_hh_INCLUDED
50 :
51 : // C++ Headers
52 : #include <array>
53 : #include <iosfwd>
54 : #include <map>
55 :
56 : // ObjexxFCL Headers
57 : #include <ObjexxFCL/Array1D.hh>
58 : #include <ObjexxFCL/Array2D.hh>
59 :
60 : // EnergyPlus Headers
61 : #include <EnergyPlus/Data/BaseData.hh>
62 : #include <EnergyPlus/DataGlobals.hh>
63 : #include <EnergyPlus/DisplayRoutines.hh>
64 : #include <EnergyPlus/EPVector.hh>
65 : #include <EnergyPlus/EnergyPlus.hh>
66 :
67 : // Third party Headers
68 : #include "re2/re2.h"
69 :
70 : namespace EnergyPlus {
71 :
72 : // Forward declarations
73 : class InputOutputFile;
74 : struct EnergyPlusData;
75 :
76 : namespace OutputProcessor {
77 :
78 : enum class ReportVDD
79 : {
80 : Invalid = -1,
81 : No, // Don't report the variable dictionaries in any form
82 : Yes, // Report the variable dictionaries in "report format"
83 : IDF, // Report the variable dictionaries in "IDF format"
84 : Num
85 : };
86 :
87 : constexpr Real64 MinSetValue(99999999999999.0);
88 : constexpr Real64 MaxSetValue(-99999999999999.0);
89 : constexpr int IMinSetValue(999999);
90 : constexpr int IMaxSetValue(-999999);
91 :
92 : enum class VariableType
93 : {
94 : Invalid = -1,
95 : // NotFound, // ref: GetVariableKeyCountandType, 0 = not found // TODO: This is actually used separately from Invalid, need to get rid of it
96 : Integer, // ref: GetVariableKeyCountandType, 1 = integer
97 : Real, // ref: GetVariableKeyCountandType, 2 = real
98 : Meter, // ref: GetVariableKeyCountandType, 3 = meter
99 : Schedule, // ref: GetVariableKeyCountandType, 4 = schedule
100 : Num
101 : };
102 :
103 : enum class MeterType
104 : {
105 : Invalid = -1,
106 : Normal, // Type value for normal meters
107 : Custom, // Type value for custom meters
108 : CustomDec, // Type value for custom meters that decrement another meter
109 : CustomDiff, // Type value for custom meters that difference another meter
110 : Num
111 : };
112 :
113 : constexpr int N_WriteTimeStampFormatData(100);
114 :
115 : // For IP Units (tabular reports) certain resources will be put in sub-tables
116 : enum class RT_IPUnits
117 : {
118 : Invalid = -1,
119 : OtherJ,
120 : Electricity,
121 : Gas,
122 : Cooling,
123 : Water,
124 : OtherKG,
125 : OtherM3,
126 : OtherL,
127 : Num
128 : };
129 :
130 : enum class ReportFreq
131 : {
132 : Invalid = -1,
133 : EachCall, // Write out each time UpdatedataandReport is called
134 : TimeStep, // Write out at 'EndTimeStepFlag'
135 : Hour, // Write out at 'EndHourFlag'
136 : Day, // Write out at 'EndDayFlag'
137 : Month, // Write out at end of month (must be determined)
138 : Simulation, // Write out once per environment 'EndEnvrnFlag'
139 : Year, // Write out at 'EndYearFlag'
140 : Num
141 : };
142 :
143 : static constexpr std::array<std::string_view, (int)ReportFreq::Num> reportFreqNames = {
144 : "Each Call", // EachCall
145 : "TimeStep", // TimeStep
146 : "Hourly", // Hourly
147 : "Daily", // Daily
148 : "Monthly", // Monthly
149 : "RunPeriod", // Simulation
150 : "Annual" // Yearly
151 : };
152 :
153 : static constexpr std::array<std::string_view, (int)ReportFreq::Num> reportFreqNamesUC = {
154 : "EACH CALL", // EachCall
155 : "TIMESTEP", // TimeStep
156 : "HOURLY", // Hourly
157 : "DAILY", // Daily
158 : "MONTHLY", // Monthly
159 : "RUNPERIOD", // Simulation
160 : "ANNUAL" // Yearly
161 : };
162 :
163 : // What is this thing?
164 : constexpr std::array<int, (int)ReportFreq::Num> reportFreqArbitraryInts = {1, 1, 1, 7, 9, 11, 11};
165 :
166 : enum class StoreType
167 : {
168 : Invalid = -1,
169 : Average, // Type value for "averaged" variables // TODO: is this just for printing annual tables
170 : Sum, // Type value for "summed" variables
171 : Num
172 : };
173 :
174 : constexpr std::array<std::string_view, (int)StoreType::Num> storeTypeNames = {
175 : // "UNUSED",
176 : "Average", // Averaged
177 : "Sum" // Summed
178 : };
179 :
180 : enum class TimeStepType
181 : {
182 : Invalid = -1,
183 : Zone, // Type value for "zone" timestep variables // TODO: is this just for printing Annual tables?
184 : System, // Type value for "system" timestep variables
185 : Num
186 : };
187 :
188 : constexpr std::array<std::string_view, (int)TimeStepType::Num> timeStepTypeNames = {
189 : // "UNUSED",
190 : "Zone", // Zone
191 : "System" // System
192 : };
193 :
194 : enum class EndUseCat
195 : {
196 : Invalid = -1,
197 : Heating,
198 : Cooling,
199 : InteriorLights,
200 : ExteriorLights,
201 : InteriorEquipment,
202 : ExteriorEquipment,
203 : Fans,
204 : Pumps,
205 : HeatRejection,
206 : Humidification,
207 : HeatRecovery,
208 : WaterSystem,
209 : Refrigeration,
210 : Cogeneration,
211 : Baseboard,
212 : Boilers,
213 : CarbonEquivalentEmissions,
214 : Chillers,
215 : CoalEmissions,
216 : ColdStorageCharge,
217 : ColdStorageDischarge,
218 : Condensate,
219 : CoolingCoils,
220 : CoolingPanel,
221 : DieselEmissions,
222 : DistrictChilledWater,
223 : DistrictHotWater,
224 : ElectricityEmissions,
225 : ElectricStorage,
226 : FreeCooling,
227 : FuelOilNo1Emissions,
228 : FuelOilNo2Emissions,
229 : GasolineEmissions,
230 : HeatingCoils,
231 : HeatProduced,
232 : HeatRecoveryForCooling,
233 : HeatRecoveryForHeating,
234 : LoopToLoop,
235 : MainsWater,
236 : NaturalGasEmissions,
237 : OtherFuel1Emissions,
238 : OtherFuel2Emissions,
239 : Photovoltaic,
240 : PowerConversion,
241 : PropaneEmissions,
242 : PurchasedElectricityEmissions,
243 : RainWater,
244 : SoldElectricityEmissions,
245 : WellWater,
246 : WindTurbine,
247 : Num
248 : };
249 :
250 : static constexpr std::array<std::string_view, (int)EndUseCat::Num> endUseCatNames = {"Heating",
251 : "Cooling",
252 : "InteriorLights",
253 : "ExteriorLights",
254 : "InteriorEquipment",
255 : "ExteriorEquipment",
256 : "Fans",
257 : "Pumps",
258 : "HeatRejection",
259 : "Humidifier",
260 : "HeatRecovery",
261 : "WaterSystems",
262 : "Refrigeration",
263 : "Cogeneration",
264 : "Baseboard",
265 : "Boilers",
266 : "CarbonEquivalentEmissions",
267 : "Chillers",
268 : "CoalEmissions",
269 : "ColdStorageCharge",
270 : "ColdStorageDischarge",
271 : "Condensate",
272 : "CoolingCoils",
273 : "CoolingPanel",
274 : "DieselEmissions",
275 : "DistrictChilledWater",
276 : "DistrictHotWater",
277 : "ElectricityEmissions",
278 : "ElectricStorage",
279 : "FreeCooling",
280 : "FuelOilNo1Emissions",
281 : "FuelOilNo2Emissions",
282 : "GasolineEmissions",
283 : "HeatingCoils",
284 : "HeatProduced",
285 : "HeatRecoveryForCooling",
286 : "HeatRecoveryForHeating",
287 : "LoopToLoop",
288 : "MainsWater",
289 : "NaturalGasEmissions",
290 : "OtherFuel1Emissions",
291 : "OtherFuel2Emissions",
292 : "Photovoltaic",
293 : "PowerConversion",
294 : "PropaneEmissions",
295 : "PurchasedElectricityEmissions",
296 : "RainWater",
297 : "SoldElectricityEmissions",
298 : "WellWater",
299 : "WindTurbine"};
300 :
301 : static constexpr std::array<std::string_view, (int)EndUseCat::Num> endUseCatNamesUC = {"HEATING",
302 : "COOLING",
303 : "INTERIORLIGHTS",
304 : "EXTERIORLIGHTS",
305 : "INTERIOREQUIPMENT",
306 : "EXTERIOREQUIPMENT",
307 : "FANS",
308 : "PUMPS",
309 : "HEATREJECTION",
310 : "HUMIDIFIER",
311 : "HEATRECOVERY",
312 : "WATERSYSTEMS",
313 : "REFRIGERATION",
314 : "COGENERATION",
315 : "BASEBOARD",
316 : "BOILERS",
317 : "CARBONEQUIVALENTEMISSIONS",
318 : "CHILLERS",
319 : "COALEMISSIONS",
320 : "COLDSTORAGECHARGE",
321 : "COLDSTORAGEDISCHARGE",
322 : "CONDENSATE",
323 : "COOLINGCOILS",
324 : "COOLINGPANEL",
325 : "DIESELEMISSIONS",
326 : "DISTRICTCHILLEDWATER",
327 : "DISTRICTHOTWATER",
328 : "ELECTRICITYEMISSIONS",
329 : "ELECTRICSTORAGE",
330 : "FREECOOLING",
331 : "FUELOILNO1EMISSIONS",
332 : "FUELOILNO2EMISSIONS",
333 : "GASOLINEEMISSIONS",
334 : "HEATINGCOILS",
335 : "HEATPRODUCED",
336 : "HEATRECOVERYFORCOOLING",
337 : "HEATRECOVERYFORHEATING",
338 : "LOOPTOLOOP",
339 : "MAINSWATER",
340 : "NATURALGASEMISSIONS",
341 : "OTHERFUEL1EMISSIONS",
342 : "OTHERFUEL2EMISSIONS",
343 : "PHOTOVOLTAIC",
344 : "POWERCONVERSION",
345 : "PROPANEEMISSIONS",
346 : "PURCHASEDELECTRICITYEMISSIONS",
347 : "RAINWATER",
348 : "SOLDELECTRICITYEMISSIONS",
349 : "WELLWATER",
350 : "WINDTURBINE"};
351 :
352 : static constexpr std::array<Constant::EndUse, (int)EndUseCat::Num> endUseCat2endUse = {
353 : Constant::EndUse::Heating, // Heating
354 : Constant::EndUse::Cooling, // Cooling
355 : Constant::EndUse::InteriorLights, // InteriorLights
356 : Constant::EndUse::ExteriorLights, // ExteriorLights
357 : Constant::EndUse::InteriorEquipment, // InteriorEquipment
358 : Constant::EndUse::ExteriorEquipment, // ExteriorEquipment
359 : Constant::EndUse::Fans, // Fans
360 : Constant::EndUse::Pumps, // Pumps
361 : Constant::EndUse::HeatRejection, // HeatRejection
362 : Constant::EndUse::Humidification, // Humidification
363 : Constant::EndUse::HeatRecovery, // HeatRecovery
364 : Constant::EndUse::WaterSystem, // WaterSystem
365 : Constant::EndUse::Refrigeration, // Refrigeration
366 : Constant::EndUse::Cogeneration, // Cogeneration
367 : Constant::EndUse::Invalid, // Baseboard
368 : Constant::EndUse::Invalid, // Boilers
369 : Constant::EndUse::Invalid, // CarbonEquivalentEmissions
370 : Constant::EndUse::Invalid, // Chillers
371 : Constant::EndUse::Invalid, // CoalEmissions
372 : Constant::EndUse::Invalid, // ColdStorageCharge
373 : Constant::EndUse::Invalid, // ColdStorageDischarge
374 : Constant::EndUse::Invalid, // Condensate
375 : Constant::EndUse::Invalid, // CoolingCoils
376 : Constant::EndUse::Invalid, // CoolingPanel
377 : Constant::EndUse::Invalid, // DieselEmissions
378 : Constant::EndUse::Invalid, // DistrictChilledWater
379 : Constant::EndUse::Invalid, // DistrictHotWater
380 : Constant::EndUse::Invalid, // ElectricityEmissions
381 : Constant::EndUse::Invalid, // ElectricStorage
382 : Constant::EndUse::Invalid, // FreeCooling
383 : Constant::EndUse::Invalid, // FuelOilNo1Emissions
384 : Constant::EndUse::Invalid, // FuelOilNo2Emissions
385 : Constant::EndUse::Invalid, // GasolineEmissions
386 : Constant::EndUse::Invalid, // HeatingCoils
387 : Constant::EndUse::Invalid, // HeatProduced
388 : Constant::EndUse::Invalid, // HeatRecoveryForCooling
389 : Constant::EndUse::Invalid, // HeatRecoveryForHeating
390 : Constant::EndUse::Invalid, // LoopToLoop
391 : Constant::EndUse::Invalid, // MainsWater
392 : Constant::EndUse::Invalid, // NaturalGasEmissions
393 : Constant::EndUse::Invalid, // OtherFuel1Emissions
394 : Constant::EndUse::Invalid, // OtherFuel2Emissions
395 : Constant::EndUse::Invalid, // Photovoltaic
396 : Constant::EndUse::Invalid, // PowerConversion
397 : Constant::EndUse::Invalid, // PropaneEmissions
398 : Constant::EndUse::Invalid, // PurchasedElectricityEmissions
399 : Constant::EndUse::Invalid, // RainWater
400 : Constant::EndUse::Invalid, // SoldElectricityEmissions
401 : Constant::EndUse::Invalid, // WellWater,
402 : Constant::EndUse::Invalid, // WindTurbine,
403 : };
404 :
405 : enum class Group
406 : {
407 : Invalid = -1,
408 : Building,
409 : HVAC,
410 : Plant,
411 : Zone,
412 : SpaceType,
413 : Num
414 : };
415 :
416 : static constexpr std::array<std::string_view, (int)Group::Num> groupNames = {"Building", "HVAC", "Plant", "Zone", "SpaceType"};
417 : static constexpr std::array<std::string_view, (int)Group::Num> groupNamesUC = {"BUILDING", "HVAC", "PLANT", "ZONE", "SPACETYPE"};
418 :
419 : struct TimeSteps
420 : {
421 : Real64 *TimeStep = nullptr; // Pointer to the Actual Time Step Variable (Zone or HVAC)
422 : Real64 CurMinute = 0.0; // Current minute (decoded from real Time Step Value)
423 : };
424 :
425 : struct OutVar
426 : {
427 : int ddVarNum = -1;
428 : VariableType varType = VariableType::Invalid;
429 : TimeStepType timeStepType = TimeStepType::Zone; // Zone or System
430 : StoreType storeType = StoreType::Average; // Variable Type (Summed/Non-Static or Average/Static)
431 : Real64 Value = 0.0; // Current Value of the variable (to resolution of Zone Time Step)
432 : Real64 TSValue = 0.0; // Value of this variable at the Zone Time Step
433 : Real64 EITSValue = 0.0; // Value of this variable at the Zone Time Step for external interface
434 : Real64 StoreValue = 0.0; // At end of Zone Time Step, value is placed here for later reporting
435 : Real64 NumStored = 0.0; // Number of hours stored
436 : bool Stored = false; // True when value is stored
437 : bool Report = false; // User has requested reporting of this variable in the IDF
438 : bool tsStored = false; // if stored for this zone timestep
439 : bool thisTSStored = false; // if stored for this zone timestep
440 : int thisTSCount = 0;
441 : ReportFreq freq = ReportFreq::Hour; // How often to report this variable
442 : Real64 MaxValue = -9999.0; // Maximum reporting (only for Averaged variables, and those greater than Time Step)
443 : Real64 MinValue = 9999.0; // Minimum reporting (only for Averaged variables, and those greater than Time Step)
444 : int maxValueDate = 0; // Date stamp of maximum
445 : int minValueDate = 0; // Date stamp of minimum
446 : int ReportID = 0; // Report variable ID number
447 : int SchedPtr = 0; // If scheduled, this points to the schedule
448 : int ZoneMult = 1; // If metered, Zone Multiplier is applied
449 : int ZoneListMult = 1; // If metered, Zone List Multiplier is applied
450 :
451 : std::string keyColonName = ""; // Name of Variable key:variable
452 : std::string keyColonNameUC = ""; // Name of Variable (Uppercase)
453 : std::string name = ""; // Name of Variable
454 : std::string nameUC = ""; // Name of Variable with out key in uppercase
455 : std::string key = ""; // Name of key only
456 : std::string keyUC = ""; // Name of key only witht out variable in uppercase
457 :
458 : Constant::Units units = Constant::Units::Invalid; // Units for Variable
459 : std::string unitNameCustomEMS; // name of units when customEMS is used for EMS variables that are unusual
460 :
461 : std::string indexGroup = "";
462 : int indexGroupKey = -1; // Is this thing even used?
463 :
464 : std::vector<int> meterNums; // Meter Numbers
465 :
466 0 : virtual ~OutVar(){};
467 :
468 : std::string multiplierString() const;
469 :
470 : void writeReportData(EnergyPlusData &state);
471 :
472 : void writeOutput(EnergyPlusData &state, // Real variable to write out
473 : ReportFreq const freq);
474 :
475 : void writeReportDictionaryItem(EnergyPlusData &state);
476 : };
477 :
478 : struct OutVarReal : public OutVar
479 : {
480 : Real64 *Which = nullptr; // Pointer to the actual variable holding the value
481 :
482 176417 : OutVarReal()
483 176417 : {
484 176417 : varType = VariableType::Real;
485 176417 : }
486 : };
487 :
488 : struct OutVarInt : public OutVar
489 : {
490 : // Members
491 : int *Which = nullptr; // The POINTER to the actual variable holding the value
492 :
493 3886 : OutVarInt()
494 3886 : {
495 3886 : varType = VariableType::Integer;
496 3886 : }
497 : };
498 :
499 : struct DDOutVar
500 : {
501 : // Members
502 : std::string name = ""; // Name of Variable
503 : TimeStepType timeStepType = TimeStepType::Invalid; // Type whether Zone or HVAC
504 : StoreType storeType = StoreType::Invalid; // Variable Type (Summed/Non-Static or Average/Static)
505 : VariableType variableType = VariableType::Invalid; // Integer, Real.
506 : int Next = -1; // Next variable of same name (different units)
507 : bool ReportedOnDDFile = false; // true after written to .rdd/.mdd file
508 : Constant::Units units = Constant::Units::Invalid; // Units for Variable
509 : std::string unitNameCustomEMS = ""; // name of units when customEMS is used for EMS variables that are unusual
510 :
511 : std::vector<int> keyOutVarNums;
512 : };
513 :
514 : struct ReqVar // Structure for requested Report Variables
515 : {
516 : // Members
517 : std::string key = ""; // Could be blank or "*"
518 : std::string name = ""; // Name of Variable
519 : ReportFreq freq = ReportFreq::Hour; // Reporting Frequency
520 : int SchedPtr = 0; // Index of the Schedule
521 : std::string SchedName = ""; // Schedule Name
522 : bool Used = false; // True when this combination (key, varname, frequency) has been set
523 :
524 : bool is_simple_string = true; // Whether the Key potentially includes a Regular Expression pattern
525 : std::shared_ptr<RE2> case_insensitive_pattern = nullptr;
526 : };
527 :
528 : struct MeterPeriod
529 : {
530 : Real64 Value = 0.0; // Daily Value
531 : Real64 MaxVal = MaxSetValue; // Maximum Value
532 : int MaxValDate = -1; // Date stamp of maximum
533 : Real64 MinVal = MinSetValue; // Minimum Value
534 : int MinValDate = -1; // Date stamp of minimum
535 :
536 : bool Rpt = false; // Report at End of Day
537 : bool RptFO = false; // Report at End of Day -- meter file only
538 : int RptNum = 0; // Report Number
539 : bool accRpt = false;
540 : bool accRptFO = false;
541 : int accRptNum = 0;
542 :
543 0 : void resetVals()
544 : {
545 0 : Value = 0.0;
546 0 : MaxVal = MaxSetValue;
547 0 : MaxValDate = 0;
548 0 : MinVal = MinSetValue;
549 0 : MinValDate = 0;
550 0 : }
551 :
552 : void WriteReportData(EnergyPlusData &state, ReportFreq freq);
553 : };
554 :
555 : struct Meter
556 : {
557 : // Members
558 : std::string Name = ""; // Name of the meter
559 : MeterType type = MeterType::Invalid; // type of meter
560 : Constant::eResource resource = Constant::eResource::Invalid; // Resource Type of the meter
561 : EndUseCat endUseCat = EndUseCat::Invalid; // End Use of the meter
562 : std::string EndUseSub = ""; // End Use subcategory of the meter
563 : Group group = Group::Invalid; // Group of the meter
564 : Constant::Units units = Constant::Units::Invalid; // Units for the Meter
565 : RT_IPUnits RT_forIPUnits; // Resource type number for IP Units (tabular) reporting
566 :
567 : Real64 CurTSValue = 0.0; // Current TimeStep Value (internal access)
568 :
569 : std::string indexGroup = "";
570 :
571 : std::array<MeterPeriod, (int)ReportFreq::Num> periods;
572 :
573 : MeterPeriod periodLastSM;
574 : MeterPeriod periodFinYrSM;
575 :
576 : std::vector<int> dstMeterNums; // Destination meters for custom meters
577 :
578 : int decMeterNum = -1; // for custom decrement meters, the number of the meter being subtracted from
579 : std::vector<int> srcVarNums; // Source variables for custom meters
580 : std::vector<int> srcMeterNums; // Source meters for custom meters
581 :
582 97318 : Meter(std::string_view name)
583 97318 : {
584 97318 : Name = std::string(name);
585 97318 : }
586 : };
587 :
588 : struct MeteredVar
589 : {
590 : int num = -1;
591 : std::string name = "";
592 : Constant::eResource resource = Constant::eResource::Invalid;
593 : Constant::Units units = Constant::Units::Invalid;
594 : VariableType varType = VariableType::Invalid;
595 : TimeStepType timeStepType = TimeStepType::Invalid;
596 : EndUseCat endUseCat = EndUseCat::Invalid;
597 : Group group = Group::Invalid;
598 : int rptNum = -1;
599 : };
600 :
601 : struct MeterData : MeteredVar
602 : {
603 : Constant::HeatOrCool heatOrCool = Constant::HeatOrCool::NoHeatNoCool;
604 : Real64 curMeterReading = 0.0;
605 :
606 : // C++ doesn't figure this out automatically, so we have to do it ourselves
607 38950 : MeterData &operator=(MeteredVar const &mv)
608 : {
609 38950 : MeteredVar::operator=(mv);
610 38950 : return *this;
611 : }
612 : };
613 :
614 : struct EndUseCategoryType
615 : {
616 : // Members
617 : std::string Name; // End use category name
618 : std::string DisplayName; // Display name for output table
619 : int NumSubcategories = 0;
620 : Array1D_string SubcategoryName; // Array of subcategory names
621 : int numSpaceTypes = 0;
622 : Array1D_string spaceTypeName; // Array of space type names
623 : };
624 :
625 : int DetermineMinuteForReporting(EnergyPlusData &state);
626 :
627 : void InitializeOutput(EnergyPlusData &state);
628 :
629 : void SetupTimePointers(EnergyPlusData &state,
630 : OutputProcessor::TimeStepType timeStepType, // Which timestep is being set up, 'Zone'=1, 'HVAC'=2
631 : Real64 &TimeStep // The timestep variable. Used to get the address
632 : );
633 :
634 : void CheckReportVariable(EnergyPlusData &state,
635 : std::string_view const name, // String Name of variable (without units)
636 : std::string const &key, // Associated Key for this variable
637 : std::vector<int> &reqVarNums);
638 :
639 : void GetReportVariableInput(EnergyPlusData &state);
640 :
641 : ReportFreq determineFrequency(EnergyPlusData &state, std::string_view const FreqString);
642 :
643 : std::string produceDateString(int DateValue, // Date of min/max
644 : ReportFreq freq // Reporting Frequency
645 : );
646 :
647 : // *****************************************************************************
648 : // The following routines implement Energy Meters in EnergyPlus.
649 : // *****************************************************************************
650 :
651 : void GetCustomMeterInput(EnergyPlusData &state, bool &ErrorsFound);
652 :
653 : int AddMeter(EnergyPlusData &state,
654 : std::string const &Name, // Name for the meter
655 : Constant::Units units, // Units for the meter
656 : Constant::eResource resource, // ResourceType for the meter
657 : EndUseCat endUseCat, // EndUse for the meter
658 : std::string_view const EndUseSub, // EndUse subcategory for the meter
659 : Group group, // Group for the meter
660 : int outVarNum);
661 :
662 : void AttachMeters(EnergyPlusData &state,
663 : Constant::Units units, // Units for this meter
664 : Constant::eResource resource, // Electricity, Gas, etc.
665 : EndUseCat endUseCat, // End-use category (Lights, Heating, etc.)
666 : std::string_view const EndUseSub, // End-use subcategory (user-defined, e.g., General Lights, Task Lights, etc.)
667 : Group group, // Group key (Facility, Zone, Building, etc.)
668 : std::string const &ZoneName, // Zone key only applicable for Building group
669 : std::string const &SpaceTypeName, // Space Type key only applicable for Building group
670 : int RepVarNum // Number of this report variable
671 : );
672 :
673 : OutputProcessor::RT_IPUnits GetResourceIPUnits(EnergyPlusData &state,
674 : Constant::eResource resource, // Resource Type
675 : Constant::Units units, // Meter units
676 : bool &ErrorsFound // true if errors found during subroutine
677 : );
678 :
679 : void UpdateMeters(EnergyPlusData &state, int TimeStamp); // Current TimeStamp (for max/min)
680 :
681 : void ReportTSMeters(EnergyPlusData &state,
682 : Real64 StartMinute, // Start Minute for TimeStep
683 : Real64 EndMinute, // End Minute for TimeStep
684 : bool &PrintESOTimeStamp, // True if the ESO Time Stamp also needs to be printed
685 : bool PrintTimeStampToSQL // Print Time Stamp to SQL file
686 : );
687 :
688 : void ReportMeters(EnergyPlusData &state, ReportFreq freq, bool PrintTimeStampToSQL // Print Time Stamp to SQL file
689 : );
690 :
691 : void ReportForTabularReports(EnergyPlusData &state);
692 :
693 : std::string DateToStringWithMonth(int codedDate); // word containing encoded month, day, hour, minute
694 :
695 : void ReportMeterDetails(EnergyPlusData &state);
696 :
697 : // *****************************************************************************
698 : // End of routines for Energy Meters implementation in EnergyPlus.
699 : // *****************************************************************************
700 :
701 : void WriteTimeStampFormatData(EnergyPlusData &state,
702 : InputOutputFile &outputFile,
703 : ReportFreq freq, // Reporting frequency.
704 : int reportID, // The ID of the time stamp
705 : std::string const &DayOfSimChr, // the number of days simulated so far
706 : bool writeToSQL, // write to SQLite
707 : int const Month = -1, // the month of the reporting interval
708 : int const DayOfMonth = -1, // The day of the reporting interval
709 : int const Hour = -1, // The hour of the reporting interval
710 : Real64 const EndMinute = -1.0, // The last minute in the reporting interval
711 : Real64 const StartMinute = -1.0, // The starting minute of the reporting interval
712 : int const DST = -1, // A flag indicating whether daylight savings time is observed
713 : std::string_view const DayType = "" // The day tied for the data (e.g., Monday)
714 : );
715 :
716 : void WriteYearlyTimeStamp(EnergyPlusData &state,
717 : InputOutputFile &outputFile,
718 : int reportID,
719 : std::string const &yearOfSimChr, // the year of the simulation
720 : bool writeToSQL);
721 :
722 : void WriteMeterDictionaryItem(EnergyPlusData &state,
723 : ReportFreq freq, // The reporting interval (e.g., hourly, daily)
724 : StoreType storeType,
725 : int reportID, // The reporting ID in for the variable
726 : std::string const &indexGroup, // The reporting group for the variable
727 : std::string const &meterName, // The variable's meter name
728 : Constant::Units unit, // The variables units
729 : bool cumulativeMeterFlag, // A flag indicating cumulative data
730 : bool meterFileOnlyFlag // A flag indicating whether the data is to be written to standard output
731 : );
732 :
733 : void WriteCumulativeReportMeterData(EnergyPlusData &state,
734 : int reportID, // The variable's report ID
735 : Real64 repValue, // The variable's value
736 : bool meterOnlyFlag // A flag that indicates if the data should be written to standard output
737 : );
738 :
739 : void WriteNumericData(EnergyPlusData &state,
740 : int reportID, // The variable's reporting ID
741 : Real64 repValue // The variable's value
742 : );
743 :
744 : void WriteNumericData(EnergyPlusData &state,
745 : int reportID, // The variable's reporting ID
746 : int32_t repValue // The variable's value
747 : );
748 :
749 : int DetermineIndexGroupKeyFromMeterName(EnergyPlusData &state, std::string const &meterName); // the meter name
750 :
751 : std::string DetermineIndexGroupFromMeterGroup(Meter const *meter); // the meter
752 :
753 : void SetInternalVariableValue(EnergyPlusData &state,
754 : OutputProcessor::VariableType varType, // 1=integer, 2=real, 3=meter
755 : int keyVarIndex, // Array index
756 : Real64 SetRealVal, // real value to set, if type is real or meter
757 : int SetIntVal // integer value to set if type is integer
758 : );
759 :
760 : std::string unitStringFromDDitem(EnergyPlusData &state, int ddItemPtr // index provided for DDVariableTypes
761 : );
762 :
763 : struct APIOutputVariableRequest
764 : {
765 : std::string varName;
766 : std::string varKey;
767 : };
768 :
769 : std::string standardizeEndUseSub(EndUseCat endUseCat, std::string_view const endUseSubCat);
770 : void addEndUseSubcategory(EnergyPlusData &state, EndUseCat endUseCat, std::string_view const endUseSubCat);
771 : void addEndUseSpaceType(EnergyPlusData &state, EndUseCat endUseCat, std::string_view const endUseSpTypeName);
772 : } // namespace OutputProcessor
773 :
774 : //==============================================================================================
775 : // *****************************************************************************
776 : // These routines are available outside the OutputProcessor Module (i.e. calling
777 : // routines do not have to "USE OutputProcessor". But each of these routines
778 : // will use the OutputProcessor and take advantage that everything is PUBLIC
779 : // within the OutputProcessor.
780 : // *****************************************************************************
781 :
782 : void SetupOutputVariable(
783 : EnergyPlusData &state,
784 : std::string_view const name, // String Name of variable (with units)
785 : Constant::Units units, // Actual units corresponding to the actual variable
786 : Real64 &ActualVariable, // Actual Variable, used to set up pointer
787 : OutputProcessor::TimeStepType timeStepType, // Zone, HeatBalance=1, HVAC, System, Plant=2
788 : OutputProcessor::StoreType variableType, // State, Average=1, NonState, Sum=2
789 : std::string const &key, // Associated Key for this variable
790 : Constant::eResource resource = Constant::eResource::Invalid, // Meter Resource Type (Electricity, Gas, etc)
791 : OutputProcessor::Group group = OutputProcessor::Group::Invalid, // Meter Super Group Key (Building, System, Plant)
792 : OutputProcessor::EndUseCat endUseCat = OutputProcessor::EndUseCat::Invalid, // Meter End Use Key (Lights, Heating, etc)
793 : std::string_view const endUseSub = {}, // Meter End Use Sub Key (General Lights, Task Lights, etc)
794 : std::string const &zone = {}, // Meter Zone Key (zone name)
795 : int const zoneMult = 1, // Zone Multiplier, defaults to 1
796 : int const zoneListMult = 1, // Zone List Multiplier, defaults to 1
797 : std::string const &spaceType = {}, // Space type (applicable for Building group only)
798 : int const indexGroupKey = -999, // Group identifier for SQL output
799 : std::string_view const customUnitName = {}, // the custom name for the units from EMS definition of units
800 : OutputProcessor::ReportFreq reportFreq = OutputProcessor::ReportFreq::Hour // Internal use -- causes reporting at this freqency
801 : );
802 :
803 : void SetupOutputVariable(EnergyPlusData &state,
804 : std::string_view const VariableName, // String Name of variable
805 : Constant::Units VariableUnit, // Actual units corresponding to the actual variable
806 : int &ActualVariable, // Actual Variable, used to set up pointer
807 : OutputProcessor::TimeStepType TimeStepType, // Zone, HeatBalance=1, HVAC, System, Plant=2
808 : OutputProcessor::StoreType VariableType, // State, Average=1, NonState, Sum=2
809 : std::string const &KeyedValue, // Associated Key for this variable
810 : int const indexGroupKey = -999, // Group identifier for SQL output
811 : OutputProcessor::ReportFreq freq = OutputProcessor::ReportFreq::Hour // Internal use -- causes reporting at this freqency
812 : );
813 :
814 : void UpdateDataandReport(EnergyPlusData &state, OutputProcessor::TimeStepType TimeStepTypeKey); // What kind of data to update (Zone, HVAC)
815 :
816 : void GenOutputVariablesAuditReport(EnergyPlusData &state);
817 :
818 : void UpdateMeterReporting(EnergyPlusData &state);
819 :
820 : void SetInitialMeterReportingAndOutputNames(EnergyPlusData &state,
821 : int WhichMeter, // Which meter number
822 : bool MeterFileOnlyIndicator, // true if this is a meter file only reporting
823 : OutputProcessor::ReportFreq freq, // at what frequency is the meter reported
824 : bool CumulativeIndicator // true if this is a Cumulative meter reporting
825 : );
826 :
827 : int GetMeterIndex(EnergyPlusData &state, std::string const &MeterName);
828 :
829 : Constant::eResource GetMeterResourceType(EnergyPlusData &state, int MeterNumber); // Which Meter Number (from GetMeterIndex)
830 :
831 : Real64 GetCurrentMeterValue(EnergyPlusData &state, int MeterNumber); // Which Meter Number (from GetMeterIndex)
832 :
833 : Real64 GetInstantMeterValue(EnergyPlusData &state,
834 : int MeterNumber, // Which Meter Number (from GetMeterIndex)
835 : OutputProcessor::TimeStepType TimeStepType // Whether this is zone of HVAC
836 : );
837 :
838 : Real64 GetInternalVariableValue(EnergyPlusData &state,
839 : OutputProcessor::VariableType varType, // 1=integer, 2=real, 3=meter
840 : int keyVarIndex // Array index
841 : );
842 :
843 : Real64 GetInternalVariableValueExternalInterface(EnergyPlusData &state,
844 : OutputProcessor::VariableType varType, // 1=integer, 2=REAL(r64), 3=meter
845 : int keyVarIndex // Array index
846 : );
847 :
848 : int GetNumMeteredVariables(EnergyPlusData &state,
849 : std::string const &ComponentType, // Given Component Type
850 : std::string const &ComponentName // Given Component Name (user defined)
851 : );
852 :
853 : int GetMeteredVariables(EnergyPlusData &state,
854 : std::string const &ComponentName, // Given Component Name (user defined)
855 : Array1D<OutputProcessor::MeteredVar> &meteredVars // Number Found
856 : );
857 :
858 : void GetVariableKeyCountandType(EnergyPlusData &state,
859 : std::string const &varName, // Standard variable name
860 : int &numKeys, // Number of keys found
861 : OutputProcessor::VariableType &varType,
862 : OutputProcessor::StoreType &varAvgSum, // Variable is Averaged=1 or Summed=2
863 : OutputProcessor::TimeStepType &varStepType, // Variable time step is Zone=1 or HVAC=2
864 : Constant::Units &varUnits // Units enumeration
865 : );
866 :
867 : void GetVariableKeys(EnergyPlusData &state,
868 : std::string const &varName, // Standard variable name
869 : OutputProcessor::VariableType varType,
870 : Array1D_string &keyNames,
871 : Array1D_int &keyVarNums // Array index for
872 : );
873 :
874 : bool ReportingThisVariable(EnergyPlusData &state, std::string const &RepVarName);
875 :
876 : void InitPollutionMeterReporting(EnergyPlusData &state, OutputProcessor::ReportFreq freq);
877 :
878 : void ProduceRDDMDD(EnergyPlusData &state);
879 :
880 : int AddDDOutVar(EnergyPlusData &state,
881 : std::string_view const nameUC, // Variable Name
882 : OutputProcessor::TimeStepType TimeStepType,
883 : OutputProcessor::StoreType StateType,
884 : OutputProcessor::VariableType VariableType,
885 : Constant::Units unitsForVar,
886 : std::string_view const customUnitName = {} // the custom name for the units from EMS definition of units
887 : );
888 :
889 : int initErrorFile(EnergyPlusData &state);
890 :
891 : struct OutputProcessorData : BaseGlobalStruct
892 : {
893 : int NumVariablesForOutput = 0;
894 : int MaxVariablesForOutput = 0;
895 : int NumTotalRVariable = 0;
896 : int NumOfRVariable = 0;
897 : int NumOfRVariable_Setup = 0;
898 : int NumOfRVariable_Sum = 0;
899 : int NumOfRVariable_Meter = 0;
900 : int NumOfIVariable = 0;
901 : int NumOfIVariable_Setup = 0;
902 : int NumTotalIVariable = 0;
903 : int NumOfIVariable_Sum = 0;
904 : bool OutputInitialized = false;
905 : OutputProcessor::ReportVDD ProduceReportVDD = OutputProcessor::ReportVDD::No;
906 : int NumHoursInMonth = 0;
907 : int NumHoursInSim = 0;
908 : std::vector<Real64> meterValues; // This holds the current timestep value for each meter.
909 :
910 : std::array<int, (int)OutputProcessor::ReportFreq::Num> freqStampReportNums = {-1, -1, -1, -1, -1, -1, -1};
911 : std::array<bool, (int)OutputProcessor::ReportFreq::Num> freqTrackingVariables = {false, false, false, false, false, false, false};
912 :
913 : Real64 TimeStepZoneSec = 0; // Seconds from NumTimeStepInHour
914 : bool ErrorsLogged = false;
915 : bool isFinalYear = false;
916 : bool GetOutputInputFlag = true;
917 : OutputProcessor::ReportFreq minimumReportFreq = OutputProcessor::ReportFreq::EachCall;
918 : std::vector<OutputProcessor::APIOutputVariableRequest> apiVarRequests;
919 : int ReportNumberCounter = 0; // The report number is used in output reports as a key.
920 : int LHourP = -1; // Helps set hours for timestamp output
921 : Real64 LStartMin = -1.0; // Helps set minutes for timestamp output
922 : Real64 LEndMin = -1.0; // Helps set minutes for timestamp output
923 : bool GetMeterIndexFirstCall = true; // trigger setup in GetMeterIndex
924 : bool InitFlag = true;
925 :
926 : std::array<OutputProcessor::TimeSteps, (int)OutputProcessor::TimeStepType::Num> TimeValue; // Pointers to the actual TimeStep variables
927 :
928 : std::vector<OutputProcessor::OutVar *> outVars; // Variables array (use NumOfRVariables to traverse)
929 : std::vector<OutputProcessor::DDOutVar *> ddOutVars; // Variable Types structure (use NumVariablesForOutput to traverse)
930 : std::map<std::string, int> ddOutVarMap;
931 : std::vector<OutputProcessor::ReqVar *> reqVars;
932 :
933 : std::vector<OutputProcessor::Meter *> meters;
934 : std::map<std::string, int> meterMap;
935 :
936 : char stamp[OutputProcessor::N_WriteTimeStampFormatData];
937 : bool Rept = false;
938 : bool OpaqSurfWarned = false;
939 :
940 : // End-use stuff
941 : int MaxNumSubcategories = 1;
942 : int maxNumEndUseSpaceTypes = 1;
943 : EPVector<OutputProcessor::EndUseCategoryType> EndUseCategory;
944 :
945 796 : void init_state([[maybe_unused]] EnergyPlusData &state) override
946 : {
947 796 : }
948 :
949 0 : void clear_state() override
950 : {
951 0 : this->NumVariablesForOutput = 0;
952 0 : this->MaxVariablesForOutput = 0;
953 0 : this->NumOfRVariable_Setup = 0;
954 0 : this->NumTotalRVariable = 0;
955 0 : this->NumOfRVariable_Sum = 0;
956 0 : this->NumOfRVariable_Meter = 0;
957 0 : this->NumOfIVariable_Setup = 0;
958 0 : this->NumTotalIVariable = 0;
959 0 : this->NumOfIVariable_Sum = 0;
960 0 : this->OutputInitialized = false;
961 0 : this->ProduceReportVDD = OutputProcessor::ReportVDD::No;
962 0 : this->NumHoursInMonth = 0;
963 0 : this->NumHoursInSim = 0;
964 0 : this->meterValues.clear();
965 0 : this->freqStampReportNums = {-1, -1, -1, -1, -1, -1, -1};
966 0 : this->freqTrackingVariables = {false};
967 0 : this->TimeStepZoneSec = 0;
968 0 : this->ErrorsLogged = false;
969 0 : this->isFinalYear = false;
970 0 : this->GetOutputInputFlag = true;
971 0 : this->minimumReportFreq = OutputProcessor::ReportFreq::EachCall;
972 0 : this->apiVarRequests.clear();
973 0 : this->ReportNumberCounter = 0;
974 0 : this->LHourP = -1;
975 0 : this->LStartMin = -1.0;
976 0 : this->LEndMin = -1.0;
977 0 : this->GetMeterIndexFirstCall = true;
978 0 : this->InitFlag = true;
979 :
980 0 : for (int i = 0; i < (int)OutputProcessor::TimeStepType::Num; ++i)
981 0 : new (&this->TimeValue[i]) OutputProcessor::TimeSteps();
982 :
983 0 : for (int i = 0; i < (int)this->outVars.size(); ++i)
984 0 : delete this->outVars[i];
985 0 : this->outVars.clear();
986 :
987 0 : for (int i = 0; i < (int)this->ddOutVars.size(); ++i)
988 0 : delete this->ddOutVars[i];
989 0 : this->ddOutVars.clear();
990 0 : this->ddOutVarMap.clear();
991 :
992 0 : for (int i = 0; i < (int)this->reqVars.size(); ++i)
993 0 : delete this->reqVars[i];
994 0 : this->reqVars.clear();
995 :
996 0 : for (int i = 0; i < (int)this->meters.size(); ++i)
997 0 : delete this->meters[i];
998 0 : this->meters.clear();
999 0 : this->meterMap.clear();
1000 :
1001 0 : this->Rept = false;
1002 0 : this->OpaqSurfWarned = false;
1003 :
1004 0 : this->MaxNumSubcategories = 1;
1005 0 : this->maxNumEndUseSpaceTypes = 1;
1006 0 : this->EndUseCategory.deallocate();
1007 0 : }
1008 : };
1009 :
1010 : } // namespace EnergyPlus
1011 :
1012 : #endif
|