-
Notifications
You must be signed in to change notification settings - Fork 377
/
OutputProcessor.cc
8216 lines (6777 loc) · 281 KB
/
OutputProcessor.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// EnergyPlus, Copyright (c) 1996-2017, The Board of Trustees of the University of Illinois and
// The Regents of the University of California, through Lawrence Berkeley National Laboratory
// (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights
// reserved.
//
// NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
// U.S. Government consequently retains certain rights. As such, the U.S. Government has been
// granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
// worldwide license in the Software to reproduce, distribute copies to the public, prepare
// derivative works, and perform publicly and display publicly, and to permit others to do so.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted
// provided that the following conditions are met:
//
// (1) Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// (2) Redistributions in binary form must reproduce the above copyright notice, this list of
// conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
// the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific prior
// written permission.
//
// (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
// without changes from the version obtained under this License, or (ii) Licensee makes a
// reference solely to the software portion of its product, Licensee must refer to the
// software as "EnergyPlus version X" software, where "X" is the version number Licensee
// obtained under this License and may not use a different name for the software. Except as
// specifically required in this Section (4), Licensee shall not use in a company name, a
// product name, in advertising, publicity, or other promotional activities any name, trade
// name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
// similar designation, without the U.S. Department of Energy's prior written consent.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// C++ Headers
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <ostream>
#include <string>
#include <unordered_set>
// ObjexxFCL Headers
#include <ObjexxFCL/Array.functions.hh>
#include <ObjexxFCL/Fmath.hh>
#include <ObjexxFCL/gio.hh>
#include <ObjexxFCL/string.functions.hh>
// EnergyPlus Headers
#include <CommandLineInterface.hh>
#include <OutputProcessor.hh>
#include <DataEnvironment.hh>
#include <DataGlobalConstants.hh>
#include <DataHeatBalance.hh>
#include <DataIPShortCuts.hh>
#include <DataOutputs.hh>
#include <DataPrecisionGlobals.hh>
#include <DataStringGlobals.hh>
#include <DataSystemVariables.hh>
#include <General.hh>
#include <InputProcessor.hh>
#include <OutputProcessor.hh>
#include <OutputReportPredefined.hh>
#include <ScheduleManager.hh>
#include <SortAndStringUtilities.hh>
#include <SQLiteProcedures.hh>
#include <UtilityRoutines.hh>
#include <milo/dtoa.hpp>
#include <milo/itoa.hpp>
namespace EnergyPlus {
namespace OutputProcessor {
// MODULE INFORMATION:
// AUTHOR Linda Lawrie
// DATE WRITTEN December 1998
// MODIFIED na
// RE-ENGINEERED na
// PURPOSE OF THIS MODULE:
// This module contains the major Output Processor routines.
// In addition, in this file are several routines which can be called
// without Useing the OutputProcessor Module
// METHODOLOGY EMPLOYED:
// Lots of pointers and other fancy data stuff.
// REFERENCES:
// EnergyPlus OutputProcessor specifications.
// OTHER NOTES:
// na
// Using/Aliasing
using namespace DataPrecisionGlobals;
using DataGlobals::MaxNameLength;
using DataGlobals::OutputFileMeters;
using DataGlobals::HourOfDay;
using DataGlobals::DayOfSim;
using DataGlobals::DayOfSimChr;
using DataGlobals::OutputFileStandard;
using DataGlobals::MinutesPerTimeStep;
using DataGlobals::ZoneTSReporting;
using DataGlobals::HVACTSReporting;
using DataGlobals::StdOutputRecordCount;
using DataEnvironment::Month;
using DataEnvironment::DayOfMonth;
using DataEnvironment::Year;
using DataEnvironment::DSTIndicator;
using DataEnvironment::DayOfWeek;
using DataEnvironment::HolidayIndex;
using namespace DataGlobalConstants;
// Data
// in this file should obey a USE OutputProcessor, ONLY: rule.
// MODULE PARAMETER DEFINITIONS:
int const ReportEach( -1 ); // Write out each time UpdatedataandReport is called
int const ReportTimeStep( 0 ); // Write out at 'EndTimeStepFlag'
int const ReportHourly( 1 ); // Write out at 'EndHourFlag'
int const ReportDaily( 2 ); // Write out at 'EndDayFlag'
int const ReportMonthly( 3 ); // Write out at end of month (must be determined)
int const ReportSim( 4 ); // Write out once per environment 'EndEnvrnFlag'
int const ReportVDD_No( 0 ); // Don't report the variable dictionaries in any form
int const ReportVDD_Yes( 1 ); // Report the variable dictionaries in "report format"
int const ReportVDD_IDF( 2 ); // Report the variable dictionaries in "IDF format"
Real64 const MinSetValue( 99999999999999.0 );
Real64 const MaxSetValue( -99999999999999.0 );
int const IMinSetValue( 999999 );
int const IMaxSetValue( -999999 );
int const ZoneVar( 1 ); // Type value for those variables reported on the Zone Time Step
int const HVACVar( 2 ); // Type value for those variables reported on the System Time Step
int const AveragedVar( 1 ); // Type value for "averaged" variables
int const SummedVar( 2 ); // Type value for "summed" variables
int const VarType_NotFound( 0 ); // ref: GetVariableKeyCountandType, 0 = not found
int const VarType_Integer( 1 ); // ref: GetVariableKeyCountandType, 1 = integer
int const VarType_Real( 2 ); // ref: GetVariableKeyCountandType, 2 = real
int const VarType_Meter( 3 ); // ref: GetVariableKeyCountandType, 3 = meter
int const VarType_Schedule( 4 ); // ref: GetVariableKeyCountandType, 4 = schedule
int const MeterType_Normal( 0 ); // Type value for normal meters
int const MeterType_Custom( 1 ); // Type value for custom meters
int const MeterType_CustomDec( 2 ); // Type value for custom meters that decrement another meter
int const MeterType_CustomDiff( 3 ); // Type value for custom meters that difference another meter
static gio::Fmt fmtLD( "*" );
static gio::Fmt fmtA( "(A)" );
static gio::Fmt TimeStampFormat( "(A,',',A,',',i2,',',i2,',',i2,',',i2,',',f5.2,',',f5.2,',',A)" );
static gio::Fmt DailyStampFormat( "(A,',',A,',',i2,',',i2,',',i2,',',A)" );
static gio::Fmt MonthlyStampFormat( "(A,',',A,',',i2)" );
static gio::Fmt RunPeriodStampFormat( "(A,',',A)" );
Array1D_string const DayTypes( 12, { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Holiday", "SummerDesignDay", "WinterDesignDay", "CustomDay1", "CustomDay2" } );
static std::string const BlankString;
int const UnitsStringLength( 16 );
int const RVarAllocInc( 1000 );
int const LVarAllocInc( 1000 );
int const IVarAllocInc( 10 );
// For IP Units (tabular reports) certain resources will be put in sub-tables
//INTEGER, PARAMETER :: RT_IPUnits_Consumption=0
int const RT_IPUnits_Electricity( 1 );
int const RT_IPUnits_Gas( 2 );
int const RT_IPUnits_Cooling( 3 );
int const RT_IPUnits_Water( 4 );
int const RT_IPUnits_OtherKG( 5 );
int const RT_IPUnits_OtherM3( 6 );
int const RT_IPUnits_OtherL( 7 );
int const RT_IPUnits_OtherJ( 0 );
// DERIVED TYPE DEFINITIONS:
int InstMeterCacheSize( 1000 ); // the maximum size of the instant meter cache used in GetInstantMeterValue
int InstMeterCacheSizeInc( 1000 ); // the increment for the instant meter cache used in GetInstantMeterValue
Array1D_int InstMeterCache; // contains a list of RVariableTypes that make up a specific meter
int InstMeterCacheLastUsed( 0 ); // the last item in the instant meter cache used
// INTERFACE BLOCK SPECIFICATIONS:
// na
// MODULE VARIABLE DECLARATIONS:
int CurrentReportNumber( 0 );
int NumVariablesForOutput( 0 );
int MaxVariablesForOutput( 0 );
int NumOfRVariable_Setup( 0 );
int NumTotalRVariable( 0 );
int NumOfRVariable_Sum( 0 );
int NumOfRVariable_Meter( 0 );
int NumOfRVariable( 0 );
int MaxRVariable( 0 );
int NumOfIVariable_Setup( 0 );
int NumTotalIVariable( 0 );
int NumOfIVariable_Sum( 0 );
int NumOfIVariable( 0 );
int MaxIVariable( 0 );
bool OutputInitialized( false );
int ProduceReportVDD( ReportVDD_No );
int OutputFileMeterDetails( 0 ); // Unit number for Meter Details file (output)
int NumHoursInDay( 24 );
int NumHoursInMonth( 0 );
int NumHoursInSim( 0 );
Array1D_int ReportList;
int NumReportList( 0 );
int NumExtraVars( 0 );
Array2D_string FreqNotice( {1,2}, {-1,4} ); // =(/'! Each Call','! TimeStep',' !Hourly',',Daily',',Monthly',',Environment'/)
int NumOfReqVariables( 0 ); // Current number of Requested Report Variables
int NumVarMeterArrays( 0 ); // Current number of Arrays pointing to meters
int NumEnergyMeters( 0 ); // Current number of Energy Meters
Array1D< Real64 > MeterValue; // This holds the current timestep value for each meter.
int TimeStepStampReportNbr; // TimeStep and Hourly Report number
std::string TimeStepStampReportChr; // TimeStep and Hourly Report number (character -- for printing)
bool TrackingHourlyVariables( false ); // Requested Hourly Report Variables
int DailyStampReportNbr; // Daily Report number
std::string DailyStampReportChr; // Daily Report number (character -- for printing)
bool TrackingDailyVariables( false ); // Requested Daily Report Variables
int MonthlyStampReportNbr; // Monthly Report number
std::string MonthlyStampReportChr; // Monthly Report number (character -- for printing)
bool TrackingMonthlyVariables( false ); // Requested Monthly Report Variables
int RunPeriodStampReportNbr; // RunPeriod Report number
std::string RunPeriodStampReportChr; // RunPeriod Report number (character -- for printing)
bool TrackingRunPeriodVariables( false ); // Requested RunPeriod Report Variables
Real64 TimeStepZoneSec; // Seconds from NumTimeStepInHour
bool ErrorsLogged( false );
bool ProduceVariableDictionary( false );
int MaxNumSubcategories( 1 );
bool isFinalYear( false );
namespace {
// These were static variables within different functions. They were pulled out into the namespace
// to facilitate easier unit testing of those functions.
// These are purposefully not in the header file as an extern variable. No one outside of OutputProcessor should
// use these. They are cleared by clear_state() for use by unit tests, but normal simulations should be unaffected.
// This is purposefully in an anonymous namespace so nothing outside this implementation file can use it.
int ReportNumberCounter( 0 ); // The report number is used in output reports as a key.
int LHourP( -1 ); // Helps set hours for timestamp output
Real64 LStartMin( -1.0 ); // Helps set minutes for timestamp output
Real64 LEndMin( -1.0 ); // Helps set minutes for timestamp output
bool GetMeterIndexFirstCall( true ); //trigger setup in GetMeterIndex
bool InitFlag( true );
}
// All routines should be listed here whether private or not
//PUBLIC ReallocateTVar
//PUBLIC SetReportNow
// Object Data
Array1D< TimeSteps > TimeValue( 2 ); // Pointers to the actual TimeStep variables
Array1D< RealVariableType > RVariableTypes; // Variable Types structure (use NumOfRVariables to traverse)
Array1D< IntegerVariableType > IVariableTypes; // Variable Types structure (use NumOfIVariables to traverse)
Array1D< VariableTypeForDDOutput > DDVariableTypes; // Variable Types structure (use NumVariablesForOutput to traverse)
Reference< RealVariables > RVariable;
Reference< IntegerVariables > IVariable;
Reference< RealVariables > RVar;
Reference< IntegerVariables > IVar;
Array1D< ReqReportVariables > ReqRepVars;
Array1D< MeterArrayType > VarMeterArrays;
Array1D< MeterType > EnergyMeters;
Array1D< EndUseCategoryType > EndUseCategory;
// Routines tagged on the end of this module:
// AddToOutputVariableList
// AssignReportNumber
// GenOutputVariablesAuditReport
// GetCurrentMeterValue
// GetInstantMeterValue
// GetInternalVariableValue
// GetInternalVariableValueExternalInterface
// GetMeteredVariables
// GetMeterIndex
// GetMeterResourceType
// GetNumMeteredVariables
// GetVariableKeyCountandType
// GetVariableKeys
// InitPollutionMeterReporting
// ProduceRDDMDD
// ReportingThisVariable
// SetInitialMeterReportingAndOutputNames
// SetupOutputVariable
// UpdateDataandReport
// UpdateMeterReporting
// Functions
// Clears the global data in OutputProcessor.
// Needed for unit tests, should not be normally called.
void
clear_state()
{
InstMeterCacheSize = 1000;
InstMeterCacheSizeInc = 1000;
InstMeterCache.deallocate();
InstMeterCacheLastUsed = 0;
CurrentReportNumber = 0;
NumVariablesForOutput = 0;
MaxVariablesForOutput = 0;
NumOfRVariable_Setup = 0;
NumTotalRVariable = 0;
NumOfRVariable_Sum = 0;
NumOfRVariable_Meter = 0;
NumOfRVariable = 0;
MaxRVariable = 0;
NumOfIVariable_Setup = 0;
NumTotalIVariable = 0;
NumOfIVariable_Sum = 0;
NumOfIVariable = 0;
MaxIVariable = 0;
OutputInitialized = false;
ProduceReportVDD = ReportVDD_No;
OutputFileMeterDetails = 0;
NumHoursInDay = 24;
NumHoursInMonth = 0;
NumHoursInSim = 0;
ReportList.deallocate();
NumReportList = 0;
NumExtraVars = 0;
FreqNotice.dimension( {1,2}, {-1,4} );
NumOfReqVariables = 0;
NumVarMeterArrays = 0;
NumEnergyMeters = 0;
MeterValue.deallocate();
TimeStepStampReportNbr = 0;
TimeStepStampReportChr = "";
TrackingHourlyVariables = false;
DailyStampReportNbr = 0;
DailyStampReportChr = "";
TrackingDailyVariables = false;
MonthlyStampReportNbr = 0;
MonthlyStampReportChr = "";
TrackingMonthlyVariables = false;
RunPeriodStampReportNbr = 0;
RunPeriodStampReportChr = "";
TrackingRunPeriodVariables = false;
TimeStepZoneSec = 0;
ErrorsLogged = false;
ProduceVariableDictionary = false;
MaxNumSubcategories = 1;
ReportNumberCounter = 0;
LHourP = -1;
LStartMin = -1.0;
LEndMin = -1.0;
GetMeterIndexFirstCall = true ;
InitFlag = true;
TimeValue.deallocate();
RVariableTypes.deallocate();
IVariableTypes.deallocate();
DDVariableTypes.deallocate();
RVariable.deallocate();
IVariable.deallocate();
RVar.deallocate();
IVar.deallocate();
ReqRepVars.deallocate();
VarMeterArrays.deallocate();
EnergyMeters.deallocate();
EndUseCategory.deallocate();
}
void
InitializeOutput()
{
// SUBROUTINE INFORMATION:
// AUTHOR Linda K. Lawrie
// DATE WRITTEN December 1998
// MODIFIED na
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// This subroutine initializes the OutputProcessor data structures.
// METHODOLOGY EMPLOYED:
// na
// REFERENCES:
// na
// USE STATEMENTS:
// na
// SUBROUTINE ARGUMENT DEFINITIONS:
// na
// SUBROUTINE PARAMETER DEFINITIONS:
// na
// INTERFACE BLOCK SPECIFICATIONS:
// na
// DERIVED TYPE DEFINITIONS:
// na
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
RVariableTypes.allocate( RVarAllocInc );
RVar.allocate();
MaxRVariable = RVarAllocInc;
IVariableTypes.allocate( IVarAllocInc );
IVar.allocate();
MaxIVariable = IVarAllocInc;
// First index is the frequency designation (-1 = each call, etc)
// Second index is the variable type (1=Average, 2=Sum)
// Note, Meters always report like Average (with min/max, etc) for hourly and above
FreqNotice( 1, -1 ) = " !Each Call";
FreqNotice( 1, 0 ) = " !TimeStep";
FreqNotice( 1, 1 ) = " !Hourly";
FreqNotice( 1, 2 ) = " !Daily [Value,Min,Hour,Minute,Max,Hour,Minute]";
FreqNotice( 1, 3 ) = " !Monthly [Value,Min,Day,Hour,Minute,Max,Day,Hour,Minute]";
FreqNotice( 1, 4 ) = " !RunPeriod [Value,Min,Month,Day,Hour,Minute,Max,Month,Day,Hour,Minute]";
FreqNotice( 2, -1 ) = " !Each Call";
FreqNotice( 2, 0 ) = " !TimeStep";
FreqNotice( 2, 1 ) = " !Hourly";
FreqNotice( 2, 2 ) = " !Daily [Value,Min,Hour,Minute,Max,Hour,Minute]";
FreqNotice( 2, 3 ) = " !Monthly [Value,Min,Day,Hour,Minute,Max,Day,Hour,Minute]";
FreqNotice( 2, 4 ) = " !RunPeriod [Value,Min,Month,Day,Hour,Minute,Max,Month,Day,Hour,Minute]";
ReportList.allocate( 500 );
NumReportList = 500;
ReportList = 0;
NumExtraVars = 0;
// Initialize end use category names - the indices must match up with endUseNames in OutputReportTabular
EndUseCategory.allocate( NumEndUses );
EndUseCategory( endUseHeating ).Name = "Heating";
EndUseCategory( endUseCooling ).Name = "Cooling";
EndUseCategory( endUseInteriorLights ).Name = "InteriorLights";
EndUseCategory( endUseExteriorLights ).Name = "ExteriorLights";
EndUseCategory( endUseInteriorEquipment ).Name = "InteriorEquipment";
EndUseCategory( endUseExteriorEquipment ).Name = "ExteriorEquipment";
EndUseCategory( endUseFans ).Name = "Fans";
EndUseCategory( endUsePumps ).Name = "Pumps";
EndUseCategory( endUseHeatRejection ).Name = "HeatRejection";
EndUseCategory( endUseHumidification ).Name = "Humidifier";
EndUseCategory( endUseHeatRecovery ).Name = "HeatRecovery";
EndUseCategory( endUseWaterSystem ).Name = "WaterSystems";
EndUseCategory( endUseRefrigeration ).Name = "Refrigeration";
EndUseCategory( endUseCogeneration ).Name = "Cogeneration";
// Initialize display names for output table - this could go away if end use key names are changed to match
EndUseCategory( endUseHeating ).DisplayName = "Heating";
EndUseCategory( endUseCooling ).DisplayName = "Cooling";
EndUseCategory( endUseInteriorLights ).DisplayName = "Interior Lighting";
EndUseCategory( endUseExteriorLights ).DisplayName = "Exterior Lighting";
EndUseCategory( endUseInteriorEquipment ).DisplayName = "Interior Equipment";
EndUseCategory( endUseExteriorEquipment ).DisplayName = "Exterior Equipment";
EndUseCategory( endUseFans ).DisplayName = "Fans";
EndUseCategory( endUsePumps ).DisplayName = "Pumps";
EndUseCategory( endUseHeatRejection ).DisplayName = "Heat Rejection";
EndUseCategory( endUseHumidification ).DisplayName = "Humidification";
EndUseCategory( endUseHeatRecovery ).DisplayName = "Heat Recovery";
EndUseCategory( endUseWaterSystem ).DisplayName = "Water Systems";
EndUseCategory( endUseRefrigeration ).DisplayName = "Refrigeration";
EndUseCategory( endUseCogeneration ).DisplayName = "Generators";
OutputInitialized = true;
TimeStepZoneSec = double( MinutesPerTimeStep ) * 60.0;
InitializeMeters();
}
void
SetupTimePointers(
std::string const & IndexKey, // Which timestep is being set up, 'Zone'=1, 'HVAC'=2
Real64 & TimeStep // The timestep variable. Used to get the address
)
{
// SUBROUTINE INFORMATION:
// AUTHOR Linda K. Lawrie
// DATE WRITTEN December 1998
// MODIFIED na
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// This subroutine sets up the derived type for the output processor that
// contains pointers to the TimeStep values used in the simulation.
// METHODOLOGY EMPLOYED:
// Indicate that the TimeStep passed in is a target for the pointer
// attributes in the derived types.
// REFERENCES:
// na
// Using/Aliasing
// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
// for the pointer in the derived type.
// SUBROUTINE PARAMETER DEFINITIONS:
// na
// INTERFACE BLOCK SPECIFICATIONS:
// na
// DERIVED TYPE DEFINITIONS:
// na
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
std::string cValue;
int Index;
Index = ValidateIndexType( IndexKey, "SetupTimePointers" );
if ( Index == 1 ) {
TimeValue( Index ).TimeStep >>= TimeStep;
TimeValue( Index ).CurMinute = 0.0;
} else if ( Index == 2 ) {
TimeValue( Index ).TimeStep >>= TimeStep;
TimeValue( Index ).CurMinute = 0.0;
} else {
gio::write( cValue, fmtLD ) << Index;
ShowSevereError( "Illegal value passed to SetupTimePointers, must be 1 or 2 == " + cValue, OutputFileStandard );
}
}
void
CheckReportVariable(
std::string const & KeyedValue, // Associated Key for this variable
std::string const & VarName // String Name of variable (without units)
)
{
// SUBROUTINE INFORMATION:
// AUTHOR Linda K. Lawrie
// DATE WRITTEN December 1998
// MODIFIED na
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// This subroutine will get the report variable information from input and
// determine if this variable (KeyedValue and VariableName) should be reported
// and, if so, what frequency to report.
// This routine is called when SetupOutputVariable is called with no "optional"
// Reporting Frequency. It is expected that SetupOutputVariable would only be
// called once for each keyed variable to be triggered for output (from the input
// requests). The optional report frequency would only be used for debugging
// purposes. Therefore, this routine will collect all occasions where this
// passed variablename would be reported from the requested input. It builds
// a list of these requests (ReportList) so that the calling routine can propagate
// the requests into the correct data structure.
// METHODOLOGY EMPLOYED:
// This instance being requested will always have a key associated with it. Matching
// instances (from input) may or may not have keys, but only one instance of a reporting
// frequency per variable is allowed. ReportList will be populated with ReqRepVars indices
// of those extra things from input that satisfy this condition.
// REFERENCES:
// na
// Using/Aliasing
using InputProcessor::FindItem;
// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
// SUBROUTINE PARAMETER DEFINITIONS:
// na
// INTERFACE BLOCK SPECIFICATIONS:
// na
// DERIVED TYPE DEFINITIONS:
// na
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
static bool GetInputFlag( true );
int Item;
int Loop;
int Pos;
int MinLook;
int MaxLook;
if ( GetInputFlag ) {
GetReportVariableInput();
GetInputFlag = false;
}
if ( NumOfReqVariables > 0 ) {
// Do a quick check
Item = FindItem( VarName, ReqRepVars, &ReqReportVariables::VarName );
NumExtraVars = 0;
ReportList = 0;
MinLook = 999999999;
MaxLook = -999999999;
if ( Item != 0 ) {
Loop = Item;
Pos = Item;
MinLook = min( MinLook, Pos );
MaxLook = max( MaxLook, Pos );
while ( Loop <= NumOfReqVariables && Pos != 0 ) {
// Mark all with blank keys as used
if ( ReqRepVars( Loop ).Key.empty() ) {
ReqRepVars( Loop ).Used = true;
}
if ( Loop < NumOfReqVariables ) {
Pos = FindItem( VarName, ReqRepVars( {Loop+1,NumOfReqVariables} ), &ReqReportVariables::VarName );
if ( Pos != 0 ) {
MinLook = min( MinLook, Loop + Pos );
MaxLook = max( MaxLook, Loop + Pos );
}
} else {
Pos = 1;
}
Loop += Pos;
}
BuildKeyVarList( KeyedValue, VarName, MinLook, MaxLook );
AddBlankKeys( VarName, MinLook, MaxLook );
}
}
}
void
BuildKeyVarList(
std::string const & KeyedValue, // Associated Key for this variable
std::string const & VariableName, // String Name of variable
int const MinIndx, // Min number (from previous routine) for this variable
int const MaxIndx // Max number (from previous routine) for this variable
)
{
// SUBROUTINE INFORMATION:
// AUTHOR Linda K. Lawrie
// DATE WRITTEN March 1999
// MODIFIED na
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// This subroutine builds an initial list (from ReqRepVars) of
// pointers to that data structure for this KeyedValue and VariableName.
// METHODOLOGY EMPLOYED:
// Go through the ReqRepVars list and add those
// that match (and dont duplicate ones already in the list).
// REFERENCES:
// na
// Using/Aliasing
using InputProcessor::SameString;
// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
// SUBROUTINE PARAMETER DEFINITIONS:
// na
// INTERFACE BLOCK SPECIFICATIONS:
// na
// DERIVED TYPE DEFINITIONS:
// na
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
int Loop;
int Loop1;
bool Dup;
Array1D_int TmpReportList;
for ( Loop = MinIndx; Loop <= MaxIndx; ++Loop ) {
if ( ! SameString( ReqRepVars( Loop ).VarName, VariableName ) ) continue;
if ( ! SameString( ReqRepVars( Loop ).Key, KeyedValue ) ) continue;
// A match. Make sure doesnt duplicate
ReqRepVars( Loop ).Used = true;
Dup = false;
for ( Loop1 = 1; Loop1 <= NumExtraVars; ++Loop1 ) {
if ( ReqRepVars( ReportList( Loop1 ) ).ReportFreq == ReqRepVars( Loop ).ReportFreq ) {
Dup = true;
} else {
continue;
}
// So Same Report Frequency
if ( ReqRepVars( ReportList( Loop1 ) ).SchedPtr != ReqRepVars( Loop ).SchedPtr ) Dup = false;
}
if ( ! Dup ) {
++NumExtraVars;
if ( NumExtraVars == NumReportList ) {
ReportList.redimension( NumReportList += 100, 0 );
}
ReportList( NumExtraVars ) = Loop;
}
}
}
void
AddBlankKeys(
std::string const & VariableName, // String Name of variable
int const MinIndx, // Min number (from previous routine) for this variable
int const MaxIndx // Max number (from previous routine) for this variable
)
{
// SUBROUTINE INFORMATION:
// AUTHOR Linda K. Lawrie
// DATE WRITTEN March 1999
// MODIFIED na
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// This subroutine adds to the ReportList any report variables that have
// been requested for all keys of that report variable (if it doesnt duplicate
// a frequency already on the list).
// METHODOLOGY EMPLOYED:
// Go through the ReqRepVars list and add those
// that match (and dont duplicate ones already in the list).
// REFERENCES:
// na
// Using/Aliasing
using InputProcessor::SameString;
// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
// SUBROUTINE PARAMETER DEFINITIONS:
// na
// INTERFACE BLOCK SPECIFICATIONS:
// na
// DERIVED TYPE DEFINITIONS:
// na
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
int Loop;
int Loop1;
bool Dup;
Array1D_int TmpReportList;
for ( Loop = MinIndx; Loop <= MaxIndx; ++Loop ) {
if ( ! ReqRepVars( Loop ).Key.empty() ) continue;
if ( ! SameString( ReqRepVars( Loop ).VarName, VariableName ) ) continue;
// A match. Make sure doesnt duplicate
Dup = false;
for ( Loop1 = 1; Loop1 <= NumExtraVars; ++Loop1 ) {
//IF (ReqRepVars(ReportList(Loop1))%ReportFreq == ReqRepVars(Loop)%ReportFreq) Dup=.TRUE.
if ( ReqRepVars( ReportList( Loop1 ) ).ReportFreq == ReqRepVars( Loop ).ReportFreq ) {
Dup = true;
} else {
continue;
}
// So Same Report Frequency
if ( ReqRepVars( ReportList( Loop1 ) ).SchedPtr != ReqRepVars( Loop ).SchedPtr ) Dup = false;
}
if ( ! Dup ) {
++NumExtraVars;
if ( NumExtraVars == NumReportList ) {
ReportList.redimension( NumReportList += 100, 0 );
}
ReportList( NumExtraVars ) = Loop;
}
}
}
void
GetReportVariableInput()
{
// SUBROUTINE INFORMATION:
// AUTHOR Linda K. Lawrie
// DATE WRITTEN December 1998
// MODIFIED na
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// This subroutine gets the requested report variables from
// the input file.
// Report Variable,
// \memo each Report Variable command picks variables to be put onto the standard output file (.eso)
// \memo some variables may not be reported for every simulation
// A1 , \field Key_Value
// \note use '*' (without quotes) to apply this variable to all keys
// A2 , \field Variable_Name
// A3 , \field Reporting_Frequency
// \type choice
// \key detailed
// \key timestep
// \key hourly
// \key daily
// \key monthly
// \key runperiod
// A4 ; \field Schedule_Name
// \type object-list
// \object-list ScheduleNames
// METHODOLOGY EMPLOYED:
// na
// REFERENCES:
// na
// Using/Aliasing
//using namespace DataIPShortCuts;
using DataGlobals::OutputFileInits;
using namespace InputProcessor;
using ScheduleManager::GetScheduleIndex;
using DataSystemVariables::cMinReportFrequency;
using DataSystemVariables::MinReportFrequency;
// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
// na
// SUBROUTINE PARAMETER DEFINITIONS:
// na
// INTERFACE BLOCK SPECIFICATIONS:
// na
// DERIVED TYPE DEFINITIONS:
// na
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
int Loop;
int NumAlpha;
int NumNumbers;
int IOStat;
int Item;
static bool ErrorsFound( false ); // If errors detected in input
std::string cCurrentModuleObject;
Array1D_string cAlphaArgs( 4 );
Array1D_string cAlphaFieldNames( 4 );
Array1D_bool lAlphaFieldBlanks( 4 );
Array1D< Real64 > rNumericArgs( 1 );
Array1D_string cNumericFieldNames( 1 );
Array1D_bool lNumericFieldBlanks( 1 );
// Formats
static gio::Fmt Format_800( "('! <Minimum Reporting Frequency (overriding input value)>, Value, Input Value')" );
static gio::Fmt Format_801( "(' Minimum Reporting Frequency, ',A,',',A)" );
// First check environment variable to see of possible override for minimum reporting frequency
if ( cMinReportFrequency != "" ) {
DetermineFrequency( cMinReportFrequency, Item ); // Use local variable Item so as not to possibly confuse things
MinReportFrequency = max( MinReportFrequency, Item );
gio::write( OutputFileInits, Format_800 );
gio::write( OutputFileInits, Format_801 ) << FreqNotice( 1, MinReportFrequency ) << cMinReportFrequency;
}
cCurrentModuleObject = "Output:Variable";
NumOfReqVariables = GetNumObjectsFound( cCurrentModuleObject );
ReqRepVars.allocate( NumOfReqVariables );
for ( Loop = 1; Loop <= NumOfReqVariables; ++Loop ) {
GetObjectItem( cCurrentModuleObject, Loop, cAlphaArgs, NumAlpha, rNumericArgs, NumNumbers, IOStat, lNumericFieldBlanks, lAlphaFieldBlanks, cAlphaFieldNames, cNumericFieldNames );
// Check for duplicates?
ReqRepVars( Loop ).Key = cAlphaArgs( 1 );
if ( ReqRepVars( Loop ).Key == "*" ) {
ReqRepVars( Loop ).Key = BlankString;
}
std::string::size_type const lbpos = index( cAlphaArgs( 2 ), '[' ); // Remove Units designation if user put it in
if ( lbpos != std::string::npos ) {
cAlphaArgs( 2 ).erase( lbpos );
}
ReqRepVars( Loop ).VarName = cAlphaArgs( 2 );
DetermineFrequency( cAlphaArgs( 3 ), ReqRepVars( Loop ).ReportFreq );
// Schedule information
ReqRepVars( Loop ).SchedName = cAlphaArgs( 4 );
if ( not_blank( ReqRepVars( Loop ).SchedName ) ) {
ReqRepVars( Loop ).SchedPtr = GetScheduleIndex( ReqRepVars( Loop ).SchedName );
if ( ReqRepVars( Loop ).SchedPtr == 0 ) {
ShowSevereError( "GetReportVariableInput: " + cCurrentModuleObject + "=\"" + cAlphaArgs( 1 ) + ':' + ReqRepVars( Loop ).VarName + "\" invalid " + cAlphaFieldNames( 4 ) + "=\"" + ReqRepVars( Loop ).SchedName + "\" - not found." );
ErrorsFound = true;
}
} else {
ReqRepVars( Loop ).SchedPtr = 0;
}
ReqRepVars( Loop ).Used = false;
}
if ( ErrorsFound ) {
ShowFatalError( "GetReportVariableInput:" + cCurrentModuleObject + ": errors in input." );
}
}
void
DetermineFrequency(
std::string const & FreqString,
int & ReportFreq
)
{
// SUBROUTINE INFORMATION:
// AUTHOR Linda K. Lawrie
// DATE WRITTEN December 1998
// MODIFIED na
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// This subroutine looks at the passed in report frequency string and
// determines the reporting frequency.
// METHODOLOGY EMPLOYED:
// na
// REFERENCES:
// \field Reporting Frequency
// \type choice
// \key Detailed
// \note Detailed lists every instance (i.e. HVAC variable timesteps)
// \key Timestep
// \note Timestep refers to the zone Timestep/Number of Timesteps in hour value
// \note RunPeriod, Environment, and Annual are the same
// \key Hourly
// \key Daily
// \key Monthly
// \key RunPeriod
// \key Environment
// \key Annual
// \default Hourly
// \note RunPeriod, Environment, and Annual are synonymous
// Using/Aliasing
using InputProcessor::SameString;
using DataSystemVariables::MinReportFrequency;
// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
// SUBROUTINE PARAMETER DEFINITIONS:
static Array1D_string const PossibleFreq( {-1,6}, { "deta", "time", "hour", "dail", "mont", "runp", "envi", "annu" } );
//=(/'detail','Timestep','Hourly','Daily','Monthly','RunPeriod','Environment','Annual'/)
static Array1D_string const ExactFreqString( {-1,6}, { "Detailed", "Timestep", "Hourly", "Daily", "Monthly", "RunPeriod", "Environment", "Annual" } );
static Array1D_int const FreqValues( {-1,6}, { -1, 0, 1, 2, 3, 4, 4, 4 } );
// note: runperiod, environment, and annual are synonomous
// INTERFACE BLOCK SPECIFICATIONS:
// na
// DERIVED TYPE DEFINITIONS:
// na
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
ReportFreq = ReportHourly; //Default
std::string::size_type const LenString = min( len( FreqString ), static_cast< std::string::size_type >( 4u ) );
std::string const FreqStringTrim( FreqString.substr( 0, LenString ) );
for ( int Loop = -1; Loop <= 6; ++Loop ) {
if ( ! SameString( FreqStringTrim, PossibleFreq( Loop ) ) ) continue;