LCOV - code coverage report
Current view: top level - EnergyPlus - SimulationManager.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 1164 1419 82.0 %
Date: 2024-08-24 18:31:18 Functions: 15 17 88.2 %

          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             : // FMI-Related Headers
      49             : extern "C" {
      50             : #include <FMI/main.h>
      51             : }
      52             : 
      53             : // C++ Headers
      54             : #include <memory>
      55             : #include <string>
      56             : 
      57             : // ObjexxFCL Headers
      58             : #include <ObjexxFCL/Array.functions.hh>
      59             : #include <ObjexxFCL/Array1D.hh>
      60             : #include <ObjexxFCL/Fmath.hh>
      61             : #include <ObjexxFCL/environment.hh>
      62             : #include <ObjexxFCL/string.functions.hh>
      63             : 
      64             : // EnergyPlus Headers
      65             : #include <EnergyPlus/BranchInputManager.hh>
      66             : #include <EnergyPlus/BranchNodeConnections.hh>
      67             : #include <EnergyPlus/CostEstimateManager.hh>
      68             : #include <EnergyPlus/CurveManager.hh>
      69             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      70             : #include <EnergyPlus/DataAirLoop.hh>
      71             : #include <EnergyPlus/DataBranchNodeConnections.hh>
      72             : #include <EnergyPlus/DataConvergParams.hh>
      73             : #include <EnergyPlus/DataErrorTracking.hh>
      74             : #include <EnergyPlus/DataGlobalConstants.hh>
      75             : #include <EnergyPlus/DataHVACGlobals.hh>
      76             : #include <EnergyPlus/DataHeatBalFanSys.hh>
      77             : #include <EnergyPlus/DataHeatBalance.hh>
      78             : #include <EnergyPlus/DataIPShortCuts.hh>
      79             : #include <EnergyPlus/DataLoopNode.hh>
      80             : #include <EnergyPlus/DataOutputs.hh>
      81             : #include <EnergyPlus/DataReportingFlags.hh>
      82             : #include <EnergyPlus/DataRuntimeLanguage.hh>
      83             : #include <EnergyPlus/DataStringGlobals.hh>
      84             : #include <EnergyPlus/DataSurfaces.hh>
      85             : #include <EnergyPlus/DataSystemVariables.hh>
      86             : #include <EnergyPlus/DataZoneEquipment.hh>
      87             : #include <EnergyPlus/DemandManager.hh>
      88             : #include <EnergyPlus/DisplayRoutines.hh>
      89             : #include <EnergyPlus/DualDuct.hh>
      90             : #include <EnergyPlus/EMSManager.hh>
      91             : #include <EnergyPlus/EconomicLifeCycleCost.hh>
      92             : #include <EnergyPlus/EconomicTariff.hh>
      93             : #include <EnergyPlus/ElectricPowerServiceManager.hh>
      94             : #include <EnergyPlus/ExteriorEnergyUse.hh>
      95             : #include <EnergyPlus/ExternalInterface.hh>
      96             : #include <EnergyPlus/FaultsManager.hh>
      97             : #include <EnergyPlus/FileSystem.hh>
      98             : #include <EnergyPlus/FluidProperties.hh>
      99             : #include <EnergyPlus/GeneralRoutines.hh>
     100             : #include <EnergyPlus/HVACControllers.hh>
     101             : #include <EnergyPlus/HVACManager.hh>
     102             : #include <EnergyPlus/HVACSizingSimulationManager.hh>
     103             : #include <EnergyPlus/HeatBalanceAirManager.hh>
     104             : #include <EnergyPlus/HeatBalanceIntRadExchange.hh>
     105             : #include <EnergyPlus/HeatBalanceManager.hh>
     106             : #include <EnergyPlus/HeatBalanceSurfaceManager.hh>
     107             : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
     108             : #include <EnergyPlus/MixedAir.hh>
     109             : #include <EnergyPlus/NodeInputManager.hh>
     110             : #include <EnergyPlus/OutAirNodeManager.hh>
     111             : #include <EnergyPlus/OutputProcessor.hh>
     112             : #include <EnergyPlus/OutputReportPredefined.hh>
     113             : #include <EnergyPlus/OutputReportTabular.hh>
     114             : #include <EnergyPlus/OutputReports.hh>
     115             : #include <EnergyPlus/Plant/PlantManager.hh>
     116             : #include <EnergyPlus/PlantPipingSystemsManager.hh>
     117             : #include <EnergyPlus/PluginManager.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/SetPointManager.hh>
     124             : #include <EnergyPlus/SimulationManager.hh>
     125             : #include <EnergyPlus/SizingManager.hh>
     126             : #include <EnergyPlus/SolarShading.hh>
     127             : #include <EnergyPlus/SurfaceGeometry.hh>
     128             : #include <EnergyPlus/SystemReports.hh>
     129             : #include <EnergyPlus/UtilityRoutines.hh>
     130             : #include <EnergyPlus/WeatherManager.hh>
     131             : #include <EnergyPlus/ZoneContaminantPredictorCorrector.hh>
     132             : #include <EnergyPlus/ZoneEquipmentManager.hh>
     133             : #include <EnergyPlus/ZoneTempPredictorCorrector.hh>
     134             : #include <EnergyPlus/api/datatransfer.h>
     135             : 
     136             : namespace EnergyPlus {
     137             : namespace SimulationManager {
     138             : 
     139             :     // MODULE INFORMATION:
     140             :     //       AUTHOR         Rick Strand
     141             :     //       DATE WRITTEN   January 1997
     142             : 
     143             :     // PURPOSE OF THIS MODULE:
     144             :     // This module contains the main driver routine which manages the major
     145             :     // control loops of the EnergyPlus simulation.  This module is also
     146             :     // responsible for setting the global environment flags for these
     147             :     // loops.
     148             : 
     149             :     // METHODOLOGY EMPLOYED:
     150             :     // This module was constructed from the remnants of (I)BLAST routines
     151             :     // SIMBLD (Simulate Building), SIMZG (Simulate Zone Group), and SIMZGD
     152             :     // (Simulate Zone Group for a Day).
     153             : 
     154             :     // REFERENCES:
     155             :     // (I)BLAST legacy code, internal Reverse Engineering documentation,
     156             :     // and internal Evolutionary Engineering documentation.
     157             : 
     158             :     // Using/Aliasing
     159             :     using namespace DataSizing;
     160             :     using namespace DataSystemVariables;
     161             :     using namespace HeatBalanceManager;
     162             :     using namespace ExternalInterface;
     163             : 
     164             :     // MODULE PARAMETER DEFINITIONS:
     165             : 
     166         796 :     void ManageSimulation(EnergyPlusData &state)
     167             :     {
     168             : 
     169             :         // SUBROUTINE INFORMATION:
     170             :         //       AUTHOR         Rick Strand
     171             :         //       DATE WRITTEN   January 1997
     172             : 
     173             :         // PURPOSE OF THIS SUBROUTINE:
     174             :         // This subroutine is the main driver of the simulation manager module.
     175             :         // It contains the main environment-time loops for the building
     176             :         // simulation.  This includes the environment loop, a day loop, an
     177             :         // hour loop, and a time step loop.
     178             : 
     179             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     180         796 :         bool ErrorsFound(false);
     181         796 :         bool TerminalError(false);
     182         796 :         bool oneTimeUnderwaterBoundaryCheck = true;
     183         796 :         bool AnyUnderwaterBoundaries = false;
     184             : 
     185         796 :         state.files.outputControl.getInput(state);
     186         796 :         state.dataResultsFramework->resultsFramework->setupOutputOptions(state);
     187             : 
     188         796 :         state.files.debug.ensure_open(state, "OpenOutputFiles", state.files.outputControl.dbg);
     189             : 
     190         796 :         if (!state.dataSQLiteProcedures->sqlite) {
     191         796 :             state.dataSQLiteProcedures->sqlite = EnergyPlus::CreateSQLiteDatabase(state);
     192             :         }
     193             : 
     194         796 :         if (state.dataSQLiteProcedures->sqlite) {
     195         123 :             state.dataSQLiteProcedures->sqlite->sqliteBegin();
     196         369 :             state.dataSQLiteProcedures->sqlite->createSQLiteSimulationsRecord(
     197         246 :                 1, state.dataStrGlobals->VerStringVar, state.dataStrGlobals->CurrentDateTime);
     198         123 :             state.dataSQLiteProcedures->sqlite->sqliteCommit();
     199             :         }
     200             : 
     201         796 :         PostIPProcessing(state);
     202             : 
     203         796 :         state.dataGlobal->BeginSimFlag = true;
     204         796 :         state.dataGlobal->DoOutputReporting = false;
     205         796 :         state.dataReportFlag->DisplayPerfSimulationFlag = false;
     206         796 :         state.dataReportFlag->DoWeatherInitReporting = false;
     207         796 :         state.dataSimulationManager->RunPeriodsInInput =
     208         796 :             (state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "RunPeriod") > 0 ||
     209         796 :              state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "RunPeriod:CustomRange") > 0 || state.dataSysVars->FullAnnualRun);
     210         796 :         state.dataErrTracking->AskForConnectionsReport = false; // set to false until sizing is finished
     211             : 
     212         796 :         state.init_state(state);
     213             : 
     214         796 :         CheckForMisMatchedEnvironmentSpecifications(state);
     215         796 :         CheckForRequestedReporting(state);
     216         796 :         OutputReportPredefined::SetPredefinedTables(state);
     217         796 :         SetPreConstructionInputParameters(state); // establish array bounds for constructions early
     218             : 
     219         796 :         OutputProcessor::SetupTimePointers(
     220         796 :             state, OutputProcessor::TimeStepType::Zone, state.dataGlobal->TimeStepZone); // Set up Time pointer for HB/Zone Simulation
     221         796 :         OutputProcessor::SetupTimePointers(state, OutputProcessor::TimeStepType::System, state.dataHVACGlobal->TimeStepSys);
     222             : 
     223         796 :         createFacilityElectricPowerServiceObject(state);
     224         796 :         createCoilSelectionReportObj(state);
     225             :         // read object information early in simulation
     226         796 :         isInputObjectUsed(state);
     227             : 
     228         796 :         BranchInputManager::ManageBranchInput(state); // just gets input and returns.
     229             : 
     230             :         // Create a new plugin manager which starts up the Python interpreter
     231         796 :         state.dataPluginManager->pluginManager = std::make_unique<EnergyPlus::PluginManagement::PluginManager>(state);
     232             : 
     233         796 :         state.dataGlobal->DoingSizing = true;
     234         796 :         SizingManager::ManageSizing(state);
     235             : 
     236         795 :         bool SimsDone = false;
     237         795 :         if (state.dataGlobal->DoDesDaySim || state.dataGlobal->DoWeathSim || state.dataGlobal->DoHVACSizingSimulation) {
     238         795 :             state.dataGlobal->DoOutputReporting = true;
     239             :         }
     240         795 :         state.dataGlobal->DoingSizing = false;
     241         795 :         state.dataHeatBal->doSpaceHeatBalance = state.dataHeatBal->doSpaceHeatBalanceSimulation;
     242             : 
     243        1221 :         if ((state.dataGlobal->DoZoneSizing || state.dataGlobal->DoSystemSizing || state.dataGlobal->DoPlantSizing) &&
     244         426 :             !(state.dataGlobal->DoDesDaySim || (state.dataGlobal->DoWeathSim && state.dataSimulationManager->RunPeriodsInInput))) {
     245           0 :             ShowWarningError(state,
     246             :                              "ManageSimulation: Input file has requested Sizing Calculations but no Simulations are requested (in SimulationControl "
     247             :                              "object). Succeeding warnings/errors may be confusing.");
     248             :         }
     249         795 :         bool Available = true; // an environment is available to process
     250             : 
     251         795 :         if (state.dataGlobal->DoPureLoadCalc) {
     252           0 :             state.dataGlobal->DoOutputReporting = true;
     253           0 :             Available = false;
     254           0 :             state.dataOutRptTab->WriteTabularFiles = true;
     255             :         }
     256             : 
     257         795 :         if (state.dataBranchInputManager->InvalidBranchDefinitions) {
     258           0 :             ShowFatalError(state, "Preceding error(s) in Branch Input cause termination.");
     259             :         }
     260             : 
     261         795 :         DisplayString(state, "Adjusting Air System Sizing");
     262         795 :         SizingManager::ManageSystemSizingAdjustments(state);
     263             : 
     264         795 :         DisplayString(state, "Adjusting Standard 62.1 Ventilation Sizing");
     265         795 :         SizingManager::ManageSystemVentilationAdjustments(state);
     266             : 
     267         795 :         DisplayString(state, "Initializing Simulation");
     268         795 :         state.dataGlobal->KickOffSimulation = true;
     269             : 
     270         795 :         Weather::ResetEnvironmentCounter(state);
     271         795 :         SetupSimulation(state, ErrorsFound);
     272             : 
     273         795 :         FaultsManager::CheckAndReadFaults(state);
     274             : 
     275         795 :         Curve::InitCurveReporting(state);
     276             : 
     277         795 :         state.dataErrTracking->AskForConnectionsReport = true; // set to true now that input processing and sizing is done.
     278         795 :         state.dataGlobal->KickOffSimulation = false;
     279         795 :         state.dataGlobal->WarmupFlag = false;
     280         795 :         state.dataReportFlag->DoWeatherInitReporting = true;
     281             : 
     282             :         //  Note:  All the inputs have been 'gotten' by the time we get here.
     283         795 :         bool ErrFound = false;
     284         795 :         if (state.dataGlobal->DoOutputReporting) {
     285         795 :             DisplayString(state, "Reporting Surfaces");
     286             : 
     287         795 :             ReportSurfaces(state);
     288             : 
     289         795 :             NodeInputManager::SetupNodeVarsForReporting(state);
     290         795 :             state.dataGlobal->MetersHaveBeenInitialized = true;
     291         795 :             Pollution::SetupPollutionMeterReporting(state);
     292         795 :             SystemReports::AllocateAndSetUpVentReports(state);
     293         795 :             if (state.dataPluginManager->pluginManager) {
     294         795 :                 EnergyPlus::PluginManagement::PluginManager::setupOutputVariables(state);
     295             :             }
     296         795 :             UpdateMeterReporting(state);
     297         795 :             Pollution::CheckPollutionMeterReporting(state);
     298         795 :             state.dataElectPwrSvcMgr->facilityElectricServiceObj->verifyCustomMetersElecPowerMgr(state);
     299         795 :             Pollution::SetupPollutionCalculations(state);
     300         795 :             DemandManager::InitDemandManagers(state);
     301         795 :             BranchInputManager::TestBranchIntegrity(state, ErrFound);
     302         795 :             if (ErrFound) TerminalError = true;
     303         795 :             TestAirPathIntegrity(state, ErrFound);
     304         795 :             if (ErrFound) TerminalError = true;
     305         795 :             NodeInputManager::CheckMarkedNodes(state, ErrFound);
     306         795 :             if (ErrFound) TerminalError = true;
     307         795 :             BranchNodeConnections::CheckNodeConnections(state, ErrFound);
     308         795 :             if (ErrFound) TerminalError = true;
     309         795 :             BranchNodeConnections::TestCompSetInletOutletNodes(state, ErrFound);
     310         795 :             if (ErrFound) TerminalError = true;
     311         795 :             MixedAir::CheckControllerLists(state, ErrFound);
     312         795 :             if (ErrFound) TerminalError = true;
     313             : 
     314         795 :             if (state.dataGlobal->DoDesDaySim || state.dataGlobal->DoWeathSim || state.dataGlobal->DoPureLoadCalc) {
     315         795 :                 ReportLoopConnections(state);
     316         795 :                 SystemReports::ReportAirLoopConnections(state);
     317         795 :                 ReportNodeConnections(state);
     318             :             }
     319         795 :             SystemReports::CreateEnergyReportStructure(state);
     320             :             bool anyEMSRan;
     321             :             // point to finish setup processing EMS, sensor ready now
     322         795 :             EMSManager::ManageEMS(state, EMSManager::EMSCallFrom::SetupSimulation, anyEMSRan, ObjexxFCL::Optional_int_const());
     323         795 :             ProduceRDDMDD(state);
     324             : 
     325         795 :             if (TerminalError) {
     326           0 :                 ShowFatalError(state, "Previous Conditions cause program termination.");
     327             :             }
     328             :         }
     329             : 
     330             :         // up until this point, output vars, meters, actuators, etc., may not have been registered; they are now
     331         795 :         state.dataPluginManager->fullyReady = true;
     332             : 
     333         795 :         if (state.dataSQLiteProcedures->sqlite) {
     334         123 :             state.dataSQLiteProcedures->sqlite->sqliteBegin();
     335         123 :             state.dataSQLiteProcedures->sqlite->updateSQLiteSimulationRecord(1, state.dataGlobal->NumOfTimeStepInHour);
     336         123 :             state.dataSQLiteProcedures->sqlite->sqliteCommit();
     337             :         }
     338             : 
     339         795 :         EconomicLifeCycleCost::GetInputForLifeCycleCost(state); // must be prior to WriteTabularReports -- do here before big simulation stuff.
     340             : 
     341             :         // check for variable latitude/location/etc
     342         795 :         Weather::ReadVariableLocationOrientation(state);
     343             : 
     344             :         // if user requested HVAC Sizing Simulation, call HVAC sizing simulation manager
     345         795 :         if (state.dataGlobal->DoHVACSizingSimulation) {
     346          12 :             ManageHVACSizingSimulation(state, ErrorsFound);
     347             :         }
     348             : 
     349         795 :         if (!state.dataGlobal->DoPureLoadCalc) {
     350         795 :             ShowMessage(state, "Beginning Simulation");
     351         795 :             DisplayString(state, "Beginning Primary Simulation");
     352             :         }
     353         795 :         Weather::ResetEnvironmentCounter(state);
     354             : 
     355         795 :         int EnvCount = 0;
     356         795 :         state.dataGlobal->WarmupFlag = true;
     357             : 
     358        3671 :         while (Available) {
     359        4465 :             if (state.dataGlobal->stopSimulation) break;
     360             : 
     361        3671 :             Weather::GetNextEnvironment(state, Available, ErrorsFound);
     362             : 
     363        3671 :             if (!Available) break;
     364        2877 :             if (ErrorsFound) break;
     365        4080 :             if ((!state.dataGlobal->DoDesDaySim) && (state.dataGlobal->KindOfSim != Constant::KindOfSim::RunPeriodWeather)) continue;
     366        2865 :             if ((!state.dataGlobal->DoWeathSim) && (state.dataGlobal->KindOfSim == Constant::KindOfSim::RunPeriodWeather)) continue;
     367        1697 :             if (state.dataGlobal->KindOfSim == Constant::KindOfSim::HVACSizeDesignDay) continue; // don't run these here, only for sizing simulations
     368             : 
     369        1662 :             if (state.dataGlobal->KindOfSim == Constant::KindOfSim::HVACSizeRunPeriodDesign)
     370           0 :                 continue; // don't run these here, only for sizing simulations
     371             : 
     372        1662 :             ++EnvCount;
     373             : 
     374        1662 :             if (state.dataSQLiteProcedures->sqlite) {
     375         251 :                 state.dataSQLiteProcedures->sqlite->sqliteBegin();
     376         753 :                 state.dataSQLiteProcedures->sqlite->createSQLiteEnvironmentPeriodRecord(
     377         502 :                     state.dataEnvrn->CurEnvirNum, state.dataEnvrn->EnvironmentName, state.dataGlobal->KindOfSim);
     378         251 :                 state.dataSQLiteProcedures->sqlite->sqliteCommit();
     379             :             }
     380             : 
     381        1662 :             state.dataErrTracking->ExitDuringSimulations = true;
     382        1662 :             SimsDone = true;
     383        1662 :             DisplayString(state, "Initializing New Environment Parameters");
     384             : 
     385        1662 :             state.dataGlobal->BeginEnvrnFlag = true;
     386        1662 :             state.dataGlobal->EndEnvrnFlag = false;
     387        1662 :             state.dataEnvrn->EndMonthFlag = false;
     388        1662 :             state.dataGlobal->WarmupFlag = true;
     389        1662 :             state.dataGlobal->DayOfSim = 0;
     390        1662 :             state.dataGlobal->DayOfSimChr = "0";
     391        1662 :             state.dataReportFlag->NumOfWarmupDays = 0;
     392        1662 :             if (state.dataEnvrn->CurrentYearIsLeapYear) {
     393           1 :                 if (state.dataGlobal->NumOfDayInEnvrn <= 366) {
     394           1 :                     state.dataOutputProcessor->isFinalYear = true;
     395             :                 }
     396             :             } else {
     397        1661 :                 if (state.dataGlobal->NumOfDayInEnvrn <= 365) {
     398        1661 :                     state.dataOutputProcessor->isFinalYear = true;
     399             :                 }
     400             :             }
     401             : 
     402        1662 :             HVACManager::ResetNodeData(state); // Reset here, because some zone calcs rely on node data (e.g. ZoneITEquip)
     403             : 
     404             :             bool anyEMSRan;
     405        1662 :             ManageEMS(state, EMSManager::EMSCallFrom::BeginNewEnvironment, anyEMSRan, ObjexxFCL::Optional_int_const()); // calling point
     406             : 
     407       16405 :             while ((state.dataGlobal->DayOfSim < state.dataGlobal->NumOfDayInEnvrn) || (state.dataGlobal->WarmupFlag)) { // Begin day loop ...
     408       14744 :                 if (state.dataGlobal->stopSimulation) break;
     409             : 
     410       14744 :                 if (state.dataSQLiteProcedures->sqlite) state.dataSQLiteProcedures->sqlite->sqliteBegin(); // setup for one transaction per day
     411             : 
     412       14744 :                 ++state.dataGlobal->DayOfSim;
     413       14744 :                 state.dataGlobal->DayOfSimChr = fmt::to_string(state.dataGlobal->DayOfSim);
     414       14744 :                 if (!state.dataGlobal->WarmupFlag) {
     415        3879 :                     ++state.dataEnvrn->CurrentOverallSimDay;
     416        3879 :                     DisplaySimDaysProgress(state, state.dataEnvrn->CurrentOverallSimDay, state.dataEnvrn->TotalOverallSimDays);
     417             :                 } else {
     418       10865 :                     state.dataGlobal->DayOfSimChr = "0";
     419             :                 }
     420       14744 :                 state.dataGlobal->BeginDayFlag = true;
     421       14744 :                 state.dataGlobal->EndDayFlag = false;
     422             : 
     423       14744 :                 if (state.dataGlobal->WarmupFlag) {
     424       10865 :                     ++state.dataReportFlag->NumOfWarmupDays;
     425       10865 :                     state.dataReportFlag->cWarmupDay = fmt::to_string(state.dataReportFlag->NumOfWarmupDays);
     426       10865 :                     DisplayString(state, "Warming up {" + state.dataReportFlag->cWarmupDay + '}');
     427        3879 :                 } else if (state.dataGlobal->DayOfSim == 1) {
     428        1661 :                     if (state.dataGlobal->KindOfSim == Constant::KindOfSim::RunPeriodWeather) {
     429           6 :                         DisplayString(state, "Starting Simulation at " + state.dataEnvrn->CurMnDyYr + " for " + state.dataEnvrn->EnvironmentName);
     430             :                     } else {
     431        1655 :                         DisplayString(state, "Starting Simulation at " + state.dataEnvrn->CurMnDy + " for " + state.dataEnvrn->EnvironmentName);
     432             :                     }
     433             :                     static constexpr std::string_view Format_700("Environment:WarmupDays,{:3}\n");
     434        1661 :                     print(state.files.eio, Format_700, state.dataReportFlag->NumOfWarmupDays);
     435        2218 :                 } else if (state.dataReportFlag->DisplayPerfSimulationFlag) {
     436         108 :                     if (state.dataGlobal->KindOfSim == Constant::KindOfSim::RunPeriodWeather) {
     437         108 :                         DisplayString(state, "Continuing Simulation at " + state.dataEnvrn->CurMnDyYr + " for " + state.dataEnvrn->EnvironmentName);
     438             :                     } else {
     439           0 :                         DisplayString(state, "Continuing Simulation at " + state.dataEnvrn->CurMnDy + " for " + state.dataEnvrn->EnvironmentName);
     440             :                     }
     441         108 :                     state.dataReportFlag->DisplayPerfSimulationFlag = false;
     442             :                 }
     443             :                 // for simulations that last longer than a week, identify when the last year of the simulation is started
     444       14744 :                 if ((state.dataGlobal->DayOfSim > 365) && ((state.dataGlobal->NumOfDayInEnvrn - state.dataGlobal->DayOfSim) == 364) &&
     445           0 :                     !state.dataGlobal->WarmupFlag) {
     446           0 :                     DisplayString(state, "Starting last  year of environment at:  " + state.dataGlobal->DayOfSimChr);
     447           0 :                     OutputReportTabular::ResetTabularReports(state);
     448             :                 }
     449             : 
     450      368576 :                 for (state.dataGlobal->HourOfDay = 1; state.dataGlobal->HourOfDay <= 24; ++state.dataGlobal->HourOfDay) { // Begin hour loop ...
     451      353833 :                     if (state.dataGlobal->stopSimulation) break;
     452             : 
     453      353833 :                     state.dataGlobal->BeginHourFlag = true;
     454      353833 :                     state.dataGlobal->EndHourFlag = false;
     455             : 
     456     2298217 :                     for (state.dataGlobal->TimeStep = 1; state.dataGlobal->TimeStep <= state.dataGlobal->NumOfTimeStepInHour;
     457     1944384 :                          ++state.dataGlobal->TimeStep) {
     458     1944385 :                         if (state.dataGlobal->stopSimulation) break;
     459             : 
     460     1944385 :                         if (state.dataGlobal->AnySlabsInModel || state.dataGlobal->AnyBasementsInModel) {
     461       13440 :                             PlantPipingSystemsManager::SimulateGroundDomains(state, false);
     462             :                         }
     463             : 
     464     1944385 :                         if (AnyUnderwaterBoundaries) {
     465        1343 :                             Weather::UpdateUnderwaterBoundaries(state);
     466             :                         }
     467             : 
     468     3887426 :                         if (state.dataEnvrn->varyingLocationSchedIndexLat > 0 || state.dataEnvrn->varyingLocationSchedIndexLong > 0 ||
     469     1943041 :                             state.dataEnvrn->varyingOrientationSchedIndex > 0) {
     470        1344 :                             Weather::UpdateLocationAndOrientation(state);
     471             :                         }
     472             : 
     473     1944385 :                         state.dataGlobal->BeginTimeStepFlag = true;
     474     1944385 :                         ExternalInterfaceExchangeVariables(state);
     475             : 
     476             :                         // Set the End__Flag variables to true if necessary.  Note that
     477             :                         // each flag builds on the previous level.  EndDayFlag cannot be
     478             :                         // .TRUE. unless EndHourFlag is also .TRUE., etc.  Note that the
     479             :                         // EndEnvrnFlag and the EndSimFlag cannot be set during warmup.
     480             :                         // Note also that BeginTimeStepFlag, EndTimeStepFlag, and the
     481             :                         // SubTimeStepFlags can/will be set/reset in the HVAC Manager.
     482             : 
     483     1944385 :                         if (state.dataGlobal->TimeStep == state.dataGlobal->NumOfTimeStepInHour) {
     484      353832 :                             state.dataGlobal->EndHourFlag = true;
     485      353832 :                             if (state.dataGlobal->HourOfDay == 24) {
     486       14743 :                                 state.dataGlobal->EndDayFlag = true;
     487       14743 :                                 if ((!state.dataGlobal->WarmupFlag) && (state.dataGlobal->DayOfSim == state.dataGlobal->NumOfDayInEnvrn)) {
     488        1661 :                                     state.dataGlobal->EndEnvrnFlag = true;
     489             :                                 }
     490             :                             }
     491             :                         }
     492             : 
     493     1944385 :                         Weather::ManageWeather(state);
     494             : 
     495     1944385 :                         ExteriorEnergyUse::ManageExteriorEnergyUse(state);
     496             : 
     497     1944385 :                         ManageHeatBalance(state);
     498             : 
     499     1944384 :                         if (oneTimeUnderwaterBoundaryCheck) {
     500         794 :                             AnyUnderwaterBoundaries = Weather::CheckIfAnyUnderwaterBoundaries(state);
     501         794 :                             oneTimeUnderwaterBoundaryCheck = false;
     502             :                         }
     503             : 
     504     1944384 :                         state.dataGlobal->BeginHourFlag = false;
     505     1944384 :                         state.dataGlobal->BeginDayFlag = false;
     506     1944384 :                         state.dataGlobal->BeginEnvrnFlag = false;
     507     1944384 :                         state.dataGlobal->BeginSimFlag = false;
     508             :                     } // TimeStep loop
     509             : 
     510      353832 :                     state.dataGlobal->PreviousHour = state.dataGlobal->HourOfDay;
     511             : 
     512             :                 } // ... End hour loop.
     513             : 
     514       14743 :                 if (state.dataSQLiteProcedures->sqlite) state.dataSQLiteProcedures->sqlite->sqliteCommit(); // one transaction per day
     515             : 
     516             :             } // ... End day loop.
     517             : 
     518             :             // Need one last call to send latest states to middleware
     519        1661 :             ExternalInterfaceExchangeVariables(state);
     520             : 
     521             :         } // ... End environment loop.
     522             : 
     523         794 :         state.dataGlobal->WarmupFlag = false;
     524             : 
     525         794 :         if (!SimsDone && state.dataGlobal->DoDesDaySim) {
     526           0 :             if ((state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays) == 0) { // if sum is 0, then there was no sizing done.
     527           0 :                 ShowWarningError(state,
     528             :                                  "ManageSimulation: SizingPeriod:* were requested in SimulationControl but no SizingPeriod:* objects in input.");
     529             :             }
     530             :         }
     531             : 
     532         794 :         if (!SimsDone && state.dataGlobal->DoWeathSim) {
     533           0 :             if (!state.dataSimulationManager->RunPeriodsInInput) { // if no run period requested, and sims not done
     534           0 :                 ShowWarningError(state, "ManageSimulation: Weather Simulation was requested in SimulationControl but no RunPeriods in input.");
     535             :             }
     536             :         }
     537             : 
     538         794 :         PlantManager::CheckOngoingPlantWarnings(state);
     539             : 
     540         794 :         if (state.dataSQLiteProcedures->sqlite) state.dataSQLiteProcedures->sqlite->sqliteBegin(); // for final data to write
     541             : 
     542         794 :         CostEstimateManager::SimCostEstimate(state);
     543             : 
     544         794 :         EconomicTariff::ComputeTariff(state); //     Compute the utility bills
     545             : 
     546         794 :         EMSManager::checkForUnusedActuatorsAtEnd(state);
     547         794 :         EMSManager::checkSetpointNodesAtEnd(state);
     548             : 
     549         794 :         OutputProcessor::ReportForTabularReports(state); // For Energy Meters (could have other things that need to be pushed to after simulation)
     550             : 
     551         794 :         OutputReportTabular::OpenOutputTabularFile(state);
     552             : 
     553         794 :         OutputReportTabular::WriteTabularReports(state); // Create the tabular reports at completion of each
     554             : 
     555         794 :         EconomicTariff::WriteTabularTariffReports(state);
     556             : 
     557         794 :         EconomicLifeCycleCost::ComputeLifeCycleCostAndReport(state); // must be after WriteTabularReports and WriteTabularTariffReports
     558             : 
     559         794 :         OutputReportTabular::CloseOutputTabularFile(state);
     560             : 
     561         794 :         HVACControllers::DumpAirLoopStatistics(state); // Dump runtime statistics for air loop controller simulation to csv file
     562             : 
     563         794 :         CloseOutputFiles(state);
     564             : 
     565             :         // state.dataSQLiteProcedures->sqlite->createZoneExtendedOutput();
     566         794 :         CreateSQLiteZoneExtendedOutput(state);
     567             : 
     568         794 :         if (state.dataSQLiteProcedures->sqlite) {
     569         123 :             DisplayString(state, "Writing final SQL reports");
     570         123 :             state.dataSQLiteProcedures->sqlite->sqliteCommit();      // final transactions
     571         123 :             state.dataSQLiteProcedures->sqlite->initializeIndexes(); // do not create indexes (SQL) until all is done.
     572             :         }
     573             : 
     574         794 :         if (ErrorsFound) {
     575           0 :             ShowFatalError(state, "Error condition occurred.  Previous Severe Errors cause termination.");
     576             :         }
     577         794 :     }
     578             : 
     579         796 :     void GetProjectData(EnergyPlusData &state)
     580             :     {
     581             : 
     582             :         // SUBROUTINE INFORMATION:
     583             :         //       AUTHOR         Linda K. Lawrie
     584             :         //       DATE WRITTEN   November 1997
     585             :         //       MODIFIED       na
     586             :         //       RE-ENGINEERED  na
     587             : 
     588             :         // PURPOSE OF THIS SUBROUTINE:
     589             :         // This subroutine gets global project data from the input file.
     590             : 
     591             :         // METHODOLOGY EMPLOYED:
     592             :         // Use GetObjectItem from the Input Processor
     593             : 
     594             :         // Using/Aliasing
     595             :         using DataStringGlobals::MatchVersion;
     596             :         using namespace DataSystemVariables;
     597         796 :         auto &deviationFromSetPtThresholdClg = state.dataHVACGlobal->deviationFromSetPtThresholdClg;
     598         796 :         auto &deviationFromSetPtThresholdHtg = state.dataHVACGlobal->deviationFromSetPtThresholdHtg;
     599             : 
     600             :         // SUBROUTINE PARAMETER DEFINITIONS:
     601             :         static constexpr std::array<int, 12> Div60 = {1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60};
     602             : 
     603             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     604         796 :         Array1D_string Alphas(10);
     605         796 :         Array1D<Real64> Number(4);
     606             :         int NumAlpha;
     607             :         int NumNumber;
     608             :         int IOStat;
     609             :         int NumDebugOut;
     610             :         int MinInt;
     611             :         int Num;
     612             :         int Which;
     613             :         bool ErrorsFound;
     614             :         int NumRunControl;
     615         796 :         std::string VersionID;
     616         796 :         std::string CurrentModuleObject;
     617             :         bool CondFDAlgo;
     618             :         int Item;
     619             : 
     620         796 :         ErrorsFound = false;
     621             : 
     622         796 :         CurrentModuleObject = "Version";
     623         796 :         Num = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     624         796 :         if (Num == 1) {
     625        1592 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
     626             :                                                                      CurrentModuleObject,
     627             :                                                                      1,
     628             :                                                                      Alphas,
     629             :                                                                      NumAlpha,
     630             :                                                                      Number,
     631             :                                                                      NumNumber,
     632             :                                                                      IOStat,
     633         796 :                                                                      state.dataIPShortCut->lNumericFieldBlanks,
     634         796 :                                                                      state.dataIPShortCut->lAlphaFieldBlanks,
     635         796 :                                                                      state.dataIPShortCut->cAlphaFieldNames,
     636         796 :                                                                      state.dataIPShortCut->cNumericFieldNames);
     637         796 :             std::string::size_type const lenVer(len(MatchVersion));
     638         796 :             if ((lenVer > 0) && (MatchVersion[lenVer - 1] == '0')) {
     639           0 :                 Which = static_cast<int>(index(Alphas(1).substr(0, lenVer - 2), MatchVersion.substr(0, lenVer - 2)));
     640             :             } else {
     641         796 :                 Which = static_cast<int>(index(Alphas(1), MatchVersion));
     642             :             }
     643         796 :             if (Which != 0) {
     644           2 :                 ShowWarningError(state, format("{}: in IDF=\"{}\" not the same as expected=\"{}\"", CurrentModuleObject, Alphas(1), MatchVersion));
     645             :             }
     646         796 :             VersionID = Alphas(1);
     647           0 :         } else if (Num == 0) {
     648           0 :             ShowWarningError(state, format("{}: missing in IDF, processing for EnergyPlus version=\"{}\"", CurrentModuleObject, MatchVersion));
     649             :         } else {
     650           0 :             ShowSevereError(state, format("Too many {} Objects found.", CurrentModuleObject));
     651           0 :             ErrorsFound = true;
     652             :         }
     653             : 
     654             :         // Do Mini Gets on HB Algorithm and by-surface overrides
     655         796 :         CurrentModuleObject = "HeatBalanceAlgorithm";
     656         796 :         Num = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     657         796 :         CondFDAlgo = false;
     658         796 :         if (Num > 0) {
     659        1438 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
     660             :                                                                      CurrentModuleObject,
     661             :                                                                      1,
     662             :                                                                      Alphas,
     663             :                                                                      NumAlpha,
     664             :                                                                      Number,
     665             :                                                                      NumNumber,
     666             :                                                                      IOStat,
     667         719 :                                                                      state.dataIPShortCut->lNumericFieldBlanks,
     668         719 :                                                                      state.dataIPShortCut->lAlphaFieldBlanks,
     669         719 :                                                                      state.dataIPShortCut->cAlphaFieldNames,
     670         719 :                                                                      state.dataIPShortCut->cNumericFieldNames);
     671             :             static constexpr std::array<std::string_view, 4> condFDTypes = {
     672             :                 "CONDUCTIONFINITEDIFFERENCE", "CONDFD", "CONDUCTIONFINITEDIFFERENCEDETAILED", "CONDUCTIONFINITEDIFFERENCESIMPLIFIED"};
     673         719 :             CondFDAlgo = std::find(condFDTypes.begin(), condFDTypes.end(), Alphas(1)) != condFDTypes.end();
     674             :         }
     675         796 :         CurrentModuleObject = "SurfaceProperty:HeatTransferAlgorithm";
     676         796 :         Num = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     677         796 :         if (Num > 0) {
     678           3 :             for (Item = 1; Item <= Num; ++Item) {
     679           4 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
     680             :                                                                          CurrentModuleObject,
     681             :                                                                          Item,
     682             :                                                                          Alphas,
     683             :                                                                          NumAlpha,
     684             :                                                                          Number,
     685             :                                                                          NumNumber,
     686             :                                                                          IOStat,
     687           2 :                                                                          state.dataIPShortCut->lNumericFieldBlanks,
     688           2 :                                                                          state.dataIPShortCut->lAlphaFieldBlanks,
     689           2 :                                                                          state.dataIPShortCut->cAlphaFieldNames,
     690           2 :                                                                          state.dataIPShortCut->cNumericFieldNames);
     691           2 :                 if (Alphas(2) == "CONDUCTIONFINITEDIFFERENCE") CondFDAlgo = true;
     692             :             }
     693             :         }
     694         796 :         CurrentModuleObject = "SurfaceProperty:HeatTransferAlgorithm:MultipleSurface";
     695         796 :         Num = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     696         796 :         if (Num > 0) {
     697           0 :             for (Item = 1; Item <= Num; ++Item) {
     698           0 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
     699             :                                                                          CurrentModuleObject,
     700             :                                                                          1,
     701             :                                                                          Alphas,
     702             :                                                                          NumAlpha,
     703             :                                                                          Number,
     704             :                                                                          NumNumber,
     705             :                                                                          IOStat,
     706           0 :                                                                          state.dataIPShortCut->lNumericFieldBlanks,
     707           0 :                                                                          state.dataIPShortCut->lAlphaFieldBlanks,
     708           0 :                                                                          state.dataIPShortCut->cAlphaFieldNames,
     709           0 :                                                                          state.dataIPShortCut->cNumericFieldNames);
     710           0 :                 if (Alphas(3) == "CONDUCTIONFINITEDIFFERENCE") CondFDAlgo = true;
     711             :             }
     712             :         }
     713         796 :         CurrentModuleObject = "SurfaceProperty:HeatTransferAlgorithm:SurfaceList";
     714         796 :         Num = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     715         796 :         if (Num > 0) {
     716           2 :             for (Item = 1; Item <= Num; ++Item) {
     717           2 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
     718             :                                                                          CurrentModuleObject,
     719             :                                                                          1,
     720           1 :                                                                          state.dataIPShortCut->cAlphaArgs,
     721             :                                                                          NumAlpha,
     722             :                                                                          Number,
     723             :                                                                          NumNumber,
     724             :                                                                          IOStat,
     725           1 :                                                                          state.dataIPShortCut->lNumericFieldBlanks,
     726           1 :                                                                          state.dataIPShortCut->lAlphaFieldBlanks,
     727           1 :                                                                          state.dataIPShortCut->cAlphaFieldNames,
     728           1 :                                                                          state.dataIPShortCut->cNumericFieldNames);
     729           1 :                 if (state.dataIPShortCut->cAlphaArgs(2) == "CONDUCTIONFINITEDIFFERENCE") CondFDAlgo = true;
     730             :             }
     731             :         }
     732         796 :         CurrentModuleObject = "SurfaceProperty:HeatTransferAlgorithm:Construction";
     733         796 :         Num = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     734         796 :         if (Num > 0) {
     735           2 :             for (Item = 1; Item <= Num; ++Item) {
     736           2 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
     737             :                                                                          CurrentModuleObject,
     738             :                                                                          1,
     739           1 :                                                                          state.dataIPShortCut->cAlphaArgs,
     740             :                                                                          NumAlpha,
     741             :                                                                          Number,
     742             :                                                                          NumNumber,
     743             :                                                                          IOStat,
     744           1 :                                                                          state.dataIPShortCut->lNumericFieldBlanks,
     745           1 :                                                                          state.dataIPShortCut->lAlphaFieldBlanks,
     746           1 :                                                                          state.dataIPShortCut->cAlphaFieldNames,
     747           1 :                                                                          state.dataIPShortCut->cNumericFieldNames);
     748           1 :                 if (state.dataIPShortCut->cAlphaArgs(2) == "CONDUCTIONFINITEDIFFERENCE") CondFDAlgo = true;
     749             :             }
     750             :         }
     751             : 
     752         796 :         CurrentModuleObject = "Timestep";
     753         796 :         Num = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     754         796 :         if (Num == 1) {
     755        1590 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
     756             :                                                                      CurrentModuleObject,
     757             :                                                                      1,
     758             :                                                                      Alphas,
     759             :                                                                      NumAlpha,
     760             :                                                                      Number,
     761             :                                                                      NumNumber,
     762             :                                                                      IOStat,
     763         795 :                                                                      state.dataIPShortCut->lNumericFieldBlanks,
     764         795 :                                                                      state.dataIPShortCut->lAlphaFieldBlanks,
     765         795 :                                                                      state.dataIPShortCut->cAlphaFieldNames,
     766         795 :                                                                      state.dataIPShortCut->cNumericFieldNames);
     767         795 :             state.dataGlobal->NumOfTimeStepInHour = Number(1);
     768         795 :             if (state.dataGlobal->NumOfTimeStepInHour <= 0 || state.dataGlobal->NumOfTimeStepInHour > 60) {
     769           0 :                 Alphas(1) = fmt::to_string(state.dataGlobal->NumOfTimeStepInHour);
     770           0 :                 ShowWarningError(state, format("{}: Requested number ({}) invalid, Defaulted to 4", CurrentModuleObject, Alphas(1)));
     771           0 :                 state.dataGlobal->NumOfTimeStepInHour = 4;
     772         795 :             } else if (mod(60, state.dataGlobal->NumOfTimeStepInHour) != 0) {
     773           0 :                 MinInt = 9999;
     774           0 :                 for (Num = 1; Num <= 12; ++Num) {
     775           0 :                     if (std::abs(state.dataGlobal->NumOfTimeStepInHour - Div60[Num - 1]) > MinInt) continue;
     776           0 :                     MinInt = state.dataGlobal->NumOfTimeStepInHour - Div60[Num - 1];
     777           0 :                     Which = Num;
     778             :                 }
     779           0 :                 ShowWarningError(state,
     780           0 :                                  format("{}: Requested number ({}) not evenly divisible into 60, defaulted to nearest ({}).",
     781             :                                         CurrentModuleObject,
     782           0 :                                         state.dataGlobal->NumOfTimeStepInHour,
     783           0 :                                         Div60[Which - 1]));
     784           0 :                 state.dataGlobal->NumOfTimeStepInHour = Div60[Which - 1];
     785             :             }
     786         795 :             if (CondFDAlgo && state.dataGlobal->NumOfTimeStepInHour < 20) {
     787           0 :                 ShowWarningError(state,
     788           0 :                                  format("{}: Requested number ({}) cannot be used when Conduction Finite Difference algorithm is selected.",
     789             :                                         CurrentModuleObject,
     790           0 :                                         state.dataGlobal->NumOfTimeStepInHour));
     791           0 :                 ShowContinueError(state, format("...{} is set to 20.", CurrentModuleObject));
     792           0 :                 state.dataGlobal->NumOfTimeStepInHour = 20;
     793             :             }
     794         795 :             if (state.dataGlobal->NumOfTimeStepInHour < 4 && state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Zone") > 0) {
     795          10 :                 ShowWarningError(state,
     796          10 :                                  format("{}: Requested number ({}) is less than the suggested minimum of 4.",
     797             :                                         CurrentModuleObject,
     798           5 :                                         state.dataGlobal->NumOfTimeStepInHour));
     799          10 :                 ShowContinueError(state,
     800          10 :                                   format("Please see entry for {} in Input/Output Reference for discussion of considerations.", CurrentModuleObject));
     801             :             }
     802           1 :         } else if (Num == 0 && state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Zone") > 0 && !CondFDAlgo) {
     803           0 :             ShowWarningError(state, format("No {} object found.  Number of TimeSteps in Hour defaulted to 4.", CurrentModuleObject));
     804           0 :             state.dataGlobal->NumOfTimeStepInHour = 4;
     805           1 :         } else if (Num == 0 && !CondFDAlgo) {
     806           1 :             state.dataGlobal->NumOfTimeStepInHour = 4;
     807           0 :         } else if (Num == 0 && state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Zone") > 0 && CondFDAlgo) {
     808           0 :             ShowWarningError(state, format("No {} object found.  Number of TimeSteps in Hour defaulted to 20.", CurrentModuleObject));
     809           0 :             ShowContinueError(state, "...Due to presence of Conduction Finite Difference Algorithm selection.");
     810           0 :             state.dataGlobal->NumOfTimeStepInHour = 20;
     811           0 :         } else if (Num == 0 && CondFDAlgo) {
     812           0 :             state.dataGlobal->NumOfTimeStepInHour = 20;
     813             :         } else {
     814           0 :             ShowSevereError(state, format("Too many {} Objects found.", CurrentModuleObject));
     815           0 :             ErrorsFound = true;
     816             :         }
     817             : 
     818         796 :         state.dataGlobal->TimeStepZone = 1.0 / double(state.dataGlobal->NumOfTimeStepInHour);
     819         796 :         state.dataGlobal->MinutesPerTimeStep = state.dataGlobal->TimeStepZone * 60;
     820         796 :         state.dataGlobal->TimeStepZoneSec = state.dataGlobal->TimeStepZone * Constant::SecInHour;
     821             : 
     822         796 :         CurrentModuleObject = "ConvergenceLimits";
     823         796 :         Num = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     824         796 :         if (Num == 1) {
     825         310 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
     826             :                                                                      CurrentModuleObject,
     827             :                                                                      1,
     828             :                                                                      Alphas,
     829             :                                                                      NumAlpha,
     830             :                                                                      Number,
     831             :                                                                      NumNumber,
     832             :                                                                      IOStat,
     833         155 :                                                                      state.dataIPShortCut->lNumericFieldBlanks,
     834         155 :                                                                      state.dataIPShortCut->lAlphaFieldBlanks,
     835         155 :                                                                      state.dataIPShortCut->cAlphaFieldNames,
     836         155 :                                                                      state.dataIPShortCut->cNumericFieldNames);
     837         155 :             MinInt = int(Number(1));
     838         155 :             if (MinInt > state.dataGlobal->MinutesPerTimeStep) {
     839           2 :                 MinInt = state.dataGlobal->MinutesPerTimeStep;
     840             :             }
     841         155 :             if (MinInt < 0 || MinInt > 60) {
     842           0 :                 ShowWarningError(
     843             :                     state,
     844           0 :                     format(
     845           0 :                         "{}: Requested {} ({}) invalid. Set to 1 minute.", CurrentModuleObject, state.dataIPShortCut->cNumericFieldNames(1), MinInt));
     846           0 :                 state.dataConvergeParams->MinTimeStepSys = 1.0 / 60.0;
     847         155 :             } else if (MinInt == 0) { // Set to TimeStepZone
     848           5 :                 state.dataConvergeParams->MinTimeStepSys = state.dataGlobal->TimeStepZone;
     849             :             } else {
     850         150 :                 state.dataConvergeParams->MinTimeStepSys = double(MinInt) / 60.0;
     851             :             }
     852         155 :             state.dataConvergeParams->MaxIter = int(Number(2));
     853         155 :             if (state.dataConvergeParams->MaxIter <= 0) {
     854           0 :                 state.dataConvergeParams->MaxIter = 20;
     855             :             }
     856         155 :             if (!state.dataIPShortCut->lNumericFieldBlanks(3)) state.dataConvergeParams->MinPlantSubIterations = int(Number(3));
     857         155 :             if (!state.dataIPShortCut->lNumericFieldBlanks(4)) state.dataConvergeParams->MaxPlantSubIterations = int(Number(4));
     858             :             // trap bad values
     859         155 :             if (state.dataConvergeParams->MinPlantSubIterations < 1) state.dataConvergeParams->MinPlantSubIterations = 1;
     860         155 :             if (state.dataConvergeParams->MaxPlantSubIterations < 3) state.dataConvergeParams->MaxPlantSubIterations = 3;
     861         155 :             if (state.dataConvergeParams->MinPlantSubIterations > state.dataConvergeParams->MaxPlantSubIterations)
     862           0 :                 state.dataConvergeParams->MaxPlantSubIterations = state.dataConvergeParams->MinPlantSubIterations + 1;
     863             : 
     864         641 :         } else if (Num == 0) {
     865         641 :             state.dataConvergeParams->MinTimeStepSys = 1.0 / 60.0;
     866         641 :             state.dataConvergeParams->MaxIter = 20;
     867         641 :             state.dataConvergeParams->MinPlantSubIterations = 2;
     868         641 :             state.dataConvergeParams->MaxPlantSubIterations = 8;
     869             :         } else {
     870           0 :             ShowSevereError(state, format("Too many {} Objects found.", CurrentModuleObject));
     871           0 :             ErrorsFound = true;
     872             :         }
     873             : 
     874         796 :         state.dataHVACGlobal->LimitNumSysSteps = int(state.dataGlobal->TimeStepZone / state.dataConvergeParams->MinTimeStepSys);
     875             : 
     876         796 :         state.dataReportFlag->DebugOutput = false;
     877         796 :         state.dataReportFlag->EvenDuringWarmup = false;
     878         796 :         CurrentModuleObject = "Output:DebuggingData";
     879         796 :         NumDebugOut = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     880         796 :         if (NumDebugOut > 1) {
     881           0 :             ShowWarningError(state, format("{}: More than 1 occurrence of this object found, only first will be used.", CurrentModuleObject));
     882             :         }
     883         796 :         if (NumDebugOut > 0) {
     884          70 :             state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, 1, Alphas, NumAlpha, Number, NumNumber, IOStat);
     885          70 :             if (NumAlpha >= 1) {
     886          70 :                 state.dataReportFlag->DebugOutput = Util::SameString(Alphas(1), "Yes");
     887             :             }
     888          70 :             if (NumAlpha >= 2) {
     889          70 :                 state.dataReportFlag->EvenDuringWarmup = Util::SameString(Alphas(2), "Yes");
     890             :             }
     891             :         }
     892             : 
     893             :         {
     894         796 :             CurrentModuleObject = "Output:Diagnostics";
     895         796 :             Num = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     896         796 :             if (Num > 1) {
     897             :                 // Let it slide, but warn
     898             :                 // ErrorsFound = true;
     899           0 :                 ShowWarningError(state, format("{}: More than 1 occurrence of this object found, only first will be used.", CurrentModuleObject));
     900             :             }
     901         796 :             auto const instances = state.dataInputProcessing->inputProcessor->epJSON.find(CurrentModuleObject);
     902             : 
     903         796 :             if (instances != state.dataInputProcessing->inputProcessor->epJSON.end()) {
     904          87 :                 auto &instancesValue = instances.value();
     905          87 :                 for (auto instance = instancesValue.begin(); instance != instancesValue.end(); ++instance) {
     906          87 :                     auto const &fields = instance.value();
     907          87 :                     std::string const &thisObjectName = instance.key();
     908          87 :                     state.dataInputProcessing->inputProcessor->markObjectAsUsed(CurrentModuleObject, thisObjectName);
     909             : 
     910          87 :                     auto diagnosticsExtensibles = fields.find("diagnostics");
     911          87 :                     if (diagnosticsExtensibles != fields.end()) {
     912         178 :                         for (auto &diagnosticsExtensible : diagnosticsExtensibles.value()) {
     913             : 
     914             :                             // We want to avoid cryptic failures such as this one: "[json.exception.out_of_range.403] key 'key' not found"
     915             :                             // Which happens if you put an "empty" entry in the extensible portion
     916          91 :                             auto it = diagnosticsExtensible.find("key");
     917          91 :                             if (it == diagnosticsExtensible.end()) {
     918           0 :                                 ShowWarningError(state,
     919           0 :                                                  format("{}: empty key found, consider removing it to avoid this warning.", CurrentModuleObject));
     920           0 :                                 continue;
     921             :                             }
     922          91 :                             std::string diagnosticName = it->get<std::string>();
     923             : 
     924          91 :                             if (Util::SameString(diagnosticName, "DisplayExtraWarnings")) {
     925          15 :                                 state.dataGlobal->DisplayExtraWarnings = true;
     926          76 :                             } else if (Util::SameString(diagnosticName, "DisplayAdvancedReportVariables")) {
     927          22 :                                 state.dataGlobal->DisplayAdvancedReportVariables = true;
     928          54 :                             } else if (Util::SameString(diagnosticName, "DisplayAllWarnings")) {
     929          36 :                                 state.dataGlobal->DisplayAllWarnings = true;
     930          36 :                                 state.dataGlobal->DisplayExtraWarnings = true;
     931          36 :                                 state.dataGlobal->DisplayUnusedObjects = true;
     932          36 :                                 state.dataGlobal->DisplayUnusedSchedules = true;
     933          18 :                             } else if (Util::SameString(diagnosticName, "DisplayUnusedObjects")) {
     934           2 :                                 state.dataGlobal->DisplayUnusedObjects = true;
     935          16 :                             } else if (Util::SameString(diagnosticName, "DisplayUnusedSchedules")) {
     936          13 :                                 state.dataGlobal->DisplayUnusedSchedules = true;
     937           3 :                             } else if (Util::SameString(diagnosticName, "DisplayZoneAirHeatBalanceOffBalance")) {
     938           2 :                                 state.dataGlobal->DisplayZoneAirHeatBalanceOffBalance = true;
     939           1 :                             } else if (Util::SameString(diagnosticName, "DoNotMirrorDetachedShading")) {
     940           0 :                                 state.dataReportFlag->MakeMirroredDetachedShading = false;
     941           1 :                             } else if (Util::SameString(diagnosticName, "DoNotMirrorAttachedShading")) {
     942           0 :                                 state.dataReportFlag->MakeMirroredAttachedShading = false;
     943           1 :                             } else if (Util::SameString(diagnosticName, "ReportDuringWarmup")) {
     944           0 :                                 state.dataSysVars->ReportDuringWarmup = true;
     945           1 :                             } else if (Util::SameString(diagnosticName, "DisplayWeatherMissingDataWarnings")) {
     946           0 :                                 state.dataEnvrn->DisplayWeatherMissingDataWarnings = true;
     947           1 :                             } else if (Util::SameString(diagnosticName, "IgnoreSolarRadiation")) { // TODO: Not a valid key choice
     948           0 :                                 state.dataEnvrn->IgnoreSolarRadiation = true;
     949           1 :                             } else if (Util::SameString(diagnosticName, "IgnoreBeamRadiation")) { // TODO: Not a valid key choice
     950           0 :                                 state.dataEnvrn->IgnoreBeamRadiation = true;
     951           1 :                             } else if (Util::SameString(diagnosticName, "IgnoreDiffuseRadiation")) { // TODO: Not a valid key choice
     952           0 :                                 state.dataEnvrn->IgnoreDiffuseRadiation = true;
     953           1 :                             } else if (Util::SameString(diagnosticName, "DeveloperFlag")) { // TODO: Not a valid key choice
     954           0 :                                 state.dataSysVars->DeveloperFlag = true;
     955           1 :                             } else if (Util::SameString(diagnosticName, "TimingFlag")) { // TODO: Not a valid key choice
     956           0 :                                 state.dataSysVars->TimingFlag = true;
     957           1 :                             } else if (Util::SameString(diagnosticName, "ReportDetailedWarmupConvergence")) {
     958           1 :                                 state.dataSysVars->ReportDetailedWarmupConvergence = true;
     959           0 :                             } else if (Util::SameString(diagnosticName, "ReportDuringHVACSizingSimulation")) {
     960           0 :                                 state.dataSysVars->ReportDuringHVACSizingSimulation = true;
     961           0 :                             } else if (Util::SameString(diagnosticName, "CreateMinimalSurfaceVariables")) { // TODO: Not a valid key choice
     962           0 :                                 continue;
     963             :                                 //        CreateMinimalSurfaceVariables=.TRUE.
     964           0 :                             } else if (Util::SameString(diagnosticName, "CreateNormalSurfaceVariables")) { // TODO: Not a valid key choice
     965           0 :                                 continue;
     966             :                                 //        IF (CreateMinimalSurfaceVariables) THEN
     967             :                                 //          CALL ShowWarningError(state, 'GetProjectData: '//TRIM(CurrentModuleObject)//'=''//  &
     968             :                                 //             TRIM(diagnosticName)//'', prior set=true for this condition reverts to false.')
     969             :                                 //        ENDIF
     970             :                                 //        CreateMinimalSurfaceVariables=.FALSE.
     971           0 :                             } else if (!diagnosticName.empty()) {
     972           0 :                                 ShowWarningError(state,
     973           0 :                                                  format("GetProjectData: {}=\"{}\", Invalid value for field, entered value ignored.",
     974             :                                                         CurrentModuleObject,
     975             :                                                         diagnosticName));
     976             :                             }
     977         178 :                         }
     978             :                     }
     979             : 
     980             :                     // Don't process the duplicate ones
     981          87 :                     break;
     982         174 :                 }
     983             :             }
     984         796 :         }
     985             : 
     986         796 :         CurrentModuleObject = "OutputControl:ReportingTolerances";
     987         796 :         Num = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     988         796 :         if (Num > 0) {
     989         162 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
     990             :                                                                      CurrentModuleObject,
     991             :                                                                      1,
     992             :                                                                      Alphas,
     993             :                                                                      NumAlpha,
     994             :                                                                      Number,
     995             :                                                                      NumNumber,
     996             :                                                                      IOStat,
     997          81 :                                                                      state.dataIPShortCut->lNumericFieldBlanks,
     998          81 :                                                                      state.dataIPShortCut->lAlphaFieldBlanks,
     999          81 :                                                                      state.dataIPShortCut->cAlphaFieldNames,
    1000          81 :                                                                      state.dataIPShortCut->cNumericFieldNames);
    1001          81 :             if (!state.dataIPShortCut->lNumericFieldBlanks(1)) {
    1002          81 :                 deviationFromSetPtThresholdHtg = -Number(1);
    1003             :             } else {
    1004           0 :                 deviationFromSetPtThresholdHtg = -0.2;
    1005             :             }
    1006          81 :             if (!state.dataIPShortCut->lNumericFieldBlanks(2)) {
    1007          81 :                 deviationFromSetPtThresholdClg = Number(2);
    1008             :             } else {
    1009           0 :                 deviationFromSetPtThresholdClg = 0.2;
    1010             :             }
    1011             :         }
    1012             : 
    1013         796 :         state.dataGlobal->DoZoneSizing = false;
    1014         796 :         state.dataGlobal->DoSystemSizing = false;
    1015         796 :         state.dataGlobal->DoPlantSizing = false;
    1016         796 :         state.dataGlobal->DoDesDaySim = true;
    1017         796 :         state.dataGlobal->DoWeathSim = true;
    1018         796 :         state.dataGlobal->DoHVACSizingSimulation = false;
    1019         796 :         state.dataGlobal->HVACSizingSimMaxIterations = 0;
    1020         796 :         CurrentModuleObject = "SimulationControl";
    1021         796 :         NumRunControl = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1022         796 :         if (NumRunControl > 0) {
    1023         788 :             state.dataSimulationManager->RunControlInInput = true;
    1024        1576 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1025             :                                                                      CurrentModuleObject,
    1026             :                                                                      1,
    1027             :                                                                      Alphas,
    1028             :                                                                      NumAlpha,
    1029             :                                                                      Number,
    1030             :                                                                      NumNumber,
    1031             :                                                                      IOStat,
    1032         788 :                                                                      state.dataIPShortCut->lNumericFieldBlanks,
    1033         788 :                                                                      state.dataIPShortCut->lAlphaFieldBlanks,
    1034         788 :                                                                      state.dataIPShortCut->cAlphaFieldNames,
    1035         788 :                                                                      state.dataIPShortCut->cNumericFieldNames);
    1036         788 :             if (Alphas(1) == "YES") state.dataGlobal->DoZoneSizing = true;
    1037         788 :             if (Alphas(2) == "YES") state.dataGlobal->DoSystemSizing = true;
    1038         788 :             if (Alphas(3) == "YES") state.dataGlobal->DoPlantSizing = true;
    1039         788 :             if (Alphas(4) == "NO") state.dataGlobal->DoDesDaySim = false;
    1040         788 :             if (Alphas(5) == "NO") state.dataGlobal->DoWeathSim = false;
    1041         788 :             if (NumAlpha > 5) {
    1042         788 :                 if (Alphas(6) == "YES") state.dataGlobal->DoHVACSizingSimulation = true;
    1043             :             }
    1044             :         }
    1045         796 :         if (state.dataSysVars->DDOnly) {
    1046         790 :             state.dataGlobal->DoDesDaySim = true;
    1047         790 :             state.dataGlobal->DoWeathSim = false;
    1048             :         }
    1049         796 :         if (state.dataSysVars->FullAnnualRun) {
    1050           6 :             state.dataGlobal->DoDesDaySim = false;
    1051           6 :             state.dataGlobal->DoWeathSim = true;
    1052             :         }
    1053             : 
    1054         796 :         if ((!state.dataGlobal->DoDesDaySim && !state.dataGlobal->DoWeathSim && !state.dataGlobal->DoHVACSizingSimulation) &&
    1055           0 :             (state.dataGlobal->DoZoneSizing || state.dataGlobal->DoSystemSizing)) {
    1056           0 :             state.dataGlobal->DoPureLoadCalc = true;
    1057             :         }
    1058             : 
    1059         796 :         CurrentModuleObject = "PerformancePrecisionTradeoffs";
    1060         796 :         auto const instances = state.dataInputProcessing->inputProcessor->epJSON.find(CurrentModuleObject);
    1061         796 :         Num = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1062         796 :         if (Num > 1) {
    1063           0 :             ErrorsFound = true;
    1064           0 :             ShowFatalError(state, format("GetProjectData: Only one (\"1\") {} object per simulation is allowed.", CurrentModuleObject));
    1065             :         }
    1066         796 :         state.dataGlobal->createPerfLog = Num > 0;
    1067         796 :         std::string overrideModeValue = "Normal";
    1068         796 :         if (instances != state.dataInputProcessing->inputProcessor->epJSON.end()) {
    1069           3 :             auto &instancesValue = instances.value();
    1070           6 :             for (auto instance = instancesValue.begin(); instance != instancesValue.end(); ++instance) {
    1071           3 :                 auto const &fields = instance.value();
    1072           3 :                 std::string const &thisObjectName = instance.key();
    1073           3 :                 state.dataInputProcessing->inputProcessor->markObjectAsUsed(CurrentModuleObject, thisObjectName);
    1074           3 :                 if (fields.find("use_coil_direct_solutions") != fields.end()) {
    1075           3 :                     state.dataGlobal->DoCoilDirectSolutions = Util::makeUPPER(fields.at("use_coil_direct_solutions").get<std::string>()) == "YES";
    1076             :                 }
    1077           3 :                 if (fields.find("zone_radiant_exchange_algorithm") != fields.end()) {
    1078           2 :                     state.dataHeatBalIntRadExchg->CarrollMethod =
    1079           4 :                         Util::makeUPPER(fields.at("zone_radiant_exchange_algorithm").get<std::string>()) == "CARROLLMRT";
    1080             :                 }
    1081           3 :                 if (fields.find("use_representative_surfaces_for_calculations") != fields.end()) {
    1082           1 :                     state.dataSurface->UseRepresentativeSurfaceCalculations =
    1083           2 :                         Util::makeUPPER(fields.at("use_representative_surfaces_for_calculations").get<std::string>()) == "YES";
    1084             :                 }
    1085           3 :                 bool overrideTimestep(false);
    1086           3 :                 bool overrideZoneAirHeatBalAlg(false);
    1087           3 :                 bool overrideMinNumWarmupDays(false);
    1088           3 :                 bool overrideBeginEnvResetSuppress(false);
    1089           3 :                 bool overrideMaxZoneTempDiff(false);
    1090           3 :                 bool overrideSystemTimestep(false);
    1091           3 :                 bool overrideMaxAllowedDelTemp(false);
    1092           3 :                 bool overridePsychTsatFnPb(false);
    1093           3 :                 state.dataZoneTempPredictorCorrector->OscillationVariablesNeeded = true;
    1094           3 :                 if (fields.find("override_mode") != fields.end()) {
    1095           1 :                     overrideModeValue = Util::makeUPPER(fields.at("override_mode").get<std::string>());
    1096           1 :                     if (overrideModeValue == "NORMAL") {
    1097             :                         // no overrides
    1098           1 :                     } else if (overrideModeValue == "MODE01") {
    1099             :                         // Zone Time step (TimeStep object) will be set to one timestep per hour
    1100           0 :                         overrideTimestep = true;
    1101           1 :                     } else if (overrideModeValue == "MODE02") {
    1102             :                         // Mode01 plus ZoneAirHeatBalanceAlgorithm will be set to Euler
    1103           0 :                         overrideTimestep = true;
    1104           0 :                         overrideZoneAirHeatBalAlg = true;
    1105           1 :                     } else if (overrideModeValue == "MODE03") {
    1106             :                         // Mode02 plus Minimum Number of Warmup Days will be set to 1
    1107           0 :                         overrideTimestep = true;
    1108           0 :                         overrideZoneAirHeatBalAlg = true;
    1109           0 :                         overrideMinNumWarmupDays = true;
    1110           1 :                     } else if (overrideModeValue == "MODE04") {
    1111             :                         // Mode03 plus Begin Environment Reset Mode will be set to SuppressAllBeginEnvironmentResets
    1112           0 :                         overrideTimestep = true;
    1113           0 :                         overrideZoneAirHeatBalAlg = true;
    1114           0 :                         overrideMinNumWarmupDays = true;
    1115           0 :                         overrideBeginEnvResetSuppress = true;
    1116           1 :                     } else if (overrideModeValue == "MODE05") {
    1117             :                         // Mode04 plus Minimun System Timestep will be set to 1hr
    1118           0 :                         overrideTimestep = true;
    1119           0 :                         overrideZoneAirHeatBalAlg = true;
    1120           0 :                         overrideMinNumWarmupDays = true;
    1121           0 :                         overrideBeginEnvResetSuppress = true;
    1122           0 :                         overrideSystemTimestep = true;
    1123           1 :                     } else if (overrideModeValue == "MODE06") {
    1124             :                         // Mode05 plus cubic spline interpolations in replacement of the original psychrometric function PsychTsatFnPb
    1125           0 :                         overrideTimestep = true;
    1126           0 :                         overrideZoneAirHeatBalAlg = true;
    1127           0 :                         overrideMinNumWarmupDays = true;
    1128           0 :                         overrideBeginEnvResetSuppress = true;
    1129           0 :                         overrideSystemTimestep = true;
    1130           0 :                         overridePsychTsatFnPb = true;
    1131           1 :                     } else if (overrideModeValue == "MODE07") {
    1132             :                         // Mode06 plus internal variable MaxZoneTempDiff will be set to 1.00
    1133           0 :                         overrideTimestep = true;
    1134           0 :                         overrideZoneAirHeatBalAlg = true;
    1135           0 :                         overrideMinNumWarmupDays = true;
    1136           0 :                         overrideBeginEnvResetSuppress = true;
    1137           0 :                         overrideSystemTimestep = true;
    1138           0 :                         overrideMaxZoneTempDiff = true;
    1139           0 :                         overridePsychTsatFnPb = true;
    1140           1 :                     } else if (overrideModeValue == "MODE08") {
    1141             :                         // Mode07 plus internal variable MaxAllowedDelTemp will be set to 0.1
    1142           1 :                         overrideTimestep = true;
    1143           1 :                         overrideZoneAirHeatBalAlg = true;
    1144           1 :                         overrideMinNumWarmupDays = true;
    1145           1 :                         overrideBeginEnvResetSuppress = true;
    1146           1 :                         overrideSystemTimestep = true;
    1147           1 :                         overrideMaxZoneTempDiff = true;
    1148           1 :                         overrideMaxAllowedDelTemp = true;
    1149           1 :                         overridePsychTsatFnPb = true;
    1150           0 :                     } else if (overrideModeValue == "ADVANCED") {
    1151           0 :                         bool advancedModeUsed = false;
    1152           0 :                         if (fields.find("maxzonetempdiff") != fields.end()) { // not required field, has default value
    1153           0 :                             state.dataConvergeParams->MaxZoneTempDiff = fields.at("maxzonetempdiff").get<Real64>();
    1154           0 :                             ShowWarningError(state,
    1155           0 :                                              format("PerformancePrecisionTradeoffs using the Advanced Override Mode, MaxZoneTempDiff set to: {:.4R}",
    1156           0 :                                                     state.dataConvergeParams->MaxZoneTempDiff));
    1157           0 :                             advancedModeUsed = true;
    1158             :                         }
    1159           0 :                         if (fields.find("maxalloweddeltemp") != fields.end()) { // not required field, has default value
    1160           0 :                             state.dataHeatBal->MaxAllowedDelTemp = fields.at("maxalloweddeltemp").get<Real64>();
    1161           0 :                             ShowWarningError(
    1162             :                                 state,
    1163           0 :                                 format("PerformancePrecisionTradeoffs using the Advanced Override Mode, MaxAllowedDelTemp set to: {:.4R}",
    1164           0 :                                        state.dataHeatBal->MaxAllowedDelTemp));
    1165           0 :                             advancedModeUsed = true;
    1166             :                         }
    1167           0 :                         if (advancedModeUsed) {
    1168           0 :                             ShowContinueError(state,
    1169             :                                               "...Care should be used when using the Advanced Override Mode. Results may be significantly different "
    1170             :                                               "than a simulation not using this mode.");
    1171             :                         } else {
    1172           0 :                             ShowWarningError(
    1173             :                                 state, "PerformancePrecisionTradeoffs using the Advanced Override Mode but no specific parameters have been set.");
    1174             :                         }
    1175             :                     } else {
    1176           0 :                         ShowSevereError(state,
    1177           0 :                                         format("Invalid over ride mode specified in PerformancePrecisionTradeoffs object: {}", overrideModeValue));
    1178             :                     }
    1179             : 
    1180           1 :                     if (overrideTimestep) {
    1181           1 :                         ShowWarningError(state, "Due to PerformancePrecisionTradeoffs Override Mode, the Number of TimeSteps has been changed to 1.");
    1182           1 :                         state.dataGlobal->NumOfTimeStepInHour = 1;
    1183           1 :                         state.dataGlobal->TimeStepZone = 1.0 / double(state.dataGlobal->NumOfTimeStepInHour);
    1184           1 :                         state.dataGlobal->MinutesPerTimeStep = state.dataGlobal->TimeStepZone * 60;
    1185           1 :                         state.dataGlobal->TimeStepZoneSec = state.dataGlobal->TimeStepZone * Constant::SecInHour;
    1186           1 :                         state.dataGlobal->OverrideTimestep = true;
    1187             :                     }
    1188           1 :                     if (overrideZoneAirHeatBalAlg) {
    1189           1 :                         ShowWarningError(
    1190             :                             state,
    1191             :                             "Due to PerformancePrecisionTradeoffs Override Mode, the ZoneAirHeatBalanceAlgorithm has been changed to EulerMethod.");
    1192           1 :                         state.dataHeatBal->OverrideZoneAirSolutionAlgo = true;
    1193             :                     }
    1194           1 :                     if (overrideMinNumWarmupDays) {
    1195           1 :                         ShowWarningError(
    1196             :                             state, "Due to PerformancePrecisionTradeoffs Override Mode, the Minimum Number of Warmup Days has been changed to 1.");
    1197           1 :                         state.dataHeatBal->MinNumberOfWarmupDays = 1;
    1198             :                     }
    1199           1 :                     if (overrideBeginEnvResetSuppress) {
    1200           1 :                         ShowWarningError(state,
    1201             :                                          "Due to PerformancePrecisionTradeoffs Override Mode, the Begin Environment Reset Mode has been changed to "
    1202             :                                          "SuppressAllBeginEnvironmentResets.");
    1203           1 :                         state.dataEnvrn->forceBeginEnvResetSuppress = true;
    1204             :                     }
    1205           1 :                     if (overrideSystemTimestep) {
    1206           1 :                         ShowWarningError(
    1207             :                             state, "Due to PerformancePrecisionTradeoffs Override Mode, the minimum System TimeSteps has been changed to 1 hr.");
    1208           1 :                         int MinTimeStepSysOverrideValue = 60.0;
    1209           1 :                         if (MinTimeStepSysOverrideValue > state.dataGlobal->MinutesPerTimeStep) {
    1210           0 :                             MinTimeStepSysOverrideValue = state.dataGlobal->MinutesPerTimeStep;
    1211             :                         }
    1212           1 :                         state.dataConvergeParams->MinTimeStepSys = MinTimeStepSysOverrideValue / 60.0;
    1213           1 :                         state.dataHVACGlobal->LimitNumSysSteps = int(state.dataGlobal->TimeStepZone / state.dataConvergeParams->MinTimeStepSys);
    1214             :                     }
    1215           1 :                     if (overridePsychTsatFnPb) {
    1216           1 :                         ShowWarningError(state,
    1217             :                                          "Due to PerformancePrecisionTradeoffs Override Mode, the saturated temperature will be calculated using "
    1218             :                                          "cubic spline interpolations in replacement of PsychTsatFnPb .");
    1219             :                         // Mode06 CSpline interpolation (64 Pa bin size + 20/16 bit)
    1220           1 :                         state.dataPsychrometrics->useInterpolationPsychTsatFnPb = true;
    1221             : #ifdef EP_cache_PsyTsatFnPb
    1222           1 :                         state.dataPsychCache->tsatprecision_bits = 20;
    1223             : #endif
    1224             :                     }
    1225           1 :                     if (overrideMaxZoneTempDiff) {
    1226           1 :                         ShowWarningError(
    1227             :                             state, "Due to PerformancePrecisionTradeoffs Override Mode, internal variable MaxZoneTempDiff will be set to 1.0 .");
    1228           1 :                         state.dataConvergeParams->MaxZoneTempDiff = 1.0;
    1229             :                     }
    1230           1 :                     if (overrideMaxAllowedDelTemp) {
    1231           1 :                         ShowWarningError(
    1232             :                             state, "Due to PerformancePrecisionTradeoffs Override Mode, internal variable MaxAllowedDelTemp will be set to 0.1 .");
    1233           1 :                         state.dataHeatBal->MaxAllowedDelTemp = 0.1;
    1234             :                     }
    1235             :                 }
    1236           3 :             }
    1237             :         }
    1238         796 :         if (ErrorsFound) {
    1239           0 :             ShowFatalError(state, "Errors found getting Project Input");
    1240             :         }
    1241             : 
    1242         796 :         print(state.files.eio, "{}\n", "! <Version>, Version ID");
    1243             :         static constexpr std::string_view Format_721(" Version, {}\n");
    1244         796 :         print(state.files.eio, Format_721, VersionID);
    1245             : 
    1246         796 :         print(state.files.eio, "{}\n", "! <Timesteps per Hour>, #TimeSteps, Minutes per TimeStep {minutes}");
    1247             :         static constexpr std::string_view Format_731(" Timesteps per Hour, {:2}, {:2}\n");
    1248         796 :         print(state.files.eio, Format_731, state.dataGlobal->NumOfTimeStepInHour, state.dataGlobal->MinutesPerTimeStep);
    1249             : 
    1250         796 :         print(state.files.eio,
    1251             :               "{}\n",
    1252             :               "! <System Convergence Limits>, Minimum System TimeStep {minutes}, Max HVAC Iterations, Minimum Plant "
    1253             :               "Iterations, Maximum Plant Iterations");
    1254         796 :         MinInt = state.dataConvergeParams->MinTimeStepSys * 60.0;
    1255             :         static constexpr std::string_view Format_733(" System Convergence Limits, {}, {}, {}, {}\n");
    1256         796 :         print(state.files.eio,
    1257             :               Format_733,
    1258             :               MinInt,
    1259         796 :               state.dataConvergeParams->MaxIter,
    1260         796 :               state.dataConvergeParams->MinPlantSubIterations,
    1261         796 :               state.dataConvergeParams->MaxPlantSubIterations);
    1262             : 
    1263         796 :         if (state.dataGlobal->DoZoneSizing) {
    1264         424 :             Alphas(1) = "Yes";
    1265             :         } else {
    1266         372 :             Alphas(1) = "No";
    1267             :         }
    1268         796 :         if (state.dataGlobal->DoSystemSizing) {
    1269         371 :             Alphas(2) = "Yes";
    1270             :         } else {
    1271         425 :             Alphas(2) = "No";
    1272             :         }
    1273         796 :         if (state.dataGlobal->DoPlantSizing) {
    1274         227 :             Alphas(3) = "Yes";
    1275             :         } else {
    1276         569 :             Alphas(3) = "No";
    1277             :         }
    1278         796 :         if (state.dataGlobal->DoDesDaySim) {
    1279         790 :             Alphas(4) = "Yes";
    1280             :         } else {
    1281           6 :             Alphas(4) = "No";
    1282             :         }
    1283         796 :         if (state.dataGlobal->DoWeathSim) {
    1284           6 :             Alphas(5) = "Yes";
    1285             :         } else {
    1286         790 :             Alphas(5) = "No";
    1287             :         }
    1288         796 :         if (state.dataGlobal->DoHVACSizingSimulation) {
    1289          12 :             Alphas(6) = "Yes";
    1290          12 :             if (NumNumber >= 1) {
    1291          12 :                 state.dataGlobal->HVACSizingSimMaxIterations = Number(1);
    1292             :             }
    1293             :         } else {
    1294         784 :             Alphas(6) = "No";
    1295             :         }
    1296             : 
    1297         796 :         print(state.files.eio,
    1298             :               "{}\n",
    1299             :               "! <Simulation Control>, Do Zone Sizing, Do System Sizing, Do Plant Sizing, Do Design Days, Do Weather "
    1300             :               "Simulation, Do HVAC Sizing Simulation");
    1301         796 :         print(state.files.eio, " Simulation Control");
    1302        5572 :         for (Num = 1; Num <= 6; ++Num) {
    1303        4776 :             print(state.files.eio, ", {}", Alphas(Num));
    1304             :         }
    1305         796 :         print(state.files.eio, "\n");
    1306             : 
    1307             :         // Performance Precision Tradeoffs
    1308         796 :         if (state.dataGlobal->DoCoilDirectSolutions) {
    1309           2 :             Alphas(1) = "Yes";
    1310           2 :             ShowWarningError(state, "PerformancePrecisionTradeoffs: Coil Direct Solution simulation is selected.");
    1311             :         } else {
    1312         794 :             Alphas(1) = "No";
    1313             :         }
    1314         796 :         if (state.dataHeatBalIntRadExchg->CarrollMethod) {
    1315           1 :             Alphas(2) = "CarrollMRT";
    1316           1 :             ShowWarningError(state, "PerformancePrecisionTradeoffs: Carroll MRT radiant exchange method is selected.");
    1317             :         } else {
    1318         795 :             Alphas(2) = "ScriptF";
    1319             :         }
    1320         796 :         Alphas(3) = overrideModeValue;
    1321         796 :         Alphas(4) = fmt::to_string(state.dataGlobal->NumOfTimeStepInHour);
    1322         796 :         if (state.dataHeatBal->OverrideZoneAirSolutionAlgo) {
    1323           1 :             Alphas(5) = "Yes";
    1324             :         } else {
    1325         795 :             Alphas(5) = "No";
    1326             :         }
    1327         796 :         Alphas(6) = fmt::to_string(state.dataHeatBal->MinNumberOfWarmupDays);
    1328         796 :         if (state.dataEnvrn->forceBeginEnvResetSuppress) {
    1329           1 :             Alphas(7) = "Yes";
    1330             :         } else {
    1331         795 :             Alphas(7) = "No";
    1332             :         }
    1333         796 :         Alphas(8) = format("{:.1R}", state.dataConvergeParams->MinTimeStepSys * 60.0);
    1334         796 :         Alphas(9) = format("{:.3R}", state.dataConvergeParams->MaxZoneTempDiff);
    1335         796 :         Alphas(10) = format("{:.4R}", state.dataHeatBal->MaxAllowedDelTemp);
    1336             :         std::string pptHeader = "! <Performance Precision Tradeoffs>, Use Coil Direct Simulation, "
    1337             :                                 "Zone Radiant Exchange Algorithm, Override Mode, Number of Timestep In Hour, "
    1338             :                                 "Force Euler Method, Minimum Number of Warmup Days, Force Suppress All Begin Environment Resets, "
    1339         796 :                                 "Minimum System Timestep, MaxZoneTempDiff, MaxAllowedDelTemp";
    1340         796 :         print(state.files.eio, "{}\n", pptHeader);
    1341         796 :         print(state.files.eio, " Performance Precision Tradeoffs");
    1342        8756 :         for (Num = 1; Num <= 10; ++Num) {
    1343        7960 :             print(state.files.eio, ", {}", Alphas(Num));
    1344             :         }
    1345         796 :         print(state.files.eio, "\n");
    1346             : 
    1347         796 :         print(state.files.eio,
    1348             :               "{}\n",
    1349             :               "! <Output Reporting Tolerances>, Tolerance for Time Heating Setpoint Not Met, Tolerance for Zone Cooling Setpoint Not Met Time");
    1350             :         // Formats
    1351             :         static constexpr std::string_view Format_751(" Output Reporting Tolerances, {:.3R}, {:.3R}, \n");
    1352             : 
    1353         796 :         print(state.files.eio, Format_751, std::abs(deviationFromSetPtThresholdHtg), deviationFromSetPtThresholdClg);
    1354             : 
    1355             :         //  IF (DisplayExtraWarnings) THEN
    1356             :         //    Write(OutputFileInits,740)
    1357             :         //    Write(OutputFileInits,741) (TRIM(Alphas(Num)),Num=1,5)
    1358             :         // 742 Format('! <Display Extra Warnings>, Display Advanced Report Variables, Do Not Mirror Detached Shading')
    1359             :         //    IF (DisplayAdvancedReportVariables) THEN
    1360             :         //      NumOut1='Yes'
    1361             :         //    ELSE
    1362             :         //      NumOut2='No'
    1363             :         //    ENDIF
    1364             :         //    IF (.not. MakeMirroredDetachedShading) THEN
    1365             :         //      NumOut1='Yes'
    1366             :         //    ELSE
    1367             :         //      NumOut2='No'
    1368             :         //    ENDIF
    1369             :         // unused0909743 Format(' Display Extra Warnings',2(', ',A))
    1370             :         //  ENDIF
    1371         796 :         if (state.dataGlobal->createPerfLog) {
    1372           3 :             writeIntialPerfLogValues(state, overrideModeValue);
    1373             :         }
    1374         796 :     }
    1375             : 
    1376           3 :     void writeIntialPerfLogValues(EnergyPlusData &state, std::string const &currentOverrideModeValue)
    1377             :     // write the input related portions of the .perflog
    1378             :     // J.Glazer February 2020
    1379             :     {
    1380           3 :         Util::appendPerfLog(state,
    1381             :                             "Program, Version, TimeStamp",
    1382           3 :                             state.dataStrGlobals->VerStringVar); // this string already includes three portions and has commas
    1383           3 :         Util::appendPerfLog(state, "Use Coil Direct Solution", bool_to_string(state.dataGlobal->DoCoilDirectSolutions));
    1384           3 :         if (state.dataHeatBalIntRadExchg->CarrollMethod) {
    1385           1 :             Util::appendPerfLog(state, "Zone Radiant Exchange Algorithm", "CarrollMRT");
    1386             :         } else {
    1387           2 :             Util::appendPerfLog(state, "Zone Radiant Exchange Algorithm", "ScriptF");
    1388             :         }
    1389           3 :         Util::appendPerfLog(state, "Override Mode", currentOverrideModeValue);
    1390           3 :         Util::appendPerfLog(state, "Number of Timesteps per Hour", fmt::to_string(state.dataGlobal->NumOfTimeStepInHour));
    1391           3 :         Util::appendPerfLog(state, "Minimum Number of Warmup Days", fmt::to_string(state.dataHeatBal->MinNumberOfWarmupDays));
    1392           3 :         Util::appendPerfLog(state, "SuppressAllBeginEnvironmentResets", bool_to_string(state.dataEnvrn->forceBeginEnvResetSuppress));
    1393           3 :         Util::appendPerfLog(state, "Minimum System Timestep", format("{:.1R}", state.dataConvergeParams->MinTimeStepSys * 60.0));
    1394           3 :         Util::appendPerfLog(state, "MaxZoneTempDiff", format("{:.2R}", state.dataConvergeParams->MaxZoneTempDiff));
    1395           3 :         Util::appendPerfLog(state, "MaxAllowedDelTemp", format("{:.4R}", state.dataHeatBal->MaxAllowedDelTemp));
    1396           3 :     }
    1397             : 
    1398           6 :     std::string bool_to_string(bool logical)
    1399             :     {
    1400           6 :         if (logical) {
    1401           3 :             return ("True");
    1402             :         } else {
    1403           3 :             return ("False");
    1404             :         }
    1405             :     }
    1406             : 
    1407         796 :     void CheckForMisMatchedEnvironmentSpecifications(EnergyPlusData &state)
    1408             :     {
    1409             : 
    1410             :         // SUBROUTINE INFORMATION:
    1411             :         //       AUTHOR         Linda Lawrie
    1412             :         //       DATE WRITTEN   August 2008
    1413             :         //       MODIFIED       na
    1414             :         //       RE-ENGINEERED  na
    1415             : 
    1416             :         // PURPOSE OF THIS SUBROUTINE:
    1417             :         // In response to CR 7518, this routine will check to see if a proper combination of SimulationControl, RunPeriod,
    1418             :         // SizingPeriod:*, etc are entered to proceed with a simulation.
    1419             : 
    1420             :         // METHODOLOGY EMPLOYED:
    1421             :         // For now (8/2008), the routine will query several objects in the input.  And try to produce warnings or
    1422             :         // fatals as a result.
    1423             : 
    1424             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1425             :         int NumZoneSizing;
    1426             :         int NumSystemSizing;
    1427             :         int NumPlantSizing;
    1428             :         int NumDesignDays;
    1429             :         int NumRunPeriodDesign;
    1430             :         int NumSizingDays;
    1431             :         bool WeatherFileAttached;
    1432             :         bool ErrorsFound;
    1433             : 
    1434         796 :         ErrorsFound = false;
    1435         796 :         NumZoneSizing = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Sizing:Zone");
    1436         796 :         NumSystemSizing = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Sizing:System");
    1437         796 :         NumPlantSizing = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Sizing:Plant");
    1438         796 :         NumDesignDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay");
    1439         796 :         NumRunPeriodDesign = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays") +
    1440         796 :                              state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileConditionType");
    1441         796 :         NumSizingDays = NumDesignDays + NumRunPeriodDesign;
    1442             : 
    1443         796 :         WeatherFileAttached = FileSystem::fileExists(state.files.inputWeatherFilePath.filePath);
    1444             : 
    1445         796 :         if (state.dataSimulationManager->RunControlInInput) {
    1446         788 :             if (state.dataGlobal->DoZoneSizing) {
    1447         424 :                 if (NumZoneSizing > 0 && NumSizingDays == 0) {
    1448           0 :                     ErrorsFound = true;
    1449           0 :                     ShowSevereError(
    1450             :                         state, "CheckEnvironmentSpecifications: Sizing for Zones has been requested but there are no design environments specified.");
    1451           0 :                     ShowContinueError(state, "...Add appropriate SizingPeriod:* objects for your simulation.");
    1452             :                 }
    1453         424 :                 if (NumZoneSizing > 0 && NumRunPeriodDesign > 0 && !WeatherFileAttached) {
    1454           0 :                     ErrorsFound = true;
    1455           0 :                     ShowSevereError(state,
    1456             :                                     "CheckEnvironmentSpecifications: Sizing for Zones has been requested; Design period from the weather file "
    1457             :                                     "requested; but no weather file specified.");
    1458             :                 }
    1459             :             }
    1460         788 :             if (state.dataGlobal->DoSystemSizing) {
    1461         371 :                 if (NumSystemSizing > 0 && NumSizingDays == 0) {
    1462           0 :                     ErrorsFound = true;
    1463           0 :                     ShowSevereError(
    1464             :                         state,
    1465             :                         "CheckEnvironmentSpecifications: Sizing for Systems has been requested but there are no design environments specified.");
    1466           0 :                     ShowContinueError(state, "...Add appropriate SizingPeriod:* objects for your simulation.");
    1467             :                 }
    1468         371 :                 if (NumSystemSizing > 0 && NumRunPeriodDesign > 0 && !WeatherFileAttached) {
    1469           0 :                     ErrorsFound = true;
    1470           0 :                     ShowSevereError(state,
    1471             :                                     "CheckEnvironmentSpecifications: Sizing for Systems has been requested; Design period from the weather file "
    1472             :                                     "requested; but no weather file specified.");
    1473             :                 }
    1474             :             }
    1475         788 :             if (state.dataGlobal->DoPlantSizing) {
    1476         227 :                 if (NumPlantSizing > 0 && NumSizingDays == 0) {
    1477           0 :                     ErrorsFound = true;
    1478           0 :                     ShowSevereError(state,
    1479             :                                     "CheckEnvironmentSpecifications: Sizing for Equipment/Plants has been requested but there are no design "
    1480             :                                     "environments specified.");
    1481           0 :                     ShowContinueError(state, "...Add appropriate SizingPeriod:* objects for your simulation.");
    1482             :                 }
    1483         227 :                 if (NumPlantSizing > 0 && NumRunPeriodDesign > 0 && !WeatherFileAttached) {
    1484           0 :                     ErrorsFound = true;
    1485           0 :                     ShowSevereError(state,
    1486             :                                     "CheckEnvironmentSpecifications: Sizing for Equipment/Plants has been requested; Design period from the weather "
    1487             :                                     "file requested; but no weather file specified.");
    1488             :                 }
    1489             :             }
    1490         788 :             if (state.dataGlobal->DoDesDaySim && NumSizingDays == 0) {
    1491           0 :                 ShowWarningError(state,
    1492             :                                  "CheckEnvironmentSpecifications: SimulationControl specified doing design day simulations, but no design "
    1493             :                                  "environments specified.");
    1494           0 :                 ShowContinueError(
    1495             :                     state,
    1496             :                     "...No design environment results produced. For these results, add appropriate SizingPeriod:* objects for your simulation.");
    1497             :             }
    1498         788 :             if (state.dataGlobal->DoDesDaySim && NumRunPeriodDesign > 0 && !WeatherFileAttached) {
    1499           0 :                 ErrorsFound = true;
    1500           0 :                 ShowSevereError(state,
    1501             :                                 "CheckEnvironmentSpecifications: SimulationControl specified doing design day simulations; weather file design "
    1502             :                                 "environments specified; but no weather file specified.");
    1503             :             }
    1504         788 :             if (state.dataGlobal->DoWeathSim && !state.dataSimulationManager->RunPeriodsInInput) {
    1505           0 :                 ShowWarningError(state,
    1506             :                                  "CheckEnvironmentSpecifications: SimulationControl specified doing weather simulations, but no run periods for "
    1507             :                                  "weather file specified.  No annual results produced.");
    1508             :             }
    1509         788 :             if (state.dataGlobal->DoWeathSim && state.dataSimulationManager->RunPeriodsInInput && !WeatherFileAttached) {
    1510           0 :                 ShowWarningError(state,
    1511             :                                  "CheckEnvironmentSpecifications: SimulationControl specified doing weather simulations; run periods for weather "
    1512             :                                  "file specified; but no weather file specified.");
    1513             :             }
    1514             :         }
    1515             : 
    1516         796 :         if (!state.dataGlobal->DoDesDaySim && !state.dataGlobal->DoWeathSim) {
    1517             :             // This amounts to checking: (!DoHVACSizingSimulation && !DoZoneSizing && !DoSystemSizing)
    1518           0 :             if (!state.dataGlobal->DoHVACSizingSimulation && !state.dataGlobal->DoPureLoadCalc) {
    1519           0 :                 ShowSevereError(state, "All elements of SimulationControl are set to \"No\". No simulations can be done. Program terminates.");
    1520           0 :                 ErrorsFound = true;
    1521             :             } else {
    1522           0 :                 ShowWarningError(state,
    1523             :                                  "\"Run Simulation for Sizing Periods\" and \"Run Simulation for Weather File Run Periods\" are both set to \"No\". "
    1524             :                                  "No simulations will be performed, and most input will not be read.");
    1525             :             }
    1526             :         }
    1527             : 
    1528         796 :         if (ErrorsFound) {
    1529           0 :             ShowFatalError(state, "Program terminates due to preceding conditions.");
    1530             :         }
    1531         796 :     }
    1532             : 
    1533         796 :     void CheckForRequestedReporting(EnergyPlusData &state)
    1534             :     {
    1535             : 
    1536             :         // SUBROUTINE INFORMATION:
    1537             :         //       AUTHOR         Linda Lawrie
    1538             :         //       DATE WRITTEN   January 2009
    1539             :         //       MODIFIED       na
    1540             :         //       RE-ENGINEERED  na
    1541             : 
    1542             :         // PURPOSE OF THIS SUBROUTINE:
    1543             :         // EnergyPlus does not automatically produce any results files.  Because of this, users may not request
    1544             :         // reports and may get confused when nothing is produced.  This routine will provide a warning when
    1545             :         // results should be produced (either sizing periods or weather files are run) but no reports are
    1546             :         // requested.
    1547             : 
    1548             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1549             :         bool SimPeriods;
    1550             :         bool ReportingRequested;
    1551             : 
    1552         796 :         ReportingRequested = false;
    1553         796 :         SimPeriods = (state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay") > 0 ||
    1554           0 :                       state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays") > 0 ||
    1555         796 :                       state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileConditionType") > 0 ||
    1556           0 :                       state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "RunPeriod") > 0);
    1557             : 
    1558         796 :         if ((state.dataGlobal->DoDesDaySim || state.dataGlobal->DoWeathSim || state.dataGlobal->DoPureLoadCalc) && SimPeriods) {
    1559         796 :             ReportingRequested = (state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:SummaryReports") > 0 ||
    1560          40 :                                   state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:TimeBins") > 0 ||
    1561          40 :                                   state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:Monthly") > 0 ||
    1562          40 :                                   state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:Annual") > 0 ||
    1563          40 :                                   state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Variable") > 0 ||
    1564           0 :                                   state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter") > 0 ||
    1565           0 :                                   state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter:MeterFileOnly") > 0 ||
    1566         836 :                                   state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter:Cumulative") > 0 ||
    1567           0 :                                   state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter:Cumulative:MeterFileOnly") > 0);
    1568             :             // Not testing for : Output:SQLite or Output:EnvironmentalImpactFactors
    1569         796 :             if (!ReportingRequested) {
    1570           0 :                 ShowWarningError(state, "No reporting elements have been requested. No simulation results produced.");
    1571           0 :                 ShowContinueError(state,
    1572             :                                   "...Review requirements such as \"Output:Table:SummaryReports\", \"Output:Table:Monthly\", \"Output:Variable\", "
    1573             :                                   "\"Output:Meter\" and others.");
    1574             :             }
    1575             :         }
    1576         796 :     }
    1577             : 
    1578           0 :     std::unique_ptr<std::ostream> OpenStreamFile(EnergyPlusData &state, const fs::path &filePath, std::ios_base::openmode mode)
    1579             :     {
    1580           0 :         auto result = std::make_unique<std::ofstream>(filePath, mode); // (AUTO_OK_UPTR)
    1581           0 :         if (!result->good()) {
    1582           0 :             ShowFatalError(state, format("OpenOutputFiles: Could not open file {} for output (write).", filePath));
    1583             :         }
    1584           0 :         return result;
    1585           0 :     }
    1586             : 
    1587           0 :     std::unique_ptr<fmt::ostream> OpenFmtStreamFile(EnergyPlusData &state, const fs::path &filePath)
    1588             :     {
    1589           0 :         std::unique_ptr<fmt::ostream> result = nullptr;
    1590             : #ifdef _WIN32
    1591             :         std::string filePathStr = FileSystem::toString(filePath);
    1592             :         const char *path = filePathStr.c_str();
    1593             : #else
    1594           0 :         const char *path = filePath.c_str();
    1595             : #endif
    1596             :         try {
    1597           0 :             auto f = fmt::output_file(path, fmt::buffer_size = (2 << 17)); // (AUTO_OK_OBJ)
    1598           0 :             result = std::make_unique<fmt::ostream>(std::move(f));
    1599           0 :         } catch (const std::system_error &error) {
    1600           0 :             ShowSevereError(state, error.what());
    1601           0 :             ShowFatalError(state, format("OpenOutputFiles: Could not open file {} for output (write).", filePath));
    1602           0 :         }
    1603           0 :         return result;
    1604           0 :     }
    1605             : 
    1606         796 :     void OpenOutputFiles(EnergyPlusData &state)
    1607             :     {
    1608             : 
    1609             :         // SUBROUTINE INFORMATION:
    1610             :         //       AUTHOR         Rick Strand
    1611             :         //       DATE WRITTEN   June 1997
    1612             :         //       MODIFIED       na
    1613             :         //       RE-ENGINEERED  na
    1614             : 
    1615             :         // PURPOSE OF THIS SUBROUTINE:
    1616             :         // This subroutine opens all of the input and output files needed for
    1617             :         // an EnergyPlus run.
    1618             : 
    1619         796 :         state.dataGlobal->StdOutputRecordCount = 0;
    1620         796 :         state.files.eso.ensure_open(state, "OpenOutputFiles", state.files.outputControl.eso);
    1621         796 :         print(state.files.eso, "Program Version,{}\n", state.dataStrGlobals->VerStringVar);
    1622             : 
    1623             :         // Open the Initialization Output File
    1624         796 :         state.files.eio.ensure_open(state, "OpenOutputFiles", state.files.outputControl.eio);
    1625         796 :         print(state.files.eio, "Program Version,{}\n", state.dataStrGlobals->VerStringVar);
    1626             : 
    1627             :         // Open the Meters Output File
    1628         796 :         state.files.mtr.ensure_open(state, "OpenOutputFiles", state.files.outputControl.mtr);
    1629         796 :         print(state.files.mtr, "Program Version,{}\n", state.dataStrGlobals->VerStringVar);
    1630             : 
    1631             :         // Open the Branch-Node Details Output File
    1632         796 :         state.files.bnd.ensure_open(state, "OpenOutputFiles", state.files.outputControl.bnd);
    1633         796 :         print(state.files.bnd, "Program Version,{}\n", state.dataStrGlobals->VerStringVar);
    1634         796 :     }
    1635             : 
    1636         794 :     void CloseOutputFiles(EnergyPlusData &state)
    1637             :     {
    1638             : 
    1639             :         // SUBROUTINE INFORMATION:
    1640             :         //       AUTHOR         Rick Strand
    1641             :         //       DATE WRITTEN   June 1997
    1642             :         //       MODIFIED       na
    1643             :         //       RE-ENGINEERED  na
    1644             : 
    1645             :         // PURPOSE OF THIS SUBROUTINE:
    1646             :         // This subroutine closes all of the input and output files needed for
    1647             :         // an EnergyPlus run.  It also prints the end of data marker for each
    1648             :         // output file.
    1649             : 
    1650             :         // METHODOLOGY EMPLOYED:
    1651             :         // na
    1652             : 
    1653             :         // REFERENCES:
    1654             :         // na
    1655             : 
    1656             :         // Using/Aliasing
    1657             :         using namespace DataOutputs;
    1658             :         using namespace DataRuntimeLanguage;
    1659             :         using namespace DataSystemVariables;
    1660             : 
    1661             :         // SUBROUTINE PARAMETER DEFINITIONS:
    1662             :         static constexpr std::string_view EndOfDataString("End of Data"); // Signifies the end of the data block in the output file
    1663             : 
    1664             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1665         794 :         std::string cEnvSetThreads;
    1666         794 :         std::string cepEnvSetThreads;
    1667         794 :         std::string cIDFSetThreads;
    1668             : 
    1669         794 :         state.files.audit.ensure_open(state, "CloseOutputFiles", state.files.outputControl.audit);
    1670             :         constexpr static std::string_view variable_fmt = " {}={:12}\n";
    1671             :         // Record some items on the audit file
    1672         794 :         print(state.files.audit, variable_fmt, "NumOfRVariable", state.dataOutputProcessor->NumOfRVariable_Setup);
    1673         794 :         print(state.files.audit, variable_fmt, "NumOfRVariable(Total)", state.dataOutputProcessor->NumTotalRVariable);
    1674         794 :         print(state.files.audit, variable_fmt, "NumOfRVariable(Actual)", state.dataOutputProcessor->NumOfRVariable);
    1675         794 :         print(state.files.audit, variable_fmt, "NumOfRVariable(Summed)", state.dataOutputProcessor->NumOfRVariable_Sum);
    1676         794 :         print(state.files.audit, variable_fmt, "NumOfRVariable(Meter)", state.dataOutputProcessor->NumOfRVariable_Meter);
    1677         794 :         print(state.files.audit, variable_fmt, "NumOfIVariable", state.dataOutputProcessor->NumOfIVariable_Setup);
    1678         794 :         print(state.files.audit, variable_fmt, "NumOfIVariable(Total)", state.dataOutputProcessor->NumTotalIVariable);
    1679         794 :         print(state.files.audit, variable_fmt, "NumOfIVariable(Actual)", state.dataOutputProcessor->NumOfIVariable);
    1680         794 :         print(state.files.audit, variable_fmt, "NumOfIVariable(Summed)", state.dataOutputProcessor->NumOfIVariable_Sum);
    1681             :         // print(state.files.audit, variable_fmt, "MaxRVariable", state.dataOutputProcessor->MaxRVariable);
    1682             :         // print(state.files.audit, variable_fmt, "MaxIVariable", state.dataOutputProcessor->MaxIVariable);
    1683         794 :         print(state.files.audit, variable_fmt, "NumEnergyMeters", state.dataOutputProcessor->meters.size());
    1684             :         // print(state.files.audit, variable_fmt, "NumVarMeterArrays", state.dataOutputProcessor->NumVarMeterArrays);
    1685         794 :         print(state.files.audit, variable_fmt, "maxUniqueKeyCount", state.dataOutRptTab->maxUniqueKeyCount);
    1686         794 :         print(state.files.audit, variable_fmt, "maxNumberOfFigures", state.dataSolarShading->maxNumberOfFigures);
    1687         794 :         print(state.files.audit, variable_fmt, "MAXHCArrayBounds", state.dataSolarShading->MAXHCArrayBounds);
    1688         794 :         print(state.files.audit, variable_fmt, "MaxVerticesPerSurface", state.dataSurface->MaxVerticesPerSurface);
    1689             :         // print(state.files.audit, variable_fmt, "NumReportList", state.dataOutputProcessor->NumReportList);
    1690             :         // print(state.files.audit, variable_fmt, "InstMeterCacheSize", state.dataOutputProcessor->InstMeterCacheSize);
    1691         794 :         if (state.dataSysVars->SutherlandHodgman) {
    1692         794 :             if (state.dataSysVars->SlaterBarsky) {
    1693           0 :                 print(state.files.audit, " {}\n", "ClippingAlgorithm=SlaterBarskyandSutherlandHodgman");
    1694             :             } else {
    1695         794 :                 print(state.files.audit, " {}\n", "ClippingAlgorithm=SutherlandHodgman");
    1696             :             }
    1697             :         } else {
    1698           0 :             print(state.files.audit, "{}\n", "ClippingAlgorithm=ConvexWeilerAtherton");
    1699             :         }
    1700         794 :         print(state.files.audit, variable_fmt, "MonthlyFieldSetInputCount", state.dataOutRptTab->MonthlyFieldSetInputCount);
    1701         794 :         print(state.files.audit, variable_fmt, "NumConsideredOutputVariables", state.dataOutput->NumConsideredOutputVariables);
    1702         794 :         print(state.files.audit, variable_fmt, "MaxConsideredOutputVariables", state.dataOutput->MaxConsideredOutputVariables);
    1703             : 
    1704         794 :         print(state.files.audit, variable_fmt, "numActuatorsUsed", state.dataRuntimeLang->numActuatorsUsed);
    1705         794 :         print(state.files.audit, variable_fmt, "numEMSActuatorsAvailable", state.dataRuntimeLang->numEMSActuatorsAvailable);
    1706         794 :         print(state.files.audit, variable_fmt, "maxEMSActuatorsAvailable", state.dataRuntimeLang->maxEMSActuatorsAvailable);
    1707         794 :         print(state.files.audit, variable_fmt, "numInternalVariablesUsed", state.dataRuntimeLang->NumInternalVariablesUsed);
    1708         794 :         print(state.files.audit, variable_fmt, "numEMSInternalVarsAvailable", state.dataRuntimeLang->numEMSInternalVarsAvailable);
    1709         794 :         print(state.files.audit, variable_fmt, "maxEMSInternalVarsAvailable", state.dataRuntimeLang->maxEMSInternalVarsAvailable);
    1710             : 
    1711         794 :         print(state.files.audit, variable_fmt, "NumOfNodeConnections", state.dataBranchNodeConnections->NumOfNodeConnections);
    1712         794 :         print(state.files.audit, variable_fmt, "MaxNumOfNodeConnections", state.dataBranchNodeConnections->MaxNumOfNodeConnections);
    1713             : #ifdef EP_Count_Calls
    1714             :         print(state.files.audit, variable_fmt, "NumShadow_Calls", state.dataTimingsData->NumShadow_Calls);
    1715             :         print(state.files.audit, variable_fmt, "NumShadowAtTS_Calls", state.dataTimingsData->NumShadowAtTS_Calls);
    1716             :         print(state.files.audit, variable_fmt, "NumClipPoly_Calls", state.dataTimingsData->NumClipPoly_Calls);
    1717             :         print(state.files.audit, variable_fmt, "NumInitSolar_Calls", state.dataTimingsData->NumInitSolar_Calls);
    1718             :         print(state.files.audit, variable_fmt, "NumAnisoSky_Calls", state.dataTimingsData->NumAnisoSky_Calls);
    1719             :         print(state.files.audit, variable_fmt, "NumDetPolyOverlap_Calls", state.dataTimingsData->NumDetPolyOverlap_Calls);
    1720             :         print(state.files.audit, variable_fmt, "NumCalcPerSolBeam_Calls", state.dataTimingsData->NumCalcPerSolBeam_Calls);
    1721             :         print(state.files.audit, variable_fmt, "NumDetShadowCombs_Calls", state.dataTimingsData->NumDetShadowCombs_Calls);
    1722             :         print(state.files.audit, variable_fmt, "NumIntSolarDist_Calls", state.dataTimingsData->NumIntSolarDist_Calls);
    1723             :         print(state.files.audit, variable_fmt, "NumIntRadExchange_Calls", state.dataTimingsData->NumIntRadExchange_Calls);
    1724             :         print(state.files.audit, variable_fmt, "NumIntRadExchangeZ_Calls", state.dataTimingsData->NumIntRadExchangeZ_Calls);
    1725             :         print(state.files.audit, variable_fmt, "NumIntRadExchangeMain_Calls", state.dataTimingsData->NumIntRadExchangeMain_Calls);
    1726             :         print(state.files.audit, variable_fmt, "NumIntRadExchangeOSurf_Calls", state.dataTimingsData->NumIntRadExchangeOSurf_Calls);
    1727             :         print(state.files.audit, variable_fmt, "NumIntRadExchangeISurf_Calls", state.dataTimingsData->NumIntRadExchangeISurf_Calls);
    1728             :         print(state.files.audit, variable_fmt, "NumMaxInsideSurfIterations", state.dataTimingsData->NumMaxInsideSurfIterations);
    1729             :         print(state.files.audit, variable_fmt, "NumCalcScriptF_Calls", state.dataTimingsData->NumCalcScriptF_Calls);
    1730             : #endif
    1731             : 
    1732         794 :         print(state.files.eso, "{}\n", EndOfDataString);
    1733         794 :         if (state.dataGlobal->StdOutputRecordCount > 0) {
    1734         776 :             print(state.files.eso, variable_fmt, "Number of Records Written", state.dataGlobal->StdOutputRecordCount);
    1735         776 :             state.files.eso.close();
    1736             :         } else {
    1737          18 :             state.files.eso.del();
    1738             :         }
    1739             : 
    1740         794 :         if (state.dataHeatBal->AnyCondFD) { // echo out relaxation factor, it may have been changed by the program
    1741          12 :             print(
    1742          12 :                 state.files.eio, "{}\n", "! <ConductionFiniteDifference Numerical Parameters>, Starting Relaxation Factor, Final Relaxation Factor");
    1743          12 :             print(state.files.eio,
    1744             :                   "ConductionFiniteDifference Numerical Parameters, {:.3R}, {:.3R}\n",
    1745          12 :                   state.dataHeatBal->CondFDRelaxFactorInput,
    1746          12 :                   state.dataHeatBal->CondFDRelaxFactor);
    1747             :         }
    1748             :         // Report number of threads to eio file
    1749             :         static constexpr std::string_view ThreadingHeader(
    1750             :             "! <Program Control Information:Threads/Parallel Sims>, Threading Supported,Maximum Number of "
    1751             :             "Threads, Env Set Threads (OMP_NUM_THREADS), EP Env Set Threads (EP_OMP_NUM_THREADS), IDF Set "
    1752             :             "Threads, Number of Threads Used (Interior Radiant Exchange), Number Nominal Surfaces, Number "
    1753             :             "Parallel Sims");
    1754         794 :         print(state.files.eio, "{}\n", ThreadingHeader);
    1755             :         static constexpr std::string_view ThreadReport("Program Control:Threads/Parallel Sims, {},{}, {}, {}, {}, {}, {}, {}\n");
    1756         794 :         if (state.dataSysVars->Threading) {
    1757           0 :             if (state.dataSysVars->iEnvSetThreads == 0) {
    1758           0 :                 cEnvSetThreads = "Not Set";
    1759             :             } else {
    1760           0 :                 cEnvSetThreads = fmt::to_string(state.dataSysVars->iEnvSetThreads);
    1761             :             }
    1762           0 :             if (state.dataSysVars->iepEnvSetThreads == 0) {
    1763           0 :                 cepEnvSetThreads = "Not Set";
    1764             :             } else {
    1765           0 :                 cepEnvSetThreads = fmt::to_string(state.dataSysVars->iepEnvSetThreads);
    1766             :             }
    1767           0 :             if (state.dataSysVars->iIDFSetThreads == 0) {
    1768           0 :                 cIDFSetThreads = "Not Set";
    1769             :             } else {
    1770           0 :                 cIDFSetThreads = fmt::to_string(state.dataSysVars->iIDFSetThreads);
    1771             :             }
    1772           0 :             if (state.dataSysVars->lnumActiveSims) {
    1773           0 :                 print(state.files.eio,
    1774             :                       ThreadReport,
    1775             :                       "Yes",
    1776           0 :                       state.dataSysVars->MaxNumberOfThreads,
    1777             :                       cEnvSetThreads,
    1778             :                       cepEnvSetThreads,
    1779             :                       cIDFSetThreads,
    1780           0 :                       state.dataSysVars->NumberIntRadThreads,
    1781           0 :                       state.dataSysVars->iNominalTotSurfaces,
    1782           0 :                       state.dataSysVars->inumActiveSims);
    1783             :             } else {
    1784           0 :                 print(state.files.eio,
    1785             :                       ThreadReport,
    1786             :                       "Yes",
    1787           0 :                       state.dataSysVars->MaxNumberOfThreads,
    1788             :                       cEnvSetThreads,
    1789             :                       cepEnvSetThreads,
    1790             :                       cIDFSetThreads,
    1791           0 :                       state.dataSysVars->NumberIntRadThreads,
    1792           0 :                       state.dataSysVars->iNominalTotSurfaces,
    1793             :                       "N/A");
    1794             :             }
    1795             :         } else { // no threading
    1796         794 :             if (state.dataSysVars->lnumActiveSims) {
    1797           0 :                 print(state.files.eio,
    1798             :                       ThreadReport,
    1799             :                       "No",
    1800           0 :                       state.dataSysVars->MaxNumberOfThreads,
    1801             :                       "N/A",
    1802             :                       "N/A",
    1803             :                       "N/A",
    1804             :                       "N/A",
    1805             :                       "N/A",
    1806           0 :                       state.dataSysVars->inumActiveSims);
    1807             :             } else {
    1808         794 :                 print(state.files.eio, ThreadReport, "No", state.dataSysVars->MaxNumberOfThreads, "N/A", "N/A", "N/A", "N/A", "N/A", "N/A");
    1809             :             }
    1810             :         }
    1811             : 
    1812             :         // Close the Initialization Output File
    1813         794 :         print(state.files.eio, "{}\n", EndOfDataString);
    1814         794 :         state.files.eio.close();
    1815             : 
    1816             :         // Close the Meters Output File
    1817         794 :         print(state.files.mtr, "{}\n", EndOfDataString);
    1818         794 :         print(state.files.mtr, " Number of Records Written={:12}\n", state.dataGlobal->StdMeterRecordCount);
    1819         794 :         if (state.dataGlobal->StdMeterRecordCount > 0) {
    1820         656 :             state.files.mtr.close();
    1821             :         } else {
    1822         138 :             state.files.mtr.del();
    1823             :         }
    1824             : 
    1825             :         // Close the External Shading Output File
    1826         794 :         state.files.shade.close();
    1827         794 :     }
    1828             : 
    1829         812 :     void SetupSimulation(EnergyPlusData &state, bool &ErrorsFound)
    1830             :     {
    1831             : 
    1832             :         // SUBROUTINE INFORMATION:
    1833             :         //       AUTHOR         B. Griffith/L. Lawrie
    1834             :         //       DATE WRITTEN   May 2008
    1835             :         //       MODIFIED       na
    1836             :         //       RE-ENGINEERED  na
    1837             : 
    1838             :         // PURPOSE OF THIS SUBROUTINE:
    1839             :         //  execute a few time steps of a simulation to facilitate setting up model
    1840             :         //  developed to resolve reverse DD problems caused be the differences
    1841             :         //  that stem from setup and information gathering that occurs during the first pass.
    1842             : 
    1843             :         // METHODOLOGY EMPLOYED:
    1844             :         // Using global flag (kickoff simulation), only a few time steps are executed.
    1845             :         // global flag is used in other parts of simulation to terminate quickly.
    1846             : 
    1847             :         // Using/Aliasing
    1848             :         using CostEstimateManager::SimCostEstimate;
    1849             :         using ExteriorEnergyUse::ManageExteriorEnergyUse;
    1850             : 
    1851         812 :         bool Available = true;
    1852             : 
    1853        3758 :         while (Available) { // do for each environment
    1854             : 
    1855        3758 :             Weather::GetNextEnvironment(state, Available, ErrorsFound);
    1856             : 
    1857        3758 :             if (!Available) break;
    1858        2946 :             if (ErrorsFound) break;
    1859             : 
    1860        2946 :             state.dataGlobal->BeginEnvrnFlag = true;
    1861        2946 :             state.dataGlobal->EndEnvrnFlag = false;
    1862        2946 :             state.dataEnvrn->EndMonthFlag = false;
    1863        2946 :             state.dataGlobal->WarmupFlag = true;
    1864        2946 :             state.dataGlobal->DayOfSim = 0;
    1865             : 
    1866        2946 :             ++state.dataGlobal->DayOfSim;
    1867        2946 :             state.dataGlobal->BeginDayFlag = true;
    1868        2946 :             state.dataGlobal->EndDayFlag = false;
    1869             : 
    1870        2946 :             state.dataGlobal->HourOfDay = 1;
    1871             : 
    1872        2946 :             state.dataGlobal->BeginHourFlag = true;
    1873        2946 :             state.dataGlobal->EndHourFlag = false;
    1874             : 
    1875        2946 :             state.dataGlobal->TimeStep = 1;
    1876             : 
    1877        2946 :             if (state.dataSysVars->DeveloperFlag) DisplayString(state, "Initializing Simulation - timestep 1:" + state.dataEnvrn->EnvironmentName);
    1878             : 
    1879        2946 :             state.dataGlobal->BeginTimeStepFlag = true;
    1880             : 
    1881        2946 :             Weather::ManageWeather(state);
    1882             : 
    1883        2946 :             ManageExteriorEnergyUse(state);
    1884             : 
    1885        2946 :             ManageHeatBalance(state);
    1886             : 
    1887        2946 :             state.dataGlobal->BeginHourFlag = false;
    1888        2946 :             state.dataGlobal->BeginDayFlag = false;
    1889        2946 :             state.dataGlobal->BeginEnvrnFlag = false;
    1890        2946 :             state.dataGlobal->BeginSimFlag = false;
    1891             : 
    1892             :             //          ! do another timestep=1
    1893        2946 :             if (state.dataSysVars->DeveloperFlag)
    1894           0 :                 DisplayString(state, "Initializing Simulation - 2nd timestep 1:" + state.dataEnvrn->EnvironmentName);
    1895             : 
    1896        2946 :             Weather::ManageWeather(state);
    1897             : 
    1898        2946 :             ManageExteriorEnergyUse(state);
    1899             : 
    1900        2946 :             ManageHeatBalance(state);
    1901             : 
    1902             :             //         do an end of day, end of environment time step
    1903             : 
    1904        2946 :             state.dataGlobal->HourOfDay = 24;
    1905        2946 :             state.dataGlobal->TimeStep = state.dataGlobal->NumOfTimeStepInHour;
    1906        2946 :             state.dataGlobal->EndEnvrnFlag = true;
    1907             : 
    1908        2946 :             if (state.dataSysVars->DeveloperFlag)
    1909           0 :                 DisplayString(state, "Initializing Simulation - hour 24 timestep 1:" + state.dataEnvrn->EnvironmentName);
    1910        2946 :             Weather::ManageWeather(state);
    1911             : 
    1912        2946 :             ManageExteriorEnergyUse(state);
    1913             : 
    1914        2946 :             ManageHeatBalance(state);
    1915             : 
    1916             :         } // ... End environment loop.
    1917             : 
    1918         812 :         if (state.dataGlobal->AnySlabsInModel || state.dataGlobal->AnyBasementsInModel) {
    1919           6 :             PlantPipingSystemsManager::SimulateGroundDomains(state, true);
    1920             :         }
    1921             : 
    1922         812 :         if (!ErrorsFound) SimCostEstimate(state); // basically will get and check input
    1923         812 :         if (ErrorsFound) ShowFatalError(state, "Previous conditions cause program termination.");
    1924         812 :     }
    1925             : 
    1926         795 :     void ReportNodeConnections(EnergyPlusData &state)
    1927             :     {
    1928             : 
    1929             :         // SUBROUTINE INFORMATION:
    1930             :         //       AUTHOR         Linda Lawrie
    1931             :         //       DATE WRITTEN   February 2004
    1932             :         //       MODIFIED       na
    1933             :         //       RE-ENGINEERED  na
    1934             : 
    1935             :         // PURPOSE OF THIS SUBROUTINE:
    1936             :         // This subroutine 'reports' the NodeConnection data structure.  It groups the
    1937             :         // report/dump by parent, non-parent objects.
    1938             : 
    1939             :         // Using/Aliasing
    1940             :         using namespace DataBranchNodeConnections;
    1941             : 
    1942             :         // Formats
    1943             :         static constexpr std::string_view Format_702("! <#{0} Node Connections>,<Number of {0} Node Connections>\n");
    1944             :         static constexpr std::string_view Format_703(
    1945             :             "! <{} Node Connection>,<Node Name>,<Node ObjectType>,<Node ObjectName>,<Node ConnectionType>,<Node FluidStream>\n");
    1946             : 
    1947         795 :         state.dataBranchNodeConnections->NonConnectedNodes.dimension(state.dataLoopNodes->NumOfNodes, true);
    1948             : 
    1949         795 :         int NumNonParents = 0;
    1950      180109 :         for (int Loop = 1; Loop <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop) {
    1951      179314 :             if (state.dataBranchNodeConnections->NodeConnections(Loop).ObjectIsParent) continue;
    1952      123895 :             ++NumNonParents;
    1953             :         }
    1954         795 :         const int NumParents = state.dataBranchNodeConnections->NumOfNodeConnections - NumNonParents;
    1955         795 :         state.dataBranchNodeConnections->ParentNodeList.allocate(NumParents);
    1956             : 
    1957             :         //  Do Parent Objects
    1958         795 :         print(state.files.bnd, "{}\n", "! ===============================================================");
    1959         795 :         print(state.files.bnd, Format_702, "Parent");
    1960         795 :         print(state.files.bnd, " #Parent Node Connections,{}\n", NumParents);
    1961         795 :         print(state.files.bnd, Format_703, "Parent");
    1962             : 
    1963      180109 :         for (int Loop = 1; Loop <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop) {
    1964      179314 :             if (!state.dataBranchNodeConnections->NodeConnections(Loop).ObjectIsParent) continue;
    1965       55419 :             state.dataBranchNodeConnections->NonConnectedNodes(state.dataBranchNodeConnections->NodeConnections(Loop).NodeNumber) = false;
    1966       55419 :             print(state.files.bnd,
    1967             :                   " Parent Node Connection,{},{},{},{},{}\n",
    1968       55419 :                   state.dataBranchNodeConnections->NodeConnections(Loop).NodeName,
    1969             :                   BranchNodeConnections::ConnectionObjectTypeNamesUC[static_cast<int>(
    1970       55419 :                       state.dataBranchNodeConnections->NodeConnections(Loop).ObjectType)],
    1971       55419 :                   state.dataBranchNodeConnections->NodeConnections(Loop).ObjectName,
    1972       55419 :                   DataLoopNode::ConnectionTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop).ConnectionType)],
    1973       55419 :                   state.dataBranchNodeConnections->NodeConnections(Loop).FluidStream);
    1974             :             // Build ParentNodeLists
    1975       88157 :             if ((state.dataBranchNodeConnections->NodeConnections(Loop).ConnectionType == DataLoopNode::ConnectionType::Inlet) ||
    1976       32738 :                 (state.dataBranchNodeConnections->NodeConnections(Loop).ConnectionType == DataLoopNode::ConnectionType::Outlet)) {
    1977       51041 :                 bool ParentComponentFound = false;
    1978     2950749 :                 for (int Loop1 = 1; Loop1 <= state.dataBranchNodeConnections->NumOfActualParents; ++Loop1) {
    1979     2899708 :                     if (state.dataBranchNodeConnections->ParentNodeList(Loop1).ComponentType !=
    1980     3944997 :                             state.dataBranchNodeConnections->NodeConnections(Loop).ObjectType ||
    1981     1045289 :                         state.dataBranchNodeConnections->ParentNodeList(Loop1).ComponentName !=
    1982     1045289 :                             state.dataBranchNodeConnections->NodeConnections(Loop).ObjectName)
    1983     2875837 :                         continue;
    1984       23871 :                     ParentComponentFound = true;
    1985             : 
    1986       23871 :                     switch (state.dataBranchNodeConnections->NodeConnections(Loop).ConnectionType) {
    1987        2934 :                     case DataLoopNode::ConnectionType::Inlet:
    1988        2934 :                         state.dataBranchNodeConnections->ParentNodeList(Loop1).InletNodeName =
    1989        5868 :                             state.dataBranchNodeConnections->NodeConnections(Loop).NodeName;
    1990        2934 :                         break;
    1991       20937 :                     case DataLoopNode::ConnectionType::Outlet:
    1992       20937 :                         state.dataBranchNodeConnections->ParentNodeList(Loop1).OutletNodeName =
    1993       41874 :                             state.dataBranchNodeConnections->NodeConnections(Loop).NodeName;
    1994       20937 :                     default:
    1995       20937 :                         break;
    1996             :                     }
    1997             :                 }
    1998       51041 :                 if (!ParentComponentFound) {
    1999       27170 :                     ++state.dataBranchNodeConnections->NumOfActualParents;
    2000       27170 :                     state.dataBranchNodeConnections->ParentNodeList(state.dataBranchNodeConnections->NumOfActualParents).ComponentType =
    2001       27170 :                         state.dataBranchNodeConnections->NodeConnections(Loop).ObjectType;
    2002       27170 :                     state.dataBranchNodeConnections->ParentNodeList(state.dataBranchNodeConnections->NumOfActualParents).ComponentName =
    2003       54340 :                         state.dataBranchNodeConnections->NodeConnections(Loop).ObjectName;
    2004             : 
    2005       27170 :                     switch (state.dataBranchNodeConnections->NodeConnections(Loop).ConnectionType) {
    2006       19747 :                     case DataLoopNode::ConnectionType::Inlet:
    2007       19747 :                         state.dataBranchNodeConnections->ParentNodeList(state.dataBranchNodeConnections->NumOfActualParents).InletNodeName =
    2008       39494 :                             state.dataBranchNodeConnections->NodeConnections(Loop).NodeName;
    2009       19747 :                         break;
    2010        7423 :                     case DataLoopNode::ConnectionType::Outlet:
    2011        7423 :                         state.dataBranchNodeConnections->ParentNodeList(state.dataBranchNodeConnections->NumOfActualParents).OutletNodeName =
    2012       14846 :                             state.dataBranchNodeConnections->NodeConnections(Loop).NodeName;
    2013        7423 :                         break;
    2014           0 :                     default:
    2015           0 :                         break;
    2016             :                     }
    2017             :                 }
    2018             :             }
    2019             :         }
    2020             : 
    2021             :         //  Do non-Parent Objects
    2022         795 :         print(state.files.bnd, "{}\n", "! ===============================================================");
    2023         795 :         print(state.files.bnd, Format_702, "Non-Parent");
    2024         795 :         print(state.files.bnd, " #Non-Parent Node Connections,{}\n", NumNonParents);
    2025         795 :         print(state.files.bnd, Format_703, "Non-Parent");
    2026             : 
    2027      180109 :         for (int Loop = 1; Loop <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop) {
    2028      179314 :             if (state.dataBranchNodeConnections->NodeConnections(Loop).ObjectIsParent) continue;
    2029      123895 :             state.dataBranchNodeConnections->NonConnectedNodes(state.dataBranchNodeConnections->NodeConnections(Loop).NodeNumber) = false;
    2030      123895 :             print(state.files.bnd,
    2031             :                   " Non-Parent Node Connection,{},{},{},{},{}\n",
    2032      123895 :                   state.dataBranchNodeConnections->NodeConnections(Loop).NodeName,
    2033             :                   BranchNodeConnections::ConnectionObjectTypeNamesUC[static_cast<int>(
    2034      123895 :                       state.dataBranchNodeConnections->NodeConnections(Loop).ObjectType)],
    2035      123895 :                   state.dataBranchNodeConnections->NodeConnections(Loop).ObjectName,
    2036      123895 :                   DataLoopNode::ConnectionTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop).ConnectionType)],
    2037      123895 :                   state.dataBranchNodeConnections->NodeConnections(Loop).FluidStream);
    2038             :         }
    2039             : 
    2040         795 :         int NumNonConnected = 0;
    2041       63030 :         for (int Loop = 1; Loop <= state.dataLoopNodes->NumOfNodes; ++Loop) {
    2042       62235 :             if (state.dataBranchNodeConnections->NonConnectedNodes(Loop)) ++NumNonConnected;
    2043             :         }
    2044             : 
    2045         795 :         if (NumNonConnected > 0) {
    2046           5 :             print(state.files.bnd, "{}\n", "! ===============================================================");
    2047             :             static constexpr std::string_view Format_705("! <#NonConnected Nodes>,<Number of NonConnected Nodes>\n #NonConnected Nodes,{}\n");
    2048           5 :             print(state.files.bnd, Format_705, NumNonConnected);
    2049             :             static constexpr std::string_view Format_706("! <NonConnected Node>,<NonConnected Node Number>,<NonConnected Node Name>");
    2050           5 :             print(state.files.bnd, "{}\n", Format_706);
    2051        1099 :             for (int Loop = 1; Loop <= state.dataLoopNodes->NumOfNodes; ++Loop) {
    2052        1094 :                 if (!state.dataBranchNodeConnections->NonConnectedNodes(Loop)) continue;
    2053          15 :                 print(state.files.bnd, " NonConnected Node,{},{}\n", Loop, state.dataLoopNodes->NodeID(Loop));
    2054             :             }
    2055             :         }
    2056             : 
    2057         795 :         state.dataBranchNodeConnections->NonConnectedNodes.deallocate();
    2058         795 :     }
    2059             : 
    2060         795 :     void ReportLoopConnections(EnergyPlusData &state)
    2061             :     {
    2062             : 
    2063             :         // SUBROUTINE INFORMATION:
    2064             :         //       AUTHOR         Linda Lawrie
    2065             :         //       DATE WRITTEN   December 2001
    2066             :         //       MODIFIED       March 2003; added other reporting
    2067             : 
    2068             :         // PURPOSE OF THIS SUBROUTINE:
    2069             :         // This subroutine reports on the node connections in various parts of the
    2070             :         // HVAC system: Component Sets, Air Loop, Plant and Condenser Loop, Supply and
    2071             :         // return air paths, controlled zones.
    2072             :         // This information should be useful in diagnosing node connection input errors.
    2073             : 
    2074             :         static constexpr std::string_view errstring = "**error**";
    2075             : 
    2076             :         // Formats
    2077             :         static constexpr std::string_view Format_700 = "! <#Component Sets>,<Number of Component Sets>";
    2078             :         static constexpr std::string_view Format_702 = "! <Component Set>,<Component Set Count>,<Parent Object Type>,<Parent Object Name>,<Component "
    2079             :                                                        "Type>,<Component Name>,<Inlet Node ID>,<Outlet Node ID>,<Description>";
    2080             :         static constexpr std::string_view Format_720 = "! <#Zone Equipment Lists>,<Number of Zone Equipment Lists>";
    2081             :         static constexpr std::string_view Format_722 =
    2082             :             "! <Zone Equipment List>,<Zone Equipment List Count>,<Zone Equipment List Name>,<Zone Name>,<Number of Components>";
    2083             :         static constexpr std::string_view Format_723 =
    2084             :             "! <Zone Equipment Component>,<Component Count>,<Component Type>,<Component Name>,<Zone Name>,<Heating "
    2085             :             "Priority>,<Cooling Priority>";
    2086             : 
    2087             :         // Report outside air node names on the Branch-Node Details file
    2088         795 :         print(state.files.bnd, "{}\n", "! ===============================================================");
    2089         795 :         print(state.files.bnd, "{}\n", "! #Outdoor Air Nodes,<Number of Outdoor Air Nodes>");
    2090         795 :         print(state.files.bnd, " #Outdoor Air Nodes,{}\n", state.dataOutAirNodeMgr->NumOutsideAirNodes);
    2091         795 :         if (state.dataOutAirNodeMgr->NumOutsideAirNodes > 0) {
    2092         510 :             print(state.files.bnd, "{}\n", "! <Outdoor Air Node>,<NodeNumber>,<Node Name>");
    2093             :         }
    2094        3182 :         for (int Count = 1; Count <= state.dataOutAirNodeMgr->NumOutsideAirNodes; ++Count) {
    2095        2387 :             print(state.files.bnd,
    2096             :                   " Outdoor Air Node,{},{}\n",
    2097        2387 :                   state.dataOutAirNodeMgr->OutsideAirNodeList(Count),
    2098        2387 :                   state.dataLoopNodes->NodeID(state.dataOutAirNodeMgr->OutsideAirNodeList(Count)));
    2099             :         }
    2100             :         // Component Sets
    2101         795 :         print(state.files.bnd, "{}\n", "! ===============================================================");
    2102         795 :         print(state.files.bnd, "{}\n", Format_700);
    2103         795 :         print(state.files.bnd, " #Component Sets,{}\n", state.dataBranchNodeConnections->NumCompSets);
    2104         795 :         print(state.files.bnd, "{}\n", Format_702);
    2105             : 
    2106       29900 :         for (int Count = 1; Count <= state.dataBranchNodeConnections->NumCompSets; ++Count) {
    2107       29105 :             print(state.files.bnd,
    2108             :                   " Component Set,{},{},{},{},{},{},{},{}\n",
    2109             :                   Count,
    2110             :                   BranchNodeConnections::ConnectionObjectTypeNamesUC[static_cast<int>(
    2111       29105 :                       state.dataBranchNodeConnections->CompSets(Count).ParentObjectType)],
    2112       29105 :                   state.dataBranchNodeConnections->CompSets(Count).ParentCName,
    2113             :                   BranchNodeConnections::ConnectionObjectTypeNamesUC[static_cast<int>(
    2114       29105 :                       state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType)],
    2115       29105 :                   state.dataBranchNodeConnections->CompSets(Count).CName,
    2116       29105 :                   state.dataBranchNodeConnections->CompSets(Count).InletNodeName,
    2117       29105 :                   state.dataBranchNodeConnections->CompSets(Count).OutletNodeName,
    2118       29105 :                   state.dataBranchNodeConnections->CompSets(Count).Description);
    2119             : 
    2120             :             std::string_view const CType = BranchNodeConnections::ConnectionObjectTypeNamesUC[static_cast<int>(
    2121       29105 :                 state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType)];
    2122       58208 :             if (state.dataBranchNodeConnections->CompSets(Count).ParentObjectType == DataLoopNode::ConnectionObjectType::Undefined ||
    2123       58208 :                 state.dataBranchNodeConnections->CompSets(Count).InletNodeName == "UNDEFINED" ||
    2124       29103 :                 state.dataBranchNodeConnections->CompSets(Count).OutletNodeName == "UNDEFINED") {
    2125           2 :                 if (state.dataErrTracking->AbortProcessing && state.dataSimulationManager->WarningOut) {
    2126           0 :                     ShowWarningError(state,
    2127             :                                      "Node Connection errors shown during \"fatal error\" processing may be false because not all inputs may have "
    2128             :                                      "been retrieved.");
    2129           0 :                     state.dataSimulationManager->WarningOut = false;
    2130             :                 }
    2131           4 :                 ShowWarningError(state,
    2132           4 :                                  format("Node Connection Error for object {}={}", CType, state.dataBranchNodeConnections->CompSets(Count).CName));
    2133           4 :                 ShowContinueError(state,
    2134           4 :                                   format("  {} not on any Branch or Parent Object", state.dataBranchNodeConnections->CompSets(Count).Description));
    2135           2 :                 ShowContinueError(state, format("  Inlet Node : {}", state.dataBranchNodeConnections->CompSets(Count).InletNodeName));
    2136           2 :                 ShowContinueError(state, format("  Outlet Node: {}", state.dataBranchNodeConnections->CompSets(Count).OutletNodeName));
    2137           2 :                 ++state.dataBranchNodeConnections->NumNodeConnectionErrors;
    2138           2 :                 if (state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType ==
    2139             :                     DataLoopNode::ConnectionObjectType::SolarCollectorUnglazedTranspired) {
    2140           0 :                     ShowContinueError(state, "This report does not necessarily indicate a problem for a MultiSystem Transpired Collector");
    2141             :                 }
    2142             :             }
    2143       29105 :             if (state.dataBranchNodeConnections->CompSets(Count).Description == "UNDEFINED") {
    2144           1 :                 if (state.dataErrTracking->AbortProcessing && state.dataSimulationManager->WarningOut) {
    2145           0 :                     ShowWarningError(state,
    2146             :                                      "Node Connection errors shown during \"fatal error\" processing may be false because not all inputs may have "
    2147             :                                      "been retrieved.");
    2148           0 :                     state.dataSimulationManager->WarningOut = false;
    2149             :                 }
    2150           2 :                 ShowWarningError(
    2151             :                     state,
    2152           2 :                     format("Potential Node Connection Error for object {}, name={}", CType, state.dataBranchNodeConnections->CompSets(Count).CName));
    2153           1 :                 ShowContinueError(state, "  Node Types are still UNDEFINED -- See Branch/Node Details file for further information");
    2154           1 :                 ShowContinueError(state, format("  Inlet Node : {}", state.dataBranchNodeConnections->CompSets(Count).InletNodeName));
    2155           1 :                 ShowContinueError(state, format("  Outlet Node: {}", state.dataBranchNodeConnections->CompSets(Count).OutletNodeName));
    2156           1 :                 ++state.dataBranchNodeConnections->NumNodeConnectionErrors;
    2157             :             }
    2158             :         }
    2159             : 
    2160       29900 :         for (int Count = 1; Count <= state.dataBranchNodeConnections->NumCompSets; ++Count) {
    2161     2203621 :             for (int Count1 = Count + 1; Count1 <= state.dataBranchNodeConnections->NumCompSets; ++Count1) {
    2162     2174516 :                 if (state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType !=
    2163     2174516 :                     state.dataBranchNodeConnections->CompSets(Count1).ComponentObjectType)
    2164     2174516 :                     continue;
    2165      411365 :                 if (state.dataBranchNodeConnections->CompSets(Count).CName != state.dataBranchNodeConnections->CompSets(Count1).CName) continue;
    2166        4373 :                 if (state.dataBranchNodeConnections->CompSets(Count).InletNodeName != state.dataBranchNodeConnections->CompSets(Count1).InletNodeName)
    2167        4373 :                     continue;
    2168           0 :                 if (state.dataBranchNodeConnections->CompSets(Count).OutletNodeName !=
    2169           0 :                     state.dataBranchNodeConnections->CompSets(Count1).OutletNodeName)
    2170           0 :                     continue;
    2171           0 :                 if (state.dataErrTracking->AbortProcessing && state.dataSimulationManager->WarningOut) {
    2172           0 :                     ShowWarningError(state,
    2173             :                                      "Node Connection errors shown during \"fatal error\" processing may be false because not all inputs may have "
    2174             :                                      "been retrieved.");
    2175           0 :                     state.dataSimulationManager->WarningOut = false;
    2176             :                 }
    2177             :                 std::string_view const CType = BranchNodeConnections::ConnectionObjectTypeNamesUC[static_cast<int>(
    2178           0 :                     state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType)];
    2179             :                 std::string_view const ParentCType = BranchNodeConnections::ConnectionObjectTypeNamesUC[static_cast<int>(
    2180           0 :                     state.dataBranchNodeConnections->CompSets(Count1).ParentObjectType)];
    2181             :                 std::string_view const ParentCType1 = BranchNodeConnections::ConnectionObjectTypeNamesUC[static_cast<int>(
    2182           0 :                     state.dataBranchNodeConnections->CompSets(Count).ParentObjectType)];
    2183           0 :                 ShowWarningError(state, "Component plus inlet/outlet node pair used more than once:");
    2184           0 :                 ShowContinueError(state, format("  Component  : {}={}", CType, state.dataBranchNodeConnections->CompSets(Count).CName));
    2185           0 :                 ShowContinueError(state, format("  Inlet Node : {}", state.dataBranchNodeConnections->CompSets(Count).InletNodeName));
    2186           0 :                 ShowContinueError(state, format("  Outlet Node: {}", state.dataBranchNodeConnections->CompSets(Count).OutletNodeName));
    2187           0 :                 ShowContinueError(state, format("  Used by    : {}={}", ParentCType, state.dataBranchNodeConnections->CompSets(Count).ParentCName));
    2188           0 :                 ShowContinueError(state, format("  and  by    : {}={}", ParentCType1, state.dataBranchNodeConnections->CompSets(Count1).ParentCName));
    2189           0 :                 ++state.dataBranchNodeConnections->NumNodeConnectionErrors;
    2190             :             }
    2191             :         }
    2192             :         //  Plant Loops
    2193         795 :         print(state.files.bnd, "{}\n", "! ===============================================================");
    2194         795 :         print(state.files.bnd, "{}\n", "! <# Plant Loops>,<Number of Plant Loops>");
    2195         795 :         print(state.files.bnd, " #Plant Loops,{}\n", state.dataHVACGlobal->NumPlantLoops);
    2196         795 :         print(state.files.bnd,
    2197             :               "{}\n",
    2198             :               "! <Plant Loop>,<Plant Loop Name>,<Loop Type>,<Inlet Node Name>,<Outlet Node Name>,<Branch List>,<Connector List>");
    2199         795 :         print(
    2200         795 :             state.files.bnd, "{}\n", "! <Plant Loop Connector>,<Connector Type>,<Connector Name>,<Loop Name>,<Loop Type>,<Number of Inlets/Outlets>");
    2201         795 :         print(state.files.bnd,
    2202             :               "{}\n",
    2203             :               "! <Plant Loop Connector Branches>,<Connector Node Count>,<Connector Type>,<Connector Name>,<Inlet Branch>,<Outlet Branch>,<Loop "
    2204             :               "Name>,<Loop Type>");
    2205         795 :         print(state.files.bnd,
    2206             :               "{}\n",
    2207             :               "! <Plant Loop Connector Nodes>,<Connector Node Count>,<Connector Type>,<Connector Name>,<Inlet Node>,<Outlet Node>,<Loop Name>,<Loop "
    2208             :               "Type>");
    2209         795 :         print(state.files.bnd,
    2210             :               "{}\n",
    2211             :               "! <Plant Loop Supply Connection>,<Plant Loop Name>,<Supply Side Outlet Node Name>,<Demand Side Inlet Node Name>");
    2212         795 :         print(state.files.bnd,
    2213             :               "{}\n",
    2214             :               "! <Plant Loop Return Connection>,<Plant Loop Name>,<Demand Side Outlet Node Name>,<Supply Side Inlet Node Name>");
    2215        1684 :         for (int Count = 1; Count <= state.dataHVACGlobal->NumPlantLoops; ++Count) {
    2216        2667 :             for (DataPlant::LoopSideLocation LoopSideNum : DataPlant::LoopSideKeys) {
    2217             :                 //  Plant Supply Side Loop
    2218             :                 // LoopSideLocation::Demand and LoopSideLocation::Supply is parametrized in DataPlant
    2219        1778 :                 std::string_view const LoopString = DataPlant::DemandSupplyNames[static_cast<int>(LoopSideNum)];
    2220             : 
    2221        1778 :                 print(state.files.bnd,
    2222             :                       " Plant Loop,{},{},{},{},{},{}\n",
    2223        1778 :                       state.dataPlnt->PlantLoop(Count).Name,
    2224             :                       LoopString,
    2225        1778 :                       state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).NodeNameIn,
    2226        1778 :                       state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).NodeNameOut,
    2227        1778 :                       state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).BranchList,
    2228        1778 :                       state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).ConnectList);
    2229             :                 //  Plant Supply Side Splitter
    2230        1778 :                 if (state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.Exists) {
    2231        1745 :                     print(state.files.bnd,
    2232             :                           "   Plant Loop Connector,Splitter,{},{},{},{}\n",
    2233        1745 :                           state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.Name,
    2234        1745 :                           state.dataPlnt->PlantLoop(Count).Name,
    2235             :                           LoopString,
    2236        1745 :                           state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.TotalOutletNodes);
    2237        9357 :                     for (int Count1 = 1; Count1 <= state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.TotalOutletNodes; ++Count1) {
    2238        7612 :                         print(state.files.bnd,
    2239             :                               "     Plant Loop Connector Branches,{},Splitter,{},",
    2240             :                               Count1,
    2241        7612 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.Name);
    2242             : 
    2243        7612 :                         if (state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.BranchNumIn <= 0) {
    2244           0 :                             print(state.files.bnd, "{},\n", errstring);
    2245             :                         } else {
    2246        7612 :                             print(state.files.bnd,
    2247             :                                   "{},",
    2248        7612 :                                   state.dataPlnt->PlantLoop(Count)
    2249        7612 :                                       .LoopSide(LoopSideNum)
    2250        7612 :                                       .Branch(state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.BranchNumIn)
    2251        7612 :                                       .Name);
    2252             :                         }
    2253             : 
    2254        7612 :                         if (state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.BranchNumOut(Count1) <= 0) {
    2255           0 :                             print(state.files.bnd, "{},{},{}\n", errstring, state.dataPlnt->PlantLoop(Count).Name, LoopString);
    2256             :                         } else {
    2257        7612 :                             print(state.files.bnd,
    2258             :                                   "{},{},{}\n",
    2259        7612 :                                   state.dataPlnt->PlantLoop(Count)
    2260        7612 :                                       .LoopSide(LoopSideNum)
    2261        7612 :                                       .Branch(state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.BranchNumOut(Count1))
    2262        7612 :                                       .Name,
    2263        7612 :                                   state.dataPlnt->PlantLoop(Count).Name,
    2264             :                                   LoopString);
    2265             :                         }
    2266             : 
    2267        7612 :                         print(state.files.bnd,
    2268             :                               "     Plant Loop Connector Nodes,   {},Splitter,{},{},{},{},{}\n",
    2269             :                               Count1,
    2270        7612 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.Name,
    2271        7612 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.NodeNameIn,
    2272        7612 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.NodeNameOut(Count1),
    2273        7612 :                               state.dataPlnt->PlantLoop(Count).Name,
    2274             :                               LoopString);
    2275             :                     }
    2276             :                 }
    2277             : 
    2278             :                 //  Plant Supply Side Mixer
    2279        1778 :                 if (state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.Exists) {
    2280        1745 :                     print(state.files.bnd,
    2281             :                           "   Plant Loop Connector,Mixer,{},{},{},{}\n",
    2282        1745 :                           state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.Name,
    2283        1745 :                           state.dataPlnt->PlantLoop(Count).Name,
    2284             :                           LoopString,
    2285        1745 :                           state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.TotalInletNodes); //',Supply,'//  &
    2286             : 
    2287        9357 :                     for (int Count1 = 1; Count1 <= state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.TotalInletNodes; ++Count1) {
    2288        7612 :                         print(state.files.bnd,
    2289             :                               "     Plant Loop Connector Branches,{},Mixer,{},",
    2290             :                               Count1,
    2291        7612 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.Name);
    2292        7612 :                         if (state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.BranchNumIn(Count1) <= 0) {
    2293           0 :                             print(state.files.bnd, "{},", errstring);
    2294             :                         } else {
    2295        7612 :                             print(state.files.bnd,
    2296             :                                   "{},",
    2297        7612 :                                   state.dataPlnt->PlantLoop(Count)
    2298        7612 :                                       .LoopSide(LoopSideNum)
    2299        7612 :                                       .Branch(state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.BranchNumIn(Count1))
    2300        7612 :                                       .Name);
    2301             :                         }
    2302        7612 :                         if (state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.BranchNumOut <= 0) {
    2303           0 :                             print(state.files.bnd, "{},{},Supply\n", errstring, state.dataPlnt->PlantLoop(Count).Name);
    2304             :                         } else {
    2305        7612 :                             print(state.files.bnd,
    2306             :                                   "{},{},{}\n",
    2307        7612 :                                   state.dataPlnt->PlantLoop(Count)
    2308        7612 :                                       .LoopSide(LoopSideNum)
    2309        7612 :                                       .Branch(state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.BranchNumOut)
    2310        7612 :                                       .Name,
    2311        7612 :                                   state.dataPlnt->PlantLoop(Count).Name,
    2312             :                                   LoopString);
    2313             :                         }
    2314        7612 :                         print(state.files.bnd,
    2315             :                               "     Plant Loop Connector Nodes,   {},Mixer,{},{},{},{},{}\n",
    2316             :                               Count1,
    2317        7612 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.Name,
    2318        7612 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.NodeNameIn(Count1),
    2319        7612 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.NodeNameOut,
    2320        7612 :                               state.dataPlnt->PlantLoop(Count).Name,
    2321             :                               LoopString);
    2322             :                     }
    2323             :                 }
    2324             :             }
    2325         889 :             print(state.files.bnd,
    2326             :                   " Plant Loop Supply Connection,{},{},{}\n",
    2327         889 :                   state.dataPlnt->PlantLoop(Count).Name,
    2328         889 :                   state.dataPlnt->PlantLoop(Count).LoopSide(DataPlant::LoopSideLocation::Supply).NodeNameOut,
    2329         889 :                   state.dataPlnt->PlantLoop(Count).LoopSide(DataPlant::LoopSideLocation::Demand).NodeNameIn);
    2330         889 :             print(state.files.bnd,
    2331             :                   " Plant Loop Return Connection,{},{},{}\n",
    2332         889 :                   state.dataPlnt->PlantLoop(Count).Name,
    2333         889 :                   state.dataPlnt->PlantLoop(Count).LoopSide(DataPlant::LoopSideLocation::Demand).NodeNameOut,
    2334         889 :                   state.dataPlnt->PlantLoop(Count).LoopSide(DataPlant::LoopSideLocation::Supply).NodeNameIn);
    2335             : 
    2336             :         } //  Plant Demand Side Loop
    2337             : 
    2338             :         //  Condenser Loops
    2339         795 :         print(state.files.bnd, "{}\n", "! ===============================================================");
    2340         795 :         print(state.files.bnd, "{}\n", "! <# Condenser Loops>,<Number of Condenser Loops>");
    2341         795 :         print(state.files.bnd, " #Condenser Loops,{}\n", state.dataHVACGlobal->NumCondLoops);
    2342         795 :         print(state.files.bnd,
    2343             :               "{}\n",
    2344             :               "! <Condenser Loop>,<Condenser Loop Name>,<Loop Type>,<Inlet Node Name>,<Outlet Node Name>,<Branch List>,<Connector List>");
    2345         795 :         print(state.files.bnd,
    2346             :               "{}\n",
    2347             :               "! <Condenser Loop Connector>,<Connector Type>,<Connector Name>,<Loop Name>,<Loop Type>,<Number of Inlets/Outlets>");
    2348         795 :         print(state.files.bnd,
    2349             :               "{}\n",
    2350             :               "! <Condenser Loop Connector Branches>,<Connector Node Count>,<Connector Type>,<Connector Name>,<Inlet Branch>,<Outlet Branch>,<Loop "
    2351             :               "Name>,<Loop Type>");
    2352         795 :         print(state.files.bnd,
    2353             :               "{}\n",
    2354             :               "! <Condenser Loop Connector Nodes>,<Connector Node Count>,<Connector Type>,<Connector Name>,<Inlet Node>,<Outlet Node>,<Loop "
    2355             :               "Name>,<Loop Type>");
    2356         795 :         print(state.files.bnd,
    2357             :               "{}\n",
    2358             :               "! <Condenser Loop Supply Connection>,<Condenser Loop Name>,<Supply Side Outlet Node Name>,<Demand Side Inlet Node Name>");
    2359         795 :         print(state.files.bnd,
    2360             :               "{}\n",
    2361             :               "! <Condenser Loop Return Connection>,<Condenser Loop Name>,<Demand Side Outlet Node Name>,<Supply Side Inlet Node Name>");
    2362             : 
    2363        1053 :         for (int Count = state.dataHVACGlobal->NumPlantLoops + 1; Count <= state.dataPlnt->TotNumLoops; ++Count) {
    2364         774 :             for (DataPlant::LoopSideLocation LoopSideNum : DataPlant::LoopSideKeys) {
    2365             :                 //  Plant Supply Side Loop
    2366             :                 // LoopSideLocation::Demand and LoopSideLocation::Supply is parametrized in DataPlant
    2367         516 :                 const auto LoopString = [&]() {
    2368         516 :                     if (LoopSideNum == DataPlant::LoopSideLocation::Demand) {
    2369         258 :                         return "Demand";
    2370         258 :                     } else if (LoopSideNum == DataPlant::LoopSideLocation::Supply) {
    2371         258 :                         return "Supply";
    2372             :                     } else {
    2373           0 :                         return "";
    2374             :                     }
    2375         516 :                 }();
    2376             : 
    2377         516 :                 print(state.files.bnd,
    2378             :                       " Plant Loop,{},{},{},{},{},{}\n",
    2379         516 :                       state.dataPlnt->PlantLoop(Count).Name,
    2380             :                       LoopString,
    2381         516 :                       state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).NodeNameIn,
    2382         516 :                       state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).NodeNameOut,
    2383         516 :                       state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).BranchList,
    2384         516 :                       state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).ConnectList);
    2385             :                 //  Plant Supply Side Splitter
    2386         516 :                 if (state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.Exists) {
    2387         516 :                     print(state.files.bnd,
    2388             :                           "   Plant Loop Connector,Splitter,{},{},{},{}\n",
    2389         516 :                           state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.Name,
    2390         516 :                           state.dataPlnt->PlantLoop(Count).Name,
    2391             :                           LoopString,
    2392         516 :                           state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.TotalOutletNodes);
    2393        1791 :                     for (int Count1 = 1; Count1 <= state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.TotalOutletNodes; ++Count1) {
    2394        1275 :                         print(state.files.bnd,
    2395             :                               "     Plant Loop Connector Branches,{},Splitter,{},",
    2396             :                               Count1,
    2397        1275 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.Name);
    2398             : 
    2399        1275 :                         if (state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.BranchNumIn <= 0) {
    2400           0 :                             print(state.files.bnd, "{},", errstring);
    2401             :                         } else {
    2402        1275 :                             print(state.files.bnd,
    2403             :                                   "{},",
    2404        1275 :                                   state.dataPlnt->PlantLoop(Count)
    2405        1275 :                                       .LoopSide(LoopSideNum)
    2406        1275 :                                       .Branch(state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.BranchNumIn)
    2407        1275 :                                       .Name);
    2408             :                         }
    2409        1275 :                         if (state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.BranchNumOut(Count1) <= 0) {
    2410           0 :                             print(state.files.bnd, "{},{},{}\n", errstring, state.dataPlnt->PlantLoop(Count).Name, LoopString);
    2411             :                         } else {
    2412             : 
    2413        1275 :                             print(state.files.bnd,
    2414             :                                   "{},{},{}\n",
    2415        1275 :                                   state.dataPlnt->PlantLoop(Count)
    2416        1275 :                                       .LoopSide(LoopSideNum)
    2417        1275 :                                       .Branch(state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.BranchNumOut(Count1))
    2418        1275 :                                       .Name,
    2419        1275 :                                   state.dataPlnt->PlantLoop(Count).Name,
    2420             :                                   LoopString);
    2421             :                         }
    2422             : 
    2423        1275 :                         print(state.files.bnd,
    2424             :                               "     Plant Loop Connector Nodes,   {},Splitter,{},{},{},{},{}\n",
    2425             :                               Count1,
    2426        1275 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.Name,
    2427        1275 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.NodeNameIn,
    2428        1275 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Splitter.NodeNameOut(Count1),
    2429        1275 :                               state.dataPlnt->PlantLoop(Count).Name,
    2430             :                               LoopString);
    2431             :                     }
    2432             :                 }
    2433             : 
    2434             :                 //  Plant Supply Side Mixer
    2435         516 :                 if (state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.Exists) {
    2436         516 :                     const int totalInletNodes = state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.TotalInletNodes;
    2437         516 :                     print(state.files.bnd,
    2438             :                           "   Plant Loop Connector,Mixer,{},{},{},{}\n",
    2439         516 :                           state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.Name,
    2440         516 :                           state.dataPlnt->PlantLoop(Count).Name,
    2441             :                           LoopString,
    2442             :                           totalInletNodes); //',Supply,'//  &
    2443             : 
    2444        1791 :                     for (int Count1 = 1; Count1 <= totalInletNodes; ++Count1) {
    2445        1275 :                         print(state.files.bnd,
    2446             :                               "     Plant Loop Connector Branches,{},Mixer,{},",
    2447             :                               Count1,
    2448        1275 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.Name);
    2449             : 
    2450        1275 :                         if (state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.BranchNumIn(Count1) <= 0) {
    2451           0 :                             print(state.files.bnd, "{},", errstring);
    2452             :                         } else {
    2453        1275 :                             print(state.files.bnd,
    2454             :                                   "{},",
    2455        1275 :                                   state.dataPlnt->PlantLoop(Count)
    2456        1275 :                                       .LoopSide(LoopSideNum)
    2457        1275 :                                       .Branch(state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.BranchNumIn(Count1))
    2458        1275 :                                       .Name);
    2459             :                         }
    2460        1275 :                         if (state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.BranchNumOut <= 0) {
    2461           0 :                             print(state.files.bnd, "{},{},{}\n", errstring, state.dataPlnt->PlantLoop(Count).Name, LoopString);
    2462             :                         } else {
    2463        1275 :                             print(state.files.bnd,
    2464             :                                   "{},{},{}\n",
    2465        1275 :                                   state.dataPlnt->PlantLoop(Count)
    2466        1275 :                                       .LoopSide(LoopSideNum)
    2467        1275 :                                       .Branch(state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.BranchNumOut)
    2468        1275 :                                       .Name,
    2469        1275 :                                   state.dataPlnt->PlantLoop(Count).Name,
    2470             :                                   LoopString);
    2471             :                         }
    2472        1275 :                         print(state.files.bnd,
    2473             :                               "     Plant Loop Connector Nodes,   {},Mixer,{},{},{},{},{}\n",
    2474             :                               Count1,
    2475        1275 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.Name,
    2476        1275 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.NodeNameIn(Count1),
    2477        1275 :                               state.dataPlnt->PlantLoop(Count).LoopSide(LoopSideNum).Mixer.NodeNameOut,
    2478        1275 :                               state.dataPlnt->PlantLoop(Count).Name,
    2479             :                               LoopString);
    2480             :                     }
    2481             :                 }
    2482             :             }
    2483         258 :             print(state.files.bnd,
    2484             :                   " Plant Loop Supply Connection,{},{},{}\n",
    2485         258 :                   state.dataPlnt->PlantLoop(Count).Name,
    2486         258 :                   state.dataPlnt->PlantLoop(Count).LoopSide(DataPlant::LoopSideLocation::Supply).NodeNameOut,
    2487         258 :                   state.dataPlnt->PlantLoop(Count).LoopSide(DataPlant::LoopSideLocation::Demand).NodeNameIn);
    2488         258 :             print(state.files.bnd,
    2489             :                   " Plant Loop Return Connection,{},{},{}\n",
    2490         258 :                   state.dataPlnt->PlantLoop(Count).Name,
    2491         258 :                   state.dataPlnt->PlantLoop(Count).LoopSide(DataPlant::LoopSideLocation::Demand).NodeNameOut,
    2492         258 :                   state.dataPlnt->PlantLoop(Count).LoopSide(DataPlant::LoopSideLocation::Supply).NodeNameIn);
    2493             : 
    2494             :         } //  Plant Demand Side Loop
    2495             : 
    2496         795 :         print(state.files.bnd, "{}\n", "! ===============================================================");
    2497         795 :         int NumOfControlledZones = 0;
    2498        5845 :         for (int Count = 1; Count <= state.dataGlobal->NumOfZones; ++Count) {
    2499        5050 :             if (!allocated(state.dataZoneEquip->ZoneEquipConfig)) continue;
    2500        5050 :             if (state.dataZoneEquip->ZoneEquipConfig(Count).IsControlled) ++NumOfControlledZones;
    2501             :         }
    2502             : 
    2503         795 :         if (NumOfControlledZones > 0) {
    2504         697 :             print(state.files.bnd, "{}\n", "! <# Controlled Zones>,<Number of Controlled Zones>");
    2505         697 :             print(state.files.bnd, " #Controlled Zones,{}\n", NumOfControlledZones);
    2506         697 :             print(state.files.bnd,
    2507             :                   "{}\n",
    2508             :                   "! <Controlled Zone>,<Controlled Zone Name>,<Equip List Name>,<Control List Name>,<Zone Node Name>,<# Inlet Nodes>,<# Exhaust "
    2509             :                   "Nodes>,<# Return Nodes>");
    2510         697 :             print(state.files.bnd,
    2511             :                   "{}\n",
    2512             :                   "! <Controlled Zone Inlet>,<Inlet Node Count>,<Controlled Zone Name>,<Supply Air Inlet Node Name>,<SD Sys:Cooling/Heating "
    2513             :                   "[DD:Cooling] Inlet Node Name>,<DD Sys:Heating Inlet Node Name>");
    2514         697 :             print(state.files.bnd, "{}\n", "! <Controlled Zone Exhaust>,<Exhaust Node Count>,<Controlled Zone Name>,<Exhaust Air Node Name>");
    2515             : 
    2516        5577 :             for (int Count = 1; Count <= state.dataGlobal->NumOfZones; ++Count) {
    2517        4880 :                 if (!state.dataZoneEquip->ZoneEquipConfig(Count).IsControlled) continue;
    2518             : 
    2519        4314 :                 print(state.files.bnd,
    2520             :                       " Controlled Zone,{},{},{},{},{},{},{}\n",
    2521        4314 :                       state.dataZoneEquip->ZoneEquipConfig(Count).ZoneName,
    2522        4314 :                       state.dataZoneEquip->ZoneEquipConfig(Count).EquipListName,
    2523        4314 :                       state.dataZoneEquip->ZoneEquipConfig(Count).ControlListName,
    2524        4314 :                       state.dataLoopNodes->NodeID(state.dataZoneEquip->ZoneEquipConfig(Count).ZoneNode),
    2525        4314 :                       state.dataZoneEquip->ZoneEquipConfig(Count).NumInletNodes,
    2526        4314 :                       state.dataZoneEquip->ZoneEquipConfig(Count).NumExhaustNodes,
    2527        4314 :                       state.dataZoneEquip->ZoneEquipConfig(Count).NumReturnNodes);
    2528        8782 :                 for (int Count1 = 1; Count1 <= state.dataZoneEquip->ZoneEquipConfig(Count).NumInletNodes; ++Count1) {
    2529        4468 :                     std::string ChrName = state.dataLoopNodes->NodeID(state.dataZoneEquip->ZoneEquipConfig(Count).AirDistUnitHeat(Count1).InNode);
    2530        4468 :                     if (ChrName == "Undefined") ChrName = "N/A";
    2531        4468 :                     print(state.files.bnd,
    2532             :                           "   Controlled Zone Inlet,{},{},{},{},{}\n",
    2533             :                           Count1,
    2534        4468 :                           state.dataZoneEquip->ZoneEquipConfig(Count).ZoneName,
    2535        4468 :                           state.dataLoopNodes->NodeID(state.dataZoneEquip->ZoneEquipConfig(Count).InletNode(Count1)),
    2536        4468 :                           state.dataLoopNodes->NodeID(state.dataZoneEquip->ZoneEquipConfig(Count).AirDistUnitCool(Count1).InNode),
    2537             :                           ChrName);
    2538        4468 :                 }
    2539        5161 :                 for (int Count1 = 1; Count1 <= state.dataZoneEquip->ZoneEquipConfig(Count).NumExhaustNodes; ++Count1) {
    2540         847 :                     print(state.files.bnd,
    2541             :                           "   Controlled Zone Exhaust,{},{},{}\n",
    2542             :                           Count1,
    2543         847 :                           state.dataZoneEquip->ZoneEquipConfig(Count).ZoneName,
    2544         847 :                           state.dataLoopNodes->NodeID(state.dataZoneEquip->ZoneEquipConfig(Count).ExhaustNode(Count1)));
    2545             :                 }
    2546        8632 :                 for (int Count1 = 1; Count1 <= state.dataZoneEquip->ZoneEquipConfig(Count).NumReturnNodes; ++Count1) {
    2547        4318 :                     print(state.files.bnd,
    2548             :                           "   Controlled Zone Return,{},{},{}\n",
    2549             :                           Count1,
    2550        4318 :                           state.dataZoneEquip->ZoneEquipConfig(Count).ZoneName,
    2551        4318 :                           state.dataLoopNodes->NodeID(state.dataZoneEquip->ZoneEquipConfig(Count).ReturnNode(Count1)));
    2552             :                 }
    2553             :             }
    2554             : 
    2555             :             // Report Zone Equipment Lists to BND File
    2556         697 :             print(state.files.bnd, "{}\n", "! ===============================================================");
    2557         697 :             print(state.files.bnd, "{}\n", Format_720);
    2558         697 :             print(state.files.bnd, " #Zone Equipment Lists,{}\n", NumOfControlledZones);
    2559         697 :             print(state.files.bnd, "{}\n", Format_722);
    2560         697 :             print(state.files.bnd, "{}\n", Format_723);
    2561             : 
    2562        5577 :             for (int Count = 1; Count <= state.dataGlobal->NumOfZones; ++Count) {
    2563             :                 // Zone equipment list array parallels controlled zone equipment array, so
    2564             :                 // same index finds corresponding data from both arrays
    2565        4880 :                 if (!state.dataZoneEquip->ZoneEquipConfig(Count).IsControlled) continue;
    2566             : 
    2567        4314 :                 print(state.files.bnd,
    2568             :                       " Zone Equipment List,{},{},{},{}\n",
    2569             :                       Count,
    2570        4314 :                       state.dataZoneEquip->ZoneEquipList(Count).Name,
    2571        4314 :                       state.dataZoneEquip->ZoneEquipConfig(Count).ZoneName,
    2572        4314 :                       state.dataZoneEquip->ZoneEquipList(Count).NumOfEquipTypes);
    2573             : 
    2574        9207 :                 for (int Count1 = 1; Count1 <= state.dataZoneEquip->ZoneEquipList(Count).NumOfEquipTypes; ++Count1) {
    2575        4893 :                     print(state.files.bnd,
    2576             :                           "   Zone Equipment Component,{},{},{},{},{},{}\n",
    2577             :                           Count1,
    2578        4893 :                           state.dataZoneEquip->ZoneEquipList(Count).EquipTypeName(Count1),
    2579        4893 :                           state.dataZoneEquip->ZoneEquipList(Count).EquipName(Count1),
    2580        4893 :                           state.dataZoneEquip->ZoneEquipConfig(Count).ZoneName,
    2581        4893 :                           state.dataZoneEquip->ZoneEquipList(Count).CoolingPriority(Count1),
    2582        4893 :                           state.dataZoneEquip->ZoneEquipList(Count).HeatingPriority(Count1));
    2583             :                 }
    2584             :             }
    2585             :         }
    2586             : 
    2587             :         // Report Dual Duct Dampers to BND File
    2588         795 :         DualDuct::ReportDualDuctConnections(state);
    2589             : 
    2590         795 :         if (state.dataBranchNodeConnections->NumNodeConnectionErrors == 0) {
    2591         790 :             ShowMessage(state, "No node connection errors were found.");
    2592             :         } else {
    2593           5 :             if (state.dataBranchNodeConnections->NumNodeConnectionErrors > 1) {
    2594           2 :                 ShowMessage(state, format("There were {} node connection errors noted.", state.dataBranchNodeConnections->NumNodeConnectionErrors));
    2595             :             } else {
    2596           3 :                 ShowMessage(state, format("There was {} node connection error noted.", state.dataBranchNodeConnections->NumNodeConnectionErrors));
    2597             :             }
    2598             :         }
    2599             : 
    2600         795 :         state.dataErrTracking->AskForConnectionsReport = false;
    2601         795 :     }
    2602             : 
    2603         796 :     void PostIPProcessing(EnergyPlusData &state)
    2604             :     {
    2605             :         // SUBROUTINE INFORMATION:
    2606             :         //       AUTHOR         Linda Lawrie
    2607             :         //       DATE WRITTEN   August 2010
    2608             : 
    2609             :         // PURPOSE OF THIS SUBROUTINE:
    2610             :         // This provides post processing (for errors, etc) directly after the InputProcessor
    2611             :         // finishes.  Code originally in the Input Processor.
    2612             : 
    2613             :         // Using/Aliasing
    2614             :         // using SQLiteProcedures::CreateSQLiteDatabase;
    2615         796 :         state.dataGlobal->DoingInputProcessing = false;
    2616             : 
    2617         796 :         state.dataInputProcessing->inputProcessor->preProcessorCheck(
    2618         796 :             state, state.dataSimulationManager->PreP_Fatal); // Check Preprocessor objects for warning, severe, etc errors.
    2619             : 
    2620         796 :         if (state.dataSimulationManager->PreP_Fatal) {
    2621           0 :             ShowFatalError(state, "Preprocessor condition(s) cause termination.");
    2622             :         }
    2623             : 
    2624         796 :         state.dataInputProcessing->inputProcessor->preScanReportingVariables(state);
    2625         796 :     }
    2626             : 
    2627         796 :     void isInputObjectUsed(EnergyPlusData &state)
    2628             :     {
    2629             :         // there is a need to know if certain object are used in the simulation
    2630             :         // this may not be the best place to do this but it's a start at early reading of input data
    2631             :         // this concept could grow to include reading all inputs prior to the start of the simulation so all data is available
    2632             :         // once inputs are processed, read in all getInputs. They will be read early and will not be read again so there is no duplication
    2633             : 
    2634             :         // for example, AirLoopHVAC:DOAS systems autosize on weather data, and WeatherManager processes that data
    2635             :         // there is no need to process that data if there are no DOAS used in the simulation
    2636        1592 :         state.dataGlobal->AirLoopHVACDOASUsedInSim =
    2637         796 :             state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "AirLoopHVAC:DedicatedOutdoorAirSystem") > 0;
    2638         796 :         EMSManager::CheckIfAnyEMS(state);
    2639         796 :         PlantManager::CheckIfAnyPlant(state);
    2640         796 :         PlantPipingSystemsManager::CheckIfAnySlabs(state);
    2641         796 :         PlantPipingSystemsManager::CheckIfAnyBasements(state);
    2642         796 :         SetPointManager::CheckIfAnyIdealCondEntSetPoint(state);
    2643         796 :     }
    2644             : 
    2645             : } // namespace SimulationManager
    2646             : 
    2647             : // EXTERNAL SUBROUTINES:
    2648             : 
    2649        1445 : void Resimulate(EnergyPlusData &state,
    2650             :                 bool &ResimExt, // Flag to resimulate the exterior energy use simulation
    2651             :                 bool &ResimHB,  // Flag to resimulate the heat balance simulation (including HVAC)
    2652             :                 bool &ResimHVAC // Flag to resimulate the HVAC simulation
    2653             : )
    2654             : {
    2655             : 
    2656             :     // SUBROUTINE INFORMATION:
    2657             :     //       AUTHOR         Peter Graham Ellis
    2658             :     //       DATE WRITTEN   August 2005
    2659             :     //       MODIFIED       Sep 2011 LKL/BG - resimulate only zones needing it for Radiant systems
    2660             :     //       RE-ENGINEERED  na
    2661             : 
    2662             :     // PURPOSE OF THIS SUBROUTINE:
    2663             :     // This subroutine is called as necessary by the Demand Manager to resimulate some of the modules that have
    2664             :     // already been simulated for the current timestep.  For example, if LIGHTS are demand limited, the lighting
    2665             :     // power is reduced which also impacts the zone internal heat gains and therefore requires that the entire
    2666             :     // zone heat balance must be resimulated.
    2667             : 
    2668             :     // METHODOLOGY EMPLOYED:
    2669             :     // If the zone heat balance must be resimulated, all the major subroutines are called sequentially in order
    2670             :     // to recalculate the impacts of demand limiting.  This routine is called from ManageHVAC _before_ any variables
    2671             :     // are reported or histories are updated.  This routine can be called multiple times without the overall
    2672             :     // simulation moving forward in time.
    2673             :     // If only HVAC components are demand limited, then the HVAC system is resimulated, not the entire heat balance.
    2674             :     // Similarly, if ony exterior lights and equipment are demand limited, it is only necessary to resimulate the
    2675             :     // exterior energy use, not the entire heat balance, nor the HVAC system.
    2676             :     // Below is the hierarchy of subroutine calls.  The calls marked with an asterisk are resimulated here.
    2677             :     // ManageSimulation
    2678             :     //     ManageWeather
    2679             :     //     ManageDemand
    2680             :     //   * ManageExteriorEnergyUse
    2681             :     //     ManageHeatBalance
    2682             :     //       * InitHeatBalance
    2683             :     //             PerformSolarCalculations
    2684             :     //         ManageSurfaceHeatBalance
    2685             :     //           * InitSurfaceHeatBalance
    2686             :     //                 ManageInternalHeatGains
    2687             :     //           * CalcHeatBalanceOutsideSurf
    2688             :     //           * CalcHeatBalanceInsideSurf
    2689             :     //             ManageAirHeatBalance
    2690             :     //                *InitAirHeatBalance
    2691             :     //                 CalcHeatBalanceAir
    2692             :     //                   * CalcAirFlow
    2693             :     //                   * ManageRefrigeratedCaseRacks
    2694             :     //                     ManageHVAC
    2695             :     //                       * ManageZoneAirUpdates 'GET ZONE SETPOINTS'
    2696             :     //                       * ManageZoneAirUpdates 'PREDICT'
    2697             :     //                       * SimHVAC
    2698             :     //                         UpdateDataandReport
    2699             :     //                 ReportAirHeatBalance
    2700             :     //             UpdateFinalSurfaceHeatBalance
    2701             :     //             UpdateThermalHistories
    2702             :     //             UpdateMoistureHistories
    2703             :     //             ManageThermalComfort
    2704             :     //             ReportSurfaceHeatBalance
    2705             :     //         RecKeepHeatBalance
    2706             :     //         ReportHeatBalance
    2707             : 
    2708             :     // Using/Aliasing
    2709             :     using ExteriorEnergyUse::ManageExteriorEnergyUse;
    2710             :     using HeatBalanceAirManager::InitAirHeatBalance;
    2711             :     using HeatBalanceSurfaceManager::InitSurfaceHeatBalance;
    2712             :     using HVACManager::SimHVAC;
    2713             :     using RefrigeratedCase::ManageRefrigeratedCaseRacks;
    2714             :     using ZoneContaminantPredictorCorrector::ManageZoneContaminanUpdates;
    2715             :     using ZoneTempPredictorCorrector::ManageZoneAirUpdates;
    2716             :     using namespace ZoneEquipmentManager;
    2717             : 
    2718             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2719        1445 :     Real64 ZoneTempChange(0.0); // Dummy variable needed for calling ManageZoneAirUpdates
    2720             : 
    2721        1445 :     if (ResimExt) {
    2722          55 :         ManageExteriorEnergyUse(state);
    2723             : 
    2724          55 :         ++state.dataDemandManager->DemandManagerExtIterations;
    2725             :     }
    2726             : 
    2727        1445 :     if (ResimHB) {
    2728             :         // Surface simulation
    2729         196 :         InitSurfaceHeatBalance(state);
    2730         196 :         HeatBalanceSurfaceManager::CalcHeatBalanceOutsideSurf(state);
    2731         196 :         HeatBalanceSurfaceManager::CalcHeatBalanceInsideSurf(state);
    2732             : 
    2733             :         // Air simulation
    2734         196 :         InitAirHeatBalance(state);
    2735         196 :         ManageRefrigeratedCaseRacks(state);
    2736             : 
    2737         196 :         ++state.dataDemandManager->DemandManagerHBIterations;
    2738         196 :         ResimHVAC = true; // Make sure HVAC is resimulated too
    2739             :     }
    2740             : 
    2741        1445 :     if (ResimHVAC) {
    2742             :         // HVAC simulation
    2743         238 :         ManageZoneAirUpdates(state,
    2744             :                              DataHeatBalFanSys::PredictorCorrectorCtrl::GetZoneSetPoints,
    2745             :                              ZoneTempChange,
    2746             :                              false,
    2747         238 :                              state.dataHVACGlobal->UseZoneTimeStepHistory,
    2748             :                              0.0);
    2749         238 :         if (state.dataContaminantBalance->Contaminant.SimulateContaminants)
    2750           0 :             ManageZoneContaminanUpdates(
    2751           0 :                 state, DataHeatBalFanSys::PredictorCorrectorCtrl::GetZoneSetPoints, false, state.dataHVACGlobal->UseZoneTimeStepHistory, 0.0);
    2752         476 :         CalcAirFlowSimple(
    2753         238 :             state, 0, state.dataHeatBal->ZoneAirMassFlow.AdjustZoneMixingFlow, state.dataHeatBal->ZoneAirMassFlow.AdjustZoneInfiltrationFlow);
    2754         238 :         ManageZoneAirUpdates(
    2755         238 :             state, DataHeatBalFanSys::PredictorCorrectorCtrl::PredictStep, ZoneTempChange, false, state.dataHVACGlobal->UseZoneTimeStepHistory, 0.0);
    2756         238 :         if (state.dataContaminantBalance->Contaminant.SimulateContaminants)
    2757           0 :             ManageZoneContaminanUpdates(
    2758           0 :                 state, DataHeatBalFanSys::PredictorCorrectorCtrl::PredictStep, false, state.dataHVACGlobal->UseZoneTimeStepHistory, 0.0);
    2759         238 :         SimHVAC(state);
    2760             : 
    2761         238 :         ++state.dataDemandManager->DemandManagerHVACIterations;
    2762             :     }
    2763        1445 : }
    2764             : 
    2765             : } // namespace EnergyPlus

Generated by: LCOV version 1.14