LCOV - code coverage report
Current view: top level - EnergyPlus - OutputReportTabular.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 9487 11787 80.5 %
Date: 2024-08-24 18:31:18 Functions: 120 137 87.6 %

          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             : // C++ Headers
      49             : #include <algorithm>
      50             : #include <cassert>
      51             : #include <cmath>
      52             : #include <iomanip>
      53             : #include <map>
      54             : #include <unordered_map>
      55             : #include <utility>
      56             : #include <vector>
      57             : 
      58             : // ObjexxFCL Headers
      59             : #include <ObjexxFCL/Array.functions.hh>
      60             : #include <ObjexxFCL/ArrayS.functions.hh>
      61             : #include <ObjexxFCL/Fmath.hh>
      62             : #include <ObjexxFCL/member.functions.hh>
      63             : #include <ObjexxFCL/numeric.hh>
      64             : #include <ObjexxFCL/string.functions.hh>
      65             : #include <ObjexxFCL/time.hh>
      66             : 
      67             : // Third-party Headers
      68             : #include <fast_float/fast_float.h>
      69             : #include <fmt/format.h>
      70             : 
      71             : // EnergyPlus Headers
      72             : #include <AirflowNetwork/Solver.hpp>
      73             : #include <EnergyPlus/Boilers.hh>
      74             : #include <EnergyPlus/ChillerElectricEIR.hh>
      75             : #include <EnergyPlus/ChillerReformulatedEIR.hh>
      76             : #include <EnergyPlus/CondenserLoopTowers.hh>
      77             : #include <EnergyPlus/CostEstimateManager.hh>
      78             : #include <EnergyPlus/DXCoils.hh>
      79             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      80             : #include <EnergyPlus/DataAirLoop.hh>
      81             : #include <EnergyPlus/DataAirSystems.hh>
      82             : #include <EnergyPlus/DataDefineEquip.hh>
      83             : #include <EnergyPlus/DataGlobalConstants.hh>
      84             : #include <EnergyPlus/DataHVACGlobals.hh>
      85             : #include <EnergyPlus/DataHeatBalFanSys.hh>
      86             : #include <EnergyPlus/DataHeatBalSurface.hh>
      87             : #include <EnergyPlus/DataHeatBalance.hh>
      88             : #include <EnergyPlus/DataIPShortCuts.hh>
      89             : #include <EnergyPlus/DataOutputs.hh>
      90             : #include <EnergyPlus/DataShadowingCombinations.hh>
      91             : #include <EnergyPlus/DataSizing.hh>
      92             : #include <EnergyPlus/DataStringGlobals.hh>
      93             : #include <EnergyPlus/DataSurfaces.hh>
      94             : #include <EnergyPlus/DataViewFactorInformation.hh>
      95             : #include <EnergyPlus/DataWater.hh>
      96             : #include <EnergyPlus/DaylightingManager.hh>
      97             : #include <EnergyPlus/DisplayRoutines.hh>
      98             : #include <EnergyPlus/EconomicLifeCycleCost.hh>
      99             : #include <EnergyPlus/ElectricPowerServiceManager.hh>
     100             : #include <EnergyPlus/EvaporativeCoolers.hh>
     101             : #include <EnergyPlus/EvaporativeFluidCoolers.hh>
     102             : #include <EnergyPlus/FileSystem.hh>
     103             : #include <EnergyPlus/FluidCoolers.hh>
     104             : #include <EnergyPlus/General.hh>
     105             : #include <EnergyPlus/HVACVariableRefrigerantFlow.hh>
     106             : #include <EnergyPlus/HeatingCoils.hh>
     107             : #include <EnergyPlus/HybridModel.hh>
     108             : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
     109             : #include <EnergyPlus/InternalHeatGains.hh>
     110             : #include <EnergyPlus/LowTempRadiantSystem.hh>
     111             : #include <EnergyPlus/MixedAir.hh>
     112             : #include <EnergyPlus/OutputProcessor.hh>
     113             : #include <EnergyPlus/OutputReportPredefined.hh>
     114             : #include <EnergyPlus/OutputReportTabular.hh>
     115             : #include <EnergyPlus/OutputReportTabularAnnual.hh>
     116             : #include <EnergyPlus/PackagedThermalStorageCoil.hh>
     117             : #include <EnergyPlus/PlantChillers.hh>
     118             : #include <EnergyPlus/PollutionModule.hh>
     119             : #include <EnergyPlus/Psychrometrics.hh>
     120             : #include <EnergyPlus/RefrigeratedCase.hh>
     121             : #include <EnergyPlus/ReportCoilSelection.hh>
     122             : #include <EnergyPlus/ResultsFramework.hh>
     123             : #include <EnergyPlus/SQLiteProcedures.hh>
     124             : #include <EnergyPlus/ScheduleManager.hh>
     125             : #include <EnergyPlus/ThermalComfort.hh>
     126             : #include <EnergyPlus/UtilityRoutines.hh>
     127             : #include <EnergyPlus/VentilatedSlab.hh>
     128             : #include <EnergyPlus/WaterManager.hh>
     129             : #include <EnergyPlus/WaterThermalTanks.hh>
     130             : #include <EnergyPlus/WeatherManager.hh>
     131             : #include <EnergyPlus/ZonePlenum.hh>
     132             : #include <EnergyPlus/ZoneTempPredictorCorrector.hh>
     133             : 
     134             : namespace EnergyPlus::OutputReportTabular {
     135             : 
     136             : // MODULE INFORMATION:
     137             : //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
     138             : //    DATE WRITTEN   July 2003
     139             : //    MODIFIED       na
     140             : //    RE-ENGINEERED  na
     141             : // PURPOSE OF THIS MODULE:
     142             : //    This module allows the user to define several different tabular
     143             : //    report that have a specific format.
     144             : // METHODOLOGY EMPLOYED:
     145             : //    Generally aggregation. Specifically, the IDF objects are read into data
     146             : //    structures on the first call to update the data.  The data structures
     147             : //    include not only ones to hold the IDF data but also that initialize
     148             : //    the structure used to gather data each iteration. The report:table:binned
     149             : //    object is stored in OutputTableBinned.
     150             : //    During initialization the TableResults data structure is created which contains
     151             : //    all the information needed to perform the aggregation on a timestep basis.
     152             : //    After the end of the simulation the original Output data structures
     153             : //    are scanned and actual tables are created doing any scaling as necessary
     154             : //    and placing all the results into an output table.  The output table
     155             : //    is written in the selected format for each of the tables defined.
     156             : // REFERENCES:
     157             : //    None.
     158             : // OTHER NOTES:.
     159             : //                                      |--> BinResults
     160             : //                                      |
     161             : //                                      |--> BinResultsAbove
     162             : //   OutputTableBinned ---------------->|
     163             : //                                      |--> BinResultsBelow
     164             : //                                      |
     165             : //                                      |--> BinObjVarID
     166             : //
     167             : //                                      |--> MonthlyFieldSetInput
     168             : //   MonthlyInput --------------------->|
     169             : //                                      |--> MonthlyTable --> MonthlyColumns
     170             : 
     171             : // Using/Aliasing
     172             : using namespace OutputReportPredefined;
     173             : using namespace DataHeatBalance;
     174             : using namespace HybridModel;
     175             : 
     176         862 : std::ofstream &open_tbl_stream(EnergyPlusData &state, int const iStyle, fs::path const &filePath, bool output_to_file)
     177             : {
     178         862 :     std::ofstream &tbl_stream(*state.dataOutRptTab->TabularOutputFile(iStyle));
     179         862 :     if (output_to_file) {
     180         862 :         tbl_stream.open(filePath);
     181         862 :         if (!tbl_stream) {
     182           0 :             ShowFatalError(state, format("OpenOutputTabularFile: Could not open file \"{}\" for output (write).", filePath));
     183             :         }
     184             :     } else {
     185           0 :         tbl_stream.setstate(std::ios_base::badbit);
     186             :     }
     187         862 :     return tbl_stream;
     188             : }
     189             : 
     190     1097533 : void UpdateTabularReports(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
     191             : {
     192             :     // SUBROUTINE INFORMATION:
     193             :     //       AUTHOR         Jason Glazer
     194             :     //       DATE WRITTEN   July 2003
     195             :     //       MODIFIED       na
     196             :     //       RE-ENGINEERED  na
     197             : 
     198             :     // PURPOSE OF THIS SUBROUTINE:
     199             :     // This is the routine that is called at the end of the time step
     200             :     // loop and updates the arrays of data that will later being put
     201             :     // into the tabular reports.
     202             : 
     203     1097533 :     auto &ort = state.dataOutRptTab;
     204             : 
     205     1097533 :     if (t_timeStepType != OutputProcessor::TimeStepType::Zone && t_timeStepType != OutputProcessor::TimeStepType::System) {
     206           0 :         ShowFatalError(state, "Invalid reporting requested -- UpdateTabularReports");
     207             :     }
     208             : 
     209     1097533 :     if (ort->UpdateTabularReportsGetInput) {
     210         794 :         GetInputTabularMonthly(state);
     211         794 :         OutputReportTabularAnnual::GetInputTabularAnnual(state);
     212         794 :         OutputReportTabularAnnual::checkAggregationOrderForAnnual(state);
     213         794 :         GetInputTabularTimeBins(state);
     214         794 :         GetInputTabularStyle(state);
     215         794 :         GetInputOutputTableSummaryReports(state);
     216         794 :         if (state.dataOutRptTab->displayThermalResilienceSummary) {
     217             :             // check whether multiple people have different threshold for a zone
     218         675 :             Real64 valueNotInit = -999.0;
     219         675 :             Real64 nearThreshold = 1.0;
     220        4215 :             for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
     221        3540 :                 state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh = valueNotInit;
     222        3540 :                 state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh = valueNotInit;
     223             :             }
     224        3571 :             for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
     225        2896 :                 int ZoneNum = state.dataHeatBal->People(iPeople).ZonePtr;
     226             : 
     227        2896 :                 Real64 ColdTempThresh = state.dataHeatBal->People(iPeople).ColdStressTempThresh;
     228        2896 :                 if (state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh < valueNotInit + nearThreshold) {
     229        2851 :                     state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh = ColdTempThresh;
     230             :                 } else {
     231          45 :                     if (state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh != ColdTempThresh) {
     232           0 :                         ShowWarningMessage(
     233           0 :                             state, fmt::format("Zone {} has multiple people objects with different Cold Stress Temperature Threshold.", ZoneNum));
     234             :                     }
     235             :                 }
     236             : 
     237        2896 :                 Real64 HeatTempThresh = state.dataHeatBal->People(iPeople).HeatStressTempThresh;
     238        2896 :                 if (state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh < valueNotInit + nearThreshold) {
     239        2851 :                     state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh = HeatTempThresh;
     240             :                 } else {
     241          45 :                     if (state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh != HeatTempThresh) {
     242           0 :                         ShowWarningMessage(
     243           0 :                             state, fmt::format("Zone {} has multiple people objects with different Heat Stress Temperature Threshold.", ZoneNum));
     244             :                     }
     245             :                 }
     246             :             }
     247             :         }
     248             :         // noel -- noticed this was called once and very slow -- sped up a little by caching keys
     249         794 :         InitializeTabularMonthly(state);
     250         794 :         if (isInvalidAggregationOrder(state)) {
     251           0 :             ShowFatalError(state, "OutputReportTabular: Invalid aggregations detected, no simulation performed.");
     252             :         }
     253         794 :         GetInputFuelAndPollutionFactors(state);
     254         794 :         SetupUnitConversions(state);
     255         794 :         AddTOCLoadComponentTableSummaries(state);
     256         794 :         ort->UpdateTabularReportsGetInput = false;
     257         794 :         date_and_time(_, _, _, ort->td);
     258             :     }
     259     1097533 :     if (state.dataGlobal->DoOutputReporting && ort->WriteTabularFiles && (state.dataGlobal->KindOfSim == Constant::KindOfSim::RunPeriodWeather)) {
     260      479981 :         if (t_timeStepType == OutputProcessor::TimeStepType::Zone) {
     261      210336 :             ort->gatherElapsedTimeBEPS += state.dataGlobal->TimeStepZone;
     262             :         }
     263      479981 :         if (state.dataGlobal->DoWeathSim) {
     264      479981 :             GatherMonthlyResultsForTimestep(state, t_timeStepType);
     265      479981 :             OutputReportTabularAnnual::GatherAnnualResultsForTimeStep(state, t_timeStepType);
     266      479981 :             GatherBinResultsForTimestep(state, t_timeStepType);
     267      479981 :             GatherBEPSResultsForTimestep(state, t_timeStepType);
     268      479981 :             GatherSourceEnergyEndUseResultsForTimestep(state, t_timeStepType);
     269      479981 :             GatherPeakDemandForTimestep(state, t_timeStepType);
     270      479981 :             GatherHeatGainReport(state, t_timeStepType);
     271      479981 :             GatherHeatEmissionReport(state, t_timeStepType);
     272             :         }
     273             :     }
     274     1097533 : }
     275             : 
     276             : //======================================================================================================================
     277             : //======================================================================================================================
     278             : 
     279             : //    GET INPUT ROUTINES
     280             : 
     281             : //======================================================================================================================
     282             : //======================================================================================================================
     283             : 
     284         794 : void GetInputTabularMonthly(EnergyPlusData &state)
     285             : {
     286             :     // SUBROUTINE INFORMATION:
     287             :     //       AUTHOR         Jason Glazer
     288             :     //       DATE WRITTEN   July 2003
     289             :     //       MODIFIED       na
     290             :     //       RE-ENGINEERED  na
     291             : 
     292             :     // PURPOSE OF THIS SUBROUTINE:
     293             :     //   The routine assigns the input information for
     294             :     //   REPORT:TABLE:MONTHLY also known as tabular monthly
     295             :     //   reports that are defined by the user. The input
     296             :     //   information is assigned to a data structure that
     297             :     //   is used for both user defined monthly reports and
     298             :     //   predefined monthly reports.
     299             : 
     300             :     // METHODOLOGY EMPLOYED:
     301             :     //   Uses get input structure and call to build up
     302             :     //   data on monthly reports.
     303             : 
     304             :     // REFERENCES:
     305             :     // na
     306             : 
     307             :     // USE STATEMENTS:
     308             :     // na
     309             : 
     310             :     // Locals
     311             :     // SUBROUTINE ARGUMENT DEFINITIONS:
     312             :     // na
     313             : 
     314             :     // SUBROUTINE PARAMETER DEFINITIONS:
     315         794 :     static std::string const CurrentModuleObject("Output:Table:Monthly");
     316             : 
     317             :     // INTERFACE BLOCK SPECIFICATIONS:
     318             :     // na
     319             : 
     320             :     // DERIVED TYPE DEFINITIONS:
     321             :     // na
     322             : 
     323             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     324         794 :     auto &ort = state.dataOutRptTab;
     325             : 
     326         794 :     if (!state.files.outputControl.writeTabular(state)) {
     327           1 :         ort->WriteTabularFiles = false;
     328         137 :         return;
     329             :     }
     330             : 
     331         793 :     ort->MonthlyInputCount = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     332         793 :     if (ort->MonthlyInputCount > 0) {
     333         136 :         ort->WriteTabularFiles = true;
     334             :         // if not a run period using weather do not create reports
     335         136 :         if (!state.dataGlobal->DoWeathSim) {
     336         272 :             ShowWarningError(
     337             :                 state,
     338         272 :                 format("{} requested with SimulationControl Run Simulation for Weather File Run Periods set to No so {} will not be generated",
     339             :                        CurrentModuleObject,
     340             :                        CurrentModuleObject));
     341         136 :             return;
     342             :         }
     343             :     }
     344             : 
     345         657 :     int NumParams = 0;        // Number of elements combined
     346         657 :     int NumAlphas = 0;        // Number of elements in the alpha array
     347         657 :     int NumNums = 0;          // Number of elements in the numeric array
     348         657 :     Array1D_string AlphArray; // character string data
     349         657 :     Array1D<Real64> NumArray; // numeric data
     350         657 :     int IOStat = -1;          // IO Status when calling get input subroutine
     351         657 :     bool ErrorsFound = false;
     352             : 
     353         657 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
     354         657 :     AlphArray.allocate(NumAlphas);
     355         657 :     NumArray.dimension(NumNums, 0.0);
     356         657 :     for (int TabNum = 1, TabNum_end = ort->MonthlyInputCount; TabNum <= TabNum_end; ++TabNum) { // MonthlyInputCount is modified in the loop
     357           0 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, TabNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
     358             : 
     359           0 :         if (TabNum - 1 > 0) {
     360           0 :             Util::IsNameEmpty(state, AlphArray(1), CurrentModuleObject, ErrorsFound);
     361             :         }
     362           0 :         if (NumAlphas < 2) {
     363           0 :             ShowSevereError(state, format("{}: No fields specified.", CurrentModuleObject));
     364             :         }
     365             :         // add to the data structure
     366           0 :         int const curTable = AddMonthlyReport(state, AlphArray(1), int(NumArray(1)));
     367           0 :         for (int jField = 2; jField <= NumAlphas; jField += 2) {
     368           0 :             if (AlphArray(jField).empty()) {
     369           0 :                 ShowWarningError(state,
     370           0 :                                  format("{}: Blank column specified in '{}', need to provide a variable or meter name ",
     371             :                                         CurrentModuleObject,
     372           0 :                                         ort->MonthlyInput(TabNum).name));
     373             :             }
     374           0 :             std::string const curAggString = AlphArray(jField + 1);
     375             :             AggType curAggType; // kind of aggregation identified (see AggType parameters)
     376             :             // set accumulator values to default as appropriate for aggregation type
     377           0 :             if (Util::SameString(curAggString, "SumOrAverage")) {
     378           0 :                 curAggType = AggType::SumOrAvg;
     379           0 :             } else if (Util::SameString(curAggString, "Maximum")) {
     380           0 :                 curAggType = AggType::Maximum;
     381           0 :             } else if (Util::SameString(curAggString, "Minimum")) {
     382           0 :                 curAggType = AggType::Minimum;
     383           0 :             } else if (Util::SameString(curAggString, "ValueWhenMaximumOrMinimum")) {
     384           0 :                 curAggType = AggType::ValueWhenMaxMin;
     385           0 :             } else if (Util::SameString(curAggString, "HoursZero")) {
     386           0 :                 curAggType = AggType::HoursZero;
     387           0 :             } else if (Util::SameString(curAggString, "HoursNonzero")) {
     388           0 :                 curAggType = AggType::HoursNonZero;
     389           0 :             } else if (Util::SameString(curAggString, "HoursPositive")) {
     390           0 :                 curAggType = AggType::HoursPositive;
     391           0 :             } else if (Util::SameString(curAggString, "HoursNonpositive")) {
     392           0 :                 curAggType = AggType::HoursNonPositive;
     393           0 :             } else if (Util::SameString(curAggString, "HoursNegative")) {
     394           0 :                 curAggType = AggType::HoursNegative;
     395           0 :             } else if (Util::SameString(curAggString, "HoursNonnegative")) {
     396           0 :                 curAggType = AggType::HoursNonNegative;
     397           0 :             } else if (Util::SameString(curAggString, "SumOrAverageDuringHoursShown")) {
     398           0 :                 curAggType = AggType::SumOrAverageHoursShown;
     399           0 :             } else if (Util::SameString(curAggString, "MaximumDuringHoursShown")) {
     400           0 :                 curAggType = AggType::MaximumDuringHoursShown;
     401           0 :             } else if (Util::SameString(curAggString, "MinimumDuringHoursShown")) {
     402           0 :                 curAggType = AggType::MinimumDuringHoursShown;
     403             :             } else {
     404           0 :                 curAggType = AggType::SumOrAvg;
     405           0 :                 ShowWarningError(state, format("{}={}, Variable name={}", CurrentModuleObject, ort->MonthlyInput(TabNum).name, AlphArray(jField)));
     406           0 :                 ShowContinueError(state, format("Invalid aggregation type=\"{}\"  Defaulting to SumOrAverage.", curAggString));
     407             :             }
     408           0 :             if (!AlphArray(jField).empty()) {
     409           0 :                 AddMonthlyFieldSetInput(state, curTable, AlphArray(jField), "", curAggType);
     410             :             }
     411           0 :         }
     412             :     }
     413         657 : }
     414             : 
     415        1515 : int AddMonthlyReport(EnergyPlusData &state, std::string const &inReportName, int const inNumDigitsShown, bool isNamedMonthly)
     416             : {
     417             :     // SUBROUTINE INFORMATION:
     418             :     //       AUTHOR         Jason Glazer
     419             :     //       DATE WRITTEN   August 2008
     420             :     //       MODIFIED
     421             :     //       RE-ENGINEERED  na
     422             : 
     423             :     // PURPOSE OF THIS SUBROUTINE:
     424             :     //   Creates a monthly report
     425             : 
     426             :     // METHODOLOGY EMPLOYED:
     427             :     // na
     428             : 
     429             :     // REFERENCES:
     430             :     // na
     431             : 
     432             :     // USE STATEMENTS:
     433             : 
     434             :     // Return value
     435             : 
     436             :     // Locals
     437             :     // SUBROUTINE ARGUMENT DEFINITIONS:
     438             :     // na
     439             : 
     440             :     // SUBROUTINE PARAMETER DEFINITIONS:
     441             : 
     442             :     // INTERFACE BLOCK SPECIFICATIONS:
     443             :     // na
     444             : 
     445             :     // DERIVED TYPE DEFINITIONS:
     446             :     // na
     447             : 
     448             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     449        1515 :     int constexpr SizeAdder(25);
     450        1515 :     auto &ort = state.dataOutRptTab;
     451             : 
     452        1515 :     if (!allocated(ort->MonthlyInput)) {
     453          26 :         ort->MonthlyInput.allocate(SizeAdder);
     454          26 :         ort->sizeMonthlyInput = SizeAdder;
     455          26 :         ort->MonthlyInputCount = 1;
     456             :     } else {
     457        1489 :         ++ort->MonthlyInputCount;
     458             :         // if larger than current size grow the array
     459        1489 :         if (ort->MonthlyInputCount > ort->sizeMonthlyInput) {
     460          48 :             ort->MonthlyInput.redimension(ort->sizeMonthlyInput += SizeAdder);
     461             :         }
     462             :     }
     463             :     // initialize new record
     464        1515 :     ort->MonthlyInput(ort->MonthlyInputCount).name = inReportName;
     465        1515 :     ort->MonthlyInput(ort->MonthlyInputCount).showDigits = inNumDigitsShown;
     466        1515 :     ort->MonthlyInput(ort->MonthlyInputCount).isNamedMonthly = isNamedMonthly;
     467        1515 :     return ort->MonthlyInputCount;
     468             : }
     469             : 
     470       10549 : void AddMonthlyFieldSetInput(
     471             :     EnergyPlusData &state, int const inMonthReport, std::string const &inVariMeter, std::string const &inColHead, AggType const inAggregate)
     472             : {
     473             :     // SUBROUTINE INFORMATION:
     474             :     //       AUTHOR         Jason Glazer
     475             :     //       DATE WRITTEN   August 2008
     476             :     //       MODIFIED
     477             :     //       RE-ENGINEERED  na
     478             : 
     479             :     // PURPOSE OF THIS SUBROUTINE:
     480             :     //   Assigns the column information for predefined
     481             :     //   monthly reports
     482             : 
     483             :     // METHODOLOGY EMPLOYED:
     484             :     //   Simple assignments to public variables.
     485             : 
     486             :     // REFERENCES:
     487             :     // na
     488             : 
     489             :     // USE STATEMENTS:
     490             : 
     491             :     // Locals
     492             :     // SUBROUTINE ARGUMENT DEFINITIONS:
     493             : 
     494             :     // SUBROUTINE PARAMETER DEFINITIONS:
     495       10549 :     int constexpr sizeIncrement(50);
     496       10549 :     auto &ort = state.dataOutRptTab;
     497             : 
     498             :     // INTERFACE BLOCK SPECIFICATIONS:
     499             :     // na
     500             : 
     501             :     // DERIVED TYPE DEFINITIONS:
     502             :     // na
     503             : 
     504             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     505             :     // na
     506             : 
     507       10549 :     if (!allocated(ort->MonthlyFieldSetInput)) {
     508          26 :         ort->MonthlyFieldSetInput.allocate(sizeIncrement);
     509          26 :         ort->sizeMonthlyFieldSetInput = sizeIncrement;
     510          26 :         ort->MonthlyFieldSetInputCount = 1;
     511             :     } else {
     512       10523 :         ++ort->MonthlyFieldSetInputCount;
     513             :         // if larger than current size grow the array
     514       10523 :         if (ort->MonthlyFieldSetInputCount > ort->sizeMonthlyFieldSetInput) {
     515          96 :             ort->MonthlyFieldSetInput.redimension(ort->sizeMonthlyFieldSetInput *=
     516             :                                                   2); // Tuned Changed += sizeIncrement to *= 2 for reduced heap allocations (at some space cost)
     517             :         }
     518             :     }
     519             :     // initialize new record)
     520       10549 :     ort->MonthlyFieldSetInput(ort->MonthlyFieldSetInputCount).variMeter = inVariMeter;
     521       10549 :     ort->MonthlyFieldSetInput(ort->MonthlyFieldSetInputCount).colHead = inColHead;
     522       10549 :     ort->MonthlyFieldSetInput(ort->MonthlyFieldSetInputCount).aggregate = inAggregate;
     523             :     // update the references from the MonthlyInput array
     524       10549 :     if ((inMonthReport > 0) && (inMonthReport <= ort->MonthlyInputCount)) {
     525       10549 :         if (ort->MonthlyInput(inMonthReport).firstFieldSet == 0) {
     526        1515 :             ort->MonthlyInput(inMonthReport).firstFieldSet = ort->MonthlyFieldSetInputCount;
     527        1515 :             ort->MonthlyInput(inMonthReport).numFieldSet = 1;
     528             :         } else {
     529        9034 :             ++ort->MonthlyInput(inMonthReport).numFieldSet;
     530             :         }
     531             :     }
     532       10549 : }
     533             : 
     534         794 : void InitializeTabularMonthly(EnergyPlusData &state)
     535             : {
     536             :     // SUBROUTINE INFORMATION:
     537             :     //       AUTHOR         Jason Glazer
     538             :     //       DATE WRITTEN   July 2008
     539             :     //       MODIFIED       na
     540             :     //       RE-ENGINEERED  na
     541             : 
     542             :     // PURPOSE OF THIS SUBROUTINE:
     543             :     //   This routine initializes the data structures based
     544             :     //   on input from either the IDF file or from the predefined
     545             :     //   monthly reports.  The data structures follow the IDD
     546             :     //   closely.  The routine initializes many of the arrays
     547             :     //   for monthly tables.
     548             : 
     549             :     // METHODOLOGY EMPLOYED:
     550             :     //   Process the data structures that define monthly tabular
     551             :     //   reports
     552             : 
     553             :     // NOTE:
     554             :     //   The bulk of this routine used to be part of the the
     555             :     //   GetInputTabularMonthly routine but when predefined
     556             :     //   monthly reports were added this routine was seperated
     557             :     //   from input.
     558             : 
     559             :     // REFERENCES:
     560             :     // na
     561             : 
     562             :     // USE STATEMENTS:
     563             :     // na
     564             : 
     565             :     // Locals
     566             :     // SUBROUTINE ARGUMENT DEFINITIONS:
     567             :     // na
     568             : 
     569             :     // SUBROUTINE PARAMETER DEFINITIONS:
     570             :     // na
     571             : 
     572             :     // INTERFACE BLOCK SPECIFICATIONS:
     573             :     // na
     574             : 
     575             :     // DERIVED TYPE DEFINITIONS:
     576             :     // na
     577             : 
     578             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     579             :     OutputProcessor::VariableType TypeVar;
     580             :     OutputProcessor::StoreType AvgSumVar;
     581             :     OutputProcessor::TimeStepType StepTypeVar;
     582         794 :     Constant::Units UnitsVar = Constant::Units::None; // Units enum
     583         794 :     Array1D_string UniqueKeyNames;
     584             :     int found;
     585         794 :     auto &ort = state.dataOutRptTab;
     586             : 
     587             :     // if not a running a weather simulation do not create reports
     588         794 :     if (!state.dataGlobal->DoWeathSim) {
     589         788 :         return;
     590             :     }
     591           6 :     ort->maxUniqueKeyCount = 1500;
     592           6 :     UniqueKeyNames.allocate(ort->maxUniqueKeyCount);
     593             :     // First pass through the input objects is to put the name of the report
     594             :     // into the array and count the number of unique keys found to allocate
     595             :     // the monthlyTables and monthlyColumns
     596             :     // This approach seems inefficient but I know of no other way to size
     597             :     // the arrays prior to filling them and to size the arrays basically
     598             :     // the same steps must be gone through as with filling the arrays.
     599             : 
     600             :     // #ifdef ITM_KEYCACHE
     601             :     //  Noel comment:  How about allocating these variables once for the whole routine?
     602             :     //     Again, if a max value for key count can be agreed upon, we could use it here --
     603             :     //     otherwise, will have to have re-allocate logic.
     604             :     //  maxKeyCount=1500 ! ?
     605             :     //  ALLOCATE(NamesOfKeys(maxKeyCount))
     606             :     //  ALLOCATE(IndexesForKeyVar(maxKeyCount))
     607             :     // #endif
     608             : 
     609           6 :     ort->MonthlyColumnsCount = 0;
     610           6 :     ort->MonthlyTablesCount = 0;
     611           6 :     for (int TabNum = 1; TabNum <= ort->MonthlyInputCount; ++TabNum) {
     612             :         // the number of columns based on number of alpha fields
     613           0 :         int const NumColumns = ort->MonthlyInput(TabNum).numFieldSet;
     614           0 :         int const FirstColumn = ort->MonthlyInput(TabNum).firstFieldSet;
     615           0 :         bool environmentKeyFound = false;
     616           0 :         int UniqueKeyCount = 0;
     617           0 :         for (int colNum = 1; colNum <= NumColumns; ++colNum) {
     618             : 
     619             :             // #ifdef ITM_KEYCACHE
     620             :             //  Noel comment:  First time in this TabNum/ColNum loop, let's save the results
     621             :             //   of GetVariableKeyCountandType & GetVariableKeys.
     622           0 :             std::string const curVariMeter = Util::makeUPPER(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).variMeter);
     623             :             // call the key count function but only need count during this pass
     624           0 :             int KeyCount = 0;
     625           0 :             GetVariableKeyCountandType(state, curVariMeter, KeyCount, TypeVar, AvgSumVar, StepTypeVar, UnitsVar);
     626           0 :             if (TypeVar == OutputProcessor::VariableType::Invalid) { // TODO: This NotFound thing has to go
     627           0 :                 if (!ort->MonthlyInput(TabNum).isNamedMonthly) {
     628           0 :                     ++state.dataOutRptTab->ErrCount1;
     629             :                 }
     630             :             }
     631             :             //    IF (KeyCount > maxKeyCount) THEN
     632             :             //      DEALLOCATE(NamesOfKeys)
     633             :             //      DEALLOCATE(IndexesForKeyVar)
     634             :             //      maxKeyCount=KeyCount
     635             :             //      ALLOCATE(NamesOfKeys(maxKeyCount))
     636             :             //      ALLOCATE(IndexesForKeyVar(maxKeyCount))
     637             :             //    ENDIF
     638             : 
     639             :             // save these values to use later -- noel
     640           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).variMeterUpper = curVariMeter;
     641           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).typeOfVar = TypeVar;
     642           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).keyCount = KeyCount;
     643           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varAvgSum = AvgSumVar;
     644           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varStepType = StepTypeVar;
     645           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varUnits = UnitsVar;
     646             : 
     647           0 :             if (TypeVar == OutputProcessor::VariableType::Invalid) {
     648           0 :                 continue;
     649             :             }
     650             : 
     651           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys.allocate(KeyCount);
     652           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).IndexesForKeyVar.allocate(KeyCount);
     653             : 
     654             :             // fill keys?
     655           0 :             GetVariableKeys(state,
     656             :                             curVariMeter,
     657             :                             TypeVar,
     658           0 :                             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys,
     659           0 :                             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).IndexesForKeyVar);
     660             : 
     661             :             //    DO iKey = 1, KeyCount
     662             :             //      MonthlyFieldSetInput(FirstColumn + ColNum - 1)%NamesOfKeys(iKey) = NamesOfKeys(iKey)  !noel
     663             :             //      MonthlyFieldSetInput(FirstColumn + ColNum - 1)%IndexesForKeyVar(iKey) = IndexesForKeyVar(iKey)  !noel
     664             :             //    ENDDO
     665             :             // #else
     666             :             //    curVariMeter = Util::makeUPPER(MonthlyFieldSetInput(FirstColumn + ColNum - 1)%variMeter)
     667             :             //    ! call the key count function but only need count during this pass
     668             :             //    CALL GetVariableKeyCountandType(state, curVariMeter,KeyCount,TypeVar,AvgSumVar,StepTypeVar,UnitsVar)
     669             :             //    ALLOCATE(NamesOfKeys(KeyCount))
     670             :             //    ALLOCATE(IndexesForKeyVar(KeyCount))
     671             :             //    CALL GetVariableKeys(state, curVariMeter,TypeVar,NamesOfKeys,IndexesForKeyVar)
     672             :             // #endif
     673             : 
     674           0 :             for (int iKey = 1; iKey <= KeyCount; ++iKey) {
     675           0 :                 found = 0;
     676             :                 // set a flag if environment variables are found
     677           0 :                 if (Util::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey), "ENVIRONMENT")) {
     678           0 :                     environmentKeyFound = true;
     679           0 :                     found = -1; // so not counted in list of unique keys
     680             :                 }
     681           0 :                 for (int jUnique = 1; jUnique <= UniqueKeyCount; ++jUnique) {
     682           0 :                     if (Util::SameString(UniqueKeyNames(jUnique), ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey))) {
     683           0 :                         found = jUnique;
     684           0 :                         break;
     685             :                     }
     686             :                 }
     687           0 :                 if (found == 0) {
     688           0 :                     ++UniqueKeyCount;
     689           0 :                     if (UniqueKeyCount > ort->maxUniqueKeyCount) {
     690           0 :                         UniqueKeyNames.redimension(ort->maxUniqueKeyCount += 500);
     691             :                     }
     692           0 :                     UniqueKeyNames(UniqueKeyCount) = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey);
     693             :                 }
     694             :             }
     695             :             // #ifdef ITM_KEYCACHE
     696             :             //     ! Don't deallocate here, only allocating/deallocating once for the whole routine
     697             :             // #else
     698             :             //     DEALLOCATE(NamesOfKeys)
     699             :             //     DEALLOCATE(IndexesForKeyVar)
     700             :             // #endif
     701           0 :         } // colNum
     702             :         // fix for CR8285 - when monthly report is only environmental variables
     703           0 :         if (environmentKeyFound && UniqueKeyCount == 0) {
     704           0 :             UniqueKeyCount = 1;
     705             :         }
     706             :         // increment the number of tables based on the number of unique keys
     707           0 :         ort->MonthlyTablesCount += UniqueKeyCount;
     708           0 :         ort->MonthlyColumnsCount += UniqueKeyCount * NumColumns;
     709             :     } // TabNum the end of the loop through the inputs objects
     710             :     // Now that we have the maximum size of the number of tables (each table is
     711             :     // repeated for the number of keys found) and the number of total columns
     712             :     // of all of the tables, allocate the arrays to store this information.
     713           6 :     ort->MonthlyTables.allocate(ort->MonthlyTablesCount);
     714           6 :     ort->MonthlyColumns.allocate(ort->MonthlyColumnsCount);
     715             :     // Initialize tables and results
     716           6 :     for (auto &e : ort->MonthlyTables) {
     717           0 :         e.keyValue.clear();
     718           0 :         e.firstColumn = 0;
     719           0 :         e.numColumns = 0;
     720             :     }
     721             : 
     722           6 :     for (auto &e : ort->MonthlyColumns) {
     723           0 :         e.varName.clear();
     724           0 :         e.varNum = 0;
     725           0 :         e.typeOfVar = OutputProcessor::VariableType::Invalid;
     726           0 :         e.avgSum = OutputProcessor::StoreType::Average;
     727           0 :         e.stepType = OutputProcessor::TimeStepType::Zone;
     728           0 :         e.units = Constant::Units::None;
     729           0 :         e.aggType = AggType::Invalid;
     730             :     }
     731           6 :     for (int colNum = 1; colNum <= ort->MonthlyColumnsCount; ++colNum) {
     732           0 :         ort->MonthlyColumns(colNum).reslt = 0.0;
     733           0 :         ort->MonthlyColumns(colNum).timeStamp = 0;
     734           0 :         ort->MonthlyColumns(colNum).duration = 0.0;
     735             :     }
     736             : 
     737             :     // If no weather file run requested, don't bother issuing a warning
     738           6 :     bool issueWarnings = false;
     739           6 :     if (state.dataGlobal->DoWeathSim && (state.dataOutRptTab->ErrCount1 > 0)) {
     740           0 :         ShowWarningError(state, "Processing Monthly Tabular Reports: Variable names not valid for this simulation");
     741             : 
     742           0 :         if (!state.dataGlobal->DisplayExtraWarnings) {
     743           0 :             ShowContinueError(state, "...use Output:Diagnostics,DisplayExtraWarnings; to show more details on individual variables.");
     744             :         } else {
     745           0 :             ShowContinueError(state,
     746             :                               "..Variables not valid for this simulation will have \"[Invalid/Undefined]\" in the Units Column of "
     747             :                               "the Table Report.");
     748           0 :             issueWarnings = true;
     749             :         }
     750             :     }
     751             : 
     752           6 :     int ColumnsRecount = 0;
     753           6 :     int TablesRecount = 0;
     754           6 :     for (int TabNum = 1; TabNum <= ort->MonthlyInputCount; ++TabNum) {
     755             :         // the number of columns based on number of alpha fields
     756           0 :         int const NumColumns = ort->MonthlyInput(TabNum).numFieldSet;
     757           0 :         int FirstColumn = ort->MonthlyInput(TabNum).firstFieldSet;
     758           0 :         int UniqueKeyCount = 0;
     759           0 :         bool environmentKeyFound = false;
     760           0 :         for (int colNum = 1; colNum <= NumColumns; ++colNum) {
     761           0 :             std::string const &curVariMeter = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).variMeterUpper;
     762           0 :             const int KeyCount = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).keyCount;
     763           0 :             TypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).typeOfVar;
     764           0 :             AvgSumVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varAvgSum;
     765           0 :             StepTypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varStepType;
     766           0 :             UnitsVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varUnits;
     767             : 
     768           0 :             if (KeyCount == 0 && issueWarnings && !ort->MonthlyInput(TabNum).isNamedMonthly) {
     769           0 :                 ShowWarningError(
     770           0 :                     state, format("In Output:Table:Monthly '{}' invalid Variable or Meter Name '{}'", ort->MonthlyInput(TabNum).name, curVariMeter));
     771             :             }
     772           0 :             for (int iKey = 1; iKey <= KeyCount; ++iKey) {
     773           0 :                 found = 0;
     774             :                 // set a flag if environment variables are found
     775           0 :                 if (Util::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey), "ENVIRONMENT")) {
     776           0 :                     environmentKeyFound = true;
     777           0 :                     found = -1; // so not counted in list of unique keys
     778             :                 }
     779           0 :                 for (int jUnique = 1; jUnique <= UniqueKeyCount; ++jUnique) {
     780           0 :                     if (Util::SameString(UniqueKeyNames(jUnique), ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey))) {
     781           0 :                         found = jUnique;
     782           0 :                         break;
     783             :                     }
     784             :                 }
     785           0 :                 if (found == 0) {
     786           0 :                     ++UniqueKeyCount;
     787           0 :                     UniqueKeyNames(UniqueKeyCount) = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey);
     788             :                 }
     789             :             }
     790             :             // #ifdef ITM_KEYCACHE
     791             :             //     ! Don't deallocate here, only allocating/deallocating once for the whole routine
     792             :             // #else
     793             :             //     DEALLOCATE(NamesOfKeys)
     794             :             //     DEALLOCATE(IndexesForKeyVar)
     795             :             // #endif
     796             :         }
     797             :         // fix for CR8285 - when monthly report is only environmental variables
     798           0 :         if (environmentKeyFound && UniqueKeyCount == 0) {
     799           0 :             UniqueKeyCount = 1;
     800             :         }
     801             :         // increment the number of tables based on the number of unique keys
     802           0 :         ort->MonthlyInput(TabNum).firstTable = TablesRecount + 1;
     803           0 :         ort->MonthlyInput(TabNum).numTables = UniqueKeyCount;
     804           0 :         TablesRecount += UniqueKeyCount;
     805             :         // loop through the different unique keys since each user defined table
     806             :         // has that many instances - one for each unique key.
     807             :         // It is unusual that this loop is about 'keys' and an inner loop is also
     808             :         // about 'keys' but for this loop the keys are really instances of tables.
     809           0 :         for (int kUniqueKey = 1; kUniqueKey <= UniqueKeyCount; ++kUniqueKey) {
     810           0 :             int const lTable = kUniqueKey + ort->MonthlyInput(TabNum).firstTable - 1;
     811             :             // use the term 'environment' for identifying the report if
     812           0 :             if (environmentKeyFound && UniqueKeyCount == 1) {
     813           0 :                 ort->MonthlyTables(lTable).keyValue = "Environment";
     814             :             } else { // this is the most common case is to use the unique key for the report
     815           0 :                 ort->MonthlyTables(lTable).keyValue = UniqueKeyNames(kUniqueKey);
     816             :             }
     817           0 :             ort->MonthlyTables(lTable).firstColumn = ColumnsRecount + 1;
     818           0 :             ort->MonthlyTables(lTable).numColumns = NumColumns;
     819           0 :             ColumnsRecount += NumColumns;
     820           0 :             FirstColumn = ort->MonthlyInput(TabNum).firstFieldSet;
     821           0 :             for (int colNum = 1; colNum <= NumColumns; ++colNum) {
     822           0 :                 environmentKeyFound = false;
     823           0 :                 int const mColumn = colNum + ort->MonthlyTables(lTable).firstColumn - 1;
     824             :                 // when going through the columns this time, not all columns may have
     825             :                 // a EP variable that corresponds to it.  In no variable is found
     826             :                 // then set it to 0 to be skipped during data gathering
     827             : 
     828             :                 // #ifdef ITM_KEYCACHE
     829             :                 //  Noel comment:  Here is where we could use the saved values
     830           0 :                 std::string const &curVariMeter = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).variMeterUpper;
     831           0 :                 int const KeyCount = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).keyCount;
     832           0 :                 TypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).typeOfVar;
     833           0 :                 AvgSumVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varAvgSum;
     834           0 :                 StepTypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varStepType;
     835           0 :                 UnitsVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varUnits;
     836             :                 //    DO iKey = 1, KeyCount  !noel
     837             :                 //       NamesOfKeys(iKey) = MonthlyFieldSetInput(FirstColumn + ColNum - 1)%NamesOfKeys(iKey)  !noel
     838             :                 //       IndexesForKeyVar(iKey) = MonthlyFieldSetInput(FirstColumn + ColNum - 1)%IndexesForKeyVar(iKey) !noel
     839             :                 //    ENDDO
     840             :                 // #else
     841             :                 //    curVariMeter = Util::makeUPPER(MonthlyFieldSetInput(FirstColumn + ColNum - 1)%variMeter)
     842             :                 //    ! call the key count function but only need count during this pass
     843             :                 //    CALL GetVariableKeyCountandType(state, curVariMeter,KeyCount,TypeVar,AvgSumVar,StepTypeVar,UnitsVar)
     844             :                 //    ALLOCATE(NamesOfKeys(KeyCount))
     845             :                 //    ALLOCATE(IndexesForKeyVar(KeyCount))
     846             :                 //    CALL GetVariableKeys(state, curVariMeter,TypeVar,NamesOfKeys,IndexesForKeyVar)
     847             :                 // #endif
     848             : 
     849           0 :                 if (KeyCount == 1) { // first test if KeyCount is one to avoid referencing a zero element array
     850           0 :                     if (Util::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(1), "ENVIRONMENT")) {
     851           0 :                         environmentKeyFound = true;
     852             :                     }
     853             :                 }
     854             :                 // if this is an environment variable - don't bother searching
     855           0 :                 if (environmentKeyFound) {
     856           0 :                     found = 1; // only one instance of environment variables so use it.
     857             :                 } else {
     858             :                     // search through the keys for the currently active key "UniqueKeyNames(kUniqueKey)"
     859           0 :                     found = 0;
     860           0 :                     for (int iKey = 1; iKey <= KeyCount; ++iKey) {
     861           0 :                         if (Util::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey), UniqueKeyNames(kUniqueKey))) {
     862           0 :                             found = iKey;
     863           0 :                             break;
     864             :                         }
     865             :                     }
     866             :                 }
     867           0 :                 if ((found > 0) && (KeyCount >= 1)) {
     868           0 :                     ort->MonthlyColumns(mColumn).varName = curVariMeter;
     869           0 :                     ort->MonthlyColumns(mColumn).varNum = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).IndexesForKeyVar(found);
     870           0 :                     ort->MonthlyColumns(mColumn).typeOfVar = TypeVar;
     871           0 :                     ort->MonthlyColumns(mColumn).avgSum = AvgSumVar;
     872           0 :                     ort->MonthlyColumns(mColumn).stepType = StepTypeVar;
     873           0 :                     ort->MonthlyColumns(mColumn).units = UnitsVar;
     874           0 :                     ort->MonthlyColumns(mColumn).aggType = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).aggregate;
     875             :                     // set accumulator values to default as appropriate for aggregation type
     876           0 :                     switch (ort->MonthlyColumns(mColumn).aggType) {
     877           0 :                     case AggType::SumOrAvg: {
     878           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     879           0 :                         ort->MonthlyColumns(mColumn).duration = 0.0;
     880           0 :                     } break;
     881           0 :                     case AggType::Maximum: {
     882           0 :                         ort->MonthlyColumns(mColumn).reslt = -HUGE_(state.dataOutRptTab->BigNum);
     883           0 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     884           0 :                     } break;
     885           0 :                     case AggType::Minimum: {
     886           0 :                         ort->MonthlyColumns(mColumn).reslt = HUGE_(state.dataOutRptTab->BigNum);
     887           0 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     888           0 :                     } break;
     889           0 :                     case AggType::ValueWhenMaxMin: {
     890           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     891           0 :                     } break;
     892           0 :                     case AggType::HoursZero: {
     893           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     894           0 :                     } break;
     895           0 :                     case AggType::HoursNonZero: {
     896           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     897           0 :                     } break;
     898           0 :                     case AggType::HoursPositive: {
     899           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     900           0 :                     } break;
     901           0 :                     case AggType::HoursNonPositive: {
     902           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     903           0 :                     } break;
     904           0 :                     case AggType::HoursNegative: {
     905           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     906           0 :                     } break;
     907           0 :                     case AggType::HoursNonNegative: {
     908           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     909           0 :                     } break;
     910           0 :                     case AggType::SumOrAverageHoursShown: {
     911           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     912           0 :                         ort->MonthlyColumns(mColumn).duration = 0.0;
     913           0 :                     } break;
     914           0 :                     case AggType::MaximumDuringHoursShown: {
     915           0 :                         ort->MonthlyColumns(mColumn).reslt = -HUGE_(state.dataOutRptTab->BigNum);
     916           0 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     917           0 :                     } break;
     918           0 :                     case AggType::MinimumDuringHoursShown: {
     919           0 :                         ort->MonthlyColumns(mColumn).reslt = HUGE_(state.dataOutRptTab->BigNum);
     920           0 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     921           0 :                     } break;
     922           0 :                     default:
     923           0 :                         break;
     924             :                     }
     925             :                 } else { // if no key corresponds to this instance of the report
     926             :                     // fixing CR5878 removed the showing of the warning once about a specific variable.
     927           0 :                     if (issueWarnings && !ort->MonthlyInput(TabNum).isNamedMonthly) {
     928           0 :                         ShowWarningError(
     929             :                             state,
     930           0 :                             format("In Output:Table:Monthly '{}' invalid Variable or Meter Name '{}'", ort->MonthlyInput(TabNum).name, curVariMeter));
     931           0 :                         ShowContinueError(
     932           0 :                             state, format("..i.e., Variable name={}:{} not valid for this simulation.", UniqueKeyNames(kUniqueKey), curVariMeter));
     933             :                     }
     934           0 :                     ort->MonthlyColumns(mColumn).varName = curVariMeter;
     935           0 :                     ort->MonthlyColumns(mColumn).varNum = 0;
     936           0 :                     ort->MonthlyColumns(mColumn).typeOfVar = OutputProcessor::VariableType::Invalid;
     937           0 :                     ort->MonthlyColumns(mColumn).avgSum = OutputProcessor::StoreType::Average;
     938           0 :                     ort->MonthlyColumns(mColumn).stepType = OutputProcessor::TimeStepType::Zone;
     939           0 :                     ort->MonthlyColumns(mColumn).units = Constant::Units::None;
     940           0 :                     ort->MonthlyColumns(mColumn).aggType = AggType::SumOrAvg;
     941             :                 }
     942             :                 // #ifdef ITM_KEYCACHE
     943             :                 // #else
     944             :                 //     DEALLOCATE(NamesOfKeys)
     945             :                 //     DEALLOCATE(IndexesForKeyVar)
     946             :                 // #endif
     947             :             } // ColNum
     948             :         }     // kUniqueKey
     949             :     }         // TabNum the end of the loop through the inputs objects
     950             : 
     951             :     // #ifdef ITM_KEYCACHE
     952             :     //  DEALLOCATE(NamesOfKeys)
     953             :     //  DEALLOCATE(IndexesForKeyVar)
     954             :     // #endif
     955         794 : }
     956             : 
     957         794 : bool isInvalidAggregationOrder(EnergyPlusData &state)
     958             : {
     959         794 :     auto &ort = state.dataOutRptTab;
     960         794 :     bool foundError = false;
     961         794 :     if (!state.dataGlobal->DoWeathSim) { // if no weather simulation than no reading of MonthlyInput array
     962         788 :         return foundError;
     963             :     }
     964           6 :     for (int iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
     965           0 :         bool foundMinOrMax = false;
     966           0 :         bool foundHourAgg = false;
     967           0 :         bool missingMaxOrMinError = false;
     968           0 :         bool missingHourAggError = false;
     969           0 :         for (int jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
     970           0 :             int curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
     971             :             // test if the aggregation types are in the correct order
     972           0 :             for (int kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
     973           0 :                 int curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
     974           0 :                 if (ort->MonthlyColumns(curCol).varNum == 0) break; // if no variable was ever found than stop checking
     975           0 :                 AggType curAggType = ort->MonthlyColumns(curCol).aggType;
     976           0 :                 if ((curAggType == AggType::Maximum) || (curAggType == AggType::Minimum)) {
     977           0 :                     foundMinOrMax = true;
     978           0 :                 } else if ((curAggType == AggType::HoursNonZero) || (curAggType == AggType::HoursZero) || (curAggType == AggType::HoursPositive) ||
     979           0 :                            (curAggType == AggType::HoursNonPositive) || (curAggType == AggType::HoursNegative) ||
     980             :                            (curAggType == AggType::HoursNonNegative)) {
     981           0 :                     foundHourAgg = true;
     982           0 :                 } else if (curAggType == AggType::ValueWhenMaxMin) {
     983           0 :                     if (!foundMinOrMax) {
     984           0 :                         missingMaxOrMinError = true;
     985             :                     }
     986           0 :                 } else if ((curAggType == AggType::SumOrAverageHoursShown) || (curAggType == AggType::MaximumDuringHoursShown) ||
     987             :                            (curAggType == AggType::MinimumDuringHoursShown)) {
     988           0 :                     if (!foundHourAgg) {
     989           0 :                         missingHourAggError = true;
     990             :                     }
     991             :                 }
     992             :             }
     993             :         }
     994           0 :         if (missingMaxOrMinError) {
     995           0 :             ShowSevereError(state,
     996           0 :                             format("The Output:Table:Monthly report named=\"{}\" has a valueWhenMaxMin aggregation type for a column without a "
     997             :                                    "previous column that uses either the minimum or maximum aggregation types. The report will not be generated.",
     998           0 :                                    ort->MonthlyInput(iInput).name));
     999           0 :             foundError = true;
    1000             :         }
    1001           0 :         if (missingHourAggError) {
    1002           0 :             ShowSevereError(state,
    1003           0 :                             format("The Output:Table:Monthly report named=\"{}\" has a --DuringHoursShown aggregation type for a column without a "
    1004             :                                    "previous field that uses one of the Hour-- aggregation types. The report will not be generated.",
    1005           0 :                                    ort->MonthlyInput(iInput).name));
    1006           0 :             foundError = true;
    1007             :         }
    1008             :     }
    1009           6 :     return foundError;
    1010             : }
    1011             : 
    1012         794 : void GetInputTabularTimeBins(EnergyPlusData &state)
    1013             : {
    1014             :     // SUBROUTINE INFORMATION:
    1015             :     //       AUTHOR         Jason Glazer
    1016             :     //       DATE WRITTEN   July 2003
    1017             :     //       MODIFIED       na
    1018             :     //       RE-ENGINEERED  na
    1019             : 
    1020             :     // PURPOSE OF THIS SUBROUTINE:
    1021             :     //   This routine initializes the data structures based
    1022             :     //   on input from in the IDF file.  The data structures
    1023             :     //   follow the IDD closely.
    1024             : 
    1025             :     // METHODOLOGY EMPLOYED:
    1026             :     //   Uses get input structure similar to other objects
    1027             : 
    1028             :     // REFERENCES:
    1029             :     // na
    1030             : 
    1031             :     // Using/Aliasing
    1032             :     using ScheduleManager::GetScheduleIndex;
    1033             : 
    1034             :     // Locals
    1035             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    1036             :     // na
    1037             : 
    1038             :     // SUBROUTINE PARAMETER DEFINITIONS:
    1039         794 :     static std::string const CurrentModuleObject("Output:Table:TimeBins");
    1040             : 
    1041             :     // INTERFACE BLOCK SPECIFICATIONS:
    1042             :     // na
    1043             : 
    1044             :     // DERIVED TYPE DEFINITIONS:
    1045             :     // na
    1046             : 
    1047             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1048         794 :     int NumParams = 0;            // Number of elements combined
    1049         794 :     int NumAlphas = 0;            // Number of elements in the alpha array
    1050         794 :     int NumNums = 0;              // Number of elements in the numeric array
    1051         794 :     Array1D_string AlphArray;     // character string data
    1052         794 :     Array1D<Real64> NumArray;     // numeric data
    1053         794 :     int IOStat = -1;              // IO Status when calling get input subroutine
    1054         794 :     Real64 constexpr bigVal(0.0); // used with HUGE: Value doesn't matter, only type: Initialize so compiler doesn't warn about use uninitialized
    1055             : 
    1056         794 :     Array1D_int objVarIDs;
    1057         794 :     Array1D_string objNames;
    1058             : 
    1059         794 :     auto &ort = state.dataOutRptTab;
    1060             : 
    1061         794 :     if (!state.files.outputControl.writeTabular(state)) {
    1062           1 :         ort->WriteTabularFiles = false;
    1063           1 :         return;
    1064             :     }
    1065             : 
    1066         793 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1067         793 :     AlphArray.allocate(NumAlphas);
    1068         793 :     NumArray.dimension(NumNums, 0.0);
    1069             : 
    1070         793 :     ort->timeInYear = 0.0; // initialize the time in year counter
    1071             :     // determine size of array that holds the IDF description
    1072         793 :     ort->OutputTableBinnedCount = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1073         793 :     ort->OutputTableBinned.allocate(ort->OutputTableBinnedCount);
    1074         793 :     if (ort->OutputTableBinnedCount > 0) {
    1075          57 :         ort->WriteTabularFiles = true;
    1076             :         // if not a run period using weather do not create reports
    1077          57 :         if (!state.dataGlobal->DoWeathSim) {
    1078         114 :             ShowWarningError(
    1079             :                 state,
    1080         114 :                 format("{} requested with SimulationControl Run Simulation for Weather File Run Periods set to No so {} will not be generated",
    1081             :                        CurrentModuleObject,
    1082             :                        CurrentModuleObject));
    1083          57 :             return;
    1084             :         }
    1085             :     }
    1086             :     // looking for maximum number of intervals for sizing
    1087         736 :     ort->BinResultsIntervalCount = 0;
    1088         736 :     ort->BinResultsTableCount = 0;
    1089         736 :     for (int iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    1090           0 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1091             :                                                                  CurrentModuleObject,
    1092             :                                                                  iInObj,
    1093             :                                                                  AlphArray,
    1094             :                                                                  NumAlphas,
    1095             :                                                                  NumArray,
    1096             :                                                                  NumNums,
    1097             :                                                                  IOStat,
    1098           0 :                                                                  state.dataIPShortCut->lNumericFieldBlanks,
    1099           0 :                                                                  state.dataIPShortCut->lAlphaFieldBlanks,
    1100           0 :                                                                  state.dataIPShortCut->cAlphaFieldNames,
    1101           0 :                                                                  state.dataIPShortCut->cNumericFieldNames);
    1102           0 :         ort->OutputTableBinned(iInObj).keyValue = AlphArray(1);
    1103           0 :         ort->OutputTableBinned(iInObj).varOrMeter = AlphArray(2);
    1104             :         // if a schedule has been specified assign
    1105           0 :         if (len(AlphArray(3)) > 0) {
    1106           0 :             ort->OutputTableBinned(iInObj).ScheduleName = AlphArray(3);
    1107           0 :             ort->OutputTableBinned(iInObj).scheduleIndex = GetScheduleIndex(state, AlphArray(3));
    1108           0 :             if (ort->OutputTableBinned(iInObj).scheduleIndex == 0) {
    1109           0 :                 ShowWarningError(
    1110             :                     state,
    1111           0 :                     format("{}: invalid {}=\"{}\" - not found.", CurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(3), AlphArray(3)));
    1112             :             }
    1113             :         } else {
    1114           0 :             ort->OutputTableBinned(iInObj).scheduleIndex = 0; // flag value for no schedule used
    1115             :         }
    1116             :         // validate the kind of variable - not used internally except for validation
    1117           0 :         if (len(AlphArray(4)) > 0) {
    1118           0 :             if (!(Util::SameString(AlphArray(4), "ENERGY") || Util::SameString(AlphArray(4), "DEMAND") ||
    1119           0 :                   Util::SameString(AlphArray(4), "TEMPERATURE") || Util::SameString(AlphArray(4), "FLOWRATE"))) {
    1120           0 :                 ShowWarningError(
    1121             :                     state,
    1122           0 :                     format("In {} named {} the Variable Type was not energy, demand, temperature, or flowrate.", CurrentModuleObject, AlphArray(1)));
    1123             :             }
    1124             :         }
    1125           0 :         ort->OutputTableBinned(iInObj).intervalStart = NumArray(1);
    1126           0 :         ort->OutputTableBinned(iInObj).intervalSize = NumArray(2);
    1127           0 :         ort->OutputTableBinned(iInObj).intervalCount = int(NumArray(3));
    1128             :         // valid range checking on inputs
    1129           0 :         if (ort->OutputTableBinned(iInObj).intervalCount < 1) {
    1130           0 :             ort->OutputTableBinned(iInObj).intervalCount = 1;
    1131             :         }
    1132           0 :         if (ort->OutputTableBinned(iInObj).intervalCount > 20) {
    1133           0 :             ort->OutputTableBinned(iInObj).intervalCount = 20;
    1134             :         }
    1135           0 :         if (ort->OutputTableBinned(iInObj).intervalSize < 0) {
    1136           0 :             ort->OutputTableBinned(iInObj).intervalSize = 1000.0;
    1137             :         }
    1138           0 :         ort->OutputTableBinned(iInObj).resIndex = ort->BinResultsTableCount + 1; // the next results report
    1139             :         // find maximum number of intervals
    1140           0 :         if (ort->OutputTableBinned(iInObj).intervalCount > ort->BinResultsIntervalCount) {
    1141           0 :             ort->BinResultsIntervalCount = ort->OutputTableBinned(iInObj).intervalCount;
    1142             :         }
    1143           0 :         GetVariableKeyCountandType(state,
    1144           0 :                                    ort->OutputTableBinned(iInObj).varOrMeter,
    1145           0 :                                    ort->OutputTableBinned(iInObj).numTables,
    1146           0 :                                    ort->OutputTableBinned(iInObj).typeOfVar,
    1147           0 :                                    ort->OutputTableBinned(iInObj).avgSum,
    1148           0 :                                    ort->OutputTableBinned(iInObj).stepType,
    1149           0 :                                    ort->OutputTableBinned(iInObj).units);
    1150           0 :         if (ort->OutputTableBinned(iInObj).typeOfVar == OutputProcessor::VariableType::Invalid) {
    1151           0 :             ShowWarningError(
    1152           0 :                 state, format("{}: User specified meter or variable not found: {}", CurrentModuleObject, ort->OutputTableBinned(iInObj).varOrMeter));
    1153             :         }
    1154             :         // If only a single table key is requested than only one should be counted
    1155             :         // later will reset the numTables array pointer but for now use it to know
    1156             :         // how many items to scan through
    1157           0 :         if (ort->OutputTableBinned(iInObj).keyValue == "*") {
    1158           0 :             ort->BinResultsTableCount += ort->OutputTableBinned(iInObj).numTables;
    1159             :         } else {
    1160           0 :             ++ort->BinResultsTableCount; // if a particular key is requested then only one more report
    1161             :         }
    1162             :     }
    1163             :     // size the arrays that holds the bin results
    1164         736 :     ort->BinResults.allocate(ort->BinResultsIntervalCount, ort->BinResultsTableCount);
    1165         736 :     ort->BinResultsBelow.allocate(ort->BinResultsTableCount);
    1166         736 :     ort->BinResultsAbove.allocate(ort->BinResultsTableCount);
    1167         736 :     ort->BinStatistics.allocate(ort->BinResultsTableCount);
    1168         736 :     ort->BinObjVarID.allocate(ort->BinResultsTableCount);
    1169             :     // now that the arrays are sized go back and fill in
    1170             :     // what ID numbers are used for each table
    1171         736 :     for (int iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    1172           0 :         int firstReport = ort->OutputTableBinned(iInObj).resIndex;
    1173             :         // allocate the arrays to the number of objects
    1174           0 :         objVarIDs.allocate(ort->OutputTableBinned(iInObj).numTables);
    1175           0 :         objNames.allocate(ort->OutputTableBinned(iInObj).numTables);
    1176           0 :         GetVariableKeys(state, ort->OutputTableBinned(iInObj).varOrMeter, ort->OutputTableBinned(iInObj).typeOfVar, objNames, objVarIDs);
    1177             : 
    1178           0 :         if (ort->OutputTableBinned(iInObj).keyValue == "*") {
    1179           0 :             for (int iTable = 1; iTable <= ort->OutputTableBinned(iInObj).numTables; ++iTable) {
    1180           0 :                 int repIndex = firstReport + (iTable - 1);
    1181           0 :                 ort->BinObjVarID(repIndex).namesOfObj = objNames(iTable);
    1182           0 :                 ort->BinObjVarID(repIndex).varMeterNum = objVarIDs(iTable);
    1183             :                 // check if valid meter or number
    1184             :                 // Why is this here?
    1185           0 :                 if (objVarIDs(iTable) == -1) {
    1186           0 :                     ShowWarningError(state, format("{}: Specified variable or meter not found: {}", CurrentModuleObject, objNames(iTable)));
    1187             :                 }
    1188             :             }
    1189             :         } else {
    1190             :             // scan through the keys and look for the user specified key
    1191           0 :             int found = 0;
    1192           0 :             for (int iTable = 1; iTable <= ort->OutputTableBinned(iInObj).numTables; ++iTable) {
    1193           0 :                 if (Util::SameString(objNames(iTable), ort->OutputTableBinned(iInObj).keyValue)) {
    1194           0 :                     found = iTable;
    1195           0 :                     break;
    1196             :                 }
    1197             :             }
    1198             :             // the first and only report is assigned to the found object name
    1199           0 :             if (!warningAboutKeyNotFound(state, found, iInObj, CurrentModuleObject)) {
    1200           0 :                 ort->BinObjVarID(firstReport).namesOfObj = objNames(found);
    1201           0 :                 ort->BinObjVarID(firstReport).varMeterNum = objVarIDs(found);
    1202             :             }
    1203             :             // reset the number of tables to one
    1204           0 :             ort->OutputTableBinned(iInObj).numTables = 1;
    1205             :         }
    1206             :     }
    1207             :     // clear the binning arrays to zeros
    1208         736 :     for (auto &e : ort->BinResults) {
    1209           0 :         e.mnth = 0.0;
    1210           0 :         e.hrly = 0.0;
    1211             :     }
    1212         736 :     for (auto &e : ort->BinResultsBelow) {
    1213           0 :         e.mnth = 0.0;
    1214           0 :         e.hrly = 0.0;
    1215             :     }
    1216         736 :     for (auto &e : ort->BinResultsAbove) {
    1217           0 :         e.mnth = 0.0;
    1218           0 :         e.hrly = 0.0;
    1219             :     }
    1220             : 
    1221             :     // initialize statistics counters
    1222         736 :     for (auto &e : ort->BinStatistics) {
    1223           0 :         e.minimum = HUGE_(bigVal);
    1224           0 :         e.maximum = -HUGE_(bigVal);
    1225           0 :         e.n = 0;
    1226           0 :         e.sum = 0.0;
    1227           0 :         e.sum2 = 0.0;
    1228             :     }
    1229         968 : }
    1230             : 
    1231           0 : bool warningAboutKeyNotFound(EnergyPlusData &state, int foundIndex, int inObjIndex, std::string const &moduleName)
    1232             : {
    1233           0 :     if (foundIndex == 0) {
    1234           0 :         ShowWarningError(state,
    1235           0 :                          format("{}: Specified key not found: {} for variable: {}",
    1236             :                                 moduleName,
    1237           0 :                                 state.dataOutRptTab->OutputTableBinned(inObjIndex).keyValue,
    1238           0 :                                 state.dataOutRptTab->OutputTableBinned(inObjIndex).varOrMeter));
    1239           0 :         return true;
    1240             :     } else {
    1241           0 :         return false;
    1242             :     }
    1243             : }
    1244             : 
    1245         794 : void GetInputTabularStyle(EnergyPlusData &state)
    1246             : {
    1247             :     // SUBROUTINE INFORMATION:
    1248             :     //       AUTHOR         Jason Glazer
    1249             :     //       DATE WRITTEN   July 2003
    1250             :     //       MODIFIED       na
    1251             :     //       RE-ENGINEERED  na
    1252             : 
    1253             :     // PURPOSE OF THIS SUBROUTINE:
    1254             :     //   This routine set a flag for the output format for
    1255             :     //   all tabular reports. This is a "unique" object.
    1256             : 
    1257             :     // METHODOLOGY EMPLOYED:
    1258             :     //   Uses get input structure similar to other objects
    1259             : 
    1260             :     // REFERENCES:
    1261             :     // na
    1262             : 
    1263             :     // Using/Aliasing
    1264             :     using DataStringGlobals::CharComma;
    1265             :     using DataStringGlobals::CharSpace;
    1266             :     using DataStringGlobals::CharTab;
    1267             : 
    1268             :     // Locals
    1269             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    1270             :     // na
    1271             : 
    1272             :     // SUBROUTINE PARAMETER DEFINITIONS:
    1273         794 :     static std::string const CurrentModuleObject("OutputControl:Table:Style");
    1274             : 
    1275             :     // INTERFACE BLOCK SPECIFICATIONS:
    1276             :     // na
    1277             : 
    1278             :     // DERIVED TYPE DEFINITIONS:
    1279             :     // na
    1280             : 
    1281             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1282         794 :     int NumParams = 0;        // Number of elements combined
    1283         794 :     int NumAlphas = 0;        // Number of elements in the alpha array
    1284         794 :     int NumNums = 0;          // Number of elements in the numeric array
    1285         794 :     Array1D_string AlphArray; // character string data
    1286         794 :     Array1D<Real64> NumArray; // numeric data
    1287         794 :     int IOStat = -1;          // IO Status when calling get input subroutine
    1288         794 :     auto &ort = state.dataOutRptTab;
    1289             : 
    1290         794 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1291         794 :     AlphArray.allocate(NumAlphas);
    1292         794 :     NumArray.dimension(NumNums, 0.0);
    1293             : 
    1294         794 :     int NumTabularStyle = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1295             : 
    1296         794 :     if (NumTabularStyle == 0) {
    1297          38 :         AlphArray(1) = "COMMA";
    1298          38 :         ort->numStyles = 1;
    1299          38 :         ort->TableStyle(1) = TableStyle::Comma;
    1300          38 :         ort->del(1) = CharComma; // comma
    1301          38 :         ort->unitsStyle = UnitsStyle::None;
    1302         756 :     } else if (NumTabularStyle == 1) {
    1303        1512 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1304             :                                                                  CurrentModuleObject,
    1305             :                                                                  1,
    1306             :                                                                  AlphArray,
    1307             :                                                                  NumAlphas,
    1308             :                                                                  NumArray,
    1309             :                                                                  NumNums,
    1310             :                                                                  IOStat,
    1311         756 :                                                                  state.dataIPShortCut->lNumericFieldBlanks,
    1312         756 :                                                                  state.dataIPShortCut->lAlphaFieldBlanks,
    1313         756 :                                                                  state.dataIPShortCut->cAlphaFieldNames,
    1314         756 :                                                                  state.dataIPShortCut->cNumericFieldNames);
    1315             :         // ColumnSeparator
    1316         756 :         if (Util::SameString(AlphArray(1), "Comma")) {
    1317           9 :             ort->numStyles = 1;
    1318           9 :             ort->TableStyle(1) = TableStyle::Comma;
    1319           9 :             ort->del(1) = CharComma; // comma
    1320         747 :         } else if (Util::SameString(AlphArray(1), "Tab")) {
    1321           1 :             ort->numStyles = 1;
    1322           1 :             ort->TableStyle(1) = TableStyle::Tab;
    1323           1 :             ort->del(1) = CharTab; // tab
    1324         746 :         } else if (Util::SameString(AlphArray(1), "Fixed")) {
    1325           1 :             ort->numStyles = 1;
    1326           1 :             ort->TableStyle(1) = TableStyle::Fixed;
    1327           1 :             ort->del(1) = CharSpace; // space
    1328         745 :         } else if (Util::SameString(AlphArray(1), "HTML")) {
    1329         691 :             ort->numStyles = 1;
    1330         691 :             ort->TableStyle(1) = TableStyle::HTML;
    1331         691 :             ort->del(1) = CharSpace; // space - this is not used much for HTML output
    1332          54 :         } else if (Util::SameString(AlphArray(1), "XML")) {
    1333           0 :             ort->numStyles = 1;
    1334           0 :             ort->TableStyle(1) = TableStyle::XML;
    1335           0 :             ort->del(1) = CharSpace; // space - this is not used much for XML output
    1336          54 :         } else if (Util::SameString(AlphArray(1), "CommaAndHTML")) {
    1337          29 :             ort->numStyles = 2;
    1338          29 :             ort->TableStyle(1) = TableStyle::Comma;
    1339          29 :             ort->del(1) = CharComma; // comma
    1340          29 :             ort->TableStyle(2) = TableStyle::HTML;
    1341          29 :             ort->del(2) = CharSpace; // space - this is not used much for HTML output
    1342          25 :         } else if (Util::SameString(AlphArray(1), "CommaAndXML")) {
    1343           0 :             ort->numStyles = 2;
    1344           0 :             ort->TableStyle(1) = TableStyle::Comma;
    1345           0 :             ort->del(1) = CharComma; // comma
    1346           0 :             ort->TableStyle(2) = TableStyle::XML;
    1347           0 :             ort->del(2) = CharSpace; // space - this is not used much for XML output
    1348          25 :         } else if (Util::SameString(AlphArray(1), "TabAndHTML")) {
    1349           5 :             ort->numStyles = 2;
    1350           5 :             ort->TableStyle(1) = TableStyle::Tab;
    1351           5 :             ort->del(1) = CharTab; // tab
    1352           5 :             ort->TableStyle(2) = TableStyle::HTML;
    1353           5 :             ort->del(2) = CharSpace; // space - this is not used much for HTML output
    1354          20 :         } else if (Util::SameString(AlphArray(1), "XMLandHTML")) {
    1355           2 :             ort->numStyles = 2;
    1356           2 :             ort->TableStyle(1) = TableStyle::XML;
    1357           2 :             ort->del(1) = CharSpace; // space - this is not used much for XML output
    1358           2 :             ort->TableStyle(2) = TableStyle::HTML;
    1359           2 :             ort->del(2) = CharSpace; // space - this is not used much for HTML output
    1360          18 :         } else if (Util::SameString(AlphArray(1), "All")) {
    1361          18 :             ort->numStyles = 5;
    1362          18 :             ort->TableStyle(1) = TableStyle::Comma;
    1363          18 :             ort->del(1) = CharComma; // comma
    1364          18 :             ort->TableStyle(2) = TableStyle::Tab;
    1365          18 :             ort->del(2) = CharTab; // tab
    1366          18 :             ort->TableStyle(3) = TableStyle::Fixed;
    1367          18 :             ort->del(3) = CharSpace; // space
    1368          18 :             ort->TableStyle(4) = TableStyle::HTML;
    1369          18 :             ort->del(4) = CharSpace; // space - this is not used much for HTML output
    1370          18 :             ort->TableStyle(5) = TableStyle::XML;
    1371          18 :             ort->del(5) = CharSpace; // space - this is not used much for XML output
    1372             :         } else {
    1373           0 :             ShowWarningError(
    1374             :                 state,
    1375           0 :                 format("{}: Invalid {}=\"{}\". Commas will be used.", CurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(1), AlphArray(1)));
    1376           0 :             ort->numStyles = 1;
    1377           0 :             ort->TableStyle(1) = TableStyle::Comma;
    1378           0 :             ort->del(1) = CharComma; // comma
    1379           0 :             AlphArray(1) = "COMMA";
    1380             :         }
    1381             :         // MonthlyUnitConversion
    1382         756 :         if (NumAlphas >= 2) {
    1383          18 :             ort->unitsStyle = SetUnitsStyleFromString(AlphArray(2));
    1384          18 :             if (ort->unitsStyle == UnitsStyle::NotFound) {
    1385           0 :                 ShowWarningError(state,
    1386           0 :                                  format("{}: Invalid {}=\"{}\". No unit conversion will be performed. Normal SI units will be shown.",
    1387             :                                         CurrentModuleObject,
    1388           0 :                                         state.dataIPShortCut->cAlphaFieldNames(2),
    1389             :                                         AlphArray(2)));
    1390             :             }
    1391             :         } else {
    1392         738 :             ort->unitsStyle = UnitsStyle::None;
    1393         738 :             AlphArray(2) = "None";
    1394             :         }
    1395           0 :     } else if (NumTabularStyle > 1) {
    1396           0 :         ShowWarningError(state, format("{}: Only one instance of this object is allowed. Commas will be used.", CurrentModuleObject));
    1397           0 :         ort->TableStyle = TableStyle::Comma;
    1398           0 :         ort->del = std::string(1, CharComma); // comma
    1399           0 :         AlphArray(1) = "COMMA";
    1400           0 :         ort->unitsStyle = UnitsStyle::None;
    1401           0 :         AlphArray(2) = "None";
    1402             :     }
    1403             : 
    1404         794 :     if (ort->WriteTabularFiles) {
    1405         143 :         print(state.files.eio, "! <Tabular Report>,Style,Unit Conversion\n");
    1406         143 :         if (AlphArray(1) != "HTML") {
    1407          30 :             ConvertCaseToLower(AlphArray(1), AlphArray(2));
    1408          30 :             AlphArray(1).erase(1);
    1409          30 :             AlphArray(1) += AlphArray(2).substr(1);
    1410             :         }
    1411         143 :         print(state.files.eio, "Tabular Report,{},{}\n", AlphArray(1), AlphArray(2));
    1412             :     }
    1413         794 : }
    1414             : 
    1415          18 : UnitsStyle SetUnitsStyleFromString(std::string const &unitStringIn)
    1416             : {
    1417          18 :     UnitsStyle unitsStyleReturn = static_cast<UnitsStyle>(getEnumValue(UnitsStyleNamesUC, Util::makeUPPER(unitStringIn)));
    1418          18 :     if (unitsStyleReturn == UnitsStyle::Invalid) {
    1419           0 :         unitsStyleReturn = UnitsStyle::NotFound;
    1420             :     }
    1421             : 
    1422          18 :     return unitsStyleReturn;
    1423             : }
    1424             : 
    1425         794 : void GetInputOutputTableSummaryReports(EnergyPlusData &state)
    1426             : {
    1427             :     // SUBROUTINE INFORMATION:
    1428             :     //       AUTHOR         Jason Glazer
    1429             :     //       DATE WRITTEN   November 2003
    1430             :     //       MODIFIED       na
    1431             :     //       RE-ENGINEERED  na
    1432             : 
    1433             :     // PURPOSE OF THIS SUBROUTINE:
    1434             :     //   This routine flags if any of the predefined reports
    1435             :     //   are requested by the user
    1436             : 
    1437             :     // METHODOLOGY EMPLOYED:
    1438             :     //   Uses get input structure similar to other objects
    1439             : 
    1440             :     // REFERENCES:
    1441             :     // na
    1442             : 
    1443             :     // Using/Aliasing
    1444             :     using DataStringGlobals::CharComma;
    1445             :     using DataStringGlobals::CharSpace;
    1446             :     using DataStringGlobals::CharTab;
    1447             : 
    1448             :     // SUBROUTINE PARAMETER DEFINITIONS:
    1449         794 :     static std::string const CurrentModuleObject("Output:Table:SummaryReports");
    1450             : 
    1451             :     // INTERFACE BLOCK SPECIFICATIONS:
    1452             :     // na
    1453             : 
    1454             :     // DERIVED TYPE DEFINITIONS:
    1455             : 
    1456             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1457         794 :     auto &ort = state.dataOutRptTab;
    1458         794 :     bool ErrorsFound = false;
    1459             : 
    1460         794 :     if (!state.files.outputControl.writeTabular(state)) {
    1461           1 :         ort->WriteTabularFiles = false;
    1462           1 :         return;
    1463             :     }
    1464             : 
    1465         793 :     int NumTabularPredefined = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1466         793 :     if (NumTabularPredefined == 1) {
    1467             : 
    1468         753 :         int NumParams = 0;
    1469         753 :         int NumAlphas = 0; // Number of elements in the alpha array
    1470         753 :         int NumNums = 0;   // Number of elements in the numeric array
    1471         753 :         Array1D_string AlphArray;
    1472         753 :         Array1D<Real64> NumArray;
    1473         753 :         int IOStat = -1; // IO Status when calling get input subroutine
    1474             : 
    1475             :         // find out how many fields since the object is extensible
    1476         753 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1477             :         // allocate the temporary arrays for the call to get the filed
    1478         753 :         AlphArray.allocate(NumAlphas);
    1479             :         // don't really need the NumArray since not expecting any numbers but the call requires it
    1480         753 :         NumArray.dimension(NumNums, 0.0);
    1481             :         // get the object
    1482         753 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, 1, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
    1483             :         // default all report flags to false (do not get produced)
    1484         753 :         ort->displayTabularBEPS = false;
    1485             :         // initialize the names of the predefined monthly report titles
    1486         753 :         InitializePredefinedMonthlyTitles(state);
    1487             :         // loop through the fields looking for matching report titles
    1488        2048 :         for (int iReport = 1; iReport <= NumAlphas; ++iReport) {
    1489        1295 :             bool nameFound = false;
    1490        1295 :             if (AlphArray(iReport).empty()) {
    1491           0 :                 ShowWarningError(state, "Blank report name in Output:Table:SummaryReports");
    1492        1295 :             } else if (Util::SameString(AlphArray(iReport), "AnnualBuildingUtilityPerformanceSummary")) {
    1493          80 :                 ort->displayTabularBEPS = true;
    1494          80 :                 ort->WriteTabularFiles = true;
    1495          80 :                 nameFound = true;
    1496        1215 :             } else if (Util::SameString(AlphArray(iReport), "ComponentCostEconomicsSummary")) {
    1497           9 :                 ort->displayTabularCompCosts = true;
    1498           9 :                 ort->WriteTabularFiles = true;
    1499           9 :                 nameFound = true;
    1500        1206 :             } else if (Util::SameString(AlphArray(iReport), "InputVerificationandResultsSummary")) {
    1501          75 :                 ort->displayTabularVeriSum = true;
    1502          75 :                 ort->WriteTabularFiles = true;
    1503          75 :                 nameFound = true;
    1504        1131 :             } else if (Util::SameString(AlphArray(iReport), "ComponentSizingSummary")) {
    1505          60 :                 ort->displayComponentSizing = true;
    1506          60 :                 ort->WriteTabularFiles = true;
    1507          60 :                 nameFound = true;
    1508        1071 :             } else if (Util::SameString(AlphArray(iReport), "SurfaceShadowingSummary")) {
    1509           0 :                 ort->displaySurfaceShadowing = true;
    1510           0 :                 ort->WriteTabularFiles = true;
    1511           0 :                 nameFound = true;
    1512        1071 :             } else if (Util::SameString(AlphArray(iReport), "DemandEndUseComponentsSummary")) {
    1513           3 :                 ort->displayDemandEndUse = true;
    1514           3 :                 ort->WriteTabularFiles = true;
    1515           3 :                 nameFound = true;
    1516        1068 :             } else if (Util::SameString(AlphArray(iReport), "AdaptiveComfortSummary")) {
    1517           0 :                 ort->displayAdaptiveComfort = true;
    1518           0 :                 ort->WriteTabularFiles = true;
    1519           0 :                 nameFound = true;
    1520        1068 :             } else if (Util::SameString(AlphArray(iReport), "SourceEnergyEndUseComponentsSummary")) {
    1521           0 :                 ort->displaySourceEnergyEndUseSummary = true;
    1522           0 :                 ort->WriteTabularFiles = true;
    1523           0 :                 nameFound = true;
    1524        1068 :             } else if (Util::SameString(AlphArray(iReport), "ZoneComponentLoadSummary")) {
    1525          25 :                 ort->displayZoneComponentLoadSummary = true;
    1526          25 :                 ort->WriteTabularFiles = true;
    1527          25 :                 nameFound = true;
    1528        1043 :             } else if (Util::SameString(AlphArray(iReport), "AirLoopComponentLoadSummary")) {
    1529           0 :                 ort->displayAirLoopComponentLoadSummary = true;
    1530           0 :                 ort->WriteTabularFiles = true;
    1531           0 :                 nameFound = true;
    1532        1043 :             } else if (Util::SameString(AlphArray(iReport), "FacilityComponentLoadSummary")) {
    1533           0 :                 ort->displayFacilityComponentLoadSummary = true;
    1534           0 :                 ort->WriteTabularFiles = true;
    1535           0 :                 nameFound = true;
    1536        1043 :             } else if (Util::SameString(AlphArray(iReport), "LEEDSummary")) {
    1537           0 :                 ort->displayLEEDSummary = true;
    1538           0 :                 ort->WriteTabularFiles = true;
    1539           0 :                 nameFound = true;
    1540        1043 :             } else if (Util::SameString(AlphArray(iReport), "LifeCycleCostReport")) {
    1541           0 :                 ort->displayLifeCycleCostReport = true;
    1542           0 :                 ort->WriteTabularFiles = true;
    1543           0 :                 nameFound = true;
    1544        1043 :             } else if (Util::SameString(AlphArray(iReport), "TariffReport")) {
    1545           0 :                 ort->displayTariffReport = true;
    1546           0 :                 ort->WriteTabularFiles = true;
    1547           0 :                 nameFound = true;
    1548        1043 :             } else if (Util::SameString(AlphArray(iReport), "EconomicResultSummary")) {
    1549           0 :                 ort->displayEconomicResultSummary = true;
    1550           0 :                 ort->WriteTabularFiles = true;
    1551           0 :                 nameFound = true;
    1552        1043 :             } else if (Util::SameString(AlphArray(iReport), "HeatEmissionsSummary")) {
    1553           1 :                 ort->displayHeatEmissionsSummary = true;
    1554           1 :                 ort->WriteTabularFiles = true;
    1555           1 :                 nameFound = true;
    1556        1042 :             } else if (Util::SameString(AlphArray(iReport), "ThermalResilienceSummary")) {
    1557           3 :                 ort->displayThermalResilienceSummary = true;
    1558           3 :                 ort->displayThermalResilienceSummaryExplicitly = true;
    1559           3 :                 ort->WriteTabularFiles = true;
    1560           3 :                 nameFound = true;
    1561        1039 :             } else if (Util::SameString(AlphArray(iReport), "CO2ResilienceSummary")) {
    1562           3 :                 ort->displayCO2ResilienceSummary = true;
    1563           3 :                 ort->displayCO2ResilienceSummaryExplicitly = true;
    1564           3 :                 ort->WriteTabularFiles = true;
    1565           3 :                 nameFound = true;
    1566        1036 :             } else if (Util::SameString(AlphArray(iReport), "VisualResilienceSummary")) {
    1567           3 :                 ort->displayVisualResilienceSummary = true;
    1568           3 :                 ort->displayVisualResilienceSummaryExplicitly = true;
    1569           3 :                 ort->WriteTabularFiles = true;
    1570           3 :                 nameFound = true;
    1571        1033 :             } else if (Util::SameString(AlphArray(iReport), "EnergyMeters")) {
    1572           0 :                 ort->WriteTabularFiles = true;
    1573           0 :                 nameFound = true;
    1574        1033 :             } else if (Util::SameString(AlphArray(iReport), "InitializationSummary")) {
    1575           1 :                 ort->WriteTabularFiles = true;
    1576           1 :                 ort->displayEioSummary = true;
    1577           1 :                 nameFound = true;
    1578        1032 :             } else if (Util::SameString(AlphArray(iReport), "AllSummary")) {
    1579         647 :                 ort->WriteTabularFiles = true;
    1580         647 :                 ort->displayTabularBEPS = true;
    1581         647 :                 ort->displayTabularVeriSum = true;
    1582         647 :                 ort->displayTabularCompCosts = true;
    1583         647 :                 ort->displaySurfaceShadowing = true;
    1584         647 :                 ort->displayComponentSizing = true;
    1585         647 :                 ort->displayDemandEndUse = true;
    1586         647 :                 ort->displayAdaptiveComfort = true;
    1587         647 :                 ort->displaySourceEnergyEndUseSummary = true;
    1588         647 :                 ort->displayLifeCycleCostReport = true;
    1589         647 :                 ort->displayTariffReport = true;
    1590         647 :                 ort->displayEconomicResultSummary = true;
    1591         647 :                 ort->displayEioSummary = true;
    1592         647 :                 ort->displayLEEDSummary = true;
    1593         647 :                 ort->displayHeatEmissionsSummary = true;
    1594         647 :                 ort->displayThermalResilienceSummary = true;
    1595         647 :                 ort->displayCO2ResilienceSummary = true;
    1596         647 :                 ort->displayVisualResilienceSummary = true;
    1597         647 :                 nameFound = true;
    1598       11964 :                 for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1599       11317 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1600             :                 }
    1601         385 :             } else if (Util::SameString(AlphArray(iReport), "AllSummaryAndSizingPeriod")) {
    1602           2 :                 ort->WriteTabularFiles = true;
    1603           2 :                 ort->displayTabularBEPS = true;
    1604           2 :                 ort->displayTabularVeriSum = true;
    1605           2 :                 ort->displayTabularCompCosts = true;
    1606           2 :                 ort->displaySurfaceShadowing = true;
    1607           2 :                 ort->displayComponentSizing = true;
    1608           2 :                 ort->displayDemandEndUse = true;
    1609           2 :                 ort->displayAdaptiveComfort = true;
    1610           2 :                 ort->displaySourceEnergyEndUseSummary = true;
    1611           2 :                 ort->displayLifeCycleCostReport = true;
    1612           2 :                 ort->displayTariffReport = true;
    1613           2 :                 ort->displayEconomicResultSummary = true;
    1614           2 :                 ort->displayEioSummary = true;
    1615           2 :                 ort->displayLEEDSummary = true;
    1616           2 :                 ort->displayHeatEmissionsSummary = true;
    1617           2 :                 ort->displayThermalResilienceSummary = true;
    1618           2 :                 ort->displayCO2ResilienceSummary = true;
    1619           2 :                 ort->displayVisualResilienceSummary = true;
    1620           2 :                 nameFound = true;
    1621          38 :                 for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1622          36 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1623             :                 }
    1624             :                 // the sizing period reports
    1625           2 :                 ort->displayZoneComponentLoadSummary = true;
    1626           2 :                 ort->displayAirLoopComponentLoadSummary = true;
    1627           2 :                 ort->displayFacilityComponentLoadSummary = true;
    1628         383 :             } else if (Util::SameString(AlphArray(iReport), "AllMonthly")) {
    1629           1 :                 ort->WriteTabularFiles = true;
    1630          64 :                 for (int jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1631          63 :                     ort->namedMonthly(jReport).show = true;
    1632             :                 }
    1633           1 :                 nameFound = true;
    1634         382 :             } else if (Util::SameString(AlphArray(iReport), "AllSummaryAndMonthly")) {
    1635          23 :                 ort->WriteTabularFiles = true;
    1636          23 :                 ort->displayTabularBEPS = true;
    1637          23 :                 ort->displayTabularVeriSum = true;
    1638          23 :                 ort->displayTabularCompCosts = true;
    1639          23 :                 ort->displaySurfaceShadowing = true;
    1640          23 :                 ort->displayComponentSizing = true;
    1641          23 :                 ort->displayDemandEndUse = true;
    1642          23 :                 ort->displayAdaptiveComfort = true;
    1643          23 :                 ort->displaySourceEnergyEndUseSummary = true;
    1644          23 :                 ort->displayLifeCycleCostReport = true;
    1645          23 :                 ort->displayTariffReport = true;
    1646          23 :                 ort->displayEconomicResultSummary = true;
    1647          23 :                 ort->displayEioSummary = true;
    1648          23 :                 ort->displayLEEDSummary = true;
    1649          23 :                 ort->displayHeatEmissionsSummary = true;
    1650          23 :                 ort->displayThermalResilienceSummary = true;
    1651          23 :                 ort->displayCO2ResilienceSummary = true;
    1652          23 :                 ort->displayVisualResilienceSummary = true;
    1653          23 :                 nameFound = true;
    1654         435 :                 for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1655         412 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1656             :                 }
    1657        1472 :                 for (int jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1658        1449 :                     ort->namedMonthly(jReport).show = true;
    1659             :                 }
    1660         359 :             } else if (Util::SameString(AlphArray(iReport), "AllSummaryMonthlyAndSizingPeriod")) {
    1661           0 :                 ort->WriteTabularFiles = true;
    1662           0 :                 ort->displayTabularBEPS = true;
    1663           0 :                 ort->displayTabularVeriSum = true;
    1664           0 :                 ort->displayTabularCompCosts = true;
    1665           0 :                 ort->displaySurfaceShadowing = true;
    1666           0 :                 ort->displayComponentSizing = true;
    1667           0 :                 ort->displayDemandEndUse = true;
    1668           0 :                 ort->displayAdaptiveComfort = true;
    1669           0 :                 ort->displaySourceEnergyEndUseSummary = true;
    1670           0 :                 ort->displayLifeCycleCostReport = true;
    1671           0 :                 ort->displayTariffReport = true;
    1672           0 :                 ort->displayEconomicResultSummary = true;
    1673           0 :                 ort->displayEioSummary = true;
    1674           0 :                 ort->displayLEEDSummary = true;
    1675           0 :                 ort->displayHeatEmissionsSummary = true;
    1676           0 :                 ort->displayThermalResilienceSummary = true;
    1677           0 :                 ort->displayCO2ResilienceSummary = true;
    1678           0 :                 ort->displayVisualResilienceSummary = true;
    1679           0 :                 nameFound = true;
    1680           0 :                 for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1681           0 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1682             :                 }
    1683           0 :                 for (int jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1684           0 :                     ort->namedMonthly(jReport).show = true;
    1685             :                 }
    1686             :                 // the sizing period reports
    1687           0 :                 ort->displayZoneComponentLoadSummary = true;
    1688           0 :                 ort->displayAirLoopComponentLoadSummary = true;
    1689           0 :                 ort->displayFacilityComponentLoadSummary = true;
    1690             :             }
    1691             :             // check the reports that are predefined and are created by OutputReportPredefined
    1692       24250 :             for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1693       22955 :                 if (Util::SameString(AlphArray(iReport), state.dataOutRptPredefined->reportName(jReport).name)) {
    1694         362 :                     ort->WriteTabularFiles = true;
    1695         362 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1696         362 :                     nameFound = true;
    1697             :                 }
    1698       22955 :                 if (Util::SameString(AlphArray(iReport), state.dataOutRptPredefined->reportName(jReport).abrev)) {
    1699           0 :                     ort->WriteTabularFiles = true;
    1700           0 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1701           0 :                     nameFound = true;
    1702             :                 }
    1703             :             }
    1704             :             // check if the predefined monthly reports are used
    1705       82880 :             for (int jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1706       81585 :                 if (Util::SameString(AlphArray(iReport), ort->namedMonthly(jReport).title)) {
    1707           3 :                     ort->namedMonthly(jReport).show = true;
    1708           3 :                     ort->WriteTabularFiles = true;
    1709           3 :                     nameFound = true;
    1710             :                 }
    1711             :             }
    1712        1295 :             if (!nameFound) {
    1713           0 :                 if (Util::SameString(AlphArray(iReport), "Standard62.1Summary")) {
    1714           0 :                     ShowWarningError(state, format("{} Field[{}]=\"Standard62.1Summary\", Report is not enabled.", CurrentModuleObject, iReport));
    1715           0 :                     ShowContinueError(state, "Do Zone Sizing or Do System Sizing must be enabled in SimulationControl.");
    1716             : 
    1717             :                 } else {
    1718           0 :                     ShowSevereError(
    1719             :                         state,
    1720           0 :                         format(
    1721             :                             "{} Field[{}]=\"{}\", invalid report name -- will not be reported.", CurrentModuleObject, iReport, AlphArray(iReport)));
    1722             :                     //      ErrorsFound=.TRUE.
    1723             :                 }
    1724             :             }
    1725             :         }
    1726         753 :         CreatePredefinedMonthlyReports(state);
    1727         793 :     } else if (NumTabularPredefined > 1) {
    1728           0 :         ShowSevereError(state, format("{}: Only one instance of this object is allowed.", CurrentModuleObject));
    1729           0 :         ErrorsFound = true;
    1730             :     }
    1731         793 :     if (ErrorsFound) {
    1732           0 :         ShowFatalError(state, format("{}: Preceding errors cause termination.", CurrentModuleObject));
    1733             :     }
    1734             :     // if the BEPS report has been called for than initialize its arrays
    1735         793 :     if (ort->displayTabularBEPS || ort->displayDemandEndUse || ort->displaySourceEnergyEndUseSummary || ort->displayLEEDSummary) {
    1736             :         // initialize the resource type names
    1737         752 :         ort->resourceTypeNames(1) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Electricity)];
    1738         752 :         ort->resourceTypeNames(2) = Constant::eResourceNames[static_cast<int>(Constant::eResource::NaturalGas)];
    1739         752 :         ort->resourceTypeNames(3) = Constant::eResourceNames[static_cast<int>(Constant::eResource::DistrictCooling)];
    1740         752 :         ort->resourceTypeNames(4) = Constant::eResourceNames[static_cast<int>(Constant::eResource::DistrictHeatingWater)];
    1741         752 :         ort->resourceTypeNames(5) = Constant::eResourceNames[static_cast<int>(Constant::eResource::DistrictHeatingSteam)];
    1742         752 :         ort->resourceTypeNames(6) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Gasoline)];
    1743         752 :         ort->resourceTypeNames(7) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Water)];
    1744         752 :         ort->resourceTypeNames(8) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Diesel)];
    1745         752 :         ort->resourceTypeNames(9) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Coal)];
    1746         752 :         ort->resourceTypeNames(10) = Constant::eResourceNames[static_cast<int>(Constant::eResource::FuelOilNo1)];
    1747         752 :         ort->resourceTypeNames(11) = Constant::eResourceNames[static_cast<int>(Constant::eResource::FuelOilNo2)];
    1748         752 :         ort->resourceTypeNames(12) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Propane)];
    1749         752 :         ort->resourceTypeNames(13) = Constant::eResourceNames[static_cast<int>(Constant::eResource::OtherFuel1)];
    1750         752 :         ort->resourceTypeNames(14) = Constant::eResourceNames[static_cast<int>(Constant::eResource::OtherFuel2)];
    1751             : 
    1752         752 :         ort->sourceTypeNames(1) = "Electricity";
    1753         752 :         ort->sourceTypeNames(2) = "NaturalGas";
    1754         752 :         ort->sourceTypeNames(3) = "Gasoline";
    1755         752 :         ort->sourceTypeNames(4) = "Diesel";
    1756         752 :         ort->sourceTypeNames(5) = "Coal";
    1757         752 :         ort->sourceTypeNames(6) = "FuelOilNo1";
    1758         752 :         ort->sourceTypeNames(7) = "FuelOilNo2";
    1759         752 :         ort->sourceTypeNames(8) = "Propane";
    1760         752 :         ort->sourceTypeNames(9) = "PurchasedElectricity";
    1761         752 :         ort->sourceTypeNames(10) = "SoldElectricity";
    1762         752 :         ort->sourceTypeNames(11) = "OtherFuel1";
    1763         752 :         ort->sourceTypeNames(12) = "OtherFuel2";
    1764             : 
    1765             :         // initialize the end use names
    1766         752 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Heating) + 1) = "Heating";
    1767         752 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Cooling) + 1) = "Cooling";
    1768         752 :         ort->endUseNames(static_cast<int>(Constant::EndUse::InteriorLights) + 1) = "InteriorLights";
    1769         752 :         ort->endUseNames(static_cast<int>(Constant::EndUse::ExteriorLights) + 1) = "ExteriorLights";
    1770         752 :         ort->endUseNames(static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) = "InteriorEquipment";
    1771         752 :         ort->endUseNames(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) = "ExteriorEquipment";
    1772         752 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Fans) + 1) = "Fans";
    1773         752 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Pumps) + 1) = "Pumps";
    1774         752 :         ort->endUseNames(static_cast<int>(Constant::EndUse::HeatRejection) + 1) = "HeatRejection";
    1775         752 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Humidification) + 1) = "Humidifier";
    1776         752 :         ort->endUseNames(static_cast<int>(Constant::EndUse::HeatRecovery) + 1) = "HeatRecovery";
    1777         752 :         ort->endUseNames(static_cast<int>(Constant::EndUse::WaterSystem) + 1) = "WaterSystems";
    1778         752 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Refrigeration) + 1) = "Refrigeration";
    1779         752 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Cogeneration) + 1) = "Cogeneration";
    1780             : 
    1781         752 :         auto &op = state.dataOutputProcessor;
    1782             :         // End use subs must be dynamically allocated to accomodate the end use with the most subcategories
    1783         752 :         ort->meterNumEndUseSubBEPS.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1784         752 :         ort->meterNumEndUseSpTypeBEPS.allocate(op->maxNumEndUseSpaceTypes, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1785       11280 :         for (int endUse = 1; endUse <= static_cast<int>(Constant::EndUse::Num); ++endUse) {
    1786      157920 :             for (int resType = 1; resType <= numResourceTypes; ++resType) {
    1787      425908 :                 for (int subCat = 1; subCat <= op->MaxNumSubcategories; ++subCat) {
    1788      278516 :                     ort->meterNumEndUseSubBEPS(subCat, endUse, resType) = -1;
    1789             :                 }
    1790      297136 :                 for (int spType = 1; spType <= op->maxNumEndUseSpaceTypes; ++spType) {
    1791      149744 :                     ort->meterNumEndUseSpTypeBEPS(spType, endUse, resType) = -1;
    1792             :                 }
    1793             :             }
    1794             :         }
    1795             : 
    1796             :         // loop through all of the resources and end uses and sub end uses for the entire facility
    1797       11280 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    1798       10528 :             std::string meterName = format("{}:FACILITY", ort->resourceTypeNames(iResource));
    1799       10528 :             int meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1800       10528 :             ort->meterNumTotalsBEPS(iResource) = meterNumber;
    1801             : 
    1802      157920 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    1803      147392 :                 meterName = format("{}:{}", ort->endUseNames(jEndUse), ort->resourceTypeNames(iResource)); //// ':FACILITY'
    1804      147392 :                 meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1805      147392 :                 ort->meterNumEndUseBEPS(iResource, jEndUse) = meterNumber;
    1806             : 
    1807      234654 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    1808      349048 :                     meterName = format("{}:{}:{}",
    1809       87262 :                                        op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub),
    1810       87262 :                                        ort->endUseNames(jEndUse),
    1811      174524 :                                        ort->resourceTypeNames(iResource));
    1812       87262 :                     meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1813       87262 :                     ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource) = meterNumber;
    1814             :                 }
    1815      165718 :                 for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    1816       54978 :                     meterName = format("{}:{}:SpaceType:{}",
    1817       18326 :                                        ort->endUseNames(jEndUse),
    1818       18326 :                                        ort->resourceTypeNames(iResource),
    1819       36652 :                                        op->EndUseCategory(jEndUse).spaceTypeName(kEndUseSpType));
    1820       18326 :                     meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1821       18326 :                     ort->meterNumEndUseSpTypeBEPS(kEndUseSpType, jEndUse, iResource) = meterNumber;
    1822             :                 }
    1823             :             }
    1824       10528 :         }
    1825             : 
    1826        9776 :         for (int iResource = 1; iResource <= numSourceTypes; ++iResource) {
    1827        9024 :             int const meterNumber = GetMeterIndex(state, Util::makeUPPER(format("{}Emissions:Source", ort->sourceTypeNames(iResource))));
    1828        9024 :             ort->meterNumTotalsSource(iResource) = meterNumber;
    1829             :         }
    1830             : 
    1831             :         // initialize the gathering arrays to zero
    1832         752 :         ort->gatherTotalsBEPS = 0.0;
    1833         752 :         ort->gatherTotalsBySourceBEPS = 0.0;
    1834         752 :         ort->gatherTotalsSource = 0.0;
    1835         752 :         ort->gatherTotalsBySource = 0.0;
    1836         752 :         ort->gatherEndUseBEPS = 0.0;
    1837         752 :         ort->gatherEndUseBySourceBEPS = 0.0;
    1838             :         // End use subs must be dynamically allocated to accommodate the end use with the most subcategories
    1839         752 :         ort->gatherEndUseSubBEPS.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1840         752 :         ort->gatherEndUseSubBEPS = 0.0;
    1841         752 :         ort->gatherEndUseSpTypeBEPS.allocate(op->maxNumEndUseSpaceTypes, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1842         752 :         ort->gatherEndUseSpTypeBEPS = 0.0;
    1843         752 :         ort->gatherDemandEndUseSub.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1844         752 :         ort->gatherDemandEndUseSub = 0.0;
    1845         752 :         ort->gatherDemandIndEndUseSub.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1846         752 :         ort->gatherDemandIndEndUseSub = 0.0;
    1847             : 
    1848             :         // get meter numbers for other meters relating to electric load components
    1849         752 :         ort->meterNumPowerFuelFireGen = GetMeterIndex(state, "COGENERATION:ELECTRICITYPRODUCED");
    1850         752 :         ort->meterNumPowerPV = GetMeterIndex(state, "PHOTOVOLTAIC:ELECTRICITYPRODUCED");
    1851         752 :         ort->meterNumPowerWind = GetMeterIndex(state, "WINDTURBINE:ELECTRICITYPRODUCED");
    1852         752 :         ort->meterNumPowerHTGeothermal = GetMeterIndex(state, "HTGEOTHERMAL:ELECTRICITYPRODUCED");
    1853         752 :         ort->meterNumElecStorage = GetMeterIndex(state, "ELECTRICSTORAGE:ELECTRICITYPRODUCED");
    1854         752 :         ort->meterNumPowerConversion = GetMeterIndex(state, "POWERCONVERSION:ELECTRICITYPRODUCED");
    1855         752 :         ort->meterNumElecProduced = GetMeterIndex(state, "ELECTRICITYPRODUCED:FACILITY");
    1856         752 :         ort->meterNumElecPurchased = GetMeterIndex(state, "ELECTRICITYPURCHASED:FACILITY");
    1857         752 :         ort->meterNumElecSurplusSold = GetMeterIndex(state, "ELECTRICITYSURPLUSSOLD:FACILITY");
    1858             :         // if no ElectricityPurchased:Facility meter is defined then no electric load center
    1859             :         // was created by the user and no power generation will occur in the plant. The amount
    1860             :         // purchased would be the total end use.
    1861         752 :         if (ort->meterNumElecPurchased == 0) {
    1862           0 :             ort->meterNumElecPurchased = GetMeterIndex(state, "ELECTRICITY:FACILITY");
    1863             :         }
    1864             : 
    1865             :         // initialize the gathering variables for the electric load components
    1866         752 :         ort->gatherPowerFuelFireGen = 0.0;
    1867         752 :         ort->gatherPowerPV = 0.0;
    1868         752 :         ort->gatherPowerWind = 0.0;
    1869         752 :         ort->gatherPowerHTGeothermal = 0.0;
    1870         752 :         ort->gatherElecProduced = 0.0;
    1871         752 :         ort->gatherElecPurchased = 0.0;
    1872         752 :         ort->gatherElecSurplusSold = 0.0;
    1873         752 :         ort->gatherElecStorage = 0.0;
    1874         752 :         ort->gatherPowerConversion = 0.0;
    1875             : 
    1876             :         // get meter numbers for onsite thermal components on BEPS report
    1877         752 :         ort->meterNumWaterHeatRecovery = GetMeterIndex(state, "HEATRECOVERY:ENERGYTRANSFER");
    1878         752 :         ort->meterNumAirHeatRecoveryCool = GetMeterIndex(state, "HEATRECOVERYFORCOOLING:ENERGYTRANSFER");
    1879         752 :         ort->meterNumAirHeatRecoveryHeat = GetMeterIndex(state, "HEATRECOVERYFORHEATING:ENERGYTRANSFER");
    1880         752 :         ort->meterNumHeatHTGeothermal = GetMeterIndex(state, "HTGEOTHERMAL:HEATPRODUCED");
    1881         752 :         ort->meterNumHeatSolarWater = GetMeterIndex(state, "SOLARWATER:FACILITY");
    1882         752 :         ort->meterNumHeatSolarAir = GetMeterIndex(state, "HEATPRODUCED:SOLARAIR");
    1883             :         // initialize the gathering variables for onsite thermal components on BEPS report
    1884         752 :         ort->gatherWaterHeatRecovery = 0.0;
    1885         752 :         ort->gatherAirHeatRecoveryCool = 0.0;
    1886         752 :         ort->gatherAirHeatRecoveryHeat = 0.0;
    1887         752 :         ort->gatherHeatHTGeothermal = 0.0;
    1888         752 :         ort->gatherHeatSolarWater = 0.0;
    1889         752 :         ort->gatherHeatSolarAir = 0.0;
    1890             : 
    1891             :         // get meter numbers for water components on BEPS report
    1892         752 :         ort->meterNumRainWater = GetMeterIndex(state, "RAINWATER:ONSITEWATER");
    1893         752 :         ort->meterNumCondensate = GetMeterIndex(state, "CONDENSATE:ONSITEWATER");
    1894         752 :         ort->meterNumGroundwater = GetMeterIndex(state, "WELLWATER:ONSITEWATER");
    1895         752 :         ort->meterNumMains = GetMeterIndex(state, "MAINSWATER:FACILITY");
    1896         752 :         ort->meterNumWaterEndUseTotal = GetMeterIndex(state, "WATER:FACILITY");
    1897             : 
    1898             :         // initialize the gathering variables for water components on BEPS report
    1899         752 :         ort->gatherRainWater = 0.0;
    1900         752 :         ort->gatherCondensate = 0.0;
    1901         752 :         ort->gatherWellwater = 0.0;
    1902         752 :         ort->gatherMains = 0.0;
    1903         752 :         ort->gatherWaterEndUseTotal = 0.0;
    1904             :     }
    1905             : }
    1906             : 
    1907         796 : bool isCompLoadRepReq(EnergyPlusData &state)
    1908             : {
    1909             :     // SUBROUTINE INFORMATION:
    1910             :     //       AUTHOR         Jason Glazer
    1911             :     //       DATE WRITTEN   November 2003
    1912             :     //       MODIFIED       na
    1913             :     //       RE-ENGINEERED  na
    1914             : 
    1915             :     // PURPOSE OF THIS SUBROUTINE:
    1916             :     //   Determine if the ZoneComponentLoadSummary or
    1917             :     //   ZoneComponentLoadDetail reports are requested.
    1918             : 
    1919             :     // METHODOLOGY EMPLOYED:
    1920             :     //   Uses get input structure similar to other objects
    1921             : 
    1922             :     // REFERENCES:
    1923             :     // na
    1924             : 
    1925             :     // USE STATEMENTS:
    1926             :     // na
    1927             : 
    1928             :     // Return value
    1929             :     bool isCompLoadRepReq;
    1930             : 
    1931             :     // Locals
    1932             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    1933             :     // na
    1934             : 
    1935             :     // SUBROUTINE PARAMETER DEFINITIONS:
    1936         796 :     static std::string const CurrentModuleObject("Output:Table:SummaryReports");
    1937             : 
    1938             :     // INTERFACE BLOCK SPECIFICATIONS:
    1939             :     // na
    1940             : 
    1941             :     // DERIVED TYPE DEFINITIONS:
    1942             : 
    1943             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1944             : 
    1945         796 :     bool isFound = false;
    1946             : 
    1947         796 :     int const NumTabularPredefined = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1948         796 :     if (NumTabularPredefined == 1) {
    1949             : 
    1950         756 :         int NumParams = 0;
    1951         756 :         int NumAlphas = 0; // Number of elements in the alpha array
    1952         756 :         int NumNums = 0;   // Number of elements in the numeric array
    1953         756 :         Array1D_string AlphArray;
    1954         756 :         Array1D<Real64> NumArray;
    1955         756 :         int IOStat = -1; // IO Status when calling get input subroutine
    1956             : 
    1957             :         // find out how many fields since the object is extensible
    1958         756 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1959             :         // allocate the temporary arrays for the call to get the filed
    1960         756 :         AlphArray.allocate(NumAlphas);
    1961             :         // don't really need the NumArray since not expecting any numbers but the call requires it
    1962         756 :         NumArray.dimension(NumNums, 0.0);
    1963             :         // get the object
    1964         756 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, 1, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
    1965             :         // loop through the fields looking for matching report titles
    1966        2075 :         for (int iReport = 1; iReport <= NumAlphas; ++iReport) {
    1967        1319 :             if (Util::SameString(AlphArray(iReport), "ZoneComponentLoadSummary")) {
    1968          25 :                 isFound = true;
    1969             :             }
    1970        1319 :             if (Util::SameString(AlphArray(iReport), "AirLoopComponentLoadSummary")) {
    1971           0 :                 isFound = true;
    1972             :             }
    1973        1319 :             if (Util::SameString(AlphArray(iReport), "FacilityComponentLoadSummary")) {
    1974           0 :                 isFound = true;
    1975             :             }
    1976        1319 :             if (Util::SameString(AlphArray(iReport), "AllSummaryAndSizingPeriod")) {
    1977           2 :                 isFound = true;
    1978             :             }
    1979        1319 :             if (Util::SameString(AlphArray(iReport), "AllSummaryMonthlyAndSizingPeriod")) {
    1980           0 :                 isFound = true;
    1981             :             }
    1982             :         }
    1983         756 :     }
    1984         796 :     isCompLoadRepReq = isFound; // return true if either report was found
    1985         796 :     return isCompLoadRepReq;
    1986             : }
    1987             : 
    1988         796 : bool hasSizingPeriodsDays(EnergyPlusData &state)
    1989             : {
    1990         796 :     int const sizePerDesDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay");
    1991         796 :     int const sizePerWeathFileDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays");
    1992         796 :     return ((sizePerDesDays + sizePerWeathFileDays) > 0);
    1993             : }
    1994             : 
    1995         753 : void InitializePredefinedMonthlyTitles(EnergyPlusData &state)
    1996             : {
    1997             :     // SUBROUTINE INFORMATION:
    1998             :     //       AUTHOR         Jason Glazer
    1999             :     //       DATE WRITTEN   September 2008
    2000             :     //       MODIFIED       na
    2001             :     //       RE-ENGINEERED  na
    2002             : 
    2003             :     // PURPOSE OF THIS SUBROUTINE:
    2004             :     //   Initialize the NamedMonthly array for the titles
    2005             :     //   of the monthly predefined reports
    2006             : 
    2007             :     // METHODOLOGY EMPLOYED:
    2008             :     // REFERENCES:
    2009             :     // na
    2010             : 
    2011             :     // Using/Aliasing
    2012             :     using namespace DataOutputs;
    2013             : 
    2014             :     // Locals
    2015             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    2016             :     // na
    2017             : 
    2018             :     // SUBROUTINE PARAMETER DEFINITIONS:
    2019             :     // na
    2020             : 
    2021             :     // INTERFACE BLOCK SPECIFICATIONS:
    2022             :     // na
    2023             : 
    2024             :     // DERIVED TYPE DEFINITIONS:
    2025             :     // na
    2026             : 
    2027             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2028         753 :     auto &ort = state.dataOutRptTab;
    2029             : 
    2030         753 :     ort->namedMonthly.allocate(numNamedMonthly);
    2031         753 :     ort->namedMonthly(1).title = "ZoneCoolingSummaryMonthly";
    2032         753 :     ort->namedMonthly(2).title = "ZoneHeatingSummaryMonthly";
    2033         753 :     ort->namedMonthly(3).title = "ZoneElectricSummaryMonthly";
    2034         753 :     ort->namedMonthly(4).title = "SpaceGainsMonthly";
    2035         753 :     ort->namedMonthly(5).title = "PeakSpaceGainsMonthly";
    2036         753 :     ort->namedMonthly(6).title = "SpaceGainComponentsAtCoolingPeakMonthly";
    2037         753 :     ort->namedMonthly(7).title = "EnergyConsumptionElectricityNaturalGasMonthly";
    2038         753 :     ort->namedMonthly(8).title = "EnergyConsumptionElectricityGeneratedPropaneMonthly";
    2039         753 :     ort->namedMonthly(9).title = "EnergyConsumptionDieselFuelOilMonthly";
    2040         753 :     ort->namedMonthly(10).title = "EnergyConsumptionDistrictHeatingCoolingMonthly";
    2041         753 :     ort->namedMonthly(11).title = "EnergyConsumptionCoalGasolineMonthly";
    2042         753 :     ort->namedMonthly(12).title = "EnergyConsumptionOtherFuelsMonthly";
    2043         753 :     ort->namedMonthly(13).title = "EndUseEnergyConsumptionElectricityMonthly";
    2044         753 :     ort->namedMonthly(14).title = "EndUseEnergyConsumptionNaturalGasMonthly";
    2045         753 :     ort->namedMonthly(15).title = "EndUseEnergyConsumptionDieselMonthly";
    2046         753 :     ort->namedMonthly(16).title = "EndUseEnergyConsumptionFuelOilMonthly";
    2047         753 :     ort->namedMonthly(17).title = "EndUseEnergyConsumptionCoalMonthly";
    2048         753 :     ort->namedMonthly(18).title = "EndUseEnergyConsumptionPropaneMonthly";
    2049         753 :     ort->namedMonthly(19).title = "EndUseEnergyConsumptionGasolineMonthly";
    2050         753 :     ort->namedMonthly(20).title = "EndUseEnergyConsumptionOtherFuelsMonthly";
    2051         753 :     ort->namedMonthly(21).title = "PeakEnergyEndUseElectricityPart1Monthly";
    2052         753 :     ort->namedMonthly(22).title = "PeakEnergyEndUseElectricityPart2Monthly";
    2053         753 :     ort->namedMonthly(23).title = "ElectricComponentsOfPeakDemandMonthly";
    2054         753 :     ort->namedMonthly(24).title = "PeakEnergyEndUseNaturalGasMonthly";
    2055         753 :     ort->namedMonthly(25).title = "PeakEnergyEndUseDieselMonthly";
    2056         753 :     ort->namedMonthly(26).title = "PeakEnergyEndUseFuelOilMonthly";
    2057         753 :     ort->namedMonthly(27).title = "PeakEnergyEndUseCoalMonthly";
    2058         753 :     ort->namedMonthly(28).title = "PeakEnergyEndUsePropaneMonthly";
    2059         753 :     ort->namedMonthly(29).title = "PeakEnergyEndUseGasolineMonthly";
    2060         753 :     ort->namedMonthly(30).title = "PeakEnergyEndUseOtherFuelsMonthly";
    2061         753 :     ort->namedMonthly(31).title = "SetpointsNotMetWithTemperaturesMonthly";
    2062         753 :     ort->namedMonthly(32).title = "ComfortReportSimple55Monthly";
    2063         753 :     ort->namedMonthly(33).title = "UnglazedTranspiredSolarCollectorSummaryMonthly";
    2064         753 :     ort->namedMonthly(34).title = "OccupantComfortDataSummaryMonthly";
    2065         753 :     ort->namedMonthly(35).title = "ChillerReportMonthly";
    2066         753 :     ort->namedMonthly(36).title = "TowerReportMonthly";
    2067         753 :     ort->namedMonthly(37).title = "BoilerReportMonthly";
    2068         753 :     ort->namedMonthly(38).title = "DXReportMonthly";
    2069         753 :     ort->namedMonthly(39).title = "WindowReportMonthly";
    2070         753 :     ort->namedMonthly(40).title = "WindowEnergyReportMonthly";
    2071         753 :     ort->namedMonthly(41).title = "WindowZoneSummaryMonthly";
    2072         753 :     ort->namedMonthly(42).title = "WindowEnergyZoneSummaryMonthly";
    2073         753 :     ort->namedMonthly(43).title = "AverageOutdoorConditionsMonthly";
    2074         753 :     ort->namedMonthly(44).title = "OutdoorConditionsMaximumDryBulbMonthly";
    2075         753 :     ort->namedMonthly(45).title = "OutdoorConditionsMinimumDryBulbMonthly";
    2076         753 :     ort->namedMonthly(46).title = "OutdoorConditionsMaximumWetBulbMonthly";
    2077         753 :     ort->namedMonthly(47).title = "OutdoorConditionsMaximumDewPointMonthly";
    2078         753 :     ort->namedMonthly(48).title = "OutdoorGroundConditionsMonthly";
    2079         753 :     ort->namedMonthly(49).title = "WindowACReportMonthly";
    2080         753 :     ort->namedMonthly(50).title = "WaterHeaterReportMonthly";
    2081         753 :     ort->namedMonthly(51).title = "GeneratorReportMonthly";
    2082         753 :     ort->namedMonthly(52).title = "DaylightingReportMonthly";
    2083         753 :     ort->namedMonthly(53).title = "CoilReportMonthly";
    2084         753 :     ort->namedMonthly(54).title = "PlantLoopDemandReportMonthly";
    2085         753 :     ort->namedMonthly(55).title = "FanReportMonthly";
    2086         753 :     ort->namedMonthly(56).title = "PumpReportMonthly";
    2087         753 :     ort->namedMonthly(57).title = "CondLoopDemandReportMonthly";
    2088         753 :     ort->namedMonthly(58).title = "ZoneTemperatureOscillationReportMonthly";
    2089         753 :     ort->namedMonthly(59).title = "AirLoopSystemEnergyAndWaterUseMonthly";
    2090         753 :     ort->namedMonthly(60).title = "AirLoopSystemComponentLoadsMonthly";
    2091         753 :     ort->namedMonthly(61).title = "AirLoopSystemComponentEnergyUseMonthly";
    2092         753 :     ort->namedMonthly(62).title = "MechanicalVentilationLoadsMonthly";
    2093         753 :     ort->namedMonthly(63).title = "HeatEmissionsReportMonthly";
    2094             : 
    2095             :     if (numNamedMonthly != NumMonthlyReports) {
    2096             :         ShowFatalError(state,
    2097             :                        format("InitializePredefinedMonthlyTitles: Number of Monthly Reports in OutputReportTabular=[{}] does not match number in "
    2098             :                               "DataOutputs=[{}].",
    2099             :                               numNamedMonthly,
    2100             :                               NumMonthlyReports));
    2101             :     } else {
    2102       48192 :         for (int xcount = 1; xcount <= numNamedMonthly; ++xcount) {
    2103       47439 :             if (!Util::SameString(MonthlyNamedReports(xcount), ort->namedMonthly(xcount).title)) {
    2104           0 :                 ShowSevereError(state,
    2105             :                                 "InitializePredefinedMonthlyTitles: Monthly Report Titles in OutputReportTabular do not match titles in DataOutput.");
    2106           0 :                 ShowContinueError(state, format("first mismatch at ORT [{}] =\"{}\".", numNamedMonthly, ort->namedMonthly(xcount).title));
    2107           0 :                 ShowContinueError(state, format("same location in DO =\"{}\".", MonthlyNamedReports(xcount)));
    2108           0 :                 ShowFatalError(state, "Preceding condition causes termination.");
    2109             :             }
    2110             :         }
    2111             :     }
    2112         753 : }
    2113             : 
    2114         753 : void CreatePredefinedMonthlyReports(EnergyPlusData &state)
    2115             : {
    2116             :     // SUBROUTINE INFORMATION:
    2117             :     //       AUTHOR         Jason Glazer
    2118             :     //       DATE WRITTEN   September 2008
    2119             :     //       MODIFIED       na
    2120             :     //       RE-ENGINEERED  na
    2121             : 
    2122             :     // PURPOSE OF THIS SUBROUTINE:
    2123             :     //   For any predefined monthly reports that have been
    2124             :     //   called out, define the individual columns.
    2125             : 
    2126             :     // METHODOLOGY EMPLOYED:
    2127             :     // REFERENCES:
    2128             :     // na
    2129             : 
    2130             :     // USE STATEMENTS:
    2131             : 
    2132             :     // Locals
    2133             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    2134             :     // na
    2135             : 
    2136             :     // SUBROUTINE PARAMETER DEFINITIONS:
    2137             :     // na
    2138             : 
    2139             :     // INTERFACE BLOCK SPECIFICATIONS:
    2140             :     // na
    2141             : 
    2142             :     // DERIVED TYPE DEFINITIONS:
    2143             :     // na
    2144             : 
    2145             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2146             :     int curReport;
    2147         753 :     auto &ort = state.dataOutRptTab;
    2148             : 
    2149             :     // ----------------------------------------------------------------------------------------
    2150             :     // If any variable are added to these reports they also need to be added to the
    2151             :     // AddVariablesForMonthlyReport routine in InputProcessor.
    2152             :     // ----------------------------------------------------------------------------------------
    2153             : 
    2154         753 :     if (ort->namedMonthly(1).show) {
    2155          24 :         curReport = AddMonthlyReport(state, "ZoneCoolingSummaryMonthly", 2, true);
    2156          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Cooling Energy", "", AggType::SumOrAvg);
    2157          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Cooling Rate", "", AggType::Maximum);
    2158          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2159          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2160          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Total Internal Latent Gain Energy", "", AggType::SumOrAvg);
    2161          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Total Internal Latent Gain Rate", "", AggType::Maximum);
    2162          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2163          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2164             :     }
    2165         753 :     if (ort->namedMonthly(2).show) {
    2166          24 :         curReport = AddMonthlyReport(state, "ZoneHeatingSummaryMonthly", 2, true);
    2167          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Heating Energy", "", AggType::SumOrAvg);
    2168          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Heating Rate", "", AggType::Maximum);
    2169          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2170             :     }
    2171         753 :     if (ort->namedMonthly(3).show) {
    2172          25 :         curReport = AddMonthlyReport(state, "ZoneElectricSummaryMonthly", 2, true);
    2173          25 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Electricity Energy", "", AggType::SumOrAvg);
    2174          25 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Electricity Energy", "", AggType::Maximum);
    2175          25 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Electricity Energy", "", AggType::SumOrAvg);
    2176          25 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Electricity Energy", "", AggType::Maximum);
    2177             :     }
    2178         753 :     if (ort->namedMonthly(4).show) {
    2179          24 :         curReport = AddMonthlyReport(state, "SpaceGainsMonthly", 2, true);
    2180          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Total Heating Energy", "", AggType::SumOrAvg);
    2181          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Total Heating Energy", "", AggType::SumOrAvg);
    2182          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2183          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Gas Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2184          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Hot Water Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2185          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Steam Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2186          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Other Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2187          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Gain Energy", "", AggType::SumOrAvg);
    2188          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Loss Energy", "", AggType::SumOrAvg);
    2189             :     }
    2190         753 :     if (ort->namedMonthly(5).show) {
    2191          24 :         curReport = AddMonthlyReport(state, "PeakSpaceGainsMonthly", 2, true);
    2192          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Total Heating Energy", "", AggType::Maximum);
    2193          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Total Heating Energy", "", AggType::Maximum);
    2194          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Total Heating Energy", "", AggType::Maximum);
    2195          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Gas Equipment Total Heating Energy", "", AggType::Maximum);
    2196          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Hot Water Equipment Total Heating Energy", "", AggType::Maximum);
    2197          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Steam Equipment Total Heating Energy", "", AggType::Maximum);
    2198          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Other Equipment Total Heating Energy", "", AggType::Maximum);
    2199          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Gain Energy", "", AggType::Maximum);
    2200          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Loss Energy", "", AggType::Maximum);
    2201             :     }
    2202         753 :     if (ort->namedMonthly(6).show) {
    2203          24 :         curReport = AddMonthlyReport(state, "SpaceGainComponentsAtCoolingPeakMonthly", 2, true);
    2204          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Cooling Rate", "", AggType::Maximum);
    2205          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2206          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2207          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2208          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Gas Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2209          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Hot Water Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2210          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Steam Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2211          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Other Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2212          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Gain Energy", "", AggType::ValueWhenMaxMin);
    2213          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Loss Energy", "", AggType::ValueWhenMaxMin);
    2214             :     }
    2215         753 :     if (ort->namedMonthly(7).show) {
    2216          24 :         curReport = AddMonthlyReport(state, "EnergyConsumptionElectricityNaturalGasMonthly", 2, true);
    2217          24 :         AddMonthlyFieldSetInput(state, curReport, "Electricity:Facility", "", AggType::SumOrAvg);
    2218          24 :         AddMonthlyFieldSetInput(state, curReport, "Electricity:Facility", "", AggType::Maximum);
    2219          24 :         AddMonthlyFieldSetInput(state, curReport, "NaturalGas:Facility", "", AggType::SumOrAvg);
    2220          24 :         AddMonthlyFieldSetInput(state, curReport, "NaturalGas:Facility", "", AggType::Maximum);
    2221             :     }
    2222         753 :     if (ort->namedMonthly(8).show) {
    2223          24 :         curReport = AddMonthlyReport(state, "EnergyConsumptionElectricityGeneratedPropaneMonthly", 2, true);
    2224          24 :         AddMonthlyFieldSetInput(state, curReport, "ElectricityProduced:Facility", "", AggType::SumOrAvg);
    2225          24 :         AddMonthlyFieldSetInput(state, curReport, "ElectricityProduced:Facility", "", AggType::Maximum);
    2226          24 :         AddMonthlyFieldSetInput(state, curReport, "Propane:Facility", "", AggType::SumOrAvg);
    2227          24 :         AddMonthlyFieldSetInput(state, curReport, "Propane:Facility", "", AggType::Maximum);
    2228             :     }
    2229         753 :     if (ort->namedMonthly(9).show) {
    2230          24 :         curReport = AddMonthlyReport(state, "EnergyConsumptionDieselFuelOilMonthly", 2, true);
    2231          24 :         AddMonthlyFieldSetInput(state, curReport, "Diesel:Facility", "", AggType::SumOrAvg);
    2232          24 :         AddMonthlyFieldSetInput(state, curReport, "Diesel:Facility", "", AggType::Maximum);
    2233          24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo1:Facility", "", AggType::SumOrAvg);
    2234          24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo1:Facility", "", AggType::Maximum);
    2235          24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo2:Facility", "", AggType::SumOrAvg);
    2236          24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo2:Facility", "", AggType::Maximum);
    2237             :     }
    2238         753 :     if (ort->namedMonthly(10).show) {
    2239          24 :         curReport = AddMonthlyReport(state, "EnergyConsumptionDistrictHeatingCoolingMonthly", 2, true);
    2240          24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictCooling:Facility", "", AggType::SumOrAvg);
    2241          24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictCooling:Facility", "", AggType::Maximum);
    2242          24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingWater:Facility", "", AggType::SumOrAvg);
    2243          24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingWater:Facility", "", AggType::Maximum);
    2244          24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingSteam:Facility", "", AggType::SumOrAvg);
    2245          24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingSteam:Facility", "", AggType::Maximum);
    2246             :     }
    2247         753 :     if (ort->namedMonthly(11).show) {
    2248          24 :         curReport = AddMonthlyReport(state, "EnergyConsumptionCoalGasolineMonthly", 2, true);
    2249          24 :         AddMonthlyFieldSetInput(state, curReport, "Coal:Facility", "", AggType::SumOrAvg);
    2250          24 :         AddMonthlyFieldSetInput(state, curReport, "Coal:Facility", "", AggType::Maximum);
    2251          24 :         AddMonthlyFieldSetInput(state, curReport, "Gasoline:Facility", "", AggType::SumOrAvg);
    2252          24 :         AddMonthlyFieldSetInput(state, curReport, "Gasoline:Facility", "", AggType::Maximum);
    2253             :     }
    2254         753 :     if (ort->namedMonthly(12).show) {
    2255          24 :         curReport = AddMonthlyReport(state, "EnergyConsumptionOtherFuelsMonthly", 2, true);
    2256          24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel1:Facility", "", AggType::SumOrAvg);
    2257          24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel1:Facility", "", AggType::Maximum);
    2258          24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel2:Facility", "", AggType::SumOrAvg);
    2259          24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel2:Facility", "", AggType::Maximum);
    2260             :     }
    2261         753 :     if (ort->namedMonthly(13).show) {
    2262          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionElectricityMonthly", 2, true);
    2263          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorLights:Electricity", "", AggType::SumOrAvg);
    2264          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorLights:Electricity", "", AggType::SumOrAvg);
    2265          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:Electricity", "", AggType::SumOrAvg);
    2266          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Electricity", "", AggType::SumOrAvg);
    2267          24 :         AddMonthlyFieldSetInput(state, curReport, "Fans:Electricity", "", AggType::SumOrAvg);
    2268          24 :         AddMonthlyFieldSetInput(state, curReport, "Pumps:Electricity", "", AggType::SumOrAvg);
    2269          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Electricity", "", AggType::SumOrAvg);
    2270          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Electricity", "", AggType::SumOrAvg);
    2271          24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRejection:Electricity", "", AggType::SumOrAvg);
    2272          24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:Electricity", "", AggType::SumOrAvg);
    2273          24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRecovery:Electricity", "", AggType::SumOrAvg);
    2274          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Electricity", "", AggType::SumOrAvg);
    2275          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Electricity", "", AggType::SumOrAvg);
    2276             :     }
    2277         753 :     if (ort->namedMonthly(14).show) {
    2278          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionNaturalGasMonthly", 2, true);
    2279          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:NaturalGas", "", AggType::SumOrAvg);
    2280          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:NaturalGas", "", AggType::SumOrAvg);
    2281          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:NaturalGas", "", AggType::SumOrAvg);
    2282          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:NaturalGas", "", AggType::SumOrAvg);
    2283          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:NaturalGas", "", AggType::SumOrAvg);
    2284          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:NaturalGas", "", AggType::SumOrAvg);
    2285          24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:NaturalGas", "", AggType::SumOrAvg);
    2286             :     }
    2287         753 :     if (ort->namedMonthly(15).show) {
    2288          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionDieselMonthly", 2, true);
    2289          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Diesel", "", AggType::SumOrAvg);
    2290          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Diesel", "", AggType::SumOrAvg);
    2291          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Diesel", "", AggType::SumOrAvg);
    2292          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Diesel", "", AggType::SumOrAvg);
    2293          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Diesel", "", AggType::SumOrAvg);
    2294             :     }
    2295         753 :     if (ort->namedMonthly(16).show) {
    2296          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionFuelOilMonthly", 2, true);
    2297          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo1", "", AggType::SumOrAvg);
    2298          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo1", "", AggType::SumOrAvg);
    2299          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo1", "", AggType::SumOrAvg);
    2300          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo1", "", AggType::SumOrAvg);
    2301          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo1", "", AggType::SumOrAvg);
    2302          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo2", "", AggType::SumOrAvg);
    2303          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo2", "", AggType::SumOrAvg);
    2304          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo2", "", AggType::SumOrAvg);
    2305          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo2", "", AggType::SumOrAvg);
    2306          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo2", "", AggType::SumOrAvg);
    2307             :     }
    2308         753 :     if (ort->namedMonthly(17).show) {
    2309          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionCoalMonthly", 2, true);
    2310          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Coal", "", AggType::SumOrAvg);
    2311          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Coal", "", AggType::SumOrAvg);
    2312          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Coal", "", AggType::SumOrAvg);
    2313             :     }
    2314         753 :     if (ort->namedMonthly(18).show) {
    2315          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionPropaneMonthly", 2, true);
    2316          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Propane", "", AggType::SumOrAvg);
    2317          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Propane", "", AggType::SumOrAvg);
    2318          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Propane", "", AggType::SumOrAvg);
    2319          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Propane", "", AggType::SumOrAvg);
    2320          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Propane", "", AggType::SumOrAvg);
    2321          24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:Propane", "", AggType::SumOrAvg);
    2322             :     }
    2323         753 :     if (ort->namedMonthly(19).show) {
    2324          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionGasolineMonthly", 2, true);
    2325          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Gasoline", "", AggType::SumOrAvg);
    2326          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Gasoline", "", AggType::SumOrAvg);
    2327          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Gasoline", "", AggType::SumOrAvg);
    2328          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Gasoline", "", AggType::SumOrAvg);
    2329          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Gasoline", "", AggType::SumOrAvg);
    2330             :     }
    2331         753 :     if (ort->namedMonthly(20).show) {
    2332          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionOtherFuelsMonthly", 2, true);
    2333          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel1", "", AggType::SumOrAvg);
    2334          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel1", "", AggType::SumOrAvg);
    2335          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel1", "", AggType::SumOrAvg);
    2336          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel1", "", AggType::SumOrAvg);
    2337          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel1", "", AggType::SumOrAvg);
    2338          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel2", "", AggType::SumOrAvg);
    2339          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel2", "", AggType::SumOrAvg);
    2340          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel2", "", AggType::SumOrAvg);
    2341          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel2", "", AggType::SumOrAvg);
    2342          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel2", "", AggType::SumOrAvg);
    2343             :     }
    2344         753 :     if (ort->namedMonthly(21).show) {
    2345          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseElectricityPart1Monthly", 2, true);
    2346          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorLights:Electricity", "", AggType::Maximum);
    2347          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorLights:Electricity", "", AggType::Maximum);
    2348          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:Electricity", "", AggType::Maximum);
    2349          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Electricity", "", AggType::Maximum);
    2350          24 :         AddMonthlyFieldSetInput(state, curReport, "Fans:Electricity", "", AggType::Maximum);
    2351          24 :         AddMonthlyFieldSetInput(state, curReport, "Pumps:Electricity", "", AggType::Maximum);
    2352          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Electricity", "", AggType::Maximum);
    2353             :     }
    2354         753 :     if (ort->namedMonthly(22).show) {
    2355          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseElectricityPart2Monthly", 2, true);
    2356          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Electricity", "", AggType::Maximum);
    2357          24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRejection:Electricity", "", AggType::Maximum);
    2358          24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:Electricity", "", AggType::Maximum);
    2359          24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRecovery:Electricity", "", AggType::Maximum);
    2360          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Electricity", "", AggType::Maximum);
    2361          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Electricity", "", AggType::Maximum);
    2362             :     }
    2363         753 :     if (ort->namedMonthly(23).show) {
    2364          24 :         curReport = AddMonthlyReport(state, "ElectricComponentsOfPeakDemandMonthly", 2, true);
    2365          24 :         AddMonthlyFieldSetInput(state, curReport, "Electricity:Facility", "", AggType::Maximum);
    2366          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorLights:Electricity", "", AggType::ValueWhenMaxMin);
    2367          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:Electricity", "", AggType::ValueWhenMaxMin);
    2368          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorLights:Electricity", "", AggType::ValueWhenMaxMin);
    2369          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Electricity", "", AggType::ValueWhenMaxMin);
    2370          24 :         AddMonthlyFieldSetInput(state, curReport, "Fans:Electricity", "", AggType::ValueWhenMaxMin);
    2371          24 :         AddMonthlyFieldSetInput(state, curReport, "Pumps:Electricity", "", AggType::ValueWhenMaxMin);
    2372          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Electricity", "", AggType::ValueWhenMaxMin);
    2373          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Electricity", "", AggType::ValueWhenMaxMin);
    2374          24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRejection:Electricity", "", AggType::ValueWhenMaxMin);
    2375             :     }
    2376         753 :     if (ort->namedMonthly(24).show) {
    2377          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseNaturalGasMonthly", 2, true);
    2378          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:NaturalGas", "", AggType::Maximum);
    2379          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:NaturalGas", "", AggType::Maximum);
    2380          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:NaturalGas", "", AggType::Maximum);
    2381          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:NaturalGas", "", AggType::Maximum);
    2382          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:NaturalGas", "", AggType::Maximum);
    2383          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:NaturalGas", "", AggType::Maximum);
    2384             :     }
    2385         753 :     if (ort->namedMonthly(25).show) {
    2386          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseDieselMonthly", 2, true);
    2387          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Diesel", "", AggType::Maximum);
    2388          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Diesel", "", AggType::Maximum);
    2389          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Diesel", "", AggType::Maximum);
    2390          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Diesel", "", AggType::Maximum);
    2391          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Diesel", "", AggType::Maximum);
    2392             :     }
    2393         753 :     if (ort->namedMonthly(26).show) {
    2394          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseFuelOilMonthly", 2, true);
    2395          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo1", "", AggType::Maximum);
    2396          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo1", "", AggType::Maximum);
    2397          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo1", "", AggType::Maximum);
    2398          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo1", "", AggType::Maximum);
    2399          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo1", "", AggType::Maximum);
    2400          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo2", "", AggType::Maximum);
    2401          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo2", "", AggType::Maximum);
    2402          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo2", "", AggType::Maximum);
    2403          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo2", "", AggType::Maximum);
    2404          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo2", "", AggType::Maximum);
    2405             :     }
    2406         753 :     if (ort->namedMonthly(27).show) {
    2407          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseCoalMonthly", 2, true);
    2408          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Coal", "", AggType::Maximum);
    2409          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Coal", "", AggType::Maximum);
    2410          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Coal", "", AggType::Maximum);
    2411             :     }
    2412         753 :     if (ort->namedMonthly(28).show) {
    2413          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUsePropaneMonthly", 2, true);
    2414          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Propane", "", AggType::Maximum);
    2415          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Propane", "", AggType::Maximum);
    2416          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Propane", "", AggType::Maximum);
    2417          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Propane", "", AggType::Maximum);
    2418          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Propane", "", AggType::Maximum);
    2419             :     }
    2420         753 :     if (ort->namedMonthly(29).show) {
    2421          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseGasolineMonthly", 2, true);
    2422          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Gasoline", "", AggType::Maximum);
    2423          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Gasoline", "", AggType::Maximum);
    2424          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Gasoline", "", AggType::Maximum);
    2425          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Gasoline", "", AggType::Maximum);
    2426          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Gasoline", "", AggType::Maximum);
    2427             :     }
    2428         753 :     if (ort->namedMonthly(30).show) {
    2429          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseOtherFuelsMonthly", 2, true);
    2430          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel1", "", AggType::Maximum);
    2431          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel1", "", AggType::Maximum);
    2432          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel1", "", AggType::Maximum);
    2433          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel1", "", AggType::Maximum);
    2434          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel1", "", AggType::Maximum);
    2435          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel2", "", AggType::Maximum);
    2436          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel2", "", AggType::Maximum);
    2437          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel2", "", AggType::Maximum);
    2438          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel2", "", AggType::Maximum);
    2439          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel2", "", AggType::Maximum);
    2440             :     }
    2441         753 :     if (ort->namedMonthly(31).show) {
    2442          24 :         curReport = AddMonthlyReport(state, "SetpointsNotMetWithTemperaturesMonthly", 2, true);
    2443          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Heating Setpoint Not Met Time", "", AggType::HoursNonZero);
    2444          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2445          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Heating Setpoint Not Met While Occupied Time", "", AggType::HoursNonZero);
    2446          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2447          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Cooling Setpoint Not Met Time", "", AggType::HoursNonZero);
    2448          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2449          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Cooling Setpoint Not Met While Occupied Time", "", AggType::HoursNonZero);
    2450          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2451             :     }
    2452         753 :     if (ort->namedMonthly(32).show) {
    2453          24 :         curReport = AddMonthlyReport(state, "ComfortReportSimple55Monthly", 2, true);
    2454          24 :         AddMonthlyFieldSetInput(
    2455             :             state, curReport, "Zone Thermal Comfort ASHRAE 55 Simple Model Summer Clothes Not Comfortable Time", "", AggType::HoursNonZero);
    2456          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2457          24 :         AddMonthlyFieldSetInput(
    2458             :             state, curReport, "Zone Thermal Comfort ASHRAE 55 Simple Model Winter Clothes Not Comfortable Time", "", AggType::HoursNonZero);
    2459          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2460          24 :         AddMonthlyFieldSetInput(
    2461             :             state, curReport, "Zone Thermal Comfort ASHRAE 55 Simple Model Summer or Winter Clothes Not Comfortable Time", "", AggType::HoursNonZero);
    2462          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2463             :     }
    2464         753 :     if (ort->namedMonthly(33).show) {
    2465          24 :         curReport = AddMonthlyReport(state, "UnglazedTranspiredSolarCollectorSummaryMonthly", 5, true);
    2466          24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector System Efficiency", "", AggType::HoursNonZero);
    2467          24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector System Efficiency", "", AggType::SumOrAverageHoursShown);
    2468          24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector Outside Face Suction Velocity", "", AggType::SumOrAverageHoursShown);
    2469          24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector Sensible Heating Rate", "", AggType::SumOrAverageHoursShown);
    2470             :     }
    2471         753 :     if (ort->namedMonthly(34).show) {
    2472          24 :         curReport = AddMonthlyReport(state, "OccupantComfortDataSummaryMonthly", 5, true);
    2473          24 :         AddMonthlyFieldSetInput(state, curReport, "People Occupant Count", "", AggType::HoursNonZero);
    2474          24 :         AddMonthlyFieldSetInput(state, curReport, "People Air Temperature", "", AggType::SumOrAverageHoursShown);
    2475          24 :         AddMonthlyFieldSetInput(state, curReport, "People Air Relative Humidity", "", AggType::SumOrAverageHoursShown);
    2476          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Thermal Comfort Fanger Model PMV", "", AggType::SumOrAverageHoursShown);
    2477          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Thermal Comfort Fanger Model PPD", "", AggType::SumOrAverageHoursShown);
    2478             :     }
    2479         753 :     if (ort->namedMonthly(35).show) {
    2480          24 :         curReport = AddMonthlyReport(state, "ChillerReportMonthly", 2, true);
    2481          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Electricity Energy", "", AggType::SumOrAvg);
    2482          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Electricity Rate", "", AggType::Maximum);
    2483          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Electricity Energy", "", AggType::HoursNonZero);
    2484          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Evaporator Cooling Energy", "", AggType::SumOrAvg);
    2485          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Evaporator Cooling Rate", "", AggType::Maximum);
    2486          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Condenser Heat Transfer Energy", "", AggType::SumOrAvg);
    2487          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller COP", "", AggType::SumOrAvg);
    2488          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller COP", "", AggType::Maximum);
    2489          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Part Load Ratio", "", AggType::SumOrAvg);
    2490          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Part Load Ratio", "", AggType::Maximum);
    2491             :     }
    2492         753 :     if (ort->namedMonthly(36).show) {
    2493          24 :         curReport = AddMonthlyReport(state, "TowerReportMonthly", 2, true);
    2494          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Fan Electricity Energy", "", AggType::SumOrAvg);
    2495          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Fan Electricity Energy", "", AggType::HoursNonZero);
    2496          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Fan Electricity Rate", "", AggType::Maximum);
    2497          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Heat Transfer Rate", "", AggType::Maximum);
    2498          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Inlet Temperature", "", AggType::SumOrAvg);
    2499          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Outlet Temperature", "", AggType::SumOrAvg);
    2500          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Mass Flow Rate", "", AggType::SumOrAvg);
    2501             :     }
    2502         753 :     if (ort->namedMonthly(37).show) {
    2503          24 :         curReport = AddMonthlyReport(state, "BoilerReportMonthly", 2, true);
    2504          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Heating Energy", "", AggType::SumOrAvg);
    2505          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Gas Consumption", "", AggType::SumOrAvg);
    2506          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Heating Energy", "", AggType::HoursNonZero);
    2507          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Heating Rate", "", AggType::Maximum);
    2508          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Gas Consumption Rate", "", AggType::Maximum);
    2509          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Inlet Temperature", "", AggType::SumOrAvg);
    2510          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Outlet Temperature", "", AggType::SumOrAvg);
    2511          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Mass Flow Rate", "", AggType::SumOrAvg);
    2512          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Ancillary Electricity Rate", "", AggType::SumOrAvg);
    2513          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Part Load Ratio", "", AggType::SumOrAvg);
    2514          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Part Load Ratio", "", AggType::Maximum);
    2515             :     }
    2516         753 :     if (ort->namedMonthly(38).show) {
    2517          24 :         curReport = AddMonthlyReport(state, "DXReportMonthly", 2, true);
    2518          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Energy", "", AggType::SumOrAvg);
    2519          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Electricity Energy", "", AggType::SumOrAvg);
    2520          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Energy", "", AggType::HoursNonZero);
    2521          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Energy", "", AggType::SumOrAvg);
    2522          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Latent Cooling Energy", "", AggType::SumOrAvg);
    2523          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Crankcase Heater Electricity Energy", "", AggType::SumOrAvg);
    2524          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Runtime Fraction", "", AggType::Maximum);
    2525          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Runtime Fraction", "", AggType::Minimum);
    2526          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Rate", "", AggType::Maximum);
    2527          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Rate", "", AggType::Maximum);
    2528          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Latent Cooling Rate", "", AggType::Maximum);
    2529          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Electricity Rate", "", AggType::Maximum);
    2530          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Crankcase Heater Electricity Rate", "", AggType::Maximum);
    2531             :     }
    2532         753 :     if (ort->namedMonthly(39).show) {
    2533          24 :         curReport = AddMonthlyReport(state, "WindowReportMonthly", 2, true);
    2534          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Solar Radiation Rate", "", AggType::SumOrAvg);
    2535          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Beam Solar Radiation Rate", "", AggType::SumOrAvg);
    2536          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Diffuse Solar Radiation Rate", "", AggType::SumOrAvg);
    2537          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Gain Rate", "", AggType::SumOrAvg);
    2538          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Loss Rate", "", AggType::SumOrAvg);
    2539          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Inside Face Glazing Condensation Status", "", AggType::HoursNonZero);
    2540          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Shading Device Is On Time Fraction", "", AggType::HoursNonZero);
    2541          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Storm Window On Off Status", "", AggType::HoursNonZero);
    2542             :     }
    2543         753 :     if (ort->namedMonthly(40).show) {
    2544          24 :         curReport = AddMonthlyReport(state, "WindowEnergyReportMonthly", 2, true);
    2545          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Solar Radiation Energy", "", AggType::SumOrAvg);
    2546          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Beam Solar Radiation Energy", "", AggType::SumOrAvg);
    2547          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Diffuse Solar Radiation Energy", "", AggType::SumOrAvg);
    2548          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Gain Energy", "", AggType::SumOrAvg);
    2549          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Loss Energy", "", AggType::SumOrAvg);
    2550             :     }
    2551         753 :     if (ort->namedMonthly(41).show) {
    2552          24 :         curReport = AddMonthlyReport(state, "WindowZoneSummaryMonthly", 2, true);
    2553          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Gain Rate", "", AggType::SumOrAvg);
    2554          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Loss Rate", "", AggType::SumOrAvg);
    2555          24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Windows Total Transmitted Solar Radiation Rate", "", AggType::SumOrAvg);
    2556          24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Exterior Windows Total Transmitted Beam Solar Radiation Rate", "", AggType::SumOrAvg);
    2557          24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Exterior Windows Total Transmitted Diffuse Solar Radiation Rate", "", AggType::SumOrAvg);
    2558          24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Interior Windows Total Transmitted Diffuse Solar Radiation Rate", "", AggType::SumOrAvg);
    2559          24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Interior Windows Total Transmitted Beam Solar Radiation Rate", "", AggType::SumOrAvg);
    2560             :     }
    2561         753 :     if (ort->namedMonthly(42).show) {
    2562          24 :         curReport = AddMonthlyReport(state, "WindowEnergyZoneSummaryMonthly", 2, true);
    2563          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Gain Energy", "", AggType::SumOrAvg);
    2564          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Loss Energy", "", AggType::SumOrAvg);
    2565          24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Windows Total Transmitted Solar Radiation Energy", "", AggType::SumOrAvg);
    2566          24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Exterior Windows Total Transmitted Beam Solar Radiation Energy", "", AggType::SumOrAvg);
    2567          24 :         AddMonthlyFieldSetInput(
    2568             :             state, curReport, "Enclosure Exterior Windows Total Transmitted Diffuse Solar Radiation Energy", "", AggType::SumOrAvg);
    2569          24 :         AddMonthlyFieldSetInput(
    2570             :             state, curReport, "Enclosure Interior Windows Total Transmitted Diffuse Solar Radiation Energy", "", AggType::SumOrAvg);
    2571          24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Interior Windows Total Transmitted Beam Solar Radiation Energy", "", AggType::SumOrAvg);
    2572             :     }
    2573         753 :     if (ort->namedMonthly(43).show) {
    2574          24 :         curReport = AddMonthlyReport(state, "AverageOutdoorConditionsMonthly", 2, true);
    2575          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::SumOrAvg);
    2576          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::SumOrAvg);
    2577          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::SumOrAvg);
    2578          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::SumOrAvg);
    2579          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::SumOrAvg);
    2580          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::SumOrAvg);
    2581          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::SumOrAvg);
    2582          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Rain Status", "", AggType::SumOrAvg);
    2583             :     }
    2584         753 :     if (ort->namedMonthly(44).show) {
    2585          24 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMaximumDryBulbMonthly", 2, true);
    2586          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::Maximum);
    2587          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2588          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::ValueWhenMaxMin);
    2589          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2590          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2591          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2592          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2593             :     }
    2594         753 :     if (ort->namedMonthly(45).show) {
    2595          24 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMinimumDryBulbMonthly", 2, true);
    2596          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::Minimum);
    2597          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2598          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::ValueWhenMaxMin);
    2599          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2600          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2601          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2602          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2603             :     }
    2604         753 :     if (ort->namedMonthly(46).show) {
    2605          24 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMaximumWetBulbMonthly", 2, true);
    2606          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::Maximum);
    2607          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2608          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::ValueWhenMaxMin);
    2609          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2610          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2611          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2612          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2613             :     }
    2614         753 :     if (ort->namedMonthly(47).show) {
    2615          24 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMaximumDewPointMonthly", 2, true);
    2616          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::Maximum);
    2617          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2618          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2619          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2620          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2621          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2622          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2623             :     }
    2624         753 :     if (ort->namedMonthly(48).show) {
    2625          24 :         curReport = AddMonthlyReport(state, "OutdoorGroundConditionsMonthly", 2, true);
    2626          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Ground Temperature", "", AggType::SumOrAvg);
    2627          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Surface Ground Temperature", "", AggType::SumOrAvg);
    2628          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Deep Ground Temperature", "", AggType::SumOrAvg);
    2629          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Mains Water Temperature", "", AggType::SumOrAvg);
    2630          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Ground Reflected Solar Radiation Rate per Area", "", AggType::SumOrAvg);
    2631          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Snow on Ground Status", "", AggType::SumOrAvg);
    2632             :     }
    2633         753 :     if (ort->namedMonthly(49).show) {
    2634          24 :         curReport = AddMonthlyReport(state, "WindowACReportMonthly", 2, true);
    2635          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Total Cooling Energy", "", AggType::SumOrAvg);
    2636          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Electricity Energy", "", AggType::SumOrAvg);
    2637          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Total Cooling Energy", "", AggType::HoursNonZero);
    2638          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Sensible Cooling Energy", "", AggType::SumOrAvg);
    2639          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Latent Cooling Energy", "", AggType::SumOrAvg);
    2640          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Total Cooling Rate", "", AggType::Maximum);
    2641          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Sensible Cooling Rate", "", AggType::ValueWhenMaxMin);
    2642          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Latent Cooling Rate", "", AggType::ValueWhenMaxMin);
    2643          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Electricity Rate", "", AggType::ValueWhenMaxMin);
    2644             :     }
    2645         753 :     if (ort->namedMonthly(50).show) {
    2646          24 :         curReport = AddMonthlyReport(state, "WaterHeaterReportMonthly", 2, true);
    2647          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Total Demand Heat Transfer Energy", "", AggType::SumOrAvg);
    2648          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Use Side Heat Transfer Energy", "", AggType::SumOrAvg);
    2649          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Burner Heating Energy", "", AggType::SumOrAvg);
    2650          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Gas Consumption", "", AggType::SumOrAvg);
    2651          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Total Demand Heat Transfer Energy", "", AggType::HoursNonZero);
    2652          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Loss Demand Energy", "", AggType::SumOrAvg);
    2653          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Heat Loss Energy", "", AggType::SumOrAvg);
    2654          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Tank Temperature", "", AggType::SumOrAvg);
    2655          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Heat Recovery Supply Energy", "", AggType::SumOrAvg);
    2656          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Source Side Heat Transfer Energy", "", AggType::SumOrAvg);
    2657             :     }
    2658         753 :     if (ort->namedMonthly(51).show) {
    2659          24 :         curReport = AddMonthlyReport(state, "GeneratorReportMonthly", 2, true);
    2660          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Produced AC Electricity Energy", "", AggType::SumOrAvg);
    2661          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Diesel Consumption", "", AggType::SumOrAvg);
    2662          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Gas Consumption", "", AggType::SumOrAvg);
    2663          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Produced AC Electricity Energy", "", AggType::HoursNonZero);
    2664          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Total Heat Recovery", "", AggType::SumOrAvg);
    2665          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Jacket Heat Recovery Energy", "", AggType::SumOrAvg);
    2666          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Lube Heat Recovery", "", AggType::SumOrAvg);
    2667          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Exhaust Heat Recovery Energy", "", AggType::SumOrAvg);
    2668          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Exhaust Air Temperature", "", AggType::SumOrAvg);
    2669             :     }
    2670         753 :     if (ort->namedMonthly(52).show) {
    2671          24 :         curReport = AddMonthlyReport(state, "DaylightingReportMonthly", 2, true);
    2672          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Exterior Beam Normal Illuminance", "", AggType::HoursNonZero);
    2673          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Lighting Power Multiplier", "", AggType::SumOrAverageHoursShown);
    2674          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Lighting Power Multiplier", "", AggType::MinimumDuringHoursShown);
    2675          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Illuminance", "", AggType::SumOrAverageHoursShown);
    2676          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Glare Index", "", AggType::SumOrAverageHoursShown);
    2677          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Glare Index Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2678          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Daylight Illuminance Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2679          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Illuminance", "", AggType::SumOrAverageHoursShown);
    2680          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Glare Index", "", AggType::SumOrAverageHoursShown);
    2681          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Glare Index Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2682          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Daylight Illuminance Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2683             :     }
    2684         753 :     if (ort->namedMonthly(53).show) {
    2685          24 :         curReport = AddMonthlyReport(state, "CoilReportMonthly", 2, true);
    2686          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating Coil Heating Energy", "", AggType::SumOrAvg);
    2687          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating Coil Heating Rate", "", AggType::Maximum);
    2688          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Energy", "", AggType::SumOrAvg);
    2689          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Energy", "", AggType::SumOrAvg);
    2690          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Rate", "", AggType::Maximum);
    2691          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Rate", "", AggType::ValueWhenMaxMin);
    2692          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Wetted Area Fraction", "", AggType::SumOrAvg);
    2693             :     }
    2694         753 :     if (ort->namedMonthly(54).show) {
    2695          24 :         curReport = AddMonthlyReport(state, "PlantLoopDemandReportMonthly", 2, true);
    2696          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::SumOrAvg);
    2697          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::Maximum);
    2698          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::SumOrAvg);
    2699          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::Maximum);
    2700             :     }
    2701         753 :     if (ort->namedMonthly(55).show) {
    2702          25 :         curReport = AddMonthlyReport(state, "FanReportMonthly", 2, true);
    2703          25 :         AddMonthlyFieldSetInput(state, curReport, "Fan Electricity Energy", "", AggType::SumOrAvg);
    2704          25 :         AddMonthlyFieldSetInput(state, curReport, "Fan Rise in Air Temperature", "", AggType::SumOrAvg);
    2705          25 :         AddMonthlyFieldSetInput(state, curReport, "Fan Electricity Rate", "", AggType::Maximum);
    2706          25 :         AddMonthlyFieldSetInput(state, curReport, "Fan Rise in Air Temperature", "", AggType::ValueWhenMaxMin);
    2707             :     }
    2708         753 :     if (ort->namedMonthly(56).show) {
    2709          24 :         curReport = AddMonthlyReport(state, "PumpReportMonthly", 2, true);
    2710          24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Electricity Energy", "", AggType::SumOrAvg);
    2711          24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Fluid Heat Gain Energy", "", AggType::SumOrAvg);
    2712          24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Electricity Rate", "", AggType::Maximum);
    2713          24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Shaft Power", "", AggType::ValueWhenMaxMin);
    2714          24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Fluid Heat Gain Rate", "", AggType::ValueWhenMaxMin);
    2715          24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Outlet Temperature", "", AggType::ValueWhenMaxMin);
    2716          24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Mass Flow Rate", "", AggType::ValueWhenMaxMin);
    2717             :     }
    2718         753 :     if (ort->namedMonthly(57).show) {
    2719          24 :         curReport = AddMonthlyReport(state, "CondLoopDemandReportMonthly", 2, true);
    2720          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::SumOrAvg);
    2721          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::Maximum);
    2722          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Inlet Temperature", "", AggType::ValueWhenMaxMin);
    2723          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Outlet Temperature", "", AggType::ValueWhenMaxMin);
    2724          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::SumOrAvg);
    2725          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::Maximum);
    2726             :     }
    2727         753 :     if (ort->namedMonthly(58).show) {
    2728          24 :         curReport = AddMonthlyReport(state, "ZoneTemperatureOscillationReportMonthly", 2, true);
    2729          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Oscillating Temperatures Time", "", AggType::HoursNonZero);
    2730          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Occupant Count", "", AggType::SumOrAverageHoursShown);
    2731             :     }
    2732         753 :     if (ort->namedMonthly(59).show) {
    2733          24 :         curReport = AddMonthlyReport(state, "AirLoopSystemEnergyAndWaterUseMonthly", 2, true);
    2734          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Hot Water Energy", "", AggType::SumOrAvg);
    2735          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Steam Energy", "", AggType::SumOrAvg);
    2736          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Chilled Water Energy", "", AggType::SumOrAvg);
    2737          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Electricity Energy", "", AggType::SumOrAvg);
    2738          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Natural Gas Energy", "", AggType::SumOrAvg);
    2739          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Water Volume", "", AggType::SumOrAvg);
    2740             :     }
    2741             : 
    2742         753 :     if (ort->namedMonthly(60).show) {
    2743          24 :         curReport = AddMonthlyReport(state, "AirLoopSystemComponentLoadsMonthly", 2, true);
    2744          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Fan Air Heating Energy", "", AggType::SumOrAvg);
    2745          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Cooling Coil Total Cooling Energy", "", AggType::SumOrAvg);
    2746          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Total Heating Energy", "", AggType::SumOrAvg);
    2747          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heat Exchanger Total Heating Energy", "", AggType::SumOrAvg);
    2748          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heat Exchanger Total Cooling Energy", "", AggType::SumOrAvg);
    2749          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Humidifier Total Heating Energy", "", AggType::SumOrAvg);
    2750          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Evaporative Cooler Total Cooling Energy", "", AggType::SumOrAvg);
    2751          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Desiccant Dehumidifier Total Cooling Energy", "", AggType::SumOrAvg);
    2752             :     }
    2753         753 :     if (ort->namedMonthly(61).show) {
    2754          24 :         curReport = AddMonthlyReport(state, "AirLoopSystemComponentEnergyUseMonthly", 2, true);
    2755          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Fan Electricity Energy", "", AggType::SumOrAvg);
    2756          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Hot Water Energy", "", AggType::SumOrAvg);
    2757          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Cooling Coil Chilled Water Energy", "", AggType::SumOrAvg);
    2758          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System DX Heating Coil Electricity Energy", "", AggType::SumOrAvg);
    2759          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System DX Cooling Coil Electricity Energy", "", AggType::SumOrAvg);
    2760          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Electricity Energy", "", AggType::SumOrAvg);
    2761          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Natural Gas Energy", "", AggType::SumOrAvg);
    2762          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Steam Energy", "", AggType::SumOrAvg);
    2763          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Humidifier Electricity Energy", "", AggType::SumOrAvg);
    2764          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Humidifier Natural Gas Energy", "", AggType::SumOrAvg);
    2765          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Evaporative Cooler Electricity Energy", "", AggType::SumOrAvg);
    2766          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Desiccant Dehumidifier Electricity Energy", "", AggType::SumOrAvg);
    2767             :     }
    2768         753 :     if (ort->namedMonthly(62).show) {
    2769          24 :         curReport = AddMonthlyReport(state, "MechanicalVentilationLoadsMonthly", 2, true);
    2770          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation No Load Heat Removal Energy", "", AggType::SumOrAvg);
    2771          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Cooling Load Increase Energy", "", AggType::SumOrAvg);
    2772          24 :         AddMonthlyFieldSetInput(
    2773             :             state, curReport, "Zone Mechanical Ventilation Cooling Load Increase Due to Overheating Energy", "", AggType::SumOrAvg);
    2774          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Cooling Load Decrease Energy", "", AggType::SumOrAvg);
    2775          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation No Load Heat Addition Energy", "", AggType::SumOrAvg);
    2776          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Heating Load Increase Energy", "", AggType::SumOrAvg);
    2777          24 :         AddMonthlyFieldSetInput(
    2778             :             state, curReport, "Zone Mechanical Ventilation Heating Load Increase Due to Overcooling Energy", "", AggType::SumOrAvg);
    2779          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Heating Load Decrease Energy", "", AggType::SumOrAvg);
    2780          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Air Changes per Hour", "", AggType::SumOrAvg);
    2781             :     }
    2782         753 :     if (ort->namedMonthly(63).show) {
    2783          25 :         curReport = AddMonthlyReport(state, "HeatEmissionsReportMonthly", 2, true);
    2784             :         // Place holder
    2785          25 :         AddMonthlyFieldSetInput(state, curReport, "Site Total Surface Heat Emission to Air", "", AggType::SumOrAvg);
    2786          25 :         AddMonthlyFieldSetInput(state, curReport, "Site Total Zone Exfiltration Heat Loss", "", AggType::SumOrAvg);
    2787          25 :         AddMonthlyFieldSetInput(state, curReport, "Site Total Zone Exhaust Air Heat Loss", "", AggType::SumOrAvg);
    2788          25 :         AddMonthlyFieldSetInput(state, curReport, "Air System Relief Air Total Heat Loss Energy", "", AggType::SumOrAvg);
    2789          25 :         AddMonthlyFieldSetInput(state, curReport, "HVAC System Total Heat Rejection Energy", "", AggType::SumOrAvg);
    2790             :     }
    2791         753 : }
    2792             : 
    2793         794 : void GetInputFuelAndPollutionFactors(EnergyPlusData &state)
    2794             : {
    2795             :     // SUBROUTINE INFORMATION:
    2796             :     //       AUTHOR         Jason Glazer
    2797             :     //       DATE WRITTEN   January 2004
    2798             :     //       MODIFIED       na
    2799             :     //       RE-ENGINEERED  na
    2800             : 
    2801             :     // PURPOSE OF THIS SUBROUTINE:
    2802             :     //   Read the Fuel Factor inputs by the user to
    2803             :     //   get the source energy conversion factors
    2804             :     //   Also reads PolutionCalculationFactors to
    2805             :     //   get information on district cooling and heating
    2806             : 
    2807             :     // METHODOLOGY EMPLOYED:
    2808             :     //   Uses get input structure similar to other objects
    2809             : 
    2810             :     // REFERENCES:
    2811             :     // na
    2812             : 
    2813             :     // Using/Aliasing
    2814             :     using Pollution::GetEnvironmentalImpactFactorInfo;
    2815             :     using Pollution::GetFuelFactorInfo;
    2816             : 
    2817             :     // Locals
    2818             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    2819             :     // na
    2820             : 
    2821             :     // SUBROUTINE PARAMETER DEFINITIONS:
    2822             :     // na
    2823             : 
    2824             :     // INTERFACE BLOCK SPECIFICATIONS:
    2825             :     // na
    2826             : 
    2827             :     // DERIVED TYPE DEFINITIONS:
    2828             :     // na
    2829             : 
    2830             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2831             :     Real64 curSourceFactor;
    2832             :     bool fuelFactorUsed;
    2833             :     bool fFScheduleUsed;
    2834             :     int ffScheduleIndex;
    2835         794 :     auto &ort = state.dataOutRptTab;
    2836             : 
    2837             :     // set the default factors for source energy - they will be overwritten if the user sets any values
    2838         794 :     ort->sourceFactorElectric = 3.167;
    2839         794 :     ort->sourceFactorNaturalGas = 1.084;
    2840         794 :     ort->sourceFactorDistrictHeatingSteam = 1.20;
    2841         794 :     ort->sourceFactorGasoline = 1.05;
    2842         794 :     ort->sourceFactorDiesel = 1.05;
    2843         794 :     ort->sourceFactorCoal = 1.05;
    2844         794 :     ort->sourceFactorFuelOil1 = 1.05;
    2845         794 :     ort->sourceFactorFuelOil2 = 1.05;
    2846         794 :     ort->sourceFactorPropane = 1.05;
    2847         794 :     ort->sourceFactorOtherFuel1 = 1.0;
    2848         794 :     ort->sourceFactorOtherFuel2 = 1.0;
    2849             :     // the following should be kept consistent with the assumptions in the pollution calculation routines
    2850         794 :     ort->efficiencyDistrictCooling = 3.0;
    2851         794 :     ort->efficiencyDistrictHeatingWater = 0.3;
    2852             : 
    2853             :     //  TotalSourceEnergyUse = (gatherTotalsSource(1) & !total source from electricity
    2854             :     //                  +  gatherTotalsSource(2)   & !natural gas
    2855             :     //                  + gatherTotalsSource(3)    & !gasoline
    2856             :     //                  + gatherTotalsSource(4)    & !diesel
    2857             :     //                  + gatherTotalsSource(5)    & !coal
    2858             :     //                  + gatherTotalsSource(6)    & !Fuel Oil No1
    2859             :     //                  + gatherTotalsSource(7)    & !Fuel Oil No2
    2860             :     //                  + gatherTotalsSource(8)    &  !propane
    2861             :     //                  + gatherTotalsBEPS(3)*sourceFactorElectric/efficiencyDistrictCooling  & !district cooling
    2862             :     //                  + gatherTotalsBEPS(4)*sourceFactorNaturalGas/efficiencyDistrictHeating  & !district heating
    2863             :     //                  + gatherTotalsBEPS(5)*sourceFactorSteam  & !steam
    2864             :     //                                          ) / largeConversionFactor
    2865             : 
    2866         794 :     GetFuelFactorInfo(state, Constant::eFuel::NaturalGas, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2867         794 :     if (fuelFactorUsed) {
    2868          78 :         ort->sourceFactorNaturalGas = curSourceFactor;
    2869          78 :         ort->fuelfactorsused(2) = true;
    2870          78 :         ort->ffUsed(2) = true;
    2871             :     }
    2872         794 :     ort->SourceFactors(2) = curSourceFactor;
    2873         794 :     if (fFScheduleUsed) {
    2874           1 :         ort->fuelFactorSchedulesUsed = true;
    2875           1 :         ort->ffSchedUsed(2) = true;
    2876           1 :         ort->ffSchedIndex(2) = ffScheduleIndex;
    2877             :     }
    2878             : 
    2879         794 :     GetFuelFactorInfo(state, Constant::eFuel::FuelOilNo2, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2880         794 :     if (fuelFactorUsed) {
    2881           0 :         ort->sourceFactorFuelOil2 = curSourceFactor;
    2882           0 :         ort->fuelfactorsused(7) = true;
    2883           0 :         ort->ffUsed(11) = true;
    2884             :     }
    2885         794 :     ort->SourceFactors(11) = curSourceFactor;
    2886         794 :     if (fFScheduleUsed) {
    2887           0 :         ort->fuelFactorSchedulesUsed = true;
    2888           0 :         ort->ffSchedUsed(11) = true;
    2889           0 :         ort->ffSchedIndex(11) = ffScheduleIndex;
    2890             :     }
    2891             : 
    2892         794 :     GetFuelFactorInfo(state, Constant::eFuel::FuelOilNo1, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2893         794 :     if (fuelFactorUsed) {
    2894          21 :         ort->sourceFactorFuelOil1 = curSourceFactor;
    2895          21 :         ort->fuelfactorsused(6) = true;
    2896          21 :         ort->ffUsed(10) = true;
    2897             :     }
    2898         794 :     ort->SourceFactors(10) = curSourceFactor;
    2899         794 :     if (fFScheduleUsed) {
    2900           0 :         ort->fuelFactorSchedulesUsed = true;
    2901           0 :         ort->ffSchedUsed(10) = true;
    2902           0 :         ort->ffSchedIndex(10) = ffScheduleIndex;
    2903             :     }
    2904             : 
    2905         794 :     GetFuelFactorInfo(state, Constant::eFuel::Coal, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2906         794 :     if (fuelFactorUsed) {
    2907           0 :         ort->sourceFactorCoal = curSourceFactor;
    2908           0 :         ort->fuelfactorsused(5) = true;
    2909           0 :         ort->ffUsed(9) = true;
    2910             :     }
    2911         794 :     ort->SourceFactors(9) = curSourceFactor;
    2912         794 :     if (fFScheduleUsed) {
    2913           0 :         ort->fuelFactorSchedulesUsed = true;
    2914           0 :         ort->ffSchedUsed(9) = true;
    2915           0 :         ort->ffSchedIndex(9) = ffScheduleIndex;
    2916             :     }
    2917             : 
    2918         794 :     GetFuelFactorInfo(state, Constant::eFuel::Electricity, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2919         794 :     if (fuelFactorUsed) {
    2920          86 :         ort->sourceFactorElectric = curSourceFactor;
    2921          86 :         ort->fuelfactorsused(1) = true;
    2922          86 :         ort->ffUsed(1) = true;
    2923             :     }
    2924         794 :     ort->SourceFactors(1) = curSourceFactor;
    2925         794 :     if (fFScheduleUsed) {
    2926           1 :         ort->fuelFactorSchedulesUsed = true;
    2927           1 :         ort->ffSchedUsed(1) = true;
    2928           1 :         ort->ffSchedIndex(1) = ffScheduleIndex;
    2929             :     }
    2930             : 
    2931         794 :     GetFuelFactorInfo(state, Constant::eFuel::Gasoline, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2932         794 :     if (fuelFactorUsed) {
    2933           0 :         ort->sourceFactorGasoline = curSourceFactor;
    2934           0 :         ort->fuelfactorsused(3) = true;
    2935           0 :         ort->ffUsed(6) = true;
    2936             :     }
    2937         794 :     ort->SourceFactors(6) = curSourceFactor;
    2938         794 :     if (fFScheduleUsed) {
    2939           0 :         ort->fuelFactorSchedulesUsed = true;
    2940           0 :         ort->ffSchedUsed(6) = true;
    2941           0 :         ort->ffSchedIndex(6) = ffScheduleIndex;
    2942             :     }
    2943             : 
    2944         794 :     GetFuelFactorInfo(state, Constant::eFuel::Propane, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2945         794 :     if (fuelFactorUsed) {
    2946          21 :         ort->sourceFactorPropane = curSourceFactor;
    2947          21 :         ort->fuelfactorsused(8) = true;
    2948          21 :         ort->ffUsed(12) = true;
    2949             :     }
    2950         794 :     ort->SourceFactors(12) = curSourceFactor;
    2951         794 :     if (fFScheduleUsed) {
    2952           0 :         ort->fuelFactorSchedulesUsed = true;
    2953           0 :         ort->ffSchedUsed(12) = true;
    2954           0 :         ort->ffSchedIndex(12) = ffScheduleIndex;
    2955             :     }
    2956             : 
    2957         794 :     GetFuelFactorInfo(state, Constant::eFuel::Diesel, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2958         794 :     if (fuelFactorUsed) {
    2959           2 :         ort->sourceFactorDiesel = curSourceFactor;
    2960           2 :         ort->fuelfactorsused(4) = true;
    2961           2 :         ort->ffUsed(8) = true;
    2962             :     }
    2963         794 :     ort->SourceFactors(8) = curSourceFactor;
    2964         794 :     if (fFScheduleUsed) {
    2965           0 :         ort->fuelFactorSchedulesUsed = true;
    2966           0 :         ort->ffSchedUsed(8) = true;
    2967           0 :         ort->ffSchedIndex(8) = ffScheduleIndex;
    2968             :     }
    2969             : 
    2970         794 :     GetFuelFactorInfo(state, Constant::eFuel::DistrictCooling, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2971         794 :     if (fuelFactorUsed) {
    2972          86 :         ort->ffUsed(3) = true;
    2973             :     }
    2974         794 :     ort->SourceFactors(3) = curSourceFactor;
    2975         794 :     if (fFScheduleUsed) {
    2976           1 :         ort->ffSchedUsed(3) = true;
    2977           1 :         ort->ffSchedIndex(3) = ffScheduleIndex;
    2978             :     }
    2979             : 
    2980         794 :     GetFuelFactorInfo(state, Constant::eFuel::DistrictHeatingWater, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2981         794 :     if (fuelFactorUsed) {
    2982          78 :         ort->ffUsed(4) = true;
    2983             :     }
    2984         794 :     ort->SourceFactors(4) = curSourceFactor;
    2985         794 :     if (fFScheduleUsed) {
    2986           1 :         ort->ffSchedUsed(4) = true;
    2987           1 :         ort->ffSchedIndex(4) = ffScheduleIndex;
    2988             :     }
    2989             : 
    2990         794 :     GetFuelFactorInfo(state, Constant::eFuel::DistrictHeatingSteam, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2991         794 :     if (fuelFactorUsed) {
    2992          78 :         ort->ffUsed(5) = true;
    2993             :     }
    2994         794 :     ort->SourceFactors(5) = curSourceFactor;
    2995         794 :     if (fFScheduleUsed) {
    2996           1 :         ort->ffSchedUsed(5) = true;
    2997           1 :         ort->ffSchedIndex(5) = ffScheduleIndex;
    2998             :     }
    2999             : 
    3000         794 :     GetFuelFactorInfo(state, Constant::eFuel::OtherFuel1, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    3001         794 :     if (fuelFactorUsed) {
    3002           1 :         ort->sourceFactorOtherFuel1 = curSourceFactor;
    3003           1 :         ort->fuelfactorsused(11) = true; // should be source number
    3004           1 :         ort->ffUsed(13) = true;
    3005             :     }
    3006         794 :     ort->SourceFactors(13) = curSourceFactor;
    3007         794 :     if (fFScheduleUsed) {
    3008           0 :         ort->fuelFactorSchedulesUsed = true;
    3009           0 :         ort->ffSchedUsed(13) = true;
    3010           0 :         ort->ffSchedIndex(13) = ffScheduleIndex;
    3011             :     }
    3012             : 
    3013         794 :     GetFuelFactorInfo(state, Constant::eFuel::OtherFuel2, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    3014         794 :     if (fuelFactorUsed) {
    3015           0 :         ort->sourceFactorOtherFuel2 = curSourceFactor;
    3016           0 :         ort->fuelfactorsused(12) = true; // should be source number
    3017           0 :         ort->ffUsed(14) = true;
    3018             :     }
    3019         794 :     ort->SourceFactors(14) = curSourceFactor;
    3020         794 :     if (fFScheduleUsed) {
    3021           0 :         ort->fuelFactorSchedulesUsed = true;
    3022           0 :         ort->ffSchedUsed(14) = true;
    3023           0 :         ort->ffSchedIndex(14) = ffScheduleIndex;
    3024             :     }
    3025             : 
    3026         794 :     GetEnvironmentalImpactFactorInfo(
    3027         794 :         state, ort->efficiencyDistrictHeatingWater, ort->efficiencyDistrictCooling, ort->sourceFactorDistrictHeatingSteam);
    3028         794 : }
    3029             : 
    3030             : //======================================================================================================================
    3031             : //======================================================================================================================
    3032             : 
    3033             : //    OTHER INITIALIZATION ROUTINES
    3034             : 
    3035             : //======================================================================================================================
    3036             : //======================================================================================================================
    3037             : 
    3038         794 : void OpenOutputTabularFile(EnergyPlusData &state)
    3039             : {
    3040             :     // SUBROUTINE INFORMATION:
    3041             :     //       AUTHOR         Jason Glazer
    3042             :     //       DATE WRITTEN   July 2003
    3043             :     //       MODIFIED       na
    3044             :     //       RE-ENGINEERED  na
    3045             : 
    3046             :     // PURPOSE OF THIS SUBROUTINE:
    3047             :     //   Create a file that holds the output from the tabular reports
    3048             :     //   the output is in a CSV file if it is comma delimited otherwise
    3049             :     //   it is in a TXT file.
    3050             : 
    3051             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3052         794 :     auto &ort = state.dataOutRptTab;
    3053             : 
    3054             :     // get a new file unit number
    3055             :     // create a file to hold the results
    3056             :     // Use a CSV file if comma separated but otherwise use TXT file
    3057             :     // extension.
    3058         794 :     if (ort->WriteTabularFiles && state.files.outputControl.tabular) {
    3059        1616 :         for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
    3060         862 :             std::string const &curDel = ort->del(iStyle);
    3061         862 :             if (ort->TableStyle(iStyle) == TableStyle::Comma) {
    3062          56 :                 DisplayString(state, "Writing tabular output file results using comma format.");
    3063             :                 std::ofstream &tbl_stream =
    3064          56 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblCsvFilePath, state.files.outputControl.tabular);
    3065          56 :                 tbl_stream << "Program Version:" << curDel << state.dataStrGlobals->VerStringVar << '\n';
    3066          56 :                 tbl_stream << "Tabular Output Report in Format: " << curDel << "Comma\n";
    3067          56 :                 tbl_stream << '\n';
    3068          56 :                 tbl_stream << "Building:" << curDel << state.dataHeatBal->BuildingName << '\n';
    3069          56 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3070           0 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << '\n';
    3071             :                 } else {
    3072         224 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << " ** " << state.dataEnvrn->WeatherFileLocationTitle
    3073          56 :                                << '\n';
    3074             :                 }
    3075          56 :                 tbl_stream << '\n';
    3076         806 :             } else if (ort->TableStyle(iStyle) == TableStyle::Tab) {
    3077          24 :                 DisplayString(state, "Writing tabular output file results using tab format.");
    3078             :                 std::ofstream &tbl_stream =
    3079          24 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblTabFilePath, state.files.outputControl.tabular);
    3080          24 :                 tbl_stream << "Program Version" << curDel << state.dataStrGlobals->VerStringVar << '\n';
    3081          24 :                 tbl_stream << "Tabular Output Report in Format: " << curDel << "Tab\n";
    3082          24 :                 tbl_stream << '\n';
    3083          24 :                 tbl_stream << "Building:" << curDel << state.dataHeatBal->BuildingName << '\n';
    3084          24 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3085           0 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << '\n';
    3086             :                 } else {
    3087          96 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << " ** " << state.dataEnvrn->WeatherFileLocationTitle
    3088          24 :                                << '\n';
    3089             :                 }
    3090          24 :                 tbl_stream << '\n';
    3091         782 :             } else if (ort->TableStyle(iStyle) == TableStyle::HTML) {
    3092         743 :                 DisplayString(state, "Writing tabular output file results using HTML format.");
    3093             :                 std::ofstream &tbl_stream =
    3094         743 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblHtmFilePath, state.files.outputControl.tabular);
    3095         743 :                 tbl_stream << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\"http://www.w3.org/TR/html4/loose.dtd\">\n";
    3096         743 :                 tbl_stream << "<html>\n";
    3097         743 :                 tbl_stream << "<head>\n";
    3098         743 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3099           0 :                     tbl_stream << "<title> " << state.dataHeatBal->BuildingName << ' ' << state.dataEnvrn->EnvironmentName << '\n';
    3100             :                 } else {
    3101        2972 :                     tbl_stream << "<title> " << state.dataHeatBal->BuildingName << ' ' << state.dataEnvrn->EnvironmentName << " ** "
    3102         743 :                                << state.dataEnvrn->WeatherFileLocationTitle << '\n';
    3103             :                 }
    3104         743 :                 tbl_stream << "  " << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2) << '-' << std::setw(2)
    3105         743 :                            << ort->td(3) << '\n';
    3106         743 :                 tbl_stream << "  " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
    3107         743 :                            << std::setfill(' ') << '\n';
    3108         743 :                 tbl_stream << " - EnergyPlus</title>\n";
    3109         743 :                 tbl_stream << "</head>\n";
    3110         743 :                 tbl_stream << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n";
    3111         743 :                 tbl_stream << "<body>\n";
    3112         743 :                 tbl_stream << "<p><a href=\"#toc\" style=\"float: right\">Table of Contents</a></p>\n";
    3113         743 :                 tbl_stream << "<a name=top></a>\n";
    3114         743 :                 tbl_stream << "<p>Program Version:<b>" << state.dataStrGlobals->VerStringVar << "</b></p>\n";
    3115         743 :                 tbl_stream << "<p>Tabular Output Report in Format: <b>HTML</b></p>\n";
    3116         743 :                 tbl_stream << "<p>Building: <b>" << state.dataHeatBal->BuildingName << "</b></p>\n";
    3117         743 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3118           0 :                     tbl_stream << "<p>Environment: <b>" << ConvertToEscaped(state.dataEnvrn->EnvironmentName, false) << "</b></p>\n";
    3119             :                 } else {
    3120        1486 :                     tbl_stream << "<p>Environment: <b>" << ConvertToEscaped(state.dataEnvrn->EnvironmentName, false) << " ** "
    3121        1486 :                                << ConvertToEscaped(state.dataEnvrn->WeatherFileLocationTitle, false) << "</b></p>\n";
    3122             :                 }
    3123         743 :                 tbl_stream << "<p>Simulation Timestamp: <b>" << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2)
    3124         743 :                            << '-' << std::setw(2) << ort->td(3) << '\n';
    3125         743 :                 tbl_stream << "  " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
    3126         743 :                            << std::setfill(' ') << "</b></p>\n";
    3127          39 :             } else if (ort->TableStyle(iStyle) == TableStyle::XML) {
    3128          20 :                 DisplayString(state, "Writing tabular output file results using XML format.");
    3129             :                 std::ofstream &tbl_stream =
    3130          20 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblXmlFilePath, state.files.outputControl.tabular);
    3131          20 :                 tbl_stream << "<?xml version=\"1.0\"?>\n";
    3132          20 :                 tbl_stream << "<EnergyPlusTabularReports>\n";
    3133          40 :                 tbl_stream << "  <state.dataHeatBal->BuildingName>" << ConvertToEscaped(state.dataHeatBal->BuildingName)
    3134          40 :                            << "</state.dataHeatBal->BuildingName>\n";
    3135          20 :                 tbl_stream << "  <EnvironmentName>" << state.dataEnvrn->EnvironmentName << "</EnvironmentName>\n";
    3136          20 :                 tbl_stream << "  <WeatherFileLocationTitle>" << state.dataEnvrn->WeatherFileLocationTitle << "</WeatherFileLocationTitle>\n";
    3137          20 :                 tbl_stream << "  <ProgramVersion>" << state.dataStrGlobals->VerStringVar << "</ProgramVersion>\n";
    3138          20 :                 tbl_stream << "  <SimulationTimestamp>\n";
    3139          20 :                 tbl_stream << "    <Date>\n";
    3140          20 :                 tbl_stream << "      " << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2) << '-' << std::setw(2)
    3141          20 :                            << ort->td(3) << '\n';
    3142          20 :                 tbl_stream << "    </Date>\n";
    3143          20 :                 tbl_stream << "    <Time>\n";
    3144          20 :                 tbl_stream << "      " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
    3145          20 :                            << std::setfill(' ') << '\n';
    3146          20 :                 tbl_stream << "    </Time>\n";
    3147          20 :                 tbl_stream << "  </SimulationTimestamp>\n";
    3148          20 :                 tbl_stream << '\n';
    3149             :             } else {
    3150          19 :                 DisplayString(state, "Writing tabular output file results using text format.");
    3151             :                 std::ofstream &tbl_stream =
    3152          19 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblTxtFilePath, state.files.outputControl.tabular);
    3153          19 :                 tbl_stream << "Program Version: " << state.dataStrGlobals->VerStringVar << '\n';
    3154          19 :                 tbl_stream << "Tabular Output Report in Format: " << curDel << "Fixed\n";
    3155          19 :                 tbl_stream << '\n';
    3156          19 :                 tbl_stream << "Building:        " << state.dataHeatBal->BuildingName << '\n';
    3157          19 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3158           0 :                     tbl_stream << "Environment:     " << state.dataEnvrn->EnvironmentName << '\n';
    3159             :                 } else {
    3160          76 :                     tbl_stream << "Environment:     " << state.dataEnvrn->EnvironmentName << " ** " << state.dataEnvrn->WeatherFileLocationTitle
    3161          19 :                                << '\n';
    3162             :                 }
    3163          19 :                 tbl_stream << '\n';
    3164             :             }
    3165             :         }
    3166             :     }
    3167         794 : }
    3168             : 
    3169         794 : void CloseOutputTabularFile(EnergyPlusData &state)
    3170             : {
    3171             :     // SUBROUTINE INFORMATION:
    3172             :     //       AUTHOR         Jason Glazer
    3173             :     //       DATE WRITTEN   July 2003
    3174             :     //       MODIFIED       na
    3175             :     //       RE-ENGINEERED  na
    3176             : 
    3177             :     // PURPOSE OF THIS SUBROUTINE:
    3178             :     //   Create a file that holds the output from the tabular reports
    3179             :     //   the output is in a CSV file if it is comma delimited otherwise
    3180             :     //   it is in a TXT file.
    3181             : 
    3182             :     // METHODOLOGY EMPLOYED:
    3183             :     //   Uses get input structure similar to other objects
    3184             : 
    3185             :     // REFERENCES:
    3186             :     // na
    3187             : 
    3188             :     // USE STATEMENTS:
    3189             :     // na
    3190             : 
    3191             :     // Locals
    3192             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    3193             :     // na
    3194             : 
    3195             :     // SUBROUTINE PARAMETER DEFINITIONS:
    3196             : 
    3197             :     // INTERFACE BLOCK SPECIFICATIONS:
    3198             :     // na
    3199             : 
    3200             :     // DERIVED TYPE DEFINITIONS:
    3201             :     // na
    3202             : 
    3203             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3204         794 :     auto &ort = state.dataOutRptTab;
    3205             : 
    3206         794 :     if (ort->WriteTabularFiles) {
    3207        1616 :         for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
    3208         862 :             std::ofstream &tbl_stream(*ort->TabularOutputFile(iStyle));
    3209         862 :             if (ort->TableStyle(iStyle) == TableStyle::HTML) { // if HTML file put ending info
    3210         743 :                 tbl_stream << "</body>\n";
    3211         743 :                 tbl_stream << "</html>\n";
    3212         119 :             } else if (ort->TableStyle(iStyle) == TableStyle::XML) {
    3213          20 :                 if (!ort->prevReportName.empty()) {
    3214          20 :                     tbl_stream << "</" << ort->prevReportName << ">\n"; // close the last element if it was used.
    3215             :                 }
    3216          20 :                 tbl_stream << "</EnergyPlusTabularReports>\n";
    3217             :             }
    3218         862 :             tbl_stream.close();
    3219             :         }
    3220             :     }
    3221         794 : }
    3222             : 
    3223         754 : void WriteTableOfContents(EnergyPlusData &state)
    3224             : {
    3225             :     // SUBROUTINE INFORMATION:
    3226             :     //       AUTHOR         Jason Glazer
    3227             :     //       DATE WRITTEN   June 2005
    3228             :     //       MODIFIED       na
    3229             :     //       RE-ENGINEERED  na
    3230             : 
    3231             :     // PURPOSE OF THIS SUBROUTINE:
    3232             :     //   Creates hyperlinks for table of contents
    3233             : 
    3234             :     // METHODOLOGY EMPLOYED:
    3235             :     //   Go through the reports and create links
    3236             : 
    3237             :     // SUBROUTINE PARAMETER DEFINITIONS:
    3238         754 :     static std::string const Entire_Facility("Entire Facility");
    3239         754 :     static std::string const Annual_Building_Utility_Performance_Summary("Annual Building Utility Performance Summary");
    3240         754 :     static std::string const Input_Verification_and_Results_Summary("Input Verification and Results Summary");
    3241         754 :     static std::string const Demand_End_Use_Components_Summary("Demand End Use Components Summary");
    3242         754 :     static std::string const Source_Energy_End_Use_Components_Summary("Source Energy End Use Components Summary");
    3243         754 :     static std::string const Component_Cost_Economics_Summary("Component Cost Economics Summary");
    3244         754 :     static std::string const Component_Sizing_Summary("Component Sizing Summary");
    3245         754 :     static std::string const Surface_Shadowing_Summary("Surface Shadowing Summary");
    3246         754 :     static std::string const Adaptive_Comfort_Summary("Adaptive Comfort Summary");
    3247         754 :     static std::string const Initialization_Summary("Initialization Summary");
    3248         754 :     static std::string const Annual_Heat_Emissions_Summary("Annual Heat Emissions Summary");
    3249         754 :     static std::string const Annual_Thermal_Resilience_Summary("Annual Thermal Resilience Summary");
    3250         754 :     static std::string const Annual_CO2_Resilience_Summary("Annual CO2 Resilience Summary");
    3251         754 :     static std::string const Annual_Visual_Resilience_Summary("Annual Visual Resilience Summary");
    3252             : 
    3253             :     // INTERFACE BLOCK SPECIFICATIONS:
    3254             :     // na
    3255             : 
    3256             :     // DERIVED TYPE DEFINITIONS:
    3257             :     // na
    3258             : 
    3259             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3260         754 :     auto &ort = state.dataOutRptTab;
    3261             : 
    3262             :     // normally do not add to the table of contents here but the order of calls is different for the life-cycle costs
    3263         754 :     if (ort->displayLifeCycleCostReport && state.dataEconLifeCycleCost->LCCparamPresent) {
    3264           1 :         AddTOCEntry(state, "Life-Cycle Cost Report", "Entire Facility");
    3265             :     }
    3266             : 
    3267        1616 :     for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
    3268         862 :         if (ort->TableStyle(iStyle) == TableStyle::HTML) {
    3269         743 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
    3270         743 :             tbl_stream << "<hr>\n";
    3271         743 :             tbl_stream << "<a name=toc></a>\n";
    3272         743 :             tbl_stream << "<p><b>Table of Contents</b></p>\n";
    3273         743 :             tbl_stream << "<a href=\"#top\">Top</a>\n";
    3274         743 :             if (ort->displayTabularBEPS) {
    3275         742 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Building_Utility_Performance_Summary, Entire_Facility)
    3276         742 :                            << "\">Annual Building Utility Performance Summary</a>\n";
    3277             :             }
    3278         743 :             if (ort->displayTabularVeriSum) {
    3279         733 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Input_Verification_and_Results_Summary, Entire_Facility)
    3280         733 :                            << "\">Input Verification and Results Summary</a>\n";
    3281             :             }
    3282         743 :             if (ort->displayDemandEndUse) {
    3283         665 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Demand_End_Use_Components_Summary, Entire_Facility)
    3284         665 :                            << "\">Demand End Use Components Summary</a>\n";
    3285             :             }
    3286         743 :             if (ort->displaySourceEnergyEndUseSummary) {
    3287         662 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Source_Energy_End_Use_Components_Summary, Entire_Facility)
    3288         662 :                            << "\">Source Energy End Use Components Summary</a>\n";
    3289             :             }
    3290         743 :             if (state.dataCostEstimateManager->DoCostEstimate) {
    3291          38 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Component_Cost_Economics_Summary, Entire_Facility)
    3292          38 :                            << "\">Component Cost Economics Summary</a>\n";
    3293             :             }
    3294         743 :             if (ort->displayComponentSizing) {
    3295         722 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Component_Sizing_Summary, Entire_Facility) << "\">Component Sizing Summary</a>\n";
    3296             :             }
    3297         743 :             if (ort->displaySurfaceShadowing) {
    3298         662 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Surface_Shadowing_Summary, Entire_Facility) << "\">Surface Shadowing Summary</a>\n";
    3299             :             }
    3300         743 :             if (ort->displayAdaptiveComfort) {
    3301         662 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Adaptive_Comfort_Summary, Entire_Facility) << "\">Adaptive Comfort Summary</a>\n";
    3302             :             }
    3303         743 :             if (ort->displayEioSummary) {
    3304         663 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Initialization_Summary, Entire_Facility) << "\">Initialization Summary</a>\n";
    3305             :             }
    3306         743 :             if (ort->displayHeatEmissionsSummary) {
    3307         663 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Heat_Emissions_Summary, Entire_Facility)
    3308         663 :                            << "\">Annual Heat Emissions Summary</a>\n";
    3309             :             }
    3310         743 :             if (ort->displayThermalResilienceSummary) {
    3311         665 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Thermal_Resilience_Summary, Entire_Facility)
    3312         665 :                            << "\">Annual Thermal Resilience Summary</a>\n";
    3313             :             }
    3314             :             //                if (displayCO2ResilienceSummary) {
    3315             :             //                    tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_CO2_Resilience_Summary, Entire_Facility)
    3316             :             //                               << "\">Annual CO2 Resilience Summary</a>\n";
    3317             :             //                }
    3318             :             //                if (displayVisualResilienceSummary) {
    3319             :             //                    tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Visual_Resilience_Summary, Entire_Facility)
    3320             :             //                               << "\">Annual Visual Resilience Summary</a>\n";
    3321             :             //                }
    3322       13788 :             for (int kReport = 1; kReport <= state.dataOutRptPredefined->numReportName; ++kReport) {
    3323       13045 :                 if (state.dataOutRptPredefined->reportName(kReport).show) {
    3324       23872 :                     tbl_stream << "<br><a href=\"#" << MakeAnchorName(state.dataOutRptPredefined->reportName(kReport).namewithspaces, Entire_Facility)
    3325       23872 :                                << "\">" << state.dataOutRptPredefined->reportName(kReport).namewithspaces << "</a>\n";
    3326             :                 }
    3327             :             }
    3328         743 :             if (state.dataGlobal->DoWeathSim) {
    3329           5 :                 for (int iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
    3330           0 :                     if (ort->MonthlyInput(iInput).numTables > 0) {
    3331           0 :                         tbl_stream << "<p><b>" << ort->MonthlyInput(iInput).name << "</b></p> |\n";
    3332           0 :                         for (int jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
    3333           0 :                             int const curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
    3334           0 :                             tbl_stream << "<a href=\"#" << MakeAnchorName(ort->MonthlyInput(iInput).name, ort->MonthlyTables(curTable).keyValue)
    3335           0 :                                        << "\">" << ort->MonthlyTables(curTable).keyValue << "</a>    |   \n";
    3336             :                         }
    3337             :                     }
    3338             :                 }
    3339           5 :                 for (int iInput = 1; iInput <= ort->OutputTableBinnedCount; ++iInput) {
    3340           0 :                     if (ort->OutputTableBinned(iInput).numTables > 0) {
    3341           0 :                         if (ort->OutputTableBinned(iInput).scheduleIndex == 0) {
    3342           0 :                             tbl_stream << "<p><b>" << ort->OutputTableBinned(iInput).varOrMeter << "</b></p> |\n";
    3343             :                         } else {
    3344           0 :                             tbl_stream << "<p><b>" << ort->OutputTableBinned(iInput).varOrMeter << " [" << ort->OutputTableBinned(iInput).ScheduleName
    3345           0 :                                        << "]</b></p> |\n";
    3346             :                         }
    3347           0 :                         for (int jTable = 1; jTable <= ort->OutputTableBinned(iInput).numTables; ++jTable) {
    3348           0 :                             int const curTable = ort->OutputTableBinned(iInput).resIndex + (jTable - 1);
    3349           0 :                             std::string curName;
    3350           0 :                             if (ort->ip()) {
    3351           0 :                                 std::string origName = format("{} [{}]",
    3352           0 :                                                               ort->OutputTableBinned(iInput).varOrMeter,
    3353           0 :                                                               Constant::unitNames[(int)ort->OutputTableBinned(iInput).units]);
    3354           0 :                                 [[maybe_unused]] int indexUnitConv = -1;
    3355           0 :                                 LookupSItoIP(state, origName, indexUnitConv, curName);
    3356           0 :                             } else {
    3357           0 :                                 curName = format("{}[{}]",
    3358           0 :                                                  ort->OutputTableBinned(iInput).varOrMeter,
    3359           0 :                                                  Constant::unitNames[(int)ort->OutputTableBinned(iInput).units]);
    3360             :                             }
    3361           0 :                             if (ort->OutputTableBinned(iInput).scheduleIndex == 0) {
    3362           0 :                                 tbl_stream << "<a href=\"#" << MakeAnchorName(curName, ort->BinObjVarID(curTable).namesOfObj) << "\">"
    3363           0 :                                            << ort->BinObjVarID(curTable).namesOfObj << "</a>   |  \n";
    3364             :                             } else {
    3365             :                                 tbl_stream << "<a href=\"#"
    3366           0 :                                            << MakeAnchorName(curName + ort->OutputTableBinned(iInput).ScheduleName,
    3367           0 :                                                              ort->BinObjVarID(curTable).namesOfObj)
    3368           0 :                                            << "\">" << ort->BinObjVarID(curTable).namesOfObj << "</a>   |  \n";
    3369             :                             }
    3370           0 :                         }
    3371             :                     }
    3372             :                 }
    3373           5 :                 OutputReportTabularAnnual::AddAnnualTableOfContents(state, tbl_stream);
    3374             :             }
    3375             :             // add entries specifically added using AddTOCEntry
    3376        1051 :             for (int iEntry = 1; iEntry <= ort->TOCEntriesCount; ++iEntry) {
    3377         308 :                 if (!ort->TOCEntries(iEntry).isWritten) {
    3378          92 :                     std::string const &curSection = ort->TOCEntries(iEntry).sectionName;
    3379          92 :                     tbl_stream << "<p><b>" << curSection << "</b></p> |\n";
    3380         440 :                     for (int jEntry = iEntry; jEntry <= ort->TOCEntriesCount; ++jEntry) {
    3381         348 :                         if (!ort->TOCEntries(jEntry).isWritten) {
    3382         348 :                             if (ort->TOCEntries(jEntry).sectionName == curSection) {
    3383         616 :                                 tbl_stream << "<a href=\"#" << MakeAnchorName(ort->TOCEntries(jEntry).sectionName, ort->TOCEntries(jEntry).reportName)
    3384         616 :                                            << "\">" << ort->TOCEntries(jEntry).reportName << "</a>   |  \n";
    3385         308 :                                 ort->TOCEntries(jEntry).isWritten = true;
    3386             :                             }
    3387             :                         }
    3388             :                     }
    3389             :                 }
    3390             :             }
    3391             : 
    3392         743 :             if (state.dataWeather->TotReportPers > 0) {
    3393           4 :                 std::string ReportPeriodSummary = "Reporting Period Summary";
    3394           4 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(ReportPeriodSummary, Entire_Facility) << "\">"
    3395             :                            << "Reporting Period Summary"
    3396           4 :                            << "</a>\n";
    3397           4 :                 AddTOCReportPeriod(state.dataWeather->TotThermalReportPers, "Thermal", state.dataWeather->ThermalReportPeriodInput, tbl_stream);
    3398           4 :                 AddTOCReportPeriod(state.dataWeather->TotCO2ReportPers, "CO2", state.dataWeather->CO2ReportPeriodInput, tbl_stream);
    3399           4 :                 AddTOCReportPeriod(state.dataWeather->TotVisualReportPers, "Visual", state.dataWeather->VisualReportPeriodInput, tbl_stream);
    3400           4 :             }
    3401             :         }
    3402             :     }
    3403         754 : }
    3404             : 
    3405          12 : void AddTOCReportPeriod(const int nReportPeriods,
    3406             :                         const std::string &kw,
    3407             :                         const Array1D<Weather::ReportPeriodData> &ReportPeriodInputData,
    3408             :                         std::ostream &tbl_stream)
    3409             : {
    3410          12 :     static std::string const Entire_Facility("Entire Facility");
    3411          23 :     for (int i = 1; i <= nReportPeriods; i++) {
    3412             :         std::string ReportPeriod_Resilience_Summary = fmt::format(
    3413          11 :             "{} Resilience Summary for Reporting Period {}: {}", kw, i, ReportPeriodInputData(i).title, ReportPeriodInputData(i).totalElectricityUse);
    3414          11 :         tbl_stream << "<br><a href=\"#" << MakeAnchorName(ReportPeriod_Resilience_Summary, Entire_Facility) << "\">" << kw
    3415          11 :                    << " Resilience Summary for Reporting Period " << i << ": " << ReportPeriodInputData(i).title << "</a>\n";
    3416          11 :     }
    3417          12 : }
    3418             : 
    3419             : //======================================================================================================================
    3420             : //======================================================================================================================
    3421             : 
    3422             : //    GATHER DATA EACH TIME STEP ROUTINES
    3423             : 
    3424             : //======================================================================================================================
    3425             : //======================================================================================================================
    3426             : 
    3427      479981 : void GatherBinResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    3428             : {
    3429             :     // SUBROUTINE INFORMATION:
    3430             :     //       AUTHOR         Jason Glazer
    3431             :     //       DATE WRITTEN   August 2003
    3432             :     //       MODIFIED       na
    3433             :     //       RE-ENGINEERED  na
    3434             : 
    3435             :     // PURPOSE OF THIS SUBROUTINE:
    3436             :     //   Gathers the data each timesetp and adds the length of the
    3437             :     //   timestep to the appropriate bin.
    3438             : 
    3439             :     // Using/Aliasing
    3440             :     using ScheduleManager::GetCurrentScheduleValue;
    3441             : 
    3442             :     // Locals
    3443             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    3444             : 
    3445             :     // SUBROUTINE PARAMETER DEFINITIONS:
    3446             :     // na
    3447             : 
    3448             :     // INTERFACE BLOCK SPECIFICATIONS:
    3449             :     // na
    3450             : 
    3451             :     // DERIVED TYPE DEFINITIONS:
    3452             :     // na
    3453             : 
    3454             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3455             :     // values of OutputTableBinned array for current index
    3456      479981 :     auto &ort = state.dataOutRptTab;
    3457             : 
    3458      479981 :     if (!state.dataGlobal->DoWeathSim) {
    3459           0 :         return;
    3460             :     }
    3461             : 
    3462             :     Real64 const elapsedTime =
    3463      479981 :         (t_timeStepType == OutputProcessor::TimeStepType::System) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
    3464             : 
    3465      479981 :     ort->timeInYear += state.dataHVACGlobal->TimeStepSys;
    3466             : 
    3467      479981 :     for (int iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    3468             :         // get values of array for current object being referenced
    3469             : 
    3470           0 :         int const curScheduleIndex = ort->OutputTableBinned(iInObj).scheduleIndex;
    3471             :         // if a schedule was used, check if it was non-zero value
    3472           0 :         bool gatherThisTime = false;
    3473           0 :         if (curScheduleIndex != 0) {
    3474           0 :             if (GetCurrentScheduleValue(state, curScheduleIndex) != 0.0) {
    3475           0 :                 gatherThisTime = true;
    3476             :             } else {
    3477           0 :                 gatherThisTime = false;
    3478             :             }
    3479             :         } else {
    3480           0 :             gatherThisTime = true;
    3481             :         }
    3482           0 :         if (gatherThisTime) {
    3483           0 :             Real64 const &curIntervalStart = ort->OutputTableBinned(iInObj).intervalStart;
    3484           0 :             Real64 const &curIntervalSize = ort->OutputTableBinned(iInObj).intervalSize;
    3485           0 :             int const curIntervalCount = ort->OutputTableBinned(iInObj).intervalCount;
    3486           0 :             Real64 const topValue = curIntervalStart + curIntervalSize * curIntervalCount;
    3487           0 :             OutputProcessor::VariableType const curTypeOfVar = ort->OutputTableBinned(iInObj).typeOfVar;
    3488           0 :             OutputProcessor::TimeStepType const curStepType = ort->OutputTableBinned(iInObj).stepType;
    3489             : 
    3490           0 :             for (int jTable = 1; jTable <= ort->OutputTableBinned(iInObj).numTables; ++jTable) {
    3491           0 :                 int curResIndex = ort->OutputTableBinned(iInObj).resIndex;
    3492           0 :                 int repIndex = curResIndex + (jTable - 1);
    3493           0 :                 if (((curStepType == OutputProcessor::TimeStepType::Zone) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) ||
    3494           0 :                     ((curStepType == OutputProcessor::TimeStepType::System) && (t_timeStepType == OutputProcessor::TimeStepType::System))) {
    3495             :                     // put actual value from OutputProcesser arrays
    3496           0 :                     Real64 curValue = GetInternalVariableValue(state, curTypeOfVar, ort->BinObjVarID(repIndex).varMeterNum);
    3497             :                     // per MJW when a summed variable is used divide it by the length of the time step
    3498           0 :                     if (ort->OutputTableBinned(iInObj).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3499           0 :                         curValue /= (elapsedTime * Constant::SecInHour);
    3500             :                     }
    3501             :                     // round the value to the number of signficant digits used in the final output report
    3502           0 :                     if (curIntervalSize < 1) {
    3503           0 :                         curValue = round(curValue * 10000.0) / 10000.0; // four significant digits
    3504           0 :                     } else if (curIntervalSize >= 10) {
    3505           0 :                         curValue = round(curValue); // zero significant digits
    3506             :                     } else {
    3507           0 :                         curValue = round(curValue * 100.0) / 100.0; // two significant digits
    3508             :                     }
    3509             :                     // check if the value is above the maximum or below the minimum value
    3510             :                     // first before binning the value within the range.
    3511           0 :                     if (curValue < curIntervalStart) {
    3512           0 :                         ort->BinResultsBelow(repIndex).mnth(state.dataEnvrn->Month) += elapsedTime;
    3513           0 :                         ort->BinResultsBelow(repIndex).hrly(state.dataGlobal->HourOfDay) += elapsedTime;
    3514           0 :                     } else if (curValue >= topValue) {
    3515           0 :                         ort->BinResultsAbove(repIndex).mnth(state.dataEnvrn->Month) += elapsedTime;
    3516           0 :                         ort->BinResultsAbove(repIndex).hrly(state.dataGlobal->HourOfDay) += elapsedTime;
    3517             :                     } else {
    3518             :                         // determine which bin the results are in
    3519           0 :                         int binNum = static_cast<int>((curValue - curIntervalStart) / curIntervalSize) + 1;
    3520           0 :                         ort->BinResults(binNum, repIndex).mnth(state.dataEnvrn->Month) += elapsedTime;
    3521           0 :                         ort->BinResults(binNum, repIndex).hrly(state.dataGlobal->HourOfDay) += elapsedTime;
    3522             :                     }
    3523             :                     // add to statistics array
    3524           0 :                     ++ort->BinStatistics(repIndex).n;
    3525           0 :                     ort->BinStatistics(repIndex).sum += curValue;
    3526           0 :                     ort->BinStatistics(repIndex).sum2 += curValue * curValue;
    3527           0 :                     if (curValue < ort->BinStatistics(repIndex).minimum) {
    3528           0 :                         ort->BinStatistics(repIndex).minimum = curValue;
    3529             :                     }
    3530           0 :                     if (curValue > ort->BinStatistics(repIndex).maximum) {
    3531           0 :                         ort->BinStatistics(repIndex).maximum = curValue;
    3532             :                     }
    3533             :                 }
    3534             :             }
    3535             :         }
    3536             :     }
    3537             : }
    3538             : 
    3539      479981 : void GatherMonthlyResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    3540             : {
    3541             :     // SUBROUTINE INFORMATION:
    3542             :     //       AUTHOR         Jason Glazer
    3543             :     //       DATE WRITTEN   September 2003
    3544             :     //       MODIFIED       na
    3545             :     //       RE-ENGINEERED  na
    3546             : 
    3547             :     // PURPOSE OF THIS SUBROUTINE:
    3548             :     //   Gathers the data each timestep and updates the arrays
    3549             :     //   holding the data that will be reported later.
    3550             : 
    3551             :     // Using/Aliasing
    3552      479981 :     Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    3553             :     using General::EncodeMonDayHrMin;
    3554             : 
    3555             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3556             : 
    3557      479981 :     if (!state.dataGlobal->DoWeathSim) {
    3558           0 :         return;
    3559             :     }
    3560             : 
    3561      479981 :     auto &ort = state.dataOutRptTab;
    3562      479981 :     assert(state.dataGlobal->TimeStepZoneSec > 0.0);
    3563             : 
    3564             :     // create temporary arrays to speed processing of these arrays
    3565      479981 :     if (ort->GatherMonthlyResultsForTimestepRunOnce) {
    3566             :         // MonthlyColumns
    3567           5 :         state.dataOutRptTab->MonthlyColumnsTypeOfVar.allocate(ort->MonthlyColumns.I());
    3568           5 :         state.dataOutRptTab->MonthlyColumnsStepType.allocate(ort->MonthlyColumns.I());
    3569           5 :         state.dataOutRptTab->MonthlyColumnsAggType.allocate(ort->MonthlyColumns.I());
    3570           5 :         state.dataOutRptTab->MonthlyColumnsVarNum.allocate(ort->MonthlyColumns.I());
    3571           5 :         for (int i = ort->MonthlyColumns.l(), e = ort->MonthlyColumns.u(); i <= e; ++i) {
    3572           0 :             auto const &col = ort->MonthlyColumns(i);
    3573           0 :             state.dataOutRptTab->MonthlyColumnsTypeOfVar(i) = col.typeOfVar;
    3574           0 :             state.dataOutRptTab->MonthlyColumnsStepType(i) = col.stepType;
    3575           0 :             state.dataOutRptTab->MonthlyColumnsAggType(i) = col.aggType;
    3576           0 :             state.dataOutRptTab->MonthlyColumnsVarNum(i) = col.varNum;
    3577             :         }
    3578             : 
    3579             :         // MonthlyTables
    3580           5 :         state.dataOutRptTab->MonthlyTablesNumColumns.allocate(ort->MonthlyTables.I());
    3581           5 :         for (int i = ort->MonthlyTables.l(), e = ort->MonthlyTables.u(); i <= e; ++i) {
    3582           0 :             state.dataOutRptTab->MonthlyTablesNumColumns(i) = ort->MonthlyTables(i).numColumns;
    3583             :         }
    3584             : 
    3585             :         // set flag so this block is only executed once
    3586           5 :         ort->GatherMonthlyResultsForTimestepRunOnce = false;
    3587             :     }
    3588             : 
    3589             :     Real64 const elapsedTime =
    3590      479981 :         (t_timeStepType == OutputProcessor::TimeStepType::System) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
    3591             : 
    3592      479981 :     ort->IsMonthGathered(state.dataEnvrn->Month) = true;
    3593      479981 :     for (int iTable = 1; iTable <= ort->MonthlyTablesCount; ++iTable) {
    3594           0 :         bool activeMinMax = false;     // at the beginning of the new timestep
    3595           0 :         bool activeHoursShown = false; // fix by JG addressing CR6482
    3596           0 :         state.dataOutRptTab->curFirstColumn = ort->MonthlyTables(iTable).firstColumn;
    3597           0 :         for (int jColumn = 1; jColumn <= state.dataOutRptTab->MonthlyTablesNumColumns(iTable); ++jColumn) {
    3598           0 :             int const curCol = jColumn + state.dataOutRptTab->curFirstColumn - 1;
    3599           0 :             OutputProcessor::VariableType const curTypeOfVar = state.dataOutRptTab->MonthlyColumnsTypeOfVar(curCol);
    3600           0 :             OutputProcessor::TimeStepType const curStepType = state.dataOutRptTab->MonthlyColumnsStepType(curCol);
    3601           0 :             if (((curStepType == OutputProcessor::TimeStepType::Zone) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) ||
    3602           0 :                 ((curStepType == OutputProcessor::TimeStepType::System) && (t_timeStepType == OutputProcessor::TimeStepType::System))) {
    3603             :                 //  the above condition used to include the following prior to new scan method
    3604             :                 //  (MonthlyColumns(curCol)%aggType .EQ. AggType::ValueWhenMaxMin)
    3605           0 :                 int const curVarNum = state.dataOutRptTab->MonthlyColumnsVarNum(curCol);
    3606           0 :                 Real64 curValue = GetInternalVariableValue(state, curTypeOfVar, curVarNum);
    3607             :                 // Get the value from the result array
    3608           0 :                 Real64 const &oldResultValue = ort->MonthlyColumns(curCol).reslt(state.dataEnvrn->Month);
    3609             :                 // Real64 oldTimeStamp = ort->MonthlyColumns(curCol).timeStamp(state.dataEnvrn->Month);
    3610           0 :                 Real64 const &oldDuration = ort->MonthlyColumns(curCol).duration(state.dataEnvrn->Month);
    3611             :                 // Zero the revised values (as default if not set later in SELECT)
    3612           0 :                 Real64 newResultValue = 0.0;
    3613           0 :                 int newTimeStamp = 0;
    3614           0 :                 Real64 newDuration = 0.0;
    3615           0 :                 bool activeNewValue = false;
    3616             :                 // the current timestamp
    3617           0 :                 int const minuteCalculated = OutputProcessor::DetermineMinuteForReporting(state);
    3618             :                 //      minuteCalculated = (CurrentTime - INT(CurrentTime))*60
    3619             :                 //      IF (t_timeStepType .EQ. OutputProcessor::TimeStepType::TimeStepSystem) minuteCalculated = minuteCalculated +
    3620             :                 //      SysTimeElapsed * 60 minuteCalculated = INT((TimeStep-1) * TimeStepZone * 60) + INT((SysTimeElapsed + TimeStepSys) * 60)
    3621             :                 int timestepTimeStamp;
    3622           0 :                 EncodeMonDayHrMin(
    3623           0 :                     timestepTimeStamp, state.dataEnvrn->Month, state.dataEnvrn->DayOfMonth, state.dataGlobal->HourOfDay, minuteCalculated);
    3624             :                 // perform the selected aggregation type
    3625             :                 // use next lines since it is faster was: SELECT CASE (MonthlyColumns(curCol)%aggType)
    3626           0 :                 switch (state.dataOutRptTab->MonthlyColumnsAggType(curCol)) {
    3627           0 :                 case AggType::SumOrAvg: {
    3628           0 :                     if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3629           0 :                         newResultValue = oldResultValue + curValue;
    3630             :                     } else {
    3631           0 :                         newResultValue = oldResultValue + curValue * elapsedTime; // for averaging - weight by elapsed time
    3632             :                     }
    3633           0 :                     newDuration = oldDuration + elapsedTime;
    3634           0 :                     activeNewValue = true;
    3635           0 :                 } break;
    3636           0 :                 case AggType::Maximum: {
    3637             :                     // per MJW when a summed variable is used divide it by the length of the time step
    3638           0 :                     if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3639           0 :                         if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3640           0 :                             curValue /= TimeStepSysSec;
    3641             :                         } else {
    3642           0 :                             curValue /= state.dataGlobal->TimeStepZoneSec;
    3643             :                         }
    3644             :                     }
    3645           0 :                     if (curValue > oldResultValue) {
    3646           0 :                         newResultValue = curValue;
    3647           0 :                         newTimeStamp = timestepTimeStamp;
    3648           0 :                         activeMinMax = true;
    3649           0 :                         activeNewValue = true;
    3650             :                     } else {
    3651           0 :                         activeMinMax = false; // reset this
    3652             :                     }
    3653           0 :                 } break;
    3654           0 :                 case AggType::Minimum: {
    3655             :                     // per MJW when a summed variable is used divide it by the length of the time step
    3656           0 :                     if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3657           0 :                         if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3658           0 :                             curValue /= TimeStepSysSec;
    3659             :                         } else {
    3660           0 :                             curValue /= state.dataGlobal->TimeStepZoneSec;
    3661             :                         }
    3662             :                     }
    3663           0 :                     if (curValue < oldResultValue) {
    3664           0 :                         newResultValue = curValue;
    3665           0 :                         newTimeStamp = timestepTimeStamp;
    3666           0 :                         activeMinMax = true;
    3667           0 :                         activeNewValue = true;
    3668             :                     } else {
    3669           0 :                         activeMinMax = false; // reset this
    3670             :                     }
    3671           0 :                 } break;
    3672           0 :                 case AggType::HoursZero: {
    3673           0 :                     if (curValue == 0) {
    3674           0 :                         newResultValue = oldResultValue + elapsedTime;
    3675           0 :                         activeHoursShown = true;
    3676           0 :                         activeNewValue = true;
    3677             :                     } else {
    3678           0 :                         activeHoursShown = false;
    3679             :                     }
    3680           0 :                 } break;
    3681           0 :                 case AggType::HoursNonZero: {
    3682           0 :                     if (curValue != 0) {
    3683           0 :                         newResultValue = oldResultValue + elapsedTime;
    3684           0 :                         activeHoursShown = true;
    3685           0 :                         activeNewValue = true;
    3686             :                     } else {
    3687           0 :                         activeHoursShown = false;
    3688             :                     }
    3689           0 :                 } break;
    3690           0 :                 case AggType::HoursPositive: {
    3691           0 :                     if (curValue > 0) {
    3692           0 :                         newResultValue = oldResultValue + elapsedTime;
    3693           0 :                         activeHoursShown = true;
    3694           0 :                         activeNewValue = true;
    3695             :                     } else {
    3696           0 :                         activeHoursShown = false;
    3697             :                     }
    3698           0 :                 } break;
    3699           0 :                 case AggType::HoursNonPositive: {
    3700           0 :                     if (curValue <= 0) {
    3701           0 :                         newResultValue = oldResultValue + elapsedTime;
    3702           0 :                         activeHoursShown = true;
    3703           0 :                         activeNewValue = true;
    3704             :                     } else {
    3705           0 :                         activeHoursShown = false;
    3706             :                     }
    3707           0 :                 } break;
    3708           0 :                 case AggType::HoursNegative: {
    3709           0 :                     if (curValue < 0) {
    3710           0 :                         newResultValue = oldResultValue + elapsedTime;
    3711           0 :                         activeHoursShown = true;
    3712           0 :                         activeNewValue = true;
    3713             :                     } else {
    3714           0 :                         activeHoursShown = false;
    3715             :                     }
    3716           0 :                 } break;
    3717           0 :                 case AggType::HoursNonNegative: {
    3718           0 :                     if (curValue >= 0) {
    3719           0 :                         newResultValue = oldResultValue + elapsedTime;
    3720           0 :                         activeHoursShown = true;
    3721           0 :                         activeNewValue = true;
    3722             :                     } else {
    3723           0 :                         activeHoursShown = false;
    3724             :                     }
    3725             :                     // The valueWhenMaxMin is picked up now during the activeMinMax if block below.
    3726             :                     // CASE (iAggType::ValueWhenMaxMin)
    3727             :                     // CASE (iAggType::SumOrAverageHoursShown)
    3728             :                     // CASE (iAggType::MaximumDuringHoursShown)
    3729             :                     // CASE (iAggType::MinimumDuringHoursShown)
    3730           0 :                 } break;
    3731           0 :                 default:
    3732           0 :                     break;
    3733             :                 }
    3734             :                 // if the new value has been set then set the monthly values to the
    3735             :                 // new columns. This skips the aggregation types that don't even get
    3736             :                 // triggered now such as valueWhenMinMax and all the agg*HoursShown
    3737           0 :                 if (activeNewValue) {
    3738           0 :                     ort->MonthlyColumns(curCol).reslt(state.dataEnvrn->Month) = newResultValue;
    3739           0 :                     ort->MonthlyColumns(curCol).timeStamp(state.dataEnvrn->Month) = newTimeStamp;
    3740           0 :                     ort->MonthlyColumns(curCol).duration(state.dataEnvrn->Month) = newDuration;
    3741             :                 }
    3742             :                 // if a minimum or maximum value was set this timeStep then
    3743             :                 // scan the remaining columns of the table looking for values
    3744             :                 // that are aggregation type "ValueWhenMaxMin" and set their values
    3745             :                 // if another minimum or maximum column is found then end
    3746             :                 // the scan (it will be taken care of when that column is done)
    3747           0 :                 if (activeMinMax) {
    3748           0 :                     for (int kOtherColumn = jColumn + 1; kOtherColumn <= ort->MonthlyTables(iTable).numColumns; ++kOtherColumn) {
    3749           0 :                         int const scanColumn = kOtherColumn + ort->MonthlyTables(iTable).firstColumn - 1;
    3750           0 :                         switch (ort->MonthlyColumns(scanColumn).aggType) {
    3751           0 :                         case AggType::Maximum:
    3752             :                         case AggType::Minimum:
    3753             :                             // end scanning since these might reset
    3754           0 :                             break; // do
    3755           0 :                         case AggType::ValueWhenMaxMin: {
    3756             :                             // this case is when the value should be set
    3757           0 :                             OutputProcessor::VariableType const scanTypeOfVar = ort->MonthlyColumns(scanColumn).typeOfVar;
    3758           0 :                             int const scanVarNum = ort->MonthlyColumns(scanColumn).varNum;
    3759           0 :                             Real64 scanValue = GetInternalVariableValue(state, scanTypeOfVar, scanVarNum);
    3760             :                             // When a summed variable is used divide it by the length of the time step
    3761           0 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3762           0 :                                 if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3763           0 :                                     scanValue /= TimeStepSysSec;
    3764             :                                 } else {
    3765           0 :                                     scanValue /= state.dataGlobal->TimeStepZoneSec;
    3766             :                                 }
    3767             :                             }
    3768           0 :                             ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = scanValue;
    3769           0 :                         } break;
    3770           0 :                         default:
    3771           0 :                             break;
    3772             :                         }
    3773             :                     }
    3774             :                 }
    3775             :                 // If the hours variable is active then scan through the rest of the variables
    3776             :                 // and accumulate
    3777           0 :                 if (activeHoursShown) {
    3778           0 :                     for (int kOtherColumn = jColumn + 1; kOtherColumn <= ort->MonthlyTables(iTable).numColumns; ++kOtherColumn) {
    3779           0 :                         int const scanColumn = kOtherColumn + ort->MonthlyTables(iTable).firstColumn - 1;
    3780           0 :                         OutputProcessor::VariableType const scanTypeOfVar = ort->MonthlyColumns(scanColumn).typeOfVar;
    3781           0 :                         int const scanVarNum = ort->MonthlyColumns(scanColumn).varNum;
    3782           0 :                         Real64 scanValue = GetInternalVariableValue(state, scanTypeOfVar, scanVarNum);
    3783           0 :                         Real64 const oldScanValue = ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month);
    3784           0 :                         switch (ort->MonthlyColumns(scanColumn).aggType) {
    3785           0 :                         case AggType::HoursZero:
    3786             :                         case AggType::HoursNonZero:
    3787             :                         case AggType::HoursPositive:
    3788             :                         case AggType::HoursNonPositive:
    3789             :                         case AggType::HoursNegative:
    3790             :                         case AggType::HoursNonNegative:
    3791             :                             // end scanning since these might reset
    3792           0 :                             break; // do
    3793           0 :                         case AggType::SumOrAverageHoursShown: {
    3794             :                             // this case is when the value should be set
    3795           0 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3796           0 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = oldScanValue + scanValue;
    3797             :                             } else {
    3798             :                                 // for averaging - weight by elapsed time
    3799           0 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = oldScanValue + scanValue * elapsedTime;
    3800             :                             }
    3801           0 :                             ort->MonthlyColumns(scanColumn).duration(state.dataEnvrn->Month) += elapsedTime;
    3802           0 :                         } break;
    3803           0 :                         case AggType::MaximumDuringHoursShown: {
    3804           0 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3805           0 :                                 if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3806           0 :                                     scanValue /= TimeStepSysSec;
    3807             :                                 } else {
    3808           0 :                                     scanValue /= state.dataGlobal->TimeStepZoneSec;
    3809             :                                 }
    3810             :                             }
    3811           0 :                             if (scanValue > oldScanValue) {
    3812           0 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = scanValue;
    3813           0 :                                 ort->MonthlyColumns(scanColumn).timeStamp(state.dataEnvrn->Month) = timestepTimeStamp;
    3814             :                             }
    3815           0 :                         } break;
    3816           0 :                         case AggType::MinimumDuringHoursShown: {
    3817           0 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3818           0 :                                 if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3819           0 :                                     scanValue /= TimeStepSysSec;
    3820             :                                 } else {
    3821           0 :                                     scanValue /= state.dataGlobal->TimeStepZoneSec;
    3822             :                                 }
    3823             :                             }
    3824           0 :                             if (scanValue < oldScanValue) {
    3825           0 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = scanValue;
    3826           0 :                                 ort->MonthlyColumns(scanColumn).timeStamp(state.dataEnvrn->Month) = timestepTimeStamp;
    3827             :                             }
    3828           0 :                         } break;
    3829           0 :                         default:
    3830           0 :                             break;
    3831             :                         }
    3832           0 :                         activeHoursShown = false; // fixed CR8317
    3833             :                     }
    3834             :                 }
    3835             :             }
    3836             :         }
    3837             :     }
    3838             : }
    3839             : 
    3840      479981 : void GatherBEPSResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    3841             : {
    3842             :     // SUBROUTINE INFORMATION:
    3843             :     //       AUTHOR         Jason Glazer
    3844             :     //       DATE WRITTEN   November 2003
    3845             :     //       MODIFIED       na
    3846             :     //       RE-ENGINEERED  na
    3847             : 
    3848             :     // PURPOSE OF THIS SUBROUTINE:
    3849             :     //   This routine gathers data for producing the BEPS report
    3850             : 
    3851             :     // METHODOLOGY EMPLOYED:
    3852             :     //   Uses get input structure similar to other objects
    3853             :     //   Meter names are of two forms:
    3854             :     //         <ResourceType>:<name>
    3855             :     //   or
    3856             :     //         <EndUseType>:<ResourceType>
    3857             :     //   For the purposes of this routine, only the facility <name>
    3858             :     //   is used.  Remember that 'Building' is actually the sum of
    3859             :     //   the zones only without system,plant and exterior. The only
    3860             :     //   way to get them all is to use 'facility'
    3861             :     //   The <EndUseType> are:
    3862             :     //          Heating
    3863             :     //          Cooling
    3864             :     //          InteriorLights
    3865             :     //          ExteriorLights
    3866             :     //          InteriorEquipment
    3867             :     //          ExteriorEquipment
    3868             :     //          Fans
    3869             :     //          Pumps
    3870             :     //          HeatRejection
    3871             :     //          Humidifier
    3872             :     //          HeatRecovery
    3873             :     //          Refrigeration
    3874             :     //          Cogeneration
    3875             :     //          WaterSystems
    3876             :     //   The <ResourceType> are:
    3877             :     //          Electricity
    3878             :     //          Gas
    3879             :     //          Gasoline
    3880             :     //          Diesel
    3881             :     //          Coal
    3882             :     //          FuelOilNo1
    3883             :     //          FuelOilNo2
    3884             :     //          Propane
    3885             :     //          Water
    3886             :     //          Steam
    3887             :     //          DistrictCooling
    3888             :     //          DistrictHeating
    3889             : 
    3890             :     using DataStringGlobals::CharComma;
    3891             :     using DataStringGlobals::CharSpace;
    3892             :     using DataStringGlobals::CharTab;
    3893             : 
    3894      479981 :     auto &ort = state.dataOutRptTab;
    3895      479981 :     auto &op = state.dataOutputProcessor;
    3896             :     // if no beps report is called then skip
    3897             : 
    3898      479981 :     if ((ort->displayTabularBEPS || ort->displayLEEDSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    3899             :         // add the current time to the total elapsed time
    3900             :         // FOLLOWING LINE MOVED TO UPDATETABULARREPORTS because used even when beps is not called
    3901             :         // gatherElapsedTimeBEPS = gatherElapsedTimeBEPS + TimeStepZone
    3902             :         // loop through all of the resource types for the entire facility
    3903             :         //  DO iResource = 1, numResourceTypes
    3904             :         //    curMeterNumber = meterNumTotalsBEPS(iResource)
    3905             :         //    IF (curMeterNumber .GT. 0) THEN
    3906             :         //      curMeterValue = GetCurrentMeterValue(curMeterNumber)
    3907             :         //      gatherTotalsBEPS(iResource) = gatherTotalsBEPS(iResource) + curMeterValue
    3908             :         //    END IF
    3909             :         //  END DO
    3910             : 
    3911             :         // loop through all of the resources and end uses for the entire facility
    3912     3155040 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    3913     2944704 :             int curResMeterNumber = ort->meterNumTotalsBEPS(iResource);
    3914     2944704 :             if (curResMeterNumber > -1) {
    3915      525792 :                 Real64 curResMeterValue = GetCurrentMeterValue(state, curResMeterNumber);
    3916      525792 :                 ort->gatherTotalsBEPS(iResource) += curResMeterValue;
    3917             :             }
    3918             : 
    3919    44170560 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    3920    41225856 :                 int curEndUseMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    3921    41225856 :                 if (curEndUseMeterNumber > -1) {
    3922     1121952 :                     Real64 curEndUseMeterValue = GetCurrentMeterValue(state, curEndUseMeterNumber);
    3923     1121952 :                     ort->gatherEndUseBEPS(iResource, jEndUse) += curEndUseMeterValue;
    3924             : 
    3925     2524608 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    3926     1402656 :                         int curSubMeterNumber = ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource);
    3927     1402656 :                         if (curSubMeterNumber > -1) {
    3928     1192128 :                             Real64 curSubMeterValue = GetCurrentMeterValue(state, curSubMeterNumber);
    3929     1192128 :                             ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, iResource) += curSubMeterValue;
    3930             :                         }
    3931             :                     }
    3932     1542624 :                     for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    3933      420672 :                         int curSpTypeMeterNumber = ort->meterNumEndUseSpTypeBEPS(kEndUseSpType, jEndUse, iResource);
    3934      420672 :                         if (curSpTypeMeterNumber > -1) {
    3935      420672 :                             Real64 curSpTypeMeterValue = GetCurrentMeterValue(state, curSpTypeMeterNumber);
    3936      420672 :                             ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, iResource) += curSpTypeMeterValue;
    3937             :                         }
    3938             :                     }
    3939             :                 }
    3940             :             }
    3941             :         }
    3942             : 
    3943     2734368 :         for (int iResource = 1; iResource <= numSourceTypes; ++iResource) {
    3944     2524032 :             int curResMeterNumber = ort->meterNumTotalsSource(iResource);
    3945     2524032 :             if (curResMeterNumber > -1) {
    3946           0 :                 Real64 curResMeterValue = GetCurrentMeterValue(state, curResMeterNumber);
    3947           0 :                 ort->gatherTotalsSource(iResource) += curResMeterValue;
    3948             :             }
    3949             :         }
    3950             : 
    3951             :         // gather the electric load components
    3952      210336 :         ort->gatherPowerFuelFireGen += GetCurrentMeterValue(state, ort->meterNumPowerFuelFireGen);
    3953      210336 :         ort->gatherPowerPV += GetCurrentMeterValue(state, ort->meterNumPowerPV);
    3954      210336 :         ort->gatherPowerWind += GetCurrentMeterValue(state, ort->meterNumPowerWind);
    3955      210336 :         ort->gatherPowerHTGeothermal += GetCurrentMeterValue(state, ort->meterNumPowerHTGeothermal);
    3956      210336 :         ort->gatherElecProduced += GetCurrentMeterValue(state, ort->meterNumElecProduced);
    3957      210336 :         ort->gatherElecPurchased += GetCurrentMeterValue(state, ort->meterNumElecPurchased);
    3958      210336 :         ort->gatherElecSurplusSold += GetCurrentMeterValue(state, ort->meterNumElecSurplusSold);
    3959      210336 :         ort->gatherElecStorage += GetCurrentMeterValue(state, ort->meterNumElecStorage);
    3960      210336 :         ort->gatherPowerConversion += GetCurrentMeterValue(state, ort->meterNumPowerConversion);
    3961             :         // gather the onsite thermal components
    3962      210336 :         ort->gatherWaterHeatRecovery += GetCurrentMeterValue(state, ort->meterNumWaterHeatRecovery);
    3963      210336 :         ort->gatherAirHeatRecoveryCool += GetCurrentMeterValue(state, ort->meterNumAirHeatRecoveryCool);
    3964      210336 :         ort->gatherAirHeatRecoveryHeat += GetCurrentMeterValue(state, ort->meterNumAirHeatRecoveryHeat);
    3965      210336 :         ort->gatherHeatHTGeothermal += GetCurrentMeterValue(state, ort->meterNumHeatHTGeothermal);
    3966      210336 :         ort->gatherHeatSolarWater += GetCurrentMeterValue(state, ort->meterNumHeatSolarWater);
    3967      210336 :         ort->gatherHeatSolarAir += GetCurrentMeterValue(state, ort->meterNumHeatSolarAir);
    3968             :         // gather the water supply components
    3969      210336 :         ort->gatherRainWater += GetCurrentMeterValue(state, ort->meterNumRainWater);
    3970      210336 :         ort->gatherCondensate += GetCurrentMeterValue(state, ort->meterNumCondensate);
    3971      210336 :         ort->gatherWellwater += GetCurrentMeterValue(state, ort->meterNumGroundwater);
    3972      210336 :         ort->gatherMains += GetCurrentMeterValue(state, ort->meterNumMains);
    3973      210336 :         ort->gatherWaterEndUseTotal += GetCurrentMeterValue(state, ort->meterNumWaterEndUseTotal);
    3974             :     }
    3975      479981 : }
    3976             : 
    3977      479981 : void GatherSourceEnergyEndUseResultsForTimestep(EnergyPlusData &state,
    3978             :                                                 OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    3979             : {
    3980             :     // SUBROUTINE INFORMATION:
    3981             :     //       AUTHOR         Mangesh Basarkar
    3982             :     //       DATE WRITTEN   September 2011
    3983             :     //       MODIFIED       na
    3984             :     //       RE-ENGINEERED  na
    3985             : 
    3986             :     // PURPOSE OF THIS SUBROUTINE:
    3987             :     //   This routine gathers data for producing the end uses report in source energy
    3988             : 
    3989             :     // METHODOLOGY EMPLOYED:
    3990             :     //   Uses get input structure similar to other objects
    3991             :     //   Meter names are of two forms:
    3992             :     //         <ResourceType>:<name>
    3993             :     //   or
    3994             :     //         <EndUseType>:<ResourceType>
    3995             :     //   The <EndUseType> are:
    3996             :     //          Heating
    3997             :     //          Cooling
    3998             :     //          InteriorLights
    3999             :     //          ExteriorLights
    4000             :     //          InteriorEquipment
    4001             :     //          ExteriorEquipment
    4002             :     //          Fans
    4003             :     //          Pumps
    4004             :     //          HeatRejection
    4005             :     //          Humidifier
    4006             :     //          HeatRecovery
    4007             :     //          Refrigeration
    4008             :     //          Cogeneration
    4009             :     //          WaterSystems
    4010             :     //   The <ResourceType> are:
    4011             :     //          Electricity 1
    4012             :     //          Gas 2
    4013             :     //          Gasoline 6
    4014             :     //          Diesel 8
    4015             :     //          Coal 9
    4016             :     //          FuelOilNo1 10
    4017             :     //          FuelOilNo2 11
    4018             :     //          Propane 12
    4019             :     //          Water 7
    4020             :     //          DistrictCooling 3
    4021             :     //          DistrictHeatingWater 4
    4022             :     //          DistrictHeatingSteam 5
    4023             : 
    4024             :     //          sourceTypeNames(1)='Electric'
    4025             :     //          sourceTypeNames(2)='NaturalGas'
    4026             :     //          sourceTypeNames(3)='Gasoline'
    4027             :     //          sourceTypeNames(4)='Diesel'
    4028             :     //          sourceTypeNames(5)='Coal'
    4029             :     //          sourceTypeNames(6)='FuelOilNo1'
    4030             :     //          sourceTypeNames(7)='FuelOilNo2'
    4031             :     //          sourceTypeNames(8)='Propane'
    4032             :     //          sourceTypeNames(9)='PurchasedElectricity'
    4033             :     //          sourceTypeNames(10)='SoldElectricity'
    4034             :     //          sourceTypeNames(11)='OtherFuel1'
    4035             :     //          sourceTypeNames(12)='OtherFuel2'
    4036             : 
    4037             :     // REFERENCES:
    4038             :     // na
    4039             : 
    4040             :     // Using/Aliasing
    4041             :     using DataStringGlobals::CharComma;
    4042             :     using DataStringGlobals::CharSpace;
    4043             :     using DataStringGlobals::CharTab;
    4044             :     using ScheduleManager::GetCurrentScheduleValue;
    4045             : 
    4046             :     // Locals
    4047             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    4048             : 
    4049             :     // SUBROUTINE PARAMETER DEFINITIONS:
    4050             :     // na
    4051             : 
    4052             :     // INTERFACE BLOCK SPECIFICATIONS:
    4053             :     // na
    4054             : 
    4055             :     // DERIVED TYPE DEFINITIONS:
    4056             :     // na
    4057             : 
    4058             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    4059      479981 :     auto &ort = state.dataOutRptTab;
    4060             : 
    4061             :     // if no beps by source report is called then skip
    4062             : 
    4063      479981 :     if ((ort->displaySourceEnergyEndUseSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    4064             :         // loop through all of the resources and end uses for the entire facility
    4065     3155040 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4066             : 
    4067     2944704 :             if (ort->ffSchedUsed(iResource)) {
    4068           0 :                 int const curMeterNumber = ort->meterNumTotalsBEPS(iResource);
    4069           0 :                 if (curMeterNumber > -1) {
    4070           0 :                     Real64 const curMeterValue = GetCurrentMeterValue(state, curMeterNumber) *
    4071           0 :                                                  GetCurrentScheduleValue(state, ort->ffSchedIndex(iResource)) * ort->SourceFactors(iResource);
    4072           0 :                     ort->gatherTotalsBySourceBEPS(iResource) += curMeterValue;
    4073             :                 }
    4074             :             } else {
    4075     2944704 :                 int const curMeterNumber = ort->meterNumTotalsBEPS(iResource);
    4076     2944704 :                 if (curMeterNumber > -1) {
    4077      525792 :                     Real64 const curMeterValue = GetCurrentMeterValue(state, curMeterNumber) * ort->SourceFactors(iResource);
    4078      525792 :                     ort->gatherTotalsBySourceBEPS(iResource) += curMeterValue;
    4079             :                 }
    4080             :             }
    4081             : 
    4082    44170560 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    4083    41225856 :                 if (ort->ffSchedUsed(iResource)) {
    4084           0 :                     int const curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4085           0 :                     if (curMeterNumber > -1) {
    4086           0 :                         Real64 const curMeterValue = GetCurrentMeterValue(state, curMeterNumber) *
    4087           0 :                                                      GetCurrentScheduleValue(state, ort->ffSchedIndex(iResource)) * ort->SourceFactors(iResource);
    4088           0 :                         ort->gatherEndUseBySourceBEPS(iResource, jEndUse) += curMeterValue;
    4089             :                     }
    4090             :                 } else {
    4091    41225856 :                     int const curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4092    41225856 :                     if (curMeterNumber > -1) {
    4093     1121952 :                         Real64 const curMeterValue = GetCurrentMeterValue(state, curMeterNumber) * ort->SourceFactors(iResource);
    4094     1121952 :                         ort->gatherEndUseBySourceBEPS(iResource, jEndUse) += curMeterValue;
    4095             :                     }
    4096             :                 }
    4097             :             }
    4098             :         }
    4099             :     }
    4100      479981 : }
    4101             : 
    4102      479981 : void GatherPeakDemandForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    4103             : {
    4104             :     // SUBROUTINE INFORMATION:
    4105             :     //       AUTHOR         Jason Glazer
    4106             :     //       DATE WRITTEN   January 2009
    4107             :     //       MODIFIED       na
    4108             :     //       RE-ENGINEERED  na
    4109             : 
    4110             :     // PURPOSE OF THIS SUBROUTINE:
    4111             :     //   This routine gathers data for producing the Peak Demand
    4112             :     //   by end-use report
    4113             : 
    4114             :     // METHODOLOGY EMPLOYED:
    4115             :     //   Uses get input structure similar to other objects
    4116             :     //   Meter names are of two forms:
    4117             :     //         <ResourceType>:<name>
    4118             :     //   or
    4119             :     //         <EndUseType>:<ResourceType>
    4120             :     //   For the purposes of this routine, only the facility <name>
    4121             :     //   is used.  Remember that 'Building' is actually the sum of
    4122             :     //   the zones only without system,plant and exterior. The only
    4123             :     //   way to get them all is to use 'facility'
    4124             :     //   The <EndUseType> are:
    4125             :     //          Heating
    4126             :     //          Cooling
    4127             :     //          InteriorLights
    4128             :     //          ExteriorLights
    4129             :     //          InteriorEquipment
    4130             :     //          ExteriorEquipment
    4131             :     //          Fans
    4132             :     //          Pumps
    4133             :     //          HeatRejection
    4134             :     //          Humidifier
    4135             :     //          HeatRecovery
    4136             :     //          Refrigeration
    4137             :     //          Cogeneration
    4138             :     //          WaterSystems
    4139             :     //   The <ResourceType> are:
    4140             :     //          Electricity
    4141             :     //          Gas
    4142             :     //          Gasoline
    4143             :     //          Diesel
    4144             :     //          Coal
    4145             :     //          FuelOilNo1
    4146             :     //          FuelOilNo2
    4147             :     //          Propane
    4148             :     //          Water
    4149             :     //          DistrictCooling
    4150             :     //          DistrictHeatingWater
    4151             :     //          DistrictHeatingSteam
    4152             : 
    4153             :     // REFERENCES:
    4154             :     // na
    4155             : 
    4156             :     // Using/Aliasing
    4157             :     using DataStringGlobals::CharComma;
    4158             :     using DataStringGlobals::CharSpace;
    4159             :     using DataStringGlobals::CharTab;
    4160             :     using General::EncodeMonDayHrMin;
    4161             : 
    4162             :     // Locals
    4163             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    4164             : 
    4165             :     // SUBROUTINE PARAMETER DEFINITIONS:
    4166             :     // na
    4167             : 
    4168             :     // INTERFACE BLOCK SPECIFICATIONS:
    4169             :     // na
    4170             : 
    4171             :     // DERIVED TYPE DEFINITIONS:
    4172             :     // na
    4173             : 
    4174             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    4175      479981 :     assert(state.dataGlobal->TimeStepZoneSec > 0.0);
    4176      479981 :     auto &ort = state.dataOutRptTab;
    4177      479981 :     auto &op = state.dataOutputProcessor;
    4178             : 
    4179      479981 :     if ((ort->displayDemandEndUse) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    4180             :         // loop through all of the resources and end uses for the entire facility
    4181     3155040 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4182     2944704 :             int curMeterNumber = ort->meterNumTotalsBEPS(iResource);
    4183     2944704 :             if (curMeterNumber > -1) {
    4184      525792 :                 Real64 curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4185             :                 // check if current value is greater than existing peak demand value
    4186      525792 :                 if (curDemandValue > ort->gatherDemandTotal(iResource)) {
    4187         611 :                     ort->gatherDemandTotal(iResource) = curDemandValue;
    4188             :                     // save the time that the peak demand occurred
    4189             :                     //        minuteCalculated = (CurrentTime - INT(CurrentTime))*60
    4190         611 :                     int const minuteCalculated = OutputProcessor::DetermineMinuteForReporting(state);
    4191             :                     int timestepTimeStamp;
    4192         611 :                     EncodeMonDayHrMin(
    4193         611 :                         timestepTimeStamp, state.dataEnvrn->Month, state.dataEnvrn->DayOfMonth, state.dataGlobal->HourOfDay, minuteCalculated);
    4194         611 :                     ort->gatherDemandTimeStamp(iResource) = timestepTimeStamp;
    4195             :                     // if new peak demand is set, then gather all of the end use values at this particular
    4196             :                     // time to find the components of the peak demand
    4197        9165 :                     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    4198        8554 :                         curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4199        8554 :                         if (curMeterNumber > -1) {
    4200        1535 :                             curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4201        1535 :                             ort->gatherDemandEndUse(iResource, jEndUse) = curDemandValue;
    4202        3474 :                             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    4203        1939 :                                 curMeterNumber = ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource);
    4204        1939 :                                 if (curMeterNumber > -1) {
    4205        1567 :                                     curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4206        1567 :                                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, iResource) = curDemandValue;
    4207             :                                 }
    4208             :                             }
    4209             :                         }
    4210             :                     }
    4211             :                 }
    4212             :             }
    4213             :         }
    4214             :     }
    4215             : 
    4216             :     // gather the peak demands of each individual enduse subcategory for the LEED report
    4217      479981 :     if ((ort->displayLEEDSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    4218             :         // loop through all of the resources and end uses for the entire facility
    4219     3155040 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4220    44170560 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    4221    41225856 :                 int curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4222    41225856 :                 if (curMeterNumber > -1) {
    4223     1121952 :                     Real64 curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4224     1121952 :                     if (curDemandValue > ort->gatherDemandIndEndUse(iResource, jEndUse)) {
    4225        1111 :                         ort->gatherDemandIndEndUse(iResource, jEndUse) = curDemandValue;
    4226             :                     }
    4227     2524608 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    4228     1402656 :                         curMeterNumber = ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource);
    4229     1402656 :                         if (curMeterNumber > -1) {
    4230     1192128 :                             curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4231             :                             // check if current value is greater than existing peak demand value
    4232     1192128 :                             if (curDemandValue > ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, iResource)) {
    4233        1111 :                                 ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, iResource) = curDemandValue;
    4234             :                             }
    4235             :                         }
    4236             :                     }
    4237             :                 }
    4238             :             }
    4239             :         }
    4240             :     }
    4241      479981 : }
    4242             : 
    4243      479981 : void GatherHeatEmissionReport(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType)
    4244             : {
    4245             :     // PURPOSE OF THIS SUBROUTINE:
    4246             :     // Gathers the data each zone timestep for the heat gain report.
    4247             :     // The routine generates an annual table with the following columns which correspond to
    4248             :     // the output variables and data structures shown.
    4249             : 
    4250      479981 :     state.dataHeatBal->SysTotalHVACReliefHeatLoss = 0;
    4251      479981 :     state.dataHeatBal->SysTotalHVACRejectHeatLoss = 0;
    4252      479981 :     auto const &ort = state.dataOutRptTab;
    4253             : 
    4254      479981 :     if (!ort->displayHeatEmissionsSummary) {
    4255           0 :         return; // don't gather data if report isn't requested
    4256             :     }
    4257             : 
    4258             :     // Only gather zone report at zone time steps
    4259      479981 :     if (t_timeStepType == OutputProcessor::TimeStepType::Zone) {
    4260      210336 :         state.dataHeatBal->BuildingPreDefRep.emiEnvelopConv += state.dataHeatBalSurf->SumSurfaceHeatEmission * Constant::convertJtoGJ;
    4261      210336 :         return;
    4262             :     }
    4263             : 
    4264      269645 :     CalcHeatEmissionReport(state);
    4265      269645 :     state.dataHeatBal->BuildingPreDefRep.emiZoneExfiltration += state.dataHeatBal->ZoneTotalExfiltrationHeatLoss * Constant::convertJtoGJ;
    4266      269645 :     state.dataHeatBal->BuildingPreDefRep.emiZoneExhaust += state.dataHeatBal->ZoneTotalExhaustHeatLoss * Constant::convertJtoGJ;
    4267      269645 :     state.dataHeatBal->BuildingPreDefRep.emiHVACRelief += state.dataHeatBal->SysTotalHVACReliefHeatLoss * Constant::convertJtoGJ;
    4268      269645 :     state.dataHeatBal->BuildingPreDefRep.emiHVACReject += state.dataHeatBal->SysTotalHVACRejectHeatLoss * Constant::convertJtoGJ;
    4269             : 
    4270      269645 :     state.dataHeatBal->BuildingPreDefRep.emiTotHeat =
    4271      269645 :         state.dataHeatBal->BuildingPreDefRep.emiEnvelopConv + state.dataHeatBal->BuildingPreDefRep.emiZoneExfiltration +
    4272      269645 :         state.dataHeatBal->BuildingPreDefRep.emiZoneExhaust + state.dataHeatBal->BuildingPreDefRep.emiHVACRelief +
    4273      269645 :         state.dataHeatBal->BuildingPreDefRep.emiHVACReject;
    4274             : }
    4275             : 
    4276     1674968 : void CalcHeatEmissionReport(EnergyPlusData &state)
    4277             : {
    4278             :     // PURPOSE OF THIS SUBROUTINE:
    4279             :     // Gathers the data each zone timestep for the heat gain report.
    4280             :     // The routine generates an annual table with the following columns which correspond to
    4281             :     // the output variables and data structures shown.
    4282             : 
    4283             :     // Using/Aliasing
    4284     1674968 :     Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    4285             : 
    4286     1674968 :     Real64 H2OHtOfVap_HVAC = Psychrometrics::PsyHgAirFnWTdb(state.dataEnvrn->OutHumRat, state.dataEnvrn->OutDryBulbTemp);
    4287     1674968 :     Real64 RhoWater = Psychrometrics::RhoH2O(state.dataEnvrn->OutDryBulbTemp);
    4288             : 
    4289     1674968 :     state.dataHeatBal->SysTotalHVACReliefHeatLoss = 0;
    4290     1674968 :     state.dataHeatBal->SysTotalHVACRejectHeatLoss = 0;
    4291             : 
    4292             :     // HVAC relief air
    4293     3570438 :     for (int iOACtrl = 1; iOACtrl <= state.dataMixedAir->NumOAControllers; ++iOACtrl) {
    4294     1895470 :         state.dataHeatBal->SysTotalHVACReliefHeatLoss += state.dataMixedAir->OAController(iOACtrl).RelTotalLossRate * TimeStepSysSec;
    4295             :     }
    4296             : 
    4297             :     // Airloop HVAC Exhaust System
    4298     1675930 :     for (int iExhSys = 1; iExhSys < state.dataZoneEquip->NumExhaustAirSystems; ++iExhSys) {
    4299         962 :         state.dataHeatBal->SysTotalHVACReliefHeatLoss += state.dataZoneEquip->ExhaustAirSystem(iExhSys).exhTotalHVACReliefHeatLoss;
    4300             :     }
    4301             : 
    4302             :     // Condenser water loop
    4303     2084182 :     for (int iCooler = 1; iCooler <= (int)state.dataCondenserLoopTowers->towers.size(); ++iCooler) {
    4304      818428 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += state.dataCondenserLoopTowers->towers(iCooler).Qactual * TimeStepSysSec +
    4305      409214 :                                                          state.dataCondenserLoopTowers->towers(iCooler).FanEnergy +
    4306      409214 :                                                          state.dataCondenserLoopTowers->towers(iCooler).BasinHeaterConsumption;
    4307             :     }
    4308     1679087 :     for (auto const &thisCooler : state.dataEvapFluidCoolers->SimpleEvapFluidCooler) {
    4309        4119 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCooler.Qactual * TimeStepSysSec + thisCooler.FanEnergy;
    4310             :     }
    4311     1681580 :     for (auto const &cooler : state.dataFluidCoolers->SimpleFluidCooler) {
    4312        6612 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += cooler.Qactual * TimeStepSysSec + cooler.FanEnergy;
    4313             :     }
    4314             : 
    4315             :     // Air- and Evap-cooled chiller
    4316     2174291 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumElectricChillers; ++iChiller) {
    4317      499323 :         auto const &thisChiller = state.dataPlantChillers->ElectricChiller(iChiller);
    4318             : 
    4319      499323 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4320      233315 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4321             :         }
    4322             :     }
    4323     1691252 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumEngineDrivenChillers; ++iChiller) {
    4324       16284 :         auto const &thisChiller = state.dataPlantChillers->EngineDrivenChiller(iChiller);
    4325             : 
    4326       16284 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4327           0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4328             :         }
    4329             :     }
    4330     1677905 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumGTChillers; ++iChiller) {
    4331        2937 :         auto const &thisChiller = state.dataPlantChillers->GTChiller(iChiller);
    4332             : 
    4333        2937 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4334           0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4335             :         }
    4336             :     }
    4337     1848325 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumConstCOPChillers; ++iChiller) {
    4338      173357 :         auto const &thisChiller = state.dataPlantChillers->ConstCOPChiller(iChiller);
    4339             : 
    4340      173357 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4341        3419 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4342             :         }
    4343             :     }
    4344             : 
    4345     1712605 :     for (int iChiller = 1; iChiller <= (int)state.dataChillerElectricEIR->ElectricEIRChiller.size(); ++iChiller) {
    4346       37637 :         auto const &thisChiller = state.dataChillerElectricEIR->ElectricEIRChiller(iChiller);
    4347             : 
    4348       37637 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4349        6658 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondEnergy;
    4350             :         }
    4351             :     }
    4352     1684174 :     for (int iChiller = 1; iChiller <= (int)state.dataChillerReformulatedEIR->ElecReformEIRChiller.size(); ++iChiller) {
    4353        9206 :         auto const &thisChiller = state.dataChillerReformulatedEIR->ElecReformEIRChiller(iChiller);
    4354             : 
    4355        9206 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4356           0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondEnergy;
    4357             :         }
    4358             :     }
    4359             : 
    4360             :     // Water / steam boiler
    4361     2063747 :     for (int iBoiler = 1; iBoiler <= (int)state.dataBoilers->Boiler.size(); ++iBoiler) {
    4362      388779 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4363      388779 :             state.dataBoilers->Boiler(iBoiler).FuelConsumed + state.dataBoilers->Boiler(iBoiler).ParasiticFuelConsumption +
    4364      388779 :             state.dataBoilers->Boiler(iBoiler).ParasiticElecConsumption - state.dataBoilers->Boiler(iBoiler).BoilerEnergy;
    4365             :     }
    4366             : 
    4367             :     // DX Coils air to air
    4368     3151811 :     for (int iCoil = 1; iCoil <= state.dataDXCoils->NumDXCoils; ++iCoil) {
    4369     1476843 :         auto const &thisDXCoil = state.dataDXCoils->DXCoil(iCoil);
    4370             : 
    4371     1476843 :         if (thisDXCoil.DXCoilType_Num == HVAC::CoilDX_CoolingSingleSpeed || thisDXCoil.DXCoilType_Num == HVAC::CoilDX_CoolingTwoSpeed ||
    4372      706320 :             thisDXCoil.DXCoilType_Num == HVAC::CoilDX_MultiSpeedCooling || thisDXCoil.DXCoilType_Num == HVAC::CoilDX_CoolingTwoStageWHumControl) {
    4373      960397 :             if (thisDXCoil.CondenserType(1) == DataHeatBalance::RefrigCondenserType::Air) {
    4374      956539 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.ElecCoolingConsumption + thisDXCoil.DefrostConsumption +
    4375      956539 :                                                                  thisDXCoil.CrankcaseHeaterConsumption + thisDXCoil.TotalCoolingEnergy;
    4376        3858 :             } else if (thisDXCoil.CondenserType(1) == DataHeatBalance::RefrigCondenserType::Evap) {
    4377        3858 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.EvapCondPumpElecConsumption + thisDXCoil.BasinHeaterConsumption +
    4378        3858 :                                                                  thisDXCoil.EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC;
    4379             :             }
    4380      960397 :             if (thisDXCoil.FuelType != Constant::eFuel::Electricity) {
    4381      793338 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.MSFuelWasteHeat * TimeStepSysSec;
    4382             :             }
    4383      516446 :         } else if (thisDXCoil.DXCoilType_Num == HVAC::CoilDX_HeatingEmpirical || thisDXCoil.DXCoilType_Num == HVAC::CoilDX_MultiSpeedHeating) {
    4384      355900 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.ElecHeatingConsumption + thisDXCoil.DefrostConsumption +
    4385      355900 :                                                              thisDXCoil.FuelConsumed + thisDXCoil.CrankcaseHeaterConsumption -
    4386      355900 :                                                              thisDXCoil.TotalHeatingEnergy;
    4387             :         }
    4388             :     }
    4389             :     // VAV coils - air to air
    4390     1858830 :     for (int iCoil = 1; iCoil <= state.dataVariableSpeedCoils->NumVarSpeedCoils; ++iCoil) {
    4391      183862 :         auto const &thisCoil = state.dataVariableSpeedCoils->VarSpeedCoil(iCoil);
    4392             : 
    4393      183862 :         if (thisCoil.VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    4394      124584 :             if (thisCoil.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4395      124584 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4396      124584 :                     thisCoil.Energy + thisCoil.CrankcaseHeaterConsumption + thisCoil.DefrostConsumption + thisCoil.EnergyLoadTotal;
    4397           0 :             } else if (thisCoil.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    4398           0 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4399           0 :                     thisCoil.EvapCondPumpElecConsumption + thisCoil.BasinHeaterConsumption + thisCoil.EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC;
    4400             :             }
    4401       59278 :         } else if (thisCoil.VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    4402       10449 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4403       10449 :                 thisCoil.Energy + thisCoil.CrankcaseHeaterConsumption + thisCoil.DefrostConsumption - thisCoil.EnergyLoadTotal;
    4404             :         }
    4405             :     }
    4406             : 
    4407             :     // Heating coils - fuel
    4408     3839799 :     for (int iCoil = 1; iCoil <= state.dataHeatingCoils->NumHeatingCoils; ++iCoil) {
    4409     2164831 :         auto const &thisCoil = state.dataHeatingCoils->HeatingCoil(iCoil);
    4410             : 
    4411     2164831 :         if (thisCoil.HCoilType_Num == HVAC::Coil_HeatingGas_MultiStage || thisCoil.HCoilType_Num == HVAC::Coil_HeatingGasOrOtherFuel) {
    4412     1448790 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCoil.FuelUseLoad + thisCoil.ParasiticFuelConsumption - thisCoil.HeatingCoilLoad;
    4413             :         }
    4414             :     }
    4415             : 
    4416             :     // Packaged TES
    4417     1680692 :     for (int iCoil = 1; iCoil <= state.dataPackagedThermalStorageCoil->NumTESCoils; ++iCoil) {
    4418        5724 :         auto const &thisCoil = state.dataPackagedThermalStorageCoil->TESCoil(iCoil);
    4419             : 
    4420        5724 :         if (thisCoil.CondenserType == PackagedThermalStorageCoil::TESCondenserType::Air) {
    4421        4293 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4422        4293 :                 thisCoil.EvapTotCoolingEnergy + thisCoil.ElecCoolingEnergy + thisCoil.ElectColdWeatherEnergy - thisCoil.Q_Ambient;
    4423        1431 :         } else if (thisCoil.CondenserType == PackagedThermalStorageCoil::TESCondenserType::Evap) {
    4424        1431 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCoil.EvapCondPumpElecConsumption + thisCoil.ElectEvapCondBasinHeaterEnergy +
    4425        1431 :                                                              thisCoil.EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC - thisCoil.Q_Ambient;
    4426             :         }
    4427             :     }
    4428             : 
    4429             :     // Water heater and thermal storage
    4430     1869420 :     for (int iTank = 1; iTank <= state.dataWaterThermalTanks->numWaterThermalTank; ++iTank) {
    4431      194452 :         auto const &thisTank = state.dataWaterThermalTanks->WaterThermalTank(iTank);
    4432             : 
    4433      194452 :         if (thisTank.AmbientTempIndicator == WaterThermalTanks::WTTAmbientTemp::OutsideAir) {
    4434       10642 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisTank.FuelEnergy - thisTank.TotalDemandEnergy;
    4435             :         }
    4436             :     }
    4437             : 
    4438             :     // Variable Refrigerant Flow
    4439     1690195 :     for (int iCoil = 1; iCoil <= state.dataHVACVarRefFlow->NumVRFCond; ++iCoil) {
    4440       15227 :         auto const &thisVRF = state.dataHVACVarRefFlow->VRF(iCoil);
    4441             : 
    4442       15227 :         if (thisVRF.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4443       14222 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisVRF.CoolElecConsumption + thisVRF.HeatElecConsumption +
    4444       14222 :                                                              thisVRF.CrankCaseHeaterElecConsumption + thisVRF.DefrostConsumption +
    4445       14222 :                                                              (thisVRF.TotalCoolingCapacity - thisVRF.TotalHeatingCapacity) * TimeStepSysSec;
    4446        1005 :         } else if (thisVRF.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    4447           0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisVRF.EvapCondPumpElecConsumption + thisVRF.BasinHeaterConsumption +
    4448           0 :                                                              thisVRF.EvapWaterConsumpRate * TimeStepSysSec * RhoWater * H2OHtOfVap_HVAC;
    4449        1005 :         } else if (thisVRF.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    4450        1005 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisVRF.QCondEnergy;
    4451             :         }
    4452             :     }
    4453             : 
    4454             :     // Refrigerated Rack
    4455     1724981 :     for (int iRef = 1; iRef <= state.dataRefrigCase->NumRefrigeratedRacks; ++iRef) {
    4456       50013 :         auto const &thisRack = state.dataRefrigCase->RefrigRack(iRef);
    4457             : 
    4458       50013 :         if (thisRack.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4459       46442 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisRack.RackElecConsumption + thisRack.RackCoolingEnergy;
    4460        3571 :         } else if (thisRack.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    4461        2306 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4462        2306 :                 thisRack.EvapPumpConsumption + thisRack.BasinHeaterConsumption + thisRack.EvapWaterConsumption * RhoWater * H2OHtOfVap_HVAC;
    4463        1265 :         } else if (thisRack.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    4464        1265 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisRack.CondEnergy;
    4465             :         }
    4466             :     }
    4467             : 
    4468             :     // Refrigerated Case - Condenser
    4469     1759400 :     for (int iRef = 1; iRef <= state.dataRefrigCase->NumRefrigCondensers; ++iRef) {
    4470       84432 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += state.dataRefrigCase->Condenser(iRef).CondEnergy;
    4471             :     }
    4472             : 
    4473             :     // Evaporative coolers
    4474     1787135 :     for (int iCooler = 1; iCooler <= state.dataEvapCoolers->NumEvapCool; ++iCooler) {
    4475      112167 :         auto const &thisCooler = state.dataEvapCoolers->EvapCond(iCooler);
    4476             : 
    4477      112167 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCooler.EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC + thisCooler.EvapCoolerEnergy;
    4478             :     }
    4479     1674968 : }
    4480             : 
    4481      479981 : void GatherHeatGainReport(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    4482             : {
    4483             :     // SUBROUTINE INFORMATION:
    4484             :     //       AUTHOR         Jason Glazer
    4485             :     //       DATE WRITTEN   August 2011
    4486             :     //       MODIFIED       na
    4487             :     //       RE-ENGINEERED  na
    4488             : 
    4489             :     // PURPOSE OF THIS SUBROUTINE:
    4490             :     //   Gathers the data each zone timestep for the heat gain report.
    4491             :     // The routine generates an annual table with the following columns which correspond to
    4492             :     // the output variables and data structures shown:
    4493             :     // Column                               Output Variable                                Internal Data Structure      Timestep Type
    4494             :     // ------                               ---------------                                -----------------------      -------- -----
    4495             :     // HVAC Input Sensible Air Heating      Zone Air Heat Balance System Air Transfer Rate ZnAirRpt()%SumMCpDTsystem    HVAC     Rate
    4496             :     //                                   Zone Air Heat Balance System Convective Heat Gain Rate ZnAirRpt()%SumNonAirSystem HVAC   Rate
    4497             :     // HVAC Input Sensible Air Cooling      Zone Air Heat Balance System Air Transfer Rate ZnAirRpt()%SumMCpDTsystem    HVAC     Rate
    4498             :     // HVAC sensible heating by ATU         sensible heating by the air terminal unit                                   HVAC     Rate
    4499             :     // HVAC sensible cooling by ATU         sensible cooling by the air terminal unit                                   HVAC     Rate
    4500             :     //                                    Zone Air Heat Balance System Convective Heat Gain Rate ZnAirRpt()%SumNonAirSystem HVAC  Rate
    4501             :     // HVAC Input Heated Surface Heating    Electric Low Temp Radiant Heating Energy       ElecRadSys()%HeatEnergy      HVAC     Energy
    4502             :     //                                      Zone Ventilated Slab Radiant Heating Energy    VentSlab()%RadHeatingEnergy  HVAC     Energy
    4503             :     //                                      Hydronic Low Temp Radiant Heating Energy       HydrRadSys()%HeatEnergy      HVAC     Energy
    4504             :     //                                      Constant Flow Low Temp Radiant Heating Energy  CFloRadSys()%HeatEnergy      HVAC     Energy
    4505             :     // HVAC Input Cooled Surface Cooling    Zone Ventilated Slab Radiant Cooling Energy    -VentSlab()%RadCoolingEnergy HVAC     Energy
    4506             :     //                                      Hydronic Low Temp Radiant Cooling Energy       -HydrRadSys()%CoolEnergy     HVAC     Energy
    4507             :     //                                      Constant Flow Low Temp Radiant Cooling Energy  -CFloRadSys()%CoolEnergy     HVAC     Energy
    4508             :     // People Sensible Heat Addition        Zone People Sensible Heating Energy            ZoneRpt()%PeopleSenGain        Zone     Energy
    4509             :     // Lights Sensible Heat Addition        Zone Lights Total Heating Energy               ZoneRpt()%LtsTotGain           Zone     Energy
    4510             :     // Equipment Sensible Heat Addition     Zone Electric Equipment Radiant Heating Energy ZoneRpt()%ElecRadGain          Zone     Energy
    4511             :     //                                      Zone Gas Equipment Radiant Heating Energy      ZoneRpt()%GasRadGain           Zone     Energy
    4512             :     //                                      Zone Steam Equipment Radiant Heating Energy    ZoneRpt()%SteamRadGain         Zone     Energy
    4513             :     //                                      Zone Hot Water Equipment Radiant Heating Energy ZoneRpt()%HWRadGain           Zone     Energy
    4514             :     //                                      Zone Other Equipment Radiant Heating Energy    ZoneRpt()%OtherRadGain         Zone     Energy
    4515             :     //                                   Zone Electric Equipment Convective Heating Energy ZoneRpt()%ElecConGain          Zone     Energy
    4516             :     //                                      Zone Gas Equipment Convective Heating Energy   ZoneRpt()%GasConGain           Zone     Energy
    4517             :     //                                      Zone Steam Equipment Convective Heating Energy ZoneRpt()%SteamConGain         Zone     Energy
    4518             :     //                                    Zone Hot Water Equipment Convective Heating Energy ZoneRpt()%HWConGain          Zone     Energy
    4519             :     //                                      Zone Other Equipment Convective Heating Energy ZoneRpt()%OtherConGain         Zone     Energy
    4520             :     // Window Heat Addition                 Zone Windows Total Heat Gain Energy            ZoneWinHeatGainRepEnergy()   Zone     Energy
    4521             :     // Interzone Air Transfer Heat Addition Zone Air Heat Balance Interzone Air Transfer Rate  ZnAirRpt()%SumMCpDTzones HVAC     Rate
    4522             :     // Infiltration Heat Addition           Zone Air Heat Balance Outdoor Air Transfer Rate ZnAirRpt()%SumMCpDtInfil     HVAC     Rate
    4523             :     // Equipment Sensible Heat Removal      Zone Electric Equipment Radiant Heating Energy ZoneRpt()%ElecRadGain          Zone     Energy
    4524             :     //                                      Zone Gas Equipment Radiant Heating Energy      ZoneRpt()%GasRadGain           Zone     Energy
    4525             :     //                                      Zone Steam Equipment Radiant Heating Energy    ZoneRpt()%SteamRadGain         Zone     Energy
    4526             :     //                                      Zone Hot Water Equipment Radiant Heating Energy ZoneRpt()%HWRadGain           Zone     Energy
    4527             :     //                                      Zone Other Equipment Radiant Heating Energy    ZoneRpt()%OtherRadGain         Zone     Energy
    4528             :     //                                   Zone Electric Equipment Convective Heating Energy ZoneRpt()%ElecConGain          Zone     Energy
    4529             :     //                                      Zone Gas Equipment Convective Heating Energy   ZoneRpt()%GasConGain           Zone     Energy
    4530             :     //                                      Zone Steam Equipment Convective Heating Energy ZoneRpt()%SteamConGain         Zone     Energy
    4531             :     //                                     Zone Hot Water Equipment Convective Heating Energy ZoneRpt()%HWConGain         Zone     Energy
    4532             :     //                                      Zone Other Equipment Convective Heating Energy ZoneRpt()%OtherConGain         Zone     Energy
    4533             :     // Window Heat Removal                  Zone Windows Total Heat Loss Energy            -ZoneWinHeatLossRepEnergy()  Zone     Energy
    4534             :     // Interzone Air Transfer Heat Removal  Zone Air Heat Balance Interzone Air Transfer Rate ZnAirRpt()%SumMCpDTzones  HVAC     Rate
    4535             :     // Infiltration Heat Removal            Zone Air Heat Balance Outdoor Air Transfer Rate ZnAirRpt()%SumMCpDtInfil     HVAC     Rate
    4536             :     // The following two columns are derived based on the values of the other columns and need to be computed on every HVAC timestep.
    4537             :     //   Opaque Surface Conduction and Other Heat Addition
    4538             :     //   Opaque Surface Conduction and Other Heat Removal
    4539             :     // For variables that are updated on a zone timestep basis, the values are used on the HVAC timestep but are ratioed by the
    4540             :     // timestep lengths.
    4541             :     // The peak reports follow a similar example.
    4542             : 
    4543             :     // Using/Aliasing
    4544      479981 :     Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    4545             : 
    4546             :     using General::EncodeMonDayHrMin;
    4547             : 
    4548      479981 :     auto &Zone = state.dataHeatBal->Zone;
    4549      479981 :     auto &ZonePreDefRep = state.dataHeatBal->ZonePreDefRep;
    4550             : 
    4551      479981 :     if (!state.dataGlobal->DoWeathSim) {
    4552           0 :         return;
    4553             :     }
    4554             : 
    4555      479981 :     if (!state.dataOutRptPredefined->reportName(state.dataOutRptPredefined->pdrSensibleGain).show)
    4556           0 :         return; // don't gather data if report isn't requested
    4557             : 
    4558      479981 :     if (t_timeStepType == OutputProcessor::TimeStepType::Zone) {
    4559      210336 :         return; // only add values over the HVAC timestep basis
    4560             :     }
    4561             : 
    4562      269645 :     auto &ort = state.dataOutRptTab;
    4563             : 
    4564      269645 :     if (ort->GatherHeatGainReportfirstTime) {
    4565           5 :         state.dataOutRptTab->radiantHeat.allocate(state.dataGlobal->NumOfZones);
    4566           5 :         state.dataOutRptTab->radiantCool.allocate(state.dataGlobal->NumOfZones);
    4567           5 :         state.dataOutRptTab->ATUHeat.allocate(state.dataGlobal->NumOfZones);
    4568           5 :         state.dataOutRptTab->ATUCool.allocate(state.dataGlobal->NumOfZones);
    4569           5 :         ort->GatherHeatGainReportfirstTime = false;
    4570             :     }
    4571             :     // clear the radiant surface accumulation variables
    4572      269645 :     state.dataOutRptTab->radiantHeat = 0.0;
    4573      269645 :     state.dataOutRptTab->radiantCool = 0.0;
    4574             :     // clear the ATU accumulation variables
    4575      269645 :     state.dataOutRptTab->ATUHeat = 0.0;
    4576      269645 :     state.dataOutRptTab->ATUCool = 0.0;
    4577             :     //--------------------
    4578             :     //     ANNUAL
    4579             :     //--------------------
    4580             :     // HVAC annual heating by ATU
    4581             :     // HVAC annual cooling by ATU
    4582      987870 :     for (state.dataOutRptTab->iunitGHGR = 1; state.dataOutRptTab->iunitGHGR <= (int)state.dataDefineEquipment->AirDistUnit.size();
    4583      718225 :          ++state.dataOutRptTab->iunitGHGR) {
    4584             :         // HVAC equipment should already have the multipliers included, no "* mult" needed (assumes autosized or multiplied hard-sized air flow).
    4585      718225 :         state.dataOutRptTab->curZoneGHGR = state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).ZoneNum;
    4586      718225 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4587      718225 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnHvacATUHt +=
    4588      718225 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).HeatGain;
    4589      718225 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnHvacATUCl -=
    4590      718225 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).CoolGain;
    4591      718225 :             state.dataOutRptTab->ATUHeat(state.dataOutRptTab->curZoneGHGR) +=
    4592      718225 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).HeatRate;
    4593      718225 :             state.dataOutRptTab->ATUCool(state.dataOutRptTab->curZoneGHGR) -=
    4594      718225 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).CoolRate;
    4595             :         }
    4596             :     }
    4597             :     // the fraction of the zone time step used by the system timestep
    4598      269645 :     state.dataOutRptTab->timeStepRatio = state.dataHVACGlobal->TimeStepSys / state.dataGlobal->TimeStepZone;
    4599     1509515 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4600     1239870 :         Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    4601             :         // People Sensible Heat Addition
    4602     1239870 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnPeoplAdd +=
    4603     1239870 :             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGain * mult * state.dataOutRptTab->timeStepRatio;
    4604             :         // Lights Sensible Heat Addition
    4605     1239870 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnLiteAdd +=
    4606     1239870 :             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGain * mult * state.dataOutRptTab->timeStepRatio;
    4607             :         // HVAC Input Sensible Air Heating
    4608             :         // HVAC Input Sensible Air Cooling
    4609     1239870 :         Real64 ZoneEqHeatorCool = state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4610     1239870 :                                   state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult -
    4611     1239870 :                                   state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR) -
    4612     1239870 :                                   state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    4613     1239870 :         if (ZoneEqHeatorCool > 0.0) {
    4614      145176 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqHt += ZoneEqHeatorCool * TimeStepSysSec;
    4615             :         } else {
    4616     1094694 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqCl += ZoneEqHeatorCool * TimeStepSysSec;
    4617             :         }
    4618             :         // Interzone Air Transfer Heat Addition
    4619             :         // Interzone Air Transfer Heat Removal
    4620     1239870 :         if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    4621           0 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaAdd +=
    4622           0 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult * TimeStepSysSec;
    4623             :         } else {
    4624     1239870 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaRem +=
    4625     1239870 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult * TimeStepSysSec;
    4626             :         }
    4627             :         // Window Heat Addition
    4628             :         // Window Heat Removal
    4629     1239870 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindAdd +=
    4630     1239870 :             state.dataHeatBal->ZoneWinHeatGainRepEnergy(state.dataOutRptTab->iZoneGHGR) * mult * state.dataOutRptTab->timeStepRatio;
    4631     1239870 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindRem -=
    4632     1239870 :             state.dataHeatBal->ZoneWinHeatLossRepEnergy(state.dataOutRptTab->iZoneGHGR) * mult * state.dataOutRptTab->timeStepRatio;
    4633             :         // Infiltration Heat Addition
    4634             :         // Infiltration Heat Removal
    4635     1239870 :         if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 0.0) {
    4636       25534 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilAdd +=
    4637       25534 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult * TimeStepSysSec;
    4638             :         } else {
    4639     1214336 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilRem +=
    4640     1214336 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult * TimeStepSysSec;
    4641             :         }
    4642             :         // Equipment Sensible Heat Addition
    4643             :         // Equipment Sensible Heat Removal
    4644             :         // the following variables are already gains so they do not need to be converted by multiplying by time.
    4645     1239870 :         state.dataOutRptTab->eqpSensGHGR = (state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGain +
    4646     1239870 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGain +
    4647     1239870 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGain +
    4648     1239870 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGain +
    4649     1239870 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGain +
    4650     1239870 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGain +
    4651     1239870 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGain +
    4652     1239870 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGain +
    4653     1239870 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGain +
    4654     1239870 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGain) *
    4655     1239870 :                                            state.dataOutRptTab->timeStepRatio;
    4656     1239870 :         if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    4657      825337 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipAdd += state.dataOutRptTab->eqpSensGHGR * mult;
    4658             :         } else {
    4659      414533 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipRem += state.dataOutRptTab->eqpSensGHGR * mult;
    4660             :         }
    4661             :     }
    4662      269645 :     state.dataOutRptTab->curZoneGHGR = 0;
    4663             :     // HVAC Input Heated Surface Heating
    4664             :     // HVAC Input Cooled Surface Cooling
    4665      269645 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataVentilatedSlab->NumOfVentSlabs;
    4666           0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4667           0 :         state.dataOutRptTab->curZoneGHGR = state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4668           0 :         Real64 const mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4669           0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4670           0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4671           0 :                 state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadHeatingEnergy * mult;
    4672           0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfCl -=
    4673           0 :                 state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadCoolingEnergy * mult;
    4674           0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) =
    4675           0 :                 state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadHeatingPower * mult;
    4676           0 :             state.dataOutRptTab->radiantCool(state.dataOutRptTab->curZoneGHGR) =
    4677           0 :                 -state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadCoolingPower * mult;
    4678             :         }
    4679             :     }
    4680      269645 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataLowTempRadSys->NumOfHydrLowTempRadSys;
    4681           0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4682           0 :         state.dataOutRptTab->curZoneGHGR = state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4683           0 :         Real64 const mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4684           0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4685           0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4686           0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).HeatEnergy * mult;
    4687           0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfCl -=
    4688           0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).CoolEnergy * mult;
    4689           0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) +=
    4690           0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).HeatPower * mult;
    4691           0 :             state.dataOutRptTab->radiantCool(state.dataOutRptTab->curZoneGHGR) -=
    4692           0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).CoolPower * mult;
    4693             :         }
    4694             :     }
    4695      269645 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataLowTempRadSys->NumOfCFloLowTempRadSys;
    4696           0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4697           0 :         state.dataOutRptTab->curZoneGHGR = state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4698           0 :         Real64 const mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4699           0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4700           0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4701           0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).HeatEnergy * mult;
    4702           0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfCl -=
    4703           0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).CoolEnergy * mult;
    4704           0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) +=
    4705           0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).HeatPower * mult;
    4706           0 :             state.dataOutRptTab->radiantCool(state.dataOutRptTab->curZoneGHGR) -=
    4707           0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).CoolPower * mult;
    4708             :         }
    4709             :     }
    4710      269645 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataLowTempRadSys->NumOfElecLowTempRadSys;
    4711           0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4712           0 :         state.dataOutRptTab->curZoneGHGR = state.dataLowTempRadSys->ElecRadSys(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4713           0 :         Real64 const mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4714           0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4715           0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4716           0 :                 state.dataLowTempRadSys->ElecRadSys(state.dataOutRptTab->iRadiantGHGR).HeatEnergy * mult;
    4717           0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) +=
    4718           0 :                 state.dataLowTempRadSys->ElecRadSys(state.dataOutRptTab->iRadiantGHGR).HeatPower * mult;
    4719             :         }
    4720             :     }
    4721             :     // Opaque Surface Conduction and Other Heat Addition
    4722             :     // Opaque Surface Conduction and Other Heat Removal
    4723     1509515 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4724             :         // ZonePreDefRep variables above already inlude zone list and group multipliers
    4725     2479740 :         state.dataOutRptTab->totalGHGR =
    4726     1239870 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnPeoplAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnLiteAdd +
    4727     1239870 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqCl +
    4728     1239870 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnHvacATUHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnHvacATUCl +
    4729     1239870 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaRem +
    4730     1239870 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindRem +
    4731     1239870 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilRem +
    4732     1239870 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipRem +
    4733     1239870 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnSurfHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnSurfCl;
    4734     2479740 :         state.dataOutRptTab->totalGHGR =
    4735     1239870 :             -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    4736     1239870 :         if (state.dataOutRptTab->totalGHGR > 0) {
    4737       30190 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnOtherAdd = state.dataOutRptTab->totalGHGR;
    4738             :         } else {
    4739     1209680 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnOtherRem = state.dataOutRptTab->totalGHGR;
    4740             :         }
    4741             :     }
    4742             :     //--------------------------------
    4743             :     // ZONE PEAK COOLING AND HEATING
    4744             :     //--------------------------------
    4745     1509515 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4746     1239870 :         Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    4747             :         // RR I can't get the Infiltration Heat Addition/Removal columns to add up.
    4748             :         // THis is the only suspect line, mixing MCpDt terms and a power term looks fishy.
    4749     1239870 :         if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4750     1239870 :              state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4751     1239870 :              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) > 0) {
    4752      318414 :             if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4753      318414 :                  state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4754      318414 :                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) >
    4755      318414 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).htPeak) {
    4756         659 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).htPeak =
    4757         659 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4758         659 :                     state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4759         659 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4760             :                 // determine timestamp
    4761             :                 //      ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    4762             :                 //      ActualtimeE = ActualTimeS+TimeStepSys
    4763             :                 //      ActualTimeHrS=INT(ActualTimeS)
    4764             :                 //      ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    4765         659 :                 int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    4766         659 :                 EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    4767         659 :                                   state.dataEnvrn->Month,
    4768         659 :                                   state.dataEnvrn->DayOfMonth,
    4769         659 :                                   state.dataGlobal->HourOfDay,
    4770             :                                   ActualTimeMin);
    4771         659 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).htPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    4772             :                 // HVAC Input Sensible Air Heating
    4773             :                 // HVAC Input Sensible Air Cooling
    4774             :                 // non-HVAC ZnAirRpt variables DO NOT include zone multipliers
    4775         659 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacHt =
    4776         659 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4777         659 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4778         659 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacCl = 0.0;
    4779             :                 // HVAC Input Heated Surface Heating
    4780             :                 // HVAC Input Cooled Surface Cooling
    4781         659 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfHt =
    4782         659 :                     state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4783         659 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfCl =
    4784         659 :                     state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4785             :                 // HVAC ATU Heating at Heat Peak
    4786             :                 // HVAC ATU Cooling at Heat Peak
    4787         659 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacATUHt =
    4788         659 :                     state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4789         659 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacATUCl =
    4790         659 :                     state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4791             :                 // People Sensible Heat Addition
    4792         659 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtPeoplAdd =
    4793         659 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    4794             :                 // Lights Sensible Heat Addition
    4795         659 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtLiteAdd =
    4796         659 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    4797             :                 // Equipment Sensible Heat Addition
    4798             :                 // Equipment Sensible Heat Removal
    4799             :                 // non-HVAC ZnAirRpt variables DO NOT include zone multipliers
    4800         659 :                 state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    4801         659 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    4802         659 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    4803         659 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    4804         659 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    4805         659 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    4806         659 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    4807         659 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    4808         659 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    4809         659 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    4810         659 :                 if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    4811         273 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipAdd = state.dataOutRptTab->eqpSensGHGR * mult;
    4812         273 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipRem = 0.0;
    4813             :                 } else {
    4814         386 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipAdd = 0.0;
    4815         386 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipRem = state.dataOutRptTab->eqpSensGHGR * mult;
    4816             :                 }
    4817             :                 // Window Heat Addition
    4818             :                 // Window Heat Removal
    4819         659 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindAdd =
    4820         659 :                     state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4821         659 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindRem =
    4822         659 :                     -state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4823             :                 // mixing object heat addition and removal
    4824         659 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    4825           0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaAdd =
    4826           0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4827           0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaRem = 0.0;
    4828             :                 } else {
    4829         659 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaAdd = 0.0;
    4830         659 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaRem =
    4831         659 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4832             :                 }
    4833             :                 // Infiltration Heat Addition
    4834             :                 // Infiltration Heat Removal
    4835         659 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 0.0) {
    4836           0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilAdd =
    4837           0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    4838           0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilRem = 0.0;
    4839             :                 } else {
    4840         659 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilAdd = 0.0;
    4841         659 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilRem =
    4842         659 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    4843             :                 }
    4844             :                 // Opaque Surface Conduction and Other Heat Addition
    4845             :                 // Opaque Surface Conduction and Other Heat Removal
    4846        1318 :                 state.dataOutRptTab->totalGHGR =
    4847         659 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtPeoplAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtLiteAdd +
    4848         659 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacCl +
    4849         659 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaRem +
    4850         659 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindRem +
    4851         659 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilRem +
    4852         659 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipRem +
    4853         659 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfCl;
    4854        1318 :                 state.dataOutRptTab->totalGHGR =
    4855         659 :                     -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    4856         659 :                 if (state.dataOutRptTab->totalGHGR > 0) {
    4857         134 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherAdd = state.dataOutRptTab->totalGHGR;
    4858         134 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherRem = 0.0;
    4859             :                 } else {
    4860         525 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherAdd = 0.0;
    4861         525 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherRem = state.dataOutRptTab->totalGHGR;
    4862             :                 }
    4863             :             }
    4864             :         } else {
    4865      921456 :             if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4866      921456 :                  state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR) +
    4867      921456 :                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) <
    4868      921456 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).clPeak) {
    4869        2024 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).clPeak =
    4870        2024 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4871        2024 :                     state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR) +
    4872        2024 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4873             :                 // determine timestamp
    4874             :                 //      ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    4875             :                 //      ActualtimeE = ActualTimeS+TimeStepSys
    4876             :                 //      ActualTimeHrS=INT(ActualTimeS)
    4877             :                 //      ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    4878        2024 :                 int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    4879        2024 :                 EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    4880        2024 :                                   state.dataEnvrn->Month,
    4881        2024 :                                   state.dataEnvrn->DayOfMonth,
    4882        2024 :                                   state.dataGlobal->HourOfDay,
    4883             :                                   ActualTimeMin);
    4884        2024 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).clPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    4885             :                 // HVAC Input Sensible Air Heating
    4886             :                 // HVAC Input Sensible Air Cooling
    4887        2024 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacHt = 0.0;
    4888        2024 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacCl =
    4889        2024 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4890        2024 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4891             :                 // HVAC Input Heated Surface Heating
    4892             :                 // HVAC Input Cooled Surface Cooling
    4893        2024 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfHt = state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR);
    4894        2024 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfCl = state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR);
    4895             :                 // HVAC heating by ATU at cool peak
    4896             :                 // HVAC cooling by ATU at cool peak
    4897        2024 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacATUHt = state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR);
    4898        2024 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacATUCl = state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    4899             :                 // People Sensible Heat Addition
    4900        2024 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClPeoplAdd =
    4901        2024 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    4902             :                 // Lights Sensible Heat Addition
    4903        2024 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClLiteAdd =
    4904        2024 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    4905             :                 // Equipment Sensible Heat Addition
    4906             :                 // Equipment Sensible Heat Removal
    4907        2024 :                 state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    4908        2024 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    4909        2024 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    4910        2024 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    4911        2024 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    4912        2024 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    4913        2024 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    4914        2024 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    4915        2024 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    4916        2024 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    4917        2024 :                 if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    4918        1843 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipAdd = state.dataOutRptTab->eqpSensGHGR * mult;
    4919        1843 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipRem = 0.0;
    4920             :                 } else {
    4921         181 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipAdd = 0.0;
    4922         181 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipRem = state.dataOutRptTab->eqpSensGHGR * mult;
    4923             :                 }
    4924             :                 // Window Heat Addition
    4925             :                 // Window Heat Removal
    4926        2024 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindAdd =
    4927        2024 :                     state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4928        2024 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindRem =
    4929        2024 :                     -state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4930             :                 // mixing object cool addition and removal
    4931        2024 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    4932           0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaAdd =
    4933           0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4934           0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaRem = 0.0;
    4935             :                 } else {
    4936        2024 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaAdd = 0.0;
    4937        2024 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaRem =
    4938        2024 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4939             :                 }
    4940             :                 // Infiltration Heat Addition
    4941             :                 // Infiltration Heat Removal
    4942        2024 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 0.0) {
    4943          71 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilAdd =
    4944          71 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    4945          71 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilRem = 0.0;
    4946             :                 } else {
    4947        1953 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilAdd = 0.0;
    4948        1953 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilRem =
    4949        1953 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    4950             :                 }
    4951             :                 // Opaque Surface Conduction and Other Heat Addition
    4952             :                 // Opaque Surface Conduction and Other Heat Removal
    4953        4048 :                 state.dataOutRptTab->totalGHGR =
    4954        2024 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClPeoplAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClLiteAdd +
    4955        2024 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacCl +
    4956        2024 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaRem +
    4957        2024 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindRem +
    4958        2024 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilRem +
    4959        2024 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipRem +
    4960        2024 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfCl;
    4961        4048 :                 state.dataOutRptTab->totalGHGR =
    4962        2024 :                     -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    4963        2024 :                 if (state.dataOutRptTab->totalGHGR > 0) {
    4964         294 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherAdd = state.dataOutRptTab->totalGHGR;
    4965         294 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherRem = 0.0;
    4966             :                 } else {
    4967        1730 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherAdd = 0.0;
    4968        1730 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherRem = state.dataOutRptTab->totalGHGR;
    4969             :                 }
    4970             :             }
    4971             :         }
    4972             :     }
    4973             :     //------------------------------------
    4974             :     // BUILDING PEAK COOLING AND HEATING
    4975             :     //------------------------------------
    4976      269645 :     state.dataOutRptTab->bldgHtPk = 0.0;
    4977      269645 :     state.dataOutRptTab->bldgClPk = 0.0;
    4978     1509515 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4979     1239870 :         Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    4980     1239870 :         if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4981     1239870 :              state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4982     1239870 :              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) > 0) {
    4983      636828 :             state.dataOutRptTab->bldgHtPk += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4984      318414 :                                              state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4985      318414 :                                              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4986             :         } else {
    4987     1842912 :             state.dataOutRptTab->bldgClPk += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4988      921456 :                                              state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR) +
    4989      921456 :                                              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4990             :         }
    4991             :     }
    4992      269645 :     if (state.dataOutRptTab->bldgHtPk > state.dataHeatBal->BuildingPreDefRep.htPeak) {
    4993         193 :         state.dataHeatBal->BuildingPreDefRep.htPeak = state.dataOutRptTab->bldgHtPk;
    4994             :         // determine timestamp
    4995             :         //  ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    4996             :         //  ActualtimeE = ActualTimeS+TimeStepSys
    4997             :         //  ActualTimeHrS=INT(ActualTimeS)
    4998             :         //  ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    4999         193 :         int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    5000         193 :         EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    5001         193 :                           state.dataEnvrn->Month,
    5002         193 :                           state.dataEnvrn->DayOfMonth,
    5003         193 :                           state.dataGlobal->HourOfDay,
    5004             :                           ActualTimeMin);
    5005         193 :         state.dataHeatBal->BuildingPreDefRep.htPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    5006             :         // reset building level results to zero prior to accumulating across zones
    5007         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt = 0.0;
    5008         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl = 0.0;
    5009         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt = 0.0;
    5010         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl = 0.0;
    5011         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt = 0.0;
    5012         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl = 0.0;
    5013         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd = 0.0;
    5014         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd = 0.0;
    5015         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd = 0.0;
    5016         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd = 0.0;
    5017         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd = 0.0;
    5018         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd = 0.0;
    5019         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd = 0.0;
    5020         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem = 0.0;
    5021         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem = 0.0;
    5022         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem = 0.0;
    5023         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem = 0.0;
    5024         193 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem = 0.0;
    5025        1087 :         for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    5026         894 :             Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    5027             :             // HVAC Input Sensible Air Heating
    5028             :             // HVAC Input Sensible Air Cooling
    5029         894 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    5030         894 :                                                                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    5031             :             // HVAC Input Heated Surface Heating
    5032             :             // HVAC Input Cooled Surface Cooling
    5033         894 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt += state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR);
    5034         894 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl += state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR);
    5035             :             // HVAC ATU Heating
    5036             :             // HVAC ATU Cooling
    5037         894 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt += state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR);
    5038         894 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl += state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    5039             :             // People Sensible Heat Addition
    5040        1788 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd +=
    5041         894 :                 state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    5042             :             // Lights Sensible Heat Addition
    5043         894 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd += state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    5044             :             // Equipment Sensible Heat Addition
    5045             :             // Equipment Sensible Heat Removal
    5046         894 :             state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    5047         894 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    5048         894 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    5049         894 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    5050         894 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    5051         894 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    5052         894 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    5053         894 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    5054         894 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    5055         894 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    5056         894 :             if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    5057         525 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd += state.dataOutRptTab->eqpSensGHGR * mult;
    5058             :             } else {
    5059         369 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem += state.dataOutRptTab->eqpSensGHGR * mult;
    5060             :             }
    5061             :             // Window Heat Addition
    5062             :             // Window Heat Removal
    5063         894 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd += state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5064         894 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem -= state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5065             :             // mixing object heat addition and removal
    5066         894 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    5067           0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5068             :             } else {
    5069         894 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5070             :             }
    5071             :             // Infiltration Heat Addition
    5072             :             // Infiltration Heat Removal
    5073         894 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 00) {
    5074           0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd +=
    5075           0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5076             :             } else {
    5077         894 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem +=
    5078         894 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5079             :             }
    5080             :         }
    5081             :         // Opaque Surface Conduction and Other Heat Addition
    5082             :         // Opaque Surface Conduction and Other Heat Removal
    5083         193 :         state.dataOutRptTab->totalGHGR = state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd +
    5084         193 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt + state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl +
    5085         193 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem +
    5086         193 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem +
    5087         193 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem +
    5088         193 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem +
    5089         193 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt + state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl;
    5090         386 :         state.dataOutRptTab->totalGHGR =
    5091         193 :             -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    5092         193 :         if (state.dataOutRptTab->totalGHGR > 0) {
    5093          40 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd += state.dataOutRptTab->totalGHGR;
    5094             :         } else {
    5095         153 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem += state.dataOutRptTab->totalGHGR;
    5096             :         }
    5097             :     }
    5098      269645 :     if (state.dataOutRptTab->bldgClPk < state.dataHeatBal->BuildingPreDefRep.clPeak) {
    5099         587 :         state.dataHeatBal->BuildingPreDefRep.clPeak = state.dataOutRptTab->bldgClPk;
    5100             :         // determine timestamp
    5101             :         //  ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    5102             :         //  ActualtimeE = ActualTimeS+TimeStepSys
    5103             :         //  ActualTimeHrS=INT(ActualTimeS)
    5104             :         //  ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    5105         587 :         int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    5106         587 :         EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    5107         587 :                           state.dataEnvrn->Month,
    5108         587 :                           state.dataEnvrn->DayOfMonth,
    5109         587 :                           state.dataGlobal->HourOfDay,
    5110             :                           ActualTimeMin);
    5111         587 :         state.dataHeatBal->BuildingPreDefRep.clPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    5112             :         // reset building level results to zero prior to accumulating across zones
    5113         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt = 0.0;
    5114         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl = 0.0;
    5115         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt = 0.0;
    5116         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl = 0.0;
    5117         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt = 0.0;
    5118         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl = 0.0;
    5119         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd = 0.0;
    5120         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd = 0.0;
    5121         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd = 0.0;
    5122         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd = 0.0;
    5123         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd = 0.0;
    5124         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd = 0.0;
    5125         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd = 0.0;
    5126         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem = 0.0;
    5127         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem = 0.0;
    5128         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem = 0.0;
    5129         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem = 0.0;
    5130         587 :         state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem = 0.0;
    5131        3341 :         for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    5132        2754 :             Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    5133             :             // HVAC Input Sensible Air Heating
    5134             :             // HVAC Input Sensible Air Cooling
    5135        2754 :             state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    5136        2754 :                                                                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    5137             :             // HVAC Input Heated Surface Heating
    5138             :             // HVAC Input Cooled Surface Cooling
    5139        2754 :             state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt += state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR);
    5140        2754 :             state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl += state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR);
    5141             :             // HVAC ATU Heating
    5142             :             // HVAC ATU Cooling
    5143        2754 :             state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt += state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR);
    5144        2754 :             state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl += state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    5145             :             // People Sensible Heat Addition
    5146        5508 :             state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd +=
    5147        2754 :                 state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    5148             :             // Lights Sensible Heat Addition
    5149        2754 :             state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd += state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    5150             :             // Equipment Sensible Heat Addition
    5151             :             // Equipment Sensible Heat Removal
    5152        2754 :             state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    5153        2754 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    5154        2754 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    5155        2754 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    5156        2754 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    5157        2754 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    5158        2754 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    5159        2754 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    5160        2754 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    5161        2754 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    5162        2754 :             if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    5163        2375 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd += state.dataOutRptTab->eqpSensGHGR * mult;
    5164             :             } else {
    5165         379 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem += state.dataOutRptTab->eqpSensGHGR * mult;
    5166             :             }
    5167             :             // Window Heat Addition
    5168             :             // Window Heat Removal
    5169        2754 :             state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd += state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5170        2754 :             state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem -= state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5171             :             // mixing object cool addition and removal
    5172        2754 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    5173           0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5174             :             } else {
    5175        2754 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5176             :             }
    5177             :             // Infiltration Heat Addition
    5178             :             // Infiltration Heat Removal
    5179        2754 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 00) {
    5180         140 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd +=
    5181         140 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5182             :             } else {
    5183        2614 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem +=
    5184        2614 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5185             :             }
    5186             :         }
    5187             :         // Opaque Surface Conduction and Other Heat Addition
    5188             :         // Opaque Surface Conduction and Other Heat Removal
    5189         587 :         state.dataOutRptTab->totalGHGR = state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd +
    5190         587 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt + state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl +
    5191         587 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem +
    5192         587 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem +
    5193         587 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem +
    5194         587 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem +
    5195         587 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt + state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl;
    5196        1174 :         state.dataOutRptTab->totalGHGR =
    5197         587 :             -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    5198         587 :         if (state.dataOutRptTab->totalGHGR > 0) {
    5199          56 :             state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd += state.dataOutRptTab->totalGHGR;
    5200             :         } else {
    5201         531 :             state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem += state.dataOutRptTab->totalGHGR;
    5202             :         }
    5203             :     }
    5204             : }
    5205             : 
    5206             : //======================================================================================================================
    5207             : //======================================================================================================================
    5208             : 
    5209             : //    WRITE OUTPUT FILE ROUTINES
    5210             : 
    5211             : //======================================================================================================================
    5212             : //======================================================================================================================
    5213             : 
    5214         794 : void WriteTabularReports(EnergyPlusData &state)
    5215             : {
    5216             :     // SUBROUTINE INFORMATION:
    5217             :     //       AUTHOR         Jason Glazer
    5218             :     //       DATE WRITTEN   August 2003
    5219             :     //       MODIFIED       January 2021, J. Yuan
    5220             :     //                      Modified to accommodate dual-unit reporting
    5221             :     //       RE-ENGINEERED  na
    5222             : 
    5223             :     // PURPOSE OF THIS SUBROUTINE:
    5224             :     //   This routine hides from the main simulation that four specific
    5225             :     //   types of tabular reports are each created. If another type of
    5226             :     //   report is added it can be added to the list here.
    5227             : 
    5228         794 :     FillWeatherPredefinedEntries(state);
    5229         794 :     FillRemainingPredefinedEntries(state);
    5230         794 :     WaterManager::ReportRainfall(state);
    5231         794 :     auto &ort = state.dataOutRptTab;
    5232             : 
    5233             :     // Here to it is ready to assign ort->unitStyle_SQLite (not in SQLiteProcedures.cc)
    5234             :     // when ort->unitsStyle inputs should have been concretely processed and assigned.
    5235         794 :     if (ort->unitsStyle_SQLite == UnitsStyle::NotFound) {
    5236         794 :         ort->unitsStyle_SQLite = ort->unitsStyle; // This is the default UseOutputControlTableStyles
    5237             :     }
    5238             : 
    5239         794 :     if (ort->WriteTabularFiles) {
    5240             : 
    5241             :         // call each type of report in turn
    5242         754 :         WriteBEPSTable(state);
    5243         754 :         WriteTableOfContents(state);
    5244         754 :         WriteVeriSumTable(state);
    5245         754 :         WriteDemandEndUseSummary(state);
    5246         754 :         WriteSourceEnergyEndUseSummary(state);
    5247         754 :         WriteComponentSizing(state);
    5248         754 :         WriteSurfaceShadowing(state);
    5249         754 :         WriteCompCostTable(state);
    5250         754 :         WriteAdaptiveComfortTable(state);
    5251         754 :         WriteEioTables(state);
    5252         754 :         WriteLoadComponentSummaryTables(state);
    5253         754 :         WriteHeatEmissionTable(state);
    5254             : 
    5255         754 :         if (ort->displayThermalResilienceSummary && !state.dataGlobal->DoPureLoadCalc) // code will crash if pure load calc
    5256         675 :             WriteThermalResilienceTables(state);                                       // code will crash if pure load calc
    5257         754 :         if (ort->displayCO2ResilienceSummary && !state.dataGlobal->DoPureLoadCalc)     // code will crash if pure load calc
    5258          15 :             WriteCO2ResilienceTables(state);                                           // code will crash if pure load calc
    5259         754 :         if (ort->displayVisualResilienceSummary && !state.dataGlobal->DoPureLoadCalc)  // code will crash if pure load calc
    5260          55 :             WriteVisualResilienceTables(state);                                        // code will crash if pure load calc
    5261         754 :         if (state.dataWeather->TotReportPers > 0) WriteReportPeriodTimeConsumption(state);
    5262         759 :         for (int i = 1; i <= state.dataWeather->TotThermalReportPers; i++) {
    5263           5 :             WriteThermalResilienceTablesRepPeriod(state, i);
    5264             :         }
    5265         757 :         for (int i = 1; i <= state.dataWeather->TotCO2ReportPers; i++) {
    5266           3 :             WriteCO2ResilienceTablesRepPeriod(state, i);
    5267             :         }
    5268         757 :         for (int i = 1; i <= state.dataWeather->TotVisualReportPers; i++) {
    5269           3 :             WriteVisualResilienceTablesRepPeriod(state, i);
    5270             :         }
    5271             : 
    5272         754 :         state.dataRptCoilSelection->coilSelectionReportObj->finishCoilSummaryReportTable(
    5273             :             state);                   // call to write out the coil selection summary table data
    5274         754 :         WritePredefinedTables(state); // moved to come after zone load components is finished
    5275             : 
    5276         754 :         if (state.dataGlobal->DoWeathSim) {
    5277           5 :             WriteMonthlyTables(state);
    5278           5 :             WriteTimeBinTables(state);
    5279           5 :             OutputReportTabularAnnual::WriteAnnualTables(state);
    5280             :         }
    5281             :     }
    5282             : 
    5283             :     constexpr static std::string_view variable_fmt = " {}={:12}\n";
    5284             :     constexpr static auto variable_fmt_syntax = check_syntax(variable_fmt); // (AUTO_OK) not sure what this is
    5285         794 :     state.files.audit.ensure_open(state, "WriteTabularReports", state.files.outputControl.audit);
    5286         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyInputCount", ort->MonthlyInputCount);
    5287         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeMonthlyInput", ort->sizeMonthlyInput);
    5288         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyFieldSetInputCount", ort->MonthlyFieldSetInputCount);
    5289         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeMonthlyFieldSetInput", ort->sizeMonthlyFieldSetInput);
    5290         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyTablesCount", ort->MonthlyTablesCount);
    5291         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyColumnsCount", ort->MonthlyColumnsCount);
    5292         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeReportName", state.dataOutRptPredefined->sizeReportName);
    5293         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numReportName", state.dataOutRptPredefined->numReportName);
    5294         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeSubTable", state.dataOutRptPredefined->sizeSubTable);
    5295         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numSubTable", state.dataOutRptPredefined->numSubTable);
    5296         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeColumnTag", state.dataOutRptPredefined->sizeColumnTag);
    5297         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numColumnTag", state.dataOutRptPredefined->numColumnTag);
    5298         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeTableEntry", state.dataOutRptPredefined->sizeTableEntry);
    5299         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numTableEntry", state.dataOutRptPredefined->numTableEntry);
    5300         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeCompSizeTableEntry", state.dataOutRptPredefined->sizeCompSizeTableEntry);
    5301         794 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numCompSizeTableEntry", state.dataOutRptPredefined->numCompSizeTableEntry);
    5302         794 : }
    5303             : 
    5304       11570 : bool produceDualUnitsFlags(const int iUnit_Sys,
    5305             :                            const UnitsStyle unitsStyle_Tab,
    5306             :                            const UnitsStyle unitsStyle_Sql,
    5307             :                            UnitsStyle &unitsStyle_Cur,
    5308             :                            bool &produce_Tab,
    5309             :                            bool &produce_Sql)
    5310             : {
    5311             :     // January 2021:
    5312             :     // PURPOSE OF THIS SUBROUTINE:
    5313             :     // This routine sets the order and flags for tabular data and sqlite writing for a Dual-Unit reporting.
    5314             :     // It will set the unit styles to used, a flag for tabular data writing, and a flag for sqlite writing.
    5315             :     // The function will return a false flag if only a second round of (SQLite) writing is needed
    5316             :     // and will return a true flag if a second round SQLite writing is not needed.
    5317             : 
    5318       11570 :     bool brkflag(false);
    5319             : 
    5320       11570 :     if (iUnit_Sys == 0) {
    5321        5785 :         unitsStyle_Cur = unitsStyle_Tab;
    5322        5785 :         produce_Tab = true;
    5323        5785 :         if (unitsStyle_Sql == unitsStyle_Tab) {
    5324        5785 :             produce_Sql = true;
    5325             :         } else {
    5326           0 :             produce_Sql = false;
    5327             :         }
    5328             :     } else { // iUnit_Sys == 1
    5329        5785 :         unitsStyle_Cur = unitsStyle_Sql;
    5330        5785 :         produce_Tab = false;
    5331        5785 :         produce_Sql = true;
    5332        5785 :         if (unitsStyle_Sql == unitsStyle_Tab) {
    5333             :             // flag true if a separate SQLite round writing is not needed
    5334        5785 :             brkflag = true;
    5335        5785 :             produce_Sql = false;
    5336             :         }
    5337             :     }
    5338             : 
    5339             :     // False if a separate sqlite round is needed;
    5340             :     // true if not
    5341       11570 :     return brkflag;
    5342             : }
    5343             : 
    5344      428256 : void parseStatLine(const std::string &lineIn,
    5345             :                    StatLineType &lineType,
    5346             :                    bool &desConditionlinepassed,
    5347             :                    bool &heatingDesignlinepassed,
    5348             :                    bool &coolingDesignlinepassed,
    5349             :                    bool isKoppen,
    5350             :                    bool &insideLiquidPrecipitation)
    5351             : {
    5352             :     // assumes that all the variables are initialized outside of this routine -- it does not re-initialize them
    5353      428256 :     if (has_prefix(lineIn, "Statistics")) {
    5354         785 :         lineType = StatLineType::StatisticsLine;
    5355      427471 :     } else if (has_prefix(lineIn, "Location")) {
    5356         785 :         lineType = StatLineType::LocationLine;
    5357      426686 :     } else if (has_prefix(lineIn, "{")) {
    5358         785 :         lineType = StatLineType::LatLongLine;
    5359      425901 :     } else if (has_prefix(lineIn, "Elevation")) {
    5360         785 :         lineType = StatLineType::ElevationLine;
    5361      425116 :     } else if (has_prefix(lineIn, "Standard Pressure")) {
    5362         785 :         lineType = StatLineType::StdPressureLine;
    5363      424331 :     } else if (has_prefix(lineIn, "Data Source")) {
    5364         785 :         lineType = StatLineType::DataSourceLine;
    5365      423546 :     } else if (has_prefix(lineIn, "WMO Station")) {
    5366         785 :         lineType = StatLineType::WMOStationLine;
    5367      422761 :     } else if (has(lineIn, "Design Conditions")) {
    5368        1540 :         if (!desConditionlinepassed) {
    5369         785 :             desConditionlinepassed = true;
    5370         785 :             lineType = StatLineType::DesignConditionsLine;
    5371             :         }
    5372      421221 :     } else if (has_prefix(lineIn, "\tHeating")) {
    5373         781 :         if (!heatingDesignlinepassed) {
    5374         781 :             heatingDesignlinepassed = true;
    5375         781 :             lineType = StatLineType::HeatingConditionsLine;
    5376             :         }
    5377      420440 :     } else if (has_prefix(lineIn, "\tCooling")) {
    5378         781 :         if (!coolingDesignlinepassed) {
    5379         781 :             coolingDesignlinepassed = true;
    5380         781 :             lineType = StatLineType::CoolingConditionsLine;
    5381             :         }
    5382      419659 :     } else if (has(lineIn, "(standard) heating degree-days (18.3")) {
    5383         755 :         lineType = StatLineType::StdHDDLine;
    5384      418904 :     } else if (has(lineIn, "(standard) cooling degree-days (10")) {
    5385         755 :         lineType = StatLineType::StdCDDLine;
    5386             : 
    5387      418149 :     } else if (has(lineIn, "Maximum Dry Bulb")) {
    5388         785 :         lineType = StatLineType::MaxDryBulbLine;
    5389      417364 :     } else if (has(lineIn, "Minimum Dry Bulb")) {
    5390         785 :         lineType = StatLineType::MinDryBulbLine;
    5391      416579 :     } else if (has(lineIn, "Maximum Dew Point")) {
    5392         785 :         lineType = StatLineType::MaxDewPointLine;
    5393      415794 :     } else if (has(lineIn, "Minimum Dew Point")) {
    5394         785 :         lineType = StatLineType::MinDewPointLine;
    5395      415009 :     } else if (has(lineIn, "(wthr file) heating degree-days (18") || has(lineIn, "heating degree-days (18")) {
    5396         785 :         lineType = StatLineType::WithHDDLine;
    5397      414224 :     } else if (has(lineIn, "(wthr file) cooling degree-days (10") || has(lineIn, "cooling degree-days (10")) {
    5398         785 :         lineType = StatLineType::WithCDDLine;
    5399             : 
    5400      413439 :     } else if (has(lineIn, "Statistics for Liquid Precipitation")) {
    5401         778 :         insideLiquidPrecipitation = true;
    5402      412661 :     } else if (insideLiquidPrecipitation && has(lineIn, "Total")) {
    5403         778 :         lineType = StatLineType::MonthlyPrec;
    5404      411883 :     } else if (insideLiquidPrecipitation && has(lineIn, "Max Hourly")) {
    5405         759 :         lineType = StatLineType::MaxHourlyPrec;
    5406         759 :         insideLiquidPrecipitation = false;
    5407             :     }
    5408             : 
    5409             :     // these not part of big if/else because sequential
    5410      428256 :     if (lineType == StatLineType::KoppenDes1Line && isKoppen) lineType = StatLineType::KoppenDes2Line;
    5411      428256 :     if (lineType == StatLineType::KoppenLine && isKoppen) lineType = StatLineType::KoppenDes1Line;
    5412      428256 :     if (has(lineIn, "ppen classification)")) lineType = StatLineType::KoppenLine;
    5413      428256 :     if (lineType == StatLineType::AshStdDes2Line) lineType = StatLineType::AshStdDes3Line;
    5414      428256 :     if (lineType == StatLineType::AshStdDes1Line) lineType = StatLineType::AshStdDes2Line;
    5415      428256 :     if (lineType == StatLineType::AshStdLine) lineType = StatLineType::AshStdDes1Line;
    5416      428256 :     if (has(lineIn, "ASHRAE Standard")) lineType = StatLineType::AshStdLine;
    5417      428256 : }
    5418             : 
    5419         794 : void FillWeatherPredefinedEntries(EnergyPlusData &state)
    5420             : {
    5421             :     // SUBROUTINE INFORMATION:
    5422             :     //       AUTHOR         Jason Glazer
    5423             :     //       DATE WRITTEN   Feb 2008
    5424             :     //       MODIFIED       na
    5425             :     //       RE-ENGINEERED  na
    5426             : 
    5427             :     // PURPOSE OF THIS SUBROUTINE:
    5428             :     //   Read the STAT file for the active weather file and summarize in a predefined report.
    5429             :     //   The stat file that is attached may have several formats -- from evolution of the
    5430             :     //   stat file from the weather converter (or others that produce a similar stat file).
    5431             : 
    5432             :     // Using/Aliasing
    5433             :     using namespace OutputReportPredefined;
    5434             : 
    5435             :     // SUBROUTINE PARAMETER DEFINITIONS:
    5436         794 :     static std::string const degChar("°");
    5437             : 
    5438         794 :     if (!FileSystem::fileExists(state.files.inStatFilePath.filePath)) {
    5439           9 :         return;
    5440             :     }
    5441             : 
    5442         785 :     auto const &ort = state.dataOutRptTab;
    5443             : 
    5444             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    5445             : 
    5446         785 :     StatLineType lineTypeinterim = StatLineType::Initialized;
    5447             :     std::string::size_type ashPtr;
    5448             :     std::string::size_type lnPtr;
    5449             :     int col1;
    5450             :     int col2;
    5451             :     int col3;
    5452             :     std::string::size_type sposlt;
    5453             :     std::string::size_type eposlt;
    5454             :     std::string::size_type sposlg;
    5455             :     std::string::size_type eposlg;
    5456             :     std::string::size_type spostz;
    5457             :     std::string::size_type epostz;
    5458         785 :     std::string ashDesYear;
    5459         785 :     std::string ashZone; // ashrae climate zone
    5460         785 :     std::string curNameWithSIUnits;
    5461         785 :     std::string curNameAndUnits;
    5462             :     int indexUnitConv;
    5463             : 
    5464         785 :     bool isASHRAE = false;
    5465         785 :     bool iscalc = false;
    5466         785 :     bool isKoppen = false;
    5467         785 :     bool heatingDesignlinepassed = false;
    5468         785 :     bool coolingDesignlinepassed = false;
    5469         785 :     bool desConditionlinepassed = false;
    5470         785 :     bool insideLiquidPrecipitation = false;
    5471         785 :     std::string storeASHRAEHDD;
    5472         785 :     std::string storeASHRAECDD;
    5473             : 
    5474        1570 :     auto statFile = state.files.inStatFilePath.open(state, "FillWeatherPredefinedEntries");
    5475      429041 :     while (statFile.good()) { // end of file, or error
    5476      428256 :         StatLineType lineType = lineTypeinterim;
    5477      428256 :         auto lineIn = statFile.readLine().data;
    5478             :         // reconcile line with different versions of stat file
    5479             :         // v7.1 added version as first line.
    5480      428256 :         strip(lineIn);
    5481      428256 :         parseStatLine(
    5482             :             lineIn, lineType, desConditionlinepassed, heatingDesignlinepassed, coolingDesignlinepassed, isKoppen, insideLiquidPrecipitation);
    5483             : 
    5484      428256 :         switch (lineType) {
    5485         785 :         case StatLineType::StatisticsLine: { // Statistics for USA_CA_San.Francisco_TMY2
    5486         785 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Reference", lineIn.substr(15));
    5487         785 :         } break;
    5488         785 :         case StatLineType::LocationLine: { // Location -- SAN_FRANCISCO CA USA
    5489         785 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Site:Location", lineIn.substr(11));
    5490         785 :         } break;
    5491         785 :         case StatLineType::LatLongLine: { //      {N 37° 37'} {W 122° 22'} {GMT -8.0 Hours}
    5492             :             // find the {}
    5493         785 :             sposlt = index(lineIn, '{');
    5494         785 :             eposlt = index(lineIn, '}');
    5495         785 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5496         785 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Latitude", lineIn.substr(sposlt, eposlt - sposlt + 1));
    5497             :                 // redefine so next scan can go with {}
    5498         785 :                 lineIn[sposlt] = '[';
    5499         785 :                 lineIn[eposlt] = ']';
    5500             :             } else {
    5501           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Latitude", "not found");
    5502             :             }
    5503         785 :             sposlg = index(lineIn, '{');
    5504         785 :             eposlg = index(lineIn, '}');
    5505         785 :             if (sposlg != std::string::npos && eposlg != std::string::npos) {
    5506         785 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Longitude", lineIn.substr(sposlg, eposlg - sposlg + 1));
    5507             :                 // redefine so next scan can go with {}
    5508         785 :                 lineIn[sposlg] = '[';
    5509         785 :                 lineIn[eposlg] = ']';
    5510             :             } else {
    5511           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Longitude", "not found");
    5512             :             }
    5513         785 :             spostz = index(lineIn, '{');
    5514         785 :             epostz = index(lineIn, '}');
    5515         785 :             if (spostz != std::string::npos && epostz != std::string::npos) {
    5516         785 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Time Zone", lineIn.substr(spostz, epostz - spostz + 1));
    5517             :                 // redefine so next scan can go with {}
    5518         785 :                 lineIn[spostz] = '[';
    5519         785 :                 lineIn[epostz] = ']';
    5520             :             } else {
    5521           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Time Zone", "not found");
    5522             :             }
    5523         785 :         } break;
    5524         785 :         case StatLineType::ElevationLine: { // Elevation --     5m above sea level
    5525         785 :             lnPtr = index(lineIn.substr(12), 'm');
    5526         785 :             if (lnPtr != std::string::npos) {
    5527         785 :                 curNameWithSIUnits = "Elevation (m) " + lineIn.substr(12 + lnPtr + 2);
    5528         785 :                 if (ort->ip()) {
    5529          11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5530          22 :                     PreDefTableEntry(state,
    5531          11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5532             :                                      curNameAndUnits,
    5533          22 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(12, lnPtr))), 1));
    5534             :                 } else {
    5535         774 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, curNameWithSIUnits, lineIn.substr(12, lnPtr));
    5536             :                 }
    5537             :             } else {
    5538           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Elevation", "not found");
    5539             :             }
    5540         785 :         } break;
    5541         785 :         case StatLineType::StdPressureLine: { // Standard Pressure at Elevation -- 101265Pa
    5542         785 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Standard Pressure at Elevation", lineIn.substr(34));
    5543         785 :         } break;
    5544         785 :         case StatLineType::DataSourceLine: { // Data Source -- TMY2-23234
    5545         785 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Data Source", lineIn.substr(15));
    5546         785 :         } break;
    5547         785 :         case StatLineType::WMOStationLine: { // WMO Station 724940
    5548         785 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "WMO Station", lineIn.substr(12));
    5549         785 :         } break;
    5550         785 :         case StatLineType::DesignConditionsLine: { //  - Using Design Conditions from "Climate Design Data 2005 ASHRAE Handbook"
    5551         785 :             ashPtr = index(lineIn, "ASHRAE");
    5552         785 :             if (ashPtr != std::string::npos) {
    5553         781 :                 isASHRAE = true;
    5554         781 :                 iscalc = true;
    5555         781 :                 if (ashPtr > 4u) { // Autodesk:BoundsViolation IF block added to protect against ashPtr<=5
    5556         781 :                     ashDesYear = lineIn.substr(ashPtr - 5, 5);
    5557             :                 } else {
    5558           0 :                     ashDesYear = "";
    5559             :                 }
    5560        1562 :                 PreDefTableEntry(state,
    5561         781 :                                  state.dataOutRptPredefined->pdchWthrVal,
    5562             :                                  "Weather File Design Conditions",
    5563        1562 :                                  "Climate Design Data " + ashDesYear + "ASHRAE Handbook");
    5564           4 :             } else if (has(lineIn, "not calculated") || lineIn == "") {
    5565           0 :                 iscalc = false;
    5566           0 :                 PreDefTableEntry(
    5567           0 :                     state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Design Conditions", "not calculated, Number of days < 1 year");
    5568             :             } else {
    5569           4 :                 isASHRAE = false;
    5570           4 :                 iscalc = true;
    5571           8 :                 PreDefTableEntry(
    5572           4 :                     state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Design Conditions", "Calculated from the weather file");
    5573             :             }
    5574         785 :         } break;
    5575         781 :         case StatLineType::HeatingConditionsLine: { //  winter/heating design conditions
    5576         781 :             if (iscalc) {
    5577         781 :                 if (isASHRAE) {
    5578         781 :                     if (ashDesYear == "2001") {
    5579           0 :                         if (ort->ip()) {
    5580           0 :                             curNameWithSIUnits = "Heating Design Temperature 99.6% (C)";
    5581           0 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5582           0 :                             PreDefTableEntry(state,
    5583           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5584             :                                              curNameAndUnits,
    5585           0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 2))), 1) + degChar);
    5586           0 :                             PreDefTableEntry(state,
    5587           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5588             :                                              "Heating Design Temperature 99% (F)",
    5589           0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 3))), 1) + degChar);
    5590             :                         } else {
    5591           0 :                             PreDefTableEntry(state,
    5592           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5593             :                                              "Heating Design Temperature 99.6% (C)",
    5594           0 :                                              GetColumnUsingTabs(lineIn, 2) + degChar);
    5595           0 :                             PreDefTableEntry(state,
    5596           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5597             :                                              "Heating Design Temperature 99% (C)",
    5598           0 :                                              GetColumnUsingTabs(lineIn, 3) + degChar);
    5599             :                         }
    5600             :                     } else { // 2005 and 2009 are the same
    5601         781 :                         if (ort->ip()) {
    5602          11 :                             curNameWithSIUnits = "Heating Design Temperature 99.6% (C)";
    5603          11 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5604          22 :                             PreDefTableEntry(state,
    5605          11 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5606             :                                              curNameAndUnits,
    5607          22 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 4))), 1) + degChar);
    5608          22 :                             PreDefTableEntry(state,
    5609          11 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5610             :                                              "Heating Design Temperature 99% (F)",
    5611          22 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 5))), 1) + degChar);
    5612             :                         } else {
    5613        1540 :                             PreDefTableEntry(state,
    5614         770 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5615             :                                              "Heating Design Temperature 99.6% (C)",
    5616        1540 :                                              GetColumnUsingTabs(lineIn, 4) + degChar);
    5617        1540 :                             PreDefTableEntry(state,
    5618         770 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5619             :                                              "Heating Design Temperature 99% (C)",
    5620        1540 :                                              GetColumnUsingTabs(lineIn, 5) + degChar);
    5621             :                         }
    5622             :                     }
    5623             :                 } else { // from weather file
    5624           0 :                     if (is_blank(GetColumnUsingTabs(lineIn, 5))) {
    5625           0 :                         col1 = 3;
    5626           0 :                         col2 = 4;
    5627             :                     } else {
    5628           0 :                         col1 = 4;
    5629           0 :                         col2 = 5;
    5630             :                     }
    5631           0 :                     if (ort->ip()) {
    5632           0 :                         curNameWithSIUnits = "Heating Design Temperature 99.6% (C)";
    5633           0 :                         LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5634           0 :                         PreDefTableEntry(state,
    5635           0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5636             :                                          curNameAndUnits,
    5637           0 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col1))), 1) + degChar);
    5638           0 :                         PreDefTableEntry(state,
    5639           0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5640             :                                          "Heating Design Temperature 99% (F)",
    5641           0 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col2))), 1) + degChar);
    5642             :                     } else {
    5643           0 :                         PreDefTableEntry(state,
    5644           0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5645             :                                          "Heating Design Temperature 99.6% (C)",
    5646           0 :                                          GetColumnUsingTabs(lineIn, col1) + degChar);
    5647           0 :                         PreDefTableEntry(state,
    5648           0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5649             :                                          "Heating Design Temperature 99% (C)",
    5650           0 :                                          GetColumnUsingTabs(lineIn, col2) + degChar);
    5651             :                     }
    5652             :                 }
    5653             :             }
    5654         781 :         } break;
    5655         781 :         case StatLineType::CoolingConditionsLine: { //  summer/cooling design conditions
    5656         781 :             if (iscalc) {
    5657         781 :                 if (isASHRAE) {
    5658         781 :                     if (ashDesYear == "2001") {
    5659           0 :                         if (ort->ip()) {
    5660           0 :                             curNameWithSIUnits = "Cooling Design Temperature 0.4% (C)";
    5661           0 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5662           0 :                             PreDefTableEntry(state,
    5663           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5664             :                                              curNameAndUnits,
    5665           0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 2))), 1) + degChar);
    5666           0 :                             PreDefTableEntry(state,
    5667           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5668             :                                              "Cooling Design Temperature 1% (F)",
    5669           0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 4))), 1) + degChar);
    5670           0 :                             PreDefTableEntry(state,
    5671           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5672             :                                              "Cooling Design Temperature 2% (F)",
    5673           0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 6))), 1) + degChar);
    5674             :                         } else {
    5675           0 :                             PreDefTableEntry(state,
    5676           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5677             :                                              "Cooling Design Temperature 0.4% (C)",
    5678           0 :                                              GetColumnUsingTabs(lineIn, 2) + degChar);
    5679           0 :                             PreDefTableEntry(state,
    5680           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5681             :                                              "Cooling Design Temperature 1% (C)",
    5682           0 :                                              GetColumnUsingTabs(lineIn, 4) + degChar);
    5683           0 :                             PreDefTableEntry(state,
    5684           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5685             :                                              "Cooling Design Temperature 2% (C)",
    5686           0 :                                              GetColumnUsingTabs(lineIn, 6) + degChar);
    5687             :                         }
    5688             :                     } else { // 2005 and 2009 are the same
    5689         781 :                         if (ort->ip()) {
    5690          11 :                             curNameWithSIUnits = "Cooling Design Temperature 0.4% (C)";
    5691          11 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5692          22 :                             PreDefTableEntry(state,
    5693          11 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5694             :                                              curNameAndUnits,
    5695          22 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 5))), 1) + degChar);
    5696          22 :                             PreDefTableEntry(state,
    5697          11 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5698             :                                              "Cooling Design Temperature 1% (F)",
    5699          22 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 7))), 1) + degChar);
    5700          22 :                             PreDefTableEntry(state,
    5701          11 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5702             :                                              "Cooling Design Temperature 2% (F)",
    5703          22 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 9))), 1) + degChar);
    5704             :                         } else {
    5705        1540 :                             PreDefTableEntry(state,
    5706         770 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5707             :                                              "Cooling Design Temperature 0.4% (C)",
    5708        1540 :                                              GetColumnUsingTabs(lineIn, 5) + degChar);
    5709        1540 :                             PreDefTableEntry(state,
    5710         770 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5711             :                                              "Cooling Design Temperature 1% (C)",
    5712        1540 :                                              GetColumnUsingTabs(lineIn, 7) + degChar);
    5713        1540 :                             PreDefTableEntry(state,
    5714         770 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5715             :                                              "Cooling Design Temperature 2% (C)",
    5716        1540 :                                              GetColumnUsingTabs(lineIn, 9) + degChar);
    5717             :                         }
    5718             :                     }
    5719             :                 } else { // from weather file
    5720           0 :                     if (is_blank(GetColumnUsingTabs(lineIn, 6))) {
    5721           0 :                         col1 = 3;
    5722           0 :                         col2 = 4;
    5723           0 :                         col3 = 5;
    5724             :                     } else {
    5725           0 :                         col1 = 4;
    5726           0 :                         col2 = 5;
    5727           0 :                         col3 = 6;
    5728             :                     }
    5729           0 :                     if (ort->ip()) {
    5730           0 :                         curNameWithSIUnits = "Cooling Design Temperature 0.4% (C)";
    5731           0 :                         LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5732           0 :                         PreDefTableEntry(state,
    5733           0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5734             :                                          curNameAndUnits,
    5735           0 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col1))), 1) + degChar);
    5736           0 :                         PreDefTableEntry(state,
    5737           0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5738             :                                          "Cooling Design Temperature 1% (F)",
    5739           0 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col2))), 1) + degChar);
    5740           0 :                         PreDefTableEntry(state,
    5741           0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5742             :                                          "Cooling Design Temperature 2% (F)",
    5743           0 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col3))), 1) + degChar);
    5744             :                     } else {
    5745           0 :                         PreDefTableEntry(state,
    5746           0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5747             :                                          "Cooling Design Temperature 0.4% (C)",
    5748           0 :                                          GetColumnUsingTabs(lineIn, col1) + degChar);
    5749           0 :                         PreDefTableEntry(state,
    5750           0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5751             :                                          "Cooling Design Temperature 1% (C)",
    5752           0 :                                          GetColumnUsingTabs(lineIn, col2) + degChar);
    5753           0 :                         PreDefTableEntry(state,
    5754           0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5755             :                                          "Cooling Design Temperature 2% (C)",
    5756           0 :                                          GetColumnUsingTabs(lineIn, col3) + degChar);
    5757             :                     }
    5758             :                 }
    5759             :             }
    5760         781 :         } break;
    5761         755 :         case StatLineType::StdHDDLine: { //  - 1745 annual (standard) heating degree-days (10°C baseline)
    5762         755 :             storeASHRAEHDD = lineIn.substr(2, 4);
    5763         755 :         } break;
    5764         755 :         case StatLineType::StdCDDLine: { //  -  464 annual (standard) cooling degree-days (18.3°C baseline)
    5765         755 :             storeASHRAECDD = lineIn.substr(2, 4);
    5766         755 :         } break;
    5767         785 :         case StatLineType::MaxDryBulbLine: { //   - Maximum Dry Bulb temperature of  35.6°C on Jul  9
    5768         785 :             sposlt = index(lineIn, "of");
    5769         785 :             eposlt = index(lineIn, 'C');
    5770         785 :             sposlt += 2;
    5771         785 :             size_t deg_index = index(lineIn, degChar);
    5772         785 :             if (deg_index != std::string::npos) {
    5773           0 :                 eposlt = deg_index - 1;
    5774             :             } else {
    5775         785 :                 eposlt -= 2;
    5776             :             }
    5777         785 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5778         785 :                 if (ort->ip()) {
    5779          11 :                     curNameWithSIUnits = "Maximum Dry Bulb Temperature (C)";
    5780          11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5781          22 :                     PreDefTableEntry(state,
    5782          11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5783             :                                      curNameAndUnits,
    5784          22 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5785             :                 } else {
    5786        1548 :                     PreDefTableEntry(state,
    5787         774 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5788             :                                      "Maximum Dry Bulb Temperature (C)",
    5789        1548 :                                      lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5790             :                 }
    5791             :             } else {
    5792           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dry Bulb Temperature", "not found");
    5793             :             }
    5794         785 :             sposlt = index(lineIn, "on");
    5795         785 :             sposlt += 2;
    5796         785 :             if (sposlt != std::string::npos) {
    5797         785 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dry Bulb Occurs on", lineIn.substr(sposlt));
    5798             :             } else {
    5799           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dry Bulb Occurs on", "not found");
    5800             :             }
    5801         785 :         } break;
    5802         785 :         case StatLineType::MinDryBulbLine: { //   - Minimum Dry Bulb temperature of -22.8°C on Jan  7
    5803         785 :             sposlt = index(lineIn, "of");
    5804         785 :             eposlt = index(lineIn, 'C');
    5805         785 :             sposlt += 2;
    5806         785 :             size_t deg_index = index(lineIn, degChar);
    5807         785 :             if (deg_index != std::string::npos) {
    5808           0 :                 eposlt = deg_index - 1;
    5809             :             } else {
    5810         785 :                 eposlt -= 2;
    5811             :             }
    5812         785 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5813         785 :                 if (ort->ip()) {
    5814          11 :                     curNameWithSIUnits = "Minimum Dry Bulb Temperature (C)";
    5815          11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5816          22 :                     PreDefTableEntry(state,
    5817          11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5818             :                                      curNameAndUnits,
    5819          22 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5820             :                 } else {
    5821        1548 :                     PreDefTableEntry(state,
    5822         774 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5823             :                                      "Minimum Dry Bulb Temperature (C)",
    5824        1548 :                                      lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5825             :                 }
    5826             :             } else {
    5827           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dry Bulb Temperature", "not found");
    5828             :             }
    5829         785 :             sposlt = index(lineIn, "on");
    5830         785 :             sposlt += 2;
    5831         785 :             if (sposlt != std::string::npos) {
    5832         785 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dry Bulb Occurs on", lineIn.substr(sposlt));
    5833             :             } else {
    5834           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dry Bulb Occurs on", "not found");
    5835             :             }
    5836         785 :         } break;
    5837         785 :         case StatLineType::MaxDewPointLine: { //   - Maximum Dew Point temperature of  25.6°C on Aug  4
    5838         785 :             sposlt = index(lineIn, "of");
    5839         785 :             eposlt = index(lineIn, 'C');
    5840         785 :             sposlt += 2;
    5841         785 :             size_t deg_index = index(lineIn, degChar);
    5842         785 :             if (deg_index != std::string::npos) {
    5843           0 :                 eposlt = deg_index - 1;
    5844             :             } else {
    5845         785 :                 eposlt -= 2;
    5846             :             }
    5847         785 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5848         785 :                 if (ort->ip()) {
    5849          11 :                     curNameWithSIUnits = "Maximum Dew Point Temperature (C)";
    5850          11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5851          22 :                     PreDefTableEntry(state,
    5852          11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5853             :                                      curNameAndUnits,
    5854          22 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5855             :                 } else {
    5856        1548 :                     PreDefTableEntry(state,
    5857         774 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5858             :                                      "Maximum Dew Point Temperature (C)",
    5859        1548 :                                      lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5860             :                 }
    5861             :             } else {
    5862           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dew Point Temperature", "not found");
    5863             :             }
    5864         785 :             sposlt = index(lineIn, "on");
    5865         785 :             sposlt += 2;
    5866         785 :             if (sposlt != std::string::npos) {
    5867         785 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dew Point Occurs on", lineIn.substr(sposlt));
    5868             :             } else {
    5869           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dew Point Occurs on", "not found");
    5870             :             }
    5871         785 :         } break;
    5872         785 :         case StatLineType::MinDewPointLine: { //   - Minimum Dew Point temperature of -28.9°C on Dec 31
    5873         785 :             sposlt = index(lineIn, "of");
    5874         785 :             eposlt = index(lineIn, 'C');
    5875         785 :             sposlt += 2;
    5876         785 :             size_t deg_index = index(lineIn, degChar);
    5877         785 :             if (deg_index != std::string::npos) {
    5878           0 :                 eposlt = deg_index - 1;
    5879             :             } else {
    5880         785 :                 eposlt -= 2;
    5881             :             }
    5882         785 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5883         785 :                 if (ort->ip()) {
    5884          11 :                     curNameWithSIUnits = "Minimum Dew Point Temperature (C)";
    5885          11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5886          22 :                     PreDefTableEntry(state,
    5887          11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5888             :                                      curNameAndUnits,
    5889          22 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5890             :                 } else {
    5891        1548 :                     PreDefTableEntry(state,
    5892         774 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5893             :                                      "Minimum Dew Point Temperature (C)",
    5894        1548 :                                      lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5895             :                 }
    5896             :             } else {
    5897           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dew Point Temperature", "not found");
    5898             :             }
    5899         785 :             sposlt = index(lineIn, "on");
    5900         785 :             sposlt += 2;
    5901         785 :             if (sposlt != std::string::npos) {
    5902         785 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dew Point Occurs on", lineIn.substr(sposlt));
    5903             :             } else {
    5904           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dew Point Occurs on", "not found");
    5905             :             }
    5906         785 :         } break;
    5907         778 :         case StatLineType::MonthlyPrec: { //   - Monthly precipitation mm
    5908         778 :             std::stringstream ss(lineIn);
    5909         778 :             std::vector<std::string> result;
    5910       12448 :             while (ss.good()) {
    5911       11670 :                 std::string substr;
    5912       11670 :                 getline(ss, substr, '\t');
    5913       11670 :                 substr.erase(remove_if(substr.begin(), substr.end(), isspace), substr.end());
    5914       11670 :                 result.push_back(substr);
    5915       11670 :             }
    5916             :             int monthlyTotalPrecFromStat[12];
    5917         778 :             int annualTotalPrecFromStat = 0;
    5918       10114 :             for (int i = 0; i < 12; i++) {
    5919        9336 :                 monthlyTotalPrecFromStat[i] = std::stoi(result[i + 2]);
    5920             :                 // fixme: add to monthly data structure
    5921        9336 :                 annualTotalPrecFromStat += monthlyTotalPrecFromStat[i];
    5922             :             }
    5923         778 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Annual Total Precipitation [mm]", annualTotalPrecFromStat);
    5924             :             // fixme: store the monthly data in some data structure
    5925         778 :         } break;
    5926         759 :         case StatLineType::MaxHourlyPrec: { //   - Highest hourly precipitation in each month
    5927             :             // Split string by \t into substrings and remove the space in each substring
    5928         759 :             std::stringstream ss(lineIn);
    5929         759 :             std::vector<std::string> result;
    5930       12144 :             while (ss.good()) {
    5931       11385 :                 std::string substr;
    5932       11385 :                 getline(ss, substr, '\t');
    5933       11385 :                 substr.erase(remove_if(substr.begin(), substr.end(), isspace), substr.end());
    5934       11385 :                 result.push_back(substr);
    5935       11385 :             }
    5936             :             int MaxHourlyPrecEachMonth[12];
    5937         759 :             int MaxHourlyPrec = 0;
    5938         759 :             int MaxHourlyPrecIdx = 0;
    5939        9867 :             for (int i = 0; i < 12; i++) {
    5940        9108 :                 MaxHourlyPrecEachMonth[i] = std::stoi(result[i + 2]);
    5941        9108 :                 if (MaxHourlyPrecEachMonth[i] > MaxHourlyPrec) {
    5942        1148 :                     MaxHourlyPrec = MaxHourlyPrecEachMonth[i];
    5943        1148 :                     MaxHourlyPrecIdx = i;
    5944             :                 }
    5945             :             }
    5946         759 :             constexpr std::array<std::string_view, 12> Months{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
    5947         759 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Max Hourly Precipitation [mm]", MaxHourlyPrec);
    5948         759 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Max Hourly Precipitation Occurs in", Months[MaxHourlyPrecIdx]);
    5949         759 :         } break;
    5950         785 :         case StatLineType::WithHDDLine: { //  - 1745 (wthr file) annual heating degree-days (10°C baseline)
    5951         785 :             if (storeASHRAEHDD != "") {
    5952         755 :                 if (ort->ip()) {
    5953          11 :                     curNameWithSIUnits = "ASHRAE Handbook 2009 Heating Degree-Days - base 65°(C)";
    5954          11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5955          22 :                     PreDefTableEntry(state,
    5956          11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5957             :                                      curNameAndUnits,
    5958          22 :                                      RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(storeASHRAEHDD)), 1));
    5959             :                 } else {
    5960        1488 :                     PreDefTableEntry(
    5961         744 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009 Heating Degree-Days (base 18.3°C)", storeASHRAEHDD);
    5962             :                 }
    5963             :             } else {
    5964          30 :                 if (ort->ip()) {
    5965           0 :                     PreDefTableEntry(
    5966           0 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009 Heating Degree-Days (base 65°F)", "not found");
    5967             :                 } else {
    5968          60 :                     PreDefTableEntry(
    5969          30 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009 Heating Degree-Days (base 18.3°C)", "not found");
    5970             :                 }
    5971             :             }
    5972         785 :             if (ort->ip()) {
    5973          11 :                 curNameWithSIUnits = "Weather File Heating Degree-Days - base 65°(C)";
    5974          11 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5975          22 :                 PreDefTableEntry(state,
    5976          11 :                                  state.dataOutRptPredefined->pdchWthrVal,
    5977             :                                  curNameAndUnits,
    5978          22 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    5979          22 :                 PreDefTableEntry(state,
    5980          11 :                                  state.dataOutRptPredefined->pdchLeedGenData,
    5981             :                                  "Heating Degree Days",
    5982          22 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    5983             :             } else {
    5984         774 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Heating Degree-Days (base 18°C)", lineIn.substr(2, 4));
    5985         774 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Heating Degree Days", lineIn.substr(2, 4));
    5986             :             }
    5987         785 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "HDD and CDD data source", "Weather File Stat");
    5988         785 :         } break;
    5989         785 :         case StatLineType::WithCDDLine: { //  -  464 (wthr file) annual cooling degree-days (18°C baseline)
    5990         785 :             if (storeASHRAECDD != "") {
    5991         755 :                 if (ort->ip()) {
    5992          11 :                     curNameWithSIUnits = "ASHRAE Handbook 2009  Cooling Degree-Days - base 50°(C)";
    5993          11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5994          22 :                     PreDefTableEntry(state,
    5995          11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5996             :                                      curNameAndUnits,
    5997          22 :                                      RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(storeASHRAECDD)), 1));
    5998             :                 } else {
    5999        1488 :                     PreDefTableEntry(
    6000         744 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009  Cooling Degree-Days (base 10°C)", storeASHRAECDD);
    6001             :                 }
    6002             :             } else {
    6003          30 :                 if (ort->ip()) {
    6004           0 :                     PreDefTableEntry(
    6005           0 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009  Cooling Degree-Days (base 50°F)", "not found");
    6006             :                 } else {
    6007          60 :                     PreDefTableEntry(
    6008          30 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009  Cooling Degree-Days (base 10°C)", "not found");
    6009             :                 }
    6010             :             }
    6011         785 :             if (ort->ip()) {
    6012          11 :                 curNameWithSIUnits = "Weather File Cooling Degree-Days - base 50°(C)";
    6013          11 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    6014          22 :                 PreDefTableEntry(state,
    6015          11 :                                  state.dataOutRptPredefined->pdchWthrVal,
    6016             :                                  curNameAndUnits,
    6017          22 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    6018          22 :                 PreDefTableEntry(state,
    6019          11 :                                  state.dataOutRptPredefined->pdchLeedGenData,
    6020             :                                  "Cooling Degree Days",
    6021          22 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    6022             :             } else {
    6023         774 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Cooling Degree-Days (base 10°C)", lineIn.substr(2, 4));
    6024         774 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Cooling Degree Days", lineIn.substr(2, 4));
    6025             :             }
    6026         785 :         } break;
    6027         785 :         case StatLineType::KoppenLine: { // - Climate type "BSk" (Köppen classification)
    6028         785 :             if (!has(lineIn, "not shown")) {
    6029         785 :                 isKoppen = true;
    6030         785 :                 if (lineIn[18] == '"') { // two character classification
    6031          65 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Classification", lineIn.substr(16, 2));
    6032             :                 } else {
    6033         720 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Classification", lineIn.substr(16, 3));
    6034             :                 }
    6035             :             } else {
    6036           0 :                 isKoppen = false;
    6037           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", lineIn.substr(2));
    6038             :             }
    6039         785 :         } break;
    6040         785 :         case StatLineType::KoppenDes1Line: { // - Tropical monsoonal or tradewind-coastal (short dry season, lat. 5-25°)
    6041         785 :             if (isKoppen) {
    6042         785 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Description", lineIn.substr(2));
    6043             :             }
    6044         785 :         } break;
    6045         785 :         case StatLineType::KoppenDes2Line: { // - Unbearably humid periods in summer, but passive cooling is possible
    6046         785 :             if (isKoppen) {
    6047         785 :                 if (len(lineIn) > 3) {                 // avoid blank lines
    6048         785 :                     if (lineIn.substr(2, 2) != "**") { // avoid line with warning
    6049         636 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", lineIn.substr(2));
    6050             :                     } else {
    6051         149 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", "");
    6052             :                     }
    6053             :                 } else {
    6054           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", "");
    6055             :                 }
    6056             :             }
    6057         785 :         } break;
    6058        3140 :         case StatLineType::AshStdLine:
    6059             :         case StatLineType::AshStdDes1Line:
    6060             :         case StatLineType::AshStdDes2Line:
    6061             :         case StatLineType::AshStdDes3Line: {
    6062             :             //  - Climate type "1A" (ASHRAE Standards 90.1-2004 and 90.2-2004 Climate Zone)**
    6063        3140 :             if (has(lineIn, "Standard")) {
    6064         785 :                 ashZone = lineIn.substr(16, 2);
    6065         785 :                 if (ashZone[1] == '"') ashZone[1] = ' ';
    6066         785 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Climate Zone", ashZone);
    6067         785 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Climate Zone", ashZone);
    6068         785 :                 if (ashZone == "1A") {
    6069          65 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Very Hot-Humid");
    6070         720 :                 } else if (ashZone == "1B") {
    6071          23 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Very Hot-Dry");
    6072         697 :                 } else if (ashZone == "2A") {
    6073           8 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Hot-Humid");
    6074         689 :                 } else if (ashZone == "2B") {
    6075           3 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Hot-Dry");
    6076         686 :                 } else if (ashZone == "3A") {
    6077           4 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Warm-Humid");
    6078         682 :                 } else if (ashZone == "3B") {
    6079           3 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Warm-Dry");
    6080         679 :                 } else if (ashZone == "3C") {
    6081          10 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Warm-Marine");
    6082         669 :                 } else if (ashZone == "4A") {
    6083           1 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Mixed-Humid");
    6084         668 :                 } else if (ashZone == "4B") {
    6085           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Mixed-Dry");
    6086         668 :                 } else if (ashZone == "4C") {
    6087           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Mixed-Marine");
    6088         668 :                 } else if (ashZone == "5A") {
    6089         586 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cool-Humid");
    6090          82 :                 } else if (ashZone == "5B") {
    6091          82 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cool-Dry");
    6092           0 :                 } else if (ashZone == "5C") {
    6093           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cool-Marine");
    6094           0 :                 } else if (ashZone == "6A") {
    6095           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cold-Humid");
    6096           0 :                 } else if (ashZone == "6B") {
    6097           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cold-Dry");
    6098           0 :                 } else if (ashZone == "7 ") {
    6099           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Very Cold");
    6100           0 :                 } else if (ashZone == "8 ") {
    6101           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Subarctic");
    6102             :                 }
    6103             :             }
    6104        3140 :         } break;
    6105      407162 :         default:
    6106      407162 :             break;
    6107             :         }
    6108      428256 :         lineIn = "";
    6109      428256 :         lineTypeinterim = StatLineType::Initialized;
    6110      428256 :         if (lineType == StatLineType::AshStdDes3Line) lineTypeinterim = StatLineType::Initialized;
    6111      428256 :         if (lineType == StatLineType::AshStdDes2Line) lineTypeinterim = StatLineType::AshStdDes2Line;
    6112      428256 :         if (lineType == StatLineType::AshStdDes1Line) lineTypeinterim = StatLineType::AshStdDes1Line;
    6113      428256 :         if (lineType == StatLineType::AshStdLine) lineTypeinterim = StatLineType::AshStdLine;
    6114      428256 :         if (lineType == StatLineType::KoppenDes2Line) lineTypeinterim = StatLineType::Initialized;
    6115      428256 :         if (lineType == StatLineType::KoppenDes1Line) lineTypeinterim = StatLineType::KoppenDes1Line;
    6116      428256 :         if (lineType == StatLineType::KoppenLine) lineTypeinterim = StatLineType::KoppenLine;
    6117      428256 :     }
    6118         785 : }
    6119             : 
    6120        3965 : std::string GetColumnUsingTabs(std::string const &inString, // Input String
    6121             :                                int const colNum             // Column number
    6122             : )
    6123             : {
    6124             :     // SUBROUTINE INFORMATION:
    6125             :     //       AUTHOR         Jason Glazer
    6126             :     //       DATE WRITTEN   March 2008
    6127             :     //       MODIFIED       na
    6128             :     //       RE-ENGINEERED  na
    6129             : 
    6130             :     // PURPOSE OF THIS SUBROUTINE:
    6131             :     //   Assumes that the input string contains tabs that mark the
    6132             :     //   separation between columns. Returns the string that appears
    6133             :     //   in the column specified.
    6134             : 
    6135             :     // SUBROUTINE PARAMETER DEFINITIONS:
    6136             :     static char const tb('\t'); // tab character
    6137             : 
    6138             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    6139        3965 :     std::string::size_type startPos = 0;
    6140             : 
    6141        3965 :     size_t endPos = inString.find_first_of(tb);
    6142        3965 :     if (colNum == 1) {
    6143           0 :         if (endPos == std::string::npos) return inString;
    6144           0 :         return inString.substr(startPos, endPos - startPos);
    6145             :     }
    6146        3965 :     if (endPos == std::string::npos) return "";
    6147             : 
    6148        3965 :     int numCols = 1;
    6149       23940 :     while (numCols < colNum) {
    6150       19975 :         startPos = endPos + 1;
    6151       19975 :         endPos = inString.find_first_of(tb, startPos);
    6152       19975 :         ++numCols;
    6153       19975 :         if (endPos == std::string::npos) break;
    6154             :     }
    6155        3965 :     if (colNum > numCols) return "";
    6156        3965 :     if (endPos == std::string::npos) endPos = inString.size();
    6157        3965 :     return inString.substr(startPos, endPos - startPos);
    6158             : }
    6159             : 
    6160         794 : void FillRemainingPredefinedEntries(EnergyPlusData &state)
    6161             : {
    6162             :     // SUBROUTINE INFORMATION:
    6163             :     //       AUTHOR         Jason Glazer
    6164             :     //       DATE WRITTEN   May 2007
    6165             :     //       MODIFIED       na
    6166             :     //       RE-ENGINEERED  na
    6167             : 
    6168             :     // PURPOSE OF THIS SUBROUTINE:
    6169             :     //   Just before writing the output reports, will gather up
    6170             :     //   any additional report entries for the predefined reports.
    6171             : 
    6172             :     // Using/Aliasing
    6173         794 :     int NumPrimaryAirSys = state.dataHVACGlobal->NumPrimaryAirSys;
    6174         794 :     int iNumberOfAutoCalcedFields = state.dataOutput->iNumberOfAutoCalcedFields;
    6175         794 :     int iNumberOfAutoSizedFields = state.dataOutput->iNumberOfAutoSizedFields;
    6176         794 :     int iNumberOfDefaultedFields = state.dataOutput->iNumberOfDefaultedFields;
    6177         794 :     int iNumberOfRecords = state.dataOutput->iNumberOfRecords;
    6178         794 :     int iTotalAutoCalculatableFields = state.dataOutput->iTotalAutoCalculatableFields;
    6179         794 :     int iTotalAutoSizableFields = state.dataOutput->iTotalAutoSizableFields;
    6180         794 :     int iTotalFieldsWithDefaults = state.dataOutput->iTotalFieldsWithDefaults;
    6181             : 
    6182             :     using ScheduleManager::GetScheduleName;
    6183             :     using ScheduleManager::ScheduleAverageHoursPerWeek;
    6184             : 
    6185             :     Real64 consumptionTotal;
    6186             : 
    6187         794 :     auto const &ort = state.dataOutRptTab;
    6188             : 
    6189         794 :     int StartOfWeek = state.dataEnvrn->RunPeriodStartDayOfWeek;
    6190         794 :     if (StartOfWeek == 0) {
    6191         788 :         StartOfWeek = 2; // if the first day of the week has not been set yet, assume monday
    6192             :     }
    6193             : 
    6194             :     // Interior Connected Lighting Power
    6195         794 :     consumptionTotal = 0.0;
    6196        5113 :     for (int iLight = 1; iLight <= state.dataHeatBal->TotLights; ++iLight) {
    6197        4319 :         auto const &thisLight = state.dataHeatBal->Lights(iLight);
    6198        4319 :         int const iZone = state.dataHeatBal->Lights(iLight).ZonePtr;
    6199        4319 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
    6200             : 
    6201        4319 :         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
    6202        4319 :         if (thisZone.SystemZoneNodeNumber > 0) { // conditioned y/n
    6203        4185 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtCond, thisLight.Name, "Y");
    6204             :         } else {
    6205         134 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtCond, thisLight.Name, "N");
    6206             :         }
    6207       12957 :         PreDefTableEntry(state,
    6208        4319 :                          state.dataOutRptPredefined->pdchInLtAvgHrSchd,
    6209             :                          thisLight.Name,
    6210        4319 :                          ScheduleAverageHoursPerWeek(state, thisLight.SchedPtr, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear));
    6211             :         // average operating hours per week
    6212        4319 :         if (ort->gatherElapsedTimeBEPS > 0) {
    6213          19 :             state.dataOutRptTab->HrsPerWeek = 24 * 7 * thisLight.SumTimeNotZeroCons / ort->gatherElapsedTimeBEPS;
    6214          19 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtAvgHrOper, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6215             :         }
    6216             :         // full load hours per week
    6217        4319 :         if ((thisLight.DesignLevel * ort->gatherElapsedTimeBEPS) > 0) {
    6218          38 :             state.dataOutRptTab->HrsPerWeek =
    6219          19 :                 24 * 7 * thisLight.SumConsumption / (thisLight.DesignLevel * ort->gatherElapsedTimeBEPS * Constant::SecInHour);
    6220          19 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtFullLoadHrs, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6221             :         }
    6222        4319 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtConsump, thisLight.Name, thisLight.SumConsumption * mult / 1000000000.0);
    6223        4319 :         consumptionTotal += thisLight.SumConsumption / 1000000000.0;
    6224             :     }
    6225         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtConsump, "Interior Lighting Total", consumptionTotal);
    6226             : 
    6227             :     // Exterior Lighting
    6228         794 :     consumptionTotal = 0.0;
    6229         984 :     for (int iLight = 1; iLight <= state.dataExteriorEnergyUse->NumExteriorLights; ++iLight) {
    6230         190 :         auto const &thisLight = state.dataExteriorEnergyUse->ExteriorLights(iLight);
    6231             : 
    6232         190 :         if (thisLight.ControlMode == ExteriorEnergyUse::LightControlType::ScheduleOnly) { // photocell/schedule
    6233          57 :             PreDefTableEntry(state,
    6234          19 :                              state.dataOutRptPredefined->pdchExLtAvgHrSchd,
    6235             :                              thisLight.Name,
    6236          19 :                              ScheduleAverageHoursPerWeek(state, thisLight.SchedPtr, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear));
    6237             :         }
    6238             :         // average operating hours per week
    6239         190 :         if (ort->gatherElapsedTimeBEPS > 0) {
    6240           0 :             state.dataOutRptTab->HrsPerWeek = 24 * 7 * thisLight.SumTimeNotZeroCons / ort->gatherElapsedTimeBEPS;
    6241           0 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtAvgHrOper, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6242             :         }
    6243             :         // full load hours per week
    6244         190 :         if ((thisLight.DesignLevel * ort->gatherElapsedTimeBEPS) > 0) {
    6245           0 :             state.dataOutRptTab->HrsPerWeek =
    6246           0 :                 24 * 7 * thisLight.SumConsumption / (thisLight.DesignLevel * ort->gatherElapsedTimeBEPS * Constant::SecInHour);
    6247           0 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtFullLoadHrs, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6248             :         }
    6249         190 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtConsump, thisLight.Name, thisLight.SumConsumption / 1000000000.0);
    6250         190 :         consumptionTotal += thisLight.SumConsumption / 1000000000.0;
    6251             :     }
    6252         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtConsump, "Exterior Lighting Total", consumptionTotal);
    6253             : 
    6254             :     // outside air ventilation
    6255         794 :     Real64 totalOccupants = 0.;
    6256         794 :     Real64 totalAverageOccupants = 0.;
    6257         794 :     Real64 totalArea = 0.;
    6258         794 :     Real64 totalVozMin = 0;
    6259         794 :     Real64 totalMechVentVol = 0;
    6260         794 :     Real64 totalNatVentVol = 0;
    6261         794 :     Real64 totalInfilVol = 0;
    6262         794 :     Real64 totalVozDyn = 0;
    6263         794 :     Real64 totalMechVentRateOcc = 0;
    6264         794 :     Real64 totalNatVentRateOcc = 0;
    6265         794 :     Real64 totalInfilRateOcc = 0;
    6266         794 :     Real64 totalVozDynOcc = 0;
    6267             : 
    6268             :     // Outdoor Air Summary and Outdoor Air Details
    6269        5838 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6270             : 
    6271        5044 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
    6272             : 
    6273        5044 :         int const zoneMult = thisZone.Multiplier * thisZone.ListMultiplier;
    6274        5044 :         if (thisZone.SystemZoneNodeNumber >= 0) { // conditioned zones only
    6275             : 
    6276        5044 :             auto &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
    6277             : 
    6278             :             // AFN infiltration -- check that afn sim is being done.
    6279        5044 :             if (!state.afn->multizone_always_simulated) {
    6280        4936 :                 thisZonePreDefRep.AFNInfilVolTotalStdDen = 0.0;
    6281        4936 :                 thisZonePreDefRep.AFNVentVolTotalStdDen = 0.0;
    6282        4936 :                 thisZonePreDefRep.AFNInfilVolTotalOccStdDen = 0.0;
    6283        4936 :                 thisZonePreDefRep.AFNVentVolTotalOccStdDen = 0.0;
    6284        4936 :                 thisZonePreDefRep.AFNInfilVolMin = 0.0;
    6285        4936 :                 thisZonePreDefRep.AFNInfilVolTotalOcc = 0.0;
    6286             :             }
    6287             : 
    6288             :             // air loop name
    6289        5044 :             if (thisZone.IsControlled) {
    6290        4309 :                 std::string airLoopName = "";
    6291        8772 :                 for (int zoneInNode = 1; zoneInNode <= state.dataZoneEquip->ZoneEquipConfig(iZone).NumInletNodes; ++zoneInNode) {
    6292        4463 :                     int airLoopNumber = state.dataZoneEquip->ZoneEquipConfig(iZone).InletNodeAirLoopNum(zoneInNode);
    6293        4463 :                     if (airLoopNumber > 0) {
    6294        3654 :                         if (airLoopName.empty()) {
    6295        3634 :                             airLoopName = state.dataAirSystemsData->PrimaryAirSystems(airLoopNumber).Name;
    6296             :                         } else {
    6297          20 :                             airLoopName += "; " + state.dataAirSystemsData->PrimaryAirSystems(airLoopNumber).Name;
    6298             :                         }
    6299             :                     }
    6300             :                 }
    6301        4309 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvAirLpNm, thisZone.Name, airLoopName);
    6302             : 
    6303             :                 // occupants
    6304        4309 :                 if (thisZone.isNominalOccupied) {
    6305        3918 :                     if (thisZonePreDefRep.NumOccAccumTime > 0) {
    6306        3817 :                         Real64 const avgOcc = thisZonePreDefRep.NumOccAccum / thisZonePreDefRep.NumOccAccumTime;
    6307        3817 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoAvgNumOcc1, thisZone.Name, avgOcc);
    6308        3817 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoAvgNumOcc2, thisZone.Name, avgOcc);
    6309        3817 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvAvgNumOcc, thisZone.Name, avgOcc);
    6310        3817 :                         totalAverageOccupants += avgOcc * zoneMult;
    6311             :                     }
    6312             :                 }
    6313        4309 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvNomNumOcc, thisZone.Name, thisZone.TotOccupants);
    6314        4309 :                 totalOccupants += thisZone.TotOccupants * zoneMult;
    6315             : 
    6316             :                 // Zone volume and area
    6317             : 
    6318        4309 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoZoneVol1, thisZone.Name, thisZone.Volume);
    6319        4309 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoZoneVol2, thisZone.Name, thisZone.Volume);
    6320        4309 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneVol, thisZone.Name, thisZone.Volume);
    6321        4309 :                 state.dataOutRptTab->totalVolume += thisZone.Volume * zoneMult;
    6322        4309 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneArea, thisZone.Name, thisZone.FloorArea);
    6323        4309 :                 totalArea += thisZone.FloorArea * zoneMult;
    6324             : 
    6325             :                 // minimum dynamic target ventilation Voz-dyn-min
    6326        4309 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvMinDynTrgVent, thisZone.Name, thisZonePreDefRep.VozMin, 3);
    6327        4309 :                 totalVozMin += thisZonePreDefRep.VozMin * zoneMult;
    6328             : 
    6329             :                 // Mechanical ventilation
    6330        4309 :                 if (thisZone.Volume > 0 && thisZonePreDefRep.TotTimeOcc > 0) {
    6331        3794 :                     PreDefTableEntry(state,
    6332        3794 :                                      state.dataOutRptPredefined->pdchOaoAvgMechVent,
    6333             :                                      thisZone.Name,
    6334        3794 :                                      thisZonePreDefRep.MechVentVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume * zoneMult),
    6335        3794 :                                      3);
    6336        3794 :                     PreDefTableEntry(state,
    6337        3794 :                                      state.dataOutRptPredefined->pdchOaoMinMechVent,
    6338             :                                      thisZone.Name,
    6339        3794 :                                      thisZonePreDefRep.MechVentVolMin / (thisZone.Volume * zoneMult),
    6340        7588 :                                      3);
    6341             :                 }
    6342        4309 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzMechVent, thisZone.Name, thisZonePreDefRep.MechVentVolTotalStdDen);
    6343        4309 :                 totalMechVentVol += thisZonePreDefRep.MechVentVolTotalStdDen * zoneMult;
    6344             : 
    6345             :                 // Natural ventilation
    6346        8618 :                 PreDefTableEntry(state,
    6347        4309 :                                  state.dataOutRptPredefined->pdchOaTaBzNatVent,
    6348             :                                  thisZone.Name,
    6349        4309 :                                  thisZonePreDefRep.SimpVentVolTotalStdDen + thisZonePreDefRep.AFNVentVolTotalStdDen);
    6350        4309 :                 totalNatVentVol += (thisZonePreDefRep.SimpVentVolTotalStdDen + thisZonePreDefRep.AFNVentVolTotalStdDen) * zoneMult;
    6351             : 
    6352             :                 // Total ventilation
    6353        8618 :                 PreDefTableEntry(state,
    6354        4309 :                                  state.dataOutRptPredefined->pdchOaTaBzTotVent,
    6355             :                                  thisZone.Name,
    6356        4309 :                                  thisZonePreDefRep.MechVentVolTotalStdDen + thisZonePreDefRep.SimpVentVolTotalStdDen +
    6357        4309 :                                      thisZonePreDefRep.AFNVentVolTotalStdDen);
    6358             : 
    6359             :                 // infiltration
    6360        4309 :                 if (thisZone.Volume > 0 && thisZonePreDefRep.TotTimeOcc > 0) {
    6361        3794 :                     PreDefTableEntry(state,
    6362        3794 :                                      state.dataOutRptPredefined->pdchOaoAvgInfil,
    6363             :                                      thisZone.Name,
    6364        3794 :                                      thisZonePreDefRep.InfilVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume),
    6365        3794 :                                      3);
    6366        3794 :                     PreDefTableEntry(
    6367        3794 :                         state, state.dataOutRptPredefined->pdchOaoMinInfil, thisZone.Name, thisZonePreDefRep.InfilVolMin / (thisZone.Volume), 3);
    6368             : 
    6369        3794 :                     PreDefTableEntry(state,
    6370        3794 :                                      state.dataOutRptPredefined->pdchOaoAvgAFNInfil,
    6371             :                                      thisZone.Name,
    6372        3794 :                                      thisZonePreDefRep.AFNInfilVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume),
    6373        3794 :                                      3);
    6374             : 
    6375        3794 :                     PreDefTableEntry(state,
    6376        3794 :                                      state.dataOutRptPredefined->pdchOaoMinAFNInfil,
    6377             :                                      thisZone.Name,
    6378        3794 :                                      thisZonePreDefRep.AFNInfilVolMin / (thisZone.Volume),
    6379        3794 :                                      3);
    6380             : 
    6381             :                     // simple 'ZoneVentilation'
    6382        3794 :                     PreDefTableEntry(state,
    6383        3794 :                                      state.dataOutRptPredefined->pdchOaoAvgSimpVent,
    6384             :                                      thisZone.Name,
    6385        3794 :                                      thisZonePreDefRep.SimpVentVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume),
    6386        3794 :                                      3);
    6387             : 
    6388        3794 :                     PreDefTableEntry(state,
    6389        3794 :                                      state.dataOutRptPredefined->pdchOaoMinSimpVent,
    6390             :                                      thisZone.Name,
    6391        3794 :                                      thisZonePreDefRep.SimpVentVolMin / (thisZone.Volume),
    6392        7588 :                                      3);
    6393             :                 }
    6394             : 
    6395             :                 // Infiltration
    6396        8618 :                 PreDefTableEntry(state,
    6397        4309 :                                  state.dataOutRptPredefined->pdchOaTaBzInfil,
    6398             :                                  thisZone.Name,
    6399        4309 :                                  thisZonePreDefRep.InfilVolTotalStdDen + thisZonePreDefRep.AFNInfilVolTotalStdDen);
    6400        4309 :                 totalInfilVol += (thisZonePreDefRep.InfilVolTotalStdDen + thisZonePreDefRep.AFNInfilVolTotalStdDen) * zoneMult;
    6401             : 
    6402             :                 // Total ventilation and infiltration
    6403        8618 :                 PreDefTableEntry(state,
    6404        4309 :                                  state.dataOutRptPredefined->pdchOaTaBzTotVentInfil,
    6405             :                                  thisZone.Name,
    6406        4309 :                                  thisZonePreDefRep.MechVentVolTotalStdDen + thisZonePreDefRep.SimpVentVolTotalStdDen +
    6407        4309 :                                      thisZonePreDefRep.AFNVentVolTotalStdDen + thisZonePreDefRep.AFNInfilVolTotalStdDen +
    6408        4309 :                                      thisZonePreDefRep.InfilVolTotalStdDen);
    6409             : 
    6410             :                 // Dynamic target ventilation Voz-dyn
    6411        4309 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzDynTrgVent, thisZone.Name, thisZonePreDefRep.VozTargetTotal);
    6412        4309 :                 totalVozDyn += thisZonePreDefRep.VozTargetTotal * zoneMult;
    6413        4309 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmBelow, thisZone.Name, thisZonePreDefRep.VozTargetTimeBelow);
    6414        4309 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAt, thisZone.Name, thisZonePreDefRep.VozTargetTimeAt);
    6415        4309 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAbove, thisZone.Name, thisZonePreDefRep.VozTargetTimeAbove);
    6416        4309 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAboveUnocc, thisZone.Name, thisZonePreDefRep.TotVentTimeNonZeroUnocc);
    6417             : 
    6418        4309 :                 if (thisZone.isNominalOccupied && (thisZonePreDefRep.TotTimeOcc > 0.0)) {
    6419        3794 :                     Real64 totTimeOccSec = thisZonePreDefRep.TotTimeOcc * Constant::SecInHour;
    6420             :                     // Mechanical ventilation
    6421        3794 :                     Real64 mechVent = thisZonePreDefRep.MechVentVolTotalOccStdDen / totTimeOccSec;
    6422        3794 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzMechVent, thisZone.Name, mechVent, 4);
    6423        3794 :                     totalMechVentRateOcc += mechVent * zoneMult;
    6424             : 
    6425             :                     // Natural ventilation
    6426        3794 :                     Real64 natVent = (thisZonePreDefRep.SimpVentVolTotalOccStdDen + thisZonePreDefRep.AFNVentVolTotalOccStdDen) / totTimeOccSec;
    6427        3794 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzNatVent, thisZone.Name, natVent, 4);
    6428        3794 :                     totalNatVentRateOcc += natVent * zoneMult;
    6429             : 
    6430             :                     // Total ventilation
    6431        3794 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTotVent, thisZone.Name, mechVent + natVent, 4);
    6432             : 
    6433             :                     // infiltration
    6434        3794 :                     Real64 infil = (thisZonePreDefRep.InfilVolTotalOccStdDen + thisZonePreDefRep.AFNInfilVolTotalOccStdDen) / totTimeOccSec;
    6435        3794 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzInfil, thisZone.Name, infil, 4);
    6436        3794 :                     totalInfilRateOcc += infil * zoneMult;
    6437             : 
    6438             :                     // Total ventilation and infiltration
    6439        3794 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTotVentInfil, thisZone.Name, mechVent + natVent + infil, 4);
    6440             : 
    6441             :                     // Dynamic target ventilation Voz-dyn
    6442        3794 :                     Real64 avgVoz = thisZonePreDefRep.VozTargetTotalOcc / totTimeOccSec;
    6443        3794 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzDynTrgVent, thisZone.Name, avgVoz, 4);
    6444        3794 :                     totalVozDynOcc += avgVoz * zoneMult;
    6445        3794 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmBelow, thisZone.Name, thisZonePreDefRep.VozTargetTimeBelowOcc);
    6446        3794 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmAt, thisZone.Name, thisZonePreDefRep.VozTargetTimeAtOcc);
    6447        3794 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmAbove, thisZone.Name, thisZonePreDefRep.VozTargetTimeAboveOcc);
    6448             :                 }
    6449        4309 :             }
    6450             :         }
    6451             :     }
    6452             : 
    6453        1996 :     for (int iSys = 1; iSys <= state.dataHVACGlobal->NumPrimaryAirSys; ++iSys) {
    6454        1202 :         auto const &thisPrimaryAirSys = state.dataAirSystemsData->PrimaryAirSystems(iSys);
    6455        1202 :         auto const &thisSysPreDefRep = state.dataSysRpts->SysPreDefRep(iSys);
    6456             : 
    6457             :         // Total Outdoor Air by Airloop
    6458        1202 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlMechVent, thisPrimaryAirSys.Name, thisSysPreDefRep.MechVentTotal);
    6459        1202 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlNatVent, thisPrimaryAirSys.Name, thisSysPreDefRep.NatVentTotal);
    6460        2404 :         PreDefTableEntry(state,
    6461        1202 :                          state.dataOutRptPredefined->pdchOaTaAlTotVent,
    6462             :                          thisPrimaryAirSys.Name,
    6463        1202 :                          thisSysPreDefRep.MechVentTotal + thisSysPreDefRep.NatVentTotal);
    6464        1202 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlSumDynTrgVent, thisPrimaryAirSys.Name, thisSysPreDefRep.TargetVentTotalVoz);
    6465        1202 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmBelow, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeBelowVozDynTotal);
    6466        1202 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmAt, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeAtVozDynTotal);
    6467        1202 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmAbove, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeAboveVozDynTotal);
    6468        1202 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmAboveUnocc, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeVentUnoccTotal);
    6469             : 
    6470             :         // Air loop times at OA limiting factors
    6471        3606 :         PreDefTableEntry(state,
    6472        1202 :                          state.dataOutRptPredefined->pdchOaTmFctNoLimit,
    6473             :                          thisPrimaryAirSys.Name,
    6474        1202 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::None)]);
    6475        3606 :         PreDefTableEntry(state,
    6476        1202 :                          state.dataOutRptPredefined->pdchOaTmFctLimit,
    6477             :                          thisPrimaryAirSys.Name,
    6478        1202 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::Limits)]);
    6479        3606 :         PreDefTableEntry(state,
    6480        1202 :                          state.dataOutRptPredefined->pdchOaTmFctEcono,
    6481             :                          thisPrimaryAirSys.Name,
    6482        1202 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::Economizer)]);
    6483        3606 :         PreDefTableEntry(state,
    6484        1202 :                          state.dataOutRptPredefined->pdchOaTmFctExhaust,
    6485             :                          thisPrimaryAirSys.Name,
    6486        1202 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::Exhaust)]);
    6487        3606 :         PreDefTableEntry(state,
    6488        1202 :                          state.dataOutRptPredefined->pdchOaTmFctMixedLimit,
    6489             :                          thisPrimaryAirSys.Name,
    6490        1202 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::MixedAir)]);
    6491        3606 :         PreDefTableEntry(state,
    6492        1202 :                          state.dataOutRptPredefined->pdchOaTmFctHiHumid,
    6493             :                          thisPrimaryAirSys.Name,
    6494        1202 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::HighHum)]);
    6495        3606 :         PreDefTableEntry(state,
    6496        1202 :                          state.dataOutRptPredefined->pdchOaTmFctDCV,
    6497             :                          thisPrimaryAirSys.Name,
    6498        1202 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::DCV)]);
    6499        3606 :         PreDefTableEntry(state,
    6500        1202 :                          state.dataOutRptPredefined->pdchOaTmFctNiteVent,
    6501             :                          thisPrimaryAirSys.Name,
    6502        1202 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::NightVent)]);
    6503        3606 :         PreDefTableEntry(state,
    6504        1202 :                          state.dataOutRptPredefined->pdchOaTmFctDemand,
    6505             :                          thisPrimaryAirSys.Name,
    6506        1202 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::DemandLimit)]);
    6507        3606 :         PreDefTableEntry(state,
    6508        1202 :                          state.dataOutRptPredefined->pdchOaTmFctEMS,
    6509             :                          thisPrimaryAirSys.Name,
    6510        1202 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::EMS)]);
    6511             : 
    6512        1202 :         if (thisSysPreDefRep.TimeOccupiedTotal > 0.0) {
    6513             :             // Average Outdoor Air During Occupancy by Airloop
    6514        1109 :             Real64 totTimeOccSec = thisSysPreDefRep.TimeOccupiedTotal * Constant::SecInHour;
    6515        1109 :             PreDefTableEntry(
    6516        1109 :                 state, state.dataOutRptPredefined->pdchOaOccAlMechVent, thisPrimaryAirSys.Name, thisSysPreDefRep.MechVentTotalOcc / totTimeOccSec, 4);
    6517        1109 :             PreDefTableEntry(
    6518        1109 :                 state, state.dataOutRptPredefined->pdchOaOccAlNatVent, thisPrimaryAirSys.Name, thisSysPreDefRep.NatVentTotalOcc / totTimeOccSec, 4);
    6519        1109 :             PreDefTableEntry(state,
    6520        1109 :                              state.dataOutRptPredefined->pdchOaOccAlTotVent,
    6521             :                              thisPrimaryAirSys.Name,
    6522        1109 :                              (thisSysPreDefRep.MechVentTotalOcc + thisSysPreDefRep.NatVentTotalOcc) / totTimeOccSec,
    6523        1109 :                              4);
    6524        1109 :             PreDefTableEntry(state,
    6525        1109 :                              state.dataOutRptPredefined->pdchOaOccAlSumDynTrgVent,
    6526             :                              thisPrimaryAirSys.Name,
    6527        1109 :                              thisSysPreDefRep.TargetVentTotalVozOcc / totTimeOccSec,
    6528        1109 :                              4);
    6529        1109 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccAlTmBelow, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeBelowVozDynTotalOcc);
    6530        1109 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccAlTmAt, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeAtVozDynTotalOcc);
    6531        1109 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccAlTmAbove, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeAboveVozDynTotalOcc);
    6532             : 
    6533             :             // Average Outdoor Air at OA Limiting Factors During Occupancy by Airloop
    6534             :             // lambda to set avgFlow during occupancy for a given airloop and limiting factor type
    6535       12192 :             auto avgFlowRate = [&state](int sysNum, MixedAir::OALimitFactor limitingFactorType) {
    6536       11090 :                 int time = state.dataSysRpts->SysPreDefRep(sysNum).TimeAtOALimitOcc[static_cast<int>(limitingFactorType)];
    6537       11090 :                 if (time > 0) {
    6538        1102 :                     return state.dataSysRpts->SysPreDefRep(sysNum).MechVentTotAtLimitOcc[static_cast<int>(limitingFactorType)] /
    6539        1102 :                            (time * Constant::SecInHour);
    6540             :                 } else {
    6541        9988 :                     return 0.0;
    6542             :                 }
    6543        1109 :             };
    6544        2218 :             PreDefTableEntry(
    6545        2218 :                 state, state.dataOutRptPredefined->pdchOaAvFctNoLimit, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::None), 4);
    6546        2218 :             PreDefTableEntry(
    6547        2218 :                 state, state.dataOutRptPredefined->pdchOaAvFctLimit, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::Limits), 4);
    6548        2218 :             PreDefTableEntry(state,
    6549        1109 :                              state.dataOutRptPredefined->pdchOaAvFctEcono,
    6550             :                              thisPrimaryAirSys.Name,
    6551             :                              avgFlowRate(iSys, MixedAir::OALimitFactor::Economizer),
    6552        1109 :                              4);
    6553        2218 :             PreDefTableEntry(state,
    6554        1109 :                              state.dataOutRptPredefined->pdchOaAvFctExhaust,
    6555             :                              thisPrimaryAirSys.Name,
    6556             :                              avgFlowRate(iSys, MixedAir::OALimitFactor::Exhaust),
    6557        1109 :                              4);
    6558        2218 :             PreDefTableEntry(state,
    6559        1109 :                              state.dataOutRptPredefined->pdchOaAvFctMixedLimit,
    6560             :                              thisPrimaryAirSys.Name,
    6561             :                              avgFlowRate(iSys, MixedAir::OALimitFactor::MixedAir),
    6562        1109 :                              4);
    6563        2218 :             PreDefTableEntry(state,
    6564        1109 :                              state.dataOutRptPredefined->pdchOaAvFctHiHumid,
    6565             :                              thisPrimaryAirSys.Name,
    6566             :                              avgFlowRate(iSys, MixedAir::OALimitFactor::HighHum),
    6567        1109 :                              4);
    6568        2218 :             PreDefTableEntry(
    6569        2218 :                 state, state.dataOutRptPredefined->pdchOaAvFctDCV, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::DCV), 4);
    6570        2218 :             PreDefTableEntry(state,
    6571        1109 :                              state.dataOutRptPredefined->pdchOaAvFctNiteVent,
    6572             :                              thisPrimaryAirSys.Name,
    6573             :                              avgFlowRate(iSys, MixedAir::OALimitFactor::NightVent),
    6574        1109 :                              4);
    6575        2218 :             PreDefTableEntry(state,
    6576        1109 :                              state.dataOutRptPredefined->pdchOaAvFctDemand,
    6577             :                              thisPrimaryAirSys.Name,
    6578             :                              avgFlowRate(iSys, MixedAir::OALimitFactor::DemandLimit),
    6579        1109 :                              4);
    6580        2218 :             PreDefTableEntry(
    6581        3327 :                 state, state.dataOutRptPredefined->pdchOaAvFctEMS, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::EMS), 4);
    6582             :         }
    6583             :     }
    6584             :     // add total rows for outdoor air details
    6585        1588 :     OutputReportPredefined::PreDefTableEntry(
    6586        1588 :         state, state.dataOutRptPredefined->pdchOaMvDesZnOa, "Total Facility", state.dataOutRptPredefined->TotalVozMax, 4);
    6587             : 
    6588         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneVol, "Total Facility", state.dataOutRptTab->totalVolume);
    6589         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneArea, "Total Facility", totalArea);
    6590         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvNomNumOcc, "Total Facility", totalOccupants);
    6591         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvAvgNumOcc, "Total Facility", totalAverageOccupants);
    6592         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvMinDynTrgVent, "Total Facility", totalVozMin, 3);
    6593             : 
    6594         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzMechVent, "Total Facility", totalMechVentVol);
    6595         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzNatVent, "Total Facility", totalNatVentVol);
    6596         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTotVent, "Total Facility", totalMechVentVol + totalNatVentVol);
    6597         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzInfil, "Total Facility", totalInfilVol);
    6598         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTotVentInfil, "Total Facility", totalMechVentVol + totalNatVentVol + totalInfilVol);
    6599         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzDynTrgVent, "Total Facility", totalVozDyn);
    6600        2382 :     PreDefTableEntry(
    6601        1588 :         state, state.dataOutRptPredefined->pdchOaTaBzTmBelow, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneBelowVozDynForOA);
    6602         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAt, "Total Facility", state.dataOutRptPredefined->TotalAllZonesAtVozDynForOA);
    6603        2382 :     PreDefTableEntry(
    6604        1588 :         state, state.dataOutRptPredefined->pdchOaTaBzTmAbove, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneAboveVozDynForOA);
    6605        2382 :     PreDefTableEntry(
    6606        1588 :         state, state.dataOutRptPredefined->pdchOaTaBzTmAboveUnocc, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneVentUnoccForOA);
    6607             : 
    6608         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzMechVent, "Total Facility", totalMechVentRateOcc, 4);
    6609         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzNatVent, "Total Facility", totalNatVentRateOcc, 4);
    6610         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTotVent, "Total Facility", totalMechVentRateOcc + totalNatVentRateOcc, 4);
    6611         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzInfil, "Total Facility", totalInfilRateOcc, 4);
    6612         794 :     PreDefTableEntry(state,
    6613         794 :                      state.dataOutRptPredefined->pdchOaOccBzTotVentInfil,
    6614             :                      "Total Facility",
    6615         794 :                      totalMechVentRateOcc + totalNatVentRateOcc + totalInfilRateOcc,
    6616         794 :                      4);
    6617         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzDynTrgVent, "Total Facility", totalVozDynOcc, 4);
    6618        2382 :     PreDefTableEntry(
    6619        1588 :         state, state.dataOutRptPredefined->pdchOaOccBzTmBelow, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneBelowVozDynOccForOA);
    6620         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmAt, "Total Facility", state.dataOutRptPredefined->TotalAllZonesAtVozDynOccForOA);
    6621        2382 :     PreDefTableEntry(
    6622        1588 :         state, state.dataOutRptPredefined->pdchOaOccBzTmAbove, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneAboveVozDynOccForOA);
    6623             : 
    6624             :     // Add the number of central air distributions system to the count report
    6625         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "HVAC Air Loops", NumPrimaryAirSys);
    6626             :     // Add the number of conditioned and unconditioned zones to the count report
    6627        5838 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6628             : 
    6629        5044 :         if (state.dataHeatBal->Zone(iZone).SystemZoneNodeNumber > 0) { // conditioned zones only
    6630        4601 :             ++state.dataOutRptTab->numCondZones;
    6631             :         } else {
    6632         443 :             ++state.dataOutRptTab->numUncondZones;
    6633             :         }
    6634             :     }
    6635         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Conditioned Zones", state.dataOutRptTab->numCondZones);
    6636         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Unconditioned Zones", state.dataOutRptTab->numUncondZones);
    6637             :     // add the number of plenums to the count report
    6638         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Supply Plenums", state.dataZonePlenum->NumZoneSupplyPlenums);
    6639         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Return Plenums", state.dataZonePlenum->NumZoneReturnPlenums);
    6640             : 
    6641             :     // Add footnote saying if it is a design day or other kind of environment
    6642             : 
    6643             :     // Field counts
    6644         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "IDF Objects", iNumberOfRecords);
    6645         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Defaulted Fields", iNumberOfDefaultedFields);
    6646         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Fields with Defaults", iTotalFieldsWithDefaults);
    6647         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autosized Fields", iNumberOfAutoSizedFields);
    6648         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autosizable Fields", iTotalAutoSizableFields);
    6649         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autocalculated Fields", iNumberOfAutoCalcedFields);
    6650         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autocalculatable Fields", iTotalAutoCalculatableFields);
    6651             : 
    6652        5838 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6653             : 
    6654        5044 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
    6655        5044 :         auto const &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
    6656             : 
    6657             :         // annual
    6658             :         // PreDefTableEntry(state,  pdchSHGSAnHvacHt, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSAnHvacHt * convertJtoGJ, 3 );
    6659             :         // PreDefTableEntry(state,  pdchSHGSAnHvacCl, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSAnHvacCl * convertJtoGJ, 3 );
    6660        5044 :         PreDefTableEntry(
    6661        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnZoneEqHt, thisZone.Name, thisZonePreDefRep.SHGSAnZoneEqHt * Constant::convertJtoGJ, 3);
    6662        5044 :         PreDefTableEntry(
    6663        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnZoneEqCl, thisZone.Name, thisZonePreDefRep.SHGSAnZoneEqCl * Constant::convertJtoGJ, 3);
    6664        5044 :         PreDefTableEntry(
    6665        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnHvacATUHt, thisZone.Name, thisZonePreDefRep.SHGSAnHvacATUHt * Constant::convertJtoGJ, 3);
    6666        5044 :         PreDefTableEntry(
    6667        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnHvacATUCl, thisZone.Name, thisZonePreDefRep.SHGSAnHvacATUCl * Constant::convertJtoGJ, 3);
    6668        5044 :         PreDefTableEntry(
    6669        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnSurfHt, thisZone.Name, thisZonePreDefRep.SHGSAnSurfHt * Constant::convertJtoGJ, 3);
    6670        5044 :         PreDefTableEntry(
    6671        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnSurfCl, thisZone.Name, thisZonePreDefRep.SHGSAnSurfCl * Constant::convertJtoGJ, 3);
    6672        5044 :         PreDefTableEntry(
    6673        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnPeoplAdd, thisZone.Name, thisZonePreDefRep.SHGSAnPeoplAdd * Constant::convertJtoGJ, 3);
    6674        5044 :         PreDefTableEntry(
    6675        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnLiteAdd, thisZone.Name, thisZonePreDefRep.SHGSAnLiteAdd * Constant::convertJtoGJ, 3);
    6676        5044 :         PreDefTableEntry(
    6677        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnEquipAdd, thisZone.Name, thisZonePreDefRep.SHGSAnEquipAdd * Constant::convertJtoGJ, 3);
    6678        5044 :         PreDefTableEntry(
    6679        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnWindAdd, thisZone.Name, thisZonePreDefRep.SHGSAnWindAdd * Constant::convertJtoGJ, 3);
    6680        5044 :         PreDefTableEntry(
    6681        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnIzaAdd, thisZone.Name, thisZonePreDefRep.SHGSAnIzaAdd * Constant::convertJtoGJ, 3);
    6682        5044 :         PreDefTableEntry(
    6683        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnInfilAdd, thisZone.Name, thisZonePreDefRep.SHGSAnInfilAdd * Constant::convertJtoGJ, 3);
    6684        5044 :         PreDefTableEntry(
    6685        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnOtherAdd, thisZone.Name, thisZonePreDefRep.SHGSAnOtherAdd * Constant::convertJtoGJ, 3);
    6686        5044 :         PreDefTableEntry(
    6687        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnEquipRem, thisZone.Name, thisZonePreDefRep.SHGSAnEquipRem * Constant::convertJtoGJ, 3);
    6688        5044 :         PreDefTableEntry(
    6689        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnWindRem, thisZone.Name, thisZonePreDefRep.SHGSAnWindRem * Constant::convertJtoGJ, 3);
    6690        5044 :         PreDefTableEntry(
    6691        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnIzaRem, thisZone.Name, thisZonePreDefRep.SHGSAnIzaRem * Constant::convertJtoGJ, 3);
    6692        5044 :         PreDefTableEntry(
    6693        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnInfilRem, thisZone.Name, thisZonePreDefRep.SHGSAnInfilRem * Constant::convertJtoGJ, 3);
    6694        5044 :         PreDefTableEntry(
    6695        5044 :             state, state.dataOutRptPredefined->pdchSHGSAnOtherRem, thisZone.Name, thisZonePreDefRep.SHGSAnOtherRem * Constant::convertJtoGJ, 3);
    6696             :         // peak cooling
    6697        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClTimePeak, thisZone.Name, DateToString(thisZonePreDefRep.clPtTimeStamp));
    6698             :         // PreDefTableEntry(state,  pdchSHGSClHvacHt, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSClHvacHt );
    6699             :         // PreDefTableEntry(state,  pdchSHGSClHvacCl, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSClHvacCl );
    6700       10088 :         PreDefTableEntry(
    6701        5044 :             state, state.dataOutRptPredefined->pdchSHGSClHvacHt, thisZone.Name, (thisZonePreDefRep.SHGSClHvacHt - thisZonePreDefRep.SHGSClHvacATUHt));
    6702       10088 :         PreDefTableEntry(
    6703        5044 :             state, state.dataOutRptPredefined->pdchSHGSClHvacCl, thisZone.Name, (thisZonePreDefRep.SHGSClHvacCl - thisZonePreDefRep.SHGSClHvacATUCl));
    6704        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUHt, thisZone.Name, thisZonePreDefRep.SHGSClHvacATUHt);
    6705        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUCl, thisZone.Name, thisZonePreDefRep.SHGSClHvacATUCl);
    6706        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfHt, thisZone.Name, thisZonePreDefRep.SHGSClSurfHt);
    6707        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfCl, thisZone.Name, thisZonePreDefRep.SHGSClSurfCl);
    6708        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClPeoplAdd, thisZone.Name, thisZonePreDefRep.SHGSClPeoplAdd);
    6709        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClLiteAdd, thisZone.Name, thisZonePreDefRep.SHGSClLiteAdd);
    6710        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipAdd, thisZone.Name, thisZonePreDefRep.SHGSClEquipAdd);
    6711        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindAdd, thisZone.Name, thisZonePreDefRep.SHGSClWindAdd);
    6712        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaAdd, thisZone.Name, thisZonePreDefRep.SHGSClIzaAdd);
    6713        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilAdd, thisZone.Name, thisZonePreDefRep.SHGSClInfilAdd);
    6714        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherAdd, thisZone.Name, thisZonePreDefRep.SHGSClOtherAdd);
    6715        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipRem, thisZone.Name, thisZonePreDefRep.SHGSClEquipRem);
    6716        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindRem, thisZone.Name, thisZonePreDefRep.SHGSClWindRem);
    6717        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaRem, thisZone.Name, thisZonePreDefRep.SHGSClIzaRem);
    6718        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilRem, thisZone.Name, thisZonePreDefRep.SHGSClInfilRem);
    6719        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherRem, thisZone.Name, thisZonePreDefRep.SHGSClOtherRem);
    6720             :         // peak heating
    6721        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtTimePeak, thisZone.Name, DateToString(thisZonePreDefRep.htPtTimeStamp));
    6722             :         // PreDefTableEntry(state,  pdchSHGSHtHvacHt, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSHtHvacHt );
    6723             :         // PreDefTableEntry(state,  pdchSHGSHtHvacCl, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSHtHvacCl );
    6724       10088 :         PreDefTableEntry(
    6725        5044 :             state, state.dataOutRptPredefined->pdchSHGSHtHvacHt, thisZone.Name, (thisZonePreDefRep.SHGSHtHvacHt - thisZonePreDefRep.SHGSHtHvacATUHt));
    6726       10088 :         PreDefTableEntry(
    6727        5044 :             state, state.dataOutRptPredefined->pdchSHGSHtHvacCl, thisZone.Name, (thisZonePreDefRep.SHGSHtHvacCl - thisZonePreDefRep.SHGSHtHvacATUCl));
    6728        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUHt, thisZone.Name, thisZonePreDefRep.SHGSHtHvacATUHt);
    6729        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUCl, thisZone.Name, thisZonePreDefRep.SHGSHtHvacATUCl);
    6730        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfHt, thisZone.Name, thisZonePreDefRep.SHGSHtSurfHt);
    6731        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfCl, thisZone.Name, thisZonePreDefRep.SHGSHtSurfCl);
    6732        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtPeoplAdd, thisZone.Name, thisZonePreDefRep.SHGSHtPeoplAdd);
    6733        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtLiteAdd, thisZone.Name, thisZonePreDefRep.SHGSHtLiteAdd);
    6734        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipAdd, thisZone.Name, thisZonePreDefRep.SHGSHtEquipAdd);
    6735        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindAdd, thisZone.Name, thisZonePreDefRep.SHGSHtWindAdd);
    6736        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaAdd, thisZone.Name, thisZonePreDefRep.SHGSHtIzaAdd);
    6737        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilAdd, thisZone.Name, thisZonePreDefRep.SHGSHtInfilAdd);
    6738        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherAdd, thisZone.Name, thisZonePreDefRep.SHGSHtOtherAdd);
    6739        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipRem, thisZone.Name, thisZonePreDefRep.SHGSHtEquipRem);
    6740        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindRem, thisZone.Name, thisZonePreDefRep.SHGSHtWindRem);
    6741        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaRem, thisZone.Name, thisZonePreDefRep.SHGSHtIzaRem);
    6742        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilRem, thisZone.Name, thisZonePreDefRep.SHGSHtInfilRem);
    6743        5044 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherRem, thisZone.Name, thisZonePreDefRep.SHGSHtOtherRem);
    6744             :     }
    6745             :     // totals for annual report
    6746        5838 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6747        5044 :         auto const &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
    6748             : 
    6749        5044 :         state.dataOutRptTab->totalZoneEqHt += thisZonePreDefRep.SHGSAnZoneEqHt;
    6750        5044 :         state.dataOutRptTab->totalZoneEqCl += thisZonePreDefRep.SHGSAnZoneEqCl;
    6751        5044 :         state.dataOutRptTab->totalHvacATUHt += thisZonePreDefRep.SHGSAnHvacATUHt;
    6752        5044 :         state.dataOutRptTab->totalHvacATUCl += thisZonePreDefRep.SHGSAnHvacATUCl;
    6753        5044 :         state.dataOutRptTab->totalSurfHt += thisZonePreDefRep.SHGSAnSurfHt;
    6754        5044 :         state.dataOutRptTab->totalSurfCl += thisZonePreDefRep.SHGSAnSurfCl;
    6755        5044 :         state.dataOutRptTab->totalPeoplAdd += thisZonePreDefRep.SHGSAnPeoplAdd;
    6756        5044 :         state.dataOutRptTab->totalLiteAdd += thisZonePreDefRep.SHGSAnLiteAdd;
    6757        5044 :         state.dataOutRptTab->totalEquipAdd += thisZonePreDefRep.SHGSAnEquipAdd;
    6758        5044 :         state.dataOutRptTab->totalWindAdd += thisZonePreDefRep.SHGSAnWindAdd;
    6759        5044 :         state.dataOutRptTab->totalIzaAdd += thisZonePreDefRep.SHGSAnIzaAdd;
    6760        5044 :         state.dataOutRptTab->totalInfilAdd += thisZonePreDefRep.SHGSAnInfilAdd;
    6761        5044 :         state.dataOutRptTab->totalOtherAdd += thisZonePreDefRep.SHGSAnOtherAdd;
    6762        5044 :         state.dataOutRptTab->totalEquipRem += thisZonePreDefRep.SHGSAnEquipRem;
    6763        5044 :         state.dataOutRptTab->totalWindRem += thisZonePreDefRep.SHGSAnWindRem;
    6764        5044 :         state.dataOutRptTab->totalIzaRem += thisZonePreDefRep.SHGSAnIzaRem;
    6765        5044 :         state.dataOutRptTab->totalInfilRem += thisZonePreDefRep.SHGSAnInfilRem;
    6766        5044 :         state.dataOutRptTab->totalOtherRem += thisZonePreDefRep.SHGSAnOtherRem;
    6767             :     }
    6768             :     // PreDefTableEntry(state,  pdchSHGSAnHvacHt, "Total Facility", totalHvacHt * convertJtoGJ, 3 );
    6769             :     // PreDefTableEntry(state,  pdchSHGSAnHvacCl, "Total Facility", totalHvacCl * convertJtoGJ, 3 );
    6770         794 :     PreDefTableEntry(
    6771         794 :         state, state.dataOutRptPredefined->pdchSHGSAnZoneEqHt, "Total Facility", state.dataOutRptTab->totalZoneEqHt * Constant::convertJtoGJ, 3);
    6772         794 :     PreDefTableEntry(
    6773         794 :         state, state.dataOutRptPredefined->pdchSHGSAnZoneEqCl, "Total Facility", state.dataOutRptTab->totalZoneEqCl * Constant::convertJtoGJ, 3);
    6774         794 :     PreDefTableEntry(
    6775         794 :         state, state.dataOutRptPredefined->pdchSHGSAnHvacATUHt, "Total Facility", state.dataOutRptTab->totalHvacATUHt * Constant::convertJtoGJ, 3);
    6776         794 :     PreDefTableEntry(
    6777         794 :         state, state.dataOutRptPredefined->pdchSHGSAnHvacATUCl, "Total Facility", state.dataOutRptTab->totalHvacATUCl * Constant::convertJtoGJ, 3);
    6778         794 :     PreDefTableEntry(
    6779         794 :         state, state.dataOutRptPredefined->pdchSHGSAnSurfHt, "Total Facility", state.dataOutRptTab->totalSurfHt * Constant::convertJtoGJ, 3);
    6780         794 :     PreDefTableEntry(
    6781         794 :         state, state.dataOutRptPredefined->pdchSHGSAnSurfCl, "Total Facility", state.dataOutRptTab->totalSurfCl * Constant::convertJtoGJ, 3);
    6782         794 :     PreDefTableEntry(
    6783         794 :         state, state.dataOutRptPredefined->pdchSHGSAnPeoplAdd, "Total Facility", state.dataOutRptTab->totalPeoplAdd * Constant::convertJtoGJ, 3);
    6784         794 :     PreDefTableEntry(
    6785         794 :         state, state.dataOutRptPredefined->pdchSHGSAnLiteAdd, "Total Facility", state.dataOutRptTab->totalLiteAdd * Constant::convertJtoGJ, 3);
    6786         794 :     PreDefTableEntry(
    6787         794 :         state, state.dataOutRptPredefined->pdchSHGSAnEquipAdd, "Total Facility", state.dataOutRptTab->totalEquipAdd * Constant::convertJtoGJ, 3);
    6788         794 :     PreDefTableEntry(
    6789         794 :         state, state.dataOutRptPredefined->pdchSHGSAnWindAdd, "Total Facility", state.dataOutRptTab->totalWindAdd * Constant::convertJtoGJ, 3);
    6790         794 :     PreDefTableEntry(
    6791         794 :         state, state.dataOutRptPredefined->pdchSHGSAnIzaAdd, "Total Facility", state.dataOutRptTab->totalIzaAdd * Constant::convertJtoGJ, 3);
    6792         794 :     PreDefTableEntry(
    6793         794 :         state, state.dataOutRptPredefined->pdchSHGSAnInfilAdd, "Total Facility", state.dataOutRptTab->totalInfilAdd * Constant::convertJtoGJ, 3);
    6794         794 :     PreDefTableEntry(
    6795         794 :         state, state.dataOutRptPredefined->pdchSHGSAnOtherAdd, "Total Facility", state.dataOutRptTab->totalOtherAdd * Constant::convertJtoGJ, 3);
    6796         794 :     PreDefTableEntry(
    6797         794 :         state, state.dataOutRptPredefined->pdchSHGSAnEquipRem, "Total Facility", state.dataOutRptTab->totalEquipRem * Constant::convertJtoGJ, 3);
    6798         794 :     PreDefTableEntry(
    6799         794 :         state, state.dataOutRptPredefined->pdchSHGSAnWindRem, "Total Facility", state.dataOutRptTab->totalWindRem * Constant::convertJtoGJ, 3);
    6800         794 :     PreDefTableEntry(
    6801         794 :         state, state.dataOutRptPredefined->pdchSHGSAnIzaRem, "Total Facility", state.dataOutRptTab->totalIzaRem * Constant::convertJtoGJ, 3);
    6802         794 :     PreDefTableEntry(
    6803         794 :         state, state.dataOutRptPredefined->pdchSHGSAnInfilRem, "Total Facility", state.dataOutRptTab->totalInfilRem * Constant::convertJtoGJ, 3);
    6804         794 :     PreDefTableEntry(
    6805         794 :         state, state.dataOutRptPredefined->pdchSHGSAnOtherRem, "Total Facility", state.dataOutRptTab->totalOtherRem * Constant::convertJtoGJ, 3);
    6806             :     // building level results for peak cooling
    6807        1588 :     PreDefTableEntry(
    6808        2382 :         state, state.dataOutRptPredefined->pdchSHGSClTimePeak, "Total Facility", DateToString(state.dataHeatBal->BuildingPreDefRep.clPtTimeStamp));
    6809             :     // PreDefTableEntry(state,  pdchSHGSClHvacHt, "Total Facility", BuildingPreDefRep.SHGSClHvacHt );
    6810             :     // PreDefTableEntry(state,  pdchSHGSClHvacCl, "Total Facility", BuildingPreDefRep.SHGSClHvacCl );
    6811        1588 :     PreDefTableEntry(state,
    6812         794 :                      state.dataOutRptPredefined->pdchSHGSClHvacHt,
    6813             :                      "Total Facility",
    6814         794 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt - state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt));
    6815        1588 :     PreDefTableEntry(state,
    6816         794 :                      state.dataOutRptPredefined->pdchSHGSClHvacCl,
    6817             :                      "Total Facility",
    6818         794 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl - state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl));
    6819         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt);
    6820         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl);
    6821         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt);
    6822         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl);
    6823         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClPeoplAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd);
    6824         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClLiteAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd);
    6825         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd);
    6826         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd);
    6827         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd);
    6828         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd);
    6829         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd);
    6830         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem);
    6831         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem);
    6832         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem);
    6833         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem);
    6834         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem);
    6835             :     // building level results for peak heating
    6836        1588 :     PreDefTableEntry(
    6837        2382 :         state, state.dataOutRptPredefined->pdchSHGSHtTimePeak, "Total Facility", DateToString(state.dataHeatBal->BuildingPreDefRep.htPtTimeStamp));
    6838             :     // PreDefTableEntry(state,  pdchSHGSHtHvacHt, "Total Facility", BuildingPreDefRep.SHGSHtHvacHt );
    6839             :     // PreDefTableEntry(state,  pdchSHGSHtHvacCl, "Total Facility", BuildingPreDefRep.SHGSHtHvacCl );
    6840        1588 :     PreDefTableEntry(state,
    6841         794 :                      state.dataOutRptPredefined->pdchSHGSHtHvacHt,
    6842             :                      "Total Facility",
    6843         794 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt - state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt));
    6844        1588 :     PreDefTableEntry(state,
    6845         794 :                      state.dataOutRptPredefined->pdchSHGSHtHvacCl,
    6846             :                      "Total Facility",
    6847         794 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl - state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl));
    6848         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt);
    6849         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl);
    6850         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt);
    6851         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl);
    6852         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtPeoplAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd);
    6853         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtLiteAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd);
    6854         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd);
    6855         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd);
    6856         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd);
    6857         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd);
    6858         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd);
    6859         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem);
    6860         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem);
    6861         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem);
    6862         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem);
    6863         794 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem);
    6864             : 
    6865             :     // LEED Report
    6866             :     // 1.1A-General Information
    6867         794 :     if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    6868           0 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Weather File", state.dataEnvrn->EnvironmentName);
    6869             :     } else {
    6870        1588 :         PreDefTableEntry(state,
    6871         794 :                          state.dataOutRptPredefined->pdchLeedGenData,
    6872             :                          "Weather File",
    6873        1588 :                          state.dataEnvrn->EnvironmentName + " ** " + state.dataEnvrn->WeatherFileLocationTitle);
    6874             :     }
    6875             : 
    6876         794 :     if (ort->ip()) {
    6877          11 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [ft2]", "-");
    6878             :     } else {
    6879         783 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [m2]", "-");
    6880             :     }
    6881             :     // LEED schedule sub table
    6882       17234 :     for (long iSch = 1; iSch <= state.dataScheduleMgr->NumSchedules; ++iSch) {
    6883       16440 :         std::string curSchName = state.dataScheduleMgr->Schedule(iSch).Name;
    6884       16440 :         std::string curSchType = ScheduleManager::GetScheduleType(state, iSch);
    6885       16440 :         if (Util::SameString(curSchType, "FRACTION")) {
    6886       13174 :             PreDefTableEntry(state,
    6887        6587 :                              state.dataOutRptPredefined->pdchLeedEflhEflh,
    6888             :                              curSchName,
    6889        6587 :                              ScheduleManager::ScheduleAnnualFullLoadHours(state, iSch, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear),
    6890        6587 :                              0);
    6891       13174 :             PreDefTableEntry(state,
    6892        6587 :                              state.dataOutRptPredefined->pdchLeedEflhNonZerHrs,
    6893             :                              curSchName,
    6894        6587 :                              ScheduleManager::ScheduleHoursGT1perc(state, iSch, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear),
    6895       13174 :                              0);
    6896             :         }
    6897       16440 :     }
    6898             :     // fill the LEED setpoint table
    6899         794 :     ZoneTempPredictorCorrector::FillPredefinedTableOnThermostatSetpoints(state);
    6900         794 :     ZoneTempPredictorCorrector::FillPredefinedTableOnThermostatSchedules(state);
    6901         794 : }
    6902             : 
    6903           5 : void WriteMonthlyTables(EnergyPlusData &state)
    6904             : {
    6905             :     // SUBROUTINE INFORMATION:
    6906             :     //       AUTHOR         Jason Glazer
    6907             :     //       DATE WRITTEN   August 2003
    6908             :     //       MODIFIED       January 2010, Kyle Benne
    6909             :     //                      Added SQLite output
    6910             :     //                      January 2021, J. Yuan
    6911             :     //                      Modified to accommodate dual-unit reporting
    6912             :     //       RE-ENGINEERED  na
    6913             : 
    6914             :     // PURPOSE OF THIS SUBROUTINE:
    6915             :     //   Set up the monthly tabular report results
    6916             : 
    6917             :     // METHODOLOGY EMPLOYED:
    6918             :     //   Creates several arrays that are passed to the WriteTable
    6919             :     //   routine.  All arrays are strings so numbers need to be
    6920             :     //   converted prior to calling WriteTable.
    6921             : 
    6922             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    6923           5 :     Array1D_string columnHead;
    6924           5 :     Array1D_int columnWidth;
    6925           5 :     Array1D_string rowHead(16);
    6926           5 :     Array2D_string tableBody;
    6927           5 :     std::string curAggString;
    6928             :     int iInput;
    6929             :     int jTable;
    6930             :     int kColumn;
    6931             :     int lMonth;
    6932             :     int curTable;
    6933             :     int curCol;
    6934             :     Real64 curVal;
    6935             :     Real64 curConversionFactor;
    6936             :     int columnUsedCount;
    6937             :     int columnRecount;
    6938             :     int digitsShown;
    6939             :     Real64 minVal;
    6940             :     Real64 maxVal;
    6941             :     Real64 sumVal;
    6942             :     Real64 sumDuration;
    6943           5 :     std::string curUnits;
    6944           5 :     std::string energyUnitsString;
    6945             :     Real64 energyUnitsConversionFactor;
    6946             :     int indexUnitConv;
    6947           5 :     std::string varNameWithUnits;
    6948             :     Real64 veryLarge;
    6949             :     Real64 verySmall;
    6950             : 
    6951             :     static Real64 const storedMaxVal(std::numeric_limits<Real64>::max());
    6952             :     static Real64 const storedMinVal(std::numeric_limits<Real64>::lowest());
    6953             : 
    6954           5 :     rowHead(1) = "January";
    6955           5 :     rowHead(2) = "February";
    6956           5 :     rowHead(3) = "March";
    6957           5 :     rowHead(4) = "April";
    6958           5 :     rowHead(5) = "May";
    6959           5 :     rowHead(6) = "June";
    6960           5 :     rowHead(7) = "July";
    6961           5 :     rowHead(8) = "August";
    6962           5 :     rowHead(9) = "September";
    6963           5 :     rowHead(10) = "October";
    6964           5 :     rowHead(11) = "November";
    6965           5 :     rowHead(12) = "December";
    6966           5 :     rowHead(13) = "";
    6967           5 :     rowHead(14) = "Annual Sum or Average";
    6968           5 :     rowHead(15) = "Minimum of Months";
    6969           5 :     rowHead(16) = "Maximum of Months";
    6970             : 
    6971             :     std::unordered_map<AggType, std::string> aggString = {
    6972           0 :         {AggType::SumOrAvg, ""},
    6973           0 :         {AggType::Maximum, " Maximum "},
    6974           0 :         {AggType::Minimum, " MINIMUM "},
    6975           0 :         {AggType::ValueWhenMaxMin, " AT MAX/MIN "},
    6976           0 :         {AggType::HoursZero, " HOURS ZERO "},
    6977           0 :         {AggType::HoursNonZero, " HOURS NON-ZERO "},
    6978           0 :         {AggType::HoursPositive, " HOURS POSITIVE "},
    6979           0 :         {AggType::HoursNonPositive, " HOURS NON-POSITIVE "},
    6980           0 :         {AggType::HoursNegative, " HOURS NEGATIVE "},
    6981           0 :         {AggType::HoursNonNegative, " HOURS NON-NEGATIVE "},
    6982           0 :         {AggType::SumOrAverageHoursShown, " FOR HOURS SHOWN "},
    6983           0 :         {AggType::MaximumDuringHoursShown, " MAX FOR HOURS SHOWN "},
    6984           0 :         {AggType::MinimumDuringHoursShown, " MIN FOR HOURS SHOWN "},
    6985          75 :     };
    6986             : 
    6987           5 :     veryLarge = 1.0E280;
    6988           5 :     verySmall = -1.0E280;
    6989             : 
    6990           5 :     auto &ort = state.dataOutRptTab;
    6991             : 
    6992          10 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    6993          10 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    6994          10 :         bool produceTabular = true;
    6995          10 :         bool produceSQLite = false;
    6996          10 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
    6997             : 
    6998             :         // set the unit conversion
    6999           5 :         if (unitsStyle_cur == UnitsStyle::None) {
    7000           5 :             energyUnitsString = "J";
    7001           5 :             energyUnitsConversionFactor = 1.0;
    7002           0 :         } else if (unitsStyle_cur == UnitsStyle::JtoKWH) {
    7003           0 :             energyUnitsString = "kWh";
    7004           0 :             energyUnitsConversionFactor = 1.0 / 3600000.0;
    7005           0 :         } else if (unitsStyle_cur == UnitsStyle::JtoMJ) {
    7006           0 :             energyUnitsString = "MJ";
    7007           0 :             energyUnitsConversionFactor = 1.0 / 1000000.0;
    7008           0 :         } else if (unitsStyle_cur == UnitsStyle::JtoGJ) {
    7009           0 :             energyUnitsString = "GJ";
    7010           0 :             energyUnitsConversionFactor = 1.0 / 1000000000.0;
    7011             :         } else { // Should never happen but assures compilers of initialization
    7012           0 :             energyUnitsString = "J";
    7013           0 :             energyUnitsConversionFactor = 1.0;
    7014             :         }
    7015             : 
    7016             :         // loop through each input to get the name of the tables
    7017           5 :         for (iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
    7018             :             // loop through each report and
    7019           0 :             digitsShown = ort->MonthlyInput(iInput).showDigits;
    7020           0 :             for (jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
    7021           0 :                 curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
    7022             :                 // first loop through and count how many 'columns' are defined
    7023             :                 // since max and min actually define two columns (the value
    7024             :                 // and the timestamp).
    7025           0 :                 columnUsedCount = 0;
    7026           0 :                 for (kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
    7027           0 :                     curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
    7028           0 :                     switch (ort->MonthlyColumns(curCol).aggType) {
    7029           0 :                     case AggType::SumOrAvg:
    7030             :                     case AggType::ValueWhenMaxMin:
    7031             :                     case AggType::HoursZero:
    7032             :                     case AggType::HoursNonZero:
    7033             :                     case AggType::HoursPositive:
    7034             :                     case AggType::HoursNonPositive:
    7035             :                     case AggType::HoursNegative:
    7036             :                     case AggType::HoursNonNegative:
    7037             :                     case AggType::SumOrAverageHoursShown: {
    7038           0 :                         ++columnUsedCount;
    7039           0 :                     } break;
    7040           0 :                     case AggType::Maximum:
    7041             :                     case AggType::Minimum:
    7042             :                     case AggType::MaximumDuringHoursShown:
    7043             :                     case AggType::MinimumDuringHoursShown: {
    7044           0 :                         columnUsedCount += 2;
    7045           0 :                     } break;
    7046           0 :                     default:
    7047           0 :                         break;
    7048             :                     }
    7049             :                 } // jColumn
    7050           0 :                 columnHead.allocate(columnUsedCount);
    7051           0 :                 columnWidth.dimension(columnUsedCount, 14); // array assignment - same for all columns
    7052           0 :                 tableBody.allocate(columnUsedCount, 16);
    7053           0 :                 tableBody = ""; // set entire table to blank as default
    7054           0 :                 columnRecount = 0;
    7055           0 :                 for (kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
    7056           0 :                     curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
    7057           0 :                     curAggString = aggString.at(ort->MonthlyColumns(curCol).aggType);
    7058           0 :                     if (len(curAggString) > 0) {
    7059           0 :                         curAggString = " {" + stripped(curAggString) + '}';
    7060             :                     }
    7061             :                     // do the unit conversions
    7062           0 :                     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    7063           0 :                         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
    7064             :                         varNameWithUnits =
    7065           0 :                             format("{} [{}]", ort->MonthlyColumns(curCol).varName, Constant::unitNames[(int)ort->MonthlyColumns(curCol).units]);
    7066           0 :                         LookupSItoIP(state, varNameWithUnits, indexUnitConv, curUnits);
    7067           0 :                         GetUnitConversion(state, indexUnitConv, curConversionFactor, state.dataOutRptTab->curConversionOffset, curUnits);
    7068           0 :                     } else if (Util::SameString(Constant::unitNames[(int)ort->MonthlyColumns(curCol).units], "J")) {
    7069           0 :                         curUnits = energyUnitsString;
    7070           0 :                         curConversionFactor = energyUnitsConversionFactor;
    7071           0 :                         state.dataOutRptTab->curConversionOffset = 0.0;
    7072             :                     } else { // if not joules don't perform conversion
    7073           0 :                         curUnits = Constant::unitNames[(int)ort->MonthlyColumns(curCol).units];
    7074           0 :                         curConversionFactor = 1.0;
    7075           0 :                         state.dataOutRptTab->curConversionOffset = 0.0;
    7076             :                     }
    7077           0 :                     switch (ort->MonthlyColumns(curCol).aggType) {
    7078           0 :                     case AggType::SumOrAvg:
    7079             :                     case AggType::SumOrAverageHoursShown: {
    7080           0 :                         ++columnRecount;
    7081             :                         // put in the name of the variable for the column
    7082           0 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + curAggString + " [" + curUnits + ']';
    7083           0 :                         sumVal = 0.0;
    7084           0 :                         sumDuration = 0.0;
    7085           0 :                         minVal = storedMaxVal;
    7086           0 :                         maxVal = storedMinVal;
    7087           0 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7088           0 :                             if (ort->MonthlyColumns(curCol).avgSum ==
    7089             :                                 OutputProcessor::StoreType::Average) { // if it is a average variable divide by duration
    7090           0 :                                 if (ort->MonthlyColumns(curCol).duration(lMonth) != 0) {
    7091           0 :                                     curVal = ((ort->MonthlyColumns(curCol).reslt(lMonth) / ort->MonthlyColumns(curCol).duration(lMonth)) *
    7092             :                                               curConversionFactor) +
    7093           0 :                                              state.dataOutRptTab->curConversionOffset;
    7094             :                                 } else {
    7095           0 :                                     curVal = 0.0;
    7096             :                                 }
    7097           0 :                                 sumVal +=
    7098           0 :                                     (ort->MonthlyColumns(curCol).reslt(lMonth) * curConversionFactor) + state.dataOutRptTab->curConversionOffset;
    7099           0 :                                 sumDuration += ort->MonthlyColumns(curCol).duration(lMonth);
    7100             :                             } else {
    7101           0 :                                 curVal = (ort->MonthlyColumns(curCol).reslt(lMonth) * curConversionFactor) + state.dataOutRptTab->curConversionOffset;
    7102           0 :                                 sumVal += curVal;
    7103             :                             }
    7104           0 :                             if (ort->IsMonthGathered(lMonth)) {
    7105           0 :                                 tableBody(columnRecount, lMonth) = RealToStr(curVal, digitsShown);
    7106           0 :                                 if (curVal > maxVal) maxVal = curVal;
    7107           0 :                                 if (curVal < minVal) minVal = curVal;
    7108             :                             } else {
    7109           0 :                                 tableBody(columnRecount, lMonth) = "-";
    7110             :                             }
    7111             :                         } // lMonth
    7112             :                         // add the summary to bottom
    7113           0 :                         if (ort->MonthlyColumns(curCol).avgSum ==
    7114             :                             OutputProcessor::StoreType::Average) { // if it is a average variable divide by duration
    7115           0 :                             if (sumDuration > 0) {
    7116           0 :                                 tableBody(columnRecount, 14) = RealToStr(sumVal / sumDuration, digitsShown);
    7117             :                             } else {
    7118           0 :                                 tableBody(columnRecount, 14) = "";
    7119             :                             }
    7120             :                         } else {
    7121           0 :                             tableBody(columnRecount, 14) = RealToStr(sumVal, digitsShown);
    7122             :                         }
    7123           0 :                         if (minVal != storedMaxVal) {
    7124           0 :                             tableBody(columnRecount, 15) = RealToStr(minVal, digitsShown);
    7125             :                         }
    7126           0 :                         if (maxVal != storedMinVal) {
    7127           0 :                             tableBody(columnRecount, 16) = RealToStr(maxVal, digitsShown);
    7128             :                         }
    7129           0 :                     } break;
    7130           0 :                     case AggType::HoursZero:
    7131             :                     case AggType::HoursNonZero:
    7132             :                     case AggType::HoursPositive:
    7133             :                     case AggType::HoursNonPositive:
    7134             :                     case AggType::HoursNegative:
    7135             :                     case AggType::HoursNonNegative: {
    7136           0 :                         ++columnRecount;
    7137             :                         // put in the name of the variable for the column
    7138           0 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + curAggString + " [HOURS]";
    7139           0 :                         sumVal = 0.0;
    7140           0 :                         minVal = storedMaxVal;
    7141           0 :                         maxVal = storedMinVal;
    7142           0 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7143           0 :                             curVal = ort->MonthlyColumns(curCol).reslt(lMonth);
    7144           0 :                             if (ort->IsMonthGathered(lMonth)) {
    7145           0 :                                 tableBody(columnRecount, lMonth) = RealToStr(curVal, digitsShown);
    7146           0 :                                 sumVal += curVal;
    7147           0 :                                 if (curVal > maxVal) maxVal = curVal;
    7148           0 :                                 if (curVal < minVal) minVal = curVal;
    7149             :                             } else {
    7150           0 :                                 tableBody(columnRecount, lMonth) = "-";
    7151             :                             }
    7152             :                         } // lMonth
    7153             :                         // add the summary to bottom
    7154           0 :                         tableBody(columnRecount, 14) = RealToStr(sumVal, digitsShown);
    7155           0 :                         if (minVal != storedMaxVal) {
    7156           0 :                             tableBody(columnRecount, 15) = RealToStr(minVal, digitsShown);
    7157             :                         }
    7158           0 :                         if (maxVal != storedMinVal) {
    7159           0 :                             tableBody(columnRecount, 16) = RealToStr(maxVal, digitsShown);
    7160             :                         }
    7161           0 :                     } break;
    7162           0 :                     case AggType::ValueWhenMaxMin: {
    7163           0 :                         ++columnRecount;
    7164           0 :                         if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) {
    7165           0 :                             curUnits += "/s";
    7166             :                         }
    7167           0 :                         if (Util::SameString(curUnits, "J/s")) {
    7168           0 :                             curUnits = "W";
    7169             :                         }
    7170             :                         // CR7783 fix
    7171           0 :                         if (Util::SameString(curUnits, "kWh/s")) {
    7172           0 :                             curUnits = "W";
    7173           0 :                             curConversionFactor *= 3600000.0;
    7174             :                         }
    7175           0 :                         if (Util::SameString(curUnits, "GJ/s")) {
    7176           0 :                             curUnits = "kW";
    7177           0 :                             curConversionFactor *= 1000000.0;
    7178             :                         }
    7179           0 :                         if (Util::SameString(curUnits, "MJ/s")) {
    7180           0 :                             curUnits = "kW";
    7181           0 :                             curConversionFactor *= 1000.0;
    7182             :                         }
    7183           0 :                         if (Util::SameString(curUnits, "therm/s")) {
    7184           0 :                             curUnits = "kBtu/h";
    7185           0 :                             curConversionFactor *= 360000.0;
    7186             :                         }
    7187           0 :                         if (Util::SameString(curUnits, "kBtu/s")) {
    7188           0 :                             curUnits = "kBtu/h";
    7189           0 :                             curConversionFactor *= 3600.0;
    7190             :                         }
    7191           0 :                         if (Util::SameString(curUnits, "ton-hrs/s")) {
    7192           0 :                             curUnits = "ton";
    7193           0 :                             curConversionFactor *= 3600.0;
    7194             :                         }
    7195           0 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + curAggString + " [" + curUnits + ']';
    7196           0 :                         minVal = storedMaxVal;
    7197           0 :                         maxVal = storedMinVal;
    7198           0 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7199           0 :                             curVal = ort->MonthlyColumns(curCol).reslt(lMonth) * curConversionFactor + state.dataOutRptTab->curConversionOffset;
    7200           0 :                             if (ort->IsMonthGathered(lMonth)) {
    7201           0 :                                 tableBody(columnRecount, lMonth) = RealToStr(curVal, digitsShown);
    7202           0 :                                 if (curVal > maxVal) maxVal = curVal;
    7203           0 :                                 if (curVal < minVal) minVal = curVal;
    7204             :                             } else {
    7205           0 :                                 tableBody(columnRecount, lMonth) = "-";
    7206             :                             }
    7207             :                         } // lMonth
    7208             :                         // add the summary to bottom
    7209           0 :                         if (minVal != storedMaxVal) {
    7210           0 :                             tableBody(columnRecount, 15) = RealToStr(minVal, digitsShown);
    7211             :                         }
    7212           0 :                         if (maxVal != storedMinVal) {
    7213           0 :                             tableBody(columnRecount, 16) = RealToStr(maxVal, digitsShown);
    7214             :                         }
    7215           0 :                     } break;
    7216           0 :                     case AggType::Maximum:
    7217             :                     case AggType::Minimum:
    7218             :                     case AggType::MaximumDuringHoursShown:
    7219             :                     case AggType::MinimumDuringHoursShown: {
    7220           0 :                         columnRecount += 2;
    7221             :                         // put in the name of the variable for the column
    7222           0 :                         if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    7223           0 :                             curUnits += "/s";
    7224             :                         }
    7225           0 :                         if (Util::SameString(curUnits, "J/s")) {
    7226           0 :                             curUnits = "W";
    7227             :                         }
    7228             :                         // CR7783 fix
    7229           0 :                         if (Util::SameString(curUnits, "kWh/s")) {
    7230           0 :                             curUnits = "W";
    7231           0 :                             curConversionFactor *= 3600000.0;
    7232             :                         }
    7233           0 :                         if (Util::SameString(curUnits, "GJ/s")) {
    7234           0 :                             curUnits = "kW";
    7235           0 :                             curConversionFactor *= 1000000.0;
    7236             :                         }
    7237           0 :                         if (Util::SameString(curUnits, "MJ/s")) {
    7238           0 :                             curUnits = "kW";
    7239           0 :                             curConversionFactor *= 1000.0;
    7240             :                         }
    7241           0 :                         if (Util::SameString(curUnits, "therm/s")) {
    7242           0 :                             curUnits = "kBtu/h";
    7243           0 :                             curConversionFactor *= 360000.0;
    7244             :                         }
    7245           0 :                         if (Util::SameString(curUnits, "kBtu/s")) {
    7246           0 :                             curUnits = "kBtu/h";
    7247           0 :                             curConversionFactor *= 3600.0;
    7248             :                         }
    7249           0 :                         if (Util::SameString(curUnits, "ton-hrs/s")) {
    7250           0 :                             curUnits = "ton";
    7251           0 :                             curConversionFactor *= 3600.0;
    7252             :                         }
    7253           0 :                         columnHead(columnRecount - 1) = ort->MonthlyColumns(curCol).varName + curAggString + " [" + curUnits + ']';
    7254           0 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + " {TIMESTAMP}";
    7255           0 :                         minVal = storedMaxVal;
    7256           0 :                         maxVal = storedMinVal;
    7257           0 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7258           0 :                             if (ort->IsMonthGathered(lMonth)) {
    7259           0 :                                 curVal = ort->MonthlyColumns(curCol).reslt(lMonth);
    7260             :                                 // CR7788 the conversion factors were causing an overflow for the InchPound case since the
    7261             :                                 // value was very small
    7262             :                                 // restructured the following lines to hide showing HUGE and -HUGE values in output table CR8154 Glazer
    7263           0 :                                 if ((curVal < veryLarge) && (curVal > verySmall)) {
    7264           0 :                                     curVal = curVal * curConversionFactor + state.dataOutRptTab->curConversionOffset;
    7265           0 :                                     if (curVal > maxVal) maxVal = curVal;
    7266           0 :                                     if (curVal < minVal) minVal = curVal;
    7267           0 :                                     if (curVal < veryLarge && curVal > verySmall) {
    7268           0 :                                         tableBody(columnRecount - 1, lMonth) = RealToStr(curVal, digitsShown);
    7269             :                                     } else {
    7270           0 :                                         tableBody(columnRecount - 1, lMonth) = "-";
    7271             :                                     }
    7272           0 :                                     tableBody(columnRecount, lMonth) = DateToString(ort->MonthlyColumns(curCol).timeStamp(lMonth));
    7273             :                                 } else {
    7274           0 :                                     tableBody(columnRecount - 1, lMonth) = "-";
    7275           0 :                                     tableBody(columnRecount, lMonth) = "-";
    7276             :                                 }
    7277             :                             } else {
    7278           0 :                                 tableBody(columnRecount - 1, lMonth) = "-";
    7279           0 :                                 tableBody(columnRecount, lMonth) = "-";
    7280             :                             }
    7281             :                         } // lMonth
    7282             :                         // add the summary to bottom
    7283             :                         // Don't include if the original min and max values are still present
    7284           0 :                         if (minVal < veryLarge) {
    7285           0 :                             tableBody(columnRecount - 1, 15) = RealToStr(minVal, digitsShown);
    7286             :                         } else {
    7287           0 :                             tableBody(columnRecount - 1, 15) = "-";
    7288             :                         }
    7289           0 :                         if (maxVal > verySmall) {
    7290           0 :                             tableBody(columnRecount - 1, 16) = RealToStr(maxVal, digitsShown);
    7291             :                         } else {
    7292           0 :                             tableBody(columnRecount - 1, 15) = "-";
    7293             :                         }
    7294           0 :                     } break;
    7295           0 :                     default:
    7296           0 :                         break;
    7297             :                     }
    7298             :                 } // KColumn
    7299           0 :                 if (produceTabular) {
    7300           0 :                     WriteReportHeaders(
    7301           0 :                         state, ort->MonthlyInput(iInput).name, ort->MonthlyTables(curTable).keyValue, OutputProcessor::StoreType::Average);
    7302           0 :                     WriteSubtitle(state, "Custom Monthly Report");
    7303           0 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth, true); // transpose monthly XML tables.
    7304             :                 }
    7305           0 :                 if (produceSQLite) {
    7306           0 :                     if (state.dataSQLiteProcedures->sqlite) {
    7307           0 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    7308             :                                                                                            rowHead,
    7309             :                                                                                            columnHead,
    7310           0 :                                                                                            ort->MonthlyInput(iInput).name,
    7311           0 :                                                                                            ort->MonthlyTables(curTable).keyValue,
    7312             :                                                                                            "Custom Monthly Report");
    7313             :                     }
    7314             :                 }
    7315           0 :                 if (produceTabular) {
    7316           0 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    7317           0 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    7318             :                                                                                                               rowHead,
    7319             :                                                                                                               columnHead,
    7320           0 :                                                                                                               ort->MonthlyInput(iInput).name,
    7321           0 :                                                                                                               ort->MonthlyTables(curTable).keyValue,
    7322             :                                                                                                               "Custom Monthly Report");
    7323             :                     }
    7324             :                 }
    7325             :             } // jTables
    7326             :         }     // iInput
    7327             :     }
    7328           5 : }
    7329             : 
    7330           5 : void WriteTimeBinTables(EnergyPlusData &state)
    7331             : {
    7332             :     // SUBROUTINE INFORMATION:
    7333             :     //       AUTHOR         Jason Glazer
    7334             :     //       DATE WRITTEN   August 2003
    7335             :     //       MODIFIED       January 2010, Kyle Benne
    7336             :     //                      Added SQLite output
    7337             :     //       RE-ENGINEERED  na
    7338             : 
    7339             :     // PURPOSE OF THIS SUBROUTINE:
    7340             :     //   Set up the time bin tabular report results
    7341             : 
    7342             :     // METHODOLOGY EMPLOYED:
    7343             :     //   Creates several arrays that are passed to the WriteTable
    7344             :     //   routine.  All arrays are strings so numbers need to be
    7345             :     //   converted prior to calling WriteTable.
    7346             : 
    7347             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    7348             :     // main table
    7349           5 :     Array1D_string columnHead;
    7350           5 :     Array1D_int columnWidth;
    7351           5 :     Array1D_string rowHead(39);
    7352           5 :     Array2D_string tableBody;
    7353             :     // stat table
    7354           5 :     Array1D_string columnHeadStat(1);
    7355           5 :     Array1D_int columnWidthStat(1);
    7356           5 :     Array1D_string rowHeadStat(6);
    7357          10 :     Array2D_string tableBodyStat(1, 6);
    7358             : 
    7359           5 :     std::string repNameWithUnitsandscheduleName;
    7360           5 :     std::string curNameWithSIUnits;
    7361           5 :     std::string curNameAndUnits;
    7362             : 
    7363           5 :     auto &ort = state.dataOutRptTab;
    7364             : 
    7365          10 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    7366          10 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    7367          10 :         bool produceTabular = true;
    7368          10 :         bool produceSQLite = false;
    7369          10 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
    7370             : 
    7371           5 :         rowHead(1) = "Interval Start";
    7372           5 :         rowHead(2) = "Interval End";
    7373           5 :         rowHead(3) = "January";
    7374           5 :         rowHead(4) = "February";
    7375           5 :         rowHead(5) = "March";
    7376           5 :         rowHead(6) = "April";
    7377           5 :         rowHead(7) = "May";
    7378           5 :         rowHead(8) = "June";
    7379           5 :         rowHead(9) = "July";
    7380           5 :         rowHead(10) = "August";
    7381           5 :         rowHead(11) = "September";
    7382           5 :         rowHead(12) = "October";
    7383           5 :         rowHead(13) = "November";
    7384           5 :         rowHead(14) = "December";
    7385           5 :         rowHead(15) = "12:01 to  1:00 am";
    7386           5 :         rowHead(16) = " 1:01 to  2:00 am";
    7387           5 :         rowHead(17) = " 2:01 to  3:00 am";
    7388           5 :         rowHead(18) = " 3:01 to  4:00 am";
    7389           5 :         rowHead(19) = " 4:01 to  5:00 am";
    7390           5 :         rowHead(20) = " 5:01 to  6:00 am";
    7391           5 :         rowHead(21) = " 6:01 to  7:00 am";
    7392           5 :         rowHead(22) = " 7:01 to  8:00 am";
    7393           5 :         rowHead(23) = " 8:01 to  9:00 am";
    7394           5 :         rowHead(24) = " 9:01 to 10:00 am";
    7395           5 :         rowHead(25) = "10:01 to 11:00 am";
    7396           5 :         rowHead(26) = "11:01 to 12:00 pm";
    7397           5 :         rowHead(27) = "12:01 to  1:00 pm";
    7398           5 :         rowHead(28) = " 1:01 to  2:00 pm";
    7399           5 :         rowHead(29) = " 2:01 to  3:00 pm";
    7400           5 :         rowHead(30) = " 3:01 to  4:00 pm";
    7401           5 :         rowHead(31) = " 4:01 to  5:00 pm";
    7402           5 :         rowHead(32) = " 5:01 to  6:00 pm";
    7403           5 :         rowHead(33) = " 6:01 to  7:00 pm";
    7404           5 :         rowHead(34) = " 7:01 to  8:00 pm";
    7405           5 :         rowHead(35) = " 8:01 to  9:00 pm";
    7406           5 :         rowHead(36) = " 9:01 to 10:00 pm";
    7407           5 :         rowHead(37) = "10:01 to 11:00 pm";
    7408           5 :         rowHead(38) = "11:01 to 12:00 am";
    7409           5 :         rowHead(39) = "Total";
    7410             : 
    7411           5 :         for (int iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    7412           0 :             int const firstReport = ort->OutputTableBinned(iInObj).resIndex;
    7413             :             curNameWithSIUnits =
    7414           0 :                 format("{} [{}]", ort->OutputTableBinned(iInObj).varOrMeter, Constant::unitNames[(int)ort->OutputTableBinned(iInObj).units]);
    7415             :             Real64 curIntervalStart;
    7416             :             Real64 curIntervalSize;
    7417           0 :             int indexUnitConv = -1;
    7418           0 :             if (unitsStyle_cur == UnitsStyle::InchPound) {
    7419           0 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    7420           0 :                 curIntervalStart = ConvertIP(state, indexUnitConv, ort->OutputTableBinned(iInObj).intervalStart);
    7421           0 :                 curIntervalSize = ConvertIPdelta(state, indexUnitConv, ort->OutputTableBinned(iInObj).intervalSize);
    7422           0 :             } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
    7423           0 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    7424           0 :                 curIntervalStart = ConvertIP(state, indexUnitConv, ort->OutputTableBinned(iInObj).intervalStart);
    7425           0 :                 curIntervalSize = ConvertIPdelta(state, indexUnitConv, ort->OutputTableBinned(iInObj).intervalSize);
    7426             :             } else {
    7427           0 :                 curNameAndUnits = curNameWithSIUnits;
    7428           0 :                 curIntervalStart = ort->OutputTableBinned(iInObj).intervalStart;
    7429           0 :                 curIntervalSize = ort->OutputTableBinned(iInObj).intervalSize;
    7430             :             }
    7431           0 :             int const curIntervalCount = ort->OutputTableBinned(iInObj).intervalCount;
    7432           0 :             int const curNumTables = ort->OutputTableBinned(iInObj).numTables;
    7433           0 :             Real64 const topValue = curIntervalStart + curIntervalSize * curIntervalCount;
    7434           0 :             int numIntervalDigits = 2;
    7435           0 :             if (curIntervalSize < 1) {
    7436           0 :                 numIntervalDigits = 4;
    7437           0 :             } else if (curIntervalSize >= 10) {
    7438           0 :                 numIntervalDigits = 0;
    7439             :             }
    7440           0 :             int const numCols = curIntervalCount + 3;
    7441             :             // make arrays two columns wider for below and above bin range
    7442           0 :             columnHead.allocate(numCols);
    7443           0 :             columnWidth.allocate(numCols);
    7444           0 :             columnWidth = 14; // array assignment - same for all columns
    7445           0 :             tableBody.allocate(numCols, 39);
    7446           0 :             tableBody = "";
    7447           0 :             columnHead = "- [hr]";
    7448           0 :             tableBody(1, 1) = "less than";
    7449           0 :             tableBody(1, 2) = RealToStr(curIntervalStart, numIntervalDigits);
    7450           0 :             for (int nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7451           0 :                 columnHead(nCol + 1) = fmt::format("{} [hr]", nCol);
    7452             :                 // beginning of interval
    7453           0 :                 tableBody(nCol + 1, 1) = RealToStr(curIntervalStart + (nCol - 1) * curIntervalSize, numIntervalDigits) + "<=";
    7454             :                 // end of interval
    7455           0 :                 tableBody(nCol + 1, 2) = RealToStr(curIntervalStart + nCol * curIntervalSize, numIntervalDigits) + '>';
    7456             :             }
    7457           0 :             tableBody(curIntervalCount + 2, 1) = "equal to or more than";
    7458           0 :             tableBody(curIntervalCount + 2, 2) = RealToStr(topValue, numIntervalDigits);
    7459           0 :             tableBody(numCols, 1) = "Row";
    7460           0 :             tableBody(numCols, 2) = "Total";
    7461           0 :             for (int iTable = 1; iTable <= curNumTables; ++iTable) {
    7462           0 :                 int const repIndex = firstReport + (iTable - 1);
    7463           0 :                 if (ort->OutputTableBinned(iInObj).scheduleIndex == 0) {
    7464           0 :                     repNameWithUnitsandscheduleName = curNameAndUnits;
    7465             :                 } else {
    7466           0 :                     repNameWithUnitsandscheduleName = curNameAndUnits + " [" + ort->OutputTableBinned(iInObj).ScheduleName + ']';
    7467             :                 }
    7468           0 :                 if (produceTabular) {
    7469           0 :                     WriteReportHeaders(
    7470           0 :                         state, repNameWithUnitsandscheduleName, ort->BinObjVarID(repIndex).namesOfObj, ort->OutputTableBinned(iInObj).avgSum);
    7471             :                 }
    7472           0 :                 for (int kHour = 1; kHour <= 24; ++kHour) {
    7473           0 :                     tableBody(1, 14 + kHour) = RealToStr(ort->BinResultsBelow(repIndex).hrly(kHour), 2);
    7474           0 :                     tableBody(curIntervalCount + 2, 14 + kHour) = RealToStr(ort->BinResultsAbove(repIndex).hrly(kHour), 2);
    7475           0 :                     Real64 rowTotal = ort->BinResultsBelow(repIndex).hrly(kHour) + ort->BinResultsAbove(repIndex).hrly(kHour);
    7476           0 :                     for (int nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7477           0 :                         tableBody(nCol + 1, 14 + kHour) = RealToStr(ort->BinResults(nCol, repIndex).hrly(kHour), 2);
    7478             :                         // sum the total for all columns
    7479           0 :                         rowTotal += ort->BinResults(nCol, repIndex).hrly(kHour);
    7480             :                     }
    7481           0 :                     tableBody(numCols, 14 + kHour) = RealToStr(rowTotal, 2);
    7482             :                 }
    7483           0 :                 Real64 tableTotal = 0.0;
    7484           0 :                 for (int kMonth = 1; kMonth <= 12; ++kMonth) {
    7485           0 :                     tableBody(1, 2 + kMonth) = RealToStr(ort->BinResultsBelow(repIndex).mnth(kMonth), 2);
    7486           0 :                     tableBody(curIntervalCount + 2, 2 + kMonth) = RealToStr(ort->BinResultsAbove(repIndex).mnth(kMonth), 2);
    7487           0 :                     Real64 rowTotal = ort->BinResultsBelow(repIndex).mnth(kMonth) + ort->BinResultsAbove(repIndex).mnth(kMonth);
    7488           0 :                     for (int nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7489           0 :                         tableBody(nCol + 1, 2 + kMonth) = RealToStr(ort->BinResults(nCol, repIndex).mnth(kMonth), 2);
    7490             :                         // sum the total for all columns
    7491           0 :                         rowTotal += ort->BinResults(nCol, repIndex).mnth(kMonth);
    7492             :                     }
    7493           0 :                     tableBody(numCols, 2 + kMonth) = RealToStr(rowTotal, 2);
    7494           0 :                     tableTotal += rowTotal;
    7495             :                 }
    7496             :                 // compute total row
    7497           0 :                 for (int nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7498           0 :                     Real64 colTotal = 0.0;
    7499           0 :                     for (int kMonth = 1; kMonth <= 12; ++kMonth) {
    7500           0 :                         colTotal += ort->BinResults(nCol, repIndex).mnth(kMonth);
    7501             :                     }
    7502           0 :                     tableBody(nCol + 1, 39) = RealToStr(colTotal, 2);
    7503             :                 }
    7504           0 :                 Real64 aboveTotal = 0.0;
    7505           0 :                 Real64 belowTotal = 0.0;
    7506           0 :                 for (int kMonth = 1; kMonth <= 12; ++kMonth) {
    7507           0 :                     aboveTotal += ort->BinResultsAbove(repIndex).mnth(kMonth);
    7508           0 :                     belowTotal += ort->BinResultsBelow(repIndex).mnth(kMonth);
    7509             :                 }
    7510           0 :                 tableBody(1, 39) = RealToStr(belowTotal, 2);
    7511           0 :                 tableBody(curIntervalCount + 2, 39) = RealToStr(aboveTotal, 2);
    7512           0 :                 tableBody(numCols, 39) = RealToStr(tableTotal, 2);
    7513           0 :                 if (produceTabular) {
    7514           0 :                     WriteTextLine(state, "Values in table are in hours.");
    7515           0 :                     WriteTextLine(state, "");
    7516           0 :                     WriteSubtitle(state, "Time Bin Results");
    7517           0 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth, true); // transpose XML tables
    7518             :                 }
    7519           0 :                 if (produceSQLite) {
    7520           0 :                     if (state.dataSQLiteProcedures->sqlite) {
    7521           0 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    7522             :                                                                                            rowHead,
    7523             :                                                                                            columnHead,
    7524             :                                                                                            repNameWithUnitsandscheduleName,
    7525           0 :                                                                                            ort->BinObjVarID(repIndex).namesOfObj,
    7526             :                                                                                            "Time Bin Results");
    7527             :                     }
    7528             :                 }
    7529           0 :                 if (produceTabular) {
    7530           0 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    7531           0 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    7532             :                                                                                                               rowHead,
    7533             :                                                                                                               columnHead,
    7534             :                                                                                                               repNameWithUnitsandscheduleName,
    7535           0 :                                                                                                               ort->BinObjVarID(repIndex).namesOfObj,
    7536             :                                                                                                               "Time Bin Results");
    7537             :                     }
    7538             :                 }
    7539             :                 // create statistics table
    7540           0 :                 rowHeadStat(1) = "Minimum";
    7541           0 :                 rowHeadStat(2) = "Mean minus two standard deviations";
    7542           0 :                 rowHeadStat(3) = "Mean";
    7543           0 :                 rowHeadStat(4) = "Mean plus two standard deviations";
    7544           0 :                 rowHeadStat(5) = "Maximum";
    7545           0 :                 rowHeadStat(6) = "Standard deviation";
    7546           0 :                 columnHeadStat(1) = "Statistic";
    7547           0 :                 columnWidthStat(1) = 14;
    7548             :                 // per Applied Regression Analysis and Other Multivariate Methods, Kleinburger/Kupper, 1978
    7549             :                 // first check if very large constant number has caused the second part to be larger than the first
    7550           0 :                 Real64 repStDev = 0.0;
    7551           0 :                 Real64 repMean = 0.0;
    7552             : 
    7553           0 :                 if (ort->BinStatistics(repIndex).n > 1) {
    7554           0 :                     if (ort->BinStatistics(repIndex).sum2 > (pow_2(ort->BinStatistics(repIndex).sum) / ort->BinStatistics(repIndex).n)) {
    7555           0 :                         repStDev = std::sqrt(
    7556           0 :                             (ort->BinStatistics(repIndex).sum2 - (pow_2(ort->BinStatistics(repIndex).sum) / ort->BinStatistics(repIndex).n)) /
    7557           0 :                             (ort->BinStatistics(repIndex).n - 1));
    7558             :                     } else {
    7559           0 :                         repStDev = 0.0;
    7560             :                     }
    7561           0 :                     repMean = ort->BinStatistics(repIndex).sum / ort->BinStatistics(repIndex).n;
    7562             :                 }
    7563             : 
    7564           0 :                 if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    7565           0 :                     unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
    7566           0 :                     tableBodyStat(1, 1) = RealToStr(ConvertIP(state, indexUnitConv, ort->BinStatistics(repIndex).minimum), 2);
    7567           0 :                     tableBodyStat(1, 2) = RealToStr(ConvertIP(state, indexUnitConv, repMean - 2 * repStDev), 2);
    7568           0 :                     tableBodyStat(1, 3) = RealToStr(ConvertIP(state, indexUnitConv, repMean), 2);
    7569           0 :                     tableBodyStat(1, 4) = RealToStr(ConvertIP(state, indexUnitConv, repMean + 2 * repStDev), 2);
    7570           0 :                     tableBodyStat(1, 5) = RealToStr(ConvertIP(state, indexUnitConv, ort->BinStatistics(repIndex).maximum), 2);
    7571           0 :                     tableBodyStat(1, 6) = RealToStr(ConvertIPdelta(state, indexUnitConv, repStDev), 2);
    7572             :                 } else {
    7573           0 :                     tableBodyStat(1, 1) = RealToStr(ort->BinStatistics(repIndex).minimum, 2);
    7574           0 :                     tableBodyStat(1, 2) = RealToStr(repMean - 2 * repStDev, 2);
    7575           0 :                     tableBodyStat(1, 3) = RealToStr(repMean, 2);
    7576           0 :                     tableBodyStat(1, 4) = RealToStr(repMean + 2 * repStDev, 2);
    7577           0 :                     tableBodyStat(1, 5) = RealToStr(ort->BinStatistics(repIndex).maximum, 2);
    7578           0 :                     tableBodyStat(1, 6) = RealToStr(repStDev, 2);
    7579             :                 }
    7580           0 :                 if (produceTabular) {
    7581           0 :                     WriteSubtitle(state, "Statistics");
    7582           0 :                     WriteTable(state, tableBodyStat, rowHeadStat, columnHeadStat, columnWidthStat, true); // transpose XML table
    7583             :                 }
    7584           0 :                 if (produceSQLite) {
    7585           0 :                     if (state.dataSQLiteProcedures->sqlite) {
    7586           0 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    7587           0 :                             tableBody, rowHead, columnHead, repNameWithUnitsandscheduleName, ort->BinObjVarID(repIndex).namesOfObj, "Statistics");
    7588             :                     }
    7589             :                 }
    7590           0 :                 if (produceTabular) {
    7591           0 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    7592           0 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    7593           0 :                             tableBody, rowHead, columnHead, repNameWithUnitsandscheduleName, ort->BinObjVarID(repIndex).namesOfObj, "Statistics");
    7594             :                     }
    7595             :                 }
    7596             :             }
    7597             :         }
    7598             :     }
    7599           5 : }
    7600             : 
    7601         754 : void WriteBEPSTable(EnergyPlusData &state)
    7602             : {
    7603             :     // SUBROUTINE INFORMATION:
    7604             :     //       AUTHOR         Jason Glazer
    7605             :     //       DATE WRITTEN   November 2003
    7606             :     //       MODIFIED       January 2010, Kyle Benne; Added SQLite output
    7607             :     //                      March 2020, Dareum Nam; Disaggregated "Additional Fuel"
    7608             : 
    7609             :     // PURPOSE OF THIS SUBROUTINE:
    7610             :     //   Take the gathered total and enduse meter data and structure
    7611             :     //   the results into a tabular report for output.
    7612             : 
    7613             :     // METHODOLOGY EMPLOYED:
    7614             :     //   Create arrays for the call to WriteTable and then call it.
    7615             :     //   This report actually consists of many sub-tables each with
    7616             :     //   its own call to WriteTable.  Anytime that column headings are
    7617             :     //   desired they are done in a new table because the only place
    7618             :     //   that will split up very long header lines for the fixed width
    7619             :     //   table is the header rows.
    7620             : 
    7621         754 :     int constexpr colElectricity(1);
    7622         754 :     int constexpr colGas(2);
    7623         754 :     int constexpr colGasoline(3);
    7624         754 :     int constexpr colDiesel(4);
    7625         754 :     int constexpr colCoal(5);
    7626         754 :     int constexpr colFuelOilNo1(6);
    7627         754 :     int constexpr colFuelOilNo2(7);
    7628         754 :     int constexpr colPropane(8);
    7629         754 :     int constexpr colOtherFuel1(9);
    7630         754 :     int constexpr colOtherFuel2(10);
    7631         754 :     int constexpr colPurchCool(11);
    7632         754 :     int constexpr colPurchHeatWtr(12);
    7633         754 :     int constexpr colPurchHeatSt(13);
    7634             : 
    7635         754 :     Real64 constexpr SmallValue(1.e-14);
    7636         754 :     auto &ort = state.dataOutRptTab;
    7637         754 :     auto &op = state.dataOutputProcessor;
    7638             : 
    7639         754 :     if (!ort->displayTabularBEPS && !ort->displayLEEDSummary) {
    7640           2 :         return;
    7641             :     }
    7642             : 
    7643             :     // all arrays are in the format: (row, column)
    7644         752 :     Array1D_string columnHead;
    7645         752 :     Array1D_int columnWidth;
    7646         752 :     Array1D_string rowHead;
    7647         752 :     Array2D_string tableBody;
    7648             : 
    7649        1504 :     Array2D<Real64> useVal(14, 15);
    7650        1504 :     Array2D<Real64> normalVal(14, 4);
    7651         752 :     Array1D<Real64> collapsedTotal(14);
    7652        1504 :     Array2D<Real64> collapsedEndUse(14, static_cast<int>(Constant::EndUse::Num));
    7653        1504 :     Array3D<Real64> collapsedEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
    7654        1504 :     Array2D<Real64> endUseSubOther(14, static_cast<int>(Constant::EndUse::Num));
    7655        1504 :     Array3D<Real64> collapsedEndUseSpType(state.dataOutputProcessor->maxNumEndUseSpaceTypes, static_cast<int>(Constant::EndUse::Num), 14);
    7656             : 
    7657             :     // Jan 2021: Added temp storage
    7658         752 :     Real64 gtPowerFuelFireGen = ort->gatherPowerFuelFireGen;
    7659         752 :     Real64 gtPowerPV = ort->gatherPowerPV;
    7660         752 :     Real64 gtPowerWind = ort->gatherPowerWind;
    7661         752 :     Real64 gtPowerHTGeothermal = ort->gatherPowerHTGeothermal;
    7662         752 :     Real64 gtPowerConversion = ort->gatherPowerConversion;
    7663         752 :     Real64 gtElecProduced = ort->gatherElecProduced;
    7664         752 :     Real64 gtElecPUrchased = ort->gatherElecPurchased;
    7665         752 :     Real64 gtElecSurplusSold = ort->gatherElecSurplusSold;
    7666             : 
    7667         752 :     Real64 gtWaterHeatRecovery = ort->gatherWaterHeatRecovery;
    7668         752 :     Real64 gtAirHeatRecoveryCool = ort->gatherAirHeatRecoveryCool;
    7669         752 :     Real64 gtAirHeatRecoveryHeat = ort->gatherAirHeatRecoveryHeat;
    7670         752 :     Real64 gtHeatHTGeothermal = ort->gatherHeatHTGeothermal;
    7671         752 :     Real64 gtHeatSolarWater = ort->gatherHeatSolarWater;
    7672         752 :     Real64 gtHeatSolarAir = ort->gatherHeatSolarAir;
    7673             : 
    7674             :     // show the headers of the report
    7675         752 :     if (ort->displayTabularBEPS) {
    7676         752 :         WriteReportHeaders(state, "Annual Building Utility Performance Summary", "Entire Facility", OutputProcessor::StoreType::Average);
    7677             :         // show the number of hours that the table applies to
    7678         752 :         WriteTextLine(state, "Values gathered over " + RealToStr(ort->gatherElapsedTimeBEPS, 2) + " hours", true);
    7679         752 :         if (ort->gatherElapsedTimeBEPS < 8759.0) { // might not add up to 8760 exactly but can't be more than 1 hour diff.
    7680         747 :             WriteTextLine(state, "WARNING: THE REPORT DOES NOT REPRESENT A FULL ANNUAL SIMULATION.", true);
    7681             :         }
    7682         752 :         WriteTextLine(state, "", true);
    7683             :     }
    7684             : 
    7685        1504 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    7686        1504 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    7687        1504 :         bool produceTabular = true;
    7688        1504 :         bool produceSQLite = false;
    7689        1504 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
    7690             : 
    7691             :         // determine building floor areas
    7692         752 :         DetermineBuildingFloorArea(state);
    7693             :         // collapse the gatherEndUseBEPS array to the resource groups displayed
    7694       11280 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7695       10528 :             collapsedEndUse(1, jEndUse) = ort->gatherEndUseBEPS(1, jEndUse);   // electricity
    7696       10528 :             collapsedEndUse(2, jEndUse) = ort->gatherEndUseBEPS(2, jEndUse);   // natural gas
    7697       10528 :             collapsedEndUse(3, jEndUse) = ort->gatherEndUseBEPS(6, jEndUse);   // gasoline
    7698       10528 :             collapsedEndUse(4, jEndUse) = ort->gatherEndUseBEPS(8, jEndUse);   // diesel
    7699       10528 :             collapsedEndUse(5, jEndUse) = ort->gatherEndUseBEPS(9, jEndUse);   // coal
    7700       10528 :             collapsedEndUse(6, jEndUse) = ort->gatherEndUseBEPS(10, jEndUse);  // Fuel Oil No1
    7701       10528 :             collapsedEndUse(7, jEndUse) = ort->gatherEndUseBEPS(11, jEndUse);  // Fuel Oil No2
    7702       10528 :             collapsedEndUse(8, jEndUse) = ort->gatherEndUseBEPS(12, jEndUse);  // propane
    7703       10528 :             collapsedEndUse(9, jEndUse) = ort->gatherEndUseBEPS(13, jEndUse);  // otherfuel1
    7704       10528 :             collapsedEndUse(10, jEndUse) = ort->gatherEndUseBEPS(14, jEndUse); // otherfuel2
    7705       10528 :             collapsedEndUse(11, jEndUse) = ort->gatherEndUseBEPS(3, jEndUse);  // district cooling <- purchased cooling
    7706       10528 :             collapsedEndUse(12, jEndUse) = ort->gatherEndUseBEPS(4, jEndUse);  // district heating water <- purchased heating
    7707       10528 :             collapsedEndUse(13, jEndUse) = ort->gatherEndUseBEPS(5, jEndUse);  // district heating steam  <- purchased heating
    7708       10528 :             collapsedEndUse(14, jEndUse) = ort->gatherEndUseBEPS(7, jEndUse);  // water
    7709             :         }
    7710             :         // repeat with totals
    7711         752 :         collapsedTotal(1) = ort->gatherTotalsBEPS(1);   // electricity
    7712         752 :         collapsedTotal(2) = ort->gatherTotalsBEPS(2);   // natural gas
    7713         752 :         collapsedTotal(3) = ort->gatherTotalsBEPS(6);   // gasoline
    7714         752 :         collapsedTotal(4) = ort->gatherTotalsBEPS(8);   // diesel
    7715         752 :         collapsedTotal(5) = ort->gatherTotalsBEPS(9);   // coal
    7716         752 :         collapsedTotal(6) = ort->gatherTotalsBEPS(10);  // Fuel Oil No1
    7717         752 :         collapsedTotal(7) = ort->gatherTotalsBEPS(11);  // Fuel Oil No2
    7718         752 :         collapsedTotal(8) = ort->gatherTotalsBEPS(12);  // propane
    7719         752 :         collapsedTotal(9) = ort->gatherTotalsBEPS(13);  // other fuel 1
    7720         752 :         collapsedTotal(10) = ort->gatherTotalsBEPS(14); // other fuel 2
    7721         752 :         collapsedTotal(11) = ort->gatherTotalsBEPS(3);  // district cooling <- purchased cooling
    7722         752 :         collapsedTotal(12) = ort->gatherTotalsBEPS(4);  // district heating water <- purchased heating
    7723         752 :         collapsedTotal(13) = ort->gatherTotalsBEPS(5);  // distrcit heating steam  <- purchased heating
    7724         752 :         collapsedTotal(14) = ort->gatherTotalsBEPS(7);  // water
    7725             : 
    7726         752 :         if (produceTabular) {
    7727         752 :             if (state.dataGlobal->createPerfLog) {
    7728           3 :                 Util::appendPerfLog(state, "Electricity ABUPS Total [J]", format("{:.3R}", collapsedTotal(1)));
    7729           3 :                 Util::appendPerfLog(state, "Natural Gas ABUPS Total [J]", format("{:.3R}", collapsedTotal(2)));
    7730           3 :                 Util::appendPerfLog(state, "Gasoline ABUPS Total [J]", format("{:.3R}", collapsedTotal(3)));
    7731           3 :                 Util::appendPerfLog(state, "Diesel ABUPS Total [J]", format("{:.3R}", collapsedTotal(4)));
    7732           3 :                 Util::appendPerfLog(state, "Coal ABUPS Total [J]", format("{:.3R}", collapsedTotal(5)));
    7733           3 :                 Util::appendPerfLog(state, "Fuel Oil No 1 ABUPS Total [J]", format("{:.3R}", collapsedTotal(6)));
    7734           3 :                 Util::appendPerfLog(state, "Fuel Oil No 2 ABUPS Total [J]", format("{:.3R}", collapsedTotal(7)));
    7735           3 :                 Util::appendPerfLog(state, "Propane ABUPS Total [J]", format("{:.3R}", collapsedTotal(8)));
    7736           3 :                 Util::appendPerfLog(state, "Other Fuel 1 ABUPS Total [J]", format("{:.3R}", collapsedTotal(9)));
    7737           3 :                 Util::appendPerfLog(state, "Other Fuel 2 ABUPS Total [J]", format("{:.3R}", collapsedTotal(10)));
    7738           3 :                 Util::appendPerfLog(state, "District Cooling ABUPS Total [J]", format("{:.3R}", collapsedTotal(11)));
    7739           3 :                 Util::appendPerfLog(state, "District Heating Water ABUPS Total [J]", format("{:.3R}", collapsedTotal(12)));
    7740           3 :                 Util::appendPerfLog(state, "District Heating Steam ABUPS Total [J]", format("{:.3R}", collapsedTotal(13)));
    7741           3 :                 Util::appendPerfLog(state, "Water ABUPS Total [m3]", format("{:.3R}", collapsedTotal(14)));
    7742           3 :                 Util::appendPerfLog(state, "Values Gathered Over [hours]", format("{:.2R}", ort->gatherElapsedTimeBEPS));
    7743           3 :                 Util::appendPerfLog(state,
    7744             :                                     "Facility Any Zone Oscillating Temperatures Time [hours]",
    7745           6 :                                     format("{:.2R}", state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillate));
    7746           3 :                 Util::appendPerfLog(state,
    7747             :                                     "Facility Any Zone Oscillating Temperatures During Occupancy Time [hours]",
    7748           6 :                                     format("{:.2R}", state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillateDuringOccupancy));
    7749           3 :                 Util::appendPerfLog(state,
    7750             :                                     "Facility Any Zone Oscillating Temperatures in Deadband Time [hours]",
    7751           6 :                                     format("{:.2R}", state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillateInDeadband));
    7752             :             }
    7753             :         }
    7754       11280 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7755       16761 :             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    7756        6233 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 1) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 1);   // electricity
    7757        6233 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 2) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 2);   // natural gas
    7758        6233 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 3) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 6);   // gasoline
    7759        6233 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 4) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 8);   // diesel
    7760        6233 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 5) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 9);   // coal
    7761        6233 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 6) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 10);  // Fuel Oil No1
    7762        6233 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 7) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 11);  // Fuel Oil No2
    7763        6233 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 8) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 12);  // propane
    7764        6233 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 9) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 13);  // otherfuel1
    7765        6233 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 10) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 14); // otherfuel2
    7766        6233 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 11) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 3);  // district cooling <- purch cooling
    7767       12466 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 12) =
    7768        6233 :                     ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 4); // district heating water <- purch heating
    7769       12466 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 13) =
    7770        6233 :                     ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 5); // district heating steam <- purch heating
    7771        6233 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 14) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 7); // water
    7772             :             }
    7773             : 
    7774       11837 :             for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    7775        1309 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 1) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 1);   // electricity
    7776        1309 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 2) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 2);   // natural gas
    7777        1309 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 3) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 6);   // gasoline
    7778        1309 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 4) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 8);   // diesel
    7779        1309 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 5) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 9);   // coal
    7780        1309 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 6) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 10);  // Fuel Oil No1
    7781        1309 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 7) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 11);  // Fuel Oil No2
    7782        1309 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 8) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 12);  // propane
    7783        1309 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 9) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 13);  // otherfuel1
    7784        1309 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 10) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 14); // otherfuel2
    7785        2618 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 11) =
    7786        1309 :                     ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 3); // district cooling <- purch cooling
    7787        2618 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 12) =
    7788        1309 :                     ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 4); // district heating water <- purch heating
    7789        2618 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 13) =
    7790        1309 :                     ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 5); // district heating steam <- purch heating
    7791        1309 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 14) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 7); // water
    7792             :             }
    7793             :         }
    7794             :         // unit conversion - all values are used as divisors
    7795             :         Real64 largeConversionFactor;
    7796             :         Real64 kConversionFactor;
    7797             :         Real64 waterConversionFactor;
    7798             :         Real64 areaConversionFactor;
    7799         752 :         Real64 ipElectricityConversionFactor = 1.0;
    7800         752 :         switch (unitsStyle_cur) {
    7801           6 :         case UnitsStyle::JtoKWH: {
    7802           6 :             largeConversionFactor = 3600000.0;
    7803           6 :             kConversionFactor = 1.0;
    7804           6 :             waterConversionFactor = 1.0;
    7805           6 :             areaConversionFactor = 1.0;
    7806           6 :         } break;
    7807          11 :         case UnitsStyle::InchPound: {
    7808          11 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    7809          11 :             kConversionFactor = 1.0;
    7810          11 :             waterConversionFactor = getSpecificUnitDivider(state, "m3", "gal"); // 0.003785413 m3 to gal
    7811          11 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    7812          11 :         } break;
    7813           0 :         case UnitsStyle::InchPoundExceptElectricity: {
    7814           0 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    7815           0 :             kConversionFactor = 1.0;
    7816           0 :             waterConversionFactor = getSpecificUnitDivider(state, "m3", "gal"); // 0.003785413 m3 to gal
    7817           0 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    7818           0 :             ipElectricityConversionFactor = largeConversionFactor / (1000.0 * 3600.0);
    7819           0 :         } break;
    7820         735 :         default: {
    7821         735 :             largeConversionFactor = 1000000000.0;
    7822         735 :             kConversionFactor = 1000.0;
    7823         735 :             waterConversionFactor = 1.0;
    7824         735 :             areaConversionFactor = 1.0;
    7825         735 :         } break;
    7826             :         }
    7827             : 
    7828             :         // convert units into GJ (divide by 1,000,000,000) if J otherwise kWh
    7829       10528 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't do water
    7830        9776 :             Real64 ipElectricityAdjust = (iResource == 1) ? ipElectricityConversionFactor : 1.0;
    7831      146640 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7832      136864 :                 collapsedEndUse(iResource, jEndUse) /= (largeConversionFactor / ipElectricityAdjust);
    7833      217893 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    7834       81029 :                     collapsedEndUseSub(kEndUseSub, jEndUse, iResource) /= (largeConversionFactor / ipElectricityAdjust);
    7835             :                 }
    7836      153881 :                 for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    7837       17017 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, iResource) /= (largeConversionFactor / ipElectricityAdjust);
    7838             :                 }
    7839             :             }
    7840        9776 :             collapsedTotal(iResource) /= (largeConversionFactor / ipElectricityAdjust);
    7841             :         }
    7842             :         // do water
    7843       11280 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7844       10528 :             collapsedEndUse(14, jEndUse) /= waterConversionFactor;
    7845       16761 :             for (int kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    7846        6233 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 14) /= waterConversionFactor;
    7847             :             }
    7848       11837 :             for (int kEndUseSpType = 1; kEndUseSpType <= state.dataOutputProcessor->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    7849        1309 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 14) /= waterConversionFactor;
    7850             :             }
    7851             :         }
    7852             : 
    7853         752 :         collapsedTotal(14) = WaterConversionFunct(collapsedTotal(14), waterConversionFactor);
    7854             : 
    7855         752 :         if (iUnitSystem == 0) {
    7856         752 :             gtPowerFuelFireGen = ort->gatherPowerFuelFireGen;
    7857         752 :             gtPowerPV = ort->gatherPowerPV;
    7858         752 :             gtPowerWind = ort->gatherPowerWind;
    7859         752 :             gtPowerHTGeothermal = ort->gatherPowerHTGeothermal;
    7860         752 :             gtPowerConversion = ort->gatherPowerConversion;
    7861         752 :             gtElecProduced = ort->gatherElecProduced;
    7862         752 :             gtElecPUrchased = ort->gatherElecPurchased;
    7863         752 :             gtElecSurplusSold = ort->gatherElecSurplusSold;
    7864             :         } else { // if(iUnitSystem == 1)
    7865           0 :             ort->gatherPowerFuelFireGen = gtPowerFuelFireGen;
    7866           0 :             ort->gatherPowerPV = gtPowerPV;
    7867           0 :             ort->gatherPowerWind = gtPowerWind;
    7868           0 :             ort->gatherPowerHTGeothermal = gtPowerHTGeothermal;
    7869           0 :             ort->gatherPowerConversion = gtPowerConversion;
    7870           0 :             ort->gatherElecProduced = gtElecProduced;
    7871           0 :             ort->gatherElecPurchased = gtElecPUrchased;
    7872           0 :             ort->gatherElecSurplusSold = gtElecSurplusSold;
    7873             :         }
    7874             :         // convert to GJ
    7875         752 :         Real64 convFactorMulti = ipElectricityConversionFactor / largeConversionFactor;
    7876         752 :         ort->gatherPowerFuelFireGen *= convFactorMulti;
    7877         752 :         ort->gatherPowerPV *= convFactorMulti;
    7878         752 :         ort->gatherPowerWind *= convFactorMulti;
    7879         752 :         ort->gatherPowerHTGeothermal *= convFactorMulti;
    7880         752 :         ort->gatherPowerConversion *= convFactorMulti;
    7881         752 :         ort->gatherElecProduced *= convFactorMulti;
    7882         752 :         ort->gatherElecPurchased *= convFactorMulti;
    7883         752 :         ort->gatherElecSurplusSold *= convFactorMulti;
    7884             : 
    7885             :         // get change in overall state of charge for electrical storage devices.
    7886         752 :         if (state.dataElectPwrSvcMgr->facilityElectricServiceObj->numElecStorageDevices > 0) {
    7887             :             // All flow in/out of storage is accounted for in gatherElecStorage, so separate calculation of change in state of charge is not
    7888             :             // necessary OverallNetEnergyFromStorage = ( sum( ElecStorage.StartingEnergyStored() ) - sum(
    7889             :             // ElecStorage.ThisTimeStepStateOfCharge() ) ) + gatherElecStorage;
    7890           8 :             ort->OverallNetEnergyFromStorage = ort->gatherElecStorage;
    7891           8 :             ort->OverallNetEnergyFromStorage *= convFactorMulti;
    7892             :         } else {
    7893         744 :             ort->OverallNetEnergyFromStorage = 0.0;
    7894             :         }
    7895             :         // determine which resource is the primary heating resourse
    7896         752 :         int resourcePrimaryHeating = 0;
    7897         752 :         Real64 heatingMaximum = 0.0;
    7898       10528 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't do water
    7899        9776 :             if (collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Heating) + 1) > heatingMaximum) {
    7900           6 :                 heatingMaximum = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Heating) + 1); // +1 because enum is 0-based
    7901           6 :                 resourcePrimaryHeating = iResource;
    7902             :             }
    7903             :         }
    7904             : 
    7905             :         //---- Source and Site Energy Sub-Table
    7906         752 :         rowHead.allocate(4);
    7907         752 :         columnHead.allocate(3);
    7908         752 :         columnWidth.allocate(3);
    7909         752 :         columnWidth = 14; // array assignment - same for all columns
    7910         752 :         tableBody.allocate(3, 4);
    7911             : 
    7912         752 :         switch (unitsStyle_cur) {
    7913           6 :         case UnitsStyle::JtoKWH: {
    7914           6 :             columnHead(1) = "Total Energy [kWh]";
    7915           6 :             columnHead(2) = "Energy Per Total Building Area [kWh/m2]";
    7916           6 :             columnHead(3) = "Energy Per Conditioned Building Area [kWh/m2]";
    7917           6 :         } break;
    7918          11 :         case UnitsStyle::InchPound: {
    7919          11 :             columnHead(1) = "Total Energy [kBtu]";
    7920          11 :             columnHead(2) = "Energy Per Total Building Area [kBtu/ft2]";
    7921          11 :             columnHead(3) = "Energy Per Conditioned Building Area [kBtu/ft2]";
    7922          11 :         } break;
    7923           0 :         case UnitsStyle::InchPoundExceptElectricity: {
    7924           0 :             columnHead(1) = "Total Energy [kBtu]";
    7925           0 :             columnHead(2) = "Energy Per Total Building Area [kBtu/ft2]";
    7926           0 :             columnHead(3) = "Energy Per Conditioned Building Area [kBtu/ft2]";
    7927           0 :         } break;
    7928         735 :         default: {
    7929         735 :             columnHead(1) = "Total Energy [GJ]";
    7930         735 :             columnHead(2) = "Energy Per Total Building Area [MJ/m2]";
    7931         735 :             columnHead(3) = "Energy Per Conditioned Building Area [MJ/m2]";
    7932         735 :         } break;
    7933             :         }
    7934             : 
    7935         752 :         rowHead(1) = "Total Site Energy";
    7936         752 :         rowHead(2) = "Net Site Energy";
    7937         752 :         rowHead(3) = "Total Source Energy";
    7938         752 :         rowHead(4) = "Net Source Energy";
    7939             : 
    7940         752 :         tableBody = "";
    7941             : 
    7942             :         // compute the net amount of electricity received from the utility which
    7943             :         // is the amount purchased less the amount sold to the utility. Note that
    7944             :         // previously these variables were converted into GJ so now we don't need
    7945             :         // to do any conversion
    7946             :         // water is not included   gatherTotalsBEPS(7)    !water
    7947             :         Real64 const totalSiteEnergyUse =
    7948         752 :             (ort->gatherTotalsBEPS(1) + ort->gatherTotalsBEPS(2) + ort->gatherTotalsBEPS(3) + ort->gatherTotalsBEPS(4) + ort->gatherTotalsBEPS(5) +
    7949         752 :              ort->gatherTotalsBEPS(6) + ort->gatherTotalsBEPS(8) + ort->gatherTotalsBEPS(9) + ort->gatherTotalsBEPS(10) + ort->gatherTotalsBEPS(11) +
    7950         752 :              ort->gatherTotalsBEPS(12) + ort->gatherTotalsBEPS(13) + ort->gatherTotalsBEPS(14)) /
    7951         752 :             largeConversionFactor; // electricity | natural gas | district cooling | district heating water | district heating steam | gasoline |
    7952             :                                    // diesel | coal | Fuel Oil No1 | Fuel Oil No2 | propane | otherfuel1 | otherfuel2
    7953             : 
    7954         752 :         Real64 const netElecPurchasedSold = ort->gatherElecPurchased - ort->gatherElecSurplusSold;
    7955             : 
    7956             :         // water is not included   gatherTotalsBEPS(7)    !water
    7957             :         Real64 const netSiteEnergyUse =
    7958         752 :             netElecPurchasedSold + (ort->gatherTotalsBEPS(2) + ort->gatherTotalsBEPS(3) + ort->gatherTotalsBEPS(4) + ort->gatherTotalsBEPS(5) +
    7959         752 :                                     ort->gatherTotalsBEPS(6) + ort->gatherTotalsBEPS(8) + ort->gatherTotalsBEPS(9) + ort->gatherTotalsBEPS(10) +
    7960         752 :                                     ort->gatherTotalsBEPS(11) + ort->gatherTotalsBEPS(12) + ort->gatherTotalsBEPS(13) + ort->gatherTotalsBEPS(14)) /
    7961         752 :                                        largeConversionFactor; // electricity (already in GJ) | natural gas | district cooling |
    7962             :                                                               // district heating water | district heating steam | gasoline | diesel | coal | Fuel Oil
    7963             :                                                               // No1 | Fuel Oil No2 | propane | otherfuel1 | otherfuel2
    7964             : 
    7965         752 :         if (ort->efficiencyDistrictCooling == 0) ort->efficiencyDistrictCooling = 1.0;
    7966         752 :         if (ort->efficiencyDistrictHeatingWater == 0) ort->efficiencyDistrictHeatingWater = 1.0;
    7967             : 
    7968             :         // source emissions already have the source factors included in the calcs.
    7969         752 :         Real64 totalSourceEnergyUse = 0.0;
    7970             :         //  electricity
    7971         752 :         if (ort->fuelfactorsused(1)) {
    7972          85 :             totalSourceEnergyUse += ort->gatherTotalsSource(1);
    7973             :         } else {
    7974         667 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(1) * ort->sourceFactorElectric;
    7975             :         }
    7976             :         //  natural gas
    7977         752 :         if (ort->fuelfactorsused(2)) {
    7978          77 :             totalSourceEnergyUse += ort->gatherTotalsSource(2);
    7979             :         } else {
    7980         675 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(2) * ort->sourceFactorNaturalGas;
    7981             :         }
    7982             :         // gasoline
    7983         752 :         if (ort->fuelfactorsused(3)) {
    7984           0 :             totalSourceEnergyUse += ort->gatherTotalsSource(3);
    7985             :         } else {
    7986         752 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(6) * ort->sourceFactorGasoline;
    7987             :         }
    7988             :         // diesel
    7989         752 :         if (ort->fuelfactorsused(4)) {
    7990           2 :             totalSourceEnergyUse += ort->gatherTotalsSource(4);
    7991             :         } else {
    7992         750 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(8) * ort->sourceFactorDiesel;
    7993             :         }
    7994             :         // coal
    7995         752 :         if (ort->fuelfactorsused(5)) {
    7996           0 :             totalSourceEnergyUse += ort->gatherTotalsSource(5);
    7997             :         } else {
    7998         752 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(9) * ort->sourceFactorCoal;
    7999             :         }
    8000             :         // Fuel Oil No1
    8001         752 :         if (ort->fuelfactorsused(6)) {
    8002          21 :             totalSourceEnergyUse += ort->gatherTotalsSource(6);
    8003             :         } else {
    8004         731 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(10) * ort->sourceFactorFuelOil1;
    8005             :         }
    8006             :         // Fuel Oil No2
    8007         752 :         if (ort->fuelfactorsused(7)) {
    8008           0 :             totalSourceEnergyUse += ort->gatherTotalsSource(7);
    8009             :         } else {
    8010         752 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(11) * ort->sourceFactorFuelOil2;
    8011             :         }
    8012             :         // propane
    8013         752 :         if (ort->fuelfactorsused(8)) {
    8014          21 :             totalSourceEnergyUse += ort->gatherTotalsSource(8);
    8015             :         } else {
    8016         731 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(12) * ort->sourceFactorPropane;
    8017             :         }
    8018             :         // otherfuel1
    8019         752 :         if (ort->fuelfactorsused(11)) {
    8020           1 :             totalSourceEnergyUse += ort->gatherTotalsSource(11);
    8021             :         } else {
    8022         751 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(13) * ort->sourceFactorOtherFuel1;
    8023             :         }
    8024             :         // otherfuel2
    8025         752 :         if (ort->fuelfactorsused(12)) {
    8026           0 :             totalSourceEnergyUse += ort->gatherTotalsSource(12);
    8027             :         } else {
    8028         752 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(14) * ort->sourceFactorOtherFuel2;
    8029             :         }
    8030             : 
    8031         752 :         totalSourceEnergyUse = (totalSourceEnergyUse + ort->gatherTotalsBEPS(3) * ort->sourceFactorElectric / ort->efficiencyDistrictCooling +
    8032         752 :                                 ort->gatherTotalsBEPS(4) * ort->sourceFactorNaturalGas / ort->efficiencyDistrictHeatingWater +
    8033         752 :                                 ort->gatherTotalsBEPS(5) * ort->sourceFactorDistrictHeatingSteam) /
    8034             :                                largeConversionFactor; // district cooling | district heating water | district heating steam
    8035             : 
    8036             :         // now determine "net" source from purchased and surplus sold (still in J)
    8037             : 
    8038             :         Real64 netSourceElecPurchasedSold;
    8039         752 :         if (ort->fuelfactorsused(1)) {
    8040          85 :             netSourceElecPurchasedSold = ort->gatherTotalsSource(9) - ort->gatherTotalsSource(10);
    8041             :         } else {
    8042         667 :             netSourceElecPurchasedSold = netElecPurchasedSold * ort->sourceFactorElectric * largeConversionFactor; // back to J
    8043             :         }
    8044             : 
    8045         752 :         Real64 netSourceEnergyUse = 0.0;
    8046             :         //  natural gas
    8047         752 :         if (ort->fuelfactorsused(2)) {
    8048          77 :             netSourceEnergyUse += ort->gatherTotalsSource(2);
    8049             :         } else {
    8050         675 :             netSourceEnergyUse += ort->gatherTotalsBEPS(2) * ort->sourceFactorNaturalGas;
    8051             :         }
    8052             :         // gasoline
    8053         752 :         if (ort->fuelfactorsused(3)) {
    8054           0 :             netSourceEnergyUse += ort->gatherTotalsSource(3);
    8055             :         } else {
    8056         752 :             netSourceEnergyUse += ort->gatherTotalsBEPS(6) * ort->sourceFactorGasoline;
    8057             :         }
    8058             :         // diesel
    8059         752 :         if (ort->fuelfactorsused(4)) {
    8060           2 :             netSourceEnergyUse += ort->gatherTotalsSource(4);
    8061             :         } else {
    8062         750 :             netSourceEnergyUse += ort->gatherTotalsBEPS(8) * ort->sourceFactorDiesel;
    8063             :         }
    8064             :         // coal
    8065         752 :         if (ort->fuelfactorsused(5)) {
    8066           0 :             netSourceEnergyUse += ort->gatherTotalsSource(5);
    8067             :         } else {
    8068         752 :             netSourceEnergyUse += ort->gatherTotalsBEPS(9) * ort->sourceFactorCoal;
    8069             :         }
    8070             :         // Fuel Oil No1
    8071         752 :         if (ort->fuelfactorsused(6)) {
    8072          21 :             netSourceEnergyUse += ort->gatherTotalsSource(6);
    8073             :         } else {
    8074         731 :             netSourceEnergyUse += ort->gatherTotalsBEPS(10) * ort->sourceFactorFuelOil1;
    8075             :         }
    8076             :         // Fuel Oil No2
    8077         752 :         if (ort->fuelfactorsused(7)) {
    8078           0 :             netSourceEnergyUse += ort->gatherTotalsSource(7);
    8079             :         } else {
    8080         752 :             netSourceEnergyUse += ort->gatherTotalsBEPS(11) * ort->sourceFactorFuelOil2;
    8081             :         }
    8082             :         // propane
    8083         752 :         if (ort->fuelfactorsused(8)) {
    8084          21 :             netSourceEnergyUse += ort->gatherTotalsSource(8);
    8085             :         } else {
    8086         731 :             netSourceEnergyUse += ort->gatherTotalsBEPS(12) * ort->sourceFactorPropane;
    8087             :         }
    8088             :         // otherfuel1
    8089         752 :         if (ort->fuelfactorsused(11)) {
    8090           1 :             netSourceEnergyUse += ort->gatherTotalsSource(11);
    8091             :         } else {
    8092         751 :             netSourceEnergyUse += ort->gatherTotalsBEPS(13) * ort->sourceFactorOtherFuel1;
    8093             :         }
    8094             :         // otherfuel2
    8095         752 :         if (ort->fuelfactorsused(12)) {
    8096           0 :             netSourceEnergyUse += ort->gatherTotalsSource(12);
    8097             :         } else {
    8098         752 :             netSourceEnergyUse += ort->gatherTotalsBEPS(14) * ort->sourceFactorOtherFuel2;
    8099             :         }
    8100             : 
    8101         752 :         netSourceEnergyUse =
    8102         752 :             (netSourceEnergyUse + netSourceElecPurchasedSold + ort->gatherTotalsBEPS(3) * ort->sourceFactorElectric / ort->efficiencyDistrictCooling +
    8103         752 :              ort->gatherTotalsBEPS(4) * ort->sourceFactorNaturalGas / ort->efficiencyDistrictHeatingWater +
    8104         752 :              ort->gatherTotalsBEPS(5) * ort->sourceFactorDistrictHeatingSteam) /
    8105             :             largeConversionFactor; // from other fuels | net source from electricity | district cooling | district heating water | district heating
    8106             :                                    // steam
    8107             : 
    8108             :         // show annual values
    8109         752 :         tableBody(1, 1) = RealToStr(totalSiteEnergyUse, 2);
    8110         752 :         tableBody(1, 2) = RealToStr(netSiteEnergyUse, 2);
    8111         752 :         tableBody(1, 3) = RealToStr(totalSourceEnergyUse, 2);
    8112         752 :         tableBody(1, 4) = RealToStr(netSourceEnergyUse, 2);
    8113             : 
    8114             :         // convert floor areas
    8115         752 :         Real64 const convBldgGrossFloorArea = ort->buildingGrossFloorArea / areaConversionFactor;
    8116         752 :         Real64 const convBldgCondFloorArea = ort->buildingConditionedFloorArea / areaConversionFactor;
    8117             : 
    8118             :         // show  per building area
    8119         752 :         if (convBldgGrossFloorArea > 0) {
    8120         723 :             tableBody(2, 1) = RealToStr(totalSiteEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8121         723 :             tableBody(2, 2) = RealToStr(netSiteEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8122         723 :             tableBody(2, 3) = RealToStr(totalSourceEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8123         723 :             tableBody(2, 4) = RealToStr(netSourceEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8124             :         }
    8125             :         // show  per conditioned building area
    8126         752 :         if (convBldgCondFloorArea > 0) {
    8127         670 :             tableBody(3, 1) = RealToStr(totalSiteEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8128         670 :             tableBody(3, 2) = RealToStr(netSiteEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8129         670 :             tableBody(3, 3) = RealToStr(totalSourceEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8130         670 :             tableBody(3, 4) = RealToStr(netSourceEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8131             :         }
    8132             : 
    8133             :         // heading for the entire sub-table
    8134         752 :         if (ort->displayTabularBEPS) {
    8135         752 :             if (produceTabular) {
    8136         752 :                 WriteSubtitle(state, "Site and Source Energy");
    8137         752 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8138             :             }
    8139         752 :             if (produceSQLite) {
    8140         752 :                 if (state.dataSQLiteProcedures->sqlite) {
    8141         121 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    8142             :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Site and Source Energy");
    8143             :                 }
    8144             :             }
    8145         752 :             if (produceTabular) {
    8146         752 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8147           7 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    8148             :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Site and Source Energy");
    8149             :                 }
    8150             :             }
    8151             :         }
    8152             : 
    8153             :         //---- Source and Site Energy Sub-Table
    8154         752 :         rowHead.allocate(13);
    8155         752 :         columnHead.allocate(1);
    8156         752 :         columnWidth.allocate(1);
    8157         752 :         columnWidth = 50; // array assignment
    8158         752 :         tableBody.allocate(1, 13);
    8159             : 
    8160         752 :         columnHead(1) = "Site=>Source Conversion Factor";
    8161             : 
    8162         752 :         rowHead(1) = "Electricity";
    8163         752 :         rowHead(2) = "Natural Gas";
    8164         752 :         rowHead(3) = "District Cooling";
    8165         752 :         rowHead(4) = "District Heating Water";
    8166         752 :         rowHead(5) = "District Heating Steam";
    8167         752 :         rowHead(6) = "Gasoline";
    8168         752 :         rowHead(7) = "Diesel";
    8169         752 :         rowHead(8) = "Coal";
    8170         752 :         rowHead(9) = "Fuel Oil No 1";
    8171         752 :         rowHead(10) = "Fuel Oil No 2";
    8172         752 :         rowHead(11) = "Propane";
    8173         752 :         rowHead(12) = "Other Fuel 1";
    8174         752 :         rowHead(13) = "Other Fuel 2";
    8175             : 
    8176         752 :         tableBody = "";
    8177             : 
    8178             :         // set columns to conversion factors
    8179             :         // show values
    8180             :         //  tableBody(1,1)  = TRIM(RealToStr(sourceFactorElectric,3))
    8181             :         //  tableBody(2,1)  = TRIM(RealToStr(sourceFactorNaturalGas, 3))
    8182             :         //  tableBody(3,1)  = TRIM(RealToStr(sourceFactorElectric/ efficiencyDistrictCooling,3))
    8183             :         //  tableBody(4,1)  = TRIM(RealToStr(sourceFactorNaturalGas/ efficiencyDistrictHeating ,3))
    8184             :         //  tableBody(5,1)  = TRIM(RealToStr(sourceFactorSteam ,3))
    8185             :         //  tableBody(6,1)  = TRIM(RealToStr(sourceFactorGasoline ,3))
    8186             :         //  tableBody(7,1)  = TRIM(RealToStr(sourceFactorDiesel ,3))
    8187             :         //  tableBody(8,1)  = TRIM(RealToStr(sourceFactorCoal ,3))
    8188             :         //  tableBody(9,1)  = TRIM(RealToStr(sourceFactorFuelOil1 ,3))
    8189             :         //  tableBody(10,1) = TRIM(RealToStr(sourceFactorFuelOil2 ,3))
    8190             :         //  tableBody(11,1) = TRIM(RealToStr(sourceFactorPropane ,3))
    8191             : 
    8192         752 :         if (!ort->ffSchedUsed(1)) {
    8193         751 :             tableBody(1, 1) = RealToStr(ort->sourceFactorElectric, 3);
    8194           1 :         } else if (ort->gatherTotalsBEPS(1) > SmallValue) {
    8195           0 :             tableBody(1, 1) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(1) / ort->gatherTotalsBEPS(1), 3) +
    8196           0 :                               " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(1)) + "\")";
    8197             :         } else {
    8198           1 :             tableBody(1, 1) = "N/A";
    8199             :         }
    8200             : 
    8201         752 :         if (!ort->ffSchedUsed(2)) {
    8202         751 :             tableBody(1, 2) = RealToStr(ort->sourceFactorNaturalGas, 3);
    8203           1 :         } else if (ort->gatherTotalsBEPS(2) > SmallValue) {
    8204           0 :             tableBody(1, 2) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(2) / ort->gatherTotalsBEPS(2), 3) +
    8205           0 :                               " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(2)) + "\")";
    8206             :         } else {
    8207           1 :             tableBody(1, 2) = "N/A";
    8208             :         }
    8209             : 
    8210         752 :         tableBody(1, 3) = RealToStr(ort->sourceFactorElectric / ort->efficiencyDistrictCooling, 3); // District Cooling
    8211             : 
    8212         752 :         tableBody(1, 4) = RealToStr(ort->sourceFactorNaturalGas / ort->efficiencyDistrictHeatingWater, 3); // District Heating Water
    8213             : 
    8214         752 :         tableBody(1, 5) = RealToStr(ort->sourceFactorDistrictHeatingSteam, 3); // District Heating Steam
    8215             : 
    8216         752 :         if (!ort->ffSchedUsed(6)) {
    8217         752 :             tableBody(1, 6) = RealToStr(ort->sourceFactorGasoline, 3);
    8218           0 :         } else if (ort->gatherTotalsBEPS(6) > SmallValue) {
    8219           0 :             tableBody(1, 6) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(6) / ort->gatherTotalsBEPS(6), 3) +
    8220           0 :                               " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(6)) + "\")";
    8221             :         } else {
    8222           0 :             tableBody(1, 6) = "N/A";
    8223             :         }
    8224             : 
    8225         752 :         if (!ort->ffSchedUsed(8)) {
    8226         752 :             tableBody(1, 7) = RealToStr(ort->sourceFactorDiesel, 3);
    8227           0 :         } else if (ort->gatherTotalsBEPS(8) > SmallValue) {
    8228           0 :             tableBody(1, 7) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(8) / ort->gatherTotalsBEPS(8), 3) +
    8229           0 :                               " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(8)) + "\")";
    8230             :         } else {
    8231           0 :             tableBody(1, 7) = "N/A";
    8232             :         }
    8233             : 
    8234         752 :         if (!ort->ffSchedUsed(9)) {
    8235         752 :             tableBody(1, 8) = RealToStr(ort->sourceFactorCoal, 3);
    8236           0 :         } else if (ort->gatherTotalsBEPS(9) > SmallValue) {
    8237           0 :             tableBody(1, 8) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(9) / ort->gatherTotalsBEPS(9), 3) +
    8238           0 :                               " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(9)) + "\")";
    8239             :         } else {
    8240           0 :             tableBody(1, 8) = "N/A";
    8241             :         }
    8242             : 
    8243         752 :         if (!ort->ffSchedUsed(10)) {
    8244         752 :             tableBody(1, 9) = RealToStr(ort->sourceFactorFuelOil1, 3);
    8245           0 :         } else if (ort->gatherTotalsBEPS(10) > SmallValue) {
    8246           0 :             tableBody(1, 9) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(10) / ort->gatherTotalsBEPS(10), 3) +
    8247           0 :                               " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(10)) + "\")";
    8248             :         } else {
    8249           0 :             tableBody(1, 9) = "N/A";
    8250             :         }
    8251             : 
    8252         752 :         if (!ort->ffSchedUsed(11)) {
    8253         752 :             tableBody(1, 10) = RealToStr(ort->sourceFactorFuelOil2, 3);
    8254           0 :         } else if (ort->gatherTotalsBEPS(11) > SmallValue) {
    8255           0 :             tableBody(1, 10) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(11) / ort->gatherTotalsBEPS(11), 3) +
    8256           0 :                                " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(11)) + "\")";
    8257             :         } else {
    8258           0 :             tableBody(1, 10) = "N/A";
    8259             :         }
    8260             : 
    8261         752 :         if (!ort->ffSchedUsed(12)) {
    8262         752 :             tableBody(1, 11) = RealToStr(ort->sourceFactorPropane, 3);
    8263           0 :         } else if (ort->gatherTotalsBEPS(12) > SmallValue) {
    8264           0 :             tableBody(1, 11) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(12) / ort->gatherTotalsBEPS(12), 3) +
    8265           0 :                                " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(12)) + "\")";
    8266             :         } else {
    8267           0 :             tableBody(1, 11) = "N/A";
    8268             :         }
    8269             : 
    8270         752 :         if (!ort->ffSchedUsed(13)) {
    8271         752 :             tableBody(1, 12) = RealToStr(ort->sourceFactorOtherFuel1, 3);
    8272           0 :         } else if (ort->gatherTotalsBEPS(13) > SmallValue) {
    8273           0 :             tableBody(1, 12) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(13) / ort->gatherTotalsBEPS(13), 3) +
    8274           0 :                                " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(13)) + "\")";
    8275             :         } else {
    8276           0 :             tableBody(1, 12) = "N/A";
    8277             :         }
    8278             : 
    8279         752 :         if (!ort->ffSchedUsed(14)) {
    8280         752 :             tableBody(1, 13) = RealToStr(ort->sourceFactorOtherFuel2, 3);
    8281           0 :         } else if (ort->gatherTotalsBEPS(14) > SmallValue) {
    8282           0 :             tableBody(1, 13) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(14) / ort->gatherTotalsBEPS(14), 3) +
    8283           0 :                                " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(14)) + "\")";
    8284             :         } else {
    8285           0 :             tableBody(1, 13) = "N/A";
    8286             :         }
    8287             : 
    8288             :         // heading for the entire sub-table
    8289         752 :         if (ort->displayTabularBEPS) {
    8290         752 :             if (produceTabular) {
    8291         752 :                 WriteSubtitle(state, "Site to Source Energy Conversion Factors");
    8292         752 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8293             :             }
    8294         752 :             if (produceSQLite) {
    8295         752 :                 if (state.dataSQLiteProcedures->sqlite) {
    8296         121 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    8297             :                                                                                        rowHead,
    8298             :                                                                                        columnHead,
    8299             :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    8300             :                                                                                        "Entire Facility",
    8301             :                                                                                        "Site to Source Energy Conversion Factors");
    8302             :                 }
    8303             :             }
    8304         752 :             if (produceTabular) {
    8305         752 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8306           7 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    8307             :                                                                                                           rowHead,
    8308             :                                                                                                           columnHead,
    8309             :                                                                                                           "AnnualBuildingUtilityPerformanceSummary",
    8310             :                                                                                                           "Entire Facility",
    8311             :                                                                                                           "Site to Source Energy Conversion Factors");
    8312             :                 }
    8313             :             }
    8314             :         }
    8315             : 
    8316             :         //---- Building Area Sub-Table
    8317         752 :         rowHead.allocate(3);
    8318         752 :         columnHead.allocate(1);
    8319         752 :         columnWidth.allocate(1);
    8320         752 :         columnWidth = 14; // array assignment - same for all columns
    8321         752 :         tableBody.allocate(1, 3);
    8322             : 
    8323         752 :         switch (unitsStyle_cur) {
    8324           6 :         case UnitsStyle::JtoKWH: {
    8325           6 :             columnHead(1) = "Area [m2]";
    8326           6 :         } break;
    8327          11 :         case UnitsStyle::InchPound: {
    8328          11 :             columnHead(1) = "Area [ft2]";
    8329          11 :         } break;
    8330           0 :         case UnitsStyle::InchPoundExceptElectricity: {
    8331           0 :             columnHead(1) = "Area [ft2]";
    8332           0 :         } break;
    8333         735 :         default: {
    8334         735 :             columnHead(1) = "Area [m2]";
    8335         735 :         } break;
    8336             :         }
    8337             : 
    8338         752 :         rowHead(1) = "Total Building Area";
    8339         752 :         rowHead(2) = "Net Conditioned Building Area";
    8340         752 :         rowHead(3) = "Unconditioned Building Area";
    8341             : 
    8342         752 :         tableBody = "";
    8343         752 :         tableBody(1, 1) = RealToStr(convBldgGrossFloorArea, 2);
    8344             : 
    8345         752 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    8346         741 :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
    8347          11 :             if (produceTabular) {
    8348          22 :                 PreDefTableEntry(
    8349          33 :                     state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [ft2]", RealToStr(convBldgGrossFloorArea, 2));
    8350             :             }
    8351             :         } else {
    8352         741 :             if (produceTabular) {
    8353        1482 :                 PreDefTableEntry(
    8354        2223 :                     state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [m2]", RealToStr(convBldgGrossFloorArea, 2));
    8355             :             }
    8356             :         }
    8357             : 
    8358         752 :         tableBody(1, 2) = RealToStr(convBldgCondFloorArea, 2);
    8359         752 :         tableBody(1, 3) = RealToStr(convBldgGrossFloorArea - convBldgCondFloorArea, 2);
    8360             : 
    8361             :         // heading for the entire sub-table
    8362         752 :         if (ort->displayTabularBEPS) {
    8363         752 :             if (produceTabular) {
    8364         752 :                 WriteSubtitle(state, "Building Area");
    8365         752 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8366             :             }
    8367         752 :             if (produceSQLite) {
    8368         752 :                 if (state.dataSQLiteProcedures->sqlite) {
    8369         121 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    8370             :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Building Area");
    8371             :                 }
    8372             :             }
    8373         752 :             if (produceTabular) {
    8374         752 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8375           7 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    8376             :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Building Area");
    8377             :                 }
    8378             :             }
    8379             :         }
    8380             : 
    8381             :         //---- End Use Sub-Table
    8382         752 :         rowHead.allocate(16);
    8383         752 :         columnHead.allocate(14);
    8384         752 :         columnWidth.allocate(14);
    8385         752 :         columnWidth = 10; // array assignment - same for all columns
    8386         752 :         tableBody.allocate(14, 16);
    8387       11280 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8388      157920 :             for (int iEndUse = 0; iEndUse < static_cast<int>(Constant::EndUse::Num); ++iEndUse) {
    8389      147392 :                 useVal(iResource, iEndUse + 1) = collapsedEndUse(iResource, iEndUse + 1);
    8390             :             }
    8391       10528 :             useVal(iResource, 15) = collapsedTotal(iResource); // totals
    8392             :         }
    8393             : 
    8394         752 :         rowHead(static_cast<int>(Constant::EndUse::Heating) + 1) = "Heating";
    8395         752 :         rowHead(static_cast<int>(Constant::EndUse::Cooling) + 1) = "Cooling";
    8396         752 :         rowHead(static_cast<int>(Constant::EndUse::InteriorLights) + 1) = "Interior Lighting";
    8397         752 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorLights) + 1) = "Exterior Lighting";
    8398         752 :         rowHead(static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) = "Interior Equipment";
    8399         752 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) = "Exterior Equipment";
    8400         752 :         rowHead(static_cast<int>(Constant::EndUse::Fans) + 1) = "Fans";
    8401         752 :         rowHead(static_cast<int>(Constant::EndUse::Pumps) + 1) = "Pumps";
    8402         752 :         rowHead(static_cast<int>(Constant::EndUse::HeatRejection) + 1) = "Heat Rejection";
    8403         752 :         rowHead(static_cast<int>(Constant::EndUse::Humidification) + 1) = "Humidification";
    8404         752 :         rowHead(static_cast<int>(Constant::EndUse::HeatRecovery) + 1) = "Heat Recovery";
    8405         752 :         rowHead(static_cast<int>(Constant::EndUse::WaterSystem) + 1) = "Water Systems";
    8406         752 :         rowHead(static_cast<int>(Constant::EndUse::Refrigeration) + 1) = "Refrigeration";
    8407         752 :         rowHead(static_cast<int>(Constant::EndUse::Cogeneration) + 1) = "Generators";
    8408         752 :         rowHead(15) = "";
    8409         752 :         rowHead(16) = "Total End Uses";
    8410             : 
    8411         752 :         switch (unitsStyle_cur) {
    8412           6 :         case UnitsStyle::JtoKWH: {
    8413           6 :             columnHead(1) = "Electricity [kWh]";
    8414           6 :             columnHead(2) = "Natural Gas [kWh]";
    8415           6 :             columnHead(3) = "Gasoline [kWh]";
    8416           6 :             columnHead(4) = "Diesel [kWh]";
    8417           6 :             columnHead(5) = "Coal [kWh]";
    8418           6 :             columnHead(6) = "Fuel Oil No 1 [kWh]";
    8419           6 :             columnHead(7) = "Fuel Oil No 2 [kWh]";
    8420           6 :             columnHead(8) = "Propane [kWh]";
    8421           6 :             columnHead(9) = "Other Fuel 1 [kWh]";
    8422           6 :             columnHead(10) = "Other Fuel 2 [kWh]";
    8423           6 :             columnHead(11) = "District Cooling [kWh]";
    8424           6 :             columnHead(12) = "District Heating Water [kWh]";
    8425           6 :             columnHead(13) = "District Heating Steam [kWh]";
    8426           6 :             columnHead(14) = "Water [m3]";
    8427           6 :         } break;
    8428          11 :         case UnitsStyle::InchPound: {
    8429          11 :             columnHead(1) = "Electricity [kBtu]";
    8430          11 :             columnHead(2) = "Natural Gas [kBtu]";
    8431          11 :             columnHead(3) = "Gasoline [kBtu]";
    8432          11 :             columnHead(4) = "Diesel [kBtu]";
    8433          11 :             columnHead(5) = "Coal [kBtu]";
    8434          11 :             columnHead(6) = "Fuel Oil No 1 [kBtu]";
    8435          11 :             columnHead(7) = "Fuel Oil No 2 [kBtu]";
    8436          11 :             columnHead(8) = "Propane [kBtu]";
    8437          11 :             columnHead(9) = "Other Fuel 1 [kBtu]";
    8438          11 :             columnHead(10) = "Other Fuel 2 [kBtu]";
    8439          11 :             columnHead(11) = "District Cooling [kBtu]";
    8440          11 :             columnHead(12) = "District Heating Water [kBtu]";
    8441          11 :             columnHead(13) = "District Heating Steam [kBtu]";
    8442          11 :             columnHead(14) = "Water [gal]";
    8443          11 :         } break;
    8444           0 :         case UnitsStyle::InchPoundExceptElectricity: {
    8445           0 :             columnHead(1) = "Electricity [kWh]";
    8446           0 :             columnHead(2) = "Natural Gas [kBtu]";
    8447           0 :             columnHead(3) = "Gasoline [kBtu]";
    8448           0 :             columnHead(4) = "Diesel [kBtu]";
    8449           0 :             columnHead(5) = "Coal [kBtu]";
    8450           0 :             columnHead(6) = "Fuel Oil No 1 [kBtu]";
    8451           0 :             columnHead(7) = "Fuel Oil No 2 [kBtu]";
    8452           0 :             columnHead(8) = "Propane [kBtu]";
    8453           0 :             columnHead(9) = "Other Fuel 1 [kBtu]";
    8454           0 :             columnHead(10) = "Other Fuel 2 [kBtu]";
    8455           0 :             columnHead(11) = "District Cooling [kBtu]";
    8456           0 :             columnHead(12) = "District Heating Water [kBtu]";
    8457           0 :             columnHead(13) = "District Heating Steam [kBtu]";
    8458           0 :             columnHead(14) = "Water [gal]";
    8459           0 :         } break;
    8460         735 :         default: {
    8461         735 :             columnHead(1) = "Electricity [GJ]";
    8462         735 :             columnHead(2) = "Natural Gas [GJ]";
    8463         735 :             columnHead(3) = "Gasoline [GJ]";
    8464         735 :             columnHead(4) = "Diesel [GJ]";
    8465         735 :             columnHead(5) = "Coal [GJ]";
    8466         735 :             columnHead(6) = "Fuel Oil No 1 [GJ]";
    8467         735 :             columnHead(7) = "Fuel Oil No 2 [GJ]";
    8468         735 :             columnHead(8) = "Propane [GJ]";
    8469         735 :             columnHead(9) = "Other Fuel 1 [GJ]";
    8470         735 :             columnHead(10) = "Other Fuel 2 [GJ]";
    8471         735 :             columnHead(11) = "District Cooling [GJ]";
    8472         735 :             columnHead(12) = "District Heating Water [GJ]";
    8473         735 :             columnHead(13) = "District Heating Steam [GJ]";
    8474         735 :             columnHead(14) = "Water [m3]";
    8475         735 :         } break;
    8476             :         }
    8477             : 
    8478         752 :         tableBody = "";
    8479       11280 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8480      157920 :             for (int jEndUse = 1; jEndUse <= 14; ++jEndUse) {
    8481      147392 :                 tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse), 2);
    8482             :             }
    8483       10528 :             tableBody(iResource, 16) = RealToStr(useVal(iResource, 15), 2);
    8484             :         }
    8485             :         // add warning message if end use values do not add up to total
    8486       11280 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8487       10528 :             Real64 curTotal = 0.0;
    8488      157920 :             for (int jUse = 1; jUse <= 14; ++jUse) {
    8489      147392 :                 curTotal += useVal(iResource, jUse);
    8490             :             }
    8491       10528 :             if (std::abs(curTotal - collapsedTotal(iResource)) > (collapsedTotal(iResource) * 0.001)) {
    8492           0 :                 ShowWarningError(state, ResourceWarningMessage(columnHead(iResource)));
    8493             :             }
    8494             :         }
    8495             : 
    8496         752 :         Real64 const unconvert = largeConversionFactor / 1000000000.0; // to avoid double converting, the values for the LEED report should be in GJ
    8497         752 :         Real64 const unconvert_ipExceptElec = (largeConversionFactor / ipElectricityConversionFactor) /
    8498             :                                               1000000000.0; // to avoid double converting, the values for the LEED report should be in GJ
    8499             : 
    8500             :         //  Energy Use Intensities - Electricity
    8501         752 :         if (ort->buildingGrossFloorArea > 0) {
    8502         723 :             if (produceTabular) {
    8503         723 :                 PreDefTableEntry(state,
    8504         723 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8505             :                                  "Interior Lighting (All)",
    8506         723 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 3) / ort->buildingGrossFloorArea,
    8507         723 :                                  2);
    8508         723 :                 PreDefTableEntry(state,
    8509         723 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8510             :                                  "Space Heating",
    8511         723 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 1) / ort->buildingGrossFloorArea,
    8512         723 :                                  2);
    8513         723 :                 PreDefTableEntry(state,
    8514         723 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8515             :                                  "Space Cooling",
    8516         723 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 2) / ort->buildingGrossFloorArea,
    8517         723 :                                  2);
    8518         723 :                 PreDefTableEntry(state,
    8519         723 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8520             :                                  "Fans (All)",
    8521         723 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 7) / ort->buildingGrossFloorArea,
    8522         723 :                                  2);
    8523         723 :                 PreDefTableEntry(state,
    8524         723 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8525             :                                  "Service Water Heating",
    8526         723 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 12) / ort->buildingGrossFloorArea,
    8527         723 :                                  2);
    8528         723 :                 PreDefTableEntry(state,
    8529         723 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8530             :                                  "Receptacle Equipment",
    8531         723 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 5) / ort->buildingGrossFloorArea,
    8532         723 :                                  2);
    8533         723 :                 PreDefTableEntry(state,
    8534         723 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8535             :                                  "Miscellaneous (All)",
    8536         723 :                                  unconvert_ipExceptElec * 1000 * (useVal(colElectricity, 15)) / ort->buildingGrossFloorArea,
    8537         723 :                                  2);
    8538         723 :                 PreDefTableEntry(state,
    8539         723 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8540             :                                  "Subtotal",
    8541         723 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 15) / ort->buildingGrossFloorArea,
    8542        1446 :                                  2);
    8543             :             }
    8544             :         }
    8545             : 
    8546         752 :         if (produceTabular) {
    8547         752 :             PreDefTableEntry(
    8548         752 :                 state, state.dataOutRptPredefined->pdchLeedEusTotal, "Electricity", unconvert_ipExceptElec * useVal(colElectricity, 15), 2);
    8549         752 :             PreDefTableEntry(state,
    8550         752 :                              state.dataOutRptPredefined->pdchLeedEusProc,
    8551             :                              "Electricity",
    8552         752 :                              unconvert_ipExceptElec * (useVal(colElectricity, 5) + useVal(colElectricity, 13)),
    8553        1504 :                              2);
    8554             :         }
    8555             : 
    8556         752 :         Real64 processElecCost = 0.0;
    8557         752 :         if (useVal(colElectricity, 15) != 0) {
    8558           5 :             Real64 const processFraction = (useVal(colElectricity, 5) + useVal(colElectricity, 13)) / useVal(colElectricity, 15);
    8559           5 :             processElecCost = state.dataOutRptPredefined->LEEDelecCostTotal * processFraction;
    8560             :         }
    8561         752 :         if (produceTabular) {
    8562         752 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Electricity", processElecCost, 2);
    8563        1504 :             addFootNoteSubTable(
    8564         752 :                 state, state.dataOutRptPredefined->pdstLeedEneCostSum, "Process energy cost based on ratio of process to total energy.");
    8565             :         }
    8566             : 
    8567             :         //  Energy Use Intensities- Natural Gas
    8568         752 :         if (ort->buildingGrossFloorArea > 0) {
    8569         723 :             if (produceTabular) {
    8570         723 :                 PreDefTableEntry(state,
    8571         723 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8572             :                                  "Space Heating",
    8573         723 :                                  unconvert * 1000 * useVal(colGas, 1) / ort->buildingGrossFloorArea,
    8574         723 :                                  2);
    8575         723 :                 PreDefTableEntry(state,
    8576         723 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8577             :                                  "Service Water Heating",
    8578         723 :                                  unconvert * 1000 * useVal(colGas, 12) / ort->buildingGrossFloorArea,
    8579         723 :                                  2);
    8580         723 :                 PreDefTableEntry(state,
    8581         723 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8582             :                                  "Miscellaneous (All)",
    8583         723 :                                  unconvert * 1000 * useVal(colGas, 15) / ort->buildingGrossFloorArea,
    8584         723 :                                  2);
    8585         723 :                 PreDefTableEntry(state,
    8586         723 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8587             :                                  "Subtotal",
    8588         723 :                                  unconvert * 1000 * useVal(colGas, 15) / ort->buildingGrossFloorArea,
    8589        1446 :                                  2);
    8590             :             }
    8591             :         }
    8592         752 :         if (produceTabular) {
    8593         752 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEusTotal, "Natural Gas", unconvert * useVal(colGas, 15), 2);
    8594         752 :             PreDefTableEntry(
    8595        1504 :                 state, state.dataOutRptPredefined->pdchLeedEusProc, "Natural Gas", unconvert * (useVal(colGas, 5) + useVal(colGas, 13)), 2);
    8596             :         }
    8597             : 
    8598         752 :         Real64 processGasCost = 0.0;
    8599         752 :         if (useVal(colGas, 15) != 0) {
    8600           3 :             Real64 const processFraction = (useVal(colGas, 5) + useVal(colGas, 13)) / useVal(colGas, 15);
    8601           3 :             processGasCost = state.dataOutRptPredefined->LEEDgasCostTotal * processFraction;
    8602             :         }
    8603         752 :         if (produceTabular) {
    8604         752 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Natural Gas", processGasCost, 2);
    8605             :         }
    8606             :         //  Energy Use Intensities  - Additional Fuel
    8607             :         Real64 const useValColAddFuel15 =
    8608         752 :             useVal(3, 15) + useVal(4, 15) + useVal(5, 15) + useVal(6, 15) + useVal(7, 15) + useVal(8, 15) + useVal(9, 15) + useVal(10, 15);
    8609             :         Real64 const useValColAddFuel5 =
    8610         752 :             useVal(3, 5) + useVal(4, 5) + useVal(5, 5) + useVal(6, 5) + useVal(7, 5) + useVal(8, 5) + useVal(9, 5) + useVal(10, 5);
    8611             :         Real64 const useValColAddFuel13 =
    8612         752 :             useVal(3, 13) + useVal(4, 13) + useVal(5, 13) + useVal(6, 13) + useVal(7, 13) + useVal(8, 13) + useVal(9, 13) + useVal(10, 13);
    8613         752 :         if (ort->buildingGrossFloorArea > 0) {
    8614         723 :             if (produceTabular) {
    8615         723 :                 PreDefTableEntry(state,
    8616         723 :                                  state.dataOutRptPredefined->pdchLeedEuiOthr,
    8617             :                                  "Miscellaneous",
    8618         723 :                                  unconvert * 1000 * useValColAddFuel15 / ort->buildingGrossFloorArea,
    8619         723 :                                  2);
    8620         723 :                 PreDefTableEntry(state,
    8621         723 :                                  state.dataOutRptPredefined->pdchLeedEuiOthr,
    8622             :                                  "Subtotal",
    8623         723 :                                  unconvert * 1000 * useValColAddFuel15 / ort->buildingGrossFloorArea,
    8624        1446 :                                  2);
    8625             :             }
    8626             :         }
    8627         752 :         if (produceTabular) {
    8628         752 :             PreDefTableEntry(state,
    8629         752 :                              state.dataOutRptPredefined->pdchLeedEusTotal,
    8630             :                              "Additional",
    8631         752 :                              (useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) + useVal(colPurchHeatSt, 15)),
    8632         752 :                              2);
    8633         752 :             PreDefTableEntry(state,
    8634         752 :                              state.dataOutRptPredefined->pdchLeedEusProc,
    8635             :                              "Additional",
    8636             :                              unconvert *
    8637         752 :                                  (useValColAddFuel5 + useValColAddFuel13 + useVal(colPurchCool, 5) + useVal(colPurchCool, 13) +
    8638         752 :                                   useVal(colPurchHeatWtr, 5) + useVal(colPurchHeatWtr, 13) + useVal(colPurchHeatSt, 5) + useVal(colPurchHeatSt, 13)),
    8639        1504 :                              2);
    8640             :         }
    8641             : 
    8642         752 :         Real64 processOthrCost = 0.0;
    8643         752 :         if ((useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) + useVal(colPurchHeatSt, 15)) > 0.001) {
    8644             :             Real64 const processFraction =
    8645           2 :                 (useValColAddFuel5 + useValColAddFuel13 + useVal(colPurchCool, 5) + useVal(colPurchCool, 13) + useVal(colPurchHeatWtr, 5) +
    8646           2 :                  useVal(colPurchHeatWtr, 13) + useVal(colPurchHeatSt, 5) + useVal(colPurchHeatSt, 13)) /
    8647           2 :                 (useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) + useVal(colPurchHeatSt, 15));
    8648           2 :             processOthrCost = state.dataOutRptPredefined->LEEDothrCostTotal * processFraction;
    8649             :         }
    8650         752 :         if (produceTabular) {
    8651         752 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Additional", processOthrCost, 2);
    8652         752 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Total", processElecCost + processGasCost + processOthrCost, 2);
    8653             :         }
    8654             :         // accumulate for percentage table
    8655         752 :         state.dataOutRptTab->leedSiteIntLite = 0.0;
    8656         752 :         state.dataOutRptTab->leedSiteSpHeat = 0.0;
    8657         752 :         state.dataOutRptTab->leedSiteSpCool = 0.0;
    8658         752 :         state.dataOutRptTab->leedSiteFanInt = 0.0;
    8659         752 :         state.dataOutRptTab->leedSiteSrvWatr = 0.0;
    8660         752 :         state.dataOutRptTab->leedSiteRecept = 0.0;
    8661         752 :         state.dataOutRptTab->leedSiteTotal = 0.0;
    8662       10528 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't bother with water
    8663        9776 :             state.dataOutRptTab->leedSiteIntLite += useVal(iResource, 3);
    8664        9776 :             state.dataOutRptTab->leedSiteSpHeat += useVal(iResource, 1);
    8665        9776 :             state.dataOutRptTab->leedSiteSpCool += useVal(iResource, 2);
    8666        9776 :             state.dataOutRptTab->leedSiteFanInt += useVal(iResource, 7);
    8667        9776 :             state.dataOutRptTab->leedSiteSrvWatr += useVal(iResource, 12);
    8668        9776 :             state.dataOutRptTab->leedSiteRecept += useVal(iResource, 5);
    8669        9776 :             state.dataOutRptTab->leedSiteTotal += useVal(iResource, 15);
    8670             :         }
    8671         752 :         if (state.dataOutRptTab->leedSiteTotal != 0) {
    8672           5 :             if (produceTabular) {
    8673           5 :                 PreDefTableEntry(state,
    8674           5 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8675             :                                  "Interior Lighting (All)",
    8676           5 :                                  100 * state.dataOutRptTab->leedSiteIntLite / state.dataOutRptTab->leedSiteTotal,
    8677           5 :                                  2);
    8678           5 :                 PreDefTableEntry(state,
    8679           5 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8680             :                                  "Space Heating",
    8681           5 :                                  100 * state.dataOutRptTab->leedSiteSpHeat / state.dataOutRptTab->leedSiteTotal,
    8682           5 :                                  2);
    8683           5 :                 PreDefTableEntry(state,
    8684           5 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8685             :                                  "Space Cooling",
    8686           5 :                                  100 * state.dataOutRptTab->leedSiteSpCool / state.dataOutRptTab->leedSiteTotal,
    8687           5 :                                  2);
    8688           5 :                 PreDefTableEntry(state,
    8689           5 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8690             :                                  "Fans (All)",
    8691           5 :                                  100 * state.dataOutRptTab->leedSiteFanInt / state.dataOutRptTab->leedSiteTotal,
    8692           5 :                                  2);
    8693           5 :                 PreDefTableEntry(state,
    8694           5 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8695             :                                  "Service Water Heating",
    8696           5 :                                  100 * state.dataOutRptTab->leedSiteSrvWatr / state.dataOutRptTab->leedSiteTotal,
    8697           5 :                                  2);
    8698           5 :                 PreDefTableEntry(state,
    8699           5 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8700             :                                  "Receptacle Equipment",
    8701           5 :                                  100 * state.dataOutRptTab->leedSiteRecept / state.dataOutRptTab->leedSiteTotal,
    8702           5 :                                  2);
    8703           5 :                 PreDefTableEntry(
    8704             :                     state,
    8705           5 :                     state.dataOutRptPredefined->pdchLeedEupPerc,
    8706             :                     "Miscellaneous",
    8707           5 :                     100 *
    8708           5 :                         (state.dataOutRptTab->leedSiteTotal -
    8709           5 :                          (state.dataOutRptTab->leedSiteIntLite + state.dataOutRptTab->leedSiteSpHeat + state.dataOutRptTab->leedSiteSpCool +
    8710           5 :                           state.dataOutRptTab->leedSiteFanInt + state.dataOutRptTab->leedSiteSrvWatr + state.dataOutRptTab->leedSiteRecept)) /
    8711           5 :                         state.dataOutRptTab->leedSiteTotal,
    8712          10 :                     2);
    8713             :             }
    8714             :         }
    8715             :         // totals across energy source
    8716         752 :         if (produceTabular) {
    8717         752 :             PreDefTableEntry(state,
    8718         752 :                              state.dataOutRptPredefined->pdchLeedEusTotal,
    8719             :                              "Total",
    8720         752 :                              unconvert_ipExceptElec * useVal(colElectricity, 15) +
    8721         752 :                                  unconvert * (useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) +
    8722         752 :                                               useVal(colPurchHeatSt, 15) + +useVal(colGas, 15)),
    8723         752 :                              2);
    8724         752 :             PreDefTableEntry(state,
    8725         752 :                              state.dataOutRptPredefined->pdchLeedEusProc,
    8726             :                              "Total",
    8727         752 :                              unconvert_ipExceptElec * (useVal(colElectricity, 5) + useVal(colElectricity, 13)) +
    8728         752 :                                  unconvert * (useValColAddFuel5 + useValColAddFuel13 + useVal(colPurchCool, 5) + useVal(colPurchCool, 13) +
    8729         752 :                                               useVal(colPurchHeatWtr, 5) + useVal(colPurchHeatWtr, 13) + useVal(colPurchHeatSt, 5) +
    8730         752 :                                               useVal(colPurchHeatSt, 13) + +useVal(colGas, 5) + useVal(colGas, 13)),
    8731        1504 :                              2);
    8732             :         }
    8733             : 
    8734        1504 :         std::string footnote;
    8735         752 :         switch (resourcePrimaryHeating) {
    8736           0 :         case colElectricity: {
    8737           0 :             if (produceTabular) {
    8738           0 :                 footnote = "Note: Electricity appears to be the principal heating source based on energy usage.";
    8739           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "Electricity");
    8740             :             }
    8741           0 :         } break;
    8742           3 :         case colGas: {
    8743           3 :             if (produceTabular) {
    8744           3 :                 footnote = "Note: Natural gas appears to be the principal heating source based on energy usage.";
    8745           3 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "Natural Gas");
    8746             :             }
    8747           3 :         } break;
    8748           0 :         case colGasoline:
    8749             :         case colDiesel:
    8750             :         case colCoal:
    8751             :         case colFuelOilNo1:
    8752             :         case colFuelOilNo2:
    8753             :         case colPropane:
    8754             :         case colOtherFuel1:
    8755             :         case colOtherFuel2: {
    8756           0 :             if (produceTabular) {
    8757           0 :                 footnote = "Note: Additional fuel appears to be the principal heating source based on energy usage.";
    8758           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "Additional Fuel");
    8759             :             }
    8760           0 :         } break;
    8761           2 :         case colPurchHeatWtr: {
    8762           2 :             if (produceTabular) {
    8763           2 :                 footnote = "Note: District heating water appears to be the principal heating source based on energy usage.";
    8764           2 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "District Heating Water");
    8765             :             }
    8766           2 :         } break;
    8767           0 :         case colPurchHeatSt: {
    8768           0 :             if (produceTabular) {
    8769           0 :                 footnote = "Note: District heating steam appears to be the principal heating source based on energy usage.";
    8770           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "District Heating steam");
    8771             :             }
    8772           0 :         } break;
    8773             :         }
    8774             :         // heading for the entire sub-table
    8775         752 :         if (ort->displayTabularBEPS) {
    8776         752 :             if (produceTabular) {
    8777         752 :                 WriteSubtitle(state, "End Uses");
    8778         752 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, footnote);
    8779             :             }
    8780         752 :             if (produceSQLite) {
    8781         752 :                 if (state.dataSQLiteProcedures->sqlite) {
    8782         121 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    8783             :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "End Uses");
    8784             :                 }
    8785             :             }
    8786         752 :             if (produceTabular) {
    8787         752 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8788           7 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    8789             :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "End Uses");
    8790             :                 }
    8791             :             }
    8792             :         }
    8793             : 
    8794             :         //---- End Uses By Subcategory Sub-Table
    8795        1504 :         writeBEPSEndUseBySubCatOrSpaceType(state,
    8796             :                                            EndUseSubTableType::BySubCategory,
    8797             :                                            endUseSubOther,
    8798             :                                            collapsedEndUse,
    8799             :                                            collapsedEndUseSub,
    8800         752 :                                            ort->needOtherRowLEED45,
    8801             :                                            unitsStyle_cur,
    8802             :                                            produceTabular,
    8803             :                                            produceSQLite);
    8804             : 
    8805        1504 :         writeBEPSEndUseBySubCatOrSpaceType(state,
    8806             :                                            EndUseSubTableType::BySpaceType,
    8807             :                                            endUseSubOther,
    8808             :                                            collapsedEndUse,
    8809             :                                            collapsedEndUseSpType,
    8810         752 :                                            ort->needOtherRowEndUse,
    8811             :                                            unitsStyle_cur,
    8812             :                                            produceTabular,
    8813             :                                            produceSQLite);
    8814             : 
    8815             :         // EAp2-4/5. Performance Rating Method Compliance
    8816             :         // repeat some of the code for the end use subcategory table but only looping over the energy resources and not including water
    8817             : 
    8818        1504 :         Array1D_int resource_entry_map;
    8819         752 :         resource_entry_map.allocate(13);
    8820         752 :         resource_entry_map(1) = state.dataOutRptPredefined->pdchLeedPerfElEneUse;          // electricity
    8821         752 :         resource_entry_map(2) = state.dataOutRptPredefined->pdchLeedPerfGasEneUse;         // natural gas
    8822         752 :         resource_entry_map(3) = state.dataOutRptPredefined->pdchLeedPerfGasolineEneUse;    // gasoline
    8823         752 :         resource_entry_map(4) = state.dataOutRptPredefined->pdchLeedPerfDieselEneUse;      // diesel
    8824         752 :         resource_entry_map(5) = state.dataOutRptPredefined->pdchLeedPerfCoalEneUse;        // coal
    8825         752 :         resource_entry_map(6) = state.dataOutRptPredefined->pdchLeedPerfFuelOil1EneUse;    // fuel oil no 1
    8826         752 :         resource_entry_map(7) = state.dataOutRptPredefined->pdchLeedPerfFuelOil2EneUse;    // fuel oil no 2
    8827         752 :         resource_entry_map(8) = state.dataOutRptPredefined->pdchLeedPerfPropaneEneUse;     // propane
    8828         752 :         resource_entry_map(9) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel1EneUse;  // other fuel 1
    8829         752 :         resource_entry_map(10) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel2EneUse; // other fuel 2
    8830         752 :         resource_entry_map(11) = state.dataOutRptPredefined->pdchLeedPerfDisClEneUse;      // district cooling
    8831         752 :         resource_entry_map(12) = state.dataOutRptPredefined->pdchLeedPerfDisHtWtrEneUse;   // district heating Water
    8832         752 :         resource_entry_map(13) = state.dataOutRptPredefined->pdchLeedPerfDisHtStEneUse;    // district heating Steam
    8833             : 
    8834       10528 :         for (int iResource = 1; iResource <= 13; ++iResource) {
    8835        9776 :             int i = 1;
    8836        9776 :             Real64 localUnconvert = (iResource == 1) ? unconvert_ipExceptElec : unconvert;
    8837      146640 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    8838      136864 :                 if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
    8839      149409 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    8840       81029 :                         if (produceTabular) {
    8841      243087 :                             PreDefTableEntry(state,
    8842       81029 :                                              resource_entry_map(iResource),
    8843      162058 :                                              op->EndUseCategory(jEndUse).DisplayName + " -- " +
    8844       81029 :                                                  op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub),
    8845       81029 :                                              localUnconvert * collapsedEndUseSub(kEndUseSub, jEndUse, iResource));
    8846             :                         }
    8847       81029 :                         ++i;
    8848             :                     }
    8849             :                     // put other
    8850       68380 :                     if (ort->needOtherRowLEED45(jEndUse)) {
    8851           0 :                         if (produceTabular) {
    8852           0 :                             PreDefTableEntry(state,
    8853           0 :                                              resource_entry_map(iResource),
    8854           0 :                                              op->EndUseCategory(jEndUse).DisplayName + " -- Other",
    8855           0 :                                              localUnconvert * endUseSubOther(iResource, jEndUse));
    8856             :                         }
    8857           0 :                         ++i;
    8858             :                     }
    8859             :                 } else {
    8860       68484 :                     if (produceTabular) {
    8861      205452 :                         PreDefTableEntry(state,
    8862       68484 :                                          resource_entry_map(iResource),
    8863      136968 :                                          op->EndUseCategory(jEndUse).DisplayName + " -- Not Subdivided",
    8864       68484 :                                          localUnconvert * collapsedEndUse(iResource, jEndUse));
    8865             :                     }
    8866       68484 :                     ++i;
    8867             :                 }
    8868             :             }
    8869             :         }
    8870             : 
    8871             :         //---- Normalized by Conditioned Area Sub-Table
    8872             :         // Calculations for both normalized tables are first
    8873         752 :         rowHead.allocate(4);
    8874         752 :         columnHead.allocate(14);
    8875         752 :         columnWidth.allocate(14);
    8876         752 :         columnWidth = 7; // array assignment - same for all columns
    8877         752 :         tableBody.allocate(14, 4);
    8878       11280 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8879             :             // Lights     <- InteriorLights | <- ExteriorLights
    8880       10528 :             normalVal(iResource, 1) = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::InteriorLights) + 1) +
    8881       10528 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::ExteriorLights) + 1);
    8882             : 
    8883             :             // HVAC       <- fans | <- pumps | <- heating | <- cooling | <- heat rejection | <- humidification | <- water system | <- domestic hot
    8884             :             // water
    8885       10528 :             normalVal(iResource, 2) = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Fans) + 1) +
    8886       10528 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Pumps) + 1) +
    8887       10528 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Heating) + 1) +
    8888       10528 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Cooling) + 1) +
    8889       10528 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::HeatRejection) + 1) +
    8890       10528 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Humidification) + 1) +
    8891       10528 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::WaterSystem) + 1);
    8892             : 
    8893             :             // Other <- InteriorEquipment | <- ExteriorEquipment | <- generator fuel | <- Heat Recovery (parasitics) | <- Refrigeration
    8894       10528 :             normalVal(iResource, 3) = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) +
    8895       10528 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) +
    8896       10528 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Cogeneration) + 1) +
    8897       10528 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::HeatRecovery) + 1) +
    8898       10528 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Refrigeration) + 1);
    8899             : 
    8900       10528 :             normalVal(iResource, 4) = collapsedTotal(iResource); // totals
    8901             :         }
    8902             :         // convert the normalized end use values to MJ from GJ if using J
    8903       10528 :         for (int iResource = 1; iResource <= 13; ++iResource) { // not including resource=14 water
    8904       48880 :             for (int jEndUse = 1; jEndUse <= 4; ++jEndUse) {
    8905       39104 :                 normalVal(iResource, jEndUse) *= kConversionFactor;
    8906             :             }
    8907             :         }
    8908             : 
    8909         752 :         rowHead(1) = "Lighting"; // typo fixed 5-17-04 BTG
    8910         752 :         rowHead(2) = "HVAC";
    8911         752 :         rowHead(3) = "Other";
    8912         752 :         rowHead(4) = "Total";
    8913             : 
    8914         752 :         switch (unitsStyle_cur) {
    8915           6 :         case UnitsStyle::JtoKWH: {
    8916           6 :             columnHead(1) = "Electricity Intensity [kWh/m2]";
    8917           6 :             columnHead(2) = "Natural Gas Intensity [kWh/m2]";
    8918           6 :             columnHead(3) = "Gasoline Intensity [kWh/m2]";
    8919           6 :             columnHead(4) = "Diesel Intensity [kWh/m2]";
    8920           6 :             columnHead(5) = "Coal Intensity [kWh/m2]";
    8921           6 :             columnHead(6) = "Fuel Oil No 1 Intensity [kWh/m2]";
    8922           6 :             columnHead(7) = "Fuel Oil No 2 Intensity [kWh/m2]";
    8923           6 :             columnHead(8) = "Propane Intensity [kWh/m2]";
    8924           6 :             columnHead(9) = "Other Fuel 1 Intensity [kWh/m2]";
    8925           6 :             columnHead(10) = "Other Fuel 2 Intensity [kWh/m2]";
    8926           6 :             columnHead(11) = "District Cooling Intensity [kWh/m2]";
    8927           6 :             columnHead(12) = "District Heating Water Intensity [kWh/m2]";
    8928           6 :             columnHead(13) = "District Heating Steam Intensity [kWh/m2]";
    8929           6 :             columnHead(14) = "Water Intensity [m3/m2]";
    8930           6 :         } break;
    8931          11 :         case UnitsStyle::InchPound: {
    8932          11 :             columnHead(1) = "Electricity Intensity [kBtu/ft2]";
    8933          11 :             columnHead(2) = "Natural Gas Intensity [kBtu/ft2]";
    8934          11 :             columnHead(3) = "Gasoline Intensity [kBtu/ft2]";
    8935          11 :             columnHead(4) = "Diesel Intensity [kBtu/ft2]";
    8936          11 :             columnHead(5) = "Coal Intensity [kBtu/ft2]";
    8937          11 :             columnHead(6) = "Fuel Oil No 1 Intensity [kBtu/ft2]";
    8938          11 :             columnHead(7) = "Fuel Oil No 2 Intensity [kBtu/ft2]";
    8939          11 :             columnHead(8) = "Propane Intensity [kBtu/ft2]";
    8940          11 :             columnHead(9) = "Other Fuel 1 Intensity [kBtu/ft2]";
    8941          11 :             columnHead(10) = "Other Fuel 2 Intensity [kBtu/ft2]";
    8942          11 :             columnHead(11) = "District Cooling Intensity [kBtu/ft2]";
    8943          11 :             columnHead(12) = "District Heating Water Intensity [kBtu/ft2]";
    8944          11 :             columnHead(13) = "District Heating Steam Intensity [kBtu/ft2]";
    8945          11 :             columnHead(14) = "Water Intensity [gal/ft2]";
    8946          11 :         } break;
    8947           0 :         case UnitsStyle::InchPoundExceptElectricity: {
    8948           0 :             columnHead(1) = "Electricity Intensity [kWh/ft2]";
    8949           0 :             columnHead(2) = "Natural Gas Intensity [kBtu/ft2]";
    8950           0 :             columnHead(3) = "Gasoline Intensity [kBtu/ft2]";
    8951           0 :             columnHead(4) = "Diesel Intensity [kBtu/ft2]";
    8952           0 :             columnHead(5) = "Coal Intensity [kBtu/ft2]";
    8953           0 :             columnHead(6) = "Fuel Oil No 1 Intensity [kBtu/ft2]";
    8954           0 :             columnHead(7) = "Fuel Oil No 2 Intensity [kBtu/ft2]";
    8955           0 :             columnHead(8) = "Propane Intensity [kBtu/ft2]";
    8956           0 :             columnHead(9) = "Other Fuel 1 Intensity [kBtu/ft2]";
    8957           0 :             columnHead(10) = "Other Fuel 2 Intensity [kBtu/ft2]";
    8958           0 :             columnHead(11) = "District Cooling Intensity [kBtu/ft2]";
    8959           0 :             columnHead(12) = "District Heating Water Intensity [kBtu/ft2]";
    8960           0 :             columnHead(13) = "District Heating Steam Intensity [kBtu/ft2]";
    8961           0 :             columnHead(14) = "Water Intensity [gal/ft2]";
    8962           0 :         } break;
    8963         735 :         default: {
    8964         735 :             columnHead(1) = "Electricity Intensity [MJ/m2]";
    8965         735 :             columnHead(2) = "Natural Gas Intensity [MJ/m2]";
    8966         735 :             columnHead(3) = "Gasoline Intensity [MJ/m2]";
    8967         735 :             columnHead(4) = "Diesel Intensity [MJ/m2]";
    8968         735 :             columnHead(5) = "Coal Intensity [MJ/m2]";
    8969         735 :             columnHead(6) = "Fuel Oil No 1 Intensity [MJ/m2]";
    8970         735 :             columnHead(7) = "Fuel Oil No 2 Intensity [MJ/m2]";
    8971         735 :             columnHead(8) = "Propane Intensity [MJ/m2]";
    8972         735 :             columnHead(9) = "Other Fuel 1 Intensity [MJ/m2]";
    8973         735 :             columnHead(10) = "Other Fuel 2 Intensity [MJ/m2]";
    8974         735 :             columnHead(11) = "District Cooling Intensity [MJ/m2]";
    8975         735 :             columnHead(12) = "District Heating Water Intensity [MJ/m2]";
    8976         735 :             columnHead(13) = "District Heating Steam Intensity [MJ/m2]";
    8977         735 :             columnHead(14) = "Water Intensity [m3/m2]";
    8978         735 :         } break;
    8979             :         }
    8980             : 
    8981         752 :         if (produceTabular) {
    8982         752 :             WriteTextLine(state, "Normalized Metrics", true);
    8983             :         }
    8984             : 
    8985             :         // write the conditioned area based table
    8986         752 :         tableBody = "";
    8987         752 :         if (convBldgCondFloorArea > 0) {
    8988       10050 :             for (int iResource = 1; iResource <= 14; ++iResource) {
    8989       46900 :                 for (int jEndUse = 1; jEndUse <= 4; ++jEndUse) {
    8990       37520 :                     tableBody(iResource, jEndUse) = RealToStr(normalVal(iResource, jEndUse) / convBldgCondFloorArea, 2);
    8991             :                 }
    8992             :             }
    8993             :         }
    8994             :         // heading for the entire sub-table
    8995         752 :         if (ort->displayTabularBEPS) {
    8996         752 :             if (produceTabular) {
    8997         752 :                 WriteSubtitle(state, "Utility Use Per Conditioned Floor Area");
    8998         752 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8999             :             }
    9000         752 :             if (produceSQLite) {
    9001         752 :                 if (state.dataSQLiteProcedures->sqlite) {
    9002         121 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9003             :                                                                                        rowHead,
    9004             :                                                                                        columnHead,
    9005             :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    9006             :                                                                                        "Entire Facility",
    9007             :                                                                                        "Utility Use Per Conditioned Floor Area");
    9008             :                 }
    9009             :             }
    9010         752 :             if (produceTabular) {
    9011         752 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9012           7 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    9013             :                                                                                                           rowHead,
    9014             :                                                                                                           columnHead,
    9015             :                                                                                                           "AnnualBuildingUtilityPerformanceSummary",
    9016             :                                                                                                           "Entire Facility",
    9017             :                                                                                                           "Utility Use Per Conditioned Floor Area");
    9018             :                 }
    9019             :             }
    9020             :         }
    9021             :         //---- Normalized by Total Area Sub-Table
    9022         752 :         tableBody = "";
    9023         752 :         if (convBldgGrossFloorArea > 0) {
    9024       10122 :             for (int iResource = 1; iResource <= 13; ++iResource) {
    9025       46995 :                 for (int jEndUse = 1; jEndUse <= 4; ++jEndUse) {
    9026       37596 :                     tableBody(iResource, jEndUse) = RealToStr(normalVal(iResource, jEndUse) / convBldgGrossFloorArea, 2);
    9027             :                 }
    9028             :             }
    9029             :         }
    9030             :         // heading for the entire sub-table
    9031         752 :         if (ort->displayTabularBEPS) {
    9032         752 :             if (produceTabular) {
    9033         752 :                 WriteSubtitle(state, "Utility Use Per Total Floor Area");
    9034         752 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9035             :             }
    9036         752 :             if (produceSQLite) {
    9037         752 :                 if (state.dataSQLiteProcedures->sqlite) {
    9038         121 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9039             :                                                                                        rowHead,
    9040             :                                                                                        columnHead,
    9041             :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    9042             :                                                                                        "Entire Facility",
    9043             :                                                                                        "Utility Use Per Total Floor Area");
    9044             :                 }
    9045             :             }
    9046         752 :             if (produceTabular) {
    9047         752 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9048           7 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    9049             :                                                                                                           rowHead,
    9050             :                                                                                                           columnHead,
    9051             :                                                                                                           "AnnualBuildingUtilityPerformanceSummary",
    9052             :                                                                                                           "Entire Facility",
    9053             :                                                                                                           "Utility Use Per Total Floor Area");
    9054             :                 }
    9055             :             }
    9056             :         }
    9057             : 
    9058             :         //---- Electric Loads Satisfied Sub-Table
    9059         752 :         rowHead.allocate(14);
    9060         752 :         columnHead.allocate(2);
    9061         752 :         columnWidth.allocate(2);
    9062         752 :         columnWidth = 14; // array assignment - same for all columns
    9063         752 :         tableBody.allocate(2, 14);
    9064             : 
    9065         752 :         switch (unitsStyle_cur) {
    9066           6 :         case UnitsStyle::JtoKWH: {
    9067           6 :             columnHead(1) = "Electricity [kWh]";
    9068           6 :         } break;
    9069          11 :         case UnitsStyle::InchPound: {
    9070          11 :             columnHead(1) = "Electricity [kBtu]";
    9071          11 :         } break;
    9072           0 :         case UnitsStyle::InchPoundExceptElectricity: {
    9073           0 :             columnHead(1) = "Electricity [kWh]";
    9074           0 :         } break;
    9075         735 :         default: {
    9076         735 :             columnHead(1) = "Electricity [GJ]";
    9077         735 :         } break;
    9078             :         }
    9079         752 :         columnHead(2) = "Percent Electricity [%]";
    9080             : 
    9081         752 :         rowHead(1) = "Fuel-Fired Power Generation";
    9082         752 :         rowHead(2) = "High Temperature Geothermal*";
    9083         752 :         rowHead(3) = "Photovoltaic Power";
    9084         752 :         rowHead(4) = "Wind Power";
    9085         752 :         rowHead(5) = "Power Conversion";
    9086         752 :         rowHead(6) = "Net Decrease in On-Site Storage";
    9087         752 :         rowHead(7) = "Total On-Site Electric Sources";
    9088         752 :         rowHead(8) = "";
    9089         752 :         rowHead(9) = "Electricity Coming From Utility";
    9090         752 :         rowHead(10) = "Surplus Electricity Going To Utility";
    9091         752 :         rowHead(11) = "Net Electricity From Utility";
    9092         752 :         rowHead(12) = "";
    9093         752 :         rowHead(13) = "Total On-Site and Utility Electric Sources";
    9094         752 :         rowHead(14) = "Total Electricity End Uses";
    9095             : 
    9096         752 :         tableBody = "";
    9097             : 
    9098             :         // show annual values
    9099         752 :         tableBody(1, 1) = RealToStr(ort->gatherPowerFuelFireGen, 3);
    9100         752 :         tableBody(1, 2) = RealToStr(ort->gatherPowerHTGeothermal, 3);
    9101         752 :         tableBody(1, 3) = RealToStr(ort->gatherPowerPV, 3);
    9102         752 :         if (produceTabular) {
    9103         752 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedRenAnGen, "Photovoltaic", unconvert_ipExceptElec * ort->gatherPowerPV, 2);
    9104             :         }
    9105         752 :         tableBody(1, 4) = RealToStr(ort->gatherPowerWind, 3);
    9106         752 :         if (produceTabular) {
    9107         752 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedRenAnGen, "Wind", unconvert_ipExceptElec * ort->gatherPowerWind, 2);
    9108             :         }
    9109         752 :         tableBody(1, 5) = RealToStr(ort->gatherPowerConversion, 3);
    9110         752 :         tableBody(1, 6) = RealToStr(ort->OverallNetEnergyFromStorage, 3);
    9111         752 :         tableBody(1, 7) = RealToStr(ort->gatherElecProduced, 3);
    9112         752 :         tableBody(1, 9) = RealToStr(ort->gatherElecPurchased, 3);
    9113         752 :         tableBody(1, 10) = RealToStr(ort->gatherElecSurplusSold, 3);
    9114         752 :         tableBody(1, 11) = RealToStr(ort->gatherElecPurchased - ort->gatherElecSurplusSold, 3);
    9115         752 :         tableBody(1, 13) = RealToStr(ort->gatherElecProduced + (ort->gatherElecPurchased - ort->gatherElecSurplusSold), 3);
    9116         752 :         tableBody(1, 14) = RealToStr(collapsedTotal(1), 3);
    9117             : 
    9118             :         // show annual percentages
    9119         752 :         if (collapsedTotal(1) > 0) {
    9120           5 :             tableBody(2, 1) = RealToStr(100.0 * ort->gatherPowerFuelFireGen / collapsedTotal(1), 2);
    9121           5 :             tableBody(2, 2) = RealToStr(100.0 * ort->gatherPowerHTGeothermal / collapsedTotal(1), 2);
    9122           5 :             tableBody(2, 3) = RealToStr(100.0 * ort->gatherPowerPV / collapsedTotal(1), 2);
    9123           5 :             tableBody(2, 4) = RealToStr(100.0 * ort->gatherPowerWind / collapsedTotal(1), 2);
    9124           5 :             tableBody(2, 5) = RealToStr(100.0 * ort->gatherPowerConversion / collapsedTotal(1), 2);
    9125           5 :             tableBody(2, 6) = RealToStr(100.0 * ort->OverallNetEnergyFromStorage / collapsedTotal(1), 2);
    9126           5 :             tableBody(2, 7) = RealToStr(100.0 * ort->gatherElecProduced / collapsedTotal(1), 2);
    9127           5 :             tableBody(2, 9) = RealToStr(100.0 * ort->gatherElecPurchased / collapsedTotal(1), 2);
    9128           5 :             tableBody(2, 10) = RealToStr(100.0 * ort->gatherElecSurplusSold / collapsedTotal(1), 2);
    9129           5 :             tableBody(2, 11) = RealToStr(100.0 * (ort->gatherElecPurchased - ort->gatherElecSurplusSold) / collapsedTotal(1), 2);
    9130           5 :             tableBody(2, 13) =
    9131          10 :                 RealToStr(100.0 * (ort->gatherElecProduced + (ort->gatherElecPurchased - ort->gatherElecSurplusSold)) / collapsedTotal(1), 2);
    9132           5 :             tableBody(2, 14) = RealToStr(100.0, 2);
    9133             :         }
    9134             : 
    9135             :         // heading for the entire sub-table
    9136         752 :         if (ort->displayTabularBEPS) {
    9137         752 :             if (produceTabular) {
    9138         752 :                 WriteSubtitle(state, "Electric Loads Satisfied");
    9139         752 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9140             :             }
    9141         752 :             if (produceSQLite) {
    9142         752 :                 if (state.dataSQLiteProcedures->sqlite) {
    9143         121 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9144             :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Electric Loads Satisfied");
    9145             :                 }
    9146             :             }
    9147         752 :             if (produceTabular) {
    9148         752 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9149           7 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9150             :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Electric Loads Satisfied");
    9151             :                 }
    9152             :             }
    9153             :         }
    9154             : 
    9155             :         //---- On-Site Thermal Sources Sub-Table
    9156         752 :         rowHead.allocate(7);
    9157         752 :         columnHead.allocate(2);
    9158         752 :         columnWidth.allocate(2);
    9159         752 :         columnWidth = 14; // array assignment - same for all columns
    9160         752 :         tableBody.allocate(2, 7);
    9161             : 
    9162         752 :         switch (unitsStyle_cur) {
    9163           6 :         case UnitsStyle::JtoKWH: {
    9164           6 :             columnHead(1) = "Heat [kWh]";
    9165           6 :         } break;
    9166          11 :         case UnitsStyle::InchPound: {
    9167          11 :             columnHead(1) = "Heat [kBtu]";
    9168          11 :         } break;
    9169           0 :         case UnitsStyle::InchPoundExceptElectricity: {
    9170           0 :             columnHead(1) = "Heat [kBtu]";
    9171           0 :         } break;
    9172         735 :         default: {
    9173         735 :             columnHead(1) = "Heat [GJ]";
    9174         735 :         } break;
    9175             :         }
    9176             : 
    9177         752 :         columnHead(2) = "Percent Heat [%]";
    9178             : 
    9179         752 :         rowHead(1) = "Water-Side Heat Recovery";
    9180         752 :         rowHead(2) = "Air to Air Heat Recovery for Cooling";
    9181         752 :         rowHead(3) = "Air to Air Heat Recovery for Heating";
    9182         752 :         rowHead(4) = "High-Temperature Geothermal*";
    9183         752 :         rowHead(5) = "Solar Water Thermal";
    9184         752 :         rowHead(6) = "Solar Air Thermal";
    9185         752 :         rowHead(7) = "Total On-Site Thermal Sources";
    9186             : 
    9187         752 :         tableBody = "";
    9188             : 
    9189         752 :         if (iUnitSystem == 0) {
    9190         752 :             gtWaterHeatRecovery = ort->gatherWaterHeatRecovery;
    9191         752 :             gtAirHeatRecoveryCool = ort->gatherAirHeatRecoveryCool;
    9192         752 :             gtAirHeatRecoveryHeat = ort->gatherAirHeatRecoveryHeat;
    9193         752 :             gtHeatHTGeothermal = ort->gatherHeatHTGeothermal;
    9194         752 :             gtHeatSolarWater = ort->gatherHeatSolarWater;
    9195         752 :             gtHeatSolarAir = ort->gatherHeatSolarAir;
    9196             :         } else {
    9197           0 :             ort->gatherWaterHeatRecovery = gtWaterHeatRecovery;
    9198           0 :             ort->gatherAirHeatRecoveryCool = gtAirHeatRecoveryCool;
    9199           0 :             ort->gatherAirHeatRecoveryHeat = gtAirHeatRecoveryHeat;
    9200           0 :             ort->gatherHeatHTGeothermal = gtHeatHTGeothermal;
    9201           0 :             ort->gatherHeatSolarWater = gtHeatSolarWater;
    9202           0 :             ort->gatherHeatSolarAir = gtHeatSolarAir;
    9203             :         }
    9204             : 
    9205             :         // convert to GJ
    9206         752 :         ort->gatherWaterHeatRecovery /= largeConversionFactor;
    9207         752 :         ort->gatherAirHeatRecoveryCool /= largeConversionFactor;
    9208         752 :         ort->gatherAirHeatRecoveryHeat /= largeConversionFactor;
    9209         752 :         ort->gatherHeatHTGeothermal /= largeConversionFactor;
    9210         752 :         ort->gatherHeatSolarWater /= largeConversionFactor;
    9211         752 :         ort->gatherHeatSolarAir /= largeConversionFactor;
    9212             : 
    9213             :         // determine total on site heat
    9214         752 :         Real64 const totalOnsiteHeat = ort->gatherWaterHeatRecovery + ort->gatherAirHeatRecoveryCool + ort->gatherAirHeatRecoveryHeat +
    9215         752 :                                        ort->gatherHeatHTGeothermal + ort->gatherHeatSolarWater + ort->gatherHeatSolarAir;
    9216             : 
    9217             :         // show annual values
    9218         752 :         tableBody(1, 1) = RealToStr(ort->gatherWaterHeatRecovery, 2);
    9219         752 :         tableBody(1, 2) = RealToStr(ort->gatherAirHeatRecoveryCool, 2);
    9220         752 :         tableBody(1, 3) = RealToStr(ort->gatherAirHeatRecoveryHeat, 2);
    9221         752 :         tableBody(1, 4) = RealToStr(ort->gatherHeatHTGeothermal, 2);
    9222         752 :         tableBody(1, 5) = RealToStr(ort->gatherHeatSolarWater, 2);
    9223         752 :         tableBody(1, 6) = RealToStr(ort->gatherHeatSolarAir, 2);
    9224         752 :         tableBody(1, 7) = RealToStr(totalOnsiteHeat, 2);
    9225             : 
    9226         752 :         if (totalOnsiteHeat > 0) {
    9227           0 :             tableBody(2, 1) = RealToStr(100.0 * ort->gatherWaterHeatRecovery / totalOnsiteHeat, 2);
    9228           0 :             tableBody(2, 2) = RealToStr(100.0 * ort->gatherAirHeatRecoveryCool / totalOnsiteHeat, 2);
    9229           0 :             tableBody(2, 3) = RealToStr(100.0 * ort->gatherAirHeatRecoveryHeat / totalOnsiteHeat, 2);
    9230           0 :             tableBody(2, 4) = RealToStr(100.0 * ort->gatherHeatHTGeothermal / totalOnsiteHeat, 2);
    9231           0 :             tableBody(2, 5) = RealToStr(100.0 * ort->gatherHeatSolarWater / totalOnsiteHeat, 2);
    9232           0 :             tableBody(2, 6) = RealToStr(100.0 * ort->gatherHeatSolarAir / totalOnsiteHeat, 2);
    9233           0 :             tableBody(2, 7) = RealToStr(100.0, 2);
    9234             :         }
    9235             : 
    9236             :         // heading for the entire sub-table
    9237         752 :         if (ort->displayTabularBEPS) {
    9238         752 :             if (produceTabular) {
    9239         752 :                 WriteSubtitle(state, "On-Site Thermal Sources");
    9240         752 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9241             :             }
    9242         752 :             if (produceSQLite) {
    9243         752 :                 if (state.dataSQLiteProcedures->sqlite) {
    9244         121 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9245             :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "On-Site Thermal Sources");
    9246             :                 }
    9247             :             }
    9248         752 :             if (produceTabular) {
    9249         752 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9250           7 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9251             :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "On-Site Thermal Sources");
    9252             :                 }
    9253             :             }
    9254             :         }
    9255             : 
    9256             :         //---- Water Loads Sub-Table
    9257             :         // As of 12/8/2003 decided to not include this sub-table to wait
    9258             :         // until water use is implemented in EnergyPlus before displaying
    9259             :         // the table. Implementing water end-uses makes sense for EnergyPlus
    9260             :         // but since they are not really implemented as of December 2003 the
    9261             :         // table would be all zeros.  Recommendation to exclude this table
    9262             :         // for now made by Glazer and Crawley.
    9263             :         // Aug 2006, adding table in with implementation of water system, BGriffith
    9264         752 :         rowHead.allocate(13);
    9265         752 :         columnHead.allocate(2);
    9266         752 :         columnWidth.allocate(2);
    9267         752 :         columnWidth = 14; // array assignment - same for all columns
    9268         752 :         tableBody.allocate(2, 13);
    9269         752 :         switch (unitsStyle_cur) {
    9270           6 :         case UnitsStyle::JtoKWH: {
    9271           6 :             columnHead(1) = "Water [m3]";
    9272           6 :         } break;
    9273          11 :         case UnitsStyle::InchPound: {
    9274          11 :             columnHead(1) = "Water [gal]";
    9275          11 :         } break;
    9276           0 :         case UnitsStyle::InchPoundExceptElectricity: {
    9277           0 :             columnHead(1) = "Water [gal]";
    9278           0 :         } break;
    9279         735 :         default: {
    9280         735 :             columnHead(1) = "Water [m3]";
    9281         735 :         } break;
    9282             :         }
    9283             : 
    9284         752 :         columnHead(2) = "Percent Water [%]";
    9285         752 :         rowHead(1) = "Rainwater Collection";
    9286         752 :         rowHead(2) = "Condensate Collection";
    9287         752 :         rowHead(3) = "Groundwater Well";
    9288         752 :         rowHead(4) = "Total On Site Water Sources";
    9289         752 :         rowHead(5) = "-";
    9290         752 :         rowHead(6) = "Initial Storage";
    9291         752 :         rowHead(7) = "Final Storage";
    9292         752 :         rowHead(8) = "Change in Storage";
    9293         752 :         rowHead(9) = "-";
    9294         752 :         rowHead(10) = "Water Supplied by Utility";
    9295         752 :         rowHead(11) = "-";
    9296         752 :         rowHead(12) = "Total On Site, Change in Storage, and Utility Water Sources";
    9297         752 :         rowHead(13) = "Total Water End Uses";
    9298         752 :         tableBody = "-";
    9299             : 
    9300         752 :         Real64 const totalOnsiteWater = ort->gatherRainWater + ort->gatherCondensate + ort->gatherWellwater;
    9301             : 
    9302             :         //  ! show annual values
    9303         752 :         tableBody(1, 1) = RealToStr(ort->gatherRainWater / waterConversionFactor, 2);
    9304         752 :         tableBody(1, 2) = RealToStr(ort->gatherCondensate / waterConversionFactor, 2);
    9305         752 :         tableBody(1, 3) = RealToStr(ort->gatherWellwater / waterConversionFactor, 2);
    9306         752 :         tableBody(1, 4) = RealToStr(totalOnsiteWater / waterConversionFactor, 2);
    9307             : 
    9308         752 :         Real64 initialStorage = 0.0;
    9309         752 :         Real64 finalStorage = 0.0;
    9310         752 :         Real64 StorageChange = 0.0;
    9311         752 :         if (allocated(state.dataWaterData->WaterStorage)) {
    9312           5 :             initialStorage = sum(state.dataWaterData->WaterStorage, &DataWater::StorageTankDataStruct::InitialVolume);
    9313           5 :             finalStorage = sum(state.dataWaterData->WaterStorage, &DataWater::StorageTankDataStruct::ThisTimeStepVolume);
    9314           5 :             StorageChange = initialStorage - finalStorage;
    9315             :         }
    9316         752 :         tableBody(1, 6) = RealToStr(initialStorage / waterConversionFactor, 2);
    9317         752 :         tableBody(1, 7) = RealToStr(finalStorage / waterConversionFactor, 2);
    9318         752 :         tableBody(1, 8) = RealToStr(StorageChange / waterConversionFactor, 2);
    9319             : 
    9320         752 :         Real64 const totalWater = totalOnsiteWater + ort->gatherMains + StorageChange;
    9321             : 
    9322         752 :         tableBody(1, 10) = RealToStr(ort->gatherMains / waterConversionFactor, 2);
    9323         752 :         tableBody(1, 12) = RealToStr(totalWater / waterConversionFactor, 2);
    9324         752 :         tableBody(1, 13) = RealToStr(ort->gatherWaterEndUseTotal / waterConversionFactor, 2);
    9325             : 
    9326         752 :         if (ort->gatherWaterEndUseTotal > 0) {
    9327           0 :             tableBody(2, 1) = RealToStr(100.0 * ort->gatherRainWater / ort->gatherWaterEndUseTotal, 2);
    9328           0 :             tableBody(2, 2) = RealToStr(100.0 * ort->gatherCondensate / ort->gatherWaterEndUseTotal, 2);
    9329           0 :             tableBody(2, 3) = RealToStr(100.0 * ort->gatherWellwater / ort->gatherWaterEndUseTotal, 2);
    9330           0 :             tableBody(2, 4) = RealToStr(100.0 * totalOnsiteWater / ort->gatherWaterEndUseTotal, 2);
    9331           0 :             tableBody(2, 6) = RealToStr(100.0 * initialStorage / ort->gatherWaterEndUseTotal, 2);
    9332           0 :             tableBody(2, 7) = RealToStr(100.0 * finalStorage / ort->gatherWaterEndUseTotal, 2);
    9333           0 :             tableBody(2, 8) = RealToStr(100.0 * StorageChange / ort->gatherWaterEndUseTotal, 2);
    9334             : 
    9335           0 :             tableBody(2, 10) = RealToStr(100.0 * ort->gatherMains / ort->gatherWaterEndUseTotal, 2);
    9336             : 
    9337           0 :             tableBody(2, 12) = RealToStr(100.0 * totalWater / ort->gatherWaterEndUseTotal, 2);
    9338           0 :             tableBody(2, 13) = RealToStr(100.0, 2);
    9339             :         }
    9340             : 
    9341             :         //  ! heading for the entire sub-table
    9342         752 :         if (ort->displayTabularBEPS) {
    9343         752 :             if (produceTabular) {
    9344         752 :                 WriteSubtitle(state, "Water Source Summary");
    9345         752 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9346             :             }
    9347         752 :             if (produceSQLite) {
    9348         752 :                 if (state.dataSQLiteProcedures->sqlite) {
    9349         121 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9350             :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Water Source Summary");
    9351             :                 }
    9352             :             }
    9353         752 :             if (produceTabular) {
    9354         752 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9355           7 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9356             :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Water Source Summary");
    9357             :                 }
    9358             :             }
    9359             : 
    9360             :             //---- Comfort and Setpoint Not Met Sub-Table
    9361         752 :             rowHead.allocate(2);
    9362         752 :             columnHead.allocate(1);
    9363         752 :             columnWidth.allocate(1);
    9364         752 :             columnWidth = 14; // array assignment - same for all columns
    9365         752 :             tableBody.allocate(1, 2);
    9366             : 
    9367         752 :             if (produceTabular) {
    9368         752 :                 WriteSubtitle(state, "Setpoint Not Met Criteria");
    9369             :             }
    9370             : 
    9371         752 :             std::string const curNameWithSIUnits = "Degrees [deltaC]";
    9372         752 :             if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    9373         741 :                 unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
    9374          11 :                 int indexUnitConv = -1;
    9375          11 :                 std::string curNameAndUnits;
    9376          11 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    9377          11 :                 columnHead(1) = curNameAndUnits;
    9378          11 :             } else {
    9379         741 :                 columnHead(1) = curNameWithSIUnits;
    9380             :             }
    9381             : 
    9382         752 :             rowHead(1) = "Tolerance for Zone Heating Setpoint Not Met Time";
    9383         752 :             rowHead(2) = "Tolerance for Zone Cooling Setpoint Not Met Time";
    9384             : 
    9385         752 :             if (!(unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    9386         741 :                   unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
    9387         741 :                 tableBody(1, 1) = RealToStr(std::abs(state.dataHVACGlobal->deviationFromSetPtThresholdHtg), 2);
    9388         741 :                 tableBody(1, 2) = RealToStr(state.dataHVACGlobal->deviationFromSetPtThresholdClg, 2);
    9389             :             } else {
    9390          11 :                 int indexUnitConv = -1;
    9391          11 :                 std::string curNameAndUnits;
    9392          11 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    9393          11 :                 tableBody(1, 1) = RealToStr(ConvertIPdelta(state, indexUnitConv, std::abs(state.dataHVACGlobal->deviationFromSetPtThresholdHtg)), 2);
    9394          11 :                 tableBody(1, 2) = RealToStr(ConvertIPdelta(state, indexUnitConv, state.dataHVACGlobal->deviationFromSetPtThresholdClg), 2);
    9395          11 :             }
    9396             : 
    9397         752 :             if (produceTabular) {
    9398         752 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9399             :             }
    9400         752 :             if (produceSQLite) {
    9401         752 :                 if (state.dataSQLiteProcedures->sqlite) {
    9402         121 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9403             :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Setpoint Not Met Criteria");
    9404             :                 }
    9405             :             }
    9406         752 :             if (produceTabular) {
    9407         752 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9408           7 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9409             :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Setpoint Not Met Criteria");
    9410             :                 }
    9411             :             }
    9412         752 :         }
    9413             : 
    9414         752 :         rowHead.allocate(3);
    9415         752 :         columnHead.allocate(1);
    9416         752 :         columnWidth.allocate(1);
    9417         752 :         columnWidth = 14; // array assignment - same for all columns
    9418         752 :         tableBody.allocate(1, 3);
    9419             : 
    9420         752 :         if (ort->displayTabularBEPS) {
    9421         752 :             if (produceTabular) {
    9422         752 :                 WriteSubtitle(state, "Comfort and Setpoint Not Met Summary");
    9423             :             }
    9424             :         }
    9425             : 
    9426         752 :         columnHead(1) = "Facility [Hours]";
    9427             : 
    9428         752 :         rowHead(1) = "Time Setpoint Not Met During Occupied Heating";
    9429         752 :         rowHead(2) = "Time Setpoint Not Met During Occupied Cooling";
    9430         752 :         rowHead(3) = "Time Not Comfortable Based on Simple ASHRAE 55-2004";
    9431             : 
    9432         752 :         tableBody(1, 1) = RealToStr(state.dataOutRptPredefined->TotalNotMetHeatingOccupiedForABUPS, 2);
    9433         752 :         tableBody(1, 2) = RealToStr(state.dataOutRptPredefined->TotalNotMetCoolingOccupiedForABUPS, 2);
    9434         752 :         if (produceTabular) {
    9435        1504 :             PreDefTableEntry(state,
    9436         752 :                              state.dataOutRptPredefined->pdchLeedAmData,
    9437             :                              "Number of hours heating loads not met",
    9438        1504 :                              RealToStr(state.dataOutRptPredefined->TotalNotMetHeatingOccupiedForABUPS, 2));
    9439        1504 :             PreDefTableEntry(state,
    9440         752 :                              state.dataOutRptPredefined->pdchLeedAmData,
    9441             :                              "Number of hours cooling loads not met",
    9442        1504 :                              RealToStr(state.dataOutRptPredefined->TotalNotMetCoolingOccupiedForABUPS, 2));
    9443        1504 :             PreDefTableEntry(state,
    9444         752 :                              state.dataOutRptPredefined->pdchLeedAmData,
    9445             :                              "Number of hours not met",
    9446        1504 :                              RealToStr(state.dataOutRptPredefined->TotalNotMetOccupiedForABUPS, 2));
    9447             :         }
    9448         752 :         tableBody(1, 3) = RealToStr(state.dataOutRptPredefined->TotalTimeNotSimpleASH55EitherForABUPS, 2);
    9449             : 
    9450         752 :         if (ort->displayTabularBEPS) {
    9451         752 :             if (produceTabular) {
    9452         752 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9453             :             }
    9454         752 :             if (produceSQLite) {
    9455         752 :                 if (state.dataSQLiteProcedures->sqlite) {
    9456         121 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9457             :                                                                                        rowHead,
    9458             :                                                                                        columnHead,
    9459             :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    9460             :                                                                                        "Entire Facility",
    9461             :                                                                                        "Comfort and Setpoint Not Met Summary");
    9462             :                 }
    9463             :             }
    9464         752 :             if (produceTabular) {
    9465         752 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9466           7 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    9467             :                                                                                                           rowHead,
    9468             :                                                                                                           columnHead,
    9469             :                                                                                                           "AnnualBuildingUtilityPerformanceSummary",
    9470             :                                                                                                           "Entire Facility",
    9471             :                                                                                                           "Comfort and Setpoint Not Met Summary");
    9472             :                 }
    9473             :             }
    9474             :         }
    9475             :     }
    9476             :     //---- Control Summary Sub-Table
    9477             : 
    9478             :     //---- End Notes
    9479         752 :     if (ort->displayTabularBEPS) {
    9480         752 :         WriteTextLine(state, "Note 1: An asterisk (*) indicates that the feature is not yet implemented.");
    9481             :     }
    9482         752 : }
    9483             : 
    9484           0 : std::string ResourceWarningMessage(std::string const &resource)
    9485             : {
    9486           0 :     return "In the Annual Building Utility Performance Summary Report the total row does not match the sum of the column for: " + resource;
    9487             : }
    9488             : 
    9489         752 : Real64 WaterConversionFunct(Real64 WaterTotal, Real64 ConversionFactor)
    9490             : {
    9491         752 :     return WaterTotal / ConversionFactor;
    9492             : }
    9493             : 
    9494        1504 : void writeBEPSEndUseBySubCatOrSpaceType(EnergyPlusData &state,
    9495             :                                         EndUseSubTableType tableType,
    9496             :                                         Array2D<Real64> &endUseSubOther,
    9497             :                                         Array2D<Real64> &collapsedEndUse,
    9498             :                                         Array3D<Real64> &collapsedEndUseSubTable,
    9499             :                                         Array1D_bool &needOtherRow,
    9500             :                                         const UnitsStyle unitsStyle_cur,
    9501             :                                         const bool produceTabular,
    9502             :                                         const bool produceSQLite)
    9503             : {
    9504        1504 :     auto const &ort = state.dataOutRptTab;
    9505        1504 :     auto &op = state.dataOutputProcessor;
    9506        1504 :     constexpr int numCol = 15;
    9507        1504 :     Array1D_string columnHead;
    9508        1504 :     Array1D_int columnWidth;
    9509        1504 :     columnHead.allocate(numCol);
    9510        1504 :     columnWidth.allocate(numCol);
    9511       24064 :     for (int col = 1; col <= numCol; ++col) {
    9512       22560 :         columnWidth(col) = 10; // array assignment - same for all columns
    9513             :     }
    9514        1504 :     switch (unitsStyle_cur) {
    9515          12 :     case UnitsStyle::JtoKWH: {
    9516          12 :         columnHead(2) = "Electricity [kWh]";
    9517          12 :         columnHead(3) = "Natural Gas [kWh]";
    9518          12 :         columnHead(4) = "Gasoline [kWh]";
    9519          12 :         columnHead(5) = "Diesel [kWh]";
    9520          12 :         columnHead(6) = "Coal [kWh]";
    9521          12 :         columnHead(7) = "Fuel Oil No 1 [kWh]";
    9522          12 :         columnHead(8) = "Fuel Oil No 2 [kWh]";
    9523          12 :         columnHead(9) = "Propane [kWh]";
    9524          12 :         columnHead(10) = "Other Fuel 1 [kWh]";
    9525          12 :         columnHead(11) = "Other Fuel 2 [kWh]";
    9526          12 :         columnHead(12) = "District Cooling [kWh]";
    9527          12 :         columnHead(13) = "District Heating Water [kWh]";
    9528          12 :         columnHead(14) = "District Heating Steam [kWh]";
    9529          12 :         columnHead(15) = "Water [m3]";
    9530          12 :     } break;
    9531          22 :     case UnitsStyle::InchPound: {
    9532          22 :         columnHead(2) = "Electricity [kBtu]";
    9533          22 :         columnHead(3) = "Natural Gas [kBtu]";
    9534          22 :         columnHead(4) = "Gasoline [kBtu]";
    9535          22 :         columnHead(5) = "Diesel [kBtu]";
    9536          22 :         columnHead(6) = "Coal [kBtu]";
    9537          22 :         columnHead(7) = "Fuel Oil No 1 [kBtu]";
    9538          22 :         columnHead(8) = "Fuel Oil No 2 [kBtu]";
    9539          22 :         columnHead(9) = "Propane [kBtu]";
    9540          22 :         columnHead(10) = "Other Fuel 1 [kBtu]";
    9541          22 :         columnHead(11) = "Other Fuel 2 [kBtu]";
    9542          22 :         columnHead(12) = "District Cooling [kBtu]";
    9543          22 :         columnHead(13) = "District Heating Water [kBtu]";
    9544          22 :         columnHead(14) = "District Heating Steam [kBtu]";
    9545          22 :         columnHead(15) = "Water [gal]";
    9546          22 :     } break;
    9547           0 :     case UnitsStyle::InchPoundExceptElectricity: {
    9548           0 :         columnHead(2) = "Electricity [kWh]";
    9549           0 :         columnHead(3) = "Natural Gas [kBtu]";
    9550           0 :         columnHead(4) = "Gasoline [kBtu]";
    9551           0 :         columnHead(5) = "Diesel [kBtu]";
    9552           0 :         columnHead(6) = "Coal [kBtu]";
    9553           0 :         columnHead(7) = "Fuel Oil No 1 [kBtu]";
    9554           0 :         columnHead(8) = "Fuel Oil No 2 [kBtu]";
    9555           0 :         columnHead(9) = "Propane [kBtu]";
    9556           0 :         columnHead(10) = "Other Fuel 1 [kBtu]";
    9557           0 :         columnHead(11) = "Other Fuel 2 [kBtu]";
    9558           0 :         columnHead(12) = "District Cooling [kBtu]";
    9559           0 :         columnHead(13) = "District Heating Water [kBtu]";
    9560           0 :         columnHead(14) = "District Heating Steam [kBtu]";
    9561           0 :         columnHead(15) = "Water [gal]";
    9562           0 :     } break;
    9563        1470 :     default: {
    9564        1470 :         columnHead(2) = "Electricity [GJ]";
    9565        1470 :         columnHead(3) = "Natural Gas [GJ]";
    9566        1470 :         columnHead(4) = "Gasoline [GJ]";
    9567        1470 :         columnHead(5) = "Diesel [GJ]";
    9568        1470 :         columnHead(6) = "Coal [GJ]";
    9569        1470 :         columnHead(7) = "Fuel Oil No 1 [GJ]";
    9570        1470 :         columnHead(8) = "Fuel Oil No 2 [GJ]";
    9571        1470 :         columnHead(9) = "Propane [GJ]";
    9572        1470 :         columnHead(10) = "Other Fuel 1 [GJ]";
    9573        1470 :         columnHead(11) = "Other Fuel 2 [GJ]";
    9574        1470 :         columnHead(12) = "District Cooling [GJ]";
    9575        1470 :         columnHead(13) = "District Heating Water [GJ]";
    9576        1470 :         columnHead(14) = "District Heating Steam [GJ]";
    9577        1470 :         columnHead(15) = "Water [m3]";
    9578        1470 :     } break;
    9579             :     }
    9580             : 
    9581        1504 :     int numSubCatOrTypes = 0;
    9582        1504 :     int numRows = 0;
    9583        1504 :     if (tableType == EndUseSubTableType::BySubCategory) {
    9584         752 :         columnHead(1) = "Subcategory";
    9585         752 :     } else if (tableType == EndUseSubTableType::BySpaceType) {
    9586         752 :         columnHead(1) = "Space Type";
    9587             :     }
    9588             : 
    9589             :     // determine number of rows and if subcategories add up to the total
    9590             :     // if not, determine the difference for the 'other' row
    9591       22560 :     for (int i = 1; i <= static_cast<int>(Constant::EndUse::Num); ++i) {
    9592       21056 :         needOtherRow(i) = false; // set array to all false assuming no other rows are needed
    9593             :     }
    9594       22560 :     for (int iResource = 1; iResource <= 14; ++iResource) {
    9595      315840 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9596      294784 :             if (tableType == EndUseSubTableType::BySubCategory) {
    9597      147392 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9598      147392 :             } else if (tableType == EndUseSubTableType::BySpaceType) {
    9599      147392 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9600             :             }
    9601      294784 :             if (numSubCatOrTypes > 0) {
    9602             :                 // set the value to the total for the end use
    9603       91672 :                 endUseSubOther(iResource, jEndUse) = collapsedEndUse(iResource, jEndUse);
    9604             :                 // subtract off each sub end use category value
    9605      197260 :                 for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9606      105588 :                     endUseSubOther(iResource, jEndUse) -= collapsedEndUseSubTable(kEndUseSub, jEndUse, iResource);
    9607             :                 }
    9608             :                 // if just a small value remains set it to zero
    9609       91672 :                 if (std::abs(endUseSubOther(iResource, jEndUse)) > 0.01) {
    9610           0 :                     needOtherRow(jEndUse) = true;
    9611             :                 } else {
    9612       91672 :                     endUseSubOther(iResource, jEndUse) = 0.0;
    9613             :                 }
    9614             :             } else {
    9615      203112 :                 endUseSubOther(iResource, jEndUse) = 0.0;
    9616             :             }
    9617             :         }
    9618             :     }
    9619             : 
    9620       22560 :     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9621       21056 :         if (tableType == EndUseSubTableType::BySubCategory) {
    9622       10528 :             numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9623       10528 :         } else if (tableType == EndUseSubTableType::BySpaceType) {
    9624       10528 :             numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9625             :         }
    9626       21056 :         if (numSubCatOrTypes > 0) {
    9627       14090 :             for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9628        7542 :                 ++numRows;
    9629             :             }
    9630        6548 :             if (needOtherRow(jEndUse)) {
    9631           0 :                 ++numRows;
    9632             :             }
    9633             :         } else {
    9634       14508 :             ++numRows;
    9635             :         }
    9636             :     }
    9637             :     // all arrays are in the format: (row, column)
    9638        3008 :     Array1D_string rowHead;
    9639        3008 :     Array2D_string tableBody;
    9640        1504 :     rowHead.allocate(numRows);
    9641        1504 :     tableBody.allocate(numCol, numRows); // TODO: this appears to be (column, row)...
    9642       24064 :     for (int col = 1; col <= numCol; ++col) {
    9643      353310 :         for (int row = 1; row <= numRows; ++row) {
    9644      330750 :             rowHead(row) = "";
    9645      330750 :             tableBody(col, row) = "";
    9646             :         }
    9647             :     }
    9648             : 
    9649             :     // Build row head and subcategories columns
    9650             :     {
    9651        1504 :         int i = 1;
    9652       22560 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9653       21056 :             if (tableType == EndUseSubTableType::BySubCategory) {
    9654       10528 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9655       10528 :             } else if (tableType == EndUseSubTableType::BySpaceType) {
    9656       10528 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9657             :             }
    9658       21056 :             rowHead(i) = op->EndUseCategory(jEndUse).DisplayName;
    9659       21056 :             if (numSubCatOrTypes > 0) {
    9660       14090 :                 for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9661        7542 :                     if (tableType == EndUseSubTableType::BySubCategory) {
    9662        6233 :                         tableBody(1, i) = op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub);
    9663        1309 :                     } else if (tableType == EndUseSubTableType::BySpaceType) {
    9664        1309 :                         tableBody(1, i) = op->EndUseCategory(jEndUse).spaceTypeName(kEndUseSub);
    9665             :                     }
    9666        7542 :                     ++i;
    9667             :                 }
    9668             :                 // check if an 'other' row is needed
    9669        6548 :                 if (needOtherRow(jEndUse)) {
    9670           0 :                     tableBody(1, i) = "Other";
    9671           0 :                     ++i;
    9672             :                 }
    9673             :             } else {
    9674       14508 :                 if (tableType == EndUseSubTableType::BySubCategory) {
    9675        5268 :                     tableBody(1, i) = "General";
    9676        9240 :                 } else if (tableType == EndUseSubTableType::BySpaceType) {
    9677        9240 :                     tableBody(1, i) = "Unassigned";
    9678             :                 }
    9679       14508 :                 ++i;
    9680             :             }
    9681             :         }
    9682             :     }
    9683             : 
    9684       22560 :     for (int iResource = 1; iResource <= 14; ++iResource) {
    9685       21056 :         int i = 1;
    9686      315840 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9687      294784 :             if (tableType == EndUseSubTableType::BySubCategory) {
    9688      147392 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9689      147392 :             } else if (tableType == EndUseSubTableType::BySpaceType) {
    9690      147392 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9691             :             }
    9692      294784 :             if (numSubCatOrTypes > 0) {
    9693      197260 :                 for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9694      105588 :                     tableBody(iResource + 1, i) = RealToStr(collapsedEndUseSubTable(kEndUseSub, jEndUse, iResource), 2);
    9695      105588 :                     ++i;
    9696             :                 }
    9697             :                 // put other
    9698       91672 :                 if (needOtherRow(jEndUse)) {
    9699           0 :                     tableBody(iResource + 1, i) = RealToStr(endUseSubOther(iResource, jEndUse), 2);
    9700           0 :                     ++i;
    9701             :                 }
    9702             :             } else {
    9703      203112 :                 tableBody(iResource + 1, i) = RealToStr(collapsedEndUse(iResource, jEndUse), 2);
    9704      203112 :                 ++i;
    9705             :             }
    9706             :         }
    9707             :     }
    9708             : 
    9709             :     // heading for the entire sub-table
    9710        1504 :     if (ort->displayTabularBEPS) {
    9711        1504 :         std::string subTableTitle;
    9712        1504 :         if (tableType == EndUseSubTableType::BySubCategory) {
    9713         752 :             subTableTitle = "End Uses By Subcategory";
    9714         752 :         } else if (tableType == EndUseSubTableType::BySpaceType) {
    9715         752 :             subTableTitle = "End Uses By Space Type";
    9716             :         }
    9717        1504 :         if (produceTabular) {
    9718        1504 :             WriteSubtitle(state, subTableTitle);
    9719        1504 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9720             :         }
    9721        1504 :         Array1D_string rowHeadTemp(rowHead);
    9722             :         // Before outputing to SQL, we forward fill the End use column (rowHead)
    9723             :         // for better sql queries
    9724        1504 :         FillRowHead(rowHeadTemp);
    9725             : 
    9726       23554 :         for (int i = 1; i <= numRows; ++i) {
    9727       22050 :             rowHeadTemp(i) = rowHeadTemp(i) + ":" + tableBody(1, i);
    9728             :         }
    9729             : 
    9730             :         // Erase the SubCategory (first column), using slicing
    9731       13536 :         Array2D_string tableBodyTemp(tableBody({2, _, _}, {_, _, _}));
    9732        7520 :         Array1D_string columnHeadTemp(columnHead({2, _, _}));
    9733        1504 :         if (produceSQLite) {
    9734        1504 :             if (state.dataSQLiteProcedures->sqlite) {
    9735         242 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9736             :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", subTableTitle);
    9737             :             }
    9738             :         }
    9739        1504 :         if (produceTabular) {
    9740        1504 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9741          14 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9742             :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", subTableTitle);
    9743             :             }
    9744             :         }
    9745        1504 :         rowHeadTemp.deallocate();
    9746        1504 :         tableBodyTemp.deallocate();
    9747        1504 :         columnHeadTemp.deallocate();
    9748        1504 :     }
    9749        1504 : }
    9750         754 : void WriteSourceEnergyEndUseSummary(EnergyPlusData &state)
    9751             : {
    9752             :     // SUBROUTINE INFORMATION:
    9753             :     //       AUTHOR         Mangesh Basarkar
    9754             :     //       DATE WRITTEN   September 2011
    9755             :     //       MODIFIED       March 2020, Dareum Nam; Disaggregated "Additional Fuel"
    9756             :     //       RE-ENGINEERED  na
    9757             : 
    9758             :     // PURPOSE OF THIS SUBROUTINE:
    9759             :     //   Take the gathered total and end use source energy meter data and structure
    9760             :     //   the results into a tabular report for output.
    9761             : 
    9762             :     // METHODOLOGY EMPLOYED:
    9763             :     //   Create arrays for the call to WriteTable and then call it.
    9764             : 
    9765         754 :     auto &ort = state.dataOutRptTab;
    9766             : 
    9767         754 :     if (!ort->displaySourceEnergyEndUseSummary) {
    9768          82 :         return;
    9769             :     }
    9770             : 
    9771             :     // all arrays are in the format: (row, column)
    9772         672 :     Array1D_string columnHead;
    9773         672 :     Array1D_int columnWidth;
    9774         672 :     Array1D_string rowHead;
    9775         672 :     Array2D_string tableBody;
    9776             : 
    9777             :     // all arrays are in the format: (row, columnm)
    9778        1344 :     Array2D<Real64> useVal(14, 15);
    9779         672 :     Array1D<Real64> collapsedTotal(14);
    9780        1344 :     Array2D<Real64> collapsedEndUse(14, static_cast<int>(Constant::EndUse::Num));
    9781        1344 :     Array3D<Real64> collapsedEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
    9782             : 
    9783             :     // show the headers of the report
    9784         672 :     WriteReportHeaders(state, "Source Energy End Use Components Summary", "Entire Facility", OutputProcessor::StoreType::Average);
    9785             :     // show the number of hours that the table applies to
    9786         672 :     WriteTextLine(state, "Values gathered over " + RealToStr(ort->gatherElapsedTimeBEPS, 2) + " hours", true);
    9787         672 :     if (ort->gatherElapsedTimeBEPS < 8759.0) { // might not add up to 8760 exactly but can't be more than 1 hour diff.
    9788         667 :         WriteTextLine(state, "WARNING: THE REPORT DOES NOT REPRESENT A FULL ANNUAL SIMULATION.", true);
    9789             :     }
    9790         672 :     WriteTextLine(state, "", true);
    9791             : 
    9792             :     // determine building floor areas
    9793         672 :     DetermineBuildingFloorArea(state);
    9794             : 
    9795        1344 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    9796        1344 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    9797        1344 :         bool produceTabular = true;
    9798        1344 :         bool produceSQLite = false;
    9799        1344 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
    9800             : 
    9801             :         // collapse the gatherEndUseBEPS array to the resource groups displayed
    9802       10080 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9803        9408 :             collapsedEndUse(1, jEndUse) = ort->gatherEndUseBySourceBEPS(1, jEndUse);   // electricity
    9804        9408 :             collapsedEndUse(2, jEndUse) = ort->gatherEndUseBySourceBEPS(2, jEndUse);   // natural gas
    9805        9408 :             collapsedEndUse(3, jEndUse) = ort->gatherEndUseBySourceBEPS(6, jEndUse);   // gasoline
    9806        9408 :             collapsedEndUse(4, jEndUse) = ort->gatherEndUseBySourceBEPS(8, jEndUse);   // diesel
    9807        9408 :             collapsedEndUse(5, jEndUse) = ort->gatherEndUseBySourceBEPS(9, jEndUse);   // coal
    9808        9408 :             collapsedEndUse(6, jEndUse) = ort->gatherEndUseBySourceBEPS(10, jEndUse);  // Fuel Oil No1
    9809        9408 :             collapsedEndUse(7, jEndUse) = ort->gatherEndUseBySourceBEPS(11, jEndUse);  // Fuel Oil No2
    9810        9408 :             collapsedEndUse(8, jEndUse) = ort->gatherEndUseBySourceBEPS(12, jEndUse);  // propane
    9811        9408 :             collapsedEndUse(9, jEndUse) = ort->gatherEndUseBySourceBEPS(13, jEndUse);  // otherfuel1
    9812        9408 :             collapsedEndUse(10, jEndUse) = ort->gatherEndUseBySourceBEPS(14, jEndUse); // otherfuel2
    9813        9408 :             collapsedEndUse(11, jEndUse) = ort->gatherEndUseBySourceBEPS(3, jEndUse);  // district cooling <- purchased cooling
    9814        9408 :             collapsedEndUse(12, jEndUse) = ort->gatherEndUseBySourceBEPS(4, jEndUse);  // district heating water <- purchased heating
    9815        9408 :             collapsedEndUse(13, jEndUse) = ort->gatherEndUseBySourceBEPS(5, jEndUse);  // district heating steam <- purchased heating
    9816        9408 :             collapsedEndUse(14, jEndUse) = ort->gatherEndUseBySourceBEPS(7, jEndUse);  // water
    9817             :         }
    9818             :         // repeat with totals
    9819         672 :         collapsedTotal(1) = ort->gatherTotalsBySourceBEPS(1);   // electricity
    9820         672 :         collapsedTotal(2) = ort->gatherTotalsBySourceBEPS(2);   // natural gas
    9821         672 :         collapsedTotal(3) = ort->gatherTotalsBySourceBEPS(6);   // gasoline
    9822         672 :         collapsedTotal(4) = ort->gatherTotalsBySourceBEPS(8);   // diesel
    9823         672 :         collapsedTotal(5) = ort->gatherTotalsBySourceBEPS(9);   // coal
    9824         672 :         collapsedTotal(6) = ort->gatherTotalsBySourceBEPS(10);  // Fuel Oil No1
    9825         672 :         collapsedTotal(7) = ort->gatherTotalsBySourceBEPS(11);  // Fuel Oil No2
    9826         672 :         collapsedTotal(8) = ort->gatherTotalsBySourceBEPS(12);  // propane
    9827         672 :         collapsedTotal(9) = ort->gatherTotalsBySourceBEPS(13);  // otherfuel1
    9828         672 :         collapsedTotal(10) = ort->gatherTotalsBySourceBEPS(14); // otherfuel2
    9829         672 :         collapsedTotal(11) = ort->gatherTotalsBySourceBEPS(3);  // district cooling <- purchased cooling
    9830         672 :         collapsedTotal(12) = ort->gatherTotalsBySourceBEPS(4);  // district heating water <- purchased heating
    9831         672 :         collapsedTotal(13) = ort->gatherTotalsBySourceBEPS(5);  // district heating steam <- purchased heating
    9832         672 :         collapsedTotal(14) = ort->gatherTotalsBySourceBEPS(7);  // water
    9833             : 
    9834             :         // unit conversion - all values are used as divisors
    9835             :         Real64 largeConversionFactor;
    9836             :         Real64 areaConversionFactor;
    9837         672 :         Real64 ipElectricityConversionFactor = 1.0;
    9838         672 :         switch (unitsStyle_cur) {
    9839           6 :         case UnitsStyle::JtoKWH: {
    9840           6 :             largeConversionFactor = 3600000.0;
    9841           6 :             areaConversionFactor = 1.0;
    9842           6 :         } break;
    9843          11 :         case UnitsStyle::InchPound: {
    9844          11 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    9845          11 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    9846          11 :         } break;
    9847           0 :         case UnitsStyle::InchPoundExceptElectricity: {
    9848           0 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    9849           0 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    9850           0 :             ipElectricityConversionFactor = largeConversionFactor / (1000.0 * 3600.0);
    9851           0 :         } break;
    9852         655 :         default: {
    9853         655 :             largeConversionFactor = 1000000.0; // to MJ
    9854         655 :             areaConversionFactor = 1.0;
    9855         655 :         } break;
    9856             :         }
    9857             : 
    9858             :         // convert units into MJ (divide by 1,000,000) if J otherwise kWh
    9859        9408 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't do water
    9860        8736 :             Real64 ipElectricityAdjust = (iResource == 1) ? ipElectricityConversionFactor : 1.0;
    9861      131040 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9862      122304 :                 collapsedEndUse(iResource, jEndUse) /= (largeConversionFactor / ipElectricityAdjust);
    9863             :             }
    9864        8736 :             collapsedTotal(iResource) /= (largeConversionFactor / ipElectricityAdjust);
    9865             :         }
    9866             : 
    9867         672 :         rowHead.allocate(16);
    9868         672 :         columnHead.allocate(13);
    9869         672 :         columnWidth.allocate(13);
    9870         672 :         columnWidth = 10; // array assignment - same for all columns
    9871         672 :         tableBody.allocate(13, 16);
    9872       10080 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    9873      141120 :             for (int iEndUse = 0; iEndUse < static_cast<int>(Constant::EndUse::Num); ++iEndUse) {
    9874      131712 :                 useVal(iResource, iEndUse + 1) = collapsedEndUse(iResource, iEndUse + 1);
    9875             :             }
    9876        9408 :             useVal(iResource, 15) = collapsedTotal(iResource); // totals
    9877             :         }
    9878             : 
    9879         672 :         rowHead(static_cast<int>(Constant::EndUse::Heating) + 1) = "Heating";
    9880         672 :         rowHead(static_cast<int>(Constant::EndUse::Cooling) + 1) = "Cooling";
    9881         672 :         rowHead(static_cast<int>(Constant::EndUse::InteriorLights) + 1) = "Interior Lighting";
    9882         672 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorLights) + 1) = "Exterior Lighting";
    9883         672 :         rowHead(static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) = "Interior Equipment";
    9884         672 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) = "Exterior Equipment";
    9885         672 :         rowHead(static_cast<int>(Constant::EndUse::Fans) + 1) = "Fans";
    9886         672 :         rowHead(static_cast<int>(Constant::EndUse::Pumps) + 1) = "Pumps";
    9887         672 :         rowHead(static_cast<int>(Constant::EndUse::HeatRejection) + 1) = "Heat Rejection";
    9888         672 :         rowHead(static_cast<int>(Constant::EndUse::Humidification) + 1) = "Humidification";
    9889         672 :         rowHead(static_cast<int>(Constant::EndUse::HeatRecovery) + 1) = "Heat Recovery";
    9890         672 :         rowHead(static_cast<int>(Constant::EndUse::WaterSystem) + 1) = "Water Systems";
    9891         672 :         rowHead(static_cast<int>(Constant::EndUse::Refrigeration) + 1) = "Refrigeration";
    9892         672 :         rowHead(static_cast<int>(Constant::EndUse::Cogeneration) + 1) = "Generators";
    9893         672 :         rowHead(15) = "";
    9894         672 :         rowHead(16) = "Total Source Energy End Use Components";
    9895             : 
    9896         672 :         largeConversionFactor = 1.0;
    9897             : 
    9898         672 :         switch (unitsStyle_cur) {
    9899           6 :         case UnitsStyle::JtoKWH: {
    9900           6 :             columnHead(1) = "Source Electricity [kWh]";
    9901           6 :             columnHead(2) = "Source Natural Gas [kWh]";
    9902           6 :             columnHead(3) = "Source Gasoline [kWh]";
    9903           6 :             columnHead(4) = "Source Diesel [kWh]";
    9904           6 :             columnHead(5) = "Source Coal [kWh]";
    9905           6 :             columnHead(6) = "Source Fuel Oil No 1 [kWh]";
    9906           6 :             columnHead(7) = "Source Fuel Oil No 2 [kWh]";
    9907           6 :             columnHead(8) = "Source Propane [kWh]";
    9908           6 :             columnHead(9) = "Source Other Fuel 1 [kWh]";
    9909           6 :             columnHead(10) = "Source Other Fuel 2 [kWh]";
    9910           6 :             columnHead(11) = "Source District Cooling [kWh]";
    9911           6 :             columnHead(12) = "Source District Heating Water [kWh]";
    9912           6 :             columnHead(13) = "Source District Heating Steam [kWh]";
    9913           6 :         } break;
    9914          11 :         case UnitsStyle::InchPound: {
    9915          11 :             columnHead(1) = "Source Electricity [kBtu]";
    9916          11 :             columnHead(2) = "Source Natural Gas [kBtu]";
    9917          11 :             columnHead(3) = "Source Gasoline [kBtu]";
    9918          11 :             columnHead(4) = "Source Diesel [kBtu]";
    9919          11 :             columnHead(5) = "Source Coal [kBtu]";
    9920          11 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu]";
    9921          11 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu]";
    9922          11 :             columnHead(8) = "Source Propane [kBtu]";
    9923          11 :             columnHead(9) = "Source Other Fuel 1 [kBtu]";
    9924          11 :             columnHead(10) = "Source Other Fuel 2 [kBtu]";
    9925          11 :             columnHead(11) = "Source District Cooling [kBtu]";
    9926          11 :             columnHead(12) = "Source District Heating Water [kBtu]";
    9927          11 :             columnHead(13) = "Source District Heating Steam [kBtu]";
    9928          11 :         } break;
    9929           0 :         case UnitsStyle::InchPoundExceptElectricity: {
    9930           0 :             columnHead(1) = "Source Electricity [kWh]";
    9931           0 :             columnHead(2) = "Source Natural Gas [kBtu]";
    9932           0 :             columnHead(3) = "Source Gasoline [kBtu]";
    9933           0 :             columnHead(4) = "Source Diesel [kBtu]";
    9934           0 :             columnHead(5) = "Source Coal [kBtu]";
    9935           0 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu]";
    9936           0 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu]";
    9937           0 :             columnHead(8) = "Source Propane [kBtu]";
    9938           0 :             columnHead(9) = "Source Other Fuel 1 [kBtu]";
    9939           0 :             columnHead(10) = "Source Other Fuel 2 [kBtu]";
    9940           0 :             columnHead(11) = "Source District Cooling [kBtu]";
    9941           0 :             columnHead(12) = "Source District Heating Water [kBtu]";
    9942           0 :             columnHead(13) = "Source District Heating Steam [kBtu]";
    9943           0 :         } break;
    9944         655 :         default: {
    9945         655 :             columnHead(1) = "Source Electricity [GJ]";
    9946         655 :             columnHead(2) = "Source Natural Gas [GJ]";
    9947         655 :             columnHead(3) = "Source Gasoline [GJ]";
    9948         655 :             columnHead(4) = "Source Diesel [GJ]";
    9949         655 :             columnHead(5) = "Source Coal [GJ]";
    9950         655 :             columnHead(6) = "Source Fuel Oil No 1 [GJ]";
    9951         655 :             columnHead(7) = "Source Fuel Oil No 2 [GJ]";
    9952         655 :             columnHead(8) = "Source Propane [GJ]";
    9953         655 :             columnHead(9) = "Source Other Fuel 1 [GJ]";
    9954         655 :             columnHead(10) = "Source Other Fuel 2 [GJ]";
    9955         655 :             columnHead(11) = "Source District Cooling [GJ]";
    9956         655 :             columnHead(12) = "Source District Heating Water [GJ]";
    9957         655 :             columnHead(13) = "Source District Heating Steam [GJ]";
    9958         655 :             largeConversionFactor = 1000.0; // for converting MJ to GJ
    9959         655 :         } break;
    9960             :         }
    9961             : 
    9962             :         //---- End Uses by Source Energy Sub-Table
    9963             : 
    9964         672 :         tableBody = "";
    9965        9408 :         for (int iResource = 1; iResource <= 13; ++iResource) {
    9966      131040 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9967      122304 :                 tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse) / largeConversionFactor, 2);
    9968             :             }
    9969        8736 :             tableBody(iResource, 16) = RealToStr(useVal(iResource, 15) / largeConversionFactor, 2);
    9970             :         }
    9971             : 
    9972             :         // heading for the entire sub-table
    9973         672 :         if (produceTabular) {
    9974         672 :             WriteSubtitle(state, "Source Energy End Use Components Summary");
    9975         672 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9976             :         }
    9977         672 :         if (produceSQLite) {
    9978         672 :             if (state.dataSQLiteProcedures->sqlite) {
    9979          73 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9980             :                                                                                    rowHead,
    9981             :                                                                                    columnHead,
    9982             :                                                                                    "SourceEnergyEndUseComponentsSummary",
    9983             :                                                                                    "Entire Facility",
    9984             :                                                                                    "Source Energy End Use Components Summary");
    9985             :             }
    9986             :         }
    9987         672 :         if (produceTabular) {
    9988         672 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9989           6 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    9990             :                                                                                                       rowHead,
    9991             :                                                                                                       columnHead,
    9992             :                                                                                                       "SourceEnergyEndUseComponentsSummary",
    9993             :                                                                                                       "Entire Facility",
    9994             :                                                                                                       "Source Energy End Use Components Summary");
    9995             :             }
    9996             :         }
    9997             : 
    9998             :         // Normalized by Area tables
    9999             : 
   10000         672 :         switch (unitsStyle_cur) {
   10001           6 :         case UnitsStyle::JtoKWH: {
   10002           6 :             columnHead(1) = "Source Electricity [kWh/m2]";
   10003           6 :             columnHead(2) = "Source Natural Gas [kWh/m2]";
   10004           6 :             columnHead(3) = "Source Gasoline [kWh/m2]";
   10005           6 :             columnHead(4) = "Source Diesel [kWh/m2]";
   10006           6 :             columnHead(5) = "Source Coal [kWh/m2]";
   10007           6 :             columnHead(6) = "Source Fuel Oil No 1 [kWh/m2]";
   10008           6 :             columnHead(7) = "Source Fuel Oil No 2 [kWh/m2]";
   10009           6 :             columnHead(8) = "Source Propane [kWh/m2]";
   10010           6 :             columnHead(9) = "Source Other Fuel 1 [kWh/m2]";
   10011           6 :             columnHead(10) = "Source Other Fuel 2 [kWh/m2]";
   10012           6 :             columnHead(11) = "Source District Cooling [kWh/m2]";
   10013           6 :             columnHead(12) = "Source District Heating Water [kWh/m2]";
   10014           6 :             columnHead(13) = "Source District Heating Steam [kWh/m2]";
   10015           6 :         } break;
   10016          11 :         case UnitsStyle::InchPound: {
   10017          11 :             columnHead(1) = "Source Electricity [kBtu/ft2]";
   10018          11 :             columnHead(2) = "Source Natural Gas [kBtu/ft2]";
   10019          11 :             columnHead(3) = "Source Gasoline [kBtu/ft2]";
   10020          11 :             columnHead(4) = "Source Diesel [kBtu/ft2]";
   10021          11 :             columnHead(5) = "Source Coal [kBtu/ft2]";
   10022          11 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu/ft2]";
   10023          11 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu/ft2]";
   10024          11 :             columnHead(8) = "Source Propane [kBtu/ft2]";
   10025          11 :             columnHead(9) = "Source Other Fuel 1 [kBtu/ft2]";
   10026          11 :             columnHead(10) = "Source Other Fuel 2 [kBtu/ft2]";
   10027          11 :             columnHead(11) = "Source District Cooling [kBtu/ft2]";
   10028          11 :             columnHead(12) = "Source District Heating Water [kBtu/ft2]";
   10029          11 :             columnHead(13) = "Source District Heating Steam [kBtu/ft2]";
   10030          11 :         } break;
   10031           0 :         case UnitsStyle::InchPoundExceptElectricity: {
   10032           0 :             columnHead(1) = "Source Electricity [kWh/ft2]";
   10033           0 :             columnHead(2) = "Source Natural Gas [kBtu/ft2]";
   10034           0 :             columnHead(3) = "Source Gasoline [kBtu/ft2]";
   10035           0 :             columnHead(4) = "Source Diesel [kBtu/ft2]";
   10036           0 :             columnHead(5) = "Source Coal [kBtu/ft2]";
   10037           0 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu/ft2]";
   10038           0 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu/ft2]";
   10039           0 :             columnHead(8) = "Source Propane [kBtu/ft2]";
   10040           0 :             columnHead(9) = "Source Other Fuel 1 [kBtu/ft2]";
   10041           0 :             columnHead(10) = "Source Other Fuel 2 [kBtu/ft2]";
   10042           0 :             columnHead(11) = "Source District Cooling [kBtu/ft2]";
   10043           0 :             columnHead(12) = "Source District Heating Water [kBtu/ft2]";
   10044           0 :             columnHead(13) = "Source District Heating Steam [kBtu/ft2]";
   10045           0 :         } break;
   10046         655 :         default: {
   10047         655 :             columnHead(1) = "Source Electricity [MJ/m2]";
   10048         655 :             columnHead(2) = "Source Natural Gas [MJ/m2]";
   10049         655 :             columnHead(3) = "Source Gasoline [MJ/m2]";
   10050         655 :             columnHead(4) = "Source Diesel [MJ/m2]";
   10051         655 :             columnHead(5) = "Source Coal [MJ/m2]";
   10052         655 :             columnHead(6) = "Source Fuel Oil No 1 [MJ/m2]";
   10053         655 :             columnHead(7) = "Source Fuel Oil No 2 [MJ/m2]";
   10054         655 :             columnHead(8) = "Source Propane [MJ/m2]";
   10055         655 :             columnHead(9) = "Source Other Fuel 1 [MJ/m2]";
   10056         655 :             columnHead(10) = "Source Other Fuel 2 [MJ/m2]";
   10057         655 :             columnHead(11) = "Source District Cooling [MJ/m2]";
   10058         655 :             columnHead(12) = "Source District Heating Water [MJ/m2]";
   10059         655 :             columnHead(13) = "Source District Heating Steam [MJ/m2]";
   10060         655 :         } break;
   10061             :         }
   10062             : 
   10063             :         //---- Normalized by Conditioned Area Sub-Table
   10064             :         {
   10065         672 :             tableBody = "";
   10066             :             // convert floor area
   10067         672 :             Real64 convBldgCondFloorArea = ort->buildingConditionedFloorArea / areaConversionFactor;
   10068         672 :             if (convBldgCondFloorArea > 0) {
   10069        8330 :                 for (int iResource = 1; iResource <= 13; ++iResource) {
   10070      116025 :                     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10071      108290 :                         tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse) / convBldgCondFloorArea, 2);
   10072             :                     }
   10073        7735 :                     tableBody(iResource, 16) = RealToStr(useVal(iResource, 15) / convBldgCondFloorArea, 2);
   10074             :                 }
   10075             :             }
   10076             : 
   10077         672 :             if (produceTabular) {
   10078         672 :                 WriteTextLine(state, "Normalized Metrics", true);
   10079             : 
   10080             :                 // heading for the entire sub-table
   10081         672 :                 WriteSubtitle(state, "Source Energy End Use Components Per Conditioned Floor Area");
   10082         672 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10083             :             }
   10084         672 :             if (produceSQLite) {
   10085         672 :                 if (state.dataSQLiteProcedures->sqlite) {
   10086          73 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   10087             :                                                                                        rowHead,
   10088             :                                                                                        columnHead,
   10089             :                                                                                        "SourceEnergyEndUseComponentsSummary",
   10090             :                                                                                        "Entire Facility",
   10091             :                                                                                        "Source Energy End Use Components Per Conditioned Floor Area");
   10092             :                 }
   10093             :             }
   10094         672 :             if (produceTabular) {
   10095         672 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10096           6 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10097             :                         tableBody,
   10098             :                         rowHead,
   10099             :                         columnHead,
   10100             :                         "SourceEnergyEndUseComponentsSummary",
   10101             :                         "Entire Facility",
   10102             :                         "Source Energy End Use Components Per Conditioned Floor Area");
   10103             :                 }
   10104             :             }
   10105             :         } // End of Normalized by Conditioned Area
   10106             : 
   10107             :         //---- Normalized by Total Area Sub-Table
   10108             :         {
   10109         672 :             tableBody = "";
   10110         672 :             Real64 convBldgGrossFloorArea = ort->buildingGrossFloorArea / areaConversionFactor;
   10111             : 
   10112         672 :             if (convBldgGrossFloorArea > 0) {
   10113        9002 :                 for (int iResource = 1; iResource <= 13; ++iResource) {
   10114      125385 :                     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10115      117026 :                         tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse) / convBldgGrossFloorArea, 2);
   10116             :                     }
   10117        8359 :                     tableBody(iResource, 16) = RealToStr(useVal(iResource, 15) / convBldgGrossFloorArea, 2);
   10118             :                 }
   10119             :             }
   10120             : 
   10121             :             // heading for the entire sub-table
   10122         672 :             if (produceTabular) {
   10123         672 :                 WriteSubtitle(state, "Source Energy End Use Components Per Total Floor Area");
   10124         672 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10125             :             }
   10126         672 :             if (produceSQLite) {
   10127         672 :                 if (state.dataSQLiteProcedures->sqlite) {
   10128          73 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   10129             :                                                                                        rowHead,
   10130             :                                                                                        columnHead,
   10131             :                                                                                        "SourceEnergyEndUseComponentsSummary",
   10132             :                                                                                        "Entire Facility",
   10133             :                                                                                        "Source Energy End Use Components Per Total Floor Area");
   10134             :                 }
   10135             :             }
   10136         672 :             if (produceTabular) {
   10137         672 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10138           6 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10139             :                         tableBody,
   10140             :                         rowHead,
   10141             :                         columnHead,
   10142             :                         "SourceEnergyEndUseComponentsSummary",
   10143             :                         "Entire Facility",
   10144             :                         "Source Energy End Use Components Per Total Floor Area");
   10145             :                 }
   10146             :             }
   10147             :         } // End of Normalized by Total Area
   10148             :     }     // End of Dual Units reporting
   10149         672 : }
   10150             : 
   10151         754 : void WriteDemandEndUseSummary(EnergyPlusData &state)
   10152             : {
   10153             :     // SUBROUTINE INFORMATION:
   10154             :     //       AUTHOR         Jason Glazer
   10155             :     //       DATE WRITTEN   January 2009
   10156             :     //       MODIFIED       January 2010, Kyle Benne; Added SQLite output
   10157             :     //                      March 2020, Dareum Nam; Disaggregated "Additional Fuel"
   10158             :     //       RE-ENGINEERED  na
   10159             : 
   10160             :     // PURPOSE OF THIS SUBROUTINE:
   10161             :     //   Take the gathered total and enduse meter data and structure
   10162             :     //   the results into a tabular report for output.
   10163             : 
   10164             :     // METHODOLOGY EMPLOYED:
   10165             :     //   Create arrays for the call to WriteTable and then call it.
   10166             :     //   This report actually consists of many sub-tables each with
   10167             :     //   its own call to WriteTable.
   10168             : 
   10169         754 :     auto &ort = state.dataOutRptTab;
   10170         754 :     auto &op = state.dataOutputProcessor;
   10171             : 
   10172         754 :     if (!ort->displayDemandEndUse) {
   10173          79 :         return;
   10174             :     }
   10175             : 
   10176             :     // all arrays are in the format: (row, column)
   10177         675 :     Array1D_string columnHead;
   10178         675 :     Array1D_int columnWidth;
   10179         675 :     Array1D_string rowHead;
   10180         675 :     Array2D_string tableBody;
   10181             : 
   10182             :     // all arrays are in the format: (row, column)
   10183        1350 :     Array2D<Real64> useVal(14, 15);
   10184         675 :     Array1D<Real64> collapsedTotal(14);
   10185        1350 :     Array2D<Real64> collapsedEndUse(14, static_cast<int>(Constant::EndUse::Num));
   10186        1350 :     Array2D<Real64> collapsedIndEndUse(14, static_cast<int>(Constant::EndUse::Num));
   10187         675 :     Array1D_int collapsedTimeStep(14);
   10188        1350 :     Array3D<Real64> collapsedEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
   10189        1350 :     Array3D<Real64> collapsedIndEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
   10190        1350 :     Array2D<Real64> endUseSubOther(14, static_cast<int>(Constant::EndUse::Num));
   10191             : 
   10192             :     // show the headers of the report
   10193         675 :     WriteReportHeaders(state, "Demand End Use Components Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   10194             : 
   10195         675 :     Real64 ipElectricityConversion = 1.0; // declare here so that last one used is correct for LEEED section
   10196        1350 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   10197        1350 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   10198        1350 :         bool produceTabular = true;
   10199        1350 :         bool produceSQLite = false;
   10200        1350 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   10201             : 
   10202             :         // totals - select which additional fuel to display
   10203         675 :         collapsedTotal = 0.0;
   10204         675 :         collapsedTotal(1) = ort->gatherDemandTotal(1); // electricity
   10205         675 :         collapsedTimeStep(1) = ort->gatherDemandTimeStamp(1);
   10206         675 :         collapsedTotal(2) = ort->gatherDemandTotal(2); // natural gas
   10207         675 :         collapsedTimeStep(2) = ort->gatherDemandTimeStamp(2);
   10208         675 :         collapsedTotal(3) = ort->gatherDemandTotal(6); // gasoline
   10209         675 :         collapsedTimeStep(3) = ort->gatherDemandTimeStamp(6);
   10210         675 :         collapsedTotal(4) = ort->gatherDemandTotal(8); // diesel
   10211         675 :         collapsedTimeStep(4) = ort->gatherDemandTimeStamp(8);
   10212         675 :         collapsedTotal(5) = ort->gatherDemandTotal(9); // coal
   10213         675 :         collapsedTimeStep(5) = ort->gatherDemandTimeStamp(9);
   10214         675 :         collapsedTotal(6) = ort->gatherDemandTotal(10); // fuel oil no 1
   10215         675 :         collapsedTimeStep(6) = ort->gatherDemandTimeStamp(10);
   10216         675 :         collapsedTotal(7) = ort->gatherDemandTotal(11); // fuel oil no 2
   10217         675 :         collapsedTimeStep(7) = ort->gatherDemandTimeStamp(11);
   10218         675 :         collapsedTotal(8) = ort->gatherDemandTotal(12); // propane
   10219         675 :         collapsedTimeStep(8) = ort->gatherDemandTimeStamp(12);
   10220         675 :         collapsedTotal(9) = ort->gatherDemandTotal(13); // other fuel 1
   10221         675 :         collapsedTimeStep(9) = ort->gatherDemandTimeStamp(13);
   10222         675 :         collapsedTotal(10) = ort->gatherDemandTotal(14); // other fuel 2
   10223         675 :         collapsedTimeStep(10) = ort->gatherDemandTimeStamp(14);
   10224         675 :         collapsedTotal(11) = ort->gatherDemandTotal(3); // district cooling <- purchased cooling
   10225         675 :         collapsedTimeStep(11) = ort->gatherDemandTimeStamp(3);
   10226         675 :         collapsedTotal(12) = ort->gatherDemandTotal(4); // district heating water <- purchased heating
   10227         675 :         collapsedTimeStep(12) = ort->gatherDemandTimeStamp(4);
   10228         675 :         collapsedTotal(13) = ort->gatherDemandTotal(5); // district heating steam <- purchased heating
   10229         675 :         collapsedTimeStep(13) = ort->gatherDemandTimeStamp(5);
   10230         675 :         collapsedTotal(14) = ort->gatherDemandTotal(7); // water
   10231         675 :         collapsedTimeStep(14) = ort->gatherDemandTimeStamp(7);
   10232             : 
   10233         675 :         Real64 powerConversion = 1.0;
   10234         675 :         Real64 flowConversion = 1.0;
   10235         675 :         ipElectricityConversion = 1.0;
   10236             : 
   10237             :         // establish unit conversion factors
   10238         675 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   10239          11 :             powerConversion = getSpecificUnitMultiplier(state, "W", "kBtuh");
   10240          11 :             flowConversion = getSpecificUnitMultiplier(state, "m3/s", "gal/min");
   10241         664 :         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   10242           0 :             powerConversion = getSpecificUnitMultiplier(state, "W", "kBtuh");
   10243           0 :             flowConversion = getSpecificUnitMultiplier(state, "m3/s", "gal/min");
   10244           0 :             ipElectricityConversion = powerConversion * 1000.0; // W to kW adjustment
   10245             :         }
   10246             : 
   10247             :         // collapse the gatherEndUseBEPS array to the resource groups displayed
   10248         675 :         collapsedEndUse = 0.0;
   10249       10125 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10250        9450 :             collapsedEndUse(1, jEndUse) = ort->gatherDemandEndUse(1, jEndUse) * (powerConversion / ipElectricityConversion); // electricity
   10251        9450 :             collapsedEndUse(2, jEndUse) = ort->gatherDemandEndUse(2, jEndUse) * powerConversion;                             // natural gas
   10252        9450 :             collapsedEndUse(3, jEndUse) = ort->gatherDemandEndUse(6, jEndUse) * powerConversion;                             // gasoline
   10253        9450 :             collapsedEndUse(4, jEndUse) = ort->gatherDemandEndUse(8, jEndUse) * powerConversion;                             // diesel
   10254        9450 :             collapsedEndUse(5, jEndUse) = ort->gatherDemandEndUse(9, jEndUse) * powerConversion;                             // coal
   10255        9450 :             collapsedEndUse(6, jEndUse) = ort->gatherDemandEndUse(10, jEndUse) * powerConversion;                            // fuel oil no 1
   10256        9450 :             collapsedEndUse(7, jEndUse) = ort->gatherDemandEndUse(11, jEndUse) * powerConversion;                            // fuel oil no 2
   10257        9450 :             collapsedEndUse(8, jEndUse) = ort->gatherDemandEndUse(12, jEndUse) * powerConversion;                            // propane
   10258        9450 :             collapsedEndUse(9, jEndUse) = ort->gatherDemandEndUse(13, jEndUse) * powerConversion;                            // otherfuel1
   10259        9450 :             collapsedEndUse(10, jEndUse) = ort->gatherDemandEndUse(14, jEndUse) * powerConversion;                           // otherfuel2
   10260        9450 :             collapsedEndUse(11, jEndUse) = ort->gatherDemandEndUse(3, jEndUse) * powerConversion;                            // purchased cooling
   10261        9450 :             collapsedEndUse(12, jEndUse) = ort->gatherDemandEndUse(4, jEndUse) * powerConversion;                            // district heating water
   10262        9450 :             collapsedEndUse(13, jEndUse) = ort->gatherDemandEndUse(5, jEndUse) * powerConversion;                            // district heating steam
   10263        9450 :             collapsedEndUse(14, jEndUse) = ort->gatherDemandEndUse(7, jEndUse) * flowConversion;                             // water
   10264             :         }
   10265       10125 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10266       14705 :             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10267       10510 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 1) =
   10268        5255 :                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 1) * (powerConversion / ipElectricityConversion);                // electricity
   10269        5255 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 2) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 2) * powerConversion;   // natural gas
   10270        5255 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 3) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 6) * powerConversion;   // gasoline
   10271        5255 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 4) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 8) * powerConversion;   // diesel
   10272        5255 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 5) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 9) * powerConversion;   // coal
   10273        5255 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 6) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 10) * powerConversion;  // fuel oil no 1
   10274        5255 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 7) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 11) * powerConversion;  // fuel oil no 2
   10275        5255 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 8) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 12) * powerConversion;  // propane
   10276        5255 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 9) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 13) * powerConversion;  // otherfuel1
   10277        5255 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 10) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 14) * powerConversion; // otherfuel2
   10278        5255 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 11) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 3) * powerConversion;  // purch cooling
   10279       10510 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 12) =
   10280        5255 :                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 4) * powerConversion; // district heating water
   10281       10510 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 13) =
   10282        5255 :                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 5) * powerConversion; // district heating steam
   10283        5255 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 14) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 7) * flowConversion; // water
   10284             :             }
   10285             :         }
   10286             :         // collapse the individual peaks for the end use subcategories for the LEED report
   10287             :         // collapse the gatherEndUseBEPS array to the resource groups displayed
   10288             :         // no unit conversion, it is done at the reporting stage if necessary
   10289         675 :         collapsedIndEndUse = 0.0;
   10290       10125 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10291        9450 :             collapsedIndEndUse(1, jEndUse) = ort->gatherDemandIndEndUse(1, jEndUse) * (1.0 / ipElectricityConversion); // electricity
   10292        9450 :             collapsedIndEndUse(2, jEndUse) = ort->gatherDemandIndEndUse(2, jEndUse);                                   // natural gas
   10293        9450 :             collapsedIndEndUse(3, jEndUse) = ort->gatherDemandIndEndUse(6, jEndUse);                                   // gasoline
   10294        9450 :             collapsedIndEndUse(4, jEndUse) = ort->gatherDemandIndEndUse(8, jEndUse);                                   // diesel
   10295        9450 :             collapsedIndEndUse(5, jEndUse) = ort->gatherDemandIndEndUse(9, jEndUse);                                   // coal
   10296        9450 :             collapsedIndEndUse(6, jEndUse) = ort->gatherDemandIndEndUse(10, jEndUse);                                  // fuel oil no 1
   10297        9450 :             collapsedIndEndUse(7, jEndUse) = ort->gatherDemandIndEndUse(11, jEndUse);                                  // fuel oil no 2
   10298        9450 :             collapsedIndEndUse(8, jEndUse) = ort->gatherDemandIndEndUse(12, jEndUse);                                  // propane
   10299        9450 :             collapsedIndEndUse(9, jEndUse) = ort->gatherDemandIndEndUse(13, jEndUse);                                  // otherfuel1
   10300        9450 :             collapsedIndEndUse(10, jEndUse) = ort->gatherDemandIndEndUse(14, jEndUse);                                 // otherfuel2
   10301        9450 :             collapsedIndEndUse(11, jEndUse) = ort->gatherDemandIndEndUse(3, jEndUse);                                  // purchased cooling
   10302        9450 :             collapsedIndEndUse(12, jEndUse) = ort->gatherDemandIndEndUse(4, jEndUse);                                  // district heating water
   10303        9450 :             collapsedIndEndUse(13, jEndUse) = ort->gatherDemandIndEndUse(5, jEndUse);                                  // district heating steam
   10304        9450 :             collapsedIndEndUse(14, jEndUse) = ort->gatherDemandIndEndUse(7, jEndUse);                                  // water
   10305             :         }
   10306       10125 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10307       14705 :             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10308       10510 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 1) =
   10309        5255 :                     ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 1) * (1.0 / ipElectricityConversion);             // electricity
   10310        5255 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 2) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 2);   // natural gas
   10311        5255 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 3) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 6);   // gasoline
   10312        5255 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 4) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 8);   // diesel
   10313        5255 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 5) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 9);   // coal
   10314        5255 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 6) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 10);  // fuel oil no 1
   10315        5255 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 7) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 11);  // fuel oil no 2
   10316        5255 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 8) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 12);  // propane
   10317        5255 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 9) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 13);  // otherfuel1
   10318        5255 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 10) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 14); // otherfuel2
   10319        5255 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 11) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 3);  // purch cooling
   10320        5255 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 12) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 4);  // district heating water
   10321        5255 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 13) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 5);  // district heating steam
   10322        5255 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 14) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 7);  // water
   10323             :             }
   10324             :         }
   10325             : 
   10326             :         // convert totals
   10327         675 :         collapsedTotal(1) *= (powerConversion / ipElectricityConversion); // electricity
   10328         675 :         collapsedTotal(2) *= powerConversion;                             // natural gas
   10329         675 :         collapsedTotal(3) *= powerConversion;                             // gasoline
   10330         675 :         collapsedTotal(4) *= powerConversion;                             // diesel
   10331         675 :         collapsedTotal(5) *= powerConversion;                             // coal
   10332         675 :         collapsedTotal(6) *= powerConversion;                             // fuel oil no 1
   10333         675 :         collapsedTotal(7) *= powerConversion;                             // fuel oil no 2
   10334         675 :         collapsedTotal(8) *= powerConversion;                             // propane
   10335         675 :         collapsedTotal(9) *= powerConversion;                             // otherfuel1
   10336         675 :         collapsedTotal(10) *= powerConversion;                            // otherfuel2
   10337         675 :         collapsedTotal(11) *= powerConversion;                            // purchased cooling
   10338         675 :         collapsedTotal(12) *= powerConversion;                            // district heating water
   10339         675 :         collapsedTotal(13) *= powerConversion;                            // district heating steam
   10340         675 :         collapsedTotal(14) *= flowConversion;                             // water
   10341             :         //---- End Use Sub-Table
   10342         675 :         rowHead.allocate(17);
   10343         675 :         columnHead.allocate(14);
   10344         675 :         columnWidth.allocate(14);
   10345         675 :         columnWidth = 10; // array assignment - same for all columns
   10346         675 :         tableBody.allocate(14, 17);
   10347       10125 :         for (int iResource = 1; iResource <= 14; ++iResource) {
   10348      141750 :             for (int iEndUse = 0; iEndUse < static_cast<int>(Constant::EndUse::Num); ++iEndUse) {
   10349      132300 :                 useVal(iResource, iEndUse + 1) = collapsedEndUse(iResource, iEndUse + 1);
   10350             :             }
   10351        9450 :             useVal(iResource, 15) = collapsedTotal(iResource); // totals
   10352             :         }
   10353             : 
   10354         675 :         rowHead(1) = "Time of Peak";
   10355         675 :         rowHead(static_cast<int>(Constant::EndUse::Heating) + 2) = "Heating";
   10356         675 :         rowHead(static_cast<int>(Constant::EndUse::Cooling) + 2) = "Cooling";
   10357         675 :         rowHead(static_cast<int>(Constant::EndUse::InteriorLights) + 2) = "Interior Lighting";
   10358         675 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorLights) + 2) = "Exterior Lighting";
   10359         675 :         rowHead(static_cast<int>(Constant::EndUse::InteriorEquipment) + 2) = "Interior Equipment";
   10360         675 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 2) = "Exterior Equipment";
   10361         675 :         rowHead(static_cast<int>(Constant::EndUse::Fans) + 2) = "Fans";
   10362         675 :         rowHead(static_cast<int>(Constant::EndUse::Pumps) + 2) = "Pumps";
   10363         675 :         rowHead(static_cast<int>(Constant::EndUse::HeatRejection) + 2) = "Heat Rejection";
   10364         675 :         rowHead(static_cast<int>(Constant::EndUse::Humidification) + 2) = "Humidification";
   10365         675 :         rowHead(static_cast<int>(Constant::EndUse::HeatRecovery) + 2) = "Heat Recovery";
   10366         675 :         rowHead(static_cast<int>(Constant::EndUse::WaterSystem) + 2) = "Water Systems";
   10367         675 :         rowHead(static_cast<int>(Constant::EndUse::Refrigeration) + 2) = "Refrigeration";
   10368         675 :         rowHead(static_cast<int>(Constant::EndUse::Cogeneration) + 2) = "Generators";
   10369         675 :         rowHead(16) = "";
   10370         675 :         rowHead(17) = "Total End Uses";
   10371             : 
   10372         675 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   10373          11 :             columnHead(1) = "Electricity [kBtuh]";
   10374          11 :             columnHead(2) = "Natural Gas [kBtuh]";
   10375          11 :             columnHead(3) = "Gasoline [kBtuh]";
   10376          11 :             columnHead(4) = "Diesel [kBtuh]";
   10377          11 :             columnHead(5) = "Coal [kBtuh]";
   10378          11 :             columnHead(6) = "Fuel Oil No 1 [kBtuh]";
   10379          11 :             columnHead(7) = "Fuel Oil No 2 [kBtuh]";
   10380          11 :             columnHead(8) = "Propane [kBtuh]";
   10381          11 :             columnHead(9) = "Other Fuel 1 [kBtuh]";
   10382          11 :             columnHead(10) = "Other Fuel 2 [kBtuh]";
   10383          11 :             columnHead(11) = "District Cooling [kBtuh]";
   10384          11 :             columnHead(12) = "District Heating Water [kBtuh]";
   10385          11 :             columnHead(13) = "District Heating Steam [kBtuh]";
   10386          11 :             columnHead(14) = "Water [gal/min]";
   10387         664 :         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   10388           0 :             columnHead(1) = "Electricity [kW]";
   10389           0 :             columnHead(2) = "Natural Gas [kBtuh]";
   10390           0 :             columnHead(3) = "Gasoline [kBtuh]";
   10391           0 :             columnHead(4) = "Diesel [kBtuh]";
   10392           0 :             columnHead(5) = "Coal [kBtuh]";
   10393           0 :             columnHead(6) = "Fuel Oil No 1 [kBtuh]";
   10394           0 :             columnHead(7) = "Fuel Oil No 2 [kBtuh]";
   10395           0 :             columnHead(8) = "Propane [kBtuh]";
   10396           0 :             columnHead(9) = "Other Fuel 1 [kBtuh]";
   10397           0 :             columnHead(10) = "Other Fuel 2 [kBtuh]";
   10398           0 :             columnHead(11) = "District Cooling [kBtuh]";
   10399           0 :             columnHead(12) = "District Heating Water [kBtuh]";
   10400           0 :             columnHead(13) = "District Heating Steam [kBtuh]";
   10401           0 :             columnHead(14) = "Water [gal/min]";
   10402             :         } else {
   10403         664 :             columnHead(1) = "Electricity [W]";
   10404         664 :             columnHead(2) = "Natural Gas [W]";
   10405         664 :             columnHead(3) = "Gasoline [W]";
   10406         664 :             columnHead(4) = "Diesel [W]";
   10407         664 :             columnHead(5) = "Coal [W]";
   10408         664 :             columnHead(6) = "Fuel Oil No 1 [W]";
   10409         664 :             columnHead(7) = "Fuel Oil No 2 [W]";
   10410         664 :             columnHead(8) = "Propane [W]";
   10411         664 :             columnHead(9) = "Other Fuel 1 [W]";
   10412         664 :             columnHead(10) = "Other Fuel 2 [W]";
   10413         664 :             columnHead(11) = "District Cooling [W]";
   10414         664 :             columnHead(12) = "District Heating Water [W]";
   10415         664 :             columnHead(13) = "District Heating Steam [W]";
   10416         664 :             columnHead(14) = "Water [m3/s]";
   10417             :         }
   10418             : 
   10419         675 :         tableBody = "";
   10420       10125 :         for (int iResource = 1; iResource <= 14; ++iResource) {
   10421      141750 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10422      132300 :                 tableBody(iResource, 1 + jEndUse) = RealToStr(useVal(iResource, jEndUse), 2);
   10423             :             }
   10424        9450 :             tableBody(iResource, 1) = DateToString(collapsedTimeStep(iResource));
   10425        9450 :             tableBody(iResource, 17) = RealToStr(collapsedTotal(iResource), 2);
   10426             :         }
   10427             : 
   10428             :         // complete the LEED end use table using the same values
   10429             : 
   10430         675 :         if (produceTabular) {
   10431         675 :             WriteSubtitle(state, "End Uses");
   10432         675 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, state.dataOutRptTab->footnote);
   10433             :         }
   10434         675 :         if (produceSQLite) {
   10435         675 :             if (state.dataSQLiteProcedures->sqlite) {
   10436          73 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10437             :                     tableBody, rowHead, columnHead, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses");
   10438             :             }
   10439             :         }
   10440         675 :         if (produceTabular) {
   10441         675 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10442           6 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10443             :                     tableBody, rowHead, columnHead, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses");
   10444             :             }
   10445             :         }
   10446             : 
   10447             :         //---- End Uses By Subcategory Sub-Table
   10448         675 :         int numRows = 0;
   10449       10125 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10450        9450 :             if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10451        9796 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10452        5255 :                     ++numRows;
   10453             :                 }
   10454             :             } else {
   10455        4909 :                 ++numRows;
   10456             :             }
   10457             :         }
   10458             : 
   10459         675 :         rowHead.allocate(numRows);
   10460         675 :         columnHead.allocate(15);
   10461         675 :         columnWidth.allocate(15);
   10462         675 :         columnWidth = 10; // array assignment - same for all columns
   10463         675 :         tableBody.allocate(15, numRows);
   10464             : 
   10465         675 :         rowHead = "";
   10466         675 :         tableBody = "";
   10467             : 
   10468             :         // Build row head and subcategories columns
   10469             :         {
   10470         675 :             int i = 1;
   10471       10125 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10472        9450 :                 rowHead(i) = op->EndUseCategory(jEndUse).DisplayName;
   10473        9450 :                 if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10474        9796 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10475        5255 :                         tableBody(1, i) = op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub);
   10476        5255 :                         ++i;
   10477             :                     }
   10478             :                 } else {
   10479        4909 :                     tableBody(1, i) = "General";
   10480        4909 :                     ++i;
   10481             :                 }
   10482             :             }
   10483             :         }
   10484             : 
   10485         675 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   10486          11 :             columnHead(1) = "Subcategory";
   10487          11 :             columnHead(2) = "Electricity [kBtuh]";
   10488          11 :             columnHead(3) = "Natural Gas [kBtuh]";
   10489          11 :             columnHead(4) = "Gasoline [kBtuh]";
   10490          11 :             columnHead(5) = "Diesel [kBtuh]";
   10491          11 :             columnHead(6) = "Coal [kBtuh]";
   10492          11 :             columnHead(7) = "Fuel Oil No 1 [kBtuh]";
   10493          11 :             columnHead(8) = "Fuel Oil No 2 [kBtuh]";
   10494          11 :             columnHead(9) = "Propane [kBtuh]";
   10495          11 :             columnHead(10) = "Other Fuel 1 [kBtuh]";
   10496          11 :             columnHead(11) = "Other Fuel 2 [kBtuh]";
   10497          11 :             columnHead(12) = "District Cooling [kBtuh]";
   10498          11 :             columnHead(13) = "District Heating Water [kBtuh]";
   10499          11 :             columnHead(14) = "District Heating Steam [kBtuh]";
   10500          11 :             columnHead(15) = "Water [gal/min]";
   10501         664 :         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   10502           0 :             columnHead(1) = "Subcategory";
   10503           0 :             columnHead(2) = "Electricity [kW]";
   10504           0 :             columnHead(3) = "Natural Gas [kBtuh]";
   10505           0 :             columnHead(4) = "Gasoline [kBtuh]";
   10506           0 :             columnHead(5) = "Diesel [kBtuh]";
   10507           0 :             columnHead(6) = "Coal [kBtuh]";
   10508           0 :             columnHead(7) = "Fuel Oil No 1 [kBtuh]";
   10509           0 :             columnHead(8) = "Fuel Oil No 2 [kBtuh]";
   10510           0 :             columnHead(9) = "Propane [kBtuh]";
   10511           0 :             columnHead(10) = "Other Fuel 1 [kBtuh]";
   10512           0 :             columnHead(11) = "Other Fuel 2 [kBtuh]";
   10513           0 :             columnHead(12) = "District Cooling [kBtuh]";
   10514           0 :             columnHead(13) = "District Heating Water [kBtuh]";
   10515           0 :             columnHead(14) = "District Heating Steam [kBtuh]";
   10516           0 :             columnHead(15) = "Water [gal/min]";
   10517             :         } else {
   10518         664 :             columnHead(1) = "Subcategory";
   10519         664 :             columnHead(2) = "Electricity [W]";
   10520         664 :             columnHead(3) = "Natural Gas [W]";
   10521         664 :             columnHead(4) = "Gasoline [W]";
   10522         664 :             columnHead(5) = "Diesel [W]";
   10523         664 :             columnHead(6) = "Coal [W]";
   10524         664 :             columnHead(7) = "Fuel Oil No 1 [W]";
   10525         664 :             columnHead(8) = "Fuel Oil No 2 [W]";
   10526         664 :             columnHead(9) = "Propane [W]";
   10527         664 :             columnHead(10) = "Other Fuel 1 [W]";
   10528         664 :             columnHead(11) = "Other Fuel 2 [W]";
   10529         664 :             columnHead(12) = "District Cooling [W]";
   10530         664 :             columnHead(13) = "District Heating Water [W]";
   10531         664 :             columnHead(14) = "District Heating Steam [W]";
   10532         664 :             columnHead(15) = "Water [m3/s]";
   10533             :         }
   10534             : 
   10535       10125 :         for (int iResource = 1; iResource <= 14; ++iResource) {
   10536        9450 :             int i = 1;
   10537      141750 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10538      132300 :                 if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10539      137144 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10540       73570 :                         tableBody(iResource + 1, i) = RealToStr(collapsedEndUseSub(kEndUseSub, jEndUse, iResource), 2);
   10541       73570 :                         ++i;
   10542             :                     }
   10543             :                 } else {
   10544       68726 :                     tableBody(iResource + 1, i) = RealToStr(collapsedEndUse(iResource, jEndUse), 2);
   10545       68726 :                     ++i;
   10546             :                 }
   10547             :             }
   10548             :         }
   10549             : 
   10550             :         // heading for the entire sub-table
   10551         675 :         if (produceTabular) {
   10552         675 :             WriteSubtitle(state, "End Uses By Subcategory");
   10553         675 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, state.dataOutRptTab->footnote);
   10554             :         }
   10555             : 
   10556         675 :         Array1D_string rowHeadTemp(rowHead);
   10557             :         // Before outputing to SQL, we forward fill the End use column (rowHead) (cf #7481)
   10558             :         // for better sql queries
   10559         675 :         FillRowHead(rowHeadTemp);
   10560             : 
   10561       10839 :         for (int i = 1; i <= numRows; ++i) {
   10562       10164 :             rowHeadTemp(i) = rowHeadTemp(i) + ":" + tableBody(1, i);
   10563             :         }
   10564             : 
   10565             :         // Erase the SubCategory (first column), using slicing
   10566        6075 :         Array2D_string tableBodyTemp(tableBody({2, _, _}, {_, _, _}));
   10567        3375 :         Array1D_string columnHeadTemp(columnHead({2, _, _}));
   10568             : 
   10569         675 :         if (produceSQLite) {
   10570         675 :             if (state.dataSQLiteProcedures->sqlite) {
   10571          73 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10572             :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses By Subcategory");
   10573             :             }
   10574             :         }
   10575             : 
   10576         675 :         if (produceTabular) {
   10577         675 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10578           6 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10579             :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses By Subcategory");
   10580             :             }
   10581             :         }
   10582         675 :         rowHeadTemp.deallocate();
   10583         675 :         tableBodyTemp.deallocate();
   10584         675 :         columnHeadTemp.deallocate();
   10585         675 :     }
   10586             : 
   10587             :     // EAp2-4/5. Performance Rating Method Compliance
   10588       10125 :     for (int iResource = 1; iResource <= 14; ++iResource) {
   10589      141750 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10590      132300 :             if (ort->needOtherRowLEED45(jEndUse)) {
   10591           0 :                 if (op->EndUseCategory(jEndUse).NumSubcategories == 0) {
   10592           0 :                     endUseSubOther(iResource, jEndUse) = collapsedIndEndUse(iResource, jEndUse); // often the case that no subcategories are defined
   10593             :                 } else {
   10594           0 :                     Real64 sumOfSubcategories = 0.;
   10595           0 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10596           0 :                         sumOfSubcategories += collapsedIndEndUseSub(kEndUseSub, jEndUse, iResource);
   10597             :                     }
   10598           0 :                     endUseSubOther(iResource, jEndUse) = collapsedIndEndUse(iResource, jEndUse) - sumOfSubcategories;
   10599           0 :                     if (endUseSubOther(iResource, jEndUse) < 0.) {
   10600           0 :                         endUseSubOther(iResource, jEndUse) = 0.;
   10601             :                     }
   10602             :                 }
   10603             :             }
   10604             :         }
   10605             :     }
   10606             : 
   10607         675 :     Array1D_int resource_entry_map;
   10608         675 :     resource_entry_map.allocate(13);
   10609         675 :     resource_entry_map(1) = state.dataOutRptPredefined->pdchLeedPerfElDem;          // electricity
   10610         675 :     resource_entry_map(2) = state.dataOutRptPredefined->pdchLeedPerfGasDem;         // natural gas
   10611         675 :     resource_entry_map(3) = state.dataOutRptPredefined->pdchLeedPerfGasolineDem;    // gasoline
   10612         675 :     resource_entry_map(4) = state.dataOutRptPredefined->pdchLeedPerfDieselDem;      // diesel
   10613         675 :     resource_entry_map(5) = state.dataOutRptPredefined->pdchLeedPerfCoalDem;        // coal
   10614         675 :     resource_entry_map(6) = state.dataOutRptPredefined->pdchLeedPerfFuelOil1Dem;    // fuel oil no 1
   10615         675 :     resource_entry_map(7) = state.dataOutRptPredefined->pdchLeedPerfFuelOil2Dem;    // fuel oil no 2
   10616         675 :     resource_entry_map(8) = state.dataOutRptPredefined->pdchLeedPerfPropaneDem;     // propane
   10617         675 :     resource_entry_map(9) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel1Dem;  // other fuel 1
   10618         675 :     resource_entry_map(10) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel2Dem; // other fuel 2
   10619         675 :     resource_entry_map(11) = state.dataOutRptPredefined->pdchLeedPerfDisClDem;      // district cooling
   10620         675 :     resource_entry_map(12) = state.dataOutRptPredefined->pdchLeedPerfDisHtWtrDem;   // district heating water
   10621         675 :     resource_entry_map(13) = state.dataOutRptPredefined->pdchLeedPerfDisHtStDem;    // district heating steam
   10622             : 
   10623        9450 :     for (int iResource = 1; iResource <= 13; ++iResource) {
   10624        8775 :         int i = 1;
   10625        8775 :         Real64 localUnconvert = (iResource == 1) ? ipElectricityConversion : 1.0;
   10626      131625 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10627      122850 :             if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10628      127348 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10629      136630 :                     PreDefTableEntry(state,
   10630       68315 :                                      resource_entry_map(iResource),
   10631      136630 :                                      op->EndUseCategory(jEndUse).DisplayName + " -- " + op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub),
   10632       68315 :                                      localUnconvert * collapsedIndEndUseSub(kEndUseSub, jEndUse, iResource));
   10633       68315 :                     ++i;
   10634             :                 }
   10635             :                 // put other
   10636       59033 :                 if (ort->needOtherRowLEED45(jEndUse)) {
   10637           0 :                     PreDefTableEntry(state,
   10638           0 :                                      resource_entry_map(iResource),
   10639           0 :                                      op->EndUseCategory(jEndUse).DisplayName + " -- Other",
   10640           0 :                                      localUnconvert * endUseSubOther(iResource, jEndUse));
   10641           0 :                     ++i;
   10642             :                 }
   10643             :             } else {
   10644      127634 :                 PreDefTableEntry(state,
   10645       63817 :                                  resource_entry_map(iResource),
   10646      127634 :                                  op->EndUseCategory(jEndUse).DisplayName + " -- Not Subdivided",
   10647       63817 :                                  localUnconvert * collapsedIndEndUse(iResource, jEndUse));
   10648       63817 :                 ++i;
   10649             :             }
   10650             :         }
   10651             :     }
   10652         675 : }
   10653             : 
   10654         754 : void WriteCompCostTable(EnergyPlusData &state)
   10655             : {
   10656             : 
   10657             :     // SUBROUTINE INFORMATION:
   10658             :     //       AUTHOR         BGriffith
   10659             :     //       DATE WRITTEN   April/May 2004
   10660             :     //       MODIFIED       January 2010, Kyle Benne
   10661             :     //                      Added SQLite output
   10662             :     //       RE-ENGINEERED  na
   10663             : 
   10664             :     // PURPOSE OF THIS SUBROUTINE:
   10665             :     // produce a results table from Cost Estimate Calculations
   10666             : 
   10667             :     // METHODOLOGY EMPLOYED:
   10668             :     // USE data from CostEstimateManager, call JGlazer's subroutines
   10669             : 
   10670             :     // REFERENCES:
   10671             :     // na
   10672             : 
   10673             :     // Using/Aliasing
   10674             : 
   10675             :     // Locals
   10676             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   10677             :     // na
   10678             : 
   10679             :     // SUBROUTINE PARAMETER DEFINITIONS:
   10680             :     // na
   10681             : 
   10682             :     // INTERFACE BLOCK SPECIFICATIONS:
   10683             :     // na
   10684             : 
   10685             :     // DERIVED TYPE DEFINITIONS:
   10686             :     // na
   10687             : 
   10688             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   10689         754 :     auto &ort = state.dataOutRptTab;
   10690             : 
   10691         754 :     if (!state.dataCostEstimateManager->DoCostEstimate) {
   10692         716 :         return;
   10693             :     }
   10694             : 
   10695          76 :     Array2D<Real64> TableBodyData(3, 10);
   10696          38 :     Array1D_string columnHead;
   10697          38 :     Array1D_int columnWidth;
   10698          38 :     Array1D_string rowHead;
   10699          38 :     Array2D_string tableBody;
   10700             : 
   10701          38 :     WriteReportHeaders(state, "Component Cost Economics Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   10702             : 
   10703             :     // compute floor area if no ABUPS
   10704          38 :     if (ort->buildingConditionedFloorArea == 0.0) {
   10705           1 :         DetermineBuildingFloorArea(state);
   10706             :     }
   10707             : 
   10708          76 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   10709          76 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   10710          76 :         bool produceTabular = true;
   10711          76 :         bool produceSQLite = false;
   10712          76 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   10713             : 
   10714             :         // 1st sub-table with total Costs and normalized with area
   10715          38 :         rowHead.allocate(10);
   10716          38 :         columnHead.allocate(3);
   10717          38 :         columnWidth.allocate(3);
   10718          38 :         columnWidth = 14; // array assignment - same for all columns
   10719          38 :         tableBody.allocate(3, 10);
   10720             : 
   10721          38 :         columnHead(1) = "Reference Bldg.";
   10722          38 :         columnHead(2) = "Current Bldg. Model";
   10723          38 :         columnHead(3) = "Difference";
   10724             : 
   10725          38 :         rowHead(1) = "Line Item SubTotal (~~$~~)";
   10726          38 :         rowHead(2) = "Misc. Costs (~~$~~)";
   10727          38 :         rowHead(3) = "Regional Adjustment (~~$~~)";
   10728          38 :         rowHead(4) = "Design Fee (~~$~~)";
   10729          38 :         rowHead(5) = "Contractor Fee (~~$~~)";
   10730          38 :         rowHead(6) = "Contingency (~~$~~)";
   10731          38 :         rowHead(7) = "Permits, Bonds, Insurance (~~$~~)";
   10732          38 :         rowHead(8) = "Commissioning (~~$~~)";
   10733          38 :         rowHead(9) = "Cost Estimate Total (~~$~~)";
   10734          38 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   10735          38 :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   10736           0 :             std::string const SIunit = "[m2]";
   10737           0 :             std::string m2_unitName;
   10738           0 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWCCT, m2_unitName);
   10739           0 :             state.dataOutRptTab->m2_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWCCT, 1.0);
   10740           0 :             rowHead(10) = "Cost Per Conditioned Building Area (~~$~~/ft2)";
   10741           0 :         } else {
   10742          38 :             rowHead(10) = "Cost Per Conditioned Building Area (~~$~~/m2)";
   10743          38 :             state.dataOutRptTab->m2_unitConv = 1.0;
   10744             :         }
   10745          38 :         TableBodyData = 0.0;
   10746          38 :         tableBody = "";
   10747             : 
   10748          38 :         TableBodyData(1, 1) = state.dataCostEstimateManager->RefrncBldg.LineItemTot;
   10749          38 :         tableBody(1, 1) = RealToStr(TableBodyData(1, 1), 2);
   10750          38 :         TableBodyData(1, 2) = state.dataCostEstimateManager->RefrncBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea;
   10751          38 :         tableBody(1, 2) = RealToStr(TableBodyData(1, 2), 2);
   10752             : 
   10753          38 :         if (state.dataCostEstimateManager->RefrncBldg.RegionalModifier != 1.0) {
   10754           2 :             TableBodyData(1, 3) = (state.dataCostEstimateManager->RefrncBldg.LineItemTot +
   10755           1 :                                    state.dataCostEstimateManager->RefrncBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea) *
   10756           1 :                                   (state.dataCostEstimateManager->RefrncBldg.RegionalModifier - 1.0);
   10757             :         } else {
   10758          37 :             TableBodyData(1, 3) = 0.0;
   10759             :         }
   10760             : 
   10761             :         // holds interim value for construction component costs: reference bldg.
   10762          38 :         Real64 const RefBldgConstCost = sum(TableBodyData(1, {1, 3}));
   10763             : 
   10764          38 :         tableBody(1, 3) = RealToStr(TableBodyData(1, 3), 2);
   10765          38 :         TableBodyData(1, 4) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.DesignFeeFrac;
   10766          38 :         tableBody(1, 4) = RealToStr(TableBodyData(1, 4), 2);
   10767          38 :         TableBodyData(1, 5) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.ContractorFeeFrac;
   10768          38 :         tableBody(1, 5) = RealToStr(TableBodyData(1, 5), 2);
   10769          38 :         TableBodyData(1, 6) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.ContingencyFrac;
   10770          38 :         tableBody(1, 6) = RealToStr(TableBodyData(1, 6), 2);
   10771          38 :         TableBodyData(1, 7) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.BondCostFrac;
   10772          38 :         tableBody(1, 7) = RealToStr(TableBodyData(1, 7), 2);
   10773          38 :         TableBodyData(1, 8) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.CommissioningFrac;
   10774          38 :         tableBody(1, 8) = RealToStr(TableBodyData(1, 8), 2);
   10775          38 :         state.dataCostEstimateManager->RefrncBldg.GrandTotal = sum(TableBodyData(1, {1, 8}));
   10776          38 :         TableBodyData(1, 9) = state.dataCostEstimateManager->RefrncBldg.GrandTotal;
   10777          38 :         tableBody(1, 9) = RealToStr(TableBodyData(1, 9), 2);
   10778          38 :         if (ort->buildingConditionedFloorArea > 0.0) {
   10779          38 :             TableBodyData(1, 10) = TableBodyData(1, 9) / (ort->buildingConditionedFloorArea * state.dataOutRptTab->m2_unitConv);
   10780             :         }
   10781          38 :         tableBody(1, 10) = RealToStr(TableBodyData(1, 10), 2);
   10782             : 
   10783          38 :         TableBodyData(2, 1) = state.dataCostEstimateManager->CurntBldg.LineItemTot;
   10784          38 :         tableBody(2, 1) = RealToStr(TableBodyData(2, 1), 2);
   10785          38 :         TableBodyData(2, 2) = state.dataCostEstimateManager->CurntBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea;
   10786          38 :         tableBody(2, 2) = RealToStr(TableBodyData(2, 2), 2);
   10787          38 :         if (state.dataCostEstimateManager->CurntBldg.RegionalModifier != 1.0) {
   10788           2 :             TableBodyData(2, 3) = (state.dataCostEstimateManager->CurntBldg.LineItemTot +
   10789           1 :                                    state.dataCostEstimateManager->CurntBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea) *
   10790           1 :                                   (state.dataCostEstimateManager->CurntBldg.RegionalModifier - 1.0);
   10791             :         } else {
   10792          37 :             TableBodyData(2, 3) = 0.0;
   10793             :         }
   10794          38 :         tableBody(2, 3) = RealToStr(TableBodyData(2, 3), 2);
   10795             : 
   10796             :         // holds interim value for construction component costs: current bldg.
   10797          38 :         Real64 const CurntBldgConstCost = sum(TableBodyData(2, {1, 3}));
   10798             : 
   10799          38 :         TableBodyData(2, 4) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.DesignFeeFrac;
   10800          38 :         tableBody(2, 4) = RealToStr(TableBodyData(2, 4), 2);
   10801             : 
   10802          38 :         TableBodyData(2, 5) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.ContractorFeeFrac;
   10803          38 :         tableBody(2, 5) = RealToStr(TableBodyData(2, 5), 2);
   10804          38 :         TableBodyData(2, 6) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.ContingencyFrac;
   10805          38 :         tableBody(2, 6) = RealToStr(TableBodyData(2, 6), 2);
   10806          38 :         TableBodyData(2, 7) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.BondCostFrac;
   10807          38 :         tableBody(2, 7) = RealToStr(TableBodyData(2, 7), 2);
   10808          38 :         TableBodyData(2, 8) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.CommissioningFrac;
   10809          38 :         tableBody(2, 8) = RealToStr(TableBodyData(2, 8), 2);
   10810             : 
   10811          38 :         state.dataCostEstimateManager->CurntBldg.GrandTotal = sum(TableBodyData(2, {1, 8}));
   10812          38 :         TableBodyData(2, 9) = state.dataCostEstimateManager->CurntBldg.GrandTotal;
   10813          38 :         tableBody(2, 9) = RealToStr(TableBodyData(2, 9), 2);
   10814          38 :         if (ort->buildingConditionedFloorArea > 0) {
   10815          38 :             TableBodyData(2, 10) = TableBodyData(2, 9) / (ort->buildingConditionedFloorArea * state.dataOutRptTab->m2_unitConv);
   10816             :         }
   10817          38 :         tableBody(2, 10) = RealToStr(TableBodyData(2, 10), 2);
   10818             : 
   10819          38 :         TableBodyData(3, {1, 10}) = TableBodyData(2, {1, 10}) - TableBodyData(1, {1, 10});
   10820          38 :         tableBody(3, 1) = RealToStr(TableBodyData(3, 1), 2);
   10821          38 :         tableBody(3, 2) = RealToStr(TableBodyData(3, 2), 2);
   10822          38 :         tableBody(3, 3) = RealToStr(TableBodyData(3, 3), 2);
   10823          38 :         tableBody(3, 4) = RealToStr(TableBodyData(3, 4), 2);
   10824          38 :         tableBody(3, 5) = RealToStr(TableBodyData(3, 5), 2);
   10825          38 :         tableBody(3, 6) = RealToStr(TableBodyData(3, 6), 2);
   10826          38 :         tableBody(3, 7) = RealToStr(TableBodyData(3, 7), 2);
   10827          38 :         tableBody(3, 8) = RealToStr(TableBodyData(3, 8), 2);
   10828          38 :         tableBody(3, 9) = RealToStr(TableBodyData(3, 9), 2);
   10829          38 :         tableBody(3, 10) = RealToStr(TableBodyData(3, 10), 2);
   10830             : 
   10831          38 :         if (produceTabular) {
   10832          38 :             WriteSubtitle(state, "Construction Cost Estimate Summary");
   10833          38 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10834             :         }
   10835          38 :         if (produceSQLite) {
   10836          38 :             if (state.dataSQLiteProcedures->sqlite) {
   10837           5 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10838             :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Construction Cost Estimate Summary");
   10839             :             }
   10840             :         }
   10841          38 :         if (produceTabular) {
   10842          38 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10843           0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10844             :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Construction Cost Estimate Summary");
   10845             :             }
   10846             :         }
   10847             : 
   10848          38 :         int const NumRows = static_cast<int>(state.dataCostEstimateManager->CostLineItem.size()) + 1; // body will have the total and line items
   10849          38 :         int const NumCols = 6; // Line no., Line name, Qty, Units, ValperQty, Subtotal
   10850          38 :         rowHead.allocate(NumRows);
   10851          38 :         columnHead.allocate(NumCols);
   10852          38 :         columnWidth.dimension(NumCols, 14); // array assignment - same for all columns
   10853          38 :         tableBody.allocate(NumCols, NumRows);
   10854          38 :         tableBody = "--";                        // array init
   10855          38 :         rowHead = "--";                          // array init
   10856          38 :         rowHead(NumRows) = "Line Item SubTotal"; // last line in table will be a total
   10857             :         // setup up column headers
   10858          38 :         columnHead(1) = "Line No.";
   10859          38 :         columnHead(2) = "Item Name";
   10860          38 :         columnHead(3) = "Quantity.";
   10861          38 :         columnHead(4) = "Units";
   10862          38 :         columnHead(5) = "~~$~~ per Qty.";
   10863          38 :         columnHead(6) = "SubTotal ~~$~~";
   10864             : 
   10865          38 :         columnWidth = {7, 30, 16, 10, 16, 16}; // array assignment - for all columns
   10866             : 
   10867        2351 :         for (int item = 1; item <= (int)state.dataCostEstimateManager->CostLineItem.size(); ++item) {
   10868        2313 :             tableBody(1, item) = fmt::to_string(state.dataCostEstimateManager->CostLineItem(item).LineNumber);
   10869        2313 :             tableBody(2, item) = state.dataCostEstimateManager->CostLineItem(item).LineName;
   10870        2313 :             if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   10871        2313 :                 unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   10872           0 :                 std::string IPunitName;
   10873           0 :                 LookupSItoIP(state, state.dataCostEstimateManager->CostLineItem(item).Units, state.dataOutRptTab->unitConvIndexWCCT, IPunitName);
   10874           0 :                 if (state.dataOutRptTab->unitConvIndexWCCT != 0) {
   10875             :                     Real64 const IPqty =
   10876           0 :                         ConvertIP(state, state.dataOutRptTab->unitConvIndexWCCT, state.dataCostEstimateManager->CostLineItem(item).Qty);
   10877           0 :                     tableBody(3, item) = RealToStr(IPqty, 2);
   10878           0 :                     tableBody(4, item) = IPunitName;
   10879           0 :                     Real64 const IPsingleValue = ConvertIP(state, state.dataOutRptTab->unitConvIndexWCCT, 1.0);
   10880           0 :                     if (IPsingleValue != 0.0) {
   10881           0 :                         Real64 const IPvaluePer = state.dataCostEstimateManager->CostLineItem(item).ValuePer / IPsingleValue;
   10882           0 :                         tableBody(5, item) = RealToStr(IPvaluePer, 2);
   10883             :                     }
   10884             :                 } else {
   10885           0 :                     tableBody(3, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).Qty, 2);
   10886           0 :                     tableBody(4, item) = state.dataCostEstimateManager->CostLineItem(item).Units;
   10887           0 :                     tableBody(5, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).ValuePer, 2);
   10888             :                 }
   10889           0 :             } else {
   10890        2313 :                 tableBody(3, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).Qty, 2);
   10891        2313 :                 tableBody(4, item) = state.dataCostEstimateManager->CostLineItem(item).Units;
   10892        2313 :                 tableBody(5, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).ValuePer, 2);
   10893             :             }
   10894        2313 :             tableBody(6, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).LineSubTotal, 2);
   10895             :         }
   10896          38 :         tableBody(6, NumRows) = RealToStr(state.dataCostEstimateManager->CurntBldg.LineItemTot, 2);
   10897          38 :         if (produceTabular) {
   10898          38 :             WriteSubtitle(state, "Cost Line Item Details"); //: '//TRIM(RealToStr(CostEstimateTotal, 2)))
   10899          38 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10900             :         }
   10901          38 :         if (produceSQLite) {
   10902          38 :             if (state.dataSQLiteProcedures->sqlite) {
   10903           5 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10904             :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Cost Line Item Details");
   10905             :             }
   10906             :         }
   10907          38 :         if (produceTabular) {
   10908          38 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10909           0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10910             :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Cost Line Item Details");
   10911             :             }
   10912             :         }
   10913             :     }
   10914          38 : }
   10915             : 
   10916             : // modify the ith row in the reportingperiod input verification table
   10917          11 : void writeRowReportPeriodInputVeri(const std::string &reportType,
   10918             :                                    Array2D_string &tableBody,
   10919             :                                    const int rowid,
   10920             :                                    const int periodIdx,
   10921             :                                    const Array1D<Weather::ReportPeriodData> &ReportPeriodInputData)
   10922             : {
   10923          11 :     tableBody(1, rowid) = reportType;
   10924          11 :     tableBody(2, rowid) = std::to_string(periodIdx);
   10925          11 :     tableBody(3, rowid) = ReportPeriodInputData(periodIdx).title;
   10926          22 :     tableBody(4, rowid) = formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).startYear,
   10927          11 :                                                       ReportPeriodInputData(periodIdx).startMonth,
   10928          11 :                                                       ReportPeriodInputData(periodIdx).startDay,
   10929          22 :                                                       ReportPeriodInputData(periodIdx).startHour);
   10930          22 :     tableBody(5, rowid) = formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).endYear,
   10931          11 :                                                       ReportPeriodInputData(periodIdx).endMonth,
   10932          11 :                                                       ReportPeriodInputData(periodIdx).endDay,
   10933          22 :                                                       ReportPeriodInputData(periodIdx).endHour);
   10934          11 :     tableBody(6, rowid) = RealToStr(ReportPeriodInputData(periodIdx).totalElectricityUse / 3600000.0, 2);
   10935          11 : }
   10936             : 
   10937         754 : void WriteVeriSumTable(EnergyPlusData &state)
   10938             : {
   10939             :     // SUBROUTINE INFORMATION:
   10940             :     //       AUTHOR         Jason Glazer
   10941             :     //       DATE WRITTEN   June 2006
   10942             :     //       MODIFIED       Jan. 2010, Kyle Benne. Added SQLite output
   10943             :     //                      Aug. 2015, Sang Hoon Lee. Added a new table for hybrid modeling multiplier output.
   10944             :     //       RE-ENGINEERED  na
   10945             : 
   10946             :     // PURPOSE OF THIS SUBROUTINE:
   10947             :     //   Summarize inputs and results for use with code and beyond-code
   10948             :     //   compliance into a tabular report for output.
   10949             : 
   10950             :     // METHODOLOGY EMPLOYED:
   10951             :     //   Create arrays for the call to WriteTable and then call it.
   10952             :     //   This report actually consists of many sub-tables each with
   10953             :     //   its own call to WriteTable.
   10954             : 
   10955             :     // Using/Aliasing
   10956             :     using DataHeatBalance::ZoneData;
   10957             :     using DataSurfaces::ExternalEnvironment;
   10958             :     using DataSurfaces::Ground;
   10959             :     using DataSurfaces::GroundFCfactorMethod;
   10960             :     using DataSurfaces::KivaFoundation;
   10961             :     using DataSurfaces::OtherSideCondModeledExt;
   10962             :     using DataSurfaces::SurfaceClass;
   10963             :     using General::SafeDivide;
   10964             :     using ScheduleManager::GetScheduleName;
   10965             :     using ScheduleManager::ScheduleAverageHoursPerWeek;
   10966             : 
   10967         754 :     auto const &ort = state.dataOutRptTab;
   10968             : 
   10969             :     // all arrays are in the format: (row, columnm)
   10970         754 :     if (!ort->displayTabularVeriSum) {
   10971          10 :         return;
   10972             :     }
   10973             : 
   10974             :     // SUBROUTINE PARAMETER DEFINITIONS:
   10975         744 :     int constexpr wwrcTotal(1);
   10976         744 :     int constexpr wwrcNorth(2);
   10977         744 :     int constexpr wwrcEast(3);
   10978         744 :     int constexpr wwrcSouth(4);
   10979         744 :     int constexpr wwrcWest(5);
   10980         744 :     int constexpr wwrrWall(1);
   10981         744 :     int constexpr wwrrAbvGndWall(2);
   10982         744 :     int constexpr wwrrWindow(3);
   10983         744 :     int constexpr wwrrWWR(4);
   10984         744 :     int constexpr wwrrAbvGndWWR(5);
   10985             : 
   10986             :     // all arrays are in the format: (row, column)
   10987         744 :     Array1D_string columnHead;
   10988         744 :     Array1D_int columnWidth;
   10989         744 :     Array1D_string rowHead;
   10990         744 :     Array2D_string tableBody;
   10991             : 
   10992         744 :     Array1D<Real64> zoneOpeningArea;
   10993         744 :     zoneOpeningArea.allocate(state.dataGlobal->NumOfZones);
   10994             :     // zoneOpeningArea = 0.0;
   10995             : 
   10996         744 :     Array1D<Real64> zoneGlassArea;
   10997         744 :     zoneGlassArea.allocate(state.dataGlobal->NumOfZones);
   10998             :     // zoneGlassArea = 0.0;
   10999             : 
   11000        1488 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   11001        1488 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   11002        1488 :         bool produceTabular = true;
   11003        1488 :         bool produceSQLite = false;
   11004        1488 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   11005             : 
   11006             :         // show the headers of the report
   11007         744 :         if (produceTabular) {
   11008         744 :             WriteReportHeaders(state, "Input Verification and Results Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   11009             :         }
   11010             : 
   11011             :         // Moved these initializations into the loop
   11012         744 :         state.dataOutRptTab->zstArea = 0.0;
   11013         744 :         state.dataOutRptTab->zstVolume = 0.0;
   11014         744 :         state.dataOutRptTab->zstWallArea = 0.0;
   11015         744 :         state.dataOutRptTab->zstUndWallArea = 0.0;
   11016         744 :         state.dataOutRptTab->zstWindowArea = 0.0;
   11017         744 :         state.dataOutRptTab->zstOpeningArea = 0.0;
   11018         744 :         state.dataOutRptTab->zstLight = 0.0;
   11019         744 :         state.dataOutRptTab->zstPeople = 0.0;
   11020         744 :         state.dataOutRptTab->zstPlug = 0.0;
   11021             : 
   11022         744 :         zoneOpeningArea = 0.0;
   11023         744 :         zoneGlassArea = 0.0;
   11024             : 
   11025             :         // do unit conversions if necessary
   11026         744 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   11027          11 :             std::string SIunit;
   11028          11 :             SIunit = "[m]";
   11029          11 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m_unitName);
   11030          11 :             state.dataOutRptTab->m_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11031          11 :             SIunit = "[m2]";
   11032          11 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m2_unitName);
   11033          11 :             state.dataOutRptTab->m2_unitConvWVST = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11034          11 :             SIunit = "[m3]";
   11035          11 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m3_unitName);
   11036          11 :             state.dataOutRptTab->m3_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11037          11 :             SIunit = "[W/m2]";
   11038          11 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->Wm2_unitName);
   11039          11 :             state.dataOutRptTab->Wm2_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11040         744 :         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   11041           0 :             std::string SIunit;
   11042           0 :             SIunit = "[m]";
   11043           0 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m_unitName);
   11044           0 :             state.dataOutRptTab->m_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11045           0 :             SIunit = "[m2]";
   11046           0 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m2_unitName);
   11047           0 :             state.dataOutRptTab->m2_unitConvWVST = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11048           0 :             SIunit = "[m3]";
   11049           0 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m3_unitName);
   11050           0 :             state.dataOutRptTab->m3_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11051           0 :             SIunit = "[W/m2]";
   11052             :             // LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->Wm2_unitName);
   11053           0 :             state.dataOutRptTab->Wm2_unitName = "[W/ft2]";
   11054           0 :             state.dataOutRptTab->Wm2_unitConv = 0.3048 * 0.3048; // ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11055           0 :         } else {
   11056         733 :             state.dataOutRptTab->m_unitName = "[m]";
   11057         733 :             state.dataOutRptTab->m_unitConv = 1.0;
   11058         733 :             state.dataOutRptTab->m2_unitName = "[m2]";
   11059         733 :             state.dataOutRptTab->m2_unitConvWVST = 1.0;
   11060         733 :             state.dataOutRptTab->m3_unitName = "[m3]";
   11061         733 :             state.dataOutRptTab->m3_unitConv = 1.0;
   11062         733 :             state.dataOutRptTab->Wm2_unitName = "[W/m2]";
   11063         733 :             state.dataOutRptTab->Wm2_unitConv = 1.0;
   11064             :         }
   11065             :         //---- General Sub-Table
   11066             : 
   11067             :         // since a variable number of design days is possible, first read them before sizing the arrays
   11068         744 :         rowHead.allocate(10);
   11069         744 :         columnHead.allocate(1);
   11070         744 :         columnWidth.allocate(1);
   11071         744 :         columnWidth = 14; // array assignment - same for all columns
   11072         744 :         tableBody.allocate(1, 10);
   11073             : 
   11074         744 :         columnHead(1) = "Value";
   11075         744 :         rowHead(1) = "Program Version and Build";
   11076         744 :         rowHead(2) = "RunPeriod";
   11077         744 :         rowHead(3) = "Weather File";
   11078         744 :         rowHead(4) = "Latitude [deg]";
   11079         744 :         rowHead(5) = "Longitude [deg]";
   11080             : 
   11081         744 :         rowHead(6) = "Elevation " + state.dataOutRptTab->m_unitName;
   11082         744 :         rowHead(7) = "Time Zone";
   11083         744 :         rowHead(8) = "North Axis Angle [deg]";
   11084         744 :         rowHead(9) = "Rotation for Appendix G [deg]";
   11085         744 :         rowHead(10) = "Hours Simulated [hrs]";
   11086             :         //  rowHead(9)  = 'Num Table Entries' !used for debugging
   11087             : 
   11088         744 :         tableBody = "";
   11089             : 
   11090         744 :         tableBody(1, 1) = state.dataStrGlobals->VerStringVar;                                         // program
   11091         744 :         tableBody(1, 2) = state.dataEnvrn->EnvironmentName;                                           // runperiod name
   11092         744 :         tableBody(1, 3) = state.dataEnvrn->WeatherFileLocationTitle;                                  // weather
   11093         744 :         tableBody(1, 4) = RealToStr(state.dataEnvrn->Latitude, 2);                                    // latitude
   11094         744 :         tableBody(1, 5) = RealToStr(state.dataEnvrn->Longitude, 2);                                   // longitude
   11095         744 :         tableBody(1, 6) = RealToStr(state.dataEnvrn->Elevation * state.dataOutRptTab->m_unitConv, 2); // Elevation
   11096         744 :         tableBody(1, 7) = RealToStr(state.dataEnvrn->TimeZoneNumber, 2);                              // Time Zone
   11097         744 :         tableBody(1, 8) = RealToStr(state.dataHeatBal->BuildingAzimuth, 2);                           // north axis angle
   11098         744 :         tableBody(1, 9) = RealToStr(state.dataHeatBal->BuildingRotationAppendixG, 2);                 // Rotation for Appendix G
   11099         744 :         tableBody(1, 10) = RealToStr(ort->gatherElapsedTimeBEPS, 2);                                  // hours simulated
   11100             :         //  tableBody(9,1) = TRIM(fmt::to_string(numTableEntry)) !number of table entries for predefined tables
   11101             : 
   11102         744 :         if (produceTabular) {
   11103         744 :             WriteSubtitle(state, "General");
   11104         744 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11105             :         }
   11106         744 :         if (produceSQLite) {
   11107         744 :             if (state.dataSQLiteProcedures->sqlite) {
   11108         120 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11109             :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "General");
   11110             :             }
   11111             :         }
   11112         744 :         if (produceTabular) {
   11113         744 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11114           7 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11115             :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "General");
   11116             :             }
   11117             : 
   11118             :             //---- Window Wall Ratio Sub-Table
   11119         744 :             WriteTextLine(state, "ENVELOPE", true);
   11120             :         }
   11121             : 
   11122         744 :         rowHead.allocate(5);
   11123         744 :         columnHead.allocate(5);
   11124         744 :         columnWidth.allocate(5);
   11125         744 :         columnWidth = 14; // array assignment - same for all columns
   11126         744 :         tableBody.allocate(5, 5);
   11127             : 
   11128         744 :         columnHead(wwrcTotal) = "Total";
   11129         744 :         columnHead(wwrcNorth) = "North (315 to 45 deg)";
   11130         744 :         columnHead(wwrcEast) = "East (45 to 135 deg)";
   11131         744 :         columnHead(wwrcSouth) = "South (135 to 225 deg)";
   11132         744 :         columnHead(wwrcWest) = "West (225 to 315 deg)";
   11133             : 
   11134         744 :         rowHead(wwrrWall) = "Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11135         744 :         rowHead(wwrrAbvGndWall) = "Above Ground Wall Area " + state.dataOutRptTab->m2_unitName;
   11136         744 :         rowHead(wwrrWindow) = "Window Opening Area " + state.dataOutRptTab->m2_unitName;
   11137         744 :         rowHead(wwrrWWR) = "Gross Window-Wall Ratio [%]";
   11138         744 :         rowHead(wwrrAbvGndWWR) = "Above Ground Window-Wall Ratio [%]";
   11139             : 
   11140         744 :         Real64 wallAreaN = 0.0;
   11141         744 :         Real64 wallAreaS = 0.0;
   11142         744 :         Real64 wallAreaE = 0.0;
   11143         744 :         Real64 wallAreaW = 0.0;
   11144         744 :         Real64 aboveGroundWallAreaN = 0.0;
   11145         744 :         Real64 aboveGroundWallAreaS = 0.0;
   11146         744 :         Real64 aboveGroundWallAreaE = 0.0;
   11147         744 :         Real64 aboveGroundWallAreaW = 0.0;
   11148         744 :         Real64 windowAreaN = 0.0;
   11149         744 :         Real64 windowAreaS = 0.0;
   11150         744 :         Real64 windowAreaE = 0.0;
   11151         744 :         Real64 windowAreaW = 0.0;
   11152             :         // wall and window areas attached to conditioned zones
   11153         744 :         Real64 wallAreaNcond = 0.0;
   11154         744 :         Real64 wallAreaScond = 0.0;
   11155         744 :         Real64 wallAreaEcond = 0.0;
   11156         744 :         Real64 wallAreaWcond = 0.0;
   11157         744 :         Real64 aboveGroundWallAreaNcond = 0.0;
   11158         744 :         Real64 aboveGroundWallAreaScond = 0.0;
   11159         744 :         Real64 aboveGroundWallAreaEcond = 0.0;
   11160         744 :         Real64 aboveGroundWallAreaWcond = 0.0;
   11161         744 :         Real64 windowAreaNcond = 0.0;
   11162         744 :         Real64 windowAreaScond = 0.0;
   11163         744 :         Real64 windowAreaEcond = 0.0;
   11164         744 :         Real64 windowAreaWcond = 0.0;
   11165             : 
   11166         744 :         Real64 roofArea = 0.0;
   11167         744 :         Real64 skylightArea = 0.0;
   11168             : 
   11169         744 :         bool DetailedWWR = (state.dataInputProcessing->inputProcessor->getNumSectionsFound("DETAILEDWWR_DEBUG") > 0);
   11170         744 :         if (DetailedWWR) {
   11171           0 :             if (produceTabular) {
   11172           0 :                 print(state.files.debug, "{}\n", "======90.1 Classification [>=60 & <=120] tilt = wall==================");
   11173           0 :                 print(state.files.debug, "{}\n", "SurfName,Class,Area,Tilt");
   11174             :             }
   11175             :         }
   11176             : 
   11177       44800 :         for (int iSurf = 1; iSurf <= state.dataSurface->TotSurfaces; ++iSurf) {
   11178             :             // only exterior surfaces including underground
   11179       44056 :             auto const &thisSurf = state.dataSurface->Surface(iSurf);
   11180       44056 :             if (!thisSurf.HeatTransSurf) continue;
   11181       42573 :             bool const isAboveGround = (thisSurf.ExtBoundCond == ExternalEnvironment) || (thisSurf.ExtBoundCond == OtherSideCondModeledExt);
   11182       42573 :             if (isAboveGround || (thisSurf.ExtBoundCond == Ground) || (thisSurf.ExtBoundCond == GroundFCfactorMethod) ||
   11183       23221 :                 (thisSurf.ExtBoundCond == KivaFoundation)) {
   11184       19390 :                 Real64 curAzimuth = thisSurf.Azimuth;
   11185             :                 // Round to two decimals, like the display in tables
   11186       19390 :                 curAzimuth = round(curAzimuth * 100.0) / 100.0;
   11187       19390 :                 Real64 curArea = thisSurf.GrossArea;
   11188       19390 :                 if (thisSurf.FrameDivider != 0) {
   11189         376 :                     Real64 const frameWidth = state.dataSurface->FrameDivider(thisSurf.FrameDivider).FrameWidth;
   11190         376 :                     Real64 const frameArea =
   11191         376 :                         (thisSurf.Height + 2.0 * frameWidth) * (thisSurf.Width + 2.0 * frameWidth) - (thisSurf.Height * thisSurf.Width);
   11192         376 :                     curArea += frameArea;
   11193             :                 }
   11194       19390 :                 int const zonePt = thisSurf.Zone;
   11195             : 
   11196       19390 :                 bool const isConditioned = (zonePt > 0) && (state.dataHeatBal->Zone(zonePt).SystemZoneNodeNumber > 0);
   11197       19390 :                 if ((thisSurf.Tilt >= 60.0) && (thisSurf.Tilt <= 120.0)) {
   11198             :                     // vertical walls and windows
   11199       14611 :                     switch (thisSurf.Class) {
   11200        8659 :                     case SurfaceClass::Wall:
   11201             :                     case SurfaceClass::Floor:
   11202             :                     case SurfaceClass::Roof: {
   11203        8659 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11204        8659 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
   11205        8659 :                         if ((curAzimuth >= 315.0) || (curAzimuth < 45.0)) {
   11206        2247 :                             wallAreaN += curArea * mult;
   11207        2247 :                             if (isConditioned) wallAreaNcond += curArea * mult;
   11208        2247 :                             if (isAboveGround) {
   11209        2201 :                                 aboveGroundWallAreaN += curArea * mult;
   11210        2201 :                                 if (isConditioned) aboveGroundWallAreaNcond += curArea * mult;
   11211             :                             }
   11212        6412 :                         } else if ((curAzimuth >= 45.0) && (curAzimuth < 135.0)) {
   11213        2050 :                             wallAreaE += curArea * mult;
   11214        2050 :                             if (isConditioned) wallAreaEcond += curArea * mult;
   11215        2050 :                             if (isAboveGround) {
   11216        2005 :                                 aboveGroundWallAreaE += curArea * mult;
   11217        2005 :                                 if (isConditioned) aboveGroundWallAreaEcond += curArea * mult;
   11218             :                             }
   11219        4362 :                         } else if ((curAzimuth >= 135.0) && (curAzimuth < 225.0)) {
   11220        2243 :                             wallAreaS += curArea * mult;
   11221        2243 :                             if (isConditioned) wallAreaScond += curArea * mult;
   11222        2243 :                             if (isAboveGround) {
   11223        2197 :                                 aboveGroundWallAreaS += curArea * mult;
   11224        2197 :                                 if (isConditioned) aboveGroundWallAreaScond += curArea * mult;
   11225             :                             }
   11226        2119 :                         } else if ((curAzimuth >= 225.0) && (curAzimuth < 315.0)) {
   11227        2119 :                             wallAreaW += curArea * mult;
   11228        2119 :                             if (isConditioned) wallAreaWcond += curArea * mult;
   11229        2119 :                             if (isAboveGround) {
   11230        2075 :                                 aboveGroundWallAreaW += curArea * mult;
   11231        2075 :                                 if (isConditioned) aboveGroundWallAreaWcond += curArea * mult;
   11232             :                             }
   11233             :                         }
   11234        8659 :                         if (DetailedWWR) {
   11235           0 :                             if (produceTabular) {
   11236           0 :                                 print(state.files.debug, "{},Wall,{:.1R},{:.1R}\n", thisSurf.Name, curArea * mult, thisSurf.Tilt);
   11237             :                             }
   11238             :                         }
   11239        8659 :                     } break;
   11240        5555 :                     case SurfaceClass::Window:
   11241             :                     case SurfaceClass::TDD_Dome: {
   11242        5555 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11243        5555 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier * thisSurf.Multiplier;
   11244        5555 :                         if ((curAzimuth >= 315.0) || (curAzimuth < 45.0)) {
   11245        1396 :                             windowAreaN += curArea * mult;
   11246        1396 :                             if (isConditioned) windowAreaNcond += curArea * mult;
   11247        4159 :                         } else if ((curAzimuth >= 45.0) && (curAzimuth < 135.0)) {
   11248        1007 :                             windowAreaE += curArea * mult;
   11249        1007 :                             if (isConditioned) windowAreaEcond += curArea * mult;
   11250        3152 :                         } else if ((curAzimuth >= 135.0) && (curAzimuth < 225.0)) {
   11251        2150 :                             windowAreaS += curArea * mult;
   11252        2150 :                             if (isConditioned) windowAreaScond += curArea * mult;
   11253        1002 :                         } else if ((curAzimuth >= 225.0) && (curAzimuth < 315.0)) {
   11254        1002 :                             windowAreaW += curArea * mult;
   11255        1002 :                             if (isConditioned) windowAreaWcond += curArea * mult;
   11256             :                         }
   11257        5555 :                         zoneOpeningArea(zonePt) += curArea * thisSurf.Multiplier; // total window opening area for each zone (glass plus frame area)
   11258        5555 :                         zoneGlassArea(zonePt) += thisSurf.GrossArea * thisSurf.Multiplier;
   11259        5555 :                         if (DetailedWWR) {
   11260           0 :                             if (produceTabular) {
   11261           0 :                                 print(state.files.debug, "{},Window,{:.1R},{:.1R}\n", thisSurf.Name, curArea * mult, thisSurf.Tilt);
   11262             :                             }
   11263             :                         }
   11264        5555 :                     } break;
   11265         397 :                     default:
   11266         397 :                         break;
   11267             :                     }
   11268       19390 :                 } else if (thisSurf.Tilt < 60.0) { // roof and skylights
   11269        2530 :                     switch (thisSurf.Class) {
   11270        2140 :                     case SurfaceClass::Wall:
   11271             :                     case SurfaceClass::Floor:
   11272             :                     case SurfaceClass::Roof: {
   11273        2140 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11274        2140 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
   11275        2140 :                         roofArea += curArea * mult;
   11276        2140 :                         if (DetailedWWR) {
   11277           0 :                             if (produceTabular) {
   11278           0 :                                 print(state.files.debug, "{},Roof,{:.1R},{:.1R}\n", thisSurf.Name, curArea * mult, thisSurf.Tilt);
   11279             :                             }
   11280             :                         }
   11281        2140 :                     } break;
   11282         389 :                     case SurfaceClass::Window:
   11283             :                     case SurfaceClass::TDD_Dome: {
   11284         389 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11285         389 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier * thisSurf.Multiplier;
   11286         389 :                         skylightArea += curArea * mult;
   11287         389 :                         if (DetailedWWR) {
   11288           0 :                             if (produceTabular) {
   11289           0 :                                 print(state.files.debug, "{},Skylight,{:.1R},{:.1R}\n", thisSurf.Name, curArea * mult, thisSurf.Tilt);
   11290             :                             }
   11291             :                         }
   11292         389 :                     } break;
   11293           1 :                     default:
   11294           1 :                         break;
   11295             :                     }
   11296             :                 } else { // floors
   11297             :                          // ignored
   11298             :                 }
   11299             :             }
   11300             :         }
   11301             : 
   11302         744 :         Real64 TotalWallArea = wallAreaN + wallAreaS + wallAreaE + wallAreaW;
   11303         744 :         Real64 TotalAboveGroundWallArea = aboveGroundWallAreaN + aboveGroundWallAreaS + aboveGroundWallAreaE + aboveGroundWallAreaW;
   11304         744 :         Real64 TotalWindowArea = windowAreaN + windowAreaS + windowAreaE + windowAreaW;
   11305         744 :         if (DetailedWWR) {
   11306           0 :             if (produceTabular) {
   11307           0 :                 print(state.files.debug, "{}\n", "========================");
   11308           0 :                 print(state.files.debug, "{}\n", "TotalWallArea,WallAreaN,WallAreaS,WallAreaE,WallAreaW");
   11309           0 :                 print(state.files.debug, "{}\n", "TotalWindowArea,WindowAreaN,WindowAreaS,WindowAreaE,WindowAreaW");
   11310           0 :                 print(state.files.debug, "{:.2R},{:.2R},{:.2R},{:.2R},{:.2R}\n", TotalWallArea, wallAreaN, wallAreaS, wallAreaE, wallAreaW);
   11311           0 :                 print(state.files.debug, "{:.2R},{:.2R},{:.2R},{:.2R},{:.2R}\n", TotalWindowArea, windowAreaN, windowAreaS, windowAreaE, windowAreaW);
   11312             :             }
   11313             :         }
   11314             : 
   11315         744 :         tableBody = "";
   11316             : 
   11317         744 :         tableBody(wwrcNorth, wwrrWall) = RealToStr(wallAreaN * state.dataOutRptTab->m2_unitConvWVST, 2);
   11318         744 :         tableBody(wwrcSouth, wwrrWall) = RealToStr(wallAreaS * state.dataOutRptTab->m2_unitConvWVST, 2);
   11319         744 :         tableBody(wwrcEast, wwrrWall) = RealToStr(wallAreaE * state.dataOutRptTab->m2_unitConvWVST, 2);
   11320         744 :         tableBody(wwrcWest, wwrrWall) = RealToStr(wallAreaW * state.dataOutRptTab->m2_unitConvWVST, 2);
   11321         744 :         tableBody(wwrcTotal, wwrrWall) = RealToStr(TotalWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11322             : 
   11323         744 :         tableBody(wwrcNorth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaN * state.dataOutRptTab->m2_unitConvWVST, 2);
   11324         744 :         tableBody(wwrcSouth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaS * state.dataOutRptTab->m2_unitConvWVST, 2);
   11325         744 :         tableBody(wwrcEast, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaE * state.dataOutRptTab->m2_unitConvWVST, 2);
   11326         744 :         tableBody(wwrcWest, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaW * state.dataOutRptTab->m2_unitConvWVST, 2);
   11327         744 :         tableBody(wwrcTotal, wwrrAbvGndWall) = RealToStr(TotalAboveGroundWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11328             : 
   11329         744 :         tableBody(wwrcNorth, wwrrWindow) = RealToStr(windowAreaN * state.dataOutRptTab->m2_unitConvWVST, 2);
   11330         744 :         tableBody(wwrcSouth, wwrrWindow) = RealToStr(windowAreaS * state.dataOutRptTab->m2_unitConvWVST, 2);
   11331         744 :         tableBody(wwrcEast, wwrrWindow) = RealToStr(windowAreaE * state.dataOutRptTab->m2_unitConvWVST, 2);
   11332         744 :         tableBody(wwrcWest, wwrrWindow) = RealToStr(windowAreaW * state.dataOutRptTab->m2_unitConvWVST, 2);
   11333         744 :         tableBody(wwrcTotal, wwrrWindow) = RealToStr(TotalWindowArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11334             : 
   11335         744 :         tableBody(wwrcNorth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaN, wallAreaN), 2);
   11336         744 :         tableBody(wwrcSouth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaS, wallAreaS), 2);
   11337         744 :         tableBody(wwrcEast, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaE, wallAreaE), 2);
   11338         744 :         tableBody(wwrcWest, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaW, wallAreaW), 2);
   11339         744 :         tableBody(wwrcTotal, wwrrWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalWallArea), 2);
   11340             : 
   11341         744 :         tableBody(wwrcNorth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaN, aboveGroundWallAreaN), 2);
   11342         744 :         tableBody(wwrcSouth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaS, aboveGroundWallAreaS), 2);
   11343         744 :         tableBody(wwrcEast, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaE, aboveGroundWallAreaE), 2);
   11344         744 :         tableBody(wwrcWest, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaW, aboveGroundWallAreaW), 2);
   11345         744 :         tableBody(wwrcTotal, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalAboveGroundWallArea), 2);
   11346             : 
   11347         744 :         if (produceTabular) {
   11348         744 :             WriteSubtitle(state, "Window-Wall Ratio");
   11349         744 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11350             :         }
   11351         744 :         if (produceSQLite) {
   11352         744 :             if (state.dataSQLiteProcedures->sqlite) {
   11353         120 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11354             :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Window-Wall Ratio");
   11355             :             }
   11356             :         }
   11357         744 :         if (produceTabular) {
   11358         744 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11359           7 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11360             :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Window-Wall Ratio");
   11361             :             }
   11362             :         }
   11363             : 
   11364             :         //---- Conditioned Window Wall Ratio Sub-Table
   11365         744 :         rowHead.allocate(5);
   11366         744 :         columnHead.allocate(5);
   11367         744 :         columnWidth.allocate(5);
   11368         744 :         columnWidth = 14; // array assignment - same for all columns
   11369         744 :         tableBody.allocate(5, 5);
   11370             : 
   11371         744 :         columnHead(wwrcTotal) = "Total";
   11372         744 :         columnHead(wwrcNorth) = "North (315 to 45 deg)";
   11373         744 :         columnHead(wwrcEast) = "East (45 to 135 deg)";
   11374         744 :         columnHead(wwrcSouth) = "South (135 to 225 deg)";
   11375         744 :         columnHead(wwrcWest) = "West (225 to 315 deg)";
   11376             : 
   11377         744 :         rowHead(wwrrWall) = "Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11378         744 :         rowHead(wwrrAbvGndWall) = "Above Ground Wall Area " + state.dataOutRptTab->m2_unitName;
   11379         744 :         rowHead(wwrrWindow) = "Window Opening Area " + state.dataOutRptTab->m2_unitName;
   11380         744 :         rowHead(wwrrWWR) = "Gross Window-Wall Ratio [%]";
   11381         744 :         rowHead(wwrrAbvGndWWR) = "Above Ground Window-Wall Ratio [%]";
   11382             : 
   11383             :         // calculations appear in last block with normal window-wall ratio table
   11384             : 
   11385         744 :         TotalWallArea = wallAreaNcond + wallAreaScond + wallAreaEcond + wallAreaWcond;
   11386         744 :         TotalAboveGroundWallArea = aboveGroundWallAreaNcond + aboveGroundWallAreaScond + aboveGroundWallAreaEcond + aboveGroundWallAreaWcond;
   11387         744 :         TotalWindowArea = windowAreaNcond + windowAreaScond + windowAreaEcond + windowAreaWcond;
   11388             : 
   11389         744 :         tableBody = "";
   11390             : 
   11391         744 :         tableBody(wwrcNorth, wwrrWall) = RealToStr(wallAreaNcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11392         744 :         tableBody(wwrcSouth, wwrrWall) = RealToStr(wallAreaScond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11393         744 :         tableBody(wwrcEast, wwrrWall) = RealToStr(wallAreaEcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11394         744 :         tableBody(wwrcWest, wwrrWall) = RealToStr(wallAreaWcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11395         744 :         tableBody(wwrcTotal, wwrrWall) = RealToStr(TotalWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11396             : 
   11397         744 :         tableBody(wwrcNorth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaNcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11398         744 :         tableBody(wwrcSouth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaScond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11399         744 :         tableBody(wwrcEast, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaEcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11400         744 :         tableBody(wwrcWest, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaWcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11401         744 :         tableBody(wwrcTotal, wwrrAbvGndWall) = RealToStr(TotalAboveGroundWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11402             : 
   11403         744 :         tableBody(wwrcNorth, wwrrWindow) = RealToStr(windowAreaNcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11404         744 :         tableBody(wwrcSouth, wwrrWindow) = RealToStr(windowAreaScond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11405         744 :         tableBody(wwrcEast, wwrrWindow) = RealToStr(windowAreaEcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11406         744 :         tableBody(wwrcWest, wwrrWindow) = RealToStr(windowAreaWcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11407         744 :         tableBody(wwrcTotal, wwrrWindow) = RealToStr(TotalWindowArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11408             : 
   11409         744 :         tableBody(wwrcNorth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaNcond, wallAreaNcond), 2);
   11410         744 :         tableBody(wwrcSouth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaScond, wallAreaScond), 2);
   11411         744 :         tableBody(wwrcEast, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaEcond, wallAreaEcond), 2);
   11412         744 :         tableBody(wwrcWest, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaWcond, wallAreaWcond), 2);
   11413         744 :         tableBody(wwrcTotal, wwrrWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalWallArea), 2);
   11414             : 
   11415         744 :         tableBody(wwrcNorth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaNcond, aboveGroundWallAreaNcond), 2);
   11416         744 :         tableBody(wwrcSouth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaScond, aboveGroundWallAreaScond), 2);
   11417         744 :         tableBody(wwrcEast, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaEcond, aboveGroundWallAreaEcond), 2);
   11418         744 :         tableBody(wwrcWest, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaWcond, aboveGroundWallAreaWcond), 2);
   11419         744 :         tableBody(wwrcTotal, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalAboveGroundWallArea), 2);
   11420             : 
   11421         744 :         if (produceTabular) {
   11422         744 :             WriteSubtitle(state, "Conditioned Window-Wall Ratio");
   11423         744 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11424             :         }
   11425         744 :         if (produceSQLite) {
   11426         744 :             if (state.dataSQLiteProcedures->sqlite) {
   11427         120 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11428             :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Conditioned Window-Wall Ratio");
   11429             :             }
   11430             :         }
   11431         744 :         if (produceTabular) {
   11432         744 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11433           7 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11434             :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Conditioned Window-Wall Ratio");
   11435             :             }
   11436             :         }
   11437             : 
   11438             :         //---- Skylight Roof Ratio Sub-Table
   11439         744 :         rowHead.allocate(3);
   11440         744 :         columnHead.allocate(1);
   11441         744 :         columnWidth.allocate(1);
   11442         744 :         columnWidth = 14; // array assignment - same for all columns
   11443         744 :         tableBody.allocate(1, 3);
   11444             : 
   11445         744 :         columnHead(1) = "Total";
   11446             : 
   11447         744 :         rowHead(1) = "Gross Roof Area " + state.dataOutRptTab->m2_unitName;
   11448         744 :         rowHead(2) = "Skylight Area " + state.dataOutRptTab->m2_unitName;
   11449         744 :         rowHead(3) = "Skylight-Roof Ratio [%]";
   11450             : 
   11451         744 :         if (DetailedWWR) {
   11452           0 :             if (produceTabular) {
   11453           0 :                 print(state.files.debug, "{}\n", "========================");
   11454           0 :                 print(state.files.debug, "{}\n", "TotalRoofArea,SkylightArea");
   11455           0 :                 print(state.files.debug, "{:.2R},{:.2R}\n", roofArea, skylightArea);
   11456             :             }
   11457             :         }
   11458             : 
   11459         744 :         tableBody(1, 1) = RealToStr(roofArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11460         744 :         tableBody(1, 2) = RealToStr(skylightArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11461         744 :         tableBody(1, 3) = RealToStr(100.0 * SafeDivide(skylightArea, roofArea), 2);
   11462             : 
   11463         744 :         if (produceTabular) {
   11464         744 :             WriteSubtitle(state, "Skylight-Roof Ratio");
   11465         744 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11466             :         }
   11467         744 :         if (produceSQLite) {
   11468         744 :             if (state.dataSQLiteProcedures->sqlite) {
   11469         120 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11470             :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Skylight-Roof Ratio");
   11471             :             }
   11472             :         }
   11473         744 :         if (produceTabular) {
   11474         744 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11475           7 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11476             :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Skylight-Roof Ratio");
   11477             :             }
   11478             :         }
   11479             : 
   11480             :         //---- Hybrid Model: Internal Thermal Mass Sub-Table
   11481         744 :         if (state.dataHybridModel->FlagHybridModel_TM) {
   11482           1 :             rowHead.allocate(state.dataGlobal->NumOfZones);
   11483           1 :             int const NumOfCol = 2;
   11484           1 :             columnHead.allocate(NumOfCol);
   11485           1 :             columnWidth.allocate(NumOfCol);
   11486           1 :             columnWidth = 14; // array assignment - same for all columns
   11487           1 :             tableBody.allocate(NumOfCol, state.dataGlobal->NumOfZones);
   11488             : 
   11489           1 :             columnHead(1) = "Hybrid Modeling (Y/N)";
   11490           1 :             columnHead(2) = "Temperature Capacitance Multiplier ";
   11491             : 
   11492           1 :             rowHead = "";
   11493           1 :             tableBody = "";
   11494             : 
   11495           5 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   11496           4 :                 auto const &thisZone = state.dataHeatBal->Zone(iZone);
   11497             : 
   11498           4 :                 rowHead(iZone) = thisZone.Name;
   11499           4 :                 if (state.dataHybridModel->HybridModelZone(iZone).InternalThermalMassCalc_T) {
   11500           3 :                     tableBody(1, iZone) = "Yes";
   11501             :                 } else {
   11502           1 :                     tableBody(1, iZone) = "No";
   11503             :                 }
   11504           4 :                 tableBody(2, iZone) = RealToStr(thisZone.ZoneVolCapMultpSensHMAverage, 2);
   11505             :             }
   11506             : 
   11507           1 :             if (produceTabular) {
   11508           1 :                 WriteSubtitle(state, "Hybrid Model: Internal Thermal Mass");
   11509           1 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11510             :             }
   11511           1 :             if (produceSQLite) {
   11512           1 :                 if (state.dataSQLiteProcedures->sqlite) {
   11513           0 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   11514             :                                                                                        rowHead,
   11515             :                                                                                        columnHead,
   11516             :                                                                                        "InputVerificationandResultsSummary",
   11517             :                                                                                        "Entire Facility",
   11518             :                                                                                        "Hybrid Model: Internal Thermal Mass");
   11519             :                 }
   11520             :             }
   11521             :         }
   11522             : 
   11523         744 :         Real64 const totExtGrossWallArea_Multiplied = sum(state.dataHeatBal->Zone, &ZoneData::ExtGrossWallArea_Multiplied);
   11524         744 :         Real64 const totExtGrossGroundWallArea_Multiplied = sum(state.dataHeatBal->Zone, &ZoneData::ExtGrossGroundWallArea_Multiplied);
   11525         744 :         if (totExtGrossWallArea_Multiplied > 0.0 || totExtGrossGroundWallArea_Multiplied > 0.0) {
   11526             :             Real64 const pdiff =
   11527         717 :                 std::abs((wallAreaN + wallAreaS + wallAreaE + wallAreaW) - (totExtGrossWallArea_Multiplied + totExtGrossGroundWallArea_Multiplied)) /
   11528         717 :                 (totExtGrossWallArea_Multiplied + totExtGrossGroundWallArea_Multiplied);
   11529         717 :             if (pdiff > 0.019) {
   11530           0 :                 if (produceTabular) {
   11531           0 :                     ShowWarningError(
   11532             :                         state, "WriteVeriSumTable: InputVerificationsAndResultsSummary: Wall area based on [>=60,<=120] degrees (tilt) as walls");
   11533           0 :                     ShowContinueError(state,
   11534           0 :                                       format("differs ~{:.1R}% from user entered Wall class surfaces. Degree calculation based on ASHRAE "
   11535             :                                              "90.1 wall definitions.",
   11536           0 :                                              pdiff * 100.0));
   11537             :                     //      CALL ShowContinueError(state, format("Calculated based on degrees=[{}{}{}{}{}{}] m2, Calculated from user entered Wall
   11538             :                     //      class surfaces=[{}{}{}{}{}{}", //, &, //, TRIM(ADJUSTL(RealToStr((wallAreaN + wallAreaS + wallAreaE +
   11539             :                     //      wallAreaW),3)))//, &, //, //, &, //,
   11540             :                     //      TRIM(ADJUSTL(RealToStr(SUM(Zone(1:NumOfZones)%ExtGrossWallArea_Multiplied),3)))//', m2.'), ShowContinueError(state,
   11541             :                     //      "Check classes of surfaces and tilts for discrepancies."));
   11542           0 :                     ShowContinueError(state,
   11543           0 :                                       format("Total wall area by ASHRAE 90.1 definition={} m2.",
   11544           0 :                                              stripped(RealToStr((wallAreaN + wallAreaS + wallAreaE + wallAreaW), 3))));
   11545           0 :                     ShowContinueError(
   11546             :                         state,
   11547           0 :                         format("Total exterior wall area from user entered classes={} m2.", stripped(RealToStr(totExtGrossWallArea_Multiplied, 3))));
   11548           0 :                     ShowContinueError(state,
   11549           0 :                                       format("Total ground contact wall area from user entered classes={} m2.",
   11550           0 :                                              stripped(RealToStr(totExtGrossGroundWallArea_Multiplied, 3))));
   11551             :                 }
   11552             :             }
   11553             :         }
   11554             :         //---- Space Summary Sub-Table
   11555         744 :         if (produceTabular) {
   11556         744 :             WriteTextLine(state, "PERFORMANCE", true);
   11557             :         }
   11558             : 
   11559         744 :         rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   11560             : 
   11561         744 :         int const NumOfCol = 12;
   11562         744 :         columnHead.allocate(NumOfCol);
   11563         744 :         columnWidth.allocate(NumOfCol);
   11564         744 :         columnWidth = 14; // array assignment - same for all columns
   11565         744 :         tableBody.allocate(NumOfCol, state.dataGlobal->NumOfZones + 4);
   11566             : 
   11567         744 :         columnHead(1) = "Area " + state.dataOutRptTab->m2_unitName;
   11568         744 :         columnHead(2) = "Conditioned (Y/N)";
   11569         744 :         columnHead(3) = "Part of Total Floor Area (Y/N)";
   11570         744 :         columnHead(4) = "Volume " + state.dataOutRptTab->m3_unitName;
   11571         744 :         columnHead(5) = "Multipliers";
   11572         744 :         columnHead(6) = "Above Ground Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11573         744 :         columnHead(7) = "Underground Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11574         744 :         columnHead(8) = "Window Glass Area " + state.dataOutRptTab->m2_unitName;
   11575         744 :         columnHead(9) = "Opening Area " + state.dataOutRptTab->m2_unitName;
   11576         744 :         columnHead(10) = "Lighting " + state.dataOutRptTab->Wm2_unitName;
   11577        1488 :         columnHead(11) = "People " + state.dataOutRptTab->m2_unitName.substr(0, len(state.dataOutRptTab->m2_unitName) - 1) + " per person" +
   11578        1488 :                          state.dataOutRptTab->m2_unitName[len(state.dataOutRptTab->m2_unitName) - 1];
   11579         744 :         columnHead(12) = "Plug and Process " + state.dataOutRptTab->Wm2_unitName;
   11580             : 
   11581         744 :         rowHead = "";
   11582         744 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->grandTotal) = "Total";
   11583         744 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->condTotal) = "Conditioned Total";
   11584         744 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->uncondTotal) = "Unconditioned Total";
   11585         744 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->notpartTotal) = "Not Part of Total";
   11586             : 
   11587         744 :         tableBody = "";
   11588             : 
   11589        5604 :         for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   11590        4860 :             auto const &thisZone = state.dataHeatBal->Zone(iZone);
   11591             : 
   11592        4860 :             Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
   11593        4860 :             rowHead(iZone) = thisZone.Name;
   11594             :             // Conditioned or not
   11595        4860 :             bool zoneIsCond = false;
   11596        4860 :             if (thisZone.SystemZoneNodeNumber > 0) {
   11597        4454 :                 tableBody(2, iZone) = "Yes";
   11598        4454 :                 zoneIsCond = true;
   11599             :             } else {
   11600         406 :                 tableBody(2, iZone) = "No";
   11601         406 :                 zoneIsCond = false;
   11602             :             }
   11603             :             // Part of Total Floor Area or not
   11604        4860 :             bool usezoneFloorArea = false;
   11605        4860 :             if (thisZone.isPartOfTotalArea) {
   11606        4724 :                 tableBody(3, iZone) = "Yes";
   11607        4724 :                 usezoneFloorArea = true;
   11608             :             } else {
   11609         136 :                 tableBody(3, iZone) = "No";
   11610         136 :                 usezoneFloorArea = false;
   11611             :             }
   11612        4860 :             tableBody(1, iZone) = RealToStr(thisZone.FloorArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11613        4860 :             tableBody(4, iZone) = RealToStr(thisZone.Volume * state.dataOutRptTab->m3_unitConv, 2);
   11614             :             // no unit conversion necessary since done automatically
   11615        4860 :             if (produceTabular) {
   11616        4860 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutSpArea, thisZone.Name, thisZone.FloorArea, 2);
   11617             :             }
   11618        4860 :             if (zoneIsCond) {
   11619        4454 :                 if (produceTabular) {
   11620        4454 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutOcArea, thisZone.Name, thisZone.FloorArea, 2);
   11621        4454 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutUnArea, thisZone.Name, "0.00");
   11622             :                 }
   11623             :             } else {
   11624         406 :                 if (produceTabular) {
   11625         406 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutOcArea, thisZone.Name, "0.00");
   11626         406 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutUnArea, thisZone.Name, thisZone.FloorArea, 2);
   11627             :                 }
   11628             :             }
   11629        4860 :             tableBody(5, iZone) = RealToStr(mult, 2);
   11630        4860 :             tableBody(6, iZone) = RealToStr(thisZone.ExtGrossWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11631        4860 :             tableBody(7, iZone) = RealToStr(thisZone.ExtGrossGroundWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11632        4860 :             tableBody(8, iZone) = RealToStr(zoneGlassArea(iZone) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11633        4860 :             tableBody(9, iZone) = RealToStr(zoneOpeningArea(iZone) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11634             :             // lighting density
   11635        4860 :             Real64 totLightPower = 0.0;
   11636      142362 :             for (int iLight = 1; iLight <= state.dataHeatBal->TotLights; ++iLight) {
   11637      137502 :                 if (iZone == state.dataHeatBal->Lights(iLight).ZonePtr) {
   11638        4185 :                     totLightPower += state.dataHeatBal->Lights(iLight).DesignLevel;
   11639             :                 }
   11640             :             }
   11641        4860 :             if (thisZone.FloorArea > 0) {
   11642        4858 :                 tableBody(10, iZone) = RealToStr(state.dataOutRptTab->Wm2_unitConv * totLightPower / thisZone.FloorArea, 4);
   11643             :             }
   11644             :             // people density
   11645        4860 :             Real64 totNumPeople = 0.0;
   11646      108363 :             for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   11647      103503 :                 if (iZone == state.dataHeatBal->People(iPeople).ZonePtr) {
   11648        3964 :                     totNumPeople += state.dataHeatBal->People(iPeople).NumberOfPeople;
   11649             :                 }
   11650             :             }
   11651        4860 :             if (totNumPeople > 0) {
   11652        3862 :                 tableBody(11, iZone) = RealToStr(thisZone.FloorArea * state.dataOutRptTab->m2_unitConvWVST / totNumPeople, 2);
   11653             :             }
   11654             :             // plug and process density
   11655        4860 :             Real64 totPlugProcess = 0.0;
   11656      133168 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotElecEquip; ++iPlugProc) {
   11657      128308 :                 if (iZone == state.dataHeatBal->ZoneElectric(iPlugProc).ZonePtr) {
   11658        4261 :                     totPlugProcess += state.dataHeatBal->ZoneElectric(iPlugProc).DesignLevel;
   11659             :                 }
   11660             :             }
   11661        7438 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotGasEquip; ++iPlugProc) {
   11662        2578 :                 if (iZone == state.dataHeatBal->ZoneGas(iPlugProc).ZonePtr) {
   11663          77 :                     totPlugProcess += state.dataHeatBal->ZoneGas(iPlugProc).DesignLevel;
   11664             :                 }
   11665             :             }
   11666        5023 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotOthEquip; ++iPlugProc) {
   11667         163 :                 if (iZone == state.dataHeatBal->ZoneOtherEq(iPlugProc).ZonePtr) {
   11668          57 :                     totPlugProcess += state.dataHeatBal->ZoneOtherEq(iPlugProc).DesignLevel;
   11669             :                 }
   11670             :             }
   11671        4971 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotHWEquip; ++iPlugProc) {
   11672         111 :                 if (iZone == state.dataHeatBal->ZoneHWEq(iPlugProc).ZonePtr) {
   11673          14 :                     totPlugProcess += state.dataHeatBal->ZoneHWEq(iPlugProc).DesignLevel;
   11674             :                 }
   11675             :             }
   11676        4879 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotITEquip; ++iPlugProc) {
   11677          19 :                 if (iZone == state.dataHeatBal->ZoneITEq(iPlugProc).ZonePtr) {
   11678           7 :                     totPlugProcess += state.dataHeatBal->ZoneITEq(iPlugProc).DesignTotalPower;
   11679             :                 }
   11680             :             }
   11681        4860 :             if (thisZone.FloorArea > 0) {
   11682        4858 :                 tableBody(12, iZone) = RealToStr(totPlugProcess * state.dataOutRptTab->Wm2_unitConv / thisZone.FloorArea, 4);
   11683             :             }
   11684             : 
   11685             :             // total rows for Total / Not Part of Total
   11686             :             // In "Total": break between conditioned/unconditioned
   11687             : 
   11688             :             // If not part of total, goes directly to this row
   11689        4860 :             if (!usezoneFloorArea) {
   11690         136 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->notpartTotal) += mult * thisZone.FloorArea;
   11691         136 :                 state.dataOutRptTab->zstVolume(state.dataOutRptTab->notpartTotal) += mult * thisZone.Volume;
   11692         136 :                 state.dataOutRptTab->zstWallArea(state.dataOutRptTab->notpartTotal) += mult * thisZone.ExtGrossWallArea;
   11693         136 :                 state.dataOutRptTab->zstUndWallArea(state.dataOutRptTab->notpartTotal) += mult * thisZone.ExtGrossGroundWallArea;
   11694         136 :                 state.dataOutRptTab->zstWindowArea(state.dataOutRptTab->notpartTotal) += mult * zoneGlassArea(iZone);
   11695         136 :                 state.dataOutRptTab->zstOpeningArea(state.dataOutRptTab->notpartTotal) += mult * zoneOpeningArea(iZone);
   11696         136 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->notpartTotal) += mult * totLightPower;
   11697         136 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->notpartTotal) += mult * totNumPeople;
   11698         136 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->notpartTotal) += mult * totPlugProcess;
   11699             :             } else {
   11700             :                 // Add it to the 'Total'
   11701        4724 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->grandTotal) += mult * thisZone.FloorArea;
   11702        4724 :                 state.dataOutRptTab->zstVolume(state.dataOutRptTab->grandTotal) += mult * thisZone.Volume;
   11703        4724 :                 state.dataOutRptTab->zstWallArea(state.dataOutRptTab->grandTotal) += mult * thisZone.ExtGrossWallArea;
   11704        4724 :                 state.dataOutRptTab->zstUndWallArea(state.dataOutRptTab->grandTotal) += mult * thisZone.ExtGrossGroundWallArea;
   11705        4724 :                 state.dataOutRptTab->zstWindowArea(state.dataOutRptTab->grandTotal) += mult * zoneGlassArea(iZone);
   11706        4724 :                 state.dataOutRptTab->zstOpeningArea(state.dataOutRptTab->grandTotal) += mult * zoneOpeningArea(iZone);
   11707        4724 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->grandTotal) += mult * totLightPower;
   11708        4724 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->grandTotal) += mult * totNumPeople;
   11709        4724 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->grandTotal) += mult * totPlugProcess;
   11710             : 
   11711             :                 // Subtotal between cond/unconditioned
   11712        4724 :                 int const condUncondTotal = zoneIsCond ? state.dataOutRptTab->condTotal : state.dataOutRptTab->uncondTotal;
   11713        4724 :                 state.dataOutRptTab->zstArea(condUncondTotal) += mult * thisZone.FloorArea;
   11714        4724 :                 state.dataOutRptTab->zstVolume(condUncondTotal) += mult * thisZone.Volume;
   11715        4724 :                 state.dataOutRptTab->zstWallArea(condUncondTotal) += mult * thisZone.ExtGrossWallArea;
   11716        4724 :                 state.dataOutRptTab->zstUndWallArea(condUncondTotal) += mult * thisZone.ExtGrossGroundWallArea;
   11717        4724 :                 state.dataOutRptTab->zstWindowArea(condUncondTotal) += mult * zoneGlassArea(iZone);
   11718        4724 :                 state.dataOutRptTab->zstOpeningArea(condUncondTotal) += mult * zoneOpeningArea(iZone);
   11719        4724 :                 state.dataOutRptTab->zstLight(condUncondTotal) += mult * totLightPower;
   11720        4724 :                 state.dataOutRptTab->zstPeople(condUncondTotal) += mult * totNumPeople;
   11721        4724 :                 state.dataOutRptTab->zstPlug(condUncondTotal) += mult * totPlugProcess;
   11722             :             }
   11723             :         }
   11724        3720 :         for (int iTotal = 1; iTotal <= 4; ++iTotal) {
   11725        2976 :             tableBody(1, state.dataGlobal->NumOfZones + iTotal) =
   11726        5952 :                 RealToStr(state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11727        2976 :             tableBody(4, state.dataGlobal->NumOfZones + iTotal) =
   11728        5952 :                 RealToStr(state.dataOutRptTab->zstVolume(iTotal) * state.dataOutRptTab->m3_unitConv, 2);
   11729        2976 :             tableBody(6, state.dataGlobal->NumOfZones + iTotal) =
   11730        5952 :                 RealToStr(state.dataOutRptTab->zstWallArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11731        2976 :             tableBody(7, state.dataGlobal->NumOfZones + iTotal) =
   11732        5952 :                 RealToStr(state.dataOutRptTab->zstUndWallArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11733        2976 :             tableBody(8, state.dataGlobal->NumOfZones + iTotal) =
   11734        5952 :                 RealToStr(state.dataOutRptTab->zstWindowArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11735        2976 :             tableBody(9, state.dataGlobal->NumOfZones + iTotal) =
   11736        5952 :                 RealToStr(state.dataOutRptTab->zstOpeningArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11737        2976 :             if (state.dataOutRptTab->zstArea(iTotal) != 0) {
   11738        1624 :                 tableBody(10, state.dataGlobal->NumOfZones + iTotal) =
   11739        3248 :                     RealToStr(state.dataOutRptTab->zstLight(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   11740        1624 :                 tableBody(12, state.dataGlobal->NumOfZones + iTotal) =
   11741        3248 :                     RealToStr(state.dataOutRptTab->zstPlug(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   11742             :             }
   11743        2976 :             if (state.dataOutRptTab->zstPeople(iTotal) != 0) {
   11744        2562 :                 tableBody(11, state.dataGlobal->NumOfZones + iTotal) = RealToStr(
   11745        2562 :                     state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST / state.dataOutRptTab->zstPeople(iTotal), 2);
   11746             :             }
   11747             :         }
   11748         744 :         if (produceTabular) {
   11749         744 :             PreDefTableEntry(
   11750         744 :                 state, state.dataOutRptPredefined->pdchLeedSutSpArea, "Totals", state.dataOutRptTab->zstArea(state.dataOutRptTab->grandTotal), 2);
   11751         744 :             PreDefTableEntry(
   11752         744 :                 state, state.dataOutRptPredefined->pdchLeedSutOcArea, "Totals", state.dataOutRptTab->zstArea(state.dataOutRptTab->condTotal), 2);
   11753         744 :             PreDefTableEntry(
   11754         744 :                 state, state.dataOutRptPredefined->pdchLeedSutUnArea, "Totals", state.dataOutRptTab->zstArea(state.dataOutRptTab->uncondTotal), 2);
   11755             : 
   11756         744 :             WriteSubtitle(state, "Zone Summary");
   11757         744 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11758             :         }
   11759         744 :         if (produceSQLite) {
   11760         744 :             if (state.dataSQLiteProcedures->sqlite) {
   11761         120 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11762             :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Zone Summary");
   11763             :             }
   11764             :         }
   11765         744 :         if (produceTabular) {
   11766         744 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11767           7 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11768             :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Zone Summary");
   11769             :             }
   11770             :         }
   11771             : 
   11772         744 :         writeVeriSumSpaceTables(state, produceTabular, produceSQLite);
   11773             :     }
   11774         744 : }
   11775             : 
   11776         744 : void writeVeriSumSpaceTables(EnergyPlusData &state, bool produceTabular, bool produceSQLite)
   11777             : {
   11778             : 
   11779             :     // Write Space and SpaceType sub-tables for Input Verification and Results Summary
   11780         744 :     Array1D_string spaceRowHead;
   11781         744 :     Array1D_string spaceColumnHead;
   11782         744 :     Array1D_int spaceColumnWidth;
   11783         744 :     Array2D_string spaceTableBody;
   11784         744 :     int spaceNumCol = 11;
   11785         744 :     spaceRowHead.allocate(state.dataGlobal->numSpaces + 4); // Extra rows for totals
   11786         744 :     spaceColumnHead.allocate(spaceNumCol);
   11787         744 :     spaceColumnWidth.allocate(spaceNumCol);
   11788         744 :     spaceTableBody.allocate(spaceNumCol, state.dataGlobal->numSpaces + 4); // Extra rows for totals
   11789        8928 :     for (int iCol = 1; iCol <= spaceNumCol; ++iCol) {
   11790        8184 :         spaceColumnWidth(iCol) = 14;
   11791             :     }
   11792             : 
   11793         744 :     spaceColumnHead(1) = "Area " + state.dataOutRptTab->m2_unitName;
   11794         744 :     spaceColumnHead(2) = "Conditioned (Y/N)";
   11795         744 :     spaceColumnHead(3) = "Part of Total Floor Area (Y/N)";
   11796         744 :     spaceColumnHead(4) = "Multipliers";
   11797         744 :     spaceColumnHead(5) = "Zone Name";
   11798         744 :     spaceColumnHead(6) = "Space Type";
   11799         744 :     spaceColumnHead(7) = "Radiant/Solar Enclosure Name";
   11800         744 :     spaceColumnHead(8) = "Lighting " + state.dataOutRptTab->Wm2_unitName;
   11801        1488 :     spaceColumnHead(9) = "People " + state.dataOutRptTab->m2_unitName.substr(0, len(state.dataOutRptTab->m2_unitName) - 1) + " per person" +
   11802        1488 :                          state.dataOutRptTab->m2_unitName[len(state.dataOutRptTab->m2_unitName) - 1];
   11803         744 :     spaceColumnHead(10) = "Plug and Process " + state.dataOutRptTab->Wm2_unitName;
   11804         744 :     spaceColumnHead(11) = "Tags";
   11805             : 
   11806         744 :     int constexpr colSpaceArea(1);
   11807         744 :     int constexpr colConditioned(2);
   11808         744 :     int constexpr colPartOfTotal(3);
   11809         744 :     int constexpr colMultipliers(4);
   11810         744 :     int constexpr colZoneName(5);
   11811         744 :     int constexpr colSpaceType(6);
   11812         744 :     int constexpr colEnclName(7);
   11813         744 :     int constexpr colSpaceLighting(8);
   11814         744 :     int constexpr colSpacePeople(9);
   11815         744 :     int constexpr colSpacePlugProcess(10);
   11816         744 :     int constexpr colSpaceTags(11);
   11817             : 
   11818         744 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->grandTotal) = "Total";
   11819         744 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->condTotal) = "Conditioned Total";
   11820         744 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->uncondTotal) = "Unconditioned Total";
   11821         744 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->notpartTotal) = "Not Part of Total";
   11822             : 
   11823         744 :     EPVector<Real64> spaceTotLighting;
   11824         744 :     EPVector<Real64> spaceTotPeople;
   11825         744 :     EPVector<Real64> spaceTotPlugProcess;
   11826         744 :     spaceTotLighting.allocate(state.dataGlobal->numSpaces);
   11827         744 :     spaceTotPeople.allocate(state.dataGlobal->numSpaces);
   11828         744 :     spaceTotPlugProcess.allocate(state.dataGlobal->numSpaces);
   11829        5616 :     for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   11830        4872 :         spaceTotLighting(iSpace) = 0.0;
   11831        4872 :         spaceTotPeople(iSpace) = 0.0;
   11832        4872 :         spaceTotPlugProcess(iSpace) = 0.0;
   11833             :     }
   11834             : 
   11835         744 :     Array1D_string spaceTypeRowHead;
   11836         744 :     Array1D_string spaceTypeColumnHead;
   11837         744 :     Array1D_int spaceTypeColumnWidth;
   11838         744 :     Array2D_string spaceTypeTableBody;
   11839         744 :     int spaceTypeNumCol = 7;
   11840         744 :     spaceTypeRowHead.allocate(state.dataGlobal->numSpaceTypes + 1); // Extra row for total
   11841         744 :     spaceTypeColumnHead.allocate(spaceTypeNumCol);
   11842         744 :     spaceTypeColumnWidth.allocate(spaceTypeNumCol);
   11843         744 :     spaceTypeTableBody.allocate(spaceTypeNumCol, state.dataGlobal->numSpaceTypes + 1); // Extra row for total
   11844        5952 :     for (int iCol = 1; iCol <= spaceTypeNumCol; ++iCol) {
   11845        5208 :         spaceTypeColumnWidth(iCol) = 14;
   11846             :     }
   11847         744 :     spaceTypeColumnHead(1) = "Total Area " + state.dataOutRptTab->m2_unitName;
   11848         744 :     spaceTypeColumnHead(2) = "Conditioned Area " + state.dataOutRptTab->m2_unitName;
   11849         744 :     spaceTypeColumnHead(3) = "Unconditioned Area " + state.dataOutRptTab->m2_unitName;
   11850         744 :     spaceTypeColumnHead(4) = "Not Part of Total Area " + state.dataOutRptTab->m2_unitName;
   11851         744 :     spaceTypeColumnHead(5) = "Lighting " + state.dataOutRptTab->Wm2_unitName;
   11852        1488 :     spaceTypeColumnHead(6) = "People " + state.dataOutRptTab->m2_unitName.substr(0, len(state.dataOutRptTab->m2_unitName) - 1) + " per person" +
   11853        1488 :                              state.dataOutRptTab->m2_unitName[len(state.dataOutRptTab->m2_unitName) - 1];
   11854         744 :     spaceTypeColumnHead(7) = "Plug and Process " + state.dataOutRptTab->Wm2_unitName;
   11855             : 
   11856         744 :     int constexpr colSpaceTypeTotArea(1);
   11857         744 :     int constexpr colSpaceTypeCondArea(2);
   11858         744 :     int constexpr colSpaceTypeUncondArea(3);
   11859         744 :     int constexpr colSpaceTypeNotTotArea(4);
   11860         744 :     int constexpr colSpaceTypeLighting(5);
   11861         744 :     int constexpr colSpaceTypePeople(6);
   11862         744 :     int constexpr colSpaceTypePlugProcess(7);
   11863             : 
   11864         744 :     spaceTypeRowHead(state.dataGlobal->numSpaceTypes + state.dataOutRptTab->grandTotal) = "Total";
   11865             : 
   11866         744 :     EPVector<Real64> spaceTypeTotArea;
   11867         744 :     EPVector<Real64> spaceTypeCondArea;
   11868         744 :     EPVector<Real64> spaceTypeUncondArea;
   11869         744 :     EPVector<Real64> spaceTypeNotTotArea;
   11870         744 :     EPVector<Real64> spaceTypeTotLighting;
   11871         744 :     EPVector<Real64> spaceTypeTotPeople;
   11872         744 :     EPVector<Real64> spaceTypeTotPlugProcess;
   11873         744 :     spaceTypeTotArea.allocate(state.dataGlobal->numSpaceTypes);
   11874         744 :     spaceTypeCondArea.allocate(state.dataGlobal->numSpaceTypes);
   11875         744 :     spaceTypeUncondArea.allocate(state.dataGlobal->numSpaceTypes);
   11876         744 :     spaceTypeNotTotArea.allocate(state.dataGlobal->numSpaceTypes);
   11877         744 :     spaceTypeTotLighting.allocate(state.dataGlobal->numSpaceTypes);
   11878         744 :     spaceTypeTotPeople.allocate(state.dataGlobal->numSpaceTypes);
   11879         744 :     spaceTypeTotPlugProcess.allocate(state.dataGlobal->numSpaceTypes);
   11880        1473 :     for (int iSpaceType = 1; iSpaceType <= state.dataGlobal->numSpaceTypes; ++iSpaceType) {
   11881         729 :         spaceTypeTotArea(iSpaceType) = 0.0;
   11882         729 :         spaceTypeCondArea(iSpaceType) = 0.0;
   11883         729 :         spaceTypeUncondArea(iSpaceType) = 0.0;
   11884         729 :         spaceTypeNotTotArea(iSpaceType) = 0.0;
   11885         729 :         spaceTypeTotLighting(iSpaceType) = 0.0;
   11886         729 :         spaceTypeTotPeople(iSpaceType) = 0.0;
   11887         729 :         spaceTypeTotPlugProcess(iSpaceType) = 0.0;
   11888             :     }
   11889             : 
   11890             :     // Accumulate internal gain totals by space and space type
   11891        4708 :     for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   11892        3964 :         auto const &curPeople = state.dataHeatBal->People(iPeople);
   11893        3964 :         int const spaceNum = curPeople.spaceIndex;
   11894        3964 :         Real64 const people = curPeople.NumberOfPeople;
   11895        3964 :         spaceTotPeople(spaceNum) += people;
   11896        3964 :         spaceTypeTotPeople(state.dataHeatBal->space(spaceNum).spaceTypeNum) += people;
   11897             :     }
   11898        4929 :     for (int iLights = 1; iLights <= state.dataHeatBal->TotLights; ++iLights) {
   11899        4185 :         auto const &curLighting = state.dataHeatBal->Lights(iLights);
   11900        4185 :         int const spaceNum = curLighting.spaceIndex;
   11901        4185 :         Real64 const lighting = curLighting.DesignLevel;
   11902        4185 :         spaceTotLighting(spaceNum) += lighting;
   11903        4185 :         spaceTypeTotLighting(state.dataHeatBal->space(spaceNum).spaceTypeNum) += lighting;
   11904             :     }
   11905        5005 :     for (int iElecEquip = 1; iElecEquip <= state.dataHeatBal->TotElecEquip; ++iElecEquip) {
   11906        4261 :         auto const &curElecEquip = state.dataHeatBal->ZoneElectric(iElecEquip);
   11907        4261 :         int const spaceNum = curElecEquip.spaceIndex;
   11908        4261 :         Real64 const elecEquip = curElecEquip.DesignLevel;
   11909        4261 :         spaceTotPlugProcess(spaceNum) += elecEquip;
   11910        4261 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += elecEquip;
   11911             :     }
   11912         821 :     for (int iGasEquip = 1; iGasEquip <= state.dataHeatBal->TotGasEquip; ++iGasEquip) {
   11913          77 :         auto const &curGasEquip = state.dataHeatBal->ZoneGas(iGasEquip);
   11914          77 :         int const spaceNum = curGasEquip.spaceIndex;
   11915          77 :         Real64 const gasEquip = curGasEquip.DesignLevel;
   11916          77 :         spaceTotPlugProcess(spaceNum) += gasEquip;
   11917          77 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += gasEquip;
   11918             :     }
   11919         801 :     for (int iOthEquip = 1; iOthEquip <= state.dataHeatBal->TotOthEquip; ++iOthEquip) {
   11920          57 :         auto const &curOthEquip = state.dataHeatBal->ZoneOtherEq(iOthEquip);
   11921          57 :         int const spaceNum = curOthEquip.spaceIndex;
   11922          57 :         Real64 const othEquip = curOthEquip.DesignLevel;
   11923          57 :         spaceTotPlugProcess(spaceNum) += othEquip;
   11924          57 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += othEquip;
   11925             :     }
   11926         758 :     for (int iHWEquip = 1; iHWEquip <= state.dataHeatBal->TotHWEquip; ++iHWEquip) {
   11927          14 :         auto const &curHWEquip = state.dataHeatBal->ZoneHWEq(iHWEquip);
   11928          14 :         int const spaceNum = curHWEquip.spaceIndex;
   11929          14 :         Real64 const hwEquip = curHWEquip.DesignLevel;
   11930          14 :         spaceTotPlugProcess(spaceNum) += hwEquip;
   11931          14 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += hwEquip;
   11932             :     }
   11933         749 :     for (int iSteamEquip = 1; iSteamEquip <= state.dataHeatBal->TotStmEquip; ++iSteamEquip) {
   11934           5 :         auto const &curSteamEquip = state.dataHeatBal->ZoneSteamEq(iSteamEquip);
   11935           5 :         int const spaceNum = curSteamEquip.spaceIndex;
   11936           5 :         Real64 const steamEquip = curSteamEquip.DesignLevel;
   11937           5 :         spaceTotPlugProcess(spaceNum) += steamEquip;
   11938           5 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += steamEquip;
   11939             :     }
   11940         751 :     for (int iITEquip = 1; iITEquip <= state.dataHeatBal->TotITEquip; ++iITEquip) {
   11941           7 :         auto const &curITEquip = state.dataHeatBal->ZoneITEq(iITEquip);
   11942           7 :         int const spaceNum = curITEquip.spaceIndex;
   11943           7 :         Real64 const itEquip = curITEquip.DesignTotalPower;
   11944           7 :         spaceTotPlugProcess(spaceNum) += itEquip;
   11945           7 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += itEquip;
   11946             :     }
   11947             : 
   11948             :     // re-use existing zone total variables
   11949        3720 :     for (int iTotal = 1; iTotal <= 4; ++iTotal) {
   11950        2976 :         state.dataOutRptTab->zstArea(iTotal) = 0.0;
   11951        2976 :         state.dataOutRptTab->zstLight(iTotal) = 0.0;
   11952        2976 :         state.dataOutRptTab->zstPlug(iTotal) = 0.0;
   11953        2976 :         state.dataOutRptTab->zstPeople(iTotal) = 0.0;
   11954             :     }
   11955             : 
   11956         744 :     int spaceTableRowNum = 0;
   11957        5604 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   11958        4860 :         auto const &curZone = state.dataHeatBal->Zone(iZone);
   11959        4860 :         Real64 const mult = Real64(curZone.Multiplier) * Real64(curZone.ListMultiplier);
   11960        9732 :         for (int const spaceNum : curZone.spaceIndexes) {
   11961        4872 :             auto &curSpace = state.dataHeatBal->space(spaceNum);
   11962        4872 :             bool spaceIsCond = false;
   11963        4872 :             bool useSpaceFloorArea = false;
   11964        4872 :             ++spaceTableRowNum;
   11965        4872 :             spaceRowHead(spaceTableRowNum) = curSpace.Name;
   11966        4872 :             spaceTableBody(colZoneName, spaceTableRowNum) = curZone.Name;
   11967        4872 :             spaceTableBody(colSpaceType, spaceTableRowNum) = curSpace.spaceType;
   11968        4872 :             spaceTableBody(colEnclName, spaceTableRowNum) = state.dataViewFactor->EnclSolInfo(curSpace.solarEnclosureNum).Name;
   11969        4872 :             spaceTableBody(colSpaceArea, spaceTableRowNum) = RealToStr(curSpace.FloorArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11970             :             // Conditioned or not
   11971        4872 :             if (curZone.SystemZoneNodeNumber > 0) {
   11972        4466 :                 spaceTableBody(colConditioned, spaceTableRowNum) = "Yes";
   11973        4466 :                 spaceIsCond = true;
   11974             :             } else {
   11975         406 :                 spaceTableBody(colConditioned, spaceTableRowNum) = "No";
   11976         406 :                 spaceIsCond = false;
   11977             :             }
   11978             :             // Part of Total Floor Area or not
   11979        4872 :             if (curZone.isPartOfTotalArea) {
   11980        4736 :                 spaceTableBody(colPartOfTotal, spaceTableRowNum) = "Yes";
   11981        4736 :                 useSpaceFloorArea = true;
   11982             :             } else {
   11983         136 :                 spaceTableBody(colPartOfTotal, spaceTableRowNum) = "No";
   11984         136 :                 useSpaceFloorArea = false;
   11985             :             }
   11986             :             // lighting density
   11987        4872 :             spaceTableBody(colMultipliers, spaceTableRowNum) = RealToStr(mult, 2);
   11988        4872 :             if (curSpace.FloorArea > 0) {
   11989        4867 :                 spaceTableBody(colSpaceLighting, spaceTableRowNum) =
   11990        9734 :                     RealToStr(state.dataOutRptTab->Wm2_unitConv * spaceTotLighting(spaceNum) / curSpace.FloorArea, 4);
   11991             :             } else {
   11992           5 :                 spaceTableBody(colSpaceLighting, spaceTableRowNum) = RealToStr(0.0, 4);
   11993             :             }
   11994             :             // people density
   11995        4872 :             if (spaceTotPeople(spaceNum) > 0) {
   11996        3871 :                 spaceTableBody(colSpacePeople, spaceTableRowNum) =
   11997        7742 :                     RealToStr(curSpace.FloorArea * state.dataOutRptTab->m2_unitConvWVST / spaceTotPeople(spaceNum), 2);
   11998             :             } else {
   11999        1001 :                 spaceTableBody(colSpacePeople, spaceTableRowNum) = RealToStr(0.0, 2);
   12000             :             }
   12001             :             // plug and process density
   12002        4872 :             if (curSpace.FloorArea > 0) {
   12003        4867 :                 spaceTableBody(colSpacePlugProcess, spaceTableRowNum) =
   12004        9734 :                     RealToStr(spaceTotPlugProcess(spaceNum) * state.dataOutRptTab->Wm2_unitConv / curSpace.FloorArea, 4);
   12005             :             } else {
   12006           5 :                 spaceTableBody(colSpacePlugProcess, spaceTableRowNum) = RealToStr(0.0, 4);
   12007             :             }
   12008             : 
   12009        9744 :             spaceTableBody(colSpaceTags, spaceTableRowNum) = fmt::format("{}", fmt::join(curSpace.tags, ", "));
   12010             : 
   12011             :             // If not part of total, goes directly to this row
   12012        4872 :             if (!useSpaceFloorArea) {
   12013         136 :                 spaceTypeNotTotArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   12014         136 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->notpartTotal) += mult * curSpace.FloorArea;
   12015         136 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->notpartTotal) += mult * spaceTotLighting(spaceNum);
   12016         136 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->notpartTotal) += mult * spaceTotPeople(spaceNum);
   12017         136 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->notpartTotal) += mult * spaceTotPlugProcess(spaceNum);
   12018             :             } else {
   12019             :                 // Add it to the 'Total'
   12020        4736 :                 spaceTypeTotArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   12021        4736 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->grandTotal) += mult * curSpace.FloorArea;
   12022        4736 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->grandTotal) += mult * spaceTotLighting(spaceNum);
   12023        4736 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->grandTotal) += mult * spaceTotPeople(spaceNum);
   12024        4736 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->grandTotal) += mult * spaceTotPlugProcess(spaceNum);
   12025             : 
   12026             :                 // Subtotal between cond/unconditioned
   12027             :                 int condUncondTotalIndex;
   12028        4736 :                 if (spaceIsCond) {
   12029        4357 :                     spaceTypeCondArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   12030        4357 :                     condUncondTotalIndex = state.dataOutRptTab->condTotal;
   12031             : 
   12032             :                 } else {
   12033         379 :                     spaceTypeUncondArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   12034         379 :                     condUncondTotalIndex = state.dataOutRptTab->uncondTotal;
   12035             :                 }
   12036        4736 :                 state.dataOutRptTab->zstArea(condUncondTotalIndex) += mult * curSpace.FloorArea;
   12037        4736 :                 state.dataOutRptTab->zstLight(condUncondTotalIndex) += mult * spaceTotLighting(spaceNum);
   12038        4736 :                 state.dataOutRptTab->zstPeople(condUncondTotalIndex) += mult * spaceTotPeople(spaceNum);
   12039        4736 :                 state.dataOutRptTab->zstPlug(condUncondTotalIndex) += mult * spaceTotPlugProcess(spaceNum);
   12040             :             }
   12041        4860 :         }
   12042             :     }
   12043             :     // total rows for Total / Not Part of Total
   12044             :     // In "Total": break between conditioned/unconditioned
   12045        3720 :     for (int iTotal = 1; iTotal <= 4; ++iTotal) {
   12046        2976 :         spaceTableBody(colSpaceArea, state.dataGlobal->numSpaces + iTotal) =
   12047        5952 :             RealToStr(state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12048        2976 :         if (state.dataOutRptTab->zstArea(iTotal) != 0) {
   12049        1624 :             spaceTableBody(colSpaceLighting, state.dataGlobal->numSpaces + iTotal) =
   12050        3248 :                 RealToStr(state.dataOutRptTab->zstLight(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   12051        1624 :             spaceTableBody(colSpacePlugProcess, state.dataGlobal->numSpaces + iTotal) =
   12052        3248 :                 RealToStr(state.dataOutRptTab->zstPlug(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   12053             :         } else {
   12054        1352 :             spaceTableBody(colSpaceLighting, state.dataGlobal->numSpaces + iTotal) = RealToStr(0.0, 4);
   12055        1352 :             spaceTableBody(colSpacePlugProcess, state.dataGlobal->numSpaces + iTotal) = RealToStr(0.0, 4);
   12056             :         }
   12057        2976 :         if (state.dataOutRptTab->zstPeople(iTotal) != 0) {
   12058        1281 :             spaceTableBody(colSpacePeople, state.dataGlobal->numSpaces + iTotal) =
   12059        2562 :                 RealToStr(state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST / state.dataOutRptTab->zstPeople(iTotal), 2);
   12060             :         } else {
   12061        1695 :             spaceTableBody(colSpacePeople, state.dataGlobal->numSpaces + iTotal) = RealToStr(0.0, 2);
   12062             :         }
   12063             :     }
   12064             : 
   12065         744 :     Real64 totalArea = 0.0;
   12066         744 :     Real64 condArea = 0.0;
   12067         744 :     Real64 uncondArea = 0.0;
   12068         744 :     Real64 notTotalArea = 0.0;
   12069        1473 :     for (int iSpaceType = 1; iSpaceType <= state.dataGlobal->numSpaceTypes; ++iSpaceType) {
   12070         729 :         spaceTypeRowHead(iSpaceType) = state.dataHeatBal->spaceTypes(iSpaceType);
   12071         729 :         spaceTypeTableBody(colSpaceTypeTotArea, iSpaceType) = RealToStr(spaceTypeTotArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12072         729 :         spaceTypeTableBody(colSpaceTypeCondArea, iSpaceType) = RealToStr(spaceTypeCondArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12073         729 :         spaceTypeTableBody(colSpaceTypeUncondArea, iSpaceType) = RealToStr(spaceTypeUncondArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12074         729 :         spaceTypeTableBody(colSpaceTypeNotTotArea, iSpaceType) = RealToStr(spaceTypeNotTotArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12075         729 :         totalArea += spaceTypeTotArea(iSpaceType);
   12076         729 :         condArea += spaceTypeCondArea(iSpaceType);
   12077         729 :         uncondArea += spaceTypeUncondArea(iSpaceType);
   12078         729 :         notTotalArea += spaceTypeNotTotArea(iSpaceType);
   12079             :         // lighting density
   12080         729 :         if (spaceTypeTotArea(iSpaceType) > 0) {
   12081         724 :             spaceTypeTableBody(colSpaceTypeLighting, iSpaceType) =
   12082        1448 :                 RealToStr(state.dataOutRptTab->Wm2_unitConv * spaceTypeTotLighting(iSpaceType) / spaceTypeTotArea(iSpaceType), 4);
   12083             :         } else {
   12084           5 :             spaceTypeTableBody(colSpaceTypeLighting, iSpaceType) = RealToStr(0.0, 4);
   12085             :         }
   12086             :         // people density
   12087         729 :         if (spaceTypeTotPeople(iSpaceType) > 0) {
   12088         646 :             spaceTypeTableBody(colSpaceTypePeople, iSpaceType) =
   12089        1292 :                 RealToStr(spaceTypeTotArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST / spaceTypeTotPeople(iSpaceType), 2);
   12090             :         } else {
   12091          83 :             spaceTypeTableBody(colSpaceTypePeople, iSpaceType) = RealToStr(0.0, 2);
   12092             :         }
   12093             :         // plug and process density
   12094         729 :         if (spaceTypeTotArea(iSpaceType) > 0) {
   12095         724 :             spaceTypeTableBody(colSpaceTypePlugProcess, iSpaceType) =
   12096        1448 :                 RealToStr(spaceTypeTotPlugProcess(iSpaceType) * state.dataOutRptTab->Wm2_unitConv / spaceTypeTotArea(iSpaceType), 4);
   12097             :         } else {
   12098           5 :             spaceTypeTableBody(colSpaceTypePlugProcess, iSpaceType) = RealToStr(0.0, 4);
   12099             :         }
   12100             :     }
   12101             :     // Total Area
   12102         744 :     spaceTypeTableBody(colSpaceTypeTotArea, state.dataGlobal->numSpaceTypes + 1) = RealToStr(totalArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12103         744 :     spaceTypeTableBody(colSpaceTypeCondArea, state.dataGlobal->numSpaceTypes + 1) = RealToStr(condArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12104         744 :     spaceTypeTableBody(colSpaceTypeUncondArea, state.dataGlobal->numSpaceTypes + 1) = RealToStr(uncondArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12105         744 :     spaceTypeTableBody(colSpaceTypeNotTotArea, state.dataGlobal->numSpaceTypes + 1) =
   12106        1488 :         RealToStr(notTotalArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12107             : 
   12108         744 :     if (produceTabular) {
   12109         744 :         WriteSubtitle(state, "Space Summary");
   12110         744 :         WriteTable(state, spaceTableBody, spaceRowHead, spaceColumnHead, spaceColumnWidth);
   12111             : 
   12112         744 :         WriteSubtitle(state, "Space Type Summary");
   12113         744 :         WriteTable(state, spaceTypeTableBody, spaceTypeRowHead, spaceTypeColumnHead, spaceTypeColumnWidth);
   12114             : 
   12115         744 :         if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12116           7 :             state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12117             :                 spaceTableBody, spaceRowHead, spaceColumnHead, "InputVerificationandResultsSummary", "Entire Facility", "Space Summary");
   12118             : 
   12119           7 :             state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(spaceTypeTableBody,
   12120             :                                                                                                   spaceTypeRowHead,
   12121             :                                                                                                   spaceTypeColumnHead,
   12122             :                                                                                                   "InputVerificationandResultsSummary",
   12123             :                                                                                                   "Entire Facility",
   12124             :                                                                                                   "Space Type Summary");
   12125             :         }
   12126             :     }
   12127             : 
   12128         744 :     if (produceSQLite) {
   12129         744 :         if (state.dataSQLiteProcedures->sqlite) {
   12130         120 :             state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12131             :                 spaceTableBody, spaceRowHead, spaceColumnHead, "InputVerificationandResultsSummary", "Entire Facility", "Space Summary");
   12132             : 
   12133         120 :             state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(spaceTypeTableBody,
   12134             :                                                                                spaceTypeRowHead,
   12135             :                                                                                spaceTypeColumnHead,
   12136             :                                                                                "InputVerificationandResultsSummary",
   12137             :                                                                                "Entire Facility",
   12138             :                                                                                "Space Type Summary");
   12139             :         }
   12140             :     }
   12141         744 : }
   12142             : 
   12143         754 : void WriteAdaptiveComfortTable(EnergyPlusData &state)
   12144             : {
   12145             : 
   12146             :     // SUBROUTINE INFORMATION:
   12147             :     //       AUTHOR         Tyler Hoyt
   12148             :     //       DATE WRITTEN   August 2011
   12149             :     //       MODIFIED       na
   12150             :     //       RE-ENGINEERED  na
   12151             : 
   12152             :     // PURPOSE OF THIS SUBROUTINE:
   12153             :     // Writes summary table for adaptive comfort models. Tabulates
   12154             :     // occupied hours not meeting comfort bounds for ASHRAE-55 and
   12155             :     // CEN-15251 adaptive models.
   12156         754 :     auto &ort = state.dataOutRptTab;
   12157         754 :     if (!ort->displayAdaptiveComfort || state.dataHeatBal->TotPeople <= 0) {
   12158         185 :         return;
   12159             :     }
   12160             : 
   12161         569 :     Array1D_int peopleInd; // Index the relevant people
   12162         569 :     peopleInd.allocate(state.dataHeatBal->TotPeople);
   12163             : 
   12164             :     // Should deallocate after writing table. - LKL
   12165             : 
   12166        3460 :     for (int i = 1; i <= state.dataHeatBal->TotPeople; ++i) {
   12167        2891 :         if (state.dataHeatBal->People(i).AdaptiveASH55 || state.dataHeatBal->People(i).AdaptiveCEN15251) {
   12168           6 :             ++ort->numPeopleAdaptive;
   12169           6 :             peopleInd(ort->numPeopleAdaptive) = i;
   12170             :         }
   12171             :     }
   12172             : 
   12173         569 :     Array1D_string rowHead;
   12174         569 :     Array2D_string tableBody;
   12175         569 :     rowHead.allocate(ort->numPeopleAdaptive);
   12176         569 :     tableBody.allocate(5, ort->numPeopleAdaptive);
   12177             : 
   12178         569 :     WriteReportHeaders(state, "Adaptive Comfort Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   12179         569 :     WriteSubtitle(state, "Time Not Meeting the Adaptive Comfort Models during Occupied Hours");
   12180             : 
   12181         569 :     Array1D_int columnWidth;
   12182         569 :     columnWidth.allocate(5);
   12183         569 :     columnWidth = 10;
   12184             : 
   12185         569 :     Array1D_string columnHead(5);
   12186         569 :     columnHead(1) = "ASHRAE55 90% Acceptability Limits [Hours]";
   12187         569 :     columnHead(2) = "ASHRAE55 80% Acceptability Limits  [Hours]";
   12188         569 :     columnHead(3) = "CEN15251 Category I Acceptability Limits [Hours]";
   12189         569 :     columnHead(4) = "CEN15251 Category II Acceptability Limits [Hours]";
   12190         569 :     columnHead(5) = "CEN15251 Category III Acceptability Limits [Hours]";
   12191             : 
   12192         569 :     tableBody = "";
   12193         575 :     for (int i = 1; i <= ort->numPeopleAdaptive; ++i) {
   12194           6 :         rowHead(i) = state.dataHeatBal->People(i).Name;
   12195           6 :         if (state.dataHeatBal->People(i).AdaptiveASH55) {
   12196           6 :             tableBody(1, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetASH5590, 2);
   12197           6 :             tableBody(2, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetASH5580, 2);
   12198             :         }
   12199           6 :         if (state.dataHeatBal->People(i).AdaptiveCEN15251) {
   12200           1 :             tableBody(3, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetCEN15251CatI, 2);
   12201           1 :             tableBody(4, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetCEN15251CatII, 2);
   12202           1 :             tableBody(5, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetCEN15251CatIII, 2);
   12203             :         }
   12204             :     }
   12205             : 
   12206         569 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12207         569 :     if (state.dataSQLiteProcedures->sqlite) {
   12208          54 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   12209             :                                                                            rowHead,
   12210             :                                                                            columnHead,
   12211             :                                                                            "AdaptiveComfortSummary",
   12212             :                                                                            "Entire Facility",
   12213             :                                                                            "Time Not Meeting the Adaptive Comfort Models during Occupied Hours");
   12214             :     }
   12215         569 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12216           6 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12217             :             tableBody,
   12218             :             rowHead,
   12219             :             columnHead,
   12220             :             "AdaptiveComfortSummary",
   12221             :             "Entire Facility",
   12222             :             "Time Not Meeting the Adaptive Comfort Models during Occupied Hours");
   12223             :     }
   12224         569 : }
   12225             : 
   12226          38 : std::string formatReportPeriodTimestamp(const int year, const int month, const int day, const int hour)
   12227             : {
   12228          38 :     if (year != 0) {
   12229           0 :         return fmt::format("{}/{}/{} {}:00", year, month, day, hour);
   12230             :     } else {
   12231          38 :         return fmt::format("{}/{} {}:00", month, day, hour);
   12232             :     }
   12233             : }
   12234             : 
   12235           8 : void WriteReportHeaderReportingPeriod(EnergyPlusData &state,
   12236             :                                       const std::string &reportKeyWord,
   12237             :                                       const int periodIdx,
   12238             :                                       const Array1D<Weather::ReportPeriodData> &ReportPeriodInputData)
   12239             : {
   12240          16 :     WriteReportHeaders(
   12241             :         state,
   12242          16 :         fmt::format("{} Resilience Summary for Reporting Period {}: {}", reportKeyWord, periodIdx, ReportPeriodInputData(periodIdx).title),
   12243             :         "Entire Facility",
   12244             :         OutputProcessor::StoreType::Average);
   12245             : 
   12246           8 :     WriteSubtitle(state,
   12247          16 :                   format("Reporting period: {} -- {}, Total Electricity Usage: {:.2R} kWh",
   12248          16 :                          formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).startYear,
   12249           8 :                                                      ReportPeriodInputData(periodIdx).startMonth,
   12250           8 :                                                      ReportPeriodInputData(periodIdx).startDay,
   12251           8 :                                                      ReportPeriodInputData(periodIdx).startHour),
   12252          16 :                          formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).endYear,
   12253           8 :                                                      ReportPeriodInputData(periodIdx).endMonth,
   12254           8 :                                                      ReportPeriodInputData(periodIdx).endDay,
   12255           8 :                                                      ReportPeriodInputData(periodIdx).endHour),
   12256           8 :                          ReportPeriodInputData(periodIdx).totalElectricityUse / 3600000.0));
   12257           8 : }
   12258             : 
   12259           4 : void WriteReportPeriodTimeConsumption(EnergyPlusData &state)
   12260             : {
   12261             :     // Reporting Period Time and Consumption Table
   12262             :     // It has the following columns: report type (thermal, co2, visual), period, start, end, total electricity
   12263           4 :     Array1D_string columnHead;
   12264           4 :     Array1D_int columnWidth;
   12265           4 :     Array1D_string rowHead;
   12266           4 :     Array2D_string tableBody;
   12267           4 :     int numRowsReportPeriod = state.dataWeather->TotThermalReportPers + state.dataWeather->TotCO2ReportPers + state.dataWeather->TotVisualReportPers;
   12268           4 :     rowHead.allocate(numRowsReportPeriod);
   12269           4 :     columnHead.allocate(6);
   12270           4 :     columnWidth.allocate(6);
   12271           4 :     columnWidth = 14; // array assignment - same for all columns
   12272           4 :     tableBody.allocate(6, numRowsReportPeriod);
   12273             : 
   12274           4 :     int constexpr reportperiodType(1);
   12275           4 :     int constexpr reportperiodId(2);
   12276           4 :     int constexpr reportperiodTitle(3);
   12277           4 :     int constexpr reportperiodStart(4);
   12278           4 :     int constexpr reportperiodEnd(5);
   12279           4 :     int constexpr reportperiodElectricity(6);
   12280             : 
   12281           4 :     WriteReportHeaders(state, "Reporting Period Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   12282             : 
   12283           4 :     columnHead(reportperiodType) = "Report Type";
   12284           4 :     columnHead(reportperiodId) = "Report Index";
   12285           4 :     columnHead(reportperiodTitle) = "Title";
   12286           4 :     columnHead(reportperiodStart) = "Start Time";
   12287           4 :     columnHead(reportperiodEnd) = "End Time";
   12288           4 :     columnHead(reportperiodElectricity) = "Total Electricity (kWh)";
   12289          15 :     for (int i = 1; i <= numRowsReportPeriod; i++) {
   12290          11 :         rowHead(i) = std::to_string(i);
   12291             :     }
   12292             :     // loop through rows
   12293           4 :     int rowid = 1;
   12294           9 :     for (int periodIdx = 1; periodIdx <= state.dataWeather->TotThermalReportPers; periodIdx++) {
   12295           5 :         writeRowReportPeriodInputVeri("Thermal", tableBody, rowid, periodIdx, state.dataWeather->ThermalReportPeriodInput);
   12296           5 :         rowid += 1;
   12297             :     }
   12298           7 :     for (int periodIdx = 1; periodIdx <= state.dataWeather->TotCO2ReportPers; periodIdx++) {
   12299           3 :         writeRowReportPeriodInputVeri("CO2", tableBody, rowid, periodIdx, state.dataWeather->CO2ReportPeriodInput);
   12300           3 :         rowid += 1;
   12301             :     }
   12302           7 :     for (int periodIdx = 1; periodIdx <= state.dataWeather->TotVisualReportPers; periodIdx++) {
   12303           3 :         writeRowReportPeriodInputVeri("Visual", tableBody, rowid, periodIdx, state.dataWeather->VisualReportPeriodInput);
   12304           3 :         rowid += 1;
   12305             :     }
   12306             : 
   12307           4 :     std::string tableName = "Reporting Period Time and Consumption";
   12308           4 :     WriteSubtitle(state, tableName);
   12309           4 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12310           4 :     if (state.dataSQLiteProcedures->sqlite) {
   12311           0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12312             :             tableBody, rowHead, columnHead, "ReportingPeriodSummary", "Entire Facility", tableName);
   12313             :     }
   12314           4 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12315           0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12316             :             tableBody, rowHead, columnHead, "Reporting Period Summary", "Entire Facility", tableName);
   12317             :     }
   12318           4 : }
   12319             : 
   12320           5 : void WriteThermalResilienceTablesRepPeriod(EnergyPlusData &state, int const periodIdx)
   12321             : {
   12322             : 
   12323           5 :     auto const &ort = state.dataOutRptTab;
   12324           5 :     if (!ort->WriteTabularFiles) {
   12325           0 :         return;
   12326             :     }
   12327             : 
   12328             :     Real64 degreeHourConversion;
   12329           5 :     UnitsStyle unitsStyle_cur = ort->unitsStyle;
   12330             : 
   12331           5 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12332             :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12333           0 :         degreeHourConversion = getSpecificUnitMultiplier(state, "°C·hr", "°F·hr");
   12334             :     } else {
   12335           5 :         degreeHourConversion = 1.0;
   12336             :     }
   12337             : 
   12338           5 :     std::string tableType = "Thermal";
   12339           5 :     WriteReportHeaderReportingPeriod(state, tableType, periodIdx, state.dataWeather->ThermalReportPeriodInput);
   12340           5 :     std::string periodTitle = state.dataWeather->ThermalReportPeriodInput(periodIdx).title;
   12341             : 
   12342           5 :     int columnNum = 5;
   12343           5 :     Array1D_int columnWidth;
   12344           5 :     columnWidth.allocate(columnNum);
   12345           5 :     columnWidth = 10;
   12346           5 :     Array1D_string columnHead(5);
   12347           5 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12348             :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12349           0 :         columnHead(1) = "Safe (≤ 80.1°F) [hr]";
   12350           0 :         columnHead(2) = "Caution (> 80.1°F, ≤ 90.0°F) [hr]";
   12351           0 :         columnHead(3) = "Extreme Caution (> 90.0°F, ≤ 102.9°F) [hr]";
   12352           0 :         columnHead(4) = "Danger (> 102.9, ≤ 125.1°F) [hr]";
   12353           0 :         columnHead(5) = "Extreme Danger (> 125.1°F) [hr]";
   12354             :     } else {
   12355           5 :         columnHead(1) = "Safe (≤ 26.7°C) [hr]";
   12356           5 :         columnHead(2) = "Caution (> 26.7°C, ≤ 32.2°C) [hr]";
   12357           5 :         columnHead(3) = "Extreme Caution (> 32.2°C, ≤ 39.4°C) [hr]";
   12358           5 :         columnHead(4) = "Danger (> 39.4°C, ≤ 51.7°C) [hr]";
   12359           5 :         columnHead(5) = "Extreme Danger (> 51.7°C) [hr]";
   12360             :     }
   12361             : 
   12362           5 :     Array1D_string rowHead;
   12363           5 :     Array2D_string tableBody;
   12364           5 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   12365           5 :     tableBody.allocate(columnNum, state.dataGlobal->NumOfZones + 4);
   12366             : 
   12367           5 :     std::string tableName = "Heat Index Hours";
   12368           5 :     WriteResilienceBinsTableReportingPeriod(state,
   12369             :                                             tableType,
   12370             :                                             columnNum,
   12371             :                                             periodIdx,
   12372             :                                             periodTitle,
   12373             :                                             tableName,
   12374             :                                             columnHead,
   12375             :                                             columnWidth,
   12376           5 :                                             state.dataHeatBalFanSys->ZoneHeatIndexHourBinsRepPeriod,
   12377             :                                             rowHead,
   12378             :                                             tableBody);
   12379             : 
   12380           5 :     tableName = "Heat Index OccupantHours";
   12381           5 :     WriteResilienceBinsTableReportingPeriod(state,
   12382             :                                             tableType,
   12383             :                                             columnNum,
   12384             :                                             periodIdx,
   12385             :                                             periodTitle,
   12386             :                                             tableName,
   12387             :                                             columnHead,
   12388             :                                             columnWidth,
   12389           5 :                                             state.dataHeatBalFanSys->ZoneHeatIndexOccuHourBinsRepPeriod,
   12390             :                                             rowHead,
   12391             :                                             tableBody);
   12392             : 
   12393           5 :     tableName = "Heat Index OccupiedHours";
   12394           5 :     WriteResilienceBinsTableReportingPeriod(state,
   12395             :                                             tableType,
   12396             :                                             columnNum,
   12397             :                                             periodIdx,
   12398             :                                             periodTitle,
   12399             :                                             tableName,
   12400             :                                             columnHead,
   12401             :                                             columnWidth,
   12402           5 :                                             state.dataHeatBalFanSys->ZoneHeatIndexOccupiedHourBinsRepPeriod,
   12403             :                                             rowHead,
   12404             :                                             tableBody);
   12405             : 
   12406           5 :     columnHead(1) = "Little to no Discomfort (≤ 29) [hr]";
   12407           5 :     columnHead(2) = "Some Discomfort (> 29, ≤ 40) [hr]";
   12408           5 :     columnHead(3) = "Great Discomfort; Avoid Exertion (> 40, ≤ 45) [hr]";
   12409           5 :     columnHead(4) = "Dangerous (> 45, ≤ 50) [hr]";
   12410           5 :     columnHead(5) = "Heat Stroke Quite Possible (> 50) [hr]";
   12411           5 :     tableName = "Humidex Hours";
   12412           5 :     WriteResilienceBinsTableReportingPeriod(state,
   12413             :                                             tableType,
   12414             :                                             columnNum,
   12415             :                                             periodIdx,
   12416             :                                             periodTitle,
   12417             :                                             tableName,
   12418             :                                             columnHead,
   12419             :                                             columnWidth,
   12420           5 :                                             state.dataHeatBalFanSys->ZoneHumidexHourBinsRepPeriod,
   12421             :                                             rowHead,
   12422             :                                             tableBody);
   12423             : 
   12424           5 :     tableName = "Humidex OccupantHours";
   12425           5 :     WriteResilienceBinsTableReportingPeriod(state,
   12426             :                                             tableType,
   12427             :                                             columnNum,
   12428             :                                             periodIdx,
   12429             :                                             periodTitle,
   12430             :                                             tableName,
   12431             :                                             columnHead,
   12432             :                                             columnWidth,
   12433           5 :                                             state.dataHeatBalFanSys->ZoneHumidexOccuHourBinsRepPeriod,
   12434             :                                             rowHead,
   12435             :                                             tableBody);
   12436             : 
   12437           5 :     tableName = "Humidex OccupiedHours";
   12438           5 :     WriteResilienceBinsTableReportingPeriod(state,
   12439             :                                             tableType,
   12440             :                                             columnNum,
   12441             :                                             periodIdx,
   12442             :                                             periodTitle,
   12443             :                                             tableName,
   12444             :                                             columnHead,
   12445             :                                             columnWidth,
   12446           5 :                                             state.dataHeatBalFanSys->ZoneHumidexOccupiedHourBinsRepPeriod,
   12447             :                                             rowHead,
   12448             :                                             tableBody);
   12449             : 
   12450           5 :     bool hasPierceSET = true;
   12451           5 :     if (state.dataHeatBal->TotPeople == 0) {
   12452           0 :         hasPierceSET = false;
   12453           0 :         if (ort->displayThermalResilienceSummaryExplicitly) {
   12454           0 :             ShowWarningError(state,
   12455             :                              "Writing Reporting Period Thermal Resilience Summary - SET Degree-Hours reports: "
   12456             :                              "Zone Thermal Comfort Pierce Model Standard Effective Temperature is required, "
   12457             :                              "but no People object is defined.");
   12458             :         }
   12459             :     }
   12460          13 :     for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   12461           8 :         if (!state.dataHeatBal->People(iPeople).Pierce) {
   12462           0 :             hasPierceSET = false;
   12463           0 :             if (ort->displayThermalResilienceSummaryExplicitly) {
   12464           0 :                 ShowWarningError(state,
   12465           0 :                                  format("Writing Reporting Period Thermal Resilience Summary - SET Degree-Hours reports: Zone Thermal Comfort "
   12466             :                                         "Pierce Model Standard Effective Temperature is required, but no Pierce model is defined in {} object.",
   12467           0 :                                         state.dataHeatBal->People(iPeople).Name));
   12468             :             }
   12469             :         }
   12470             :     }
   12471             : 
   12472           5 :     if (hasPierceSET) {
   12473           5 :         columnHead(1) = "SET ≤ 12.2°C Degree-Hours [°C·hr]";
   12474           5 :         columnHead(2) = "SET ≤ 12.2°C Occupant-Weighted Degree-Hours [°C·hr]";
   12475           5 :         columnHead(3) = "SET ≤ 12.2°C Occupied Degree-Hours [°C·hr]";
   12476           5 :         columnHead(4) = "Longest SET ≤ 12.2°C Duration for Occupied Period [hr]";
   12477           5 :         columnHead(5) = "Start Time of the Longest SET ≤ 12.2°C Duration for Occupied Period ";
   12478             : 
   12479           5 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12480             :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12481           0 :             columnHead(1) = "SET ≤ 54.0°F Degree-Hours [°F·hr]";
   12482           0 :             columnHead(2) = "SET ≤ 54.0°F Occupant-Weighted Degree-Hours [°F·hr]";
   12483           0 :             columnHead(3) = "SET ≤ 54.0°F Occupied Degree-Hours [°F·hr]";
   12484           0 :             columnHead(4) = "Longest SET ≤ 54.0°F Duration for Occupied Period [hr]";
   12485           0 :             columnHead(5) = "Start Time of the Longest SET ≤ 54.0°F Duration for Occupied Period ";
   12486             :         } else {
   12487           5 :             columnHead(1) = "SET ≤ 12.2°C Degree-Hours [°C·hr]";
   12488           5 :             columnHead(2) = "SET ≤ 12.2°C Occupant-Weighted Degree-Hours [°C·hr]";
   12489           5 :             columnHead(3) = "SET ≤ 12.2°C Occupied Degree-Hours [°C·hr]";
   12490           5 :             columnHead(4) = "Longest SET ≤ 12.2°C Duration for Occupied Period [hr]";
   12491           5 :             columnHead(5) = "Start Time of the Longest SET ≤ 12.2°C Duration for Occupied Period ";
   12492             :         }
   12493             : 
   12494           5 :         tableName = "Heating SET Degree-Hours";
   12495           5 :         Array1D_string rowHeadSET;
   12496           5 :         Array2D_string tableBodySET;
   12497           5 :         rowHeadSET.allocate(state.dataGlobal->NumOfZones + 3);
   12498           5 :         tableBodySET.allocate(columnNum, state.dataGlobal->NumOfZones + 3);
   12499           5 :         WriteSETHoursTableReportingPeriod(state,
   12500             :                                           columnNum,
   12501             :                                           periodIdx,
   12502             :                                           periodTitle,
   12503             :                                           tableName,
   12504             :                                           columnHead,
   12505             :                                           columnWidth,
   12506           5 :                                           state.dataHeatBalFanSys->ZoneLowSETHoursRepPeriod,
   12507             :                                           rowHeadSET,
   12508             :                                           tableBodySET,
   12509             :                                           degreeHourConversion);
   12510             : 
   12511           5 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12512             :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12513           0 :             columnHead(1) = "SET > 86°F Degree-Hours [°F·hr]";
   12514           0 :             columnHead(2) = "SET > 86°F Occupant-Weighted Degree-Hours [°F·hr]";
   12515           0 :             columnHead(3) = "SET > 86°F Occupied Degree-Hours [°F·hr]";
   12516           0 :             columnHead(4) = "Longest SET > 86°F Duration for Occupied Period [hr]";
   12517           0 :             columnHead(5) = "Start Time of the Longest SET > 86°F Duration for Occupied Period";
   12518             :         } else {
   12519           5 :             columnHead(1) = "SET > 30°C Degree-Hours [°C·hr]";
   12520           5 :             columnHead(2) = "SET > 30°C Occupant-Weighted Degree-Hours [°C·hr]";
   12521           5 :             columnHead(3) = "SET > 30°C Occupied Degree-Hours [°C·hr]";
   12522           5 :             columnHead(4) = "Longest SET > 30°C Duration for Occupied Period [hr]";
   12523           5 :             columnHead(5) = "Start Time of the Longest SET > 30°C Duration for Occupied Period";
   12524             :         }
   12525             : 
   12526           5 :         tableName = "Cooling SET Degree-Hours";
   12527           5 :         WriteSETHoursTableReportingPeriod(state,
   12528             :                                           columnNum,
   12529             :                                           periodIdx,
   12530             :                                           periodTitle,
   12531             :                                           tableName,
   12532             :                                           columnHead,
   12533             :                                           columnWidth,
   12534           5 :                                           state.dataHeatBalFanSys->ZoneHighSETHoursRepPeriod,
   12535             :                                           rowHeadSET,
   12536             :                                           tableBodySET,
   12537             :                                           degreeHourConversion);
   12538           5 :     }
   12539             : 
   12540           5 :     columnHead(1) = "Hours of Safety [hr]";
   12541           5 :     columnHead(2) = "End Time of the Safety Duration";
   12542           5 :     columnHead(3) = "Safe Temperature Exceedance Hours [hr]";
   12543           5 :     columnHead(4) = "Safe Temperature Exceedance OccupantHours [hr]";
   12544           5 :     columnHead(5) = "Safe Temperature Exceedance OccupiedHours [hr]";
   12545           5 :     tableName = "Hours of Safety for Cold Events";
   12546           5 :     WriteHourOfSafetyTableReportingPeriod(state,
   12547             :                                           columnNum,
   12548             :                                           periodIdx,
   12549             :                                           periodTitle,
   12550             :                                           tableName,
   12551             :                                           columnHead,
   12552             :                                           columnWidth,
   12553           5 :                                           state.dataHeatBalFanSys->ZoneColdHourOfSafetyBinsRepPeriod,
   12554             :                                           rowHead,
   12555             :                                           tableBody,
   12556             :                                           2);
   12557             : 
   12558           5 :     tableName = "Hours of Safety for Heat Events";
   12559           5 :     WriteHourOfSafetyTableReportingPeriod(state,
   12560             :                                           columnNum,
   12561             :                                           periodIdx,
   12562             :                                           periodTitle,
   12563             :                                           tableName,
   12564             :                                           columnHead,
   12565             :                                           columnWidth,
   12566           5 :                                           state.dataHeatBalFanSys->ZoneHeatHourOfSafetyBinsRepPeriod,
   12567             :                                           rowHead,
   12568             :                                           tableBody,
   12569             :                                           2);
   12570             : 
   12571           5 :     int columnNumUnmetDegHr = 6;
   12572           5 :     Array1D_string columnHeadUnmetDegHr(6);
   12573             :     // must initialize this otherwise it will only output 5 columns
   12574           5 :     Array1D_int columnWidthUnmetDegHr;
   12575           5 :     columnWidthUnmetDegHr.allocate(columnNumUnmetDegHr);
   12576           5 :     columnWidthUnmetDegHr = 10;
   12577           5 :     columnHeadUnmetDegHr(1) = "Cooling Setpoint Unmet Degree-Hours [°C·hr]";
   12578           5 :     columnHeadUnmetDegHr(2) = "Cooling Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   12579           5 :     columnHeadUnmetDegHr(3) = "Cooling Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   12580           5 :     columnHeadUnmetDegHr(4) = "Heating Setpoint Unmet Degree-Hours [°C·hr]";
   12581           5 :     columnHeadUnmetDegHr(5) = "Heating Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   12582           5 :     columnHeadUnmetDegHr(6) = "Heating Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   12583           5 :     tableName = "Unmet Degree-Hours";
   12584             : 
   12585           5 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12586             :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12587             :         int indexUnitConv;
   12588           0 :         std::string curUnits;
   12589           0 :         for (int i = 1; i < columnNumUnmetDegHr; i++) {
   12590           0 :             LookupSItoIP(state, columnHeadUnmetDegHr(i), indexUnitConv, curUnits);
   12591           0 :             columnHeadUnmetDegHr(i) = curUnits;
   12592             :         }
   12593           0 :     }
   12594             : 
   12595           5 :     Array2D_string tableBodyUnmetDegHr;
   12596           5 :     tableBodyUnmetDegHr.allocate(columnNumUnmetDegHr, state.dataGlobal->NumOfZones + 4);
   12597           5 :     WriteResilienceBinsTableReportingPeriod(state,
   12598             :                                             tableType,
   12599             :                                             columnNumUnmetDegHr,
   12600             :                                             periodIdx,
   12601             :                                             periodTitle,
   12602             :                                             tableName,
   12603             :                                             columnHeadUnmetDegHr,
   12604             :                                             columnWidthUnmetDegHr,
   12605           5 :                                             state.dataHeatBalFanSys->ZoneUnmetDegreeHourBinsRepPeriod,
   12606             :                                             rowHead,
   12607             :                                             tableBodyUnmetDegHr,
   12608             :                                             degreeHourConversion);
   12609             : 
   12610           5 :     int columnNumDiscomfortWt = 4;
   12611           5 :     Array1D_string columnHeadDiscomfortWt(columnNumDiscomfortWt);
   12612           5 :     columnHeadDiscomfortWt(1) = "Very-cold Exceedance OccupiedHours [hr]";
   12613           5 :     columnHeadDiscomfortWt(2) = "Cool Exceedance OccupiedHours [hr]";
   12614           5 :     columnHeadDiscomfortWt(3) = "Warm Exceedance OccupiedHours [hr]";
   12615           5 :     columnHeadDiscomfortWt(4) = "Very-hot Exceedance OccupiedHours [hr]";
   12616           5 :     tableName = "Discomfort-weighted Exceedance OccupantHours";
   12617           5 :     Array1D_int columnWidthDiscomfortWt;
   12618           5 :     columnWidthDiscomfortWt.allocate(columnNumDiscomfortWt);
   12619           5 :     columnWidth = 10;
   12620           5 :     Array2D_string tableBodyDiscomfortWt;
   12621           5 :     tableBodyDiscomfortWt.allocate(columnNumDiscomfortWt, state.dataGlobal->NumOfZones + 4);
   12622           5 :     WriteResilienceBinsTableReportingPeriod(state,
   12623             :                                             tableType,
   12624             :                                             columnNumDiscomfortWt,
   12625             :                                             periodIdx,
   12626             :                                             periodTitle,
   12627             :                                             tableName,
   12628             :                                             columnHeadDiscomfortWt,
   12629             :                                             columnWidthDiscomfortWt,
   12630           5 :                                             state.dataHeatBalFanSys->ZoneDiscomfortWtExceedOccuHourBinsRepPeriod,
   12631             :                                             rowHead,
   12632             :                                             tableBodyDiscomfortWt);
   12633           5 :     tableName = "Discomfort-weighted Exceedance OccupiedHours";
   12634           5 :     WriteResilienceBinsTableReportingPeriod(state,
   12635             :                                             tableType,
   12636             :                                             columnNumDiscomfortWt,
   12637             :                                             periodIdx,
   12638             :                                             periodTitle,
   12639             :                                             tableName,
   12640             :                                             columnHeadDiscomfortWt,
   12641             :                                             columnWidthDiscomfortWt,
   12642           5 :                                             state.dataHeatBalFanSys->ZoneDiscomfortWtExceedOccupiedHourBinsRepPeriod,
   12643             :                                             rowHead,
   12644             :                                             tableBodyDiscomfortWt);
   12645           5 :     columnHead.deallocate();
   12646           5 :     columnWidth.deallocate();
   12647           5 :     tableBody.deallocate();
   12648           5 :     columnHeadUnmetDegHr.deallocate();
   12649           5 :     columnWidthUnmetDegHr.deallocate();
   12650           5 :     tableBodyUnmetDegHr.deallocate();
   12651           5 :     columnHeadDiscomfortWt.deallocate();
   12652           5 :     columnWidthDiscomfortWt.deallocate();
   12653           5 :     tableBodyDiscomfortWt.deallocate();
   12654           5 : }
   12655             : 
   12656             : template <int columnNum>
   12657         210 : void WriteResilienceBinsTable(EnergyPlusData &state,
   12658             :                               std::array<int, columnNum> const &columnHead,
   12659             :                               const std::array<Real64, columnNum> DataHeatBalance::ZoneResilience::*memberPtr,
   12660             :                               Real64 const unitConvMultiplier)
   12661             : {
   12662         210 :     std::array<Real64, columnNum> columnMax = {0.0};
   12663         210 :     std::array<Real64, columnNum> columnMin = {0.0};
   12664         210 :     std::array<Real64, columnNum> columnSum = {0.0};
   12665        1005 :     for (int j = 0; j < columnNum; j++) {
   12666         795 :         columnMin[j] = (state.dataHeatBal->Resilience(1).*memberPtr)[j] * unitConvMultiplier;
   12667             :     }
   12668        2265 :     for (int i = 1; i <= state.dataGlobal->NumOfZones; ++i) {
   12669        2055 :         const std::string &ZoneName = state.dataHeatBal->Zone(i).Name;
   12670       10104 :         for (int j = 0; j < columnNum; j++) {
   12671        8049 :             Real64 curValue = (state.dataHeatBal->Resilience(i).*memberPtr)[j] * unitConvMultiplier;
   12672        8049 :             if (curValue > columnMax[j]) columnMax[j] = curValue;
   12673        8049 :             if (curValue < columnMin[j]) columnMin[j] = curValue;
   12674        8049 :             columnSum[j] += curValue;
   12675        8049 :             PreDefTableEntry(state, columnHead[j], ZoneName, RealToStr(curValue, 2));
   12676             :         }
   12677             :     }
   12678        1005 :     for (int j = 0; j < columnNum; j++) {
   12679         795 :         PreDefTableEntry(state, columnHead[j], "Min", RealToStr(columnMin[j], 2));
   12680         795 :         PreDefTableEntry(state, columnHead[j], "Max", RealToStr(columnMax[j], 2));
   12681         795 :         PreDefTableEntry(state, columnHead[j], "Average", RealToStr(columnSum[j] / state.dataGlobal->NumOfZones, 2));
   12682         795 :         PreDefTableEntry(state, columnHead[j], "Sum", RealToStr(columnSum[j], 2));
   12683             :     }
   12684         210 : }
   12685             : 
   12686             : template <int columnNum>
   12687        5832 : void WriteResilienceBinsTableNonPreDefUseZoneData(EnergyPlusData &state,
   12688             :                                                   const std::string &tableName,
   12689             :                                                   Array1D_string const &columnHead,
   12690             :                                                   Array1D_int &columnWidth,
   12691             :                                                   const std::array<Real64, columnNum> DataHeatBalance::ZoneResilience::*memberPtr,
   12692             :                                                   Array1D_string &rowHead,
   12693             :                                                   Array2D_string &tableBody,
   12694             :                                                   Real64 const unitConvMultiplier)
   12695             : {
   12696        5832 :     WriteSubtitle(state, tableName);
   12697             : 
   12698        5832 :     std::array<Real64, columnNum> columnMax = {0.0};
   12699        5832 :     std::array<Real64, columnNum> columnMin = {0.0};
   12700        5832 :     std::array<Real64, columnNum> columnSum = {0.0};
   12701             : 
   12702       34344 :     for (int j = 0; j < columnNum; j++) {
   12703       28512 :         columnMin.at(j) = (state.dataHeatBal->Resilience(1).*memberPtr).at(j) * unitConvMultiplier;
   12704             :     }
   12705       37692 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12706       31860 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12707       31860 :         rowHead(ZoneNum) = ZoneName;
   12708      187620 :         for (int j = 0; j < columnNum; j++) {
   12709      155760 :             Real64 curValue = (state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j) * unitConvMultiplier;
   12710      155760 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   12711      155760 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   12712      155760 :             columnSum.at(j) += curValue;
   12713      155760 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   12714             :         }
   12715             :     }
   12716             : 
   12717        5832 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12718        5832 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12719        5832 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12720        5832 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   12721             : 
   12722       34344 :     for (int j = 0; j < columnNum; j++) {
   12723       28512 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12724       28512 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12725       28512 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12726       28512 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   12727             :     }
   12728             : 
   12729        5832 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12730        5832 :     if (state.dataSQLiteProcedures->sqlite) {
   12731         567 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12732             :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12733             :     }
   12734        5832 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12735          54 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12736             :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12737             :     }
   12738        5832 : }
   12739             : 
   12740          54 : void WriteResilienceBinsTableReportingPeriod(EnergyPlusData &state,
   12741             :                                              const std::string &tableType,
   12742             :                                              int const columnNum,
   12743             :                                              int const periodIdx,
   12744             :                                              const std::string &periodTitle,
   12745             :                                              const std::string &tableName,
   12746             :                                              Array1D_string const &columnHead,
   12747             :                                              Array1D_int &columnWidth,
   12748             :                                              Array2D<std::vector<Real64>> const &ZoneBins,
   12749             :                                              Array1D_string &rowHead,
   12750             :                                              Array2D_string &tableBody,
   12751             :                                              Real64 const unitConvMultiplier)
   12752             : {
   12753          54 :     WriteSubtitle(state, tableName);
   12754             : 
   12755          54 :     std::vector<Real64> columnMax(columnNum, 0);
   12756          54 :     std::vector<Real64> columnMin(columnNum, 0);
   12757          54 :     std::vector<Real64> columnSum(columnNum, 0);
   12758             : 
   12759         310 :     for (int j = 0; j < columnNum; j++) {
   12760         256 :         columnMin.at(j) = ZoneBins(1, periodIdx).at(j) * unitConvMultiplier;
   12761             :     }
   12762         108 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12763          54 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12764          54 :         rowHead(ZoneNum) = ZoneName;
   12765         310 :         for (int j = 0; j < columnNum; j++) {
   12766         256 :             Real64 curValue = ZoneBins(ZoneNum, periodIdx).at(j) * unitConvMultiplier;
   12767         256 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   12768         256 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   12769         256 :             columnSum.at(j) += curValue;
   12770         256 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   12771             :         }
   12772             :     }
   12773             : 
   12774          54 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12775          54 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12776          54 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12777          54 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   12778             : 
   12779         310 :     for (int j = 0; j < columnNum; j++) {
   12780         256 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12781         256 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12782         256 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12783         256 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   12784             :     }
   12785             : 
   12786          54 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12787          54 :     if (state.dataSQLiteProcedures->sqlite) {
   12788           0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12789           0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-" + tableType + "ResilienceSummary", "Entire Facility", tableName);
   12790             :     }
   12791          54 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12792           0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12793           0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-" + tableType + "ResilienceSummary", "Entire Facility", tableName);
   12794             :     }
   12795          54 : }
   12796             : 
   12797          12 : void WriteSETHoursTableNonPreDefUseZoneData(EnergyPlusData &state,
   12798             :                                             int const columnNum,
   12799             :                                             const std::string &tableName,
   12800             :                                             Array1D_string const &columnHead,
   12801             :                                             Array1D_int &columnWidth,
   12802             :                                             const std::array<Real64, 5> DataHeatBalance::ZoneResilience::*memberPtr,
   12803             :                                             Array1D_string &rowHead,
   12804             :                                             Array2D_string &tableBody,
   12805             :                                             Real64 const unitConvMultiplier)
   12806             : {
   12807             : 
   12808          12 :     WriteSubtitle(state, tableName);
   12809             : 
   12810          12 :     std::vector<Real64> columnMax(columnNum - 1, 0);
   12811          12 :     std::vector<Real64> columnMin(columnNum - 1, 0);
   12812          12 :     std::vector<Real64> columnSum(columnNum - 1, 0);
   12813          12 :     std::vector<Real64> multiplier(columnNum - 1, unitConvMultiplier);
   12814          12 :     multiplier[columnNum - 2] = 1.0;
   12815             : 
   12816          60 :     for (int j = 0; j < columnNum - 1; j++) {
   12817          48 :         columnMin.at(j) = (state.dataHeatBal->Resilience(1).*memberPtr).at(j) * multiplier.at(j);
   12818             :     }
   12819          24 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12820          12 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12821          12 :         rowHead(ZoneNum) = ZoneName;
   12822          60 :         for (int j = 0; j < columnNum - 1; j++) {
   12823          48 :             Real64 curValue = (state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j) * multiplier.at(j);
   12824          48 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   12825          48 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   12826          48 :             columnSum.at(j) += curValue;
   12827          48 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   12828             :         }
   12829          12 :         tableBody(columnNum, ZoneNum) = DateToString((state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(columnNum - 1));
   12830             :     }
   12831             : 
   12832          12 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12833          12 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12834          12 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12835             : 
   12836          60 :     for (int j = 0; j < columnNum - 1; j++) {
   12837          48 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12838          48 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12839          48 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12840             :     }
   12841          12 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 1) = "-";
   12842          12 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 2) = "-";
   12843          12 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 3) = "-";
   12844             : 
   12845          12 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12846          12 :     if (state.dataSQLiteProcedures->sqlite) {
   12847           0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12848             :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12849             :     }
   12850          12 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12851           0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12852             :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12853             :     }
   12854          12 : }
   12855             : 
   12856          10 : void WriteSETHoursTableReportingPeriod(EnergyPlusData &state,
   12857             :                                        int const columnNum,
   12858             :                                        int const periodIdx,
   12859             :                                        const std::string &periodTitle,
   12860             :                                        const std::string &tableName,
   12861             :                                        Array1D_string const &columnHead,
   12862             :                                        Array1D_int &columnWidth,
   12863             :                                        Array2D<std::vector<Real64>> const &ZoneBins,
   12864             :                                        Array1D_string &rowHead,
   12865             :                                        Array2D_string &tableBody,
   12866             :                                        Real64 const unitConvMultiplier)
   12867             : {
   12868             : 
   12869          10 :     WriteSubtitle(state, tableName);
   12870             : 
   12871          10 :     std::vector<Real64> columnMax(columnNum - 1, 0);
   12872          10 :     std::vector<Real64> columnMin(columnNum - 1, 0);
   12873          10 :     std::vector<Real64> columnSum(columnNum - 1, 0);
   12874          10 :     std::vector<Real64> multiplier(columnNum - 1, unitConvMultiplier);
   12875          10 :     multiplier[columnNum - 2] = 1.0;
   12876             : 
   12877          50 :     for (int j = 0; j < columnNum - 1; j++) {
   12878          40 :         columnMin.at(j) = ZoneBins(1, periodIdx).at(j) * multiplier.at(j);
   12879             :     }
   12880          20 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12881          10 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12882          10 :         rowHead(ZoneNum) = ZoneName;
   12883          50 :         for (int j = 0; j < columnNum - 1; j++) {
   12884          40 :             Real64 curValue = ZoneBins(ZoneNum, periodIdx).at(j) * multiplier.at(j);
   12885          40 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   12886          40 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   12887          40 :             columnSum.at(j) += curValue;
   12888          40 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   12889             :         }
   12890          10 :         tableBody(columnNum, ZoneNum) = DateToString(ZoneBins(ZoneNum, periodIdx)[columnNum - 1]);
   12891             :     }
   12892             : 
   12893          10 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12894          10 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12895          10 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12896             : 
   12897          50 :     for (int j = 0; j < columnNum - 1; j++) {
   12898          40 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12899          40 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12900          40 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12901             :     }
   12902          10 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 1) = "-";
   12903          10 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 2) = "-";
   12904          10 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 3) = "-";
   12905             : 
   12906          10 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12907          10 :     if (state.dataSQLiteProcedures->sqlite) {
   12908           0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12909           0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   12910             :     }
   12911          10 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12912           0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12913           0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   12914             :     }
   12915          10 : }
   12916             : 
   12917           0 : std::string RetrieveEntryFromTableBody(Array2D_string &tableBody, int const rowIndex, int const columnIndex)
   12918             : {
   12919           0 :     return trimmed(ljustified(tableBody(columnIndex, rowIndex)));
   12920             : }
   12921             : 
   12922        1296 : void WriteHourOfSafetyTableNonPreDefUseZoneData(EnergyPlusData &state,
   12923             :                                                 int const columnNum,
   12924             :                                                 const std::string &tableName,
   12925             :                                                 Array1D_string const &columnHead,
   12926             :                                                 Array1D_int &columnWidth,
   12927             :                                                 const std::array<Real64, 5> DataHeatBalance::ZoneResilience::*memberPtr,
   12928             :                                                 Array1D_string &rowHead,
   12929             :                                                 Array2D_string &tableBody,
   12930             :                                                 int const dateColIdx)
   12931             : {
   12932             : 
   12933        1296 :     WriteSubtitle(state, tableName);
   12934        8376 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   12935        7080 :         rowHead(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).Name;
   12936       42480 :         for (int j = 1; j <= columnNum; j++) {
   12937       35400 :             tableBody(j, ZoneNum) = RealToStr((state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j - 1), 2);
   12938             :         }
   12939        7080 :         tableBody(dateColIdx, ZoneNum) = DateToString((state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(dateColIdx - 1));
   12940             :     }
   12941             : 
   12942        1296 :     std::vector<Real64> columnMax(columnNum, 0);
   12943        1296 :     std::vector<Real64> columnMin(columnNum, 0);
   12944        1296 :     std::vector<Real64> columnSum(columnNum, 0);
   12945             : 
   12946        7776 :     for (int j = 0; j < columnNum; j++) {
   12947        6480 :         columnMin.at(j) = (state.dataHeatBal->Resilience(1).*memberPtr).at(j);
   12948             :     }
   12949        8376 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   12950       42480 :         for (int j = 0; j < columnNum; j++) {
   12951       35400 :             Real64 curValue = (state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j);
   12952       35400 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   12953       35400 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   12954       35400 :             columnSum.at(j) += curValue;
   12955             :         }
   12956             :     }
   12957             : 
   12958        1296 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12959        1296 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12960        1296 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12961        1296 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   12962             : 
   12963        7776 :     for (int j = 0; j < columnNum; j++) {
   12964        6480 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12965        6480 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12966        6480 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12967        6480 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   12968             :     }
   12969             : 
   12970        6480 :     for (int i = 1; i < 5; i++) {
   12971        5184 :         tableBody(dateColIdx, state.dataGlobal->NumOfZones + i) = "-";
   12972             :     }
   12973             : 
   12974        1296 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12975        1296 :     if (state.dataSQLiteProcedures->sqlite) {
   12976         126 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12977             :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12978             :     }
   12979        1296 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12980          12 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12981             :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12982             :     }
   12983        1296 : }
   12984             : 
   12985          10 : void WriteHourOfSafetyTableReportingPeriod(EnergyPlusData &state,
   12986             :                                            int const columnNum,
   12987             :                                            int const periodIdx,
   12988             :                                            const std::string &periodTitle,
   12989             :                                            const std::string &tableName,
   12990             :                                            Array1D_string const &columnHead,
   12991             :                                            Array1D_int &columnWidth,
   12992             :                                            Array2D<std::vector<Real64>> const &ZoneBins,
   12993             :                                            Array1D_string &rowHead,
   12994             :                                            Array2D_string &tableBody,
   12995             :                                            int const dateColIdx)
   12996             : {
   12997             : 
   12998          10 :     WriteSubtitle(state, tableName);
   12999          20 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   13000          10 :         rowHead(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).Name;
   13001          60 :         for (int j = 1; j <= columnNum; j++) {
   13002          50 :             tableBody(j, ZoneNum) = RealToStr(ZoneBins(ZoneNum, periodIdx).at(j - 1), 2);
   13003             :         }
   13004          10 :         tableBody(dateColIdx, ZoneNum) = DateToString(ZoneBins(ZoneNum, periodIdx).at(dateColIdx - 1));
   13005             :     }
   13006             : 
   13007          10 :     std::vector<Real64> columnMax(columnNum, 0);
   13008          10 :     std::vector<Real64> columnMin(columnNum, 0);
   13009          10 :     std::vector<Real64> columnSum(columnNum, 0);
   13010             : 
   13011          60 :     for (int j = 0; j < columnNum; j++) {
   13012          50 :         columnMin.at(j) = ZoneBins(1, periodIdx).at(j);
   13013             :     }
   13014          20 :     for (int i = 1; i <= state.dataGlobal->NumOfZones; ++i) {
   13015          60 :         for (int j = 0; j < columnNum; j++) {
   13016          50 :             Real64 curValue = ZoneBins(i, periodIdx).at(j);
   13017          50 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   13018          50 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   13019          50 :             columnSum.at(j) += curValue;
   13020             :         }
   13021             :     }
   13022             : 
   13023          10 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   13024          10 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   13025          10 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   13026          10 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   13027             : 
   13028          60 :     for (int j = 0; j < columnNum; j++) {
   13029          50 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   13030          50 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   13031          50 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   13032          50 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   13033             :     }
   13034             : 
   13035          50 :     for (int i = 1; i < 5; i++) {
   13036          40 :         tableBody(dateColIdx, state.dataGlobal->NumOfZones + i) = "-";
   13037             :     }
   13038             : 
   13039          10 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13040          10 :     if (state.dataSQLiteProcedures->sqlite) {
   13041           0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13042           0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   13043             :     }
   13044          10 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13045           0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13046           0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   13047             :     }
   13048          10 : }
   13049             : 
   13050           0 : void WriteHourOfSafetyTable(EnergyPlusData &state,
   13051             :                             int const columnNum,
   13052             :                             std::vector<int> const &columnHead,
   13053             :                             Array1D<std::vector<Real64>> const &ZoneBins,
   13054             :                             int const dateColIdx)
   13055             : {
   13056           0 :     std::vector<Real64> columnMax(columnNum, 0);
   13057           0 :     std::vector<Real64> columnMin(columnNum, 0);
   13058           0 :     std::vector<Real64> columnSum(columnNum, 0);
   13059           0 :     for (int j = 0; j < columnNum; j++) {
   13060           0 :         columnMin[j] = ZoneBins(1)[j];
   13061             :     }
   13062           0 :     for (int i = 1; i <= state.dataGlobal->NumOfZones; ++i) {
   13063           0 :         auto const &thisZone = state.dataHeatBal->Zone(i);
   13064           0 :         for (int j = 0; j < columnNum; j++) {
   13065           0 :             if (j == dateColIdx) {
   13066           0 :                 std::string startDateTime = DateToString(int(ZoneBins(i)[dateColIdx]));
   13067           0 :                 PreDefTableEntry(state, columnHead[dateColIdx], thisZone.Name, startDateTime);
   13068           0 :             } else {
   13069           0 :                 Real64 curValue = ZoneBins(i)[j];
   13070           0 :                 if (curValue > columnMax[j]) columnMax[j] = curValue;
   13071           0 :                 if (curValue < columnMin[j]) columnMin[j] = curValue;
   13072           0 :                 columnSum[j] += curValue;
   13073           0 :                 PreDefTableEntry(state, columnHead[j], thisZone.Name, RealToStr(curValue, 2));
   13074             :             }
   13075             :         }
   13076             :     }
   13077           0 :     for (int j = 0; j < columnNum; j++) {
   13078           0 :         if (j == dateColIdx) {
   13079           0 :             PreDefTableEntry(state, columnHead[j], "Min", "-");
   13080           0 :             PreDefTableEntry(state, columnHead[j], "Max", "-");
   13081           0 :             PreDefTableEntry(state, columnHead[j], "Average", "-");
   13082           0 :             PreDefTableEntry(state, columnHead[j], "Sum", "-");
   13083             :         } else {
   13084           0 :             PreDefTableEntry(state, columnHead[j], "Min", RealToStr(columnMin[j], 2));
   13085           0 :             PreDefTableEntry(state, columnHead[j], "Max", RealToStr(columnMax[j], 2));
   13086           0 :             PreDefTableEntry(state, columnHead[j], "Average", RealToStr(columnSum[j] / state.dataGlobal->NumOfZones, 2));
   13087           0 :             PreDefTableEntry(state, columnHead[j], "Sum", RealToStr(columnSum[j], 2));
   13088             :         }
   13089             :     }
   13090           0 : }
   13091             : 
   13092         675 : void WriteThermalResilienceTables(EnergyPlusData &state)
   13093             : {
   13094             : 
   13095             :     // Using/Aliasing
   13096         675 :     auto const &ort = state.dataOutRptTab;
   13097             : 
   13098         675 :     if (state.dataGlobal->NumOfZones <= 0) {
   13099          27 :         return;
   13100             :     }
   13101             : 
   13102             :     Real64 degreeHourConversion;
   13103         648 :     UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13104         648 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13105             :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   13106          11 :         degreeHourConversion = getSpecificUnitMultiplier(state, "°C·hr", "°F·hr");
   13107             :     } else {
   13108         637 :         degreeHourConversion = 1.0;
   13109             :     }
   13110             : 
   13111         648 :     WriteReportHeaders(state, "Annual Thermal Resilience Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   13112             : 
   13113         648 :     Array1D_int columnWidth;
   13114         648 :     columnWidth.allocate(numColumnThermalTbl);
   13115         648 :     columnWidth = 10;
   13116         648 :     Array1D_string rowHead;
   13117         648 :     Array2D_string tableBody;
   13118         648 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   13119         648 :     tableBody.allocate(numColumnThermalTbl, state.dataGlobal->NumOfZones + 4);
   13120         648 :     Array1D_string columnHeadStr(numColumnThermalTbl);
   13121             : 
   13122         648 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13123             :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   13124          11 :         columnHeadStr(1) = "Safe (≤ 80.1°F) [hr]";
   13125          11 :         columnHeadStr(2) = "Caution (> 80.1°F, ≤ 90.0°F) [hr]";
   13126          11 :         columnHeadStr(3) = "Extreme Caution (> 90.0°F, ≤ 102.9°F) [hr]";
   13127          11 :         columnHeadStr(4) = "Danger (> 102.9, ≤ 125.1°F) [hr]";
   13128          11 :         columnHeadStr(5) = "Extreme Danger (> 125.1°F) [hr]";
   13129             :     } else {
   13130         637 :         columnHeadStr(1) = "Safe (≤ 26.7°C) [hr]";
   13131         637 :         columnHeadStr(2) = "Caution (> 26.7°C, ≤ 32.2°C) [hr]";
   13132         637 :         columnHeadStr(3) = "Extreme Caution (> 32.2°C, ≤ 39.4°C) [hr]";
   13133         637 :         columnHeadStr(4) = "Danger (> 39.4°C, ≤ 51.7°C) [hr]";
   13134         637 :         columnHeadStr(5) = "Extreme Danger (> 51.7°C) [hr]";
   13135             :     }
   13136             : 
   13137         648 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatIndex = &DataHeatBalance::ZoneResilience::ZoneHeatIndexHourBins;
   13138         648 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatIndexOccuHour =
   13139             :         &DataHeatBalance::ZoneResilience::ZoneHeatIndexOccuHourBins;
   13140         648 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatIndexOccupiedHour =
   13141             :         &DataHeatBalance::ZoneResilience::ZoneHeatIndexOccupiedHourBins;
   13142         648 :     std::string tableName = "Heat Index Hours";
   13143         648 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(state, tableName, columnHeadStr, columnWidth, ptrHeatIndex, rowHead, tableBody);
   13144         648 :     tableName = "Heat Index OccupantHours";
   13145         648 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13146             :         state, tableName, columnHeadStr, columnWidth, ptrHeatIndexOccuHour, rowHead, tableBody);
   13147         648 :     tableName = "Heat Index OccupiedHours";
   13148         648 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13149             :         state, tableName, columnHeadStr, columnWidth, ptrHeatIndexOccupiedHour, rowHead, tableBody);
   13150             : 
   13151         648 :     columnHeadStr(1) = "Little to no Discomfort (≤ 29) [hr]";
   13152         648 :     columnHeadStr(2) = "Some Discomfort (> 29, ≤ 40) [hr]";
   13153         648 :     columnHeadStr(3) = "Great Discomfort; Avoid Exertion (> 40, ≤ 45) [hr]";
   13154         648 :     columnHeadStr(4) = "Dangerous (> 45, ≤ 50) [hr]";
   13155         648 :     columnHeadStr(5) = "Heat Stroke Quite Possible (> 50) [hr]";
   13156             : 
   13157         648 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHumidex = &DataHeatBalance::ZoneResilience::ZoneHumidexHourBins;
   13158         648 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHumidexOccuHour =
   13159             :         &DataHeatBalance::ZoneResilience::ZoneHumidexOccuHourBins;
   13160         648 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHumidexOccupiedHour =
   13161             :         &DataHeatBalance::ZoneResilience::ZoneHumidexOccupiedHourBins;
   13162         648 :     tableName = "Humidex Hours";
   13163         648 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(state, tableName, columnHeadStr, columnWidth, ptrHumidex, rowHead, tableBody);
   13164         648 :     tableName = "Humidex OccupantHours";
   13165         648 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13166             :         state, tableName, columnHeadStr, columnWidth, ptrHumidexOccuHour, rowHead, tableBody);
   13167         648 :     tableName = "Humidex OccupiedHours";
   13168         648 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13169             :         state, tableName, columnHeadStr, columnWidth, ptrHumidexOccupiedHour, rowHead, tableBody);
   13170             : 
   13171         648 :     bool hasPierceSET = true;
   13172         648 :     if (state.dataHeatBal->TotPeople == 0) {
   13173          76 :         hasPierceSET = false;
   13174          76 :         if (ort->displayThermalResilienceSummaryExplicitly) {
   13175           0 :             ShowWarningError(state,
   13176             :                              "Writing Annual Thermal Resilience Summary - SET Degree-Hours reports: "
   13177             :                              "Zone Thermal Comfort Pierce Model Standard Effective Temperature is required, "
   13178             :                              "but no People object is defined.");
   13179             :         }
   13180             :     }
   13181        3544 :     for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   13182        2896 :         if (!state.dataHeatBal->People(iPeople).Pierce) {
   13183        2885 :             hasPierceSET = false;
   13184        2885 :             if (ort->displayThermalResilienceSummaryExplicitly) {
   13185           0 :                 ShowWarningError(state,
   13186           0 :                                  format("Writing Annual Thermal Resilience Summary - SET Degree-Hours reports: Zone Thermal Comfort Pierce Model "
   13187             :                                         "Standard Effective Temperature is required, but no Pierce model is defined in {} object.",
   13188           0 :                                         state.dataHeatBal->People(iPeople).Name));
   13189             :             }
   13190             :         }
   13191             :     }
   13192             : 
   13193         648 :     if (hasPierceSET) {
   13194           6 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13195             :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   13196           0 :             columnHeadStr(1) = "SET > 86°F Degree-Hours [°F·hr]";
   13197           0 :             columnHeadStr(2) = "SET > 86°F Occupant-Weighted Degree-Hours [°F·hr]";
   13198           0 :             columnHeadStr(3) = "SET > 86°F Occupied Degree-Hours [°F·hr]";
   13199           0 :             columnHeadStr(4) = "Longest SET > 86°F Duration for Occupied Period [hr]";
   13200           0 :             columnHeadStr(5) = "Start Time of the Longest SET > 86°F Duration for Occupied Period";
   13201             :         } else {
   13202           6 :             columnHeadStr(1) = "SET > 30°C Degree-Hours [°C·hr]";
   13203           6 :             columnHeadStr(2) = "SET > 30°C Occupant-Weighted Degree-Hours [°C·hr]";
   13204           6 :             columnHeadStr(3) = "SET > 30°C Occupied Degree-Hours [°C·hr]";
   13205           6 :             columnHeadStr(4) = "Longest SET > 30°C Duration for Occupied Period [hr]";
   13206           6 :             columnHeadStr(5) = "Start Time of the Longest SET > 30°C Duration for Occupied Period";
   13207             :         }
   13208             : 
   13209           6 :         std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrLowSETHours = &DataHeatBalance::ZoneResilience::ZoneLowSETHours;
   13210           6 :         std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHighSETHours =
   13211             :             &DataHeatBalance::ZoneResilience::ZoneHighSETHours;
   13212           6 :         Array1D_string rowHeadSET;
   13213           6 :         Array2D_string tableBodySET;
   13214           6 :         rowHeadSET.allocate(state.dataGlobal->NumOfZones + 3);
   13215           6 :         tableBodySET.allocate(numColumnThermalTbl, state.dataGlobal->NumOfZones + 3);
   13216           6 :         tableName = "Heating SET Degree-Hours";
   13217           6 :         WriteSETHoursTableNonPreDefUseZoneData(
   13218             :             state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrLowSETHours, rowHeadSET, tableBodySET, degreeHourConversion);
   13219           6 :         tableName = "Cooling SET Degree-Hours";
   13220           6 :         WriteSETHoursTableNonPreDefUseZoneData(
   13221             :             state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrHighSETHours, rowHeadSET, tableBodySET, degreeHourConversion);
   13222           6 :     }
   13223             : 
   13224         648 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrColdHourOfSafetyBins =
   13225             :         &DataHeatBalance::ZoneResilience::ZoneColdHourOfSafetyBins;
   13226         648 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatHourOfSafetyBins =
   13227             :         &DataHeatBalance::ZoneResilience::ZoneHeatHourOfSafetyBins;
   13228         648 :     tableName = "Hours of Safety for Cold Events";
   13229         648 :     columnHeadStr(1) = "Hours of Safety [hr]";
   13230         648 :     columnHeadStr(2) = "End Time of the Safety Duration";
   13231         648 :     columnHeadStr(3) = "Safe Temperature Exceedance Hours [hr]";
   13232         648 :     columnHeadStr(4) = "Safe Temperature Exceedance OccupantHours [hr]";
   13233         648 :     columnHeadStr(5) = "Safe Temperature Exceedance OccupiedHours [hr]";
   13234         648 :     WriteHourOfSafetyTableNonPreDefUseZoneData(
   13235             :         state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrColdHourOfSafetyBins, rowHead, tableBody, 2);
   13236         648 :     tableName = "Hours of Safety for Heat Events";
   13237         648 :     WriteHourOfSafetyTableNonPreDefUseZoneData(
   13238             :         state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrHeatHourOfSafetyBins, rowHead, tableBody, 2);
   13239             : 
   13240         648 :     Array1D_int columnWidthUnmetDegHr;
   13241         648 :     columnWidthUnmetDegHr.allocate(numColumnUnmetDegreeHourTbl);
   13242         648 :     columnWidthUnmetDegHr = 10;
   13243         648 :     Array1D_string columnHeadUnmetDegHr;
   13244         648 :     columnHeadUnmetDegHr.allocate(numColumnUnmetDegreeHourTbl);
   13245         648 :     Array2D_string tableBodyUnmetDegHr;
   13246         648 :     tableBodyUnmetDegHr.allocate(numColumnUnmetDegreeHourTbl, state.dataGlobal->NumOfZones + 4);
   13247         648 :     tableName = "Unmet Degree-Hours";
   13248         648 :     columnHeadUnmetDegHr(1) = "Cooling Setpoint Unmet Degree-Hours [°C·hr]";
   13249         648 :     columnHeadUnmetDegHr(2) = "Cooling Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   13250         648 :     columnHeadUnmetDegHr(3) = "Cooling Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   13251         648 :     columnHeadUnmetDegHr(4) = "Heating Setpoint Unmet Degree-Hours [°C·hr]";
   13252         648 :     columnHeadUnmetDegHr(5) = "Heating Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   13253         648 :     columnHeadUnmetDegHr(6) = "Heating Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   13254             : 
   13255         648 :     if (unitsStyle_cur == UnitsStyle::InchPound) {
   13256             :         int indexUnitConv;
   13257          11 :         std::string curUnits;
   13258          66 :         for (int i = 1; i < numColumnUnmetDegreeHourTbl; i++) {
   13259          55 :             LookupSItoIP(state, columnHeadUnmetDegHr(i), indexUnitConv, curUnits);
   13260          55 :             columnHeadUnmetDegHr(i) = curUnits;
   13261             :         }
   13262         648 :     } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   13263             :         int indexUnitConv;
   13264           0 :         std::string curUnits;
   13265           0 :         for (int i = 1; i < numColumnUnmetDegreeHourTbl; i++) {
   13266           0 :             LookupSItoIP(state, columnHeadUnmetDegHr(i), indexUnitConv, curUnits);
   13267           0 :             columnHeadUnmetDegHr(i) = curUnits;
   13268             :         }
   13269           0 :     }
   13270             : 
   13271         648 :     std::array<Real64, numColumnUnmetDegreeHourTbl> DataHeatBalance::ZoneResilience::*ptrUnmetDegreeHourBins =
   13272             :         &DataHeatBalance::ZoneResilience::ZoneUnmetDegreeHourBins;
   13273         648 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnUnmetDegreeHourTbl>(
   13274             :         state, tableName, columnHeadUnmetDegHr, columnWidthUnmetDegHr, ptrUnmetDegreeHourBins, rowHead, tableBodyUnmetDegHr, degreeHourConversion);
   13275             : 
   13276         648 :     columnHeadStr.allocate(numColumnDiscomfortWtExceedHourTbl);
   13277         648 :     columnWidth.allocate(numColumnDiscomfortWtExceedHourTbl);
   13278         648 :     columnWidth = 10;
   13279         648 :     tableBody.allocate(numColumnDiscomfortWtExceedHourTbl, state.dataGlobal->NumOfZones + 4);
   13280         648 :     columnHeadStr(1) = "Very-cold Exceedance OccupantHours [hr]";
   13281         648 :     columnHeadStr(2) = "Cool Exceedance OccupantHours [hr]";
   13282         648 :     columnHeadStr(3) = "Warm Exceedance OccupantHours [hr]";
   13283         648 :     columnHeadStr(4) = "Very-hot Exceedance OccupantHours [hr]";
   13284             : 
   13285         648 :     std::array<Real64, numColumnDiscomfortWtExceedHourTbl> DataHeatBalance::ZoneResilience::*ptrDiscomfortWtExceedOccuHourBins =
   13286             :         &DataHeatBalance::ZoneResilience::ZoneDiscomfortWtExceedOccuHourBins;
   13287         648 :     std::array<Real64, numColumnDiscomfortWtExceedHourTbl> DataHeatBalance::ZoneResilience::*ptrDiscomfortWtExceedOccupiedHourBins =
   13288             :         &DataHeatBalance::ZoneResilience::ZoneDiscomfortWtExceedOccupiedHourBins;
   13289         648 :     tableName = "Discomfort-weighted Exceedance OccupantHours";
   13290         648 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnDiscomfortWtExceedHourTbl>(
   13291             :         state, tableName, columnHeadStr, columnWidth, ptrDiscomfortWtExceedOccuHourBins, rowHead, tableBody);
   13292         648 :     tableName = "Discomfort-weighted Exceedance OccupiedHours";
   13293         648 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnDiscomfortWtExceedHourTbl>(
   13294             :         state, tableName, columnHeadStr, columnWidth, ptrDiscomfortWtExceedOccupiedHourBins, rowHead, tableBody);
   13295         648 :     rowHead.deallocate();
   13296         648 :     columnHeadStr.deallocate();
   13297         648 :     tableBody.deallocate();
   13298         648 :     tableBodyUnmetDegHr.deallocate();
   13299         648 :     columnWidth.deallocate();
   13300         648 :     columnHeadUnmetDegHr.deallocate();
   13301         648 :     columnWidthUnmetDegHr.deallocate();
   13302         648 : }
   13303             : 
   13304          15 : void WriteCO2ResilienceTables(EnergyPlusData &state)
   13305             : {
   13306             : 
   13307          15 :     if (state.dataGlobal->NumOfZones <= 0) {
   13308           0 :         return;
   13309             :     }
   13310             :     std::array<int, numColumnCO2Tbl> columnHead = {
   13311          15 :         state.dataOutRptPredefined->pdchCO2HourSafe, state.dataOutRptPredefined->pdchCO2HourCaution, state.dataOutRptPredefined->pdchCO2HourHazard};
   13312             : 
   13313          15 :     std::array<Real64, numColumnCO2Tbl> DataHeatBalance::ZoneResilience::*ptrCO2LevelHourBins =
   13314             :         &DataHeatBalance::ZoneResilience::ZoneCO2LevelHourBins;
   13315          15 :     std::array<Real64, numColumnCO2Tbl> DataHeatBalance::ZoneResilience::*ptrCO2LevelOccuHourBins =
   13316             :         &DataHeatBalance::ZoneResilience::ZoneCO2LevelOccuHourBins;
   13317          15 :     std::array<Real64, numColumnCO2Tbl> DataHeatBalance::ZoneResilience::*ptrCO2LevelOccupiedHourBins =
   13318             :         &DataHeatBalance::ZoneResilience::ZoneCO2LevelOccupiedHourBins;
   13319          15 :     WriteResilienceBinsTable<numColumnCO2Tbl>(state, columnHead, ptrCO2LevelHourBins);
   13320             : 
   13321          15 :     columnHead = {state.dataOutRptPredefined->pdchCO2OccuHourSafe,
   13322          15 :                   state.dataOutRptPredefined->pdchCO2OccuHourCaution,
   13323          15 :                   state.dataOutRptPredefined->pdchCO2OccuHourHazard};
   13324          15 :     WriteResilienceBinsTable<numColumnCO2Tbl>(state, columnHead, ptrCO2LevelOccuHourBins);
   13325             : 
   13326          15 :     columnHead = {state.dataOutRptPredefined->pdchCO2OccupiedHourSafe,
   13327          15 :                   state.dataOutRptPredefined->pdchCO2OccupiedHourCaution,
   13328          15 :                   state.dataOutRptPredefined->pdchCO2OccupiedHourHazard};
   13329          15 :     WriteResilienceBinsTable<numColumnCO2Tbl>(state, columnHead, ptrCO2LevelOccupiedHourBins);
   13330             : }
   13331             : 
   13332           3 : void WriteCO2ResilienceTablesRepPeriod(EnergyPlusData &state, const int periodIdx)
   13333             : {
   13334           3 :     auto const &ort = state.dataOutRptTab;
   13335             :     // TODO: this is wrong. This function is called only when ort->WriteTabularFiles is true already. Missing a '!'
   13336           3 :     if (ort->WriteTabularFiles) {
   13337           3 :         return;
   13338             :     }
   13339           0 :     WriteReportHeaderReportingPeriod(state, "CO2", periodIdx, state.dataWeather->CO2ReportPeriodInput);
   13340           0 :     std::string periodTitle = state.dataWeather->CO2ReportPeriodInput(periodIdx).title;
   13341             : 
   13342           0 :     Array1D_int columnWidth;
   13343           0 :     columnWidth.allocate(numColumnCO2Tbl);
   13344           0 :     columnWidth = 10;
   13345           0 :     Array1D_string columnHead(numColumnCO2Tbl);
   13346           0 :     columnHead(1) = "Safe (<= 1000 ppm) [hr]";
   13347           0 :     columnHead(2) = "Caution (> 1000, <= 5000 ppm) [hr]";
   13348           0 :     columnHead(3) = "Hazard (> 5000 ppm) [hr]";
   13349             : 
   13350           0 :     Array1D_string rowHead;
   13351           0 :     Array2D_string tableBody;
   13352           0 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   13353           0 :     tableBody.allocate(numColumnCO2Tbl, state.dataGlobal->NumOfZones + 4);
   13354             : 
   13355           0 :     std::string tableName = "CO2 Level Hours";
   13356           0 :     std::string tableType = "CO2";
   13357           0 :     WriteResilienceBinsTableReportingPeriod(state,
   13358             :                                             tableType,
   13359             :                                             numColumnCO2Tbl,
   13360             :                                             periodIdx,
   13361             :                                             periodTitle,
   13362             :                                             tableName,
   13363             :                                             columnHead,
   13364             :                                             columnWidth,
   13365           0 :                                             state.dataHeatBalFanSys->ZoneCO2LevelHourBinsRepPeriod,
   13366             :                                             rowHead,
   13367             :                                             tableBody);
   13368             : 
   13369           0 :     tableName = "CO2 Level OccupantHours";
   13370           0 :     WriteResilienceBinsTableReportingPeriod(state,
   13371             :                                             tableType,
   13372             :                                             numColumnCO2Tbl,
   13373             :                                             periodIdx,
   13374             :                                             periodTitle,
   13375             :                                             tableName,
   13376             :                                             columnHead,
   13377             :                                             columnWidth,
   13378           0 :                                             state.dataHeatBalFanSys->ZoneCO2LevelOccuHourBinsRepPeriod,
   13379             :                                             rowHead,
   13380             :                                             tableBody);
   13381             : 
   13382           0 :     tableName = "CO2 Level OccupiedHours";
   13383           0 :     WriteResilienceBinsTableReportingPeriod(state,
   13384             :                                             tableType,
   13385             :                                             numColumnCO2Tbl,
   13386             :                                             periodIdx,
   13387             :                                             periodTitle,
   13388             :                                             tableName,
   13389             :                                             columnHead,
   13390             :                                             columnWidth,
   13391           0 :                                             state.dataHeatBalFanSys->ZoneCO2LevelOccupiedHourBinsRepPeriod,
   13392             :                                             rowHead,
   13393             :                                             tableBody);
   13394           0 : }
   13395             : 
   13396          55 : void WriteVisualResilienceTables(EnergyPlusData &state)
   13397             : {
   13398         683 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   13399         628 :         if (state.dataDayltg->ZoneDaylight(ZoneNum).totRefPts == 0) {
   13400         410 :             if (state.dataOutRptTab->displayVisualResilienceSummaryExplicitly) {
   13401           0 :                 ShowWarningError(state,
   13402           0 :                                  format("Writing Annual Visual Resilience Summary - Lighting Level Hours reports: Zone Average Daylighting Reference "
   13403             :                                         "Point Illuminance output is required, but no Daylighting Controls are defined in Zone:{}",
   13404           0 :                                         state.dataHeatBal->Zone(ZoneNum).Name));
   13405             :             }
   13406             :         }
   13407             :     }
   13408             : 
   13409          55 :     if (state.dataGlobal->NumOfZones <= 0) return;
   13410          55 :     std::array<int, numColumnVisualTbl> columnHead = {state.dataOutRptPredefined->pdchIllumHourDark,
   13411         110 :                                                       state.dataOutRptPredefined->pdchIllumHourDim,
   13412         110 :                                                       state.dataOutRptPredefined->pdchIllumHourAdequate,
   13413          55 :                                                       state.dataOutRptPredefined->pdchIllumHourBright};
   13414             : 
   13415          55 :     std::array<Real64, numColumnVisualTbl> DataHeatBalance::ZoneResilience::*ptrLightingLevelHourBins =
   13416             :         &DataHeatBalance::ZoneResilience::ZoneLightingLevelHourBins;
   13417          55 :     std::array<Real64, numColumnVisualTbl> DataHeatBalance::ZoneResilience::*ptrLightingLevelOccuHourBins =
   13418             :         &DataHeatBalance::ZoneResilience::ZoneLightingLevelOccuHourBins;
   13419          55 :     std::array<Real64, numColumnVisualTbl> DataHeatBalance::ZoneResilience::*ptrLightingLevelOccupiedHourBins =
   13420             :         &DataHeatBalance::ZoneResilience::ZoneLightingLevelOccupiedHourBins;
   13421          55 :     WriteResilienceBinsTable<numColumnVisualTbl>(state, columnHead, ptrLightingLevelHourBins);
   13422             : 
   13423          55 :     columnHead = {state.dataOutRptPredefined->pdchIllumOccuHourDark,
   13424          55 :                   state.dataOutRptPredefined->pdchIllumOccuHourDim,
   13425          55 :                   state.dataOutRptPredefined->pdchIllumOccuHourAdequate,
   13426          55 :                   state.dataOutRptPredefined->pdchIllumOccuHourBright};
   13427          55 :     WriteResilienceBinsTable<numColumnVisualTbl>(state, columnHead, ptrLightingLevelOccuHourBins);
   13428             : 
   13429          55 :     columnHead = {state.dataOutRptPredefined->pdchIllumOccupiedHourDark,
   13430          55 :                   state.dataOutRptPredefined->pdchIllumOccupiedHourDim,
   13431          55 :                   state.dataOutRptPredefined->pdchIllumOccupiedHourAdequate,
   13432          55 :                   state.dataOutRptPredefined->pdchIllumOccupiedHourBright};
   13433          55 :     WriteResilienceBinsTable<numColumnVisualTbl>(state, columnHead, ptrLightingLevelOccupiedHourBins);
   13434             : }
   13435             : 
   13436           3 : void WriteVisualResilienceTablesRepPeriod(EnergyPlusData &state, const int periodIdx)
   13437             : {
   13438           3 :     auto const &ort = state.dataOutRptTab;
   13439           3 :     if (!ort->WriteTabularFiles) {
   13440           0 :         return;
   13441             :     }
   13442             : 
   13443           3 :     WriteReportHeaderReportingPeriod(state, "Visual", periodIdx, state.dataWeather->VisualReportPeriodInput);
   13444           3 :     std::string periodTitle = state.dataWeather->VisualReportPeriodInput(periodIdx).title;
   13445             : 
   13446           3 :     Array1D_int columnWidth;
   13447           3 :     columnWidth.allocate(numColumnVisualTbl);
   13448           3 :     columnWidth = 10;
   13449           3 :     Array1D_string columnHead(numColumnVisualTbl);
   13450           3 :     columnHead(1) = "A Bit Dark (<= 100 lux) [hr]";
   13451           3 :     columnHead(2) = "Dim (> 100, <= 300 lux) [hr]";
   13452           3 :     columnHead(3) = "Adequate (> 300, <= 500 lux) [hr]";
   13453           3 :     columnHead(4) = "Bright (>500 lux) [hr]";
   13454             : 
   13455           3 :     Array1D_string rowHead;
   13456           3 :     Array2D_string tableBody;
   13457           3 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   13458           3 :     tableBody.allocate(numColumnVisualTbl, state.dataGlobal->NumOfZones + 4);
   13459             : 
   13460           3 :     std::string tableName = "Illuminance Level Hours";
   13461           3 :     std::string tableType = "Visual";
   13462           3 :     WriteResilienceBinsTableReportingPeriod(state,
   13463             :                                             tableType,
   13464             :                                             numColumnVisualTbl,
   13465             :                                             periodIdx,
   13466             :                                             periodTitle,
   13467             :                                             tableName,
   13468             :                                             columnHead,
   13469             :                                             columnWidth,
   13470           3 :                                             state.dataHeatBalFanSys->ZoneLightingLevelHourBinsRepPeriod,
   13471             :                                             rowHead,
   13472             :                                             tableBody);
   13473             : 
   13474           3 :     tableName = "Illuminance Level OccupantHours";
   13475           3 :     WriteResilienceBinsTableReportingPeriod(state,
   13476             :                                             tableType,
   13477             :                                             numColumnVisualTbl,
   13478             :                                             periodIdx,
   13479             :                                             periodTitle,
   13480             :                                             tableName,
   13481             :                                             columnHead,
   13482             :                                             columnWidth,
   13483           3 :                                             state.dataHeatBalFanSys->ZoneLightingLevelOccuHourBinsRepPeriod,
   13484             :                                             rowHead,
   13485             :                                             tableBody);
   13486             : 
   13487           3 :     tableName = "Illuminance Level OccupiedHours";
   13488           3 :     WriteResilienceBinsTableReportingPeriod(state,
   13489             :                                             tableType,
   13490             :                                             numColumnVisualTbl,
   13491             :                                             periodIdx,
   13492             :                                             periodTitle,
   13493             :                                             tableName,
   13494             :                                             columnHead,
   13495             :                                             columnWidth,
   13496           3 :                                             state.dataHeatBalFanSys->ZoneLightingLevelOccupiedHourBinsRepPeriod,
   13497             :                                             rowHead,
   13498             :                                             tableBody);
   13499           3 : }
   13500             : 
   13501         754 : void WriteHeatEmissionTable(EnergyPlusData &state)
   13502             : {
   13503             : 
   13504         754 :     Array1D_string columnHead(6);
   13505         754 :     Array1D_int columnWidth;
   13506         754 :     Array1D_string rowHead;
   13507         754 :     Array2D_string tableBody;
   13508         754 :     auto const &ort = state.dataOutRptTab;
   13509             : 
   13510         754 :     if (state.dataOutRptTab->displayHeatEmissionsSummary) {
   13511             : 
   13512        1346 :         for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   13513        1346 :             UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13514        1346 :             bool produceTabular = true;
   13515        1346 :             bool produceSQLite = false;
   13516        1346 :             if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   13517             : 
   13518         673 :             if (produceTabular) {
   13519         673 :                 WriteReportHeaders(state, "Annual Heat Emissions Report", "Entire Facility", OutputProcessor::StoreType::Average);
   13520         673 :                 WriteSubtitle(state, "Annual Heat Emissions Summary");
   13521             :             }
   13522             : 
   13523         673 :             columnWidth.allocate(6);
   13524         673 :             columnWidth = 10;
   13525             : 
   13526         673 :             rowHead.allocate(1);
   13527         673 :             tableBody.allocate(6, 1);
   13528             : 
   13529         673 :             Real64 energyconversion = 1.0;
   13530         673 :             if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13531         662 :                 unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   13532          11 :                 rowHead(1) = "Heat Emissions [kBtu]";
   13533          11 :                 energyconversion = 1.0 / getSpecificUnitDivider(state, "GJ", "kBtu"); // 1054351.84 J to kBtu
   13534         662 :             } else if (unitsStyle_cur == UnitsStyle::JtoGJ) {
   13535           0 :                 rowHead(1) = "Heat Emissions [GJ]";
   13536           0 :                 energyconversion = 1.0;
   13537         662 :             } else if (unitsStyle_cur == UnitsStyle::JtoKWH) {
   13538           6 :                 rowHead(1) = "Heat Emissions [kWh]";
   13539           6 :                 energyconversion = 1.0e3 / 3.6;
   13540         656 :             } else if (unitsStyle_cur == UnitsStyle::JtoMJ) {
   13541           0 :                 rowHead(1) = "Heat Emissions [MJ]";
   13542           0 :                 energyconversion = 1.0e3;
   13543         656 :             } else if (unitsStyle_cur == UnitsStyle::None) {
   13544         656 :                 rowHead(1) = "Heat Emissions [GJ]";
   13545         656 :                 energyconversion = 1.0;
   13546             :             } else {
   13547           0 :                 rowHead(1) = "Heat Emissions [GJ]";
   13548           0 :                 energyconversion = 1.0;
   13549             :             }
   13550             : 
   13551         673 :             columnHead(1) = "Envelope Convection";
   13552         673 :             columnHead(2) = "Zone Exfiltration";
   13553         673 :             columnHead(3) = "Zone Exhaust Air";
   13554         673 :             columnHead(4) = "HVAC Relief Air";
   13555         673 :             columnHead(5) = "HVAC Reject Heat";
   13556         673 :             columnHead(6) = "Total";
   13557             : 
   13558         673 :             tableBody = "";
   13559         673 :             tableBody(1, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiEnvelopConv * energyconversion, 2);
   13560         673 :             tableBody(2, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiZoneExfiltration * energyconversion, 2);
   13561         673 :             tableBody(3, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiZoneExhaust * energyconversion, 2);
   13562         673 :             tableBody(4, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiHVACRelief * energyconversion, 2);
   13563         673 :             tableBody(5, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiHVACReject * energyconversion, 2);
   13564         673 :             tableBody(6, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiTotHeat * energyconversion, 2);
   13565             : 
   13566         673 :             if (produceTabular) {
   13567         673 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13568         673 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13569           6 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13570             :                         tableBody, rowHead, columnHead, "AnnualHeatEmissionsReport", "Entire Facility", "Annual Heat Emissions Summary");
   13571             :                 }
   13572             :             }
   13573         673 :             if (produceSQLite) {
   13574         673 :                 if (state.dataSQLiteProcedures->sqlite) {
   13575          74 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13576             :                         tableBody, rowHead, columnHead, "AnnualHeatEmissionsReport", "Entire Facility", "Annual Heat Emissions Summary");
   13577             :                 }
   13578             :             }
   13579             :         }
   13580             :     }
   13581         754 : }
   13582             : 
   13583         754 : void WritePredefinedTables(EnergyPlusData &state)
   13584             : {
   13585             :     // SUBROUTINE INFORMATION:
   13586             :     //       AUTHOR         Jason Glazer
   13587             :     //       DATE WRITTEN   August 2006
   13588             :     //       MODIFIED       January 2010, Kyle Benne; Added SQLite output
   13589             :     //                      March 2010, Linda Lawrie; Modify SizingPeriod:DesignDay to convert column/humidity types
   13590             :     //       RE-ENGINEERED  na
   13591             : 
   13592             :     // PURPOSE OF THIS SUBROUTINE:
   13593             :     //   Write out tables that have been predefined with data gathered
   13594             :     //   throughout the program code.
   13595             : 
   13596             :     // METHODOLOGY EMPLOYED:
   13597             :     //   Create arrays for the call to WriteTable and then call it.
   13598             :     //   This is a generic routine to write a report with multiple
   13599             :     //   subtables. The structure of the report are created in
   13600             :     //   OutputReportPredefined which also includes a routine that
   13601             :     //   builds up a tableEntry array which holds the data for the
   13602             :     //   predefined reports.
   13603             : 
   13604             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   13605             : 
   13606             :     // all arrays are in the format: (row, column)
   13607         754 :     Array1D_string columnHead;
   13608         754 :     Array1D_int columnWidth;
   13609         754 :     Array1D_string rowHead;
   13610         754 :     Array2D_string tableBody;
   13611         754 :     Array1D_int rowToUnqObjName;
   13612         754 :     Array1D_int colHeadToColTag;
   13613         754 :     Array1D_string uniqueObjectName;
   13614         754 :     Array1D_bool useUniqueObjectName;
   13615         754 :     int colCurrent(0);
   13616         754 :     int rowCurrent(0);
   13617         754 :     Array1D_int colUnitConv;
   13618         754 :     auto const &ort = state.dataOutRptTab;
   13619             : 
   13620        1508 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   13621        1508 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13622        1508 :         bool produceTabular = true;
   13623        1508 :         bool produceSQLite = false;
   13624        1508 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   13625         754 :             break;
   13626             :         }
   13627             : 
   13628             :         // loop through the entries and associate them with the subtable and create
   13629             :         // list of unique object names
   13630             :         // Much of this code is to allow for integer compares instead of string
   13631             :         // compares that are nested three levels in a loop.
   13632         754 :         uniqueObjectName.allocate(state.dataOutRptPredefined->numTableEntry);
   13633         754 :         useUniqueObjectName.allocate(state.dataOutRptPredefined->numTableEntry);
   13634         754 :         int numUnqObjName = 0;
   13635     3718044 :         for (int lTableEntry = 1; lTableEntry <= state.dataOutRptPredefined->numTableEntry; ++lTableEntry) {
   13636             :             // associate the subtable with each column
   13637     3717290 :             int const curColumn = state.dataOutRptPredefined->tableEntry(lTableEntry).indexColumn;
   13638     3717290 :             if ((curColumn >= 1) && (curColumn <= state.dataOutRptPredefined->numColumnTag)) {
   13639     3717290 :                 state.dataOutRptPredefined->tableEntry(lTableEntry).subTableIndex = state.dataOutRptPredefined->columnTag(curColumn).indexSubTable;
   13640             :             }
   13641             :             // make a list of unique object names
   13642     3717290 :             std::string const &curObjectName = state.dataOutRptPredefined->tableEntry(lTableEntry).objectName;
   13643     3717290 :             int found = 0;
   13644  1356927014 :             for (int mUnqObjNames = 1; mUnqObjNames <= numUnqObjName; ++mUnqObjNames) {
   13645  1356634202 :                 if (curObjectName == uniqueObjectName(mUnqObjNames)) {
   13646     3424478 :                     found = mUnqObjNames;
   13647     3424478 :                     break;
   13648             :                 }
   13649             :             }
   13650             :             // if found then point to the unique object
   13651     3717290 :             if (found > 0) {
   13652     3424478 :                 state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName = found;
   13653             :                 // if not found add to the unique object list
   13654             :             } else {
   13655      292812 :                 ++numUnqObjName;
   13656      292812 :                 uniqueObjectName(numUnqObjName) = curObjectName;
   13657      292812 :                 state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName = numUnqObjName;
   13658             :             }
   13659             :         }
   13660             :         // loop through all reports and include those that have been flagged as 'show'
   13661       13988 :         for (int iReportName = 1; iReportName <= state.dataOutRptPredefined->numReportName; ++iReportName) {
   13662       13234 :             if (state.dataOutRptPredefined->reportName(iReportName).show) {
   13663       12108 :                 if (produceTabular) {
   13664       24216 :                     WriteReportHeaders(state,
   13665       12108 :                                        state.dataOutRptPredefined->reportName(iReportName).namewithspaces,
   13666             :                                        "Entire Facility",
   13667             :                                        OutputProcessor::StoreType::Average);
   13668             :                 }
   13669             :                 // loop through the subtables and include those that are associated with this report
   13670     1214408 :                 for (int jSubTable = 1, jSubTable_end = state.dataOutRptPredefined->numSubTable; jSubTable <= jSubTable_end; ++jSubTable) {
   13671     1202300 :                     if (state.dataOutRptPredefined->subTable(jSubTable).indexReportName == iReportName) {
   13672             :                         // determine how many columns
   13673       69406 :                         int curNumColumns = 0;
   13674    60717970 :                         for (int kColumnTag = 1; kColumnTag <= state.dataOutRptPredefined->numColumnTag; ++kColumnTag) {
   13675    60648564 :                             if (state.dataOutRptPredefined->columnTag(kColumnTag).indexSubTable == jSubTable) {
   13676      612582 :                                 ++curNumColumns;
   13677             :                             }
   13678             :                         }
   13679             :                         // determine how many rows by going through table entries and setting
   13680             :                         // flag in useUniqueObjectName to true, then count number of true's.
   13681       69406 :                         useUniqueObjectName = false; // array assignment
   13682   318456401 :                         for (int lTableEntry = 1; lTableEntry <= state.dataOutRptPredefined->numTableEntry; ++lTableEntry) {
   13683   318386995 :                             if (state.dataOutRptPredefined->tableEntry(lTableEntry).subTableIndex == jSubTable) {
   13684     3105526 :                                 useUniqueObjectName(state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName) = true;
   13685             :                             }
   13686             :                         }
   13687       69406 :                         int curNumRows = 0;
   13688    25650051 :                         for (int mUnqObjNames = 1; mUnqObjNames <= numUnqObjName; ++mUnqObjNames) {
   13689    25580645 :                             if (useUniqueObjectName(mUnqObjNames)) {
   13690      361505 :                                 ++curNumRows;
   13691             :                             }
   13692             :                         }
   13693       69406 :                         if (curNumRows == 0) curNumRows = 1;
   13694             :                         // now create the arrays that are filled with values
   13695       69406 :                         rowHead.allocate(curNumRows);
   13696       69406 :                         columnHead.allocate(curNumColumns);
   13697       69406 :                         columnWidth.dimension(curNumColumns, 14); // array assignment - same for all columns
   13698       69406 :                         tableBody.allocate(curNumColumns, curNumRows);
   13699       69406 :                         rowHead = "";
   13700       69406 :                         columnHead = "";
   13701       69406 :                         tableBody = "";
   13702             :                         // this array stores the unique object name index for each row
   13703       69406 :                         rowToUnqObjName.allocate(curNumRows);
   13704             :                         // this array stores the columnHead index for each column
   13705       69406 :                         colHeadToColTag.allocate(curNumColumns);
   13706       69406 :                         colUnitConv.allocate(curNumColumns);
   13707             :                         // set row headings
   13708       69406 :                         int countRow = 0;
   13709       69406 :                         rowHead(1) = "None";
   13710    25650051 :                         for (int mUnqObjNames = 1; mUnqObjNames <= numUnqObjName; ++mUnqObjNames) {
   13711    25580645 :                             if (useUniqueObjectName(mUnqObjNames)) {
   13712      361505 :                                 ++countRow;
   13713      361505 :                                 rowHead(countRow) = uniqueObjectName(mUnqObjNames);
   13714      361505 :                                 rowToUnqObjName(countRow) = mUnqObjNames;
   13715             :                             }
   13716             :                         }
   13717             :                         // set column headings
   13718       69406 :                         int countColumn = 0;
   13719    60717970 :                         for (int kColumnTag = 1; kColumnTag <= state.dataOutRptPredefined->numColumnTag; ++kColumnTag) {
   13720    60648564 :                             if (state.dataOutRptPredefined->columnTag(kColumnTag).indexSubTable == jSubTable) {
   13721      612582 :                                 ++countColumn;
   13722             :                                 // do the unit conversions
   13723      612582 :                                 std::string const &colTagWithSI = state.dataOutRptPredefined->columnTag(kColumnTag).heading;
   13724             :                                 int indexUnitConv;
   13725      612582 :                                 std::string curColTag;
   13726      612582 :                                 if (unitsStyle_cur == UnitsStyle::InchPound) {
   13727        9862 :                                     LookupSItoIP(state, colTagWithSI, indexUnitConv, curColTag);
   13728        9862 :                                     colUnitConv(countColumn) = indexUnitConv;
   13729      602720 :                                 } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   13730           0 :                                     LookupSItoIP(state, colTagWithSI, indexUnitConv, curColTag);
   13731           0 :                                     colUnitConv(countColumn) = indexUnitConv;
   13732      602720 :                                 } else if (unitsStyle_cur == UnitsStyle::JtoKWH) {
   13733        5472 :                                     LookupJtokWH(state, colTagWithSI, indexUnitConv, curColTag);
   13734        5472 :                                     colUnitConv(countColumn) = indexUnitConv;
   13735             :                                 } else {
   13736      597248 :                                     curColTag = colTagWithSI;
   13737      597248 :                                     colUnitConv(countColumn) = 0;
   13738             :                                 }
   13739      612582 :                                 columnHead(countColumn) = curColTag;
   13740      612582 :                                 colHeadToColTag(countColumn) = kColumnTag;
   13741      612582 :                             }
   13742             :                         }
   13743             :                         // fill the body of the table from the entries
   13744             :                         // find the entries associated with the current subtable
   13745   318456401 :                         for (int lTableEntry = 1; lTableEntry <= state.dataOutRptPredefined->numTableEntry; ++lTableEntry) {
   13746   318386995 :                             if (state.dataOutRptPredefined->tableEntry(lTableEntry).subTableIndex == jSubTable) {
   13747             :                                 // determine what column the current entry is in
   13748     3105526 :                                 int const curColTagIndex = state.dataOutRptPredefined->tableEntry(lTableEntry).indexColumn;
   13749    36190968 :                                 for (int nColHead = 1; nColHead <= curNumColumns; ++nColHead) {
   13750    36190968 :                                     if (curColTagIndex == colHeadToColTag(nColHead)) {
   13751     3105526 :                                         colCurrent = nColHead;
   13752     3105526 :                                         break;
   13753             :                                     }
   13754             :                                 }
   13755             :                                 // determine what row the current entry is in
   13756     3105526 :                                 int const curRowUnqObjIndex = state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName;
   13757    91154655 :                                 for (int oRowHead = 1; oRowHead <= curNumRows; ++oRowHead) {
   13758    91154655 :                                     if (curRowUnqObjIndex == rowToUnqObjName(oRowHead)) {
   13759     3105526 :                                         rowCurrent = oRowHead;
   13760     3105526 :                                         break;
   13761             :                                     }
   13762             :                                 }
   13763             :                                 // finally assign the entry to the place in the table body
   13764     3105526 :                                 if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13765     3062223 :                                     unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity ||
   13766     3062223 :                                     unitsStyle_cur == UnitsStyle::JtoKWH) {
   13767       67324 :                                     int columnUnitConv = colUnitConv(colCurrent);
   13768       67624 :                                     if (Util::SameString(state.dataOutRptPredefined->subTable(jSubTable).name, "SizingPeriod:DesignDay") &&
   13769         300 :                                         (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13770          72 :                                          unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   13771         228 :                                         if (Util::SameString(columnHead(colCurrent), "Humidity Value")) {
   13772          38 :                                             std::string repTableTag;
   13773          38 :                                             LookupSItoIP(state,
   13774          38 :                                                          state.dataOutRptPredefined->tableEntry(lTableEntry + 1).charEntry,
   13775             :                                                          columnUnitConv,
   13776             :                                                          repTableTag);
   13777          38 :                                             state.dataOutRptPredefined->tableEntry(lTableEntry + 1).charEntry = repTableTag;
   13778          38 :                                         }
   13779             :                                     }
   13780       67324 :                                     if (state.dataOutRptPredefined->tableEntry(lTableEntry).origEntryIsReal && (columnUnitConv != 0)) {
   13781             :                                         Real64 const IPvalue =
   13782       30612 :                                             ConvertIP(state, columnUnitConv, state.dataOutRptPredefined->tableEntry(lTableEntry).origRealEntry);
   13783       30612 :                                         tableBody(colCurrent, rowCurrent) =
   13784       61224 :                                             RealToStr(IPvalue, state.dataOutRptPredefined->tableEntry(lTableEntry).significantDigits);
   13785             :                                     } else {
   13786       36712 :                                         tableBody(colCurrent, rowCurrent) = state.dataOutRptPredefined->tableEntry(lTableEntry).charEntry;
   13787             :                                     }
   13788       67324 :                                 } else {
   13789     3038202 :                                     tableBody(colCurrent, rowCurrent) = state.dataOutRptPredefined->tableEntry(lTableEntry).charEntry;
   13790             :                                 }
   13791             :                             }
   13792             :                         }
   13793             :                         // create the actual output table
   13794       69406 :                         if (produceTabular) {
   13795       69406 :                             WriteSubtitle(state, state.dataOutRptPredefined->subTable(jSubTable).name);
   13796       69406 :                             WriteTable(
   13797       69406 :                                 state, tableBody, rowHead, columnHead, columnWidth, false, state.dataOutRptPredefined->subTable(jSubTable).footnote);
   13798             :                         }
   13799       69406 :                         if (produceSQLite) {
   13800       69406 :                             if (state.dataSQLiteProcedures->sqlite) {
   13801       27513 :                                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13802             :                                     tableBody,
   13803             :                                     rowHead,
   13804             :                                     columnHead,
   13805        9171 :                                     state.dataOutRptPredefined->reportName(iReportName).name,
   13806             :                                     "Entire Facility",
   13807        9171 :                                     state.dataOutRptPredefined->subTable(jSubTable).name);
   13808             :                             }
   13809             :                         }
   13810       69406 :                         if (produceTabular) {
   13811       69406 :                             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13812        1956 :                                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13813             :                                     tableBody,
   13814             :                                     rowHead,
   13815             :                                     columnHead,
   13816         652 :                                     state.dataOutRptPredefined->reportName(iReportName).name,
   13817             :                                     "Entire Facility",
   13818         652 :                                     state.dataOutRptPredefined->subTable(jSubTable).name);
   13819             :                             }
   13820             :                         }
   13821             :                     }
   13822             :                 }
   13823             :             }
   13824             :         }
   13825             :     }
   13826         754 : }
   13827             : 
   13828         754 : void WriteComponentSizing(EnergyPlusData &state)
   13829             : {
   13830             :     // SUBROUTINE INFORMATION:
   13831             :     //       AUTHOR         Jason Glazer
   13832             :     //       DATE WRITTEN   July 2007
   13833             :     //       MODIFIED       January 2010, Kyle Benne
   13834             :     //                      Added SQLite output
   13835             :     //       RE-ENGINEERED  na
   13836             : 
   13837             :     // PURPOSE OF THIS SUBROUTINE:
   13838             :     //   Write out tables based on component sizing data originally
   13839             :     //   found in the EIO report.
   13840             : 
   13841             :     // METHODOLOGY EMPLOYED:
   13842             :     //   Create arrays for the call to WriteTable and then call it.
   13843             :     //   The tables created do not have known headers for rows or
   13844             :     //   columns so those are determined based on what calls have
   13845             :     //   been made to the Sizer routine.  A table
   13846             :     //   is created for each type of component. Columns are created
   13847             :     //   for each description within that table. Rows are created
   13848             :     //   for each named object.
   13849             : 
   13850         754 :     auto const &ort = state.dataOutRptTab;
   13851         754 :     if (!ort->displayComponentSizing) {
   13852          22 :         return;
   13853             :     }
   13854             : 
   13855             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   13856             :     // all arrays are in the format: (row, column)
   13857         732 :     Array1D_string columnHead;
   13858         732 :     Array1D_int columnWidth;
   13859         732 :     Array1D_int colUnitConv;
   13860         732 :     Array1D_string rowHead;
   13861         732 :     Array2D_string tableBody;
   13862         732 :     Array1D_string uniqueDesc;
   13863         732 :     Array1D_string uniqueObj;
   13864             :     int numUniqueObj;
   13865         732 :     std::string curDesc;
   13866         732 :     std::string curObj;
   13867             :     int foundEntry;
   13868             :     int foundDesc;
   13869             :     int foundObj;
   13870             :     int iTableEntry;
   13871             :     int jUnique;
   13872             : 
   13873         732 :     WriteReportHeaders(state, "Component Sizing Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   13874             : 
   13875        1464 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   13876        1464 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13877        1464 :         bool produceTabular = true;
   13878        1464 :         bool produceSQLite = false;
   13879        1464 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   13880             : 
   13881             :         // The arrays that look for unique headers are dimensioned in the
   13882             :         // running program since the size of the number of entries is
   13883             :         // not previously known. Use the size of all entries since that
   13884             :         // is the maximum possible.
   13885         732 :         uniqueDesc.allocate(state.dataOutRptPredefined->numCompSizeTableEntry);
   13886         732 :         uniqueObj.allocate(state.dataOutRptPredefined->numCompSizeTableEntry);
   13887             :         // initially clear the written flags for entire array
   13888             :         // The following line is not really necessary and it is possible that the array has
   13889             :         // not been allocated when this is first called.
   13890             :         //  CompSizeTableEntry%written = .FALSE.
   13891             :         // repeat the following loop until everything in array has been
   13892             :         // written into a table
   13893         732 :         int loopLimit = 0;
   13894        6557 :         while (loopLimit <= 100) { // put a maximum count since complex loop that could run indefinitely if error
   13895        6557 :             foundEntry = 0;
   13896        6557 :             ++loopLimit;
   13897      649066 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   13898      648334 :                 if (!state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).written) {
   13899        5825 :                     foundEntry = iTableEntry;
   13900        5825 :                     break;
   13901             :                 }
   13902             :             }
   13903        6557 :             if (foundEntry == 0) break; // leave main loop - all items put into tables
   13904             :             // clear active items
   13905     1456525 :             for (auto &e : state.dataOutRptPredefined->CompSizeTableEntry)
   13906     1450700 :                 e.active = false;
   13907             :             // make an unwritten item that is of the same type active - these will be the
   13908             :             // entries for the particular subtable.
   13909      951151 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   13910      945326 :                 if (!state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).written) {
   13911      296100 :                     if (Util::SameString(state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).typeField,
   13912      296100 :                                          state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField)) {
   13913       71215 :                         state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).active = true;
   13914             :                     }
   13915             :                 }
   13916             :             }
   13917             :             // identify unique descriptions and objects (columns and rows) in order
   13918             :             // to size the table arrays properly.
   13919             :             // reset the counters for the arrays looking for unique rows and columns
   13920        5825 :             int numUniqueDesc = 0;
   13921        5825 :             numUniqueObj = 0;
   13922      951151 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   13923             :                 // search for descriptions
   13924      945326 :                 foundDesc = 0;
   13925      945326 :                 if (state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).active) {
   13926       71215 :                     curDesc = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).description;
   13927             :                     // look through the list of unique items to see if it matches
   13928      261846 :                     for (jUnique = 1; jUnique <= numUniqueDesc; ++jUnique) {
   13929      240357 :                         if (Util::SameString(curDesc, uniqueDesc(jUnique))) {
   13930       49726 :                             foundDesc = jUnique;
   13931       49726 :                             break;
   13932             :                         }
   13933             :                     }
   13934             :                     // if not found add to the list
   13935       71215 :                     if (foundDesc == 0) {
   13936       21489 :                         ++numUniqueDesc;
   13937       21489 :                         uniqueDesc(numUniqueDesc) = curDesc;
   13938             :                     }
   13939             :                     // search for objects
   13940       71215 :                     foundObj = 0;
   13941       71215 :                     curObj = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).nameField;
   13942      826572 :                     for (jUnique = 1; jUnique <= numUniqueObj; ++jUnique) {
   13943      808416 :                         if (Util::SameString(curObj, uniqueObj(jUnique))) {
   13944       53059 :                             foundObj = jUnique;
   13945       53059 :                             break;
   13946             :                         }
   13947             :                     }
   13948             :                     // if not found add to the list
   13949       71215 :                     if (foundObj == 0) {
   13950       18156 :                         ++numUniqueObj;
   13951       18156 :                         uniqueObj(numUniqueObj) = curObj;
   13952             :                     }
   13953             :                 }
   13954             :             }
   13955             :             // make sure the table has at least one row and columns
   13956        5825 :             if (numUniqueDesc == 0) numUniqueDesc = 1;
   13957        5825 :             if (numUniqueObj == 0) numUniqueObj = 1;
   13958             :             // now that the unique row and column headers are known the array
   13959             :             // sizes can be set for the table arrays
   13960        5825 :             rowHead.allocate(numUniqueObj);
   13961        5825 :             columnHead.allocate(numUniqueDesc);
   13962        5825 :             columnWidth.dimension(numUniqueDesc, 14); // array assignment - same for all columns
   13963        5825 :             colUnitConv.allocate(numUniqueDesc);
   13964        5825 :             tableBody.allocate(numUniqueDesc, numUniqueObj);
   13965             :             // initialize table body to blanks (in case entries are incomplete)
   13966        5825 :             tableBody = "";
   13967             :             // transfer the row and column headings first
   13968       27314 :             for (jUnique = 1; jUnique <= numUniqueDesc; ++jUnique) {
   13969             :                 // do the unit conversions
   13970       21489 :                 state.dataOutRptTab->curColHeadWithSI = uniqueDesc(jUnique);
   13971       21489 :                 if (unitsStyle_cur == UnitsStyle::InchPound) {
   13972         362 :                     LookupSItoIP(
   13973         362 :                         state, state.dataOutRptTab->curColHeadWithSI, state.dataOutRptTab->indexUnitConvWCS, state.dataOutRptTab->curColHead);
   13974         362 :                     colUnitConv(jUnique) = state.dataOutRptTab->indexUnitConvWCS;
   13975       21127 :                 } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   13976           0 :                     LookupSItoIP(
   13977           0 :                         state, state.dataOutRptTab->curColHeadWithSI, state.dataOutRptTab->indexUnitConvWCS, state.dataOutRptTab->curColHead);
   13978           0 :                     colUnitConv(jUnique) = state.dataOutRptTab->indexUnitConvWCS;
   13979             :                 } else {
   13980       21127 :                     state.dataOutRptTab->curColHead = state.dataOutRptTab->curColHeadWithSI;
   13981       21127 :                     colUnitConv(jUnique) = 0;
   13982             :                 }
   13983       21489 :                 columnHead(jUnique) = state.dataOutRptTab->curColHead;
   13984             :             }
   13985       23981 :             for (jUnique = 1; jUnique <= numUniqueObj; ++jUnique) {
   13986       18156 :                 rowHead(jUnique) = uniqueObj(jUnique);
   13987             :             }
   13988             :             // fill the table
   13989      951151 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   13990             :                 // find the row and column for the specific entry
   13991      945326 :                 if (state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).active) {
   13992       71215 :                     curDesc = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).description;
   13993       71215 :                     foundDesc = 0;
   13994      261846 :                     for (jUnique = 1; jUnique <= numUniqueDesc; ++jUnique) {
   13995      261846 :                         if (Util::SameString(uniqueDesc(jUnique), curDesc)) {
   13996       71215 :                             foundDesc = jUnique;
   13997       71215 :                             break;
   13998             :                         }
   13999             :                     }
   14000       71215 :                     curObj = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).nameField;
   14001       71215 :                     foundObj = 0;
   14002      826572 :                     for (jUnique = 1; jUnique <= numUniqueObj; ++jUnique) {
   14003      826572 :                         if (Util::SameString(rowHead(jUnique), curObj)) {
   14004       71215 :                             foundObj = jUnique;
   14005       71215 :                             break;
   14006             :                         }
   14007             :                     }
   14008       71215 :                     if ((foundDesc >= 1) && (foundObj >= 1)) {
   14009       71215 :                         state.dataOutRptTab->curValueSIWCS = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).valField;
   14010       71215 :                         if (unitsStyle_cur == UnitsStyle::InchPound) {
   14011         639 :                             if (colUnitConv(foundDesc) != 0) {
   14012         567 :                                 state.dataOutRptTab->curValueWCS = ConvertIP(state, colUnitConv(foundDesc), state.dataOutRptTab->curValueSIWCS);
   14013             :                             } else {
   14014          72 :                                 state.dataOutRptTab->curValueWCS = state.dataOutRptTab->curValueSIWCS;
   14015             :                             }
   14016       70576 :                         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   14017           0 :                             if (colUnitConv(foundDesc) != 0) {
   14018           0 :                                 state.dataOutRptTab->curValueWCS = ConvertIP(state, colUnitConv(foundDesc), state.dataOutRptTab->curValueSIWCS);
   14019             :                             } else {
   14020           0 :                                 state.dataOutRptTab->curValueWCS = state.dataOutRptTab->curValueSIWCS;
   14021             :                             }
   14022             :                         } else {
   14023       70576 :                             state.dataOutRptTab->curValueWCS = state.dataOutRptTab->curValueSIWCS;
   14024             :                         }
   14025       71215 :                         if (std::abs(state.dataOutRptTab->curValueWCS) >= 1.0) {
   14026       31228 :                             tableBody(foundDesc, foundObj) = RealToStr(state.dataOutRptTab->curValueWCS, 2);
   14027             :                         } else {
   14028       39987 :                             tableBody(foundDesc, foundObj) = RealToStr(state.dataOutRptTab->curValueWCS, 6);
   14029             :                         }
   14030       71215 :                         state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).written = true;
   14031             :                     }
   14032             :                 }
   14033             :             }
   14034             :             // write the table
   14035        5825 :             if (produceTabular) {
   14036        5825 :                 WriteSubtitle(state, state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField);
   14037             :             }
   14038             : 
   14039       11445 :             if (state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField == "AirTerminal:SingleDuct:VAV:Reheat" ||
   14040        5620 :                 state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField == "AirTerminal:SingleDuct:VAV:NoReheat") {
   14041         232 :                 if (produceTabular) {
   14042         232 :                     WriteTable(state,
   14043             :                                tableBody,
   14044             :                                rowHead,
   14045             :                                columnHead,
   14046             :                                columnWidth,
   14047             :                                false,
   14048             :                                "User-Specified values were used. Design Size values were used if no User-Specified values were provided. "
   14049             :                                "Design Size "
   14050             :                                "values may be derived from alternate User-Specified values.");
   14051             :                 }
   14052             :             } else {
   14053        5593 :                 if (produceTabular) {
   14054        5593 :                     WriteTable(state,
   14055             :                                tableBody,
   14056             :                                rowHead,
   14057             :                                columnHead,
   14058             :                                columnWidth,
   14059             :                                false,
   14060             :                                "User-Specified values were used. Design Size values were used if no User-Specified values were provided.");
   14061             :                 }
   14062             :             }
   14063             : 
   14064        5825 :             if (produceSQLite) {
   14065        5825 :                 if (state.dataSQLiteProcedures->sqlite) {
   14066        2158 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14067             :                         tableBody,
   14068             :                         rowHead,
   14069             :                         columnHead,
   14070             :                         "ComponentSizingSummary",
   14071             :                         "Entire Facility",
   14072        1079 :                         state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField);
   14073             :                 }
   14074             :             }
   14075        5825 :             if (produceTabular) {
   14076        5825 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14077         144 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14078             :                         tableBody,
   14079             :                         rowHead,
   14080             :                         columnHead,
   14081             :                         "ComponentSizingSummary",
   14082             :                         "Entire Facility",
   14083          72 :                         state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField,
   14084             :                         "User-Specified values were used. Design Size values were used if no User-Specified values were provided.");
   14085             :                 }
   14086             :             }
   14087             :         }
   14088             :     }
   14089         732 : }
   14090             : 
   14091         754 : void WriteSurfaceShadowing(EnergyPlusData &state)
   14092             : {
   14093             :     // SUBROUTINE INFORMATION:
   14094             :     //       AUTHOR         Jason Glazer
   14095             :     //       DATE WRITTEN   July 2007
   14096             :     //       MODIFIED       January 2010, Kyle Benne
   14097             :     //                      Added SQLite output
   14098             :     //       RE-ENGINEERED  June 2014, Stuart Mentzer, Performance tuning
   14099             : 
   14100             :     // PURPOSE OF THIS SUBROUTINE:
   14101             :     //   Write out tables based on which surfaces shade subsurfaces.
   14102             : 
   14103             :     // METHODOLOGY EMPLOYED:
   14104             :     //   Create arrays for the call to WriteTable and then call it.
   14105             :     //   Use <br> tag to put multiple rows into a single cell.
   14106             : 
   14107             :     // Using/Aliasing
   14108             :     using namespace DataShadowingCombinations;
   14109             : 
   14110         754 :     auto &ort = state.dataOutRptTab;
   14111             : 
   14112             :     // displaySurfaceShadowing = false  for debugging
   14113         754 :     if (!ort->displaySurfaceShadowing) {
   14114          82 :         return;
   14115             :     }
   14116             : 
   14117             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14118             :     // all arrays are in the format: (row, column)
   14119         672 :     Array1D_string columnHead(1);
   14120         672 :     Array1D_int columnWidth(1);
   14121         672 :     Array1D_string rowHead;
   14122         672 :     Array2D_string tableBody;
   14123         672 :     Array1D_int unique;
   14124             : 
   14125         672 :     int numreceivingfields = 0;
   14126       32528 :     for (int HTS = 1; HTS <= state.dataSurface->TotSurfaces; ++HTS) {
   14127       31856 :         numreceivingfields += state.dataShadowComb->ShadowComb(HTS).NumGenSurf;
   14128       31856 :         numreceivingfields += state.dataShadowComb->ShadowComb(HTS).NumSubSurf;
   14129             :     }
   14130             : 
   14131         672 :     state.dataOutRptPredefined->ShadowRelate.allocate(numreceivingfields);
   14132         672 :     state.dataOutRptPredefined->numShadowRelate = 0;
   14133       32528 :     for (int HTS = 1; HTS <= state.dataSurface->TotSurfaces; ++HTS) {
   14134       53024 :         for (int NGSS = 1; NGSS <= state.dataShadowComb->ShadowComb(HTS).NumGenSurf; ++NGSS) {
   14135       21168 :             ++state.dataOutRptPredefined->numShadowRelate;
   14136       21168 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).castSurf =
   14137       21168 :                 state.dataShadowComb->ShadowComb(HTS).GenSurf(NGSS);
   14138       21168 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recSurf = HTS;
   14139       21168 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recKind = recKindSurface;
   14140             :         }
   14141       36420 :         for (int NGSS = 1; NGSS <= state.dataShadowComb->ShadowComb(HTS).NumSubSurf; ++NGSS) {
   14142        4564 :             ++state.dataOutRptPredefined->numShadowRelate;
   14143        4564 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).castSurf =
   14144        4564 :                 state.dataShadowComb->ShadowComb(HTS).SubSurf(NGSS);
   14145        4564 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recSurf = HTS;
   14146        4564 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recKind = recKindSubsurface;
   14147             :         }
   14148             :     }
   14149         672 :     assert(numreceivingfields == state.dataOutRptPredefined->numShadowRelate);
   14150             : 
   14151         672 :     WriteReportHeaders(state, "Surface Shadowing Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   14152         672 :     unique.allocate(state.dataOutRptPredefined->numShadowRelate);
   14153             :     // do entire process twice, once with surfaces receiving, once with subsurfaces receiving
   14154        2016 :     for (int iKindRec = recKindSurface; iKindRec <= recKindSubsurface; ++iKindRec) {
   14155             : 
   14156             :         // Build map from receiving surface to container of names
   14157             :         typedef std::map<int, std::pair<int, std::vector<std::string const *>>> ShadowMap;
   14158        1344 :         ShadowMap shadow_map;
   14159       52808 :         for (int iShadRel = 1; iShadRel <= state.dataOutRptPredefined->numShadowRelate; ++iShadRel) {
   14160       51464 :             if (state.dataOutRptPredefined->ShadowRelate(iShadRel).recKind == iKindRec) {
   14161       25732 :                 int const curRecSurf = state.dataOutRptPredefined->ShadowRelate(iShadRel).recSurf;
   14162       25732 :                 std::string const &name(state.dataSurface->Surface(state.dataOutRptPredefined->ShadowRelate(iShadRel).castSurf).Name);
   14163       25732 :                 auto &elem(shadow_map[curRecSurf]);            // Creates the entry if not present (and zero-initializes the int in the pair)
   14164       25732 :                 elem.first += static_cast<int>(name.length()); // Accumulate total of name lengths
   14165       25732 :                 elem.second.push_back(&name);                  // Add this name
   14166             :             }
   14167             :         }
   14168        1344 :         int const numUnique = static_cast<int>(shadow_map.size());
   14169        1344 :         if (numUnique == 0) {
   14170         264 :             columnHead(1) = "None";
   14171             :         } else {
   14172        1080 :             columnHead(1) = "Possible Shadow Receivers";
   14173             :         }
   14174        1344 :         columnWidth = 14; // array assignment - same for all columns
   14175        1344 :         rowHead.allocate(numUnique);
   14176        1344 :         tableBody.allocate(1, numUnique);
   14177        1344 :         int jUnique = 0;
   14178        7643 :         for (auto const &elem : shadow_map) {
   14179        6299 :             ++jUnique;
   14180        6299 :             int const curRecSurf = elem.first;
   14181        6299 :             rowHead(jUnique) = state.dataSurface->Surface(curRecSurf).Name;
   14182             : 
   14183        6299 :             std::string listOfSurf;
   14184        6299 :             listOfSurf.reserve(elem.second.first + (3 * numUnique)); // To avoid string allocations during appends
   14185       32031 :             for (auto const *p : elem.second.second) {
   14186       25732 :                 listOfSurf += *p;
   14187       25732 :                 listOfSurf += " | "; //'<br>' // Separate append to avoid string temporary
   14188        6299 :             }
   14189        6299 :             tableBody(1, jUnique) = listOfSurf;
   14190        7643 :         }
   14191             : 
   14192             :         // write the table
   14193        1344 :         if (iKindRec == recKindSurface) {
   14194         672 :             WriteSubtitle(state, "Surfaces (Walls, Roofs, etc) that may be Shadowed by Other Surfaces");
   14195         672 :             if (state.dataSQLiteProcedures->sqlite) {
   14196          73 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14197             :                     tableBody,
   14198             :                     rowHead,
   14199             :                     columnHead,
   14200             :                     "SurfaceShadowingSummary",
   14201             :                     "Entire Facility",
   14202             :                     "Surfaces (Walls, Roofs, etc) that may be Shadowed by Other Surfaces");
   14203             :             }
   14204         672 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14205           6 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14206             :                     tableBody,
   14207             :                     rowHead,
   14208             :                     columnHead,
   14209             :                     "SurfaceShadowingSummary",
   14210             :                     "Entire Facility",
   14211             :                     "Surfaces (Walls, Roofs, etc) that may be Shadowed by Other Surfaces");
   14212             :             }
   14213         672 :         } else if (iKindRec == recKindSubsurface) {
   14214         672 :             WriteSubtitle(state, "Subsurfaces (Windows and Doors) that may be Shadowed by Surfaces");
   14215         672 :             if (state.dataSQLiteProcedures->sqlite) {
   14216          73 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14217             :                     tableBody,
   14218             :                     rowHead,
   14219             :                     columnHead,
   14220             :                     "SurfaceShadowingSummary",
   14221             :                     "Entire Facility",
   14222             :                     "Subsurfaces (Windows and Doors) that may be Shadowed by Surfaces");
   14223             :             }
   14224         672 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14225           6 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14226             :                     tableBody,
   14227             :                     rowHead,
   14228             :                     columnHead,
   14229             :                     "SurfaceShadowingSummary",
   14230             :                     "Entire Facility",
   14231             :                     "Subsurfaces (Windows and Doors) that may be Shadowed by Surfaces");
   14232             :             }
   14233             :         }
   14234        1344 :         WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   14235        1344 :     }
   14236         672 : }
   14237             : 
   14238             : // Parses the contents of the EIO (initializations) file and creates subtables for each type of record in the tabular output files
   14239             : // Glazer - November 2016
   14240         754 : void WriteEioTables(EnergyPlusData &state)
   14241             : {
   14242             : 
   14243         754 :     auto const &ort = state.dataOutRptTab;
   14244             : 
   14245         754 :     if (!ort->displayEioSummary) {
   14246          81 :         return;
   14247             :     }
   14248             : 
   14249         673 :     Array1D_string columnHead;
   14250         673 :     Array1D_int columnWidth;
   14251         673 :     Array1D_string rowHead;
   14252         673 :     Array2D_string tableBody; // in the format: (row, column)
   14253         673 :     Array1D_int colUnitConv;
   14254             : 
   14255             :     // setting up  report header
   14256         673 :     WriteReportHeaders(state, "Initialization Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   14257             : 
   14258         673 :     std::vector<std::string> headerLines; // holds the lines that describe each type of records - each starts with ! symbol
   14259         673 :     std::vector<std::string> bodyLines;   // holds the data records only
   14260      217807 :     for (auto const &line : state.files.eio.getLines()) {
   14261      217134 :         if (line.at(0) == '!') {
   14262       38087 :             headerLines.push_back(line);
   14263             :         } else {
   14264      179047 :             if (line.at(0) == ' ') {
   14265      127184 :                 bodyLines.push_back(line.substr(1)); // remove leading space
   14266             :             } else {
   14267       51863 :                 bodyLines.push_back(line);
   14268             :             }
   14269             :         }
   14270         673 :     }
   14271             : 
   14272        1346 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   14273        1346 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   14274        1346 :         bool produceTabular = true;
   14275        1346 :         bool produceSQLite = false;
   14276        1346 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   14277             : 
   14278             :         // now go through each header and create a report for each one
   14279       38760 :         for (std::string const &headerLine : headerLines) {
   14280       38087 :             std::vector<std::string> headerFields = splitCommaString(headerLine);
   14281       38087 :             std::string tableNameWithSigns = headerFields.at(0);
   14282             :             std::string tableName =
   14283       38087 :                 tableNameWithSigns.substr(3, tableNameWithSigns.size() - 4); // get rid of the '! <' from the beginning and the '>' from the end
   14284             :             // first count the number of matching lines
   14285       38087 :             int countOfMatchingLines = 0;
   14286    11619603 :             for (std::string const &bodyLine : bodyLines) {
   14287    11581516 :                 if (bodyLine.size() > tableName.size()) {
   14288    11294247 :                     if (bodyLine.substr(0, tableName.size() + 1) ==
   14289    22588494 :                         tableName + ",") { // this needs to match the test used to populate the body of table below
   14290      177240 :                         ++countOfMatchingLines;
   14291             :                     }
   14292             :                 }
   14293       38087 :             }
   14294       38087 :             int numRows = countOfMatchingLines;
   14295       38087 :             int numCols = headerFields.size() - 1;
   14296             : 
   14297       38087 :             if (numRows >= 1) {
   14298       36681 :                 rowHead.allocate(numRows);
   14299       36681 :                 columnHead.allocate(numCols);
   14300       36681 :                 columnWidth.allocate(numCols);
   14301       36681 :                 columnWidth = 14; // array assignment - same for all columns
   14302       36681 :                 tableBody.allocate(numCols, numRows);
   14303       36681 :                 tableBody = ""; // make sure everything is blank
   14304       36681 :                 colUnitConv.allocate(numCols);
   14305             :                 // transfer the header row into column headings
   14306      310672 :                 for (int iCol = 1; iCol <= numCols; ++iCol) {
   14307      273991 :                     columnHead(iCol) = headerFields.at(iCol);
   14308             :                     // set the unit conversions
   14309             :                     // colUnitConv(iCol) = unitsFromHeading(state, columnHead(iCol));
   14310             :                     // Jan 2021: use overloaded version for dual units
   14311      273991 :                     colUnitConv(iCol) = unitsFromHeading(state, columnHead(iCol), unitsStyle_cur);
   14312             :                 }
   14313             :                 // look for data lines
   14314       36681 :                 int rowNum = 0;
   14315    10978435 :                 for (std::string const &bodyLine : bodyLines) {
   14316    10941754 :                     if (bodyLine.size() > tableName.size()) {
   14317    10660812 :                         if (bodyLine.substr(0, tableName.size() + 1) ==
   14318    21321624 :                             tableName + ",") { // this needs to match the test used in the original counting
   14319      177240 :                             ++rowNum;
   14320      177240 :                             if (rowNum > countOfMatchingLines) break; // should never happen since same test as original could
   14321      177240 :                             std::vector<std::string> dataFields = splitCommaString(bodyLine);
   14322      177240 :                             rowHead(rowNum) = fmt::to_string(rowNum);
   14323     1937270 :                             for (int iCol = 1; iCol <= numCols && iCol < int(dataFields.size()); ++iCol) {
   14324     1760030 :                                 if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   14325     1741442 :                                     unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity ||
   14326     1741442 :                                     unitsStyle_cur == UnitsStyle::JtoKWH) {
   14327       28400 :                                     if (isNumber(dataFields[iCol]) && colUnitConv(iCol) > 0) { // if it is a number that has a conversion
   14328        6312 :                                         int numDecimalDigits = digitsAferDecimal(dataFields[iCol]);
   14329        6312 :                                         Real64 convertedVal = ConvertIP(state, colUnitConv(iCol), StrToReal(dataFields[iCol]));
   14330        6312 :                                         tableBody(iCol, rowNum) = RealToStr(convertedVal, numDecimalDigits);
   14331       22088 :                                     } else if (iCol == numCols && columnHead(iCol) == "Value" && iCol > 1) { // if it is the last column and the
   14332             :                                                                                                              // header is Value then treat the
   14333             :                                                                                                              // previous column as source of units
   14334             :                                         // int indexUnitConv =
   14335             :                                         //    unitsFromHeading(state, tableBody(iCol - 1, rowNum)); // base units on previous column
   14336             :                                         // Jan 2021: use overloaded version for dual units
   14337             :                                         int indexUnitConv =
   14338        1138 :                                             unitsFromHeading(state, tableBody(iCol - 1, rowNum), unitsStyle_cur); // base units on previous column
   14339             : 
   14340        1138 :                                         int numDecimalDigits = digitsAferDecimal(dataFields[iCol]);
   14341        1138 :                                         Real64 convertedVal = ConvertIP(state, indexUnitConv, StrToReal(dataFields[iCol]));
   14342        1138 :                                         tableBody(iCol, rowNum) = RealToStr(convertedVal, numDecimalDigits);
   14343             :                                     } else {
   14344       20950 :                                         tableBody(iCol, rowNum) = dataFields[iCol];
   14345             :                                     }
   14346       28400 :                                 } else {
   14347     1731630 :                                     tableBody(iCol, rowNum) = dataFields[iCol];
   14348             :                                 }
   14349             :                             }
   14350      177240 :                         }
   14351             :                     }
   14352       36681 :                 }
   14353             : 
   14354       36681 :                 if (produceTabular) {
   14355       36681 :                     WriteSubtitle(state, tableName);
   14356       36681 :                     std::string footnote;
   14357       36681 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, footnote);
   14358       36681 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14359         171 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14360             :                             tableBody, rowHead, columnHead, "InitializationSummary", "Entire Facility", tableName);
   14361             :                     }
   14362       36681 :                 }
   14363       36681 :                 if (produceSQLite) {
   14364       36681 :                     if (state.dataSQLiteProcedures->sqlite) {
   14365        3893 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14366             :                             tableBody, rowHead, columnHead, "InitializationSummary", "Entire Facility", tableName);
   14367             :                     }
   14368             :                 }
   14369             :             }
   14370       38760 :         }
   14371             :     }
   14372             : 
   14373             :     // as of Oct 2016 only the <Program Control Information:Threads/Parallel Sims> section is written after this point
   14374         673 : }
   14375             : 
   14376             : // changes the heading that contains and SI to IP as well as providing the unit conversion index
   14377             : // Glazer Nov 2016
   14378           0 : int unitsFromHeading(EnergyPlusData &state, std::string &heading)
   14379             : {
   14380           0 :     auto const &ort = state.dataOutRptTab;
   14381             : 
   14382           0 :     std::string curHeading;
   14383           0 :     int unitConv = 0;
   14384           0 :     if (ort->unitsStyle == UnitsStyle::InchPound) {
   14385           0 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14386           0 :     } else if (ort->unitsStyle == UnitsStyle::InchPoundExceptElectricity) {
   14387           0 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14388           0 :     } else if (ort->unitsStyle == UnitsStyle::JtoKWH) {
   14389           0 :         LookupJtokWH(state, heading, unitConv, curHeading);
   14390             :     } else {
   14391           0 :         curHeading = heading;
   14392             :     }
   14393           0 :     heading = curHeading;
   14394           0 :     return (unitConv);
   14395           0 : }
   14396             : 
   14397             : // Jan 2021: Overloaded this function to accomondate dual units output needs
   14398             : // changes the heading that contains and SI to IP as well as providing the unit conversion index
   14399             : // Glazer Nov 2016
   14400      275129 : int unitsFromHeading(EnergyPlusData &state, std::string &heading, UnitsStyle unitsStyle_para)
   14401             : {
   14402      275129 :     std::string curHeading = "";
   14403      275129 :     int unitConv = 0;
   14404      275129 :     if (unitsStyle_para == UnitsStyle::InchPound) {
   14405        5092 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14406      270037 :     } else if (unitsStyle_para == UnitsStyle::InchPoundExceptElectricity) {
   14407           0 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14408      270037 :     } else if (unitsStyle_para == UnitsStyle::JtoKWH) {
   14409        3063 :         LookupJtokWH(state, heading, unitConv, curHeading);
   14410             :     } else {
   14411      266974 :         curHeading = heading;
   14412             :     }
   14413      275129 :     heading = curHeading;
   14414      275129 :     return (unitConv);
   14415      275129 : }
   14416             : 
   14417             : // function that returns a vector of strings when given a string with comma delimitters
   14418             : // Glazer Nov 2016
   14419      215327 : std::vector<std::string> splitCommaString(std::string const &inputString)
   14420             : {
   14421      215327 :     std::vector<std::string> fields;
   14422      215327 :     std::string field;
   14423      215327 :     std::stringstream inputSS(inputString);
   14424     2493651 :     while (std::getline(inputSS, field, ',')) {
   14425     2278324 :         fields.push_back(stripped(field));
   14426             :     }
   14427      430654 :     return fields;
   14428      215327 : }
   14429             : 
   14430         794 : void AddTOCLoadComponentTableSummaries(EnergyPlusData &state)
   14431             : {
   14432             :     // SUBROUTINE INFORMATION:
   14433             :     //       AUTHOR         Jason Glazer
   14434             :     //       DATE WRITTEN   March 2012
   14435             :     //       MODIFIED       na
   14436             :     //       RE-ENGINEERED  na
   14437             : 
   14438             :     // PURPOSE OF THIS SUBROUTINE:
   14439             :     //   Add the table of contents entries for the Zone heat transfer
   14440             :     //   summary report.
   14441             : 
   14442             :     // METHODOLOGY EMPLOYED:
   14443             :     //   Call the AddTOCEntry routine for each zone.
   14444             : 
   14445         794 :     auto const &ort = state.dataOutRptTab;
   14446             : 
   14447         794 :     if (state.dataGlobal->CompLoadReportIsReq) {
   14448          27 :         if (ort->displayZoneComponentLoadSummary) {
   14449         242 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   14450         215 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) continue;
   14451         185 :                 AddTOCEntry(state, "Zone Component Load Summary", state.dataHeatBal->Zone(iZone).Name);
   14452             :             }
   14453             :         }
   14454          27 :         if (ort->displayAirLoopComponentLoadSummary) {
   14455           4 :             for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) {
   14456           2 :                 AddTOCEntry(state, "AirLoop Component Load Summary", state.dataSize->FinalSysSizing(AirLoopNum).AirPriLoopName);
   14457             :             }
   14458             :         }
   14459          27 :         if (ort->displayFacilityComponentLoadSummary) {
   14460           2 :             AddTOCEntry(state, "Facility Component Load Summary", "Facility");
   14461             :         }
   14462             :     }
   14463         794 : }
   14464             : 
   14465      178743 : void AllocateLoadComponentArrays(EnergyPlusData &state)
   14466             : {
   14467             :     // SUBROUTINE INFORMATION:
   14468             :     //       AUTHOR         Jason Glazer
   14469             :     //       DATE WRITTEN   April 2012
   14470             :     //       MODIFIED       na
   14471             :     //       RE-ENGINEERED  na
   14472             : 
   14473             :     // PURPOSE OF THIS SUBROUTINE:
   14474             :     //   Allocate the arrays related to the load component report
   14475             : 
   14476             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14477      178743 :     auto const &ort = state.dataOutRptTab;
   14478             : 
   14479      178743 :     if (!ort->AllocateLoadComponentArraysDoAllocate) {
   14480      178716 :         return;
   14481             :     }
   14482             :     // For many of the following arrays the last dimension is the number of environments and is same as sizing arrays
   14483          27 :     ort->radiantPulseTimestep.allocate({0, state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays}, state.dataGlobal->NumOfZones);
   14484          27 :     ort->radiantPulseTimestep = 0;
   14485          27 :     ort->radiantPulseReceived.allocate({0, state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays}, state.dataSurface->TotSurfaces);
   14486          27 :     ort->radiantPulseReceived = 0.0;
   14487          81 :     ort->loadConvectedNormal.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14488          27 :                                       {0, state.dataGlobal->NumOfTimeStepInHour * 24},
   14489          27 :                                       state.dataSurface->TotSurfaces);
   14490          27 :     ort->loadConvectedNormal = 0.0;
   14491          81 :     ort->loadConvectedWithPulse.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14492          27 :                                          {0, state.dataGlobal->NumOfTimeStepInHour * 24},
   14493          27 :                                          state.dataSurface->TotSurfaces);
   14494          27 :     ort->loadConvectedWithPulse = 0.0;
   14495          81 :     ort->netSurfRadSeq.allocate(
   14496          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces);
   14497          27 :     ort->netSurfRadSeq = 0.0;
   14498          27 :     ort->decayCurveCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces);
   14499          27 :     ort->decayCurveCool = 0.0;
   14500          27 :     ort->decayCurveHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces);
   14501          27 :     ort->decayCurveHeat = 0.0;
   14502          81 :     ort->ITABSFseq.allocate(
   14503          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces);
   14504          27 :     ort->ITABSFseq = 0.0;
   14505          81 :     ort->TMULTseq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14506          27 :                            state.dataGlobal->NumOfTimeStepInHour * 24,
   14507          27 :                            state.dataViewFactor->NumOfRadiantEnclosures);
   14508          27 :     ort->TMULTseq = 0.0;
   14509          81 :     ort->peopleInstantSeq.allocate(
   14510          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14511          27 :     ort->peopleInstantSeq = 0.0;
   14512          81 :     ort->peopleLatentSeq.allocate(
   14513          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14514          27 :     ort->peopleLatentSeq = 0.0;
   14515          81 :     ort->peopleRadSeq.allocate(
   14516          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14517          27 :     ort->peopleRadSeq = 0.0;
   14518          81 :     ort->lightInstantSeq.allocate(
   14519          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14520          27 :     ort->lightInstantSeq = 0.0;
   14521          81 :     ort->lightRetAirSeq.allocate(
   14522          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14523          27 :     ort->lightRetAirSeq = 0.0;
   14524          81 :     ort->lightLWRadSeq.allocate(
   14525          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14526          27 :     ort->lightLWRadSeq = 0.0;
   14527          81 :     ort->lightSWRadSeq.allocate(
   14528          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces);
   14529          27 :     ort->lightSWRadSeq = 0.0;
   14530          81 :     ort->equipInstantSeq.allocate(
   14531          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14532          27 :     ort->equipInstantSeq = 0.0;
   14533          81 :     ort->equipLatentSeq.allocate(
   14534          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14535          27 :     ort->equipLatentSeq = 0.0;
   14536          81 :     ort->equipRadSeq.allocate(
   14537          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14538          27 :     ort->equipRadSeq = 0.0;
   14539          81 :     ort->refrigInstantSeq.allocate(
   14540          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14541          27 :     ort->refrigInstantSeq = 0.0;
   14542          81 :     ort->refrigRetAirSeq.allocate(
   14543          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14544          27 :     ort->refrigRetAirSeq = 0.0;
   14545          81 :     ort->refrigLatentSeq.allocate(
   14546          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14547          27 :     ort->refrigLatentSeq = 0.0;
   14548          81 :     ort->waterUseInstantSeq.allocate(
   14549          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14550          27 :     ort->waterUseInstantSeq = 0.0;
   14551          81 :     ort->waterUseLatentSeq.allocate(
   14552          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14553          27 :     ort->waterUseLatentSeq = 0.0;
   14554          81 :     ort->hvacLossInstantSeq.allocate(
   14555          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14556          27 :     ort->hvacLossInstantSeq = 0.0;
   14557          81 :     ort->hvacLossRadSeq.allocate(
   14558          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14559          27 :     ort->hvacLossRadSeq = 0.0;
   14560          81 :     ort->powerGenInstantSeq.allocate(
   14561          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14562          27 :     ort->powerGenInstantSeq = 0.0;
   14563          81 :     ort->powerGenRadSeq.allocate(
   14564          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14565          27 :     ort->powerGenRadSeq = 0.0;
   14566          81 :     ort->infilInstantSeq.allocate(
   14567          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14568          27 :     ort->infilInstantSeq = 0.0;
   14569          81 :     ort->infilLatentSeq.allocate(
   14570          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14571          27 :     ort->infilLatentSeq = 0.0;
   14572          81 :     ort->zoneVentInstantSeq.allocate(
   14573          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14574          27 :     ort->zoneVentInstantSeq = 0.0;
   14575          81 :     ort->zoneVentLatentSeq.allocate(
   14576          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14577          27 :     ort->zoneVentLatentSeq = 0.0;
   14578          81 :     ort->interZoneMixInstantSeq.allocate(
   14579          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14580          27 :     ort->interZoneMixInstantSeq = 0.0;
   14581          81 :     ort->interZoneMixLatentSeq.allocate(
   14582          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14583          27 :     ort->interZoneMixLatentSeq = 0.0;
   14584          81 :     ort->feneCondInstantSeq.allocate(
   14585          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones);
   14586          27 :     ort->feneCondInstantSeq = 0.0;
   14587          81 :     ort->feneSolarRadSeq.allocate(
   14588          54 :         state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces);
   14589          27 :     ort->feneSolarRadSeq = 0.0;
   14590          27 :     ort->AllocateLoadComponentArraysDoAllocate = false;
   14591             : }
   14592             : 
   14593          27 : void DeallocateLoadComponentArrays(EnergyPlusData &state)
   14594             : {
   14595             :     // SUBROUTINE INFORMATION:
   14596             :     //       AUTHOR         Jason Glazer
   14597             :     //       DATE WRITTEN   August 2012
   14598             :     //       MODIFIED       na
   14599             :     //       RE-ENGINEERED  na
   14600             : 
   14601             :     // PURPOSE OF THIS SUBROUTINE:
   14602             :     //   Deallocate the arrays related to the load component report that will not
   14603             :     //   be needed in the reporting.
   14604             : 
   14605             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14606          27 :     auto const &ort = state.dataOutRptTab;
   14607          27 :     ort->radiantPulseTimestep.deallocate();
   14608          27 :     ort->radiantPulseReceived.deallocate();
   14609          27 :     ort->loadConvectedWithPulse.deallocate();
   14610          27 : }
   14611             : 
   14612          27 : void ComputeLoadComponentDecayCurve(EnergyPlusData &state)
   14613             : {
   14614             : 
   14615             :     // SUBROUTINE INFORMATION:
   14616             :     //       AUTHOR         Jason Glazer
   14617             :     //       DATE WRITTEN   August 2012
   14618             :     //       MODIFIED       na
   14619             :     //       RE-ENGINEERED  na
   14620             : 
   14621             :     // PURPOSE OF THIS SUBROUTINE:
   14622             :     // Determines the load component decay curve based on normal and pulse results from zone sizing.
   14623             : 
   14624             :     // METHODOLOGY EMPLOYED:
   14625             :     // Decay curve is the fraction of the heat convected from a surface over the initial radiant heat
   14626             :     // absorbed by the surface.
   14627             : 
   14628             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14629             :     Real64 diff;
   14630          27 :     auto const &ort = state.dataOutRptTab;
   14631             : 
   14632        1913 :     for (state.dataOutRptTab->SurfNumCLCDC = 1; state.dataOutRptTab->SurfNumCLCDC <= state.dataSurface->TotSurfaces;
   14633        1886 :          ++state.dataOutRptTab->SurfNumCLCDC) {
   14634        1886 :         state.dataOutRptTab->ZoneNumCLCDC = state.dataSurface->Surface(state.dataOutRptTab->SurfNumCLCDC).Zone;
   14635        1886 :         if (state.dataOutRptTab->ZoneNumCLCDC == 0) continue;
   14636        1782 :         if (!state.dataZoneEquip->ZoneEquipConfig(state.dataOutRptTab->ZoneNumCLCDC).IsControlled) continue;
   14637        1365 :         state.dataOutRptTab->CoolDesSelectedCLCDC = state.dataSize->CalcFinalZoneSizing(state.dataOutRptTab->ZoneNumCLCDC).CoolDDNum;
   14638             :         // loop over timesteps after pulse occurred
   14639        1365 :         if (state.dataOutRptTab->CoolDesSelectedCLCDC != 0) {
   14640        2730 :             state.dataOutRptTab->TimeOfPulseCLCDC =
   14641        1365 :                 ort->radiantPulseTimestep(state.dataOutRptTab->CoolDesSelectedCLCDC, state.dataOutRptTab->ZoneNumCLCDC);
   14642             :             // if the CoolDesSelected time is on a different day than
   14643             :             // when the pulse occurred, need to scan back and find when
   14644             :             // the pulse occurred.
   14645        1365 :             if (state.dataOutRptTab->TimeOfPulseCLCDC == 0) {
   14646           0 :                 for (int i = state.dataOutRptTab->CoolDesSelectedCLCDC; i >= 1; --i) {
   14647           0 :                     state.dataOutRptTab->TimeOfPulseCLCDC = ort->radiantPulseTimestep(i, state.dataOutRptTab->ZoneNumCLCDC);
   14648           0 :                     if (state.dataOutRptTab->TimeOfPulseCLCDC != 0) break;
   14649             :                 }
   14650             :             }
   14651        1365 :             if (state.dataOutRptTab->TimeOfPulseCLCDC == 0) state.dataOutRptTab->TimeOfPulseCLCDC = 1;
   14652        1365 :             for (state.dataOutRptTab->TimeStepCLCDC = state.dataOutRptTab->TimeOfPulseCLCDC;
   14653       83265 :                  state.dataOutRptTab->TimeStepCLCDC <= state.dataGlobal->NumOfTimeStepInHour * 24;
   14654       81900 :                  ++state.dataOutRptTab->TimeStepCLCDC) {
   14655       81900 :                 if (ort->radiantPulseReceived(state.dataOutRptTab->CoolDesSelectedCLCDC, state.dataOutRptTab->SurfNumCLCDC) != 0.0) {
   14656      161640 :                     diff = ort->loadConvectedWithPulse(
   14657       80820 :                                state.dataOutRptTab->CoolDesSelectedCLCDC, state.dataOutRptTab->TimeStepCLCDC, state.dataOutRptTab->SurfNumCLCDC) -
   14658      161640 :                            ort->loadConvectedNormal(
   14659       80820 :                                state.dataOutRptTab->CoolDesSelectedCLCDC, state.dataOutRptTab->TimeStepCLCDC, state.dataOutRptTab->SurfNumCLCDC);
   14660       80820 :                     ort->decayCurveCool(state.dataOutRptTab->TimeStepCLCDC - state.dataOutRptTab->TimeOfPulseCLCDC + 1,
   14661      161640 :                                         state.dataOutRptTab->SurfNumCLCDC) =
   14662       80820 :                         -diff / ort->radiantPulseReceived(state.dataOutRptTab->CoolDesSelectedCLCDC, state.dataOutRptTab->SurfNumCLCDC);
   14663             :                 } else {
   14664        2160 :                     ort->decayCurveCool(state.dataOutRptTab->TimeStepCLCDC - state.dataOutRptTab->TimeOfPulseCLCDC + 1,
   14665        2160 :                                         state.dataOutRptTab->SurfNumCLCDC) = 0.0;
   14666             :                 }
   14667             :             }
   14668             :         }
   14669        1365 :         state.dataOutRptTab->HeatDesSelectedCLCDC = state.dataSize->CalcFinalZoneSizing(state.dataOutRptTab->ZoneNumCLCDC).HeatDDNum;
   14670        1365 :         if (state.dataOutRptTab->HeatDesSelectedCLCDC != 0) {
   14671        2730 :             state.dataOutRptTab->TimeOfPulseCLCDC =
   14672        1365 :                 ort->radiantPulseTimestep(state.dataOutRptTab->HeatDesSelectedCLCDC, state.dataOutRptTab->ZoneNumCLCDC);
   14673             :             // scan back to the day that the heating pulse occurs, if necessary
   14674        1365 :             if (state.dataOutRptTab->TimeOfPulseCLCDC == 0) {
   14675           0 :                 for (int i = state.dataOutRptTab->HeatDesSelectedCLCDC; i >= 1; --i) {
   14676           0 :                     state.dataOutRptTab->TimeOfPulseCLCDC = ort->radiantPulseTimestep(i, state.dataOutRptTab->ZoneNumCLCDC);
   14677           0 :                     if (state.dataOutRptTab->TimeOfPulseCLCDC != 0) break;
   14678             :                 }
   14679             :             }
   14680        1365 :             if (state.dataOutRptTab->TimeOfPulseCLCDC == 0) state.dataOutRptTab->TimeOfPulseCLCDC = 1;
   14681        1365 :             for (state.dataOutRptTab->TimeStepCLCDC = state.dataOutRptTab->TimeOfPulseCLCDC;
   14682       83265 :                  state.dataOutRptTab->TimeStepCLCDC <= state.dataGlobal->NumOfTimeStepInHour * 24;
   14683       81900 :                  ++state.dataOutRptTab->TimeStepCLCDC) {
   14684       81900 :                 if (ort->radiantPulseReceived(state.dataOutRptTab->HeatDesSelectedCLCDC, state.dataOutRptTab->SurfNumCLCDC) != 0.0) {
   14685      161640 :                     diff = ort->loadConvectedWithPulse(
   14686       80820 :                                state.dataOutRptTab->HeatDesSelectedCLCDC, state.dataOutRptTab->TimeStepCLCDC, state.dataOutRptTab->SurfNumCLCDC) -
   14687      161640 :                            ort->loadConvectedNormal(
   14688       80820 :                                state.dataOutRptTab->HeatDesSelectedCLCDC, state.dataOutRptTab->TimeStepCLCDC, state.dataOutRptTab->SurfNumCLCDC);
   14689       80820 :                     ort->decayCurveHeat(state.dataOutRptTab->TimeStepCLCDC - state.dataOutRptTab->TimeOfPulseCLCDC + 1,
   14690      161640 :                                         state.dataOutRptTab->SurfNumCLCDC) =
   14691       80820 :                         -diff / ort->radiantPulseReceived(state.dataOutRptTab->HeatDesSelectedCLCDC, state.dataOutRptTab->SurfNumCLCDC);
   14692             :                 } else {
   14693        2160 :                     ort->decayCurveHeat(state.dataOutRptTab->TimeStepCLCDC - state.dataOutRptTab->TimeOfPulseCLCDC + 1,
   14694        2160 :                                         state.dataOutRptTab->SurfNumCLCDC) = 0.0;
   14695             :                 }
   14696             :             }
   14697             :         }
   14698             :     }
   14699             : 
   14700          27 :     if (state.dataGlobal->ShowDecayCurvesInEIO) {
   14701             :         // show the line definition for the decay curves
   14702           8 :         print(state.files.eio,
   14703             :               "! <Radiant to Convective Decay Curves for Cooling>,Zone Name, Surface Name, Time "
   14704             :               "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\n");
   14705           8 :         print(state.files.eio,
   14706             :               "! <Radiant to Convective Decay Curves for Heating>,Zone Name, Surface Name, Time "
   14707             :               "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\n");
   14708             :         // Put the decay curve into the EIO file
   14709          56 :         for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   14710          48 :             auto &thisZone = state.dataHeatBal->Zone(iZone);
   14711        2814 :             for (int kSurf : state.dataSurface->AllSurfaceListReportOrder) {
   14712        2766 :                 if (state.dataSurface->Surface(kSurf).Zone != iZone) continue;
   14713         429 :                 print(state.files.eio,
   14714             :                       "{},{},{}",
   14715             :                       "Radiant to Convective Decay Curves for Cooling",
   14716         429 :                       thisZone.Name,
   14717         429 :                       state.dataSurface->Surface(kSurf).Name);
   14718       15873 :                 for (int jTime = 1; jTime <= min(state.dataGlobal->NumOfTimeStepInHour * 24, 36); ++jTime) {
   14719       15444 :                     print(state.files.eio, ",{:6.3F}", ort->decayCurveCool(jTime, kSurf));
   14720             :                 }
   14721             :                 // put a line feed at the end of the line
   14722         429 :                 print(state.files.eio, "\n");
   14723          48 :             }
   14724             : 
   14725        2814 :             for (int kSurf : state.dataSurface->AllSurfaceListReportOrder) {
   14726        2766 :                 if (state.dataSurface->Surface(kSurf).Zone != iZone) continue;
   14727         429 :                 print(state.files.eio,
   14728             :                       "{},{},{}",
   14729             :                       "Radiant to Convective Decay Curves for Heating",
   14730         429 :                       thisZone.Name,
   14731         429 :                       state.dataSurface->Surface(kSurf).Name);
   14732       15873 :                 for (int jTime = 1; jTime <= min(state.dataGlobal->NumOfTimeStepInHour * 24, 36); ++jTime) {
   14733       15444 :                     print(state.files.eio, ",{:6.3F}", ort->decayCurveHeat(jTime, kSurf));
   14734             :                 }
   14735             :                 // put a line feed at the end of the line
   14736         429 :                 print(state.files.eio, "\n");
   14737          48 :             }
   14738             :         }
   14739             :     }
   14740          27 : }
   14741             : 
   14742      818667 : void GatherComponentLoadsSurface(EnergyPlusData &state)
   14743             : {
   14744             :     // SUBROUTINE INFORMATION:
   14745             :     //       AUTHOR         Jason Glazer
   14746             :     //       DATE WRITTEN   September 2012
   14747             :     //       MODIFIED       na
   14748             :     //       RE-ENGINEERED  na
   14749             : 
   14750             :     // PURPOSE OF THIS SUBROUTINE:
   14751             :     //   Gather values during sizing used for loads component report.
   14752             : 
   14753             :     // METHODOLOGY EMPLOYED:
   14754             :     //   Save sequence of values for report during sizing.
   14755             : 
   14756             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14757      818667 :     auto const &ort = state.dataOutRptTab;
   14758             : 
   14759      818667 :     if (state.dataGlobal->CompLoadReportIsReq && !state.dataGlobal->isPulseZoneSizing) {
   14760       73284 :         state.dataOutRptTab->TimeStepInDayGCLS =
   14761       36642 :             (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->NumOfTimeStepInHour + state.dataGlobal->TimeStep;
   14762       36642 :         ort->feneCondInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLS, _) = 0.0;
   14763     2683542 :         for (state.dataOutRptTab->iSurfGCLS = 1; state.dataOutRptTab->iSurfGCLS <= state.dataSurface->TotSurfaces; ++state.dataOutRptTab->iSurfGCLS) {
   14764     2646900 :             state.dataOutRptTab->ZoneNumGCLS = state.dataSurface->Surface(state.dataOutRptTab->iSurfGCLS).Zone;
   14765     2646900 :             if (state.dataOutRptTab->ZoneNumGCLS == 0) continue;
   14766     2506500 :             if (state.dataSurface->Surface(state.dataOutRptTab->iSurfGCLS).Class != DataSurfaces::SurfaceClass::Window) continue;
   14767             :             // IF (.not. ZoneEquipConfig(ZoneNum)%IsControlled) CYCLE
   14768      278448 :             ort->feneCondInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLS, state.dataOutRptTab->ZoneNumGCLS) +=
   14769      278448 :                 state.dataSurface->SurfWinGainConvGlazToZoneRep(state.dataOutRptTab->iSurfGCLS) +
   14770      278448 :                 state.dataSurface->SurfWinConvHeatFlowNatural(state.dataOutRptTab->iSurfGCLS) +
   14771      278448 :                 state.dataSurface->SurfWinGainConvShadeToZoneRep(state.dataOutRptTab->iSurfGCLS) +
   14772      278448 :                 state.dataSurface->SurfWinGainFrameDividerToZoneRep(state.dataOutRptTab->iSurfGCLS);
   14773             :             // for now assume zero instant solar - may change related
   14774             :             // to how blinds and shades absorb solar radiation and
   14775             :             // convect that heat that timestep.
   14776             :             // feneSolarInstantSeq(ZoneNum,TimeStepInDay,CurOverallSimDay) = 0
   14777             :         }
   14778      338220 :         for (int izone = 1; izone <= state.dataGlobal->NumOfZones; ++izone) {
   14779      301578 :             Real64 tubularGain = 0.0;
   14780      301578 :             tubularGain = InternalHeatGains::SumInternalConvectionGainsByTypes(state, izone, OutputReportTabular::IntGainTypesTubularGCLS);
   14781      301578 :             ort->feneCondInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLS, izone) += tubularGain;
   14782             :         }
   14783             :     }
   14784      818667 : }
   14785             : 
   14786       12032 : void GatherComponentLoadsHVAC(EnergyPlusData &state)
   14787             : {
   14788             :     // SUBROUTINE INFORMATION:
   14789             :     //       AUTHOR         Jason Glazer
   14790             :     //       DATE WRITTEN   September 2012
   14791             :     //       MODIFIED       na
   14792             :     //       RE-ENGINEERED  na
   14793             : 
   14794             :     // PURPOSE OF THIS SUBROUTINE:
   14795             :     //   Gather values during sizing used for loads component report.
   14796             : 
   14797             :     // METHODOLOGY EMPLOYED:
   14798             :     //   Save sequence of values for report during sizing.
   14799             : 
   14800             :     // Using/Aliasing
   14801             : 
   14802             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14803             : 
   14804       12032 :     if (!(state.dataGlobal->CompLoadReportIsReq && !state.dataGlobal->isPulseZoneSizing)) {
   14805        6016 :         return;
   14806             :     }
   14807        6016 :     auto &ort = state.dataOutRptTab;
   14808        6016 :     Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
   14809        6016 :     state.dataOutRptTab->TimeStepInDayGCLH = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->NumOfTimeStepInHour + state.dataGlobal->TimeStep;
   14810       55256 :     for (state.dataOutRptTab->iZoneGCLH = 1; state.dataOutRptTab->iZoneGCLH <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGCLH) {
   14811       49240 :         ort->infilInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) =
   14812       49240 :             ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).InfilHeatGain -
   14813       49240 :               state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).InfilHeatLoss) /
   14814             :              TimeStepSysSec); // zone infiltration
   14815       49240 :         if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   14816           0 :             ort->infilInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) +=
   14817           0 :                 (state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneInfiSenGainW -
   14818           0 :                  state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneInfiSenLossW); // air flow network
   14819             :         }
   14820       49240 :         ort->infilLatentSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) =
   14821       49240 :             ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).InfilLatentGain -
   14822       49240 :               state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).InfilLatentLoss) /
   14823             :              TimeStepSysSec); // zone infiltration
   14824       49240 :         if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   14825           0 :             ort->infilLatentSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) +=
   14826           0 :                 (state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneInfiLatGainW -
   14827           0 :                  state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneInfiLatLossW); // air flow network
   14828             :         }
   14829             : 
   14830       49240 :         ort->zoneVentInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) =
   14831       49240 :             ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).VentilHeatGain -
   14832       49240 :               state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).VentilHeatLoss) /
   14833             :              TimeStepSysSec); // zone ventilation
   14834       49240 :         if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   14835           0 :             ort->zoneVentInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) +=
   14836           0 :                 (state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneVentSenGainW -
   14837           0 :                  state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneVentSenLossW); // air flow network
   14838             :         }
   14839       49240 :         ort->zoneVentLatentSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) =
   14840       49240 :             ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).VentilLatentGain -
   14841       49240 :               state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).VentilLatentLoss) /
   14842             :              TimeStepSysSec); // zone ventilation
   14843       49240 :         if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   14844           0 :             ort->zoneVentInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) +=
   14845           0 :                 (state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneVentLatGainW -
   14846           0 :                  state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneVentLatLossW); // air flow network
   14847             :         }
   14848             : 
   14849       49240 :         ort->interZoneMixInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) =
   14850       49240 :             ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).MixHeatGain -
   14851       49240 :               state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).MixHeatLoss) /
   14852             :              TimeStepSysSec); // zone mixing
   14853       49240 :         if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   14854           0 :             ort->interZoneMixInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) +=
   14855           0 :                 (state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneMixSenGainW -
   14856           0 :                  state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneMixSenLossW); // air flow network
   14857             :         }
   14858       49240 :         ort->interZoneMixLatentSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) =
   14859       49240 :             ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).MixLatentGain -
   14860       49240 :               state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).MixLatentLoss) /
   14861             :              TimeStepSysSec); // zone mixing
   14862       49240 :         if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   14863           0 :             ort->interZoneMixLatentSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) +=
   14864           0 :                 (state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneMixLatGainW -
   14865           0 :                  state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneMixLatLossW); // air flow network
   14866             :         }
   14867             :     }
   14868             : }
   14869             : 
   14870         754 : void WriteLoadComponentSummaryTables(EnergyPlusData &state)
   14871             : {
   14872             :     // SUBROUTINE INFORMATION:
   14873             :     //       AUTHOR         Jason Glazer
   14874             :     //       DATE WRITTEN   March 2012
   14875             :     //       MODIFIED       na
   14876             :     //       RE-ENGINEERED  Amir Roth, Feb 2016 (unified with ComputeDelayedComponents to simplify code and debugging)
   14877             : 
   14878             :     // PURPOSE OF THIS SUBROUTINE:
   14879             :     //   Write the tables for the ZoneLoadComponentSummary and
   14880             :     //   ZoneLoadComponentDetail reports which summarize the major
   14881             :     //   load components for each zone in the building.
   14882             : 
   14883             :     // METHODOLOGY EMPLOYED:
   14884             :     //   Create arrays for the call to WriteTable and then call it.
   14885             :     //   This report actually consists of many sub-tables each with
   14886             :     //   its own call to WriteTable.
   14887             :     // The overall methodology is explained below:
   14888             :     //
   14889             :     // Determine decay curve - Pulse of radiant heat which is about 5% of lighting and
   14890             :     //   equipment input for a single timestep a few hours after
   14891             :     //   cooling or heat is scheduled on for each zone [radiantPulseTimestep(iZone)].
   14892             :     //   The radiant heat received on each wall is stored [radiantPulseReceived(jSurface)].
   14893             :     //   The load convected in the normal case [loadConvectedNormal(jSurface, kTime, mode)]
   14894             :     //   and in the case with the pulse [loadConvectedWithPulse(jSurface, kTime, mode)].
   14895             :     //   The difference divided by the pulse received by each surface
   14896             :     //   [radiantPulseReceived(jSurface)] is stored in [decayCurve(jSurface,kTime,mode)].
   14897             :     //
   14898             :     // Determine delayed loads - From the last timestep of the peak load on the zone
   14899             :     //   working backwards any radiant heat that was absorbed by the wall from an internal gain
   14900             :     //   or solar gain is multiplied by the appropriate timesteps in the decay curve
   14901             :     //   [decayCurve(jSurface,kTime,mode)] for timesteps that make up
   14902             :     //   the number of averaged timesteps are used to determine the peak load
   14903             :     //   [NumTimeStepsInAvg]. The sum for all surfaces in the zone are added together to
   14904             :     //   determine the delayed load.
   14905             :     //
   14906             :     // Determine instant loads - Average the convective portion of the internal gains
   14907             :     //   for the timesteps made up of the peak load period. Average those across the peak
   14908             :     //   load period.
   14909             :     //
   14910             :     // The comments from ComputeDelayedComponents which was incorporated into this routine follow:
   14911             :     //
   14912             :     // PURPOSE OF THIS SUBROUTINE:
   14913             :     //   For load component report, convert the sequence of radiant gains
   14914             :     //   for people and equipment and other internal loads into convective
   14915             :     //   gains based on the decay curves.
   14916             :     //
   14917             :     // METHODOLOGY EMPLOYED:
   14918             :     //   For each step of sequence from each design day, compute the
   14919             :     //   contributions from previous timesteps multiplied by the decay
   14920             :     //   curve. Rather than store every internal load's radiant contribution
   14921             :     //   to each surface, the EnclRadThermAbsMult and ITABSF sequences were also stored
   14922             :     //   which allocates the total radiant to each surface in the zone. The
   14923             :     //   formula used is:
   14924             :     //       SurfQRadThermInAbs(SurfNum) = QL(NZ) * EnclRadThermAbsMult(NZ) * SurfAbsThermalInt(SurfNum)
   14925             : 
   14926         754 :     auto &ort = state.dataOutRptTab;
   14927         781 :     if (!((ort->displayZoneComponentLoadSummary || ort->displayAirLoopComponentLoadSummary || ort->displayFacilityComponentLoadSummary) &&
   14928          27 :           state.dataGlobal->CompLoadReportIsReq)) {
   14929         727 :         return;
   14930             :     }
   14931             : 
   14932          27 :     auto &NumPrimaryAirSys = state.dataHVACGlobal->NumPrimaryAirSys;
   14933             : 
   14934          27 :     auto const &CalcFinalFacilitySizing(state.dataSize->CalcFinalFacilitySizing);
   14935             : 
   14936             :     int coolDesSelected;
   14937             :     int timeCoolMax;
   14938             :     int heatDesSelected;
   14939             :     int timeHeatMax;
   14940             : 
   14941             :     // Delayed components are moved into this function so that we can calculate them one zone at a time
   14942             :     // with Array1D
   14943          27 :     Array1D<Real64> peopleDelaySeqHeat;
   14944          27 :     Array1D<Real64> peopleDelaySeqCool;
   14945          27 :     Array1D<Real64> lightDelaySeqHeat;
   14946          27 :     Array1D<Real64> lightDelaySeqCool;
   14947          27 :     Array1D<Real64> equipDelaySeqHeat;
   14948          27 :     Array1D<Real64> equipDelaySeqCool;
   14949          27 :     Array1D<Real64> hvacLossDelaySeqHeat;
   14950          27 :     Array1D<Real64> hvacLossDelaySeqCool;
   14951          27 :     Array1D<Real64> powerGenDelaySeqHeat;
   14952          27 :     Array1D<Real64> powerGenDelaySeqCool;
   14953          27 :     Array1D<Real64> feneSolarDelaySeqHeat;
   14954          27 :     Array1D<Real64> feneSolarDelaySeqCool;
   14955          27 :     Array2D<Real64> surfDelaySeqHeat;
   14956          27 :     Array2D<Real64> surfDelaySeqCool;
   14957             : 
   14958          27 :     Array1D<CompLoadTablesType> ZoneHeatCompLoadTables; // for zone level component load summary output tables
   14959          27 :     Array1D<CompLoadTablesType> ZoneCoolCompLoadTables;
   14960             : 
   14961          27 :     Array1D<CompLoadTablesType> AirLoopHeatCompLoadTables; // for airloop level component load summary output tables
   14962          27 :     Array1D<CompLoadTablesType> AirLoopCoolCompLoadTables;
   14963          27 :     Array1D<CompLoadTablesType> AirLoopZonesHeatCompLoadTables; // zone results used for airloop report - never directly output
   14964          27 :     Array1D<CompLoadTablesType> AirLoopZonesCoolCompLoadTables;
   14965             : 
   14966          27 :     CompLoadTablesType FacilityHeatCompLoadTables; // for facility level component load summary output tables
   14967          27 :     CompLoadTablesType FacilityCoolCompLoadTables;
   14968          27 :     Array1D<CompLoadTablesType> FacilityZonesHeatCompLoadTables; // zone results used for facility report - never directly output
   14969          27 :     Array1D<CompLoadTablesType> FacilityZonesCoolCompLoadTables;
   14970             : 
   14971             :     // Jan 2021: The following variable is redudant in the original code, deleting the line
   14972             :     // CompLoadTablesType curCompLoadTable; // active component load table
   14973             : 
   14974          54 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   14975          54 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   14976          54 :         bool produceTabular = true;
   14977          54 :         bool produceSQLite = false;
   14978          54 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   14979             : 
   14980             :         // adjusted initilization location to after variable declaration for loops 2021-01-11
   14981          27 :         peopleDelaySeqHeat.dimension(state.dataGlobal->NumOfTimeStepInHour * 24, 0.0);
   14982          27 :         peopleDelaySeqHeat = 0.0;
   14983          27 :         peopleDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   14984          27 :         peopleDelaySeqCool = 0.0;
   14985          27 :         lightDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   14986          27 :         lightDelaySeqHeat = 0.0;
   14987          27 :         lightDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   14988          27 :         lightDelaySeqCool = 0.0;
   14989          27 :         equipDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   14990          27 :         equipDelaySeqHeat = 0.0;
   14991          27 :         equipDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   14992          27 :         equipDelaySeqCool = 0.0;
   14993          27 :         hvacLossDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   14994          27 :         hvacLossDelaySeqHeat = 0.0;
   14995          27 :         hvacLossDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   14996          27 :         hvacLossDelaySeqCool = 0.0;
   14997          27 :         powerGenDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   14998          27 :         powerGenDelaySeqHeat = 0.0;
   14999          27 :         powerGenDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   15000          27 :         powerGenDelaySeqCool = 0.0;
   15001          27 :         feneSolarDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   15002          27 :         feneSolarDelaySeqHeat = 0.0;
   15003          27 :         feneSolarDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   15004          27 :         feneSolarDelaySeqCool = 0.0;
   15005          27 :         surfDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces);
   15006          27 :         surfDelaySeqHeat = 0.0;
   15007          27 :         surfDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces);
   15008          27 :         surfDelaySeqCool = 0.0;
   15009             : 
   15010             :         // initialize arrays
   15011          27 :         if (ort->displayZoneComponentLoadSummary) {
   15012          27 :             ZoneHeatCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15013         242 :             for (auto &e : ZoneHeatCompLoadTables) {
   15014         215 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15015         215 :                 e.cells = 0.;
   15016         215 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15017         215 :                 e.cellUsed = false;
   15018             :             }
   15019          27 :             ZoneCoolCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15020         242 :             for (auto &e : ZoneCoolCompLoadTables) {
   15021         215 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15022         215 :                 e.cells = 0.;
   15023         215 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15024         215 :                 e.cellUsed = false;
   15025             :             }
   15026             :         }
   15027          27 :         if (ort->displayAirLoopComponentLoadSummary) {
   15028           2 :             AirLoopHeatCompLoadTables.allocate(NumPrimaryAirSys);
   15029           4 :             for (auto &e : AirLoopHeatCompLoadTables) {
   15030           2 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15031           2 :                 e.cells = 0.;
   15032           2 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15033           2 :                 e.cellUsed = false;
   15034           2 :                 e.zoneIndices.allocate(state.dataGlobal->NumOfZones); // only need to allocate this for the AirLoop
   15035           2 :                 e.zoneIndices = 0;
   15036             :             }
   15037           2 :             AirLoopCoolCompLoadTables.allocate(NumPrimaryAirSys);
   15038           4 :             for (auto &e : AirLoopCoolCompLoadTables) {
   15039           2 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15040           2 :                 e.cells = 0.;
   15041           2 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15042           2 :                 e.cellUsed = false;
   15043           2 :                 e.zoneIndices.allocate(state.dataGlobal->NumOfZones); // only need to allocate this for the AirLoop
   15044           2 :                 e.zoneIndices = 0;
   15045             :             }
   15046           2 :             AirLoopZonesHeatCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15047          14 :             for (auto &e : AirLoopZonesHeatCompLoadTables) {
   15048          12 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15049          12 :                 e.cells = 0.;
   15050          12 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15051          12 :                 e.cellUsed = false;
   15052             :             }
   15053           2 :             AirLoopZonesCoolCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15054          14 :             for (auto &e : AirLoopZonesCoolCompLoadTables) {
   15055          12 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15056          12 :                 e.cells = 0.;
   15057          12 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15058          12 :                 e.cellUsed = false;
   15059             :             }
   15060             :         }
   15061          27 :         if (ort->displayFacilityComponentLoadSummary) {
   15062           2 :             FacilityHeatCompLoadTables.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15063           2 :             FacilityHeatCompLoadTables.cells = 0.;
   15064           2 :             FacilityHeatCompLoadTables.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15065           2 :             FacilityHeatCompLoadTables.cellUsed = false;
   15066             : 
   15067           2 :             FacilityCoolCompLoadTables.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15068           2 :             FacilityCoolCompLoadTables.cells = 0.;
   15069           2 :             FacilityCoolCompLoadTables.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15070           2 :             FacilityCoolCompLoadTables.cellUsed = false;
   15071             : 
   15072           2 :             FacilityZonesHeatCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15073          14 :             for (auto &e : FacilityZonesHeatCompLoadTables) {
   15074          12 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15075          12 :                 e.cells = 0.;
   15076          12 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15077          12 :                 e.cellUsed = false;
   15078             :             }
   15079           2 :             FacilityZonesCoolCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15080          14 :             for (auto &e : FacilityZonesCoolCompLoadTables) {
   15081          12 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15082          12 :                 e.cells = 0.;
   15083          12 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15084          12 :                 e.cellUsed = false;
   15085             :             }
   15086             :         }
   15087             : 
   15088             :         // get the zone areas needed later
   15089          27 :         Array1D<ZompComponentAreasType> ZoneComponentAreas;
   15090          27 :         ZoneComponentAreas.allocate(state.dataGlobal->NumOfZones);
   15091          27 :         GetZoneComponentAreas(state, ZoneComponentAreas);
   15092             : 
   15093             :         // ZoneComponentLoadSummary
   15094          27 :         if (ort->displayZoneComponentLoadSummary) {
   15095         242 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15096         215 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) continue;
   15097         185 :                 if (allocated(state.dataSize->CalcFinalZoneSizing)) {
   15098         185 :                     auto const &thisCalcFinalZoneSizing = state.dataSize->CalcFinalZoneSizing(iZone);
   15099         185 :                     coolDesSelected = thisCalcFinalZoneSizing.CoolDDNum;
   15100         185 :                     ZoneCoolCompLoadTables(iZone).desDayNum = coolDesSelected;
   15101         185 :                     timeCoolMax = thisCalcFinalZoneSizing.TimeStepNumAtCoolMax;
   15102         185 :                     ZoneCoolCompLoadTables(iZone).timeStepMax = timeCoolMax;
   15103             : 
   15104         185 :                     GetDelaySequences(state,
   15105             :                                       coolDesSelected,
   15106             :                                       true,
   15107             :                                       iZone,
   15108             :                                       peopleDelaySeqCool,
   15109             :                                       equipDelaySeqCool,
   15110             :                                       hvacLossDelaySeqCool,
   15111             :                                       powerGenDelaySeqCool,
   15112             :                                       lightDelaySeqCool,
   15113             :                                       feneSolarDelaySeqCool,
   15114         185 :                                       ort->feneCondInstantSeq,
   15115             :                                       surfDelaySeqCool);
   15116         185 :                     ComputeTableBodyUsingMovingAvg(state,
   15117         185 :                                                    ZoneCoolCompLoadTables(iZone).cells,
   15118         185 :                                                    ZoneCoolCompLoadTables(iZone).cellUsed,
   15119             :                                                    coolDesSelected,
   15120             :                                                    timeCoolMax,
   15121             :                                                    iZone,
   15122             :                                                    peopleDelaySeqCool,
   15123             :                                                    equipDelaySeqCool,
   15124             :                                                    hvacLossDelaySeqCool,
   15125             :                                                    powerGenDelaySeqCool,
   15126             :                                                    lightDelaySeqCool,
   15127             :                                                    feneSolarDelaySeqCool,
   15128         185 :                                                    ort->feneCondInstantSeq,
   15129             :                                                    surfDelaySeqCool);
   15130         185 :                     CollectPeakZoneConditions(state, ZoneCoolCompLoadTables(iZone), coolDesSelected, timeCoolMax, iZone, true);
   15131             :                     // send latent load info to coil summary report
   15132         185 :                     state.dataRptCoilSelection->coilSelectionReportObj->setZoneLatentLoadCoolingIdealPeak(
   15133         185 :                         iZone, ZoneCoolCompLoadTables(iZone).cells(LoadCompCol::Latent, LoadCompRow::GrdTot));
   15134             : 
   15135         185 :                     heatDesSelected = thisCalcFinalZoneSizing.HeatDDNum;
   15136         185 :                     ZoneHeatCompLoadTables(iZone).desDayNum = heatDesSelected;
   15137         185 :                     timeHeatMax = thisCalcFinalZoneSizing.TimeStepNumAtHeatMax;
   15138         185 :                     ZoneHeatCompLoadTables(iZone).timeStepMax = timeHeatMax;
   15139             : 
   15140         185 :                     GetDelaySequences(state,
   15141             :                                       heatDesSelected,
   15142             :                                       false,
   15143             :                                       iZone,
   15144             :                                       peopleDelaySeqHeat,
   15145             :                                       equipDelaySeqHeat,
   15146             :                                       hvacLossDelaySeqHeat,
   15147             :                                       powerGenDelaySeqHeat,
   15148             :                                       lightDelaySeqHeat,
   15149             :                                       feneSolarDelaySeqHeat,
   15150         185 :                                       ort->feneCondInstantSeq,
   15151             :                                       surfDelaySeqHeat);
   15152         185 :                     ComputeTableBodyUsingMovingAvg(state,
   15153         185 :                                                    ZoneHeatCompLoadTables(iZone).cells,
   15154         185 :                                                    ZoneHeatCompLoadTables(iZone).cellUsed,
   15155             :                                                    heatDesSelected,
   15156             :                                                    timeHeatMax,
   15157             :                                                    iZone,
   15158             :                                                    peopleDelaySeqHeat,
   15159             :                                                    equipDelaySeqHeat,
   15160             :                                                    hvacLossDelaySeqHeat,
   15161             :                                                    powerGenDelaySeqHeat,
   15162             :                                                    lightDelaySeqHeat,
   15163             :                                                    feneSolarDelaySeqHeat,
   15164         185 :                                                    ort->feneCondInstantSeq,
   15165             :                                                    surfDelaySeqHeat);
   15166         185 :                     CollectPeakZoneConditions(state, ZoneHeatCompLoadTables(iZone), heatDesSelected, timeHeatMax, iZone, false);
   15167             : 
   15168             :                     // send latent load info to coil summary report
   15169         185 :                     state.dataRptCoilSelection->coilSelectionReportObj->setZoneLatentLoadHeatingIdealPeak(
   15170         185 :                         iZone, ZoneHeatCompLoadTables(iZone).cells(LoadCompCol::Latent, LoadCompRow::GrdTot));
   15171             : 
   15172         185 :                     AddAreaColumnForZone(iZone, ZoneComponentAreas, ZoneCoolCompLoadTables(iZone));
   15173         185 :                     AddAreaColumnForZone(iZone, ZoneComponentAreas, ZoneHeatCompLoadTables(iZone));
   15174             : 
   15175         185 :                     AddTotalRowsForLoadSummary(ZoneCoolCompLoadTables(iZone));
   15176         185 :                     AddTotalRowsForLoadSummary(ZoneHeatCompLoadTables(iZone));
   15177             : 
   15178         185 :                     ComputePeakDifference(ZoneCoolCompLoadTables(iZone));
   15179         185 :                     ComputePeakDifference(ZoneHeatCompLoadTables(iZone));
   15180             : 
   15181             :                     // We delay the potential application of SI to IP conversion and actual output until after both the
   15182             :                     // AirLoopComponentLoadSummary and FacilityComponentLoadSummary have been processed because below we try to retrieve the info
   15183             :                     // directly when the timestamp would match (cf #7356), and if we converted right now, we would apply the conversion twice
   15184             :                 }
   15185             :             }
   15186             :         }
   15187             : 
   15188             :         // AirLoopComponentLoadSummary
   15189          27 :         if (ort->displayAirLoopComponentLoadSummary && NumPrimaryAirSys > 0) {
   15190           2 :             Array1D_int zoneToAirLoopCool;
   15191           2 :             zoneToAirLoopCool.dimension(state.dataGlobal->NumOfZones);
   15192           2 :             Array1D_int zoneToAirLoopHeat;
   15193           2 :             zoneToAirLoopHeat.dimension(state.dataGlobal->NumOfZones);
   15194             :             // set the peak day and time for each zone used by the airloops - use all zones connected to the airloop for both heating and cooling
   15195             :             // (regardless of "heated" or "cooled" zone status)
   15196           4 :             for (int iAirLoop = 1; iAirLoop <= NumPrimaryAirSys; ++iAirLoop) {
   15197           2 :                 auto const &finalSysSizing = state.dataSize->FinalSysSizing(iAirLoop);
   15198           2 :                 auto const &sysSizPeakDDNum = state.dataSize->SysSizPeakDDNum(iAirLoop);
   15199           2 :                 zoneToAirLoopCool = 0;
   15200           2 :                 zoneToAirLoopHeat = 0;
   15201           2 :                 if (finalSysSizing.loadSizingType == DataSizing::LoadSizing::Sensible) {
   15202           2 :                     coolDesSelected = sysSizPeakDDNum.SensCoolPeakDD;
   15203           2 :                     if (coolDesSelected != 0) {
   15204           2 :                         timeCoolMax = sysSizPeakDDNum.TimeStepAtSensCoolPk(coolDesSelected);
   15205             :                     } else {
   15206           0 :                         timeCoolMax = 0;
   15207             :                     }
   15208           0 :                 } else if (finalSysSizing.loadSizingType == DataSizing::LoadSizing::Ventilation) {
   15209           0 :                     coolDesSelected = sysSizPeakDDNum.CoolFlowPeakDD;
   15210           0 :                     if (coolDesSelected != 0) {
   15211           0 :                         timeCoolMax = sysSizPeakDDNum.TimeStepAtCoolFlowPk(coolDesSelected);
   15212             :                     } else {
   15213           0 :                         timeCoolMax = 0;
   15214             :                     }
   15215             :                 } else {
   15216           0 :                     coolDesSelected = sysSizPeakDDNum.TotCoolPeakDD;
   15217           0 :                     if (coolDesSelected != 0) {
   15218           0 :                         timeCoolMax = sysSizPeakDDNum.TimeStepAtTotCoolPk(coolDesSelected);
   15219             :                     } else {
   15220           0 :                         timeCoolMax = 0;
   15221             :                     }
   15222             :                 }
   15223           2 :                 heatDesSelected = sysSizPeakDDNum.HeatPeakDD;
   15224           2 :                 if (heatDesSelected != 0) {
   15225           2 :                     timeHeatMax = sysSizPeakDDNum.TimeStepAtHeatPk(heatDesSelected);
   15226             :                 } else {
   15227           0 :                     timeHeatMax = 0;
   15228             :                 }
   15229             : 
   15230           2 :                 int NumZonesCooled = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).NumZonesCooled;
   15231          12 :                 for (int ZonesCooledNum = 1; ZonesCooledNum <= NumZonesCooled; ++ZonesCooledNum) { // loop over cooled zones
   15232          10 :                     int CtrlZoneNum = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).CoolCtrlZoneNums(ZonesCooledNum);
   15233          10 :                     zoneToAirLoopCool(CtrlZoneNum) = iAirLoop;
   15234          10 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).desDayNum = coolDesSelected;
   15235          10 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).timeStepMax = timeCoolMax;
   15236          10 :                     zoneToAirLoopHeat(CtrlZoneNum) = iAirLoop;
   15237          10 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).desDayNum = heatDesSelected;
   15238          10 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).timeStepMax = timeHeatMax;
   15239             :                 }
   15240           2 :                 int NumZonesHeated = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).NumZonesHeated;
   15241           2 :                 for (int ZonesHeatedNum = 1; ZonesHeatedNum <= NumZonesHeated; ++ZonesHeatedNum) { // loop over heated zones
   15242           0 :                     int CtrlZoneNum = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).HeatCtrlZoneNums(ZonesHeatedNum);
   15243           0 :                     zoneToAirLoopCool(CtrlZoneNum) = iAirLoop;
   15244           0 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).desDayNum = coolDesSelected;
   15245           0 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).timeStepMax = timeCoolMax;
   15246           0 :                     zoneToAirLoopHeat(CtrlZoneNum) = iAirLoop;
   15247           0 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).desDayNum = heatDesSelected;
   15248           0 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).timeStepMax = timeHeatMax;
   15249             :                 }
   15250             : 
   15251             :                 // now go through the zones and if design day and time of max match the previously calculated zone results use those otherwise
   15252             :                 // compute them for specific design day and time of max
   15253          14 :                 for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15254          12 :                     if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) continue;
   15255          10 :                     auto &airLoopZonesCoolCompLoadTables = AirLoopZonesCoolCompLoadTables(iZone);
   15256          10 :                     auto &airLoopZonesHeatCompLoadTables = AirLoopZonesHeatCompLoadTables(iZone);
   15257             :                     // The ZoneCoolCompLoadTables already hasn't gotten a potential IP conversion yet, so we won't convert it twice.
   15258          10 :                     if (ort->displayZoneComponentLoadSummary &&
   15259          20 :                         (airLoopZonesCoolCompLoadTables.desDayNum == ZoneCoolCompLoadTables(iZone).desDayNum) &&
   15260          10 :                         (airLoopZonesCoolCompLoadTables.timeStepMax == ZoneCoolCompLoadTables(iZone).timeStepMax)) {
   15261           0 :                         airLoopZonesCoolCompLoadTables = ZoneCoolCompLoadTables(iZone);
   15262             :                     } else {
   15263          10 :                         coolDesSelected = airLoopZonesCoolCompLoadTables.desDayNum;
   15264          10 :                         timeCoolMax = airLoopZonesCoolCompLoadTables.timeStepMax;
   15265             : 
   15266          10 :                         GetDelaySequences(state,
   15267             :                                           coolDesSelected,
   15268             :                                           true,
   15269             :                                           iZone,
   15270             :                                           peopleDelaySeqCool,
   15271             :                                           equipDelaySeqCool,
   15272             :                                           hvacLossDelaySeqCool,
   15273             :                                           powerGenDelaySeqCool,
   15274             :                                           lightDelaySeqCool,
   15275             :                                           feneSolarDelaySeqCool,
   15276          10 :                                           ort->feneCondInstantSeq,
   15277             :                                           surfDelaySeqCool);
   15278          10 :                         ComputeTableBodyUsingMovingAvg(state,
   15279          10 :                                                        airLoopZonesCoolCompLoadTables.cells,
   15280          10 :                                                        airLoopZonesCoolCompLoadTables.cellUsed,
   15281             :                                                        coolDesSelected,
   15282             :                                                        timeCoolMax,
   15283             :                                                        iZone,
   15284             :                                                        peopleDelaySeqCool,
   15285             :                                                        equipDelaySeqCool,
   15286             :                                                        hvacLossDelaySeqCool,
   15287             :                                                        powerGenDelaySeqCool,
   15288             :                                                        lightDelaySeqCool,
   15289             :                                                        feneSolarDelaySeqCool,
   15290          10 :                                                        ort->feneCondInstantSeq,
   15291             :                                                        surfDelaySeqCool);
   15292          10 :                         CollectPeakZoneConditions(state, airLoopZonesCoolCompLoadTables, coolDesSelected, timeCoolMax, iZone, true);
   15293          10 :                         AddAreaColumnForZone(iZone, ZoneComponentAreas, airLoopZonesCoolCompLoadTables);
   15294             :                     }
   15295          10 :                     if (ort->displayZoneComponentLoadSummary &&
   15296          20 :                         (airLoopZonesHeatCompLoadTables.desDayNum == ZoneHeatCompLoadTables(iZone).desDayNum) &&
   15297          10 :                         (airLoopZonesHeatCompLoadTables.timeStepMax == ZoneHeatCompLoadTables(iZone).timeStepMax)) {
   15298           0 :                         airLoopZonesHeatCompLoadTables = ZoneHeatCompLoadTables(iZone);
   15299             :                     } else {
   15300          10 :                         heatDesSelected = airLoopZonesHeatCompLoadTables.desDayNum;
   15301          10 :                         timeHeatMax = airLoopZonesHeatCompLoadTables.timeStepMax;
   15302             : 
   15303          10 :                         GetDelaySequences(state,
   15304             :                                           heatDesSelected,
   15305             :                                           false,
   15306             :                                           iZone,
   15307             :                                           peopleDelaySeqHeat,
   15308             :                                           equipDelaySeqHeat,
   15309             :                                           hvacLossDelaySeqHeat,
   15310             :                                           powerGenDelaySeqHeat,
   15311             :                                           lightDelaySeqHeat,
   15312             :                                           feneSolarDelaySeqHeat,
   15313          10 :                                           ort->feneCondInstantSeq,
   15314             :                                           surfDelaySeqHeat);
   15315          10 :                         ComputeTableBodyUsingMovingAvg(state,
   15316          10 :                                                        airLoopZonesHeatCompLoadTables.cells,
   15317          10 :                                                        airLoopZonesHeatCompLoadTables.cellUsed,
   15318             :                                                        heatDesSelected,
   15319             :                                                        timeHeatMax,
   15320             :                                                        iZone,
   15321             :                                                        peopleDelaySeqHeat,
   15322             :                                                        equipDelaySeqHeat,
   15323             :                                                        hvacLossDelaySeqHeat,
   15324             :                                                        powerGenDelaySeqHeat,
   15325             :                                                        lightDelaySeqHeat,
   15326             :                                                        feneSolarDelaySeqHeat,
   15327          10 :                                                        ort->feneCondInstantSeq,
   15328             :                                                        surfDelaySeqHeat);
   15329          10 :                         CollectPeakZoneConditions(state, airLoopZonesHeatCompLoadTables, heatDesSelected, timeHeatMax, iZone, false);
   15330          10 :                         AddAreaColumnForZone(iZone, ZoneComponentAreas, airLoopZonesHeatCompLoadTables);
   15331             :                     }
   15332             :                 }
   15333             :                 // combine the zones for each air loop
   15334             : 
   15335           2 :                 auto &airLoopCoolTable = AirLoopCoolCompLoadTables(iAirLoop);
   15336           2 :                 auto &airLoopHeatTable = AirLoopHeatCompLoadTables(iAirLoop);
   15337          14 :                 for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15338          12 :                     auto const &thisZone = state.dataHeatBal->Zone(iZone);
   15339             : 
   15340          12 :                     if (zoneToAirLoopCool(iZone) == iAirLoop) {
   15341          10 :                         Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   15342          10 :                         if (mult == 0.0) {
   15343           0 :                             mult = 1.0;
   15344             :                         }
   15345          10 :                         CombineLoadCompResults(airLoopCoolTable, AirLoopZonesCoolCompLoadTables(iZone), mult);
   15346             :                     }
   15347          12 :                     if (zoneToAirLoopHeat(iZone) == iAirLoop) {
   15348          10 :                         Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   15349          10 :                         if (mult == 0.0) {
   15350           0 :                             mult = 1.0;
   15351             :                         }
   15352          10 :                         CombineLoadCompResults(airLoopHeatTable, AirLoopZonesHeatCompLoadTables(iZone), mult);
   15353             :                     }
   15354             :                 }
   15355           4 :                 for (int SysSizIndex = 1; SysSizIndex <= state.dataSize->NumSysSizInput; ++SysSizIndex) {
   15356           2 :                     if (state.dataSize->SysSizInput(SysSizIndex).AirLoopNum != iAirLoop) continue;
   15357           2 :                     if (state.dataSize->SysSizInput(SysSizIndex).SizingOption == DataSizing::SizingConcurrence::Coincident) {
   15358           0 :                         airLoopCoolTable.peakDesSensLoad = finalSysSizing.SysCoolCoinSpaceSens;
   15359           0 :                         airLoopCoolTable.designPeakLoad = finalSysSizing.SysDesCoolLoad;
   15360             : 
   15361           0 :                         airLoopHeatTable.peakDesSensLoad = -finalSysSizing.SysHeatCoinSpaceSens;
   15362           0 :                         airLoopHeatTable.designPeakLoad = -finalSysSizing.SysDesHeatLoad;
   15363             : 
   15364           0 :                         airLoopCoolTable.diffPeakEst = airLoopCoolTable.peakDesSensLoad - airLoopCoolTable.estInstDelSensLoad;
   15365           0 :                         airLoopCoolTable.diffDesignPeak = airLoopCoolTable.designPeakLoad - airLoopCoolTable.peakDesSensLoad;
   15366             : 
   15367           0 :                         airLoopHeatTable.diffPeakEst = airLoopHeatTable.peakDesSensLoad - airLoopHeatTable.estInstDelSensLoad;
   15368           0 :                         airLoopHeatTable.diffDesignPeak = airLoopHeatTable.designPeakLoad - airLoopHeatTable.peakDesSensLoad;
   15369             :                     }
   15370             :                 }
   15371             : 
   15372             :                 // Coincident and NonCoincident alike
   15373           2 :                 airLoopCoolTable.mixAirTemp = finalSysSizing.MixTempAtCoolPeak;
   15374           2 :                 airLoopHeatTable.mixAirTemp = finalSysSizing.HeatMixTemp;
   15375             : 
   15376           2 :                 ComputeEngineeringChecks(airLoopCoolTable);
   15377           2 :                 ComputeEngineeringChecks(airLoopHeatTable);
   15378             : 
   15379           2 :                 AddTotalRowsForLoadSummary(airLoopCoolTable);
   15380           2 :                 AddTotalRowsForLoadSummary(airLoopHeatTable);
   15381             : 
   15382           2 :                 ComputePeakDifference(airLoopCoolTable);
   15383           2 :                 ComputePeakDifference(airLoopHeatTable);
   15384             : 
   15385           2 :                 CreateListOfZonesForAirLoop(state, airLoopCoolTable, zoneToAirLoopCool, iAirLoop);
   15386           2 :                 CreateListOfZonesForAirLoop(state, airLoopHeatTable, zoneToAirLoopHeat, iAirLoop);
   15387             : 
   15388           2 :                 LoadSummaryUnitConversion(state, airLoopCoolTable, unitsStyle_cur);
   15389           2 :                 LoadSummaryUnitConversion(state, airLoopHeatTable, unitsStyle_cur);
   15390             : 
   15391           2 :                 OutputCompLoadSummary(
   15392             :                     state, OutputType::AirLoop, airLoopCoolTable, airLoopHeatTable, iAirLoop, unitsStyle_cur, produceTabular, produceSQLite);
   15393             :             }
   15394           2 :         }
   15395             : 
   15396             :         // FacilityComponentLoadSummary
   15397          27 :         if (ort->displayFacilityComponentLoadSummary) {
   15398             : 
   15399           2 :             coolDesSelected = CalcFinalFacilitySizing.CoolDDNum;
   15400           2 :             timeCoolMax = CalcFinalFacilitySizing.TimeStepNumAtCoolMax;
   15401             : 
   15402           2 :             heatDesSelected = CalcFinalFacilitySizing.HeatDDNum;
   15403           2 :             timeHeatMax = CalcFinalFacilitySizing.TimeStepNumAtHeatMax;
   15404             : 
   15405          14 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15406          12 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) continue;
   15407          10 :                 auto &facilityZonesCoolCompLoadTables = FacilityZonesCoolCompLoadTables(iZone);
   15408          10 :                 auto &facilityZonesHeatCompLoadTables = FacilityZonesHeatCompLoadTables(iZone);
   15409          10 :                 auto const &thisZone = state.dataHeatBal->Zone(iZone);
   15410             : 
   15411          10 :                 Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   15412          10 :                 if (mult == 0.0) {
   15413           0 :                     mult = 1.0;
   15414             :                 }
   15415             : 
   15416             :                 // The ZoneCoolCompLoadTables already hasn't gotten a potential IP conversion yet, so we won't convert it twice.
   15417          20 :                 if (ort->displayZoneComponentLoadSummary && (coolDesSelected == ZoneCoolCompLoadTables(iZone).desDayNum) &&
   15418          10 :                     (timeCoolMax == ZoneCoolCompLoadTables(iZone).timeStepMax)) {
   15419           0 :                     facilityZonesCoolCompLoadTables = ZoneCoolCompLoadTables(iZone);
   15420             :                 } else {
   15421          10 :                     GetDelaySequences(state,
   15422             :                                       coolDesSelected,
   15423             :                                       true,
   15424             :                                       iZone,
   15425             :                                       peopleDelaySeqCool,
   15426             :                                       equipDelaySeqCool,
   15427             :                                       hvacLossDelaySeqCool,
   15428             :                                       powerGenDelaySeqCool,
   15429             :                                       lightDelaySeqCool,
   15430             :                                       feneSolarDelaySeqCool,
   15431          10 :                                       ort->feneCondInstantSeq,
   15432             :                                       surfDelaySeqCool);
   15433          10 :                     ComputeTableBodyUsingMovingAvg(state,
   15434          10 :                                                    facilityZonesCoolCompLoadTables.cells,
   15435          10 :                                                    facilityZonesCoolCompLoadTables.cellUsed,
   15436             :                                                    coolDesSelected,
   15437             :                                                    timeCoolMax,
   15438             :                                                    iZone,
   15439             :                                                    peopleDelaySeqCool,
   15440             :                                                    equipDelaySeqCool,
   15441             :                                                    hvacLossDelaySeqCool,
   15442             :                                                    powerGenDelaySeqCool,
   15443             :                                                    lightDelaySeqCool,
   15444             :                                                    feneSolarDelaySeqCool,
   15445          10 :                                                    ort->feneCondInstantSeq,
   15446             :                                                    surfDelaySeqCool);
   15447          10 :                     CollectPeakZoneConditions(state, facilityZonesCoolCompLoadTables, coolDesSelected, timeCoolMax, iZone, true);
   15448          10 :                     AddAreaColumnForZone(iZone, ZoneComponentAreas, facilityZonesCoolCompLoadTables);
   15449             :                 }
   15450          10 :                 facilityZonesCoolCompLoadTables.timeStepMax = timeCoolMax;
   15451          10 :                 facilityZonesCoolCompLoadTables.desDayNum = coolDesSelected;
   15452          10 :                 CombineLoadCompResults(FacilityCoolCompLoadTables, facilityZonesCoolCompLoadTables, mult);
   15453             : 
   15454          20 :                 if (ort->displayZoneComponentLoadSummary && (heatDesSelected == ZoneHeatCompLoadTables(iZone).desDayNum) &&
   15455          10 :                     (timeHeatMax == ZoneHeatCompLoadTables(iZone).timeStepMax)) {
   15456          10 :                     facilityZonesHeatCompLoadTables = ZoneHeatCompLoadTables(iZone);
   15457             :                 } else {
   15458           0 :                     GetDelaySequences(state,
   15459             :                                       heatDesSelected,
   15460             :                                       false,
   15461             :                                       iZone,
   15462             :                                       peopleDelaySeqHeat,
   15463             :                                       equipDelaySeqHeat,
   15464             :                                       hvacLossDelaySeqHeat,
   15465             :                                       powerGenDelaySeqHeat,
   15466             :                                       lightDelaySeqHeat,
   15467             :                                       feneSolarDelaySeqHeat,
   15468           0 :                                       ort->feneCondInstantSeq,
   15469             :                                       surfDelaySeqHeat);
   15470           0 :                     ComputeTableBodyUsingMovingAvg(state,
   15471           0 :                                                    facilityZonesHeatCompLoadTables.cells,
   15472           0 :                                                    facilityZonesHeatCompLoadTables.cellUsed,
   15473             :                                                    heatDesSelected,
   15474             :                                                    timeHeatMax,
   15475             :                                                    iZone,
   15476             :                                                    peopleDelaySeqHeat,
   15477             :                                                    equipDelaySeqHeat,
   15478             :                                                    hvacLossDelaySeqHeat,
   15479             :                                                    powerGenDelaySeqHeat,
   15480             :                                                    lightDelaySeqHeat,
   15481             :                                                    feneSolarDelaySeqHeat,
   15482           0 :                                                    ort->feneCondInstantSeq,
   15483             :                                                    surfDelaySeqHeat);
   15484           0 :                     CollectPeakZoneConditions(state, facilityZonesHeatCompLoadTables, heatDesSelected, timeHeatMax, iZone, false);
   15485           0 :                     AddAreaColumnForZone(iZone, ZoneComponentAreas, facilityZonesHeatCompLoadTables);
   15486             :                 }
   15487          10 :                 facilityZonesHeatCompLoadTables.timeStepMax = timeHeatMax;
   15488          10 :                 facilityZonesHeatCompLoadTables.desDayNum = heatDesSelected;
   15489          10 :                 CombineLoadCompResults(FacilityHeatCompLoadTables, facilityZonesHeatCompLoadTables, mult);
   15490             :             }
   15491             : 
   15492           2 :             auto &facilityCoolTable = FacilityCoolCompLoadTables;
   15493           2 :             auto &facilityHeatTable = FacilityHeatCompLoadTables;
   15494           2 :             facilityCoolTable.peakDesSensLoad = 0.0;
   15495           2 :             facilityCoolTable.designPeakLoad = 0.0;
   15496           2 :             facilityHeatTable.peakDesSensLoad = 0.0;
   15497           2 :             facilityHeatTable.designPeakLoad = 0.0;
   15498           2 :             facilityCoolTable.diffPeakEst = 0.0;
   15499           2 :             facilityHeatTable.diffPeakEst = 0.0;
   15500           2 :             facilityCoolTable.diffDesignPeak = 0.0;
   15501           4 :             for (int iAirLoop = 1; iAirLoop <= NumPrimaryAirSys; ++iAirLoop) {
   15502           2 :                 facilityCoolTable.peakDesSensLoad += AirLoopCoolCompLoadTables(iAirLoop).peakDesSensLoad;
   15503           2 :                 facilityCoolTable.designPeakLoad += AirLoopCoolCompLoadTables(iAirLoop).designPeakLoad;
   15504           2 :                 facilityHeatTable.peakDesSensLoad += AirLoopHeatCompLoadTables(iAirLoop).peakDesSensLoad;
   15505           2 :                 facilityHeatTable.designPeakLoad += AirLoopHeatCompLoadTables(iAirLoop).designPeakLoad;
   15506           2 :                 facilityCoolTable.diffPeakEst += AirLoopCoolCompLoadTables(iAirLoop).diffPeakEst;
   15507           2 :                 facilityCoolTable.diffDesignPeak += AirLoopCoolCompLoadTables(iAirLoop).diffDesignPeak;
   15508           2 :                 facilityHeatTable.diffPeakEst += AirLoopHeatCompLoadTables(iAirLoop).diffPeakEst;
   15509           2 :                 facilityCoolTable.diffDesignPeak += AirLoopHeatCompLoadTables(iAirLoop).diffDesignPeak;
   15510             :             }
   15511             : 
   15512           2 :             ComputeEngineeringChecks(FacilityCoolCompLoadTables);
   15513           2 :             ComputeEngineeringChecks(FacilityHeatCompLoadTables);
   15514             : 
   15515           2 :             AddTotalRowsForLoadSummary(FacilityCoolCompLoadTables);
   15516           2 :             AddTotalRowsForLoadSummary(FacilityHeatCompLoadTables);
   15517             : 
   15518           2 :             ComputePeakDifference(FacilityCoolCompLoadTables);
   15519           2 :             ComputePeakDifference(FacilityHeatCompLoadTables);
   15520             : 
   15521           2 :             LoadSummaryUnitConversion(state, FacilityCoolCompLoadTables, unitsStyle_cur);
   15522           2 :             LoadSummaryUnitConversion(state, FacilityHeatCompLoadTables, unitsStyle_cur);
   15523             : 
   15524           2 :             OutputCompLoadSummary(state,
   15525             :                                   OutputType::Facility,
   15526             :                                   FacilityCoolCompLoadTables,
   15527             :                                   FacilityHeatCompLoadTables,
   15528             :                                   0,
   15529             :                                   unitsStyle_cur,
   15530             :                                   produceTabular,
   15531             :                                   produceSQLite);
   15532             :         }
   15533             : 
   15534             :         // ZoneComponentLoadSummary: Now we convert and Display
   15535          27 :         if (ort->displayZoneComponentLoadSummary) {
   15536         242 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15537         215 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) continue;
   15538         185 :                 if (allocated(state.dataSize->CalcFinalZoneSizing)) {
   15539         185 :                     LoadSummaryUnitConversion(state, ZoneCoolCompLoadTables(iZone), unitsStyle_cur);
   15540         185 :                     LoadSummaryUnitConversion(state, ZoneHeatCompLoadTables(iZone), unitsStyle_cur);
   15541             : 
   15542         370 :                     OutputCompLoadSummary(state,
   15543             :                                           OutputType::Zone,
   15544         185 :                                           ZoneCoolCompLoadTables(iZone),
   15545         185 :                                           ZoneHeatCompLoadTables(iZone),
   15546             :                                           iZone,
   15547             :                                           unitsStyle_cur,
   15548             :                                           produceTabular,
   15549             :                                           produceSQLite);
   15550             :                 }
   15551             :             }
   15552             :         }
   15553             : 
   15554          27 :         ZoneHeatCompLoadTables.deallocate();
   15555          27 :         ZoneCoolCompLoadTables.deallocate();
   15556          27 :         AirLoopHeatCompLoadTables.deallocate();
   15557          27 :         AirLoopCoolCompLoadTables.deallocate();
   15558          27 :         AirLoopZonesHeatCompLoadTables.deallocate();
   15559          27 :         AirLoopZonesCoolCompLoadTables.deallocate();
   15560             : 
   15561          27 :         FacilityHeatCompLoadTables.cells.deallocate();
   15562          27 :         FacilityHeatCompLoadTables.cellUsed.deallocate();
   15563          27 :         FacilityCoolCompLoadTables.cells.deallocate();
   15564          27 :         FacilityCoolCompLoadTables.cellUsed.deallocate();
   15565             : 
   15566          27 :         FacilityZonesHeatCompLoadTables.deallocate();
   15567          27 :         FacilityZonesCoolCompLoadTables.deallocate();
   15568             : 
   15569          27 :         peopleDelaySeqHeat.deallocate();
   15570          27 :         peopleDelaySeqCool.deallocate();
   15571          27 :         lightDelaySeqHeat.deallocate();
   15572          27 :         lightDelaySeqCool.deallocate();
   15573          27 :         equipDelaySeqHeat.deallocate();
   15574          27 :         equipDelaySeqCool.deallocate();
   15575          27 :         hvacLossDelaySeqHeat.deallocate();
   15576          27 :         hvacLossDelaySeqCool.deallocate();
   15577          27 :         powerGenDelaySeqHeat.deallocate();
   15578          27 :         powerGenDelaySeqCool.deallocate();
   15579          27 :         feneSolarDelaySeqHeat.deallocate();
   15580          27 :         feneSolarDelaySeqCool.deallocate();
   15581          27 :         surfDelaySeqHeat.deallocate();
   15582          27 :         surfDelaySeqCool.deallocate();
   15583          27 :     }
   15584          27 : }
   15585             : 
   15586             : // populate the delay sequence arrays for the component load summary table output
   15587         400 : void GetDelaySequences(EnergyPlusData &state,
   15588             :                        int const desDaySelected,
   15589             :                        bool const isCooling,
   15590             :                        int const zoneIndex,
   15591             :                        Array1D<Real64> &peopleDelaySeq,
   15592             :                        Array1D<Real64> &equipDelaySeq,
   15593             :                        Array1D<Real64> &hvacLossDelaySeq,
   15594             :                        Array1D<Real64> &powerGenDelaySeq,
   15595             :                        Array1D<Real64> &lightDelaySeq,
   15596             :                        Array1D<Real64> &feneSolarDelaySeq,
   15597             :                        Array3D<Real64> &feneCondInstantSeq,
   15598             :                        Array2D<Real64> &surfDelaySeq)
   15599             : {
   15600             : 
   15601             :     // static bool initAdjFenDone(false); moved to anonymous namespace for unit testing
   15602         400 :     auto &ort = state.dataOutRptTab;
   15603             : 
   15604         400 :     if (!ort->initAdjFenDone) {
   15605          81 :         state.dataOutRptTab->adjFenDone.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   15606          27 :                                                  state.dataGlobal->NumOfTimeStepInHour * 24,
   15607          27 :                                                  state.dataGlobal->NumOfZones);
   15608          27 :         state.dataOutRptTab->adjFenDone = false;
   15609          27 :         ort->initAdjFenDone = true;
   15610             :     }
   15611             : 
   15612         400 :     if (desDaySelected != 0) {
   15613             : 
   15614         400 :         Array2D<Real64> decayCurve;
   15615         400 :         if (isCooling) {
   15616         205 :             decayCurve = ort->decayCurveCool;
   15617             :         } else {
   15618         195 :             decayCurve = ort->decayCurveHeat;
   15619             :         }
   15620             : 
   15621       38800 :         for (int kTimeStep = 1; kTimeStep <= state.dataGlobal->NumOfTimeStepInHour * 24; ++kTimeStep) {
   15622       38400 :             Real64 peopleConvIntoZone = 0.0;
   15623       38400 :             Real64 equipConvIntoZone = 0.0;
   15624       38400 :             Real64 hvacLossConvIntoZone = 0.0;
   15625       38400 :             Real64 powerGenConvIntoZone = 0.0;
   15626       38400 :             Real64 lightLWConvIntoZone = 0.0;
   15627       38400 :             Real64 lightSWConvIntoZone = 0.0;
   15628       38400 :             Real64 feneSolarConvIntoZone = 0.0;
   15629       38400 :             Real64 adjFeneSurfNetRadSeq = 0.0;
   15630             : 
   15631             :             // code from ComputeDelayedComponents starts
   15632       79104 :             for (int spaceNum : state.dataHeatBal->Zone(zoneIndex).spaceIndexes) {
   15633       40704 :                 auto const &thisSpace = state.dataHeatBal->space(spaceNum);
   15634      320064 :                 for (int jSurf = thisSpace.HTSurfaceFirst; jSurf <= thisSpace.HTSurfaceLast; ++jSurf) {
   15635      279360 :                     int radEnclosureNum = state.dataSurface->Surface(jSurf).RadEnclIndex;
   15636             : 
   15637             :                     // for each time step, step back through time and apply decay curve to radiant heat for each end use absorbed in each surface
   15638      279360 :                     Real64 peopleConvFromSurf = 0.0;
   15639      279360 :                     Real64 equipConvFromSurf = 0.0;
   15640      279360 :                     Real64 hvacLossConvFromSurf = 0.0;
   15641      279360 :                     Real64 powerGenConvFromSurf = 0.0;
   15642      279360 :                     Real64 lightLWConvFromSurf = 0.0;
   15643      279360 :                     Real64 lightSWConvFromSurf = 0.0;
   15644      279360 :                     Real64 feneSolarConvFromSurf = 0.0;
   15645             : 
   15646    13828320 :                     for (int mStepBack = 1; mStepBack <= kTimeStep; ++mStepBack) {
   15647    13548960 :                         int sourceStep = kTimeStep - mStepBack + 1;
   15648    13548960 :                         Real64 thisQRadThermInAbsMult = ort->TMULTseq(desDaySelected, sourceStep, radEnclosureNum) *
   15649    13548960 :                                                         ort->ITABSFseq(desDaySelected, sourceStep, jSurf) * state.dataSurface->Surface(jSurf).Area *
   15650    13548960 :                                                         decayCurve(mStepBack, jSurf);
   15651    13548960 :                         peopleConvFromSurf += ort->peopleRadSeq(desDaySelected, sourceStep, zoneIndex) * thisQRadThermInAbsMult;
   15652    13548960 :                         equipConvFromSurf += ort->equipRadSeq(desDaySelected, sourceStep, zoneIndex) * thisQRadThermInAbsMult;
   15653    13548960 :                         hvacLossConvFromSurf += ort->hvacLossRadSeq(desDaySelected, sourceStep, zoneIndex) * thisQRadThermInAbsMult;
   15654    13548960 :                         powerGenConvFromSurf += ort->powerGenRadSeq(desDaySelected, sourceStep, zoneIndex) * thisQRadThermInAbsMult;
   15655    13548960 :                         lightLWConvFromSurf += ort->lightLWRadSeq(desDaySelected, sourceStep, zoneIndex) * thisQRadThermInAbsMult;
   15656             :                         // short wave is already accumulated by surface
   15657    13548960 :                         lightSWConvFromSurf += ort->lightSWRadSeq(desDaySelected, sourceStep, jSurf) * decayCurve(mStepBack, jSurf);
   15658    13548960 :                         feneSolarConvFromSurf += ort->feneSolarRadSeq(desDaySelected, sourceStep, jSurf) * decayCurve(mStepBack, jSurf);
   15659             :                     } // for mStepBack
   15660             : 
   15661      279360 :                     peopleConvIntoZone += peopleConvFromSurf;
   15662      279360 :                     equipConvIntoZone += equipConvFromSurf;
   15663      279360 :                     hvacLossConvIntoZone += hvacLossConvFromSurf;
   15664      279360 :                     powerGenConvIntoZone += powerGenConvFromSurf;
   15665      279360 :                     lightLWConvIntoZone += lightLWConvFromSurf;
   15666      279360 :                     lightSWConvIntoZone += lightSWConvFromSurf;
   15667      279360 :                     feneSolarConvIntoZone += feneSolarConvFromSurf;
   15668             :                     // code from ComputeDelayedComponents ends
   15669             :                     // determine the remaining convective heat from the surfaces that are not based
   15670             :                     // on any of these other loads
   15671             :                     // negative because heat from surface should be positive
   15672      558720 :                     surfDelaySeq(kTimeStep, jSurf) =
   15673      279360 :                         -ort->loadConvectedNormal(desDaySelected, kTimeStep, jSurf) - ort->netSurfRadSeq(desDaySelected, kTimeStep, jSurf) -
   15674      279360 :                         (peopleConvFromSurf + equipConvFromSurf + hvacLossConvFromSurf + powerGenConvFromSurf + lightLWConvFromSurf +
   15675      279360 :                          lightSWConvFromSurf +
   15676             :                          feneSolarConvFromSurf); // remove net radiant for the surface
   15677             :                                                  // also remove the net radiant component on the instanteous conduction for fenestration
   15678      279360 :                     if (state.dataSurface->Surface(jSurf).Class == DataSurfaces::SurfaceClass::Window) {
   15679       41856 :                         adjFeneSurfNetRadSeq += ort->netSurfRadSeq(desDaySelected, kTimeStep, jSurf);
   15680             :                     }
   15681             :                 } // for jSurf
   15682       38400 :             }
   15683       38400 :             peopleDelaySeq(kTimeStep) = peopleConvIntoZone;
   15684       38400 :             equipDelaySeq(kTimeStep) = equipConvIntoZone;
   15685       38400 :             hvacLossDelaySeq(kTimeStep) = hvacLossConvIntoZone;
   15686       38400 :             powerGenDelaySeq(kTimeStep) = powerGenConvIntoZone;
   15687             :             // combine short wave (visible) and long wave (thermal) impacts
   15688       38400 :             lightDelaySeq(kTimeStep) = lightLWConvIntoZone + lightSWConvIntoZone;
   15689       38400 :             feneSolarDelaySeq(kTimeStep) = feneSolarConvIntoZone;
   15690             :             // also remove the net radiant component on the instanteous conduction for fenestration
   15691       38400 :             if (!state.dataOutRptTab->adjFenDone(desDaySelected, kTimeStep, zoneIndex)) {
   15692       35520 :                 feneCondInstantSeq(desDaySelected, kTimeStep, zoneIndex) -= adjFeneSurfNetRadSeq;
   15693       35520 :                 state.dataOutRptTab->adjFenDone(desDaySelected, kTimeStep, zoneIndex) = true;
   15694             :             }
   15695             :         } // for kTimeStep
   15696             : 
   15697         400 :         decayCurve.deallocate();
   15698             : 
   15699         400 :     } // if desDaySelected != 0
   15700         400 : }
   15701             : 
   15702             : // set the load summary table cells based on the load sequences using moving averages to smooth out
   15703         400 : void ComputeTableBodyUsingMovingAvg(EnergyPlusData &state,
   15704             :                                     Array2D<Real64> &resultCells,
   15705             :                                     Array2D_bool &resCellsUsd,
   15706             :                                     int const desDaySelected,
   15707             :                                     int const timeOfMax,
   15708             :                                     int const zoneIndex,
   15709             :                                     Array1D<Real64> const &peopleDelaySeq,
   15710             :                                     Array1D<Real64> const &equipDelaySeq,
   15711             :                                     Array1D<Real64> const &hvacLossDelaySeq,
   15712             :                                     Array1D<Real64> const &powerGenDelaySeq,
   15713             :                                     Array1D<Real64> const &lightDelaySeq,
   15714             :                                     Array1D<Real64> const &feneSolarDelaySeq,
   15715             :                                     Array3D<Real64> const &feneCondInstantSeq,
   15716             :                                     Array2D<Real64> const &surfDelaySeq)
   15717             : {
   15718         400 :     Array1D<Real64> AvgData;     // sequence data to be averaging
   15719         400 :     Array1D<Real64> delayOpaque; // hold values for report for delayed opaque
   15720             : 
   15721         400 :     resultCells = 0.;
   15722         400 :     resCellsUsd = false;
   15723         400 :     delayOpaque.allocate(LoadCompRow::GrdTot);
   15724         400 :     AvgData.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   15725             : 
   15726         400 :     if (desDaySelected != 0 && timeOfMax != 0) {
   15727             :         // Don't update/average original array data
   15728             :         // PEOPLE
   15729         400 :         AvgData = state.dataOutRptTab->peopleInstantSeq(desDaySelected, _, zoneIndex);
   15730         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15731         400 :         resultCells(LoadCompCol::SensInst, LoadCompRow::People) = AvgData(timeOfMax);
   15732         400 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::People) = true;
   15733         400 :         AvgData = state.dataOutRptTab->peopleLatentSeq(desDaySelected, _, zoneIndex);
   15734         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15735         400 :         resultCells(LoadCompCol::Latent, LoadCompRow::People) = AvgData(timeOfMax);
   15736         400 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::People) = true;
   15737         400 :         AvgData = peopleDelaySeq(_);
   15738         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15739         400 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::People) = AvgData(timeOfMax);
   15740         400 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::People) = true;
   15741             : 
   15742             :         // LIGHTS
   15743         400 :         AvgData = state.dataOutRptTab->lightInstantSeq(desDaySelected, _, zoneIndex);
   15744         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15745         400 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Lights) = AvgData(timeOfMax);
   15746         400 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Lights) = true;
   15747         400 :         AvgData = state.dataOutRptTab->lightRetAirSeq(desDaySelected, _, zoneIndex);
   15748         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15749         400 :         resultCells(LoadCompCol::SensRA, LoadCompRow::Lights) = AvgData(timeOfMax);
   15750         400 :         resCellsUsd(LoadCompCol::SensRA, LoadCompRow::Lights) = true;
   15751         400 :         AvgData = lightDelaySeq(_);
   15752         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15753         400 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::Lights) = AvgData(timeOfMax);
   15754         400 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::Lights) = true;
   15755             : 
   15756             :         // EQUIPMENT
   15757         400 :         AvgData = state.dataOutRptTab->equipInstantSeq(desDaySelected, _, zoneIndex);
   15758         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15759         400 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Equip) = AvgData(timeOfMax);
   15760         400 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Equip) = true;
   15761         400 :         AvgData = state.dataOutRptTab->equipLatentSeq(desDaySelected, _, zoneIndex);
   15762         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15763         400 :         resultCells(LoadCompCol::Latent, LoadCompRow::Equip) = AvgData(timeOfMax);
   15764         400 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::Equip) = true;
   15765         400 :         AvgData = equipDelaySeq(_);
   15766         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15767         400 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::Equip) = AvgData(timeOfMax);
   15768         400 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::Equip) = true;
   15769             : 
   15770             :         // REFRIGERATION EQUIPMENT
   15771         400 :         AvgData = state.dataOutRptTab->refrigInstantSeq(desDaySelected, _, zoneIndex);
   15772         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15773         400 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Refrig) = AvgData(timeOfMax);
   15774         400 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Refrig) = true;
   15775         400 :         AvgData = state.dataOutRptTab->refrigRetAirSeq(desDaySelected, _, zoneIndex);
   15776         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15777         400 :         resultCells(LoadCompCol::SensRA, LoadCompRow::Refrig) = AvgData(timeOfMax);
   15778         400 :         resCellsUsd(LoadCompCol::SensRA, LoadCompRow::Refrig) = true;
   15779         400 :         AvgData = state.dataOutRptTab->refrigLatentSeq(desDaySelected, _, zoneIndex);
   15780         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15781         400 :         resultCells(LoadCompCol::Latent, LoadCompRow::Refrig) = AvgData(timeOfMax);
   15782         400 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::Refrig) = true;
   15783             : 
   15784             :         // WATER USE EQUIPMENT
   15785         400 :         AvgData = state.dataOutRptTab->waterUseInstantSeq(desDaySelected, _, zoneIndex);
   15786         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15787         400 :         resultCells(LoadCompCol::SensInst, LoadCompRow::WaterUse) = AvgData(timeOfMax);
   15788         400 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::WaterUse) = true;
   15789         400 :         AvgData = state.dataOutRptTab->waterUseLatentSeq(desDaySelected, _, zoneIndex);
   15790         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15791         400 :         resultCells(LoadCompCol::Latent, LoadCompRow::WaterUse) = AvgData(timeOfMax);
   15792         400 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::WaterUse) = true;
   15793             : 
   15794             :         // HVAC EQUIPMENT LOSSES
   15795         400 :         AvgData = state.dataOutRptTab->hvacLossInstantSeq(desDaySelected, _, zoneIndex);
   15796         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15797         400 :         resultCells(LoadCompCol::SensInst, LoadCompRow::HvacLoss) = AvgData(timeOfMax);
   15798         400 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::HvacLoss) = true;
   15799         400 :         AvgData = hvacLossDelaySeq(_);
   15800         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15801         400 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::HvacLoss) = AvgData(timeOfMax);
   15802         400 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::HvacLoss) = true;
   15803             : 
   15804             :         // POWER GENERATION EQUIPMENT
   15805         400 :         AvgData = state.dataOutRptTab->powerGenInstantSeq(desDaySelected, _, zoneIndex);
   15806         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15807         400 :         resultCells(LoadCompCol::SensInst, LoadCompRow::PowerGen) = AvgData(timeOfMax);
   15808         400 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::PowerGen) = true;
   15809         400 :         AvgData = powerGenDelaySeq(_);
   15810         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15811         400 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::PowerGen) = AvgData(timeOfMax);
   15812         400 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::PowerGen) = true;
   15813             : 
   15814             :         // DOAS
   15815         400 :         Real64 const mult = state.dataHeatBal->Zone(zoneIndex).Multiplier * state.dataHeatBal->Zone(zoneIndex).ListMultiplier;
   15816         800 :         resultCells(LoadCompCol::SensInst, LoadCompRow::DOAS) =
   15817         400 :             state.dataSize->CalcZoneSizing(desDaySelected, zoneIndex).DOASHeatAddSeq(timeOfMax) / mult;
   15818         400 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::DOAS) = true;
   15819         800 :         resultCells(LoadCompCol::Latent, LoadCompRow::DOAS) =
   15820         400 :             state.dataSize->CalcZoneSizing(desDaySelected, zoneIndex).DOASLatAddSeq(timeOfMax) / mult;
   15821         400 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::DOAS) = true;
   15822             : 
   15823             :         // INFILTRATION
   15824         400 :         AvgData = state.dataOutRptTab->infilInstantSeq(desDaySelected, _, zoneIndex);
   15825         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15826         400 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Infil) = AvgData(timeOfMax);
   15827         400 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Infil) = true;
   15828         400 :         AvgData = state.dataOutRptTab->infilLatentSeq(desDaySelected, _, zoneIndex);
   15829         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15830         400 :         resultCells(LoadCompCol::Latent, LoadCompRow::Infil) = AvgData(timeOfMax);
   15831         400 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::Infil) = true;
   15832             : 
   15833             :         // ZONE VENTILATION
   15834         400 :         AvgData = state.dataOutRptTab->zoneVentInstantSeq(desDaySelected, _, zoneIndex);
   15835         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15836         400 :         resultCells(LoadCompCol::SensInst, LoadCompRow::ZoneVent) = AvgData(timeOfMax);
   15837         400 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::ZoneVent) = true;
   15838         400 :         AvgData = state.dataOutRptTab->zoneVentLatentSeq(desDaySelected, _, zoneIndex);
   15839         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15840         400 :         resultCells(LoadCompCol::Latent, LoadCompRow::ZoneVent) = AvgData(timeOfMax);
   15841         400 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::ZoneVent) = true;
   15842             : 
   15843             :         // INTERZONE MIXING
   15844         400 :         AvgData = state.dataOutRptTab->interZoneMixInstantSeq(desDaySelected, _, zoneIndex);
   15845         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15846         400 :         resultCells(LoadCompCol::SensInst, LoadCompRow::IntZonMix) = AvgData(timeOfMax);
   15847         400 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::IntZonMix) = true;
   15848         400 :         AvgData = state.dataOutRptTab->interZoneMixLatentSeq(desDaySelected, _, zoneIndex);
   15849         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15850         400 :         resultCells(LoadCompCol::Latent, LoadCompRow::IntZonMix) = AvgData(timeOfMax);
   15851         400 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::IntZonMix) = true;
   15852             : 
   15853             :         // FENESTRATION CONDUCTION
   15854         400 :         AvgData = feneCondInstantSeq(desDaySelected, _, zoneIndex);
   15855         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15856         400 :         resultCells(LoadCompCol::SensInst, LoadCompRow::FeneCond) = AvgData(timeOfMax);
   15857         400 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::FeneCond) = true;
   15858             : 
   15859             :         // FENESTRATION SOLAR
   15860         400 :         AvgData = feneSolarDelaySeq(_);
   15861         400 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15862         400 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::FeneSolr) = AvgData(timeOfMax);
   15863         400 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::FeneSolr) = true;
   15864             : 
   15865             :         // opaque surfaces - must combine individual surfaces by class and other side conditions
   15866         400 :         delayOpaque = 0.0;
   15867         824 :         for (int spaceNum : state.dataHeatBal->Zone(zoneIndex).spaceIndexes) {
   15868         424 :             auto const &thisSpace = state.dataHeatBal->space(spaceNum);
   15869        3334 :             for (int kSurf = thisSpace.HTSurfaceFirst; kSurf <= thisSpace.HTSurfaceLast; ++kSurf) {
   15870             : 
   15871        2910 :                 int curExtBoundCond = state.dataSurface->Surface(kSurf).ExtBoundCond;
   15872             :                 // if exterior is other side coefficients using ground preprocessor terms then
   15873             :                 // set it to ground instead of other side coefficients
   15874        2910 :                 if (curExtBoundCond == DataSurfaces::OtherSideCoefNoCalcExt || curExtBoundCond == DataSurfaces::OtherSideCoefCalcExt) {
   15875           0 :                     if (has_prefixi(state.dataSurface->OSC(state.dataSurface->Surface(kSurf).OSCPtr).Name, "surfPropOthSdCoef")) {
   15876           0 :                         curExtBoundCond = DataSurfaces::Ground;
   15877             :                     }
   15878             :                 }
   15879        2910 :                 AvgData = surfDelaySeq(_, kSurf);
   15880        2910 :                 General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15881        2910 :                 Real64 singleSurfDelay = AvgData(timeOfMax);
   15882        2910 :                 switch (state.dataSurface->Surface(kSurf).Class) {
   15883        1612 :                 case DataSurfaces::SurfaceClass::Wall: {
   15884             :                     switch (curExtBoundCond) {
   15885         332 :                     case DataSurfaces::ExternalEnvironment: {
   15886         332 :                         delayOpaque(LoadCompRow::ExtWall) += singleSurfDelay;
   15887         332 :                     } break;
   15888           0 :                     case DataSurfaces::Ground:
   15889             :                     case DataSurfaces::GroundFCfactorMethod:
   15890             :                     case DataSurfaces::KivaFoundation: {
   15891           0 :                         delayOpaque(LoadCompRow::GrdWall) += singleSurfDelay;
   15892           0 :                     } break;
   15893           0 :                     case DataSurfaces::OtherSideCoefNoCalcExt:
   15894             :                     case DataSurfaces::OtherSideCoefCalcExt:
   15895             :                     case DataSurfaces::OtherSideCondModeledExt: {
   15896           0 :                         delayOpaque(LoadCompRow::OtherWall) += singleSurfDelay;
   15897           0 :                     } break;
   15898        1280 :                     default: { // interzone
   15899        1280 :                         delayOpaque(LoadCompRow::IntZonWall) += singleSurfDelay;
   15900        1280 :                     } break;
   15901             :                     }
   15902        1612 :                 } break;
   15903         418 :                 case DataSurfaces::SurfaceClass::Floor: {
   15904             :                     switch (curExtBoundCond) {
   15905           0 :                     case DataSurfaces::ExternalEnvironment: {
   15906           0 :                         delayOpaque(LoadCompRow::ExtFlr) += singleSurfDelay;
   15907           0 :                     } break;
   15908         318 :                     case DataSurfaces::Ground:
   15909             :                     case DataSurfaces::GroundFCfactorMethod:
   15910             :                     case DataSurfaces::KivaFoundation: {
   15911         318 :                         delayOpaque(LoadCompRow::GrdFlr) += singleSurfDelay;
   15912         318 :                     } break;
   15913           0 :                     case DataSurfaces::OtherSideCoefNoCalcExt:
   15914             :                     case DataSurfaces::OtherSideCoefCalcExt:
   15915             :                     case DataSurfaces::OtherSideCondModeledExt: {
   15916           0 :                         delayOpaque(LoadCompRow::OtherFlr) += singleSurfDelay;
   15917           0 :                     } break;
   15918         100 :                     default: { // interzone
   15919         100 :                         delayOpaque(LoadCompRow::IntZonFlr) += singleSurfDelay;
   15920         100 :                     } break;
   15921             :                     }
   15922         418 :                 } break;
   15923         412 :                 case DataSurfaces::SurfaceClass::Roof: {
   15924             :                     switch (curExtBoundCond) {
   15925           0 :                     case DataSurfaces::ExternalEnvironment: {
   15926           0 :                         delayOpaque(LoadCompRow::Roof) += singleSurfDelay;
   15927           0 :                     } break;
   15928           0 :                     case DataSurfaces::Ground:
   15929             :                     case DataSurfaces::GroundFCfactorMethod:
   15930             :                     case DataSurfaces::KivaFoundation:
   15931             :                     case DataSurfaces::OtherSideCoefNoCalcExt:
   15932             :                     case DataSurfaces::OtherSideCoefCalcExt:
   15933             :                     case DataSurfaces::OtherSideCondModeledExt: {
   15934           0 :                         delayOpaque(LoadCompRow::OtherRoof) += singleSurfDelay;
   15935           0 :                     } break;
   15936         412 :                     default: { // interzone
   15937         412 :                         delayOpaque(LoadCompRow::IntZonCeil) += singleSurfDelay;
   15938         412 :                     } break;
   15939             :                     }
   15940         412 :                 } break;
   15941           0 :                 case DataSurfaces::SurfaceClass::Door: {
   15942           0 :                     delayOpaque(LoadCompRow::OpqDoor) += singleSurfDelay;
   15943           0 :                 } break;
   15944         468 :                 default:
   15945         468 :                     break;
   15946             :                 }
   15947             :             }
   15948         400 :         }
   15949        4800 :         for (int k = LoadCompRow::Roof; k <= LoadCompRow::OtherFlr; ++k) {
   15950        4400 :             resultCells(LoadCompCol::SensDelay, k) = delayOpaque(k);
   15951        4400 :             resCellsUsd(LoadCompCol::SensDelay, k) = true;
   15952             :         }
   15953         400 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::OpqDoor) = delayOpaque(LoadCompRow::OpqDoor);
   15954         400 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::OpqDoor) = true;
   15955             :     }
   15956         400 : }
   15957             : 
   15958             : // for the load summary report add values the peak conditions subtable
   15959         400 : void CollectPeakZoneConditions(
   15960             :     EnergyPlusData &state, CompLoadTablesType &compLoad, int const desDaySelected, int const timeOfMax, int const zoneIndex, bool const isCooling)
   15961             : {
   15962             : 
   15963         400 :     if (timeOfMax != 0) {
   15964             : 
   15965         400 :         auto const &thisZone = state.dataHeatBal->Zone(zoneIndex);
   15966         400 :         auto const &thisCalcFinalZoneSizing = state.dataSize->CalcFinalZoneSizing(zoneIndex);
   15967             : 
   15968         400 :         Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   15969         400 :         if (mult == 0.0) mult = 1.0;
   15970             : 
   15971         400 :         if (isCooling) {
   15972             :             // Time of Peak Load
   15973         205 :             if ((desDaySelected > 0) && ((size_t)desDaySelected <= state.dataWeather->DesDayInput.size())) {
   15974         615 :                 compLoad.peakDateHrMin = format("{}/{} {}",
   15975         205 :                                                 state.dataWeather->DesDayInput(desDaySelected).Month,
   15976         205 :                                                 state.dataWeather->DesDayInput(desDaySelected).DayOfMonth,
   15977         410 :                                                 state.dataRptCoilSelection->coilSelectionReportObj->getTimeText(state, timeOfMax));
   15978             :             } else {
   15979           0 :                 compLoad.peakDateHrMin = thisCalcFinalZoneSizing.CoolPeakDateHrMin;
   15980             :             }
   15981             : 
   15982             :             // Outside Dry Bulb Temperature
   15983         205 :             compLoad.outsideDryBulb = thisCalcFinalZoneSizing.CoolOutTempSeq(timeOfMax);
   15984             : 
   15985             :             // Outside Wet Bulb Temperature
   15986             :             // use standard air pressure because air pressure is not tracked with sizing data
   15987         205 :             if (thisCalcFinalZoneSizing.CoolOutHumRatSeq(timeOfMax) < 1.0 && thisCalcFinalZoneSizing.CoolOutHumRatSeq(timeOfMax) > 0.0) {
   15988         410 :                 compLoad.outsideWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state,
   15989         205 :                                                                          thisCalcFinalZoneSizing.CoolOutTempSeq(timeOfMax),
   15990         205 :                                                                          thisCalcFinalZoneSizing.CoolOutHumRatSeq(timeOfMax),
   15991         205 :                                                                          state.dataEnvrn->StdBaroPress);
   15992             :             }
   15993             : 
   15994             :             // Outside Humidity Ratio at Peak
   15995         205 :             compLoad.outsideHumRatio = thisCalcFinalZoneSizing.CoolOutHumRatSeq(timeOfMax);
   15996             : 
   15997             :             // Zone Dry Bulb Temperature
   15998         205 :             compLoad.zoneDryBulb = thisCalcFinalZoneSizing.CoolZoneTempSeq(timeOfMax);
   15999             : 
   16000             :             // Zone Relative Humdity
   16001             :             // use standard air pressure because air pressure is not tracked with sizing data
   16002         205 :             compLoad.zoneRelHum = Psychrometrics::PsyRhFnTdbWPb(state,
   16003         205 :                                                                 thisCalcFinalZoneSizing.CoolZoneTempSeq(timeOfMax),
   16004         205 :                                                                 thisCalcFinalZoneSizing.CoolZoneHumRatSeq(timeOfMax),
   16005         205 :                                                                 state.dataEnvrn->StdBaroPress);
   16006             : 
   16007             :             // Zone Humidity Ratio at Peak
   16008         205 :             compLoad.zoneHumRatio = thisCalcFinalZoneSizing.CoolZoneHumRatSeq(timeOfMax);
   16009             : 
   16010             :             // Peak Design Sensible Load
   16011         205 :             compLoad.peakDesSensLoad = thisCalcFinalZoneSizing.DesCoolLoad / mult; // change sign
   16012             : 
   16013             :             // Design Peak Load
   16014         205 :             compLoad.designPeakLoad = state.dataSize->FinalZoneSizing(zoneIndex).DesCoolLoad / mult;
   16015             : 
   16016             :             // Supply air temperature
   16017         205 :             if (thisCalcFinalZoneSizing.ZnCoolDgnSAMethod == DataSizing::SupplyAirTemperature) {
   16018         150 :                 compLoad.supAirTemp = thisCalcFinalZoneSizing.CoolDesTemp;
   16019             :             } else {
   16020          55 :                 Real64 DeltaTemp = -std::abs(thisCalcFinalZoneSizing.CoolDesTempDiff);
   16021          55 :                 compLoad.supAirTemp = DeltaTemp + thisCalcFinalZoneSizing.ZoneTempAtCoolPeak;
   16022             :             }
   16023             : 
   16024             :             // Main fan air flow
   16025         205 :             compLoad.mainFanAirFlow = thisCalcFinalZoneSizing.DesCoolVolFlow;
   16026             : 
   16027             :         } else {
   16028             :             // Time of Peak Load
   16029         195 :             if ((size_t)desDaySelected <= state.dataWeather->DesDayInput.size()) {
   16030         585 :                 compLoad.peakDateHrMin = format("{}/{} {}",
   16031         195 :                                                 state.dataWeather->DesDayInput(desDaySelected).Month,
   16032         195 :                                                 state.dataWeather->DesDayInput(desDaySelected).DayOfMonth,
   16033         390 :                                                 state.dataRptCoilSelection->coilSelectionReportObj->getTimeText(state, timeOfMax));
   16034             :             } else {
   16035           0 :                 compLoad.peakDateHrMin = thisCalcFinalZoneSizing.HeatPeakDateHrMin;
   16036             :             }
   16037             : 
   16038             :             // Outside Dry Bulb Temperature
   16039         195 :             compLoad.outsideDryBulb = thisCalcFinalZoneSizing.HeatOutTempSeq(timeOfMax);
   16040             : 
   16041             :             // Outside Wet Bulb Temperature
   16042             :             // use standard air pressure because air pressure is not tracked with sizing data
   16043         195 :             if (thisCalcFinalZoneSizing.HeatOutHumRatSeq(timeOfMax) < 1.0 && thisCalcFinalZoneSizing.HeatOutHumRatSeq(timeOfMax) > 0.0) {
   16044         390 :                 compLoad.outsideWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state,
   16045         195 :                                                                          thisCalcFinalZoneSizing.HeatOutTempSeq(timeOfMax),
   16046         195 :                                                                          thisCalcFinalZoneSizing.HeatOutHumRatSeq(timeOfMax),
   16047         195 :                                                                          state.dataEnvrn->StdBaroPress);
   16048             :             }
   16049             : 
   16050             :             // Outside Humidity Ratio at Peak
   16051         195 :             compLoad.outsideHumRatio = thisCalcFinalZoneSizing.HeatOutHumRatSeq(timeOfMax);
   16052             : 
   16053             :             // Zone Dry Bulb Temperature
   16054         195 :             compLoad.zoneDryBulb = thisCalcFinalZoneSizing.HeatZoneTempSeq(timeOfMax);
   16055             : 
   16056             :             // Zone Relative Humdity
   16057             :             // use standard air pressure because air pressure is not tracked with sizing data
   16058         195 :             compLoad.zoneRelHum = Psychrometrics::PsyRhFnTdbWPb(state,
   16059         195 :                                                                 thisCalcFinalZoneSizing.HeatZoneTempSeq(timeOfMax),
   16060         195 :                                                                 thisCalcFinalZoneSizing.HeatZoneHumRatSeq(timeOfMax),
   16061         195 :                                                                 state.dataEnvrn->StdBaroPress);
   16062             : 
   16063             :             // Zone Humidity Ratio at Peak
   16064         195 :             compLoad.zoneHumRatio = thisCalcFinalZoneSizing.HeatZoneHumRatSeq(timeOfMax);
   16065             : 
   16066             :             // Peak Design Sensible Load
   16067         195 :             compLoad.peakDesSensLoad = -thisCalcFinalZoneSizing.DesHeatLoad / mult; // change sign
   16068             : 
   16069             :             // Design Peak Load
   16070         195 :             compLoad.designPeakLoad = -state.dataSize->FinalZoneSizing(zoneIndex).DesHeatLoad / mult;
   16071             : 
   16072             :             // Supply air temperature
   16073         195 :             if (thisCalcFinalZoneSizing.ZnHeatDgnSAMethod == DataSizing::SupplyAirTemperature) {
   16074         140 :                 compLoad.supAirTemp = thisCalcFinalZoneSizing.HeatDesTemp;
   16075             :             } else {
   16076          55 :                 Real64 DeltaTemp = -std::abs(thisCalcFinalZoneSizing.HeatDesTempDiff);
   16077          55 :                 compLoad.supAirTemp = DeltaTemp + thisCalcFinalZoneSizing.ZoneTempAtHeatPeak;
   16078             :             }
   16079             : 
   16080             :             // Main fan air flow
   16081         195 :             compLoad.mainFanAirFlow = thisCalcFinalZoneSizing.DesHeatVolFlow;
   16082             :         }
   16083             : 
   16084             :         // Outside air flow
   16085         400 :         compLoad.outsideAirFlow = thisCalcFinalZoneSizing.MinOA;
   16086             : 
   16087             :         // outside air %
   16088         400 :         if (compLoad.mainFanAirFlow != 0.) {
   16089         400 :             compLoad.outsideAirRatio = compLoad.outsideAirFlow / compLoad.mainFanAirFlow;
   16090             :         }
   16091             : 
   16092         400 :         compLoad.floorArea = thisZone.FloorArea;
   16093             : 
   16094         400 :         if (compLoad.floorArea != 0.) {
   16095             :             // airflow per floor area
   16096         400 :             compLoad.airflowPerFlrArea = compLoad.mainFanAirFlow / compLoad.floorArea;
   16097             : 
   16098             :             // capacity per floor area
   16099         400 :             compLoad.totCapPerArea = compLoad.designPeakLoad / compLoad.floorArea;
   16100             :         }
   16101         400 :         if (compLoad.designPeakLoad != 0.) {
   16102             :             // airflow per capacity
   16103         400 :             compLoad.airflowPerTotCap = compLoad.mainFanAirFlow / compLoad.designPeakLoad;
   16104             : 
   16105             :             // floor area per capacity
   16106         400 :             compLoad.areaPerTotCap = thisZone.FloorArea / compLoad.designPeakLoad;
   16107             :         }
   16108             : 
   16109             :         // Number of people
   16110         400 :         Real64 const totNumPeople = std::accumulate(state.dataHeatBal->People.cbegin(),
   16111         800 :                                                     state.dataHeatBal->People.cend(),
   16112             :                                                     0.0,
   16113        7890 :                                                     [&zoneIndex](const Real64 &sum, const DataHeatBalance::PeopleData &people) {
   16114        7890 :                                                         return zoneIndex == people.ZonePtr ? (sum + people.NumberOfPeople) : sum;
   16115             :                                                     });
   16116         400 :         compLoad.numPeople = totNumPeople;
   16117             :     }
   16118         400 : }
   16119             : 
   16120           8 : void ComputeEngineeringChecks(CompLoadTablesType &compLoad)
   16121             : {
   16122             :     // outside air %
   16123           8 :     if (compLoad.mainFanAirFlow != 0.) {
   16124           8 :         compLoad.outsideAirRatio = compLoad.outsideAirFlow / compLoad.mainFanAirFlow;
   16125             :     }
   16126             : 
   16127           8 :     if (compLoad.floorArea != 0.) {
   16128             :         // airflow per floor area
   16129           8 :         compLoad.airflowPerFlrArea = compLoad.mainFanAirFlow / compLoad.floorArea;
   16130             : 
   16131             :         // capacity per floor area
   16132           8 :         compLoad.totCapPerArea = compLoad.designPeakLoad / compLoad.floorArea;
   16133             :     }
   16134           8 :     if (compLoad.designPeakLoad != 0.) {
   16135             :         // airflow per capacity
   16136           8 :         compLoad.airflowPerTotCap = compLoad.mainFanAirFlow / compLoad.designPeakLoad;
   16137             : 
   16138             :         // floor area per capacity
   16139           8 :         compLoad.areaPerTotCap = compLoad.floorArea / compLoad.designPeakLoad;
   16140             :     }
   16141           8 : }
   16142             : 
   16143             : // gather the areas used in the load component tables
   16144          27 : void GetZoneComponentAreas(EnergyPlusData &state, Array1D<ZompComponentAreasType> &areas)
   16145             : {
   16146             :     using namespace DataSurfaces;
   16147             : 
   16148         242 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   16149         215 :         areas(iZone).floor = state.dataHeatBal->Zone(iZone).FloorArea;
   16150             :     }
   16151             : 
   16152        1913 :     for (auto const &curSurface : state.dataSurface->Surface) {
   16153        1886 :         if (!curSurface.HeatTransSurf) {
   16154         122 :             continue;
   16155             :         }
   16156        1764 :         bool isExterior = curSurface.ExtBoundCond == ExternalEnvironment || curSurface.ExtBoundCond == OtherSideCondModeledExt;
   16157        1764 :         bool isTouchingGround =
   16158        1764 :             curSurface.ExtBoundCond == Ground || curSurface.ExtBoundCond == GroundFCfactorMethod || curSurface.ExtBoundCond == KivaFoundation;
   16159        1764 :         int curZoneIndex = curSurface.Zone;
   16160             :         // ZoneData curZone = Zone(curSurface.Zone);
   16161        1764 :         if (curSurface.Class == SurfaceClass::Wall) {
   16162         894 :             if (isExterior) {
   16163         302 :                 areas(curZoneIndex).extWall += curSurface.GrossArea;
   16164         592 :             } else if (isTouchingGround) {
   16165           0 :                 areas(curZoneIndex).grndCntWall += curSurface.GrossArea;
   16166             :             } else {
   16167         592 :                 areas(curZoneIndex).intZoneWall += curSurface.GrossArea;
   16168             :             }
   16169         870 :         } else if (curSurface.Class == SurfaceClass::Roof) {
   16170         269 :             if (isExterior) {
   16171          28 :                 areas(curZoneIndex).roof += curSurface.GrossArea;
   16172             :             } else {
   16173         241 :                 areas(curZoneIndex).ceiling += curSurface.GrossArea;
   16174             :             }
   16175         601 :         } else if (curSurface.Class == SurfaceClass::Floor) {
   16176         385 :             if (isExterior) {
   16177           0 :                 areas(curZoneIndex).extFloor += curSurface.GrossArea;
   16178         385 :             } else if (isTouchingGround) {
   16179         144 :                 areas(curZoneIndex).grndCntFloor += curSurface.GrossArea;
   16180             :             } else {
   16181         241 :                 areas(curZoneIndex).intZoneFloor += curSurface.GrossArea;
   16182             :             }
   16183         216 :         } else if (curSurface.Class == SurfaceClass::Window || curSurface.Class == SurfaceClass::TDD_Dome) {
   16184         200 :             areas(curZoneIndex).fenestration += curSurface.GrossArea;
   16185          16 :         } else if (curSurface.Class == SurfaceClass::Door || curSurface.Class == SurfaceClass::GlassDoor) {
   16186           0 :             areas(curZoneIndex).door += curSurface.GrossArea;
   16187             :         }
   16188          27 :     }
   16189          27 : }
   16190             : 
   16191             : // adds the area column for the load component tables
   16192         400 : void AddAreaColumnForZone(int const zoneNum, Array1D<ZompComponentAreasType> const &compAreas, CompLoadTablesType &compLoad)
   16193             : {
   16194         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::People) = compAreas(zoneNum).floor;
   16195         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::People) = true;
   16196             : 
   16197         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Lights) = compAreas(zoneNum).floor;
   16198         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Lights) = true;
   16199             : 
   16200         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Equip) = compAreas(zoneNum).floor;
   16201         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Equip) = true;
   16202             : 
   16203         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Refrig) = compAreas(zoneNum).floor;
   16204         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Refrig) = true;
   16205             : 
   16206         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::WaterUse) = compAreas(zoneNum).floor;
   16207         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::WaterUse) = true;
   16208             : 
   16209         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Infil) = compAreas(zoneNum).extWall;
   16210         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Infil) = true;
   16211             : 
   16212         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Roof) = compAreas(zoneNum).roof;
   16213         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Roof) = true;
   16214             : 
   16215         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::IntZonCeil) = compAreas(zoneNum).ceiling;
   16216         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::IntZonCeil) = true;
   16217             : 
   16218         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OtherRoof) = compAreas(zoneNum).roof;
   16219         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OtherRoof) = true;
   16220             : 
   16221         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::ExtWall) = compAreas(zoneNum).extWall;
   16222         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::ExtWall) = true;
   16223             : 
   16224         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::IntZonWall) = compAreas(zoneNum).intZoneWall;
   16225         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::IntZonWall) = true;
   16226             : 
   16227         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::GrdWall) = compAreas(zoneNum).grndCntWall;
   16228         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::GrdWall) = true;
   16229             : 
   16230         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OtherWall) = compAreas(zoneNum).extWall;
   16231         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OtherWall) = true;
   16232             : 
   16233         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::ExtFlr) = compAreas(zoneNum).extFloor;
   16234         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::ExtFlr) = true;
   16235             : 
   16236         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::IntZonFlr) = compAreas(zoneNum).intZoneFloor;
   16237         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::IntZonFlr) = true;
   16238             : 
   16239         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::GrdFlr) = compAreas(zoneNum).grndCntFloor;
   16240         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::GrdFlr) = true;
   16241             : 
   16242         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OtherFlr) = compAreas(zoneNum).intZoneFloor;
   16243         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OtherFlr) = true;
   16244             : 
   16245         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::FeneCond) = compAreas(zoneNum).fenestration;
   16246         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::FeneCond) = true;
   16247             : 
   16248         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::FeneSolr) = compAreas(zoneNum).fenestration;
   16249         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::FeneSolr) = true;
   16250             : 
   16251         400 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OpqDoor) = compAreas(zoneNum).door;
   16252         400 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OpqDoor) = true;
   16253         400 : }
   16254             : 
   16255             : // Used for the AirLoop and Facility level load component tables to sum the results from invidual zones
   16256          40 : void CombineLoadCompResults(CompLoadTablesType &compLoadTotal, CompLoadTablesType const &compLoadPartial, Real64 const multiplier)
   16257             : {
   16258             :     // sum the main results
   16259         360 :     for (int col = 1; col <= LoadCompCol::PerArea; ++col) {
   16260        8640 :         for (int row = 1; row <= LoadCompRow::GrdTot; ++row) {
   16261        8320 :             compLoadTotal.cells(col, row) += compLoadPartial.cells(col, row) * multiplier;
   16262        8320 :             compLoadTotal.cellUsed(col, row) = compLoadTotal.cellUsed(col, row) || compLoadPartial.cellUsed(col, row);
   16263             :         }
   16264             :     }
   16265             : 
   16266             :     // take the partial value for these
   16267          40 :     compLoadTotal.desDayNum = compLoadPartial.desDayNum;
   16268          40 :     compLoadTotal.timeStepMax = compLoadPartial.timeStepMax;
   16269          40 :     compLoadTotal.peakDateHrMin = compLoadPartial.peakDateHrMin;
   16270          40 :     compLoadTotal.outsideDryBulb = compLoadPartial.outsideDryBulb;
   16271          40 :     compLoadTotal.outsideWetBulb = compLoadPartial.outsideWetBulb;
   16272          40 :     compLoadTotal.outsideHumRatio = compLoadPartial.outsideHumRatio;
   16273          40 :     compLoadTotal.zoneDryBulb = compLoadPartial.zoneDryBulb;
   16274          40 :     compLoadTotal.zoneRelHum = compLoadPartial.zoneRelHum;
   16275          40 :     compLoadTotal.zoneHumRatio = compLoadPartial.zoneHumRatio;
   16276          40 :     compLoadTotal.supAirTemp = compLoadPartial.supAirTemp;
   16277             : 
   16278             :     // sum the peak related values
   16279          40 :     compLoadTotal.designPeakLoad += compLoadPartial.designPeakLoad * multiplier;
   16280          40 :     compLoadTotal.diffDesignPeak += compLoadPartial.diffDesignPeak * multiplier;
   16281          40 :     compLoadTotal.peakDesSensLoad += compLoadPartial.peakDesSensLoad * multiplier;
   16282          40 :     compLoadTotal.estInstDelSensLoad += compLoadPartial.estInstDelSensLoad * multiplier;
   16283          40 :     compLoadTotal.diffPeakEst += compLoadPartial.diffPeakEst * multiplier;
   16284          40 :     compLoadTotal.mainFanAirFlow += compLoadPartial.mainFanAirFlow * multiplier;
   16285          40 :     compLoadTotal.outsideAirFlow += compLoadPartial.outsideAirFlow * multiplier;
   16286             : 
   16287             :     // sum the engineering checks
   16288          40 :     compLoadTotal.numPeople += compLoadPartial.numPeople * multiplier;
   16289          40 :     compLoadTotal.floorArea += compLoadPartial.floorArea * multiplier;
   16290          40 : }
   16291             : 
   16292             : // create the total row and total columns for the load summary tables
   16293         378 : void AddTotalRowsForLoadSummary(CompLoadTablesType &compLoadTotal)
   16294             : {
   16295             : 
   16296             :     // zero the grand total -total cell
   16297         378 :     compLoadTotal.cells(LoadCompCol::Total, LoadCompRow::GrdTot) = 0.;
   16298         378 :     compLoadTotal.cellUsed(LoadCompCol::Total, LoadCompRow::GrdTot) = true;
   16299             : 
   16300             :     // zero the grand total row
   16301        1890 :     for (int col = 1; col <= LoadCompCol::Latent; ++col) {
   16302        1512 :         compLoadTotal.cells(col, LoadCompRow::GrdTot) = 0.;
   16303        1512 :         compLoadTotal.cellUsed(col, LoadCompRow::GrdTot) = true;
   16304             :     }
   16305             : 
   16306        9828 :     for (int row = 1; row <= LoadCompRow::OpqDoor; ++row) {
   16307             :         // zero the total column
   16308        9450 :         compLoadTotal.cells(LoadCompCol::Total, row) = 0.;
   16309        9450 :         compLoadTotal.cellUsed(LoadCompCol::Total, row) = true;
   16310       47250 :         for (int col = 1; col <= LoadCompCol::Latent; ++col) {
   16311             :             // add the cell to the grand total row and total column
   16312       37800 :             if (compLoadTotal.cellUsed(col, row)) {
   16313       15120 :                 compLoadTotal.cells(LoadCompCol::Total, row) += compLoadTotal.cells(col, row);
   16314       15120 :                 compLoadTotal.cells(col, LoadCompRow::GrdTot) += compLoadTotal.cells(col, row);
   16315       15120 :                 compLoadTotal.cells(LoadCompCol::Total, LoadCompRow::GrdTot) += compLoadTotal.cells(col, row);
   16316             :             }
   16317             :         }
   16318             :     }
   16319             : 
   16320             :     // compute the % grand total column
   16321         378 :     Real64 grandTotalTotal = compLoadTotal.cells(LoadCompCol::Total, LoadCompRow::GrdTot);
   16322         378 :     if (grandTotalTotal != 0.0) {
   16323        9828 :         for (int row = 1; row <= LoadCompRow::OpqDoor; ++row) {
   16324        9450 :             compLoadTotal.cells(LoadCompCol::Perc, row) = 100 * compLoadTotal.cells(LoadCompCol::Total, row) / grandTotalTotal;
   16325        9450 :             compLoadTotal.cellUsed(LoadCompCol::Perc, row) = true;
   16326             :         }
   16327             :     }
   16328             :     // compute the Total per Area column
   16329        9828 :     for (int row = 1; row <= LoadCompRow::OpqDoor; ++row) {
   16330        9450 :         if (compLoadTotal.cellUsed(LoadCompCol::Total, row) && compLoadTotal.cells(LoadCompCol::Area, row) != 0.) {
   16331        9288 :             compLoadTotal.cells(LoadCompCol::PerArea, row) =
   16332        4644 :                 compLoadTotal.cells(LoadCompCol::Total, row) / compLoadTotal.cells(LoadCompCol::Area, row);
   16333        4644 :             compLoadTotal.cellUsed(LoadCompCol::PerArea, row) = true;
   16334             :         }
   16335             :     }
   16336         378 : }
   16337             : 
   16338             : // compute the peak difference between actual and estimated load in load component summary peak conditions table
   16339         378 : void ComputePeakDifference(CompLoadTablesType &compLoad)
   16340             : {
   16341             :     // Estimated Instant + Delayed Sensible Load
   16342         378 :     compLoad.estInstDelSensLoad =
   16343         378 :         compLoad.cells(LoadCompCol::SensInst, LoadCompRow::GrdTot) + compLoad.cells(LoadCompCol::SensDelay, LoadCompRow::GrdTot);
   16344             : 
   16345             :     // Difference
   16346         378 :     compLoad.diffPeakEst = compLoad.peakDesSensLoad - compLoad.estInstDelSensLoad;
   16347             : 
   16348             :     // Peak Design Diff
   16349         378 :     compLoad.diffDesignPeak = compLoad.designPeakLoad - compLoad.peakDesSensLoad;
   16350         378 : }
   16351             : 
   16352             : // apply unit conversions to the load components summary tables
   16353           0 : void LoadSummaryUnitConversion(EnergyPlusData &state, CompLoadTablesType &compLoadTotal)
   16354             : {
   16355           0 :     auto const &ort = state.dataOutRptTab;
   16356             : 
   16357           0 :     if (!ort->ip()) {
   16358           0 :         return;
   16359             :     }
   16360             : 
   16361           0 :     Real64 const powerConversion = getSpecificUnitMultiplier(state, "W", "Btu/h");
   16362           0 :     Real64 const areaConversion = getSpecificUnitMultiplier(state, "m2", "ft2");
   16363           0 :     Real64 const powerPerAreaConversion = getSpecificUnitMultiplier(state, "W/m2", "Btu/h-ft2");
   16364           0 :     Real64 const airFlowConversion = getSpecificUnitMultiplier(state, "m3/s", "ft3/min");
   16365           0 :     Real64 const airFlowPerAreaConversion = getSpecificUnitMultiplier(state, "m3/s-m2", "ft3/min-ft2");
   16366           0 :     Real64 const powerPerFlowLiquidConversion = getSpecificUnitMultiplier(state, "W-s/m3", "W-min/gal");
   16367           0 :     for (int row = 1; row <= LoadCompRow::GrdTot; ++row) {
   16368           0 :         for (int col = 1; col <= LoadCompCol::Total; ++col) {
   16369           0 :             if (compLoadTotal.cellUsed(col, row)) {
   16370           0 :                 compLoadTotal.cells(col, row) *= powerConversion;
   16371             :             }
   16372             :         }
   16373           0 :         if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16374           0 :             compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerConversion;
   16375             :         }
   16376           0 :         if (compLoadTotal.cellUsed(LoadCompCol::Area, row)) {
   16377           0 :             compLoadTotal.cells(LoadCompCol::Area, row) *= areaConversion;
   16378             :         }
   16379           0 :         if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16380           0 :             compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerPerAreaConversion;
   16381             :         }
   16382             :     }
   16383           0 :     int const tempConvIndx = getSpecificUnitIndex(state, "C", "F");
   16384           0 :     compLoadTotal.outsideDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideDryBulb);
   16385           0 :     compLoadTotal.outsideWetBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideWetBulb);
   16386           0 :     compLoadTotal.zoneDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.zoneDryBulb);
   16387           0 :     compLoadTotal.peakDesSensLoad *= powerConversion;
   16388             : 
   16389           0 :     compLoadTotal.supAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.supAirTemp);
   16390           0 :     compLoadTotal.mixAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.mixAirTemp);
   16391           0 :     compLoadTotal.mainFanAirFlow *= airFlowConversion;
   16392           0 :     compLoadTotal.outsideAirFlow *= airFlowConversion;
   16393           0 :     compLoadTotal.designPeakLoad *= powerConversion;
   16394           0 :     compLoadTotal.diffDesignPeak *= powerConversion;
   16395             : 
   16396           0 :     compLoadTotal.estInstDelSensLoad *= powerConversion;
   16397           0 :     compLoadTotal.diffPeakEst *= powerConversion;
   16398             : 
   16399           0 :     compLoadTotal.airflowPerFlrArea *= airFlowPerAreaConversion;
   16400           0 :     if (powerConversion != 0.) {
   16401           0 :         compLoadTotal.airflowPerTotCap = compLoadTotal.airflowPerTotCap * airFlowPerAreaConversion / powerConversion;
   16402           0 :         compLoadTotal.areaPerTotCap = compLoadTotal.areaPerTotCap * areaConversion / powerConversion;
   16403             :     }
   16404           0 :     if (areaConversion != 0.) {
   16405           0 :         compLoadTotal.totCapPerArea = compLoadTotal.totCapPerArea * powerConversion / areaConversion;
   16406             :     }
   16407           0 :     compLoadTotal.chlPumpPerFlow *= powerPerFlowLiquidConversion;
   16408           0 :     compLoadTotal.cndPumpPerFlow *= powerPerFlowLiquidConversion;
   16409             : }
   16410             : 
   16411             : // Jan 2021: Overloaded the function with addtional parameters for dual units;
   16412             : //           used overloading since the original function was checked in an existing test unit.
   16413             : // apply unit conversions to the load components summary tables
   16414         378 : void LoadSummaryUnitConversion(EnergyPlusData &state, CompLoadTablesType &compLoadTotal, UnitsStyle unitsStyle_para)
   16415             : {
   16416         378 :     if (unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   16417             :         unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   16418           0 :         Real64 powerConversion = getSpecificUnitMultiplier(state, "W", "Btu/h");
   16419           0 :         Real64 areaConversion = getSpecificUnitMultiplier(state, "m2", "ft2");
   16420           0 :         Real64 powerPerAreaConversion = getSpecificUnitMultiplier(state, "W/m2", "Btu/h-ft2");
   16421           0 :         Real64 airFlowConversion = getSpecificUnitMultiplier(state, "m3/s", "ft3/min");
   16422           0 :         Real64 airFlowPerAreaConversion = getSpecificUnitMultiplier(state, "m3/s-m2", "ft3/min-ft2");
   16423           0 :         Real64 powerPerFlowLiquidConversion = getSpecificUnitMultiplier(state, "W-s/m3", "W-min/gal");
   16424           0 :         for (int row = 1; row <= LoadCompRow::GrdTot; ++row) {
   16425           0 :             for (int col = 1; col <= LoadCompCol::Total; ++col) {
   16426           0 :                 if (compLoadTotal.cellUsed(col, row)) {
   16427           0 :                     compLoadTotal.cells(col, row) *= powerConversion;
   16428             :                 }
   16429             :             }
   16430           0 :             if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16431           0 :                 compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerConversion;
   16432             :             }
   16433           0 :             if (compLoadTotal.cellUsed(LoadCompCol::Area, row)) {
   16434           0 :                 compLoadTotal.cells(LoadCompCol::Area, row) *= areaConversion;
   16435             :             }
   16436           0 :             if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16437           0 :                 compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerPerAreaConversion;
   16438             :             }
   16439             :         }
   16440           0 :         int tempConvIndx = getSpecificUnitIndex(state, "C", "F");
   16441           0 :         compLoadTotal.outsideDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideDryBulb);
   16442           0 :         compLoadTotal.outsideWetBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideWetBulb);
   16443           0 :         compLoadTotal.zoneDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.zoneDryBulb);
   16444           0 :         compLoadTotal.peakDesSensLoad *= powerConversion;
   16445             : 
   16446           0 :         compLoadTotal.supAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.supAirTemp);
   16447           0 :         compLoadTotal.mixAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.mixAirTemp);
   16448           0 :         compLoadTotal.mainFanAirFlow *= airFlowConversion;
   16449           0 :         compLoadTotal.outsideAirFlow *= airFlowConversion;
   16450           0 :         compLoadTotal.designPeakLoad *= powerConversion;
   16451           0 :         compLoadTotal.diffDesignPeak *= powerConversion;
   16452             : 
   16453           0 :         compLoadTotal.estInstDelSensLoad *= powerConversion;
   16454           0 :         compLoadTotal.diffPeakEst *= powerConversion;
   16455             : 
   16456           0 :         compLoadTotal.airflowPerFlrArea *= airFlowPerAreaConversion;
   16457           0 :         if (powerConversion != 0.) {
   16458           0 :             compLoadTotal.airflowPerTotCap = compLoadTotal.airflowPerTotCap * airFlowPerAreaConversion / powerConversion;
   16459           0 :             compLoadTotal.areaPerTotCap = compLoadTotal.areaPerTotCap * areaConversion / powerConversion;
   16460             :         }
   16461           0 :         if (areaConversion != 0.) {
   16462           0 :             compLoadTotal.totCapPerArea = compLoadTotal.totCapPerArea * powerConversion / areaConversion;
   16463             :         }
   16464           0 :         compLoadTotal.chlPumpPerFlow *= powerPerFlowLiquidConversion;
   16465           0 :         compLoadTotal.cndPumpPerFlow *= powerPerFlowLiquidConversion;
   16466             :     }
   16467         378 : }
   16468             : 
   16469             : // make a list of the zones for the airloop component loads report
   16470           4 : void CreateListOfZonesForAirLoop(EnergyPlusData &state, CompLoadTablesType &compLoad, Array1D_int const &zoneToAirLoop, int const curAirLoop)
   16471             : {
   16472           4 :     int counter = 0;
   16473          28 :     for (int zi = 1; zi <= state.dataGlobal->NumOfZones; ++zi) {
   16474          24 :         if (zoneToAirLoop(zi) == curAirLoop) {
   16475          20 :             ++counter;
   16476          20 :             compLoad.zoneIndices(counter) = zi;
   16477             :         }
   16478             :     }
   16479           4 : }
   16480             : 
   16481             : // Jan 2021: Added additional parameters to accommodate dual-unit reporting
   16482             : // provide output from the load component summary tables
   16483         189 : void OutputCompLoadSummary(EnergyPlusData &state,
   16484             :                            EnergyPlus::OutputReportTabular::OutputType const kind,
   16485             :                            CompLoadTablesType const &compLoadCool,
   16486             :                            CompLoadTablesType const &compLoadHeat,
   16487             :                            int const zoneOrAirLoopIndex,
   16488             :                            UnitsStyle unitsStyle_para,
   16489             :                            bool produceTabular_para,
   16490             :                            bool produceSQLite_para)
   16491             : {
   16492             : 
   16493         189 :     auto const &ort = state.dataOutRptTab;
   16494             : 
   16495         189 :     std::string reportName;
   16496         189 :     std::string zoneAirLoopFacilityName;
   16497         189 :     bool writeOutput = false;
   16498             : 
   16499         189 :     if (kind == OutputType::Zone && ort->displayZoneComponentLoadSummary) {
   16500         185 :         reportName = "Zone Component Load Summary";
   16501         185 :         zoneAirLoopFacilityName = state.dataHeatBal->Zone(zoneOrAirLoopIndex).Name;
   16502         185 :         writeOutput = true;
   16503           4 :     } else if (kind == OutputType::AirLoop && ort->displayAirLoopComponentLoadSummary) {
   16504           2 :         reportName = "AirLoop Component Load Summary";
   16505           2 :         zoneAirLoopFacilityName = state.dataSize->FinalSysSizing(zoneOrAirLoopIndex).AirPriLoopName;
   16506           2 :         writeOutput = true;
   16507           2 :     } else if (kind == OutputType::Facility && ort->displayFacilityComponentLoadSummary) {
   16508           2 :         reportName = "Facility Component Load Summary";
   16509           2 :         zoneAirLoopFacilityName = "Facility";
   16510           2 :         writeOutput = true;
   16511             :     } else {
   16512           0 :         writeOutput = false;
   16513             :     }
   16514             : 
   16515         189 :     if (!writeOutput) {
   16516           0 :         return;
   16517             :     }
   16518             : 
   16519         189 :     CompLoadTablesType curCompLoad;
   16520         189 :     Array1D_string columnHead;
   16521         189 :     Array1D_int columnWidth;
   16522         189 :     Array1D_string rowHead;
   16523         189 :     Array2D_string tableBody; //(row, column)
   16524             : 
   16525         189 :     if (produceTabular_para) {
   16526         189 :         WriteReportHeaders(state, reportName, zoneAirLoopFacilityName, OutputProcessor::StoreType::Average);
   16527             :     }
   16528         189 :     std::string peakLoadCompName;
   16529         189 :     std::string peakCondName;
   16530         189 :     std::string zonesIncludedName;
   16531         189 :     std::string engineeringCheckName;
   16532         567 :     for (int coolHeat = 1; coolHeat <= 2; ++coolHeat) {
   16533         378 :         tableBody.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   16534         378 :         tableBody = "";
   16535         378 :         if (coolHeat == 1) {
   16536         189 :             curCompLoad = compLoadCool;
   16537         189 :             peakLoadCompName = "Estimated Cooling Peak Load Components";
   16538         189 :             peakCondName = "Cooling Peak Conditions";
   16539         189 :             zonesIncludedName = "Zones Included for Cooling";
   16540         189 :             engineeringCheckName = "Engineering Checks for Cooling";
   16541             :         } else {
   16542         189 :             curCompLoad = compLoadHeat;
   16543         189 :             peakLoadCompName = "Estimated Heating Peak Load Components";
   16544         189 :             peakCondName = "Heating Peak Conditions";
   16545         189 :             zonesIncludedName = "Zones Included for Heating";
   16546         189 :             engineeringCheckName = "Engineering Checks for Heating";
   16547             :         }
   16548             :         // move number array into string array
   16549        3402 :         for (int c = 1; c <= LoadCompCol::PerArea; ++c) {
   16550       81648 :             for (int r = 1; r <= LoadCompRow::GrdTot; ++r) { // to last row before total
   16551       78624 :                 if (curCompLoad.cellUsed(c, r)) {
   16552       48114 :                     tableBody(c, r) = RealToStr(curCompLoad.cells(c, r), 2);
   16553             :                 }
   16554             :             }
   16555             :         }
   16556         378 :         rowHead.allocate(LoadCompRow::GrdTot);
   16557             :         // internal gains
   16558         378 :         rowHead(LoadCompRow::People) = "People";
   16559         378 :         rowHead(LoadCompRow::Lights) = "Lights";
   16560         378 :         rowHead(LoadCompRow::Equip) = "Equipment";
   16561         378 :         rowHead(LoadCompRow::Refrig) = "Refrigeration Equipment";
   16562         378 :         rowHead(LoadCompRow::WaterUse) = "Water Use Equipment";
   16563         378 :         rowHead(LoadCompRow::PowerGen) = "Power Generation Equipment";
   16564         378 :         rowHead(LoadCompRow::HvacLoss) = "HVAC Equipment Losses";
   16565         378 :         rowHead(LoadCompRow::Refrig) = "Refrigeration";
   16566             :         // misc
   16567         378 :         rowHead(LoadCompRow::DOAS) = "DOAS Direct to Zone";
   16568         378 :         rowHead(LoadCompRow::Infil) = "Infiltration";
   16569         378 :         rowHead(LoadCompRow::ZoneVent) = "Zone Ventilation";
   16570         378 :         rowHead(LoadCompRow::IntZonMix) = "Interzone Mixing";
   16571             :         // opaque surfaces
   16572         378 :         rowHead(LoadCompRow::Roof) = "Roof";
   16573         378 :         rowHead(LoadCompRow::IntZonCeil) = "Interzone Ceiling";
   16574         378 :         rowHead(LoadCompRow::OtherRoof) = "Other Roof";
   16575         378 :         rowHead(LoadCompRow::ExtWall) = "Exterior Wall";
   16576         378 :         rowHead(LoadCompRow::IntZonWall) = "Interzone Wall";
   16577         378 :         rowHead(LoadCompRow::GrdWall) = "Ground Contact Wall";
   16578         378 :         rowHead(LoadCompRow::OtherWall) = "Other Wall";
   16579         378 :         rowHead(LoadCompRow::ExtFlr) = "Exterior Floor";
   16580         378 :         rowHead(LoadCompRow::IntZonFlr) = "Interzone Floor";
   16581         378 :         rowHead(LoadCompRow::GrdFlr) = "Ground Contact Floor";
   16582         378 :         rowHead(LoadCompRow::OtherFlr) = "Other Floor";
   16583             :         // subsurfaces
   16584         378 :         rowHead(LoadCompRow::FeneCond) = "Fenestration Conduction";
   16585         378 :         rowHead(LoadCompRow::FeneSolr) = "Fenestration Solar";
   16586         378 :         rowHead(LoadCompRow::OpqDoor) = "Opaque Door";
   16587         378 :         rowHead(LoadCompRow::GrdTot) = "Grand Total";
   16588             : 
   16589         378 :         columnHead.allocate(LoadCompCol::PerArea);
   16590         378 :         if (!(unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   16591             :               unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   16592         378 :             columnHead(LoadCompCol::SensInst) = "Sensible - Instant [W]";
   16593         378 :             columnHead(LoadCompCol::SensDelay) = "Sensible - Delayed [W]";
   16594         378 :             columnHead(LoadCompCol::SensRA) = "Sensible - Return Air [W]";
   16595         378 :             columnHead(LoadCompCol::Latent) = "Latent [W]";
   16596         378 :             columnHead(LoadCompCol::Total) = "Total [W]";
   16597         378 :             columnHead(LoadCompCol::Perc) = "%Grand Total";
   16598         378 :             columnHead(LoadCompCol::Area) = "Related Area [m2]";
   16599         378 :             columnHead(LoadCompCol::PerArea) = "Total per Area [W/m2]";
   16600             :         } else {
   16601           0 :             columnHead(LoadCompCol::SensInst) = "Sensible - Instant [Btu/h]";
   16602           0 :             columnHead(LoadCompCol::SensDelay) = "Sensible - Delayed [Btu/h]";
   16603           0 :             columnHead(LoadCompCol::SensRA) = "Sensible - Return Air [Btu/h]";
   16604           0 :             columnHead(LoadCompCol::Latent) = "Latent [Btu/h]";
   16605           0 :             columnHead(LoadCompCol::Total) = "Total [Btu/h]";
   16606           0 :             columnHead(LoadCompCol::Perc) = "%Grand Total";
   16607           0 :             columnHead(LoadCompCol::Area) = "Related Area [ft2]";
   16608           0 :             columnHead(LoadCompCol::PerArea) = "Total per Area [Btu/h-ft2]";
   16609             :         }
   16610         378 :         columnWidth.dimension(LoadCompCol::PerArea, 14); // array assignment - same for all columns
   16611             : 
   16612         378 :         if (produceTabular_para) {
   16613         378 :             WriteSubtitle(state, peakLoadCompName);
   16614         378 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   16615             :         }
   16616         378 :         if (produceSQLite_para) {
   16617         378 :             if (state.dataSQLiteProcedures->sqlite) {
   16618         120 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   16619             :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakLoadCompName);
   16620             :             }
   16621             :         }
   16622         378 :         if (produceTabular_para) {
   16623         378 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   16624           0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   16625             :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakLoadCompName);
   16626             :             }
   16627             :         }
   16628             : 
   16629             :         //---- Peak Conditions
   16630             : 
   16631         378 :         rowHead.allocate(16);
   16632         378 :         columnHead.allocate(1);
   16633         378 :         columnWidth.allocate(1);
   16634         378 :         columnWidth = 14; // array assignment - same for all columns
   16635             : 
   16636         378 :         tableBody.allocate(1, 16);
   16637         378 :         tableBody = "";
   16638             : 
   16639         378 :         columnHead(1) = "Value";
   16640         378 :         if (!(unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   16641             :               unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   16642         378 :             rowHead(1) = "Time of Peak Load";
   16643         378 :             rowHead(2) = "Outside Dry Bulb Temperature [C]";
   16644         378 :             rowHead(3) = "Outside Wet Bulb Temperature [C]";
   16645         378 :             rowHead(4) = "Outside Humidity Ratio at Peak [kgWater/kgDryAir]";
   16646         378 :             rowHead(5) = "Zone Dry Bulb Temperature [C]";
   16647         378 :             rowHead(6) = "Zone Relative Humidity [%]";
   16648         378 :             rowHead(7) = "Zone Humidity Ratio at Peak [kgWater/kgDryAir]";
   16649             : 
   16650         378 :             rowHead(8) = "Supply Air Temperature [C]";
   16651         378 :             rowHead(9) = "Mixed Air Temperature [C]";
   16652         378 :             rowHead(10) = "Main Fan Air Flow [m3/s]";
   16653         378 :             rowHead(11) = "Outside Air Flow [m3/s]";
   16654         378 :             rowHead(12) = "Peak Sensible Load with Sizing Factor [W]";
   16655         378 :             rowHead(13) = "Difference Due to Sizing Factor [W]";
   16656             : 
   16657         378 :             rowHead(14) = "Peak Sensible Load [W]";
   16658         378 :             rowHead(15) = "Estimated Instant + Delayed Sensible Load [W]";
   16659         378 :             rowHead(16) = "Difference Between Peak and Estimated Sensible Load [W]";
   16660             :         } else {
   16661           0 :             rowHead(1) = "Time of Peak Load";
   16662           0 :             rowHead(2) = "Outside Dry Bulb Temperature [F]";
   16663           0 :             rowHead(3) = "Outside Wet Bulb Temperature [F]";
   16664           0 :             rowHead(4) = "Outside Humidity Ratio at Peak [lbWater/lbAir]";
   16665           0 :             rowHead(5) = "Zone Dry Bulb Temperature [F]";
   16666           0 :             rowHead(6) = "Zone Relative Humidity [%]";
   16667           0 :             rowHead(7) = "Zone Humidity Ratio at Peak [lbWater/lbAir]";
   16668             : 
   16669           0 :             rowHead(8) = "Supply Air Temperature [F]";
   16670           0 :             rowHead(9) = "Mixed Air Temperature [F]";
   16671           0 :             rowHead(10) = "Main Fan Air Flow [ft3/min]";
   16672           0 :             rowHead(11) = "Outside Air Flow [ft3/min]";
   16673           0 :             rowHead(12) = "Peak Sensible Load with Sizing Factor [Btu/h]";
   16674           0 :             rowHead(13) = "Difference Due to Sizing Factor [Btu/h]";
   16675             : 
   16676           0 :             rowHead(14) = "Peak Sensible Load  [Btu/h]";
   16677           0 :             rowHead(15) = "Estimated Instant + Delayed Sensible Load [Btu/h]";
   16678           0 :             rowHead(16) = "Difference Between Peak and Estimated Sensible Load [Btu/h]";
   16679             :         }
   16680             : 
   16681         378 :         if (curCompLoad.timeStepMax != 0) {
   16682         378 :             tableBody(1, 1) = curCompLoad.peakDateHrMin;                  // Time of Peak Load
   16683         378 :             tableBody(1, 2) = RealToStr(curCompLoad.outsideDryBulb, 2);   // Outside Dry Bulb Temperature
   16684         378 :             tableBody(1, 3) = RealToStr(curCompLoad.outsideWetBulb, 2);   // Outside Wet Bulb Temperature
   16685         378 :             tableBody(1, 4) = RealToStr(curCompLoad.outsideHumRatio, 5);  // Outside Humidity Ratio at Peak
   16686         378 :             tableBody(1, 5) = RealToStr(curCompLoad.zoneDryBulb, 2);      // Zone Dry Bulb Temperature
   16687         378 :             tableBody(1, 6) = RealToStr(100 * curCompLoad.zoneRelHum, 2); // Zone Relative Humdity
   16688         378 :             tableBody(1, 7) = RealToStr(curCompLoad.zoneHumRatio, 5);     // Zone Humidity Ratio at Peak
   16689             :         }
   16690         378 :         tableBody(1, 8) = RealToStr(curCompLoad.supAirTemp, 2); // supply air temperature
   16691         378 :         if (kind == OutputType::AirLoop) {
   16692           4 :             tableBody(1, 9) = RealToStr(curCompLoad.mixAirTemp, 2); // mixed air temperature - not for zone or facility
   16693             :         }
   16694         378 :         tableBody(1, 10) = RealToStr(curCompLoad.mainFanAirFlow, 4);     // main fan air flow
   16695         378 :         tableBody(1, 11) = RealToStr(curCompLoad.outsideAirFlow, 4);     // outside air flow
   16696         378 :         tableBody(1, 12) = RealToStr(curCompLoad.designPeakLoad, 2);     // design peak load
   16697         378 :         tableBody(1, 13) = RealToStr(curCompLoad.diffDesignPeak, 2);     // difference between Design and Peak Load
   16698         378 :         tableBody(1, 14) = RealToStr(curCompLoad.peakDesSensLoad, 2);    // Peak Design Sensible Load
   16699         378 :         tableBody(1, 15) = RealToStr(curCompLoad.estInstDelSensLoad, 2); // Estimated Instant + Delayed Sensible Load
   16700         378 :         tableBody(1, 16) = RealToStr(curCompLoad.diffPeakEst, 2);        // Difference
   16701             : 
   16702         378 :         if (produceTabular_para) {
   16703         378 :             WriteSubtitle(state, peakCondName);
   16704         378 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   16705             :         }
   16706         378 :         if (produceSQLite_para) {
   16707         378 :             if (state.dataSQLiteProcedures->sqlite) {
   16708         120 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   16709             :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakCondName);
   16710             :             }
   16711             :         }
   16712         378 :         if (produceTabular_para) {
   16713         378 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   16714           0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   16715             :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakCondName);
   16716             :             }
   16717             :         }
   16718             : 
   16719             :         //---- Engineering Checks
   16720             : 
   16721         378 :         rowHead.allocate(6);
   16722         378 :         columnHead.allocate(1);
   16723         378 :         columnWidth.allocate(1);
   16724         378 :         columnWidth = 14; // array assignment - same for all columns
   16725             : 
   16726         378 :         tableBody.allocate(1, 6);
   16727         378 :         tableBody = "";
   16728             : 
   16729         378 :         columnHead(1) = "Value";
   16730         378 :         if (!(unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   16731             :               unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   16732         378 :             rowHead(1) = "Outside Air Fraction [fraction]";
   16733         378 :             rowHead(2) = "Airflow per Floor Area [m3/s-m2]";
   16734         378 :             rowHead(3) = "Airflow per Total Capacity [m3/s-W]";
   16735         378 :             rowHead(4) = "Floor Area per Total Capacity [m2/W]";
   16736         378 :             rowHead(5) = "Total Capacity per Floor Area [W/m2]";
   16737             :             // rowHead( 6 ) = "Chiller Pump Power per Flow [W-s/m3]"; // facility only
   16738             :             // rowHead( 7 ) = "Condenser Pump Power per Flor [W-s/m3]"; // facility only
   16739         378 :             rowHead(6) = "Number of People";
   16740             :         } else {
   16741           0 :             rowHead(1) = "Outside Air Fraction [fraction]";
   16742           0 :             rowHead(2) = "Airflow per Floor Area [ft3/min-ft2]";
   16743           0 :             rowHead(3) = "Airflow per Total Capacity [ft3-h/min-Btu]";
   16744           0 :             rowHead(4) = "Floor Area per Total Capacity [ft2-h/Btu]";
   16745           0 :             rowHead(5) = "Total Capacity per Floor Area [Btu/h-ft2]";
   16746             :             // rowHead( 6 ) = "Chiller Pump Power per Flow [W-min/gal]";
   16747             :             // rowHead( 7 ) = "Condenser Pump Power per Flow [W-min/gal]";
   16748           0 :             rowHead(6) = "Number of People";
   16749             :         }
   16750             : 
   16751         756 :         tableBody(1, 1) = fmt::format("{:.{}f}", curCompLoad.outsideAirRatio, 4); // outside Air
   16752         378 :         tableBody(1, 2) = fmt::format("{:0.3E}", curCompLoad.airflowPerFlrArea);  // airflow per floor area
   16753         378 :         tableBody(1, 3) = fmt::format("{:0.3E}", curCompLoad.airflowPerTotCap);   // airflow per total capacity
   16754         378 :         tableBody(1, 4) = fmt::format("{:0.3E}", curCompLoad.areaPerTotCap);      // area per total capacity
   16755         378 :         tableBody(1, 5) = fmt::format("{:0.3E}", curCompLoad.totCapPerArea);      // total capacity per area
   16756         756 :         tableBody(1, 6) = fmt::format("{:.{}f}", curCompLoad.numPeople, 1);       // number of people
   16757             : 
   16758         378 :         if (produceTabular_para) {
   16759         378 :             WriteSubtitle(state, engineeringCheckName);
   16760         378 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   16761             :         }
   16762         378 :         if (produceSQLite_para) {
   16763         378 :             if (state.dataSQLiteProcedures->sqlite) {
   16764         120 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   16765             :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, engineeringCheckName);
   16766             :             }
   16767             :         }
   16768         378 :         if (produceTabular_para) {
   16769         378 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   16770           0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   16771             :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, engineeringCheckName);
   16772             :             }
   16773             :         }
   16774             : 
   16775             :         // write the list of zone for the AirLoop level report
   16776         378 :         if (kind == OutputType::AirLoop && curCompLoad.zoneIndices.allocated()) {
   16777           4 :             int maxRow = 0;
   16778          28 :             for (size_t zi = 1; zi <= curCompLoad.zoneIndices.size(); ++zi) {
   16779          24 :                 if (curCompLoad.zoneIndices(zi) > 0) {
   16780          20 :                     maxRow = zi;
   16781             :                 }
   16782             :             }
   16783             : 
   16784           4 :             rowHead.allocate(maxRow);
   16785           4 :             columnHead.allocate(1);
   16786           4 :             columnWidth.allocate(1);
   16787           4 :             columnWidth = 14; // array assignment - same for all columns
   16788           4 :             tableBody.allocate(1, maxRow);
   16789           4 :             tableBody = "";
   16790             : 
   16791           4 :             columnHead(1) = "Zone Name";
   16792          24 :             for (int zi = 1; zi <= maxRow; ++zi) {
   16793          20 :                 rowHead(zi) = fmt::to_string(zi);
   16794          20 :                 if (curCompLoad.zoneIndices(zi) > 0) {
   16795          20 :                     tableBody(1, zi) = state.dataHeatBal->Zone(curCompLoad.zoneIndices(zi)).Name;
   16796             :                 }
   16797             :             }
   16798             : 
   16799           4 :             if (produceTabular_para) {
   16800           4 :                 WriteSubtitle(state, zonesIncludedName);
   16801           4 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   16802             :             }
   16803           4 :             if (produceSQLite_para) {
   16804           4 :                 if (state.dataSQLiteProcedures->sqlite) {
   16805           0 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   16806             :                         tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, zonesIncludedName);
   16807             :                 }
   16808             :             }
   16809           4 :             if (produceTabular_para) {
   16810           4 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   16811           0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   16812             :                         tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, zonesIncludedName);
   16813             :                 }
   16814             :             }
   16815             :         }
   16816             :     }
   16817         189 : }
   16818             : 
   16819       19276 : void WriteReportHeaders(EnergyPlusData &state,
   16820             :                         std::string const &reportName,
   16821             :                         std::string const &objectName,
   16822             :                         OutputProcessor::StoreType const averageOrSum)
   16823             : {
   16824             :     // SUBROUTINE INFORMATION:
   16825             :     //       AUTHOR         Jason Glazer
   16826             :     //       DATE WRITTEN   August 2003
   16827             :     //       MODIFIED       na
   16828             :     //       RE-ENGINEERED  na
   16829             : 
   16830             :     // PURPOSE OF THIS SUBROUTINE:
   16831             :     //   Write the first few lines of each report with headers to the output
   16832             :     //   file for tabular reports.
   16833             : 
   16834       19276 :     std::string const modifiedReportName(reportName + (averageOrSum == OutputProcessor::StoreType::Sum ? " per second" : ""));
   16835       19276 :     auto &ort = state.dataOutRptTab;
   16836             : 
   16837       41478 :     for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   16838       22202 :         std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   16839       22202 :         std::string const &curDel(ort->del(iStyle));
   16840       22202 :         TableStyle const style = ort->TableStyle(iStyle);
   16841       22202 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab)) {
   16842        2177 :             tbl_stream << "----------------------------------------------------------------------------------------------------\n";
   16843        2177 :             tbl_stream << "REPORT:" << curDel << modifiedReportName << '\n';
   16844        2177 :             tbl_stream << "FOR:" << curDel << objectName << '\n';
   16845       20025 :         } else if (style == TableStyle::Fixed) {
   16846         497 :             tbl_stream << "----------------------------------------------------------------------------------------------------\n";
   16847         497 :             tbl_stream << "REPORT:      " << curDel << modifiedReportName << '\n';
   16848         497 :             tbl_stream << "FOR:         " << curDel << objectName << '\n';
   16849       19528 :         } else if (style == TableStyle::HTML) {
   16850       19004 :             tbl_stream << "<hr>\n";
   16851       19004 :             tbl_stream << "<p><a href=\"#toc\" style=\"float: right\">Table of Contents</a></p>\n";
   16852       19004 :             tbl_stream << "<a name=" << MakeAnchorName(reportName, objectName) << "></a>\n";
   16853       19004 :             tbl_stream << "<p>Report:<b>" << curDel << modifiedReportName << "</b></p>\n";
   16854       19004 :             tbl_stream << "<p>For:<b>" << curDel << objectName << "</b></p>\n";
   16855       19004 :             tbl_stream << "<p>Timestamp: <b>" << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2) << '-'
   16856       19004 :                        << std::setw(2) << ort->td(3) << '\n';
   16857       19004 :             tbl_stream << "    " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
   16858       19004 :                        << std::setfill(' ') << "</b></p>\n";
   16859         524 :         } else if (style == TableStyle::XML) {
   16860         524 :             if (len(ort->prevReportName) != 0) {
   16861         504 :                 tbl_stream << "</" << ort->prevReportName << ">\n"; // close the last element if it was used.
   16862             :             }
   16863         524 :             tbl_stream << "<" << ConvertToElementTag(modifiedReportName) << ">\n";
   16864         524 :             tbl_stream << "  <for>" << ConvertToEscaped(objectName) << "</for>\n";
   16865         524 :             ort->prevReportName = ConvertToElementTag(modifiedReportName); // save the name for next time
   16866             :         }
   16867             :     }
   16868             :     // clear the active subtable name for the XML reporting
   16869       19276 :     ort->activeSubTableName = "";
   16870             :     // save the report name if the subtable name is not available during XML processing
   16871       19276 :     ort->activeReportName = modifiedReportName;
   16872             :     // save the "for" which is the object name in the report for HTML comment that contains the report, for, and subtable
   16873       19276 :     ort->activeForName = objectName;
   16874       19276 : }
   16875             : 
   16876      142066 : void WriteSubtitle(EnergyPlusData &state, std::string const &subtitle)
   16877             : {
   16878             :     // SUBROUTINE INFORMATION:
   16879             :     //       AUTHOR         Jason Glazer
   16880             :     //       DATE WRITTEN   November 2003
   16881             :     //       MODIFIED       na
   16882             :     //       RE-ENGINEERED  na
   16883             : 
   16884             :     // PURPOSE OF THIS SUBROUTINE:
   16885             :     //   Insert a subtitle into the current report
   16886             : 
   16887             :     // Locals
   16888             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   16889             : 
   16890             :     // SUBROUTINE PARAMETER DEFINITIONS:
   16891             : 
   16892             :     // INTERFACE BLOCK SPECIFICATIONS:
   16893             :     // na
   16894             : 
   16895             :     // DERIVED TYPE DEFINITIONS:
   16896             :     // na
   16897             : 
   16898             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   16899             :     int iStyle;
   16900      142066 :     auto &ort = state.dataOutRptTab;
   16901             : 
   16902      305498 :     for (iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   16903      163432 :         TableStyle const style = ort->TableStyle(iStyle);
   16904      163432 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab) || (style == TableStyle::Fixed)) {
   16905       19633 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   16906       19633 :             tbl_stream << subtitle << "\n\n";
   16907      163432 :         } else if (style == TableStyle::HTML) {
   16908      140121 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   16909      140121 :             tbl_stream << "<b>" << subtitle << "</b><br><br>\n";
   16910      140121 :             tbl_stream << "<!-- FullName:" << ort->activeReportName << '_' << ort->activeForName << '_' << subtitle << "-->\n";
   16911        3678 :         } else if (style == TableStyle::XML) {
   16912             :             // save the active subtable name for the XML reporting
   16913        3678 :             ort->activeSubTableName = subtitle;
   16914             :             // no other output is needed since WriteTable uses the subtable name for each record.
   16915             :         }
   16916             :     }
   16917      142066 : }
   16918             : 
   16919        8942 : void WriteTextLine(EnergyPlusData &state, std::string const &lineOfText, bool const useBold)
   16920             : {
   16921             :     // SUBROUTINE INFORMATION:
   16922             :     //       AUTHOR         Jason Glazer
   16923             :     //       DATE WRITTEN   April 2007
   16924             :     //       MODIFIED       na
   16925             :     //       RE-ENGINEERED  na
   16926             : 
   16927             :     // PURPOSE OF THIS SUBROUTINE:
   16928             :     //   Insert a subtitle into the current report
   16929             : 
   16930             :     // Locals
   16931             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   16932             : 
   16933             :     // SUBROUTINE PARAMETER DEFINITIONS:
   16934             : 
   16935             :     // INTERFACE BLOCK SPECIFICATIONS:
   16936             :     // na
   16937             : 
   16938             :     // DERIVED TYPE DEFINITIONS:
   16939             :     // na
   16940             : 
   16941             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   16942             :     int iStyle;
   16943        8942 :     auto &ort = state.dataOutRptTab;
   16944             : 
   16945       19348 :     for (iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   16946       10406 :         TableStyle const style = ort->TableStyle(iStyle);
   16947       10406 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab) || (style == TableStyle::Fixed)) {
   16948        1356 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   16949        1356 :             tbl_stream << lineOfText << '\n';
   16950       10406 :         } else if (style == TableStyle::HTML) {
   16951        8830 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   16952        8830 :             if (useBold) {
   16953        7160 :                 tbl_stream << "<b>" << lineOfText << "</b><br><br>\n";
   16954             :             } else {
   16955        1670 :                 tbl_stream << lineOfText << "<br>\n";
   16956             :             }
   16957         220 :         } else if (style == TableStyle::XML) {
   16958         220 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   16959         220 :             if (!lineOfText.empty()) {
   16960         180 :                 tbl_stream << "<note>" << lineOfText << "</note>\n";
   16961             :             }
   16962             :         }
   16963             :     }
   16964        8942 : }
   16965             : 
   16966      142058 : void WriteTable(EnergyPlusData &state,
   16967             :                 Array2S_string const body, // row,column
   16968             :                 const Array1D_string &rowLabels,
   16969             :                 const Array1D_string &columnLabels,
   16970             :                 Array1D_int &widthColumn,
   16971             :                 bool transposeXML,
   16972             :                 std::string_view const footnoteText)
   16973             : {
   16974             :     // SUBROUTINE INFORMATION:
   16975             :     //       AUTHOR         Jason Glazer
   16976             :     //       DATE WRITTEN   August 2003
   16977             :     //       MODIFIED       na
   16978             :     //       RE-ENGINEERED  na
   16979             : 
   16980             :     // PURPOSE OF THIS SUBROUTINE:
   16981             :     //   Output a table to the tabular output file in the selected
   16982             :     //   style (comma, tab, space, html, xml).
   16983             :     //   The widthColumn array is only used for fixed space formatted reports
   16984             :     //   if columnLables contain a vertical bar '|', they are broken into multiple
   16985             :     //   rows.  If they exceed the column width even after that and the format is
   16986             :     //   fixed, they are further shortened.
   16987             :     //   To include the currency symbol ($ by default but other symbols if the user
   16988             :     //   has input it with Economics:CurrencyType) use the string ~~$~~ in the row
   16989             :     //   headers, column headers, and body. For HTML files, the ASCII or UNICODE
   16990             :     //   symbol for the currency will be included. For TXT files, the ASCII symbol
   16991             :     //   will be used.
   16992             : 
   16993             :     // Argument array dimensioning
   16994             : 
   16995             :     // Locals
   16996             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   16997             : 
   16998             :     // SUBROUTINE PARAMETER DEFINITIONS:
   16999      142058 :     static std::string const blank;
   17000             : 
   17001             :     // INTERFACE BLOCK SPECIFICATIONS:
   17002             :     // na
   17003             : 
   17004             :     // DERIVED TYPE DEFINITIONS:
   17005             :     // na
   17006             : 
   17007             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17008      142058 :     Array2D_string colLabelMulti;
   17009      142058 :     std::string workColumn;
   17010      142058 :     Array1D_string rowLabelTags;
   17011      142058 :     Array1D_string columnLabelTags;
   17012      142058 :     Array1D_string rowUnitStrings;
   17013      142058 :     Array1D_string columnUnitStrings;
   17014      142058 :     Array2D_string bodyEsc;
   17015             : 
   17016      142058 :     std::string outputLine;
   17017      142058 :     std::string tagWithAttrib;
   17018             :     std::string::size_type col1start;
   17019      142058 :     auto &ort = state.dataOutRptTab;
   17020             : 
   17021             :     // create blank string
   17022             :     // get sizes of arrays
   17023      142058 :     int rowsBody = isize(body, 2);
   17024      142058 :     int colsBody = isize(body, 1);
   17025      142058 :     int rowsRowLabels = isize(rowLabels);
   17026      142058 :     int colsColumnLabels = isize(columnLabels);
   17027      142058 :     int const colsWidthColumn = isize(widthColumn);
   17028             :     // check size of arrays for consistancy and if inconsistent use smaller value
   17029             :     // and display warning
   17030      142058 :     if (rowsBody != rowsRowLabels) {
   17031           0 :         ShowWarningError(state, "REPORT:TABLE Inconsistant number of rows.");
   17032           0 :         rowsBody = min(rowsBody, rowsRowLabels);
   17033           0 :         rowsRowLabels = rowsBody;
   17034             :     }
   17035      142058 :     if ((colsBody != colsColumnLabels) || (colsBody != colsWidthColumn)) {
   17036           0 :         ShowWarningError(state, "REPORT:TABLE Inconsistent number of columns.");
   17037           0 :         colsBody = min(colsBody, min(colsColumnLabels, colsWidthColumn));
   17038           0 :         colsColumnLabels = colsBody;
   17039             :     }
   17040             :     // create arrays to hold the XML tags
   17041      142058 :     rowLabelTags.allocate(rowsBody);
   17042      142058 :     columnLabelTags.allocate(colsBody);
   17043      142058 :     rowUnitStrings.allocate(rowsBody);
   17044      142058 :     columnUnitStrings.allocate(colsBody);
   17045      142058 :     bodyEsc.allocate(colsBody, rowsBody);
   17046             :     // create new array to hold multiple line column lables
   17047      142058 :     colLabelMulti.allocate(colsColumnLabels, 50);
   17048      142058 :     colLabelMulti = blank; // set array to blank
   17049      142058 :     int maxNumColLabelRows = 0;
   17050             : 
   17051      305480 :     for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   17052      163422 :         std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17053      163422 :         std::string const &curDel = ort->del(iStyle);
   17054             :         // go through the columns and break them into multiple lines
   17055             :         // if bar '|' is found in a row then break into two lines
   17056             :         // if longer than the column width break into two lines for fixed style only
   17057     1434023 :         for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17058     1270601 :             int numColLabelRows = 0;
   17059     1270601 :             workColumn = columnLabels(iCol);
   17060     1270601 :             widthColumn(iCol) = max(widthColumn(iCol), static_cast<int>(len(columnLabels(iCol))));
   17061             :             while (true) {
   17062     1287673 :                 std::string::size_type const barLoc = index(workColumn, '|');
   17063     1287673 :                 if (barLoc != std::string::npos) {
   17064       17072 :                     ++numColLabelRows;
   17065       17072 :                     colLabelMulti(iCol, numColLabelRows) = workColumn.substr(0, barLoc);
   17066       17072 :                     workColumn.erase(0, barLoc + 1);
   17067             :                 } else {
   17068     1270601 :                     ++numColLabelRows;
   17069     1270601 :                     colLabelMulti(iCol, numColLabelRows) = workColumn;
   17070     1270601 :                     break; // inner do loop
   17071             :                 }
   17072       17072 :             }
   17073     1270601 :             if (numColLabelRows > maxNumColLabelRows) {
   17074      142728 :                 maxNumColLabelRows = numColLabelRows;
   17075             :             }
   17076             :         }
   17077             : 
   17078      163422 :         auto const &thisStyle = ort->TableStyle(iStyle);
   17079             : 
   17080             :         // output depending on style of format
   17081      163422 :         if ((thisStyle == TableStyle::Comma) || (thisStyle == TableStyle::Tab)) {
   17082             :             // column headers
   17083       33731 :             for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17084       17597 :                 outputLine = curDel; // one leading delimiters on column header lines
   17085      145133 :                 for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17086      127536 :                     outputLine += curDel + stripped(colLabelMulti(iCol, jRow));
   17087             :                 }
   17088       17597 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17089             :             }
   17090             :             // body with row headers
   17091      172177 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17092      156043 :                 outputLine = curDel + rowLabels(jRow); // one leading delimiters on table body lines
   17093     1609058 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17094     1453015 :                     outputLine += curDel + stripped(body(iCol, jRow));
   17095             :                 }
   17096      156043 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17097             :             }
   17098       16134 :             if (!footnoteText.empty()) {
   17099        1916 :                 tbl_stream << fmt::format("{}\n", footnoteText);
   17100             :             }
   17101       16134 :             tbl_stream << "\n\n";
   17102             : 
   17103      163422 :         } else if (thisStyle == TableStyle::Fixed) {
   17104             : 
   17105             :             // extra preprocessing for fixed style reports
   17106             :             // break column headings into multiple rows if long (for fixed) or contain two spaces in a row.
   17107       30546 :             for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17108       27049 :                 int const colWidthLimit = widthColumn(iCol);
   17109       54934 :                 for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17110       27885 :                     pare(colLabelMulti(iCol, jRow), colWidthLimit);
   17111             :                 }
   17112             :             }
   17113        3497 :             std::string::size_type maxWidthRowLabel = 0;
   17114       15739 :             for (int jRow = 1; jRow <= rowsRowLabels; ++jRow) {
   17115       12242 :                 std::string::size_type widthRowLabel = len(rowLabels(jRow));
   17116       12242 :                 if (widthRowLabel > maxWidthRowLabel) {
   17117        5080 :                     maxWidthRowLabel = widthRowLabel;
   17118             :                 }
   17119             :             }
   17120             : 
   17121             :             // column headers
   17122        7355 :             for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17123        3858 :                 outputLine = blank; // spaces(:maxWidthRowLabel+2)  // two extra spaces and leave blank area for row labels
   17124        3858 :                 col1start = max(maxWidthRowLabel + 2u, static_cast<std::string::size_type>(3u));
   17125       31743 :                 for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17126       27885 :                     if (iCol != 1) {
   17127       24027 :                         outputLine += "  " + rjustified(sized(colLabelMulti(iCol, jRow), widthColumn(iCol)));
   17128             :                     } else {
   17129        3858 :                         outputLine = std::string(col1start - 1, ' ') + "  " + rjustified(sized(colLabelMulti(iCol, jRow), widthColumn(iCol)));
   17130             :                     }
   17131             :                 }
   17132        3858 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17133             :             }
   17134             :             // body with row headers
   17135       15739 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17136       12242 :                 outputLine = "  " + rjustified(sized(rowLabels(jRow), maxWidthRowLabel)); // two blank spaces on table body lines
   17137             :                 // col1start = max( len( outputLine ) + 2u, maxWidthRowLabel + 2u );
   17138      106931 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17139       94689 :                     if (iCol != 1) {
   17140       82447 :                         outputLine += "  " + rjustified(sized(body(iCol, jRow), widthColumn(iCol)));
   17141             :                     } else {
   17142       12242 :                         outputLine += "   " + rjustified(sized(body(iCol, jRow), widthColumn(iCol)));
   17143             :                     }
   17144             :                 }
   17145       12242 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17146             :             }
   17147        3497 :             if (!footnoteText.empty()) {
   17148         345 :                 tbl_stream << fmt::format("{}\n", footnoteText);
   17149             :             }
   17150        3497 :             tbl_stream << "\n\n";
   17151             : 
   17152      143791 :         } else if (thisStyle == TableStyle::HTML) {
   17153             :             // set up it being a table
   17154      140113 :             tbl_stream << "<table border=\"1\" cellpadding=\"4\" cellspacing=\"0\">\n";
   17155             :             // column headers
   17156      140113 :             tbl_stream << "  <tr><td></td>\n"; // start new row and leave empty cell
   17157     1230942 :             for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17158     1090829 :                 outputLine = "    <td align=\"right\">";
   17159     2210698 :                 for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17160     1119869 :                     outputLine += ConvertToEscaped(colLabelMulti(iCol, jRow), false);
   17161     1119869 :                     if (jRow < maxNumColLabelRows) {
   17162       29040 :                         outputLine += "<br>";
   17163             :                     }
   17164             :                 }
   17165     1090829 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, true) << "</td>\n";
   17166             :             }
   17167      140113 :             tbl_stream << "  </tr>\n";
   17168             :             // body with row headers
   17169      990884 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17170      850771 :                 tbl_stream << "  <tr>\n";
   17171      850771 :                 if (rowLabels(jRow) != "") {
   17172     1688368 :                     tbl_stream << "    <td align=\"right\">" << ConvertToEscaped(InsertCurrencySymbol(state, rowLabels(jRow), true), false)
   17173     1688368 :                                << "</td>\n";
   17174             :                 } else {
   17175        6587 :                     tbl_stream << "    <td align=\"right\">&nbsp;</td>\n";
   17176             :                 }
   17177     8301218 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17178     7450447 :                     if (body(iCol, jRow) != "") {
   17179    13382614 :                         tbl_stream << "    <td align=\"right\">" << ConvertToEscaped(InsertCurrencySymbol(state, body(iCol, jRow), true), false)
   17180    13382614 :                                    << "</td>\n";
   17181             :                     } else {
   17182      759140 :                         tbl_stream << "    <td align=\"right\">&nbsp;</td>\n";
   17183             :                     }
   17184             :                 }
   17185      850771 :                 tbl_stream << "  </tr>\n";
   17186             :             }
   17187             :             // end the table
   17188      140113 :             tbl_stream << "</table>\n";
   17189      140113 :             if (!footnoteText.empty()) {
   17190       18874 :                 tbl_stream << fmt::format("<i>{}</i>\n", footnoteText);
   17191             :             }
   17192      140113 :             tbl_stream << "<br><br>\n";
   17193        3678 :         } else if (thisStyle == TableStyle::XML) {
   17194             :             // check if entire table is blank and it if is skip generating anything
   17195        3678 :             bool isTableBlank = true;
   17196        5146 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17197       19461 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17198       17993 :                     if (len(body(iCol, jRow)) > 0) {
   17199        2462 :                         isTableBlank = false;
   17200        2462 :                         break;
   17201             :                     }
   17202             :                 }
   17203        3930 :                 if (!isTableBlank) break;
   17204             :             }
   17205             :             // if non-blank cells in the table body were found create the table.
   17206        3678 :             if (!isTableBlank) {
   17207             :                 // if report name and subtable name the same add "record" to the end
   17208        2462 :                 ort->activeSubTableName = ConvertToElementTag(ort->activeSubTableName);
   17209        2462 :                 ort->activeReportNameNoSpace = ConvertToElementTag(ort->activeReportName);
   17210        2462 :                 if (Util::SameString(ort->activeSubTableName, ort->activeReportNameNoSpace)) {
   17211          20 :                     ort->activeSubTableName += "Record";
   17212             :                 }
   17213             :                 // if no subtable name use the report name and add "record" to the end
   17214        2462 :                 if (len(ort->activeSubTableName) == 0) {
   17215           0 :                     ort->activeSubTableName = ort->activeReportNameNoSpace + "Record";
   17216             :                 }
   17217             :                 // if a single column table, transpose it automatically
   17218        2462 :                 if ((colsBody == 1) && (rowsBody > 1)) {
   17219         302 :                     transposeXML = true;
   17220             :                 }
   17221             :                 // first convert all row and column headers into tags compatible with XML strings
   17222       14015 :                 for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17223       11553 :                     rowLabelTags(jRow) = ConvertToElementTag(rowLabels(jRow));
   17224       11553 :                     if (len(rowLabelTags(jRow)) == 0) {
   17225         207 :                         rowLabelTags(jRow) = "none";
   17226             :                     }
   17227       11553 :                     rowUnitStrings(jRow) = GetUnitSubString(rowLabels(jRow));
   17228       11553 :                     if (Util::SameString(rowUnitStrings(jRow), "Invalid/Undefined")) {
   17229           0 :                         rowUnitStrings(jRow) = "";
   17230             :                     }
   17231             :                 }
   17232       19465 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17233       17003 :                     columnLabelTags(iCol) = ConvertToElementTag(columnLabels(iCol));
   17234       17003 :                     if (len(columnLabelTags(iCol)) == 0) {
   17235           0 :                         columnLabelTags(iCol) = "none";
   17236             :                     }
   17237       17003 :                     columnUnitStrings(iCol) = GetUnitSubString(columnLabels(iCol));
   17238       17003 :                     if (Util::SameString(columnUnitStrings(iCol), "Invalid/Undefined")) {
   17239           0 :                         columnUnitStrings(iCol) = "";
   17240             :                     }
   17241             :                 }
   17242             :                 // convert entire table body to one with escape characters (no " ' < > &)
   17243       14015 :                 for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17244       96262 :                     for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17245       84709 :                         bodyEsc(iCol, jRow) = ConvertToEscaped(body(iCol, jRow));
   17246             :                     }
   17247             :                 }
   17248        2462 :                 if (!transposeXML) {
   17249             :                     // body with row headers
   17250       11703 :                     for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17251             :                         // check if record is blank and it if is skip generating anything
   17252        9543 :                         bool isRecordBlank = true;
   17253       11255 :                         for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17254       11131 :                             if (len(bodyEsc(iCol, jRow)) > 0) {
   17255        9419 :                                 isRecordBlank = false;
   17256        9419 :                                 break;
   17257             :                             }
   17258             :                         }
   17259        9543 :                         if (!isRecordBlank) {
   17260        9419 :                             tbl_stream << "  <" << ort->activeSubTableName << ">\n";
   17261        9419 :                             if (len(rowLabelTags(jRow)) > 0) {
   17262        9419 :                                 tbl_stream << "    <name>" << rowLabelTags(jRow) << "</name>\n";
   17263             :                             }
   17264       90906 :                             for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17265       81487 :                                 if (len(stripped(bodyEsc(iCol, jRow))) > 0) { // skip blank cells
   17266       76431 :                                     tagWithAttrib = "<" + columnLabelTags(iCol);
   17267       76431 :                                     if (len(columnUnitStrings(iCol)) > 0) {
   17268      112042 :                                         tagWithAttrib += std::string(" units=") + char(34) + columnUnitStrings(iCol) + char(34) +
   17269       56021 :                                                          '>'; // if units are present add them as an attribute
   17270             :                                     } else {
   17271       20410 :                                         tagWithAttrib += ">";
   17272             :                                     }
   17273       76431 :                                     tbl_stream << "    " << tagWithAttrib << stripped(bodyEsc(iCol, jRow)) << "</" << columnLabelTags(iCol) << ">\n";
   17274             :                                 }
   17275             :                             }
   17276        9419 :                             tbl_stream << "  </" << ort->activeSubTableName << ">\n";
   17277             :                         }
   17278             :                     }
   17279             :                 } else { // transpose XML table
   17280             :                     // body with row headers
   17281         604 :                     for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17282             :                         // check if record is blank and it if is skip generating anything
   17283         302 :                         bool isRecordBlank = true;
   17284         302 :                         for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17285         302 :                             if (len(bodyEsc(iCol, jRow)) > 0) {
   17286         302 :                                 isRecordBlank = false;
   17287         302 :                                 break;
   17288             :                             }
   17289             :                         }
   17290         302 :                         if (!isRecordBlank) {
   17291         302 :                             tbl_stream << "  <" << ort->activeSubTableName << ">\n";
   17292             :                             // if the column has units put them into the name tag
   17293         302 :                             if (len(columnLabelTags(iCol)) > 0) {
   17294         302 :                                 if (len(columnUnitStrings(iCol)) > 0) {
   17295         242 :                                     tbl_stream << "    <name units=" << char(34) << columnUnitStrings(iCol) << char(34) << '>'
   17296         121 :                                                << columnLabelTags(iCol) << "</name>\n";
   17297             :                                 } else {
   17298         181 :                                     tbl_stream << "    <name>" << columnLabelTags(iCol) << "</name>\n";
   17299             :                                 }
   17300             :                             }
   17301        2312 :                             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17302        2010 :                                 if (len(bodyEsc(iCol, jRow)) > 0) { // skip blank cells
   17303        1992 :                                     tagWithAttrib = "<" + rowLabelTags(jRow);
   17304        1992 :                                     if (len(rowUnitStrings(jRow)) > 0) {
   17305         456 :                                         tagWithAttrib += std::string(" units=") + char(34) + rowUnitStrings(jRow) + char(34) +
   17306         228 :                                                          ">\n"; // if units are present add them as an attribute
   17307             :                                     } else {
   17308        1764 :                                         tagWithAttrib += ">";
   17309             :                                     }
   17310        1992 :                                     tbl_stream << "    " << tagWithAttrib << stripped(bodyEsc(iCol, jRow)) << "</" << rowLabelTags(jRow) << ">\n";
   17311             :                                 }
   17312             :                             }
   17313         302 :                             tbl_stream << "  </" << ort->activeSubTableName << ">\n";
   17314             :                         }
   17315             :                     }
   17316             :                 }
   17317        2462 :                 if (!footnoteText.empty()) {
   17318         155 :                     tbl_stream << fmt::format("  <footnote>{}</footnote>\n", footnoteText);
   17319             :                 }
   17320             :             }
   17321             :         } else {
   17322             :         }
   17323             :     }
   17324      142058 : }
   17325             : 
   17326       38140 : std::string MakeAnchorName(std::string const &reportString, std::string const &objectString)
   17327             : {
   17328             :     // SUBROUTINE INFORMATION:
   17329             :     //       AUTHOR         Jason Glazer
   17330             :     //       DATE WRITTEN   June 2005
   17331             :     //       MODIFIED
   17332             :     //       RE-ENGINEERED  na
   17333             : 
   17334             :     // PURPOSE OF THIS SUBROUTINE:
   17335             :     //   Use the name of the report and object be used to create and HTML anchor
   17336             : 
   17337             :     // METHODOLOGY EMPLOYED:
   17338             :     //   Remove spaces and put double colon between names
   17339             : 
   17340             :     // REFERENCES:
   17341             :     // na
   17342             : 
   17343             :     // USE STATEMENTS:
   17344             : 
   17345             :     // Return value
   17346       38140 :     std::string StringOut;
   17347       38140 :     StringOut.reserve(reportString.size() + objectString.size() + 2);
   17348             : 
   17349             :     // Locals
   17350             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17351             :     // na
   17352             : 
   17353             :     // SUBROUTINE PARAMETER DEFINITIONS:
   17354             : 
   17355             :     // INTERFACE BLOCK SPECIFICATIONS:
   17356             :     // na
   17357             : 
   17358             :     // DERIVED TYPE DEFINITIONS:
   17359             :     // na
   17360             : 
   17361             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17362             : 
   17363      930260 :     for (char const i : reportString) {
   17364      892120 :         if (has(validChars, i)) {
   17365      808588 :             StringOut += i;
   17366             :         }
   17367             :     }
   17368       38140 :     StringOut += "::";
   17369      611932 :     for (char const i : objectString) {
   17370      573792 :         if (has(validChars, i)) {
   17371      536078 :             StringOut += i;
   17372             :         }
   17373             :     }
   17374       38140 :     return StringOut;
   17375           0 : }
   17376             : 
   17377     8816060 : std::string InsertCurrencySymbol(EnergyPlusData &state,
   17378             :                                  std::string const &inString, // Input String
   17379             :                                  bool const isHTML            // True if an HTML string
   17380             : )
   17381             : {
   17382             :     // SUBROUTINE INFORMATION:
   17383             :     //       AUTHOR         Jason Glazer
   17384             :     //       DATE WRITTEN   August 2008
   17385             :     //       MODIFIED       na
   17386             :     //       RE-ENGINEERED  na
   17387             : 
   17388             :     // PURPOSE OF THIS SUBROUTINE:
   17389             :     //   Looks for the ~~$~~
   17390             : 
   17391             :     // METHODOLOGY EMPLOYED:
   17392             :     //   na
   17393             :     // Using/Aliasing
   17394             : 
   17395             :     // Return value
   17396             : 
   17397             :     // Locals
   17398             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17399             : 
   17400             :     // SUBROUTINE PARAMETER DEFINITIONS:
   17401             :     // na
   17402             : 
   17403             :     // INTERFACE BLOCK SPECIFICATIONS:
   17404             :     // na
   17405             : 
   17406             :     // DERIVED TYPE DEFINITIONS:
   17407             :     // na
   17408             : 
   17409             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17410             : 
   17411     8816060 :     std::string outSt(trimmed(inString)); // Result String
   17412     8816060 :     std::string::size_type loc = index(outSt, "~~$~~");
   17413     8818216 :     while (loc != std::string::npos) {
   17414        2156 :         if (isHTML) {
   17415        3536 :             outSt = inString.substr(0, loc) + state.dataCostEstimateManager->monetaryUnit(state.dataCostEstimateManager->selectedMonetaryUnit).html +
   17416        5304 :                     outSt.substr(loc + 5);
   17417             :         } else {
   17418         776 :             outSt = inString.substr(0, loc) + state.dataCostEstimateManager->monetaryUnit(state.dataCostEstimateManager->selectedMonetaryUnit).txt +
   17419        1164 :                     outSt.substr(loc + 5);
   17420             :         }
   17421        2156 :         loc = index(outSt, "~~$~~");
   17422             :     }
   17423     8816060 :     return outSt;
   17424           0 : }
   17425             : 
   17426       34528 : std::string ConvertToElementTag(std::string const &inString) // Input String
   17427             : {
   17428             :     // SUBROUTINE INFORMATION:
   17429             :     //       AUTHOR         Jason Glazer
   17430             :     //       DATE WRITTEN   February 2013
   17431             :     //       MODIFIED       na
   17432             :     //       RE-ENGINEERED  na
   17433             : 
   17434             :     // PURPOSE OF THIS SUBROUTINE:
   17435             :     //   Convert report column or row header into a tag string
   17436             :     //   that just has A-Z, a-z, or 0-1 characters and is
   17437             :     //   shown in camelCase.
   17438             : 
   17439             :     // METHODOLOGY EMPLOYED:
   17440             :     //   na
   17441             : 
   17442             :     // Return value
   17443       34528 :     std::string outString; // Result String
   17444             : 
   17445             :     // Locals
   17446             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17447             : 
   17448             :     // SUBROUTINE PARAMETER DEFINITIONS:
   17449             :     // na
   17450             : 
   17451             :     // INTERFACE BLOCK SPECIFICATIONS:
   17452             :     // na
   17453             : 
   17454             :     // DERIVED TYPE DEFINITIONS:
   17455             :     // na
   17456             : 
   17457             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17458             : 
   17459       34528 :     bool foundOther = true; // flag if character found besides A-Z, a-z, 0-9
   17460      718070 :     for (std::string::size_type iIn = 0, e = inString.length(); iIn < e; ++iIn) {
   17461      691896 :         char const c(inString[iIn]);
   17462      691896 :         int const curCharVal = int(c);
   17463      691896 :         if ((curCharVal >= 65) && (curCharVal <= 90)) { // A-Z upper case
   17464      106171 :             if (foundOther) {
   17465       87431 :                 outString += c; // keep as upper case after finding a space or another character
   17466             :             } else {
   17467       18740 :                 outString += char(curCharVal + 32); // convert to lower case
   17468             :             }
   17469      106171 :             foundOther = false;
   17470      585725 :         } else if ((curCharVal >= 97) && (curCharVal <= 122)) { // A-Z lower case
   17471      475917 :             if (foundOther) {
   17472        7130 :                 outString += char(curCharVal - 32); // convert to upper case
   17473             :             } else {
   17474      468787 :                 outString += c; // leave as lower case
   17475             :             }
   17476      475917 :             foundOther = false;
   17477      109808 :         } else if ((curCharVal >= 48) && (curCharVal <= 57)) { // 0-9 numbers
   17478             :             // if first character is a number then prepend with the letter "t"
   17479       10305 :             if (outString.length() == 0) outString += 't';
   17480       10305 :             outString += c;
   17481       10305 :             foundOther = false;
   17482       99503 :         } else if (curCharVal == 91) { // [ bracket
   17483        8354 :             break;                     // stop parsing because unit string was found
   17484             :         } else {
   17485       91149 :             foundOther = true;
   17486             :         }
   17487             :     }
   17488       34528 :     return outString;
   17489           0 : }
   17490             : 
   17491           0 : std::string ConvertUnicodeToUTF8(unsigned long const codepoint)
   17492             : {
   17493             :     // Taken from http://stackoverflow.com/a/19968992/2358662 and http://stackoverflow.com/a/148766/2358662
   17494           0 :     std::string s;
   17495           0 :     if (codepoint <= 0x7f) {
   17496           0 :         s.push_back(static_cast<char>(codepoint));
   17497           0 :     } else if (codepoint <= 0x7ff) {
   17498           0 :         s.push_back(static_cast<char>(0xc0 | ((codepoint >> 6) & 0x1f)));
   17499           0 :         s.push_back(static_cast<char>(0x80 | (codepoint & 0x3f)));
   17500           0 :     } else if (codepoint <= 0xffff) {
   17501           0 :         s.push_back(static_cast<char>(0xe0 | ((codepoint >> 12) & 0x0f)));
   17502           0 :         s.push_back(static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
   17503           0 :         s.push_back(static_cast<char>(0x80 | (codepoint & 0x3f)));
   17504           0 :     } else if (codepoint <= 0x10ffff) {
   17505           0 :         s.push_back(static_cast<char>(0xf0 | ((codepoint >> 18) & 0x07)));
   17506           0 :         s.push_back(static_cast<char>(0x80 | ((codepoint >> 12) & 0x3f)));
   17507           0 :         s.push_back(static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
   17508           0 :         s.push_back(static_cast<char>(0x80 | (codepoint & 0x3f)));
   17509             :     }
   17510           0 :     return s;
   17511           0 : }
   17512             : 
   17513     8742099 : std::string ConvertToEscaped(std::string const &inString, bool isXML) // Input String
   17514             : {
   17515             :     // SUBROUTINE INFORMATION:
   17516             :     //       AUTHOR         Jason Glazer
   17517             :     //       DATE WRITTEN   February 2013
   17518             :     //       MODIFIED       na
   17519             :     //       RE-ENGINEERED  na
   17520             : 
   17521             :     // PURPOSE OF THIS SUBROUTINE:
   17522             :     //   Convert to XML safe escaped character string
   17523             :     //   so it excludes:
   17524             :     //               " ' < > & degree-sign
   17525             :     //   If isXML=false, it does an HTML conversion, so only ` < > & ` and degree sign
   17526             :     //   Technically HTML4 doesn't support &quot, though most browsers would anyways.
   17527             :     //   Also, escaping single and double quotes is only needed inside attributes
   17528             : 
   17529     8742099 :     if (inString.empty()) {
   17530       20816 :         return "";
   17531             :     };
   17532             : 
   17533     8721283 :     std::string s;
   17534     8721283 :     size_t const inputSize = inString.size();
   17535     8721283 :     s.reserve(inputSize);
   17536     8721283 :     size_t index = 0;
   17537             : 
   17538             :     while (true) {
   17539   125850796 :         if (index == inputSize) {
   17540     8721283 :             break;
   17541             :         }
   17542   117129513 :         char c = inString[index++];
   17543   117129513 :         if ((c == '\"') && isXML) {
   17544           0 :             s += "&quot;";
   17545   117129513 :         } else if (c == '&') {
   17546        4106 :             s += "&amp;";
   17547   117125407 :         } else if ((c == '\'') && isXML) {
   17548          34 :             s += "&apos;";
   17549   117125373 :         } else if (c == '<') {
   17550       10007 :             s += "&lt;";
   17551   117115366 :         } else if (c == '>') {
   17552       38994 :             s += "&gt;";
   17553   117076372 :         } else if (c == char(176) && !isXML) {
   17554        2169 :             s += "&deg;";
   17555   117074203 :         } else if (c == char(226) && char(inString[index]) == char(137) && char(inString[index + 1]) == char(164) && !isXML) { // ≤
   17556       15457 :             s += "&le;";
   17557       15457 :             index += 2;
   17558   117058746 :         } else if (c == char(226) && char(inString[index]) == char(137) && char(inString[index + 1]) == char(165) && !isXML) { // ≥
   17559           0 :             s += "&ge;";
   17560           0 :             index += 2;
   17561   117058746 :         } else if (c == '\xC2') {
   17562       32889 :             if (index == inputSize) {
   17563           0 :                 s += '\xC2';
   17564             :             } else {
   17565       32889 :                 c = inString[index++];
   17566       32889 :                 if (c == '\xB0' && !isXML) {
   17567       28812 :                     s += "&deg;";
   17568             :                 } else {
   17569        4077 :                     s += '\xC2';
   17570        4077 :                     s += c;
   17571             :                 }
   17572             :             }
   17573   117025857 :         } else if (c == '\xB0' && !isXML) {
   17574           0 :             s += "&deg;";
   17575   117025857 :         } else if (c == '\\') {
   17576           0 :             if (index == inputSize) {
   17577           0 :                 break;
   17578             :             };
   17579           0 :             c = inString[index++];
   17580           0 :             if ((c == '"') && isXML) {
   17581           0 :                 s += "&quot;";
   17582           0 :             } else if ((c == '\'') && isXML) {
   17583           0 :                 s += "&apos;";
   17584           0 :             } else if (c == 'u' || c == 'x') {
   17585           0 :                 int remainingLen = inputSize - index;
   17586           0 :                 unsigned long codePoint(0);
   17587           0 :                 if (c == 'u' && remainingLen > 3) {
   17588           0 :                     codePoint = std::stoul(inString.substr(index, 4), nullptr, 16);
   17589           0 :                     index += 4;
   17590           0 :                 } else if (c == 'x' && remainingLen > 1) {
   17591           0 :                     codePoint = std::stoul(inString.substr(index, 2), nullptr, 16);
   17592           0 :                     index += 2;
   17593             :                 }
   17594           0 :                 std::string const unicodeString = ConvertUnicodeToUTF8(codePoint);
   17595           0 :                 if (unicodeString == "\xC2\xB0" && !isXML) { // only check for degree at this point
   17596           0 :                     s += "&deg;";
   17597             :                 } else {
   17598           0 :                     s += unicodeString;
   17599             :                 }
   17600           0 :             } else {
   17601           0 :                 s += c;
   17602             :             }
   17603             :         } else {
   17604   117025857 :             s += c;
   17605             :         }
   17606   117129513 :     }
   17607     8721283 :     return s;
   17608     8721283 : }
   17609             : 
   17610        1548 : void DetermineBuildingFloorArea(EnergyPlusData &state)
   17611             : {
   17612             : 
   17613             :     // SUBROUTINE INFORMATION:
   17614             :     //       AUTHOR         Jason Glazer
   17615             :     //       DATE WRITTEN   November 2003
   17616             :     //       MODIFIED       BTG added checks for plenums. Feb2004
   17617             :     //       RE-ENGINEERED  na
   17618             : 
   17619             :     // PURPOSE OF THIS SUBROUTINE:
   17620             :     //   To determine the total floor area of the building and the
   17621             :     //   conditioned floor area of the building
   17622             : 
   17623             :     // METHODOLOGY EMPLOYED:
   17624             :     //   Use the Zone array and sum the areas for all zones
   17625             : 
   17626             :     // REFERENCES:
   17627             :     // na
   17628             : 
   17629             :     // Using/Aliasing
   17630             : 
   17631             :     // Locals
   17632             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17633             :     // na
   17634             : 
   17635             :     // SUBROUTINE PARAMETER DEFINITIONS:
   17636             : 
   17637             :     // INTERFACE BLOCK SPECIFICATIONS:
   17638             :     // na
   17639             : 
   17640             :     // DERIVED TYPE DEFINITIONS:
   17641             :     // na
   17642             : 
   17643             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17644        1548 :     auto const &ort = state.dataOutRptTab;
   17645             : 
   17646        1548 :     ort->buildingGrossFloorArea = 0.0;
   17647        1548 :     ort->buildingConditionedFloorArea = 0.0;
   17648       10284 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   17649        8736 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
   17650        8736 :         Real64 const curZoneArea = thisZone.FloorArea * thisZone.Multiplier * thisZone.ListMultiplier;
   17651             : 
   17652             :         // OLD CHECK IF PLENUM SHOULD BE EXCLUDED AUTOMATICALLY
   17653             :         // check if this zone is also a return plenum or a supply plenum
   17654             :         // found = 0
   17655             :         // if (NumZoneReturnPlenums > 0) THEN
   17656             :         //  found = Util::FindItemInList(thisZone%Name, ZoneRetPlenCond%ZoneName, NumZoneReturnPlenums)
   17657             :         // endif
   17658             :         // IF (found /= 0)  curZoneArea = 0.0d0
   17659             :         // found = 0
   17660             :         // if (NumZoneSupplyPlenums > 0) THEN
   17661             :         //  found = Util::FindItemInList(thisZone%Name, ZoneSupPlenCond%ZoneName, NumZoneSupplyPlenums)
   17662             :         // endif
   17663             :         // IF (found /= 0)  curZoneArea = 0.0d0
   17664             : 
   17665        8736 :         if (thisZone.isPartOfTotalArea) {
   17666        8566 :             ort->buildingGrossFloorArea += curZoneArea;
   17667             :             // If a ZoneHVAC:EquipmentConnections is used for a zone then
   17668             :             // it is considered conditioned. Also ZONE SUPPLY PLENUM and ZONE RETURN PLENUM are
   17669             :             // also is considered conditioned.
   17670        8566 :             if (thisZone.SystemZoneNodeNumber > 0) {
   17671        7667 :                 ort->buildingConditionedFloorArea += curZoneArea;
   17672             :             }
   17673             :         }
   17674             :     }
   17675        1548 : }
   17676             : 
   17677        2179 : void FillRowHead(Array1D_string &rowHead)
   17678             : {
   17679             :     // Forward fill the blanks in rowHead (eg End use column)
   17680        2179 :     std::string currentEndUseName;
   17681       34393 :     for (size_t i = 1; i <= rowHead.size(); ++i) {
   17682       32214 :         std::string &thisEndUseName = rowHead(i);
   17683       32214 :         if (thisEndUseName.empty()) {
   17684        1708 :             thisEndUseName = currentEndUseName;
   17685             :         } else {
   17686       30506 :             currentEndUseName = thisEndUseName;
   17687             :         }
   17688             :     }
   17689        2179 : }
   17690             : 
   17691             : //======================================================================================================================
   17692             : //======================================================================================================================
   17693             : 
   17694             : //    ROUTINES TO RESET GATHERED VALUES TO ZERO
   17695             : 
   17696             : //======================================================================================================================
   17697             : //======================================================================================================================
   17698             : 
   17699           0 : void ResetTabularReports(EnergyPlusData &state)
   17700             : {
   17701             :     // Jason Glazer - October 2015
   17702             :     // Reset all gathering arrays to zero for multi-year simulations
   17703             :     // so that only last year is reported in tabular reports
   17704           0 :     state.dataOutRptTab->gatherElapsedTimeBEPS = 0.0;
   17705           0 :     ResetMonthlyGathering(state);
   17706           0 :     OutputReportTabularAnnual::ResetAnnualGathering(state);
   17707           0 :     ResetBinGathering(state);
   17708           0 :     ResetBEPSGathering(state);
   17709           0 :     ResetSourceEnergyEndUseGathering(state);
   17710           0 :     ResetPeakDemandGathering(state);
   17711           0 :     ResetHeatGainGathering(state);
   17712           0 :     ResetRemainingPredefinedEntries(state);
   17713           0 :     ThermalComfort::ResetThermalComfortSimpleASH55(state);
   17714           0 :     ThermalComfort::ResetSetPointMet(state);
   17715           0 :     ResetAdaptiveComfort(state);
   17716           0 :     state.dataOutputProcessor->isFinalYear = true;
   17717           0 : }
   17718             : 
   17719           0 : void ResetMonthlyGathering(EnergyPlusData &state)
   17720             : {
   17721             :     // Jason Glazer - October 2015
   17722             :     // Reset all monthly gathering arrays to zero for multi-year simulations
   17723             :     // so that only last year is reported in tabular reports
   17724           0 :     auto &ort = state.dataOutRptTab;
   17725             : 
   17726           0 :     for (int iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
   17727           0 :         for (int jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
   17728           0 :             int const curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
   17729           0 :             for (int kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
   17730           0 :                 int const curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
   17731           0 :                 ort->MonthlyColumns(curCol).timeStamp = 0;
   17732           0 :                 ort->MonthlyColumns(curCol).duration = 0.0;
   17733           0 :                 if (ort->MonthlyColumns(curCol).aggType == AggType::Maximum ||
   17734           0 :                     ort->MonthlyColumns(curCol).aggType == AggType::MaximumDuringHoursShown) {
   17735           0 :                     ort->MonthlyColumns(curCol).reslt = -HUGE_(state.dataOutRptTab->BigNumRMG);
   17736           0 :                 } else if (ort->MonthlyColumns(curCol).aggType == AggType::Minimum ||
   17737           0 :                            ort->MonthlyColumns(curCol).aggType == AggType::MinimumDuringHoursShown) {
   17738           0 :                     ort->MonthlyColumns(curCol).reslt = HUGE_(state.dataOutRptTab->BigNumRMG);
   17739             :                 } else {
   17740           0 :                     ort->MonthlyColumns(curCol).reslt = 0.0;
   17741             :                 }
   17742             :             }
   17743             :         }
   17744             :     }
   17745           0 : }
   17746             : 
   17747           0 : void ResetBinGathering(EnergyPlusData &state)
   17748             : {
   17749             :     // Jason Glazer - October 2015
   17750             :     // Reset all timebins gathering arrays to zero for multi-year simulations
   17751             :     // so that only last year is reported in tabular reports
   17752           0 :     Real64 constexpr bigVal(0.0); // used with HUGE: Value doesn't matter, only type: Initialize so compiler doesn't warn about use uninitialized
   17753           0 :     auto &ort = state.dataOutRptTab;
   17754             : 
   17755             :     // clear the binning arrays to zeros
   17756           0 :     for (auto &e : ort->BinResults) {
   17757           0 :         e.mnth = 0.0;
   17758           0 :         e.hrly = 0.0;
   17759             :     }
   17760           0 :     for (auto &e : ort->BinResultsBelow) {
   17761           0 :         e.mnth = 0.0;
   17762           0 :         e.hrly = 0.0;
   17763             :     }
   17764           0 :     for (auto &e : ort->BinResultsAbove) {
   17765           0 :         e.mnth = 0.0;
   17766           0 :         e.hrly = 0.0;
   17767             :     }
   17768             : 
   17769             :     // re-initialize statistics counters
   17770           0 :     for (auto &e : ort->BinStatistics) {
   17771           0 :         e.minimum = HUGE_(bigVal);
   17772           0 :         e.maximum = -HUGE_(bigVal);
   17773           0 :         e.n = 0;
   17774           0 :         e.sum = 0.0;
   17775           0 :         e.sum2 = 0.0;
   17776             :     }
   17777           0 : }
   17778             : 
   17779           0 : void ResetBEPSGathering(EnergyPlusData &state)
   17780             : {
   17781             :     // Jason Glazer - October 2015
   17782             :     // Reset all ABUPS gathering arrays to zero for multi-year simulations
   17783             :     // so that only last year is reported in tabular reports
   17784           0 :     auto &ort = state.dataOutRptTab;
   17785           0 :     ort->gatherTotalsBEPS = 0.0;
   17786           0 :     ort->gatherEndUseBEPS = 0.0;
   17787           0 :     ort->gatherEndUseSubBEPS = 0.0;
   17788           0 :     ort->gatherTotalsSource = 0.0;
   17789             :     // reset the specific components being gathered
   17790           0 :     ort->gatherPowerFuelFireGen = 0.0;
   17791           0 :     ort->gatherPowerPV = 0.0;
   17792           0 :     ort->gatherPowerWind = 0.0;
   17793           0 :     ort->gatherPowerHTGeothermal = 0.0;
   17794           0 :     ort->gatherElecProduced = 0.0;
   17795           0 :     ort->gatherElecPurchased = 0.0;
   17796           0 :     ort->gatherElecSurplusSold = 0.0;
   17797           0 :     ort->gatherElecStorage = 0.0;
   17798           0 :     ort->gatherPowerConversion = 0.0;
   17799           0 :     ort->gatherWaterHeatRecovery = 0.0;
   17800           0 :     ort->gatherAirHeatRecoveryCool = 0.0;
   17801           0 :     ort->gatherAirHeatRecoveryHeat = 0.0;
   17802           0 :     ort->gatherHeatHTGeothermal = 0.0;
   17803           0 :     ort->gatherHeatSolarWater = 0.0;
   17804           0 :     ort->gatherHeatSolarAir = 0.0;
   17805           0 :     ort->gatherRainWater = 0.0;
   17806           0 :     ort->gatherCondensate = 0.0;
   17807           0 :     ort->gatherWellwater = 0.0;
   17808           0 :     ort->gatherMains = 0.0;
   17809           0 :     ort->gatherWaterEndUseTotal = 0.0;
   17810           0 : }
   17811             : 
   17812           0 : void ResetSourceEnergyEndUseGathering(EnergyPlusData &state)
   17813             : {
   17814             :     // Jason Glazer - October 2015
   17815             :     // Reset all source energy end use table gathering arrays to zero for multi-year simulations
   17816             :     // so that only last year is reported in tabular reports
   17817           0 :     auto &ort = state.dataOutRptTab;
   17818           0 :     ort->gatherTotalsBySourceBEPS = 0.0;
   17819           0 :     ort->gatherEndUseBySourceBEPS = 0.0;
   17820           0 : }
   17821             : 
   17822           0 : void ResetPeakDemandGathering(EnergyPlusData &state)
   17823             : {
   17824             :     // Jason Glazer - October 2015
   17825             :     // Reset all demand end use components table gathering arrays to zero for multi-year simulations
   17826             :     // so that only last year is reported in tabular reports
   17827           0 :     auto &ort = state.dataOutRptTab;
   17828           0 :     ort->gatherDemandTotal = 0.0;
   17829           0 :     ort->gatherDemandTimeStamp = 0;
   17830           0 :     ort->gatherDemandEndUse = 0.0;
   17831           0 :     ort->gatherDemandEndUseSub = 0.0;
   17832           0 : }
   17833             : 
   17834           0 : void ResetHeatGainGathering(EnergyPlusData &state)
   17835             : {
   17836             :     // Jason Glazer - October 2015
   17837             :     // Reset all sensible heat gas summary report gathering arrays to zero for multi-year simulations
   17838             :     // so that only last year is reported in tabular reports
   17839           0 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   17840           0 :         auto &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
   17841             : 
   17842           0 :         thisZonePreDefRep.SHGSAnPeoplAdd = 0.;
   17843           0 :         thisZonePreDefRep.SHGSAnLiteAdd = 0.;
   17844           0 :         thisZonePreDefRep.SHGSAnZoneEqHt = 0.;
   17845           0 :         thisZonePreDefRep.SHGSAnZoneEqCl = 0.;
   17846           0 :         thisZonePreDefRep.SHGSAnIzaAdd = 0.;
   17847           0 :         thisZonePreDefRep.SHGSAnIzaRem = 0.;
   17848           0 :         thisZonePreDefRep.SHGSAnWindAdd = 0.;
   17849           0 :         thisZonePreDefRep.SHGSAnWindRem = 0.;
   17850           0 :         thisZonePreDefRep.SHGSAnInfilAdd = 0.;
   17851           0 :         thisZonePreDefRep.SHGSAnInfilRem = 0.;
   17852           0 :         thisZonePreDefRep.SHGSAnEquipAdd = 0.;
   17853           0 :         thisZonePreDefRep.SHGSAnEquipRem = 0.;
   17854           0 :         thisZonePreDefRep.SHGSAnHvacATUHt = 0.;
   17855           0 :         thisZonePreDefRep.SHGSAnHvacATUCl = 0.;
   17856           0 :         thisZonePreDefRep.SHGSAnSurfHt = 0.;
   17857           0 :         thisZonePreDefRep.SHGSAnSurfCl = 0.;
   17858           0 :         thisZonePreDefRep.SHGSAnOtherAdd = 0.;
   17859           0 :         thisZonePreDefRep.SHGSAnOtherRem = 0.;
   17860           0 :         thisZonePreDefRep.htPeak = 0.;
   17861           0 :         thisZonePreDefRep.htPtTimeStamp = 0;
   17862           0 :         thisZonePreDefRep.SHGSHtHvacHt = 0.;
   17863           0 :         thisZonePreDefRep.SHGSHtHvacCl = 0.;
   17864           0 :         thisZonePreDefRep.SHGSHtSurfHt = 0.;
   17865           0 :         thisZonePreDefRep.SHGSHtSurfCl = 0.;
   17866           0 :         thisZonePreDefRep.SHGSHtHvacATUHt = 0.;
   17867           0 :         thisZonePreDefRep.SHGSHtHvacATUCl = 0.;
   17868           0 :         thisZonePreDefRep.SHGSHtPeoplAdd = 0.;
   17869           0 :         thisZonePreDefRep.SHGSHtLiteAdd = 0.;
   17870           0 :         thisZonePreDefRep.SHGSHtEquipAdd = 0.;
   17871           0 :         thisZonePreDefRep.SHGSHtEquipRem = 0.;
   17872           0 :         thisZonePreDefRep.SHGSHtWindAdd = 0.;
   17873           0 :         thisZonePreDefRep.SHGSHtWindRem = 0.;
   17874           0 :         thisZonePreDefRep.SHGSHtIzaAdd = 0.;
   17875           0 :         thisZonePreDefRep.SHGSHtIzaRem = 0.;
   17876           0 :         thisZonePreDefRep.SHGSHtInfilAdd = 0.;
   17877           0 :         thisZonePreDefRep.SHGSHtInfilRem = 0.;
   17878           0 :         thisZonePreDefRep.SHGSHtOtherAdd = 0.;
   17879           0 :         thisZonePreDefRep.SHGSHtOtherRem = 0.;
   17880           0 :         thisZonePreDefRep.clPeak = 0.;
   17881           0 :         thisZonePreDefRep.clPtTimeStamp = 0;
   17882           0 :         thisZonePreDefRep.SHGSClHvacHt = 0.;
   17883           0 :         thisZonePreDefRep.SHGSClHvacCl = 0.;
   17884           0 :         thisZonePreDefRep.SHGSClSurfHt = 0.;
   17885           0 :         thisZonePreDefRep.SHGSClSurfCl = 0.;
   17886           0 :         thisZonePreDefRep.SHGSClHvacATUHt = 0.;
   17887           0 :         thisZonePreDefRep.SHGSClHvacATUCl = 0.;
   17888           0 :         thisZonePreDefRep.SHGSClPeoplAdd = 0.;
   17889           0 :         thisZonePreDefRep.SHGSClLiteAdd = 0.;
   17890           0 :         thisZonePreDefRep.SHGSClEquipAdd = 0.;
   17891           0 :         thisZonePreDefRep.SHGSClEquipRem = 0.;
   17892           0 :         thisZonePreDefRep.SHGSClWindAdd = 0.;
   17893           0 :         thisZonePreDefRep.SHGSClWindRem = 0.;
   17894           0 :         thisZonePreDefRep.SHGSClIzaAdd = 0.;
   17895           0 :         thisZonePreDefRep.SHGSClIzaRem = 0.;
   17896           0 :         thisZonePreDefRep.SHGSClInfilAdd = 0.;
   17897           0 :         thisZonePreDefRep.SHGSClInfilRem = 0.;
   17898           0 :         thisZonePreDefRep.SHGSClOtherAdd = 0.;
   17899           0 :         thisZonePreDefRep.SHGSClOtherRem = 0.;
   17900             :     }
   17901             : 
   17902           0 :     state.dataHeatBal->BuildingPreDefRep.htPeak = 0.;
   17903           0 :     state.dataHeatBal->BuildingPreDefRep.htPtTimeStamp = 0;
   17904           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt = 0.0;
   17905           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl = 0.0;
   17906           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt = 0.0;
   17907           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl = 0.0;
   17908           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt = 0.0;
   17909           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl = 0.0;
   17910           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd = 0.0;
   17911           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd = 0.0;
   17912           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd = 0.0;
   17913           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd = 0.0;
   17914           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd = 0.0;
   17915           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd = 0.0;
   17916           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd = 0.0;
   17917           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem = 0.0;
   17918           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem = 0.0;
   17919           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem = 0.0;
   17920           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem = 0.0;
   17921           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem = 0.0;
   17922             : 
   17923           0 :     state.dataHeatBal->BuildingPreDefRep.clPeak = 0.;
   17924           0 :     state.dataHeatBal->BuildingPreDefRep.clPtTimeStamp = 0;
   17925           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt = 0.0;
   17926           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl = 0.0;
   17927           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt = 0.0;
   17928           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl = 0.0;
   17929           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt = 0.0;
   17930           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl = 0.0;
   17931           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd = 0.0;
   17932           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd = 0.0;
   17933           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd = 0.0;
   17934           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd = 0.0;
   17935           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd = 0.0;
   17936           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd = 0.0;
   17937           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd = 0.0;
   17938           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem = 0.0;
   17939           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem = 0.0;
   17940           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem = 0.0;
   17941           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem = 0.0;
   17942           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem = 0.0;
   17943           0 : }
   17944             : 
   17945           0 : void ResetRemainingPredefinedEntries(EnergyPlusData &state)
   17946             : {
   17947             :     // Jason Glazer - October 2015
   17948             :     // Reset all entries that are added to the predefined reports in the FillRemainingPredefinedEntries() function to zero for multi-year
   17949             :     // simulations so that only last year is reported in tabular reports
   17950             : 
   17951           0 :     Real64 constexpr bigVal(0.0); // used with HUGE: Value doesn't matter, only type: Initialize so compiler doesn't warn about use uninitialized
   17952             : 
   17953           0 :     for (int iLight = 1; iLight <= state.dataHeatBal->TotLights; ++iLight) {
   17954           0 :         state.dataHeatBal->Lights(iLight).SumTimeNotZeroCons = 0.;
   17955           0 :         state.dataHeatBal->Lights(iLight).SumConsumption = 0.;
   17956             :     }
   17957             : 
   17958           0 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   17959           0 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
   17960             : 
   17961           0 :         if (thisZone.SystemZoneNodeNumber >= 0) { // conditioned zones only
   17962           0 :             if (thisZone.isNominalOccupied) {
   17963           0 :                 auto &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
   17964             : 
   17965           0 :                 thisZonePreDefRep.MechVentVolTotalOcc = 0.;
   17966           0 :                 thisZonePreDefRep.MechVentVolTotalOccStdDen = 0.;
   17967           0 :                 thisZonePreDefRep.MechVentVolMin = HUGE_(bigVal);
   17968           0 :                 thisZonePreDefRep.InfilVolTotalOcc = 0.;
   17969           0 :                 thisZonePreDefRep.InfilVolTotalOccStdDen = 0.;
   17970           0 :                 thisZonePreDefRep.InfilVolMin = HUGE_(bigVal);
   17971           0 :                 thisZonePreDefRep.AFNInfilVolTotalOcc = 0.;
   17972           0 :                 thisZonePreDefRep.AFNInfilVolTotalOccStdDen = 0.;
   17973           0 :                 thisZonePreDefRep.AFNInfilVolMin = HUGE_(bigVal);
   17974           0 :                 thisZonePreDefRep.SimpVentVolTotalOcc = 0.;
   17975           0 :                 thisZonePreDefRep.SimpVentVolTotalOccStdDen = 0.;
   17976           0 :                 thisZonePreDefRep.SimpVentVolMin = HUGE_(bigVal);
   17977           0 :                 thisZonePreDefRep.AFNVentVolTotalOccStdDen = 0.;
   17978           0 :                 thisZonePreDefRep.TotTimeOcc = 0.;
   17979             :             }
   17980             :         }
   17981             :     }
   17982           0 : }
   17983             : 
   17984           0 : void ResetAdaptiveComfort(EnergyPlusData &state)
   17985             : {
   17986             :     // Jason Glazer - October 2015
   17987             :     // Reset accumulation variable for adaptive comfort report to zero for multi-year simulations
   17988             :     // so that only last year is reported in tabular reports
   17989           0 :     auto const &ort = state.dataOutRptTab;
   17990           0 :     if (ort->displayAdaptiveComfort && state.dataHeatBal->TotPeople > 0) {
   17991           0 :         for (int i = 1; i <= state.dataHeatBal->TotPeople; ++i) {
   17992           0 :             auto &thisPeople = state.dataHeatBal->People(i);
   17993             : 
   17994           0 :             if (thisPeople.AdaptiveASH55) {
   17995           0 :                 thisPeople.TimeNotMetASH5590 = 0.;
   17996           0 :                 thisPeople.TimeNotMetASH5580 = 0.;
   17997             :             }
   17998           0 :             if (thisPeople.AdaptiveCEN15251) {
   17999           0 :                 thisPeople.TimeNotMetCEN15251CatI = 0.;
   18000           0 :                 thisPeople.TimeNotMetCEN15251CatII = 0.;
   18001           0 :                 thisPeople.TimeNotMetCEN15251CatIII = 0.;
   18002             :             }
   18003             :         }
   18004             :     }
   18005           0 : }
   18006             : 
   18007             : //======================================================================================================================
   18008             : //======================================================================================================================
   18009             : 
   18010             : //    ROUTINES RELATED TO IF VALUE IS IN A RANGE
   18011             : 
   18012             : //======================================================================================================================
   18013             : //======================================================================================================================
   18014             : 
   18015     3401176 : bool isInTriangle(
   18016             :     Real64 const qx, Real64 const qy, Real64 const x1, Real64 const y1, Real64 const x2, Real64 const y2, Real64 const x3, Real64 const y3)
   18017             : {
   18018             :     // SUBROUTINE INFORMATION:
   18019             :     //       AUTHOR         Jason Glazer
   18020             :     //       DATE WRITTEN   June 2005
   18021             :     //       MODIFIED
   18022             :     //       RE-ENGINEERED  na
   18023             : 
   18024             :     // PURPOSE OF THIS SUBROUTINE:
   18025             :     //   Determine if point q is in triangle defined by points a,b,c
   18026             : 
   18027             :     // METHODOLOGY EMPLOYED:
   18028             :     //   The function used three times is positive the point is on the "right"
   18029             :     //   side and negative if on "left" side. By checking to make sure the signs
   18030             :     //   are always the same. it determines that the point is inside of the
   18031             :     //   triangle.
   18032             : 
   18033             :     // REFERENCES:
   18034             :     //   http://mcraefamily.com/MathHelp/GeometryPointAndTriangle2.htm
   18035             : 
   18036     3401176 :     Real64 const fAB = (qy - y1) * (x2 - x1) - (qx - x1) * (y2 - y1);
   18037     3401176 :     Real64 const fCA = (qy - y3) * (x1 - x3) - (qx - x3) * (y1 - y3);
   18038     3401176 :     Real64 const fBC = (qy - y2) * (x3 - x2) - (qx - x2) * (y3 - y2);
   18039     3401176 :     return ((fAB * fBC) >= 0.0 && (fBC * fCA) >= 0.0);
   18040             : }
   18041             : 
   18042     1700588 : bool isInQuadrilateral(Real64 const qx,
   18043             :                        Real64 const qy,
   18044             :                        Real64 const ax,
   18045             :                        Real64 const ay,
   18046             :                        Real64 const bx,
   18047             :                        Real64 const by,
   18048             :                        Real64 const cx,
   18049             :                        Real64 const cy,
   18050             :                        Real64 const dx,
   18051             :                        Real64 const dy)
   18052             : {
   18053             :     // SUBROUTINE INFORMATION:
   18054             :     //       AUTHOR         Jason Glazer
   18055             :     //       DATE WRITTEN   June 2005
   18056             :     //       MODIFIED
   18057             :     //       RE-ENGINEERED  na
   18058             : 
   18059             :     // PURPOSE OF THIS SUBROUTINE:
   18060             :     //   Determine if point q is in a quadrilateral defined by points a,b,c,d
   18061             :     //   Those points should express a quadrilateral in order of the points going
   18062             :     //   around the outside of the polygon. They should not describe an "hourglass"
   18063             :     //   shape where the lines cross in the middle of the figure.
   18064             : 
   18065             :     // METHODOLOGY EMPLOYED:
   18066             :     //   Check if the point is in triangle a,b,c or in triangle c,d,a
   18067             : 
   18068             :     // REFERENCES:
   18069             :     //   http://mcraefamily.com/MathHelp/GeometryPointAndTriangle4.htm
   18070             : 
   18071     1700588 :     bool const inABC = isInTriangle(qx, qy, ax, ay, bx, by, cx, cy);
   18072     1700588 :     bool const inCDA = isInTriangle(qx, qy, cx, cy, dx, dy, ax, ay);
   18073     1700588 :     return (inABC || inCDA);
   18074             : }
   18075             : 
   18076             : //======================================================================================================================
   18077             : //======================================================================================================================
   18078             : 
   18079             : //    SUPPORT ROUTINES
   18080             : 
   18081             : //======================================================================================================================
   18082             : //======================================================================================================================
   18083             : 
   18084     1996876 : std::string RealToStr(Real64 const RealIn, int const numDigits)
   18085             : {
   18086             :     // FUNCTION INFORMATION:
   18087             :     //       AUTHOR         Jason Glazer
   18088             :     //       DATE WRITTEN   August 2003
   18089             :     //       MODIFIED       November 2008; LKL - prevent errors
   18090             :     //       RE-ENGINEERED  na
   18091             : 
   18092             :     // PURPOSE OF THIS FUNCTION:
   18093             :     //   Abstract away the internal write concept
   18094             : 
   18095             :     static constexpr std::array<const char *, 10> formDigitsA{
   18096             :         "{:#11.0F}", "{:12.1F}", "{:12.2F}", "{:12.3F}", "{:12.4F}", "{:12.5F}", "{:12.6F}", "{:12.7F}", "{:12.8F}", "{:12.9F}"};
   18097             : 
   18098             :     static constexpr std::array<Real64, 10> maxvalDigitsA(
   18099             :         {9999999999.0, 999999999.0, 99999999.0, 9999999.0, 999999.0, 99999.0, 9999.0, 999.0, 99.0, 9.0});
   18100             : 
   18101             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   18102     1996876 :     int nDigits = numDigits;
   18103     1996876 :     if (RealIn < 0.0) --nDigits;
   18104     1996876 :     if (nDigits > 9) nDigits = 9;
   18105     1996876 :     if (nDigits < 0) nDigits = 0;
   18106             : 
   18107     1996876 :     if (std::abs(RealIn) > maxvalDigitsA.at(nDigits)) {
   18108          82 :         return format("{:12.6Z}", RealIn);
   18109             :     } else {
   18110     1996794 :         return format<FormatSyntax::FMT>(formDigitsA.at(nDigits), RealIn);
   18111             :     }
   18112             :     //  WRITE(FMT=, UNIT=stringOut) RealIn
   18113             :     // check if it did not fit
   18114             :     //  IF (stringOut(1:1) .EQ. "*") THEN
   18115             :     //    WRITE(FMT='(E12.6)', UNIT=stringOut) RealIn
   18116             :     //  END IF
   18117             : 
   18118             :     // WRITE(FMT="(F10.4)", UNIT=stringOut, IOSTAT=status ) RealIn
   18119             : }
   18120             : 
   18121       16614 : Real64 StrToReal(std::string_view stringIn)
   18122             : {
   18123             :     // SUBROUTINE INFORMATION:
   18124             :     //       AUTHOR         Linda Lawrie
   18125             :     //       DATE WRITTEN   March 2010
   18126             :     //       MODIFIED       na
   18127             :     //       RE-ENGINEERED  na
   18128             : 
   18129             :     // PURPOSE OF THIS SUBROUTINE:
   18130             :     //   Abstract away the internal read concept
   18131             : 
   18132       16614 :     size_t first_char = stringIn.find_first_not_of(' ');
   18133       16614 :     if (first_char != std::string_view::npos) {
   18134       16613 :         stringIn.remove_prefix(first_char);
   18135             :     }
   18136             : 
   18137       16614 :     Real64 realValue = -99999.0;
   18138       16614 :     auto answer = fast_float::from_chars(stringIn.data(), stringIn.data() + stringIn.size(), realValue); // (AUTO_OK_OBJ)
   18139       16614 :     if (answer.ec != std::errc()) {
   18140           1 :         return -99999.0;
   18141             :     }
   18142       16613 :     return realValue;
   18143             : }
   18144             : 
   18145       28238 : std::string DateToString(int const codedDate) // word containing encoded month, day, hour, minute
   18146             : {
   18147             :     // SUBROUTINE INFORMATION:
   18148             :     //       AUTHOR         Jason Glazer
   18149             :     //       DATE WRITTEN   August 2003
   18150             :     //       MODIFIED       na
   18151             :     //       RE-ENGINEERED  na
   18152             : 
   18153             :     // PURPOSE OF THIS SUBROUTINE:
   18154             :     //   Convert the coded date format into a usable
   18155             :     //   string
   18156             : 
   18157             :     int Month;  // month in integer format (1-12)
   18158             :     int Day;    // day in integer format (1-31)
   18159             :     int Hour;   // hour in integer format (1-24)
   18160             :     int Minute; // minute in integer format (0:59)
   18161             :     static constexpr std::array<std::string_view, 12> Months{"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
   18162             : 
   18163       28238 :     if (codedDate == 0) {
   18164       28147 :         return "-";
   18165             :     }
   18166             : 
   18167          91 :     General::DecodeMonDayHrMin(codedDate, Month, Day, Hour, Minute);
   18168          91 :     if (Month < 1 || Month > 12) {
   18169           0 :         return "-";
   18170             :     }
   18171             : 
   18172          91 :     --Hour;
   18173          91 :     if (Minute == 60) {
   18174           0 :         ++Hour;
   18175           0 :         Minute = 0;
   18176             :     }
   18177             : 
   18178         182 :     return fmt::format("{:02}-{:3}-{:02}:{:02}", Day, Months[Month - 1], Hour, Minute);
   18179             : }
   18180             : 
   18181       28400 : bool isNumber(std::string const &s)
   18182             : {
   18183             :     char *p;
   18184       28400 :     strtod(s.c_str(), &p);
   18185       28407 :     for (; isspace(*p); ++p)
   18186             :         ; // handle trailing whitespace
   18187       28400 :     return *p == 0;
   18188             : }
   18189             : 
   18190             : // return the number of digits after the decimal point
   18191             : // Glazer - November 2016
   18192        7450 : int digitsAferDecimal(std::string const &s)
   18193             : {
   18194        7450 :     std::size_t decimalpos = s.find('.');
   18195             :     std::size_t numDigits;
   18196        7450 :     if (decimalpos == s.npos) {
   18197          68 :         numDigits = 0;
   18198             :     } else {
   18199        7382 :         std::size_t epos = s.find('E');
   18200        7382 :         if (epos == s.npos) epos = s.find('e');
   18201        7382 :         if (epos == s.npos) {
   18202        6699 :             numDigits = s.length() - (decimalpos + 1);
   18203             :         } else {
   18204         683 :             numDigits = epos - (decimalpos + 1);
   18205             :         }
   18206             :     }
   18207        7450 :     return int(numDigits);
   18208             : }
   18209             : 
   18210         308 : void AddTOCEntry(EnergyPlusData &state, std::string const &nameSection, std::string const &nameReport)
   18211             : {
   18212             :     // SUBROUTINE INFORMATION:
   18213             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   18214             :     //    DATE WRITTEN   September 2005
   18215             :     //    MODIFIED       na
   18216             :     //    RE-ENGINEERED  na
   18217             : 
   18218             :     // PURPOSE OF THIS SUBROUTINE:
   18219             :     //   Adds an entry for the TOC so that it can be created
   18220             :     //   prior to the actual reports being generated. Note that
   18221             :     //   the arguments must match what is used in
   18222             :     //   "WriteReportHeaders" for the HTML anchors to work
   18223             :     //   correctly.
   18224             : 
   18225             :     // METHODOLOGY EMPLOYED:
   18226             : 
   18227             :     // REFERENCES:
   18228             :     //    na
   18229             : 
   18230             :     // USE STATEMENTS:
   18231             : 
   18232             :     // Locals
   18233             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   18234             : 
   18235             :     // SUBROUTINE PARAMETER DEFINITIONS:
   18236             :     //    na
   18237             : 
   18238             :     // INTERFACE BLOCK SPECIFICATIONS:
   18239             :     //    na
   18240             : 
   18241             :     // DERIVED TYPE DEFINITIONS:
   18242             :     //    na
   18243             : 
   18244             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   18245             :     //    na
   18246         308 :     auto &ort = state.dataOutRptTab;
   18247             : 
   18248         308 :     if (!allocated(ort->TOCEntries)) {
   18249          56 :         ort->TOCEntriesSize = 20;
   18250          56 :         ort->TOCEntries.allocate(ort->TOCEntriesSize);
   18251          56 :         ort->TOCEntriesCount = 1;
   18252             :     } else {
   18253         252 :         ++ort->TOCEntriesCount;
   18254             :         // if larger than current size grow the array
   18255         252 :         if (ort->TOCEntriesCount > ort->TOCEntriesSize) {
   18256           2 :             ort->TOCEntries.redimension(ort->TOCEntriesSize += 20);
   18257             :         }
   18258             :     }
   18259         308 :     ort->TOCEntries(ort->TOCEntriesCount).reportName = nameReport;
   18260         308 :     ort->TOCEntries(ort->TOCEntriesCount).sectionName = nameSection;
   18261         308 : }
   18262             : 
   18263         794 : void SetupUnitConversions(EnergyPlusData &state)
   18264             : {
   18265             :     // SUBROUTINE INFORMATION:
   18266             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   18267             :     //    DATE WRITTEN   February 12, 2009
   18268             :     //    MODIFIED       March 2010; Linda Lawrie; Add deltaC and KJ/KG
   18269             :     //    RE-ENGINEERED  na
   18270             : 
   18271             :     // PURPOSE OF THIS SUBROUTINE:
   18272             :     //   Initialize the array that contains the unit conversion
   18273             :     //   information. The code is based on code generated
   18274             :     //   in a spreadsheet titled UnitConversion.xls
   18275             : 
   18276             :     // METHODOLOGY EMPLOYED:
   18277             : 
   18278             :     // REFERENCES:
   18279             :     //    na
   18280             : 
   18281             :     // USE STATEMENTS:
   18282             : 
   18283             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   18284             : 
   18285             :     // SUBROUTINE PARAMETER DEFINITIONS:
   18286             :     //    na
   18287             : 
   18288             :     // INTERFACE BLOCK SPECIFICATIONS:
   18289             :     //    na
   18290             : 
   18291             :     // DERIVED TYPE DEFINITIONS:
   18292             :     //    na
   18293             : 
   18294             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   18295             :     //    na
   18296         794 :     auto &ort = state.dataOutRptTab;
   18297             : 
   18298         794 :     ort->UnitConvSize = 118;
   18299         794 :     ort->UnitConv.allocate(ort->UnitConvSize);
   18300         794 :     ort->UnitConv(1).siName = "%";
   18301         794 :     ort->UnitConv(2).siName = "°C";
   18302         794 :     ort->UnitConv(3).siName = "0=OFF 1=ON";
   18303         794 :     ort->UnitConv(4).siName = "0-NO  1-YES";
   18304         794 :     ort->UnitConv(5).siName = "1-YES 0-NO";
   18305         794 :     ort->UnitConv(6).siName = "A";
   18306         794 :     ort->UnitConv(7).siName = "ACH";
   18307         794 :     ort->UnitConv(8).siName = "ACH";
   18308         794 :     ort->UnitConv(9).siName = "BASE 10C";
   18309         794 :     ort->UnitConv(10).siName = "BASE 18C";
   18310         794 :     ort->UnitConv(11).siName = "C";
   18311         794 :     ort->UnitConv(12).siName = "CD/M2";
   18312         794 :     ort->UnitConv(13).siName = "DEG";
   18313         794 :     ort->UnitConv(14).siName = "FRAC";
   18314         794 :     ort->UnitConv(15).siName = "HOUR";
   18315         794 :     ort->UnitConv(16).siName = "HOURS";
   18316         794 :     ort->UnitConv(17).siName = "HR";
   18317         794 :     ort->UnitConv(18).siName = "HRS";
   18318         794 :     ort->UnitConv(19).siName = "J";
   18319         794 :     ort->UnitConv(20).siName = "J";
   18320         794 :     ort->UnitConv(21).siName = "J";
   18321         794 :     ort->UnitConv(22).siName = "J";
   18322         794 :     ort->UnitConv(23).siName = "J";
   18323         794 :     ort->UnitConv(24).siName = "J";
   18324         794 :     ort->UnitConv(25).siName = "J/KG";
   18325         794 :     ort->UnitConv(26).siName = "J/KGWATER";
   18326         794 :     ort->UnitConv(27).siName = "J/M2";
   18327         794 :     ort->UnitConv(28).siName = "K/M";
   18328         794 :     ort->UnitConv(29).siName = "KG";
   18329         794 :     ort->UnitConv(30).siName = "KG/KG";
   18330         794 :     ort->UnitConv(31).siName = "KG/M3";
   18331         794 :     ort->UnitConv(32).siName = "KG/S";
   18332         794 :     ort->UnitConv(33).siName = "KGWATER/KGDRYAIR";
   18333         794 :     ort->UnitConv(34).siName = "KGWATER/SEC";
   18334         794 :     ort->UnitConv(35).siName = "KMOL/S";
   18335         794 :     ort->UnitConv(36).siName = "KMOL/SEC";
   18336         794 :     ort->UnitConv(37).siName = "KWH";
   18337         794 :     ort->UnitConv(38).siName = "L";
   18338         794 :     ort->UnitConv(39).siName = "L";
   18339         794 :     ort->UnitConv(40).siName = "LUM/W";
   18340         794 :     ort->UnitConv(41).siName = "LUX";
   18341         794 :     ort->UnitConv(42).siName = "M";
   18342         794 :     ort->UnitConv(43).siName = "M";
   18343         794 :     ort->UnitConv(44).siName = "M/S";
   18344         794 :     ort->UnitConv(45).siName = "M/S";
   18345         794 :     ort->UnitConv(46).siName = "M2";
   18346         794 :     ort->UnitConv(47).siName = "M2/PERSON";
   18347         794 :     ort->UnitConv(48).siName = "M3";
   18348         794 :     ort->UnitConv(49).siName = "M3";
   18349         794 :     ort->UnitConv(50).siName = "M3/M2";
   18350         794 :     ort->UnitConv(51).siName = "M3/S";
   18351         794 :     ort->UnitConv(52).siName = "M3/S";
   18352         794 :     ort->UnitConv(53).siName = "M3/S-M2";
   18353         794 :     ort->UnitConv(54).siName = "M3/S-PERSON";
   18354         794 :     ort->UnitConv(55).siName = "M3/S-PERSON";
   18355         794 :     ort->UnitConv(56).siName = "PA";
   18356         794 :     ort->UnitConv(57).siName = "PA";
   18357         794 :     ort->UnitConv(58).siName = "PA";
   18358         794 :     ort->UnitConv(59).siName = "PA";
   18359         794 :     ort->UnitConv(60).siName = "PA";
   18360         794 :     ort->UnitConv(61).siName = "PA";
   18361         794 :     ort->UnitConv(62).siName = "PA";
   18362         794 :     ort->UnitConv(63).siName = "PA";
   18363         794 :     ort->UnitConv(64).siName = "S";
   18364         794 :     ort->UnitConv(65).siName = "V";
   18365         794 :     ort->UnitConv(66).siName = "W";
   18366         794 :     ort->UnitConv(67).siName = "W";
   18367         794 :     ort->UnitConv(68).siName = "W";
   18368         794 :     ort->UnitConv(69).siName = "W";
   18369         794 :     ort->UnitConv(70).siName = "W";
   18370         794 :     ort->UnitConv(71).siName = "W/KG";
   18371         794 :     ort->UnitConv(72).siName = "W/KG H2O"; // TODO: replace with W/kgWater? or rather just remove
   18372         794 :     ort->UnitConv(73).siName = "W/K";
   18373         794 :     ort->UnitConv(74).siName = "W/M2";
   18374         794 :     ort->UnitConv(75).siName = "W/M2";
   18375         794 :     ort->UnitConv(76).siName = "W/M2-C";
   18376         794 :     ort->UnitConv(77).siName = "W/M2-K";
   18377         794 :     ort->UnitConv(78).siName = "W/W";
   18378         794 :     ort->UnitConv(79).siName = "W/W";
   18379         794 :     ort->UnitConv(80).siName = "deltaC";
   18380         794 :     ort->UnitConv(81).siName = "KJ/KG";
   18381         794 :     ort->UnitConv(82).siName = "W-S/M3";
   18382         794 :     ort->UnitConv(83).siName = "W-S/M3";
   18383         794 :     ort->UnitConv(84).siName = "~~$~~/m2";
   18384         794 :     ort->UnitConv(85).siName = "GJ";
   18385         794 :     ort->UnitConv(86).siName = "GJ";
   18386         794 :     ort->UnitConv(87).siName = "GJ";
   18387         794 :     ort->UnitConv(88).siName = "GJ";
   18388         794 :     ort->UnitConv(89).siName = "GJ";
   18389         794 :     ort->UnitConv(90).siName = "GJ";
   18390         794 :     ort->UnitConv(91).siName = "GJ";
   18391         794 :     ort->UnitConv(92).siName = "MJ/m2";
   18392         794 :     ort->UnitConv(93).siName = "MJ/m2";
   18393         794 :     ort->UnitConv(94).siName = "MJ/m2";
   18394         794 :     ort->UnitConv(95).siName = "MJ/m2";
   18395         794 :     ort->UnitConv(96).siName = "Invalid/Undefined";
   18396         794 :     ort->UnitConv(97).siName = "";
   18397         794 :     ort->UnitConv(98).siName = "W/C";
   18398         794 :     ort->UnitConv(99).siName = "DAY";
   18399         794 :     ort->UnitConv(100).siName = "MIN";
   18400         794 :     ort->UnitConv(101).siName = "HR/WK";
   18401         794 :     ort->UnitConv(102).siName = "$";
   18402         794 :     ort->UnitConv(103).siName = "$/UNIT ENERGY";
   18403         794 :     ort->UnitConv(104).siName = "KW";
   18404         794 :     ort->UnitConv(105).siName = " ";
   18405         794 :     ort->UnitConv(106).siName = "AH";
   18406         794 :     ort->UnitConv(107).siName = "CLO";
   18407         794 :     ort->UnitConv(108).siName = "J/KG-K";
   18408         794 :     ort->UnitConv(109).siName = "KGWATER/S";
   18409         794 :     ort->UnitConv(110).siName = "PPM";
   18410         794 :     ort->UnitConv(111).siName = "RAD";
   18411         794 :     ort->UnitConv(112).siName = "REV/MIN";
   18412         794 :     ort->UnitConv(113).siName = "NM";
   18413         794 :     ort->UnitConv(114).siName = "BTU/W-H"; // Used for AHRI rating metrics (e.g. SEER)
   18414         794 :     ort->UnitConv(115).siName = "PERSON/M2";
   18415         794 :     ort->UnitConv(116).siName = "MM";
   18416         794 :     ort->UnitConv(117).siName = "MM";
   18417         794 :     ort->UnitConv(118).siName = "°C·hr";
   18418             : 
   18419         794 :     ort->UnitConv(1).ipName = "%";
   18420         794 :     ort->UnitConv(2).ipName = "F";
   18421         794 :     ort->UnitConv(3).ipName = "0=Off 1=On";
   18422         794 :     ort->UnitConv(4).ipName = "0-No  1-Yes";
   18423         794 :     ort->UnitConv(5).ipName = "1-Yes 0-No";
   18424         794 :     ort->UnitConv(6).ipName = "A";
   18425         794 :     ort->UnitConv(7).ipName = "ACH";
   18426         794 :     ort->UnitConv(8).ipName = "ach";
   18427         794 :     ort->UnitConv(9).ipName = "base 50F";
   18428         794 :     ort->UnitConv(10).ipName = "base 65F";
   18429         794 :     ort->UnitConv(11).ipName = "F";
   18430         794 :     ort->UnitConv(12).ipName = "cd/in2";
   18431         794 :     ort->UnitConv(13).ipName = "deg";
   18432         794 :     ort->UnitConv(14).ipName = "Frac";
   18433         794 :     ort->UnitConv(15).ipName = "Hour";
   18434         794 :     ort->UnitConv(16).ipName = "Hours";
   18435         794 :     ort->UnitConv(17).ipName = "hr";
   18436         794 :     ort->UnitConv(18).ipName = "hrs";
   18437         794 :     ort->UnitConv(19).ipName = "kBtu";
   18438         794 :     ort->UnitConv(20).ipName = "kWh";
   18439         794 :     ort->UnitConv(21).ipName = "therm";
   18440         794 :     ort->UnitConv(22).ipName = "MMBtu";
   18441         794 :     ort->UnitConv(23).ipName = "Wh";
   18442         794 :     ort->UnitConv(24).ipName = "ton-hrs";
   18443         794 :     ort->UnitConv(25).ipName = "Btu/lb";
   18444         794 :     ort->UnitConv(26).ipName = "Btu/lbWater";
   18445         794 :     ort->UnitConv(27).ipName = "kBtu/sqft";
   18446         794 :     ort->UnitConv(28).ipName = "F/ft";
   18447         794 :     ort->UnitConv(29).ipName = "lb";
   18448         794 :     ort->UnitConv(30).ipName = "lb/lb";
   18449         794 :     ort->UnitConv(31).ipName = "lb/ft3";
   18450         794 :     ort->UnitConv(32).ipName = "lb/s";
   18451         794 :     ort->UnitConv(33).ipName = "lbWater/lbDryAir";
   18452         794 :     ort->UnitConv(34).ipName = "lbWater/s";
   18453         794 :     ort->UnitConv(35).ipName = "kmol/s";
   18454         794 :     ort->UnitConv(36).ipName = "kmol/sec";
   18455         794 :     ort->UnitConv(37).ipName = "kWh";
   18456         794 :     ort->UnitConv(38).ipName = "gal";
   18457         794 :     ort->UnitConv(39).ipName = "ft3";
   18458         794 :     ort->UnitConv(40).ipName = "lum/W";
   18459         794 :     ort->UnitConv(41).ipName = "foot-candles";
   18460         794 :     ort->UnitConv(42).ipName = "ft";
   18461         794 :     ort->UnitConv(43).ipName = "in";
   18462         794 :     ort->UnitConv(44).ipName = "ft/min";
   18463         794 :     ort->UnitConv(45).ipName = "miles/hr";
   18464         794 :     ort->UnitConv(46).ipName = "ft2";
   18465         794 :     ort->UnitConv(47).ipName = "ft2/person";
   18466         794 :     ort->UnitConv(48).ipName = "ft3";
   18467         794 :     ort->UnitConv(49).ipName = "gal";
   18468         794 :     ort->UnitConv(50).ipName = "f3/f2";
   18469         794 :     ort->UnitConv(51).ipName = "ft3/min";
   18470         794 :     ort->UnitConv(52).ipName = "gal/min";
   18471         794 :     ort->UnitConv(53).ipName = "ft3/min-ft2";
   18472         794 :     ort->UnitConv(54).ipName = "ft3/min-person";
   18473         794 :     ort->UnitConv(55).ipName = "gal/min-person";
   18474         794 :     ort->UnitConv(56).ipName = "psi";
   18475         794 :     ort->UnitConv(57).ipName = "inHg";
   18476         794 :     ort->UnitConv(58).ipName = "inH2O";
   18477         794 :     ort->UnitConv(59).ipName = "ftH2O";
   18478         794 :     ort->UnitConv(60).ipName = "psi";
   18479         794 :     ort->UnitConv(61).ipName = "inHg";
   18480         794 :     ort->UnitConv(62).ipName = "inH2O";
   18481         794 :     ort->UnitConv(63).ipName = "ftH2O";
   18482         794 :     ort->UnitConv(64).ipName = "s";
   18483         794 :     ort->UnitConv(65).ipName = "V";
   18484         794 :     ort->UnitConv(66).ipName = "Btu/h";
   18485         794 :     ort->UnitConv(67).ipName = "W";
   18486         794 :     ort->UnitConv(68).ipName = "kW";
   18487         794 :     ort->UnitConv(69).ipName = "kBtuh";
   18488         794 :     ort->UnitConv(70).ipName = "ton";
   18489         794 :     ort->UnitConv(71).ipName = "kBtuh/lb";
   18490         794 :     ort->UnitConv(72).ipName = "kBtuh/lb";
   18491         794 :     ort->UnitConv(73).ipName = "Btu/h-F";
   18492         794 :     ort->UnitConv(74).ipName = "Btu/h-ft2";
   18493         794 :     ort->UnitConv(75).ipName = "kBtuh/ft2";
   18494         794 :     ort->UnitConv(76).ipName = "Btu/h-ft2-F";
   18495         794 :     ort->UnitConv(77).ipName = "Btu/h-ft2-F";
   18496         794 :     ort->UnitConv(78).ipName = "Btuh/Btuh";
   18497         794 :     ort->UnitConv(79).ipName = "W/W";
   18498         794 :     ort->UnitConv(80).ipName = "deltaF";
   18499         794 :     ort->UnitConv(81).ipName = "Btu/lb";
   18500         794 :     ort->UnitConv(82).ipName = "W-min/ft3";
   18501         794 :     ort->UnitConv(83).ipName = "W-min/gal";
   18502         794 :     ort->UnitConv(84).ipName = "~~$~~/ft2";
   18503         794 :     ort->UnitConv(85).ipName = "kBtu";
   18504         794 :     ort->UnitConv(86).ipName = "kWh";
   18505         794 :     ort->UnitConv(87).ipName = "kWh";
   18506         794 :     ort->UnitConv(88).ipName = "therm";
   18507         794 :     ort->UnitConv(89).ipName = "MMBtu";
   18508         794 :     ort->UnitConv(90).ipName = "Wh";
   18509         794 :     ort->UnitConv(91).ipName = "ton-hrs";
   18510         794 :     ort->UnitConv(92).ipName = "kWh/ft2";
   18511         794 :     ort->UnitConv(93).ipName = "kBtu/ft2";
   18512         794 :     ort->UnitConv(94).ipName = "kBtu/ft2";
   18513         794 :     ort->UnitConv(95).ipName = "kWh/m2";
   18514         794 :     ort->UnitConv(96).ipName = "Invalid/Undefined";
   18515         794 :     ort->UnitConv(97).ipName = "";
   18516         794 :     ort->UnitConv(98).ipName = "Btu/h-F";
   18517         794 :     ort->UnitConv(99).ipName = "day";
   18518         794 :     ort->UnitConv(100).ipName = "min";
   18519         794 :     ort->UnitConv(101).ipName = "hr/wk";
   18520         794 :     ort->UnitConv(102).ipName = "$";
   18521         794 :     ort->UnitConv(103).ipName = "$/unit energy";
   18522         794 :     ort->UnitConv(104).ipName = "kW";
   18523         794 :     ort->UnitConv(105).ipName = " ";
   18524         794 :     ort->UnitConv(106).ipName = "Ah";
   18525         794 :     ort->UnitConv(107).ipName = "clo";
   18526         794 :     ort->UnitConv(108).ipName = "Btu/lbm-R";
   18527         794 :     ort->UnitConv(109).ipName = "lbWater/s";
   18528         794 :     ort->UnitConv(110).ipName = "ppm";
   18529         794 :     ort->UnitConv(111).ipName = "rad";
   18530         794 :     ort->UnitConv(112).ipName = "rev/min";
   18531         794 :     ort->UnitConv(113).ipName = "lbf-ft";
   18532         794 :     ort->UnitConv(114).ipName = "Btu/W-h";
   18533         794 :     ort->UnitConv(115).ipName = "person/ft2";
   18534         794 :     ort->UnitConv(116).ipName = "in";
   18535         794 :     ort->UnitConv(117).ipName = "ft";
   18536         794 :     ort->UnitConv(118).ipName = "°F·hr";
   18537             : 
   18538         794 :     ort->UnitConv(1).mult = 1.0;
   18539         794 :     ort->UnitConv(2).mult = 1.8;
   18540         794 :     ort->UnitConv(3).mult = 1.0;
   18541         794 :     ort->UnitConv(4).mult = 1.0;
   18542         794 :     ort->UnitConv(5).mult = 1.0;
   18543         794 :     ort->UnitConv(6).mult = 1.0;
   18544         794 :     ort->UnitConv(7).mult = 1.0;
   18545         794 :     ort->UnitConv(8).mult = 1.0;
   18546         794 :     ort->UnitConv(9).mult = 1.8;
   18547         794 :     ort->UnitConv(10).mult = 1.8;
   18548         794 :     ort->UnitConv(11).mult = 1.8;
   18549         794 :     ort->UnitConv(12).mult = 0.000645160041625726;
   18550         794 :     ort->UnitConv(13).mult = 1.0;
   18551         794 :     ort->UnitConv(14).mult = 1.0;
   18552         794 :     ort->UnitConv(15).mult = 1.0;
   18553         794 :     ort->UnitConv(16).mult = 1.0;
   18554         794 :     ort->UnitConv(17).mult = 1.0;
   18555         794 :     ort->UnitConv(18).mult = 1.0;
   18556         794 :     ort->UnitConv(19).mult = 0.00000094845;
   18557         794 :     ort->UnitConv(20).mult = 0.000000277778;
   18558         794 :     ort->UnitConv(21).mult = 0.0000000094845;
   18559         794 :     ort->UnitConv(22).mult = 0.00000000094845;
   18560         794 :     ort->UnitConv(23).mult = 0.000277777777777778;
   18561         794 :     ort->UnitConv(24).mult = 0.0000000789847;
   18562         794 :     ort->UnitConv(25).mult = 0.00042956;
   18563         794 :     ort->UnitConv(26).mult = 0.0000004302105;
   18564         794 :     ort->UnitConv(27).mult = 0.00000008811404;
   18565         794 :     ort->UnitConv(28).mult = 0.54861322767449;
   18566         794 :     ort->UnitConv(29).mult = 2.2046;
   18567         794 :     ort->UnitConv(30).mult = 1.0;
   18568         794 :     ort->UnitConv(31).mult = 0.062428;
   18569         794 :     ort->UnitConv(32).mult = 2.2046;
   18570         794 :     ort->UnitConv(33).mult = 1.0;
   18571         794 :     ort->UnitConv(34).mult = 2.2046;
   18572         794 :     ort->UnitConv(35).mult = 1.0;
   18573         794 :     ort->UnitConv(36).mult = 1.0;
   18574         794 :     ort->UnitConv(37).mult = 1.0;
   18575         794 :     ort->UnitConv(38).mult = 0.264172037284185;
   18576         794 :     ort->UnitConv(39).mult = 0.0353146624712848;
   18577         794 :     ort->UnitConv(40).mult = 1.0;
   18578         794 :     ort->UnitConv(41).mult = 0.092902267;
   18579         794 :     ort->UnitConv(42).mult = 3.281;
   18580         794 :     ort->UnitConv(43).mult = 39.37;
   18581         794 :     ort->UnitConv(44).mult = 196.86;
   18582         794 :     ort->UnitConv(45).mult = 2.2369;
   18583         794 :     ort->UnitConv(46).mult = 10.764961;
   18584         794 :     ort->UnitConv(47).mult = 10.764961;
   18585         794 :     ort->UnitConv(48).mult = 35.319837041;
   18586         794 :     ort->UnitConv(49).mult = 264.172;
   18587         794 :     ort->UnitConv(50).mult = 3.281;
   18588         794 :     ort->UnitConv(51).mult = 2118.6438;
   18589         794 :     ort->UnitConv(52).mult = 15852.0;
   18590         794 :     ort->UnitConv(53).mult = 196.85;
   18591         794 :     ort->UnitConv(54).mult = 2118.6438;
   18592         794 :     ort->UnitConv(55).mult = 15852.0;
   18593         794 :     ort->UnitConv(56).mult = 0.0001450377;
   18594         794 :     ort->UnitConv(57).mult = 0.00029613;
   18595         794 :     ort->UnitConv(58).mult = 0.00401463;
   18596         794 :     ort->UnitConv(59).mult = 0.00033455;
   18597         794 :     ort->UnitConv(60).mult = 0.0001450377;
   18598         794 :     ort->UnitConv(61).mult = 0.00029613;
   18599         794 :     ort->UnitConv(62).mult = 0.00401463;
   18600         794 :     ort->UnitConv(63).mult = 0.00033455;
   18601         794 :     ort->UnitConv(64).mult = 1.0;
   18602         794 :     ort->UnitConv(65).mult = 1.0;
   18603         794 :     ort->UnitConv(66).mult = 3.412;
   18604         794 :     ort->UnitConv(67).mult = 1.0;
   18605         794 :     ort->UnitConv(68).mult = 0.001;
   18606         794 :     ort->UnitConv(69).mult = 0.00341442;
   18607         794 :     ort->UnitConv(70).mult = 0.0002843333;
   18608         794 :     ort->UnitConv(71).mult = 0.001547673;
   18609         794 :     ort->UnitConv(72).mult = 0.001547673;
   18610         794 :     ort->UnitConv(73).mult = 1.8987;
   18611         794 :     ort->UnitConv(74).mult = 0.316954237;
   18612         794 :     ort->UnitConv(75).mult = 0.000316954237;
   18613         794 :     ort->UnitConv(76).mult = 0.176085687;
   18614         794 :     ort->UnitConv(77).mult = 0.176085687;
   18615         794 :     ort->UnitConv(78).mult = 1.0;
   18616         794 :     ort->UnitConv(79).mult = 1.0;
   18617         794 :     ort->UnitConv(80).mult = 1.8;
   18618         794 :     ort->UnitConv(81).mult = 0.42956;
   18619         794 :     ort->UnitConv(82).mult = 1.0 / 2118.6438;
   18620         794 :     ort->UnitConv(83).mult = 1.0 / 15852;
   18621         794 :     ort->UnitConv(84).mult = 1.0 / 10.764961;
   18622         794 :     ort->UnitConv(85).mult = 0.00000094845 * 1000000000;
   18623         794 :     ort->UnitConv(86).mult = 0.000000277778 * 1000000000;
   18624         794 :     ort->UnitConv(87).mult = 0.000000277778 * 1000000000;
   18625         794 :     ort->UnitConv(88).mult = 0.0000000094845 * 1000000000;
   18626         794 :     ort->UnitConv(89).mult = 0.00000000094845 * 1000000000;
   18627         794 :     ort->UnitConv(90).mult = 0.000277777777777778 * 1000000000;
   18628         794 :     ort->UnitConv(91).mult = 0.0000000789847 * 1000000000;
   18629         794 :     ort->UnitConv(92).mult = 0.277777777777778 / 10.764961;
   18630         794 :     ort->UnitConv(93).mult = 0.94708628903179 / 10.764961;
   18631         794 :     ort->UnitConv(94).mult = 0.94708628903179 / 10.764961;
   18632         794 :     ort->UnitConv(95).mult = 0.27777777777778;
   18633         794 :     ort->UnitConv(96).mult = 1.0;
   18634         794 :     ort->UnitConv(97).mult = 1.0;
   18635         794 :     ort->UnitConv(98).mult = 1.8987;
   18636         794 :     ort->UnitConv(99).mult = 1.0;
   18637         794 :     ort->UnitConv(100).mult = 1.0;
   18638         794 :     ort->UnitConv(101).mult = 1.0;
   18639         794 :     ort->UnitConv(102).mult = 1.0;
   18640         794 :     ort->UnitConv(103).mult = 1.0;
   18641         794 :     ort->UnitConv(104).mult = 1.0;
   18642         794 :     ort->UnitConv(105).mult = 1.0;
   18643         794 :     ort->UnitConv(106).mult = 1.0;
   18644         794 :     ort->UnitConv(107).mult = 1.0;
   18645         794 :     ort->UnitConv(108).mult = 0.000238845896627;
   18646         794 :     ort->UnitConv(109).mult = 2.2046;
   18647         794 :     ort->UnitConv(110).mult = 1.0;
   18648         794 :     ort->UnitConv(111).mult = 1.0;
   18649         794 :     ort->UnitConv(112).mult = 1.0;
   18650         794 :     ort->UnitConv(113).mult = 0.737562149277;
   18651         794 :     ort->UnitConv(114).mult = 1.0;
   18652         794 :     ort->UnitConv(115).mult = 0.09290304;
   18653         794 :     ort->UnitConv(116).mult = 0.03937;
   18654         794 :     ort->UnitConv(117).mult = 0.003281;
   18655         794 :     ort->UnitConv(118).mult = 1.8;
   18656             : 
   18657         794 :     ort->UnitConv(2).offset = 32.0;
   18658         794 :     ort->UnitConv(11).offset = 32.0;
   18659         794 :     ort->UnitConv(25).offset = 7.6736;
   18660         794 :     ort->UnitConv(81).offset = 7.6736; // 80 is KJ/KG -- should this be multiplied by 1000?
   18661             : 
   18662         794 :     ort->UnitConv(20).hint = "ELEC";
   18663         794 :     ort->UnitConv(21).hint = "GAS";
   18664         794 :     ort->UnitConv(24).hint = "COOL";
   18665         794 :     ort->UnitConv(38).hint = "WATER";
   18666         794 :     ort->UnitConv(49).hint = "WATER";
   18667         794 :     ort->UnitConv(52).hint = "WATER";
   18668         794 :     ort->UnitConv(67).hint = "ELEC";
   18669         794 :     ort->UnitConv(70).hint = "COOL";
   18670         794 :     ort->UnitConv(79).hint = "SI";
   18671         794 :     ort->UnitConv(83).hint = "WATER";
   18672         794 :     ort->UnitConv(86).hint = "CONSUMP";
   18673         794 :     ort->UnitConv(87).hint = "ELEC";
   18674         794 :     ort->UnitConv(88).hint = "GAS";
   18675         794 :     ort->UnitConv(91).hint = "COOL";
   18676         794 :     ort->UnitConv(92).hint = "ELEC";
   18677         794 :     ort->UnitConv(93).hint = "GAS";
   18678         794 :     ort->UnitConv(94).hint = "ADDITIONAL";
   18679             : 
   18680         794 :     ort->UnitConv(19).several = true;
   18681         794 :     ort->UnitConv(20).several = true;
   18682         794 :     ort->UnitConv(21).several = true;
   18683         794 :     ort->UnitConv(22).several = true;
   18684         794 :     ort->UnitConv(23).several = true;
   18685         794 :     ort->UnitConv(24).several = true;
   18686         794 :     ort->UnitConv(38).several = true;
   18687         794 :     ort->UnitConv(39).several = true;
   18688         794 :     ort->UnitConv(42).several = true;
   18689         794 :     ort->UnitConv(43).several = true;
   18690         794 :     ort->UnitConv(44).several = true;
   18691         794 :     ort->UnitConv(45).several = true;
   18692         794 :     ort->UnitConv(48).several = true;
   18693         794 :     ort->UnitConv(49).several = true;
   18694         794 :     ort->UnitConv(51).several = true;
   18695         794 :     ort->UnitConv(52).several = true;
   18696         794 :     ort->UnitConv(54).several = true;
   18697         794 :     ort->UnitConv(55).several = true;
   18698         794 :     ort->UnitConv(56).several = true;
   18699         794 :     ort->UnitConv(57).several = true;
   18700         794 :     ort->UnitConv(58).several = true;
   18701         794 :     ort->UnitConv(59).several = true;
   18702         794 :     ort->UnitConv(60).several = true;
   18703         794 :     ort->UnitConv(61).several = true;
   18704         794 :     ort->UnitConv(62).several = true;
   18705         794 :     ort->UnitConv(63).several = true;
   18706         794 :     ort->UnitConv(66).several = true;
   18707         794 :     ort->UnitConv(67).several = true;
   18708         794 :     ort->UnitConv(68).several = true;
   18709         794 :     ort->UnitConv(69).several = true;
   18710         794 :     ort->UnitConv(70).several = true;
   18711         794 :     ort->UnitConv(74).several = true;
   18712         794 :     ort->UnitConv(75).several = true;
   18713         794 :     ort->UnitConv(78).several = true;
   18714         794 :     ort->UnitConv(79).several = true;
   18715         794 :     ort->UnitConv(82).several = true;
   18716         794 :     ort->UnitConv(83).several = true;
   18717         794 :     ort->UnitConv(85).several = true;
   18718         794 :     ort->UnitConv(86).several = true;
   18719         794 :     ort->UnitConv(87).several = true;
   18720         794 :     ort->UnitConv(88).several = true;
   18721         794 :     ort->UnitConv(89).several = true;
   18722         794 :     ort->UnitConv(90).several = true;
   18723         794 :     ort->UnitConv(91).several = true;
   18724         794 :     ort->UnitConv(92).several = true;
   18725         794 :     ort->UnitConv(93).several = true;
   18726         794 :     ort->UnitConv(94).several = true;
   18727         794 :     ort->UnitConv(95).several = true;
   18728         794 :     ort->UnitConv(116).several = true;
   18729         794 :     ort->UnitConv(117).several = true;
   18730         794 : }
   18731             : 
   18732       28556 : std::string GetUnitSubString(std::string const &inString) // Input String
   18733             : {
   18734             :     // SUBROUTINE INFORMATION:
   18735             :     //       AUTHOR         Jason Glazer
   18736             :     //       DATE WRITTEN   February 2013
   18737             :     //       MODIFIED       na
   18738             :     //       RE-ENGINEERED  na
   18739             : 
   18740             :     // PURPOSE OF THIS SUBROUTINE:
   18741             :     //   return the substring contained in brackets []
   18742             :     //   that contains the units.
   18743             : 
   18744             :     // METHODOLOGY EMPLOYED:
   18745             :     //   na
   18746             : 
   18747             :     // Return value
   18748       28556 :     std::string outUnit; // Result String
   18749             : 
   18750             :     // Locals
   18751             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   18752             : 
   18753             :     // SUBROUTINE PARAMETER DEFINITIONS:
   18754             :     // na
   18755             : 
   18756             :     // INTERFACE BLOCK SPECIFICATIONS:
   18757             :     // na
   18758             : 
   18759             :     // DERIVED TYPE DEFINITIONS:
   18760             :     // na
   18761             : 
   18762             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   18763             : 
   18764             :     // check if string has brackets or parentheses
   18765       28556 :     std::string::size_type const posLBrac = index(inString, '['); // left bracket
   18766       28556 :     std::string::size_type const posRBrac = index(inString, ']'); // right bracket
   18767             :     // extract the substring with the units
   18768       28556 :     if ((posLBrac != std::string::npos) && (posRBrac != std::string::npos) && (posRBrac - posLBrac >= 1)) {
   18769        8354 :         outUnit = inString.substr(posLBrac + 1, posRBrac - posLBrac - 1);
   18770             :     }
   18771       28556 :     return outUnit;
   18772           0 : }
   18773             : 
   18774       15596 : void LookupSItoIP(EnergyPlusData &state, std::string const &stringInWithSI, int &unitConvIndex, std::string &stringOutWithIP)
   18775             : {
   18776             :     // SUBROUTINE INFORMATION:
   18777             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   18778             :     //    DATE WRITTEN   February 12, 2009
   18779             : 
   18780             :     // PURPOSE OF THIS SUBROUTINE:
   18781             :     //   The input string to this subroutine can either contain
   18782             :     //   a unit that should be looked up or it can contain
   18783             :     //   but the unit and other text (such as the column heading)
   18784             :     //   that includes a hint for when the unit may have multiple
   18785             :     //   possible conversions. If the input string includes
   18786             :     //   just the unit it does not have either brackets or
   18787             :     //   parenthesis. If the string includes text with a possible
   18788             :     //   hint the units themselves will be in either brackets
   18789             :     //   or parentheses. The index to the unitConv array is returned
   18790             :     //   which can be used with the convertIP function. Also the
   18791             :     //   string with the IP units substituted is returned.
   18792             : 
   18793       15596 :     std::string unitSIOnly;
   18794             :     int modeInString;
   18795       15596 :     int constexpr misBrac(1);
   18796       15596 :     int constexpr misParen(2);
   18797       15596 :     int constexpr misBrce(3);
   18798       15596 :     int constexpr misNoHint(4);
   18799       15596 :     std::string const stringInUpper(Util::makeUPPER(stringInWithSI));
   18800       15596 :     auto &ort = state.dataOutRptTab;
   18801             : 
   18802       15596 :     stringOutWithIP = "";
   18803             :     // check if string has brackets or parentheses
   18804       15596 :     std::string::size_type posLBrac = index(stringInUpper, '[');  // left bracket
   18805       15596 :     std::string::size_type posRBrac = index(stringInUpper, ']');  // right bracket
   18806       15596 :     std::string::size_type posLParen = index(stringInUpper, '('); // left parenthesis
   18807       15596 :     std::string::size_type posRParen = index(stringInUpper, ')'); // right parenthesis
   18808       15596 :     std::string::size_type posLBrce = index(stringInUpper, '{');  // left brace
   18809       15596 :     std::string::size_type posRBrce = index(stringInUpper, '}');  // right brace
   18810       15596 :     bool noBrackets = true;
   18811             :     // extract the substring with the units
   18812       15596 :     if ((posLBrac != std::string::npos) && (posRBrac != std::string::npos) && (posRBrac - posLBrac >= 1)) {
   18813        7222 :         unitSIOnly = stringInUpper.substr(posLBrac + 1, posRBrac - posLBrac - 1);
   18814        7222 :         modeInString = misBrac;
   18815        7222 :         noBrackets = false;
   18816        8374 :     } else if ((posLBrce != std::string::npos) && (posRBrce != std::string::npos) && (posRBrce - posLBrce >= 1)) {
   18817        2617 :         unitSIOnly = stringInUpper.substr(posLBrce + 1, posRBrce - posLBrce - 1);
   18818        2617 :         modeInString = misBrce;
   18819        5757 :     } else if ((posLParen != std::string::npos) && (posRParen != std::string::npos) && (posRParen - posLParen >= 1)) {
   18820         180 :         unitSIOnly = stringInUpper.substr(posLParen + 1, posRParen - posLParen - 1);
   18821         180 :         modeInString = misParen;
   18822             :     } else {
   18823        5577 :         unitSIOnly = stringInUpper;
   18824        5577 :         modeInString = misNoHint;
   18825             :     }
   18826       15596 :     unitSIOnly = stripped(unitSIOnly);
   18827       15596 :     int defaultConv = 0;
   18828       15596 :     int foundConv = 0;
   18829       15596 :     int firstOfSeveral = 0;
   18830     1493516 :     for (int iUnit = 1; iUnit <= ort->UnitConvSize; ++iUnit) {
   18831     1482643 :         if (Util::SameString(ort->UnitConv(iUnit).siName, unitSIOnly)) {
   18832       21479 :             if (ort->UnitConv(iUnit).several) {
   18833       17362 :                 if (firstOfSeveral == 0) firstOfSeveral = iUnit;
   18834       17362 :                 if (ort->UnitConv(iUnit).is_default) defaultConv = iUnit;
   18835             :                 // look for the hint string
   18836       17362 :                 if (len(ort->UnitConv(iUnit).hint) > 0) {
   18837        7384 :                     if (has(stringInUpper, ort->UnitConv(iUnit).hint)) {
   18838         606 :                         foundConv = iUnit;
   18839         606 :                         break;
   18840             :                     }
   18841             :                 }
   18842             :             } else { // not several possibilities so don't bother with rest of array
   18843        4117 :                 foundConv = iUnit;
   18844        4117 :                 break;
   18845             :             }
   18846             :         }
   18847             :     }
   18848             :     // if it is found set the selected value to what was found. if not found,
   18849             :     // directly set it to the default and if no default set it to the first item
   18850             :     // in group.  Return zero if not found.
   18851       15596 :     int selectedConv(0);
   18852       15596 :     if (foundConv > 0) {
   18853        4723 :         selectedConv = foundConv;
   18854             :     } else {
   18855             :         // not found - see if in a group it should be default or first.
   18856       10873 :         if (firstOfSeveral == 0) {
   18857        6553 :             selectedConv = 0;
   18858             :         } else {
   18859        4320 :             if (defaultConv != 0) {
   18860           0 :                 selectedConv = defaultConv;
   18861             :             } else {
   18862        4320 :                 selectedConv = firstOfSeveral;
   18863             :             }
   18864             :         }
   18865             :     }
   18866             :     // if one was selected substitute the units into the output string
   18867       15596 :     if (selectedConv > 0) {
   18868        9043 :         if (modeInString == misBrac) {
   18869        7200 :             stringOutWithIP = stringInWithSI.substr(0, posLBrac + 1) + ort->UnitConv(selectedConv).ipName + stringInWithSI.substr(posRBrac);
   18870        1843 :         } else if (modeInString == misParen) {
   18871         143 :             stringOutWithIP = stringInWithSI.substr(0, posLParen + 1) + ort->UnitConv(selectedConv).ipName + stringInWithSI.substr(posRParen);
   18872        1700 :         } else if (modeInString == misBrce) {
   18873        1700 :             stringOutWithIP = stringInWithSI.substr(0, posLBrce + 1) + ort->UnitConv(selectedConv).ipName + stringInWithSI.substr(posRBrce);
   18874           0 :         } else if (modeInString == misNoHint) {
   18875           0 :             stringOutWithIP = ort->UnitConv(selectedConv).ipName;
   18876             :         }
   18877             :     } else {
   18878             :         // if no conversion just output the input string
   18879        6553 :         stringOutWithIP = stringInWithSI;
   18880             :     }
   18881             : 
   18882       15596 :     unitConvIndex = selectedConv;
   18883             : 
   18884             :     // Add warning if units not found.
   18885       15596 :     if (unitConvIndex == 0 && !noBrackets) {
   18886          22 :         ShowWarningError(state, format("Unable to find a unit conversion from {} into IP units", stringInWithSI));
   18887          22 :         ShowContinueError(state, "Applying default conversion factor of 1.0");
   18888             :     }
   18889       15596 : }
   18890             : 
   18891        8535 : void LookupJtokWH(EnergyPlusData &state, std::string const &stringInWithJ, int &unitConvIndex, std::string &stringOutWithKWH)
   18892             : {
   18893             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   18894             :     //    DATE WRITTEN   April 15, 2016
   18895             : 
   18896             :     // For the given unit expressed in J find the unit conversion
   18897             :     // using kWh instead. This is used when unitsStyle == unitsStyleJtoKWH
   18898             :     // return zero if no unit conversion should be done
   18899             : 
   18900        8535 :     stringOutWithKWH = stringInWithJ;
   18901        8535 :     std::string::size_type gjPos = stringOutWithKWH.find("[GJ]");
   18902        8535 :     std::string::size_type mjm2Pos = stringOutWithKWH.find("[MJ/m2]");
   18903        8535 :     if (gjPos != std::string::npos) {
   18904         240 :         stringOutWithKWH.replace(gjPos, 4, "[kWh]");
   18905         240 :         unitConvIndex = getSpecificUnitIndex(state, "GJ", "kWh");
   18906        8295 :     } else if (mjm2Pos != std::string::npos) {
   18907          18 :         stringOutWithKWH.replace(mjm2Pos, 7, "[kWh/m2]");
   18908          18 :         unitConvIndex = getSpecificUnitIndex(state, "MJ/m2", "kWh/m2");
   18909             :     } else {
   18910        8277 :         unitConvIndex = 0;
   18911             :     }
   18912        8535 : }
   18913             : 
   18914       38783 : Real64 ConvertIP(EnergyPlusData &state, int const unitConvIndex, Real64 const SIvalue)
   18915             : {
   18916             :     // SUBROUTINE INFORMATION:
   18917             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   18918             :     //    DATE WRITTEN   February 13, 2009
   18919             :     //    MODIFIED       September 2012
   18920             :     //    RE-ENGINEERED  na
   18921             : 
   18922             :     // PURPOSE OF THIS SUBROUTINE:
   18923             :     //   Apply the selected unit conversion to the input value
   18924             :     //   expressed in SI units to result in IP units.
   18925             :     //   If zero is provided as unit index, return the original
   18926             :     //   value (no conversion)
   18927             : 
   18928             :     // METHODOLOGY EMPLOYED:
   18929             : 
   18930             :     // REFERENCES:
   18931             :     //    na
   18932             : 
   18933             :     // USE STATEMENTS:
   18934             : 
   18935             :     // Return value
   18936             :     Real64 ConvertIP;
   18937             : 
   18938             :     // Locals
   18939             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   18940             : 
   18941             :     // SUBROUTINE PARAMETER DEFINITIONS:
   18942             :     //    na
   18943             : 
   18944             :     // INTERFACE BLOCK SPECIFICATIONS:
   18945             :     //    na
   18946             : 
   18947             :     // DERIVED TYPE DEFINITIONS:
   18948             :     //    na
   18949             : 
   18950             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   18951             :     //    na
   18952             : 
   18953       38783 :     auto &ort = state.dataOutRptTab;
   18954             : 
   18955       38783 :     if (unitConvIndex == 0 || SIvalue == -999.0 || SIvalue == -99999.0) { // don't convert unknown data to IP
   18956        3122 :         ConvertIP = SIvalue;
   18957       35661 :     } else if ((unitConvIndex > 0) && (unitConvIndex <= ort->UnitConvSize)) {
   18958       35661 :         ConvertIP = (SIvalue * ort->UnitConv(unitConvIndex).mult) + ort->UnitConv(unitConvIndex).offset;
   18959             :     } else {
   18960           0 :         ConvertIP = SIvalue;
   18961             :     }
   18962       38783 :     return ConvertIP;
   18963             : }
   18964             : 
   18965          88 : Real64 ConvertIPdelta(EnergyPlusData &state, int const unitConvIndex, Real64 const SIvalue)
   18966             : {
   18967             :     // SUBROUTINE INFORMATION:
   18968             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   18969             :     //    DATE WRITTEN   February 18, 2009
   18970             :     //    MODIFIED       na
   18971             :     //    RE-ENGINEERED  na
   18972             : 
   18973             :     // PURPOSE OF THIS SUBROUTINE:
   18974             :     //   Apply the selected unit conversion to the input value
   18975             :     //   expressed in SI units to result in IP units. This routine
   18976             :     //   only uses the mulitplier and NOT the offset and is appropriate
   18977             :     //   when the number being converted is a difference or delta
   18978             :     //   between values (such as a temperature difference).
   18979             : 
   18980             :     // METHODOLOGY EMPLOYED:
   18981             : 
   18982             :     // REFERENCES:
   18983             :     //    na
   18984             : 
   18985             :     // USE STATEMENTS:
   18986             : 
   18987             :     // Return value
   18988             :     Real64 ConvertIPdelta;
   18989             : 
   18990             :     // Locals
   18991             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   18992             : 
   18993             :     // SUBROUTINE PARAMETER DEFINITIONS:
   18994             :     //    na
   18995             : 
   18996             :     // INTERFACE BLOCK SPECIFICATIONS:
   18997             :     //    na
   18998             : 
   18999             :     // DERIVED TYPE DEFINITIONS:
   19000             :     //    na
   19001             : 
   19002             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19003             :     //    na
   19004             : 
   19005          88 :     auto &ort = state.dataOutRptTab;
   19006             : 
   19007          88 :     if (unitConvIndex == 0) {
   19008           0 :         ConvertIPdelta = SIvalue;
   19009          88 :     } else if ((unitConvIndex > 0) && (unitConvIndex <= ort->UnitConvSize)) {
   19010          88 :         ConvertIPdelta = SIvalue * ort->UnitConv(unitConvIndex).mult;
   19011             :     } else {
   19012           0 :         ConvertIPdelta = SIvalue;
   19013             :     }
   19014          88 :     return ConvertIPdelta;
   19015             : }
   19016             : 
   19017           0 : void GetUnitConversion(EnergyPlusData &state, int const unitConvIndex, Real64 &multiplier, Real64 &offset, std::string &IPunit)
   19018             : {
   19019             :     // SUBROUTINE INFORMATION:
   19020             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19021             :     //    DATE WRITTEN   February 13, 2009
   19022             :     //    MODIFIED       na
   19023             :     //    RE-ENGINEERED  na
   19024             : 
   19025             :     // PURPOSE OF THIS SUBROUTINE:
   19026             :     //   Return of the multiplier and adder for the given
   19027             :     //   SI to IP unit conversion.
   19028             :     //     SI = (IP * multipier) + offset
   19029             :     //  This function could be replaced by referencing the
   19030             :     //  array directly but does include some checking of the
   19031             :     //  bounds of the array.
   19032             : 
   19033             :     // METHODOLOGY EMPLOYED:
   19034             : 
   19035             :     // REFERENCES:
   19036             :     //    na
   19037             : 
   19038             :     // USE STATEMENTS:
   19039             : 
   19040             :     // Locals
   19041             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19042             : 
   19043             :     // SUBROUTINE PARAMETER DEFINITIONS:
   19044             :     //    na
   19045             : 
   19046             :     // INTERFACE BLOCK SPECIFICATIONS:
   19047             :     //    na
   19048             : 
   19049             :     // DERIVED TYPE DEFINITIONS:
   19050             :     //    na
   19051             : 
   19052             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19053             :     //    na
   19054             : 
   19055           0 :     auto &ort = state.dataOutRptTab;
   19056             : 
   19057           0 :     if ((unitConvIndex > 0) && (unitConvIndex <= ort->UnitConvSize)) {
   19058           0 :         multiplier = ort->UnitConv(unitConvIndex).mult;
   19059           0 :         offset = ort->UnitConv(unitConvIndex).offset;
   19060           0 :         IPunit = ort->UnitConv(unitConvIndex).ipName;
   19061             :     } else {
   19062           0 :         multiplier = 1.0;
   19063           0 :         offset = 0.0;
   19064           0 :         IPunit = "";
   19065             :     }
   19066           0 : }
   19067             : 
   19068          99 : Real64 getSpecificUnitMultiplier(EnergyPlusData &state, std::string const &SIunit, std::string const &IPunit)
   19069             : {
   19070             :     // SUBROUTINE INFORMATION:
   19071             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19072             :     //    DATE WRITTEN   February 13, 2009
   19073             :     //    MODIFIED       na
   19074             :     //    RE-ENGINEERED  na
   19075             : 
   19076             :     // PURPOSE OF THIS SUBROUTINE:
   19077             :     //   Return of the multiplier for a specific
   19078             :     //   SI to IP unit conversion. No offset is provided so
   19079             :     //   it cannot be used to convert units such as temperatures
   19080             :     //   that include an offset.
   19081             :     //     SI = (IP * multipier) + offset
   19082             :     //   Unlike LookupSItoIP, this function does not expect more
   19083             :     //   the units in the two input parameters. No hints or
   19084             :     //   defaults are used since both the SI and IP units are
   19085             :     //   input by the user.
   19086             : 
   19087             :     // METHODOLOGY EMPLOYED:
   19088             : 
   19089             :     // REFERENCES:
   19090             :     //    na
   19091             : 
   19092             :     // USE STATEMENTS:
   19093             : 
   19094             :     // Return value
   19095             :     Real64 getSpecificUnitMultiplier;
   19096             : 
   19097             :     // Locals
   19098             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19099             : 
   19100             :     // SUBROUTINE PARAMETER DEFINITIONS:
   19101             :     //    na
   19102             : 
   19103             :     // INTERFACE BLOCK SPECIFICATIONS:
   19104             :     //    na
   19105             : 
   19106             :     // DERIVED TYPE DEFINITIONS:
   19107             :     //    na
   19108             : 
   19109             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19110          99 :     auto &ort = state.dataOutRptTab;
   19111             : 
   19112        5533 :     for (state.dataOutRptTab->iUnitGsum = 1; state.dataOutRptTab->iUnitGsum <= ort->UnitConvSize; ++state.dataOutRptTab->iUnitGsum) {
   19113        5533 :         if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsum).siName, SIunit)) {
   19114         154 :             if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsum).ipName, IPunit)) {
   19115          99 :                 state.dataOutRptTab->foundGsum = state.dataOutRptTab->iUnitGsum;
   19116          99 :                 break;
   19117             :             }
   19118             :         }
   19119             :     }
   19120          99 :     if (state.dataOutRptTab->foundGsum != 0) {
   19121          99 :         getSpecificUnitMultiplier = ort->UnitConv(state.dataOutRptTab->foundGsum).mult;
   19122             :     } else {
   19123           0 :         ShowWarningError(state, format("Unable to find a unit conversion from {} to {}", SIunit, IPunit));
   19124           0 :         ShowContinueError(state, "Applying default conversion factor of 1.0");
   19125           0 :         getSpecificUnitMultiplier = 1.0;
   19126             :     }
   19127          99 :     return getSpecificUnitMultiplier;
   19128             : }
   19129             : 
   19130          66 : Real64 getSpecificUnitDivider(EnergyPlusData &state, std::string const &SIunit, std::string const &IPunit)
   19131             : {
   19132             :     // SUBROUTINE INFORMATION:
   19133             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19134             :     //    DATE WRITTEN   February 13, 2009
   19135             :     //    MODIFIED       na
   19136             :     //    RE-ENGINEERED  na
   19137             : 
   19138             :     // PURPOSE OF THIS SUBROUTINE:
   19139             :     //   Returns the divider (1/multiplier) for a specific
   19140             :     //   SI to IP unit conversion. No offset is provided so
   19141             :     //   it cannot be used to convert units such as temperatures
   19142             :     //   that include an offset.
   19143             :     //     SI = (IP * multipier) + offset
   19144             :     //   Unlike LookupSItoIP, this function does not expect more
   19145             :     //   the units in the two input parameters. No hints or
   19146             :     //   defaults are used since both the SI and IP units are
   19147             :     //   input by the user.
   19148             : 
   19149             :     // METHODOLOGY EMPLOYED:
   19150             : 
   19151             :     // REFERENCES:
   19152             :     //    na
   19153             : 
   19154             :     // USE STATEMENTS:
   19155             : 
   19156             :     // Return value
   19157             :     Real64 getSpecificUnitDivider;
   19158             : 
   19159             :     // Locals
   19160             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19161             : 
   19162             :     // SUBROUTINE PARAMETER DEFINITIONS:
   19163             :     //    na
   19164             : 
   19165             :     // INTERFACE BLOCK SPECIFICATIONS:
   19166             :     //    na
   19167             : 
   19168             :     // DERIVED TYPE DEFINITIONS:
   19169             :     //    na
   19170             : 
   19171             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19172             :     Real64 mult;
   19173             : 
   19174          66 :     mult = getSpecificUnitMultiplier(state, SIunit, IPunit);
   19175          66 :     if (mult != 0) {
   19176          66 :         getSpecificUnitDivider = 1 / mult;
   19177             :     } else {
   19178           0 :         ShowWarningError(state, format("Unable to find a unit conversion from {} to {}", SIunit, IPunit));
   19179           0 :         ShowContinueError(state, "Applying default conversion factor of 1.0");
   19180           0 :         getSpecificUnitDivider = 1.0;
   19181             :     }
   19182          66 :     return getSpecificUnitDivider;
   19183             : }
   19184             : 
   19185         258 : Real64 getSpecificUnitIndex(EnergyPlusData &state, std::string const &SIunit, std::string const &IPunit)
   19186             : {
   19187             :     // SUBROUTINE INFORMATION:
   19188             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19189             :     //    DATE WRITTEN   September 21, 2012
   19190             :     //    MODIFIED       na
   19191             :     //    RE-ENGINEERED  na
   19192             : 
   19193             :     // PURPOSE OF THIS SUBROUTINE:
   19194             :     //   Return of the unit conversion index for a specific
   19195             :     //   SI to IP unit conversion.
   19196             :     //   Unlike LookupSItoIP, this function does not expect more
   19197             :     //   the units in the two input parameters. No hints or
   19198             :     //   defaults are used since both the SI and IP units are
   19199             :     //   input by the user.
   19200             : 
   19201             :     // METHODOLOGY EMPLOYED:
   19202             : 
   19203             :     // REFERENCES:
   19204             :     //    na
   19205             : 
   19206             :     // USE STATEMENTS:
   19207             : 
   19208             :     // Return value
   19209             :     Real64 getSpecificUnitIndex;
   19210             : 
   19211             :     // Locals
   19212             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19213             : 
   19214             :     // SUBROUTINE PARAMETER DEFINITIONS:
   19215             :     //    na
   19216             : 
   19217             :     // INTERFACE BLOCK SPECIFICATIONS:
   19218             :     //    na
   19219             : 
   19220             :     // DERIVED TYPE DEFINITIONS:
   19221             :     //    na
   19222             : 
   19223             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19224         258 :     auto &ort = state.dataOutRptTab;
   19225             : 
   19226       22350 :     for (state.dataOutRptTab->iUnitGsui = 1; state.dataOutRptTab->iUnitGsui <= ort->UnitConvSize; ++state.dataOutRptTab->iUnitGsui) {
   19227       22350 :         if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsui).siName, SIunit)) {
   19228         552 :             if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsui).ipName, IPunit)) {
   19229         258 :                 state.dataOutRptTab->foundGsui = state.dataOutRptTab->iUnitGsui;
   19230         258 :                 break;
   19231             :             }
   19232             :         }
   19233             :     }
   19234         258 :     if (state.dataOutRptTab->foundGsui != 0) {
   19235         258 :         getSpecificUnitIndex = state.dataOutRptTab->foundGsui;
   19236             :     } else {
   19237           0 :         getSpecificUnitIndex = 0.0;
   19238             :     }
   19239         258 :     return getSpecificUnitIndex;
   19240             : }
   19241             : 
   19242             : } // namespace EnergyPlus::OutputReportTabular

Generated by: LCOV version 1.14