Class: Standard Abstract

Inherits:
Object
  • Object
show all
Includes:
CoilDX, CoolingTower, Fan, PrototypeFan, Pump
Defined in:
lib/openstudio-standards/standards/standard.rb,
lib/openstudio-standards/weather/Weather.Model.rb,
lib/openstudio-standards/standards/Standards.Model.rb,
lib/openstudio-standards/standards/Standards.Space.rb,
lib/openstudio-standards/standards/Standards.Surface.rb,
lib/openstudio-standards/standards/Standards.FanOnOff.rb,
lib/openstudio-standards/standards/Standards.PlantLoop.rb,
lib/openstudio-standards/standards/Standards.SpaceType.rb,
lib/openstudio-standards/standards/Standards.SubSurface.rb,
lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb,
lib/openstudio-standards/standards/Standards.FluidCooler.rb,
lib/openstudio-standards/standards/Standards.ThermalZone.rb,
lib/openstudio-standards/standards/Standards.Construction.rb,
lib/openstudio-standards/standards/Standards.BuildingStory.rb,
lib/openstudio-standards/standards/Standards.PlanarSurface.rb,
lib/openstudio-standards/standards/Standards.BoilerHotWater.rb,
lib/openstudio-standards/standards/Standards.CoilHeatingGas.rb,
lib/openstudio-standards/standards/Standards.FanZoneExhaust.rb,
lib/openstudio-standards/standards/Standards.ScheduleCompact.rb,
lib/openstudio-standards/standards/Standards.ScheduleRuleset.rb,
lib/openstudio-standards/standards/Standards.ScheduleConstant.rb,
lib/openstudio-standards/standards/Standards.WaterHeaterMixed.rb,
lib/openstudio-standards/standards/Standards.FanConstantVolume.rb,
lib/openstudio-standards/standards/Standards.FanVariableVolume.rb,
lib/openstudio-standards/standards/Standards.PumpConstantSpeed.rb,
lib/openstudio-standards/standards/Standards.PumpVariableSpeed.rb,
lib/openstudio-standards/standards/Standards.ZoneHVACComponent.rb,
lib/openstudio-standards/standards/Standards.ChillerElectricEIR.rb,
lib/openstudio-standards/standards/Standards.CoolingTowerTwoSpeed.rb,
lib/openstudio-standards/standards/Standards.HeatExchangerSensLat.rb,
lib/openstudio-standards/standards/Standards.CoilCoolingDXTwoSpeed.rb,
lib/openstudio-standards/standards/Standards.CoilCoolingDXMultiSpeed.rb,
lib/openstudio-standards/standards/Standards.CoilHeatingDXMultiSpeed.rb,
lib/openstudio-standards/standards/Standards.CoolingTowerSingleSpeed.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.FanOnOff.rb,
lib/openstudio-standards/standards/Standards.CoilCoolingDXSingleSpeed.rb,
lib/openstudio-standards/standards/Standards.CoilHeatingDXSingleSpeed.rb,
lib/openstudio-standards/standards/Standards.CoilHeatingGasMultiStage.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.Model.swh.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb,
lib/openstudio-standards/standards/Standards.CoolingTowerVariableSpeed.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.Model.hvac.rb,
lib/openstudio-standards/standards/Standards.HeaderedPumpsConstantSpeed.rb,
lib/openstudio-standards/standards/Standards.HeaderedPumpsVariableSpeed.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.CoolingTower.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.SizingSystem.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.refrigeration.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.BoilerHotWater.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.CoilHeatingGas.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.FanZoneExhaust.rb,
lib/openstudio-standards/standards/Standards.AirTerminalSingleDuctVAVReheat.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.Model.elevators.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.CoilCoolingWater.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.CoilHeatingWater.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.FanConstantVolume.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.FanVariableVolume.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.PumpVariableSpeed.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.Model.transformers.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.CoilHeatingElectric.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.ControllerWaterCoil.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.ServiceWaterHeating.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.CoilCoolingDXTwoSpeed.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.Model.exterior_lights.rb,
lib/openstudio-standards/standards/Standards.AirTerminalSingleDuctParallelPIUReheat.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.radiant_system_controls.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.CentralAirSourceHeatPump.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.CoilCoolingDXSingleSpeed.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.CoilHeatingDXSingleSpeed.rb,
lib/openstudio-standards/standards/Standards.CoilCoolingWaterToAirHeatPumpEquationFit.rb,
lib/openstudio-standards/standards/Standards.CoilHeatingWaterToAirHeatPumpEquationFit.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.AirTerminalSingleDuctVAVReheat.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.AirConditionerVariableRefrigerantFlow.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.HeatExchangerAirToAirSensibleAndLatent.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.CoilCoolingWaterToAirHeatPumpEquationFit.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.CoilHeatingWaterToAirHeatPumpEquationFit.rb

Overview

This class is abstract.

This abstract class holds generic methods that many energy standards would commonly use. Many of the methods in this class apply efficiency values from the OpenStudio-Standards spreadsheet. If a method in this class is redefined by a subclass, the implementation in the subclass is used.

Direct Known Subclasses

ASHRAE901, CBES, DEER, ICCIECC, NECB2011, OEESC

Constant Summary collapse

STANDARDS_LIST =

A list of available Standards subclasses that can be created using the Standard.build() method.

{}

Instance Attribute Summary collapse

Model collapse

Space collapse

Surface collapse

PlantLoop collapse

SpaceType collapse

SubSurface collapse

AirLoopHVAC collapse

FluidCooler collapse

ThermalZone collapse

Construction collapse

BuildingStory collapse

PlanarSurface collapse

BoilerHotWater collapse

CoilHeatingGas collapse

ScheduleCompact collapse

ScheduleRuleset collapse

ScheduleConstant collapse

WaterHeaterMixed collapse

ZoneHVACComponent collapse

ChillerElectricEIR collapse

HeatExchangerSensLat collapse

CoilCoolingDXMultiSpeed collapse

CoilHeatingDXMultiSpeed collapse

CoilHeatingGasMultiStage collapse

utilities collapse

Cooling Tower collapse

Sizing System collapse

hvac_systems collapse

refrigeration collapse

Boiler Hot Water collapse

AirTerminalSingleDuctVAVReheat collapse

CoilCoolingWater collapse

CoilHeatingWater collapse

CoilHeatingElectric collapse

ControllerWaterCoil collapse

ServiceWaterHeating collapse

CoilCoolingDXTwoSpeed collapse

AirTerminalSingleDuctParallelPIUReheat collapse

Central Air Source Heat Pump collapse

CoilCoolingDXSingleSpeed collapse

CoilHeatingDXSingleSpeed collapse

CoilCoolingWaterToAirHeatPumpEquationFit collapse

CoilHeatingWaterToAirHeatPumpEquationFit collapse

AirConditionerVariableRefrigerantFlow collapse

HeatExchangerAirToAirSensibleAndLatent collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PrototypeFan

apply_base_fan_variables, #create_fan_by_name, #get_fan_from_standards, #prototype_fan_apply_prototype_fan_efficiency

Methods included from CoilDX

#coil_dx_find_search_criteria, #coil_dx_heat_pump?, #coil_dx_heating_type, #coil_dx_subcategory

Methods included from CoolingTower

#cooling_tower_apply_minimum_power_per_flow, #cooling_tower_apply_minimum_power_per_flow_gpm_limit

Methods included from Pump

#pump_apply_prm_pressure_rise_and_motor_efficiency, #pump_apply_standard_minimum_motor_efficiency, #pump_brake_horsepower, #pump_motor_horsepower, #pump_pumppower, #pump_rated_w_per_gpm, #pump_standard_minimum_motor_efficiency_and_size

Methods included from Fan

#fan_adjust_pressure_rise_to_meet_fan_power, #fan_apply_standard_minimum_motor_efficiency, #fan_baseline_impeller_efficiency, #fan_brake_horsepower, #fan_change_impeller_efficiency, #fan_change_motor_efficiency, #fan_fanpower, #fan_motor_horsepower, #fan_rated_w_per_cfm, #fan_small_fan?, #fan_standard_minimum_motor_efficiency_and_size

Instance Attribute Details

#space_multiplier_mapObject

Returns the value of attribute space_multiplier_map.



4
5
6
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4

def space_multiplier_map
  @space_multiplier_map
end

#standards_dataObject

Returns the value of attribute standards_data.



7
8
9
# File 'lib/openstudio-standards/standards/standard.rb', line 7

def standards_data
  @standards_data
end

#templateObject (readonly)

Returns the value of attribute template.



8
9
10
# File 'lib/openstudio-standards/standards/standard.rb', line 8

def template
  @template
end

Class Method Details

.build(name) ⇒ Object

Create an instance of a Standard by passing it’s name

Examples:

Create a new Standard object by name

standard = Standard.build('NECB2011')

Parameters:

  • name (String)

    the name of the Standard to build. valid choices are: DOE Pre-1980, DOE 1980-2004, 90.1-2004, 90.1-2007, 90.1-2010, 90.1-2013, 90.1-2016, 90.1-2019, NREL ZNE Ready 2017, NECB2011



34
35
36
37
38
39
40
41
# File 'lib/openstudio-standards/standards/standard.rb', line 34

def self.build(name)
  if STANDARDS_LIST[name].nil?
    raise "ERROR: Did not find a class called '#{name}' to create in #{JSON.pretty_generate(STANDARDS_LIST)}"
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.standard', "Using OpenStudio Standards version #{OpenstudioStandards::VERSION} with template #{name}.")
  return STANDARDS_LIST[name].new
end

.register_standard(name) ⇒ Object

Add the standard to the STANDARDS_LIST.



22
23
24
# File 'lib/openstudio-standards/standards/standard.rb', line 22

def self.register_standard(name)
  STANDARDS_LIST[name] = self
end

Instance Method Details

#adjust_infiltration_to_lower_pressure(initial_infiltration_rate_m3_per_s, intial_pressure_pa, final_pressure_pa, infiltration_coefficient = 0.65) ⇒ Object

Convert one infiltration rate at a given pressure to an infiltration rate at another pressure per method described here: www.taskair.net/knowledge/Infiltration%20Modeling%20Guidelines%20for%20Commercial%20Building%20Energy%20Analysis.pdf where the infiltration coefficient is 0.65

Parameters:

  • initial_infiltration_rate_m3_per_s (Double)

    initial infiltration rate in m^3/s

  • intial_pressure_pa (Double)

    pressure rise at which initial infiltration rate was determined in Pa

  • final_pressure_pa (Double)

    desired pressure rise to adjust infiltration rate to in Pa

  • infiltration_coefficient (Double) (defaults to: 0.65)

    infiltration coeffiecient



409
410
411
412
413
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 409

def adjust_infiltration_to_lower_pressure(initial_infiltration_rate_m3_per_s, intial_pressure_pa, final_pressure_pa, infiltration_coefficient = 0.65)
  adjusted_infiltration_rate_m3_per_s = initial_infiltration_rate_m3_per_s * (final_pressure_pa / intial_pressure_pa)**infiltration_coefficient

  return adjusted_infiltration_rate_m3_per_s
end

#adjust_infiltration_to_prototype_building_conditions(initial_infiltration_rate_m3_per_s) ⇒ Double

Convert the infiltration rate at a 75 Pa to an infiltration rate at the typical value for the prototype buildings per method described here: www.pnl.gov/main/publications/external/technical_reports/PNNL-18898.pdf Gowri K, DW Winiarski, and RE Jarnagin. 2009. Infiltration modeling guidelines for commercial building energy analysis. PNNL-18898, Pacific Northwest National Laboratory, Richland, WA.

Parameters:

  • initial_infiltration_rate_m3_per_s (Double)

    initial infiltration rate in m^3/s

Returns:

  • (Double)


424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 424

def adjust_infiltration_to_prototype_building_conditions(initial_infiltration_rate_m3_per_s)
  # Details of these coefficients can be found in paper
  alpha = 0.22 # unitless - terrain adjustment factor
  intial_pressure_pa = 75.0 # 75 Pa
  uh = 4.47 # m/s - wind speed
  rho = 1.18 # kg/m^3 - air density
  cs = 0.1617 # unitless - positive surface pressure coefficient
  n = 0.65 # unitless - infiltration coefficient

  # Calculate the typical pressure - same for all building types
  final_pressure_pa = 0.5 * cs * rho * uh**2

  # OpenStudio::logFree(OpenStudio::Debug, "openstudio.Standards.Space", "Final pressure PA = #{final_pressure_pa.round(3)} Pa.")

  adjusted_infiltration_rate_m3_per_s = (1.0 + alpha) * initial_infiltration_rate_m3_per_s * (final_pressure_pa / intial_pressure_pa)**n

  return adjusted_infiltration_rate_m3_per_s
end

#adjust_sizing_system(air_loop_hvac, dsgn_temps, type_of_load_sizing: 'Sensible', min_sys_airflow_ratio: 0.3, sizing_option: 'Coincident') ⇒ Object

Prototype SizingSystem object

Parameters:

  • air_loop_hvac (<OpenStudio::Model::AirLoopHVAC>)

    air loop to set sizing system properties

  • dsgn_temps (Hash)

    a hash of design temperature lookups from standard_design_sizing_temperatures



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.SizingSystem.rb', line 8

def adjust_sizing_system(air_loop_hvac,
                         dsgn_temps,
                         type_of_load_sizing: 'Sensible',
                         min_sys_airflow_ratio: 0.3,
                         sizing_option: 'Coincident')

  # adjust sizing system defaults
  sizing_system = air_loop_hvac.sizingSystem
  sizing_system.setTypeofLoadtoSizeOn(type_of_load_sizing)
  sizing_system.autosizeDesignOutdoorAirFlowRate
  sizing_system.setPreheatDesignTemperature(dsgn_temps['prehtg_dsgn_sup_air_temp_c'])
  sizing_system.setPrecoolDesignTemperature(dsgn_temps['preclg_dsgn_sup_air_temp_c'])
  sizing_system.setCentralCoolingDesignSupplyAirTemperature(dsgn_temps['clg_dsgn_sup_air_temp_c'])
  sizing_system.setCentralHeatingDesignSupplyAirTemperature(dsgn_temps['htg_dsgn_sup_air_temp_c'])
  sizing_system.setPreheatDesignHumidityRatio(0.008)
  sizing_system.setPrecoolDesignHumidityRatio(0.008)
  sizing_system.setCentralCoolingDesignSupplyAirHumidityRatio(0.0085)
  sizing_system.setCentralHeatingDesignSupplyAirHumidityRatio(0.0080)
  if air_loop_hvac.model.version < OpenStudio::VersionString.new('2.7.0')
    sizing_system.setMinimumSystemAirFlowRatio(min_sys_airflow_ratio)
  else
    sizing_system.setCentralHeatingMaximumSystemAirFlowRatio(min_sys_airflow_ratio)
  end
  sizing_system.setSizingOption(sizing_option)
  sizing_system.setAllOutdoorAirinCooling(false)
  sizing_system.setAllOutdoorAirinHeating(false)
  sizing_system.setSystemOutdoorAirMethod('ZoneSum')
  sizing_system.setCoolingDesignAirFlowMethod('DesignDay')
  sizing_system.setHeatingDesignAirFlowMethod('DesignDay')

  return sizing_system
end

#afue_to_thermal_eff(afue) ⇒ Double

A helper method to convert from AFUE to thermal efficiency

Parameters:

  • afue (Double)

    Annual Fuel Utilization Efficiency

Returns:

  • (Double)

    Thermal efficiency (%)



369
370
371
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 369

def afue_to_thermal_eff(afue)
  return afue
end

#air_loop_hvac_add_motorized_oa_damper(air_loop_hvac, min_occ_pct = 0.05, occ_sch = nil) ⇒ Bool

Add a motorized damper by modifying the OA schedule to require zero OA during unoccupied hours. This means that even during morning warmup or nightcyling, no OA will be brought into the building, lowering heating/cooling load. If no occupancy schedule is supplied, one will be created. In this case, occupied is defined as the total percent occupancy for the loop for all zones served. If the OA schedule is already other than Always On, will assume that this schedule reflects a motorized OA damper and not change.

the system will be considered unoccupied. If not supplied, one will be created based on the supplied occupancy threshold.

Parameters:

  • min_occ_pct (Double) (defaults to: 0.05)

    the fractional value below which

  • occ_sch (OpenStudio::Model::Schedule) (defaults to: nil)

    the occupancy schedule.

Returns:

  • (Bool)

    true if successful, false if not



2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2549

def air_loop_hvac_add_motorized_oa_damper(air_loop_hvac, min_occ_pct = 0.05, occ_sch = nil)
  # Get the OA system and OA controller
  oa_sys = air_loop_hvac.airLoopHVACOutdoorAirSystem
  if oa_sys.is_initialized
    oa_sys = oa_sys.get
  else
    return false # No OA system
  end
  oa_control = oa_sys.getControllerOutdoorAir

  # Get the current min OA schedule and do nothing
  # if it is already set to something other than Always On
  if oa_control.minimumOutdoorAirSchedule.is_initialized
    min_oa_sch = oa_control.minimumOutdoorAirSchedule.get
    unless min_oa_sch == air_loop_hvac.model.alwaysOnDiscreteSchedule
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Min OA damper schedule is already set to #{min_oa_sch.name}, assume this includes correct motorized OA damper control.")
      return true
    end
  end

  # Get the airloop occupancy schedule if none supplied
  # or if the supplied availability schedule is Always On, implying
  # that the availability schedule does not reflect occupancy.
  if occ_sch.nil? || occ_sch == air_loop_hvac.model.alwaysOnDiscreteSchedule
    occ_sch = air_loop_hvac_get_occupancy_schedule(air_loop_hvac, occupied_percentage_threshold: min_occ_pct)
    flh = schedule_ruleset_annual_equivalent_full_load_hrs(occ_sch)
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Annual occupied hours = #{flh.round} hr/yr, assuming a #{min_occ_pct} occupancy threshold.  This schedule will be used to close OA damper during unoccupied hours.")
  else
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Setting motorized OA damper schedule to #{occ_sch.name}.")
  end

  # Set the minimum OA schedule to follow occupancy
  oa_control.setMinimumOutdoorAirSchedule(occ_sch)

  return true
end

#air_loop_hvac_adjust_minimum_vav_damper_positions(air_loop_hvac) ⇒ Bool

TODO:

Add exception logic for systems serving parking garage, warehouse, or multifamily

Adjust minimum VAV damper positions to the values

Returns:

  • (Bool)

    Returns true if required, false if not.



1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1756

def air_loop_hvac_adjust_minimum_vav_damper_positions(air_loop_hvac)
  # Do not apply the adjustment to some of the system in
  # the hospital and outpatient which have their minimum
  # damper position determined based on AIA 2001 ventilation
  # requirements
  if (@instvarbuilding_type == 'Hospital' && (air_loop_hvac.name.to_s.include?('VAV_ER') || air_loop_hvac.name.to_s.include?('VAV_ICU') ||
                                              air_loop_hvac.name.to_s.include?('VAV_OR') || air_loop_hvac.name.to_s.include?('VAV_LABS') ||
                                              air_loop_hvac.name.to_s.include?('VAV_PATRMS'))) ||
     (@instvarbuilding_type == 'Outpatient' && air_loop_hvac.name.to_s.include?('Outpatient F1'))

    return true
  end

  # Total uncorrected outdoor airflow rate
  v_ou = 0.0
  air_loop_hvac.thermalZones.each do |zone|
    # Vou is the system uncorrected outdoor airflow:
    # Zone airflow is multiplied by the zone multiplier
    v_ou += thermal_zone_outdoor_airflow_rate(zone) * zone.multiplier.to_f
  end

  v_ou_cfm = OpenStudio.convert(v_ou, 'm^3/s', 'cfm').get

  # System primary airflow rate (whether autosized or hard-sized)
  v_ps = 0.0

  v_ps = if air_loop_hvac.autosizedDesignSupplyAirFlowRate.is_initialized
           air_loop_hvac.autosizedDesignSupplyAirFlowRate.get
         else
           air_loop_hvac.designSupplyAirFlowRate.get
         end
  v_ps_cfm = OpenStudio.convert(v_ps, 'm^3/s', 'cfm').get

  # Average outdoor air fraction
  x_s = v_ou / v_ps

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: v_ou = #{v_ou_cfm.round} cfm, v_ps = #{v_ps_cfm.round} cfm, x_s = #{x_s.round(2)}.")

  # Determine the zone ventilation effectiveness
  # for every zone on the system.
  # When ventilation effectiveness is too low,
  # increase the minimum damper position.
  e_vzs = []
  e_vzs_adj = []
  num_zones_adj = 0

  # Retrieve the sum of the zone minimum primary airflow
  vpz_min_sum = air_loop_hvac.autosizeSumMinimumHeatingAirFlowRates

  air_loop_hvac.thermalZones.sort.each do |zone|
    # Breathing zone airflow rate
    v_bz = thermal_zone_outdoor_airflow_rate(zone)

    # Zone air distribution, assumed 1 per PNNL
    e_z = 1.0

    # Zone airflow rate
    v_oz = v_bz / e_z

    # Primary design airflow rate
    # max of heating and cooling
    # design air flow rates
    v_pz = 0.0
    clg_dsn_flow = zone.autosizedCoolingDesignAirFlowRate
    if clg_dsn_flow.is_initialized
      clg_dsn_flow = clg_dsn_flow.get
      if clg_dsn_flow > v_pz
        v_pz = clg_dsn_flow
      end
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: #{zone.name} clg_dsn_flow could not be found.")
    end
    htg_dsn_flow = zone.autosizedHeatingDesignAirFlowRate
    if htg_dsn_flow.is_initialized
      htg_dsn_flow = htg_dsn_flow.get
      if htg_dsn_flow > v_pz
        v_pz = htg_dsn_flow
      end
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: #{zone.name} htg_dsn_flow could not be found.")
    end

    # Get the minimum damper position
    mdp_term = 1.0
    min_zn_flow = 0.0
    zone.equipment.each do |equip|
      if equip.to_AirTerminalSingleDuctVAVHeatAndCoolNoReheat.is_initialized
        term = equip.to_AirTerminalSingleDuctVAVHeatAndCoolNoReheat.get
        mdp_term = term.zoneMinimumAirFlowFraction
      elsif equip.to_AirTerminalSingleDuctVAVHeatAndCoolReheat.is_initialized
        term = equip.to_AirTerminalSingleDuctVAVHeatAndCoolReheat.get
        mdp_term = term.zoneMinimumAirFlowFraction
      elsif equip.to_AirTerminalSingleDuctVAVNoReheat.is_initialized
        term = equip.to_AirTerminalSingleDuctVAVNoReheat.get
        if term.constantMinimumAirFlowFraction.is_initialized
          mdp_term = term.constantMinimumAirFlowFraction.get
        end
      elsif equip.to_AirTerminalSingleDuctVAVReheat.is_initialized
        term = equip.to_AirTerminalSingleDuctVAVReheat.get
        if term.constantMinimumAirFlowFraction.is_initialized
          mdp_term = term.constantMinimumAirFlowFraction.get
        end
        if term.fixedMinimumAirFlowRate.is_initialized
          min_zn_flow = term.fixedMinimumAirFlowRate.get
        end
      end
    end

    # Zone ventilation efficiency calculation is computed
    # on a per zone basis, the zone primary airflow is
    # adjusted to removed the zone multiplier
    v_pz /= zone.multiplier.to_f

    # For VAV Reheat terminals, min flow is greater of mdp
    # and min flow rate / design flow rate.
    mdp = mdp_term
    mdp_oa = min_zn_flow / v_pz
    if min_zn_flow > 0.0
      mdp = [mdp_term, mdp_oa].max.round(2)
    end

    # Zone minimum discharge airflow rate
    v_dz = v_pz * mdp

    # Zone discharge air fraction
    z_d = v_oz / v_dz

    # Zone ventilation effectiveness
    e_vz = 1.0 + x_s - z_d

    # Store the ventilation effectiveness
    e_vzs << e_vz

    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Zone #{zone.name} v_oz = #{v_oz.round(2)} m^3/s, v_pz = #{v_pz.round(2)} m^3/s, v_dz = #{v_dz.round(2)}, z_d = #{z_d.round(2)}.")

    # Check the ventilation effectiveness against
    # the minimum limit per PNNL and increase
    # as necessary.
    if e_vz < 0.6

      # Adjusted discharge air fraction
      z_d_adj = 1.0 + x_s - 0.6

      # Adjusted min discharge airflow rate
      v_dz_adj = v_oz / z_d_adj

      # Adjusted minimum damper position
      mdp_adj = v_dz_adj / v_pz

      # Don't allow values > 1
      if mdp_adj > 1.0
        mdp_adj = 1.0
      end

      # Zone ventilation effectiveness
      e_vz_adj = 1.0 + x_s - z_d_adj

      # Store the ventilation effectiveness
      e_vzs_adj << e_vz_adj
      # Round the minimum damper position to avoid nondeterministic results
      # at the ~13th decimal place, which can cause regression errors
      mdp_adj = mdp_adj.round(11)

      # Set the adjusted minimum damper position
      air_loop_hvac_set_minimum_damper_position(zone, mdp_adj)

      num_zones_adj += 1

      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Zone #{zone.name} has a ventilation effectiveness of #{e_vz.round(2)}.  Increasing to #{e_vz_adj.round(2)} by increasing minimum damper position from #{mdp.round(2)} to #{mdp_adj.round(2)}.")

    else
      # Store the unadjusted value
      e_vzs_adj << e_vz
    end
  end

  # Min system zone ventilation effectiveness
  e_v = e_vzs.min

  # Total system outdoor intake flow rate
  v_ot = v_ou / e_v
  v_ot_cfm = OpenStudio.convert(v_ot, 'm^3/s', 'cfm').get

  # Min system zone ventilation effectiveness
  e_v_adj = e_vzs_adj.min

  # Total system outdoor intake flow rate
  v_ot_adj = v_ou / e_v_adj
  v_ot_adj_cfm = OpenStudio.convert(v_ot_adj, 'm^3/s', 'cfm').get

  # Adjust minimum damper position if the sum of maximum
  # zone airflow are lower than the calculated system
  # outdoor air intake
  if v_ot_adj > vpz_min_sum && v_ot_adj > 0
    mdp_adj = [v_ot_adj / air_loop_hvac.autosizeSumAirTerminalMaxAirFlowRate, 1].min
    air_loop_hvac.thermalZones.sort.each do |zone|
      air_loop_hvac_set_minimum_damper_position(zone, mdp_adj)
    end
  end

  # Report out the results of the multizone calculations
  if num_zones_adj > 0
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: the multizone outdoor air calculation method was applied.  A simple summation of the zone outdoor air requirements gives a value of #{v_ou_cfm.round} cfm.  Applying the multizone method gives a value of #{v_ot_cfm.round} cfm, with an original system ventilation effectiveness of #{e_v.round(2)}.  After increasing the minimum damper position in #{num_zones_adj} critical zones, the resulting requirement is #{v_ot_adj_cfm.round} cfm with a system ventilation effectiveness of #{e_v_adj.round(2)}.")
  else
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: the multizone outdoor air calculation method was applied.  A simple summation of the zone requirements gives a value of #{v_ou_cfm.round} cfm.  However, applying the multizone method requires #{v_ot_adj_cfm.round} cfm based on the ventilation effectiveness of the system.")
  end

  # Hard-size the sizing:system
  # object with the calculated min OA flow rate
  sizing_system = air_loop_hvac.sizingSystem
  sizing_system.setDesignOutdoorAirFlowRate(v_ot_adj)

  return true
end

#air_loop_hvac_adjust_minimum_vav_damper_positions_outpatient(air_loop_hvac) ⇒ Object

For critical zones of Outpatient, if the minimum airflow rate required by the accreditation standard (AIA 2001) is significantly less than the autosized peak design airflow in any of the three climate zones (Houston, Baltimore and Burlington), the minimum airflow fraction of the terminal units is reduced to the value: “required minimum airflow rate / autosized peak design flow” Reference: <Achieving the 30% Goal: Energy and Cost Savings Analysis of ASHRAE Standard 90.1-2010> Page109-111 For implementation purpose, since it is time-consuming to perform autosizing in three climate zones, just use the results of the current climate zone



1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1998

def air_loop_hvac_adjust_minimum_vav_damper_positions_outpatient(air_loop_hvac)
  air_loop_hvac.model.getSpaces.sort.each do |space|
    zone = space.thermalZone.get
    sizing_zone = zone.sizingZone
    space_area = space.floorArea
    if sizing_zone.coolingDesignAirFlowMethod == 'DesignDay'
      next
    elsif sizing_zone.coolingDesignAirFlowMethod == 'DesignDayWithLimit'
      minimum_airflow_per_zone_floor_area = sizing_zone.coolingMinimumAirFlowperZoneFloorArea
      minimum_airflow_per_zone = minimum_airflow_per_zone_floor_area * space_area
      # get the autosized maximum air flow of the VAV terminal
      zone.equipment.each do |equip|
        if equip.to_AirTerminalSingleDuctVAVReheat.is_initialized
          vav_terminal = equip.to_AirTerminalSingleDuctVAVReheat.get
          rated_maximum_flow_rate = vav_terminal.autosizedMaximumAirFlowRate.get
          # compare the VAV autosized maximum airflow with the minimum airflow rate required by the accreditation standard
          ratio = minimum_airflow_per_zone / rated_maximum_flow_rate

          # round to avoid results variances in sizing runs
          ratio = ratio.round(11)

          if ratio >= 0.95
            vav_terminal.setConstantMinimumAirFlowFraction(1)
          elsif ratio < 0.95
            vav_terminal.setConstantMinimumAirFlowFraction(ratio)
          end
        end
      end
    end
  end
  return true
end

#air_loop_hvac_allowable_system_brake_horsepower(air_loop_hvac) ⇒ Double

Determine the allowable fan system brake horsepower Per Table 6.5.3.1.1A

Returns:

  • (Double)

    allowable fan system brake horsepower units = horsepower



439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 439

def air_loop_hvac_allowable_system_brake_horsepower(air_loop_hvac)
  # Get design supply air flow rate (whether autosized or hard-sized)
  dsn_air_flow_m3_per_s = 0
  dsn_air_flow_cfm = 0
  if air_loop_hvac.autosizedDesignSupplyAirFlowRate.is_initialized
    dsn_air_flow_m3_per_s = air_loop_hvac.autosizedDesignSupplyAirFlowRate.get
    dsn_air_flow_cfm = OpenStudio.convert(dsn_air_flow_m3_per_s, 'm^3/s', 'cfm').get
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "* #{dsn_air_flow_cfm.round} cfm = Autosized Design Supply Air Flow Rate.")
  else
    dsn_air_flow_m3_per_s = air_loop_hvac.designSupplyAirFlowRate.get
    dsn_air_flow_cfm = OpenStudio.convert(dsn_air_flow_m3_per_s, 'm^3/s', 'cfm').get
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "* #{dsn_air_flow_cfm.round} cfm = Hard sized Design Supply Air Flow Rate.")
  end

  # Get the fan limitation pressure drop adjustment bhp
  fan_pwr_adjustment_bhp = air_loop_hvac_fan_power_limitation_pressure_drop_adjustment_brake_horsepower(air_loop_hvac)

  # Determine the number of zones the system serves
  num_zones_served = air_loop_hvac.thermalZones.size

  # Get the supply air fan and determine whether VAV or CAV system.
  # Assume that supply air fan is fan closest to the demand outlet node.
  # The fan may be inside of a piece of unitary equipment.
  fan_pwr_limit_type = nil
  air_loop_hvac.supplyComponents.reverse.each do |comp|
    if comp.to_FanConstantVolume.is_initialized || comp.to_FanOnOff.is_initialized
      fan_pwr_limit_type = 'constant volume'
    elsif comp.to_FanVariableVolume.is_initialized
      fan_pwr_limit_type = 'variable volume'
    elsif comp.to_AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass.is_initialized
      fan = comp.to_AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass.get.supplyAirFan
      if fan.to_FanConstantVolume.is_initialized || comp.to_FanOnOff.is_initialized
        fan_pwr_limit_type = 'constant volume'
      elsif fan.to_FanVariableVolume.is_initialized
        fan_pwr_limit_type = 'variable volume'
      end
    elsif comp.to_AirLoopHVACUnitarySystem.is_initialized
      fan = comp.to_AirLoopHVACUnitarySystem.get.supplyFan.get
      if fan.to_FanConstantVolume.is_initialized || fan.to_FanOnOff.is_initialized
        fan_pwr_limit_type = 'constant volume'
      elsif fan.to_FanVariableVolume.is_initialized
        fan_pwr_limit_type = 'variable volume'
      end
    end
  end

  # For 90.1-2010, single-zone VAV systems use the
  # constant volume limitation per 6.5.3.1.1
  if template == 'ASHRAE 90.1-2010' && fan_pwr_limit_type == 'variable volume' && num_zones_served == 1
    fan_pwr_limit_type = 'constant volume'
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Using the constant volume limitation because single-zone VAV system.")
  end

  # Calculate the Allowable Fan System brake horsepower per Table G3.1.2.9
  allowable_fan_bhp = 0
  if fan_pwr_limit_type == 'constant volume'
    if dsn_air_flow_cfm > 0
      allowable_fan_bhp = dsn_air_flow_cfm * 0.00094 + fan_pwr_adjustment_bhp
    else
      allowable_fan_bhp = 0.00094
    end
  elsif fan_pwr_limit_type == 'variable volume'
    if dsn_air_flow_cfm > 0
      allowable_fan_bhp = dsn_air_flow_cfm * 0.0013 + fan_pwr_adjustment_bhp
    else
      allowable_fan_bhp = 0.0013
    end
  end
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Allowable brake horsepower = #{allowable_fan_bhp.round(2)}HP based on #{dsn_air_flow_cfm.round} cfm and #{fan_pwr_adjustment_bhp.round(2)} bhp of adjustment.")

  # Calculate and report the total area for debugging/testing
  floor_area_served_m2 = air_loop_hvac_floor_area_served(air_loop_hvac)

  if floor_area_served_m2.zero?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "AirLoopHVAC #{air_loop_hvac.name} serves zero floor area. Check that it has thermal zones attached to it, and that they have non-zero floor area'.")
    return allowable_fan_bhp
  end

  floor_area_served_ft2 = OpenStudio.convert(floor_area_served_m2, 'm^2', 'ft^2').get
  cfm_per_ft2 = dsn_air_flow_cfm / floor_area_served_ft2

  if allowable_fan_bhp.zero?
    cfm_per_hp = 0
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "AirLoopHVAC #{air_loop_hvac.name} has zero allowable fan bhp, probably due to zero design air flow cfm'.")
  else
    cfm_per_hp = dsn_air_flow_cfm / allowable_fan_bhp
  end
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: area served = #{floor_area_served_ft2.round} ft^2.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: flow per area = #{cfm_per_ft2.round} cfm/ft^2.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: flow per hp = #{cfm_per_hp.round} cfm/hp.")

  return allowable_fan_bhp
end

#air_loop_hvac_apply_baseline_fan_pressure_rise(air_loop_hvac) ⇒ Object

Set the fan pressure rises that will result in the system hitting the baseline allowable fan power



617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 617

def air_loop_hvac_apply_baseline_fan_pressure_rise(air_loop_hvac)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "#{air_loop_hvac.name}-Setting #{template} baseline fan power.")

  # Get the total system bhp from the proposed system, including terminal fans
  proposed_sys_bhp = air_loop_hvac_system_fan_brake_horsepower(air_loop_hvac, true)

  # Get the allowable fan brake horsepower
  allowable_fan_bhp = air_loop_hvac_allowable_system_brake_horsepower(air_loop_hvac)

  # Get the fan power limitation from proposed system
  fan_pwr_adjustment_bhp = air_loop_hvac_fan_power_limitation_pressure_drop_adjustment_brake_horsepower(air_loop_hvac)

  # Subtract the fan power adjustment
  allowable_fan_bhp -= fan_pwr_adjustment_bhp

  # Get all fans
  fans = air_loop_hvac_supply_return_exhaust_relief_fans(air_loop_hvac)

  # TODO: improve description
  # Loop through the fans, changing the pressure rise
  # until the fan bhp is the same percentage of the baseline allowable bhp
  # as it was on the proposed system.
  fans.each do |fan|
    # TODO: Yixing Check the model of the Fan Coil Unit
    next if fan.name.to_s.include?('Fan Coil fan')
    next if fan.name.to_s.include?('UnitHeater Fan')

    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', fan.name.to_s)

    # Get the bhp of the fan on the proposed system
    proposed_fan_bhp = fan_brake_horsepower(fan)

    # Get the bhp of the fan on the proposed system
    proposed_fan_bhp_frac = proposed_fan_bhp / proposed_sys_bhp

    # Determine the target bhp of the fan on the baseline system
    baseline_fan_bhp = proposed_fan_bhp_frac * allowable_fan_bhp
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "* #{baseline_fan_bhp.round(1)} bhp = Baseline fan brake horsepower.")

    # Set the baseline impeller eff of the fan,
    # preserving the proposed motor eff.
    baseline_impeller_eff = fan_baseline_impeller_efficiency(fan)
    fan_change_impeller_efficiency(fan, baseline_impeller_eff)
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "* #{(baseline_impeller_eff * 100).round(1)}% = Baseline fan impeller efficiency.")

    # Set the baseline motor efficiency for the specified bhp
    baseline_motor_eff = fan.standardMinimumMotorEfficiency(standards, allowable_fan_bhp)
    fan_change_motor_efficiency(fan, baseline_motor_eff)

    # Get design supply air flow rate (whether autosized or hard-sized)
    dsn_air_flow_m3_per_s = 0
    if fan.autosizedDesignSupplyAirFlowRate.is_initialized
      dsn_air_flow_m3_per_s = fan.autosizedDesignSupplyAirFlowRate.get
      dsn_air_flow_cfm = OpenStudio.convert(dsn_air_flow_m3_per_s, 'm^3/s', 'cfm').get
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "* #{dsn_air_flow_cfm.round} cfm = Autosized Design Supply Air Flow Rate.")
    else
      dsn_air_flow_m3_per_s = fan.designSupplyAirFlowRate.get
      dsn_air_flow_cfm = OpenStudio.convert(dsn_air_flow_m3_per_s, 'm^3/s', 'cfm').get
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "* #{dsn_air_flow_cfm.round} cfm = User entered Design Supply Air Flow Rate.")
    end

    # Determine the fan pressure rise that will result in the target bhp
    # pressure_rise_pa = fan_bhp*746 / fan_motor_eff*fan_total_eff / dsn_air_flow_m3_per_s
    baseline_pressure_rise_pa = baseline_fan_bhp * 746 / fan.motorEfficiency * fan.fanEfficiency / dsn_air_flow_m3_per_s
    baseline_pressure_rise_in_wc = OpenStudio.convert(fan_pressure_rise_pa, 'Pa', 'inH_{2}O').get
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "* #{fan_pressure_rise_in_wc.round(2)} in w.c. = Pressure drop to achieve allowable fan power.")

    # Calculate the bhp of the fan to make sure it matches
    calc_bhp = fan_brake_horsepower(fan)
    if ((calc_bhp - baseline_fan_bhp) / baseline_fan_bhp).abs > 0.02
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.AirLoopHVAC', "#{fan.name} baseline fan bhp supposed to be #{baseline_fan_bhp}, but is #{calc_bhp}.")
    end
  end

  # Calculate the total bhp of the system to make sure it matches the goal
  calc_sys_bhp = air_loop_hvac_system_fan_brake_horsepower(air_loop_hvac, false)
  if ((calc_sys_bhp - allowable_fan_bhp) / allowable_fan_bhp).abs > 0.02
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.AirLoopHVAC', "#{air_loop_hvac.name} baseline system bhp supposed to be #{allowable_fan_bhp}, but is #{calc_sys_bhp}.")
  end
end

#air_loop_hvac_apply_economizer_integration(air_loop_hvac, climate_zone) ⇒ Bool

Note:

this method assumes you previously checked that an economizer is required at all via #economizer_required?

For systems required to have an economizer, set the economizer to integrated on non-integrated per the standard.

Returns:

  • (Bool)

    returns true if successful, false if not



1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1043

def air_loop_hvac_apply_economizer_integration(air_loop_hvac, climate_zone)
  # Determine if an integrated economizer is required
  integrated_economizer_required = air_loop_hvac_integrated_economizer_required?(air_loop_hvac, climate_zone)

  # Get the OA system and OA controller
  oa_sys = air_loop_hvac.airLoopHVACOutdoorAirSystem

  return false unless oa_sys.is_initialized

  oa_sys = oa_sys.get
  oa_control = oa_sys.getControllerOutdoorAir
  # Apply integrated or non-integrated economizer
  if integrated_economizer_required
    oa_control.setLockoutType('LockoutWithHeating')
  else
    # If the airloop include hyrdronic cooling coils,
    # prevent economizer from operating at and above SAT,
    # similar to a non-integrated economizer. This is done
    # because LockoutWithCompressor doesn't work with hydronic
    # coils
    if air_loop_hvac_include_hydronic_cooling_coil?(air_loop_hvac)
      oa_control.setLockoutType('LockoutWithHeating')
      oa_control.setEconomizerMaximumLimitDryBulbTemperature(standard_design_sizing_temperatures['clg_dsgn_sup_air_temp_c'])
    else
      oa_control.setLockoutType('LockoutWithCompressor')
    end
  end

  return true
end

#air_loop_hvac_apply_economizer_limits(air_loop_hvac, climate_zone) ⇒ Bool

Set the economizer limits per the standard. Limits are based on the economizer type currently specified in the ControllerOutdoorAir object on this air loop.

Returns:

  • (Bool)

    returns true if successful, false if not



931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 931

def air_loop_hvac_apply_economizer_limits(air_loop_hvac, climate_zone)
  # EnergyPlus economizer types
  # 'NoEconomizer'
  # 'FixedDryBulb'
  # 'FixedEnthalpy'
  # 'DifferentialDryBulb'
  # 'DifferentialEnthalpy'
  # 'FixedDewPointAndDryBulb'
  # 'ElectronicEnthalpy'
  # 'DifferentialDryBulbAndEnthalpy'

  # Get the OA system and OA controller
  oa_sys = air_loop_hvac.airLoopHVACOutdoorAirSystem
  if oa_sys.is_initialized
    oa_sys = oa_sys.get
  else
    return false # No OA system
  end
  oa_control = oa_sys.getControllerOutdoorAir
  economizer_type = oa_control.getEconomizerControlType

  # Return false if no economizer is present
  if economizer_type == 'NoEconomizer'
    return false
  end

  # Reset the limits
  oa_control.resetEconomizerMaximumLimitDryBulbTemperature
  oa_control.resetEconomizerMaximumLimitEnthalpy
  oa_control.resetEconomizerMaximumLimitDewpointTemperature
  oa_control.resetEconomizerMinimumLimitDryBulbTemperature

  # Determine the limits
  drybulb_limit_f, enthalpy_limit_btu_per_lb, dewpoint_limit_f = air_loop_hvac_economizer_limits(air_loop_hvac, climate_zone)

  # Do nothing if no limits were specified
  if drybulb_limit_f.nil? && enthalpy_limit_btu_per_lb.nil? && dewpoint_limit_f.nil?
    return false
  end

  # Set the limits
  case economizer_type
  when 'FixedDryBulb'
    if drybulb_limit_f
      drybulb_limit_c = OpenStudio.convert(drybulb_limit_f, 'F', 'C').get
      oa_control.setEconomizerMaximumLimitDryBulbTemperature(drybulb_limit_c)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Economizer type = #{economizer_type}, dry bulb limit = #{drybulb_limit_f}F")
    end
  when 'FixedEnthalpy'
    if enthalpy_limit_btu_per_lb
      enthalpy_limit_j_per_kg = OpenStudio.convert(enthalpy_limit_btu_per_lb, 'Btu/lb', 'J/kg').get
      oa_control.setEconomizerMaximumLimitEnthalpy(enthalpy_limit_j_per_kg)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Economizer type = #{economizer_type}, enthalpy limit = #{enthalpy_limit_btu_per_lb}Btu/lb")
    end
  when 'FixedDewPointAndDryBulb'
    if drybulb_limit_f && dewpoint_limit_f
      drybulb_limit_c = OpenStudio.convert(drybulb_limit_f, 'F', 'C').get
      dewpoint_limit_c = OpenStudio.convert(dewpoint_limit_f, 'F', 'C').get
      oa_control.setEconomizerMaximumLimitDryBulbTemperature(drybulb_limit_c)
      oa_control.setEconomizerMaximumLimitDewpointTemperature(dewpoint_limit_c)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Economizer type = #{economizer_type}, dry bulb limit = #{drybulb_limit_f}F, dew-point limit = #{dewpoint_limit_f}F")
    end
  end

  return true
end

#air_loop_hvac_apply_energy_recovery_ventilator(air_loop_hvac, climate_zone) ⇒ Bool

TODO:

Add exception logic for systems serving parking garage, warehouse, or multifamily

Add an ERV to this airloop

Returns:

  • (Bool)

    Returns true if required, false if not.



1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1575

def air_loop_hvac_apply_energy_recovery_ventilator(air_loop_hvac, climate_zone)
  # Get the OA system
  oa_system = nil
  if air_loop_hvac.airLoopHVACOutdoorAirSystem.is_initialized
    oa_system = air_loop_hvac.airLoopHVACOutdoorAirSystem.get
  else
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}, ERV cannot be added because the system has no OA intake.")
    return false
  end

  # Get the existing ERV or create an ERV and add it to the OA system
  erv = nil
  air_loop_hvac.supplyComponents.each do |supply_comp|
    if supply_comp.to_HeatExchangerAirToAirSensibleAndLatent.is_initialized
      erv = supply_comp.to_HeatExchangerAirToAirSensibleAndLatent.get
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}, adjusting properties for existing ERV #{erv.name} instead of adding another one.")
    end
  end
  if erv.nil?
    erv = OpenStudio::Model::HeatExchangerAirToAirSensibleAndLatent.new(air_loop_hvac.model)
    erv.addToNode(oa_system.outboardOANode.get)
  end

  # Determine whether to use an ERV and HRV and heat exchanger style
  erv_type = air_loop_hvac_energy_recovery_ventilator_type(air_loop_hvac, climate_zone)
  heat_exchanger_type = air_loop_hvac_energy_recovery_ventilator_heat_exchanger_type(air_loop_hvac)
  erv.setName("#{air_loop_hvac.name} #{erv_type}")
  erv.setHeatExchangerType(heat_exchanger_type)

  # apply heat exchanger efficiencies
  air_loop_hvac_apply_energy_recovery_ventilator_efficiency(erv, erv_type: erv_type, heat_exchanger_type: heat_exchanger_type)

  # Apply the prototype heat exchanger power assumptions for rotary style heat exchangers
  heat_exchanger_air_to_air_sensible_and_latent_apply_prototype_nominal_electric_power(erv)

  # add economizer lockout
  erv.setSupplyAirOutletTemperatureControl(false)
  erv.setEconomizerLockout(true)

  # add defrost
  erv.setFrostControlType('ExhaustOnly')
  erv.setThresholdTemperature(-23.3) # -10F
  erv.setInitialDefrostTimeFraction(0.167)
  erv.setRateofDefrostTimeFractionIncrease(1.44)

  # Add a setpoint manager OA pretreat to control the ERV
  spm_oa_pretreat = OpenStudio::Model::SetpointManagerOutdoorAirPretreat.new(air_loop_hvac.model)
  spm_oa_pretreat.setMinimumSetpointTemperature(-99.0)
  spm_oa_pretreat.setMaximumSetpointTemperature(99.0)
  spm_oa_pretreat.setMinimumSetpointHumidityRatio(0.00001)
  spm_oa_pretreat.setMaximumSetpointHumidityRatio(1.0)
  # Reference setpoint node and mixed air stream node are outlet node of the OA system
  mixed_air_node = oa_system.mixedAirModelObject.get.to_Node.get
  spm_oa_pretreat.setReferenceSetpointNode(mixed_air_node)
  spm_oa_pretreat.setMixedAirStreamNode(mixed_air_node)
  # Outdoor air node is the outboard OA node of the OA system
  spm_oa_pretreat.setOutdoorAirStreamNode(oa_system.outboardOANode.get)
  # Return air node is the inlet node of the OA system
  return_air_node = oa_system.returnAirModelObject.get.to_Node.get
  spm_oa_pretreat.setReturnAirStreamNode(return_air_node)
  # Attach to the outlet of the ERV
  erv_outlet = erv.primaryAirOutletModelObject.get.to_Node.get
  spm_oa_pretreat.addToNode(erv_outlet)

  # Determine if the system is a DOAS based on whether there is 100% OA in heating and cooling sizing.
  is_doas = false
  sizing_system = air_loop_hvac.sizingSystem
  if sizing_system.allOutdoorAirinCooling && sizing_system.allOutdoorAirinHeating
    is_doas = true
  end

  # Set the bypass control type
  # If DOAS system, BypassWhenWithinEconomizerLimits
  # to disable ERV during economizing.
  # Otherwise, BypassWhenOAFlowGreaterThanMinimum
  # to disable ERV during economizing and when OA
  # is also greater than minimum.
  bypass_ctrl_type = if is_doas
                       'BypassWhenWithinEconomizerLimits'
                     else
                       'BypassWhenOAFlowGreaterThanMinimum'
                     end
  oa_system.getControllerOutdoorAir.setHeatRecoveryBypassControlType(bypass_ctrl_type)

  return true
end

#air_loop_hvac_apply_energy_recovery_ventilator_efficiency(erv, erv_type: 'ERV', heat_exchanger_type: 'Rotary') ⇒ Object

Apply efficiency values to the erv

Parameters:



1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1668

def air_loop_hvac_apply_energy_recovery_ventilator_efficiency(erv, erv_type: 'ERV', heat_exchanger_type: 'Rotary')
  erv.setSensibleEffectivenessat100HeatingAirFlow(0.7)
  erv.setLatentEffectivenessat100HeatingAirFlow(0.6)
  erv.setSensibleEffectivenessat75HeatingAirFlow(0.7)
  erv.setLatentEffectivenessat75HeatingAirFlow(0.6)
  erv.setSensibleEffectivenessat100CoolingAirFlow(0.75)
  erv.setLatentEffectivenessat100CoolingAirFlow(0.6)
  erv.setSensibleEffectivenessat75CoolingAirFlow(0.75)
  erv.setLatentEffectivenessat75CoolingAirFlow(0.6)
  return erv
end

#air_loop_hvac_apply_maximum_reheat_temperature(air_loop_hvac, max_reheat_c) ⇒ Bool

Sets the maximum reheat temperature to the specified value for all reheat terminals (of any type) on the loop.

Parameters:

  • max_reheat_c (Double)

    the maximum reheat temperature, in C

Returns:

  • (Bool)

    returns true if successful, false if not.



3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3235

def air_loop_hvac_apply_maximum_reheat_temperature(air_loop_hvac, max_reheat_c)
  air_loop_hvac.demandComponents.each do |sc|
    if sc.to_AirTerminalSingleDuctConstantVolumeReheat.is_initialized
      term = sc.to_AirTerminalSingleDuctConstantVolumeReheat.get
      term.setMaximumReheatAirTemperature(max_reheat_c)
    elsif sc.to_AirTerminalSingleDuctParallelPIUReheat.is_initialized
      # No control option available
    elsif sc.to_AirTerminalSingleDuctSeriesPIUReheat.is_initialized
      # No control option available
    elsif sc.to_AirTerminalSingleDuctVAVHeatAndCoolReheat.is_initialized
      term = sc.to_AirTerminalSingleDuctVAVHeatAndCoolReheat.get
      term.setMaximumReheatAirTemperature(max_reheat_c)
    elsif sc.to_AirTerminalSingleDuctVAVReheat.is_initialized
      term = sc.to_AirTerminalSingleDuctVAVReheat.get
      term.setMaximumReheatAirTemperature(max_reheat_c)
    end
  end

  max_reheat_f = OpenStudio.convert(max_reheat_c, 'C', 'F').get
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: reheat terminal maximum set to #{max_reheat_f.round} F.")

  return true
end

#air_loop_hvac_apply_minimum_vav_damper_positions(air_loop_hvac, has_ddc = true) ⇒ Bool

Set the minimum VAV damper positions.

is DDC control of vav terminals. If false, assumes otherwise.

Parameters:

  • has_ddc (Bool) (defaults to: true)

    if true, will assume that there

Returns:

  • (Bool)

    true if successful, false if not



1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1737

def air_loop_hvac_apply_minimum_vav_damper_positions(air_loop_hvac, has_ddc = true)
  air_loop_hvac.thermalZones.each do |zone|
    zone.equipment.each do |equip|
      if equip.to_AirTerminalSingleDuctVAVReheat.is_initialized
        zone_oa = thermal_zone_outdoor_airflow_rate(zone)
        vav_terminal = equip.to_AirTerminalSingleDuctVAVReheat.get
        air_terminal_single_duct_vav_reheat_apply_minimum_damper_position(vav_terminal, zone_oa, has_ddc)
      end
    end
  end

  return true
end

#air_loop_hvac_apply_multizone_vav_outdoor_air_sizing(air_loop_hvac) ⇒ Object

TODO:

move building-type-specific code to Prototype classes

Apply multizone vav outdoor air method and adjust multizone VAV damper positions to achieve a system minimum ventilation effectiveness of 0.6 per PNNL. Hard-size the resulting min OA into the sizing:system object.

return [Bool] returns true if successful, false if not



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 12

def air_loop_hvac_apply_multizone_vav_outdoor_air_sizing(air_loop_hvac)
  # First time adjustment:
  # Only applies to multi-zone vav systems
  # exclusion: for Outpatient: (1) both AHU1 and AHU2 in 'DOE Ref Pre-1980' and 'DOE Ref 1980-2004'
  # (2) AHU1 in 2004-2019
  # TODO refactor: move building-type-specific code to Prototype classes
  if air_loop_hvac_multizone_vav_system?(air_loop_hvac) && !(air_loop_hvac.name.to_s.include? 'Outpatient F1')
    air_loop_hvac_adjust_minimum_vav_damper_positions(air_loop_hvac)
  end

  return true
end

#air_loop_hvac_apply_prm_baseline_controls(air_loop_hvac, climate_zone) ⇒ Bool

Apply all PRM baseline required controls to the airloop. Only applies those controls that differ from the normal prescriptive controls, which are added via air_loop_hvac_apply_standard_controls(AirLoopHVAC)

Returns:

  • (Bool)

    returns true if successful, false if not



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 172

def air_loop_hvac_apply_prm_baseline_controls(air_loop_hvac, climate_zone)
  # Economizers
  if air_loop_hvac_prm_baseline_economizer_required?(air_loop_hvac, climate_zone)
    air_loop_hvac_apply_prm_baseline_economizer(air_loop_hvac, climate_zone)
  end

  # Multizone VAV Systems
  if air_loop_hvac_multizone_vav_system?(air_loop_hvac)

    # VSD no Static Pressure Reset on all VAV systems
    # per G3.1.3.15
    air_loop_hvac_supply_return_exhaust_relief_fans(air_loop_hvac).each do |fan|
      if fan.to_FanVariableVolume.is_initialized
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Setting fan part load curve per G3.1.3.15.")
        fan_variable_volume_set_control_type(fan, 'Multi Zone VAV with VSD and Fixed SP Setpoint')
      end
    end

    # SAT Reset
    # G3.1.3.12 SAT reset required for all Multizone VAV systems,
    # even if not required by prescriptive section.
    air_loop_hvac_enable_supply_air_temperature_reset_warmest_zone(air_loop_hvac)

  end

  # Unoccupied shutdown
  air_loop_hvac_enable_unoccupied_fan_shutoff(air_loop_hvac)

  return true
end

#air_loop_hvac_apply_prm_baseline_economizer(air_loop_hvac, climate_zone) ⇒ Bool

Apply the PRM economizer type and set temperature limits

Returns:

  • (Bool)

    returns true if successful, false if not



1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1240

def air_loop_hvac_apply_prm_baseline_economizer(air_loop_hvac, climate_zone)
  # EnergyPlus economizer types
  # 'NoEconomizer'
  # 'FixedDryBulb'
  # 'FixedEnthalpy'
  # 'DifferentialDryBulb'
  # 'DifferentialEnthalpy'
  # 'FixedDewPointAndDryBulb'
  # 'ElectronicEnthalpy'
  # 'DifferentialDryBulbAndEnthalpy'

  # Determine the type and limits
  economizer_type, drybulb_limit_f, enthalpy_limit_btu_per_lb, dewpoint_limit_f = air_loop_hvac_prm_economizer_type_and_limits(air_loop_hvac, climate_zone)

  # Get the OA system and OA controller
  oa_sys = air_loop_hvac.airLoopHVACOutdoorAirSystem
  if oa_sys.is_initialized
    oa_sys = oa_sys.get
  else
    return false # No OA system
  end
  oa_control = oa_sys.getControllerOutdoorAir

  # Set the economizer type
  oa_control.setEconomizerControlType(economizer_type)

  # Reset the limits
  oa_control.resetEconomizerMaximumLimitDryBulbTemperature
  oa_control.resetEconomizerMaximumLimitEnthalpy
  oa_control.resetEconomizerMaximumLimitDewpointTemperature
  oa_control.resetEconomizerMinimumLimitDryBulbTemperature

  # Set the limits
  case economizer_type
  when 'FixedDryBulb'
    if drybulb_limit_f
      drybulb_limit_c = OpenStudio.convert(drybulb_limit_f, 'F', 'C').get
      oa_control.setEconomizerMaximumLimitDryBulbTemperature(drybulb_limit_c)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Economizer type = #{economizer_type}, dry bulb limit = #{drybulb_limit_f}F")
    end
  when 'FixedEnthalpy'
    if enthalpy_limit_btu_per_lb
      enthalpy_limit_j_per_kg = OpenStudio.convert(enthalpy_limit_btu_per_lb, 'Btu/lb', 'J/kg').get
      oa_control.setEconomizerMaximumLimitEnthalpy(enthalpy_limit_j_per_kg)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Economizer type = #{economizer_type}, enthalpy limit = #{enthalpy_limit_btu_per_lb}Btu/lb")
    end
  when 'FixedDewPointAndDryBulb'
    if drybulb_limit_f && dewpoint_limit_f
      drybulb_limit_c = OpenStudio.convert(drybulb_limit_f, 'F', 'C').get
      dewpoint_limit_c = OpenStudio.convert(dewpoint_limit_f, 'F', 'C').get
      oa_control.setEconomizerMaximumLimitDryBulbTemperature(drybulb_limit_c)
      oa_control.setEconomizerMaximumLimitDewpointTemperature(dewpoint_limit_c)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Economizer type = #{economizer_type}, dry bulb limit = #{drybulb_limit_f}F, dew-point limit = #{dewpoint_limit_f}F")
    end
  end

  return true
end

#air_loop_hvac_apply_prm_baseline_fan_power(air_loop_hvac) ⇒ Object

TODO:

Figure out how to split fan power between multiple fans

Calculate and apply the performance rating method baseline fan power to this air loop. Fan motor efficiency will be set, and then fan pressure rise adjusted so that the fan power is the maximum allowable. Also adjusts the fan power and flow rates of any parallel PIU terminals on the system.

if the proposed model had multiple fans (supply, return, exhaust, etc.) return [Bool] true if successful, false if not.



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 339

def air_loop_hvac_apply_prm_baseline_fan_power(air_loop_hvac)
  # Main AHU fans

  # Calculate the allowable fan motor bhp
  # for the entire airloop.
  allowable_fan_bhp = air_loop_hvac_allowable_system_brake_horsepower(air_loop_hvac)

  # Divide the allowable power evenly between the fans
  # on this airloop.
  all_fans = air_loop_hvac_supply_return_exhaust_relief_fans(air_loop_hvac)
  allowable_fan_bhp /= all_fans.size

  # Set the motor efficiencies
  # for all fans based on the calculated
  # allowed brake hp.  Then calculate the allowable
  # fan power for each fan and adjust
  # the fan pressure rise accordingly
  all_fans.each do |fan|
    fan_apply_standard_minimum_motor_efficiency(fan, allowable_fan_bhp)
    allowable_power_w = allowable_fan_bhp * 746 / fan.motorEfficiency
    fan_adjust_pressure_rise_to_meet_fan_power(fan, allowable_power_w)
  end

  # Fan powered terminal fans

  # Adjust each terminal fan
  air_loop_hvac.demandComponents.each do |dc|
    next if dc.to_AirTerminalSingleDuctParallelPIUReheat.empty?

    pfp_term = dc.to_AirTerminalSingleDuctParallelPIUReheat.get
    air_terminal_single_duct_parallel_piu_reheat_apply_prm_baseline_fan_power(pfp_term)
  end

  return true
end

#air_loop_hvac_apply_prm_sizing_temperatures(air_loop_hvac) ⇒ Bool

Set the system sizing properties based on the zone sizing information

Returns:

  • (Bool)

    true if successful, false if not.



3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3262

def air_loop_hvac_apply_prm_sizing_temperatures(air_loop_hvac)
  # Get the design heating and cooling SAT information
  # for all zones served by the system.
  htg_setpts_c = []
  clg_setpts_c = []
  air_loop_hvac.thermalZones.each do |zone|
    sizing_zone = zone.sizingZone
    htg_setpts_c << sizing_zone.zoneHeatingDesignSupplyAirTemperature
    clg_setpts_c << sizing_zone.zoneCoolingDesignSupplyAirTemperature
  end

  # Cooling SAT set to minimum zone cooling design SAT
  clg_sat_c = clg_setpts_c.min

  # If the system has terminal reheat,
  # heating SAT is set to the same value as cooling SAT
  # and the terminals are expected to do the heating.
  # If not, heating SAT set to maximum zone heating design SAT.
  has_term_rht = air_loop_hvac_terminal_reheat?(air_loop_hvac)
  htg_sat_c = if has_term_rht
                clg_sat_c
              else
                htg_setpts_c.max
              end

  # Set the central SAT values
  sizing_system = air_loop_hvac.sizingSystem
  sizing_system.setCentralCoolingDesignSupplyAirTemperature(clg_sat_c)
  sizing_system.setCentralHeatingDesignSupplyAirTemperature(htg_sat_c)

  clg_sat_f = OpenStudio.convert(clg_sat_c, 'C', 'F').get
  htg_sat_f = OpenStudio.convert(htg_sat_c, 'C', 'F').get
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: central heating SAT set to #{htg_sat_f.round} F, cooling SAT set to #{clg_sat_f.round} F.")

  # If it's a terminal reheat system, set the reheat terminal setpoints too
  if has_term_rht
    rht_c = htg_setpts_c.max
    air_loop_hvac_apply_maximum_reheat_temperature(air_loop_hvac, rht_c)
  end

  return true
end

#air_loop_hvac_apply_single_zone_controls(air_loop_hvac, climate_zone) ⇒ Bool

Generate the EMS used to implement the economizer and staging controls for packaged single zone units.

Returns:

  • (Bool)

    returns true if successful, false if not



2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2630

def air_loop_hvac_apply_single_zone_controls(air_loop_hvac, climate_zone)
  # These controls only apply to systems with DX cooling
  unless air_loop_hvac_dx_cooling?(air_loop_hvac)
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Single zone controls not applicable because no DX cooling.")
    return true
  end

  # Number of stages is determined by the template
  num_stages = air_loop_hvac_single_zone_controls_num_stages(air_loop_hvac, climate_zone)

  # If zero stages, no special control is required
  if num_stages.zero?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: No special economizer controls were modeled.")
    return true
  end

  # Fan control program only used for systems with two-stage DX coils
  fan_control = if air_loop_hvac_multi_stage_dx_cooling?(air_loop_hvac)
                  true
                else
                  false
                end

  # Scrub special characters from the system name
  sn = air_loop_hvac.name.get.to_s
  snc = sn.gsub(/\W/, '').delete('_')
  # If the name starts with a number, prepend with a letter
  if snc[0] =~ /[0-9]/
    snc = "SYS#{snc}"
  end

  # Get the zone name
  zone = air_loop_hvac.thermalZones[0]
  zone_name = zone.name.get.to_s
  zn_name_clean = zone_name.gsub(/\W/, '_')

  # Zone air node
  zone_air_node = zone.zoneAirNode

  # Get the OA system and OA controller
  oa_sys = air_loop_hvac.airLoopHVACOutdoorAirSystem
  if oa_sys.is_initialized
    oa_sys = oa_sys.get
  else
    return false # No OA system
  end
  oa_control = oa_sys.getControllerOutdoorAir
  oa_node = oa_sys.outboardOANode.get

  # Get the name of the min oa schedule
  min_oa_sch = if oa_control.minimumOutdoorAirSchedule.is_initialized
                 oa_control.minimumOutdoorAirSchedule.get
               else
                 air_loop_hvac.model.alwaysOnDiscreteSchedule
               end

  # Get the supply fan
  if air_loop_hvac.supplyFan.empty?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: No supply fan found, cannot apply DX fan/economizer control.")
    return false
  end
  fan = air_loop_hvac.supplyFan.get

  # Supply outlet node
  sup_out_node = air_loop_hvac.supplyOutletNode

  # DX Cooling Coil
  dx_coil = nil
  air_loop_hvac.supplyComponents.each do |equip|
    if equip.to_CoilCoolingDXSingleSpeed.is_initialized
      dx_coil = equip.to_CoilCoolingDXSingleSpeed.get
    elsif equip.to_CoilCoolingDXTwoSpeed.is_initialized
      dx_coil = equip.to_CoilCoolingDXTwoSpeed.get
    end
  end
  if dx_coil.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: No DX cooling coil found, cannot apply DX fan/economizer control.")
    return false
  end

  # Heating Coil
  htg_coil = nil
  air_loop_hvac.supplyComponents.each do |equip|
    if equip.to_CoilHeatingGas.is_initialized
      htg_coil = equip.to_CoilHeatingGas.get
    elsif equip.to_CoilHeatingElectric.is_initialized
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: electric heating coil was found, cannot apply DX fan/economizer control.")
      return false
    elsif equip.to_CoilHeatingWater.is_initialized
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: hot water heating coil was found found, cannot apply DX fan/economizer control.")
      return false
    end
  end
  if htg_coil.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: No heating coil found, cannot apply DX fan/economizer control.")
    return false
  end

  # Create an economizer maximum OA fraction schedule with
  # a maximum of 70% to reflect damper leakage per PNNL
  max_oa_sch_name = "#{snc}maxOASch"
  max_oa_sch = OpenStudio::Model::ScheduleRuleset.new(air_loop_hvac.model)
  max_oa_sch.setName(max_oa_sch_name)
  max_oa_sch.defaultDaySchedule.setName("#{max_oa_sch_name}Default")
  max_oa_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0.7)
  oa_control.setMaximumFractionofOutdoorAirSchedule(max_oa_sch)

  ### EMS shared by both programs ###
  # Sensors
  oat_db_c_sen = OpenStudio::Model::EnergyManagementSystemSensor.new(air_loop_hvac.model, 'Site Outdoor Air Drybulb Temperature')
  oat_db_c_sen.setName('OATF')
  oat_db_c_sen.setKeyName('Environment')

  oat_wb_c_sen = OpenStudio::Model::EnergyManagementSystemSensor.new(air_loop_hvac.model, 'Site Outdoor Air Wetbulb Temperature')
  oat_wb_c_sen.setName('OAWBC')
  oat_wb_c_sen.setKeyName('Environment')

  oa_sch_sen = OpenStudio::Model::EnergyManagementSystemSensor.new(air_loop_hvac.model, 'Schedule Value')
  oa_sch_sen.setName("#{snc}OASch")
  oa_sch_sen.setKeyName(min_oa_sch.handle.to_s)

  oa_flow_sen = OpenStudio::Model::EnergyManagementSystemSensor.new(air_loop_hvac.model, 'System Node Mass Flow Rate')
  oa_flow_sen.setName("#{snc}OAFlowMass")
  oa_flow_sen.setKeyName(oa_node.handle.to_s)

  dat_sen = OpenStudio::Model::EnergyManagementSystemSensor.new(air_loop_hvac.model, 'System Node Setpoint Temperature')
  dat_sen.setName("#{snc}DATRqd")
  dat_sen.setKeyName(sup_out_node.handle.to_s)

  # Internal Variables
  oa_flow_var = OpenStudio::Model::EnergyManagementSystemInternalVariable.new(air_loop_hvac.model, 'Outdoor Air Controller Minimum Mass Flow Rate')
  oa_flow_var.setName("#{snc}OADesignMass")
  oa_flow_var.setInternalDataIndexKeyName(oa_control.handle.to_s)

  # Global Variables
  gvar = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(air_loop_hvac.model, "#{snc}NumberofStages")

  # Programs
  num_stg_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(air_loop_hvac.model)
  num_stg_prg.setName("#{snc}SetNumberofStages")
  num_stg_prg_body = <<-EMS
    SET #{snc}NumberofStages = #{num_stages}
  EMS
  num_stg_prg.setBody(num_stg_prg_body)

  # Program Calling Managers
  setup_mgr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(air_loop_hvac.model)
  setup_mgr.setName("#{snc}SetNumberofStagesCallingManager")
  setup_mgr.setCallingPoint('BeginNewEnvironment')
  setup_mgr.addProgram(num_stg_prg)

  ### Fan Control ###
  if fan_control

    ### Economizer Control ###
    # Actuators
    econ_eff_act = OpenStudio::Model::EnergyManagementSystemActuator.new(max_oa_sch, 'Schedule:Year', 'Schedule Value')
    econ_eff_act.setName("#{snc}TimestepEconEff")

    # Programs
    econ_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(air_loop_hvac.model)
    econ_prg.setName("#{snc}EconomizerCTRLProg")
    econ_prg_body = <<-EMS
      SET #{econ_eff_act.handle} = 0.7
      SET MaxE = 0.7
      SET #{dat_sen.handle} = (#{dat_sen.handle}*1.8)+32
      SET OATF = (#{oat_db_c_sen.handle}*1.8)+32
      SET OAwbF = (#{oat_wb_c_sen.handle}*1.8)+32
      IF #{oa_flow_sen.handle} > (#{oa_flow_var.handle}*#{oa_sch_sen.handle})
        SET EconoActive = 1
      ELSE
        SET EconoActive = 0
      ENDIF
      SET dTNeeded = 75-#{dat_sen.handle}
      SET CoolDesdT = ((98*0.15)+(75*(1-0.15)))-55
      SET CoolLoad = dTNeeded/ CoolDesdT
      IF CoolLoad > 1
        SET CoolLoad = 1
      ELSEIF CoolLoad < 0
        SET CoolLoad = 0
      ENDIF
      IF EconoActive == 1
        SET Stage = #{snc}NumberofStages
        IF Stage == 2
          IF CoolLoad < 0.6
            SET #{econ_eff_act.handle} = MaxE
          ELSE
            SET ECOEff = 0-2.18919863612305
            SET ECOEff = ECOEff+(0-0.674461284910428*CoolLoad)
            SET ECOEff = ECOEff+(0.000459106275872404*(OATF^2))
            SET ECOEff = ECOEff+(0-0.00000484778537945252*(OATF^3))
            SET ECOEff = ECOEff+(0.182915713033586*OAwbF)
            SET ECOEff = ECOEff+(0-0.00382838660261133*(OAwbF^2))
            SET ECOEff = ECOEff+(0.0000255567460240583*(OAwbF^3))
            SET #{econ_eff_act.handle} = ECOEff
          ENDIF
        ELSE
          SET ECOEff = 2.36337942464462
          SET ECOEff = ECOEff+(0-0.409939515512619*CoolLoad)
          SET ECOEff = ECOEff+(0-0.0565205596792225*OAwbF)
          SET ECOEff = ECOEff+(0-0.0000632612294169389*(OATF^2))
          SET #{econ_eff_act.handle} = ECOEff+(0.000571724868775081*(OAwbF^2))
        ENDIF
        IF #{econ_eff_act.handle} > MaxE
          SET #{econ_eff_act.handle} = MaxE
        ELSEIF #{econ_eff_act.handle} < (#{oa_flow_var.handle}*#{oa_sch_sen.handle})
          SET #{econ_eff_act.handle} = (#{oa_flow_var.handle}*#{oa_sch_sen.handle})
        ENDIF
      ENDIF
    EMS
    econ_prg.setBody(econ_prg_body)

    # Program Calling Managers
    econ_mgr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(air_loop_hvac.model)
    econ_mgr.setName("#{snc}EcoManager")
    econ_mgr.setCallingPoint('InsideHVACSystemIterationLoop')
    econ_mgr.addProgram(econ_prg)

    # Sensors
    zn_temp_sen = OpenStudio::Model::EnergyManagementSystemSensor.new(air_loop_hvac.model, 'System Node Temperature')
    zn_temp_sen.setName("#{zn_name_clean}Temp")
    zn_temp_sen.setKeyName(zone_air_node.handle.to_s)

    htg_rtf_sen = OpenStudio::Model::EnergyManagementSystemSensor.new(air_loop_hvac.model, 'Heating Coil Runtime Fraction')
    htg_rtf_sen.setName("#{snc}HeatingRTF")
    htg_rtf_sen.setKeyName(htg_coil.handle.to_s)

    clg_rtf_sen = OpenStudio::Model::EnergyManagementSystemSensor.new(air_loop_hvac.model, 'Cooling Coil Runtime Fraction')
    clg_rtf_sen.setName("#{snc}RTF")
    clg_rtf_sen.setKeyName(dx_coil.handle.to_s)

    spd_sen = OpenStudio::Model::EnergyManagementSystemSensor.new(air_loop_hvac.model, 'Coil System Compressor Speed Ratio')
    spd_sen.setName("#{snc}SpeedRatio")
    spd_sen.setKeyName("#{dx_coil.handle} CoilSystem")

    # Internal Variables
    fan_pres_var = OpenStudio::Model::EnergyManagementSystemInternalVariable.new(air_loop_hvac.model, 'Fan Nominal Pressure Rise')
    fan_pres_var.setName("#{snc}FanDesignPressure")
    fan_pres_var.setInternalDataIndexKeyName(fan.handle.to_s)

    dsn_flow_var = OpenStudio::Model::EnergyManagementSystemInternalVariable.new(air_loop_hvac.model, 'Outdoor Air Controller Maximum Mass Flow Rate')
    dsn_flow_var.setName("#{snc}DesignFlowMass")
    dsn_flow_var.setInternalDataIndexKeyName(oa_control.handle.to_s)

    # Actuators
    fan_pres_act = OpenStudio::Model::EnergyManagementSystemActuator.new(fan, 'Fan', 'Fan Pressure Rise')
    fan_pres_act.setName("#{snc}FanPressure")

    # Global Variables
    gvar = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(air_loop_hvac.model, "#{snc}FanPwrExp")
    gvar = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(air_loop_hvac.model, "#{snc}Stg1Spd")
    gvar = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(air_loop_hvac.model, "#{snc}Stg2Spd")
    gvar = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(air_loop_hvac.model, "#{snc}HeatSpeed")
    gvar = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(air_loop_hvac.model, "#{snc}VenSpeed")

    # Programs
    fan_par_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(air_loop_hvac.model)
    fan_par_prg.setName("#{snc}SetFanPar")
    fan_par_prg_body = <<-EMS
      IF #{snc}NumberofStages == 1
        Return
      ENDIF
      SET #{snc}FanPwrExp = 2.2
      SET OAFrac = #{oa_flow_sen.handle}/#{dsn_flow_var.handle}
      IF  OAFrac < 0.66
        SET #{snc}VenSpeed = 0.66
        SET #{snc}Stg1Spd = 0.66
      ELSE
        SET #{snc}VenSpeed = OAFrac
        SET #{snc}Stg1Spd = OAFrac
      ENDIF
      SET #{snc}Stg2Spd = 1.0
      SET #{snc}HeatSpeed = 1.0
    EMS
    fan_par_prg.setBody(fan_par_prg_body)

    fan_ctrl_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(air_loop_hvac.model)
    fan_ctrl_prg.setName("#{snc}FanControl")
    fan_ctrl_prg_body = <<-EMS
      IF #{snc}NumberofStages == 1
        Return
      ENDIF
      IF #{htg_rtf_sen.handle} > 0
        SET Heating = #{htg_rtf_sen.handle}
        SET Ven = 1-#{htg_rtf_sen.handle}
        SET Eco = 0
        SET Stage1 = 0
        SET Stage2 = 0
      ELSE
        SET Heating = 0
        SET EcoSpeed = #{snc}VenSpeed
        IF #{spd_sen.handle} == 0
          IF #{clg_rtf_sen.handle} > 0
            SET Stage1 = #{clg_rtf_sen.handle}
            SET Stage2 = 0
            SET Ven = 1-#{clg_rtf_sen.handle}
            SET Eco = 0
            IF #{oa_flow_sen.handle} > (#{oa_flow_var.handle}*#{oa_sch_sen.handle})
              SET #{snc}Stg1Spd = 1.0
            ENDIF
          ELSE
            SET Stage1 = 0
            SET Stage2 = 0
            IF #{oa_flow_sen.handle} > (#{oa_flow_var.handle}*#{oa_sch_sen.handle})
              SET Eco = 1.0
              SET Ven = 0
              !Calculate the expected discharge air temperature if the system runs at its low speed
              SET ExpDAT = #{dat_sen.handle}-(1-#{snc}VenSpeed)*#{zn_temp_sen.handle}
              SET ExpDAT = ExpDAT/#{snc}VenSpeed
              IF #{oat_db_c_sen.handle} > ExpDAT
                SET EcoSpeed = #{snc}Stg2Spd
              ENDIF
            ELSE
              SET Eco = 0
              SET Ven = 1.0
            ENDIF
          ENDIF
        ELSE
          SET Stage1 = 1-#{spd_sen.handle}
          SET Stage2 = #{spd_sen.handle}
          SET Ven = 0
          SET Eco = 0
          IF #{oa_flow_sen.handle} > (#{oa_flow_var.handle}*#{oa_sch_sen.handle})
            SET #{snc}Stg1Spd = 1.0
          ENDIF
        ENDIF
      ENDIF
      ! For each mode (percent time in mode)*(fanSpeer^PwrExp) is the contribution to weighted fan power over time step
      SET FPR = Ven*(#{snc}VenSpeed ^ #{snc}FanPwrExp)
      SET FPR = FPR+Eco*(EcoSpeed^#{snc}FanPwrExp)
      SET FPR1 = Stage1*(#{snc}Stg1Spd^#{snc}FanPwrExp)
      SET FPR = FPR+FPR1
      SET FPR2 = Stage2*(#{snc}Stg2Spd^#{snc}FanPwrExp)
      SET FPR = FPR+FPR2
      SET FPR3 = Heating*(#{snc}HeatSpeed^#{snc}FanPwrExp)
      SET FanPwrRatio = FPR+ FPR3
      ! system fan power is directly proportional to static pressure so this change linearly adjusts fan energy for speed control
      SET #{fan_pres_act.handle} = #{fan_pres_var.handle}*FanPwrRatio
    EMS
    fan_ctrl_prg.setBody(fan_ctrl_prg_body)

    # Program Calling Managers
    # Note that num_stg_prg must be listed before fan_par_prg
    # because it initializes a variable used by fan_par_prg.
    setup_mgr.addProgram(fan_par_prg)

    fan_ctrl_mgr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(air_loop_hvac.model)
    fan_ctrl_mgr.setName("#{snc}FanMainManager")
    fan_ctrl_mgr.setCallingPoint('BeginTimestepBeforePredictor')
    fan_ctrl_mgr.addProgram(fan_ctrl_prg)

  end

  return true
end

#air_loop_hvac_apply_standard_controls(air_loop_hvac, climate_zone) ⇒ Bool

TODO:

optimum start

TODO:

night damper shutoff

TODO:

nightcycle control

TODO:

night fan shutoff

Apply all standard required controls to the airloop

Returns:

  • (Bool)

    returns true if successful, false if not



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 33

def air_loop_hvac_apply_standard_controls(air_loop_hvac, climate_zone)
  # Unoccupied shutdown
  # Apply this before ERV because it modifies annual hours of operation which can impact ERV requirements
  if air_loop_hvac_unoccupied_fan_shutoff_required?(air_loop_hvac)
    occ_threshold = air_loop_hvac_unoccupied_threshold
    air_loop_hvac_enable_unoccupied_fan_shutoff(air_loop_hvac, min_occ_pct = occ_threshold)
  else
    air_loop_hvac.setAvailabilitySchedule(air_loop_hvac.model.alwaysOnDiscreteSchedule)
  end

  # Energy Recovery Ventilation
  if air_loop_hvac_energy_recovery_ventilator_required?(air_loop_hvac, climate_zone)
    air_loop_hvac_apply_energy_recovery_ventilator(air_loop_hvac, climate_zone)
  end

  # Economizers
  air_loop_hvac_apply_economizer_limits(air_loop_hvac, climate_zone)
  air_loop_hvac_apply_economizer_integration(air_loop_hvac, climate_zone)

  # Multizone VAV Systems
  if air_loop_hvac_multizone_vav_system?(air_loop_hvac)

    # VAV Reheat Control
    air_loop_hvac_apply_vav_damper_action(air_loop_hvac)

    # Multizone VAV Optimization
    # This rule does not apply to two hospital and one outpatient systems (TODO add hospital two systems as exception)
    unless air_loop_hvac.name.to_s.include? 'Outpatient F1'
      if air_loop_hvac_multizone_vav_optimization_required?(air_loop_hvac, climate_zone)
        air_loop_hvac_enable_multizone_vav_optimization(air_loop_hvac)
      else
        air_loop_hvac_disable_multizone_vav_optimization(air_loop_hvac)
      end
    end

    # Static Pressure Reset
    # Per 5.2.2.16 (Halverson et al 2014), all multiple zone VAV systems are assumed to have DDC for all years of DOE 90.1 prototypes, so the has_ddc is not used any more.
    air_loop_hvac_supply_return_exhaust_relief_fans(air_loop_hvac).each do |fan|
      if fan.to_FanVariableVolume.is_initialized
        plr_req = fan_variable_volume_part_load_fan_power_limitation?(fan)
        # Part Load Fan Pressure Control
        if plr_req
          fan_variable_volume_set_control_type(fan, 'Multi Zone VAV with VSD and SP Setpoint Reset')
        # No Part Load Fan Pressure Control
        else
          fan_variable_volume_set_control_type(fan, 'Multi Zone VAV with discharge dampers')
        end
      else
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{fan}: This is not a multizone VAV fan system.")
      end
    end

    ## # Static Pressure Reset
    ## # assume no systems have DDC control of VAV terminals
    ## has_ddc = false
    ## spr_req = air_loop_hvac_static_pressure_reset_required?(air_loop_hvac, template, has_ddc)
    ## air_loop_hvac_supply_return_exhaust_relief_fans(air_loop_hvac).each do |fan|
    ##   if fan.to_FanVariableVolume.is_initialized
    ##     plr_req = fan_variable_volume_part_load_fan_power_limitation?(fan, template)
    ##     # Part Load Fan Pressure Control & Static Pressure Reset
    ##     if plr_req && spr_req
    ##       fan_variable_volume_set_control_type(fan, 'Multi Zone VAV with VSD and Static Pressure Reset')
    ##     # Part Load Fan Pressure Control only
    ##     elsif plr_req && !spr_req
    ##       fan_variable_volume_set_control_type(fan, 'Multi Zone VAV with VSD and Fixed SP Setpoint')
    ##     # Static Pressure Reset only
    ##     elsif !plr_req && spr_req
    ##       fan_variable_volume_set_control_type(fan, 'Multi Zone VAV with VSD and Fixed SP Setpoint')
    ##     # No Control Required
    ##     else
    ##       fan_variable_volume_set_control_type(fan, 'Multi Zone VAV with AF or BI Riding Curve')
    ##     end
    ##   else
    ##     OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.AirLoopHVAC', "For #{name}: there is a constant volume fan on a multizone vav system.  Cannot apply static pressure reset controls.")
    ##   end
    ## end
  end

  # DCV
  if air_loop_hvac_demand_control_ventilation_required?(air_loop_hvac, climate_zone)
    air_loop_hvac_enable_demand_control_ventilation(air_loop_hvac, climate_zone)
    # For systems that require DCV,
    # all individual zones that require DCV preserve
    # both per-area and per-person OA requirements.
    # Other zones have OA requirements converted
    # to per-area values only so DCV performance is only
    # based on the subset of zones that required DCV.
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Converting ventilation requirements to per-area for all zones served that do not require DCV.")
    air_loop_hvac.thermalZones.sort.each do |zone|
      unless thermal_zone_demand_control_ventilation_required?(zone, climate_zone)
        thermal_zone_convert_oa_req_to_per_area(zone)
      end
    end
  end

  # SAT reset
  if air_loop_hvac_supply_air_temperature_reset_required?(air_loop_hvac, climate_zone)
    reset_type = air_loop_hvac_supply_air_temperature_reset_type(air_loop_hvac)
    case reset_type
      when 'warmest_zone'
        air_loop_hvac_enable_supply_air_temperature_reset_warmest_zone(air_loop_hvac)
      when 'oa'
        air_loop_hvac_enable_supply_air_temperature_reset_outdoor_temperature(air_loop_hvac)
      else
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "No SAT reset for #{air_loop_hvac.name}.")
    end
  end

  # Motorized OA damper
  if air_loop_hvac_motorized_oa_damper_required?(air_loop_hvac, climate_zone)
    # Assume that the availability schedule has already been
    # set to reflect occupancy and use this for the OA damper.
    occ_threshold = air_loop_hvac_unoccupied_threshold
    air_loop_hvac_add_motorized_oa_damper(air_loop_hvac, occ_threshold, air_loop_hvac.availabilitySchedule)
  else
    air_loop_hvac_remove_motorized_oa_damper(air_loop_hvac)
  end

  # Optimum Start
  air_loop_hvac_enable_optimum_start(air_loop_hvac) if air_loop_hvac_optimum_start_required?(air_loop_hvac)

  # Single zone systems
  if air_loop_hvac.thermalZones.size == 1
    air_loop_hvac_supply_return_exhaust_relief_fans(air_loop_hvac).each do |fan|
      if fan.to_FanVariableVolume.is_initialized
        fan_variable_volume_set_control_type(fan, 'Single Zone VAV Fan')
      end
    end
    air_loop_hvac_apply_single_zone_controls(air_loop_hvac, climate_zone)
  end
end

#air_loop_hvac_apply_vav_damper_action(air_loop_hvac) ⇒ Bool

TODO:

see if this impacts the sizing run.

Set the VAV damper control to single maximum or dual maximum control depending on the standard.

Returns:

  • (Bool)

    Returns true if successful, false if not



2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2398

def air_loop_hvac_apply_vav_damper_action(air_loop_hvac)
  damper_action = air_loop_hvac_vav_damper_action(air_loop_hvac)

  # Interpret this as an EnergyPlus input
  damper_action_eplus = nil
  if damper_action == 'Single Maximum'
    damper_action_eplus = 'Normal'
  elsif damper_action == 'Dual Maximum'
    # EnergyPlus 8.7 changed the meaning of 'Reverse'.
    # For versions of OpenStudio using E+ 8.6 or lower
    damper_action_eplus = if air_loop_hvac.model.version < OpenStudio::VersionString.new('2.0.5')
                            'Reverse'
                          # For versions of OpenStudio using E+ 8.7 or higher
                          else
                            'ReverseWithLimits'
                          end
  end

  # Set the control for any VAV reheat terminals on this airloop.
  control_type_set = false
  air_loop_hvac.demandComponents.each do |equip|
    if equip.to_AirTerminalSingleDuctVAVReheat.is_initialized
      term = equip.to_AirTerminalSingleDuctVAVReheat.get
      # Dual maximum only applies to terminals with HW reheat coils
      if damper_action == 'Dual Maximum'
        if term.reheatCoil.to_CoilHeatingWater.is_initialized
          term.setDamperHeatingAction(damper_action_eplus)
          control_type_set = true
        end
      else
        term.setDamperHeatingAction(damper_action_eplus)
        control_type_set = true
        term.setMaximumFlowFractionDuringReheat(0.5)
      end
    end
  end

  if control_type_set
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: VAV damper action was set to #{damper_action} control.")
  end

  return true
end

#air_loop_hvac_data_center_area_served(air_loop_hvac) ⇒ Double

TODO:

Add an is_data_center field to the

Determine how much data center area the airloop serves.

in m^2. standards space type spreadsheet instead of relying on the standards space type name to identify a data center.

Returns:

  • (Double)

    the area of data center is served,



3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3189

def air_loop_hvac_data_center_area_served(air_loop_hvac)
  dc_area_m2 = 0.0

  air_loop_hvac.thermalZones.each do |zone|
    zone.spaces.each do |space|
      # Skip spaces with no space type
      next if space.spaceType.empty?

      space_type = space.spaceType.get

      # Skip spaces with no standards space type
      next if space_type.standardsSpaceType.empty?

      standards_space_type = space_type.standardsSpaceType.get
      # Counts as a data center if the name includes 'data'
      if standards_space_type.downcase.include?('data center') || standards_space_type.downcase.include?('datacenter')
        dc_area_m2 += space.floorArea
      end
      std_bldg_type = space.spaceType.get.standardsBuildingType.get
      if std_bldg_type.downcase.include?('datacenter') && standards_space_type.downcase.include?('computerroom')
        dc_area_m2 += space.floorArea
      end
    end
  end

  return dc_area_m2
end

#air_loop_hvac_dcv_required_when_erv(air_loop_hvac) ⇒ Object

Determine if the standard has an exception for demand control ventilation when an energy recovery device is present. Defaults to true.



2128
2129
2130
2131
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2128

def air_loop_hvac_dcv_required_when_erv(air_loop_hvac)
  dcv_required_when_erv_present = false
  return dcv_required_when_erv_present
end

#air_loop_hvac_demand_control_ventilation_limits(air_loop_hvac) ⇒ Array<Double>

Determines the OA flow rates above which an economizer is required. Two separate rates, one for systems with an economizer and another for systems without. Defaults to pre-1980 logic, where the limits are zero for both types.

Returns:

  • (Array<Double>)
    min_oa_without_economizer_cfm, min_oa_with_economizer_cfm


2120
2121
2122
2123
2124
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2120

def air_loop_hvac_demand_control_ventilation_limits(air_loop_hvac)
  min_oa_without_economizer_cfm = 0
  min_oa_with_economizer_cfm = 0
  return [min_oa_without_economizer_cfm, min_oa_with_economizer_cfm]
end

#air_loop_hvac_demand_control_ventilation_required?(air_loop_hvac, climate_zone) ⇒ Bool

TODO:

Add exception logic for systems that serve multifamily, parking garage, warehouse

Determine if demand control ventilation (DCV) is required for this air loop.

Returns:

  • (Bool)

    Returns true if required, false if not.



2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2038

def air_loop_hvac_demand_control_ventilation_required?(air_loop_hvac, climate_zone)
  dcv_required = false

  # OA flow limits
  min_oa_without_economizer_cfm, min_oa_with_economizer_cfm = air_loop_hvac_demand_control_ventilation_limits(air_loop_hvac)

  # If the limits are zero for both, DCV not required
  if min_oa_without_economizer_cfm.zero? && min_oa_with_economizer_cfm.zero?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{template} #{climate_zone}:  #{air_loop_hvac.name}: DCV is not required for any system.")
    return dcv_required
  end

  # Check if the system has an ERV
  if air_loop_hvac_energy_recovery?(air_loop_hvac)
    # May or may not be required for systems that have an ERV
    if air_loop_hvac_dcv_required_when_erv(air_loop_hvac)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: DCV may be required although the system has Energy Recovery.")
    else
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: DCV is not required since the system has Energy Recovery.")
      return dcv_required
    end
  end

  # Get the min OA flow rate
  oa_flow_m3_per_s = 0
  if air_loop_hvac.airLoopHVACOutdoorAirSystem.is_initialized
    oa_system = air_loop_hvac.airLoopHVACOutdoorAirSystem.get
    controller_oa = oa_system.getControllerOutdoorAir
    if controller_oa.minimumOutdoorAirFlowRate.is_initialized
      oa_flow_m3_per_s = controller_oa.minimumOutdoorAirFlowRate.get
    elsif controller_oa.autosizedMinimumOutdoorAirFlowRate.is_initialized
      oa_flow_m3_per_s = controller_oa.autosizedMinimumOutdoorAirFlowRate.get
    end
  else
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}, DCV not applicable because it has no OA intake.")
    return dcv_required
  end
  oa_flow_cfm = OpenStudio.convert(oa_flow_m3_per_s, 'm^3/s', 'cfm').get

  # Check for min OA without an economizer OR has economizer
  if oa_flow_cfm < min_oa_without_economizer_cfm && air_loop_hvac_economizer?(air_loop_hvac) == false
    # Message if doesn't pass OA limit
    if oa_flow_cfm < min_oa_without_economizer_cfm
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: DCV is not required since the system min oa flow is #{oa_flow_cfm.round} cfm, less than the minimum of #{min_oa_without_economizer_cfm.round} cfm.")
    end
    # Message if doesn't have economizer
    if air_loop_hvac_economizer?(air_loop_hvac) == false
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: DCV is not required since the system does not have an economizer.")
    end
    return dcv_required
  end

  # If has economizer, cfm limit is lower
  if oa_flow_cfm < min_oa_with_economizer_cfm && air_loop_hvac_economizer?(air_loop_hvac)
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: DCV is not required since the system has an economizer, but the min oa flow is #{oa_flow_cfm.round} cfm, less than the minimum of #{min_oa_with_economizer_cfm.round} cfm for systems with an economizer.")
    return dcv_required
  end

  # Check area and density limits
  # for all of zones on the loop
  any_zones_req_dcv = false
  air_loop_hvac.thermalZones.sort.each do |zone|
    if thermal_zone_demand_control_ventilation_required?(zone, climate_zone)
      any_zones_req_dcv = true
      break
    end
  end
  unless any_zones_req_dcv
    return dcv_required
  end

  # If here, DCV is required
  dcv_required = true

  return dcv_required
end

#air_loop_hvac_disable_multizone_vav_optimization(air_loop_hvac) ⇒ Bool

Disable multizone vav optimization by changing the Outdoor Air Method in the Controller:MechanicalVentilation object to ‘ZoneSum’

Returns:

  • (Bool)

    Returns true if required, false if not.



1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1717

def air_loop_hvac_disable_multizone_vav_optimization(air_loop_hvac)
  # Disable multizone vav optimization
  # at each timestep.
  if air_loop_hvac.airLoopHVACOutdoorAirSystem.is_initialized
    oa_system = air_loop_hvac.airLoopHVACOutdoorAirSystem.get
    controller_oa = oa_system.getControllerOutdoorAir
    controller_mv = controller_oa.controllerMechanicalVentilation
    controller_mv.setSystemOutdoorAirMethod('ZoneSum')
    controller_oa.autosizeMinimumOutdoorAirFlowRate
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}, cannot disable multizone vav optimization because the system has no OA intake.")
    return false
  end
end

#air_loop_hvac_dx_cooling?(air_loop_hvac) ⇒ Bool

Determine if this Air Loop uses DX cooling.

Returns:

  • (Bool)

    true if uses DX cooling, false if not.



3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3331

def air_loop_hvac_dx_cooling?(air_loop_hvac)
  dx_clg = false

  # Check for all DX coil types
  dx_types = [
    'OS_Coil_Cooling_DX_MultiSpeed',
    'OS_Coil_Cooling_DX_SingleSpeed',
    'OS_Coil_Cooling_DX_TwoSpeed',
    'OS_Coil_Cooling_DX_TwoStageWithHumidityControlMode',
    'OS_Coil_Cooling_DX_VariableRefrigerantFlow',
    'OS_Coil_Cooling_DX_VariableSpeed',
    'OS_CoilSystem_Cooling_DX_HeatExchangerAssisted'
  ]

  air_loop_hvac.supplyComponents.each do |component|
    # Get the object type, getting the internal coil
    # type if inside a unitary system.
    obj_type = component.iddObjectType.valueName.to_s
    case obj_type
    when 'OS_AirLoopHVAC_UnitaryHeatCool_VAVChangeoverBypass'
      component = component.to_AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass.get
      obj_type = component.coolingCoil.iddObjectType.valueName.to_s
    when 'OS_AirLoopHVAC_UnitaryHeatPump_AirToAir'
      component = component.to_AirLoopHVACUnitaryHeatPumpAirToAir.get
      obj_type = component.coolingCoil.iddObjectType.valueName.to_s
    when 'OS_AirLoopHVAC_UnitaryHeatPump_AirToAir_MultiSpeed'
      component = component.to_AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.get
      obj_type = component.coolingCoil.iddObjectType.valueName.to_s
    when 'OS_AirLoopHVAC_UnitarySystem'
      component = component.to_AirLoopHVACUnitarySystem.get
      if component.coolingCoil.is_initialized
        obj_type = component.coolingCoil.get.iddObjectType.valueName.to_s
      end
    end
    # See if the object type is a DX coil
    if dx_types.include?(obj_type)
      dx_clg = true
      break # Stop if find a DX coil
    end
  end

  return dx_clg
end

#air_loop_hvac_economizer?(air_loop_hvac) ⇒ Bool

Determine if the system has an economizer

Returns:

  • (Bool)

    Returns true if required, false if not.



2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2269

def air_loop_hvac_economizer?(air_loop_hvac)
  # Get the OA system and OA controller
  oa_sys = air_loop_hvac.airLoopHVACOutdoorAirSystem
  if oa_sys.is_initialized
    oa_sys = oa_sys.get
  else
    return false # No OA system
  end
  oa_control = oa_sys.getControllerOutdoorAir
  economizer_type = oa_control.getEconomizerControlType

  # Return false if no economizer is present
  if economizer_type == 'NoEconomizer'
    return false
  else
    return true
  end
end

#air_loop_hvac_economizer_limits(air_loop_hvac, climate_zone) ⇒ Array<Double>

Determine the limits for the type of economizer present on the AirLoopHVAC, if any.

Returns:

  • (Array<Double>)
    drybulb_limit_f, enthalpy_limit_btu_per_lb, dewpoint_limit_f


1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1001

def air_loop_hvac_economizer_limits(air_loop_hvac, climate_zone)
  drybulb_limit_f = nil
  enthalpy_limit_btu_per_lb = nil
  dewpoint_limit_f = nil

  # Get the OA system and OA controller
  oa_sys = air_loop_hvac.airLoopHVACOutdoorAirSystem
  if oa_sys.is_initialized
    oa_sys = oa_sys.get
  else
    return [nil, nil, nil] # No OA system
  end
  oa_control = oa_sys.getControllerOutdoorAir
  economizer_type = oa_control.getEconomizerControlType

  case economizer_type
  when 'NoEconomizer'
    return [nil, nil, nil]
  when 'FixedDryBulb'
    search_criteria = {
      'template' => template,
      'climate_zone' => climate_zone
    }
    econ_limits = model_find_object(standards_data['economizers'], search_criteria)
    drybulb_limit_f = econ_limits['fixed_dry_bulb_high_limit_shutoff_temp']
  when 'FixedEnthalpy'
    enthalpy_limit_btu_per_lb = 28
  when 'FixedDewPointAndDryBulb'
    drybulb_limit_f = 75
    dewpoint_limit_f = 55
  end

  return [drybulb_limit_f, enthalpy_limit_btu_per_lb, dewpoint_limit_f]
end

#air_loop_hvac_economizer_required?(air_loop_hvac, climate_zone) ⇒ Bool

Determine whether or not this system is required to have an economizer.

‘ASHRAE 169-2013-3A’, ‘ASHRAE 169-2013-3B’, ‘ASHRAE 169-2013-3C’, ‘ASHRAE 169-2013-4A’, ‘ASHRAE 169-2013-4B’, ‘ASHRAE 169-2013-4C’, ‘ASHRAE 169-2013-5A’, ‘ASHRAE 169-2013-5B’, ‘ASHRAE 169-2013-5C’, ‘ASHRAE 169-2013-6A’, ‘ASHRAE 169-2013-6B’, ‘ASHRAE 169-2013-7A’, ‘ASHRAE 169-2013-7B’, ‘ASHRAE 169-2013-8A’, ‘ASHRAE 169-2013-8B’

Parameters:

  • climate_zone (String)

    valid choices: ‘ASHRAE 169-2013-1A’, ‘ASHRAE 169-2013-1B’, ‘ASHRAE 169-2013-2A’, ‘ASHRAE 169-2013-2B’,

Returns:

  • (Bool)

    returns true if an economizer is required, false if not



856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 856

def air_loop_hvac_economizer_required?(air_loop_hvac, climate_zone)
  economizer_required = false

  # skip systems without outdoor air
  return economizer_required unless air_loop_hvac.airLoopHVACOutdoorAirSystem.is_initialized

  # Determine if the system serves residential spaces
  is_res = false
  if air_loop_hvac_residential_area_served(air_loop_hvac) > 0
    is_res = true
  end

  # Determine if the airloop serves any computer rooms
  # / data centers, which changes the economizer.
  is_dc = false
  if air_loop_hvac_data_center_area_served(air_loop_hvac) > 0
    is_dc = true
  end

  # Retrieve economizer limits from JSON
  search_criteria = {
    'template' => template,
    'climate_zone' => climate_zone,
    'data_center' => is_dc
  }
  econ_limits = model_find_object(standards_data['economizers'], search_criteria)
  if econ_limits.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "Cannot find economizer limits for template '#{template}' and climate zone '#{climate_zone}', assuming no economizer required.")
    return economizer_required
  end

  # Determine the minimum capacity and whether or not it is a data center
  minimum_capacity_btu_per_hr = econ_limits['capacity_limit']

  # A big number of btu per hr as the minimum requirement if nil in spreadsheet
  infinity_btu_per_hr = 999_999_999_999
  minimum_capacity_btu_per_hr = infinity_btu_per_hr if minimum_capacity_btu_per_hr.nil?

  # Exception valid for 90.1-2004 (6.5.1.(e)) through 90.1-2019 (6.5.1.4)
  if is_res
    minimum_capacity_btu_per_hr *= 5
  end

  # Check whether the system requires an economizer by comparing
  # the system capacity to the minimum capacity.
  total_cooling_capacity_w = air_loop_hvac_total_cooling_capacity(air_loop_hvac)
  total_cooling_capacity_btu_per_hr = OpenStudio.convert(total_cooling_capacity_w, 'W', 'Btu/hr').get

  if total_cooling_capacity_btu_per_hr >= minimum_capacity_btu_per_hr
    if is_dc
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "#{air_loop_hvac.name} requires an economizer because the total cooling capacity of #{total_cooling_capacity_btu_per_hr.round} Btu/hr exceeds the minimum capacity of #{minimum_capacity_btu_per_hr.round} Btu/hr for data centers.")
    elsif is_res
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "#{air_loop_hvac.name} requires an economizer because the total cooling capacity of #{total_cooling_capacity_btu_per_hr.round} Btu/hr exceeds the minimum capacity of #{minimum_capacity_btu_per_hr.round} Btu/hr for residential spaces.")
    else
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "#{air_loop_hvac.name} requires an economizer because the total cooling capacity of #{total_cooling_capacity_btu_per_hr.round} Btu/hr exceeds the minimum capacity of #{minimum_capacity_btu_per_hr.round} Btu/hr.")
    end
    economizer_required = true
  else
    if is_dc
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "#{air_loop_hvac.name} does not require an economizer because the total cooling capacity of #{total_cooling_capacity_btu_per_hr.round} Btu/hr is less than the minimum capacity of #{minimum_capacity_btu_per_hr.round} Btu/hr for data centers.")
    elsif is_res
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "#{air_loop_hvac.name} requires an economizer because the total cooling capacity of #{total_cooling_capacity_btu_per_hr.round} Btu/hr exceeds the minimum capacity of #{minimum_capacity_btu_per_hr.round} Btu/hr for residential spaces.")
    else
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "#{air_loop_hvac.name} does not require an economizer because the total cooling capacity of #{total_cooling_capacity_btu_per_hr.round} Btu/hr is less than the minimum capacity of #{minimum_capacity_btu_per_hr.round} Btu/hr.")
    end
  end

  return economizer_required
end

#air_loop_hvac_economizer_type_allowable?(air_loop_hvac, climate_zone) ⇒ Bool

Check the economizer type currently specified in the ControllerOutdoorAir object on this air loop is acceptable per the standard. Defaults to 90.1-2007 logic.

Returns false if the economizer type is not allowable.

Returns:

  • (Bool)

    Returns true if allowable, if the system has no economizer or no OA system.



1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1359

def air_loop_hvac_economizer_type_allowable?(air_loop_hvac, climate_zone)
  # EnergyPlus economizer types
  # 'NoEconomizer'
  # 'FixedDryBulb'
  # 'FixedEnthalpy'
  # 'DifferentialDryBulb'
  # 'DifferentialEnthalpy'
  # 'FixedDewPointAndDryBulb'
  # 'ElectronicEnthalpy'
  # 'DifferentialDryBulbAndEnthalpy'

  # Get the OA system and OA controller
  oa_sys = air_loop_hvac.airLoopHVACOutdoorAirSystem
  if oa_sys.is_initialized
    oa_sys = oa_sys.get
  else
    return true # No OA system
  end
  oa_control = oa_sys.getControllerOutdoorAir
  economizer_type = oa_control.getEconomizerControlType

  # Return true if no economizer is present
  if economizer_type == 'NoEconomizer'
    return true
  end

  # Determine the prohibited types
  prohibited_types = []
  case climate_zone
  when 'ASHRAE 169-2006-0B',
       'ASHRAE 169-2006-1B',
       'ASHRAE 169-2006-2B',
       'ASHRAE 169-2006-3B',
       'ASHRAE 169-2006-3C',
       'ASHRAE 169-2006-4B',
       'ASHRAE 169-2006-4C',
       'ASHRAE 169-2006-5B',
       'ASHRAE 169-2006-6B',
       'ASHRAE 169-2006-7A',
       'ASHRAE 169-2006-7B',
       'ASHRAE 169-2006-8A',
       'ASHRAE 169-2006-8B',
       'ASHRAE 169-2013-0B',
       'ASHRAE 169-2013-1B',
       'ASHRAE 169-2013-2B',
       'ASHRAE 169-2013-3B',
       'ASHRAE 169-2013-3C',
       'ASHRAE 169-2013-4B',
       'ASHRAE 169-2013-4C',
       'ASHRAE 169-2013-5B',
       'ASHRAE 169-2013-6B',
       'ASHRAE 169-2013-7A',
       'ASHRAE 169-2013-7B',
       'ASHRAE 169-2013-8A',
       'ASHRAE 169-2013-8B'
    prohibited_types = ['FixedEnthalpy']
  when 'ASHRAE 169-2006-0A',
       'ASHRAE 169-2006-1A',
       'ASHRAE 169-2006-2A',
       'ASHRAE 169-2006-3A',
       'ASHRAE 169-2006-4A',
       'ASHRAE 169-2013-0A',
       'ASHRAE 169-2013-1A',
       'ASHRAE 169-2013-2A',
       'ASHRAE 169-2013-3A',
       'ASHRAE 169-2013-4A'
    prohibited_types = ['DifferentialDryBulb']
  when 'ASHRAE 169-2006-5A',
       'ASHRAE 169-2006-6A',
       'ASHRAE 169-2013-5A',
       'ASHRAE 169-2013-6A'
    prohibited_types = []
  end

  # Check if the specified type is allowed
  economizer_type_allowed = true
  if prohibited_types.include?(economizer_type)
    economizer_type_allowed = false
  end

  return economizer_type_allowed
end

#air_loop_hvac_enable_demand_control_ventilation(air_loop_hvac, climate_zone) ⇒ Bool

Enable demand control ventilation (DCV) for this air loop. Zones on this loop that require DCV preserve both per-area and per-person OA reqs. Other zones have OA reqs converted to per-area values only so that DCV won’t impact these zones.

Returns:

  • (Bool)

    Returns true if required, false if not.



2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2140

def air_loop_hvac_enable_demand_control_ventilation(air_loop_hvac, climate_zone)
  # Get the OA intake
  controller_oa = nil
  controller_mv = nil
  if air_loop_hvac.airLoopHVACOutdoorAirSystem.is_initialized
    oa_system = air_loop_hvac.airLoopHVACOutdoorAirSystem.get
    controller_oa = oa_system.getControllerOutdoorAir
    controller_mv = controller_oa.controllerMechanicalVentilation
    if controller_mv.demandControlledVentilation == true
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: DCV was already enabled.")
      return true
    end
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Could not enable DCV since the system has no OA intake.")
    return false
  end

  # Change the min flow rate in the controller outdoor air
  controller_oa.setMinimumOutdoorAirFlowRate(0.0)

  # Enable DCV in the controller mechanical ventilation
  controller_mv.setDemandControlledVentilation(true)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Enabled DCV.")

  return true
end

#air_loop_hvac_enable_multizone_vav_optimization(air_loop_hvac) ⇒ Bool

Enable multizone vav optimization by changing the Outdoor Air Method in the Controller:MechanicalVentilation object to ‘VentilationRateProcedure’

Returns:

  • (Bool)

    Returns true if required, false if not.



1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1697

def air_loop_hvac_enable_multizone_vav_optimization(air_loop_hvac)
  # Enable multizone vav optimization
  # at each timestep.
  if air_loop_hvac.airLoopHVACOutdoorAirSystem.is_initialized
    oa_system = air_loop_hvac.airLoopHVACOutdoorAirSystem.get
    controller_oa = oa_system.getControllerOutdoorAir
    controller_mv = controller_oa.controllerMechanicalVentilation
    controller_mv.setSystemOutdoorAirMethod('VentilationRateProcedure')
    # Change the min flow rate in the controller outdoor air
    controller_oa.setMinimumOutdoorAirFlowRate(0.0)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}, cannot enable multizone vav optimization because the system has no OA intake.")
    return false
  end
end

#air_loop_hvac_enable_optimum_start(air_loop_hvac) ⇒ Object

Adds optimum start control to the airloop.



240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 240

def air_loop_hvac_enable_optimum_start(air_loop_hvac)
  # Get the heating and cooling setpoint schedules
  # for all zones on this airloop.
  htg_clg_schs = []
  air_loop_hvac.thermalZones.each do |zone|
    # Skip zones with no thermostat
    next if zone.thermostatSetpointDualSetpoint.empty?

    # Get the heating and cooling setpoint schedules
    tstat = zone.thermostatSetpointDualSetpoint.get
    htg_sch = nil
    if tstat.heatingSetpointTemperatureSchedule.is_initialized
      htg_sch = tstat.heatingSetpointTemperatureSchedule.get
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{zone.name}: Cannot find a heating setpoint schedule for this zone, cannot apply optimum start control.")
      next
    end
    clg_sch = nil
    if tstat.coolingSetpointTemperatureSchedule.is_initialized
      clg_sch = tstat.coolingSetpointTemperatureSchedule.get
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{zone.name}: Cannot find a cooling setpoint schedule for this zone, cannot apply optimum start control.")
      next
    end
    htg_clg_schs << [htg_sch, clg_sch]
  end

  # Clean name of airloop
  loop_name_clean = air_loop_hvac.name.get.to_s.gsub(/\W/, '').delete('_')
  # If the name starts with a number, prepend with a letter
  if loop_name_clean[0] =~ /[0-9]/
    loop_name_clean = "SYS#{loop_name_clean}"
  end

  # Sensors
  oat_db_c_sen = OpenStudio::Model::EnergyManagementSystemSensor.new(air_loop_hvac.model, 'Site Outdoor Air Drybulb Temperature')
  oat_db_c_sen.setName('OAT')
  oat_db_c_sen.setKeyName('Environment')

  # Make a program for each unique set of schedules.
  # For most air loops, all zones will have the same
  # pair of schedules.
  htg_clg_schs.uniq.each_with_index do |htg_clg_sch, i|
    htg_sch = htg_clg_sch[0]
    clg_sch = htg_clg_sch[1]

    # Actuators
    htg_sch_act = OpenStudio::Model::EnergyManagementSystemActuator.new(htg_sch, 'Schedule:Year', 'Schedule Value')
    htg_sch_act.setName("#{loop_name_clean}HtgSch#{i}")

    clg_sch_act = OpenStudio::Model::EnergyManagementSystemActuator.new(clg_sch, 'Schedule:Year', 'Schedule Value')
    clg_sch_act.setName("#{loop_name_clean}ClgSch#{i}")

    # Programs
    optstart_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(air_loop_hvac.model)
    optstart_prg.setName("#{loop_name_clean}OptimumStartProg#{i}")
    optstart_prg_body = <<-EMS
    IF DaylightSavings==0 && DayOfWeek>1 && Hour==5 && #{oat_db_c_sen.handle}<23.9 && #{oat_db_c_sen.handle}>1.7
      SET #{clg_sch_act.handle} = 29.4
      SET #{htg_sch_act.handle} = 15.6
    ELSEIF DaylightSavings==0 && DayOfWeek==1 && Hour==7 && #{oat_db_c_sen.handle}<23.9 && #{oat_db_c_sen.handle}>1.7
      SET #{clg_sch_act.handle} = 29.4
      SET #{htg_sch_act.handle} = 15.6
    ELSEIF DaylightSavings==1 && DayOfWeek>1 && Hour==4 && #{oat_db_c_sen.handle}<23.9 && #{oat_db_c_sen.handle}>1.7
      SET #{clg_sch_act.handle} = 29.4
      SET #{htg_sch_act.handle} = 15.6
    ELSEIF DaylightSavings==1 && DayOfWeek==1 && Hour==6 && #{oat_db_c_sen.handle}<23.9 && #{oat_db_c_sen.handle}>1.7
      SET #{clg_sch_act.handle} = 29.4
      SET #{htg_sch_act.handle} = 15.6
    ELSE
      SET #{clg_sch_act.handle} = NULL
      SET #{htg_sch_act.handle} = NULL
    ENDIF
    EMS
    optstart_prg.setBody(optstart_prg_body)

    # Program Calling Managers
    setup_mgr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(air_loop_hvac.model)
    setup_mgr.setName("#{loop_name_clean}OptimumStartCallingManager#{i}")
    setup_mgr.setCallingPoint('BeginTimestepBeforePredictor')
    setup_mgr.addProgram(optstart_prg)
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Optimum start control enabled.")

  return true
end

#air_loop_hvac_enable_supply_air_temperature_reset_delta(air_loop_hvac) ⇒ Double

Determines supply air temperature (SAT) temperature. Defaults to 90.1-2007, 5 delta-F ®

Returns:

  • (Double)

    the SAT reset amount ®



2215
2216
2217
2218
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2215

def air_loop_hvac_enable_supply_air_temperature_reset_delta(air_loop_hvac)
  sat_reset_r = 5
  return sat_reset_r
end

#air_loop_hvac_enable_supply_air_temperature_reset_outdoor_temperature(air_loop_hvac) ⇒ Bool

Enable supply air temperature (SAT) reset based on outdoor air conditions. SAT will be kept at the current design temperature when outdoor air is above 70F, increased by 5F when outdoor air is below 50F, and reset linearly when outdoor air is between 50F and 70F.

Returns:

  • (Bool)

    Returns true if successful, false if not.



2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2227

def air_loop_hvac_enable_supply_air_temperature_reset_outdoor_temperature(air_loop_hvac)
  # for AHU1 in Outpatient, SAT is 52F constant, no reset
  return true if air_loop_hvac.name.get == 'PVAV Outpatient F1'

  # Get the current setpoint and calculate
  # the new setpoint.
  sizing_system = air_loop_hvac.sizingSystem
  sat_at_hi_oat_c = sizing_system.centralCoolingDesignSupplyAirTemperature
  sat_at_hi_oat_f = OpenStudio.convert(sat_at_hi_oat_c, 'C', 'F').get
  # 5F increase when it's cold outside,
  # and therefore less cooling capacity is likely required.
  increase_f = air_loop_hvac_enable_supply_air_temperature_reset_delta(air_loop_hvac)
  sat_at_lo_oat_f = sat_at_hi_oat_f + increase_f
  sat_at_lo_oat_c = OpenStudio.convert(sat_at_lo_oat_f, 'F', 'C').get

  # Define the high and low outdoor air temperatures
  lo_oat_f = 50
  lo_oat_c = OpenStudio.convert(lo_oat_f, 'F', 'C').get
  hi_oat_f = 70
  hi_oat_c = OpenStudio.convert(hi_oat_f, 'F', 'C').get

  # Create a setpoint manager
  sat_oa_reset = OpenStudio::Model::SetpointManagerOutdoorAirReset.new(air_loop_hvac.model)
  sat_oa_reset.setName("#{air_loop_hvac.name} SAT Reset")
  sat_oa_reset.setControlVariable('Temperature')
  sat_oa_reset.setSetpointatOutdoorLowTemperature(sat_at_lo_oat_c)
  sat_oa_reset.setOutdoorLowTemperature(lo_oat_c)
  sat_oa_reset.setSetpointatOutdoorHighTemperature(sat_at_hi_oat_c)
  sat_oa_reset.setOutdoorHighTemperature(hi_oat_c)

  # Attach the setpoint manager to the
  # supply outlet node of the system.
  sat_oa_reset.addToNode(air_loop_hvac.supplyOutletNode)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Supply air temperature reset was enabled.  When OAT is greater than #{hi_oat_f.round}F, SAT is #{sat_at_hi_oat_f.round}F.  When OAT is less than #{lo_oat_f.round}F, SAT is #{sat_at_lo_oat_f.round}F.  It varies linearly in between these points.")

  return true
end

#air_loop_hvac_enable_supply_air_temperature_reset_warmest_zone(air_loop_hvac) ⇒ Bool

Enable supply air temperature (SAT) reset based on the cooling demand of the warmest zone.

Returns:

  • (Bool)

    Returns true if successful, false if not.



2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2181

def air_loop_hvac_enable_supply_air_temperature_reset_warmest_zone(air_loop_hvac)
  # Get the current setpoint and calculate
  # the new setpoint.
  sizing_system = air_loop_hvac.sizingSystem
  design_sat_c = sizing_system.centralCoolingDesignSupplyAirTemperature
  design_sat_f = OpenStudio.convert(design_sat_c, 'C', 'F').get

  # Get the SAT reset delta
  sat_reset_r = air_loop_hvac_enable_supply_air_temperature_reset_delta(air_loop_hvac)
  sat_reset_k = OpenStudio.convert(sat_reset_r, 'R', 'K').get

  max_sat_f = design_sat_f + sat_reset_r
  max_sat_c = design_sat_c + sat_reset_k

  # Create a setpoint manager
  sat_warmest_reset = OpenStudio::Model::SetpointManagerWarmest.new(air_loop_hvac.model)
  sat_warmest_reset.setName("#{air_loop_hvac.name} SAT Warmest Reset")
  sat_warmest_reset.setStrategy('MaximumTemperature')
  sat_warmest_reset.setMinimumSetpointTemperature(design_sat_c)
  sat_warmest_reset.setMaximumSetpointTemperature(max_sat_c)

  # Attach the setpoint manager to the
  # supply outlet node of the system.
  sat_warmest_reset.addToNode(air_loop_hvac.supplyOutletNode)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Supply air temperature reset was enabled using a SPM Warmest with a min SAT of #{design_sat_f.round}F and a max SAT of #{max_sat_f.round}F.")

  return true
end

#air_loop_hvac_enable_unoccupied_fan_shutoff(air_loop_hvac, min_occ_pct = 0.05) ⇒ Bool

Shut off the system during unoccupied periods. During these times, systems will cycle on briefly if temperature drifts below setpoint. For systems with fan-powered terminals, the whole system (not just the terminal fans) will cycle on. Terminal-only night cycling is not used because the terminals cannot provide cooling, so terminal-only night cycling leads to excessive unmet cooling hours during unoccupied periods. If the system already has a schedule other than Always-On, no change will be made. If the system has an Always-On schedule assigned, a new schedule will be created. In this case, occupied is defined as the total percent occupancy for the loop for all zones served.

the system will be considered unoccupied.

Parameters:

  • min_occ_pct (Double) (defaults to: 0.05)

    the fractional value below which

Returns:

  • (Bool)

    true if successful, false if not



3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3057

def air_loop_hvac_enable_unoccupied_fan_shutoff(air_loop_hvac, min_occ_pct = 0.05)
  # Set the system to night cycle
  air_loop_hvac.setNightCycleControlType('CycleOnAny')

  # Check if already using a schedule other than always on
  avail_sch = air_loop_hvac.availabilitySchedule
  unless avail_sch == air_loop_hvac.model.alwaysOnDiscreteSchedule
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Availability schedule is already set to #{avail_sch.name}.  Will assume this includes unoccupied shut down; no changes will be made.")
    return true
  end

  # Get the airloop occupancy schedule
  loop_occ_sch = air_loop_hvac_get_occupancy_schedule(air_loop_hvac, occupied_percentage_threshold: min_occ_pct)
  flh = schedule_ruleset_annual_equivalent_full_load_hrs(loop_occ_sch)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Annual occupied hours = #{flh.round} hr/yr, assuming a #{min_occ_pct} occupancy threshold.  This schedule will be used as the HVAC operation schedule.")

  # Set HVAC availability schedule to follow occupancy
  air_loop_hvac.setAvailabilitySchedule(loop_occ_sch)
  air_loop_hvac.supplyComponents.each do |comp|
    if comp.to_AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.is_initialized
      comp.to_AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.get.setSupplyAirFanOperatingModeSchedule(loop_occ_sch)
    elsif comp.to_AirLoopHVACUnitarySystem.is_initialized
      comp.to_AirLoopHVACUnitarySystem.get.setSupplyAirFanOperatingModeSchedule(loop_occ_sch)
    end
  end

  return true
end

#air_loop_hvac_energy_recovery?(air_loop_hvac) ⇒ Bool

Determine if the system has energy recovery already

Returns:

  • (Bool)

    Returns true if an ERV is present, false if not.



2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2358

def air_loop_hvac_energy_recovery?(air_loop_hvac)
  has_erv = false

  # Get the OA system
  oa_sys = air_loop_hvac.airLoopHVACOutdoorAirSystem
  if oa_sys.is_initialized
    oa_sys = oa_sys.get
  else
    return has_erv # No OA system
  end

  # Find any ERV on the OA system
  oa_sys.oaComponents.each do |oa_comp|
    if oa_comp.to_HeatExchangerAirToAirSensibleAndLatent.is_initialized
      has_erv = true
    end
  end

  return has_erv
end

#air_loop_hvac_energy_recovery_ventilator_flow_limit(air_loop_hvac, climate_zone, pct_oa) ⇒ Double

Determine the airflow limits that govern whether or not an ERV is required. Based on climate zone and % OA. Defaults to DOE Ref Pre-1980, not required. if nil, ERV is never required.

Returns:

  • (Double)

    the flow rate above which an ERV is required.



1549
1550
1551
1552
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1549

def air_loop_hvac_energy_recovery_ventilator_flow_limit(air_loop_hvac, climate_zone, pct_oa)
  erv_cfm = nil # Not required
  return erv_cfm
end

#air_loop_hvac_energy_recovery_ventilator_heat_exchanger_type(air_loop_hvac) ⇒ String

Determine whether to use a Plate-Frame or Rotary Wheel style ERV depending on air loop outdoor air flow rate Defaults to Rotary.

Returns:



1565
1566
1567
1568
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1565

def air_loop_hvac_energy_recovery_ventilator_heat_exchanger_type(air_loop_hvac)
  heat_exchanger_type = 'Rotary'
  return heat_exchanger_type
end

#air_loop_hvac_energy_recovery_ventilator_required?(air_loop_hvac, climate_zone) ⇒ Bool

TODO:

Add exception logic for systems serving parking garage, warehouse, or multifamily

Check if ERV is required on this airloop.

Returns:

  • (Bool)

    Returns true if required, false if not.



1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1447

def air_loop_hvac_energy_recovery_ventilator_required?(air_loop_hvac, climate_zone)
  # ERV Not Applicable for AHUs that serve
  # parking garage, warehouse, or multifamily
  # if space_types_served_names.include?('PNNL_Asset_Rating_Apartment_Space_Type') ||
  # space_types_served_names.include?('PNNL_Asset_Rating_LowRiseApartment_Space_Type') ||
  # space_types_served_names.include?('PNNL_Asset_Rating_ParkingGarage_Space_Type') ||
  # space_types_served_names.include?('PNNL_Asset_Rating_Warehouse_Space_Type')
  # OpenStudio::logFree(OpenStudio::Info, "openstudio.standards.AirLoopHVAC", "For #{self.name}, ERV not applicable because it because it serves parking garage, warehouse, or multifamily.")
  # return false
  # end

  erv_required = nil
  # ERV not applicable for medical AHUs (AHU1 in Outpatient), per AIA 2001 - 7.31.D2.
  # TODO refactor: move building type specific code
  if air_loop_hvac.name.to_s.include? 'Outpatient F1'
    erv_required = false
    return erv_required
  end

  # ERV not applicable for medical AHUs, per AIA 2001 - 7.31.D2.
  if air_loop_hvac.name.to_s.include? 'VAV_ER'
    erv_required = false
    return erv_required
  elsif air_loop_hvac.name.to_s.include? 'VAV_OR'
    erv_required = false
    return erv_required
  end
  case template
  when '90.1-2004', '90.1-2007' # TODO: Refactor figure out how to remove this.
    if air_loop_hvac.name.to_s.include? 'VAV_ICU'
      erv_required = false
      return erv_required
    elsif air_loop_hvac.name.to_s.include? 'VAV_PATRMS'
      erv_required = false
      return erv_required
    end
  end

  # ERV Not Applicable for AHUs that have DCV or that have no OA intake.
  if air_loop_hvac.airLoopHVACOutdoorAirSystem.is_initialized
    oa_system = air_loop_hvac.airLoopHVACOutdoorAirSystem.get
    controller_oa = oa_system.getControllerOutdoorAir
    controller_mv = controller_oa.controllerMechanicalVentilation
    if controller_mv.demandControlledVentilation == true
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}, ERV not applicable because DCV enabled.")
      return false
    end
  else
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}, ERV not applicable because it has no OA intake.")
    return false
  end

  # Get the AHU design supply air flow rate
  dsn_flow_m3_per_s = nil
  if air_loop_hvac.designSupplyAirFlowRate.is_initialized
    dsn_flow_m3_per_s = air_loop_hvac.designSupplyAirFlowRate.get
  elsif air_loop_hvac.autosizedDesignSupplyAirFlowRate.is_initialized
    dsn_flow_m3_per_s = air_loop_hvac.autosizedDesignSupplyAirFlowRate.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name} design supply air flow rate is not available, cannot apply efficiency standard.")
    return false
  end
  dsn_flow_cfm = OpenStudio.convert(dsn_flow_m3_per_s, 'm^3/s', 'cfm').get

  # Get the minimum OA flow rate
  min_oa_flow_m3_per_s = nil
  if controller_oa.minimumOutdoorAirFlowRate.is_initialized
    min_oa_flow_m3_per_s = controller_oa.minimumOutdoorAirFlowRate.get
  elsif controller_oa.autosizedMinimumOutdoorAirFlowRate.is_initialized
    min_oa_flow_m3_per_s = controller_oa.autosizedMinimumOutdoorAirFlowRate.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{controller_oa.name}: minimum OA flow rate is not available, cannot apply efficiency standard.")
    return false
  end
  min_oa_flow_cfm = OpenStudio.convert(min_oa_flow_m3_per_s, 'm^3/s', 'cfm').get

  # Calculate the percent OA at design airflow
  pct_oa = min_oa_flow_m3_per_s / dsn_flow_m3_per_s

  # Determine the airflow limit
  erv_cfm = air_loop_hvac_energy_recovery_ventilator_flow_limit(air_loop_hvac, climate_zone, pct_oa)

  # Determine if an ERV is required
  if erv_cfm.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}, ERV not required based on #{(pct_oa * 100).round}% OA flow, design supply air flow of #{dsn_flow_cfm.round}cfm, and climate zone #{climate_zone}.")
    erv_required = false
  elsif dsn_flow_cfm < erv_cfm
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}, ERV not required based on #{(pct_oa * 100).round}% OA flow, design supply air flow of #{dsn_flow_cfm.round}cfm, and climate zone #{climate_zone}. Does not exceed minimum flow requirement of #{erv_cfm}cfm.")
    erv_required = false
  else
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}, ERV required based on #{(pct_oa * 100).round}% OA flow, design supply air flow of #{dsn_flow_cfm.round}cfm, and climate zone #{climate_zone}. Exceeds minimum flow requirement of #{erv_cfm}cfm.")
    erv_required = true
  end

  return erv_required
end

#air_loop_hvac_energy_recovery_ventilator_type(air_loop_hvac, climate_zone) ⇒ String

Determine whether to apply an Energy Recovery Ventilator ‘ERV’ or a Heat Recovery Ventilator ‘HRV’ depending on the climate zone Defaults to ERV.

Returns:



1557
1558
1559
1560
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1557

def air_loop_hvac_energy_recovery_ventilator_type(air_loop_hvac, climate_zone)
  erv_type = 'ERV'
  return erv_type
end

#air_loop_hvac_fan_power_limitation_pressure_drop_adjustment_brake_horsepower(air_loop_hvac) ⇒ Double

TODO:

Determine the presence of MERV filters and other stuff in Table 6.5.3.1.1B. May need to extend AirLoopHVAC data model

Determine the fan power limitation pressure drop adjustment Per Table 6.5.3.1.1B

Returns:

  • (Double)

    fan power limitation pressure drop adjustment units = horsepower



381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 381

def air_loop_hvac_fan_power_limitation_pressure_drop_adjustment_brake_horsepower(air_loop_hvac)
  # Get design supply air flow rate (whether autosized or hard-sized)
  dsn_air_flow_m3_per_s = 0
  dsn_air_flow_cfm = 0
  if air_loop_hvac.autosizedDesignSupplyAirFlowRate.is_initialized
    dsn_air_flow_m3_per_s = air_loop_hvac.autosizedDesignSupplyAirFlowRate.get
    dsn_air_flow_cfm = OpenStudio.convert(dsn_air_flow_m3_per_s, 'm^3/s', 'cfm').get
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "* #{dsn_air_flow_cfm.round} cfm = Autosized Design Supply Air Flow Rate.")
  else
    dsn_air_flow_m3_per_s = air_loop_hvac.designSupplyAirFlowRate.get
    dsn_air_flow_cfm = OpenStudio.convert(dsn_air_flow_m3_per_s, 'm^3/s', 'cfm').get
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "* #{dsn_air_flow_cfm.round} cfm = Hard sized Design Supply Air Flow Rate.")
  end

  # TODO: determine the presence of MERV filters and other stuff
  # in Table 6.5.3.1.1B
  # perhaps need to extend AirLoopHVAC data model
  has_fully_ducted_return_and_or_exhaust_air_systems = false
  has_MERV_9_through_12 = false
  has_MERV_13_through_15 = false

  # Calculate Fan Power Limitation Pressure Drop Adjustment (in wc)
  fan_pwr_adjustment_in_wc = 0

  # Fully ducted return and/or exhaust air systems
  if has_fully_ducted_return_and_or_exhaust_air_systems
    adj_in_wc = 0.5
    fan_pwr_adjustment_in_wc += adj_in_wc
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "--Added #{adj_in_wc} in wc for Fully ducted return and/or exhaust air systems")
  end

  # MERV 9 through 12
  if has_MERV_9_through_12
    adj_in_wc = 0.5
    fan_pwr_adjustment_in_wc += adj_in_wc
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "--Added #{adj_in_wc} in wc for Particulate Filtration Credit: MERV 9 through 12")
  end

  # MERV 13 through 15
  if has_MERV_13_through_15
    adj_in_wc = 0.9
    fan_pwr_adjustment_in_wc += adj_in_wc
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "--Added #{adj_in_wc} in wc for Particulate Filtration Credit: MERV 13 through 15")
  end

  # Convert the pressure drop adjustment to brake horsepower (bhp)
  # assuming that all supply air passes through all devices
  fan_pwr_adjustment_bhp = fan_pwr_adjustment_in_wc * dsn_air_flow_cfm / 4131
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Fan Power Limitation Pressure Drop Adjustment = #{fan_pwr_adjustment_bhp.round(2)} bhp")

  return fan_pwr_adjustment_bhp
end

#air_loop_hvac_find_design_supply_air_flow_rate(air_loop_hvac) ⇒ Double

find design_supply_air_flow_rate

Returns:

  • (Double)

    design_supply_air_flow_rate m^3/s



3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3140

def air_loop_hvac_find_design_supply_air_flow_rate(air_loop_hvac)
  # Get the design_supply_air_flow_rate
  design_supply_air_flow_rate = nil
  if air_loop_hvac.designSupplyAirFlowRate.is_initialized
    design_supply_air_flow_rate = air_loop_hvac.designSupplyAirFlowRate.get
  elsif air_loop_hvac.autosizedDesignSupplyAirFlowRate.is_initialized
    design_supply_air_flow_rate = air_loop_hvac.autosizedDesignSupplyAirFlowRate.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name} design supply air flow rate is not available.")
  end

  return design_supply_air_flow_rate
end

#air_loop_hvac_floor_area_served(air_loop_hvac) ⇒ Object

Calculate the total floor area of all zones attached to the air loop, in m^2.

return [Double] the total floor area of all zones attached to the air loop, in m^2.



3091
3092
3093
3094
3095
3096
3097
3098
3099
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3091

def air_loop_hvac_floor_area_served(air_loop_hvac)
  total_area = 0.0

  air_loop_hvac.thermalZones.each do |zone|
    total_area += zone.floorArea
  end

  return total_area
end

#air_loop_hvac_floor_area_served_exterior_zones(air_loop_hvac) ⇒ Object

Calculate the total floor area of all zones attached to the air loop that have at least one exterior surface, in m^2.

return [Double] the total floor area of all zones attached to the air loop, in m^2.



3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3124

def air_loop_hvac_floor_area_served_exterior_zones(air_loop_hvac)
  total_area = 0.0

  air_loop_hvac.thermalZones.each do |zone|
    # Skip zones that have no exterior surface area
    next if zone.exteriorSurfaceArea.zero?

    total_area += zone.floorArea
  end

  return total_area
end

#air_loop_hvac_floor_area_served_interior_zones(air_loop_hvac) ⇒ Object

Calculate the total floor area of all zones attached to the air loop that have no exterior surfaces, in m^2.

return [Double] the total floor area of all zones attached to the air loop, in m^2.



3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3106

def air_loop_hvac_floor_area_served_interior_zones(air_loop_hvac)
  total_area = 0.0

  air_loop_hvac.thermalZones.each do |zone|
    # Skip zones that have exterior surface area
    next if zone.exteriorSurfaceArea > 0

    total_area += zone.floorArea
  end

  return total_area
end

#air_loop_hvac_get_occupancy_schedule(air_loop_hvac, occupied_percentage_threshold: 0.05) ⇒ ScheduleRuleset

This method creates a new discrete fractional schedule ruleset. The value is set to one when occupancy across all zones is greater than or equal to the occupied_percentage_threshold, and zero all other times. This method is designed to use the total number of people on the airloop, so if there is a zone that is continuously occupied by a few people, but other zones that are intermittently occupied by many people, the first zone doesn’t drive the entire system.

Parameters:

  • air_loop_hvac (<OpenStudio::Model::AirLoopHVAC>)

    air loop to create occupancy schedule

  • occupied_percentage_threshold (Double) (defaults to: 0.05)

    the minimum fraction (0 to 1) that counts as occupied

Returns:

  • (ScheduleRuleset)

    a ScheduleRuleset where 0 = unoccupied, 1 = occupied



2618
2619
2620
2621
2622
2623
2624
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2618

def air_loop_hvac_get_occupancy_schedule(air_loop_hvac, occupied_percentage_threshold: 0.05)
  # Create combined occupancy schedule of every space in every zone served by this airloop
  sch_ruleset = thermal_zones_get_occupancy_schedule(air_loop_hvac.thermalZones,
                                                     sch_name: "#{air_loop_hvac.name} Occ Sch",
                                                     occupied_percentage_threshold: occupied_percentage_threshold)
  return sch_ruleset
end

#air_loop_hvac_humidifier_count(air_loop_hvac) ⇒ Integer

Determine how many humidifies are on the airloop

Returns:

  • (Integer)

    the number of humidifiers



3220
3221
3222
3223
3224
3225
3226
3227
3228
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3220

def air_loop_hvac_humidifier_count(air_loop_hvac)
  humidifiers = 0
  air_loop_hvac.supplyComponents.each do |cmp|
    if cmp.to_HumidifierSteamElectric.is_initialized
      humidifiers += 1
    end
  end
  return humidifiers
end

#air_loop_hvac_include_hydronic_cooling_coil?(air_loop_hvac) ⇒ Bool

Determine if the airloop includes hydronic cooling coils

Returns:

  • (Bool)

    returns true if hydronic coolings coils are included on the airloop



1077
1078
1079
1080
1081
1082
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1077

def air_loop_hvac_include_hydronic_cooling_coil?(air_loop_hvac)
  air_loop_hvac.supplyComponents.each do |comp|
    return true if comp.to_CoilCoolingWater.is_initialized
  end
  return false
end

#air_loop_hvac_include_wshp?(air_loop_hvac) ⇒ Bool

Determine if the airloop includes WSHP cooling coils

Returns:

  • (Bool)

    returns true if WSHP cooling coils are included on the airloop



1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1087

def air_loop_hvac_include_wshp?(air_loop_hvac)
  air_loop_hvac.supplyComponents.each do |comp|
    return true if comp.to_CoilCoolingWaterToAirHeatPumpEquationFit.is_initialized

    if comp.to_AirLoopHVACUnitarySystem.is_initialized
      clg_coil = comp.to_AirLoopHVACUnitarySystem.get.coolingCoil.get
      return true if clg_coil.to_CoilCoolingWaterToAirHeatPumpEquationFit.is_initialized

    end
  end
  return false
end

#air_loop_hvac_integrated_economizer_required?(air_loop_hvac, climate_zone) ⇒ Boolean

Determine if the system economizer must be integrated or not. Default logic is from 90.1-2004.

Returns:

  • (Boolean)


1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1102

def air_loop_hvac_integrated_economizer_required?(air_loop_hvac, climate_zone)
  # Determine if it is a VAV system
  is_vav = air_loop_hvac_vav_system?(air_loop_hvac)

  # Determine the number of zones the system serves
  num_zones_served = air_loop_hvac.thermalZones.size

  minimum_capacity_btu_per_hr = 65_000
  minimum_capacity_w = OpenStudio.convert(minimum_capacity_btu_per_hr, 'Btu/hr', 'W').get
  # 6.5.1.3 Integrated Economizer Control
  # Exception a, DX VAV systems
  if is_vav == true && num_zones_served > 1
    integrated_economizer_required = false
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: non-integrated economizer per 6.5.1.3 exception a, DX VAV system.")
    # Exception b, DX units less than 65,000 Btu/hr
  elsif air_loop_hvac_total_cooling_capacity(air_loop_hvac) < minimum_capacity_w
    integrated_economizer_required = false
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: non-integrated economizer per 6.5.1.3 exception b, DX system less than #{minimum_capacity_btu_per_hr}Btu/hr.")
  else
    # Exception c, Systems in climate zones 1,2,3a,4a,5a,5b,6,7,8
    case climate_zone
    when 'ASHRAE 169-2006-0A',
         'ASHRAE 169-2006-0B',
         'ASHRAE 169-2006-1A',
         'ASHRAE 169-2006-1B',
         'ASHRAE 169-2006-2A',
         'ASHRAE 169-2006-2B',
         'ASHRAE 169-2006-3A',
         'ASHRAE 169-2006-4A',
         'ASHRAE 169-2006-5A',
         'ASHRAE 169-2006-5B',
         'ASHRAE 169-2006-6A',
         'ASHRAE 169-2006-6B',
         'ASHRAE 169-2006-7A',
         'ASHRAE 169-2006-7B',
         'ASHRAE 169-2006-8A',
         'ASHRAE 169-2006-8B',
         'ASHRAE 169-2013-0A',
         'ASHRAE 169-2013-0B',
         'ASHRAE 169-2013-1A',
         'ASHRAE 169-2013-1B',
         'ASHRAE 169-2013-2A',
         'ASHRAE 169-2013-2B',
         'ASHRAE 169-2013-3A',
         'ASHRAE 169-2013-4A',
         'ASHRAE 169-2013-5A',
         'ASHRAE 169-2013-5B',
         'ASHRAE 169-2013-6A',
         'ASHRAE 169-2013-6B',
         'ASHRAE 169-2013-7A',
         'ASHRAE 169-2013-7B',
         'ASHRAE 169-2013-8A',
         'ASHRAE 169-2013-8B'
      integrated_economizer_required = false
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: non-integrated economizer per 6.5.1.3 exception c, climate zone #{climate_zone}.")
    when 'ASHRAE 169-2006-3B',
         'ASHRAE 169-2006-3C',
         'ASHRAE 169-2006-4B',
         'ASHRAE 169-2006-4C',
         'ASHRAE 169-2006-5C',
         'ASHRAE 169-2013-3B',
         'ASHRAE 169-2013-3C',
         'ASHRAE 169-2013-4B',
         'ASHRAE 169-2013-4C',
         'ASHRAE 169-2013-5C'
      integrated_economizer_required = true
    end
  end

  return integrated_economizer_required
end

#air_loop_hvac_motorized_oa_damper_limits(air_loop_hvac, climate_zone) ⇒ Array<Double>

Determine the air flow and number of story limits for whether motorized OA damper is required. Defaults to DOE Ref Pre-1980 logic (never required). If both nil, never required

Returns:

  • (Array<Double>)

    [minimum_oa_flow_cfm, maximum_stories].



2527
2528
2529
2530
2531
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2527

def air_loop_hvac_motorized_oa_damper_limits(air_loop_hvac, climate_zone)
  minimum_oa_flow_cfm = nil
  maximum_stories = nil
  return [minimum_oa_flow_cfm, maximum_stories]
end

#air_loop_hvac_motorized_oa_damper_required?(air_loop_hvac, climate_zone) ⇒ Boolean

Determine if a motorized OA damper is required

Returns:

  • (Boolean)


2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2452

def air_loop_hvac_motorized_oa_damper_required?(air_loop_hvac, climate_zone)
  motorized_oa_damper_required = false

  # TODO: refactor: Remove building type dependent logic
  if air_loop_hvac.name.to_s.include? 'Outpatient F1'
    motorized_oa_damper_required = true
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: always has a damper, the minimum OA schedule is the same as airloop availability schedule.")
    return motorized_oa_damper_required
  end

  # If the system has an economizer, it must have a motorized damper.
  if air_loop_hvac_economizer?(air_loop_hvac)
    motorized_oa_damper_required = true
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Because the system has an economizer, it requires a motorized OA damper.")
    return motorized_oa_damper_required
  end

  # Determine the exceptions based on
  # number of stories, climate zone, and
  # outdoor air intake rates.
  minimum_oa_flow_cfm, maximum_stories = air_loop_hvac_motorized_oa_damper_limits(air_loop_hvac, climate_zone)

  # Assuming that buildings not requiring this always
  # used backdraft gravity dampers
  if minimum_oa_flow_cfm.nil? && maximum_stories.nil?
    return motorized_oa_damper_required
  end

  # Get the number of stories
  num_stories = air_loop_hvac.model.getBuildingStorys.size

  # Check the number of stories exception,
  # which is climate-zone dependent.
  if num_stories < maximum_stories
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Motorized OA damper not required because the building has #{num_stories} stories, less than the minimum of #{maximum_stories} stories for climate zone #{climate_zone}.")
    return motorized_oa_damper_required
  end

  # Get the min OA flow rate
  oa_flow_m3_per_s = 0
  if air_loop_hvac.airLoopHVACOutdoorAirSystem.is_initialized
    oa_system = air_loop_hvac.airLoopHVACOutdoorAirSystem.get
    controller_oa = oa_system.getControllerOutdoorAir
    if controller_oa.minimumOutdoorAirFlowRate.is_initialized
      oa_flow_m3_per_s = controller_oa.minimumOutdoorAirFlowRate.get
    elsif controller_oa.autosizedMinimumOutdoorAirFlowRate.is_initialized
      oa_flow_m3_per_s = controller_oa.autosizedMinimumOutdoorAirFlowRate.get
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Could not determine the minimum OA flow rate, cannot determine if a motorized OA damper is required.")
      return motorized_oa_damper_required
    end
  else
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}, Motorized OA damper not applicable because it has no OA intake.")
    return motorized_oa_damper_required
  end
  oa_flow_cfm = OpenStudio.convert(oa_flow_m3_per_s, 'm^3/s', 'cfm').get

  # Check the OA flow rate exception
  if oa_flow_cfm < minimum_oa_flow_cfm
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Motorized OA damper not required because the system OA intake of #{oa_flow_cfm.round} cfm is less than the minimum threshold of #{minimum_oa_flow_cfm} cfm.")
    return motorized_oa_damper_required
  end

  # If here, motorized damper is required
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Motorized OA damper is required because the building has #{num_stories} stories which is greater than or equal to the minimum of #{maximum_stories} stories for climate zone #{climate_zone}, and the system OA intake of #{oa_flow_cfm.round} cfm is greater than or equal to the minimum threshold of #{minimum_oa_flow_cfm} cfm. ")
  motorized_oa_damper_required = true

  return motorized_oa_damper_required
end

#air_loop_hvac_multi_stage_dx_cooling?(air_loop_hvac) ⇒ Bool

Determine if this Air Loop uses multi-stage DX cooling.

Returns:

  • (Bool)

    true if uses multi-stage DX cooling, false if not.



3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3378

def air_loop_hvac_multi_stage_dx_cooling?(air_loop_hvac)
  dx_clg = false

  # Check for all DX coil types
  dx_types = [
    'OS_Coil_Cooling_DX_MultiSpeed',
    'OS_Coil_Cooling_DX_TwoSpeed',
    'OS_Coil_Cooling_DX_TwoStageWithHumidityControlMode'
  ]

  air_loop_hvac.supplyComponents.each do |component|
    # Get the object type, getting the internal coil
    # type if inside a unitary system.
    obj_type = component.iddObjectType.valueName.to_s
    case obj_type
    when 'OS_AirLoopHVAC_UnitaryHeatCool_VAVChangeoverBypass'
      component = component.to_AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass.get
      obj_type = component.coolingCoil.iddObjectType.valueName.to_s
    when 'OS_AirLoopHVAC_UnitaryHeatPump_AirToAir'
      component = component.to_AirLoopHVACUnitaryHeatPumpAirToAir.get
      obj_type = component.coolingCoil.iddObjectType.valueName.to_s
    when 'OS_AirLoopHVAC_UnitaryHeatPump_AirToAir_MultiSpeed'
      component = component.to_AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.get
      obj_type = component.coolingCoil.iddObjectType.valueName.to_s
    when 'OS_AirLoopHVAC_UnitarySystem'
      component = component.to_AirLoopHVACUnitarySystem.get
      if component.coolingCoil.is_initialized
        obj_type = component.coolingCoil.get.iddObjectType.valueName.to_s
      end
    end
    # See if the object type is a DX coil
    if dx_types.include?(obj_type)
      dx_clg = true
      break # Stop if find a DX coil
    end
  end

  return dx_clg
end

#air_loop_hvac_multizone_vav_optimization_required?(air_loop_hvac, climate_zone) ⇒ Bool

TODO:

Add exception logic for systems with AIA healthcare ventilation requirements dual duct systems

Determine if multizone vav optimization is required. Defaults to 90.1-2007 logic, where it is not required.

Returns:

  • (Bool)

    Returns true if required, false if not.



1688
1689
1690
1691
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1688

def air_loop_hvac_multizone_vav_optimization_required?(air_loop_hvac, climate_zone)
  multizone_opt_required = false
  return multizone_opt_required
end

#air_loop_hvac_multizone_vav_system?(air_loop_hvac) ⇒ Bool

Determine if the system is a multizone VAV system

Returns:

  • (Bool)

    Returns true if required, false if not.



2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2316

def air_loop_hvac_multizone_vav_system?(air_loop_hvac)
  multizone_vav_system = false

  # Must serve more than 1 zone
  if air_loop_hvac.thermalZones.size < 2
    return multizone_vav_system
  end

  # Must be a variable volume system
  is_vav = air_loop_hvac_vav_system?(air_loop_hvac)
  if is_vav == false
    return multizone_vav_system
  end

  # If here, it's a multizone VAV system
  multizone_vav_system = true

  return multizone_vav_system
end

#air_loop_hvac_optimum_start_required?(air_loop_hvac) ⇒ Boolean

Determines if optimum start control is required. Defaults to 90.1-2004 logic, which requires optimum start if > 10,000 cfm

Returns:

  • (Boolean)


207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 207

def air_loop_hvac_optimum_start_required?(air_loop_hvac)
  opt_start_required = false

  # data centers don't require optimum start as generally not occupied
  return opt_start_required if air_loop_hvac.name.to_s.include?('CRAH') ||
                               air_loop_hvac.name.to_s.include?('CRAC')

  # Get design supply air flow rate (whether autosized or hard-sized)
  dsn_air_flow_m3_per_s = 0
  dsn_air_flow_cfm = 0
  if air_loop_hvac.autosizedDesignSupplyAirFlowRate.is_initialized
    dsn_air_flow_m3_per_s = air_loop_hvac.autosizedDesignSupplyAirFlowRate.get
    dsn_air_flow_cfm = OpenStudio.convert(dsn_air_flow_m3_per_s, 'm^3/s', 'cfm').get
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "* #{dsn_air_flow_cfm.round} cfm = Autosized Design Supply Air Flow Rate.")
  else
    dsn_air_flow_m3_per_s = air_loop_hvac.designSupplyAirFlowRate.get
    dsn_air_flow_cfm = OpenStudio.convert(dsn_air_flow_m3_per_s, 'm^3/s', 'cfm').get
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "* #{dsn_air_flow_cfm.round} cfm = Hard sized Design Supply Air Flow Rate.")
  end
  # Optimum start per 6.4.3.3.3, only required if > 10,000 cfm
  cfm_limit = 10_000
  if dsn_air_flow_cfm > cfm_limit
    opt_start_required = true
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Optimum start is required since design flow rate of #{dsn_air_flow_cfm.round} cfm exceeds the limit of #{cfm_limit} cfm.")
  else
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Optimum start is not required since design flow rate of #{dsn_air_flow_cfm.round} cfm is below the limit of #{cfm_limit} cfm.")
  end

  return opt_start_required
end

#air_loop_hvac_prm_baseline_economizer_required?(air_loop_hvac, climate_zone) ⇒ Bool

Determine if an economizer is required per the PRM. Default logic from 90.1-2007

Returns:

  • (Bool)

    returns true if required, false if not



1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1179

def air_loop_hvac_prm_baseline_economizer_required?(air_loop_hvac, climate_zone)
  economizer_required = false

  # A big number of ft2 as the minimum requirement
  infinity_ft2 = 999_999_999_999
  min_int_area_served_ft2 = infinity_ft2
  min_ext_area_served_ft2 = infinity_ft2

  # Determine the minimum capacity that requires an economizer
  case climate_zone
  when 'ASHRAE 169-2006-0A',
       'ASHRAE 169-2006-0B',
       'ASHRAE 169-2006-1A',
       'ASHRAE 169-2006-1B',
       'ASHRAE 169-2006-2A',
       'ASHRAE 169-2006-3A',
       'ASHRAE 169-2006-4A',
       'ASHRAE 169-2013-0A',
       'ASHRAE 169-2013-0B',
       'ASHRAE 169-2013-1A',
       'ASHRAE 169-2013-1B',
       'ASHRAE 169-2013-2A',
       'ASHRAE 169-2013-3A',
       'ASHRAE 169-2013-4A'
    min_int_area_served_ft2 = infinity_ft2 # No requirement
    min_ext_area_served_ft2 = infinity_ft2 # No requirement
  else
    min_int_area_served_ft2 = 0 # Always required
    min_ext_area_served_ft2 = 0 # Always required
  end

  # Check whether the system requires an economizer by comparing
  # the system capacity to the minimum capacity.
  min_int_area_served_m2 = OpenStudio.convert(min_int_area_served_ft2, 'ft^2', 'm^2').get
  min_ext_area_served_m2 = OpenStudio.convert(min_ext_area_served_ft2, 'ft^2', 'm^2').get

  # Get the interior and exterior area served
  int_area_served_m2 = air_loop_hvac_floor_area_served_interior_zones(air_loop_hvac)
  ext_area_served_m2 = air_loop_hvac_floor_area_served_exterior_zones(air_loop_hvac)

  # Check the floor area exception
  if int_area_served_m2 < min_int_area_served_m2 && ext_area_served_m2 < min_ext_area_served_m2
    if min_int_area_served_ft2 == infinity_ft2 && min_ext_area_served_ft2 == infinity_ft2
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Economizer not required for climate zone #{climate_zone}.")
    else
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Economizer not required for because the interior area served of #{int_area_served_m2} ft2 is less than the minimum of #{min_int_area_served_m2} and the perimeter area served of #{ext_area_served_m2} ft2 is less than the minimum of #{min_ext_area_served_m2} for climate zone #{climate_zone}.")
    end
    return economizer_required
  end

  # If here, economizer required
  economizer_required = true
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Economizer required for the performance rating method baseline.")

  return economizer_required
end

#air_loop_hvac_prm_economizer_type_and_limits(air_loop_hvac, climate_zone) ⇒ Array<Double>

Determine the economizer type and limits for the the PRM Defaults to 90.1-2007 logic.

Returns:

  • (Array<Double>)
    economizer_type, drybulb_limit_f, enthalpy_limit_btu_per_lb, dewpoint_limit_f


1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1302

def air_loop_hvac_prm_economizer_type_and_limits(air_loop_hvac, climate_zone)
  economizer_type = 'NoEconomizer'
  drybulb_limit_f = nil
  enthalpy_limit_btu_per_lb = nil
  dewpoint_limit_f = nil

  case climate_zone
  when 'ASHRAE 169-2006-0B',
       'ASHRAE 169-2006-1B',
       'ASHRAE 169-2006-2B',
       'ASHRAE 169-2006-3B',
       'ASHRAE 169-2006-3C',
       'ASHRAE 169-2006-4B',
       'ASHRAE 169-2006-4C',
       'ASHRAE 169-2006-5B',
       'ASHRAE 169-2006-5C',
       'ASHRAE 169-2006-6B',
       'ASHRAE 169-2006-7B',
       'ASHRAE 169-2006-8A',
       'ASHRAE 169-2006-8B',
       'ASHRAE 169-2013-0B',
       'ASHRAE 169-2013-1B',
       'ASHRAE 169-2013-2B',
       'ASHRAE 169-2013-3B',
       'ASHRAE 169-2013-3C',
       'ASHRAE 169-2013-4B',
       'ASHRAE 169-2013-4C',
       'ASHRAE 169-2013-5B',
       'ASHRAE 169-2013-5C',
       'ASHRAE 169-2013-6B',
       'ASHRAE 169-2013-7B',
       'ASHRAE 169-2013-8A',
       'ASHRAE 169-2013-8B'
    economizer_type = 'FixedDryBulb'
    drybulb_limit_f = 75
  when 'ASHRAE 169-2006-5A',
       'ASHRAE 169-2006-6A',
       'ASHRAE 169-2006-7A',
       'ASHRAE 169-2013-5A',
       'ASHRAE 169-2013-6A',
       'ASHRAE 169-2013-7A'
    economizer_type = 'FixedDryBulb'
    drybulb_limit_f = 70
  else
    economizer_type = 'FixedDryBulb'
    drybulb_limit_f = 65
  end

  return [economizer_type, drybulb_limit_f, enthalpy_limit_btu_per_lb, dewpoint_limit_f]
end

#air_loop_hvac_remove_motorized_oa_damper(air_loop_hvac) ⇒ Object

Remove a motorized OA damper by modifying the OA schedule to require full OA at all times. Whenever the fan operates, the damper will be open and OA will be brought into the building. This reflects the use of a backdraft gravity damper, and increases building loads unnecessarily during unoccupied hours.



2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2591

def air_loop_hvac_remove_motorized_oa_damper(air_loop_hvac)
  # Get the OA system and OA controller
  oa_sys = air_loop_hvac.airLoopHVACOutdoorAirSystem
  if oa_sys.is_initialized
    oa_sys = oa_sys.get
  else
    return false # No OA system
  end
  oa_control = oa_sys.getControllerOutdoorAir

  # Set the minimum OA schedule to always 1 (100%)
  oa_control.setMinimumOutdoorAirSchedule(air_loop_hvac.model.alwaysOnDiscreteSchedule)

  return true
end

#air_loop_hvac_residential_area_served(air_loop_hvac) ⇒ Object

Determine how much residential area the airloop serves



3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3157

def air_loop_hvac_residential_area_served(air_loop_hvac)
  res_area = 0.0

  air_loop_hvac.thermalZones.each do |zone|
    zone.spaces.each do |space|
      # Skip spaces with no space type
      next if space.spaceType.empty?

      space_type = space.spaceType.get

      # Skip spaces with no standards space type
      next if space_type.standardsSpaceType.empty?

      standards_space_type = space_type.standardsSpaceType.get
      if standards_space_type.downcase.include?('apartment') || standards_space_type.downcase.include?('guestroom') || standards_space_type.downcase.include?('patroom')
        res_area += space.floorArea
      end
    end
  end

  return res_area
end

#air_loop_hvac_set_minimum_damper_position(zone, mdp) ⇒ Object

Set an air terminal’s minimum damper position



1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1972

def air_loop_hvac_set_minimum_damper_position(zone, mdp)
  zone.equipment.each do |equip|
    if equip.to_AirTerminalSingleDuctVAVHeatAndCoolNoReheat.is_initialized
      term = equip.to_AirTerminalSingleDuctVAVHeatAndCoolNoReheat.get
      term.setZoneMinimumAirFlowFraction(mdp)
    elsif equip.to_AirTerminalSingleDuctVAVHeatAndCoolReheat.is_initialized
      term = equip.to_AirTerminalSingleDuctVAVHeatAndCoolReheat.get
      term.setZoneMinimumAirFlowFraction(mdp)
    elsif equip.to_AirTerminalSingleDuctVAVNoReheat.is_initialized
      term = equip.to_AirTerminalSingleDuctVAVNoReheat.get
      term.setConstantMinimumAirFlowFraction(mdp)
    elsif equip.to_AirTerminalSingleDuctVAVReheat.is_initialized
      term = equip.to_AirTerminalSingleDuctVAVReheat.get
      term.setConstantMinimumAirFlowFraction(mdp)
    end
  end

  return true
end

#air_loop_hvac_single_zone_controls_num_stages(air_loop_hvac, climate_zone) ⇒ Integer

Determine the number of stages that should be used as controls for single zone DX systems. Defaults to zero, which means that no special single zone control is required.

Returns:

  • (Integer)

    the number of stages: 0, 1, 2



2991
2992
2993
2994
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2991

def air_loop_hvac_single_zone_controls_num_stages(air_loop_hvac, climate_zone)
  num_stages = 0
  return num_stages
end

#air_loop_hvac_static_pressure_reset_required?(air_loop_hvac, has_ddc) ⇒ Boolean

TODO:

Instead of requiring the input of whether a system has DDC control of VAV terminals or not, determine this from the system itself. This may require additional information be added to the OpenStudio data model.

Determine if static pressure reset is required for this system. For 90.1, this determination needs information about whether or not the system has DDC control over the VAV terminals. Defaults to 90.1-2007 logic.

over VAV terminals. return [Bool] returns true if static pressure reset is required, false if not

Parameters:

  • has_ddc (Bool)

    whether or not the system has DDC control

Returns:

  • (Boolean)


3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3008

def air_loop_hvac_static_pressure_reset_required?(air_loop_hvac, has_ddc)
  sp_reset_required = false

  if has_ddc
    sp_reset_required = true
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Static pressure reset is required because the system has DDC control of VAV terminals.")
  else
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Static pressure reset not required because the system does not have DDC control of VAV terminals.")
  end

  return sp_reset_required
end

#air_loop_hvac_supply_air_temperature_reset_required?(air_loop_hvac, climate_zone) ⇒ Bool

Determine if the system required supply air temperature (SAT) reset. Defaults to 90.1-2007, no SAT reset required.

Returns:

  • (Bool)

    Returns true if required, false if not.



2172
2173
2174
2175
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2172

def air_loop_hvac_supply_air_temperature_reset_required?(air_loop_hvac, climate_zone)
  is_sat_reset_required = false
  return is_sat_reset_required
end

#air_loop_hvac_supply_return_exhaust_relief_fans(air_loop_hvac) ⇒ Array

Get all of the supply, return, exhaust, and relief fans on this system

Returns:

  • (Array)

    an array of FanConstantVolume, FanVariableVolume, and FanOnOff objects



536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 536

def air_loop_hvac_supply_return_exhaust_relief_fans(air_loop_hvac)
  # Fans on the supply side of the airloop directly, or inside of unitary equipment.
  fans = []
  sup_and_oa_comps = air_loop_hvac.supplyComponents
  sup_and_oa_comps += air_loop_hvac.oaComponents
  sup_and_oa_comps.each do |comp|
    if comp.to_FanConstantVolume.is_initialized
      fans << comp.to_FanConstantVolume.get
    elsif comp.to_FanVariableVolume.is_initialized
      fans << comp.to_FanVariableVolume.get
    elsif comp.to_AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass.is_initialized
      sup_fan = comp.to_AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass.get.supplyAirFan
      if sup_fan.to_FanConstantVolume.is_initialized
        fans << sup_fan.to_FanConstantVolume.get
      elsif sup_fan.to_FanOnOff.is_initialized
        fans << sup_fan.to_FanOnOff.get
      end
    elsif comp.to_AirLoopHVACUnitarySystem.is_initialized
      sup_fan = comp.to_AirLoopHVACUnitarySystem.get.supplyFan
      next if sup_fan.empty?

      sup_fan = sup_fan.get
      if sup_fan.to_FanConstantVolume.is_initialized
        fans << sup_fan.to_FanConstantVolume.get
      elsif sup_fan.to_FanOnOff.is_initialized
        fans << sup_fan.to_FanOnOff.get
      elsif sup_fan.to_FanVariableVolume.is_initialized
        fans << sup_fan.to_FanVariableVolume.get
      end
    end
  end

  return fans
end

#air_loop_hvac_system_fan_brake_horsepower(air_loop_hvac, include_terminal_fans = true) ⇒ Double

Determine the total brake horsepower of the fans on the system with or without the fans inside of fan powered terminals.

Parameters:

  • include_terminal_fans (Bool) (defaults to: true)

    if true, power from fan powered terminals will be included

Returns:

  • (Double)

    total brake horsepower of the fans on the system units = horsepower



577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 577

def air_loop_hvac_system_fan_brake_horsepower(air_loop_hvac, include_terminal_fans = true)
  # TODO: get the template from the parent model itself?
  # Or not because maybe you want to see the difference between two standards?
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "#{air_loop_hvac.name}-Determining #{template} allowable system fan power.")

  # Get all fans
  fans = []
  # Supply, exhaust, relief, and return fans
  fans += air_loop_hvac_supply_return_exhaust_relief_fans(air_loop_hvac)

  # Fans inside of fan-powered terminals
  if include_terminal_fans
    air_loop_hvac.demandComponents.each do |comp|
      if comp.to_AirTerminalSingleDuctSeriesPIUReheat.is_initialized
        term_fan = comp.to_AirTerminalSingleDuctSeriesPIUReheat.get.supplyAirFan
        if term_fan.to_FanConstantVolume.is_initialized
          fans << term_fan.to_FanConstantVolume.get
        end
      elsif comp.to_AirTerminalSingleDuctParallelPIUReheat.is_initialized
        term_fan = comp.to_AirTerminalSingleDuctParallelPIUReheat.get.fan
        if term_fan.to_FanConstantVolume.is_initialized
          fans << term_fan.to_FanConstantVolume.get
        end
      end
    end
  end

  # Loop through all fans on the system and
  # sum up their brake horsepower values.
  sys_fan_bhp = 0
  fans.sort.each do |fan|
    sys_fan_bhp += fan_brake_horsepower(fan)
  end

  return sys_fan_bhp
end

#air_loop_hvac_system_multiplier(air_loop_hvac) ⇒ Integer

Determine if every zone on the system has an identical multiplier. If so, return this number. If not, return 1.

Returns:

  • (Integer)

    an integer representing the system multiplier.



3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3308

def air_loop_hvac_system_multiplier(air_loop_hvac)
  mult = 1

  # Get all the zone multipliers
  zn_mults = []
  air_loop_hvac.thermalZones.each do |zone|
    zn_mults << zone.multiplier
  end

  # Warn if there are different multipliers
  uniq_mults = zn_mults.uniq
  if uniq_mults.size > 1
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: not all zones on the system have an identical zone multiplier.  Multipliers are: #{uniq_mults.join(', ')}.")
  else
    mult = uniq_mults[0]
  end

  return mult
end

#air_loop_hvac_terminal_reheat?(air_loop_hvac) ⇒ Bool

Determine if the system has terminal reheat

Returns:

  • (Bool)

    returns true if has one or more reheat terminals, false if it doesn’t.



2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2339

def air_loop_hvac_terminal_reheat?(air_loop_hvac)
  has_term_rht = false
  air_loop_hvac.demandComponents.each do |sc|
    if sc.to_AirTerminalSingleDuctConstantVolumeReheat.is_initialized ||
       sc.to_AirTerminalSingleDuctParallelPIUReheat.is_initialized ||
       sc.to_AirTerminalSingleDuctSeriesPIUReheat.is_initialized ||
       sc.to_AirTerminalSingleDuctVAVHeatAndCoolReheat.is_initialized ||
       sc.to_AirTerminalSingleDuctVAVReheat.is_initialized
      has_term_rht = true
      break
    end
  end

  return has_term_rht
end

#air_loop_hvac_total_cooling_capacity(air_loop_hvac) ⇒ Double

TODO:

Change to pull water coil nominal capacity instead of design load; not a huge difference, but water coil nominal capacity not available in sizing table.

TODO:

Handle all additional cooling coil types. Currently only handles CoilCoolingDXSingleSpeed, CoilCoolingDXTwoSpeed, and CoilCoolingWater

Get the total cooling capacity for the air loop

Returns:

  • (Double)

    total cooling capacity units = Watts (W)



704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 704

def air_loop_hvac_total_cooling_capacity(air_loop_hvac)
  # Sum the cooling capacity for all cooling components
  # on the airloop, which may be inside of unitary systems.
  total_cooling_capacity_w = 0
  air_loop_hvac.supplyComponents.each do |sc|
    # CoilCoolingDXSingleSpeed
    if sc.to_CoilCoolingDXSingleSpeed.is_initialized
      coil = sc.to_CoilCoolingDXSingleSpeed.get
      if coil.ratedTotalCoolingCapacity.is_initialized
        total_cooling_capacity_w += coil.ratedTotalCoolingCapacity.get
      elsif coil.autosizedRatedTotalCoolingCapacity.is_initialized
        total_cooling_capacity_w += coil.autosizedRatedTotalCoolingCapacity.get
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name} capacity of #{coil.name} is not available, total cooling capacity of air loop will be incorrect when applying standard.")
      end
      # CoilCoolingDXTwoSpeed
    elsif sc.to_CoilCoolingDXTwoSpeed.is_initialized
      coil = sc.to_CoilCoolingDXTwoSpeed.get
      if coil.ratedHighSpeedTotalCoolingCapacity.is_initialized
        total_cooling_capacity_w += coil.ratedHighSpeedTotalCoolingCapacity.get
      elsif coil.autosizedRatedHighSpeedTotalCoolingCapacity.is_initialized
        total_cooling_capacity_w += coil.autosizedRatedHighSpeedTotalCoolingCapacity.get
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name} capacity of #{coil.name} is not available, total cooling capacity of air loop will be incorrect when applying standard.")
      end
      # CoilCoolingWater
    elsif sc.to_CoilCoolingWater.is_initialized
      coil = sc.to_CoilCoolingWater.get
      if coil.autosizedDesignCoilLoad.is_initialized # TODO: Change to pull water coil nominal capacity instead of design load
        total_cooling_capacity_w += coil.autosizedDesignCoilLoad.get
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name} capacity of #{coil.name} is not available, total cooling capacity of air loop will be incorrect when applying standard.")
      end
      # CoilCoolingWaterToAirHeatPumpEquationFit
    elsif sc.to_CoilCoolingWaterToAirHeatPumpEquationFit.is_initialized
      coil = sc.to_CoilCoolingWaterToAirHeatPumpEquationFit.get
      if coil.ratedTotalCoolingCapacity.is_initialized
        total_cooling_capacity_w += coil.ratedTotalCoolingCapacity.get
      elsif coil.autosizedRatedTotalCoolingCapacity.is_initialized
        total_cooling_capacity_w += coil.autosizedRatedTotalCoolingCapacity.get
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name} capacity of #{coil.name} is not available, total cooling capacity of air loop will be incorrect when applying standard.")
      end
    elsif sc.to_AirLoopHVACUnitarySystem.is_initialized
      unitary = sc.to_AirLoopHVACUnitarySystem.get
      if unitary.coolingCoil.is_initialized
        clg_coil = unitary.coolingCoil.get
        # CoilCoolingDXSingleSpeed
        if clg_coil.to_CoilCoolingDXSingleSpeed.is_initialized
          coil = clg_coil.to_CoilCoolingDXSingleSpeed.get
          if coil.ratedTotalCoolingCapacity.is_initialized
            total_cooling_capacity_w += coil.ratedTotalCoolingCapacity.get
          elsif coil.autosizedRatedTotalCoolingCapacity.is_initialized
            total_cooling_capacity_w += coil.autosizedRatedTotalCoolingCapacity.get
          else
            OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name} capacity of #{coil.name} is not available, total cooling capacity of air loop will be incorrect when applying standard.")
          end
        # CoilCoolingDXTwoSpeed
        elsif clg_coil.to_CoilCoolingDXTwoSpeed.is_initialized
          coil = clg_coil.to_CoilCoolingDXTwoSpeed.get
          if coil.ratedHighSpeedTotalCoolingCapacity.is_initialized
            total_cooling_capacity_w += coil.ratedHighSpeedTotalCoolingCapacity.get
          elsif coil.autosizedRatedHighSpeedTotalCoolingCapacity.is_initialized
            total_cooling_capacity_w += coil.autosizedRatedHighSpeedTotalCoolingCapacity.get
          else
            OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name} capacity of #{coil.name} is not available, total cooling capacity of air loop will be incorrect when applying standard.")
          end
        # CoilCoolingWater
        elsif clg_coil.to_CoilCoolingWater.is_initialized
          coil = clg_coil.to_CoilCoolingWater.get
          if coil.autosizedDesignCoilLoad.is_initialized # TODO: Change to pull water coil nominal capacity instead of design load
            total_cooling_capacity_w += coil.autosizedDesignCoilLoad.get
          else
            OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name} capacity of #{coil.name} is not available, total cooling capacity of air loop will be incorrect when applying standard.")
          end
        # CoilCoolingWaterToAirHeatPumpEquationFit
        elsif clg_coil.to_CoilCoolingWaterToAirHeatPumpEquationFit.is_initialized
          coil = clg_coil.to_CoilCoolingWaterToAirHeatPumpEquationFit.get
          if coil.ratedTotalCoolingCapacity.is_initialized
            total_cooling_capacity_w += coil.ratedTotalCoolingCapacity.get
          elsif coil.autosizedRatedTotalCoolingCapacity.is_initialized
            total_cooling_capacity_w += coil.autosizedRatedTotalCoolingCapacity.get
          else
            OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name} capacity of #{coil.name} is not available, total cooling capacity of air loop will be incorrect when applying standard.")
          end
        end
      end
    elsif sc.to_AirLoopHVACUnitaryHeatPumpAirToAir.is_initialized
      unitary = sc.to_AirLoopHVACUnitaryHeatPumpAirToAir.get
      clg_coil = unitary.coolingCoil
      # CoilCoolingDXSingleSpeed
      if clg_coil.to_CoilCoolingDXSingleSpeed.is_initialized
        coil = clg_coil.to_CoilCoolingDXSingleSpeed.get
        if coil.ratedTotalCoolingCapacity.is_initialized
          total_cooling_capacity_w += coil.ratedTotalCoolingCapacity.get
        elsif coil.autosizedRatedTotalCoolingCapacity.is_initialized
          total_cooling_capacity_w += coil.autosizedRatedTotalCoolingCapacity.get
        else
          OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name} capacity of #{coil.name} is not available, total cooling capacity of air loop will be incorrect when applying standard.")
        end
      # CoilCoolingDXTwoSpeed
      elsif clg_coil.to_CoilCoolingDXTwoSpeed.is_initialized
        coil = clg_coil.to_CoilCoolingDXTwoSpeed.get
        if coil.ratedHighSpeedTotalCoolingCapacity.is_initialized
          total_cooling_capacity_w += coil.ratedHighSpeedTotalCoolingCapacity.get
        elsif coil.autosizedRatedHighSpeedTotalCoolingCapacity.is_initialized
          total_cooling_capacity_w += coil.autosizedRatedHighSpeedTotalCoolingCapacity.get
        else
          OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name} capacity of #{coil.name} is not available, total cooling capacity of air loop will be incorrect when applying standard.")
        end
      # CoilCoolingWater
      elsif clg_coil.to_CoilCoolingWater.is_initialized
        coil = clg_coil.to_CoilCoolingWater.get
        if coil.autosizedDesignCoilLoad.is_initialized # TODO: Change to pull water coil nominal capacity instead of design load
          total_cooling_capacity_w += coil.autosizedDesignCoilLoad.get
        else
          OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name} capacity of #{coil.name} is not available, total cooling capacity of air loop will be incorrect when applying standard.")
        end
      end
    elsif sc.to_AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.is_initialized
      unitary = sc.to_AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.get
      clg_coil = unitary.coolingCoil
      # CoilCoolingDXMultSpeed
      if clg_coil.to_CoilCoolingDXMultiSpeed.is_initialized
        coil = clg_coil.to_CoilCoolingDXMultiSpeed.get
        total_cooling_capacity_w = coil_cooling_dx_multi_speed_find_capacity(coil)
      end
    elsif sc.to_CoilCoolingDXMultiSpeed.is_initialized ||
          sc.to_CoilCoolingCooledBeam.is_initialized ||
          sc.to_AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass.is_initialized ||
          sc.to_AirLoopHVACUnitarySystem.is_initialized
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "#{air_loop_hvac.name} has a cooling coil named #{sc.name}, whose type is not yet covered by economizer checks.")
      # CoilCoolingDXMultiSpeed
      # CoilCoolingCooledBeam
      # CoilCoolingWaterToAirHeatPumpEquationFit
      # AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass
      # AirLoopHVACUnitaryHeatPumpAirToAir
      # AirLoopHVACUnitarySystem
    end
  end

  return total_cooling_capacity_w
end

#air_loop_hvac_unitary_system?(air_loop_hvac) ⇒ Bool

Determine if the air loop is a unitary system

Returns:

  • (Bool)

    Returns true if a unitary system is present, false if not.



2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2382

def air_loop_hvac_unitary_system?(air_loop_hvac)
  is_unitary_system = false
  air_loop_hvac.supplyComponents.each do |component|
    obj_type = component.iddObjectType.valueName.to_s
    case obj_type
    when 'OS_AirLoopHVAC_UnitarySystem', 'OS_AirLoopHVAC_UnitaryHeatPump_AirToAir', 'OS_AirLoopHVAC_UnitaryHeatPump_AirToAir_MultiSpeed', 'OS_AirLoopHVAC_UnitaryHeatCool_VAVChangeoverBypass'
      is_unitary_system = true
    end
  end
  return is_unitary_system
end

#air_loop_hvac_unoccupied_fan_shutoff_required?(air_loop_hvac) ⇒ Bool

Determine if a system’s fans must shut off when not required. Per ASHRAE 90.1 section 6.4.3.3, HVAC systems are required to have off-hour controls

Returns:

  • (Bool)

    true if required, false if not



3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3024

def air_loop_hvac_unoccupied_fan_shutoff_required?(air_loop_hvac)
  shutoff_required = true

  # Determine if the airloop serves any computer rooms or data centers, which default to always on.
  if air_loop_hvac_data_center_area_served(air_loop_hvac) > 0
    shutoff_required = false
  end

  return shutoff_required
end

#air_loop_hvac_unoccupied_thresholdObject

Default occupancy fraction threshold for determining if the spaces on the air loop are occupied



3036
3037
3038
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3036

def air_loop_hvac_unoccupied_threshold
  return 0.15
end

#air_loop_hvac_vav_damper_action(air_loop_hvac) ⇒ String

Determine whether the VAV damper control is single maximum or dual maximum control. Defaults to 90.1-2007.

Returns:

  • (String)

    the damper control type: Single Maximum, Dual Maximum



2446
2447
2448
2449
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2446

def air_loop_hvac_vav_damper_action(air_loop_hvac)
  damper_action = 'Dual Maximum'
  return damper_action
end

#air_loop_hvac_vav_system?(air_loop_hvac) ⇒ Boolean

Determine if the system is a VAV system based on the fan which may be inside of a unitary system.

Returns:

  • (Boolean)


2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2290

def air_loop_hvac_vav_system?(air_loop_hvac)
  is_vav = false
  air_loop_hvac.supplyComponents.reverse.each do |comp|
    if comp.to_FanVariableVolume.is_initialized
      is_vav = true
    elsif comp.to_AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass.is_initialized
      fan = comp.to_AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass.get.supplyAirFan
      if fan.to_FanVariableVolume.is_initialized
        is_vav = true
      end
    elsif comp.to_AirLoopHVACUnitarySystem.is_initialized
      fan = comp.to_AirLoopHVACUnitarySystem.get.supplyFan
      if fan.is_initialized
        if fan.get.to_FanVariableVolume.is_initialized
          is_vav = true
        end
      end
    end
  end

  return is_vav
end

#air_terminal_single_duct_parallel_piu_reheat_apply_prm_baseline_fan_power(air_terminal_single_duct_parallel_piu_reheat) ⇒ Bool

Sets the fan power of a PIU fan based on the W/cfm specified in the standard.

Returns:

  • (Bool)

    returns true if successful, false if not



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/openstudio-standards/standards/Standards.AirTerminalSingleDuctParallelPIUReheat.rb', line 8

def air_terminal_single_duct_parallel_piu_reheat_apply_prm_baseline_fan_power(air_terminal_single_duct_parallel_piu_reheat)
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirTerminalSingleDuctParallelPIUReheat', "Setting PIU fan power for #{air_terminal_single_duct_parallel_piu_reheat.name}.")

  # Determine the fan sizing flow rate, min flow rate,
  # and W/cfm
  sec_flow_frac = 0.5
  min_flow_frac = 0.3
  fan_efficacy_w_per_cfm = 0.35

  # Convert efficacy to metric
  # 1 cfm = 0.0004719 m^3/s
  fan_efficacy_w_per_m3_per_s = fan_efficacy_w_per_cfm / 0.0004719

  # Get the maximum flow rate through the terminal
  max_primary_air_flow_rate = nil
  if air_terminal_single_duct_parallel_piu_reheat.autosizedMaximumPrimaryAirFlowRate.is_initialized
    max_primary_air_flow_rate = air_terminal_single_duct_parallel_piu_reheat.autosizedMaximumPrimaryAirFlowRate.get
  elsif air_terminal_single_duct_parallel_piu_reheat.maximumPrimaryAirFlowRate.is_initialized
    max_primary_air_flow_rate = air_terminal_single_duct_parallel_piu_reheat.maximumPrimaryAirFlowRate.get
  end

  # Set the max secondary air flow rate
  max_sec_flow_rate_m3_per_s = max_primary_air_flow_rate * sec_flow_frac
  air_terminal_single_duct_parallel_piu_reheat.setMaximumSecondaryAirFlowRate(max_sec_flow_rate_m3_per_s)
  max_sec_flow_rate_cfm = OpenStudio.convert(max_sec_flow_rate_m3_per_s, 'm^3/s', 'ft^3/min').get

  # Set the minimum flow fraction
  # TODO Also compare to min OA requirement
  air_terminal_single_duct_parallel_piu_reheat.setMinimumPrimaryAirFlowFraction(min_flow_frac)

  # Get the fan
  fan = air_terminal_single_duct_parallel_piu_reheat.fan.to_FanConstantVolume.get

  # Set the impeller efficiency
  fan_change_impeller_efficiency(fan, fan_baseline_impeller_efficiency(fan))

  # Set the motor efficiency, preserving the impeller efficency.
  # For terminal fans, a bhp lookup of 0.5bhp is always used because
  # they are assumed to represent a series of small fans in reality.
  fan_apply_standard_minimum_motor_efficiency(fan, fan_brake_horsepower(fan))

  # Calculate a new pressure rise to hit the target W/cfm
  fan_tot_eff = fan.fanEfficiency
  fan_rise_new_pa = fan_efficacy_w_per_m3_per_s * fan_tot_eff
  fan.setPressureRise(fan_rise_new_pa)

  # Calculate the newly set efficacy
  fan_power_new_w = fan_rise_new_pa * max_sec_flow_rate_m3_per_s / fan_tot_eff
  fan_efficacy_new_w_per_cfm = fan_power_new_w / max_sec_flow_rate_cfm
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirTerminalSingleDuctParallelPIUReheat', "For #{air_terminal_single_duct_parallel_piu_reheat.name}: fan efficacy set to #{fan_efficacy_new_w_per_cfm.round(2)} W/cfm.")

  return true
end

#air_terminal_single_duct_vav_reheat_apply_initial_prototype_damper_position(air_terminal_single_duct_vav_reheat, zone_oa_per_area) ⇒ Bool

Set the initial minimum damper position based on OA rate of the space and the template. Defaults to basic behavior, but this method is overridden by all of the ASHRAE-based templates. Zones with low OA per area get lower initial guesses. Final position will be adjusted upward as necessary by Standards.AirLoopHVAC.apply_minimum_vav_damper_positions

Parameters:

  • zone_oa_per_area (Double)

    the zone outdoor air per area, m^3/s

Returns:

  • (Bool)

    returns true if successful, false if not



10
11
12
13
14
15
16
17
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.AirTerminalSingleDuctVAVReheat.rb', line 10

def air_terminal_single_duct_vav_reheat_apply_initial_prototype_damper_position(air_terminal_single_duct_vav_reheat, zone_oa_per_area)
  min_damper_position = 0.3

  # Set the minimum flow fraction
  air_terminal_single_duct_vav_reheat.setConstantMinimumAirFlowFraction(min_damper_position)

  return true
end

#air_terminal_single_duct_vav_reheat_apply_minimum_damper_position(air_terminal_single_duct_vav_reheat, zone_min_oa = nil, has_ddc = true) ⇒ Bool

TODO:

remove exception where older vintages don’t have minimum positions adjusted.

Set the minimum damper position based on OA rate of the space and the template. Zones with low OA per area get lower initial guesses. Final position will be adjusted upward as necessary by Standards.AirLoopHVAC.adjust_minimum_vav_damper_positions If supplied, this will be set as a minimum limit in addition to the minimum damper position. EnergyPlus will use the larger of the two values during sizing. which impacts the minimum damper position requirement.

Parameters:

  • zone_min_oa (Double) (defaults to: nil)

    the zone outdoor air flow rate, in m^3/s.

  • has_ddc (Bool) (defaults to: true)

    whether or not there is DDC control of the VAV terminal,

Returns:

  • (Bool)

    returns true if successful, false if not



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/openstudio-standards/standards/Standards.AirTerminalSingleDuctVAVReheat.rb', line 16

def air_terminal_single_duct_vav_reheat_apply_minimum_damper_position(air_terminal_single_duct_vav_reheat, zone_min_oa = nil, has_ddc = true)
  # Minimum damper position
  min_damper_position = air_terminal_single_duct_vav_reheat_minimum_damper_position(air_terminal_single_duct_vav_reheat, has_ddc)
  air_terminal_single_duct_vav_reheat.setConstantMinimumAirFlowFraction(min_damper_position)
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirTerminalSingleDuctVAVReheat', "For #{air_terminal_single_duct_vav_reheat.name}: set minimum damper position to #{min_damper_position}.")

  # Minimum OA flow rate
  # If specified, will also add this limit
  # and the larger of the two will be used
  # for sizing.
  unless zone_min_oa.nil?
    air_terminal_single_duct_vav_reheat.setFixedMinimumAirFlowRate(zone_min_oa)
  end

  return true
end

#air_terminal_single_duct_vav_reheat_minimum_damper_position(air_terminal_single_duct_vav_reheat, has_ddc = false) ⇒ Object

Specifies the minimum damper position for VAV dampers. Defaults to 30%

Parameters:

  • has_ddc (Bool) (defaults to: false)

    whether or not there is DDC control of the VAV terminal in question



37
38
39
40
# File 'lib/openstudio-standards/standards/Standards.AirTerminalSingleDuctVAVReheat.rb', line 37

def air_terminal_single_duct_vav_reheat_minimum_damper_position(air_terminal_single_duct_vav_reheat, has_ddc = false)
  min_damper_position = 0.3
  return min_damper_position
end

#air_terminal_single_duct_vav_reheat_reheat_type(air_terminal_single_duct_vav_reheat) ⇒ String

Determines whether the terminal has a NaturalGas, Electricity, or HotWater reheat coil. Electricity, or HotWater.

Returns:

  • (String)

    reheat type. One of NaturalGas,



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/openstudio-standards/standards/Standards.AirTerminalSingleDuctVAVReheat.rb', line 64

def air_terminal_single_duct_vav_reheat_reheat_type(air_terminal_single_duct_vav_reheat)
  type = nil

  if air_terminal_single_duct_vav_reheat.to_AirTerminalSingleDuctVAVNoReheat.is_initialized
    return nil
  end

  # Get the reheat coil
  rht_coil = air_terminal_single_duct_vav_reheat.reheatCoil
  if rht_coil.to_CoilHeatingElectric.is_initialized
    type = 'Electricity'
  elsif rht_coil.to_CoilHeatingWater.is_initialized
    type = 'HotWater'
  elsif rht_coil.to_CoilHeatingGas.is_initialized
    type = 'NaturalGas'
  end

  return type
end

#air_terminal_single_duct_vav_reheat_set_heating_cap(air_terminal_single_duct_vav_reheat) ⇒ Object

Sets the capacity of the reheat coil based on the minimum flow fraction, and the maximum flow rate.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/openstudio-standards/standards/Standards.AirTerminalSingleDuctVAVReheat.rb', line 44

def air_terminal_single_duct_vav_reheat_set_heating_cap(air_terminal_single_duct_vav_reheat)
  flow_rate_fraction = 0.0
  if air_terminal_single_duct_vav_reheat.constantMinimumAirFlowFraction.is_initialized
    flow_rate_fraction = air_terminal_single_duct_vav_reheat.constantMinimumAirFlowFraction.get
  end
  if air_terminal_single_duct_vav_reheat.reheatCoil.to_CoilHeatingWater.is_initialized
    reheat_coil = air_terminal_single_duct_vav_reheat.reheatCoil.to_CoilHeatingWater.get
    if reheat_coil.autosizedRatedCapacity.to_f < 1.0e-6
      cap = 1.2 * 1000.0 * flow_rate_fraction * air_terminal_single_duct_vav_reheat.autosizedMaximumAirFlowRate.to_f * (18.0 - 13.0)
      reheat_coil.setPerformanceInputMethod('NominalCapacity')
      reheat_coil.setRatedCapacity(cap)
      air_terminal_single_duct_vav_reheat.setMaximumReheatAirTemperature(18.0)
    end
  end
end

#apply_changes_to_surface_construction(model, surface, conductance = nil, shgc = nil, tvis = nil, is_percentage = false) ⇒ Object



535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 535

def apply_changes_to_surface_construction(model, surface, conductance = nil, shgc = nil, tvis = nil, is_percentage = false)
  # If user has no changes...do nothing and return true.
  return true if conductance.nil? && shgc.nil? && tvis.nil?

  standard = Standard.new
  construction = OpenStudio::Model.getConstructionByName(surface.model, surface.construction.get.name.to_s).get

  # set initial targets
  target_u_value_si = conductance
  target_shgc = shgc
  target_tvis = tvis
  # Mulitply by percentages if required.
  if is_percentage
    target_u_value_si = target_u_value_si / 100.0 * BTAP::Resources::Envelope::Constructions.get_conductance(construction) unless conductance.nil?
    if standard.construction_simple_glazing?(construction)
      target_shgc = target_shgc / 100.0 * construction.layers.first.to_SimpleGlazing.get.solarHeatGainCoefficient unless target_shgc.nil?
      target_tvis = target_tvis / 100.0 * construction.layers.first.to_SimpleGlazing.get.setVisibleTransmittance unless target_tvis.nil?
    end
  end

  new_construction_name_suffix = ':{'
  new_construction_name_suffix << " \"cond\"=>#{target_u_value_si.round(3)}" unless target_u_value_si.nil?
  new_construction_name_suffix << " \"shgc\"=>#{target_shgc.round(3)}" unless target_shgc.nil?
  new_construction_name_suffix << " \"tvis\"=>#{target_tvis.round(3)}" unless target_tvis.nil?
  new_construction_name_suffix << '}'

  new_construction_name = "#{surface.construction.get.name}-#{new_construction_name_suffix}"
  new_construction = OpenStudio::Model.getConstructionByName(surface.model, new_construction_name)

  if new_construction.empty?
    # create new construction.
    # create a copy
    target_u_value_ip = OpenStudio.convert(target_u_value_si.to_f, 'W/m^2*K', 'Btu/ft^2*hr*R').get unless target_u_value_si.nil?
    new_construction = construction_deep_copy(model, construction)
    case surface.outsideBoundaryCondition
      when 'Outdoors'
        if standard.construction_simple_glazing?(new_construction)
          unless conductance.nil?
            standard.construction_set_glazing_u_value(new_construction,
                                                      target_u_value_ip.to_f,
                                                      nil,
                                                      false,
                                                      false)
          end
          unless shgc.nil?
            standard.construction_set_glazing_shgc(new_construction,
                                                   shgc)
          end
          unless tvis.nil?
            construction_set_glazing_tvis(new_construction,
                                          tvis)
          end

        else
          unless conductance.nil?
            standard.construction_set_u_value(new_construction,
                                              target_u_value_ip.to_f,
                                              find_and_set_insulation_layer(
                                                new_construction
                                              ).name.get,
                                              intended_surface_type = nil,
                                              false,
                                              false)
          end
        end
      when 'Ground'
        case surface.surfaceType
          when 'Wall'
            unless conductance.nil?
              standard.construction_set_u_value(new_construction,
                                                target_u_value_ip.to_f,
                                                find_and_set_insulation_layer(
                                                  new_construction
                                                ).name.get,
                                                intended_surface_type = nil,
                                                false,
                                                false)
            end
          #               standard.construction_set_underground_wall_c_factor(new_construction,
          #                                                                   target_u_value_ip.to_f,
          #                                                                   find_and_set_insulaton_layer(model,
          #                                                                   new_construction).name.get)
          when 'RoofCeiling', 'Floor'
            unless conductance.nil?
              standard.construction_set_u_value(new_construction,
                                                target_u_value_ip.to_f,
                                                find_and_set_insulation_layer(new_construction).name.get,
                                                intended_surface_type = nil,
                                                false,
                                                false)
            end
          #               standard.construction_set_slab_f_factor(new_construction,
          #                                                       target_u_value_ip.to_f,
          #                                                       find_and_set_insulaton_layer(model,
          #                                                       new_construction).name.get)
        end
    end
    new_construction.setName(new_construction_name)
  else
    new_construction = new_construction.get
  end
  surface.setConstruction(new_construction)
end

#apply_lighting_schedule(space_type, space_type_properties, default_sch_set) ⇒ Object



554
555
556
557
558
559
560
# File 'lib/openstudio-standards/standards/Standards.SpaceType.rb', line 554

def apply_lighting_schedule(space_type, space_type_properties, default_sch_set)
  lighting_sch = space_type_properties['lighting_schedule']
  unless lighting_sch.nil?
    default_sch_set.setLightingSchedule(model_add_schedule(space_type.model, lighting_sch))
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set lighting schedule to #{lighting_sch}.")
  end
end

#apply_limit_to_subsurface_ratio(model, ratio, surface_type = 'Wall') ⇒ Object

This method will limit the subsurface of a given surface_type (“Wall” or “RoofCeiling”) to the ratio for the building. This method only reduces subsurface sizes at most.



4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4460

def apply_limit_to_subsurface_ratio(model, ratio, surface_type = 'Wall')
  fdwr = get_outdoor_subsurface_ratio(model, surface_type)
  if fdwr <= ratio
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Building FDWR of #{fdwr} is already lower than limit of #{ratio.round}%.")
    return true
  end
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Reducing the size of all windows (by shrinking to centroid) to reduce window area down to the limit of #{ratio.round}%.")
  # Determine the factors by which to reduce the window / door area
  mult = ratio / fdwr
  # Reduce the window area if any of the categories necessary
  model.getSpaces.sort.each do |space|
    # Loop through all surfaces in this space
    space.surfaces.sort.each do |surface|
      # Skip non-outdoor surfaces
      next unless surface.outsideBoundaryCondition == 'Outdoors'
      # Skip non-walls
      next unless surface.surfaceType == surface_type

      # Subsurfaces in this surface
      surface.subSurfaces.sort.each do |ss|
        # Reduce the size of the window
        red = 1.0 - mult
        sub_surface_reduce_area_by_percent_by_shrinking_toward_centroid(ss, red)
      end
    end
  end
  return true
end

#apply_max_fdwr(model, runner, sillHeight_si, wwr) ⇒ Object

This method will apply the a FDWR to a model. It will remove any existing windows and doors and use the Default contruction to set to apply the window construction. Sill height is in meters



4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4410

def apply_max_fdwr(model, runner, sillHeight_si, wwr)
  empty_const_warning = false
  model.getSpaces.sort.each do |space|
    space.surfaces.sort.each do |surface|
      zone = surface.space.get.thermalZone
      zone_multiplier = nil
      next if zone.empty?

      if (surface.outsideBoundaryCondition == 'Outdoors') && (surface.surfaceType == 'Wall')
        surface.subSurfaces.each(&:remove)
        new_window = surface.setWindowToWallRatio(wwr, sillHeight_si, true)
        raise "#{surface.name.get} did not get set to #{wwr}. The size of the surface is #{surface.grossArea}" unless surface.windowToWallRatio.round(3) == wwr.round(3)

        if new_window.empty?
          runner.registerWarning("The requested window to wall ratio for surface '#{surface.name}' was too large. Fenestration was not altered for this surface.")
        else
          windows_added = true
          # warn user if resulting window doesn't have a construction, as it will result in failed simulation. In the future may use logic from starting windows to apply construction to new window.
          if new_window.get.construction.empty? && (empty_const_warning == false)
            runner.registerWarning('one or more resulting windows do not have constructions. This script is intended to be used with models using construction sets versus hard assigned constructions.')
            empty_const_warning = true
          end
        end
      end
    end
  end
end

#apply_max_srr(model, runner, srr, skylight_area = 0.25 * 0.25) ⇒ Object

This method will apply the a SRR to a model. It will remove any existing skylights and use the Default contruction to set to apply the skylight construction. A default skylight square area of 0.25^2 is used.



4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4440

def apply_max_srr(model, runner, srr, skylight_area = 0.25 * 0.25)
  spaces = []
  surface_type = 'RoofCeiling'
  model.getSpaces.sort.each do |space|
    space.surfaces.sort.each do |surface|
      if (surface.outsideBoundaryCondition == 'Outdoors') && (surface.surfaceType == surface_type)
        spaces << space
        break
      end
    end
  end
  pattern = OpenStudio::Model.generateSkylightPattern(spaces, spaces[0].directionofRelativeNorth, srr, Math.sqrt(skylight_area), Math.sqrt(skylight_area)) # ratio, x value, y value
  # applying skylight pattern
  skylights = OpenStudio::Model.applySkylightPattern(pattern, spaces, OpenStudio::Model::OptionalConstructionBase.new)
  spacenames = spaces.map { |space| space.name.get }
  runner.registerInfo("Adding #{skylights.size} skylights to #{spacenames}")
end

#boiler_hot_water_apply_efficiency_and_curves(boiler_hot_water) ⇒ Bool

Applies the standard efficiency ratings and typical performance curves to this object.

Parameters:

Returns:

  • (Bool)

    true if successful, false if not



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/openstudio-standards/standards/Standards.BoilerHotWater.rb', line 113

def boiler_hot_water_apply_efficiency_and_curves(boiler_hot_water)
  successfully_set_all_properties = false

  # Define the criteria to find the boiler properties
  # in the hvac standards data set.
  search_criteria = boiler_hot_water_find_search_criteria(boiler_hot_water)
  fuel_type = search_criteria['fuel_type']
  fluid_type = search_criteria['fluid_type']

  # Get the capacity
  capacity_w = boiler_hot_water_find_capacity(boiler_hot_water)

  # Convert capacity to Btu/hr
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get
  capacity_kbtu_per_hr = OpenStudio.convert(capacity_w, 'W', 'kBtu/hr').get

  # Get the boiler properties
  blr_props = model_find_object(standards_data['boilers'], search_criteria, capacity_btu_per_hr)
  unless blr_props
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.BoilerHotWater', "For #{boiler_hot_water.name}, cannot find boiler properties with search criteria #{search_criteria}, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end

  # Make the EFFFPLR curve (not all boilers will have one)
  if blr_props['efffplr']
    eff_fplr = model_add_curve(boiler_hot_water.model, blr_props['efffplr'])
    if eff_fplr
      boiler_hot_water.setNormalizedBoilerEfficiencyCurve(eff_fplr)
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.BoilerHotWater', "For #{boiler_hot_water.name}, cannot find eff_fplr curve, will not be set.")
      successfully_set_all_properties = false
    end
  end

  # Get the minimum efficiency standards
  thermal_eff = nil

  # If specified as AFUE
  unless blr_props['minimum_annual_fuel_utilization_efficiency'].nil?
    min_afue = blr_props['minimum_annual_fuel_utilization_efficiency']
    thermal_eff = afue_to_thermal_eff(min_afue)
    new_comp_name = "#{boiler_hot_water.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_afue} AFUE"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.BoilerHotWater', "For #{template}: #{boiler_hot_water.name}: #{fuel_type} #{fluid_type} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; AFUE = #{min_afue}")
  end

  # If specified as thermal efficiency
  unless blr_props['minimum_thermal_efficiency'].nil?
    thermal_eff = blr_props['minimum_thermal_efficiency']
    new_comp_name = "#{boiler_hot_water.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{thermal_eff} Thermal Eff"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.BoilerHotWater', "For #{template}: #{boiler_hot_water.name}: #{fuel_type} #{fluid_type} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; Thermal Efficiency = #{thermal_eff}")
  end

  # If specified as combustion efficiency
  unless blr_props['minimum_combustion_efficiency'].nil?
    min_comb_eff = blr_props['minimum_combustion_efficiency']
    thermal_eff = combustion_eff_to_thermal_eff(min_comb_eff)
    new_comp_name = "#{boiler_hot_water.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_comb_eff} Combustion Eff"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.BoilerHotWater', "For #{template}: #{boiler_hot_water.name}: #{fuel_type} #{fluid_type} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; Combustion Efficiency = #{min_comb_eff}")
  end

  # Set the name
  boiler_hot_water.setName(new_comp_name)

  # Set the efficiency values
  unless thermal_eff.nil?
    boiler_hot_water.setNominalThermalEfficiency(thermal_eff)
  end

  return successfully_set_all_properties
end

#boiler_hot_water_find_capacity(boiler_hot_water) ⇒ Double

Find capacity in W

Returns:

  • (Double)

    capacity in W



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/openstudio-standards/standards/Standards.BoilerHotWater.rb', line 39

def boiler_hot_water_find_capacity(boiler_hot_water)
  capacity_w = nil
  if boiler_hot_water.nominalCapacity.is_initialized
    capacity_w = boiler_hot_water.nominalCapacity.get
  elsif boiler_hot_water.autosizedNominalCapacity.is_initialized
    capacity_w = boiler_hot_water.autosizedNominalCapacity.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.BoilerHotWater', "For #{boiler_hot_water.name} capacity is not available, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end

  return capacity_w
end

#boiler_hot_water_find_search_criteria(boiler_hot_water) ⇒ Hash

find search criteria

Returns:

  • (Hash)

    used for standards_lookup_table(model)



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/openstudio-standards/standards/Standards.BoilerHotWater.rb', line 7

def boiler_hot_water_find_search_criteria(boiler_hot_water)
  # Define the criteria to find the boiler properties
  # in the hvac standards data set.
  search_criteria = {}
  search_criteria['template'] = template

  # Get fuel type
  fuel_type = nil
  case boiler_hot_water.fuelType
  when 'NaturalGas'
    fuel_type = 'Gas'
  when 'Electricity'
    fuel_type = 'Electric'
  when 'FuelOilNo1', 'FuelOilNo2'
    fuel_type = 'Oil'
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.BoilerHotWater', "For #{boiler_hot_water.name}, a fuel type of #{fuelType} is not yet supported.  Assuming 'Gas.'")
    fuel_type = 'Gas'
  end

  search_criteria['fuel_type'] = fuel_type

  # Get the fluid type
  fluid_type = 'Hot Water'
  search_criteria['fluid_type'] = fluid_type

  return search_criteria
end

#boiler_hot_water_standard_minimum_thermal_efficiency(boiler_hot_water, rename = false) ⇒ Double

Finds lookup object in standards and return minimum thermal efficiency

Returns:

  • (Double)

    minimum thermal efficiency



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/openstudio-standards/standards/Standards.BoilerHotWater.rb', line 57

def boiler_hot_water_standard_minimum_thermal_efficiency(boiler_hot_water, rename = false)
  # Get the boiler properties
  search_criteria = boiler_hot_water_find_search_criteria(boiler_hot_water)
  capacity_w = boiler_hot_water_find_capacity(boiler_hot_water)
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get
  capacity_kbtu_per_hr = OpenStudio.convert(capacity_w, 'W', 'kBtu/hr').get

  # Get the minimum efficiency standards
  thermal_eff = nil

  # Get the boiler properties
  blr_props = model_find_object(standards_data['boilers'], search_criteria, capacity_btu_per_hr)
  unless blr_props
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.BoilerHotWater', "For #{boiler_hot_water.name}, cannot find boiler properties, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end

  fuel_type = blr_props['fuel_type']
  fluid_type = blr_props['fluid_type']

  # If specified as AFUE
  unless blr_props['minimum_annual_fuel_utilization_efficiency'].nil?
    min_afue = blr_props['minimum_annual_fuel_utilization_efficiency']
    thermal_eff = afue_to_thermal_eff(min_afue)
    new_comp_name = "#{boiler_hot_water.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_afue} AFUE"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.BoilerHotWater', "For #{template}: #{boiler_hot_water.name}: #{fuel_type} #{fluid_type} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; AFUE = #{min_afue}")
  end

  # If specified as thermal efficiency
  unless blr_props['minimum_thermal_efficiency'].nil?
    thermal_eff = blr_props['minimum_thermal_efficiency']
    new_comp_name = "#{boiler_hot_water.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{thermal_eff} Thermal Eff"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.BoilerHotWater', "For #{template}: #{boiler_hot_water.name}: #{fuel_type} #{fluid_type} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; Thermal Efficiency = #{thermal_eff}")
  end

  # If specified as combustion efficiency
  unless blr_props['minimum_combustion_efficiency'].nil?
    min_comb_eff = blr_props['minimum_combustion_efficiency']
    thermal_eff = combustion_eff_to_thermal_eff(min_comb_eff)
    new_comp_name = "#{boiler_hot_water.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_comb_eff} Combustion Eff"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.BoilerHotWater', "For #{template}: #{boiler_hot_water.name}: #{fuel_type} #{fluid_type} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; Combustion Efficiency = #{min_comb_eff}")
  end

  # Rename
  if rename
    boiler_hot_water.setName(new_comp_name)
  end

  return thermal_eff
end

#building_story_floor_multiplier(building_story) ⇒ Integer

Checks all spaces on this story that are part of the total floor area to see if they have the same multiplier. If they do, assume that the multipliers are being used as a floor multiplier.

returning 1 if no floor multiplier.

Returns:

  • (Integer)

    return the floor multiplier for this story,



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/openstudio-standards/standards/Standards.BuildingStory.rb', line 11

def building_story_floor_multiplier(building_story)
  floor_multiplier = 1

  # Determine the multipliers for all spaces
  multipliers = []
  building_story.spaces.each do |space|
    # Ignore spaces that aren't part of the total floor area
    next unless space.partofTotalFloorArea

    multipliers << space.multiplier
  end

  # If there are no spaces on this story, assume
  # a multiplier of 1
  if multipliers.size.zero?
    return floor_multiplier
  end

  # Calculate the average multiplier and
  # then convert to integer.
  avg_multiplier = (multipliers.inject { |a, e| a + e }.to_f / multipliers.size).to_i

  # If the multiplier is greater than 1, report this
  if avg_multiplier > 1
    floor_multiplier = avg_multiplier
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.BuildingStory', "Story #{building_story.name} has a multiplier of #{floor_multiplier}.")
  end

  return floor_multiplier
end

#building_story_minimum_z_value(building_story) ⇒ Double

Gets the minimum z-value of the story. This is considered to be the minimum z value of any vertex of any surface of any space on the story, with the exception of plenum spaces.

Returns:

  • (Double)

    the minimum z-value, in m



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/openstudio-standards/standards/Standards.BuildingStory.rb', line 48

def building_story_minimum_z_value(building_story)
  z_heights = []
  building_story.spaces.each do |space|
    # Skip plenum spaces
    next if space_plenum?(space)

    # Get the z value of the space, which
    # vertices in space surfaces are relative to.
    z_origin = space.zOrigin

    # loop through space surfaces to find min z value
    space.surfaces.each do |surface|
      surface.vertices.each do |vertex|
        z_heights << vertex.z + z_origin
      end
    end
  end

  # Error if no z heights were found
  z = 999.9
  if !z_heights.empty?
    z = z_heights.min
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.BuildingStory', "For #{building_story.name} could not find the minimum_z_value, which means the story has no spaces assigned or the spaces have no surfaces.")
  end

  return z
end

#change_construction_properties_in_model(model, values, is_percentage = false) ⇒ Object



482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 482

def change_construction_properties_in_model(model, values, is_percentage = false)
  puts JSON.pretty_generate(values)
  # copy orginal model for reporting.
  before_measure_model = BTAP::FileIO.deep_copy(model)
  # report change as Info
  info = ''
  outdoor_surfaces = BTAP::Geometry::Surfaces.filter_by_boundary_condition(model.getSurfaces, 'Outdoors')
  outdoor_subsurfaces = BTAP::Geometry::Surfaces.get_subsurfaces_from_surfaces(outdoor_surfaces)
  ground_surfaces = BTAP::Geometry::Surfaces.filter_by_boundary_condition(model.getSurfaces, 'Ground')
  ext_windows = BTAP::Geometry::Surfaces.filter_subsurfaces_by_types(outdoor_subsurfaces, ['FixedWindow', 'OperableWindow'])
  ext_skylights = BTAP::Geometry::Surfaces.filter_subsurfaces_by_types(outdoor_subsurfaces, ['Skylight', 'TubularDaylightDiffuser', 'TubularDaylightDome'])
  ext_doors = BTAP::Geometry::Surfaces.filter_subsurfaces_by_types(outdoor_subsurfaces, ['Door'])
  ext_glass_doors = BTAP::Geometry::Surfaces.filter_subsurfaces_by_types(outdoor_subsurfaces, ['GlassDoor'])
  ext_overhead_doors = BTAP::Geometry::Surfaces.filter_subsurfaces_by_types(outdoor_subsurfaces, ['OverheadDoor'])

  # Ext and Ground Surfaces
  (outdoor_surfaces + ground_surfaces).sort.each do |surface|
    ecm_cond_name = "#{surface.outsideBoundaryCondition.downcase}_#{surface.surfaceType.downcase}_conductance"
    apply_changes_to_surface_construction(model,
                                          surface,
                                          values[ecm_cond_name],
                                          nil,
                                          nil,
                                          is_percentage)
    # report change as Info
    surface_conductance = BTAP::Geometry::Surfaces.get_surface_construction_conductance(surface)
    before_measure_surface_conductance = BTAP::Geometry::Surfaces.get_surface_construction_conductance(OpenStudio::Model.getSurfaceByName(before_measure_model, surface.name.to_s).get)
    if before_measure_surface_conductance.round(3) != surface_conductance.round(3)
      info << "#{surface.outsideBoundaryCondition.downcase}_#{surface.surfaceType.downcase}_conductance for #{surface.name} changed from #{before_measure_surface_conductance.round(3)} to #{surface_conductance.round(3)}."
    end
  end
  # Subsurfaces
  (ext_doors + ext_overhead_doors + ext_windows + ext_glass_doors + ext_skylights).sort.each do |surface|
    ecm_cond_name = "#{surface.outsideBoundaryCondition.downcase}_#{surface.subSurfaceType.downcase}_conductance"
    ecm_shgc_name = "#{surface.outsideBoundaryCondition.downcase}_#{surface.subSurfaceType.downcase}_shgc"
    ecm_tvis_name = "#{surface.outsideBoundaryCondition.downcase}_#{surface.subSurfaceType.downcase}_tvis"
    apply_changes_to_surface_construction(model,
                                          surface,
                                          values[ecm_cond_name],
                                          values[ecm_shgc_name],
                                          values[ecm_tvis_name])

    surface_conductance = BTAP::Geometry::Surfaces.get_surface_construction_conductance(surface)
    before_surface = OpenStudio::Model.getSubSurfaceByName(before_measure_model, surface.name.to_s).get
    before_measure_surface_conductance = BTAP::Geometry::Surfaces.get_surface_construction_conductance(before_surface)
    if before_measure_surface_conductance.round(3) != surface_conductance.round(3)
      info << "#{surface.outsideBoundaryCondition.downcase}_#{surface.subSurfaceType.downcase}_conductance for #{surface.name} changed from #{before_measure_surface_conductance.round(3)} to #{surface_conductance.round(3)}."
    end
  end
  info << JSON.pretty_generate(BTAP::FileIO.compare_osm_files(before_measure_model, model))
  return info
end

#chiller_electric_eir_apply_efficiency_and_curves(chiller_electric_eir, clg_tower_objs) ⇒ Bool

Applies the standard efficiency ratings and typical performance curves to this object.

Returns:

  • (Bool)

    true if successful, false if not



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/openstudio-standards/standards/Standards.ChillerElectricEIR.rb', line 97

def chiller_electric_eir_apply_efficiency_and_curves(chiller_electric_eir, clg_tower_objs)
  chillers = standards_data['chillers']

  # Define the criteria to find the chiller properties
  # in the hvac standards data set.
  search_criteria = chiller_electric_eir_find_search_criteria(chiller_electric_eir)
  cooling_type = search_criteria['cooling_type']
  condenser_type = search_criteria['condenser_type']
  compressor_type = search_criteria['compressor_type']

  # Get the chiller capacity
  capacity_w = chiller_electric_eir_find_capacity(chiller_electric_eir)

  # Convert capacity to tons
  capacity_tons = OpenStudio.convert(capacity_w, 'W', 'ton').get

  # Get the chiller properties
  chlr_props = model_find_object(chillers, search_criteria, capacity_tons, Date.today)
  unless chlr_props
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ChillerElectricEIR', "For #{chiller_electric_eir.name}, cannot find chiller properties using #{search_criteria}, cannot apply standard efficiencies or curves.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end

  # Make the CAPFT curve
  cool_cap_ft = model_add_curve(chiller_electric_eir.model, chlr_props['capft'])
  if cool_cap_ft
    chiller_electric_eir.setCoolingCapacityFunctionOfTemperature(cool_cap_ft)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ChillerElectricEIR', "For #{chiller_electric_eir.name}, cannot find cool_cap_ft curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the EIRFT curve
  cool_eir_ft = model_add_curve(chiller_electric_eir.model, chlr_props['eirft'])
  if cool_eir_ft
    chiller_electric_eir.setElectricInputToCoolingOutputRatioFunctionOfTemperature(cool_eir_ft)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ChillerElectricEIR', "For #{chiller_electric_eir.name}, cannot find cool_eir_ft curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the EIRFPLR curve
  # which may be either a CurveBicubic or a CurveQuadratic based on chiller type
  cool_plf_fplr = model_add_curve(chiller_electric_eir.model, chlr_props['eirfplr'])
  if cool_plf_fplr
    chiller_electric_eir.setElectricInputToCoolingOutputRatioFunctionOfPLR(cool_plf_fplr)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ChillerElectricEIR', "For #{chiller_electric_eir.name}, cannot find cool_plf_fplr curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Set the efficiency value
  kw_per_ton = nil
  cop = nil
  if chlr_props['minimum_full_load_efficiency']
    kw_per_ton = chlr_props['minimum_full_load_efficiency']
    cop = kw_per_ton_to_cop(kw_per_ton)
    chiller_electric_eir.setReferenceCOP(cop)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ChillerElectricEIR', "For #{chiller_electric_eir.name}, cannot find minimum full load efficiency, will not be set.")
    successfully_set_all_properties = false
  end

  # Append the name with size and kw/ton
  chiller_electric_eir.setName("#{chiller_electric_eir.name} #{capacity_tons.round}tons #{kw_per_ton.round(1)}kW/ton")
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ChillerElectricEIR', "For #{template}: #{chiller_electric_eir.name}: #{cooling_type} #{condenser_type} #{compressor_type} Capacity = #{capacity_tons.round}tons; COP = #{cop.round(1)} (#{kw_per_ton.round(1)}kW/ton)")

  return successfully_set_all_properties
end

#chiller_electric_eir_find_capacity(chiller_electric_eir) ⇒ Double

Finds capacity in W

Returns:

  • (Double)

    capacity in W to be used for find object



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/openstudio-standards/standards/Standards.ChillerElectricEIR.rb', line 57

def chiller_electric_eir_find_capacity(chiller_electric_eir)
  if chiller_electric_eir.referenceCapacity.is_initialized
    capacity_w = chiller_electric_eir.referenceCapacity.get
  elsif chiller_electric_eir.autosizedReferenceCapacity.is_initialized
    capacity_w = chiller_electric_eir.autosizedReferenceCapacity.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ChillerElectricEIR', "For #{chiller_electric_eir.name} capacity is not available, cannot apply efficiency standard.")
    return false
  end

  return capacity_w
end

#chiller_electric_eir_find_search_criteria(chiller_electric_eir) ⇒ hash

Finds the search criteria

Returns:

  • (hash)

    has for search criteria to be used for find object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/openstudio-standards/standards/Standards.ChillerElectricEIR.rb', line 7

def chiller_electric_eir_find_search_criteria(chiller_electric_eir)
  search_criteria = {}
  search_criteria['template'] = template

  # Determine if WaterCooled or AirCooled by
  # checking if the chiller is connected to a condenser
  # water loop or not.  Use name as fallback for exporting HVAC library.
  cooling_type = 'AirCooled'
  if chiller_electric_eir.secondaryPlantLoop.is_initialized || chiller_electric_eir.name.get.to_s.include?('WaterCooled')
    cooling_type = 'WaterCooled'
  end

  search_criteria['cooling_type'] = cooling_type

  # TODO: Standards replace this with a mechanism to store this
  # data in the chiller object itself.
  # For now, retrieve the condenser type from the name
  name = chiller_electric_eir.name.get
  condenser_type = nil
  compressor_type = nil
  if cooling_type == 'AirCooled'
    if name.include?('WithCondenser')
      condenser_type = 'WithCondenser'
    elsif name.include?('WithoutCondenser')
      condenser_type = 'WithoutCondenser'
    end
  elsif cooling_type == 'WaterCooled'
    if name.include?('Reciprocating')
      compressor_type = 'Reciprocating'
    elsif name.include?('Rotary Screw')
      compressor_type = 'Rotary Screw'
    elsif name.include?('Scroll')
      compressor_type = 'Scroll'
    elsif name.include?('Centrifugal')
      compressor_type = 'Centrifugal'
    end
  end
  unless condenser_type.nil?
    search_criteria['condenser_type'] = condenser_type
  end
  unless compressor_type.nil?
    search_criteria['compressor_type'] = compressor_type
  end

  return search_criteria
end

#chiller_electric_eir_standard_minimum_full_load_efficiency(chiller_electric_eir) ⇒ Double

Finds lookup object in standards and return full load efficiency

Returns:

  • (Double)

    full load efficiency (COP)



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/openstudio-standards/standards/Standards.ChillerElectricEIR.rb', line 73

def chiller_electric_eir_standard_minimum_full_load_efficiency(chiller_electric_eir)
  # Get the chiller properties
  search_criteria = chiller_electric_eir_find_search_criteria(chiller_electric_eir)
  capacity_w = chiller_electric_eir_find_capacity(chiller_electric_eir)
  return nil unless capacity_w

  capacity_tons = OpenStudio.convert(capacity_w, 'W', 'ton').get
  chlr_props = model_find_object(standards_data['chillers'], search_criteria, capacity_tons, Date.today)

  if chlr_props.nil? || !chlr_props['minimum_full_load_efficiency']
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ChillerElectricEIR', "For #{chiller_electric_eir.name}, cannot find minimum full load efficiency.")
    return nil
  else
    # lookup the efficiency value
    kw_per_ton = chlr_props['minimum_full_load_efficiency']
    cop = kw_per_ton_to_cop(kw_per_ton)
  end

  return cop
end

#coil_cooling_dx_multi_speed_apply_efficiency_and_curves(coil_cooling_dx_multi_speed, sql_db_vars_map) ⇒ Bool

Applies the standard efficiency ratings and typical performance curves to this object.

Returns:

  • (Bool)

    true if successful, false if not



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingDXMultiSpeed.rb', line 7

def coil_cooling_dx_multi_speed_apply_efficiency_and_curves(coil_cooling_dx_multi_speed, sql_db_vars_map)
  successfully_set_all_properties = true

  # Define the criteria to find the chiller properties
  # in the hvac standards data set.
  search_criteria = {}
  search_criteria['template'] = template
  cooling_type = coil_cooling_dx_multi_speed.condenserType
  search_criteria['cooling_type'] = cooling_type

  # TODO: Standards - add split system vs single package to model
  # For now, assume single package as default
  sub_category = 'Single Package'

  # Determine the heating type if unitary or zone hvac
  heat_pump = false
  heating_type = nil
  containing_comp = nil
  if coil_cooling_dx_multi_speed.airLoopHVAC.empty?
    if coil_cooling_dx_multi_speed.containingHVACComponent.is_initialized
      containing_comp = coil_cooling_dx_multi_speed.containingHVACComponent.get
      if containing_comp.to_AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.is_initialized
        htg_coil = containing_comp.to_AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.get.heatingCoil
        if htg_coil.to_CoilHeatingDXMultiSpeed.is_initialized
          heat_pump = true
          heating_type = 'Electric Resistance or None'
        elsif htg_coil.to_CoilHeatingGasMultiStage.is_initialized
          heating_type = 'All Other'
        end
        # TODO: Add other unitary systems
      end
    elsif coil_cooling_dx_multi_speed.containingZoneHVACComponent.is_initialized
      containing_comp = coil_cooling_dx_multi_speed.containingZoneHVACComponent.get
      if containing_comp.to_ZoneHVACPackagedTerminalAirConditioner.is_initialized
        sub_category = 'PTAC'
        htg_coil = containing_comp.to_ZoneHVACPackagedTerminalAirConditioner.get.heatingCoil
        if htg_coil.to_CoilHeatingElectric.is_initialized
          heating_type = 'Electric Resistance or None'
        elsif htg_coil.to_CoilHeatingWater.is_initialized || htg_coil.to_CoilHeatingGas.is_initialized || htg_col.to_CoilHeatingGasMultiStage
          heating_type = 'All Other'
        end
        # TODO: Add other zone hvac systems
      end
    end
  end

  # Add the heating type to the search criteria
  unless heating_type.nil?
    search_criteria['heating_type'] = heating_type
  end

  search_criteria['subcategory'] = sub_category

  # Get the coil capacity
  capacity_w = nil
  clg_stages = stages
  if clg_stages.last.grossRatedTotalCoolingCapacity.is_initialized
    capacity_w = clg_stages.last.grossRatedTotalCoolingCapacity.get
  elsif coil_cooling_dx_multi_speed.autosizedSpeed4GrossRatedTotalCoolingCapacity.is_initialized
    capacity_w = coil_cooling_dx_multi_speed.autosizedSpeed4GrossRatedTotalCoolingCapacity.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{coil_cooling_dx_multi_speed.name} capacity is not available, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end

  # Volume flow rate
  flow_rate4 = nil
  if clg_stages.last.ratedAirFlowRate.is_initialized
    flow_rate4 = clg_stages.last.ratedAirFlowRate.get
  elsif coil_cooling_dx_multi_speed.autosizedSpeed4RatedAirFlowRate.is_initialized
    flow_rate4 = coil_cooling_dx_multi_speed.autosizedSpeed4RatedAirFlowRate.get
  end

  # Convert capacity to Btu/hr
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get
  capacity_kbtu_per_hr = OpenStudio.convert(capacity_w, 'W', 'kBtu/hr').get

  # Lookup efficiencies depending on whether it is a unitary AC or a heat pump
  ac_props = nil
  ac_props = if heat_pump == true
               model_find_object(standards_data['heat_pumps'], search_criteria, capacity_btu_per_hr, Date.today)
             else
               model_find_object(standards_data['unitary_acs'], search_criteria, capacity_btu_per_hr, Date.today)
             end

  # Check to make sure properties were found
  if ac_props.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{coil_cooling_dx_multi_speed.name}, cannot find efficiency info using #{search_criteria}, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end

  # Make the COOL-CAP-FT curve
  cool_cap_ft = model_add_curve(model, ac_props['cool_cap_ft'], standards)
  if cool_cap_ft
    clg_stages.each do |stage|
      stage.setTotalCoolingCapacityFunctionofTemperatureCurve(cool_cap_ft)
    end
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{coil_cooling_dx_multi_speed.name}, cannot find cool_cap_ft curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the COOL-CAP-FFLOW curve
  cool_cap_fflow = model_add_curve(model, ac_props['cool_cap_fflow'], standards)
  if cool_cap_fflow
    clg_stages.each do |stage|
      stage.setTotalCoolingCapacityFunctionofFlowFractionCurve(cool_cap_fflow)
    end
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{coil_cooling_dx_multi_speed.name}, cannot find cool_cap_fflow curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the COOL-EIR-FT curve
  cool_eir_ft = model_add_curve(model, ac_props['cool_eir_ft'], standards)
  if cool_eir_ft
    clg_stages.each do |stage|
      stage.setEnergyInputRatioFunctionofTemperatureCurve(cool_eir_ft)
    end
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{coil_cooling_dx_multi_speed.name}, cannot find cool_eir_ft curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the COOL-EIR-FFLOW curve
  cool_eir_fflow = model_add_curve(model, ac_props['cool_eir_fflow'], standards)
  if cool_eir_fflow
    clg_stages.each do |stage|
      stage.setEnergyInputRatioFunctionofFlowFractionCurve(cool_eir_fflow)
    end
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{coil_cooling_dx_multi_speed.name}, cannot find cool_eir_fflow curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the COOL-PLF-FPLR curve
  cool_plf_fplr = model_add_curve(model, ac_props['cool_plf_fplr'], standards)
  if cool_plf_fplr
    clg_stages.each do |stage|
      stage.setPartLoadFractionCorrelationCurve(cool_plf_fplr)
    end
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{coil_cooling_dx_multi_speed.name}, cannot find cool_plf_fplr curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Get the minimum efficiency standards
  cop = nil

  if coil_dx_subcategory(coil_cooling_dx_multi_speed) == 'PTAC'
    ptac_eer_coeff_1 = ac_props['ptac_eer_coefficient_1']
    ptac_eer_coeff_2 = ac_props['ptac_eer_coefficient_2']
    capacity_btu_per_hr = 7000 if capacity_btu_per_hr < 7000
    capacity_btu_per_hr = 15_000 if capacity_btu_per_hr > 15_000
    ptac_eer = ptac_eer_coeff_1 + (ptac_eer_coeff_2 * capacity_btu_per_hr)
    cop = eer_to_cop(ptac_eer)
    # self.setName("#{self.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{ptac_eer}EER")
    new_comp_name = "#{coil_cooling_dx_multi_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{ptac_eer}EER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{template}: #{coil_cooling_dx_multi_speed.name}: #{cooling_type} #{heating_type} #{subcategory} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; EER = #{ptac_eer}")
  end

  # If specified as SEER
  unless ac_props['minimum_seasonal_energy_efficiency_ratio'].nil?
    min_seer = ac_props['minimum_seasonal_energy_efficiency_ratio']
    cop = seer_to_cop_cooling_with_fan(min_seer)
    new_comp_name = "#{coil_cooling_dx_multi_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_seer}SEER"
    #      self.setName("#{self.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_seer}SEER")
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{template}: #{coil_cooling_dx_multi_speed.name}: #{cooling_type} #{heating_type} #{subcategory} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; SEER = #{min_seer}")
  end

  # If specified as EER
  unless ac_props['minimum_energy_efficiency_ratio'].nil?
    min_eer = ac_props['minimum_energy_efficiency_ratio']
    cop = eer_to_cop(min_eer)
    new_comp_name = "#{coil_cooling_dx_multi_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_eer}EER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{template}: #{coil_cooling_dx_multi_speed.name}: #{cooling_type} #{heating_type} #{subcategory} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; EER = #{min_eer}")
  end

  # if specified as SEER (heat pump)
  unless ac_props['minimum_seasonal_efficiency'].nil?
    min_seer = ac_props['minimum_seasonal_efficiency']
    cop = seer_to_cop_cooling_with_fan(min_seer)
    new_comp_name = "#{coil_cooling_dx_multi_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_seer}SEER"
    #      self.setName("#{self.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_seer}SEER")
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{template}: #{coil_cooling_dx_multi_speed.name}: #{cooling_type} #{heating_type} #{subcategory} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; SEER = #{min_seer}")
  end

  # If specified as EER (heat pump)
  unless ac_props['minimum_full_load_efficiency'].nil?
    min_eer = ac_props['minimum_full_load_efficiency']
    cop = eer_to_cop(min_eer)
    new_comp_name = "#{coil_cooling_dx_multi_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_eer}EER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{template}: #{coil_cooling_dx_multi_speed.name}: #{cooling_type} #{heating_type} #{subcategory} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; EER = #{min_eer}")
  end

  sql_db_vars_map[new_comp_name] = name.to_s
  coil_cooling_dx_multi_speed.setName(new_comp_name)

  # Set the efficiency values

  unless cop.nil?
    clg_stages.each do |istage|
      istage.setGrossRatedCoolingCOP(cop)
    end
  end

  return sql_db_vars_map
end

#coil_cooling_dx_multi_speed_find_capacity(coil_cooling_dx_multi_speed) ⇒ Double

Finds capacity in W

Returns:

  • (Double)

    capacity in W to be used for find object



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingDXMultiSpeed.rb', line 221

def coil_cooling_dx_multi_speed_find_capacity(coil_cooling_dx_multi_speed)
  capacity_w = nil
  clg_stages = coil_cooling_dx_multi_speed.stages
  if clg_stages.last.grossRatedTotalCoolingCapacity.is_initialized
    capacity_w = clg_stages.last.grossRatedTotalCoolingCapacity.get
  elsif (clg_stages.size == 1) && coil_cooling_dx_multi_speed.autosizedSpeed1GrossRatedTotalCoolingCapacity.is_initialized
    capacity_w = coil_cooling_dx_multi_speed.autosizedSpeed1GrossRatedTotalCoolingCapacity.get
  elsif (clg_stages.size == 2) && coil_cooling_dx_multi_speed.autosizedSpeed2GrossRatedTotalCoolingCapacity.is_initialized
    capacity_w = coil_cooling_dx_multi_speed.autosizedSpeed2GrossRatedTotalCoolingCapacity.get
  elsif (clg_stages.size == 3) && coil_cooling_dx_multi_speed.autosizedSpeed3GrossRatedTotalCoolingCapacity.is_initialized
    capacity_w = coil_cooling_dx_multi_speed.autosizedSpeed3GrossRatedTotalCoolingCapacity.get
  elsif (clg_stages.size == 4) && coil_cooling_dx_multi_speed.autosizedSpeed4GrossRatedTotalCoolingCapacity.is_initialized
    capacity_w = coil_cooling_dx_multi_speed.autosizedSpeed4GrossRatedTotalCoolingCapacity.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{coil_cooling_dx_multi_speed.name} capacity is not available, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end

  return capacity_w
end

#coil_cooling_dx_multi_speed_standard_minimum_cop(coil_cooling_dx_multi_speed) ⇒ Double

Finds lookup object in standards and return efficiency

Parameters:

  • rename (Bool)

    if true, object will be renamed to include capacity and efficiency level

Returns:

  • (Double)

    full load efficiency (COP)



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingDXMultiSpeed.rb', line 247

def coil_cooling_dx_multi_speed_standard_minimum_cop(coil_cooling_dx_multi_speed)
  search_criteria = coil_dx_find_search_criteria(coil_cooling_dx_multi_speed)
  cooling_type = search_criteria['cooling_type']
  heating_type = search_criteria['heating_type']
  capacity_w = coil_cooling_dx_multi_speed_find_capacity(coil_cooling_dx_multi_speed)

  # Convert capacity to Btu/hr
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get
  capacity_kbtu_per_hr = OpenStudio.convert(capacity_w, 'W', 'kBtu/hr').get

  # Lookup efficiencies depending on whether it is a unitary AC or a heat pump
  ac_props = nil
  ac_props = if coil_dx_heat_pump?(coil_cooling_dx_multi_speed)
               model_find_object(standards_data['heat_pumps'], search_criteria, capacity_btu_per_hr, Date.today)
             else
               model_find_object(standards_data['unitary_acs'], search_criteria, capacity_btu_per_hr, Date.today)
             end

  # Get the minimum efficiency standards
  cop = nil

  # If specified as SEER
  unless ac_props['minimum_seasonal_energy_efficiency_ratio'].nil?
    min_seer = ac_props['minimum_seasonal_energy_efficiency_ratio']
    cop = seer_to_cop_cooling_with_fan(min_seer)
    new_comp_name = "#{coil_cooling_dx_multi_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_seer}SEER"
    #      self.setName("#{self.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_seer}SEER")
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{template}: #{coil_cooling_dx_multi_speed.name}: #{cooling_type} #{heating_type} #{coil_dx_subcategory(coil_cooling_dx_multi_speed)} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; SEER = #{min_seer}")
  end

  # If specified as EER
  unless ac_props['minimum_energy_efficiency_ratio'].nil?
    min_eer = ac_props['minimum_energy_efficiency_ratio']
    cop = eer_to_cop(min_eer)
    new_comp_name = "#{coil_cooling_dx_multi_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_eer}EER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{template}: #{coil_cooling_dx_multi_speed.name}: #{cooling_type} #{heating_type} #{coil_dx_subcategory(coil_cooling_dx_multi_speed)} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; EER = #{min_eer}")
  end

  # if specified as SEER (heat pump)
  unless ac_props['minimum_seasonal_efficiency'].nil?
    min_seer = ac_props['minimum_seasonal_efficiency']
    cop = seer_to_cop_cooling_with_fan(min_seer)
    new_comp_name = "#{coil_cooling_dx_multi_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_seer}SEER"
    #      self.setName("#{self.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_seer}SEER")
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{template}: #{coil_cooling_dx_multi_speed.name}: #{cooling_type} #{heating_type} #{coil_dx_subcategory(coil_cooling_dx_multi_speed)} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; SEER = #{min_seer}")
  end

  # If specified as EER (heat pump)
  unless ac_props['minimum_full_load_efficiency'].nil?
    min_eer = ac_props['minimum_full_load_efficiency']
    cop = eer_to_cop(min_eer)
    new_comp_name = "#{coil_cooling_dx_multi_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_eer}EER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{template}: #{coil_cooling_dx_multi_speed.name}: #{cooling_type} #{heating_type} #{coil_dx_subcategory(coil_cooling_dx_multi_speed)} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; EER = #{min_eer}")
  end

  return cop, new_comp_name
end

#coil_cooling_dx_single_speed_apply_efficiency_and_curves(coil_cooling_dx_single_speed, sql_db_vars_map) ⇒ Bool

Applies the standard efficiency ratings and typical performance curves to this object.

Returns:

  • (Bool)

    true if successful, false if not



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingDXSingleSpeed.rb', line 171

def coil_cooling_dx_single_speed_apply_efficiency_and_curves(coil_cooling_dx_single_speed, sql_db_vars_map)
  successfully_set_all_properties = true

  # Get the search criteria
  search_criteria = coil_dx_find_search_criteria(coil_cooling_dx_single_speed)

  # Get the capacity
  capacity_w = coil_cooling_dx_single_speed_find_capacity(coil_cooling_dx_single_speed)
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get
  capacity_kbtu_per_hr = OpenStudio.convert(capacity_w, 'W', 'kBtu/hr').get

  # Lookup efficiencies depending on whether it is a unitary AC or a heat pump
  ac_props = nil
  ac_props = if coil_dx_heat_pump?(coil_cooling_dx_single_speed)
               model_find_object(standards_data['heat_pumps'], search_criteria, capacity_btu_per_hr, Date.today)
             else
               model_find_object(standards_data['unitary_acs'], search_criteria, capacity_btu_per_hr, Date.today)
             end

  # Check to make sure properties were found
  if ac_props.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{coil_cooling_dx_single_speed.name}, cannot find efficiency info using #{search_criteria}, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return sql_db_vars_map
  end

  # Make the COOL-CAP-FT curve
  cool_cap_ft = model_add_curve(coil_cooling_dx_single_speed.model, ac_props['cool_cap_ft'])
  if cool_cap_ft
    coil_cooling_dx_single_speed.setTotalCoolingCapacityFunctionOfTemperatureCurve(cool_cap_ft)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{coil_cooling_dx_single_speed.name}, cannot find cool_cap_ft curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the COOL-CAP-FFLOW curve
  cool_cap_fflow = model_add_curve(coil_cooling_dx_single_speed.model, ac_props['cool_cap_fflow'])
  if cool_cap_fflow
    coil_cooling_dx_single_speed.setTotalCoolingCapacityFunctionOfFlowFractionCurve(cool_cap_fflow)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{coil_cooling_dx_single_speed.name}, cannot find cool_cap_fflow curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the COOL-EIR-FT curve
  cool_eir_ft = model_add_curve(coil_cooling_dx_single_speed.model, ac_props['cool_eir_ft'])
  if cool_eir_ft
    coil_cooling_dx_single_speed.setEnergyInputRatioFunctionOfTemperatureCurve(cool_eir_ft)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{coil_cooling_dx_single_speed.name}, cannot find cool_eir_ft curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the COOL-EIR-FFLOW curve
  cool_eir_fflow = model_add_curve(coil_cooling_dx_single_speed.model, ac_props['cool_eir_fflow'])
  if cool_eir_fflow
    coil_cooling_dx_single_speed.setEnergyInputRatioFunctionOfFlowFractionCurve(cool_eir_fflow)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{coil_cooling_dx_single_speed.name}, cannot find cool_eir_fflow curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the COOL-PLF-FPLR curve
  cool_plf_fplr = model_add_curve(coil_cooling_dx_single_speed.model, ac_props['cool_plf_fplr'])
  if cool_plf_fplr
    coil_cooling_dx_single_speed.setPartLoadFractionCorrelationCurve(cool_plf_fplr)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{coil_cooling_dx_single_speed.name}, cannot find cool_plf_fplr curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Preserve the original name
  orig_name = coil_cooling_dx_single_speed.name.to_s

  # Find the minimum COP and rename with efficiency rating
  cop = coil_cooling_dx_single_speed_standard_minimum_cop(coil_cooling_dx_single_speed, true)

  # Map the original name to the new name
  sql_db_vars_map[coil_cooling_dx_single_speed.name.to_s] = orig_name

  # Set the efficiency values
  unless cop.nil?
    coil_cooling_dx_single_speed.setRatedCOP(OpenStudio::OptionalDouble.new(cop))
  end

  return sql_db_vars_map
end

#coil_cooling_dx_single_speed_find_capacity(coil_cooling_dx_single_speed) ⇒ Double

Finds capacity in W

Returns:

  • (Double)

    capacity in W to be used for find object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingDXSingleSpeed.rb', line 9

def coil_cooling_dx_single_speed_find_capacity(coil_cooling_dx_single_speed)
  capacity_w = nil
  if coil_cooling_dx_single_speed.ratedTotalCoolingCapacity.is_initialized
    capacity_w = coil_cooling_dx_single_speed.ratedTotalCoolingCapacity.get
  elsif coil_cooling_dx_single_speed.autosizedRatedTotalCoolingCapacity.is_initialized
    capacity_w = coil_cooling_dx_single_speed.autosizedRatedTotalCoolingCapacity.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{coil_cooling_dx_single_speed.name} capacity is not available, cannot apply efficiency standard.")
    return 0.0
  end

  # If it's a PTAC or PTHP System, we need to divide the capacity by the potential zone multiplier
  # because the COP is dependent on capacity, and the capacity should be the capacity of a single zone, not all the zones
  if ['PTAC', 'PTHP'].include?(coil_dx_subcategory(coil_cooling_dx_single_speed))
    mult = 1
    comp = coil_cooling_dx_single_speed.containingZoneHVACComponent
    if comp.is_initialized
      if comp.get.thermalZone.is_initialized
        mult = comp.get.thermalZone.get.multiplier
        if mult > 1
          total_cap = capacity_w
          capacity_w /= mult
          OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{coil_cooling_dx_single_speed.name}, total capacity of #{OpenStudio.convert(total_cap, 'W', 'kBtu/hr').get.round(2)}kBTU/hr was divided by the zone multiplier of #{mult} to give #{capacity_kbtu_per_hr = OpenStudio.convert(capacity_w, 'W', 'kBtu/hr').get.round(2)}kBTU/hr.")
        end
      end
    end
  end

  return capacity_w
end

#coil_cooling_dx_single_speed_standard_minimum_cop(coil_cooling_dx_single_speed, rename = false) ⇒ Double

Finds lookup object in standards and return efficiency

Parameters:

  • rename (Bool) (defaults to: false)

    if true, object will be renamed to include capacity and efficiency level

Returns:

  • (Double)

    full load efficiency (COP)



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingDXSingleSpeed.rb', line 44

def coil_cooling_dx_single_speed_standard_minimum_cop(coil_cooling_dx_single_speed, rename = false)
  search_criteria = coil_dx_find_search_criteria(coil_cooling_dx_single_speed)
  cooling_type = search_criteria['cooling_type']
  heating_type = search_criteria['heating_type']
  sub_category = search_criteria['subcategory']
  capacity_w = coil_cooling_dx_single_speed_find_capacity(coil_cooling_dx_single_speed)
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get
  capacity_kbtu_per_hr = OpenStudio.convert(capacity_w, 'W', 'kBtu/hr').get

  # Look up the efficiency characteristics
  # Lookup efficiencies depending on whether it is a unitary AC or a heat pump
  ac_props = nil
  ac_props = if coil_dx_heat_pump?(coil_cooling_dx_single_speed)
               model_find_object(standards_data['heat_pumps'], search_criteria, capacity_btu_per_hr, Date.today)
             else
               model_find_object(standards_data['unitary_acs'], search_criteria, capacity_btu_per_hr, Date.today)
             end

  # Check to make sure properties were found
  if ac_props.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{coil_cooling_dx_single_speed.name}, cannot find efficiency info using #{search_criteria}, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end

  # Get the minimum efficiency standards
  cop = nil

  # If PTHP, use equations if coefficients are specified
  pthp_eer_coeff_1 = ac_props['pthp_eer_coefficient_1']
  pthp_eer_coeff_2 = ac_props['pthp_eer_coefficient_2']
  if sub_category == 'PTHP' && !pthp_eer_coeff_1.nil? && !pthp_eer_coeff_2.nil?
    # TABLE 6.8.1D
    # EER = pthp_eer_coeff_1 - (pthp_eer_coeff_2 * Cap / 1000)
    # Note c: Cap means the rated cooling capacity of the product in Btu/h.
    # If the unit's capacity is less than 7000 Btu/h, use 7000 Btu/h in the calculation.
    # If the unit's capacity is greater than 15,000 Btu/h, use 15,000 Btu/h in the calculation.
    eer_calc_cap_btu_per_hr = capacity_btu_per_hr
    eer_calc_cap_btu_per_hr = 7000 if capacity_btu_per_hr < 7000
    eer_calc_cap_btu_per_hr = 15_000 if capacity_btu_per_hr > 15_000
    pthp_eer = pthp_eer_coeff_1 - (pthp_eer_coeff_2 * eer_calc_cap_btu_per_hr / 1000.0)
    cop = eer_to_cop(pthp_eer)
    new_comp_name = "#{coil_cooling_dx_single_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{pthp_eer.round(1)}EER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{coil_cooling_dx_single_speed.name}: #{cooling_type} #{heating_type} #{sub_category} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; EER = #{pthp_eer.round(1)}")
  end

  # If PTAC, use equations if coefficients are specified
  ptac_eer_coeff_1 = ac_props['ptac_eer_coefficient_1']
  ptac_eer_coeff_2 = ac_props['ptac_eer_coefficient_2']
  if sub_category == 'PTAC' && !ptac_eer_coeff_1.nil? && !ptac_eer_coeff_2.nil?
    # TABLE 6.8.1D
    # EER = ptac_eer_coeff_1 - (ptac_eer_coeff_2 * Cap / 1000)
    # Note c: Cap means the rated cooling capacity of the product in Btu/h.
    # If the unit's capacity is less than 7000 Btu/h, use 7000 Btu/h in the calculation.
    # If the unit's capacity is greater than 15,000 Btu/h, use 15,000 Btu/h in the calculation.
    eer_calc_cap_btu_per_hr = capacity_btu_per_hr
    eer_calc_cap_btu_per_hr = 7000 if capacity_btu_per_hr < 7000
    eer_calc_cap_btu_per_hr = 15_000 if capacity_btu_per_hr > 15_000
    ptac_eer = ptac_eer_coeff_1 - (ptac_eer_coeff_2 * eer_calc_cap_btu_per_hr / 1000.0)
    cop = eer_to_cop(ptac_eer)
    new_comp_name = "#{coil_cooling_dx_single_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{ptac_eer.round(1)}EER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{coil_cooling_dx_single_speed.name}: #{cooling_type} #{heating_type} #{sub_category} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; EER = #{ptac_eer.round(1)}")
  end

  # If CRAC, use equations if coefficients are specified
  crac_minimum_scop = ac_props['minimum_scop']
  if sub_category == 'CRAC' && !crac_minimum_scop.nil?
    # TABLE 6.8.1K in 90.1-2010, TABLE 6.8.1-10 in 90.1-2019
    # cop = scop/sensible heat ratio
    if coil_cooling_dx_single_speed.ratedSensibleHeatRatio.is_initialized
      crac_sensible_heat_ratio = coil_cooling_dx_single_speed.ratedSensibleHeatRatio.get
    elsif coil_cooling_dx_single_speed.autosizedRatedSensibleHeatRatio.is_initialized
      # Though actual inlet temperature is very high (thus basically no dehumidification),
      # sensible heat ratio can't be pre-assigned as 1 because it should be the value at conditions defined in ASHRAE Standard 127 => 26.7 degC drybulb/19.4 degC wetbulb.
      crac_sensible_heat_ratio = coil_cooling_dx_single_speed.autosizedRatedSensibleHeatRatio.get
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.CoilCoolingDXSingleSpeed', 'Failed to get autosized sensible heat ratio')
    end
    cop = crac_minimum_scop / crac_sensible_heat_ratio
    cop = cop.round(2)
    new_comp_name = "#{coil_cooling_dx_single_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{crac_minimum_scop}SCOP #{cop}COP"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{coil_cooling_dx_single_speed.name}: #{cooling_type} #{heating_type} #{sub_category} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; SCOP = #{crac_minimum_scop}")
  end

  # If specified as SEER
  unless ac_props['minimum_seasonal_energy_efficiency_ratio'].nil?
    min_seer = ac_props['minimum_seasonal_energy_efficiency_ratio']
    cop = seer_to_cop_cooling_with_fan(min_seer)
    new_comp_name = "#{coil_cooling_dx_single_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_seer}SEER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{template}: #{coil_cooling_dx_single_speed.name}: #{cooling_type} #{heating_type} #{sub_category} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; SEER = #{min_seer}")
  end

  # If specified as EER
  unless ac_props['minimum_energy_efficiency_ratio'].nil?
    min_eer = ac_props['minimum_energy_efficiency_ratio']
    cop = eer_to_cop(min_eer)
    new_comp_name = "#{coil_cooling_dx_single_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_eer}EER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{template}: #{coil_cooling_dx_single_speed.name}: #{cooling_type} #{heating_type} #{sub_category} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; EER = #{min_eer}")
  end

  # if specified as SEER (heat pump)
  unless ac_props['minimum_seasonal_efficiency'].nil?
    min_seer = ac_props['minimum_seasonal_efficiency']
    cop = seer_to_cop_cooling_with_fan(min_seer)
    new_comp_name = "#{coil_cooling_dx_single_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_seer}SEER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{template}: #{coil_cooling_dx_single_speed.name}: #{cooling_type} #{heating_type} #{sub_category} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; SEER = #{min_seer}")
  end

  # If specified as EER (heat pump)
  unless ac_props['minimum_full_load_efficiency'].nil?
    min_eer = ac_props['minimum_full_load_efficiency']
    cop = eer_to_cop(min_eer)
    new_comp_name = "#{coil_cooling_dx_single_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_eer}EER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXSingleSpeed', "For #{template}: #{coil_cooling_dx_single_speed.name}: #{cooling_type} #{heating_type} #{sub_category} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; EER = #{min_eer}")
  end

  # Rename
  if rename
    coil_cooling_dx_single_speed.setName(new_comp_name)
  end

  return cop
end

#coil_cooling_dx_two_speed_apply_efficiency_and_curves(coil_cooling_dx_two_speed, sql_db_vars_map) ⇒ Bool

Applies the standard efficiency ratings and typical performance curves to this object.

Returns:

  • (Bool)

    true if successful, false if not



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingDXTwoSpeed.rb', line 102

def coil_cooling_dx_two_speed_apply_efficiency_and_curves(coil_cooling_dx_two_speed, sql_db_vars_map)
  successfully_set_all_properties = true

  # Get the search criteria
  search_criteria = coil_dx_find_search_criteria(coil_cooling_dx_two_speed)

  # Get the capacity
  capacity_w = coil_cooling_dx_two_speed_find_capacity(coil_cooling_dx_two_speed)
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get
  capacity_kbtu_per_hr = OpenStudio.convert(capacity_w, 'W', 'kBtu/hr').get

  # Lookup efficiencies depending on whether it is a unitary AC or a heat pump
  ac_props = nil
  ac_props = if coil_dx_heat_pump?(coil_cooling_dx_two_speed)
               model_find_object(standards_data['heat_pumps'], search_criteria, capacity_btu_per_hr, Date.today)
             else
               model_find_object(standards_data['unitary_acs'], search_criteria, capacity_btu_per_hr, Date.today)
             end

  # Check to make sure properties were found
  if ac_props.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXTwoSpeed', "For #{coil_cooling_dx_two_speed.name}, cannot find efficiency info using #{search_criteria}, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return sql_db_vars_map
  end

  # Make the total COOL-CAP-FT curve
  tot_cool_cap_ft = model_add_curve(coil_cooling_dx_two_speed.model, ac_props['cool_cap_ft'])
  if tot_cool_cap_ft
    coil_cooling_dx_two_speed.setTotalCoolingCapacityFunctionOfTemperatureCurve(tot_cool_cap_ft)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXTwoSpeed', "For #{coil_cooling_dx_two_speed.name}, cannot find cool_cap_ft curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the total COOL-CAP-FFLOW curve
  tot_cool_cap_fflow = model_add_curve(coil_cooling_dx_two_speed.model, ac_props['cool_cap_fflow'])
  if tot_cool_cap_fflow
    coil_cooling_dx_two_speed.setTotalCoolingCapacityFunctionOfFlowFractionCurve(tot_cool_cap_fflow)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXTwoSpeed', "For #{coil_cooling_dx_two_speed.name}, cannot find cool_cap_fflow curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the COOL-EIR-FT curve
  cool_eir_ft = model_add_curve(coil_cooling_dx_two_speed.model, ac_props['cool_eir_ft'])
  if cool_eir_ft
    coil_cooling_dx_two_speed.setEnergyInputRatioFunctionOfTemperatureCurve(cool_eir_ft)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXTwoSpeed', "For #{coil_cooling_dx_two_speed.name}, cannot find cool_eir_ft curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the COOL-EIR-FFLOW curve
  cool_eir_fflow = model_add_curve(coil_cooling_dx_two_speed.model, ac_props['cool_eir_fflow'])
  if cool_eir_fflow
    coil_cooling_dx_two_speed.setEnergyInputRatioFunctionOfFlowFractionCurve(cool_eir_fflow)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXTwoSpeed', "For #{coil_cooling_dx_two_speed.name}, cannot find cool_eir_fflow curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the COOL-PLF-FPLR curve
  cool_plf_fplr = model_add_curve(coil_cooling_dx_two_speed.model, ac_props['cool_plf_fplr'])
  if cool_plf_fplr
    coil_cooling_dx_two_speed.setPartLoadFractionCorrelationCurve(cool_plf_fplr)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXTwoSpeed', "For #{coil_cooling_dx_two_speed.name}, cannot find cool_plf_fplr curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the low speed COOL-CAP-FT curve
  low_speed_cool_cap_ft = model_add_curve(coil_cooling_dx_two_speed.model, ac_props['cool_cap_ft'])
  if low_speed_cool_cap_ft
    coil_cooling_dx_two_speed.setLowSpeedTotalCoolingCapacityFunctionOfTemperatureCurve(low_speed_cool_cap_ft)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXTwoSpeed', "For #{coil_cooling_dx_two_speed.name}, cannot find cool_cap_ft curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the low speed COOL-EIR-FT curve
  low_speed_cool_eir_ft = model_add_curve(coil_cooling_dx_two_speed.model, ac_props['cool_eir_ft'])
  if low_speed_cool_eir_ft
    coil_cooling_dx_two_speed.setLowSpeedEnergyInputRatioFunctionOfTemperatureCurve(low_speed_cool_eir_ft)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXTwoSpeed', "For #{coil_cooling_dx_two_speed.name}, cannot find cool_eir_ft curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Preserve the original name
  orig_name = coil_cooling_dx_two_speed.name.to_s

  # Find the minimum COP and rename with efficiency rating
  cop = coil_cooling_dx_two_speed_standard_minimum_cop(coil_cooling_dx_two_speed, true)

  # Map the original name to the new name
  sql_db_vars_map[coil_cooling_dx_two_speed.name.to_s] = orig_name

  # Set the efficiency values
  unless cop.nil?
    coil_cooling_dx_two_speed.setRatedHighSpeedCOP(cop)
    coil_cooling_dx_two_speed.setRatedLowSpeedCOP(cop)
  end

  return sql_db_vars_map
end

#coil_cooling_dx_two_speed_find_capacity(coil_cooling_dx_two_speed) ⇒ Double

Finds capacity in W

Returns:

  • (Double)

    capacity in W to be used for find object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingDXTwoSpeed.rb', line 9

def coil_cooling_dx_two_speed_find_capacity(coil_cooling_dx_two_speed)
  capacity_w = nil
  if coil_cooling_dx_two_speed.ratedHighSpeedTotalCoolingCapacity.is_initialized
    capacity_w = coil_cooling_dx_two_speed.ratedHighSpeedTotalCoolingCapacity.get
  elsif coil_cooling_dx_two_speed.autosizedRatedHighSpeedTotalCoolingCapacity.is_initialized
    capacity_w = coil_cooling_dx_two_speed.autosizedRatedHighSpeedTotalCoolingCapacity.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXTwoSpeed', "For #{coil_cooling_dx_two_speed.name} capacity is not available, cannot apply efficiency standard.")
    return 0.0
  end

  return capacity_w
end

#coil_cooling_dx_two_speed_standard_minimum_cop(coil_cooling_dx_two_speed, rename = false) ⇒ Double

Finds lookup object in standards and return efficiency

Returns:

  • (Double)

    full load efficiency (COP)



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingDXTwoSpeed.rb', line 26

def coil_cooling_dx_two_speed_standard_minimum_cop(coil_cooling_dx_two_speed, rename = false)
  search_criteria = coil_dx_find_search_criteria(coil_cooling_dx_two_speed)
  cooling_type = search_criteria['cooling_type']
  heating_type = search_criteria['heating_type']
  sub_category = search_criteria['subcategory']
  capacity_w = coil_cooling_dx_two_speed_find_capacity(coil_cooling_dx_two_speed)
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get
  capacity_kbtu_per_hr = OpenStudio.convert(capacity_w, 'W', 'kBtu/hr').get

  # Lookup efficiencies depending on whether it is a unitary AC or a heat pump
  ac_props = nil
  ac_props = if coil_dx_heat_pump?(coil_cooling_dx_two_speed)
               model_find_object(standards_data['heat_pumps'], search_criteria, capacity_btu_per_hr, Date.today)
             else
               model_find_object(standards_data['unitary_acs'], search_criteria, capacity_btu_per_hr, Date.today)
             end

  # Check to make sure properties were found
  if ac_props.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXTwoSpeed', "For #{coil_cooling_dx_two_speed.name}, cannot find efficiency info using #{search_criteria}, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end

  # Get the minimum efficiency standards
  cop = nil

  # Check to make sure properties were found
  if ac_props.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXTwoSpeed', "For #{coil_cooling_dx_two_speed.name}, cannot find efficiency info using #{search_criteria}, cannot apply efficiency standard.")
    return cop # value of nil
  end

  # If specified as SEER
  unless ac_props['minimum_seasonal_energy_efficiency_ratio'].nil?
    min_seer = ac_props['minimum_seasonal_energy_efficiency_ratio']
    cop = seer_to_cop_cooling_with_fan(min_seer)
    new_comp_name = "#{coil_cooling_dx_two_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_seer}SEER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXTwoSpeed', "For #{template}: #{coil_cooling_dx_two_speed.name}: #{cooling_type} #{heating_type} #{sub_category} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; SEER = #{min_seer}")
  end

  # If specified as EER
  unless ac_props['minimum_energy_efficiency_ratio'].nil?
    min_eer = ac_props['minimum_energy_efficiency_ratio']
    cop = eer_to_cop(min_eer)
    new_comp_name = "#{coil_cooling_dx_two_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_eer}EER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXTwoSpeed', "For #{template}: #{coil_cooling_dx_two_speed.name}: #{cooling_type} #{heating_type} #{sub_category} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; EER = #{min_eer}")
  end

  # if specified as SEER (heat pump)
  unless ac_props['minimum_seasonal_efficiency'].nil?
    min_seer = ac_props['minimum_seasonal_efficiency']
    cop = seer_to_cop_cooling_with_fan(min_seer)
    new_comp_name = "#{coil_cooling_dx_two_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_seer}SEER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXTwoSpeed', "For #{template}: #{coil_cooling_dx_two_speed.name}: #{cooling_type} #{heating_type} #{sub_category} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; SEER = #{min_seer}")
  end

  # If specified as EER (heat pump)
  unless ac_props['minimum_full_load_efficiency'].nil?
    min_eer = ac_props['minimum_full_load_efficiency']
    cop = eer_to_cop(min_eer)
    new_comp_name = "#{coil_cooling_dx_two_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_eer}EER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingDXTwoSpeed', "For #{template}: #{coil_cooling_dx_two_speed.name}: #{cooling_type} #{heating_type} #{sub_category} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; EER = #{min_eer}")
  end

  # Rename
  if rename
    coil_cooling_dx_two_speed.setName(new_comp_name)
  end

  return cop
end

#coil_cooling_water_to_air_heat_pump_apply_efficiency_and_curves(coil_cooling_water_to_air_heat_pump, sql_db_vars_map) ⇒ Bool

Applies the standard efficiency ratings and typical performance curves to this object.

Returns:

  • (Bool)

    true if successful, false if not



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingWaterToAirHeatPumpEquationFit.rb', line 64

def coil_cooling_water_to_air_heat_pump_apply_efficiency_and_curves(coil_cooling_water_to_air_heat_pump, sql_db_vars_map)
  successfully_set_all_properties = true

  # Get the search criteria
  search_criteria = {}
  search_criteria['template'] = template
  capacity_w = coil_cooling_water_to_air_heat_pump_find_capacity(coil_cooling_water_to_air_heat_pump)
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get

  # Look up the efficiency characteristics
  coil_props = model_find_object(standards_data['water_source_heat_pumps'], search_criteria, capacity_btu_per_hr, Date.today)

  # Check to make sure properties were found
  if coil_props.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingWaterToAirHeatPumpEquationFit', "For #{coil_cooling_water_to_air_heat_pump.name}, cannot find efficiency info using #{search_criteria}, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return sql_db_vars_map
  end

  # TODO: Add methods to set coefficients, and add coefficients to data spreadsheet
  # using OS defaults for now
  # tot_cool_cap_coeff1 = coil_props['tot_cool_cap_coeff1']
  # if tot_cool_cap_coeff1
  #   coil_cooling_water_to_air_heat_pump.setTotalCoolingCapacityCoefficient1(tot_cool_cap_coeff1)
  # else
  #   OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingWaterToAirHeatPumpEquationFit', "For #{coil_cooling_water_to_air_heat_pump.name}, cannot find tot_cool_cap_coeff1, will not be set.")
  #   successfully_set_all_properties = false
  # end

  # Preserve the original name
  orig_name = coil_cooling_water_to_air_heat_pump.name.to_s

  # Find the minimum COP and rename with efficiency rating
  cop = coil_cooling_water_to_air_heat_pump_standard_minimum_cop(coil_cooling_water_to_air_heat_pump, true)

  # Map the original name to the new name
  sql_db_vars_map[coil_cooling_water_to_air_heat_pump.name.to_s] = orig_name

  # Set the efficiency values
  unless cop.nil?
    coil_cooling_water_to_air_heat_pump.setRatedCoolingCoefficientofPerformance(cop)
  end

  return sql_db_vars_map
end

#coil_cooling_water_to_air_heat_pump_find_capacity(coil_cooling_water_to_air_heat_pump) ⇒ Double

Finds capacity in W

Returns:

  • (Double)

    capacity in W to be used for find object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingWaterToAirHeatPumpEquationFit.rb', line 7

def coil_cooling_water_to_air_heat_pump_find_capacity(coil_cooling_water_to_air_heat_pump)
  capacity_w = nil
  if coil_cooling_water_to_air_heat_pump.ratedTotalCoolingCapacity.is_initialized
    capacity_w = coil_cooling_water_to_air_heat_pump.ratedTotalCoolingCapacity.get
  elsif coil_cooling_water_to_air_heat_pump.autosizedRatedTotalCoolingCapacity.is_initialized
    capacity_w = coil_cooling_water_to_air_heat_pump.autosizedRatedTotalCoolingCapacity.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingWaterToAirHeatPumpEquationFit', "For #{coil_cooling_water_to_air_heat_pump.name} capacity is not available, cannot apply efficiency standard.")
    return 0.0
  end

  return capacity_w
end

#coil_cooling_water_to_air_heat_pump_standard_minimum_cop(coil_cooling_water_to_air_heat_pump, rename = false) ⇒ Double

Finds lookup object in standards and return efficiency

Parameters:

  • rename (Bool) (defaults to: false)

    if true, object will be renamed to include capacity and efficiency level

Returns:

  • (Double)

    full load efficiency (COP)



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingWaterToAirHeatPumpEquationFit.rb', line 25

def coil_cooling_water_to_air_heat_pump_standard_minimum_cop(coil_cooling_water_to_air_heat_pump, rename = false)
  search_criteria = {}
  search_criteria['template'] = template
  capacity_w = coil_cooling_water_to_air_heat_pump_find_capacity(coil_cooling_water_to_air_heat_pump)
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get
  capacity_kbtu_per_hr = OpenStudio.convert(capacity_w, 'W', 'kBtu/hr').get

  # Look up the efficiency characteristics
  coil_props = model_find_object(standards_data['water_source_heat_pumps'], search_criteria, capacity_btu_per_hr, Date.today)

  # Check to make sure properties were found
  if coil_props.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingWaterToAirHeatPumpEquationFit', "For #{coil_cooling_water_to_air_heat_pump.name}, cannot find efficiency info using #{search_criteria}, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end

  # Get the minimum efficiency standards
  cop = nil

  # If specified as EER (heat pump)
  unless coil_props['minimum_full_load_efficiency'].nil?
    min_eer = coil_props['minimum_full_load_efficiency']
    cop = eer_to_cop(min_eer, capacity_w = nil)
    new_comp_name = "#{coil_cooling_water_to_air_heat_pump.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_eer}EER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilCoolingWaterToAirHeatPumpEquationFit', "For #{template}: #{coil_cooling_water_to_air_heat_pump.name}: Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; EER = #{min_eer}")
  end

  # Rename
  if rename
    coil_cooling_water_to_air_heat_pump.setName(new_comp_name)
  end

  return cop
end

#coil_heating_dx_multi_speed_apply_efficiency_and_curves(coil_heating_dx_multi_speed, sql_db_vars_map) ⇒ Bool

Applies the standard efficiency ratings and typical performance curves to this object.

Returns:

  • (Bool)

    true if successful, false if not



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/openstudio-standards/standards/Standards.CoilHeatingDXMultiSpeed.rb', line 7

def coil_heating_dx_multi_speed_apply_efficiency_and_curves(coil_heating_dx_multi_speed, sql_db_vars_map)
  successfully_set_all_properties = true

  # Define the criteria to find the unitary properties
  # in the hvac standards data set.
  search_criteria = {}
  search_criteria['template'] = template

  # Determine supplemental heating type if unitary
  heat_pump = false
  suppl_heating_type = nil
  if coil_heating_dx_multi_speed.airLoopHVAC.empty?
    if coil_heating_dx_multi_speed.containingHVACComponent.is_initialized
      containing_comp = coil_heating_dx_multi_speed.containingHVACComponent.get
      if containing_comp.to_AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.is_initialized
        heat_pump = true
        htg_coil = containing_comp.to_AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.get.supplementalHeatingCoil
        suppl_heating_type = if htg_coil.to_CoilHeatingElectric.is_initialized
                               'Electric Resistance or None'
                             else
                               'All Other'
                             end
      end
      # TODO: Add other unitary systems
    end
  end

  # TODO: Standards - add split system vs single package to model
  # For now, assume single package
  subcategory = 'Single Package'
  search_criteria['subcategory'] = subcategory

  # Get the coil capacity
  clg_capacity = nil
  if heat_pump == true
    containing_comp = coil_heating_dx_multi_speed.containingHVACComponent.get
    heat_pump_comp = containing_comp.to_AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.get
    ccoil = heat_pump_comp.coolingCoil
    dxcoil = ccoil.to_CoilCoolingDXMultiSpeed.get
    dxcoil_name = dxcoil.name.to_s
    if sql_db_vars_map
      if sql_db_vars_map[dxcoil_name]
        dxcoil.setName(sql_db_vars_map[dxcoil_name])
      end
    end
    clg_stages = dxcoil.stages
    if clg_stages.last.grossRatedTotalCoolingCapacity.is_initialized
      clg_capacity = clg_stages.last.grossRatedTotalCoolingCapacity.get
    elsif dxcoil.autosizedSpeed4GrossRatedTotalCoolingCapacity.is_initialized
      clg_capacity = dxcoil.autosizedSpeed4GrossRatedTotalCoolingCapacity.get
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXMultiSpeed', "For #{coil_heating_dx_multi_speed.name} capacity is not available, cannot apply efficiency standard.")
      successfully_set_all_properties = false
      return successfully_set_all_properties
    end
    dxcoil.setName(dxcoil_name)
  end

  # Convert capacity to Btu/hr
  capacity_btu_per_hr = OpenStudio.convert(clg_capacity, 'W', 'Btu/hr').get
  capacity_kbtu_per_hr = OpenStudio.convert(clg_capacity, 'W', 'kBtu/hr').get

  # Lookup efficiencies depending on whether it is a unitary AC or a heat pump
  hp_props = model_find_object(standards_data['heat_pumps'], search_criteria, capacity_btu_per_hr, Date.today)

  # Check to make sure properties were found
  if hp_props.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXMultipeed', "For #{coil_heating_dx_multi_speed.name}, cannot find efficiency info using #{search_criteria}, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end

  # Make the HEAT-CAP-FT curve
  htg_stages = stages
  heat_cap_ft = model_add_curve(model, hp_props['heat_cap_ft'], standards)
  if heat_cap_ft
    htg_stages.each do |istage|
      istage.setHeatingCapacityFunctionofTemperatureCurve(heat_cap_ft)
    end
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXMultiSpeed', "For #{coil_heating_dx_multi_speed.name}, cannot find heat_cap_ft curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the HEAT-CAP-FFLOW curve
  heat_cap_fflow = model_add_curve(model, hp_props['heat_cap_fflow'], standards)
  if heat_cap_fflow
    htg_stages.each do |istage|
      istage.setHeatingCapacityFunctionofFlowFractionCurve(heat_cap_fflow)
    end
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXMultiSpeed', "For #{coil_heating_dx_multi_speed.name}, cannot find heat_cap_fflow curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the HEAT-EIR-FT curve
  heat_eir_ft = model_add_curve(model, hp_props['heat_eir_ft'], standards)
  if heat_eir_ft
    htg_stages.each do |istage|
      istage.setEnergyInputRatioFunctionofTemperatureCurve(heat_eir_ft)
    end
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXMultiSpeed', "For #{coil_heating_dx_multi_speed.name}, cannot find heat_eir_ft curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the HEAT-EIR-FFLOW curve
  heat_eir_fflow = model_add_curve(model, hp_props['heat_eir_fflow'], standards)
  if heat_eir_fflow
    htg_stages.each do |istage|
      istage.setEnergyInputRatioFunctionofFlowFractionCurve(heat_eir_fflow)
    end
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXMultiSpeed', "For #{coil_heating_dx_multi_speed.name}, cannot find heat_eir_fflow curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the HEAT-PLF-FPLR curve
  heat_plf_fplr = model_add_curve(model, hp_props['heat_plf_fplr'], standards)
  if heat_plf_fplr
    htg_stages.each do |istage|
      istage.setPartLoadFractionCorrelationCurve(heat_plf_fplr)
    end
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXMultiSpeed', "For #{coil_heating_dx_multi_speed.name}, cannot find heat_plf_fplr curve, will not be set.")
    successfully_set_all_properties = false
  end

  htg_capacity = nil
  flow_rate4 = nil
  htg_stages = coil_heating_dx_multi_speed.stages
  if htg_stages.last.grossRatedHeatingCapacity.is_initialized
    htg_capacity = htg_stages.last.grossRatedHeatingCapacity.get
  elsif coil_heating_dx_multi_speed.autosizedSpeed4GrossRatedHeatingCapacity.is_initialized
    htg_capacity = coil_heating_dx_multi_speed.autosizedSpeed4GrossRatedHeatingCapacity.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXMultiSpeed', "For #{coil_heating_dx_multi_speed.name} capacity is not available, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end
  if htg_stages.last.ratedAirFlowRate.is_initialized
    flow_rate4 = htg_stages.last.ratedAirFlowRate.get
  elsif coil_heating_dx_multi_speed.autosizedSpeed4RatedAirFlowRate.is_initialized
    flow_rate4 = coil_heating_dx_multi_speed.autosizedSpeed4RatedAirFlowRate.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXMultiSpeed', "For #{coil_heating_dx_multi_speed.name} capacity is not available, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end

  # Convert capacity to Btu/hr
  capacity_btu_per_hr = OpenStudio.convert(htg_capacity, 'W', 'Btu/hr').get
  capacity_kbtu_per_hr = OpenStudio.convert(htg_capacity, 'W', 'kBtu/hr').get

  # Get the minimum efficiency standards
  cop = nil

  # If specified as SEER
  unless hp_props['minimum_seasonal_energy_efficiency_ratio'].nil?
    min_seer = hp_props['minimum_seasonal_energy_efficiency_ratio']
    cop = seer_to_cop_cooling_with_fan(min_seer)
    coil_heating_dx_multi_speed.setName("#{coil_heating_dx_multi_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_seer}SEER")
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilHeatingDXMultiSpeed', "For #{template}: #{coil_heating_dx_multi_speed.name}: #{suppl_heating_type} #{subcategory} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; SEER = #{min_seer}")
  end

  # If specified as EER
  unless hp_props['minimum_energy_efficiency_ratio'].nil?
    min_eer = hp_props['minimum_energy_efficiency_ratio']
    cop = eer_to_cop(min_eer)
    coil_heating_dx_multi_speed.setName("#{coil_heating_dx_multi_speed.name} #{capacity_kbtu_per_hr.round}kBtu/hr #{min_eer}EER")
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilHeatingDXMultiSpeed', "For #{template}: #{coil_heating_dx_multi_speed.name}:  #{suppl_heating_type} #{subcategory} Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; EER = #{min_eer}")
  end

  # Set the efficiency values
  unless cop.nil?
    htg_stages.each do |istage|
      istage.setGrossRatedHeatingCOP(cop)
    end
  end
end

#coil_heating_dx_single_speed_apply_defrost_eir_curve_limits(htg_coil) ⇒ Object



197
198
199
200
201
202
203
204
205
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.CoilHeatingDXSingleSpeed.rb', line 197

def coil_heating_dx_single_speed_apply_defrost_eir_curve_limits(htg_coil)
  return false unless htg_coil.defrostEnergyInputRatioFunctionofTemperatureCurve.is_initialized

  def_eir_f_of_temp = htg_coil.defrostEnergyInputRatioFunctionofTemperatureCurve.get.to_CurveBiquadratic.get
  def_eir_f_of_temp.setMinimumValueofx(12.77778)
  def_eir_f_of_temp.setMaximumValueofx(23.88889)
  def_eir_f_of_temp.setMinimumValueofy(21.11111)
  def_eir_f_of_temp.setMaximumValueofy(46.11111)
end

#coil_heating_dx_single_speed_apply_efficiency_and_curves(coil_heating_dx_single_speed, sql_db_vars_map) ⇒ Bool

Applies the standard efficiency ratings and typical performance curves to this object.

Returns:

  • (Bool)

    true if successful, false if not



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/openstudio-standards/standards/Standards.CoilHeatingDXSingleSpeed.rb', line 179

def coil_heating_dx_single_speed_apply_efficiency_and_curves(coil_heating_dx_single_speed, sql_db_vars_map)
  successfully_set_all_properties = true

  # Get the search criteria
  search_criteria = coil_dx_find_search_criteria(coil_heating_dx_single_speed)

  # Get the capacity
  capacity_w = coil_heating_dx_single_speed_find_capacity(coil_heating_dx_single_speed)
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get
  capacity_kbtu_per_hr = OpenStudio.convert(capacity_w, 'W', 'kBtu/hr').get

  # Lookup efficiencies
  ac_props = model_find_object(standards_data['heat_pumps_heating'], search_criteria, capacity_btu_per_hr, Date.today)

  # Check to make sure properties were found
  if ac_props.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXSingleSpeed', "For #{coil_heating_dx_single_speed.name}, cannot find efficiency info using #{search_criteria}, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return sql_db_vars_map
  end

  # Make the HEAT-CAP-FT curve
  heat_cap_ft = model_add_curve(coil_heating_dx_single_speed.model, ac_props['heat_cap_ft'])
  if heat_cap_ft
    coil_heating_dx_single_speed.setTotalHeatingCapacityFunctionofTemperatureCurve(heat_cap_ft)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXSingleSpeed', "For #{coil_heating_dx_single_speed.name}, cannot find heat_cap_ft curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the HEAT-CAP-FFLOW curve
  heat_cap_fflow = model_add_curve(coil_heating_dx_single_speed.model, ac_props['heat_cap_fflow'])
  if heat_cap_fflow
    coil_heating_dx_single_speed.setTotalHeatingCapacityFunctionofFlowFractionCurve(heat_cap_fflow)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXSingleSpeed', "For #{coil_heating_dx_single_speed.name}, cannot find heat_cap_fflow curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the HEAT-EIR-FT curve
  heat_eir_ft = model_add_curve(coil_heating_dx_single_speed.model, ac_props['heat_eir_ft'])
  if heat_eir_ft
    coil_heating_dx_single_speed.setEnergyInputRatioFunctionofTemperatureCurve(heat_eir_ft)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXSingleSpeed', "For #{coil_heating_dx_single_speed.name}, cannot find heat_eir_ft curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the HEAT-EIR-FFLOW curve
  heat_eir_fflow = model_add_curve(coil_heating_dx_single_speed.model, ac_props['heat_eir_fflow'])
  if heat_eir_fflow
    coil_heating_dx_single_speed.setEnergyInputRatioFunctionofFlowFractionCurve(heat_eir_fflow)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXSingleSpeed', "For #{coil_heating_dx_single_speed.name}, cannot find heat_eir_fflow curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Make the HEAT-PLF-FPLR curve
  heat_plf_fplr = model_add_curve(coil_heating_dx_single_speed.model, ac_props['heat_plf_fplr'])
  if heat_plf_fplr
    coil_heating_dx_single_speed.setPartLoadFractionCorrelationCurve(heat_plf_fplr)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXSingleSpeed', "For #{coil_heating_dx_single_speed.name}, cannot find heat_plf_fplr curve, will not be set.")
    successfully_set_all_properties = false
  end

  # Preserve the original name
  orig_name = coil_heating_dx_single_speed.name.to_s

  # Find the minimum COP and rename with efficiency rating
  cop = coil_heating_dx_single_speed_standard_minimum_cop(coil_heating_dx_single_speed, true)

  # Map the original name to the new name
  sql_db_vars_map[coil_heating_dx_single_speed.name.to_s] = orig_name

  # Set the efficiency values
  unless cop.nil?
    coil_heating_dx_single_speed.setRatedCOP(cop)
  end

  return sql_db_vars_map
end

#coil_heating_dx_single_speed_find_capacity(coil_heating_dx_single_speed) ⇒ Double

Finds capacity in W. This is the cooling capacity of the paired DX cooling coil.

Returns:

  • (Double)

    capacity in W to be used for find object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/openstudio-standards/standards/Standards.CoilHeatingDXSingleSpeed.rb', line 10

def coil_heating_dx_single_speed_find_capacity(coil_heating_dx_single_speed)
  capacity_w = nil

  # Get the paired cooling coil
  clg_coil = nil

  # Unitary and zone equipment
  if coil_heating_dx_single_speed.airLoopHVAC.empty?
    if coil_heating_dx_single_speed.containingHVACComponent.is_initialized
      containing_comp = coil_heating_dx_single_speed.containingHVACComponent.get
      if containing_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.is_initialized
        clg_coil = containing_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.coolingCoil
      elsif containing_comp.to_AirLoopHVACUnitarySystem.is_initialized
        unitary = containing_comp.to_AirLoopHVACUnitarySystem.get
        if unitary.coolingCoil.is_initialized
          clg_coil = unitary.coolingCoil.get
        end
      end
      # TODO: Add other unitary systems
    elsif coil_heating_dx_single_speed.containingZoneHVACComponent.is_initialized
      containing_comp = coil_heating_dx_single_speed.containingZoneHVACComponent.get
      # PTHP
      if containing_comp.to_ZoneHVACPackagedTerminalHeatPump.is_initialized
        pthp = containing_comp.to_ZoneHVACPackagedTerminalHeatPump.get
        clg_coil = containing_comp.to_ZoneHVACPackagedTerminalHeatPump.get.coolingCoil
      end
    end
  end

  # On AirLoop directly
  if coil_heating_dx_single_speed.airLoopHVAC.is_initialized
    air_loop = coil_heating_dx_single_speed.airLoopHVAC.get
    # Check for the presence of any other type of cooling coil
    clg_types = ['OS:Coil:Cooling:DX:SingleSpeed',
                 'OS:Coil:Cooling:DX:TwoSpeed',
                 'OS:Coil:Cooling:DX:MultiSpeed']
    clg_types.each do |ct|
      coils = air_loop.supplyComponents(ct.to_IddObjectType)
      next if coils.empty?

      clg_coil = coils[0]
      break # Stop on first DX cooling coil found
    end
  end

  # If no paired cooling coil was found,
  # throw an error and fall back to the heating capacity
  # of the DX heating coil
  if clg_coil.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXSingleSpeed', "For #{coil_heating_dx_single_speed.name}, the paired DX cooling coil could not be found to determine capacity. Efficiency will incorrectly be based on DX coil's heating capacity.")
    if coil_heating_dx_single_speed.ratedTotalHeatingCapacity.is_initialized
      capacity_w = coil_heating_dx_single_speed.ratedTotalHeatingCapacity.get
    elsif coil_heating_dx_single_speed.autosizedRatedTotalHeatingCapacity.is_initialized
      capacity_w = coil_heating_dx_single_speed.autosizedRatedTotalHeatingCapacity.get
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXSingleSpeed', "For #{coil_heating_dx_single_speed.name} capacity is not available, cannot apply efficiency standard to paired DX heating coil.")
      return 0.0
    end
    return capacity_w
  end

  # If a coil was found, cast to the correct type
  if clg_coil.to_CoilCoolingDXSingleSpeed.is_initialized
    clg_coil = clg_coil.to_CoilCoolingDXSingleSpeed.get
    capacity_w = coil_cooling_dx_single_speed_find_capacity(clg_coil)
  elsif clg_coil.to_CoilCoolingDXTwoSpeed.is_initialized
    clg_coil = clg_coil.to_CoilCoolingDXTwoSpeed.get
    capacity_w = coil_cooling_dx_two_speed_find_capacity(clg_coil)
  elsif clg_coil.to_CoilCoolingDXMultiSpeed.is_initialized
    clg_coil = clg_coil.to_CoilCoolingDXMultiSpeed.get
    capacity_w = coil_cooling_dx_multi_speed_find_capacity(clg_coil)
  end

  # If it's a PTAC or PTHP System, we need to divide the capacity by the potential zone multiplier
  # because the COP is dependent on capacity, and the capacity should be the capacity of a single zone, not all the zones
  if ['PTAC', 'PTHP'].include?(coil_dx_subcategory(coil_heating_dx_single_speed))
    mult = 1
    comp = coil_heating_dx_single_speed.containingZoneHVACComponent
    if comp.is_initialized
      if comp.get.thermalZone.is_initialized
        mult = comp.get.thermalZone.get.multiplier
        if mult > 1
          total_cap = capacity_w
          capacity_w /= mult
          OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilHeatingDXSingleSpeed', "For #{coil_heating_dx_single_speed.name}, total capacity of #{OpenStudio.convert(total_cap, 'W', 'kBtu/hr').get.round(2)}kBTU/hr was divided by the zone multiplier of #{mult} to give #{capacity_kbtu_per_hr = OpenStudio.convert(capacity_w, 'W', 'kBtu/hr').get.round(2)}kBTU/hr.")
        end
      end
    end
  end

  return capacity_w
end

#coil_heating_dx_single_speed_standard_minimum_cop(coil_heating_dx_single_speed, rename = false) ⇒ Double

Finds lookup object in standards and return efficiency

Returns:

  • (Double)

    full load efficiency (COP)



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/openstudio-standards/standards/Standards.CoilHeatingDXSingleSpeed.rb', line 106

def coil_heating_dx_single_speed_standard_minimum_cop(coil_heating_dx_single_speed, rename = false)
  # find ac properties
  search_criteria = coil_dx_find_search_criteria(coil_heating_dx_single_speed)
  sub_category = search_criteria['subcategory']
  suppl_heating_type = search_criteria['heating_type']
  capacity_w = coil_heating_dx_single_speed_find_capacity(coil_heating_dx_single_speed)
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get
  capacity_kbtu_per_hr = OpenStudio.convert(capacity_w, 'W', 'kBtu/hr').get

  # Get the minimum efficiency standards
  cop = nil

  # find object
  ac_props = model_find_object(standards_data['heat_pumps_heating'], search_criteria, capacity_btu_per_hr, Date.today)

  # Check to make sure properties were found
  if ac_props.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingDXSingleSpeed', "For #{coil_heating_dx_single_speed.name}, cannot find efficiency info using #{search_criteria}, cannot apply efficiency standard.")
    return cop # value of nil
  end

  # If PTHP, use equations
  if sub_category == 'PTHP'
    pthp_cop_coeff_1 = ac_props['pthp_cop_coefficient_1']
    pthp_cop_coeff_2 = ac_props['pthp_cop_coefficient_2']
    # TABLE 6.8.1D
    # COP = pthp_cop_coeff_1 - (pthp_cop_coeff_2 * Cap / 1000)
    # Note c: Cap means the rated cooling capacity of the product in Btu/h.
    # If the unit's capacity is less than 7000 Btu/h, use 7000 Btu/h in the calculation.
    # If the unit's capacity is greater than 15,000 Btu/h, use 15,000 Btu/h in the calculation.
    capacity_btu_per_hr = 7000 if capacity_btu_per_hr < 7000
    capacity_btu_per_hr = 15_000 if capacity_btu_per_hr > 15_000
    min_coph = pthp_cop_coeff_1 - (pthp_cop_coeff_2 * capacity_btu_per_hr / 1000.0)
    cop = cop_heating_to_cop_heating_no_fan(min_coph, OpenStudio.convert(capacity_kbtu_per_hr, 'kBtu/hr', 'W').get)
    new_comp_name = "#{coil_heating_dx_single_speed.name} #{capacity_kbtu_per_hr.round} Clg kBtu/hr #{min_coph.round(1)}COPH"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilHeatingDXSingleSpeed', "For #{coil_heating_dx_single_speed.name}: #{sub_category} Cooling Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; COPH = #{min_coph.round(2)}")
  end

  # If specified as HSPF
  unless ac_props['minimum_heating_seasonal_performance_factor'].nil?
    min_hspf = ac_props['minimum_heating_seasonal_performance_factor']
    cop = hspf_to_cop_heating_with_fan(min_hspf)
    new_comp_name = "#{coil_heating_dx_single_speed.name} #{capacity_kbtu_per_hr.round} Clg kBtu/hr #{min_hspf.round(1)}HSPF"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilHeatingDXSingleSpeed', "For #{template}: #{coil_heating_dx_single_speed.name}: #{suppl_heating_type} #{sub_category} Cooling Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; HSPF = #{min_hspf}")
  end

  # If specified as COPH
  unless ac_props['minimum_coefficient_of_performance_heating'].nil?
    min_coph = ac_props['minimum_coefficient_of_performance_heating']
    cop = cop_heating_to_cop_heating_no_fan(min_coph, OpenStudio.convert(capacity_kbtu_per_hr, 'kBtu/hr', 'W').get)
    new_comp_name = "#{coil_heating_dx_single_speed.name} #{capacity_kbtu_per_hr.round} Clg kBtu/hr #{min_coph.round(1)}COPH"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilHeatingDXSingleSpeed', "For #{template}: #{coil_heating_dx_single_speed.name}: #{suppl_heating_type} #{sub_category} Cooling Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; COPH = #{min_coph}")
  end

  # If specified as EER
  unless ac_props['minimum_energy_efficiency_ratio'].nil?
    min_eer = ac_props['minimum_energy_efficiency_ratio']
    cop = eer_to_cop(min_eer)
    new_comp_name = "#{coil_heating_dx_single_speed.name} #{capacity_kbtu_per_hr.round} Clg kBtu/hr #{min_eer.round(1)}EER"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilHeatingDXSingleSpeed', "For #{template}: #{coil_heating_dx_single_speed.name}:  #{suppl_heating_type} #{sub_category} Cooling Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; EER = #{min_eer}")
  end

  # Rename
  if rename
    coil_heating_dx_single_speed.setName(new_comp_name)
  end

  return cop
end

#coil_heating_gas_apply_efficiency_and_curves(coil_heating_gas) ⇒ Bool

Applies the standard efficiency ratings and typical performance curves to this object.

Returns:

  • (Bool)

    true if successful, false if not



7
8
9
10
11
# File 'lib/openstudio-standards/standards/Standards.CoilHeatingGas.rb', line 7

def coil_heating_gas_apply_efficiency_and_curves(coil_heating_gas)
  successfully_set_all_properties = true

  return successfully_set_all_properties
end

#coil_heating_gas_apply_prototype_efficiency(coil_heating_gas) ⇒ Object

Updates the efficiency of some gas heating coils per the prototype assumptions. Defaults to making no changes.



60
61
62
63
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.CoilHeatingGas.rb', line 60

def coil_heating_gas_apply_prototype_efficiency(coil_heating_gas)
  # Do nothing
  return true
end

#coil_heating_gas_multi_stage_apply_efficiency_and_curves(coil_heating_gas_multi_stage, standards) ⇒ Bool

Applies the standard efficiency ratings and typical performance curves to this object.

Returns:

  • (Bool)

    true if successful, false if not



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/openstudio-standards/standards/Standards.CoilHeatingGasMultiStage.rb', line 21

def coil_heating_gas_multi_stage_apply_efficiency_and_curves(coil_heating_gas_multi_stage, standards)
  successfully_set_all_properties = true

  # Get the coil capacity
  capacity_w = nil
  htg_stages = stages
  if htg_stages.last.nominalCapacity.is_initialized
    capacity_w = htg_stages.last.nominalCapacity.get
  elsif coil_heating_gas_multi_stage.autosizedStage4NominalCapacity.is_initialized
    capacity_w = coil_heating_gas_multi_stage.autosizedStage4NominalCapacity.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingGasMultiStage', "For #{coil_heating_gas_multi_stage.name} capacity is not available, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end

  # plf vs plr curve for furnace
  furnace_plffplr_curve = model_add_curve(model, furnace_plffplr_curve_name, standards)
  if furnace_plffplr_curve
    coil_heating_gas_multi_stage.setPartLoadFractionCorrelationCurve(furnace_plffplr_curve)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingGasMultiStage', "For #{coil_heating_gas_multi_stage.name}, cannot find plffplr curve, will not be set.")
    successfully_set_all_properties = false
  end
end

#coil_heating_gas_multi_stage_find_capacity(coil_heating_gas_multi_stage) ⇒ Double

Finds capacity in W

Returns:

  • (Double)

    capacity in W to be used for find object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/openstudio-standards/standards/Standards.CoilHeatingGasMultiStage.rb', line 50

def coil_heating_gas_multi_stage_find_capacity(coil_heating_gas_multi_stage)
  capacity_w = nil
  htg_stages = coil_heating_gas_multi_stage.stages
  if htg_stages.last.nominalCapacity.is_initialized
    capacity_w = htg_stages.last.nominalCapacity.get
  elsif (htg_stages.size == 1) && coil_heating_gas_multi_stage.autosizedStage1NominalCapacity.is_initialized
    capacity_w = coil_heating_gas_multi_stage.autosizedStage1NominalCapacity.get
  elsif (htg_stages.size == 2) && coil_heating_gas_multi_stage.autosizedStage2NominalCapacity.is_initialized
    capacity_w = coil_heating_gas_multi_stage.autosizedStage2NominalCapacity.get
  elsif (htg_stages.size == 3) && coil_heating_gas_multi_stage.autosizedStage3NominalCapacity.is_initialized
    capacity_w = coil_heating_gas_multi_stage.autosizedStage3NominalCapacity.get
  elsif (htg_stages.size == 4) && coil_heating_gas_multi_stage.autosizedStage4NominalCapacity.is_initialized
    capacity_w = coil_heating_gas_multi_stage.autosizedStage4NominalCapacity.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilCoolingDXMultiSpeed', "For #{coil_heating_gas_multi_stage.name} capacity is not available, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end
end

#coil_heating_gas_multi_stage_find_search_criteria(coil_heating_gas_multi_stage) ⇒ Hash

find search criteria

Returns:

  • (Hash)

    used for model_find_object(model)



7
8
9
10
11
12
13
14
15
16
# File 'lib/openstudio-standards/standards/Standards.CoilHeatingGasMultiStage.rb', line 7

def coil_heating_gas_multi_stage_find_search_criteria(coil_heating_gas_multi_stage)
  # Define the criteria to find the coil heating gas multi-stage properties
  # in the hvac standards data set.
  search_criteria = {}
  search_criteria['template'] = template
  search_criteria['fuel_type'] = 'Gas'
  search_criteria['fluid_type'] = 'Air'

  return search_criteria
end

#coil_heating_water_to_air_heat_pump_apply_efficiency_and_curves(coil_heating_water_to_air_heat_pump, sql_db_vars_map) ⇒ Bool

Applies the standard efficiency ratings and typical performance curves to this object.

Returns:

  • (Bool)

    true if successful, false if not



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/openstudio-standards/standards/Standards.CoilHeatingWaterToAirHeatPumpEquationFit.rb', line 129

def coil_heating_water_to_air_heat_pump_apply_efficiency_and_curves(coil_heating_water_to_air_heat_pump, sql_db_vars_map)
  successfully_set_all_properties = true

  # Get the search criteria
  search_criteria = {}
  search_criteria['template'] = template
  capacity_w = coil_heating_water_to_air_heat_pump_find_capacity(coil_heating_water_to_air_heat_pump)
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get

  # Look up the efficiency characteristics
  coil_props = model_find_object(standards_data['water_source_heat_pumps_heating'], search_criteria, capacity_btu_per_hr, Date.today)

  # Check to make sure properties were found
  if coil_props.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingWaterToAirHeatPumpEquationFit', "For #{coil_heating_water_to_air_heat_pump.name}, cannot find efficiency info using #{search_criteria}, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return sql_db_vars_map
  end

  # TODO: Add methods to set coefficients, and add coefficients to data spreadsheet
  # using OS defaults for now
  # heat_cap_coeff1 = coil_props['heat_cap_coeff1']
  # if heat_cap_coeff1
  #   coil_heating_water_to_air_heat_pump.setHeatingCapacityCoefficient1(heat_cap_coeff1)
  # else
  #   OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingWaterToAirHeatPumpEquationFit', "For #{coil_heating_water_to_air_heat_pump.name}, cannot find heat_cap_coeff1, will not be set.")
  #   successfully_set_all_properties = false
  # end

  # Preserve the original name
  orig_name = coil_heating_water_to_air_heat_pump.name.to_s

  # Find the minimum COP and rename with efficiency rating
  cop = coil_heating_water_to_air_heat_pump_standard_minimum_cop(coil_heating_water_to_air_heat_pump, true)

  # Map the original name to the new name
  sql_db_vars_map[coil_heating_water_to_air_heat_pump.name.to_s] = orig_name

  # Set the efficiency values
  unless cop.nil?
    coil_heating_water_to_air_heat_pump.setRatedHeatingCoefficientofPerformance(cop)
  end

  return sql_db_vars_map
end

#coil_heating_water_to_air_heat_pump_find_capacity(coil_heating_water_to_air_heat_pump) ⇒ Double

Finds capacity in W. This is the cooling capacity of the paired cooling coil.

Returns:

  • (Double)

    capacity in W to be used for find object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/openstudio-standards/standards/Standards.CoilHeatingWaterToAirHeatPumpEquationFit.rb', line 8

def coil_heating_water_to_air_heat_pump_find_capacity(coil_heating_water_to_air_heat_pump)
  capacity_w = nil

  # Get the paired cooling coil
  clg_coil = nil

  # Unitary and zone equipment
  if coil_heating_water_to_air_heat_pump.airLoopHVAC.empty?
    if coil_heating_water_to_air_heat_pump.containingHVACComponent.is_initialized
      containing_comp = coil_heating_water_to_air_heat_pump.containingHVACComponent.get
      if containing_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.is_initialized
        clg_coil = containing_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.coolingCoil
      elsif containing_comp.to_AirLoopHVACUnitarySystem.is_initialized
        unitary = containing_comp.to_AirLoopHVACUnitarySystem.get
        if unitary.coolingCoil.is_initialized
          clg_coil = unitary.coolingCoil.get
        end
      end
    elsif coil_heating_water_to_air_heat_pump.containingZoneHVACComponent.is_initialized
      containing_comp = coil_heating_water_to_air_heat_pump.containingZoneHVACComponent.get
      # PTHP
      if containing_comp.to_ZoneHVACPackagedTerminalHeatPump.is_initialized
        clg_coil = containing_comp.to_ZoneHVACPackagedTerminalHeatPump.get.coolingCoil
      # WSHP
      elsif containing_comp.to_ZoneHVACWaterToAirHeatPump.is_initialized
        clg_coil = containing_comp.to_ZoneHVACWaterToAirHeatPump.get.coolingCoil
      end
    end
  end

  # On AirLoop directly
  if coil_heating_water_to_air_heat_pump.airLoopHVAC.is_initialized
    air_loop = coil_heating_water_to_air_heat_pump.airLoopHVAC.get
    # Check for the presence of any other type of cooling coil
    clg_types = ['OS:Coil:Cooling:DX:SingleSpeed',
                 'OS:Coil:Cooling:DX:TwoSpeed',
                 'OS:Coil:Cooling:DX:MultiSpeed']
    clg_types.each do |ct|
      coils = air_loop.supplyComponents(ct.to_IddObjectType)
      next if coils.empty?

      clg_coil = coils[0]
      break # Stop on first cooling coil found
    end
  end

  # If no paired cooling coil was found,
  # throw an error and fall back to the heating capacity of the heating coil
  if clg_coil.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingWaterToAirHeatPumpEquationFit', "For #{coil_heating_water_to_air_heat_pump.name}, the paired cooling coil could not be found to determine capacity. Efficiency will incorrectly be based on coil's heating capacity.")
    if coil_heating_water_to_air_heat_pump.ratedTotalHeatingCapacity.is_initialized
      capacity_w = coil_heating_water_to_air_heat_pump.ratedTotalHeatingCapacity.get
    elsif coil_heating_water_to_air_heat_pump.autosizedRatedTotalHeatingCapacity.is_initialized
      capacity_w = coil_heating_water_to_air_heat_pump.autosizedRatedTotalHeatingCapacity.get
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingWaterToAirHeatPumpEquationFit', "For #{coil_heating_water_to_air_heat_pump.name} capacity is not available, cannot apply efficiency standard to paired heating coil.")
      return 0.0
    end
    return capacity_w
  end

  # If a coil was found, cast to the correct type
  if clg_coil.to_CoilCoolingDXSingleSpeed.is_initialized
    clg_coil = clg_coil.to_CoilCoolingDXSingleSpeed.get
    capacity_w = coil_cooling_dx_single_speed_find_capacity(clg_coil)
  elsif clg_coil.to_CoilCoolingDXTwoSpeed.is_initialized
    clg_coil = clg_coil.to_CoilCoolingDXTwoSpeed.get
    capacity_w = coil_cooling_dx_two_speed_find_capacity(clg_coil)
  elsif clg_coil.to_CoilCoolingDXMultiSpeed.is_initialized
    clg_coil = clg_coil.to_CoilCoolingDXMultiSpeed.get
    capacity_w = coil_cooling_dx_multi_speed_find_capacity(clg_coil)
  elsif clg_coil.to_CoilCoolingWaterToAirHeatPumpEquationFit.is_initialized
    clg_coil = clg_coil.to_CoilCoolingWaterToAirHeatPumpEquationFit.get
    capacity_w = coil_cooling_water_to_air_heat_pump_find_capacity(clg_coil)
  end

  return capacity_w
end

#coil_heating_water_to_air_heat_pump_standard_minimum_cop(coil_heating_water_to_air_heat_pump, rename = false) ⇒ Double

Finds lookup object in standards and return efficiency

Parameters:

  • rename (Bool) (defaults to: false)

    if true, object will be renamed to include capacity and efficiency level

Returns:

  • (Double)

    full load efficiency (COP)



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/openstudio-standards/standards/Standards.CoilHeatingWaterToAirHeatPumpEquationFit.rb', line 91

def coil_heating_water_to_air_heat_pump_standard_minimum_cop(coil_heating_water_to_air_heat_pump, rename = false)
  search_criteria = {}
  search_criteria['template'] = template
  capacity_w = coil_heating_water_to_air_heat_pump_find_capacity(coil_heating_water_to_air_heat_pump)
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get
  capacity_kbtu_per_hr = OpenStudio.convert(capacity_w, 'W', 'kBtu/hr').get

  # Look up the efficiency characteristics
  coil_props = model_find_object(standards_data['water_source_heat_pumps_heating'], search_criteria, capacity_btu_per_hr, Date.today)

  # Check to make sure properties were found
  if coil_props.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.CoilHeatingWaterToAirHeatPumpEquationFit', "For #{coil_heating_water_to_air_heat_pump.name}, cannot find efficiency info using #{search_criteria}, cannot apply efficiency standard.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  end

  # Get the minimum efficiency standards
  cop = nil

  # If specified as EER
  unless coil_props['minimum_coefficient_of_performance_heating'].nil?
    cop = coil_props['minimum_coefficient_of_performance_heating']
    new_comp_name = "#{coil_heating_water_to_air_heat_pump.name} #{capacity_kbtu_per_hr.round} Clg kBtu/hr #{cop.round(1)}COPH"
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.CoilHeatingWaterToAirHeatPumpEquationFit', "For #{template}: #{coil_heating_water_to_air_heat_pump.name}: Cooling Capacity = #{capacity_kbtu_per_hr.round}kBtu/hr; COPH = #{cop}")
  end

  # Rename
  if rename
    coil_heating_water_to_air_heat_pump.setName(new_comp_name)
  end

  return cop
end

#combustion_eff_to_thermal_eff(combustion_eff) ⇒ Double

A helper method to convert from combustion efficiency to thermal efficiency

Parameters:

  • combustion_eff (Double)

    Combustion efficiency (%)

Returns:

  • (Double)

    Thermal efficiency (%)



387
388
389
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 387

def combustion_eff_to_thermal_eff(combustion_eff)
  return combustion_eff - 0.007
end

#construction_calculated_solar_heat_gain_coefficient(construction) ⇒ Double

Get the SHGC as calculated by EnergyPlus. Only applies to fenestration constructions.

Returns:

  • (Double)

    the SHGC as a decimal.



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 302

def construction_calculated_solar_heat_gain_coefficient(construction)
  construction_name = construction.name.get.to_s

  shgc = nil

  sql = construction.model.sqlFile

  if sql.is_initialized
    sql = sql.get

    row_query = "SELECT RowName
                FROM tabulardatawithstrings
                WHERE ReportName='EnvelopeSummary'
                AND ReportForString='Entire Facility'
                AND TableName='Exterior Fenestration'
                AND Value='#{construction_name.upcase}'"

    row_id = sql.execAndReturnFirstString(row_query)

    if row_id.is_initialized
      row_id = row_id.get
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Construction', "SHGC row ID not found for construction: #{construction_name}.")
      row_id = 9999
    end

    shgc_query = "SELECT Value
                FROM tabulardatawithstrings
                WHERE ReportName='EnvelopeSummary'
                AND ReportForString='Entire Facility'
                AND TableName='Exterior Fenestration'
                AND ColumnName='Glass SHGC'
                AND RowName='#{row_id}'"

    shgc = sql.execAndReturnFirstDouble(shgc_query)

    shgc = if shgc.is_initialized
             shgc.get
           end

  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Construction', 'Model has no sql file containing results, cannot lookup data.')
  end

  return shgc
end

#construction_calculated_u_factor(construction) ⇒ Double

Get the U-Factor as calculated by EnergyPlus. Only applies to fenestration constructions.

Returns:

  • (Double)

    the U-Factor in W/m^2*K.



402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 402

def construction_calculated_u_factor(construction)
  construction_name = construction.name.get.to_s

  u_factor_w_per_m2_k = nil

  sql = construction.model.sqlFile

  if sql.is_initialized
    sql = sql.get

    row_query = "SELECT RowName
                FROM tabulardatawithstrings
                WHERE ReportName='EnvelopeSummary'
                AND ReportForString='Entire Facility'
                AND TableName='Exterior Fenestration'
                AND Value='#{construction_name.upcase}'"

    row_id = sql.execAndReturnFirstString(row_query)

    if row_id.is_initialized
      row_id = row_id.get
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Construction', "U-Factor row ID not found for construction: #{construction_name}.")
      row_id = 9999
    end

    u_factor_query = "SELECT Value
                FROM tabulardatawithstrings
                WHERE ReportName='EnvelopeSummary'
                AND ReportForString='Entire Facility'
                AND TableName='Exterior Fenestration'
                AND ColumnName='Glass U-Factor'
                AND RowName='#{row_id}'"

    u_factor_w_per_m2_k = sql.execAndReturnFirstDouble(u_factor_query)

    u_factor_w_per_m2_k = if u_factor_w_per_m2_k.is_initialized
                            u_factor_w_per_m2_k.get
                          end

  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Construction', 'Model has no sql file containing results, cannot lookup data.')
  end

  return u_factor_w_per_m2_k
end

#construction_calculated_visible_transmittance(construction) ⇒ Double

Get the VT as calculated by EnergyPlus. Only applies to fenestration constructions.

Returns:

  • (Double)

    the visible transmittance as a decimal.



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 352

def construction_calculated_visible_transmittance(construction)
  construction_name = construction.name.get.to_s

  vt = nil

  sql = construction.model.sqlFile

  if sql.is_initialized
    sql = sql.get

    row_query = "SELECT RowName
                FROM tabulardatawithstrings
                WHERE ReportName='EnvelopeSummary'
                AND ReportForString='Entire Facility'
                AND TableName='Exterior Fenestration'
                AND Value='#{construction_name.upcase}'"

    row_id = sql.execAndReturnFirstString(row_query)

    if row_id.is_initialized
      row_id = row_id.get
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Construction', "VT row ID not found for construction: #{construction_name}.")
      row_id = 9999
    end

    vt_query = "SELECT Value
                FROM tabulardatawithstrings
                WHERE ReportName='EnvelopeSummary'
                AND ReportForString='Entire Facility'
                AND TableName='Exterior Fenestration'
                AND ColumnName='Glass Visible Transmittance'
                AND RowName='#{row_id}'"

    vt = sql.execAndReturnFirstDouble(vt_query)

    vt = if vt.is_initialized
           vt.get
         end

  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Construction', 'Model has no sql file containing results, cannot lookup data.')
  end

  return vt
end

#construction_deep_copy(model, construction) ⇒ String

This will create a deep copy of the construction

Parameters:

Returns:

  • (String)

    new_construction

Author:



644
645
646
647
648
649
650
651
652
653
654
655
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 644

def construction_deep_copy(model, construction)
  construction = BTAP::Common.validate_array(model, construction, 'Construction').first
  new_construction = construction.clone.to_Construction.get
  # interating through layers."
  (0..new_construction.layers.length - 1).each do |layernumber|
    # cloning material"
    cloned_layer = new_construction.getLayer(layernumber).clone.to_Material.get
    # "setting material to new construction."
    new_construction.setLayer(layernumber, cloned_layer)
  end
  return new_construction
end

#construction_set_glazing_shgc(construction, target_shgc) ⇒ Bool

Sets the U-value of a construction to a specified value by modifying the thickness of the insulation layer.

Parameters:

  • target_shgc (Double)

    Solar Heat Gain Coefficient

Returns:

  • (Bool)

    returns true if successful, false if not



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 217

def construction_set_glazing_shgc(construction, target_shgc)
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "Setting SHGC for #{construction.name}.")

  # Skip layer-by-layer fenestration constructions
  unless construction_simple_glazing?(construction)
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Construction', "Can only set the SHGC of simple glazing. #{construction.name} is not simple glazing.")
    return false
  end

  # Set the SHGC
  glass_layer = construction.layers.first.to_SimpleGlazing.get
  glass_layer.setSolarHeatGainCoefficient(target_shgc)
  glass_layer.setName("#{glass_layer.name} SHGC #{target_shgc.round(2)}")

  # Modify the construction name
  construction.setName("#{construction.name} SHGC #{target_shgc.round(2)}")

  return true
end

#construction_set_glazing_tvis(construction, target_tvis) ⇒ Bool

Sets the T-vis of a simple glazing construction to a specified value by modifying the thickness of the insulation layer.

Parameters:

  • target_tvis (Double)

    Visible Transmittance

Returns:

  • (Bool)

    returns true if successful, false if not



662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 662

def construction_set_glazing_tvis(construction, target_tvis)
  if target_tvis >= 1.0
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Construction', "Can only set the Tvis can only be set to less than 1.0. #{target_tvis} is greater than 1.0")
    return false
  end

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "Setting TVis for #{construction.name} to #{target_tvis}")
  standard = Standard.new
  # Skip layer-by-layer fenestration constructions
  unless standard.construction_simple_glazing?(construction)
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Construction', "Can only set the Tvis of simple glazing. #{construction.name} is not simple glazing.")
    return false
  end

  # Set the Tvis
  glass_layer = construction.layers.first.to_SimpleGlazing.get
  glass_layer.setVisibleTransmittance(target_tvis)
  glass_layer.setName("#{glass_layer.name} TVis #{target_tvis.round(3)}")

  # Modify the construction name
  construction.setName("#{construction.name} TVis #{target_tvis.round(2)}")
  return true
end

#construction_set_glazing_u_value(construction, target_u_value_ip, intended_surface_type = 'ExteriorWall', target_includes_int_film_coefficients, target_includes_ext_film_coefficients) ⇒ Bool

Sets the U-value of a construction to a specified value by modifying the thickness of the insulation layer.

Parameters:

  • target_u_value_ip (Double)

    U-Value (Btu/ft^2*hr*R)

  • intended_surface_type (String) (defaults to: 'ExteriorWall')

    Valid choices: ‘AtticFloor’, ‘AtticWall’, ‘AtticRoof’, ‘DemisingFloor’, ‘InteriorFloor’, ‘InteriorCeiling’, ‘DemisingWall’, ‘InteriorWall’, ‘InteriorPartition’, ‘InteriorWindow’, ‘InteriorDoor’, ‘DemisingRoof’, ‘ExteriorRoof’, ‘Skylight’, ‘TubularDaylightDome’, ‘TubularDaylightDiffuser’, ‘ExteriorFloor’, ‘ExteriorWall’, ‘ExteriorWindow’, ‘ExteriorDoor’, ‘GlassDoor’, ‘OverheadDoor’, ‘GroundContactFloor’, ‘GroundContactWall’, ‘GroundContactRoof’

  • target_includes_int_film_coefficients (Bool)

    if true, subtracts off standard film interior coefficients from your target_u_value before modifying insulation thickness. Film values from 90.1-2010 A9.4.1 Air Films

  • target_includes_ext_film_coefficients (Bool)

    if true, subtracts off standard exterior film coefficients from your target_u_value before modifying insulation thickness. Film values from 90.1-2010 A9.4.1 Air Films

Returns:

  • (Bool)

    returns true if successful, false if not



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 136

def construction_set_glazing_u_value(construction, target_u_value_ip, intended_surface_type = 'ExteriorWall', target_includes_int_film_coefficients, target_includes_ext_film_coefficients)
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "Setting U-Value for #{construction.name}.")

  # Skip layer-by-layer fenestration constructions
  unless construction_simple_glazing?(construction)
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Construction', "Can only set the u-value of simple glazing. #{construction.name} is not simple glazing.")
    return false
  end

  glass_layer = construction.layers.first.to_SimpleGlazing.get
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---glass_layer = #{glass_layer.name} u_factor_si = #{glass_layer.uFactor.round(2)}.")

  # Convert the target U-value to SI
  target_u_value_ip = target_u_value_ip.to_f
  target_r_value_ip = 1.0 / target_u_value_ip

  target_u_value_si = OpenStudio.convert(target_u_value_ip, 'Btu/ft^2*hr*R', 'W/m^2*K').get
  target_r_value_si = 1.0 / target_u_value_si

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "#{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---target_u_value_ip = #{target_u_value_ip.round(3)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---target_r_value_ip = #{target_r_value_ip.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---target_u_value_si = #{target_u_value_si.round(3)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---target_r_value_si = #{target_r_value_si.round(2)} for #{construction.name}.")

  # Determine the R-value of the air films, if requested
  film_coeff_r_value_si = 0.0
  # In EnergyPlus, the U-factor input of the WindowMaterial:SimpleGlazingSystem
  # object includes the film coefficients (see IDD description, and I/O reference
  # guide) so the target_includes_int_film_coefficients and target_includes_ext_film_coefficients
  # variable values are changed to their opposite so if the target value includes a film
  # the target value is unchanged
  film_coeff_r_value_si += film_coefficients_r_value(intended_surface_type, !target_includes_int_film_coefficients, !target_includes_ext_film_coefficients)
  film_coeff_u_value_si = 1.0 / film_coeff_r_value_si
  film_coeff_u_value_ip = OpenStudio.convert(film_coeff_u_value_si, 'W/m^2*K', 'Btu/ft^2*hr*R').get
  film_coeff_r_value_ip = 1.0 / film_coeff_u_value_ip

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---film_coeff_r_value_si = #{film_coeff_r_value_si.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---film_coeff_u_value_si = #{film_coeff_u_value_si.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---film_coeff_u_value_ip = #{film_coeff_u_value_ip.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---film_coeff_r_value_ip = #{film_coeff_r_value_ip.round(2)} for #{construction.name}.")

  # Determine the difference between the desired R-value
  # and the R-value of the and air films.
  # This is the desired R-value of the insulation.
  ins_r_value_si = target_r_value_si - film_coeff_r_value_si
  if ins_r_value_si <= 0.0
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Construction', "Requested U-value of #{target_u_value_ip} Btu/ft^2*hr*R for #{construction.name} is too high given the film coefficients of U-#{film_coeff_u_value_ip.round(2)} Btu/ft^2*hr*R; U-value will not be modified.")
    return false
  end
  ins_u_value_si = 1.0 / ins_r_value_si

  if ins_u_value_si > 7.0
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Construction', "Requested U-value of #{target_u_value_ip} for #{construction.name} is too high given the film coefficients of U-#{film_coeff_u_value_ip.round(2)}; setting U-value to EnergyPlus limit of 7.0 W/m^2*K (1.23 Btu/ft^2*hr*R).")
    ins_u_value_si = 7.0
  end

  ins_u_value_ip = OpenStudio.convert(ins_u_value_si, 'W/m^2*K', 'Btu/ft^2*hr*R').get
  ins_r_value_ip = 1.0 / ins_u_value_ip

  # Set the U-value of the insulation layer
  glass_layer = construction.layers.first.to_SimpleGlazing.get
  glass_layer.setUFactor(ins_u_value_si)
  glass_layer.setName("#{glass_layer.name} U-#{ins_u_value_ip.round(2)}")

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---ins_r_value_ip = #{ins_r_value_ip.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---ins_u_value_ip = #{ins_u_value_ip.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---ins_u_value_si = #{ins_u_value_si.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---glass_layer = #{glass_layer.name} u_factor_si = #{glass_layer.uFactor.round(2)}.")

  # Modify the construction name
  construction.setName("#{construction.name} U-#{target_u_value_ip.round(2)}")

  return true
end

#construction_set_slab_f_factor(construction, target_f_factor_ip, insulation_layer_name = nil) ⇒ Bool

Set the F-Factor of a slab to a specified value. Assumes an unheated, fully insulated slab, and modifies the insulation layer according to the values from 90.1-2004 Table A6.3 Assembly F-Factors for Slab-on-Grade Floors.

Parameters:

  • target_f_factor_ip (Double)

    F-Factor

  • insulation_layer_name (String) (defaults to: nil)

    The name of the insulation layer in this construction

Returns:

  • (Bool)

    returns true if successful, false if not



263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 263

def construction_set_slab_f_factor(construction, target_f_factor_ip, insulation_layer_name = nil)
  # Regression from table A6.3 unheated, fully insulated slab
  r_value_ip = 1.0248 * target_f_factor_ip**-2.186
  u_value_ip = 1.0 / r_value_ip

  # Set the insulation U-value
  construction_set_u_value(construction, u_value_ip, insulation_layer_name, 'GroundContactFloor', true, true)

  # Modify the construction name
  construction.setName("#{construction.name} F-#{target_f_factor_ip.round(3)}")

  return true
end

#construction_set_u_value(construction, target_u_value_ip, insulation_layer_name = nil, intended_surface_type = 'ExteriorWall', target_includes_int_film_coefficients, target_includes_ext_film_coefficients) ⇒ Bool

TODO:

Put in Phlyroy’s logic for inferring the insulation layer of a construction

Sets the U-value of a construction to a specified value by modifying the thickness of the insulation layer.

Parameters:

  • target_u_value_ip (Double)

    U-Value (Btu/ft^2*hr*R)

  • insulation_layer_name (String) (defaults to: nil)

    The name of the insulation layer in this construction

  • intended_surface_type (String) (defaults to: 'ExteriorWall')

    Valid choices: ‘AtticFloor’, ‘AtticWall’, ‘AtticRoof’, ‘DemisingFloor’, ‘InteriorFloor’, ‘InteriorCeiling’, ‘DemisingWall’, ‘InteriorWall’, ‘InteriorPartition’, ‘InteriorWindow’, ‘InteriorDoor’, ‘DemisingRoof’, ‘ExteriorRoof’, ‘Skylight’, ‘TubularDaylightDome’, ‘TubularDaylightDiffuser’, ‘ExteriorFloor’, ‘ExteriorWall’, ‘ExteriorWindow’, ‘ExteriorDoor’, ‘GlassDoor’, ‘OverheadDoor’, ‘GroundContactFloor’, ‘GroundContactWall’, ‘GroundContactRoof’

  • target_includes_int_film_coefficients (Bool)

    if true, subtracts off standard film interior coefficients from your target_u_value before modifying insulation thickness. Film values from 90.1-2010 A9.4.1 Air Films

  • target_includes_ext_film_coefficients (Bool)

    if true, subtracts off standard exterior film coefficients from your target_u_value before modifying insulation thickness. Film values from 90.1-2010 A9.4.1 Air Films

Returns:

  • (Bool)

    returns true if successful, false if not



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 21

def construction_set_u_value(construction, target_u_value_ip, insulation_layer_name = nil, intended_surface_type = 'ExteriorWall', target_includes_int_film_coefficients, target_includes_ext_film_coefficients)
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "Setting U-Value for #{construction.name}.")

  # Skip layer-by-layer fenestration constructions
  if construction.isFenestration
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Construction', "Can only set the u-value of opaque constructions or simple glazing. #{construction.name} is not opaque or simple glazing.")
    return false
  end

  # Make sure an insulation layer was specified
  if insulation_layer_name.nil? && target_u_value_ip == 0.0
    # Do nothing if the construction already doesn't have an insulation layer
  elsif insulation_layer_name.nil?
    insulation_layer_name = find_and_set_insulaton_layer(construction).name
  end

  # Remove the insulation layer if the specified U-value is zero.
  if target_u_value_ip == 0.0
    layer_index = 0
    construction.layers.each do |layer|
      break if layer.name.get == insulation_layer_name

      layer_index += 1
    end
    construction.eraseLayer(layer_index)
    return true
  end

  min_r_value_si = film_coefficients_r_value(intended_surface_type, target_includes_int_film_coefficients, target_includes_ext_film_coefficients)
  max_u_value_si = 1.0 / min_r_value_si
  max_u_value_ip = OpenStudio.convert(max_u_value_si, 'W/m^2*K', 'Btu/ft^2*hr*R').get
  if target_u_value_ip >= max_u_value_ip
    target_u_value_ip = 1.0 / OpenStudio.convert(min_r_value_si + 0.001, 'm^2*K/W', 'ft^2*hr*R/Btu').get
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Construction', "Requested U-value of #{target_u_value_ip} for #{construction.name} is greater than the sum of the inside and outside resistance, and the max U-value (6.636 SI) is used instead.")
  end

  # Convert the target U-value to SI
  target_u_value_ip = target_u_value_ip.to_f
  target_r_value_ip = 1.0 / target_u_value_ip

  target_u_value_si = OpenStudio.convert(target_u_value_ip, 'Btu/ft^2*hr*R', 'W/m^2*K').get
  target_r_value_si = 1.0 / target_u_value_si

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "#{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---target_u_value_ip = #{target_u_value_ip.round(3)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---target_r_value_ip = #{target_r_value_ip.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---target_u_value_si = #{target_u_value_si.round(3)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Construction', "---target_r_value_si = #{target_r_value_si.round(2)} for #{construction.name}.")

  # Determine the R-value of the non-insulation layers
  other_layer_r_value_si = 0.0
  construction.layers.each do |layer|
    next if layer.to_OpaqueMaterial.empty?
    next if layer.name.get == insulation_layer_name

    other_layer_r_value_si += layer.to_OpaqueMaterial.get.thermalResistance
  end

  # Determine the R-value of the air films, if requested
  other_layer_r_value_si += film_coefficients_r_value(intended_surface_type, target_includes_int_film_coefficients, target_includes_ext_film_coefficients)

  # Determine the difference between the desired R-value
  # and the R-value of the non-insulation layers and air films.
  # This is the desired R-value of the insulation.
  ins_r_value_si = target_r_value_si - other_layer_r_value_si
  if ins_r_value_si <= 0.0
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Construction', "Requested U-value of #{target_u_value_ip} for #{construction.name} is too low given the other materials in the construction; insulation layer will not be modified.")
    return false
  end
  ins_r_value_ip = OpenStudio.convert(ins_r_value_si, 'm^2*K/W', 'ft^2*h*R/Btu').get

  # Set the R-value of the insulation layer
  construction.layers.each do |layer|
    next unless layer.name.get == insulation_layer_name

    if layer.to_StandardOpaqueMaterial.is_initialized
      layer = layer.to_StandardOpaqueMaterial.get
      layer.setThickness(ins_r_value_si * layer.conductivity)
      layer.setName("#{layer.name} R-#{ins_r_value_ip.round(2)}")
      break # Stop looking for the insulation layer once found
    elsif layer.to_MasslessOpaqueMaterial.is_initialized
      layer = layer.to_MasslessOpaqueMaterial.get
      layer.setThermalResistance(ins_r_value_si)
      layer.setName("#{layer.name} R-#{ins_r_value_ip.round(2)}")
      break # Stop looking for the insulation layer once found
    elsif layer.to_AirGap.is_initialized
      layer = layer.to_AirGap.get
      target_thickness = ins_r_value_si * layer.thermalConductivity
      layer.setThickness(target_thickness)
      layer.setName("#{layer.name} R-#{ins_r_value_ip.round(2)}")
      break # Stop looking for the insulation layer once found
    end
  end

  # Modify the construction name
  construction.setName("#{construction.name} R-#{target_r_value_ip.round(2)}")

  return true
end

#construction_set_underground_wall_c_factor(construction, target_c_factor_ip, insulation_layer_name = nil) ⇒ Bool

Set the C-Factor of an underground wall to a specified value. Assumes continuous exterior insulation and modifies the insulation layer according to the values from 90.1-2004 Table A4.2 Assembly C-Factors for Below-Grade walls.

Parameters:

  • target_c_factor_ip (Double)

    C-Factor

  • insulation_layer_name (String) (defaults to: nil)

    The name of the insulation layer in this construction

Returns:

  • (Bool)

    returns true if successful, false if not



285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 285

def construction_set_underground_wall_c_factor(construction, target_c_factor_ip, insulation_layer_name = nil)
  # Regression from table A4.2 continuous exterior insulation
  r_value_ip = 0.775 * target_c_factor_ip**-1.067
  u_value_ip = 1.0 / r_value_ip

  # Set the insulation U-value
  construction_set_u_value(construction, u_value_ip, insulation_layer_name, 'GroundContactWall', true, true)

  # Modify the construction name
  construction.setName("#{construction.name} C-#{target_c_factor_ip.round(3)}")

  return true
end

#construction_simple_glazing?(construction) ⇒ Bool

Determines if the construction is a simple glazing construction, as indicated by having a single layer of type SimpleGlazing.

Returns:

  • (Bool)

    returns true if it is a simple glazing, false if not.



240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 240

def construction_simple_glazing?(construction)
  # Not simple if more than 1 layer
  if construction.layers.length > 1
    return false
  end

  # Not simple unless the layer is a SimpleGlazing material
  if construction.layers.first.to_SimpleGlazing.empty?
    return false
  end

  # If here, must be simple glazing
  return true
end

#controller_water_coil_set_convergence_limits(controller_water_coil) ⇒ Bool

Sets the convergence tolerance to 0.0001 deltaC for all hot water coils.

@ TODO: Figure out what the reason for this is,

because it seems like a workaround for an E+ bug that was probably addressed long ago.

Returns:

  • (Bool)

    returns true if successful, false if not



9
10
11
12
13
14
15
16
17
18
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.ControllerWaterCoil.rb', line 9

def controller_water_coil_set_convergence_limits(controller_water_coil)
  controller_action = controller_water_coil.action
  if controller_action.is_initialized
    if controller_action.get == 'Normal'
      controller_water_coil.setControllerConvergenceTolerance(0.0001)
    end
  end

  return true
end

#convert_curve_biquadratic(coeffs, ip_to_si = true) ⇒ Array<Double>

Convert biquadratic curves that are a function of temperature from IP (F) to SI © or vice-versa. The curve is of the form z = C1 + C2*x + C3*x^2 + C4*y + C5*y^2 + C6*x*y where C1, C2, … are the coefficients, x is the first independent variable (in F or C) y is the second independent variable (in F or C) and z is the resulting value

Parameters:

  • coeffs (Array<Double>)

    an array of 6 coefficients, in order

Returns:

  • (Array<Double>)

    the revised coefficients in the new unit system

Author:

  • Scott Horowitz, NREL



454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 454

def convert_curve_biquadratic(coeffs, ip_to_si = true)
  if ip_to_si
    # Convert IP curves to SI curves
    si_coeffs = []
    si_coeffs << coeffs[0] + 32.0 * (coeffs[1] + coeffs[3]) + 1024.0 * (coeffs[2] + coeffs[4] + coeffs[5])
    si_coeffs << 9.0 / 5.0 * coeffs[1] + 576.0 / 5.0 * coeffs[2] + 288.0 / 5.0 * coeffs[5]
    si_coeffs << 81.0 / 25.0 * coeffs[2]
    si_coeffs << 9.0 / 5.0 * coeffs[3] + 576.0 / 5.0 * coeffs[4] + 288.0 / 5.0 * coeffs[5]
    si_coeffs << 81.0 / 25.0 * coeffs[4]
    si_coeffs << 81.0 / 25.0 * coeffs[5]
    return si_coeffs
  else
    # Convert SI curves to IP curves
    ip_coeffs = []
    ip_coeffs << coeffs[0] - 160.0 / 9.0 * (coeffs[1] + coeffs[3]) + 25_600.0 / 81.0 * (coeffs[2] + coeffs[4] + coeffs[5])
    ip_coeffs << 5.0 / 9.0 * (coeffs[1] - 320.0 / 9.0 * coeffs[2] - 160.0 / 9.0 * coeffs[5])
    ip_coeffs << 25.0 / 81.0 * coeffs[2]
    ip_coeffs << 5.0 / 9.0 * (coeffs[3] - 320.0 / 9.0 * coeffs[4] - 160.0 / 9.0 * coeffs[5])
    ip_coeffs << 25.0 / 81.0 * coeffs[4]
    ip_coeffs << 25.0 / 81.0 * coeffs[5]
    return ip_coeffs
  end
end

#cooling_tower_single_speed_apply_efficiency_and_curves(cooling_tower_single_speed) ⇒ Bool

Applies the standard efficiency ratings and typical performance curves to this object.

Returns:

  • (Bool)

    true if successful, false if not



9
10
11
12
13
# File 'lib/openstudio-standards/standards/Standards.CoolingTowerSingleSpeed.rb', line 9

def cooling_tower_single_speed_apply_efficiency_and_curves(cooling_tower_single_speed)
  cooling_tower_apply_minimum_power_per_flow(cooling_tower_single_speed)

  return true
end

#cooling_tower_two_speed_apply_efficiency_and_curves(cooling_tower_two_speed) ⇒ Bool

Applies the standard efficiency ratings and typical performance curves to this object.

Returns:

  • (Bool)

    true if successful, false if not



9
10
11
12
13
# File 'lib/openstudio-standards/standards/Standards.CoolingTowerTwoSpeed.rb', line 9

def cooling_tower_two_speed_apply_efficiency_and_curves(cooling_tower_two_speed)
  cooling_tower_apply_minimum_power_per_flow(cooling_tower_two_speed)

  return true
end

#cooling_tower_variable_speed_apply_efficiency_and_curves(cooling_tower_variable_speed) ⇒ Bool

Applies the standard efficiency ratings and typical performance curves to this object.

Returns:

  • (Bool)

    true if successful, false if not



9
10
11
12
# File 'lib/openstudio-standards/standards/Standards.CoolingTowerVariableSpeed.rb', line 9

def cooling_tower_variable_speed_apply_efficiency_and_curves(cooling_tower_variable_speed)
  cooling_tower_apply_minimum_power_per_flow(cooling_tower_variable_speed)
  return true
end

#cop_heating_to_cop_heating_no_fan(coph47, capacity_w) ⇒ Double

Convert from COP_H to COP (no fan) for heat pump heating coils

Parameters:

  • coph47 (Double)

    coefficient of performance at 47F Tdb, 42F Twb

  • capacity_w (Double)

    the heating capacity at AHRI rating conditions, in W

Returns:

  • (Double)

    Coefficient of Performance (COP)



271
272
273
274
275
276
277
278
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 271

def cop_heating_to_cop_heating_no_fan(coph47, capacity_w)
  # Convert the capacity to Btu/hr
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get

  cop = 1.48E-7 * coph47 * capacity_btu_per_hr + 1.062 * coph47

  return cop
end

#cop_to_eer(cop, capacity_w = nil) ⇒ Double

Convert from COP to EER

Parameters:

  • cop (Double)

    COP

Returns:

  • (Double)

    Energy Efficiency Ratio (EER)



331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 331

def cop_to_eer(cop, capacity_w = nil)
  if capacity_w.nil?
    # The PNNL Method.
    # r is the ratio of supply fan power to total equipment power at the rating condition,
    # assumed to be 0.12 for the reference buildngs per PNNL.
    r = 0.12
    eer = 3.413 * (cop * (1 - r) - r)
  else
    # The 90.1-2013 method
    # Convert the capacity to Btu/hr
    capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get
    eer = cop / (7.84E-8 * capacity_btu_per_hr + 0.338)
  end

  return eer
end

#cop_to_kw_per_ton(cop) ⇒ Double

Convert from COP to kW/ton

Parameters:

  • cop (Double)

    Coefficient of Performance (COP)

Returns:

  • (Double)

    kW of input power per ton of cooling



352
353
354
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 352

def cop_to_kw_per_ton(cop)
  return 3.517 / cop
end

#cop_to_seer_cooling_no_fan(cop) ⇒ Double

Convert from COP to SEER

Parameters:

  • cop (Double)

    COP

Returns:

  • (Double)

    Seasonal Energy Efficiency Ratio



233
234
235
236
237
238
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 233

def cop_to_seer_cooling_no_fan(cop)
  delta = 0.3796**2 - 4.0 * 0.0076 * cop
  seer = (-delta**0.5 + 0.3796) / (2.0 * 0.0076)

  return seer
end

#cop_to_seer_cooling_with_fan(cop) ⇒ Double

Convert from COP to SEER (with fan) for cooling coils per the method specified in 90.1-2013 Appendix G

Parameters:

  • seer (Double)

    seasonal energy efficiency ratio (SEER)

Returns:

  • (Double)

    Coefficient of Performance (COP)



257
258
259
260
261
262
263
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 257

def cop_to_seer_cooling_with_fan(cop)
  eer = cop_to_eer(cop)
  delta = 1.1088**2 - 4.0 * 0.0182 * eer
  seer = (1.1088 - delta**0.5) / (2.0 * 0.0182)

  return seer
end

#create_air_conditioner_variable_refrigerant_flow(model, name: 'VRF System', schedule: nil, type: nil, cooling_cop: 4.287, heating_cop: 4.147, heat_recovery: true, defrost_strategy: 'Resistive', condenser_type: 'AirCooled', condenser_loop: nil, master_zone: nil, priority_control_type: 'LoadPriority') ⇒ Object

Prototype AirConditionerVariableRefrigerantFlow object Enters in default curves for coil by type of coil

Parameters:

  • name (String) (defaults to: 'VRF System')

    the name of the system, or nil in which case it will be defaulted

  • schedule (String) (defaults to: nil)

    name of the availability schedule, or [<OpenStudio::Model::Schedule>] Schedule object, or nil in which case default to always on

  • type (String) (defaults to: nil)

    the type of unit to reference for the correct curve set

  • cooling_cop (Double) (defaults to: 4.287)

    rated cooling coefficient of performance

  • heating_cop (Double) (defaults to: 4.147)

    rated heating coefficient of performance

  • heat_recovery (Bool) (defaults to: true)

    does the unit have heat recovery

  • defrost_strategy (String) (defaults to: 'Resistive')

    type of defrost strategy. options are ReverseCycle or Resistive

  • condenser_type (String) (defaults to: 'AirCooled')

    type of condenser options are AirCooled (default), WaterCooled, and EvaporativelyCooled. if WaterCooled, the user most include a condenser_loop

  • master_zone (<OpenStudio::Model::ThermalZone>) (defaults to: nil)

    master control zone to switch between heating and cooling

  • priority_control_type (String) (defaults to: 'LoadPriority')

    type of master thermostat priority control type options are LoadPriority, ZonePriority, ThermostatOffsetPriority, MasterThermostatPriority



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.AirConditionerVariableRefrigerantFlow.rb', line 19

def create_air_conditioner_variable_refrigerant_flow(model,
                                                     name: 'VRF System',
                                                     schedule: nil,
                                                     type: nil,
                                                     cooling_cop: 4.287,
                                                     heating_cop: 4.147,
                                                     heat_recovery: true,
                                                     defrost_strategy: 'Resistive',
                                                     condenser_type: 'AirCooled',
                                                     condenser_loop: nil,
                                                     master_zone: nil,
                                                     priority_control_type: 'LoadPriority')

  vrf_outdoor_unit = OpenStudio::Model::AirConditionerVariableRefrigerantFlow.new(model)

  # set name
  if name.nil?
    vrf_outdoor_unit.setName('VRF System')
  else
    vrf_outdoor_unit.setName(name)
  end

  # set availability schedule
  if schedule.nil?
    # default always on
    availability_schedule = model.alwaysOnDiscreteSchedule
  elsif schedule.class == String
    availability_schedule = model_add_schedule(model, schedule)

    if availability_schedule.nil? && schedule == 'alwaysOffDiscreteSchedule'
      availability_schedule = model.alwaysOffDiscreteSchedule
    elsif availability_schedule.nil?
      availability_schedule = model.alwaysOnDiscreteSchedule
    end
  elsif !schedule.to_Schedule.empty?
    availability_schedule = schedule
  else
    availability_schedule = model.alwaysOnDiscreteSchedule
  end
  vrf_outdoor_unit.setAvailabilitySchedule(availability_schedule)

  # set cops
  vrf_outdoor_unit.setRatedCoolingCOP(cooling_cop)
  vrf_outdoor_unit.setRatedHeatingCOP(heating_cop)

  # heat recovery
  if heat_recovery
    vrf_outdoor_unit.setHeatPumpWasteHeatRecovery(true)
  else
    vrf_outdoor_unit.setHeatPumpWasteHeatRecovery(false)
  end

  # defrost strategy
  vrf_outdoor_unit.setDefrostStrategy(defrost_strategy)

  # defaults
  vrf_outdoor_unit.setMinimumOutdoorTemperatureinCoolingMode(-15.0)
  vrf_outdoor_unit.setMaximumOutdoorTemperatureinCoolingMode(50.0)
  vrf_outdoor_unit.setMinimumOutdoorTemperatureinHeatingMode(-25.0)
  vrf_outdoor_unit.setMaximumOutdoorTemperatureinHeatingMode(16.1)
  vrf_outdoor_unit.setMinimumOutdoorTemperatureinHeatRecoveryMode(-10.0)
  vrf_outdoor_unit.setMaximumOutdoorTemperatureinHeatRecoveryMode(27.2)
  vrf_outdoor_unit.setEquivalentPipingLengthusedforPipingCorrectionFactorinCoolingMode(30.48)
  vrf_outdoor_unit.setEquivalentPipingLengthusedforPipingCorrectionFactorinHeatingMode(30.48)
  vrf_outdoor_unit.setVerticalHeightusedforPipingCorrectionFactor(10.668)

  # condenser type
  if condenser_type == 'WaterCooled'
    vrf_outdoor_unit.setString(56, condenser_type)
    # require condenser_loop
    unless condenser_loop
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', 'Must specify condenser_loop for vrf_outdoor_unit if WaterCooled')
    end
    condenser_loop.addDemandBranchForComponent(vrf_outdoor_unit)
  elsif condenser_type == 'EvaporativelyCooled'
    vrf_outdoor_unit.setString(56, condenser_type)
  end

  # set master zone
  unless master_zone.to_ThermalZone.empty?
    vrf_outdoor_unit.setZoneforMasterThermostatLocation(master_zone)
    vrf_outdoor_unit.setMasterThermostatPriorityControlType(priority_control_type)
  end

  vrf_cool_cap_f_of_low_temp = nil
  vrf_cool_cap_ratio_boundary = nil
  vrf_cool_cap_f_of_high_temp = nil
  vrf_cool_eir_f_of_low_temp = nil
  vrf_cool_eir_ratio_boundary = nil
  vrf_cool_eir_f_of_high_temp = nil
  vrf_cooling_eir_low_plr = nil
  vrf_cooling_eir_high_plr = nil
  vrf_cooling_comb_ratio = nil
  vrf_cooling_cplffplr = nil
  vrf_heat_cap_f_of_low_temp = nil
  vrf_heat_cap_ratio_boundary = nil
  vrf_heat_cap_f_of_high_temp = nil
  vrf_heat_eir_f_of_low_temp = nil
  vrf_heat_eir_boundary = nil
  vrf_heat_eir_f_of_high_temp = nil
  vrf_heating_eir_low_plr = nil
  vrf_heating_eir_hi_plr = nil
  vrf_heating_comb_ratio = nil
  vrf_heating_cplffplr = nil
  vrf_defrost_eir_f_of_temp = nil

  # curve sets
  if type == 'OS default'

    # use OS default curves

  else # default curve set

    # based on DAIKINREYQ 120 on BCL

    # Cooling Capacity Ratio Modifier Function of Low Temperature Curve
    vrf_cool_cap_f_of_low_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    vrf_cool_cap_f_of_low_temp.setName('vrf_cool_cap_f_of_low_temp')
    vrf_cool_cap_f_of_low_temp.setCoefficient1Constant(-1.69653019339465)
    vrf_cool_cap_f_of_low_temp.setCoefficient2x(0.207248180531939)
    vrf_cool_cap_f_of_low_temp.setCoefficient3xPOW2(-0.00343146229659024)
    vrf_cool_cap_f_of_low_temp.setCoefficient4y(0.016381597419714)
    vrf_cool_cap_f_of_low_temp.setCoefficient5yPOW2(-6.7387172629965e-05)
    vrf_cool_cap_f_of_low_temp.setCoefficient6xTIMESY(-0.000849848402870241)
    vrf_cool_cap_f_of_low_temp.setMinimumValueofx(13.9)
    vrf_cool_cap_f_of_low_temp.setMaximumValueofx(23.9)
    vrf_cool_cap_f_of_low_temp.setMinimumValueofy(-5.0)
    vrf_cool_cap_f_of_low_temp.setMaximumValueofy(43.3)
    vrf_cool_cap_f_of_low_temp.setMinimumCurveOutput(0.59)
    vrf_cool_cap_f_of_low_temp.setMaximumCurveOutput(1.33)

    # Cooling Capacity Ratio Boundary Curve
    vrf_cool_cap_ratio_boundary = OpenStudio::Model::CurveCubic.new(model)
    vrf_cool_cap_ratio_boundary.setName('vrf_cool_cap_ratio_boundary')
    vrf_cool_cap_ratio_boundary.setCoefficient1Constant(25.73)
    vrf_cool_cap_ratio_boundary.setCoefficient2x(-0.03150043)
    vrf_cool_cap_ratio_boundary.setCoefficient3xPOW2(-0.01416595)
    vrf_cool_cap_ratio_boundary.setCoefficient4xPOW3(0.0)
    vrf_cool_cap_ratio_boundary.setMinimumValueofx(11.0)
    vrf_cool_cap_ratio_boundary.setMaximumValueofx(30.0)

    # Cooling Capacity Ratio Modifier Function of High Temperature Curve
    vrf_cool_cap_f_of_high_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    vrf_cool_cap_f_of_high_temp.setName('vrf_cool_cap_f_of_high_temp')
    vrf_cool_cap_f_of_high_temp.setCoefficient1Constant(0.6867358)
    vrf_cool_cap_f_of_high_temp.setCoefficient2x(0.0207631)
    vrf_cool_cap_f_of_high_temp.setCoefficient3xPOW2(0.0005447)
    vrf_cool_cap_f_of_high_temp.setCoefficient4y(-0.0016218)
    vrf_cool_cap_f_of_high_temp.setCoefficient5yPOW2(-4.259e-07)
    vrf_cool_cap_f_of_high_temp.setCoefficient6xTIMESY(-0.0003392)
    vrf_cool_cap_f_of_high_temp.setMinimumValueofx(15.0)
    vrf_cool_cap_f_of_high_temp.setMaximumValueofx(24.0)
    vrf_cool_cap_f_of_high_temp.setMinimumValueofy(16.0)
    vrf_cool_cap_f_of_high_temp.setMaximumValueofy(43.0)

    # Cooling Energy Input Ratio Modifier Function of Low Temperature Curve
    vrf_cool_eir_f_of_low_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    vrf_cool_eir_f_of_low_temp.setName('vrf_cool_eir_f_of_low_temp')
    vrf_cool_eir_f_of_low_temp.setCoefficient1Constant(-1.61908214818635)
    vrf_cool_eir_f_of_low_temp.setCoefficient2x(0.185964818731756)
    vrf_cool_eir_f_of_low_temp.setCoefficient3xPOW2(-0.00389610393381592)
    vrf_cool_eir_f_of_low_temp.setCoefficient4y(-0.00901995326324613)
    vrf_cool_eir_f_of_low_temp.setCoefficient5yPOW2(0.00030340007815629)
    vrf_cool_eir_f_of_low_temp.setCoefficient6xTIMESY(0.000476048529099348)
    vrf_cool_eir_f_of_low_temp.setMinimumValueofx(13.9)
    vrf_cool_eir_f_of_low_temp.setMaximumValueofx(23.9)
    vrf_cool_eir_f_of_low_temp.setMinimumValueofy(-5.0)
    vrf_cool_eir_f_of_low_temp.setMaximumValueofy(43.3)
    vrf_cool_eir_f_of_low_temp.setMinimumCurveOutput(0.27)
    vrf_cool_eir_f_of_low_temp.setMaximumCurveOutput(1.15)

    # Cooling Energy Input Ratio Boundary Curve
    vrf_cool_eir_ratio_boundary = OpenStudio::Model::CurveCubic.new(model)
    vrf_cool_eir_ratio_boundary.setName('vrf_cool_eir_ratio_boundary')
    vrf_cool_eir_ratio_boundary.setCoefficient1Constant(25.73473775)
    vrf_cool_eir_ratio_boundary.setCoefficient2x(-0.03150043)
    vrf_cool_eir_ratio_boundary.setCoefficient3xPOW2(-0.01416595)
    vrf_cool_eir_ratio_boundary.setCoefficient4xPOW3(0.0)
    vrf_cool_eir_ratio_boundary.setMinimumValueofx(15.0)
    vrf_cool_eir_ratio_boundary.setMaximumValueofx(24.0)

    # Cooling Energy Input Ratio Modifier Function of High Temperature Curve
    vrf_cool_eir_f_of_high_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    vrf_cool_eir_f_of_high_temp.setName('vrf_cool_eir_f_of_high_temp')
    vrf_cool_eir_f_of_high_temp.setCoefficient1Constant(-1.4395110176)
    vrf_cool_eir_f_of_high_temp.setCoefficient2x(0.1619850459)
    vrf_cool_eir_f_of_high_temp.setCoefficient3xPOW2(-0.0034911781)
    vrf_cool_eir_f_of_high_temp.setCoefficient4y(0.0269442645)
    vrf_cool_eir_f_of_high_temp.setCoefficient5yPOW2(0.0001346163)
    vrf_cool_eir_f_of_high_temp.setCoefficient6xTIMESY(-0.0006714941)
    vrf_cool_eir_f_of_high_temp.setMinimumValueofx(15.0)
    vrf_cool_eir_f_of_high_temp.setMaximumValueofx(23.9)
    vrf_cool_eir_f_of_high_temp.setMinimumValueofy(16.8)
    vrf_cool_eir_f_of_high_temp.setMaximumValueofy(43.3)

    # Cooling Energy Input Ratio Modifier Function of Low Part-Load Ratio Curve
    vrf_cooling_eir_low_plr = OpenStudio::Model::CurveCubic.new(model)
    vrf_cooling_eir_low_plr.setName('vrf_cool_eir_f_of_low_temp')
    vrf_cooling_eir_low_plr.setCoefficient1Constant(0.0734992169827752)
    vrf_cooling_eir_low_plr.setCoefficient2x(0.334783365234032)
    vrf_cooling_eir_low_plr.setCoefficient3xPOW2(0.591613015486343)
    vrf_cooling_eir_low_plr.setCoefficient4xPOW3(0.0)
    vrf_cooling_eir_low_plr.setMinimumValueofx(0.25)
    vrf_cooling_eir_low_plr.setMaximumValueofx(1.0)
    vrf_cooling_eir_low_plr.setMinimumCurveOutput(0.0)
    vrf_cooling_eir_low_plr.setMaximumCurveOutput(1.0)

    # Cooling Energy Input Ratio Modifier Function of High Part-Load Ratio Curve
    vrf_cooling_eir_high_plr = OpenStudio::Model::CurveCubic.new(model)
    vrf_cooling_eir_high_plr.setName('vrf_cooling_eir_high_plr')
    vrf_cooling_eir_high_plr.setCoefficient1Constant(1.0)
    vrf_cooling_eir_high_plr.setCoefficient2x(0.0)
    vrf_cooling_eir_high_plr.setCoefficient3xPOW2(0.0)
    vrf_cooling_eir_high_plr.setCoefficient4xPOW3(0.0)
    vrf_cooling_eir_high_plr.setMinimumValueofx(1.0)
    vrf_cooling_eir_high_plr.setMaximumValueofx(1.5)

    # Cooling Combination Ratio Correction Factor Curve
    vrf_cooling_comb_ratio = OpenStudio::Model::CurveCubic.new(model)
    vrf_cooling_comb_ratio.setName('vrf_cooling_comb_ratio')
    vrf_cooling_comb_ratio.setCoefficient1Constant(0.24034)
    vrf_cooling_comb_ratio.setCoefficient2x(-0.21873)
    vrf_cooling_comb_ratio.setCoefficient3xPOW2(1.97941)
    vrf_cooling_comb_ratio.setCoefficient4xPOW3(-1.02636)
    vrf_cooling_comb_ratio.setMinimumValueofx(0.5)
    vrf_cooling_comb_ratio.setMaximumValueofx(2.0)
    vrf_cooling_comb_ratio.setMinimumCurveOutput(0.5)
    vrf_cooling_comb_ratio.setMaximumCurveOutput(1.056)

    # Cooling Part-Load Fraction Correlation Curve
    vrf_cooling_cplffplr = OpenStudio::Model::CurveCubic.new(model)
    vrf_cooling_cplffplr.setName('vrf_cooling_cplffplr')
    vrf_cooling_cplffplr.setCoefficient1Constant(0.85)
    vrf_cooling_cplffplr.setCoefficient2x(0.15)
    vrf_cooling_cplffplr.setCoefficient3xPOW2(0.0)
    vrf_cooling_cplffplr.setCoefficient4xPOW3(0.0)
    vrf_cooling_cplffplr.setMinimumValueofx(1.0)
    vrf_cooling_cplffplr.setMaximumValueofx(1.0)

    # Heating Capacity Ratio Modifier Function of Low Temperature Curve Name
    vrf_heat_cap_f_of_low_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    vrf_heat_cap_f_of_low_temp.setName('vrf_heat_cap_f_of_low_temp')
    vrf_heat_cap_f_of_low_temp.setCoefficient1Constant(0.983220174655636)
    vrf_heat_cap_f_of_low_temp.setCoefficient2x(0.0157167577703294)
    vrf_heat_cap_f_of_low_temp.setCoefficient3xPOW2(-0.000835032422884084)
    vrf_heat_cap_f_of_low_temp.setCoefficient4y(0.0522939264581759)
    vrf_heat_cap_f_of_low_temp.setCoefficient5yPOW2(-0.000531556035364549)
    vrf_heat_cap_f_of_low_temp.setCoefficient6xTIMESY(-0.00190605953116024)
    vrf_heat_cap_f_of_low_temp.setMinimumValueofx(16.1)
    vrf_heat_cap_f_of_low_temp.setMaximumValueofx(23.9)
    vrf_heat_cap_f_of_low_temp.setMinimumValueofy(-25.0)
    vrf_heat_cap_f_of_low_temp.setMaximumValueofy(13.3)
    vrf_heat_cap_f_of_low_temp.setMinimumCurveOutput(0.515151515151515)
    vrf_heat_cap_f_of_low_temp.setMaximumCurveOutput(1.2)

    # Heating Capacity Ratio Boundary Curve Name
    vrf_heat_cap_ratio_boundary = OpenStudio::Model::CurveCubic.new(model)
    vrf_heat_cap_ratio_boundary.setName('vrf_heat_cap_ratio_boundary')
    vrf_heat_cap_ratio_boundary.setCoefficient1Constant(58.577)
    vrf_heat_cap_ratio_boundary.setCoefficient2x(-3.0255)
    vrf_heat_cap_ratio_boundary.setCoefficient3xPOW2(0.0193)
    vrf_heat_cap_ratio_boundary.setCoefficient4xPOW3(0.0)
    vrf_heat_cap_ratio_boundary.setMinimumValueofx(15)
    vrf_heat_cap_ratio_boundary.setMaximumValueofx(23.9)

    # Heating Capacity Ratio Modifier Function of High Temperature Curve Name
    vrf_heat_cap_f_of_high_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    vrf_heat_cap_f_of_high_temp.setName('vrf_heat_cap_f_of_high_temp')
    vrf_heat_cap_f_of_high_temp.setCoefficient1Constant(2.5859872368)
    vrf_heat_cap_f_of_high_temp.setCoefficient2x(-0.0953227101)
    vrf_heat_cap_f_of_high_temp.setCoefficient3xPOW2(0.0009553288)
    vrf_heat_cap_f_of_high_temp.setCoefficient4y(0.0)
    vrf_heat_cap_f_of_high_temp.setCoefficient5yPOW2(0.0)
    vrf_heat_cap_f_of_high_temp.setCoefficient6xTIMESY(0.0)
    vrf_heat_cap_f_of_high_temp.setMinimumValueofx(21.1)
    vrf_heat_cap_f_of_high_temp.setMaximumValueofx(27.2)
    vrf_heat_cap_f_of_high_temp.setMinimumValueofy(-944)
    vrf_heat_cap_f_of_high_temp.setMaximumValueofy(15)

    # Heating Energy Input Ratio Modifier Function of Low Temperature Curve Name
    vrf_heat_eir_f_of_low_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    vrf_heat_eir_f_of_low_temp.setName('vrf_heat_eir_f_of_low_temp')
    vrf_heat_eir_f_of_low_temp.setCoefficient1Constant(0.756830029796909)
    vrf_heat_eir_f_of_low_temp.setCoefficient2x(0.0457499799042671)
    vrf_heat_eir_f_of_low_temp.setCoefficient3xPOW2(-0.00136357240431388)
    vrf_heat_eir_f_of_low_temp.setCoefficient4y(0.0554884599902023)
    vrf_heat_eir_f_of_low_temp.setCoefficient5yPOW2(-0.00120700875497686)
    vrf_heat_eir_f_of_low_temp.setCoefficient6xTIMESY(-0.00303329271420931)
    vrf_heat_eir_f_of_low_temp.setMinimumValueofx(16.1)
    vrf_heat_eir_f_of_low_temp.setMaximumValueofx(23.9)
    vrf_heat_eir_f_of_low_temp.setMinimumValueofy(-25.0)
    vrf_heat_eir_f_of_low_temp.setMaximumValueofy(13.3)
    vrf_heat_eir_f_of_low_temp.setMinimumCurveOutput(0.7)
    vrf_heat_eir_f_of_low_temp.setMaximumCurveOutput(1.184)

    # Heating Energy Input Ratio Boundary Curve Name
    vrf_heat_eir_boundary = OpenStudio::Model::CurveCubic.new(model)
    vrf_heat_eir_boundary.setName('vrf_heat_eir_boundary')
    vrf_heat_eir_boundary.setCoefficient1Constant(58.577)
    vrf_heat_eir_boundary.setCoefficient2x(-3.0255)
    vrf_heat_eir_boundary.setCoefficient3xPOW2(0.0193)
    vrf_heat_eir_boundary.setCoefficient4xPOW3(0.0)
    vrf_heat_eir_boundary.setMinimumValueofx(15.0)
    vrf_heat_eir_boundary.setMaximumValueofx(23.9)

    # Heating Energy Input Ratio Modifier Function of High Temperature Curve Name
    vrf_heat_eir_f_of_high_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    vrf_heat_eir_f_of_high_temp.setName('vrf_heat_eir_f_of_high_temp')
    vrf_heat_eir_f_of_high_temp.setCoefficient1Constant(1.3885703646)
    vrf_heat_eir_f_of_high_temp.setCoefficient2x(-0.0229771462)
    vrf_heat_eir_f_of_high_temp.setCoefficient3xPOW2(0.000537274)
    vrf_heat_eir_f_of_high_temp.setCoefficient4y(-0.0273936962)
    vrf_heat_eir_f_of_high_temp.setCoefficient5yPOW2(0.0004030426)
    vrf_heat_eir_f_of_high_temp.setCoefficient6xTIMESY(-5.9786e-05)
    vrf_heat_eir_f_of_high_temp.setMinimumValueofx(21.1)
    vrf_heat_eir_f_of_high_temp.setMaximumValueofx(27.2)
    vrf_heat_eir_f_of_high_temp.setMinimumValueofy(0.0)
    vrf_heat_eir_f_of_high_temp.setMaximumValueofy(1.0)

    # Heating Performance Curve Outdoor Temperature Type
    vrf_outdoor_unit.setHeatingPerformanceCurveOutdoorTemperatureType('WetBulbTemperature')

    # Heating Energy Input Ratio Modifier Function of Low Part-Load Ratio Curve Name
    vrf_heating_eir_low_plr = OpenStudio::Model::CurveCubic.new(model)
    vrf_heating_eir_low_plr.setName('vrf_heating_eir_low_plr')
    vrf_heating_eir_low_plr.setCoefficient1Constant(0.0724906507105475)
    vrf_heating_eir_low_plr.setCoefficient2x(0.658189977561701)
    vrf_heating_eir_low_plr.setCoefficient3xPOW2(0.269259536275246)
    vrf_heating_eir_low_plr.setCoefficient4xPOW3(0.0)
    vrf_heating_eir_low_plr.setMinimumValueofx(0.25)
    vrf_heating_eir_low_plr.setMaximumValueofx(1.0)
    vrf_heating_eir_low_plr.setMinimumCurveOutput(0.0)
    vrf_heating_eir_low_plr.setMaximumCurveOutput(1.0)

    # Heating Energy Input Ratio Modifier Function of High Part-Load Ratio Curve Name
    vrf_heating_eir_hi_plr = OpenStudio::Model::CurveCubic.new(model)
    vrf_heating_eir_hi_plr.setName('vrf_heating_eir_hi_plr')
    vrf_heating_eir_hi_plr.setCoefficient1Constant(1.0)
    vrf_heating_eir_hi_plr.setCoefficient2x(0.0)
    vrf_heating_eir_hi_plr.setCoefficient3xPOW2(0.0)
    vrf_heating_eir_hi_plr.setCoefficient4xPOW3(0.0)
    vrf_heating_eir_hi_plr.setMinimumValueofx(1.0)
    vrf_heating_eir_hi_plr.setMaximumValueofx(1.5)

    # Heating Combination Ratio Correction Factor Curve Name
    vrf_heating_comb_ratio = OpenStudio::Model::CurveCubic.new(model)
    vrf_heating_comb_ratio.setName('vrf_heating_comb_ratio')
    vrf_heating_comb_ratio.setCoefficient1Constant(0.62115)
    vrf_heating_comb_ratio.setCoefficient2x(-1.55798)
    vrf_heating_comb_ratio.setCoefficient3xPOW2(3.36817)
    vrf_heating_comb_ratio.setCoefficient4xPOW3(-1.4224)
    vrf_heating_comb_ratio.setMinimumValueofx(0.5)
    vrf_heating_comb_ratio.setMaximumValueofx(2.0)
    vrf_heating_comb_ratio.setMinimumCurveOutput(0.5)
    vrf_heating_comb_ratio.setMaximumCurveOutput(1.155)

    # Heating Part-Load Fraction Correlation Curve Name
    vrf_heating_cplffplr = OpenStudio::Model::CurveCubic.new(model)
    vrf_heating_cplffplr.setName('vrf_heating_cplffplr')
    vrf_heating_cplffplr.setCoefficient1Constant(0.85)
    vrf_heating_cplffplr.setCoefficient2x(0.15)
    vrf_heating_cplffplr.setCoefficient3xPOW2(0.0)
    vrf_heating_cplffplr.setCoefficient4xPOW3(0.0)
    vrf_heating_cplffplr.setMinimumValueofx(1.0)
    vrf_heating_cplffplr.setMaximumValueofx(1.0)

    # Defrost Energy Input Ratio Modifier Function of Temperature Curve
    vrf_defrost_eir_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    vrf_defrost_eir_f_of_temp.setName('vrf_defrost_eir_f_of_temp')
    vrf_defrost_eir_f_of_temp.setCoefficient1Constant(-1.61908214818635)
    vrf_defrost_eir_f_of_temp.setCoefficient2x(0.185964818731756)
    vrf_defrost_eir_f_of_temp.setCoefficient3xPOW2(-0.00389610393381592)
    vrf_defrost_eir_f_of_temp.setCoefficient4y(-0.00901995326324613)
    vrf_defrost_eir_f_of_temp.setCoefficient5yPOW2(0.00030340007815629)
    vrf_defrost_eir_f_of_temp.setCoefficient6xTIMESY(0.000476048529099348)
    vrf_defrost_eir_f_of_temp.setMinimumValueofx(13.9)
    vrf_defrost_eir_f_of_temp.setMaximumValueofx(23.9)
    vrf_defrost_eir_f_of_temp.setMinimumValueofy(-5.0)
    vrf_defrost_eir_f_of_temp.setMaximumValueofy(50.0)
    vrf_defrost_eir_f_of_temp.setMinimumCurveOutput(0.27)
    vrf_defrost_eir_f_of_temp.setMaximumCurveOutput(1.155)

    # set defrost control
    vrf_outdoor_unit.setDefrostStrategy('ReverseCycle')
    vrf_outdoor_unit.setDefrostControl('OnDemand')

  end

  vrf_outdoor_unit.setCoolingCapacityRatioModifierFunctionofLowTemperatureCurve(vrf_cool_cap_f_of_low_temp) unless vrf_cool_cap_f_of_low_temp.nil?
  vrf_outdoor_unit.setCoolingCapacityRatioBoundaryCurve(vrf_cool_cap_ratio_boundary) unless vrf_cool_cap_ratio_boundary.nil?
  vrf_outdoor_unit.setCoolingCapacityRatioModifierFunctionofHighTemperatureCurve(vrf_cool_cap_f_of_high_temp) unless vrf_cool_cap_f_of_high_temp.nil?
  vrf_outdoor_unit.setCoolingEnergyInputRatioModifierFunctionofLowTemperatureCurve(vrf_cool_eir_f_of_low_temp) unless vrf_cool_eir_f_of_low_temp.nil?
  vrf_outdoor_unit.setCoolingEnergyInputRatioBoundaryCurve(vrf_cool_eir_ratio_boundary) unless vrf_cool_eir_ratio_boundary.nil?
  vrf_outdoor_unit.setCoolingEnergyInputRatioModifierFunctionofHighTemperatureCurve(vrf_cool_eir_f_of_high_temp) unless vrf_cool_eir_f_of_high_temp.nil?
  vrf_outdoor_unit.setCoolingEnergyInputRatioModifierFunctionofLowPartLoadRatioCurve(vrf_cooling_eir_low_plr) unless vrf_cooling_eir_low_plr.nil?
  vrf_outdoor_unit.setCoolingEnergyInputRatioModifierFunctionofHighPartLoadRatioCurve(vrf_cooling_eir_high_plr) unless vrf_cooling_eir_high_plr.nil?
  vrf_outdoor_unit.setCoolingCombinationRatioCorrectionFactorCurve(vrf_cooling_comb_ratio) unless vrf_cooling_comb_ratio.nil?
  vrf_outdoor_unit.setCoolingPartLoadFractionCorrelationCurve(vrf_cooling_cplffplr) unless vrf_cooling_cplffplr.nil?
  vrf_outdoor_unit.setHeatingCapacityRatioModifierFunctionofLowTemperatureCurve(vrf_heat_cap_f_of_low_temp) unless vrf_heat_cap_f_of_low_temp.nil?
  vrf_outdoor_unit.setHeatingCapacityRatioBoundaryCurve(vrf_heat_cap_ratio_boundary) unless vrf_heat_cap_ratio_boundary.nil?
  vrf_outdoor_unit.setHeatingCapacityRatioModifierFunctionofHighTemperatureCurve(vrf_heat_cap_f_of_high_temp) unless vrf_heat_cap_f_of_high_temp.nil?
  vrf_outdoor_unit.setHeatingEnergyInputRatioModifierFunctionofLowTemperatureCurve(vrf_heat_eir_f_of_low_temp) unless vrf_heat_eir_f_of_low_temp.nil?
  vrf_outdoor_unit.setHeatingEnergyInputRatioBoundaryCurve(vrf_heat_eir_boundary) unless vrf_heat_eir_boundary.nil?
  vrf_outdoor_unit.setHeatingEnergyInputRatioModifierFunctionofHighTemperatureCurve(vrf_heat_eir_f_of_high_temp) unless vrf_heat_eir_f_of_high_temp.nil?
  vrf_outdoor_unit.setHeatingEnergyInputRatioModifierFunctionofLowPartLoadRatioCurve(vrf_heating_eir_low_plr) unless vrf_heating_eir_low_plr.nil?
  vrf_outdoor_unit.setHeatingEnergyInputRatioModifierFunctionofHighPartLoadRatioCurve(vrf_heating_eir_hi_plr) unless vrf_heating_eir_hi_plr.nil?
  vrf_outdoor_unit.setHeatingCombinationRatioCorrectionFactorCurve(vrf_heating_comb_ratio) unless vrf_heating_comb_ratio.nil?
  vrf_outdoor_unit.setHeatingPartLoadFractionCorrelationCurve(vrf_heating_cplffplr) unless vrf_heating_cplffplr.nil?
  vrf_outdoor_unit.setDefrostEnergyInputRatioModifierFunctionofTemperatureCurve(vrf_defrost_eir_f_of_temp) unless vrf_defrost_eir_f_of_temp.nil?

  return vrf_outdoor_unit
end

#create_boiler_hot_water(model, hot_water_loop: nil, name: 'Boiler', fuel_type: 'NaturalGas', draft_type: 'Natural', nominal_thermal_efficiency: 0.80, eff_curve_temp_eval_var: 'LeavingBoiler', flow_mode: 'LeavingSetpointModulated', lvg_temp_dsgn: 180.0, out_temp_lmt: 203.0, min_plr: 0.0, max_plr: 1.2, opt_plr: 1.0, sizing_factor: nil) ⇒ Object

Prototype BoilerHotWater object

Parameters:

  • hot_water_loop (<OpenStudio::Model::PlantLoop>) (defaults to: nil)

    a hot water loop served by the boiler

  • name (String) (defaults to: 'Boiler')

    the name of the boiler, or nil in which case it will be defaulted

  • fuel_type (String) (defaults to: 'NaturalGas')

    type of fuel serving the boiler

  • draft_type (String) (defaults to: 'Natural')

    Boiler type Condensing, MechanicalNoncondensing, Natural (default)

  • nominal_thermal_efficiency (Double) (defaults to: 0.80)

    boiler nominal thermal efficiency

  • eff_curve_temp_eval_var (String) (defaults to: 'LeavingBoiler')

    LeavingBoiler or EnteringBoiler temperature for the boiler efficiency curve

  • flow_mode (String) (defaults to: 'LeavingSetpointModulated')

    boiler flow mode

  • lvg_temp_dsgn (Double) (defaults to: 180.0)

    boiler leaving design temperature, degrees Fahrenheit note that this field is deprecated in OS versions 3.0+

  • out_temp_lmt (Double) (defaults to: 203.0)

    boiler outlet temperature limit, degrees Fahrenheit

  • min_plr (Double) (defaults to: 0.0)

    boiler minimum part load ratio

  • max_plr (Double) (defaults to: 1.2)

    boiler maximum part load ratio

  • opt_plr (Double) (defaults to: 1.0)

    boiler optimum part load ratio

  • sizing_factor (Double) (defaults to: nil)

    boiler oversizing factor



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.BoilerHotWater.rb', line 20

def create_boiler_hot_water(model,
                            hot_water_loop: nil,
                            name: 'Boiler',
                            fuel_type: 'NaturalGas',
                            draft_type: 'Natural',
                            nominal_thermal_efficiency: 0.80,
                            eff_curve_temp_eval_var: 'LeavingBoiler',
                            flow_mode: 'LeavingSetpointModulated',
                            lvg_temp_dsgn: 180.0,
                            out_temp_lmt: 203.0, # 95C
                            min_plr: 0.0,
                            max_plr: 1.2,
                            opt_plr: 1.0,
                            sizing_factor: nil)

  # create the boiler
  boiler = OpenStudio::Model::BoilerHotWater.new(model)
  if name.nil?
    if !hot_water_loop.nil?
      boiler.setName("#{hot_water_loop.name} Boiler")
    else
      boiler.setName('Boiler')
    end
  else
    boiler.setName(name)
  end

  if fuel_type.nil? || fuel_type == 'Gas'
    boiler.setFuelType('NaturalGas')
  else
    boiler.setFuelType(fuel_type)
  end

  if nominal_thermal_efficiency.nil?
    boiler.setNominalThermalEfficiency(0.8)
  else
    boiler.setNominalThermalEfficiency(nominal_thermal_efficiency)
  end

  if eff_curve_temp_eval_var.nil?
    boiler.setEfficiencyCurveTemperatureEvaluationVariable('LeavingBoiler')
  else
    boiler.setEfficiencyCurveTemperatureEvaluationVariable(eff_curve_temp_eval_var)
  end

  if flow_mode.nil?
    boiler.setBoilerFlowMode('LeavingSetpointModulated')
  else
    boiler.setBoilerFlowMode(flow_mode)
  end

  if model.version < OpenStudio::VersionString.new('3.0.0')
    if lvg_temp_dsgn.nil?
      boiler.setDesignWaterOutletTemperature(OpenStudio.convert(180.0, 'F', 'C').get)
    else
      boiler.setDesignWaterOutletTemperature(OpenStudio.convert(lvg_temp_dsgn, 'F', 'C').get)
    end
  end

  if !out_temp_lmt.nil?
    boiler.setWaterOutletUpperTemperatureLimit(OpenStudio.convert(203.0, 'F', 'C').get)
  else
    boiler.setWaterOutletUpperTemperatureLimit(OpenStudio.convert(out_temp_lmt, 'F', 'C').get)
  end

  # logic to set different defaults for condensing boilers if not specified
  if draft_type == 'Condensing'
    if model.version < OpenStudio::VersionString.new('3.0.0')
      boiler.setDesignWaterOutletTemperature(OpenStudio.convert(120.0, 'F', 'C').get) if lvg_temp_dsgn.nil?
    end
    boiler.setNominalThermalEfficiency(0.96) if nominal_thermal_efficiency.nil?
  end

  if min_plr.nil?
    boiler.setMinimumPartLoadRatio(0.0)
  else
    boiler.setMinimumPartLoadRatio(min_plr)
  end

  if max_plr.nil?
    boiler.setMaximumPartLoadRatio(1.2)
  else
    boiler.setMaximumPartLoadRatio(max_plr)
  end

  if opt_plr.nil?
    boiler.setOptimumPartLoadRatio(1.0)
  else
    boiler.setOptimumPartLoadRatio(opt_plr)
  end

  boiler.setSizingFactor(sizing_factor) unless sizing_factor.nil?

  # add to supply side of hot water loop if specified
  hot_water_loop.addSupplyBranchForComponent(boiler) unless hot_water_loop.nil?

  return boiler
end

#create_central_air_source_heat_pump(model, hot_water_loop, name: nil, cop: 3.65) ⇒ Object

TODO:

update curve to better calculate based on the rated cop

TODO:

refactor to use the new EnergyPlus central air source heat pump object when it becomes available set hot_water_loop to an optional keyword argument, and add input keyword arguments for other characteristics

Prototype CentralAirSourceHeatPump object using PlantComponentUserDefined

Parameters:

  • hot_water_loop (<OpenStudio::Model::PlantLoop>)

    a hot water loop served by the central air source heat pump

  • name (String) (defaults to: nil)

    the name of the central air source heat pump, or nil in which case it will be defaulted

  • cop (Double) (defaults to: 3.65)

    air source heat pump rated cop



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.CentralAirSourceHeatPump.rb', line 12

def create_central_air_source_heat_pump(model,
                                        hot_water_loop,
                                        name: nil,
                                        cop: 3.65)

  # create the PlantComponentUserDefined object as a proxy for the Central Air Source Heat Pump
  plant_comp = OpenStudio::Model::PlantComponentUserDefined.new(model)
  if name.nil?
    if !hot_water_loop.nil?
      name = "#{hot_water_loop.name} Central Air Source Heat Pump"
    else
      name = 'Central Air Source Heat Pump'
    end
  end

  # change equipment name for EMS validity
  plant_comp.setName(name.gsub(/[ +-.]/, '_'))

  # set plant component properties
  plant_comp.setPlantLoadingMode('MeetsLoadWithNominalCapacityHiOutLimit')
  plant_comp.setPlantLoopFlowRequestMode('NeedsFlowIfLoopIsOn')

  # plant design volume flow rate internal variable
  vdot_des_int_var = OpenStudio::Model::EnergyManagementSystemInternalVariable.new(model, 'Plant Design Volume Flow Rate')
  vdot_des_int_var.setName("#{plant_comp.name}_Vdot_Des_Int_Var")
  vdot_des_int_var.setInternalDataIndexKeyName(hot_water_loop.handle.to_s)

  # inlet temperature internal variable
  tin_int_var = OpenStudio::Model::EnergyManagementSystemInternalVariable.new(model, 'Inlet Temperature for Plant Connection 1')
  tin_int_var.setName("#{plant_comp.name}_Tin_Int_Var")
  tin_int_var.setInternalDataIndexKeyName(plant_comp.handle.to_s)

  # inlet mass flow rate internal variable
  mdot_int_var = OpenStudio::Model::EnergyManagementSystemInternalVariable.new(model, 'Inlet Mass Flow Rate for Plant Connection 1')
  mdot_int_var.setName("#{plant_comp.name}_Mdot_Int_Var")
  mdot_int_var.setInternalDataIndexKeyName(plant_comp.handle.to_s)

  # inlet specific heat internal variable
  cp_int_var = OpenStudio::Model::EnergyManagementSystemInternalVariable.new(model, 'Inlet Specific Heat for Plant Connection 1')
  cp_int_var.setName("#{plant_comp.name}_Cp_Int_Var")
  cp_int_var.setInternalDataIndexKeyName(plant_comp.handle.to_s)

  # inlet density internal variable
  rho_int_var = OpenStudio::Model::EnergyManagementSystemInternalVariable.new(model, 'Inlet Density for Plant Connection 1')
  rho_int_var.setName("#{plant_comp.name}_rho_Int_Var")
  rho_int_var.setInternalDataIndexKeyName(plant_comp.handle.to_s)

  # load request internal variable
  load_int_var = OpenStudio::Model::EnergyManagementSystemInternalVariable.new(model, 'Load Request for Plant Connection 1')
  load_int_var.setName("#{plant_comp.name}_Load_Int_Var")
  load_int_var.setInternalDataIndexKeyName(plant_comp.handle.to_s)

  # supply outlet node setpoint temperature sensor
  setpt_mgr_sch_sen = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Schedule Value')
  setpt_mgr_sch_sen.setName("#{plant_comp.name}_Setpt_Mgr_Temp_Sen")
  hot_water_loop.supplyOutletNode.setpointManagers.each do |m|
    if m.to_SetpointManagerScheduled.is_initialized
      setpt_mgr_sch_sen.setKeyName(m.to_SetpointManagerScheduled.get.schedule.name.to_s)
    end
  end

  # outdoor air drybulb temperature sensor
  oa_dbt_sen = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Site Outdoor Air Drybulb Temperature')
  oa_dbt_sen.setName("#{plant_comp.name}_OA_DBT_Sen")
  oa_dbt_sen.setKeyName('Environment')

  # minimum mass flow rate actuator
  mdot_min_act = plant_comp.minimumMassFlowRateActuator.get
  mdot_min_act.setName("#{plant_comp.name}_Mdot_Min_Act")

  # maximum mass flow rate actuator
  mdot_max_act = plant_comp.maximumMassFlowRateActuator.get
  mdot_max_act.setName("#{plant_comp.name}_Mdot_Max_Act")

  # design flow rate actuator
  vdot_des_act = plant_comp.designVolumeFlowRateActuator.get
  vdot_des_act.setName("#{plant_comp.name}_Vdot_Des_Act")

  # minimum loading capacity actuator
  cap_min_act = plant_comp.minimumLoadingCapacityActuator.get
  cap_min_act.setName("#{plant_comp.name}_Cap_Min_Act")

  # maximum loading capacity actuator
  cap_max_act = plant_comp.maximumLoadingCapacityActuator.get
  cap_max_act.setName("#{plant_comp.name}_Cap_Max_Act")

  # optimal loading capacity actuator
  cap_opt_act = plant_comp.optimalLoadingCapacityActuator.get
  cap_opt_act.setName("#{plant_comp.name}_Cap_Opt_Act")

  # outlet temperature actuator
  tout_act = plant_comp.outletTemperatureActuator.get
  tout_act.setName("#{plant_comp.name}_Tout_Act")

  # mass flow rate actuator
  mdot_req_act = plant_comp.massFlowRateActuator.get
  mdot_req_act.setName("#{plant_comp.name}_Mdot_Req_Act")

  # heat pump COP curve
  constant_coeff = 1.932 + (cop - 3.65)
  hp_cop_curve = OpenStudio::Model::CurveQuadratic.new(model)
  hp_cop_curve.setCoefficient1Constant(constant_coeff)
  hp_cop_curve.setCoefficient2x(0.227674286)
  hp_cop_curve.setCoefficient3xPOW2(-0.007313143)
  hp_cop_curve.setMinimumValueofx(1.67)
  hp_cop_curve.setMaximumValueofx(12.78)
  hp_cop_curve.setInputUnitTypeforX('Temperature')
  hp_cop_curve.setOutputUnitType('Dimensionless')

  # heat pump COP curve index variable
  hp_cop_curve_idx_var = OpenStudio::Model::EnergyManagementSystemCurveOrTableIndexVariable.new(model, hp_cop_curve)

  # high outlet temperature limit actuator
  tout_max_act = OpenStudio::Model::EnergyManagementSystemActuator.new(plant_comp, 'Plant Connection 1', 'High Outlet Temperature Limit')
  tout_max_act.setName("#{plant_comp.name}_Tout_Max_Act")

  # init program
  init_pgrm = plant_comp.plantInitializationProgram.get
  init_pgrm.setName("#{plant_comp.name}_Init_Pgrm")
  init_pgrm_body = <<-EMS
  SET Loop_Exit_Temp = #{hot_water_loop.sizingPlant.designLoopExitTemperature}
  SET Loop_Delta_Temp = #{hot_water_loop.sizingPlant.loopDesignTemperatureDifference}
  SET Cp = @CPHW Loop_Exit_Temp
  SET rho = @RhoH2O Loop_Exit_Temp
  SET #{vdot_des_act.handle} = #{vdot_des_int_var.handle}
  SET #{mdot_min_act.handle} = 0
  SET Mdot_Max = #{vdot_des_int_var.handle} * rho
  SET #{mdot_max_act.handle} = Mdot_Max
  SET Cap = Mdot_Max * Cp * Loop_Delta_Temp
  SET #{cap_min_act.handle} = 0
  SET #{cap_max_act.handle} = Cap
  SET #{cap_opt_act.handle} = 1 * Cap
  EMS
  init_pgrm.setBody(init_pgrm_body)

  # sim program
  sim_pgrm = plant_comp.plantSimulationProgram.get
  sim_pgrm.setName("#{plant_comp.name}_Sim_Pgrm")
  sim_pgrm_body = <<-EMS
  SET tmp = #{load_int_var.handle}
  SET tmp = #{tin_int_var.handle}
  SET tmp = #{mdot_int_var.handle}
  SET #{tout_max_act.handle} = 75.0
  IF #{load_int_var.handle} == 0
  SET #{tout_act.handle} = #{tin_int_var.handle}
  SET #{mdot_req_act.handle} = 0
  SET Elec = 0
  RETURN
  ENDIF
  IF #{load_int_var.handle} >= #{cap_max_act.handle}
  SET Qdot = #{cap_max_act.handle}
  SET Mdot = #{mdot_max_act.handle}
  SET #{mdot_req_act.handle} = Mdot
  SET #{tout_act.handle} = (Qdot / (Mdot * #{cp_int_var.handle})) + #{tin_int_var.handle}
  IF #{tout_act.handle} > #{tout_max_act.handle}
  SET #{tout_act.handle} = #{tout_max_act.handle}
  SET Qdot = Mdot * #{cp_int_var.handle} * (#{tout_act.handle} - #{tin_int_var.handle})
  ENDIF
  ELSE
  SET Qdot = #{load_int_var.handle}
  SET #{tout_act.handle} = #{setpt_mgr_sch_sen.handle}
  SET Mdot = Qdot / (#{cp_int_var.handle} * (#{tout_act.handle} - #{tin_int_var.handle}))
  SET #{mdot_req_act.handle} = Mdot
  ENDIF
  SET Tdb = #{oa_dbt_sen.handle}
  SET COP = @CurveValue #{hp_cop_curve_idx_var.handle} Tdb
  SET EIR = 1 / COP
  SET Pwr = Qdot * EIR
  SET Elec = Pwr * SystemTimestep * 3600
  EMS
  sim_pgrm.setBody(sim_pgrm_body)

  # init program calling manager
  init_mgr = plant_comp.plantInitializationProgramCallingManager.get
  init_mgr.setName("#{plant_comp.name}_Init_Pgrm_Mgr")

  # sim program calling manager
  sim_mgr = plant_comp.plantSimulationProgramCallingManager.get
  sim_mgr.setName("#{plant_comp.name}_Sim_Pgrm_Mgr")

  # metered output variable
  elec_mtr_out_var = OpenStudio::Model::EnergyManagementSystemMeteredOutputVariable.new(model, "#{plant_comp.name} Electricity Consumption")
  elec_mtr_out_var.setName("#{plant_comp.name} Electricity Consumption")
  elec_mtr_out_var.setEMSVariableName('Elec')
  elec_mtr_out_var.setUpdateFrequency('SystemTimestep')
  elec_mtr_out_var.setString(4, sim_pgrm.handle.to_s)
  elec_mtr_out_var.setResourceType('Electricity')
  elec_mtr_out_var.setGroupType('HVAC')
  elec_mtr_out_var.setEndUseCategory('Heating')
  elec_mtr_out_var.setEndUseSubcategory('')
  elec_mtr_out_var.setUnits('J')

  # add to supply side of hot water loop if specified
  hot_water_loop.addSupplyBranchForComponent(plant_comp) unless hot_water_loop.nil?

  # add operation scheme
  htg_op_scheme = OpenStudio::Model::PlantEquipmentOperationHeatingLoad.new(model)
  htg_op_scheme.addEquipment(1000000000, plant_comp)
  hot_water_loop.setPlantEquipmentOperationHeatingLoad(htg_op_scheme)

  return plant_comp
end

#create_coil_cooling_dx_single_speed(model, air_loop_node: nil, name: '1spd DX Clg Coil', schedule: nil, type: nil, cop: nil) ⇒ Object

Prototype CoilCoolingDXSingleSpeed object Enters in default curves for coil by type of coil

Parameters:

  • air_loop_node (<OpenStudio::Model::Node>) (defaults to: nil)

    the coil will be placed on this node of the air loop

  • name (String) (defaults to: '1spd DX Clg Coil')

    the name of the system, or nil in which case it will be defaulted

  • schedule (String) (defaults to: nil)

    name of the availability schedule, or [<OpenStudio::Model::Schedule>] Schedule object, or nil in which case default to always on

  • type (String) (defaults to: nil)

    the type of single speed DX coil to reference the correct curve set

  • cop (Double) (defaults to: nil)

    rated cooling coefficient of performance



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.CoilCoolingDXSingleSpeed.rb', line 11

def create_coil_cooling_dx_single_speed(model,
                                        air_loop_node: nil,
                                        name: '1spd DX Clg Coil',
                                        schedule: nil,
                                        type: nil,
                                        cop: nil)

  clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model)

  # add to air loop if specified
  clg_coil.addToNode(air_loop_node) unless air_loop_node.nil?

  # set coil name
  clg_coil.setName(name)

  # set coil availability schedule
  if schedule.nil?
    # default always on
    coil_availability_schedule = model.alwaysOnDiscreteSchedule
  elsif schedule.class == String
    coil_availability_schedule = model_add_schedule(model, schedule)

    if coil_availability_schedule.nil? && schedule == 'alwaysOffDiscreteSchedule'
      coil_availability_schedule = model.alwaysOffDiscreteSchedule
    elsif coil_availability_schedule.nil?
      coil_availability_schedule = model.alwaysOnDiscreteSchedule
    end
  elsif !schedule.to_Schedule.empty?
    coil_availability_schedule = schedule
  else
    coil_availability_schedule = model.alwaysOnDiscreteSchedule
  end
  clg_coil.setAvailabilitySchedule(coil_availability_schedule)

  # set coil cop
  clg_coil.setRatedCOP(cop) unless cop.nil?

  clg_cap_f_of_temp = nil
  clg_cap_f_of_flow = nil
  clg_energy_input_ratio_f_of_temp = nil
  clg_energy_input_ratio_f_of_flow = nil
  clg_part_load_ratio = nil

  # curve sets
  case type
  when 'OS default'
    # use OS defaults

  when 'Heat Pump'
    # "PSZ-AC_Unitary_PackagecoolCapFT"
    clg_cap_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    clg_cap_f_of_temp.setCoefficient1Constant(0.766956)
    clg_cap_f_of_temp.setCoefficient2x(0.0107756)
    clg_cap_f_of_temp.setCoefficient3xPOW2(-0.0000414703)
    clg_cap_f_of_temp.setCoefficient4y(0.00134961)
    clg_cap_f_of_temp.setCoefficient5yPOW2(-0.000261144)
    clg_cap_f_of_temp.setCoefficient6xTIMESY(0.000457488)
    clg_cap_f_of_temp.setMinimumValueofx(12.78)
    clg_cap_f_of_temp.setMaximumValueofx(23.89)
    clg_cap_f_of_temp.setMinimumValueofy(21.1)
    clg_cap_f_of_temp.setMaximumValueofy(46.1)

    clg_cap_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)
    clg_cap_f_of_flow.setCoefficient1Constant(0.8)
    clg_cap_f_of_flow.setCoefficient2x(0.2)
    clg_cap_f_of_flow.setCoefficient3xPOW2(0.0)
    clg_cap_f_of_flow.setMinimumValueofx(0.5)
    clg_cap_f_of_flow.setMaximumValueofx(1.5)

    clg_energy_input_ratio_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    clg_energy_input_ratio_f_of_temp.setCoefficient1Constant(0.297145)
    clg_energy_input_ratio_f_of_temp.setCoefficient2x(0.0430933)
    clg_energy_input_ratio_f_of_temp.setCoefficient3xPOW2(-0.000748766)
    clg_energy_input_ratio_f_of_temp.setCoefficient4y(0.00597727)
    clg_energy_input_ratio_f_of_temp.setCoefficient5yPOW2(0.000482112)
    clg_energy_input_ratio_f_of_temp.setCoefficient6xTIMESY(-0.000956448)
    clg_energy_input_ratio_f_of_temp.setMinimumValueofx(12.78)
    clg_energy_input_ratio_f_of_temp.setMaximumValueofx(23.89)
    clg_energy_input_ratio_f_of_temp.setMinimumValueofy(21.1)
    clg_energy_input_ratio_f_of_temp.setMaximumValueofy(46.1)

    clg_energy_input_ratio_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)
    clg_energy_input_ratio_f_of_flow.setCoefficient1Constant(1.156)
    clg_energy_input_ratio_f_of_flow.setCoefficient2x(-0.1816)
    clg_energy_input_ratio_f_of_flow.setCoefficient3xPOW2(0.0256)
    clg_energy_input_ratio_f_of_flow.setMinimumValueofx(0.5)
    clg_energy_input_ratio_f_of_flow.setMaximumValueofx(1.5)

    clg_part_load_ratio = OpenStudio::Model::CurveQuadratic.new(model)
    clg_part_load_ratio.setCoefficient1Constant(0.85)
    clg_part_load_ratio.setCoefficient2x(0.15)
    clg_part_load_ratio.setCoefficient3xPOW2(0.0)
    clg_part_load_ratio.setMinimumValueofx(0.0)
    clg_part_load_ratio.setMaximumValueofx(1.0)

  when 'PSZ-AC'
    # Defaults to "DOE Ref DX Clg Coil Cool-Cap-fT"
    clg_cap_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    clg_cap_f_of_temp.setCoefficient1Constant(0.9712123)
    clg_cap_f_of_temp.setCoefficient2x(-0.015275502)
    clg_cap_f_of_temp.setCoefficient3xPOW2(0.0014434524)
    clg_cap_f_of_temp.setCoefficient4y(-0.00039321)
    clg_cap_f_of_temp.setCoefficient5yPOW2(-0.0000068364)
    clg_cap_f_of_temp.setCoefficient6xTIMESY(-0.0002905956)
    clg_cap_f_of_temp.setMinimumValueofx(-100.0)
    clg_cap_f_of_temp.setMaximumValueofx(100.0)
    clg_cap_f_of_temp.setMinimumValueofy(-100.0)
    clg_cap_f_of_temp.setMaximumValueofy(100.0)

    clg_cap_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)
    clg_cap_f_of_flow.setCoefficient1Constant(1.0)
    clg_cap_f_of_flow.setCoefficient2x(0.0)
    clg_cap_f_of_flow.setCoefficient3xPOW2(0.0)
    clg_cap_f_of_flow.setMinimumValueofx(-100.0)
    clg_cap_f_of_flow.setMaximumValueofx(100.0)

    # "DOE Ref DX Clg Coil Cool-EIR-fT",
    clg_energy_input_ratio_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    clg_energy_input_ratio_f_of_temp.setCoefficient1Constant(0.28687133)
    clg_energy_input_ratio_f_of_temp.setCoefficient2x(0.023902164)
    clg_energy_input_ratio_f_of_temp.setCoefficient3xPOW2(-0.000810648)
    clg_energy_input_ratio_f_of_temp.setCoefficient4y(0.013458546)
    clg_energy_input_ratio_f_of_temp.setCoefficient5yPOW2(0.0003389364)
    clg_energy_input_ratio_f_of_temp.setCoefficient6xTIMESY(-0.0004870044)
    clg_energy_input_ratio_f_of_temp.setMinimumValueofx(-100.0)
    clg_energy_input_ratio_f_of_temp.setMaximumValueofx(100.0)
    clg_energy_input_ratio_f_of_temp.setMinimumValueofy(-100.0)
    clg_energy_input_ratio_f_of_temp.setMaximumValueofy(100.0)

    clg_energy_input_ratio_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)
    clg_energy_input_ratio_f_of_flow.setCoefficient1Constant(1.0)
    clg_energy_input_ratio_f_of_flow.setCoefficient2x(0.0)
    clg_energy_input_ratio_f_of_flow.setCoefficient3xPOW2(0.0)
    clg_energy_input_ratio_f_of_flow.setMinimumValueofx(-100.0)
    clg_energy_input_ratio_f_of_flow.setMaximumValueofx(100.0)

    # "DOE Ref DX Clg Coil Cool-PLF-fPLR"
    clg_part_load_ratio = OpenStudio::Model::CurveQuadratic.new(model)
    clg_part_load_ratio.setCoefficient1Constant(0.90949556)
    clg_part_load_ratio.setCoefficient2x(0.09864773)
    clg_part_load_ratio.setCoefficient3xPOW2(-0.00819488)
    clg_part_load_ratio.setMinimumValueofx(0.0)
    clg_part_load_ratio.setMaximumValueofx(1.0)
    clg_part_load_ratio.setMinimumCurveOutput(0.7)
    clg_part_load_ratio.setMaximumCurveOutput(1.0)

  when 'Window AC'
    # Performance curves
    # From Frigidaire 10.7 EER unit in Winkler et. al. Lab Testing of Window ACs (2013)
    # NOTE: These coefficients are in SI UNITS
    cool_cap_ft_coeffs_si = [0.6405, 0.01568, 0.0004531, 0.001615, -0.0001825, 0.00006614]
    cool_eir_ft_coeffs_si = [2.287, -0.1732, 0.004745, 0.01662, 0.000484, -0.001306]
    cool_cap_fflow_coeffs = [0.887, 0.1128, 0]
    cool_eir_fflow_coeffs = [1.763, -0.6081, 0]
    cool_plf_fplr_coeffs = [0.78, 0.22, 0]

    # Make the curves
    clg_cap_f_of_temp = create_curve_biquadratic(model, cool_cap_ft_coeffs_si, 'RoomAC-Cap-fT', 0, 100, 0, 100, nil, nil)
    clg_cap_f_of_flow = create_curve_quadratic(model, cool_cap_fflow_coeffs, 'RoomAC-Cap-fFF', 0, 2, 0, 2, is_dimensionless = true)
    clg_energy_input_ratio_f_of_temp = create_curve_biquadratic(model, cool_eir_ft_coeffs_si, 'RoomAC-EIR-fT', 0, 100, 0, 100, nil, nil)
    clg_energy_input_ratio_f_of_flow = create_curve_quadratic(model, cool_eir_fflow_coeffs, 'RoomAC-EIR-fFF', 0, 2, 0, 2, is_dimensionless = true)
    clg_part_load_ratio = create_curve_quadratic(model, cool_plf_fplr_coeffs, 'RoomAC-PLF-fPLR', 0, 1, 0, 1, is_dimensionless = true)

  when 'Residential Central AC'
    # Performance curves
    # These coefficients are in IP UNITS
    cool_cap_ft_coeffs_ip = [3.670270705, -0.098652414, 0.000955906, 0.006552414, -0.0000156, -0.000131877]
    cool_eir_ft_coeffs_ip = [-3.302695861, 0.137871531, -0.001056996, -0.012573945, 0.000214638, -0.000145054]
    cool_cap_fflow_coeffs = [0.718605468, 0.410099989, -0.128705457]
    cool_eir_fflow_coeffs = [1.32299905, -0.477711207, 0.154712157]
    cool_plf_fplr_coeffs = [0.8, 0.2, 0]

    # Convert coefficients from IP to SI
    cool_cap_ft_coeffs_si = convert_curve_biquadratic(cool_cap_ft_coeffs_ip)
    cool_eir_ft_coeffs_si = convert_curve_biquadratic(cool_eir_ft_coeffs_ip)

    # Make the curves
    clg_cap_f_of_temp = create_curve_biquadratic(model, cool_cap_ft_coeffs_si, 'AC-Cap-fT', 0, 100, 0, 100, nil, nil)
    clg_cap_f_of_flow = create_curve_quadratic(model, cool_cap_fflow_coeffs, 'AC-Cap-fFF', 0, 2, 0, 2, is_dimensionless = true)
    clg_energy_input_ratio_f_of_temp = create_curve_biquadratic(model, cool_eir_ft_coeffs_si, 'AC-EIR-fT', 0, 100, 0, 100, nil, nil)
    clg_energy_input_ratio_f_of_flow = create_curve_quadratic(model, cool_eir_fflow_coeffs, 'AC-EIR-fFF', 0, 2, 0, 2, is_dimensionless = true)
    clg_part_load_ratio = create_curve_quadratic(model, cool_plf_fplr_coeffs, 'AC-PLF-fPLR', 0, 1, 0, 1, is_dimensionless = true)

  when 'Residential Central ASHP'
    # Performance curves
    # These coefficients are in IP UNITS
    cool_cap_ft_coeffs_ip = [3.68637657, -0.098352478, 0.000956357, 0.005838141, -0.0000127, -0.000131702]
    cool_eir_ft_coeffs_ip = [-3.437356399, 0.136656369, -0.001049231, -0.0079378, 0.000185435, -0.0001441]
    cool_cap_fflow_coeffs = [0.718664047, 0.41797409, -0.136638137]
    cool_eir_fflow_coeffs = [1.143487507, -0.13943972, -0.004047787]
    cool_plf_fplr_coeffs = [0.8, 0.2, 0]

    # Convert coefficients from IP to SI
    cool_cap_ft_coeffs_si = convert_curve_biquadratic(cool_cap_ft_coeffs_ip)
    cool_eir_ft_coeffs_si = convert_curve_biquadratic(cool_eir_ft_coeffs_ip)

    # Make the curves
    clg_cap_f_of_temp = create_curve_biquadratic(model, cool_cap_ft_coeffs_si, 'Cool-Cap-fT', 0, 100, 0, 100, nil, nil)
    clg_cap_f_of_flow = create_curve_quadratic(model, cool_cap_fflow_coeffs, 'Cool-Cap-fFF', 0, 2, 0, 2, is_dimensionless = true)
    clg_energy_input_ratio_f_of_temp = create_curve_biquadratic(model, cool_eir_ft_coeffs_si, 'Cool-EIR-fT', 0, 100, 0, 100, nil, nil)
    clg_energy_input_ratio_f_of_flow = create_curve_quadratic(model, cool_eir_fflow_coeffs, 'Cool-EIR-fFF', 0, 2, 0, 2, is_dimensionless = true)
    clg_part_load_ratio = create_curve_quadratic(model, cool_plf_fplr_coeffs, 'Cool-PLF-fPLR', 0, 1, 0, 1, is_dimensionless = true)

  else # default curve set, type == 'Split AC' || 'PTAC'
    clg_cap_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    clg_cap_f_of_temp.setCoefficient1Constant(0.942587793)
    clg_cap_f_of_temp.setCoefficient2x(0.009543347)
    clg_cap_f_of_temp.setCoefficient3xPOW2(0.00068377)
    clg_cap_f_of_temp.setCoefficient4y(-0.011042676)
    clg_cap_f_of_temp.setCoefficient5yPOW2(0.000005249)
    clg_cap_f_of_temp.setCoefficient6xTIMESY(-0.00000972)
    clg_cap_f_of_temp.setMinimumValueofx(12.77778)
    clg_cap_f_of_temp.setMaximumValueofx(23.88889)
    clg_cap_f_of_temp.setMinimumValueofy(23.88889)
    clg_cap_f_of_temp.setMaximumValueofy(46.11111)

    clg_cap_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)
    clg_cap_f_of_flow.setCoefficient1Constant(0.8)
    clg_cap_f_of_flow.setCoefficient2x(0.2)
    clg_cap_f_of_flow.setCoefficient3xPOW2(0)
    clg_cap_f_of_flow.setMinimumValueofx(0.5)
    clg_cap_f_of_flow.setMaximumValueofx(1.5)

    clg_energy_input_ratio_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    clg_energy_input_ratio_f_of_temp.setCoefficient1Constant(0.342414409)
    clg_energy_input_ratio_f_of_temp.setCoefficient2x(0.034885008)
    clg_energy_input_ratio_f_of_temp.setCoefficient3xPOW2(-0.0006237)
    clg_energy_input_ratio_f_of_temp.setCoefficient4y(0.004977216)
    clg_energy_input_ratio_f_of_temp.setCoefficient5yPOW2(0.000437951)
    clg_energy_input_ratio_f_of_temp.setCoefficient6xTIMESY(-0.000728028)
    clg_energy_input_ratio_f_of_temp.setMinimumValueofx(12.77778)
    clg_energy_input_ratio_f_of_temp.setMaximumValueofx(23.88889)
    clg_energy_input_ratio_f_of_temp.setMinimumValueofy(23.88889)
    clg_energy_input_ratio_f_of_temp.setMaximumValueofy(46.11111)

    clg_energy_input_ratio_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)
    clg_energy_input_ratio_f_of_flow.setCoefficient1Constant(1.1552)
    clg_energy_input_ratio_f_of_flow.setCoefficient2x(-0.1808)
    clg_energy_input_ratio_f_of_flow.setCoefficient3xPOW2(0.0256)
    clg_energy_input_ratio_f_of_flow.setMinimumValueofx(0.5)
    clg_energy_input_ratio_f_of_flow.setMaximumValueofx(1.5)

    clg_part_load_ratio = OpenStudio::Model::CurveQuadratic.new(model)
    clg_part_load_ratio.setCoefficient1Constant(0.85)
    clg_part_load_ratio.setCoefficient2x(0.15)
    clg_part_load_ratio.setCoefficient3xPOW2(0.0)
    clg_part_load_ratio.setMinimumValueofx(0.0)
    clg_part_load_ratio.setMaximumValueofx(1.0)
    clg_part_load_ratio.setMinimumCurveOutput(0.7)
    clg_part_load_ratio.setMaximumCurveOutput(1.0)

  end

  clg_coil.setTotalCoolingCapacityFunctionOfTemperatureCurve(clg_cap_f_of_temp) unless clg_cap_f_of_temp.nil?
  clg_coil.setTotalCoolingCapacityFunctionOfFlowFractionCurve(clg_cap_f_of_flow) unless clg_cap_f_of_flow.nil?
  clg_coil.setEnergyInputRatioFunctionOfTemperatureCurve(clg_energy_input_ratio_f_of_temp) unless clg_energy_input_ratio_f_of_temp.nil?
  clg_coil.setEnergyInputRatioFunctionOfFlowFractionCurve(clg_energy_input_ratio_f_of_flow) unless clg_energy_input_ratio_f_of_flow.nil?
  clg_coil.setPartLoadFractionCorrelationCurve(clg_part_load_ratio) unless clg_part_load_ratio.nil?

  return clg_coil
end

#create_coil_cooling_dx_two_speed(model, air_loop_node: nil, name: '2spd DX Clg Coil', schedule: nil, type: nil) ⇒ Object

Prototype CoilCoolingDXTwoSpeed object Enters in default curves for coil by type of coil

Parameters:

  • air_loop_node (<OpenStudio::Model::Node>) (defaults to: nil)

    the coil will be placed on this node of the air loop

  • name (String) (defaults to: '2spd DX Clg Coil')

    the name of the system, or nil in which case it will be defaulted

  • schedule (String) (defaults to: nil)

    name of the availability schedule, or [<OpenStudio::Model::Schedule>] Schedule object, or nil in which case default to always on

  • type (String) (defaults to: nil)

    the type of two speed DX coil to reference the correct curve set



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.CoilCoolingDXTwoSpeed.rb', line 10

def create_coil_cooling_dx_two_speed(model,
                                     air_loop_node: nil,
                                     name: '2spd DX Clg Coil',
                                     schedule: nil,
                                     type: nil)

  clg_coil = OpenStudio::Model::CoilCoolingDXTwoSpeed.new(model)

  # add to air loop if specified
  clg_coil.addToNode(air_loop_node) unless air_loop_node.nil?

  # set coil name
  clg_coil.setName(name)

  # set coil availability schedule
  if schedule.nil?
    # default always on
    coil_availability_schedule = model.alwaysOnDiscreteSchedule
  elsif schedule.class == String
    coil_availability_schedule = model_add_schedule(model, schedule)

    if coil_availability_schedule.nil? && schedule == 'alwaysOffDiscreteSchedule'
      coil_availability_schedule = model.alwaysOffDiscreteSchedule
    elsif coil_availability_schedule.nil?
      coil_availability_schedule = model.alwaysOnDiscreteSchedule
    end
  elsif !schedule.to_Schedule.empty?
    coil_availability_schedule = schedule
  else
    coil_availability_schedule = model.alwaysOnDiscreteSchedule
  end
  clg_coil.setAvailabilitySchedule(coil_availability_schedule)

  clg_cap_f_of_temp = nil
  clg_cap_f_of_flow = nil
  clg_energy_input_ratio_f_of_temp = nil
  clg_energy_input_ratio_f_of_flow = nil
  clg_part_load_ratio = nil
  clg_cap_f_of_temp_low_spd = nil
  clg_energy_input_ratio_f_of_temp_low_spd = nil

  # curve sets
  if type == 'OS default'
    # use OS defaults
  elsif type == 'Residential Minisplit HP'
    # Performance curves
    # These coefficients are in SI units
    cool_cap_ft_coeffs_si = [0.7531983499655835, 0.003618193903031667, 0.0, 0.006574385031351544, -6.87181191015432e-05, 0.0]
    cool_eir_ft_coeffs_si = [-0.06376924779982301, -0.0013360593470367282, 1.413060577993827e-05, 0.019433076486584752, -4.91395947154321e-05, -4.909341249475308e-05]
    cool_cap_fflow_coeffs = [1, 0, 0]
    cool_eir_fflow_coeffs = [1, 0, 0]
    cool_plf_fplr_coeffs = [0.89, 0.11, 0]

    # Make the curves
    clg_cap_f_of_temp = create_curve_biquadratic(model, cool_cap_ft_coeffs_si, 'Cool-Cap-fT', 0, 100, 0, 100, nil, nil)
    clg_cap_f_of_flow = create_curve_quadratic(model, cool_cap_fflow_coeffs, 'Cool-Cap-fFF', 0, 2, 0, 2, is_dimensionless = true)
    clg_energy_input_ratio_f_of_temp = create_curve_biquadratic(model, cool_eir_ft_coeffs_si, 'Cool-EIR-fT', 0, 100, 0, 100, nil, nil)
    clg_energy_input_ratio_f_of_flow = create_curve_quadratic(model, cool_eir_fflow_coeffs, 'Cool-EIR-fFF', 0, 2, 0, 2, is_dimensionless = true)
    clg_part_load_ratio = create_curve_quadratic(model, cool_plf_fplr_coeffs, 'Cool-PLF-fPLR', 0, 1, 0, 1, is_dimensionless = true)
    clg_cap_f_of_temp_low_spd = create_curve_biquadratic(model, cool_cap_ft_coeffs_si, 'Cool-Cap-fT', 0, 100, 0, 100, nil, nil)
    clg_energy_input_ratio_f_of_temp_low_spd = create_curve_biquadratic(model, cool_eir_ft_coeffs_si, 'Cool-EIR-fT', 0, 100, 0, 100, nil, nil)
    clg_coil.setRatedLowSpeedSensibleHeatRatio(0.73)
    clg_coil.setCondenserType('AirCooled')
  else # default curve set, type == 'PSZ-AC' || 'Split AC' || 'PTAC'
    clg_cap_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    clg_cap_f_of_temp.setCoefficient1Constant(0.42415)
    clg_cap_f_of_temp.setCoefficient2x(0.04426)
    clg_cap_f_of_temp.setCoefficient3xPOW2(-0.00042)
    clg_cap_f_of_temp.setCoefficient4y(0.00333)
    clg_cap_f_of_temp.setCoefficient5yPOW2(-0.00008)
    clg_cap_f_of_temp.setCoefficient6xTIMESY(-0.00021)
    clg_cap_f_of_temp.setMinimumValueofx(17.0)
    clg_cap_f_of_temp.setMaximumValueofx(22.0)
    clg_cap_f_of_temp.setMinimumValueofy(13.0)
    clg_cap_f_of_temp.setMaximumValueofy(46.0)

    clg_cap_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)
    clg_cap_f_of_flow.setCoefficient1Constant(0.77136)
    clg_cap_f_of_flow.setCoefficient2x(0.34053)
    clg_cap_f_of_flow.setCoefficient3xPOW2(-0.11088)
    clg_cap_f_of_flow.setMinimumValueofx(0.75918)
    clg_cap_f_of_flow.setMaximumValueofx(1.13877)

    clg_energy_input_ratio_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    clg_energy_input_ratio_f_of_temp.setCoefficient1Constant(1.23649)
    clg_energy_input_ratio_f_of_temp.setCoefficient2x(-0.02431)
    clg_energy_input_ratio_f_of_temp.setCoefficient3xPOW2(0.00057)
    clg_energy_input_ratio_f_of_temp.setCoefficient4y(-0.01434)
    clg_energy_input_ratio_f_of_temp.setCoefficient5yPOW2(0.00063)
    clg_energy_input_ratio_f_of_temp.setCoefficient6xTIMESY(-0.00038)
    clg_energy_input_ratio_f_of_temp.setMinimumValueofx(17.0)
    clg_energy_input_ratio_f_of_temp.setMaximumValueofx(22.0)
    clg_energy_input_ratio_f_of_temp.setMinimumValueofy(13.0)
    clg_energy_input_ratio_f_of_temp.setMaximumValueofy(46.0)

    clg_energy_input_ratio_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)
    clg_energy_input_ratio_f_of_flow.setCoefficient1Constant(1.20550)
    clg_energy_input_ratio_f_of_flow.setCoefficient2x(-0.32953)
    clg_energy_input_ratio_f_of_flow.setCoefficient3xPOW2(0.12308)
    clg_energy_input_ratio_f_of_flow.setMinimumValueofx(0.75918)
    clg_energy_input_ratio_f_of_flow.setMaximumValueofx(1.13877)

    clg_part_load_ratio = OpenStudio::Model::CurveQuadratic.new(model)
    clg_part_load_ratio.setCoefficient1Constant(0.77100)
    clg_part_load_ratio.setCoefficient2x(0.22900)
    clg_part_load_ratio.setCoefficient3xPOW2(0.0)
    clg_part_load_ratio.setMinimumValueofx(0.0)
    clg_part_load_ratio.setMaximumValueofx(1.0)

    clg_cap_f_of_temp_low_spd = OpenStudio::Model::CurveBiquadratic.new(model)
    clg_cap_f_of_temp_low_spd.setCoefficient1Constant(0.42415)
    clg_cap_f_of_temp_low_spd.setCoefficient2x(0.04426)
    clg_cap_f_of_temp_low_spd.setCoefficient3xPOW2(-0.00042)
    clg_cap_f_of_temp_low_spd.setCoefficient4y(0.00333)
    clg_cap_f_of_temp_low_spd.setCoefficient5yPOW2(-0.00008)
    clg_cap_f_of_temp_low_spd.setCoefficient6xTIMESY(-0.00021)
    clg_cap_f_of_temp_low_spd.setMinimumValueofx(17.0)
    clg_cap_f_of_temp_low_spd.setMaximumValueofx(22.0)
    clg_cap_f_of_temp_low_spd.setMinimumValueofy(13.0)
    clg_cap_f_of_temp_low_spd.setMaximumValueofy(46.0)

    clg_energy_input_ratio_f_of_temp_low_spd = OpenStudio::Model::CurveBiquadratic.new(model)
    clg_energy_input_ratio_f_of_temp_low_spd.setCoefficient1Constant(1.23649)
    clg_energy_input_ratio_f_of_temp_low_spd.setCoefficient2x(-0.02431)
    clg_energy_input_ratio_f_of_temp_low_spd.setCoefficient3xPOW2(0.00057)
    clg_energy_input_ratio_f_of_temp_low_spd.setCoefficient4y(-0.01434)
    clg_energy_input_ratio_f_of_temp_low_spd.setCoefficient5yPOW2(0.00063)
    clg_energy_input_ratio_f_of_temp_low_spd.setCoefficient6xTIMESY(-0.00038)
    clg_energy_input_ratio_f_of_temp_low_spd.setMinimumValueofx(17.0)
    clg_energy_input_ratio_f_of_temp_low_spd.setMaximumValueofx(22.0)
    clg_energy_input_ratio_f_of_temp_low_spd.setMinimumValueofy(13.0)
    clg_energy_input_ratio_f_of_temp_low_spd.setMaximumValueofy(46.0)

    clg_coil.setRatedLowSpeedSensibleHeatRatio(OpenStudio::OptionalDouble.new(0.69))
    clg_coil.setBasinHeaterCapacity(10)
    clg_coil.setBasinHeaterSetpointTemperature(2.0)
  end

  clg_coil.setTotalCoolingCapacityFunctionOfTemperatureCurve(clg_cap_f_of_temp) unless clg_cap_f_of_temp.nil?
  clg_coil.setTotalCoolingCapacityFunctionOfFlowFractionCurve(clg_cap_f_of_flow) unless clg_cap_f_of_flow.nil?
  clg_coil.setEnergyInputRatioFunctionOfTemperatureCurve(clg_energy_input_ratio_f_of_temp) unless clg_energy_input_ratio_f_of_temp.nil?
  clg_coil.setEnergyInputRatioFunctionOfFlowFractionCurve(clg_energy_input_ratio_f_of_flow) unless clg_energy_input_ratio_f_of_flow.nil?
  clg_coil.setPartLoadFractionCorrelationCurve(clg_part_load_ratio) unless clg_part_load_ratio.nil?
  clg_coil.setLowSpeedTotalCoolingCapacityFunctionOfTemperatureCurve(clg_cap_f_of_temp_low_spd) unless clg_cap_f_of_temp_low_spd.nil?
  clg_coil.setLowSpeedEnergyInputRatioFunctionOfTemperatureCurve(clg_energy_input_ratio_f_of_temp_low_spd) unless clg_energy_input_ratio_f_of_temp_low_spd.nil?

  return clg_coil
end

#create_coil_cooling_water(model, chilled_water_loop, air_loop_node: nil, name: 'Clg Coil', schedule: nil, design_inlet_water_temperature: nil, design_inlet_air_temperature: nil, design_outlet_air_temperature: nil) ⇒ Object

Prototype CoilCoolingWater object

Parameters:

  • chilled_water_loop (<OpenStudio::Model::PlantLoop>)

    the coil will be placed on the demand side of this plant loop

  • air_loop_node (<OpenStudio::Model::Node>) (defaults to: nil)

    the coil will be placed on this node of the air loop

  • name (String) (defaults to: 'Clg Coil')

    the name of the coil, or nil in which case it will be defaulted

  • schedule (String) (defaults to: nil)

    name of the availability schedule, or [<OpenStudio::Model::Schedule>] Schedule object, or nil in which case default to always on

  • design_inlet_water_temperature (Double) (defaults to: nil)

    design inlet water temperature in degrees Celsius, default is nil

  • design_inlet_air_temperature (Double) (defaults to: nil)

    design inlet air temperature in degrees Celsius, default is nil

  • design_outlet_air_temperature (Double) (defaults to: nil)

    design outlet air temperature in degrees Celsius, default is nil



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.CoilCoolingWater.rb', line 12

def create_coil_cooling_water(model,
                              chilled_water_loop,
                              air_loop_node: nil,
                              name: 'Clg Coil',
                              schedule: nil,
                              design_inlet_water_temperature: nil,
                              design_inlet_air_temperature: nil,
                              design_outlet_air_temperature: nil)

  clg_coil = OpenStudio::Model::CoilCoolingWater.new(model)

  # add to chilled water loop
  chilled_water_loop.addDemandBranchForComponent(clg_coil)

  # add to air loop if specified
  clg_coil.addToNode(air_loop_node) unless air_loop_node.nil?

  # set coil name
  if name.nil?
    clg_coil.setName('Clg Coil')
  else
    clg_coil.setName(name)
  end

  # set coil availability schedule
  if schedule.nil?
    # default always on
    coil_availability_schedule = model.alwaysOnDiscreteSchedule
  elsif schedule.class == String
    coil_availability_schedule = model_add_schedule(model, schedule)

    if coil_availability_schedule.nil? && schedule == 'alwaysOffDiscreteSchedule'
      coil_availability_schedule = model.alwaysOffDiscreteSchedule
    elsif coil_availability_schedule.nil?
      coil_availability_schedule = model.alwaysOnDiscreteSchedule
    end
  elsif !schedule.to_Schedule.empty?
    coil_availability_schedule = schedule
  else
    coil_availability_schedule = model.alwaysOnDiscreteSchedule
  end
  clg_coil.setAvailabilitySchedule(coil_availability_schedule)

  # rated temperatures
  if design_inlet_water_temperature.nil?
    clg_coil.autosizeDesignInletWaterTemperature
  else
    clg_coil.setDesignInletWaterTemperature(design_inlet_water_temperature)
  end
  clg_coil.setDesignInletAirTemperature(design_inlet_air_temperature) unless design_inlet_air_temperature.nil?
  clg_coil.setDesignOutletAirTemperature(design_outlet_air_temperature) unless design_outlet_air_temperature.nil?

  # defaults
  clg_coil.setHeatExchangerConfiguration('CrossFlow')

  # coil controller properties
  # NOTE: These inputs will get overwritten if addToNode or addDemandBranchForComponent is called on the htg_coil object after this
  clg_coil_controller = clg_coil.controllerWaterCoil.get
  clg_coil_controller.setName("#{clg_coil.name} Controller")
  clg_coil_controller.setAction('Reverse')
  clg_coil_controller.setMinimumActuatedFlow(0.0)

  return clg_coil
end

#create_coil_cooling_water_to_air_heat_pump_equation_fit(model, plant_loop, air_loop_node: nil, name: 'Water-to-Air HP Clg Coil', type: nil, cop: 3.4) ⇒ Object

Prototype CoilCoolingWaterToAirHeatPumpEquationFit object Enters in default curves for coil by type of coil

Parameters:

  • plant_loop (<OpenStudio::Model::PlantLoop>)

    the coil will be placed on the demand side of this plant loop

  • air_loop_node (<OpenStudio::Model::Node>) (defaults to: nil)

    the coil will be placed on this node of the air loop

  • name (String) (defaults to: 'Water-to-Air HP Clg Coil')

    the name of the system, or nil in which case it will be defaulted

  • type (String) (defaults to: nil)

    the type of coil to reference the correct curve set

  • cop (Double) (defaults to: 3.4)

    rated cooling coefficient of performance



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.CoilCoolingWaterToAirHeatPumpEquationFit.rb', line 11

def create_coil_cooling_water_to_air_heat_pump_equation_fit(model,
                                                            plant_loop,
                                                            air_loop_node: nil,
                                                            name: 'Water-to-Air HP Clg Coil',
                                                            type: nil,
                                                            cop: 3.4)

  clg_coil = OpenStudio::Model::CoilCoolingWaterToAirHeatPumpEquationFit.new(model)

  # add to air loop if specified
  clg_coil.addToNode(air_loop_node) unless air_loop_node.nil?

  # set coil name
  clg_coil.setName(name)

  # add to plant loop
  if plant_loop.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'No plant loop supplied for cooling coil')
    return false
  end
  plant_loop.addDemandBranchForComponent(clg_coil)

  # set coil cop
  if cop.nil?
    clg_coil.setRatedCoolingCoefficientofPerformance(3.4)
  else
    clg_coil.setRatedCoolingCoefficientofPerformance(cop)
  end

  # curve sets
  if type == 'OS default'
    # use OS default curves
  else # default curve set
    clg_coil.setTotalCoolingCapacityCoefficient1(-4.30266987344639)
    clg_coil.setTotalCoolingCapacityCoefficient2(7.18536990534372)
    clg_coil.setTotalCoolingCapacityCoefficient3(-2.23946714486189)
    clg_coil.setTotalCoolingCapacityCoefficient4(0.139995928440879)
    clg_coil.setTotalCoolingCapacityCoefficient5(0.102660179888915)
    clg_coil.setSensibleCoolingCapacityCoefficient1(6.0019444814887)
    clg_coil.setSensibleCoolingCapacityCoefficient2(22.6300677244073)
    clg_coil.setSensibleCoolingCapacityCoefficient3(-26.7960783730934)
    clg_coil.setSensibleCoolingCapacityCoefficient4(-1.72374720346819)
    clg_coil.setSensibleCoolingCapacityCoefficient5(0.490644802367817)
    clg_coil.setSensibleCoolingCapacityCoefficient6(0.0693119353468141)
    clg_coil.setCoolingPowerConsumptionCoefficient1(-5.67775976415698)
    clg_coil.setCoolingPowerConsumptionCoefficient2(0.438988156976704)
    clg_coil.setCoolingPowerConsumptionCoefficient3(5.845277342193)
    clg_coil.setCoolingPowerConsumptionCoefficient4(0.141605667000125)
    clg_coil.setCoolingPowerConsumptionCoefficient5(-0.168727936032429)
  end

  return clg_coil
end

#create_coil_heating_dx_single_speed(model, air_loop_node: nil, name: '1spd DX Htg Coil', schedule: nil, type: nil, cop: 3.3, defrost_strategy: 'ReverseCycle') ⇒ Object

Prototype CoilHeatingDXSingleSpeed object Enters in default curves for coil by type of coil

Parameters:

  • air_loop_node (<OpenStudio::Model::Node>) (defaults to: nil)

    the coil will be placed on this node of the air loop

  • name (String) (defaults to: '1spd DX Htg Coil')

    the name of the system, or nil in which case it will be defaulted

  • schedule (String) (defaults to: nil)

    name of the availability schedule, or [<OpenStudio::Model::Schedule>] Schedule object, or nil in which case default to always on

  • type (String) (defaults to: nil)

    the type of single speed DX coil to reference the correct curve set

  • cop (Double) (defaults to: 3.3)

    rated heating coefficient of performance

  • defrost_strategy (String) (defaults to: 'ReverseCycle')

    type of defrost strategy. options are reverse-cycle or resistive



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.CoilHeatingDXSingleSpeed.rb', line 12

def create_coil_heating_dx_single_speed(model,
                                        air_loop_node: nil,
                                        name: '1spd DX Htg Coil',
                                        schedule: nil,
                                        type: nil,
                                        cop: 3.3,
                                        defrost_strategy: 'ReverseCycle')

  htg_coil = OpenStudio::Model::CoilHeatingDXSingleSpeed.new(model)

  # add to air loop if specified
  htg_coil.addToNode(air_loop_node) unless air_loop_node.nil?

  # set coil name
  htg_coil.setName(name)

  # set coil availability schedule
  if schedule.nil?
    # default always on
    coil_availability_schedule = model.alwaysOnDiscreteSchedule
  elsif schedule.class == String
    coil_availability_schedule = model_add_schedule(model, schedule)

    if coil_availability_schedule.nil? && schedule == 'alwaysOffDiscreteSchedule'
      coil_availability_schedule = model.alwaysOffDiscreteSchedule
    elsif coil_availability_schedule.nil?
      coil_availability_schedule = model.alwaysOnDiscreteSchedule
    end
  elsif !schedule.to_Schedule.empty?
    coil_availability_schedule = schedule
  else
    coil_availability_schedule = model.alwaysOnDiscreteSchedule
  end
  htg_coil.setAvailabilitySchedule(coil_availability_schedule)

  # set coil cop
  if cop.nil?
    htg_coil.setRatedCOP(3.3)
  else
    htg_coil.setRatedCOP(cop)
  end

  htg_cap_f_of_temp = nil
  htg_cap_f_of_flow = nil
  htg_energy_input_ratio_f_of_temp = nil
  htg_energy_input_ratio_f_of_flow = nil
  htg_part_load_fraction = nil
  def_eir_f_of_temp = nil

  # curve sets
  if type == 'OS default'
    # use OS defaults
  elsif type == 'Residential Central Air Source HP'
    # Performance curves
    # These coefficients are in IP UNITS
    heat_cap_ft_coeffs_ip = [0.566333415, -0.000744164, -0.0000103, 0.009414634, 0.0000506, -0.00000675]
    heat_eir_ft_coeffs_ip = [0.718398423, 0.003498178, 0.000142202, -0.005724331, 0.00014085, -0.000215321]
    heat_cap_fflow_coeffs = [0.694045465, 0.474207981, -0.168253446]
    heat_eir_fflow_coeffs = [2.185418751, -1.942827919, 0.757409168]
    heat_plf_fplr_coeffs = [0.8, 0.2, 0]
    defrost_eir_coeffs = [0.1528, 0, 0, 0, 0, 0]

    # Convert coefficients from IP to SI
    heat_cap_ft_coeffs_si = convert_curve_biquadratic(heat_cap_ft_coeffs_ip)
    heat_eir_ft_coeffs_si = convert_curve_biquadratic(heat_eir_ft_coeffs_ip)

    htg_cap_f_of_temp = create_curve_biquadratic(model, heat_cap_ft_coeffs_si, 'Heat-Cap-fT', 0, 100, 0, 100, nil, nil)
    htg_cap_f_of_flow = create_curve_quadratic(model, heat_cap_fflow_coeffs, 'Heat-Cap-fFF', 0, 2, 0, 2, is_dimensionless = true)
    htg_energy_input_ratio_f_of_temp = create_curve_biquadratic(model, heat_eir_ft_coeffs_si, 'Heat-EIR-fT', 0, 100, 0, 100, nil, nil)
    htg_energy_input_ratio_f_of_flow = create_curve_quadratic(model, heat_eir_fflow_coeffs, 'Heat-EIR-fFF', 0, 2, 0, 2, is_dimensionless = true)
    htg_part_load_fraction = create_curve_quadratic(model, heat_plf_fplr_coeffs, 'Heat-PLF-fPLR', 0, 1, 0, 1, is_dimensionless = true)

    # Heating defrost curve for reverse cycle
    def_eir_f_of_temp = create_curve_biquadratic(model, defrost_eir_coeffs, 'DefrostEIR', -100, 100, -100, 100, nil, nil)
  elsif type == 'Residential Minisplit HP'
    # Performance curves
    # These coefficients are in SI UNITS
    heat_cap_ft_coeffs_si = [1.14715889038462, -0.010386676170938, 0, 0.00865384615384615, 0, 0]
    heat_eir_ft_coeffs_si = [0.9999941697687026, 0.004684593830254383, 5.901286675833333e-05, -0.0028624467783091973, 1.3041120194135802e-05, -0.00016172918478765433]
    heat_cap_fflow_coeffs = [1, 0, 0]
    heat_eir_fflow_coeffs = [1, 0, 0]
    heat_plf_fplr_coeffs = [0.89, 0.11, 0]
    defrost_eir_coeffs = [0.1528, 0, 0, 0, 0, 0]

    htg_cap_f_of_temp = create_curve_biquadratic(model, heat_cap_ft_coeffs_si, 'Heat-Cap-fT', -100, 100, -100, 100, nil, nil)
    htg_cap_f_of_flow = create_curve_quadratic(model, heat_cap_fflow_coeffs, 'Heat-Cap-fFF', 0, 2, 0, 2, is_dimensionless = true)
    htg_energy_input_ratio_f_of_temp = create_curve_biquadratic(model, heat_eir_ft_coeffs_si, 'Heat-EIR-fT', -100, 100, -100, 100, nil, nil)
    htg_energy_input_ratio_f_of_flow = create_curve_quadratic(model, heat_eir_fflow_coeffs, 'Heat-EIR-fFF', 0, 2, 0, 2, is_dimensionless = true)
    htg_part_load_fraction = create_curve_quadratic(model, heat_plf_fplr_coeffs, 'Heat-PLF-fPLR', 0, 1, 0.6, 1, is_dimensionless = true)

    # Heating defrost curve for reverse cycle
    def_eir_f_of_temp = create_curve_biquadratic(model, defrost_eir_coeffs, 'Defrost EIR', -100, 100, -100, 100, nil, nil)
  else # default curve set
    htg_cap_f_of_temp = OpenStudio::Model::CurveCubic.new(model)
    htg_cap_f_of_temp.setName("#{htg_coil.name} Htg Cap Func of Temp Curve")
    htg_cap_f_of_temp.setCoefficient1Constant(0.758746)
    htg_cap_f_of_temp.setCoefficient2x(0.027626)
    htg_cap_f_of_temp.setCoefficient3xPOW2(0.000148716)
    htg_cap_f_of_temp.setCoefficient4xPOW3(0.0000034992)
    htg_cap_f_of_temp.setMinimumValueofx(-20.0)
    htg_cap_f_of_temp.setMaximumValueofx(20.0)

    htg_cap_f_of_flow = OpenStudio::Model::CurveCubic.new(model)
    htg_cap_f_of_flow.setName("#{htg_coil.name} Htg Cap Func of Flow Frac Curve")
    htg_cap_f_of_flow.setCoefficient1Constant(0.84)
    htg_cap_f_of_flow.setCoefficient2x(0.16)
    htg_cap_f_of_flow.setCoefficient3xPOW2(0.0)
    htg_cap_f_of_flow.setCoefficient4xPOW3(0.0)
    htg_cap_f_of_flow.setMinimumValueofx(0.5)
    htg_cap_f_of_flow.setMaximumValueofx(1.5)

    htg_energy_input_ratio_f_of_temp = OpenStudio::Model::CurveCubic.new(model)
    htg_energy_input_ratio_f_of_temp.setName("#{htg_coil.name} EIR Func of Temp Curve")
    htg_energy_input_ratio_f_of_temp.setCoefficient1Constant(1.19248)
    htg_energy_input_ratio_f_of_temp.setCoefficient2x(-0.0300438)
    htg_energy_input_ratio_f_of_temp.setCoefficient3xPOW2(0.00103745)
    htg_energy_input_ratio_f_of_temp.setCoefficient4xPOW3(-0.000023328)
    htg_energy_input_ratio_f_of_temp.setMinimumValueofx(-20.0)
    htg_energy_input_ratio_f_of_temp.setMaximumValueofx(20.0)

    htg_energy_input_ratio_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)
    htg_energy_input_ratio_f_of_flow.setName("#{htg_coil.name} EIR Func of Flow Frac Curve")
    htg_energy_input_ratio_f_of_flow.setCoefficient1Constant(1.3824)
    htg_energy_input_ratio_f_of_flow.setCoefficient2x(-0.4336)
    htg_energy_input_ratio_f_of_flow.setCoefficient3xPOW2(0.0512)
    htg_energy_input_ratio_f_of_flow.setMinimumValueofx(0.0)
    htg_energy_input_ratio_f_of_flow.setMaximumValueofx(1.0)

    htg_part_load_fraction = OpenStudio::Model::CurveQuadratic.new(model)
    htg_part_load_fraction.setName("#{htg_coil.name} PLR Correlation Curve")
    htg_part_load_fraction.setCoefficient1Constant(0.85)
    htg_part_load_fraction.setCoefficient2x(0.15)
    htg_part_load_fraction.setCoefficient3xPOW2(0.0)
    htg_part_load_fraction.setMinimumValueofx(0.0)
    htg_part_load_fraction.setMaximumValueofx(1.0)

    unless defrost_strategy == 'Resistive'
      def_eir_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)
      def_eir_f_of_temp.setName("#{htg_coil.name} Defrost EIR Func of Temp Curve")
      def_eir_f_of_temp.setCoefficient1Constant(0.297145)
      def_eir_f_of_temp.setCoefficient2x(0.0430933)
      def_eir_f_of_temp.setCoefficient3xPOW2(-0.000748766)
      def_eir_f_of_temp.setCoefficient4y(0.00597727)
      def_eir_f_of_temp.setCoefficient5yPOW2(0.000482112)
      def_eir_f_of_temp.setCoefficient6xTIMESY(-0.000956448)
      def_eir_f_of_temp.setMinimumValueofx(-23.33333)
      def_eir_f_of_temp.setMaximumValueofx(29.44444)
      def_eir_f_of_temp.setMinimumValueofy(-23.33333)
      def_eir_f_of_temp.setMaximumValueofy(29.44444)
    end
  end

  if type == 'PSZ-AC'
    htg_coil.setMinimumOutdoorDryBulbTemperatureforCompressorOperation(-12.2)
    htg_coil.setMaximumOutdoorDryBulbTemperatureforDefrostOperation(1.67)
    htg_coil.setCrankcaseHeaterCapacity(50.0)
    htg_coil.setMaximumOutdoorDryBulbTemperatureforCrankcaseHeaterOperation(4.4)
    htg_coil.setDefrostControl('OnDemand')

    def_eir_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)
    def_eir_f_of_temp.setName("#{htg_coil.name} Defrost EIR Func of Temp Curve")
    def_eir_f_of_temp.setCoefficient1Constant(0.297145)
    def_eir_f_of_temp.setCoefficient2x(0.0430933)
    def_eir_f_of_temp.setCoefficient3xPOW2(-0.000748766)
    def_eir_f_of_temp.setCoefficient4y(0.00597727)
    def_eir_f_of_temp.setCoefficient5yPOW2(0.000482112)
    def_eir_f_of_temp.setCoefficient6xTIMESY(-0.000956448)
    def_eir_f_of_temp.setMinimumValueofx(-23.33333)
    def_eir_f_of_temp.setMaximumValueofx(29.44444)
    def_eir_f_of_temp.setMinimumValueofy(-23.33333)
    def_eir_f_of_temp.setMaximumValueofy(29.44444)
  end

  htg_coil.setTotalHeatingCapacityFunctionofTemperatureCurve(htg_cap_f_of_temp) unless htg_cap_f_of_temp.nil?
  htg_coil.setTotalHeatingCapacityFunctionofFlowFractionCurve(htg_cap_f_of_flow) unless htg_cap_f_of_flow.nil?
  htg_coil.setEnergyInputRatioFunctionofTemperatureCurve(htg_energy_input_ratio_f_of_temp) unless htg_energy_input_ratio_f_of_temp.nil?
  htg_coil.setEnergyInputRatioFunctionofFlowFractionCurve(htg_energy_input_ratio_f_of_flow) unless htg_energy_input_ratio_f_of_flow.nil?
  htg_coil.setPartLoadFractionCorrelationCurve(htg_part_load_fraction) unless htg_part_load_fraction.nil?
  htg_coil.setDefrostEnergyInputRatioFunctionofTemperatureCurve(def_eir_f_of_temp) unless def_eir_f_of_temp.nil?
  htg_coil.setDefrostStrategy(defrost_strategy)
  htg_coil.setDefrostControl('OnDemand')

  return htg_coil
end

#create_coil_heating_electric(model, air_loop_node: nil, name: 'Electric Htg Coil', schedule: nil, nominal_capacity: nil, efficiency: 1.0) ⇒ Object

Prototype CoilHeatingElectric object

Parameters:

  • air_loop_node (<OpenStudio::Model::Node>) (defaults to: nil)

    the coil will be placed on this node of the air loop

  • name (String) (defaults to: 'Electric Htg Coil')

    the name of the system, or nil in which case it will be defaulted

  • schedule (String) (defaults to: nil)

    name of the availability schedule, or [<OpenStudio::Model::Schedule>] Schedule object, or nil in which case default to always on

  • nominal_capacity (Double) (defaults to: nil)

    rated nominal capacity

  • efficiency (Double) (defaults to: 1.0)

    rated heating efficiency



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.CoilHeatingElectric.rb', line 10

def create_coil_heating_electric(model,
                                 air_loop_node: nil,
                                 name: 'Electric Htg Coil',
                                 schedule: nil,
                                 nominal_capacity: nil,
                                 efficiency: 1.0)

  htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model)

  # add to air loop if specified
  htg_coil.addToNode(air_loop_node) unless air_loop_node.nil?

  # set coil name
  htg_coil.setName(name)

  # set coil availability schedule
  if schedule.nil?
    # default always on
    coil_availability_schedule = model.alwaysOnDiscreteSchedule
  elsif schedule.class == String
    coil_availability_schedule = model_add_schedule(model, schedule)

    if coil_availability_schedule.nil? && schedule == 'alwaysOffDiscreteSchedule'
      coil_availability_schedule = model.alwaysOffDiscreteSchedule
    elsif coil_availability_schedule.nil?
      coil_availability_schedule = model.alwaysOnDiscreteSchedule
    end
  elsif !schedule.to_Schedule.empty?
    coil_availability_schedule = schedule
  else
    coil_availability_schedule = model.alwaysOnDiscreteSchedule
  end
  htg_coil.setAvailabilitySchedule(coil_availability_schedule)

  # set capacity
  htg_coil.setNominalCapacity(nominal_capacity) unless nominal_capacity.nil?

  # set efficiency
  htg_coil.setEfficiency(efficiency) unless efficiency.nil?

  return htg_coil
end

#create_coil_heating_gas(model, air_loop_node: nil, name: 'Gas Htg Coil', schedule: nil, nominal_capacity: nil, efficiency: 0.80) ⇒ Object

Prototype CoilHeatingGas object

Parameters:

  • air_loop_node (<OpenStudio::Model::Node>) (defaults to: nil)

    the coil will be placed on this node of the air loop

  • name (String) (defaults to: 'Gas Htg Coil')

    the name of the system, or nil in which case it will be defaulted

  • schedule (String) (defaults to: nil)

    name of the availability schedule, or [<OpenStudio::Model::Schedule>] Schedule object, or nil in which case default to always on

  • nominal_capacity (Double) (defaults to: nil)

    rated nominal capacity

  • efficiency (Double) (defaults to: 0.80)

    rated heating efficiency



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.CoilHeatingGas.rb', line 10

def create_coil_heating_gas(model,
                            air_loop_node: nil,
                            name: 'Gas Htg Coil',
                            schedule: nil,
                            nominal_capacity: nil,
                            efficiency: 0.80)

  htg_coil = OpenStudio::Model::CoilHeatingGas.new(model)

  # add to air loop if specified
  htg_coil.addToNode(air_loop_node) unless air_loop_node.nil?

  # set coil name
  htg_coil.setName(name)

  # set coil availability schedule
  if schedule.nil?
    # default always on
    coil_availability_schedule = model.alwaysOnDiscreteSchedule
  elsif schedule.class == String
    coil_availability_schedule = model_add_schedule(model, schedule)

    if coil_availability_schedule.nil? && schedule == 'alwaysOffDiscreteSchedule'
      coil_availability_schedule = model.alwaysOffDiscreteSchedule
    elsif coil_availability_schedule.nil?
      coil_availability_schedule = model.alwaysOnDiscreteSchedule
    end
  elsif !schedule.to_Schedule.empty?
    coil_availability_schedule = schedule
  else
    coil_availability_schedule = model.alwaysOnDiscreteSchedule
  end
  htg_coil.setAvailabilitySchedule(coil_availability_schedule)

  # set capacity
  htg_coil.setNominalCapacity(nominal_capacity) unless nominal_capacity.nil?

  # set efficiency
  htg_coil.setGasBurnerEfficiency(efficiency)

  # defaults
  htg_coil.setParasiticElectricLoad(0)
  htg_coil.setParasiticGasLoad(0)

  return htg_coil
end

#create_coil_heating_water(model, hot_water_loop, air_loop_node: nil, name: 'Htg Coil', schedule: nil, rated_inlet_water_temperature: nil, rated_outlet_water_temperature: nil, rated_inlet_air_temperature: 16.6, rated_outlet_air_temperature: 32.2, controller_convergence_tolerance: 0.1) ⇒ Object

Prototype CoilHeatingWater object

Parameters:

  • hot_water_loop (<OpenStudio::Model::PlantLoop>)

    the coil will be placed on the demand side of this plant loop

  • air_loop_node (<OpenStudio::Model::Node>) (defaults to: nil)

    the coil will be placed on this node of the air loop

  • name (String) (defaults to: 'Htg Coil')

    the name of the coil, or nil in which case it will be defaulted

  • schedule (String) (defaults to: nil)

    name of the availability schedule, or [<OpenStudio::Model::Schedule>] Schedule object, or nil in which case default to always on

  • rated_inlet_water_temperature (Double) (defaults to: nil)

    rated inlet water temperature in degrees Celsius, default is hot water loop design exit temperature

  • rated_outlet_water_temperature (Double) (defaults to: nil)

    rated outlet water temperature in degrees Celsius, default is hot water loop design return temperature

  • rated_inlet_air_temperature (Double) (defaults to: 16.6)

    rated inlet air temperature in degrees Celsius, default is 16.6 (62F)

  • rated_outlet_air_temperature (Double) (defaults to: 32.2)

    rated outlet air temperature in degrees Celsius, default is 32.2 (90F)

  • controller_convergence_tolerance (Double) (defaults to: 0.1)

    controller convergence tolerance



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.CoilHeatingWater.rb', line 14

def create_coil_heating_water(model,
                              hot_water_loop,
                              air_loop_node: nil,
                              name: 'Htg Coil',
                              schedule: nil,
                              rated_inlet_water_temperature: nil,
                              rated_outlet_water_temperature: nil,
                              rated_inlet_air_temperature: 16.6,
                              rated_outlet_air_temperature: 32.2,
                              controller_convergence_tolerance: 0.1)

  htg_coil = OpenStudio::Model::CoilHeatingWater.new(model)

  # add to hot water loop
  hot_water_loop.addDemandBranchForComponent(htg_coil)

  # add to air loop if specified
  htg_coil.addToNode(air_loop_node) unless air_loop_node.nil?

  # set coil name
  if name.nil?
    htg_coil.setName('Htg Coil')
  else
    htg_coil.setName(name)
  end

  # set coil availability schedule
  if schedule.nil?
    # default always on
    coil_availability_schedule = model.alwaysOnDiscreteSchedule
  elsif schedule.class == String
    coil_availability_schedule = model_add_schedule(model, schedule)

    if coil_availability_schedule.nil? && schedule == 'alwaysOffDiscreteSchedule'
      coil_availability_schedule = model.alwaysOffDiscreteSchedule
    elsif coil_availability_schedule.nil?
      coil_availability_schedule = model.alwaysOnDiscreteSchedule
    end
  elsif !schedule.to_Schedule.empty?
    coil_availability_schedule = schedule
  else
    coil_availability_schedule = model.alwaysOnDiscreteSchedule
  end
  htg_coil.setAvailabilitySchedule(coil_availability_schedule)

  # rated water temperatures, use hot water loop temperatures if defined
  if rated_inlet_water_temperature.nil?
    rated_inlet_water_temperature = hot_water_loop.sizingPlant.designLoopExitTemperature
    htg_coil.setRatedInletWaterTemperature(rated_inlet_water_temperature)
  else
    htg_coil.setRatedInletWaterTemperature(rated_inlet_water_temperature)
  end
  if rated_outlet_water_temperature.nil?
    rated_outlet_water_temperature = rated_inlet_water_temperature - hot_water_loop.sizingPlant.loopDesignTemperatureDifference
    htg_coil.setRatedOutletWaterTemperature(rated_outlet_water_temperature)
  else
    htg_coil.setRatedOutletWaterTemperature(rated_outlet_water_temperature)
  end

  # rated air temperatures
  if rated_inlet_air_temperature.nil?
    htg_coil.setRatedInletAirTemperature(16.6)
  else
    htg_coil.setRatedInletAirTemperature(rated_inlet_air_temperature)
  end
  if rated_outlet_air_temperature.nil?
    htg_coil.setRatedOutletAirTemperature(32.2)
  else
    htg_coil.setRatedOutletAirTemperature(rated_outlet_air_temperature)
  end

  # coil controller properties
  # NOTE: These inputs will get overwritten if addToNode or addDemandBranchForComponent is called on the htg_coil object after this
  htg_coil_controller = htg_coil.controllerWaterCoil.get
  htg_coil_controller.setName("#{htg_coil.name} Controller")
  htg_coil_controller.setMinimumActuatedFlow(0.0)
  htg_coil_controller.setControllerConvergenceTolerance(controller_convergence_tolerance) unless controller_convergence_tolerance.nil?

  return htg_coil
end

#create_coil_heating_water_to_air_heat_pump_equation_fit(model, plant_loop, air_loop_node: nil, name: 'Water-to-Air HP Htg Coil', type: nil, cop: 4.2) ⇒ Object

Prototype CoilHeatingWaterToAirHeatPumpEquationFit object Enters in default curves for coil by type of coil

Parameters:

  • plant_loop (<OpenStudio::Model::PlantLoop>)

    the coil will be placed on the demand side of this plant loop

  • air_loop_node (<OpenStudio::Model::Node>) (defaults to: nil)

    the coil will be placed on this node of the air loop

  • name (String) (defaults to: 'Water-to-Air HP Htg Coil')

    the name of the system, or nil in which case it will be defaulted

  • type (String) (defaults to: nil)

    the type of coil to reference the correct curve set

  • cop (Double) (defaults to: 4.2)

    rated heating coefficient of performance



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.CoilHeatingWaterToAirHeatPumpEquationFit.rb', line 11

def create_coil_heating_water_to_air_heat_pump_equation_fit(model,
                                                            plant_loop,
                                                            air_loop_node: nil,
                                                            name: 'Water-to-Air HP Htg Coil',
                                                            type: nil,
                                                            cop: 4.2)

  htg_coil = OpenStudio::Model::CoilHeatingWaterToAirHeatPumpEquationFit.new(model)

  # add to air loop if specified
  htg_coil.addToNode(air_loop_node) unless air_loop_node.nil?

  # set coil name
  htg_coil.setName(name)

  # add to plant loop
  if plant_loop.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'No plant loop supplied for heating coil')
    return false
  end
  plant_loop.addDemandBranchForComponent(htg_coil)

  # set coil cop
  if cop.nil?
    htg_coil.setRatedHeatingCoefficientofPerformance(4.2)
  else
    htg_coil.setRatedHeatingCoefficientofPerformance(cop)
  end

  # curve sets
  if type == 'OS default'
    # use OS default curves
  else # default curve set
    htg_coil.setHeatingCapacityCoefficient1(0.237847462869254)
    htg_coil.setHeatingCapacityCoefficient2(-3.35823796081626)
    htg_coil.setHeatingCapacityCoefficient3(3.80640467406376)
    htg_coil.setHeatingCapacityCoefficient4(0.179200417311554)
    htg_coil.setHeatingCapacityCoefficient5(0.12860719846082)
    htg_coil.setHeatingPowerConsumptionCoefficient1(-3.79175529243238)
    htg_coil.setHeatingPowerConsumptionCoefficient2(3.38799239505527)
    htg_coil.setHeatingPowerConsumptionCoefficient3(1.5022612076303)
    htg_coil.setHeatingPowerConsumptionCoefficient4(-0.177653510577989)
    htg_coil.setHeatingPowerConsumptionCoefficient5(-0.103079864171839)
  end

  return htg_coil
end

#create_curve_bicubic(model, coeffs, crv_name, min_x, max_x, min_y, max_y, min_out, max_out) ⇒ Object

Create a bicubic curve of the form z = C1 + C2*x + C3*x^2 + C4*y + C5*y^2 + C6*x*y + C7*x^3 + C8*y^3 + C9*x^2*y + C10*x*y^2

Parameters:

  • coeffs (Array<Double>)

    an array of 10 coefficients, in order

  • crv_name (String)

    the name of the curve

  • min_x (Double)

    the minimum value of independent variable X that will be used

  • max_x (Double)

    the maximum value of independent variable X that will be used

  • min_y (Double)

    the minimum value of independent variable Y that will be used

  • max_y (Double)

    the maximum value of independent variable Y that will be used

  • min_out (Double)

    the minimum value of dependent variable Z

  • max_out (Double)

    the maximum value of dependent variable Z

Author:

  • Scott Horowitz, NREL



520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 520

def create_curve_bicubic(model, coeffs, crv_name, min_x, max_x, min_y, max_y, min_out, max_out)
  curve = OpenStudio::Model::CurveBicubic.new(model)
  curve.setName(crv_name)
  curve.setCoefficient1Constant(coeffs[0])
  curve.setCoefficient2x(coeffs[1])
  curve.setCoefficient3xPOW2(coeffs[2])
  curve.setCoefficient4y(coeffs[3])
  curve.setCoefficient5yPOW2(coeffs[4])
  curve.setCoefficient6xTIMESY(coeffs[5])
  curve.setCoefficient7xPOW3(coeffs[6])
  curve.setCoefficient8yPOW3(coeffs[7])
  curve.setCoefficient9xPOW2TIMESY(coeffs[8])
  curve.setCoefficient10xTIMESYPOW2(coeffs[9])
  curve.setMinimumValueofx(min_x) unless min_x.nil?
  curve.setMaximumValueofx(max_x) unless max_x.nil?
  curve.setMinimumValueofy(min_y) unless min_y.nil?
  curve.setMaximumValueofy(max_y) unless max_y.nil?
  curve.setMinimumCurveOutput(min_out) unless min_out.nil?
  curve.setMaximumCurveOutput(max_out) unless max_out.nil?
  return curve
end

#create_curve_biquadratic(model, coeffs, crv_name, min_x, max_x, min_y, max_y, min_out, max_out) ⇒ Object

Create a biquadratic curve of the form z = C1 + C2*x + C3*x^2 + C4*y + C5*y^2 + C6*x*y

Parameters:

  • coeffs (Array<Double>)

    an array of 6 coefficients, in order

  • crv_name (String)

    the name of the curve

  • min_x (Double)

    the minimum value of independent variable X that will be used

  • max_x (Double)

    the maximum value of independent variable X that will be used

  • min_y (Double)

    the minimum value of independent variable Y that will be used

  • max_y (Double)

    the maximum value of independent variable Y that will be used

  • min_out (Double)

    the minimum value of dependent variable Z

  • max_out (Double)

    the maximum value of dependent variable Z

Author:

  • Scott Horowitz, NREL



490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 490

def create_curve_biquadratic(model, coeffs, crv_name, min_x, max_x, min_y, max_y, min_out, max_out)
  curve = OpenStudio::Model::CurveBiquadratic.new(model)
  curve.setName(crv_name)
  curve.setCoefficient1Constant(coeffs[0])
  curve.setCoefficient2x(coeffs[1])
  curve.setCoefficient3xPOW2(coeffs[2])
  curve.setCoefficient4y(coeffs[3])
  curve.setCoefficient5yPOW2(coeffs[4])
  curve.setCoefficient6xTIMESY(coeffs[5])
  curve.setMinimumValueofx(min_x) unless min_x.nil?
  curve.setMaximumValueofx(max_x) unless max_x.nil?
  curve.setMinimumValueofy(min_y) unless min_y.nil?
  curve.setMaximumValueofy(max_y) unless max_y.nil?
  curve.setMinimumCurveOutput(min_out) unless min_out.nil?
  curve.setMaximumCurveOutput(max_out) unless max_out.nil?
  return curve
end

#create_curve_cubic(coeffs, crv_name, min_x, max_x, min_out, max_out) ⇒ Object

Create a cubic curve of the form z = C1 + C2*x + C3*x^2 + C4*x^3

Parameters:

  • coeffs (Array<Double>)

    an array of 4 coefficients, in order

  • crv_name (String)

    the name of the curve

  • min_x (Double)

    the minimum value of independent variable X that will be used

  • max_x (Double)

    the maximum value of independent variable X that will be used

  • min_out (Double)

    the minimum value of dependent variable Z

  • max_out (Double)

    the maximum value of dependent variable Z

Author:

  • Scott Horowitz, NREL



581
582
583
584
585
586
587
588
589
590
591
592
593
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 581

def create_curve_cubic(coeffs, crv_name, min_x, max_x, min_out, max_out)
  curve = OpenStudio::Model::CurveCubic.new(self)
  curve.setName(crv_name)
  curve.setCoefficient1Constant(coeffs[0])
  curve.setCoefficient2x(coeffs[1])
  curve.setCoefficient3xPOW2(coeffs[2])
  curve.setCoefficient4xPOW3(coeffs[3])
  curve.setMinimumValueofx(min_x) unless min_x.nil?
  curve.setMaximumValueofx(max_x) unless max_x.nil?
  curve.setMinimumCurveOutput(min_out) unless min_out.nil?
  curve.setMaximumCurveOutput(max_out) unless max_out.nil?
  return curve
end

#create_curve_exponent(coeffs, crv_name, min_x, max_x, min_out, max_out) ⇒ Object

Create an exponential curve of the form z = C1 + C2*x^C3

Parameters:

  • coeffs (Array<Double>)

    an array of 3 coefficients, in order

  • crv_name (String)

    the name of the curve

  • min_x (Double)

    the minimum value of independent variable X that will be used

  • max_x (Double)

    the maximum value of independent variable X that will be used

  • min_out (Double)

    the minimum value of dependent variable Z

  • max_out (Double)

    the maximum value of dependent variable Z

Author:

  • Scott Horowitz, NREL



605
606
607
608
609
610
611
612
613
614
615
616
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 605

def create_curve_exponent(coeffs, crv_name, min_x, max_x, min_out, max_out)
  curve = OpenStudio::Model::CurveExponent.new(self)
  curve.setName(crv_name)
  curve.setCoefficient1Constant(coeffs[0])
  curve.setCoefficient2Constant(coeffs[1])
  curve.setCoefficient3Constant(coeffs[2])
  curve.setMinimumValueofx(min_x) unless min_x.nil?
  curve.setMaximumValueofx(max_x) unless max_x.nil?
  curve.setMinimumCurveOutput(min_out) unless min_out.nil?
  curve.setMaximumCurveOutput(max_out) unless max_out.nil?
  return curve
end

#create_curve_quadratic(model, coeffs, crv_name, min_x, max_x, min_out, max_out, is_dimensionless = false) ⇒ Object

Create a quadratic curve of the form z = C1 + C2*x + C3*x^2

and the resulting output dependent variable is considered unitless

Parameters:

  • coeffs (Array<Double>)

    an array of 3 coefficients, in order

  • crv_name (String)

    the name of the curve

  • min_x (Double)

    the minimum value of independent variable X that will be used

  • max_x (Double)

    the maximum value of independent variable X that will be used

  • min_out (Double)

    the minimum value of dependent variable Z

  • max_out (Double)

    the maximum value of dependent variable Z

  • is_dimensionless (Bool) (defaults to: false)

    if true, the X independent variable is considered unitless

Author:

  • Scott Horowitz, NREL



554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 554

def create_curve_quadratic(model, coeffs, crv_name, min_x, max_x, min_out, max_out, is_dimensionless = false)
  curve = OpenStudio::Model::CurveQuadratic.new(model)
  curve.setName(crv_name)
  curve.setCoefficient1Constant(coeffs[0])
  curve.setCoefficient2x(coeffs[1])
  curve.setCoefficient3xPOW2(coeffs[2])
  curve.setMinimumValueofx(min_x) unless min_x.nil?
  curve.setMaximumValueofx(max_x) unless max_x.nil?
  curve.setMinimumCurveOutput(min_out) unless min_out.nil?
  curve.setMaximumCurveOutput(max_out) unless max_out.nil?
  if is_dimensionless
    curve.setInputUnitTypeforX('Dimensionless')
    curve.setOutputUnitType('Dimensionless')
  end
  return curve
end

#create_fan_constant_volume(model, fan_name: nil, fan_efficiency: nil, pressure_rise: nil, motor_efficiency: nil, motor_in_airstream_fraction: nil, end_use_subcategory: nil) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanConstantVolume.rb', line 87

def create_fan_constant_volume(model,
                               fan_name: nil,
                               fan_efficiency: nil,
                               pressure_rise: nil,
                               motor_efficiency: nil,
                               motor_in_airstream_fraction: nil,
                               end_use_subcategory: nil)
  fan = OpenStudio::Model::FanConstantVolume.new(model)
  PrototypeFan.apply_base_fan_variables(fan,
                                        fan_name: fan_name,
                                        fan_efficiency: fan_efficiency,
                                        pressure_rise: pressure_rise,
                                        end_use_subcategory: end_use_subcategory)
  fan.setMotorEfficiency(motor_efficiency) unless motor_efficiency.nil?
  fan.setMotorInAirstreamFraction(motor_in_airstream_fraction) unless motor_in_airstream_fraction.nil?
  return fan
end

#create_fan_constant_volume_from_json(model, fan_json, fan_name: nil, fan_efficiency: nil, pressure_rise: nil, motor_efficiency: nil, motor_in_airstream_fraction: nil, end_use_subcategory: nil) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanConstantVolume.rb', line 105

def create_fan_constant_volume_from_json(model,
                                         fan_json,
                                         fan_name: nil,
                                         fan_efficiency: nil,
                                         pressure_rise: nil,
                                         motor_efficiency: nil,
                                         motor_in_airstream_fraction: nil,
                                         end_use_subcategory: nil)
  # check values to use
  fan_efficiency ||= fan_json['fan_efficiency']
  pressure_rise ||= fan_json['pressure_rise']
  motor_efficiency ||= fan_json['motor_efficiency']
  motor_in_airstream_fraction ||= fan_json['motor_in_airstream_fraction']
  end_use_subcategory ||= fan_json['end_use_subcategory']

  # convert values
  pressure_rise = pressure_rise ? OpenStudio.convert(pressure_rise, 'inH_{2}O', 'Pa').get : nil

  # create fan
  fan = create_fan_constant_volume(model,
                                   fan_name: fan_name,
                                   fan_efficiency: fan_efficiency,
                                   pressure_rise: pressure_rise,
                                   motor_efficiency: motor_efficiency,
                                   motor_in_airstream_fraction: motor_in_airstream_fraction,
                                   end_use_subcategory: end_use_subcategory)
  return fan
end

#create_fan_on_off(model, fan_name: nil, fan_efficiency: nil, pressure_rise: nil, motor_efficiency: nil, motor_in_airstream_fraction: nil, end_use_subcategory: nil) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanOnOff.rb', line 93

def create_fan_on_off(model,
                      fan_name: nil,
                      fan_efficiency: nil,
                      pressure_rise: nil,
                      motor_efficiency: nil,
                      motor_in_airstream_fraction: nil,
                      end_use_subcategory: nil)
  fan = OpenStudio::Model::FanOnOff.new(model)
  PrototypeFan.apply_base_fan_variables(fan,
                                        fan_name: fan_name,
                                        fan_efficiency: fan_efficiency,
                                        pressure_rise: pressure_rise,
                                        end_use_subcategory: end_use_subcategory)
  fan.setMotorEfficiency(motor_efficiency) unless motor_efficiency.nil?
  fan.setMotorInAirstreamFraction(motor_in_airstream_fraction) unless motor_in_airstream_fraction.nil?
  return fan
end

#create_fan_on_off_from_json(model, fan_json, fan_name: nil, fan_efficiency: nil, pressure_rise: nil, motor_efficiency: nil, motor_in_airstream_fraction: nil, end_use_subcategory: nil) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanOnOff.rb', line 111

def create_fan_on_off_from_json(model,
                                fan_json,
                                fan_name: nil,
                                fan_efficiency: nil,
                                pressure_rise: nil,
                                motor_efficiency: nil,
                                motor_in_airstream_fraction: nil,
                                end_use_subcategory: nil)
  # check values to use
  fan_efficiency ||= fan_json['fan_efficiency']
  pressure_rise ||= fan_json['pressure_rise']
  motor_efficiency ||= fan_json['motor_efficiency']
  motor_in_airstream_fraction ||= fan_json['motor_in_airstream_fraction']

  # convert values
  pressure_rise = pressure_rise ? OpenStudio.convert(pressure_rise, 'inH_{2}O', 'Pa').get : nil

  # create fan
  fan = create_fan_on_off(model,
                          fan_name: fan_name,
                          fan_efficiency: fan_efficiency,
                          pressure_rise: pressure_rise,
                          motor_efficiency: motor_efficiency,
                          motor_in_airstream_fraction: motor_in_airstream_fraction,
                          end_use_subcategory: end_use_subcategory)
  return fan
end

#create_fan_variable_volume(model, fan_name: nil, fan_efficiency: nil, pressure_rise: nil, motor_efficiency: nil, motor_in_airstream_fraction: nil, fan_power_minimum_flow_rate_input_method: nil, fan_power_minimum_flow_rate_fraction: nil, fan_power_coefficient_1: nil, fan_power_coefficient_2: nil, fan_power_coefficient_3: nil, fan_power_coefficient_4: nil, fan_power_coefficient_5: nil, end_use_subcategory: nil) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanVariableVolume.rb', line 85

def create_fan_variable_volume(model,
                               fan_name: nil,
                               fan_efficiency: nil,
                               pressure_rise: nil,
                               motor_efficiency: nil,
                               motor_in_airstream_fraction: nil,
                               fan_power_minimum_flow_rate_input_method: nil,
                               fan_power_minimum_flow_rate_fraction: nil,
                               fan_power_coefficient_1: nil,
                               fan_power_coefficient_2: nil,
                               fan_power_coefficient_3: nil,
                               fan_power_coefficient_4: nil,
                               fan_power_coefficient_5: nil,
                               end_use_subcategory: nil)
  fan = OpenStudio::Model::FanVariableVolume.new(model)
  PrototypeFan.apply_base_fan_variables(fan,
                                        fan_name: fan_name,
                                        fan_efficiency: fan_efficiency,
                                        pressure_rise: pressure_rise,
                                        end_use_subcategory: end_use_subcategory)
  fan.setMotorEfficiency(motor_efficiency) unless motor_efficiency.nil?
  fan.setMotorInAirstreamFraction(motor_in_airstream_fraction) unless motor_in_airstream_fraction.nil?
  fan.setFanPowerMinimumFlowRateInputMethod(fan_power_minimum_flow_rate_input_method) unless fan_power_minimum_flow_rate_input_method.nil?
  fan.setFanPowerMinimumFlowFraction(fan_power_minimum_flow_rate_fraction) unless fan_power_minimum_flow_rate_fraction.nil?
  fan.setFanPowerCoefficient1(fan_power_coefficient_1) unless fan_power_coefficient_1.nil?
  fan.setFanPowerCoefficient2(fan_power_coefficient_2) unless fan_power_coefficient_2.nil?
  fan.setFanPowerCoefficient3(fan_power_coefficient_3) unless fan_power_coefficient_3.nil?
  fan.setFanPowerCoefficient4(fan_power_coefficient_4) unless fan_power_coefficient_4.nil?
  fan.setFanPowerCoefficient5(fan_power_coefficient_5) unless fan_power_coefficient_5.nil?
  return fan
end

#create_fan_variable_volume_from_json(model, fan_json, fan_name: nil, fan_efficiency: nil, pressure_rise: nil, motor_efficiency: nil, motor_in_airstream_fraction: nil, fan_power_minimum_flow_rate_input_method: nil, fan_power_minimum_flow_rate_fraction: nil, end_use_subcategory: nil, fan_power_coefficient_1: nil, fan_power_coefficient_2: nil, fan_power_coefficient_3: nil, fan_power_coefficient_4: nil, fan_power_coefficient_5: nil) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanVariableVolume.rb', line 117

def create_fan_variable_volume_from_json(model,
                                         fan_json,
                                         fan_name: nil,
                                         fan_efficiency: nil,
                                         pressure_rise: nil,
                                         motor_efficiency: nil,
                                         motor_in_airstream_fraction: nil,
                                         fan_power_minimum_flow_rate_input_method: nil,
                                         fan_power_minimum_flow_rate_fraction: nil,
                                         end_use_subcategory: nil,
                                         fan_power_coefficient_1: nil,
                                         fan_power_coefficient_2: nil,
                                         fan_power_coefficient_3: nil,
                                         fan_power_coefficient_4: nil,
                                         fan_power_coefficient_5: nil)
  # check values to use
  fan_efficiency ||= fan_json['fan_efficiency']
  pressure_rise ||= fan_json['pressure_rise']
  motor_efficiency ||= fan_json['motor_efficiency']
  motor_in_airstream_fraction ||= fan_json['motor_in_airstream_fraction']
  fan_power_minimum_flow_rate_input_method ||= fan_json['fan_power_minimum_flow_rate_input_method']
  fan_power_minimum_flow_rate_fraction ||= fan_json['fan_power_minimum_flow_rate_fraction']
  fan_power_coefficient_1 ||= fan_json['fan_power_coefficient_1']
  fan_power_coefficient_2 ||= fan_json['fan_power_coefficient_2']
  fan_power_coefficient_3 ||= fan_json['fan_power_coefficient_3']
  fan_power_coefficient_4 ||= fan_json['fan_power_coefficient_4']
  fan_power_coefficient_5 ||= fan_json['fan_power_coefficient_5']

  # convert values
  pressure_rise_pa = OpenStudio.convert(pressure_rise, 'inH_{2}O', 'Pa').get unless pressure_rise.nil?

  # create fan
  fan = create_fan_variable_volume(model,
                                   fan_name: fan_name,
                                   fan_efficiency: fan_efficiency,
                                   pressure_rise: pressure_rise_pa,
                                   motor_efficiency: motor_efficiency,
                                   motor_in_airstream_fraction: motor_in_airstream_fraction,
                                   fan_power_minimum_flow_rate_input_method: fan_power_minimum_flow_rate_input_method,
                                   fan_power_minimum_flow_rate_fraction: fan_power_minimum_flow_rate_fraction,
                                   end_use_subcategory: end_use_subcategory,
                                   fan_power_coefficient_1: fan_power_coefficient_1,
                                   fan_power_coefficient_2: fan_power_coefficient_2,
                                   fan_power_coefficient_3: fan_power_coefficient_3,
                                   fan_power_coefficient_4: fan_power_coefficient_4,
                                   fan_power_coefficient_5: fan_power_coefficient_5)
  return fan
end

#create_fan_zone_exhaust(model, fan_name: nil, fan_efficiency: nil, pressure_rise: nil, system_availability_manager_coupling_mode: nil, end_use_subcategory: nil) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanZoneExhaust.rb', line 50

def create_fan_zone_exhaust(model,
                            fan_name: nil,
                            fan_efficiency: nil,
                            pressure_rise: nil,
                            system_availability_manager_coupling_mode: nil,
                            end_use_subcategory: nil)
  fan = OpenStudio::Model::FanZoneExhaust.new(model)
  PrototypeFan.apply_base_fan_variables(fan,
                                        fan_name: fan_name,
                                        fan_efficiency: fan_efficiency,
                                        pressure_rise: pressure_rise,
                                        end_use_subcategory: end_use_subcategory)
  fan.setSystemAvailabilityManagerCouplingMode(system_availability_manager_coupling_mode) unless system_availability_manager_coupling_mode.nil?
  return fan
end

#create_fan_zone_exhaust_from_json(model, fan_json, fan_name: nil, fan_efficiency: nil, pressure_rise: nil, system_availability_manager_coupling_mode: nil, end_use_subcategory: nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanZoneExhaust.rb', line 24

def create_fan_zone_exhaust_from_json(model,
                                      fan_json,
                                      fan_name: nil,
                                      fan_efficiency: nil,
                                      pressure_rise: nil,
                                      system_availability_manager_coupling_mode: nil,
                                      end_use_subcategory: nil)

  # check values to use
  fan_efficiency ||= fan_json['fan_efficiency']
  pressure_rise ||= fan_json['pressure_rise']
  system_availability_manager_coupling_mode ||= fan_json['system_availability_manager_coupling_mode']

  # convert values
  pressure_rise = pressure_rise ? OpenStudio.convert(pressure_rise, 'inH_{2}O', 'Pa').get : nil

  # create fan
  fan = create_fan_zone_exhaust(model,
                                fan_name: fan_name,
                                fan_efficiency: fan_efficiency,
                                pressure_rise: pressure_rise,
                                system_availability_manager_coupling_mode: system_availability_manager_coupling_mode,
                                end_use_subcategory: end_use_subcategory)
  return fan
end

#day_schedule_equivalent_full_load_hrs(day_sch) ⇒ Double

Returns the min and max value for this schedule_day object

Parameters:

  • daySchedule (object)

Returns:

  • (Double)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/openstudio-standards/standards/Standards.ScheduleRuleset.rb', line 8

def day_schedule_equivalent_full_load_hrs(day_sch)
  # Determine the full load hours for just one day
  daily_flh = 0
  values = day_sch.values
  times = day_sch.times

  previous_time_decimal = 0
  times.each_with_index do |time, i|
    time_decimal = (time.days * 24.0) + time.hours + (time.minutes / 60.0) + (time.seconds / 3600.0)
    duration_of_value = time_decimal - previous_time_decimal
    # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "  Value of #{values[i]} for #{duration_of_value} hours")
    daily_flh += values[i] * duration_of_value
    previous_time_decimal = time_decimal
  end

  # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "  #{daily_flh.round(2)} EFLH per day")
  # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "  Used #{number_of_days_sch_used} days per year")

  return daily_flh
end

#define_space_multiplierObject



7
8
9
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 7

def define_space_multiplier
  return @space_multiplier_map
end

#eer_to_cop(eer, capacity_w = nil) ⇒ Double

Convert from EER to COP

Parameters:

  • eer (Double)

    Energy Efficiency Ratio (EER)

  • capacity_w (Double) (defaults to: nil)

    the heating capacity at AHRI rating conditions, in W

Returns:

  • (Double)

    Coefficient of Performance (COP)



309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 309

def eer_to_cop(eer, capacity_w = nil)
  if capacity_w.nil?
    # The PNNL Method.
    # r is the ratio of supply fan power to total equipment power at the rating condition,
    # assumed to be 0.12 for the reference buildings per PNNL.
    r = 0.12
    cop = (eer / 3.413 + r) / (1 - r)
  else
    # The 90.1-2013 method
    # Convert the capacity to Btu/hr
    capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get
    cop = 7.84E-8 * eer * capacity_btu_per_hr + 0.338 * eer
  end

  return cop
end

#fan_constant_volume_airloop_fan_pressure_rise(fan_constant_volume) ⇒ Double

Determine the prototype fan pressure rise for a constant volume fan on an AirLoopHVAC based on the airflow of the system. to the logic from ASHRAE 90.1-2004 prototypes.

Returns:

  • (Double)

    the pressure rise (in H2O). Defaults



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanConstantVolume.rb', line 60

def fan_constant_volume_airloop_fan_pressure_rise(fan_constant_volume)
  # Get the max flow rate from the fan.
  maximum_flow_rate_m3_per_s = nil
  if fan_constant_volume.maximumFlowRate.is_initialized
    maximum_flow_rate_m3_per_s = fan_constant_volume.maximumFlowRate.get
  elsif fan_constant_volume.autosizedMaximumFlowRate.is_initialized
    maximum_flow_rate_m3_per_s = fan_constant_volume.autosizedMaximumFlowRate.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.prototype.FanConstantVolume', "For #{fan_constant_volume.name} max flow rate is not available, cannot apply prototype assumptions.")
    return false
  end

  # Convert max flow rate to cfm
  maximum_flow_rate_cfm = OpenStudio.convert(maximum_flow_rate_m3_per_s, 'm^3/s', 'cfm').get

  # Determine the pressure rise
  pressure_rise_in_h2o = if maximum_flow_rate_cfm < 7437
                           2.5
                         elsif maximum_flow_rate_cfm >= 7437 && maximum_flow_rate_cfm < 20_000
                           4.46
                         else # Over 20,000 cfm
                           4.09
                         end

  return pressure_rise_in_h2o
end

#fan_constant_volume_apply_prototype_fan_pressure_rise(fan_constant_volume) ⇒ Object

Sets the fan pressure rise based on the Prototype buildings inputs which are governed by the flow rate coming through the fan and whether the fan lives inside a unit heater, PTAC, etc.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanConstantVolume.rb', line 8

def fan_constant_volume_apply_prototype_fan_pressure_rise(fan_constant_volume)
  # Don't modify unit heater fans
  return true if fan_constant_volume.name.to_s.include?('UnitHeater Fan')

  # Get the max flow rate from the fan.
  maximum_flow_rate_m3_per_s = nil
  if fan_constant_volume.maximumFlowRate.is_initialized
    maximum_flow_rate_m3_per_s = fan_constant_volume.maximumFlowRate.get
  elsif fan_constant_volume.autosizedMaximumFlowRate.is_initialized
    maximum_flow_rate_m3_per_s = fan_constant_volume.autosizedMaximumFlowRate.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.prototype.FanConstantVolume', "For #{fan_constant_volume.name} max flow rate is not available, cannot apply prototype assumptions.")
    return false
  end

  # Convert max flow rate to cfm
  maximum_flow_rate_cfm = OpenStudio.convert(maximum_flow_rate_m3_per_s, 'm^3/s', 'cfm').get

  # Pressure rise will be determined based on the
  # following logic.
  pressure_rise_in_h2o = 0.0

  # If the fan lives inside of a zone hvac equipment
  if fan_constant_volume.containingZoneHVACComponent.is_initialized
    zone_hvac = fan_constant_volume.containingZoneHVACComponent.get
    if zone_hvac.to_ZoneHVACPackagedTerminalAirConditioner.is_initialized
      pressure_rise_in_h2o = 1.33
    elsif zone_hvac.to_ZoneHVACFourPipeFanCoil.is_initialized
      pressure_rise_in_h2o = 1.33
    elsif zone_hvac.to_ZoneHVACUnitHeater.is_initialized
      pressure_rise_in_h2o = 0.2
    else # This type of fan should not exist in the prototype models
      return false
    end
  # If the fan lives on an airloop
  elsif fan_constant_volume.airLoopHVAC.is_initialized
    pressure_rise_in_h2o = fan_constant_volume_airloop_fan_pressure_rise(fan_constant_volume)
  end

  # Set the fan pressure rise
  pressure_rise_pa = OpenStudio.convert(pressure_rise_in_h2o, 'inH_{2}O', 'Pa').get
  fan_constant_volume.setPressureRise(pressure_rise_pa)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.FanConstantVolume', "For Prototype: #{fan_constant_volume.name}: #{maximum_flow_rate_cfm.round}cfm; Pressure Rise = #{pressure_rise_in_h2o}in w.c.")

  return true
end

#fan_on_off_airloop_or_unitary_fan_pressure_rise(fan_on_off) ⇒ Double

Determine the prototype fan pressure rise for an on off fan on an AirLoopHVAC or inside a unitary system based on the airflow of the system. to the logic from ASHRAE 90.1-2004 prototypes.

Returns:

  • (Double)

    the pressure rise (in H2O). Defaults



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanOnOff.rb', line 66

def fan_on_off_airloop_or_unitary_fan_pressure_rise(fan_on_off)
  # Get the max flow rate from the fan.
  maximum_flow_rate_m3_per_s = nil
  if fan_on_off.maximumFlowRate.is_initialized
    maximum_flow_rate_m3_per_s = fan_on_off.maximumFlowRate.get
  elsif fan_on_off.autosizedMaximumFlowRate.is_initialized
    maximum_flow_rate_m3_per_s = fan_on_off.autosizedMaximumFlowRate.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.prototype.FanOnOff', "For #{fan_on_off.name} max flow rate is not available, cannot apply prototype assumptions.")
    return false
  end

  # Convert max flow rate to cfm
  maximum_flow_rate_cfm = OpenStudio.convert(maximum_flow_rate_m3_per_s, 'm^3/s', 'cfm').get

  # Determine the pressure rise
  pressure_rise_in_h2o = if maximum_flow_rate_cfm < 7437
                           2.5
                         elsif maximum_flow_rate_cfm >= 7437 && maximum_flow_rate_cfm < 20_000
                           4.46
                         else # Over 20,000 cfm
                           4.09
                         end

  return pressure_rise_in_h2o
end

#fan_on_off_apply_prototype_fan_pressure_rise(fan_on_off) ⇒ Object

Sets the fan pressure rise based on the Prototype buildings inputs which are governed by the flow rate coming through the fan and whether the fan lives inside a unit heater, PTAC, etc.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanOnOff.rb', line 9

def fan_on_off_apply_prototype_fan_pressure_rise(fan_on_off)
  # Get the max flow rate from the fan.
  maximum_flow_rate_m3_per_s = nil
  if fan_on_off.maximumFlowRate.is_initialized
    maximum_flow_rate_m3_per_s = fan_on_off.maximumFlowRate.get
  elsif fan_on_off.autosizedMaximumFlowRate.is_initialized
    maximum_flow_rate_m3_per_s = fan_on_off.autosizedMaximumFlowRate.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.prototype.FanOnOff', "For #{fan_on_off.name} max flow rate is not available, cannot apply prototype assumptions.")
    return false
  end

  # Convert max flow rate to cfm
  maximum_flow_rate_cfm = OpenStudio.convert(maximum_flow_rate_m3_per_s, 'm^3/s', 'cfm').get

  # Pressure rise will be determined based on the
  # following logic.
  pressure_rise_in_h2o = 0.0

  # If the fan lives inside of a zone hvac equipment
  if fan_on_off.containingZoneHVACComponent.is_initialized
    zone_hvac = fan_on_off.containingZoneHVACComponent.get
    if zone_hvac.to_ZoneHVACPackagedTerminalAirConditioner.is_initialized
      pressure_rise_in_h2o = 1.33
    elsif zone_hvac.to_ZoneHVACFourPipeFanCoil.is_initialized
      pressure_rise_in_h2o = 1.087563267
    elsif zone_hvac.to_ZoneHVACUnitHeater.is_initialized
      pressure_rise_in_h2o = 0.2
    else # This type of fan should not exist in the prototype models
      return false
    end
  end

  # If the fan lives on an airloop
  if fan_on_off.airLoopHVAC.is_initialized
    pressure_rise_in_h2o = fan_on_off_airloop_or_unitary_fan_pressure_rise(fan_on_off)
  end

  # If the fan lives inside a unitary system
  if fan_on_off.airLoopHVAC.empty? && fan_on_off.containingZoneHVACComponent.empty?
    pressure_rise_in_h2o = fan_on_off_airloop_or_unitary_fan_pressure_rise(fan_on_off)
  end

  # Set the fan pressure rise
  pressure_rise_pa = OpenStudio.convert(pressure_rise_in_h2o, 'inH_{2}O', 'Pa').get
  fan_on_off.setPressureRise(pressure_rise_pa)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.FanOnOff', "For Prototype: #{fan_on_off.name}: #{maximum_flow_rate_cfm.round}cfm; Pressure Rise = #{pressure_rise_in_h2o}in w.c.")

  return true
end

#fan_variable_volume_airloop_fan_pressure_rise(fan_variable_volume) ⇒ Double

Determine the prototype fan pressure rise for a variable volume fan on an AirLoopHVAC based on the airflow of the system. to the logic from ASHRAE 90.1-2004 prototypes.

Returns:

  • (Double)

    the pressure rise (in H2O). Defaults



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanVariableVolume.rb', line 58

def fan_variable_volume_airloop_fan_pressure_rise(fan_variable_volume)
  # Get the max flow rate from the fan.
  maximum_flow_rate_m3_per_s = nil
  if fan_variable_volume.maximumFlowRate.is_initialized
    maximum_flow_rate_m3_per_s = fan_variable_volume.maximumFlowRate.get
  elsif fan_variable_volume.autosizedMaximumFlowRate.is_initialized
    maximum_flow_rate_m3_per_s = fan_variable_volume.autosizedMaximumFlowRate.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.prototype.FanVariableVolume', "For #{fan_variable_volume.name} max flow rate is not available, cannot apply prototype assumptions.")
    return false
  end

  # Convert max flow rate to cfm
  maximum_flow_rate_cfm = OpenStudio.convert(maximum_flow_rate_m3_per_s, 'm^3/s', 'cfm').get

  # Determine the pressure rise
  pressure_rise_in_h2o = if maximum_flow_rate_cfm < 4648
                           4.0
                         elsif maximum_flow_rate_cfm >= 4648 && maximum_flow_rate_cfm < 20_000
                           6.32
                         else # Over 20,000 cfm
                           5.58
                         end

  return pressure_rise_in_h2o
end

#fan_variable_volume_apply_prototype_fan_pressure_rise(fan_variable_volume) ⇒ Object

Sets the fan pressure rise based on the Prototype buildings inputs which are governed by the flow rate coming through the fan and whether the fan lives inside a unit heater, PTAC, etc.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanVariableVolume.rb', line 9

def fan_variable_volume_apply_prototype_fan_pressure_rise(fan_variable_volume)
  # Get the max flow rate from the fan.
  maximum_flow_rate_m3_per_s = nil
  if fan_variable_volume.maximumFlowRate.is_initialized
    maximum_flow_rate_m3_per_s = fan_variable_volume.maximumFlowRate.get
  elsif fan_variable_volume.autosizedMaximumFlowRate.is_initialized
    maximum_flow_rate_m3_per_s = fan_variable_volume.autosizedMaximumFlowRate.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.prototype.FanVariableVolume', "For #{fan_variable_volume.name} max flow rate is not available, cannot apply prototype assumptions.")
    return false
  end

  # Convert max flow rate to cfm
  maximum_flow_rate_cfm = OpenStudio.convert(maximum_flow_rate_m3_per_s, 'm^3/s', 'cfm').get

  # Pressure rise will be determined based on the
  # following logic.
  pressure_rise_in_h2o = 0.0

  # If the fan lives inside of a zone hvac equipment
  if fan_variable_volume.containingZoneHVACComponent.is_initialized
    zone_hvac = fan_variable_volume.ZoneHVACComponent.get
    if zone_hvac.to_ZoneHVACPackagedTerminalAirConditioner.is_initialized
      pressure_rise_in_h2o = 1.33
    elsif zone_hvac.to_ZoneHVACFourPipeFanCoil.is_initialized
      pressure_rise_in_h2o = 1.33
    elsif zone_hvac.to_ZoneHVACUnitHeater.is_initialized
      pressure_rise_in_h2o = 0.2
    else # This type of fan should not exist in the prototype models
      return false
    end
  # If the fan lives on an airloop
  elsif fan_variable_volume.airLoopHVAC.is_initialized
    pressure_rise_in_h2o = fan_variable_volume_airloop_fan_pressure_rise(fan_variable_volume)
  end

  # Set the fan pressure rise
  pressure_rise_pa = OpenStudio.convert(pressure_rise_in_h2o, 'inH_{2}O', 'Pa').get
  fan_variable_volume.setPressureRise(pressure_rise_pa)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.FanVariableVolume', "For Prototype: #{fan_variable_volume.name}: #{maximum_flow_rate_cfm.round}cfm; Pressure Rise = #{pressure_rise_in_h2o}in w.c.")

  return true
end

#fan_variable_volume_cooling_system_type(fan_variable_volume) ⇒ String

Determine if the cooling system is DX, CHW, evaporative, or a mixture. dx, chw, evaporative, mixed, unknown.

Returns:

  • (String)

    the cooling system type. Possible options are:



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/openstudio-standards/standards/Standards.FanVariableVolume.rb', line 181

def fan_variable_volume_cooling_system_type(fan_variable_volume)
  clg_sys_type = 'unknown'

  # Get the air loop this fan is connected to
  air_loop = fan_variable_volume.airLoopHVAC
  return clg_sys_type unless air_loop.is_initialized

  air_loop = air_loop.get

  # Check the types of coils on the AirLoopHVAC
  has_dx = false
  has_chw = false
  has_evap = false
  air_loop.supplyComponents.each do |sc|
    # CoilCoolingDXSingleSpeed
    if sc.to_CoilCoolingDXSingleSpeed.is_initialized
      has_dx = true
    # CoilCoolingDXTwoSpeed
    elsif sc.to_CoilCoolingDXTwoSpeed.is_initialized
      has_dx = true
    # CoilCoolingMultiSpeed
    elsif sc.to_CoilCoolingDXMultiSpeed.is_initialized
      has_dx = true
    # CoilCoolingWater
    elsif sc.to_CoilCoolingWater.is_initialized
      has_chw = true
    # CoilCoolingWaterToAirHeatPumpEquationFit
    elsif sc.to_CoilCoolingWaterToAirHeatPumpEquationFit.is_initialized
      has_dx = true
    # UnitarySystem
    elsif sc.to_AirLoopHVACUnitarySystem.is_initialized
      unitary = sc.to_AirLoopHVACUnitarySystem.get
      if unitary.coolingCoil.is_initialized
        clg_coil = unitary.coolingCoil.get
        # CoilCoolingDXSingleSpeed
        if clg_coil.to_CoilCoolingDXSingleSpeed.is_initialized
          has_dx = true
        # CoilCoolingDXTwoSpeed
        elsif clg_coil.to_CoilCoolingDXTwoSpeed.is_initialized
          has_dx = true
        # CoilCoolingWater
        elsif clg_coil.to_CoilCoolingWater.is_initialized
          has_chw = true
        # CoilCoolingWaterToAirHeatPumpEquationFit
        elsif clg_coil.to_CoilCoolingWaterToAirHeatPumpEquationFit.is_initialized
          has_dx = true
        end
      end
    # UnitaryHeatPumpAirToAir
    elsif sc.to_AirLoopHVACUnitaryHeatPumpAirToAir.is_initialized
      unitary = sc.to_AirLoopHVACUnitaryHeatPumpAirToAir.get
      clg_coil = unitary.coolingCoil
      # CoilCoolingDXSingleSpeed
      if clg_coil.to_CoilCoolingDXSingleSpeed.is_initialized
        has_dx = true
      # CoilCoolingDXTwoSpeed
      elsif clg_coil.to_CoilCoolingDXTwoSpeed.is_initialized
        has_dx = true
      # CoilCoolingWater
      elsif clg_coil.to_CoilCoolingWater.is_initialized
        has_chw = true
      end
    # EvaporativeCoolerDirectResearchSpecial
    elsif sc.to_EvaporativeCoolerDirectResearchSpecial.is_initialized
      has_evap = true
    # EvaporativeCoolerIndirectResearchSpecial
    elsif sc.to_EvaporativeCoolerIndirectResearchSpecial.is_initialized
      has_evap = true
    elsif sc.to_CoilCoolingCooledBeam.is_initialized ||
          sc.to_AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass.is_initialized ||
          sc.to_AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.is_initialized ||
          sc.to_AirLoopHVACUnitarySystem.is_initialized
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.FanVariableVolume', "#{air_loop.name} has a cooling coil named #{sc.name}, whose type is not yet covered by cooling system type checks.")
    end
  end

  # Determine the type
  if (has_chw && has_dx && has_evap) ||
     (has_chw && has_dx) ||
     (has_chw && has_evap) ||
     (has_dx && has_evap)
    clg_sys_type = 'mixed'
  elsif has_chw
    clg_sys_type = 'chw'
  elsif has_dx
    clg_sys_type = 'dx'
  elsif has_evap
    clg_sys_type = 'evap'
  end

  return clg_sys_type
end

#fan_variable_volume_part_load_fan_power_limitation?(fan_variable_volume) ⇒ Boolean

Determines whether there is a requirement to have a VSD or some other method to reduce fan power at low part load ratios.

Returns:

  • (Boolean)


113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/openstudio-standards/standards/Standards.FanVariableVolume.rb', line 113

def fan_variable_volume_part_load_fan_power_limitation?(fan_variable_volume)
  part_load_control_required = false

  # Check if the fan is on a multizone or single zone system.
  # If not on an AirLoop (for example, in unitary system or zone equipment), assumed to be a single zone fan
  mz_fan = false
  if fan_variable_volume.airLoopHVAC.is_initialized
    air_loop = fan_variable_volume.airLoopHVAC.get
    mz_fan = air_loop_hvac_multizone_vav_system?(air_loop)
  end

  # No part load fan power control is required for single zone VAV systems
  unless mz_fan
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.FanVariableVolume', "For #{fan_variable_volume.name}: No part load fan power control is required for single zone VAV systems.")
    return part_load_control_required
  end

  # Determine the motor and capacity size limits
  hp_limit = fan_variable_volume_part_load_fan_power_limitation_hp_limit(fan_variable_volume)
  cap_limit_btu_per_hr = fan_variable_volume_part_load_fan_power_limitation_capacity_limit(fan_variable_volume)

  # Check against limits
  if hp_limit && cap_limit_btu_per_hr
    air_loop = fan_variable_volume.airLoopHVAC
    unless air_loop.is_initialized
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.FanVariableVolume', "For #{fan_variable_volume.name}: Could not find the air loop to get cooling capacity for determining part load fan power control requirement.")
      return part_load_control_required
    end
    air_loop = air_loop.get
    clg_cap_w = air_loop_hvac_total_cooling_capacity(air_loop)
    clg_cap_btu_per_hr = OpenStudio.convert(clg_cap_w, 'W', 'Btu/hr').get
    fan_hp = fan_motor_horsepower(fan_variable_volume)
    if fan_hp >= hp_limit && clg_cap_btu_per_hr >= cap_limit_btu_per_hr
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.FanVariableVolume', "For #{fan_variable_volume.name}: part load fan power control is required for #{fan_hp.round(1)} HP fan, #{clg_cap_btu_per_hr.round} Btu/hr cooling capacity.")
      part_load_control_required = true
    end
  elsif hp_limit
    fan_hp = fan_motor_horsepower(fan_variable_volume)
    if fan_hp >= hp_limit
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.FanVariableVolume', "For #{fan_variable_volume.name}: Part load fan power control is required for #{fan_hp.round(1)} HP fan.")
      part_load_control_required = true
    end
  end

  return part_load_control_required
end

#fan_variable_volume_part_load_fan_power_limitation_capacity_limit(fan_variable_volume) ⇒ Double

The threhold capacity below which part load control is not required.

Parameters:

Returns:

  • (Double)

    the limit, in Btu/hr. Return nil for no limit by default.



173
174
175
176
# File 'lib/openstudio-standards/standards/Standards.FanVariableVolume.rb', line 173

def fan_variable_volume_part_load_fan_power_limitation_capacity_limit(fan_variable_volume)
  cap_limit_btu_per_hr = nil # No minimum limit
  return cap_limit_btu_per_hr
end

#fan_variable_volume_part_load_fan_power_limitation_hp_limit(fan_variable_volume) ⇒ Double

The threhold horsepower below which part load control is not required.

Parameters:

Returns:

  • (Double)

    the limit, in horsepower. Return nil for no limit by default.



164
165
166
167
# File 'lib/openstudio-standards/standards/Standards.FanVariableVolume.rb', line 164

def fan_variable_volume_part_load_fan_power_limitation_hp_limit(fan_variable_volume)
  hp_limit = nil # No minimum limit
  return hp_limit
end

#fan_variable_volume_set_control_type(fan_variable_volume, control_type) ⇒ Object

Modify the fan curve coefficients to reflect a specific type of control.

Multi Zone VAV with discharge dampers, Multi Zone VAV with VSD and SP Setpoint Reset, Multi Zone VAV with AF or BI Riding Curve, Multi Zone VAV with AF or BI with Inlet Vanes, Multi Zone VAV with FC Riding Curve, Multi Zone VAV with FC with Inlet Vanes, Multi Zone VAV with Vane-axial with Variable Pitch Blades, Multi Zone VAV with VSD and Fixed SP Setpoint, Multi Zone VAV with VSD and Static Pressure Reset, Single Zone VAV Fan

Parameters:

  • control_type (String)

    valid choices are:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/openstudio-standards/standards/Standards.FanVariableVolume.rb', line 19

def fan_variable_volume_set_control_type(fan_variable_volume, control_type)
  # Determine the coefficients
  coeff_a = nil
  coeff_b = nil
  coeff_c = nil
  coeff_d = nil
  min_pct_pwr = nil
  case control_type

  # add 'Multi Zone VAV with discharge dampers' and change the minimum fan power fraction of "Multi Zone VAV with VSD and Static Pressure Reset"
  when 'Multi Zone VAV with discharge dampers'
    coeff_a = 0.18984763
    coeff_b = 0.31447014
    coeff_c = 0.49568211
    coeff_d = 0.0
    min_pct_pwr = 0.25
  when 'Multi Zone VAV with VSD and SP Setpoint Reset'
    coeff_a = 0.04076
    coeff_b = 0.0881
    coeff_c = -0.0729
    coeff_d = 0.9437
    min_pct_pwr = 0.25
  when 'Multi Zone VAV with AF or BI Riding Curve'
    coeff_a = 0.1631
    coeff_b = 1.5901
    coeff_c = -0.8817
    coeff_d = 0.1281
    min_pct_pwr = 0.7
  when 'Multi Zone VAV with AF or BI with Inlet Vanes'
    coeff_a = 0.9977
    coeff_b = -0.659
    coeff_c = 0.9547
    coeff_d = -0.2936
    min_pct_pwr = 0.5
  when 'Multi Zone VAV with FC Riding Curve'
    coeff_a = 0.1224
    coeff_b = 0.612
    coeff_c = 0.5983
    coeff_d = -0.3334
    min_pct_pwr = 0.3
  when 'Multi Zone VAV with FC with Inlet Vanes'
    coeff_a = 0.3038
    coeff_b = -0.7608
    coeff_c = 2.2729
    coeff_d = -0.8169
    min_pct_pwr = 0.3
  when 'Multi Zone VAV with Vane-axial with Variable Pitch Blades'
    coeff_a = 0.1639
    coeff_b = -0.4016
    coeff_c = 1.9909
    coeff_d = -0.7541
    min_pct_pwr = 0.2
  when 'Multi Zone VAV with VSD and Fixed SP Setpoint'
    coeff_a = 0.0013
    coeff_b = 0.1470
    coeff_c = 0.9506
    coeff_d = -0.0998
    min_pct_pwr = 0.2
  when 'Multi Zone VAV with VSD and Static Pressure Reset'
    coeff_a = 0.04076
    coeff_b = 0.0881
    coeff_c = -0.0729
    coeff_d = 0.9437
    min_pct_pwr = 0.1
  when 'Single Zone VAV Fan'
    coeff_a = 0.027828
    coeff_b = 0.026583
    coeff_c = -0.087069
    coeff_d = 1.030920
    min_pct_pwr = 0.1
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.FanVariableVolume', "Fan control type '#{control_type}' not recognized, fan power coefficients will not be changed.")
    return false
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.FanVariableVolume', "For #{fan_variable_volume.name}: Set fan curve coefficients to reflect control type of '#{control_type}'.")

  # Set the coefficients
  fan_variable_volume.setFanPowerCoefficient1(coeff_a)
  fan_variable_volume.setFanPowerCoefficient2(coeff_b)
  fan_variable_volume.setFanPowerCoefficient3(coeff_c)
  fan_variable_volume.setFanPowerCoefficient4(coeff_d)

  # Set the fan minimum power
  fan_variable_volume.setFanPowerMinimumFlowRateInputMethod('Fraction')
  fan_variable_volume.setFanPowerMinimumFlowFraction(min_pct_pwr)

  # Append the control type to the fan name
  # self.setName("#{self.name} #{control_type}")
end

#fan_zone_exhaust_apply_prototype_fan_pressure_rise(fan_zone_exhaust) ⇒ Object

Sets the fan pressure rise based on the Prototype buildings inputs



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanZoneExhaust.rb', line 7

def fan_zone_exhaust_apply_prototype_fan_pressure_rise(fan_zone_exhaust)
  # Do not modify dummy exhaust fans
  return true if fan_zone_exhaust.name.to_s.downcase.include? 'dummy'

  # All exhaust fans are assumed to have a pressure rise of
  # 0.5 in w.c. in the prototype building models.
  pressure_rise_in_h2o = 0.5

  # Set the pressure rise
  pressure_rise_pa = OpenStudio.convert(pressure_rise_in_h2o, 'inH_{2}O', 'Pa').get
  fan_zone_exhaust.setPressureRise(pressure_rise_pa)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.FanZoneExhaust', "For Prototype: #{fan_zone_exhaust.name}: Pressure Rise = #{pressure_rise_in_h2o}in w.c.")

  return true
end

#film_coefficients_r_value(intended_surface_type, int_film, ext_film) ⇒ Double

Gives the total R-value of the interior and exterior (if applicable) film coefficients for a particular type of surface.

Parameters:

  • intended_surface_type (String)

    Valid choices: ‘AtticFloor’, ‘AtticWall’, ‘AtticRoof’, ‘DemisingFloor’, ‘InteriorFloor’, ‘InteriorCeiling’, ‘DemisingWall’, ‘InteriorWall’, ‘InteriorPartition’, ‘InteriorWindow’, ‘InteriorDoor’, ‘DemisingRoof’, ‘ExteriorRoof’, ‘Skylight’, ‘TubularDaylightDome’, ‘TubularDaylightDiffuser’, ‘ExteriorFloor’, ‘ExteriorWall’, ‘ExteriorWindow’, ‘ExteriorDoor’, ‘GlassDoor’, ‘OverheadDoor’, ‘GroundContactFloor’, ‘GroundContactWall’, ‘GroundContactRoof’

  • int_film (Bool)

    if true, interior film coefficient will be included in result

  • ext_film (Bool)

    if true, exterior film coefficient will be included in result

Returns:

  • (Double)

    Returns the R-Value of the film coefficients [m^2*K/W]



631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 631

def film_coefficients_r_value(intended_surface_type, int_film, ext_film)
  # Return zero if both interior and exterior are false
  return 0.0 if !int_film && !ext_film

  # Film values from 90.1-2010 A9.4.1 Air Films
  film_ext_surf_r_ip = 0.17
  film_semi_ext_surf_r_ip = 0.46
  film_int_surf_ht_flow_up_r_ip = 0.61
  film_int_surf_ht_flow_dwn_r_ip = 0.92
  fil_int_surf_vertical_r_ip = 0.68

  film_ext_surf_r_si = OpenStudio.convert(film_ext_surf_r_ip, 'ft^2*hr*R/Btu', 'm^2*K/W').get
  film_semi_ext_surf_r_si = OpenStudio.convert(film_semi_ext_surf_r_ip, 'ft^2*hr*R/Btu', 'm^2*K/W').get
  film_int_surf_ht_flow_up_r_si = OpenStudio.convert(film_int_surf_ht_flow_up_r_ip, 'ft^2*hr*R/Btu', 'm^2*K/W').get
  film_int_surf_ht_flow_dwn_r_si = OpenStudio.convert(film_int_surf_ht_flow_dwn_r_ip, 'ft^2*hr*R/Btu', 'm^2*K/W').get
  fil_int_surf_vertical_r_si = OpenStudio.convert(fil_int_surf_vertical_r_ip, 'ft^2*hr*R/Btu', 'm^2*K/W').get

  film_r_si = 0.0
  case intended_surface_type
  when 'AtticFloor'
    film_r_si += film_int_surf_ht_flow_up_r_si if ext_film # Outside
    film_r_si += film_semi_ext_surf_r_si if int_film # Inside
  when 'AtticWall', 'AtticRoof'
    film_r_si += film_ext_surf_r_si if ext_film # Outside
    film_r_si += film_semi_ext_surf_r_si if int_film # Inside
  when 'DemisingFloor', 'InteriorFloor'
    film_r_si += film_int_surf_ht_flow_up_r_si if ext_film # Outside
    film_r_si += film_int_surf_ht_flow_dwn_r_si if int_film # Inside
  when 'InteriorCeiling'
    film_r_si += film_int_surf_ht_flow_dwn_r_si if ext_film # Outside
    film_r_si += film_int_surf_ht_flow_up_r_si if int_film # Inside
  when 'DemisingWall', 'InteriorWall', 'InteriorPartition', 'InteriorWindow', 'InteriorDoor'
    film_r_si += fil_int_surf_vertical_r_si if ext_film # Outside
    film_r_si += fil_int_surf_vertical_r_si if int_film # Inside
  when 'DemisingRoof', 'ExteriorRoof', 'Skylight', 'TubularDaylightDome', 'TubularDaylightDiffuser'
    film_r_si += film_ext_surf_r_si if ext_film # Outside
    film_r_si += film_int_surf_ht_flow_up_r_si if int_film # Inside
  when 'ExteriorFloor'
    film_r_si += film_ext_surf_r_si if ext_film # Outside
    film_r_si += film_int_surf_ht_flow_dwn_r_si if int_film # Inside
  when 'ExteriorWall', 'ExteriorWindow', 'ExteriorDoor', 'GlassDoor', 'OverheadDoor'
    film_r_si += film_ext_surf_r_si if ext_film # Outside
    film_r_si += fil_int_surf_vertical_r_si if int_film # Inside
  when 'GroundContactFloor'
    film_r_si += film_int_surf_ht_flow_dwn_r_si if int_film # Inside
  when 'GroundContactWall'
    film_r_si += fil_int_surf_vertical_r_si if int_film # Inside
  when 'GroundContactRoof'
    film_r_si += film_int_surf_ht_flow_up_r_si if int_film # Inside
  end
  return film_r_si
end

#find_and_set_insulation_layer(construction) ⇒ Object



449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 449

def find_and_set_insulation_layer(construction)
  # skip if already has an insulation layer set.
  if construction.insulation.empty?
    # find insulation layer
    min_conductance = 100.0
    # loop through Layers
    construction.layers.each do |layer|
      # try casting the layer to an OpaqueMaterial.
      material = nil
      material = layer.to_OpaqueMaterial.get unless layer.to_OpaqueMaterial.empty?
      material = layer.to_FenestrationMaterial.get unless layer.to_FenestrationMaterial.empty?
      # check if the cast was successful, then find the insulation layer.
      unless material.nil?

        if BTAP::Resources::Envelope::Materials.get_conductance(material) < min_conductance
          # Keep track of the highest thermal resistance value.
          min_conductance = BTAP::Resources::Envelope::Materials.get_conductance(material)
          return_material = material
          unless material.to_OpaqueMaterial.empty?
            construction.setInsulation(material)
          end
        end
      end
    end
    if construction.insulation.empty? && construction.isOpaque
      raise
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Construction', "This construction has no insulation layer specified. Construction #{construction.name.get} insulation layer could not be set!. This occurs when a insulation layer is duplicated in the construction.")
    end
  else
    return construction.insulation.get
  end
end

#find_exposed_conditioned_roof_surfaces(model) ⇒ Object

This method is similar to the ‘find_exposed_conditioned_vertical_surfaces’ above only it is for roofs. Again, it distinguishes between plenum and non plenum roof area but collects and returns both.



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/openstudio-standards/standards/Standards.Surface.rb', line 195

def find_exposed_conditioned_roof_surfaces(model)
  exposed_surfaces = []
  plenum_surfaces = []
  exp_plenum_area = 0
  total_exp_area = 0
  exp_nonplenum_area = 0
  sub_surfaces_info = []
  sub_surface_area = 0
  # Sort through each space and determine if it conditioned.  Conditioned meaning it is either heated, cooled, or both.
  model.getSpaces.sort.each do |space|
    cooled = space_cooled?(space)
    heated = space_heated?(space)
    # If the space is conditioned sort through the surfaces looking for outdoor roofs.
    if heated || cooled
      space.surfaces.sort.each do |surface|
        # Assume a roof is of type 'RoofCeiling' and has an 'Outdoors' boundary condition.
        next unless surface.surfaceType == 'RoofCeiling'
        next unless surface.outsideBoundaryCondition == 'Outdoors'

        # Determine if the roof is adjacent to a plenum.
        sub_surface_info = []
        if space_plenum?(space)
          # If the roof is adjacent to a plenum add it to the plenum roof array and the plenum roof area counter
          # (accounting for space multipliers).
          plenum_surfaces << surface
          exp_plenum_area += surface.grossArea * space.multiplier
        else
          # If the roof is not adjacent to a plenum add it to the non-plenum roof array and the non-plenum roof area
          # counter (accounting for space multipliers).
          exposed_surfaces << surface
          exp_nonplenum_area += surface.grossArea * space.multiplier
          surface.subSurfaces.sort.each do |sub_surface|
            sub_surface_area += sub_surface.grossArea.to_f * space.multiplier
            sub_surface_info << {
              'subsurface_name' => sub_surface.nameString,
              'subsurface_type' => sub_surface.subSurfaceType,
              'gross_area_m2' => sub_surface.grossArea.to_f,
              'construction_name' => sub_surface.construction.get.nameString
            }
          end
          unless sub_surface_info.empty?
            sub_surfaces_info << {
              'surface_name' => surface.nameString,
              'subsurfaces' => sub_surface_info
            }
          end
        end
        # Regardless of if the roof is adjacent to a plenum or not add it to the total roof area counter (accounting
        # for space multipliers).
        total_exp_area += surface.grossArea * space.multiplier
      end
    end
  end
  srr = 999
  unless exp_nonplenum_area < 0.1
    srr = sub_surface_area / exp_nonplenum_area
  end
  # Put the information into a hash and return it to whomever called this method.
  exp_surf_info = {
    'total_exp_roof_area_m2' => total_exp_area,
    'exp_plenum_roof_area_m2' => exp_plenum_area,
    'exp_nonplenum_roof_area_m2' => exp_nonplenum_area,
    'exp_plenum_roofs' => plenum_surfaces,
    'exp_nonplenum_roofs' => exposed_surfaces,
    'srr' => srr,
    'sub_surfaces' => sub_surfaces_info
  }
  return exp_surf_info
end

#find_exposed_conditioned_vertical_surfaces(model, max_angle: 91, min_angle: 89) ⇒ Object

Chris Kirney 2018-09-12: This method searches through a model a returns vertical exterior surfaces which help enclose a conditioned space. It distinguishes between walls adjacent to plenums and wall adjacent to other conditioned spaces (as attics in OpenStudio are considered plenums and conditioned spaces though many would not agree). It returns a hash of the total exposed wall area adjacent to conditioned spaces (including plenums), the total exposed plenum wall area, the total exposed non-plenum area (adjacent to conditioned spaces), the exposed plenum walls and the exposed non-plenum walls (adjacent to conditioned spaces).



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/openstudio-standards/standards/Standards.Surface.rb', line 116

def find_exposed_conditioned_vertical_surfaces(model, max_angle: 91, min_angle: 89)
  exposed_surfaces = []
  plenum_surfaces = []
  exp_plenum_area = 0
  total_exp_area = 0
  exp_nonplenum_area = 0
  sub_surfaces_info = []
  sub_surface_area = 0
  # Sort through each space
  model.getSpaces.sort.each do |space|
    # Is the space heated or cooled?
    cooled = space_cooled?(space)
    heated = space_heated?(space)
    # Assume conditioned means the space is heated, cooled, or both.
    if heated || cooled
      # If the space is conditioned then go through each surface and determine if it a vertial exterior wall.
      space.surfaces.sort.each do |surface|
        # I define an exterior wall as one that is called a wall and that has a boundary contion of Outdoors.
        # Note that this will not include foundation walls.
        next unless surface.surfaceType == 'Wall'
        next unless surface.outsideBoundaryCondition == 'Outdoors'

        # Determine if the wall is vertical which I define as being between 89 and 91 degrees from horizontal.
        tilt_radian = surface.tilt
        tilt_degrees = OpenStudio.convert(tilt_radian, 'rad', 'deg').get
        sub_surface_info = []
        if tilt_degrees <= max_angle && tilt_degrees >= min_angle
          # If the wall is vertical determine if it is adjacent to a plenum.  If yes include it in the array of
          # plenum walls and add it to the plenum wall area counter (accounting for space multipliers).
          if space_plenum?(space)
            plenum_surfaces << surface
            exp_plenum_area += surface.grossArea * space.multiplier
          else
            # If not a plenum then include it in the array of non-plenum walls and add it to the non-plenum area
            # counter (accounting for space multipliers).
            exposed_surfaces << surface
            exp_nonplenum_area += surface.grossArea * space.multiplier
            surface.subSurfaces.sort.each do |sub_surface|
              sub_surface_area += sub_surface.grossArea.to_f * space.multiplier
              sub_surface_info << {
                'subsurface_name' => sub_surface.nameString,
                'subsurface_type' => sub_surface.subSurfaceType,
                'gross_area_m2' => sub_surface.grossArea.to_f,
                'construction_name' => sub_surface.construction.get.nameString
              }
            end
            unless sub_surface_info.empty?
              sub_surfaces_info << {
                'surface_name' => surface.nameString,
                'subsurfaces' => sub_surface_info
              }
            end
          end
          # Regardless of if the wall is adjacent to a plenum or not add it to the exposed wall area adjacent to
          # conditioned spaces (accounting for space multipliers).
          total_exp_area += surface.grossArea * space.multiplier
        end
      end
    end
  end
  fdwr = 999
  unless exp_nonplenum_area < 0.1
    fdwr = sub_surface_area / exp_nonplenum_area
  end
  # Add everything into a hash and return that hash to whomever called the method.
  exp_surf_info = {
    'total_exp_wall_area_m2' => total_exp_area,
    'exp_plenum_wall_area_m2' => exp_plenum_area,
    'exp_nonplenum_wall_area_m2' => exp_nonplenum_area,
    'exp_plenum_walls' => plenum_surfaces,
    'exp_nonplenum_walls' => exposed_surfaces,
    'fdwr' => fdwr,
    'sub_surfaces' => sub_surfaces_info
  }
  return exp_surf_info
end

#find_highest_roof_centre(model) ⇒ Object

This method finds the centroid of the highest roof(s). It cycles through each space and finds which surfaces are described as roofceiling whose outside boundary condition is outdoors. Of those surfaces that do it looks for the highest one(s) and finds the centroid of those. It returns the following hash: roof_cent =

top_spaces:  array of spaces which contain the highest roofs,
roof_centroid:  global x, y, and z coords of the centroid of the highest roof surfaces,
roof_area:  area of the highst roof surfaces

Each element of the top_spaces is a hash containing the following: top_space = {

space:  OpenStudio space containing the surface,
x:  global x coord of the centroid of roof surface(s),
y:  global y coord of the centroid of roof surface(s),
z:  global z coord of the centroid of roof surface(s),
area_m2:  area of the roof surface(s)}


280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/openstudio-standards/standards/Standards.Surface.rb', line 280

def find_highest_roof_centre(model)
  # Initialize some variables
  tol = 6
  max_height = -1000000000000000
  top_spaces = []
  spaces_info = []
  roof_centroid = [0, 0, 0]
  # Go through each space looking for outdoor roofs
  model.getSpaces.sort.each do |space|
    outdoor_roof = false
    space_max = -1000000000000000
    max_surf = nil
    space_surfaces = space.surfaces
    # Go through each surface in the space.  If it is an outdoor roofceiling then continue.  Otherwise go to the next
    # space.
    space_surfaces.each do |surface|
      outdoor_roof = true if surface.surfaceType.to_s.upcase == 'ROOFCEILING' && surface.outsideBoundaryCondition.to_s.upcase == 'OUTDOORS'
      # Is this surface the highest roof on this space?
      if surface.centroid.z.to_f.round(tol) > space_max
        space_max = surface.centroid.z.to_f.round(tol)
        max_surf = surface
      end
    end
    # If no outdoor roofceiling go to the next space.
    next if outdoor_roof == false

    z_Origin = space.zOrigin.to_f
    ceiling_centroid = [0, 0, 0]

    # Go through the surfaces and look for ones that are the highest.  Any that are the highest get added to the
    # centroid calculation.
    space_surfaces.each do |sp_surface|
      if max_surf.centroid.z.to_f.round(tol) == sp_surface.centroid.z.to_f.round(tol)
        ceiling_centroid[0] += sp_surface.centroid.x.to_f * sp_surface.grossArea.to_f
        ceiling_centroid[1] += sp_surface.centroid.y.to_f * sp_surface.grossArea.to_f
        ceiling_centroid[2] += sp_surface.grossArea.to_f
      end
    end

    # Calculate the centroid of the highest surface/surfaces for this space.
    ceiling_centroid[0] /= ceiling_centroid[2]
    ceiling_centroid[1] /= ceiling_centroid[2]

    # Put the info into an array containing hashes of spaces with outdoor roofceilings
    spaces_info << {
      space: space,
      x: ceiling_centroid[0] + space.xOrigin.to_f,
      y: ceiling_centroid[1] + space.yOrigin.to_f,
      z: max_surf.centroid.z.to_f + z_Origin,
      area_m2: ceiling_centroid[2]
    }
    # This is to determine which are the global highest outdoor roofceilings
    if max_height.round(tol) < (max_surf.centroid.z.to_f + z_Origin).round(tol)
      max_height = (max_surf.centroid.z.to_f + z_Origin).round(tol)
    end
  end
  # Go through the roofceilings and find the highest one(s) and calculate the centroid.
  spaces_info.each do |space_info|
    # If the outdoor roofceiling is one of the highest ones add it to an array of hashes and get the info needed to
    # calculate the centroid
    if space_info[:z].to_f.round(tol) == max_height.round(tol)
      top_spaces << space_info
      roof_centroid[0] += space_info[:x] * space_info[:area_m2]
      roof_centroid[1] += space_info[:y] * space_info[:area_m2]
      roof_centroid[2] += space_info[:area_m2]
    end
  end
  # calculate the centroid of the highest outdoor roofceiling(s) and add the info to a hash to return to whomever
  # called this method.
  roof_centroid[0] /= roof_centroid[2]
  roof_centroid[1] /= roof_centroid[2]
  roof_cent = {
    top_spaces: top_spaces,
    roof_centroid: [roof_centroid[0], roof_centroid[1], max_height],
    roof_area: roof_centroid[2]
  }
  return roof_cent
end

#fluid_cooler_apply_minimum_power_per_flow(fluid_cooler, equipment_type: 'Closed Cooling Tower') ⇒ Bool

Set the fluid cooler fan power such that the tower hits the minimum performance (gpm/hp) specified by the standard. Note that in this case hp is motor nameplate hp, per 90.1. This method assumes that the fan brake horsepower is 90% of the motor nameplate hp. This method determines the minimum motor efficiency for the nameplate motor hp and sets the actual fan power by multiplying the brake horsepower by the efficiency. Thus the fan power used as an input to the simulation divided by the design flow rate will not (and should not) exactly equal the minimum tower performance.

Parameters:

  • fluid_cooler (OpenStudio::Model::FluidCoolerSingleSpeed, OpenStudio::Model::FluidCoolerTwoSpeed, OpenStudio::Model::EvaporativeFluidCoolerSingleSpeed, OpenStudio::Model::EvaporativeFluidCoolerTwoSpeed)

    the fluid cooler

  • equipment_type (String) (defaults to: 'Closed Cooling Tower')

    heat rejection equipment type enumeration used for lookup query, options are ‘Closed Cooling Tower’, modeled as an EvaporativeFluidCooler, or ‘Dry Cooler’, modeled as a FluidCooler

Returns:

  • (Bool)

    true if successful, false if not



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/openstudio-standards/standards/Standards.FluidCooler.rb', line 25

def fluid_cooler_apply_minimum_power_per_flow(fluid_cooler, equipment_type: 'Closed Cooling Tower')
  # Get the design water flow rate
  if fluid_cooler.designWaterFlowRate.is_initialized
    design_water_flow_m3_per_s = fluid_cooler.designWaterFlowRate.get
  elsif fluid_cooler.autosizedDesignWaterFlowRate.is_initialized
    design_water_flow_m3_per_s = fluid_cooler.autosizedDesignWaterFlowRate.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.FluidCooler', "For #{fluid_cooler.name} design water flow rate is not available, cannot apply efficiency standard.")
    return false
  end
  design_water_flow_gpm = OpenStudio.convert(design_water_flow_m3_per_s, 'm^3/s', 'gal/min').get

  # Get the table of fluid cooler efficiencies
  heat_rejection = standards_data['heat_rejection']

  # Define the criteria to find the fluid cooler properties
  # in the hvac standards data set.
  search_criteria = {}
  search_criteria['template'] = template

  # Closed cooling towers are fluidcooler objects.
  search_criteria['equipment_type'] = equipment_type

  # TODO: Standards replace this with a mechanism to store this
  # data in the fluid cooler object itself.
  # For now, retrieve the fan type from the name
  name = fluid_cooler.name.get
  if name.include?('Centrifugal')
    fan_type = 'Centrifugal'
  elsif name.include?('Propeller or Axial')
    fan_type = 'Propeller or Axial'
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.FluidCooler', "Cannot find fan type for #{fluid_cooler.name}. Assuming propeller or axial.")
    fan_type = 'Propeller or Axial'
  end
  unless fan_type.nil?
    search_criteria['fan_type'] = fan_type
  end

  # Get the fluid cooler properties
  ct_props = model_find_object(heat_rejection, search_criteria)
  unless ct_props
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.FluidCooler', "For #{fluid_cooler.name}, cannot find heat rejection properties, cannot apply standard efficiencies or curves.")
    return false
  end

  # Get fluid cooler efficiency
  min_gpm_per_hp = ct_props['minimum_performance']
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.FluidCooler', "For #{fluid_cooler.name}, design water flow = #{design_water_flow_gpm.round} gpm, minimum performance = #{min_gpm_per_hp} gpm/hp (nameplate).")

  # Calculate the allowed fan brake horsepower
  # per method used in PNNL prototype buildings.
  # Assumes that the fan brake horsepower is 90%
  # of the fan nameplate rated motor power.
  fan_motor_nameplate_hp = design_water_flow_gpm / min_gpm_per_hp
  fan_bhp = 0.9 * fan_motor_nameplate_hp

  # Lookup the minimum motor efficiency
  motors = standards_data['motors']

  # Assuming all fan motors are 4-pole Enclosed
  search_criteria = {
    'template' => template,
    'number_of_poles' => 4.0,
    'type' => 'Enclosed'
  }

  motor_properties = model_find_object(motors, search_criteria, fan_motor_nameplate_hp)
  if motor_properties.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.FluidCooler', "For #{fluid_cooler.name}, could not find motor properties using search criteria: #{search_criteria}, motor_hp = #{motor_hp} hp.")
    return false
  end

  fan_motor_eff = motor_properties['nominal_full_load_efficiency']
  nominal_hp = motor_properties['maximum_capacity'].to_f.round(1)
  # Round to nearest whole HP for niceness
  if nominal_hp >= 2
    nominal_hp = nominal_hp.round
  end

  # Calculate the fan motor power
  fan_motor_actual_power_hp = fan_bhp / fan_motor_eff
  # Convert to W
  fan_motor_actual_power_w = fan_motor_actual_power_hp * 745.7 # 745.7 W/HP

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.FluidCooler', "For #{fluid_cooler.name}, allowed fan motor nameplate hp = #{fan_motor_nameplate_hp.round(1)} hp, fan brake horsepower = #{fan_bhp.round(1)}, and fan motor actual power = #{fan_motor_actual_power_hp.round(1)} hp (#{fan_motor_actual_power_w.round} W) at #{fan_motor_eff} motor efficiency.")

  # Append the efficiency to the name
  fluid_cooler.setName("#{fluid_cooler.name} #{min_gpm_per_hp.round(1)} gpm/hp")

  # Hard size the design fan power.
  # Leave the water flow and air flow autosized.
  if fluid_cooler.to_FluidCoolerSingleSpeed.is_initialized
    fluid_cooler.setDesignAirFlowRateFanPower(fan_motor_actual_power_w)
  elsif fluid_cooler.to_FluidCoolerTwoSpeed.is_initialized
    fluid_cooler.setHighFanSpeedFanPower(fan_motor_actual_power_w)
    fluid_cooler.setLowFanSpeedFanPower(0.3 * fan_motor_actual_power_w)
  elsif fluid_cooler.to_EvaporativeFluidCoolerSingleSpeed.is_initialized
    fluid_cooler.setFanPoweratDesignAirFlowRate(fan_motor_actual_power_w)
  elsif fluid_cooler.to_EvaporativeFluidCoolerTwoSpeed.is_initialized
    fluid_cooler.setHighFanSpeedFanPower(fan_motor_actual_power_w)
    fluid_cooler.setLowFanSpeedFanPower(0.3 * fan_motor_actual_power_w)
  end

  return true
end

#get_outdoor_subsurface_ratio(model, surface_type = 'Wall') ⇒ Object

This method return the building ratio of subsurface_area / surface_type_area where surface_type can be “Wall” or “RoofCeiling”



4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4542

def get_outdoor_subsurface_ratio(model, surface_type = 'Wall')
  surface_area = 0.0
  sub_surface_area = 0
  all_surfaces = []
  all_sub_surfaces = []
  model.getSpaces.sort.each do |space|
    zone = space.thermalZone
    zone_multiplier = nil
    next if zone.empty?

    zone_multiplier = zone.get.multiplier
    space.surfaces.sort.each do |surface|
      if (surface.outsideBoundaryCondition == 'Outdoors') && (surface.surfaceType == surface_type)
        surface_area += surface.grossArea * zone_multiplier
        surface.subSurfaces.sort.each do |sub_surface|
          sub_surface_area += sub_surface.grossArea * sub_surface.multiplier * zone_multiplier
        end
      end
    end
  end
  return fdwr = (sub_surface_area / surface_area)
end

#headered_pumps_variable_speed_set_control_type(headered_pumps_variable_speed, control_type) ⇒ Object

Set the pump curve coefficients based on the specified control type.

are Riding Curve, VSD No Reset, VSD DP Reset

Parameters:

  • control_type (String)

    valid choices



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/openstudio-standards/standards/Standards.HeaderedPumpsVariableSpeed.rb', line 11

def headered_pumps_variable_speed_set_control_type(headered_pumps_variable_speed, control_type)
  # Determine the coefficients
  coeff_a = nil
  coeff_b = nil
  coeff_c = nil
  coeff_d = nil
  case control_type
  when 'Constant Flow'
    coeff_a = 0.0
    coeff_b = 1.0
    coeff_c = 0.0
    coeff_d = 0.0
  when 'Riding Curve'
    coeff_a = 0.0
    coeff_b = 3.2485
    coeff_c = -4.7443
    coeff_d = 2.5294
  when 'VSD No Reset'
    coeff_a = 0.0
    coeff_b = 0.5726
    coeff_c = -0.301
    coeff_d = 0.7347
  when 'VSD DP Reset'
    coeff_a = 0.0
    coeff_b = 0.0205
    coeff_c = 0.4101
    coeff_d = 0.5753
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.HeaderedPumpsVariableSpeed', "Pump control type '#{control_type}' not recognized, pump coefficients will not be changed.")
    return false
  end

  # Set the coefficients
  headered_pumps_variable_speed.setCoefficient1ofthePartLoadPerformanceCurve(coeff_a)
  headered_pumps_variable_speed.setCoefficient2ofthePartLoadPerformanceCurve(coeff_b)
  headered_pumps_variable_speed.setCoefficient3ofthePartLoadPerformanceCurve(coeff_c)
  headered_pumps_variable_speed.setCoefficient4ofthePartLoadPerformanceCurve(coeff_d)
  headered_pumps_variable_speed.setPumpControlType('Intermittent')

  # Append the control type to the pump name
  # self.setName("#{self.name} #{control_type}")

  return true
end

#heat_exchanger_air_to_air_sensible_and_latent_apply_efficiency(heat_exchanger_air_to_air_sensible_and_latent) ⇒ Object

Sets the minimum effectiveness of the heat exchanger per the standard.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/openstudio-standards/standards/Standards.HeatExchangerSensLat.rb', line 6

def heat_exchanger_air_to_air_sensible_and_latent_apply_efficiency(heat_exchanger_air_to_air_sensible_and_latent)
  # Assumed to be sensible and latent at all flow
  min_effct = heat_exchanger_air_to_air_sensible_and_latent_minimum_efficiency(heat_exchanger_air_to_air_sensible_and_latent)

  heat_exchanger_air_to_air_sensible_and_latent.setSensibleEffectivenessat100HeatingAirFlow(min_effct)
  heat_exchanger_air_to_air_sensible_and_latent.setLatentEffectivenessat100HeatingAirFlow(min_effct)
  heat_exchanger_air_to_air_sensible_and_latent.setSensibleEffectivenessat75HeatingAirFlow(min_effct)
  heat_exchanger_air_to_air_sensible_and_latent.setLatentEffectivenessat75HeatingAirFlow(min_effct)
  heat_exchanger_air_to_air_sensible_and_latent.setSensibleEffectivenessat100CoolingAirFlow(min_effct)
  heat_exchanger_air_to_air_sensible_and_latent.setLatentEffectivenessat100CoolingAirFlow(min_effct)
  heat_exchanger_air_to_air_sensible_and_latent.setSensibleEffectivenessat75CoolingAirFlow(min_effct)
  heat_exchanger_air_to_air_sensible_and_latent.setLatentEffectivenessat75CoolingAirFlow(min_effct)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.HeatExchangerSensLat', "For #{heat_exchanger_air_to_air_sensible_and_latent.name}: Set sensible and latent effectiveness to #{(min_effct * 100).round}%.")

  return true
end

#heat_exchanger_air_to_air_sensible_and_latent_apply_prototype_efficiency(heat_exchanger_air_to_air_sensible_and_latent) ⇒ Object

Sets the minimum effectiveness of the heat exchanger per the DOE prototype assumptions, which assume that an enthalpy wheel is used, which exceeds the 50% effectiveness minimum actually defined by 90.1.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.HeatExchangerAirToAirSensibleAndLatent.rb', line 75

def heat_exchanger_air_to_air_sensible_and_latent_apply_prototype_efficiency(heat_exchanger_air_to_air_sensible_and_latent)
  heat_exchanger_air_to_air_sensible_and_latent.setSensibleEffectivenessat100HeatingAirFlow(0.7)
  heat_exchanger_air_to_air_sensible_and_latent.setLatentEffectivenessat100HeatingAirFlow(0.6)
  heat_exchanger_air_to_air_sensible_and_latent.setSensibleEffectivenessat75HeatingAirFlow(0.7)
  heat_exchanger_air_to_air_sensible_and_latent.setLatentEffectivenessat75HeatingAirFlow(0.6)
  heat_exchanger_air_to_air_sensible_and_latent.setSensibleEffectivenessat100CoolingAirFlow(0.75)
  heat_exchanger_air_to_air_sensible_and_latent.setLatentEffectivenessat100CoolingAirFlow(0.6)
  heat_exchanger_air_to_air_sensible_and_latent.setSensibleEffectivenessat75CoolingAirFlow(0.75)
  heat_exchanger_air_to_air_sensible_and_latent.setLatentEffectivenessat75CoolingAirFlow(0.6)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.HeatExchangerAirToAirSensibleAndLatent', "For #{heat_exchanger_air_to_air_sensible_and_latent.name}: Changed sensible and latent effectiveness to ~70% per DOE Prototype assumptions for an enthalpy wheel.")

  return true
end

#heat_exchanger_air_to_air_sensible_and_latent_apply_prototype_nominal_electric_power(heat_exchanger_air_to_air_sensible_and_latent) ⇒ Object

Sets the motor power to account for the extra fan energy from the increase in fan total static pressure



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.HeatExchangerAirToAirSensibleAndLatent.rb', line 11

def heat_exchanger_air_to_air_sensible_and_latent_apply_prototype_nominal_electric_power(heat_exchanger_air_to_air_sensible_and_latent)
  # Get the nominal supply air flow rate
  supply_air_flow_m3_per_s = nil
  if heat_exchanger_air_to_air_sensible_and_latent.nominalSupplyAirFlowRate.is_initialized
    supply_air_flow_m3_per_s = heat_exchanger_air_to_air_sensible_and_latent.nominalSupplyAirFlowRate.get
  elsif heat_exchanger_air_to_air_sensible_and_latent.autosizedNominalSupplyAirFlowRate.is_initialized
    supply_air_flow_m3_per_s = heat_exchanger_air_to_air_sensible_and_latent.autosizedNominalSupplyAirFlowRate.get
  else
    # Get the min OA flow rate from the OA
    # system if the ERV was not on the system during sizing.
    # This prevents us from having to perform a second sizing run.
    controller_oa = nil
    oa_system = nil
    # Get the air loop
    air_loop = heat_exchanger_air_to_air_sensible_and_latent.airLoopHVAC
    if air_loop.empty?
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.HeatExchangerAirToAirSensibleAndLatent', "For #{heat_exchanger_air_to_air_sensible_and_latent.name}, cannot get the air loop and therefore cannot get the min OA flow.")
      return false
    end
    air_loop = air_loop.get
    # Get the OA system
    if air_loop.airLoopHVACOutdoorAirSystem.is_initialized
      oa_system = air_loop.airLoopHVACOutdoorAirSystem.get
      controller_oa = oa_system.getControllerOutdoorAir
    else
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.HeatExchangerAirToAirSensibleAndLatent', "For #{heat_exchanger_air_to_air_sensible_and_latent.name}, cannot find the min OA flow because it has no OA intake.")
      return false
    end
    # Get the min OA flow rate from the OA
    if controller_oa.minimumOutdoorAirFlowRate.is_initialized
      supply_air_flow_m3_per_s = controller_oa.minimumOutdoorAirFlowRate.get
    elsif controller_oa.autosizedMinimumOutdoorAirFlowRate.is_initialized
      supply_air_flow_m3_per_s = controller_oa.autosizedMinimumOutdoorAirFlowRate.get
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.prototype.HeatExchangerAirToAirSensibleAndLatent', "For #{heat_exchanger_air_to_air_sensible_and_latent.name}, ERV minimum OA flow rate is not available, cannot apply prototype nominal power assumption.")
      return false
    end
  end

  # Convert the flow rate to cfm
  supply_air_flow_cfm = OpenStudio.convert(supply_air_flow_m3_per_s, 'm^3/s', 'cfm').get

  # Calculate the motor power for the rotary wheel per:
  # Power (W) = (Nominal Supply Air Flow Rate (CFM) * 0.3386) + 49.5
  # power = (supply_air_flow_cfm * 0.3386) + 49.5

  # Calculate the motor power for the rotary wheel per:
  # Power (W) = (Minimum Outdoor Air Flow Rate (m^3/s) * 212.5 / 0.5) + (Minimum Outdoor Air Flow Rate (m^3/s) * 162.5 / 0.5) + 50
  # This power is largely the added fan power from the extra static pressure drop from the enthalpy wheel.
  # It is included as motor power so it is only added when the enthalpy wheel is active, rather than a universal increase to the fan total static pressure.
  # From p.96 of https://www.pnnl.gov/main/publications/external/technical_reports/PNNL-20405.pdf
  default_fan_efficiency = heat_exchanger_air_to_air_sensible_and_latent_prototype_default_fan_efficiency
  power = (supply_air_flow_m3_per_s * 212.5 / default_fan_efficiency) + (supply_air_flow_m3_per_s * 0.9 * 162.5 / default_fan_efficiency) + 50
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.HeatExchangerAirToAirSensibleAndLatent', "For #{heat_exchanger_air_to_air_sensible_and_latent.name}, ERV power is calculated to be #{power.round} W, based on a min OA flow of #{supply_air_flow_cfm.round} cfm.  This power represents mostly the added fan energy from the extra static pressure, and is active only when the ERV is operating.")

  # Set the power for the HX
  heat_exchanger_air_to_air_sensible_and_latent.setNominalElectricPower(power)

  return true
end

#heat_exchanger_air_to_air_sensible_and_latent_minimum_efficiency(heat_exchanger_air_to_air_sensible_and_latent) ⇒ Object

Defines the minimum sensible and latent effectiveness of the heat exchanger. Assumed to apply to sensible and latent effectiveness at all flow rates.

Parameters:



29
30
31
32
# File 'lib/openstudio-standards/standards/Standards.HeatExchangerSensLat.rb', line 29

def heat_exchanger_air_to_air_sensible_and_latent_minimum_efficiency(heat_exchanger_air_to_air_sensible_and_latent)
  min_effct = 0.5
  return min_effct
end

#heat_exchanger_air_to_air_sensible_and_latent_prototype_default_fan_efficiencyObject

Default fan efficiency assumption for the prm added fan power



5
6
7
8
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.HeatExchangerAirToAirSensibleAndLatent.rb', line 5

def heat_exchanger_air_to_air_sensible_and_latent_prototype_default_fan_efficiency
  default_fan_efficiency = 0.5
  return default_fan_efficiency
end

#heating_design_outdoor_temperaturesArray<Double>

Gets the maximum OA dry bulb temperatures for all WinterDesignDays in the model.

Returns:

  • (Array<Double>)

    an array of OA temperatures in C



277
278
279
280
281
282
283
284
285
286
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 277

def heating_design_outdoor_temperatures
  heating_design_outdoor_temps = []
  getDesignDays.each do |dd|
    next unless dd.dayType == 'WinterDesignDay'

    heating_design_outdoor_temps << dd.maximumDryBulbTemperature
  end

  return heating_design_outdoor_temps
end

#hspf_to_cop_heating_no_fan(hspf) ⇒ Double

Convert from HSPF to COP (no fan) for heat pump heating coils

Parameters:

  • hspf (Double)

    heating seasonal performance factor (HSPF)

Returns:

  • (Double)

    Coefficient of Performance (COP)



285
286
287
288
289
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 285

def hspf_to_cop_heating_no_fan(hspf)
  cop = -0.0296 * hspf * hspf + 0.7134 * hspf

  return cop
end

#hspf_to_cop_heating_with_fan(hspf) ⇒ Double

Convert from HSPF to COP (with fan) for heat pump heating coils

Parameters:

  • hspf (Double)

    heating seasonal performance factor (HSPF)

Returns:

  • (Double)

    Coefficient of Performance (COP)



296
297
298
299
300
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 296

def hspf_to_cop_heating_with_fan(hspf)
  cop = -0.0255 * hspf * hspf + 0.6239 * hspf

  return cop
end

#intializeObject

set up template class variable.



44
45
46
# File 'lib/openstudio-standards/standards/standard.rb', line 44

def intialize
  super()
end

#kw_per_ton_to_cop(kw_per_ton) ⇒ Double

A helper method to convert from kW/ton to COP

Parameters:

  • kw_per_ton (Double)

    kW of input power per ton of cooling

Returns:

  • (Double)

    Coefficient of Performance (COP)



360
361
362
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 360

def kw_per_ton_to_cop(kw_per_ton)
  return 3.517 / kw_per_ton
end

#load_hvac_map(hvac_map_file) ⇒ Hash

Loads a JSON file containing the space type map into a hash

Parameters:

  • hvac_map_file (String)

    path to JSON file, relative to the /data folder

Returns:

  • (Hash)

    returns a hash that contains the space type map



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 199

def load_hvac_map(hvac_map_file)
  # Load the geometry .osm from relative to the data folder
  rel_path_to_hvac_map = "../../../../../data/#{hvac_map_file}"

  # Load the JSON depending on whether running from normal gem location
  # or from the embedded location in the OpenStudio CLI
  if File.dirname(__FILE__)[0] == ':'
    # running from embedded location in OpenStudio CLI
    hvac_map_string = load_resource_relative(rel_path_to_hvac_map)
    hvac_map = JSON.parse(hvac_map_string)
  else
    abs_path = File.join(File.dirname(__FILE__), rel_path_to_hvac_map)
    hvac_map = JSON.parse(File.read(abs_path)) if File.exist?(abs_path)
  end

  return hvac_map
end

#load_initial_osm(osm_file) ⇒ Bool

Loads a osm as a starting point.

Returns:

  • (Bool)

    returns true if successful, false if not



4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4568

def load_initial_osm(osm_file)
  # Load the geometry .osm
  unless File.exist?(osm_file)
    raise("The initial osm path: #{osm_file} does not exist.")
  end

  osm_model_path = OpenStudio::Path.new(osm_file.to_s)
  # Upgrade version if required.
  version_translator = OpenStudio::OSVersion::VersionTranslator.new
  model = version_translator.loadModel(osm_model_path).get
  validate_initial_model(model)
  return model
end

#load_standards_database(data_directories = []) ⇒ Hash

Loads the openstudio standards dataset for this standard. For standards subclassed from other standards, the lowest-level data will override data supplied at a higher level. For example, data from ASHRAE 90.1-2004 will be overriden by data from ComStock ASHRAE 90.1-2004.

Returns:

  • (Hash)

    a hash of standards data



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/openstudio-standards/standards/standard.rb', line 85

def load_standards_database(data_directories = [])
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.standard', "Loading OpenStudio Standards data for #{template}")
  @standards_data = {}

  # Load the JSON files from each directory
  data_directories.each do |data_dir|
    if __dir__[0] == ':' # Running from OpenStudio CLI
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.standard', "Loading JSON files from OpenStudio CLI embedded directory #{data_dir}")
      EmbeddedScripting.allFileNamesAsString.split(';').each do |file|
        # Skip files outside of the specified directory
        next unless file.start_with?("#{data_dir}/data")

        # Skip files that are not JSON
        next unless File.basename(file).match(/.*\.json/)

        # Read the JSON file
        data = JSON.parse(EmbeddedScripting.getFileAsString(file))
        data.each_pair do |key, objs|
          # Override the template in inherited files to match the instantiated template
          objs.each do |obj|
            if obj.key?('template')
              obj['template'] = template
            end
          end
          if @standards_data[key].nil?
            OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.standard', "Adding #{key} from #{File.basename(file)}")
          else
            OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.standard', "Overriding #{key} with #{File.basename(file)}")
          end
          @standards_data[key] = objs
        end
      end
    else
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.standard', "Loading JSON files from #{data_dir}")
      files = Dir.glob("#{data_dir}/data/*.json").select { |e| File.file? e }
      files.each do |file|
        data = JSON.parse(File.read(file))
        data.each_pair do |key, objs|
          # Override the template in inherited files to match the instantiated template
          objs.each do |obj|
            if obj.key?('template')
              obj['template'] = template
            end
          end
          if @standards_data[key].nil?
            OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.standard', "Adding #{key} from #{File.basename(file)}")
          else
            OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.standard', "Overriding #{key} with #{File.basename(file)}")
          end
          @standards_data[key] = objs
        end
      end
    end
  end

  # Check that standards data was loaded
  if @standards_data.keys.size.zero?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.standard', "OpenStudio Standards JSON data was not loaded correctly for #{template}.")
  end
  return @standards_data
end

#model_add_baseboard(model, thermal_zones, hot_water_loop: nil) ⇒ Array<OpenStudio::Model::ZoneHVACBaseboardConvectiveElectric, OpenStudio::Model::ZoneHVACBaseboardConvectiveWater>

Adds hydronic or electric baseboard heating to each zone.

Parameters:

Returns:



4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4205

def model_add_baseboard(model,
                        thermal_zones,
                        hot_water_loop: nil)

  # Make a baseboard heater for each zone
  baseboards = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding baseboard heat for #{zone.name}.")

    if hot_water_loop.nil?
      baseboard = OpenStudio::Model::ZoneHVACBaseboardConvectiveElectric.new(model)
      baseboard.setName("#{zone.name} Electric Baseboard")
      baseboard.addToThermalZone(zone)
      baseboards << baseboard
    else
      htg_coil = OpenStudio::Model::CoilHeatingWaterBaseboard.new(model)
      htg_coil.setName("#{zone.name} Hydronic Baseboard Coil")
      hot_water_loop.addDemandBranchForComponent(htg_coil)
      baseboard = OpenStudio::Model::ZoneHVACBaseboardConvectiveWater.new(model, model.alwaysOnDiscreteSchedule, htg_coil)
      baseboard.setName("#{zone.name} Hydronic Baseboard")
      baseboard.addToThermalZone(zone)
      baseboards << baseboard
    end
  end

  return baseboards
end

#model_add_booster_swh_end_uses(model, swh_booster_loop, peak_flowrate, flowrate_schedule, water_use_temperature) ⇒ OpenStudio::Model::WaterUseEquipment

Creates water fixtures and attaches them to the supplied booster water loop.

the booster water loop to add water fixtures to. the resulting water fixture.

Parameters:

  • swh_booster_loop (OpenStudio::Model::PlantLoop)
  • peak_flowrate (Double)

    in m^3/s

  • flowrate_schedule (String)

    name of the flow rate schedule

  • water_use_temperature (Double)

    mixed water use temperature, in C

Returns:

  • (OpenStudio::Model::WaterUseEquipment)


983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.ServiceWaterHeating.rb', line 983

def model_add_booster_swh_end_uses(model,
                                   swh_booster_loop,
                                   peak_flowrate,
                                   flowrate_schedule,
                                   water_use_temperature)

  # Water use connection
  swh_connection = OpenStudio::Model::WaterUseConnections.new(model)

  # Water fixture definition
  water_fixture_def = OpenStudio::Model::WaterUseEquipmentDefinition.new(model)
  rated_flow_rate_m3_per_s = peak_flowrate
  rated_flow_rate_gal_per_min = OpenStudio.convert(rated_flow_rate_m3_per_s, 'm^3/s', 'gal/min').get
  water_fixture_def.setName("Booster Water Fixture Def - #{rated_flow_rate_gal_per_min.round(2)} gpm")
  water_fixture_def.setPeakFlowRate(rated_flow_rate_m3_per_s)
  # Target mixed water temperature
  mixed_water_temp_f = OpenStudio.convert(water_use_temperature, 'C', 'F').get
  mixed_water_temp_sch = model_add_constant_schedule_ruleset(model,
                                                             OpenStudio.convert(mixed_water_temp_f, 'F', 'C').get,
                                                             name = "Mixed Water At Faucet Temp - #{mixed_water_temp_f.round}F")
  water_fixture_def.setTargetTemperatureSchedule(mixed_water_temp_sch)

  # Water use equipment
  water_fixture = OpenStudio::Model::WaterUseEquipment.new(water_fixture_def)
  water_fixture.setName("Booster Water Fixture - #{rated_flow_rate_gal_per_min.round(2)} gpm at #{mixed_water_temp_f.round}F")
  schedule = model_add_schedule(model, flowrate_schedule)
  water_fixture.setFlowRateFractionSchedule(schedule)
  swh_connection.addWaterUseEquipment(water_fixture)

  # Connect the water use connection to the SWH loop
  unless swh_booster_loop.nil?
    swh_booster_loop.addDemandBranchForComponent(swh_connection)
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding water fixture to #{swh_booster_loop.name}.")
  end

  return water_fixture
end

#model_add_cav(model, thermal_zones, system_name: nil, hot_water_loop: nil, chilled_water_loop: nil, hvac_op_sch: nil, oa_damper_sch: nil, fan_efficiency: 0.62, fan_motor_efficiency: 0.9, fan_pressure_rise: 4.0) ⇒ OpenStudio::Model::AirLoopHVAC

Creates a CAV system and adds it to the model.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • system_name (String) (defaults to: nil)

    the name of the system, or nil in which case it will be defaulted

  • hot_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    hot water loop to connect to heating and reheat coils.

  • chilled_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    chilled water loop to connect to the cooling coil.

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule or nil in which case will be defaulted to always on

  • oa_damper_sch (String) (defaults to: nil)

    name of the oa damper schedule or nil in which case will be defaulted to always open

  • fan_efficiency (Double) (defaults to: 0.62)

    fan total efficiency, including motor and impeller

  • fan_motor_efficiency (Double) (defaults to: 0.9)

    fan motor efficiency

  • fan_pressure_rise (Double) (defaults to: 4.0)

    fan pressure rise, inH2O

Returns:



2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 2264

def model_add_cav(model,
                  thermal_zones,
                  system_name: nil,
                  hot_water_loop: nil,
                  chilled_water_loop: nil,
                  hvac_op_sch: nil,
                  oa_damper_sch: nil,
                  fan_efficiency: 0.62,
                  fan_motor_efficiency: 0.9,
                  fan_pressure_rise: 4.0)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding CAV for #{thermal_zones.size} zones.")

  # create air handler
  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  if system_name.nil?
    air_loop.setName("#{thermal_zones.size} Zone CAV")
  else
    air_loop.setName(system_name)
  end

  # hvac operation schedule
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # oa damper schedule
  if oa_damper_sch.nil?
    oa_damper_sch = model.alwaysOnDiscreteSchedule
  else
    oa_damper_sch = model_add_schedule(model, oa_damper_sch)
  end

  # default design temperatures used across all air loops
  dsgn_temps = standard_design_sizing_temperatures
  unless hot_water_loop.nil?
    hw_temp_c = hot_water_loop.sizingPlant.designLoopExitTemperature
    hw_delta_t_k = hot_water_loop.sizingPlant.loopDesignTemperatureDifference
  end

  # adjusted design heating temperature for cav
  dsgn_temps['htg_dsgn_sup_air_temp_f'] = 62.0
  dsgn_temps['htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['htg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['zn_htg_dsgn_sup_air_temp_f'] = 122.0
  dsgn_temps['zn_htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_htg_dsgn_sup_air_temp_f'], 'F', 'C').get

  # default design settings used across all air loops
  sizing_system = adjust_sizing_system(air_loop, dsgn_temps, min_sys_airflow_ratio: 1.0)

  # air handler controls
  sa_temp_sch = model_add_constant_schedule_ruleset(model,
                                                    dsgn_temps['clg_dsgn_sup_air_temp_c'],
                                                    name = "Supply Air Temp - #{dsgn_temps['clg_dsgn_sup_air_temp_f']}F")
  sa_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, sa_temp_sch)
  sa_stpt_manager.setName("#{air_loop.name} Supply Air Setpoint Manager")
  sa_stpt_manager.addToNode(air_loop.supplyOutletNode)

  # create fan
  fan = create_fan_by_name(model,
                           'Packaged_RTU_SZ_AC_CAV_Fan',
                           fan_name: "#{air_loop.name} Fan",
                           fan_efficiency: fan_efficiency,
                           pressure_rise: fan_pressure_rise,
                           motor_efficiency: fan_motor_efficiency,
                           end_use_subcategory: 'CAV System Fans')
  fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  fan.addToNode(air_loop.supplyInletNode)

  # create heating coil
  create_coil_heating_water(model,
                            hot_water_loop,
                            air_loop_node: air_loop.supplyInletNode,
                            name: "#{air_loop.name} Main Htg Coil",
                            rated_inlet_water_temperature: hw_temp_c,
                            rated_outlet_water_temperature: (hw_temp_c - hw_delta_t_k),
                            rated_inlet_air_temperature: dsgn_temps['prehtg_dsgn_sup_air_temp_c'],
                            rated_outlet_air_temperature: dsgn_temps['htg_dsgn_sup_air_temp_c'])

  # create cooling coil
  if chilled_water_loop.nil?
    create_coil_cooling_dx_two_speed(model,
                                     air_loop_node: air_loop.supplyInletNode,
                                     name: "#{air_loop.name} 2spd DX Clg Coil",
                                     type: 'OS default')
  else
    create_coil_cooling_water(model,
                              chilled_water_loop,
                              air_loop_node: air_loop.supplyInletNode,
                              name: "#{air_loop.name} Clg Coil")
  end

  # create outdoor air intake system
  oa_intake_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
  oa_intake_controller.setName("#{air_loop.name} OA Controller")
  oa_intake_controller.setMinimumLimitType('FixedMinimum')
  oa_intake_controller.autosizeMinimumOutdoorAirFlowRate
  oa_intake_controller.setMinimumFractionofOutdoorAirSchedule(oa_damper_sch)
  oa_intake_controller.resetEconomizerMinimumLimitDryBulbTemperature
  controller_mv = oa_intake_controller.controllerMechanicalVentilation
  controller_mv.setName("#{air_loop.name} Vent Controller")
  controller_mv.setSystemOutdoorAirMethod('ZoneSum')
  oa_intake = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
  oa_intake.setName("#{air_loop.name} OA System")
  oa_intake.addToNode(air_loop.supplyInletNode)

  # set air loop availability controls and night cycle manager, after oa system added
  air_loop.setAvailabilitySchedule(hvac_op_sch)
  air_loop.setNightCycleControlType('CycleOnAny')

  # Connect the CAV system to each zone
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "Adding CAV for #{zone.name}")

    # Reheat coil
    rht_coil = create_coil_heating_water(model,
                                         hot_water_loop,
                                         name: "#{zone.name} Reheat Coil",
                                         rated_inlet_water_temperature: hw_temp_c,
                                         rated_outlet_water_temperature: (hw_temp_c - hw_delta_t_k),
                                         rated_inlet_air_temperature: dsgn_temps['htg_dsgn_sup_air_temp_c'],
                                         rated_outlet_air_temperature: dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    # VAV terminal
    terminal = OpenStudio::Model::AirTerminalSingleDuctVAVReheat.new(model, model.alwaysOnDiscreteSchedule, rht_coil)
    terminal.setName("#{zone.name} VAV Terminal")
    if model.version < OpenStudio::VersionString.new('3.0.1')
      terminal.setZoneMinimumAirFlowMethod('Constant')
    else
      terminal.setZoneMinimumAirFlowInputMethod('Constant')
    end
    terminal.setMaximumFlowPerZoneFloorAreaDuringReheat(0.0)
    terminal.setMaximumFlowFractionDuringReheat(0.5)
    terminal.setMaximumReheatAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    air_loop.multiAddBranchForZone(zone, terminal.to_HVACComponent.get)
    air_terminal_single_duct_vav_reheat_apply_initial_prototype_damper_position(terminal, thermal_zone_outdoor_airflow_rate_per_area(zone))

    # zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setCoolingDesignAirFlowMethod('DesignDayWithLimit')
    sizing_zone.setHeatingDesignAirFlowMethod('DesignDay')
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
  end

  # Set the damper action based on the template.
  air_loop_hvac_apply_vav_damper_action(air_loop)

  return true
end

#model_add_central_air_source_heat_pump(model, thermal_zones, heating: true, cooling: true, ventilation: false) ⇒ Array<OpenStudio::Model::AirLoopHVAC>

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to add fan coil units to.

  • heating (Bool) (defaults to: true)

    if true, the unit will include a NaturalGas heating coil

  • cooling (Bool) (defaults to: true)

    if true, the unit will include a DX cooling coil

  • ventilation (Bool) (defaults to: false)

    if true, the unit will include an OA intake

Returns:



4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4917

def model_add_central_air_source_heat_pump(model,
                                           thermal_zones,
                                           heating: true,
                                           cooling: true,
                                           ventilation: false)
  # defaults
  hspf = 7.7
  # seer = 13.0
  # eer = 11.4
  cop = 3.05
  shr = 0.73
  ac_w_per_cfm = 0.365
  min_hp_oat_f = 0.0
  crank_case_heat_w = 0.0
  crank_case_max_temp_f = 55

  # default design temperatures across all air loops
  dsgn_temps = standard_design_sizing_temperatures

  # adjusted temperatures for furnace_central_ac
  dsgn_temps['zn_htg_dsgn_sup_air_temp_f'] = 122.0
  dsgn_temps['zn_htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_htg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['htg_dsgn_sup_air_temp_f'] = dsgn_temps['zn_htg_dsgn_sup_air_temp_f']
  dsgn_temps['htg_dsgn_sup_air_temp_c'] = dsgn_temps['zn_htg_dsgn_sup_air_temp_c']

  hps = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding Central Air Source HP for #{zone.name}.")

    air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
    air_loop.setName("#{zone.name} Central Air Source HP")

    # default design settings used across all air loops
    sizing_system = adjust_sizing_system(air_loop, dsgn_temps, sizing_option: 'NonCoincident')
    sizing_system.setAllOutdoorAirinCooling(true)
    sizing_system.setAllOutdoorAirinHeating(true)

    # create heating coil
    htg_coil = nil
    supplemental_htg_coil = nil
    if heating
      htg_coil = create_coil_heating_dx_single_speed(model,
                                                     name: "#{air_loop.name} heating coil",
                                                     type: 'Residential Central Air Source HP',
                                                     cop: hspf_to_cop_heating_no_fan(hspf))
      htg_coil.setRatedSupplyFanPowerPerVolumeFlowRate(ac_w_per_cfm / OpenStudio.convert(1.0, 'cfm', 'm^3/s').get)
      htg_coil.setMinimumOutdoorDryBulbTemperatureforCompressorOperation(OpenStudio.convert(min_hp_oat_f, 'F', 'C').get)
      htg_coil.setMaximumOutdoorDryBulbTemperatureforDefrostOperation(OpenStudio.convert(40.0, 'F', 'C').get)
      htg_coil.setCrankcaseHeaterCapacity(crank_case_heat_w)
      htg_coil.setMaximumOutdoorDryBulbTemperatureforCrankcaseHeaterOperation(OpenStudio.convert(crank_case_max_temp_f, 'F', 'C').get)
      htg_coil.setDefrostStrategy('ReverseCycle')
      htg_coil.setDefrostControl('OnDemand')
      htg_coil.resetDefrostTimePeriodFraction

      # Supplemental Heating Coil

      # create supplemental heating coil
      supplemental_htg_coil = create_coil_heating_electric(model,
                                                           name: "#{air_loop.name} Supplemental Htg Coil")
    end

    # create cooling coil
    clg_coil = nil
    if cooling
      clg_coil = create_coil_cooling_dx_single_speed(model,
                                                     name: "#{air_loop.name} Cooling Coil",
                                                     type: 'Residential Central ASHP',
                                                     cop: cop)
      clg_coil.setRatedSensibleHeatRatio(shr)
      clg_coil.setRatedEvaporatorFanPowerPerVolumeFlowRate(OpenStudio::OptionalDouble.new(ac_w_per_cfm / OpenStudio.convert(1.0, 'cfm', 'm^3/s').get))
      clg_coil.setNominalTimeForCondensateRemovalToBegin(OpenStudio::OptionalDouble.new(1000.0))
      clg_coil.setRatioOfInitialMoistureEvaporationRateAndSteadyStateLatentCapacity(OpenStudio::OptionalDouble.new(1.5))
      clg_coil.setMaximumCyclingRate(OpenStudio::OptionalDouble.new(3.0))
      clg_coil.setLatentCapacityTimeConstant(OpenStudio::OptionalDouble.new(45.0))
      clg_coil.setCondenserType('AirCooled')
      clg_coil.setCrankcaseHeaterCapacity(OpenStudio::OptionalDouble.new(crank_case_heat_w))
      clg_coil.setMaximumOutdoorDryBulbTemperatureForCrankcaseHeaterOperation(OpenStudio::OptionalDouble.new(OpenStudio.convert(crank_case_max_temp_f, 'F', 'C').get))
    end

    # create fan
    fan = create_fan_by_name(model,
                             'Residential_HVAC_Fan',
                             fan_name: "#{air_loop.name} Supply Fan",
                             end_use_subcategory: 'Residential HVAC Fans')
    fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)

    # create outdoor air intake
    if ventilation
      oa_intake_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
      oa_intake_controller.setName("#{air_loop.name} OA Controller")
      oa_intake_controller.autosizeMinimumOutdoorAirFlowRate
      oa_intake_controller.resetEconomizerMinimumLimitDryBulbTemperature
      oa_intake = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
      oa_intake.setName("#{air_loop.name} OA System")
      oa_intake.addToNode(air_loop.supplyInletNode)
    end

    # create unitary system (holds the coils and fan)
    unitary = OpenStudio::Model::AirLoopHVACUnitarySystem.new(model)
    unitary.setName("#{air_loop.name} Unitary System")
    unitary.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
    unitary.setMaximumSupplyAirTemperature(OpenStudio.convert(170.0, 'F', 'C').get) # higher temp for supplemental heat as to not severely limit its use, resulting in unmet hours.
    unitary.setMaximumOutdoorDryBulbTemperatureforSupplementalHeaterOperation(OpenStudio.convert(40.0, 'F', 'C').get)
    unitary.setControllingZoneorThermostatLocation(zone)
    unitary.addToNode(air_loop.supplyInletNode)

    # set flow rates during different conditions
    unitary.setSupplyAirFlowRateWhenNoCoolingorHeatingisRequired(0.0) unless ventilation

    # attach the coils and fan
    unitary.setHeatingCoil(htg_coil) if htg_coil
    unitary.setCoolingCoil(clg_coil) if clg_coil
    unitary.setSupplementalHeatingCoil(supplemental_htg_coil) if supplemental_htg_coil
    unitary.setSupplyFan(fan)
    unitary.setFanPlacement('BlowThrough')
    unitary.setSupplyAirFanOperatingModeSchedule(model.alwaysOffDiscreteSchedule)

    # create a diffuser
    diffuser = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule)
    diffuser.setName(" #{zone.name} Direct Air")
    air_loop.multiAddBranchForZone(zone, diffuser.to_HVACComponent.get)

    hps << air_loop
  end

  return hps
end

#model_add_chw_loop(model, system_name: 'Chilled Water Loop', cooling_fuel: 'Electricity', dsgn_sup_wtr_temp: 44.0, dsgn_sup_wtr_temp_delt: 10.1, chw_pumping_type: nil, chiller_cooling_type: nil, chiller_condenser_type: nil, chiller_compressor_type: nil, num_chillers: 1, condenser_water_loop: nil, waterside_economizer: 'none') ⇒ OpenStudio::Model::PlantLoop

Creates a chilled water loop and adds it to the model.

Parameters:

  • system_name (String) (defaults to: 'Chilled Water Loop')

    the name of the system, or nil in which case it will be defaulted

  • cooling_fuel (String) (defaults to: 'Electricity')

    cooling fuel. Valid choices are: Electricity, DistrictCooling

  • dsgn_sup_wtr_temp (Double) (defaults to: 44.0)

    design supply water temperature in degrees Fahrenheit, default 44F

  • dsgn_sup_wtr_temp_delt (Double) (defaults to: 10.1)

    design supply-return water temperature difference in degrees Rankine, default 10R

  • chw_pumping_type (String) (defaults to: nil)

    valid choices are const_pri, const_pri_var_sec

  • chiller_cooling_type (String) (defaults to: nil)

    valid choices are AirCooled, WaterCooled

  • chiller_condenser_type (String) (defaults to: nil)

    valid choices are WithCondenser, WithoutCondenser, nil

  • chiller_compressor_type (String) (defaults to: nil)

    valid choices are Centrifugal, Reciprocating, Rotary Screw, Scroll, nil

  • num_chillers (Integer) (defaults to: 1)

    the number of chillers

  • condenser_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    optional condenser water loop for water-cooled chillers. If this is not passed in, the chillers will be air cooled.

  • waterside_economizer (String) (defaults to: 'none')

    Options are ‘none’, ‘integrated’, ‘non-integrated’. If ‘integrated’ will add a heat exchanger to the supply inlet of the chilled water loop

    to provide waterside economizing whenever wet bulb temperatures allow
    

    If ‘non-integrated’ will add a heat exchanger in parallel with the chiller that will operate

    only when it can meet cooling demand exclusively with the waterside economizing.
    

Returns:



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 206

def model_add_chw_loop(model,
                       system_name: 'Chilled Water Loop',
                       cooling_fuel: 'Electricity',
                       dsgn_sup_wtr_temp: 44.0,
                       dsgn_sup_wtr_temp_delt: 10.1,
                       chw_pumping_type: nil,
                       chiller_cooling_type: nil,
                       chiller_condenser_type: nil,
                       chiller_compressor_type: nil,
                       num_chillers: 1,
                       condenser_water_loop: nil,
                       waterside_economizer: 'none')
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding chilled water loop.')

  # create chilled water loop
  chilled_water_loop = OpenStudio::Model::PlantLoop.new(model)
  if system_name.nil?
    chilled_water_loop.setName('Chilled Water Loop')
  else
    chilled_water_loop.setName(system_name)
  end

  # chilled water loop sizing and controls
  if dsgn_sup_wtr_temp.nil?
    dsgn_sup_wtr_temp = 44.0
    dsgn_sup_wtr_temp_c = OpenStudio.convert(dsgn_sup_wtr_temp, 'F', 'C').get
  else
    dsgn_sup_wtr_temp_c = OpenStudio.convert(dsgn_sup_wtr_temp, 'F', 'C').get
  end
  if dsgn_sup_wtr_temp_delt.nil?
    dsgn_sup_wtr_temp_delt_k = OpenStudio.convert(10.1, 'R', 'K').get
  else
    dsgn_sup_wtr_temp_delt_k = OpenStudio.convert(dsgn_sup_wtr_temp_delt, 'R', 'K').get
  end
  chilled_water_loop.setMinimumLoopTemperature(1.0)
  chilled_water_loop.setMaximumLoopTemperature(40.0)
  sizing_plant = chilled_water_loop.sizingPlant
  sizing_plant.setLoopType('Cooling')
  sizing_plant.setDesignLoopExitTemperature(dsgn_sup_wtr_temp_c)
  sizing_plant.setLoopDesignTemperatureDifference(dsgn_sup_wtr_temp_delt_k)
  chw_temp_sch = model_add_constant_schedule_ruleset(model,
                                                     dsgn_sup_wtr_temp_c,
                                                     name = "#{chilled_water_loop.name} Temp - #{dsgn_sup_wtr_temp.round(0)}F")
  chw_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, chw_temp_sch)
  chw_stpt_manager.setName("#{chilled_water_loop.name} Setpoint Manager")
  chw_stpt_manager.addToNode(chilled_water_loop.supplyOutletNode)
  # TODO: Yixing check the CHW Setpoint from standards
  # TODO: Should be a OutdoorAirReset, see the changes I've made in Standards.PlantLoop.apply_prm_baseline_temperatures

  # create chilled water pumps
  if chw_pumping_type == 'const_pri'
    # primary chilled water pump
    pri_chw_pump = OpenStudio::Model::PumpVariableSpeed.new(model)
    pri_chw_pump.setName("#{chilled_water_loop.name} Pump")
    pri_chw_pump.setRatedPumpHead(OpenStudio.convert(60.0, 'ftH_{2}O', 'Pa').get)
    pri_chw_pump.setMotorEfficiency(0.9)
    # flat pump curve makes it behave as a constant speed pump
    pri_chw_pump.setFractionofMotorInefficienciestoFluidStream(0)
    pri_chw_pump.setCoefficient1ofthePartLoadPerformanceCurve(0)
    pri_chw_pump.setCoefficient2ofthePartLoadPerformanceCurve(1)
    pri_chw_pump.setCoefficient3ofthePartLoadPerformanceCurve(0)
    pri_chw_pump.setCoefficient4ofthePartLoadPerformanceCurve(0)
    pri_chw_pump.setPumpControlType('Intermittent')
    pri_chw_pump.addToNode(chilled_water_loop.supplyInletNode)
  elsif chw_pumping_type == 'const_pri_var_sec'
    # primary chilled water pump
    pri_chw_pump = OpenStudio::Model::PumpConstantSpeed.new(model)
    pri_chw_pump.setName("#{chilled_water_loop.name} Primary Pump")
    pri_chw_pump.setRatedPumpHead(OpenStudio.convert(15.0, 'ftH_{2}O', 'Pa').get)
    pri_chw_pump.setMotorEfficiency(0.9)
    pri_chw_pump.setPumpControlType('Intermittent')
    pri_chw_pump.addToNode(chilled_water_loop.supplyInletNode)
    # secondary chilled water pump
    sec_chw_pump = OpenStudio::Model::PumpVariableSpeed.new(model)
    sec_chw_pump.setName("#{chilled_water_loop.name} Secondary Pump")
    sec_chw_pump.setRatedPumpHead(OpenStudio.convert(45.0, 'ftH_{2}O', 'Pa').get)
    sec_chw_pump.setMotorEfficiency(0.9)
    # curve makes it perform like variable speed pump
    sec_chw_pump.setFractionofMotorInefficienciestoFluidStream(0)
    sec_chw_pump.setCoefficient1ofthePartLoadPerformanceCurve(0)
    sec_chw_pump.setCoefficient2ofthePartLoadPerformanceCurve(0.0205)
    sec_chw_pump.setCoefficient3ofthePartLoadPerformanceCurve(0.4101)
    sec_chw_pump.setCoefficient4ofthePartLoadPerformanceCurve(0.5753)
    sec_chw_pump.setPumpControlType('Intermittent')
    sec_chw_pump.addToNode(chilled_water_loop.demandInletNode)
    # Change the chilled water loop to have a two-way common pipes
    chilled_water_loop.setCommonPipeSimulation('CommonPipe')
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', 'No pumping type specified for the chilled water loop.')
  end

  # check for existence of condenser_water_loop if WaterCooled
  if chiller_cooling_type == 'WaterCooled'
    if condenser_water_loop.nil?
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', 'Requested chiller is WaterCooled but no condenser loop specified.')
    end
  end

  # check for non-existence of condenser_water_loop if AirCooled
  if chiller_cooling_type == 'AirCooled'
    unless condenser_water_loop.nil?
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', 'Requested chiller is AirCooled but condenser loop specified.')
    end
  end

  if cooling_fuel == 'DistrictCooling'
    # DistrictCooling
    dist_clg = OpenStudio::Model::DistrictCooling.new(model)
    dist_clg.setName('Purchased Cooling')
    dist_clg.autosizeNominalCapacity
    chilled_water_loop.addSupplyBranchForComponent(dist_clg)
  else
    # make the correct type of chiller based these properties
    chiller_sizing_factor = (1.0 / num_chillers).round(2)
    num_chillers.times do |i|
      chiller = OpenStudio::Model::ChillerElectricEIR.new(model)
      chiller.setName("#{template} #{chiller_cooling_type} #{chiller_condenser_type} #{chiller_compressor_type} Chiller #{i}")
      chilled_water_loop.addSupplyBranchForComponent(chiller)
      chiller.setReferenceLeavingChilledWaterTemperature(dsgn_sup_wtr_temp_c)
      chiller.setLeavingChilledWaterLowerTemperatureLimit(OpenStudio.convert(36.0, 'F', 'C').get)
      chiller.setReferenceEnteringCondenserFluidTemperature(OpenStudio.convert(95.0, 'F', 'C').get)
      chiller.setMinimumPartLoadRatio(0.15)
      chiller.setMaximumPartLoadRatio(1.0)
      chiller.setOptimumPartLoadRatio(1.0)
      chiller.setMinimumUnloadingRatio(0.25)
      chiller.setChillerFlowMode('ConstantFlow')
      chiller.setSizingFactor(chiller_sizing_factor)

      # connect the chiller to the condenser loop if one was supplied
      if condenser_water_loop.nil?
        chiller.setCondenserType('AirCooled')
      else
        condenser_water_loop.addDemandBranchForComponent(chiller)
        chiller.setCondenserType('WaterCooled')
      end
    end
  end

  # enable waterside economizer if requested
  unless condenser_water_loop.nil?
    case waterside_economizer
    when 'integrated'
      model_add_waterside_economizer(model, chilled_water_loop, condenser_water_loop,
                                     integrated: true)
    when 'non-integrated'
      model_add_waterside_economizer(model, chilled_water_loop, condenser_water_loop,
                                     integrated: false)
    end
  end

  # chilled water loop pipes
  chiller_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  chiller_bypass_pipe.setName("#{chilled_water_loop.name} Chiller Bypass")
  chilled_water_loop.addSupplyBranchForComponent(chiller_bypass_pipe)

  coil_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  coil_bypass_pipe.setName("#{chilled_water_loop.name} Coil Bypass")
  chilled_water_loop.addDemandBranchForComponent(coil_bypass_pipe)

  supply_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  supply_outlet_pipe.setName("#{chilled_water_loop.name} Supply Outlet")
  supply_outlet_pipe.addToNode(chilled_water_loop.supplyOutletNode)

  demand_inlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_inlet_pipe.setName("#{chilled_water_loop.name} Demand Inlet")
  demand_inlet_pipe.addToNode(chilled_water_loop.demandInletNode)

  demand_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_outlet_pipe.setName("#{chilled_water_loop.name} Demand Outlet")
  demand_outlet_pipe.addToNode(chilled_water_loop.demandOutletNode)

  return chilled_water_loop
end

#model_add_constant_schedule_ruleset(model, value, name = nil, sch_type_limit: 'Temperature') ⇒ Object

Create constant ScheduleRuleset

Parameters:

  • value (double)

    the value to use, 24-7, 365

  • name (string) (defaults to: nil)

    the name of the schedule

  • sch_type_limit (string) (defaults to: 'Temperature')

    the name of a schedule type limit options are Temperature, Humidity Ratio, Fractional, OnOff, and Activity

Returns:

  • schedule



1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1942

def model_add_constant_schedule_ruleset(model,
                                        value,
                                        name = nil,
                                        sch_type_limit: 'Temperature')
  # check to see if schedule exists with same name and constant value and return if true
  unless name.nil?
    existing_sch = model.getScheduleRulesetByName(name)
    if existing_sch.is_initialized
      existing_sch = existing_sch.get
      existing_day_sch_vals = existing_sch.defaultDaySchedule.values
      if existing_day_sch_vals.size == 1 && existing_day_sch_vals[0] == value
        return existing_sch
      end
    end
  end

  schedule = OpenStudio::Model::ScheduleRuleset.new(model)
  unless name.nil?
    schedule.setName(name)
    schedule.defaultDaySchedule.setName("#{name} Default")
  end

  if !sch_type_limit.nil?
    sch_type_limits_obj = model_add_schedule_type_limits(model, standard_sch_type_limit: sch_type_limit)
    schedule.setScheduleTypeLimits(sch_type_limits_obj)
  end

  schedule.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), value)
  return schedule
end

#model_add_construction(model, construction_name, construction_props = nil) ⇒ Object

TODO:

make return an OptionalConstruction

Create a construction from the openstudio standards dataset. If construction_props are specified, modifies the insulation layer accordingly.



2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2275

def model_add_construction(model, construction_name, construction_props = nil)
  # First check model and return construction if it already exists
  model.getConstructions.sort.each do |construction|
    if construction.name.get.to_s == construction_name
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "Already added construction: #{construction_name}")
      return construction
    end
  end

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "Adding construction: #{construction_name}")

  # Get the object data
  data = model_find_object(standards_data['constructions'], 'name' => construction_name)
  unless data
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Model', "Cannot find data for construction: #{construction_name}, will not be created.")
    return OpenStudio::Model::OptionalConstruction.new
  end

  # Make a new construction and set the standards details
  construction = OpenStudio::Model::Construction.new(model)
  construction.setName(construction_name)
  standards_info = construction.standardsInformation

  intended_surface_type = data['intended_surface_type']
  intended_surface_type ||= ''
  standards_info.setIntendedSurfaceType(intended_surface_type)

  standards_construction_type = data['standards_construction_type']
  standards_construction_type ||= ''
  standards_info.setStandardsConstructionType(standards_construction_type)

  # TODO: could put construction rendering color in the spreadsheet

  # Add the material layers to the construction
  layers = OpenStudio::Model::MaterialVector.new
  data['materials'].each do |material_name|
    material = model_add_material(model, material_name)
    if material
      layers << material
    end
  end
  construction.setLayers(layers)

  # Modify the R value of the insulation to hit the specified U-value, C-Factor, or F-Factor.
  # Doesn't currently operate on glazing constructions
  if construction_props
    # Determine the target U-value, C-factor, and F-factor
    target_u_value_ip = construction_props['assembly_maximum_u_value']
    target_f_factor_ip = construction_props['assembly_maximum_f_factor']
    target_c_factor_ip = construction_props['assembly_maximum_c_factor']
    target_shgc = construction_props['assembly_maximum_solar_heat_gain_coefficient']
    u_includes_int_film = construction_props['u_value_includes_interior_film_coefficient']
    u_includes_ext_film = construction_props['u_value_includes_exterior_film_coefficient']

    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "#{data['intended_surface_type']} u_val #{target_u_value_ip} f_fac #{target_f_factor_ip} c_fac #{target_c_factor_ip}")

    if target_u_value_ip

      # Handle Opaque and Fenestration Constructions differently
      if construction.isFenestration && construction_simple_glazing?(construction)
        # Set the U-Value and SHGC
        construction_set_glazing_u_value(construction, target_u_value_ip.to_f, data['intended_surface_type'], u_includes_int_film, u_includes_ext_film)
        construction_set_glazing_shgc(construction, target_shgc.to_f)
      else # if !data['intended_surface_type'] == 'ExteriorWindow' && !data['intended_surface_type'] == 'Skylight'
        # Set the U-Value
        construction_set_u_value(construction, target_u_value_ip.to_f, data['insulation_layer'], data['intended_surface_type'], u_includes_int_film, u_includes_ext_film)
        # else
        # OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Not modifying U-value for #{data['intended_surface_type']} u_val #{target_u_value_ip} f_fac #{target_f_factor_ip} c_fac #{target_c_factor_ip}")
      end

    elsif target_f_factor_ip && data['intended_surface_type'] == 'GroundContactFloor'

      # Set the F-Factor (only applies to slabs on grade)
      # TODO figure out what the prototype buildings did about ground heat transfer
      # construction_set_slab_f_factor(construction, target_f_factor_ip.to_f, data['insulation_layer'])
      construction_set_u_value(construction, 0.0, data['insulation_layer'], data['intended_surface_type'], u_includes_int_film, u_includes_ext_film)

    elsif target_c_factor_ip && data['intended_surface_type'] == 'GroundContactWall'

      # Set the C-Factor (only applies to underground walls)
      # TODO figure out what the prototype buildings did about ground heat transfer
      # construction_set_underground_wall_c_factor(construction, target_c_factor_ip.to_f, data['insulation_layer'])
      construction_set_u_value(construction, 0.0, data['insulation_layer'], data['intended_surface_type'], u_includes_int_film, u_includes_ext_film)

    end

    # If the construction is fenestration,
    # also set the frame type for use in future lookups
    if construction.isFenestration
      case standards_construction_type
      when 'Metal framing (all other)'
        standards_info.setFenestrationFrameType('Metal Framing')
      when 'Nonmetal framing (all)'
        standards_info.setFenestrationFrameType('Non-Metal Framing')
      end
    end

    # If the construction has a skylight framing material specified,
    # get the skylight frame material properties and add frame to
    # all skylights in the model.
    if data['skylight_framing']
      # Get the skylight framing material
      framing_name = data['skylight_framing']
      frame_data = model_find_object(standards_data['materials'], 'name' => framing_name)
      if frame_data
        frame_width_in = frame_data['frame_width'].to_f
        frame_with_m = OpenStudio.convert(frame_width_in, 'in', 'm').get
        frame_resistance_ip = frame_data['resistance'].to_f
        frame_resistance_si = OpenStudio.convert(frame_resistance_ip, 'hr*ft^2*R/Btu', 'm^2*K/W').get
        frame_conductance_si = 1.0 / frame_resistance_si
        frame = OpenStudio::Model::WindowPropertyFrameAndDivider.new(model)
        frame.setName("Skylight frame R-#{frame_resistance_ip.round(2)} #{frame_width_in.round(1)} in. wide")
        frame.setFrameWidth(frame_with_m)
        frame.setFrameConductance(frame_conductance_si)
        skylights_frame_added = 0
        model.getSubSurfaces.each do |sub_surface|
          next unless sub_surface.outsideBoundaryCondition == 'Outdoors' && sub_surface.subSurfaceType == 'Skylight'

          # TODO: enable proper window frame setting after https://github.com/NREL/OpenStudio/issues/2895 is fixed
          sub_surface.setString(8, frame.name.get.to_s)
          skylights_frame_added += 1
          # if sub_surface.allowWindowPropertyFrameAndDivider
          #   sub_surface.setWindowPropertyFrameAndDivider(frame)
          #   skylights_frame_added += 1
          # else
          #   OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Model', "For #{sub_surface.name}: cannot add a frame to this skylight.")
          # end
        end
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Adding #{frame.name} to #{skylights_frame_added} skylights.") if skylights_frame_added > 0
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Model', "Cannot find skylight framing data for: #{framing_name}, will not be created.")
        return false # TODO: change to return empty optional material
      end
    end

  end
  #     # Check if the construction with the modified name was already in the model.
  #     # If it was, delete this new construction and return the copy already in the model.
  #     m = construction.name.get.to_s.match(/\s(\d+)/)
  #     if m
  #       revised_cons_name = construction.name.get.to_s.gsub(/\s\d+/,'')
  #       model.getConstructions.sort.each do |exist_construction|
  #         if exist_construction.name.get.to_s == revised_cons_name
  #           OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "Already added construction: #{construction_name}")
  #           # Remove the recently added construction
  #           lyrs = construction.layers
  #           # Erase the layers in the construction
  #           construction.setLayers([])
  #           # Delete unused materials
  #           lyrs.uniq.each do |lyr|
  #             if lyr.directUseCount.zero?
  #               OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Model', "Removing Material: #{lyr.name}")
  #               lyr.remove
  #             end
  #           end
  #           construction.remove # Remove the construction
  #           return exist_construction
  #         end
  #       end
  #     end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Adding construction #{construction.name}.")

  return construction
end

#model_add_construction_set(model, clim, building_type, spc_type, is_residential) ⇒ Object

Create a construction set from the openstudio standards dataset. Returns an Optional DefaultConstructionSet



2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2483

def model_add_construction_set(model, clim, building_type, spc_type, is_residential)
  construction_set = OpenStudio::Model::OptionalDefaultConstructionSet.new

  # Find the climate zone set that this climate zone falls into
  climate_zone_set = model_find_climate_zone_set(model, clim)
  unless climate_zone_set
    return construction_set
  end

  # Get the object data
  data = model_find_object(standards_data['construction_sets'], 'template' => template, 'climate_zone_set' => climate_zone_set, 'building_type' => building_type, 'space_type' => spc_type, 'is_residential' => is_residential)
  unless data
    # Search again without the is_residential criteria in the case that this field is not specified for a standard
    data = model_find_object(standards_data['construction_sets'], 'template' => template, 'climate_zone_set' => climate_zone_set, 'building_type' => building_type, 'space_type' => spc_type)
    unless data
      # if nothing matches say that we could not find it
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Construction set for template =#{template}, climate zone set =#{climate_zone_set}, building type = #{building_type}, space type = #{spc_type}, is residential = #{is_residential} was not found in standards_data['construction_sets']")
      return construction_set
    end
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Adding construction set: #{template}-#{clim}-#{building_type}-#{spc_type}-is_residential#{is_residential}")

  name = model_make_name(model, clim, building_type, spc_type)

  # Create a new construction set and name it
  construction_set = OpenStudio::Model::DefaultConstructionSet.new(model)
  construction_set.setName(name)

  # Exterior surfaces constructions
  exterior_surfaces = OpenStudio::Model::DefaultSurfaceConstructions.new(model)
  construction_set.setDefaultExteriorSurfaceConstructions(exterior_surfaces)
  # Special condition for attics, where the insulation is actually on the floor but the soffit is uninsulated
  if spc_type == 'Attic'
    exterior_surfaces.setFloorConstruction(model_add_construction(model, 'Typical Attic Soffit'))
  else
    if data['exterior_floor_standards_construction_type'] && data['exterior_floor_building_category']
      exterior_surfaces.setFloorConstruction(model_find_and_add_construction(model,
                                                                             climate_zone_set,
                                                                             'ExteriorFloor',
                                                                             data['exterior_floor_standards_construction_type'],
                                                                             data['exterior_floor_building_category']))
    end
  end
  if data['exterior_wall_standards_construction_type'] && data['exterior_wall_building_category']
    exterior_surfaces.setWallConstruction(model_find_and_add_construction(model,
                                                                          climate_zone_set,
                                                                          'ExteriorWall',
                                                                          data['exterior_wall_standards_construction_type'],
                                                                          data['exterior_wall_building_category']))
  end
  # Special condition for attics, where the insulation is actually on the floor and the roof itself is uninsulated
  if spc_type == 'Attic'
    if data['exterior_roof_standards_construction_type'] && data['exterior_roof_building_category']
      exterior_surfaces.setRoofCeilingConstruction(model_add_construction(model, 'Typical Uninsulated Wood Joist Attic Roof'))
    end
  else
    if data['exterior_roof_standards_construction_type'] && data['exterior_roof_building_category']
      exterior_surfaces.setRoofCeilingConstruction(model_find_and_add_construction(model,
                                                                                   climate_zone_set,
                                                                                   'ExteriorRoof',
                                                                                   data['exterior_roof_standards_construction_type'],
                                                                                   data['exterior_roof_building_category']))
    end
  end
  # Interior surfaces constructions
  interior_surfaces = OpenStudio::Model::DefaultSurfaceConstructions.new(model)
  construction_set.setDefaultInteriorSurfaceConstructions(interior_surfaces)
  construction_name = data['interior_floors']
  # Special condition for attics, where the insulation is actually on the floor and the roof itself is uninsulated
  if spc_type == 'Attic'
    if data['exterior_roof_standards_construction_type'] && data['exterior_roof_building_category']
      interior_surfaces.setFloorConstruction(model_find_and_add_construction(model,
                                                                             climate_zone_set,
                                                                             'ExteriorRoof',
                                                                             data['exterior_roof_standards_construction_type'],
                                                                             data['exterior_roof_building_category']))

    end
  else
    unless construction_name.nil?
      interior_surfaces.setFloorConstruction(model_add_construction(model, construction_name))
    end
  end
  construction_name = data['interior_walls']
  unless construction_name.nil?
    interior_surfaces.setWallConstruction(model_add_construction(model, construction_name))
  end
  construction_name = data['interior_ceilings']
  unless construction_name.nil?
    interior_surfaces.setRoofCeilingConstruction(model_add_construction(model, construction_name))
  end

  # Ground contact surfaces constructions
  ground_surfaces = OpenStudio::Model::DefaultSurfaceConstructions.new(model)
  construction_set.setDefaultGroundContactSurfaceConstructions(ground_surfaces)
  if data['ground_contact_floor_standards_construction_type'] && data['ground_contact_floor_building_category']
    ground_surfaces.setFloorConstruction(model_find_and_add_construction(model,
                                                                         climate_zone_set,
                                                                         'GroundContactFloor',
                                                                         data['ground_contact_floor_standards_construction_type'],
                                                                         data['ground_contact_floor_building_category']))
  end
  if data['ground_contact_wall_standards_construction_type'] && data['ground_contact_wall_building_category']
    ground_surfaces.setWallConstruction(model_find_and_add_construction(model,
                                                                        climate_zone_set,
                                                                        'GroundContactWall',
                                                                        data['ground_contact_wall_standards_construction_type'],
                                                                        data['ground_contact_wall_building_category']))
  end
  if data['ground_contact_ceiling_standards_construction_type'] && data['ground_contact_ceiling_building_category']
    ground_surfaces.setRoofCeilingConstruction(model_find_and_add_construction(model,
                                                                               climate_zone_set,
                                                                               'GroundContactRoof',
                                                                               data['ground_contact_ceiling_standards_construction_type'],
                                                                               data['ground_contact_ceiling_building_category']))

  end

  # Exterior sub surfaces constructions
  exterior_subsurfaces = OpenStudio::Model::DefaultSubSurfaceConstructions.new(model)
  construction_set.setDefaultExteriorSubSurfaceConstructions(exterior_subsurfaces)
  if data['exterior_fixed_window_standards_construction_type'] && data['exterior_fixed_window_building_category']
    exterior_subsurfaces.setFixedWindowConstruction(model_find_and_add_construction(model,
                                                                                    climate_zone_set,
                                                                                    'ExteriorWindow',
                                                                                    data['exterior_fixed_window_standards_construction_type'],
                                                                                    data['exterior_fixed_window_building_category']))
  end
  if data['exterior_operable_window_standards_construction_type'] && data['exterior_operable_window_building_category']
    exterior_subsurfaces.setOperableWindowConstruction(model_find_and_add_construction(model,
                                                                                       climate_zone_set,
                                                                                       'ExteriorWindow',
                                                                                       data['exterior_operable_window_standards_construction_type'],
                                                                                       data['exterior_operable_window_building_category']))
  end
  if data['exterior_door_standards_construction_type'] && data['exterior_door_building_category']
    exterior_subsurfaces.setDoorConstruction(model_find_and_add_construction(model,
                                                                             climate_zone_set,
                                                                             'ExteriorDoor',
                                                                             data['exterior_door_standards_construction_type'],
                                                                             data['exterior_door_building_category']))
  end
  if data['exterior_glass_door_standards_construction_type'] && data['exterior_glass_door_building_category']
    exterior_subsurfaces.setGlassDoorConstruction(model_find_and_add_construction(model,
                                                                                  climate_zone_set,
                                                                                  'GlassDoor',
                                                                                  data['exterior_glass_door_standards_construction_type'],
                                                                                  data['exterior_glass_door_building_category']))
  end
  if data['exterior_overhead_door_standards_construction_type'] && data['exterior_overhead_door_building_category']
    exterior_subsurfaces.setOverheadDoorConstruction(model_find_and_add_construction(model,
                                                                                     climate_zone_set,
                                                                                     'ExteriorDoor',
                                                                                     data['exterior_overhead_door_standards_construction_type'],
                                                                                     data['exterior_overhead_door_building_category']))
  end
  if data['exterior_skylight_standards_construction_type'] && data['exterior_skylight_building_category']
    exterior_subsurfaces.setSkylightConstruction(model_find_and_add_construction(model,
                                                                                 climate_zone_set,
                                                                                 'Skylight',
                                                                                 data['exterior_skylight_standards_construction_type'],
                                                                                 data['exterior_skylight_building_category']))
  end
  if (construction_name = data['tubular_daylight_domes'])
    exterior_subsurfaces.setTubularDaylightDomeConstruction(model_add_construction(model, construction_name))
  end
  if (construction_name = data['tubular_daylight_diffusers'])
    exterior_subsurfaces.setTubularDaylightDiffuserConstruction(model_add_construction(model, construction_name))
  end

  # Interior sub surfaces constructions
  interior_subsurfaces = OpenStudio::Model::DefaultSubSurfaceConstructions.new(model)
  construction_set.setDefaultInteriorSubSurfaceConstructions(interior_subsurfaces)
  if (construction_name = data['interior_fixed_windows'])
    interior_subsurfaces.setFixedWindowConstruction(model_add_construction(model, construction_name))
  end
  if (construction_name = data['interior_operable_windows'])
    interior_subsurfaces.setOperableWindowConstruction(model_add_construction(model, construction_name))
  end
  if (construction_name = data['interior_doors'])
    interior_subsurfaces.setDoorConstruction(model_add_construction(model, construction_name))
  end

  # Other constructions
  if (construction_name = data['interior_partitions'])
    construction_set.setInteriorPartitionConstruction(model_add_construction(model, construction_name))
  end
  if (construction_name = data['space_shading'])
    construction_set.setSpaceShadingConstruction(model_add_construction(model, construction_name))
  end
  if (construction_name = data['building_shading'])
    construction_set.setBuildingShadingConstruction(model_add_construction(model, construction_name))
  end
  if (construction_name = data['site_shading'])
    construction_set.setSiteShadingConstruction(model_add_construction(model, construction_name))
  end

  # componentize the construction set
  # construction_set_component = construction_set.createComponent

  # Return the construction set
  return OpenStudio::Model::OptionalDefaultConstructionSet.new(construction_set)
end

#model_add_crac(model, thermal_zones, climate_zone, system_name: nil, hvac_op_sch: nil, oa_damper_sch: nil, fan_location: 'DrawThrough', fan_type: 'ConstantVolume', cooling_type: 'Single Speed DX AC', supply_temp_sch: nil) ⇒ Array<OpenStudio::Model::AirLoopHVAC>

Creates a CRAC system for data center and adds it to the model.

or nil in which case will be defaulted to always on or nil in which case will be defaulted to always open no heating

Parameters:

  • system_name (String) (defaults to: nil)

    the name of the system, or nil in which case it will be defaulted

  • thermal_zones (String)

    zones to connect to this system

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule

  • oa_damper_sch (Double) (defaults to: nil)

    name of the oa damper schedule,

  • fan_location (Double) (defaults to: 'DrawThrough')

    valid choices are BlowThrough, DrawThrough

  • fan_type (Double) (defaults to: 'ConstantVolume')

    valid choices are ConstantVolume, Cycling, VariableVolume

  • cooling_type (String) (defaults to: 'Single Speed DX AC')

    valid choices are Two Speed DX AC, Single Speed DX AC

Returns:



3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 3037

def model_add_crac(model,
                   thermal_zones,
                   climate_zone,
                   system_name: nil,
                   hvac_op_sch: nil,
                   oa_damper_sch: nil,
                   fan_location: 'DrawThrough',
                   fan_type: 'ConstantVolume',
                   cooling_type: 'Single Speed DX AC',
                   supply_temp_sch: nil)

  # hvac operation schedule
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # oa damper schedule
  if oa_damper_sch.nil?
    oa_damper_sch = model.alwaysOnDiscreteSchedule
  else
    oa_damper_sch = model_add_schedule(model, oa_damper_sch)
  end

  # Make a CRAC for each data center zone
  air_loops = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding CRAC for #{zone.name}.")

    air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
    if system_name.nil?
      air_loop.setName("#{zone.name} CRAC")
    else
      air_loop.setName("#{zone.name} #{system_name}")
    end

    # default design temperatures across all air loops
    dsgn_temps = standard_design_sizing_temperatures

    # adjusted zone design heating temperature for data center psz_ac
    dsgn_temps['prehtg_dsgn_sup_air_temp_f'] = 64.4
    dsgn_temps['preclg_dsgn_sup_air_temp_f'] = 80.6
    dsgn_temps['htg_dsgn_sup_air_temp_f'] = 55
    dsgn_temps['clg_dsgn_sup_air_temp_f'] = 55
    dsgn_temps['zn_htg_dsgn_sup_air_temp_f'] = dsgn_temps['htg_dsgn_sup_air_temp_f']
    dsgn_temps['zn_clg_dsgn_sup_air_temp_f'] = dsgn_temps['clg_dsgn_sup_air_temp_f']
    dsgn_temps['prehtg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['prehtg_dsgn_sup_air_temp_f'], 'F', 'C').get
    dsgn_temps['preclg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['preclg_dsgn_sup_air_temp_f'], 'F', 'C').get
    dsgn_temps['htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['htg_dsgn_sup_air_temp_f'], 'F', 'C').get
    dsgn_temps['clg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['clg_dsgn_sup_air_temp_f'], 'F', 'C').get
    dsgn_temps['zn_htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_htg_dsgn_sup_air_temp_f'], 'F', 'C').get
    dsgn_temps['zn_clg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_clg_dsgn_sup_air_temp_f'], 'F', 'C').get

    # default design settings used across all air loops
    sizing_system = adjust_sizing_system(air_loop, dsgn_temps, min_sys_airflow_ratio: 0.05)

    # Zone sizing
    sizing_zone = zone.sizingZone
    # per ASHRAE 90.4, recommended range of data center supply air temperature is 18-27C, pick the mean value 22.5C as prototype
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])

    # create fan
    # ConstantVolume: Packaged Rooftop Single Zone Air conditioner
    # Cycling: Unitary System
    # CyclingHeatPump: Unitary Heat Pump system
    if fan_type == 'VariableVolume'
      fan = create_fan_by_name(model,
                               'CRAC_VAV_fan',
                               fan_name: "#{air_loop.name} Fan")
      fan.setAvailabilitySchedule(hvac_op_sch)
    elsif fan_type == 'ConstantVolume'
      fan = create_fan_by_name(model,
                               'CRAC_CAV_fan',
                               fan_name: "#{air_loop.name} Fan")
      fan.setAvailabilitySchedule(hvac_op_sch)
    elsif fan_type == 'Cycling'
      fan = create_fan_by_name(model,
                               'CRAC_Cycling_fan',
                               fan_name: "#{air_loop.name} Fan")
      fan.setAvailabilitySchedule(hvac_op_sch)
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Fan type '#{fan_type}' not recognized, cannot add CRAC.")
      return []
    end

    # create cooling coil
    case cooling_type
    when 'Two Speed DX AC'
      clg_coil = create_coil_cooling_dx_two_speed(model,
                                                  name: "#{air_loop.name} 2spd DX AC Clg Coil")
    when 'Single Speed DX AC'
      clg_coil = create_coil_cooling_dx_single_speed(model,
                                                     name: "#{air_loop.name} 1spd DX AC Clg Coil",
                                                     type: 'PSZ-AC')
    else
      clg_coil = nil
    end

    oa_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
    oa_controller.setName("#{air_loop.name} OA System Controller")
    oa_controller.setMinimumOutdoorAirSchedule(oa_damper_sch)
    oa_system = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_controller)
    oa_system.setName("#{air_loop.name} OA System")

    # CRAC can't operate properly at very low ambient temperature (E+ limit: -25C)
    # As a result, the room temperature will rise to HUGE
    # Adding economizer can solve the issue, but economizer is not added until first sizing done, which causes severe error during sizing
    # To solve the issue, add economizer here for cold climates
    # select the climate zones with winter design temperature lower than -20C (for safer)
    cold_climates = ['ASHRAE 169-2006-6A', 'ASHRAE 169-2006-6B', 'ASHRAE 169-2006-7A',
                     'ASHRAE 169-2006-7B', 'ASHRAE 169-2006-8A', 'ASHRAE 169-2006-8B']
    if cold_climates.include? climate_zone
      # Determine the economizer type in the prototype buildings, which depends on climate zone.
      economizer_type = model_economizer_type(model, climate_zone)
      oa_controller.setEconomizerControlType(economizer_type)

      # Check that the economizer type set by the prototypes
      # is not prohibited by code.  If it is, change to no economizer.
      unless air_loop_hvac_economizer_type_allowable?(air_loop, climate_zone)
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.prototype.Model', "#{air_loop.name} is required to have an economizer, but the type chosen, #{economizer_type} is prohibited by code for , climate zone #{climate_zone}.  Economizer type will be switched to No Economizer.")
        oa_controller.setEconomizerControlType('NoEconomizer')
      end
    end

    # add humidifier to control minimum RH
    humidifier = OpenStudio::Model::HumidifierSteamElectric.new(model)
    humidifier.autosizeRatedCapacity
    humidifier.autosizeRatedPower
    humidifier.setName("#{air_loop.name} Electric Steam Humidifier")

    # Add the components to the air loop
    # in order from closest to zone to furthest from zone
    supply_inlet_node = air_loop.supplyInletNode

    if fan_location == 'DrawThrough'
      # Add the fan
      fan.addToNode(supply_inlet_node) unless fan.nil?
      # Add the humidifier
      humidifier.addToNode(supply_inlet_node) unless humidifier.nil?
      # Add the cooling coil
      clg_coil.addToNode(supply_inlet_node) unless clg_coil.nil?

    elsif fan_location == 'BlowThrough'
      # Add the humidifier
      humidifier.addToNode(supply_inlet_node) unless humidifier.nil?
      # Add the cooling coil
      clg_coil.addToNode(supply_inlet_node) unless clg_coil.nil?
      # Add the fan
      fan.addToNode(supply_inlet_node) unless fan.nil?

    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'Invalid fan location')
      return false
    end

    # add humidifying setpoint
    humidity_spm = OpenStudio::Model::SetpointManagerSingleZoneHumidityMinimum.new(model)
    humidity_spm.setControlZone(zone)
    humidity_spm.addToNode(humidifier.outletModelObject.get.to_Node.get)

    humidistat = OpenStudio::Model::ZoneControlHumidistat.new(model)
    humidistat.setHumidifyingRelativeHumiditySetpointSchedule(model_add_schedule(model, 'DataCenter Humidity Setpoint Schedule'))
    zone.setZoneControlHumidistat(humidistat)

    # Add a setpoint manager for cooling to control the supply air temperature based on the needs of this zone
    if supply_temp_sch.nil?
      supply_temp_sch = model_add_constant_schedule_ruleset(model,
                                                            dsgn_temps['clg_dsgn_sup_air_temp_c'],
                                                            name = 'AHU Supply Temp Sch')
    end
    setpoint_mgr_cooling = OpenStudio::Model::SetpointManagerScheduled.new(model, supply_temp_sch)
    setpoint_mgr_cooling.setName('CRAC supply air setpoint manager')
    setpoint_mgr_cooling.addToNode(air_loop.supplyOutletNode)

    # Add the OA system
    oa_system.addToNode(supply_inlet_node)

    # set air loop availability controls
    air_loop.setAvailabilitySchedule(hvac_op_sch)

    # Create a diffuser and attach the zone/diffuser pair to the air loop
    diffuser = OpenStudio::Model::AirTerminalSingleDuctVAVNoReheat.new(model, model.alwaysOnDiscreteSchedule)
    diffuser.setName("#{air_loop.name} Diffuser")
    if model.version < OpenStudio::VersionString.new('3.0.1')
      diffuser.setZoneMinimumAirFlowMethod('Constant')
    else
      diffuser.setZoneMinimumAirFlowInputMethod('Constant')
    end
    diffuser.setConstantMinimumAirFlowFraction(0.1)
    air_loop.multiAddBranchForZone(zone, diffuser.to_HVACComponent.get)

    air_loops << air_loop
  end

  return air_loops
end

#model_add_crah(model, thermal_zones, system_name: nil, chilled_water_loop: nil, hvac_op_sch: nil, oa_damper_sch: nil, return_plenum: nil, supply_temp_sch: nil) ⇒ Array<OpenStudio::Model::AirLoopHVAC>

Creates a CRAH system for larger size data center and adds it to the model.

or nil in which case will be defaulted to always on or nil in which case will be defaulted to always open no heating

Parameters:

  • chilled_water_loop (string) (defaults to: nil)
  • system_name (String) (defaults to: nil)

    the name of the system, or nil in which case it will be defaulted

  • thermal_zones (String)

    zones to connect to this system

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule

  • oa_damper_sch (Double) (defaults to: nil)

    name of the oa damper schedule,

Returns:



3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 3247

def model_add_crah(model,
                   thermal_zones,
                   system_name: nil,
                   chilled_water_loop: nil,
                   hvac_op_sch: nil,
                   oa_damper_sch: nil,
                   return_plenum: nil,
                   supply_temp_sch: nil)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding CRAH system for #{thermal_zones.size} zones data center.")
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "---#{zone.name}")
  end

  # hvac operation schedule
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # oa damper schedule
  if oa_damper_sch.nil?
    oa_damper_sch = model.alwaysOnDiscreteSchedule
  else
    oa_damper_sch = model_add_schedule(model, oa_damper_sch)
  end

  # air handler
  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  if system_name.nil?
    air_loop.setName('Data Center CRAH')
  else
    air_loop.setName(system_name)
  end

  # default design temperatures across all air loops
  dsgn_temps = standard_design_sizing_temperatures

  # adjusted zone design heating temperature for data center psz_ac
  dsgn_temps['prehtg_dsgn_sup_air_temp_f'] = 64.4
  dsgn_temps['preclg_dsgn_sup_air_temp_f'] = 80.6
  dsgn_temps['htg_dsgn_sup_air_temp_f'] = 55
  dsgn_temps['clg_dsgn_sup_air_temp_f'] = 55
  dsgn_temps['zn_htg_dsgn_sup_air_temp_f'] = dsgn_temps['htg_dsgn_sup_air_temp_f']
  dsgn_temps['zn_clg_dsgn_sup_air_temp_f'] = dsgn_temps['clg_dsgn_sup_air_temp_f']
  dsgn_temps['prehtg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['prehtg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['preclg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['preclg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['htg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['clg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['clg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['zn_htg_dsgn_sup_air_temp_c'] = dsgn_temps['htg_dsgn_sup_air_temp_c']
  dsgn_temps['zn_clg_dsgn_sup_air_temp_c'] = dsgn_temps['clg_dsgn_sup_air_temp_c']

  # default design settings used across all air loops
  sizing_system = adjust_sizing_system(air_loop, dsgn_temps, min_sys_airflow_ratio: 0.3)

  # Add a setpoint manager for cooling to control the supply air temperature based on the needs of this zone
  if supply_temp_sch.nil?
    supply_temp_sch = model_add_constant_schedule_ruleset(model,
                                                          dsgn_temps['clg_dsgn_sup_air_temp_c'],
                                                          name = 'AHU Supply Temp Sch')
  end
  setpoint_mgr_cooling = OpenStudio::Model::SetpointManagerScheduled.new(model, supply_temp_sch)
  setpoint_mgr_cooling.setName('CRAH supply air setpoint manager')
  setpoint_mgr_cooling.addToNode(air_loop.supplyOutletNode)

  # create fan
  fan = create_fan_by_name(model,
                           'VAV_System_Fan',
                           fan_name: "#{air_loop.name} Fan")
  fan.setAvailabilitySchedule(hvac_op_sch)
  fan.addToNode(air_loop.supplyInletNode)

  # add humidifier to control minimum RH
  humidifier = OpenStudio::Model::HumidifierSteamElectric.new(model)
  humidifier.autosizeRatedCapacity
  humidifier.autosizeRatedPower
  humidifier.setName("#{air_loop.name} Electric Steam Humidifier")
  humidifier.addToNode(air_loop.supplyInletNode)

  # cooling coil
  if chilled_water_loop.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'No chilled water plant loop supplied for CRAH system')
    return false
  else
    create_coil_cooling_water(model,
                              chilled_water_loop,
                              air_loop_node: air_loop.supplyInletNode,
                              name: "#{air_loop.name} Water Clg Coil",
                              schedule: hvac_op_sch)
  end

  # outdoor air intake system
  oa_intake_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
  oa_intake_controller.setName("#{air_loop.name} OA Controller")
  oa_intake_controller.setMinimumLimitType('FixedMinimum')
  oa_intake_controller.setMinimumOutdoorAirSchedule(oa_damper_sch)
  oa_intake_controller.autosizeMinimumOutdoorAirFlowRate

  controller_mv = oa_intake_controller.controllerMechanicalVentilation
  controller_mv.setName("#{air_loop.name} Vent Controller")
  controller_mv.setSystemOutdoorAirMethod('ZoneSum')

  oa_intake = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
  oa_intake.setName("#{air_loop.name} OA System")
  oa_intake.addToNode(air_loop.supplyInletNode)

  # set air loop availability controls
  air_loop.setAvailabilitySchedule(hvac_op_sch)

  # hook the CRAH system to each zone
  thermal_zones.each do |zone|
    # Create a diffuser and attach the zone/diffuser pair to the air loop
    diffuser = OpenStudio::Model::AirTerminalSingleDuctVAVNoReheat.new(model, model.alwaysOnDiscreteSchedule)
    diffuser.setName("#{zone.name} VAV terminal")
    if model.version < OpenStudio::VersionString.new('3.0.1')
      diffuser.setZoneMinimumAirFlowMethod('Constant')
    else
      diffuser.setZoneMinimumAirFlowInputMethod('Constant')
    end
    diffuser.setConstantMinimumAirFlowFraction(0.1)
    air_loop.multiAddBranchForZone(zone, diffuser.to_HVACComponent.get)

    # Zone sizing
    sizing_zone = zone.sizingZone
    # per ASHRAE 90.4, recommended range of data center supply air temperature is 18-27C, pick the mean value 22.5C as prototype
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])

    humidity_spm = OpenStudio::Model::SetpointManagerSingleZoneHumidityMinimum.new(model)
    humidity_spm.setControlZone(zone)
    humidity_spm.addToNode(humidifier.outletModelObject.get.to_Node.get)

    humidistat = OpenStudio::Model::ZoneControlHumidistat.new(model)
    humidistat.setHumidifyingRelativeHumiditySetpointSchedule(model_add_schedule(model, 'DataCenter Humidity Setpoint Schedule'))
    zone.setZoneControlHumidistat(humidistat)

    unless return_plenum.nil?
      zone.setReturnPlenum(return_plenum)
    end
  end

  return air_loop
end

#model_add_curve(model, curve_name) ⇒ Object

Adds a curve from the OpenStudio-Standards dataset to the model based on the curve name.



2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2690

def model_add_curve(model, curve_name)
  # First check model and return curve if it already exists
  existing_curves = []
  existing_curves += model.getCurveLinears
  existing_curves += model.getCurveCubics
  existing_curves += model.getCurveQuadratics
  existing_curves += model.getCurveBicubics
  existing_curves += model.getCurveBiquadratics
  existing_curves.sort.each do |curve|
    if curve.name.get.to_s == curve_name
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "Already added curve: #{curve_name}")
      return curve
    end
  end

  # OpenStudio::logFree(OpenStudio::Info, "openstudio.prototype.addCurve", "Adding curve '#{curve_name}' to the model.")

  # Find curve data
  data = model_find_object(standards_data['curves'], 'name' => curve_name)
  if data.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "Could not find a curve called '#{curve_name}' in the standards.")
    return nil
  end

  # Make the correct type of curve
  case data['form']
    when 'Linear'
      curve = OpenStudio::Model::CurveLinear.new(model)
      curve.setName(data['name'])
      curve.setCoefficient1Constant(data['coeff_1'])
      curve.setCoefficient2x(data['coeff_2'])
      curve.setMinimumValueofx(data['minimum_independent_variable_1']) if data['minimum_independent_variable_1']
      curve.setMaximumValueofx(data['maximum_independent_variable_1']) if data['maximum_independent_variable_1']
      curve.setMinimumCurveOutput(data['minimum_dependent_variable_output']) if data['minimum_dependent_variable_output']
      curve.setMaximumCurveOutput(data['maximum_dependent_variable_output']) if data['maximum_dependent_variable_output']
      return curve
    when 'Cubic'
      curve = OpenStudio::Model::CurveCubic.new(model)
      curve.setName(data['name'])
      curve.setCoefficient1Constant(data['coeff_1'])
      curve.setCoefficient2x(data['coeff_2'])
      curve.setCoefficient3xPOW2(data['coeff_3'])
      curve.setCoefficient4xPOW3(data['coeff_4'])
      curve.setMinimumValueofx(data['minimum_independent_variable_1']) if data['minimum_independent_variable_1']
      curve.setMaximumValueofx(data['maximum_independent_variable_1']) if data['maximum_independent_variable_1']
      curve.setMinimumCurveOutput(data['minimum_dependent_variable_output']) if data['minimum_dependent_variable_output']
      curve.setMaximumCurveOutput(data['maximum_dependent_variable_output']) if data['maximum_dependent_variable_output']
      return curve
    when 'Quadratic'
      curve = OpenStudio::Model::CurveQuadratic.new(model)
      curve.setName(data['name'])
      curve.setCoefficient1Constant(data['coeff_1'])
      curve.setCoefficient2x(data['coeff_2'])
      curve.setCoefficient3xPOW2(data['coeff_3'])
      curve.setMinimumValueofx(data['minimum_independent_variable_1']) if data['minimum_independent_variable_1']
      curve.setMaximumValueofx(data['maximum_independent_variable_1']) if data['maximum_independent_variable_1']
      curve.setMinimumCurveOutput(data['minimum_dependent_variable_output']) if data['minimum_dependent_variable_output']
      curve.setMaximumCurveOutput(data['maximum_dependent_variable_output']) if data['maximum_dependent_variable_output']
      return curve
    when 'BiCubic'
      curve = OpenStudio::Model::CurveBicubic.new(model)
      curve.setName(data['name'])
      curve.setCoefficient1Constant(data['coeff_1'])
      curve.setCoefficient2x(data['coeff_2'])
      curve.setCoefficient3xPOW2(data['coeff_3'])
      curve.setCoefficient4y(data['coeff_4'])
      curve.setCoefficient5yPOW2(data['coeff_5'])
      curve.setCoefficient6xTIMESY(data['coeff_6'])
      curve.setCoefficient7xPOW3(data['coeff_7'])
      curve.setCoefficient8yPOW3(data['coeff_8'])
      curve.setCoefficient9xPOW2TIMESY(data['coeff_9'])
      curve.setCoefficient10xTIMESYPOW2(data['coeff_10'])
      curve.setMinimumValueofx(data['minimum_independent_variable_1']) if data['minimum_independent_variable_1']
      curve.setMaximumValueofx(data['maximum_independent_variable_1']) if data['maximum_independent_variable_1']
      curve.setMinimumValueofy(data['minimum_independent_variable_2']) if data['minimum_independent_variable_2']
      curve.setMaximumValueofy(data['maximum_independent_variable_2']) if data['maximum_independent_variable_2']
      curve.setMinimumCurveOutput(data['minimum_dependent_variable_output']) if data['minimum_dependent_variable_output']
      curve.setMaximumCurveOutput(data['maximum_dependent_variable_output']) if data['maximum_dependent_variable_output']
      return curve
    when 'BiQuadratic'
      curve = OpenStudio::Model::CurveBiquadratic.new(model)
      curve.setName(data['name'])
      curve.setCoefficient1Constant(data['coeff_1'])
      curve.setCoefficient2x(data['coeff_2'])
      curve.setCoefficient3xPOW2(data['coeff_3'])
      curve.setCoefficient4y(data['coeff_4'])
      curve.setCoefficient5yPOW2(data['coeff_5'])
      curve.setCoefficient6xTIMESY(data['coeff_6'])
      curve.setMinimumValueofx(data['minimum_independent_variable_1']) if data['minimum_independent_variable_1']
      curve.setMaximumValueofx(data['maximum_independent_variable_1']) if data['maximum_independent_variable_1']
      curve.setMinimumValueofy(data['minimum_independent_variable_2']) if data['minimum_independent_variable_2']
      curve.setMaximumValueofy(data['maximum_independent_variable_2']) if data['maximum_independent_variable_2']
      curve.setMinimumCurveOutput(data['minimum_dependent_variable_output']) if data['minimum_dependent_variable_output']
      curve.setMaximumCurveOutput(data['maximum_dependent_variable_output']) if data['maximum_dependent_variable_output']
      return curve
    when 'BiLinear'
      curve = OpenStudio::Model::CurveBiquadratic.new(model)
      curve.setName(data['name'])
      curve.setCoefficient1Constant(data['coeff_1'])
      curve.setCoefficient2x(data['coeff_2'])
      curve.setCoefficient4y(data['coeff_3'])
      curve.setMinimumValueofx(data['minimum_independent_variable_1']) if data['minimum_independent_variable_1']
      curve.setMaximumValueofx(data['maximum_independent_variable_1']) if data['maximum_independent_variable_1']
      curve.setMinimumValueofy(data['minimum_independent_variable_2']) if data['minimum_independent_variable_2']
      curve.setMaximumValueofy(data['maximum_independent_variable_2']) if data['maximum_independent_variable_2']
      curve.setMinimumCurveOutput(data['minimum_dependent_variable_output']) if data['minimum_dependent_variable_output']
      curve.setMaximumCurveOutput(data['maximum_dependent_variable_output']) if data['maximum_dependent_variable_output']
      return curve
    when 'MultiVariableLookupTable'
      num_ind_var = data['number_independent_variables'].to_i
      table = OpenStudio::Model::TableMultiVariableLookup.new(model, num_ind_var)
      table.setName(data['name'])
      table.setInterpolationMethod(data['interpolation_method'])
      table.setNumberofInterpolationPoints(data['number_of_interpolation_points'])
      table.setCurveType(data['curve_type'])
      table.setTableDataFormat('SingleLineIndependentVariableWithMatrix')
      table.setNormalizationReference(data['normalization_reference'].to_f)
      table.setOutputUnitType(data['output_unit_type'])
      table.setMinimumValueofX1(data['minimum_independent_variable_1'].to_f)
      table.setMaximumValueofX1(data['maximum_independent_variable_1'].to_f)
      table.setInputUnitTypeforX1(data['input_unit_type_x1'])
      if num_ind_var == 2
        table.setMinimumValueofX2(data['minimum_independent_variable_2'].to_f)
        table.setMaximumValueofX2(data['maximum_independent_variable_2'].to_f)
        table.setInputUnitTypeforX2(data['input_unit_type_x2'])
      end
      data_points = data.each.select { |key, value| key.include? 'data_point' }
      data_points.each do |key, value|
        if num_ind_var == 1
          table.addPoint(value.split(',')[0].to_f, value.split(',')[1].to_f)
        elsif num_ind_var == 2
          table.addPoint(value.split(',')[0].to_f, value.split(',')[1].to_f, value.split(',')[2].to_f)
        end
      end
      return table
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "#{curve_name}' has an invalid form: #{data['form']}', cannot create this curve.")
      return nil
  end
end

#model_add_cw_loop(model, system_name: 'Condenser Water Loop', cooling_tower_type: 'Open Cooling Tower', cooling_tower_fan_type: 'Propeller or Axial', cooling_tower_capacity_control: 'TwoSpeed Fan', number_of_cells_per_tower: 1, number_cooling_towers: 1, use_90_1_design_sizing: true, sup_wtr_temp: 70.0, dsgn_sup_wtr_temp: 85.0, dsgn_sup_wtr_temp_delt: 10.0, wet_bulb_approach: 7.0, pump_spd_ctrl: 'Constant', pump_tot_hd: 49.7) ⇒ OpenStudio::Model::PlantLoop

Creates a condenser water loop and adds it to the model.

Parameters:

  • system_name (String) (defaults to: 'Condenser Water Loop')

    the name of the system, or nil in which case it will be defaulted

  • cooling_tower_type (String) (defaults to: 'Open Cooling Tower')

    valid choices are Open Cooling Tower, Closed Cooling Tower

  • cooling_tower_fan_type (String) (defaults to: 'Propeller or Axial')

    valid choices are Centrifugal, “Propeller or Axial”

  • cooling_tower_capacity_control (String) (defaults to: 'TwoSpeed Fan')

    valid choices are Fluid Bypass, Fan Cycling, TwoSpeed Fan, Variable Speed Fan

  • number_of_cells_per_tower (Integer) (defaults to: 1)

    the number of discrete cells per tower

  • number_cooling_towers (Integer) (defaults to: 1)

    the number of cooling towers to be added (in parallel)

  • use_90_1_design_sizing (Boolean) (defaults to: true)

    will determine the design sizing temperatures based on the 90.1 Appendix G approach. Overrides sup_wtr_temp, dsgn_sup_wtr_temp, dsgn_sup_wtr_temp_delt, and wet_bulb_approach if true.

  • sup_wtr_temp (Double) (defaults to: 70.0)

    supply water temperature in degrees Fahrenheit, default 70F

  • dsgn_sup_wtr_temp (Double) (defaults to: 85.0)

    design supply water temperature in degrees Fahrenheit, default 85F

  • dsgn_sup_wtr_temp_delt (Double) (defaults to: 10.0)

    design water range temperature in degrees Rankine, default 10R

  • wet_bulb_approach (Double) (defaults to: 7.0)

    design wet bulb approach temperature, default 7R

  • pump_spd_ctrl (String) (defaults to: 'Constant')

    pump speed control type, Constant or Variable (default)

  • pump_tot_hd (Double) (defaults to: 49.7)

    pump head in ft H2O

Returns:



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 397

def model_add_cw_loop(model,
                      system_name: 'Condenser Water Loop',
                      cooling_tower_type: 'Open Cooling Tower',
                      cooling_tower_fan_type: 'Propeller or Axial',
                      cooling_tower_capacity_control: 'TwoSpeed Fan',
                      number_of_cells_per_tower: 1,
                      number_cooling_towers: 1,
                      use_90_1_design_sizing: true,
                      sup_wtr_temp: 70.0,
                      dsgn_sup_wtr_temp: 85.0,
                      dsgn_sup_wtr_temp_delt: 10.0,
                      wet_bulb_approach: 7.0,
                      pump_spd_ctrl: 'Constant',
                      pump_tot_hd: 49.7)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding condenser water loop.')

  # create condenser water loop
  condenser_water_loop = OpenStudio::Model::PlantLoop.new(model)
  if system_name.nil?
    condenser_water_loop.setName('Condenser Water Loop')
  else
    condenser_water_loop.setName(system_name)
  end

  # condenser water loop sizing and controls
  if sup_wtr_temp.nil?
    sup_wtr_temp = 70.0
    sup_wtr_temp_c = OpenStudio.convert(sup_wtr_temp, 'F', 'C').get
  else
    sup_wtr_temp_c = OpenStudio.convert(sup_wtr_temp, 'F', 'C').get
  end
  if dsgn_sup_wtr_temp.nil?
    dsgn_sup_wtr_temp = 85.0
    dsgn_sup_wtr_temp_c = OpenStudio.convert(dsgn_sup_wtr_temp, 'F', 'C').get
  else
    dsgn_sup_wtr_temp_c = OpenStudio.convert(dsgn_sup_wtr_temp, 'F', 'C').get
  end
  if dsgn_sup_wtr_temp_delt.nil?
    dsgn_sup_wtr_temp_delt_k = OpenStudio.convert(10.0, 'R', 'K').get
  else
    dsgn_sup_wtr_temp_delt_k = OpenStudio.convert(dsgn_sup_wtr_temp_delt, 'R', 'K').get
  end
  if wet_bulb_approach.nil?
    wet_bulb_approach_k = OpenStudio.convert(7.0, 'R', 'K').get
  else
    wet_bulb_approach_k = OpenStudio.convert(wet_bulb_approach, 'R', 'K').get
  end
  condenser_water_loop.setMinimumLoopTemperature(5.0)
  condenser_water_loop.setMaximumLoopTemperature(80.0)
  sizing_plant = condenser_water_loop.sizingPlant
  sizing_plant.setLoopType('Condenser')
  sizing_plant.setDesignLoopExitTemperature(dsgn_sup_wtr_temp_c)
  sizing_plant.setLoopDesignTemperatureDifference(dsgn_sup_wtr_temp_delt_k)
  sizing_plant.setSizingOption('Coincident')
  sizing_plant.setZoneTimestepsinAveragingWindow(6)
  sizing_plant.setCoincidentSizingFactorMode('GlobalCoolingSizingFactor')

  # follow outdoor air wetbulb with given approach temperature
  cw_stpt_manager = OpenStudio::Model::SetpointManagerFollowOutdoorAirTemperature.new(model)
  cw_stpt_manager.setName("#{condenser_water_loop.name} Setpoint Manager Follow OATwb with #{wet_bulb_approach}F Approach")
  cw_stpt_manager.setReferenceTemperatureType('OutdoorAirWetBulb')
  cw_stpt_manager.setMaximumSetpointTemperature(dsgn_sup_wtr_temp_c)
  cw_stpt_manager.setMinimumSetpointTemperature(sup_wtr_temp_c)
  cw_stpt_manager.setOffsetTemperatureDifference(wet_bulb_approach_k)
  cw_stpt_manager.addToNode(condenser_water_loop.supplyOutletNode)

  # create condenser water pump
  case pump_spd_ctrl
  when 'Constant'
    cw_pump = OpenStudio::Model::PumpConstantSpeed.new(model)
  when 'Variable'
    cw_pump = OpenStudio::Model::PumpVariableSpeed.new(model)
  when 'HeaderedVariable'
    cw_pump = OpenStudio::Model::HeaderedPumpsVariableSpeed.new(model)
    cw_pump.setNumberofPumpsinBank(2)
  when 'HeaderedConstant'
    cw_pump = OpenStudio::Model::HeaderedPumpsConstantSpeed.new(model)
    cw_pump.setNumberofPumpsinBank(2)
  else
    cw_pump = OpenStudio::Model::PumpConstantSpeed.new(model)
  end
  cw_pump.setName("#{condenser_water_loop.name} #{pump_spd_ctrl} Pump")
  cw_pump.setPumpControlType('Intermittent')

  if pump_tot_hd.nil?
    pump_tot_hd_pa =  OpenStudio.convert(49.7, 'ftH_{2}O', 'Pa').get
  else
    pump_tot_hd_pa =  OpenStudio.convert(pump_tot_hd, 'ftH_{2}O', 'Pa').get
  end
  cw_pump.setRatedPumpHead(pump_tot_hd_pa)
  cw_pump.addToNode(condenser_water_loop.supplyInletNode)

  # Cooling towers
  # Per PNNL PRM Reference Manual
  number_cooling_towers.times do |_i|
    # Tower object depends on the control type
    cooling_tower = nil
    case cooling_tower_capacity_control
    when 'Fluid Bypass', 'Fan Cycling'
      cooling_tower = OpenStudio::Model::CoolingTowerSingleSpeed.new(model)
      if cooling_tower_capacity_control == 'Fluid Bypass'
        cooling_tower.setCellControl('FluidBypass')
      else
        cooling_tower.setCellControl('FanCycling')
      end
    when 'TwoSpeed Fan'
      cooling_tower = OpenStudio::Model::CoolingTowerTwoSpeed.new(model)
      # TODO: expose newer cooling tower sizing fields in API
      # cooling_tower.setLowFanSpeedAirFlowRateSizingFactor(0.5)
      # cooling_tower.setLowFanSpeedFanPowerSizingFactor(0.3)
      # cooling_tower.setLowFanSpeedUFactorTimesAreaSizingFactor
      # cooling_tower.setLowSpeedNominalCapacitySizingFactor
    when 'Variable Speed Fan'
      cooling_tower = OpenStudio::Model::CoolingTowerVariableSpeed.new(model)
      cooling_tower.setDesignRangeTemperature(dsgn_sup_wtr_temp_delt_k)
      cooling_tower.setDesignApproachTemperature(wet_bulb_approach_k)
      cooling_tower.setFractionofTowerCapacityinFreeConvectionRegime(0.125)
      twr_fan_curve = model_add_curve(model, 'VSD-TWR-FAN-FPLR')
      cooling_tower.setFanPowerRatioFunctionofAirFlowRateRatioCurve(twr_fan_curve)
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Prototype.hvac_systems', "#{cooling_tower_capacity_control} is not a valid choice of cooling tower capacity control.  Valid choices are Fluid Bypass, Fan Cycling, TwoSpeed Fan, Variable Speed Fan.")
    end

    # Set the properties that apply to all tower types and attach to the condenser loop.
    unless cooling_tower.nil?
      cooling_tower.setName("#{cooling_tower_fan_type} #{cooling_tower_capacity_control} #{cooling_tower_type}")
      cooling_tower.setSizingFactor(1 / number_cooling_towers)
      cooling_tower.setNumberofCells(number_of_cells_per_tower)
      condenser_water_loop.addSupplyBranchForComponent(cooling_tower)
    end
  end

  # apply 90.1 sizing temperatures
  if use_90_1_design_sizing
    # use the formulation in 90.1-2010 G3.1.3.11 to set the approach temperature
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Prototype.hvac_systems', "Using the 90.1-2010 G3.1.3.11 approach temperature sizing methodology for condenser loop #{condenser_water_loop.name}.")

    # first, look in the model design day objects for sizing information
    summer_oat_wbs_f = []
    condenser_water_loop.model.getDesignDays.sort.each do |dd|
      next unless dd.dayType == 'SummerDesignDay'
      next unless dd.name.get.to_s.include?('WB=>MDB')

      if dd.humidityIndicatingType == 'Wetbulb'
        summer_oat_wb_c = dd.humidityIndicatingConditionsAtMaximumDryBulb
        summer_oat_wbs_f << OpenStudio.convert(summer_oat_wb_c, 'C', 'F').get
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Prototype.hvac_systems', "For #{dd.name}, humidity is specified as #{dd.humidityIndicatingType}; cannot determine Twb.")
      end
    end

    # if no design day objects are present in the model, attempt to load the .ddy file directly
    if summer_oat_wbs_f.size.zero?
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Prototype.hvac_systems', 'No valid WB=>MDB Summer Design Days were found in the model.  Attempting to load wet bulb sizing from the .ddy file directly.')
      if model.weatherFile.is_initialized && model.weatherFile.get.path.is_initialized
        weather_file = model.weatherFile.get.path.get.to_s
        # Run differently depending on whether running from embedded filesystem in OpenStudio CLI or not
        if weather_file[0] == ':' # Running from OpenStudio CLI
          # Attempt to load in the ddy file based on convention that it is in the same directory and has the same basename as the epw file.
          ddy_file = weather_file.gsub('.epw', '.ddy')
          if EmbeddedScripting.hasFile(ddy_file)
            ddy_string = EmbeddedScripting.getFileAsString(ddy_file)
            temp_ddy_path = "#{Dir.pwd}/in.ddy"
            File.open(temp_ddy_path, 'wb') { |f| f << ddy_string; f.flush }
            ddy_model = OpenStudio::EnergyPlus.loadAndTranslateIdf(temp_ddy_path).get
            File.delete(temp_ddy_path) if File.exist?(temp_ddy_path)
          else
            OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Prototype.hvac_systems', "Could not locate a .ddy file for weather file path #{weather_file}")
          end
        else
          # Attempt to load in the ddy file based on convention that it is in the same directory and has the same basename as the epw file.
          ddy_file = "#{File.join(File.dirname(weather_file), File.basename(weather_file, '.*'))}.ddy"
          if File.exist? ddy_file
            ddy_model = OpenStudio::EnergyPlus.loadAndTranslateIdf(ddy_file).get
          else
            OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Prototype.hvac_systems', "Could not locate a .ddy file for weather file path #{weather_file}")
          end
        end

        unless ddy_model.nil?
          ddy_model.getDesignDays.sort.each do |dd|
            # Save the model wetbulb design conditions Condns WB=>MDB
            if dd.name.get.include? '4% Condns WB=>MDB'
              summer_oat_wb_c = dd.humidityIndicatingConditionsAtMaximumDryBulb
              summer_oat_wbs_f << OpenStudio.convert(summer_oat_wb_c, 'C', 'F').get
            end
          end
        end
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Prototype.hvac_systems', 'The model does not have a weather file object or path specified in the object. Cannot get .ddy file directory.')
      end
    end

    # if values are still absent, use the CTI rating condition 78F
    design_oat_wb_f = nil
    if summer_oat_wbs_f.size.zero?
      design_oat_wb_f = 78.0
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Prototype.hvac_systems', "For condenser loop #{condenser_water_loop.name}, no design day OATwb conditions found.  CTI rating condition of 78F OATwb will be used for sizing cooling towers.")
    else
      # Take worst case condition
      design_oat_wb_f = summer_oat_wbs_f.max
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.Prototype.hvac_systems', "The maximum design wet bulb temperature from the Summer Design Day WB=>MDB is #{design_oat_wb_f} F")
    end
    design_oat_wb_c = OpenStudio.convert(design_oat_wb_f, 'F', 'C').get

    # call method to apply design sizing to the condenser water loop
    prototype_apply_condenser_water_temperatures(condenser_water_loop, design_wet_bulb_c: design_oat_wb_c)
  end

  # Condenser water loop pipes
  cooling_tower_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  cooling_tower_bypass_pipe.setName("#{condenser_water_loop.name} Cooling Tower Bypass")
  condenser_water_loop.addSupplyBranchForComponent(cooling_tower_bypass_pipe)

  chiller_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  chiller_bypass_pipe.setName("#{condenser_water_loop.name} Chiller Bypass")
  condenser_water_loop.addDemandBranchForComponent(chiller_bypass_pipe)

  supply_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  supply_outlet_pipe.setName("#{condenser_water_loop.name} Supply Outlet")
  supply_outlet_pipe.addToNode(condenser_water_loop.supplyOutletNode)

  demand_inlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_inlet_pipe.setName("#{condenser_water_loop.name} Demand Inlet")
  demand_inlet_pipe.addToNode(condenser_water_loop.demandInletNode)

  demand_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_outlet_pipe.setName("#{condenser_water_loop.name} Demand Outlet")
  demand_outlet_pipe.addToNode(condenser_water_loop.demandOutletNode)

  return condenser_water_loop
end

#model_add_data_center_hvac(model, thermal_zones, hot_water_loop, heat_pump_loop, system_name: nil, hvac_op_sch: nil, oa_damper_sch: nil, main_data_center: false) ⇒ Array<OpenStudio::Model::AirLoopHVAC>

Creates a data center PSZ-AC system for each zone.

Parameters:

  • system_name (String) (defaults to: nil)

    the name of the system, or nil in which case it will be defaulted

  • hot_water_loop (OpenStudio::Model::PlantLoop)

    hot water loop to connect to the heating coil

  • heat_pump_loop (OpenStudio::Model::PlantLoop)

    heat pump water loop to connect to heat pump

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule or nil in which case will be defaulted to always on

  • oa_damper_sch (String) (defaults to: nil)

    name of the oa damper schedule or nil in which case will be defaulted to always open

  • main_data_center (Bool) (defaults to: false)

    whether or not this is the main data center in the building.

Returns:



2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 2874

def model_add_data_center_hvac(model,
                               thermal_zones,
                               hot_water_loop,
                               heat_pump_loop,
                               system_name: nil,
                               hvac_op_sch: nil,
                               oa_damper_sch: nil,
                               main_data_center: false)

  # hvac operation schedule
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # oa damper schedule
  if oa_damper_sch.nil?
    oa_damper_sch = model.alwaysOnDiscreteSchedule
  else
    oa_damper_sch = model_add_schedule(model, oa_damper_sch)
  end

  # create a PSZ-AC for each zone
  air_loops = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding data center HVAC for #{zone.name}.")

    air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
    if system_name.nil?
      air_loop.setName("#{zone.name} PSZ-AC Data Center")
    else
      air_loop.setName("#{zone.name} #{system_name}")
    end

    # default design temperatures across all air loops
    dsgn_temps = standard_design_sizing_temperatures
    unless hot_water_loop.nil?
      hw_temp_c = hot_water_loop.sizingPlant.designLoopExitTemperature
      hw_delta_t_k = hot_water_loop.sizingPlant.loopDesignTemperatureDifference
    end

    # adjusted zone design heating temperature for data center psz_ac
    dsgn_temps['htg_dsgn_sup_air_temp_f'] = dsgn_temps['zn_htg_dsgn_sup_air_temp_f']
    dsgn_temps['htg_dsgn_sup_air_temp_c'] = dsgn_temps['zn_htg_dsgn_sup_air_temp_c']

    # default design settings used across all air loops
    sizing_system = adjust_sizing_system(air_loop, dsgn_temps, min_sys_airflow_ratio: 1.0)

    # air handler controls
    # add a setpoint manager single zone reheat to control the supply air temperature
    setpoint_mgr_single_zone_reheat = OpenStudio::Model::SetpointManagerSingleZoneReheat.new(model)
    setpoint_mgr_single_zone_reheat.setName("#{zone.name} Setpoint Manager SZ Reheat")
    setpoint_mgr_single_zone_reheat.setControlZone(zone)
    setpoint_mgr_single_zone_reheat.setMinimumSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    setpoint_mgr_single_zone_reheat.setMaximumSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    setpoint_mgr_single_zone_reheat.addToNode(air_loop.supplyOutletNode)

    # zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])

    # add the components to the air loop in order from closest to zone to furthest from zone
    if main_data_center
      # extra water heating coil
      create_coil_heating_water(model,
                                hot_water_loop,
                                air_loop_node: air_loop.supplyInletNode,
                                name: "#{air_loop.name} Water Htg Coil",
                                rated_inlet_water_temperature: hw_temp_c,
                                rated_outlet_water_temperature: (hw_temp_c - hw_delta_t_k),
                                rated_inlet_air_temperature: dsgn_temps['prehtg_dsgn_sup_air_temp_c'],
                                rated_outlet_air_temperature: dsgn_temps['htg_dsgn_sup_air_temp_c'])

      # extra electric heating coil
      create_coil_heating_electric(model,
                                   air_loop_node: air_loop.supplyInletNode,
                                   name: "#{air_loop.name} Electric Htg Coil")

      # humidity controllers
      humidifier = OpenStudio::Model::HumidifierSteamElectric.new(model)
      humidifier.setRatedCapacity(3.72E-5)
      humidifier.setRatedPower(100_000)
      humidifier.setName("#{air_loop.name} Electric Steam Humidifier")
      humidifier.addToNode(air_loop.supplyInletNode)
      humidity_spm = OpenStudio::Model::SetpointManagerSingleZoneHumidityMinimum.new(model)
      humidity_spm.setControlZone(zone)
      humidity_spm.addToNode(humidifier.outletModelObject.get.to_Node.get)
      humidistat = OpenStudio::Model::ZoneControlHumidistat.new(model)
      humidistat.setHumidifyingRelativeHumiditySetpointSchedule(model_add_schedule(model, 'OfficeLarge DC_MinRelHumSetSch'))
      zone.setZoneControlHumidistat(humidistat)
    end

    # create fan
    # @type [OpenStudio::Model::FanConstantVolume]
    fan = create_fan_by_name(model,
                             'Packaged_RTU_SZ_AC_Cycling_Fan',
                             fan_name: "#{air_loop.name} Fan")
    fan.setAvailabilitySchedule(hvac_op_sch)

    # create heating and cooling coils
    htg_coil = create_coil_heating_water_to_air_heat_pump_equation_fit(model,
                                                                       heat_pump_loop,
                                                                       name: "#{air_loop.name} Water-to-Air HP Htg Coil")
    clg_coil = create_coil_cooling_water_to_air_heat_pump_equation_fit(model,
                                                                       heat_pump_loop,
                                                                       name: "#{air_loop.name} Water-to-Air HP Clg Coil")
    supplemental_htg_coil = create_coil_heating_electric(model,
                                                         name: "#{air_loop.name} Electric Backup Htg Coil")

    # wrap fan and coils in a unitary system object
    unitary_system = OpenStudio::Model::AirLoopHVACUnitarySystem.new(model)
    unitary_system.setName("#{zone.name} Unitary HP")
    unitary_system.setSupplyFan(fan)
    unitary_system.setHeatingCoil(htg_coil)
    unitary_system.setCoolingCoil(clg_coil)
    unitary_system.setSupplementalHeatingCoil(supplemental_htg_coil)
    unitary_system.setControllingZoneorThermostatLocation(zone)
    unitary_system.setMaximumOutdoorDryBulbTemperatureforSupplementalHeaterOperation(OpenStudio.convert(40.0, 'F', 'C').get)
    unitary_system.setFanPlacement('BlowThrough')
    unitary_system.setSupplyAirFanOperatingModeSchedule(hvac_op_sch)
    unitary_system.setSupplyAirFanOperatingModeSchedule(model.alwaysOnDiscreteSchedule)
    unitary_system.addToNode(air_loop.supplyInletNode)

    # create outdoor air system
    oa_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
    oa_controller.setName("#{air_loop.name} OA System Controller")
    oa_controller.setMinimumOutdoorAirSchedule(oa_damper_sch)
    oa_controller.autosizeMinimumOutdoorAirFlowRate
    oa_controller.resetEconomizerMinimumLimitDryBulbTemperature
    oa_system = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_controller)
    oa_system.setName("#{air_loop.name} OA System")
    oa_system.addToNode(air_loop.supplyInletNode)

    # set air loop availability controls and night cycle manager, after oa system added
    air_loop.setAvailabilitySchedule(hvac_op_sch)
    air_loop.setNightCycleControlType('CycleOnAny')

    # create a diffuser and attach the zone/diffuser pair to the air loop
    diffuser = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule)
    diffuser.setName("#{air_loop.name} Diffuser")
    air_loop.multiAddBranchForZone(zone, diffuser.to_HVACComponent.get)

    air_loops << air_loop
  end

  return air_loops
end

#model_add_data_center_load(model, space, dc_watts_per_area) ⇒ Bool

Adds a data center load to a given space.

Parameters:

  • space (OpenStudio::Model::Space)

    which space to assign the data center loads to

  • dc_watts_per_area (Double)

    data center load, in W/m^2

Returns:

  • (Bool)

    returns true if successful, false if not



2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 2850

def model_add_data_center_load(model, space, dc_watts_per_area)
  # create data center load
  data_center_definition = OpenStudio::Model::ElectricEquipmentDefinition.new(model)
  data_center_definition.setName('Data Center Load')
  data_center_definition.setWattsperSpaceFloorArea(dc_watts_per_area)
  data_center_equipment = OpenStudio::Model::ElectricEquipment.new(data_center_definition)
  data_center_equipment.setName('Data Center Load')
  data_center_sch = model.alwaysOnDiscreteSchedule
  data_center_equipment.setSchedule(data_center_sch)
  data_center_equipment.setSpace(space)

  return true
end

#model_add_daylighting_controls(model) ⇒ Object

Applies daylighting controls to each space in the model per the standard.



1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1562

def model_add_daylighting_controls(model)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started adding daylighting controls.')

  # Add daylighting controls to each space
  model.getSpaces.sort.each do |space|
    added = space_add_daylighting_controls(space, false, false)
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Finished adding daylighting controls.')
end

#model_add_design_days_and_weather_file(model, climate_zone, epw_file) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 80

def model_add_design_days_and_weather_file(model, climate_zone, epw_file)
  success = true
  require_relative 'Weather.stat_file'

  # Remove any existing Design Day objects that are in the file
  model.getDesignDays.each(&:remove)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.weather.Model', "Started adding weather file for climate zone: #{climate_zone}.")

  # Define the weather file for each climate zone
  climate_zone_weather_file_map = model_get_climate_zone_weather_file_map(epw_file)

  # Get the weather file name from the hash
  weather_file_name = if epw_file.nil? || (epw_file.to_s.strip == '')
                        climate_zone_weather_file_map[climate_zone]
                      else
                        epw_file.to_s
                      end
  if weather_file_name.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.weather.Model', "Could not determine the weather file for climate zone: #{climate_zone}.")
    success = false
  end

  # Define where the weather files lives
  weather_dir = nil
  if __dir__[0] == ':' # Running from OpenStudio CLI
    # load weather file from embedded files
    epw_string = load_resource_relative("../../../data/weather/#{weather_file_name}")
    ddy_string = load_resource_relative("../../../data/weather/#{weather_file_name.gsub('.epw', '.ddy')}")
    stat_string = load_resource_relative("../../../data/weather/#{weather_file_name.gsub('.epw', '.stat')}")

    # extract to local weather dir
    weather_dir = File.expand_path(File.join(Dir.pwd, 'extracted_files/weather/'))
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.weather.Model', "Extracting weather files from OpenStudio CLI to #{weather_dir}")
    FileUtils.mkdir_p(weather_dir)
    File.open("#{weather_dir}/#{weather_file_name}", 'wb') { |f| f << epw_string; f.flush }
    File.open("#{weather_dir}/#{weather_file_name.gsub('.epw', '.ddy')}", 'wb') { |f| f << ddy_string; f.flush }
    File.open("#{weather_dir}/#{weather_file_name.gsub('.epw', '.stat')}", 'wb') { |f| f << stat_string; f.flush }
  else
    # loaded gem from system path
    top_dir = File.expand_path('../../..', File.dirname(__FILE__))
    weather_dir = File.expand_path("#{top_dir}/data/weather")
  end

  # Add Weather File
  unless (Pathname.new weather_dir).absolute?
    weather_dir = File.expand_path(File.join(File.dirname(__FILE__), weather_dir))
  end

  weather_file = File.join(weather_dir, weather_file_name)
  epw_file = OpenStudio::EpwFile.new(weather_file)
  OpenStudio::Model::WeatherFile.setWeatherFile(model, epw_file).get

  weather_name = "#{epw_file.city}_#{epw_file.stateProvinceRegion}_#{epw_file.country}"
  weather_lat = epw_file.latitude
  weather_lon = epw_file.longitude
  weather_time = epw_file.timeZone
  weather_elev = epw_file.elevation

  # Add or update site data
  site = model.getSite
  site.setName(weather_name)
  site.setLatitude(weather_lat)
  site.setLongitude(weather_lon)
  site.setTimeZone(weather_time)
  site.setElevation(weather_elev)

  # Add SiteWaterMainsTemperature -- via parsing of STAT file.
  stat_filename = "#{File.join(File.dirname(weather_file), File.basename(weather_file, '.*'))}.stat"
  if File.exist? stat_filename
    stat_file = EnergyPlus::StatFile.new(stat_filename)
    water_temp = model.getSiteWaterMainsTemperature
    water_temp.setAnnualAverageOutdoorAirTemperature(stat_file.mean_dry_bulb)
    water_temp.setMaximumDifferenceInMonthlyAverageOutdoorAirTemperatures(stat_file.delta_dry_bulb)
    # OpenStudio::logFree(OpenStudio::Info, "openstudio.weather.Model", "Mean dry bulb is #{stat_file.mean_dry_bulb}")
    # OpenStudio::logFree(OpenStudio::Info, "openstudio.weather.Model", "Delta dry bulb is #{stat_file.delta_dry_bulb}")
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.weather.Model', 'Could not find .stat file for weather, will use default water mains temperatures which may be inaccurate for the location.')
    success = false
  end

  # Load in the ddy file based on convention that it is in
  # the same directory and has the same basename as the epw file.
  ddy_file = "#{File.join(File.dirname(weather_file), File.basename(weather_file, '.*'))}.ddy"
  if File.exist? ddy_file
    ddy_model = OpenStudio::EnergyPlus.loadAndTranslateIdf(ddy_file).get
    ddy_model.getObjectsByType('OS:SizingPeriod:DesignDay'.to_IddObjectType).sort.each do |d|
      # Import the 99.6% Heating and 0.4% Cooling design days
      ddy_list = /(Htg 99.6. Condns DB)|(Clg .4% Condns DB=>MWB)|(Clg 0.4% Condns DB=>MCWB)/
      if d.name.get =~ ddy_list
        model.addObject(d.clone)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.weather.Model', "Added #{d.name} design day.")
      end
    end
    # Check to ensure that some design days were added
    if model.getDesignDays.size.zero?
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.weather.Model', "No design days were loaded, check syntax of .ddy file: #{ddy_file}.")
    end
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.weather.Model', "Could not find .ddy file for: #{ddy_file}.")
    success = false
  end

  return success
end

#model_add_district_ambient_loop(model, system_name: 'Ambient Loop') ⇒ OpenStudio::Model::PlantLoop

Adds an ambient condenser water loop that will be used in a district to connect buildings as a shared sink/source for heat pumps.

TODO: add inputs for design temperatures like heat pump loop object TODO: handle ground and heat pump with this; make heating/cooling source options (boiler, fluid cooler, district)

Parameters:

  • system_name (String) (defaults to: 'Ambient Loop')

    the name of the system, or nil in which case it will be defaulted

Returns:



942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 942

def model_add_district_ambient_loop(model,
                                    system_name: 'Ambient Loop')
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding district ambient loop.')

  # create ambient loop
  ambient_loop = OpenStudio::Model::PlantLoop.new(model)
  if system_name.nil?
    ambient_loop.setName('Ambient Loop')
  else
    ambient_loop.setName(system_name)
  end

  # ambient loop sizing and controls
  ambient_loop.setMinimumLoopTemperature(5.0)
  ambient_loop.setMaximumLoopTemperature(80.0)

  amb_high_temp_f = 90 # Supplemental cooling below 65F
  amb_low_temp_f = 41 # Supplemental heat below 41F
  amb_temp_sizing_f = 102.2 # CW sized to deliver 102.2F
  amb_delta_t_r = 19.8 # 19.8F delta-T
  amb_high_temp_c = OpenStudio.convert(amb_high_temp_f, 'F', 'C').get
  amb_low_temp_c = OpenStudio.convert(amb_low_temp_f, 'F', 'C').get
  amb_temp_sizing_c = OpenStudio.convert(amb_temp_sizing_f, 'F', 'C').get
  amb_delta_t_k = OpenStudio.convert(amb_delta_t_r, 'R', 'K').get

  amb_high_temp_sch = model_add_constant_schedule_ruleset(model,
                                                          amb_high_temp_c,
                                                          name = "Ambient Loop High Temp - #{amb_high_temp_f}F")

  amb_low_temp_sch = model_add_constant_schedule_ruleset(model,
                                                         amb_low_temp_c,
                                                         name = "Ambient Loop Low Temp - #{amb_low_temp_f}F")

  amb_stpt_manager = OpenStudio::Model::SetpointManagerScheduledDualSetpoint.new(model)
  amb_stpt_manager.setName("#{ambient_loop.name} Supply Water Setpoint Manager")
  amb_stpt_manager.setHighSetpointSchedule(amb_high_temp_sch)
  amb_stpt_manager.setLowSetpointSchedule(amb_low_temp_sch)
  amb_stpt_manager.addToNode(ambient_loop.supplyOutletNode)

  sizing_plant = ambient_loop.sizingPlant
  sizing_plant.setLoopType('Heating')
  sizing_plant.setDesignLoopExitTemperature(amb_temp_sizing_c)
  sizing_plant.setLoopDesignTemperatureDifference(amb_delta_t_k)

  # create pump
  pump = OpenStudio::Model::PumpVariableSpeed.new(model)
  pump.setName("#{ambient_loop.name} Pump")
  pump.setRatedPumpHead(OpenStudio.convert(60.0, 'ftH_{2}O', 'Pa').get)
  pump.setPumpControlType('Intermittent')
  pump.addToNode(ambient_loop.supplyInletNode)

  # cooling
  district_cooling = OpenStudio::Model::DistrictCooling.new(model)
  district_cooling.setNominalCapacity(1_000_000_000_000) # large number; no autosizing
  ambient_loop.addSupplyBranchForComponent(district_cooling)

  # heating
  district_heating = OpenStudio::Model::DistrictHeating.new(model)
  district_heating.setNominalCapacity(1_000_000_000_000) # large number; no autosizing
  ambient_loop.addSupplyBranchForComponent(district_heating)

  # add ambient water loop pipes
  supply_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  supply_bypass_pipe.setName("#{ambient_loop.name} Supply Bypass")
  ambient_loop.addSupplyBranchForComponent(supply_bypass_pipe)

  demand_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_bypass_pipe.setName("#{ambient_loop.name} Demand Bypass")
  ambient_loop.addDemandBranchForComponent(demand_bypass_pipe)

  supply_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  supply_outlet_pipe.setName("#{ambient_loop.name} Supply Outlet")
  supply_outlet_pipe.addToNode(ambient_loop.supplyOutletNode)

  demand_inlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_inlet_pipe.setName("#{ambient_loop.name} Demand Inlet")
  demand_inlet_pipe.addToNode(ambient_loop.demandInletNode)

  demand_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_outlet_pipe.setName("#{ambient_loop.name} Demand Outlet")
  demand_outlet_pipe.addToNode(ambient_loop.demandOutletNode)

  return ambient_loop
end

#model_add_doas(model, thermal_zones, system_name: nil, doas_type: 'DOASCV', hot_water_loop: nil, chilled_water_loop: nil, hvac_op_sch: nil, min_oa_sch: nil, min_frac_oa_sch: nil, fan_maximum_flow_rate: nil, econo_ctrl_mthd: 'NoEconomizer', include_exhaust_fan: true, demand_control_ventilation: false, doas_control_strategy: 'NeutralSupplyAir', clg_dsgn_sup_air_temp: 60.0, htg_dsgn_sup_air_temp: 70.0) ⇒ OpenStudio::Model::AirLoopHVAC

Creates a DOAS system with terminal units for each zone.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • system_name (String) (defaults to: nil)

    the name of the system, or nil in which case it will be defaulted

  • doas_type (String) (defaults to: 'DOASCV')

    DOASCV or DOASVAV, determines whether the DOAS is operated at scheduled, constant flow rate, or airflow is variable to allow for economizing or demand controlled ventilation

  • doas_control_strategy (String) (defaults to: 'NeutralSupplyAir')

    DOAS control strategy

  • hot_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    hot water loop to connect to heating and zone fan coils

  • chilled_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    chilled water loop to connect to cooling coil

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule, default is always on

  • min_oa_sch (String) (defaults to: nil)

    name of the minimum outdoor air schedule, default is always on

  • min_frac_oa_sch (String) (defaults to: nil)

    name of the minimum fraction of outdoor air schedule, default is always on

  • fan_maximum_flow_rate (Double) (defaults to: nil)

    fan maximum flow rate in cfm, default is autosize

  • econo_ctrl_mthd (String) (defaults to: 'NoEconomizer')

    economizer control type, default is Fixed Dry Bulb If enabled, the DOAS will be sized for twice the ventilation minimum to allow economizing

  • include_exhaust_fan (Bool) (defaults to: true)

    if true, include an exhaust fan

  • clg_dsgn_sup_air_temp (Double) (defaults to: 60.0)

    design cooling supply air temperature in degrees Fahrenheit, default 65F

  • htg_dsgn_sup_air_temp (Double) (defaults to: 70.0)

    design heating supply air temperature in degrees Fahrenheit, default 75F

Returns:



1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 1274

def model_add_doas(model,
                   thermal_zones,
                   system_name: nil,
                   doas_type: 'DOASCV',
                   hot_water_loop: nil,
                   chilled_water_loop: nil,
                   hvac_op_sch: nil,
                   min_oa_sch: nil,
                   min_frac_oa_sch: nil,
                   fan_maximum_flow_rate: nil,
                   econo_ctrl_mthd: 'NoEconomizer',
                   include_exhaust_fan: true,
                   demand_control_ventilation: false,
                   doas_control_strategy: 'NeutralSupplyAir',
                   clg_dsgn_sup_air_temp: 60.0,
                   htg_dsgn_sup_air_temp: 70.0)

  # Check the total OA requirement for all zones on the system
  tot_oa_req = 0
  thermal_zones.each do |zone|
    tot_oa_req += thermal_zone_outdoor_airflow_rate(zone)
  end

  # If the total OA requirement is zero do not add the DOAS system because the simulations will fail
  if tot_oa_req.zero?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Not adding DOAS system for #{thermal_zones.size} zones because combined OA requirement for all zones is zero.")
    return false
  end
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding DOAS system for #{thermal_zones.size} zones.")

  # create a DOAS air loop
  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  if system_name.nil?
    air_loop.setName("#{thermal_zones.size} Zone DOAS")
  else
    air_loop.setName(system_name)
  end

  # set availability schedule
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # DOAS design temperatures
  if clg_dsgn_sup_air_temp.nil?
    clg_dsgn_sup_air_temp_c = OpenStudio.convert(60.0, 'F', 'C').get
  else
    clg_dsgn_sup_air_temp_c = OpenStudio.convert(clg_dsgn_sup_air_temp, 'F', 'C').get
  end

  if htg_dsgn_sup_air_temp.nil?
    htg_dsgn_sup_air_temp_c = OpenStudio.convert(70.0, 'F', 'C').get
  else
    htg_dsgn_sup_air_temp_c = OpenStudio.convert(htg_dsgn_sup_air_temp, 'F', 'C').get
  end

  # modify system sizing properties
  sizing_system = air_loop.sizingSystem
  sizing_system.setTypeofLoadtoSizeOn('VentilationRequirement')
  sizing_system.setAllOutdoorAirinCooling(true)
  sizing_system.setAllOutdoorAirinHeating(true)
  # set minimum airflow ratio to 1.0 to avoid under-sizing heating coil
  if model.version < OpenStudio::VersionString.new('2.7.0')
    sizing_system.setMinimumSystemAirFlowRatio(1.0)
  else
    sizing_system.setCentralHeatingMaximumSystemAirFlowRatio(1.0)
  end
  sizing_system.setSizingOption('Coincident')
  sizing_system.setCentralCoolingDesignSupplyAirTemperature(clg_dsgn_sup_air_temp_c)
  sizing_system.setCentralHeatingDesignSupplyAirTemperature(htg_dsgn_sup_air_temp_c)

  if doas_type == 'DOASCV'
    supply_fan = create_fan_by_name(model,
                                    'Constant_DOAS_Fan',
                                    fan_name: 'DOAS Supply Fan',
                                    end_use_subcategory: 'DOAS Fans')
  else # 'DOASVAV'
    supply_fan = create_fan_by_name(model,
                                    'Variable_DOAS_Fan',
                                    fan_name: 'DOAS Supply Fan',
                                    end_use_subcategory: 'DOAS Fans')
  end
  supply_fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  supply_fan.setMaximumFlowRate(OpenStudio.convert(fan_maximum_flow_rate, 'cfm', 'm^3/s').get) unless fan_maximum_flow_rate.nil?
  supply_fan.addToNode(air_loop.supplyInletNode)

  # create heating coil
  if hot_water_loop.nil?
    # electric backup heating coil
    create_coil_heating_electric(model,
                                 air_loop_node: air_loop.supplyInletNode,
                                 name: "#{air_loop.name} Backup Htg Coil")
    # heat pump coil
    create_coil_heating_dx_single_speed(model,
                                        air_loop_node: air_loop.supplyInletNode,
                                        name: "#{air_loop.name} Htg Coil")
  else
    create_coil_heating_water(model,
                              hot_water_loop,
                              air_loop_node: air_loop.supplyInletNode,
                              name: "#{air_loop.name} Htg Coil",
                              controller_convergence_tolerance: 0.0001)
  end

  # could add a humidity controller here set to limit supply air to a 16.6C/62F dewpoint
  # the default outdoor air reset to 60F prevents exceeding this dewpoint in all ASHRAE climate zones
  # the humidity controller needs a DX coil that can control humidity, e.g. CoilCoolingDXTwoStageWithHumidityControlMode
  # max_humidity_ratio_sch = model_add_constant_schedule_ruleset(model,
  #                                                              0.012,
  #                                                              name = "0.012 Humidity Ratio Schedule",
  #                                                              sch_type_limit: "Humidity Ratio")
  # sat_oa_reset = OpenStudio::Model::SetpointManagerScheduled.new(model, max_humidity_ratio_sch)
  # sat_oa_reset.setName("#{air_loop.name.to_s} Humidity Controller")
  # sat_oa_reset.setControlVariable('MaximumHumidityRatio')
  # sat_oa_reset.addToNode(air_loop.supplyInletNode)

  # create cooling coil
  if chilled_water_loop.nil?
    create_coil_cooling_dx_two_speed(model,
                                     air_loop_node: air_loop.supplyInletNode,
                                     name: "#{air_loop.name} 2spd DX Clg Coil",
                                     type: 'OS default')
  else
    create_coil_cooling_water(model,
                              chilled_water_loop,
                              air_loop_node: air_loop.supplyInletNode,
                              name: "#{air_loop.name} Clg Coil")
  end

  # minimum outdoor air schedule
  unless min_oa_sch.nil?
    min_oa_sch = model_add_schedule(model, min_oa_sch)
  end

  # minimum outdoor air fraction schedule
  if min_frac_oa_sch.nil?
    min_frac_oa_sch = model.alwaysOnDiscreteSchedule
  else
    min_frac_oa_sch = model_add_schedule(model, min_frac_oa_sch)
  end

  # create controller outdoor air
  controller_oa = OpenStudio::Model::ControllerOutdoorAir.new(model)
  controller_oa.setName("#{air_loop.name} Outdoor Air Controller")
  controller_oa.setEconomizerControlType(econo_ctrl_mthd)
  controller_oa.setMinimumLimitType('FixedMinimum')
  controller_oa.autosizeMinimumOutdoorAirFlowRate
  controller_oa.setMinimumOutdoorAirSchedule(min_oa_sch) unless min_oa_sch.nil?
  controller_oa.setMinimumFractionofOutdoorAirSchedule(min_frac_oa_sch)
  controller_oa.resetEconomizerMinimumLimitDryBulbTemperature
  controller_oa.resetEconomizerMaximumLimitDryBulbTemperature
  controller_oa.resetEconomizerMaximumLimitEnthalpy
  controller_oa.resetMaximumFractionofOutdoorAirSchedule
  controller_oa.setHeatRecoveryBypassControlType('BypassWhenWithinEconomizerLimits')
  controller_mech_vent = controller_oa.controllerMechanicalVentilation
  controller_mech_vent.setName("#{air_loop.name} Mechanical Ventilation Controller")
  controller_mech_vent.setDemandControlledVentilation(true) if demand_control_ventilation
  controller_mech_vent.setSystemOutdoorAirMethod('ZoneSum')

  # create outdoor air system
  oa_system = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, controller_oa)
  oa_system.setName("#{air_loop.name} OA System")
  oa_system.addToNode(air_loop.supplyInletNode)

  # create an exhaust fan
  if include_exhaust_fan
    if doas_type == 'DOASCV'
      exhaust_fan = create_fan_by_name(model,
                                       'Constant_DOAS_Fan',
                                       fan_name: 'DOAS Exhaust Fan',
                                       end_use_subcategory: 'DOAS Fans')
    else # 'DOASVAV'
      exhaust_fan = create_fan_by_name(model,
                                       'Variable_DOAS_Fan',
                                       fan_name: 'DOAS Exhaust Fan',
                                       end_use_subcategory: 'DOAS Fans')
    end
    # set pressure rise 1.0 inH2O lower than supply fan, 1.0 inH2O minimum
    exhaust_fan_pressure_rise = supply_fan.pressureRise - OpenStudio.convert(1.0, 'inH_{2}O', 'Pa').get
    exhaust_fan_pressure_rise = OpenStudio.convert(1.0, 'inH_{2}O', 'Pa').get if exhaust_fan_pressure_rise < OpenStudio.convert(1.0, 'inH_{2}O', 'Pa').get
    exhaust_fan.setPressureRise(exhaust_fan_pressure_rise)
    exhaust_fan.addToNode(air_loop.supplyInletNode)
  end

  # create a setpoint manager
  sat_oa_reset = OpenStudio::Model::SetpointManagerOutdoorAirReset.new(model)
  sat_oa_reset.setName("#{air_loop.name} SAT Reset")
  sat_oa_reset.setControlVariable('Temperature')
  sat_oa_reset.setSetpointatOutdoorLowTemperature(htg_dsgn_sup_air_temp_c)
  sat_oa_reset.setOutdoorLowTemperature(OpenStudio.convert(55.0, 'F', 'C').get)
  sat_oa_reset.setSetpointatOutdoorHighTemperature(clg_dsgn_sup_air_temp_c)
  sat_oa_reset.setOutdoorHighTemperature(OpenStudio.convert(70.0, 'F', 'C').get)
  sat_oa_reset.addToNode(air_loop.supplyOutletNode)

  # set air loop availability controls and night cycle manager, after oa system added
  air_loop.setAvailabilitySchedule(hvac_op_sch)
  air_loop.setNightCycleControlType('CycleOnAnyZoneFansOnly')

  # add thermal zones to airloop
  thermal_zones.each do |zone|
    # skip zones with no outdoor air flow rate
    unless thermal_zone_outdoor_airflow_rate(zone) > 0
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "---#{zone.name} has no outdoor air flow rate and will not be added to #{air_loop.name}")
      next
    end

    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "---adding #{zone.name} to #{air_loop.name}")

    # make an air terminal for the zone
    if doas_type == 'DOASCV'
      air_terminal = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule)
    elsif doas_type == 'DOASVAVReheat'
      # Reheat coil
      if hot_water_loop.nil?
        rht_coil = create_coil_heating_electric(model, name: "#{zone.name} Electric Reheat Coil")
      else
        rht_coil = create_coil_heating_water(model, hot_water_loop, name: "#{zone.name} Reheat Coil")
      end
      # VAV reheat terminal
      air_terminal = OpenStudio::Model::AirTerminalSingleDuctVAVReheat.new(model, model.alwaysOnDiscreteSchedule, rht_coil)
      if model.version < OpenStudio::VersionString.new('3.0.1')
        air_terminal.setZoneMinimumAirFlowMethod('Constant')
      else
        air_terminal.setZoneMinimumAirFlowInputMethod('Constant')
      end
      air_terminal.setControlForOutdoorAir(true) if demand_control_ventilation
    else # 'DOASVAV'
      air_terminal = OpenStudio::Model::AirTerminalSingleDuctVAVNoReheat.new(model, model.alwaysOnDiscreteSchedule)
      if model.version < OpenStudio::VersionString.new('3.0.1')
        air_terminal.setZoneMinimumAirFlowMethod('Constant')
      else
        air_terminal.setZoneMinimumAirFlowInputMethod('Constant')
      end
      air_terminal.setConstantMinimumAirFlowFraction(0.1)
      air_terminal.setControlForOutdoorAir(true) if demand_control_ventilation
    end
    air_terminal.setName("#{zone.name} Air Terminal")

    # attach new terminal to the zone and to the airloop
    air_loop.multiAddBranchForZone(zone, air_terminal.to_HVACComponent.get)

    # ensure the DOAS takes priority, so ventilation load is included when treated by other zonal systems
    # From EnergyPlus I/O reference:
    # "For situations where one or more equipment types has limited capacity or limited control capability, order the
    #  sequence so that the most controllable piece of equipment runs last. For example, with a dedicated outdoor air
    #  system (DOAS), the air terminal for the DOAS should be assigned Heating Sequence = 1 and Cooling Sequence = 1.
    #  Any other equipment should be assigned sequence 2 or higher so that it will see the net load after the DOAS air
    #  is added to the zone."
    zone.setCoolingPriority(air_terminal.to_ModelObject.get, 1)
    zone.setHeatingPriority(air_terminal.to_ModelObject.get, 1)

    # set the cooling and heating fraction to zero so that if DCV is enabled,
    # the system will lower the ventilation rate rather than trying to meet the heating or cooling load.
    if model.version < OpenStudio::VersionString.new('2.8.0')
      if demand_control_ventilation
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', 'Unable to add DOAS with DCV to model because the setSequentialCoolingFraction method is not available in OpenStudio versions less than 2.8.0.')
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', 'OpenStudio version is less than 2.8.0.  The DOAS system will not be able to have DCV if changed at a later date.')
      end
    else
      zone.setSequentialCoolingFraction(air_terminal.to_ModelObject.get, 0.0)
      zone.setSequentialHeatingFraction(air_terminal.to_ModelObject.get, 0.0)

      # if economizing, override to meet cooling load first with doas supply
      unless econo_ctrl_mthd == 'NoEconomizer'
        zone.setSequentialCoolingFraction(air_terminal.to_ModelObject.get, 1.0)
      end
    end

    # DOAS sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setAccountforDedicatedOutdoorAirSystem(true)
    sizing_zone.setDedicatedOutdoorAirSystemControlStrategy(doas_control_strategy)
    sizing_zone.setDedicatedOutdoorAirLowSetpointTemperatureforDesign(clg_dsgn_sup_air_temp_c)
    sizing_zone.setDedicatedOutdoorAirHighSetpointTemperatureforDesign(htg_dsgn_sup_air_temp_c)
  end

  return air_loop
end

#model_add_doas_cold_supply(model, thermal_zones, system_name: nil, hot_water_loop: nil, chilled_water_loop: nil, hvac_op_sch: nil, min_oa_sch: nil, min_frac_oa_sch: nil, fan_maximum_flow_rate: nil, econo_ctrl_mthd: 'FixedDryBulb', energy_recovery: false, doas_control_strategy: 'NeutralSupplyAir', clg_dsgn_sup_air_temp: 55.0, htg_dsgn_sup_air_temp: 60.0) ⇒ OpenStudio::Model::AirLoopHVAC

Creates a DOAS system with cold supply and terminal units for each zone. This is the default DOAS system for DOE prototype buildings. Use model_add_doas for other DOAS systems.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • system_name (String) (defaults to: nil)

    the name of the system, or nil in which case it will be defaulted

  • hot_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    hot water loop to connect to heating and zone fan coils

  • chilled_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    chilled water loop to connect to cooling coil

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule, default is always on

  • min_oa_sch (String) (defaults to: nil)

    name of the minimum outdoor air schedule, default is always on

  • min_frac_oa_sch (String) (defaults to: nil)

    name of the minimum fraction of outdoor air schedule, default is always on

  • fan_maximum_flow_rate (Double) (defaults to: nil)

    fan maximum flow rate in cfm, default is autosize

  • econo_ctrl_mthd (String) (defaults to: 'FixedDryBulb')

    economizer control type, default is Fixed Dry Bulb

  • energy_recovery (Bool) (defaults to: false)

    if true, an ERV will be added to the system

  • doas_control_strategy (String) (defaults to: 'NeutralSupplyAir')

    DOAS control strategy

  • clg_dsgn_sup_air_temp (Double) (defaults to: 55.0)

    design cooling supply air temperature in degrees Fahrenheit, default 65F

  • htg_dsgn_sup_air_temp (Double) (defaults to: 60.0)

    design heating supply air temperature in degrees Fahrenheit, default 75F

Returns:



1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 1044

def model_add_doas_cold_supply(model,
                               thermal_zones,
                               system_name: nil,
                               hot_water_loop: nil,
                               chilled_water_loop: nil,
                               hvac_op_sch: nil,
                               min_oa_sch: nil,
                               min_frac_oa_sch: nil,
                               fan_maximum_flow_rate: nil,
                               econo_ctrl_mthd: 'FixedDryBulb',
                               energy_recovery: false,
                               doas_control_strategy: 'NeutralSupplyAir',
                               clg_dsgn_sup_air_temp: 55.0,
                               htg_dsgn_sup_air_temp: 60.0)

  # Check the total OA requirement for all zones on the system
  tot_oa_req = 0
  thermal_zones.each do |zone|
    tot_oa_req += thermal_zone_outdoor_airflow_rate(zone)
    break if tot_oa_req > 0
  end

  # If the total OA requirement is zero do not add the DOAS system because the simulations will fail
  if tot_oa_req.zero?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Not adding DOAS system for #{thermal_zones.size} zones because combined OA requirement for all zones is zero.")
    return false
  end
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding DOAS system for #{thermal_zones.size} zones.")

  # create a DOAS air loop
  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  if system_name.nil?
    air_loop.setName("#{thermal_zones.size} Zone DOAS")
  else
    air_loop.setName(system_name)
  end

  # set availability schedule
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # DOAS design temperatures
  if clg_dsgn_sup_air_temp.nil?
    clg_dsgn_sup_air_temp_c = OpenStudio.convert(55.0, 'F', 'C').get
  else
    clg_dsgn_sup_air_temp_c = OpenStudio.convert(clg_dsgn_sup_air_temp, 'F', 'C').get
  end

  if htg_dsgn_sup_air_temp.nil?
    htg_dsgn_sup_air_temp_c = OpenStudio.convert(60.0, 'F', 'C').get
  else
    htg_dsgn_sup_air_temp_c = OpenStudio.convert(htg_dsgn_sup_air_temp, 'F', 'C').get
  end

  # modify system sizing properties
  sizing_system = air_loop.sizingSystem
  sizing_system.setTypeofLoadtoSizeOn('VentilationRequirement')
  sizing_system.setAllOutdoorAirinCooling(true)
  sizing_system.setAllOutdoorAirinHeating(true)
  # set minimum airflow ratio to 1.0 to avoid under-sizing heating coil
  if model.version < OpenStudio::VersionString.new('2.7.0')
    sizing_system.setMinimumSystemAirFlowRatio(1.0)
  else
    sizing_system.setCentralHeatingMaximumSystemAirFlowRatio(1.0)
  end
  sizing_system.setSizingOption('Coincident')
  sizing_system.setCentralCoolingDesignSupplyAirTemperature(clg_dsgn_sup_air_temp_c)
  sizing_system.setCentralHeatingDesignSupplyAirTemperature(htg_dsgn_sup_air_temp_c)

  # create supply fan
  supply_fan = create_fan_by_name(model,
                                  'Constant_DOAS_Fan',
                                  fan_name: 'DOAS Supply Fan',
                                  end_use_subcategory: 'DOAS Fans')
  supply_fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  supply_fan.setMaximumFlowRate(OpenStudio.convert(fan_maximum_flow_rate, 'cfm', 'm^3/s').get) unless fan_maximum_flow_rate.nil?
  supply_fan.addToNode(air_loop.supplyInletNode)

  # create heating coil
  if hot_water_loop.nil?
    # electric backup heating coil
    create_coil_heating_electric(model,
                                 air_loop_node: air_loop.supplyInletNode,
                                 name: "#{air_loop.name} Backup Htg Coil")
    # heat pump coil
    create_coil_heating_dx_single_speed(model,
                                        air_loop_node: air_loop.supplyInletNode,
                                        name: "#{air_loop.name} Htg Coil")
  else
    create_coil_heating_water(model,
                              hot_water_loop,
                              air_loop_node: air_loop.supplyInletNode,
                              name: "#{air_loop.name} Htg Coil",
                              controller_convergence_tolerance: 0.0001)
  end

  # create cooling coil
  if chilled_water_loop.nil?
    create_coil_cooling_dx_two_speed(model,
                                     air_loop_node: air_loop.supplyInletNode,
                                     name: "#{air_loop.name} 2spd DX Clg Coil",
                                     type: 'OS default')
  else
    create_coil_cooling_water(model,
                              chilled_water_loop,
                              air_loop_node: air_loop.supplyInletNode,
                              name: "#{air_loop.name} Clg Coil")
  end

  # minimum outdoor air schedule
  if min_oa_sch.nil?
    min_oa_sch = model.alwaysOnDiscreteSchedule
  else
    min_oa_sch = model_add_schedule(model, min_oa_sch)
  end

  # minimum outdoor air fraction schedule
  if min_frac_oa_sch.nil?
    min_frac_oa_sch = model.alwaysOnDiscreteSchedule
  else
    min_frac_oa_sch = model_add_schedule(model, min_frac_oa_sch)
  end

  # create controller outdoor air
  controller_oa = OpenStudio::Model::ControllerOutdoorAir.new(model)
  controller_oa.setName("#{air_loop.name} OA Controller")
  controller_oa.setEconomizerControlType(econo_ctrl_mthd)
  controller_oa.setMinimumLimitType('FixedMinimum')
  controller_oa.autosizeMinimumOutdoorAirFlowRate
  controller_oa.setMinimumOutdoorAirSchedule(min_oa_sch)
  controller_oa.setMinimumFractionofOutdoorAirSchedule(min_frac_oa_sch)
  controller_oa.resetEconomizerMaximumLimitDryBulbTemperature
  controller_oa.resetEconomizerMaximumLimitEnthalpy
  controller_oa.resetMaximumFractionofOutdoorAirSchedule
  controller_oa.resetEconomizerMinimumLimitDryBulbTemperature
  controller_oa.setHeatRecoveryBypassControlType('BypassWhenWithinEconomizerLimits')

  # create outdoor air system
  oa_system = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, controller_oa)
  oa_system.setName("#{air_loop.name} OA System")
  oa_system.addToNode(air_loop.supplyInletNode)

  # create a setpoint manager
  sat_oa_reset = OpenStudio::Model::SetpointManagerOutdoorAirReset.new(model)
  sat_oa_reset.setName("#{air_loop.name} SAT Reset")
  sat_oa_reset.setControlVariable('Temperature')
  sat_oa_reset.setSetpointatOutdoorLowTemperature(htg_dsgn_sup_air_temp_c)
  sat_oa_reset.setOutdoorLowTemperature(OpenStudio.convert(60.0, 'F', 'C').get)
  sat_oa_reset.setSetpointatOutdoorHighTemperature(clg_dsgn_sup_air_temp_c)
  sat_oa_reset.setOutdoorHighTemperature(OpenStudio.convert(70.0, 'F', 'C').get)
  sat_oa_reset.addToNode(air_loop.supplyOutletNode)

  # set air loop availability controls and night cycle manager, after oa system added
  air_loop.setAvailabilitySchedule(hvac_op_sch)
  air_loop.setNightCycleControlType('CycleOnAny')

  # add energy recovery if requested
  if energy_recovery
    # Get the OA system and its outboard OA node
    oa_system = air_loop.airLoopHVACOutdoorAirSystem.get

    # create the ERV and set its properties
    erv = OpenStudio::Model::HeatExchangerAirToAirSensibleAndLatent.new(model)
    erv.addToNode(oa_system.outboardOANode.get)
    erv.setHeatExchangerType('Rotary')
    # TODO: come up with scheme for estimating power of ERV motor wheel which might require knowing airflow.
    # erv.setNominalElectricPower(value_new)
    erv.setEconomizerLockout(true)
    erv.setSupplyAirOutletTemperatureControl(false)

    erv.setSensibleEffectivenessat100HeatingAirFlow(0.76)
    erv.setSensibleEffectivenessat75HeatingAirFlow(0.81)
    erv.setLatentEffectivenessat100HeatingAirFlow(0.68)
    erv.setLatentEffectivenessat75HeatingAirFlow(0.73)

    erv.setSensibleEffectivenessat100CoolingAirFlow(0.76)
    erv.setSensibleEffectivenessat75CoolingAirFlow(0.81)
    erv.setLatentEffectivenessat100CoolingAirFlow(0.68)
    erv.setLatentEffectivenessat75CoolingAirFlow(0.73)

    # increase fan static pressure to account for ERV
    erv_pressure_rise = OpenStudio.convert(1.0, 'inH_{2}O', 'Pa').get
    new_pressure_rise = supply_fan.pressureRise + erv_pressure_rise
    supply_fan.setPressureRise(new_pressure_rise)
  end

  # add thermal zones to airloop
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "---adding #{zone.name} to #{air_loop.name}")

    # make an air terminal for the zone
    air_terminal = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule)
    air_terminal.setName("#{zone.name} Air Terminal")

    # attach new terminal to the zone and to the airloop
    air_loop.multiAddBranchForZone(zone, air_terminal.to_HVACComponent.get)

    # DOAS sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setAccountforDedicatedOutdoorAirSystem(true)
    sizing_zone.setDedicatedOutdoorAirSystemControlStrategy('ColdSupplyAir')
    sizing_zone.setDedicatedOutdoorAirLowSetpointTemperatureforDesign(clg_dsgn_sup_air_temp_c)
    sizing_zone.setDedicatedOutdoorAirHighSetpointTemperatureforDesign(htg_dsgn_sup_air_temp_c)
  end

  return air_loop
end

#model_add_elevator(model, space, number_of_elevators, elevator_type, elevator_schedule, elevator_fan_schedule, elevator_lights_schedule, building_type = nil) ⇒ OpenStudio::Model::ElectricEquipment

Add an elevator the the specified space

to assign the elevators to. Traction, Hydraulic

Parameters:

  • space (OpenStudio::Model::Space)

    the space

  • number_of_elevators (Integer)

    the number of elevators

  • elevator_type (String)

    valid choices are

  • elevator_schedule (String)

    the name of the elevator schedule

  • elevator_fan_schedule (String)

    the name of the elevator fan schedule

  • elevator_lights_schedule (String)

    the name of the elevator lights schedule

  • building_type (String) (defaults to: nil)

    the building type

Returns:

  • (OpenStudio::Model::ElectricEquipment)

    the resulting elevator



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.elevators.rb', line 14

def model_add_elevator(model,
                       space,
                       number_of_elevators,
                       elevator_type,
                       elevator_schedule,
                       elevator_fan_schedule,
                       elevator_lights_schedule,
                       building_type = nil)

  # Lift motor assumptions
  lift_pwr_w = model_elevator_lift_power(model, elevator_type, building_type)

  # Size assumptions
  length_ft = 6.66
  width_ft = 4.25
  height_ft = 8.0
  area_ft2 = length_ft * width_ft
  volume_ft3 = area_ft2 * height_ft

  # Ventilation assumptions
  vent_rate_acm = 1 # air changes per minute
  vent_rate_cfm = volume_ft3 / vent_rate_acm
  vent_pwr_w = model_elevator_fan_pwr(model, vent_rate_cfm)

  # Heating fraction radiant assumptions
  elec_equip_frac_radiant = 0.5

  # Lighting assumptions
  design_ltg_lm_per_ft2 = 30
  light_loss_factor = 0.75
  pct_incandescent = model_elevator_lighting_pct_incandescent(model)
  pct_led = 1.0 - pct_incandescent

  incandescent_efficacy_lm_per_w = 10.0
  led_efficacy_lm_per_w = 35.0
  target_ltg_lm_per_ft2 = design_ltg_lm_per_ft2 / light_loss_factor # 40
  target_ltg_lm = target_ltg_lm_per_ft2 * area_ft2 # 1132.2
  lm_incandescent = target_ltg_lm * pct_incandescent # 792.54
  lm_led = target_ltg_lm * pct_led # 339.66
  w_incandescent = lm_incandescent / incandescent_efficacy_lm_per_w # 79.254
  w_led = lm_led / led_efficacy_lm_per_w # 9.7
  lighting_pwr_w = w_incandescent + w_led

  # Elevator lift motor
  elevator_definition = OpenStudio::Model::ElectricEquipmentDefinition.new(model)
  elevator_definition.setName('Elevator Lift Motor')
  elevator_definition.setDesignLevel(lift_pwr_w)
  elevator_definition.setFractionRadiant(elec_equip_frac_radiant)

  elevator_equipment = OpenStudio::Model::ElectricEquipment.new(elevator_definition)
  elevator_equipment.setName("#{number_of_elevators.round} Elevator Lift Motors")
  elevator_equipment.setEndUseSubcategory('Elevators')
  elevator_sch = model_add_schedule(model, elevator_schedule)
  elevator_equipment.setSchedule(elevator_sch)
  elevator_equipment.setSpace(space)
  elevator_equipment.setMultiplier(number_of_elevators)

  # Elevator fan
  elevator_fan_definition = OpenStudio::Model::ElectricEquipmentDefinition.new(model)
  elevator_fan_definition.setName('Elevator Fan')
  elevator_fan_definition.setDesignLevel(vent_pwr_w)
  elevator_fan_definition.setFractionRadiant(elec_equip_frac_radiant)

  elevator_fan_equipment = OpenStudio::Model::ElectricEquipment.new(elevator_fan_definition)
  elevator_fan_equipment.setName("#{number_of_elevators.round} Elevator Fans")
  elevator_fan_equipment.setEndUseSubcategory('Elevators')
  elevator_fan_sch = model_add_schedule(model, elevator_fan_schedule)
  elevator_fan_equipment.setSchedule(elevator_fan_sch)
  elevator_fan_equipment.setSpace(space)
  elevator_fan_equipment.setMultiplier(number_of_elevators)

  # Elevator lights
  elevator_lights_definition = OpenStudio::Model::ElectricEquipmentDefinition.new(model)
  elevator_lights_definition.setName('Elevator Lights')
  elevator_lights_definition.setDesignLevel(lighting_pwr_w)
  elevator_lights_definition.setFractionRadiant(elec_equip_frac_radiant)

  elevator_lights_equipment = OpenStudio::Model::ElectricEquipment.new(elevator_lights_definition)
  elevator_lights_equipment.setName("#{number_of_elevators.round} Elevator Lights")
  elevator_lights_equipment.setEndUseSubcategory('Elevators')
  elevator_lights_sch = model_add_schedule(model, elevator_lights_schedule)
  elevator_lights_equipment.setSchedule(elevator_lights_sch)
  elevator_lights_equipment.setSpace(space)
  elevator_lights_equipment.setMultiplier(number_of_elevators)

  return elevator_equipment
end

#model_add_elevators(model) ⇒ OpenStudio::Model::ElectricEquipment

Add elevators to the model based on the building size, number of stories, and building type. Logic was derived from the DOE prototype buildings.

Returns:

  • (OpenStudio::Model::ElectricEquipment)

    the resulting elevator



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.elevators.rb', line 146

def model_add_elevators(model)
  # determine effective number of stories
  effective_num_stories = model_effective_num_stories(model)

  # determine elevator type
  # todo - add logic here or upstream to have some multi-story buildings without elevators (e.g. small multi-family and small hotels)
  if effective_num_stories[:below_grade] + effective_num_stories[:above_grade] < 2
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', 'The building only has 1 story, no elevators will be added.')
    return nil # don't add elevators
  elsif effective_num_stories[:below_grade] + effective_num_stories[:above_grade] < 6
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', 'The building has fewer than 6 effective stories; assuming Hydraulic elevators.')
    elevator_type = 'Hydraulic'
  else
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', 'The building has 6 or more effective stories; assuming Traction elevators.')
    elevator_type = 'Traction'
  end

  # determine space to put elevator load in
  # largest bottom story (including basement) space that has multiplier of 1
  bottom_spaces = {}
  bottom_story = effective_num_stories[:story_hash].keys.first
  bottom_story.spaces.each do |space|
    next if space.multiplier > 1

    bottom_spaces[space] = space.floorArea
  end
  target_space = bottom_spaces.key(bottom_spaces.values.max)

  building_types = []

  # determine number of elevators
  number_of_pass_elevators = 0.0
  number_of_freight_elevators = 0.0
  building_type_hash = {}

  # apply building type specific log to add to number of elevators based on Beyer (2009) rules of thumb
  space_type_hash = model_create_space_type_hash(model)
  space_type_hash.each do |space_type, hash|
    # update building_type_hash
    if building_type_hash.key?(hash[:stds_bldg_type])
      building_type_hash[hash[:stds_bldg_type]] += hash[:floor_area]
    else
      building_type_hash[hash[:stds_bldg_type]] = hash[:floor_area]
    end

    building_type = hash[:stds_bldg_type]
    building_types << building_type

    # store floor area ip
    floor_area_ip = OpenStudio.convert(hash[:floor_area], 'm^2', 'ft^2').get

    # load elevator_data
    search_criteria = {
      'building_type' => building_type,
      'template' => template
    }
    elevator_data_lookup = model_find_object(standards_data['elevators'], search_criteria)
    if elevator_data_lookup.nil?
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.prototype.elevators', "Could not find elevator data for #{building_type}, elevator counts will not account for serving this portion of the building area.")
      next
    end

    # determine number of passenger elevators
    if !elevator_data_lookup['area_per_passenger_elevator'].nil?
      pass_elevs = floor_area_ip / elevator_data_lookup['area_per_passenger_elevator'].to_f
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "For #{space_type.name}, adding #{pass_elevs.round(1)} passenger elevators at 1 per #{elevator_data_lookup['area_per_passenger_elevator']} ft^2.")
    elsif !elevator_data_lookup['units_per_passenger_elevator'].nil?
      pass_elevs = hash[:num_units] / elevator_data_lookup['units_per_passenger_elevator'].to_f
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "For #{space_type.name}, adding #{pass_elevs.round(1)} passenger elevators at 1 per #{elevator_data_lookup['units_per_passenger_elevator']} units.")
    elsif !elevator_data_lookup['beds_per_passenger_elevator'].nil?
      pass_elevs = hash[:num_beds] / elevator_data_lookup['beds_per_passenger_elevator'].to_f
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "For #{space_type.name}, adding #{pass_elevs.round(1)} passenger elevators at 1 per #{elevator_data_lookup['beds_per_passenger_elevator']} beds.")
    else
      pass_elevs = 0.0
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "Unexpected key, can't calculate number of passenger elevators from #{elevator_data_lookup.keys.first}.")
    end

    # determine number of freight elevators
    if !elevator_data_lookup['area_per_freight_elevator'].nil?
      freight_elevs = floor_area_ip / elevator_data_lookup['area_per_freight_elevator'].to_f
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "For #{space_type.name}, adding #{freight_elevs.round(1)} freight/service elevators at 1 per #{elevator_data_lookup['area_per_freight_elevator']} ft^2.")
    elsif !elevator_data_lookup['units_per_freight_elevator'].nil?
      freight_elevs = hash[:num_units] / elevator_data_lookup['units_per_freight_elevator'].to_f
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "For #{space_type.name}, adding #{freight_elevs.round(1)} freight/service elevators at 1 per #{elevator_data_lookup['units_per_freight_elevator']} units.")
    elsif !elevator_data_lookup['beds_per_freight_elevator'].nil?
      freight_elevs = hash[:num_beds] / elevator_data_lookup['beds_per_freight_elevator'].to_f
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "For #{space_type.name}, adding #{freight_elevs.round(1)} freight/service elevators at 1 per #{elevator_data_lookup['beds_per_freight_elevator']} beds.")
    else
      freight_elevs = 0.0
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "Unexpected key, can't calculate number of freight elevators from #{elevator_data_lookup.keys.first}.")
    end
    number_of_pass_elevators += pass_elevs
    number_of_freight_elevators += freight_elevs
  end

  # additional passenger elevators (applicable for DOE LargeHotel and DOE Hospital only)
  add_pass_elevs = 0.0
  building_types.uniq.each do |building_type|
    # load elevator_data
    search_criteria = { 'building_type' => building_type }
    elevator_data_lookup = model_find_object(standards_data['elevators'], search_criteria)
    if elevator_data_lookup.nil?
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.prototype.elevators', "Could not find elevator data for #{building_type}.")
      next
    end

    # determine number of additional passenger elevators
    if !elevator_data_lookup['additional_passenger_elevators'].nil?
      add_pass_elevs += elevator_data_lookup['additional_passenger_elevators']
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "Adding #{elevator_data_lookup['additional_passenger_elevators']} additional passenger elevators.")
    else
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', 'No additional passenger elevators added to model.')
    end
  end

  # adjust number of elevators (can be double but if not 0 must be at least 1.0)
  if (number_of_pass_elevators > 0.0) && (number_of_pass_elevators < 1.0)
    number_of_pass_elevators = 1.0
  end
  if (number_of_freight_elevators > 0.0) && (number_of_freight_elevators < 1.0)
    number_of_freight_elevators = 1.0
  end

  # determine total number of elevators (rounding up to nearest whole number)
  number_of_pass_elevators = number_of_pass_elevators.ceil + add_pass_elevs
  number_of_freight_elevators = number_of_freight_elevators.ceil
  number_of_elevators = number_of_pass_elevators + number_of_freight_elevators

  building_type = building_type_hash.key(building_type_hash.values.max)

  # determine blended occupancy schedule
  occ_schedule = spaces_get_occupancy_schedule(model.getSpaces)

  # get total number of people in building
  max_occ_in_spaces = 0
  model.getSpaces.each do |space|
    # From the space type
    if space.spaceType.is_initialized
      space.spaceType.get.people.each do |people|
        num_ppl = people.getNumberOfPeople(space.floorArea)
        max_occ_in_spaces += num_ppl
      end
    end
    # From the space
    space.people.each do |people|
      num_ppl = people.getNumberOfPeople(space.floorArea)
      max_occ_in_spaces += num_ppl
    end
  end

  # make elevator schedule based on change in occupancy for each timestep
  day_schedules = []
  default_day_schedule = occ_schedule.defaultDaySchedule
  day_schedules << default_day_schedule
  occ_schedule.scheduleRules.each do |rule|
    day_schedules << rule.daySchedule
  end
  day_schedules.each do |day_schedule|
    elevator_hourly_fractions = []
    (0..23).each do |hr|
      t = OpenStudio::Time.new(0, hr, 0, 0)
      value = day_schedule.getValue(t)
      t_plus = OpenStudio::Time.new(0, hr + 1, 0, 0)
      value_plus = day_schedule.getValue(t_plus)
      change_occupancy_fraction = (value_plus - value).abs
      change_num_people = change_occupancy_fraction * max_occ_in_spaces * 1.2
      # multiplication factor or 1.2 to account for interfloor traffic

      # determine time per ride based on number of floors and elevator type
      if elevator_type == 'Hydraulic'
        time_per_ride = 8.7 + (effective_num_stories[:above_grade] * 5.6)
      elsif elevator_type == 'Traction'
        time_per_ride = 5.6 + (effective_num_stories[:above_grade] * 2.1)
      else
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.prototype.elevators', "Elevator type #{elevator_type} not recognized.")
        return nil
      end

      # determine elevator operation fraction for each timestep
      people_per_ride = 5
      rides_per_elevator = (change_num_people / people_per_ride) / number_of_elevators
      operation_time = rides_per_elevator * time_per_ride
      elevator_operation_fraction = operation_time / 3600
      if elevator_operation_fraction > 1.00
        elevator_operation_fraction = 1.00
      end
      elevator_hourly_fractions << elevator_operation_fraction
    end

    # replace hourly occupancy values with operating fractions
    day_schedule.clearValues
    (0..23).each do |hr|
      t = OpenStudio::Time.new(0, hr, 0, 0)
      value = elevator_hourly_fractions[hr]
      value_plus = if hr <= 22
                     elevator_hourly_fractions[hr + 1]
                   else
                     elevator_hourly_fractions[0]
                   end
      next if value == value_plus

      day_schedule.addValue(t, elevator_hourly_fractions[hr])
    end
  end

  occ_schedule.setName('Elevator Schedule')

  # clone new elevator schedule and assign to elevator
  elev_sch = occ_schedule.clone(model)
  elevator_schedule = elev_sch.name.to_s

  # For elevator lights and fan, assume 100% operation during hours that elevator fraction > 0 (when elevator is in operation).
  # elevator lights
  lights_sch = occ_schedule.clone(model)
  lights_sch = lights_sch.to_ScheduleRuleset.get
  profiles = []
  profiles << lights_sch.defaultDaySchedule
  rules = lights_sch.scheduleRules
  rules.each do |rule|
    profiles << rule.daySchedule
  end
  profiles.each do |profile|
    times = profile.times
    values = profile.values
    values.each_with_index do |val, i|
      if val > 0
        profile.addValue(times[i], 1.0)
      end
    end
  end
  elevator_lights_schedule = lights_sch.name.to_s

  # elevator fan
  fan_sch = occ_schedule.clone(model)
  fan_sch = fan_sch.to_ScheduleRuleset.get
  profiles = []
  profiles << fan_sch.defaultDaySchedule
  rules = fan_sch.scheduleRules
  rules.each do |rule|
    profiles << rule.daySchedule
  end
  profiles.each do |profile|
    times = profile.times
    values = profile.values
    values.each_with_index do |val, i|
      if val > 0
        profile.addValue(times[i], 1.0)
      end
    end
  end
  elevator_fan_schedule = fan_sch.name.to_s

  # TODO: - currently add elevator doesn't allow me to choose the size of the elevator?
  # ref bldg pdf has formula for motor hp based on weight, speed, counterweight fraction and mech eff (in 5.1.4)

  # TODO: - should schedules change based on traction vs. hydraulic vs. just taking what is in prototype.

  # call add_elevator in Prototype.hvac_systems.rb to create elevator objects
  elevator = model_add_elevator(model,
                                target_space,
                                number_of_elevators,
                                elevator_type,
                                elevator_schedule,
                                elevator_fan_schedule,
                                elevator_lights_schedule,
                                building_type)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "Adding #{elevator.multiplier.round(1)} #{elevator_type} elevators to the model in #{target_space.name}.")

  # check fraction lost on heat from elevator if traction, change to 100% lost if not setup that way.
  if elevator_type == 'Traction'
    elevator.definition.to_ElectricEquipmentDefinition.get.setFractionLatent(0.0)
    elevator.definition.to_ElectricEquipmentDefinition.get.setFractionRadiant(0.0)
    elevator.definition.to_ElectricEquipmentDefinition.get.setFractionLost(1.0)
  end

  return elevator
end

#model_add_evap_cooler(model, thermal_zones) ⇒ Array<OpenStudio::Model::AirLoopHVAC>

Creates an evaporative cooler for each zone and adds it to the model.

Parameters:

Returns:



4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4048

def model_add_evap_cooler(model,
                          thermal_zones)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding evaporative coolers for #{thermal_zones.size} zones.")
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "---#{zone.name}")
  end

  # default design temperatures used across all air loops
  dsgn_temps = standard_design_sizing_temperatures

  # adjusted design temperatures for evap cooler
  dsgn_temps['clg_dsgn_sup_air_temp_f'] = 70.0
  dsgn_temps['clg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['clg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['max_clg_dsgn_sup_air_temp_f'] = 78.0
  dsgn_temps['max_clg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['max_clg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['approach_r'] = 3.0 # wetbulb approach temperature
  dsgn_temps['approach_k'] = OpenStudio.convert(dsgn_temps['approach_r'], 'R', 'K').get

  # EMS programs
  programs = []

  # Make an evap cooler for each zone
  evap_coolers = []
  thermal_zones.each do |zone|
    zone_name_clean = zone.name.get.delete(':')

    # Air loop
    air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
    air_loop.setName("#{zone_name_clean} Evaporative Cooler")

    # default design settings used across all air loops
    sizing_system = adjust_sizing_system(air_loop, dsgn_temps)

    # air handler controls
    # setpoint follows OAT WetBulb
    evap_stpt_manager = OpenStudio::Model::SetpointManagerFollowOutdoorAirTemperature.new(model)
    evap_stpt_manager.setName("#{dsgn_temps['approach_r']} F above OATwb")
    evap_stpt_manager.setReferenceTemperatureType('OutdoorAirWetBulb')
    evap_stpt_manager.setMaximumSetpointTemperature(dsgn_temps['max_clg_dsgn_sup_air_temp_c'])
    evap_stpt_manager.setMinimumSetpointTemperature(dsgn_temps['clg_dsgn_sup_air_temp_c'])
    evap_stpt_manager.setOffsetTemperatureDifference(dsgn_temps['approach_k'])
    evap_stpt_manager.addToNode(air_loop.supplyOutletNode)

    # Schedule to control the airloop availability
    air_loop_avail_sch = OpenStudio::Model::ScheduleConstant.new(model)
    air_loop_avail_sch.setName("#{air_loop.name} Availability Sch")
    air_loop_avail_sch.setValue(1)
    air_loop.setAvailabilitySchedule(air_loop_avail_sch)

    # EMS to turn on Evap Cooler if there is a cooling load in the target zone.
    # Without this EMS, the airloop runs 24/7-365 even when there is no load in the zone.

    # Create a sensor to read the zone load
    zn_load_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model,
                                                                         'Zone Predicted Sensible Load to Cooling Setpoint Heat Transfer Rate')
    zn_load_sensor.setName("#{zone_name_clean.to_s.gsub(/[ +-.]/, '_')} Clg Load Sensor")
    zn_load_sensor.setKeyName(zone.handle.to_s)

    # Create an actuator to set the airloop availability
    air_loop_avail_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(air_loop_avail_sch,
                                                                                    'Schedule:Constant',
                                                                                    'Schedule Value')
    air_loop_avail_actuator.setName("#{air_loop.name.to_s.gsub(/[ +-.]/, '_')} Availability Actuator")

    # Create a program to turn on Evap Cooler if
    # there is a cooling load in the target zone.
    # Load < 0.0 is a cooling load.
    avail_program = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
    avail_program.setName("#{air_loop.name.to_s.gsub(/[ +-.]/, '_')} Availability Control")
    avail_program_body = <<-EMS
      IF #{zn_load_sensor.handle} < 0.0
        SET #{air_loop_avail_actuator.handle} = 1
      ELSE
        SET #{air_loop_avail_actuator.handle} = 0
      ENDIF
    EMS
    avail_program.setBody(avail_program_body)

    programs << avail_program

    # Direct Evap Cooler
    # TODO: better assumptions for evap cooler performance and fan pressure rise
    evap = OpenStudio::Model::EvaporativeCoolerDirectResearchSpecial.new(model, model.alwaysOnDiscreteSchedule)
    evap.setName("#{zone.name} Evap Media")
    evap.autosizePrimaryAirDesignFlowRate
    evap.addToNode(air_loop.supplyInletNode)

    # Fan (cycling), must be inside unitary system to cycle on airloop
    fan = create_fan_by_name(model,
                             'Evap_Cooler_Supply_Fan',
                             fan_name: "#{zone.name} Evap Cooler Supply Fan")
    fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)

    # Dummy zero-capacity cooling coil
    clg_coil = create_coil_cooling_dx_single_speed(model,
                                                   name: 'Dummy Always Off DX Coil',
                                                   schedule: model.alwaysOffDiscreteSchedule)
    unitary_system = OpenStudio::Model::AirLoopHVACUnitarySystem.new(model)
    unitary_system.setName("#{zone.name} Evap Cooler Cycling Fan")
    unitary_system.setSupplyFan(fan)
    unitary_system.setCoolingCoil(clg_coil)
    unitary_system.setControllingZoneorThermostatLocation(zone)
    unitary_system.setMaximumSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    unitary_system.setFanPlacement('BlowThrough')
    unitary_system.setSupplyAirFlowRateMethodDuringCoolingOperation('SupplyAirFlowRate')
    unitary_system.setSupplyAirFlowRateMethodDuringHeatingOperation('SupplyAirFlowRate')
    unitary_system.setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired('SupplyAirFlowRate')
    unitary_system.setSupplyAirFanOperatingModeSchedule(model.alwaysOffDiscreteSchedule)
    unitary_system.addToNode(air_loop.supplyInletNode)

    # Outdoor air intake system
    oa_intake_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
    oa_intake_controller.setName("#{air_loop.name} OA Controller")
    oa_intake_controller.setMinimumLimitType('FixedMinimum')
    oa_intake_controller.autosizeMinimumOutdoorAirFlowRate
    oa_intake_controller.resetEconomizerMinimumLimitDryBulbTemperature
    oa_intake_controller.setMinimumFractionofOutdoorAirSchedule(model.alwaysOnDiscreteSchedule)
    controller_mv = oa_intake_controller.controllerMechanicalVentilation
    controller_mv.setName("#{air_loop.name} Vent Controller")
    controller_mv.setSystemOutdoorAirMethod('ZoneSum')

    oa_intake = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
    oa_intake.setName("#{air_loop.name} OA System")
    oa_intake.addToNode(air_loop.supplyInletNode)

    # make an air terminal for the zone
    air_terminal = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule)
    air_terminal.setName("#{zone.name} Air Terminal")

    # attach new terminal to the zone and to the airloop
    air_loop.multiAddBranchForZone(zone, air_terminal.to_HVACComponent.get)

    sizing_zone = zone.sizingZone
    sizing_zone.setCoolingDesignAirFlowMethod('DesignDay')
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])

    evap_coolers << air_loop
  end

  # Create a programcallingmanager
  avail_pcm = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)
  avail_pcm.setName('EvapCoolerAvailabilityProgramCallingManager')
  avail_pcm.setCallingPoint('AfterPredictorAfterHVACManagers')
  programs.each do |program|
    avail_pcm.addProgram(program)
  end

  return evap_coolers
end

#model_add_exhaust_fan(model, thermal_zones, flow_rate: nil, availability_sch_name: nil, flow_fraction_schedule_name: nil, balanced_exhaust_fraction_schedule_name: nil) ⇒ Array<OpenStudio::Model::FanZoneExhaust>

Adds an exhaust fan to each zone.

@todo: use the create_fan_zone_exhaust method, default to 1.25 inH2O pressure rise and fan efficiency of 0.6

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    an array of thermal zones

  • flow_rate (Double) (defaults to: nil)

    the exhaust fan flow rate in m^3/s

  • availability_sch_name (String) (defaults to: nil)

    the name of the fan availability schedule

  • flow_fraction_schedule_name (String) (defaults to: nil)

    the name of the flow fraction schedule

  • balanced_exhaust_fraction_schedule_name (String) (defaults to: nil)

    the name of the balanced exhaust fraction schedule

Returns:

  • (Array<OpenStudio::Model::FanZoneExhaust>)

    an array of exhaust fans created



5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5363

def model_add_exhaust_fan(model,
                          thermal_zones,
                          flow_rate: nil,
                          availability_sch_name: nil,
                          flow_fraction_schedule_name: nil,
                          balanced_exhaust_fraction_schedule_name: nil)

  if availability_sch_name.nil?
    availability_schedule = model.alwaysOnDiscreteSchedule
  else
    availability_schedule = model_add_schedule(model, availability_sch_name)
  end

  # make an exhaust fan for each zone
  fans = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding zone exhaust fan for #{zone.name}.")
    fan = OpenStudio::Model::FanZoneExhaust.new(model)
    fan.setName("#{zone.name} Exhaust Fan")
    fan.setAvailabilitySchedule(availability_schedule)

    # input the flow rate as a number (assign directly) or from an array (assign each flow rate to each zone)
    if flow_rate.is_a? Numeric
      fan.setMaximumFlowRate(flow_rate)
    elsif flow_rate.class.to_s == 'Array'
      index = thermal_zones.index(zone)
      flow_rate_zone = flow_rate[index]
      fan.setMaximumFlowRate(flow_rate_zone)
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', 'Wrong format of flow rate')
    end

    unless flow_fraction_schedule_name.nil?
      fan.setFlowFractionSchedule(model_add_schedule(model, flow_fraction_schedule_name))
    end

    fan.setSystemAvailabilityManagerCouplingMode('Decoupled')
    unless balanced_exhaust_fraction_schedule_name.nil?
      fan.setBalancedExhaustFractionSchedule(model_add_schedule(model, balanced_exhaust_fraction_schedule_name))
    end

    fan.addToThermalZone(zone)
    fans << fan
  end

  return fans
end

#model_add_four_pipe_fan_coil(model, thermal_zones, chilled_water_loop, hot_water_loop: nil, ventilation: false, capacity_control_method: 'CyclingFan') ⇒ Array<OpenStudio::Model::ZoneHVACFourPipeFanCoil>

Adds four pipe fan coil units to each zone.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to add fan coil units

  • chilled_water_loop (OpenStudio::Model::PlantLoop)

    the chilled water loop that serves the fan coils.

  • hot_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    the hot water loop that serves the fan coils. If nil, a zero-capacity, electric heating coil set to Always-Off will be included in the unit.

  • ventilation (Bool) (defaults to: false)

    If true, ventilation will be supplied through the unit. If false, no ventilation will be supplied through the unit, with the expectation that it will be provided by a DOAS or separate system.

  • capacity_control_method (String) (defaults to: 'CyclingFan')

    Capacity control method for the fan coil. Options are ConstantFanVariableFlow, CyclingFan, VariableFanVariableFlow, and VariableFanConstantFlow. If VariableFan, the fan will be VariableVolume.

Returns:



4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4300

def model_add_four_pipe_fan_coil(model,
                                 thermal_zones,
                                 chilled_water_loop,
                                 hot_water_loop: nil,
                                 ventilation: false,
                                 capacity_control_method: 'CyclingFan')

  # default design temperatures used across all air loops
  dsgn_temps = standard_design_sizing_temperatures

  # make a fan coil unit for each zone
  fcus = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding fan coil for #{zone.name}.")
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])

    if chilled_water_loop
      fcu_clg_coil = create_coil_cooling_water(model,
                                               chilled_water_loop,
                                               name: "#{zone.name} FCU Cooling Coil")
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', 'Fan coil units require a chilled water loop, but none was provided.')
      return false
    end

    if hot_water_loop
      fcu_htg_coil = create_coil_heating_water(model,
                                               hot_water_loop,
                                               name: "#{zone.name} FCU Heating Coil",
                                               rated_outlet_air_temperature: dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    else
      # Zero-capacity, always-off electric heating coil
      fcu_htg_coil = create_coil_heating_electric(model,
                                                  name: "#{zone.name} No Heat",
                                                  schedule: model.alwaysOffDiscreteSchedule,
                                                  nominal_capacity: 0.0)
    end

    case capacity_control_method
    when 'VariableFanVariableFlow', 'VariableFanConstantFlow'
      fcu_fan = create_fan_by_name(model,
                                   'Fan_Coil_VarSpeed_Fan',
                                   fan_name: "#{zone.name} Fan Coil Variable Fan",
                                   end_use_subcategory: 'FCU Fans')
    else
      fcu_fan = create_fan_by_name(model,
                                   'Fan_Coil_Fan',
                                   fan_name: "#{zone.name} Fan Coil fan",
                                   end_use_subcategory: 'FCU Fans')
    end
    fcu_fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
    fcu_fan.autosizeMaximumFlowRate

    fcu = OpenStudio::Model::ZoneHVACFourPipeFanCoil.new(model,
                                                         model.alwaysOnDiscreteSchedule,
                                                         fcu_fan,
                                                         fcu_clg_coil,
                                                         fcu_htg_coil)
    fcu.setName("#{zone.name} FCU")
    fcu.setCapacityControlMethod(capacity_control_method)
    fcu.autosizeMaximumSupplyAirFlowRate
    unless ventilation
      fcu.setMaximumOutdoorAirFlowRate(0.0)
    end
    fcu.addToThermalZone(zone)
    fcus << fcu
  end

  return fcus
end

#model_add_furnace_central_ac(model, thermal_zones, heating: true, cooling: false, ventilation: false) ⇒ Array<OpenStudio::Model::AirLoopHVAC>

Adds a forced air furnace or central AC to each zone. Default is a forced air furnace without outdoor air Code adapted from: github.com/NREL/OpenStudio-BEopt/blob/master/measures/ResidentialHVACFurnaceFuel/measure.rb

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to add fan coil units to.

  • heating (Bool) (defaults to: true)

    if true, the unit will include a NaturalGas heating coil

  • cooling (Bool) (defaults to: false)

    if true, the unit will include a DX cooling coil

  • ventilation (Bool) (defaults to: false)

    if true, the unit will include an OA intake

Returns:



4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4787

def model_add_furnace_central_ac(model,
                                 thermal_zones,
                                 heating: true,
                                 cooling: false,
                                 ventilation: false)

  if heating && cooling
    equip_name = 'Central Heating and AC'
  elsif heating && !cooling
    equip_name = 'Furnace'
  elsif cooling && !heating
    equip_name = 'Central AC'
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', 'Heating and cooling both disabled, not a valid Furnace or Central AC selection, no equipment was added.')
    return false
  end

  # defaults
  afue = 0.78
  # seer = 13.0
  eer = 11.1
  shr = 0.73
  ac_w_per_cfm = 0.365
  crank_case_heat_w = 0.0
  crank_case_max_temp_f = 55.0

  furnaces = []
  thermal_zones.each do |zone|
    air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
    air_loop.setName("#{zone.name} #{equip_name}")
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding furnace AC for #{zone.name}.")

    # default design temperatures across all air loops
    dsgn_temps = standard_design_sizing_temperatures

    # adjusted temperatures for furnace_central_ac
    dsgn_temps['zn_htg_dsgn_sup_air_temp_f'] = 122.0
    dsgn_temps['zn_htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_htg_dsgn_sup_air_temp_f'], 'F', 'C').get
    dsgn_temps['htg_dsgn_sup_air_temp_f'] = dsgn_temps['zn_htg_dsgn_sup_air_temp_f']
    dsgn_temps['htg_dsgn_sup_air_temp_c'] = dsgn_temps['zn_htg_dsgn_sup_air_temp_c']

    # default design settings used across all air loops
    sizing_system = adjust_sizing_system(air_loop, dsgn_temps, sizing_option: 'NonCoincident')
    sizing_system.setAllOutdoorAirinCooling(true)
    sizing_system.setAllOutdoorAirinHeating(true)

    # create heating coil
    htg_coil = nil
    if heating
      htg_coil = create_coil_heating_gas(model,
                                         name: "#{air_loop.name} Heating Coil",
                                         efficiency: afue_to_thermal_eff(afue))
    end

    # create cooling coil
    clg_coil = nil
    if cooling
      clg_coil = create_coil_cooling_dx_single_speed(model,
                                                     name: "#{air_loop.name} Cooling Coil",
                                                     type: 'Residential Central AC')
      clg_coil.setRatedSensibleHeatRatio(shr)
      clg_coil.setRatedCOP(OpenStudio::OptionalDouble.new(eer_to_cop(eer)))
      clg_coil.setRatedEvaporatorFanPowerPerVolumeFlowRate(OpenStudio::OptionalDouble.new(ac_w_per_cfm / OpenStudio.convert(1.0, 'cfm', 'm^3/s').get))
      clg_coil.setNominalTimeForCondensateRemovalToBegin(OpenStudio::OptionalDouble.new(1000.0))
      clg_coil.setRatioOfInitialMoistureEvaporationRateAndSteadyStateLatentCapacity(OpenStudio::OptionalDouble.new(1.5))
      clg_coil.setMaximumCyclingRate(OpenStudio::OptionalDouble.new(3.0))
      clg_coil.setLatentCapacityTimeConstant(OpenStudio::OptionalDouble.new(45.0))
      clg_coil.setCondenserType('AirCooled')
      clg_coil.setCrankcaseHeaterCapacity(OpenStudio::OptionalDouble.new(crank_case_heat_w))
      clg_coil.setMaximumOutdoorDryBulbTemperatureForCrankcaseHeaterOperation(OpenStudio::OptionalDouble.new(OpenStudio.convert(crank_case_max_temp_f, 'F', 'C').get))
    end

    # create fan
    fan = create_fan_by_name(model,
                             'Residential_HVAC_Fan',
                             fan_name: "#{air_loop.name} Supply Fan",
                             end_use_subcategory: 'Residential HVAC Fans')
    fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)

    if ventilation
      # create outdoor air intake
      oa_intake_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
      oa_intake_controller.setName("#{air_loop.name} OA Controller")
      oa_intake_controller.autosizeMinimumOutdoorAirFlowRate
      oa_intake_controller.resetEconomizerMinimumLimitDryBulbTemperature
      oa_intake = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
      oa_intake.setName("#{air_loop.name} OA System")
      oa_intake.addToNode(air_loop.supplyInletNode)
    end

    # create unitary system (holds the coils and fan)
    unitary = OpenStudio::Model::AirLoopHVACUnitarySystem.new(model)
    unitary.setName("#{air_loop.name} Unitary System")
    unitary.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
    unitary.setMaximumSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    unitary.setControllingZoneorThermostatLocation(zone)
    unitary.addToNode(air_loop.supplyInletNode)

    # set flow rates during different conditions
    unitary.setSupplyAirFlowRateDuringHeatingOperation(0.0) unless heating
    unitary.setSupplyAirFlowRateDuringCoolingOperation(0.0) unless cooling
    unitary.setSupplyAirFlowRateWhenNoCoolingorHeatingisRequired(0.0) unless ventilation

    # attach the coils and fan
    unitary.setHeatingCoil(htg_coil) if htg_coil
    unitary.setCoolingCoil(clg_coil) if clg_coil
    unitary.setSupplyFan(fan)
    unitary.setFanPlacement('BlowThrough')
    unitary.setSupplyAirFanOperatingModeSchedule(model.alwaysOffDiscreteSchedule)

    # create a diffuser
    diffuser = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule)
    diffuser.setName("#{zone.name} Direct Air")
    air_loop.multiAddBranchForZone(zone, diffuser.to_HVACComponent.get)

    furnaces << air_loop
  end

  return furnaces
end

#model_add_ground_hx_loop(model, system_name: 'Ground HX Loop') ⇒ OpenStudio::Model::PlantLoop

Creates loop that roughly mimics a properly sized ground heat exchanger for supplemental heating/cooling and adds it to the model.

TODO: replace condenser loop w/ ground HX model that does not involve district objects

Parameters:

  • system_name (String) (defaults to: 'Ground HX Loop')

    the name of the system, or nil in which case it will be defaulted

Returns:



846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 846

def model_add_ground_hx_loop(model,
                             system_name: 'Ground HX Loop')
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding ground source loop.')

  # create ground hx loop
  ground_hx_loop = OpenStudio::Model::PlantLoop.new(model)
  if system_name.nil?
    ground_hx_loop.setName('Ground HX Loop')
  else
    ground_hx_loop.setName(system_name)
  end

  # ground hx loop sizing and controls
  ground_hx_loop.setMinimumLoopTemperature(5.0)
  ground_hx_loop.setMaximumLoopTemperature(80.0)
  delta_t_k = OpenStudio.convert(12.0, 'R', 'K').get # temp change at high and low entering condition
  min_inlet_c = OpenStudio.convert(30.0, 'F', 'C').get # low entering condition.
  max_inlet_c = OpenStudio.convert(90.0, 'F', 'C').get # high entering condition

  # calculate the linear formula that defines outlet temperature based on inlet temperature of the ground hx
  min_outlet_c = min_inlet_c + delta_t_k
  max_outlet_c = max_inlet_c - delta_t_k
  slope_c_per_c = (max_outlet_c - min_outlet_c) / (max_inlet_c - min_inlet_c)
  intercept_c = min_outlet_c - (slope_c_per_c * min_inlet_c)

  sizing_plant = ground_hx_loop.sizingPlant
  sizing_plant.setLoopType('Heating')
  sizing_plant.setDesignLoopExitTemperature(max_outlet_c)
  sizing_plant.setLoopDesignTemperatureDifference(delta_t_k)

  # create pump
  pump = OpenStudio::Model::PumpConstantSpeed.new(model)
  pump.setName("#{ground_hx_loop.name} Pump")
  pump.setRatedPumpHead(OpenStudio.convert(60.0, 'ftH_{2}O', 'Pa').get)
  pump.setPumpControlType('Intermittent')
  pump.addToNode(ground_hx_loop.supplyInletNode)

  # use EMS and a PlantComponentTemperatureSource to mimic the operation of the ground heat exchanger.

  # schedule to actuate ground HX outlet temperature
  hx_temp_sch = OpenStudio::Model::ScheduleConstant.new(model)
  hx_temp_sch.setName('Ground HX Temp Sch')
  hx_temp_sch.setValue(24.0)

  ground_hx = OpenStudio::Model::PlantComponentTemperatureSource.new(model)
  ground_hx.setName('Ground HX')
  ground_hx.setTemperatureSpecificationType('Scheduled')
  ground_hx.setSourceTemperatureSchedule(hx_temp_sch)
  ground_hx_loop.addSupplyBranchForComponent(ground_hx)

  hx_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, hx_temp_sch)
  hx_stpt_manager.setName("#{ground_hx.name} Supply Outlet Setpoint")
  hx_stpt_manager.addToNode(ground_hx.outletModelObject.get.to_Node.get)

  loop_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, hx_temp_sch)
  loop_stpt_manager.setName("#{ground_hx_loop.name} Supply Outlet Setpoint")
  loop_stpt_manager.addToNode(ground_hx_loop.supplyOutletNode)

  # sensor to read supply inlet temperature
  inlet_temp_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model,
                                                                          'System Node Temperature')
  inlet_temp_sensor.setName("#{ground_hx.name.to_s.gsub(/[ +-.]/, '_')} Inlet Temp Sensor")
  inlet_temp_sensor.setKeyName(ground_hx_loop.supplyInletNode.handle.to_s)

  # actuator to set supply outlet temperature
  outlet_temp_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(hx_temp_sch,
                                                                               'Schedule:Constant',
                                                                               'Schedule Value')
  outlet_temp_actuator.setName("#{ground_hx.name} Outlet Temp Actuator")

  # program to control outlet temperature
  # adjusts delta-t based on calculation of slope and intercept from control temperatures
  program = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  program.setName("#{ground_hx.name.to_s.gsub(/[ +-.]/, '_')} Temperature Control")
  program_body = <<-EMS
    SET Tin = #{inlet_temp_sensor.handle}
    SET Tout = #{slope_c_per_c.round(2)} * Tin + #{intercept_c.round(1)}
    SET #{outlet_temp_actuator.handle} = Tout
  EMS
  program.setBody(program_body)

  # program calling manager
  pcm = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)
  pcm.setName("#{program.name.to_s.gsub(/[ +-.]/, '_')} Calling Manager")
  pcm.setCallingPoint('InsideHVACSystemIterationLoop')
  pcm.addProgram(program)

  return ground_hx_loop
end

#model_add_ground_temperatures(model, building_type, climate_zone) ⇒ Object



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 186

def model_add_ground_temperatures(model, building_type, climate_zone)
  # Define the weather file for each climate zone
  climate_zone_weather_file_map = model_get_climate_zone_weather_file_map

  # Get the weather file name from the hash
  weather_file_name = climate_zone_weather_file_map[climate_zone]
  if weather_file_name.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.weather.Model', "Could not determine the weather file for climate zone: #{climate_zone}, cannot get ground temperatures from stat file.")
  end

  # Define where the weather files lives
  weather_dir = nil
  if __dir__[0] == ':' # Running from OpenStudio CLI
    # load stat file from embedded files
    stat_string = load_resource_relative("../../../data/weather/#{weather_file_name.gsub('.epw', '.stat')}")

    # extract to local weather dir
    weather_dir = File.expand_path(File.join(Dir.pwd, 'extracted_files/weather/'))
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.weather.Model', "Extracting stat file from OpenStudio CLI to #{weather_dir}")
    FileUtils.mkdir_p(weather_dir)
    File.open("#{weather_dir}/#{weather_file_name.gsub('.epw', '.stat')}", 'wb') { |f| f << stat_string; f.flush }
  else
    # loaded gem from system path
    top_dir = File.expand_path('../../..', File.dirname(__FILE__))
    weather_dir = File.expand_path("#{top_dir}/data/weather")
  end

  # Expand the weather directory path
  unless (Pathname.new weather_dir).absolute?
    weather_dir = File.expand_path(File.join(File.dirname(__FILE__), weather_dir))
  end

  # Get the path to the stat file
  weather_file = File.join(weather_dir, weather_file_name)

  # Add ground temperatures via parsing of STAT file.
  ground_temperatures = []
  stat_file_path = "#{File.join(File.dirname(weather_file), File.basename(weather_file, '.*'))}.stat"
  if File.exist? stat_file_path
    ground_temperatures = model_get_monthly_ground_temps_from_stat_file(stat_file_path)
    unless ground_temperatures.empty?
      # set the site ground temperature building surface
      ground_temp = model.getSiteGroundTemperatureFCfactorMethod
      ground_temp.setAllMonthlyTemperatures(ground_temperatures)
    end
  end

  # Return if ground temperatures were found
  return unless ground_temperatures.empty?

  # If stat_file_path did not turn up an EPW file, set default ground temperatures
  OpenStudio.logFree(OpenStudio::Warn, 'openstudio.weather.Model', 'Could not find ground temperatures in stat file; will use standards lookup.')

  # Look up ground temperatures from templates
  ground_temp_vals = standards_lookup_table_first(table_name: 'ground_temperatures', search_criteria: { 'template' => template, 'climate_zone' => climate_zone, 'building_type' => building_type })
  if ground_temp_vals && ground_temp_vals['jan']
    ground_temp = model.getSiteGroundTemperatureBuildingSurface
    ground_temp.setJanuaryGroundTemperature(ground_temp_vals['jan'])
    ground_temp.setFebruaryGroundTemperature(ground_temp_vals['feb'])
    ground_temp.setMarchGroundTemperature(ground_temp_vals['mar'])
    ground_temp.setAprilGroundTemperature(ground_temp_vals['apr'])
    ground_temp.setMayGroundTemperature(ground_temp_vals['may'])
    ground_temp.setJuneGroundTemperature(ground_temp_vals['jun'])
    ground_temp.setJulyGroundTemperature(ground_temp_vals['jul'])
    ground_temp.setAugustGroundTemperature(ground_temp_vals['aug'])
    ground_temp.setSeptemberGroundTemperature(ground_temp_vals['sep'])
    ground_temp.setOctoberGroundTemperature(ground_temp_vals['oct'])
    ground_temp.setNovemberGroundTemperature(ground_temp_vals['nov'])
    ground_temp.setDecemberGroundTemperature(ground_temp_vals['dec'])
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.weather.Model', 'Could not find ground temperatures in standards lookup; will use generic temperatures, which will skew results.')
    ground_temp = model.getSiteGroundTemperatureBuildingSurface
    ground_temp.setJanuaryGroundTemperature(19.527)
    ground_temp.setFebruaryGroundTemperature(19.502)
    ground_temp.setMarchGroundTemperature(19.536)
    ground_temp.setAprilGroundTemperature(19.598)
    ground_temp.setMayGroundTemperature(20.002)
    ground_temp.setJuneGroundTemperature(21.640)
    ground_temp.setJulyGroundTemperature(22.225)
    ground_temp.setAugustGroundTemperature(22.375)
    ground_temp.setSeptemberGroundTemperature(21.449)
    ground_temp.setOctoberGroundTemperature(20.121)
    ground_temp.setNovemberGroundTemperature(19.802)
    ground_temp.setDecemberGroundTemperature(19.633)
  end
end

#model_add_heatpump_water_heater(model, type: 'PumpedCondenser', water_heater_capacity: 500, electric_backup_capacity: 4500, water_heater_volume: OpenStudio.convert(80.0, 'gal', 'm^3').get, service_water_temperature: OpenStudio.convert(125.0, 'F', 'C').get, parasitic_fuel_consumption_rate: 3.0, swh_temp_sch: nil, cop: 2.8, shr: 0.88, tank_ua: 3.9, set_peak_use_flowrate: false, peak_flowrate: 0.0, flowrate_schedule: nil, water_heater_thermal_zone: nil) ⇒ OpenStudio::Model::WaterHeaterMixed

Creates a heatpump water heater and attaches it to the supplied service water heating loop.

Parameters:

  • water_heater_capacity (Double) (defaults to: 500)

    water heater capacity, in W

  • water_heater_volume (Double) (defaults to: OpenStudio.convert(80.0, 'gal', 'm^3').get)

    water heater volume, in m^3

  • service_water_temperature (Double) (defaults to: OpenStudio.convert(125.0, 'F', 'C').get)

    water heater temperature, in C

  • parasitic_fuel_consumption_rate (Double) (defaults to: 3.0)

    water heater parasitic fuel consumption rate, in W

  • swh_temp_sch (OpenStudio::Model::Schedule) (defaults to: nil)

    the service water heating schedule. If nil, will be defaulted.

  • set_peak_use_flowrate (Bool) (defaults to: false)

    if true, the peak flow rate and flow rate schedule will be set.

  • peak_flowrate (Double) (defaults to: 0.0)

    in m^3/s

  • flowrate_schedule (String) (defaults to: nil)

    name of the flow rate schedule

  • water_heater_thermal_zone (OpenStudio::Model::ThermalZone) (defaults to: nil)

    zone to place water heater in. If nil, will be assumed in 70F air for heat loss.

Returns:



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.ServiceWaterHeating.rb', line 318

def model_add_heatpump_water_heater(model,
                                    type: 'PumpedCondenser',
                                    water_heater_capacity: 500,
                                    electric_backup_capacity: 4500,
                                    water_heater_volume: OpenStudio.convert(80.0, 'gal', 'm^3').get,
                                    service_water_temperature: OpenStudio.convert(125.0, 'F', 'C').get,
                                    parasitic_fuel_consumption_rate: 3.0,
                                    swh_temp_sch: nil,
                                    cop: 2.8,
                                    shr: 0.88,
                                    tank_ua: 3.9,
                                    set_peak_use_flowrate: false,
                                    peak_flowrate: 0.0,
                                    flowrate_schedule: nil,
                                    water_heater_thermal_zone: nil)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding heat pump water heater')

  # create heat pump water heater
  if type == 'WrappedCondenser'
    hpwh = OpenStudio::Model::WaterHeaterHeatPumpWrappedCondenser.new(model)
  elsif type == 'PumpedCondenser'
    hpwh = OpenStudio::Model::WaterHeaterHeatPump.new(model)
  end

  # calculate tank height and radius
  water_heater_capacity_kbtu_per_hr = OpenStudio.convert(water_heater_capacity, 'W', 'kBtu/hr').get
  hpwh_vol_gal = OpenStudio.convert(water_heater_volume, 'm^3', 'gal').get
  tank_height = 0.0188 * hpwh_vol_gal + 0.0935 # linear relationship that gets GE height at 50 gal and AO Smith height at 80 gal
  tank_radius = (0.9 * water_heater_volume / (Math::PI * tank_height))**0.5
  tank_surface_area = 2.0 * Math::PI * tank_radius * (tank_radius + tank_height)
  u_tank = (5.678 * tank_ua) / OpenStudio.convert(tank_surface_area, 'm^2', 'ft^2').get
  hpwh.setName("#{hpwh_vol_gal.round}gal Heat Pump Water Heater - #{water_heater_capacity_kbtu_per_hr.round(0)}kBtu/hr")

  if type == 'WrappedCondenser'
    hpwh.setMinimumInletAirTemperatureforCompressorOperation(OpenStudio.convert(45.0, 'F', 'C').get)
    hpwh.setMaximumInletAirTemperatureforCompressorOperation(OpenStudio.convert(120.0, 'F', 'C').get)
    # set sensor heights
    if hpwh_vol_gal <= 50.0
      hpwh.setDeadBandTemperatureDifference(0.5)
      h_ue = (1 - (3.5 / 12.0)) * tank_height # in the 4th node of the tank (counting from top)
      h_le = (1 - (10.5 / 12.0)) * tank_height # in the 11th node of the tank (counting from top)
      h_condtop = (1 - (5.5 / 12.0)) * tank_height # in the 6th node of the tank (counting from top)
      h_condbot = (1 - (10.99 / 12.0)) * tank_height # in the 11th node of the tank
      h_hpctrl = (1 - (2.5 / 12.0)) * tank_height # in the 3rd node of the tank
      hpwh.setControlSensor1HeightInStratifiedTank(h_hpctrl)
      hpwh.setControlSensor1Weight(1.0)
      hpwh.setControlSensor2HeightInStratifiedTank(h_hpctrl)
    else
      hpwh.setDeadBandTemperatureDifference(3.89)
      h_ue = (1 - (3.5 / 12.0)) * tank_height # in the 3rd node of the tank (counting from top)
      h_le = (1 - (9.5 / 12.0)) * tank_height # in the 10th node of the tank (counting from top)
      h_condtop = (1 - (5.5 / 12.0)) * tank_height # in the 6th node of the tank (counting from top)
      h_condbot = 0.01 # bottom node
      h_hpctrl_up = (1 - (2.5 / 12.0)) * tank_height # in the 3rd node of the tank
      h_hpctrl_low = (1 - (8.5 / 12.0)) * tank_height # in the 9th node of the tank
      hpwh.setControlSensor1HeightInStratifiedTank(h_hpctrl_up)
      hpwh.setControlSensor1Weight(0.75)
      hpwh.setControlSensor2HeightInStratifiedTank(h_hpctrl_low)
    end
    hpwh.setCondenserBottomLocation(h_condbot)
    hpwh.setCondenserTopLocation(h_condtop)
    hpwh.setTankElementControlLogic('MutuallyExclusive')
  elsif type == 'PumpedCondenser'
    hpwh.setDeadBandTemperatureDifference(3.89)
  end

  # set heat pump water heater properties
  hpwh.setEvaporatorAirFlowRate(OpenStudio.convert(181.0, 'ft^3/min', 'm^3/s').get)
  hpwh.setFanPlacement('DrawThrough')
  hpwh.setOnCycleParasiticElectricLoad(0.0)
  hpwh.setOffCycleParasiticElectricLoad(0.0)
  hpwh.setParasiticHeatRejectionLocation('Outdoors')

  # set temperature setpoint schedule
  if swh_temp_sch.nil?
    # temperature schedule type limits
    temp_sch_type_limits = model_add_schedule_type_limits(model,
                                                          name: 'Temperature Schedule Type Limits',
                                                          lower_limit_value: 0.0,
                                                          upper_limit_value: 100.0,
                                                          numeric_type: 'Continuous',
                                                          unit_type: 'Temperature')
    # service water heating loop controls
    swh_temp_c = service_water_temperature
    swh_temp_f = OpenStudio.convert(swh_temp_c, 'C', 'F').get
    swh_delta_t_r = 9.0 # 9F delta-T
    swh_temp_c = OpenStudio.convert(swh_temp_f, 'F', 'C').get
    swh_delta_t_k = OpenStudio.convert(swh_delta_t_r, 'R', 'K').get
    swh_temp_sch = model_add_constant_schedule_ruleset(model,
                                                       swh_temp_c,
                                                       name = "Heat Pump Water Heater Temp - #{swh_temp_f.round}F")
    swh_temp_sch.setScheduleTypeLimits(temp_sch_type_limits)
  end
  hpwh.setCompressorSetpointTemperatureSchedule(swh_temp_sch)

  # coil curves
  hpwh_cap = OpenStudio::Model::CurveBiquadratic.new(model)
  hpwh_cap.setName('HPWH-Cap-fT')
  hpwh_cap.setCoefficient1Constant(0.563)
  hpwh_cap.setCoefficient2x(0.0437)
  hpwh_cap.setCoefficient3xPOW2(0.000039)
  hpwh_cap.setCoefficient4y(0.0055)
  hpwh_cap.setCoefficient5yPOW2(-0.000148)
  hpwh_cap.setCoefficient6xTIMESY(-0.000145)
  hpwh_cap.setMinimumValueofx(0.0)
  hpwh_cap.setMaximumValueofx(100.0)
  hpwh_cap.setMinimumValueofy(0.0)
  hpwh_cap.setMaximumValueofy(100.0)

  hpwh_cop = OpenStudio::Model::CurveBiquadratic.new(model)
  hpwh_cop.setName('HPWH-COP-fT')
  hpwh_cop.setCoefficient1Constant(1.1332)
  hpwh_cop.setCoefficient2x(0.063)
  hpwh_cop.setCoefficient3xPOW2(-0.0000979)
  hpwh_cop.setCoefficient4y(-0.00972)
  hpwh_cop.setCoefficient5yPOW2(-0.0000214)
  hpwh_cop.setCoefficient6xTIMESY(-0.000686)
  hpwh_cop.setMinimumValueofx(0.0)
  hpwh_cop.setMaximumValueofx(100.0)
  hpwh_cop.setMinimumValueofy(0.0)
  hpwh_cop.setMaximumValueofy(100.0)

  # create DX coil object
  if type == 'WrappedCondenser'
    coil = hpwh.dXCoil.to_CoilWaterHeatingAirToWaterHeatPumpWrapped.get
    coil.setRatedCondenserWaterTemperature(48.89)
  elsif type == 'PumpedCondenser'
    coil = OpenStudio::Model::CoilWaterHeatingAirToWaterHeatPump.new(model)
    hpwh.setDXCoil(coil)
  end

  # set coil properties
  coil.setName("#{hpwh.name} Coil")
  coil.setRatedHeatingCapacity(water_heater_capacity * cop)
  coil.setRatedCOP(cop)
  coil.setRatedSensibleHeatRatio(shr)
  coil.setRatedEvaporatorInletAirDryBulbTemperature(OpenStudio.convert(67.5, 'F', 'C').get)
  coil.setRatedEvaporatorInletAirWetBulbTemperature(OpenStudio.convert(56.426, 'F', 'C').get)
  coil.setRatedEvaporatorAirFlowRate(OpenStudio.convert(181.0, 'ft^3/min', 'm^3/s').get)
  coil.setEvaporatorFanPowerIncludedinRatedCOP(true)
  coil.setEvaporatorAirTemperatureTypeforCurveObjects('WetBulbTemperature')
  coil.setHeatingCapacityFunctionofTemperatureCurve(hpwh_cap)
  coil.setHeatingCOPFunctionofTemperatureCurve(hpwh_cop)
  coil.setMaximumAmbientTemperatureforCrankcaseHeaterOperation(0.0)

  # set tank properties
  if type == 'WrappedCondenser'
    tank = hpwh.tank.to_WaterHeaterStratified.get
    tank.setTankHeight(tank_height)
    tank.setHeaterPriorityControl('MasterSlave')
    if hpwh_vol_gal <= 50.0
      tank.setHeater1DeadbandTemperatureDifference(25.0)
      tank.setHeater2DeadbandTemperatureDifference(30.0)
    else
      tank.setHeater1DeadbandTemperatureDifference(18.5)
      tank.setHeater2DeadbandTemperatureDifference(3.89)
    end
    hpwh_bottom_element_sp = OpenStudio::Model::ScheduleConstant.new(model)
    hpwh_bottom_element_sp.setName("#{hpwh.name} BottomElementSetpoint")
    hpwh_top_element_sp = OpenStudio::Model::ScheduleConstant.new(model)
    hpwh_top_element_sp.setName("#{hpwh.name} TopElementSetpoint")
    tank.setHeater1Capacity(electric_backup_capacity)
    tank.setHeater1Height(h_ue)
    tank.setHeater1SetpointTemperatureSchedule(hpwh_top_element_sp) # Overwritten later by EMS
    tank.setHeater2Capacity(electric_backup_capacity)
    tank.setHeater2Height(h_le)
    tank.setHeater2SetpointTemperatureSchedule(hpwh_bottom_element_sp)
    tank.setUniformSkinLossCoefficientperUnitAreatoAmbientTemperature(u_tank)
    tank.setNumberofNodes(12)
    tank.setAdditionalDestratificationConductivity(0)
    tank.setNode1AdditionalLossCoefficient(0)
    tank.setNode2AdditionalLossCoefficient(0)
    tank.setNode3AdditionalLossCoefficient(0)
    tank.setNode4AdditionalLossCoefficient(0)
    tank.setNode5AdditionalLossCoefficient(0)
    tank.setNode6AdditionalLossCoefficient(0)
    tank.setNode7AdditionalLossCoefficient(0)
    tank.setNode8AdditionalLossCoefficient(0)
    tank.setNode9AdditionalLossCoefficient(0)
    tank.setNode10AdditionalLossCoefficient(0)
    tank.setNode11AdditionalLossCoefficient(0)
    tank.setNode12AdditionalLossCoefficient(0)
    tank.setUseSideDesignFlowRate(0.9 * water_heater_volume / 60.1)
    tank.setSourceSideDesignFlowRate(0)
    tank.setSourceSideFlowControlMode('')
    tank.setSourceSideInletHeight(0)
    tank.setSourceSideOutletHeight(0)
  elsif type == 'PumpedCondenser'
    tank = OpenStudio::Model::WaterHeaterMixed.new(model)
    hpwh.setTank(tank)
    tank.setDeadbandTemperatureDifference(3.89)
    tank.setHeaterControlType('Cycle')
    tank.setHeaterMaximumCapacity(electric_backup_capacity)
  end
  tank.setName("#{hpwh.name} Tank")
  tank.setEndUseSubcategory('Service Hot Water')
  tank.setTankVolume(0.9 * water_heater_volume)
  tank.setMaximumTemperatureLimit(90.0)
  tank.setHeaterFuelType('Electricity')
  tank.setHeaterThermalEfficiency(1.0)
  tank.setOffCycleParasiticFuelConsumptionRate(parasitic_fuel_consumption_rate)
  tank.setOffCycleParasiticFuelType('Electricity')
  tank.setOnCycleParasiticFuelConsumptionRate(parasitic_fuel_consumption_rate)
  tank.setOnCycleParasiticFuelType('Electricity')

  # set fan properties
  fan = hpwh.fan.to_FanOnOff.get
  fan.setName("#{hpwh.name} Fan")
  fan_power = 0.0462 # watts per cfm
  if hpwh_vol_gal <= 50.0
    fan.setFanEfficiency(23.0 / fan_power * OpenStudio.convert(1.0, 'ft^3/min', 'm^3/s').get)
    fan.setPressureRise(23.0)
  else
    fan.setFanEfficiency(65.0 / fan_power * OpenStudio.convert(1.0, 'ft^3/min', 'm^3/s').get)
    fan.setPressureRise(65.0)
  end
  fan.setMaximumFlowRate(OpenStudio.convert(181.0, 'ft^3/min', 'm^3/s').get)
  fan.setMotorEfficiency(1.0)
  fan.setMotorInAirstreamFraction(1.0)
  fan.setEndUseSubcategory('Service Hot Water')

  if water_heater_thermal_zone.nil?
    # add in schedules for Tamb, RHamb, and the compressor
    # assume the water heater is indoors at 70F for now
    default_water_heater_ambient_temp_sch = model_add_constant_schedule_ruleset(model,
                                                                                OpenStudio.convert(70.0, 'F', 'C').get,
                                                                                name = 'Water Heater Ambient Temp Schedule - 70F')
    default_water_heater_ambient_temp_sch.setScheduleTypeLimits(temp_sch_type_limits)
    tank.setAmbientTemperatureIndicator('Schedule')
    tank.setAmbientTemperatureSchedule(default_water_heater_ambient_temp_sch)
    tank.resetAmbientTemperatureThermalZone
    hpwh_rhamb = OpenStudio::Model::ScheduleConstant.new(model)
    hpwh_rhamb.setName("#{hpwh.name} Ambient Humidity Schedule")
    hpwh_rhamb.setValue(0.5)
    hpwh.setInletAirConfiguration('Schedule')
    hpwh.setInletAirTemperatureSchedule(default_water_heater_ambient_temp_sch)
    hpwh.setInletAirHumiditySchedule(hpwh_rhamb)
    hpwh.setCompressorLocation('Schedule')
    hpwh.setCompressorAmbientTemperatureSchedule(default_water_heater_ambient_temp_sch)
  else
    hpwh.addToThermalZone(water_heater_thermal_zone)
    hpwh.setInletAirConfiguration('ZoneAirOnly')
    hpwh.setCompressorLocation('Zone')
    tank.setAmbientTemperatureIndicator('ThermalZone')
    tank.setAmbientTemperatureThermalZone(water_heater_thermal_zone)
    tank.resetAmbientTemperatureSchedule
  end

  if set_peak_use_flowrate
    rated_flow_rate_m3_per_s = peak_flowrate
    rated_flow_rate_gal_per_min = OpenStudio.convert(rated_flow_rate_m3_per_s, 'm^3/s', 'gal/min').get
    tank.setPeakUseFlowRate(rated_flow_rate_m3_per_s)
    schedule = model_add_schedule(model, flowrate_schedule)
    tank.setUseFlowRateFractionSchedule(schedule)
  end

  return hpwh
end

#model_add_high_temp_radiant(model, thermal_zones, heating_type: 'NaturalGas', combustion_efficiency: 0.8, control_type: 'MeanAirTemperature') ⇒ Array<OpenStudio::Model::ZoneHVACHighTemperatureRadiant>

Creates a high temp radiant heater for each zone and adds it to the model.

array of the resulting radiant heaters.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • heating_type (String) (defaults to: 'NaturalGas')

    valid choices are Gas, Electric

  • combustion_efficiency (Double) (defaults to: 0.8)

    combustion efficiency as decimal

  • control_type (String) (defaults to: 'MeanAirTemperature')

    control type

Returns:



3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 3995

def model_add_high_temp_radiant(model,
                                thermal_zones,
                                heating_type: 'NaturalGas',
                                combustion_efficiency: 0.8,
                                control_type: 'MeanAirTemperature')

  # make a high temp radiant heater for each zone
  radiant_heaters = []
  thermal_zones.each do |zone|
    high_temp_radiant = OpenStudio::Model::ZoneHVACHighTemperatureRadiant.new(model)
    high_temp_radiant.setName("#{zone.name} High Temp Radiant")

    if heating_type.nil? || heating_type == 'Gas'
      high_temp_radiant.setFuelType('NaturalGas')
    else
      high_temp_radiant.setFuelType(heating_type)
    end

    if combustion_efficiency.nil?
      if heating_type == 'NaturalGas' || heating_type == 'Gas'
        high_temp_radiant.setCombustionEfficiency(0.8)
      elsif heating_type == 'Electric'
        high_temp_radiant.setCombustionEfficiency(1.0)
      end
    else
      high_temp_radiant.setCombustionEfficiency(combustion_efficiency)
    end

    # set heating setpoint schedule
    tstat = zone.thermostatSetpointDualSetpoint.get
    if tstat.heatingSetpointTemperatureSchedule.is_initialized
      htg_sch = tstat.heatingSetpointTemperatureSchedule.get
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "For #{zone.name}: Cannot find a heating setpoint schedule for this zone, cannot apply high temp radiant system.")
      return false
    end

    # set defaults
    high_temp_radiant.setHeatingSetpointTemperatureSchedule(htg_sch)
    high_temp_radiant.setTemperatureControlType(control_type)
    high_temp_radiant.setFractionofInputConvertedtoRadiantEnergy(0.8)
    high_temp_radiant.setHeatingThrottlingRange(2)
    high_temp_radiant.addToThermalZone(zone)
    radiant_heaters << high_temp_radiant
  end

  return radiant_heaters
end

#model_add_hp_loop(model, heating_fuel: 'NaturalGas', cooling_fuel: 'Electricity', cooling_type: 'EvaporativeFluidCooler', system_name: 'Heat Pump Loop', sup_wtr_high_temp: 87.0, sup_wtr_low_temp: 67.0, dsgn_sup_wtr_temp: 102.2, dsgn_sup_wtr_temp_delt: 19.8) ⇒ OpenStudio::Model::PlantLoop

Creates a heat pump loop which has a boiler and fluid cooler for supplemental heating/cooling and adds it to the model.

TODO: replace cooling tower with fluid cooler after fixing sizing inputs

Parameters:

  • heating_fuel (String) (defaults to: 'NaturalGas')
  • cooling_fuel (String) (defaults to: 'Electricity')

    cooling fuel. Valid options are: Electricity, DistrictCooling

  • cooling_type (String) (defaults to: 'EvaporativeFluidCooler')

    cooling type if not DistrictCooling. Valid options are: CoolingTower, CoolingTowerSingleSpeed, CoolingTowerTwoSpeed, CoolingTowerVariableSpeed, FluidCooler, FluidCoolerSingleSpeed, FluidCoolerTwoSpeed, EvaporativeFluidCooler, EvaporativeFluidCoolerSingleSpeed, EvaporativeFluidCoolerTwoSpeed

  • system_name (String) (defaults to: 'Heat Pump Loop')

    the name of the system, or nil in which case it will be defaulted

  • sup_wtr_high_temp (Double) (defaults to: 87.0)

    target supply water temperature to enable cooling in degrees Fahrenheit, default 65.0F

  • sup_wtr_low_temp (Double) (defaults to: 67.0)

    target supply water temperature to enable heating in degrees Fahrenheit, default 41.0F

  • dsgn_sup_wtr_temp (Double) (defaults to: 102.2)

    design supply water temperature in degrees Fahrenheit, default 102.2F

  • dsgn_sup_wtr_temp_delt (Double) (defaults to: 19.8)

    design supply-return water temperature difference in degrees Rankine, default 19.8R

Returns:



646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 646

def model_add_hp_loop(model,
                      heating_fuel: 'NaturalGas',
                      cooling_fuel: 'Electricity',
                      cooling_type: 'EvaporativeFluidCooler',
                      system_name: 'Heat Pump Loop',
                      sup_wtr_high_temp: 87.0,
                      sup_wtr_low_temp: 67.0,
                      dsgn_sup_wtr_temp: 102.2,
                      dsgn_sup_wtr_temp_delt: 19.8)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding heat pump loop.')

  # create heat pump loop
  heat_pump_water_loop = OpenStudio::Model::PlantLoop.new(model)
  heat_pump_water_loop.setLoadDistributionScheme('SequentialLoad')
  if system_name.nil?
    heat_pump_water_loop.setName('Heat Pump Loop')
  else
    heat_pump_water_loop.setName(system_name)
  end

  # hot water loop sizing and controls
  if sup_wtr_high_temp.nil?
    sup_wtr_high_temp = 87.0
    sup_wtr_high_temp_c = OpenStudio.convert(sup_wtr_high_temp, 'F', 'C').get
  else
    sup_wtr_high_temp_c = OpenStudio.convert(sup_wtr_high_temp, 'F', 'C').get
  end
  if sup_wtr_low_temp.nil?
    sup_wtr_low_temp = 67.0
    sup_wtr_low_temp_c = OpenStudio.convert(sup_wtr_low_temp, 'F', 'C').get
  else
    sup_wtr_low_temp_c = OpenStudio.convert(sup_wtr_low_temp, 'F', 'C').get
  end
  if dsgn_sup_wtr_temp.nil?
    dsgn_sup_wtr_temp_c = OpenStudio.convert(102.2, 'F', 'C').get
  else
    dsgn_sup_wtr_temp_c = OpenStudio.convert(dsgn_sup_wtr_temp, 'F', 'C').get
  end
  if dsgn_sup_wtr_temp_delt.nil?
    dsgn_sup_wtr_temp_delt_k = OpenStudio.convert(19.8, 'R', 'K').get
  else
    dsgn_sup_wtr_temp_delt_k = OpenStudio.convert(dsgn_sup_wtr_temp_delt, 'R', 'K').get
  end
  sizing_plant = heat_pump_water_loop.sizingPlant
  sizing_plant.setLoopType('Heating')
  heat_pump_water_loop.setMinimumLoopTemperature(10.0)
  heat_pump_water_loop.setMaximumLoopTemperature(35.0)
  sizing_plant.setDesignLoopExitTemperature(dsgn_sup_wtr_temp_c)
  sizing_plant.setLoopDesignTemperatureDifference(dsgn_sup_wtr_temp_delt_k)
  hp_high_temp_sch = model_add_constant_schedule_ruleset(model,
                                                         sup_wtr_high_temp_c,
                                                         name = "#{heat_pump_water_loop.name} High Temp - #{sup_wtr_high_temp.round(0)}F")
  hp_low_temp_sch = model_add_constant_schedule_ruleset(model,
                                                        sup_wtr_low_temp_c,
                                                        name = "#{heat_pump_water_loop.name} Low Temp - #{sup_wtr_low_temp.round(0)}F")
  hp_stpt_manager = OpenStudio::Model::SetpointManagerScheduledDualSetpoint.new(model)
  hp_stpt_manager.setName("#{heat_pump_water_loop.name} Scheduled Dual Setpoint")
  hp_stpt_manager.setHighSetpointSchedule(hp_high_temp_sch)
  hp_stpt_manager.setLowSetpointSchedule(hp_low_temp_sch)
  hp_stpt_manager.addToNode(heat_pump_water_loop.supplyOutletNode)

  # create pump
  hp_pump = OpenStudio::Model::PumpConstantSpeed.new(model)
  hp_pump.setName("#{heat_pump_water_loop.name} Pump")
  hp_pump.setRatedPumpHead(OpenStudio.convert(60.0, 'ftH_{2}O', 'Pa').get)
  hp_pump.setPumpControlType('Intermittent')
  hp_pump.addToNode(heat_pump_water_loop.supplyInletNode)

  # add setpoint manager schedule to cooling equipment outlet so correct plant operation scheme is generated
  cooling_equipment_stpt_manager = OpenStudio::Model::SetpointManagerScheduledDualSetpoint.new(model)
  cooling_equipment_stpt_manager.setHighSetpointSchedule(hp_high_temp_sch)
  cooling_equipment_stpt_manager.setLowSetpointSchedule(hp_low_temp_sch)

  # create cooling equipment and add to the loop
  case cooling_fuel
  when 'DistrictCooling'
    cooling_equipment = OpenStudio::Model::DistrictCooling.new(model)
    cooling_equipment.setName("#{heat_pump_water_loop.name} District Cooling")
    cooling_equipment.autosizeNominalCapacity
    heat_pump_water_loop.addSupplyBranchForComponent(cooling_equipment)
    cooling_equipment_stpt_manager.setName("#{heat_pump_water_loop.name} District Cooling Scheduled Dual Setpoint")
  else
    case cooling_type
    when 'CoolingTower', 'CoolingTowerTwoSpeed'
      cooling_equipment = OpenStudio::Model::CoolingTowerTwoSpeed.new(model)
      cooling_equipment.setName("#{heat_pump_water_loop.name} CoolingTowerTwoSpeed")
      heat_pump_water_loop.addSupplyBranchForComponent(cooling_equipment)
      cooling_equipment_stpt_manager.setName("#{heat_pump_water_loop.name} Cooling Tower Scheduled Dual Setpoint")
    when 'CoolingTowerSingleSpeed'
      cooling_equipment = OpenStudio::Model::CoolingTowerSingleSpeed.new(model)
      cooling_equipment.setName("#{heat_pump_water_loop.name} CoolingTowerSingleSpeed")
      heat_pump_water_loop.addSupplyBranchForComponent(cooling_equipment)
      cooling_equipment_stpt_manager.setName("#{heat_pump_water_loop.name} Cooling Tower Scheduled Dual Setpoint")
    when 'CoolingTowerVariableSpeed'
      cooling_equipment = OpenStudio::Model::CoolingTowerVariableSpeed.new(model)
      cooling_equipment.setName("#{heat_pump_water_loop.name} CoolingTowerVariableSpeed")
      heat_pump_water_loop.addSupplyBranchForComponent(cooling_equipment)
      cooling_equipment_stpt_manager.setName("#{heat_pump_water_loop.name} Cooling Tower Scheduled Dual Setpoint")
    when 'FluidCooler', 'FluidCoolerSingleSpeed'
      cooling_equipment = OpenStudio::Model::FluidCoolerSingleSpeed.new(model)
      cooling_equipment.setName("#{heat_pump_water_loop.name} FluidCoolerSingleSpeed")
      heat_pump_water_loop.addSupplyBranchForComponent(cooling_equipment)
      cooling_equipment_stpt_manager.setName("#{heat_pump_water_loop.name} Fluid Cooler Scheduled Dual Setpoint")
      # Remove hard coded default values
      cooling_equipment.setPerformanceInputMethod('UFactorTimesAreaAndDesignWaterFlowRate')
      cooling_equipment.autosizeDesignWaterFlowRate
      cooling_equipment.autosizeDesignAirFlowRate
    when 'FluidCoolerTwoSpeed'
      cooling_equipment = OpenStudio::Model::FluidCoolerTwoSpeed.new(model)
      cooling_equipment.setName("#{heat_pump_water_loop.name} FluidCoolerTwoSpeed")
      heat_pump_water_loop.addSupplyBranchForComponent(cooling_equipment)
      cooling_equipment_stpt_manager.setName("#{heat_pump_water_loop.name} Fluid Cooler Scheduled Dual Setpoint")
      # Remove hard coded default values
      cooling_equipment.setPerformanceInputMethod('UFactorTimesAreaAndDesignWaterFlowRate')
      cooling_equipment.autosizeDesignWaterFlowRate
      cooling_equipment.autosizeHighFanSpeedAirFlowRate
      cooling_equipment.autosizeLowFanSpeedAirFlowRate
    when 'EvaporativeFluidCooler', 'EvaporativeFluidCoolerSingleSpeed'
      cooling_equipment = OpenStudio::Model::EvaporativeFluidCoolerSingleSpeed.new(model)
      cooling_equipment.setName("#{heat_pump_water_loop.name} EvaporativeFluidCoolerSingleSpeed")
      cooling_equipment.setDesignSprayWaterFlowRate(0.002208) # Based on HighRiseApartment
      cooling_equipment.setPerformanceInputMethod('UFactorTimesAreaAndDesignWaterFlowRate')
      heat_pump_water_loop.addSupplyBranchForComponent(cooling_equipment)
      cooling_equipment_stpt_manager.setName("#{heat_pump_water_loop.name} Fluid Cooler Scheduled Dual Setpoint")
    when 'EvaporativeFluidCoolerTwoSpeed'
      cooling_equipment = OpenStudio::Model::EvaporativeFluidCoolerTwoSpeed.new(model)
      cooling_equipment.setName("#{heat_pump_water_loop.name} EvaporativeFluidCoolerTwoSpeed")
      cooling_equipment.setDesignSprayWaterFlowRate(0.002208) # Based on HighRiseApartment
      cooling_equipment.setPerformanceInputMethod('UFactorTimesAreaAndDesignWaterFlowRate')
      heat_pump_water_loop.addSupplyBranchForComponent(cooling_equipment)
      cooling_equipment_stpt_manager.setName("#{heat_pump_water_loop.name} Fluid Cooler Scheduled Dual Setpoint")
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Cooling fuel type #{cooling_type} is not a valid option, no cooling equipment will be added.")
      return false
    end
  end
  cooling_equipment_stpt_manager.addToNode(cooling_equipment.outletModelObject.get.to_Node.get)

  # add setpoint manager schedule to heating equipment outlet so correct plant operation scheme is generated
  heating_equipment_stpt_manager = OpenStudio::Model::SetpointManagerScheduledDualSetpoint.new(model)
  heating_equipment_stpt_manager.setHighSetpointSchedule(hp_high_temp_sch)
  heating_equipment_stpt_manager.setLowSetpointSchedule(hp_low_temp_sch)

  # create heating equipment and add to the loop
  case heating_fuel
  when 'DistrictHeating'
    heating_equipment = OpenStudio::Model::DistrictHeating.new(model)
    heating_equipment.setName("#{heat_pump_water_loop.name} District Heating")
    heating_equipment.autosizeNominalCapacity
    heat_pump_water_loop.addSupplyBranchForComponent(heating_equipment)
    heating_equipment_stpt_manager.setName("#{heat_pump_water_loop.name} District Heating Scheduled Dual Setpoint")
  when 'AirSourceHeatPump', 'ASHP'
    heating_equipment = create_central_air_source_heat_pump(model, heat_pump_water_loop)
    heating_equipment_stpt_manager.setName("#{heat_pump_water_loop.name} ASHP Scheduled Dual Setpoint")
  when 'Electricity', 'Gas', 'NaturalGas', 'PropaneGas', 'FuelOilNo1', 'FuelOilNo2'
    heating_equipment = create_boiler_hot_water(model,
                                                hot_water_loop: heat_pump_water_loop,
                                                name: "#{heat_pump_water_loop.name} Supplemental Boiler",
                                                fuel_type: heating_fuel,
                                                flow_mode: 'ConstantFlow',
                                                lvg_temp_dsgn: 86.0,
                                                min_plr: 0.0,
                                                max_plr: 1.2,
                                                opt_plr: 1.0)
    heating_equipment_stpt_manager.setName("#{heat_pump_water_loop.name} Boiler Scheduled Dual Setpoint")
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Boiler fuel type #{heating_fuel} is not valid, no heating equipment will be added.")
    return false
  end
  heating_equipment_stpt_manager.addToNode(heating_equipment.outletModelObject.get.to_Node.get)

  # add heat pump water loop pipes
  supply_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  supply_bypass_pipe.setName("#{heat_pump_water_loop.name} Supply Bypass")
  heat_pump_water_loop.addSupplyBranchForComponent(supply_bypass_pipe)

  demand_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_bypass_pipe.setName("#{heat_pump_water_loop.name} Demand Bypass")
  heat_pump_water_loop.addDemandBranchForComponent(demand_bypass_pipe)

  supply_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  supply_outlet_pipe.setName("#{heat_pump_water_loop.name} Supply Outlet")
  supply_outlet_pipe.addToNode(heat_pump_water_loop.supplyOutletNode)

  demand_inlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_inlet_pipe.setName("#{heat_pump_water_loop.name} Demand Inlet")
  demand_inlet_pipe.addToNode(heat_pump_water_loop.demandInletNode)

  demand_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_outlet_pipe.setName("#{heat_pump_water_loop.name} Demand Outlet")
  demand_outlet_pipe.addToNode(heat_pump_water_loop.demandOutletNode)

  return heat_pump_water_loop
end

#model_add_hvac(model, building_type, climate_zone, prototype_input, epw_file) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.hvac.rb', line 2

def model_add_hvac(model, building_type, climate_zone, prototype_input, epw_file)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started Adding HVAC')

  # Get the list of HVAC systems, as defined for each building in the Prototype.building_name files

  # Add each HVAC system
  @system_to_space_map.each do |system|
    thermal_zones = model_get_zones_from_spaces_on_system(model, system)
    return_plenum = model_get_return_plenum_from_system(model, system)

    # Add the HVAC systems
    case system['type']
    when 'VAV'
      # Retrieve the existing hot water loop or add a new one if necessary.
      hot_water_loop = nil
      hot_water_loop = if model.getPlantLoopByName('Hot Water Loop').is_initialized
                         model.getPlantLoopByName('Hot Water Loop').get
                       else
                         model_add_hw_loop(model,
                                           'NaturalGas',
                                           dsgn_sup_wtr_temp: system['hot_water_design_supply_water_temperature'],
                                           boiler_lvg_temp_dsgn: system['boiler_leaving_temperature_design'],
                                           boiler_out_temp_lmt: system['boiler_outlet_temperature_limit'],
                                           boiler_sizing_factor: system['boiler_sizing_factor'])
                       end

      # Retrieve the existing chilled water loop or add a new one if necessary.
      chilled_water_loop = nil
      if model.getPlantLoopByName('Chilled Water Loop').is_initialized
        chilled_water_loop = model.getPlantLoopByName('Chilled Water Loop').get
      else
        # get num_chillers from prototype_input
        num_chillers = prototype_input['chw_number_chillers']
        if num_chillers.nil? || num_chillers.to_i < 1
          num_chillers = 1
        end
        # update num_chillers if specified in @system_to_space_map
        if !system['chw_number_chillers'].nil? && system['chw_number_chillers'].to_i > 0
          num_chillers = system['chw_number_chillers']
        end

        # get number_cooling_towers if specified in @system_to_space_map
        number_cooling_towers = 1
        if !system['number_cooling_towers'].nil? && system['number_cooling_towers'].to_i > 0
          number_cooling_towers = system['number_cooling_towers']
        end

        condenser_water_loop = nil
        if system['chiller_cooling_type'] == 'WaterCooled'
          condenser_water_loop = model_add_cw_loop(model,
                                                   cooling_tower_type: 'Open Cooling Tower',
                                                   cooling_tower_fan_type: 'Centrifugal',
                                                   cooling_tower_capacity_control: 'Variable Speed Fan',
                                                   number_of_cells_per_tower: 2,
                                                   number_cooling_towers: number_cooling_towers.to_i)
        end
        chilled_water_loop = model_add_chw_loop(model,
                                                cooling_fuel: 'Electricity',
                                                dsgn_sup_wtr_temp: system['chilled_water_design_supply_water_temperature'],
                                                dsgn_sup_wtr_temp_delt: system['chilled_water_design_supply_water_temperature_delta'],
                                                chw_pumping_type: system['chw_pumping_type'],
                                                chiller_cooling_type: system['chiller_cooling_type'],
                                                chiller_condenser_type: system['chiller_condenser_type'],
                                                chiller_compressor_type: system['chiller_compressor_type'],
                                                condenser_water_loop: condenser_water_loop,
                                                num_chillers: num_chillers.to_i)
      end

      # Add the VAV
      model_add_vav_reheat(model,
                           thermal_zones,
                           system_name: system['name'],
                           return_plenum: return_plenum,
                           reheat_type: 'Water',
                           hot_water_loop: hot_water_loop,
                           chilled_water_loop: chilled_water_loop,
                           hvac_op_sch: system['operation_schedule'],
                           oa_damper_sch: system['oa_damper_schedule'],
                           fan_efficiency: 0.62,
                           fan_motor_efficiency: 0.9,
                           fan_pressure_rise: 4.0,
                           min_sys_airflow_ratio: system['min_sys_airflow_ratio'],
                           vav_sizing_option: system['vav_sizing_option'])

    when 'CAV'
      # Retrieve the existing hot water loop or add a new one if necessary.
      hot_water_loop = nil
      hot_water_loop = if model.getPlantLoopByName('Hot Water Loop').is_initialized
                         model.getPlantLoopByName('Hot Water Loop').get
                       else
                         model_add_hw_loop(model, 'NaturalGas')
                       end

      chilled_water_loop = nil
      if model.getPlantLoopByName('Chilled Water Loop').is_initialized
        chilled_water_loop = model.getPlantLoopByName('Chilled Water Loop').get
      elsif building_type == 'Hospital'
        condenser_water_loop = nil
        condenser_water_loop = model_add_cw_loop(model, cooling_tower_capacity_control: 'Variable Speed Fan') if system['chiller_cooling_type'] == 'WaterCooled'
        chilled_water_loop = model_add_chw_loop(model,
                                                cooling_fuel: 'Electricity',
                                                dsgn_sup_wtr_temp: system['chilled_water_design_supply_water_temperature'],
                                                dsgn_sup_wtr_temp_delt: system['chilled_water_design_supply_water_temperature_delta'],
                                                chw_pumping_type: system['chw_pumping_type'],
                                                chiller_cooling_type: system['chiller_cooling_type'],
                                                chiller_condenser_type: system['chiller_condenser_type'],
                                                chiller_compressor_type: system['chiller_compressor_type'],
                                                condenser_water_loop: condenser_water_loop)
      end

      # Add the CAV
      model_add_cav(model,
                    thermal_zones,
                    system_name: system['name'],
                    hot_water_loop: hot_water_loop,
                    chilled_water_loop: chilled_water_loop,
                    hvac_op_sch: system['operation_schedule'],
                    oa_damper_sch: system['oa_damper_schedule'],
                    fan_efficiency: 0.62,
                    fan_motor_efficiency: 0.9,
                    fan_pressure_rise: 4.0)

    when 'PSZ-AC'
      # Special logic to make unitary heat pumps all blow-through
      fan_position = 'DrawThrough'
      if system['heating_type'] == 'Single Speed Heat Pump' ||
         system['heating_type'] == 'Water To Air Heat Pump'
        fan_position = 'BlowThrough'
      end

      # Special logic to make a heat pump loop if necessary
      heat_pump_loop = nil
      if system['heating_type'] == 'Water To Air Heat Pump'
        # @code_sections [90.1-2016_6.5.5.2.1]
        # change highrise apartment heat rejection fan (< 5hp) from single speed to two speed evaporative fluid cooler
        # TODO: this is temporary fix, it should be applied to all heat rejection devices smaller than 5hp.
        if system['heat_pump_loop_cooling_type'].nil?
          hp_loop_cooling_type = 'EvaporativeFluidCooler'
        else
          hp_loop_cooling_type = system['heat_pump_loop_cooling_type']
        end
        heat_pump_loop = model_get_or_add_heat_pump_loop(model, 'NaturalGas', 'Electricity', heat_pump_loop_cooling_type: hp_loop_cooling_type)
      end
      # if water to air heat pump is using existing chilled water loop and hot water loop as source
      # get existing loops, and assign heat_pump_cool_loop = chilled_water_loop, heat_pump_heat_loop = hot_water_loop
      # applicable to super tall building elevator machine room that is in the middle of the building

      model_add_psz_ac(model,
                       thermal_zones,
                       system_name: system['name'],
                       cooling_type: system['cooling_type'],
                       chilled_water_loop: heat_pump_loop,
                       heating_type: system['heating_type'],
                       supplemental_heating_type: system['supplemental_heating_type'],
                       hot_water_loop: heat_pump_loop,
                       fan_location: fan_position,
                       fan_type: system['fan_type'],
                       hvac_op_sch: system['operation_schedule'],
                       oa_damper_sch: system['oa_damper_schedule'])

    when 'PVAV'
      # Retrieve the existing hot water loop or add a new one if necessary.
      hot_water_loop = nil
      hot_water_loop = if model.getPlantLoopByName('Hot Water Loop').is_initialized
                         model.getPlantLoopByName('Hot Water Loop').get
                       elsif building_type == 'MediumOffice'
                         nil
                       elsif building_type == 'MediumOfficeDetailed'
                         nil
                       else
                         model_add_hw_loop(model,
                                           'NaturalGas',
                                           pump_spd_ctrl: system['hotwater_pump_speed_control'])
                       end
      case system['electric_reheat']
      when true
        electric_reheat = true
      else
        electric_reheat = false
      end
      model_add_pvav(model,
                     thermal_zones,
                     system_name: system['name'],
                     hvac_op_sch: system['operation_schedule'],
                     oa_damper_sch: system['oa_damper_schedule'],
                     electric_reheat: electric_reheat,
                     hot_water_loop: hot_water_loop,
                     return_plenum: return_plenum)

    when 'DOAS Cold Supply'
      # Retrieve the existing hot water loop or add a new one if necessary.
      hot_water_loop = nil
      hot_water_loop = if model.getPlantLoopByName('Hot Water Loop').is_initialized
                         model.getPlantLoopByName('Hot Water Loop').get
                       else
                         model_add_hw_loop(model, 'NaturalGas')
                       end

      # Retrieve the existing chilled water loop or add a new one if necessary.
      chilled_water_loop = nil
      if model.getPlantLoopByName('Chilled Water Loop').is_initialized
        chilled_water_loop = model.getPlantLoopByName('Chilled Water Loop').get
      else
        num_chillers = 1
        if !system['num_chillers'].nil? && system['num_chillers'].to_i > 0
          num_chillers = system['num_chillers'].to_i
        end
        condenser_water_loop = nil
        if system['chiller_cooling_type'] == 'WaterCooled'
          condenser_water_loop = model_add_cw_loop(model,
                                                   cooling_tower_type: 'Open Cooling Tower',
                                                   cooling_tower_fan_type: 'Centrifugal',
                                                   cooling_tower_capacity_control: 'Fan Cycling',
                                                   number_of_cells_per_tower: 2,
                                                   number_cooling_towers: num_chillers)
        end
        chilled_water_loop = model_add_chw_loop(model,
                                                cooling_fuel: 'Electricity',
                                                dsgn_sup_wtr_temp: system['chilled_water_design_supply_water_temperature'],
                                                dsgn_sup_wtr_temp_delt: system['chilled_water_design_supply_water_temperature_delta'],
                                                chw_pumping_type: system['chw_pumping_type'],
                                                chiller_cooling_type: system['chiller_cooling_type'],
                                                chiller_condenser_type: system['chiller_condenser_type'],
                                                chiller_compressor_type: system['chiller_compressor_type'],
                                                num_chillers: num_chillers,
                                                condenser_water_loop: condenser_water_loop)
      end
      model_add_doas_cold_supply(model,
                                 thermal_zones,
                                 system_name: system['name'],
                                 hot_water_loop: hot_water_loop,
                                 chilled_water_loop: chilled_water_loop,
                                 hvac_op_sch: system['operation_schedule'],
                                 min_oa_sch: system['oa_damper_schedule'],
                                 min_frac_oa_sch: system['minimum_fraction_of_outdoor_air_schedule'],
                                 fan_maximum_flow_rate: system['fan_maximum_flow_rate'],
                                 econo_ctrl_mthd: system['economizer_control_method'],
                                 doas_control_strategy: system['doas_control_strategy'],
                                 clg_dsgn_sup_air_temp: system['cooling_design_supply_air_temperature'],
                                 htg_dsgn_sup_air_temp: system['heating_design_supply_air_temperature'])

      model_add_four_pipe_fan_coil(model,
                                   thermal_zones,
                                   chilled_water_loop,
                                   hot_water_loop: hot_water_loop,
                                   ventilation: false)

    when 'Packaged DOAS'
      # Retrieve the existing hot water loop or add a new one if necessary.
      hot_water_loop = nil
      hot_water_loop = if model.getPlantLoopByName('Hot Water Loop').is_initialized
                         model.getPlantLoopByName('Hot Water Loop').get
                       else
                         model_add_hw_loop(model, 'NaturalGas')
                       end
      # check inputs
      doas_type = system['doas_type'] || 'DOASCV'
      econo_ctrl_mthd = system['economizer_control_method'] || 'NoEconomizer'
      doas_control_strategy = system['doas_control_strategy'] || 'NeutralSupplyAir'
      clg_dsgn_sup_air_temp = system['cooling_design_supply_air_temperature'] || 60.0
      htg_dsgn_sup_air_temp = system['heating_design_supply_air_temperature'] || 70.0

      # for boolean input, this makes sure we get the correct input translation
      if system['include_exhaust_fan'].nil? || true?(system['include_exhaust_fan'])
        include_exhaust_fan = true
      else
        include_exhaust_fan = false
      end
      if true?(system['demand_control_ventilation'])
        demand_control_ventilation = true
      else
        demand_control_ventilation = false
      end

      model_add_doas(model,
                     thermal_zones,
                     system_name: system['name'],
                     doas_type: doas_type,
                     hot_water_loop: hot_water_loop,
                     chilled_water_loop: nil,
                     hvac_op_sch: system['operation_schedule'],
                     min_oa_sch: system['oa_damper_schedule'],
                     min_frac_oa_sch: system['minimum_fraction_of_outdoor_air_schedule'],
                     fan_maximum_flow_rate: system['fan_maximum_flow_rate'],
                     econo_ctrl_mthd: econo_ctrl_mthd,
                     include_exhaust_fan: include_exhaust_fan,
                     demand_control_ventilation: demand_control_ventilation,
                     doas_control_strategy: doas_control_strategy,
                     clg_dsgn_sup_air_temp: clg_dsgn_sup_air_temp,
                     htg_dsgn_sup_air_temp: htg_dsgn_sup_air_temp)

    when 'DC' # Data Center in Large Office building
      # Retrieve the existing hot water loop or add a new one if necessary.
      hot_water_loop = model_get_or_add_hot_water_loop(model, 'NaturalGas')

      # Set heat pump loop cooling type to CoolingTowerTwoSpeed if not specified in system hash
      heat_pump_loop_cooling_type = system['heat_pump_loop_cooling_type'].nil? ? 'CoolingTowerTwoSpeed' : system['heat_pump_loop_cooling_type']

      heat_pump_loop = model_get_or_add_heat_pump_loop(model, 'NaturalGas', 'Electricity',
                                                       heat_pump_loop_cooling_type: heat_pump_loop_cooling_type)
      model_add_data_center_hvac(model,
                                 thermal_zones,
                                 hot_water_loop,
                                 heat_pump_loop,
                                 hvac_op_sch: system['flow_fraction_schedule'],
                                 oa_damper_sch: system['flow_fraction_schedule'],
                                 main_data_center: system['main_data_center'])

    when 'CRAC' # Small Data Center
      model_add_crac(model,
                     thermal_zones,
                     climate_zone,
                     system_name: system['name'],
                     hvac_op_sch: system['CRAC_operation_schedule'],
                     oa_damper_sch: system['CRAC_oa_damper_schedule'],
                     fan_location: 'DrawThrough',
                     fan_type: system['CRAC_fan_type'],
                     cooling_type: system['CRAC_cooling_type'],
                     supply_temp_sch: nil)

    when 'CRAH' # Large Data Center (standalone)
      # Retrieve the existing chilled water loop or add a new one if necessary.
      chilled_water_loop = nil
      if model.getPlantLoopByName('Chilled Water Loop').is_initialized
        chilled_water_loop = model.getPlantLoopByName('Chilled Water Loop').get
      else
        condenser_water_loop = nil
        if system['chiller_cooling_type'] == 'WaterCooled'
          condenser_water_loop = model_add_cw_loop(model,
                                                   cooling_tower_type: 'Open Cooling Tower',
                                                   cooling_tower_fan_type: 'Centrifugal',
                                                   cooling_tower_capacity_control: 'Fan Cycling',
                                                   number_of_cells_per_tower: 2,
                                                   number_cooling_towers: 1)
        end
        chilled_water_loop = model_add_chw_loop(model,
                                                cooling_fuel: 'Electricity',
                                                dsgn_sup_wtr_temp: system['chilled_water_design_supply_water_temperature'],
                                                dsgn_sup_wtr_temp_delt: system['chilled_water_design_supply_water_temperature_delta'],
                                                chw_pumping_type: system['chw_pumping_type'],
                                                chiller_cooling_type: system['chiller_cooling_type'],
                                                chiller_condenser_type: system['chiller_condenser_type'],
                                                chiller_compressor_type: system['chiller_compressor_type'],
                                                condenser_water_loop: condenser_water_loop,
                                                waterside_economizer: system['waterside_economizer'])
      end
      model_add_crah(model,
                     thermal_zones,
                     system_name: system['name'],
                     chilled_water_loop: chilled_water_loop,
                     hvac_op_sch: system['operation_schedule'],
                     oa_damper_sch: system['oa_damper_schedule'],
                     return_plenum: nil,
                     supply_temp_sch: nil)

    when 'SAC'
      model_add_split_ac(model,
                         thermal_zones,
                         cooling_type: system['cooling_type'],
                         heating_type: system['heating_type'],
                         supplemental_heating_type: system['supplemental_heating_type'],
                         fan_type: system['fan_type'],
                         hvac_op_sch: system['operation_schedule'],
                         oa_damper_sch: system['oa_damper_schedule'],
                         econ_max_oa_frac_sch: system['econ_max_oa_frac_sch'])

    when 'UnitHeater'
      model_add_unitheater(model,
                           thermal_zones,
                           hvac_op_sch: system['operation_schedule'],
                           fan_control_type: system['fan_type'],
                           fan_pressure_rise: system['fan_static_pressure'],
                           heating_type: system['heating_type'])

    when 'PTAC'
      model_add_ptac(model,
                     thermal_zones,
                     cooling_type: system['cooling_type'],
                     heating_type: system['heating_type'],
                     fan_type: system['fan_type'])

    when 'PTHP'
      model_add_pthp(model,
                     thermal_zones,
                     fan_type: system['fan_type'])

    when 'Exhaust Fan'
      model_add_exhaust_fan(model,
                            thermal_zones,
                            flow_rate: system['flow_rate'],
                            availability_sch_name: system['operation_schedule'],
                            flow_fraction_schedule_name: system['flow_fraction_schedule'],
                            balanced_exhaust_fraction_schedule_name: system['balanced_exhaust_fraction_schedule'])

    when 'Zone Ventilation'
      model_add_zone_ventilation(model,
                                 thermal_zones,
                                 ventilation_type: system['ventilation_type'],
                                 flow_rate: system['flow_rate'],
                                 availability_sch_name: system['operation_schedule'])

    when 'Refrigeration'
      model_add_refrigeration(model,
                              system['case_type'],
                              system['cooling_capacity_per_length'],
                              system['length'],
                              system['evaporator_fan_pwr_per_length'],
                              system['lighting_per_length'],
                              system['lighting_schedule'],
                              system['defrost_pwr_per_length'],
                              system['restocking_schedule'],
                              system['cop'],
                              system['cop_f_of_t_curve_name'],
                              system['condenser_fan_pwr'],
                              system['condenser_fan_pwr_curve_name'],
                              thermal_zones[0])

    # When multiple cases and walk-ins asssigned to a system
    when 'Refrigeration_system'
      model_add_refrigeration_system(model,
                                     system['compressor_type'],
                                     system['name'],
                                     system['cases'],
                                     system['walkins'],
                                     thermal_zones[0])

    when 'WSHP'
      condenser_loop = case system['heating_type']
                       when 'Gas'
                         model_get_or_add_heat_pump_loop(model,
                                                         system['heating_type'],
                                                         system['cooling_type'],
                                                         heat_pump_loop_cooling_type: 'CoolingTowerTwoSpeed')
                       else
                         model_get_or_add_ambient_water_loop(model)
                       end
      model_add_water_source_hp(model,
                                thermal_zones,
                                condenser_loop,
                                ventilation: true)

    when 'Fan Coil'
      case system['heating_type']
      when 'Gas', 'DistrictHeating', 'Electricity'
        hot_water_loop = model_get_or_add_hot_water_loop(model, system['heating_type'])
      when nil
        hot_water_loop = nil
      end
      case system['cooling_type']
      when 'Electricity', 'DistrictCooling'
        chilled_water_loop = model_get_or_add_chilled_water_loop(model, system['cooling_type'], chilled_water_loop_cooling_type: 'AirCooled')
      when nil
        chilled_water_loop = nil
      end
      model_add_four_pipe_fan_coil(model,
                                   thermal_zones,
                                   chilled_water_loop,
                                   hot_water_loop: hot_water_loop,
                                   ventilation: true)

    when 'Baseboards'
      case system['heating_type']
      when 'Gas', 'DistrictHeating'
        hot_water_loop = model_get_or_add_hot_water_loop(model, system['heating_type'])
      when 'Electricity'
        hot_water_loop = nil
      when nil
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'Baseboards must have heating_type specified.')
      end
      model_add_baseboard(model,
                          thermal_zones,
                          hot_water_loop: hot_water_loop)

    when 'Unconditioned'
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'System type is Unconditioned.  No system will be added.')

    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "System type '#{system['type']}' is not recognized for system named '#{system['name']}'.  This system will not be added.")

    end
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Finished adding HVAC')

  return true
end

#model_add_hvac_system(model, system_type, main_heat_fuel, zone_heat_fuel, cool_fuel, zones, hot_water_loop_type: 'HighTemperature', chilled_water_loop_cooling_type: 'WaterCooled', heat_pump_loop_cooling_type: 'EvaporativeFluidCooler', air_loop_heating_type: 'Water', air_loop_cooling_type: 'Water', zone_equipment_ventilation: true, fan_coil_capacity_control_method: 'CyclingFan') ⇒ Bool

Add the specified system type to the specified zones based on the specified template. For multi-zone system types, add one system per story.

Parameters:

  • system_type (String)

    The system type

  • main_heat_fuel (String)

    Main heating fuel used for air loops and plant loops

  • zone_heat_fuel (String)

    Zone heating fuel for zone hvac equipment and terminal units

  • cool_fuel (String)

    Cooling fuel used for air loops, plant loops, and zone equipment

  • zones (Array<OpenStudio::Model::ThermalZone>)

    array of thermal zones served by the system

  • hot_water_loop_type (String) (defaults to: 'HighTemperature')

    Archetype for hot water loops HighTemperature (180F supply) (default) or LowTemperature (120F supply) only used if HVAC system has a hot water loop

  • chilled_water_loop_cooling_type (String) (defaults to: 'WaterCooled')

    Archetype for chilled water loops, AirCooled or WaterCooled only used if HVAC system has a chilled water loop and cool_fuel is Electricity

  • heat_pump_loop_cooling_type (String) (defaults to: 'EvaporativeFluidCooler')

    the type of cooling equipment for heat pump loops if not DistrictCooling. Valid options are: CoolingTower, CoolingTowerSingleSpeed, CoolingTowerTwoSpeed, CoolingTowerVariableSpeed, FluidCooler, FluidCoolerSingleSpeed, FluidCoolerTwoSpeed, EvaporativeFluidCooler, EvaporativeFluidCoolerSingleSpeed, EvaporativeFluidCoolerTwoSpeed

  • air_loop_heating_type (String) (defaults to: 'Water')

    type of heating coil serving main air loop, options are Gas, DX, or Water

  • air_loop_cooling_type (String) (defaults to: 'Water')

    type of cooling coil serving main air loop, options are DX or Water

  • zone_equipment_ventilation (Bool) (defaults to: true)

    toggle whether to include outdoor air ventilation on zone equipment including as fan coil units, VRF terminals, or water source heat pumps.

  • fan_coil_capacity_control_method (String) (defaults to: 'CyclingFan')

    Only applicable to Fan Coil system type. Capacity control method for the fan coil. Options are ConstantFanVariableFlow, CyclingFan, VariableFanVariableFlow, and VariableFanConstantFlow. If VariableFan, the fan will be VariableVolume.

Returns:

  • (Bool)

    returns true if successful, false if not



5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5805

def model_add_hvac_system(model,
                          system_type,
                          main_heat_fuel,
                          zone_heat_fuel,
                          cool_fuel,
                          zones,
                          hot_water_loop_type: 'HighTemperature',
                          chilled_water_loop_cooling_type: 'WaterCooled',
                          heat_pump_loop_cooling_type: 'EvaporativeFluidCooler',
                          air_loop_heating_type: 'Water',
                          air_loop_cooling_type: 'Water',
                          zone_equipment_ventilation: true,
                          fan_coil_capacity_control_method: 'CyclingFan')

  # enforce defaults if fields are nil
  hot_water_loop_type = 'HighTemperature' if hot_water_loop_type.nil?
  chilled_water_loop_cooling_type = 'WaterCooled' if chilled_water_loop_cooling_type.nil?
  heat_pump_loop_cooling_type = 'EvaporativeFluidCooler' if heat_pump_loop_cooling_type.nil?
  air_loop_heating_type = 'Water' if air_loop_heating_type.nil?
  air_loop_cooling_type = 'Water' if air_loop_cooling_type.nil?
  zone_equipment_ventilation = true if zone_equipment_ventilation.nil?
  fan_coil_capacity_control_method = 'CyclingFan' if fan_coil_capacity_control_method.nil?

  # don't do anything if there are no zones
  return true if zones.empty?

  case system_type
  when 'PTAC'
    case main_heat_fuel
    when 'NaturalGas', 'DistrictHeating'
      heating_type = 'Water'
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                       hot_water_loop_type: hot_water_loop_type)
    when 'AirSourceHeatPump'
      heating_type = 'Water'
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                       hot_water_loop_type: 'LowTemperature')
    when 'Electricity'
      heating_type = main_heat_fuel
      hot_water_loop = nil
    else
      heating_type = zone_heat_fuel
      hot_water_loop = nil
    end

    model_add_ptac(model,
                   zones,
                   cooling_type: 'Single Speed DX AC',
                   heating_type: heating_type,
                   hot_water_loop: hot_water_loop,
                   fan_type: 'Cycling',
                   ventilation: zone_equipment_ventilation)

  when 'PTHP'
    model_add_pthp(model,
                   zones,
                   fan_type: 'Cycling',
                   ventilation: zone_equipment_ventilation)

  when 'PSZ-AC'
    case main_heat_fuel
    when 'NaturalGas', 'Gas'
      heating_type = main_heat_fuel
      supplemental_heating_type = 'Electricity'
      if air_loop_heating_type == 'Water'
        hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                         hot_water_loop_type: hot_water_loop_type)
      else
        hot_water_loop = nil
      end
    when 'DistrictHeating'
      heating_type = 'Water'
      supplemental_heating_type = 'Electricity'
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                       hot_water_loop_type: hot_water_loop_type)
    when 'AirSourceHeatPump', 'ASHP'
      heating_type = 'Water'
      supplemental_heating_type = 'Electricity'
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                       hot_water_loop_type: 'LowTemperature')
    when 'Electricity'
      heating_type = main_heat_fuel
      supplemental_heating_type = 'Electricity'
    else
      heating_type = zone_heat_fuel
      supplemental_heating_type = nil
      hot_water_loop = nil
    end

    case cool_fuel
    when 'DistrictCooling'
      chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel)
      cooling_type = 'Water'
    else
      chilled_water_loop = nil
      cooling_type = 'Single Speed DX AC'
    end

    model_add_psz_ac(model,
                     zones,
                     cooling_type: cooling_type,
                     chilled_water_loop: chilled_water_loop,
                     hot_water_loop: hot_water_loop,
                     heating_type: heating_type,
                     supplemental_heating_type: supplemental_heating_type,
                     fan_location: 'DrawThrough',
                     fan_type: 'ConstantVolume')

  when 'PSZ-HP'
    model_add_psz_ac(model,
                     zones,
                     system_name: 'PSZ-HP',
                     cooling_type: 'Single Speed Heat Pump',
                     heating_type: 'Single Speed Heat Pump',
                     supplemental_heating_type: 'Electricity',
                     fan_location: 'DrawThrough',
                     fan_type: 'ConstantVolume')

  when 'PSZ-VAV'
    if main_heat_fuel.nil?
      supplemental_heating_type = nil
    else
      supplemental_heating_type = 'Electricity'
    end
    model_add_psz_vav(model,
                      zones,
                      system_name: 'PSZ-VAV',
                      heating_type: main_heat_fuel,
                      supplemental_heating_type: supplemental_heating_type,
                      hvac_op_sch: nil,
                      oa_damper_sch: nil)

  when 'VRF'
    model_add_vrf(model,
                  zones,
                  ventilation: zone_equipment_ventilation)

  when 'Fan Coil'
    case main_heat_fuel
    when 'NaturalGas', 'DistrictHeating', 'Electricity'
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                       hot_water_loop_type: hot_water_loop_type)
    when 'AirSourceHeatPump'
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                       hot_water_loop_type: 'LowTemperature')
    else
      hot_water_loop = nil
    end

    case cool_fuel
    when 'Electricity', 'DistrictCooling'
      chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel,
                                                               chilled_water_loop_cooling_type: chilled_water_loop_cooling_type)
    else
      chilled_water_loop = nil
    end

    model_add_four_pipe_fan_coil(model,
                                 zones,
                                 chilled_water_loop,
                                 hot_water_loop: hot_water_loop,
                                 ventilation: zone_equipment_ventilation,
                                 capacity_control_method: fan_coil_capacity_control_method)

  when 'Radiant Slab'
    case main_heat_fuel
    when 'NaturalGas', 'DistrictHeating', 'Electricity'
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                       hot_water_loop_type: hot_water_loop_type)
    when 'AirSourceHeatPump'
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                       hot_water_loop_type: 'LowTemperature')
    else
      hot_water_loop = nil
    end

    case cool_fuel
    when 'Electricity', 'DistrictCooling'
      chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel,
                                                               chilled_water_loop_cooling_type: chilled_water_loop_cooling_type)
    else
      chilled_water_loop = nil
    end

    model_add_low_temp_radiant(model,
                               zones,
                               hot_water_loop,
                               chilled_water_loop)

  when 'Baseboards'
    case main_heat_fuel
    when 'NaturalGas', 'DistrictHeating'
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                       hot_water_loop_type: hot_water_loop_type)
    when 'AirSourceHeatPump'
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                       hot_water_loop_type: 'LowTemperature')
    when 'Electricity'
      hot_water_loop = nil
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'Baseboards must have heating_type specified.')
      return false
    end
    model_add_baseboard(model,
                        zones,
                        hot_water_loop: hot_water_loop)

  when 'Unit Heaters'
    model_add_unitheater(model,
                         zones,
                         hvac_op_sch: nil,
                         fan_control_type: 'ConstantVolume',
                         fan_pressure_rise: 0.2,
                         heating_type: main_heat_fuel)

  when 'High Temp Radiant'
    model_add_high_temp_radiant(model,
                                zones,
                                heating_type: main_heat_fuel,
                                combustion_efficiency: 0.8)

  when 'Window AC'
    model_add_window_ac(model,
                        zones)

  when 'Residential AC'
    model_add_furnace_central_ac(model,
                                 zones,
                                 heating: false,
                                 cooling: true,
                                 ventilation: false)

  when 'Forced Air Furnace'
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', 'If a Forced Air Furnace with ventilation serves a core zone, make sure the outdoor air is included in design sizing for the systems (typically occupancy, and therefore ventilation is zero during winter sizing), otherwise it may not be sized large enough to meet the heating load in some situations.')
    model_add_furnace_central_ac(model,
                                 zones,
                                 heating: true,
                                 cooling: false,
                                 ventilation: true)

  when 'Residential Forced Air Furnace'
    model_add_furnace_central_ac(model,
                                 zones,
                                 heating: true,
                                 cooling: false,
                                 ventilation: false)

  when 'Residential Forced Air Furnace with AC'
    model_add_furnace_central_ac(model,
                                 zones,
                                 heating: true,
                                 cooling: true,
                                 ventilation: false)

  when 'Residential Air Source Heat Pump'
    heating = true unless main_heat_fuel.nil?
    cooling = true unless cool_fuel.nil?
    model_add_central_air_source_heat_pump(model,
                                           zones,
                                           heating: heating,
                                           cooling: cooling,
                                           ventilation: false)

  when 'Residential Minisplit Heat Pumps'
    model_add_minisplit_hp(model,
                           zones)

  when 'VAV Reheat'
    case main_heat_fuel
    when 'NaturalGas', 'Gas', 'HeatPump', 'DistrictHeating'
      heating_type = main_heat_fuel
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                       hot_water_loop_type: hot_water_loop_type)
    when 'AirSourceHeatPump'
      heating_type = main_heat_fuel
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                       hot_water_loop_type: 'LowTemperature')
    else
      heating_type = 'Electricity'
      hot_water_loop = nil
    end

    case air_loop_cooling_type
    when 'Water'
      chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel,
                                                               chilled_water_loop_cooling_type: chilled_water_loop_cooling_type)
    else
      chilled_water_loop = nil
    end

    if hot_water_loop.nil?
      case zone_heat_fuel
      when 'NaturalGas', 'Gas'
        reheat_type = 'NaturalGas'
      when 'Electricity'
        reheat_type = 'Electricity'
      else
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "zone_heat_fuel '#{zone_heat_fuel}' not supported with main_heat_fuel '#{main_heat_fuel}' for a 'VAV Reheat' system type.")
        return false
      end
    else
      reheat_type = 'Water'
    end

    model_add_vav_reheat(model,
                         zones,
                         heating_type: heating_type,
                         reheat_type: reheat_type,
                         hot_water_loop: hot_water_loop,
                         chilled_water_loop: chilled_water_loop,
                         fan_efficiency: 0.62,
                         fan_motor_efficiency: 0.9,
                         fan_pressure_rise: 4.0)

  when 'VAV No Reheat'
    case main_heat_fuel
    when 'NaturalGas', 'Gas', 'HeatPump', 'DistrictHeating'
      heating_type = main_heat_fuel
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                       hot_water_loop_type: hot_water_loop_type)
    when 'AirSourceHeatPump'
      heating_type = main_heat_fuel
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                       hot_water_loop_type: 'LowTemperature')
    else
      heating_type = 'Electricity'
      hot_water_loop = nil
    end

    if air_loop_cooling_type == 'Water'
      chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel,
                                                               chilled_water_loop_cooling_type: chilled_water_loop_cooling_type)
    else
      chilled_water_loop = nil
    end
    model_add_vav_reheat(model,
                         zones,
                         heating_type: heating_type,
                         reheat_type: nil,
                         hot_water_loop: hot_water_loop,
                         chilled_water_loop: chilled_water_loop,
                         fan_efficiency: 0.62,
                         fan_motor_efficiency: 0.9,
                         fan_pressure_rise: 4.0)

  when 'VAV Gas Reheat'
    if air_loop_cooling_type == 'Water'
      chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel,
                                                               chilled_water_loop_cooling_type: chilled_water_loop_cooling_type)
    else
      chilled_water_loop = nil
    end
    model_add_vav_reheat(model,
                         zones,
                         heating_type: 'NaturalGas',
                         reheat_type: 'NaturalGas',
                         chilled_water_loop: chilled_water_loop,
                         fan_efficiency: 0.62,
                         fan_motor_efficiency: 0.9,
                         fan_pressure_rise: 4.0)

  when 'PVAV Reheat'
    case main_heat_fuel
    when 'AirSourceHeatPump'
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                       hot_water_loop_type: 'LowTemperature')
    else
      if air_loop_heating_type == 'Water'
        hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                         hot_water_loop_type: hot_water_loop_type)
      else
        heating_type = main_heat_fuel
      end
    end

    case cool_fuel
    when 'Electricity'
      chilled_water_loop = nil
    else
      chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel,
                                                               chilled_water_loop_cooling_type: chilled_water_loop_cooling_type)
    end

    if zone_heat_fuel == 'Electricity'
      electric_reheat = true
    else
      electric_reheat = false
    end

    model_add_pvav(model,
                   zones,
                   hot_water_loop: hot_water_loop,
                   chilled_water_loop: chilled_water_loop,
                   heating_type: heating_type,
                   electric_reheat: electric_reheat)

  when 'PVAV PFP Boxes'
    case cool_fuel
    when 'DistrictCooling'
      chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel)
    else
      chilled_water_loop = nil
    end
    model_add_pvav_pfp_boxes(model,
                             zones,
                             chilled_water_loop: chilled_water_loop,
                             fan_efficiency: 0.62,
                             fan_motor_efficiency: 0.9,
                             fan_pressure_rise: 4.0)

  when 'VAV PFP Boxes'
    chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel,
                                                             chilled_water_loop_cooling_type: chilled_water_loop_cooling_type)
    model_add_pvav_pfp_boxes(model,
                             zones,
                             chilled_water_loop: chilled_water_loop,
                             fan_efficiency: 0.62,
                             fan_motor_efficiency: 0.9,
                             fan_pressure_rise: 4.0)

  when 'Water Source Heat Pumps'
    if main_heat_fuel == 'DistrictHeating' && cool_fuel == 'DistrictCooling'
      condenser_loop = model_get_or_add_ambient_water_loop(model)
    elsif main_heat_fuel == 'AmbientLoop' && cool_fuel == 'AmbientLoop'
      condenser_loop = model_get_or_add_ambient_water_loop(model)
    else
      condenser_loop = model_get_or_add_heat_pump_loop(model, main_heat_fuel, cool_fuel,
                                                       heat_pump_loop_cooling_type: heat_pump_loop_cooling_type)
    end
    model_add_water_source_hp(model,
                              zones,
                              condenser_loop,
                              ventilation: zone_equipment_ventilation)

  when 'Ground Source Heat Pumps'
    condenser_loop = model_get_or_add_ground_hx_loop(model)
    model_add_water_source_hp(model,
                              zones,
                              condenser_loop,
                              ventilation: zone_equipment_ventilation)

  when 'DOAS Cold Supply'
    hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                     hot_water_loop_type: hot_water_loop_type)
    chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel,
                                                             chilled_water_loop_cooling_type: chilled_water_loop_cooling_type)
    model_add_doas_cold_supply(model,
                               zones,
                               hot_water_loop: hot_water_loop,
                               chilled_water_loop: chilled_water_loop)

  when 'DOAS'
    if air_loop_heating_type == 'Water'
      case main_heat_fuel
      when nil
        hot_water_loop = nil
      when 'AirSourceHeatPump'
        hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                         hot_water_loop_type: 'LowTemperature')
      when 'Electricity'
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "air_loop_heating_type '#{air_loop_heating_type}' is not supported with main_heat_fuel '#{main_heat_fuel}' for a 'DOAS' system type.")
        return false
      else
        hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                         hot_water_loop_type: hot_water_loop_type)
      end
    else
      hot_water_loop = nil
    end
    if air_loop_cooling_type == 'Water'
      chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel,
                                                               chilled_water_loop_cooling_type: chilled_water_loop_cooling_type)
    else
      chilled_water_loop = nil
    end

    model_add_doas(model,
                   zones,
                   hot_water_loop: hot_water_loop,
                   chilled_water_loop: chilled_water_loop)

  when 'DOAS with DCV'
    if air_loop_heating_type == 'Water'
      case main_heat_fuel
      when nil
        hot_water_loop = nil
      when 'AirSourceHeatPump'
        hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                         hot_water_loop_type: 'LowTemperature')
      else
        hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                         hot_water_loop_type: hot_water_loop_type)
      end
    else
      hot_water_loop = nil
    end
    if air_loop_cooling_type == 'Water'
      chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel,
                                                               chilled_water_loop_cooling_type: chilled_water_loop_cooling_type)
    else
      chilled_water_loop = nil
    end

    model_add_doas(model,
                   zones,
                   hot_water_loop: hot_water_loop,
                   chilled_water_loop: chilled_water_loop,
                   doas_type: 'DOASVAV',
                   demand_control_ventilation: true)

  when 'DOAS with Economizing'
    if air_loop_heating_type == 'Water'
      case main_heat_fuel
      when nil
        hot_water_loop = nil
      when 'AirSourceHeatPump'
        hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                         hot_water_loop_type: 'LowTemperature')
      else
        hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel,
                                                         hot_water_loop_type: hot_water_loop_type)
      end
    else
      hot_water_loop = nil
    end
    if air_loop_cooling_type == 'Water'
      chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel,
                                                               chilled_water_loop_cooling_type: chilled_water_loop_cooling_type)
    else
      chilled_water_loop = nil
    end

    model_add_doas(model,
                   zones,
                   hot_water_loop: hot_water_loop,
                   chilled_water_loop: chilled_water_loop,
                   doas_type: 'DOASVAV',
                   econo_ctrl_mthd: 'FixedDryBulb')

  when 'ERVs'
    model_add_zone_erv(model, zones)

  when 'Evaporative Cooler'
    model_add_evap_cooler(model, zones)

  when 'Ideal Air Loads'
    model_add_ideal_air_loads(model, zones)

  else
    # Combination Systems
    if system_type.include? 'with DOAS with DCV'
      # add DOAS DCV system
      model_add_hvac_system(model, 'DOAS with DCV', main_heat_fuel, zone_heat_fuel, cool_fuel, zones,
                            hot_water_loop_type: hot_water_loop_type,
                            chilled_water_loop_cooling_type: chilled_water_loop_cooling_type,
                            heat_pump_loop_cooling_type: heat_pump_loop_cooling_type,
                            air_loop_heating_type: air_loop_heating_type,
                            air_loop_cooling_type: air_loop_cooling_type,
                            zone_equipment_ventilation: false,
                            fan_coil_capacity_control_method: fan_coil_capacity_control_method)
      # add paired system type
      paired_system_type = system_type.gsub(' with DOAS with DCV', '')
      model_add_hvac_system(model, paired_system_type, main_heat_fuel, zone_heat_fuel, cool_fuel, zones,
                            hot_water_loop_type: hot_water_loop_type,
                            chilled_water_loop_cooling_type: chilled_water_loop_cooling_type,
                            heat_pump_loop_cooling_type: heat_pump_loop_cooling_type,
                            air_loop_heating_type: air_loop_heating_type,
                            air_loop_cooling_type: air_loop_cooling_type,
                            zone_equipment_ventilation: false,
                            fan_coil_capacity_control_method: fan_coil_capacity_control_method)
    elsif system_type.include? 'with DOAS'
      # add DOAS system
      model_add_hvac_system(model, 'DOAS', main_heat_fuel, zone_heat_fuel, cool_fuel, zones,
                            hot_water_loop_type: hot_water_loop_type,
                            chilled_water_loop_cooling_type: chilled_water_loop_cooling_type,
                            heat_pump_loop_cooling_type: heat_pump_loop_cooling_type,
                            air_loop_heating_type: air_loop_heating_type,
                            air_loop_cooling_type: air_loop_cooling_type,
                            zone_equipment_ventilation: false,
                            fan_coil_capacity_control_method: fan_coil_capacity_control_method)
      # add paired system type
      paired_system_type = system_type.gsub(' with DOAS', '')
      model_add_hvac_system(model, paired_system_type, main_heat_fuel, zone_heat_fuel, cool_fuel, zones,
                            hot_water_loop_type: hot_water_loop_type,
                            chilled_water_loop_cooling_type: chilled_water_loop_cooling_type,
                            heat_pump_loop_cooling_type: heat_pump_loop_cooling_type,
                            air_loop_heating_type: air_loop_heating_type,
                            air_loop_cooling_type: air_loop_cooling_type,
                            zone_equipment_ventilation: false,
                            fan_coil_capacity_control_method: fan_coil_capacity_control_method)
    elsif system_type.include? 'with ERVs'
      # add DOAS system
      model_add_hvac_system(model, 'ERVs', main_heat_fuel, zone_heat_fuel, cool_fuel, zones,
                            hot_water_loop_type: hot_water_loop_type,
                            chilled_water_loop_cooling_type: chilled_water_loop_cooling_type,
                            heat_pump_loop_cooling_type: heat_pump_loop_cooling_type,
                            air_loop_heating_type: air_loop_heating_type,
                            air_loop_cooling_type: air_loop_cooling_type,
                            zone_equipment_ventilation: false,
                            fan_coil_capacity_control_method: fan_coil_capacity_control_method)
      # add paired system type
      paired_system_type = system_type.gsub(' with ERVs', '')
      model_add_hvac_system(model, paired_system_type, main_heat_fuel, zone_heat_fuel, cool_fuel, zones,
                            hot_water_loop_type: hot_water_loop_type,
                            chilled_water_loop_cooling_type: chilled_water_loop_cooling_type,
                            heat_pump_loop_cooling_type: heat_pump_loop_cooling_type,
                            air_loop_heating_type: air_loop_heating_type,
                            air_loop_cooling_type: air_loop_cooling_type,
                            zone_equipment_ventilation: false,
                            fan_coil_capacity_control_method: fan_coil_capacity_control_method)
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "HVAC system type '#{system_type}' not recognized")
      return false
    end
  end

  # rename air loop and plant loop nodes for readability
  rename_air_loop_nodes(model)
  rename_plant_loop_nodes(model)
end

#model_add_hw_loop(model, boiler_fuel_type, ambient_loop: nil, system_name: 'Hot Water Loop', dsgn_sup_wtr_temp: 180.0, dsgn_sup_wtr_temp_delt: 20.0, pump_spd_ctrl: 'Variable', pump_tot_hd: nil, boiler_draft_type: nil, boiler_eff_curve_temp_eval_var: nil, boiler_lvg_temp_dsgn: nil, boiler_out_temp_lmt: nil, boiler_max_plr: nil, boiler_sizing_factor: nil) ⇒ OpenStudio::Model::PlantLoop

Creates a hot water loop with a boiler, district heating, or a water-to-water heat pump and adds it to the model.

Parameters:

  • boiler_fuel_type (String)

    valid choices are Electricity, NaturalGas, PropaneGas, FuelOilNo1, FuelOilNo2, DistrictHeating, HeatPump

  • ambient_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    The condenser loop for the heat pump. Only used when boiler_fuel_type is HeatPump.

  • system_name (String) (defaults to: 'Hot Water Loop')

    the name of the system, or nil in which case it will be defaulted

  • dsgn_sup_wtr_temp (Double) (defaults to: 180.0)

    design supply water temperature in degrees Fahrenheit, default 180F

  • dsgn_sup_wtr_temp_delt (Double) (defaults to: 20.0)

    design supply-return water temperature difference in degrees Rankine, default 20R

  • pump_spd_ctrl (String) (defaults to: 'Variable')

    pump speed control type, Constant or Variable (default)

  • pump_tot_hd (Double) (defaults to: nil)

    pump head in ft H2O

  • boiler_draft_type (String) (defaults to: nil)

    Boiler type Condensing, MechanicalNoncondensing, Natural (default)

  • boiler_eff_curve_temp_eval_var (String) (defaults to: nil)

    LeavingBoiler or EnteringBoiler temperature for the boiler efficiency curve

  • boiler_lvg_temp_dsgn (Double) (defaults to: nil)

    boiler leaving design temperature in degrees Fahrenheit

  • boiler_out_temp_lmt (Double) (defaults to: nil)

    boiler outlet temperature limit in degrees Fahrenheit

  • boiler_max_plr (Double) (defaults to: nil)

    boiler maximum part load ratio

  • boiler_sizing_factor (Double) (defaults to: nil)

    boiler oversizing factor

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 41

def model_add_hw_loop(model,
                      boiler_fuel_type,
                      ambient_loop: nil,
                      system_name: 'Hot Water Loop',
                      dsgn_sup_wtr_temp: 180.0,
                      dsgn_sup_wtr_temp_delt: 20.0,
                      pump_spd_ctrl: 'Variable',
                      pump_tot_hd: nil,
                      boiler_draft_type: nil,
                      boiler_eff_curve_temp_eval_var: nil,
                      boiler_lvg_temp_dsgn: nil,
                      boiler_out_temp_lmt: nil,
                      boiler_max_plr: nil,
                      boiler_sizing_factor: nil)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding hot water loop.')

  # create hot water loop
  hot_water_loop = OpenStudio::Model::PlantLoop.new(model)
  if system_name.nil?
    hot_water_loop.setName('Hot Water Loop')
  else
    hot_water_loop.setName(system_name)
  end

  # hot water loop sizing and controls
  if dsgn_sup_wtr_temp.nil?
    dsgn_sup_wtr_temp = 180.0
    dsgn_sup_wtr_temp_c = OpenStudio.convert(dsgn_sup_wtr_temp, 'F', 'C').get
  else
    dsgn_sup_wtr_temp_c = OpenStudio.convert(dsgn_sup_wtr_temp, 'F', 'C').get
  end
  if dsgn_sup_wtr_temp_delt.nil?
    dsgn_sup_wtr_temp_delt_k = OpenStudio.convert(20.0, 'R', 'K').get
  else
    dsgn_sup_wtr_temp_delt_k = OpenStudio.convert(dsgn_sup_wtr_temp_delt, 'R', 'K').get
  end

  sizing_plant = hot_water_loop.sizingPlant
  sizing_plant.setLoopType('Heating')
  sizing_plant.setDesignLoopExitTemperature(dsgn_sup_wtr_temp_c)
  sizing_plant.setLoopDesignTemperatureDifference(dsgn_sup_wtr_temp_delt_k)
  hot_water_loop.setMinimumLoopTemperature(10.0)
  hw_temp_sch = model_add_constant_schedule_ruleset(model,
                                                    dsgn_sup_wtr_temp_c,
                                                    name = "#{hot_water_loop.name} Temp - #{dsgn_sup_wtr_temp.round(0)}F")
  hw_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, hw_temp_sch)
  hw_stpt_manager.setName("#{hot_water_loop.name} Setpoint Manager")
  hw_stpt_manager.addToNode(hot_water_loop.supplyOutletNode)

  # create hot water pump
  if pump_spd_ctrl == 'Constant'
    hw_pump = OpenStudio::Model::PumpConstantSpeed.new(model)
  elsif pump_spd_ctrl == 'Variable'
    hw_pump = OpenStudio::Model::PumpVariableSpeed.new(model)
  else
    hw_pump = OpenStudio::Model::PumpVariableSpeed.new(model)
  end
  hw_pump.setName("#{hot_water_loop.name} Pump")
  if pump_tot_hd.nil?
    pump_tot_hd_pa = OpenStudio.convert(60, 'ftH_{2}O', 'Pa').get
  else
    pump_tot_hd_pa = OpenStudio.convert(pump_tot_hd, 'ftH_{2}O', 'Pa').get
  end
  hw_pump.setRatedPumpHead(pump_tot_hd_pa)
  hw_pump.setMotorEfficiency(0.9)
  hw_pump.setPumpControlType('Intermittent')
  hw_pump.addToNode(hot_water_loop.supplyInletNode)

  # create boiler and add to loop
  case boiler_fuel_type
    # District Heating
    when 'DistrictHeating'
      district_heat = OpenStudio::Model::DistrictHeating.new(model)
      district_heat.setName("#{hot_water_loop.name} District Heating")
      district_heat.autosizeNominalCapacity
      hot_water_loop.addSupplyBranchForComponent(district_heat)
    # Ambient Loop
    when 'HeatPump', 'AmbientLoop'
      water_to_water_hp = OpenStudio::Model::HeatPumpWaterToWaterEquationFitHeating.new(model)
      water_to_water_hp.setName("#{hot_water_loop.name} Water to Water Heat Pump")
      hot_water_loop.addSupplyBranchForComponent(water_to_water_hp)
      # Get or add an ambient loop
      if ambient_loop.nil?
        ambient_loop = model_get_or_add_ambient_water_loop(model)
      end
      ambient_loop.addDemandBranchForComponent(water_to_water_hp)
    # Central Air Source Heat Pump
    when 'AirSourceHeatPump', 'ASHP'
      create_central_air_source_heat_pump(model, hot_water_loop)
    # Boiler
    when 'Electricity', 'Gas', 'NaturalGas', 'PropaneGas', 'FuelOilNo1', 'FuelOilNo2'
      if boiler_lvg_temp_dsgn.nil?
        lvg_temp_dsgn = dsgn_sup_wtr_temp
      else
        lvg_temp_dsgn = boiler_lvg_temp_dsgn
      end

      if boiler_out_temp_lmt.nil?
        out_temp_lmt = OpenStudio.convert(203.0, 'F', 'C').get
      else
        out_temp_lmt = boiler_out_temp_lmt
      end

      boiler = create_boiler_hot_water(model,
                                       hot_water_loop: hot_water_loop,
                                       fuel_type: boiler_fuel_type,
                                       draft_type: boiler_draft_type,
                                       nominal_thermal_efficiency: 0.78,
                                       eff_curve_temp_eval_var: boiler_eff_curve_temp_eval_var,
                                       lvg_temp_dsgn: lvg_temp_dsgn,
                                       out_temp_lmt: out_temp_lmt,
                                       max_plr: boiler_max_plr,
                                       sizing_factor: boiler_sizing_factor)

      # TODO: Yixing. Adding temperature setpoint controller at boiler outlet causes simulation errors
      # boiler_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(self, hw_temp_sch)
      # boiler_stpt_manager.setName("Boiler outlet setpoint manager")
      # boiler_stpt_manager.addToNode(boiler.outletModelObject.get.to_Node.get)
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Boiler fuel type #{boiler_fuel_type} is not valid, no boiler will be added.")
  end

  # add hot water loop pipes
  supply_equipment_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  supply_equipment_bypass_pipe.setName("#{hot_water_loop.name} Supply Equipment Bypass")
  hot_water_loop.addSupplyBranchForComponent(supply_equipment_bypass_pipe)

  coil_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  coil_bypass_pipe.setName("#{hot_water_loop.name} Coil Bypass")
  hot_water_loop.addDemandBranchForComponent(coil_bypass_pipe)

  supply_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  supply_outlet_pipe.setName("#{hot_water_loop.name} Supply Outlet")
  supply_outlet_pipe.addToNode(hot_water_loop.supplyOutletNode)

  demand_inlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_inlet_pipe.setName("#{hot_water_loop.name} Demand Inlet")
  demand_inlet_pipe.addToNode(hot_water_loop.demandInletNode)

  demand_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_outlet_pipe.setName("#{hot_water_loop.name} Demand Outlet")
  demand_outlet_pipe.addToNode(hot_water_loop.demandOutletNode)

  return hot_water_loop
end

#model_add_ideal_air_loads(model, thermal_zones, hvac_op_sch: nil, heat_avail_sch: nil, cool_avail_sch: nil, heat_limit_type: 'NoLimit', cool_limit_type: 'NoLimit', dehumid_limit_type: 'ConstantSensibleHeatRatio', cool_sensible_heat_ratio: 0.7, humid_ctrl_type: 'None', include_outdoor_air: true, enable_dcv: false, econo_ctrl_mthd: 'NoEconomizer', heat_recovery_type: 'None', heat_recovery_sensible_eff: 0.7, heat_recovery_latent_eff: 0.65, add_output_meters: false) ⇒ Array<OpenStudio::Model::ZoneHVACIdealLoadsAirSystem>

Adds ideal air loads systems for each zone.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to enable ideal air loads

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule, default is always on

  • heat_avail_sch (String) (defaults to: nil)

    name of the heating availability schedule, default is always on

  • cool_avail_sch (String) (defaults to: nil)

    name of the cooling availability schedule, default is always on

  • heat_limit_type (String) (defaults to: 'NoLimit')

    heating limit type options are ‘NoLimit’, ‘LimitFlowRate’, ‘LimitCapacity’, and ‘LimitFlowRateAndCapacity’

  • cool_limit_type (String) (defaults to: 'NoLimit')

    cooling limit type options are ‘NoLimit’, ‘LimitFlowRate’, ‘LimitCapacity’, and ‘LimitFlowRateAndCapacity’

  • dehumid_limit_type (String) (defaults to: 'ConstantSensibleHeatRatio')

    dehumidification limit type options are ‘None’, ‘ConstantSensibleHeatRatio’, ‘Humidistat’, ‘ConstantSupplyHumidityRatio’

  • cool_sensible_heat_ratio (Double) (defaults to: 0.7)

    cooling sensible heat ratio if dehumidification limit type is ‘ConstantSensibleHeatRatio’

  • humid_ctrl_type (String) (defaults to: 'None')

    humidification control type options are ‘None’, ‘Humidistat’, ‘ConstantSupplyHumidityRatio’

  • include_outdoor_air (Boolean) (defaults to: true)

    include design specification outdoor air ventilation

  • enable_dcv (Boolean) (defaults to: false)

    include demand control ventilation, uses occupancy schedule if true

  • econo_ctrl_mthd (String) (defaults to: 'NoEconomizer')

    economizer control method (require a cool_limit_type and include_outdoor_air set to true) options are ‘NoEconomizer’, ‘DifferentialDryBulb’, ‘DifferentialEnthalpy’

  • heat_recovery_type (String) (defaults to: 'None')

    heat recovery type options are ‘None’, ‘Sensible’, ‘Enthalpy’

  • heat_recovery_sensible_eff (Double) (defaults to: 0.7)

    heat recovery sensible effectivness if heat recovery specified

  • heat_recovery_latent_eff (Double) (defaults to: 0.65)

    heat recovery latent effectivness if heat recovery specified

  • add_output_meters (Boolean) (defaults to: false)

    include and output custom meter objects to sum all ideal air loads values

Returns:



5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5218

def model_add_ideal_air_loads(model,
                              thermal_zones,
                              hvac_op_sch: nil,
                              heat_avail_sch: nil,
                              cool_avail_sch: nil,
                              heat_limit_type: 'NoLimit',
                              cool_limit_type: 'NoLimit',
                              dehumid_limit_type: 'ConstantSensibleHeatRatio',
                              cool_sensible_heat_ratio: 0.7,
                              humid_ctrl_type: 'None',
                              include_outdoor_air: true,
                              enable_dcv: false,
                              econo_ctrl_mthd: 'NoEconomizer',
                              heat_recovery_type: 'None',
                              heat_recovery_sensible_eff: 0.7,
                              heat_recovery_latent_eff: 0.65,
                              add_output_meters: false)

  # set availability schedules
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # set heating availability schedules
  if heat_avail_sch.nil?
    heat_avail_sch = model.alwaysOnDiscreteSchedule
  else
    heat_avail_sch = model_add_schedule(model, heat_avail_sch)
  end

  # set cooling availability schedules
  if cool_avail_sch.nil?
    cool_avail_sch = model.alwaysOnDiscreteSchedule
  else
    cool_avail_sch = model_add_schedule(model, cool_avail_sch)
  end

  ideal_systems = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding ideal air loads for for #{zone.name}.")
    ideal_loads = OpenStudio::Model::ZoneHVACIdealLoadsAirSystem.new(model)
    ideal_loads.setName("#{zone.name} Ideal Loads Air System")
    ideal_loads.setAvailabilitySchedule(hvac_op_sch)
    ideal_loads.setHeatingAvailabilitySchedule(heat_avail_sch)
    ideal_loads.setCoolingAvailabilitySchedule(cool_avail_sch)
    ideal_loads.setHeatingLimit(heat_limit_type)
    ideal_loads.setCoolingLimit(cool_limit_type)
    ideal_loads.setDehumidificationControlType(dehumid_limit_type)
    ideal_loads.setCoolingSensibleHeatRatio(cool_sensible_heat_ratio)
    ideal_loads.setHumidificationControlType(humid_ctrl_type)
    if include_outdoor_air
      # get the design specification outdoor air of the largest space in the zone
      # TODO: create a new design specification outdoor air object that sums ventilation rates and schedules if multiple design specification outdoor air objects
      space_areas = zone.spaces.map(&:floorArea)
      largest_space = zone.spaces.select { |s| s.floorArea == space_areas.max }
      largest_space = largest_space[0]
      design_spec_oa = largest_space.designSpecificationOutdoorAir
      if design_spec_oa.is_initialized
        design_spec_oa = design_spec_oa.get
        ideal_loads.setDesignSpecificationOutdoorAirObject(design_spec_oa)
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "Outdoor air requested for ideal loads object, but space #{largest_space.name} in thermal zone #{zone.name} does not have a design specification outdoor air object.")
      end
    end
    if enable_dcv
      ideal_loads.setDemandControlledVentilationType('OccupancySchedule')
    else
      ideal_loads.setDemandControlledVentilationType('None')
    end
    ideal_loads.setOutdoorAirEconomizerType(econo_ctrl_mthd)
    ideal_loads.setHeatRecoveryType(heat_recovery_type)
    ideal_loads.setSensibleHeatRecoveryEffectiveness(heat_recovery_sensible_eff)
    ideal_loads.setLatentHeatRecoveryEffectiveness(heat_recovery_latent_eff)
    ideal_loads.addToThermalZone(zone)
    ideal_systems << ideal_loads

    # set zone sizing parameters
    zone_sizing = zone.sizingZone
    zone_sizing.setHeatingMaximumAirFlowFraction(1.0)
  end

  if add_output_meters
    # ideal air loads system variables to include
    ideal_air_loads_system_variables = [
      'Zone Ideal Loads Supply Air Sensible Heating Energy',
      'Zone Ideal Loads Supply Air Latent Heating Energy',
      'Zone Ideal Loads Supply Air Total Heating Energy',
      'Zone Ideal Loads Supply Air Sensible Cooling Energy',
      'Zone Ideal Loads Supply Air Latent Cooling Energy',
      'Zone Ideal Loads Supply Air Total Cooling Energy',
      'Zone Ideal Loads Zone Sensible Heating Energy',
      'Zone Ideal Loads Zone Latent Heating Energy',
      'Zone Ideal Loads Zone Total Heating Energy',
      'Zone Ideal Loads Zone Sensible Cooling Energy',
      'Zone Ideal Loads Zone Latent Cooling Energy',
      'Zone Ideal Loads Zone Total Cooling Energy',
      'Zone Ideal Loads Outdoor Air Sensible Heating Energy',
      'Zone Ideal Loads Outdoor Air Latent Heating Energy',
      'Zone Ideal Loads Outdoor Air Total Heating Energy',
      'Zone Ideal Loads Outdoor Air Sensible Cooling Energy',
      'Zone Ideal Loads Outdoor Air Latent Cooling Energy',
      'Zone Ideal Loads Outdoor Air Total Cooling Energy',
      'Zone Ideal Loads Heat Recovery Sensible Heating Energy',
      'Zone Ideal Loads Heat Recovery Latent Heating Energy',
      'Zone Ideal Loads Heat Recovery Total Heating Energy',
      'Zone Ideal Loads Heat Recovery Sensible Cooling Energy',
      'Zone Ideal Loads Heat Recovery Latent Cooling Energy',
      'Zone Ideal Loads Heat Recovery Total Cooling Energy'
    ]

    meters_added = 0
    outputs_added = 0
    ideal_air_loads_system_variables.each do |variable|
      # create meter definition for variable
      meter_definition = OpenStudio::Model::MeterCustom.new(model)
      meter_definition.setName("Sum #{variable}")
      meter_definition.setFuelType('Generic')
      model.getZoneHVACIdealLoadsAirSystems.each { |sys| meter_definition.addKeyVarGroup(sys.name.to_s, variable) }
      meters_added += 1

      # add output meter
      output_meter_definition = OpenStudio::Model::OutputMeter.new(model)
      output_meter_definition.setName("Sum #{variable}")
      output_meter_definition.setReportingFrequency('Hourly')
      output_meter_definition.setMeterFileOnly(true)
      output_meter_definition.setCumulative(false)
      outputs_added += 1
    end
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Added #{meters_added} custom meter objects and #{outputs_added} meter outputs for ideal loads air systems.")
  end

  return ideal_systems
end

#model_add_low_temp_radiant(model, thermal_zones, hot_water_loop, chilled_water_loop, radiant_type: 'floor', include_carpet: true, carpet_thickness_in: 0.25, control_strategy: 'proportional_control', proportional_gain: 0.3, minimum_operation: 1, weekend_temperature_reset: 2, early_reset_out_arg: 20, switch_over_time: 24.0, radiant_lockout: false, radiant_lockout_start_time: 12.0, radiant_lockout_end_time: 20.0) ⇒ Array<OpenStudio::Model::ZoneHVACLowTemperatureRadiantVariableFlow>

Adds low temperature radiant loop systems to each zone.

TODO - Once the OpenStudio API supports it, make chilled water loops optional for heating only systems

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to add radiant loops

  • hot_water_loop (OpenStudio::Model::PlantLoop)

    the hot water loop that serves the radiant loop.

  • chilled_water_loop (OpenStudio::Model::PlantLoop)

    the chilled water loop that serves the radiant loop.

  • radiant_type (String) (defaults to: 'floor')

    type of radiant system, floor or ceiling, to create in zone.

  • include_carpet (Bool) (defaults to: true)

    boolean to include thin carpet tile over radiant slab, default to true

  • carpet_thickness_in (Double) (defaults to: 0.25)

    thickness of carpet in inches

  • control_strategy (String) (defaults to: 'proportional_control')

    name of control strategy

  • proportional_gain (Double) (defaults to: 0.3)

    (Optional) Only applies if control_strategy is ‘proportional_control’. Proportional gain constant (recommended 0.3 or less).

  • minimum_operation (Double) (defaults to: 1)

    (Optional) Only applies if control_strategy is ‘proportional_control’. Minimum number of hours of operation for radiant system before it shuts off.

  • weekend_temperature_reset (Double) (defaults to: 2)

    (Optional) Only applies if control_strategy is ‘proportional_control’. Weekend temperature reset for slab temperature setpoint in degree Celsius.

  • early_reset_out_arg (Double) (defaults to: 20)

    (Optional) Only applies if control_strategy is ‘proportional_control’. Time at which the weekend temperature reset is removed.

  • switch_over_time (Double) (defaults to: 24.0)

    Time limitation for when the system can switch between heating and cooling

  • radiant_lockout (Bool) (defaults to: false)

    True if system contains a radiant lockout

  • radiant_lockout_start_time (double) (defaults to: 12.0)

    decimal hour of when radiant lockout starts Only used if radiant_lockout is true

  • radiant_lockout_end_time (double) (defaults to: 20.0)

    decimal hour of when radiant lockout ends Only used if radiant_lockout is true

Returns:

  • (Array<OpenStudio::Model::ZoneHVACLowTemperatureRadiantVariableFlow>)

    array of radiant objects.



4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4398

def model_add_low_temp_radiant(model,
                               thermal_zones,
                               hot_water_loop,
                               chilled_water_loop,
                               radiant_type: 'floor',
                               include_carpet: true,
                               carpet_thickness_in: 0.25,
                               control_strategy: 'proportional_control',
                               proportional_gain: 0.3,
                               minimum_operation: 1,
                               weekend_temperature_reset: 2,
                               early_reset_out_arg: 20,
                               switch_over_time: 24.0,
                               radiant_lockout: false,
                               radiant_lockout_start_time: 12.0,
                               radiant_lockout_end_time: 20.0)

  # create internal source constructions for surfaces
  OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "Replacing #{radiant_type} constructions with new radiant slab constructions.")

  # determine construction insulation thickness by climate zone
  climate_zone = model_standards_climate_zone(model)
  if climate_zone.empty?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', 'Unable to determine climate zone for radiant slab insulation determination.  Defaulting to climate zone 5, R-20 insulation, 110F heating design supply water temperature.')
    cz_mult = 4
    radiant_htg_dsgn_sup_wtr_temp_f = 110
  else
    climate_zone_set = model_find_climate_zone_set(model, climate_zone)
    case climate_zone_set.gsub('ClimateZone ', '').gsub('CEC T24 ', '')
    when '1'
      cz_mult = 2
      radiant_htg_dsgn_sup_wtr_temp_f = 90
    when '2', '2A', '2B', 'CEC15'
      cz_mult = 2
      radiant_htg_dsgn_sup_wtr_temp_f = 100
    when '3', '3A', '3B', '3C', 'CEC3', 'CEC4', 'CEC5', 'CEC6', 'CEC7', 'CEC8', 'CEC9', 'CEC10', 'CEC11', 'CEC12', 'CEC13', 'CEC14'
      cz_mult = 3
      radiant_htg_dsgn_sup_wtr_temp_f = 100
    when '4', '4A', '4B', '4C', 'CEC1', 'CEC2'
      cz_mult = 4
      radiant_htg_dsgn_sup_wtr_temp_f = 100
    when '5', '5A', '5B', '5C', 'CEC16'
      cz_mult = 4
      radiant_htg_dsgn_sup_wtr_temp_f = 110
    when '6', '6A', '6B'
      cz_mult = 4
      radiant_htg_dsgn_sup_wtr_temp_f = 120
    when '7', '8'
      cz_mult = 5
      radiant_htg_dsgn_sup_wtr_temp_f = 120
    else # default to 4
      cz_mult = 4
      radiant_htg_dsgn_sup_wtr_temp_f = 100
    end
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "Based on model climate zone #{climate_zone} using R-#{(cz_mult * 5).to_i} slab insulation, R-#{((cz_mult + 1) * 5).to_i} exterior floor insulation, R-#{((cz_mult + 1) * 2 * 5).to_i} exterior roof insulation, and #{radiant_htg_dsgn_sup_wtr_temp_f}F heating design supply water temperature.")
  end

  # create materials
  mat_concrete_3_5in = OpenStudio::Model::StandardOpaqueMaterial.new(model, 'MediumRough', 0.0889, 2.31, 2322, 832)
  mat_concrete_3_5in.setName('Radiant Slab Concrete - 3.5 in.')

  mat_concrete_1_5in = OpenStudio::Model::StandardOpaqueMaterial.new(model, 'MediumRough', 0.0381, 2.31, 2322, 832)
  mat_concrete_1_5in.setName('Radiant Slab Concrete - 1.5 in')

  mat_refl_roof_membrane = model.getStandardOpaqueMaterialByName('Roof Membrane - Highly Reflective')
  if mat_refl_roof_membrane.is_initialized
    mat_refl_roof_membrane = model.getStandardOpaqueMaterialByName('Roof Membrane - Highly Reflective').get
  else
    mat_refl_roof_membrane = OpenStudio::Model::StandardOpaqueMaterial.new(model, 'VeryRough', 0.0095, 0.16, 1121.29, 1460)
    mat_refl_roof_membrane.setThermalAbsorptance(0.75)
    mat_refl_roof_membrane.setSolarAbsorptance(0.45)
    mat_refl_roof_membrane.setVisibleAbsorptance(0.7)
    mat_refl_roof_membrane.setName('Roof Membrane - Highly Reflective')
  end

  if include_carpet
    carpet_thickness_m = OpenStudio.convert(carpet_thickness_in / 12.0, 'ft', 'm').get
    conductivity_si = 0.06
    conductivity_ip = OpenStudio.convert(conductivity_si, 'W/m*K', 'Btu*in/hr*ft^2*R').get
    r_value_ip = carpet_thickness_in * (1 / conductivity_ip)
    mat_thin_carpet_tile = OpenStudio::Model::StandardOpaqueMaterial.new(model, 'MediumRough', carpet_thickness_m, conductivity_si, 288, 1380)
    mat_thin_carpet_tile.setThermalAbsorptance(0.9)
    mat_thin_carpet_tile.setSolarAbsorptance(0.7)
    mat_thin_carpet_tile.setVisibleAbsorptance(0.8)
    mat_thin_carpet_tile.setName("Radiant Slab Thin Carpet Tile R-#{r_value_ip.round(2)}")
  end

  # set exterior slab insulation thickness based on climate zone
  slab_insulation_thickness_m = 0.0254 * cz_mult
  mat_slab_insulation = OpenStudio::Model::StandardOpaqueMaterial.new(model, 'Rough', slab_insulation_thickness_m, 0.02, 56.06, 1210)
  mat_slab_insulation.setName("Radiant Ground Slab Insulation - #{cz_mult} in.")

  ext_insulation_thickness_m = 0.0254 * (cz_mult + 1)
  mat_ext_insulation = OpenStudio::Model::StandardOpaqueMaterial.new(model, 'Rough', ext_insulation_thickness_m, 0.02, 56.06, 1210)
  mat_ext_insulation.setName("Radiant Exterior Slab Insulation - #{cz_mult + 1} in.")

  roof_insulation_thickness_m = 0.0254 * (cz_mult + 1) * 2
  mat_roof_insulation = OpenStudio::Model::StandardOpaqueMaterial.new(model, 'Rough', roof_insulation_thickness_m, 0.02, 56.06, 1210)
  mat_roof_insulation.setName("Radiant Exterior Ceiling Insulation - #{(cz_mult + 1) * 2} in.")

  # create radiant internal source constructions
  OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', 'New constructions exclude the metal deck, as high thermal diffusivity materials cause errors in EnergyPlus internal source construction calculations.')

  layers = []
  layers << mat_slab_insulation
  layers << mat_concrete_3_5in
  layers << mat_concrete_1_5in
  layers << mat_thin_carpet_tile if include_carpet
  radiant_ground_slab_construction = OpenStudio::Model::ConstructionWithInternalSource.new(layers)
  radiant_ground_slab_construction.setName('Radiant Ground Slab Construction')
  radiant_ground_slab_construction.setSourcePresentAfterLayerNumber(2)
  radiant_ground_slab_construction.setTemperatureCalculationRequestedAfterLayerNumber(3)
  radiant_ground_slab_construction.setTubeSpacing(0.2286) # 9 inches

  layers = []
  layers << mat_ext_insulation
  layers << mat_concrete_3_5in
  layers << mat_concrete_1_5in
  layers << mat_thin_carpet_tile if include_carpet
  radiant_exterior_slab_construction = OpenStudio::Model::ConstructionWithInternalSource.new(layers)
  radiant_exterior_slab_construction.setName('Radiant Exterior Slab Construction')
  radiant_exterior_slab_construction.setSourcePresentAfterLayerNumber(2)
  radiant_exterior_slab_construction.setTemperatureCalculationRequestedAfterLayerNumber(3)
  radiant_exterior_slab_construction.setTubeSpacing(0.2286) # 9 inches

  layers = []
  layers << mat_concrete_3_5in
  layers << mat_concrete_1_5in
  layers << mat_thin_carpet_tile if include_carpet
  radiant_interior_floor_slab_construction = OpenStudio::Model::ConstructionWithInternalSource.new(layers)
  radiant_interior_floor_slab_construction.setName('Radiant Interior Floor Slab Construction')
  radiant_interior_floor_slab_construction.setSourcePresentAfterLayerNumber(1)
  radiant_interior_floor_slab_construction.setTemperatureCalculationRequestedAfterLayerNumber(2)
  radiant_interior_floor_slab_construction.setTubeSpacing(0.2286) # 9 inches

  layers = []
  layers << mat_thin_carpet_tile if include_carpet
  layers << mat_concrete_3_5in
  layers << mat_concrete_1_5in
  radiant_interior_ceiling_slab_construction = OpenStudio::Model::ConstructionWithInternalSource.new(layers)
  radiant_interior_ceiling_slab_construction.setName('Radiant Interior Ceiling Slab Construction')
  slab_src_loc = include_carpet ? 2 : 1
  radiant_interior_ceiling_slab_construction.setSourcePresentAfterLayerNumber(slab_src_loc)
  radiant_interior_ceiling_slab_construction.setTemperatureCalculationRequestedAfterLayerNumber(slab_src_loc + 1)
  radiant_interior_ceiling_slab_construction.setTubeSpacing(0.2286) # 9 inches

  layers = []
  layers << mat_refl_roof_membrane
  layers << mat_roof_insulation
  layers << mat_concrete_3_5in
  layers << mat_concrete_1_5in
  radiant_ceiling_slab_construction = OpenStudio::Model::ConstructionWithInternalSource.new(layers)
  radiant_ceiling_slab_construction.setName('Radiant Exterior Ceiling Slab Construction')
  radiant_ceiling_slab_construction.setSourcePresentAfterLayerNumber(3)
  radiant_ceiling_slab_construction.setTemperatureCalculationRequestedAfterLayerNumber(4)
  radiant_ceiling_slab_construction.setTubeSpacing(0.2286) # 9 inches

  # adjust hot and chilled water loop temperatures and set new setpoint schedules
  radiant_htg_dsgn_sup_wtr_temp_delt_r = 10
  radiant_htg_dsgn_sup_wtr_temp_c = OpenStudio.convert(radiant_htg_dsgn_sup_wtr_temp_f, 'F', 'C').get
  radiant_htg_dsgn_sup_wtr_temp_delt_k = OpenStudio.convert(radiant_htg_dsgn_sup_wtr_temp_delt_r, 'R', 'K').get
  hot_water_loop.sizingPlant.setDesignLoopExitTemperature(radiant_htg_dsgn_sup_wtr_temp_c)
  hot_water_loop.sizingPlant.setLoopDesignTemperatureDifference(radiant_htg_dsgn_sup_wtr_temp_delt_k)
  hw_temp_sch = model_add_constant_schedule_ruleset(model,
                                                    radiant_htg_dsgn_sup_wtr_temp_c,
                                                    name = "#{hot_water_loop.name} Temp - #{radiant_htg_dsgn_sup_wtr_temp_f.round(0)}F")
  hot_water_loop.supplyOutletNode.setpointManagers.each do |spm|
    if spm.to_SetpointManagerScheduled.is_initialized
      spm = spm.to_SetpointManagerScheduled.get
      spm.setSchedule(hw_temp_sch)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Changing hot water loop setpoint for '#{hot_water_loop.name}' to '#{hw_temp_sch.name}' to account for the radiant system.")
    end
  end

  radiant_clg_dsgn_sup_wtr_temp_f = 55.0
  radiant_clg_dsgn_sup_wtr_temp_delt_r = 5.0
  radiant_clg_dsgn_sup_wtr_temp_c = OpenStudio.convert(radiant_clg_dsgn_sup_wtr_temp_f, 'F', 'C').get
  radiant_clg_dsgn_sup_wtr_temp_delt_k = OpenStudio.convert(radiant_clg_dsgn_sup_wtr_temp_delt_r, 'R', 'K').get
  chilled_water_loop.sizingPlant.setDesignLoopExitTemperature(radiant_clg_dsgn_sup_wtr_temp_c)
  chilled_water_loop.sizingPlant.setLoopDesignTemperatureDifference(radiant_clg_dsgn_sup_wtr_temp_delt_k)
  chw_temp_sch = model_add_constant_schedule_ruleset(model,
                                                     radiant_clg_dsgn_sup_wtr_temp_c,
                                                     name = "#{chilled_water_loop.name} Temp - #{radiant_clg_dsgn_sup_wtr_temp_f.round(0)}F")
  chilled_water_loop.supplyOutletNode.setpointManagers.each do |spm|
    if spm.to_SetpointManagerScheduled.is_initialized
      spm = spm.to_SetpointManagerScheduled.get
      spm.setSchedule(chw_temp_sch)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Changing chilled water loop setpoint for '#{chilled_water_loop.name}' to '#{chw_temp_sch.name}' to account for the radiant system.")
    end
  end

  # default temperature controls for radiant system
  zn_radiant_htg_dsgn_temp_f = 68.0
  zn_radiant_htg_dsgn_temp_c = OpenStudio.convert(zn_radiant_htg_dsgn_temp_f, 'F', 'C').get
  zn_radiant_clg_dsgn_temp_f = 74.0
  zn_radiant_clg_dsgn_temp_c = OpenStudio.convert(zn_radiant_clg_dsgn_temp_f, 'F', 'C').get

  htg_control_temp_sch = model_add_constant_schedule_ruleset(model,
                                                             zn_radiant_htg_dsgn_temp_c,
                                                             name = "Zone Radiant Loop Heating Threshold Temperature Schedule - #{zn_radiant_htg_dsgn_temp_f.round(0)}F")
  clg_control_temp_sch = model_add_constant_schedule_ruleset(model,
                                                             zn_radiant_clg_dsgn_temp_c,
                                                             name = "Zone Radiant Loop Cooling Threshold Temperature Schedule - #{zn_radiant_clg_dsgn_temp_f.round(0)}F")
  throttling_range_f = 4.0 # 2 degF on either side of control temperature
  throttling_range_c = OpenStudio.convert(throttling_range_f, 'F', 'C').get

  # create availability schedule for radiant loop
  if radiant_lockout
    radiant_avail_sch = OpenStudio::Model::ScheduleRuleset.new(model)
    radiant_avail_sch.setName('Radiant System Availability Schedule')

    start_hour = radiant_lockout_start_time.to_i
    start_minute = ((radiant_lockout_start_time % 1) * 60).to_i
    end_hour = radiant_lockout_end_time.to_i
    end_minute = ((radiant_lockout_end_time % 1) * 60).to_i

    if radiant_lockout_end_time > radiant_lockout_start_time
      radiant_avail_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, start_hour, start_minute, 0), 1.0)
      radiant_avail_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, end_hour, end_minute, 0), 0.0)
      radiant_avail_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 1.0) if radiant_lockout_end_time < 24
    elsif radiant_lockout_start_time > radiant_lockout_end_time
      radiant_avail_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, end_hour, end_minute, 0), 0.0)
      radiant_avail_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, start_hour, start_minute, 0), 1.0)
      radiant_avail_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0.0) if radiant_lockout_start_time < 24
    else
      radiant_avail_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 1.0)
    end
  else
    radiant_avail_sch = model.alwaysOnDiscreteSchedule
  end

  # make a low temperature radiant loop for each zone
  radiant_loops = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding radiant loop for #{zone.name}.")
    if zone.name.to_s.include? ':'
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Thermal zone '#{zone.name}' has a restricted character ':' in the name and will not work with some EMS and output reporting objects. Please rename the zone.")
    end

    # create radiant coils
    if hot_water_loop
      radiant_loop_htg_coil = OpenStudio::Model::CoilHeatingLowTempRadiantVarFlow.new(model, htg_control_temp_sch)
      radiant_loop_htg_coil.setName("#{zone.name} Radiant Loop Heating Coil")
      radiant_loop_htg_coil.setHeatingControlThrottlingRange(throttling_range_c)
      hot_water_loop.addDemandBranchForComponent(radiant_loop_htg_coil)
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', 'Radiant loops require a hot water loop, but none was provided.')
    end

    if chilled_water_loop
      radiant_loop_clg_coil = OpenStudio::Model::CoilCoolingLowTempRadiantVarFlow.new(model, clg_control_temp_sch)
      radiant_loop_clg_coil.setName("#{zone.name} Radiant Loop Cooling Coil")
      radiant_loop_clg_coil.setCoolingControlThrottlingRange(throttling_range_c)
      chilled_water_loop.addDemandBranchForComponent(radiant_loop_clg_coil)
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', 'Radiant loops require a chilled water loop, but none was provided.')
    end

    radiant_loop = OpenStudio::Model::ZoneHVACLowTempRadiantVarFlow.new(model,
                                                                        radiant_avail_sch,
                                                                        radiant_loop_htg_coil,
                                                                        radiant_loop_clg_coil)

    # assign internal source construction to floors in zone
    zone.spaces.each do |space|
      space.surfaces.each do |surface|
        if radiant_type == 'floor'
          if surface.surfaceType == 'Floor'
            if surface.outsideBoundaryCondition == 'Ground'
              surface.setConstruction(radiant_ground_slab_construction)
            elsif surface.outsideBoundaryCondition == 'Outdoors'
              surface.setConstruction(radiant_exterior_slab_construction)
            else # interior floor
              surface.setConstruction(radiant_interior_floor_slab_construction)
            end
          end
        elsif radiant_type == 'ceiling'
          if surface.surfaceType == 'RoofCeiling'
            if surface.outsideBoundaryCondition == 'Outdoors'
              surface.setConstruction(radiant_ceiling_slab_construction)
            else # interior ceiling
              surface.setConstruction(radiant_interior_ceiling_slab_construction)
            end
          end
        end
      end
    end

    # radiant loop surfaces
    radiant_loop.setName("#{zone.name} Radiant Loop")
    if radiant_type == 'floor'
      radiant_loop.setRadiantSurfaceType('Floors')
    elsif radiant_type == 'ceiling'
      radiant_loop.setRadiantSurfaceType('Ceilings')
    end

    # radiant loop layout details
    radiant_loop.setHydronicTubingInsideDiameter(0.015875) # 5/8 in. ID, 3/4 in. OD
    # @TODO include a method to determine tubing length in the zone
    # loop_length = 7*zone.floorArea
    # radiant_loop.setHydronicTubingLength()
    radiant_loop.setNumberofCircuits('CalculateFromCircuitLength')
    radiant_loop.setCircuitLength(106.7)

    # radiant loop controls
    radiant_loop.setTemperatureControlType('MeanAirTemperature')
    radiant_loop.addToThermalZone(zone)
    radiant_loops << radiant_loop

    # rename nodes before adding EMS code
    rename_plant_loop_nodes(model)

    # set radiant loop controls
    if control_strategy == 'proportional_control'
      model_add_radiant_proportional_controls(model, zone, radiant_loop,
                                              radiant_type: radiant_type,
                                              proportional_gain: proportional_gain,
                                              minimum_operation: minimum_operation,
                                              weekend_temperature_reset: weekend_temperature_reset,
                                              early_reset_out_arg: early_reset_out_arg,
                                              switch_over_time: switch_over_time)
    end
  end

  return radiant_loops
end

#model_add_material(model, material_name) ⇒ Object

TODO:

make return an OptionalMaterial

Create a material from the openstudio standards dataset.



2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2177

def model_add_material(model, material_name)
  # First check model and return material if it already exists
  model.getMaterials.sort.each do |material|
    if material.name.get.to_s == material_name
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "Already added material: #{material_name}")
      return material
    end
  end

  # OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', "Adding material: #{material_name}")

  # Get the object data
  data = model_find_object(standards_data['materials'], 'name' => material_name)
  unless data
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Model', "Cannot find data for material: #{material_name}, will not be created.")
    return false # TODO: change to return empty optional material
  end

  material = nil
  material_type = data['material_type']

  if material_type == 'StandardOpaqueMaterial'
    material = OpenStudio::Model::StandardOpaqueMaterial.new(model)
    material.setName(material_name)

    material.setRoughness(data['roughness'].to_s)
    material.setThickness(OpenStudio.convert(data['thickness'].to_f, 'in', 'm').get)
    material.setThermalConductivity(OpenStudio.convert(data['conductivity'].to_f, 'Btu*in/hr*ft^2*R', 'W/m*K').get)
    material.setDensity(OpenStudio.convert(data['density'].to_f, 'lb/ft^3', 'kg/m^3').get)
    material.setSpecificHeat(OpenStudio.convert(data['specific_heat'].to_f, 'Btu/lb*R', 'J/kg*K').get)
    material.setThermalAbsorptance(data['thermal_absorptance'].to_f)
    material.setSolarAbsorptance(data['solar_absorptance'].to_f)
    material.setVisibleAbsorptance(data['visible_absorptance'].to_f)

  elsif material_type == 'MasslessOpaqueMaterial'
    material = OpenStudio::Model::MasslessOpaqueMaterial.new(model)
    material.setName(material_name)
    material.setThermalResistance(OpenStudio.convert(data['resistance'].to_f, 'hr*ft^2*R/Btu', 'm^2*K/W').get)
    material.setThermalConductivity(OpenStudio.convert(data['conductivity'].to_f, 'Btu*in/hr*ft^2*R', 'W/m*K').get)
    material.setThermalAbsorptance(data['thermal_absorptance'].to_f)
    material.setSolarAbsorptance(data['solar_absorptance'].to_f)
    material.setVisibleAbsorptance(data['visible_absorptance'].to_f)

  elsif material_type == 'AirGap'
    material = OpenStudio::Model::AirGap.new(model)
    material.setName(material_name)

    material.setThermalResistance(OpenStudio.convert(data['resistance'].to_f, 'hr*ft^2*R/Btu*in', 'm*K/W').get)

  elsif material_type == 'Gas'
    material = OpenStudio::Model::Gas.new(model)
    material.setName(material_name)

    material.setThickness(OpenStudio.convert(data['thickness'].to_f, 'in', 'm').get)
    material.setGasType(data['gas_type'].to_s)

  elsif material_type == 'SimpleGlazing'
    material = OpenStudio::Model::SimpleGlazing.new(model)
    material.setName(material_name)

    material.setUFactor(OpenStudio.convert(data['u_factor'].to_f, 'Btu/hr*ft^2*R', 'W/m^2*K').get)
    material.setSolarHeatGainCoefficient(data['solar_heat_gain_coefficient'].to_f)
    material.setVisibleTransmittance(data['visible_transmittance'].to_f)

  elsif material_type == 'StandardGlazing'
    material = OpenStudio::Model::StandardGlazing.new(model)
    material.setName(material_name)

    material.setOpticalDataType(data['optical_data_type'].to_s)
    material.setThickness(OpenStudio.convert(data['thickness'].to_f, 'in', 'm').get)
    material.setSolarTransmittanceatNormalIncidence(data['solar_transmittance_at_normal_incidence'].to_f)
    material.setFrontSideSolarReflectanceatNormalIncidence(data['front_side_solar_reflectance_at_normal_incidence'].to_f)
    material.setBackSideSolarReflectanceatNormalIncidence(data['back_side_solar_reflectance_at_normal_incidence'].to_f)
    material.setVisibleTransmittanceatNormalIncidence(data['visible_transmittance_at_normal_incidence'].to_f)
    material.setFrontSideVisibleReflectanceatNormalIncidence(data['front_side_visible_reflectance_at_normal_incidence'].to_f)
    material.setBackSideVisibleReflectanceatNormalIncidence(data['back_side_visible_reflectance_at_normal_incidence'].to_f)
    material.setInfraredTransmittanceatNormalIncidence(data['infrared_transmittance_at_normal_incidence'].to_f)
    material.setFrontSideInfraredHemisphericalEmissivity(data['front_side_infrared_hemispherical_emissivity'].to_f)
    material.setBackSideInfraredHemisphericalEmissivity(data['back_side_infrared_hemispherical_emissivity'].to_f)
    material.setThermalConductivity(OpenStudio.convert(data['conductivity'].to_f, 'Btu*in/hr*ft^2*R', 'W/m*K').get)
    material.setDirtCorrectionFactorforSolarandVisibleTransmittance(data['dirt_correction_factor_for_solar_and_visible_transmittance'].to_f)
    if /true/i =~ data['solar_diffusing'].to_s
      material.setSolarDiffusing(true)
    else
      material.setSolarDiffusing(false)
    end

  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Unknown material type #{material_type}, cannot add material called #{material_name}.")
    exit
  end

  return material
end

#model_add_minisplit_hp(model, thermal_zones, cooling_type: 'Two Speed DX AC', heating_type: 'Single Speed DX', hvac_op_sch: nil) ⇒ OpenStudio::Model::AirLoopHVAC

Creates a minisplit heatpump system for each zone and adds it to the model.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • cooling_type (String) (defaults to: 'Two Speed DX AC')

    valid choices are Two Speed DX AC, Single Speed DX AC, Single Speed Heat Pump

  • heating_type (String) (defaults to: 'Single Speed DX')

    valid choices are Single Speed DX

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule or nil in which case will be defaulted to always on

Returns:



3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 3558

def model_add_minisplit_hp(model,
                           thermal_zones,
                           cooling_type: 'Two Speed DX AC',
                           heating_type: 'Single Speed DX',
                           hvac_op_sch: nil)

  # hvac operation schedule
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # default design temperatures across all air loops
  dsgn_temps = standard_design_sizing_temperatures

  # adjusted temperatures for minisplit
  dsgn_temps['zn_htg_dsgn_sup_air_temp_f'] = 122.0
  dsgn_temps['zn_htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_htg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['htg_dsgn_sup_air_temp_f'] = dsgn_temps['zn_htg_dsgn_sup_air_temp_f']
  dsgn_temps['htg_dsgn_sup_air_temp_c'] = dsgn_temps['zn_htg_dsgn_sup_air_temp_c']

  minisplit_hps = []
  thermal_zones.each do |zone|
    air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
    air_loop.setName("#{zone.name} Minisplit Heat Pump")
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding minisplit HP for #{zone.name}.")

    # default design settings used across all air loops
    sizing_system = adjust_sizing_system(air_loop, dsgn_temps, sizing_option: 'NonCoincident')
    sizing_system.setAllOutdoorAirinCooling(false)
    sizing_system.setAllOutdoorAirinHeating(false)

    # create heating coil
    case heating_type
    when 'Single Speed DX'
      htg_coil = create_coil_heating_dx_single_speed(model,
                                                     name: "#{air_loop.name} Heating Coil",
                                                     type: 'Residential Minisplit HP')
      htg_coil.setMinimumOutdoorDryBulbTemperatureforCompressorOperation(OpenStudio.convert(-30.0, 'F', 'C').get)
      htg_coil.setMaximumOutdoorDryBulbTemperatureforDefrostOperation(OpenStudio.convert(40.0, 'F', 'C').get)
      htg_coil.setCrankcaseHeaterCapacity(0)
      htg_coil.setDefrostStrategy('ReverseCycle')
      htg_coil.setDefrostControl('OnDemand')
      htg_coil.resetDefrostTimePeriodFraction
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "No heating coil type selected for minisplit HP for #{zone.name}.")
      htg_coil = nil
    end

    # create backup heating coil
    supplemental_htg_coil = create_coil_heating_electric(model,
                                                         name: "#{air_loop.name} Electric Backup Htg Coil")

    # create cooling coil
    case cooling_type
    when 'Two Speed DX AC'
      clg_coil = create_coil_cooling_dx_two_speed(model,
                                                  name: "#{air_loop.name} 2spd DX AC Clg Coil",
                                                  type: 'Residential Minisplit HP')
    when 'Single Speed DX AC'
      clg_coil = create_coil_cooling_dx_single_speed(model,
                                                     name: "#{air_loop.name} 1spd DX AC Clg Coil", type: 'Split AC')
    when 'Single Speed Heat Pump'
      clg_coil = create_coil_cooling_dx_single_speed(model,
                                                     name: "#{air_loop.name} 1spd DX HP Clg Coil", type: 'Heat Pump')
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "No cooling coil type selected for minisplit HP for #{zone.name}.")
      clg_coil = nil
    end

    # create fan
    fan = create_fan_by_name(model,
                             'Minisplit_HP_Fan',
                             fan_name: "#{air_loop.name} Fan",
                             end_use_subcategory: 'Minisplit HP Fans')
    fan.setAvailabilitySchedule(hvac_op_sch)

    # create unitary system (holds the coils and fan)
    unitary = OpenStudio::Model::AirLoopHVACUnitarySystem.new(model)
    unitary.setName("#{air_loop.name} Unitary System")
    unitary.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
    unitary.setMaximumSupplyAirTemperature(OpenStudio.convert(200.0, 'F', 'C').get)
    unitary.setMaximumOutdoorDryBulbTemperatureforSupplementalHeaterOperation(OpenStudio.convert(40.0, 'F', 'C').get)
    unitary.setControllingZoneorThermostatLocation(zone)
    unitary.addToNode(air_loop.supplyInletNode)
    unitary.setSupplyAirFlowRateWhenNoCoolingorHeatingisRequired(0.0)

    # attach the coils and fan
    unitary.setHeatingCoil(htg_coil) if htg_coil
    unitary.setCoolingCoil(clg_coil) if clg_coil
    unitary.setSupplementalHeatingCoil(supplemental_htg_coil) if supplemental_htg_coil
    unitary.setSupplyFan(fan)
    unitary.setFanPlacement('BlowThrough')
    unitary.setSupplyAirFanOperatingModeSchedule(model.alwaysOffDiscreteSchedule)

    # create a diffuser
    diffuser = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule)
    diffuser.setName(" #{zone.name} Direct Air")
    air_loop.multiAddBranchForZone(zone, diffuser.to_HVACComponent.get)

    minisplit_hps << air_loop
  end

  return minisplit_hps
end

#model_add_piping_losses_to_swh_system(model, swh_loop, circulating, pipe_insulation_thickness: 0, floor_area_served: 465, number_of_stories: 1, air_temp_surrounding_piping: 21.1111) ⇒ Object

Adds insulated 0.75in copper piping to the model. For circulating systems, assume length of piping is proportional to the area and number of stories in the building. For non-circulating systems, assume that the water heaters are close to the point of use. Assume that piping is located in a zone

Parameters:

  • model (OpenStudio::Model::Model)

    the model

  • swh_loop (OpenStudio::Model::PlantLoop)

    the service water heating loop

  • floor_area_served (Double) (defaults to: 465)

    the area of building served by the service water heating loop, in m^2

  • number_of_stories (Integer) (defaults to: 1)

    the number of stories served by the service water heating loop

  • pipe_insulation_thickness (Double) (defaults to: 0)

    the thickness of the pipe insulation, in m. Use 0 for no insulation

  • circulating (Bool)

    use true for circulating systems, false for non-circulating systems

  • air_temp_surrounding_piping (Double) (defaults to: 21.1111)

    the temperature of the air surrounding the piping, in C.



1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.ServiceWaterHeating.rb', line 1035

def model_add_piping_losses_to_swh_system(model,
                                          swh_loop,
                                          circulating,
                                          pipe_insulation_thickness: 0,
                                          floor_area_served: 465,
                                          number_of_stories: 1,
                                          air_temp_surrounding_piping: 21.1111)

  # Estimate pipe length
  if circulating
    # For circulating systems, get pipe length based on the size of the building.
    # Formula from A.3.1 PrototypeModelEnhancements_2014_0.pdf
    floor_area_ft2 = OpenStudio.convert(floor_area_served, 'm^2', 'ft^2').get
    pipe_length_ft = 2.0 * (Math.sqrt(floor_area_ft2 / number_of_stories) + (10.0 * (number_of_stories - 1.0)))
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Pipe length #{pipe_length_ft.round}ft = 2.0 * ( (#{floor_area_ft2.round}ft2 / #{number_of_stories} stories)^0.5 + (10.0ft * (#{number_of_stories} stories - 1.0) ) )")
  else
    # For non-circulating systems, assume water heater is close to point of use
    pipe_length_ft = 20.0
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Pipe length #{pipe_length_ft.round}ft. For non-circulating systems, assume water heater is close to point of use.")
  end

  # For systems whose water heater object represents multiple pieces
  # of equipment, multiply the piping length by the number of pieces of equipment.
  swh_loop.supplyComponents('OS_WaterHeater_Mixed'.to_IddObjectType).each do |sc|
    next unless sc.to_WaterHeaterMixed.is_initialized

    water_heater = sc.to_WaterHeaterMixed.get
    comp_qty = water_heater.component_quantity
    if comp_qty > 1
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Piping length has been multiplied by #{comp_qty}X because #{water_heater.name} represents #{comp_qty} pieces of equipment.")
      pipe_length_ft *= comp_qty
      break
    end
  end

  # Service water heating piping heat loss scheduled air temperature
  swh_piping_air_temp_c = air_temp_surrounding_piping
  swh_piping_air_temp_f = OpenStudio.convert(swh_piping_air_temp_c, 'C', 'F').get
  swh_piping_air_temp_sch = model_add_constant_schedule_ruleset(model,
                                                                swh_piping_air_temp_c,
                                                                name = "#{swh_loop.name} Piping Air Temp - #{swh_piping_air_temp_f.round}F")

  # Service water heating piping heat loss scheduled air velocity
  swh_piping_air_velocity_m_per_s = 0.3
  swh_piping_air_velocity_mph = OpenStudio.convert(swh_piping_air_velocity_m_per_s, 'm/s', 'mile/hr').get
  swh_piping_air_velocity_sch = model_add_constant_schedule_ruleset(model,
                                                                    swh_piping_air_velocity_m_per_s,
                                                                    name = "#{swh_loop.name} Piping Air Velocity - #{swh_piping_air_velocity_mph.round(2)}mph")

  # Material for 3/4in type L (heavy duty) copper pipe
  copper_pipe = OpenStudio::Model::StandardOpaqueMaterial.new(model)
  copper_pipe.setName('Copper pipe 0.75in type L')
  copper_pipe.setRoughness('Smooth')
  copper_pipe.setThickness(OpenStudio.convert(0.045, 'in', 'm').get)
  copper_pipe.setThermalConductivity(386.0)
  copper_pipe.setDensity(OpenStudio.convert(556, 'lb/ft^3', 'kg/m^3').get)
  copper_pipe.setSpecificHeat(OpenStudio.convert(0.092, 'Btu/lb*R', 'J/kg*K').get)
  copper_pipe.setThermalAbsorptance(0.9) # TODO: find reference for property
  copper_pipe.setSolarAbsorptance(0.7) # TODO: find reference for property
  copper_pipe.setVisibleAbsorptance(0.7) # TODO: find reference for property

  # Construction for pipe
  pipe_construction = OpenStudio::Model::Construction.new(model)

  # Add insulation material to insulated pipe
  if pipe_insulation_thickness > 0
    # Material for fiberglass insulation
    # R-value from Owens-Corning 1/2in fiberglass pipe insulation
    # https://www.grainger.com/product/OWENS-CORNING-1-2-Thick-40PP22
    # but modified until simulated heat loss = 17.7 Btu/hr/ft of pipe with 140F water and 70F air
    pipe_insulation_thickness_in = OpenStudio.convert(pipe_insulation_thickness, 'm', 'in').get
    insulation = OpenStudio::Model::StandardOpaqueMaterial.new(model)
    insulation.setName("Fiberglass batt #{pipe_insulation_thickness_in.round(2)}in")
    insulation.setRoughness('Smooth')
    insulation.setThickness(OpenStudio.convert(pipe_insulation_thickness_in, 'in', 'm').get)
    insulation.setThermalConductivity(OpenStudio.convert(0.46, 'Btu*in/hr*ft^2*R', 'W/m*K').get)
    insulation.setDensity(OpenStudio.convert(0.7, 'lb/ft^3', 'kg/m^3').get)
    insulation.setSpecificHeat(OpenStudio.convert(0.2, 'Btu/lb*R', 'J/kg*K').get)
    insulation.setThermalAbsorptance(0.9) # Irrelevant for Pipe:Indoor; no radiation model is used
    insulation.setSolarAbsorptance(0.7) # Irrelevant for Pipe:Indoor; no radiation model is used
    insulation.setVisibleAbsorptance(0.7) # Irrelevant for Pipe:Indoor; no radiation model is used

    pipe_construction.setName("Copper pipe 0.75in type L with #{pipe_insulation_thickness_in.round(2)}in fiberglass batt")
    pipe_construction.setLayers([insulation, copper_pipe])
  else
    pipe_construction.setName('Uninsulated copper pipe 0.75in type L')
    pipe_construction.setLayers([copper_pipe])
  end

  heat_loss_pipe = OpenStudio::Model::PipeIndoor.new(model)
  heat_loss_pipe.setName("#{swh_loop.name} Pipe #{pipe_length_ft}ft")
  heat_loss_pipe.setEnvironmentType('Schedule')
  # heat_loss_pipe.setAmbientTemperatureSchedule(swh_piping_air_temp_sch) # TODO: schedule type registry error for this setter
  heat_loss_pipe.setPointer(7, swh_piping_air_temp_sch.handle)
  # heat_loss_pipe.setAmbientAirVelocitySchedule(model.alwaysOffDiscreteSchedule) # TODO: schedule type registry error for this setter
  heat_loss_pipe.setPointer(8, swh_piping_air_velocity_sch.handle)
  heat_loss_pipe.setConstruction(pipe_construction)
  heat_loss_pipe.setPipeInsideDiameter(OpenStudio.convert(0.785, 'in', 'm').get)
  heat_loss_pipe.setPipeLength(OpenStudio.convert(pipe_length_ft, 'ft', 'm').get)

  heat_loss_pipe.addToNode(swh_loop.demandInletNode)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Added #{pipe_length_ft.round}ft of #{pipe_construction.name} losing heat to #{swh_piping_air_temp_f.round}F air to #{swh_loop.name}.")
  return true
end

#model_add_prm_baseline_system(model, system_type, main_heat_fuel, zone_heat_fuel, cool_fuel, zones) ⇒ Object

Add the specified baseline system type to the specified zones based on the specified template. For some multi-zone system types, the standards require identifying zones whose loads or schedules are outliers and putting these systems on separate single-zone systems. This method does that.

TODO: Add 90.1-2013 systems 11-13

Parameters:

  • system_type (String)

    The system type. Valid choices are PTHP, PTAC, PSZ_AC, PSZ_HP, PVAV_Reheat, PVAV_PFP_Boxes, VAV_Reheat, VAV_PFP_Boxes, Gas_Furnace, Electric_Furnace, which are also returned by the method OpenStudio::Model::Model.prm_baseline_system_type.

  • main_heat_fuel (String)

    main heating fuel. Valid choices are Electricity, NaturalGas, DistrictHeating

  • zone_heat_fuel (String)

    zone heating/reheat fuel. Valid choices are Electricity, NaturalGas, DistrictHeating

  • cool_fuel (String)

    cooling fuel. Valid choices are Electricity, DistrictCooling



731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 731

def model_add_prm_baseline_system(model, system_type, main_heat_fuel, zone_heat_fuel, cool_fuel, zones)
  case system_type
    when 'PTAC' # System 1
      unless zones.empty?
        # Retrieve the existing hot water loop or add a new one if necessary.
        hot_water_loop = nil
        hot_water_loop = if model.getPlantLoopByName('Hot Water Loop').is_initialized
                           model.getPlantLoopByName('Hot Water Loop').get
                         else
                           model_add_hw_loop(model, main_heat_fuel)
                         end

        # Add a hot water PTAC to each zone
        model_add_ptac(model,
                       zones,
                       cooling_type: 'Single Speed DX AC',
                       heating_type: 'Water',
                       hot_water_loop: hot_water_loop,
                       fan_type: 'ConstantVolume')
      end

    when 'PTHP' # System 2
      unless zones.empty?
        # add an air-source packaged terminal heat pump with electric supplemental heat to each zone.
        model_add_pthp(model,
                       zones,
                       fan_type: 'ConstantVolume')
      end

    when 'PSZ_AC' # System 3
      unless zones.empty?
        heating_type = 'Gas'
        # if district heating
        hot_water_loop = nil
        if main_heat_fuel == 'DistrictHeating'
          heating_type = 'Water'
          hot_water_loop = if model.getPlantLoopByName('Hot Water Loop').is_initialized
                             model.getPlantLoopByName('Hot Water Loop').get
                           else
                             model_add_hw_loop(model, main_heat_fuel)
                           end
        end

        cooling_type = 'Single Speed DX AC'
        # If district cooling
        chilled_water_loop = nil
        if cool_fuel == 'DistrictCooling'
          cooling_type = 'Water'
          chilled_water_loop = if model.getPlantLoopByName('Chilled Water Loop').is_initialized
                                 model.getPlantLoopByName('Chilled Water Loop').get
                               else
                                 model_add_chw_loop(model,
                                                    cooling_fuel: cool_fuel,
                                                    chw_pumping_type: 'const_pri')
                               end
        end

        # Add a PSZ-AC to each zone
        model_add_psz_ac(model,
                         zones,
                         cooling_type: cooling_type,
                         chilled_water_loop: chilled_water_loop,
                         heating_type: heating_type,
                         supplemental_heating_type: 'Gas',
                         hot_water_loop: hot_water_loop,
                         fan_location: 'DrawThrough',
                         fan_type: 'ConstantVolume')
      end

    when 'PSZ_HP' # System 4
      unless zones.empty?
        # Add an air-source packaged single zone heat pump with electric supplemental heat to each zone.
        model_add_psz_ac(model,
                         zones,
                         system_name: 'PSZ-HP',
                         cooling_type: 'Single Speed Heat Pump',
                         heating_type: 'Single Speed Heat Pump',
                         supplemental_heating_type: 'Electric',
                         fan_location: 'DrawThrough',
                         fan_type: 'ConstantVolume')
      end

    when 'PVAV_Reheat' # System 5
      # Retrieve the existing hot water loop or add a new one if necessary.
      hot_water_loop = nil
      hot_water_loop = if model.getPlantLoopByName('Hot Water Loop').is_initialized
                         model.getPlantLoopByName('Hot Water Loop').get
                       else
                         model_add_hw_loop(model, main_heat_fuel)
                       end

      # If district cooling
      chilled_water_loop = nil
      if cool_fuel == 'DistrictCooling'
        chilled_water_loop = if model.getPlantLoopByName('Chilled Water Loop').is_initialized
                               model.getPlantLoopByName('Chilled Water Loop').get
                             else
                               model_add_chw_loop(model,
                                                  cooling_fuel: cool_fuel,
                                                  chw_pumping_type: 'const_pri')
                             end
      end

      # If electric zone heat
      electric_reheat = false
      if zone_heat_fuel == 'Electricity'
        electric_reheat = true
      end

      # Group zones by story
      story_zone_lists = model_group_zones_by_story(model, zones)

      # For the array of zones on each story,
      # separate the primary zones from the secondary zones.
      # Add the baseline system type to the primary zones
      # and add the suplemental system type to the secondary zones.
      story_zone_lists.each do |story_group|
        # Differentiate primary and secondary zones
        pri_sec_zone_lists = model_differentiate_primary_secondary_thermal_zones(model, story_group)
        pri_zones = pri_sec_zone_lists['primary']
        sec_zones = pri_sec_zone_lists['secondary']

        # Add a PVAV with Reheat for the primary zones
        stories = []
        story_group[0].spaces.each do |space|
          stories << [space.buildingStory.get.name.get, building_story_minimum_z_value(space.buildingStory.get)]
        end
        story_name = stories.min_by { |nm, z| z }[0]
        system_name = "#{story_name} PVAV_Reheat (Sys5)"

        # If and only if there are primary zones to attach to the loop
        # counter example: floor with only one elevator machine room that get classified as sec_zones
        unless pri_zones.empty?
          model_add_pvav(model,
                         pri_zones,
                         system_name: system_name,
                         hot_water_loop: hot_water_loop,
                         chilled_water_loop: chilled_water_loop,
                         electric_reheat: electric_reheat)
        end

        # Add a PSZ_AC for each secondary zone
        unless sec_zones.empty?
          model_add_prm_baseline_system(model, 'PSZ_AC', main_heat_fuel, zone_heat_fuel, cool_fuel, sec_zones)
        end
      end

    when 'PVAV_PFP_Boxes' # System 6
      # If district cooling
      chilled_water_loop = nil
      if cool_fuel == 'DistrictCooling'
        chilled_water_loop = if model.getPlantLoopByName('Chilled Water Loop').is_initialized
                               model.getPlantLoopByName('Chilled Water Loop').get
                             else
                               model_add_chw_loop(model,
                                                  cooling_fuel: cool_fuel,
                                                  chw_pumping_type: 'const_pri')
                             end
      end

      # Group zones by story
      story_zone_lists = model_group_zones_by_story(model, zones)

      # For the array of zones on each story,
      # separate the primary zones from the secondary zones.
      # Add the baseline system type to the primary zones
      # and add the suplemental system type to the secondary zones.
      story_zone_lists.each do |story_group|
        # Differentiate primary and secondary zones
        pri_sec_zone_lists = model_differentiate_primary_secondary_thermal_zones(model, story_group)
        pri_zones = pri_sec_zone_lists['primary']
        sec_zones = pri_sec_zone_lists['secondary']

        # Add an VAV for the primary zones
        stories = []
        story_group[0].spaces.each do |space|
          stories << [space.buildingStory.get.name.get, building_story_minimum_z_value(space.buildingStory.get)]
        end
        story_name = stories.min_by { |nm, z| z }[0]
        system_name = "#{story_name} PVAV_PFP_Boxes (Sys6)"
        # If and only if there are primary zones to attach to the loop
        unless pri_zones.empty?
          model_add_pvav_pfp_boxes(model,
                                   pri_zones,
                                   system_name: system_name,
                                   chilled_water_loop: chilled_water_loop,
                                   fan_efficiency: 0.62,
                                   fan_motor_efficiency: 0.9,
                                   fan_pressure_rise: 4.0)
        end
        # Add a PSZ_HP for each secondary zone
        unless sec_zones.empty?
          model_add_prm_baseline_system(model, 'PSZ_HP', main_heat_fuel, zone_heat_fuel, cool_fuel, sec_zones)
        end
      end

    when 'VAV_Reheat' # System 7
      # Retrieve the existing hot water loop or add a new one if necessary.
      hot_water_loop = nil
      hot_water_loop = if model.getPlantLoopByName('Hot Water Loop').is_initialized
                         model.getPlantLoopByName('Hot Water Loop').get
                       else
                         model_add_hw_loop(model, main_heat_fuel)
                       end

      # Retrieve the existing chilled water loop or add a new one if necessary.
      chilled_water_loop = nil
      if model.getPlantLoopByName('Chilled Water Loop').is_initialized
        chilled_water_loop = model.getPlantLoopByName('Chilled Water Loop').get
      else
        if cool_fuel == 'DistrictCooling'
          chilled_water_loop = model_add_chw_loop(model,
                                                  cooling_fuel: cool_fuel,
                                                  chw_pumping_type: 'const_pri')
        else
          fan_type = model_cw_loop_cooling_tower_fan_type(model)
          condenser_water_loop = model_add_cw_loop(model,
                                                   cooling_tower_type: 'Open Cooling Tower',
                                                   cooling_tower_fan_type: 'Propeller or Axial',
                                                   cooling_tower_capacity_control: fan_type,
                                                   number_of_cells_per_tower: 1,
                                                   number_cooling_towers: 1)
          chilled_water_loop = model_add_chw_loop(model,
                                                  chw_pumping_type: 'const_pri_var_sec',
                                                  chiller_cooling_type: 'WaterCooled',
                                                  chiller_compressor_type: 'Rotary Screw',
                                                  condenser_water_loop: condenser_water_loop)
        end
      end

      # If electric zone heat
      reheat_type = 'Water'
      if zone_heat_fuel == 'Electricity'
        reheat_type = 'Electricity'
      end

      # Group zones by story
      story_zone_lists = model_group_zones_by_story(model, zones)

      # For the array of zones on each story, separate the primary zones from the secondary zones.
      # Add the baseline system type to the primary zones and add the suplemental system type to the secondary zones.
      story_zone_lists.each do |story_group|
        # The model_group_zones_by_story(model)  NO LONGER returns empty lists when a given floor doesn't have any of the zones
        # So NO need to filter it out otherwise you get an error undefined method `spaces' for nil:NilClass
        # next if zones.empty?

        # Differentiate primary and secondary zones
        pri_sec_zone_lists = model_differentiate_primary_secondary_thermal_zones(model, story_group)
        pri_zones = pri_sec_zone_lists['primary']
        sec_zones = pri_sec_zone_lists['secondary']

        # Add a VAV for the primary zones
        stories = []
        story_group[0].spaces.each do |space|
          stories << [space.buildingStory.get.name.get, building_story_minimum_z_value(space.buildingStory.get)]
        end
        story_name = stories.min_by { |nm, z| z }[0]
        system_name = "#{story_name} VAV_Reheat (Sys7)"

        # If and only if there are primary zones to attach to the loop
        # counter example: floor with only one elevator machine room that get classified as sec_zones
        unless pri_zones.empty?
          model_add_vav_reheat(model,
                               pri_zones,
                               system_name: system_name,
                               reheat_type: reheat_type,
                               hot_water_loop: hot_water_loop,
                               chilled_water_loop: chilled_water_loop,
                               fan_efficiency: 0.62,
                               fan_motor_efficiency: 0.9,
                               fan_pressure_rise: 4.0)
        end

        # Add a PSZ_AC for each secondary zone
        unless sec_zones.empty?
          model_add_prm_baseline_system(model, 'PSZ_AC', main_heat_fuel, zone_heat_fuel, cool_fuel, sec_zones)
        end
      end

    when 'VAV_PFP_Boxes' # System 8
      # Retrieve the existing chilled water loop or add a new one if necessary.
      chilled_water_loop = nil
      if model.getPlantLoopByName('Chilled Water Loop').is_initialized
        chilled_water_loop = model.getPlantLoopByName('Chilled Water Loop').get
      else
        if cool_fuel == 'DistrictCooling'
          chilled_water_loop = model_add_chw_loop(model,
                                                  cooling_fuel: cool_fuel,
                                                  chw_pumping_type: 'const_pri')
        else
          fan_type = model_cw_loop_cooling_tower_fan_type(model)
          condenser_water_loop = model_add_cw_loop(model,
                                                   cooling_tower_type: 'Open Cooling Tower',
                                                   cooling_tower_fan_type: 'Propeller or Axial',
                                                   cooling_tower_capacity_control: fan_type,
                                                   number_of_cells_per_tower: 1,
                                                   number_cooling_towers: 1)
          chilled_water_loop = model_add_chw_loop(model,
                                                  chw_pumping_type: 'const_pri_var_sec',
                                                  chiller_cooling_type: 'WaterCooled',
                                                  chiller_compressor_type: 'Rotary Screw',
                                                  condenser_water_loop: condenser_water_loop)
        end
      end

      # Group zones by story
      story_zone_lists = model_group_zones_by_story(model, zones)

      # For the array of zones on each story,
      # separate the primary zones from the secondary zones.
      # Add the baseline system type to the primary zones
      # and add the suplemental system type to the secondary zones.
      story_zone_lists.each do |story_group|
        # Differentiate primary and secondary zones
        pri_sec_zone_lists = model_differentiate_primary_secondary_thermal_zones(model, story_group)
        pri_zones = pri_sec_zone_lists['primary']
        sec_zones = pri_sec_zone_lists['secondary']

        # Add an VAV for the primary zones
        stories = []
        story_group[0].spaces.each do |space|
          stories << [space.buildingStory.get.name.get, building_story_minimum_z_value(space.buildingStory.get)]
        end
        story_name = stories.min_by { |nm, z| z }[0]
        system_name = "#{story_name} VAV_PFP_Boxes (Sys8)"
        # If and only if there are primary zones to attach to the loop
        unless pri_zones.empty?
          model_add_vav_pfp_boxes(model,
                                  pri_zones,
                                  system_name: system_name,
                                  chilled_water_loop: chilled_water_loop,
                                  fan_efficiency: 0.62,
                                  fan_motor_efficiency: 0.9,
                                  fan_pressure_rise: 4.0)
        end
        # Add a PSZ_HP for each secondary zone
        unless sec_zones.empty?
          model_add_prm_baseline_system(model, 'PSZ_HP', main_heat_fuel, zone_heat_fuel, cool_fuel, sec_zones)
        end
      end

    when 'Gas_Furnace' # System 9
      unless zones.empty?
        # If district heating
        hot_water_loop = nil
        if main_heat_fuel == 'DistrictHeating'
          hot_water_loop = if model.getPlantLoopByName('Hot Water Loop').is_initialized
                             model.getPlantLoopByName('Hot Water Loop').get
                           else
                             model_add_hw_loop(model, main_heat_fuel)
                           end
        end
        # Add a System 9 - Gas Unit Heater to each zone
        model_add_unitheater(model,
                             zones,
                             fan_control_type: 'ConstantVolume',
                             fan_pressure_rise: 0.2,
                             heating_type: main_heat_fuel,
                             hot_water_loop: hot_water_loop)
      end

    when 'Electric_Furnace' # System 10
      unless zones.empty?
        # Add a System 10 - Electric Unit Heater to each zone
        model_add_unitheater(model,
                             zones,
                             fan_control_type: 'ConstantVolume',
                             fan_pressure_rise: 0.2,
                             heating_type: main_heat_fuel)
      end

    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "System type #{system_type} is not a valid choice, nothing will be added to the model.")
      return false
  end
  return true
end

#model_add_psz_ac(model, thermal_zones, system_name: nil, cooling_type: 'Single Speed DX AC', chilled_water_loop: nil, hot_water_loop: nil, heating_type: nil, supplemental_heating_type: nil, fan_location: 'DrawThrough', fan_type: 'ConstantVolume', hvac_op_sch: nil, oa_damper_sch: nil) ⇒ Array<OpenStudio::Model::AirLoopHVAC>

Creates a PSZ-AC system for each zone and adds it to the model.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • system_name (String) (defaults to: nil)

    the name of the system, or nil in which case it will be defaulted

  • cooling_type (String) (defaults to: 'Single Speed DX AC')

    valid choices are Water, Two Speed DX AC, Single Speed DX AC, Single Speed Heat Pump, Water To Air Heat Pump

  • chilled_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    chilled water loop to connect cooling coil to, or nil

  • hot_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    hot water loop to connect heating coil to, or nil

  • heating_type (String) (defaults to: nil)

    valid choices are NaturalGas, Electricity, Water, Single Speed Heat Pump, Water To Air Heat Pump, or nil (no heat)

  • supplemental_heating_type (String) (defaults to: nil)

    valid choices are Electricity, NaturalGas, nil (no heat)

  • fan_location (String) (defaults to: 'DrawThrough')

    valid choices are BlowThrough, DrawThrough

  • fan_type (String) (defaults to: 'ConstantVolume')

    valid choices are ConstantVolume, Cycling

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule or nil in which case will be defaulted to always on

  • oa_damper_sch (String) (defaults to: nil)

    name of the oa damper schedule or nil in which case will be defaulted to always open

Returns:



2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 2428

def model_add_psz_ac(model,
                     thermal_zones,
                     system_name: nil,
                     cooling_type: 'Single Speed DX AC',
                     chilled_water_loop: nil,
                     hot_water_loop: nil,
                     heating_type: nil,
                     supplemental_heating_type: nil,
                     fan_location: 'DrawThrough',
                     fan_type: 'ConstantVolume',
                     hvac_op_sch: nil,
                     oa_damper_sch: nil)

  # hvac operation schedule
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # oa damper schedule
  if oa_damper_sch.nil?
    oa_damper_sch = model.alwaysOnDiscreteSchedule
  else
    oa_damper_sch = model_add_schedule(model, oa_damper_sch)
  end

  # create a PSZ-AC for each zone
  air_loops = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding PSZ-AC for #{zone.name}.")

    air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
    if system_name.nil?
      air_loop.setName("#{zone.name} PSZ-AC")
    else
      air_loop.setName("#{zone.name} #{system_name}")
    end

    # default design temperatures and settings used across all air loops
    dsgn_temps = standard_design_sizing_temperatures
    unless hot_water_loop.nil?
      hw_temp_c = hot_water_loop.sizingPlant.designLoopExitTemperature
      hw_delta_t_k = hot_water_loop.sizingPlant.loopDesignTemperatureDifference
    end

    # adjusted design heating temperature for psz_ac
    dsgn_temps['zn_htg_dsgn_sup_air_temp_f'] = 122.0
    dsgn_temps['zn_htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_htg_dsgn_sup_air_temp_f'], 'F', 'C').get
    dsgn_temps['htg_dsgn_sup_air_temp_f'] = dsgn_temps['zn_htg_dsgn_sup_air_temp_f']
    dsgn_temps['htg_dsgn_sup_air_temp_c'] = dsgn_temps['zn_htg_dsgn_sup_air_temp_c']

    # default design settings used across all air loops
    sizing_system = adjust_sizing_system(air_loop, dsgn_temps, min_sys_airflow_ratio: 1.0)

    # air handler controls
    # add a setpoint manager single zone reheat to control the supply air temperature
    setpoint_mgr_single_zone_reheat = OpenStudio::Model::SetpointManagerSingleZoneReheat.new(model)
    setpoint_mgr_single_zone_reheat.setName("#{zone.name} Setpoint Manager SZ Reheat")
    setpoint_mgr_single_zone_reheat.setControlZone(zone)
    setpoint_mgr_single_zone_reheat.setMinimumSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    setpoint_mgr_single_zone_reheat.setMaximumSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    setpoint_mgr_single_zone_reheat.addToNode(air_loop.supplyOutletNode)

    # zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])

    # create heating coil
    case heating_type
    when 'NaturalGas', 'Gas'
      htg_coil = create_coil_heating_gas(model,
                                         name: "#{air_loop.name} Gas Htg Coil")
    when 'Water'
      if hot_water_loop.nil?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'No hot water plant loop supplied')
        return false
      end
      htg_coil = create_coil_heating_water(model,
                                           hot_water_loop,
                                           name: "#{air_loop.name} Water Htg Coil",
                                           rated_inlet_water_temperature: hw_temp_c,
                                           rated_outlet_water_temperature: (hw_temp_c - hw_delta_t_k),
                                           rated_inlet_air_temperature: dsgn_temps['prehtg_dsgn_sup_air_temp_c'],
                                           rated_outlet_air_temperature: dsgn_temps['htg_dsgn_sup_air_temp_c'])
    when 'Single Speed Heat Pump'
      htg_coil = create_coil_heating_dx_single_speed(model,
                                                     name: "#{zone.name} HP Htg Coil",
                                                     type: 'PSZ-AC',
                                                     cop: 3.3)
    when 'Water To Air Heat Pump'
      htg_coil = create_coil_heating_water_to_air_heat_pump_equation_fit(model,
                                                                         hot_water_loop,
                                                                         name: "#{air_loop.name} Water-to-Air HP Htg Coil")
    when 'Electricity', 'Electric'
      htg_coil = create_coil_heating_electric(model,
                                              name: "#{air_loop.name} Electric Htg Coil")
    else
      # zero-capacity, always-off electric heating coil
      htg_coil = create_coil_heating_electric(model,
                                              name: "#{air_loop.name} No Heat",
                                              schedule: model.alwaysOffDiscreteSchedule,
                                              nominal_capacity: 0.0)
    end

    # create supplemental heating coil
    case supplemental_heating_type
    when 'Electricity', 'Electric'
      supplemental_htg_coil = create_coil_heating_electric(model,
                                                           name: "#{air_loop.name} Electric Backup Htg Coil")
    when 'NaturalGas', 'Gas'
      supplemental_htg_coil = create_coil_heating_gas(model,
                                                      name: "#{air_loop.name} Gas Backup Htg Coil")
    else
      # Zero-capacity, always-off electric heating coil
      supplemental_htg_coil = create_coil_heating_electric(model,
                                                           name: "#{air_loop.name} No Heat",
                                                           schedule: model.alwaysOffDiscreteSchedule,
                                                           nominal_capacity: 0.0)
    end

    # create cooling coil
    case cooling_type
    when 'Water'
      if chilled_water_loop.nil?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'No chilled water plant loop supplied')
        return false
      end
      clg_coil = create_coil_cooling_water(model,
                                           chilled_water_loop,
                                           name: "#{air_loop.name} Water Clg Coil")
    when 'Two Speed DX AC'
      clg_coil = create_coil_cooling_dx_two_speed(model,
                                                  name: "#{air_loop.name} 2spd DX AC Clg Coil")
    when 'Single Speed DX AC'
      clg_coil = create_coil_cooling_dx_single_speed(model,
                                                     name: "#{air_loop.name} 1spd DX AC Clg Coil",
                                                     type: 'PSZ-AC')
    when 'Single Speed Heat Pump'
      clg_coil = create_coil_cooling_dx_single_speed(model,
                                                     name: "#{air_loop.name} 1spd DX HP Clg Coil",
                                                     type: 'Heat Pump')
      # clg_coil.setMaximumOutdoorDryBulbTemperatureForCrankcaseHeaterOperation(OpenStudio::OptionalDouble.new(10.0))
      # clg_coil.setRatedSensibleHeatRatio(0.69)
      # clg_coil.setBasinHeaterCapacity(10)
      # clg_coil.setBasinHeaterSetpointTemperature(2.0)
    when 'Water To Air Heat Pump'
      if chilled_water_loop.nil?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'No chilled water plant loop supplied')
        return false
      end
      clg_coil = create_coil_cooling_water_to_air_heat_pump_equation_fit(model,
                                                                         chilled_water_loop,
                                                                         name: "#{air_loop.name} Water-to-Air HP Clg Coil")
    else
      clg_coil = nil
    end

    # Use a Fan:OnOff in the unitary system object
    case fan_type
    when 'Cycling'
      fan = create_fan_by_name(model,
                               'Packaged_RTU_SZ_AC_Cycling_Fan',
                               fan_name: "#{air_loop.name} Fan")
    when 'ConstantVolume'
      fan = create_fan_by_name(model,
                               'Packaged_RTU_SZ_AC_CAV_OnOff_Fan',
                               fan_name: "#{air_loop.name} Fan")
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'Invalid fan_type')
      return false
    end

    # fan location
    if fan_location.nil?
      fan_location = 'DrawThrough'
    end
    case fan_location
    when 'DrawThrough', 'BlowThrough'
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "Setting fan location for #{fan.name} to #{fan_location}.")
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "Invalid fan_location #{fan_location} for fan #{fan.name}.")
      return false
    end

    # construct unitary system object
    unitary_system = OpenStudio::Model::AirLoopHVACUnitarySystem.new(model)
    unitary_system.setSupplyFan(fan) unless fan.nil?
    unitary_system.setHeatingCoil(htg_coil) unless htg_coil.nil?
    unitary_system.setCoolingCoil(clg_coil) unless clg_coil.nil?
    unitary_system.setSupplementalHeatingCoil(supplemental_htg_coil) unless supplemental_htg_coil.nil?
    unitary_system.setControllingZoneorThermostatLocation(zone)
    unitary_system.setFanPlacement(fan_location)
    unitary_system.addToNode(air_loop.supplyInletNode)

    # added logic and naming for heat pumps
    case heating_type
    when 'Water To Air Heat Pump'
      unitary_system.setMaximumOutdoorDryBulbTemperatureforSupplementalHeaterOperation(OpenStudio.convert(40.0, 'F', 'C').get)
      unitary_system.setName("#{air_loop.name} Unitary HP")
      unitary_system.setMaximumSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
      unitary_system.setSupplyAirFlowRateMethodDuringCoolingOperation('SupplyAirFlowRate')
      unitary_system.setSupplyAirFlowRateMethodDuringHeatingOperation('SupplyAirFlowRate')
      unitary_system.setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired('SupplyAirFlowRate')
    when 'Single Speed Heat Pump'
      unitary_system.setMaximumOutdoorDryBulbTemperatureforSupplementalHeaterOperation(OpenStudio.convert(40.0, 'F', 'C').get)
      unitary_system.setName("#{air_loop.name} Unitary HP")
    else
      unitary_system.setName("#{air_loop.name} Unitary AC")
    end

    # specify control logic
    unitary_system.setAvailabilitySchedule(hvac_op_sch)
    if fan_type == 'Cycling'
      unitary_system.setSupplyAirFanOperatingModeSchedule(model.alwaysOffDiscreteSchedule)
    else # constant volume operation
      unitary_system.setSupplyAirFanOperatingModeSchedule(hvac_op_sch)
    end

    # add the OA system
    oa_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
    oa_controller.setName("#{air_loop.name} OA System Controller")
    oa_controller.setMinimumOutdoorAirSchedule(oa_damper_sch)
    oa_controller.autosizeMinimumOutdoorAirFlowRate
    oa_controller.resetEconomizerMinimumLimitDryBulbTemperature
    oa_system = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_controller)
    oa_system.setName("#{air_loop.name} OA System")
    oa_system.addToNode(air_loop.supplyInletNode)

    # TODO: enable economizer maximum fraction outdoor air schedule input
    # econ_eff_sch = model_add_schedule(model, 'RetailStandalone PSZ_Econ_MaxOAFrac_Sch')

    # set air loop availability controls and night cycle manager, after oa system added
    air_loop.setAvailabilitySchedule(hvac_op_sch)
    air_loop.setNightCycleControlType('CycleOnAny')
    avail_mgr = air_loop.availabilityManager
    if avail_mgr.is_initialized
      avail_mgr = avail_mgr.get
      if avail_mgr.to_AvailabilityManagerNightCycle.is_initialized
        avail_mgr = avail_mgr.to_AvailabilityManagerNightCycle.get
        avail_mgr.setCyclingRunTime(1800)
      end
    end

    # create a diffuser and attach the zone/diffuser pair to the air loop
    diffuser = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule)
    diffuser.setName("#{air_loop.name} Diffuser")
    air_loop.multiAddBranchForZone(zone, diffuser.to_HVACComponent.get)
    air_loops << air_loop
  end

  return air_loops
end

#model_add_psz_vav(model, thermal_zones, system_name: nil, heating_type: nil, supplemental_heating_type: nil, hvac_op_sch: nil, oa_damper_sch: nil) ⇒ Array<OpenStudio::Model::AirLoopHVAC>

Creates a packaged single zone VAV system for each zone and adds it to the model.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • system_name (String) (defaults to: nil)

    the name of the system, or nil in which case it will be defaulted

  • heating_type (String) (defaults to: nil)

    valid choices are NaturalGas, Electricity, Water, nil (no heat)

  • supplemental_heating_type (String) (defaults to: nil)

    valid choices are Electricity, NaturalGas, nil (no heat)

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule or nil in which case will be defaulted to always on

  • oa_damper_sch (String) (defaults to: nil)

    name of the oa damper schedule or nil in which case will be defaulted to always open

Returns:



2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 2692

def model_add_psz_vav(model,
                      thermal_zones,
                      system_name: nil,
                      heating_type: nil,
                      supplemental_heating_type: nil,
                      hvac_op_sch: nil,
                      oa_damper_sch: nil)

  # hvac operation schedule
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # oa damper schedule
  if oa_damper_sch.nil?
    oa_damper_sch = model.alwaysOnDiscreteSchedule
  else
    oa_damper_sch = model_add_schedule(model, oa_damper_sch)
  end

  # create a PSZ-VAV for each zone
  air_loops = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding PSZ-VAV for #{zone.name}.")

    air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
    if system_name.nil?
      air_loop.setName("#{zone.name} PSZ-VAV")
    else
      air_loop.setName("#{zone.name} #{system_name}")
    end

    # default design temperatures used across all air loops
    dsgn_temps = standard_design_sizing_temperatures

    # adjusted zone design heating temperature for psz_vav
    dsgn_temps['htg_dsgn_sup_air_temp_f'] = dsgn_temps['zn_htg_dsgn_sup_air_temp_f']
    dsgn_temps['htg_dsgn_sup_air_temp_c'] = dsgn_temps['zn_htg_dsgn_sup_air_temp_c']

    # default design settings used across all air loops
    sizing_system = adjust_sizing_system(air_loop, dsgn_temps)

    # air handler controls
    # add a setpoint manager single zone reheat to control the supply air temperature
    setpoint_mgr_single_zone_reheat = OpenStudio::Model::SetpointManagerSingleZoneReheat.new(model)
    setpoint_mgr_single_zone_reheat.setName("#{zone.name} Setpoint Manager SZ Reheat")
    setpoint_mgr_single_zone_reheat.setControlZone(zone)
    setpoint_mgr_single_zone_reheat.setMinimumSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    setpoint_mgr_single_zone_reheat.setMaximumSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    setpoint_mgr_single_zone_reheat.addToNode(air_loop.supplyOutletNode)

    # zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])

    # create fan
    # @type [OpenStudio::Model::FanVariableVolume] fan
    fan = create_fan_by_name(model,
                             'VAV_System_Fan',
                             fan_name: "#{air_loop.name} Fan",
                             end_use_subcategory: 'VAV System Fans')
    fan.setAvailabilitySchedule(hvac_op_sch)

    # create heating coil
    case heating_type
    when 'NaturalGas', 'Gas'
      htg_coil = create_coil_heating_gas(model,
                                         name: "#{air_loop.name} Gas Htg Coil")
    when 'Electricity', 'Electric'
      htg_coil = create_coil_heating_electric(model,
                                              name: "#{air_loop.name} Electric Htg Coil")
    else
      # Zero-capacity, always-off electric heating coil
      htg_coil = create_coil_heating_electric(model,
                                              name: "#{air_loop.name} No Heat",
                                              schedule: model.alwaysOffDiscreteSchedule,
                                              nominal_capacity: 0.0)
    end

    # create supplemental heating coil
    case supplemental_heating_type
    when 'Electricity', 'Electric'
      supplemental_htg_coil = create_coil_heating_electric(model,
                                                           name: "#{air_loop.name} Electric Backup Htg Coil")
    when 'NaturalGas', 'Gas'
      supplemental_htg_coil = create_coil_heating_gas(model,
                                                      name: "#{air_loop.name} Gas Backup Htg Coil")
    else
      # zero-capacity, always-off electric heating coil
      supplemental_htg_coil = create_coil_heating_electric(model,
                                                           name: "#{air_loop.name} No Backup Heat",
                                                           schedule: model.alwaysOffDiscreteSchedule,
                                                           nominal_capacity: 0.0)
    end

    # create cooling coil
    clg_coil = OpenStudio::Model::CoilCoolingDXVariableSpeed.new(model)
    clg_coil.setName("#{air_loop.name} Var spd DX AC Clg Coil")
    clg_coil.setBasinHeaterCapacity(10.0)
    clg_coil.setBasinHeaterSetpointTemperature(2.0)
    # first speed level
    clg_spd_1 = OpenStudio::Model::CoilCoolingDXVariableSpeedSpeedData.new(model)
    clg_coil.addSpeed(clg_spd_1)
    clg_coil.setNominalSpeedLevel(1)

    # TODO: enable economizer maximum fraction outdoor air schedule input
    # econ_eff_sch = model_add_schedule(model, 'RetailStandalone PSZ_Econ_MaxOAFrac_Sch')

    # wrap coils in a unitary system
    unitary_system = OpenStudio::Model::AirLoopHVACUnitarySystem.new(model)
    unitary_system.setSupplyFan(fan)
    unitary_system.setHeatingCoil(htg_coil)
    unitary_system.setCoolingCoil(clg_coil)
    unitary_system.setSupplementalHeatingCoil(supplemental_htg_coil)
    unitary_system.setName("#{zone.name} Unitary PSZ-VAV")
    unitary_system.setString(2, 'SingleZoneVAV') # TODO: add setControlType() method
    unitary_system.setControllingZoneorThermostatLocation(zone)
    unitary_system.setMaximumSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    unitary_system.setFanPlacement('BlowThrough')
    unitary_system.setSupplyAirFlowRateMethodDuringCoolingOperation('SupplyAirFlowRate')
    unitary_system.setSupplyAirFlowRateMethodDuringHeatingOperation('SupplyAirFlowRate')
    unitary_system.setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired('SupplyAirFlowRate')
    unitary_system.setSupplyAirFanOperatingModeSchedule(model.alwaysOnDiscreteSchedule)
    unitary_system.addToNode(air_loop.supplyInletNode)

    # create outdoor air system
    oa_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
    oa_controller.setName("#{air_loop.name} OA Sys Controller")
    oa_controller.setMinimumOutdoorAirSchedule(oa_damper_sch)
    oa_controller.autosizeMinimumOutdoorAirFlowRate
    oa_controller.resetEconomizerMinimumLimitDryBulbTemperature
    oa_controller.setHeatRecoveryBypassControlType('BypassWhenOAFlowGreaterThanMinimum')
    oa_system = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_controller)
    oa_system.setName("#{air_loop.name} OA System")
    oa_system.addToNode(air_loop.supplyInletNode)

    # set air loop availability controls and night cycle manager, after oa system added
    air_loop.setAvailabilitySchedule(hvac_op_sch)
    air_loop.setNightCycleControlType('CycleOnAny')

    # create a VAV no reheat terminal and attach the zone/terminal pair to the air loop
    diffuser = OpenStudio::Model::AirTerminalSingleDuctVAVNoReheat.new(model, model.alwaysOnDiscreteSchedule)
    diffuser.setName("#{air_loop.name} Diffuser")
    air_loop.multiAddBranchForZone(zone, diffuser.to_HVACComponent.get)
    air_loops << air_loop
  end

  return air_loops
end

#model_add_ptac(model, thermal_zones, cooling_type: 'Two Speed DX AC', heating_type: 'Gas', hot_water_loop: nil, fan_type: 'Cycling', ventilation: true) ⇒ Array<OpenStudio::Model::ZoneHVACPackagedTerminalAirConditioner>

Creates a PTAC system for each zone and adds it to the model.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • cooling_type (String) (defaults to: 'Two Speed DX AC')

    valid choices are Two Speed DX AC, Single Speed DX AC

  • heating_type (String) (defaults to: 'Gas')

    valid choices are NaturalGas, Electricity, Water, nil (no heat)

  • hot_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    hot water loop to connect heating coil to. Set to nil for heating types besides water

  • fan_type (String) (defaults to: 'Cycling')

    valid choices are ConstantVolume, Cycling

  • ventilation (Bool) (defaults to: true)

    If true, ventilation will be supplied through the unit. If false, no ventilation will be supplied through the unit, with the expectation that it will be provided by a DOAS or separate system.

Returns:



3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 3675

def model_add_ptac(model,
                   thermal_zones,
                   cooling_type: 'Two Speed DX AC',
                   heating_type: 'Gas',
                   hot_water_loop: nil,
                   fan_type: 'Cycling',
                   ventilation: true)

  # default design temperatures used across all air loops
  dsgn_temps = standard_design_sizing_temperatures
  unless hot_water_loop.nil?
    hw_temp_c = hot_water_loop.sizingPlant.designLoopExitTemperature
    hw_delta_t_k = hot_water_loop.sizingPlant.loopDesignTemperatureDifference
  end

  # adjusted zone design temperatures for ptac
  dsgn_temps['zn_htg_dsgn_sup_air_temp_f'] = 122.0
  dsgn_temps['zn_htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_htg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['zn_clg_dsgn_sup_air_temp_f'] = 57.0
  dsgn_temps['zn_clg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_clg_dsgn_sup_air_temp_f'], 'F', 'C').get

  # make a PTAC for each zone
  ptacs = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding PTAC for #{zone.name}.")

    # zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneCoolingDesignSupplyAirHumidityRatio(0.008)
    sizing_zone.setZoneHeatingDesignSupplyAirHumidityRatio(0.008)

    # add fan
    if fan_type == 'ConstantVolume'
      fan = create_fan_by_name(model,
                               'PTAC_CAV_Fan',
                               fan_name: "#{zone.name} PTAC Fan")
    elsif fan_type == 'Cycling'
      fan = create_fan_by_name(model,
                               'PTAC_Cycling_Fan',
                               fan_name: "#{zone.name} PTAC Fan")
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "ptac_fan_type of #{fan_type} is not recognized.")
    end
    fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)

    # add heating coil
    case heating_type
    when 'NaturalGas', 'Gas'
      htg_coil = create_coil_heating_gas(model,
                                         name: "#{zone.name} PTAC Gas Htg Coil")
    when 'Electricity', 'Electric'
      htg_coil = create_coil_heating_electric(model,
                                              name: "#{zone.name} PTAC Electric Htg Coil")
    when nil
      htg_coil = create_coil_heating_electric(model,
                                              name: "#{zone.name} PTAC No Heat",
                                              schedule: model.alwaysOffDiscreteSchedule,
                                              nominal_capacity: 0)
    when 'Water'
      if hot_water_loop.nil?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'No hot water plant loop supplied')
        return false
      end
      htg_coil = create_coil_heating_water(model,
                                           hot_water_loop,
                                           name: "#{hot_water_loop.name} Water Htg Coil",
                                           rated_inlet_water_temperature: hw_temp_c,
                                           rated_outlet_water_temperature: (hw_temp_c - hw_delta_t_k))
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "ptac_heating_type of #{heating_type} is not recognized.")
    end

    # add cooling coil
    if cooling_type == 'Two Speed DX AC'
      clg_coil = create_coil_cooling_dx_two_speed(model,
                                                  name: "#{zone.name} PTAC 2spd DX AC Clg Coil")
    elsif cooling_type == 'Single Speed DX AC'
      clg_coil = create_coil_cooling_dx_single_speed(model,
                                                     name: "#{zone.name} PTAC 1spd DX AC Clg Coil",
                                                     type: 'PTAC')
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "ptac_cooling_type of #{cooling_type} is not recognized.")
    end

    # wrap coils in a PTAC system
    ptac_system = OpenStudio::Model::ZoneHVACPackagedTerminalAirConditioner.new(model,
                                                                                model.alwaysOnDiscreteSchedule,
                                                                                fan,
                                                                                htg_coil,
                                                                                clg_coil)
    ptac_system.setName("#{zone.name} PTAC")
    ptac_system.setFanPlacement('DrawThrough')
    if fan_type == 'ConstantVolume'
      ptac_system.setSupplyAirFanOperatingModeSchedule(model.alwaysOnDiscreteSchedule)
    else
      ptac_system.setSupplyAirFanOperatingModeSchedule(model.alwaysOffDiscreteSchedule)
    end
    unless ventilation
      ptac_system.setOutdoorAirFlowRateDuringCoolingOperation(0.0)
      ptac_system.setOutdoorAirFlowRateDuringHeatingOperation(0.0)
      ptac_system.setOutdoorAirFlowRateWhenNoCoolingorHeatingisNeeded(0.0)
    end
    ptac_system.addToThermalZone(zone)
    ptacs << ptac_system
  end

  return ptacs
end

#model_add_pthp(model, thermal_zones, fan_type: 'Cycling', ventilation: true) ⇒ Array<OpenStudio::Model::ZoneHVACPackagedTerminalAirConditioner>

Creates a PTHP system for each zone and adds it to the model.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • fan_type (String) (defaults to: 'Cycling')

    valid choices are ConstantVolume, Cycling

  • ventilation (Bool) (defaults to: true)

    If true, ventilation will be supplied through the unit. If false, no ventilation will be supplied through the unit, with the expectation that it will be provided by a DOAS or separate system.

Returns:



3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 3793

def model_add_pthp(model,
                   thermal_zones,
                   fan_type: 'Cycling',
                   ventilation: true)

  # default design temperatures used across all air loops
  dsgn_temps = standard_design_sizing_temperatures

  # adjusted zone design temperatures for pthp
  dsgn_temps['zn_htg_dsgn_sup_air_temp_f'] = 122.0
  dsgn_temps['zn_htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_htg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['zn_clg_dsgn_sup_air_temp_f'] = 57.0
  dsgn_temps['zn_clg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_clg_dsgn_sup_air_temp_f'], 'F', 'C').get

  # make a PTHP for each zone
  pthps = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding PTHP for #{zone.name}.")

    # zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneCoolingDesignSupplyAirHumidityRatio(0.008)
    sizing_zone.setZoneHeatingDesignSupplyAirHumidityRatio(0.008)

    # add fan
    if fan_type == 'ConstantVolume'
      fan = create_fan_by_name(model,
                               'PTAC_CAV_Fan',
                               fan_name: "#{zone.name} PTHP Fan")
    elsif fan_type == 'Cycling'
      fan = create_fan_by_name(model,
                               'PTAC_Cycling_Fan',
                               fan_name: "#{zone.name} PTHP Fan")
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "PTHP fan_type of #{fan_type} is not recognized.")
      return false
    end
    fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)

    # add heating coil
    htg_coil = create_coil_heating_dx_single_speed(model,
                                                   name: "#{zone.name} PTHP Htg Coil")
    # add cooling coil
    clg_coil = create_coil_cooling_dx_single_speed(model,
                                                   name: "#{zone.name} PTHP Clg Coil",
                                                   type: 'Heat Pump')
    # supplemental heating coil
    supplemental_htg_coil = create_coil_heating_electric(model,
                                                         name: "#{zone.name} PTHP Supplemental Htg Coil")
    # wrap coils in a PTHP system
    pthp_system = OpenStudio::Model::ZoneHVACPackagedTerminalHeatPump.new(model,
                                                                          model.alwaysOnDiscreteSchedule,
                                                                          fan,
                                                                          htg_coil,
                                                                          clg_coil,
                                                                          supplemental_htg_coil)
    pthp_system.setName("#{zone.name} PTHP")
    pthp_system.setFanPlacement('DrawThrough')
    pthp_system.setSupplyAirFanOperatingModeSchedule(model.alwaysOffDiscreteSchedule)
    if fan_type == 'ConstantVolume'
      pthp_system.setSupplyAirFanOperatingModeSchedule(model.alwaysOnDiscreteSchedule)
    else
      pthp_system.setSupplyAirFanOperatingModeSchedule(model.alwaysOffDiscreteSchedule)
    end
    unless ventilation
      pthp_system.setOutdoorAirFlowRateDuringCoolingOperation(0.0)
      pthp_system.setOutdoorAirFlowRateDuringHeatingOperation(0.0)
      pthp_system.setOutdoorAirFlowRateWhenNoCoolingorHeatingisNeeded(0.0)
    end
    pthp_system.addToThermalZone(zone)
    pthps << pthp_system
  end

  return pthps
end

#model_add_pvav(model, thermal_zones, system_name: nil, return_plenum: nil, hot_water_loop: nil, chilled_water_loop: nil, heating_type: nil, electric_reheat: false, hvac_op_sch: nil, oa_damper_sch: nil) ⇒ OpenStudio::Model::AirLoopHVAC

Creates a packaged VAV system and adds it to the model.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • system_name (String) (defaults to: nil)

    the name of the system, or nil in which case it will be defaulted

  • return_plenum (OpenStudio::Model::ThermalZone) (defaults to: nil)

    the zone to attach as the supply plenum, or nil, in which case no return plenum will be used

  • hot_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    hot water loop to connect heating and reheat coils to. If nil, will be electric heat and electric reheat

  • chilled_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    chilled water loop to connect cooling coils to. If nil, will be DX cooling

  • heating_type (String) (defaults to: nil)

    main heating coil fuel type valid choices are NaturalGas, Electricity, Water, or nil (defaults to NaturalGas)

  • electric_reheat (Bool) (defaults to: false)

    if true electric reheat coils, if false the reheat coils served by hot_water_loop

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule or nil in which case will be defaulted to always on

  • oa_damper_sch (String) (defaults to: nil)

    name of the oa damper schedule or nil in which case will be defaulted to always open

Returns:



1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 1940

def model_add_pvav(model,
                   thermal_zones,
                   system_name: nil,
                   return_plenum: nil,
                   hot_water_loop: nil,
                   chilled_water_loop: nil,
                   heating_type: nil,
                   electric_reheat: false,
                   hvac_op_sch: nil,
                   oa_damper_sch: nil)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding Packaged VAV for #{thermal_zones.size} zones.")

  # create air handler
  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  if system_name.nil?
    air_loop.setName("#{thermal_zones.size} Zone PVAV")
  else
    air_loop.setName(system_name)
  end

  # hvac operation schedule
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # oa damper schedule
  if oa_damper_sch.nil?
    oa_damper_sch = model.alwaysOnDiscreteSchedule
  else
    oa_damper_sch = model_add_schedule(model, oa_damper_sch)
  end

  # default design temperatures used across all air loops
  dsgn_temps = standard_design_sizing_temperatures
  unless hot_water_loop.nil?
    hw_temp_c = hot_water_loop.sizingPlant.designLoopExitTemperature
    hw_delta_t_k = hot_water_loop.sizingPlant.loopDesignTemperatureDifference
  end

  # adjusted zone design heating temperature for pvav unless it would cause a temperature higher than reheat water supply temperature
  unless !hot_water_loop.nil? && hw_temp_c < OpenStudio.convert(140.0, 'F', 'C').get
    dsgn_temps['zn_htg_dsgn_sup_air_temp_f'] = 122.0
    dsgn_temps['zn_htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_htg_dsgn_sup_air_temp_f'], 'F', 'C').get
  end

  # default design settings used across all air loops
  sizing_system = adjust_sizing_system(air_loop, dsgn_temps)

  # air handler controls
  sa_temp_sch = model_add_constant_schedule_ruleset(model,
                                                    dsgn_temps['clg_dsgn_sup_air_temp_c'],
                                                    name = "Supply Air Temp - #{dsgn_temps['clg_dsgn_sup_air_temp_f']}F")
  sa_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, sa_temp_sch)
  sa_stpt_manager.setName("#{air_loop.name} Supply Air Setpoint Manager")
  sa_stpt_manager.addToNode(air_loop.supplyOutletNode)

  # create fan
  fan = create_fan_by_name(model,
                           'VAV_default',
                           fan_name: "#{air_loop.name} Fan")
  fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  fan.addToNode(air_loop.supplyInletNode)

  # create heating coil
  if hot_water_loop.nil?
    if heating_type == 'Electricity'
      create_coil_heating_electric(model,
                                   air_loop_node: air_loop.supplyInletNode,
                                   name: "#{air_loop.name} Main Electric Htg Coil")
    else # default to NaturalGas
      create_coil_heating_gas(model,
                              air_loop_node: air_loop.supplyInletNode,
                              name: "#{air_loop.name} Main Gas Htg Coil")
    end
  else
    create_coil_heating_water(model,
                              hot_water_loop,
                              air_loop_node: air_loop.supplyInletNode,
                              name: "#{air_loop.name} Main Htg Coil",
                              rated_inlet_water_temperature: hw_temp_c,
                              rated_outlet_water_temperature: (hw_temp_c - hw_delta_t_k),
                              rated_inlet_air_temperature: dsgn_temps['prehtg_dsgn_sup_air_temp_c'],
                              rated_outlet_air_temperature: dsgn_temps['htg_dsgn_sup_air_temp_c'])
  end

  # create cooling coil
  if chilled_water_loop.nil?
    create_coil_cooling_dx_two_speed(model,
                                     air_loop_node: air_loop.supplyInletNode,
                                     name: "#{air_loop.name} 2spd DX Clg Coil",
                                     type: 'OS default')
  else
    create_coil_cooling_water(model,
                              chilled_water_loop,
                              air_loop_node: air_loop.supplyInletNode,
                              name: "#{air_loop.name} Clg Coil")
  end

  # Outdoor air intake system
  oa_intake_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
  oa_intake_controller.setMinimumLimitType('FixedMinimum')
  oa_intake_controller.autosizeMinimumOutdoorAirFlowRate
  oa_intake_controller.setMinimumOutdoorAirSchedule(oa_damper_sch)
  oa_intake_controller.resetEconomizerMinimumLimitDryBulbTemperature
  oa_intake = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
  oa_intake.setName("#{air_loop.name} OA System")
  oa_intake.addToNode(air_loop.supplyInletNode)
  controller_mv = oa_intake_controller.controllerMechanicalVentilation
  controller_mv.setName("#{air_loop.name} Ventilation Controller")
  controller_mv.setAvailabilitySchedule(oa_damper_sch)

  # set air loop availability controls and night cycle manager, after oa system added
  air_loop.setAvailabilitySchedule(hvac_op_sch)
  air_loop.setNightCycleControlType('CycleOnAny')
  avail_mgr = air_loop.availabilityManager
  if avail_mgr.is_initialized
    avail_mgr = avail_mgr.get
    if avail_mgr.to_AvailabilityManagerNightCycle.is_initialized
      avail_mgr = avail_mgr.to_AvailabilityManagerNightCycle.get
      avail_mgr.setCyclingRunTime(1800)
    end
  end

  # attach the VAV system to each zone
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "Adding PVAV terminal for #{zone.name}")

    # create reheat coil
    if electric_reheat || hot_water_loop.nil?
      rht_coil = create_coil_heating_electric(model,
                                              name: "#{zone.name} Electric Reheat Coil")
    else
      rht_coil = create_coil_heating_water(model,
                                           hot_water_loop,
                                           name: "#{zone.name} Reheat Coil",
                                           rated_inlet_water_temperature: hw_temp_c,
                                           rated_outlet_water_temperature: (hw_temp_c - hw_delta_t_k),
                                           rated_inlet_air_temperature: dsgn_temps['htg_dsgn_sup_air_temp_c'],
                                           rated_outlet_air_temperature: dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    end

    # create VAV terminal
    terminal = OpenStudio::Model::AirTerminalSingleDuctVAVReheat.new(model, model.alwaysOnDiscreteSchedule, rht_coil)
    terminal.setName("#{zone.name} VAV Terminal")
    if model.version < OpenStudio::VersionString.new('3.0.1')
      terminal.setZoneMinimumAirFlowMethod('Constant')
    else
      terminal.setZoneMinimumAirFlowInputMethod('Constant')
    end
    terminal.setMaximumReheatAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    air_loop.multiAddBranchForZone(zone, terminal.to_HVACComponent.get)
    air_terminal_single_duct_vav_reheat_apply_initial_prototype_damper_position(terminal, thermal_zone_outdoor_airflow_rate_per_area(zone))

    unless return_plenum.nil?
      zone.setReturnPlenum(return_plenum)
    end

    # zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
  end

  # Design outdoor air calculation based on VRP if applicable (prototypes maintained by PNNL)
  model_system_outdoor_air_sizing_vrp_method(air_loop)

  # set the damper action based on the template
  air_loop_hvac_apply_vav_damper_action(air_loop)

  return true
end

#model_add_pvav_pfp_boxes(model, thermal_zones, system_name: nil, chilled_water_loop: nil, hvac_op_sch: nil, oa_damper_sch: nil, fan_efficiency: 0.62, fan_motor_efficiency: 0.9, fan_pressure_rise: 4.0) ⇒ OpenStudio::Model::AirLoopHVAC

Creates a packaged VAV system with parallel fan powered boxes and adds it to the model.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • system_name (String) (defaults to: nil)

    the name of the system, or nil in which case it will be defaulted

  • chilled_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    chilled water loop to connect cooling coils to. If nil, will be DX cooling

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule or nil in which case will be defaulted to always on

  • oa_damper_sch (String) (defaults to: nil)

    name of the oa damper schedule or nil in which case will be defaulted to always open

  • fan_efficiency (Double) (defaults to: 0.62)

    fan total efficiency, including motor and impeller

  • fan_motor_efficiency (Double) (defaults to: 0.9)

    fan motor efficiency

  • fan_pressure_rise (Double) (defaults to: 4.0)

    fan pressure rise, inH2O

Returns:



2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 2125

def model_add_pvav_pfp_boxes(model,
                             thermal_zones,
                             system_name: nil,
                             chilled_water_loop: nil,
                             hvac_op_sch: nil,
                             oa_damper_sch: nil,
                             fan_efficiency: 0.62,
                             fan_motor_efficiency: 0.9,
                             fan_pressure_rise: 4.0)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding PVAV with PFP Boxes and Reheat system for #{thermal_zones.size} zones.")

  # create air handler
  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  if system_name.nil?
    air_loop.setName("#{thermal_zones.size} Zone PVAV with PFP Boxes and Reheat")
  else
    air_loop.setName(system_name)
  end

  # hvac operation schedule
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # oa damper schedule
  if oa_damper_sch.nil?
    oa_damper_sch = model.alwaysOnDiscreteSchedule
  else
    oa_damper_sch = model_add_schedule(model, oa_damper_sch)
  end

  # default design temperatures and settings used across all air loops
  dsgn_temps = standard_design_sizing_temperatures
  sizing_system = adjust_sizing_system(air_loop, dsgn_temps)

  # air handler controls
  sa_temp_sch = model_add_constant_schedule_ruleset(model,
                                                    dsgn_temps['clg_dsgn_sup_air_temp_c'],
                                                    name = "Supply Air Temp - #{dsgn_temps['clg_dsgn_sup_air_temp_f']}F")
  sa_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, sa_temp_sch)
  sa_stpt_manager.setName("#{air_loop.name} Supply Air Setpoint Manager")
  sa_stpt_manager.addToNode(air_loop.supplyOutletNode)

  # create fan
  # @type [OpenStudio::Model::FanVariableVolume] fan
  fan = create_fan_by_name(model,
                           'VAV_System_Fan',
                           fan_name: "#{air_loop.name} Fan",
                           fan_efficiency: fan_efficiency,
                           pressure_rise: fan_pressure_rise,
                           motor_efficiency: fan_motor_efficiency,
                           end_use_subcategory: 'VAV System Fans')
  fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  fan.addToNode(air_loop.supplyInletNode)

  # create heating coil
  create_coil_heating_electric(model,
                               air_loop_node: air_loop.supplyInletNode,
                               name: "#{air_loop.name} Main Htg Coil")

  # create cooling coil
  if chilled_water_loop.nil?
    create_coil_cooling_dx_two_speed(model,
                                     air_loop_node: air_loop.supplyInletNode,
                                     name: "#{air_loop.name} 2spd DX Clg Coil", type: 'OS default')
  else
    create_coil_cooling_water(model,
                              chilled_water_loop,
                              air_loop_node: air_loop.supplyInletNode,
                              name: "#{air_loop.name} Clg Coil")
  end

  # create outdoor air intake system
  oa_intake_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
  oa_intake_controller.setName("#{air_loop.name} OA Controller")
  oa_intake_controller.setMinimumLimitType('FixedMinimum')
  oa_intake_controller.autosizeMinimumOutdoorAirFlowRate
  oa_intake_controller.setMinimumOutdoorAirSchedule(oa_damper_sch)
  oa_intake_controller.resetEconomizerMinimumLimitDryBulbTemperature
  controller_mv = oa_intake_controller.controllerMechanicalVentilation
  controller_mv.setName("#{air_loop.name} Vent Controller")
  controller_mv.setSystemOutdoorAirMethod('ZoneSum')

  oa_intake = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
  oa_intake.setName("#{air_loop.name} OA System")
  oa_intake.addToNode(air_loop.supplyInletNode)

  # set air loop availability controls and night cycle manager, after oa system added
  air_loop.setAvailabilitySchedule(hvac_op_sch)
  air_loop.setNightCycleControlType('CycleOnAny')

  # attach the VAV system to each zone
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "Adding PVAV PFP Box to zone #{zone.name}")

    # create electric reheat coil
    rht_coil = create_coil_heating_electric(model,
                                            name: "#{zone.name} Electric Reheat Coil")

    # create terminal fan
    # @type [OpenStudio::Model::FanConstantVolume] pfp_fan
    pfp_fan = create_fan_by_name(model,
                                 'PFP_Fan',
                                 fan_name: "#{zone.name} PFP Term Fan")
    pfp_fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)

    # parallel fan powered terminal
    pfp_terminal = OpenStudio::Model::AirTerminalSingleDuctParallelPIUReheat.new(model,
                                                                                 model.alwaysOnDiscreteSchedule,
                                                                                 pfp_fan,
                                                                                 rht_coil)
    pfp_terminal.setName("#{zone.name} PFP Term")
    air_loop.multiAddBranchForZone(zone, pfp_terminal.to_HVACComponent.get)

    # adjust zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setCoolingDesignAirFlowMethod('DesignDay')
    sizing_zone.setHeatingDesignAirFlowMethod('DesignDay')
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
  end

  return air_loop
end

#model_add_radiant_proportional_controls(model, zone, radiant_loop, radiant_type: 'floor', model_occ_hr_start: 6.0, model_occ_hr_end: 18.0, proportional_gain: 0.3, minimum_operation: 1, weekend_temperature_reset: 2, early_reset_out_arg: 20, switch_over_time: 24.0) ⇒ Object

These EnergyPlus objects implement a proportional control for a single thermal zone with a radiant system.

Parameters:

  • zone (OpenStudio::Model::ThermalZone)

    ] zone to add radiant controls

  • radiant_loop (OpenStudio::Model::ZoneHVACLowTempRadiantVarFlow)

    ] radiant loop in thermal zone

  • radiant_type (String) (defaults to: 'floor')

    determines the surface of the radiant system for surface temperature output reporting options are ‘floor’ and ‘ceiling’

  • model_occ_hr_start (Double) (defaults to: 6.0)

    Starting hour of building occupancy

  • model_occ_hr_end (Double) (defaults to: 18.0)

    Ending hour of building occupancy

  • proportional_gain (Double) (defaults to: 0.3)

    Proportional gain constant (recommended 0.3 or less).

  • minimum_operation (Double) (defaults to: 1)

    Minimum number of hours of operation for radiant system before it shuts off.

  • weekend_temperature_reset (Double) (defaults to: 2)

    Weekend temperature reset for slab temperature setpoint in degree Celsius.

  • early_reset_out_arg (Double) (defaults to: 20)

    Time at which the weekend temperature reset is removed.

  • switch_over_time (Double) (defaults to: 24.0)

    Time limitation for when the system can switch between heating and cooling



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.radiant_system_controls.rb', line 16

def model_add_radiant_proportional_controls(model, zone, radiant_loop,
                                            radiant_type: 'floor',
                                            model_occ_hr_start: 6.0,
                                            model_occ_hr_end: 18.0,
                                            proportional_gain: 0.3,
                                            minimum_operation: 1,
                                            weekend_temperature_reset: 2,
                                            early_reset_out_arg: 20,
                                            switch_over_time: 24.0)

  zone_name = zone.name.to_s.gsub(/[ +-.]/, '_')
  zone_timestep = model.getTimestep.numberOfTimestepsPerHour

  if model.version < OpenStudio::VersionString.new('3.1.1')
    coil_cooling_radiant = radiant_loop.coolingCoil.to_CoilCoolingLowTempRadiantVarFlow.get
    coil_heating_radiant = radiant_loop.heatingCoil.to_CoilHeatingLowTempRadiantVarFlow.get
  else
    coil_cooling_radiant = radiant_loop.coolingCoil.get.to_CoilCoolingLowTempRadiantVarFlow.get
    coil_heating_radiant = radiant_loop.heatingCoil.get.to_CoilHeatingLowTempRadiantVarFlow.get
  end

  #####
  # List of schedule objects used to hold calculation results
  ####

  # cold water control actuator
  # Command to turn ON/OFF the cold water through the radiant system. 0=ON and 100=OFF
  # Large temperatures are used to ensure that the radiant system valve will fully open and close
  sch_radiant_clgsetp = model_add_constant_schedule_ruleset(model,
                                                            0.0,
                                                            name = "#{zone_name}_Sch_Radiant_ClgSetP")
  coil_cooling_radiant.setCoolingControlTemperatureSchedule(sch_radiant_clgsetp)
  cmd_cold_water_ctrl = OpenStudio::Model::EnergyManagementSystemActuator.new(sch_radiant_clgsetp,
                                                                              'Schedule:Year',
                                                                              'Schedule Value')
  cmd_cold_water_ctrl.setName("#{zone_name}_CMD_COLD_WATER_CTRL")

  # hot water control actuator
  # Command to turn ON/OFF the hot water through the radiant system. 60=ON and -60=OFF.
  # Large temperatures are used to to ensure that the radiant system valve will fully open and close
  sch_radiant_htgsetp = model_add_constant_schedule_ruleset(model,
                                                            -60.0,
                                                            name = "#{zone_name}_Sch_Radiant_HtgSetP")
  coil_heating_radiant.setHeatingControlTemperatureSchedule(sch_radiant_htgsetp)
  cmd_hot_water_ctrl = OpenStudio::Model::EnergyManagementSystemActuator.new(sch_radiant_htgsetp,
                                                                             'Schedule:Year',
                                                                             'Schedule Value')
  cmd_hot_water_ctrl.setName("#{zone_name}_CMD_HOT_WATER_CTRL")

  # set schedule type limits for hot water control
  hot_water_schedule_type_limits = model.getScheduleTypeLimitsByName('Radiant_Hot_water_Ctrl_Temperature_Limits')
  if hot_water_schedule_type_limits.is_initialized
    hot_water_schedule_type_limits = hot_water_schedule_type_limits.get
  else
    hot_water_schedule_type_limits = OpenStudio::Model::ScheduleTypeLimits.new(model)
    hot_water_schedule_type_limits.setName('Radiant_Hot_water_Ctrl_Temperature_Limits')
    hot_water_schedule_type_limits.setLowerLimitValue(-60.0)
    hot_water_schedule_type_limits.setUpperLimitValue(100.0)
    hot_water_schedule_type_limits.setNumericType('Continuous')
    hot_water_schedule_type_limits.setUnitType('Temperature')
  end
  sch_radiant_htgsetp.setScheduleTypeLimits(hot_water_schedule_type_limits)

  # Calculated active slab heating and cooling temperature setpoint. Default temperature is taken at the slab surface.
  sch_slab_sp = model_add_constant_schedule_ruleset(model,
                                                    21.0,
                                                    name = "#{zone_name}_Sch_Slab_SP")
  cmd_slab_sp = OpenStudio::Model::EnergyManagementSystemActuator.new(sch_slab_sp,
                                                                      'Schedule:Year',
                                                                      'Schedule Value')
  cmd_slab_sp.setName("#{zone_name}_CMD_SLAB_SP")

  # add output variable for slab setpoint temperature
  var = OpenStudio::Model::OutputVariable.new('Schedule Value', model)
  var.setKeyValue("#{zone_name}_Sch_Slab_SP")
  var.setReportingFrequency('Timestep')

  # Calculated cooling setpoint error. Calculated from upper comfort limit minus setpoint offset and 'measured' controlled zone temperature.
  sch_csp_error = model_add_constant_schedule_ruleset(model,
                                                      0.0,
                                                      name = "#{zone_name}_Sch_CSP_Error")
  cmd_csp_error = OpenStudio::Model::EnergyManagementSystemActuator.new(sch_csp_error,
                                                                        'Schedule:Year',
                                                                        'Schedule Value')
  cmd_csp_error.setName("#{zone_name}_CMD_CSP_ERROR")

  # Calculated heating setpoint error. Calculated from lower comfort limit plus setpoint offset and 'measured' controlled zone temperature.
  sch_hsp_error = model_add_constant_schedule_ruleset(model,
                                                      0.0,
                                                      name = "#{zone_name}_Sch_HSP_Error")
  cmd_hsp_error = OpenStudio::Model::EnergyManagementSystemActuator.new(sch_hsp_error,
                                                                        'Schedule:Year',
                                                                        'Schedule Value')
  cmd_hsp_error.setName("#{zone_name}_CMD_HSP_ERROR")

  # Averaged radiant slab controlled temperature. Averaged over the last 24 hours.
  sch_avg_ctrl_temp = model_add_constant_schedule_ruleset(model,
                                                          20.0,
                                                          name = "#{zone_name}_Sch_Avg_Ctrl_Temp")
  cmd_ctrl_temp_running_mean = OpenStudio::Model::EnergyManagementSystemActuator.new(sch_avg_ctrl_temp,
                                                                                     'Schedule:Year',
                                                                                     'Schedule Value')
  cmd_ctrl_temp_running_mean.setName("#{zone_name}_CMD_CTRL_TEMP_RUNNING_MEAN")

  # Averaged outdoor air temperature. Averaged over the last 24 hours.
  sch_oat_running_mean = model.getScheduleConstantByName('SCH_OAT_RUNNING_MEAN')
  if sch_oat_running_mean.is_initialized
    sch_oat_running_mean = sch_oat_running_mean.get
  else
    sch_oat_running_mean = model_add_constant_schedule_ruleset(model,
                                                               20.0,
                                                               name = 'SCH_OAT_RUNNING_MEAN')
  end

  cmd_oat_running_mean = model.getEnergyManagementSystemActuatorByName('CMD_OAT_RUNNING_MEAN')
  if cmd_oat_running_mean.is_initialized
    cmd_oat_running_mean = cmd_oat_running_mean.get
  else
    cmd_oat_running_mean = OpenStudio::Model::EnergyManagementSystemActuator.new(sch_oat_running_mean,
                                                                                 'Schedule:Year',
                                                                                 'Schedule Value')
    cmd_oat_running_mean.setName('CMD_OAT_RUNNING_MEAN')
  end

  #####
  # List of global variables used in EMS scripts
  ####

  # Start of occupied time of zone. Valid from 1-24.
  occ_hr_start = model.getEnergyManagementSystemGlobalVariableByName('occ_hr_start')
  if occ_hr_start.is_initialized
    occ_hr_start = occ_hr_start.get
  else
    occ_hr_start = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, 'occ_hr_start')
  end

  # End of occupied time of zone. Valid from 1-24.
  occ_hr_end = model.getEnergyManagementSystemGlobalVariableByName('occ_hr_end')
  if occ_hr_end.is_initialized
    occ_hr_end = occ_hr_end.get
  else
    occ_hr_end = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, 'occ_hr_end')
  end

  # Proportional  gain constant (recommended 0.3 or less).
  prp_k = model.getEnergyManagementSystemGlobalVariableByName('prp_k')
  if prp_k.is_initialized
    prp_k = prp_k.get
  else
    prp_k = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, 'prp_k')
  end

  # mean outdoor dry-bulb air temperature
  mean_oat = model.getEnergyManagementSystemGlobalVariableByName('mean_oat')
  if mean_oat.is_initialized
    mean_oat = mean_oat.get
  else
    mean_oat = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, 'mean_oat')
  end

  # Is the day a weekend? 1=Weekend and 0=Not Weekend.
  weekend = model.getEnergyManagementSystemGlobalVariableByName('weekend')
  if weekend.is_initialized
    weekend = weekend.get
  else
    weekend = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, 'weekend')
  end

  # Is the building in unoccupied model? 1=Unoccupied and 0=Not Unoccupied.
  unoccupied = model.getEnergyManagementSystemGlobalVariableByName('unoccupied')
  if unoccupied.is_initialized
    unoccupied = unoccupied.get
  else
    unoccupied = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, 'unoccupied')
  end

  # Minimum number of hours of operation for radiant system before it shuts off.
  min_oper = model.getEnergyManagementSystemGlobalVariableByName('min_oper')
  if min_oper.is_initialized
    min_oper = min_oper.get
  else
    min_oper = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, 'min_oper')
  end

  # Weekend temperature reset for slab temperature setpoint in degree Celsius.
  wkend_temp_reset = model.getEnergyManagementSystemGlobalVariableByName('wkend_temp_reset')
  if wkend_temp_reset.is_initialized
    wkend_temp_reset = wkend_temp_reset.get
  else
    wkend_temp_reset = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, 'wkend_temp_reset')
  end

  # Time at which the weekend temperature reset is removed.
  early_reset_out = model.getEnergyManagementSystemGlobalVariableByName('early_reset_out')
  if early_reset_out.is_initialized
    early_reset_out = early_reset_out.get
  else
    early_reset_out = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, 'early_reset_out')
  end

  # Upper slab temperature setpoint limit
  upper_slab_sp_lim = model.getEnergyManagementSystemGlobalVariableByName('upper_slab_sp_lim')
  if upper_slab_sp_lim.is_initialized
    upper_slab_sp_lim = upper_slab_sp_lim.get
  else
    upper_slab_sp_lim = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, 'upper_slab_sp_lim')
  end

  # Lower slab temperature setpoint limit
  lower_slab_sp_lim = model.getEnergyManagementSystemGlobalVariableByName('lower_slab_sp_lim')
  if lower_slab_sp_lim.is_initialized
    lower_slab_sp_lim = lower_slab_sp_lim.get
  else
    lower_slab_sp_lim = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, 'lower_slab_sp_lim')
  end

  # Temperature offset used to modify.
  ctrl_temp_offset = model.getEnergyManagementSystemGlobalVariableByName('ctrl_temp_offset')
  if ctrl_temp_offset.is_initialized
    ctrl_temp_offset = ctrl_temp_offset.get
  else
    ctrl_temp_offset = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, 'ctrl_temp_offset')
  end

  # zone specific variables

  # Maximum 'measured' temperature in zone during occupied times. Default setup uses mean air temperature.
  # Other possible choices are operative and mean radiant temperature.
  zone_max_ctrl_temp = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, "#{zone_name}_max_ctrl_temp")

  # Minimum 'measured' temperature in zone during occupied times. Default setup uses mean air temperature.
  # Other possible choices are operative and mean radiant temperature.
  zone_min_ctrl_temp = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, "#{zone_name}_min_ctrl_temp")

  # mean temperature of control surface
  zone_mean_ctrl = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, "#{zone_name}_mean_ctrl")

  # Continuous operation where there is no active hydronic heating or cooling in thermal zone in hours.
  zone_cont_neutral_oper = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, "#{zone_name}_cont_neutral_oper")

  # Zone mode of thermal zone. -1=Heating, 1=Cooling, and 0=Neutral.
  zone_zone_mode = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, "#{zone_name}_zone_mode")

  # Amount of hours that building needs to be in neutral mode in order to switch over from heating to cooling or from cooling to heating.
  zone_switch_over_time = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, "#{zone_name}_switch_over_time")

  # Continuous operation when radiant system is active in hours.
  zone_cont_rad_oper = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, "#{zone_name}_cont_rad_oper")

  # Total time the radiant system was in cooling mode in the last 24 hours.
  # Calculated at one timestep before the end of occupied time.
  zone_daily_cool_sum = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, "#{zone_name}_daily_cool_sum")

  # Total time the radiant system was in heating mode in the last 24 hours.
  # Calculated at one timestep before the end of occupied time.
  zone_daily_heat_sum = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, "#{zone_name}_daily_heat_sum")

  # Total time the radiant system was in cooling mode for the previous day.
  zone_daily_cool_sum_one = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, "#{zone_name}_daily_cool_sum_one")

  # Total time the radiant system was in heating mode for the previous day.
  zone_daily_heat_sum_one = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, "#{zone_name}_daily_heat_sum_one")

  #####
  # List of 'sensors' used in the EMS programs
  ####

  # Outdoor air temperature.
  oat = model.getEnergyManagementSystemSensorByName('OAT')
  if oat.is_initialized
    oat = oat.get
  else
    oat = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Site Outdoor Air Drybulb Temperature')
    oat.setName('OAT')
    oat.setKeyName('Environment')
  end

  # Number of timesteps to average control temperature. (Currently unused)
  # avg_window_n = model.getEnergyManagementSystemSensorByName('avg_window_n')
  # if avg_window_n.is_initialized
  #   avg_window_n = avg_window_n.get
  # else
  #   avg_window_n = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Schedule Value')
  #   avg_window_n.setName('avg_window_n')
  #   avg_window_n.setKeyName('Sch_Slab_Ctrl_Avg_Window_N')
  # end

  # Controlled zone temperature for the zone.
  zone_ctrl_temperature = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Zone Air Temperature')
  zone_ctrl_temperature.setName("#{zone_name}_Ctrl_Temperature")
  zone_ctrl_temperature.setKeyName(zone.name.get)

  # Active surface slab temperature. # Use largest surface in zone.
  surface_type = radiant_type == 'floor' ? 'Floor' : 'RoofCeiling'
  surfaces = []
  zone.spaces.each do |space|
    space.surfaces.each do |surface|
      surfaces << surface if surface.surfaceType == surface_type
    end
  end
  if surfaces.empty?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Zone #{zone.name} does not have floor surfaces; cannot add radiant system.")
    return false
  end
  zone_floor = surfaces.max_by(&:grossArea)
  zone_srf_temp = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Surface Inside Face Temperature')
  zone_srf_temp.setName("#{zone_name}_Srf_Temp")
  zone_srf_temp.setKeyName(zone_floor.name.get)

  # check for zone thermostats
  zone_thermostat = zone.thermostatSetpointDualSetpoint
  unless zone_thermostat.is_initialized
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Zone #{zone.name} does not have thermostats.")
    return false
  end
  zone_thermostat = zone.thermostatSetpointDualSetpoint.get
  zone_clg_thermostat = zone_thermostat.coolingSetpointTemperatureSchedule.get
  zone_htg_thermostat = zone_thermostat.heatingSetpointTemperatureSchedule.get

  # Upper comfort limit for the zone. Taken from existing thermostat schedules in the zone.
  zone_upper_comfort_limit = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Schedule Value')
  zone_upper_comfort_limit.setName("#{zone_name}_Upper_Comfort_Limit")
  zone_upper_comfort_limit.setKeyName(zone_clg_thermostat.name.get)

  # Lower comfort limit for the zone. Taken from existing thermostat schedules in the zone.
  zone_lower_comfort_limit = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Schedule Value')
  zone_lower_comfort_limit.setName("#{zone_name}_Lower_Comfort_Limit")
  zone_lower_comfort_limit.setKeyName(zone_htg_thermostat.name.get)

  # Radiant system water flow rate used to determine if there is active hydronic cooling in the radiant system.
  zone_rad_cool_operation = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'System Node Mass Flow Rate')
  zone_rad_cool_operation.setName("#{zone_name}_Rad_Cool_Operation")
  zone_rad_cool_operation.setKeyName(coil_cooling_radiant.to_StraightComponent.get.inletModelObject.get.name.get)

  # Radiant system water flow rate used to determine if there is active hydronic heating in the radiant system.
  zone_rad_heat_operation = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'System Node Mass Flow Rate')
  zone_rad_heat_operation.setName("#{zone_name}_Rad_Heat_Operation")
  zone_rad_heat_operation.setKeyName(coil_heating_radiant.to_StraightComponent.get.inletModelObject.get.name.get)

  # Last 24 hours trend for the outdoor air temperature.
  oat_trend = model.getEnergyManagementSystemTrendVariableByName('OAT_Trend')
  if oat_trend.is_initialized
    oat_trend = oat_trend.get
  else
    oat_trend = OpenStudio::Model::EnergyManagementSystemTrendVariable.new(model, oat)
    oat_trend.setName('OAT_Trend')
    oat_trend.setNumberOfTimestepsToBeLogged(zone_timestep * 24)
  end

  # Last 24 hours trend for active slab surface temperature.
  zone_srf_temp_trend = OpenStudio::Model::EnergyManagementSystemTrendVariable.new(model, zone_srf_temp)
  zone_srf_temp_trend.setName("#{zone_name}_Srf_Temp_Trend")
  zone_srf_temp_trend.setNumberOfTimestepsToBeLogged(zone_timestep * 24)

  # Last 24 hours trend for radiant system in cooling mode.
  zone_rad_cool_operation_trend = OpenStudio::Model::EnergyManagementSystemTrendVariable.new(model, zone_rad_cool_operation)
  zone_rad_cool_operation_trend.setName("#{zone_name}_Rad_Cool_Operation_Trend")
  zone_rad_cool_operation_trend.setNumberOfTimestepsToBeLogged(zone_timestep * 24)

  # Last 24 hours trend for radiant system in heating mode.
  zone_rad_heat_operation_trend = OpenStudio::Model::EnergyManagementSystemTrendVariable.new(model, zone_rad_heat_operation)
  zone_rad_heat_operation_trend.setName("#{zone_name}_Rad_Heat_Operation_Trend")
  zone_rad_heat_operation_trend.setNumberOfTimestepsToBeLogged(zone_timestep * 24)

  #####
  # List of EMS programs to implement the proportional control for the radiant system.
  ####

  # Initialize global constant values used in EMS programs.
  set_constant_values_prg = model.getEnergyManagementSystemTrendVariableByName('Set_Constant_Values')
  unless set_constant_values_prg.is_initialized
    set_constant_values_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
    set_constant_values_prg.setName('Set_Constant_Values')
    set_constant_values_prg_body = <<-EMS
      SET occ_hr_start       = #{model_occ_hr_start},
      SET occ_hr_end         = #{model_occ_hr_end},
      SET prp_k              = #{proportional_gain},
      SET min_oper           = #{minimum_operation},
      SET ctrl_temp_offset   = 0.5,
      SET wkend_temp_reset   = #{weekend_temperature_reset},
      SET early_reset_out    = #{early_reset_out_arg},
      SET upper_slab_sp_lim  = 29,
      SET lower_slab_sp_lim  = 19
    EMS
    set_constant_values_prg.setBody(set_constant_values_prg_body)
  end

  # Determine if it is a weekend or not a weekend schedule for the building.
  determine_weekend_prg = model.getEnergyManagementSystemTrendVariableByName('Determine_Weekend')
  unless determine_weekend_prg.is_initialized
    determine_weekend_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
    determine_weekend_prg.setName('Determine_Weekend')
    determine_weekend_prg_body = <<-EMS
      IF (DayOfWeek == 1) || (DayOfWeek == 7),
          SET weekend = 1,
      ELSEIF (DayOfWeek == 2) && (CurrentTime < occ_hr_start),
          SET weekend = 1,
      ELSEIF (DayOfWeek == 6) && (CurrentTime > occ_hr_end),
          SET weekend = 1,
      ELSE,
          SET weekend = 0,
      ENDIF
    EMS
    determine_weekend_prg.setBody(determine_weekend_prg_body)
  end

  # Determine if building is in unoccupied mode or not in unoccupied mode.
  determine_unoccupied_prg = model.getEnergyManagementSystemTrendVariableByName('Determine_Unoccupied')
  unless determine_unoccupied_prg.is_initialized
    determine_unoccupied_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
    determine_unoccupied_prg.setName('Determine_Unoccupied')
    determine_unoccupied_prg_body = <<-EMS
      IF (DayOfWeek == 1) || (DayOfWeek == 7),
          SET unoccupied = 0,
      ELSEIF (CurrentTime > occ_hr_end) || (CurrentTime < occ_hr_start),
          IF (DayOfWeek == 2) && (CurrentTime < occ_hr_start),
              SET unoccupied = 0,
          ELSEIF (DayOfWeek == 6) && (CurrentTime > occ_hr_end),
              SET unoccupied = 0,
          ELSE,
              SET unoccupied = 1,
          ENDIF,
      ELSE,
          SET unoccupied = 0,
      ENDIF
    EMS
    determine_unoccupied_prg.setBody(determine_unoccupied_prg_body)
  end

  # Initialize zone specific constant values used in EMS programs.
  set_constant_zone_values_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  set_constant_zone_values_prg.setName("#{zone_name}_Set_Constant_Values")
  set_constant_zone_values_prg_body = <<-EMS
    SET #{zone_name}_max_ctrl_temp      = #{zone_name}_Lower_Comfort_Limit,
    SET #{zone_name}_min_ctrl_temp      = #{zone_name}_Upper_Comfort_Limit,
    SET #{zone_name}_cont_neutral_oper  = 0,
    SET #{zone_name}_zone_mode          = 0,
    SET #{zone_name}_switch_over_time   = #{switch_over_time},
    SET #{zone_name}_CMD_CSP_ERROR      = 0,
    SET #{zone_name}_CMD_HSP_ERROR      = 0,
    SET #{zone_name}_CMD_SLAB_SP        = #{zone_name}_Lower_Comfort_Limit,
    SET #{zone_name}_cont_rad_oper      = 0,
    SET #{zone_name}_daily_cool_sum     = 0,
    SET #{zone_name}_daily_heat_sum     = 0,
    SET #{zone_name}_daily_cool_sum_one = 0,
    SET #{zone_name}_daily_heat_sum_one = 0
  EMS
  set_constant_zone_values_prg.setBody(set_constant_zone_values_prg_body)

  # Calculate temperature averages.
  calculate_trends_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  calculate_trends_prg.setName("#{zone_name}_Calculate_Trends")
  calculate_trends_prg_body = <<-EMS
    SET mean_oat                                = @TrendAverage OAT_Trend 24/ZoneTimeStep,
    SET #{zone_name}_mean_ctrl                  = @TrendAverage #{zone_name}_Srf_Temp_Trend 24/ZoneTimeStep,
    SET CMD_OAT_RUNNING_MEAN                    = mean_oat + 0,
    SET #{zone_name}_CMD_CTRL_TEMP_RUNNING_MEAN = #{zone_name}_mean_ctrl + 0
  EMS
  calculate_trends_prg.setBody(calculate_trends_prg_body)

  # Calculate maximum and minimum 'measured' controlled temperature in the zone
  calculate_minmax_ctrl_temp_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  calculate_minmax_ctrl_temp_prg.setName("#{zone_name}_Calculate_Extremes_In_Zone")
  calculate_minmax_ctrl_temp_prg_body = <<-EMS
    IF ((CurrentTime >= occ_hr_start) && (CurrentTime <= occ_hr_end)),
        IF #{zone_name}_Ctrl_Temperature > #{zone_name}_max_ctrl_temp,
            SET #{zone_name}_max_ctrl_temp = #{zone_name}_Ctrl_Temperature,
        ENDIF,
        IF #{zone_name}_Ctrl_Temperature < #{zone_name}_min_ctrl_temp,
            SET #{zone_name}_min_ctrl_temp = #{zone_name}_Ctrl_Temperature,
        ENDIF,
    ELSE,
      SET #{zone_name}_max_ctrl_temp = #{zone_name}_Lower_Comfort_Limit,
      SET #{zone_name}_min_ctrl_temp = #{zone_name}_Upper_Comfort_Limit,
    ENDIF
  EMS
  calculate_minmax_ctrl_temp_prg.setBody(calculate_minmax_ctrl_temp_prg_body)

  # Calculate errors from comfort zone limits and 'measured' controlled temperature in the zone.
  calculate_errors_from_comfort_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  calculate_errors_from_comfort_prg.setName("#{zone_name}_Calculate_Errors_From_Comfort")
  calculate_errors_from_comfort_prg_body = <<-EMS
    IF (CurrentTime >= (occ_hr_end - ZoneTimeStep)) && (CurrentTime <= (occ_hr_end)),
        SET #{zone_name}_CMD_CSP_ERROR = (#{zone_name}_Upper_Comfort_Limit - ctrl_temp_offset) - #{zone_name}_max_ctrl_temp,
        SET #{zone_name}_CMD_HSP_ERROR = (#{zone_name}_Lower_Comfort_Limit + ctrl_temp_offset) - #{zone_name}_min_ctrl_temp,
    ENDIF
  EMS
  calculate_errors_from_comfort_prg.setBody(calculate_errors_from_comfort_prg_body)

  # Calculate time when there is no active hydronic heating or cooling.
  calculate_neutral_time_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  calculate_neutral_time_prg.setName("#{zone_name}_Calculate_Neutral_Time")
  calculate_neutral_time_prg_body = <<-EMS
    IF (#{zone_name}_Rad_Cool_Operation > 0) || (#{zone_name}_Rad_Heat_Operation > 0),
        SET #{zone_name}_cont_neutral_oper = 0,
    ELSE,
        SET #{zone_name}_cont_neutral_oper = #{zone_name}_cont_neutral_oper + ZoneTimeStep,
    ENDIF
  EMS
  calculate_neutral_time_prg.setBody(calculate_neutral_time_prg_body)

  # Calculate time when there is active hydronic heating or cooling in thermal zone.
  calculate_continuous_radiant_operation_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  calculate_continuous_radiant_operation_prg.setName("#{zone_name}_Calculate_Continuous_Radiant_Operation")
  calculate_continuous_radiant_operation_prg_body = <<-EMS
    IF (#{zone_name}_Rad_Cool_Operation > 0) || (#{zone_name}_Rad_Heat_Operation > 0),
        SET #{zone_name}_cont_rad_oper = #{zone_name}_cont_rad_oper + ZoneTimeStep,
    ELSE,
        SET #{zone_name}_cont_rad_oper = 0,
    ENDIF
  EMS
  calculate_continuous_radiant_operation_prg.setBody(calculate_continuous_radiant_operation_prg_body)

  # Determine if the zone is in cooling, heating, or neutral mode.
  determine_zone_mode_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  determine_zone_mode_prg.setName("#{zone_name}_Determine_Zone_Mode")
  determine_zone_mode_prg_body = <<-EMS
    SET #{zone_name}_cont_cool_oper = @TrendSum #{zone_name}_Rad_Cool_Operation_Trend 24/ZoneTimeStep,
    SET #{zone_name}_cont_heat_oper = @TrendSum #{zone_name}_Rad_Heat_Operation_Trend 24/ZoneTimeStep,
    IF (#{zone_name}_zone_mode <> 0) && (#{zone_name}_cont_neutral_oper > #{zone_name}_switch_over_time),
        SET #{zone_name}_zone_mode = 0,
    ELSEIF (#{zone_name}_cont_cool_oper > 0) && (#{zone_name}_zone_mode == 0),
        SET #{zone_name}_zone_mode = 1,
    ELSEIF (#{zone_name}_cont_heat_oper > 0) && (#{zone_name}_zone_mode == 0),
        SET #{zone_name}_zone_mode = -1,
    ELSE,
        SET #{zone_name}_zone_mode = #{zone_name}_zone_mode,
    ENDIF
  EMS
  determine_zone_mode_prg.setBody(determine_zone_mode_prg_body)

  # Calculate the cumulative time for active hydronic cooling and heating.
  calculate_cumulative_sum_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  calculate_cumulative_sum_prg.setName("#{zone_name}_Calculate_Cumulative_Sum")
  calculate_cumulative_sum_prg_body = <<-EMS
    IF (CurrentTime == (occ_hr_end - ZoneTimeStep)),
        SET #{zone_name}_daily_cool_sum_one = #{zone_name}_daily_cool_sum,
        SET #{zone_name}_daily_heat_sum_one = #{zone_name}_daily_heat_sum,
        SET #{zone_name}_daily_cool_sum = @TrendSum #{zone_name}_Rad_Cool_Operation_Trend 24/ZoneTimeStep,
        SET #{zone_name}_daily_heat_sum = @TrendSum #{zone_name}_Rad_Heat_Operation_Trend 24/ZoneTimeStep,
    ENDIF
  EMS
  calculate_cumulative_sum_prg.setBody(calculate_cumulative_sum_prg_body)

  # Calculate the new active slab temperature setpoint for heating and cooling
  calculate_slab_ctrl_setpoint_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  calculate_slab_ctrl_setpoint_prg.setName("#{zone_name}_Calculate_Slab_Ctrl_Setpoint")
  calculate_slab_ctrl_setpoint_prg_body = <<-EMS
    IF (#{zone_name}_zone_mode >= 0),
      SET #{zone_name}_cont_cool_oper = @TrendSum #{zone_name}_Rad_Cool_Operation_Trend 24/ZoneTimeStep,
      IF (#{zone_name}_cont_cool_oper > 0) && (CurrentTime == occ_hr_end),
        SET #{zone_name}_CMD_SLAB_SP = #{zone_name}_CMD_SLAB_SP + (#{zone_name}_CMD_CSP_ERROR*prp_k),
      ENDIF,
    ELSEIF (#{zone_name}_zone_mode <= 0),
      SET #{zone_name}_cont_heat_oper = @TrendSum #{zone_name}_Rad_Heat_Operation_Trend 24/ZoneTimeStep,
      IF (#{zone_name}_cont_heat_oper > 0) && (CurrentTime == occ_hr_end),
        SET #{zone_name}_CMD_SLAB_SP = #{zone_name}_CMD_SLAB_SP + (#{zone_name}_CMD_HSP_ERROR*prp_k),
      ENDIF,
    ENDIF,
    IF (#{zone_name}_CMD_SLAB_SP < lower_slab_sp_lim),
      SET #{zone_name}_CMD_SLAB_SP = lower_slab_sp_lim,
    ELSEIF (#{zone_name}_CMD_SLAB_SP > upper_slab_sp_lim),
      SET #{zone_name}_CMD_SLAB_SP = upper_slab_sp_lim,
    ENDIF,
  EMS
  calculate_slab_ctrl_setpoint_prg.setBody(calculate_slab_ctrl_setpoint_prg_body)

  # Apply a weekend setback at the start of a weekend and remove the reset at the defined time.
  implement_setback_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  implement_setback_prg.setName("#{zone_name}_Implement_setback")
  implement_setback_prg_body = <<-EMS
    IF early_reset_out > occ_hr_start,
        SET turn_on_day = 1,
        SET turn_on_hour = 24 - (early_reset_out - occ_hr_start),
    ELSE,
        SET turn_on_day = 2,
        SET turn_on_hour = occ_hr_start - early_reset_out,
    ENDIF,
    IF (CurrentTime == occ_hr_end) && (DayOfWeek == 6),
        SET #{zone_name}_CMD_SLAB_SP = #{zone_name}_CMD_SLAB_SP,
    ELSEIF (CurrentTime == turn_on_hour) && (DayOfWeek == turn_on_day),
        SET #{zone_name}_CMD_SLAB_SP = #{zone_name}_CMD_SLAB_SP,
    ENDIF
  EMS
  implement_setback_prg.setBody(implement_setback_prg_body)

  # Get design day size
  num_design_days = model.getDesignDays.size
  OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "EMS code for radiant system operation depends on the number of design days being fixed. The model has #{num_design_days}.  Do not change design days now that the model has EMS code dependent on them. ")

  # Turn radiant system ON/OFF for cooling or heating based on calculated setpoints and building mode.
  determine_radiant_operation_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  determine_radiant_operation_prg.setName("#{zone_name}_Determine_Radiant_Operation")
  determine_radiant_operation_prg_body = <<-EMS
    IF (CurrentEnvironment) <= #{num_design_days} ! Operation during design days
        SET #{zone_name}_CMD_COLD_WATER_CTRL = 0,
        SET #{zone_name}_CMD_HOT_WATER_CTRL = -60,
    ELSE,                ! Operation during annual simulation
        IF (#{zone_name}_zone_mode >= 0) && (#{zone_name}_Srf_Temp > #{zone_name}_CMD_SLAB_SP),
            SET #{zone_name}_CMD_COLD_WATER_CTRL = 0,
            SET #{zone_name}_CMD_HOT_WATER_CTRL = -60,
        ELSEIF (#{zone_name}_zone_mode >= 0) && (#{zone_name}_Srf_Temp < #{zone_name}_CMD_SLAB_SP) && (min_oper > #{zone_name}_cont_rad_oper) && (#{zone_name}_cont_rad_oper <> 0),
            SET #{zone_name}_CMD_COLD_WATER_CTRL = 0,
            SET #{zone_name}_CMD_HOT_WATER_CTRL = -60,
        ELSEIF (#{zone_name}_zone_mode <= 0) && (#{zone_name}_Srf_Temp < #{zone_name}_CMD_SLAB_SP),
            SET #{zone_name}_CMD_COLD_WATER_CTRL = 100,
            SET #{zone_name}_CMD_HOT_WATER_CTRL = 60,
        ELSEIF (#{zone_name}_zone_mode <= 0) && (#{zone_name}_Srf_Temp > #{zone_name}_CMD_SLAB_SP) && (min_oper > #{zone_name}_cont_rad_oper) && (#{zone_name}_cont_rad_oper <> 0),
            SET #{zone_name}_CMD_COLD_WATER_CTRL = 100,
            SET #{zone_name}_CMD_HOT_WATER_CTRL = 60,
        ELSE,
            SET #{zone_name}_CMD_COLD_WATER_CTRL = 60,
            SET #{zone_name}_CMD_HOT_WATER_CTRL = -60,
        ENDIF,
    ENDIF
  EMS
  determine_radiant_operation_prg.setBody(determine_radiant_operation_prg_body)

  #####
  # List of EMS program manager objects
  ####
  initialize_constant_parameters = model.getEnergyManagementSystemProgramCallingManagerByName('Set_Constant_Values')
  if initialize_constant_parameters.is_initialized
    initialize_constant_parameters = initialize_constant_parameters.get
  else
    initialize_constant_parameters = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)
    initialize_constant_parameters.setName('Initialize_Constant_Parameters')
    initialize_constant_parameters.setCallingPoint('BeginNewEnvironment')
    initialize_constant_parameters.addProgram(set_constant_values_prg)
  end

  initialize_constant_parameters_after_warmup = model.getEnergyManagementSystemProgramCallingManagerByName('Set_Constant_Values')
  if initialize_constant_parameters_after_warmup.is_initialized
    initialize_constant_parameters_after_warmup = initialize_constant_parameters_after_warmup.get
  else
    initialize_constant_parameters_after_warmup = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)
    initialize_constant_parameters_after_warmup.setName('Initialize_Constant_Parameters_After_Warmup')
    initialize_constant_parameters_after_warmup.setCallingPoint('BeginNewEnvironment')
    initialize_constant_parameters_after_warmup.addProgram(set_constant_values_prg)
  end

  zone_initialize_constant_parameters = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)
  zone_initialize_constant_parameters.setName("#{zone_name}_Initialize_Constant_Parameters")
  zone_initialize_constant_parameters.setCallingPoint('BeginNewEnvironment')
  zone_initialize_constant_parameters.addProgram(set_constant_zone_values_prg)

  zone_initialize_constant_parameters_after_warmup = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)
  zone_initialize_constant_parameters_after_warmup.setName("#{zone_name}_Initialize_Constant_Parameters_After_Warmup")
  zone_initialize_constant_parameters_after_warmup.setCallingPoint('BeginNewEnvironment')
  zone_initialize_constant_parameters_after_warmup.addProgram(set_constant_zone_values_prg)

  average_building_temperature = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)
  average_building_temperature.setName("#{zone_name}_Average_Building_Temperature")
  average_building_temperature.setCallingPoint('EndOfZoneTimestepAfterZoneReporting')
  average_building_temperature.addProgram(calculate_minmax_ctrl_temp_prg)
  average_building_temperature.addProgram(calculate_errors_from_comfort_prg)
  average_building_temperature.addProgram(calculate_neutral_time_prg)
  average_building_temperature.addProgram(determine_zone_mode_prg)
  average_building_temperature.addProgram(calculate_trends_prg)
  average_building_temperature.addProgram(calculate_continuous_radiant_operation_prg)
  average_building_temperature.addProgram(calculate_cumulative_sum_prg)

  programs_at_beginning_of_timestep = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)
  programs_at_beginning_of_timestep.setName("#{zone_name}_Programs_At_Beginning_Of_Timestep")
  programs_at_beginning_of_timestep.setCallingPoint('BeginTimestepBeforePredictor')
  programs_at_beginning_of_timestep.addProgram(determine_weekend_prg)
  programs_at_beginning_of_timestep.addProgram(determine_unoccupied_prg)
  programs_at_beginning_of_timestep.addProgram(determine_zone_mode_prg)
  programs_at_beginning_of_timestep.addProgram(implement_setback_prg)
  programs_at_beginning_of_timestep.addProgram(calculate_slab_ctrl_setpoint_prg)
  programs_at_beginning_of_timestep.addProgram(determine_radiant_operation_prg)

  #####
  # List of variables for output.
  ####
  zone_max_ctrl_temp_output = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model, zone_max_ctrl_temp)
  zone_max_ctrl_temp_output.setName("#{zone_name} Maximum occupied temperature in zone")
  zone_min_ctrl_temp_output = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model, zone_min_ctrl_temp)
  zone_min_ctrl_temp_output.setName("#{zone_name} Minimum occupied temperature in zone")
  zone_zone_mode_output = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model, zone_zone_mode)
  zone_zone_mode_output.setName("#{zone_name} Zone Mode of Operation")
  zone_cont_neutral_oper_output = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model, zone_cont_neutral_oper)
  zone_cont_neutral_oper_output.setName("#{zone_name} Number of Hours in Neutral Operation")
  zone_cont_rad_oper_output = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model, zone_cont_rad_oper)
  zone_cont_rad_oper_output.setName("#{zone_name} Number of Hours in Continuous Operation")
  zone_daily_cool_sum_output = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model, zone_daily_cool_sum)
  zone_daily_cool_sum_output.setName("#{zone_name} Daily Building Cool Operation")
  zone_daily_heat_sum_output = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model, zone_daily_heat_sum)
  zone_daily_heat_sum_output.setName("#{zone_name} Daily Building Heat Operation")
  zone_daily_cool_sum_one_output = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model, zone_daily_cool_sum_one)
  zone_daily_cool_sum_one_output.setName("#{zone_name} Daily Building Cool Operation One")
  zone_daily_heat_sum_one_output = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model, zone_daily_heat_sum_one)
  zone_daily_heat_sum_one_output.setName("#{zone_name} Daily Building Heat Operation One")
end

#model_add_refrigeration_case(model, thermal_zone, case_type, size_category) ⇒ Object

Adds a refrigerated case to the model.

case is located, and which will be impacted by the case’s thermal load. This parameter is used also by the “Refrigeration System Lineup” tab. refer to the “”Refrigerated Cases“ tab on the OpenStudio_Standards spreadsheet. are: ”<35k ft2“, ”35k - 50k ft2“, ”>50k ft2“

Parameters:

  • thermal_zone (OpenStudio::Model::ThermalZone)

    the thermal zone where the

  • case_type (String)

    the case type/name. For valid choices

  • size_category (String)

    size category of the building area. Valid choices



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.refrigeration.rb', line 13

def model_add_refrigeration_case(model, thermal_zone, case_type, size_category)
  # Get the case properties
  #

  search_criteria = {
    'template' => template,
    'case_type' => case_type,
    'size_category' => size_category
  }

  props = model_find_object(standards_data['refrigerated_cases'], search_criteria)
  if props.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Could not find refrigerated case properties for: #{search_criteria}.")
    return nil
  end

  # Capacity, defrost, anti-sweat
  case_length = OpenStudio.convert(props['case_length'], 'ft', 'm').get
  case_temp = OpenStudio.convert(props['case_temp'], 'F', 'C').get
  cooling_capacity_per_length = OpenStudio.convert(props['cooling_capacity_per_length'], 'Btu/hr*ft', 'W/m').get
  evap_fan_power_per_length = OpenStudio.convert(props['evap_fan_power_per_length'], 'W/ft', 'W/m').get
  if props['evap_temp']
    evap_temp_c = OpenStudio.convert(props['evap_temp'], 'F', 'C').get
  end
  lighting_w_per_m = OpenStudio.convert(props['lighting_per_ft'], 'W/ft', 'W/m').get
  if props['lighting_schedule']
    case_lighting_schedule = model_add_schedule(model, props['lighting_schedule'])
  else
    case_lighting_schedule = model.alwaysOnDiscreteSchedule
  end
  fraction_of_lighting_energy_to_case = props['fraction_of_lighting_energy_to_case']
  if props['latent_case_credit_curve_name']
    latent_case_credit_curve = model_add_curve(model, props['latent_case_credit_curve_name'])
  end
  defrost_power_per_length = OpenStudio.convert(props['defrost_power_per_length'], 'W/ft', 'W/m').get
  defrost_type = props['defrost_type']
  if props['defrost_correction_type']
    defrost_correction_type = props['defrost_correction_type']
  end
  if props['defrost_correction_curve_name']
    defrost_correction_curve_name = model_add_curve(model, props['defrost_correction_curve_name'])
  end
  if props['anti_sweat_power']
    anti_sweat_power = OpenStudio.convert(props['anti_sweat_power'], 'W/ft', 'W/m').get
  end
  if props['minimum_anti_sweat_heater_power_per_unit_length']
    minimum_anti_sweat_heater_power_per_unit_length = OpenStudio.convert(props['minimum_anti_sweat_heater_power_per_unit_length'], 'W/ft', 'W/m').get
  end
  if props['anti_sweat_heater_control']
    if props['anti_sweat_heater_control'] == 'RelativeHumidity'
      anti_sweat_heater_control = 'Linear'
    else
      anti_sweat_heater_control = props['anti_sweat_heater_control']
    end
  end
  if props['fractionofantisweatheaterenergytocase']
    fractionofantisweatheaterenergytocase = props['fractionofantisweatheaterenergytocase']
  end

  # Case
  ref_case = OpenStudio::Model::RefrigerationCase.new(model, model.alwaysOnDiscreteSchedule)
  ref_case.setName(case_type)
  ref_case.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  ref_case.setThermalZone(thermal_zone)
  ref_case.setRatedAmbientTemperature(OpenStudio.convert(75, 'F', 'C').get)
  ref_case.setRatedLatentHeatRatio(props['latent_heat_ratio']) if props['latent_heat_ratio']
  ref_case.setRatedRuntimeFraction(props['rated_runtime_fraction']) if props['rated_runtime_fraction']
  ref_case.setCaseLength(case_length)
  ref_case.setCaseOperatingTemperature(case_temp)
  ref_case.setRatedTotalCoolingCapacityperUnitLength(cooling_capacity_per_length)
  cooling_capacity_w = ref_case.caseLength * ref_case.ratedTotalCoolingCapacityperUnitLength
  cooling_capacity_btu_per_hr = OpenStudio.convert(cooling_capacity_w, 'W', 'Btu/hr').get
  ref_case.setStandardCaseFanPowerperUnitLength(evap_fan_power_per_length)
  ref_case.setOperatingCaseFanPowerperUnitLength(evap_fan_power_per_length)
  if props['evap_temp']
    ref_case.setDesignEvaporatorTemperatureorBrineInletTemperature(evap_temp_c)
  end
  ref_case.setStandardCaseLightingPowerperUnitLength(lighting_w_per_m)
  ref_case.setInstalledCaseLightingPowerperUnitLength(lighting_w_per_m)
  ref_case.setCaseLightingSchedule(case_lighting_schedule)

  if props['latent_case_credit_curve_name']
    ref_case.setLatentCaseCreditCurve(latent_case_credit_curve)
  end
  ref_case.setCaseDefrostPowerperUnitLength(defrost_power_per_length)
  if props['defrost_type']
    ref_case.setCaseDefrostType(defrost_type)
  end
  ref_case.setDefrostEnergyCorrectionCurveType(defrost_correction_type)
  if props['defrost_correction_curve_name']
    ref_case.setDefrostEnergyCorrectionCurve(defrost_correction_curve_name)
  end
  if props['anti_sweat_power']
    ref_case.setCaseAntiSweatHeaterPowerperUnitLength(anti_sweat_power)
  end
  ref_case.setFractionofAntiSweatHeaterEnergytoCase(fractionofantisweatheaterenergytocase)
  ref_case.setFractionofLightingEnergytoCase(fraction_of_lighting_energy_to_case)
  if props['minimum_anti_sweat_heater_power_per_unit_length']
    ref_case.setMinimumAntiSweatHeaterPowerperUnitLength(minimum_anti_sweat_heater_power_per_unit_length)
  end
  if props['anti_sweat_heater_control']
    ref_case.setAntiSweatHeaterControlType(anti_sweat_heater_control)
  end
  ref_case.setHumidityatZeroAntiSweatHeaterEnergy(0)
  if props['under_case_hvac_return_air_fraction']
    ref_case.setUnderCaseHVACReturnAirFraction(props['under_case_hvac_return_air_fraction'])
  else
    ref_case.setUnderCaseHVACReturnAirFraction(0)
  end
  if props['restocking_schedule']
    if props['restocking_schedule'].downcase == 'always off'
      # restocking_sch = model.alwaysOffDiscreteSchedule
      ref_case.resetRefrigeratedCaseRestockingSchedule
    else
      restocking_sch = model_add_schedule(model, props['restocking_schedule'])
      ref_case.setRefrigeratedCaseRestockingSchedule(restocking_sch)
    end
  else
    ref_case.resetRefrigeratedCaseRestockingSchedule
  end

  if props['case_category']
    ref_case_addprops = ref_case.additionalProperties
    ref_case_addprops.setFeature('case_category', props['case_category'])
  end

  length_ft = OpenStudio.convert(case_length, 'm', 'ft').get
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Added #{length_ft.round} ft display case called #{case_type} with a cooling capacity of #{cooling_capacity_btu_per_hr.round} Btu/hr to #{thermal_zone.name}.")

  return ref_case
end

#model_add_refrigeration_compressor(model, compressor_name) ⇒ Object

Adds a refrigeration compressor to the model.



347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.refrigeration.rb', line 347

def model_add_refrigeration_compressor(model, compressor_name)
  # Get the compressor properties
  search_criteria = {
    'template' => template,
    'compressor_name' => compressor_name
  }

  props = model_find_object(standards_data['refrigeration_compressors'], search_criteria)
  if props.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Could not find refrigeration compressor properties for: #{search_criteria}.")
    return nil
  end

  # Performance curves
  pwr_curve_name = props['power_curve']
  cap_curve_name = props['capacity_curve']

  # Make the compressor
  compressor = OpenStudio::Model::RefrigerationCompressor.new(model)
  compressor.setRefrigerationCompressorPowerCurve(model_add_curve(model, pwr_curve_name))
  compressor.setRefrigerationCompressorCapacityCurve(model_add_curve(model, cap_curve_name))

  return compressor
end

#model_add_refrigeration_system(model, compressor_type, system_name, cases, walkins, thermal_zone) ⇒ Object

TODO:

Move refrigeration compressors to spreadsheet

Adds a full commercial refrigeration rack, as would be found in a supermarket, to the model.

Low Temp, Med Temp case_type and space_names. walkin_type, space_names, and number_of_walkins refrigeration piping is located.

Parameters:

  • compressor_type (String)

    the system temperature range. valid choices are:

  • system_name (String)

    the name of the refrigeration system

  • cases (Array<Hash>)

    an array of cases with keys:

  • walkins (Array<Hashs>)

    an array of walkins with keys:

  • thermal_zone (OpenStudio::Model::ThermalZone)

    the thermal zone where the



844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.refrigeration.rb', line 844

def model_add_refrigeration_system(model,
                                   compressor_type,
                                   system_name,
                                   cases,
                                   walkins,
                                   thermal_zone)

  # Refrigeration system
  ref_sys = OpenStudio::Model::RefrigerationSystem.new(model)
  ref_sys.setName(system_name.to_s)
  ref_sys.setSuctionPipingZone(thermal_zone)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model',
                     "Adding #{compressor_type} refrigeration system called #{system_name} with #{cases.size} cases and #{walkins.size} walkins.")

  # Compressors (20 for each system)
  for i in 0...20
    compressor = model_add_refrigeration_compressor(model, compressor_type)
    ref_sys.addCompressor(compressor)
  end

  size_category = 'Any'
  # Cases
  cooling_cap = 0
  i = 0
  cases.each do |case_|
    zone = model_get_zones_from_spaces_on_system(model, case_)[0]
    ref_case = model_add_refrigeration_case(model, zone, case_['case_type'], size_category)
    return false if ref_case.nil?

    ########################################
    # Defrost schedule
    defrost_sch = OpenStudio::Model::ScheduleRuleset.new(model)
    defrost_sch.setName('Refrigeration Defrost Schedule')
    defrost_sch.defaultDaySchedule.setName('Refrigeration Defrost Schedule Default')
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, i, 0, 0), 0)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, i, 59, 0), 0)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
    # Dripdown schedule
    dripdown_sch = OpenStudio::Model::ScheduleRuleset.new(model)
    dripdown_sch.setName('Refrigeration Defrost Schedule')
    dripdown_sch.defaultDaySchedule.setName('Refrigeration Defrost Schedule Default')
    dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, i, 0, 0), 0)
    dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, i, 59, 0), 0)
    dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
    # Case Credit Schedule
    case_credit_sch = OpenStudio::Model::ScheduleRuleset.new(model)
    case_credit_sch.setName('Refrigeration Case Credit Schedule')
    case_credit_sch.defaultDaySchedule.setName('Refrigeration Case Credit Schedule Default')
    case_credit_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 7, 0, 0), 0.2)
    case_credit_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 21, 0, 0), 0.4)
    case_credit_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0.2)
    ref_case.setCaseDefrostSchedule(defrost_sch)
    ref_case.setCaseDefrostDripDownSchedule(dripdown_sch)
    ref_case.setCaseCreditFractionSchedule(case_credit_sch)
    ########################################
    ref_sys.addCase(ref_case)
    i += 1
  end

  # Walkins
  walkins.each do |walkin|
    for i in 0...walkin['number_of_walkins']

      zone = model_get_zones_from_spaces_on_system(model, walkin)[0]
      ref_walkin = model_add_refrigeration_walkin(model, zone, size_category, walkin['walkin_type'])
      return false if ref_walkin.nil?

      ########################################
      # Defrost schedule
      defrost_sch = OpenStudio::Model::ScheduleRuleset.new(model)
      defrost_sch.setName('Refrigeration Defrost Schedule')
      defrost_sch.defaultDaySchedule.setName('Refrigeration Defrost Schedule Default')
      defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, i, 0, 0), 0)
      defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, i, 59, 0), 1)
      defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, i + 10, 0, 0), 0)
      defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, i + 10, 59, 0), 1)
      defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
      # Dripdown schedule
      dripdown_sch = OpenStudio::Model::ScheduleRuleset.new(model)
      dripdown_sch.setName('Refrigeration Defrost Schedule')
      dripdown_sch.defaultDaySchedule.setName('Refrigeration Defrost Schedule Default')
      dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, i, 0, 0), 0)
      dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, i, 59, 0), 1)
      dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, i + 10, 0, 0), 0)
      dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, i + 10, 59, 0), 1)
      dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
      ref_walkin.setDefrostSchedule(defrost_sch)
      ref_walkin.setDefrostDripDownSchedule(dripdown_sch)
      ref_sys.addWalkin(ref_walkin)
      ########################################
      cooling_cap += ref_walkin.ratedCoilCoolingCapacity # calculate total cooling capacity of the cases + walkins
    end
  end

  # Condenser capacity
  # The heat rejection rate from the condenser is equal to the rated capacity of all the display cases and walk-ins connected to the compressor rack
  # plus the power rating of the compressors making up the compressor rack.
  # Assuming a COP of 1.3 for low-temperature compressor racks and a COP of 2.0 for medium-temperature compressor racks,
  # the required condenser capacity is approximated as follows:
  # Note the factor 1.2 has been included to over-estimate the condenser size.  The total capacity of the display cases can be calculated
  # from their rated cooling capacity times the length of the cases.  The capacity of each of the walk-ins is specified directly.
  condensor_cap = if compressor_type == 'Low Temp'
                    1.2 * cooling_cap * (1 + 1 / 1.3)
                  else
                    1.2 * cooling_cap * (1 + 1 / 2.0)
                  end
  condenser_coefficient_2 = condensor_cap / 5.6
  condenser_curve = OpenStudio::Model::CurveLinear.new(model)
  condenser_curve.setCoefficient1Constant(0)
  condenser_curve.setCoefficient2x(condenser_coefficient_2)
  condenser_curve.setMinimumValueofx(1.4)
  condenser_curve.setMaximumValueofx(33.3)

  # Condenser fan power
  # The condenser fan power can be estimated from the heat rejection capacity of the condenser as follows:
  condenser_fan_pwr = 0.0441 * condensor_cap + 695

  # Condenser
  condenser = OpenStudio::Model::RefrigerationCondenserAirCooled.new(model)
  condenser.setRatedFanPower(condenser_fan_pwr)
  condenser.setRatedEffectiveTotalHeatRejectionRateCurve(condenser_curve)
  condenser.setCondenserFanSpeedControlType('Fixed')
  condenser.setMinimumFanAirFlowRatio(0.1)

  ref_sys.setRefrigerationCondenser(condenser)

  return true
end

#model_add_refrigeration_walkin(model, thermal_zone, size_category, walkin_type) ⇒ Object

walkin is located, and which will be impacted by the walkin’s thermal load. are: “<35k ft2”, “35k - 50k ft2”, “>50k ft2” refer to the “Refrigerated Walkins” tab on the OpenStudio_Standards spreadsheet. This parameter is used also by the “Refrigeration System Lineup” tab.

Parameters:

  • thermal_zone (OpenStudio::Model::ThermalZone)

    the thermal zone where the

  • size_category (String)

    size category of the building area. Valid choices

  • walkin_type (String)

    the walkin type/name. For valid choices



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.refrigeration.rb', line 152

def model_add_refrigeration_walkin(model, thermal_zone, size_category, walkin_type)
  # Get the walkin properties
  search_criteria = {
    'template' => template,
    'size_category' => size_category,
    'walkin_type' => walkin_type
  }

  props = model_find_object(standards_data['refrigeration_walkins'], search_criteria)
  if props.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Could not find walkin properties for: #{search_criteria}.")
    return nil
  end

  # Capacity, defrost, lighting
  walkin_type = props['walkin_type']
  if props['rated_cooling_capacity']
    rated_cooling_capacity = OpenStudio.convert(props['rated_cooling_capacity'], 'Btu/h', 'W').get
  end
  if props['cooling_capacity_c0']
    cooling_capacity_c0 = OpenStudio.convert(OpenStudio.convert(props['cooling_capacity_c0'], 'Btu/h', 'W').get, 'W/ft', 'W/m').get
  end
  if props['cooling_capacity_c1']
    cooling_capacity_c1 = OpenStudio.convert(OpenStudio.convert(props['cooling_capacity_c1'], 'Btu/h', 'W').get, 'W/ft', 'W/m').get
  end
  if props['cooling_capacity_c2']
    cooling_capacity_c2 = OpenStudio.convert(OpenStudio.convert(props['cooling_capacity_c2'], 'Btu/h', 'W').get, 'W/ft', 'W/m').get
  end
  if props['fan_power_mult']
    fan_power_mult = props['fan_power_mult']
  end
  if props['lighting_power_mult']
    lighting_power_mult = props['lighting_power_mult']
  end
  if props['reachin_door_area_mult']
    reachin_door_area_mult = OpenStudio.convert(props['reachin_door_area_mult'], 'ft^2', 'm^2').get
  end
  operating_temp = OpenStudio.convert(props['operating_temp'], 'F', 'C').get
  if props['source_temp']
    source_temp = OpenStudio.convert(props['source_temp'], 'F', 'C').get
  end
  if props['defrost_control_type']
    defrost_control_type = props['defrost_control_type']
  end
  defrost_type = props['defrost_type']
  defrost_power_mult = props['defrost_power_mult']
  defrost_power = props['defrost_power']
  ratedtotalheatingpower = props['ratedtotalheatingpower']
  ratedcirculationfanpower = props['ratedcirculationfanpower']
  fan_power = props['fan_power']
  lighting_power = props['lighting_power']
  # lighting_power_mult = props_ref_system['lighting_power_mult']
  if props['insulated_floor_u']
    insulated_floor_u = OpenStudio.convert(props['insulated_floor_u'], 'Btu/ft^2*h*R', 'W/m^2*K').get
  end
  if props['insulated_surface_u']
    insulated_surface_u = OpenStudio.convert(props['insulated_surface_u'], 'Btu/ft^2*h*R', 'W/m^2*K').get
  end
  if props['stocking_door_u']
    insulated_door_u = OpenStudio.convert(props['stocking_door_u'], 'Btu/ft^2*h*R', 'W/m^2*K').get
  end
  if props['glass_reachin_door_u_value']
    glass_reachin_door_u_value = OpenStudio.convert(props['glass_reachin_door_u_value'], 'Btu/ft^2*h*R', 'W/m^2*K').get
  end
  if props['reachin_door_area']
    reachin_door_area = OpenStudio.convert(props['reachin_door_area'], 'ft^2', 'm^2').get
  end
  if props['total_insulated_surface_area']
    total_insulated_surface_area = OpenStudio.convert(props['total_insulated_surface_area'], 'ft^2', 'm^2').get
  end
  if props['height_of_glass_reachin_doors']
    height_of_glass_reachin_doors = OpenStudio.convert(props['height_of_glass_reachin_doors'], 'ft', 'm').get
  end
  if props['area_of_stocking_doors']
    area_of_stocking_doors = OpenStudio.convert(props['area_of_stocking_doors'], 'ft^2', 'm^2').get
  end
  if props['floor_surface_area']
    floor_surface_area = OpenStudio.convert(props['floor_surface_area'], 'ft^2', 'm^2').get
  end
  if props['height_of_stocking_doors']
    height_of_stocking_doors = OpenStudio.convert(props['height_of_stocking_doors'], 'ft', 'm').get
  end
  lightingschedule = props['lighting_schedule']
  temperatureterminationdefrostfractiontoice = props['temperatureterminationdefrostfractiontoice']

  # Calculated properties
  if rated_cooling_capacity.nil?
    rated_cooling_capacity = cooling_capacity_c2 * (floor_surface_area ^ 2) + cooling_capacity_c1 * floor_surface_area + cooling_capacity_c0
  end
  if defrost_power.nil?
    defrost_power = defrost_power_mult * rated_cooling_capacity
  end
  if total_insulated_surface_area.nil?
    total_insulated_surface_area = 1.7226 * floor_surface_area + 28.653
  end
  if reachin_door_area.nil?
    reachin_door_area = reachin_door_area_mult * floor_surface_area
  end
  if fan_power.nil?
    fan_power = fan_power_mult * rated_cooling_capacity
  end
  if lighting_power.nil?
    lighting_power = lighting_power_mult * floor_surface_area
  end

  # Walk-In
  ref_walkin = OpenStudio::Model::RefrigerationWalkIn.new(model, model.alwaysOnDiscreteSchedule)
  ref_walkin.setName(walkin_type.to_s)
  ref_walkin.setZoneBoundaryThermalZone(thermal_zone)
  ref_walkin.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  ref_walkin.setRatedCoilCoolingCapacity(rated_cooling_capacity)
  rated_cooling_capacity_btu_per_hr = OpenStudio.convert(rated_cooling_capacity, 'W', 'Btu/hr').get
  ref_walkin.setOperatingTemperature(operating_temp)
  if props['source_temp']
    ref_walkin.setRatedCoolingSourceTemperature(source_temp)
  end
  if props['defrost_control_type']
    ref_walkin.setDefrostControlType(defrost_control_type)
  end
  ref_walkin.setDefrostType(defrost_type)
  ref_walkin.setDefrostPower(defrost_power)
  if props['ratedtotalheatingpower']
    ref_walkin.setRatedTotalHeatingPower(ratedtotalheatingpower)
  end
  if props['ratedcirculationfanpower']
    ref_walkin.setRatedCirculationFanPower(ratedcirculationfanpower)
  end
  ref_walkin.setRatedCoolingCoilFanPower(fan_power)
  ref_walkin.setRatedTotalLightingPower(lighting_power)
  if props['insulated_floor_u']
    ref_walkin.setInsulatedFloorUValue(insulated_floor_u)
  end
  if props['insulated_surface_u']
    ref_walkin.setZoneBoundaryInsulatedSurfaceUValueFacingZone(insulated_surface_u)
  end
  if props['stocking_door_u']
    ref_walkin.setZoneBoundaryStockingDoorUValueFacingZone(insulated_door_u)
  end
  if props['reachin_door_area']
    ref_walkin.setZoneBoundaryAreaofGlassReachInDoorsFacingZone(reachin_door_area)
  end
  if props['total_insulated_surface_area']
    ref_walkin.setZoneBoundaryTotalInsulatedSurfaceAreaFacingZone(total_insulated_surface_area)
  end
  if props['area_of_stocking_doors']
    ref_walkin.setZoneBoundaryAreaofStockingDoorsFacingZone(area_of_stocking_doors)
  end
  if props['floor_surface_area']
    ref_walkin.setInsulatedFloorSurfaceArea(floor_surface_area)
  end
  if props['height_of_glass_reachin_doors']
    ref_walkin.setZoneBoundaryHeightofGlassReachInDoorsFacingZone(height_of_glass_reachin_doors)
  end
  if props['height_of_stocking_doors']
    ref_walkin.setZoneBoundaryHeightofStockingDoorsFacingZone(height_of_stocking_doors)
  end
  if props['glass_reachin_door_u_value']
    ref_walkin.setZoneBoundaryGlassReachInDoorUValueFacingZone(glass_reachin_door_u_value)
  end
  if props['temperatureterminationdefrostfractiontoice']
    ref_walkin.setTemperatureTerminationDefrostFractiontoIce(temperatureterminationdefrostfractiontoice)
  end

  if props['restocking_schedule']
    if props['restocking_schedule'].downcase == 'always off'
      # restocking_sch = model.alwaysOffDiscreteSchedule
      ref_walkin.resetRestockingSchedule
    else
      restocking_sch = model_add_schedule(model, props['restocking_schedule'])
      ref_walkin.setRestockingSchedule(restocking_sch)
    end
  else
    ref_walkin.resetRestockingSchedule
  end

  ref_walkin.setLightingSchedule(model_add_schedule(model, lightingschedule))
  ref_walkin.setZoneBoundaryStockingDoorOpeningScheduleFacingZone(model_add_schedule(model, 'door_wi_sched'))

  ref_walkin_addprops = ref_walkin.additionalProperties
  ref_walkin_addprops.setFeature('motor_category', props['motor_category'])

  # Add doorway protection
  if props['doorway_protection_type']
    ref_walkin.zoneBoundaries.each do |zb|
      zb.setStockingDoorOpeningProtectionTypeFacingZone(props['doorway_protection_type'])
    end
  end

  insulated_floor_area_ft2 = OpenStudio.convert(floor_surface_area, 'm^2', 'ft^2').get
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Added #{insulated_floor_area_ft2.round} ft2 walkin called #{walkin_type} with a capacity of #{rated_cooling_capacity_btu_per_hr.round} Btu/hr to #{thermal_zone.name}.")

  return ref_walkin
end

#model_add_schedule(model, schedule_name) ⇒ ScheduleRuleset

TODO:

make return an OptionalScheduleRuleset

Create a schedule from the openstudio standards dataset and add it to the model.

Parameters:

  • schedule_name (String)

    name of the schedule

Returns:

  • (ScheduleRuleset)

    the resulting schedule ruleset



2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2067

def model_add_schedule(model, schedule_name)
  return nil if schedule_name.nil? || schedule_name == ''

  # First check model and return schedule if it already exists
  model.getSchedules.sort.each do |schedule|
    if schedule.name.get.to_s == schedule_name
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "Already added schedule: #{schedule_name}")
      return schedule
    end
  end

  require 'date'

  # OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', "Adding schedule: #{schedule_name}")

  # Find all the schedule rules that match the name
  rules = model_find_objects(standards_data['schedules'], 'name' => schedule_name)
  if rules.size.zero?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Cannot find data for schedule: #{schedule_name}, will not be created.")
    return model.alwaysOnDiscreteSchedule
  end

  # Make a schedule ruleset
  sch_ruleset = OpenStudio::Model::ScheduleRuleset.new(model)
  sch_ruleset.setName(schedule_name.to_s)

  # Loop through the rules, making one for each row in the spreadsheet
  rules.each do |rule|
    day_types = rule['day_types']
    start_date = DateTime.parse(rule['start_date'])
    end_date = DateTime.parse(rule['end_date'])
    sch_type = rule['type']
    values = rule['values']

    # Day Type choices: Wkdy, Wknd, Mon, Tue, Wed, Thu, Fri, Sat, Sun, WntrDsn, SmrDsn, Hol
    # Default
    if day_types.include?('Default')
      day_sch = sch_ruleset.defaultDaySchedule
      day_sch.setName("#{schedule_name} Default")
      model_add_vals_to_sch(model, day_sch, sch_type, values)
    end

    # Winter Design Day
    if day_types.include?('WntrDsn')
      day_sch = OpenStudio::Model::ScheduleDay.new(model)
      sch_ruleset.setWinterDesignDaySchedule(day_sch)
      day_sch = sch_ruleset.winterDesignDaySchedule
      day_sch.setName("#{schedule_name} Winter Design Day")
      model_add_vals_to_sch(model, day_sch, sch_type, values)
    end

    # Summer Design Day
    if day_types.include?('SmrDsn')
      day_sch = OpenStudio::Model::ScheduleDay.new(model)
      sch_ruleset.setSummerDesignDaySchedule(day_sch)
      day_sch = sch_ruleset.summerDesignDaySchedule
      day_sch.setName("#{schedule_name} Summer Design Day")
      model_add_vals_to_sch(model, day_sch, sch_type, values)
    end

    # Other days (weekdays, weekends, etc)
    if day_types.include?('Wknd') ||
       day_types.include?('Wkdy') ||
       day_types.include?('Sat') ||
       day_types.include?('Sun') ||
       day_types.include?('Mon') ||
       day_types.include?('Tue') ||
       day_types.include?('Wed') ||
       day_types.include?('Thu') ||
       day_types.include?('Fri')

      # Make the Rule
      sch_rule = OpenStudio::Model::ScheduleRule.new(sch_ruleset)
      day_sch = sch_rule.daySchedule
      day_sch.setName("#{schedule_name} #{day_types} Day")
      model_add_vals_to_sch(model, day_sch, sch_type, values)

      # Set the dates when the rule applies
      sch_rule.setStartDate(OpenStudio::Date.new(OpenStudio::MonthOfYear.new(start_date.month.to_i), start_date.day.to_i))
      sch_rule.setEndDate(OpenStudio::Date.new(OpenStudio::MonthOfYear.new(end_date.month.to_i), end_date.day.to_i))

      # Set the days when the rule applies
      # Weekends
      if day_types.include?('Wknd')
        sch_rule.setApplySaturday(true)
        sch_rule.setApplySunday(true)
      end
      # Weekdays
      if day_types.include?('Wkdy')
        sch_rule.setApplyMonday(true)
        sch_rule.setApplyTuesday(true)
        sch_rule.setApplyWednesday(true)
        sch_rule.setApplyThursday(true)
        sch_rule.setApplyFriday(true)
      end
      # Individual Days
      sch_rule.setApplyMonday(true) if day_types.include?('Mon')
      sch_rule.setApplyTuesday(true) if day_types.include?('Tue')
      sch_rule.setApplyWednesday(true) if day_types.include?('Wed')
      sch_rule.setApplyThursday(true) if day_types.include?('Thu')
      sch_rule.setApplyFriday(true) if day_types.include?('Fri')
      sch_rule.setApplySaturday(true) if day_types.include?('Sat')
      sch_rule.setApplySunday(true) if day_types.include?('Sun')
    end
  end # Next rule
  return sch_ruleset
end

#model_add_schedule_type_limits(model, standard_sch_type_limit: nil, name: nil, lower_limit_value: nil, upper_limit_value: nil, numeric_type: nil, unit_type: nil) ⇒ <OpenStudio::Model::ScheduleTypeLimits>

Create ScheduleTypeLimits

Parameters:

  • standard_sch_type_limit (string) (defaults to: nil)

    the name of a standard schedule type limit with predefined limits options are Temperature, Humidity Ratio, Fractional, OnOff, and Activity

  • name (string) (defaults to: nil)

    the name of the schedule type limits

  • lower_limit_value (double) (defaults to: nil)

    the lower limit value for the schedule type

  • upper_limit_value (double) (defaults to: nil)

    the upper limit value for the schedule type

  • numeric_type (string) (defaults to: nil)

    the numeric type, options are Continuous or Discrete

  • unit_type (string) (defaults to: nil)

    the unit type, options are defined in EnergyPlus I/O reference

Returns:

  • (<OpenStudio::Model::ScheduleTypeLimits>)


1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1983

def model_add_schedule_type_limits(model,
                                   standard_sch_type_limit: nil,
                                   name: nil,
                                   lower_limit_value: nil,
                                   upper_limit_value: nil,
                                   numeric_type: nil,
                                   unit_type: nil)

  if standard_sch_type_limit.nil?
    if lower_limit_value.nil? || upper_limit_value.nil? || numeric_type.nil? || unit_type.nil?
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', 'If calling model_add_schedule_type_limits without a standard_sch_type_limit, you must specify all properties of ScheduleTypeLimits.')
      return false
    end
    schedule_type_limits = OpenStudio::Model::ScheduleTypeLimits.new(model)
    schedule_type_limits.setName(name) if !name.nil?
    schedule_type_limits.setLowerLimitValue(lower_limit_value)
    schedule_type_limits.setUpperLimitValue(upper_limit_value)
    schedule_type_limits.setNumericType(numeric_type)
    schedule_type_limits.setUnitType(unit_type)
  else
    schedule_type_limits = model.getScheduleTypeLimitsByName(standard_sch_type_limit)
    if !schedule_type_limits.empty?
      schedule_type_limits = schedule_type_limits.get
      if schedule_type_limits.name.to_s.downcase == 'temperature'
        schedule_type_limits.resetLowerLimitValue
        schedule_type_limits.resetUpperLimitValue
        schedule_type_limits.setNumericType('Continuous')
        schedule_type_limits.setUnitType('Temperature')
      end
    else
      case standard_sch_type_limit.downcase
        when 'temperature'
          schedule_type_limits = OpenStudio::Model::ScheduleTypeLimits.new(model)
          schedule_type_limits.setName('Temperature')
          schedule_type_limits.setLowerLimitValue(0.0)
          schedule_type_limits.setUpperLimitValue(100.0)
          schedule_type_limits.setNumericType('Continuous')
          schedule_type_limits.setUnitType('Temperature')

        when 'humidity ratio'
          schedule_type_limits = OpenStudio::Model::ScheduleTypeLimits.new(model)
          schedule_type_limits.setName('Humidity Ratio')
          schedule_type_limits.setLowerLimitValue(0.0)
          schedule_type_limits.setUpperLimitValue(0.3)
          schedule_type_limits.setNumericType('Continuous')
          schedule_type_limits.setUnitType('Dimensionless')

        when 'fraction', 'fractional'
          schedule_type_limits = OpenStudio::Model::ScheduleTypeLimits.new(model)
          schedule_type_limits.setName('Fraction')
          schedule_type_limits.setLowerLimitValue(0.0)
          schedule_type_limits.setUpperLimitValue(1.0)
          schedule_type_limits.setNumericType('Continuous')
          schedule_type_limits.setUnitType('Dimensionless')

        when 'onoff'
          schedule_type_limits = OpenStudio::Model::ScheduleTypeLimits.new(model)
          schedule_type_limits.setName('OnOff')
          schedule_type_limits.setLowerLimitValue(0)
          schedule_type_limits.setUpperLimitValue(1)
          schedule_type_limits.setNumericType('Discrete')
          schedule_type_limits.setUnitType('Availability')

        when 'activity'
          schedule_type_limits = OpenStudio::Model::ScheduleTypeLimits.new(model)
          schedule_type_limits.setName('Activity')
          schedule_type_limits.setLowerLimitValue(70.0)
          schedule_type_limits.setUpperLimitValue(1000.0)
          schedule_type_limits.setNumericType('Continuous')
          schedule_type_limits.setUnitType('ActivityLevel')
        else
          OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', 'Invalid standard_sch_type_limit for method model_add_schedule_type_limits.')
      end
    end
  end
  return schedule_type_limits
end

#model_add_split_ac(model, thermal_zones, cooling_type: 'Two Speed DX AC', heating_type: 'Single Speed Heat Pump', supplemental_heating_type: 'Gas', fan_type: 'Cycling', hvac_op_sch: nil, oa_damper_sch: nil, econ_max_oa_frac_sch: nil) ⇒ OpenStudio::Model::AirLoopHVAC

Creates a split DX AC system for each zone and adds it to the model.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • cooling_type (String) (defaults to: 'Two Speed DX AC')

    valid choices are Two Speed DX AC, Single Speed DX AC, Single Speed Heat Pump

  • heating_type (String) (defaults to: 'Single Speed Heat Pump')

    valid choices are Gas, Single Speed Heat Pump

  • supplemental_heating_type (String) (defaults to: 'Gas')

    valid choices are Electric, Gas

  • fan_type (String) (defaults to: 'Cycling')

    valid choices are ConstantVolume, Cycling

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule or nil in which case will be defaulted to always on

  • oa_damper_sch (String) (defaults to: nil)

    name of the oa damper schedule, or nil in which case will be defaulted to always open

  • econ_max_oa_frac_sch (String) (defaults to: nil)

    name of the economizer maximum outdoor air fraction schedule

Returns:



3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 3403

def model_add_split_ac(model,
                       thermal_zones,
                       cooling_type: 'Two Speed DX AC',
                       heating_type: 'Single Speed Heat Pump',
                       supplemental_heating_type: 'Gas',
                       fan_type: 'Cycling',
                       hvac_op_sch: nil,
                       oa_damper_sch: nil,
                       econ_max_oa_frac_sch: nil)

  # create a split AC for each group of thermal zones
  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  thermal_zones_name = thermal_zones.map(&:name).join(' - ')
  air_loop.setName("#{thermal_zones_name} SAC")

  # hvac operation schedule
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # oa damper schedule
  if oa_damper_sch.nil?
    oa_damper_sch = model.alwaysOnDiscreteSchedule
  else
    oa_damper_sch = model_add_schedule(model, oa_damper_sch)
  end

  # default design temperatures used across all air loops
  dsgn_temps = standard_design_sizing_temperatures

  # adjusted zone design heating temperature for split_ac
  dsgn_temps['zn_htg_dsgn_sup_air_temp_f'] = 122.0
  dsgn_temps['zn_htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_htg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['htg_dsgn_sup_air_temp_f'] = dsgn_temps['zn_htg_dsgn_sup_air_temp_f']
  dsgn_temps['htg_dsgn_sup_air_temp_c'] = dsgn_temps['zn_htg_dsgn_sup_air_temp_c']

  # default design settings used across all air loops
  sizing_system = adjust_sizing_system(air_loop, dsgn_temps, min_sys_airflow_ratio: 1.0, sizing_option: 'NonCoincident')

  # air handler controls
  # add a setpoint manager single zone reheat to control the supply air temperature
  setpoint_mgr_single_zone_reheat = OpenStudio::Model::SetpointManagerSingleZoneReheat.new(model)
  setpoint_mgr_single_zone_reheat.setName("#{air_loop.name} Setpoint Manager SZ Reheat")
  setpoint_mgr_single_zone_reheat.setControlZone(thermal_zones[0])
  setpoint_mgr_single_zone_reheat.setMinimumSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
  setpoint_mgr_single_zone_reheat.setMaximumSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
  setpoint_mgr_single_zone_reheat.addToNode(air_loop.supplyOutletNode)

  # add the components to the air loop in order from closest to zone to furthest from zone
  # create fan
  fan = nil
  if fan_type == 'ConstantVolume'
    fan = create_fan_by_name(model,
                             'Split_AC_CAV_Fan',
                             fan_name: "#{air_loop.name} Fan",
                             end_use_subcategory: 'CAV System Fans')
    fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  elsif fan_type == 'Cycling'
    fan = create_fan_by_name(model,
                             'Split_AC_Cycling_Fan',
                             fan_name: "#{air_loop.name} Fan",
                             end_use_subcategory: 'CAV System Fans')
    fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "fan_type #{fan_type} invalid for split AC system.")
  end
  fan.addToNode(air_loop.supplyInletNode) unless fan.nil?

  # create supplemental heating coil
  if supplemental_heating_type == 'Electric'
    create_coil_heating_electric(model,
                                 air_loop_node: air_loop.supplyInletNode,
                                 name: "#{air_loop.name} Electric Backup Htg Coil")
  elsif supplemental_heating_type == 'Gas'
    create_coil_heating_gas(model,
                            air_loop_node: air_loop.supplyInletNode,
                            name: "#{air_loop.name} Gas Backup Htg Coil")
  end

  # create heating coil
  if heating_type == 'Gas'
    htg_coil = create_coil_heating_gas(model,
                                       air_loop_node: air_loop.supplyInletNode,
                                       name: "#{air_loop.name} Gas Htg Coil")
    htg_part_load_fraction_correlation = OpenStudio::Model::CurveCubic.new(model)
    htg_part_load_fraction_correlation.setCoefficient1Constant(0.8)
    htg_part_load_fraction_correlation.setCoefficient2x(0.2)
    htg_part_load_fraction_correlation.setCoefficient3xPOW2(0.0)
    htg_part_load_fraction_correlation.setCoefficient4xPOW3(0.0)
    htg_part_load_fraction_correlation.setMinimumValueofx(0.0)
    htg_part_load_fraction_correlation.setMaximumValueofx(1.0)
    htg_coil.setPartLoadFractionCorrelationCurve(htg_part_load_fraction_correlation)
  elsif heating_type == 'Single Speed Heat Pump'
    create_coil_heating_dx_single_speed(model,
                                        air_loop_node: air_loop.supplyInletNode,
                                        name: "#{air_loop.name} HP Htg Coil")
  end

  # create cooling coil
  if cooling_type == 'Two Speed DX AC'
    create_coil_cooling_dx_two_speed(model,
                                     air_loop_node: air_loop.supplyInletNode,
                                     name: "#{air_loop.name} 2spd DX AC Clg Coil")
  elsif cooling_type == 'Single Speed DX AC'
    create_coil_cooling_dx_single_speed(model,
                                        air_loop_node: air_loop.supplyInletNode,
                                        name: "#{air_loop.name} 1spd DX AC Clg Coil", type: 'Split AC')
  elsif cooling_type == 'Single Speed Heat Pump'
    create_coil_cooling_dx_single_speed(model,
                                        air_loop_node: air_loop.supplyInletNode,
                                        name: "#{air_loop.name} 1spd DX HP Clg Coil", type: 'Heat Pump')
  end

  # create outdoor air controller
  oa_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
  oa_controller.setName("#{air_loop.name} OA System Controller")
  oa_controller.setMinimumOutdoorAirSchedule(oa_damper_sch)
  oa_controller.autosizeMinimumOutdoorAirFlowRate
  oa_controller.resetEconomizerMinimumLimitDryBulbTemperature
  oa_controller.setMaximumFractionofOutdoorAirSchedule(model_add_schedule(model, econ_max_oa_frac_sch)) unless econ_max_oa_frac_sch.nil?
  oa_system = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_controller)
  oa_system.setName("#{air_loop.name} OA System")
  oa_system.addToNode(air_loop.supplyInletNode)

  # set air loop availability controls after oa system added
  air_loop.setAvailabilitySchedule(hvac_op_sch)

  # create a diffuser and attach the zone/diffuser pair to the air loop
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding #{zone.name} to split DX AC system.")

    diffuser = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule)
    diffuser.setName("#{zone.name} SAC Diffuser")
    air_loop.multiAddBranchForZone(zone, diffuser.to_HVACComponent.get)

    # zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneCoolingDesignSupplyAirHumidityRatio(0.008)
    sizing_zone.setZoneHeatingDesignSupplyAirHumidityRatio(0.008)
  end

  return air_loop
end

#model_add_swh(model, building_type, climate_zone, prototype_input, epw_file) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.swh.rb', line 2

def model_add_swh(model, building_type, climate_zone, prototype_input, epw_file)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started Adding Service Water Heating')

  # Add the main service water heating loop, if specified
  # for tall and super tall buildings, add main (multiple) and booster swh in model_custom_hvac_tweaks
  unless prototype_input['main_water_heater_volume'].nil? || (building_type == 'TallBuilding' || building_type == 'SuperTallBuilding')
    # Get the thermal zone for the water heater, if specified
    water_heater_zone = nil
    if prototype_input['main_water_heater_space_name']
      wh_space_name = prototype_input['main_water_heater_space_name']
      wh_space = model.getSpaceByName(wh_space_name)
      if wh_space.empty?
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "Cannot find a space called #{wh_space_name} in the model, water heater will not be placed in a zone.")
      else
        wh_zone = wh_space.get.thermalZone
        if wh_zone.empty?
          OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "Cannot find a zone that contains the space #{wh_space_name} in the model, water heater will not be placed in a zone.")
        else
          water_heater_zone = wh_zone.get
        end
      end
    end

    swh_fueltype = prototype_input['main_water_heater_fuel']
    # Add the main service water loop
    unless building_type == 'RetailStripmall' && template != 'NECB2011'
      main_swh_loop = model_add_swh_loop(model,
                                         'Main Service Water Loop',
                                         water_heater_zone,
                                         OpenStudio.convert(prototype_input['main_service_water_temperature'], 'F', 'C').get,
                                         prototype_input['main_service_water_pump_head'].to_f,
                                         prototype_input['main_service_water_pump_motor_efficiency'],
                                         OpenStudio.convert(prototype_input['main_water_heater_capacity'], 'Btu/hr', 'W').get,
                                         OpenStudio.convert(prototype_input['main_water_heater_volume'], 'gal', 'm^3').get,
                                         swh_fueltype,
                                         OpenStudio.convert(prototype_input['main_service_water_parasitic_fuel_consumption_rate'], 'Btu/hr', 'W').get)
    end

    # Attach the end uses if specified in prototype inputs
    # TODO remove special logic for large office SWH end uses
    # TODO remove special logic for stripmall SWH end uses and service water loops
    # TODO remove special logic for large hotel SWH end uses
    if building_type == 'LargeOffice' && template != 'NECB2011'

      # Only the core spaces have service water
      ['Core_bottom', 'Core_mid', 'Core_top'].sort.each do |space_name|
        # ['Mechanical_Bot_ZN_1','Mechanical_Mid_ZN_1','Mechanical_Top_ZN_1'].each do |space_name| # for new space type large office
        model_add_swh_end_uses(model,
                               'Main',
                               main_swh_loop,
                               OpenStudio.convert(prototype_input['main_service_water_peak_flowrate'], 'gal/min', 'm^3/s').get,
                               prototype_input['main_service_water_flowrate_schedule'],
                               OpenStudio.convert(prototype_input['main_water_use_temperature'], 'F', 'C').get,
                               space_name)
      end
    elsif building_type == 'LargeOfficeDetailed' && template != 'NECB2011'

      # Only mechanical rooms have service water
      ['Mechanical_Bot_ZN_1', 'Mechanical_Mid_ZN_1', 'Mechanical_Top_ZN_1'].sort.each do |space_name| # for new space type large office
        model_add_swh_end_uses(model,
                               'Main',
                               main_swh_loop,
                               OpenStudio.convert(prototype_input['main_service_water_peak_flowrate'], 'gal/min', 'm^3/s').get,
                               prototype_input['main_service_water_flowrate_schedule'],
                               OpenStudio.convert(prototype_input['main_water_use_temperature'], 'F', 'C').get,
                               space_name)
      end
    elsif building_type == 'RetailStripmall' && template != 'NECB2011'

      return true if template == 'DOE Ref Pre-1980' || template == 'DOE Ref 1980-2004'

      # Create a separate hot water loop & water heater for each space in the list
      swh_space_names = ['LGstore1', 'SMstore1', 'SMstore2', 'SMstore3', 'LGstore2', 'SMstore5', 'SMstore6']
      swh_sch_names = ['RetailStripmall Type1_SWH_SCH', 'RetailStripmall Type1_SWH_SCH', 'RetailStripmall Type2_SWH_SCH',
                       'RetailStripmall Type2_SWH_SCH', 'RetailStripmall Type3_SWH_SCH', 'RetailStripmall Type3_SWH_SCH',
                       'RetailStripmall Type3_SWH_SCH']
      rated_use_rate_gal_per_min = 0.03 # in gal/min
      rated_flow_rate_m3_per_s = OpenStudio.convert(rated_use_rate_gal_per_min, 'gal/min', 'm^3/s').get

      # Loop through all spaces
      swh_space_names.zip(swh_sch_names).sort.each do |swh_space_name, swh_sch_name|
        swh_thermal_zone = model.getSpaceByName(swh_space_name).get.thermalZone.get
        main_swh_loop = model_add_swh_loop(model,
                                           "#{swh_thermal_zone.name} Service Water Loop",
                                           swh_thermal_zone,
                                           OpenStudio.convert(prototype_input['main_service_water_temperature'], 'F', 'C').get,
                                           prototype_input['main_service_water_pump_head'].to_f,
                                           prototype_input['main_service_water_pump_motor_efficiency'],
                                           OpenStudio.convert(prototype_input['main_water_heater_capacity'], 'Btu/hr', 'W').get,
                                           OpenStudio.convert(prototype_input['main_water_heater_volume'], 'gal', 'm^3').get,
                                           prototype_input['main_water_heater_fuel'],
                                           OpenStudio.convert(prototype_input['main_service_water_parasitic_fuel_consumption_rate'], 'Btu/hr', 'W').get)

        model_add_swh_end_uses(model,
                               'Main',
                               main_swh_loop,
                               rated_flow_rate_m3_per_s,
                               swh_sch_name,
                               OpenStudio.convert(prototype_input['main_water_use_temperature'], 'F', 'C').get,
                               swh_space_name)
      end

    elsif prototype_input['main_service_water_peak_flowrate']
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.model.Model', 'Adding shw by main_service_water_peak_flowrate')

      # Attaches the end uses if specified as a lump value in the prototype_input
      model_add_swh_end_uses(model,
                             'Main',
                             main_swh_loop,
                             OpenStudio.convert(prototype_input['main_service_water_peak_flowrate'], 'gal/min', 'm^3/s').get,
                             prototype_input['main_service_water_flowrate_schedule'],
                             OpenStudio.convert(prototype_input['main_water_use_temperature'], 'F', 'C').get,
                             nil)

    else
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.model.Model', 'Adding shw by space_type_map')

      # Attaches the end uses if specified by space type
      space_type_map = @space_type_map

      if template == 'NECB2011'
        building_type = 'Space Function'
      end

      # Log how many water fixtures are added
      water_fixtures = []

      # Loop through spaces types and add service hot water if specified
      space_type_map.sort.each do |space_type_name, space_names|
        search_criteria = {
          'template' => template,
          'building_type' => model_get_lookup_name(building_type),
          'space_type' => space_type_name
        }
        data = standards_lookup_table_first(table_name: 'space_types', search_criteria: search_criteria)

        # Skip space types with no data
        next if data.nil?

        # Skip space types with no water use, unless it is a NECB archetype (these do not have peak flow rates defined)
        next unless template == 'NECB2011' || !data['service_water_heating_peak_flow_rate'].nil? || !data['service_water_heating_peak_flow_per_area'].nil?

        # Add a service water use for each space
        space_names.sort.each do |space_name|
          space = model.getSpaceByName(space_name).get
          space_multiplier = nil
          space_multiplier = case template
                               when 'NECB2011'
                                 # Added this to prevent double counting of zone multipliers.. space multipliers are never used in NECB archtypes.
                                 1
                               else
                                 space.multiplier
                             end

          water_fixture = model_add_swh_end_uses_by_space(model,
                                                          main_swh_loop,
                                                          space,
                                                          space_multiplier)
          unless water_fixture.nil?
            water_fixtures << water_fixture
          end
        end
      end

      OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Added #{water_fixtures.size} water fixtures to model")

    end

  end

  # Add the booster water heater, if specified
  # for tall and super tall buildings, add main (multiple) and booster swh in model_custom_hvac_tweaks
  unless prototype_input['booster_water_heater_volume'].nil? || (building_type == 'TallBuilding' || building_type == 'SuperTallBuilding')
    # Add the booster water loop
    swh_booster_loop = model_add_swh_booster(model,
                                             main_swh_loop,
                                             OpenStudio.convert(prototype_input['booster_water_heater_capacity'], 'Btu/hr', 'W').get,
                                             OpenStudio.convert(prototype_input['booster_water_heater_volume'], 'gal', 'm^3').get,
                                             prototype_input['booster_water_heater_fuel'],
                                             OpenStudio.convert(prototype_input['booster_water_temperature'], 'F', 'C').get,
                                             0,
                                             nil)

    # Attach the end uses
    model_add_booster_swh_end_uses(model,
                                   swh_booster_loop,
                                   OpenStudio.convert(prototype_input['booster_service_water_peak_flowrate'], 'gal/min', 'm^3/s').get,
                                   prototype_input['booster_service_water_flowrate_schedule'],
                                   OpenStudio.convert(prototype_input['booster_water_use_temperature'], 'F', 'C').get)
  end

  # Add the laundry water heater, if specified
  # for tall and super tall buildings, add laundry swh in model_custom_hvac_tweaks
  unless prototype_input['laundry_water_heater_volume'].nil? || (building_type == 'TallBuilding' || building_type == 'SuperTallBuilding')
    # Add the laundry service water heating loop
    laundry_swh_loop = model_add_swh_loop(model,
                                          'Laundry Service Water Loop',
                                          nil,
                                          OpenStudio.convert(prototype_input['laundry_service_water_temperature'], 'F', 'C').get,
                                          prototype_input['laundry_service_water_pump_head'].to_f,
                                          prototype_input['laundry_service_water_pump_motor_efficiency'],
                                          OpenStudio.convert(prototype_input['laundry_water_heater_capacity'], 'Btu/hr', 'W').get,
                                          OpenStudio.convert(prototype_input['laundry_water_heater_volume'], 'gal', 'm^3').get,
                                          prototype_input['laundry_water_heater_fuel'],
                                          OpenStudio.convert(prototype_input['laundry_service_water_parasitic_fuel_consumption_rate'], 'Btu/hr', 'W').get)

    # Attach the end uses if specified in prototype inputs
    model_add_swh_end_uses(model,
                           'Laundry',
                           laundry_swh_loop,
                           OpenStudio.convert(prototype_input['laundry_service_water_peak_flowrate'], 'gal/min', 'm^3/s').get,
                           prototype_input['laundry_service_water_flowrate_schedule'],
                           OpenStudio.convert(prototype_input['laundry_water_use_temperature'], 'F', 'C').get,
                           nil)
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Finished adding Service Water Heating')

  return true
end

#model_add_swh_booster(model, main_service_water_loop, water_heater_capacity, water_heater_volume, water_heater_fuel, booster_water_temperature, parasitic_fuel_consumption_rate, booster_water_heater_thermal_zone) ⇒ OpenStudio::Model::PlantLoop

Creates a booster water heater and attaches it to the supplied service water heating loop.

the main service water loop that this booster assists. Gas, Electric fuel consumption rate, in W zones to place water heater in. If nil, will be assumed in 70F air for heat loss. the resulting booster water loop.

Parameters:

  • main_service_water_loop (OpenStudio::Model::PlantLoop)
  • water_heater_capacity (Double)

    water heater capacity, in W

  • water_heater_volume (Double)

    water heater volume, in m^3

  • water_heater_fuel (Double)

    valid choices are

  • booster_water_temperature (Double)

    water heater temperature, in C

  • parasitic_fuel_consumption_rate (Double)

    water heater parasitic

  • booster_water_heater_thermal_zone (OpenStudio::Model::ThermalZone)

Returns:



594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.ServiceWaterHeating.rb', line 594

def model_add_swh_booster(model,
                          main_service_water_loop,
                          water_heater_capacity,
                          water_heater_volume,
                          water_heater_fuel,
                          booster_water_temperature,
                          parasitic_fuel_consumption_rate,
                          booster_water_heater_thermal_zone)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding booster water heater to #{main_service_water_loop.name}")

  # Booster water heating loop
  booster_service_water_loop = OpenStudio::Model::PlantLoop.new(model)
  booster_service_water_loop.setName('Service Water Loop')

  # Temperature schedule type limits
  temp_sch_type_limits = model_add_schedule_type_limits(model,
                                                        name: 'Temperature Schedule Type Limits',
                                                        lower_limit_value: 0.0,
                                                        upper_limit_value: 100.0,
                                                        numeric_type: 'Continuous',
                                                        unit_type: 'Temperature')

  # Service water heating loop controls
  swh_temp_c = booster_water_temperature
  swh_temp_f = OpenStudio.convert(swh_temp_c, 'C', 'F').get
  swh_delta_t_r = 9 # 9F delta-T
  swh_delta_t_k = OpenStudio.convert(swh_delta_t_r, 'R', 'K').get
  swh_temp_sch = model_add_constant_schedule_ruleset(model,
                                                     swh_temp_c,
                                                     name = "Service Water Booster Temp - #{swh_temp_f}F")
  swh_temp_sch.setScheduleTypeLimits(temp_sch_type_limits)
  swh_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, swh_temp_sch)
  swh_stpt_manager.setName('Hot water booster setpoint manager')
  swh_stpt_manager.addToNode(booster_service_water_loop.supplyOutletNode)
  sizing_plant = booster_service_water_loop.sizingPlant
  sizing_plant.setLoopType('Heating')
  sizing_plant.setDesignLoopExitTemperature(swh_temp_c)
  sizing_plant.setLoopDesignTemperatureDifference(swh_delta_t_k)

  # Booster water heating pump
  swh_pump = OpenStudio::Model::PumpVariableSpeed.new(model)
  swh_pump.setName('Booster Water Loop Pump')
  swh_pump.setRatedPumpHead(0.0) # As if there is no circulation pump
  swh_pump.setRatedPowerConsumption(0.0) # As if there is no circulation pump
  swh_pump.setMotorEfficiency(1)
  swh_pump.setPumpControlType('Continuous')
  swh_pump.setMinimumFlowRate(0.0)
  swh_pump.addToNode(booster_service_water_loop.supplyInletNode)

  # Water heater
  # TODO Standards - Change water heater methodology to follow
  # 'Model Enhancements Appendix A.'
  water_heater_capacity_btu_per_hr = OpenStudio.convert(water_heater_capacity, 'W', 'Btu/hr').get
  water_heater_capacity_kbtu_per_hr = OpenStudio.convert(water_heater_capacity_btu_per_hr, 'Btu/hr', 'kBtu/hr').get
  water_heater_vol_gal = OpenStudio.convert(water_heater_volume, 'm^3', 'gal').get

  # Water heater depends on the fuel type
  water_heater = OpenStudio::Model::WaterHeaterMixed.new(model)
  water_heater.setName("#{water_heater_vol_gal}gal #{water_heater_fuel} Booster Water Heater - #{water_heater_capacity_kbtu_per_hr.round}kBtu/hr")
  water_heater.setTankVolume(OpenStudio.convert(water_heater_vol_gal, 'gal', 'm^3').get)
  water_heater.setSetpointTemperatureSchedule(swh_temp_sch)
  water_heater.setDeadbandTemperatureDifference(2.0)
  water_heater.setEndUseSubcategory('Booster')

  if booster_water_heater_thermal_zone.nil?
    # Assume the water heater is indoors at 70F or 72F
    case template
      when '90.1-2004', '90.1-2007', '90.1-2010', '90.1-2013', '90.1-2016', '90.1-2019'
        indoor_temp = 71.6
      else
        indoor_temp = 70.0
      end
    default_water_heater_ambient_temp_sch = model_add_constant_schedule_ruleset(model,
                                                                                OpenStudio.convert(indoor_temp, 'F', 'C').get,
                                                                                name = 'Water Heater Ambient Temp Schedule - ' + indoor_temp.to_s)
    default_water_heater_ambient_temp_sch.setScheduleTypeLimits(temp_sch_type_limits)
    water_heater.setAmbientTemperatureIndicator('Schedule')
    water_heater.setAmbientTemperatureSchedule(default_water_heater_ambient_temp_sch)
    water_heater.resetAmbientTemperatureThermalZone
  else
    water_heater.setAmbientTemperatureIndicator('ThermalZone')
    water_heater.setAmbientTemperatureThermalZone(booster_water_heater_thermal_zone)
    water_heater.resetAmbientTemperatureSchedule
  end

  water_heater.setMaximumTemperatureLimit(swh_temp_c)
  water_heater.setDeadbandTemperatureDifference(OpenStudio.convert(3.6, 'R', 'K').get)
  water_heater.setHeaterControlType('Cycle')
  water_heater.setHeaterMaximumCapacity(OpenStudio.convert(water_heater_capacity_btu_per_hr, 'Btu/hr', 'W').get)
  water_heater.setOffCycleParasiticHeatFractiontoTank(0.8)
  water_heater.setIndirectWaterHeatingRecoveryTime(1.5) # 1.5hrs
  if water_heater_fuel == 'Electricity'
    water_heater.setHeaterFuelType('Electricity')
    water_heater.setHeaterThermalEfficiency(1.0)
    water_heater.setOffCycleParasiticFuelConsumptionRate(parasitic_fuel_consumption_rate)
    water_heater.setOnCycleParasiticFuelConsumptionRate(parasitic_fuel_consumption_rate)
    water_heater.setOffCycleParasiticFuelType('Electricity')
    water_heater.setOnCycleParasiticFuelType('Electricity')
    water_heater.setOffCycleLossCoefficienttoAmbientTemperature(1.053)
    water_heater.setOnCycleLossCoefficienttoAmbientTemperature(1.053)
  elsif water_heater_fuel == 'Natural Gas' || water_heater_fuel == 'NaturalGas'
    water_heater.setHeaterFuelType('Gas')
    water_heater.setHeaterThermalEfficiency(0.8)
    water_heater.setOffCycleParasiticFuelConsumptionRate(parasitic_fuel_consumption_rate)
    water_heater.setOnCycleParasiticFuelConsumptionRate(parasitic_fuel_consumption_rate)
    water_heater.setOffCycleParasiticFuelType('Gas')
    water_heater.setOnCycleParasiticFuelType('Gas')
    water_heater.setOffCycleLossCoefficienttoAmbientTemperature(6.0)
    water_heater.setOnCycleLossCoefficienttoAmbientTemperature(6.0)
  end

  booster_service_water_loop.addSupplyBranchForComponent(water_heater)

  # Service water heating loop bypass pipes
  water_heater_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  booster_service_water_loop.addSupplyBranchForComponent(water_heater_bypass_pipe)
  coil_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  booster_service_water_loop.addDemandBranchForComponent(coil_bypass_pipe)
  supply_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  supply_outlet_pipe.addToNode(booster_service_water_loop.supplyOutletNode)
  demand_inlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_inlet_pipe.addToNode(booster_service_water_loop.demandInletNode)
  demand_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_outlet_pipe.addToNode(booster_service_water_loop.demandOutletNode)

  # Heat exchanger to supply the booster water heater
  # with normal hot water from the main service water loop.
  hx = OpenStudio::Model::HeatExchangerFluidToFluid.new(model)
  hx.setName('HX for Booster Water Heating')
  hx.setHeatExchangeModelType('Ideal')
  hx.setControlType('UncontrolledOn')
  hx.setHeatTransferMeteringEndUseType('LoopToLoop')

  # Add the HX to the supply side of the booster loop
  hx.addToNode(booster_service_water_loop.supplyInletNode)

  # Add the HX to the demand side of
  # the main service water loop.
  main_service_water_loop.addDemandBranchForComponent(hx)

  # Add a plant component temperature source to the demand outlet
  # of the HX to represent the fact that the water used by the booster
  # would in reality be at the mains temperature.
  mains_src = OpenStudio::Model::PlantComponentTemperatureSource.new(model)
  mains_src.setName('Mains Water Makeup for SWH Booster')
  mains_src.addToNode(hx.demandOutletModelObject.get.to_Node.get)

  # Mains water temperature sensor
  mains_water_temp_sen = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Site Mains Water Temperature')
  mains_water_temp_sen.setName('Mains_Water_Temp_Sen')
  mains_water_temp_sen.setKeyName('Environment')

  # Schedule to actuate
  water_mains_temp_sch = OpenStudio::Model::ScheduleConstant.new(model)
  water_mains_temp_sch.setName('Mains Water Temperature')
  water_mains_temp_sch.setValue(OpenStudio.convert(50, 'F', 'C').get)

  # Actuator for mains water temperature schedule
  mains_water_temp_sch_act = OpenStudio::Model::EnergyManagementSystemActuator.new(water_mains_temp_sch, 'Schedule:Constant', 'Schedule Value')
  mains_water_temp_sch_act.setName('Mains_Water_Temp_Act')

  # Program
  mains_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  mains_prg.setName('Mains_Water_Prg')
  mains_prg_body = "SET #{mains_water_temp_sch_act.handle} = #{mains_water_temp_sen.handle}"
  mains_prg.setBody(mains_prg_body)

  # Program Calling Manager
  mains_mgr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)
  mains_mgr.setName('Mains_Water_Prg_Mgr')
  mains_mgr.setCallingPoint('BeginTimestepBeforePredictor')
  mains_mgr.addProgram(mains_prg)

  # Make the plant component use the actuated schedule
  mains_src.setTemperatureSpecificationType('Scheduled')
  mains_src.setSourceTemperatureSchedule(water_mains_temp_sch)

  return booster_service_water_loop
end

#model_add_swh_end_uses(model, use_name, swh_loop, peak_flowrate, flowrate_schedule, water_use_temperature, space_name, frac_sensible: 0.2, frac_latent: 0.05) ⇒ OpenStudio::Model::WaterUseEquipment

Creates water fixtures and attaches them to the supplied service water loop.

to the newly created fixture. the main service water loop to add water fixtures to. or nil, in which case it will not be assigned to any particular space. the resulting water fixture.

Parameters:

  • use_name (String)

    The name that will be assigned

  • swh_loop (OpenStudio::Model::PlantLoop)
  • peak_flowrate (Double)

    in m^3/s

  • flowrate_schedule (String)

    name of the flow rate schedule

  • water_use_temperature (Double)

    mixed water use temperature, in C

  • space_name (String)

    the name of the space to add the water fixture to,

Returns:

  • (OpenStudio::Model::WaterUseEquipment)


789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.ServiceWaterHeating.rb', line 789

def model_add_swh_end_uses(model,
                           use_name,
                           swh_loop,
                           peak_flowrate,
                           flowrate_schedule,
                           water_use_temperature,
                           space_name,
                           frac_sensible: 0.2,
                           frac_latent: 0.05)
  # Water use connection
  swh_connection = OpenStudio::Model::WaterUseConnections.new(model)

  # Water fixture definition
  water_fixture_def = OpenStudio::Model::WaterUseEquipmentDefinition.new(model)
  rated_flow_rate_m3_per_s = peak_flowrate
  rated_flow_rate_gal_per_min = OpenStudio.convert(rated_flow_rate_m3_per_s, 'm^3/s', 'gal/min').get

  water_use_sensible_frac_sch = model_add_constant_schedule_ruleset(model,
                                                                    frac_sensible,
                                                                    name = "Fraction Sensible - #{frac_sensible}",
                                                                    sch_type_limit: 'Fractional')
  water_use_latent_frac_sch = model_add_constant_schedule_ruleset(model,
                                                                  frac_latent,
                                                                  name = "Fraction Latent - #{frac_latent}",
                                                                  sch_type_limit: 'Fractional')
  water_fixture_def.setSensibleFractionSchedule(water_use_sensible_frac_sch)
  water_fixture_def.setLatentFractionSchedule(water_use_latent_frac_sch)
  water_fixture_def.setPeakFlowRate(rated_flow_rate_m3_per_s)
  water_fixture_def.setName("#{use_name} Service Water Use Def #{rated_flow_rate_gal_per_min.round(2)}gpm")
  # Target mixed water temperature
  mixed_water_temp_f = OpenStudio.convert(water_use_temperature, 'C', 'F').get
  mixed_water_temp_sch = model_add_constant_schedule_ruleset(model,
                                                             OpenStudio.convert(mixed_water_temp_f, 'F', 'C').get,
                                                             name = "Mixed Water At Faucet Temp - #{mixed_water_temp_f.round}F")
  water_fixture_def.setTargetTemperatureSchedule(mixed_water_temp_sch)

  # Water use equipment
  water_fixture = OpenStudio::Model::WaterUseEquipment.new(water_fixture_def)
  schedule = model_add_schedule(model, flowrate_schedule)
  water_fixture.setFlowRateFractionSchedule(schedule)

  if space_name.nil?
    water_fixture.setName("#{use_name} Service Water Use #{rated_flow_rate_gal_per_min.round(2)}gpm at #{mixed_water_temp_f.round}F")
    swh_connection.setName("#{use_name} WUC #{rated_flow_rate_gal_per_min.round(2)}gpm at #{mixed_water_temp_f.round}F")
  else
    water_fixture.setName("#{space_name} Service Water Use #{rated_flow_rate_gal_per_min.round(2)}gpm at #{mixed_water_temp_f.round}F")
    swh_connection.setName("#{space_name} WUC #{rated_flow_rate_gal_per_min.round(2)}gpm at #{mixed_water_temp_f.round}F")
  end

  unless space_name.nil?
    space = model.getSpaceByName(space_name)
    space = space.get
    water_fixture.setSpace(space)
  end

  swh_connection.addWaterUseEquipment(water_fixture)

  # Connect the water use connection to the SWH loop
  unless swh_loop.nil?
    swh_loop.addDemandBranchForComponent(swh_connection)
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding water fixture to #{swh_loop.name}.")
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Added #{water_fixture.name}.")

  return water_fixture
end

#model_add_swh_end_uses_by_space(model, swh_loop, space, space_multiplier = 1.0, is_flow_per_area = true) ⇒ OpenStudio::Model::WaterUseEquipment

This method will add a swh water fixture to the model for the space. It will return a water fixture object, or NIL if there is no water load at all.

Adds a WaterUseEquipment object representing the SWH loads of the supplied Space. Attaches this WaterUseEquipment to the supplied PlantLoop via a new WaterUseConnections object.

Parameters:

  • model (OpenStudio::Model::Model)

    the model

  • swh_loop (OpenStudio::Model::PlantLoop)

    the SWH loop to connect the WaterUseEquipment to

  • is_flow_per_area (Bool) (defaults to: true)

    if true, use the value in the ‘service_water_heating_peak_flow_per_area’ field of the space_types JSON. If false, use the value in the ‘service_water_heating_peak_flow_rate’ field.

Returns:

  • (OpenStudio::Model::WaterUseEquipment)

    the WaterUseEquipment for the



871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.ServiceWaterHeating.rb', line 871

def model_add_swh_end_uses_by_space(model,
                                    swh_loop,
                                    space,
                                    space_multiplier = 1.0,
                                    is_flow_per_area = true)
  # SpaceType
  if space.spaceType.empty?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', "Space #{space.name} does not have a Space Type assigned, cannot add SWH end uses.")
    return nil
  end
  space_type = space.spaceType.get

  # Standards Building Type
  if space_type.standardsBuildingType.empty?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', "Space #{space.name}'s Space Type does not have a Standards Building Type assigned, cannot add SWH end uses.")
    return nil
  end
  stds_bldg_type = space_type.standardsBuildingType.get
  building_type = model_get_lookup_name(stds_bldg_type)

  # Standards Space Type
  if space_type.standardsSpaceType.empty?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', "Space #{space.name}'s Space Type does not have a Standards Space Type assigned, cannot add SWH end uses.")
    return nil
  end
  stds_spc_type = space_type.standardsSpaceType.get

  # find the specific space_type properties from standard.json
  search_criteria = {
    'template' => template,
    'building_type' => building_type,
    'space_type' => stds_spc_type
  }
  data = standards_lookup_table_first(table_name: 'space_types', search_criteria: search_criteria)
  if data.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Could not find space type for: #{search_criteria}.")
    return nil
  end
  space_area = OpenStudio.convert(space.floorArea, 'm^2', 'ft^2').get # ft2

  # If there is no service hot water load.. Don't bother adding anything.
  if data['service_water_heating_peak_flow_per_area'].to_f == 0.0 &&
     data['service_water_heating_peak_flow_rate'].to_f == 0.0
    return nil
  end

  # Water use connection
  swh_connection = OpenStudio::Model::WaterUseConnections.new(model)

  # Water fixture definition
  water_fixture_def = OpenStudio::Model::WaterUseEquipmentDefinition.new(model)
  rated_flow_rate_per_area = data['service_water_heating_peak_flow_per_area'].to_f # gal/h.ft2
  rated_flow_rate_gal_per_hour = if is_flow_per_area
                                   rated_flow_rate_per_area * space_area * space_multiplier # gal/h
                                 else
                                   data['service_water_heating_peak_flow_rate'].to_f
                                 end
  rated_flow_rate_gal_per_min = rated_flow_rate_gal_per_hour / 60 # gal/h to gal/min
  rated_flow_rate_m3_per_s = OpenStudio.convert(rated_flow_rate_gal_per_min, 'gal/min', 'm^3/s').get
  water_use_sensible_frac_sch = model_add_constant_schedule_ruleset(model,
                                                                    0.2,
                                                                    name = 'Fraction Sensible - 0.2',
                                                                    sch_type_limit: 'Fractional')
  water_use_latent_frac_sch = model_add_constant_schedule_ruleset(model,
                                                                  0.05,
                                                                  name = 'Fraction Latent - 0.05',
                                                                  sch_type_limit: 'Fractional')
  water_fixture_def.setSensibleFractionSchedule(water_use_sensible_frac_sch)
  water_fixture_def.setLatentFractionSchedule(water_use_latent_frac_sch)
  water_fixture_def.setPeakFlowRate(rated_flow_rate_m3_per_s)
  water_fixture_def.setName("#{space.name.get} Service Water Use Def #{rated_flow_rate_gal_per_min.round(2)}gpm")
  # Target mixed water temperature
  mixed_water_temp_f = data['service_water_heating_target_temperature']
  mixed_water_temp_c = OpenStudio.convert(mixed_water_temp_f, 'F', 'C').get
  mixed_water_temp_sch = model_add_constant_schedule_ruleset(model,
                                                             mixed_water_temp_c,
                                                             name = "Mixed Water At Faucet Temp - #{mixed_water_temp_f.round}F")
  water_fixture_def.setTargetTemperatureSchedule(mixed_water_temp_sch)

  # Water use equipment
  water_fixture = OpenStudio::Model::WaterUseEquipment.new(water_fixture_def)
  schedule = model_add_schedule(model, data['service_water_heating_schedule'])
  water_fixture.setFlowRateFractionSchedule(schedule)
  water_fixture.setName("#{space.name.get} Service Water Use #{rated_flow_rate_gal_per_min.round(2)}gpm")
  swh_connection.addWaterUseEquipment(water_fixture)
  # Assign water fixture to a space
  water_fixture.setSpace(space) if model_attach_water_fixtures_to_spaces?(model)

  # Connect the water use connection to the SWH loop
  swh_loop.addDemandBranchForComponent(swh_connection)
  return water_fixture
end

#model_add_swh_end_uses_by_spaceonly(model, space, swh_loop) ⇒ Object

This method will add an swh water fixture to the model for the space. if the it will return a water fixture object, or NIL if there is no water load at all.



6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 6428

def model_add_swh_end_uses_by_spaceonly(model, space, swh_loop)
  # Water use connection
  swh_connection = OpenStudio::Model::WaterUseConnections.new(model)

  # Water fixture definition
  water_fixture_def = OpenStudio::Model::WaterUseEquipmentDefinition.new(model)

  # water_use_sensible_frac_sch = OpenStudio::Model::ScheduleConstant.new(self)
  # water_use_sensible_frac_sch.setValue(0.2)
  # water_use_latent_frac_sch = OpenStudio::Model::ScheduleConstant.new(self)
  # water_use_latent_frac_sch.setValue(0.05)
  # Note that when water use equipment is assigned to spaces then the water used by the equipment is multiplied by the
  # space (ultimately thermal zone) multiplier.  Note that there is a separate water use equipment multiplier as well
  # which is different than the space (ultimately thermal zone) multiplier.
  rated_flow_rate_gal_per_min = OpenStudio.convert(space['shw_peakflow_ind_SI'], 'm^3/s', 'gal/min').get
  water_use_sensible_frac_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  water_use_sensible_frac_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0.2)
  water_use_latent_frac_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  water_use_latent_frac_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0.05)
  water_fixture_def.setSensibleFractionSchedule(water_use_sensible_frac_sch)
  water_fixture_def.setLatentFractionSchedule(water_use_latent_frac_sch)
  water_fixture_def.setPeakFlowRate(space['shw_peakflow_ind_SI'])
  water_fixture_def.setName("#{space['shw_spaces'].name.to_s.capitalize} Service Water Use Def #{rated_flow_rate_gal_per_min.round(2)}gal/min")
  # Target mixed water temperature
  mixed_water_temp_c = space['shw_temp_SI']
  mixed_water_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  mixed_water_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), mixed_water_temp_c)
  water_fixture_def.setTargetTemperatureSchedule(mixed_water_temp_sch)

  # Water use equipment
  water_fixture = OpenStudio::Model::WaterUseEquipment.new(water_fixture_def)
  schedule = model_add_schedule(model, space['shw_sched'])
  water_fixture.setFlowRateFractionSchedule(schedule)
  water_fixture.setName("#{space['shw_spaces'].name.to_s.capitalize} Service Water Use #{rated_flow_rate_gal_per_min.round(2)}gal/min")
  swh_connection.addWaterUseEquipment(water_fixture)
  # Assign water fixture to a space
  water_fixture.setSpace(space['shw_spaces']) if model_attach_water_fixtures_to_spaces?(model)

  # Connect the water use connection to the SWH loop
  swh_loop.addDemandBranchForComponent(swh_connection)
  return water_fixture
end

#model_add_swh_loop(model, system_name, water_heater_thermal_zone, service_water_temperature, service_water_pump_head, service_water_pump_motor_efficiency, water_heater_capacity, water_heater_volume, water_heater_fuel, parasitic_fuel_consumption_rate, add_pipe_losses = false, floor_area_served = 465, number_of_stories = 1, pipe_insulation_thickness = 0.0127, number_water_heaters = 1) ⇒ OpenStudio::Model::PlantLoop

Creates a service water heating loop.

Used to modify efficiencies for water heaters based on individual component size while avoiding having to model lots of individual water heaters (for runtime sake). the resulting service water loop.

Parameters:

  • system_name (String)

    the name of the system, or nil in which case it will be defaulted

  • water_heater_thermal_zone (OpenStudio::Model::ThermalZone)

    zones to place water heater in. If nil, will be assumed in 70F air for heat loss.

  • service_water_temperature (Double)

    service water temperature, in C

  • service_water_pump_head (Double)

    service water pump head, in Pa

  • service_water_pump_motor_efficiency (Double)

    service water pump motor efficiency, as decimal.

  • water_heater_capacity (Double)

    water heater heating capacity, in W

  • water_heater_volume (Double)

    water heater volume, in m^3

  • water_heater_fuel (String)

    water heater fuel. Valid choices are NaturalGas, Electricity

  • parasitic_fuel_consumption_rate (Double)

    the parasitic fuel consumption rate of the water heater, in W

  • add_pipe_losses (Bool) (defaults to: false)

    if true, add piping and associated heat losses to system. If false, add no pipe heat losses

  • floor_area_served (Double) (defaults to: 465)

    area served by the SWH loop, in m^2. Used for pipe loss piping length estimation

  • number_of_stories (Integer) (defaults to: 1)

    number of stories served by the SWH loop. Used for pipe loss piping length estimation

  • pipe_insulation_thickness (Double) (defaults to: 0.0127)

    thickness of the fiberglass batt pipe insulation, in m. Use 0 for uninsulated pipes

  • number_water_heaters (Double) (defaults to: 1)

    the number of water heaters represented by the capacity and volume inputs.

Returns:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.ServiceWaterHeating.rb', line 25

def model_add_swh_loop(model,
                       system_name,
                       water_heater_thermal_zone,
                       service_water_temperature,
                       service_water_pump_head,
                       service_water_pump_motor_efficiency,
                       water_heater_capacity,
                       water_heater_volume,
                       water_heater_fuel,
                       parasitic_fuel_consumption_rate,
                       add_pipe_losses = false,
                       floor_area_served = 465,
                       number_of_stories = 1,
                       pipe_insulation_thickness = 0.0127, # 1/2in
                       number_water_heaters = 1)
  # Service water heating loop
  service_water_loop = OpenStudio::Model::PlantLoop.new(model)
  service_water_loop.setMinimumLoopTemperature(10.0)
  service_water_loop.setMaximumLoopTemperature(60.0)

  if system_name.nil?
    service_water_loop.setName('Service Water Loop')
  else
    service_water_loop.setName(system_name)
  end

  # Temperature schedule type limits
  temp_sch_type_limits = model_add_schedule_type_limits(model,
                                                        name: 'Temperature Schedule Type Limits',
                                                        lower_limit_value: 0.0,
                                                        upper_limit_value: 100.0,
                                                        numeric_type: 'Continuous',
                                                        unit_type: 'Temperature')

  # Service water heating loop controls
  swh_temp_c = service_water_temperature
  swh_temp_f = OpenStudio.convert(swh_temp_c, 'C', 'F').get
  swh_delta_t_r = 9.0 # 9F delta-T
  swh_delta_t_k = OpenStudio.convert(swh_delta_t_r, 'R', 'K').get
  swh_temp_sch = model_add_constant_schedule_ruleset(model,
                                                     swh_temp_c,
                                                     name = "Service Water Loop Temp - #{swh_temp_f.round}F")
  swh_temp_sch.setScheduleTypeLimits(temp_sch_type_limits)
  swh_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, swh_temp_sch)
  swh_stpt_manager.setName('Service hot water setpoint manager')
  swh_stpt_manager.addToNode(service_water_loop.supplyOutletNode)
  sizing_plant = service_water_loop.sizingPlant
  sizing_plant.setLoopType('Heating')
  sizing_plant.setDesignLoopExitTemperature(swh_temp_c)
  sizing_plant.setLoopDesignTemperatureDifference(swh_delta_t_k)

  # Determine if circulating or non-circulating based on supplied head pressure
  swh_pump_head_press_pa = service_water_pump_head
  circulating = true
  if swh_pump_head_press_pa.nil? || swh_pump_head_press_pa <= 1
    # As if there is no circulation pump
    swh_pump_head_press_pa = 0.001
    service_water_pump_motor_efficiency = 1
    circulating = false
  end

  # Service water heating pump
  if circulating
    swh_pump = OpenStudio::Model::PumpConstantSpeed.new(model)
    swh_pump.setName("#{service_water_loop.name} Circulator Pump")
    swh_pump.setPumpControlType('Intermittent')
  else
    swh_pump = OpenStudio::Model::PumpVariableSpeed.new(model)
    swh_pump.setName("#{service_water_loop.name} Water Mains Pressure Driven")
    swh_pump.setPumpControlType('Continuous')
  end
  swh_pump.setRatedPumpHead(swh_pump_head_press_pa.to_f)
  swh_pump.setMotorEfficiency(service_water_pump_motor_efficiency)
  swh_pump.addToNode(service_water_loop.supplyInletNode)

  water_heater = model_add_water_heater(model,
                                        water_heater_capacity,
                                        water_heater_volume,
                                        water_heater_fuel,
                                        service_water_temperature,
                                        parasitic_fuel_consumption_rate,
                                        swh_temp_sch,
                                        false,
                                        0.0,
                                        nil,
                                        water_heater_thermal_zone,
                                        number_water_heaters)

  service_water_loop.addSupplyBranchForComponent(water_heater)

  # Pipe losses
  if add_pipe_losses
    model_add_piping_losses_to_swh_system(model,
                                          service_water_loop,
                                          circulating,
                                          pipe_insulation_thickness: pipe_insulation_thickness,
                                          floor_area_served: floor_area_served,
                                          number_of_stories: number_of_stories)
  end

  # Service water heating loop bypass pipes
  water_heater_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  service_water_loop.addSupplyBranchForComponent(water_heater_bypass_pipe)
  coil_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  service_water_loop.addDemandBranchForComponent(coil_bypass_pipe)
  supply_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  supply_outlet_pipe.addToNode(service_water_loop.supplyOutletNode)
  demand_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_outlet_pipe.addToNode(service_water_loop.demandOutletNode)

  if circulating
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Added circulating SWH loop called #{service_water_loop.name}")
  else
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Added non-circulating SWH loop called #{service_water_loop.name}")
  end

  return service_water_loop
end

#model_add_transformer(model, wired_lighting_frac: nil, transformer_size: nil, transformer_efficiency: nil, excluded_interiorequip_key: '', excluded_interiorequip_meter: nil) ⇒ Object

Add transformers for some prototypes



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.transformers.rb', line 4

def model_add_transformer(model,
                          wired_lighting_frac: nil,
                          transformer_size: nil,
                          transformer_efficiency: nil,
                          excluded_interiorequip_key: '',
                          excluded_interiorequip_meter: nil)
  # throw an error if transformer properties are missing
  if wired_lighting_frac.nil? || transformer_size.nil? || transformer_efficiency.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.transformers', "Either 'wired_lighting_frac', 'transformer_size', or 'transformer_efficiency' is unspecified.  Cannot add transformer.")
    return false
  end

  # TODO: default values are for testing only.
  # ems sensor for interior lighting
  facility_int_ltg = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'InteriorLights:Electricity')
  facility_int_ltg.setName('Facility_Int_LTG')

  # declaire ems variable for transformer wired lighting portion
  wired_ltg_var = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, 'Wired_LTG')

  # ems program for transformer load
  transformer_load_prog = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  transformer_load_prog.setName('Transformer_Load_Prog')
  transformer_load_prog_body = <<-EMS
  SET Wired_LTG = Facility_Int_LTG*#{wired_lighting_frac}
  EMS
  transformer_load_prog.setBody(transformer_load_prog_body)

  # ems program calling manager
  transformer_load_prog_manager = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)
  transformer_load_prog_manager.setName('Transformer_Load_Prog_Manager')
  transformer_load_prog_manager.setCallingPoint('AfterPredictorAfterHVACManagers')
  transformer_load_prog_manager.addProgram(transformer_load_prog)

  # ems output variable
  wired_ltg_emsout = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model, wired_ltg_var)
  wired_ltg_emsout.setName('Wired_LTG')
  wired_ltg_emsout.setTypeOfDataInVariable('Summed')
  wired_ltg_emsout.setUpdateFrequency('ZoneTimeStep')
  wired_ltg_emsout.setUnits('J')

  # meter for ems output
  wired_ltg_meter = OpenStudio::Model::MeterCustom.new(model)
  wired_ltg_meter.setName('Wired_LTG_Electricity')
  wired_ltg_meter.setFuelType('Electricity')
  wired_ltg_meter.addKeyVarGroup('', 'Wired_LTG')

  # meter for wired int equip
  unless excluded_interiorequip_meter.nil?
    wired_int_equip_meter = OpenStudio::Model::MeterCustomDecrement.new(model, 'InteriorEquipment:Electricity')
    wired_int_equip_meter.setName('Wired_Int_EQUIP')
    wired_int_equip_meter.setFuelType('Electricity')
    wired_int_equip_meter.addKeyVarGroup(excluded_interiorequip_key, excluded_interiorequip_meter)
  end

  # add transformer
  transformer = OpenStudio::Model::ElectricLoadCenterTransformer.new(model)
  transformer.setName('Transformer_1')
  transformer.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  transformer.setTransformerUsage('PowerInFromGrid')
  transformer.setRatedCapacity(transformer_size)
  transformer.setPhase('3')
  transformer.setConductorMaterial('Aluminum')
  transformer.setFullLoadTemperatureRise(150)
  transformer.setFractionofEddyCurrentLosses(0.1)
  transformer.setPerformanceInputMethod('NominalEfficiency')
  transformer.setNameplateEfficiency(transformer_efficiency)
  transformer.setPerUnitLoadforNameplateEfficiency(0.35)
  transformer.setReferenceTemperatureforNameplateEfficiency(75)
  transformer.setConsiderTransformerLossforUtilityCost(true)
  transformer.addMeter('Wired_LTG_Electricity')
  if excluded_interiorequip_meter.nil?
    transformer.addMeter('InteriorEquipment:Electricity') # by default, add this as the second meter
  else
    transformer.addMeter('Wired_Int_EQUIP')
  end
end

#model_add_typical_exterior_lights(model, exterior_lighting_zone_number, onsite_parking_fraction = 1.0, add_base_site_allowance = false, use_model_for_entries_and_canopies = false) ⇒ Hash

TODO:
  • would be nice to add argument for some building types (SmallHotel, MidriseApartment, PrimarySchool, SecondarySchool, RetailStripmall) if it has interior or exterior circulation.

Add exterior lighting to the model

Parameters:

  • exterior_lighting_zone_number (Integer)

    Valid choices are

Returns:

  • (Hash)

    the resulting exterior lights



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.exterior_lights.rb', line 7

def model_add_typical_exterior_lights(model, exterior_lighting_zone_number, onsite_parking_fraction = 1.0, add_base_site_allowance = false, use_model_for_entries_and_canopies = false)
  exterior_lights = {}
  installed_power = 0.0

  # populate search hash
  search_criteria = {
    'template' => template,
    'exterior_lighting_zone_number' => exterior_lighting_zone_number
  }

  # load exterior_lighting_properties
  exterior_lighting_properties = standards_lookup_table_first(table_name: 'exterior_lighting', search_criteria: search_criteria)

  # make sure lighting properties were found
  if exterior_lighting_properties.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.prototype.exterior_lights', "Exterior lighting properties not found for #{template}, ext lighting zone #{exterior_lighting_zone_number}, none will be added to model.")
    return exterior_lights
  end

  # get building types and ratio (needed to get correct schedules, parking area, entries, canopies, and drive throughs)
  space_type_hash = model_create_space_type_hash(model)

  # get model specific values to map to exterior_lighting_properties
  area_length_count_hash = model_create_exterior_lighting_area_length_count_hash(model, space_type_hash, use_model_for_entries_and_canopies)

  # using midnight to 6am setback or shutdown
  start_setback_shutoff = { hr: 24, min: 0 }
  end_setback_shutoff = { hr: 6, min: 0 }
  shuttoff = false
  setback = false
  if exterior_lighting_properties['building_facade_and_landscape_automatic_shut_off'] == 1
    ext_lights_sch_facade_and_landscape = OpenStudio::Model::ScheduleRuleset.new(model)
    default_day = ext_lights_sch_facade_and_landscape.defaultDaySchedule
    default_day.addValue(OpenStudio::Time.new(0, end_setback_shutoff[:hr], end_setback_shutoff[:min], 0), 0.0)
    default_day.addValue(OpenStudio::Time.new(0, start_setback_shutoff[:hr], start_setback_shutoff[:min], 0), 1.0)
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.exterior_lights', "Facade and Landscape exterior lights shut off from #{start_setback_shutoff} to #{end_setback_shutoff}")
  else
    ext_lights_sch_facade_and_landscape = model.alwaysOnDiscreteSchedule
  end
  if !exterior_lighting_properties['occupancy_setback_reduction'].nil? && (exterior_lighting_properties['occupancy_setback_reduction'] > 0.0)
    ext_lights_sch_other = OpenStudio::Model::ScheduleRuleset.new(model)
    setback_value = 1.0 - exterior_lighting_properties['occupancy_setback_reduction']
    default_day = ext_lights_sch_other.defaultDaySchedule
    default_day.addValue(OpenStudio::Time.new(0, end_setback_shutoff[:hr], end_setback_shutoff[:min], 0), setback_value)
    default_day.addValue(OpenStudio::Time.new(0, start_setback_shutoff[:hr], start_setback_shutoff[:min], 0), 1.0)
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.exterior_lights', "Non Facade and Landscape lights reduce by #{exterior_lighting_properties['occupancy_setback_reduction'] * 100} % from #{start_setback_shutoff} to #{end_setback_shutoff}")
  else
    ext_lights_sch_other = model.alwaysOnDiscreteSchedule
  end

  # add exterior lights for parking area
  if area_length_count_hash[:parking_area_and_drives_area] > 0

    # lighting values
    multiplier = area_length_count_hash[:parking_area_and_drives_area] * onsite_parking_fraction
    power = exterior_lighting_properties['parking_areas_and_drives']
    name_prefix = 'Parking Areas and Drives'

    # create ext light def
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.exterior_lights', "Added #{power.round(2)} W/ft^2 of lighting for #{multiplier} ft^2 of parking area.")
    ext_lights_def = OpenStudio::Model::ExteriorLightsDefinition.new(model)
    ext_lights_def.setName("#{name_prefix} Def (W/ft^2)")
    ext_lights_def.setDesignLevel(power)

    # create ext light inst
    # creating exterior lights object
    ext_lights = OpenStudio::Model::ExteriorLights.new(ext_lights_def, ext_lights_sch_other)
    ext_lights.setMultiplier(multiplier)
    ext_lights.setName(name_prefix)
    ext_lights.setControlOption(exterior_lighting_properties['control_option'])
    ext_lights.setEndUseSubcategory(name_prefix)
    exterior_lights[name_prefix] = ext_lights

    # update installed power
    installed_power += power * multiplier
  end

  # add exterior lights for facades
  if area_length_count_hash[:building_facades] > 0

    # lighting values
    multiplier = area_length_count_hash[:building_facades]
    power = exterior_lighting_properties['building_facades']
    name_prefix = 'Building Facades'

    # create ext light def
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.exterior_lights', "Added #{power.round(2)} W/ft^2 of lighting for #{multiplier} ft^2 of building facade area.")
    ext_lights_def = OpenStudio::Model::ExteriorLightsDefinition.new(model)
    ext_lights_def.setName("#{name_prefix} Def (W/ft^2)")
    ext_lights_def.setDesignLevel(power)

    # create ext light inst
    # creating exterior lights object
    ext_lights = OpenStudio::Model::ExteriorLights.new(ext_lights_def, ext_lights_sch_facade_and_landscape)
    ext_lights.setMultiplier(multiplier)
    ext_lights.setName(name_prefix)
    ext_lights.setControlOption(exterior_lighting_properties['control_option'])
    ext_lights.setEndUseSubcategory(name_prefix)
    exterior_lights[name_prefix] = ext_lights

    # update installed power
    installed_power += power * multiplier
  end

  # add exterior lights for main entries
  if area_length_count_hash[:main_entries] > 0

    # lighting values
    multiplier = area_length_count_hash[:main_entries]
    power = exterior_lighting_properties['main_entries']
    name_prefix = 'Main Entries'

    # create ext light def
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.exterior_lights', "Added #{power.round(2)} W/ft of lighting for #{multiplier} ft of main entry length.")
    ext_lights_def = OpenStudio::Model::ExteriorLightsDefinition.new(model)
    ext_lights_def.setName("#{name_prefix} Def (W/ft)")
    ext_lights_def.setDesignLevel(power)

    # create ext light inst
    # creating exterior lights object
    ext_lights = OpenStudio::Model::ExteriorLights.new(ext_lights_def, ext_lights_sch_other)
    ext_lights.setMultiplier(multiplier)
    ext_lights.setName(name_prefix)
    ext_lights.setControlOption(exterior_lighting_properties['control_option'])
    ext_lights.setEndUseSubcategory(name_prefix)
    exterior_lights[name_prefix] = ext_lights

    # update installed power
    installed_power += power * multiplier
  end

  # add exterior lights for other doors
  if area_length_count_hash[:other_doors] > 0

    # lighting values
    multiplier = area_length_count_hash[:other_doors]
    power = exterior_lighting_properties['other_doors']
    name_prefix = 'Other Doors'

    # create ext light def
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.exterior_lights', "Added #{power.round(2)} W/ft of lighting for #{multiplier} ft of other doors.")
    ext_lights_def = OpenStudio::Model::ExteriorLightsDefinition.new(model)
    ext_lights_def.setName("#{name_prefix} Def (W/ft)")
    ext_lights_def.setDesignLevel(power)

    # create ext light inst
    # creating exterior lights object
    ext_lights = OpenStudio::Model::ExteriorLights.new(ext_lights_def, ext_lights_sch_other)
    ext_lights.setMultiplier(multiplier)
    ext_lights.setName(name_prefix)
    ext_lights.setControlOption(exterior_lighting_properties['control_option'])
    ext_lights.setEndUseSubcategory(name_prefix)
    exterior_lights[name_prefix] = ext_lights

    # update installed power
    installed_power += power * multiplier
  end

  # add exterior lights for entry canopies
  if area_length_count_hash[:canopy_entry_area] > 0

    # lighting values
    multiplier = area_length_count_hash[:canopy_entry_area]
    power = exterior_lighting_properties['entry_canopies']
    name_prefix = 'Entry Canopies'

    # create ext light def
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.exterior_lights', "Added #{power} W/ft^2 of lighting for #{multiplier} ft^2 of building entry canopies.")
    ext_lights_def = OpenStudio::Model::ExteriorLightsDefinition.new(model)
    ext_lights_def.setName("#{name_prefix} Def (W/ft^2)")
    ext_lights_def.setDesignLevel(power)

    # create ext light inst
    # creating exterior lights object
    ext_lights = OpenStudio::Model::ExteriorLights.new(ext_lights_def, ext_lights_sch_other)
    ext_lights.setMultiplier(multiplier)
    ext_lights.setName(name_prefix)
    ext_lights.setControlOption(exterior_lighting_properties['control_option'])
    ext_lights.setEndUseSubcategory(name_prefix)
    exterior_lights[name_prefix] = ext_lights

    # update installed power
    installed_power += power * multiplier
  end

  # add exterior lights for emergency canopies
  if area_length_count_hash[:canopy_emergency_area] > 0

    # lighting values
    multiplier = area_length_count_hash[:canopy_emergency_area]
    power = exterior_lighting_properties['loading_areas_for_emergency_vehicles']
    name_prefix = 'Emergency Canopies'

    # create ext light def
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.exterior_lights', "Added #{power} W/ft^2 of lighting for #{multiplier} ft^2 of building emergency canopies.")
    ext_lights_def = OpenStudio::Model::ExteriorLightsDefinition.new(model)
    ext_lights_def.setName("#{name_prefix} Def (W/ft^2)")
    ext_lights_def.setDesignLevel(power)

    # create ext light inst
    # creating exterior lights object
    ext_lights = OpenStudio::Model::ExteriorLights.new(ext_lights_def, ext_lights_sch_other)
    ext_lights.setMultiplier(multiplier)
    ext_lights.setName(name_prefix)
    ext_lights.setControlOption(exterior_lighting_properties['control_option'])
    ext_lights.setEndUseSubcategory(name_prefix)
    exterior_lights[name_prefix] = ext_lights

    # update installed power
    installed_power += power * multiplier
  end

  # add exterior lights for drive through windows
  if area_length_count_hash[:drive_through_windows] > 0

    # lighting values
    multiplier = area_length_count_hash[:drive_through_windows]
    power = exterior_lighting_properties['drive_through_windows_and_doors']
    name_prefix = 'Drive Through Windows'

    # create ext light def
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.exterior_lights', "Added #{power} W/drive through window of lighting for #{multiplier} drive through windows.")
    ext_lights_def = OpenStudio::Model::ExteriorLightsDefinition.new(model)
    ext_lights_def.setName("#{name_prefix} Def (W/ft^2)")
    ext_lights_def.setDesignLevel(power)

    # create ext light inst
    # creating exterior lights object
    ext_lights = OpenStudio::Model::ExteriorLights.new(ext_lights_def, ext_lights_sch_other)
    ext_lights.setMultiplier(multiplier)
    ext_lights.setName(name_prefix)
    ext_lights.setControlOption(exterior_lighting_properties['control_option'])
    ext_lights.setEndUseSubcategory(name_prefix)
    exterior_lights[name_prefix] = ext_lights

    # update installed power
    installed_power += power * multiplier
  end

  # TODO: - add_base_site_lighting_allowance (non landscaping tradable lighting)
  # add exterior lights for drive through windows
  if add_base_site_allowance

    # lighting values
    if !exterior_lighting_properties['base_site_allowance_power'].nil?
      power = exterior_lighting_properties['base_site_allowance_power']
    elsif !exterior_lighting_properties['base_site_allowance_fraction'].nil?
      power = exterior_lighting_properties['base_site_allowance_fraction'] * installed_power # shold be of allowed vs. installed, but hard to calculate
    else
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.exterior_lights', 'Cannot determine target base site allowance power, will set to 0 W.')
      power = 0.0
    end
    name_prefix = 'Base Site Allowance'

    # create ext light def
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.exterior_lights', "Added #{power} W of non landscape tradable exterior lighting. Will follow occupancy setback reduction.")
    ext_lights_def = OpenStudio::Model::ExteriorLightsDefinition.new(model)
    ext_lights_def.setName("#{name_prefix} Def (W)")
    ext_lights_def.setDesignLevel(power)

    # create ext light inst
    # creating exterior lights object
    ext_lights = OpenStudio::Model::ExteriorLights.new(ext_lights_def, ext_lights_sch_other)
    ext_lights.setName(name_prefix)
    ext_lights.setControlOption(exterior_lighting_properties['control_option'])
    ext_lights.setEndUseSubcategory(name_prefix)
    exterior_lights[name_prefix] = ext_lights

    # don't need to update installed power for this
  end

  return exterior_lights
end

#model_add_typical_refrigeration(model, building_type) ⇒ Object

Add a typical refrigeration system to the model, including cases, walkins, compressors, and condensors. For small stores, each case and walkin is served by one compressor and one condenser. For larger stores, all medium temp cases and walkins are served by one multi-compressor rack, and all low temp cases and walkins another.



509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.refrigeration.rb', line 509

def model_add_typical_refrigeration(model, building_type)
  # Define system category and scaling factor
  floor_area_ft2 = OpenStudio.convert(model.getBuilding.floorArea, 'm^2', 'ft^2').get
  case building_type
  when 'SuperMarket', 'Gro'
    if floor_area_ft2 < 35_000 # this is in m2
      size_category = '<35k ft2'
      floor_area_scaling_factor = floor_area_ft2 / 35_000
    elsif floor_area_ft2 < 50_000
      size_category = '35k - 50k ft2'
      floor_area_scaling_factor = floor_area_ft2 / 50_000
    else
      size_category = '>50k ft2'
      floor_area_scaling_factor = floor_area_ft2 / 50_000
    end
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Refrigeration size category is #{size_category}, with a scaling factor of #{floor_area_scaling_factor} because the floor area is #{floor_area_ft2.round} ft2.  All cases and walkins added later will subsequently be scaled by this factor.")
  else
    size_category = 'Kitchen'
    floor_area_scaling_factor = 1 # Do not scale kitchen systems
  end

  # Add a low and medium temperature system
  ['Medium Temperature', 'Low Temperature'].each do |system_type|
    # Find refrigeration system lineup
    search_criteria = {
      'template' => template,
      'building_type' => building_type,
      'size_category' => size_category,
      'system_type' => system_type
    }
    props_lineup = model_find_object(standards_data['refrigeration_system_lineup'], search_criteria)
    if props_lineup.nil?
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "No refrigeration system lineup found for #{search_criteria}, no system will be added.")
      next
    end
    number_of_display_cases = props_lineup['number_of_display_cases']
    number_of_walkins = props_lineup['number_of_walkins']
    compressor_name = props_lineup['compressor_name']
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Refrigeration system lineup found for #{search_criteria}: #{number_of_display_cases} display cases and #{number_of_walkins} walkins, with compressor '#{compressor_name}'.")

    # Find the thermal zones most suited for holding the display cases
    thermal_zone_case = nil
    if number_of_display_cases > 0
      thermal_zone_case = model_typical_display_case_zone(model)
      if thermal_zone_case.nil?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "Attempted to add #{number_of_display_cases} display cases to the model, but could find no thermal zone to put them into.")
        return false
      end
    end

    # Add display cases
    display_cases = []
    (1..number_of_display_cases).each_with_index do |display_case_number, def_start_hr_iterator|
      case_type = props_lineup["case_type_#{display_case_number}"]

      # Add the basic case
      ref_case = model_add_refrigeration_case(model, thermal_zone_case, case_type, size_category)
      return false if ref_case.nil?

      # Scale based on floor area
      ref_case.setCaseLength(ref_case.caseLength * floor_area_scaling_factor)

      # Find defrost and dripdown properties
      search_criteria = {
        'template' => template,
        'case_type' => case_type,
        'size_category' => size_category
      }
      props_case = model_find_object(standards_data['refrigerated_cases'], search_criteria)
      if props_case.nil?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Could not find refrigerated case properties for: #{search_criteria}.")
        next
      end
      numb_defrosts_per_day = props_case['defrost_per_day']
      minutes_defrost = props_case['minutes_defrost']
      minutes_dripdown = props_case['minutes_dripdown']
      minutes_defrost = 59 if minutes_defrost > 59 # Just to make sure to remain in the same hour
      minutes_dripdown = 59 if minutes_dripdown > 59 # Just to make sure to remain in the same hour

      # Add defrost and dripdown schedules
      defrost_sch = OpenStudio::Model::ScheduleRuleset.new(model)
      defrost_sch.setName('Refrigeration Defrost Schedule')
      defrost_sch.defaultDaySchedule.setName("Refrigeration Defrost Schedule Default - #{case_type}")
      dripdown_sch = OpenStudio::Model::ScheduleRuleset.new(model)
      dripdown_sch.setName('Refrigeration Dripdown Schedule')
      dripdown_sch.defaultDaySchedule.setName("Refrigeration Dripdown Schedule Default - #{case_type}")

      # Stagger the defrosts for cases by 1 hr
      interval_defrost = (24 / numb_defrosts_per_day).floor # Hour interval between each defrost period
      if (def_start_hr_iterator + interval_defrost * numb_defrosts_per_day) > 23
        first_def_start_hr = 0 # Start over again at midnight when time reaches 23hrs
      else
        first_def_start_hr = def_start_hr_iterator
      end

      # Add the specified number of defrost periods to the daily schedule
      (1..numb_defrosts_per_day).each do |defrost_of_day|
        def_start_hr = first_def_start_hr + ((1 - defrost_of_day) * interval_defrost)
        defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, def_start_hr, 0, 0), 0)
        defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, def_start_hr, minutes_defrost.to_int, 0), 0)
        dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, def_start_hr, 0, 0), 0) # Dripdown is synced with defrost
        dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, def_start_hr, minutes_dripdown.to_int, 0), 0)
      end
      defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
      dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)

      # Assign the defrost and dripdown schedules
      ref_case.setCaseDefrostSchedule(defrost_sch)
      ref_case.setCaseDefrostDripDownSchedule(dripdown_sch)

      display_cases << ref_case
    end

    # Find the thermal zones most suited for holding the walkins
    thermal_zone_walkin = nil
    if number_of_walkins > 0
      thermal_zone_walkin = model_typical_walkin_zone(model)
      if thermal_zone_walkin.nil?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "Attempted to add #{number_of_walkins} walkins to the model, but could find no thermal zone to put them into.")
        return false
      end
    end

    # Add walkin cases
    walkins = []
    (1..number_of_walkins).each_with_index do |walkin_number, def_start_hr_iterator|
      walkin_type = props_lineup["walkin_type_#{walkin_number}"]

      # Add the basic walkin
      ref_walkin = model_add_refrigeration_walkin(model, thermal_zone_walkin, size_category, walkin_type)
      return false if ref_walkin.nil?

      # Scale based on floor area
      ref_walkin.setRatedTotalLightingPower(ref_walkin.ratedTotalLightingPower * floor_area_scaling_factor)
      ref_walkin.setRatedCoolingCoilFanPower(ref_walkin.ratedCoolingCoilFanPower * floor_area_scaling_factor)
      ref_walkin.setDefrostPower(ref_walkin.defrostPower.get * floor_area_scaling_factor)
      ref_walkin.setRatedCoilCoolingCapacity(ref_walkin.ratedCoilCoolingCapacity * floor_area_scaling_factor)
      ref_walkin.setZoneBoundaryTotalInsulatedSurfaceAreaFacingZone(ref_walkin.zoneBoundaryTotalInsulatedSurfaceAreaFacingZone.get * floor_area_scaling_factor)
      ref_walkin.setInsulatedFloorSurfaceArea(ref_walkin.insulatedFloorSurfaceArea * floor_area_scaling_factor)

      # Check that walkin physically fits inside the thermal zone.
      # If not, remove the walkin and warn.
      walkin_floor_area_ft2 = OpenStudio.convert(ref_walkin.insulatedFloorSurfaceArea, 'm^2', 'ft^2').get.round
      walkin_zone_floor_area_ft2 = OpenStudio.convert(thermal_zone_walkin.floorArea, 'm^2', 'ft^2').get.round
      if walkin_floor_area_ft2 > walkin_zone_floor_area_ft2
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "Walkin #{ref_walkin.name} has an area of #{walkin_floor_area_ft2} ft^2, which is larger than the #{walkin_zone_floor_area_ft2} ft^2 zone.  Walkin will be kept in the model, but considered re-sizing the zone '#{thermal_zone_walkin.name}'.")
      end

      # Find defrost and dripdown properties
      search_criteria = {
        'template' => template,
        'walkin_type' => walkin_type,
        'size_category' => size_category
      }
      props_walkin = model_find_object(standards_data['refrigeration_walkins'], search_criteria)
      if props_walkin.nil?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Could not find walkin properties for: #{search_criteria}.")
        next
      end
      numb_defrosts_per_day = props_walkin['defrost_per_day']
      minutes_defrost = props_walkin['minutes_defrost']
      minutes_dripdown = props_walkin['minutes_dripdown']
      minutes_defrost = 59 if minutes_defrost > 59 # Just to make sure to remain in the same hour
      minutes_dripdown = 59 if minutes_dripdown > 59 # Just to make sure to remain in the same hour

      # Add defrost and dripdown schedules
      defrost_sch_walkin = OpenStudio::Model::ScheduleRuleset.new(model)
      defrost_sch_walkin.setName('Refrigeration Defrost Schedule')
      defrost_sch_walkin.defaultDaySchedule.setName("Refrigeration Defrost Schedule Default - #{walkin_type}")
      dripdown_sch_walkin = OpenStudio::Model::ScheduleRuleset.new(model)
      dripdown_sch_walkin.setName('Refrigeration Dripdown Schedule')
      dripdown_sch_walkin.defaultDaySchedule.setName("Refrigeration Dripdown Schedule Default - #{walkin_type}")

      # Stagger the defrosts for cases by 1 hr
      interval_defrost = (24 / numb_defrosts_per_day).floor # Hour interval between each defrost period
      if (def_start_hr_iterator + interval_defrost * numb_defrosts_per_day) > 23
        first_def_start_hr = 0 # Start over again at midnight when time reaches 23hrs
      else
        first_def_start_hr = def_start_hr_iterator
      end

      # Add the specified number of defrost periods to the daily schedule
      (1..numb_defrosts_per_day).each do |defrost_of_day|
        def_start_hr = first_def_start_hr + ((1 - defrost_of_day) * interval_defrost)
        defrost_sch_walkin.defaultDaySchedule.addValue(OpenStudio::Time.new(0, def_start_hr, 0, 0), 0)
        defrost_sch_walkin.defaultDaySchedule.addValue(OpenStudio::Time.new(0, def_start_hr, minutes_defrost.to_int, 0), 0)
        dripdown_sch_walkin.defaultDaySchedule.addValue(OpenStudio::Time.new(0, def_start_hr, 0, 0), 0) # Dripdown is synced with defrost
        dripdown_sch_walkin.defaultDaySchedule.addValue(OpenStudio::Time.new(0, def_start_hr, minutes_dripdown.to_int, 0), 0)
      end
      defrost_sch_walkin.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
      dripdown_sch_walkin.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)

      # Assign the defrost and dripdown schedules
      ref_walkin.setDefrostSchedule(defrost_sch_walkin)
      ref_walkin.setDefrostDripDownSchedule(dripdown_sch_walkin)

      walkins << ref_walkin
    end

    # Divide cases and walkins into one or more refrigeration systems depending on store type
    # For small stores and kitchens one system with one compressor and one condenser per case is employed.
    # For larger stores, multiple cases and walkins are served by a rack with multiple compressors.
    ref_system_lineups = []
    case system_type
    when '<35k ft2', 'Kitchen'
      # Put each case on its own system
      display_cases.each do |ref_case|
        ref_system_lineups << { 'ref_cases' => [ref_case], 'walkins' => [] }
      end
      # Put each walkin on its own system
      walkins.each do |walkin|
        ref_system_lineups << { 'ref_cases' => [], 'walkins' => [walkin] }
      end
    else
      # Put all cases and walkins on one system
      ref_system_lineups << { 'ref_cases' => display_cases, 'walkins' => walkins }
    end

    # Find refrigeration system properties
    search_criteria = {
      'template' => template,
      'building_type' => building_type,
      'size_category' => size_category,
      'system_type' => system_type
    }
    props_ref_system = model_find_object(standards_data['refrigeration_system'], search_criteria)
    if props_ref_system.nil?
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Could not find refrigeration system properties for: #{search_criteria}.")
      next
    end

    # Add refrigeration systems
    ref_system_lineups.each do |ref_system_lineup|
      # Skip if no cases or walkins are attached to the system
      next if ref_system_lineup['ref_cases'].empty? && ref_system_lineup['walkins'].empty?

      # Add refrigeration system
      ref_system = OpenStudio::Model::RefrigerationSystem.new(model)
      ref_system.setName(system_type)
      ref_system.setRefrigerationSystemWorkingFluidType(props_ref_system['refrigerant'])
      ref_system.setSuctionTemperatureControlType(props_ref_system['refrigerant'])

      # Sum the capacity required by all cases and walkins
      # and attach the cases and walkins to the system.
      rated_case_capacity_w = 0
      ref_system_lineup['ref_cases'].each do |ref_case|
        rated_case_capacity_w += ref_case.ratedTotalCoolingCapacityperUnitLength * ref_case.caseLength
        ref_system.addCase(ref_case)
      end
      ref_system_lineup['walkins'].each do |walkin|
        rated_case_capacity_w += walkin.ratedCoilCoolingCapacity
        ref_system.addWalkin(walkin)
      end

      # Find the compressor properties
      search_criteria = {
        'template' => template,
        'compressor_name' => compressor_name
      }
      props_compressor = model_find_object(standards_data['refrigeration_compressors'], search_criteria)
      if props_compressor.nil?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Could not find refrigeration compressor properties for: #{search_criteria}.")
        next
      end

      # Calculate the number of compressors required to meet the
      # combined rated capacity of all the cases
      # and add them to the system
      rated_compressor_capacity_btu_per_hr = props_compressor['rated_capacity']
      number_of_compressors = (rated_case_capacity_w / OpenStudio.convert(rated_compressor_capacity_btu_per_hr, 'Btu/h', 'W').get).ceil
      (1..number_of_compressors).each do |compressor_number|
        compressor = model_add_refrigeration_compressor(model, compressor_name)
        ref_system.addCompressor(compressor)
      end
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Added #{number_of_compressors} compressors, each with a capacity of #{rated_compressor_capacity_btu_per_hr.round} Btu/hr to serve #{OpenStudio.convert(rated_case_capacity_w, 'W', 'Btu/hr').get.round} Btu/hr of case and walkin load.")

      # Find the condenser properties
      search_criteria = {
        'template' => template,
        'building_type' => building_type,
        'system_type' => system_type,
        'size_category' => size_category
      }
      props_condenser = model_find_object(standards_data['refrigeration_condenser'], search_criteria)
      if props_condenser.nil?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Could not find refrigeration condenser properties for: #{search_criteria}.")
        next
      end

      # Heat rejection as a function of temperature
      heat_rejection_curve = OpenStudio::Model::CurveLinear.new(model)
      heat_rejection_curve.setName('Condenser Heat Rejection Function of Temperature')
      heat_rejection_curve.setCoefficient1Constant(0)
      heat_rejection_curve.setCoefficient2x(props_condenser['heatrejectioncurve_c1'])
      heat_rejection_curve.setMinimumValueofx(-50)
      heat_rejection_curve.setMaximumValueofx(50)

      # Add condenser
      condenser = OpenStudio::Model::RefrigerationCondenserAirCooled.new(model)
      condenser.setRatedEffectiveTotalHeatRejectionRateCurve(heat_rejection_curve)
      condenser.setRatedSubcoolingTemperatureDifference(OpenStudio.convert(props_condenser['subcool_t'], 'F', 'C').get)
      condenser.setMinimumFanAirFlowRatio(props_condenser['min_airflow'])
      condenser.setRatedFanPower(props_condenser['fan_power_per_q_rejected'].to_f * rated_case_capacity_w)
      condenser.setCondenserFanSpeedControlType(props_condenser['fan_speed_control'])
      ref_system.setRefrigerationCondenser(condenser)

      OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Added #{system_type} refrigeration system")
    end
  end

  return true
end

#model_add_typical_swh(model, water_heater_fuel: nil, pipe_insul_in: nil, circulating: nil) ⇒ Array

TODO:
  • add in losses from tank and pipe insulation, etc.

add typical swh demand and supply to model

Parameters:

  • water_heater_fuel (String) (defaults to: nil)

    water heater fuel. Valid choices are NaturalGas, Electricity, and HeatPump. If not supplied, a smart default will be determined based on building type.

  • pipe_insul_in (Double) (defaults to: nil)

    thickness of the pipe insulation, in inches.

  • circulating (String) (defaults to: nil)

    whether the (circulating, noncirculating, nil) nil is smart

Returns:

  • (Array)

    hot water loops



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.swh.rb', line 231

def model_add_typical_swh(model,
                          water_heater_fuel: nil,
                          pipe_insul_in: nil,
                          circulating: nil)
  # array of hot water loops
  swh_systems = []

  # hash of general water use equipment awaiting loop
  water_use_equipment_hash = {} # key is standards building type value is array of water use equipment

  # create space type hash (need num_units for MidriseApartment and RetailStripmall)
  space_type_hash = model_create_space_type_hash(model, trust_effective_num_spaces = false)

  # loop through space types adding demand side of swh
  model.getSpaceTypes.sort.each do |space_type|
    next unless space_type.standardsBuildingType.is_initialized
    next unless space_type_hash.key?(space_type) # this is used for space types without any floor area

    stds_bldg_type = space_type.standardsBuildingType.get

    # lookup space_type_properties
    space_type_properties = space_type_get_standards_data(space_type)
    peak_flow_rate_gal_per_hr_per_ft2 = space_type_properties['service_water_heating_peak_flow_per_area'].to_f
    peak_flow_rate_gal_per_hr = space_type_properties['service_water_heating_peak_flow_rate'].to_f
    swh_system_type = space_type_properties['service_water_heating_system_type']
    flow_rate_fraction_schedule = model_add_schedule(model, space_type_properties['service_water_heating_schedule'])
    service_water_temperature_f = space_type_properties['service_water_heating_target_temperature'].to_f
    service_water_temperature_c = OpenStudio.convert(service_water_temperature_f, 'F', 'C').get
    booster_water_temperature_f = space_type_properties['booster_water_heating_target_temperature'].to_f
    booster_water_temperature_c = OpenStudio.convert(booster_water_temperature_f, 'F', 'C').get
    booster_water_heater_fraction = space_type_properties['booster_water_heater_fraction'].to_f
    service_water_fraction_sensible = space_type_properties['service_water_heating_fraction_sensible']
    service_water_fraction_latent = space_type_properties['service_water_heating_fraction_latent']
    floor_area_m2 = space_type_hash[space_type][:floor_area]
    floor_area_ft2 = OpenStudio.convert(floor_area_m2, 'm^2', 'ft^2').get

    # next if no service water heating demand
    next unless peak_flow_rate_gal_per_hr_per_ft2 > 0.0 || peak_flow_rate_gal_per_hr > 0.0

    # If there is no SWH schedule specified, assume
    # that there should be no SWH consumption for this space type.
    unless flow_rate_fraction_schedule
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', "No service water heating schedule was specified for #{space_type.name}, an always off schedule will be used and no water will be used.")
      flow_rate_fraction_schedule = model.alwaysOffDiscreteSchedule
    end

    # Determine flow rate
    case swh_system_type
    when 'One Per Unit'
      water_heater_fuel = 'Electricity' if water_heater_fuel.nil?
      num_units = space_type_hash[space_type][:num_units].round # First try number of units
      num_units = space_type_hash[space_type][:effective_num_spaces].round if num_units.zero? # Fall back on number of spaces
      peak_flow_rate_gal_per_hr = num_units * peak_flow_rate_gal_per_hr
      peak_flow_rate_m3_per_s = OpenStudio.convert(peak_flow_rate_gal_per_hr, 'gal/hr', 'm^3/s').get
      use_name = "#{space_type.name} #{num_units} units"
    else
      # TODO: - add building type or sice specific logic or just assume Gas? (SmallOffice and Warehouse are only non unit prototypes with Electric heating)
      water_heater_fuel = 'NaturalGas' if water_heater_fuel.nil?
      num_units = 1
      peak_flow_rate_gal_per_hr = peak_flow_rate_gal_per_hr_per_ft2 * floor_area_ft2
      peak_flow_rate_m3_per_s = OpenStudio.convert(peak_flow_rate_gal_per_hr, 'gal/hr', 'm^3/s').get
      use_name = space_type.name.to_s
    end

    # Split flow rate between main and booster uses if specified
    booster_water_use_equip = nil
    if booster_water_heater_fraction > 0.0
      booster_peak_flow_rate_m3_per_s = peak_flow_rate_m3_per_s * booster_water_heater_fraction
      peak_flow_rate_m3_per_s -= booster_peak_flow_rate_m3_per_s

      # Add booster water heater equipment and connections
      booster_water_use_equip = model_add_swh_end_uses(model,
                                                       "Booster #{use_name}",
                                                       loop = nil,
                                                       booster_peak_flow_rate_m3_per_s,
                                                       flow_rate_fraction_schedule.name.get,
                                                       booster_water_temperature_c,
                                                       space_name = nil,
                                                       frac_sensible: service_water_fraction_sensible,
                                                       frac_latent: service_water_fraction_latent)
    end

    # Add water use equipment and connections
    water_use_equip = model_add_swh_end_uses(model,
                                             use_name,
                                             swh_loop = nil,
                                             peak_flow_rate_m3_per_s,
                                             flow_rate_fraction_schedule.name.get,
                                             service_water_temperature_c,
                                             space_name = nil,
                                             frac_sensible: service_water_fraction_sensible,
                                             frac_latent: service_water_fraction_latent)

    # Water heater sizing
    case swh_system_type
    when 'One Per Unit'
      water_heater_capacity_w = num_units * OpenStudio.convert(20.0, 'kBtu/hr', 'W').get
      water_heater_volume_m3 = num_units * OpenStudio.convert(50.0, 'gal', 'm^3').get
      num_water_heaters = num_units
    else
      water_use_equips = [water_use_equip]
      water_use_equips << booster_water_use_equip unless booster_water_use_equip.nil? # Include booster in sizing since flows will be preheated by main water heater
      water_heater_sizing = model_find_water_heater_capacity_volume_and_parasitic(model, water_use_equips)
      water_heater_capacity_w = water_heater_sizing[:water_heater_capacity]
      water_heater_volume_m3 = water_heater_sizing[:water_heater_volume]
      num_water_heaters = 1
    end

    # Add either a dedicated SWH loop or save to add to shared SWH loop
    case swh_system_type
    when 'Shared'

      # Store water use equip by building type to add to shared building hot water loop
      if water_use_equipment_hash.key?(stds_bldg_type)
        water_use_equipment_hash[stds_bldg_type] << water_use_equip
      else
        water_use_equipment_hash[stds_bldg_type] = [water_use_equip]
      end

    when 'One Per Unit', 'Dedicated'
      pipe_insul_in = 0.0 if pipe_insul_in.nil?

      # Add service water loop with water heater
      swh_loop = model_add_swh_loop(model,
                                    system_name = "#{space_type.name} Service Water Loop",
                                    water_heater_thermal_zone = nil,
                                    service_water_temperature_c,
                                    service_water_pump_head = 0.01,
                                    service_water_pump_motor_efficiency = 1.0,
                                    water_heater_capacity_w,
                                    water_heater_volume_m3,
                                    water_heater_fuel,
                                    parasitic_fuel_consumption_rate_w = 0,
                                    add_pipe_losses = true,
                                    floor_area_served = OpenStudio.convert(950, 'ft^2', 'm^2').get,
                                    number_of_stories = 1,
                                    pipe_insulation_thickness = OpenStudio.convert(pipe_insul_in, 'in', 'm').get,
                                    num_water_heaters)
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "In model_add_typical, num_water_heaters = #{num_water_heaters}")
      # Add loop to list
      swh_systems << swh_loop

      # Attach water use equipment to the loop
      swh_connection = water_use_equip.waterUseConnections
      swh_loop.addDemandBranchForComponent(swh_connection.get) if swh_connection.is_initialized

      # If a booster fraction is specified, some percentage of the water
      # is assumed to be heated beyond the normal temperature by a separate
      # booster water heater.  This booster water heater is fed by the
      # main water heater, so the booster is responsible for a smaller delta-T.
      if booster_water_heater_fraction > 0
        # find_water_heater_capacity_volume_and_parasitic
        booster_water_heater_sizing = model_find_water_heater_capacity_volume_and_parasitic(model,
                                                                                            [booster_water_use_equip],
                                                                                            htg_eff: 1.0,
                                                                                            inlet_temp_f: service_water_temperature_f,
                                                                                            target_temp_f: booster_water_temperature_f)

        # Add service water booster loop with water heater
        # Note that booster water heaters are always assumed to be electric resistance
        swh_booster_loop = model_add_swh_booster(model,
                                                 swh_loop,
                                                 booster_water_heater_sizing[:water_heater_capacity],
                                                 water_heater_volume_m3 = OpenStudio.convert(6, 'gal', 'm^3').get,
                                                 water_heater_fuel = 'Electricity',
                                                 booster_water_temperature_c,
                                                 parasitic_fuel_consumption_rate_w = 0.0,
                                                 booster_water_heater_thermal_zone = nil)

        # Rename the service water booster loop
        swh_booster_loop.setName("#{space_type.name} Service Water Booster Loop")

        # Attach booster water use equipment to the booster loop
        booster_swh_connection = booster_water_use_equip.waterUseConnections
        swh_booster_loop.addDemandBranchForComponent(booster_swh_connection.get) if booster_swh_connection.is_initialized
      end

    else
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "'#{swh_system_type}' is not a valid Service Water Heating System Type, cannot add SWH to #{space_type.name}.  Valid choices are One Per Unit, Dedicated, and Shared.")
    end
  end

  # get building floor area and effective number of stories
  bldg_floor_area_m2 = model.getBuilding.floorArea
  bldg_effective_num_stories_hash = model_effective_num_stories(model)
  bldg_effective_num_stories = bldg_effective_num_stories_hash[:below_grade] + bldg_effective_num_stories_hash[:above_grade]

  # add non-dedicated system(s) here. Separate systems for water use equipment from different building types
  water_use_equipment_hash.sort.each do |stds_bldg_type, water_use_equipment_array|
    # TODO: find the water use equipment with the highest temperature
    water_heater_temp_f = 140.0
    water_heater_temp_c = OpenStudio.convert(water_heater_temp_f, 'F', 'C').get

    # find pump values
    # Table A.2 in PrototypeModelEnhancements_2014_0.pdf shows 10ft on everything except SecondarySchool which has 11.4ft
    # TODO: Remove hard-coded building-type-based lookups for circulating vs. non-circulating SWH systems
    circulating_bldg_types = [
      # DOE building types
      'Office',
      'PrimarySchool',
      'Outpatient',
      'Hospital',
      'SmallHotel',
      'LargeHotel',
      'FullServiceRestaurant',
      'HighriseApartment',
      # DEER building types
      'Asm', # 'Assembly'
      'ECC', # 'Education - Community College'
      'EPr', # 'Education - Primary School'
      'ERC', # 'Education - Relocatable Classroom'
      'ESe', # 'Education - Secondary School'
      'EUn', # 'Education - University'
      'Gro', # 'Grocery'
      'Hsp', # 'Health/Medical - Hospital'
      'Htl', # 'Lodging - Hotel'
      'MBT', # 'Manufacturing Biotech'
      'MFm', # 'Residential Multi-family'
      'Mtl', # 'Lodging - Motel'
      'Nrs', # 'Health/Medical - Nursing Home'
      'OfL', # 'Office - Large'
      # 'RFF', # 'Restaurant - Fast-Food'
      'RSD' # 'Restaurant - Sit-Down'
    ]
    if circulating_bldg_types.include?(stds_bldg_type)
      service_water_pump_head_pa = OpenStudio.convert(10.0, 'ftH_{2}O', 'Pa').get
      service_water_pump_motor_efficiency = 0.3
      circulating = true if circulating.nil?
      pipe_insul_in = 0.5 if pipe_insul_in.nil?
    else # values for non-circulating pump
      service_water_pump_head_pa = 0.01
      service_water_pump_motor_efficiency = 1.0
      circulating = false if circulating.nil?
      pipe_insul_in = 0.0 if pipe_insul_in.nil?
    end

    bldg_type_floor_area_m2 = 0.0
    space_type_hash.sort.each do |space_type, space_type_props|
      bldg_type_floor_area_m2 += space_type_props[:floor_area] if space_type_props[:stds_bldg_type] == stds_bldg_type
    end

    # Calculate the number of stories covered by this building type
    num_stories = bldg_effective_num_stories * (bldg_type_floor_area_m2 / bldg_floor_area_m2)

    # Water heater sizing
    water_heater_sizing = model_find_water_heater_capacity_volume_and_parasitic(model, water_use_equipment_array)
    water_heater_capacity_w = water_heater_sizing[:water_heater_capacity]
    water_heater_volume_m3 = water_heater_sizing[:water_heater_volume]

    # Add a shared service water heating loop with water heater
    shared_swh_loop = model_add_swh_loop(model,
                                         "#{stds_bldg_type} Shared Service Water Loop",
                                         water_heater_thermal_zone = nil,
                                         water_heater_temp_c,
                                         service_water_pump_head_pa,
                                         service_water_pump_motor_efficiency,
                                         water_heater_capacity_w,
                                         water_heater_volume_m3,
                                         water_heater_fuel,
                                         parasitic_fuel_consumption_rate_w = 0,
                                         add_pipe_losses = true,
                                         floor_area_served = bldg_type_floor_area_m2,
                                         number_of_stories = num_stories,
                                         pipe_insulation_thickness = OpenStudio.convert(pipe_insul_in, 'in', 'm').get)

    # Attach all water use equipment to the shared loop
    water_use_equipment_array.sort.each do |water_use_equip|
      swh_connection = water_use_equip.waterUseConnections
      shared_swh_loop.addDemandBranchForComponent(swh_connection.get) if swh_connection.is_initialized
    end

    # add to list of systems
    swh_systems << shared_swh_loop

    OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Adding shared water heating loop for #{stds_bldg_type}.")
  end

  return swh_systems
end

#model_add_unitheater(model, thermal_zones, hvac_op_sch: nil, fan_control_type: 'ConstantVolume', fan_pressure_rise: 0.2, heating_type: nil, hot_water_loop: nil, rated_inlet_water_temperature: 180.0, rated_outlet_water_temperature: 160.0, rated_inlet_air_temperature: 60.0, rated_outlet_air_temperature: 104.0) ⇒ Array<OpenStudio::Model::ZoneHVACUnitHeater>

Creates a unit heater for each zone and adds it to the model.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule or nil in which case will be defaulted to always on

  • fan_control_type (String) (defaults to: 'ConstantVolume')

    valid choices are OnOff, ConstantVolume, VariableVolume

  • fan_pressure_rise (Double) (defaults to: 0.2)

    fan pressure rise, inH2O

  • heating_type (String) (defaults to: nil)

    valid choices are NaturalGas, Gas, Electricity, Electric, DistrictHeating

  • hot_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    hot water loop to connect to the heating coil

  • rated_inlet_water_temperature (Double) (defaults to: 180.0)

    rated inlet water temperature in degrees Fahrenheit, default is 180F

  • rated_outlet_water_temperature (Double) (defaults to: 160.0)

    rated outlet water temperature in degrees Fahrenheit, default is 160F

  • rated_inlet_air_temperature (Double) (defaults to: 60.0)

    rated inlet air temperature in degrees Fahrenheit, default is 60F

  • rated_outlet_air_temperature (Double) (defaults to: 104.0)

    rated outlet air temperature in degrees Fahrenheit, default is 100F

Returns:



3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 3884

def model_add_unitheater(model,
                         thermal_zones,
                         hvac_op_sch: nil,
                         fan_control_type: 'ConstantVolume',
                         fan_pressure_rise: 0.2,
                         heating_type: nil,
                         hot_water_loop: nil,
                         rated_inlet_water_temperature: 180.0,
                         rated_outlet_water_temperature: 160.0,
                         rated_inlet_air_temperature: 60.0,
                         rated_outlet_air_temperature: 104.0)

  # hvac operation schedule
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # set defaults if nil
  fan_control_type = 'ConstantVolume' if fan_control_type.nil?
  fan_pressure_rise = 0.2 if fan_pressure_rise.nil?

  # default design temperatures used across all air loops
  dsgn_temps = standard_design_sizing_temperatures

  # adjusted zone design heating temperature for unit heater
  dsgn_temps['zn_htg_dsgn_sup_air_temp_f'] = 122.0
  dsgn_temps['zn_htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_htg_dsgn_sup_air_temp_f'], 'F', 'C').get

  # make a unit heater for each zone
  unit_heaters = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding unit heater for #{zone.name}.")

    # zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])

    # add fan
    fan = create_fan_by_name(model,
                             'Unit_Heater_Fan',
                             fan_name: "#{zone.name} UnitHeater Fan",
                             pressure_rise: fan_pressure_rise)
    fan.setAvailabilitySchedule(hvac_op_sch)

    # add heating coil
    if heating_type == 'NaturalGas' || heating_type == 'Gas'
      htg_coil = create_coil_heating_gas(model,
                                         name: "#{zone.name} UnitHeater Gas Htg Coil",
                                         schedule: hvac_op_sch)
    elsif heating_type == 'Electricity' || heating_type == 'Electric'
      htg_coil = create_coil_heating_electric(model,
                                              name: "#{zone.name} UnitHeater Electric Htg Coil",
                                              schedule: hvac_op_sch)
    elsif heating_type == 'DistrictHeating' && !hot_water_loop.nil?
      # control temperature for hot water loop
      if rated_inlet_water_temperature.nil?
        rated_inlet_water_temperature_c = OpenStudio.convert(180.0, 'F', 'C').get
      else
        rated_inlet_water_temperature_c = OpenStudio.convert(rated_inlet_water_temperature, 'F', 'C').get
      end
      if rated_outlet_water_temperature.nil?
        rated_outlet_water_temperature_c = OpenStudio.convert(160.0, 'F', 'C').get
      else
        rated_outlet_water_temperature_c = OpenStudio.convert(rated_outlet_water_temperature, 'F', 'C').get
      end
      if rated_inlet_air_temperature.nil?
        rated_inlet_air_temperature_c = OpenStudio.convert(60.0, 'F', 'C').get
      else
        rated_inlet_air_temperature_c = OpenStudio.convert(rated_inlet_air_temperature, 'F', 'C').get
      end
      if rated_outlet_air_temperature.nil?
        rated_outlet_air_temperature_c = OpenStudio.convert(104.0, 'F', 'C').get
      else
        rated_outlet_air_temperature_c = OpenStudio.convert(rated_outlet_air_temperature, 'F', 'C').get
      end
      htg_coil = create_coil_heating_water(model,
                                           hot_water_loop,
                                           name: "#{zone.name} UnitHeater Water Htg Coil",
                                           rated_inlet_water_temperature: rated_inlet_water_temperature_c,
                                           rated_outlet_water_temperature: rated_outlet_water_temperature_c,
                                           rated_inlet_air_temperature: rated_inlet_air_temperature_c,
                                           rated_outlet_air_temperature: rated_outlet_air_temperature_c)
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', 'No heating type was found when adding unit heater; no unit heater will be created.')
      return false
    end

    # create unit heater
    unit_heater = OpenStudio::Model::ZoneHVACUnitHeater.new(model,
                                                            hvac_op_sch,
                                                            fan,
                                                            htg_coil)
    unit_heater.setName("#{zone.name} Unit Heater")
    unit_heater.setFanControlType(fan_control_type)
    unit_heater.addToThermalZone(zone)
    unit_heaters << unit_heater
  end

  return unit_heaters
end

#model_add_vav_pfp_boxes(model, thermal_zones, system_name: nil, chilled_water_loop: nil, hvac_op_sch: nil, oa_damper_sch: nil, fan_efficiency: 0.62, fan_motor_efficiency: 0.9, fan_pressure_rise: 4.0) ⇒ OpenStudio::Model::AirLoopHVAC

Creates a VAV system with parallel fan powered boxes and adds it to the model.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • system_name (String) (defaults to: nil)

    the name of the system, or nil in which case it will be defaulted

  • chilled_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    chilled water loop to connect to the cooling coil

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule or nil in which case will be defaulted to always on

  • oa_damper_sch (String) (defaults to: nil)

    name of the oa damper schedule or nil in which case will be defaulted to always open

  • fan_efficiency (Double) (defaults to: 0.62)

    fan total efficiency, including motor and impeller

  • fan_motor_efficiency (Double) (defaults to: 0.9)

    fan motor efficiency

  • fan_pressure_rise (Double) (defaults to: 4.0)

    fan pressure rise, inH2O

Returns:



1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 1807

def model_add_vav_pfp_boxes(model,
                            thermal_zones,
                            system_name: nil,
                            chilled_water_loop: nil,
                            hvac_op_sch: nil,
                            oa_damper_sch: nil,
                            fan_efficiency: 0.62,
                            fan_motor_efficiency: 0.9,
                            fan_pressure_rise: 4.0)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding VAV with PFP Boxes and Reheat system for #{thermal_zones.size} zones.")

  # create air handler
  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  if system_name.nil?
    air_loop.setName("#{thermal_zones.size} Zone VAV with PFP Boxes and Reheat")
  else
    air_loop.setName(system_name)
  end

  # hvac operation schedule
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # oa damper schedule
  if oa_damper_sch.nil?
    oa_damper_sch = model.alwaysOnDiscreteSchedule
  else
    oa_damper_sch = model_add_schedule(model, oa_damper_sch)
  end

  # default design temperatures and settings used across all air loops
  dsgn_temps = standard_design_sizing_temperatures
  sizing_system = adjust_sizing_system(air_loop, dsgn_temps)

  # air handler controls
  sa_temp_sch = model_add_constant_schedule_ruleset(model,
                                                    dsgn_temps['clg_dsgn_sup_air_temp_c'],
                                                    name = "Supply Air Temp - #{dsgn_temps['clg_dsgn_sup_air_temp_f']}F")
  sa_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, sa_temp_sch)
  sa_stpt_manager.setName("#{air_loop.name} Supply Air Setpoint Manager")
  sa_stpt_manager.addToNode(air_loop.supplyOutletNode)

  # create fan
  # @type [OpenStudio::Model::FanVariableVolume] fan
  fan = create_fan_by_name(model,
                           'VAV_System_Fan',
                           fan_name: "#{air_loop.name} Fan",
                           fan_efficiency: fan_efficiency,
                           pressure_rise: fan_pressure_rise,
                           motor_efficiency: fan_motor_efficiency,
                           end_use_subcategory: 'VAV System Fans')
  fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  fan.addToNode(air_loop.supplyInletNode)

  # create heating coil
  create_coil_heating_electric(model,
                               air_loop_node: air_loop.supplyInletNode,
                               name: "#{air_loop.name} Htg Coil")

  # create cooling coil
  create_coil_cooling_water(model,
                            chilled_water_loop,
                            air_loop_node: air_loop.supplyInletNode,
                            name: "#{air_loop.name} Clg Coil")

  # create outdoor air intake system
  oa_intake_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
  oa_intake_controller.setName("#{air_loop.name} OA Controller")
  oa_intake_controller.setMinimumLimitType('FixedMinimum')
  oa_intake_controller.autosizeMinimumOutdoorAirFlowRate
  oa_intake_controller.resetEconomizerMinimumLimitDryBulbTemperature
  # oa_intake_controller.setMinimumOutdoorAirSchedule(oa_damper_sch)
  controller_mv = oa_intake_controller.controllerMechanicalVentilation
  controller_mv.setName("#{air_loop.name} Vent Controller")
  controller_mv.setSystemOutdoorAirMethod('ZoneSum')
  oa_intake = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
  oa_intake.setName("#{air_loop.name} OA System")
  oa_intake.addToNode(air_loop.supplyInletNode)

  # set air loop availability controls and night cycle manager, after oa system added
  air_loop.setAvailabilitySchedule(hvac_op_sch)
  air_loop.setNightCycleControlType('CycleOnAny')

  # attach the VAV system to each zone
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding VAV with PFP Boxes and Reheat system terminal for #{zone.name}.")

    # create reheat coil
    rht_coil = create_coil_heating_electric(model,
                                            name: "#{zone.name} Electric Reheat Coil")

    # create terminal fan
    # @type [OpenStudio::Model::FanConstantVolume] pfp_fan
    pfp_fan = create_fan_by_name(model,
                                 'PFP_Fan',
                                 fan_name: "#{zone.name} PFP Term Fan")
    pfp_fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)

    # create parallel fan powered terminal
    pfp_terminal = OpenStudio::Model::AirTerminalSingleDuctParallelPIUReheat.new(model,
                                                                                 model.alwaysOnDiscreteSchedule,
                                                                                 pfp_fan,
                                                                                 rht_coil)
    pfp_terminal.setName("#{zone.name} PFP Term")
    air_loop.multiAddBranchForZone(zone, pfp_terminal.to_HVACComponent.get)

    # zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setCoolingDesignAirFlowMethod('DesignDay')
    sizing_zone.setHeatingDesignAirFlowMethod('DesignDay')
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
  end

  return air_loop
end

#model_add_vav_reheat(model, thermal_zones, system_name: nil, return_plenum: nil, heating_type: nil, reheat_type: nil, hot_water_loop: nil, chilled_water_loop: nil, hvac_op_sch: nil, oa_damper_sch: nil, fan_efficiency: 0.62, fan_motor_efficiency: 0.9, fan_pressure_rise: 4.0, min_sys_airflow_ratio: 0.3, vav_sizing_option: 'Coincident', econo_ctrl_mthd: nil) ⇒ OpenStudio::Model::AirLoopHVAC

Creates a VAV system and adds it to the model.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to connect to this system

  • system_name (String) (defaults to: nil)

    the name of the system, or nil in which case it will be defaulted

  • return_plenum (OpenStudio::Model::ThermalZone) (defaults to: nil)

    the zone to attach as the supply plenum, or nil, in which case no return plenum will be used

  • heating_type (String) (defaults to: nil)

    main heating coil fuel type valid choices are NaturalGas, Gas, Electricity, HeatPump, DistrictHeating, or nil (defaults to NaturalGas)

  • reheat_type (String) (defaults to: nil)

    valid options are NaturalGas, Gas, Electricity, Water, nil (no heat)

  • hot_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    hot water loop to connect heating and reheat coils to

  • chilled_water_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    chilled water loop to connect cooling coil to

  • hvac_op_sch (String) (defaults to: nil)

    name of the HVAC operation schedule or nil in which case will be defaulted to always on

  • oa_damper_sch (String) (defaults to: nil)

    name of the oa damper schedule, or nil in which case will be defaulted to always open

  • fan_efficiency (Double) (defaults to: 0.62)

    fan total efficiency, including motor and impeller

  • fan_motor_efficiency (Double) (defaults to: 0.9)

    fan motor efficiency

  • fan_pressure_rise (Double) (defaults to: 4.0)

    fan pressure rise, inH2O

  • min_sys_airflow_ratio (Double) (defaults to: 0.3)

    minimum system airflow ratio

  • vav_sizing_option (String) (defaults to: 'Coincident')

    air system sizing option, Coincident or NonCoincident

  • econo_ctrl_mthd (String) (defaults to: nil)

    economizer control type

Returns:



1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 1575

def model_add_vav_reheat(model,
                         thermal_zones,
                         system_name: nil,
                         return_plenum: nil,
                         heating_type: nil,
                         reheat_type: nil,
                         hot_water_loop: nil,
                         chilled_water_loop: nil,
                         hvac_op_sch: nil,
                         oa_damper_sch: nil,
                         fan_efficiency: 0.62,
                         fan_motor_efficiency: 0.9,
                         fan_pressure_rise: 4.0,
                         min_sys_airflow_ratio: 0.3,
                         vav_sizing_option: 'Coincident',
                         econo_ctrl_mthd: nil)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding VAV system for #{thermal_zones.size} zones.")

  # create air handler
  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  if system_name.nil?
    air_loop.setName("#{thermal_zones.size} Zone VAV")
  else
    air_loop.setName(system_name)
  end

  # hvac operation schedule
  if hvac_op_sch.nil?
    hvac_op_sch = model.alwaysOnDiscreteSchedule
  else
    hvac_op_sch = model_add_schedule(model, hvac_op_sch)
  end

  # oa damper schedule
  unless oa_damper_sch.nil?
    oa_damper_sch = model_add_schedule(model, oa_damper_sch)
  end

  # default design temperatures and settings used across all air loops
  dsgn_temps = standard_design_sizing_temperatures
  sizing_system = adjust_sizing_system(air_loop, dsgn_temps)
  if !min_sys_airflow_ratio.nil?
    if model.version < OpenStudio::VersionString.new('2.7.0')
      sizing_system.setMinimumSystemAirFlowRatio(min_sys_airflow_ratio)
    else
      sizing_system.setCentralHeatingMaximumSystemAirFlowRatio(min_sys_airflow_ratio)
    end
  end
  sizing_system.setSizingOption(vav_sizing_option) unless vav_sizing_option.nil?
  unless hot_water_loop.nil?
    hw_temp_c = hot_water_loop.sizingPlant.designLoopExitTemperature
    hw_delta_t_k = hot_water_loop.sizingPlant.loopDesignTemperatureDifference
  end

  # air handler controls
  sa_temp_sch = model_add_constant_schedule_ruleset(model,
                                                    dsgn_temps['clg_dsgn_sup_air_temp_c'],
                                                    name = "Supply Air Temp - #{dsgn_temps['clg_dsgn_sup_air_temp_f']}F")
  sa_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, sa_temp_sch)
  sa_stpt_manager.setName("#{air_loop.name} Supply Air Setpoint Manager")
  sa_stpt_manager.addToNode(air_loop.supplyOutletNode)

  # create fan
  # @type [OpenStudio::Model::FanVariableVolume] fan
  fan = create_fan_by_name(model,
                           'VAV_System_Fan',
                           fan_name: "#{air_loop.name} Fan",
                           fan_efficiency: fan_efficiency,
                           pressure_rise: fan_pressure_rise,
                           motor_efficiency: fan_motor_efficiency,
                           end_use_subcategory: 'VAV System Fans')
  fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  fan.addToNode(air_loop.supplyInletNode)

  # create heating coil
  if hot_water_loop.nil?
    if heating_type == 'Electricity'
      create_coil_heating_electric(model,
                                   air_loop_node: air_loop.supplyInletNode,
                                   name: "#{air_loop.name} Main Electric Htg Coil")
    else # default to NaturalGas
      create_coil_heating_gas(model,
                              air_loop_node: air_loop.supplyInletNode,
                              name: "#{air_loop.name} Main Gas Htg Coil")
    end
  else
    create_coil_heating_water(model,
                              hot_water_loop,
                              air_loop_node: air_loop.supplyInletNode,
                              name: "#{air_loop.name} Main Htg Coil",
                              rated_inlet_water_temperature: hw_temp_c,
                              rated_outlet_water_temperature: (hw_temp_c - hw_delta_t_k),
                              rated_inlet_air_temperature: dsgn_temps['prehtg_dsgn_sup_air_temp_c'],
                              rated_outlet_air_temperature: dsgn_temps['htg_dsgn_sup_air_temp_c'])
  end

  # create cooling coil
  if chilled_water_loop.nil?
    create_coil_cooling_dx_two_speed(model,
                                     air_loop_node: air_loop.supplyInletNode,
                                     name: "#{air_loop.name} 2spd DX Clg Coil",
                                     type: 'OS default')
  else
    create_coil_cooling_water(model,
                              chilled_water_loop,
                              air_loop_node: air_loop.supplyInletNode,
                              name: "#{air_loop.name} Clg Coil")
  end

  # outdoor air intake system
  oa_intake_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
  oa_intake_controller.setName("#{air_loop.name} OA Controller")
  oa_intake_controller.setMinimumLimitType('FixedMinimum')
  oa_intake_controller.autosizeMinimumOutdoorAirFlowRate
  oa_intake_controller.resetMaximumFractionofOutdoorAirSchedule
  oa_intake_controller.resetEconomizerMinimumLimitDryBulbTemperature
  unless econo_ctrl_mthd.nil?
    oa_intake_controller.setEconomizerControlType(econo_ctrl_mthd)
  end
  unless oa_damper_sch.nil?
    oa_intake_controller.setMinimumOutdoorAirSchedule(oa_damper_sch)
  end
  controller_mv = oa_intake_controller.controllerMechanicalVentilation
  controller_mv.setName("#{air_loop.name} Vent Controller")
  controller_mv.setSystemOutdoorAirMethod('ZoneSum')
  oa_intake = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
  oa_intake.setName("#{air_loop.name} OA System")
  oa_intake.addToNode(air_loop.supplyInletNode)

  # set air loop availability controls and night cycle manager, after oa system added
  air_loop.setAvailabilitySchedule(hvac_op_sch)
  air_loop.setNightCycleControlType('CycleOnAny')
  avail_mgr = air_loop.availabilityManager
  if avail_mgr.is_initialized
    avail_mgr = avail_mgr.get
    if avail_mgr.to_AvailabilityManagerNightCycle.is_initialized
      avail_mgr = avail_mgr.to_AvailabilityManagerNightCycle.get
      avail_mgr.setCyclingRunTime(1800)
    end
  end

  # hook the VAV system to each zone
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "Adding VAV system terminal for #{zone.name}")

    # create reheat coil
    case reheat_type
    when 'NaturalGas', 'Gas'
      rht_coil = create_coil_heating_gas(model,
                                         name: "#{zone.name} Gas Reheat Coil")
    when 'Electricity'
      rht_coil = create_coil_heating_electric(model,
                                              name: "#{zone.name} Electric Reheat Coil")
    when 'Water'
      rht_coil = create_coil_heating_water(model,
                                           hot_water_loop,
                                           name: "#{zone.name} Reheat Coil",
                                           rated_inlet_water_temperature: hw_temp_c,
                                           rated_outlet_water_temperature: (hw_temp_c - hw_delta_t_k),
                                           rated_inlet_air_temperature: dsgn_temps['htg_dsgn_sup_air_temp_c'],
                                           rated_outlet_air_temperature: dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    else
      # no reheat
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "No reheat coil for terminal in #{zone.name}")
    end

    # set zone reheat temperatures depending on reheat
    case reheat_type
    when 'NaturalGas', 'Gas', 'Electricity', 'Water'
      # create vav terminal
      terminal = OpenStudio::Model::AirTerminalSingleDuctVAVReheat.new(model, model.alwaysOnDiscreteSchedule, rht_coil)
      terminal.setName("#{zone.name} VAV Terminal")
      if model.version < OpenStudio::VersionString.new('3.0.1')
        terminal.setZoneMinimumAirFlowMethod('Constant')
      else
        terminal.setZoneMinimumAirFlowInputMethod('Constant')
      end
      terminal.setMaximumFlowFractionDuringReheat(0.5)
      terminal.setMaximumReheatAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
      air_loop.multiAddBranchForZone(zone, terminal.to_HVACComponent.get)
      air_terminal_single_duct_vav_reheat_apply_initial_prototype_damper_position(terminal, thermal_zone_outdoor_airflow_rate_per_area(zone))

      # zone sizing
      sizing_zone = zone.sizingZone
      sizing_zone.setCoolingDesignAirFlowMethod('DesignDayWithLimit')
      sizing_zone.setHeatingDesignAirFlowMethod('DesignDay')
      sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
      sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])
    else
      # no reheat
      # create vav terminal
      terminal = OpenStudio::Model::AirTerminalSingleDuctVAVNoReheat.new(model, model.alwaysOnDiscreteSchedule)
      terminal.setName("#{zone.name} VAV Terminal")
      if model.version < OpenStudio::VersionString.new('3.0.1')
        terminal.setZoneMinimumAirFlowMethod('Constant')
      else
        terminal.setZoneMinimumAirFlowInputMethod('Constant')
      end
      air_loop.multiAddBranchForZone(zone, terminal.to_HVACComponent.get)
      air_terminal_single_duct_vav_reheat_apply_initial_prototype_damper_position(terminal, thermal_zone_outdoor_airflow_rate_per_area(zone))

      # zone sizing
      sizing_zone = zone.sizingZone
      sizing_zone.setCoolingDesignAirFlowMethod('DesignDayWithLimit')
      sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    end

    unless return_plenum.nil?
      zone.setReturnPlenum(return_plenum)
    end
  end

  # Design outdoor air calculation based on VRP if applicable (prototypes maintained by PNNL)
  model_system_outdoor_air_sizing_vrp_method(air_loop)

  # set the damper action based on the template
  air_loop_hvac_apply_vav_damper_action(air_loop)

  return air_loop
end

#model_add_vrf(model, thermal_zones, ventilation: false) ⇒ Array<OpenStudio::Model::ZoneHVACTerminalUnitVariableRefrigerantFlow>

Adds Variable Refrigerant Flow system and terminal units for each zone

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to add fan coil units

  • ventilation (Bool) (defaults to: false)

    If true, ventilation will be supplied through the unit. If false, no ventilation will be supplied through the unit, with the expectation that it will be provided by a DOAS or separate system.

Returns:



4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4239

def model_add_vrf(model,
                  thermal_zones,
                  ventilation: false)

  # create vrf outdoor unit
  master_zone = thermal_zones[0]
  vrf_outdoor_unit = create_air_conditioner_variable_refrigerant_flow(model,
                                                                      name: "#{thermal_zones.size} Zone VRF System",
                                                                      master_zone: master_zone)

  # default design temperatures used across all air loops
  dsgn_temps = standard_design_sizing_temperatures

  vrfs = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding vrf unit for #{zone.name}.")

    # zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(dsgn_temps['zn_clg_dsgn_sup_air_temp_c'])
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(dsgn_temps['zn_htg_dsgn_sup_air_temp_c'])

    # add vrf terminal unit
    vrf_terminal_unit = OpenStudio::Model::ZoneHVACTerminalUnitVariableRefrigerantFlow.new(model)
    vrf_terminal_unit.setName("#{zone.name} VRF Terminal Unit")
    vrf_terminal_unit.addToThermalZone(zone)
    vrf_terminal_unit.setTerminalUnitAvailabilityschedule(model.alwaysOnDiscreteSchedule)

    unless ventilation
      vrf_terminal_unit.setOutdoorAirFlowRateDuringCoolingOperation(0.0)
      vrf_terminal_unit.setOutdoorAirFlowRateDuringHeatingOperation(0.0)
      vrf_terminal_unit.setOutdoorAirFlowRateWhenNoCoolingorHeatingisNeeded(0.0)
    end

    # set fan variables
    # always off denotes cycling fan
    vrf_terminal_unit.setSupplyAirFanOperatingModeSchedule(model.alwaysOffDiscreteSchedule)
    vrf_fan = vrf_terminal_unit.supplyAirFan.to_FanOnOff.get
    vrf_fan.setPressureRise(300.0)
    vrf_fan.setMotorEfficiency(0.8)
    vrf_fan.setFanEfficiency(0.6)
    vrf_fan.setName("#{zone.name} VRF Unit Cycling Fan")

    # add to main condensing unit
    vrf_outdoor_unit.addTerminal(vrf_terminal_unit)
  end

  return vrfs
end

#model_add_water_heater(model, water_heater_capacity, water_heater_volume, water_heater_fuel, service_water_temperature, parasitic_fuel_consumption_rate, swh_temp_sch, set_peak_use_flowrate, peak_flowrate, flowrate_schedule, water_heater_thermal_zone, number_water_heaters) ⇒ OpenStudio::Model::WaterHeaterMixed

Creates a water heater and attaches it to the supplied service water heating loop.

Used to modify efficiencies for water heaters based on individual component size while avoiding having to model lots of individual water heaters (for runtime sake).

Parameters:

  • water_heater_capacity (Double)

    water heater capacity, in W

  • water_heater_volume (Double)

    water heater volume, in m^3

  • water_heater_fuel (Double)

    valid choices are NaturalGas, Electricity

  • service_water_temperature (Double)

    water heater temperature, in C

  • parasitic_fuel_consumption_rate (Double)

    water heater parasitic fuel consumption rate, in W

  • swh_temp_sch (OpenStudio::Model::Schedule)

    the service water heating schedule. If nil, will be defaulted.

  • set_peak_use_flowrate (Bool)

    if true, the peak flow rate and flow rate schedule will be set.

  • peak_flowrate (Double)

    in m^3/s

  • flowrate_schedule (String)

    name of the flow rate schedule

  • water_heater_thermal_zone (OpenStudio::Model::ThermalZone)

    zone to place water heater in. If nil, will be assumed in 70F air for heat loss.

  • number_water_heaters (Double)

    the number of water heaters represented by the capacity and volume inputs.

Returns:



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.ServiceWaterHeating.rb', line 161

def model_add_water_heater(model,
                           water_heater_capacity,
                           water_heater_volume,
                           water_heater_fuel,
                           service_water_temperature,
                           parasitic_fuel_consumption_rate,
                           swh_temp_sch,
                           set_peak_use_flowrate,
                           peak_flowrate,
                           flowrate_schedule,
                           water_heater_thermal_zone,
                           number_water_heaters)
  # Water heater
  # TODO Standards - Change water heater methodology to follow
  # 'Model Enhancements Appendix A.'
  water_heater_capacity_btu_per_hr = OpenStudio.convert(water_heater_capacity, 'W', 'Btu/hr').get
  water_heater_capacity_kbtu_per_hr = OpenStudio.convert(water_heater_capacity_btu_per_hr, 'Btu/hr', 'kBtu/hr').get
  water_heater_vol_gal = OpenStudio.convert(water_heater_volume, 'm^3', 'gal').get

  # Temperature schedule type limits
  temp_sch_type_limits = model_add_schedule_type_limits(model,
                                                        name: 'Temperature Schedule Type Limits',
                                                        lower_limit_value: 0.0,
                                                        upper_limit_value: 100.0,
                                                        numeric_type: 'Continuous',
                                                        unit_type: 'Temperature')

  if swh_temp_sch.nil?
    # Service water heating loop controls
    swh_temp_c = service_water_temperature
    swh_temp_f = OpenStudio.convert(swh_temp_c, 'C', 'F').get
    swh_delta_t_r = 9 # 9F delta-T
    swh_temp_c = OpenStudio.convert(swh_temp_f, 'F', 'C').get
    swh_delta_t_k = OpenStudio.convert(swh_delta_t_r, 'R', 'K').get
    swh_temp_sch = model_add_constant_schedule_ruleset(model,
                                                       swh_temp_c,
                                                       name = "Service Water Loop Temp - #{swh_temp_f.round}F")
    swh_temp_sch.setScheduleTypeLimits(temp_sch_type_limits)
  end

  # Water heater depends on the fuel type
  water_heater = OpenStudio::Model::WaterHeaterMixed.new(model)

  # Assign a quantity to the water heater if it represents multiple water heaters
  if number_water_heaters > 1
    water_heater.setName("#{number_water_heaters}X #{(water_heater_vol_gal / number_water_heaters).round}gal #{water_heater_fuel} Water Heater - #{(water_heater_capacity_kbtu_per_hr / number_water_heaters).round}kBtu/hr")
    water_heater.set_component_quantity(number_water_heaters)
  else
    water_heater.setName("#{water_heater_vol_gal.round}gal #{water_heater_fuel} Water Heater - #{water_heater_capacity_kbtu_per_hr.round}kBtu/hr")
  end

  water_heater.setTankVolume(OpenStudio.convert(water_heater_vol_gal, 'gal', 'm^3').get)
  water_heater.setSetpointTemperatureSchedule(swh_temp_sch)
  water_heater.setDeadbandTemperatureDifference(2.0)

  if water_heater_thermal_zone.nil?
    # Assume the water heater is indoors at 70F or 72F
    case template
      when '90.1-2004', '90.1-2007', '90.1-2010', '90.1-2013', '90.1-2016', '90.1-2019'
        indoor_temp = 71.6
      else
        indoor_temp = 70.0
      end
    default_water_heater_ambient_temp_sch = model_add_constant_schedule_ruleset(model,
                                                                                OpenStudio.convert(indoor_temp, 'F', 'C').get,
                                                                                name = 'Water Heater Ambient Temp Schedule - ' + indoor_temp.to_s + 'f')
    default_water_heater_ambient_temp_sch.setScheduleTypeLimits(temp_sch_type_limits)
    water_heater.setAmbientTemperatureIndicator('Schedule')
    water_heater.setAmbientTemperatureSchedule(default_water_heater_ambient_temp_sch)
    water_heater.resetAmbientTemperatureThermalZone
  else
    water_heater.setAmbientTemperatureIndicator('ThermalZone')
    water_heater.setAmbientTemperatureThermalZone(water_heater_thermal_zone)
    water_heater.resetAmbientTemperatureSchedule
  end

  water_heater.setMaximumTemperatureLimit(service_water_temperature)
  water_heater.setDeadbandTemperatureDifference(OpenStudio.convert(3.6, 'R', 'K').get)
  water_heater.setHeaterControlType('Cycle')
  water_heater.setHeaterMaximumCapacity(OpenStudio.convert(water_heater_capacity_btu_per_hr, 'Btu/hr', 'W').get)
  water_heater.setOffCycleParasiticHeatFractiontoTank(0.8)
  water_heater.setIndirectWaterHeatingRecoveryTime(1.5) # 1.5hrs
  if water_heater_fuel == 'Electricity'
    water_heater.setHeaterFuelType('Electricity')
    water_heater.setHeaterThermalEfficiency(1.0)
    water_heater.setOffCycleParasiticFuelConsumptionRate(parasitic_fuel_consumption_rate)
    water_heater.setOnCycleParasiticFuelConsumptionRate(parasitic_fuel_consumption_rate)
    water_heater.setOffCycleParasiticFuelType('Electricity')
    water_heater.setOnCycleParasiticFuelType('Electricity')
    water_heater.setOffCycleLossCoefficienttoAmbientTemperature(1.053)
    water_heater.setOnCycleLossCoefficienttoAmbientTemperature(1.053)
  elsif water_heater_fuel == 'Natural Gas' || water_heater_fuel == 'NaturalGas'
    water_heater.setHeaterFuelType('Gas')
    water_heater.setHeaterThermalEfficiency(0.78)
    water_heater.setOffCycleParasiticFuelConsumptionRate(parasitic_fuel_consumption_rate)
    water_heater.setOnCycleParasiticFuelConsumptionRate(parasitic_fuel_consumption_rate)
    water_heater.setOffCycleParasiticFuelType('Gas')
    water_heater.setOnCycleParasiticFuelType('Gas')
    water_heater.setOffCycleLossCoefficienttoAmbientTemperature(6.0)
    water_heater.setOnCycleLossCoefficienttoAmbientTemperature(6.0)
  elsif water_heater_fuel == 'HeatPump'
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', 'Simple workaround to represent heat pump water heaters without incurring significant runtime penalty associated with using correct objects.')
    # Make a part-load efficiency modifier curve with a value above 1, which
    # is multiplied by the nominal efficiency of 100% to represent
    # the COP of a HPWH.
    # TODO could make this workaround better by using EMS
    # to modify this curve output in realtime based on
    # the OA temperature.
    hpwh_cop = 2.8
    eff_f_of_plr = OpenStudio::Model::CurveCubic.new(model)
    eff_f_of_plr.setName("HPWH_COP_#{hpwh_cop}")
    eff_f_of_plr.setCoefficient1Constant(hpwh_cop)
    eff_f_of_plr.setCoefficient2x(0.0)
    eff_f_of_plr.setCoefficient3xPOW2(0.0)
    eff_f_of_plr.setCoefficient4xPOW3(0.0)
    eff_f_of_plr.setMinimumValueofx(0.0)
    eff_f_of_plr.setMaximumValueofx(1.0)
    water_heater.setHeaterFuelType('Electricity')
    water_heater.setHeaterThermalEfficiency(1.0)
    water_heater.setPartLoadFactorCurve(eff_f_of_plr)
    water_heater.setOffCycleParasiticFuelConsumptionRate(parasitic_fuel_consumption_rate)
    water_heater.setOnCycleParasiticFuelConsumptionRate(parasitic_fuel_consumption_rate)
    water_heater.setOffCycleParasiticFuelType('Electricity')
    water_heater.setOnCycleParasiticFuelType('Electricity')
    water_heater.setOffCycleLossCoefficienttoAmbientTemperature(1.053)
    water_heater.setOnCycleLossCoefficienttoAmbientTemperature(1.053)
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "#{water_heater_fuel} is not a valid water heater fuel.  Valid choices are Electricity, NaturalGas, and HeatPump.")
  end

  if set_peak_use_flowrate
    rated_flow_rate_m3_per_s = peak_flowrate
    rated_flow_rate_gal_per_min = OpenStudio.convert(rated_flow_rate_m3_per_s, 'm^3/s', 'gal/min').get
    water_heater.setPeakUseFlowRate(rated_flow_rate_m3_per_s)

    schedule = model_add_schedule(model, flowrate_schedule)
    water_heater.setUseFlowRateFractionSchedule(schedule)
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Added water heater called #{water_heater.name}")

  return water_heater
end

#model_add_water_source_hp(model, thermal_zones, condenser_loop, ventilation: true) ⇒ Array<OpenStudio::Model::ZoneHVACWaterToAirHeatPump>

Adds zone level water-to-air heat pumps for each zone.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones served by heat pumps

  • condenser_loop (OpenStudio::Model::PlantLoop)

    the condenser loop for the heat pumps #

  • ventilation (Bool) (defaults to: true)

    if true, ventilation will be supplied through the unit. If false, no ventilation will be supplied through the unit, with the expectation that it will be provided by a DOAS or separate system.

Returns:



5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5052

def model_add_water_source_hp(model,
                              thermal_zones,
                              condenser_loop,
                              ventilation: true)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding zone water-to-air heat pump.')

  water_to_air_hp_systems = []
  thermal_zones.each do |zone|
    supplemental_htg_coil = create_coil_heating_electric(model,
                                                         name: "#{zone.name} Supplemental Htg Coil")
    htg_coil = create_coil_heating_water_to_air_heat_pump_equation_fit(model,
                                                                       condenser_loop,
                                                                       name: "#{zone.name} Water-to-Air HP Htg Coil")
    clg_coil = create_coil_cooling_water_to_air_heat_pump_equation_fit(model,
                                                                       condenser_loop,
                                                                       name: "#{zone.name} Water-to-Air HP Clg Coil")

    # add fan
    fan = create_fan_by_name(model,
                             'WSHP_Fan',
                             fan_name: "#{zone.name} WSHP Fan")
    fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)

    water_to_air_hp_system = OpenStudio::Model::ZoneHVACWaterToAirHeatPump.new(model,
                                                                               model.alwaysOnDiscreteSchedule,
                                                                               fan,
                                                                               htg_coil,
                                                                               clg_coil,
                                                                               supplemental_htg_coil)
    water_to_air_hp_system.setName("#{zone.name} WSHP")
    unless ventilation
      water_to_air_hp_system.setOutdoorAirFlowRateDuringHeatingOperation(0.0)
      water_to_air_hp_system.setOutdoorAirFlowRateDuringCoolingOperation(0.0)
      water_to_air_hp_system.setOutdoorAirFlowRateWhenNoCoolingorHeatingisNeeded(0.0)
    end
    water_to_air_hp_system.addToThermalZone(zone)

    water_to_air_hp_systems << water_to_air_hp_system
  end

  return water_to_air_hp_systems
end

#model_add_waterside_economizer(model, chilled_water_loop, condenser_water_loop, integrated: true) ⇒ Object

Adds a waterside economizer to the chilled water and condenser loop

Parameters:

  • integrated (Bool) (defaults to: true)

    when set to true, models an integrated waterside economizer Integrated: in series with chillers, can run simultaneously with chillers Non-Integrated: in parallel with chillers, chillers locked out during operation



5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5551

def model_add_waterside_economizer(model, chilled_water_loop, condenser_water_loop,
                                   integrated: true)

  # make a new heat exchanger
  heat_exchanger = OpenStudio::Model::HeatExchangerFluidToFluid.new(model)
  heat_exchanger.setHeatExchangeModelType('CounterFlow')
  # zero degree minimum necessary to allow both economizer and heat exchanger to operate in both integrated and non-integrated archetypes
  # possibly results from an EnergyPlus issue that didn't get resolved correctly https://github.com/NREL/EnergyPlus/issues/5626
  heat_exchanger.setMinimumTemperatureDifferencetoActivateHeatExchanger(OpenStudio.convert(0.0, 'R', 'K').get)
  heat_exchanger.setHeatTransferMeteringEndUseType('FreeCooling')
  heat_exchanger.setOperationMinimumTemperatureLimit(OpenStudio.convert(35.0, 'F', 'C').get)
  heat_exchanger.setOperationMaximumTemperatureLimit(OpenStudio.convert(72.0, 'F', 'C').get)
  heat_exchanger.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)

  # get the chillers on the chilled water loop
  chillers = chilled_water_loop.supplyComponents('OS:Chiller:Electric:EIR'.to_IddObjectType)

  if integrated
    if chillers.empty?
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "No chillers were found on #{chilled_water_loop.name}; only modeling waterside economizer")
    end

    # set methods for integrated heat exchanger
    heat_exchanger.setName('Integrated Waterside Economizer Heat Exchanger')
    heat_exchanger.setControlType('CoolingDifferentialOnOff')

    # add the heat exchanger to the chilled water loop upstream of the chiller
    heat_exchanger.addToNode(chilled_water_loop.supplyInletNode)

    # Copy the setpoint managers from the plant's supply outlet node to the chillers and HX outlets.
    # This is necessary so that the correct type of operation scheme will be created.
    # Without this, OS will create an uncontrolled operation scheme and the chillers will never run.
    chw_spms = chilled_water_loop.supplyOutletNode.setpointManagers
    objs = []
    chillers.each do |obj|
      objs << obj.to_ChillerElectricEIR.get
    end
    objs << heat_exchanger
    objs.each do |obj|
      outlet = obj.supplyOutletModelObject.get.to_Node.get
      chw_spms.each do |spm|
        new_spm = spm.clone.to_SetpointManager.get
        new_spm.addToNode(outlet)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Copied SPM #{spm.name} to the outlet of #{obj.name}.")
      end
    end
  else
    # non-integrated
    # if the heat exchanger can meet the entire load, the heat exchanger will run and the chiller is disabled.
    # In E+, only one chiller can be tied to a given heat exchanger, so if you have multiple chillers,
    # they will cannot be tied to a single heat exchanger without EMS.
    chiller = nil
    if chillers.empty?
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "No chillers were found on #{chilled_water_loop.name}; cannot add a non-integrated waterside economizer.")
      heat_exchanger.setControlType('CoolingSetpointOnOff')
    elsif chillers.size > 1
      chiller = chillers.min
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "More than one chiller was found on #{chilled_water_loop.name}.  EnergyPlus only allows a single chiller to be interlocked with the HX.  Chiller #{chiller.name} was selected.  Additional chillers will not be locked out during HX operation.")
    else # 1 chiller
      chiller = chillers[0]
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Chiller '#{chiller.name}' will be locked out during HX operation.")
    end
    chiller = chiller.to_ChillerElectricEIR.get

    # set methods for non-integrated heat exchanger
    heat_exchanger.setName('Non-Integrated Waterside Economizer Heat Exchanger')
    heat_exchanger.setControlType('CoolingSetpointOnOffWithComponentOverride')

    # add the heat exchanger to a supply side branch of the chilled water loop parallel with the chiller(s)
    chilled_water_loop.addSupplyBranchForComponent(heat_exchanger)

    # Copy the setpoint managers from the plant's supply outlet node to the HX outlet.
    # This is necessary so that the correct type of operation scheme will be created.
    # Without this, the HX will never run
    chw_spms = chilled_water_loop.supplyOutletNode.setpointManagers
    outlet = heat_exchanger.supplyOutletModelObject.get.to_Node.get
    chw_spms.each do |spm|
      new_spm = spm.clone.to_SetpointManager.get
      new_spm.addToNode(outlet)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Copied SPM #{spm.name} to the outlet of #{heat_exchanger.name}.")
    end

    # set the supply and demand inlet fields to interlock the heat exchanger with the chiller
    chiller_supply_inlet = chiller.supplyInletModelObject.get.to_Node.get
    heat_exchanger.setComponentOverrideLoopSupplySideInletNode(chiller_supply_inlet)
    chiller_demand_inlet = chiller.demandInletModelObject.get.to_Node.get
    heat_exchanger.setComponentOverrideLoopDemandSideInletNode(chiller_demand_inlet)

    # check if the chilled water pump is on a branch with the chiller.
    # if it is, move this pump before the splitter so that it can push water through either the chiller or the heat exchanger.
    pumps_on_branches = []
    # search for constant and variable speed pumps  between supply splitter and supply mixer.
    chilled_water_loop.supplyComponents(chilled_water_loop.supplySplitter, chilled_water_loop.supplyMixer).each do |supply_comp|
      if supply_comp.to_PumpConstantSpeed.is_initialized
        pumps_on_branches << supply_comp.to_PumpConstantSpeed.get
      elsif supply_comp.to_PumpVariableSpeed.is_initialized
        pumps_on_branches << supply_comp.to_PumpVariableSpeed.get
      end
    end
    # If only one pump is found, clone it, put the clone on the supply inlet node, and delete the original pump.
    # If multiple branch pumps, clone the first pump found, add it to the inlet of the heat exchanger, and warn user.
    if pumps_on_branches.size == 1
      pump = pumps_on_branches[0]
      pump_clone = pump.clone(model).to_StraightComponent.get
      pump_clone.addToNode(chilled_water_loop.supplyInletNode)
      pump.remove
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', 'Since you need a pump to move water through the HX, the pump serving the chiller was moved so that it can also serve the HX depending on the desired control sequence.')
    elsif pumps_on_branches.size > 1
      hx_inlet_node = heat_exchanger.inletModelObject.get.to_Node.get
      pump = pumps_on_branches[0]
      pump_clone = pump.clone(model).to_StraightComponent.get
      pump_clone.addToNode(hx_inlet_node)
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', 'Found 2 or more pumps on branches.  Since you need a pump to move water through the HX, the first pump encountered was copied and placed in series with the HX.  This pump might not be reasonable for this duty, please check.')
    end
  end

  # add heat exchanger to condenser water loop
  condenser_water_loop.addDemandBranchForComponent(heat_exchanger)

  # change setpoint manager on condenser water loop to allow waterside economizing
  dsgn_sup_wtr_temp_f = 42.0
  dsgn_sup_wtr_temp_c = OpenStudio.convert(dsgn_sup_wtr_temp_f, 'F', 'C').get
  condenser_water_loop.supplyOutletNode.setpointManagers.each do |spm|
    if spm.to_SetpointManagerFollowOutdoorAirTemperature.is_initialized
      spm = spm.to_SetpointManagerFollowOutdoorAirTemperature.get
      spm.setMinimumSetpointTemperature(dsgn_sup_wtr_temp_c)
    elsif spm.to_SetpointManagerScheduled.is_initialized
      spm = spm.to_SetpointManagerScheduled.get
      cw_temp_sch = model_add_constant_schedule_ruleset(model,
                                                        dsgn_sup_wtr_temp_c,
                                                        name = "#{chilled_water_loop.name} Temp - #{dsgn_sup_wtr_temp_f.round(0)}F")
      spm.setSchedule(cw_temp_sch)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Changing condenser water loop setpoint for '#{condenser_water_loop.name}' to '#{cw_temp_sch.name}' to account for the waterside economizer.")
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', "Condenser water loop '#{condenser_water_loop.name}' setpoint manager '#{spm.name}' is not a recognized setpoint manager type.  Cannot change to account for the waterside economizer.")
    end
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Added #{heat_exchanger.name} to condenser water loop #{condenser_water_loop.name} and chilled water loop #{chilled_water_loop.name} to enable waterside economizing.")

  return heat_exchanger
end

#model_add_window_ac(model, thermal_zones) ⇒ Array<OpenStudio::Model::ZoneHVACPackagedTerminalAirConditioner>

Parameters:

Returns:



4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4730

def model_add_window_ac(model,
                        thermal_zones)

  # Defaults
  eer = 8.5 # Btu/W-h
  cop = OpenStudio.convert(eer, 'Btu/h', 'W').get
  shr = 0.65 # The sensible heat ratio (ratio of the sensible portion of the load to the total load) at the nominal rated capacity
  # airflow_cfm_per_ton = 350.0 # cfm/ton

  acs = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding window AC for #{zone.name}.")

    clg_coil = create_coil_cooling_dx_single_speed(model,
                                                   name: "#{zone.name} Window AC Cooling Coil",
                                                   type: 'Window AC',
                                                   cop: cop)
    clg_coil.setRatedSensibleHeatRatio(shr)
    clg_coil.setRatedEvaporatorFanPowerPerVolumeFlowRate(OpenStudio::OptionalDouble.new(773.3))
    clg_coil.setEvaporativeCondenserEffectiveness(OpenStudio::OptionalDouble.new(0.9))
    clg_coil.setMaximumOutdoorDryBulbTemperatureForCrankcaseHeaterOperation(OpenStudio::OptionalDouble.new(10))
    clg_coil.setBasinHeaterSetpointTemperature(OpenStudio::OptionalDouble.new(2))

    fan = create_fan_by_name(model,
                             'Window_AC_Supply_Fan',
                             fan_name: "#{zone.name} Window AC Supply Fan",
                             end_use_subcategory: 'Window AC Fans')
    fan.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)

    htg_coil = create_coil_heating_electric(model,
                                            name: "#{zone.name} Window AC Always Off Htg Coil",
                                            schedule: model.alwaysOffDiscreteSchedule,
                                            nominal_capacity: 0)
    ptac = OpenStudio::Model::ZoneHVACPackagedTerminalAirConditioner.new(model,
                                                                         model.alwaysOnDiscreteSchedule,
                                                                         fan,
                                                                         htg_coil,
                                                                         clg_coil)
    ptac.setName("#{zone.name} Window AC")
    ptac.setSupplyAirFanOperatingModeSchedule(model.alwaysOffDiscreteSchedule)
    ptac.addToThermalZone(zone)
    acs << ptac
  end

  return acs
end

#model_add_zone_erv(model, thermal_zones) ⇒ Array<OpenStudio::Model::ZoneHVACEnergyRecoveryVentilator>

Adds zone level ERVs for each zone.

TODO: review the static pressure rise for the ERV

Parameters:

Returns:

  • (Array<OpenStudio::Model::ZoneHVACEnergyRecoveryVentilator>)

    an array of zone ERVs



5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5101

def model_add_zone_erv(model,
                       thermal_zones)
  ervs = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding ERV for #{zone.name}.")

    # Determine the OA requirement for this zone
    min_oa_flow_m3_per_s_per_m2 = thermal_zone_outdoor_airflow_rate_per_area(zone)
    supply_fan = create_fan_by_name(model,
                                    'ERV_Supply_Fan',
                                    fan_name: "#{zone.name} ERV Supply Fan")
    impeller_eff = fan_baseline_impeller_efficiency(supply_fan)
    fan_change_impeller_efficiency(supply_fan, impeller_eff)
    exhaust_fan = create_fan_by_name(model,
                                     'ERV_Supply_Fan',
                                     fan_name: "#{zone.name} ERV Exhaust Fan")
    fan_change_impeller_efficiency(exhaust_fan, impeller_eff)

    erv_controller = OpenStudio::Model::ZoneHVACEnergyRecoveryVentilatorController.new(model)
    erv_controller.setName("#{zone.name} ERV Controller")
    # erv_controller.setExhaustAirTemperatureLimit("NoExhaustAirTemperatureLimit")
    # erv_controller.setExhaustAirEnthalpyLimit("NoExhaustAirEnthalpyLimit")
    # erv_controller.setTimeofDayEconomizerFlowControlSchedule(self.alwaysOnDiscreteSchedule)
    # erv_controller.setHighHumidityControlFlag(false)

    heat_exchanger = OpenStudio::Model::HeatExchangerAirToAirSensibleAndLatent.new(model)
    heat_exchanger.setName("#{zone.name} ERV HX")
    heat_exchanger.setHeatExchangerType('Plate')
    heat_exchanger.setEconomizerLockout(false)
    heat_exchanger.setSupplyAirOutletTemperatureControl(false)
    heat_exchanger.setSensibleEffectivenessat100HeatingAirFlow(0.76)
    heat_exchanger.setSensibleEffectivenessat75HeatingAirFlow(0.81)
    heat_exchanger.setLatentEffectivenessat100HeatingAirFlow(0.68)
    heat_exchanger.setLatentEffectivenessat75HeatingAirFlow(0.73)
    heat_exchanger.setSensibleEffectivenessat100CoolingAirFlow(0.76)
    heat_exchanger.setSensibleEffectivenessat75CoolingAirFlow(0.81)
    heat_exchanger.setLatentEffectivenessat100CoolingAirFlow(0.68)
    heat_exchanger.setLatentEffectivenessat75CoolingAirFlow(0.73)

    zone_hvac = OpenStudio::Model::ZoneHVACEnergyRecoveryVentilator.new(model, heat_exchanger, supply_fan, exhaust_fan)
    zone_hvac.setName("#{zone.name} ERV")
    zone_hvac.setVentilationRateperUnitFloorArea(min_oa_flow_m3_per_s_per_m2)
    zone_hvac.setController(erv_controller)
    zone_hvac.addToThermalZone(zone)

    # ensure the ERV takes priority, so ventilation load is included when treated by other zonal systems
    # From EnergyPlus I/O reference:
    # "For situations where one or more equipment types has limited capacity or limited control capability, order the
    #  sequence so that the most controllable piece of equipment runs last. For example, with a dedicated outdoor air
    #  system (DOAS), the air terminal for the DOAS should be assigned Heating Sequence = 1 and Cooling Sequence = 1.
    #  Any other equipment should be assigned sequence 2 or higher so that it will see the net load after the DOAS air
    #  is added to the zone."
    zone.setCoolingPriority(zone_hvac.to_ModelObject.get, 1)
    zone.setHeatingPriority(zone_hvac.to_ModelObject.get, 1)

    # set the cooling and heating fraction to zero so that the ERV does not try to meet the heating or cooling load.
    if model.version < OpenStudio::VersionString.new('2.8.0')
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Model.Model', 'OpenStudio version is less than 2.8.0; ERV will attempt to meet heating and cooling load up to ventilation rate.  If this is not intended, use a newer version of OpenStudio.')
    else
      zone.setSequentialCoolingFraction(zone_hvac.to_ModelObject.get, 0.0)
      zone.setSequentialHeatingFraction(zone_hvac.to_ModelObject.get, 0.0)
    end

    # Calculate ERV SAT during sizing periods
    # Standard rating conditions based on AHRI Std 1060 - 2013
    # heating design
    oat_f = 35.0
    return_air_f = 70.0
    eff = heat_exchanger.sensibleEffectivenessat100HeatingAirFlow
    coldest_erv_supply_f = oat_f - (eff * (oat_f - return_air_f))
    coldest_erv_supply_c = OpenStudio.convert(coldest_erv_supply_f, 'F', 'C').get

    # cooling design
    oat_f = 95.0
    return_air_f = 75.0
    eff = heat_exchanger.sensibleEffectivenessat100CoolingAirFlow
    hottest_erv_supply_f = oat_f - (eff * (oat_f - return_air_f))
    hottest_erv_supply_c = OpenStudio.convert(hottest_erv_supply_f, 'F', 'C').get

    # Ensure that zone sizing accounts for OA from ERV
    sizing_zone = zone.sizingZone
    sizing_zone.setAccountforDedicatedOutdoorAirSystem(true)
    sizing_zone.setDedicatedOutdoorAirSystemControlStrategy('NeutralSupplyAir')
    sizing_zone.setDedicatedOutdoorAirLowSetpointTemperatureforDesign(coldest_erv_supply_c)
    sizing_zone.setDedicatedOutdoorAirHighSetpointTemperatureforDesign(hottest_erv_supply_c)

    ervs << zone_hvac
  end

  return ervs
end

#model_add_zone_ventilation(model, thermal_zones, ventilation_type: nil, flow_rate: nil, availability_sch_name: nil) ⇒ Array<OpenStudio::Model::ZoneVentilationDesignFlowRate>

Adds a zone ventilation design flow rate to each zone.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    an array of thermal zones

  • ventilation_type (String) (defaults to: nil)

    the zone ventilation type either Exhaust, Natural, or Intake

  • flow_rate (Double) (defaults to: nil)

    the ventilation design flow rate in m^3/s

  • availability_sch_name (String) (defaults to: nil)

    the name of the fan availability schedule

Returns:

  • (Array<OpenStudio::Model::ZoneVentilationDesignFlowRate>)

    an array of zone ventilation objects created



5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5418

def model_add_zone_ventilation(model,
                               thermal_zones,
                               ventilation_type: nil,
                               flow_rate: nil,
                               availability_sch_name: nil)

  if availability_sch_name.nil?
    availability_schedule = model.alwaysOnDiscreteSchedule
  else
    availability_schedule = model_add_schedule(model, availability_sch_name)
  end

  if flow_rate.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'Flow rate nil for zone ventilation.')
  end

  # make a zone ventilation object for each zone
  zone_ventilations = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding zone ventilation fan for #{zone.name}.")
    ventilation = OpenStudio::Model::ZoneVentilationDesignFlowRate.new(model)
    ventilation.setName("#{zone.name} Ventilation")
    ventilation.setSchedule(availability_schedule)

    if ventilation_type == 'Exhaust'
      ventilation.setDesignFlowRateCalculationMethod('Flow/Zone')
      ventilation.setDesignFlowRate(flow_rate)
      ventilation.setFanPressureRise(31.1361206455786)
      ventilation.setFanTotalEfficiency(0.51)
      ventilation.setConstantTermCoefficient(1.0)
      ventilation.setVelocityTermCoefficient(0.0)
      ventilation.setTemperatureTermCoefficient(0.0)
      ventilation.setMinimumIndoorTemperature(29.4444452244559)
      ventilation.setMaximumIndoorTemperature(100.0)
      ventilation.setDeltaTemperature(-100.0)
    elsif ventilation_type == 'Natural'
      ventilation.setDesignFlowRateCalculationMethod('Flow/Zone')
      ventilation.setDesignFlowRate(flow_rate)
      ventilation.setFanPressureRise(0.0)
      ventilation.setFanTotalEfficiency(1.0)
      ventilation.setConstantTermCoefficient(0.0)
      ventilation.setVelocityTermCoefficient(0.224)
      ventilation.setTemperatureTermCoefficient(0.0)
      ventilation.setMinimumIndoorTemperature(-73.3333352760033)
      ventilation.setMaximumIndoorTemperature(29.4444452244559)
      ventilation.setDeltaTemperature(-100.0)
    elsif ventilation_type == 'Intake'
      ventilation.setDesignFlowRateCalculationMethod('Flow/Area')
      ventilation.setFlowRateperZoneFloorArea(flow_rate)
      ventilation.setFanPressureRise(49.8)
      ventilation.setFanTotalEfficiency(0.53625)
      ventilation.setConstantTermCoefficient(1.0)
      ventilation.setVelocityTermCoefficient(0.0)
      ventilation.setTemperatureTermCoefficient(0.0)
      ventilation.setMinimumIndoorTemperature(7.5)
      ventilation.setMaximumIndoorTemperature(35)
      ventilation.setDeltaTemperature(-27.5)
      ventilation.setMinimumOutdoorTemperature(-30.0)
      ventilation.setMaximumOutdoorTemperature(50.0)
      ventilation.setMaximumWindSpeed(6.0)
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "ventilation type #{ventilation_type} invalid for zone ventilation.")
    end
    ventilation.setVentilationType(ventilation_type)
    ventilation.addToThermalZone(zone)
    zone_ventilations << ventilation
  end

  return zone_ventilations
end

#model_apply_hvac_efficiency_standard(model, climate_zone, apply_controls: true, sql_db_vars_map: nil) ⇒ Object

Applies the HVAC parts of the template to all objects in the model using the the template specified in the model.



1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1481

def model_apply_hvac_efficiency_standard(model, climate_zone, apply_controls: true, sql_db_vars_map: nil)
  sql_db_vars_map = {} if sql_db_vars_map.nil?

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Started applying HVAC efficiency standards for #{template} template.")

  # Air Loop Controls
  if apply_controls.nil? || apply_controls == true
    model.getAirLoopHVACs.sort.each { |obj| air_loop_hvac_apply_standard_controls(obj, climate_zone) }
  end

  # Plant Loop Controls
  if apply_controls.nil? || apply_controls == true
    model.getPlantLoops.sort.each { |obj| plant_loop_apply_standard_controls(obj, climate_zone) }
  end

  # Zone HVAC Controls
  model.getZoneHVACComponents.sort.each { |obj| zone_hvac_component_apply_standard_controls(obj) }

  ##### Apply equipment efficiencies

  # Fans
  model.getFanVariableVolumes.sort.each { |obj| fan_apply_standard_minimum_motor_efficiency(obj, fan_brake_horsepower(obj)) }
  model.getFanConstantVolumes.sort.each { |obj| fan_apply_standard_minimum_motor_efficiency(obj, fan_brake_horsepower(obj)) }
  model.getFanOnOffs.sort.each { |obj| fan_apply_standard_minimum_motor_efficiency(obj, fan_brake_horsepower(obj)) }
  model.getFanZoneExhausts.sort.each { |obj| fan_apply_standard_minimum_motor_efficiency(obj, fan_brake_horsepower(obj)) }

  # Pumps
  model.getPumpConstantSpeeds.sort.each { |obj| pump_apply_standard_minimum_motor_efficiency(obj) }
  model.getPumpVariableSpeeds.sort.each { |obj| pump_apply_standard_minimum_motor_efficiency(obj) }
  model.getHeaderedPumpsConstantSpeeds.sort.each { |obj| pump_apply_standard_minimum_motor_efficiency(obj) }
  model.getHeaderedPumpsVariableSpeeds.sort.each { |obj| pump_apply_standard_minimum_motor_efficiency(obj) }

  # Unitary HPs
  # set DX HP coils before DX clg coils because when DX HP coils need to first
  # pull the capacities of their paired DX clg coils, and this does not work
  # correctly if the DX clg coil efficiencies have been set because they are renamed.
  model.getCoilHeatingDXSingleSpeeds.sort.each { |obj| sql_db_vars_map = coil_heating_dx_single_speed_apply_efficiency_and_curves(obj, sql_db_vars_map) }

  # Unitary ACs
  model.getCoilCoolingDXTwoSpeeds.sort.each { |obj| sql_db_vars_map = coil_cooling_dx_two_speed_apply_efficiency_and_curves(obj, sql_db_vars_map) }
  model.getCoilCoolingDXSingleSpeeds.sort.each { |obj| sql_db_vars_map = coil_cooling_dx_single_speed_apply_efficiency_and_curves(obj, sql_db_vars_map) }
  model.getCoilCoolingDXMultiSpeeds.sort.each { |obj| sql_db_vars_map = coil_cooling_dx_multi_speed_apply_efficiency_and_curves(obj, sql_db_vars_map) }

  # WSHPs
  # set WSHP heating coils before cooling coils to get cooling coil capacities before they are renamed
  model.getCoilHeatingWaterToAirHeatPumpEquationFits.sort.each { |obj| sql_db_vars_map = coil_heating_water_to_air_heat_pump_apply_efficiency_and_curves(obj, sql_db_vars_map) }
  model.getCoilCoolingWaterToAirHeatPumpEquationFits.sort.each { |obj| sql_db_vars_map = coil_cooling_water_to_air_heat_pump_apply_efficiency_and_curves(obj, sql_db_vars_map) }

  # Chillers
  clg_tower_objs = model.getCoolingTowerSingleSpeeds
  model.getChillerElectricEIRs.sort.each { |obj| chiller_electric_eir_apply_efficiency_and_curves(obj, clg_tower_objs) }

  # Boilers
  model.getBoilerHotWaters.sort.each { |obj| boiler_hot_water_apply_efficiency_and_curves(obj) }

  # Water Heaters
  model.getWaterHeaterMixeds.sort.each { |obj| water_heater_mixed_apply_efficiency(obj) }

  # Cooling Towers
  model.getCoolingTowerSingleSpeeds.sort.each { |obj| cooling_tower_single_speed_apply_efficiency_and_curves(obj) }
  model.getCoolingTowerTwoSpeeds.sort.each { |obj| cooling_tower_two_speed_apply_efficiency_and_curves(obj) }
  model.getCoolingTowerVariableSpeeds.sort.each { |obj| cooling_tower_variable_speed_apply_efficiency_and_curves(obj) }

  # Fluid Coolers
  model.getFluidCoolerSingleSpeeds.sort.each { |obj| fluid_cooler_apply_minimum_power_per_flow(obj, equipment_type: 'Dry Cooler') }
  model.getFluidCoolerTwoSpeeds.sort.each { |obj| fluid_cooler_apply_minimum_power_per_flow(obj, equipment_type: 'Dry Cooler') }
  model.getEvaporativeFluidCoolerSingleSpeeds.sort.each { |obj| fluid_cooler_apply_minimum_power_per_flow(obj, equipment_type: 'Closed Cooling Tower') }
  model.getEvaporativeFluidCoolerTwoSpeeds.sort.each { |obj| fluid_cooler_apply_minimum_power_per_flow(obj, equipment_type: 'Closed Cooling Tower') }

  # ERVs
  model.getHeatExchangerAirToAirSensibleAndLatents.each { |obj| heat_exchanger_air_to_air_sensible_and_latent_apply_efficiency(obj) }

  # Gas Heaters
  model.getCoilHeatingGass.sort.each { |obj| coil_heating_gas_apply_efficiency_and_curves(obj) }
  model.getCoilHeatingGasMultiStages.each { |obj| coil_heating_gas_multi_stage_apply_efficiency_and_curves(obj) }

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Finished applying HVAC efficiency standards for #{template} template.")
  return true
end

#model_apply_infiltration_standard(model) ⇒ Bool

TODO:

This infiltration method is not used by the Reference

Apply the air leakage requirements to the model, as described in PNNL section 5.2.1.6. This method creates customized infiltration objects for each space and removes the SpaceType-level infiltration objects.

base infiltration rates off of. buildings, fix this inconsistency.

Returns:

  • (Bool)

    true if successful, false if not



1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1582

def model_apply_infiltration_standard(model)
  # Set the infiltration rate at each space
  model.getSpaces.sort.each do |space|
    space_apply_infiltration_rate(space)
  end

  # Remove infiltration rates set at the space type
  model.getSpaceTypes.sort.each do |space_type|
    space_type.spaceInfiltrationDesignFlowRates.each(&:remove)
  end

  return true
end

#model_apply_multizone_vav_outdoor_air_sizing(model) ⇒ Object

Note:

This must be performed before the sizing run because it impacts component sizes, which in turn impact efficiencies.

Applies the multi-zone VAV outdoor air sizing requirements to all applicable air loops in the model.



1471
1472
1473
1474
1475
1476
1477
1478
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1471

def model_apply_multizone_vav_outdoor_air_sizing(model)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started applying multizone vav OA sizing.')

  # Multi-zone VAV outdoor air sizing
  model.getAirLoopHVACs.sort.each { |obj| air_loop_hvac_apply_multizone_vav_outdoor_air_sizing(obj) }

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Finished applying multizone vav OA sizing.')
end

#model_apply_parametric_schedules(model, ramp_frequency: nil, infer_hoo_for_non_assigned_objects: true, error_on_out_of_order: true) ⇒ Array

Note:

This measure will replace any prior chagnes made to ScheduleRule objects with new ScheduleRule values from

This method applies the hours of operation for a space and the load profile formulas in the overloaded ScheduleRulset objects to update time value pairs for ScheduleDay objects. Object type specific logic will be used to generate profiles for summer and winter design days.

profile formulas

Parameters:

  • model (Model)
  • ramp_frequency (Double) (defaults to: nil)

    ramp frequency in minutes. If nil method will match simulation timestep

  • infer_hoo_for_non_assigned_objects (Bool) (defaults to: true)

    # attempt to get hoo for objects like swh with and exterior lighting

  • error_on_out_of_order (Bool) (defaults to: true)

    true will error if applying formula creates out of order values

Returns:

  • (Array)

    of modified ScheduleRuleset objects

Author:

  • David Goldwasser



4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4993

def model_apply_parametric_schedules(model, ramp_frequency: nil, infer_hoo_for_non_assigned_objects: true, error_on_out_of_order: true)
  # get ramp frequency (fractional hour) from timestep
  if ramp_frequency.nil?
    steps_per_hour = if model.getSimulationControl.timestep.is_initialized
                       model.getSimulationControl.timestep.get.numberOfTimestepsPerHour
                     else
                       6 # default OpenStudio timestep if none specified
                     end
    ramp_frequency = 1.0 / steps_per_hour.to_f
  end

  # Go through model and create parametric formulas for all schedules
  parametric_inputs = model_setup_parametric_schedules(model, gather_data_only: true)

  parametric_schedules = []
  model.getScheduleRulesets.sort.each do |sch|
    if !sch.hasAdditionalProperties || !sch.additionalProperties.hasFeature('param_sch_ver')
      # for now don't look at schedules without targets, in future can alter these by looking at building level hours of operation
      next if sch.directUseCount <= 0 # won't catch if used for space type load instance, but that space type isn't used

      # TODO: - address schedules that fall into this category, if they are used in the model
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Model', "For #{sch.sources.first.name}, #{sch.name} is not setup as parametric schedule. It has #{sch.sources.size} sources.")
      next
    end

    # apply parametric inputs
    schedule_apply_parametric_inputs(sch, ramp_frequency, infer_hoo_for_non_assigned_objects, error_on_out_of_order, parametric_inputs)

    # add schedule to array
    parametric_schedules << sch
  end

  return parametric_schedules
end

#model_apply_prm_baseline_skylight_to_roof_ratio(model) ⇒ Object

TODO:

support semiheated spaces as a separate SRR category

TODO:

add skylight frame area to calculation of SRR

Reduces the SRR to the values specified by the PRM. SRR reduction will be done by shrinking vertices toward the centroid.



3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3695

def model_apply_prm_baseline_skylight_to_roof_ratio(model)
  # Loop through all spaces in the model, and
  # per the PNNL PRM Reference Manual, find the areas
  # of each space conditioning category (res, nonres, semi-heated)
  # separately.  Include space multipliers.
  nr_wall_m2 = 0.001 # Avoids divide by zero errors later
  nr_sky_m2 = 0
  res_wall_m2 = 0.001
  res_sky_m2 = 0
  sh_wall_m2 = 0.001
  sh_sky_m2 = 0
  total_roof_m2 = 0.001
  total_subsurface_m2 = 0
  model.getSpaces.sort.each do |space|
    # Loop through all surfaces in this space
    wall_area_m2 = 0
    sky_area_m2 = 0
    space.surfaces.sort.each do |surface|
      # Skip non-outdoor surfaces
      next unless surface.outsideBoundaryCondition == 'Outdoors'
      # Skip non-walls
      next unless surface.surfaceType == 'RoofCeiling'

      # This wall's gross area (including skylight area)
      wall_area_m2 += surface.grossArea * space.multiplier
      # Subsurfaces in this surface
      surface.subSurfaces.sort.each do |ss|
        next unless ss.subSurfaceType == 'Skylight'

        sky_area_m2 += ss.netArea * space.multiplier
      end
    end

    # Determine the space category
    cat = 'NonRes'
    if space_residential?(space)
      cat = 'Res'
    end
    # if space.is_semiheated
    # cat = 'Semiheated'
    # end

    # Add to the correct category
    case cat
      when 'NonRes'
        nr_wall_m2 += wall_area_m2
        nr_sky_m2 += sky_area_m2
      when 'Res'
        res_wall_m2 += wall_area_m2
        res_sky_m2 += sky_area_m2
      when 'Semiheated'
        sh_wall_m2 += wall_area_m2
        sh_sky_m2 += sky_area_m2
    end
    total_roof_m2 += wall_area_m2
    total_subsurface_m2 += sky_area_m2
  end

  # Calculate the SRR of each category
  srr_nr = ((nr_sky_m2 / nr_wall_m2) * 100).round(1)
  srr_res = ((res_sky_m2 / res_wall_m2) * 100).round(1)
  srr_sh = ((sh_sky_m2 / sh_wall_m2) * 100).round(1)
  srr = ((total_subsurface_m2 / total_roof_m2) * 100.0).round(1)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "The skylight to roof ratios (SRRs) are: NonRes: #{srr_nr.round}%, Res: #{srr_res.round}%.")

  # SRR limit
  srr_lim = model_prm_skylight_to_roof_ratio_limit(model)

  # Check against SRR limit
  red_nr = srr_nr > srr_lim
  red_res = srr_res > srr_lim
  red_sh = srr_sh > srr_lim

  # Stop here unless skylights need reducing
  return true unless red_nr || red_res || red_sh

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Reducing the size of all skylights equally down to the limit of #{srr_lim.round}%.")

  # Determine the factors by which to reduce the skylight area
  mult_nr_red = srr_lim / srr_nr
  mult_res_red = srr_lim / srr_res
  # mult_sh_red = srr_lim / srr_sh

  # Reduce the skylight area if any of the categories necessary
  model.getSpaces.sort.each do |space|
    # Determine the space category
    cat = 'NonRes'
    if space_residential?(space)
      cat = 'Res'
    end
    # if space.is_semiheated
    # cat = 'Semiheated'
    # end

    # Skip spaces whose skylights don't need to be reduced
    case cat
      when 'NonRes'
        next unless red_nr

        mult = mult_nr_red
      when 'Res'
        next unless red_res

        mult = mult_res_red
      when 'Semiheated'
        next unless red_sh
      # mult = mult_sh_red
    end

    # Loop through all surfaces in this space
    space.surfaces.sort.each do |surface|
      # Skip non-outdoor surfaces
      next unless surface.outsideBoundaryCondition == 'Outdoors'
      # Skip non-walls
      next unless surface.surfaceType == 'RoofCeiling'

      # Subsurfaces in this surface
      surface.subSurfaces.sort.each do |ss|
        next unless ss.subSurfaceType == 'Skylight'

        # Reduce the size of the skylight
        red = 1.0 - mult
        sub_surface_reduce_area_by_percent_by_shrinking_toward_centroid(ss, red)
      end
    end
  end

  return true
end

#model_apply_prm_baseline_window_to_wall_ratio(model, climate_zone) ⇒ Object

TODO:

add proper support for 90.1-2013 with all those building type specific values

TODO:

support 90.1-2004 requirement that windows be modeled as horizontal bands.

TODO:

support semiheated spaces as a separate WWR category

TODO:

add window frame area to calculation of WWR

Reduces the WWR to the values specified by the PRM. WWR reduction will be done by moving vertices inward toward centroid. This causes the least impact on the daylighting area calculations and controls placement.

Currently just using existing window geometry, and shrinking as necessary if WWR is above limit.



3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3526

def model_apply_prm_baseline_window_to_wall_ratio(model, climate_zone)
  # Loop through all spaces in the model, and
  # per the PNNL PRM Reference Manual, find the areas
  # of each space conditioning category (res, nonres, semi-heated)
  # separately.  Include space multipliers.
  nr_wall_m2 = 0.001 # Avoids divide by zero errors later
  nr_wind_m2 = 0
  res_wall_m2 = 0.001
  res_wind_m2 = 0
  sh_wall_m2 = 0.001
  sh_wind_m2 = 0
  total_wall_m2 = 0.001
  total_subsurface_m2 = 0.0
  # Store the space conditioning category for later use
  space_cats = {}
  model.getSpaces.sort.each do |space|
    # Loop through all surfaces in this space
    wall_area_m2 = 0
    wind_area_m2 = 0
    space.surfaces.sort.each do |surface|
      # Skip non-outdoor surfaces
      next unless surface.outsideBoundaryCondition == 'Outdoors'
      # Skip non-walls
      next unless surface.surfaceType.casecmp('wall').zero?

      # This wall's gross area (including window area)
      wall_area_m2 += surface.grossArea * space.multiplier
      # Subsurfaces in this surface
      surface.subSurfaces.sort.each do |ss|
        next unless ss.subSurfaceType == 'FixedWindow' || ss.subSurfaceType == 'OperableWindow'

        wind_area_m2 += ss.netArea * space.multiplier
      end
    end

    # Determine the space category
    # TODO: This should really use the heating/cooling loads from the proposed building.
    # However, in an attempt to avoid another sizing run just for this purpose,
    # conditioned status is based on heating/cooling setpoints.
    # If heated-only, will be assumed Semiheated.
    # The full-bore method is on the next line in case needed.
    # cat = thermal_zone_conditioning_category(space, template, climate_zone)
    cooled = space_cooled?(space)
    heated = space_heated?(space)
    cat = 'Unconditioned'
    # Unconditioned
    if !heated && !cooled
      cat = 'Unconditioned'
      # Heated-Only
    elsif heated && !cooled
      cat = 'Semiheated'
      # Heated and Cooled
    else
      res = space_residential?(space)
      cat = if res
              'ResConditioned'
            else
              'NonResConditioned'
            end
    end
    space_cats[space] = cat

    # Add to the correct category
    case cat
      when 'Unconditioned'
        next # Skip unconditioned spaces
      when 'NonResConditioned'
        nr_wall_m2 += wall_area_m2
        nr_wind_m2 += wind_area_m2
      when 'ResConditioned'
        res_wall_m2 += wall_area_m2
        res_wind_m2 += wind_area_m2
      when 'Semiheated'
        sh_wall_m2 += wall_area_m2
        sh_wind_m2 += wind_area_m2
    end
  end

  # Calculate the WWR of each category
  wwr_nr = ((nr_wind_m2 / nr_wall_m2) * 100.0).round(1)
  wwr_res = ((res_wind_m2 / res_wall_m2) * 100).round(1)
  wwr_sh = ((sh_wind_m2 / sh_wall_m2) * 100).round(1)

  # Convert to IP and report
  nr_wind_ft2 = OpenStudio.convert(nr_wind_m2, 'm^2', 'ft^2').get
  nr_wall_ft2 = OpenStudio.convert(nr_wall_m2, 'm^2', 'ft^2').get

  res_wind_ft2 = OpenStudio.convert(res_wind_m2, 'm^2', 'ft^2').get
  res_wall_ft2 = OpenStudio.convert(res_wall_m2, 'm^2', 'ft^2').get

  sh_wind_ft2 = OpenStudio.convert(sh_wind_m2, 'm^2', 'ft^2').get
  sh_wall_ft2 = OpenStudio.convert(sh_wall_m2, 'm^2', 'ft^2').get

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "WWR NonRes = #{wwr_nr.round}%; window = #{nr_wind_ft2.round} ft2, wall = #{nr_wall_ft2.round} ft2.")
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "WWR Res = #{wwr_res.round}%; window = #{res_wind_ft2.round} ft2, wall = #{res_wall_ft2.round} ft2.")
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "WWR Semiheated = #{wwr_sh.round}%; window = #{sh_wind_ft2.round} ft2, wall = #{sh_wall_ft2.round} ft2.")

  # WWR limit
  wwr_lim = 40.0

  # Check against WWR limit
  red_nr = wwr_nr > wwr_lim
  red_res = wwr_res > wwr_lim
  red_sh = wwr_sh > wwr_lim

  # Stop here unless windows need reducing
  return true unless red_nr || red_res || red_sh

  # Determine the factors by which to reduce the window area
  mult_nr_red = wwr_lim / wwr_nr
  mult_res_red = wwr_lim / wwr_res
  mult_sh_red = wwr_lim / wwr_sh

  # Reduce the window area if any of the categories necessary
  model.getSpaces.sort.each do |space|
    # Determine the space category
    # from the previously stored values
    cat = space_cats[space]

    # Get the correct multiplier
    case cat
      when 'Unconditioned'
        next # Skip unconditioned spaces
      when 'NonResConditioned'
        next unless red_nr

        mult = mult_nr_red
      when 'ResConditioned'
        next unless red_res

        mult = mult_res_red
      when 'Semiheated'
        next unless red_sh

        mult = mult_sh_red
    end

    # Loop through all surfaces in this space
    space.surfaces.sort.each do |surface|
      # Skip non-outdoor surfaces
      next unless surface.outsideBoundaryCondition == 'Outdoors'
      # Skip non-walls
      next unless surface.surfaceType.casecmp('wall').zero?

      # Subsurfaces in this surface
      surface.subSurfaces.sort.each do |ss|
        next unless ss.subSurfaceType == 'FixedWindow' || ss.subSurfaceType == 'OperableWindow'

        # Reduce the size of the window
        # If a vertical rectangle, raise sill height to avoid
        # impacting daylighting areas, otherwise
        # reduce toward centroid.
        red = 1.0 - mult
        if sub_surface_vertical_rectangle?(ss)
          sub_surface_reduce_area_by_percent_by_raising_sill(ss, red)
        else
          sub_surface_reduce_area_by_percent_by_shrinking_toward_centroid(ss, red)
        end
      end
    end
  end

  return true
end

#model_apply_prm_construction_types(model) ⇒ Bool

Go through the default construction sets and hard-assigned constructions. Clone the existing constructions and set their intended surface type and standards construction type per the PRM. For some standards, this will involve making modifications. For others, it will not.

90.1-2007, 90.1-2010, 90.1-2013

Returns:

  • (Bool)

    returns true if successful, false if not



3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3314

def model_apply_prm_construction_types(model)
  types_to_modify = []

  # Possible boundary conditions are
  # Adiabatic
  # Surface
  # Outdoors
  # Ground

  # Possible surface types are
  # AtticFloor
  # AtticWall
  # AtticRoof
  # DemisingFloor
  # DemisingWall
  # DemisingRoof
  # ExteriorFloor
  # ExteriorWall
  # ExteriorRoof
  # ExteriorWindow
  # ExteriorDoor
  # GlassDoor
  # GroundContactFloor
  # GroundContactWall
  # GroundContactRoof
  # InteriorFloor
  # InteriorWall
  # InteriorCeiling
  # InteriorPartition
  # InteriorWindow
  # InteriorDoor
  # OverheadDoor
  # Skylight
  # TubularDaylightDome
  # TubularDaylightDiffuser

  # Possible standards construction types
  # Mass
  # SteelFramed
  # WoodFramed
  # IEAD
  # View
  # Daylight
  # Swinging
  # NonSwinging
  # Heated
  # Unheated
  # RollUp
  # Sliding
  # Metal
  # Nonmetal framing (all)
  # Metal framing (curtainwall/storefront)
  # Metal framing (entrance door)
  # Metal framing (all other)
  # Metal Building
  # Attic and Other
  # Glass with Curb
  # Plastic with Curb
  # Without Curb

  # Create an array of types
  types_to_modify << ['Outdoors', 'ExteriorWall', 'SteelFramed']
  types_to_modify << ['Outdoors', 'ExteriorRoof', 'IEAD']
  types_to_modify << ['Outdoors', 'ExteriorFloor', 'SteelFramed']
  types_to_modify << ['Ground', 'GroundContactFloor', 'Unheated']
  types_to_modify << ['Ground', 'GroundContactWall', 'Mass']

  # Modify all constructions of each type
  types_to_modify.each do |boundary_cond, surf_type, const_type|
    constructions = model_find_constructions(model, boundary_cond, surf_type)

    constructions.sort.each do |const|
      standards_info = const.standardsInformation
      standards_info.setIntendedSurfaceType(surf_type)
      standards_info.setStandardsConstructionType(const_type)
    end
  end

  return true
end

#model_apply_prm_sizing_parameters(model) ⇒ Object

Changes the sizing parameters to the PRM specifications.



3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3903

def model_apply_prm_sizing_parameters(model)
  clg = 1.15
  htg = 1.25

  sizing_params = model.getSizingParameters
  sizing_params.setHeatingSizingFactor(htg)
  sizing_params.setCoolingSizingFactor(clg)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.Model', "Set sizing factors to #{htg} for heating and #{clg} for cooling.")
end

#model_apply_standard_constructions(model, climate_zone) ⇒ Bool

Apply the standard construction to each surface in the model, based on the construction type currently assigned.

Returns:

  • (Bool)

    true if successful, false if not



3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3398

def model_apply_standard_constructions(model, climate_zone)
  types_to_modify = []

  # Possible boundary conditions are
  # Adiabatic
  # Surface
  # Outdoors
  # Ground

  # Possible surface types are
  # Floor
  # Wall
  # RoofCeiling
  # FixedWindow
  # OperableWindow
  # Door
  # GlassDoor
  # OverheadDoor
  # Skylight
  # TubularDaylightDome
  # TubularDaylightDiffuser

  # Create an array of surface types
  types_to_modify << ['Outdoors', 'Floor']
  types_to_modify << ['Outdoors', 'Wall']
  types_to_modify << ['Outdoors', 'RoofCeiling']
  types_to_modify << ['Outdoors', 'FixedWindow']
  types_to_modify << ['Outdoors', 'OperableWindow']
  types_to_modify << ['Outdoors', 'Door']
  types_to_modify << ['Outdoors', 'GlassDoor']
  types_to_modify << ['Outdoors', 'OverheadDoor']
  types_to_modify << ['Outdoors', 'Skylight']
  types_to_modify << ['Ground', 'Floor']
  types_to_modify << ['Ground', 'Wall']

  # Find just those surfaces
  surfaces_to_modify = []
  types_to_modify.each do |boundary_condition, surface_type|
    # Surfaces
    model.getSurfaces.sort.each do |surf|
      next unless surf.outsideBoundaryCondition == boundary_condition
      next unless surf.surfaceType == surface_type

      surfaces_to_modify << surf
    end

    # SubSurfaces
    model.getSubSurfaces.sort.each do |surf|
      next unless surf.outsideBoundaryCondition == boundary_condition
      next unless surf.subSurfaceType == surface_type

      surfaces_to_modify << surf
    end
  end

  # Modify these surfaces
  prev_created_consts = {}
  surfaces_to_modify.sort.each do |surf|
    prev_created_consts = planar_surface_apply_standard_construction(surf, climate_zone, prev_created_consts)
  end

  # List the unique array of constructions
  if prev_created_consts.size.zero?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Model', 'None of the constructions in your proposed model have both Intended Surface Type and Standards Construction Type')
  else
    prev_created_consts.each do |surf_type, construction|
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "For #{surf_type.join(' ')}, applied #{construction.name}.")
    end
  end

  return true
end

#model_assign_spaces_to_stories(model) ⇒ Bool

Assign each space in the model to a building story based on common z (height) values. If no story object is found for a particular height, create a new one and assign it to the space. Does not assign a story to plenum spaces.

Returns:

  • (Bool)

    returns true if successful, false if not.



1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1432

def model_assign_spaces_to_stories(model)
  # Make hash of spaces and minz values
  sorted_spaces = {}
  model.getSpaces.sort.each do |space|
    # Skip plenum spaces
    next if space_plenum?(space)

    # loop through space surfaces to find min z value
    z_points = []
    space.surfaces.each do |surface|
      surface.vertices.each do |vertex|
        z_points << vertex.z
      end
    end
    minz = z_points.min + space.zOrigin
    sorted_spaces[space] = minz
  end

  # Pre-sort spaces
  sorted_spaces = sorted_spaces.sort_by { |a| a[1] }

  # Take the sorted list and assign/make stories
  sorted_spaces.each do |space|
    space_obj = space[0]
    space_minz = space[1]
    if space_obj.buildingStory.empty?
      story = model_get_story_for_nominal_z_coordinate(model, space_minz)
      space_obj.setBuildingStory(story)
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Model', "Space #{space[0].name} was not assigned to a story by the user.  It has been assigned to #{story.name}.")
    end
  end

  return true
end

#model_attach_water_fixtures_to_spaces?(model) ⇒ Boolean

Determine whether or not water fixtures are attached to spaces

Returns:

  • (Boolean)


965
966
967
968
969
970
971
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.ServiceWaterHeating.rb', line 965

def model_attach_water_fixtures_to_spaces?(model)
  # TODO: For hotels and apartments, add the water fixture at the space level
  # if building_type!=nil && ((building_type.downcase.include?"hotel") || (building_type.downcase.include?"apartment"))
  #   return true
  # end
  return false
end

#model_baseline_system_vav_fan_type(model) ⇒ String

Determines the fan type used by VAV_Reheat and VAV_PFP_Boxes systems. Defaults to two speed fan.

Returns:

  • (String)

    the fan type: TwoSpeed Fan, Variable Speed Fan



1112
1113
1114
1115
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1112

def model_baseline_system_vav_fan_type(model)
  fan_type = 'TwoSpeed Fan'
  return fan_type
end

#model_create_exterior_lighting_area_length_count_hash(model, space_type_hash, use_model_for_entries_and_canopies) ⇒ hash

TODO:
  • add code in to determine number of entries and canopy area from model geoemtry

TODO:
  • come up with better logic for entry widths

get exterior lighting area’s, distances, and counts

Returns:

  • (hash)

    hash of exterior lighting value types and building type and model specific values



286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.exterior_lights.rb', line 286

def model_create_exterior_lighting_area_length_count_hash(model, space_type_hash, use_model_for_entries_and_canopies)
  # populate building_type_hashes from space_type_hash
  building_type_hashes = {}
  space_type_hash.each do |space_type, hash|
    # if space type standards building type already exists,
    # add data to that standards building type in building_type_hashes
    if building_type_hashes.key?(hash[:stds_bldg_type])
      building_type_hashes[hash[:stds_bldg_type]][:effective_num_spaces] += hash[:effective_num_spaces]
      building_type_hashes[hash[:stds_bldg_type]][:floor_area] += hash[:floor_area]
      building_type_hashes[hash[:stds_bldg_type]][:num_people] += hash[:num_people]
      building_type_hashes[hash[:stds_bldg_type]][:num_students] += hash[:num_students]
      building_type_hashes[hash[:stds_bldg_type]][:num_units] += hash[:num_units]
      building_type_hashes[hash[:stds_bldg_type]][:num_beds] += hash[:num_beds]
    else
      # initialize hash for this building type
      building_type_hash = {}
      building_type_hash[:effective_num_spaces] = hash[:effective_num_spaces]
      building_type_hash[:floor_area] = hash[:floor_area]
      building_type_hash[:num_people] = hash[:num_people]
      building_type_hash[:num_students] = hash[:num_students]
      building_type_hash[:num_units] = hash[:num_units]
      building_type_hash[:num_beds] = hash[:num_beds]
      building_type_hashes[hash[:stds_bldg_type]] = building_type_hash
    end
  end

  # rename Office to SmallOffice, MediumOffice or LargeOffice depending on size
  if building_type_hashes.key?('Office')
    office_type = model_remap_office(model, building_type_hashes['Office'][:floor_area])
    building_type_hashes[office_type] = building_type_hashes.delete('Office')
  end

  # initialize parking areas and drives area variables
  parking_area_and_drives_area = 0.0
  main_entries = 0.0
  other_doors = 0.0
  drive_through_windows = 0.0
  canopy_entry_area = 0.0
  canopy_emergency_area = 0.0

  # calculate exterior lighting properties for each building type
  building_type_hashes.each do |building_type, hash|
    # calculate floor area and ground floor area in IP units
    floor_area_ip = OpenStudio.convert(hash[:floor_area], 'm^2', 'ft^2').get
    effective_num_stories = model_effective_num_stories(model)
    ground_floor_area_ip = floor_area_ip / effective_num_stories[:above_grade]

    # load illuminated parking area properties for standards building type
    search_criteria = { 'building_type' => building_type }
    illuminated_parking_area_lookup = standards_lookup_table_first(table_name: 'parking', search_criteria: search_criteria)
    if illuminated_parking_area_lookup.nil?
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.prototype.exterior_lights', "Could not find parking data for #{building_type}.")
      return {} # empty hash
    end

    # calculate number of parking spots
    num_spots = 0.0
    if !illuminated_parking_area_lookup['building_area_per_spot'].nil?
      num_spots += floor_area_ip / illuminated_parking_area_lookup['building_area_per_spot'].to_f
    elsif !illuminated_parking_area_lookup['units_per_spot'].nil?
      num_spots += hash[:num_units] / illuminated_parking_area_lookup['units_per_spot'].to_f
    elsif !illuminated_parking_area_lookup['students_per_spot'].nil?
      num_spots += hash[:num_students] / illuminated_parking_area_lookup['students_per_spot'].to_f
    elsif !illuminated_parking_area_lookup['beds_per_spot'].nil?
      num_spots += hash[:num_beds] / illuminated_parking_area_lookup['beds_per_spot'].to_f
    else
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.exterior_lights', "Unexpected key, can't calculate number of parking spots from #{illuminated_parking_area_lookup.keys.first}.")
    end
    # add to cumulative parking area
    parking_area_and_drives_area += num_spots * illuminated_parking_area_lookup['parking_area_per_spot']

    # load entryways data for standards building type
    search_criteria = { 'building_type' => building_type }
    exterior_lighting_assumptions_lookup = standards_lookup_table_first(table_name: 'entryways', search_criteria: search_criteria)

    if exterior_lighting_assumptions_lookup.nil?
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.prototype.exterior_lights', "Could not find entryway data for #{building_type}.")
      return {} # empty hash
    end

    # calculate door, window, and canopy length properties for exterior lighting
    if use_model_for_entries_and_canopies
      # TODO: - get number of entries and canopy size from model geometry
    else

      # main entries
      main_entries = (ground_floor_area_ip / 10_000.0) * exterior_lighting_assumptions_lookup['entrance_doors_per_10,000']

      # other doors
      other_doors += (ground_floor_area_ip / 10_000.0) * exterior_lighting_assumptions_lookup['others_doors_per_10,000']

      # drive through windows
      unless exterior_lighting_assumptions_lookup['floor_area_per_drive_through_window'].nil?
        drive_through_windows += ground_floor_area_ip / exterior_lighting_assumptions_lookup['floor_area_per_drive_through_window'].to_f
      end

      # rollup doors are currently excluded

      # entrance canopies
      if !exterior_lighting_assumptions_lookup['entrance_canopies'].nil? && !exterior_lighting_assumptions_lookup['canopy_size'].nil?
        canopy_entry_area = exterior_lighting_assumptions_lookup['entrance_canopies'] * exterior_lighting_assumptions_lookup['canopy_size']
      end

      # emergency canopies
      if !exterior_lighting_assumptions_lookup['emergency_canopies'].nil? && !exterior_lighting_assumptions_lookup['canopy_size'].nil?
        canopy_emergency_area = exterior_lighting_assumptions_lookup['emergency_canopies'] * exterior_lighting_assumptions_lookup['canopy_size']
      end
    end
  end

  # no source for width of different entry types
  main_entry_width_ip = 8 # ft
  other_doors_width_ip = 4 # ft

  # ensure the building has at least 1 main entry
  main_entries = 1.0 if main_entries > 0 && main_entries < 1

  # populate hash
  area_length_count_hash = {}
  area_length_count_hash[:parking_area_and_drives_area] = parking_area_and_drives_area
  area_length_count_hash[:main_entries] = main_entries * main_entry_width_ip
  area_length_count_hash[:other_doors] = other_doors * other_doors_width_ip
  area_length_count_hash[:drive_through_windows] = drive_through_windows
  area_length_count_hash[:canopy_entry_area] = canopy_entry_area
  area_length_count_hash[:canopy_emergency_area] = canopy_emergency_area

  # determine effective number of stories to find first above grade story exterior wall area
  effective_num_stories = model_effective_num_stories(model)
  ground_story = effective_num_stories[:story_hash].keys[effective_num_stories[:below_grade]]
  ground_story_ext_wall_area_si = effective_num_stories[:story_hash][ground_story][:ext_wall_area]
  ground_story_ext_wall_area_ip = OpenStudio.convert(ground_story_ext_wall_area_si, 'm^2', 'ft^2').get

  # building_facades
  # reference buildings uses first story and plenum area all around
  # prototype uses Table 4.19 by building type lit facade vs. total facade
  area_length_count_hash[:building_facades] = ground_story_ext_wall_area_ip

  return area_length_count_hash
end

#model_create_prm_baseline_building(model, building_type, climate_zone, custom = nil, sizing_run_dir = Dir.pwd, debug = false) ⇒ Bool

Note:

Per 90.1, the Performance Rating Method “does NOT offer an alternative compliance path for minimum standard compliance.”

Creates a Performance Rating Method (aka Appendix G aka LEED) baseline building model based on the inputs currently in the model. the current model with this model.

This means you can’t use this method for code compliance to get a permit.

Parameters:

  • building_type (String)

    the building type

  • climate_zone (String)

    the climate zone

  • custom (String) (defaults to: nil)

    the custom logic that will be applied during baseline creation. Valid choices are ‘Xcel Energy CO EDA’ or ‘90.1-2007 with addenda dn’. If nothing is specified, no custom logic will be applied; the process will follow the template logic explicitly.

  • sizing_run_dir (String) (defaults to: Dir.pwd)

    the directory where the sizing runs will be performed

  • debug (Boolean) (defaults to: false)

    If true, will report out more detailed debugging output

Returns:

  • (Bool)

    returns true if successful, false if not



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 26

def model_create_prm_baseline_building(model, building_type, climate_zone, custom = nil, sizing_run_dir = Dir.pwd, debug = false)
  model.getBuilding.setName("#{template}-#{building_type}-#{climate_zone} PRM baseline created: #{Time.new}")

  # Remove external shading devices
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', '*** Removing External Shading Devices ***')
  model_remove_external_shading_devices(model)

  # Reduce the WWR and SRR, if necessary
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', '*** Adjusting Window and Skylight Ratios ***')
  model_apply_prm_baseline_window_to_wall_ratio(model, climate_zone)
  model_apply_prm_baseline_skylight_to_roof_ratio(model)

  # Assign building stories to spaces in the building where stories are not yet assigned.
  model_assign_spaces_to_stories(model)

  # Modify the internal loads in each space type, keeping user-defined schedules.
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', '*** Changing Lighting Loads ***')
  model.getSpaceTypes.sort.each do |space_type|
    set_people = false
    set_lights = true
    set_electric_equipment = false
    set_gas_equipment = false
    set_ventilation = false
    set_infiltration = false
    space_type_apply_internal_loads(space_type, set_people, set_lights, set_electric_equipment, set_gas_equipment, set_ventilation, set_infiltration)
  end

  # If any of the lights are missing schedules, assign an always-off schedule to those lights.
  # This is assumed to be the user's intent in the proposed model.
  model.getLightss.sort.each do |lights|
    if lights.schedule.empty?
      lights.setSchedule(model.alwaysOffDiscreteSchedule)
    end
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', '*** Adding Daylighting Controls ***')

  # Run a sizing run to calculate VLT for layer-by-layer windows.
  if model_create_prm_baseline_building_requires_vlt_sizing_run(model)
    if model_run_sizing_run(model, "#{sizing_run_dir}/SRVLT") == false
      return false
    end
  end

  # Add daylighting controls to each space
  model.getSpaces.sort.each do |space|
    added = space_add_daylighting_controls(space, false, false)
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', '*** Applying Baseline Constructions ***')

  # Modify some of the construction types as necessary
  model_apply_prm_construction_types(model)

  # Set the construction properties of all the surfaces in the model
  model_apply_standard_constructions(model, climate_zone)

  # Get the groups of zones that define the baseline HVAC systems for later use.
  # This must be done before removing the HVAC systems because it requires knowledge of proposed HVAC fuels.
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', '*** Grouping Zones by Fuel Type and Occupancy Type ***')
  sys_groups = model_prm_baseline_system_groups(model, custom)

  # Remove all HVAC from model, excluding service water heating
  model_remove_prm_hvac(model)

  # Remove all EMS objects from the model
  model_remove_prm_ems_objects(model)

  # Modify the service water heating loops per the baseline rules
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', '*** Cleaning up Service Water Heating Loops ***')
  model_apply_baseline_swh_loops(model, building_type)

  # Determine the baseline HVAC system type for each of the groups of zones and add that system type.
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', '*** Adding Baseline HVAC Systems ***')
  sys_groups.each do |sys_group|
    # Determine the primary baseline system type
    system_type = model_prm_baseline_system_type(model,
                                                 climate_zone,
                                                 sys_group['occ'],
                                                 sys_group['fuel'],
                                                 sys_group['area_ft2'],
                                                 sys_group['stories'],
                                                 custom)

    sys_group['zones'].sort.each_slice(5) do |zone_list|
      zone_names = []
      zone_list.each do |zone|
        zone_names << zone.name.get.to_s
      end
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "--- #{zone_names.join(', ')}")
    end

    # Add the system type for these zones
    model_add_prm_baseline_system(model,
                                  system_type[0],
                                  system_type[1],
                                  system_type[2],
                                  system_type[3],
                                  sys_group['zones'])
  end

  # Set the zone sizing SAT for each zone in the model
  model.getThermalZones.each do |zone|
    thermal_zone_apply_prm_baseline_supply_temperatures(zone)
  end

  # Set the system sizing properties based on the zone sizing information
  model.getAirLoopHVACs.each do |air_loop|
    air_loop_hvac_apply_prm_sizing_temperatures(air_loop)
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', '*** Applying Baseline HVAC System Controls ***')

  # SAT reset, economizers
  model.getAirLoopHVACs.sort.each do |air_loop|
    air_loop_hvac_apply_prm_baseline_controls(air_loop, climate_zone)
  end

  # Apply the minimum damper positions, assuming no DDC control of VAV terminals
  model.getAirLoopHVACs.sort.each do |air_loop|
    air_loop_hvac_apply_minimum_vav_damper_positions(air_loop, false)
  end

  # Apply the baseline system temperatures
  model.getPlantLoops.sort.each do |plant_loop|
    # Skip the SWH loops
    next if plant_loop_swh_loop?(plant_loop)

    plant_loop_apply_prm_baseline_temperatures(plant_loop)
  end

  # Set the heating and cooling sizing parameters
  model_apply_prm_sizing_parameters(model)

  # Run sizing run with the HVAC equipment
  if model_run_sizing_run(model, "#{sizing_run_dir}/SR1") == false
    return false
  end

  # If there are any multizone systems, reset damper positions to achieve a 60% ventilation effectiveness minimum for the system
  # following the ventilation rate procedure from 62.1
  model_apply_multizone_vav_outdoor_air_sizing(model)

  # Set the baseline fan power for all airloops
  model.getAirLoopHVACs.sort.each do |air_loop|
    air_loop_hvac_apply_prm_baseline_fan_power(air_loop)
  end

  # Set the baseline fan power for all zone HVAC
  model.getZoneHVACComponents.sort.each do |zone_hvac|
    zone_hvac_component_apply_prm_baseline_fan_power(zone_hvac)
  end

  # Set the baseline number of boilers and chillers
  model.getPlantLoops.sort.each do |plant_loop|
    # Skip the SWH loops
    next if plant_loop_swh_loop?(plant_loop)

    plant_loop_apply_prm_number_of_boilers(plant_loop)
    plant_loop_apply_prm_number_of_chillers(plant_loop)
  end

  # Set the baseline number of cooling towers
  # Must be done after all chillers are added
  model.getPlantLoops.sort.each do |plant_loop|
    # Skip the SWH loops
    next if plant_loop_swh_loop?(plant_loop)

    plant_loop_apply_prm_number_of_cooling_towers(plant_loop)
  end

  # Run sizing run with the new chillers, boilers, and cooling towers to determine capacities
  if model_run_sizing_run(model, "#{sizing_run_dir}/SR2") == false
    return false
  end

  # Set the pumping control strategy and power
  # Must be done after sizing components
  model.getPlantLoops.sort.each do |plant_loop|
    # Skip the SWH loops
    next if plant_loop_swh_loop?(plant_loop)

    plant_loop_apply_prm_baseline_pump_power(plant_loop)
    plant_loop_apply_prm_baseline_pumping_type(plant_loop)
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', '*** Applying Prescriptive HVAC Controls and Equipment Efficiencies ***')

  # Apply the HVAC efficiency standard
  model_apply_hvac_efficiency_standard(model, climate_zone)

  # Fix EMS references.
  # Temporary workaround for OS issue #2598
  model_temp_fix_ems_references(model)

  # Delete all the unused resource objects
  model_remove_unused_resource_objects(model)

  # TODO: turn off self shading
  # Set Solar Distribution to MinimalShadowing... problem is when you also have detached shading such as surrounding buildings etc
  # It won't be taken into account, while it should: only self shading from the building itself should be turned off but to my knowledge there isn't a way to do this in E+

  model_status = 'final'
  model.save(OpenStudio::Path.new("#{sizing_run_dir}/#{model_status}.osm"), true)

  # Translate to IDF and save for debugging
  forward_translator = OpenStudio::EnergyPlus::ForwardTranslator.new
  idf = forward_translator.translateModel(model)
  idf_path = OpenStudio::Path.new("#{sizing_run_dir}/#{model_status}.idf")
  idf.save(idf_path, true)

  return true
end

#model_create_prm_baseline_building_requires_vlt_sizing_run(model) ⇒ Object

Determine if there needs to be a sizing run after constructions are added so that EnergyPlus can calculate the VLTs of layer-by-layer glazing constructions. These VLT values are needed for the daylighting controls logic for some templates.



243
244
245
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 243

def model_create_prm_baseline_building_requires_vlt_sizing_run(model)
  return false # Not required for most templates
end

#model_create_space_type_hash(model, trust_effective_num_spaces = false) ⇒ hash

TODO:
  • add code when determining number of units to makeuse of trust_effective_num_spaces arg

create space_type_hash with info such as effective_num_spaces, num_units, num_meds, num_meals

Parameters:

  • trust_effective_num_spaces (Bool) (defaults to: false)

    defaults to false - set to true if modeled every space as a real rpp, vs. space as collection of rooms

Returns:

  • (hash)

    hash of space types with misc information



4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4306

def model_create_space_type_hash(model, trust_effective_num_spaces = false)
  # assumed class size to deduct teachers from occupant count for classrooms
  typical_class_size = 20.0

  space_type_hash = {}
  model.getSpaceTypes.sort.each do |space_type|
    # get standards info
    stds_bldg_type = space_type.standardsBuildingType
    stds_space_type = space_type.standardsSpaceType
    if stds_bldg_type.is_initialized && stds_space_type.is_initialized && !space_type.spaces.empty?
      stds_bldg_type = stds_bldg_type.get
      stds_space_type = stds_space_type.get
      effective_num_spaces = 0
      floor_area = 0.0
      num_people = 0.0
      num_students = 0.0
      num_units = 0.0
      num_beds = 0.0
      num_people_bldg_total = nil # may need this in future, not same as sumo of people for all space types.
      num_meals = nil
      # determine num_elevators in another method
      # determine num_parking_spots in another method

      # loop through spaces to get mis values
      space_type.spaces.sort.each do |space|
        next unless space.partofTotalFloorArea

        effective_num_spaces += space.multiplier
        floor_area += space.floorArea * space.multiplier
        num_people += space.numberOfPeople * space.multiplier
      end

      # determine number of units
      if stds_bldg_type == 'SmallHotel' && stds_space_type.include?('GuestRoom') # doesn't always == GuestRoom so use include?
        avg_unit_size = OpenStudio.convert(354.2, 'ft^2', 'm^2').get # calculated from prototype
        num_units = floor_area / avg_unit_size
      elsif stds_bldg_type == 'LargeHotel' && stds_space_type.include?('GuestRoom')
        avg_unit_size = OpenStudio.convert(279.7, 'ft^2', 'm^2').get # calculated from prototype
        num_units = floor_area / avg_unit_size
      elsif stds_bldg_type == 'MidriseApartment' && stds_space_type.include?('Apartment')
        avg_unit_size = OpenStudio.convert(949.9, 'ft^2', 'm^2').get # calculated from prototype
        num_units = floor_area / avg_unit_size
      elsif stds_bldg_type == 'HighriseApartment' && stds_space_type.include?('Apartment')
        avg_unit_size = OpenStudio.convert(949.9, 'ft^2', 'm^2').get # calculated from prototype
        num_units = floor_area / avg_unit_size
      elsif stds_bldg_type == 'StripMall'
        avg_unit_size = OpenStudio.convert(22_500.0 / 10.0, 'ft^2', 'm^2').get # calculated from prototype
        num_units = floor_area / avg_unit_size
      elsif stds_bldg_type == 'Htl' && (stds_space_type.include?('GuestRmOcc') || stds_space_type.include?('GuestRmUnOcc'))
        avg_unit_size = OpenStudio.convert(354.2, 'ft^2', 'm^2').get # calculated from prototype
        num_units = floor_area / avg_unit_size
      elsif stds_bldg_type == 'MFm' && (stds_space_type.include?('ResBedroom') || stds_space_type.include?('ResLiving'))
        avg_unit_size = OpenStudio.convert(949.9, 'ft^2', 'm^2').get # calculated from prototype
        num_units = floor_area / avg_unit_size
      elsif stds_bldg_type == 'Mtl' && (stds_space_type.include?('GuestRmOcc') || stds_space_type.include?('GuestRmUnOcc'))
        avg_unit_size = OpenStudio.convert(354.2, 'ft^2', 'm^2').get # calculated from prototype
        num_units = floor_area / avg_unit_size
      elsif stds_bldg_type == 'Nrs' && stds_space_type.include?('PatientRoom')
        avg_unit_size = OpenStudio.convert(354.2, 'ft^2', 'm^2').get # calculated from prototype
        num_units = floor_area / avg_unit_size
      end

      # determine number of beds
      if stds_bldg_type == 'Hospital' && ['PatRoom', 'ICU_PatRm', 'ICU_Open'].include?(stds_space_type)
        num_beds = num_people
      elsif stds_bldg_type == 'Hsp' && ['PatientRoom', 'HspSurgOutptLab', 'HspNursing'].include?(stds_space_type)
        num_beds = num_people
      end

      # determine number of students
      if ['PrimarySchool', 'SecondarySchool'].include?(stds_bldg_type) && stds_space_type == 'Classroom'
        num_students += num_people * ((typical_class_size - 1.0) / typical_class_size)
      elsif ['EPr', 'ESe', 'ERC', 'EUn', 'ECC'].include?(stds_bldg_type) && stds_space_type == 'Classroom'
        num_students += num_people * ((typical_class_size - 1.0) / typical_class_size)
      end

      space_type_hash[space_type] = {}
      space_type_hash[space_type][:stds_bldg_type] = stds_bldg_type
      space_type_hash[space_type][:stds_space_type] = stds_space_type
      space_type_hash[space_type][:effective_num_spaces] = effective_num_spaces
      space_type_hash[space_type][:floor_area] = floor_area
      space_type_hash[space_type][:num_people] = num_people
      space_type_hash[space_type][:num_students] = num_students
      space_type_hash[space_type][:num_units] = num_units
      space_type_hash[space_type][:num_beds] = num_beds

      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "For #{space_type.name}, floor area = #{OpenStudio.convert(floor_area, 'm^2', 'ft^2').get.round} ft^2.") unless floor_area == 0.0
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "For #{space_type.name}, number of spaces = #{effective_num_spaces}.") unless effective_num_spaces == 0.0
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "For #{space_type.name}, number of units = #{num_units}.") unless num_units == 0.0
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "For #{space_type.name}, number of people = #{num_people.round}.") unless num_people == 0.0
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "For #{space_type.name}, number of students = #{num_students}.") unless num_students == 0.0
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "For #{space_type.name}, number of beds = #{num_beds}.") unless num_beds == 0.0
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "For #{space_type.name}, number of meals = #{num_meals}.") unless num_meals.nil?

    else
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Cannot identify standards building type and space type for #{space_type.name}, it won't be added to space_type_hash.")
    end
  end

  return space_type_hash.sort.to_h
end

#model_create_story_hash(model) ⇒ hash

Create sorted hash of stories with data need to determine effective number of stories above and below grade the key should be the story object, which would allow other measures the ability to for example loop through spaces of the bottom story

Returns:

  • (hash)

    hash of space types with data in value necessary to determine effective number of stories above and below grade



4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4190

def model_create_story_hash(model)
  story_hash = {}

  # loop through stories
  model.getBuildingStorys.sort.each do |story|
    # skip of story doesn't have any spaces
    next if story.spaces.empty?

    story_min_z = nil
    story_zone_multipliers = []
    story_spaces_part_of_floor_area = []
    story_spaces_not_part_of_floor_area = []
    story_ext_wall_area = 0.0
    story_ground_wall_area = 0.0

    # loop through space surfaces to find min z value
    story.spaces.each do |space|
      # skip of space doesn't have any geometry
      next if space.surfaces.empty?

      # get space multiplier
      story_zone_multipliers << space.multiplier

      # space part of floor area check
      if space.partofTotalFloorArea
        story_spaces_part_of_floor_area << space
      else
        story_spaces_not_part_of_floor_area << space
      end

      # update exterior wall area (not sure if this is net or gross)
      story_ext_wall_area += space.exteriorWallArea

      space_min_z = nil
      z_points = []
      space.surfaces.each do |surface|
        surface.vertices.each do |vertex|
          z_points << vertex.z
        end

        # update count of ground wall areas
        next if surface.surfaceType != 'Wall'
        next if surface.outsideBoundaryCondition != 'Ground' # TODO: - make more flexible for slab/basement model.modeling

        story_ground_wall_area += surface.grossArea
      end

      # skip if surface had no vertices
      next if z_points.empty?

      # update story min_z
      space_min_z = z_points.min + space.zOrigin
      if story_min_z.nil? || (story_min_z > space_min_z)
        story_min_z = space_min_z
      end
    end

    # update story hash
    story_hash[story] = {}
    story_hash[story][:min_z] = story_min_z
    story_hash[story][:multipliers] = story_zone_multipliers
    story_hash[story][:part_of_floor_area] = story_spaces_part_of_floor_area
    story_hash[story][:not_part_of_floor_area] = story_spaces_not_part_of_floor_area
    story_hash[story][:ext_wall_area] = story_ext_wall_area
    story_hash[story][:ground_wall_area] = story_ground_wall_area
  end

  # sort hash by min_z low to high
  story_hash = story_hash.sort_by { |k, v| v[:min_z] }

  # reassemble into hash after sorting
  hash = {}
  story_hash.each do |story, props|
    hash[story] = props
  end

  return hash
end

#model_cw_loop_cooling_tower_fan_type(model) ⇒ String

Determine which type of fan the cooling tower will have. Defaults to TwoSpeed Fan.

Returns:

  • (String)

    the fan type: TwoSpeed Fan, Variable Speed Fan



5541
5542
5543
5544
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5541

def model_cw_loop_cooling_tower_fan_type(model)
  fan_type = 'Variable Speed Fan'
  return fan_type
end

#model_differentiate_primary_secondary_thermal_zones(model, zones) ⇒ Hash

Determine which of the zones should be served by the primary HVAC system. First, eliminate zones that differ by more# than 40 full load hours per week. In this case, lighting schedule is used as the proxy for operation instead of occupancy to avoid accidentally removing transition spaces. Second, eliminate zones whose design internal loads differ from the area-weighted average of all other zones on the system by more than 10 Btu/hr*ft^2.

where the keys are ‘primary’ and ‘secondary’

Returns:

  • (Hash)

    A hash of two arrays of ThermalZones,



1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1269

def model_differentiate_primary_secondary_thermal_zones(model, zones)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', 'Determining which zones are served by the primary vs. secondary HVAC system.')

  # Determine the operational hours (proxy is annual
  # full load lighting hours) for all zones
  zone_data_1 = []
  zones.each do |zone|
    data = {}
    data['zone'] = zone
    # Get the area
    area_ft2 = OpenStudio.convert(zone.floorArea * zone.multiplier, 'm^2', 'ft^2').get
    data['area_ft2'] = area_ft2
    # OpenStudio::logFree(OpenStudio::Info, "openstudio.Standards.Model", "#{zone.name}")
    zone.spaces.each do |space|
      # OpenStudio::logFree(OpenStudio::Info, "openstudio.Standards.Model", "***#{space.name}")
      # Get all lights from either the space
      # or the space type.
      all_lights = []
      all_lights += space.lights
      if space.spaceType.is_initialized
        all_lights += space.spaceType.get.lights
      end
      # Base the annual operational hours
      # on the first lights schedule with hours
      # greater than zero.
      ann_op_hrs = 0
      all_lights.sort.each do |lights|
        # OpenStudio::logFree(OpenStudio::Info, "openstudio.Standards.Model", "******#{lights.name}")
        # Get the fractional lighting schedule
        lights_sch = lights.schedule
        full_load_hrs = 0.0
        # Skip lights with no schedule
        next if lights_sch.empty?

        lights_sch = lights_sch.get
        if lights_sch.to_ScheduleRuleset.is_initialized
          lights_sch = lights_sch.to_ScheduleRuleset.get
          full_load_hrs = schedule_ruleset_annual_equivalent_full_load_hrs(lights_sch)
          if full_load_hrs > 0
            ann_op_hrs = full_load_hrs
            break # Stop after the first schedule with more than 0 hrs
          end
        elsif lights_sch.to_ScheduleConstant.is_initialized
          lights_sch = lights_sch.to_ScheduleConstant.get
          full_load_hrs = schedule_constant_annual_equivalent_full_load_hrs(lights_sch)
          if full_load_hrs > 0
            ann_op_hrs = full_load_hrs
            break # Stop after the first schedule with more than 0 hrs
          end
        end
      end
      wk_op_hrs = ann_op_hrs / 52.0
      data['wk_op_hrs'] = wk_op_hrs
      # OpenStudio::logFree(OpenStudio::Info, "openstudio.Standards.Model", "******wk_op_hrs = #{wk_op_hrs.round}")
    end

    zone_data_1 << data
  end

  # Filter out any zones that operate differently by more than 40hrs/wk.
  # This will be determined by a difference of more than (40 hrs/wk * 52 wks/yr) = 2080 annual full load hrs.
  zones_same_hrs = model_eliminate_outlier_zones(model, zone_data_1, 'wk_op_hrs', 40, 'weekly operating hrs', 'hrs')

  # Get the internal loads for
  # all remaining zones.
  zone_data_2 = []
  zones_same_hrs.each do |zn_data|
    data = {}
    zone = zn_data['zone']
    data['zone'] = zone
    # Get the area
    area_m2 = zone.floorArea * zone.multiplier
    area_ft2 = OpenStudio.convert(area_m2, 'm^2', 'ft^2').get
    data['area_ft2'] = area_ft2
    # Get the internal loads
    int_load_w = thermal_zone_design_internal_load(zone) * zone.multiplier
    # Normalize per-area
    int_load_w_per_m2 = int_load_w / area_m2
    int_load_btu_per_ft2 = OpenStudio.convert(int_load_w_per_m2, 'W/m^2', 'Btu/hr*ft^2').get
    data['int_load_btu_per_ft2'] = int_load_btu_per_ft2
    zone_data_2 << data
  end

  # Filter out any zones that are +/- 10 Btu/hr*ft^2 from the average
  pri_zn_data = model_eliminate_outlier_zones(model, zone_data_2, 'int_load_btu_per_ft2', 10, 'internal load', 'Btu/hr*ft^2')

  # Get just the primary zones themselves
  pri_zones = []
  pri_zone_names = []
  pri_zn_data.each do |zn_data|
    pri_zones << zn_data['zone']
    pri_zone_names << zn_data['zone'].name.get.to_s
  end

  # Get the secondary zones
  sec_zones = []
  sec_zone_names = []
  zones.each do |zone|
    unless pri_zones.include?(zone)
      sec_zones << zone
      sec_zone_names << zone.name.get.to_s
    end
  end

  # Report out the primary vs. secondary zones
  unless pri_zone_names.empty?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Primary system zones = #{pri_zone_names.join(', ')}.")
  end
  unless sec_zone_names.empty?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Secondary system zones = #{sec_zone_names.join(', ')}.")
  end

  return { 'primary' => pri_zones, 'secondary' => sec_zones }
end

#model_effective_num_stories(model) ⇒ Object

populate this method Determine the effective number of stories above and below grade

Returns:

  • hash with effective_num_stories_below_grade and effective_num_stories_above_grade



4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4273

def model_effective_num_stories(model)
  below_grade = 0
  above_grade = 0

  # call model_create_story_hash(model)
  story_hash = model_create_story_hash(model)

  story_hash.each do |story, hash|
    # skip if no spaces in story are included in the building area
    next if hash[:part_of_floor_area].empty?

    # only count as below grade if ground wall area is greater than ext wall area and story below is also below grade
    if above_grade.zero? && (hash[:ground_wall_area] > hash[:ext_wall_area])
      below_grade += 1 * hash[:multipliers].min
    else
      above_grade += 1 * hash[:multipliers].min
    end
  end

  # populate hash
  effective_num_stories = {}
  effective_num_stories[:below_grade] = below_grade
  effective_num_stories[:above_grade] = above_grade
  effective_num_stories[:story_hash] = story_hash

  return effective_num_stories
end

#model_elevator_fan_pwr(model, vent_rate_cfm) ⇒ Double

Determines the power of the elevator ventilation fan. Defaults to 90.1-2010, which had no requirement for ventilation fan efficiency.

Returns:

  • (Double)

    the ventilation fan power (W)



134
135
136
137
138
139
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.elevators.rb', line 134

def model_elevator_fan_pwr(model, vent_rate_cfm)
  vent_pwr_per_flow_w_per_cfm = 0.33
  vent_pwr_w = vent_pwr_per_flow_w_per_cfm * vent_rate_cfm

  return vent_pwr_w
end

#model_elevator_lift_power(model, elevator_type, building_type) ⇒ Object

Determines the power required by an individual elevator of a given type. Defaults to the values used by the DOE prototype buildings. Traction, Hydraulic

Parameters:

  • elevator_type (String)

    valid choices are



107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.elevators.rb', line 107

def model_elevator_lift_power(model, elevator_type, building_type)
  lift_pwr_w = 0
  if elevator_type == 'Traction'
    lift_pwr_w += 20_370.0
  elsif elevator_type == 'Hydraulic'
    lift_pwr_w += 16_055.0
  else
    lift_pwr_w += 16_055.0
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', "Elevator type '#{elevator_type}', not recognized, will assume Hydraulic elevator, #{lift_pwr_w} W.")
  end

  return lift_pwr_w
end

#model_elevator_lighting_pct_incandescent(model) ⇒ Object

Determines the percentage of the elevator cab lighting that is incandescent. The remainder is assumed to be LED. Defaults to 70% incandescent, representing older elevators.



125
126
127
128
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.elevators.rb', line 125

def model_elevator_lighting_pct_incandescent(model)
  pct_incandescent = 0.7
  return pct_incandescent
end

#model_eliminate_outlier_zones(model, array_of_zones, key_to_inspect, tolerance, field_name, units) ⇒ Object

Parameters:

  • array_of_zones (Array)

    an array of Hashes for each zone, with the keys ‘zone’,



1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1191

def model_eliminate_outlier_zones(model, array_of_zones, key_to_inspect, tolerance, field_name, units)
  # Sort the zones by the desired key
  begin
    array_of_zones = array_of_zones.sort_by { |hsh| hsh[key_to_inspect] }
  rescue ArgumentError => e
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Unable to sort array_of_zones by #{key_to_inspect} due to #{e.message}, defaulting to order that was passed")
  end

  # Calculate the area-weighted average
  total = 0.0
  total_area = 0.0
  all_vals = []
  all_areas = []
  all_zn_names = []
  array_of_zones.each do |zn|
    val = zn[key_to_inspect]
    area = zn['area_ft2']
    total += val * area
    total_area += area
    all_vals << val.round(1)
    all_areas << area.round
    all_zn_names << zn['zone'].name.get.to_s
  end

  if total_area == 0
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Total area is zero for array_of_zones with key #{key_to_inspect}, unable to calculate area-weighted average.")
    return false
  end

  avg = total / total_area
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "Values for #{field_name}, tol = #{tolerance} #{units}, area ft2:")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "vals  #{all_vals.join(', ')}")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "areas #{all_areas.join(', ')}")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "names #{all_zn_names.join(', ')}")

  # Calculate the biggest delta and the index of the biggest delta
  biggest_delta_i = 0 # array at first item in case delta is 0
  biggest_delta = 0.0
  worst = nil
  array_of_zones.each_with_index do |zn, i|
    val = zn[key_to_inspect]
    if worst.nil? # array at first item in case delta is 0
      worst = val
    end
    delta = (val - avg).abs
    if delta >= biggest_delta
      biggest_delta = delta
      biggest_delta_i = i
      worst = val
    end
  end

  # puts "   #{worst} - #{avg.round} = #{biggest_delta.round} biggest delta"

  # Compare the biggest delta against the difference and eliminate that zone if higher than the limit.
  if biggest_delta > tolerance
    zn_name = array_of_zones[biggest_delta_i]['zone'].name.get.to_s
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "For zone #{zn_name}, the #{field_name} of #{worst.round(1)} #{units} is more than #{tolerance} #{units} outside the area-weighted average of #{avg.round(1)} #{units}; it will be placed on its own secondary system.")
    array_of_zones.delete_at(biggest_delta_i)
    # Call method recursively if something was eliminated
    array_of_zones = model_eliminate_outlier_zones(model, array_of_zones, key_to_inspect, tolerance, field_name, units)
  else
    zn_name = array_of_zones[biggest_delta_i]['zone'].name.get.to_s
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "For zone #{zn_name}, the #{field_name} #{worst.round(2)} #{units} - average #{field_name} #{avg.round(2)} #{units} = #{biggest_delta.round(2)} #{units} less than the tolerance of #{tolerance} #{units}, stopping elimination process.")
  end

  return array_of_zones
end

#model_find_and_add_construction(model, climate_zone_set, intended_surface_type, standards_construction_type, building_category) ⇒ Object

Helper method to find a particular construction and add it to the model after modifying the insulation value if necessary.



2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2442

def model_find_and_add_construction(model, climate_zone_set, intended_surface_type, standards_construction_type, building_category)
  # Get the construction properties,
  # which specifies properties by construction category by climate zone set.
  # AKA the info in Tables 5.5-1-5.5-8

  props = model_find_object(standards_data['construction_properties'],
                            'template' => template,
                            'climate_zone_set' => climate_zone_set,
                            'intended_surface_type' => intended_surface_type,
                            'standards_construction_type' => standards_construction_type,
                            'building_category' => building_category)

  if !props
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Could not find construction properties for: #{template}-#{climate_zone_set}-#{intended_surface_type}-#{standards_construction_type}-#{building_category}.")
    # Return an empty construction
    construction = OpenStudio::Model::Construction.new(model)
    construction.setName('Could not find construction properties set to Adiabatic ')
    almost_adiabatic = OpenStudio::Model::MasslessOpaqueMaterial.new(model, 'Smooth', 500)
    construction.insertLayer(0, almost_adiabatic)
    return construction
  else
    # OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Construction properties for: #{template}-#{climate_zone_set}-#{intended_surface_type}-#{standards_construction_type}-#{building_category} = #{props}.")
  end

  # Make sure that a construction is specified
  if props['construction'].nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "No typical construction is specified for construction properties of: #{template}-#{climate_zone_set}-#{intended_surface_type}-#{standards_construction_type}-#{building_category}.  Make sure it is entered in the spreadsheet.")
    # Return an empty construction
    construction = OpenStudio::Model::Construction.new(model)
    construction.setName('No typical construction was specified')
    return construction
  end

  # Add the construction, modifying properties as necessary
  construction = model_add_construction(model, props['construction'], props)

  return construction
end

#model_find_ashrae_hot_water_demand(model) ⇒ Array

Returns average daily hot water consumption by building type recommendations from 2011 ASHRAE Handbook - HVAC Applications Table 7 section 50.14 Not all building types are included in lookup some recommendations have multiple values based on number of units. Will return an array of hashes. Many may have one array entry. all values other than block size are gallons.

specific to building type. Array will be empty for some building types.

Returns:

  • (Array)

    array of hashes. Each array entry based on different capacity



3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3947

def model_find_ashrae_hot_water_demand(model)
  # TODO: - for types not in table use standards area normalized swh values

  # get building type
  building_data = model_get_building_climate_zone_and_building_type(model)
  building_type = building_data['building_type']

  result = []
  if building_type == 'FullServiceRestaurant'
    result << { units: 'meal', block: nil, max_hourly: 1.5, max_daily: 11.0, avg_day_unit: 2.4 }
  elsif building_type == 'Hospital'
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "No SWH rules of thumbs for #{building_type}.")
  elsif ['LargeHotel', 'SmallHotel'].include? building_type
    result << { units: 'unit', block: 20, max_hourly: 6.0, max_daily: 35.0, avg_day_unit: 24.0 }
    result << { units: 'unit', block: 60, max_hourly: 5.0, max_daily: 25.0, avg_day_unit: 14.0 }
    result << { units: 'unit', block: 100, max_hourly: 4.0, max_daily: 15.0, avg_day_unit: 10.0 }
  elsif building_type == 'MidriseApartment'
    result << { units: 'unit', block: 20, max_hourly: 12.0, max_daily: 80.0, avg_day_unit: 42.0 }
    result << { units: 'unit', block: 50, max_hourly: 10.0, max_daily: 73.0, avg_day_unit: 40.0 }
    result << { units: 'unit', block: 75, max_hourly: 8.5, max_daily: 66.0, avg_day_unit: 38.0 }
    result << { units: 'unit', block: 100, max_hourly: 7.0, max_daily: 60.0, avg_day_unit: 37.0 }
    result << { units: 'unit', block: 200, max_hourly: 5.0, max_daily: 50.0, avg_day_unit: 35.0 }
  elsif ['Office', 'LargeOffice', 'MediumOffice', 'SmallOffice', 'LargeOfficeDetailed', 'MediumOfficeDetailed', 'SmallOfficeDetailed'].include? building_type
    result << { units: 'person', block: nil, max_hourly: 0.4, max_daily: 2.0, avg_day_unit: 1.0 }
  elsif building_type == 'Outpatient'
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "No SWH rules of thumbs for #{building_type}.")
  elsif building_type == 'PrimarySchool'
    result << { units: 'student', block: nil, max_hourly: 0.6, max_daily: 1.5, avg_day_unit: 0.6 }
  elsif building_type == 'QuickServiceRestaurant'
    result << { units: 'meal', block: nil, max_hourly: 0.7, max_daily: 6.0, avg_day_unit: 0.7 }
  elsif building_type == 'Retail'
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "No SWH rules of thumbs for #{building_type}.")
  elsif building_type == 'SecondarySchool'
    result << { units: 'student', block: nil, max_hourly: 1.0, max_daily: 3.6, avg_day_unit: 1.8 }
  elsif building_type == 'StripMall'
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "No SWH rules of thumbs for #{building_type}.")
  elsif building_type == 'SuperMarket'
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "No SWH rules of thumbs for #{building_type}.")
  elsif building_type == 'Warehouse'
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "No SWH rules of thumbs for #{building_type}.")
  elsif ['SmallDataCenterLowITE', 'SmallDataCenterHighITE', 'LargeDataCenterLowITE', 'LargeDataCenterHighITE', 'Laboratory'].include? building_type
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "No SWH rules of thumbs for #{building_type}.")
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Didn't find expected building type. As a result can't determine hot water demand recommendations")
  end

  return result
end

#model_find_climate_zone_set(model, clim) ⇒ Object

Helper method to find out which climate zone set contains a specific climate zone. Returns climate zone set name as String if success, nil if not found.



4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4116

def model_find_climate_zone_set(model, clim)
  result = nil

  possible_climate_zone_sets = []
  standards_data['climate_zone_sets'].each do |climate_zone_set|
    if climate_zone_set['climate_zones'].include?(clim)
      possible_climate_zone_sets << climate_zone_set['name']
    end
  end

  # Check the results
  if possible_climate_zone_sets.size.zero?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Cannot find a climate zone set containing #{clim}.  Make sure to use ASHRAE standards with ASHRAE climate zones and DEER or CA Title 24 standards with CEC climate zones.")
  elsif possible_climate_zone_sets.size > 2
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Found more than 2 climate zone sets containing #{clim}; will return last matching climate zone set.")
  end

  # Get the climate zone from the possible set
  climate_zone_set = model_get_climate_zone_set_from_list(model, possible_climate_zone_sets)

  # Check that a climate zone set was found
  if climate_zone_set.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Cannot find a climate zone set in standard #{template}")
  end

  return climate_zone_set
end

#model_find_constructions(model, boundary_condition, type) ⇒ Object

Get a unique list of constructions with given boundary condition and a given type of surface. Pulls from both default construction sets and hard-assigned constructions.

valid choices are: Adiabatic Surface Outdoors Ground valid choices are: AtticFloor AtticWall AtticRoof DemisingFloor DemisingWall DemisingRoof ExteriorFloor ExteriorWall ExteriorRoof ExteriorWindow ExteriorDoor GlassDoor GroundContactFloor GroundContactWall GroundContactRoof InteriorFloor InteriorWall InteriorCeiling InteriorPartition InteriorWindow InteriorDoor OverheadDoor Skylight TubularDaylightDome TubularDaylightDiffuser return [Array<OpenStudio::Model::ConstructionBase>] an array of all constructions.

Parameters:

  • boundary_condition (String)

    the desired boundary condition

  • type (String)

    the type of surface to find



3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3188

def model_find_constructions(model, boundary_condition, type)
  constructions = []

  # From default construction sets
  model.getDefaultConstructionSets.sort.each do |const_set|
    ext_surfs = const_set.defaultExteriorSurfaceConstructions
    int_surfs = const_set.defaultInteriorSurfaceConstructions
    gnd_surfs = const_set.defaultGroundContactSurfaceConstructions
    ext_subsurfs = const_set.defaultExteriorSubSurfaceConstructions
    int_subsurfs = const_set.defaultInteriorSubSurfaceConstructions

    # Can't handle incomplete construction sets
    if ext_surfs.empty? ||
       int_surfs.empty? ||
       gnd_surfs.empty? ||
       ext_subsurfs.empty? ||
       int_subsurfs.empty?

      OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Space', "Default construction set #{const_set.name} is incomplete; constructions from this set will not be reported.")
      next
    end

    ext_surfs = ext_surfs.get
    int_surfs = int_surfs.get
    gnd_surfs = gnd_surfs.get
    ext_subsurfs = ext_subsurfs.get
    int_subsurfs = int_subsurfs.get

    case type
      # Exterior Surfaces
      when 'ExteriorWall', 'AtticWall'
        constructions << ext_surfs.wallConstruction
      when 'ExteriorFloor'
        constructions << ext_surfs.floorConstruction
      when 'ExteriorRoof', 'AtticRoof'
        constructions << ext_surfs.roofCeilingConstruction
      # Interior Surfaces
      when 'InteriorWall', 'DemisingWall', 'InteriorPartition'
        constructions << int_surfs.wallConstruction
      when 'InteriorFloor', 'AtticFloor', 'DemisingFloor'
        constructions << int_surfs.floorConstruction
      when 'InteriorCeiling', 'DemisingRoof'
        constructions << int_surfs.roofCeilingConstruction
      # Ground Contact Surfaces
      when 'GroundContactWall'
        constructions << gnd_surfs.wallConstruction
      when 'GroundContactFloor'
        constructions << gnd_surfs.floorConstruction
      when 'GroundContactRoof'
        constructions << gnd_surfs.roofCeilingConstruction
      # Exterior SubSurfaces
      when 'ExteriorWindow'
        constructions << ext_subsurfs.fixedWindowConstruction
        constructions << ext_subsurfs.operableWindowConstruction
      when 'ExteriorDoor'
        constructions << ext_subsurfs.doorConstruction
      when 'GlassDoor'
        constructions << ext_subsurfs.glassDoorConstruction
      when 'OverheadDoor'
        constructions << ext_subsurfs.overheadDoorConstruction
      when 'Skylight'
        constructions << ext_subsurfs.skylightConstruction
      when 'TubularDaylightDome'
        constructions << ext_subsurfs.tubularDaylightDomeConstruction
      when 'TubularDaylightDiffuser'
        constructions << ext_subsurfs.tubularDaylightDiffuserConstruction
      # Interior SubSurfaces
      when 'InteriorWindow'
        constructions << int_subsurfs.fixedWindowConstruction
        constructions << int_subsurfs.operableWindowConstruction
      when 'InteriorDoor'
        constructions << int_subsurfs.doorConstruction
    end
  end

  # Hard-assigned surfaces
  model.getSurfaces.sort.each do |surf|
    next unless surf.outsideBoundaryCondition == boundary_condition

    surf_type = surf.surfaceType
    if surf_type == 'Floor' || surf_type == 'Wall'
      next unless type.include?(surf_type)
    elsif surf_type == 'RoofCeiling'
      next unless type.include?('Roof') || type.include?('Ceiling')
    end
    constructions << surf.construction
  end

  # Hard-assigned subsurfaces
  model.getSubSurfaces.sort.each do |surf|
    next unless surf.outsideBoundaryCondition == boundary_condition

    surf_type = surf.subSurfaceType
    if surf_type == 'FixedWindow' || surf_type == 'OperableWindow'
      next unless type == 'ExteriorWindow'
    elsif surf_type == 'Door'
      next unless type.include?('Door')
    else
      next unless surf.subSurfaceType == type
    end
    constructions << surf.construction
  end

  # Throw out the empty constructions
  all_constructions = []
  constructions.uniq.each do |const|
    next if const.empty?

    all_constructions << const.get
  end

  # Only return the unique list (should already be uniq)
  all_constructions = all_constructions.uniq

  # ConstructionBase can be sorted
  all_constructions = all_constructions.sort

  return all_constructions
end

#model_find_icc_iecc_2015_hot_water_demand(model, units_per_bldg, bedrooms_per_unit) ⇒ Double

Returns average daily hot water consumption for residential buildings gal/day from ICC IECC 2015 Residential Standard Reference Design from Table R405.5.2(1)

Returns:

  • (Double)

    gal/day



4001
4002
4003
4004
4005
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4001

def model_find_icc_iecc_2015_hot_water_demand(model, units_per_bldg, bedrooms_per_unit)
  swh_gal_per_day = units_per_bldg * (30.0 + (10.0 * bedrooms_per_unit))

  return swh_gal_per_day
end

#model_find_icc_iecc_2015_internal_loads(model, units_per_bldg, bedrooms_per_unit) ⇒ Hash

Returns average daily internal loads for residential buildings from Table R405.5.2(1)

Returns:

  • (Hash)

    mech_vent_cfm, infiltration_ach, igain_btu_per_day, internal_mass_lbs



4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4010

def model_find_icc_iecc_2015_internal_loads(model, units_per_bldg, bedrooms_per_unit)
  # get total and conditioned floor area
  total_floor_area = model.getBuilding.floorArea
  if model.getBuilding.conditionedFloorArea.is_initialized
    conditioned_floor_area = model.getBuilding.conditionedFloorArea.get
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', 'Cannot find conditioned floor area, will use total floor area.')
    conditioned_floor_area = total_floor_area
  end

  # get climate zone value
  climate_zone = model_standards_climate_zone(model)

  internal_loads = {}
  internal_loads['mech_vent_cfm'] = units_per_bldg * (0.01 * conditioned_floor_area + 7.5 * (bedrooms_per_unit + 1.0))
  internal_loads['infiltration_ach'] = if ['1A', '1B', '2A', '2B'].include? climate_zone_value
                                         5.0
                                       else
                                         3.0
                                       end
  internal_loads['igain_btu_per_day'] = units_per_bldg * (17_900.0 + 23.8 * conditioned_floor_area + 4104.0 * bedrooms_per_unit)
  internal_loads['internal_mass_lbs'] = total_floor_area * 8.0

  return internal_loads
end

#model_find_object(hash_of_objects, search_criteria, capacity = nil, date = nil, area = nil, num_floors = nil) ⇒ Hash

Method to search through a hash for an object that meets the desired search criteria, as passed via a hash. If capacity is supplied, the object will only be returned if the specified capacity is between the minimum_capacity and maximum_capacity values.

Examples:

Find the motor that meets these size criteria

search_criteria = {
'template' => template,
'number_of_poles' => 4.0,
'type' => 'Enclosed',
}
motor_properties = self.model.find_object(motors, search_criteria, capacity: 2.5)

Parameters:

  • hash_of_objects (Hash)

    hash of objects to search through

  • search_criteria (Hash)

    hash of search criteria

  • capacity (Double) (defaults to: nil)

    capacity of the object in question. If capacity is supplied, the objects will only be returned if the specified capacity is between the minimum_capacity and maximum_capacity values.

  • date (<OpenStudio::Date>) (defaults to: nil)

    date of the object in question. If date is supplied, the objects will only be returned if the specified date is between the start_date and end_date.

  • area (Double) (defaults to: nil)

    area of the object in question. If area is supplied, the objects will only be returned if the specified area is between the minimum_area and maximum_area values.

  • num_floors (Double) (defaults to: nil)

    capacity of the object in question. If num_floors is supplied, the objects will only be returned if the specified num_floors is between the minimum_floors and maximum_floors values.

Returns:

  • (Hash)

    Return tbe first matching object hash if successful, nil if not.



1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1735

def model_find_object(hash_of_objects, search_criteria, capacity = nil, date = nil, area = nil, num_floors = nil)
  matching_objects = model_find_objects(hash_of_objects, search_criteria, capacity, date, area, num_floors)

  # Check the number of matching objects found
  if matching_objects.size.zero?
    desired_object = nil
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "Find object search criteria returned no results. Search criteria: #{search_criteria}. Called from #{caller(0)[1]}")
  elsif matching_objects.size == 1
    desired_object = matching_objects[0]
  else
    desired_object = matching_objects[0]
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Model', "Find object search criteria returned #{matching_objects.size} results, the first one will be returned. Called from #{caller(0)[1]}. \n Search criteria: \n #{search_criteria}, capacity = #{capacity} \n  All results: \n #{matching_objects.join("\n")}")
  end

  return desired_object
end

#model_find_objects(hash_of_objects, search_criteria, capacity = nil, date = nil, area = nil, num_floors = nil) ⇒ Array

Method to search through a hash for the objects that meets the desired search criteria, as passed via a hash. Returns an Array (empty if nothing found) of matching objects.

Examples:

Find all the schedule rules that match the name

rules = model_find_objects(standards_data['schedules'], 'name' => schedule_name)
if rules.size.zero?
  OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Cannot find data for schedule: #{schedule_name}, will not be created.")
  return false
end

Parameters:

  • hash_of_objects (Hash)

    hash of objects to search through

  • search_criteria (Hash)

    hash of search criteria

  • capacity (Double) (defaults to: nil)

    capacity of the object in question. If capacity is supplied, the objects will only be returned if the specified capacity is between the minimum_capacity and maximum_capacity values.

  • date (<OpenStudio::Date>) (defaults to: nil)

    date of the object in question. If date is supplied, the objects will only be returned if the specified date is between the start_date and end_date.

  • area (Double) (defaults to: nil)

    area of the object in question. If area is supplied, the objects will only be returned if the specified area is between the minimum_area and maximum_area values.

  • num_floors (Double) (defaults to: nil)

    capacity of the object in question. If num_floors is supplied, the objects will only be returned if the specified num_floors is between the minimum_floors and maximum_floors values.

Returns:

  • (Array)

    returns an array of hashes, one hash per object. Array is empty if no results.



1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1616

def model_find_objects(hash_of_objects, search_criteria, capacity = nil, date = nil, area = nil, num_floors = nil)
  matching_objects = []
  if hash_of_objects.is_a?(Hash) && hash_of_objects.key?('table')
    hash_of_objects = hash_of_objects['table']
  end

  # Compare each of the objects against the search criteria
  raise("This is not a table #{hash_of_objects}") unless hash_of_objects.respond_to?(:each)

  hash_of_objects.each do |object|
    meets_all_search_criteria = true
    search_criteria.each do |key, value|
      # Don't check non-existent search criteria
      next unless object.key?(key)

      # Stop as soon as one of the search criteria is not met
      # 'Any' is a special key that matches anything
      unless object[key] == value || object[key] == 'Any'
        meets_all_search_criteria = false
        break
      end
    end
    # Skip objects that don't meet all search criteria
    next unless meets_all_search_criteria

    # If made it here, object matches all search criteria
    matching_objects << object
  end

  # If capacity was specified, narrow down the matching objects
  unless capacity.nil?
    # Skip objects that don't have fields for minimum_capacity and maximum_capacity
    matching_objects = matching_objects.reject { |object| !object.key?('minimum_capacity') || !object.key?('maximum_capacity') }

    # Skip objects that don't have values specified for minimum_capacity and maximum_capacity
    matching_objects = matching_objects.reject { |object| object['minimum_capacity'].nil? || object['maximum_capacity'].nil? }

    # Round up if capacity is an integer
    if capacity == capacity.round
      capacity += (capacity * 0.01)
    end
    # Skip objects whose the minimum capacity is below or maximum capacity above the specified capacity
    matching_capacity_objects = matching_objects.reject { |object| capacity.to_f <= object['minimum_capacity'].to_f || capacity.to_f > object['maximum_capacity'].to_f }

    # If no object was found, round the capacity down in case the number fell between the limits in the json file.
    if matching_capacity_objects.size.zero?
      capacity *= 0.99
      # Skip objects whose minimum capacity is below or maximum capacity above the specified capacity
      matching_objects = matching_objects.reject { |object| capacity.to_f <= object['minimum_capacity'].to_f || capacity.to_f > object['maximum_capacity'].to_f }
    else
      matching_objects = matching_capacity_objects
    end
  end

  # If date was specified, narrow down the matching objects
  unless date.nil?
    # Skip objects that don't have fields for start_date and end_date
    matching_objects = matching_objects.reject { |object| !object.key?('start_date') || !object.key?('end_date') }

    # Skip objects whose start date is earlier than the specified date
    matching_objects = matching_objects.reject { |object| date <= Date.parse(object['start_date']) }

    # Skip objects whose end date is later than the specified date
    matching_objects = matching_objects.reject { |object| date > Date.parse(object['end_date']) }
  end

  # If area was specified, narrow down the matching objects
  unless area.nil?
    # Skip objects that don't have fields for minimum_area and maximum_area
    matching_objects = matching_objects.reject { |object| !object.key?('minimum_area') || !object.key?('maximum_area') }

    # Skip objects that don't have values specified for minimum_area and maximum_area
    matching_objects = matching_objects.reject { |object| object['minimum_area'].nil? || object['maximum_area'].nil? }

    # Skip objects whose minimum area is below or maximum area is above area
    matching_objects = matching_objects.reject { |object| area.to_f <= object['minimum_area'].to_f || area.to_f > object['maximum_area'].to_f }
  end

  # If area was specified, narrow down the matching objects
  unless num_floors.nil?
    # Skip objects that don't have fields for minimum_floors and maximum_floors
    matching_objects = matching_objects.reject { |object| !object.key?('minimum_floors') || !object.key?('maximum_floors') }

    # Skip objects that don't have values specified for minimum_floors and maximum_floors
    matching_objects = matching_objects.reject { |object| object['minimum_floors'].nil? || object['maximum_floors'].nil? }

    # Skip objects whose minimum floors is below or maximum floors is above num_floors
    matching_objects = matching_objects.reject { |object| num_floors.to_f < object['minimum_floors'].to_f || num_floors.to_f > object['maximum_floors'].to_f }
  end

  # Check the number of matching objects found
  if matching_objects.size.zero?
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "Find objects search criteria returned no results. Search criteria: #{search_criteria}. Called from #{caller(0)[1]}.")
  end

  return matching_objects
end

#model_find_prototype_floor_area(model, building_type) ⇒ Double

Keep track of floor area for prototype buildings. This is used to calculate EUI’s to compare against non prototype buildings Areas taken from scorecard Excel Files

Parameters:

  • building_type (String)

    the building type

Returns:

  • (Double)

    floor area (m^2) of prototype building for building type passed in. Returns nil if unexpected building type



2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2984

def model_find_prototype_floor_area(model, building_type)
  if building_type == 'FullServiceRestaurant' # 5502 ft^2
    result = 511
  elsif building_type == 'Hospital' # 241,410 ft^2 (including basement)
    result = 22_422
  elsif building_type == 'LargeHotel' # 122,132 ft^2
    result = 11_345
  elsif building_type == 'LargeOffice' # 498,600 ft^2
    result = 46_320
  elsif building_type == 'MediumOffice' # 53,600 ft^2
    result = 4982
  elsif building_type == 'LargeOfficeDetailed' # 498,600 ft^2
    result = 46_320
  elsif building_type == 'MediumOfficeDetailed' # 53,600 ft^2
    result = 4982
  elsif building_type == 'MidriseApartment' # 33,700 ft^2
    result = 3135
  elsif building_type == 'Office'
    result = nil
    # TODO: there shouldn't be a prototype building for this
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', 'Measures calling this should choose between SmallOffice, MediumOffice, and LargeOffice')
  elsif building_type == 'Outpatient' # 40.950 ft^2
    result = 3804
  elsif building_type == 'PrimarySchool' # 73,960 ft^2
    result = 6871
  elsif building_type == 'QuickServiceRestaurant' # 2500 ft^2
    result = 232
  elsif building_type == 'Retail' # 24,695 ft^2
    result = 2294
  elsif building_type == 'SecondarySchool' # 210,900 ft^2
    result = 19_592
  elsif building_type == 'SmallHotel' # 43,200 ft^2
    result = 4014
  elsif building_type == 'SmallOffice' # 5500 ft^2
    result = 511
  elsif building_type == 'SmallOfficeDetailed' # 5500 ft^2
    result = 511
  elsif building_type == 'StripMall' # 22,500 ft^2
    result = 2090
  elsif building_type == 'SuperMarket' # 45,002 ft2 (from legacy reference idf file)
    result = 4181
  elsif building_type == 'Warehouse' # 49,495 ft^2 (legacy ref shows 52,045, but I wil calc using 49,495)
    result = 4595
  elsif building_type == 'SmallDataCenterLowITE' || building_type == 'SmallDataCenterHighITE'  # 600 ft^2
    result = 56
  elsif building_type == 'LargeDataCenterLowITE' || building_type == 'LargeDataCenterHighITE'  # 6000 ft^2
    result = 557
  elsif building_type == 'Laboratory' # 90000 ft^2
    result = 8361
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Didn't find expected building type. As a result can't determine floor prototype floor area")
    result = nil
  end

  return result
end

#model_find_target_eui(model) ⇒ Double

user needs to pass in template as string. The building type and climate zone will come from the model. If the building type or ASHRAE climate zone is not set in the model this will return nil If the lookup doesn’t find matching simulation results this wil return nil

Returns:

  • (Double)

    EUI (MJ/m^2) for target template for given OSM. Returns nil if can’t calculate EUI



3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3090

def model_find_target_eui(model)
  building_data = model_get_building_climate_zone_and_building_type(model)
  climate_zone = building_data['climate_zone']
  building_type = building_data['building_type']

  # look up results
  target_consumption = model_process_results_for_datapoint(model, climate_zone, building_type)

  # lookup target floor area for prototype buildings
  target_floor_area = model_find_prototype_floor_area(model, building_type)

  if target_consumption['total_legacy_energy_val'] > 0
    if target_floor_area > 0
      result = target_consumption['total_legacy_energy_val'] / target_floor_area
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', 'Cannot find prototype building floor area')
      result = nil
    end
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Cannot find target results for #{climate_zone},#{building_type},#{template}")
    result = nil # couldn't calculate EUI consumpiton lookup failed
  end

  return result
end

#model_find_target_eui_by_end_use(model) ⇒ Hash

user needs to pass in template as string. The building type and climate zone will come from the model. If the building type or ASHRAE climate zone is not set in the model this will return nil If the lookup doesn’t find matching simulation results this wil return nil

Returns:

  • (Hash)

    EUI (MJ/m^2) This will return a hash of end uses. key is end use, value is eui



3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3121

def model_find_target_eui_by_end_use(model)
  building_data = model_get_building_climate_zone_and_building_type(model)
  climate_zone = building_data['climate_zone']
  building_type = building_data['building_type']

  # look up results
  target_consumption = model_process_results_for_datapoint(model, climate_zone, building_type)

  # lookup target floor area for prototype buildings
  target_floor_area = model_find_prototype_floor_area(model, building_type)

  if target_consumption['total_legacy_energy_val'] > 0
    if target_floor_area > 0
      result = {}
      target_consumption['total_energy_by_end_use'].each do |end_use, consumption|
        result[end_use] = consumption / target_floor_area
      end
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', 'Cannot find prototype building floor area')
      result = nil
    end
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Cannot find target results for #{climate_zone},#{building_type},#{template}")
    result = nil # couldn't calculate EUI consumpiton lookup failed
  end

  return result
end

#model_find_water_heater_capacity_volume_and_parasitic(model, water_use_equipment_array, storage_to_cap_ratio_gal_to_kbtu_per_hr: 1.0, htg_eff: 0.8, inlet_temp_f: 40.0, target_temp_f: 140.0, peak_flow_fraction: 1.0) ⇒ Hash

Use rules from DOE Prototype Building documentation to determine water heater capacity, volume, pipe dump losses, and pipe thermal losses.

Parameters:

  • water_use_equipment_array (Array)

    array of water use equipment objects that will be using this water heater

  • storage_to_cap_ratio_gal_to_kbtu_per_hr (Double) (defaults to: 1.0)

    storage volume gal to kBtu/hr of capacity

  • htg_eff (Double) (defaults to: 0.8)

    water heater thermal efficiency, fraction

  • inlet_temp_f (Double) (defaults to: 40.0)

    inlet cold water temperature, degrees Fahrenheit

  • target_temp_f (Double) (defaults to: 140.0)

    target supply water temperatre from the tank, degrees Fahrenheit

Returns:

  • (Hash)

    hash with values needed to size water heater made with downstream method



520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.swh.rb', line 520

def model_find_water_heater_capacity_volume_and_parasitic(model,
                                                          water_use_equipment_array,
                                                          storage_to_cap_ratio_gal_to_kbtu_per_hr: 1.0,
                                                          htg_eff: 0.8,
                                                          inlet_temp_f: 40.0,
                                                          target_temp_f: 140.0,
                                                          peak_flow_fraction: 1.0)
  # A.1.4 Total Storage Volume and Water Heater Capacity of PrototypeModelEnhancements_2014_0.pdf shows 1 gallon of storage to 1 kBtu/h of capacity

  water_heater_sizing = {}

  # Get the maximum flow rates for all pieces of water use equipment
  adjusted_max_flow_rates_gal_per_hr = [] # gallons per hour
  water_use_equipment_array.sort.each do |water_use_equip|
    water_use_equip_sch = water_use_equip.flowRateFractionSchedule
    next if water_use_equip_sch.empty?

    water_use_equip_sch = water_use_equip_sch.get
    if water_use_equip_sch.to_ScheduleRuleset.is_initialized
      water_use_equip_sch = water_use_equip_sch.to_ScheduleRuleset.get
      max_sch_value = schedule_ruleset_annual_min_max_value(water_use_equip_sch)['max']
    elsif water_use_equip_sch.to_ScheduleConstant.is_initialized
      water_use_equip_sch = water_use_equip_sch.to_ScheduleConstant.get
      max_sch_value = schedule_constant_annual_min_max_value(water_use_equip_sch)['max']
    elsif water_use_equip_sch.to_ScheduleCompact.is_initialized
      water_use_equip_sch = water_use_equip_sch.to_ScheduleCompact.get
      max_sch_value = schedule_compact_annual_min_max_value(water_use_equip_sch)['max']
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', "The peak flow rate fraction for #{water_use_equip_sch.name} could not be determined, assuming 1 for water heater sizing purposes.")
      max_sch_value = 1.0
    end

    # Get peak flow rate from water use equipment definition
    peak_flow_rate_m3_per_s = water_use_equip.waterUseEquipmentDefinition.peakFlowRate

    # Calculate adjusted flow rate based on the peak fraction found in the flow rate fraction schedule
    adjusted_peak_flow_rate_m3_per_s = max_sch_value * peak_flow_rate_m3_per_s
    adjusted_max_flow_rates_gal_per_hr << OpenStudio.convert(adjusted_peak_flow_rate_m3_per_s, 'm^3/s', 'gal/hr').get
  end

  # Sum gph values from water use equipment to use in formula
  total_adjusted_flow_rate_gal_per_hr = adjusted_max_flow_rates_gal_per_hr.inject(:+)

  # Calculate capacity based on analysis of combined water use equipment maximum flow rates and schedules
  # Max gal/hr * 8.4 lb/gal * 1 Btu/lb F * (120F - 40F)/0.8 = Btu/hr
  water_heater_capacity_btu_per_hr = peak_flow_fraction * total_adjusted_flow_rate_gal_per_hr * 8.4 * 1.0 * (target_temp_f - inlet_temp_f) / htg_eff
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Capacity of #{water_heater_capacity_btu_per_hr.round} Btu/hr = #{peak_flow_fraction} peak fraction * #{total_adjusted_flow_rate_gal_per_hr.round} gal/hr * 8.4 lb/gal * 1.0 Btu/lb F * (#{target_temp_f.round} - #{inlet_temp_f.round} deltaF / #{htg_eff} htg eff).")
  water_heater_capacity_m3_per_s = OpenStudio.convert(water_heater_capacity_btu_per_hr, 'Btu/hr', 'W').get

  # Calculate volume based on capacity
  # Default assumption is 1 gal of volume per 1 kBtu/hr of heating capacity
  water_heater_capacity_kbtu_per_hr = OpenStudio.convert(water_heater_capacity_btu_per_hr, 'Btu/hr', 'kBtu/hr').get
  water_heater_volume_gal = water_heater_capacity_kbtu_per_hr * storage_to_cap_ratio_gal_to_kbtu_per_hr
  # increase tank size to 40 galons if calculated value is smaller
  water_heater_volume_gal = 40.0 if water_heater_volume_gal < 40.0 # gal
  water_heater_volume_m3 = OpenStudio.convert(water_heater_volume_gal, 'gal', 'm^3').get

  # Populate return hash
  water_heater_sizing[:water_heater_capacity] = water_heater_capacity_m3_per_s
  water_heater_sizing[:water_heater_volume] = water_heater_volume_m3

  return water_heater_sizing
end

#model_get_baseline_system_type_by_zone(model, climate_zone, custom = nil) ⇒ Hash

Looks through the model and creates an hash of what the baseline system type should be for each zone.

PTHP, PTAC, PSZ_AC, PSZ_HP, PVAV_Reheat, PVAV_PFP_Boxes, VAV_Reheat, VAV_PFP_Boxes, Gas_Furnace, Electric_Furnace

Returns:

  • (Hash)

    keys are zones, values are system type strings



1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1122

def model_get_baseline_system_type_by_zone(model, climate_zone, custom = nil)
  zone_to_sys_type = {}

  # Get the groups of zones that define the
  # baseline HVAC systems for later use.
  # This must be done before removing the HVAC systems
  # because it requires knowledge of proposed HVAC fuels.
  sys_groups = model_prm_baseline_system_groups(model, custom)

  # Assign building stories to spaces in the building
  # where stories are not yet assigned.
  model_assign_spaces_to_stories(model)

  # Determine the baseline HVAC system type for each of
  # the groups of zones and add that system type.
  sys_groups.each do |sys_group|
    # Determine the primary baseline system type
    pri_system_type = model_prm_baseline_system_type(model,
                                                     climate_zone,
                                                     sys_group['occ'],
                                                     sys_group['fuel'],
                                                     sys_group['area_ft2'],
                                                     sys_group['stories'],
                                                     custom)[0]

    # Record the zone-by-zone system type assignments
    case pri_system_type
      when 'PTAC', 'PTHP', 'PSZ_AC', 'PSZ_HP', 'Gas_Furnace', 'Electric_Furnace'

        sys_group['zones'].each do |zone|
          zone_to_sys_type[zone] = pri_system_type
        end

      when 'PVAV_Reheat', 'PVAV_PFP_Boxes', 'VAV_Reheat', 'VAV_PFP_Boxes'

        # Determine the secondary system type
        sec_system_type = nil
        case pri_system_type
        when 'PVAV_Reheat', 'VAV_Reheat'
          sec_system_type = 'PSZ_AC'
        when 'PVAV_PFP_Boxes', 'VAV_PFP_Boxes'
          sec_system_type = 'PSZ_HP'
        end

        # Group zones by story
        story_zone_lists = model_group_zones_by_story(model, sys_group['zones'])
        # For the array of zones on each story,
        # separate the primary zones from the secondary zones.
        # Add the baseline system type to the primary zones
        # and add the suplemental system type to the secondary zones.
        story_zone_lists.each do |zones|
          # Differentiate primary and secondary zones
          pri_sec_zone_lists = model_differentiate_primary_secondary_thermal_zones(model, zones)
          # Record the primary zone system types
          pri_sec_zone_lists['primary'].each do |zone|
            zone_to_sys_type[zone] = pri_system_type
          end
          # Record the secondary zone system types
          pri_sec_zone_lists['secondary'].each do |zone|
            zone_to_sys_type[zone] = sec_system_type
          end
        end
    end
  end

  return zone_to_sys_type
end

#model_get_building_climate_zone_and_building_type(model, remap_office = true) ⇒ hash

this is used by other methods to get the climate zone and building type from a model. it has logic to break office into small, medium or large based on building area that can be turned off

Parameters:

  • remap_office (bool) (defaults to: true)

    re-map small office or leave it alone

Returns:

  • (hash)

    key for climate zone and building type, both values are strings



3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3045

def model_get_building_climate_zone_and_building_type(model, remap_office = true)
  # get climate zone from model
  climate_zone = model_standards_climate_zone(model)

  # get building type from model
  building_type = ''
  if model.getBuilding.standardsBuildingType.is_initialized
    building_type = model.getBuilding.standardsBuildingType.get
  end

  # map office building type to small medium or large
  if building_type == 'Office' && remap_office
    open_studio_area = model.getBuilding.floorArea
    building_type = model_remap_office(model, open_studio_area)
  end

  results = {}
  results['climate_zone'] = climate_zone
  results['building_type'] = building_type

  return results
end

#model_get_climate_zone_set_from_list(model, possible_climate_zone_sets) ⇒ Object

Determine which climate zone to use. Defaults to the least specific climate zone set. For example, 2A and 2 both contain 2A, so use 2.



4147
4148
4149
4150
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4147

def model_get_climate_zone_set_from_list(model, possible_climate_zone_sets)
  climate_zone_set = possible_climate_zone_sets.min
  return climate_zone_set
end

#model_get_climate_zone_weather_file_map(epw_file = '') ⇒ Object

Helper method to set the weather file, import the design days, set water mains temperature, and set ground temperature. Based on ChangeBuildingLocation measure by Nicholas Long



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 6

def model_get_climate_zone_weather_file_map(epw_file = '')
  # Define the weather file for each climate zone
  climate_zone_weather_file_map = {
    'ASHRAE 169-2006-0A' => 'VNM_SVN_Ho.Chi.Minh-Tan.Son.Nhat.Intl.AP.489000_TMYx.epw',
    'ASHRAE 169-2006-0B' => 'ARE_DU_Dubai.Intl.AP.411940_TMYx.epw',
    'ASHRAE 169-2006-1A' => 'USA_FL_Miami.Intl.AP.722020_TMY3.epw',
    'ASHRAE 169-2006-1B' => 'SAU_RI_Riyadh.AB.404380_TMYx.epw',
    'ASHRAE 169-2006-2A' => 'USA_TX_Houston-Bush.Intercontinental.AP.722430_TMY3.epw',
    'ASHRAE 169-2006-2B' => 'USA_AZ_Phoenix-Sky.Harbor.Intl.AP.722780_TMY3.epw',
    'ASHRAE 169-2006-3A' => 'USA_TN_Memphis.Intl.AP.723340_TMY3.epw',
    'ASHRAE 169-2006-3B' => 'USA_TX_El.Paso.Intl.AP.722700_TMY3.epw',
    'ASHRAE 169-2006-3C' => 'USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw',
    'ASHRAE 169-2006-4A' => 'USA_MD_Baltimore-Washington.Intl.AP.724060_TMY3.epw',
    'ASHRAE 169-2006-4B' => 'USA_NM_Albuquerque.Intl.AP.723650_TMY3.epw',
    'ASHRAE 169-2006-4C' => 'USA_OR_Salem-McNary.Field.726940_TMY3.epw',
    'ASHRAE 169-2006-5A' => 'USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw',
    'ASHRAE 169-2006-5B' => 'USA_ID_Boise.Air.Terminal.726810_TMY3.epw',
    'ASHRAE 169-2006-5C' => 'CAN_BC_Vancouver.718920_CWEC.epw',
    'ASHRAE 169-2006-6A' => 'USA_VT_Burlington.Intl.AP.726170_TMY3.epw',
    'ASHRAE 169-2006-6B' => 'USA_MT_Helena.Rgnl.AP.727720_TMY3.epw',
    'ASHRAE 169-2006-7A' => 'USA_MN_Duluth.Intl.AP.727450_TMY3.epw',
    'ASHRAE 169-2006-7B' => 'USA_MN_Duluth.Intl.AP.727450_TMY3.epw',
    'ASHRAE 169-2006-8A' => 'USA_AK_Fairbanks.Intl.AP.702610_TMY3.epw',
    'ASHRAE 169-2006-8B' => 'USA_AK_Fairbanks.Intl.AP.702610_TMY3.epw',
    'ASHRAE 169-2013-0A' => 'VNM_SVN_Ho.Chi.Minh-Tan.Son.Nhat.Intl.AP.489000_TMYx.epw',
    'ASHRAE 169-2013-0B' => 'ARE_DU_Dubai.Intl.AP.411940_TMYx.epw',
    'ASHRAE 169-2013-1A' => 'USA_HI_Honolulu.Intl.AP.911820_TMY3.epw',
    'ASHRAE 169-2013-1B' => 'IND_DL_New.Delhi-Safdarjung.AP.421820_TMYx.epw',
    'ASHRAE 169-2013-2A' => 'USA_FL_Tampa-MacDill.AFB.747880_TMY3.epw',
    'ASHRAE 169-2013-2B' => 'USA_AZ_Tucson-Davis-Monthan.AFB.722745_TMY3.epw',
    'ASHRAE 169-2013-3A' => 'USA_GA_Atlanta-Hartsfield.Jackson.Intl.AP.722190_TMY3.epw',
    'ASHRAE 169-2013-3B' => 'USA_TX_El.Paso.Intl.AP.722700_TMY3.epw',
    'ASHRAE 169-2013-3C' => 'USA_CA_San.Deigo-Brown.Field.Muni.AP.722904_TMY3.epw',
    'ASHRAE 169-2013-4A' => 'USA_NY_New.York-John.F.Kennedy.Intl.AP.744860_TMY3.epw',
    'ASHRAE 169-2013-4B' => 'USA_NM_Albuquerque.Intl.Sunport.723650_TMY3.epw',
    'ASHRAE 169-2013-4C' => 'USA_WA_Seattle-Tacoma.Intl.AP.727930_TMY3.epw',
    'ASHRAE 169-2013-5A' => 'USA_NY_Buffalo.Niagara.Intl.AP.725280_TMY3.epw',
    'ASHRAE 169-2013-5B' => 'USA_CO_Denver-Aurora-Buckley.AFB.724695_TMY3.epw',
    'ASHRAE 169-2013-5C' => 'USA_WA_Port.Angeles-William.R.Fairchild.Intl.AP.727885_TMY3.epw',
    'ASHRAE 169-2013-6A' => 'USA_MN_Rochester.Intl.AP.726440_TMY3.epw',
    'ASHRAE 169-2013-6B' => 'USA_MT_Great.Falls.Intl.AP.727750_TMY3.epw',
    'ASHRAE 169-2013-7A' => 'USA_MN_International.Falls.Intl.AP.727470_TMY3.epw',
    'ASHRAE 169-2013-7B' => 'USA_MN_International.Falls.Intl.AP.727470_TMY3.epw',
    'ASHRAE 169-2013-8A' => 'USA_AK_Fairbanks.Intl.AP.702610_TMY3.epw',
    'ASHRAE 169-2013-8B' => 'USA_AK_Fairbanks.Intl.AP.702610_TMY3.epw',
    # For measure input
    'NECB HDD Method' => epw_file.to_s,
    # For testing
    'NECB-CNEB-5' => epw_file.to_s,
    'NECB-CNEB-6' => epw_file.to_s,
    'NECB-CNEB-7a' => epw_file.to_s,
    'NECB-CNEB-7b' => epw_file.to_s,
    'NECB-CNEB-8' => epw_file.to_s,
    # For DEER
    'CEC T24-CEC1' => 'ARCATA_725945_CZ2010.epw',
    'CEC T24-CEC2' => 'SANTA-ROSA_724957_CZ2010.epw',
    'CEC T24-CEC3' => 'OAKLAND_724930_CZ2010.epw',
    'CEC T24-CEC4' => 'SAN-JOSE-REID_724946_CZ2010.epw',
    'CEC T24-CEC5' => 'SANTA-MARIA_723940_CZ2010.epw',
    'CEC T24-CEC6' => 'TORRANCE_722955_CZ2010.epw',
    'CEC T24-CEC7' => 'SAN-DIEGO-LINDBERGH_722900_CZ2010.epw',
    'CEC T24-CEC8' => 'FULLERTON_722976_CZ2010.epw',
    'CEC T24-CEC9' => 'BURBANK-GLENDALE_722880_CZ2010.epw',
    'CEC T24-CEC10' => 'RIVERSIDE_722869_CZ2010.epw',
    'CEC T24-CEC11' => 'RED-BLUFF_725910_CZ2010.epw',
    'CEC T24-CEC12' => 'SACRAMENTO-EXECUTIVE_724830_CZ2010.epw',
    'CEC T24-CEC13' => 'FRESNO_723890_CZ2010.epw',
    'CEC T24-CEC14' => 'PALMDALE_723820_CZ2010.epw',
    'CEC T24-CEC15' => 'PALM-SPRINGS-INTL_722868_CZ2010.epw',
    'CEC T24-CEC16' => 'BLUE-CANYON_725845_CZ2010.epw'
  }
  return climate_zone_weather_file_map
end

#model_get_construction_properties(model, intended_surface_type, standards_construction_type, building_category, climate_zone = nil) ⇒ hash

Returns standards data for selected construction

Parameters:

  • intended_surface_type (string)

    the surface type

  • standards_construction_type (string)

    the type of construction

  • building_category (string)

    the type of building

  • climate_zone (string) (defaults to: nil)

    the building’s climate zone

Returns:

  • (hash)

    hash of construction properties



3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3478

def model_get_construction_properties(model, intended_surface_type, standards_construction_type, building_category, climate_zone = nil)
  # get climate_zone_set
  climate_zone = model_get_building_climate_zone_and_building_type(model)['climate_zone'] if climate_zone.nil?
  climate_zone_set = model_find_climate_zone_set(model, climate_zone)

  # populate search hash
  search_criteria = {
    'template' => template,
    'climate_zone_set' => climate_zone_set,
    'intended_surface_type' => intended_surface_type,
    'standards_construction_type' => standards_construction_type,
    'building_category' => building_category
  }

  # switch to use this but update test in standards and measures to load this outside of the method
  construction_properties = model_find_object(standards_data['construction_properties'], search_criteria)

  return construction_properties
end

#model_get_construction_set(building_type, space_type = nil) ⇒ hash

Returns standards data for selected construction set

Parameters:

  • building_category (string)

    the type of building

  • space_type (string) (defaults to: nil)

    space type within the building type. Typically nil.

Returns:

  • (hash)

    hash of construction set data



3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3503

def model_get_construction_set(building_type, space_type = nil)
  # populate search hash
  search_criteria = {
    'template' => template,
    'building_type' => building_type,
    'space_type' => space_type
  }

  # Search construction sets table for the exterior wall building category and construction type
  construction_set_data = model_find_object(standards_data['construction_sets'], search_criteria)

  return construction_set_data
end

#model_get_full_weather_file_path(model) ⇒ OpenStudio::OptionalPath

Get the full path to the weather file that is specified in the model

Returns:

  • (OpenStudio::OptionalPath)


2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2833

def model_get_full_weather_file_path(model)
  full_epw_path = OpenStudio::OptionalPath.new

  if model.weatherFile.is_initialized
    epw_path = model.weatherFile.get.path
    if epw_path.is_initialized
      if File.exist?(epw_path.get.to_s)
        full_epw_path = OpenStudio::OptionalPath.new(epw_path.get)
      else
        # If this is an always-run Measure, need to check a different path
        alt_weath_path = File.expand_path(File.join(Dir.pwd, '../../resources'))
        alt_epw_path = File.expand_path(File.join(alt_weath_path, epw_path.get.to_s))
        if File.exist?(alt_epw_path)
          full_epw_path = OpenStudio::OptionalPath.new(OpenStudio::Path.new(alt_epw_path))
        else
          OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Model has been assigned a weather file, but the file is not in the specified location of '#{epw_path.get}'.")
        end
      end
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', 'Model has a weather file assigned, but the weather file path has been deleted.')
    end
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', 'Model has not been assigned a weather file.')
  end

  return full_epw_path
end

#model_get_lookup_name(building_type) ⇒ String

TODO:

Unify the lookup names and eliminate this method

Get the name of the building type used in lookups

Parameters:

  • building_type (String)

    the building type

Returns:

  • (String)

    returns the lookup name as a string



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/openstudio-standards/standards/standard.rb', line 53

def model_get_lookup_name(building_type)
  lookup_name = building_type
  case building_type
  when 'SmallOffice'
    lookup_name = 'Office'
  when 'SmallOfficeDetailed'
    lookup_name = 'Office'
  when 'MediumOffice'
    lookup_name = 'Office'
  when 'MediumOfficeDetailed'
    lookup_name = 'Office'
  when 'LargeOffice'
    lookup_name = 'Office'
  when 'LargeOfficeDetailed'
    lookup_name = 'Office'
  when 'RetailStandalone'
    lookup_name = 'Retail'
  when 'RetailStripmall'
    lookup_name = 'StripMall'
  when 'Office'
    lookup_name = 'Office'
  end
  return lookup_name
end

#model_get_monthly_ground_temps_from_stat_file(stat_file_path) ⇒ Array

This function gets the average ground temperature averages, under the assumption that ground temperature lags 3 months behind the ambient dry bulb temperature. (e.g. April’s ground temperature equal January’s average dry bulb temperature)

Parameters:

  • stat_file_path (String)

    path to STAT file

Returns:

  • (Array)

    a length 12 array of monthly ground temperatures, one for each month



293
294
295
296
297
298
299
300
301
302
303
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 293

def model_get_monthly_ground_temps_from_stat_file(stat_file_path)
  if File.exist? stat_file_path
    stat_file = EnergyPlus::StatFile.new(stat_file_path)
    monthly_dry_bulb = stat_file.monthly_dry_bulb[0..11]
    ground_temperatures = monthly_dry_bulb.rotate(-3)
    return ground_temperatures
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.weather.Model', "Stat file: #{stat_file_path} was not found when calculating ground temperatures.")
    return []
  end
end

#model_get_or_add_ambient_water_loop(model) ⇒ Object

Get the existing ambient water loop in the model or add a new one if there isn’t one already.



5738
5739
5740
5741
5742
5743
5744
5745
5746
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5738

def model_get_or_add_ambient_water_loop(model)
  # retrieve the existing hot water loop or add a new one if necessary
  ambient_water_loop = if model.getPlantLoopByName('Ambient Loop').is_initialized
                         model.getPlantLoopByName('Ambient Loop').get
                       else
                         model_add_district_ambient_loop(model)
                       end
  return ambient_water_loop
end

#model_get_or_add_chilled_water_loop(model, cool_fuel, chilled_water_loop_cooling_type: 'WaterCooled') ⇒ Object

Get the existing chilled water loop in the model or add a new one if there isn’t one already.

Parameters:

  • cool_fuel (String)

    the cooling fuel. Valid choices are Electricity, DistrictCooling, and HeatPump.

  • chilled_water_loop_cooling_type (String) (defaults to: 'WaterCooled')

    Archetype for chilled water loops, AirCooled or WaterCooled



5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5493

def model_get_or_add_chilled_water_loop(model, cool_fuel,
                                        chilled_water_loop_cooling_type: 'WaterCooled')
  # retrieve the existing chilled water loop or add a new one if necessary
  chilled_water_loop = nil
  if model.getPlantLoopByName('Chilled Water Loop').is_initialized
    chilled_water_loop = model.getPlantLoopByName('Chilled Water Loop').get
  else
    case cool_fuel
    when 'DistrictCooling'
      chilled_water_loop = model_add_chw_loop(model,
                                              chw_pumping_type: 'const_pri',
                                              cooling_fuel: cool_fuel)
    when 'HeatPump'
      condenser_water_loop = model_get_or_add_ambient_water_loop(model)
      chilled_water_loop = model_add_chw_loop(model,
                                              chw_pumping_type: 'const_pri_var_sec',
                                              chiller_cooling_type: 'WaterCooled',
                                              chiller_compressor_type: 'Rotary Screw',
                                              condenser_water_loop: condenser_water_loop)
    when 'Electricity'
      if chilled_water_loop_cooling_type == 'AirCooled'
        chilled_water_loop = model_add_chw_loop(model,
                                                chw_pumping_type: 'const_pri',
                                                cooling_fuel: cool_fuel)
      else
        fan_type = model_cw_loop_cooling_tower_fan_type(model)
        condenser_water_loop = model_add_cw_loop(model,
                                                 cooling_tower_type: 'Open Cooling Tower',
                                                 cooling_tower_fan_type: 'Propeller or Axial',
                                                 cooling_tower_capacity_control: fan_type,
                                                 number_of_cells_per_tower: 1,
                                                 number_cooling_towers: 1)
        chilled_water_loop = model_add_chw_loop(model,
                                                chw_pumping_type: 'const_pri_var_sec',
                                                chiller_cooling_type: 'WaterCooled',
                                                chiller_compressor_type: 'Rotary Screw',
                                                condenser_water_loop: condenser_water_loop)
      end
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', 'No cool_fuel specified.')
    end
  end

  return chilled_water_loop
end

#model_get_or_add_ground_hx_loop(model) ⇒ Object

Get the existing ground heat exchanger loop in the model or add a new one if there isn’t one already.



5749
5750
5751
5752
5753
5754
5755
5756
5757
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5749

def model_get_or_add_ground_hx_loop(model)
  # retrieve the existing ground HX loop or add a new one if necessary
  ground_hx_loop = if model.getPlantLoopByName('Ground HX Loop').is_initialized
                     model.getPlantLoopByName('Ground HX Loop').get
                   else
                     model_add_ground_hx_loop(model)
                   end
  return ground_hx_loop
end

#model_get_or_add_heat_pump_loop(model, heat_fuel, cool_fuel, heat_pump_loop_cooling_type: 'EvaporativeFluidCooler') ⇒ Object

Get the existing heat pump loop in the model or add a new one if there isn’t one already.

Parameters:

  • heat_fuel (String)

    the heating fuel. Valid choices are NaturalGas, Electricity, DistrictHeating

  • cool_fuel (String)

    the cooling fuel. Valid choices are Electricity and DistrictCooling.

  • heat_pump_loop_cooling_type (String) (defaults to: 'EvaporativeFluidCooler')

    the type of cooling equipment if not DistrictCooling. Valid options are: CoolingTower, CoolingTowerSingleSpeed, CoolingTowerTwoSpeed, CoolingTowerVariableSpeed, FluidCooler, FluidCoolerSingleSpeed, FluidCoolerTwoSpeed, EvaporativeFluidCooler, EvaporativeFluidCoolerSingleSpeed, EvaporativeFluidCoolerTwoSpeed



5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5768

def model_get_or_add_heat_pump_loop(model, heat_fuel, cool_fuel,
                                    heat_pump_loop_cooling_type: 'EvaporativeFluidCooler')
  # retrieve the existing heat pump loop or add a new one if necessary
  heat_pump_loop = if model.getPlantLoopByName('Heat Pump Loop').is_initialized
                     model.getPlantLoopByName('Heat Pump Loop').get
                   else
                     model_add_hp_loop(model, heating_fuel: heat_fuel, cooling_fuel: cool_fuel, cooling_type: heat_pump_loop_cooling_type)
                   end
  return heat_pump_loop
end

#model_get_or_add_hot_water_loop(model, heat_fuel, hot_water_loop_type: 'HighTemperature') ⇒ Object

Get the existing hot water loop in the model or add a new one if there isn’t one already.

Parameters:

  • heat_fuel (String)

    the heating fuel. Valid choices are NaturalGas, Electricity, DistrictHeating

  • hot_water_loop_type (String) (defaults to: 'HighTemperature')

    Archetype for hot water loops HighTemperature (180F supply) or LowTemperature (120F supply)



5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5699

def model_get_or_add_hot_water_loop(model, heat_fuel,
                                    hot_water_loop_type: 'HighTemperature')
  if heat_fuel.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'Hot water loop fuel type is nil.  Cannot add hot water loop.')
  end
  make_new_hot_water_loop = true
  hot_water_loop = nil
  # retrieve the existing hot water loop or add a new one if not of the correct type
  if model.getPlantLoopByName('Hot Water Loop').is_initialized
    hot_water_loop = model.getPlantLoopByName('Hot Water Loop').get
    design_loop_exit_temperature = hot_water_loop.sizingPlant.designLoopExitTemperature
    design_loop_exit_temperature = OpenStudio.convert(design_loop_exit_temperature, 'C', 'F').get
    # check that the loop is the correct archetype
    if hot_water_loop_type == 'HighTemperature'
      make_new_hot_water_loop = false if design_loop_exit_temperature > 130.0
    elsif hot_water_loop_type == 'LowTemperature'
      make_new_hot_water_loop = false if design_loop_exit_temperature <= 130.0
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "Hot water loop archetype #{hot_water_loop_type} not recognized.")
    end
  end

  if make_new_hot_water_loop
    if hot_water_loop_type == 'HighTemperature'
      hot_water_loop = model_add_hw_loop(model, heat_fuel)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'New high temperature hot water loop created.')
    elsif hot_water_loop_type == 'LowTemperature'
      hot_water_loop = model_add_hw_loop(model, heat_fuel,
                                         dsgn_sup_wtr_temp: 120.0,
                                         boiler_draft_type: 'Condensing')
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'New low temperature hot water loop created.')
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "Hot water loop archetype #{hot_water_loop_type} not recognized.")
    end
  end
  return hot_water_loop
end

#model_get_story_for_nominal_z_coordinate(model, minz, tolerance = 0.3) ⇒ OpenStudio::Model::BuildingStory

Helper method to get the story object that corresponds to a specific minimum z value. Makes a new story if none found at this height.

Parameters:

  • minz (Double)

    the z value (height) of the desired story, in meters.

  • tolerance (Double) (defaults to: 0.3)

    tolerance for comparison, in m. Default is 0.3 m ~1ft

Returns:

  • (OpenStudio::Model::BuildingStory)

    the story



3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3921

def model_get_story_for_nominal_z_coordinate(model, minz, tolerance = 0.3)
  model.getBuildingStorys.sort.each do |story|
    z = building_story_minimum_z_value(story)

    if (minz - z).abs < tolerance
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "The story with a min z value of #{minz.round(2)} is #{story.name}.")
      return story
    end
  end

  story = OpenStudio::Model::BuildingStory.new(model)
  story.setNominalZCoordinate(minz)
  OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Model', "No story with a min z value of #{minz.round(2)} m +/- #{tolerance} m was found, so a new story called #{story.name} was created.")

  return story
end

#model_group_zones_by_story(model, zones) ⇒ Array<Array<OpenStudio::Model::ThermalZone>>

Group an array of zones into multiple arrays, one for each story in the building. Zones with spaces on multiple stories will be assigned to only one of the stories. Removes empty array (when the story doesn’t contain any of the zones)

Returns:



1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1388

def model_group_zones_by_story(model, zones)
  story_zone_lists = []
  zones_already_assigned = []
  model.getBuildingStorys.sort.each do |story|
    # Get all the spaces on this story
    spaces = story.spaces

    # Get all the thermal zones that serve these spaces
    all_zones_on_story = []
    spaces.each do |space|
      if space.thermalZone.is_initialized
        all_zones_on_story << space.thermalZone.get
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Model', "Space #{space.name} has no thermal zone, it is not included in the simulation.")
      end
    end

    # Find zones in the list that are on this story
    zones_on_story = []
    zones.each do |zone|
      if all_zones_on_story.include?(zone)
        # Skip zones that were already assigned to a story.
        # This can happen if a zone has multiple spaces on multiple stories.
        # Stairwells and atriums are typical scenarios.
        next if zones_already_assigned.include?(zone)

        zones_on_story << zone
        zones_already_assigned << zone
      end
    end

    unless zones_on_story.empty?
      story_zone_lists << zones_on_story
    end
  end

  return story_zone_lists
end

#model_infer_hours_of_operation_building(model, fraction_of_daily_occ_range: 0.25, invert_res: true, gen_occ_profile: false) ⇒ ScheduleRuleset

This method looks at occupancy profiles for the building as a whole and generates an hours of operation default schedule for the building. It also clears out any higher level hours of operation schedule assignments. Spaces are organized by res and non_res. Whichever of the two groups has higher design level of people is used for building hours of operation Resulting hours of operation can have as many rules as necessary to describe the operation. Each ScheduleDay should be an on/off schedule with only values of 0 and 1. There should not be more than one on/off cycle per day. In future this could create different hours of operation for residential vs. non-residential, by building type, story, or space type. However this measure is a stop gap to convert old generic schedules to parametric schedules. Future new schedules should be designed as paramtric from the start and would not need to run through this inference process

Parameters:

  • model (Model)
  • fraction_of_daily_occ_range (Double) (defaults to: 0.25)

    fraction above/below daily min range required to start and end hours of operation

  • invert_res (Bool) (defaults to: true)

    if true will reverse hours of operation for residential space types

  • gen_occ_profile (Bool) (defaults to: false)

    if true creates a merged occupancy schedule for diagnostic purposes. This schedule is added to the model but no specifically returned by this method

Returns:

  • (ScheduleRuleset)

    schedule that is assigned to the building as default hours of operation

Author:

  • David Goldwasser



4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4676

def model_infer_hours_of_operation_building(model, fraction_of_daily_occ_range: 0.25, invert_res: true, gen_occ_profile: false)
  # create an array of non-residential and residential spaces
  res_spaces = []
  non_res_spaces = []
  res_people_design = 0
  non_res_people_design = 0
  model.getSpaces.sort.each do |space|
    if space_residential?(space)
      res_spaces << space
      res_people_design += space.numberOfPeople * space.multiplier
    else
      non_res_spaces << space
      non_res_people_design += space.numberOfPeople * space.multiplier
    end
  end
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Standards.Model', "Model has design level of #{non_res_people_design} people in non residential spaces and #{res_people_design} people in residential spaces.")

  # create merged schedule for prevalent type (not used but can be generated for diagnostics)
  if gen_occ_profile
    res_prevalent = false
    if res_people_design > non_res_people_design
      occ_merged = spaces_get_occupancy_schedule(res_spaces, sch_name: 'Calculated Occupancy Fraction Residential Merged')
      res_prevalent = true
    else
      occ_merged = spaces_get_occupancy_schedule(non_res_spaces, sch_name: 'Calculated Occupancy Fraction NonResidential Merged')
    end
  end

  # re-run spaces_get_occupancy_schedule with x above min occupancy to create on/off schedule
  if res_people_design > non_res_people_design
    hours_of_operation = spaces_get_occupancy_schedule(res_spaces,
                                                       sch_name: 'Building Hours of Operation Residential',
                                                       occupied_percentage_threshold: fraction_of_daily_occ_range,
                                                       threshold_calc_method: 'normalized_daily_range')
    res_prevalent = true
  else
    hours_of_operation = spaces_get_occupancy_schedule(non_res_spaces,
                                                       sch_name: 'Building Hours of Operation NonResidential',
                                                       occupied_percentage_threshold: fraction_of_daily_occ_range,
                                                       threshold_calc_method: 'normalized_daily_range')
  end

  # remove gaps resulting in multiple on off cycles for each rule in schedule so it will be valid hours of operation
  profiles = []
  profiles << hours_of_operation.defaultDaySchedule
  hours_of_operation.scheduleRules.each do |rule|
    profiles << rule.daySchedule
  end
  profiles.sort.each do |profile|
    times = profile.times
    values = profile.values
    next if times.size <= 3 # length of 1-3 should produce valid hours_of_operation profiles

    # Find the latest time where the value == 1
    latest_time = nil
    times.zip(values).each do |time, value|
      if value > 0
        latest_time = time
      end
    end
    # Skip profiles that are zero all the time
    next if latest_time.nil?

    # Calculate the duration from this point to midnight
    wrap_dur_left_hr = 0
    if values.first == 0 && values.last == 0
      wrap_dur_left_hr = 24.0 - latest_time.totalHours
    end
    occ_gap_hash = {}
    prev_time = 0
    prev_val = nil
    times.each_with_index do |time, i|
      next if time.totalHours == 0.0 # should not see this
      next if values[i] == prev_val # check if two 0 until time next to each other

      if values[i] == 0 # only store vacant segments
        if time.totalHours == 24
          occ_gap_hash[prev_time] = time.totalHours - prev_time + wrap_dur_left_hr
        else
          occ_gap_hash[prev_time] = time.totalHours - prev_time
        end
      end
      prev_time = time.totalHours
      prev_val = values[i]
    end
    profile.clearValues
    max_occ_gap_start = occ_gap_hash.key(occ_gap_hash.values.max)
    max_occ_gap_end_hr = max_occ_gap_start + occ_gap_hash[max_occ_gap_start] # can't add time and duration in hours
    if max_occ_gap_end_hr > 24.0 then max_occ_gap_end_hr -= 24.0 end

    # time for gap start
    target_start_hr = max_occ_gap_start.truncate
    target_start_min = ((max_occ_gap_start - target_start_hr) * 60.0).truncate
    max_occ_gap_start = OpenStudio::Time.new(0, target_start_hr, target_start_min, 0)

    # time for gap end
    target_end_hr = max_occ_gap_end_hr.truncate
    target_end_min = ((max_occ_gap_end_hr - target_end_hr) * 60.0).truncate
    max_occ_gap_end = OpenStudio::Time.new(0, target_end_hr, target_end_min, 0)

    profile.addValue(max_occ_gap_start, 1)
    profile.addValue(max_occ_gap_end, 0)
    os_time_24 = OpenStudio::Time.new(0, 24, 0, 0)
    if max_occ_gap_start > max_occ_gap_end
      profile.addValue(os_time_24, 0)
    else
      profile.addValue(os_time_24, 1)
    end
  end

  # reverse 1 and 0 values for res_prevalent building
  # currently spaces_get_occupancy_schedule doesn't use defaultDayProflie, so only inspecting rules for now.
  if invert_res && res_prevalent
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Standards.Model', 'Per argument passed in hours of operation are being inverted for buildings with more people in residential versus non-residential spaces.')
    hours_of_operation.scheduleRules.each do |rule|
      profile = rule.daySchedule
      times = profile.times
      values = profile.values
      profile.clearValues
      times.each_with_index do |time, i|
        orig_val = values[i]
        new_value = nil
        if orig_val == 0 then new_value = 1 end
        if orig_val == 1 then new_value = 0 end
        profile.addValue(time, new_value)
      end
    end
  end

  # set hours of operation for building level hours of operation
  model.getDefaultScheduleSets.each(&:resetHoursofOperationSchedule)
  if model.getBuilding.defaultScheduleSet.is_initialized
    default_sch_set = model.getBuilding.defaultScheduleSet.get
  else
    default_sch_set = OpenStudio::Model::DefaultScheduleSet.new(model)
    default_sch_set.setName('Building Default Schedule Set')
    model.getBuilding.setDefaultScheduleSet(default_sch_set)
  end
  default_sch_set.setHoursofOperationSchedule(hours_of_operation)

  return hours_of_operation
end

#model_legacy_results_by_end_use_and_fuel_type(model, climate_zone, building_type, run_type) ⇒ Hash

Find the legacy simulation results from a CSV of previously created results.

e.g. Heating|Electricity, Exterior Equipment|Water. All end use/fuel type combos are present, with values of 0.0 if none of this end use/fuel type combo was used by the simulation. Returns nil if the legacy results couldn’t be found.

Returns:

  • (Hash)

    a hash of results for each fuel, where the keys are in the form ‘End Use|Fuel Type’,



2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2867

def model_legacy_results_by_end_use_and_fuel_type(model, climate_zone, building_type, run_type)
  # Load the legacy idf results CSV file into a ruby hash
  top_dir = File.expand_path('../../..', File.dirname(__FILE__))
  standards_data_dir = "#{top_dir}/data/standards"
  temp = ''
  # Run differently depending on whether running from embedded filesystem in OpenStudio CLI or not
  if __dir__[0] == ':' # Running from OpenStudio CLI
    # load file from embedded files
    if run_type == 'dd-only'
      temp = load_resource_relative('../../../data/standards/test_performance_expected_dd_results.csv', 'r:UTF-8')
    else
      temp = load_resource_relative('../../../data/standards/legacy_idf_results.csv', 'r:UTF-8')
    end
  else
    # loaded gem from system path
    if run_type == 'dd-only'
      temp = File.read("#{standards_data_dir}/test_performance_expected_dd_results.csv")
    else
      temp = File.read("#{standards_data_dir}/legacy_idf_results.csv")
    end
  end
  legacy_idf_csv = CSV.new(temp, headers: true, converters: :all)
  legacy_idf_results = legacy_idf_csv.to_a.map(&:to_hash)

  # Get the results for this building
  search_criteria = {
    'Building Type' => building_type,
    'Template' => template,
    'Climate Zone' => climate_zone
  }
  energy_values = model_find_object(legacy_idf_results, search_criteria)
  if energy_values.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Could not find legacy simulation results for #{search_criteria}")
    return {}
  end

  return energy_values
end

#model_make_name(model, clim, building_type, spc_type) ⇒ Object

Helper method to make a shortened version of a name that will be readable in a GUI.



4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4037

def model_make_name(model, clim, building_type, spc_type)
  clim = clim.gsub('ClimateZone ', 'CZ')
  if clim == 'CZ1-8'
    clim = ''
  end

  if building_type == 'FullServiceRestaurant'
    building_type = 'FullSrvRest'
  elsif building_type == 'Hospital'
    building_type = 'Hospital'
  elsif building_type == 'LargeHotel'
    building_type = 'LrgHotel'
  elsif building_type == 'LargeOffice'
    building_type = 'LrgOffice'
  elsif building_type == 'MediumOffice'
    building_type = 'MedOffice'
  elsif building_type == 'MidriseApartment'
    building_type = 'MidApt'
  elsif building_type == 'HighriseApartment'
    building_type = 'HighApt'
  elsif building_type == 'Office'
    building_type = 'Office'
  elsif building_type == 'Outpatient'
    building_type = 'Outpatient'
  elsif building_type == 'PrimarySchool'
    building_type = 'PriSchl'
  elsif building_type == 'QuickServiceRestaurant'
    building_type = 'QckSrvRest'
  elsif building_type == 'Retail'
    building_type = 'Retail'
  elsif building_type == 'SecondarySchool'
    building_type = 'SecSchl'
  elsif building_type == 'SmallHotel'
    building_type = 'SmHotel'
  elsif building_type == 'SmallOffice'
    building_type = 'SmOffice'
  elsif building_type == 'StripMall'
    building_type = 'StMall'
  elsif building_type == 'SuperMarket'
    building_type = 'SpMarket'
  elsif building_type == 'Warehouse'
    building_type = 'Warehouse'
  elsif building_type == 'SmallDataCenterLowITE'
    building_type = 'SmDCLowITE'
  elsif building_type == 'SmallDataCenterHighITE'
    building_type = 'SmDCHighITE'
  elsif building_type == 'LargeDataCenterLowITE'
    building_type = 'LrgDCLowITE'
  elsif building_type == 'LargeDataCenterHighITE'
    building_type = 'LrgDCHighITE'
  elsif building_type == 'Laboratory'
    building_type = 'Laboratory'
  elsif building_type == 'TallBuilding'
    building_type = 'TallBldg'
  elsif building_type == 'SuperTallBuilding'
    building_type = 'SpTallBldg'
  end

  parts = [template]

  unless building_type.nil?
    parts << building_type
  end

  unless spc_type.nil?
    parts << spc_type
  end

  unless clim.empty?
    parts << clim
  end

  result = parts.join(' - ')

  return result
end

#model_num_stories_spanned(model, zones) ⇒ Integer

Determine the number of stories spanned by the supplied zones. If all zones on one of the stories have an indentical multiplier, assume that the multiplier is a floor multiplier and increase the number of stories accordingly. Stories do not have to be contiguous.

Parameters:

Returns:

  • (Integer)

    the number of stories spanned



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 272

def model_num_stories_spanned(model, zones)
  # Get the story object for all zones
  stories = []
  zones.each do |zone|
    zone.spaces.each do |space|
      story = space.buildingStory
      next if story.empty?

      stories << story.get
    end
  end

  # Reduce down to the unique set of stories
  stories = stories.uniq

  # Tally up stories including multipliers
  num_stories = 0
  stories.each do |story|
    num_stories += building_story_floor_multiplier(story)
  end

  return num_stories
end

#model_prm_baseline_system_change_fuel_type(model, fuel_type, climate_zone, custom = nil) ⇒ String

Change the fuel type based on climate zone, depending on the standard. Defaults to no change.

Returns:

  • (String)

    the revised fuel type



716
717
718
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 716

def model_prm_baseline_system_change_fuel_type(model, fuel_type, climate_zone, custom = nil)
  return fuel_type # Don't change fuel type for most templates
end

#model_prm_baseline_system_group_minimum_area(model, custom) ⇒ Double

Determines the area of the building above which point the non-dominant area type gets it’s own HVAC system type.

Returns:

  • (Double)

    the minimum area (m^2)



604
605
606
607
608
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 604

def model_prm_baseline_system_group_minimum_area(model, custom)
  exception_min_area_ft2 = 20_000
  exception_min_area_m2 = OpenStudio.convert(exception_min_area_ft2, 'ft^2', 'm^2').get
  return exception_min_area_m2
end

#model_prm_baseline_system_groups(model, custom) ⇒ Array<Hash>

Determine the dominant and exceptional areas of the building based on fuel types and occupancy types.

with keys area_ft2, type, fuel, and zones (an array of zones)

Returns:

  • (Array<Hash>)

    an array of hashes of area information,



345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 345

def model_prm_baseline_system_groups(model, custom)
  # Define the minimum area for the
  # exception that allows a different
  # system type in part of the building.
  exception_min_area_m2 = model_prm_baseline_system_group_minimum_area(model, custom)
  exception_min_area_ft2 = OpenStudio.convert(exception_min_area_m2, 'm^2', 'ft^2').get

  # Get occupancy type, fuel type, and area information for all zones,
  # excluding unconditioned zones.
  # Occupancy types are:
  # Residential
  # NonResidential
  # (and for 90.1-2013)
  # PublicAssembly
  # Retail
  # Fuel types are:
  # fossil
  # electric
  # (and for Xcel Energy CO EDA)
  # fossilandelectric
  zones = model_zones_with_occ_and_fuel_type(model, custom)

  # Ensure that there is at least one conditioned zone
  if zones.size.zero?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Model', 'The building does not appear to have any conditioned zones. Make sure zones have thermostat with appropriate heating and cooling setpoint schedules.')
    return []
  end

  # Group the zones by occupancy type
  type_to_area = Hash.new { 0.0 }
  zones_grouped_by_occ = zones.group_by { |z| z['occ'] }

  # Determine the dominant occupancy type by area
  zones_grouped_by_occ.each do |occ_type, zns|
    zns.each do |zn|
      type_to_area[occ_type] += zn['area']
    end
  end
  dom_occ = type_to_area.sort_by { |k, v| v }.reverse[0][0]

  # Get the dominant occupancy type group
  dom_occ_group = zones_grouped_by_occ[dom_occ]

  # Check the non-dominant occupancy type groups to see if they are big enough to trigger the occupancy exception.
  # If they are, leave the group standing alone.
  # If they are not, add the zones in that group back to the dominant occupancy type group.
  occ_groups = []
  zones_grouped_by_occ.each do |occ_type, zns|
    # Skip the dominant occupancy type
    next if occ_type == dom_occ

    # Add up the floor area of the group
    area_m2 = 0
    zns.each do |zn|
      area_m2 += zn['area']
    end
    area_ft2 = OpenStudio.convert(area_m2, 'm^2', 'ft^2').get

    # If the non-dominant group is big enough, preserve that group.
    if area_ft2 > exception_min_area_ft2
      occ_groups << [occ_type, zns]
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "The portion of the building with an occupancy type of #{occ_type} is bigger than the minimum exception area of #{exception_min_area_ft2.round} ft2.  It will be assigned a separate HVAC system type.")
      # Otherwise, add the zones back to the dominant group.
    else
      dom_occ_group += zns
    end
  end
  # Add the dominant occupancy group to the list
  occ_groups << [dom_occ, dom_occ_group]

  # Inside of each remaining occupancy group, determine the dominant fuel type.
  # This determination should only include zones that are part of the dominant area type inside of this group.
  occ_and_fuel_groups = []
  occ_groups.each do |occ_type, zns|
    # Separate the zones that are part of the dominant occ type
    dom_occ_zns = []
    nondom_occ_zns = []
    zns.each do |zn|
      if zn['occ'] == occ_type
        dom_occ_zns << zn
      else
        nondom_occ_zns << zn
      end
    end

    # Determine the dominant fuel type from the subset of the dominant area type zones
    fuel_to_area = Hash.new { 0.0 }
    zones_grouped_by_fuel = dom_occ_zns.group_by { |z| z['fuel'] }
    zones_grouped_by_fuel.each do |fuel, zns_by_fuel|
      zns_by_fuel.each do |zn|
        fuel_to_area[fuel] += zn['area']
      end
    end

    sorted_by_area = fuel_to_area.sort_by { |k, v| v }.reverse
    dom_fuel = sorted_by_area[0][0]

    # Don't allow unconditioned to be the dominant fuel, go to the next biggest
    if dom_fuel == 'unconditioned'
      if sorted_by_area.size > 1
        dom_fuel = sorted_by_area[1][0]
      else
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', 'The fuel type was not able to be determined for any zones in this model.  Run with debug messages enabled to see possible reasons.')
        return []
      end
    end

    # Get the dominant fuel type group
    dom_fuel_group = {}
    dom_fuel_group['occ'] = occ_type
    dom_fuel_group['fuel'] = dom_fuel
    dom_fuel_group['zones'] = zones_grouped_by_fuel[dom_fuel]

    # The zones that aren't part of the dominant occ type are automatically added to the dominant fuel group
    dom_fuel_group['zones'] += nondom_occ_zns

    # Check the non-dominant occupancy type groups to see if they are big enough to trigger the occupancy exception.
    # If they are, leave the group standing alone.
    # If they are not, add the zones in that group back to the dominant occupancy type group.
    zones_grouped_by_fuel.each do |fuel_type, zns_by_fuel|
      # Skip the dominant occupancy type
      next if fuel_type == dom_fuel

      # Add up the floor area of the group
      area_m2 = 0
      zns_by_fuel.each do |zn|
        area_m2 += zn['area']
      end
      area_ft2 = OpenStudio.convert(area_m2, 'm^2', 'ft^2').get

      # If the non-dominant group is big enough, preserve that group.
      if area_ft2 > exception_min_area_ft2
        group = {}
        group['occ'] = occ_type
        group['fuel'] = fuel_type
        group['zones'] = zns_by_fuel
        occ_and_fuel_groups << group
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "The portion of the building with an occupancy type of #{occ_type} and fuel type of #{fuel_type} is bigger than the minimum exception area of #{exception_min_area_ft2.round} ft2.  It will be assigned a separate HVAC system type.")
        # Otherwise, add the zones back to the dominant group.
      else
        dom_fuel_group['zones'] += zns_by_fuel
      end
    end
    # Add the dominant occupancy group to the list
    occ_and_fuel_groups << dom_fuel_group
  end

  # Moved heated-only zones into their own groups.
  # Per the PNNL PRM RM, this must be done AFTER the dominant occ and fuel types are determined
  # so that heated-only zone areas are part of the determination.
  final_groups = []
  occ_and_fuel_groups.each do |gp|
    # Skip unconditioned groups
    next if gp['fuel'] == 'unconditioned'

    heated_only_zones = []
    heated_cooled_zones = []
    gp['zones'].each do |zn|
      if thermal_zone_heated?(zn['zone']) && !thermal_zone_cooled?(zn['zone'])
        heated_only_zones << zn
      else
        heated_cooled_zones << zn
      end
    end
    gp['zones'] = heated_cooled_zones

    # Add the group (less unheated zones) to the final list
    final_groups << gp

    # If there are any heated-only zones, create a new group for them.
    unless heated_only_zones.empty?
      htd_only_group = {}
      htd_only_group['occ'] = 'heatedonly'
      htd_only_group['fuel'] = gp['fuel']
      htd_only_group['zones'] = heated_only_zones
      final_groups << htd_only_group
    end
  end

  # Calculate the area for each of the final groups and replace the zone hashes with the zone objects
  final_groups.each do |gp|
    area_m2 = 0.0
    gp_zns = []
    gp['zones'].each do |zn|
      area_m2 += zn['area']
      gp_zns << zn['zone']
    end
    area_ft2 = OpenStudio.convert(area_m2, 'm^2', 'ft^2').get
    gp['area_ft2'] = area_ft2
    gp['zones'] = gp_zns
  end

  # TODO: Remove the secondary zones before
  # determining the area used to pick the HVAC system, per PNNL PRM RM

  # If there is any district heating or district cooling in the proposed building, the heating and cooling
  # fuels in the entire baseline building are changed for the purposes of HVAC system assignment
  all_htg_fuels = []
  all_clg_fuels = []
  model.getThermalZones.sort.each do |zone|
    all_htg_fuels += zone.heating_fuels
    all_clg_fuels += zone.cooling_fuels
  end

  purchased_heating = false
  purchased_cooling = false

  # Purchased heating
  if all_htg_fuels.include?('DistrictHeating')
    purchased_heating = true
  end

  # Purchased cooling
  if all_clg_fuels.include?('DistrictCooling')
    purchased_cooling = true
  end

  # Categorize
  district_fuel = nil
  if purchased_heating && purchased_cooling
    district_fuel = 'purchasedheatandcooling'
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', 'The proposed model included purchased heating and cooling.  All baseline building system selection will be based on this information.')
  elsif purchased_heating && !purchased_cooling
    district_fuel = 'purchasedheat'
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', 'The proposed model included purchased heating.  All baseline building system selection will be based on this information.')
  elsif !purchased_heating && purchased_cooling
    district_fuel = 'purchasedcooling'
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', 'The proposed model included purchased cooling.  All baseline building system selection will be based on this information.')
  end

  # Change the fuel in all final groups if district systems were found.
  if district_fuel
    final_groups.each do |gp|
      gp['fuel'] = district_fuel
    end
  end

  # Determine the number of stories spanned by each group and report out info.
  final_groups.each do |group|
    # Determine the number of stories this group spans
    num_stories = model_num_stories_spanned(model, group['zones'])
    group['stories'] = num_stories
    # Report out the final grouping
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Final system type group: occ = #{group['occ']}, fuel = #{group['fuel']}, area = #{group['area_ft2'].round} ft2, num stories = #{group['stories']}, zones:")
    group['zones'].sort.each_slice(5) do |zone_list|
      zone_names = []
      zone_list.each do |zone|
        zone_names << zone.name.get.to_s
      end
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "--- #{zone_names.join(', ')}")
    end
  end

  return final_groups
end

#model_prm_baseline_system_number(model, climate_zone, area_type, fuel_type, area_ft2, num_stories, custom) ⇒ String

Determines which system number is used for the baseline system. Default is 90.1-2004 approach.

Returns:

  • (String)

    the system number: 1_or_2, 3_or_4, 5_or_6, 7_or_8, 9_or_10



685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 685

def model_prm_baseline_system_number(model, climate_zone, area_type, fuel_type, area_ft2, num_stories, custom)
  sys_num = nil
  # Set the area limit
  limit_ft2 = 75_000

  # Warn about heated only
  if area_type == 'heatedonly'
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Model', "Per Table G3.1.10.d, '(In the proposed building) Where no cooling system exists or no cooling system has been specified, the cooling system shall be identical to the system modeled in the baseline building design.' This requires that you go back and add a cooling system to the proposed model.  This code cannot do that for you; you must do it manually.")
  end

  case area_type
    when 'residential'
      sys_num = '1_or_2'
    when 'nonresidential', 'heatedonly'
      # nonresidential and 3 floors or less and <25,000 ft2
      if num_stories <= 3 && area_ft2 < limit_ft2
        sys_num = '3_or_4'
        # nonresidential and 4 or 5 floors or 5 floors or less and 25,000 ft2 to 150,000 ft2
      elsif ((num_stories == 4 || num_stories == 5) && area_ft2 < limit_ft2) || (num_stories <= 5 && (area_ft2 >= limit_ft2 && area_ft2 <= 150_000))
        sys_num = '5_or_6'
        # nonresidential and more than 5 floors or >150,000 ft2
      elsif num_stories >= 5 || area_ft2 > 150_000
        sys_num = '7_or_8'
      end
  end

  return sys_num
end

#model_prm_baseline_system_type(model, climate_zone, area_type, fuel_type, area_ft2, num_stories, custom) ⇒ String

Determine the baseline system type given the inputs. Logic is different for different standards.

90.1-2007, 90.1-2010, 90.1-2013 TODO: add 90.1-2013 systems 11-13

Parameters:

  • area_type (String)

    Valid choices are residential, nonresidential, and heatedonly

  • fuel_type (String)

    Valid choices are electric, fossil, fossilandelectric, purchasedheat, purchasedcooling, purchasedheatandcooling

  • area_ft2 (Double)

    Area in ft^2

  • num_stories (Integer)

    Number of stories

Returns:

  • (String)

    The system type. Possibilities are PTHP, PTAC, PSZ_AC, PSZ_HP, PVAV_Reheat, PVAV_PFP_Boxes, VAV_Reheat, VAV_PFP_Boxes, Gas_Furnace, Electric_Furnace



621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 621

def model_prm_baseline_system_type(model, climate_zone, area_type, fuel_type, area_ft2, num_stories, custom)
  #             [type, central_heating_fuel, zone_heating_fuel, cooling_fuel]
  system_type = [nil, nil, nil, nil]

  # Get the row from TableG3.1.1A
  sys_num = model_prm_baseline_system_number(model, climate_zone, area_type, fuel_type, area_ft2, num_stories, custom)

  # Modify the fuel type if called for by the standard
  fuel_type = model_prm_baseline_system_change_fuel_type(model, fuel_type, climate_zone, custom)

  # Define the lookup by row and by fuel type
  sys_lookup = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }

  # fossil, fossil and electric, purchased heat, purchased heat and cooling
  sys_lookup['1_or_2']['fossil'] = ['PTAC', 'NaturalGas', nil, 'Electricity']
  sys_lookup['1_or_2']['fossilandelectric'] = ['PTAC', 'NaturalGas', nil, 'Electricity']
  sys_lookup['1_or_2']['purchasedheat'] = ['PTAC', 'DistrictHeating', nil, 'Electricity']
  sys_lookup['1_or_2']['purchasedheatandcooling'] = ['Fan_Coil', 'DistrictHeating', nil, 'DistrictCooling']
  sys_lookup['3_or_4']['fossil'] = ['PSZ_AC', 'NaturalGas', nil, 'Electricity']
  sys_lookup['3_or_4']['fossilandelectric'] = ['PSZ_AC', 'NaturalGas', nil, 'Electricity']
  sys_lookup['3_or_4']['purchasedheat'] = ['PSZ_AC', 'DistrictHeating', nil, 'Electricity']
  sys_lookup['3_or_4']['purchasedheatandcooling'] = ['PSZ_AC', 'DistrictHeating', nil, 'DistrictCooling']
  sys_lookup['5_or_6']['fossil'] = ['PVAV_Reheat', 'NaturalGas', 'NaturalGas', 'Electricity']
  sys_lookup['5_or_6']['fossilandelectric'] = ['PVAV_Reheat', 'NaturalGas', 'Electricity', 'Electricity']
  sys_lookup['5_or_6']['purchasedheat'] = ['PVAV_Reheat', 'DistrictHeating', 'DistrictHeating', 'Electricity']
  sys_lookup['5_or_6']['purchasedheatandcooling'] = ['PVAV_Reheat', 'DistrictHeating', 'DistrictHeating', 'DistrictCooling']
  sys_lookup['7_or_8']['fossil'] = ['VAV_Reheat', 'NaturalGas', 'NaturalGas', 'Electricity']
  sys_lookup['7_or_8']['fossilandelectric'] = ['VAV_Reheat', 'NaturalGas', 'Electricity', 'Electricity']
  sys_lookup['7_or_8']['purchasedheat'] = ['VAV_Reheat', 'DistrictHeating', 'DistrictHeating', 'Electricity']
  sys_lookup['7_or_8']['purchasedheatandcooling'] = ['VAV_Reheat', 'DistrictHeating', 'DistrictHeating', 'DistrictCooling']
  sys_lookup['9_or_10']['fossil'] = ['Gas_Furnace', 'NaturalGas', nil, nil]
  sys_lookup['9_or_10']['fossilandelectric'] = ['Gas_Furnace', 'NaturalGas', nil, nil]
  sys_lookup['9_or_10']['purchasedheat'] = ['Gas_Furnace', 'DistrictHeating', nil, nil]
  sys_lookup['9_or_10']['purchasedheatandcooling'] = ['Gas_Furnace', 'DistrictHeating', nil, nil]
  # electric (heat), purchased cooling
  sys_lookup['1_or_2']['electric'] = ['PTHP', 'Electricity', nil, 'Electricity']
  sys_lookup['1_or_2']['purchasedcooling'] = ['Fan_Coil', 'NaturalGas', nil, 'DistrictCooling']
  sys_lookup['3_or_4']['electric'] = ['PSZ_HP', 'Electricity', nil, 'Electricity']
  sys_lookup['3_or_4']['purchasedcooling'] = ['PSZ_AC', 'NaturalGas', nil, 'DistrictCooling']
  sys_lookup['5_or_6']['electric'] = ['PVAV_PFP_Boxes', 'Electricity', 'Electricity', 'Electricity']
  sys_lookup['5_or_6']['purchasedcooling'] = ['PVAV_PFP_Boxes', 'Electricity', 'Electricity', 'DistrictCooling']
  sys_lookup['7_or_8']['electric'] = ['VAV_PFP_Boxes', 'Electricity', 'Electricity', 'Electricity']
  sys_lookup['7_or_8']['purchasedcooling'] = ['VAV_PFP_Boxes', 'Electricity', 'Electricity', 'DistrictCooling']
  sys_lookup['9_or_10']['electric'] = ['Electric_Furnace', 'Electricity', nil, nil]
  sys_lookup['9_or_10']['purchasedcooling'] = ['Electric_Furnace', 'Electricity', nil, nil]

  # Get the system type
  system_type = sys_lookup[sys_num][fuel_type]

  if system_type.nil?
    system_type = [nil, nil, nil, nil]
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Could not determine system type for #{template}, #{area_type}, #{fuel_type}, #{area_ft2.round} ft^2, #{num_stories} stories.")
  else
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "System type is #{system_type[0]} for #{template}, #{area_type}, #{fuel_type}, #{area_ft2.round} ft^2, #{num_stories} stories.")
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "--- #{system_type[1]} for main heating") unless system_type[1].nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "--- #{system_type[2]} for zone heat/reheat") unless system_type[2].nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "--- #{system_type[3]} for cooling") unless system_type[3].nil?
  end

  return system_type
end

#model_prm_skylight_to_roof_ratio_limit(model) ⇒ Double

Determines the skylight to roof ratio limit for a given standard 5% by default.

Returns:

  • (Double)

    the skylight to roof ratio, as a percent: 5.0 = 5%



3828
3829
3830
3831
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3828

def model_prm_skylight_to_roof_ratio_limit(model)
  srr_lim = 5.0
  return srr_lim
end

#model_process_results_for_datapoint(model, climate_zone, building_type) ⇒ Hash

Method to gather prototype simulation results for a specific climate zone, building type, and template

Parameters:

  • climate_zone (String)

    string for the ASHRAE climate zone.

  • building_type (String)

    string for prototype building type.

Returns:

  • (Hash)

    Returns a hash with data presented in various bins. Returns nil if no search results



2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2911

def model_process_results_for_datapoint(model, climate_zone, building_type)
  # Hash to store the legacy results by fuel and by end use
  legacy_results_hash = {}
  legacy_results_hash['total_legacy_energy_val'] = 0
  legacy_results_hash['total_legacy_water_val'] = 0
  legacy_results_hash['total_energy_by_fuel'] = {}
  legacy_results_hash['total_energy_by_end_use'] = {}

  # Get the legacy simulation results
  legacy_values = model_legacy_results_by_end_use_and_fuel_type(model, climate_zone, building_type, 'annual')
  if legacy_values.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Could not find legacy idf results for #{search_criteria}")
    return legacy_results_hash
  end

  # List of all fuel types
  fuel_types = ['Electricity', 'Natural Gas', 'Additional Fuel', 'District Cooling', 'District Heating', 'Water']

  # List of all end uses
  end_uses = ['Heating', 'Cooling', 'Interior Lighting', 'Exterior Lighting', 'Interior Equipment', 'Exterior Equipment', 'Fans', 'Pumps', 'Heat Rejection', 'Humidification', 'Heat Recovery', 'Water Systems', 'Refrigeration', 'Generators']

  # Sum the legacy results up by fuel and by end use
  fuel_types.each do |fuel_type|
    end_uses.each do |end_use|
      next if end_use == 'Exterior Equipment'

      legacy_val = legacy_values["#{end_use}|#{fuel_type}"]

      # Combine the exterior lighting and exterior equipment
      if end_use == 'Exterior Lighting'
        legacy_exterior_equipment = legacy_values["Exterior Equipment|#{fuel_type}"]
        unless legacy_exterior_equipment.nil?
          legacy_val += legacy_exterior_equipment
        end
      end

      if legacy_val.nil?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "#{fuel_type} #{end_use} legacy idf value not found")
        next
      end

      # Add the energy to the total
      if fuel_type == 'Water'
        legacy_results_hash['total_legacy_water_val'] += legacy_val
      else
        legacy_results_hash['total_legacy_energy_val'] += legacy_val

        # add to fuel specific total
        if legacy_results_hash['total_energy_by_fuel'][fuel_type]
          legacy_results_hash['total_energy_by_fuel'][fuel_type] += legacy_val # add to existing counter
        else
          legacy_results_hash['total_energy_by_fuel'][fuel_type] = legacy_val # start new counter
        end

        # add to end use specific total
        if legacy_results_hash['total_energy_by_end_use'][end_use]
          legacy_results_hash['total_energy_by_end_use'][end_use] += legacy_val # add to existing counter
        else
          legacy_results_hash['total_energy_by_end_use'][end_use] = legacy_val # start new counter
        end
      end
    end
  end

  return legacy_results_hash
end

#model_remap_office(model, floor_area) ⇒ String

remap office to one of the protptye buildings

Parameters:

  • floor_area (Double)

    floor area (m^2)

Returns:

  • (String)

    SmallOffice, MediumOffice, LargeOffice



3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3071

def model_remap_office(model, floor_area)
  # prototype small office approx 500 m^2
  # prototype medium office approx 5000 m^2
  # prototype large office approx 50,000 m^2
  # map office building type to small medium or large
  building_type = if floor_area < 2750
                    'SmallOffice'
                  elsif floor_area < 25_250
                    'MediumOffice'
                  else
                    'LargeOffice'
                  end
end

#model_remove_external_shading_devices(model) ⇒ Bool

Remove external shading devices. Site shading will not be impacted.

Returns:

  • (Bool)

    returns true if successful, false if not.



3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3886

def model_remove_external_shading_devices(model)
  shading_surfaces_removed = 0
  model.getShadingSurfaceGroups.sort.each do |shade_group|
    # Skip Site shading
    next if shade_group.shadingSurfaceType == 'Site'

    # Space shading surfaces should be removed
    shading_surfaces_removed += shade_group.shadingSurfaces.size
    shade_group.remove
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Removed #{shading_surfaces_removed} external shading devices.")

  return true
end

#model_remove_prm_ems_objects(model) ⇒ Bool

Remove EMS objects that may be orphaned from removing HVAC

Returns:

  • (Bool)

    true if successful, false if not



3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3867

def model_remove_prm_ems_objects(model)
  model.getEnergyManagementSystemActuators.each(&:remove)
  model.getEnergyManagementSystemConstructionIndexVariables.each(&:remove)
  model.getEnergyManagementSystemCurveOrTableIndexVariables.each(&:remove)
  model.getEnergyManagementSystemGlobalVariables.each(&:remove)
  model.getEnergyManagementSystemInternalVariables.each(&:remove)
  model.getEnergyManagementSystemMeteredOutputVariables.each(&:remove)
  model.getEnergyManagementSystemOutputVariables.each(&:remove)
  model.getEnergyManagementSystemPrograms.each(&:remove)
  model.getEnergyManagementSystemProgramCallingManagers.each(&:remove)
  model.getEnergyManagementSystemSensors.each(&:remove)
  model.getEnergyManagementSystemSubroutines.each(&:remove)
  model.getEnergyManagementSystemTrendVariables.each(&:remove)

  return true
end

#model_remove_prm_hvac(model) ⇒ Bool

Remove all HVAC that will be replaced during the performance rating method baseline generation. This does not include plant loops that serve WaterUse:Equipment or Fan:ZoneExhaust

Returns:

  • (Bool)

    true if successful, false if not



3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3837

def model_remove_prm_hvac(model)
  # Plant loops
  model.getPlantLoops.sort.each do |loop|
    # Don't remove service water heating loops
    next if plant_loop_swh_loop?(loop)

    loop.remove
  end

  # Air loops
  model.getAirLoopHVACs.each(&:remove)

  # Zone equipment
  model.getThermalZones.sort.each do |zone|
    zone.equipment.each do |zone_equipment|
      next if zone_equipment.to_FanZoneExhaust.is_initialized

      zone_equipment.remove
    end
  end

  # Outdoor VRF units (not in zone, not in loops)
  model.getAirConditionerVariableRefrigerantFlows.each(&:remove)

  return true
end

#model_remove_unused_resource_objects(model) ⇒ Bool

Removes all of the unused ResourceObjects (Curves, ScheduleDay, Material, etc.) from the model.

Returns:

  • (Bool)

    returns true if successful, false if not



4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4648

def model_remove_unused_resource_objects(model)
  start_size = model.objects.size
  model.getResourceObjects.sort.each do |obj|
    if obj.directUseCount.zero?
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "#{obj.name} is unused; it will be removed.")
      model.removeObject(obj.handle)
    end
  end
  end_size = model.objects.size
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "The model started with #{start_size} objects and finished with #{end_size} objects after removing unused resource objects.")
  return true
end

#model_residential_and_nonresidential_floor_areas(model) ⇒ Hash

Determine the residential and nonresidential floor areas based on the space type properties for each space. For spaces with no space type, assume nonresidential.

Returns:

  • (Hash)

    keys are ‘residential’ and ‘nonresidential’, units are m^2



251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 251

def model_residential_and_nonresidential_floor_areas(model)
  res_area_m2 = 0
  nonres_area_m2 = 0
  model.getSpaces.sort.each do |space|
    if thermal_zone_residential?(space)
      res_area_m2 += space.floorArea
    else
      nonres_area_m2 += space.floorArea
    end
  end

  return { 'residential' => res_area_m2, 'nonresidential' => nonres_area_m2 }
end

#model_set_climate_zone(model, climate_zone) ⇒ Boolean

Sets the climate zone object in the model using the correct institution based on the climate zone specified in the format used by the openstudio-standards lookups. Clears out any climate zones previously added to the model.

For example: ASHRAE 169-2013-2A, CEC T24-CEC3

Parameters:

Returns:

  • (Boolean)

    returns true if successful, false if not



4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4526

def model_set_climate_zone(model, climate_zone)
  # Remove previous climate zones from the model
  model.getClimateZones.clear
  # Split the string into the correct institution and value
  if climate_zone.include? 'ASHRAE 169-2006-'
    model.getClimateZones.setClimateZone('ASHRAE', climate_zone.gsub('ASHRAE 169-2006-', ''))
  elsif climate_zone.include? 'ASHRAE 169-2013-'
    model.getClimateZones.setClimateZone('ASHRAE', climate_zone.gsub('ASHRAE 169-2013-', ''))
  elsif climate_zone.include? 'CEC T24-CEC'
    model.getClimateZones.setClimateZone('CEC', climate_zone.gsub('CEC T24-CEC', ''))

  end
  return true
end

#model_setup_parametric_schedules(model, step_ramp_logic: nil, infer_hoo_for_non_assigned_objects: true, gather_data_only: false, hoo_var_method: 'hours') ⇒ Hash

This method users the hours of operation for a space and the existing ScheduleRuleset profiles to setup parametric schedule inputs. Inputs include one or more load profile formulas. Data is stored in model attributes for downstream application. This should impact all ScheduleRuleset objects in the model. Plant and Air loop hoours of operations should be traced back to a space or spaces.

Parameters:

  • model (Model)
  • step_ramp_logic (String) (defaults to: nil)
  • infer_hoo_for_non_assigned_objects (Bool) (defaults to: true)

    # attempt to get hoo for objects like swh with and exterior lighting

  • gather_data_only: (defaults to: false)

    false (stops method before changes made if true)

  • accepts (hoo_var_method)

    hours and fractional. Any other value value will result in hoo variables not being applied

Returns:

  • (Hash)

    schedule is key, value is hash of number of objects

Author:

  • David Goldwasser



4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4831

def model_setup_parametric_schedules(model, step_ramp_logic: nil, infer_hoo_for_non_assigned_objects: true, gather_data_only: false, hoo_var_method: 'hours')
  parametric_inputs = {}
  default_sch_type = OpenStudio::Model::DefaultScheduleType.new('HoursofOperationSchedule')
  # thermal zones, air loops, plant loops will require some logic if they refer to more than one hours of operaiton schedule.
  # for initial use case while have same horus of operaiton so this can be pretty simple, but will have to re-visit it sometime
  # possible solution A: choose hoo that contributes the largest fraction of floor area
  # possible solution B: expand the hours of operation for a given day to include combined range of hoo objects
  # whatever approach is used for gathering parametric inputs for existing ruleset schedules should also be used for model_apply_parametric_schedules

  # loop through spaces (trace hours of operation back to space)
  gather_inputs_parametric_space_space_type_schedules(model.getSpaces, parametric_inputs, gather_data_only)

  # loop through space types (trace hours of operation back to space type).
  gather_inputs_parametric_space_space_type_schedules(model.getSpaceTypes, parametric_inputs, gather_data_only)

  # loop through thermal zones (trace hours of operation back to spaces in thermal zone)
  thermal_zone_hash = {} # key is zone and hash is hours of operation
  model.getThermalZones.sort.each do |zone|
    # identify hours of operation
    hours_of_operation = spaces_hours_of_operation(zone.spaces)
    thermal_zone_hash[zone] = hours_of_operation
    # get thermostat setpoint schedules
    if zone.thermostatSetpointDualSetpoint.is_initialized
      thermostat = zone.thermostatSetpointDualSetpoint.get
      if thermostat.heatingSetpointTemperatureSchedule.is_initialized && thermostat.heatingSetpointTemperatureSchedule.get.to_ScheduleRuleset.is_initialized
        schedule = thermostat.heatingSetpointTemperatureSchedule.get.to_ScheduleRuleset.get
        gather_inputs_parametric_schedules(schedule, thermostat, parametric_inputs, hours_of_operation, gather_data_only: gather_data_only, hoo_var_method: hoo_var_method)
      end
      if thermostat.coolingSetpointTemperatureSchedule.is_initialized && thermostat.coolingSetpointTemperatureSchedule.get.to_ScheduleRuleset.is_initialized
        schedule = thermostat.coolingSetpointTemperatureSchedule.get.to_ScheduleRuleset.get
        gather_inputs_parametric_schedules(schedule, thermostat, parametric_inputs, hours_of_operation, gather_data_only: gather_data_only, hoo_var_method: hoo_var_method)
      end
    end
  end

  # loop through air loops (trace hours of operation back through spaces served by air loops)
  air_loop_hash = {} # key is zone and hash is hours of operation
  model.getAirLoopHVACs.sort.each do |air_loop|
    # identify hours of operation
    air_loop_spaces = []
    air_loop.thermalZones.sort.each do |zone|
      air_loop_spaces += zone.spaces
      air_loop_spaces += zone.spaces
    end
    hours_of_operation = spaces_hours_of_operation(air_loop_spaces)
    air_loop_hash[air_loop] = hours_of_operation
    if air_loop.availabilitySchedule.to_ScheduleRuleset.is_initialized
      schedule = air_loop.availabilitySchedule.to_ScheduleRuleset.get
      gather_inputs_parametric_schedules(schedule, air_loop, parametric_inputs, hours_of_operation, gather_data_only: gather_data_only, hoo_var_method: hoo_var_method)
    end
    avail_mgrs = air_loop.availabilityManagers
    avail_mgrs.sort.each do |avail_mgr|
      # TODO: - I'm finding availability mangers, but not any resources for them, even if I use OpenStudio::Model.getRecursiveChildren(avail_mgr)
      resources = avail_mgr.resources
      resources = OpenStudio::Model.getRecursiveResources(avail_mgr)
      resources.sort.each do |resource|
        if resource.to_ScheduleRuleset.is_initialized
          schedule = resource.to_ScheduleRuleset.get
          gather_inputs_parametric_schedules(schedule, avail_mgr, parametric_inputs, hours_of_operation, gather_data_only: gather_data_only, hoo_var_method: hoo_var_method)
        end
      end
    end
  end

  # look through all model HVAC components find scheduleRuleset objects, resources, that use them and zone or air loop for hours of operation
  hvac_components = model.getHVACComponents
  hvac_components.sort.each do |component|
    # identify zone, or air loop it refers to, some may refer to plant loop, OA or other component
    thermal_zone = nil
    air_loop = nil
    plant_loop = nil
    schedules = []
    if component.to_ZoneHVACComponent.is_initialized && component.to_ZoneHVACComponent.get.thermalZone.is_initialized
      thermal_zone = component.to_ZoneHVACComponent.get.thermalZone.get
    end
    if component.airLoopHVAC.is_initialized
      air_loop = component.airLoopHVAC.get
    end
    if component.plantLoop.is_initialized
      plant_loop = component.plantLoop.get
    end
    component.resources.sort.each do |resource|
      if resource.to_ThermalZone.is_initialized
        thermal_zone = resource.to_ThermalZone.get
      elsif resource.to_ScheduleRuleset.is_initialized
        schedules << resource.to_ScheduleRuleset.get
      end
    end

    # inspect resources for children of objects found in thermal zone or plant loop
    # get objects like OA controllers and unitary object components
    next if thermal_zone.nil? && air_loop.nil?

    children = OpenStudio::Model.getRecursiveChildren(component)
    children.sort.each do |child|
      child.resources.sort.each do |sub_resource|
        if sub_resource.to_ScheduleRuleset.is_initialized
          schedules << sub_resource.to_ScheduleRuleset.get
        end
      end
    end

    # process schedules found for this component
    schedules.sort.each do |schedule|
      hours_of_operation = nil
      if !thermal_zone.nil?
        hours_of_operation = thermal_zone_hash[thermal_zone]
      elsif !air_loop.nil?
        hours_of_operation = air_loop_hash[air_loop]
      elsif !plant_loop.nil?
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "#{schedule.name.get} is associated with plant loop, will not gather parametric inputs")
        next
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', "Cannot identify where #{component.name.get} is in system. Will not gather parametric inputs for #{schedule.name.get}")
        next
      end
      gather_inputs_parametric_schedules(schedule, component, parametric_inputs, hours_of_operation, gather_data_only: gather_data_only, hoo_var_method: hoo_var_method)
    end
  end

  # TODO: - Service Water Heating supply side (may or may not be associated with a space)
  # todo - water use equipment definitions (temperature, sensible, latent) may be in multiple spaces, need to identify hoo, but typically constant schedules

  # water use equipment (flow rate fraction)
  # todo - address common schedules used across multiple instances
  model.getWaterUseEquipments.sort.each do |water_use_equipment|
    if water_use_equipment.flowRateFractionSchedule.is_initialized && water_use_equipment.flowRateFractionSchedule.get.to_ScheduleRuleset.is_initialized
      schedule = water_use_equipment.flowRateFractionSchedule.get.to_ScheduleRuleset.get
      next if parametric_inputs.key?(schedule)

      opt_space = water_use_equipment.space
      if opt_space.is_initialized
        space = space.get
        hours_of_operation = space_hours_of_operation(space)
        gather_inputs_parametric_schedules(schedule, water_use_equipment, parametric_inputs, hours_of_operation, gather_data_only: gather_data_only, hoo_var_method: hoo_var_method)
      else
        hours_of_operation = spaces_hours_of_operation(model.getSpaces)
        if !hours_of_operation.nil?
          gather_inputs_parametric_schedules(schedule, water_use_equipment, parametric_inputs, hours_of_operation, gather_data_only: gather_data_only, hoo_var_method: hoo_var_method)
        end
      end

    end
  end
  # TODO: - Refrigeration (will be associated with thermal zone)
  # todo - exterior lights (will be astronomical, but like AEDG's may have reduction later at night)

  return parametric_inputs
end

#model_standards_climate_zone(model) ⇒ String

Converts the climate zone in the model into the format used by the openstudio-standards lookup tables. For example: institution: ASHRAE, value: 6A becomes: ASHRAE 169-2013-6A. institution: CEC, value: 3 becomes: CEC T24-CEC3.

empty string if no climate zone is present in the model.

Parameters:

Returns:

  • (String)

    the string representation of the climate zone,



4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4497

def model_standards_climate_zone(model)
  climate_zone = ''
  model.getClimateZones.climateZones.each do |cz|
    if cz.institution == 'ASHRAE'
      next if cz.value == '' # Skip blank ASHRAE climate zones put in by OpenStudio Application

      climate_zone = if cz.value == '7' || cz.value == '8'
                       "ASHRAE 169-2013-#{cz.value}A"
                     else
                       "ASHRAE 169-2013-#{cz.value}"
                     end
    elsif cz.institution == 'CEC'
      next if cz.value == '' # Skip blank ASHRAE climate zones put in by OpenStudio Application

      climate_zone = "CEC T24-CEC#{cz.value}"
    end
  end
  return climate_zone
end

#model_system_outdoor_air_sizing_vrp_method(air_loop_hvac) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.SizingSystem.rb', line 41

def model_system_outdoor_air_sizing_vrp_method(air_loop_hvac)
  sizing_system = air_loop_hvac.sizingSystem
  # sizing_system.setSystemOutdoorAirMethod("VentilationRateProcedure")
  # Set the minimum zone ventilation efficiency to be 0.6
  air_loop_hvac.thermalZones.sort.each do |zone|
    sizing_zone = zone.sizingZone
    # It is not yet possible to adjust the minimum zone ventilation efficiency
    # @todo, update this section when OS allows to adjust minimum zone ventilation efficiency
    # In EnergyPlus this is done through the DesignSpecification:ZoneAirDistribution object
    # which is then assigned to a Sizing:Zone object
  end

  return true
end

#model_typical_display_case_zone(model) ⇒ Object

Find the thermal zone that is best for adding refrigerated display cases into. First, check for space types that typically have refrigeration. Fall back to largest zone in the model if no typical space types are found.

# @param model [OpenStudio::Model::Model] the model
# @return [OpenStudio::Model::ThermalZone] returns a thermal zone if found, nil if not.


377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.refrigeration.rb', line 377

def model_typical_display_case_zone(model)
  # Ideally, look for one of the space types
  # that would typically have refrigeration.
  display_case_zone = nil
  display_case_zone_area_m2 = 0
  model.getThermalZones.each do |zone|
    space_type = thermal_zone_majority_space_type(zone)
    next if space_type.empty?

    space_type = space_type.get
    next if space_type.standardsSpaceType.empty?
    next if space_type.standardsBuildingType.empty?

    stds_spc_type = space_type.standardsSpaceType.get
    stds_bldg_type = space_type.standardsBuildingType.get
    case "#{stds_bldg_type} #{stds_spc_type}"
    when 'PrimarySchool Kitchen',
        'SecondarySchool Kitchen',
        'SuperMarket Sales',
        'QuickServiceRestaurant Kitchen',
        'FullServiceRestaurant Kitchen',
        'LargeHotel Kitchen',
        'Hospital Kitchen',
        'EPr Kitchen',
        'ESe Kitchen',
        'Gro GrocSales',
        'RFF StockRoom',
        'RSD StockRoom',
        'Htl Kitchen',
        'Hsp Kitchen'
      if zone.floorArea > display_case_zone_area_m2
        display_case_zone = zone
        display_case_zone_area_m2 = zone.floorArea
      end
    end
  end

  unless display_case_zone.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Display case zone is #{display_case_zone.name}, the largest zone with a space type typical for display cases.")
    return display_case_zone
  end

  # If no typical space type was found,
  # choose the largest zone in the model.
  display_case_zone = nil
  display_case_zone_area_m2 = 0
  model.getThermalZones.each do |zone|
    if zone.floorArea > display_case_zone_area_m2
      display_case_zone = zone
      display_case_zone_area_m2 = zone.floorArea
    end
  end

  unless display_case_zone.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "No space types typical for display cases were found, so the display cases will be placed in #{display_case_zone.name}, the largest zone.")
    return display_case_zone
  end

  return display_case_zone
end

#model_typical_hvac_system_type(model, climate_zone, area_type, delivery_type, heating_source, cooling_source, area_m2, num_stories) ⇒ Array

Determine the typical system type given the inputs.

Parameters:

  • area_type (String)

    Valid choices are residential and nonresidential

  • delivery_type (String)

    Conditioning delivery type. Valid choices are air and hydronic

  • heating_source (String)

    Valid choices are Electricity, NaturalGas, DistrictHeating, DistrictAmbient

  • cooling_source (String)

    Valid choices are Electricity, DistrictCooling, DistrictAmbient

  • area_m2 (Double)

    Area in m^2

  • num_stories (Integer)

    Number of stories

Returns:

  • (Array)

    An array containing the system type, central heating fuel, zone heating fuel, and cooling fuel



498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.hvac.rb', line 498

def model_typical_hvac_system_type(model,
                                   climate_zone,
                                   area_type,
                                   delivery_type,
                                   heating_source,
                                   cooling_source,
                                   area_m2,
                                   num_stories)

  # Convert area to ft^2
  area_ft2 = OpenStudio.convert(area_m2, 'm^2', 'ft^2').get

  case area_type
  when 'residential'
    area_type = 'Residential'
  when 'nonresidential', 'retail', 'publicassembly', 'heatedonly'
    area_type = 'Nonresidential'
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "area_type '#{area_type}' invalid or missing.")
    return nil
  end

  # lookup size category
  search_criteria = {}
  search_criteria['template'] = template
  search_criteria['building_category'] = area_type
  size_data = model_find_object(standards_data['size_category'], search_criteria, nil, nil, area_ft2, num_stories)
  if size_data.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Unable to find size category for #{search_criteria}.")
    return nil
  end

  # lookup infered HVAC system type
  search_criteria = {}
  search_criteria['template'] = template
  search_criteria['size_category'] = size_data['size_category']
  search_criteria['heating_source'] = heating_source
  search_criteria['cooling_source'] = cooling_source
  search_criteria['delivery_type'] = delivery_type
  hvac_data = model_find_object(standards_data['hvac_inference'], search_criteria)

  # return system type inputs with format [type, central_heating_fuel, zone_heating_fuel, cooling_fuel]
  if hvac_data.nil? || hvac_data.empty?
    system_type_inputs = [nil, nil, nil, nil]
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Could not determine system type for #{area_type} building of size #{area_ft2.round} ft^2 and #{num_stories} stories, and lookups #{search_criteria}.")
  else
    system_type_inputs = [hvac_data['hvac_system_type'], hvac_data['central_heating_fuel'], hvac_data['zone_heating_fuel'], hvac_data['cooling_fuel']]
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "System type is #{system_type_inputs[0]} for #{area_type} building of size #{area_ft2.round} ft^2 and #{num_stories} stories, and lookups #{search_criteria}.")
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "--- #{system_type_inputs[1]} for main heating") unless system_type_inputs[1].nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "--- #{system_type_inputs[2]} for zone heat/reheat") unless system_type_inputs[2].nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "--- #{system_type_inputs[3]} for cooling") unless system_type_inputs[3].nil?
  end

  return system_type_inputs
end

#model_typical_walkin_zone(model) ⇒ OpenStudio::Model::ThermalZone

Find the thermal zone that is best for adding refrigerated walkins into. First, check for space types that typically have refrigeration. Fall back to largest zone in the model if no typical space types are found.

Parameters:

Returns:



443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.refrigeration.rb', line 443

def model_typical_walkin_zone(model)
  # Ideally, look for one of the space types
  # that would typically have refrigeration walkins.
  walkin_zone = nil
  walkin_zone_area_m2 = 0
  model.getThermalZones.each do |zone|
    space_type = thermal_zone_majority_space_type(zone)
    next if space_type.empty?

    space_type = space_type.get
    next if space_type.standardsSpaceType.empty?
    next if space_type.standardsBuildingType.empty?

    stds_spc_type = space_type.standardsSpaceType.get
    stds_bldg_type = space_type.standardsBuildingType.get
    case "#{stds_bldg_type} #{stds_spc_type}"
    when 'PrimarySchool Kitchen',
        'SecondarySchool Kitchen',
        'SuperMarket DryStorage',
        'QuickServiceRestaurant	Kitchen',
        'FullServiceRestaurant Kitchen',
        'LargeHotel Kitchen',
        'Hospital Kitchen',
        'EPr Kitchen',
        'ESe Kitchen',
        'Gro RefWalkInCool',
        'Gro RefWalkInFreeze',
        'RFF StockRoom',
        'RSD StockRoom',
        'Htl Kitchen',
        'Hsp Kitchen'
      if zone.floorArea > walkin_zone_area_m2
        walkin_zone = zone
        walkin_zone_area_m2 = zone.floorArea
      end
    end
  end

  unless walkin_zone.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Walkin zone is #{walkin_zone.name}, the largest zone with a space type typical for walkins.")
    return walkin_zone
  end

  # If no typical space type was found,
  # choose the largest zone in the model.
  walkin_zone = nil
  walkin_zone_area_m2 = 0
  model.getThermalZones.each do |zone|
    if zone.floorArea > walkin_zone_area_m2
      walkin_zone = zone
      walkin_zone_area_m2 = zone.floorArea
    end
  end

  unless walkin_zone.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "No space types typical for walkins were found, so the walkins will be placed in #{walkin_zone.name}, the largest zone.")
    return walkin_zone
  end

  return walkin_zone
end

#model_validate_standards_spacetypes_in_model(model) ⇒ Object

This method ensures that all spaces with spacetypes defined contain at least a standardSpaceType appropriate for the template. So, if any space with a space type defined does not have a Stnadard spacetype, or is undefined, an error will stop with information that the spacetype needs to be defined.



4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4155

def model_validate_standards_spacetypes_in_model(model)
  error_string = ''
  # populate search hash
  model.getSpaces.sort.each do |space|
    unless space.spaceType.empty?
      if space.spaceType.get.standardsSpaceType.empty? || space.spaceType.get.standardsBuildingType.empty?
        error_string << "Space: #{space.name} has SpaceType of #{space.spaceType.get.name} but the standardSpaceType or standardBuildingType  is undefined. Please use an appropriate standardSpaceType for #{template}\n"
        next
      else
        search_criteria = {
          'template' => template,
          'building_type' => space.spaceType.get.standardsBuildingType.get,
          'space_type' => space.spaceType.get.standardsSpaceType.get
        }
        # lookup space type properties
        space_type_properties = model_find_object(standards_data['space_types'], search_criteria)
        if space_type_properties.nil?
          error_string << "Could not find spacetype of criteria : #{search_criteria}. Please ensure you have a valid standardSpaceType and stantdardBuildingType defined.\n"
          space_type_properties = {}
        end
      end
    end
  end
  if error_string == ''
    return true
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', error_string)
    return false
  end
end

#model_ventilation_method(model) ⇒ String

Determines how ventilation for the standard is specified. When ‘Sum’, all min OA flow rates are added up. Commonly used by 90.1. When ‘Maximum’, only the biggest OA flow rate. Used by T24.

Parameters:

Returns:

  • (String)

    the ventilation method, either Sum or Maximum



4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4632

def model_ventilation_method(model)
  building_data = model_get_building_climate_zone_and_building_type(model)
  building_type = building_data['building_type']
  if building_type != 'Laboratory' # Laboratory has multiple criteria on ventilation, pick the greatest
    ventilation_method = 'Sum'
  else
    ventilation_method = 'Maximum'
  end

  return ventilation_method
end

#model_walkin_freezer_latent_case_credit_curve(model) ⇒ Object

TODO:

Should probably use the model_add_refrigeration_walkin

Determine the latent case credit curve to use for walkins. Defaults to values after 90.1-2007. and lookups from the spreadsheet instead of hard-coded values.



826
827
828
829
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.refrigeration.rb', line 826

def model_walkin_freezer_latent_case_credit_curve(model)
  latent_case_credit_curve_name = 'Single Shelf Horizontal Latent Energy Multiplier_After2004'
  return latent_case_credit_curve_name
end

#model_zones_with_occ_and_fuel_type(model, custom) ⇒ Array<Hash>

Categorize zones by occupancy type and fuel type, where the types depend on the standard.

Returns:

  • (Array<Hash>)

    an array of hashes, one for each zone, with the keys ‘zone’, ‘type’ (occ type), ‘fuel’, and ‘area’



299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 299

def model_zones_with_occ_and_fuel_type(model, custom)
  zones = []

  model.getThermalZones.sort.each do |zone|
    # Skip plenums
    if thermal_zone_plenum?(zone)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Zone #{zone.name} is a plenum.  It will not be assigned a baseline system.")
      next
    end

    # Skip unconditioned zones
    heated = thermal_zone_heated?(zone)
    cooled = thermal_zone_cooled?(zone)
    if !heated && !cooled
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Model', "Zone #{zone.name} is unconditioned.  It will not be assigned a baseline system.")
      next
    end

    zn_hash = {}

    # The zone object
    zn_hash['zone'] = zone

    # Floor area
    zn_hash['area'] = zone.floorArea

    # Occupancy type
    zn_hash['occ'] = thermal_zone_occupancy_type(zone)

    # Building type
    zn_hash['bldg_type'] = thermal_zone_building_type(zone)

    # Fuel type
    zn_hash['fuel'] = thermal_zone_fossil_or_electric_type(zone, custom)

    zones << zn_hash
  end

  return zones
end

#planar_surface_apply_standard_construction(planar_surface, climate_zone, previous_construction_map = {}) ⇒ Hash

TODO:

Align the standard construction enumerations in the

If construction properties can be found based on the template, the standards intended surface type, the standards construction type, the climate zone, and the occupancy type, create a construction that meets those properties and assign it to this surface.

90.1-2007, 90.1-2010, 90.1-2013

template, climate_zone, intended_surface_type, standards_construction_type, occ_type

and the values are the constructions. If supplied, constructions will be pulled from this hash if already created to avoid creating duplicate constructions.

template, climate_zone, intended_surface_type, standards_construction_type, occ_type

and the value is the newly created construction. This can be used to avoid creating duplicate constructions. spreadsheet with the enumerations in OpenStudio (follow CBECC-Com).

Parameters:

  • climate_zone (String)

    the climate zone

  • previous_construction_map (Hash) (defaults to: {})

    a hash where the keys are an array of inputs

Returns:

  • (Hash)

    returns a hash where the key is an array of inputs



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/openstudio-standards/standards/Standards.PlanarSurface.rb', line 24

def planar_surface_apply_standard_construction(planar_surface, climate_zone, previous_construction_map = {})
  # Skip surfaces not in a space
  return previous_construction_map if planar_surface.space.empty?

  space = planar_surface.space.get

  # Skip surfaces that don't have a construction
  return previous_construction_map if planar_surface.construction.empty?

  construction = planar_surface.construction.get

  # Determine if residential or nonresidential
  # based on the space type.
  occ_type = 'Nonresidential'
  if space_residential?(space)
    occ_type = 'Residential'
  end

  # Get the climate zone set
  climate_zone_set = model_find_climate_zone_set(planar_surface.model, climate_zone)

  # Get the intended surface type
  standards_info = construction.standardsInformation
  surf_type = standards_info.intendedSurfaceType
  if surf_type.empty?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlanarSurface', "Could not determine the intended surface type for #{planar_surface.name} from #{construction.name}.  This surface will not have the standard applied.")
    return previous_construction_map
  end
  surf_type = surf_type.get

  # Get the standards type, which is based on different fields
  # if is intended for a window, a skylight, or something else.
  # Mapping is between standards-defined enumerations and the
  # enumerations available in OpenStudio.
  stds_type = nil
  # Windows
  if surf_type == 'ExteriorWindow'
    stds_type = standards_info.fenestrationFrameType
    if stds_type.is_initialized
      stds_type = stds_type.get
      case stds_type
      when 'Metal Framing', 'Metal Framing with Thermal Break'
        stds_type = 'Metal framing (all other)'
      when 'Non-Metal Framing'
        stds_type = 'Nonmetal framing (all)'
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlanarSurface', "The standards fenestration frame type #{stds_type} cannot be used on #{surf_type} in #{planar_surface.name}.  This surface will not have the standard applied.")
        return previous_construction_map
      end
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlanarSurface', "Could not determine the standards fenestration frame type for #{planar_surface.name} from #{construction.name}.  This surface will not have the standard applied.")
      return previous_construction_map
    end
  # Skylights
  elsif surf_type == 'Skylight'
    stds_type = standards_info.fenestrationType
    if stds_type.is_initialized
      stds_type = stds_type.get
      case stds_type
      when 'Glass Skylight with Curb'
        stds_type = 'Glass with Curb'
      when 'Plastic Skylight with Curb'
        stds_type = 'Plastic with Curb'
      when 'Plastic Skylight without Curb', 'Glass Skylight without Curb'
        stds_type = 'Without Curb'
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlanarSurface', "The standards fenestration type #{stds_type} cannot be used on #{surf_type} in #{planar_surface.name}.  This surface will not have the standard applied.")
        return previous_construction_map
      end
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlanarSurface', "Could not determine the standards fenestration type for #{planar_surface.name} from #{construction.name}.  This surface will not have the standard applied.")
      return previous_construction_map
    end
  # All other surface types
  else
    stds_type = standards_info.standardsConstructionType
    if stds_type.is_initialized
      stds_type = stds_type.get
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlanarSurface', "Could not determine the standards construction type for #{planar_surface.name}.  This surface will not have the standard applied.")
      return previous_construction_map
    end
  end

  # Check if the construction type was already created.
  # If yes, use that construction.  If no, make a new one.
  new_construction = nil
  type = [template, climate_zone, surf_type, stds_type, occ_type]
  if previous_construction_map[type]
    new_construction = previous_construction_map[type]
  else
    new_construction = model_find_and_add_construction(planar_surface.model,
                                                       climate_zone_set,
                                                       surf_type,
                                                       stds_type,
                                                       occ_type)
    if !new_construction == false
      previous_construction_map[type] = new_construction
    end
  end

  # Assign the new construction to the surface
  if new_construction
    planar_surface.setConstruction(new_construction)
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.PlanarSurface', "Set the construction for #{planar_surface.name} to #{new_construction.name}.")
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlanarSurface', "Could not generate a standard construction for #{planar_surface.name}.")
    return previous_construction_map
  end

  return previous_construction_map
end

#plant_loop_apply_prm_baseline_chilled_water_pumping_type(plant_loop) ⇒ Object

Applies the chilled water pumping controls to the loop based on Appendix G.



696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 696

def plant_loop_apply_prm_baseline_chilled_water_pumping_type(plant_loop)
  # Determine the pumping type.
  minimum_cap_tons = 300

  # Determine the capacity
  cap_w = plant_loop_total_cooling_capacity(plant_loop)
  cap_tons = OpenStudio.convert(cap_w, 'W', 'ton').get

  # Determine if it a district cooling system
  has_district_cooling = false
  plant_loop.supplyComponents.each do |sc|
    if sc.to_DistrictCooling.is_initialized
      has_district_cooling = true
    end
  end

  # Determine the primary and secondary pumping types
  pri_control_type = nil
  sec_control_type = nil
  if has_district_cooling
    pri_control_type = if cap_tons > minimum_cap_tons
                         'VSD No Reset'
                       else
                         'Riding Curve'
                       end
  else
    pri_control_type = 'Constant Flow'
    sec_control_type = if cap_tons > minimum_cap_tons
                         'VSD No Reset'
                       else
                         'Riding Curve'
                       end
  end

  # Report out the pumping type
  unless pri_control_type.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, primary pump type is #{pri_control_type}.")
  end

  unless sec_control_type.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, secondary pump type is #{sec_control_type}.")
  end

  # Modify all the primary pumps
  plant_loop.supplyComponents.each do |sc|
    if sc.to_PumpVariableSpeed.is_initialized
      pump = sc.to_PumpVariableSpeed.get
      pump_variable_speed_set_control_type(pump, pri_control_type)
    elsif sc.to_HeaderedPumpsVariableSpeed.is_initialized
      pump = sc.to_HeaderedPumpsVariableSpeed.get
      headered_pump_variable_speed_set_control_type(pump, control_type)
    end
  end

  # Modify all the secondary pumps
  plant_loop.demandComponents.each do |sc|
    if sc.to_PumpVariableSpeed.is_initialized
      pump = sc.to_PumpVariableSpeed.get
      pump_variable_speed_set_control_type(pump, sec_control_type)
    elsif sc.to_HeaderedPumpsVariableSpeed.is_initialized
      pump = sc.to_HeaderedPumpsVariableSpeed.get
      headered_pump_variable_speed_set_control_type(pump, control_type)
    end
  end

  return true
end

#plant_loop_apply_prm_baseline_chilled_water_temperatures(plant_loop) ⇒ Object

Applies the chilled water temperatures to the plant loop based on Appendix G.



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 184

def plant_loop_apply_prm_baseline_chilled_water_temperatures(plant_loop)
  sizing_plant = plant_loop.sizingPlant

  # Loop properties
  # G3.1.3.8 - LWT 44 / EWT 56
  chw_temp_f = 44
  chw_delta_t_r = 12
  min_temp_f = 34
  max_temp_f = 200
  # For water-cooled chillers this is the water temperature entering the condenser (e.g., leaving the cooling tower).
  ref_cond_wtr_temp_f = 85

  chw_temp_c = OpenStudio.convert(chw_temp_f, 'F', 'C').get
  chw_delta_t_k = OpenStudio.convert(chw_delta_t_r, 'R', 'K').get
  min_temp_c = OpenStudio.convert(min_temp_f, 'F', 'C').get
  max_temp_c = OpenStudio.convert(max_temp_f, 'F', 'C').get
  ref_cond_wtr_temp_c = OpenStudio.convert(ref_cond_wtr_temp_f, 'F', 'C').get

  sizing_plant.setDesignLoopExitTemperature(chw_temp_c)
  sizing_plant.setLoopDesignTemperatureDifference(chw_delta_t_k)
  plant_loop.setMinimumLoopTemperature(min_temp_c)
  plant_loop.setMaximumLoopTemperature(max_temp_c)

  # ASHRAE Appendix G - G3.1.3.9 (for ASHRAE 90.1-2004, 2007 and 2010)
  # ChW reset: 44F at 80F and above, 54F at 60F and below
  plant_loop_enable_supply_water_temperature_reset(plant_loop)

  # Chiller properties
  plant_loop.supplyComponents.each do |sc|
    if sc.to_ChillerElectricEIR.is_initialized
      chiller = sc.to_ChillerElectricEIR.get
      chiller.setReferenceLeavingChilledWaterTemperature(chw_temp_c)
      chiller.setReferenceEnteringCondenserFluidTemperature(ref_cond_wtr_temp_c)
    end
  end

  return true
end

#plant_loop_apply_prm_baseline_condenser_water_pumping_type(plant_loop) ⇒ Object

Applies the condenser water pumping controls to the loop based on Appendix G.



797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 797

def plant_loop_apply_prm_baseline_condenser_water_pumping_type(plant_loop)
  # All condenser water loops are constant flow
  control_type = 'Constant Flow'

  # Report out the pumping type
  unless control_type.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, pump type is #{control_type}.")
  end

  # Modify all primary pumps
  plant_loop.supplyComponents.each do |sc|
    if sc.to_PumpVariableSpeed.is_initialized
      pump = sc.to_PumpVariableSpeed.get
      pump_variable_speed_set_control_type(pump, control_type)
    elsif sc.to_HeaderedPumpsVariableSpeed.is_initialized
      pump = sc.to_HeaderedPumpsVariableSpeed.get
      headered_pump_variable_speed_set_control_type(pump, control_type)
    end
  end

  return true
end

#plant_loop_apply_prm_baseline_condenser_water_temperatures(plant_loop) ⇒ Object

Applies the condenser water temperatures to the plant loop based on Appendix G.



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 224

def plant_loop_apply_prm_baseline_condenser_water_temperatures(plant_loop)
  sizing_plant = plant_loop.sizingPlant
  loop_type = sizing_plant.loopType
  return true unless loop_type == 'Condenser'

  # Much of the thought in this section came from @jmarrec

  # Determine the design OATwb from the design days.
  # Per https://unmethours.com/question/16698/which-cooling-design-day-is-most-common-for-sizing-rooftop-units/
  # the WB=>MDB day is used to size cooling towers.
  summer_oat_wbs_f = []
  plant_loop.model.getDesignDays.sort.each do |dd|
    next unless dd.dayType == 'SummerDesignDay'
    next unless dd.name.get.to_s.include?('WB=>MDB')

    if dd.humidityIndicatingType == 'Wetbulb'
      summer_oat_wb_c = dd.humidityIndicatingConditionsAtMaximumDryBulb
      summer_oat_wbs_f << OpenStudio.convert(summer_oat_wb_c, 'C', 'F').get
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlantLoop', "For #{dd.name}, humidity is specified as #{dd.humidityIndicatingType}; cannot determine Twb.")
    end
  end

  # Use the value from the design days or 78F, the CTI rating condition, if no design day information is available.
  design_oat_wb_f = nil
  if summer_oat_wbs_f.size.zero?
    design_oat_wb_f = 78
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, no design day OATwb conditions were found.  CTI rating condition of 78F OATwb will be used for sizing cooling towers.")
  else
    # Take worst case condition
    design_oat_wb_f = summer_oat_wbs_f.max
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "The maximum design wet bulb temperature from the Summer Design Day WB=>MDB is #{design_oat_wb_f} F")
  end

  # There is an EnergyPlus model limitation that the design_oat_wb_f < 80F for cooling towers
  ep_max_design_oat_wb_f = 80
  if design_oat_wb_f > ep_max_design_oat_wb_f
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, reduced design OATwb from #{design_oat_wb_f.round(1)} F to E+ model max input of #{ep_max_design_oat_wb_f} F.")
    design_oat_wb_f = ep_max_design_oat_wb_f
  end

  # Determine the design CW temperature, approach, and range
  design_oat_wb_c = OpenStudio.convert(design_oat_wb_f, 'F', 'C').get
  leaving_cw_t_c, approach_k, range_k = plant_loop_prm_baseline_condenser_water_temperatures(plant_loop, design_oat_wb_c)

  # Convert to IP units
  leaving_cw_t_f = OpenStudio.convert(leaving_cw_t_c, 'C', 'F').get
  approach_r = OpenStudio.convert(approach_k, 'K', 'R').get
  range_r = OpenStudio.convert(range_k, 'K', 'R').get

  # Report out design conditions
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, design OATwb = #{design_oat_wb_f.round(1)} F, approach = #{approach_r.round(1)} deltaF, range = #{range_r.round(1)} deltaF, leaving condenser water temperature = #{leaving_cw_t_f.round(1)} F.")

  # Set the CW sizing parameters
  sizing_plant.setDesignLoopExitTemperature(leaving_cw_t_c)
  sizing_plant.setLoopDesignTemperatureDifference(range_k)

  # Set Cooling Tower sizing parameters.
  # Only the variable speed cooling tower in E+ allows you to set the design temperatures.
  #
  # Per the documentation
  # http://bigladdersoftware.com/epx/docs/8-4/input-output-reference/group-condenser-equipment.html#field-design-u-factor-times-area-value
  # for CoolingTowerSingleSpeed and CoolingTowerTwoSpeed
  # E+ uses the following values during sizing:
  # 95F entering water temp
  # 95F OATdb
  # 78F OATwb
  # range = loop design delta-T aka range (specified above)
  plant_loop.supplyComponents.each do |sc|
    if sc.to_CoolingTowerVariableSpeed.is_initialized
      ct = sc.to_CoolingTowerVariableSpeed.get
      # E+ has a minimum limit of 68F (20C) for this field.
      # Check against limit before attempting to set value.
      eplus_design_oat_wb_c_lim = 20
      if design_oat_wb_c < eplus_design_oat_wb_c_lim
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, a design OATwb of 68F will be used for sizing the cooling towers because the actual design value is below the limit EnergyPlus accepts for this input.")
        design_oat_wb_c = eplus_design_oat_wb_c_lim
      end
      ct.setDesignInletAirWetBulbTemperature(design_oat_wb_c)
      ct.setDesignApproachTemperature(approach_k)
      ct.setDesignRangeTemperature(range_k)
    end
  end

  # Set the min and max CW temps
  # Typical design of min temp is really around 40F
  # (that's what basin heaters, when used, are sized for usually)
  min_temp_f = 34
  max_temp_f = 200
  min_temp_c = OpenStudio.convert(min_temp_f, 'F', 'C').get
  max_temp_c = OpenStudio.convert(max_temp_f, 'F', 'C').get
  plant_loop.setMinimumLoopTemperature(min_temp_c)
  plant_loop.setMaximumLoopTemperature(max_temp_c)

  # Cooling Tower operational controls
  # G3.1.3.11 - Tower shall be controlled to maintain a 70F LCnWT where weather permits,
  # floating up to leaving water at design conditions.
  float_down_to_f = 70
  float_down_to_c = OpenStudio.convert(float_down_to_f, 'F', 'C').get

  cw_t_stpt_manager = nil
  plant_loop.supplyOutletNode.setpointManagers.each do |spm|
    if spm.to_SetpointManagerFollowOutdoorAirTemperature.is_initialized
      if spm.name.get.include? 'Setpoint Manager Follow OATwb'
        cw_t_stpt_manager = spm.to_SetpointManagerFollowOutdoorAirTemperature.get
      end
    end
  end
  if cw_t_stpt_manager.nil?
    cw_t_stpt_manager = OpenStudio::Model::SetpointManagerFollowOutdoorAirTemperature.new(plant_loop.model)
    cw_t_stpt_manager.addToNode(plant_loop.supplyOutletNode)
  end
  cw_t_stpt_manager.setName("#{plant_loop.name} Setpoint Manager Follow OATwb with #{approach_r.round(1)}F Approach")
  cw_t_stpt_manager.setReferenceTemperatureType('OutdoorAirWetBulb')
  # At low design OATwb, it is possible to calculate
  # a maximum temperature below the minimum.  In this case,
  # make the maximum and minimum the same.
  if leaving_cw_t_c < float_down_to_c
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, the maximum leaving temperature of #{leaving_cw_t_f.round(1)} F is below the minimum of #{float_down_to_f.round(1)} F.  The maximum will be set to the same value as the minimum.")
    leaving_cw_t_c = float_down_to_c
  end
  cw_t_stpt_manager.setMaximumSetpointTemperature(leaving_cw_t_c)
  cw_t_stpt_manager.setMinimumSetpointTemperature(float_down_to_c)
  cw_t_stpt_manager.setOffsetTemperatureDifference(approach_k)
  return true
end

#plant_loop_apply_prm_baseline_hot_water_pumping_type(plant_loop) ⇒ Object

Applies the hot water pumping controls to the loop based on Appendix G.



765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 765

def plant_loop_apply_prm_baseline_hot_water_pumping_type(plant_loop)
  # Determine the minimum area to determine
  # pumping type.
  minimum_area_ft2 = 120_000

  # Determine the area served
  area_served_m2 = plant_loop_total_floor_area_served(plant_loop)
  area_served_ft2 = OpenStudio.convert(area_served_m2, 'm^2', 'ft^2').get

  # Determine the pump type
  control_type = 'Riding Curve'
  if area_served_ft2 > minimum_area_ft2
    control_type = 'VSD No Reset'
  end

  # Modify all the primary pumps
  plant_loop.supplyComponents.each do |sc|
    if sc.to_PumpVariableSpeed.is_initialized
      pump = sc.to_PumpVariableSpeed.get
      pump_variable_speed_set_control_type(pump, control_type)
    end
  end

  # Report out the pumping type
  unless control_type.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, pump type is #{control_type}.")
  end

  return true
end

#plant_loop_apply_prm_baseline_hot_water_temperatures(plant_loop) ⇒ Object

Applies the hot water temperatures to the plant loop based on Appendix G.



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 150

def plant_loop_apply_prm_baseline_hot_water_temperatures(plant_loop)
  sizing_plant = plant_loop.sizingPlant

  # Loop properties
  # G3.1.3.3 - HW Supply at 180F, return at 130F
  hw_temp_f = 180
  hw_delta_t_r = 50
  min_temp_f = 50

  hw_temp_c = OpenStudio.convert(hw_temp_f, 'F', 'C').get
  hw_delta_t_k = OpenStudio.convert(hw_delta_t_r, 'R', 'K').get
  min_temp_c = OpenStudio.convert(min_temp_f, 'F', 'C').get

  sizing_plant.setDesignLoopExitTemperature(hw_temp_c)
  sizing_plant.setLoopDesignTemperatureDifference(hw_delta_t_k)
  plant_loop.setMinimumLoopTemperature(min_temp_c)

  # ASHRAE Appendix G - G3.1.3.4 (for ASHRAE 90.1-2004, 2007 and 2010)
  # HW reset: 180F at 20F and below, 150F at 50F and above
  plant_loop_enable_supply_water_temperature_reset(plant_loop)

  # Boiler properties
  if plant_loop.model.version < OpenStudio::VersionString.new('3.0.0')
    plant_loop.supplyComponents.each do |sc|
      if sc.to_BoilerHotWater.is_initialized
        boiler = sc.to_BoilerHotWater.get
        boiler.setDesignWaterOutletTemperature(hw_temp_c)
      end
    end
  end
  return true
end

#plant_loop_apply_prm_baseline_pump_power(plant_loop) ⇒ Object

TODO: I think it makes more sense to sense the motor efficiency right there… But actually it’s completely irrelevant… you could set at 0.9 and just calculate the pressurise rise to have your 19 W/GPM or whatever



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 37

def plant_loop_apply_prm_baseline_pump_power(plant_loop)
  # Determine the pumping power per
  # flow based on loop type.
  pri_w_per_gpm = nil
  sec_w_per_gpm = nil

  sizing_plant = plant_loop.sizingPlant
  loop_type = sizing_plant.loopType

  case loop_type
    when 'Heating'

      has_district_heating = false
      plant_loop.supplyComponents.each do |sc|
        if sc.to_DistrictHeating.is_initialized
          has_district_heating = true
        end
      end

      pri_w_per_gpm = if has_district_heating # District HW
                        14.0
                      else # HW
                        19.0
                      end

    when 'Cooling'

      has_district_cooling = false
      plant_loop.supplyComponents.each do |sc|
        if sc.to_DistrictCooling.is_initialized
          has_district_cooling = true
        end
      end

      has_secondary_pump = false
      plant_loop.demandComponents.each do |sc|
        if sc.to_PumpConstantSpeed.is_initialized || sc.to_PumpVariableSpeed.is_initialized
          has_secondary_pump = true
        end
      end

      if has_district_cooling # District CHW
        pri_w_per_gpm = 16.0
      elsif has_secondary_pump # Primary/secondary CHW
        pri_w_per_gpm = 9.0
        sec_w_per_gpm = 13.0
      else # Primary only CHW
        pri_w_per_gpm = 22.0
      end

    when 'Condenser'

      # TODO: prm condenser loop pump power
      pri_w_per_gpm = 19.0

  end

  # Modify all the primary pumps
  plant_loop.supplyComponents.each do |sc|
    if sc.to_PumpConstantSpeed.is_initialized
      pump = sc.to_PumpConstantSpeed.get
      pump_apply_prm_pressure_rise_and_motor_efficiency(pump, pri_w_per_gpm)
    elsif sc.to_PumpVariableSpeed.is_initialized
      pump = sc.to_PumpVariableSpeed.get
      pump_apply_prm_pressure_rise_and_motor_efficiency(pump, pri_w_per_gpm)
    elsif sc.to_HeaderedPumpsConstantSpeed.is_initialized
      pump = sc.to_HeaderedPumpsConstantSpeed.get
      pump_apply_prm_pressure_rise_and_motor_efficiency(pump, pri_w_per_gpm)
    elsif sc.to_HeaderedPumpsVariableSpeed.is_initialized
      pump = sc.to_HeaderedPumpsVariableSpeed.get
      pump_apply_prm_pressure_rise_and_motor_efficiency(pump, pri_w_per_gpm)
    end
  end

  # Modify all the secondary pumps
  plant_loop.demandComponents.each do |sc|
    if sc.to_PumpConstantSpeed.is_initialized
      pump = sc.to_PumpConstantSpeed.get
      pump_apply_prm_pressure_rise_and_motor_efficiency(pump, sec_w_per_gpm)
    elsif sc.to_PumpVariableSpeed.is_initialized
      pump = sc.to_PumpVariableSpeed.get
      pump_apply_prm_pressure_rise_and_motor_efficiency(pump, sec_w_per_gpm)
    elsif sc.to_HeaderedPumpsConstantSpeed.is_initialized
      pump = sc.to_HeaderedPumpsConstantSpeed.get
      pump_apply_prm_pressure_rise_and_motor_efficiency(pump, pri_w_per_gpm)
    elsif sc.to_HeaderedPumpsVariableSpeed.is_initialized
      pump = sc.to_HeaderedPumpsVariableSpeed.get
      pump_apply_prm_pressure_rise_and_motor_efficiency(pump, pri_w_per_gpm)
    end
  end

  return true
end

#plant_loop_apply_prm_baseline_pumping_type(plant_loop) ⇒ Object

Applies the pumping controls to the loop based on Appendix G.



679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 679

def plant_loop_apply_prm_baseline_pumping_type(plant_loop)
  sizing_plant = plant_loop.sizingPlant
  loop_type = sizing_plant.loopType

  case loop_type
    when 'Heating'
      plant_loop_apply_prm_baseline_hot_water_pumping_type(plant_loop)
    when 'Cooling'
      plant_loop_apply_prm_baseline_chilled_water_pumping_type(plant_loop)
    when 'Condenser'
      plant_loop_apply_prm_baseline_condenser_water_pumping_type(plant_loop)
  end

  return true
end

#plant_loop_apply_prm_baseline_temperatures(plant_loop) ⇒ TrueClass

Applies the temperatures to the plant loop based on Appendix G.

Parameters:

  • plant_loop (Object)

Returns:



134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 134

def plant_loop_apply_prm_baseline_temperatures(plant_loop)
  sizing_plant = plant_loop.sizingPlant
  loop_type = sizing_plant.loopType
  case loop_type
    when 'Heating'
      plant_loop_apply_prm_baseline_hot_water_temperatures(plant_loop)
    when 'Cooling'
      plant_loop_apply_prm_baseline_chilled_water_temperatures(plant_loop)
    when 'Condenser'
      plant_loop_apply_prm_baseline_condenser_water_temperatures(plant_loop)
  end

  return true
end

#plant_loop_apply_prm_number_of_boilers(plant_loop) ⇒ Object

Splits the single boiler used for the initial sizing run into multiple separate boilers based on Appendix G.



822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 822

def plant_loop_apply_prm_number_of_boilers(plant_loop)
  # Skip non-heating plants
  return true unless plant_loop.sizingPlant.loopType == 'Heating'

  # Determine the minimum area to determine
  # number of boilers.
  minimum_area_ft2 = 15_000

  # Determine the area served
  area_served_m2 = plant_loop_total_floor_area_served(plant_loop)
  area_served_ft2 = OpenStudio.convert(area_served_m2, 'm^2', 'ft^2').get

  # Do nothing if only one boiler is required
  return true if area_served_ft2 < minimum_area_ft2

  # Get all existing boilers
  boilers = []
  plant_loop.supplyComponents.each do |sc|
    if sc.to_BoilerHotWater.is_initialized
      boilers << sc.to_BoilerHotWater.get
    end
  end

  # Ensure there is only 1 boiler to start
  first_boiler = nil
  if boilers.size.zero?
    return true
  elsif boilers.size > 1
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, found #{boilers.size}, cannot split up per performance rating method baseline requirements.")
  else
    first_boiler = boilers[0]
  end

  # Clone the existing boiler and create
  # a new branch for it
  second_boiler = first_boiler.clone(plant_loop.model)
  if second_boiler.to_BoilerHotWater.is_initialized
    second_boiler = second_boiler.to_BoilerHotWater.get
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, could not clone boiler #{first_boiler.name}, cannot apply the performance rating method number of boilers.")
    return false
  end
  plant_loop.addSupplyBranchForComponent(second_boiler)
  final_boilers = [first_boiler, second_boiler]
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, added a second boiler.")

  # Set the sizing factor for all boilers evenly and Rename the boilers
  sizing_factor = (1.0 / final_boilers.size).round(2)
  final_boilers.each_with_index do |boiler, i|
    boiler.setSizingFactor(sizing_factor)
    boiler.setName("#{first_boiler.name} #{i + 1} of #{final_boilers.size}")
  end

  # Set the equipment to stage sequentially
  plant_loop.setLoadDistributionScheme('SequentialLoad')

  return true
end

#plant_loop_apply_prm_number_of_chillers(plant_loop) ⇒ Object

Splits the single chiller used for the initial sizing run into multiple separate chillers based on Appendix G.



883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 883

def plant_loop_apply_prm_number_of_chillers(plant_loop)
  # Skip non-cooling plants
  return true unless plant_loop.sizingPlant.loopType == 'Cooling'

  # Determine the number and type of chillers
  num_chillers = nil
  chiller_cooling_type = nil
  chiller_compressor_type = nil

  # Determine the capacity of the loop
  cap_w = plant_loop_total_cooling_capacity(plant_loop)
  cap_tons = OpenStudio.convert(cap_w, 'W', 'ton').get
  if cap_tons <= 300
    num_chillers = 1
    chiller_cooling_type = 'WaterCooled'
    chiller_compressor_type = 'Rotary Screw'
  elsif cap_tons > 300 && cap_tons < 600
    num_chillers = 2
    chiller_cooling_type = 'WaterCooled'
    chiller_compressor_type = 'Rotary Screw'
  else
    # Max capacity of a single chiller
    max_cap_ton = 800.0
    num_chillers = (cap_tons / max_cap_ton).floor + 1
    # Must be at least 2 chillers
    num_chillers += 1 if num_chillers == 1
    chiller_cooling_type = 'WaterCooled'
    chiller_compressor_type = 'Centrifugal'
  end

  # Get all existing chillers and pumps
  chillers = []
  pumps = []
  plant_loop.supplyComponents.each do |sc|
    if sc.to_ChillerElectricEIR.is_initialized
      chillers << sc.to_ChillerElectricEIR.get
    elsif sc.to_PumpConstantSpeed.is_initialized
      pumps << sc.to_PumpConstantSpeed.get
    elsif sc.to_PumpVariableSpeed.is_initialized
      pumps << sc.to_PumpVariableSpeed.get
    end
  end

  # Ensure there is only 1 chiller to start
  first_chiller = nil
  if chillers.size.zero?
    return true
  elsif chillers.size > 1
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, found #{chillers.size} chillers, cannot split up per performance rating method baseline requirements.")
  else
    first_chiller = chillers[0]
  end

  # Ensure there is only 1 pump to start
  orig_pump = nil
  if pumps.size.zero?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, found #{pumps.size} pumps.  A loop must have at least one pump.")
    return false
  elsif pumps.size > 1
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, found #{pumps.size} pumps, cannot split up per performance rating method baseline requirements.")
    return false
  else
    orig_pump = pumps[0]
  end

  # Determine the per-chiller capacity
  # and sizing factor
  per_chiller_sizing_factor = (1.0 / num_chillers).round(2)
  # This is unused
  per_chiller_cap_tons = cap_tons / num_chillers

  # Set the sizing factor and the chiller type: could do it on the first chiller before cloning it, but renaming warrants looping on chillers anyways

  # Add any new chillers
  final_chillers = [first_chiller]
  (num_chillers - 1).times do
    new_chiller = first_chiller.clone(plant_loop.model)
    if new_chiller.to_ChillerElectricEIR.is_initialized
      new_chiller = new_chiller.to_ChillerElectricEIR.get
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, could not clone chiller #{first_chiller.name}, cannot apply the performance rating method number of chillers.")
      return false
    end
    # Connect the new chiller to the same CHW loop
    # as the old chiller.
    plant_loop.addSupplyBranchForComponent(new_chiller)
    # Connect the new chiller to the same CW loop
    # as the old chiller, if it was water-cooled.
    cw_loop = first_chiller.secondaryPlantLoop
    if cw_loop.is_initialized
      cw_loop.get.addDemandBranchForComponent(new_chiller)
    end

    final_chillers << new_chiller
  end

  # If there is more than one cooling tower,
  # replace the original pump with a headered pump
  # of the same type and properties.
  if final_chillers.size > 1
    num_pumps = final_chillers.size
    new_pump = nil
    if orig_pump.to_PumpConstantSpeed.is_initialized
      new_pump = OpenStudio::Model::HeaderedPumpsConstantSpeed.new(plant_loop.model)
      new_pump.setNumberofPumpsinBank(num_pumps)
      new_pump.setName("#{orig_pump.name} Bank of #{num_pumps}")
      new_pump.setRatedPumpHead(orig_pump.ratedPumpHead)
      new_pump.setMotorEfficiency(orig_pump.motorEfficiency)
      new_pump.setFractionofMotorInefficienciestoFluidStream(orig_pump.fractionofMotorInefficienciestoFluidStream)
      new_pump.setPumpControlType(orig_pump.pumpControlType)
    elsif orig_pump.to_PumpVariableSpeed.is_initialized
      new_pump = OpenStudio::Model::HeaderedPumpsVariableSpeed.new(plant_loop.model)
      new_pump.setNumberofPumpsinBank(num_pumps)
      new_pump.setName("#{orig_pump.name} Bank of #{num_pumps}")
      new_pump.setRatedPumpHead(orig_pump.ratedPumpHead)
      new_pump.setMotorEfficiency(orig_pump.motorEfficiency)
      new_pump.setFractionofMotorInefficienciestoFluidStream(orig_pump.fractionofMotorInefficienciestoFluidStream)
      new_pump.setPumpControlType(orig_pump.pumpControlType)
      new_pump.setCoefficient1ofthePartLoadPerformanceCurve(orig_pump.coefficient1ofthePartLoadPerformanceCurve)
      new_pump.setCoefficient2ofthePartLoadPerformanceCurve(orig_pump.coefficient2ofthePartLoadPerformanceCurve)
      new_pump.setCoefficient3ofthePartLoadPerformanceCurve(orig_pump.coefficient3ofthePartLoadPerformanceCurve)
      new_pump.setCoefficient4ofthePartLoadPerformanceCurve(orig_pump.coefficient4ofthePartLoadPerformanceCurve)
    end
    # Remove the old pump
    orig_pump.remove
    # Attach the new headered pumps
    new_pump.addToNode(plant_loop.supplyInletNode)
  end

  # Set the sizing factor and the chiller types
  final_chillers.each_with_index do |final_chiller, i|
    final_chiller.setName("#{template} #{chiller_cooling_type} #{chiller_compressor_type} Chiller #{i + 1} of #{final_chillers.size}")
    final_chiller.setSizingFactor(per_chiller_sizing_factor)
    final_chiller.setCondenserType(chiller_cooling_type)
  end
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, there are #{final_chillers.size} #{chiller_cooling_type} #{chiller_compressor_type} chillers.")

  # Set the equipment to stage sequentially
  plant_loop.setLoadDistributionScheme('SequentialLoad')

  return true
end

#plant_loop_apply_prm_number_of_cooling_towers(plant_loop) ⇒ Object

Splits the single cooling tower used for the initial sizing run into multiple separate cooling towers based on Appendix G.



1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 1028

def plant_loop_apply_prm_number_of_cooling_towers(plant_loop)
  # Skip non-cooling plants
  return true unless plant_loop.sizingPlant.loopType == 'Condenser'

  # Determine the number of chillers
  # already in the model
  num_chillers = plant_loop.model.getChillerElectricEIRs.size

  # Get all existing cooling towers and pumps
  clg_twrs = []
  pumps = []
  plant_loop.supplyComponents.each do |sc|
    if sc.to_CoolingTowerSingleSpeed.is_initialized
      clg_twrs << sc.to_CoolingTowerSingleSpeed.get
    elsif sc.to_CoolingTowerTwoSpeed.is_initialized
      clg_twrs << sc.to_CoolingTowerTwoSpeed.get
    elsif sc.to_CoolingTowerVariableSpeed.is_initialized
      clg_twrs << sc.to_CoolingTowerVariableSpeed.get
    elsif sc.to_PumpConstantSpeed.is_initialized
      pumps << sc.to_PumpConstantSpeed.get
    elsif sc.to_PumpVariableSpeed.is_initialized
      pumps << sc.to_PumpVariableSpeed.get
    end
  end

  # Ensure there is only 1 cooling tower to start
  orig_twr = nil
  if clg_twrs.size.zero?
    return true
  elsif clg_twrs.size > 1
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, found #{clg_twrs.size} cooling towers, cannot split up per performance rating method baseline requirements.")
    return false
  else
    orig_twr = clg_twrs[0]
  end

  # Ensure there is only 1 pump to start
  orig_pump = nil
  if pumps.size.zero?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, found #{pumps.size} pumps.  A loop must have at least one pump.")
    return false
  elsif pumps.size > 1
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, found #{pumps.size} pumps, cannot split up per performance rating method baseline requirements.")
    return false
  else
    orig_pump = pumps[0]
  end

  # Determine the per-cooling_tower sizing factor
  clg_twr_sizing_factor = (1.0 / num_chillers).round(2)

  # Add a cooling tower for each chiller.
  # Add an accompanying CW pump for each cooling tower.
  final_twrs = [orig_twr]
  new_twr = nil
  (num_chillers - 1).times do
    if orig_twr.to_CoolingTowerSingleSpeed.is_initialized
      new_twr = orig_twr.clone(plant_loop.model)
      new_twr = new_twr.to_CoolingTowerSingleSpeed.get
    elsif orig_twr.to_CoolingTowerTwoSpeed.is_initialized
      new_twr = orig_twr.clone(plant_loop.model)
      new_twr = new_twr.to_CoolingTowerTwoSpeed.get
    elsif orig_twr.to_CoolingTowerVariableSpeed.is_initialized
      # TODO: remove workaround after resolving
      # https://github.com/NREL/OpenStudio/issues/2212
      # Workaround is to create a new tower
      # and replicate all the properties of the first tower.
      new_twr = OpenStudio::Model::CoolingTowerVariableSpeed.new(plant_loop.model)
      new_twr.setName(orig_twr.name.get.to_s)
      new_twr.setDesignInletAirWetBulbTemperature(orig_twr.designInletAirWetBulbTemperature.get)
      new_twr.setDesignApproachTemperature(orig_twr.designApproachTemperature.get)
      new_twr.setDesignRangeTemperature(orig_twr.designRangeTemperature.get)
      new_twr.setFractionofTowerCapacityinFreeConvectionRegime(orig_twr.fractionofTowerCapacityinFreeConvectionRegime.get)
      if orig_twr.fanPowerRatioFunctionofAirFlowRateRatioCurve.is_initialized
        new_twr.setFanPowerRatioFunctionofAirFlowRateRatioCurve(orig_twr.fanPowerRatioFunctionofAirFlowRateRatioCurve.get)
      end
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, could not clone cooling tower #{orig_twr.name}, cannot apply the performance rating method number of cooling towers.")
      return false
    end

    # Connect the new cooling tower to the CW loop
    plant_loop.addSupplyBranchForComponent(new_twr)
    new_twr_inlet = new_twr.inletModelObject.get.to_Node.get

    final_twrs << new_twr
  end

  # If there is more than one cooling tower,
  # replace the original pump with a headered pump
  # of the same type and properties.
  if final_twrs.size > 1
    num_pumps = final_twrs.size
    new_pump = nil
    if orig_pump.to_PumpConstantSpeed.is_initialized
      new_pump = OpenStudio::Model::HeaderedPumpsConstantSpeed.new(plant_loop.model)
      new_pump.setNumberofPumpsinBank(num_pumps)
      new_pump.setName("#{orig_pump.name} Bank of #{num_pumps}")
      new_pump.setRatedPumpHead(orig_pump.ratedPumpHead)
      new_pump.setMotorEfficiency(orig_pump.motorEfficiency)
      new_pump.setFractionofMotorInefficienciestoFluidStream(orig_pump.fractionofMotorInefficienciestoFluidStream)
      new_pump.setPumpControlType(orig_pump.pumpControlType)
    elsif orig_pump.to_PumpVariableSpeed.is_initialized
      new_pump = OpenStudio::Model::HeaderedPumpsVariableSpeed.new(plant_loop.model)
      new_pump.setNumberofPumpsinBank(num_pumps)
      new_pump.setName("#{orig_pump.name} Bank of #{num_pumps}")
      new_pump.setRatedPumpHead(orig_pump.ratedPumpHead)
      new_pump.setMotorEfficiency(orig_pump.motorEfficiency)
      new_pump.setFractionofMotorInefficienciestoFluidStream(orig_pump.fractionofMotorInefficienciestoFluidStream)
      new_pump.setPumpControlType(orig_pump.pumpControlType)
      new_pump.setCoefficient1ofthePartLoadPerformanceCurve(orig_pump.coefficient1ofthePartLoadPerformanceCurve)
      new_pump.setCoefficient2ofthePartLoadPerformanceCurve(orig_pump.coefficient2ofthePartLoadPerformanceCurve)
      new_pump.setCoefficient3ofthePartLoadPerformanceCurve(orig_pump.coefficient3ofthePartLoadPerformanceCurve)
      new_pump.setCoefficient4ofthePartLoadPerformanceCurve(orig_pump.coefficient4ofthePartLoadPerformanceCurve)
    end
    # Remove the old pump
    orig_pump.remove
    # Attach the new headered pumps
    new_pump.addToNode(plant_loop.supplyInletNode)
  end

  # Set the sizing factors
  final_twrs.each_with_index do |final_cooling_tower, i|
    final_cooling_tower.setName("#{final_cooling_tower.name} #{i + 1} of #{final_twrs.size}")
    final_cooling_tower.setSizingFactor(clg_twr_sizing_factor)
  end
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, there are #{final_twrs.size} cooling towers, one for each chiller.")

  # Set the equipment to stage sequentially
  plant_loop.setLoadDistributionScheme('SequentialLoad')
end

#plant_loop_apply_standard_controls(plant_loop, climate_zone) ⇒ Bool

Apply all standard required controls to the plantloop

Returns:

  • (Bool)

    returns true if successful, false if not



8
9
10
11
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 8

def plant_loop_apply_standard_controls(plant_loop, climate_zone)
  # Supply water temperature reset
  # plant_loop_enable_supply_water_temperature_reset(plant_loop) if plant_loop_supply_water_temperature_reset_required?(plant_loop)
end

#plant_loop_capacity_W_by_maxflow_and_deltaT_forwater(plant_loop) ⇒ Object

This method calculates the capacity of a plant loop by multiplying the temp difference across the loop, the maximum flow rate, the fluid density, and the fluid heat capacity (currently only works with water). This may be a little more approximate than the heating and cooling capacity methods described above however is not limited to certain types of equipment and can be used for condensing plant loops too.



1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 1374

def plant_loop_capacity_W_by_maxflow_and_deltaT_forwater(plant_loop)
  plantloop_maxflowrate = nil
  if plant_loop.fluidType != 'Water'
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.PlantLoop', "The fluid used in the plant loop named #{plant_loop.name} is not water.  The current version of this method only calculates the capacity of plant loops that use water.")
  end
  plantloop_maxflowrate = plant_loop_find_maximum_loop_flow_rate(plant_loop)
  plantloop_dt = plant_loop.sizingPlant.loopDesignTemperatureDifference.to_f
  # Plant loop capacity = temperature difference across plant loop * maximum plant loop flow rate * density of water (1000 kg/m^3) * see next line
  # Heat capacity of water (4180 J/(kg*K))
  plantloop_capacity = plantloop_dt * plantloop_maxflowrate * 1000.0 * 4180.0
  return plantloop_capacity
end

#plant_loop_enable_supply_water_temperature_reset(plant_loop) ⇒ TrueClass

Enable reset of hot or chilled water temperature based on outdoor air temperature.

Parameters:

  • plant_loop (Object)

Returns:



425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 425

def plant_loop_enable_supply_water_temperature_reset(plant_loop)
  # Get the current setpoint manager on the outlet node
  # and determine if already has temperature reset
  spms = plant_loop.supplyOutletNode.setpointManagers
  spms.each do |spm|
    if spm.to_SetpointManagerOutdoorAirReset.is_initialized
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}: supply water temperature reset is already enabled.")
      return false
    end
  end

  # Get the design water temperature
  sizing_plant = plant_loop.sizingPlant
  design_temp_c = sizing_plant.designLoopExitTemperature
  design_temp_f = OpenStudio.convert(design_temp_c, 'C', 'F').get
  loop_type = sizing_plant.loopType

  # Apply the reset, depending on the type of loop.
  case loop_type
    when 'Heating'

      # Hot water as-designed when cold outside
      hwt_at_lo_oat_f = design_temp_f
      hwt_at_lo_oat_c = OpenStudio.convert(hwt_at_lo_oat_f, 'F', 'C').get
      # 30F decrease when it's hot outside,
      # and therefore less heating capacity is likely required.
      decrease_f = 30.0
      hwt_at_hi_oat_f = hwt_at_lo_oat_f - decrease_f
      hwt_at_hi_oat_c = OpenStudio.convert(hwt_at_hi_oat_f, 'F', 'C').get

      # Define the high and low outdoor air temperatures
      lo_oat_f = 20
      lo_oat_c = OpenStudio.convert(lo_oat_f, 'F', 'C').get
      hi_oat_f = 50
      hi_oat_c = OpenStudio.convert(hi_oat_f, 'F', 'C').get

      # Create a setpoint manager
      hwt_oa_reset = OpenStudio::Model::SetpointManagerOutdoorAirReset.new(plant_loop.model)
      hwt_oa_reset.setName("#{plant_loop.name} HW Temp Reset")
      hwt_oa_reset.setControlVariable('Temperature')
      hwt_oa_reset.setSetpointatOutdoorLowTemperature(hwt_at_lo_oat_c)
      hwt_oa_reset.setOutdoorLowTemperature(lo_oat_c)
      hwt_oa_reset.setSetpointatOutdoorHighTemperature(hwt_at_hi_oat_c)
      hwt_oa_reset.setOutdoorHighTemperature(hi_oat_c)
      hwt_oa_reset.addToNode(plant_loop.supplyOutletNode)

      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}: hot water temperature reset from #{hwt_at_lo_oat_f.round}F to #{hwt_at_hi_oat_f.round}F between outdoor air temps of #{lo_oat_f.round}F and #{hi_oat_f.round}F.")

    when 'Cooling'

      # Chilled water as-designed when hot outside
      chwt_at_hi_oat_f = design_temp_f
      chwt_at_hi_oat_c = OpenStudio.convert(chwt_at_hi_oat_f, 'F', 'C').get
      # 10F increase when it's cold outside,
      # and therefore less cooling capacity is likely required.
      increase_f = 10.0
      chwt_at_lo_oat_f = chwt_at_hi_oat_f + increase_f
      chwt_at_lo_oat_c = OpenStudio.convert(chwt_at_lo_oat_f, 'F', 'C').get

      # Define the high and low outdoor air temperatures
      lo_oat_f = 60
      lo_oat_c = OpenStudio.convert(lo_oat_f, 'F', 'C').get
      hi_oat_f = 80
      hi_oat_c = OpenStudio.convert(hi_oat_f, 'F', 'C').get

      # Create a setpoint manager
      chwt_oa_reset = OpenStudio::Model::SetpointManagerOutdoorAirReset.new(plant_loop.model)
      chwt_oa_reset.setName("#{plant_loop.name} CHW Temp Reset")
      chwt_oa_reset.setControlVariable('Temperature')
      chwt_oa_reset.setSetpointatOutdoorLowTemperature(chwt_at_lo_oat_c)
      chwt_oa_reset.setOutdoorLowTemperature(lo_oat_c)
      chwt_oa_reset.setSetpointatOutdoorHighTemperature(chwt_at_hi_oat_c)
      chwt_oa_reset.setOutdoorHighTemperature(hi_oat_c)
      chwt_oa_reset.addToNode(plant_loop.supplyOutletNode)

      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}: chilled water temperature reset from #{chwt_at_hi_oat_f.round}F to #{chwt_at_lo_oat_f.round}F between outdoor air temps of #{hi_oat_f.round}F and #{lo_oat_f.round}F.")

    else

      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}: cannot enable supply water temperature reset for a #{loop_type} loop.")
      return false

  end

  return true
end

#plant_loop_find_maximum_loop_flow_rate(plant_loop) ⇒ Double

find maximum_loop_flow_rate

Returns:

  • (Double)

    maximum_loop_flow_rate m^3/s



1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 1213

def plant_loop_find_maximum_loop_flow_rate(plant_loop)
  # Get the maximum_loop_flow_rate
  maximum_loop_flow_rate = nil
  if plant_loop.maximumLoopFlowRate.is_initialized
    maximum_loop_flow_rate = plant_loop.maximumLoopFlowRate.get
  elsif plant_loop.autosizedMaximumLoopFlowRate.is_initialized
    maximum_loop_flow_rate = plant_loop.autosizedMaximumLoopFlowRate.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlantLoop', "For #{plant_loop.name} maximum loop flow rate is not available.")
  end

  return maximum_loop_flow_rate
end

#plant_loop_prm_baseline_condenser_water_temperatures(plant_loop, design_oat_wb_c) ⇒ Array<Double>

Determine the performance rating method specified design condenser water temperature, approach, and range

Parameters:

Returns:

  • (Array<Double>)
    leaving_cw_t_c, approach_k, range_k


357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 357

def plant_loop_prm_baseline_condenser_water_temperatures(plant_loop, design_oat_wb_c)
  design_oat_wb_f = OpenStudio.convert(design_oat_wb_c, 'C', 'F').get

  # G3.1.3.11 - CW supply temp = 85F or 10F approaching design wet bulb temperature,
  # whichever is lower.  Design range = 10F
  # Design Temperature rise of 10F => Range: 10F
  range_r = 10

  # Determine the leaving CW temp
  max_leaving_cw_t_f = 85
  leaving_cw_t_10f_approach_f = design_oat_wb_f + 10
  leaving_cw_t_f = [max_leaving_cw_t_f, leaving_cw_t_10f_approach_f].min

  # Calculate the approach
  approach_r = leaving_cw_t_f - design_oat_wb_f

  # Convert to SI units
  leaving_cw_t_c = OpenStudio.convert(leaving_cw_t_f, 'F', 'C').get
  approach_k = OpenStudio.convert(approach_r, 'R', 'K').get
  range_k = OpenStudio.convert(range_r, 'R', 'K').get

  return [leaving_cw_t_c, approach_k, range_k]
end

#plant_loop_supply_water_temperature_reset_required?(plant_loop) ⇒ Boolean

Determine if temperature reset is required. Required if heating or cooling capacity is greater than 300,000 Btu/hr.

Returns:

  • (Boolean)


384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 384

def plant_loop_supply_water_temperature_reset_required?(plant_loop)
  reset_required = false

  # Not required for service water heating systems
  if plant_loop_swh_loop?(plant_loop)
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}: supply water temperature reset not required for service water heating systems.")
    return reset_required
  end

  # Not required for variable flow systems
  if plant_loop_variable_flow_system?(plant_loop)
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}: supply water temperature reset not required for variable flow systems per 6.5.4.3 Exception b.")
    return reset_required
  end

  # Determine the capacity of the system
  heating_capacity_w = plant_loop_total_heating_capacity(plant_loop)
  cooling_capacity_w = plant_loop_total_cooling_capacity(plant_loop)

  heating_capacity_btu_per_hr = OpenStudio.convert(heating_capacity_w, 'W', 'Btu/hr').get
  cooling_capacity_btu_per_hr = OpenStudio.convert(cooling_capacity_w, 'W', 'Btu/hr').get

  # Compare against capacity minimum requirement
  min_cap_btu_per_hr = 300_000
  if heating_capacity_btu_per_hr > min_cap_btu_per_hr
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}: supply water temperature reset is required because heating capacity of #{heating_capacity_btu_per_hr.round} Btu/hr exceeds the minimum threshold of #{min_cap_btu_per_hr.round} Btu/hr.")
    reset_required = true
  elsif cooling_capacity_btu_per_hr > min_cap_btu_per_hr
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}: supply water temperature reset is required because cooling capacity of #{cooling_capacity_btu_per_hr.round} Btu/hr exceeds the minimum threshold of #{min_cap_btu_per_hr.round} Btu/hr.")
    reset_required = true
  else
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}: supply water temperature reset is not required because capacity is less than minimum of #{min_cap_btu_per_hr.round} Btu/hr.")
  end

  return reset_required
end

#plant_loop_swh_loop?(plant_loop) ⇒ Boolean

Determines if the loop is a Service Water Heating loop by checking if there is a WaterUseConnection on the demand side or a WaterHeaterMixed on the supply side

Returns:

  • (Boolean)

    true if it’s indeed a SHW loop, false otherwise



1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 1231

def plant_loop_swh_loop?(plant_loop)
  serves_swh = false
  plant_loop.demandComponents.each do |comp|
    if comp.to_WaterUseConnections.is_initialized
      serves_swh = true
      break
    end
  end
  plant_loop.supplyComponents.each do |comp|
    if comp.to_WaterHeaterMixed.is_initialized
      serves_swh = true
      break
    end
  end

  # If there is a waterheater on the demand side,
  # check if the loop connected to that waterheater's
  # demand side is an swh loop itself
  plant_loop.demandComponents.each do |comp|
    if comp.to_WaterHeaterMixed.is_initialized
      comp = comp.to_WaterHeaterMixed.get
      if comp.plantLoop.is_initialized
        if plant_loop_swh_loop?(comp.plantLoop.get)
          serves_swh = true
          break
        end
      end
    end
  end

  return serves_swh
end

#plant_loop_swh_system_type(plant_loop) ⇒ Array<Array<String>, Bool, Double, Double>

Classifies the service water system and returns information about fuel types, whether it serves both heating and service water heating, the water storage volume, and the total heating capacity.

fuel types, combination_system (true/false), storage_capacity (m^3), plant_loop_total_heating_capacity(plant_loop) (W)

Returns:

  • (Array<Array<String>, Bool, Double, Double>)

    An array of:



1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 1270

def plant_loop_swh_system_type(plant_loop)
  combination_system = true
  storage_capacity = 0
  primary_fuels = []
  secondary_fuels = []

  # @Todo: to work correctly, plant_loop_total_heating_capacity(plantloop)  requires to have either hardsized capacities or a sizing run.
  primary_heating_capacity = plant_loop_total_heating_capacity(plant_loop)
  secondary_heating_capacity = 0

  plant_loop.supplyComponents.each do |component|
    # Get the object type
    obj_type = component.iddObjectType.valueName.to_s

    case obj_type
      when 'OS_DistrictHeating'
        primary_fuels << 'DistrictHeating'
        combination_system = false
      when 'OS_HeatPump_WaterToWater_EquationFit_Heating'
        primary_fuels << 'Electricity'
      when 'OS_SolarCollector_FlatPlate_PhotovoltaicThermal'
        primary_fuels << 'SolarEnergy'
      when 'OS_SolarCollector_FlatPlate_Water'
        primary_fuels << 'SolarEnergy'
      when 'OS_SolarCollector_IntegralCollectorStorage'
        primary_fuels << 'SolarEnergy'
      when 'OS_WaterHeater_HeatPump'
        primary_fuels << 'Electricity'
      when 'OS_WaterHeater_Mixed'
        component = component.to_WaterHeaterMixed.get
        # Check it it's actually a heater, not just a storage tank
        if component.heaterMaximumCapacity.empty? || component.heaterMaximumCapacity.get != 0
          # If it does, we add the heater Fuel Type
          primary_fuels << component.heaterFuelType
          # And in this case we'll reuse this object
          combination_system = false
        end
        # @TODO: not sure about whether it should be an elsif or not
        # Check the plant loop connection on the source side
        if component.secondaryPlantLoop.is_initialized
          source_plant_loop = component.secondaryPlantLoop.get
          secondary_fuels += plant_loop.model.plant_loop_heating_fuels(source_plant_loop)
          secondary_heating_capacity += plant_loop_total_heating_capacity(source_plant_loop)
        end

        # Storage capacity
        if component.tankVolume.is_initialized
          storage_capacity = component.tankVolume.get
        end

      when 'OS_WaterHeater_Stratified'
        component = component.to_WaterHeaterStratified.get

        # Check if the heater actually has a capacity (otherwise it's simply a Storage Tank)
        if component.heaterMaximumCapacity.empty? || component.heaterMaximumCapacity.get != 0
          # If it does, we add the heater Fuel Type
          primary_fuels << component.heaterFuelType
          # And in this case we'll reuse this object
          combination_system = false
        end
        # @TODO: not sure about whether it should be an elsif or not
        # Check the plant loop connection on the source side
        if component.secondaryPlantLoop.is_initialized
          source_plant_loop = component.secondaryPlantLoop.get
          secondary_fuels += plant_loop.model.plant_loop_heating_fuels(source_plant_loop)
          secondary_heating_capacity += plant_loop_total_heating_capacity(source_plant_loop)
        end

        # Storage capacity
        if component.tankVolume.is_initialized
          storage_capacity = component.tankVolume.get
        end

      when 'OS_HeatExchanger_FluidToFluid'
        hx = component.to_HeatExchangerFluidToFluid.get
        cooling_hx_control_types = ['CoolingSetpointModulated', 'CoolingSetpointOnOff', 'CoolingDifferentialOnOff', 'CoolingSetpointOnOffWithComponentOverride']
        cooling_hx_control_types.each(&:downcase!)
        if !cooling_hx_control_types.include?(hx.controlType.downcase) && hx.secondaryPlantLoop.is_initialized
          source_plant_loop = hx.secondaryPlantLoop.get
          secondary_fuels += plant_loop.model.plant_loop_heating_fuels(source_plant_loop)
          secondary_heating_capacity += plant_loop_total_heating_capacity(source_plant_loop)
        end

      when 'OS_Node', 'OS_Pump_ConstantSpeed', 'OS_Pump_VariableSpeed', 'OS_Connector_Splitter', 'OS_Connector_Mixer', 'OS_Pipe_Adiabatic'
      # To avoid extraneous debug messages
    end
  end

  # @Todo: decide how to handle primary and secondary stuff
  fuels = primary_fuels + secondary_fuels
  total_heating_capacity = primary_heating_capacity + secondary_heating_capacity
  # If the primary heating capacity is bigger than secondary, assume the secondary is just a backup and disregard it?
  # if primary_heating_capacity > secondary_heating_capacity
  #   plant_loop_total_heating_capacity(plant_loop)  = primary_heating_capacity
  #   fuels = primary_fuels
  # end

  return fuels.uniq.sort, combination_system, storage_capacity, total_heating_capacity
end

#plant_loop_total_cooling_capacity(plant_loop) ⇒ Double, Fixnum

Get the total cooling capacity for the plant loop

Parameters:

  • plant_loop (Object)

Returns:

  • (Double)

    total cooling capacity units = Watts (W)

  • (Fixnum)


518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 518

def plant_loop_total_cooling_capacity(plant_loop)
  # Sum the cooling capacity for all cooling components
  # on the plant loop.
  total_cooling_capacity_w = 0
  plant_loop.supplyComponents.each do |sc|
    # ChillerElectricEIR
    if sc.to_ChillerElectricEIR.is_initialized
      chiller = sc.to_ChillerElectricEIR.get
      if chiller.referenceCapacity.is_initialized
        total_cooling_capacity_w += chiller.referenceCapacity.get
      elsif chiller.autosizedReferenceCapacity.is_initialized
        total_cooling_capacity_w += chiller.autosizedReferenceCapacity.get
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlantLoop', "For #{plant_loop.name} capacity of #{chiller.name} is not available, total cooling capacity of plant loop will be incorrect when applying standard.")
      end
      # DistrictCooling
    elsif sc.to_DistrictCooling.is_initialized
      dist_clg = sc.to_DistrictCooling.get
      if dist_clg.nominalCapacity.is_initialized
        total_cooling_capacity_w += dist_clg.nominalCapacity.get
      elsif dist_clg.autosizedNominalCapacity.is_initialized
        total_cooling_capacity_w += dist_clg.autosizedNominalCapacity.get
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlantLoop', "For #{plant_loop.name} capacity of DistrictCooling #{dist_clg.name} is not available, total heating capacity of plant loop will be incorrect when applying standard.")
      end
    end
  end

  total_cooling_capacity_tons = OpenStudio.convert(total_cooling_capacity_w, 'W', 'ton').get
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, cooling capacity is #{total_cooling_capacity_tons.round} tons of refrigeration.")

  return total_cooling_capacity_w
end

#plant_loop_total_floor_area_served(plant_loop) ⇒ Object

Determine the total floor area served by this loop. If the loop serves a coil attached to an AirLoopHVAC, count the area of all zones served by that loop. If the loop serves coils inside of zone equipment, count the area of the zones containing the zone equipment.



617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 617

def plant_loop_total_floor_area_served(plant_loop)
  sizing_plant = plant_loop.sizingPlant
  loop_type = sizing_plant.loopType

  # Get all the coils served by this loop
  coils = []
  case loop_type
    when 'Heating'
      plant_loop.demandComponents.each do |dc|
        if dc.to_CoilHeatingWater.is_initialized
          coils << dc.to_CoilHeatingWater.get
        end
      end
    when 'Cooling'
      plant_loop.demandComponents.each do |dc|
        if dc.to_CoilCoolingWater.is_initialized
          coils << dc.to_CoilCoolingWater.get
        end
      end
    else
      return 0.0
  end

  # The coil can either be on an airloop (as a main heating coil)
  # in an HVAC Component (like a unitary system on an airloop),
  # or in a Zone HVAC Component (like a fan coil).
  zones_served = []
  coils.each do |coil|
    if coil.airLoopHVAC.is_initialized
      air_loop = coil.airLoopHVAC.get
      zones_served += air_loop.thermalZones
    elsif coil.containingHVACComponent.is_initialized
      containing_comp = coil.containingHVACComponent.get
      if containing_comp.airLoopHVAC.is_initialized
        air_loop = containing_comp.airLoopHVAC.get
        zones_served += air_loop.thermalZones
      end
    elsif coil.containingZoneHVACComponent.is_initialized
      zone_hvac = coil.containingZoneHVACComponent.get
      if zone_hvac.thermalZone.is_initialized
        zones_served << zone_hvac.thermalZone.get
      end
    end
  end

  # Add up the area of all zones served.
  # Make sure to only add unique zones in
  # case the same zone is served by multiple
  # coils served by the same loop.  For example,
  # a HW and Reheat
  area_served_m2 = 0.0
  zones_served.uniq.each do |zone|
    area_served_m2 += zone.floorArea
  end
  area_served_ft2 = OpenStudio.convert(area_served_m2, 'm^2', 'ft^2').get

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, serves #{area_served_ft2.round} ft^2.")

  return area_served_m2
end

#plant_loop_total_heating_capacity(plant_loop) ⇒ Double, Object

TODO:

Add district heating to plant loop heating capacity

Get the total heating capacity for the plant loop

Parameters:

  • plant_loop (Object)

Returns:

  • (Double)

    total heating capacity units = Watts (W)

  • (Object)


559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 559

def plant_loop_total_heating_capacity(plant_loop)
  # Sum the heating capacity for all heating components
  # on the plant loop.
  total_heating_capacity_w = 0
  plant_loop.supplyComponents.each do |sc|
    # BoilerHotWater
    if sc.to_BoilerHotWater.is_initialized
      boiler = sc.to_BoilerHotWater.get
      if boiler.nominalCapacity.is_initialized
        total_heating_capacity_w += boiler.nominalCapacity.get
      elsif boiler.autosizedNominalCapacity.is_initialized
        total_heating_capacity_w += boiler.autosizedNominalCapacity.get
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlantLoop', "For #{plant_loop.name} capacity of Boiler:HotWater ' #{boiler.name} is not available, total heating capacity of plant loop will be incorrect when applying standard.")
      end
      # WaterHeater:Mixed
    elsif sc.to_WaterHeaterMixed.is_initialized
      water_heater = sc.to_WaterHeaterMixed.get
      if water_heater.heaterMaximumCapacity.is_initialized
        total_heating_capacity_w += water_heater.heaterMaximumCapacity.get
      elsif water_heater.autosizedHeaterMaximumCapacity.is_initialized
        total_heating_capacity_w += water_heater.autosizedHeaterMaximumCapacity.get
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlantLoop', "For #{plant_loop.name} capacity of WaterHeater:Mixed #{water_heater.name} is not available, total heating capacity of plant loop will be incorrect when applying standard.")
      end
      # WaterHeater:Stratified
    elsif sc.to_WaterHeaterStratified.is_initialized
      water_heater = sc.to_WaterHeaterStratified.get
      if water_heater.heater1Capacity.is_initialized
        total_heating_capacity_w += water_heater.heater1Capacity.get
      end
      if water_heater.heater2Capacity.is_initialized
        total_heating_capacity_w += water_heater.heater2Capacity.get
      end
      # DistrictHeating
    elsif sc.to_DistrictHeating.is_initialized
      dist_htg = sc.to_DistrictHeating.get
      if dist_htg.nominalCapacity.is_initialized
        total_heating_capacity_w += dist_htg.nominalCapacity.get
      elsif dist_htg.autosizedNominalCapacity.is_initialized
        total_heating_capacity_w += dist_htg.autosizedNominalCapacity.get
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlantLoop', "For #{plant_loop.name} capacity of DistrictHeating #{dist_htg.name} is not available, total heating capacity of plant loop will be incorrect when applying standard.")
      end
    end
  end

  total_heating_capacity_kbtu_per_hr = OpenStudio.convert(total_heating_capacity_w, 'W', 'kBtu/hr').get
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "For #{plant_loop.name}, heating capacity is #{total_heating_capacity_kbtu_per_hr.round} kBtu/hr.")

  return total_heating_capacity_w
end

#plant_loop_total_rated_w_per_gpm(plant_loop) ⇒ Double

Determines the total rated watts per GPM of the loop

Returns:

  • (Double)

    rated power consumption per flow @units Watts per GPM (W*s/m^3)



1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 1164

def plant_loop_total_rated_w_per_gpm(plant_loop)
  sizing_plant = plant_loop.sizingPlant
  loop_type = sizing_plant.loopType

  # Supply W/GPM
  supply_w_per_gpm = 0
  demand_w_per_gpm = 0

  plant_loop.supplyComponents.each do |component|
    if component.to_PumpConstantSpeed.is_initialized
      pump = component.to_PumpConstantSpeed.get
      pump_rated_w_per_gpm = pump_rated_w_per_gpm(pump)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "'#{loop_type}' Loop #{plant_loop.name} - Primary (Supply) Constant Speed Pump '#{pump.name}' - pump_rated_w_per_gpm #{pump_rated_w_per_gpm} W/GPM")
      supply_w_per_gpm += pump_rated_w_per_gpm
    elsif component.to_PumpVariableSpeed.is_initialized
      pump = component.to_PumpVariableSpeed.get
      pump_rated_w_per_gpm = pump_rated_w_per_gpm(pump)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "'#{loop_type}' Loop #{plant_loop.name} - Primary (Supply) VSD Pump '#{pump.name}' - pump_rated_w_per_gpm #{pump_rated_w_per_gpm} W/GPM")
      supply_w_per_gpm += pump_rated_w_per_gpm
    end
  end

  # Determine if primary only or primary-secondary
  # IF there's a pump on the demand side it's primary-secondary
  demand_pumps = plant_loop.demandComponents('OS:Pump:VariableSpeed'.to_IddObjectType) + plant_loop.demandComponents('OS:Pump:ConstantSpeed'.to_IddObjectType)
  demand_pumps.each do |component|
    if component.to_PumpConstantSpeed.is_initialized
      pump = component.to_PumpConstantSpeed.get
      pump_rated_w_per_gpm = pump_rated_w_per_gpm(pump)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "'#{loop_type}' Loop #{plant_loop.name} - Secondary (Demand) Constant Speed Pump '#{pump.name}' - pump_rated_w_per_gpm #{pump_rated_w_per_gpm} W/GPM")
      demand_w_per_gpm += pump_rated_w_per_gpm
    elsif component.to_PumpVariableSpeed.is_initialized
      pump = component.to_PumpVariableSpeed.get
      pump_rated_w_per_gpm = pump_rated_w_per_gpm(pump)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "'#{loop_type}' Loop #{plant_loop.name} - Secondary (Demand) VSD Pump '#{pump.name}' - pump_rated_w_per_gpm #{pump_rated_w_per_gpm} W/GPM")
      demand_w_per_gpm += pump_rated_w_per_gpm
    end
  end

  total_rated_w_per_gpm = supply_w_per_gpm + demand_w_per_gpm

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.PlantLoop', "'#{loop_type}' Loop #{plant_loop.name} - Total #{total_rated_w_per_gpm} W/GPM - Supply #{supply_w_per_gpm} W/GPM - Demand #{demand_w_per_gpm} W/GPM")

  return total_rated_w_per_gpm
end

#plant_loop_variable_flow_system?(plant_loop) ⇒ Boolean

Determine if the plant loop is variable flow. Returns true if primary and/or secondary pumps are variable speed.

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 15

def plant_loop_variable_flow_system?(plant_loop)
  variable_flow = false

  # Check all the primary pumps
  plant_loop.supplyComponents.each do |sc|
    if sc.to_PumpVariableSpeed.is_initialized
      variable_flow = true
    end
  end

  # Check all the secondary pumps
  plant_loop.demandComponents.each do |sc|
    if sc.to_PumpVariableSpeed.is_initialized
      variable_flow = true
    end
  end

  return variable_flow
end

#prototype_apply_condenser_water_temperatures(condenser_loop, design_wet_bulb_c: nil) ⇒ Object

Apply approach temperature sizing criteria to a condenser water loop

Parameters:

  • condenser_loop (<OpenStudio::Model::PlantLoop>)

    a condenser loop served by a cooling tower

  • design_wet_bulb_c (Double) (defaults to: nil)

    the outdoor design wetbulb conditions in degrees C



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.CoolingTower.rb', line 8

def prototype_apply_condenser_water_temperatures(condenser_loop,
                                                 design_wet_bulb_c: nil)
  sizing_plant = condenser_loop.sizingPlant
  loop_type = sizing_plant.loopType
  return false unless loop_type == 'Condenser'

  # if values are absent, use the CTI rating condition 78F
  if design_wet_bulb_c.nil?
    design_wet_bulb_c = OpenStudio.convert(78.0, 'F', 'C').get
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Prototype.hvac_systems', "For condenser loop #{condenser_loop.name}, no design day OATwb conditions given.  CTI rating condition of 78F OATwb will be used for sizing cooling towers.")
  end

  # EnergyPlus has a minimum limit of 68F and maximum limit of 80F for cooling towers
  design_wet_bulb_f = OpenStudio.convert(design_wet_bulb_c, 'C', 'F').get
  eplus_min_design_wet_bulb_f = 68.0
  eplus_max_design_wet_bulb_f = 80.0
  if design_wet_bulb_f < eplus_min_design_wet_bulb_f
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Prototype.CoolingTower', "For condenser loop #{condenser_loop.name}, increased design OATwb from #{design_wet_bulb_f.round(1)} F to EneryPlus model minimum limit of #{eplus_min_design_wet_bulb_f} F.")
    design_wet_bulb_f = eplus_min_design_wet_bulb_f
  elsif design_wet_bulb_f > eplus_max_design_wet_bulb_f
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Prototype.CoolingTower', "For condenser loop #{condenser_loop.name}, reduced design OATwb from #{design_wet_bulb_f.round(1)} F to EneryPlus model maximum limit of #{eplus_max_design_wet_bulb_f} F.")
    design_wet_bulb_f = eplus_max_design_wet_bulb_f
  end
  design_wet_bulb_c = OpenStudio.convert(design_wet_bulb_f, 'F', 'C').get

  # Determine the design CW temperature, approach, and range
  leaving_cw_t_c, approach_k, range_k = prototype_condenser_water_temperatures(design_wet_bulb_c)

  # Convert to IP units
  leaving_cw_t_f = OpenStudio.convert(leaving_cw_t_c, 'C', 'F').get
  approach_r = OpenStudio.convert(approach_k, 'K', 'R').get
  range_r = OpenStudio.convert(range_k, 'K', 'R').get

  # Report out design conditions
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Prototype.CoolingTower', "For condenser loop #{condenser_loop.name}, design OATwb = #{design_wet_bulb_f.round(1)} F, approach = #{approach_r.round(1)} deltaF, range = #{range_r.round(1)} deltaF, leaving condenser water temperature = #{leaving_cw_t_f.round(1)} F.")

  # Set Cooling Tower sizing parameters.
  # Only the variable speed cooling tower in E+ allows you to set the design temperatures.
  #
  # Per the documentation
  # http://bigladdersoftware.com/epx/docs/8-4/input-output-reference/group-condenser-equipment.html#field-design-u-factor-times-area-value
  # for CoolingTowerSingleSpeed and CoolingTowerTwoSpeed
  # E+ uses the following values during sizing:
  # 95F entering water temp
  # 95F OATdb
  # 78F OATwb
  # range = loop design delta-T aka range (specified above)
  condenser_loop.supplyComponents.each do |sc|
    if sc.to_CoolingTowerVariableSpeed.is_initialized
      ct = sc.to_CoolingTowerVariableSpeed.get
      ct.setDesignInletAirWetBulbTemperature(design_wet_bulb_c)
      ct.setDesignApproachTemperature(approach_k)
      ct.setDesignRangeTemperature(range_k)
    end
  end

  # Set the CW sizing parameters
  # EnergyPlus autosizing routine assumes 85F and 10F temperature difference
  energyplus_design_loop_exit_temperature_c = OpenStudio.convert(85.0, 'F', 'C').get
  sizing_plant.setDesignLoopExitTemperature(energyplus_design_loop_exit_temperature_c)
  sizing_plant.setLoopDesignTemperatureDifference(OpenStudio.convert(10.0, 'R', 'K').get)

  # Cooling Tower operational controls
  # G3.1.3.11 - Tower shall be controlled to maintain a 70F LCnWT where weather permits,
  # floating up to leaving water at design conditions.
  float_down_to_f = 70.0
  float_down_to_c = OpenStudio.convert(float_down_to_f, 'F', 'C').get

  # get or create a setpoint manager
  cw_t_stpt_manager = nil
  condenser_loop.supplyOutletNode.setpointManagers.each do |spm|
    if spm.to_SetpointManagerFollowOutdoorAirTemperature.is_initialized
      if spm.name.get.include? 'Setpoint Manager Follow OATwb'
        cw_t_stpt_manager = spm.to_SetpointManagerFollowOutdoorAirTemperature.get
      end
    end
  end
  if cw_t_stpt_manager.nil?
    cw_t_stpt_manager = OpenStudio::Model::SetpointManagerFollowOutdoorAirTemperature.new(condenser_loop.model)
    cw_t_stpt_manager.addToNode(condenser_loop.supplyOutletNode)
  end

  cw_t_stpt_manager.setName("#{condenser_loop.name} Setpoint Manager Follow OATwb with #{approach_r.round(1)}F Approach")
  cw_t_stpt_manager.setReferenceTemperatureType('OutdoorAirWetBulb')
  # At low design OATwb, it is possible to calculate
  # a maximum temperature below the minimum.  In this case,
  # make the maximum and minimum the same.
  if leaving_cw_t_c < float_down_to_c
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PlantLoop', "For #{condenser_loop.name}, the maximum leaving temperature of #{leaving_cw_t_f.round(1)} F is below the minimum of #{float_down_to_f.round(1)} F.  The maximum will be set to the same value as the minimum.")
    leaving_cw_t_c = float_down_to_c
  end
  cw_t_stpt_manager.setMaximumSetpointTemperature(leaving_cw_t_c)
  cw_t_stpt_manager.setMinimumSetpointTemperature(float_down_to_c)
  cw_t_stpt_manager.setOffsetTemperatureDifference(approach_k)
end

#prototype_condenser_water_temperatures(design_oat_wb_c) ⇒ Array<Double>

Determine the performance rating method specified design condenser water temperature, approach, and range

Parameters:

  • design_oat_wb_c (Double)

    the design OA wetbulb temperature ©

Returns:

  • (Array<Double>)
    leaving_cw_t_c, approach_k, range_k


108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.CoolingTower.rb', line 108

def prototype_condenser_water_temperatures(design_oat_wb_c)
  design_oat_wb_f = OpenStudio.convert(design_oat_wb_c, 'C', 'F').get

  # 90.1-2010 G3.1.3.11 - CW supply temp = 85F or 10F approaching design wet bulb temperature, whichever is lower.
  # Design range = 10F
  # Design Temperature rise of 10F => Range: 10F
  range_r = 10.0

  # Determine the leaving CW temp
  max_leaving_cw_t_f = 85.0
  leaving_cw_t_10f_approach_f = design_oat_wb_f + 10.0
  leaving_cw_t_f = [max_leaving_cw_t_f, leaving_cw_t_10f_approach_f].min

  # Calculate the approach
  approach_r = leaving_cw_t_f - design_oat_wb_f

  # Convert to SI units
  leaving_cw_t_c = OpenStudio.convert(leaving_cw_t_f, 'F', 'C').get
  approach_k = OpenStudio.convert(approach_r, 'R', 'K').get
  range_k = OpenStudio.convert(range_r, 'R', 'K').get

  return [leaving_cw_t_c, approach_k, range_k]
end

#pump_variable_speed_control_type(pump) ⇒ Boolean

Determine and set type of part load control type for heating and chilled water variable speed pumps

Parameters:

Returns:

  • (Boolean)

    Returns true if applicable, false otherwise



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.PumpVariableSpeed.rb', line 9

def pump_variable_speed_control_type(pump)
  # Get plant loop
  plant_loop = pump.plantLoop.get

  # Get plant loop type
  plant_loop_type = plant_loop.sizingPlant.loopType
  return false unless plant_loop_type == 'Heating' || plant_loop_type == 'Cooling'

  # Get rated pump power
  if pump.autosizedRatedPowerConsumption.is_initialized
    pump_rated_power_w = pump.autosizedRatedPowerConsumption.get
  elsif pump.ratedPowerConsumption.is_initialized
    pump_rated_power_w = pump.ratedPowerConsumption.get
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Pump', "For #{pump.name}, could not find rated pump power consumption, cannot determine w per gpm correctly.")
    return false
  end

  # Get nominal nameplate HP
  pump_nominal_hp = pump_rated_power_w * pump.motorEfficiency / 745.7

  # Assign peformance curves
  control_type = pump_variable_speed_get_control_type(pump, plant_loop_type, pump_nominal_hp)

  # Set pump part load performance curve coefficients
  pump_variable_speed_set_control_type(pump, control_type) unless !control_type

  return true
end

#pump_variable_speed_get_control_type(pump, plant_loop_type, pump_nominal_hp) ⇒ String

Determine type of pump part load control type

Parameters:

Returns:

  • (String)

    Pump part load control type



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.PumpVariableSpeed.rb', line 45

def pump_variable_speed_get_control_type(pump, plant_loop_type, pump_nominal_hp)
  # Get plant loop
  plant_loop = pump.plantLoop.get

  # Default assumptions are based on ASHRAE 90.1-2010 Appendix G (G3.1.3.5 and G3.1.3.10)
  case plant_loop_type
    when 'Heating'
      # Determine the area served by the plant loop
      area_served_m2 = plant_loop_total_floor_area_served(plant_loop)
      area_served_ft2 = OpenStudio.convert(area_served_m2, 'm^2', 'ft^2').get

      if area_served_ft2 > 120_000
        return 'VSD No Reset'
      else
        return 'Riding Curve'
      end
    when 'Cooling'
      # Get plant loop capacity capacity
      cooling_capacity_w = plant_loop_total_cooling_capacity(plant_loop)

      if cooling_capacity_w >= 300
        return 'VSD No Reset'
      else
        return 'Riding Curve'
      end
  end
end

#pump_variable_speed_set_control_type(pump_variable_speed, control_type) ⇒ Object

Set the pump curve coefficients based on the specified control type.

are Riding Curve, VSD No Reset, VSD DP Reset

Parameters:

  • control_type (String)

    valid choices



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/openstudio-standards/standards/Standards.PumpVariableSpeed.rb', line 11

def pump_variable_speed_set_control_type(pump_variable_speed, control_type)
  # Determine the coefficients
  coeff_a = nil
  coeff_b = nil
  coeff_c = nil
  coeff_d = nil
  case control_type
  when 'Constant Flow'
    coeff_a = 0.0
    coeff_b = 1.0
    coeff_c = 0.0
    coeff_d = 0.0
  when 'Riding Curve'
    coeff_a = 0.0
    coeff_b = 3.2485
    coeff_c = -4.7443
    coeff_d = 2.5294
  when 'VSD No Reset'
    coeff_a = 0.0
    coeff_b = 0.5726
    coeff_c = -0.301
    coeff_d = 0.7347
  when 'VSD DP Reset'
    coeff_a = 0.0
    coeff_b = 0.0205
    coeff_c = 0.4101
    coeff_d = 0.5753
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.PumpVariableSpeed', "Pump control type '#{control_type}' not recognized, pump coefficients will not be changed.")
    return false
  end

  # Set the coefficients
  pump_variable_speed.setCoefficient1ofthePartLoadPerformanceCurve(coeff_a)
  pump_variable_speed.setCoefficient2ofthePartLoadPerformanceCurve(coeff_b)
  pump_variable_speed.setCoefficient3ofthePartLoadPerformanceCurve(coeff_c)
  pump_variable_speed.setCoefficient4ofthePartLoadPerformanceCurve(coeff_d)
  pump_variable_speed.setPumpControlType('Intermittent')

  # Append the control type to the pump name
  # self.setName("#{self.name} #{control_type}")

  return true
end

#remove_air_loops(model) ⇒ Object

Remove all air loops in model



108
109
110
111
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 108

def remove_air_loops(model)
  model.getAirLoopHVACs.each(&:remove)
  return model
end

#remove_all_HVAC(model) ⇒ Object

Remove all HVAC equipment including service hot water loops and zone exhaust fans



186
187
188
189
190
191
192
193
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 186

def remove_all_HVAC(model)
  remove_air_loops(model)
  remove_all_plant_loops(model)
  remove_vrf(model)
  remove_all_zone_equipment(model)
  remove_unused_curves(model)
  return model
end

#remove_all_plant_loops(model) ⇒ Object

Remove all plant loops in model including those used for service hot water



131
132
133
134
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 131

def remove_all_plant_loops(model)
  model.getPlantLoops.each(&:remove)
  return model
end

#remove_All_Subsurfaces(surface:) ⇒ Object

This removes all of the subsurfaces from a surface. Is a preparation for replaceing windows or clearing doors before adding windows.



324
325
326
# File 'lib/openstudio-standards/standards/Standards.SubSurface.rb', line 324

def remove_All_Subsurfaces(surface:)
  surface.subSurfaces.sort.each(&:remove)
end

#remove_all_zone_equipment(model) ⇒ Object

Remove all zone equipment including exhaust fans



158
159
160
161
162
163
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 158

def remove_all_zone_equipment(model)
  model.getThermalZones.each do |zone|
    zone.equipment.each(&:remove)
  end
  return model
end

#remove_HVAC(model) ⇒ Object

Remove HVAC equipment except for service hot water loops and zone exhaust fans



176
177
178
179
180
181
182
183
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 176

def remove_HVAC(model)
  remove_air_loops(model)
  remove_plant_loops(model)
  remove_vrf(model)
  remove_zone_equipment(model)
  remove_unused_curves(model)
  return model
end

#remove_plant_loops(model) ⇒ Object

Remove plant loops in model except those used for service hot water



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 114

def remove_plant_loops(model)
  plant_loops = model.getPlantLoops
  plant_loops.each do |plant_loop|
    shw_use = false
    plant_loop.demandComponents.each do |component|
      if component.to_WaterUseConnections.is_initialized || component.to_CoilWaterHeatingDesuperheater.is_initialized
        shw_use = true
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "#{plant_loop.name} is used for SHW or refrigeration heat reclaim and will not be removed.")
        break
      end
    end
    plant_loop.remove unless shw_use
  end
  return model
end

#remove_unused_curves(model) ⇒ Object

Remove unused performance curves



166
167
168
169
170
171
172
173
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 166

def remove_unused_curves(model)
  model.getCurves.each do |curve|
    if curve.directUseCount == 0
      model.removeObject(curve.handle)
    end
  end
  return model
end

#remove_vrf(model) ⇒ Object

Remove VRF units



137
138
139
140
141
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 137

def remove_vrf(model)
  model.getAirConditionerVariableRefrigerantFlows.each(&:remove)
  model.getZoneHVACTerminalUnitVariableRefrigerantFlows.each(&:remove)
  return model
end

#remove_zone_equipment(model) ⇒ Object

Remove zone equipment except for exhaust fans



144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 144

def remove_zone_equipment(model)
  model.getThermalZones.each do |zone|
    zone.equipment.each do |equipment|
      if equipment.to_FanZoneExhaust.is_initialized
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "#{equipment.name} is a zone exhaust fan and will not be removed.")
      else
        equipment.remove
      end
    end
  end
  return model
end

#rename_air_loop_nodes(model) ⇒ Object

renames air loop nodes to readable values



715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 715

def rename_air_loop_nodes(model)
  # rename all hvac components on air loops
  model.getHVACComponents.sort.each do |component|
    next if component.to_Node.is_initialized # skip nodes

    unless component.airLoopHVAC.empty?
      # rename water to air component outlet nodes
      if component.to_WaterToAirComponent.is_initialized
        component = component.to_WaterToAirComponent.get
        unless component.airOutletModelObject.empty?
          component_outlet_object = component.airOutletModelObject.get
          next unless component_outlet_object.to_Node.is_initialized

          component_outlet_object.setName("#{component.name} Outlet Air Node")
        end
      end

      # rename air to air component nodes
      if component.to_AirToAirComponent.is_initialized
        component = component.to_AirToAirComponent.get
        unless component.primaryAirOutletModelObject.empty?
          component_outlet_object = component.primaryAirOutletModelObject.get
          next unless component_outlet_object.to_Node.is_initialized

          component_outlet_object.setName("#{component.name} Primary Outlet Air Node")
        end
        unless component.secondaryAirInletModelObject.empty?
          component_inlet_object = component.secondaryAirInletModelObject.get
          next unless component_inlet_object.to_Node.is_initialized

          component_inlet_object.setName("#{component.name} Secondary Inlet Air Node")
        end
      end

      # rename straight component outlet nodes
      if component.to_StraightComponent.is_initialized
        unless component.to_StraightComponent.get.outletModelObject.empty?
          component_outlet_object = component.to_StraightComponent.get.outletModelObject.get
          next unless component_outlet_object.to_Node.is_initialized

          component_outlet_object.setName("#{component.name} Outlet Air Node")
        end
      end
    end

    # rename zone hvac component nodes
    if component.to_ZoneHVACComponent.is_initialized
      component = component.to_ZoneHVACComponent.get
      unless component.airInletModelObject.empty?
        component_inlet_object = component.airInletModelObject.get
        next unless component_inlet_object.to_Node.is_initialized

        component_inlet_object.setName("#{component.name} Inlet Air Node")
      end
      unless component.airOutletModelObject.empty?
        component_outlet_object = component.airOutletModelObject.get
        next unless component_outlet_object.to_Node.is_initialized

        component_outlet_object.setName("#{component.name} Outlet Air Node")
      end
    end
  end

  # rename supply side nodes
  model.getAirLoopHVACs.sort.each do |air_loop|
    air_loop_name = air_loop.name.to_s
    air_loop.demandInletNode.setName("#{air_loop_name} Demand Inlet Node")
    air_loop.demandOutletNode.setName("#{air_loop_name} Demand Outlet Node")
    air_loop.supplyInletNode.setName("#{air_loop_name} Supply Inlet Node")
    air_loop.supplyOutletNode.setName("#{air_loop_name} Supply Outlet Node")

    unless air_loop.reliefAirNode.empty?
      relief_node = air_loop.reliefAirNode.get
      relief_node.setName("#{air_loop_name} Relief Air Node")
    end

    unless air_loop.mixedAirNode.empty?
      mixed_node = air_loop.mixedAirNode.get
      mixed_node.setName("#{air_loop_name} Mixed Air Node")
    end

    # rename outdoor air system and nodes
    unless air_loop.airLoopHVACOutdoorAirSystem.empty?
      oa_system = air_loop.airLoopHVACOutdoorAirSystem.get
      unless oa_system.outboardOANode.empty?
        oa_node = oa_system.outboardOANode.get
        oa_node.setName("#{air_loop_name} Outdoor Air Node")
      end
    end
  end

  # rename zone air and terminal nodes
  model.getThermalZones.sort.each do |zone|
    zone.zoneAirNode.setName("#{zone.name} Zone Air Node")

    unless zone.returnAirModelObject.empty?
      zone.returnAirModelObject.get.setName("#{zone.name} Return Air Node")
    end

    unless zone.airLoopHVACTerminal.empty?
      terminal_unit = zone.airLoopHVACTerminal.get
      if terminal_unit.to_StraightComponent.is_initialized
        component = terminal_unit.to_StraightComponent.get
        component.inletModelObject.get.setName("#{terminal_unit.name} Inlet Air Node")
      end
    end
  end

  # rename zone equipment list objects
  model.getZoneHVACEquipmentLists.sort.each do |obj|
    begin
      zone = obj.thermalZone
      obj.setName("#{zone.name} Zone HVAC Equipment List")
    rescue StandardError => e
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', "Removing ZoneHVACEquipmentList #{obj.name}; missing thermal zone.")
      obj.remove
    end
  end

  return model
end

#rename_plant_loop_nodes(model) ⇒ Object

renames plant loop nodes to readable values



838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 838

def rename_plant_loop_nodes(model)
  # rename all hvac components on plant loops
  model.getHVACComponents.sort.each do |component|
    next if component.to_Node.is_initialized # skip nodes

    unless component.plantLoop.empty?
      # rename straight component nodes
      # some inlet or outlet nodes may get renamed again
      if component.to_StraightComponent.is_initialized
        unless component.to_StraightComponent.get.inletModelObject.empty?
          component_inlet_object = component.to_StraightComponent.get.inletModelObject.get
          next unless component_inlet_object.to_Node.is_initialized

          component_inlet_object.setName("#{component.name} Inlet Water Node")
        end
        unless component.to_StraightComponent.get.outletModelObject.empty?
          component_outlet_object = component.to_StraightComponent.get.outletModelObject.get
          next unless component_outlet_object.to_Node.is_initialized

          component_outlet_object.setName("#{component.name} Outlet Water Node")
        end
      end

      # rename water to air component nodes
      if component.to_WaterToAirComponent.is_initialized
        component = component.to_WaterToAirComponent.get
        unless component.waterInletModelObject.empty?
          component_inlet_object = component.waterInletModelObject.get
          next unless component_inlet_object.to_Node.is_initialized

          component_inlet_object.setName("#{component.name} Inlet Water Node")
        end
        unless component.waterOutletModelObject.empty?
          component_outlet_object = component.waterOutletModelObject.get
          next unless component_outlet_object.to_Node.is_initialized

          component_outlet_object.setName("#{component.name} Outlet Water Node")
        end
      end

      # rename water to water component nodes
      if component.to_WaterToWaterComponent.is_initialized
        component = component.to_WaterToWaterComponent.get
        unless component.demandInletModelObject.empty?
          demand_inlet_object = component.demandInletModelObject.get
          next unless demand_inlet_object.to_Node.is_initialized

          demand_inlet_object.setName("#{component.name} Demand Inlet Water Node")
        end
        unless component.demandOutletModelObject.empty?
          demand_outlet_object = component.demandOutletModelObject.get
          next unless demand_outlet_object.to_Node.is_initialized

          demand_outlet_object.setName("#{component.name} Demand Outlet Water Node")
        end
        unless component.supplyInletModelObject.empty?
          supply_inlet_object = component.supplyInletModelObject.get
          next unless supply_inlet_object.to_Node.is_initialized

          supply_inlet_object.setName("#{component.name} Supply Inlet Water Node")
        end
        unless component.supplyOutletModelObject .empty?
          supply_outlet_object = component.supplyOutletModelObject .get
          next unless supply_outlet_object.to_Node.is_initialized

          supply_outlet_object.setName("#{component.name} Supply Outlet Water Node")
        end
      end
    end
  end

  # rename plant nodes
  model.getPlantLoops.sort.each do |plant_loop|
    plant_loop_name = plant_loop.name.to_s
    plant_loop.demandInletNode.setName("#{plant_loop_name} Demand Inlet Node")
    plant_loop.demandOutletNode.setName("#{plant_loop_name} Demand Outlet Node")
    plant_loop.supplyInletNode.setName("#{plant_loop_name} Supply Inlet Node")
    plant_loop.supplyOutletNode.setName("#{plant_loop_name} Supply Outlet Node")
  end
end

#safe_load_model(model_path_string) ⇒ Object

load a model into OS & version translates, exiting and erroring if a problem is found



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 5

def safe_load_model(model_path_string)
  model_path = OpenStudio::Path.new(model_path_string)
  if OpenStudio.exists(model_path)
    version_translator = OpenStudio::OSVersion::VersionTranslator.new
    model = version_translator.loadModel(model_path)
    if model.empty?
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "Version translation failed for #{model_path_string}")
      return false
    else
      model = model.get
    end
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "#{model_path_string} couldn't be found")
    return false
  end
  return model
end

#safe_load_sql(sql_path_string) ⇒ Object

load a sql file, exiting and erroring if a problem is found



24
25
26
27
28
29
30
31
32
33
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 24

def safe_load_sql(sql_path_string)
  sql_path = OpenStudio::Path.new(sql_path_string)
  if OpenStudio.exists(sql_path)
    sql = OpenStudio::SqlFile.new(sql_path)
  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "#{sql_path} couldn't be found")
    return false
  end
  return sql
end

#schedule_apply_parametric_inputs(schedule, ramp_frequency, infer_hoo_for_non_assigned_objects, error_on_out_of_order, parametric_inputs = nil) ⇒ Object

this will use parametric inputs contained in schedule and profiles along with inferred hours of operation to generate updated ruleset schedule profiles

Parameters:

  • schedule
  • infer_hoo_for_non_assigned_objects (Bool)

    # attempt to get hoo for objects like swh with and exterior lighting

  • error_on_out_of_order (Bool)

    true will error if applying formula creates out of order values

Returns:

  • schedule

Author:

  • David Goldwasser



386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
# File 'lib/openstudio-standards/standards/Standards.ScheduleRuleset.rb', line 386

def schedule_apply_parametric_inputs(schedule, ramp_frequency, infer_hoo_for_non_assigned_objects, error_on_out_of_order, parametric_inputs = nil)
  # Check if parametric inputs were supplied and generate them if not
  if parametric_inputs.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ScheduleRuleset', "For #{schedule.name}, no parametric inputs were not supplied so they will be generated now.")
    parametric_inputs = model_setup_parametric_schedules(schedule.model, gather_data_only: true)
  end

  # Check that parametric inputs exist for this schedule after generation
  if parametric_inputs[schedule].nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ScheduleRuleset', "For #{schedule.name}, no parametric inputs exists so schedule will not be changed.")
    return schedule
  end

  # Check that an hours of operation schedule is associated with this schedule
  if parametric_inputs[schedule][:hoo_inputs].nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ScheduleRuleset', "For #{schedule.name}, no associated hours of operation schedule was found so schedule will not be changed.")
    return schedule
  end

  # Get the hours of operation schedule
  hours_of_operation = parametric_inputs[schedule][:hoo_inputs]
  # OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ScheduleRuleset', "For #{schedule.name} hours_of_operation = #{hours_of_operation.name}.")

  starting_aeflh = schedule_ruleset_annual_equivalent_full_load_hrs(schedule)

  # store floor and ceiling value
  val_flr = nil
  if schedule.hasAdditionalProperties && schedule.additionalProperties.hasFeature('param_sch_floor')
    val_flr = schedule.additionalProperties.getFeatureAsDouble('param_sch_floor').get
  end
  val_clg = nil
  if schedule.hasAdditionalProperties && schedule.additionalProperties.hasFeature('param_sch_ceiling')
    val_clg = schedule.additionalProperties.getFeatureAsDouble('param_sch_ceiling').get
  end

  # loop through schedule days from highest to lowest priority (with default as lowest priority)
  # if rule needs to be split to address hours of operation rules add new rule next to relevant existing rule
  profiles = {}
  schedule.scheduleRules.each do |rule|
    # remove any use manually generated non parametric rules or any auto-generated rules from prior application of formulas and hoo
    sch_day = rule.daySchedule
    if !sch_day.hasAdditionalProperties || !sch_day.additionalProperties.hasFeature('param_day_tag') || (sch_day.additionalProperties.getFeatureAsString('param_day_tag').get == 'autogen')
      sch_day.remove # remove day schedule for this rule
      rule.remove # remove the rule
    elsif !sch_day.additionalProperties.hasFeature('param_day_profile')
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ScheduleRuleset', "#{schedule.name} doesn't have a parametric formula for #{rule.name} This profile will not be altered.")
      next
    else
      profiles[sch_day] = rule
    end
  end
  profiles[schedule.defaultDaySchedule] = nil

  # get indices for current schedule
  year_description = schedule.model.yearDescription.get
  year = year_description.assumedYear
  year_start_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('January'), 1, year)
  year_end_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('December'), 31, year)
  indices_vector = schedule.getActiveRuleIndices(year_start_date, year_end_date)

  # process profiles
  profiles.each do |sch_day, rule|
    # for current profile index identify hours of operation index that contains all days
    if rule.nil?
      current_rule_index = -1
    else
      current_rule_index = rule.ruleIndex
    end

    # loop through indices looking of rule in hoo that contains days in the rule
    hoo_target_index = nil
    days_used = []
    indices_vector.each_with_index do |profile_index, i|
      if profile_index == current_rule_index then days_used << i + 1 end
    end
    # find days_used in hoo profiles that contains all days used from this profile
    hoo_profile_match_hash = {}
    best_fit_check = {}
    hours_of_operation.each do |profile_index, value|
      days_for_rule_not_in_hoo_profile = days_used - value[:days_used]
      hoo_profile_match_hash[profile_index] = days_for_rule_not_in_hoo_profile
      best_fit_check[profile_index] = days_for_rule_not_in_hoo_profile.size
      if days_for_rule_not_in_hoo_profile.empty?
        hoo_target_index = profile_index
      end
    end
    clone_needed = false
    hoo_target_index = best_fit_check.key(best_fit_check.values.min)
    if best_fit_check[hoo_target_index] > 0
      clone_needed = true
    end

    # get hours of operation for this specific profile
    hoo_start = hours_of_operation[hoo_target_index][:hoo_start]
    hoo_end = hours_of_operation[hoo_target_index][:hoo_end]

    # update scheduleDay
    process_hrs_of_operation_hash(sch_day, hoo_start, hoo_end, val_flr, val_clg, ramp_frequency, infer_hoo_for_non_assigned_objects, error_on_out_of_order)

    # clone new rule if needed
    if clone_needed

      # make list of new rules needed as has or array
      autogen_rules = {}
      days_to_fill = hoo_profile_match_hash[hoo_target_index]
      hours_of_operation.each do |profile_index, value|
        remainder = days_to_fill - value[:days_used]
        day_for_rule = days_to_fill - remainder
        if remainder.size < days_to_fill.size
          autogen_rules[profile_index] = { days_to_fill: day_for_rule, hoo_start: hoo_start, hoo_end: hoo_end }
        end
        days_to_fill = remainder
      end

      # loop through new rules to make and process
      autogen_rules.each do |autogen_rule, hash|
        # generate new rule
        sch_rule_autogen = OpenStudio::Model::ScheduleRule.new(schedule)
        if current_rule_index
          target_index = schedule.scheduleRules.size - 1 # just above default
        else
          target_index = current_rule_index - 1 # confirm just above orig rule
        end
        current_rule_index = target_index
        if rule.nil?
          sch_rule_autogen.setName("autogen #{schedule.name} #{target_index}")
        else
          sch_rule_autogen.setName("autogen #{rule.name} #{target_index}")
        end
        schedule.setScheduleRuleIndex(sch_rule_autogen, target_index) # TODO: - confirm this is higher priority than the non-auto-generated rule
        hash[:days_to_fill].each do |day|
          date = OpenStudio::Date.fromDayOfYear(day, year)
          sch_rule_autogen.addSpecificDate(date)
        end
        sch_rule_autogen.setApplySunday(true)
        sch_rule_autogen.setApplyMonday(true)
        sch_rule_autogen.setApplyTuesday(true)
        sch_rule_autogen.setApplyWednesday(true)
        sch_rule_autogen.setApplyThursday(true)
        sch_rule_autogen.setApplyFriday(true)
        sch_rule_autogen.setApplySaturday(true)

        # match profile from source rule (don't add time/values need a formula to process)
        sch_day_auto_gen = sch_rule_autogen.daySchedule
        sch_day_auto_gen.setName("#{sch_rule_autogen.name}_day_sch")
        sch_day_auto_gen.additionalProperties.setFeature('param_day_tag', 'autogen')
        val = sch_day.additionalProperties.getFeatureAsString('param_day_profile').get
        sch_day_auto_gen.additionalProperties.setFeature('param_day_profile', val)
        val = sch_day.additionalProperties.getFeatureAsString('param_day_secondary_logic').get
        sch_day_auto_gen.additionalProperties.setFeature('param_day_secondary_logic', val)
        val = sch_day.additionalProperties.getFeatureAsString('param_day_secondary_logic_arg_val').get
        sch_day_auto_gen.additionalProperties.setFeature('param_day_secondary_logic_arg_val', val)

        # get hours of operation for this specific profile
        hoo_start = hash[:hoo_start]
        hoo_end = hash[:hoo_end]

        # process new rule
        process_hrs_of_operation_hash(sch_day_auto_gen, hoo_start, hoo_end, val_flr, val_clg, ramp_frequency, infer_hoo_for_non_assigned_objects, error_on_out_of_order)
      end

    end
  end

  # TODO: - create summer and winter design day profiles (make sure scheduleDay objects parametric)
  # todo - should they have their own formula, or should this be hard coded logic by schedule type

  # check orig vs. updated aeflh
  final_aeflh = schedule_ruleset_annual_equivalent_full_load_hrs(schedule)
  percent_change = ((starting_aeflh - final_aeflh) / starting_aeflh) * 100.0
  if percent_change.abs > 0.05
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ScheduleRuleset', "For #{schedule.name}, applying parametric schedules made a #{percent_change.round(1)}% change in annual equivalent full load hours. (from #{starting_aeflh.round(2)} to #{final_aeflh.round(2)})")
  end

  return schedule
end

#schedule_compact_annual_min_max_value(schedule_compact) ⇒ Object

Returns the min and max value for this schedule.

return [Hash] Hash has two keys, min and max.

Author:

  • Andrew Parker, NREL.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/openstudio-standards/standards/Standards.ScheduleCompact.rb', line 8

def schedule_compact_annual_min_max_value(schedule_compact)
  vals = []
  prev_str = ''
  sch.extensibleGroups.each do |eg|
    if prev_str.include?('until')
      val = eg.getDouble(0)
      if val.is_initialized
        vals << eg.getDouble(0).get
      end
    end
    str = eg.getString(0)
    if str.is_initialized
      prev_str = str.get.downcase
    end
  end

  # Error if no values were found
  if vals.size.zero?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.ScheduleCompact', "Could not find any value in #{schedule_compact.name} when determining min and max.")
    result = { 'min' => 999.9, 'max' => 999.9 }
    return result
  end

  result = { 'min' => vals.min, 'max' => vals.max }

  return result
end

#schedule_constant_annual_equivalent_full_load_hrs(schedule_constant) ⇒ Object

Returns the equivalent full load hours (EFLH) for this schedule. For example, an always-on fractional schedule (always 1.0, 24/7, 365) would return a value of 8760.

return [Double] The total number of full load hours for this schedule

Author:

  • Andrew Parker, NREL



10
11
12
13
14
# File 'lib/openstudio-standards/standards/Standards.ScheduleConstant.rb', line 10

def schedule_constant_annual_equivalent_full_load_hrs(schedule_constant)
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ScheduleConstant', "Calculating total annual EFLH for schedule: #{schedule_constant.name}")

  return annual_flh = schedule_constant.value * 8760
end

#schedule_constant_annual_min_max_value(schedule_constant) ⇒ Object

Returns the min and max value for this schedule. It doesn’t evaluate design days only run-period conditions

return [Hash] Hash has two keys, min and max.

Author:

  • David Goldwasser, NREL.



21
22
23
24
25
# File 'lib/openstudio-standards/standards/Standards.ScheduleConstant.rb', line 21

def schedule_constant_annual_min_max_value(schedule_constant)
  result = { 'min' => schedule_constant.value, 'max' => schedule_constant.value }

  return result
end

#schedule_ruleset_annual_equivalent_full_load_hrs(schedule_ruleset) ⇒ Double

Returns the equivalent full load hours (EFLH) for this schedule. For example, an always-on fractional schedule (always 1.0, 24/7, 365) would return a value of 8760.

Parameters:

  • scheduleRuleset (object)

Returns:

  • (Double)

    The total number of full load hours for this schedule.

Author:

  • Andrew Parker, NREL. Matt Leach, NORESCO.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/openstudio-standards/standards/Standards.ScheduleRuleset.rb', line 36

def schedule_ruleset_annual_equivalent_full_load_hrs(schedule_ruleset)
  # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "Calculating total annual EFLH for schedule: #{self.name}")

  # Define the start and end date
  year_start_date = nil
  year_end_date = nil
  if schedule_ruleset.model.yearDescription.is_initialized
    year_description = schedule_ruleset.model.yearDescription.get
    year = year_description.assumedYear
    year_start_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('January'), 1, year)
    year_end_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('December'), 31, year)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ScheduleRuleset', 'Year description is not specified. Full load hours calculation will assume 2009, the default year OS uses.')
    year_start_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('January'), 1, 2009)
    year_end_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('December'), 31, 2009)
  end

  # Get the ordered list of all the day schedules
  # that are used by this schedule ruleset
  day_schs = schedule_ruleset.getDaySchedules(year_start_date, year_end_date)
  # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "***Day Schedules Used***")
  day_schs.uniq.each do |day_sch|
    # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "  #{day_sch.name.get}")
  end

  # Get a 365-value array of which schedule is used on each day of the year,
  day_schs_used_each_day = schedule_ruleset.getActiveRuleIndices(year_start_date, year_end_date)
  if !day_schs_used_each_day.length == 365
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.ScheduleRuleset', "#{schedule_ruleset.name} does not have 365 daily schedules accounted for, cannot accurately calculate annual EFLH.")
    return 0
  end

  # Create a map that shows how many days each schedule is used
  day_sch_freq = day_schs_used_each_day.group_by { |n| n }

  # Build a hash that maps schedule day index to schedule day
  schedule_index_to_day = {}
  day_schs.each_with_index do |day_sch, i|
    schedule_index_to_day[day_schs_used_each_day[i]] = day_sch
  end

  # Loop through each of the schedules that is used, figure out the
  # full load hours for that day, then multiply this by the number
  # of days that day schedule applies and add this to the total.
  annual_flh = 0
  max_daily_flh = 0
  default_day_sch = schedule_ruleset.defaultDaySchedule
  day_sch_freq.each do |freq|
    # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", freq.inspect
    # exit

    # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "Schedule Index = #{freq[0]}"
    sch_index = freq[0]
    number_of_days_sch_used = freq[1].size

    # Get the day schedule at this index
    day_sch = nil
    day_sch = if sch_index == -1 # If index = -1, this day uses the default day schedule (not a rule)
                default_day_sch
              else
                schedule_index_to_day[sch_index]
              end
    # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "Calculating EFLH for: #{day_sch.name}")

    daily_flh = day_schedule_equivalent_full_load_hrs(day_sch)

    # Multiply the daily EFLH by the number
    # of days this schedule is used per year
    # and add this to the overall total
    annual_flh += daily_flh * number_of_days_sch_used
  end

  # Warn if the max daily EFLH is more than 24,
  # which would indicate that this isn't a
  # fractional schedule.
  if max_daily_flh > 24
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ScheduleRuleset', "#{schedule_ruleset.name} has more than 24 EFLH in one day schedule, indicating that it is not a fractional schedule.")
  end

  return annual_flh
end

#schedule_ruleset_annual_hourly_values(schedule_ruleset) ⇒ Array<Double>

Returns the averaged hourly values of the ruleset schedule for all hours of the year

Parameters:

  • schedule_ruleset (<OpenStudio::Model::ScheduleRuleset>)

    A ScheduleRuleset object

Returns:

  • (Array<Double>)

    An array of hourly values over the whole year



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/openstudio-standards/standards/Standards.ScheduleRuleset.rb', line 256

def schedule_ruleset_annual_hourly_values(schedule_ruleset)
  schedule_values = []
  year_description = schedule_ruleset.model.getYearDescription
  (1..365).each do |i|
    date = year_description.makeDate(i)
    day_sch = schedule_ruleset.getDaySchedules(date, date)[0]
    (0..23).each do |j|
      # take average value over the hour
      value_15 = day_sch.getValue(OpenStudio::Time.new(0, j, 15, 0))
      value_30 = day_sch.getValue(OpenStudio::Time.new(0, j, 30, 0))
      value_45 = day_sch.getValue(OpenStudio::Time.new(0, j, 45, 0))
      avg = (value_15 + value_30 + value_45).to_f / 3.0
      schedule_values << avg.round(5)
    end
  end
  return schedule_values
end

#schedule_ruleset_annual_hours_above_value(schedule_ruleset, lower_limit) ⇒ Double

Returns the total number of hours where the schedule is greater than the specified value.

will not be counted. this schedule is above the specified value.

Parameters:

  • lower_limit (Double)

    the lower limit. Values equal to the limit

Returns:

  • (Double)

    The total number of hours

Author:

  • Andrew Parker, NREL.



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/openstudio-standards/standards/Standards.ScheduleRuleset.rb', line 163

def schedule_ruleset_annual_hours_above_value(schedule_ruleset, lower_limit)
  # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "Calculating total annual hours above #{lower_limit} for schedule: #{self.name}")

  # Define the start and end date
  year_start_date = nil
  year_end_date = nil
  if schedule_ruleset.model.yearDescription.is_initialized
    year_description = schedule_ruleset.model.yearDescription.get
    year = year_description.assumedYear
    year_start_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('January'), 1, year)
    year_end_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('December'), 31, year)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ScheduleRuleset', 'Year description is not specified. Annual hours above value calculation will assume 2009, the default year OS uses.')
    year_start_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('January'), 1, 2009)
    year_end_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('December'), 31, 2009)
  end

  # Get the ordered list of all the day schedules
  # that are used by this schedule ruleset
  day_schs = schedule_ruleset.getDaySchedules(year_start_date, year_end_date)
  # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "***Day Schedules Used***")
  day_schs.uniq.each do |day_sch|
    # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "  #{day_sch.name.get}")
  end

  # Get a 365-value array of which schedule is used on each day of the year,
  day_schs_used_each_day = schedule_ruleset.getActiveRuleIndices(year_start_date, year_end_date)
  if !day_schs_used_each_day.length == 365
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.ScheduleRuleset', "#{schedule_ruleset.name} does not have 365 daily schedules accounted for, cannot accurately calculate annual EFLH.")
    return 0
  end

  # Create a map that shows how many days each schedule is used
  day_sch_freq = day_schs_used_each_day.group_by { |n| n }

  # Build a hash that maps schedule day index to schedule day
  schedule_index_to_day = {}
  day_schs.each_with_index do |day_sch, i|
    schedule_index_to_day[day_schs_used_each_day[i]] = day_sch
  end

  # Loop through each of the schedules that is used, figure out the
  # hours for that day, then multiply this by the number
  # of days that day schedule applies and add this to the total.
  annual_hrs = 0
  default_day_sch = schedule_ruleset.defaultDaySchedule
  day_sch_freq.each do |freq|
    # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", freq.inspect
    # exit

    # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "Schedule Index = #{freq[0]}"
    sch_index = freq[0]
    number_of_days_sch_used = freq[1].size

    # Get the day schedule at this index
    day_sch = nil
    day_sch = if sch_index == -1 # If index = -1, this day uses the default day schedule (not a rule)
                default_day_sch
              else
                schedule_index_to_day[sch_index]
              end
    # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "Calculating hours above #{lower_limit} for: #{day_sch.name}")

    # Determine the hours for just one day
    daily_hrs = 0
    values = day_sch.values
    times = day_sch.times

    previous_time_decimal = 0
    times.each_with_index do |time, i|
      time_decimal = (time.days * 24.0) + time.hours + (time.minutes / 60.0) + (time.seconds / 3600.0)
      duration_of_value = time_decimal - previous_time_decimal
      # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "  Value of #{values[i]} for #{duration_of_value} hours")
      daily_hrs += values[i] * duration_of_value
      previous_time_decimal = time_decimal
    end

    # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "  #{daily_hrs.round(2)} hours above #{lower_limit} per day")
    # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.ScheduleRuleset", "  Used #{number_of_days_sch_used} days per year")

    # Multiply the daily hours by the number
    # of days this schedule is used per year
    # and add this to the overall total
    annual_hrs += daily_hrs * number_of_days_sch_used
  end

  return annual_hrs
end

#schedule_ruleset_annual_min_max_value(schedule_ruleset) ⇒ Hash

Returns the min and max value for this schedule. It doesn’t evaluate design days only run-period conditions

Parameters:

  • scheduleRuleset (object)

Returns:

  • (Hash)

    Hash has two keys, min and max.

Author:

  • David Goldwasser, NREL.



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/openstudio-standards/standards/Standards.ScheduleRuleset.rb', line 124

def schedule_ruleset_annual_min_max_value(schedule_ruleset)
  # gather profiles
  profiles = []
  profiles << schedule_ruleset.defaultDaySchedule
  rules = schedule_ruleset.scheduleRules
  rules.each do |rule|
    profiles << rule.daySchedule
  end

  # test profiles
  min = nil
  max = nil
  profiles.each do |profile|
    profile.values.each do |value|
      if min.nil?
        min = value
      else
        min = value if min > value
      end
      if max.nil?
        max = value
      else
        max = value if max < value
      end
    end
  end
  result = { 'min' => min, 'max' => max }

  return result
end

#schedule_ruleset_cleanup_profiles(schedule_ruleset) ⇒ Object

Remove unused profiles and set most prevalent profile as default When moving profile that isn’t lowest priority to default need to address possible issues with overlapping rules dates or days of week method expands on functionality of RemoveUnusedDefaultProfiles measure

Parameters:

  • ScheduleRuleset (Object)

Returns:

  • (Object)

    ScheduleRuleset

Author:

  • David Goldwasser



281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/openstudio-standards/standards/Standards.ScheduleRuleset.rb', line 281

def schedule_ruleset_cleanup_profiles(schedule_ruleset)
  # set start and end dates
  year_description = schedule_ruleset.model.yearDescription.get
  year = year_description.assumedYear
  year_start_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('January'), 1, year)
  year_end_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('December'), 31, year)

  indices_vector = schedule_ruleset.getActiveRuleIndices(year_start_date, year_end_date)
  most_frequent_item = indices_vector.uniq.max_by { |i| indices_vector.count(i) }
  rule_vector = schedule_ruleset.scheduleRules

  replace_existing_default = false
  if indices_vector.include? -1 && most_frequent_item != -1
    # clean up if default isn't most common (e.g. sunday vs. weekday)
    # if no existing rules cover specific days of week, make new rule from default covering those days of week
    possible_days_of_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
    used_days_of_week = []
    rule_vector.each do |rule|
      if rule.applyMonday then used_days_of_week << 'Monday' end
      if rule.applyTuesday then used_days_of_week << 'Tuesday' end
      if rule.applyWednesday then used_days_of_week << 'Wednesday' end
      if rule.applyThursday then used_days_of_week << 'Thursday' end
      if rule.applyFriday then used_days_of_week << 'Friday' end
      if rule.applySaturday then used_days_of_week << 'Saturday' end
      if rule.applySunday then used_days_of_week << 'Sunday' end
    end
    if used_days_of_week.uniq.size < possible_days_of_week.size
      replace_existing_default = true
      schedule_rule_new = OpenStudio::Model::ScheduleRule.new(schedule_ruleset, schedule_ruleset.defaultDaySchedule)
      if !used_days_of_week.include?('Monday') then schedule_rule_new.setApplyMonday(true) end
      if !used_days_of_week.include?('Tuesday') then schedule_rule_new.setApplyTuesday(true) end
      if !used_days_of_week.include?('Wednesday') then schedule_rule_new.setApplyWednesday(true) end
      if !used_days_of_week.include?('Thursday') then schedule_rule_new.setApplyThursday(true) end
      if !used_days_of_week.include?('Friday') then schedule_rule_new.setApplyFriday(true) end
      if !used_days_of_week.include?('Saturday') then schedule_rule_new.setApplySaturday(true) end
      if !used_days_of_week.include?('Sunday') then schedule_rule_new.setApplySunday(true) end
    end
  end

  if !indices_vector.include?(-1) || replace_existing_default

    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ScheduleRuleset', "#{schedule_ruleset.name} does not used the default profile, it will be replaced.")

    # reset values in default ScheduleDay
    old_default_schedule_day = schedule_ruleset.defaultDaySchedule
    old_default_schedule_day.clearValues

    # update selection to the most commonly used profile vs. the lowest priority, if it can be done without any conflicts
    # safe test is to see if any other rules use same days of week as most common,
    # if doesn't pass then make highest rule the new default to avoid any problems. School may not pass this test, woudl use last rule
    days_of_week_most_frequent_item = []
    schedule_rule_most_frequent = rule_vector[most_frequent_item]
    if schedule_rule_most_frequent.applyMonday then days_of_week_most_frequent_item << 'Monday' end
    if schedule_rule_most_frequent.applyTuesday then days_of_week_most_frequent_item << 'Tuesday' end
    if schedule_rule_most_frequent.applyWednesday then days_of_week_most_frequent_item << 'Wednesday' end
    if schedule_rule_most_frequent.applyThursday then days_of_week_most_frequent_item << 'Thursday' end
    if schedule_rule_most_frequent.applyFriday then days_of_week_most_frequent_item << 'Friday' end
    if schedule_rule_most_frequent.applySaturday then days_of_week_most_frequent_item << 'Saturday' end
    if schedule_rule_most_frequent.applySunday then days_of_week_most_frequent_item << 'Sunday' end

    # loop through rules
    conflict_found = false
    rule_vector.each do |rule|
      next if rule == schedule_rule_most_frequent

      days_of_week_most_frequent_item.each do |day_of_week|
        if (day_of_week == 'Monday') && rule.applyMonday then conflict_found == true end
        if (day_of_week == 'Tuesday') && rule.applyTuesday then conflict_found == true end
        if (day_of_week == 'Wednesday') && rule.applyWednesday then conflict_found == true end
        if (day_of_week == 'Thursday') && rule.applyThursday then conflict_found == true end
        if (day_of_week == 'Friday') && rule.applyFriday then conflict_found == true end
        if (day_of_week == 'Saturday') && rule.applySaturday then conflict_found == true end
        if (day_of_week == 'Sunday') && rule.applySunday then conflict_found == true end
      end
    end
    if conflict_found
      new_default_index = indices_vector.max
    else
      new_default_index = most_frequent_item
    end

    # get values for new default profile
    new_default_daySchedule = rule_vector[new_default_index].daySchedule
    new_default_daySchedule_values = new_default_daySchedule.values
    new_default_daySchedule_times = new_default_daySchedule.times

    # update values and times for default profile
    for i in 0..(new_default_daySchedule_values.size - 1)
      old_default_schedule_day.addValue(new_default_daySchedule_times[i], new_default_daySchedule_values[i])
    end

    # remove rule object that has become the default. Also try to remove the ScheduleDay
    rule_vector[new_default_index].remove # this seems to also remove the ScheduleDay associated with the rule
  end

  return schedule_ruleset
end

#schedule_ruleset_set_hours_of_operation(schedule_ruleset, wkdy_start_time: nil, wkdy_end_time: nil, sat_start_time: nil, sat_end_time: nil, sun_start_time: nil, sun_end_time: nil) ⇒ Bool

Apply specified hours of operation values to rules in this schedule. Weekday values will be applied to the default profile. Weekday values will be applied to any rules that are used on a weekday. Saturday values will be applied to any rules that are used on a Saturday. Sunday values will be applied to any rules that are used on a Sunday. If a rule applies to Weekdays, Saturdays, and/or Sundays, values will be applied in that order of precedence. If a rule does not apply to any of these days, it is unused and will not be modified.

Parameters:

  • wkdy_start_time (OpenStudio::Time) (defaults to: nil)

    Weekday start time. If nil, no change will be made to this day.

  • wkdy_end_time (OpenStudio::Time) (defaults to: nil)

    Weekday end time. If greater than 24:00, hours of operation will wrap over midnight.

  • sat_start_time (OpenStudio::Time) (defaults to: nil)

    Saturday start time. If nil, no change will be made to this day.

  • sat_end_time (OpenStudio::Time) (defaults to: nil)

    Saturday end time. If greater than 24:00, hours of operation will wrap over midnight.

  • sun_start_time (OpenStudio::Time) (defaults to: nil)

    Sunday start time. If nil, no change will be made to this day.

  • sun_end_time (OpenStudio::Time) (defaults to: nil)

    Sunday end time. If greater than 24:00, hours of operation will wrap over midnight.

Returns:

  • (Bool)

    Returns true if successful, false if not



577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
# File 'lib/openstudio-standards/standards/Standards.ScheduleRuleset.rb', line 577

def schedule_ruleset_set_hours_of_operation(schedule_ruleset, wkdy_start_time: nil, wkdy_end_time: nil, sat_start_time: nil, sat_end_time: nil, sun_start_time: nil, sun_end_time: nil)
  # Default day is assumed to represent weekdays
  if wkdy_start_time && wkdy_end_time
    schedule_day_set_hours_of_operation(schedule_ruleset.defaultDaySchedule, wkdy_start_time, wkdy_end_time)
    # OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ScheduleRuleset', "For #{schedule_ruleset.name}, set default operating hours to #{wkdy_start_time}-#{wkdy_end_time}.")
  end

  # Modify each rule
  schedule_ruleset.scheduleRules.each do |rule|
    if rule.applyMonday || rule.applyTuesday || rule.applyWednesday || rule.applyThursday || rule.applyFriday
      if wkdy_start_time && wkdy_end_time
        schedule_day_set_hours_of_operation(rule.daySchedule, wkdy_start_time, wkdy_end_time)
        # OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ScheduleRuleset', "For #{schedule_ruleset.name}, set Saturday rule operating hours to #{wkdy_start_time}-#{wkdy_end_time}.")
      end
    elsif rule.applySaturday
      if sat_start_time && sat_end_time
        schedule_day_set_hours_of_operation(rule.daySchedule, sat_start_time, sat_end_time)
        # OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ScheduleRuleset', "For #{schedule_ruleset.name}, set Saturday rule operating hours to #{sat_start_time}-#{sat_end_time}.")
      end
    elsif rule.applySunday
      if sun_start_time && sun_end_time
        schedule_day_set_hours_of_operation(rule.daySchedule, sun_start_time, sun_end_time)
        # OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ScheduleRuleset', "For #{schedule_ruleset.name}, set Sunday rule operating hours to #{sun_start_time}-#{sun_end_time}.")
      end
    end
  end

  return true
end

#seer_to_cop_cooling_no_fan(seer) ⇒ Double

Convert from SEER to COP (no fan) for cooling coils

Parameters:

  • seer (Double)

    seasonal energy efficiency ratio (SEER)

Returns:

  • (Double)

    Coefficient of Performance (COP)



222
223
224
225
226
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 222

def seer_to_cop_cooling_no_fan(seer)
  cop = -0.0076 * seer * seer + 0.3796 * seer

  return cop
end

#seer_to_cop_cooling_with_fan(seer) ⇒ Double

Convert from SEER to COP (with fan) for cooling coils per the method specified in 90.1-2013 Appendix G

Parameters:

  • seer (Double)

    seasonal energy efficiency ratio (SEER)

Returns:

  • (Double)

    Coefficient of Performance (COP)



245
246
247
248
249
250
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 245

def seer_to_cop_cooling_with_fan(seer)
  eer = -0.0182 * seer * seer + 1.1088 * seer
  cop = (eer / 3.413 + 0.12) / (1 - 0.12)

  return cop
end

#set_VAV_terminals_to_control_for_outdoor_air(model, air_loop: nil) ⇒ Object

Sets VAV reheat and VAV no reheat terminals on an air loop to control for outdoor air

Parameters:



688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 688

def set_VAV_terminals_to_control_for_outdoor_air(model, air_loop: nil)
  vav_reheats = model.getAirTerminalSingleDuctVAVReheats
  vav_no_reheats = model.getAirTerminalSingleDuctVAVNoReheats

  if !air_loop.nil?
    vav_reheats.each do |vav_reheat|
      next if vav_reheat.airLoopHVAC.get.name.to_s != air_loop.name.to_s

      vav_reheat.setControlForOutdoorAir(true)
    end
    vav_no_reheats.each do |vav_no_reheat|
      next if vav_no_reheat.airLoopHVAC.get.name.to_s != air_loop.name.to_s

      vav_no_reheat.setControlForOutdoorAir(true)
    end
  else # all terminals
    vav_reheats.each do |vav_reheat|
      vav_reheat.setControlForOutdoorAir(true)
    end
    vav_no_reheats.each do |vav_no_reheat|
      vav_no_reheat.setControlForOutdoorAir(true)
    end
  end
  return model
end

#set_Window_To_Wall_Ratio_set_name(surface:, area_fraction:, construction:) ⇒ Object

This just uses applies ‘setWindowToWallRatio’ method from the OpenStudio SDK. The only addition is that it changes the name of the window to be the surface name plus the subsurface type (always ‘fixedwindow’).



312
313
314
315
316
317
318
319
320
# File 'lib/openstudio-standards/standards/Standards.SubSurface.rb', line 312

def set_Window_To_Wall_Ratio_set_name(surface:, area_fraction:, construction:)
  surface.setWindowToWallRatio(area_fraction)
  surface.subSurfaces.sort.each do |sub_surf|
    sub_surf.setSubSurfaceType('FixedWindow')
    sub_surf.setConstruction(construction)
    new_name = surface.name.to_s + '_' + sub_surf.subSurfaceType.to_s
    sub_surf.setName(new_name)
  end
end

#space_add_daylighting_controls(space, remove_existing_controls, draw_daylight_areas_for_debugging = false) ⇒ Hash

TODO:

add a list of valid choices for template argument

TODO:

add exception for retail spaces

TODO:

add exception 2 for skylights with VT < 0.4

TODO:

add exception 3 for CZ 8 where lighting < 200W

TODO:

stop skipping non-vertical walls

TODO:

stop skipping non-horizontal roofs

TODO:

Determine the illuminance setpoint for the controls based on space type

TODO:

rotate sensor to face window (only needed for glare calcs)

Note:

This method is super complicated because of all the polygon/geometry math required. and therefore may not return perfect results. However, it works well in most tested situations. When it fails, it will log warnings/errors for users to see.

Adds daylighting controls (sidelighting and toplighting) per the template

Parameters:

  • remove_existing_controls (Bool)

    if true, will remove existing controls then add new ones

  • draw_daylight_areas_for_debugging (Bool) (defaults to: false)

    If this argument is set to true, daylight areas will be added to the model as surfaces for visual debugging. Yellow = toplighted area, Red = primary sidelighted area, Blue = secondary sidelighted area, Light Blue = floor

Returns:

  • (Hash)

    returns a hash of resulting areas (m^2). Hash keys are: ‘toplighted_area’, ‘primary_sidelighted_area’, ‘secondary_sidelighted_area’, ‘total_window_area’, ‘total_skylight_area’



806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 806

def space_add_daylighting_controls(space, remove_existing_controls, draw_daylight_areas_for_debugging = false)
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "******For #{space.name}, adding daylight controls.")

  # Check for existing daylighting controls
  # and remove if specified in the input
  existing_daylighting_controls = space.daylightingControls
  unless existing_daylighting_controls.empty?
    if remove_existing_controls
      existing_daylighting_controls.each(&:remove)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Space', "For #{space.name}, removed #{existing_daylighting_controls.size} existing daylight controls before adding new controls.")
    else
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Space', "For #{space.name}, daylight controls were already present, no additional controls added.")
      return false
    end
  end

  # Skip this space if it has no exterior windows or skylights
  ext_fen_area_m2 = 0
  space.surfaces.each do |surface|
    next unless surface.outsideBoundaryCondition == 'Outdoors'

    surface.subSurfaces.each do |sub_surface|
      next unless sub_surface.subSurfaceType == 'FixedWindow' || sub_surface.subSurfaceType == 'OperableWindow' || sub_surface.subSurfaceType == 'Skylight' || sub_surface.subSurfaceType == 'GlassDoor'

      ext_fen_area_m2 += sub_surface.netArea
    end
  end
  if ext_fen_area_m2.zero?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Space', "For #{space.name}, daylighting control not applicable because no exterior fenestration is present.")
    return false
  end

  areas = nil

  # Get the area of the space
  space_area_m2 = space.floorArea

  # Get the LPD of the space
  space_lpd_w_per_m2 = space.lightingPowerPerFloorArea

  # Get the daylighting areas
  areas = space_daylighted_areas(space, draw_daylight_areas_for_debugging)

  # Determine the type of daylighting controls required
  req_top_ctrl, req_pri_ctrl, req_sec_ctrl = space_daylighting_control_required?(space, areas)

  # Stop here if no controls are required
  if !req_top_ctrl && !req_pri_ctrl && !req_sec_ctrl
    return false
  end

  # Output the daylight control requirements
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "For #{space.name}, toplighting control required = #{req_top_ctrl}")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "For #{space.name}, primary sidelighting control required = #{req_pri_ctrl}")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "For #{space.name}, secondary sidelighting control required = #{req_sec_ctrl}")

  # Stop here if no lighting controls are required.
  # Do not put daylighting control points into the space.
  if !req_top_ctrl && !req_pri_ctrl && !req_sec_ctrl
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "For #{space.name}, no daylighting control is required.")
    return false
  end

  # Record a floor in the space for later use
  floor_surface = nil
  space.surfaces.sort.each do |surface|
    if surface.surfaceType == 'Floor'
      floor_surface = surface
      break
    end
  end

  # Find all exterior windows/skylights in the space and record their azimuths and areas
  windows = {}
  skylights = {}
  space.surfaces.sort.each do |surface|
    next unless surface.outsideBoundaryCondition == 'Outdoors' && (surface.surfaceType == 'Wall' || surface.surfaceType == 'RoofCeiling')

    # Skip non-vertical walls and non-horizontal roofs
    straight_upward = OpenStudio::Vector3d.new(0, 0, 1)
    surface_normal = surface.outwardNormal
    if surface.surfaceType == 'Wall'
      # TODO: stop skipping non-vertical walls
      unless surface_normal.z.abs < 0.001
        unless surface.subSurfaces.empty?
          OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "Cannot currently handle non-vertical walls; skipping windows on #{surface.name} in #{space.name} for daylight sensor positioning.")
          next
        end
      end
    elsif surface.surfaceType == 'RoofCeiling'
      # TODO: stop skipping non-horizontal roofs
      unless surface_normal.to_s == straight_upward.to_s
        unless surface.subSurfaces.empty?
          OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "Cannot currently handle non-horizontal roofs; skipping skylights on #{surface.name} in #{space.name} for daylight sensor positioning.")
          OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "---Surface #{surface.name} has outward normal of #{surface_normal.to_s.gsub(/\[|\]/, '|')}; up is #{straight_upward.to_s.gsub(/\[|\]/, '|')}.")
          next
        end
      end
    end

    # Find the azimuth of the facade
    facade = nil
    group = surface.planarSurfaceGroup
    if group.is_initialized
      group = group.get
      site_transformation = group.buildingTransformation
      site_vertices = site_transformation * surface.vertices
      site_outward_normal = OpenStudio.getOutwardNormal(site_vertices)
      if site_outward_normal.empty?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Space', "Could not compute outward normal for #{surface.name.get}")
        next
      end
      site_outward_normal = site_outward_normal.get
      north = OpenStudio::Vector3d.new(0.0, 1.0, 0.0)
      azimuth = if site_outward_normal.x < 0.0
                  360.0 - OpenStudio.radToDeg(OpenStudio.getAngle(site_outward_normal, north))
                else
                  OpenStudio.radToDeg(OpenStudio.getAngle(site_outward_normal, north))
                end
    else
      # The surface is not in a group; should not hit, since
      # called from Space.surfaces
      next
    end

    # TODO: modify to work for buildings in the southern hemisphere?
    if azimuth >= 315.0 || azimuth < 45.0
      facade = '4-North'
    elsif azimuth >= 45.0 && azimuth < 135.0
      facade = '3-East'
    elsif azimuth >= 135.0 && azimuth < 225.0
      facade = '1-South'
    elsif azimuth >= 225.0 && azimuth < 315.0
      facade = '2-West'
    end

    # Label the facade as "Up" if it is a skylight
    if surface_normal.to_s == straight_upward.to_s
      facade = '0-Up'
    end

    # Loop through all subsurfaces and
    surface.subSurfaces.sort.each do |sub_surface|
      next unless sub_surface.outsideBoundaryCondition == 'Outdoors' && (sub_surface.subSurfaceType == 'FixedWindow' || sub_surface.subSurfaceType == 'OperableWindow' || sub_surface.subSurfaceType == 'Skylight')

      # Find the area
      net_area_m2 = sub_surface.netArea

      # Find the head height and sill height of the window
      vertex_heights_above_floor = []
      sub_surface.vertices.each do |vertex|
        vertex_on_floorplane = floor_surface.plane.project(vertex)
        vertex_heights_above_floor << (vertex - vertex_on_floorplane).length
      end
      head_height_m = vertex_heights_above_floor.max
      # OpenStudio::logFree(OpenStudio::Info, "openstudio.standards.Space", "---head height = #{head_height_m}m, sill height = #{sill_height_m}m")

      # Log the window properties to use when creating daylight sensors
      properties = { facade: facade, area_m2: net_area_m2, handle: sub_surface.handle, head_height_m: head_height_m, name: sub_surface.name.get.to_s }
      if facade == '0-Up'
        skylights[sub_surface] = properties
      else
        windows[sub_surface] = properties
      end
    end # next sub-surface
  end # next surface

  # Determine the illuminance setpoint for the controls based on space type
  daylight_stpt_lux = 375

  # find the specific space_type properties
  space_type = space.spaceType
  if space_type.empty?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "Space #{space_type} is an unknown space type, assuming #{daylight_stpt_lux} Lux daylight setpoint")
  else
    space_type = space_type.get
    standards_building_type = if space_type.standardsBuildingType.is_initialized
                                space_type.standardsBuildingType.get
                              end
    standards_space_type = if space_type.standardsSpaceType.is_initialized
                             space_type.standardsSpaceType.get
                           end

    # use the building type (standards_building_type) and space type (standards_space_type)
    # as well as template to locate the space type data
    search_criteria = {
      'template' => template,
      'building_type' => standards_building_type,
      'space_type' => standards_space_type
    }

    data = model_find_object(standards_data['space_types'], search_criteria)
    if data.nil?
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "No data available for #{space_type.name}: #{standards_space_type} of #{standards_building_type} at #{template}, assuming a #{daylight_stpt_lux} Lux daylight setpoint!")
    else
      # Read the illuminance setpoint value
      # If 'na', daylighting is not appropriate for this space type for some reason
      daylight_stpt_lux = data['target_illuminance_setpoint']
      if daylight_stpt_lux == 'na'
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Space', "For #{space.name}: daylighting is not appropriate for #{template} #{standards_building_type} #{standards_space_type}.")
        return true
      end
      # If a setpoint is specified, use that.  Otherwise use a default.
      daylight_stpt_lux = daylight_stpt_lux.to_f
      if daylight_stpt_lux.zero?
        daylight_stpt_lux = 375
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Space', "For #{space.name}: no specific illuminance setpoint defined for #{template} #{standards_building_type} #{standards_space_type}, assuming #{daylight_stpt_lux} Lux.")
      else
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Space', "For #{space.name}: illuminance setpoint = #{daylight_stpt_lux} Lux")
      end
      # for the office prototypes where core and perimeter zoning is used,
      # there are additional assumptions about how much of the daylit area can be used.
      if standards_building_type == 'Office' && standards_space_type.include?('WholeBuilding')
        psa_nongeo_frac = data['psa_nongeometry_fraction'].to_f
        ssa_nongeo_frac = data['ssa_nongeometry_fraction'].to_f
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Space', "For #{space.name}: assuming only #{(psa_nongeo_frac * 100).round}% of the primary sidelit area is daylightable based on typical design practice.")
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Space', "For #{space.name}: assuming only #{(ssa_nongeo_frac * 100).round}% of the secondary sidelit area is daylightable based on typical design practice.")
      end
    end
  end

  # Get the zone that the space is in
  zone = space.thermalZone
  if zone.empty?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Space', "Space #{space.name} has no thermal zone")
  else
    zone = zone.get
  end

  # Sort by priority; first by facade, then by area,
  # then by name to ensure deterministic in case identical in other ways
  sorted_windows = windows.sort_by { |_window, vals| [vals[:facade], vals[:area], vals[:name]] }
  sorted_skylights = skylights.sort_by { |_skylight, vals| [vals[:facade], vals[:area], vals[:name]] }

  # Report out the sorted skylights for debugging
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "For #{space.name}, Skylights:")
  sorted_skylights.each do |sky, p|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "---#{sky.name} #{p[:facade]}, area = #{p[:area_m2].round(2)} m^2")
  end

  # Report out the sorted windows for debugging
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "For #{space.name}, Windows:")
  sorted_windows.each do |win, p|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "---#{win.name} #{p[:facade]}, area = #{p[:area_m2].round(2)} m^2")
  end

  # Determine the sensor fractions and the attached windows
  sensor_1_frac, sensor_2_frac, sensor_1_window, sensor_2_window = space_daylighting_fractions_and_windows(space,
                                                                                                           areas,
                                                                                                           sorted_windows,
                                                                                                           sorted_skylights,
                                                                                                           req_top_ctrl,
                                                                                                           req_pri_ctrl,
                                                                                                           req_sec_ctrl)

  # Further adjust the sensor controlled fraction for the three
  # office prototypes based on assumptions about geometry that is not explicitly
  # defined in the model.
  if standards_building_type == 'Office' && standards_space_type.include?('WholeBuilding')
    sensor_1_frac *= psa_nongeo_frac unless psa_nongeo_frac.nil?
    sensor_2_frac *= ssa_nongeo_frac unless ssa_nongeo_frac.nil?
  end

  # Place the sensors and set control fractions
  # get the zone that the space is in
  zone = space.thermalZone
  if zone.empty?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Space', "Space #{space.name}, cannot determine daylighted areas.")
    return false
  else
    zone = space.thermalZone.get
  end

  # Ensure that total controlled fraction
  # is never set above 1 (100%)
  sensor_1_frac = sensor_1_frac.round(3)
  sensor_2_frac = sensor_2_frac.round(3)
  if sensor_1_frac >= 1.0
    sensor_1_frac = 1.0 - 0.001
  end
  if sensor_1_frac + sensor_2_frac >= 1.0
    # Lower sensor_2_frac so that the total
    # is just slightly lower than 1.0
    sensor_2_frac = 1.0 - sensor_1_frac - 0.001
  end

  # Sensors
  if sensor_1_frac > 0.0
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Space', "For #{space.name}: sensor 1 controls #{(sensor_1_frac * 100).round}% of the zone lighting.")
  end
  if sensor_2_frac > 0.0
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Space', "For #{space.name}: sensor 2 controls #{(sensor_2_frac * 100).round}% of the zone lighting.")
  end

  # First sensor
  if sensor_1_window
    # OpenStudio::logFree(OpenStudio::Info, "openstudio.standards.Space", "For #{self.name}, calculating daylighted areas.")
    # runner.registerInfo("Daylight sensor 1 inside of #{sensor_1_frac.name}")
    sensor_1 = OpenStudio::Model::DaylightingControl.new(space.model)
    sensor_1.setName("#{space.name} Daylt Sensor 1")
    sensor_1.setSpace(space)
    sensor_1.setIlluminanceSetpoint(daylight_stpt_lux)
    sensor_1.setLightingControlType('Stepped')
    sensor_1.setNumberofSteppedControlSteps(3) # all sensors 3-step per design
    sensor_1.setMinimumInputPowerFractionforContinuousDimmingControl(0.3)
    sensor_1.setMinimumLightOutputFractionforContinuousDimmingControl(0.2)
    sensor_1.setProbabilityLightingwillbeResetWhenNeededinManualSteppedControl(1.0)
    sensor_1.setMaximumAllowableDiscomfortGlareIndex(22.0)

    # Place sensor depending on skylight or window
    sensor_vertex = nil
    if sensor_1_window[1][:facade] == '0-Up'
      sub_surface = sensor_1_window[0]
      outward_normal = sub_surface.outwardNormal
      centroid = OpenStudio.getCentroid(sub_surface.vertices).get
      ht_above_flr = OpenStudio.convert(2.5, 'ft', 'm').get
      outward_normal.setLength(sensor_1_window[1][:head_height_m] - ht_above_flr)
      sensor_vertex = centroid + outward_normal.reverseVector
    else
      sub_surface = sensor_1_window[0]
      window_outward_normal = sub_surface.outwardNormal
      window_centroid = OpenStudio.getCentroid(sub_surface.vertices).get
      window_outward_normal.setLength(sensor_1_window[1][:head_height_m] * 0.66)
      vertex = window_centroid + window_outward_normal.reverseVector
      vertex_on_floorplane = floor_surface.plane.project(vertex)
      floor_outward_normal = floor_surface.outwardNormal
      floor_outward_normal.setLength(OpenStudio.convert(2.5, 'ft', 'm').get)
      sensor_vertex = vertex_on_floorplane + floor_outward_normal.reverseVector
    end
    sensor_1.setPosition(sensor_vertex)

    # TODO: rotate sensor to face window (only needed for glare calcs)
    zone.setPrimaryDaylightingControl(sensor_1)
    zone.setFractionofZoneControlledbyPrimaryDaylightingControl(sensor_1_frac)
  end

  # Second sensor
  if sensor_2_window
    # OpenStudio::logFree(OpenStudio::Info, "openstudio.standards.Space", "For #{self.name}, calculating daylighted areas.")
    # runner.registerInfo("Daylight sensor 2 inside of #{sensor_2_frac.name}")
    sensor_2 = OpenStudio::Model::DaylightingControl.new(space.model)
    sensor_2.setName("#{space.name} Daylt Sensor 2")
    sensor_2.setSpace(space)
    sensor_2.setIlluminanceSetpoint(daylight_stpt_lux)
    sensor_2.setLightingControlType('Stepped')
    sensor_2.setNumberofSteppedControlSteps(3) # all sensors 3-step per design
    sensor_2.setMinimumInputPowerFractionforContinuousDimmingControl(0.3)
    sensor_2.setMinimumLightOutputFractionforContinuousDimmingControl(0.2)
    sensor_2.setProbabilityLightingwillbeResetWhenNeededinManualSteppedControl(1.0)
    sensor_2.setMaximumAllowableDiscomfortGlareIndex(22.0)

    # Place sensor depending on skylight or window
    sensor_vertex = nil
    if sensor_2_window[1][:facade] == '0-Up'
      sub_surface = sensor_2_window[0]
      outward_normal = sub_surface.outwardNormal
      centroid = OpenStudio.getCentroid(sub_surface.vertices).get
      ht_above_flr = OpenStudio.convert(2.5, 'ft', 'm').get
      outward_normal.setLength(sensor_2_window[1][:head_height_m] - ht_above_flr)
      sensor_vertex = centroid + outward_normal.reverseVector
    else
      sub_surface = sensor_2_window[0]
      window_outward_normal = sub_surface.outwardNormal
      window_centroid = OpenStudio.getCentroid(sub_surface.vertices).get
      window_outward_normal.setLength(sensor_2_window[1][:head_height_m] * 1.33)
      vertex = window_centroid + window_outward_normal.reverseVector
      vertex_on_floorplane = floor_surface.plane.project(vertex)
      floor_outward_normal = floor_surface.outwardNormal
      floor_outward_normal.setLength(OpenStudio.convert(2.5, 'ft', 'm').get)
      sensor_vertex = vertex_on_floorplane + floor_outward_normal.reverseVector
    end
    sensor_2.setPosition(sensor_vertex)

    # TODO: rotate sensor to face window (only needed for glare calcs)
    zone.setSecondaryDaylightingControl(sensor_2)
    zone.setFractionofZoneControlledbySecondaryDaylightingControl(sensor_2_frac)
  end

  return true
end

#space_apply_infiltration_rate(space) ⇒ Double

TODO:

handle doors and vestibules

Set the infiltration rate for this space to include the impact of air leakage requirements in the standard.

Returns:

  • (Double)

    true if successful, false if not



1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1228

def space_apply_infiltration_rate(space)
  # data center keeps positive pressure all the time, so no infiltration
  if space.spaceType.is_initialized && space.spaceType.get.standardsSpaceType.is_initialized
    std_space_type = space.spaceType.get.standardsSpaceType.get
    if std_space_type.downcase.include?('data center') || std_space_type.downcase.include?('datacenter')
      return true
    end

    if space.spaceType.get.standardsBuildingType.is_initialized
      std_bldg_type = space.spaceType.get.standardsBuildingType.get
      if std_bldg_type.downcase.include?('datacenter') && std_space_type.downcase.include?('computerroom')
        return true
      end
    end
  end

  # Determine the total building baseline infiltration rate in cfm per ft2 of exterior above grade wall area at 75 Pa
  # exterior above grade envelope area includes any surface with boundary condition 'Outdoors' in OpenStudio/EnergyPlus
  basic_infil_rate_cfm_per_ft2 = space_infiltration_rate_75_pa(space)

  # Do nothing if no infiltration
  return true if basic_infil_rate_cfm_per_ft2.zero?

  # Conversion factor
  # 1 m^3/s*m^2 = 196.85 cfm/ft2
  conv_fact = 196.85

  # Adjust the infiltration rate to the average pressure for the prototype buildings.
  adj_infil_rate_cfm_per_ft2 = adjust_infiltration_to_prototype_building_conditions(basic_infil_rate_cfm_per_ft2)
  adj_infil_rate_m3_per_s_per_m2 = adj_infil_rate_cfm_per_ft2 / conv_fact
  # Get the exterior wall area
  exterior_wall_and_window_area_m2 = space_exterior_wall_and_window_area(space)

  # Don't create an object if there is no exterior wall area
  if exterior_wall_and_window_area_m2 <= 0.0
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Space', "For #{space.name}, no exterior wall area was found, no infiltration will be added.")
    return true
  end
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Space', "For #{space.name}, set infiltration rate to #{adj_infil_rate_cfm_per_ft2.round(3)} cfm/ft2 exterior wall area (aka #{basic_infil_rate_cfm_per_ft2} cfm/ft2 @75Pa).")

  # Calculate the total infiltration, assuming
  # that it only occurs through exterior walls
  tot_infil_m3_per_s = adj_infil_rate_m3_per_s_per_m2 * exterior_wall_and_window_area_m2

  # Now spread the total infiltration rate over all
  # exterior surface areas (for the E+ input field)
  all_ext_infil_m3_per_s_per_m2 = tot_infil_m3_per_s / space.exteriorArea

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "For #{space.name}, adj infil = #{all_ext_infil_m3_per_s_per_m2.round(8)} m^3/s*m^2.")

  # Get any infiltration schedule already assigned to this space or its space type
  # If not, the always on schedule will be applied.
  infil_sch = nil
  unless space.spaceInfiltrationDesignFlowRates.empty?
    old_infil = space.spaceInfiltrationDesignFlowRates[0]
    if old_infil.schedule.is_initialized
      infil_sch = old_infil.schedule.get
    end
  end

  if infil_sch.nil? && space.spaceType.is_initialized
    space_type = space.spaceType.get
    unless space_type.spaceInfiltrationDesignFlowRates.empty?
      old_infil = space_type.spaceInfiltrationDesignFlowRates[0]
      if old_infil.schedule.is_initialized
        infil_sch = old_infil.schedule.get
      end
    end
  end

  if infil_sch.nil?
    infil_sch = space.model.alwaysOnDiscreteSchedule
  end

  # Create an infiltration rate object for this space
  infiltration = OpenStudio::Model::SpaceInfiltrationDesignFlowRate.new(space.model)
  infiltration.setName("#{space.name} Infiltration")
  # infiltration.setFlowperExteriorWallArea(adj_infil_rate_m3_per_s_per_m2)
  infiltration.setFlowperExteriorSurfaceArea(all_ext_infil_m3_per_s_per_m2.round(13))
  infiltration.setSchedule(infil_sch)
  infiltration.setConstantTermCoefficient(0.0)
  infiltration.setTemperatureTermCoefficient 0.0
  infiltration.setVelocityTermCoefficient(0.224)
  infiltration.setVelocitySquaredTermCoefficient(0.0)

  infiltration.setSpace(space)

  return true
end

#space_conditioning_category(space, climate_zone) ⇒ String

TODO:

add logic to detect indirectly-conditioned spaces

Determines whether the space is conditioned per 90.1, which is based on heating and cooling loads.

Parameters:

  • climate_zone (String)

    climate zone

Returns:

  • (String)

    NonResConditioned, ResConditioned, Semiheated, Unconditioned



1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1489

def space_conditioning_category(space, climate_zone)
  # Get the zone this space is inside
  zone = space.thermalZone

  # Assume unconditioned if not assigned to a zone
  if zone.empty?
    return 'Unconditioned'
  end

  # Get the category from the zone
  cond_cat = zone.get.conditioning_category(climate_zone)

  return cond_cat
end

#space_cooled?(space) ⇒ Bool

Determines cooling status. If the space’s zone has a thermostat with a minimum cooling setpoint above 33C (91F), counts as cooled.

Returns:

  • (Bool)

    true if cooled, false if not

Author:

  • Andrew Parker, Julien Marrec



1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1531

def space_cooled?(space)
  # Get the zone this space is inside
  zone = space.thermalZone

  # Assume uncooled if not assigned to a zone
  if zone.empty?
    return false
  end

  # Get the category from the zone
  cld = thermal_zone_cooled?(zone.get)

  return cld
end

#space_daylighted_area_window_width(space) ⇒ String

Determines the method used to extend the daylighted area horizontally next to a window. If the method is ‘fixed’, 2 ft is added to the width of each window. If the method is ‘proportional’, a distance equal to half of the head height of the window is added. If the method is ‘none’, no additional width is added. Default is none.

Returns:

  • (String)

    returns ‘fixed’ or ‘proportional’



551
552
553
554
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 551

def space_daylighted_area_window_width(space)
  method = 'none'
  return method
end

#space_daylighted_areas(space, draw_daylight_areas_for_debugging = false) ⇒ Hash

TODO:

add a list of valid choices for template argument

Note:

This method is super complicated because of all the polygon/geometry math required. and therefore may not return perfect results. However, it works well in most tested situations. When it fails, it will log warnings/errors for users to see.

Returns values for the different types of daylighted areas in the space. Definitions for each type of area follow the respective template. TODO stop skipping non-vertical walls

Parameters:

  • draw_daylight_areas_for_debugging (Bool) (defaults to: false)

    If this argument is set to true, daylight areas will be added to the model as surfaces for visual debugging. Yellow = toplighted area, Red = primary sidelighted area, Blue = secondary sidelighted area, Light Blue = floor

Returns:

  • (Hash)

    returns a hash of resulting areas (m^2). Hash keys are: ‘toplighted_area’, ‘primary_sidelighted_area’, ‘secondary_sidelighted_area’, ‘total_window_area’, ‘total_skylight_area’



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 19

def space_daylighted_areas(space, draw_daylight_areas_for_debugging = false)
  ### Begin the actual daylight area calculations ###

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "For #{space.name}, calculating daylighted areas.")

  result = { 'toplighted_area' => 0.0,
             'primary_sidelighted_area' => 0.0,
             'secondary_sidelighted_area' => 0.0,
             'total_window_area' => 0.0,
             'total_skylight_area' => 0.0 }

  total_window_area = 0
  total_skylight_area = 0

  # Make rendering colors to help debug visually
  if draw_daylight_areas_for_debugging
    # Yellow
    toplit_construction = OpenStudio::Model::Construction.new(space.model)
    toplit_color = OpenStudio::Model::RenderingColor.new(space.model)
    toplit_color.setRenderingRedValue(255)
    toplit_color.setRenderingGreenValue(255)
    toplit_color.setRenderingBlueValue(0)
    toplit_construction.setRenderingColor(toplit_color)

    # Red
    pri_sidelit_construction = OpenStudio::Model::Construction.new(space.model)
    pri_sidelit_color = OpenStudio::Model::RenderingColor.new(space.model)
    pri_sidelit_color.setRenderingRedValue(255)
    pri_sidelit_color.setRenderingGreenValue(0)
    pri_sidelit_color.setRenderingBlueValue(0)
    pri_sidelit_construction.setRenderingColor(pri_sidelit_color)

    # Blue
    sec_sidelit_construction = OpenStudio::Model::Construction.new(space.model)
    sec_sidelit_color = OpenStudio::Model::RenderingColor.new(space.model)
    sec_sidelit_color.setRenderingRedValue(0)
    sec_sidelit_color.setRenderingGreenValue(0)
    sec_sidelit_color.setRenderingBlueValue(255)
    sec_sidelit_construction.setRenderingColor(sec_sidelit_color)

    # Light Blue
    flr_construction = OpenStudio::Model::Construction.new(space.model)
    flr_color = OpenStudio::Model::RenderingColor.new(space.model)
    flr_color.setRenderingRedValue(0)
    flr_color.setRenderingGreenValue(255)
    flr_color.setRenderingBlueValue(255)
    flr_construction.setRenderingColor(flr_color)
  end

  # Move the polygon up slightly for viewability in sketchup
  up_translation_flr = OpenStudio.createTranslation(OpenStudio::Vector3d.new(0, 0, 0.05))
  up_translation_top = OpenStudio.createTranslation(OpenStudio::Vector3d.new(0, 0, 0.1))
  up_translation_pri = OpenStudio.createTranslation(OpenStudio::Vector3d.new(0, 0, 0.1))
  up_translation_sec = OpenStudio.createTranslation(OpenStudio::Vector3d.new(0, 0, 0.1))

  # Get the space's surface group's transformation
  @space_transformation = space.transformation

  # Record a floor in the space for later use
  floor_surface = nil

  # Record all floor polygons
  floor_polygons = []
  floor_z = 0.0
  space.surfaces.sort.each do |surface|
    if surface.surfaceType == 'Floor'
      floor_surface = surface
      floor_z = surface.vertices[0].z
      # floor_polygons << surface.vertices
      # Hard-set the z for the floor to zero
      new_floor_polygon = []
      surface.vertices.each do |vertex|
        new_floor_polygon << OpenStudio::Point3d.new(vertex.x, vertex.y, 0.0)
      end
      floor_polygons << new_floor_polygon
    end
  end

  # Make sure there is one floor surface
  if floor_surface.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "Could not find a floor in space #{space.name}, cannot determine daylighted areas.")
    return result
  end

  # Make a set of vertices representing each subsurfaces sidelighteding area
  # and fold them all down onto the floor of the self.
  toplit_polygons = []
  pri_sidelit_polygons = []
  sec_sidelit_polygons = []
  space.surfaces.sort.each do |surface|
    if surface.outsideBoundaryCondition == 'Outdoors' && surface.surfaceType == 'Wall'

      # TODO: stop skipping non-vertical walls
      surface_normal = surface.outwardNormal
      surface_normal_z = surface_normal.z
      unless surface_normal_z.abs < 0.001
        unless surface.subSurfaces.empty?
          OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "Cannot currently handle non-vertical walls; skipping windows on #{surface.name} in #{space.name}.")
          next
        end
      end

      surface.subSurfaces.sort.each do |sub_surface|
        next unless sub_surface.outsideBoundaryCondition == 'Outdoors' && (sub_surface.subSurfaceType == 'FixedWindow' || sub_surface.subSurfaceType == 'OperableWindow' || sub_surface.subSurfaceType == 'GlassDoor')

        # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.Space", "***#{sub_surface.name}***"
        total_window_area += sub_surface.netArea

        # Find the head height and sill height of the window
        vertex_heights_above_floor = []
        sub_surface.vertices.each do |vertex|
          vertex_on_floorplane = floor_surface.plane.project(vertex)
          vertex_heights_above_floor << (vertex - vertex_on_floorplane).length
        end
        sill_height_m = vertex_heights_above_floor.min
        head_height_m = vertex_heights_above_floor.max
        # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.Space", "head height = #{head_height_m.round(2)}m, sill height = #{sill_height_m.round(2)}m")

        # Find the width of the window
        rot_origin = nil
        unless sub_surface.vertices.size == 4
          OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "A sub-surface in space #{space.name} has other than 4 vertices; this sub-surface will not be included in the daylighted area calculation.")
          next
        end
        prev_vertex_on_floorplane = nil
        max_window_width_m = 0
        sub_surface.vertices.each do |vertex|
          vertex_on_floorplane = floor_surface.plane.project(vertex)
          unless prev_vertex_on_floorplane
            prev_vertex_on_floorplane = vertex_on_floorplane
            next
          end
          width_m = (prev_vertex_on_floorplane - vertex_on_floorplane).length
          if width_m > max_window_width_m
            max_window_width_m = width_m
            rot_origin = vertex_on_floorplane
          end
        end

        # Determine the extra width to add to the sidelighted area
        extra_width_m = 0
        width_method = space_daylighted_area_window_width(space)
        if width_method == 'proportional'
          extra_width_m = head_height_m / 2
        elsif width_method == 'fixed'
          extra_width_m = OpenStudio.convert(2, 'ft', 'm').get
        end
        # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.Space", "Adding #{extra_width_m.round(2)}m to the width for the sidelighted area.")

        # Align the vertices with face coordinate system
        face_transform = OpenStudio::Transformation.alignFace(sub_surface.vertices)
        aligned_vertices = face_transform.inverse * sub_surface.vertices

        # Find the min and max x values
        min_x_val = 99_999
        max_x_val = -99_999
        aligned_vertices.each do |vertex|
          # Min x value
          if vertex.x < min_x_val
            min_x_val = vertex.x
          end
          # Max x value
          if vertex.x > max_x_val
            max_x_val = vertex.x
          end
        end
        # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.Space", "min_x_val = #{min_x_val.round(2)}, max_x_val = #{max_x_val.round(2)}")

        # Create polygons that are adjusted
        # to expand from the window shape to the sidelighteded areas.
        pri_sidelit_sub_polygon = []
        sec_sidelit_sub_polygon = []
        aligned_vertices.each do |vertex|
          # Primary sidelighted area
          # Move the x vertices outward by the specified amount.
          if (vertex.x - min_x_val).abs < 0.01
            new_x = vertex.x - extra_width_m
          elsif (vertex.x - max_x_val).abs < 0.01
            new_x = vertex.x + extra_width_m
          else
            new_x = 99.9
            OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "A window in space #{space.name} is non-rectangular; this sub-surface will not be included in the primary daylighted area calculation. #{vertex.x} != #{min_x_val} or #{max_x_val}")
          end

          # Zero-out the y for the bottom edge because the
          # sidelighteding area extends down to the floor.
          new_y = if vertex.y.zero?
                    vertex.y - sill_height_m
                  else
                    vertex.y
                  end

          # Set z = 0 so that intersection works.
          new_z = 0.0

          # Make the new vertex
          new_vertex = OpenStudio::Point3d.new(new_x, new_y, new_z)
          pri_sidelit_sub_polygon << new_vertex
          # OpenStudio::logFree(OpenStudio::Info, "openstudio.standards.Space", "#{vertex.x.round(2)}, #{vertex.y.round(2)}, #{vertex.z.round(2)} to #{new_vertex.x.round(2)}, #{new_vertex.y.round(2)}, #{new_vertex.z.round(2)}")

          # Secondary sidelighted area
          # Move the x vertices outward by the specified amount.
          if (vertex.x - min_x_val).abs < 0.01
            new_x = vertex.x - extra_width_m
          elsif (vertex.x - max_x_val).abs < 0.01
            new_x = vertex.x + extra_width_m
          else
            new_x = 99.9
            OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "A window in space #{space.name} is non-rectangular; this sub-surface will not be included in the secondary daylighted area calculation.")
          end

          # Add the head height of the window to all points
          # sidelighteding area extends down to the floor.
          new_y = if vertex.y.zero?
                    vertex.y - sill_height_m + head_height_m
                  else
                    vertex.y + head_height_m
                  end

          # Set z = 0 so that intersection works.
          new_z = 0.0

          # Make the new vertex
          new_vertex = OpenStudio::Point3d.new(new_x, new_y, new_z)
          sec_sidelit_sub_polygon << new_vertex
        end

        # Realign the vertices with space coordinate system
        pri_sidelit_sub_polygon = face_transform * pri_sidelit_sub_polygon
        sec_sidelit_sub_polygon = face_transform * sec_sidelit_sub_polygon

        # Rotate the sidelighteded areas down onto the floor
        down_vector = OpenStudio::Vector3d.new(0, 0, -1)
        outward_normal_vector = sub_surface.outwardNormal
        rot_vector = down_vector.cross(outward_normal_vector)
        ninety_deg_in_rad = OpenStudio.degToRad(90) # TODO: change
        new_rotation = OpenStudio.createRotation(rot_origin, rot_vector, ninety_deg_in_rad)
        pri_sidelit_sub_polygon = new_rotation * pri_sidelit_sub_polygon
        sec_sidelit_sub_polygon = new_rotation * sec_sidelit_sub_polygon

        # Put the polygon vertices into counterclockwise order
        pri_sidelit_sub_polygon = pri_sidelit_sub_polygon.reverse
        sec_sidelit_sub_polygon = sec_sidelit_sub_polygon.reverse

        # Add these polygons to the list
        pri_sidelit_polygons << pri_sidelit_sub_polygon
        sec_sidelit_polygons << sec_sidelit_sub_polygon
      end # Next subsurface
    elsif surface.outsideBoundaryCondition == 'Outdoors' && surface.surfaceType == 'RoofCeiling'

      # TODO: stop skipping non-horizontal roofs
      surface_normal = surface.outwardNormal
      straight_upward = OpenStudio::Vector3d.new(0, 0, 1)
      unless surface_normal.to_s == straight_upward.to_s
        unless surface.subSurfaces.empty?
          OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "Cannot currently handle non-horizontal roofs; skipping skylights on #{surface.name} in #{space.name}.")
          OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "---Surface #{surface.name} has outward normal of #{surface_normal.to_s.gsub(/\[|\]/, '|')}; up is #{straight_upward.to_s.gsub(/\[|\]/, '|')}.")
          next
        end
      end

      surface.subSurfaces.sort.each do |sub_surface|
        next unless sub_surface.outsideBoundaryCondition == 'Outdoors' && sub_surface.subSurfaceType == 'Skylight'

        # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.Space", "***#{sub_surface.name}***")
        total_skylight_area += sub_surface.netArea

        # Project the skylight onto the floor plane
        polygon_on_floor = []
        vertex_heights_above_floor = []
        sub_surface.vertices.each do |vertex|
          vertex_on_floorplane = floor_surface.plane.project(vertex)
          vertex_heights_above_floor << (vertex - vertex_on_floorplane).length
          polygon_on_floor << vertex_on_floorplane
        end

        # Determine the ceiling height.
        # Assumes skylight is flush with ceiling.
        ceiling_height_m = vertex_heights_above_floor.max

        # Align the vertices with face coordinate system
        face_transform = OpenStudio::Transformation.alignFace(polygon_on_floor)
        aligned_vertices = face_transform.inverse * polygon_on_floor

        # Find the min and max x and y values
        min_x_val = 99_999
        max_x_val = -99_999
        min_y_val = 99_999
        max_y_val = -99_999
        aligned_vertices.each do |vertex|
          # Min x value
          if vertex.x < min_x_val
            min_x_val = vertex.x
          end
          # Max x value
          if vertex.x > max_x_val
            max_x_val = vertex.x
          end
          # Min y value
          if vertex.y < min_y_val
            min_y_val = vertex.y
          end
          # Max y value
          if vertex.y > max_x_val
            max_y_val = vertex.y
          end
        end

        # Figure out how much to expand the window
        additional_extent_m = 0.7 * ceiling_height_m

        # Create polygons that are adjusted
        # to expand from the window shape to the sidelighteded areas.
        toplit_sub_polygon = []
        aligned_vertices.each do |vertex|
          # Move the x vertices outward by the specified amount.
          if vertex.x == min_x_val
            new_x = vertex.x - additional_extent_m
          elsif vertex.x == max_x_val
            new_x = vertex.x + additional_extent_m
          else
            new_x = 99.9
            OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "A skylight in space #{space.name} is non-rectangular; this sub-surface will not be included in the daylighted area calculation.")
          end

          # Move the y vertices outward by the specified amount.
          if vertex.y == min_y_val
            new_y = vertex.y - additional_extent_m
          elsif vertex.y == max_y_val
            new_y = vertex.y + additional_extent_m
          else
            new_y = 99.9
            OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "A skylight in space #{space.name} is non-rectangular; this sub-surface will not be included in the daylighted area calculation.")
          end

          # Set z = 0 so that intersection works.
          new_z = 0.0

          # Make the new vertex
          new_vertex = OpenStudio::Point3d.new(new_x, new_y, new_z)
          toplit_sub_polygon << new_vertex
        end

        # Realign the vertices with space coordinate system
        toplit_sub_polygon = face_transform * toplit_sub_polygon

        # Put the polygon vertices into counterclockwise order
        toplit_sub_polygon = toplit_sub_polygon.reverse

        # Add these polygons to the list
        toplit_polygons << toplit_sub_polygon
      end # Next subsurface

    end # End if outdoor wall or roofceiling
  end # Next surface

  # Set z=0 for all the polygons so that intersection will work
  toplit_polygons = space_polygons_set_z(space, toplit_polygons, 0.0)
  pri_sidelit_polygons = space_polygons_set_z(space, pri_sidelit_polygons, 0.0)
  sec_sidelit_polygons = space_polygons_set_z(space, sec_sidelit_polygons, 0.0)

  # Check the initial polygons
  space_check_z_zero(space, floor_polygons, 'floor_polygons')
  space_check_z_zero(space, toplit_polygons, 'toplit_polygons')
  space_check_z_zero(space, pri_sidelit_polygons, 'pri_sidelit_polygons')
  space_check_z_zero(space, sec_sidelit_polygons, 'sec_sidelit_polygons')

  # Join, then subtract
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', '***Joining polygons***')

  # Join toplighted polygons into a single set
  combined_toplit_polygons = space_join_polygons(space, toplit_polygons, 0.01, 'toplit_polygons')

  # Join primary sidelighted polygons into a single set
  combined_pri_sidelit_polygons = space_join_polygons(space, pri_sidelit_polygons, 0.01, 'pri_sidelit_polygons')

  # Join secondary sidelighted polygons into a single set
  combined_sec_sidelit_polygons = space_join_polygons(space, sec_sidelit_polygons, 0.01, 'sec_sidelit_polygons')

  # Join floor polygons into a single set
  combined_floor_polygons = space_join_polygons(space, floor_polygons, 0.01, 'floor_polygons')

  # Check the joined polygons
  space_check_z_zero(space, combined_floor_polygons, 'combined_floor_polygons')
  space_check_z_zero(space, combined_toplit_polygons, 'combined_toplit_polygons')
  space_check_z_zero(space, combined_pri_sidelit_polygons, 'combined_pri_sidelit_polygons')
  space_check_z_zero(space, combined_sec_sidelit_polygons, 'combined_sec_sidelit_polygons')

  # Make a new surface for each of the resulting polygons to visually inspect it
  # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.Space", "***Making Surfaces to view in SketchUp***")

  # combined_toplit_polygons.each do |polygon|
  # dummy_space = OpenStudio::Model::Space.new(model)
  # polygon = up_translation_top * polygon
  # daylt_surf = OpenStudio::Model::Surface.new(polygon, model)
  # daylt_surf.setConstruction(toplit_construction)
  # daylt_surf.setSpace(dummy_space)
  # daylt_surf.setName("Top")
  # end

  # combined_pri_sidelit_polygons.each do |polygon|
  # dummy_space = OpenStudio::Model::Space.new(model)
  # polygon = up_translation_pri * polygon
  # daylt_surf = OpenStudio::Model::Surface.new(polygon, model)
  # daylt_surf.setConstruction(pri_sidelit_construction)
  # daylt_surf.setSpace(dummy_space)
  # daylt_surf.setName("Pri")
  # end

  # combined_sec_sidelit_polygons.each do |polygon|
  # dummy_space = OpenStudio::Model::Space.new(model)
  # polygon = up_translation_sec * polygon
  # daylt_surf = OpenStudio::Model::Surface.new(polygon, model)
  # daylt_surf.setConstruction(sec_sidelit_construction)
  # daylt_surf.setSpace(dummy_space)
  # daylt_surf.setName("Sec")
  # end

  # combined_floor_polygons.each do |polygon|
  # dummy_space = OpenStudio::Model::Space.new(model)
  # polygon = up_translation_flr * polygon
  # daylt_surf = OpenStudio::Model::Surface.new(polygon, model)
  # daylt_surf.setConstruction(flr_construction)
  # daylt_surf.setSpace(dummy_space)
  # daylt_surf.setName("Flr")
  # end

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', '***Subtracting overlapping areas***')

  # Subtract lower-priority daylighting areas from higher priority ones
  pri_minus_top_polygons = space_a_polygons_minus_b_polygons(space, combined_pri_sidelit_polygons, combined_toplit_polygons, 'combined_pri_sidelit_polygons', 'combined_toplit_polygons')

  sec_minus_top_polygons = space_a_polygons_minus_b_polygons(space, combined_sec_sidelit_polygons, combined_toplit_polygons, 'combined_sec_sidelit_polygons', 'combined_toplit_polygons')

  sec_minus_top_minus_pri_polygons = space_a_polygons_minus_b_polygons(space, sec_minus_top_polygons, combined_pri_sidelit_polygons, 'sec_minus_top_polygons', 'combined_pri_sidelit_polygons')

  # Check the subtracted polygons
  space_check_z_zero(space, pri_minus_top_polygons, 'pri_minus_top_polygons')
  space_check_z_zero(space, sec_minus_top_polygons, 'sec_minus_top_polygons')
  space_check_z_zero(space, sec_minus_top_minus_pri_polygons, 'sec_minus_top_minus_pri_polygons')

  # Make a new surface for each of the resulting polygons to visually inspect it.
  # First reset the z so the surfaces show up on the correct plane.
  if draw_daylight_areas_for_debugging

    combined_toplit_polygons_at_floor = space_polygons_set_z(space, combined_toplit_polygons, floor_z)
    pri_minus_top_polygons_at_floor = space_polygons_set_z(space, pri_minus_top_polygons, floor_z)
    sec_minus_top_minus_pri_polygons_at_floor = space_polygons_set_z(space, sec_minus_top_minus_pri_polygons, floor_z)
    combined_floor_polygons_at_floor = space_polygons_set_z(space, combined_floor_polygons, floor_z)

    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', '***Making Surfaces to view in SketchUp***')
    dummy_space = OpenStudio::Model::Space.new(space.model)

    combined_toplit_polygons_at_floor.each do |polygon|
      polygon = up_translation_top * polygon
      polygon = @space_transformation * polygon
      daylt_surf = OpenStudio::Model::Surface.new(polygon, space.model)
      daylt_surf.setConstruction(toplit_construction)
      daylt_surf.setSpace(dummy_space)
      daylt_surf.setName('Top')
    end

    pri_minus_top_polygons_at_floor.each do |polygon|
      polygon = up_translation_pri * polygon
      polygon = @space_transformation * polygon
      daylt_surf = OpenStudio::Model::Surface.new(polygon, space.model)
      daylt_surf.setConstruction(pri_sidelit_construction)
      daylt_surf.setSpace(dummy_space)
      daylt_surf.setName('Pri')
    end

    sec_minus_top_minus_pri_polygons_at_floor.each do |polygon|
      polygon = up_translation_sec * polygon
      polygon = @space_transformation * polygon
      daylt_surf = OpenStudio::Model::Surface.new(polygon, space.model)
      daylt_surf.setConstruction(sec_sidelit_construction)
      daylt_surf.setSpace(dummy_space)
      daylt_surf.setName('Sec')
    end

    combined_floor_polygons_at_floor.each do |polygon|
      polygon = up_translation_flr * polygon
      polygon = @space_transformation * polygon
      daylt_surf = OpenStudio::Model::Surface.new(polygon, space.model)
      daylt_surf.setConstruction(flr_construction)
      daylt_surf.setSpace(dummy_space)
      daylt_surf.setName('Flr')
    end
  end

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', '***Calculating Daylighted Areas***')

  # Get the total floor area
  total_floor_area_m2 = space_total_area_of_polygons(space, combined_floor_polygons)
  total_floor_area_ft2 = OpenStudio.convert(total_floor_area_m2, 'm^2', 'ft^2').get
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "total_floor_area_ft2 = #{total_floor_area_ft2.round(1)}")

  # Toplighted area
  toplighted_area_m2 = space_area_a_polygons_overlap_b_polygons(space, combined_toplit_polygons, combined_floor_polygons, 'combined_toplit_polygons', 'combined_floor_polygons')

  # Primary sidelighted area
  primary_sidelighted_area_m2 = space_area_a_polygons_overlap_b_polygons(space, pri_minus_top_polygons, combined_floor_polygons, 'pri_minus_top_polygons', 'combined_floor_polygons')

  # Secondary sidelighted area
  secondary_sidelighted_area_m2 = space_area_a_polygons_overlap_b_polygons(space, sec_minus_top_minus_pri_polygons, combined_floor_polygons, 'sec_minus_top_minus_pri_polygons', 'combined_floor_polygons')

  # Convert to IP for displaying
  toplighted_area_ft2 = OpenStudio.convert(toplighted_area_m2, 'm^2', 'ft^2').get
  primary_sidelighted_area_ft2 = OpenStudio.convert(primary_sidelighted_area_m2, 'm^2', 'ft^2').get
  secondary_sidelighted_area_ft2 = OpenStudio.convert(secondary_sidelighted_area_m2, 'm^2', 'ft^2').get

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "toplighted_area_ft2 = #{toplighted_area_ft2.round(1)}")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "primary_sidelighted_area_ft2 = #{primary_sidelighted_area_ft2.round(1)}")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "secondary_sidelighted_area_ft2 = #{secondary_sidelighted_area_ft2.round(1)}")

  result['toplighted_area'] = toplighted_area_m2
  result['primary_sidelighted_area'] = primary_sidelighted_area_m2
  result['secondary_sidelighted_area'] = secondary_sidelighted_area_m2
  result['total_window_area'] = total_window_area
  result['total_skylight_area'] = total_skylight_area

  return result
end

#space_daylighting_control_required?(space, areas) ⇒ Array<Bool>

Determine if the space requires daylighting controls for toplighting, primary sidelighting, and secondary sidelighting. Defaults to false for all types.

Parameters:

Returns:

  • (Array<Bool>)

    req_top_ctrl, req_pri_ctrl, req_sec_ctrl



1194
1195
1196
1197
1198
1199
1200
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1194

def space_daylighting_control_required?(space, areas)
  req_top_ctrl = false
  req_pri_ctrl = false
  req_sec_ctrl = false

  return [req_top_ctrl, req_pri_ctrl, req_sec_ctrl]
end

#space_daylighting_fractions_and_windows(space, areas, sorted_windows, sorted_skylights, req_top_ctrl, req_pri_ctrl, req_sec_ctrl) ⇒ Object

Determine the fraction controlled by each sensor and which window each sensor should go near.

Parameters:

  • space (OpenStudio::Model::Space)

    the space with the daylighting

  • sorted_windows (Hash)

    a hash of windows, sorted by priority

  • sorted_skylights (Hash)

    a hash of skylights, sorted by priority



1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1208

def space_daylighting_fractions_and_windows(space,
                                            areas,
                                            sorted_windows,
                                            sorted_skylights,
                                            req_top_ctrl,
                                            req_pri_ctrl,
                                            req_sec_ctrl)
  sensor_1_frac = 0.0
  sensor_2_frac = 0.0
  sensor_1_window = nil
  sensor_2_window = nil

  return [sensor_1_frac, sensor_2_frac, sensor_1_window, sensor_2_window]
end

#space_design_internal_load(space) ⇒ Double

Determine the design internal load (W) for this space without space multipliers. This include People, Lights, Electric Equipment, and Gas Equipment. It assumes 100% of the wattage is converted to heat, and that the design peak schedule value is 1 (100%).

Returns:

  • (Double)

    the design internal load, in W



1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1554

def space_design_internal_load(space)
  load_w = 0.0

  # People
  space.people.each do |people|
    w_per_person = 125 # Initial assumption
    act_sch = people.activityLevelSchedule
    if act_sch.is_initialized
      if act_sch.get.to_ScheduleRuleset.is_initialized
        act_sch = act_sch.get.to_ScheduleRuleset.get
        w_per_person = schedule_ruleset_annual_min_max_value(act_sch)['max']
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "#{space.name} people activity schedule is not a Schedule:Ruleset.  Assuming #{w_per_person}W/person.")
      end
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "#{space.name} people activity schedule not found.  Assuming #{w_per_person}W/person.")
    end

    num_ppl = people.getNumberOfPeople(space.floorArea)

    ppl_w = num_ppl * w_per_person

    load_w += ppl_w
  end

  # Lights
  load_w += space.lightingPower

  # Electric Equipment
  load_w += space.electricEquipmentPower

  # Gas Equipment
  load_w += space.gasEquipmentPower

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "#{space.name} has #{load_w.round}W of design internal loads.")

  return load_w
end

#space_exterior_wall_and_roof_and_subsurface_area(space) ⇒ Double

Calculate the area of the exterior walls, including the area of the windows on these walls.

Returns:

  • (Double)

    area in m^2



1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1355

def space_exterior_wall_and_roof_and_subsurface_area(space)
  area_m2 = 0.0

  # Loop through all surfaces in this space
  space.surfaces.sort.each do |surface|
    # Skip non-outdoor surfaces
    next unless surface.outsideBoundaryCondition == 'Outdoors'
    # Skip non-walls
    next unless surface.surfaceType == 'Wall' || surface.surfaceType == 'RoofCeiling'

    # This surface
    area_m2 += surface.netArea
    # Subsurfaces in this surface
    surface.subSurfaces.sort.each do |subsurface|
      area_m2 += subsurface.netArea
    end
  end

  return area_m2
end

#space_exterior_wall_and_window_area(space) ⇒ Double

Calculate the area of the exterior walls, including the area of the windows on these walls.

Returns:

  • (Double)

    area in m^2



1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1330

def space_exterior_wall_and_window_area(space)
  area_m2 = 0.0

  # Loop through all surfaces in this space
  space.surfaces.sort.each do |surface|
    # Skip non-outdoor surfaces
    next unless surface.outsideBoundaryCondition == 'Outdoors'
    # Skip non-walls
    next unless surface.surfaceType == 'Wall'

    # This surface
    area_m2 += surface.netArea
    # Subsurfaces in this surface
    surface.subSurfaces.sort.each do |subsurface|
      area_m2 += subsurface.netArea
    end
  end

  return area_m2
end

#space_get_adjacent_space_with_most_shared_wall_area(space, same_floor = true) ⇒ Object

Find the space that has the most wall area touching this space.



1654
1655
1656
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1654

def space_get_adjacent_space_with_most_shared_wall_area(space, same_floor = true)
  return get_adjacent_spaces_with_touching_area(same_floor)[0][0]
end

#space_get_adjacent_spaces_with_shared_wall_areas(space, same_floor = true) ⇒ Object

will return a sorted array of array of spaces and connected area (Descending)



1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1593

def space_get_adjacent_spaces_with_shared_wall_areas(space, same_floor = true)
  same_floor_spaces = []
  spaces = []
  space.surfaces.each do |surface|
    adj_surface = surface.adjacentSurface
    unless adj_surface.empty?
      space.model.getSpaces.sort.each do |other_space|
        next if other_space == space

        other_space.surfaces.each do |surf|
          if surf == adj_surface.get
            spaces << other_space
          end
        end
      end
    end
  end
  # If looking for only spaces adjacent on the same floor.
  if same_floor == true
    raise "Cannot get adjacent spaces of space #{space.name} since space not set to BuildingStory" if space.buildingStory.empty?

    spaces.each do |other_space|
      raise "One or more adjecent spaces to space #{space.name} is not assigned to a BuildingStory. Ensure all spaces are assigned." if space.buildingStory.empty?

      if other_space.buildingStory.get == space.buildingStory.get
        same_floor_spaces << other_space
      end
    end
    spaces = same_floor_spaces
  end

  # now sort by areas.
  area_index = []
  array_hash = {}
  return nil if spaces.size.zero?

  # iterate through each surface in the space
  space.surfaces.each do |surface|
    # get the adjacent surface in another space.
    adj_surface = surface.adjacentSurface
    unless adj_surface.empty?
      # go through each of the adjeacent spaces to find the matching  surface/space.
      spaces.each_with_index do |other_space, index|
        next if other_space == space

        other_space.surfaces.each do |surf|
          if surf == adj_surface.get
            # initialize array index to zero for first time so += will work.
            area_index[index] = 0 if area_index[index].nil?
            area_index[index] += surf.grossArea
            array_hash[other_space] = area_index[index]
          end
        end
      end
    end
  end
  sorted_spaces = array_hash.sort_by { |_key, value| value }.reverse
  return sorted_spaces
end

#space_heated?(space) ⇒ Bool

Determines heating status. If the space’s zone has a thermostat with a maximum heating setpoint above 5C (41F), counts as heated.

Returns:

  • (Bool)

    true if heated, false if not

Author:

  • Andrew Parker, Julien Marrec



1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1510

def space_heated?(space)
  # Get the zone this space is inside
  zone = space.thermalZone

  # Assume unheated if not assigned to a zone
  if zone.empty?
    return false
  end

  # Get the category from the zone
  htd = thermal_zone_heated?(zone.get)

  return htd
end

#space_hours_of_operation(space) ⇒ Hash

If the model has an hours of operation schedule set in default schedule set for building that looks valid it will report hours of operation. Won’t be a single set of values, will be a collection of rules note Building, space, and spaceType can get hours of operation from schedule set, but not buildingStory

Parameters:

  • space (Space)

    takes space

Returns:

  • (Hash)

    start and end of hours of operation, stat date, end date, bool for each day of the week

Author:

  • David Goldwasser



1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1668

def space_hours_of_operation(space)
  default_sch_type = OpenStudio::Model::DefaultScheduleType.new('HoursofOperationSchedule')
  hours_of_operation = space.getDefaultSchedule(default_sch_type)
  if !hours_of_operation.is_initialized
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "Hours of Operation Schedule is not set for #{space.name}.")
    return nil
  end
  hours_of_operation = hours_of_operation.get
  if !hours_of_operation.to_ScheduleRuleset.is_initialized
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "Hours of Operation Schedule #{hours_of_operation.name} is not a ScheduleRuleset.")
    return nil
  end
  hours_of_operation = hours_of_operation.to_ScheduleRuleset.get
  profiles = {}

  # get indices for current schedule
  year_description = hours_of_operation.model.yearDescription.get
  year = year_description.assumedYear
  year_start_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('January'), 1, year)
  year_end_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('December'), 31, year)
  indices_vector = hours_of_operation.getActiveRuleIndices(year_start_date, year_end_date)

  # add default profile to hash
  hoo_start = nil
  hoo_end = nil
  unexpected_val = false
  times = hours_of_operation.defaultDaySchedule.times
  values = hours_of_operation.defaultDaySchedule.values
  times.each_with_index do |time, i|
    if values[i] == 0 && hoo_start.nil?
      hoo_start = time.totalHours
    elsif values[i] == 1 && hoo_end.nil?
      hoo_end = time.totalHours
    elsif values[i] != 1 && values[i] != 0
      unexpected_val = true
    end
  end

  # address schedule that is always on or always off (start and end can not both be nil unless unexpected value was found)
  if !hoo_start.nil? && hoo_end.nil?
    hoo_end = hoo_start
  elsif !hoo_end.nil? && hoo_start.nil?
    hoo_start = hoo_end
  end

  # some validation
  if times.size > 3 || unexpected_val || hoo_start.nil? || hoo_end.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "#{hours_of_operation.name} does not look like a valid hours of operation schedule for parametric schedule generation.")
    return nil
  end

  # hours of operation start and finish
  rule_hash = {}
  rule_hash[:hoo_start] = hoo_start
  rule_hash[:hoo_end] = hoo_end
  hoo_hours = nil
  if hoo_start == hoo_end
    if values.uniq == [1]
      hoo_hours = 24
    else
      hoo_hours = 0
    end
  elsif hoo_end > hoo_start
    hoo_hours = hoo_end - hoo_start
  elsif hoo_start > hoo_end
    hoo_hours = hoo_end + 24 - hoo_start
  end
  rule_hash[:hoo_hours] = hoo_hours
  days_used = []
  indices_vector.each_with_index do |profile_index, i|
    if profile_index == -1 then days_used << i + 1 end
  end
  rule_hash[:days_used] = days_used
  profiles[-1] = rule_hash

  hours_of_operation.scheduleRules.reverse.each do |rule|
    # may not need date and days of week, will likely refer to specific date and get rule when applying parametricformula
    rule_hash = {}

    hoo_start = nil
    hoo_end = nil
    unexpected_val = false
    times = rule.daySchedule.times
    values = rule.daySchedule.values
    times.each_with_index do |time, i|
      if values[i] == 0 && hoo_start.nil?
        hoo_start = time.totalHours
      elsif values[i] == 1 && hoo_end.nil?
        hoo_end = time.totalHours
      elsif values[i] != 1 && values[i] != 0
        unexpected_val = true
      end
    end

    # address schedule that is always on or always off (start and end can not both be nil unless unexpected value was found)
    if !hoo_start.nil? && hoo_end.nil?
      hoo_end = hoo_start
    elsif !hoo_end.nil? && hoo_start.nil?
      hoo_start = hoo_end
    end

    # some validation
    if times.size > 3 || unexpected_val || hoo_start.nil? || hoo_end.nil?
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "#{hours_of_operation.name} does not look like a valid hours of operation schedule for parametric schedule generation.")
      return nil
    end

    # hours of operation start and finish
    rule_hash[:hoo_start] = hoo_start
    rule_hash[:hoo_end] = hoo_end
    hoo_hours = nil
    if hoo_start == hoo_end
      if values.uniq == [1]
        hoo_hours = 24
      else
        hoo_hours = 0
      end
    elsif hoo_end > hoo_start
      hoo_hours = hoo_end - hoo_start
    elsif hoo_start > hoo_end
      hoo_hours = hoo_end + 24 - hoo_start
    end
    rule_hash[:hoo_hours] = hoo_hours
    days_used = []
    indices_vector.each_with_index do |profile_index, i|
      if profile_index == rule.ruleIndex then days_used << i + 1 end
    end
    rule_hash[:days_used] = days_used

    #       # todo - delete rule details below unless end up needing to use them
    #       if rule.startDate.is_initialized
    #         date = rule.startDate.get
    #         rule_hash[:start_date] = "#{date.monthOfYear.value}/#{date.dayOfMonth}"
    #       else
    #         rule_hash[:start_date] = nil
    #       end
    #       if rule.endDate.is_initialized
    #         date = rule.endDate.get
    #         rule_hash[:end_date] = "#{date.monthOfYear.value}/#{date.dayOfMonth}"
    #       else
    #         rule_hash[:end_date] = nil
    #       end
    #       rule_hash[:mon] = rule.applyMonday
    #       rule_hash[:tue] = rule.applyTuesday
    #       rule_hash[:wed] = rule.applyWednesday
    #       rule_hash[:thu] = rule.applyThursday
    #       rule_hash[:fri] = rule.applyFriday
    #       rule_hash[:sat] = rule.applySaturday
    #       rule_hash[:sun] = rule.applySunday

    # update hash
    profiles[rule.ruleIndex] = rule_hash
  end

  return profiles
end

#space_infiltration_rate_75_pa(space) ⇒ Double

Baseline infiltration rate

Returns:

  • (Double)

    the baseline infiltration rate, in cfm/ft^2 exterior above grade wall area at 75 Pa



1321
1322
1323
1324
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1321

def space_infiltration_rate_75_pa(space)
  basic_infil_rate_cfm_per_ft2 = 1.8
  return basic_infil_rate_cfm_per_ft2
end

#space_plenum?(space) ⇒ Boolean

Determine if the space is a plenum. Assume it is a plenum if it is a supply or return plenum for an AirLoop, if it is not part of the total floor area, or if the space type name contains the word plenum.

return [Bool] returns true if plenum, false if not

Returns:

  • (Boolean)


1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1384

def space_plenum?(space)
  plenum_status = false

  # Check if it is designated
  # as not part of the building
  # floor area.  This method internally
  # also checks to see if the space's zone
  # is a supply or return plenum
  unless space.partofTotalFloorArea
    plenum_status = true
    return plenum_status
  end

  # TODO: - update to check if it has internal loads

  # Check if the space type name
  # contains the word plenum.
  space_type = space.spaceType
  if space_type.is_initialized
    space_type = space_type.get
    if space_type.name.get.to_s.downcase.include?('plenum')
      plenum_status = true
      return plenum_status
    end
    if space_type.standardsSpaceType.is_initialized
      if space_type.standardsSpaceType.get.downcase.include?('plenum')
        plenum_status = true
        return plenum_status
      end
    end
  end

  return plenum_status
end

#space_residential?(space) ⇒ Boolean

Determine if the space is residential based on the space type properties for the space. For spaces with no space type, assume nonresidential. For spaces that are plenums, base the decision on the space type of the space below the largest floor in the plenum.

return [Bool] true if residential, false if nonresidential

Returns:

  • (Boolean)


1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1426

def space_residential?(space)
  is_res = false

  space_to_check = space

  # If this space is a plenum, check the space type
  # of the space below the largest floor in the space
  if space_plenum?(space)
    # Find the largest floor
    largest_floor_area = 0.0
    largest_surface = nil
    space.surfaces.each do |surface|
      next unless surface.surfaceType == 'Floor' && surface.outsideBoundaryCondition == 'Surface'

      if surface.grossArea > largest_floor_area
        largest_floor_area = surface.grossArea
        largest_surface = surface
      end
    end
    if largest_surface.nil?
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "#{space.name} is a plenum, but could not find a floor with a space below it to determine if plenum should be  res or nonres.  Assuming nonresidential.")
      return is_res
    end
    # Get the space on the other side of this floor
    if largest_surface.adjacentSurface.is_initialized
      adj_surface = largest_surface.adjacentSurface.get
      if adj_surface.space.is_initialized
        space_to_check = adj_surface.space.get
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "#{space.name} is a plenum, but could not find a space attached to the largest floor's adjacent surface #{adj_surface.name} to determine if plenum should be res or nonres.  Assuming nonresidential.")
        return is_res
      end
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "#{space.name} is a plenum, but could not find a floor with a space below it to determine if plenum should be  res or nonres.  Assuming nonresidential.")
      return is_res
    end
  end

  space_type = space_to_check.spaceType
  if space_type.is_initialized
    space_type = space_type.get
    # Get the space type data
    space_type_properties = space_type_get_standards_data(space_type)
    if space_type_properties.nil?
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "Could not find space type properties for #{space_to_check.name}, assuming nonresidential.")
      is_res = false
    else
      is_res = space_type_properties['is_residential'] == 'Yes'
    end
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "Could not find a space type for #{space_to_check.name}, assuming nonresidential.")
    is_res = false
  end

  return is_res
end

#space_sidelighting_effective_aperture(space, primary_sidelighted_area) ⇒ Double

Returns the sidelighting effective aperture space_sidelighting_effective_aperture(space) = E(window area * window VT) / primary_sidelighted_area

Parameters:

  • primary_sidelighted_area (Double)

    the primary sidelighted area (m^2) of the space

Returns:

  • (Double)

    the unitless sidelighting effective aperture metric



561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 561

def space_sidelighting_effective_aperture(space, primary_sidelighted_area)
  # space_sidelighting_effective_aperture(space)  = E(window area * window VT) / primary_sidelighted_area
  sidelighting_effective_aperture = 9999

  num_sub_surfaces = 0

  # Loop through all windows and add up area * VT
  sum_window_area_times_vt = 0
  construction_name_to_vt_map = {}
  space.surfaces.sort.each do |surface|
    next unless surface.outsideBoundaryCondition == 'Outdoors' && surface.surfaceType == 'Wall'

    surface.subSurfaces.sort.each do |sub_surface|
      next unless sub_surface.outsideBoundaryCondition == 'Outdoors' && (sub_surface.subSurfaceType == 'FixedWindow' || sub_surface.subSurfaceType == 'OperableWindow' || sub_surface.subSurfaceType == 'GlassDoor')

      num_sub_surfaces += 1

      # Get the area
      area_m2 = sub_surface.netArea

      # Get the window construction name
      construction_name = nil
      construction = sub_surface.construction
      if construction.is_initialized
        construction = construction.get
        construction_name = construction.name.get.upcase
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "For #{space.name}, could not determine construction for #{sub_surface.name}, will not be included in space_sidelighting_effective_aperture(space) calculation.")
        next
      end

      # Store VT for this construction in map if not already looked up
      if construction_name_to_vt_map[construction_name].nil?

        # Get the VT from construction (Simple Glazing) if available
        if construction.visibleTransmittance.is_initialized
          construction_name_to_vt_map[construction_name] = construction.visibleTransmittance.get
        else
          # get the VT from the sql file
          sql = space.model.sqlFile
          if sql.is_initialized
            sql = sql.get

            row_query = "SELECT RowName
                        FROM tabulardatawithstrings
                        WHERE ReportName='EnvelopeSummary'
                        AND ReportForString='Entire Facility'
                        AND TableName='Exterior Fenestration'
                        AND Value='#{construction_name.upcase}'"

            row_id = sql.execAndReturnFirstString(row_query)

            if row_id.is_initialized
              row_id = row_id.get
            else
              OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', "VT row ID not found for construction: #{construction_name}, #{sub_surface.name} will not be included in space_sidelighting_effective_aperture(space) calculation.")
              row_id = 9999
            end

            vt_query = "SELECT Value
                        FROM tabulardatawithstrings
                        WHERE ReportName='EnvelopeSummary'
                        AND ReportForString='Entire Facility'
                        AND TableName='Exterior Fenestration'
                        AND ColumnName='Glass Visible Transmittance'
                        AND RowName='#{row_id}'"

            vt = sql.execAndReturnFirstDouble(vt_query)

            vt = if vt.is_initialized
                   vt.get
                 end

            # Record the VT
            construction_name_to_vt_map[construction_name] = vt
          else
            OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Space', 'Model has no sql file containing results, cannot lookup data.')
          end
        end
      end

      # Get the VT from the map
      vt = construction_name_to_vt_map[construction_name]
      if vt.nil?
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "For #{space.name}, could not determine VLT for #{construction_name}, will not be included in sidelighting effective aperture calculation.")
        vt = 0
      end

      sum_window_area_times_vt += area_m2 * vt
    end
  end

  # Calculate the effective aperture
  if sum_window_area_times_vt.zero?
    sidelighting_effective_aperture = 9999
    if num_sub_surfaces > 0
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "#{space.name} has no windows where VLT could be determined, sidelighting effective aperture will be higher than it should.")
    end
  else
    sidelighting_effective_aperture = sum_window_area_times_vt / primary_sidelighted_area
  end

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "For #{space.name} sidelighting effective aperture = #{sidelighting_effective_aperture.round(4)}.")

  return sidelighting_effective_aperture
end

#space_skylight_effective_aperture(space, toplighted_area) ⇒ Double

Returns the skylight effective aperture space_skylight_effective_aperture(space) = E(0.85 * skylight area * skylight VT * WF) / toplighted_area

Parameters:

  • toplighted_area (Double)

    the toplighted area (m^2) of the space

Returns:

  • (Double)

    the unitless skylight effective aperture metric



673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 673

def space_skylight_effective_aperture(space, toplighted_area)
  # space_skylight_effective_aperture(space)  = E(0.85 * skylight area * skylight VT * WF) / toplighted_area
  skylight_effective_aperture = 0.0

  num_sub_surfaces = 0

  # Assume that well factor (WF) is 0.9 (all wells are less than 2 feet deep)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Space', 'Assuming that all skylight wells are less than 2 feet deep to calculate skylight effective aperture.')
  wf = 0.9

  # Loop through all windows and add up area * VT
  sum_85pct_times_skylight_area_times_vt_times_wf = 0
  construction_name_to_vt_map = {}
  space.surfaces.sort.each do |surface|
    next unless surface.outsideBoundaryCondition == 'Outdoors' && surface.surfaceType == 'RoofCeiling'

    surface.subSurfaces.sort.each do |sub_surface|
      next unless sub_surface.outsideBoundaryCondition == 'Outdoors' && sub_surface.subSurfaceType == 'Skylight'

      num_sub_surfaces += 1

      # Get the area
      area_m2 = sub_surface.netArea

      # Get the window construction name
      construction_name = nil
      construction = sub_surface.construction
      if construction.is_initialized
        construction = construction.get
        construction_name = construction.name.get.upcase
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "For #{space.name}, could not determine construction for #{sub_surface.name}, will not be included in space_skylight_effective_aperture(space) calculation.")
        next
      end

      # Store VT for this construction in map if not already looked up
      if construction_name_to_vt_map[construction_name].nil?

        # Get the VT from construction (Simple Glazing) if available
        if construction.visibleTransmittance.is_initialized
          construction_name_to_vt_map[construction_name] = construction.visibleTransmittance.get
        else
          # get the VT from the sql file
          sql = space.model.sqlFile
          if sql.is_initialized
            sql = sql.get

            row_query = "SELECT RowName
                        FROM tabulardatawithstrings
                        WHERE ReportName='EnvelopeSummary'
                        AND ReportForString='Entire Facility'
                        AND TableName='Exterior Fenestration'
                        AND Value='#{construction_name}'"

            row_id = sql.execAndReturnFirstString(row_query)

            if row_id.is_initialized
              row_id = row_id.get
            else
              OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "Data not found for query: #{row_query}")
              next
            end

            vt_query = "SELECT Value
                        FROM tabulardatawithstrings
                        WHERE ReportName='EnvelopeSummary'
                        AND ReportForString='Entire Facility'
                        AND TableName='Exterior Fenestration'
                        AND ColumnName='Glass Visible Transmittance'
                        AND RowName='#{row_id}'"

            vt = sql.execAndReturnFirstDouble(vt_query)

            vt = if vt.is_initialized
                   vt.get
                 end

            # Record the VT
            construction_name_to_vt_map[construction_name] = vt

          else
            OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Space', 'Model has no sql file containing results, cannot lookup data.')
          end
        end
      end

      # Get the VT from the map
      vt = construction_name_to_vt_map[construction_name]
      if vt.nil?
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "For #{space.name}, could not determine VLT for #{construction_name}, will not be included in skylight effective aperture calculation.")
        vt = 0
      end

      sum_85pct_times_skylight_area_times_vt_times_wf += 0.85 * area_m2 * vt * wf
    end
  end

  # Calculate the effective aperture
  if sum_85pct_times_skylight_area_times_vt_times_wf.zero?
    skylight_effective_aperture = 9999
    if num_sub_surfaces > 0
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Space', "#{space.name} has no skylights where VLT could be determined, skylight effective aperture will be higher than it should.")
    end
  else
    skylight_effective_aperture = sum_85pct_times_skylight_area_times_vt_times_wf / toplighted_area
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Space', "#{space.name} skylight effective aperture = #{skylight_effective_aperture}.")

  return skylight_effective_aperture
end

#space_type_apply_internal_load_schedules(space_type, set_people, set_lights, set_electric_equipment, set_gas_equipment, set_ventilation, set_infiltration, make_thermostat) ⇒ Bool

Sets the schedules for the selected internal loads to typical schedules. Get the default schedule set for this space type if one exists or make one if none exists. For each category that is selected, add the typical schedule for this category to the default schedule set. This method does not alter any schedules of any internal loads that does not inherit from the default schedule set.

schedules listed for the space type. This thermostat is not hooked to any zone by this method, but may be found and used later.

Parameters:

  • set_people (Bool)

    if true, set the occupancy and activity schedules

  • set_lights (Bool)

    if true, set the lighting schedule

  • set_electric_equipment (Bool)

    if true, set the electric schedule schedule

  • set_gas_equipment (Bool)

    if true, set the gas equipment density

  • set_infiltration (Bool)

    if true, set the infiltration schedule

  • make_thermostat (Bool)

    if true, makes a thermostat for this space type from the

Returns:

  • (Bool)

    returns true if successful, false if not



468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
# File 'lib/openstudio-standards/standards/Standards.SpaceType.rb', line 468

def space_type_apply_internal_load_schedules(space_type, set_people, set_lights, set_electric_equipment, set_gas_equipment, set_ventilation, set_infiltration, make_thermostat)
  # Get the standards data
  space_type_properties = space_type_get_standards_data(space_type)

  # Get the default schedule set
  # or create a new one if none exists.
  default_sch_set = nil
  if space_type.defaultScheduleSet.is_initialized
    default_sch_set = space_type.defaultScheduleSet.get
  else
    default_sch_set = OpenStudio::Model::DefaultScheduleSet.new(space_type.model)
    default_sch_set.setName("#{space_type.name} Schedule Set")
    space_type.setDefaultScheduleSet(default_sch_set)
  end

  # People
  if set_people
    occupancy_sch = space_type_properties['occupancy_schedule']
    unless occupancy_sch.nil?
      default_sch_set.setNumberofPeopleSchedule(model_add_schedule(space_type.model, occupancy_sch))
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set occupancy schedule to #{occupancy_sch}.")
    end

    occupancy_activity_sch = space_type_properties['occupancy_activity_schedule']
    unless occupancy_activity_sch.nil?
      default_sch_set.setPeopleActivityLevelSchedule(model_add_schedule(space_type.model, occupancy_activity_sch))
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set occupant activity schedule to #{occupancy_activity_sch}.")
    end

  end

  # Lights
  if set_lights

    apply_lighting_schedule(space_type, space_type_properties, default_sch_set)

  end

  # Electric Equipment
  if set_electric_equipment
    elec_equip_sch = space_type_properties['electric_equipment_schedule']
    unless elec_equip_sch.nil?
      default_sch_set.setElectricEquipmentSchedule(model_add_schedule(space_type.model, elec_equip_sch))
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set electric equipment schedule to #{elec_equip_sch}.")
    end
  end

  # Gas Equipment
  if set_gas_equipment
    gas_equip_sch = space_type_properties['gas_equipment_schedule']
    unless gas_equip_sch.nil?
      default_sch_set.setGasEquipmentSchedule(model_add_schedule(space_type.model, gas_equip_sch))
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set gas equipment schedule to #{gas_equip_sch}.")
    end
  end

  # Infiltration
  if set_infiltration
    infiltration_sch = space_type_properties['infiltration_schedule']
    unless infiltration_sch.nil?
      default_sch_set.setInfiltrationSchedule(model_add_schedule(space_type.model, infiltration_sch))
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set infiltration schedule to #{infiltration_sch}.")
    end
  end

  # Thermostat
  if make_thermostat
    thermostat = OpenStudio::Model::ThermostatSetpointDualSetpoint.new(space_type.model)
    thermostat.setName("#{space_type.name} Thermostat")

    heating_setpoint_sch = space_type_properties['heating_setpoint_schedule']
    unless heating_setpoint_sch.nil?
      thermostat.setHeatingSetpointTemperatureSchedule(model_add_schedule(space_type.model, heating_setpoint_sch))
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set heating setpoint schedule to #{heating_setpoint_sch}.")
    end

    cooling_setpoint_sch = space_type_properties['cooling_setpoint_schedule']
    unless cooling_setpoint_sch.nil?
      thermostat.setCoolingSetpointTemperatureSchedule(model_add_schedule(space_type.model, cooling_setpoint_sch))
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set cooling setpoint schedule to #{cooling_setpoint_sch}.")
    end
  end

  return true
end

#space_type_apply_internal_loads(space_type, set_people, set_lights, set_electric_equipment, set_gas_equipment, set_ventilation, set_infiltration) ⇒ Bool

Sets the selected internal loads to standards-based or typical values. For each category that is selected get all load instances. Remove all but the first instance if multiple instances. Add a new instance/definition if no instance exists. Modify the definition for the remaining instance to have the specified values. This method does not alter any loads directly assigned to spaces. This method skips plenums.

Also, assign reasonable clothing, air velocity, and work efficiency inputs to allow reasonable thermal comfort metrics to be calculated. to return air, fraction radiant, and fraction visible.

Parameters:

  • set_people (Bool)

    if true, set the people density.

  • set_lights (Bool)

    if true, set the lighting density, lighting fraction

  • set_electric_equipment (Bool)

    if true, set the electric equipment density

  • set_gas_equipment (Bool)

    if true, set the gas equipment density

  • set_ventilation (Bool)

    if true, set the ventilation rates (per-person and per-area)

  • set_infiltration (Bool)

    if true, set the infiltration rates

Returns:

  • (Bool)

    returns true if successful, false if not



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
# File 'lib/openstudio-standards/standards/Standards.SpaceType.rb', line 78

def space_type_apply_internal_loads(space_type, set_people, set_lights, set_electric_equipment, set_gas_equipment, set_ventilation, set_infiltration)
  # Skip plenums
  # Check if the space type name
  # contains the word plenum.
  if space_type.name.get.to_s.downcase.include?('plenum')
    return false
  end

  if space_type.standardsSpaceType.is_initialized
    if space_type.standardsSpaceType.get.downcase.include?('plenum')
      return false
    end
  end

  # Get the standards data
  space_type_properties = space_type_get_standards_data(space_type)

  # Need to add a check, or it'll crash on space_type_properties['occupancy_per_area'].to_f below
  if space_type_properties.nil? || space_type_properties.empty?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} was not found in the standards data.")
    return false
  end
  # People
  people_have_info = false
  occupancy_per_area = space_type_properties['occupancy_per_area'].to_f
  people_have_info = true unless occupancy_per_area.zero?

  if set_people && people_have_info

    # Remove all but the first instance
    instances = space_type.people.sort
    if instances.size.zero?
      # Create a new definition and instance
      definition = OpenStudio::Model::PeopleDefinition.new(space_type.model)
      definition.setName("#{space_type.name} People Definition")
      instance = OpenStudio::Model::People.new(definition)
      instance.setName("#{space_type.name} People")
      instance.setSpaceType(space_type)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} had no people, one has been created.")
      instances << instance
    elsif instances.size > 1
      instances.each_with_index do |inst, i|
        next if i.zero?

        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "Removed #{inst.name} from #{space_type.name}.")
        inst.remove
      end
    end

    # Modify the definition of the instance
    space_type.people.sort.each do |inst|
      definition = inst.peopleDefinition
      unless occupancy_per_area.zero?
        definition.setPeopleperSpaceFloorArea(OpenStudio.convert(occupancy_per_area / 1000, 'people/ft^2', 'people/m^2').get)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set occupancy to #{occupancy_per_area} people/1000 ft^2.")
      end

      # set fraction radiant  ##
      definition.setFractionRadiant(0.3)

      # Clothing schedule for thermal comfort metrics
      clothing_sch = space_type.model.getScheduleRulesetByName('Clothing Schedule')
      if clothing_sch.is_initialized
        clothing_sch = clothing_sch.get
      else
        clothing_sch = OpenStudio::Model::ScheduleRuleset.new(space_type.model)
        clothing_sch.setName('Clothing Schedule')
        clothing_sch.defaultDaySchedule.setName('Clothing Schedule Default Winter Clothes')
        clothing_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 1.0)
        sch_rule = OpenStudio::Model::ScheduleRule.new(clothing_sch)
        sch_rule.daySchedule.setName('Clothing Schedule Summer Clothes')
        sch_rule.daySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0.5)
        sch_rule.setStartDate(OpenStudio::Date.new(OpenStudio::MonthOfYear.new(5), 1))
        sch_rule.setEndDate(OpenStudio::Date.new(OpenStudio::MonthOfYear.new(9), 30))
      end
      inst.setClothingInsulationSchedule(clothing_sch)

      # Air velocity schedule for thermal comfort metrics
      air_velo_sch = space_type.model.getScheduleRulesetByName('Air Velocity Schedule')
      if air_velo_sch.is_initialized
        air_velo_sch = air_velo_sch.get
      else
        air_velo_sch = OpenStudio::Model::ScheduleRuleset.new(space_type.model)
        air_velo_sch.setName('Air Velocity Schedule')
        air_velo_sch.defaultDaySchedule.setName('Air Velocity Schedule Default')
        air_velo_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0.2)
      end
      inst.setAirVelocitySchedule(air_velo_sch)

      # Work efficiency schedule for thermal comfort metrics
      work_efficiency_sch = space_type.model.getScheduleRulesetByName('Work Efficiency Schedule')
      if work_efficiency_sch.is_initialized
        work_efficiency_sch = work_efficiency_sch.get
      else
        work_efficiency_sch = OpenStudio::Model::ScheduleRuleset.new(space_type.model)
        work_efficiency_sch.setName('Work Efficiency Schedule')
        work_efficiency_sch.defaultDaySchedule.setName('Work Efficiency Schedule Default')
        work_efficiency_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
      end
      inst.setWorkEfficiencySchedule(work_efficiency_sch)
    end

  end

  # Lights
  lights_have_info = false
  lighting_per_area = space_type_properties['lighting_per_area'].to_f
  lighting_per_person = space_type_properties['lighting_per_person'].to_f
  lights_frac_to_return_air = space_type_properties['lighting_fraction_to_return_air']
  lights_frac_radiant = space_type_properties['lighting_fraction_radiant']
  lights_frac_visible = space_type_properties['lighting_fraction_visible']
  lights_frac_replaceable = space_type_properties['lighting_fraction_replaceable'].to_f
  lights_frac_linear_fluorescent = space_type_properties['lpd_fraction_linear_fluorescent']
  lights_frac_compact_fluorescent = space_type_properties['lpd_fraction_compact_fluorescent']
  lights_frac_high_bay = space_type_properties['lpd_fraction_high_bay']
  lights_frac_specialty_lighting = space_type_properties['lpd_fraction_specialty_lighting']
  lights_frac_exit_lighting = space_type_properties['lpd_fraction_exit_lighting']
  lights_have_info = true unless lighting_per_area.zero?
  lights_have_info = true unless lighting_per_person.zero?

  if set_lights && lights_have_info

    # Remove all but the first instance
    instances = space_type.lights.sort
    if instances.size.zero?
      definition = OpenStudio::Model::LightsDefinition.new(space_type.model)
      definition.setName("#{space_type.name} Lights Definition")
      instance = OpenStudio::Model::Lights.new(definition)
      instance.setName("#{space_type.name} Lights")
      instance.setSpaceType(space_type)
      instance.setFractionReplaceable(lights_frac_replaceable)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} had no lights, one has been created.")
      instances << instance
    elsif instances.size > 1
      instances.each_with_index do |inst, i|
        next if i.zero?

        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "Removed #{inst.name} from #{space_type.name}.")
        inst.remove
      end
    end

    # Modify the definition of the instance
    space_type.lights.sort.each do |inst|
      inst.setFractionReplaceable(lights_frac_replaceable)
      definition = inst.lightsDefinition
      unless lighting_per_area.zero?
        occ_sens_lpd_factor = 1.0
        definition.setWattsperSpaceFloorArea(OpenStudio.convert(lighting_per_area.to_f * occ_sens_lpd_factor, 'W/ft^2', 'W/m^2').get)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set LPD to #{lighting_per_area} W/ft^2.")
      end
      unless lighting_per_person.zero?
        definition.setWattsperPerson(OpenStudio.convert(lighting_per_person.to_f, 'W/person', 'W/person').get)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set lighting to #{lighting_per_person} W/person.")
      end
      definition.setReturnAirFraction(lights_frac_to_return_air.to_f) if lights_frac_to_return_air
      definition.setFractionRadiant(lights_frac_radiant.to_f) if lights_frac_radiant
      definition.setFractionVisible(lights_frac_visible.to_f) if lights_frac_visible
      # definition.setFractionReplaceable(lights_frac_replaceable) if lights_frac_replaceable
      definition.additionalProperties.setFeature('lpd_fraction_linear_fluorescent', lights_frac_linear_fluorescent.to_f) if lights_frac_linear_fluorescent
      definition.additionalProperties.setFeature('lpd_fraction_compact_fluorescent', lights_frac_compact_fluorescent.to_f) if lights_frac_compact_fluorescent
      definition.additionalProperties.setFeature('lpd_fraction_high_bay', lights_frac_high_bay.to_f) if lights_frac_high_bay
      definition.additionalProperties.setFeature('lpd_fraction_specialty_lighting', lights_frac_specialty_lighting.to_f) if lights_frac_specialty_lighting
      definition.additionalProperties.setFeature('lpd_fraction_exit_lighting', lights_frac_exit_lighting.to_f) if lights_frac_exit_lighting
    end

    # If additional lights are specified, add those too
    additional_lighting_per_area = space_type_properties['additional_lighting_per_area'].to_f
    unless additional_lighting_per_area.zero?
      # Create the lighting definition
      additional_lights_def = OpenStudio::Model::LightsDefinition.new(space_type.model)
      additional_lights_def.setName("#{space_type.name} Additional Lights Definition")
      additional_lights_def.setWattsperSpaceFloorArea(OpenStudio.convert(additional_lighting_per_area.to_f, 'W/ft^2', 'W/m^2').get)
      additional_lights_def.setReturnAirFraction(lights_frac_to_return_air)
      additional_lights_def.setFractionRadiant(lights_frac_radiant)
      additional_lights_def.setFractionVisible(lights_frac_visible)

      # By default, all additional lighting is specialty lighting
      additional_lights_def.additionalProperties.setFeature('lpd_fraction_linear_fluorescent', 0.0)
      additional_lights_def.additionalProperties.setFeature('lpd_fraction_compact_fluorescent', 0.0)
      additional_lights_def.additionalProperties.setFeature('lpd_fraction_high_bay', 0.0)
      additional_lights_def.additionalProperties.setFeature('lpd_fraction_specialty_lighting', 1.0)
      additional_lights_def.additionalProperties.setFeature('lpd_fraction_exit_lighting', 0.0)

      # Create the lighting instance and hook it up to the space type
      additional_lights = OpenStudio::Model::Lights.new(additional_lights_def)
      additional_lights.setName("#{space_type.name} Additional Lights")
      additional_lights.setSpaceType(space_type)
    end

  end

  # Electric Equipment
  elec_equip_have_info = false
  elec_equip_per_area = space_type_properties['electric_equipment_per_area'].to_f
  elec_equip_frac_latent = space_type_properties['electric_equipment_fraction_latent']
  elec_equip_frac_radiant = space_type_properties['electric_equipment_fraction_radiant']
  elec_equip_frac_lost = space_type_properties['electric_equipment_fraction_lost']
  elec_equip_have_info = true unless elec_equip_per_area.zero?

  if set_electric_equipment && elec_equip_have_info

    # Remove all but the first instance
    instances = space_type.electricEquipment.sort
    if instances.size.zero?
      definition = OpenStudio::Model::ElectricEquipmentDefinition.new(space_type.model)
      definition.setName("#{space_type.name} Elec Equip Definition")
      instance = OpenStudio::Model::ElectricEquipment.new(definition)
      instance.setName("#{space_type.name} Elec Equip")
      instance.setSpaceType(space_type)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} had no electric equipment, one has been created.")
      instances << instance
    elsif instances.size > 1
      instances.each_with_index do |inst, i|
        next if i.zero?

        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "Removed #{inst.name} from #{space_type.name}.")
        inst.remove
      end
    end

    # Modify the definition of the instance
    space_type.electricEquipment.sort.each do |inst|
      definition = inst.electricEquipmentDefinition
      unless elec_equip_per_area.zero?
        definition.setWattsperSpaceFloorArea(OpenStudio.convert(elec_equip_per_area.to_f, 'W/ft^2', 'W/m^2').get)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set electric EPD to #{elec_equip_per_area} W/ft^2.")
      end
      definition.setFractionLatent(elec_equip_frac_latent.to_f) if elec_equip_frac_latent
      definition.setFractionRadiant(elec_equip_frac_radiant.to_f) if elec_equip_frac_radiant
      definition.setFractionLost(elec_equip_frac_lost.to_f) if elec_equip_frac_lost
    end

  end

  # Gas Equipment
  gas_equip_have_info = false
  gas_equip_per_area = space_type_properties['gas_equipment_per_area'].to_f
  gas_equip_frac_latent = space_type_properties['gas_equipment_fraction_latent']
  gas_equip_frac_radiant = space_type_properties['gas_equipment_fraction_radiant']
  gas_equip_frac_lost = space_type_properties['gas_equipment_fraction_lost']
  gas_equip_have_info = true unless gas_equip_per_area.zero?

  if set_gas_equipment && gas_equip_have_info

    # Remove all but the first instance
    instances = space_type.gasEquipment.sort
    if instances.size.zero?
      definition = OpenStudio::Model::GasEquipmentDefinition.new(space_type.model)
      definition.setName("#{space_type.name} Gas Equip Definition")
      instance = OpenStudio::Model::GasEquipment.new(definition)
      instance.setName("#{space_type.name} Gas Equip")
      instance.setSpaceType(space_type)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} had no gas equipment, one has been created.")
      instances << instance
    elsif instances.size > 1
      instances.each_with_index do |inst, i|
        next if i.zero?

        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "Removed #{inst.name} from #{space_type.name}.")
        inst.remove
      end
    end

    # Modify the definition of the instance
    space_type.gasEquipment.sort.each do |inst|
      definition = inst.gasEquipmentDefinition
      unless gas_equip_per_area.zero?
        definition.setWattsperSpaceFloorArea(OpenStudio.convert(gas_equip_per_area.to_f, 'Btu/hr*ft^2', 'W/m^2').get)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set gas EPD to #{gas_equip_per_area} Btu/hr*ft^2.")
      end
      definition.setFractionLatent(gas_equip_frac_latent.to_f) if gas_equip_frac_latent
      definition.setFractionRadiant(gas_equip_frac_radiant.to_f) if gas_equip_frac_radiant
      definition.setFractionLost(gas_equip_frac_lost.to_f) if gas_equip_frac_lost
    end

  end

  # Ventilation
  ventilation_have_info = false
  ventilation_per_area = space_type_properties['ventilation_per_area'].to_f
  ventilation_per_person = space_type_properties['ventilation_per_person'].to_f
  ventilation_ach = space_type_properties['ventilation_air_changes'].to_f
  ventilation_have_info = true unless ventilation_per_area.zero?
  ventilation_have_info = true unless ventilation_per_person.zero?
  ventilation_have_info = true unless ventilation_ach.zero?

  # Get the design OA or create a new one if none exists
  ventilation = space_type.designSpecificationOutdoorAir
  if ventilation.is_initialized
    ventilation = ventilation.get
  else
    ventilation = OpenStudio::Model::DesignSpecificationOutdoorAir.new(space_type.model)
    ventilation.setName("#{space_type.name} Ventilation")
    space_type.setDesignSpecificationOutdoorAir(ventilation)
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} had no ventilation specification, one has been created.")
  end

  if set_ventilation && ventilation_have_info

    # Modify the ventilation properties
    ventilation_method = model_ventilation_method(space_type.model)
    ventilation.setOutdoorAirMethod(ventilation_method)
    unless ventilation_per_area.zero?
      ventilation.setOutdoorAirFlowperFloorArea(OpenStudio.convert(ventilation_per_area.to_f, 'ft^3/min*ft^2', 'm^3/s*m^2').get)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set ventilation per area to #{ventilation_per_area} cfm/ft^2.")
    end
    unless ventilation_per_person.zero?
      ventilation.setOutdoorAirFlowperPerson(OpenStudio.convert(ventilation_per_person.to_f, 'ft^3/min*person', 'm^3/s*person').get)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set ventilation per person to #{ventilation_per_person} cfm/person.")
    end
    unless ventilation_ach.zero?
      ventilation.setOutdoorAirFlowAirChangesperHour(ventilation_ach)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set ventilation to #{ventilation_ach} ACH.")
    end

  elsif set_ventilation && !ventilation_have_info

    # All space types must have a design spec OA
    # object for ventilation controls to work correctly,
    # even if the values are all zero.
    ventilation.setOutdoorAirFlowperFloorArea(0)
    ventilation.setOutdoorAirFlowperPerson(0)
    ventilation.setOutdoorAirFlowAirChangesperHour(0)

  end

  # Infiltration
  infiltration_have_info = false
  infiltration_per_area_ext = space_type_properties['infiltration_per_exterior_area'].to_f
  infiltration_per_area_ext_wall = space_type_properties['infiltration_per_exterior_wall_area'].to_f
  infiltration_ach = space_type_properties['infiltration_air_changes'].to_f
  unless infiltration_per_area_ext.zero? && infiltration_per_area_ext_wall.zero? && infiltration_ach.zero?
    infiltration_have_info = true
  end

  if set_infiltration && infiltration_have_info

    # Remove all but the first instance
    instances = space_type.spaceInfiltrationDesignFlowRates.sort
    if instances.size.zero?
      instance = OpenStudio::Model::SpaceInfiltrationDesignFlowRate.new(space_type.model)
      instance.setName("#{space_type.name} Infiltration")
      instance.setSpaceType(space_type)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} had no infiltration objects, one has been created.")
      instances << instance
    elsif instances.size > 1
      instances.each_with_index do |inst, i|
        next if i.zero?

        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "Removed #{inst.name} from #{space_type.name}.")
        inst.remove
      end
    end

    # Modify each instance
    space_type.spaceInfiltrationDesignFlowRates.sort.each do |inst|
      unless infiltration_per_area_ext.zero?
        inst.setFlowperExteriorSurfaceArea(OpenStudio.convert(infiltration_per_area_ext.to_f, 'ft^3/min*ft^2', 'm^3/s*m^2').get.round(13))
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set infiltration to #{ventilation_ach} per ft^2 exterior surface area.")
      end
      unless infiltration_per_area_ext_wall.zero?
        inst.setFlowperExteriorWallArea(OpenStudio.convert(infiltration_per_area_ext_wall.to_f, 'ft^3/min*ft^2', 'm^3/s*m^2').get)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set infiltration to #{infiltration_per_area_ext_wall} per ft^2 exterior wall area.")
      end
      unless infiltration_ach.zero?
        inst.setAirChangesperHour(infiltration_ach)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set infiltration to #{ventilation_ach} ACH.")
      end
    end

  end
end

#space_type_apply_rendering_color(space_type) ⇒ Bool

Sets the color for the space types as shown in the SketchUp plugin using render by space type.

Returns:

  • (Bool)

    returns true if successful, false if not.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/openstudio-standards/standards/Standards.SpaceType.rb', line 37

def space_type_apply_rendering_color(space_type)
  # Get the standards data
  space_type_properties = space_type_get_standards_data(space_type)

  # Set the rendering color of the space type
  rgb = space_type_properties['rgb']
  if rgb.nil?
    return false
  end

  rgb = rgb.split('_')
  r = rgb[0].to_i
  g = rgb[1].to_i
  b = rgb[2].to_i
  rendering_color = OpenStudio::Model::RenderingColor.new(space_type.model)
  rendering_color.setName(space_type.name.get)
  rendering_color.setRenderingRedValue(r)
  rendering_color.setRenderingGreenValue(g)
  rendering_color.setRenderingBlueValue(b)
  space_type.setRenderingColor(rendering_color)

  return true
end

#space_type_get_construction_properties(space_type, intended_surface_type, standards_construction_type) ⇒ hash

Returns standards data for selected construction

Parameters:

  • intended_surface_type (string)

    the type of surface

  • standards_construction_type (string)

    the type of construction

Returns:

  • (hash)

    hash of construction properties



567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
# File 'lib/openstudio-standards/standards/Standards.SpaceType.rb', line 567

def space_type_get_construction_properties(space_type, intended_surface_type, standards_construction_type)
  # get building_category value
  building_category = if !space_type_get_standards_data(space_type).nil? && space_type_get_standards_data(space_type)['is_residential'] == 'Yes'
                        'Residential'
                      else
                        'Nonresidential'
                      end

  # get climate_zone_set
  climate_zone = model_get_building_climate_zone_and_building_type(space_type.model)['climate_zone']
  climate_zone_set = model_find_climate_zone_set(space_type.model, climate_zone)

  # populate search hash
  search_criteria = {
    'template' => template,
    'climate_zone_set' => climate_zone_set,
    'intended_surface_type' => intended_surface_type,
    'standards_construction_type' => standards_construction_type,
    'building_category' => building_category
  }

  # switch to use this but update test in standards and measures to load this outside of the method
  construction_properties = model_find_object(standards_data['construction_properties'], search_criteria)

  return construction_properties
end

#space_type_get_standards_data(space_type) ⇒ hash

Returns standards data for selected space type and template

Returns:

  • (hash)

    hash of internal loads for different load types



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/openstudio-standards/standards/Standards.SpaceType.rb', line 7

def space_type_get_standards_data(space_type)
  standards_building_type = if space_type.standardsBuildingType.is_initialized
                              space_type.standardsBuildingType.get
                            end
  standards_space_type = if space_type.standardsSpaceType.is_initialized
                           space_type.standardsSpaceType.get
                         end

  # populate search hash
  search_criteria = {
    'template' => template,
    'building_type' => standards_building_type,
    'space_type' => standards_space_type
  }

  # lookup space type properties
  space_type_properties = model_find_object(standards_data['space_types'], search_criteria)

  if space_type_properties.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.SpaceType', "Space type properties lookup failed: #{search_criteria}.")
    space_type_properties = {}
  end

  return space_type_properties
end

#spaces_get_occupancy_schedule(spaces, sch_name: nil, occupied_percentage_threshold: nil, threshold_calc_method: 'value') ⇒ <OpenStudio::Model::ScheduleRuleset>

TODO:

Speed up this method. Bottleneck is ScheduleRule.getDaySchedules

This method creates a new fractional schedule ruleset. If occupied_percentage_threshold is set, this method will return a discrete on/off fractional schedule with a value of one when occupancy across all spaces is greater than or equal to the occupied_percentage_threshold, and zero all other times. Otherwise the method will return the weighted fractional occupancy schedule.

fractional passes raw value through, normalized_annual_range evaluates each value against the min/max range for the year normalized_daily_range evaluates each value against the min/max range for the day. The goal is a dynamic threshold that calibrates each day.

Parameters:

  • spaces (Array<OpenStudio::Model::Space>)

    array of spaces to generate occupancy schedule from

  • sch_name (String) (defaults to: nil)

    the name of the generated occupancy schedule

  • occupied_percentage_threshold (Double) (defaults to: nil)

    the minimum fraction (0 to 1) that counts as occupied if this parameter is set, the returned ScheduleRuleset will be 0 = unoccupied, 1 = occupied otherwise the ScheduleRuleset will be the weighted fractional occupancy schedule based on threshold_calc_method

  • threshold_calc_method (String) (defaults to: 'value')

    customizes behavior of occupied_percentage_threshold

Returns:

  • (<OpenStudio::Model::ScheduleRuleset>)

    a ScheduleRuleset of fractional or discrete occupancy



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 229

def spaces_get_occupancy_schedule(spaces, sch_name: nil, occupied_percentage_threshold: nil, threshold_calc_method: 'value')
  annual_normalized_tol = nil
  if threshold_calc_method == 'normalized_annual_range'
    # run this method without threshold to get annual min and max
    temp_merged = spaces_get_occupancy_schedule(spaces)
    tem_min_max = schedule_ruleset_annual_min_max_value(temp_merged)
    annual_normalized_tol = tem_min_max['min'] + (tem_min_max['max'] - tem_min_max['min']) * occupied_percentage_threshold
    temp_merged.remove
  end
  # Get all the occupancy schedules in spaces.
  # Include people added via the SpaceType and hard-assigned to the Space itself.
  occ_schedules_num_occ = {}
  max_occ_in_spaces = 0
  spaces.each do |space|
    # From the space type
    if space.spaceType.is_initialized
      space.spaceType.get.people.each do |people|
        num_ppl_sch = people.numberofPeopleSchedule
        if num_ppl_sch.is_initialized
          num_ppl_sch = num_ppl_sch.get
          num_ppl_sch = num_ppl_sch.to_ScheduleRuleset
          next if num_ppl_sch.empty? # Skip non-ruleset schedules

          num_ppl_sch = num_ppl_sch.get
          num_ppl = people.getNumberOfPeople(space.floorArea)
          if occ_schedules_num_occ[num_ppl_sch].nil?
            occ_schedules_num_occ[num_ppl_sch] = num_ppl
          else
            occ_schedules_num_occ[num_ppl_sch] += num_ppl
          end
          max_occ_in_spaces += num_ppl
        end
      end
    end
    # From the space
    space.people.each do |people|
      num_ppl_sch = people.numberofPeopleSchedule
      if num_ppl_sch.is_initialized
        num_ppl_sch = num_ppl_sch.get
        num_ppl_sch = num_ppl_sch.to_ScheduleRuleset
        next if num_ppl_sch.empty? # Skip non-ruleset schedules

        num_ppl_sch = num_ppl_sch.get
        num_ppl = people.getNumberOfPeople(space.floorArea)
        if occ_schedules_num_occ[num_ppl_sch].nil?
          occ_schedules_num_occ[num_ppl_sch] = num_ppl
        else
          occ_schedules_num_occ[num_ppl_sch] += num_ppl
        end
        max_occ_in_spaces += num_ppl
      end
    end
  end

  unless sch_name.nil?
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "Finding space schedules for #{sch_name}.")
  end
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "The #{spaces.size} spaces have #{occ_schedules_num_occ.size} unique occ schedules.")
  occ_schedules_num_occ.each do |occ_sch, num_occ|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "...#{occ_sch.name} - #{num_occ.round} people")
  end
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "   Total #{max_occ_in_spaces.round} people in #{spaces.size} spaces.")

  # Store arrays of 365 day schedules used by each occ schedule once for later
  # Store arrays of day schedule times for later
  occ_schedules_day_schedules = {}
  day_schedule_times = {}
  year = spaces[0].model.getYearDescription
  first_date_of_year = year.makeDate(1)
  end_date_of_year = year.makeDate(365)
  occ_schedules_num_occ.each do |occ_sch, num_occ|
    day_schedules = occ_sch.getDaySchedules(first_date_of_year, end_date_of_year)
    # Store array of day schedules
    occ_schedules_day_schedules[occ_sch] = day_schedules
    day_schedules.uniq.each do |day_sch|
      # Skip schedules that have been stored previously
      next unless day_schedule_times[day_sch].nil?

      # Store times
      times = []
      day_sch.times.each do |time|
        times << time.toString
      end
      day_schedule_times[day_sch] = times
    end
  end

  # For each day of the year, determine time_value_pairs = []
  yearly_data = []
  (1..365).each do |i|
    times_on_this_day = []
    os_date = year.makeDate(i)
    day_of_week = os_date.dayOfWeek.valueName

    # Get the unique time indices and corresponding day schedules
    day_sch_num_occ = {}
    occ_schedules_num_occ.each do |occ_sch, num_occ|
      daily_sch = occ_schedules_day_schedules[occ_sch][i - 1]
      times_on_this_day += day_schedule_times[daily_sch]
      day_sch_num_occ[daily_sch] = num_occ
    end

    daily_normalized_tol = nil
    if threshold_calc_method == 'normalized_daily_range'
      # pre-process day to get daily min and max
      daily_spaces_occ_frac = []
      times_on_this_day.uniq.sort.each do |time|
        os_time = OpenStudio::Time.new(time)
        # Total number of people at each time
        tot_occ_at_time = 0
        day_sch_num_occ.each do |day_sch, num_occ|
          occ_frac = day_sch.getValue(os_time)
          tot_occ_at_time += occ_frac * num_occ
        end
        # Total fraction for the spaces at each time
        daily_spaces_occ_frac << tot_occ_at_time / max_occ_in_spaces
        daily_normalized_tol = daily_spaces_occ_frac.min + (daily_spaces_occ_frac.max - daily_spaces_occ_frac.min) * occupied_percentage_threshold
      end
    end

    # Determine the total fraction for the spaces at each time
    daily_times = []
    daily_os_times = []
    daily_values = []
    daily_occs = []
    times_on_this_day.uniq.sort.each do |time|
      os_time = OpenStudio::Time.new(time)
      # Total number of people at each time
      tot_occ_at_time = 0
      day_sch_num_occ.each do |day_sch, num_occ|
        occ_frac = day_sch.getValue(os_time)
        tot_occ_at_time += occ_frac * num_occ
      end

      # Total fraction for the spaces at each time,
      # rounded to avoid decimal precision issues
      spaces_occ_frac = (tot_occ_at_time / max_occ_in_spaces).round(3)

      # If occupied_percentage_threshold is specified, schedule values are boolean
      # Otherwise use the actual spaces_occ_frac
      if occupied_percentage_threshold.nil?
        occ_status = spaces_occ_frac
      elsif threshold_calc_method == 'normalized_annual_range'
        occ_status = 0 # unoccupied
        if spaces_occ_frac >= annual_normalized_tol
          occ_status = 1
        end
      elsif threshold_calc_method == 'normalized_daily_range'
        occ_status = 0 # unoccupied
        if spaces_occ_frac > daily_normalized_tol
          occ_status = 1
        end
      else
        occ_status = 0 # unoccupied
        if spaces_occ_frac >= occupied_percentage_threshold
          occ_status = 1
        end
      end

      # Add this data to the daily arrays
      daily_times << time
      daily_os_times << os_time
      daily_values << occ_status
      daily_occs << spaces_occ_frac.round(2)
    end

    # Simplify the daily times to eliminate intermediate points with the same value as the following point
    simple_daily_times = []
    simple_daily_os_times = []
    simple_daily_values = []
    simple_daily_occs = []
    daily_values.each_with_index do |value, j|
      next if value == daily_values[j + 1]

      simple_daily_times << daily_times[j]
      simple_daily_os_times << daily_os_times[j]
      simple_daily_values << daily_values[j]
      simple_daily_occs << daily_occs[j]
    end

    # Store the daily values
    yearly_data << { 'date' => os_date, 'day_of_week' => day_of_week, 'times' => simple_daily_times, 'values' => simple_daily_values, 'daily_os_times' => simple_daily_os_times, 'daily_occs' => simple_daily_occs }
  end

  # Create a TimeSeries from the data
  # time_series = OpenStudio::TimeSeries.new(times, values, 'unitless')
  # Make a schedule ruleset
  if sch_name.nil?
    sch_name = "#{spaces.size} space(s) Occ Sch"
  end
  sch_ruleset = OpenStudio::Model::ScheduleRuleset.new(spaces[0].model)
  sch_ruleset.setName(sch_name.to_s)
  # add properties to schedule
  props = sch_ruleset.additionalProperties
  props.setFeature('max_occ_in_spaces', max_occ_in_spaces)
  props.setFeature('number_of_spaces_included', spaces.size)
  # nothing uses this but can make user be aware if this may be out of sync with current state of occupancy profiles
  props.setFeature('date_parent_object_last_edited', Time.now.getgm.to_s)
  props.setFeature('date_parent_object_created', Time.now.getgm.to_s)

  # Default - All Occupied
  day_sch = sch_ruleset.defaultDaySchedule
  day_sch.setName("#{sch_name} Default")
  day_sch.addValue(OpenStudio::Time.new(0, 24, 0, 0), 1)

  # Winter Design Day - All Occupied
  day_sch = OpenStudio::Model::ScheduleDay.new(spaces[0].model)
  sch_ruleset.setWinterDesignDaySchedule(day_sch)
  day_sch = sch_ruleset.winterDesignDaySchedule
  day_sch.setName("#{sch_name} Winter Design Day")
  day_sch.addValue(OpenStudio::Time.new(0, 24, 0, 0), 1)

  # Summer Design Day - All Occupied
  day_sch = OpenStudio::Model::ScheduleDay.new(spaces[0].model)
  sch_ruleset.setSummerDesignDaySchedule(day_sch)
  day_sch = sch_ruleset.summerDesignDaySchedule
  day_sch.setName("#{sch_name} Summer Design Day")
  day_sch.addValue(OpenStudio::Time.new(0, 24, 0, 0), 1)

  # Create ruleset schedules, attempting to create the minimum number of unique rules
  ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'].each do |weekday|
    end_of_prev_rule = yearly_data[0]['date']
    yearly_data.each_with_index do |daily_data, k|
      # Skip unless it is the day of week
      # currently under inspection
      day = daily_data['day_of_week']
      next unless day == weekday

      date = daily_data['date']
      times = daily_data['times']
      values = daily_data['values']
      daily_os_times = daily_data['daily_os_times']

      # If the next (Monday, Tuesday, etc.) is the same as today, keep going
      # If the next is different, or if we've reached the end of the year, create a new rule
      unless yearly_data[k + 7].nil?
        next_day_times = yearly_data[k + 7]['times']
        next_day_values = yearly_data[k + 7]['values']
        next if times == next_day_times && values == next_day_values
      end

      # If here, we need to make a rule to cover from the previous rule to today
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "Making a new rule for #{weekday} from #{end_of_prev_rule} to #{date}")
      sch_rule = OpenStudio::Model::ScheduleRule.new(sch_ruleset)
      sch_rule.setName("#{sch_name} #{weekday} Rule")
      day_sch = sch_rule.daySchedule
      day_sch.setName("#{sch_name} #{weekday}")
      daily_os_times.each_with_index do |time, t|
        value = values[t]
        next if value == values[t + 1] # Don't add breaks if same value

        day_sch.addValue(time, value)
      end

      # Set the dates when the rule applies
      sch_rule.setStartDate(end_of_prev_rule)
      # for end dates in last week of year force it to use 12/31. Avoids issues if year or start day of week changes
      start_of_last_week = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('December'), 25, year.assumedYear)
      if date >= start_of_last_week
        year_end_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new('December'), 31, year.assumedYear)
        sch_rule.setEndDate(year_end_date)
      else
        sch_rule.setEndDate(date)
      end

      # Individual Days
      sch_rule.setApplyMonday(true) if weekday == 'Monday'
      sch_rule.setApplyTuesday(true) if weekday == 'Tuesday'
      sch_rule.setApplyWednesday(true) if weekday == 'Wednesday'
      sch_rule.setApplyThursday(true) if weekday == 'Thursday'
      sch_rule.setApplyFriday(true) if weekday == 'Friday'
      sch_rule.setApplySaturday(true) if weekday == 'Saturday'
      sch_rule.setApplySunday(true) if weekday == 'Sunday'

      # Reset the previous rule end date
      end_of_prev_rule = date + OpenStudio::Time.new(0, 24, 0, 0)
    end
  end

  # utilize default profile and common similar days of week for same date range
  # todo - if move to method in Standards.ScheduleRuleset.rb udpate code to check if default profile is used before replacing it with lowest priority rule.
  # todo - also merging non adjacent priority rules without getting rid of any rules between the two could create unexpected reults
  prior_rules = []
  sch_ruleset.scheduleRules.each do |rule|
    if prior_rules.empty?
      prior_rules << rule
      next
    else
      rules_combined = false
      prior_rules.each do |prior_rule|
        # see if they are similar
        next if rules_combined
        # TODO: update to combine adjacent date ranges vs. just matching date ranges
        next if prior_rule.startDate.get != rule.startDate.get
        next if prior_rule.endDate.get != rule.endDate.get
        next if prior_rule.daySchedule.times.to_a != rule.daySchedule.times.to_a
        next if prior_rule.daySchedule.values.to_a != rule.daySchedule.values.to_a

        # combine dates of week
        if rule.applyMonday then prior_rule.setApplyMonday(true) && rules_combined = true end
        if rule.applyTuesday then prior_rule.setApplyTuesday(true) && rules_combined = true end
        if rule.applyWednesday then prior_rule.setApplyWednesday(true) && rules_combined = true end
        if rule.applyThursday then prior_rule.setApplyThursday(true) && rules_combined = true end
        if rule.applyFriday then prior_rule.setApplyFriday(true) && rules_combined = true end
        if rule.applySaturday then prior_rule.setApplySaturday(true) && rules_combined = true end
        if rule.applySunday then prior_rule.setApplySunday(true) && rules_combined = true end
      end
      rules_combined ? rule.remove : prior_rules << rule
    end
  end
  # replace unused default profile with lowest priority rule
  values = prior_rules.last.daySchedule.values
  times = prior_rules.last.daySchedule.times
  prior_rules.last.remove
  sch_ruleset.defaultDaySchedule.clearValues
  values.size.times do |i|
    sch_ruleset.defaultDaySchedule.addValue(times[i], values[i])
  end

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "Created #{sch_ruleset.name} with #{schedule_ruleset_annual_equivalent_full_load_hrs(sch_ruleset)} annual EFLH.")

  return sch_ruleset
end

#spaces_hours_of_operation(spaces) ⇒ Hash

If the model has an hours of operation schedule set in default schedule set for building that looks valid it will report hours of operation. Won’t be a single set of values, will be a collection of rules this will call space_hours_of_operation on each space in array loop through all days of year to make as many rules as ncessary expand hours of operation. When hours of operation do not overlap for two spaces, add logic to remove all but largest gap

Parameters:

  • space (Spaces)

    takes array of spaces

Returns:

  • (Hash)

    start and end of hours of operation, stat date, end date, bool for each day of the week

Author:

  • David Goldwasser



1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1834

def spaces_hours_of_operation(spaces)
  hours_of_operation_array = []
  space_names = []
  spaces.each do |space|
    space_names << space.name.to_s
    hoo_hash = space_hours_of_operation(space)
    if !hoo_hash.nil?
      # OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "For #{space.name}, hours of operation hash = #{hoo_hash}.")
      hours_of_operation_array << hoo_hash
    end
  end

  # TODO: - replace this with logic to get combined hours of operation for collection of spaces.
  # each hours_of_operation_array is hash with key for each profile.
  # each profile has hash with keys for hoo_start, hoo_end, hoo_hours, days_used
  # my goal is to compare profiles and days used across all profiles to create new entries as necessary
  # then for all days I need to extend hours of operation addressing any situations where multile occupancy gaps occur
  #
  # loop through all 365/366 days

  # OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Space', "Evaluating hours of operation for #{space_names.join(',')}: #{hours_of_operation_array}")

  # TODO: - what is this getting max of, it isn't longest hours of operation, is it the most profiles?
  hours_of_operation = hours_of_operation_array.max_by { |i| hours_of_operation_array.count(i) }

  return hours_of_operation
end

#standard_design_sizing_temperaturesHash

Returns Hash of design sizing temperature lookups.

Returns:

  • (Hash)

    Hash of design sizing temperature lookups



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 7

def standard_design_sizing_temperatures
  dsgn_temps = {}
  dsgn_temps['prehtg_dsgn_sup_air_temp_f'] = 45.0
  dsgn_temps['preclg_dsgn_sup_air_temp_f'] = 55.0
  dsgn_temps['htg_dsgn_sup_air_temp_f'] = 55.0
  dsgn_temps['clg_dsgn_sup_air_temp_f'] = 55.0
  dsgn_temps['zn_htg_dsgn_sup_air_temp_f'] = 104.0
  dsgn_temps['zn_clg_dsgn_sup_air_temp_f'] = 55.0
  dsgn_temps['prehtg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['prehtg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['preclg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['preclg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['htg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['clg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['clg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['zn_htg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_htg_dsgn_sup_air_temp_f'], 'F', 'C').get
  dsgn_temps['zn_clg_dsgn_sup_air_temp_c'] = OpenStudio.convert(dsgn_temps['zn_clg_dsgn_sup_air_temp_f'], 'F', 'C').get
  return dsgn_temps
end

#standards_lookup_table_first(table_name:, search_criteria: {}, capacity: nil, date: nil) ⇒ Hash

Method to search through a hash for an object that meets the desired search criteria, as passed via a hash. If capacity is supplied, the object will only be returned if the specified capacity is between the minimum_capacity and maximum_capacity values.

Examples:

Find the motor that meets these size criteria

search_criteria = {
'template' => template,
'number_of_poles' => 4.0,
'type' => 'Enclosed',
}
motor_properties = self.model.find_object(motors, search_criteria, 2.5)

Parameters:

  • table_name (String)

    name of table

  • search_criteria (Hash) (defaults to: {})

    hash of search criteria

  • capacity (Double) (defaults to: nil)

    capacity of the object in question. If capacity is supplied, the objects will only be returned if the specified capacity is between the minimum_capacity and maximum_capacity values.

  • date (<OpenStudio::Date>) (defaults to: nil)

    date of the object in question. If date is supplied, the objects will only be returned if the specified date is between the start_date and end_date.

  • area (Double)

    area of the object in question. If area is supplied, the objects will only be returned if the specified area is between the minimum_area and maximum_area values.

  • num_floors (Double)

    capacity of the object in question. If num_floors is supplied, the objects will only be returned if the specified num_floors is between the minimum_floors and maximum_floors values.

Returns:

  • (Hash)

    Return tbe first matching object hash if successful, nil if not.



1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1914

def standards_lookup_table_first(table_name:, search_criteria: {}, capacity: nil, date: nil)
  # run the many version of the look up code...DRY.
  matching_objects = standards_lookup_table_many(table_name: table_name,
                                                 search_criteria: search_criteria,
                                                 capacity: capacity,
                                                 date: date)

  # Check the number of matching objects found
  if matching_objects.size.zero?
    desired_object = nil
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "Find object search criteria returned no results. Search criteria: #{search_criteria}. Called from #{caller(0)[1]}")
  elsif matching_objects.size == 1
    desired_object = matching_objects[0]
  else
    desired_object = matching_objects[0]
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Model', "Find object search criteria returned #{matching_objects.size} results, the first one will be returned. Called from #{caller(0)[1]}. \n Search criteria: \n #{search_criteria}, capacity = #{capacity} \n  All results: \n#{matching_objects.join("\n")}")
  end

  return desired_object
end

#standards_lookup_table_many(table_name:, search_criteria: {}, capacity: nil, date: nil, area: nil, num_floors: nil) ⇒ Array

Method to search through a hash for the objects that meets the desired search criteria, as passed via a hash. Returns an Array (empty if nothing found) of matching objects.

Examples:

Find all the schedule rules that match the name

rules = model_find_objects(standards_data['schedules'], 'name' => schedule_name)
if rules.size.zero?
  OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Cannot find data for schedule: #{schedule_name}, will not be created.")
  return false
end

Parameters:

  • table_name (Hash)

    name of table in standards database.

  • search_criteria (Hash) (defaults to: {})

    hash of search criteria

  • capacity (Double) (defaults to: nil)

    capacity of the object in question. If capacity is supplied, the objects will only be returned if the specified capacity is between the minimum_capacity and maximum_capacity values.

  • date (<OpenStudio::Date>) (defaults to: nil)

    date of the object in question. If date is supplied, the objects will only be returned if the specified date is between the start_date and end_date.

  • area (Double) (defaults to: nil)

    area of the object in question. If area is supplied, the objects will only be returned if the specified area is between the minimum_area and maximum_area values.

  • num_floors (Double) (defaults to: nil)

    capacity of the object in question. If num_floors is supplied, the objects will only be returned if the specified num_floors is between the minimum_floors and maximum_floors values.

Returns:

  • (Array)

    returns an array of hashes, one hash per object. Array is empty if no results.



1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1772

def standards_lookup_table_many(table_name:, search_criteria: {}, capacity: nil, date: nil, area: nil, num_floors: nil)
  desired_object = nil
  search_criteria_matching_objects = []
  matching_objects = []
  hash_of_objects = @standards_data[table_name]

  # needed for NRCan data structure compatibility. We keep all tables in a 'tables' hash in @standards_data and the table
  # itself is in the 'table' hash index.
  if hash_of_objects.nil?
    if @standards_data['tables'].nil?
      # Format of @standards_data is not NRCan-style and table simply doesn't exist.
      return matching_objects
    else
      table = @standards_data['tables'][table_name]['table']
      hash_of_objects = table
    end
  end

  # Compare each of the objects against the search criteria
  hash_of_objects.each do |object|
    meets_all_search_criteria = true
    search_criteria.each do |key, value|
      # Don't check non-existent search criteria
      next unless object.key?(key)

      # Stop as soon as one of the search criteria is not met
      # 'Any' is a special key that matches anything
      unless object[key] == value || object[key] == 'Any'
        meets_all_search_criteria = false
        break
      end
    end
    # Skip objects that don't meet all search criteria
    next unless meets_all_search_criteria

    # If made it here, object matches all search criteria
    matching_objects << object
  end

  # If capacity was specified, narrow down the matching objects
  unless capacity.nil?
    # Skip objects that don't have fields for minimum_capacity and maximum_capacity
    matching_objects = matching_objects.reject { |object| !object.key?('minimum_capacity') || !object.key?('maximum_capacity') }

    # Skip objects that don't have values specified for minimum_capacity and maximum_capacity
    matching_objects = matching_objects.reject { |object| object['minimum_capacity'].nil? || object['maximum_capacity'].nil? }

    # Round up if capacity is an integer
    if capacity == capacity.round
      capacity += (capacity * 0.01)
    end
    # Skip objects whose the minimum capacity is below or maximum capacity above the specified capacity
    matching_capacity_objects = matching_objects.reject { |object| capacity.to_f <= object['minimum_capacity'].to_f || capacity.to_f > object['maximum_capacity'].to_f }

    # If no object was found, round the capacity down in case the number fell between the limits in the json file.
    if matching_capacity_objects.size.zero?
      capacity *= 0.99
      search_criteria_matching_objects.each do |object|
        # Skip objects that don't have fields for minimum_capacity and maximum_capacity
        next if !object.key?('minimum_capacity') || !object.key?('maximum_capacity')
        # Skip objects that don't have values specified for minimum_capacity and maximum_capacity
        next if object['minimum_capacity'].nil? || object['maximum_capacity'].nil?
        # Skip objects whose the minimum capacity is below the specified capacity
        next if capacity <= object['minimum_capacity'].to_f
        # Skip objects whose max
        next if capacity > object['maximum_capacity'].to_f

        # Found a matching object
        matching_objects << object
      end
    end
    # If date was specified, narrow down the matching objects
    unless date.nil?
      date_matching_objects = []
      matching_objects.each do |object|
        # Skip objects that don't have fields for minimum_capacity and maximum_capacity
        next if !object.key?('start_date') || !object.key?('end_date')
        # Skip objects whose the start date is earlier than the specified date
        next if date <= Date.parse(object['start_date'])
        # Skip objects whose end date is beyond the specified date
        next if date > Date.parse(object['end_date'])

        # Found a matching object
        date_matching_objects << object
      end
      matching_objects = date_matching_objects
    end
  end

  # If area was specified, narrow down the matching objects
  unless area.nil?
    # Skip objects that don't have fields for minimum_area and maximum_area
    matching_objects = matching_objects.reject { |object| !object.key?('minimum_area') || !object.key?('maximum_area') }

    # Skip objects that don't have values specified for minimum_area and maximum_area
    matching_objects = matching_objects.reject { |object| object['minimum_area'].nil? || object['maximum_area'].nil? }

    # Skip objects whose minimum area is below or maximum area is above area
    matching_objects = matching_objects.reject { |object| area.to_f <= object['minimum_area'].to_f || area.to_f > object['maximum_area'].to_f }
  end

  # If area was specified, narrow down the matching objects
  unless num_floors.nil?
    # Skip objects that don't have fields for minimum_floors and maximum_floors
    matching_objects = matching_objects.reject { |object| !object.key?('minimum_floors') || !object.key?('maximum_floors') }

    # Skip objects that don't have values specified for minimum_floors and maximum_floors
    matching_objects = matching_objects.reject { |object| object['minimum_floors'].nil? || object['maximum_floors'].nil? }

    # Skip objects whose minimum floors is below or maximum floors is above num_floors
    matching_objects = matching_objects.reject { |object| num_floors.to_f < object['minimum_floors'].to_f || num_floors.to_f > object['maximum_floors'].to_f }
  end

  # Check the number of matching objects found
  if matching_objects.size.zero?
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "Find objects search criteria returned no results. Search criteria: #{search_criteria}. Called from #{caller(0)[1]}.")
  end

  return matching_objects
end

#strip_model(model) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 35

def strip_model(model)
  # remove all materials
  model.getMaterials.each(&:remove)

  # remove all constructions
  model.getConstructions.each(&:remove)

  # remove performance curves
  model.getCurves.each do |curve|
    model.removeObject(curve.handle)
  end

  # remove all zone equipment
  model.getThermalZones.sort.each do |zone|
    zone.equipment.each(&:remove)
  end

  # remove all thermostats
  model.getThermostatSetpointDualSetpoints.each(&:remove)

  # remove all people
  model.getPeoples.each(&:remove)
  model.getPeopleDefinitions.each(&:remove)

  # remove all lights
  model.getLightss.each(&:remove)
  model.getLightsDefinitions.each(&:remove)

  # remove all electric equipment
  model.getElectricEquipments.each(&:remove)
  model.getElectricEquipmentDefinitions.each(&:remove)

  # remove all gas equipment
  model.getGasEquipments.each(&:remove)
  model.getGasEquipmentDefinitions.each(&:remove)

  # remove all outdoor air
  model.getDesignSpecificationOutdoorAirs.each(&:remove)

  # remove all infiltration
  model.getSpaceInfiltrationDesignFlowRates.each(&:remove)

  # Remove all internal mass
  model.getInternalMasss.each(&:remove)

  # Remove all internal mass defs
  model.getInternalMassDefinitions.each(&:remove)

  # Remove all thermal zones
  model.getThermalZones.each(&:remove)

  # Remove all schedules
  model.getSchedules.each(&:remove)

  # Remove all schedule type limits
  model.getScheduleTypeLimitss.each(&:remove)

  # Remove the sizing parameters
  model.getSizingParameters.remove

  # Remove the design days
  model.getDesignDays.each(&:remove)

  # Remove the rendering colors
  model.getRenderingColors.each(&:remove)

  # Remove the daylight controls
  model.getDaylightingControls.each(&:remove)

  return model
end

#sub_surface_component_infiltration_rate(sub_surface, type) ⇒ Double

Determine the component infiltration rate for this surface

Parameters:

  • type (String)

    choices are ‘baseline’ and ‘advanced’

Returns:

  • (Double)

    infiltration rate @units cubic meters per second (m^3/s)



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/openstudio-standards/standards/Standards.SubSurface.rb', line 9

def sub_surface_component_infiltration_rate(sub_surface, type)
  comp_infil_rate_m3_per_s = 0.0

  # Define the envelope component infiltration rates
  component_infil_rates_cfm_per_ft2 = {
    'baseline' => {
      'opaque_door' => 0.40,
      'loading_dock_door' => 0.40,
      'swinging_or_revolving_glass_door' => 1.0,
      'vestibule' => 1.0,
      'sliding_glass_door' => 0.40,
      'window' => 0.40,
      'skylight' => 0.40
    },
    'advanced' => {
      'opaque_door' => 0.20,
      'loading_dock_door' => 0.20,
      'swinging_or_revolving_glass_door' => 1.0,
      'vestibule' => 1.0,
      'sliding_glass_door' => 0.20,
      'window' => 0.20,
      'skylight' => 0.20
    }
  }

  boundary_condition = sub_surface.outsideBoundaryCondition
  # Skip non-outdoor surfaces
  return comp_infil_rate_m3_per_s unless outsideBoundaryCondition == 'Outdoors' || sub_surface.outsideBoundaryCondition == 'Ground'

  # Per area infiltration rate for this surface
  surface_type = sub_surface.subSurfaceType
  infil_rate_cfm_per_ft2 = nil
  case boundary_condition
  when 'Outdoors'
    case surface_type
    when 'Door'
      infil_rate_cfm_per_ft2 = component_infil_rates_cfm_per_ft2[type]['opaque_door']
    when 'OverheadDoor'
      infil_rate_cfm_per_ft2 = component_infil_rates_cfm_per_ft2[type]['loading_dock_door']
    when 'GlassDoor'
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.Standards.Model', "For #{sub_surface.name}, assuming swinging_or_revolving_glass_door for infiltration calculation.")
      infil_rate_cfm_per_ft2 = component_infil_rates_cfm_per_ft2[type]['swinging_or_revolving_glass_door']
    when 'FixedWindow', 'OperableWindow'
      infil_rate_cfm_per_ft2 = component_infil_rates_cfm_per_ft2[type]['window']
    when 'Skylight', 'TubularDaylightDome', 'TubularDaylightDiffuser'
      infil_rate_cfm_per_ft2 = component_infil_rates_cfm_per_ft2[type]['skylight']
    end
  end
  if infil_rate_cfm_per_ft2.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Standards.Model', "For #{sub_surface.name}, could not determine surface type for infiltration, will not be included in calculation.")
    return comp_infil_rate_m3_per_s
  end

  # Area of the surface
  area_m2 = sub_surface.netArea
  area_ft2 = OpenStudio.convert(area_m2, 'm^2', 'ft^2').get

  # Rate for this surface
  comp_infil_rate_cfm = area_ft2 * infil_rate_cfm_per_ft2

  comp_infil_rate_m3_per_s = OpenStudio.convert(comp_infil_rate_cfm, 'cfm', 'm^3/s').get

  # OpenStudio::logFree(OpenStudio::Debug, "openstudio.Standards.Model", "......#{self.name}, infil = #{comp_infil_rate_cfm.round(2)} cfm @ rate = #{infil_rate_cfm_per_ft2} cfm/ft2, area = #{area_ft2.round} ft2.")

  return comp_infil_rate_m3_per_s
end

#sub_surface_create_centered_subsurface_from_scaled_surface(surface, area_fraction, model) ⇒ Object

This method adds a subsurface (a window or a skylight depending on the surface) to the centroid of a surface. The shape of the subsurface is the same as the surface but is scaled so the area of the subsurface is the defined fraction of the surface (set by area_fraction). Note that this only works for surfaces that do not fold into themselves (like an ‘L’ or a ‘V’).



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/openstudio-standards/standards/Standards.SubSurface.rb', line 191

def sub_surface_create_centered_subsurface_from_scaled_surface(surface, area_fraction, model)
  # Get rid of all existing subsurfaces.
  remove_All_Subsurfaces(surface: surface)
  # What is the centroid of the surface.
  surf_cent = surface.centroid
  scale_factor = Math.sqrt(area_fraction)

  # Create an array to collect the new vertices
  new_vertices = []

  # Loop on vertices (Point3ds)
  surface.vertices.each do |vertex|
    # Point3d - Point3d = Vector3d
    # Vector from centroid to vertex (GA, GB, GC, etc)
    centroid_vector = vertex - surf_cent

    # Resize the vector (done in place) according to scale_factor
    centroid_vector.setLength(centroid_vector.length * scale_factor)

    # Move the vertex toward the centroid
    new_vertex = surf_cent + centroid_vector

    # Add the new vertices to an array of vertices.
    new_vertices << new_vertex
  end
  # Create a new subsurface with the vertices determined above.
  new_sub_surface = OpenStudio::Model::SubSurface.new(new_vertices, model)
  # Put this sub-surface on the surface.
  new_sub_surface.setSurface(surface)
  # Set the name of the subsurface to be the surface name plus the subsurface type (likely either 'fixedwindow' or
  # 'skylight').
  new_name = surface.name.to_s + '_' + new_sub_surface.subSurfaceType.to_s
  new_sub_surface.setName(new_name)
  # There is now only one surface on the subsurface.  Enforce this
  new_sub_surface.setMultiplier(1)
end

#sub_surface_create_scaled_subsurfaces_from_surface(surface:, area_fraction:, model:, consturction:) ⇒ Object

This method adds a subsurface (a window or a skylight depending on the surface) to the centroid of a surface. The shape of the subsurface is the same as the surface but is scaled so the area of the subsurface is the defined fraction of the surface (set by area_fraction). This method is different than the ‘sub_surface_create_centered_subsurface_from_scaled_surface’ method because it can handle concave surfaces. However, it takes longer because it uses BTAP::Geometry::Surfaces.make_convex_surfaces which includes many nested loops that cycle through the verticies in a surface.



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/openstudio-standards/standards/Standards.SubSurface.rb', line 234

def sub_surface_create_scaled_subsurfaces_from_surface(surface:, area_fraction:, model:, consturction:)
  # Set geometry tolerences:
  geometry_tolerence = 12
  # Get rid of all existing subsurfaces.
  remove_All_Subsurfaces(surface: surface)
  # Return vertices of smaller surfaces that fit inside this surface.  This is done in case the surface is
  # concave.

  # Throw an error if the roof is not flat.
  surface.vertices.each do |surf_vert|
    surface.vertices.each do |surf_vert_2|
      unless surf_vert_2.z.to_f.round(geometry_tolerence) == surf_vert.z.to_f.round(geometry_tolerence)
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'Currently skylights can only be added to buildings with non-plenum flat roofs.')
      end
    end
  end
  new_surfaces = BTAP::Geometry::Surfaces.make_convex_surfaces(surface: surface, tol: geometry_tolerence)

  # What is the centroid of the surface.
  new_surf_cents = []
  for i in 0..(new_surfaces.length - 1)
    new_surf_cents << BTAP::Geometry::Surfaces.surf_centroid(surf: new_surfaces[i])
  end

  # Turn everything back into OpenStudio stuff
  os_surf_points = []
  os_surf_cents = []
  for i in 0..(new_surfaces.length - 1)
    os_surf_point = []
    for j in 0..(new_surfaces[i].length - 1)
      os_surf_point << OpenStudio::Point3d.new(new_surfaces[i][j][:x].to_f, new_surfaces[i][j][:y].to_f, new_surfaces[i][j][:z].to_f)
    end
    os_surf_cents << OpenStudio::Point3d.new(new_surf_cents[i][:x].to_f, new_surf_cents[i][:y].to_f, new_surf_cents[i][:z].to_f)
    os_surf_points << os_surf_point
  end
  scale_factor = Math.sqrt(area_fraction)

  new_sub_vertices = []
  os_surf_points.each_with_index do |new_surf, index|
    # Create an array to collect the new vertices
    new_vertices = []
    # Loop on vertices
    new_surf.each do |vertex|
      # Point3d - Point3d = Vector3d
      # Vector from centroid to vertex (GA, GB, GC, etc)
      centroid_vector = vertex - os_surf_cents[index]

      # Resize the vector (done in place) according to scale_factor
      centroid_vector.setLength(centroid_vector.length * scale_factor)

      # Move the vertex toward the centroid
      new_vertex = os_surf_cents[index] + centroid_vector

      # Add the new vertices to an array of vertices.
      new_vertices << new_vertex
    end
    # Create a new subsurface with the vertices determined above.
    new_sub_surface = OpenStudio::Model::SubSurface.new(new_vertices, model)
    # Put this sub-surface on the surface.
    new_sub_surface.setSurface(surface)
    # Set the name of the subsurface to be the surface name plus the subsurface type (likely either 'fixedwindow' or
    # 'skylight').  If there will be more than one subsurface then add a counter at the end.
    new_name = surface.name.to_s + '_' + new_sub_surface.subSurfaceType.to_s
    if new_surfaces.length > 1
      new_name = surface.name.to_s + '_' + new_sub_surface.subSurfaceType.to_s + '_' + index.to_s
    end
    # Set the skylight type to 'Skylight'
    new_sub_surface.setSubSurfaceType('Skylight')
    # Set the skylight construction to whatever was passed (should be the default skylight construction)
    new_sub_surface.setConstruction(consturction)
    new_sub_surface.setName(new_name)
    # There is now only one surface on the subsurface.  Enforce this
    new_sub_surface.setMultiplier(1)
  end
end

#sub_surface_reduce_area_by_percent_by_raising_sill(sub_surface, percent_reduction) ⇒ Object

Reduce the area of the subsurface by raising the sill height.

to reduce the area.

Parameters:

  • percent_reduction (Double)

    the fractional amount



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/openstudio-standards/standards/Standards.SubSurface.rb', line 116

def sub_surface_reduce_area_by_percent_by_raising_sill(sub_surface, percent_reduction)
  mult = 1 - percent_reduction

  # Calculate the original area
  area_original = sub_surface.netArea

  # Find the min and max z values
  min_z_val = 99_999
  max_z_val = -99_999
  sub_surface.vertices.each do |vertex|
    # Min z value
    if vertex.z < min_z_val
      min_z_val = vertex.z
    end
    # Max z value
    if vertex.z > max_z_val
      max_z_val = vertex.z
    end
  end

  # Calculate the window height
  height = max_z_val - min_z_val

  # Calculate the new sill height
  new_sill_z = max_z_val - (height * mult)

  # Reset the z value of the lowest points
  new_vertices = []
  sub_surface.vertices.each do |vertex|
    new_x = vertex.x
    new_y = vertex.y
    new_z = vertex.z
    if new_z == min_z_val
      new_z = new_sill_z
    end
    new_vertices << OpenStudio::Point3d.new(new_x, new_y, new_z)
  end

  # Reset the vertices
  sub_surface.setVertices(new_vertices)

  return true
end

#sub_surface_reduce_area_by_percent_by_shrinking_toward_centroid(sub_surface, percent_reduction) ⇒ Object

Reduce the area of the subsurface by shrinking it toward the centroid. to reduce the area.

Parameters:

  • percent_reduction (Double)

    the fractional amount

Author:

  • Julien Marrec



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/openstudio-standards/standards/Standards.SubSurface.rb', line 82

def sub_surface_reduce_area_by_percent_by_shrinking_toward_centroid(sub_surface, percent_reduction)
  mult = 1 - percent_reduction
  scale_factor = mult**0.5

  # Get the centroid (Point3d)
  g = sub_surface.centroid

  # Create an array to collect the new vertices
  new_vertices = []

  # Loop on vertices (Point3ds)
  sub_surface.vertices.each do |vertex|
    # Point3d - Point3d = Vector3d
    # Vector from centroid to vertex (GA, GB, GC, etc)
    centroid_vector = vertex - g

    # Resize the vector (done in place) according to scale_factor
    centroid_vector.setLength(centroid_vector.length * scale_factor)

    # Move the vertex toward the centroid
    vertex = g + centroid_vector

    new_vertices << vertex
  end

  # Assign the new vertices to the self
  sub_surface.setVertices(new_vertices)
end

#sub_surface_vertical_rectangle?(sub_surface) ⇒ Boolean

Determine if the sub surface is a vertical rectangle, meaning a rectangle where the bottom is parallel to the ground.

Returns:

  • (Boolean)


162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/openstudio-standards/standards/Standards.SubSurface.rb', line 162

def sub_surface_vertical_rectangle?(sub_surface)
  # Get the vertices once
  verts = sub_surface.vertices

  # Check for 4 vertices
  return false unless verts.size == 4

  # Check if the 2 lowest z-values
  # are the same
  z_vals = []
  verts.each do |vertex|
    z_vals << vertex.z
  end
  z_vals = z_vals.sort
  return false unless z_vals[0] == z_vals[1]

  # Check if the diagonals are equal length
  diag_a = verts[0] - verts[2]
  diag_b = verts[1] - verts[3]
  return false unless diag_a.length == diag_b.length

  # If here, we have a rectangle
  return true
end

#surface_absolute_azimuth(surface) ⇒ Float

Parameters:

  • surface (OpenStudio::Model:Surface)

    OpenStudio Surface object

Returns:

  • (Float)

    Surface absolute azimuth



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/openstudio-standards/standards/Standards.Surface.rb', line 364

def surface_absolute_azimuth(surface)
  # Get associated space
  space = surface.space.get

  # Get model object
  model = surface.model

  # Calculate azimuth
  surface_azimuth_rel_space = OpenStudio.convert(surface.azimuth, 'rad', 'deg').get
  space_dir_rel_N = space.directionofRelativeNorth
  building_dir_rel_N = model.getBuilding.northAxis
  surface_abs_azimuth = surface_azimuth_rel_space + space_dir_rel_N + building_dir_rel_N
  surface_abs_azimuth -= 360.0 until surface_abs_azimuth < 360.0

  return surface_abs_azimuth
end

#surface_cardinal_direction(surface) ⇒ String

Determine a surface absolute cardinal direction

Parameters:

  • surface (OpenStudio::Model::Surface)

    OpenStudio Surface object

Returns:

  • (String)

    Surface absolute cardinal



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# File 'lib/openstudio-standards/standards/Standards.Surface.rb', line 385

def surface_cardinal_direction(surface)
  # Get the surface's absolute azimuth
  surface_abs_azimuth = surface_absolute_azimuth(surface)

  # Determine the surface's cardinal direction
  if (surface_abs_azimuth >= 0 && surface_abs_azimuth <= 45) || (surface_abs_azimuth > 315 && surface_abs_azimuth <= 360)
    return 'N'
  elsif surface_abs_azimuth > 45 && surface_abs_azimuth <= 135
    return 'E'
  elsif surface_abs_azimuth > 135 && surface_abs_azimuth <= 225
    return 'S'
  elsif surface_abs_azimuth > 225 && surface_abs_azimuth <= 315
    return 'W'
  end
end

#surface_component_infiltration_rate(surface, type) ⇒ Double

TODO:

handle floors over unconditioned spaces

Determine the component infiltration rate for this surface

Parameters:

  • type (String)

    choices are ‘baseline’ and ‘advanced’

Returns:

  • (Double)

    infiltration rate @units cubic meters per second (m^3/s)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/openstudio-standards/standards/Standards.Surface.rb', line 10

def surface_component_infiltration_rate(surface, type)
  comp_infil_rate_m3_per_s = 0.0

  # Define the envelope component infiltration rates
  component_infil_rates_cfm_per_ft2 = {
    'baseline' => {
      'roof' => 0.12,
      'exterior_wall' => 0.12,
      'below_grade_wall' => 0.12,
      'floor_over_unconditioned' => 0.12,
      'slab_on_grade' => 0.12
    },
    'advanced' => {
      'roof' => 0.04,
      'exterior_wall' => 0.04,
      'below_grade_wall' => 0.04,
      'floor_over_unconditioned' => 0.04,
      'slab_on_grade' => 0.04
    }
  }

  boundary_condition = surface.outsideBoundaryCondition
  # Skip non-outdoor surfaces
  return comp_infil_rate_m3_per_s unless outsideBoundaryCondition == 'Outdoors' || surface.outsideBoundaryCondition == 'Ground'

  # Per area infiltration rate for this surface
  surface_type = surface.surfaceType
  infil_rate_cfm_per_ft2 = nil
  case boundary_condition
  when 'Outdoors'
    case surface_type
    when 'RoofCeiling'
      infil_rate_cfm_per_ft2 = component_infil_rates_cfm_per_ft2[type]['roof']
    when 'Wall'
      infil_rate_cfm_per_ft2 = component_infil_rates_cfm_per_ft2[type]['exterior_wall']
    end
  when 'Ground'
    case surface_type
    when 'Wall'
      infil_rate_cfm_per_ft2 = component_infil_rates_cfm_per_ft2[type]['below_grade_wall']
    when 'Floor'
      infil_rate_cfm_per_ft2 = component_infil_rates_cfm_per_ft2[type]['slab_on_grade']
    end
  when 'TODO Surface'
    case surface_type
    when 'Floor'
      infil_rate_cfm_per_ft2 = component_infil_rates_cfm_per_ft2[type]['floor_over_unconditioned']
    end
  end
  if infil_rate_cfm_per_ft2.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Surface', "For #{surface.name}, could not determine surface type for infiltration, will not be included in calculation.")
    return comp_infil_rate_m3_per_s
  end

  # Area of the surface
  area_m2 = surface.netArea
  area_ft2 = OpenStudio.convert(area_m2, 'm^2', 'ft^2').get

  # Rate for this surface
  comp_infil_rate_cfm = area_ft2 * infil_rate_cfm_per_ft2

  comp_infil_rate_m3_per_s = OpenStudio.convert(comp_infil_rate_cfm, 'cfm', 'm^3/s').get

  # OpenStudio::logFree(OpenStudio::Debug, "openstudio.Standards.Model", "...#{self.name}, infil = #{comp_infil_rate_cfm.round(2)} cfm @ rate = #{infil_rate_cfm_per_ft2} cfm/ft2, area = #{area_ft2.round} ft2.")

  return comp_infil_rate_m3_per_s
end

#surface_replace_existing_subsurfaces_with_centered_subsurface(model, sill_height_m, window_height_m, fdwr) ⇒ Object

Chris Kirney 2018-05-17: Not complete-do not call. Start of method meant to help implement NECB2015 8.4.4.5.(5). The method starts by finding exterior surfaces which help enclose conditioned spaces. It then removes the subsurfaces. Though not implemented yet it was supposed to then put a window centered in the surface with a sill height and window height defined passed via sill_heght_m and window_height_m (0.9 m, and 1.8 m respectively for NECB2015). The width of the window was to be set so that the fdwr matched whatever code said (passed by fdwr).



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/openstudio-standards/standards/Standards.Surface.rb', line 83

def surface_replace_existing_subsurfaces_with_centered_subsurface(model, sill_height_m, window_height_m, fdwr)
  vertical_surfaces = find_exposed_conditioned_vertical_surfaces(model)
  vertical_surfaces.each do |vertical_surface|
    vertical_surface.subSurfaces.sort.each do |vertical_subsurface|
      # Need to fix this so that error show up in right place
      if vertical_subsurface.nil?
        puts 'Surface does not exist'
      else
        vertical_subsurface.remove
      end
    end
    # corner_coords = vertical_surface.vertices
    code_window_area = fdwr * vertical_surface.grossArea
    code_window_width = code_window_area / window_height_m
    min_z = 0
    vertical_surface.vertices.each_with_index do |vertex, index|
      if index == 0
        min_z = vertex.z
      elsif vertex.z < min_z
        min_z = vertex.z
      end
    end
    surface_centroid = vertical_surface.centroid
    surface_normal = vertical_surface.outwardNormal
  end
end

#thermal_eff_to_afue(teff) ⇒ Double

A helper method to convert from thermal efficiency to AFUE

Parameters:

  • teff (Double)

    Thermal Efficiency

Returns:

  • (Double)

    AFUE



378
379
380
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 378

def thermal_eff_to_afue(teff)
  return teff
end

#thermal_eff_to_comb_eff(thermal_eff) ⇒ Double

A helper method to convert from thermal efficiency to combustion efficiency

Parameters:

  • thermal_eff (Double)

    Thermal efficiency

Returns:

  • (Double)

    Combustion efficiency



396
397
398
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 396

def thermal_eff_to_comb_eff(thermal_eff)
  return thermal_eff + 0.007
end

#thermal_zone_add_exhaust(thermal_zone, exhaust_makeup_inputs = {}) ⇒ Hash

TODO:
  • Combine availability and fraction flow schedule to make zone mixing schedule

Add Exhaust Fans based on space type lookup This measure doesn’t look if DCV is needed. Others methods can check if DCV needed and add it

Returns:

  • (Hash)

    Hash of newly made exhaust fan objects along with secondary exhaust and zone mixing objects



1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1698

def thermal_zone_add_exhaust(thermal_zone, exhaust_makeup_inputs = {})
  exhaust_fans = {} # key is primary exhaust value is hash of arrays of secondary objects

  # hash to store space type information
  space_type_hash = {} # key is space type value is floor_area_si

  # get space type ratio for spaces in zone, making more than one exhaust fan if necessary
  thermal_zone.spaces.each do |space|
    next unless space.spaceType.is_initialized
    next unless space.partofTotalFloorArea

    space_type = space.spaceType.get
    if space_type_hash.key?(space_type)
      space_type_hash[space_type] += space.floorArea # excluding space.multiplier since used to calc loads in zone
    else
      next unless space_type.standardsBuildingType.is_initialized
      next unless space_type.standardsSpaceType.is_initialized

      space_type_hash[space_type] = space.floorArea # excluding space.multiplier since used to calc loads in zone
    end
  end

  # loop through space type hash and add exhaust as needed
  space_type_hash.each do |space_type, floor_area|
    # get floor custom or calculated floor area for max flow rate calculation
    makeup_target = [space_type.standardsBuildingType.get, space_type.standardsSpaceType.get]
    if exhaust_makeup_inputs.key?(makeup_target) && exhaust_makeup_inputs[makeup_target].key?(:target_effective_floor_area)
      # pass in custom floor area
      floor_area_si = exhaust_makeup_inputs[makeup_target][:target_effective_floor_area] / thermal_zone.multiplier.to_f
      floor_area_ip = OpenStudio.convert(floor_area_si, 'm^2', 'ft^2').get
    else
      floor_area_ip = OpenStudio.convert(floor_area, 'm^2', 'ft^2').get
    end

    space_type_properties = space_type_get_standards_data(space_type)
    exhaust_per_area = space_type_properties['exhaust_per_area']
    next if exhaust_per_area.nil?

    maximum_flow_rate_ip = exhaust_per_area * floor_area_ip
    maximum_flow_rate_si = OpenStudio.convert(maximum_flow_rate_ip, 'cfm', 'm^3/s').get
    if space_type_properties['exhaust_availability_schedule'].nil?
      exhaust_schedule = thermal_zone.model.alwaysOnDiscreteSchedule
      exhaust_flow_schedule = exhaust_schedule
    else
      sch_name = space_type_properties['exhaust_availability_schedule']
      exhaust_schedule = model_add_schedule(thermal_zone.model, sch_name)
      flow_sch_name = space_type_properties['exhaust_flow_fraction_schedule']
      exhaust_flow_schedule = model_add_schedule(thermal_zone.model, flow_sch_name)
      unless exhaust_schedule
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Standards.ThermalZone', "Could not find an exhaust schedule called #{sch_name}, exhaust fans will run continuously.")
        exhaust_schedule = thermal_zone.model.alwaysOnDiscreteSchedule
      end
    end

    # add exhaust fans
    zone_exhaust_fan = OpenStudio::Model::FanZoneExhaust.new(thermal_zone.model)
    zone_exhaust_fan.setName(thermal_zone.name.to_s + ' Exhaust Fan')
    zone_exhaust_fan.setAvailabilitySchedule(exhaust_schedule)
    zone_exhaust_fan.setFlowFractionSchedule(exhaust_flow_schedule)
    # not using zone_exhaust_fan.setFlowFractionSchedule. Exhaust fans are on when available
    zone_exhaust_fan.setMaximumFlowRate(maximum_flow_rate_si)
    zone_exhaust_fan.setEndUseSubcategory('Zone Exhaust Fans')
    zone_exhaust_fan.addToThermalZone(thermal_zone)
    exhaust_fans[zone_exhaust_fan] = {} # keys are :zone_mixing and :transfer_air_source_zone_exhaust

    # set fan pressure rise
    fan_zone_exhaust_apply_prototype_fan_pressure_rise(zone_exhaust_fan)

    # update efficiency and pressure rise
    prototype_fan_apply_prototype_fan_efficiency(zone_exhaust_fan)

    # add and alter objectxs related to zone exhaust makeup air
    if exhaust_makeup_inputs.key?(makeup_target) && exhaust_makeup_inputs[makeup_target][:source_zone]

      # add balanced schedule to zone_exhaust_fan
      balanced_sch_name = space_type_properties['balanced_exhaust_fraction_schedule']
      balanced_exhaust_schedule = model_add_schedule(thermal_zone.model, balanced_sch_name).to_ScheduleRuleset.get
      zone_exhaust_fan.setBalancedExhaustFractionSchedule(balanced_exhaust_schedule)

      # use max value of balanced exhaust fraction schedule for maximum flow rate
      max_sch_val = schedule_ruleset_annual_min_max_value(balanced_exhaust_schedule)['max']
      transfer_air_zone_mixing_si = maximum_flow_rate_si * max_sch_val

      # add dummy exhaust fan to a transfer_air_source_zones
      transfer_air_source_zone_exhaust = OpenStudio::Model::FanZoneExhaust.new(thermal_zone.model)
      transfer_air_source_zone_exhaust.setName(thermal_zone.name.to_s + ' Transfer Air Source')
      transfer_air_source_zone_exhaust.setAvailabilitySchedule(exhaust_schedule)
      # not using zone_exhaust_fan.setFlowFractionSchedule. Exhaust fans are on when available
      transfer_air_source_zone_exhaust.setMaximumFlowRate(transfer_air_zone_mixing_si)
      transfer_air_source_zone_exhaust.setFanEfficiency(1.0)
      transfer_air_source_zone_exhaust.setPressureRise(0.0)
      transfer_air_source_zone_exhaust.setEndUseSubcategory('Zone Exhaust Fans')
      transfer_air_source_zone_exhaust.addToThermalZone(exhaust_makeup_inputs[makeup_target][:source_zone])
      exhaust_fans[zone_exhaust_fan][:transfer_air_source_zone_exhaust] = transfer_air_source_zone_exhaust

      # TODO: - make zone mixing schedule by combining exhaust availability and fraction flow
      zone_mixing_schedule = exhaust_schedule

      # add zone mixing
      zone_mixing = OpenStudio::Model::ZoneMixing.new(thermal_zone)
      zone_mixing.setSchedule(zone_mixing_schedule)
      zone_mixing.setSourceZone(exhaust_makeup_inputs[makeup_target][:source_zone])
      zone_mixing.setDesignFlowRate(transfer_air_zone_mixing_si)
      exhaust_fans[zone_exhaust_fan][:zone_mixing] = zone_mixing

    end
  end

  return exhaust_fans
end

#thermal_zone_add_exhaust_fan_dcv(thermal_zone, change_related_objects = true, zone_mixing_objects = [], transfer_air_source_zones = []) ⇒ Bool

Add DCV to exhaust fan and if requsted to related objects

Returns:

  • (Bool)

    not sure if there is anything to turn here other than if it was sucessful, no new objects made?



1840
1841
1842
1843
1844
1845
1846
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1840

def thermal_zone_add_exhaust_fan_dcv(thermal_zone, change_related_objects = true, zone_mixing_objects = [], transfer_air_source_zones = [])
  # set flow fraction schedule for all zone exhaust fans and then set zone mixing schedule to the intersection of exhaust avaialability and exhaust fractional schedule

  # are there associated zone mixing or dummy exhaust objects that need to change when this changes?
  # How are these ojects identifed?
  # If this is run directly after thermal_zone_add_exhaust(thermal_zone)  it will return a hash where each key is an exhaust object and hash is a hash of related zone mizing and dummy exhaust from the source zone
end

#thermal_zone_add_unconditioned_thermostat(thermal_zone) ⇒ Object

Adds a thermostat that heats the space to 0 F and cools to 120 F. These numbers are outside of the threshold that is considered heated or cooled by thermal_zone_cooled?() and thermal_zone_heated?()



1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1492

def thermal_zone_add_unconditioned_thermostat(thermal_zone)
  # Heated to 0F (below thermal_zone_heated?(thermal_zone)  threshold)
  htg_t_f = 0
  htg_t_c = OpenStudio.convert(htg_t_f, 'F', 'C').get
  htg_stpt_sch = OpenStudio::Model::ScheduleRuleset.new(thermal_zone.model)
  htg_stpt_sch.setName('Unconditioned Minimal Heating')
  htg_stpt_sch.defaultDaySchedule.setName('Unconditioned Minimal Heating Default')
  htg_stpt_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), htg_t_c)

  # Cooled to 120F (above thermal_zone_cooled?(thermal_zone)  threshold)
  clg_t_f = 120
  clg_t_c = OpenStudio.convert(clg_t_f, 'F', 'C').get
  clg_stpt_sch = OpenStudio::Model::ScheduleRuleset.new(thermal_zone.model)
  clg_stpt_sch.setName('Unconditioned Minimal Heating')
  clg_stpt_sch.defaultDaySchedule.setName('Unconditioned Minimal Heating Default')
  clg_stpt_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), clg_t_c)

  # Thermostat
  thermostat = OpenStudio::Model::ThermostatSetpointDualSetpoint.new(thermal_zone.model)
  thermostat.setName("#{thermal_zone.name} Unconditioned Thermostat")
  thermostat.setHeatingSetpointTemperatureSchedule(htg_stpt_sch)
  thermostat.setCoolingSetpointTemperatureSchedule(clg_stpt_sch)

  return true
end

#thermal_zone_apply_prm_baseline_supply_temperatures(thermal_zone) ⇒ Bool

Set the design delta-T for zone heating and cooling sizing supply air temperatures. This value determines zone air flows, which will be summed during system design airflow calculation.

Returns:

  • (Bool)

    true if successful, false if not



1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1465

def thermal_zone_apply_prm_baseline_supply_temperatures(thermal_zone)
  # Skip spaces that aren't heated or cooled
  return true unless thermal_zone_heated?(thermal_zone) || thermal_zone_cooled?(thermal_zone)

  # Heating
  htg_sat_c = thermal_zone_prm_baseline_heating_design_supply_temperature(thermal_zone)
  htg_success = thermal_zone.sizingZone.setZoneHeatingDesignSupplyAirTemperature(htg_sat_c)

  # Cooling
  clg_sat_c = thermal_zone_prm_baseline_cooling_design_supply_temperature(thermal_zone)
  clg_success = thermal_zone.sizingZone.setZoneCoolingDesignSupplyAirTemperature(clg_sat_c)

  htg_sat_f = OpenStudio.convert(htg_sat_c, 'C', 'F').get
  clg_sat_f = OpenStudio.convert(clg_sat_c, 'C', 'F').get
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "For #{thermal_zone.name}, Htg SAT = #{htg_sat_f.round(1)}F, Clg SAT = #{clg_sat_f.round(1)}F.")

  result = false
  if htg_success && clg_success
    result = true
  end

  return result
end

#thermal_zone_building_type(thermal_zone) ⇒ String

Returns the building type that represents the majority of floor area

Returns:

  • (String)

    the building type



1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1565

def thermal_zone_building_type(thermal_zone)
  # determine areas of each building type
  building_type_areas = {}
  thermal_zone.spaces.each do |space|
    # ignore space if not part of total area
    next unless space.partofTotalFloorArea

    if space.spaceType.is_initialized
      space_type = space.spaceType.get
      if space_type.standardsBuildingType.is_initialized
        building_type = space_type.standardsBuildingType.get
        if building_type_areas[building_type].nil?
          building_type_areas[building_type] = space.floorArea
        else
          building_type_areas[building_type] += space.floorArea
        end
      end
    end
  end

  # return largest building type area
  building_type = building_type_areas.key(building_type_areas.values.max)

  if building_type.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Standards.ThermalZone', "Thermal zone #{thermal_zone.name} does not have standards building type.")
  end

  return building_type
end

#thermal_zone_conditioning_category(thermal_zone, climate_zone) ⇒ String

TODO:

add logic to detect indirectly-conditioned spaces

Determines whether the zone is conditioned per 90.1, which is based on heating and cooling loads.

Parameters:

  • climate_zone (String)

    climate zone

Returns:

  • (String)

    NonResConditioned, ResConditioned, Semiheated, Unconditioned



1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1242

def thermal_zone_conditioning_category(thermal_zone, climate_zone)
  # Get the heating load
  htg_load_btu_per_ft2 = 0.0
  htg_load_w_per_m2 = thermal_zone.heatingDesignLoad
  if htg_load_w_per_m2.is_initialized
    htg_load_btu_per_ft2 = OpenStudio.convert(htg_load_w_per_m2.get, 'W/m^2', 'Btu/hr*ft^2').get
  end

  # Get the cooling load
  clg_load_btu_per_ft2 = 0.0
  clg_load_w_per_m2 = thermal_zone.coolingDesignLoad
  if clg_load_w_per_m2.is_initialized
    clg_load_btu_per_ft2 = OpenStudio.convert(clg_load_w_per_m2.get, 'W/m^2', 'Btu/hr*ft^2').get
  end

  # Determine the heating limit based on climate zone
  # From Table 3.1 Heated Space Criteria
  htg_lim_btu_per_ft2 = 0.0
  case climate_zone
  when 'ASHRAE 169-2006-0A',
      'ASHRAE 169-2006-0B',
      'ASHRAE 169-2006-1A',
      'ASHRAE 169-2006-1B',
      'ASHRAE 169-2006-2A',
      'ASHRAE 169-2006-2B',
      'ASHRAE 169-2013-0A',
      'ASHRAE 169-2013-0B',
      'ASHRAE 169-2013-1A',
      'ASHRAE 169-2013-1B',
      'ASHRAE 169-2013-2A',
      'ASHRAE 169-2013-2B'
    htg_lim_btu_per_ft2 = 5
  when 'ASHRAE 169-2006-3A',
      'ASHRAE 169-2006-3B',
      'ASHRAE 169-2006-3C',
      'ASHRAE 169-2013-3A',
      'ASHRAE 169-2013-3B',
      'ASHRAE 169-2013-3C'
    htg_lim_btu_per_ft2 = 10
  when 'ASHRAE 169-2006-4A',
      'ASHRAE 169-2006-4B',
      'ASHRAE 169-2006-4C',
      'ASHRAE 169-2006-5A',
      'ASHRAE 169-2006-5B',
      'ASHRAE 169-2006-5C',
      'ASHRAE 169-2013-4A',
      'ASHRAE 169-2013-4B',
      'ASHRAE 169-2013-4C',
      'ASHRAE 169-2013-5A',
      'ASHRAE 169-2013-5B',
      'ASHRAE 169-2013-5C'
    htg_lim_btu_per_ft2 = 15
  when 'ASHRAE 169-2006-6A',
      'ASHRAE 169-2006-6B',
      'ASHRAE 169-2006-7A',
      'ASHRAE 169-2006-7B',
      'ASHRAE 169-2013-6A',
      'ASHRAE 169-2013-6B',
      'ASHRAE 169-2013-7A',
      'ASHRAE 169-2013-7B'
    htg_lim_btu_per_ft2 = 20
  when 'ASHRAE 169-2006-8A',
      'ASHRAE 169-2006-8B',
      'ASHRAE 169-2013-8A',
      'ASHRAE 169-2013-8B'
    htg_lim_btu_per_ft2 = 25
  end

  # Cooling limit is climate-independent
  clg_lim_btu_per_ft2 = 5

  # Semiheated limit is climate-independent
  semihtd_lim_btu_per_ft2 = 3.4

  # Determine if residential
  res = false
  if thermal_zone_residential?(thermal_zone)
    res = true
  end

  cond_cat = 'Unconditioned'
  if htg_load_btu_per_ft2 > htg_lim_btu_per_ft2
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "Zone #{thermal_zone.name} is conditioned because heating load of #{htg_load_btu_per_ft2.round} Btu/hr*ft^2 exceeds minimum of #{htg_lim_btu_per_ft2.round} Btu/hr*ft^2.")
    cond_cat = if res
                 'ResConditioned'
               else
                 'NonResConditioned'
               end
  elsif clg_load_btu_per_ft2 > clg_lim_btu_per_ft2
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "Zone #{thermal_zone.name} is conditioned because cooling load of #{clg_load_btu_per_ft2.round} Btu/hr*ft^2 exceeds minimum of #{clg_lim_btu_per_ft2.round} Btu/hr*ft^2.")
    cond_cat = if res
                 'ResConditioned'
               else
                 'NonResConditioned'
               end
  elsif htg_load_btu_per_ft2 > semihtd_lim_btu_per_ft2
    cond_cat = 'Semiheated'
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "Zone #{thermal_zone.name} is semiheated because heating load of #{htg_load_btu_per_ft2.round} Btu/hr*ft^2 exceeds minimum of #{semihtd_lim_btu_per_ft2.round} Btu/hr*ft^2.")
  end

  return cond_cat
end

#thermal_zone_convert_oa_req_to_per_area(thermal_zone) ⇒ Bool

Convert total minimum OA requirement to a per-area value.

Returns:

  • (Bool)

    true if successful, false if not



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 100

def thermal_zone_convert_oa_req_to_per_area(thermal_zone)
  # For each space in the zone, convert
  # all design OA to per-area
  # unless the "Outdoor Air Method" is "Maximum"
  thermal_zone.spaces.each do |space|
    # Find the design OA, which may be assigned at either the
    # SpaceType or directly at the Space
    dsn_oa = space.designSpecificationOutdoorAir
    next if dsn_oa.empty?

    dsn_oa = dsn_oa.get
    next if dsn_oa.outdoorAirMethod == 'Maximum'

    # Get the space properties
    floor_area = space.floorArea
    number_of_people = space.numberOfPeople
    volume = space.volume

    # Sum up the total OA from all sources
    oa_for_people = number_of_people * dsn_oa.outdoorAirFlowperPerson
    oa_for_floor_area = floor_area * dsn_oa.outdoorAirFlowperFloorArea
    oa_rate = dsn_oa.outdoorAirFlowRate
    oa_for_volume = volume * dsn_oa.outdoorAirFlowAirChangesperHour / 3600
    tot_oa = oa_for_people + oa_for_floor_area + oa_rate + oa_for_volume

    # Convert total to per-area
    tot_oa_per_area = tot_oa / floor_area

    # Check if there is another design OA object that has already
    # been converted from per-person to per-area that matches.
    # If so, reuse that instead of creating a duplicate.
    new_dsn_oa_name = "#{dsn_oa.name} to per-area"
    if thermal_zone.model.getDesignSpecificationOutdoorAirByName(new_dsn_oa_name).is_initialized
      new_dsn_oa = thermal_zone.model.getDesignSpecificationOutdoorAirByName(new_dsn_oa_name).get
    else
      new_dsn_oa = OpenStudio::Model::DesignSpecificationOutdoorAir.new(thermal_zone.model)
      new_dsn_oa.setName(new_dsn_oa_name)
    end

    # Assign this new design OA to the space
    space.setDesignSpecificationOutdoorAir(new_dsn_oa)

    # Set the method
    new_dsn_oa.setOutdoorAirMethod('Sum')
    # Set the per-area requirement
    new_dsn_oa.setOutdoorAirFlowperFloorArea(tot_oa_per_area)
    # Zero-out the per-person, ACH, and flow requirements
    new_dsn_oa.setOutdoorAirFlowperPerson(0.0)
    new_dsn_oa.setOutdoorAirFlowAirChangesperHour(0.0)
    new_dsn_oa.setOutdoorAirFlowRate(0.0)
    # Copy the orignal OA schedule, if any
    if dsn_oa.outdoorAirFlowRateFractionSchedule.is_initialized
      oa_sch = dsn_oa.outdoorAirFlowRateFractionSchedule.get
      new_dsn_oa.setOutdoorAirFlowRateFractionSchedule(oa_sch)
    end

    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Standards.ThermalZone', "For #{thermal_zone.name}: Converted total ventilation requirements to per-area value.")
  end

  return true
end

#thermal_zone_cooled?(thermal_zone) ⇒ Bool

Determines cooling status. If the zone has a thermostat with a minimum cooling setpoint below 33C (91F), counts as cooled. Plenums are also assumed to be cooled.

Returns:

  • (Bool)

    true if cooled, false if not

Author:

  • Andrew Parker, Julien Marrec



1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1058

def thermal_zone_cooled?(thermal_zone)
  temp_f = 91
  temp_c = OpenStudio.convert(temp_f, 'F', 'C').get

  cld = false

  # Consider plenum zones cooled
  area_plenum = 0
  area_non_plenum = 0
  thermal_zone.spaces.each do |space|
    if space_plenum?(space)
      area_plenum += space.floorArea
    else
      area_non_plenum += space.floorArea
    end
  end

  # Majority
  if area_plenum > area_non_plenum
    cld = true
    return cld
  end

  # Check if the zone has radiant cooling,
  # and if it does, get cooling setpoint schedule
  # directly from the radiant system to check.
  thermal_zone.equipment.each do |equip|
    clg_sch = nil
    if equip.to_ZoneHVACLowTempRadiantConstFlow.is_initialized
      equip = equip.to_ZoneHVACLowTempRadiantConstFlow.get
      clg_coil = equip.coolingCoil
      if clg_coil.to_CoilCoolingLowTempRadiantConstFlow.is_initialized
        clg_coil = clg_coil.to_CoilCoolingLowTempRadiantConstFlow.get
        if clg_coil.coolingLowControlTemperatureSchedule.is_initialized
          clg_sch = clg_coil.coolingLowControlTemperatureSchedule.get
        end
      end
    elsif equip.to_ZoneHVACLowTempRadiantVarFlow.is_initialized
      equip = equip.to_ZoneHVACLowTempRadiantVarFlow.get
      clg_coil = equip.coolingCoil
      if clg_coil.to_CoilCoolingLowTempRadiantVarFlow.is_initialized
        clg_coil = clg_coil.to_CoilCoolingLowTempRadiantVarFlow.get
        if clg_coil.coolingControlTemperatureSchedule.is_initialized
          clg_sch = clg_coil.coolingControlTemperatureSchedule.get
        end
      end
    end
    # Move on if no cooling schedule was found
    next if clg_sch.nil?

    # Get the setpoint from the schedule
    if clg_sch.to_ScheduleRuleset.is_initialized
      clg_sch = clg_sch.to_ScheduleRuleset.get
      min_c = schedule_ruleset_annual_min_max_value(clg_sch)['min']
      if min_c < temp_c
        cld = true
      end
    elsif clg_sch.to_ScheduleConstant.is_initialized
      clg_sch = clg_sch.to_ScheduleConstant.get
      min_c = schedule_constant_annual_min_max_value(clg_sch)['min']
      if min_c < temp_c
        cld = true
      end
    elsif clg_sch.to_ScheduleCompact.is_initialized
      clg_sch = clg_sch.to_ScheduleCompact.get
      min_c = schedule_compact_annual_min_max_value(clg_sch)['min']
      if min_c < temp_c
        cld = true
      end
    else
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "Zone #{thermal_zone.name} used an unknown schedule type for the cooling setpoint; assuming cooled.")
      cld = true
    end
  end

  # Unheated if no thermostat present
  if thermal_zone.thermostat.empty?
    return cld
  end

  # Check the cooling setpoint
  tstat = thermal_zone.thermostat.get
  if tstat.to_ThermostatSetpointDualSetpoint
    tstat = tstat.to_ThermostatSetpointDualSetpoint.get
    clg_sch = tstat.getCoolingSchedule
    if clg_sch.is_initialized
      clg_sch = clg_sch.get
      if clg_sch.to_ScheduleRuleset.is_initialized
        clg_sch = clg_sch.to_ScheduleRuleset.get
        min_c = schedule_ruleset_annual_min_max_value(clg_sch)['min']
        if min_c < temp_c
          cld = true
        end
      elsif clg_sch.to_ScheduleConstant.is_initialized
        clg_sch = clg_sch.to_ScheduleConstant.get
        min_c = schedule_constant_annual_min_max_value(clg_sch)['min']
        if min_c < temp_c
          cld = true
        end
      elsif clg_sch.to_ScheduleCompact.is_initialized
        clg_sch = clg_sch.to_ScheduleCompact.get
        min_c = schedule_compact_annual_min_max_value(clg_sch)['min']
        if min_c < temp_c
          cld = true
        end
      else
        OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "Zone #{thermal_zone.name} used an unknown schedule type for the cooling setpoint; assuming cooled.")
        cld = true
      end
    end
  elsif tstat.to_ZoneControlThermostatStagedDualSetpoint
    tstat = tstat.to_ZoneControlThermostatStagedDualSetpoint.get
    clg_sch = tstat.coolingTemperatureSetpointSchedule
    if clg_sch.is_initialized
      clg_sch = clg_sch.get
      if clg_sch.to_ScheduleRuleset.is_initialized
        clg_sch = clg_sch.to_ScheduleRuleset.get
        min_c = schedule_ruleset_annual_min_max_value(clg_sch)['min']
        if min_c < temp_c
          cld = true
        end
      end
    end
  end

  return cld
end

#thermal_zone_demand_control_ventilation_limits(thermal_zone) ⇒ Array<Double>

Determine the area and occupancy level limits for demand control ventilation. No DCV requirements by default.

and the minimum occupancy density in m^2/person. Returns nil if there is no requirement.

Parameters:

Returns:

  • (Array<Double>)

    the minimum area, in m^2



1687
1688
1689
1690
1691
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1687

def thermal_zone_demand_control_ventilation_limits(thermal_zone)
  min_area_m2 = nil
  min_area_per_occ = nil
  return [min_area_m2, min_area_per_occ]
end

#thermal_zone_demand_control_ventilation_required?(thermal_zone, climate_zone) ⇒ Bool

TODO:

Add exception logic for 90.1-2013 for cells, sickrooms, labs, barbers, salons, and bowling alleys

Determine if demand control ventilation (DCV) is required for this zone based on area and occupant density. Does not account for System requirements like ERV, economizer, etc. Those are accounted for in the AirLoopHVAC method of the same name.

Returns:

  • (Bool)

    Returns true if required, false if not.



1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1620

def thermal_zone_demand_control_ventilation_required?(thermal_zone, climate_zone)
  dcv_required = false

  # Get the limits
  min_area_m2, min_area_m2_per_occ = thermal_zone_demand_control_ventilation_limits(thermal_zone)

  # Not required if both limits nil
  if min_area_m2.nil? && min_area_m2_per_occ.nil?
    return dcv_required
  end

  # Get the area served and the number of occupants
  area_served_m2 = 0
  num_people = 0
  thermal_zone.spaces.each do |space|
    area_served_m2 += space.floorArea
    num_people += space.numberOfPeople
  end
  area_served_ft2 = OpenStudio.convert(area_served_m2, 'm^2', 'ft^2').get

  # Check the minimum area if there is a limit
  if min_area_m2
    # Convert limit to IP
    min_area_ft2 = OpenStudio.convert(min_area_m2, 'm^2', 'ft^2').get
    # Check the limit
    if area_served_ft2 < min_area_ft2
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ThermalZone', "For #{thermal_zone.name}: DCV is not required since the area is #{area_served_ft2.round} ft2, but the minimum size is #{min_area_ft2.round} ft2.")
      return dcv_required
    end
  end

  # Check the minimum occupancy density if there is a limit
  if min_area_m2_per_occ
    # Convert limit to IP
    min_area_ft2_per_occ = OpenStudio.convert(min_area_m2_per_occ, 'm^2', 'ft^2').get
    min_occ_per_ft2 = 1.0 / min_area_ft2_per_occ
    min_occ_per_1000_ft2 = min_occ_per_ft2 * 1000
    # Check the limit
    occ_per_ft2 = num_people / area_served_ft2
    occ_per_1000_ft2 = occ_per_ft2 * 1000
    if occ_per_1000_ft2 < min_occ_per_1000_ft2
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ThermalZone', "For #{thermal_zone.name}: DCV is not required since the occupant density is #{occ_per_1000_ft2.round} people/1000 ft2, but the minimum occupant density is #{min_occ_per_1000_ft2.round} people/1000 ft2.")
      return dcv_required
    end
  end

  # If here, DCV is required
  if min_area_m2 && min_area_m2_per_occ
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ThermalZone', "For #{thermal_zone.name}: DCV is required since the occupant density of #{occ_per_1000_ft2.round} people/1000 ft2 is above minimum occupant density of #{min_occ_per_1000_ft2.round} people/1000 ft2 and the area of #{area_served_ft2.round} ft2 is above the minimum size of #{min_area_ft2.round} ft2.")
  elsif min_area_m2
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ThermalZone', "For #{thermal_zone.name}: DCV is required since the area of #{area_served_ft2.round} ft2 is above the minimum size of #{min_area_ft2.round} ft2.")
  elsif min_area_m2_per_occ
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ThermalZone', "For #{thermal_zone.name}: DCV is required since the occupant density of #{occ_per_1000_ft2.round} people/1000 ft2 is above minimum occupant density of #{min_occ_per_1000_ft2.round} people/1000 ft2.")
  end

  dcv_required = true

  return dcv_required
end

#thermal_zone_design_internal_load(thermal_zone) ⇒ Double

Determine the design internal load (W) for this zone without space multipliers. This include People, Lights, Electric Equipment, and Gas Equipment in all spaces in this zone. It assumes 100% of the wattage is converted to heat, and that the design peak schedule value is 1 (100%).

Returns:

  • (Double)

    the design internal load, in W



1527
1528
1529
1530
1531
1532
1533
1534
1535
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1527

def thermal_zone_design_internal_load(thermal_zone)
  load_w = 0.0

  thermal_zone.spaces.each do |space|
    load_w += space_design_internal_load(space)
  end

  return load_w
end

#thermal_zone_exhaust_fan_dcv_required?(thermal_zone) ⇒ Bool

returns true if DCV is required for exhaust fan for specified tempate

Returns:

  • (Bool)

    returns true if DCV is required for exhaust fan for specified tempate



1835
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1835

def thermal_zone_exhaust_fan_dcv_required?(thermal_zone); end

#thermal_zone_floor_area_with_zone_multipliers(thermal_zone) ⇒ Double

Determine the net area of the zone Loops on each space, and checks if part of total floor area or not If not part of total floor area, it is not added to the zone floor area Will multiply it by the ZONE MULTIPLIER as well!

Returns:

  • (Double)

    the zone net floor area in m^2 (with multiplier taken into account)



753
754
755
756
757
758
759
760
761
762
763
764
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 753

def thermal_zone_floor_area_with_zone_multipliers(thermal_zone)
  area_m2 = 0
  zone_mult = multiplier
  spaces.each do |space|
    # If space is not part of floor area, we don't add it
    next unless space.partofTotalFloorArea

    area_m2 += space.floorArea
  end

  return area_m2 * zone_mult
end

#thermal_zone_fossil_hybrid_or_purchased_heat?(thermal_zone) ⇒ Boolean

Determine if the thermal zone is a Fossil Fuel, Fossil/Electric Hybrid, and Purchased Heat zone. If not, it is an Electric or Other Zone. This is as-defined by 90.1 Appendix G.

return [Bool] true if Fossil Fuel, Fossil/Electric Hybrid, and Purchased Heat zone, false if Electric or Other. To-do: It’s not doing it properly right now. If you have a zone with a VRF + a DOAS (via an ATU SingleDUct Uncontrolled) it’ll pick up both natural gas and electricity and classify it as fossil fuel, when I would definitely classify it as electricity

Returns:

  • (Boolean)


595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 595

def thermal_zone_fossil_hybrid_or_purchased_heat?(thermal_zone)
  is_fossil = false

  # Get an array of the heating fuels
  # used by the zone.  Possible values are
  # Electricity, NaturalGas, PropaneGas, FuelOilNo1, FuelOilNo2,
  # Coal, Diesel, Gasoline, DistrictHeating,
  # and SolarEnergy.
  htg_fuels = thermal_zone.heating_fuels

  if htg_fuels.include?('NaturalGas') ||
     htg_fuels.include?('PropaneGas') ||
     htg_fuels.include?('FuelOilNo1') ||
     htg_fuels.include?('FuelOilNo2') ||
     htg_fuels.include?('Coal') ||
     htg_fuels.include?('Diesel') ||
     htg_fuels.include?('Gasoline') ||
     htg_fuels.include?('DistrictHeating')

    is_fossil = true
  end

  # OpenStudio::logFree(OpenStudio::Debug, "openstudio.Standards.Model", "For #{self.name}, heating fuels = #{htg_fuels.join(', ')}; thermal_zone_fossil_hybrid_or_purchased_heat?(thermal_zone)  = #{is_fossil}.")

  return is_fossil
end

#thermal_zone_fossil_or_electric_type(thermal_zone, custom) ⇒ String

Determine if the thermal zone’s fuel type category. Options are: fossil, electric, unconditioned If a customization is passed, additional categories may be returned. If ‘Xcel Energy CO EDA’, the type fossilandelectric is added. DistrictHeating is considered a fossil fuel since it is typically created by natural gas boilers.

Returns:

  • (String)

    the fuel type category



632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 632

def thermal_zone_fossil_or_electric_type(thermal_zone, custom)
  fossil = false
  electric = false

  # Fossil heating
  htg_fuels = thermal_zone.heating_fuels
  if htg_fuels.include?('NaturalGas') ||
     htg_fuels.include?('PropaneGas') ||
     htg_fuels.include?('FuelOilNo1') ||
     htg_fuels.include?('FuelOilNo2') ||
     htg_fuels.include?('Coal') ||
     htg_fuels.include?('Diesel') ||
     htg_fuels.include?('Gasoline') ||
     htg_fuels.include?('DistrictHeating')
    fossil = true
  end

  # Electric heating
  if htg_fuels.include?('Electricity')
    electric = true
  end

  # Cooling fuels, for determining
  # unconditioned zones
  clg_fuels = thermal_zone.cooling_fuels

  # Categorize
  fuel_type = nil
  if fossil
    # If uses any fossil, counts as fossil even if electric is present too
    fuel_type = 'fossil'
  elsif electric
    fuel_type = 'electric'
  elsif htg_fuels.size.zero? && clg_fuels.size.zero?
    fuel_type = 'unconditioned'
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Standards.ThermalZone', "For #{thermal_zone.name}, could not determine fuel type, assuming fossil.  Heating fuels = #{htg_fuels.join(', ')}; cooling fuels = #{clg_fuels.join(', ')}.")
    fuel_type = 'fossil'
  end

  # Customization for Xcel.
  # Likely useful for other utility
  # programs where fuel switching is important.
  # This is primarily for systems where Gas is
  # used at the central AHU and electric is
  # used at the terminals/zones.  Examples
  # include zone VRF/PTHP with gas-heated DOAS,
  # and gas VAV with electric reheat
  case custom
  when 'Xcel Energy CO EDA'
    if fossil && electric
      fuel_type = 'fossilandelectric'
    end
  end

  # OpenStudio::logFree(OpenStudio::Info, "openstudio.Standards.Model", "For #{self.name}, fuel type = #{fuel_type}.")

  return fuel_type
end

#thermal_zone_get_adjacent_zones_with_shared_wall_areas(thermal_zone, same_floor = true) ⇒ Array

returns adjacant_zones_with_shared_wall_areas

Parameters:

  • same_floor (Bool) (defaults to: true)

    (only valid option for now is true)

Returns:

  • (Array)

    adjacent zones



1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1813

def thermal_zone_get_adjacent_zones_with_shared_wall_areas(thermal_zone, same_floor = true)
  adjacent_zones = []

  thermal_zone.spaces.each do |space|
    adj_spaces = space_get_adjacent_spaces_with_shared_wall_areas(space)
    adj_spaces.each do |k, v|
      # skip if space is in current thermal zone.
      next unless space.thermalZone.is_initialized
      next if k.thermalZone.get == thermal_zone

      adjacent_zones << k.thermalZone.get
    end
  end

  adjacent_zones = adjacent_zones.uniq

  return adjacent_zones
end

#thermal_zone_get_occupancy_schedule(thermal_zone, sch_name: nil, occupied_percentage_threshold: nil) ⇒ <OpenStudio::Model::ScheduleRuleset>

This method creates a new fractional schedule ruleset. If occupied_percentage_threshold is set, this method will return a discrete on/off fractional schedule with a value of one when occupancy across all spaces is greater than or equal to the occupied_percentage_threshold, and zero all other times. Otherwise the method will return the weighted fractional occupancy schedule.

Parameters:

  • thermal_zone (<OpenStudio::Model::ThermalZone>)

    thermal_zone to create occupancy schedule

  • sch_name (String) (defaults to: nil)

    the name of the generated occupancy schedule

  • occupied_percentage_threshold (Double) (defaults to: nil)

    the minimum fraction (0 to 1) that counts as occupied if this parameter is set, the returned ScheduleRuleset will be 0 = unoccupied, 1 = occupied otherwise the ScheduleRuleset will be the weighted fractional occupancy schedule

Returns:

  • (<OpenStudio::Model::ScheduleRuleset>)

    a ScheduleRuleset of fractional or discrete occupancy



173
174
175
176
177
178
179
180
181
182
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 173

def thermal_zone_get_occupancy_schedule(thermal_zone, sch_name: nil, occupied_percentage_threshold: nil)
  if sch_name.nil?
    sch_name = "#{thermal_zone.name} Occ Sch"
  end
  # Get the occupancy schedule for all spaces in thermal_zone
  sch_ruleset = spaces_get_occupancy_schedule(thermal_zone.spaces,
                                              sch_name: sch_name,
                                              occupied_percentage_threshold: occupied_percentage_threshold)
  return sch_ruleset
end

#thermal_zone_heated?(thermal_zone) ⇒ Bool

Determines heating status. If the zone has a thermostat with a maximum heating setpoint above 5C (41F), counts as heated. Plenums are also assumed to be heated.

Returns:

  • (Bool)

    true if heated, false if not

Author:

  • Andrew Parker, Julien Marrec



916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 916

def thermal_zone_heated?(thermal_zone)
  temp_f = 41
  temp_c = OpenStudio.convert(temp_f, 'F', 'C').get

  htd = false

  # Consider plenum zones heated
  area_plenum = 0
  area_non_plenum = 0
  thermal_zone.spaces.each do |space|
    if space_plenum?(space)
      area_plenum += space.floorArea
    else
      area_non_plenum += space.floorArea
    end
  end

  # Majority
  if area_plenum > area_non_plenum
    htd = true
    return htd
  end

  # Check if the zone has radiant heating,
  # and if it does, get heating setpoint schedule
  # directly from the radiant system to check.
  thermal_zone.equipment.each do |equip|
    htg_sch = nil
    if equip.to_ZoneHVACHighTemperatureRadiant.is_initialized
      equip = equip.to_ZoneHVACHighTemperatureRadiant.get
      if equip.heatingSetpointTemperatureSchedule.is_initialized
        htg_sch = equip.heatingSetpointTemperatureSchedule.get
      end
    elsif equip.to_ZoneHVACLowTemperatureRadiantElectric.is_initialized
      equip = equip.to_ZoneHVACLowTemperatureRadiantElectric.get
      htg_sch = equip.heatingSetpointTemperatureSchedule.get
    elsif equip.to_ZoneHVACLowTempRadiantConstFlow.is_initialized
      equip = equip.to_ZoneHVACLowTempRadiantConstFlow.get
      htg_coil = equip.heatingCoil
      if htg_coil.to_CoilHeatingLowTempRadiantConstFlow.is_initialized
        htg_coil = htg_coil.to_CoilHeatingLowTempRadiantConstFlow.get
        if htg_coil.heatingHighControlTemperatureSchedule.is_initialized
          htg_sch = htg_coil.heatingHighControlTemperatureSchedule.get
        end
      end
    elsif equip.to_ZoneHVACLowTempRadiantVarFlow.is_initialized
      equip = equip.to_ZoneHVACLowTempRadiantVarFlow.get
      htg_coil = equip.heatingCoil
      if htg_coil.to_CoilHeatingLowTempRadiantVarFlow.is_initialized
        htg_coil = htg_coil.to_CoilHeatingLowTempRadiantVarFlow.get
        if htg_coil.heatingControlTemperatureSchedule.is_initialized
          htg_sch = htg_coil.heatingControlTemperatureSchedule.get
        end
      end
    end
    # Move on if no heating schedule was found
    next if htg_sch.nil?

    # Get the setpoint from the schedule
    if htg_sch.to_ScheduleRuleset.is_initialized
      htg_sch = htg_sch.to_ScheduleRuleset.get
      max_c = schedule_ruleset_annual_min_max_value(htg_sch)['max']
      if max_c > temp_c
        htd = true
      end
    elsif htg_sch.to_ScheduleConstant.is_initialized
      htg_sch = htg_sch.to_ScheduleConstant.get
      max_c = schedule_constant_annual_min_max_value(htg_sch)['max']
      if max_c > temp_c
        htd = true
      end
    elsif htg_sch.to_ScheduleCompact.is_initialized
      htg_sch = htg_sch.to_ScheduleCompact.get
      max_c = schedule_compact_annual_min_max_value(htg_sch)['max']
      if max_c > temp_c
        htd = true
      end
    else
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "Zone #{thermal_zone.name} used an unknown schedule type for the heating setpoint; assuming heated.")
      htd = true
    end
  end

  # Unheated if no thermostat present
  if thermal_zone.thermostat.empty?
    return htd
  end

  # Check the heating setpoint
  tstat = thermal_zone.thermostat.get
  if tstat.to_ThermostatSetpointDualSetpoint
    tstat = tstat.to_ThermostatSetpointDualSetpoint.get
    htg_sch = tstat.getHeatingSchedule
    if htg_sch.is_initialized
      htg_sch = htg_sch.get
      if htg_sch.to_ScheduleRuleset.is_initialized
        htg_sch = htg_sch.to_ScheduleRuleset.get
        max_c = schedule_ruleset_annual_min_max_value(htg_sch)['max']
        if max_c > temp_c
          htd = true
        end
      elsif htg_sch.to_ScheduleConstant.is_initialized
        htg_sch = htg_sch.to_ScheduleConstant.get
        max_c = schedule_constant_annual_min_max_value(htg_sch)['max']
        if max_c > temp_c
          htd = true
        end
      elsif htg_sch.to_ScheduleCompact.is_initialized
        htg_sch = htg_sch.to_ScheduleCompact.get
        max_c = schedule_compact_annual_min_max_value(htg_sch)['max']
        if max_c > temp_c
          htd = true
        end
      else
        OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "Zone #{thermal_zone.name} used an unknown schedule type for the heating setpoint; assuming heated.")
        htd = true
      end
    end
  elsif tstat.to_ZoneControlThermostatStagedDualSetpoint
    tstat = tstat.to_ZoneControlThermostatStagedDualSetpoint.get
    htg_sch = tstat.heatingTemperatureSetpointSchedule
    if htg_sch.is_initialized
      htg_sch = htg_sch.get
      if htg_sch.to_ScheduleRuleset.is_initialized
        htg_sch = htg_sch.to_ScheduleRuleset.get
        max_c = schedule_ruleset_annual_min_max_value(htg_sch)['max']
        if max_c > temp_c
          htd = true
        end
      end
    end
  end

  return htd
end

#thermal_zone_infer_system_type(thermal_zone) ⇒ String

Infers the baseline system type based on the equipment serving the zone and their heating/cooling fuels. Only does a high-level inference; does not look for the presence/absence of required controls, etc.

PTHP, PTAC, PSZ_AC, PSZ_HP, PVAV_Reheat, PVAV_PFP_Boxes, VAV_Reheat, VAV_PFP_Boxes, Gas_Furnace, Electric_Furnace

Returns:

  • (String)

    Possible system types are



774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 774

def thermal_zone_infer_system_type(thermal_zone)
  # Determine the characteristics
  # of the equipment serving the zone
  has_air_loop = false
  air_loop_num_zones = 0
  air_loop_is_vav = false
  air_loop_has_chw = false
  has_ptac = false
  has_pthp = false
  has_unitheater = false
  thermal_zone.equipment.each do |equip|
    # Skip HVAC components
    next unless equip.to_HVACComponent.is_initialized

    equip = equip.to_HVACComponent.get
    if equip.airLoopHVAC.is_initialized
      has_air_loop = true
      air_loop = equip.airLoopHVAC.get
      air_loop_num_zones = air_loop.thermalZones.size
      air_loop.supplyComponents.each do |sc|
        if sc.to_FanVariableVolume.is_initialized
          air_loop_is_vav = true
        elsif sc.to_CoilCoolingWater.is_initialized
          air_loop_has_chw = true
        end
      end
    elsif equip.to_ZoneHVACPackagedTerminalAirConditioner.is_initialized
      has_ptac = true
    elsif equip.to_ZoneHVACPackagedTerminalHeatPump.is_initialized
      has_pthp = true
    elsif equip.to_ZoneHVACUnitHeater.is_initialized
      has_unitheater = true
    end
  end

  # Get the zone heating and cooling fuels
  htg_fuels = thermal_zone.heating_fuels
  clg_fuels = thermal_zone.cooling_fuels
  is_fossil = thermal_zone_fossil_hybrid_or_purchased_heat?(thermal_zone)

  # Infer the HVAC type
  sys_type = 'Unknown'

  # Single zone
  if air_loop_num_zones < 2
    # Gas
    if is_fossil
      # Air Loop
      if has_air_loop
        # Gas_Furnace (as air loop)
        sys_type = if clg_fuels.size.zero?
                     'Gas_Furnace'
                   # PSZ_AC
                   else
                     'PSZ_AC'
                   end
      # Zone Equipment
      else
        # Gas_Furnace (as unit heater)
        if has_unitheater
          sys_type = 'Gas_Furnace'
        end
        # PTAC
        if has_ptac
          sys_type = 'PTAC'
        end
      end
    # Electric
    else
      # Air Loop
      if has_air_loop
        # Electric_Furnace (as air loop)
        sys_type = if clg_fuels.size.zero?
                     'Electric_Furnace'
                   # PSZ_HP
                   else
                     'PSZ_HP'
                   end
      # Zone Equipment
      else
        # Electric_Furnace (as unit heater)
        if has_unitheater
          sys_type = 'Electric_Furnace'
        end
        # PTHP
        if has_pthp
          sys_type = 'PTHP'
        end
      end
    end
  # Multi-zone
  else
    # Gas
    if is_fossil
      # VAV_Reheat
      if air_loop_has_chw && air_loop_is_vav
        sys_type = 'VAV_Reheat'
      end
      # PVAV_Reheat
      if !air_loop_has_chw && air_loop_is_vav
        sys_type = 'PVAV_Reheat'
      end
    # Electric
    else
      # VAV_PFP_Boxes
      if air_loop_has_chw && air_loop_is_vav
        sys_type = 'VAV_PFP_Boxes'
      end
      # PVAV_PFP_Boxes
      if !air_loop_has_chw && air_loop_is_vav
        sys_type = 'PVAV_PFP_Boxes'
      end
    end
  end

  # Report out the characteristics for debugging if
  # the system type cannot be inferred.
  if sys_type == 'Unknown'
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Standards.ThermalZone', "For #{thermal_zone.name}, the baseline system type could not be inferred.")
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "***#{thermal_zone.name}***")
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "system type = #{sys_type}")
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "has_air_loop = #{has_air_loop}")
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "air_loop_num_zones = #{air_loop_num_zones}")
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "air_loop_is_vav = #{air_loop_is_vav}")
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "air_loop_has_chw = #{air_loop_has_chw}")
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "has_ptac = #{has_ptac}")
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "has_pthp = #{has_pthp}")
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "has_unitheater = #{has_unitheater}")
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "htg_fuels = #{htg_fuels}")
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "clg_fuels = #{clg_fuels}")
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "is_fossil = #{is_fossil}")
  end

  return sys_type
end

#thermal_zone_majority_space_type(thermal_zone) ⇒ Boost::Optional<OpenStudio::Model::SpaceType>

Returns the space type that represents a majority of the floor area.

Returns:

  • (Boost::Optional<OpenStudio::Model::SpaceType>)

    an optional SpaceType



1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1541

def thermal_zone_majority_space_type(thermal_zone)
  space_type_to_area = Hash.new(0.0)

  thermal_zone.spaces.each do |space|
    if space.spaceType.is_initialized
      space_type = space.spaceType.get
      space_type_to_area[space_type] += space.floorArea
    end
  end

  # If no space types, return empty optional SpaceType
  if space_type_to_area.size.zero?
    return OpenStudio::Model::OptionalSpaceType.new
  end

  # Sort by area
  biggest_space_type = space_type_to_area.sort_by { |st, area| area }.reverse[0][0]

  return OpenStudio::Model::OptionalSpaceType.new(biggest_space_type)
end

#thermal_zone_mixed_heating_fuel?(thermal_zone) ⇒ Boolean

Determine if the thermal zone is Fossil/Purchased Heat/Electric Hybrid

return [Bool] true if mixed Fossil/Electric Hybrid, and Purchased Heat zone

Returns:

  • (Boolean)


697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 697

def thermal_zone_mixed_heating_fuel?(thermal_zone)
  is_mixed = false

  # Get an array of the heating fuels
  # used by the zone.  Possible values are
  # Electricity, NaturalGas, PropaneGas, FuelOilNo1, FuelOilNo2,
  # Coal, Diesel, Gasoline, DistrictHeating,
  # and SolarEnergy.
  htg_fuels = thermal_zone.heating_fuels

  # Includes fossil
  fossil = false
  if htg_fuels.include?('NaturalGas') ||
     htg_fuels.include?('PropaneGas') ||
     htg_fuels.include?('FuelOilNo1') ||
     htg_fuels.include?('FuelOilNo2') ||
     htg_fuels.include?('Coal') ||
     htg_fuels.include?('Diesel') ||
     htg_fuels.include?('Gasoline')

    fossil = true
  end

  # Electric and fossil and district
  if htg_fuels.include?('Electricity') && htg_fuels.include?('DistrictHeating') && fossil
    is_mixed = true
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "For #{thermal_zone.name}, heating mixed electricity, fossil, and district.")
  end

  # Electric and fossil
  if htg_fuels.include?('Electricity') && fossil
    is_mixed = true
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "For #{thermal_zone.name}, heating mixed electricity and fossil.")
  end

  # Electric and district
  if htg_fuels.include?('Electricity') && htg_fuels.include?('DistrictHeating')
    is_mixed = true
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "For #{thermal_zone.name}, heating mixed electricity and district.")
  end

  # Fossil and district
  if fossil && htg_fuels.include?('DistrictHeating')
    is_mixed = true
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "For #{thermal_zone.name}, heating mixed fossil and district.")
  end

  return is_mixed
end

#thermal_zone_occupancy_type(thermal_zone) ⇒ String

TODO:

Add public assembly building types

Determine the thermal zone’s occupancy type category. Options are: residential, nonresidential

Returns:

  • (String)

    the occupancy type category



1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1600

def thermal_zone_occupancy_type(thermal_zone)
  occ_type = if thermal_zone_residential?(thermal_zone)
               'residential'
             else
               'nonresidential'
             end

  # OpenStudio::logFree(OpenStudio::Info, "openstudio.Standards.ThermalZone", "For #{self.name}, occupancy type = #{occ_type}.")

  return occ_type
end

#thermal_zone_outdoor_airflow_rate(thermal_zone) ⇒ Double

Calculates the zone outdoor airflow requirement (Voz) based on the inputs in the DesignSpecification:OutdoorAir objects in all spaces in the zone.

Returns:

  • (Double)

    the zone outdoor air flow rate @units cubic meters per second (m^3/s)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 10

def thermal_zone_outdoor_airflow_rate(thermal_zone)
  tot_oa_flow_rate = 0.0

  spaces = thermal_zone.spaces.sort

  sum_floor_area = 0.0
  sum_number_of_people = 0.0
  sum_volume = 0.0

  # Variables for merging outdoor air
  any_max_oa_method = false
  sum_oa_for_people = 0.0
  sum_oa_for_floor_area = 0.0
  sum_oa_rate = 0.0
  sum_oa_for_volume = 0.0

  # Find common variables for the new space
  spaces.each do |space|
    floor_area = space.floorArea
    sum_floor_area += floor_area

    number_of_people = space.numberOfPeople
    sum_number_of_people += number_of_people

    volume = space.volume
    sum_volume += volume

    dsn_oa = space.designSpecificationOutdoorAir
    next if dsn_oa.empty?

    dsn_oa = dsn_oa.get

    # compute outdoor air rates in case we need them
    oa_for_people = number_of_people * dsn_oa.outdoorAirFlowperPerson
    oa_for_floor_area = floor_area * dsn_oa.outdoorAirFlowperFloorArea
    oa_rate = dsn_oa.outdoorAirFlowRate
    oa_for_volume = volume * dsn_oa.outdoorAirFlowAirChangesperHour / 3600

    # First check if this space uses the Maximum method and other spaces do not
    if dsn_oa.outdoorAirMethod == 'Maximum'
      sum_oa_rate += [oa_for_people, oa_for_floor_area, oa_rate, oa_for_volume].max
    elsif dsn_oa.outdoorAirMethod == 'Sum'
      sum_oa_for_people += oa_for_people
      sum_oa_for_floor_area += oa_for_floor_area
      sum_oa_rate += oa_rate
      sum_oa_for_volume += oa_for_volume
    end
  end

  tot_oa_flow_rate += sum_oa_for_people
  tot_oa_flow_rate += sum_oa_for_floor_area
  tot_oa_flow_rate += sum_oa_rate
  tot_oa_flow_rate += sum_oa_for_volume

  # Convert to cfm
  tot_oa_flow_rate_cfm = OpenStudio.convert(tot_oa_flow_rate, 'm^3/s', 'cfm').get

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Standards.ThermalZone', "For #{thermal_zone.name}, design min OA = #{tot_oa_flow_rate_cfm.round} cfm.")

  return tot_oa_flow_rate
end

#thermal_zone_outdoor_airflow_rate_per_area(thermal_zone) ⇒ Double

Calculates the zone outdoor airflow requirement and divides by the zone area.

Returns:

  • (Double)

    the zone outdoor air flow rate per area @units cubic meters per second (m^3/s)



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 77

def thermal_zone_outdoor_airflow_rate_per_area(thermal_zone)
  tot_oa_flow_rate_per_area = 0.0

  # Find total area of the zone
  sum_floor_area = 0.0
  thermal_zone.spaces.sort.each do |space|
    sum_floor_area += space.floorArea
  end

  # Get the OA flow rate
  tot_oa_flow_rate = thermal_zone_outdoor_airflow_rate(thermal_zone)

  # Calculate the per-area value
  tot_oa_flow_rate_per_area = tot_oa_flow_rate / sum_floor_area

  # OpenStudio::logFree(OpenStudio::Debug, "openstudio.Standards.Model", "For #{self.name}, OA per area = #{tot_oa_flow_rate_per_area.round(8)} m^3/s*m^2.")

  return tot_oa_flow_rate_per_area
end

#thermal_zone_plenum?(thermal_zone) ⇒ Bool

Determine if the thermal zone is a plenum based on whether a majority of the spaces in the zone are plenums or not.

Returns:

  • (Bool)

    true if majority plenum, false if not



1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1190

def thermal_zone_plenum?(thermal_zone)
  plenum_status = false

  area_plenum = 0
  area_non_plenum = 0
  thermal_zone.spaces.each do |space|
    if space_plenum?(space)
      area_plenum += space.floorArea
    else
      area_non_plenum += space.floorArea
    end
  end

  # Majority
  if area_plenum > area_non_plenum
    plenum_status = true
  end

  return plenum_status
end

#thermal_zone_prm_baseline_cooling_design_supply_temperature(thermal_zone) ⇒ Double

TODO:

Exception: 17F delta-T for labs

Calculate the cooling supply temperature based on the specified delta-T. Delta-T is calculated based on the highest value found in the cooling setpoint schedule.

Returns:

  • (Double)

    the design heating supply temperature, in C



1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1408

def thermal_zone_prm_baseline_cooling_design_supply_temperature(thermal_zone)
  setpoint_c = nil

  # Setpoint schedule
  tstat = thermal_zone.thermostatSetpointDualSetpoint
  if tstat.is_initialized
    tstat = tstat.get
    setpoint_sch = tstat.coolingSetpointTemperatureSchedule
    if setpoint_sch.is_initialized
      setpoint_sch = setpoint_sch.get
      if setpoint_sch.to_ScheduleRuleset.is_initialized
        setpoint_sch = setpoint_sch.to_ScheduleRuleset.get
        setpoint_c = schedule_ruleset_annual_min_max_value(setpoint_sch)['min']
      elsif setpoint_sch.to_ScheduleConstant.is_initialized
        setpoint_sch = setpoint_sch.to_ScheduleConstant.get
        setpoint_c = schedule_constant_annual_min_max_value(setpoint_sch)['min']
      elsif setpoint_sch.to_ScheduleCompact.is_initialized
        setpoint_sch = setpoint_sch.to_ScheduleCompact.get
        setpoint_c = schedule_compact_annual_min_max_value(setpoint_sch)['min']
      end
    end
  end

  # If the cooling setpoint could not be determined
  # return the current design cooling temperature
  if setpoint_c.nil?
    setpoint_c = thermal_zone.sizingZone.zoneCoolingDesignSupplyAirTemperature
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Standards.ThermalZone', "For #{thermal_zone.name}: could not determine min cooling setpoint.  Design cooling SAT will be #{OpenStudio.convert(setpoint_c, 'C', 'F').get.round} F from proposed model.")
    return setpoint_c
  end

  # If the cooling setpoint was set very high so that
  # cooling equipment never comes on
  # return the current design cooling temperature
  if setpoint_c > OpenStudio.convert(91, 'F', 'C').get
    setpoint_f = OpenStudio.convert(setpoint_c, 'C', 'F').get
    new_setpoint_c = thermal_zone.sizingZone.zoneCoolingDesignSupplyAirTemperature
    new_setpoint_f = OpenStudio.convert(new_setpoint_c, 'C', 'F').get
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Standards.ThermalZone', "For #{thermal_zone.name}: max cooling setpoint in proposed model was #{setpoint_f.round} F.  20 F SAT delta-T from this point is unreasonable. Design cooling SAT will be #{new_setpoint_f.round} F from proposed model.")
    return new_setpoint_c
  end

  # Subtract 20F delta-T
  delta_t_r = 20
  delta_t_k = OpenStudio.convert(delta_t_r, 'R', 'K').get

  sat_c = setpoint_c - delta_t_k # Subtract for cooling

  return sat_c
end

#thermal_zone_prm_baseline_heating_design_supply_temperature(thermal_zone) ⇒ Double

TODO:

Exception: 17F delta-T for labs

Calculate the heating supply temperature based on the specified delta-T. Delta-T is calculated based on the highest value found in the heating setpoint schedule.

Returns:

  • (Double)

    the design heating supply temperature, in C



1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1351

def thermal_zone_prm_baseline_heating_design_supply_temperature(thermal_zone)
  setpoint_c = nil

  # Setpoint schedule
  tstat = thermal_zone.thermostatSetpointDualSetpoint
  if tstat.is_initialized
    tstat = tstat.get
    setpoint_sch = tstat.heatingSetpointTemperatureSchedule
    if setpoint_sch.is_initialized
      setpoint_sch = setpoint_sch.get
      if setpoint_sch.to_ScheduleRuleset.is_initialized
        setpoint_sch = setpoint_sch.to_ScheduleRuleset.get
        setpoint_c = schedule_ruleset_annual_min_max_value(setpoint_sch)['max']
      elsif setpoint_sch.to_ScheduleConstant.is_initialized
        setpoint_sch = setpoint_sch.to_ScheduleConstant.get
        setpoint_c = schedule_constant_annual_min_max_value(setpoint_sch)['max']
      elsif setpoint_sch.to_ScheduleCompact.is_initialized
        setpoint_sch = setpoint_sch.to_ScheduleCompact.get
        setpoint_c = schedule_compact_annual_min_max_value(setpoint_sch)['max']
      end
    end
  end

  # If the heating setpoint could not be determined
  # return the current design heating temperature
  if setpoint_c.nil?
    setpoint_c = thermal_zone.sizingZone.zoneHeatingDesignSupplyAirTemperature
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Standards.ThermalZone', "For #{thermal_zone.name}: could not determine max heating setpoint.  Design heating SAT will be #{OpenStudio.convert(setpoint_c, 'C', 'F').get.round} F from proposed model.")
    return setpoint_c
  end

  # If the heating setpoint was set very low so that
  # heating equipment never comes on
  # return the current design heating temperature
  if setpoint_c < OpenStudio.convert(41, 'F', 'C').get
    setpoint_f = OpenStudio.convert(setpoint_c, 'C', 'F').get
    new_setpoint_c = thermal_zone.sizingZone.zoneHeatingDesignSupplyAirTemperature
    new_setpoint_f = OpenStudio.convert(new_setpoint_c, 'C', 'F').get
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.Standards.ThermalZone', "For #{thermal_zone.name}: max heating setpoint in proposed model was #{setpoint_f.round} F.  20 F SAT delta-T from this point is unreasonable. Design heating SAT will be #{new_setpoint_f.round} F from proposed model.")
    return new_setpoint_c
  end

  # Add 20F delta-T
  delta_t_r = 20
  delta_t_k = OpenStudio.convert(delta_t_r, 'R', 'K').get

  sat_c = setpoint_c + delta_t_k # Add for heating

  return sat_c
end

#thermal_zone_residential?(thermal_zone) ⇒ Boolean

Determine if the thermal zone is residential based on the space type properties for the spaces in the zone. If there are both residential and nonresidential spaces in the zone, the result will be whichever type has more floor area. In the event that they are equal, it will be assumed nonresidential.

return [Bool] true if residential, false if nonresidential

Returns:

  • (Boolean)


561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 561

def thermal_zone_residential?(thermal_zone)
  # Determine the respective areas
  res_area_m2 = 0
  nonres_area_m2 = 0
  thermal_zone.spaces.each do |space|
    # Ignore space if not part of total area
    next unless space.partofTotalFloorArea

    if space_residential?(space)
      res_area_m2 += space.floorArea
    else
      nonres_area_m2 += space.floorArea
    end
  end

  # Determine which is larger
  is_res = false
  if res_area_m2 > nonres_area_m2
    is_res = true
  end

  return is_res
end

#thermal_zone_vestibule?(thermal_zone) ⇒ Bool

Determine if this zone is a vestibule. Zone must be less than 200ft^2 and also have an infiltration object specified using Flow/Zone.

Returns:

  • (Bool)

    returns true if vestibule, false if not



1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1216

def thermal_zone_vestibule?(thermal_zone)
  is_vest = false

  # Check area
  return is_vest if thermal_zone.floorArea < OpenStudio.convert(200, 'ft^2', 'm^2').get

  # Check presence of infiltration
  thermal_zone.spaces.each do |space|
    space.spaceInfiltrationDesignFlowRates.each do |infil|
      if infil.designFlowRate.is_initialized
        is_vest = true
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ThermalZone', "For #{thermal_zone.name}: This zone is considered a vestibule.")
        break
      end
    end
  end

  return is_vest
end

#thermal_zones_get_occupancy_schedule(thermal_zones, sch_name: nil, occupied_percentage_threshold: nil) ⇒ <OpenStudio::Model::ScheduleRuleset>

This method creates a new fractional schedule ruleset. If occupied_percentage_threshold is set, this method will return a discrete on/off fractional schedule with a value of one when occupancy across all spaces is greater than or equal to the occupied_percentage_threshold, and zero all other times. Otherwise the method will return the weighted fractional occupancy schedule.

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of thermal_zones to create occupancy schedule

  • sch_name (String) (defaults to: nil)

    the name of the generated occupancy schedule

  • occupied_percentage_threshold (Double) (defaults to: nil)

    the minimum fraction (0 to 1) that counts as occupied if this parameter is set, the returned ScheduleRuleset will be 0 = unoccupied, 1 = occupied otherwise the ScheduleRuleset will be the weighted fractional occupancy schedule

Returns:

  • (<OpenStudio::Model::ScheduleRuleset>)

    a ScheduleRuleset of fractional or discrete occupancy



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 195

def thermal_zones_get_occupancy_schedule(thermal_zones, sch_name: nil, occupied_percentage_threshold: nil)
  if sch_name.nil?
    sch_name = "#{thermal_zones.size} zone Occ Sch"
  end
  # Get the occupancy schedule for all spaces in thermal_zones
  spaces = []
  thermal_zones.each do |thermal_zone|
    thermal_zone.spaces.each do |space|
      spaces << space
    end
  end
  sch_ruleset = spaces_get_occupancy_schedule(spaces,
                                              sch_name: sch_name,
                                              occupied_percentage_threshold: occupied_percentage_threshold)
  return sch_ruleset
end

#true?(obj) ⇒ Boolean

Returns:

  • (Boolean)


919
920
921
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 919

def true?(obj)
  obj.to_s.downcase == 'true'
end

#validate_initial_model(model) ⇒ Object



4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4582

def validate_initial_model(model)
  is_valid = true
  if model.getBuildingStorys.empty?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'Please assign Spaces to BuildingStorys the geometry model.')
    is_valid = false
  end
  if model.getThermalZones.empty?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'Please assign Spaces to ThermalZones the geometry model.')
    is_valid = false
  end
  if model.getBuilding.standardsNumberOfStories.empty?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'Please define Building.standardsNumberOfStories the geometry model.')
    is_valid = false
  end
  if model.getBuilding.standardsNumberOfAboveGroundStories.empty?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'Please define Building.standardsNumberOfAboveStories in the geometry model.')
    is_valid = false
  end

  if @space_type_map.nil? || @space_type_map.empty?
    @space_type_map = get_space_type_maps_from_model(model)
    if @space_type_map.nil? || @space_type_map.empty?
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "Please assign SpaceTypes in the geometry model or in standards database #{@space_type_map}.")
      is_valid = false
    else
      @space_type_map = @space_type_map.sort.to_h
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Loaded space type map from model')
    end
  end

  # ensure that model is intersected correctly.
  model.getSpaces.each { |space1| model.getSpaces.each { |space2| space1.intersectSurfaces(space2) } }
  # Get multipliers from TZ in model. Need this for HVAC contruction.
  @space_multiplier_map = {}
  model.getSpaces.sort.each do |space|
    @space_multiplier_map[space.name.get] = space.multiplier if space.multiplier > 1
  end
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Finished adding geometry')
  unless @space_multiplier_map.empty?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Found multipliers for space #{@space_multiplier_map}")
  end
  return is_valid
end

#water_heater_mixed_apply_efficiency(water_heater_mixed) ⇒ Bool

Applies the standard efficiency ratings and typical losses and paraisitic loads to this object. Efficiency and skin loss coefficient (UA) Per PNNL www.energycodes.gov/sites/default/files/documents/PrototypeModelEnhancements_2014_0.pdf Appendix A: Service Water Heating

Returns:

  • (Bool)

    true if successful, false if not



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/openstudio-standards/standards/Standards.WaterHeaterMixed.rb', line 10

def water_heater_mixed_apply_efficiency(water_heater_mixed)
  # TODO: remove this once workaround for HPWHs is removed
  if water_heater_mixed.partLoadFactorCurve.is_initialized
    if water_heater_mixed.partLoadFactorCurve.get.name.get.include?('HPWH_COP')
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.WaterHeaterMixed', "For #{water_heater_mixed.name}, the workaround for HPWHs has been applied, efficiency will not be changed.")
      return true
    end
  end

  # Get the capacity of the water heater
  # TODO add capability to pull autosized water heater capacity
  # if the Sizing:WaterHeater object is ever implemented in OpenStudio.
  capacity_w = water_heater_mixed.heaterMaximumCapacity
  if capacity_w.empty?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.WaterHeaterMixed', "For #{water_heater_mixed.name}, cannot find capacity, standard will not be applied.")
    return false
  else
    capacity_w = capacity_w.get / water_heater_mixed.component_quantity
  end
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get

  # Get the volume of the water heater
  # TODO: add capability to pull autosized water heater volume
  # if the Sizing:WaterHeater object is ever implemented in OpenStudio.
  volume_m3 = water_heater_mixed.tankVolume
  if volume_m3.empty?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.WaterHeaterMixed', "For #{water_heater_mixed.name}, cannot find volume, standard will not be applied.")
    return false
  else
    volume_m3 = @instvarbuilding_type == 'MidriseApartment' ? volume_m3.get / 23 : volume_m3.get / water_heater_mixed.component_quantity
  end
  volume_gal = OpenStudio.convert(volume_m3, 'm^3', 'gal').get

  # Get the heater fuel type
  fuel_type = water_heater_mixed.heaterFuelType
  unless fuel_type == 'NaturalGas' || fuel_type == 'Electricity'
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.WaterHeaterMixed', "For #{water_heater_mixed.name}, fuel type of #{fuel_type} is not yet supported, standard will not be applied.")
  end

  # Get the water heater properties
  search_criteria = {}
  search_criteria['template'] = template
  search_criteria['fuel_type'] = fuel_type
  wh_props = model_find_object(standards_data['water_heaters'], search_criteria, capacity_btu_per_hr)
  unless wh_props
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.WaterHeaterMixed', "For #{water_heater_mixed.name}, cannot find water heater properties, cannot apply efficiency standard.")
    return false
  end

  # Calculate the water heater efficiency and
  # skin loss coefficient (UA) using different methods,
  # depending on the metrics specified by the standard
  water_heater_eff = nil
  ua_btu_per_hr_per_f = nil

  # Rarely specified by thermal efficiency alone
  if wh_props['thermal_efficiency'] && !wh_props['standby_loss_capacity_allowance']
    et = wh_props['thermal_efficiency']
    water_heater_eff = et
    # Fixed UA
    ua_btu_per_hr_per_f = 11.37
  end

  # Typically specified this way for small electric water heaters
  # and small natural gas water heaters
  if wh_props['energy_factor_base'] && wh_props['energy_factor_volume_derate']
    # Calculate the energy factor (EF)
    base_ef = wh_props['energy_factor_base']
    vol_drt = wh_props['energy_factor_volume_derate']
    ef = base_ef - (vol_drt * volume_gal)
    # Calculate the skin loss coefficient (UA)
    # differently depending on the fuel type
    if fuel_type == 'Electricity'
      # Fixed water heater efficiency per PNNL
      water_heater_eff = 1.0
      ua_btu_per_hr_per_f = (41_094 * (1 / ef - 1)) / (24 * 67.5)
    elsif fuel_type == 'NaturalGas'
      # Fixed water heater thermal efficiency per PNNL
      water_heater_eff = 0.82
      # Calculate the Recovery Efficiency (RE)
      # based on a fixed capacity of 75,000 Btu/hr
      # and a fixed volume of 40 gallons by solving
      # this system of equations:
      # ua = (1/.95-1/re)/(67.5*(24/41094-1/(re*cap)))
      # 0.82 = (ua*67.5+cap*re)/cap
      # Solutions to the system of equations were determined
      # for discrete values of EF and modeled using a regression
      re = -0.1137 * ef**2 + 0.1997 * ef + 0.731
      # Calculate the skin loss coefficient (UA)
      # Input capacity is assumed to be the output capacity
      # divided by a burner efficiency of 80%
      ua_btu_per_hr_per_f = (water_heater_eff - re) * capacity_btu_per_hr / 0.8 / 67.5
    end
    # Two booster water heaters
    ua_btu_per_hr_per_f = water_heater_mixed.name.to_s.include?('Booster') ? ua_btu_per_hr_per_f * 2 : ua_btu_per_hr_per_f
  end

  # Typically specified this way for large electric water heaters
  if wh_props['standby_loss_base'] && wh_props['standby_loss_volume_allowance']
    # Fixed water heater efficiency per PNNL
    water_heater_eff = 1.0
    # Calculate the max allowable standby loss (SL)
    sl_base = wh_props['standby_loss_base']
    sl_drt = wh_props['standby_loss_volume_allowance']
    sl_btu_per_hr = sl_base + (sl_drt * Math.sqrt(volume_gal))
    # Calculate the skin loss coefficient (UA)
    ua_btu_per_hr_per_f = @instvarbuilding_type == 'MidriseApartment' ? sl_btu_per_hr / 70 * 23 :  sl_btu_per_hr / 70
    ua_btu_per_hr_per_f = water_heater_mixed.name.to_s.include?('Booster') ? ua_btu_per_hr_per_f * 2 : ua_btu_per_hr_per_f
  end

  # Typically specified this way for newer large electric water heaters
  if wh_props['hourly_loss_base'] && wh_props['hourly_loss_volume_allowance']
    # Fixed water heater efficiency per PNNL
    water_heater_eff = 1.0
    # Calculate the percent loss per hr
    hr_loss_base = wh_props['hourly_loss_base']
    hr_loss_allow = wh_props['hourly_loss_volume_allowance']
    hrly_loss_pct = hr_loss_base + (hr_loss_allow / volume_gal) / 100.0
    # Convert to Btu/hr, assuming:
    # Water at 120F, density = 8.25 lb/gal
    # 1 Btu to raise 1 lb of water 1 F
    # Therefore 8.25 Btu / gal of water * deg F
    # 70F delta-T between water and zone
    hrly_loss_btu_per_hr = hrly_loss_pct * volume_gal * 8.25 * 70
    # Calculate the skin loss coefficient (UA)
    ua_btu_per_hr_per_f = hrly_loss_btu_per_hr / 70
  end

  # Typically specified this way for large natural gas water heaters
  if wh_props['standby_loss_capacity_allowance'] && wh_props['standby_loss_volume_allowance'] && wh_props['thermal_efficiency']
    sl_cap_adj = wh_props['standby_loss_capacity_allowance']
    sl_vol_drt = wh_props['standby_loss_volume_allowance']
    et = wh_props['thermal_efficiency']
    # Estimate storage tank volume
    tank_volume = volume_gal > 100 ? (volume_gal - 100).round(0) : 0
    wh_tank_volume = volume_gal > 100 ? 100 : volume_gal
    # SL Storage Tank: polynomial regression based on a set of manufacturer data
    sl_tank = 0.0000005 * tank_volume**3 - 0.001 * tank_volume**2 + 1.3519 * tank_volume + 64.456 # in Btu/h
    # Calculate the max allowable standby loss (SL)
    # Output capacity is assumed to be 10 * Tank volume
    # Input capacity = Output capacity / Et
    p_on = capacity_btu_per_hr / et
    sl_btu_per_hr = p_on / sl_cap_adj + sl_vol_drt * Math.sqrt(wh_tank_volume) + sl_tank
    # Calculate the skin loss coefficient (UA)
    ua_btu_per_hr_per_f = (sl_btu_per_hr * et) / 70
    # Calculate water heater efficiency
    water_heater_eff = (ua_btu_per_hr_per_f * 70 + p_on * et) / p_on
  end

  # Ensure that efficiency and UA were both set\
  if water_heater_eff.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.WaterHeaterMixed', "For #{water_heater_mixed.name}, cannot calculate efficiency, cannot apply efficiency standard.")
    return false
  end

  if ua_btu_per_hr_per_f.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.WaterHeaterMixed', "For #{water_heater_mixed.name}, cannot calculate UA, cannot apply efficiency standard.")
    return false
  end

  # Convert to SI
  ua_btu_per_hr_per_c = OpenStudio.convert(ua_btu_per_hr_per_f, 'Btu/hr*R', 'W/K').get
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.WaterHeaterMixed', "For #{water_heater_mixed.name}, skin-loss UA = #{ua_btu_per_hr_per_c} W/K.")

  # Set the water heater properties
  # Efficiency
  water_heater_mixed.setHeaterThermalEfficiency(water_heater_eff)
  # Skin loss
  water_heater_mixed.setOffCycleLossCoefficienttoAmbientTemperature(ua_btu_per_hr_per_c)
  water_heater_mixed.setOnCycleLossCoefficienttoAmbientTemperature(ua_btu_per_hr_per_c)
  # TODO: Parasitic loss (pilot light)
  # PNNL document says pilot lights were removed, but IDFs
  # still have the on/off cycle parasitic fuel consumptions filled in
  water_heater_mixed.setOnCycleParasiticFuelType(fuel_type)
  # self.setOffCycleParasiticFuelConsumptionRate(??)
  water_heater_mixed.setOnCycleParasiticHeatFractiontoTank(0)
  water_heater_mixed.setOffCycleParasiticFuelType(fuel_type)
  # self.setOffCycleParasiticFuelConsumptionRate(??)
  water_heater_mixed.setOffCycleParasiticHeatFractiontoTank(0)

  # Append the name with standards information
  water_heater_mixed.setName("#{water_heater_mixed.name} #{water_heater_eff.round(3)} Therm Eff")
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.WaterHeaterMixed', "For #{template}: #{water_heater_mixed.name}; thermal efficiency = #{water_heater_eff.round(3)}, skin-loss UA = #{ua_btu_per_hr_per_f.round}Btu/hr")

  return true
end

#water_heater_mixed_apply_prm_baseline_fuel_type(water_heater_mixed, building_type) ⇒ Bool

Applies the correct fuel type for the water heaters in the baseline model. For most standards and for most building types, the baseline uses the same fuel type as the proposed.

Parameters:

  • building_type (String)

    the building type

Returns:

  • (Bool)

    returns true if successful, false if not.



203
204
205
206
# File 'lib/openstudio-standards/standards/Standards.WaterHeaterMixed.rb', line 203

def water_heater_mixed_apply_prm_baseline_fuel_type(water_heater_mixed, building_type)
  # baseline is same as proposed per Table G3.1 item 11.b
  return true # Do nothing
end

#water_heater_mixed_find_capacity(water_heater_mixed) ⇒ Double

Finds capacity in Btu/hr

Returns:

  • (Double)

    capacity in Btu/hr to be used for find object



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/openstudio-standards/standards/Standards.WaterHeaterMixed.rb', line 211

def water_heater_mixed_find_capacity(water_heater_mixed)
  # Get the coil capacity
  capacity_w = nil
  if water_heater_mixed.heaterMaximumCapacity.is_initialized
    capacity_w = water_heater_mixed.heaterMaximumCapacity.get
  elsif water_heater_mixed.autosizedHeaterMaximumCapacity.is_initialized
    capacity_w = water_heater_mixed.autosizedHeaterMaximumCapacity.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.WaterHeaterMixed', "For #{water_heater_mixed.name} capacity is not available.")
    return false
  end

  # Convert capacity to Btu/hr
  capacity_btu_per_hr = OpenStudio.convert(capacity_w, 'W', 'Btu/hr').get

  return capacity_btu_per_hr
end

#zone_hvac_component_apply_prm_baseline_fan_power(zone_hvac_component) ⇒ Bool

Sets the fan power of zone level HVAC equipment (Fan coils, Unit Heaters, PTACs, PTHPs, VRF Terminals, WSHPs, ERVs) based on the W/cfm specified in the standard.

Returns:

  • (Bool)

    returns true if successful, false if not



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/openstudio-standards/standards/Standards.ZoneHVACComponent.rb', line 14

def zone_hvac_component_apply_prm_baseline_fan_power(zone_hvac_component)
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ZoneHVACComponent', "Setting fan power for #{zone_hvac_component.name}.")

  # Convert this to the actual class type
  zone_hvac = if zone_hvac_component.to_ZoneHVACFourPipeFanCoil.is_initialized
                zone_hvac_component.to_ZoneHVACFourPipeFanCoil.get
              elsif zone_hvac_component.to_ZoneHVACUnitHeater.is_initialized
                zone_hvac_component.to_ZoneHVACUnitHeater.get
              elsif zone_hvac_component.to_ZoneHVACPackagedTerminalAirConditioner.is_initialized
                zone_hvac_component.to_ZoneHVACPackagedTerminalAirConditioner.get
              elsif zone_hvac_component.to_ZoneHVACPackagedTerminalHeatPump.is_initialized
                zone_hvac_component.to_ZoneHVACPackagedTerminalHeatPump.get
              elsif zone_hvac_component.to_ZoneHVACTerminalUnitVariableRefrigerantFlow.is_initialized
                zone_hvac_component.to_ZoneHVACTerminalUnitVariableRefrigerantFlow.get
              elsif zone_hvac_component.to_ZoneHVACWaterToAirHeatPump.is_initialized
                zone_hvac_component.to_ZoneHVACWaterToAirHeatPump.get
              elsif zone_hvac_component.to_ZoneHVACEnergyRecoveryVentilator.is_initialized
                zone_hvac_component.to_ZoneHVACEnergyRecoveryVentilator.get
              end

  # Do nothing for other types of zone HVAC equipment
  if zone_hvac.nil?
    return false
  end

  # Determine the W/cfm
  fan_efficacy_w_per_cfm = zone_hvac_component_prm_baseline_fan_efficacy

  # Convert efficacy to metric
  # 1 cfm = 0.0004719 m^3/s
  fan_efficacy_w_per_m3_per_s = fan_efficacy_w_per_cfm / 0.0004719

  # Get the fan
  fan = if zone_hvac.supplyAirFan.to_FanConstantVolume.is_initialized
          zone_hvac.supplyAirFan.to_FanConstantVolume.get
        elsif zone_hvac.supplyAirFan.to_FanVariableVolume.is_initialized
          zone_hvac.supplyAirFan.to_FanVariableVolume.get
        elsif zone_hvac.supplyAirFan.to_FanOnOff.is_initialized
          zone_hvac.supplyAirFan.to_FanOnOff.get
        end

  # Get the maximum flow rate through the fan
  max_air_flow_rate = nil
  if fan.autosizedMaximumFlowRate.is_initialized
    max_air_flow_rate = fan.autosizedMaximumFlowRate.get
  elsif fan.maximumFlowRate.is_initialized
    max_air_flow_rate = fan.maximumFlowRate.get
  end
  max_air_flow_rate_cfm = OpenStudio.convert(max_air_flow_rate, 'm^3/s', 'ft^3/min').get

  # Set the impeller efficiency
  fan_change_impeller_efficiency(fan, fan_baseline_impeller_efficiency(fan))

  # Set the motor efficiency, preserving the impeller efficency.
  # For zone HVAC fans, a bhp lookup of 0.5bhp is always used because
  # they are assumed to represent a series of small fans in reality.
  fan_apply_standard_minimum_motor_efficiency(fan, fan_brake_horsepower(fan))

  # Calculate a new pressure rise to hit the target W/cfm
  fan_tot_eff = fan.fanEfficiency
  fan_rise_new_pa = fan_efficacy_w_per_m3_per_s * fan_tot_eff
  fan.setPressureRise(fan_rise_new_pa)

  # Calculate the newly set efficacy
  fan_power_new_w = fan_rise_new_pa * max_air_flow_rate / fan_tot_eff
  fan_efficacy_new_w_per_cfm = fan_power_new_w / max_air_flow_rate_cfm
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ZoneHVACComponent', "For #{zone_hvac_component.name}: fan efficacy set to #{fan_efficacy_new_w_per_cfm.round(2)} W/cfm.")

  return true
end

#zone_hvac_component_apply_standard_controls(zone_hvac_component) ⇒ Bool

Apply all standard required controls to the zone equipment

Returns:

  • (Bool)

    returns true if successful, false if not



168
169
170
171
172
173
174
175
176
177
178
# File 'lib/openstudio-standards/standards/Standards.ZoneHVACComponent.rb', line 168

def zone_hvac_component_apply_standard_controls(zone_hvac_component)
  # Vestibule heating control
  if zone_hvac_component_vestibule_heating_control_required?(zone_hvac_component)
    zone_hvac_component_apply_vestibule_heating_control(zone_hvac_component)
  end

  # zone ventilation occupancy control for systems with ventilation
  zone_hvac_component_occupancy_ventilation_control(zone_hvac_component)

  return true
end

#zone_hvac_component_apply_vestibule_heating_control(zone_hvac_component) ⇒ Bool

Turns off vestibule heating below 45F

Returns:

  • (Bool)

    returns true if successful, false if not



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/openstudio-standards/standards/Standards.ZoneHVACComponent.rb', line 192

def zone_hvac_component_apply_vestibule_heating_control(zone_hvac_component)
  # Ensure that the equipment is assigned to a thermal zone
  if zone_hvac_component.thermalZone.empty?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.ZoneHVACComponent', "For #{zone_hvac_component.name}: equipment is not assigned to a thermal zone, cannot apply vestibule heating control.")
    return true
  end

  # Convert this to the actual class type
  zone_hvac = if zone_hvac_component.to_ZoneHVACFourPipeFanCoil.is_initialized
                zone_hvac_component.to_ZoneHVACFourPipeFanCoil.get
              elsif zone_hvac_component.to_ZoneHVACUnitHeater.is_initialized
                zone_hvac_component.to_ZoneHVACUnitHeater.get
              elsif zone_hvac_component.to_ZoneHVACPackagedTerminalAirConditioner.is_initialized
                zone_hvac_component.to_ZoneHVACPackagedTerminalAirConditioner.get
              elsif zone_hvac_component.to_ZoneHVACPackagedTerminalHeatPump.is_initialized
                zone_hvac_component.to_ZoneHVACPackagedTerminalHeatPump.get
              end

  # Do nothing for other types of zone HVAC equipment
  if zone_hvac.nil?
    return true
  end

  # Get the heating coil and fan
  htg_coil = zone_hvac.heatingCoil
  htg_coil = if htg_coil.to_CoilHeatingGas.is_initialized
               htg_coil.to_CoilHeatingGas.get
             elsif htg_coil.to_CoilHeatingElectric.is_initialized
               htg_coil.to_CoilHeatingElectric.get
             elsif htg_coil.to_CoilHeatingWater.is_initialized
               htg_coil.to_CoilHeatingWater.get
             elsif htg_coil.to_CoilHeatingDXSingleSpeed.is_initialized
               htg_coil.to_CoilHeatingDXSingleSpeed.get
             end

  fan = zone_hvac.supplyAirFan
  fan = if fan.to_FanOnOff.is_initialized
          fan.to_FanOnOff.get
        elsif fan.to_FanConstantVolume.is_initialized
          fan.to_FanConstantVolume.get
        elsif fan.to_FanVariableVolume.is_initialized
          fan.to_FanVariableVolume.get
        end

  # Get existing heater availability schedule if present
  # or create a new one
  avail_sch = nil
  avail_sch_name = 'VestibuleHeaterAvailSch'
  if zone_hvac_component.model.getScheduleConstantByName(avail_sch_name).is_initialized
    avail_sch = zone_hvac_component.model.getScheduleConstantByName(avail_sch_name).get
  else
    avail_sch = OpenStudio::Model::ScheduleConstant.new(zone_hvac_component.model)
    avail_sch.setName(avail_sch_name)
    avail_sch.setValue(1)
  end

  # Replace the existing availabilty schedule with the one
  # that will be controlled via EMS
  htg_coil.setAvailabilitySchedule(avail_sch)
  fan.setAvailabilitySchedule(avail_sch)

  # Clean name of zone HVAC
  equip_name_clean = zone_hvac.name.get.to_s.gsub(/\W/, '').delete('_')
  # If the name starts with a number, prepend with a letter
  if equip_name_clean[0] =~ /[0-9]/
    equip_name_clean = "EQUIP#{equip_name_clean}"
  end

  # Sensors
  # Get existing OAT sensor if present
  oat_db_c_sen = nil
  if zone_hvac_component.model.getEnergyManagementSystemSensorByName('OATVestibule').is_initialized
    oat_db_c_sen = zone_hvac_component.model.getEnergyManagementSystemSensorByName('OATVestibule').get
  else
    oat_db_c_sen = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Site Outdoor Air Drybulb Temperature')
    oat_db_c_sen.setName('OATVestibule')
    oat_db_c_sen.setKeyName('Environment')
  end

  # Actuators
  avail_sch_act = OpenStudio::Model::EnergyManagementSystemActuator.new(avail_sch, 'Schedule:Constant', 'Schedule Value')
  avail_sch_act.setName("#{equip_name_clean}VestHtgAvailSch")

  # Programs
  htg_lim_f = 45
  vestibule_htg_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  vestibule_htg_prg.setName("#{equip_name_clean}VestHtgPrg")
  vestibule_htg_prg_body = <<-EMS
  IF #{oat_db_c_sen.handle} > #{OpenStudio.convert(htg_lim_f, 'F', 'C').get}
    SET #{avail_sch_act.handle} = 0
  ENDIF
  EMS
  vestibule_htg_prg.setBody(vestibule_htg_prg_body)

  # Program Calling Managers
  vestibule_htg_mgr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)
  vestibule_htg_mgr.setName("#{equip_name_clean}VestHtgMgr")
  vestibule_htg_mgr.setCallingPoint('BeginTimestepBeforePredictor')
  vestibule_htg_mgr.addProgram(vestibule_htg_prg)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.ZoneHVACComponent', "For #{zone_hvac_component.name}: Vestibule heating control applied, heating disabled below #{htg_lim_f} F.")

  return true
end

#zone_hvac_component_occupancy_ventilation_control(zone_hvac_component) ⇒ Object

If the supply air fan operating mode schedule is always off (to follow load), and the zone requires ventilation, override it to follow the zone occupancy schedule



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/openstudio-standards/standards/Standards.ZoneHVACComponent.rb', line 92

def zone_hvac_component_occupancy_ventilation_control(zone_hvac_component)
  ventilation = false
  # Zone HVAC operating schedule if providing ventilation
  # Zone HVAC components return an OptionalSchedule object for supplyAirFanOperatingModeSchedule
  # except for ZoneHVACTerminalUnitVariableRefrigerantFlow which returns a Schedule
  existing_sch = nil
  if zone_hvac_component.to_ZoneHVACFourPipeFanCoil.is_initialized
    zone_hvac_component = zone_hvac_component.to_ZoneHVACFourPipeFanCoil.get
    if zone_hvac_component.maximumOutdoorAirFlowRate.is_initialized
      oa_rate = zone_hvac_component.maximumOutdoorAirFlowRate.get
      ventilation = true if oa_rate > 0.0
    end
    ventilation = true if zone_hvac_component.isMaximumOutdoorAirFlowRateAutosized
    fan_op_sch = zone_hvac_component.supplyAirFanOperatingModeSchedule
    existing_sch = fan_op_sch.get if fan_op_sch.is_initialized
  elsif zone_hvac_component.to_ZoneHVACPackagedTerminalAirConditioner.is_initialized
    zone_hvac_component = zone_hvac_component.to_ZoneHVACPackagedTerminalAirConditioner.get
    if zone_hvac_component.outdoorAirFlowRateWhenNoCoolingorHeatingisNeeded.is_initialized
      oa_rate = zone_hvac_component.outdoorAirFlowRateWhenNoCoolingorHeatingisNeeded.get
      ventilation = true if oa_rate > 0.0
    end
    ventilation = true if zone_hvac_component.isOutdoorAirFlowRateWhenNoCoolingorHeatingisNeededAutosized
    fan_op_sch = zone_hvac_component.supplyAirFanOperatingModeSchedule
    existing_sch = fan_op_sch.get if fan_op_sch.is_initialized
  elsif zone_hvac_component.to_ZoneHVACPackagedTerminalHeatPump.is_initialized
    zone_hvac_component = zone_hvac_component.to_ZoneHVACPackagedTerminalHeatPump.get
    if zone_hvac_component.outdoorAirFlowRateWhenNoCoolingorHeatingisNeeded.is_initialized
      oa_rate = zone_hvac_component.outdoorAirFlowRateWhenNoCoolingorHeatingisNeeded.get
      ventilation = true if oa_rate > 0.0
    end
    ventilation = true if zone_hvac_component.isOutdoorAirFlowRateWhenNoCoolingorHeatingisNeededAutosized
    fan_op_sch = zone_hvac_component.supplyAirFanOperatingModeSchedule
    existing_sch = fan_op_sch.get if fan_op_sch.is_initialized
  elsif zone_hvac_component.to_ZoneHVACTerminalUnitVariableRefrigerantFlow.is_initialized
    zone_hvac_component = zone_hvac_component.to_ZoneHVACTerminalUnitVariableRefrigerantFlow.get
    if zone_hvac_component.outdoorAirFlowRateWhenNoCoolingorHeatingisNeeded.is_initialized
      oa_rate = zone_hvac_component.outdoorAirFlowRateWhenNoCoolingorHeatingisNeeded.get
      ventilation = true if oa_rate > 0.0
    end
    ventilation = true if zone_hvac_component.isOutdoorAirFlowRateWhenNoCoolingorHeatingisNeededAutosized
    existing_sch = zone_hvac_component.supplyAirFanOperatingModeSchedule
  elsif zone_hvac_component.to_ZoneHVACWaterToAirHeatPump.is_initialized
    zone_hvac_component = zone_hvac_component.to_ZoneHVACWaterToAirHeatPump.get
    if zone_hvac_component.outdoorAirFlowRateWhenNoCoolingorHeatingisNeeded.is_initialized
      oa_rate = zone_hvac_component.outdoorAirFlowRateWhenNoCoolingorHeatingisNeeded.get
      ventilation = true if oa_rate > 0.0
    end
    ventilation = true if zone_hvac_component.isOutdoorAirFlowRateWhenNoCoolingorHeatingisNeededAutosized
    fan_op_sch = zone_hvac_component.supplyAirFanOperatingModeSchedule
    existing_sch = fan_op_sch.get if fan_op_sch.is_initialized
  end
  return false unless ventilation

  # if supply air fan operating schedule is always off,
  # override to provide ventilation during occupied hours
  unless existing_sch.nil?
    if existing_sch.name.is_initialized
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.Standards.ZoneHVACComponent', "#{zone_hvac_component.name} has ventilation, and schedule is set to always on; keeping always on schedule.")
      return false if existing_sch.name.get.to_s.downcase.include? 'always on discrete'
    end
  end

  thermal_zone = zone_hvac_component.thermalZone.get
  occ_threshold = zone_hvac_unoccupied_threshold
  occ_sch = thermal_zones_get_occupancy_schedule([thermal_zone],
                                                 sch_name: "#{zone_hvac_component.name} Occ Sch",
                                                 occupied_percentage_threshold: occ_threshold)
  zone_hvac_component.setSupplyAirFanOperatingModeSchedule(occ_sch)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Standards.ZoneHVACComponent', "#{zone_hvac_component.name} has ventilation.  Setting fan operating mode schedule to align with zone occupancy schedule.")

  return true
end

#zone_hvac_component_prm_baseline_fan_efficacyObject



4
5
6
7
# File 'lib/openstudio-standards/standards/Standards.ZoneHVACComponent.rb', line 4

def zone_hvac_component_prm_baseline_fan_efficacy
  fan_efficacy_w_per_cfm = 0.3
  return fan_efficacy_w_per_cfm
end

#zone_hvac_component_vestibule_heating_control_required?(zone_hvac_component) ⇒ Bool

Determine if vestibule heating control is required. Defaults to 90.1-2004 through 2010, not required.

Returns:

  • (Bool)

    returns true if successful, false if not



184
185
186
187
# File 'lib/openstudio-standards/standards/Standards.ZoneHVACComponent.rb', line 184

def zone_hvac_component_vestibule_heating_control_required?(zone_hvac_component)
  vest_htg_control_required = false
  return vest_htg_control_required
end

#zone_hvac_unoccupied_thresholdObject

Default occupancy fraction threshold for determining if the spaces served by the zone hvac are occupied



86
87
88
# File 'lib/openstudio-standards/standards/Standards.ZoneHVACComponent.rb', line 86

def zone_hvac_unoccupied_threshold
  return 0.15
end