LCOV - code coverage report
Current view: top level - EnergyPlus - UnitarySystem.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 12 45 26.7 %
Date: 2023-01-17 19:17:23 Functions: 14 15 93.3 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2023, The Board of Trustees of the University of Illinois,
       2             : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3             : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4             : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5             : // contributors. All rights reserved.
       6             : //
       7             : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8             : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9             : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10             : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11             : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12             : //
      13             : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14             : // provided that the following conditions are met:
      15             : //
      16             : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17             : //     conditions and the following disclaimer.
      18             : //
      19             : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20             : //     conditions and the following disclaimer in the documentation and/or other materials
      21             : //     provided with the distribution.
      22             : //
      23             : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24             : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25             : //     used to endorse or promote products derived from this software without specific prior
      26             : //     written permission.
      27             : //
      28             : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29             : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30             : //     reference solely to the software portion of its product, Licensee must refer to the
      31             : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32             : //     obtained under this License and may not use a different name for the software. Except as
      33             : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34             : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35             : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36             : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37             : //
      38             : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39             : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40             : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41             : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42             : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43             : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44             : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45             : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46             : // POSSIBILITY OF SUCH DAMAGE.
      47             : 
      48             : #ifndef ENERGYPLUS_UNITARYSYSTEM_HH
      49             : #define ENERGYPLUS_UNITARYSYSTEM_HH
      50             : 
      51             : // C++ headers
      52             : #include <string>
      53             : #include <vector>
      54             : 
      55             : // EnergyPlus headers
      56             : #include <EnergyPlus/Data/BaseData.hh>
      57             : #include <EnergyPlus/DataHVACGlobals.hh>
      58             : #include <EnergyPlus/DataHVACSystems.hh>
      59             : #include <EnergyPlus/DataHeatBalance.hh>
      60             : #include <EnergyPlus/DataZoneEquipment.hh>
      61             : #include <EnergyPlus/PackagedThermalStorageCoil.hh>
      62             : #include <EnergyPlus/Plant/PlantLocation.hh>
      63             : #include <EnergyPlus/SimAirServingZones.hh>
      64             : 
      65             : namespace EnergyPlus {
      66             : 
      67             : // Forward declarations
      68             : struct EnergyPlusData;
      69             : 
      70             : namespace UnitarySystems {
      71             : 
      72             :     // Supply Air Sizing Option
      73             :     int constexpr None = 1;
      74             :     int constexpr SupplyAirFlowRate = 2;
      75             :     int constexpr FlowPerFloorArea = 3;
      76             :     int constexpr FractionOfAutoSizedCoolingValue = 4;
      77             :     int constexpr FractionOfAutoSizedHeatingValue = 5;
      78             :     int constexpr FlowPerCoolingCapacity = 6;
      79             :     int constexpr FlowPerHeatingCapacity = 7;
      80             : 
      81             :     // Last mode of operation
      82             :     int constexpr CoolingMode = 1; // last compressor operating mode was in cooling
      83             :     int constexpr HeatingMode = 2; // last compressor operating mode was in heating
      84             :     int constexpr NoCoolHeat = 3;  // last operating mode was no cooling or heating
      85             : 
      86        3023 :     struct UnitarySysInputSpec
      87             :     {
      88             :         // system_type is not an object input but the actual type of object (e.g., UnitarySystem, CoilSystem:Cooling:DX, etc.).
      89             :         // Each specific getInput sets this string accordingly so that processInputSpec knows the object type
      90             :         // that will be used in warnings and reporting. This is a work in progress.
      91             :         std::string system_type;
      92             : 
      93             :         // object input fields
      94             :         std::string name;
      95             :         std::string control_type;
      96             :         std::string controlling_zone_or_thermostat_location;
      97             :         std::string dehumidification_control_type;
      98             :         std::string availability_schedule_name;
      99             :         std::string air_inlet_node_name;
     100             :         std::string air_outlet_node_name;
     101             :         std::string supply_fan_object_type;
     102             :         std::string supply_fan_name;
     103             :         std::string fan_placement;
     104             :         std::string supply_air_fan_operating_mode_schedule_name;
     105             :         std::string heating_coil_object_type;
     106             :         std::string heating_coil_name;
     107             :         Real64 dx_heating_coil_sizing_ratio = 1.0;
     108             :         std::string cooling_coil_object_type;
     109             :         std::string cooling_coil_name;
     110             :         std::string use_doas_dx_cooling_coil;
     111             :         Real64 minimum_supply_air_temperature = 2.0;
     112             :         std::string latent_load_control;
     113             :         std::string supplemental_heating_coil_object_type;
     114             :         std::string supplemental_heating_coil_name;
     115             :         std::string cooling_supply_air_flow_rate_method;
     116             :         Real64 cooling_supply_air_flow_rate = -999.0;
     117             :         Real64 cooling_supply_air_flow_rate_per_floor_area = -999.0;
     118             :         Real64 cooling_fraction_of_autosized_cooling_supply_air_flow_rate = -999.0;
     119             :         Real64 cooling_supply_air_flow_rate_per_unit_of_capacity = -999.0;
     120             :         std::string heating_supply_air_flow_rate_method;
     121             :         Real64 heating_supply_air_flow_rate = -999.0;
     122             :         Real64 heating_supply_air_flow_rate_per_floor_area = -999.0;
     123             :         Real64 heating_fraction_of_autosized_heating_supply_air_flow_rate = -999.0;
     124             :         Real64 heating_supply_air_flow_rate_per_unit_of_capacity = -999.0;
     125             :         std::string no_load_supply_air_flow_rate_method;
     126             :         Real64 no_load_supply_air_flow_rate = -999.0;
     127             :         Real64 no_load_supply_air_flow_rate_per_floor_area = -999.0;
     128             :         Real64 no_load_fraction_of_autosized_cooling_supply_air_flow_rate = -999.0;
     129             :         Real64 no_load_fraction_of_autosized_heating_supply_air_flow_rate = -999.0;
     130             :         Real64 no_load_supply_air_flow_rate_per_unit_of_capacity_during_cooling_operation = -999.0;
     131             :         Real64 no_load_supply_air_flow_rate_per_unit_of_capacity_during_heating_operation = -999.0;
     132             :         Real64 maximum_supply_air_temperature = 80.0;
     133             :         Real64 maximum_supply_air_temperature_from_supplemental_heater = 50.0;
     134             :         Real64 maximum_outdoor_dry_bulb_temperature_for_supplemental_heater_operation = 21.0;
     135             :         std::string outdoor_dry_bulb_temperature_sensor_node_name;
     136             :         std::string heat_pump_coil_water_flow_mode;
     137             :         Real64 maximum_cycling_rate = 2.5;
     138             :         Real64 heat_pump_time_constant = 60.0;
     139             :         Real64 fraction_of_on_cycle_power_use = 0.01;
     140             :         Real64 heat_pump_fan_delay_time = 60.0;
     141             :         Real64 ancillary_on_cycle_electric_power = 0.0;
     142             :         Real64 ancillary_off_cycle_electric_power = 0.0;
     143             :         Real64 design_heat_recovery_water_flow_rate = 0.0;
     144             :         Real64 maximum_temperature_for_heat_recovery = 80.0;
     145             :         std::string heat_recovery_water_inlet_node_name;
     146             :         std::string heat_recovery_water_outlet_node_name;
     147             :         std::string design_specification_multispeed_object_type;
     148             :         std::string design_specification_multispeed_object_name;
     149             : 
     150             :         // inputs required by non-UnitarySystem parent objects
     151             :         std::string dx_cooling_coil_system_sensor_node_name;
     152             :         std::string oa_mixer_type;
     153             :         std::string oa_mixer_name;
     154             :         std::string avail_manager_list_name;
     155             :         std::string design_spec_zonehvac_sizing_object_name;
     156             :         Real64 cooling_oa_flow_rate = 0.0;
     157             :         Real64 heating_oa_flow_rate = 0.0;
     158             :         Real64 no_load_oa_flow_rate = 0.0;
     159             :         Real64 heat_conv_tol = 0.001;
     160             :         Real64 cool_conv_tol = 0.001;
     161             : 
     162        2370 :         UnitarySysInputSpec() = default;
     163        3617 :         ~UnitarySysInputSpec() = default;
     164             :     };
     165             : 
     166         110 :     struct DesignSpecMSHP
     167             :     {
     168             : 
     169             :     public:
     170             :         std::string name;
     171             :         static DesignSpecMSHP *factory(EnergyPlusData &state, int object_type_of_num, std::string const objectName);
     172             :         int numOfSpeedHeating = 0;
     173             :         int numOfSpeedCooling = 0;
     174             :         Real64 noLoadAirFlowRateRatio = 1.0;
     175             :         std::vector<Real64> coolingVolFlowRatio; // The ratio of flow to max for this speed
     176             :         std::vector<Real64> heatingVolFlowRatio; // The ratio of flow to max for this speed
     177             : 
     178             :         //    private:
     179             :         int m_DesignSpecMSHPType_Num = 0;
     180             :         bool m_SingleModeFlag = false;
     181             : 
     182             :         static void getDesignSpecMSHP(EnergyPlusData &state);
     183             :         static void getDesignSpecMSHPdata([[maybe_unused]] EnergyPlusData &state, bool errorsFound);
     184             : 
     185         165 :         DesignSpecMSHP() = default;
     186         275 :         ~DesignSpecMSHP() = default;
     187             :     };
     188             : 
     189        3023 :     struct UnitarySys : HVACSystemData
     190             :     {
     191             : 
     192             :         enum class UnitarySysCtrlType : int
     193             :         {
     194             :             Invalid = -1,
     195             :             None,
     196             :             Load,
     197             :             Setpoint,
     198             :             CCMASHRAE,
     199             :             Num
     200             :         };
     201             : 
     202             :         enum class DehumCtrlType : int
     203             :         {
     204             :             Invalid = -1,
     205             :             None,
     206             :             CoolReheat,
     207             :             Multimode,
     208             :             Num
     209             :         };
     210             : 
     211             :         enum class FanPlace : int
     212             :         {
     213             :             Invalid = -1,
     214             :             NotYetSet,
     215             :             BlowThru,
     216             :             DrawThru,
     217             :             Num
     218             :         };
     219             : 
     220             :         // Airflow control for constant fan mode
     221             :         enum class UseCompFlow
     222             :         {
     223             :             Invalid = -1,
     224             :             On,  // set compressor OFF air flow rate equal to compressor ON air flow rate
     225             :             Off, // set compressor OFF air flow rate equal to user defined value
     226             :             Num
     227             :         };
     228             : 
     229             :         // Parent models simulated using UnitarySystem source code
     230             :         enum class SysType
     231             :         {
     232             :             Invalid = -1,
     233             :             Unitary,          // AirloopHVAC:UnitarySystem
     234             :             CoilCoolingDX,    // CoilSystem:Cooling:DX
     235             :             CoilCoolingWater, // CoilSystem:Cooling:Water
     236             :             PackagedAC,       // ZoneHVAC:PackagedTerminalAirConditioner
     237             :             PackagedHP,       // ZoneHVAC:PackagedTerminalHeatPump
     238             :             PackagedWSHP,     // ZoneHVAC:WaterToAirHeatPump
     239             :             Num,
     240             :         };
     241             : 
     242             :         UnitarySysInputSpec input_specs;
     243             :         int m_UnitarySysNum = -1;
     244             :         SysType m_sysType = SysType::Invalid;
     245             :         bool m_ThisSysInputShouldBeGotten = true;
     246             :         int m_SysAvailSchedPtr = 0; // Pointer to the availability schedule
     247             :         UnitarySysCtrlType m_ControlType = UnitarySysCtrlType::None;
     248             :         DehumCtrlType m_DehumidControlType_Num = DehumCtrlType::None;
     249             :         bool m_Humidistat = false;
     250             :         bool m_ValidASHRAECoolCoil = false;
     251             :         bool m_ValidASHRAEHeatCoil = false;
     252             :         bool m_SimASHRAEModel = false; // flag denoting that ASHRAE model (SZVAV) should be used
     253             :         bool m_setFaultModelInput = true;
     254             :         int m_FanIndex = 0;
     255             :         FanPlace m_FanPlace = FanPlace::NotYetSet;
     256             :         int m_FanOpModeSchedPtr = 0;
     257             :         bool m_FanExists = false;
     258             :         int m_FanType_Num = 0;
     259             :         bool m_RequestAutoSize = false;
     260             :         Real64 m_ActualFanVolFlowRate = 0.0;
     261             :         Real64 m_DesignFanVolFlowRate = 0.0;
     262             :         Real64 m_DesignMassFlowRate = 0.0;
     263             :         int m_FanAvailSchedPtr = 0;
     264             :         int m_FanOpMode = 0;
     265             :         int m_ATMixerIndex = 0;
     266             :         int m_ATMixerPriNode = 0;
     267             :         int m_ATMixerSecNode = 0;
     268             :         bool m_AirLoopEquipment = true; // ?
     269             :         int m_ZoneInletNode = 0;
     270             :         int m_ZoneSequenceCoolingNum = 0;
     271             :         int m_ZoneSequenceHeatingNum = 0;
     272             :         bool m_HeatCoilExists = false;
     273             :         Real64 m_HeatingSizingRatio = 1.0;
     274             :         int m_HeatingCoilType_Num = 0;
     275             :         bool m_DXHeatingCoil = false;
     276             :         int m_HeatingCoilIndex = 0;
     277             :         int m_HeatingCoilAvailSchPtr = 0;
     278             :         Real64 m_DesignHeatingCapacity = 0.0;
     279             :         Real64 m_MaxHeatAirVolFlow = 0.0;
     280             :         int m_NumOfSpeedHeating = 0;
     281             :         int m_NumOfSpeedSuppHeating = 0;
     282             :         bool m_MultiSpeedHeatingCoil = false;
     283             :         bool m_VarSpeedHeatingCoil = false;
     284             :         int HeatCtrlNode = 0;
     285             :         bool m_CoolCoilExists = false;
     286             :         int m_CoolingCoilType_Num = 0;
     287             :         int m_NumOfSpeedCooling = 0;
     288             :         int m_CoolingCoilAvailSchPtr = 0;
     289             :         Real64 m_DesignCoolingCapacity = 0.0;
     290             :         Real64 m_MaxCoolAirVolFlow = 0.0;
     291             :         int m_CondenserNodeNum = 0;
     292             :         DataHeatBalance::RefrigCondenserType m_CondenserType = DataHeatBalance::RefrigCondenserType::Invalid;
     293             :         int m_CoolingCoilIndex = 0;
     294             :         bool m_HeatPump = false;
     295             :         int m_ActualDXCoilIndexForHXAssisted = 0;
     296             :         bool m_DiscreteSpeedCoolingCoil = false;
     297             :         bool m_ContSpeedCoolingCoil = false;
     298             :         int CoolCtrlNode = 0;
     299             :         int m_WaterCyclingMode = 0;
     300             :         bool m_ISHundredPercentDOASDXCoil = false;
     301             :         bool m_RunOnSensibleLoad = false;
     302             :         bool m_RunOnLatentLoad = false;
     303             :         bool m_RunOnLatentOnlyWithSensible = false;
     304             :         int m_DehumidificationMode = 0;
     305             :         int m_SuppHeatCoilType_Num = 0;
     306             :         bool m_SuppCoilExists = false;
     307             :         Real64 m_DesignSuppHeatingCapacity = 0.0;
     308             :         int m_SuppCoilAirInletNode = 0;
     309             :         int SuppCoilOutletNodeNum = 0;
     310             :         int m_SuppCoilFluidInletNode = 0;
     311             :         Real64 m_MaxSuppCoilFluidFlow = 0.0;
     312             :         int m_SuppHeatCoilIndex = 0;
     313             :         int SuppCtrlNode = 0;
     314             :         Real64 m_SupHeaterLoad = 0.0;
     315             :         int m_CoolingSAFMethod = 0;
     316             :         int m_HeatingSAFMethod = 0;
     317             :         int m_NoCoolHeatSAFMethod = 0;
     318             :         int m_CoolingCapMethod = 0;
     319             :         int m_HeatingCapMethod = 0;
     320             :         Real64 m_MaxNoCoolHeatAirVolFlow = 0.0;
     321             :         UseCompFlow m_AirFlowControl = UseCompFlow::Invalid;
     322             :         bool m_CoolingCoilUpstream = true;
     323             :         Real64 m_MaxOATSuppHeat = 0.0;
     324             :         Real64 m_MinOATCompressorCooling = 0.0;
     325             :         Real64 m_MinOATCompressorHeating = 0.0;
     326             :         Real64 m_MaxONOFFCyclesperHour = 0.0;
     327             :         Real64 m_HPTimeConstant = 0.0;
     328             :         Real64 m_OnCyclePowerFraction = 0.0;
     329             :         Real64 m_FanDelayTime = 0.0;
     330             :         Real64 m_AncillaryOnPower = 0.0;
     331             :         Real64 m_AncillaryOffPower = 0.0;
     332             :         Real64 m_DesignHRWaterVolumeFlow = 0.0;
     333             :         Real64 m_MaxHROutletWaterTemp = 0.0;
     334             :         bool m_HeatRecActive = false;
     335             :         int m_HeatRecoveryInletNodeNum = 0;
     336             :         int m_HeatRecoveryOutletNodeNum = 0;
     337             :         int m_DesignSpecMSHPIndex = -1;
     338             :         Real64 m_NoLoadAirFlowRateRatio = 1.0;
     339             :         int m_SingleMode = 0;
     340             :         bool m_MultiOrVarSpeedHeatCoil = false;
     341             :         bool m_MultiOrVarSpeedCoolCoil = false;
     342             :         Real64 m_PartLoadFrac = 0.0;
     343             :         Real64 m_CoolingPartLoadFrac = 0.0;
     344             :         Real64 m_HeatingPartLoadFrac = 0.0;
     345             :         Real64 m_SuppHeatPartLoadFrac = 0.0;
     346             :         Real64 m_HeatCompPartLoadRatio = 0.0;
     347             :         Real64 m_CoolCompPartLoadRatio = 0.0;
     348             :         Real64 m_SpeedRatio = 0.0;
     349             :         Real64 m_CycRatio = 0.0;
     350             : 
     351             :         bool m_MyEnvrnFlag = true;
     352             :         bool m_MyEnvrnFlag2 = true;
     353             :         bool m_MyPlantScanFlag = true;
     354             :         bool m_MySuppCoilPlantScanFlag = true;
     355             :         bool m_MySetPointCheckFlag = true;
     356             :         bool m_MySizingCheckFlag = true;
     357             :         bool m_InitHeatPump = false; // Heat pump initialization flag (for error reporting)
     358             :         PlantLocation m_HRPlantLoc;
     359             :         PlantLocation m_SuppCoilPlantLoc;
     360             :         int m_SuppCoilFluidOutletNodeNum = 0;
     361             : 
     362             :         Real64 m_WSHPRuntimeFrac = 0.0;
     363             :         Real64 m_CompPartLoadRatio = 0.0;
     364             :         Real64 m_CoolingCoilSensDemand = 0.0;
     365             :         Real64 m_CoolingCoilLatentDemand = 0.0;
     366             :         Real64 m_HeatingCoilSensDemand = 0.0;
     367             :         Real64 m_SenLoadLoss = 0.0;
     368             :         Real64 m_LatLoadLoss = 0.0;
     369             :         Real64 m_DesignHeatRecMassFlowRate = 0.0;
     370             :         Real64 m_HeatRecoveryMassFlowRate = 0.0;
     371             :         Real64 m_HeatRecoveryRate = 0.0;
     372             :         Real64 m_HeatRecoveryEnergy = 0.0;
     373             :         Real64 m_HeatRecoveryInletTemp = 0.0;
     374             :         Real64 m_HeatRecoveryOutletTemp = 0.0;
     375             : 
     376             :         int m_IterationCounter = 0;
     377             : 
     378             :         Real64 m_DesiredOutletTemp = 0.0;
     379             :         Real64 m_DesiredOutletHumRat = 0.0;
     380             :         int m_FrostControlStatus = 0;
     381             : 
     382             :         Real64 m_CoolingCycRatio = 0.0;
     383             :         Real64 m_CoolingSpeedRatio = 0.0;
     384             :         int m_CoolingSpeedNum = 0;
     385             :         Real64 m_HeatingCycRatio = 0.0;
     386             :         Real64 m_HeatingSpeedRatio = 0.0;
     387             :         int m_HeatingSpeedNum = 0;
     388             :         int m_SpeedNum = 0;
     389             :         Real64 m_SuppHeatingCycRatio = 0.0;
     390             :         Real64 m_SuppHeatingSpeedRatio = 0.0;
     391             :         int m_SuppHeatingSpeedNum = 0;
     392             : 
     393             :         bool m_EMSOverrideCoilSpeedNumOn = false;
     394             :         Real64 m_EMSOverrideCoilSpeedNumValue = 0.0;
     395             :         bool m_EMSOverrideSuppCoilSpeedNumOn = false;
     396             :         Real64 m_EMSOverrideSuppCoilSpeedNumValue = 0.0;
     397             :         int m_CoilSpeedErrIdx = 0;
     398             : 
     399             :         Real64 m_DehumidInducedHeatingDemandRate = 0.0;
     400             : 
     401             :         Real64 m_TotalAuxElecPower = 0.0;
     402             :         Real64 m_HeatingAuxElecConsumption = 0.0;
     403             :         Real64 m_CoolingAuxElecConsumption = 0.0;
     404             :         Real64 m_ElecPower = 0.0;
     405             :         Real64 m_ElecPowerConsumption = 0.0;
     406             : 
     407             :         int m_LastMode = 0;
     408             :         bool m_FirstPass = true;
     409             : 
     410             :         Real64 m_TotCoolEnergyRate = 0.0;
     411             :         Real64 m_TotCoolEnergy = 0.0;
     412             :         Real64 m_SensCoolEnergyRate = 0.0;
     413             :         Real64 m_SensCoolEnergy = 0.0;
     414             :         Real64 m_LatCoolEnergyRate = 0.0;
     415             :         Real64 m_LatCoolEnergy = 0.0;
     416             :         Real64 m_TotHeatEnergyRate = 0.0;
     417             :         Real64 m_TotHeatEnergy = 0.0;
     418             :         Real64 m_SensHeatEnergyRate = 0.0;
     419             :         Real64 m_SensHeatEnergy = 0.0;
     420             :         Real64 m_LatHeatEnergyRate = 0.0;
     421             :         Real64 m_LatHeatEnergy = 0.0;
     422             : 
     423             :         bool m_DesignFanVolFlowRateEMSOverrideOn = false;       // If true, then EMS is calling to override autosize fan flow
     424             :         bool m_MaxHeatAirVolFlowEMSOverrideOn = false;          // If true, then EMS is calling to override autosize fan flow
     425             :         bool m_MaxCoolAirVolFlowEMSOverrideOn = false;          // If true, then EMS is calling to override autosize fan flow
     426             :         bool m_MaxNoCoolHeatAirVolFlowEMSOverrideOn = false;    // If true, then EMS is calling to override autosize fan flow
     427             :         Real64 m_DesignFanVolFlowRateEMSOverrideValue = 0.0;    // EMS value for override of fan flow rate autosize [m3/s]
     428             :         Real64 m_MaxHeatAirVolFlowEMSOverrideValue = 0.0;       // EMS value for override of fan flow rate autosize [m3/s]
     429             :         Real64 m_MaxCoolAirVolFlowEMSOverrideValue = 0.0;       // EMS value for override of fan flow rate autosize [m3/s]
     430             :         Real64 m_MaxNoCoolHeatAirVolFlowEMSOverrideValue = 0.0; // EMS value for override of fan flow rate autosize [m3/s]
     431             :         bool m_EMSOverrideSensZoneLoadRequest = false;          // If true, then EMS is calling to override zone load
     432             :         bool m_EMSOverrideMoistZoneLoadRequest = false;         // If true, then EMS is calling to override zone load
     433             :         Real64 m_EMSSensibleZoneLoadValue = 0.0;                // Value EMS is directing to use
     434             :         Real64 m_EMSMoistureZoneLoadValue = 0.0;                // Value EMS is directing to use
     435             :         // Staged thermostat control
     436             :         int m_StageNum = 0;    // Stage number specified by staged thermostat
     437             :         bool m_Staged = false; // Using Staged thermostat
     438             : 
     439             :         Real64 m_HeatingFanSpeedRatio = 0.0;
     440             :         Real64 m_CoolingFanSpeedRatio = 0.0;
     441             :         Real64 m_NoHeatCoolSpeedRatio = 0.0;
     442             :         bool m_MyFanFlag = true;
     443             :         bool m_MyCheckFlag = true;
     444             :         Real64 m_SensibleLoadMet = 0.0;
     445             :         Real64 m_LatentLoadMet = 0.0;
     446             :         bool m_MyStagedFlag = false;
     447             :         Real64 m_SensibleLoadPredicted = 0.0;
     448             :         Real64 m_MoistureLoadPredicted = 0.0;
     449             : 
     450             :         // Fault model of coil SAT sensor
     451             :         bool m_FaultyCoilSATFlag = false;   // True if the coil has SAT sensor fault
     452             :         int m_FaultyCoilSATIndex = 0;       // Index of the fault object corresponding to the coil
     453             :         Real64 m_FaultyCoilSATOffset = 0.0; // Coil SAT sensor offset
     454             : 
     455             :         PackagedThermalStorageCoil::PTSCOperatingMode m_TESOpMode = PackagedThermalStorageCoil::PTSCOperatingMode::Invalid;
     456             :         bool m_initLoadBasedControlAirLoopPass = false;
     457             :         int m_airLoopPassCounter = 0;
     458             :         int m_airLoopReturnCounter = 0;
     459             :         bool m_FanCompNotSetYet = true;
     460             :         bool m_CoolCompNotSetYet = true;
     461             :         bool m_HeatCompNotSetYet = true;
     462             :         bool m_SuppCompNotSetYet = true;
     463             :         bool m_OKToPrintSizing = false;
     464             :         bool m_IsDXCoil = true;
     465             :         Real64 m_SmallLoadTolerance = 5.0;             // watts
     466             :         bool m_TemperatureOffsetControlActive = false; // true if water-side economizer coil is active
     467             :         Real64 m_minAirToWaterTempOffset = 0.0;        // coil entering air to entering water temp offset
     468             : 
     469             :         int m_HRcoolCoilFluidInletNode = 0;
     470             :         int m_HRcoolCoilAirInNode = 0;
     471             :         Real64 m_minWaterLoopTempForHR = 0.0;   // water coil heat recovery loops
     472             :         bool m_waterSideEconomizerFlag = false; // user input to enable lockout with economizer
     473             :         bool m_WaterHRPlantLoopModel = false;   // signifies water heat recovery loop for this CoilSystem
     474             :         std::array<int, 4> m_OAMixerNodes{0, 0, 0, 0};
     475             :         Real64 m_CoolOutAirVolFlow = 0.0;
     476             :         Real64 m_CoolOutAirMassFlow = 0.0;
     477             :         Real64 m_HeatOutAirVolFlow = 0.0;
     478             :         Real64 m_HeatOutAirMassFlow = 0.0;
     479             :         Real64 m_NoCoolHeatOutAirVolFlow = 0.0;
     480             :         Real64 m_NoCoolHeatOutAirMassFlow = 0.0;
     481             :         Real64 m_HeatConvTol = 0.001;
     482             :         Real64 m_CoolConvTol = 0.001;
     483             :         int m_HVACSizingIndex = -1;
     484             :         int m_AvailStatus = 0;
     485             :         bool m_IsZoneEquipment = false;
     486             :         bool m_ZoneCompFlag = true;
     487             :         std::string m_AvailManagerListName;
     488             :         int m_EquipCompNum = 0; // 1-based index of this parent type for specific equipment type processing
     489             : 
     490             :     public:
     491             :         // SZVAV variables
     492             :         DataZoneEquipment::ZoneEquip ZoneEqType = DataZoneEquipment::ZoneEquip::Invalid;
     493             :         SimAirServingZones::CompType AirloopEqType = SimAirServingZones::CompType::Invalid;
     494             :         int MaxIterIndex = 0;
     495             :         int RegulaFalsiFailedIndex = 0;
     496             :         int NodeNumOfControlledZone = 0;
     497             :         Real64 FanPartLoadRatio = 0.0;
     498             :         Real64 CoolCoilWaterFlowRatio = 0.0;
     499             :         Real64 HeatCoilWaterFlowRatio = 0.0;
     500             :         int ControlZoneNum = 0;                // index of unit in ZoneEquipConfig
     501             :         int AirInNode = 0;                     // Parent inlet air node number
     502             :         int AirOutNode = 0;                    // Parent outlet air node number
     503             :         Real64 MaxCoolAirMassFlow = 0.0;       // Maximum coil air mass flow for cooling [kg/s]
     504             :         Real64 MaxHeatAirMassFlow = 0.0;       // Maximum coil air mass flow for heating [kg/s]
     505             :         Real64 MaxNoCoolHeatAirMassFlow = 0.0; // Maximum coil air mass flow for no cooling or heating [kg/s]
     506             :         Real64 DesignMinOutletTemp = 0.0;      // DOAS DX Cooling or SZVAV coil outlet air minimum temperature [C]
     507             :         Real64 DesignMaxOutletTemp = 0.0;      // Maximum supply air temperature from heating coil [C]
     508             :         Real64 LowSpeedCoolFanRatio = 0.0;     // cooling mode ratio of low speed fan flow to full flow rate
     509             :         Real64 LowSpeedHeatFanRatio = 0.0;     // heating mode ratio of low speed fan flow to full flow rate
     510             :         Real64 MaxCoolCoilFluidFlow = 0.0;     // Maximum cooling coil fluid flow for chilled water coil
     511             :         Real64 MaxHeatCoilFluidFlow = 0.0;     // Maximum heating coil fluid flow for hot water or steam coil
     512             :         int CoolCoilInletNodeNum = 0;          // Cooling coil air inlet node number
     513             :         int CoolCoilOutletNodeNum = 0;         // Cooling coil air outlet node number
     514             :         int CoolCoilFluidOutletNodeNum = 0;    // Cooling coil fluid outlet node number (from Plant Loop data)
     515             :         PlantLocation CoolCoilPlantLoc;        // Location of the cooling coil in the plant loop
     516             :         int CoolCoilFluidInletNode = 0;        // Cooling coil fluid inlet node
     517             :         PlantLocation HeatCoilPlantLoc;        // Location of the heating coil in the plant loop
     518             :         int HeatCoilFluidInletNode = 0;        // Heating coil fluid inlet node
     519             :         int HeatCoilFluidOutletNodeNum = 0;    // Heating coil fluid outlet node number (from Plant Loop data)
     520             :         int HeatCoilInletNodeNum = 0;          // Heating coil air inlet node number
     521             :         int HeatCoilOutletNodeNum = 0;         // Heating coil air outlet node number
     522             :         bool ATMixerExists = false;            // true if AT mixer is connected to Unitary System
     523             :         int ATMixerType = 0;                   // type of AT mixer, inlet-side or supply-side
     524             :         int ATMixerOutNode = 0;                // AT mixer outlet node number
     525             :         Real64 ControlZoneMassFlowFrac = 0.0;  // fraction of air flow to the control zone
     526             :         DesignSpecMSHP *m_CompPointerMSHP = nullptr;
     527             :         std::string Name;
     528             :         std::string UnitType;
     529             :         Real64 LoadSHR = 0.0;                   // Load sensible heat ratio with humidity control
     530             :         Real64 CoilSHR = 0.0;                   // Load sensible heat ratio with humidity control
     531             :         int temperatureOffsetControlStatus = 0; // water side economizer status flag, also report variable
     532             :         int OAMixerIndex = -1;                  // index to zone equipment OA mixer
     533             :         bool OAMixerExists = false;             // true if OA mixer is connected to inlet of UnitarySystem
     534             : 
     535             :         //    private:
     536             :         // private members not initialized in constructor
     537             :         std::string m_FanName;
     538             :         std::string m_ATMixerName;
     539             :         std::string m_HeatingCoilName;
     540             :         std::string m_HeatingCoilTypeName;
     541             :         std::string m_CoolingCoilName;
     542             :         std::string m_SuppHeatCoilName;
     543             :         std::string m_SuppHeatCoilTypeName;
     544             :         std::string m_DesignSpecMultispeedHPType;
     545             :         std::string m_DesignSpecMultispeedHPName;
     546             :         std::vector<Real64> m_CoolVolumeFlowRate;
     547             :         std::vector<Real64> m_CoolMassFlowRate;
     548             :         std::vector<Real64> m_MSCoolingSpeedRatio;
     549             :         std::vector<Real64> m_HeatVolumeFlowRate;
     550             :         std::vector<Real64> m_HeatMassFlowRate;
     551             :         std::vector<Real64> m_MSHeatingSpeedRatio;
     552             :         std::vector<Real64> m_HeatingVolFlowRatio;
     553             :         std::vector<int> m_IterationMode;  // array of operating mode each iteration
     554             :         std::vector<Real64> FullOutput;    // Full output for different speed
     555             :         std::vector<Real64> FullLatOutput; // Full latent output for different speed
     556             :         std::vector<Real64> SpeedSHR;      // SHR at different speed
     557             : 
     558        2370 :         struct WarnMessages
     559             :         {
     560             :             // Warning message variables
     561             :             int m_HXAssistedSensPLRIter = 0;        // used in HX Assisted calculations
     562             :             int m_HXAssistedSensPLRIterIndex = 0;   // used in HX Assisted calculations
     563             :             int m_HXAssistedSensPLRFail = 0;        // used in HX Assisted calculations
     564             :             int m_HXAssistedSensPLRFailIndex = 0;   // used in HX Assisted calculations
     565             :             int m_HXAssistedSensPLRFail2 = 0;       // used in HX Assisted calculations
     566             :             int m_HXAssistedSensPLRFailIndex2 = 0;  // used in HX Assisted calculations
     567             :             int m_HXAssistedLatPLRIter = 0;         // used in HX Assisted calculations
     568             :             int m_HXAssistedLatPLRIterIndex = 0;    // used in HX Assisted calculations
     569             :             int m_HXAssistedLatPLRFail = 0;         // used in HX Assisted calculations
     570             :             int m_HXAssistedLatPLRFailIndex = 0;    // used in HX Assisted calculations
     571             :             int m_HXAssistedCRLatPLRIter = 0;       // used in HX Assisted calculations
     572             :             int m_HXAssistedCRLatPLRIterIndex = 0;  // used in HX Assisted calculations
     573             :             int m_HXAssistedCRLatPLRFail = 0;       // used in HX Assisted calculations
     574             :             int m_HXAssistedCRLatPLRFailIndex = 0;  // used in HX Assisted calculations
     575             :             int m_HXAssistedCRLatPLRFail2 = 0;      // used in HX Assisted calculations
     576             :             int m_HXAssistedCRLatPLRFailIndex2 = 0; // used in HX Assisted calculations
     577             :             int m_SensPLRIter = 0;                  // used in cool coil calculations
     578             :             int m_SensPLRIterIndex = 0;             // used in cool coil calculations
     579             :             int m_SensPLRFail = 0;                  // used in cool coil calculations
     580             :             int m_SensPLRFailIndex = 0;             // used in cool coil calculations
     581             :             int m_LatPLRIter = 0;                   // used in cool coil calculations
     582             :             int m_LatPLRIterIndex = 0;              // used in cool coil calculations
     583             :             int m_LatPLRFail = 0;                   // used in cool coil calculations
     584             :             int m_LatPLRFailIndex = 0;              // used in cool coil calculations
     585             :             int m_HeatCoilSensPLRIter = 0;          // used in heat coil calculations
     586             :             int m_HeatCoilSensPLRIterIndex = 0;     // used in heat coil calculations
     587             :             int m_HeatCoilSensPLRFail = 0;          // used in heat coil calculations
     588             :             int m_HeatCoilSensPLRFailIndex = 0;     // used in heat coil calculations
     589             :             int m_SuppHeatCoilSensPLRIter = 0;      // used in supp heat coil calculations
     590             :             int m_SuppHeatCoilSensPLRIterIndex = 0; // used in supp heat coil calculations
     591             :             int m_SuppHeatCoilSensPLRFail = 0;      // used in supp heat coil calculations
     592             :             int m_SuppHeatCoilSensPLRFailIndex = 0; // used in supp heat coil calculations
     593             :             int m_LatMaxIterIndex = 0;              // used in PLR calculations for moisture load
     594             :             int m_LatRegulaFalsiFailedIndex = 0;    // used in PLR calculations for moisture load
     595             :         };
     596             :         WarnMessages warnIndex;
     597             : 
     598             :         static void getUnitarySystemInput(EnergyPlusData &state, std::string_view Name, bool const ZoneEquipment, int const ZoneOAUnitNum);
     599             : 
     600             :         void processInputSpec(EnergyPlusData &state,
     601             :                               const UnitarySysInputSpec &input_data,
     602             :                               int sysNum,
     603             :                               bool &errorsFound,
     604             :                               bool const ZoneEquipment,
     605             :                               int const ZoneOAUnitNum);
     606             : 
     607             :         void setSystemParams(EnergyPlusData &state, Real64 &TotalFloorAreaOnAirLoop, const std::string &thisObjectName);
     608             : 
     609             :         static Real64 calcUnitarySystemLoadResidual(EnergyPlusData &state,
     610             :                                                     Real64 const PartLoadRatio, // DX cooling coil part load ratio
     611             :                                                     int UnitarySysNum,
     612             :                                                     bool FirstHVACIteration,
     613             :                                                     // par 3 not used?
     614             :                                                     DataHVACGlobals::CompressorOperation CompressorOp,
     615             :                                                     Real64 LoadToBeMet,
     616             :                                                     Real64 coolHeatFlag, // make bool?
     617             :                                                     Real64 SensibleLoad,
     618             :                                                     Real64 OnOffAirFlowRatio,
     619             :                                                     bool HXUnitOn,
     620             :                                                     // par 10 not used
     621             :                                                     int AirLoopNum);
     622             : 
     623             :         static Real64 DXCoilVarSpeedResidual(EnergyPlusData &state,
     624             :                                              Real64 SpeedRatio, // compressor speed ratio (1.0 is max, 0.0 is min)
     625             :                                              int CoilIndex,
     626             :                                              Real64 DesOutTemp,
     627             :                                              int UnitarySysNum,
     628             :                                              Real64 CycRatio,
     629             :                                              int SpeedNum,
     630             :                                              int FanOpMode,
     631             :                                              DataHVACGlobals::CompressorOperation CompressorOp);
     632             : 
     633             :         static Real64 heatingCoilVarSpeedResidual(EnergyPlusData &state,
     634             :                                                   Real64 SpeedRatio, // compressor speed ratio (1.0 is max, 0.0 is min)
     635             :                                                   int CoilIndex,
     636             :                                                   Real64 DesOutTemp,
     637             :                                                   int UnitarySysNum,
     638             :                                                   Real64 CycRatio,
     639             :                                                   int SpeedNum,
     640             :                                                   int FanOpMode,
     641             :                                                   DataHVACGlobals::CompressorOperation CompressorOp,
     642             :                                                   bool SuppHeat);
     643             : 
     644             :         static Real64 DXCoilVarSpeedHumRatResidual(EnergyPlusData &state,
     645             :                                                    Real64 SpeedRatio, // compressor speed ratio (1.0 is max, 0.0 is min)
     646             :                                                    int CoilIndex,
     647             :                                                    Real64 DesOutHumRat,
     648             :                                                    int UnitarySysNum,
     649             :                                                    Real64 CycRatio,
     650             :                                                    int SpeedNum,
     651             :                                                    int FanOpMode,
     652             :                                                    DataHVACGlobals::CompressorOperation CompressorOp);
     653             : 
     654             :         static Real64 DXCoilCyclingResidual(EnergyPlusData &state,
     655             :                                             Real64 CycRatio, // compressor cycling ratio (1.0 is continuous, 0.0 is off)
     656             :                                             int CoilIndex,
     657             :                                             Real64 DesOutTemp,
     658             :                                             int UnitarySysNum,
     659             :                                             Real64 SpeedRatio,
     660             :                                             int SpeedNum,
     661             :                                             int FanOpMode,
     662             :                                             DataHVACGlobals::CompressorOperation CompressorOp,
     663             :                                             int AirloopNum,
     664             :                                             bool FirstHVACIteration);
     665             : 
     666             :         static Real64 DXCoilCyclingHumRatResidual(EnergyPlusData &state,
     667             :                                                   Real64 CycRatio, // compressor cycling ratio (1.0 is continuous, 0.0 is off)
     668             :                                                   int CoilIndex,
     669             :                                                   Real64 DesOutHumRat,
     670             :                                                   int UnitarySysNum,
     671             :                                                   Real64 SpeedRatio,
     672             :                                                   int SpeedNum,
     673             :                                                   int FanOpMode,
     674             :                                                   DataHVACGlobals::CompressorOperation CompressorOp);
     675             : 
     676             :         static Real64 heatingCoilVarSpeedCycResidual(EnergyPlusData &state,
     677             :                                                      Real64 CycRatio, // compressor cycling ratio (1.0 is continuous, 0.0 is off)
     678             :                                                      int CoilIndex,
     679             :                                                      Real64 DesOutTemp,
     680             :                                                      int UnitarySysNum,
     681             :                                                      Real64 SpeedRatio,
     682             :                                                      int SpeedNum,
     683             :                                                      int FanOpMode,
     684             :                                                      DataHVACGlobals::CompressorOperation CompressorOp,
     685             :                                                      bool SuppHeat);
     686             : 
     687             :         static Real64 gasElecHeatingCoilResidual(EnergyPlusData &state,
     688             :                                                  Real64 PartLoadFrac, // Compressor cycling ratio (1.0 is continuous, 0.0 is off)
     689             :                                                  int UnitarySysNum,
     690             :                                                  bool FirstHVACIteration,
     691             :                                                  Real64 desTemp,
     692             :                                                  bool SuppHeatingCoilFlag,
     693             :                                                  bool FanOpMode,
     694             :                                                  Real64 HeatingLoadArg);
     695             : 
     696             :         static Real64 coolWatertoAirHPTempResidual(EnergyPlusData &state,
     697             :                                                    Real64 PartLoadRatio, // compressor cycling ratio (1.0 is continuous, 0.0 is off)
     698             :                                                    int UnitarySysNum,
     699             :                                                    bool FirstHVACIteration,
     700             :                                                    Real64 DesOutTemp,
     701             :                                                    Real64 ReqOutput);
     702             : 
     703             :         void initUnitarySystems(EnergyPlusData &state, int AirLoopNum, bool FirstHVACIteration, int const ZoneOAUnitNum, Real64 const OAUCoilOutTemp);
     704             : 
     705             :         bool checkNodeSetPoint(EnergyPlusData &state,
     706             :                                int const AirLoopNum,       // number of the current air loop being simulated
     707             :                                int const ControlNode,      // Node to test for set point
     708             :                                int const CoilType,         // True if cooling coil, then test for HumRatMax set point
     709             :                                Real64 const OAUCoilOutTemp // the coil inlet temperature of OutdoorAirUnit
     710             :         );
     711             : 
     712             :         void frostControlSetPointLimit(EnergyPlusData &state,
     713             :                                        Real64 &TempSetPoint,       // temperature setpoint of the sensor node
     714             :                                        Real64 &HumRatSetPoint,     // humidity ratio setpoint of the sensor node
     715             :                                        Real64 const BaroPress,     // baromtric pressure, Pa [N/m^2]
     716             :                                        Real64 const TfrostControl, // minimum temperature limit for forst control
     717             :                                        int const ControlMode       // temperature or humidity control mode
     718             :         );
     719             : 
     720             :         void reportUnitarySystem(EnergyPlusData &state, int const AirLoopNum);
     721             : 
     722             :         void unitarySystemHeatRecovery(EnergyPlusData &state);
     723             : 
     724             :         void controlUnitarySystemtoSP(EnergyPlusData &state,
     725             :                                       int const AirLoopNum,                               // Primary air loop number
     726             :                                       bool const FirstHVACIteration,                      // True when first HVAC iteration
     727             :                                       DataHVACGlobals::CompressorOperation &CompressorOn, // compressor on/off control
     728             :                                       Real64 const OAUCoilOutTemp,                        // the coil inlet temperature of OutdoorAirUnit
     729             :                                       bool HXUnitOn,                                      // Flag to control HX for HXAssisted Cooling Coil
     730             :                                       Real64 &sysOutputProvided,                          // sensible output at supply air node
     731             :                                       Real64 &latOutputProvided                           // latent output at supply air node
     732             :         );
     733             : 
     734             :         void controlUnitarySystemtoLoad(EnergyPlusData &state,
     735             :                                         int const AirLoopNum,                               // Primary air loop number
     736             :                                         bool const FirstHVACIteration,                      // True when first HVAC iteration
     737             :                                         DataHVACGlobals::CompressorOperation &CompressorOn, // Determines if compressor is on or off
     738             :                                         Real64 const OAUCoilOutTemp,                        // the coil inlet temperature of OutdoorAirUnit
     739             :                                         bool HXUnitOn,                                      // Flag to control HX for HXAssisted Cooling Coil
     740             :                                         Real64 &sysOutputProvied,                           // system sensible output at supply air node
     741             :                                         Real64 &latOutputProvided                           // system latent output at supply air node
     742             :         );
     743             : 
     744             :         void updateUnitarySystemControl(EnergyPlusData &state,
     745             :                                         int const AirLoopNum,  // number of the current air loop being simulated
     746             :                                         int const OutNode,     // coil outlet node number
     747             :                                         int const ControlNode, // control node number
     748             :                                         Real64 &OnOffAirFlowRatio,
     749             :                                         bool const FirstHVACIteration,
     750             :                                         Real64 const OAUCoilOutletTemp, // "ONLY" for zoneHVAC:OutdoorAirUnit
     751             :                                         Real64 &ZoneLoad,
     752             :                                         Real64 const MaxOutletTemp // limits heating coil outlet temp [C]
     753             :         );
     754             :         void controlUnitarySystemOutputEMS(EnergyPlusData &state,
     755             :                                            int const AirLoopNum,          // Index to air loop
     756             :                                            bool const FirstHVACIteration, // True when first HVAC iteration
     757             :                                            Real64 &OnOffAirFlowRatio,     // ratio of heating PLR to cooling PLR (is this correct?)
     758             :                                            Real64 const ZoneLoad,
     759             :                                            Real64 &FullSensibleOutput,
     760             :                                            bool &HXUnitOn, // Flag to control HX for HXAssisted Cooling Coil
     761             :                                            DataHVACGlobals::CompressorOperation CompressorOn);
     762             : 
     763             :         void controlUnitarySystemOutput(EnergyPlusData &state,
     764             :                                         int const AirLoopNum,          // Index to air loop
     765             :                                         bool const FirstHVACIteration, // True when first HVAC iteration
     766             :                                         Real64 &OnOffAirFlowRatio,     // ratio of heating PLR to cooling PLR (is this correct?)
     767             :                                         Real64 const ZoneLoad,
     768             :                                         Real64 &FullSensibleOutput,
     769             :                                         bool &HXUnitOn, // Flag to control HX for HXAssisted Cooling Coil
     770             :                                         DataHVACGlobals::CompressorOperation CompressorOn);
     771             : 
     772             :         void initLoadBasedControl(EnergyPlusData &state,
     773             :                                   int const AirLoopNum, // number of the current air loop being simulated
     774             :                                   bool const FirstHVACIteration,
     775             :                                   Real64 &OnOffAirFlowRatio,
     776             :                                   Real64 &ZoneLoad);
     777             : 
     778             :         void setOnOffMassFlowRate(EnergyPlusData &state,
     779             :                                   Real64 &OnOffAirFlowRatio, // ratio of coil on to coil off air flow rate
     780             :                                   Real64 const PartLoadRatio // coil part-load ratio
     781             :         );
     782             : 
     783             :         void setAverageAirFlow(EnergyPlusData &state,
     784             :                                Real64 const PartLoadRatio, // unit part load ratio
     785             :                                Real64 &OnOffAirFlowRatio   // ratio of compressor ON airflow to AVERAGE airflow over timestep
     786             :         );
     787             : 
     788             :         void calcMultiStageSuppCoilStageByLoad(EnergyPlusData &state, Real64 const SuppHeatload, bool const FirstHVACIteration);
     789             : 
     790             :         void calculateCapacity(EnergyPlusData &state,
     791             :                                Real64 &SensOutput, // sensible output of AirloopHVAC:UnitarySystem
     792             :                                Real64 &LatOutput   // latent output of AirloopHVAC:UnitarySystem
     793             :         );
     794             : 
     795             :         void calcUnitaryCoolingSystem(EnergyPlusData &state,
     796             :                                       int const AirLoopNum,                              // index to air loop
     797             :                                       bool const FirstHVACIteration,                     // True when first HVAC iteration
     798             :                                       Real64 const PartLoadRatio,                        // coil operating part-load ratio
     799             :                                       DataHVACGlobals::CompressorOperation CompressorOn, // compressor control (0=off, 1=on)
     800             :                                       Real64 const OnOffAirFlowRatio,
     801             :                                       Real64 const CoilCoolHeatRat, // ratio of cooling to heating PLR for cycling fan RH control
     802             :                                       bool const HXUnitOn           // Flag to control HX for HXAssisted Cooling Coil
     803             :         );
     804             : 
     805             :         void calcUnitaryHeatingSystem(EnergyPlusData &state,
     806             :                                       int const AirLoopNum,                              // index to air loop
     807             :                                       bool const FirstHVACIteration,                     // True when first HVAC iteration
     808             :                                       Real64 const PartLoadRatio,                        // coil operating part-load ratio
     809             :                                       DataHVACGlobals::CompressorOperation CompressorOn, // comrpressor control (0=off, 1=on)
     810             :                                       Real64 const OnOffAirFlowRatio,                    // ratio of on to off flow rate
     811             :                                       Real64 HeatCoilLoad                                // adjusted heating coil load if outlet temp exceeds max (W)
     812             :         );
     813             : 
     814             :         void calcUnitarySuppHeatingSystem(EnergyPlusData &state,
     815             :                                           bool const FirstHVACIteration, // True when first HVAC iteration
     816             :                                           Real64 const SuppCoilLoad      // adjusted supp coil load when outlet temp exceeds max (W)
     817             :         );
     818             : 
     819             :         void setEMSSuppCoilStagePLR(EnergyPlusData &state);
     820             : 
     821             :         void calcUnitarySuppSystemToSP(EnergyPlusData &state, bool const FirstHVACIteration // True when first HVAC iteration
     822             :         );
     823             : 
     824             :         void controlCoolingSystemToSP(EnergyPlusData &PartLoadFrac,
     825             :                                       int const AirLoopNum,                              // index to air loop
     826             :                                       bool const FirstHVACIteration,                     // First HVAC iteration flag
     827             :                                       bool &HXUnitOn,                                    // flag to enable heat exchanger heat recovery
     828             :                                       DataHVACGlobals::CompressorOperation &CompressorOp // compressor on/off control
     829             :         );
     830             : 
     831             :         void controlHeatingSystemToSP(EnergyPlusData &maxPartLoadFrac,
     832             :                                       int const AirLoopNum,                               // index to air loop
     833             :                                       bool const FirstHVACIteration,                      // First HVAC iteration flag
     834             :                                       DataHVACGlobals::CompressorOperation &CompressorOp, // compressor on/off control
     835             :                                       Real64 &HeatCoilLoad                                // load met by heating coil
     836             :         );
     837             : 
     838             :         void controlSuppHeatSystemToSP(EnergyPlusData &state,
     839             :                                        int const AirLoopNum,         // index to air loop
     840             :                                        bool const FirstHVACIteration // First HVAC iteration flag
     841             :         );
     842             : 
     843             :         void simMultiSpeedCoils(EnergyPlusData &state,
     844             :                                 int const AirLoopNum,                               // Index to air loop
     845             :                                 bool const FirstHVACIteration,                      // True when first HVAC iteration
     846             :                                 DataHVACGlobals::CompressorOperation &CompressorOn, // compressor on/off control
     847             :                                 bool const SensibleLoad,
     848             :                                 bool const LatentLoad,
     849             :                                 Real64 const PartLoadFrac,
     850             :                                 int const CoilType,
     851             :                                 int const SpeedNumber);
     852             : 
     853             :         void calcPassiveSystem(EnergyPlusData &state,
     854             :                                int const AirLoopNum,         // Index to air loop
     855             :                                bool const FirstHVACIteration // True when first HVAC iteration
     856             :         );
     857             : 
     858             :         void heatPumpRunFrac(Real64 const PLR,   // part load ratio
     859             :                              bool &errFlag,      // part load factor out of range flag
     860             :                              Real64 &RuntimeFrac // the required run time fraction to meet part load
     861             :         );
     862             : 
     863             :         void setSpeedVariables(EnergyPlusData &state,
     864             :                                bool const SensibleLoad,   // True when meeting a sensible load (not a moisture load)
     865             :                                Real64 const PartLoadRatio // operating PLR
     866             :         );
     867             : 
     868             :     public:
     869             :         static void
     870             :         getUnitarySystemInputData(EnergyPlusData &state, std::string_view Name, bool const ZoneEquipment, int const ZoneOAUnitNum, bool &errorsFound);
     871             : 
     872             :         static void
     873             :         getDXCoilSystemData(EnergyPlusData &state, std::string_view Name, bool const ZoneEquipment, int const ZoneOAUnitNum, bool &errorsFound);
     874             : 
     875             :         static void getCoilWaterSystemInputData(
     876             :             EnergyPlusData &state, std::string_view CoilSysName, bool const ZoneEquipment, int const ZoneOAUnitNum, bool &errorsFound);
     877             : 
     878             :         static void getPackagedTerminalUnitData(
     879             :             EnergyPlusData &state, std::string_view Name, bool const ZoneEquipment, int const ZoneOAUnitNum, bool &errorsFound);
     880             : 
     881             :         static void allocateUnitarySys(EnergyPlusData &state);
     882             : 
     883             :         static HVACSystemData *
     884             :         factory(EnergyPlusData &state, int const object_type_of_num, std::string const objectName, bool const ZoneEquipment, int const ZoneOAUnitNum);
     885             : 
     886             :         void calcUnitarySystemToLoad(EnergyPlusData &state,
     887             :                                      int const AirLoopNum,          // index to air loop
     888             :                                      bool const FirstHVACIteration, // True when first HVAC iteration
     889             :                                      Real64 const CoolPLR,          // operating cooling part-load ratio []
     890             :                                      Real64 const HeatPLR,          // operating cooling part-load ratio []
     891             :                                      Real64 &OnOffAirFlowRatio,     // ratio of heating PLR to cooling PLR (is this correct?)
     892             :                                      Real64 &SensOutput,            // sensible capacity (W)
     893             :                                      Real64 &LatOutput,             // latent capacity (W)
     894             :                                      bool HXUnitOn,                 // Flag to control HX for HXAssisted Cooling Coil
     895             :                                      Real64 HeatCoilLoad,           // Adjusted load to heating coil when SAT exceeds max limit (W)
     896             :                                      Real64 SuppCoilLoad,           // Adjusted load to supp heating coil when SAT exceeds max limit (W)
     897             :                                      DataHVACGlobals::CompressorOperation const CompressorOn // Determines if compressor is on or off
     898             :         );
     899             : 
     900             :         static void checkUnitarySysCoilInOASysExists(EnergyPlusData &state, std::string_view UnitarySysName, int const ZoneOAUnitNum);
     901             : 
     902             :         static void getUnitarySysHeatCoolCoil(EnergyPlusData &state,
     903             :                                               std::string_view UnitarySysName, // Name of Unitary System object
     904             :                                               bool &CoolingCoil,               // Cooling coil exists
     905             :                                               bool &HeatingCoil,               // Heating coil exists
     906             :                                               int const ZoneOAUnitNum          // index to zone OA unit
     907             :         );
     908             : 
     909             :         static Real64 calcUnitarySystemWaterFlowResidual(EnergyPlusData &state,
     910             :                                                          Real64 const PartLoadRatio, // coil part load ratio
     911             :                                                          int UnitarySysNum,
     912             :                                                          bool FirstHVACIteration,
     913             :                                                          Real64 QZnReq,
     914             :                                                          int AirControlNode,
     915             :                                                          Real64 OnOffAirFlowRat,
     916             :                                                          int AirLoopNum,
     917             :                                                          int WaterControlNode,
     918             :                                                          Real64 highWaterMdot,
     919             :                                                          Real64 lowSpeedRatio,
     920             :                                                          Real64 airMdot,
     921             :                                                          Real64 par13_SATempTarget,
     922             :                                                          Real64 systemMaxAirFlowRate,
     923             :                                                          Real64 par15_LoadType,
     924             :                                                          Real64 par16_IterationMethod);
     925             : 
     926             :         void simulate(EnergyPlusData &state,
     927             :                       std::string_view Name,
     928             :                       bool const firstHVACIteration,
     929             :                       int AirLoopNum,
     930             :                       int &CompIndex,
     931             :                       bool &HeatActive,
     932             :                       bool &CoolActive,
     933             :                       int const OAUnitNum,         // If the system is an equipment of OutdoorAirUnit
     934             :                       Real64 const OAUCoilOutTemp, // the coil inlet temperature of OutdoorAirUnit
     935             :                       bool const ZoneEquipment,    // TRUE if called as zone equipment
     936             :                       Real64 &sysOutputProvided,   // sensible output at supply air node
     937             :                       Real64 &latOutputProvided    // latent output at supply air node
     938             :                       ) override;
     939             : 
     940             :         void sizeSystem(EnergyPlusData &state, bool const FirstHVACIteration, int const AirLoopNum) override;
     941             :         int getAirInNode(EnergyPlusData &state, std::string_view UnitarySysName, int const ZoneOAUnitNum, bool &errFlag) override;
     942             :         int getAirOutNode(EnergyPlusData &state, std::string_view UnitarySysName, int const ZoneOAUnitNum, bool &errFlag) override;
     943             :         int getAirOutletNode() override;
     944             :         int getMixerOANode() override;
     945             :         int getMixerMixNode() override;
     946             :         int getMixerRetNode() override;
     947             :         int getEquipIndex() override;
     948             : 
     949        2370 :         UnitarySys() = default;
     950        3617 :         ~UnitarySys() = default;
     951             :     };
     952             : 
     953             :     int getDesignSpecMSHPIndex(EnergyPlusData &state, std::string_view objectName);
     954             :     int getUnitarySystemIndex(EnergyPlusData &state, std::string_view objectName);
     955             : 
     956             :     bool searchZoneInletNodes(EnergyPlusData &state, int nodeToFind, int &ZoneEquipConfigIndex, int &InletNodeIndex);
     957             :     bool searchZoneInletNodesByEquipmentIndex(EnergyPlusData &state, int nodeToFind, int zoneEquipmentIndex);
     958             :     bool searchZoneInletNodeAirLoopNum(EnergyPlusData &state, int airLoopNumToFind, int ZoneEquipConfigIndex, int &InletNodeIndex);
     959             :     bool searchExhaustNodes(EnergyPlusData &state, const int nodeToFind, int &ZoneEquipConfigIndex, int &ExhaustNodeIndex);
     960             :     bool searchTotalComponents(EnergyPlusData &state,
     961             :                                SimAirServingZones::CompType compTypeToFind,
     962             :                                std::string_view objectNameToFind,
     963             :                                int &compIndex,
     964             :                                int &branchIndex,
     965             :                                int &airLoopIndex);
     966             :     void setupAllOutputVars(EnergyPlusData &state, int const numAllSystemTypes);
     967             :     void isWaterCoilHeatRecoveryType(EnergyPlusData &state, int const waterCoilNodeNum, bool &nodeNotFound);
     968             : 
     969             : } // namespace UnitarySystems
     970         771 : struct UnitarySystemsData : BaseGlobalStruct
     971             : {
     972             : 
     973             :     // MODULE PARAMETER DEFINITIONS
     974             :     int numUnitarySystems = 0;
     975             :     bool economizerFlag = false;      // holds air loop economizer status
     976             :     bool SuppHeatingCoilFlag = false; // set to TRUE when simulating supplemental heating coil
     977             :     bool HeatingLoad = false;         // True when zone needs heating
     978             :     bool CoolingLoad = false;         // True when zone needs cooling
     979             :     Real64 MoistureLoad = 0.0;        // Dehumidification Load (W)
     980             :     Real64 CompOnMassFlow = 0.0;      // Supply air mass flow rate w/ compressor ON [kg/s]
     981             :     Real64 CompOffMassFlow = 0.0;     // Supply air mass flow rate w/ compressor OFF [kg/s]
     982             :     Real64 OACompOnMassFlow = 0.0;    // OA mass flow rate w/ compressor ON [kg/s]
     983             :     Real64 OACompOffMassFlow = 0.0;   // OA mass flow rate w/ compressor OFF [kg/s]
     984             : 
     985             :     Real64 CompOnFlowRatio = 0.0;       // fan flow ratio when coil on
     986             :     Real64 CompOffFlowRatio = 0.0;      // fan flow ratio when coil off
     987             :     Real64 FanSpeedRatio = 0.0;         // ratio of air flow ratio passed to fan object
     988             :     Real64 CoolHeatPLRRat = 1.0;        // ratio of cooling to heating PLR, used for cycling fan RH control
     989             :     Real64 OnOffAirFlowRatioSave = 0.0; // Saves the OnOffAirFlowRatio calculated in RegulaFalsi calls.
     990             :     Real64 QToCoolSetPt = 0.0;          // load to cooling set point {W}
     991             :     Real64 QToHeatSetPt = 0.0;          // load to heating set point {W}
     992             :     Real64 m_massFlow1 = 0.0;           // Mass flow rate in operating mode 1 (Compressor On) [kg/s]
     993             :     Real64 m_massFlow2 = 0.0;           // Mass flow rate in operating mode 2 (Compressor Off) [kg/s]
     994             :     Real64 m_runTimeFraction1 = 0.0;    // Fan runtime fraction in operating mode 1 (Compressor On)
     995             :     Real64 m_runTimeFraction2 = 0.0;    // Fan runtime fraction in operating mode 2 (Compressor Off)
     996             : 
     997             :     bool initUnitarySystemsErrFlag = false;
     998             :     bool initUnitarySystemsErrorsFound = false;
     999             :     bool initLoadBasedControlFlowFracFlagReady = true;
    1000             :     Real64 initLoadBasedControlCntrlZoneTerminalUnitMassFlowRateMax = 0.0;
    1001             :     Real64 initUnitarySystemsQActual = 0.0;
    1002             : 
    1003             :     bool getInputOnceFlag = true;
    1004             :     bool getMSHPInputOnceFlag = true;
    1005             :     bool reportVariablesAreSetup = false;
    1006             : 
    1007             :     std::vector<UnitarySystems::UnitarySys> unitarySys;
    1008             :     std::vector<UnitarySystems::DesignSpecMSHP> designSpecMSHP;
    1009             : 
    1010             :     bool getInputFlag = true;
    1011             : 
    1012           0 :     void clear_state() override
    1013             :     {
    1014           0 :         numUnitarySystems = 0;
    1015           0 :         HeatingLoad = false;
    1016           0 :         CoolingLoad = false;
    1017           0 :         MoistureLoad = 0.0;
    1018           0 :         SuppHeatingCoilFlag = false;
    1019           0 :         CompOnMassFlow = 0.0;
    1020           0 :         CompOffMassFlow = 0.0;
    1021           0 :         CompOnFlowRatio = 0.0;
    1022           0 :         CompOffFlowRatio = 0.0;
    1023           0 :         OACompOnMassFlow = 0.0;
    1024           0 :         OACompOffMassFlow = 0.0;
    1025           0 :         FanSpeedRatio = 0.0;
    1026           0 :         CoolHeatPLRRat = 1.0;
    1027           0 :         OnOffAirFlowRatioSave = 0.0;
    1028           0 :         QToCoolSetPt = 0.0;
    1029           0 :         QToHeatSetPt = 0.0;
    1030           0 :         m_massFlow1 = 0.0;
    1031           0 :         m_massFlow2 = 0.0;
    1032           0 :         m_runTimeFraction1 = 0.0;
    1033           0 :         m_runTimeFraction2 = 0.0;
    1034             : 
    1035           0 :         initUnitarySystemsErrFlag = false;
    1036           0 :         initUnitarySystemsErrorsFound = false;
    1037           0 :         initLoadBasedControlFlowFracFlagReady = true;
    1038           0 :         initLoadBasedControlCntrlZoneTerminalUnitMassFlowRateMax = 0.0;
    1039           0 :         initUnitarySystemsQActual = 0.0;
    1040           0 :         getMSHPInputOnceFlag = true;
    1041           0 :         getInputOnceFlag = true;
    1042           0 :         reportVariablesAreSetup = false;
    1043           0 :         unitarySys.clear();
    1044           0 :         if (designSpecMSHP.size() > 0) designSpecMSHP.clear();
    1045           0 :         getInputFlag = true;
    1046           0 :     }
    1047             : 
    1048             :     // Default Constructor
    1049         771 :     UnitarySystemsData() = default;
    1050             : };
    1051             : } // namespace EnergyPlus
    1052             : #endif // ENERGYPLUS_UNITARYSYSTEM_HH

Generated by: LCOV version 1.13