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.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.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.hvac_systems.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.refrigeration.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.FanConstantVolume.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.FanVariableVolume.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.ControllerWaterCoil.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.AirTerminalSingleDuctVAVReheat.rb,
lib/openstudio-standards/prototypes/common/objects/Prototype.HeatExchangerAirToAirSensibleAndLatent.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, 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

ThermalZone collapse

Construction collapse

BuildingStory collapse

PlanarSurface collapse

BoilerHotWater collapse

ScheduleCompact collapse

ScheduleRuleset collapse

ScheduleConstant collapse

WaterHeaterMixed collapse

ZoneHVACComponent collapse

ChillerElectricEIR collapse

HeatExchangerSensLat collapse

CoilCoolingDXMultiSpeed collapse

CoilHeatingDXMultiSpeed collapse

CoilHeatingGasMultiStage collapse

utilities collapse

hvac_systems collapse

refrigeration collapse

CoilHeatingGas collapse

AirTerminalSingleDuctVAVReheat collapse

ControllerWaterCoil collapse

AirTerminalSingleDuctParallelPIUReheat collapse

HeatExchangerAirToAirSensibleAndLatent collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PrototypeFan

#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.



2
3
4
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2

def space_multiplier_map
  @space_multiplier_map
end

#standards_dataObject (readonly)

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, NREL ZNE Ready 2017, NECB2011



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

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
  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



299
300
301
302
303
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 299

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)


314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 314

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

#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 (%)



259
260
261
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 259

def afue_to_thermal_eff(afue)
  return afue
end

#air_loop_hvac_add_motorized_oa_damper(air_loop_hvac, min_occ_pct = 0.15, 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.

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.15)

    the fractional value below which

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

    the occupancy schedule.

Returns:

  • (Bool)

    true if successful, false if not



2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2198

def air_loop_hvac_add_motorized_oa_damper(air_loop_hvac, min_occ_pct = 0.15, occ_sch = nil)
  # Get the airloop occupancy schedule if none supplied
  if occ_sch.nil?
    occ_sch = thermal_zone_get_occupancy_schedule(thermal_zone, 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

  # 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 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.



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
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
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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1473

def air_loop_hvac_adjust_minimum_vav_damper_positions(air_loop_hvac)
  # Total uncorrected outdoor airflow rate
  v_ou = 0.0
  air_loop_hvac.thermalZones.each do |zone|
    v_ou += thermal_zone_outdoor_airflow_rate(zone)
  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
  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
        mdp_term = term.constantMinimumAirFlowFraction
        min_zn_flow = term.fixedMinimumAirFlowRate
      end
    end

    # 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_ps
    if min_zn_flow > 0.0
      mdp = [mdp_term, mdp_oa].max.round(2)
    end
    # OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{self.name}: Zone #{zone.name} mdp_term = #{mdp_term.round(2)}, mdp_oa = #{mdp_oa.round(2)}; mdp_final = #{mdp}")

    # 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

      # Set the adjusted minimum damper position
      zone.equipment.each do |equip|
        if equip.to_AirTerminalSingleDuctVAVHeatAndCoolNoReheat.is_initialized
          term = equip.to_AirTerminalSingleDuctVAVHeatAndCoolNoReheat.get
          term.setZoneMinimumAirFlowFraction(mdp_adj)
        elsif equip.to_AirTerminalSingleDuctVAVHeatAndCoolReheat.is_initialized
          term = equip.to_AirTerminalSingleDuctVAVHeatAndCoolReheat.get
          term.setZoneMinimumAirFlowFraction(mdp_adj)
        elsif equip.to_AirTerminalSingleDuctVAVNoReheat.is_initialized
          term = equip.to_AirTerminalSingleDuctVAVNoReheat.get
          term.setConstantMinimumAirFlowFraction(mdp_adj)
        elsif equip.to_AirTerminalSingleDuctVAVReheat.is_initialized
          term = equip.to_AirTerminalSingleDuctVAVReheat.get
          term.setConstantMinimumAirFlowFraction(mdp_adj)
        end
      end

      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

  # 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



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1669

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
          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



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 312

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
      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
    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'
    allowable_fan_bhp = dsn_air_flow_cfm * 0.00094 + fan_pwr_adjustment_bhp
  elsif fan_pwr_limit_type == 'variable volume'
    allowable_fan_bhp = dsn_air_flow_cfm * 0.0013 + fan_pwr_adjustment_bhp
  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
  cfm_per_hp = dsn_air_flow_cfm / allowable_fan_bhp
  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



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 475

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



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/standards/Standards.AirLoopHVAC.rb', line 896

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
  if oa_sys.is_initialized
    oa_sys = oa_sys.get
  else
    return false # No OA system
  end
  oa_control = oa_sys.getControllerOutdoorAir

  # Apply integrated or non-integrated economizer
  if integrated_economizer_required
    oa_control.setLockoutType('NoLockout')
  else
    oa_control.setLockoutType('LockoutWithCompressor')
  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



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 766

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) ⇒ Bool

TODO:

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

Add an ERV to this airloop. Will be a rotary-type HX

Returns:

  • (Bool)

    Returns true if required, false if not.



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1314

def air_loop_hvac_apply_energy_recovery_ventilator(air_loop_hvac)
  # 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

  # Create an ERV
  erv = OpenStudio::Model::HeatExchangerAirToAirSensibleAndLatent.new(air_loop_hvac.model)
  erv.setName("#{air_loop_hvac.name} ERV")
  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)
  erv.setSupplyAirOutletTemperatureControl(true)
  erv.setHeatExchangerType('Rotary')
  erv.setFrostControlType('ExhaustOnly')
  erv.setEconomizerLockout(true)
  erv.setThresholdTemperature(-23.3) # -10F
  erv.setInitialDefrostTimeFraction(0.167)
  erv.setRateofDefrostTimeFractionIncrease(1.44)

  # Add the ERV to the OA system
  erv.addToNode(oa_system.outboardOANode.get)

  # 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 teh 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)

  # Apply the prototype Heat Exchanger power assumptions.
  heat_exchanger_air_to_air_sensible_and_latent_apply_prototype_nominal_electric_power(erv)

  # 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_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.



3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3037

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



1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1454

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



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

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-2013
  # 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



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.AirLoopHVAC.rb', line 187

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



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1027

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.



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 229

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.



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3064

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



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
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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2481

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)

  ### 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)

  ### Fan Control ###
  if fan_control

    # 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



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 34

def air_loop_hvac_apply_standard_controls(air_loop_hvac, climate_zone)
  # 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)
  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

  # 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

  # 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.
    air_loop_hvac.thermalZones.sort.each do |zone|
      if thermal_zone_demand_control_ventilation_required?(zone, climate_zone)
        thermal_zone_convert_oa_req_to_per_area(zone)
      end
    end
  else
    # For systems that do not require DCV,
    # convert OA requirements to per-area values
    # so that other features such as
    # multizone VAV optimization do not
    # incorrectly take variable occupancy into account.
    air_loop_hvac.thermalZones.sort.each do |zone|
      thermal_zone_convert_oa_req_to_per_area(zone)
    end
  end

  # SAT reset
  # TODO Prototype buildings use OAT-based SAT reset,
  # but PRM RM suggests Warmest zone based SAT reset.
  if air_loop_hvac_supply_air_temperature_reset_required?(air_loop_hvac, climate_zone)
    air_loop_hvac_enable_supply_air_temperature_reset_warmest_zone(air_loop_hvac)
  end

  # Unoccupied shutdown
  if air_loop_hvac_unoccupied_fan_shutoff_required?(air_loop_hvac)
    air_loop_hvac_enable_unoccupied_fan_shutoff(air_loop_hvac)
  else
    air_loop_hvac.setAvailabilitySchedule(air_loop_hvac.model.alwaysOnDiscreteSchedule)
  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.
    air_loop_hvac_add_motorized_oa_damper(air_loop_hvac, 0.15, air_loop_hvac.availabilitySchedule)
  else
    air_loop_hvac_remove_motorized_oa_damper(air_loop_hvac)
  end

  # Zones 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
  air_loop_hvac.thermalZones.sort.each do |zone|
    if thermal_zone_demand_control_ventilation_required?(zone, climate_zone)
      thermal_zone_convert_oa_req_to_per_area(zone)
    end
  end

  # TODO: Optimum Start
  # for systems exceeding 10,000 cfm
  # Don't think that OS will be able to do this.
  # OS currently only allows 1 availability manager
  # at a time on an AirLoopHVAC.  If we add an
  # AvailabilityManager:OptimumStart, it
  # will replace the AvailabilityManager:NightCycle.
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



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2051

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,



3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3013

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
      next if space_type.standardsSpaceType.empty?
      standards_space_type = space_type.standardsSpaceType.get
      # Counts as a data center if the name includes 'data'
      next unless standards_space_type.downcase.include?('data')
      dc_area_m2 += space.floorArea
    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.



1795
1796
1797
1798
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1795

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


1787
1788
1789
1790
1791
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1787

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.



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1705

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.



1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1434

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.



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3133

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.



1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1936

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


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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 836

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'
    case climate_zone
    when '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'
      drybulb_limit_f = 75
    when 'ASHRAE 169-2006-5A',
        'ASHRAE 169-2006-6A',
        'ASHRAE 169-2006-7A'
      drybulb_limit_f = 70
    when 'ASHRAE 169-2006-1A',
        'ASHRAE 169-2006-2A',
        'ASHRAE 169-2006-3A',
        'ASHRAE 169-2006-4A'
      drybulb_limit_f = 65
    end
  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-2006-3A’, ‘ASHRAE 169-2006-3B’, ‘ASHRAE 169-2006-3C’, ‘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-2006-6A’, ‘ASHRAE 169-2006-6B’, ‘ASHRAE 169-2006-7A’, ‘ASHRAE 169-2006-7B’, ‘ASHRAE 169-2006-8A’, ‘ASHRAE 169-2006-8B’

Parameters:

  • climate_zone (String)

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

Returns:

  • (Bool)

    returns true if an economizer is required, false if not



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 708

def air_loop_hvac_economizer_required?(air_loop_hvac, climate_zone)
  economizer_required = false

  return economizer_required if air_loop_hvac.name.to_s.include? 'Outpatient F1'

  # 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, nil)
  if econ_limits.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "Cannot find economizer limits for #{template}, #{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?

  # 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.")
    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.")
    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.



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1129

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-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'
    prohibited_types = ['FixedEnthalpy']
  when
    'ASHRAE 169-2006-1A',
      'ASHRAE 169-2006-2A',
      'ASHRAE 169-2006-3A',
      'ASHRAE 169-2006-4A'
    prohibited_types = ['DifferentialDryBulb']
  when
    'ASHRAE 169-2006-5A',
      'ASHRAE 169-2006-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.



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1807

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)

  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.



1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1414

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_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 ®



1881
1882
1883
1884
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1881

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.



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1894

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 = 5.0
  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(supplyOutletNode)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Supply air temperature reset was enabled.  When OAT > #{hi_oat_f.round}F, SAT is #{sat_at_hi_oat_f.round}F.  When OAT < #{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.



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1847

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.15) ⇒ 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.15)

    the fractional value below which

Returns:

  • (Bool)

    true if successful, false if not



2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2916

def air_loop_hvac_enable_unoccupied_fan_shutoff(air_loop_hvac, min_occ_pct = 0.15)
  # 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, 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)

  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.



2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2025

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.



1303
1304
1305
1306
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1303

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_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.



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
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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1197

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.
  controller_oa = nil
  controller_mv = nil
  oa_system = 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}, 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_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



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 270

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

  # 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

  # 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



2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2990

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 sypply 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.



2943
2944
2945
2946
2947
2948
2949
2950
2951
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2943

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.



2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2975

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.



2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2958

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

TODO:

Speed up this method. Bottleneck is ScheduleRule.getDaySchedules

This method creates a schedule where the value is zero when the overall occupancy for all zones on the airloop is below the specified threshold, and one when the overall occupancy is greater than or equal to the threshold. 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:

  • 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



2256
2257
2258
2259
2260
2261
2262
2263
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
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
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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2256

def air_loop_hvac_get_occupancy_schedule(air_loop_hvac, occupied_percentage_threshold = 0.05)
  # Get all the occupancy schedules in every space in every zone
  # served by this airloop.  Include people added via the SpaceType
  # in addition to people hard-assigned to the Space itself.
  occ_schedules_num_occ = {}
  max_occ_on_airloop = 0
  air_loop_hvac.thermalZones.each do |zone|
    # Get the people objects
    zone.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_on_airloop += 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_on_airloop += num_ppl
        end
      end
    end
  end

  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "#{air_loop_hvac.name} has #{occ_schedules_num_occ.size} unique occ schedules.")
  occ_schedules_num_occ.each do |occ_sch, num_occ|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "   #{occ_sch.name} - #{num_occ.round} people")
  end
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "   Total #{max_occ_on_airloop.round} people on #{air_loop_hvac.name}")

  # For each day of the year, determine
  # time_value_pairs = []
  year = air_loop_hvac.model.getYearDescription
  yearly_data = []
  yearly_times = OpenStudio::DateTimeVector.new
  yearly_values = []
  (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
    occ_schedules_day_schs = {}
    day_sch_num_occ = {}
    occ_schedules_num_occ.each do |occ_sch, num_occ|
      # Get the day schedules for this day
      # (there should only be one)
      day_schs = occ_sch.getDaySchedules(os_date, os_date)
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "Schedule #{occ_sch.name} has #{day_schs.size} day schs") unless day_schs.size == 1
      day_schs[0].times.each do |time|
        times_on_this_day << time.toString
      end
      day_sch_num_occ[day_schs[0]] = num_occ
    end

    # Determine the total fraction for the airloop 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)
      os_date_time = OpenStudio::DateTime.new(os_date, os_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 airloop at each time
      air_loop_occ_frac = tot_occ_at_time / max_occ_on_airloop
      occ_status = 0 # unoccupied
      if air_loop_occ_frac >= occupied_percentage_threshold
        occ_status = 1
      end

      # Add this data to the daily arrays
      daily_times << time
      daily_os_times << os_time
      daily_values << occ_status
      daily_occs << air_loop_occ_frac.round(2)
    end

    # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.AirLoopHVAC", "#{daily_times.join(', ')}                  #{daily_values.join(', ')}")

    # 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

    # OpenStudio::logFree(OpenStudio::Debug, "openstudio.standards.AirLoopHVAC", "#{simple_daily_times.join(', ')}                  {simple_daily_values.join(', ')}")

    # 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
  sch_name = "#{air_loop_hvac.name} Occ Sch"
  sch_ruleset = OpenStudio::Model::ScheduleRuleset.new(air_loop_hvac.model)
  sch_ruleset.setName(sch_name.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(air_loop_hvac.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(air_loop_hvac.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|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', weekday.to_s)
    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_occs = daily_data['daily_occs']

      # 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

      daily_os_times = daily_data['daily_os_times']
      daily_occs = daily_data['daily_occs']

      # If here, we need to make a rule to cover from the previous
      # rule to today
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "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)
        OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.AirLoopHVAC', "   Adding value #{time}, #{value}")
      end

      # Set the dates when the rule applies
      sch_rule.setStartDate(end_of_prev_rule)
      sch_rule.setEndDate(date)

      # 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

  return sch_ruleset
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)


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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 921

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-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'
      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'
      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].



2178
2179
2180
2181
2182
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2178

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)


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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2106

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 maximum 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
    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
  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.



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3180

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.



1405
1406
1407
1408
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1405

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.



1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1983

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_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



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 975

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-1A',
      'ASHRAE 169-2006-1B',
      'ASHRAE 169-2006-2A',
      'ASHRAE 169-2006-3A',
      'ASHRAE 169-2006-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 < minimum of #{min_int_area_served_m2} and the perimeter area served of #{ext_area_served_m2} ft2 < 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


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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1089

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-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'
    economizer_type = 'FixedDryBulb'
    drybulb_limit_f = 75
  when 'ASHRAE 169-2006-5A',
      'ASHRAE 169-2006-6A',
      'ASHRAE 169-2006-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.



2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2228

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_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



2843
2844
2845
2846
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2843

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)


2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2860

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.



1838
1839
1840
1841
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1838

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



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 395

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



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 435

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.



3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 3110

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.



2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2006

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)



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
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 562

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_CoilCoolingDXMultiSpeed.is_initialized ||
          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.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
      # AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed
      # AirLoopHVACUnitarySystem
    end
  end

  return total_cooling_capacity_w
end

#air_loop_hvac_unoccupied_fan_shutoff_required?(air_loop_hvac) ⇒ Bool

Determine if a system’s fans must shut off when not required.

Returns:

  • (Bool)

    true if required, false if not



2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2877

def air_loop_hvac_unoccupied_fan_shutoff_required?(air_loop_hvac)
  shutoff_required = true

  # Per 90.1 6.4.3.4.5, systems less than 0.75 HP
  # must turn off when unoccupied.
  minimum_fan_hp = 0.75

  # Determine the system fan horsepower
  total_hp = 0.0
  air_loop_hvac_supply_return_exhaust_relief_fans(air_loop_hvac).each do |fan|
    total_hp += fan_motor_horsepower(fan)
  end

  # Check the HP exception
  if total_hp < minimum_fan_hp
    shutoff_required = false
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}: Unoccupied fan shutoff not required because system fan HP of #{total_hp.round(2)} HP is less than the minimum threshold of #{minimum_fan_hp} HP.")
  end

  return shutoff_required
end

#air_loop_hvac_vav_damper_action(air_loop_hvac) ⇒ String

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

Returns:

  • (String)

    the damper control type: Single Maximum, Dual Maximum



2100
2101
2102
2103
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 2100

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)


1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
# File 'lib/openstudio-standards/standards/Standards.AirLoopHVAC.rb', line 1957

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.model.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.model.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, building_type, 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



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.AirTerminalSingleDuctVAVReheat.rb', line 13

def air_terminal_single_duct_vav_reheat_apply_initial_prototype_damper_position(air_terminal_single_duct_vav_reheat, building_type, zone_oa_per_area)
  vav_name = air_terminal_single_duct_vav_reheat.name.get
  min_damper_position = 0.3

  # High OA zones
  # Determine whether or not to use the high minimum guess.
  # Cutoff was determined by correlating apparent minimum guesses
  # to OA rates in prototypes since not well documented in papers.
  if zone_oa_per_area > 0.001 # 0.001 m^3/s*m^2 = .196 cfm/ft2
    min_damper_position = 0.7
  end

  # 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



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

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



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

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,



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/openstudio-standards/standards/Standards.AirTerminalSingleDuctVAVReheat.rb', line 62

def air_terminal_single_duct_vav_reheat_reheat_type(air_terminal_single_duct_vav_reheat)
  type = nil

  # 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.



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

def air_terminal_single_duct_vav_reheat_set_heating_cap(air_terminal_single_duct_vav_reheat)
  flow_rate_fraction = air_terminal_single_duct_vav_reheat.constantMinimumAirFlowFraction
  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 * air_terminal_single_duct_vav_reheat.constantMinimumAirFlowFraction * 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

#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



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/standards/Standards.BoilerHotWater.rb', line 114

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, 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



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

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 model_find_object(model)



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
# File 'lib/openstudio-standards/standards/Standards.BoilerHotWater.rb', line 8

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 'FuelOil#1', 'FuelOil#2'
    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



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.BoilerHotWater.rb', line 58

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
# 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



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.BuildingStory.rb', line 47

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.Model', "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

#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



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
# File 'lib/openstudio-standards/standards/Standards.ChillerElectricEIR.rb', line 98

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.model.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



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

def chiller_electric_eir_find_capacity(chiller_electric_eir)
  capacity_w = nil
  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.")
    successfully_set_all_properties = false
    return successfully_set_all_properties
  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



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
# File 'lib/openstudio-standards/standards/Standards.ChillerElectricEIR.rb', line 8

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)



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

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_tons = OpenStudio.convert(chiller_electric_eir_find_capacity(chiller_electric_eir), 'W', 'ton').get
  chlr_props = model_find_object(standards_data['chillers'], search_criteria, capacity_tons, Date.today)

  # lookup 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)
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ChillerElectricEIR', "For #{chiller_electric_eir.name}, cannot find minimum full load efficiency.")
  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



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
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingDXMultiSpeed.rb', line 8

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
      end # TODO: Add other unitary systems
    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
      end # TODO: Add other zone hvac systems
    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(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(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_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



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.CoilCoolingDXSingleSpeed.rb', line 152

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



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/standards/Standards.CoilCoolingDXSingleSpeed.rb', line 10

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)



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
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingDXSingleSpeed.rb', line 45

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, OpenStudio.convert(capacity_btu_per_hr, 'Btu/hr', 'W').get)
    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, OpenStudio.convert(capacity_btu_per_hr, 'Btu/hr', 'W').get)
    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 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_no_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, OpenStudio.convert(capacity_kbtu_per_hr, 'kBtu/hr', 'W').get)
    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_no_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, OpenStudio.convert(capacity_kbtu_per_hr, 'kBtu/hr', 'W').get)
    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



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
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingDXTwoSpeed.rb', line 103

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



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

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.CoilCoolingDXSingleSpeed', "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)



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
# File 'lib/openstudio-standards/standards/Standards.CoilCoolingDXTwoSpeed.rb', line 27

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_no_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.CoilCoolingDXSingleSpeed', "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, OpenStudio.convert(capacity_kbtu_per_hr, 'kBtu/hr', 'W').get)
    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.CoilCoolingDXSingleSpeed', "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_no_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.CoilCoolingDXSingleSpeed', "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, OpenStudio.convert(capacity_kbtu_per_hr, 'kBtu/hr', 'W').get)
    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.CoilCoolingDXSingleSpeed', "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_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
# 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(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_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



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
# File 'lib/openstudio-standards/standards/Standards.CoilHeatingDXSingleSpeed.rb', line 177

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
# 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)



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
# File 'lib/openstudio-standards/standards/Standards.CoilHeatingDXSingleSpeed.rb', line 104

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_no_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, 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_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_prototype_efficiency(coil_heating_gas) ⇒ Object

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



7
8
9
10
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.CoilHeatingGas.rb', line 7

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



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
# File 'lib/openstudio-standards/standards/Standards.CoilHeatingGasMultiStage.rb', line 8

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.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

  # 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

#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 (%)



277
278
279
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 277

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.



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
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 288

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.model.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.



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
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 388

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.model.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.



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
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 338

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.model.Model', "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.Space', 'Model has no sql file containing results, cannot lookup data.')
  end

  return vt
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



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.Construction.rb', line 203

def construction_set_glazing_shgc(construction, target_shgc)
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ConstructionBase', "Setting SHGC for #{construction.name}.")

  # Skip layer-by-layer fenestration constructions
  unless construction_simple_glazing?(construction)
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ConstructionBase', "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_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



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
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 127

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.ConstructionBase', "Setting U-Value for #{construction.name}.")
  
  # Skip layer-by-layer fenestration constructions
  unless construction_simple_glazing?(construction)
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ConstructionBase', "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.ConstructionBase', "---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.ConstructionBase', "#{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ConstructionBase', "---target_u_value_ip = #{target_u_value_ip.round(3)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ConstructionBase', "---target_r_value_ip = #{target_r_value_ip.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ConstructionBase', "---target_u_value_si = #{target_u_value_si.round(3)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ConstructionBase', "---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
  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.ConstructionBase', "---film_coeff_r_value_si = #{film_coeff_r_value_si.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ConstructionBase', "---film_coeff_u_value_si = #{film_coeff_u_value_si.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ConstructionBase', "---film_coeff_u_value_ip = #{film_coeff_u_value_ip.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ConstructionBase', "---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.ConstructionBase', "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.ConstructionBase', "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.ConstructionBase', "---ins_r_value_ip = #{ins_r_value_ip.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ConstructionBase', "---ins_u_value_ip = #{ins_u_value_ip.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ConstructionBase', "---ins_u_value_si = #{ins_u_value_si.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ConstructionBase', "---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



249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 249

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



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
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 22

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.ConstructionBase', "Setting U-Value for #{construction.name}.")

  # Skip layer-by-layer fenestration constructions
  if construction.isFenestration
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.ConstructionBase', "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?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.ConstructionBase', "Requested U-value of #{target_u_value_ip} for #{construction.name}, but this construction has no insulation layer specified.  Requested U-value will not be set.")
    return false
  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

  # 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.ConstructionBase', "#{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ConstructionBase', "---target_u_value_ip = #{target_u_value_ip.round(3)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ConstructionBase', "---target_r_value_ip = #{target_r_value_ip.round(2)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ConstructionBase', "---target_u_value_si = #{target_u_value_si.round(3)} for #{construction.name}.")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ConstructionBase', "---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.ConstructionBase', "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.getConductivity)
      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



271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 271

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.



226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/openstudio-standards/standards/Standards.Construction.rb', line 226

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

TODO:

Figure out what the reason for this is,

Sets the convergence tolerance to 0.0001 deltaC for all hot water coils.

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



11
12
13
14
15
16
17
18
19
20
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.ControllerWaterCoil.rb', line 11

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



344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 344

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



10
11
12
13
14
# File 'lib/openstudio-standards/standards/Standards.CoolingTowerSingleSpeed.rb', line 10

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



10
11
12
13
14
# File 'lib/openstudio-standards/standards/Standards.CoolingTowerTwoSpeed.rb', line 10

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



10
11
12
13
# File 'lib/openstudio-standards/standards/Standards.CoolingTowerVariableSpeed.rb', line 10

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)



144
145
146
147
148
149
150
151
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 144

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)



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/prototypes/common/objects/Prototype.utilities.rb', line 215

def cop_to_eer(cop, capacity_w = nil)
  eer = 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



242
243
244
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 242

def cop_to_kw_per_ton(cop)
  return 3.517 / cop
end

#cop_to_seer(cop) ⇒ Double

Convert from COP to SEER

Parameters:

  • cop (Double)

    COP

Returns:

  • (Double)

    Seasonal Energy Efficiency Ratio



169
170
171
172
173
174
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 169

def cop_to_seer(cop)
  delta = 0.3796**2 - 4.0 * 0.0076 * cop
  seer = (-delta**0.5 + 0.3796) / (2.0 * 0.0076)

  return seer
end

#create_curve_bicubic(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



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.utilities.rb', line 410

def create_curve_bicubic(coeffs, crv_name, min_x, max_x, min_y, max_y, min_out, max_out)
  curve = OpenStudio::Model::CurveBicubic.new(self)
  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(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



380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 380

def create_curve_biquadratic(coeffs, crv_name, min_x, max_x, min_y, max_y, min_out, max_out)
  curve = OpenStudio::Model::CurveBiquadratic.new(self)
  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



471
472
473
474
475
476
477
478
479
480
481
482
483
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 471

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



495
496
497
498
499
500
501
502
503
504
505
506
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 495

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(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



444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 444

def create_curve_quadratic(coeffs, crv_name, min_x, max_x, min_out, max_out, is_dimensionless = false)
  curve = OpenStudio::Model::CurveQuadratic.new(self)
  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

#define_space_multiplierObject



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

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)



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 183

def eer_to_cop(eer, capacity_w = nil)
  cop = 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

    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:



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
# File 'lib/openstudio-standards/standards/Standards.FanVariableVolume.rb', line 182

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
  unless air_loop.is_initialized
    return clg_sys_type
  end
  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.AirLoopHVAC', "#{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)


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
# File 'lib/openstudio-standards/standards/Standards.FanVariableVolume.rb', line 114

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.AirLoopHVAC', "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.AirLoopHVAC', "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.AirLoopHVAC', "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.



174
175
176
177
# File 'lib/openstudio-standards/standards/Standards.FanVariableVolume.rb', line 174

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.



165
166
167
168
# File 'lib/openstudio-standards/standards/Standards.FanVariableVolume.rb', line 165

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:



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
# File 'lib/openstudio-standards/standards/Standards.FanVariableVolume.rb', line 20

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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.FanZoneExhaust.rb', line 7

def fan_zone_exhaust_apply_prototype_fan_pressure_rise(fan_zone_exhaust)
  # 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]



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 521

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

#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



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/standards/Standards.HeaderedPumpsVariableSpeed.rb', line 12

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.HeatExchangerAirToAirSensibleAndLatent', "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_nominal_electric_power(heat_exchanger_air_to_air_sensible_and_latent) ⇒ Object



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.HeatExchangerAirToAirSensibleAndLatent.rb', line 4

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 rotatry 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 rotatry 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
  power = (supply_air_flow_m3_per_s * 212.5 / 0.5) + (supply_air_flow_m3_per_s * 0.9 * 162.5 / 0.5) + 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.")

  # 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

#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



196
197
198
199
200
201
202
203
204
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 196

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)



158
159
160
161
162
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 158

def hspf_to_cop_heating_no_fan(hspf)
  cop = -0.0296 * hspf * hspf + 0.7134 * hspf

  return cop
end

#intializeObject

set up template class variable.



41
42
43
# File 'lib/openstudio-standards/standards/standard.rb', line 41

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)



250
251
252
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 250

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



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 109

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_standards_databaseHash

Loads the default openstudio standards dataset.

Returns:

  • (Hash)

    a hash of standards data



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
# File 'lib/openstudio-standards/standards/standard.rb', line 75

def load_standards_database
  standards_files = []
  standards_files << 'OpenStudio_Standards_boilers.json'
  standards_files << 'OpenStudio_Standards_chillers.json'
  standards_files << 'OpenStudio_Standards_climate_zone_sets.json'
  standards_files << 'OpenStudio_Standards_climate_zones.json'
  standards_files << 'OpenStudio_Standards_construction_properties.json'
  standards_files << 'OpenStudio_Standards_construction_sets.json'
  standards_files << 'OpenStudio_Standards_constructions.json'
  standards_files << 'OpenStudio_Standards_curves.json'
  standards_files << 'OpenStudio_Standards_ground_temperatures.json'
  standards_files << 'OpenStudio_Standards_heat_pumps_heating.json'
  standards_files << 'OpenStudio_Standards_heat_pumps.json'
  standards_files << 'OpenStudio_Standards_materials.json'
  standards_files << 'OpenStudio_Standards_motors.json'
  standards_files << 'OpenStudio_Standards_prototype_inputs.json'
  standards_files << 'OpenStudio_Standards_schedules.json'
  standards_files << 'OpenStudio_Standards_space_types.json'
  standards_files << 'OpenStudio_Standards_templates.json'
  standards_files << 'OpenStudio_Standards_unitary_acs.json'
  standards_files << 'OpenStudio_Standards_heat_rejection.json'
  standards_files << 'OpenStudio_Standards_exterior_lighting.json'
  standards_files << 'OpenStudio_Standards_parking.json'
  standards_files << 'OpenStudio_Standards_entryways.json'
  standards_files << 'OpenStudio_Standards_necb_climate_zones.json'
  standards_files << 'OpenStudio_Standards_necb_fdwr.json'
  standards_files << 'OpenStudio_Standards_necb_hvac_system_selection_type.json'
  standards_files << 'OpenStudio_Standards_necb_surface_conductances.json'
  standards_files << 'OpenStudio_Standards_water_heaters.json'
  standards_files << 'OpenStudio_Standards_economizers.json'
  standards_files << 'OpenStudio_Standards_refrigerated_cases.json'
  standards_files << 'OpenStudio_Standards_walkin_refrigeration.json'
  standards_files << 'OpenStudio_Standards_refrigeration_compressors.json'
  #    standards_files << 'OpenStudio_Standards_unitary_hps.json'
  # Combine the data from the JSON files into a single hash
  top_dir = File.expand_path('../../..', File.dirname(__FILE__))
  standards_data_dir = "#{top_dir}/data/standards"
  @standards_data = {}
  standards_files.sort.each do |standards_file|
    temp = ''
    if __dir__[0] == ':' # Running from OpenStudio CLI
      temp = load_resource_relative("../../../data/standards/#{standards_file}", 'r:UTF-8')
    else
      File.open("#{standards_data_dir}/#{standards_file}", 'r:UTF-8') do |f|
        temp = f.read
      end
    end
    file_hash = JSON.parse(temp)
    @standards_data = @standards_data.merge(file_hash)
  end

  # Check that standards data was loaded
  if @standards_data.keys.size.zero?
    OpenStudio.logFree(OpenStudio::Error, 'OpenStudio Standards JSON data was not loaded correctly.')
  end
  return @standards_data
end

#model_add_baseboard(model, hot_water_loop, thermal_zones) ⇒ Array<OpenStudio::Model::ZoneHVACBaseboardConvectiveElectric, OpenStudio::Model::ZoneHVACBaseboardConvectiveWater>

Adds hydronic or electric baseboard heating to each zone.

the hot water loop that serves the baseboards. If nil, baseboards are electric. array of baseboard heaters.

Parameters:

Returns:



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4862

def model_add_baseboard(model,
                        hot_water_loop,
                        thermal_zones)

  # 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, building_type = nil) ⇒ 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

  • building_type (String) (defaults to: nil)

    the building type

Returns:

  • (OpenStudio::Model::WaterUseEquipment)


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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4583

def model_add_booster_swh_end_uses(model,
                                   swh_booster_loop,
                                   peak_flowrate,
                                   flowrate_schedule,
                                   water_use_temperature,
                                   building_type = nil)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding water fixture to #{swh_booster_loop.name}.")

  # 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("Water Fixture Def - #{rated_flow_rate_gal_per_min} gal/min")
  water_fixture_def.setPeakFlowRate(rated_flow_rate_m3_per_s)
  # Target mixed water temperature
  mixed_water_temp_f = OpenStudio.convert(water_use_temperature, 'F', 'C').get
  mixed_water_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  mixed_water_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), OpenStudio.convert(mixed_water_temp_f, 'F', 'C').get)
  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} gal/min at #{mixed_water_temp_f}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
  swh_booster_loop.addDemandBranchForComponent(swh_connection)

  return water_fixture
end

#model_add_cav(model, sys_name, hot_water_loop, thermal_zones, hvac_op_sch, oa_damper_sch, fan_efficiency, fan_motor_efficiency, fan_pressure_rise, chilled_water_loop = nil, building_type = nil) ⇒ OpenStudio::Model::AirLoopHVAC

Creates a packaged VAV system 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

Parameters:

  • sys_name (String)

    the name of the system, or nil in which case it will be defaulted

  • hot_water_loop (String)

    hot water loop to connect heating and reheat coils to.

  • thermal_zones (String)

    zones to connect to this system

  • hvac_op_sch (String)

    name of the HVAC operation schedule

  • oa_damper_sch (Double)

    name of the oa damper schedule,

  • fan_efficiency (Double)

    fan total efficiency, including motor and impeller

  • fan_motor_efficiency (Double)

    fan motor efficiency

  • fan_pressure_rise (Double)

    fan pressure rise, in Pa

  • chilled_water_loop (String) (defaults to: nil)

    chilled water loop to connect cooling coil to.

  • building_type (String) (defaults to: nil)

    the building type

Returns:



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
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
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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 1493

def model_add_cav(model,
                  sys_name,
                  hot_water_loop,
                  thermal_zones,
                  hvac_op_sch,
                  oa_damper_sch,
                  fan_efficiency,
                  fan_motor_efficiency,
                  fan_pressure_rise,
                  chilled_water_loop = nil,
                  building_type = nil)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding CAV for #{thermal_zones.size} zones.")
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "---#{zone.name}")
  end

  # hvac operation schedule
  hvac_op_sch = if hvac_op_sch.nil?
                  model.alwaysOnDiscreteSchedule
                else
                  model_add_schedule(model, hvac_op_sch)
                end

  # oa damper schedule
  oa_damper_sch = if oa_damper_sch.nil?
                    model.alwaysOnDiscreteSchedule
                  else
                    model_add_schedule(model, oa_damper_sch)
                  end

  # Hot water loop control temperatures
  hw_temp_f = 152.6 # HW setpoint 152.6F
  if building_type == 'Hospital'
    hw_temp_f = 180
  end
  hw_delta_t_r = 20 # 20F delta-T
  hw_temp_c = OpenStudio.convert(hw_temp_f, 'F', 'C').get
  hw_delta_t_k = OpenStudio.convert(hw_delta_t_r, 'R', 'K').get
  air_flow_ratio = 1

  # Air handler control temperatures
  clg_sa_temp_f = 55.04 # Central deck clg temp 55F
  prehtg_sa_temp_f = 44.6 # Preheat to 44.6F
  if building_type == 'Hospital'
    prehtg_sa_temp_f = 55.04
  end
  preclg_sa_temp_f = 55.04 # Precool to 55F
  htg_sa_temp_f = 62.06 # Central deck htg temp 62.06F
  rht_sa_temp_f = 122 # VAV box reheat to 104F
  zone_htg_sa_temp_f = 122 # Zone heating design supply air temperature to 122F
  if building_type == 'Hospital'
    htg_sa_temp_f = 104 # Central deck htg temp 104F
    # rht_sa_temp_f = 122 # VAV box reheat to 104F
    zone_htg_sa_temp_f = 104 # Zone heating design supply air temperature to 122F
  end
  clg_sa_temp_c = OpenStudio.convert(clg_sa_temp_f, 'F', 'C').get
  prehtg_sa_temp_c = OpenStudio.convert(prehtg_sa_temp_f, 'F', 'C').get
  preclg_sa_temp_c = OpenStudio.convert(preclg_sa_temp_f, 'F', 'C').get
  htg_sa_temp_c = OpenStudio.convert(htg_sa_temp_f, 'F', 'C').get
  rht_sa_temp_c = OpenStudio.convert(rht_sa_temp_f, 'F', 'C').get
  zone_htg_sa_temp_c = OpenStudio.convert(zone_htg_sa_temp_f, 'F', 'C').get

  # Air handler
  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  if sys_name.nil?
    air_loop.setName("#{thermal_zones.size} Zone CAV")
  else
    air_loop.setName(sys_name)
  end
  air_loop.setAvailabilitySchedule(hvac_op_sch)

  # Air handler supply air setpoint
  sa_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  sa_temp_sch.setName("Supply Air Temp - #{clg_sa_temp_f}F")
  sa_temp_sch.defaultDaySchedule.setName("Supply Air Temp - #{clg_sa_temp_f}F Default")
  sa_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), clg_sa_temp_c)

  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)

  # Air handler sizing
  sizing_system = air_loop.sizingSystem
  sizing_system.setMinimumSystemAirFlowRatio(air_flow_ratio)
  sizing_system.setPreheatDesignTemperature(prehtg_sa_temp_c)
  sizing_system.setPrecoolDesignTemperature(preclg_sa_temp_c)
  sizing_system.setCentralCoolingDesignSupplyAirTemperature(clg_sa_temp_c)
  sizing_system.setCentralHeatingDesignSupplyAirTemperature(htg_sa_temp_c)
  if building_type == 'Hospital'
    sizing_system.setSizingOption('NonCoincident')
  else
    sizing_system.setSizingOption('Coincident')
  end
  sizing_system.setAllOutdoorAirinCooling(false)
  sizing_system.setAllOutdoorAirinHeating(false)
  sizing_system.setSystemOutdoorAirMethod('ZoneSum')

  # Fan
  fan = OpenStudio::Model::FanConstantVolume.new(model, model.alwaysOnDiscreteSchedule)
  fan.setName("#{air_loop.name} Fan")
  if building_type == 'Hospital'
    fan.setFanEfficiency(0.61425)
    fan.setMotorEfficiency(0.945)
    fan.setPressureRise(1018.41)
  else
    fan.setFanEfficiency(fan_efficiency)
    fan.setMotorEfficiency(fan_motor_efficiency)
    fan.setPressureRise(fan_pressure_rise)
  end
  fan.addToNode(air_loop.supplyInletNode)
  fan.setEndUseSubcategory('CAV system Fans')

  # Air handler heating coil
  htg_coil = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule)
  htg_coil.addToNode(air_loop.supplyInletNode)
  hot_water_loop.addDemandBranchForComponent(htg_coil)
  htg_coil.setName("#{air_loop.name} Main Htg Coil")
  htg_coil.controllerWaterCoil.get.setName("#{air_loop.name} Main Htg Coil Controller")
  htg_coil.setRatedInletWaterTemperature(hw_temp_c)
  htg_coil.setRatedInletAirTemperature(prehtg_sa_temp_c)
  htg_coil.setRatedOutletWaterTemperature(hw_temp_c - hw_delta_t_k)
  htg_coil.setRatedOutletAirTemperature(htg_sa_temp_c)

  # Air handler cooling coil

  if chilled_water_loop.nil?
    clg_coil = OpenStudio::Model::CoilCoolingDXTwoSpeed.new(model)
  else
    clg_coil = OpenStudio::Model::CoilCoolingWater.new(model, model.alwaysOnDiscreteSchedule)
    clg_coil.setHeatExchangerConfiguration('CrossFlow')
    chilled_water_loop.addDemandBranchForComponent(clg_coil)
    clg_coil.controllerWaterCoil.get.setName("#{air_loop.name} Clg Coil Controller")
  end
  clg_coil.setName("#{air_loop.name} Clg Coil")
  clg_coil.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.setMinimumOutdoorAirSchedule(motorized_oa_damper_sch)
  oa_intake_controller.setMinimumFractionofOutdoorAirSchedule(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 Sys")
  oa_intake.addToNode(air_loop.supplyInletNode)

  # The oa system needs to be added before setting the night cycle control
  air_loop.setNightCycleControlType('CycleOnAny')

  # Connect the CAV system to each zone
  thermal_zones.each do |zone|
    if building_type == 'Hospital'
      # CAV terminal
      terminal = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule)
      terminal.setName("#{zone.name} CAV Term")
    else
      # Reheat coil
      rht_coil = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule)
      rht_coil.setName("#{zone.name} Rht Coil")
      rht_coil.setRatedInletWaterTemperature(hw_temp_c)
      rht_coil.setRatedInletAirTemperature(htg_sa_temp_c)
      rht_coil.setRatedOutletWaterTemperature(hw_temp_c - hw_delta_t_k)
      rht_coil.setRatedOutletAirTemperature(rht_sa_temp_c)
      hot_water_loop.addDemandBranchForComponent(rht_coil)

      # VAV terminal
      terminal = OpenStudio::Model::AirTerminalSingleDuctVAVReheat.new(model, model.alwaysOnDiscreteSchedule, rht_coil)
      terminal.setName("#{zone.name} VAV Term")
      terminal.setZoneMinimumAirFlowMethod('Constant')
      air_terminal_single_duct_vav_reheat_apply_initial_prototype_damper_position(terminal, building_type, thermal_zone_outdoor_airflow_rate_per_area(zone))
      terminal.setMaximumFlowPerZoneFloorAreaDuringReheat(0.0)
      terminal.setMaximumFlowFractionDuringReheat(0.5)
      terminal.setMaximumReheatAirTemperature(rht_sa_temp_c)
    end
    air_loop.addBranchForZone(zone, terminal.to_StraightComponent)

    # Zone sizing
    # TODO Create general logic for cooling airflow method.
    # Large hotel uses design day with limit, school uses design day.
    sizing_zone = zone.sizingZone
    if building_type == 'SecondarySchool'
      sizing_zone.setCoolingDesignAirFlowMethod('DesignDay')
    else
      sizing_zone.setCoolingDesignAirFlowMethod('DesignDayWithLimit')
    end
    sizing_zone.setHeatingDesignAirFlowMethod('DesignDay')
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(clg_sa_temp_c)
    # sizing_zone.setZoneHeatingDesignSupplyAirTemperature(rht_sa_temp_c)
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(zone_htg_sa_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, cooling, ventilation) ⇒ Array<OpenStudio::Model::AirLoopHVAC>

Parameters:

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to add fan coil units to.

  • heating (Bool)

    if true, the unit will include a NaturalGas heating coil

  • cooling (Bool)

    if true, the unit will include a DX cooling coil

  • ventilation (Bool)

    if true, the unit will include an OA intake

Returns:



5213
5214
5215
5216
5217
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
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5213

def model_add_central_air_source_heat_pump(model,
                                           thermal_zones,
                                           heating,
                                           cooling,
                                           ventilation)

  equip_name = 'Central Air Source HP'

  # Defaults
  fan_pressure_rise_in = 0.5 # 0.5 in W.C.
  hspf = 7.7
  seer = 13
  eer = 11.4
  cop = 3.05
  shr = 0.73
  ac_w_per_cfm = 0.365
  min_hp_oat_f = 0
  sat_htg_f = 120
  sat_clg_f = 55
  crank_case_heat_w = 0
  crank_case_max_temp_f = 55

  # Unit conversion
  fan_pressure_rise_pa = OpenStudio.convert(fan_pressure_rise_in, 'inH_{2}O', 'Pa').get

  # 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]

  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
  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)
  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)

  # Make the curves
  cool_cap_ft = create_curve_biquadratic(cool_cap_ft_coeffs_si, 'Cool-Cap-fT', 0, 100, 0, 100, nil, nil)
  cool_cap_fff = create_curve_quadratic(cool_cap_fflow_coeffs, 'Cool-Cap-fFF', 0, 2, 0, 2, is_dimensionless = true)
  cool_eir_ft = create_curve_biquadratic(cool_eir_ft_coeffs_si, 'Cool-EIR-fT', 0, 100, 0, 100, nil, nil)
  cool_eir_fff = create_curve_quadratic(cool_eir_fflow_coeffs, 'Cool-EIR-fFF', 0, 2, 0, 2, is_dimensionless = true)
  cool_plf_fplr = create_curve_quadratic(cool_plf_fplr_coeffs, 'Cool-PLF-fPLR', 0, 1, 0, 1, is_dimensionless = true)

  heat_cap_ft = create_curve_biquadratic(heat_cap_ft_coeffs_si, 'Heat-Cap-fT', 0, 100, 0, 100, nil, nil)
  heat_cap_fff = create_curve_quadratic(heat_cap_fflow_coeffs, 'Heat-Cap-fFF', 0, 2, 0, 2, is_dimensionless = true)
  heat_eir_ft = create_curve_biquadratic(heat_eir_ft_coeffs_si, 'Heat-EIR-fT', 0, 100, 0, 100, nil, nil)
  heat_eir_fff = create_curve_quadratic(heat_eir_fflow_coeffs, 'Heat-EIR-fFF', 0, 2, 0, 2, is_dimensionless = true)
  heat_plf_fplr = create_curve_quadratic(heat_plf_fplr_coeffs, 'Heat-PLF-fPLR', 0, 1, 0, 1, is_dimensionless = true)

  # Heating defrost curve for reverse cycle
  defrost_eir_curve = create_curve_biquadratic(defrost_eir_coeffs, 'DefrostEIR', -100, 100, -100, 100, nil, nil)

  # Unit conversion
  fan_pressure_rise_pa = OpenStudio.convert(fan_pressure_rise_in, 'inH_{2}O', 'Pa').get

  hps = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding furnace AC for #{zone.name}.")

    air_loop_name = "#{zone.name} #{equip_name}"
    air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
    air_loop.setName(air_loop_name.to_s)

    # Heating Coil
    htg_coil = nil
    supp_htg_coil = nil
    if heating
      htg_coil = OpenStudio::Model::CoilHeatingDXSingleSpeed.new(model,
                                                                 model.alwaysOnDiscreteSchedule,
                                                                 heat_cap_ft,
                                                                 heat_cap_fff,
                                                                 heat_eir_ft,
                                                                 heat_eir_fff,
                                                                 heat_plf_fplr)
      htg_coil.setName("#{air_loop_name} heating coil")
      htg_coil.setRatedCOP(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.setDefrostEnergyInputRatioFunctionofTemperatureCurve(defrost_eir_curve)
      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')

      # Supplemental Heating Coil
      supp_htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)
      supp_htg_coil.setName("#{air_loop_name} supp htg coil")
      supp_htg_coil.setEfficiency(1)
    end

    # Cooling Coil
    clg_coil = nil
    if cooling
      clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model,
                                                                 model.alwaysOnDiscreteSchedule,
                                                                 cool_cap_ft,
                                                                 cool_cap_fff,
                                                                 cool_eir_ft,
                                                                 cool_eir_fff,
                                                                 cool_plf_fplr)
      clg_coil.setName("#{air_loop_name} cooling coil")
      clg_coil.setRatedSensibleHeatRatio(shr)
      clg_coil.setRatedCOP(OpenStudio::OptionalDouble.new(cop))
      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

    # Fan
    fan = OpenStudio::Model::FanOnOff.new(model, model.alwaysOnDiscreteSchedule)
    fan.setName("#{air_loop_name} supply fan")
    fan.setEndUseSubcategory('residential hvac fan')
    fan.setFanEfficiency(0.6) # Overall Efficiency of the Supply Fan, Motor and Drive
    fan.setPressureRise(fan_pressure_rise_pa)
    fan.setMotorEfficiency(1)
    fan.setMotorInAirstreamFraction(1)

    # 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 = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
    oa_intake.setName("#{air_loop.name} OA Sys")
    oa_intake.addToNode(air_loop.supplyInletNode)
    unless ventilation
      # Disable the OA
      oa_intake_controller.setMinimumOutdoorAirSchedule(alwaysOffDiscreteSchedule)
    end

    # Unitary System (holds the coils and fan)
    unitary = OpenStudio::Model::AirLoopHVACUnitarySystem.new(model)
    unitary.setName("#{air_loop_name} zoneunitary 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) unless ventilation

    # Attach the coils and fan
    unitary.setHeatingCoil(htg_coil) if htg_coil
    unitary.setCoolingCoil(clg_coil) if clg_coil
    unitary.setSupplementalHeatingCoil(supp_htg_coil) if supp_htg_coil
    unitary.setSupplyFan(fan)
    unitary.setFanPlacement('BlowThrough')
    unitary.setSupplyAirFanOperatingModeSchedule(alwaysOffDiscreteSchedule)

    # Diffuser
    diffuser = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule)
    diffuser.setName(" #{zone.name} direct air")
    air_loop.addBranchForZone(zone, diffuser)

    hps << air_loop
  end

  return hps
end

#model_add_chw_loop(model, chw_pumping_type, chiller_cooling_type, chiller_condenser_type, chiller_compressor_type, cooling_fuel, condenser_water_loop = nil, building_type = nil, num_chillers = 1) ⇒ OpenStudio::Model::PlantLoop

Electricity, DistrictCooling

Parameters:

  • chw_pumping_type (String)

    valid choices are const_pri, const_pri_var_sec

  • chiller_cooling_type (String)

    valid choices are AirCooled, WaterCooled

  • chiller_condenser_type (String)

    valid choices are WithCondenser, WithoutCondenser, nil

  • chiller_compressor_type (String)

    valid choices are Centrifugal, Reciprocating, Rotary Screw, Scroll, nil

  • cooling_fuel (String)

    cooling fuel. Valid choices are:

  • 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.

Returns:



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 131

def model_add_chw_loop(model,
                       chw_pumping_type,
                       chiller_cooling_type,
                       chiller_condenser_type,
                       chiller_compressor_type,
                       cooling_fuel,
                       condenser_water_loop = nil,
                       building_type = nil,
                       num_chillers = 1)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding chilled water loop.')

  # Chilled water loop
  chilled_water_loop = OpenStudio::Model::PlantLoop.new(model)
  chilled_water_loop.setName('Chilled Water Loop')
  chilled_water_loop.setMaximumLoopTemperature(98)
  chilled_water_loop.setMinimumLoopTemperature(1)

  # Chilled water loop controls
  chw_temp_f = 44 # CHW setpoint 44F
  chw_delta_t_r = 10.1 # 10.1F delta-T
  # 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
  if building_type == 'LargeHotel'
    chw_temp_f = 45 # CHW setpoint 45F
    chw_delta_t_r = 12 # 12F delta-T
  end
  chw_temp_c = OpenStudio.convert(chw_temp_f, 'F', 'C').get
  chw_delta_t_k = OpenStudio.convert(chw_delta_t_r, 'R', 'K').get
  chw_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  chw_temp_sch.setName("Chilled Water Loop Temp - #{chw_temp_f}F")
  chw_temp_sch.defaultDaySchedule.setName("Chilled Water Loop Temp - #{chw_temp_f}F Default")
  chw_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), chw_temp_c)
  chw_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, chw_temp_sch)
  chw_stpt_manager.setName('Chilled water loop setpoint manager')
  chw_stpt_manager.addToNode(chilled_water_loop.supplyOutletNode)

  sizing_plant = chilled_water_loop.sizingPlant
  sizing_plant.setLoopType('Cooling')
  sizing_plant.setDesignLoopExitTemperature(chw_temp_c)
  sizing_plant.setLoopDesignTemperatureDifference(chw_delta_t_k)

  # 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 Pump')
    pri_chw_pump_head_ft_h2o = 60.0
    pri_chw_pump_head_press_pa = OpenStudio.convert(pri_chw_pump_head_ft_h2o, 'ftH_{2}O', 'Pa').get
    pri_chw_pump.setRatedPumpHead(pri_chw_pump_head_press_pa)
    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 Primary Pump')
    pri_chw_pump_head_ft_h2o = 15
    pri_chw_pump_head_press_pa = OpenStudio.convert(pri_chw_pump_head_ft_h2o, 'ftH_{2}O', 'Pa').get
    pri_chw_pump.setRatedPumpHead(pri_chw_pump_head_press_pa)
    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 Secondary Pump')
    sec_chw_pump_head_ft_h2o = 45
    sec_chw_pump_head_press_pa = OpenStudio.convert(sec_chw_pump_head_ft_h2o, 'ftH_{2}O', 'Pa').get
    sec_chw_pump.setRatedPumpHead(sec_chw_pump_head_press_pa)
    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')
  end

  # DistrictCooling
  if cooling_fuel == 'DistrictCooling'
    dist_clg = OpenStudio::Model::DistrictCooling.new(model)
    dist_clg.setName('Purchased Cooling')
    dist_clg.autosizeNominalCapacity
    chilled_water_loop.addSupplyBranchForComponent(dist_clg)
  # Chiller
  else

    # Make the correct type of chiller based these properties
    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(chw_temp_c)
      ref_cond_wtr_temp_f = 95
      ref_cond_wtr_temp_c = OpenStudio.convert(ref_cond_wtr_temp_f, 'F', 'C').get
      chiller.setReferenceEnteringCondenserFluidTemperature(ref_cond_wtr_temp_c)
      chiller.setMinimumPartLoadRatio(0.15)
      chiller.setMaximumPartLoadRatio(1.0)
      chiller.setOptimumPartLoadRatio(1.0)
      chiller.setMinimumUnloadingRatio(0.25)
      chiller.setCondenserType('AirCooled')
      chiller.setLeavingChilledWaterLowerTemperatureLimit(OpenStudio.convert(36, 'F', 'C').get)
      chiller.setChillerFlowMode('ConstantFlow')

      if building_type == 'LargeHotel' || building_type == 'Hospital'
        chiller.setSizingFactor(0.5)
      end

      # if building_type == "LargeHotel"
      # TODO: Yixing. Add the temperature setpoint and change the flow mode will cost the simulation with
      # thousands of Severe Errors. Need to figure this out later.
      # chiller.setChillerFlowMode('LeavingSetpointModulated')
      # chiller_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(self,chw_temp_sch)
      # chiller_stpt_manager.setName("chiller outlet setpoint manager")
      # chiller_stpt_manager.addToNode(chiller.supplyOutletModelObject.get.to_Node.get)
      # end

      # Connect the chiller to the condenser loop if
      # one was supplied.
      if condenser_water_loop
        condenser_water_loop.addDemandBranchForComponent(chiller)
        chiller.setCondenserType('WaterCooled')
      end
    end
  end

  # chilled water loop pipes
  chiller_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  chilled_water_loop.addSupplyBranchForComponent(chiller_bypass_pipe)
  coil_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  chilled_water_loop.addDemandBranchForComponent(coil_bypass_pipe)
  supply_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  supply_outlet_pipe.addToNode(chilled_water_loop.supplyOutletNode)
  demand_inlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_inlet_pipe.addToNode(chilled_water_loop.demandInletNode)
  demand_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_outlet_pipe.addToNode(chilled_water_loop.demandOutletNode)

  return chilled_water_loop
end

#model_add_constant_schedule_ruleset(model, value, name = nil) ⇒ Object

Create constant ScheduleRuleset

Parameters:

  • value (double)

    the value to use, 24-7, 365

  • name (string) (defaults to: nil)

    the name of the schedule

Returns:

  • schedule



2160
2161
2162
2163
2164
2165
2166
2167
2168
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2160

def model_add_constant_schedule_ruleset(model, value, name = nil)
  schedule = OpenStudio::Model::ScheduleRuleset.new(model)
  unless name.nil?
    schedule.setName(name)
    schedule.defaultDaySchedule.setName("#{name} Default")
  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.



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
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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2388

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

  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



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
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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2547

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
    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)
  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
  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
  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

  # Interior surfaces constructions
  interior_surfaces = OpenStudio::Model::DefaultSurfaceConstructions.new(model)
  construction_set.setDefaultInteriorSurfaceConstructions(interior_surfaces)
  construction_name = data['interior_floors']
  unless construction_name.nil?
    interior_surfaces.setFloorConstruction(model_add_construction(model, construction_name))
  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
  construction_name = data['exterior_glass_doors']
  unless construction_name.nil?
    exterior_subsurfaces.setGlassDoorConstruction(model_add_construction(model, construction_name))
  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_curve(model, curve_name) ⇒ Object

Adds a curve from the OpenStudio-Standards dataset to the model based on the curve name.



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2728

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
  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, cooling_tower_type, cooling_tower_fan_type, cooling_tower_capacity_control, number_of_cells_per_tower, number_cooling_towers = 1, building_type = nil) ⇒ OpenStudio::Model::PlantLoop

Creates a condenser water loop and adds it to the model.

Parameters:

  • cooling_tower_type (String)

    valid choices are Open Cooling Tower, Closed Cooling Tower

  • cooling_tower_fan_type (String)

    valid choices are Centrifugal, Propeller or Axial

  • cooling_tower_capacity_control (String)

    valid choices are Fluid Bypass, Fan Cycling, TwoSpeed Fan, Variable Speed Fan

  • number_of_cells_per_tower (Integer)

    the number of discrete cells per tower

  • number_cooling_towers (Integer) (defaults to: 1)

    the number of cooling towers to be added (in parallel)

  • building_type (String) (defaults to: nil)

    the building type

Returns:



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 291

def model_add_cw_loop(model,
                      cooling_tower_type,
                      cooling_tower_fan_type,
                      cooling_tower_capacity_control,
                      number_of_cells_per_tower,
                      number_cooling_towers = 1,
                      building_type = nil)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding condenser water loop.')

  # Condenser water loop
  condenser_water_loop = OpenStudio::Model::PlantLoop.new(model)
  condenser_water_loop.setName('Condenser Water Loop')
  condenser_water_loop.setMaximumLoopTemperature(80)
  condenser_water_loop.setMinimumLoopTemperature(5)

  # Condenser water loop controls
  cw_temp_f = 70 # CW setpoint 70F
  cw_temp_sizing_f = 85 # CW sized to deliver 85F
  cw_delta_t_r = 10 # 10F delta-T
  cw_approach_delta_t_r = 7 # 7F approach
  cw_temp_c = OpenStudio.convert(cw_temp_f, 'F', 'C').get
  cw_temp_sizing_c = OpenStudio.convert(cw_temp_sizing_f, 'F', 'C').get
  cw_delta_t_k = OpenStudio.convert(cw_delta_t_r, 'R', 'K').get
  cw_approach_delta_t_k = OpenStudio.convert(cw_approach_delta_t_r, 'R', 'K').get
  cw_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  cw_temp_sch.setName("Condenser Water Loop Temp - #{cw_temp_f}F")
  cw_temp_sch.defaultDaySchedule.setName("Condenser Water Loop Temp - #{cw_temp_f}F Default")
  cw_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), cw_temp_c)
  cw_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, cw_temp_sch)
  cw_stpt_manager.addToNode(condenser_water_loop.supplyOutletNode)
  sizing_plant = condenser_water_loop.sizingPlant
  sizing_plant.setLoopType('Condenser')
  sizing_plant.setDesignLoopExitTemperature(cw_temp_sizing_c)
  sizing_plant.setLoopDesignTemperatureDifference(cw_delta_t_k)

  # Condenser water pump #TODO make this into a HeaderedPump:VariableSpeed
  cw_pump = OpenStudio::Model::PumpConstantSpeed.new(model)
  cw_pump.setName('Condenser Water Loop Pump')
  cw_pump_head_ft_h2o = 49.7
  cw_pump_head_press_pa = OpenStudio.convert(cw_pump_head_ft_h2o, 'ftH_{2}O', 'Pa').get
  cw_pump.setRatedPumpHead(cw_pump_head_press_pa)
  cw_pump.setPumpControlType('Intermittent')
  cw_pump.addToNode(condenser_water_loop.supplyInletNode)

  # Cooling towers
  # Per PNNL PRM Reference Manual
  number_cooling_towers.times do |_i|
    sizing_factor = 1 / number_cooling_towers
    twr_name = "#{cooling_tower_fan_type} #{cooling_tower_capacity_control} #{cooling_tower_type}"

    # 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.setDesignApproachTemperature(cw_approach_delta_t_k)
      cooling_tower.setDesignRangeTemperature(cw_delta_t_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.Model.Model', "#{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(twr_name)
      cooling_tower.setSizingFactor(sizing_factor)
      cooling_tower.setNumberofCells(number_of_cells_per_tower)
      condenser_water_loop.addSupplyBranchForComponent(cooling_tower)
    end
  end

  # Condenser water loop pipes
  cooling_tower_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  condenser_water_loop.addSupplyBranchForComponent(cooling_tower_bypass_pipe)
  chiller_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  condenser_water_loop.addDemandBranchForComponent(chiller_bypass_pipe)
  supply_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  supply_outlet_pipe.addToNode(condenser_water_loop.supplyOutletNode)
  demand_inlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_inlet_pipe.addToNode(condenser_water_loop.demandInletNode)
  demand_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_outlet_pipe.addToNode(condenser_water_loop.demandOutletNode)

  return condenser_water_loop
end

#model_add_data_center_hvac(model, sys_name, hot_water_loop, heat_pump_loop, thermal_zones, hvac_op_sch, oa_damper_sch, main_data_center = false) ⇒ Array<OpenStudio::Model::AirLoopHVAC>

Creates a data center PSZ-AC system for each zone.

or nil in which case will be defaulted to always on or nil in which case will be defaulted to always open center in the building.

Parameters:

  • sys_name (String)

    the name of the system, or nil in which case it will be defaulted

  • hot_water_loop (String)

    hot water loop to connect heatin coil to

  • heat_pump_loop (String)

    heat pump water loop to connect heat pump to

  • thermal_zones (String)

    zones to connect to this system

  • hvac_op_sch (String)

    name of the HVAC operation schedule

  • oa_damper_sch (Double)

    name of the oa damper schedule,

  • main_data_center (Bool) (defaults to: false)

    whether or not this is the main data

Returns:



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
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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 2555

def model_add_data_center_hvac(model,
                               sys_name,
                               hot_water_loop,
                               heat_pump_loop,
                               thermal_zones,
                               hvac_op_sch,
                               oa_damper_sch,
                               main_data_center = false)

  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding data center HVAC for #{zone.name}.")
  end

  hw_temp_f = 180 # HW setpoint 180F
  hw_delta_t_r = 20 # 20F delta-T
  hw_temp_c = OpenStudio.convert(hw_temp_f, 'F', 'C').get
  hw_delta_t_k = OpenStudio.convert(hw_delta_t_r, 'R', 'K').get

  # control temps used across all air handlers
  clg_sa_temp_f = 55 # Central deck clg temp 55F
  prehtg_sa_temp_f = 44.6 # Preheat to 44.6F
  htg_sa_temp_f = 55 # Central deck htg temp 55F
  rht_sa_temp_f = 104 # VAV box reheat to 104F

  clg_sa_temp_c = OpenStudio.convert(clg_sa_temp_f, 'F', 'C').get
  prehtg_sa_temp_c = OpenStudio.convert(prehtg_sa_temp_f, 'F', 'C').get
  htg_sa_temp_c = OpenStudio.convert(htg_sa_temp_f, 'F', 'C').get
  rht_sa_temp_c = OpenStudio.convert(rht_sa_temp_f, 'F', 'C').get

  # hvac operation schedule
  hvac_op_sch = if hvac_op_sch.nil?
                  model.alwaysOnDiscreteSchedule
                else
                  model_add_schedule(model, hvac_op_sch)
                end

  # oa damper schedule
  oa_damper_sch = if oa_damper_sch.nil?
                    model.alwaysOnDiscreteSchedule
                  else
                    model_add_schedule(model, oa_damper_sch)
                  end

  # Make a PSZ-AC for each zone
  air_loops = []
  thermal_zones.each do |zone|
    air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
    if sys_name.nil?
      air_loop.setName("#{zone.name} PSZ-AC Data Center")
    else
      air_loop.setName("#{zone.name} #{sys_name}")
    end
    air_loops << air_loop
    air_loop.setAvailabilitySchedule(hvac_op_sch)

    # When an air_loop is contructed, its constructor creates a sizing:system object
    # the default sizing:system contstructor makes a system:sizing object
    # appropriate for a multizone VAV system
    # this systems is a constant volume system with no VAV terminals,
    # and therfore needs different default settings
    air_loop_sizing = air_loop.sizingSystem # TODO units
    air_loop_sizing.setTypeofLoadtoSizeOn('Sensible')
    air_loop_sizing.autosizeDesignOutdoorAirFlowRate
    air_loop_sizing.setMinimumSystemAirFlowRatio(1.0)
    air_loop_sizing.setPreheatDesignTemperature(7.0)
    air_loop_sizing.setPreheatDesignHumidityRatio(0.008)
    air_loop_sizing.setPrecoolDesignTemperature(12.8)
    air_loop_sizing.setPrecoolDesignHumidityRatio(0.008)
    air_loop_sizing.setCentralCoolingDesignSupplyAirTemperature(12.8)
    air_loop_sizing.setCentralHeatingDesignSupplyAirTemperature(40.0)
    air_loop_sizing.setSizingOption('Coincident')
    air_loop_sizing.setAllOutdoorAirinCooling(false)
    air_loop_sizing.setAllOutdoorAirinHeating(false)
    air_loop_sizing.setCentralCoolingDesignSupplyAirHumidityRatio(0.0085)
    air_loop_sizing.setCentralHeatingDesignSupplyAirHumidityRatio(0.0080)
    air_loop_sizing.setCoolingDesignAirFlowMethod('DesignDay')
    air_loop_sizing.setCoolingDesignAirFlowRate(0.0)
    air_loop_sizing.setHeatingDesignAirFlowMethod('DesignDay')
    air_loop_sizing.setHeatingDesignAirFlowRate(0.0)
    air_loop_sizing.setSystemOutdoorAirMethod('ZoneSum')

    # Zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(12.8)
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(40.0)

    # Add a setpoint manager single zone reheat to control the
    # supply air temperature based on the needs of this zone
    setpoint_mgr_single_zone_reheat = OpenStudio::Model::SetpointManagerSingleZoneReheat.new(model)
    setpoint_mgr_single_zone_reheat.setControlZone(zone)

    fan = OpenStudio::Model::FanOnOff.new(model, hvac_op_sch) # Set fan op sch manually since fwd translator doesn't
    fan.setName("#{air_loop.name} Fan")
    fan_static_pressure_in_h2o = 2.5
    fan_static_pressure_pa = OpenStudio.convert(fan_static_pressure_in_h2o, 'inH_{2}O', 'Pa').get
    fan.setPressureRise(fan_static_pressure_pa)
    fan.setFanEfficiency(0.54)
    fan.setMotorEfficiency(0.90)

    htg_coil = OpenStudio::Model::CoilHeatingWaterToAirHeatPumpEquationFit.new(model)
    htg_coil.setName("#{air_loop.name} Water-to-Air HP Htg Coil")
    htg_coil.setRatedHeatingCoefficientofPerformance(4.2) # TODO: add this to standards
    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)

    heat_pump_loop.addDemandBranchForComponent(htg_coil)

    clg_coil = OpenStudio::Model::CoilCoolingWaterToAirHeatPumpEquationFit.new(model)
    clg_coil.setName("#{air_loop.name} Water-to-Air HP Clg Coil")
    clg_coil.setRatedCoolingCoefficientofPerformance(3.4) # TODO: add this to standards

    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)

    heat_pump_loop.addDemandBranchForComponent(clg_coil)

    supplemental_htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)
    supplemental_htg_coil.setName("#{air_loop.name} Electric Backup Htg Coil")

    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_system = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_controller)
    oa_system.setName("#{air_loop.name} OA Sys")

    # Add the components to the air loop
    # in order from closest to zone to furthest from zone
    supply_inlet_node = air_loop.supplyInletNode

    if main_data_center
      humidifier = OpenStudio::Model::HumidifierSteamElectric.new(model)
      humidifier.setRatedCapacity(3.72E-5)
      humidifier.setRatedPower(100_000)
      humidifier.setName("#{air_loop.name} Electric Steam Humidifier")

      extra_elec_htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)
      extra_elec_htg_coil.setName("#{air_loop.name} Electric Htg Coil")

      extra_water_htg_coil = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule)
      extra_water_htg_coil.setName("#{air_loop.name} Water Htg Coil")
      extra_water_htg_coil.setRatedInletWaterTemperature(hw_temp_c)
      extra_water_htg_coil.setRatedInletAirTemperature(prehtg_sa_temp_c)
      extra_water_htg_coil.setRatedOutletWaterTemperature(hw_temp_c - hw_delta_t_k)
      extra_water_htg_coil.setRatedOutletAirTemperature(htg_sa_temp_c)
      hot_water_loop.addDemandBranchForComponent(extra_water_htg_coil)

      extra_water_htg_coil.addToNode(supply_inlet_node)
      extra_elec_htg_coil.addToNode(supply_inlet_node)
      humidifier.addToNode(supply_inlet_node)

      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

    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 HP")
    unitary_system.setControllingZoneorThermostatLocation(zone)
    unitary_system.setMaximumOutdoorDryBulbTemperatureforSupplementalHeaterOperation(OpenStudio.convert(40, 'F', 'C').get)
    unitary_system.setFanPlacement('BlowThrough')
    unitary_system.setSupplyAirFanOperatingModeSchedule(hvac_op_sch)
    unitary_system.setSupplyAirFanOperatingModeSchedule(model.alwaysOnDiscreteSchedule)
    unitary_system.addToNode(supply_inlet_node)

    setpoint_mgr_single_zone_reheat.setMinimumSupplyAirTemperature(OpenStudio.convert(55, 'F', 'C').get)
    setpoint_mgr_single_zone_reheat.setMaximumSupplyAirTemperature(OpenStudio.convert(104, 'F', 'C').get)

    # Add the OA system
    oa_system.addToNode(supply_inlet_node)

    # Attach the nightcycle manager to the supply outlet node
    setpoint_mgr_single_zone_reheat.addToNode(air_loop.supplyOutletNode)
    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.addBranchForZone(zone, diffuser.to_StraightComponent)
  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



2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 2527

def model_add_data_center_load(model, space, dc_watts_per_area)
  # 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.



1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1872

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

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
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
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 6

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 = {
      'ASHRAE 169-2006-1A' => 'USA_FL_Miami.Intl.AP.722020_TMY3.epw',
      'ASHRAE 169-2006-1B' => 'SAU_Riyadh.404380_IWEC.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',
      # 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'
  }

  # 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/'))
    puts "Extracting weather files 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).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)/
      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}.")
    puts "Could not find .ddy file for: #{ddy_file}."
    success = false
  end

  return success
end

#model_add_district_ambient_loop(model) ⇒ OpenStudio::Model::PlantLoop

TODO:

handle ground and heat pump with this; make heating/cooling source options (boiler, fluid cooler, district)

Adds an ambient condenser water loop that will be used in a district to connect buildings as a shared sink/source for heat pumps.

Returns:



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 624

def model_add_district_ambient_loop(model)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding district ambient loop.')

  # Ambient loop
  loop = OpenStudio::Model::PlantLoop.new(model)
  loop.setName('Ambient Loop')
  loop.setMaximumLoopTemperature(80)
  loop.setMinimumLoopTemperature(5)

  # Ambient loop controls
  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 = OpenStudio::Model::ScheduleRuleset.new(model)
  amb_high_temp_sch.setName("Ambient Loop High Temp - #{amb_high_temp_f}F")
  amb_high_temp_sch.defaultDaySchedule.setName("Ambient Loop High Temp - #{amb_high_temp_f}F Default")
  amb_high_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), amb_high_temp_c)

  amb_low_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  amb_low_temp_sch.setName("Ambient Loop Low Temp - #{amb_low_temp_f}F")
  amb_low_temp_sch.defaultDaySchedule.setName("Ambient Loop Low Temp - #{amb_low_temp_f}F Default")
  amb_low_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), amb_low_temp_c)

  amb_stpt_manager = OpenStudio::Model::SetpointManagerScheduledDualSetpoint.new(model)
  amb_stpt_manager.setHighSetpointSchedule(amb_high_temp_sch)
  amb_stpt_manager.setLowSetpointSchedule(amb_low_temp_sch)
  amb_stpt_manager.addToNode(loop.supplyOutletNode)

  sizing_plant = loop.sizingPlant
  sizing_plant.setLoopType('Heating')
  sizing_plant.setDesignLoopExitTemperature(amb_temp_sizing_c)
  sizing_plant.setLoopDesignTemperatureDifference(amb_delta_t_k)

  # Ambient loop pump
  amb_pump = OpenStudio::Model::PumpVariableSpeed.new(model)
  amb_pump.setName('Ambient Loop Pump')
  amb_pump_head_ft_h2o = 60
  amb_pump_head_press_pa = OpenStudio.convert(amb_pump_head_ft_h2o, 'ftH_{2}O', 'Pa').get
  amb_pump.setRatedPumpHead(amb_pump_head_press_pa)
  amb_pump.setPumpControlType('Intermittent')
  amb_pump.addToNode(loop.supplyInletNode)

  # Cooling
  district_cooling = OpenStudio::Model::DistrictCooling.new(model)
  district_cooling.setNominalCapacity(1_000_000_000_000) # large number; no autosizing
  loop.addSupplyBranchForComponent(district_cooling)

  # Heating
  district_heating = OpenStudio::Model::DistrictHeating.new(model)
  district_heating.setNominalCapacity(1_000_000_000_000) # large number; no autosizing
  loop.addSupplyBranchForComponent(district_heating)

  # Ambient water loop pipes
  supply_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  supply_bypass_pipe.setName("#{loop.name} Supply Bypass")
  loop.addSupplyBranchForComponent(supply_bypass_pipe)

  demand_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_bypass_pipe.setName("#{loop.name} Demand Bypass")
  loop.addDemandBranchForComponent(demand_bypass_pipe)

  supply_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  supply_outlet_pipe.setName("#{loop.name} Supply Outlet")
  supply_outlet_pipe.addToNode(loop.supplyOutletNode)

  demand_inlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_inlet_pipe.setName("#{loop.name} Demand Inlet")
  demand_inlet_pipe.addToNode(loop.demandInletNode)

  demand_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_outlet_pipe.setName("#{loop.name} Demand Outlet")
  demand_outlet_pipe.addToNode(loop.demandOutletNode)

  return loop
end

#model_add_doas(model, sys_name, hot_water_loop, chilled_water_loop, thermal_zones, hvac_op_sch, oa_damper_sch, fan_max_flow_rate, economizer_control_type, building_type = nil, energy_recovery = false) ⇒ OpenStudio::Model::AirLoopHVAC

Creates a DOAS system with fan coil units for each zone.

or nil in which case will be defaulted to always on or nil in which case will be defaulted to always open if nil, this value will be autosized. FixedDryBulb, DOAS system.

Parameters:

  • sys_name (String)

    the name of the system, or nil in which case it will be defaulted

  • hot_water_loop (String)

    hot water loop to connect heating and zone fan coils to

  • chilled_water_loop (String)

    chilled water loop to connect cooling coil to

  • thermal_zones (String)

    zones to connect to this system

  • hvac_op_sch (String)

    name of the HVAC operation schedule

  • oa_damper_sch (Double)

    name of the oa damper schedule,

  • fan_max_flow_rate (Double)

    fan maximum flow rate, in m^3/s.

  • economizer_control_type (String)

    valid choices are

  • building_type (String) (defaults to: nil)

    the building type

  • energy_recovery (Bool) (defaults to: false)

    if true, an ERV will be added to the

Returns:



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
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
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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4639

def model_add_doas(model,
                   sys_name,
                   hot_water_loop,
                   chilled_water_loop,
                   thermal_zones,
                   hvac_op_sch,
                   oa_damper_sch,
                   fan_max_flow_rate,
                   economizer_control_type,
                   building_type = nil,
                   energy_recovery = false)

  # 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.")
    thermal_zones.each do |zone|
      OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "---#{zone.name}")
    end
    return false
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding DOAS system for #{thermal_zones.size} zones.")
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "---#{zone.name}")
  end

  # DOAS Controls

  # Reset SAT down to 55F during hotter outdoor
  # conditions for humidity management
  lo_oat_f = 60
  sat_at_lo_oat_f = 60
  hi_oat_f = 70
  sat_at_hi_oat_f = 55
  lo_oat_c = OpenStudio.convert(lo_oat_f, 'F', 'C').get
  hi_oat_c = OpenStudio.convert(hi_oat_f, 'F', 'C').get
  sat_at_lo_oat_c = OpenStudio.convert(sat_at_lo_oat_f, 'F', 'C').get
  sat_at_hi_oat_c = OpenStudio.convert(sat_at_hi_oat_f, 'F', 'C').get

  # Create a setpoint manager
  sat_oa_reset = OpenStudio::Model::SetpointManagerOutdoorAirReset.new(model)
  sat_oa_reset.setName('DOAS 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)

  # hvac operation schedule
  hvac_op_sch = if hvac_op_sch.nil?
                  model.alwaysOnDiscreteSchedule
                else
                  model_add_schedule(model, hvac_op_sch)
                end

  # oa damper schedule
  oa_damper_sch = if oa_damper_sch.nil?
                    model.alwaysOnDiscreteSchedule
                  else
                    model_add_schedule(model, oa_damper_sch)
                  end

  # DOAS
  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  if sys_name.nil?
    air_loop.setName("#{thermal_zones.size} Zone DOAS")
  else
    air_loop.setName(sys_name)
  end
  air_loop.setNightCycleControlType('CycleOnAny')
  # modify system sizing properties
  sizing_system = air_loop.sizingSystem
  # set central heating and cooling temperatures for sizing
  sizing_system.setCentralCoolingDesignSupplyAirTemperature(sat_at_hi_oat_c)
  sizing_system.setCentralHeatingDesignSupplyAirTemperature(sat_at_lo_oat_c)
  sizing_system.setSizingOption('Coincident')
  # load specification
  sizing_system.setTypeofLoadtoSizeOn('VentilationRequirement')
  sizing_system.setAllOutdoorAirinCooling(true)
  sizing_system.setAllOutdoorAirinHeating(true)
  sizing_system.setMinimumSystemAirFlowRatio(0.3)

  # set availability schedule
  air_loop.setAvailabilitySchedule(hvac_op_sch)

  # get the supply air inlet node
  airloop_supply_inlet = air_loop.supplyInletNode

  # create air loop fan
  # constant speed fan
  fan_static_pressure_in_h2o = 2.5
  fan_static_pressure_pa = OpenStudio.convert(fan_static_pressure_in_h2o, 'inH_{2}O', 'Pa').get
  fan = OpenStudio::Model::FanConstantVolume.new(model, model.alwaysOnDiscreteSchedule)
  fan.setName('DOAS Fan')
  fan.setFanEfficiency(0.58175)
  fan.setPressureRise(fan_static_pressure_pa)
  if fan_max_flow_rate.nil?
    fan.autosizeMaximumFlowRate
  else
    fan.setMaximumFlowRate(OpenStudio.convert(fan_max_flow_rate, 'cfm', 'm^3/s').get) # unit of fan_max_flow_rate is cfm
  end
  fan.setMotorEfficiency(0.895)
  fan.setMotorInAirstreamFraction(1.0)
  fan.setEndUseSubcategory('DOAS Fans')
  fan.addToNode(airloop_supply_inlet)

  # create heating coil
  # water coil
  heating_coil = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule)
  hot_water_loop.addDemandBranchForComponent(heating_coil)
  heating_coil.controllerWaterCoil.get.setMinimumActuatedFlow(0)
  heating_coil.addToNode(airloop_supply_inlet)
  heating_coil.controllerWaterCoil.get.setControllerConvergenceTolerance(0.0001)

  # create cooling coil
  # water coil
  cooling_coil = OpenStudio::Model::CoilCoolingWater.new(model, model.alwaysOnDiscreteSchedule)
  chilled_water_loop.addDemandBranchForComponent(cooling_coil)
  cooling_coil.controllerWaterCoil.get.setMinimumActuatedFlow(0)
  cooling_coil.addToNode(airloop_supply_inlet)

  # create controller outdoor air
  controller_oa = OpenStudio::Model::ControllerOutdoorAir.new(model)
  controller_oa.setName('DOAS OA Controller')
  controller_oa.setEconomizerControlType(economizer_control_type)
  controller_oa.setMinimumLimitType('FixedMinimum')
  controller_oa.autosizeMinimumOutdoorAirFlowRate
  controller_oa.setMinimumOutdoorAirSchedule(oa_damper_sch)
  controller_oa.resetEconomizerMaximumLimitDryBulbTemperature
  # TODO: Yixing read the schedule from the Prototype Input
  if building_type == 'LargeHotel'
    controller_oa.setMinimumFractionofOutdoorAirSchedule(model_add_schedule(model, 'HotelLarge FLR_3_DOAS_OAminOAFracSchedule'))
  end
  controller_oa.resetEconomizerMaximumLimitEnthalpy
  controller_oa.resetMaximumFractionofOutdoorAirSchedule
  controller_oa.resetEconomizerMinimumLimitDryBulbTemperature

  # create ventilation schedules and assign to OA controller
  controller_oa.setHeatRecoveryBypassControlType('BypassWhenWithinEconomizerLimits')

  # create outdoor air system
  system_oa = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, controller_oa)
  system_oa.addToNode(airloop_supply_inlet)

  # add setpoint manager to supply equipment outlet node
  sat_oa_reset.addToNode(air_loop.supplyOutletNode)

  # ERV, if requested
  if energy_recovery
    # Get the OA system and its outboard OA node
    oa_system = air_loop.airLoopHVACOutdoorAirSystem.get
    oa_node = oa_system.outboardOANode.get

    # Create the ERV and set its properties
    erv = OpenStudio::Model::HeatExchangerAirToAirSensibleAndLatent.new(model)
    erv.addToNode(oa_node)
    erv.setHeatExchangerType('Rotary')
    # TODO: Come up with scheme for estimating power of ERV motor wheel
    # which might require knowing airlow (like prototype buildings do).
    # 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 pressure caused by the ERV
    fans = []
    fans += air_loop.supplyComponents('OS:Fan:VariableVolume'.to_IddObjectType)
    fans += air_loop.supplyComponents('OS:Fan:ConstantVolume'.to_IddObjectType)
    unless fans.empty?
      if fans[0].to_FanConstantVolume.is_initialized
        fans[0].to_FanConstantVolume.get.setPressureRise(OpenStudio.convert(1.0, 'inH_{2}O', 'Pa').get)
      elsif fans[0].to_FanVariableVolume.is_initialized
        fans[0].to_FanVariableVolume.get.setPressureRise(OpenStudio.convert(1.0, 'inH_{2}O', 'Pa').get)
      end
    end
  end

  # add thermal zones to airloop
  thermal_zones.each do |zone|
    zone_name = zone.name.to_s

    # Ensure that zone sizing accounts for DOAS
    zone_sizing = zone.sizingZone
    zone_sizing.setAccountforDedicatedOutdoorAirSystem(true)
    zone_sizing.setDedicatedOutdoorAirSystemControlStrategy('ColdSupplyAir')
    zone_sizing.setDedicatedOutdoorAirLowSetpointTemperatureforDesign(sat_at_hi_oat_c)
    zone_sizing.setDedicatedOutdoorAirHighSetpointTemperatureforDesign(sat_at_lo_oat_c)

    # 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.addBranchForZone(zone, air_terminal.to_StraightComponent)
  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
# 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_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_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_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



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.elevators.rb', line 143

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)
  elevator_type = nil
  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
    elevator_type = 'Hydraulic'
  else
    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)

  # 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 specific notes; prototype uses Beyer (2009) rules of thumb
    area_per_pass_elev_ft2 = nil
    units_per_pass_elevator = nil
    beds_per_pass_elevator = nil
    area_per_freight_elev_ft2 = nil
    units_per_freight_elevator = nil
    beds_per_freight_elevator = nil
    if ['Office', 'SmallOffice', 'MediumOffice', 'LargeOffice'].include?(hash[:stds_bldg_type])
      # The office buildings have one elevator for every 45,000 ft2 (4,181 m2),
      # plus one service elevator for the large office building (500,000 ft^2).
      area_per_pass_elev_ft2 = 45_000
      bldg_area_ft2 = OpenStudio.convert(model.getBuilding.floorArea, 'm^2', 'ft^2').get
      if bldg_area_ft2 > 500_000
        area_per_freight_elev_ft2 = 500_000
      end
    elsif ['SmallHotel', 'LargeHotel'].include?(hash[:stds_bldg_type])
      # The hotels have one elevator for every 75 rooms.
      if hash[:stds_space_type].include?('GuestRoom')
        units_per_pass_elevator = 75.0
      end
      # The large hotel includes one service elevator for every two public elevators,
      # plus one additional elevator for the dining and banquet facilities on the top floor.
      # None of the other space types generate elevators.
      if ['LargeHotel'].include?(hash[:stds_bldg_type]) && hash[:stds_space_type].include?('GuestRoom')
        units_per_freight_elevator = 150.0
      elsif ['LargeHotel'].include?(hash[:stds_bldg_type]) && ['Banquet', 'Cafe'].include?(hash[:stds_space_type])
        area_per_pass_elev_ft2 = 10_000
      end
    elsif ['MidriseApartment', 'HighriseApartment'].include?(hash[:stds_bldg_type]) && hash[:stds_space_type].include?('Apartment')
      # The apartment building has one elevator for every 90 units
      units_per_pass_elevator = 90.0
    elsif ['Hospital'].include?(hash[:stds_bldg_type])
      # The hospital has one public and one service elevator for every 100 beds (250 total),
      # plus two elevators for the offices and cafeteria on the top floor.
      # None of the other space types generate elevators.
      if ['PatRoom', 'ICU_PatRm', 'ICU_Open'].include?(hash[:stds_space_type])
        beds_per_pass_elevator = 100.0
        beds_per_freight_elevator = 100.0
      elsif ['Dining', 'Kitchen', 'Office'].include?(hash[:stds_space_type])
        area_per_pass_elev_ft2 = 12_500
      end
    elsif ['PrimarySchool', 'SecondarySchool'].include?(hash[:stds_bldg_type])
      # 210,887 ft^2 secondary school prototype has 2 elevators
      area_per_pass_elev_ft2 = 100_000
    elsif ['Outpatient'].include?(hash[:stds_bldg_type])
      # 40,946 Outpatient has 3 elevators
      area_per_pass_elev_ft2 = 15_000
    elsif ['Warehouse'].include?(hash[:stds_bldg_type])
      # Warehouse has no elevators, but assume some would be needed
      area_per_freight_elev_ft2 = 250_000
    else
      # TODO: - improve catchall for building types without elevator data, using same value as what Outpatient would be if not already in space type
      # includes RetailStandalone, RetailStripmall, QuickServiceRestaurant, FullServiceRestaurant, SuperMarket (made unique logic above for warehouse)
      area_per_pass_elev_ft2 = 15_000
    end

    # passenger elevators
    if area_per_pass_elev_ft2
      pass_elevs = hash[:floor_area] / OpenStudio.convert(area_per_pass_elev_ft2, 'ft^2', 'm^2').get
      number_of_pass_elevators += pass_elevs
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "For #{space_type.name}, adding #{pass_elevs.round(1)} passenger elevators at 1 per #{area_per_pass_elev_ft2.round} ft^2.")
    end

    if units_per_pass_elevator
      pass_elevs = hash[:num_units] / units_per_pass_elevator
      number_of_pass_elevators += pass_elevs
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "For #{space_type.name}, adding #{pass_elevs.round(1)} passenger elevators at 1 per #{units_per_pass_elevator} units.")
    end

    if beds_per_pass_elevator
      pass_elevs = hash[:num_beds] / beds_per_pass_elevator
      number_of_pass_elevators += pass_elevs
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "For #{space_type.name}, adding #{pass_elevs.round(1)} passenger elevators at 1 per #{beds_per_pass_elevator} beds.")
    end

    # freight or service elevators
    if area_per_freight_elev_ft2
      freight_elevs = hash[:floor_area] / OpenStudio.convert(area_per_freight_elev_ft2, 'ft^2', 'm^2').get
      number_of_freight_elevators += freight_elevs
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "For #{space_type.name}, adding #{freight_elevs.round(1)} freight/service elevators at 1 per #{area_per_freight_elev_ft2.round} ft^2.")
    end

    if units_per_freight_elevator
      freight_elevs = hash[:num_units] / units_per_freight_elevator
      number_of_freight_elevators += freight_elevs
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "For #{space_type.name}, adding #{freight_elevs.round(1)} freight/service elevators at 1 per #{units_per_freight_elevator} units.")
    end

    if beds_per_freight_elevator
      freight_elevs = hash[:num_beds] / beds_per_freight_elevator
      number_of_freight_elevators += freight_elevs
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', "For #{space_type.name}, adding #{freight_elevs.round(1)} freight/service elevators at 1 per #{beds_per_freight_elevator} beds.")
    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
  number_of_elevators = number_of_pass_elevators + number_of_freight_elevators

  building_type = building_type_hash.key(building_type_hash.values.max)
  # rename space types as needed
  if building_type == 'Office'
    building_type = model_remap_office(model, building_type_hash['Office'])
  end
  if building_type == 'SmallHotel' then building_type = 'LargeHotel' end # no elevator schedules for SmallHotel
  if building_type == 'PrimarySchool' then building_type = 'SecondarySchool' end # no elevator schedules for PrimarySchool
  if building_type == 'Retail' then building_type = 'RetailStandalone' end # no elevator schedules for PrimarySchool
  if building_type == 'StripMall' then building_type = 'RetailStripmall' end # no elevator schedules for PrimarySchool
  if building_type == 'Outpatient'
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.prototype.elevators', 'Outpatient ElevatorPumpRoom plug loads contain the elevator loads. Not adding extra elevator loads on top of it.')
  end

  # Retrieve the Prototype Inputs from JSON
  search_criteria = {
    'template' => template,
    'building_type' => building_type
  }

  prototype_input = model_find_object(standards_data['prototype_inputs'], search_criteria, nil)
  if prototype_input.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.prototype.elevators', "Could not find prototype inputs for #{search_criteria}, cannot add elevators.")
    return nil
  end

  # assign schedules
  if ['Office', 'MediumOffice', 'MidriseApartment', 'HighriseApartment', 'SecondarySchool'].include?(building_type)
    elevator_schedule = prototype_input['elevator_schedule']
    elevator_fan_schedule = prototype_input['elevator_fan_schedule']
    elevator_lights_schedule = prototype_input['elevator_fan_schedule']
  elsif ['LargeHotel', 'Hospital', 'LargeOffice'].include?(building_type)
    elevator_schedule = prototype_input['exterior_fuel_equipment1_schedule']
    elevator_fan_schedule = prototype_input['exterior_fuel_equipment2_schedule']
    elevator_lights_schedule = prototype_input['exterior_fuel_equipment2_schedule']
  else

    # identify occupancy schedule from largest space type of this building type
    space_type_size = {}
    space_type_hash.each do |space_type, hash|
      next unless building_type.include?(hash[:stds_bldg_type])
      space_type_size[space_type] = hash[:floor_area]
    end

    # Get the largest space type
    largest_space_type = space_type_size.key(space_type_size.values.max)

    # Get the occ sch, if one is specified
    occ_sch = nil
    if largest_space_type.defaultScheduleSet.is_initialized
      if largest_space_type.defaultScheduleSet.get.numberofPeopleSchedule.is_initialized
        occ_sch = largest_space_type.defaultScheduleSet.get.numberofPeopleSchedule.get
      end
    else
      occ_sch = model.alwaysOffDiscreteSchedule
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.prototype.elevators', "No occupancy schedule was specified for #{largest_space_type.name}, an always off schedule will be used for the elvevators and the elevators will never run.")
    end

    # clone and assign to elevator
    elev_sch = occ_sch.clone(model)
    elevator_schedule = elev_sch.name.to_s
    elevator_fan_schedule = elev_sch.name.to_s
    elevator_lights_schedule = elev_sch.name.to_s

    # TODO: - scale down peak value based on building type lookup, or make parametric schedule based on hours of operation
    # includes RetailStandalone, RetailStripmall, QuickServiceRestaurant, FullServiceRestaurant, SuperMarket (made unique logic above for warehouse)

    if building_type == 'Warehouse'
      # alter default profile, summer, winter, and rules
      max_value = 0.2
      elev_sch = elev_sch.to_ScheduleRuleset.get
      day_schedules = []
      elev_sch.scheduleRules.each do |rule|
        day_schedules << rule.daySchedule
      end
      day_schedules << elev_sch.defaultDaySchedule
      day_schedules << elev_sch.summerDesignDaySchedule
      day_schedules << elev_sch.winterDesignDaySchedule

      day_schedules.each do |day_schedule|
        values = day_schedule.values
        times = day_schedule.times
        values.each_with_index do |value, i|
          if value > max_value
            day_schedule.addValue(times[i], max_value)
          end
        end
      end
    end

  end

  # 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.setFractionLost(1.0)
    elevator.definition.to_ElectricEquipmentDefinition.get.setFractionRadiant(0.0)
  end

  return elevator
end

#model_add_evap_cooler(model, thermal_zones, building_type = nil) ⇒ Array<OpenStudio::Model::AirLoopHVAC>

Creates an evaporative cooler for each zone and adds it to the model.

Parameters:

  • thermal_zones (String)

    zones to connect to this system

  • building_type (String) (defaults to: nil)

    the building type

Returns:



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
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
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
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 3835

def model_add_evap_cooler(model,
                          thermal_zones,
                          building_type = nil)

  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

  # Evap cooler control temperatures
  min_sa_temp_f = 55
  clg_sa_temp_f = 70
  max_sa_temp_f = 78
  htg_sa_temp_f = 122 # Not used

  min_sa_temp_c = OpenStudio.convert(min_sa_temp_f, 'F', 'C').get
  clg_sa_temp_c = OpenStudio.convert(clg_sa_temp_f, 'F', 'C').get
  max_sa_temp_c = OpenStudio.convert(max_sa_temp_f, 'F', 'C').get
  htg_sa_temp_c = OpenStudio.convert(htg_sa_temp_f, 'F', 'C').get

  approach_r = 3 # WetBulb approach
  approach_k = OpenStudio.convert(approach_r, 'R', 'K').get

  fan_static_pressure_in_h2o = 0.25
  fan_static_pressure_pa = OpenStudio.convert(fan_static_pressure_in_h2o, 'inH_{2}O', 'Pa').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} Evap Cooler")

    # 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} 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} 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} 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

    # Setpoint follows OAT WetBulb
    evap_stpt_manager = OpenStudio::Model::SetpointManagerFollowOutdoorAirTemperature.new(model)
    evap_stpt_manager.setName("#{approach_r} F above OATwb")
    evap_stpt_manager.setReferenceTemperatureType('OutdoorAirWetBulb')
    evap_stpt_manager.setMaximumSetpointTemperature(max_sa_temp_c)
    evap_stpt_manager.setMinimumSetpointTemperature(min_sa_temp_c)
    evap_stpt_manager.setOffsetTemperatureDifference(approach_k)
    evap_stpt_manager.addToNode(air_loop.supplyOutletNode)

    # Air handler sizing
    sizing_system = air_loop.sizingSystem
    sizing_system.setCentralCoolingDesignSupplyAirTemperature(clg_sa_temp_c)
    sizing_system.setCentralHeatingDesignSupplyAirTemperature(htg_sa_temp_c)
    sizing_system.setAllOutdoorAirinCooling(true)
    sizing_system.setAllOutdoorAirinHeating(true)
    sizing_system.setSystemOutdoorAirMethod('ZoneSum')

    # 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 = OpenStudio::Model::FanOnOff.new(model, model.alwaysOnDiscreteSchedule)
    fan.setName("#{zone.name} Evap Cooler Supply Fan")
    fan.setFanEfficiency(0.55)
    fan.setPressureRise(fan_static_pressure_pa)

    # Dummy zero-capacity cooling coil
    clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model)
    clg_coil.setName('Zero-capacity DX Coil')
    clg_coil.setAvailabilitySchedule(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(50)
    unitary_system.setFanPlacement('BlowThrough')
    unitary_system.setSupplyAirFlowRateMethodDuringCoolingOperation('SupplyAirFlowRate')
    unitary_system.setSupplyAirFlowRateMethodDuringHeatingOperation('SupplyAirFlowRate')
    unitary_system.setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired('SupplyAirFlowRate')
    unitary_system.setSupplyAirFanOperatingModeSchedule(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.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 Sys")
    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.addBranchForZone(zone, air_terminal.to_StraightComponent)

    sizing_zone = zone.sizingZone
    sizing_zone.setCoolingDesignAirFlowMethod('DesignDay')
    sizing_zone.setHeatingDesignAirFlowMethod('DesignDay')
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(clg_sa_temp_c)
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(htg_sa_temp_c)

    evap_coolers << air_loop
  end

  # Create a programcallingmanager
  avail_pcm = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)
  avail_pcm.setName('Evap Cooler Availability Program Calling Manager')
  avail_pcm.setCallingPoint('AfterPredictorAfterHVACManagers')
  programs.each do |program|
    avail_pcm.addProgram(program)
  end

  return evap_coolers
end

#model_add_exhaust_fan(model, availability_sch_name, flow_rate, flow_fraction_schedule_name, balanced_exhaust_fraction_schedule_name, thermal_zones) ⇒ Array<OpenStudio::Model::FanZoneExhaust>

Adds an exhaust fan to each zone.

of the balanced exhaust fraction schedule.

Parameters:

  • availability_sch_name (String)

    the name of the fan availability schedule

  • flow_rate (Double)

    the exhaust fan flow rate in m^3/s

  • balanced_exhaust_fraction_schedule_name (String)

    the name

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    an array of thermal zones

Returns:

  • (Array<OpenStudio::Model::FanZoneExhaust>)

    an array of exhaust fans created



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5585

def model_add_exhaust_fan(model, availability_sch_name,
                          flow_rate,
                          flow_fraction_schedule_name,
                          balanced_exhaust_fraction_schedule_name,
                          thermal_zones)

  # Make an exhaust fan for each zone
  fans = []
  thermal_zones.each do |zone|
    fan = OpenStudio::Model::FanZoneExhaust.new(model)
    fan.setName("#{zone.name} Exhaust Fan")
    fan.setAvailabilitySchedule(model_add_schedule(model, availability_sch_name))
    # two ways to input the flow rate: Number of Array.
    # For number: assign directly. For Array: assign each flow rate to each according 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, hot_water_loop, chilled_water_loop, thermal_zones, ventilation = true) ⇒ Array<OpenStudio::Model::ZoneHVACFourPipeFanCoil>

Adds four pipe fan coil units to each zone.

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. the chilled water loop that serves the fan coils. no ventilation will be supplied through the unit, with the expectation that it will be provided by a DOAS or separate system. array of fan coil units.

Parameters:

Returns:



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4903

def model_add_four_pipe_fan_coil(model,
                                 hot_water_loop,
                                 chilled_water_loop,
                                 thermal_zones,
                                 ventilation = true)

  # Supply temps used across all zones
  zn_dsn_clg_sa_temp_f = 55
  zn_dsn_htg_sa_temp_f = 104

  zn_dsn_clg_sa_temp_c = OpenStudio.convert(zn_dsn_clg_sa_temp_f, 'F', 'C').get
  zn_dsn_htg_sa_temp_c = OpenStudio.convert(zn_dsn_htg_sa_temp_f, 'F', 'C').get

  # 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}.")

    zone_sizing = zone.sizingZone
    zone_sizing.setZoneCoolingDesignSupplyAirTemperature(zn_dsn_clg_sa_temp_c)
    zone_sizing.setZoneHeatingDesignSupplyAirTemperature(zn_dsn_htg_sa_temp_c)

    fcu_clg_coil = nil
    if chilled_water_loop
      fcu_clg_coil = OpenStudio::Model::CoilCoolingWater.new(model, model.alwaysOnDiscreteSchedule)
      fcu_clg_coil.setName("#{zone.name} 'FCU Cooling Coil")
      chilled_water_loop.addDemandBranchForComponent(fcu_clg_coil)
      fcu_clg_coil.controllerWaterCoil.get.setMinimumActuatedFlow(0)
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', 'Fan coil units require a chilled water loop, but none was provided.')
      return fcus
    end

    fcu_htg_coil = nil
    if hot_water_loop
      fcu_htg_coil = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule)
      fcu_htg_coil.setName("#{zone.name} FCU Heating Coil")
      hot_water_loop.addDemandBranchForComponent(fcu_htg_coil)
      fcu_htg_coil.controllerWaterCoil.get.setMinimumActuatedFlow(0)
    else
      # Zero-capacity, always-off electric heating coil
      fcu_htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOffDiscreteSchedule)
      fcu_htg_coil.setName("#{zone.name} No Heat")
      fcu_htg_coil.setNominalCapacity(0)
    end

    fcu_fan = OpenStudio::Model::FanOnOff.new(model, model.alwaysOnDiscreteSchedule)
    fcu_fan.setName("#{zone.name} Fan Coil fan")
    fcu_fan.setFanEfficiency(0.16)
    fcu_fan.setPressureRise(270.9) # Pa
    fcu_fan.autosizeMaximumFlowRate
    fcu_fan.setMotorEfficiency(0.29)
    fcu_fan.setMotorInAirstreamFraction(1.0)
    fcu_fan.setEndUseSubcategory('FCU Fans')

    fcu = OpenStudio::Model::ZoneHVACFourPipeFanCoil.new(model,
                                                         model.alwaysOnDiscreteSchedule,
                                                         fcu_fan,
                                                         fcu_clg_coil,
                                                         fcu_htg_coil)
    fcu.setName("#{zone.name} FCU")
    fcu.setCapacityControlMethod('CyclingFan')
    fcu.autosizeMaximumSupplyAirFlowRate
    unless ventilation
      fcu.setMaximumOutdoorAirFlowRate(0)
    end
    fcu.addToThermalZone(zone)
    fcus << fcu
  end

  return fcus
end

#model_add_furnace_central_ac(model, thermal_zones, heating, cooling, ventilation) ⇒ Array<OpenStudio::Model::AirLoopHVAC>

Adds a forced air furnace or central AC to each zone. 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)

    if true, the unit will include a NaturalGas heating coil

  • cooling (Bool)

    if true, the unit will include a DX cooling coil

  • ventilation (Bool)

    if true, the unit will include an OA intake

Returns:



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
5095
5096
5097
5098
5099
5100
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
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5059

def model_add_furnace_central_ac(model,
                                 thermal_zones,
                                 heating,
                                 cooling,
                                 ventilation)

  equip_name = nil
  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 []
  end

  # Defaults
  fan_pressure_rise_in = 0.5 # 0.5 in W.C.
  afue = 0.78
  seer = 13
  eer = 11.1
  shr = 0.73
  ac_w_per_cfm = 0.365
  sat_htg_f = 120
  sat_clg_f = 55
  crank_case_heat_w = 0
  crank_case_max_temp_f = 55

  # 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
  ac_cap_ft = create_curve_biquadratic(cool_cap_ft_coeffs_si, 'AC-Cap-fT', 0, 100, 0, 100, nil, nil)
  ac_cap_fff = create_curve_quadratic(cool_cap_fflow_coeffs, 'AC-Cap-fFF', 0, 2, 0, 2, is_dimensionless = true)
  ac_eir_ft = create_curve_biquadratic(cool_eir_ft_coeffs_si, 'AC-EIR-fT', 0, 100, 0, 100, nil, nil)
  ac_eir_fff = create_curve_quadratic(cool_eir_fflow_coeffs, 'AC-EIR-fFF', 0, 2, 0, 2, is_dimensionless = true)
  ac_plf_fplr = create_curve_quadratic(cool_plf_fplr_coeffs, 'AC-PLF-fPLR', 0, 1, 0, 1, is_dimensionless = true)

  # Unit conversion
  fan_pressure_rise_pa = OpenStudio.convert(fan_pressure_rise_in, 'inH_{2}O', 'Pa').get

  furnaces = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding furnace AC for #{zone.name}.")

    air_loop_name = "#{zone.name} #{equip_name}"
    air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
    air_loop.setName(air_loop_name.to_s)

    # Heating Coil
    htg_coil = nil
    if heating
      htg_coil = OpenStudio::Model::CoilHeatingGas.new(model)
      htg_coil.setName("#{air_loop_name} htg coil")
      htg_coil.setGasBurnerEfficiency(afue_to_thermal_eff(afue))
      htg_coil.setParasiticElectricLoad(0)
      htg_coil.setParasiticGasLoad(0)
    end

    # Cooling Coil
    clg_coil = nil
    if cooling
      clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model,
                                                                 model.alwaysOnDiscreteSchedule,
                                                                 ac_cap_ft,
                                                                 ac_cap_fff,
                                                                 ac_eir_ft,
                                                                 ac_eir_fff,
                                                                 ac_plf_fplr)
      clg_coil.setName("#{air_loop_name} cooling coil")
      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

    # Fan
    fan = OpenStudio::Model::FanOnOff.new(model, model.alwaysOnDiscreteSchedule)
    fan.setName("#{air_loop_name} supply fan")
    fan.setEndUseSubcategory('residential hvac fan')
    fan.setFanEfficiency(0.6) # Overall Efficiency of the Supply Fan, Motor and Drive
    fan.setPressureRise(fan_pressure_rise_pa)
    fan.setMotorEfficiency(1)
    fan.setMotorInAirstreamFraction(1)

    # 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 = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
    oa_intake.setName("#{air_loop.name} OA Sys")
    oa_intake.addToNode(air_loop.supplyInletNode)
    unless ventilation
      # Disable the OA
      oa_intake_controller.setMinimumOutdoorAirSchedule(alwaysOffDiscreteSchedule)
    end

    # Unitary System (holds the coils and fan)
    unitary = OpenStudio::Model::AirLoopHVACUnitarySystem.new(model)
    unitary.setName("#{air_loop_name} zoneunitary system")
    unitary.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
    unitary.setMaximumSupplyAirTemperature(OpenStudio.convert(120.0, 'F', 'C').get)
    unitary.setControllingZoneorThermostatLocation(zone)
    unitary.addToNode(air_loop.supplyInletNode)

    # Set flow rates during different conditions
    unitary.setSupplyAirFlowRateDuringHeatingOperation(0) unless heating
    unitary.setSupplyAirFlowRateDuringCoolingOperation(0) unless cooling
    unitary.setSupplyAirFlowRateWhenNoCoolingorHeatingisRequired(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(alwaysOffDiscreteSchedule)

    # Diffuser
    diffuser = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule)
    diffuser.setName(" #{zone.name} direct air")
    air_loop.addBranchForZone(zone, diffuser)

    furnaces << air_loop
  end

  return furnaces
end

#model_add_ground_hx_loop(model) ⇒ OpenStudio::Model::PlantLoop

Creates loop that roughly mimics a properly sized ground heat exchanger.

for supplemental heating/cooling and adds it to the model.

Returns:



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 522

def model_add_ground_hx_loop(model)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding ground source loop.')

  # Ground source loop
  ground_hx_loop = OpenStudio::Model::PlantLoop.new(model)
  ground_hx_loop.setName('Ground HX Loop')
  ground_hx_loop.setMaximumLoopTemperature(80)
  ground_hx_loop.setMinimumLoopTemperature(5)

  # Loop controls
  max_delta_t_r = 12 # temp change at high and low entering condition
  min_inlet_f = 30 # low entering condition.
  max_inlet_f = 90 # high entering condition

  delta_t_k = OpenStudio.convert(max_delta_t_r, 'R', 'K').get
  min_inlet_c = OpenStudio.convert(min_inlet_f, 'F', 'C').get
  max_inlet_c = OpenStudio.convert(max_inlet_f, 'F', 'C').get

  # 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)

  # Pump
  pump = OpenStudio::Model::PumpConstantSpeed.new(model)
  pump.setName("#{ground_hx_loop.name} Pump")
  pump_head_ft_h2o = 60
  pump_head_press_pa = OpenStudio.convert(pump_head_ft_h2o, 'ftH_{2}O', 'Pa').get
  pump.setRatedPumpHead(pump_head_press_pa)
  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) # TODO

  hx = OpenStudio::Model::PlantComponentTemperatureSource.new(model)
  hx.setName('Ground HX')
  hx.setTemperatureSpecificationType('Scheduled')
  hx.setSourceTemperatureSchedule(hx_temp_sch)
  ground_hx_loop.addSupplyBranchForComponent(hx)

  hx_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, hx_temp_sch)
  hx_stpt_manager.setName("#{hx.name} Supply Outlet Setpoint")
  hx_stpt_manager.addToNode(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
  supply_inlet_node = ground_hx_loop.supplyInletNode

  inlet_temp_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'System Node Temperature')
  inlet_temp_sensor.setName("#{hx.name} Inlet Temp Sensor")
  inlet_temp_sensor.setKeyName(supply_inlet_node.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("#{hx.name} Outlet Temp Actuator")

  # Actuator to set supply outlet temperature
  outlet_temp_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(hx_temp_sch, 'Schedule:Constant', 'Schedule Value')
  outlet_temp_actuator.setName("#{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("#{hx.name} Temp 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} Calling Mgr")
  pcm.setCallingPoint('InsideHVACSystemIterationLoop')
  pcm.addProgram(program)

  return ground_hx_loop
end

#model_add_ground_temperatures(model, building_type, climate_zone) ⇒ Object



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
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 158

def model_add_ground_temperatures(model, building_type, climate_zone)
  ground_temp_vals = model_find_object(standards_data['ground_temperatures'], '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; 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_high_temp_radiant(model, sys_name, thermal_zones, heating_type, combustion_efficiency, building_type = nil) ⇒ Array<OpenStudio::Model::ZoneHVACHighTemperatureRadiant>

Creates a high temp radiant heater for each zone and adds it to the model.

Gas, Electric array of the resulting radiant heaters.

Parameters:

  • sys_name (String)

    the name of the system, or nil in which case it will be defaulted

  • thermal_zones (String)

    zones to connect to this system

  • heating_type (Double)

    valid choices are

  • combustion_efficiency (Double)

    combustion efficiency as decimal

  • building_type (String) (defaults to: nil)

    the building type

Returns:



3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 3806

def model_add_high_temp_radiant(model,
                                sys_name,
                                thermal_zones,
                                heating_type,
                                combustion_efficiency,
                                building_type = nil)

  # Make a high temp radiant heater for each zone
  rad_heaters = []
  thermal_zones.each do |zone|
    high_temp_radiant = OpenStudio::Model::ZoneHVACHighTemperatureRadiant.new(model)
    high_temp_radiant.setName("#{zone.name} High Temp Radiant")
    high_temp_radiant.setFuelType(heating_type)
    high_temp_radiant.setCombustionEfficiency(combustion_efficiency)
    high_temp_radiant.setTemperatureControlType(control_type)
    high_temp_radiant.setFractionofInputConvertedtoRadiantEnergy(0.8)
    high_temp_radiant.setHeatingThrottlingRange(2)
    high_temp_radiant.addToThermalZone(zone)
    rad_heaters << high_temp_radiant
  end

  return rad_heaters
end

#model_add_hp_loop(model, building_type = nil) ⇒ OpenStudio::Model::PlantLoop

TODO:

replace cooling tower with fluid cooler after fixing sizing inputs

Creates a heat pump loop which has a boiler and fluid cooler

for supplemental heating/cooling and adds it to the model.

Returns:



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 400

def model_add_hp_loop(model, building_type = nil)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding heat pump loop.')

  # Heat Pump loop
  heat_pump_water_loop = OpenStudio::Model::PlantLoop.new(model)
  heat_pump_water_loop.setName('Heat Pump Loop')
  heat_pump_water_loop.setMaximumLoopTemperature(80)
  heat_pump_water_loop.setMinimumLoopTemperature(5)

  # Heat Pump loop controls
  hp_high_temp_f = 65 # Supplemental heat below 65F
  hp_low_temp_f = 41 # Supplemental cooling below 41F
  hp_temp_sizing_f = 102.2 # CW sized to deliver 102.2F
  hp_delta_t_r = 19.8 # 19.8F delta-T
  boiler_hw_temp_f = 86 # Boiler makes 86F water

  hp_high_temp_c = OpenStudio.convert(hp_high_temp_f, 'F', 'C').get
  hp_low_temp_c = OpenStudio.convert(hp_low_temp_f, 'F', 'C').get
  hp_temp_sizing_c = OpenStudio.convert(hp_temp_sizing_f, 'F', 'C').get
  hp_delta_t_k = OpenStudio.convert(hp_delta_t_r, 'R', 'K').get
  boiler_hw_temp_c = OpenStudio.convert(boiler_hw_temp_f, 'F', 'C').get

  hp_high_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  hp_high_temp_sch.setName("Heat Pump Loop High Temp - #{hp_high_temp_f}F")
  hp_high_temp_sch.defaultDaySchedule.setName("Heat Pump Loop High Temp - #{hp_high_temp_f}F Default")
  hp_high_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), hp_high_temp_c)

  hp_low_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  hp_low_temp_sch.setName("Heat Pump Loop Low Temp - #{hp_low_temp_f}F")
  hp_low_temp_sch.defaultDaySchedule.setName("Heat Pump Loop Low Temp - #{hp_low_temp_f}F Default")
  hp_low_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), hp_low_temp_c)

  hp_stpt_manager = OpenStudio::Model::SetpointManagerScheduledDualSetpoint.new(model)
  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)

  sizing_plant = heat_pump_water_loop.sizingPlant
  sizing_plant.setLoopType('Heating')
  sizing_plant.setDesignLoopExitTemperature(hp_temp_sizing_c)
  sizing_plant.setLoopDesignTemperatureDifference(hp_delta_t_k)

  # Heat Pump loop pump
  hp_pump = OpenStudio::Model::PumpConstantSpeed.new(model)
  hp_pump.setName('Heat Pump Loop Pump')
  hp_pump_head_ft_h2o = 60
  hp_pump_head_press_pa = OpenStudio.convert(hp_pump_head_ft_h2o, 'ftH_{2}O', 'Pa').get
  hp_pump.setRatedPumpHead(hp_pump_head_press_pa)
  hp_pump.setPumpControlType('Intermittent')
  hp_pump.addToNode(heat_pump_water_loop.supplyInletNode)

  # Cooling towers
  if building_type == 'LargeOffice' || building_type == 'LargeOfficeDetail'
    # TODO: For some reason the FluidCoolorTwoSpeed is causing simulation failures.
    # might need to look into the defaults
    # cooling_tower = OpenStudio::Model::FluidCoolerTwoSpeed.new(self)
    cooling_tower = OpenStudio::Model::CoolingTowerTwoSpeed.new(model)
    cooling_tower.setName("#{heat_pump_water_loop.name} Central Tower")
    heat_pump_water_loop.addSupplyBranchForComponent(cooling_tower)
    #### Add SPM Scheduled Dual Setpoint to outlet of Fluid Cooler so correct Plant Operation Scheme is generated
    hp_stpt_manager_2 = OpenStudio::Model::SetpointManagerScheduledDualSetpoint.new(model)
    hp_stpt_manager_2.setHighSetpointSchedule(hp_high_temp_sch)
    hp_stpt_manager_2.setLowSetpointSchedule(hp_low_temp_sch)
    hp_stpt_manager_2.addToNode(cooling_tower.outletModelObject.get.to_Node.get)

  else
    # TODO: replace with FluidCooler:TwoSpeed when available
    # cooling_tower = OpenStudio::Model::CoolingTowerTwoSpeed.new(self)
    # cooling_tower.setName("#{heat_pump_water_loop.name} Sup Cooling Tower")
    # heat_pump_water_loop.addSupplyBranchForComponent(cooling_tower)
    fluid_cooler = OpenStudio::Model::EvaporativeFluidCoolerSingleSpeed.new(model)
    fluid_cooler.setName("#{heat_pump_water_loop.name} Sup Cooling Tower")
    fluid_cooler.setDesignSprayWaterFlowRate(0.002208) # Based on HighRiseApartment
    fluid_cooler.setPerformanceInputMethod('UFactorTimesAreaAndDesignWaterFlowRate')
    heat_pump_water_loop.addSupplyBranchForComponent(fluid_cooler)
  end

  # Boiler
  boiler = OpenStudio::Model::BoilerHotWater.new(model)
  boiler.setName("#{heat_pump_water_loop.name} Sup Boiler")
  boiler.setFuelType('Gas')
  boiler.setDesignWaterOutletTemperature(boiler_hw_temp_c)
  boiler.setMinimumPartLoadRatio(0)
  boiler.setMaximumPartLoadRatio(1.2)
  boiler.setOptimumPartLoadRatio(1)
  boiler.setBoilerFlowMode('ConstantFlow')
  heat_pump_water_loop.addSupplyBranchForComponent(boiler)
  #### Add SPM Scheduled Dual Setpoint to outlet of Boiler so correct Plant Operation Scheme is generated
  hp_stpt_manager_3 = OpenStudio::Model::SetpointManagerScheduledDualSetpoint.new(model)
  hp_stpt_manager_3.setHighSetpointSchedule(hp_high_temp_sch)
  hp_stpt_manager_3.setLowSetpointSchedule(hp_low_temp_sch)
  hp_stpt_manager_3.addToNode(boiler.outletModelObject.get.to_Node.get)

  # 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
# 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', building_type)
                       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
        condenser_water_loop = nil
        if system['chiller_cooling_type'] == 'WaterCooled'
          condenser_water_loop = model_add_cw_loop(model,
                                                   'Open Cooling Tower',
                                                   'Centrifugal',
                                                   'Fan Cycling',
                                                   2,
                                                   1,
                                                   building_type)
        end

        chilled_water_loop = model_add_chw_loop(model,
                                                system['chw_pumping_type'],
                                                system['chiller_cooling_type'],
                                                system['chiller_condenser_type'],
                                                system['chiller_compressor_type'],
                                                'Electricity',
                                                condenser_water_loop)

      end

      # Add the VAV
      model_add_vav_reheat(model,
                           system['name'],
                           hot_water_loop,
                           chilled_water_loop,
                           thermal_zones,
                           system['operation_schedule'],
                           system['oa_damper_schedule'],
                           vav_fan_efficiency = 0.62,
                           vav_fan_motor_efficiency = 0.9,
                           vav_fan_pressure_rise = OpenStudio.convert(4.0, 'inH_{2}O', 'Pa').get,
                           return_plenum,
                           reheat_type = 'Water',
                           building_type)

    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', building_type)
                       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
        if system['chiller_cooling_type'] == 'WaterCooled'
          condenser_water_loop = model_add_cw_loop(model)
        end

        chilled_water_loop = model_add_chw_loop(model,
                                                system['chw_pumping_type'],
                                                system['chiller_cooling_type'],
                                                system['chiller_condenser_type'],
                                                system['chiller_compressor_type'],
                                                'Electricity',
                                                condenser_water_loop)
      end

      # Add the CAV
      model_add_cav(model,
                    system['name'],
                    hot_water_loop,
                    thermal_zones,
                    system['operation_schedule'],
                    system['oa_damper_schedule'],
                    vav_fan_efficiency = 0.62,
                    vav_fan_motor_efficiency = 0.9,
                    vav_fan_pressure_rise = OpenStudio.convert(4.0, 'inH_{2}O', 'Pa').get,
                    chilled_water_loop,
                    building_type)

    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'
        heat_pump_loop = model_add_hp_loop(model, building_type)
      end

      model_add_psz_ac(model,
                       system['name'],
                       heat_pump_loop, # Typically nil unless water source hp
                       heat_pump_loop, # Typically nil unless water source hp
                       thermal_zones,
                       system['operation_schedule'],
                       system['oa_damper_schedule'],
                       fan_position,
                       system['fan_type'],
                       system['heating_type'],
                       system['supplemental_heating_type'],
                       system['cooling_type'],
                       building_type)

    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
                       else
                         model_add_hw_loop(model, 'NaturalGas', building_type)
                       end

      model_add_pvav(model,
                     system['name'],
                     thermal_zones,
                     system['operation_schedule'],
                     system['oa_damper_schedule'],
                     electric_reheat = false,
                     hot_water_loop,
                     chilled_water_loop = nil,
                     return_plenum,
                     building_type)

    when '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', building_type)
                       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
        condenser_water_loop = nil
        if system['chiller_cooling_type'] == 'WaterCooled'
          condenser_water_loop = model_add_cw_loop(model,
                                                   'Open Cooling Tower',
                                                   'Centrifugal',
                                                   'Fan Cycling',
                                                   2,
                                                   1,
                                                   building_type)
        end

        chilled_water_loop = model_add_chw_loop(model,
                                                system['chw_pumping_type'],
                                                system['chiller_cooling_type'],
                                                system['chiller_condenser_type'],
                                                system['chiller_compressor_type'],
                                                'Electricity',
                                                condenser_water_loop)
      end

      model_add_doas(model,
                     system['name'],
                     hot_water_loop,
                     chilled_water_loop,
                     thermal_zones,
                     system['operation_schedule'],
                     system['oa_damper_schedule'],
                     system['fan_maximum_flow_rate'],
                     system['economizer_control_type'],
                     building_type)

      model_add_four_pipe_fan_coil(model,
                                   hot_water_loop,
                                   chilled_water_loop,
                                   thermal_zones,
                                   ventilation=false)

    when 'DC' # Data Center

      # 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', building_type)
                       end

      # Retrieve the existing heat pump loop
      # or add a new one if necessary.
      heat_pump_loop = nil
      heat_pump_loop = if model.getPlantLoopByName('Heat Pump Loop').is_initialized
                         model.getPlantLoopByName('Heat Pump Loop').get
                       else
                         model_add_hp_loop(model, building_type)
                       end

      model_add_data_center_hvac(model,
                                 nil,
                                 hot_water_loop,
                                 heat_pump_loop,
                                 thermal_zones,
                                 system['flow_fraction_schedule'],
                                 system['flow_fraction_schedule'],
                                 system['main_data_center'])

    when 'SAC'

      model_add_split_ac(model,
                         nil,
                         thermal_zones,
                         system['operation_schedule'],
                         system['oa_damper_schedule'],
                         system['fan_type'],
                         system['heating_type'],
                         system['heating_type'],
                         system['cooling_type'],
                         building_type)

    when 'UnitHeater'

      model_add_unitheater(model,
                           nil,
                           thermal_zones,
                           system['operation_schedule'],
                           system['fan_type'],
                           OpenStudio.convert(system['fan_static_pressure'], 'inH_{2}O', 'Pa').get,
                           system['heating_type'],
                           hot_water_loop = nil,
                           building_type)

    when 'PTAC'

      model_add_ptac(model,
                     nil,
                     nil,
                     thermal_zones,
                     system['fan_type'],
                     system['heating_type'],
                     system['cooling_type'],
                     building_type)

    when 'PTHP'

        model_add_pthp(model,
                       nil,
                       thermal_zones,
                       system['fan_type'])

    when 'Exhaust Fan'

      model_add_exhaust_fan(model, system['operation_schedule'],
                            system['flow_rate'],
                            system['flow_fraction_schedule'],
                            system['balanced_exhaust_fraction_schedule'],
                            thermal_zones)

    when 'Zone Ventilation'

      model_add_zone_ventilation(model, system['operation_schedule'],
                                 system['flow_rate'],
                                 system['ventilation_type'],
                                 thermal_zones)

    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)
                       else
                         model_get_or_add_ambient_water_loop(model)
                       end

      model_add_water_source_hp(model,
                                condenser_loop,
                                thermal_zones,
                                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'], air_cooled = true)
      when nil
        chilled_water_loop = nil
      end

      model_add_four_pipe_fan_coil(model,
                                   hot_water_loop,
                                   chilled_water_loop,
                                   thermal_zones,
                                   ventilation=true)

    when 'Baseboards'
      case system['heating_type']
      when 'Gas', 'DistrictHeating'
        hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel)
      when 'Electricity'
        hot_water_loop = nil
      when nil
        # TODO: Error, Baseboard systems must have a main_heat_fuel
        # return ??
      end

      model_add_baseboard(model,
                          hot_water_loop,
                          thermal_zones)

    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) ⇒ 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.

TODO enumerate the valid strings

Parameters:

  • system_type (String)

    The system type. Valid choices are

Returns:

  • (Bool)

    returns true if successful, false if not



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5836

def model_add_hvac_system(model, system_type, main_heat_fuel, zone_heat_fuel, cool_fuel, zones)
  # 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)
    when 'Electricity'
      heating_type = main_heat_fuel
      hot_water_loop = nil
    when nil
      heating_type = zone_heat_fuel
      hot_water_loop = nil
    end

    model_add_ptac(model,
                   sys_name = nil,
                   hot_water_loop,
                   zones,
                   fan_type = 'ConstantVolume',
                   heating_type,
                   cooling_type = 'Single Speed DX AC')

  when 'PTHP'
    model_add_pthp(model,
                   sys_name = nil,
                   zones,
                   fan_type = 'ConstantVolume')

  when 'PSZ-AC'
    case main_heat_fuel
    when 'NaturalGas'
      heating_type = main_heat_fuel
      supplemental_heating_type = 'Electricity'
      hot_water_loop = nil
    when 'DistrictHeating'
      heating_type = 'Water'
      supplemental_heating_type = 'Electricity'
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel)
    when nil
      heating_type = nil
      supplemental_heating_type = nil
      hot_water_loop = nil
    when 'Electricity'
      heating_type = main_heat_fuel
      supplemental_heating_type = 'Electricity'
    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,
                     sys_name = nil,
                     hot_water_loop,
                     chilled_water_loop,
                     zones,
                     hvac_op_sch = nil,
                     oa_damper_sch = nil,
                     fan_location = 'DrawThrough',
                     fan_type = 'ConstantVolume',
                     heating_type,
                     supplemental_heating_type,
                     cooling_type)

  when 'PSZ-HP'
    model_add_psz_ac(model,
                     sys_name = 'PSZ-HP',
                     hot_water_loop = nil,
                     chilled_water_loop = nil,
                     zones,
                     hvac_op_sch = nil,
                     oa_damper_sch = nil,
                     fan_location = 'DrawThrough',
                     fan_type = 'ConstantVolume',
                     heating_type = 'Single Speed Heat Pump',
                     supplemental_heating_type = 'Electricity',
                     cooling_type = 'Single Speed Heat Pump')
  when 'PSZ-VAV'
    case main_heat_fuel
    when 'NaturalGas'
      heating_type = main_heat_fuel
      supplemental_heating_type = 'Electricity'
    when nil
      heating_type = nil
      supplemental_heating_type = nil
    when 'Electricity'
      heating_type = main_heat_fuel
      supplemental_heating_type = 'Electricity'
    end

    model_add_psz_vav(model,
                      sys_name='PSZ-VAV',
                      zones,
                      hvac_op_sch=nil,
                      oa_damper_sch=nil,
                      heating_type,
                      supplemental_heating_type)

  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)
    when nil
      hot_water_loop = nil
    end

    case cool_fuel
    when 'Electricity', 'DistrictCooling'
      chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel, air_cooled = true)
    when nil
      chilled_water_loop = nil
    end

    model_add_four_pipe_fan_coil(model,
                                 hot_water_loop,
                                 chilled_water_loop,
                                 zones)

  when 'Baseboards'
    case main_heat_fuel
    when 'NaturalGas', 'DistrictHeating'
      hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel)
    when 'Electricity'
      hot_water_loop = nil
    when nil
      # TODO: Error, Baseboard systems must have a main_heat_fuel
      # return ??
    end

    model_add_baseboard(model,
                        hot_water_loop,
                        zones)

  when 'Unit Heaters'
    model_add_unitheater(model,
                         sys_name = nil,
                         zones,
                         hvac_op_sch = nil,
                         fan_control_type = 'ConstantVolume',
                         fan_pressure_rise = OpenStudio.convert(0.2, 'inH_{2}O', 'Pa').get,
                         main_heat_fuel,
                         hot_water_loop = nil)

  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'
    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 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,
                                           cooling,
                                           ventilation = false)

  when 'VAV Reheat'
    hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel)
    chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel, air_cooled = false)

    reheat_type = 'Water'
    if zone_heat_fuel == 'Electricity'
      reheat_type = 'Electricity'
    end

    model_add_vav_reheat(model,
                         sys_name = nil,
                         hot_water_loop,
                         chilled_water_loop,
                         zones,
                         hvac_op_sch = nil,
                         oa_damper_sch = nil,
                         vav_fan_efficiency = 0.62,
                         vav_fan_motor_efficiency = 0.9,
                         vav_fan_pressure_rise = OpenStudio.convert(4.0, 'inH_{2}O', 'Pa').get,
                         return_plenum = nil,
                         reheat_type)

  when 'VAV No Reheat'
    chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel, air_cooled = false)

    model_add_vav_reheat(model,
                         sys_name = nil,
                         hot_water_loop,
                         chilled_water_loop,
                         zones,
                         hvac_op_sch = nil,
                         oa_damper_sch = nil,
                         vav_fan_efficiency = 0.62,
                         vav_fan_motor_efficiency = 0.9,
                         vav_fan_pressure_rise = OpenStudio.convert(4.0, 'inH_{2}O', 'Pa').get,
                         return_plenum = nil,
                         reheat_type = nil)

  when 'VAV Gas Reheat'
    chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel, air_cooled = false)

    model_add_vav_reheat(model,
                         sys_name = nil,
                         hot_water_loop,
                         chilled_water_loop,
                         zones,
                         hvac_op_sch = nil,
                         oa_damper_sch = nil,
                         vav_fan_efficiency = 0.62,
                         vav_fan_motor_efficiency = 0.9,
                         vav_fan_pressure_rise = OpenStudio.convert(4.0, 'inH_{2}O', 'Pa').get,
                         return_plenum = nil,
                         reheat_type = 'NaturalGas')

  when 'PVAV Reheat'
    hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel)
    chilled_water_loop = case cool_fuel
                         when 'Electricity'
                           nil
                         else
                           model_get_or_add_chilled_water_loop(model, cool_fuel, air_cooled = false)
                         end

    electric_reheat = false
    if zone_heat_fuel == 'Electricity'
      electric_reheat = true
    end

    model_add_pvav(model,
                   sys_name = nil,
                   zones,
                   hvac_op_sch = nil,
                   oa_damper_sch = nil,
                   electric_reheat,
                   hot_water_loop,
                   chilled_water_loop,
                   return_plenum = nil)

  when 'PVAV PFP Boxes'
    chilled_water_loop = case cool_fuel
                         when 'DistrictCooling'
                           model_get_or_add_chilled_water_loop(model, cool_fuel)
                         end

    model_add_pvav_pfp_boxes(model,
                             sys_name = nil,
                             zones,
                             hvac_op_sch = nil,
                             oa_damper_sch = nil,
                             vav_fan_efficiency = 0.62,
                             vav_fan_motor_efficiency = 0.9,
                             vav_fan_pressure_rise = OpenStudio.convert(4.0, 'inH_{2}O', 'Pa').get,
                             chilled_water_loop)
  when 'VAV PFP Boxes'
    chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel, air_cooled = false)

    model_add_pvav_pfp_boxes(model,
                             sys_name = nil,
                             zones,
                             hvac_op_sch = nil,
                             oa_damper_sch = nil,
                             vav_fan_efficiency = 0.62,
                             vav_fan_motor_efficiency = 0.9,
                             vav_fan_pressure_rise = OpenStudio.convert(4.0, 'inH_{2}O', 'Pa').get,
                             chilled_water_loop)

  when 'Water Source Heat Pumps'
    condenser_loop = case main_heat_fuel
                     when 'NaturalGas'
                       model_get_or_add_heat_pump_loop(model)
                     else
                       model_get_or_add_ambient_water_loop(model)
                     end

    model_add_water_source_hp(model, condenser_loop,
                              zones,
                              ventilation = false)

  when 'Ground Source Heat Pumps'
    # TODO: replace condenser loop w/ ground HX model
    # that does not involve district objects
    condenser_loop = model_get_or_add_ground_hx_loop(model)
    model_add_water_source_hp(model, condenser_loop,
                              zones,
                              ventilation = false)

  when 'DOAS'
    hot_water_loop = model_get_or_add_hot_water_loop(model, main_heat_fuel)
    chilled_water_loop = model_get_or_add_chilled_water_loop(model, cool_fuel, air_cooled = false)

    model_add_doas(model,
                   sys_name = nil,
                   hot_water_loop,
                   chilled_water_loop,
                   zones,
                   hvac_op_sch = nil,
                   oa_damper_sch = nil,
                   fan_max_flow_rate = nil,
                   economizer_control_type = 'FixedDryBulb',
                   building_type = nil)

  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)

  ### Combination Systems ###
  when 'Water Source Heat Pumps with ERVs'
    model_add_hvac_system(model,
                          system_type = 'Water Source Heat Pumps',
                          main_heat_fuel,
                          zone_heat_fuel,
                          cool_fuel,
                          zones)

    model_add_hvac_system(model,
                          system_type = 'ERVs',
                          main_heat_fuel,
                          zone_heat_fuel,
                          cool_fuel,
                          zones)

  when 'Water Source Heat Pumps with DOAS'
    model_add_hvac_system(model,
                          system_type = 'Water Source Heat Pumps',
                          main_heat_fuel,
                          zone_heat_fuel,
                          cool_fuel,
                          zones)

    model_add_hvac_system(model,
                          system_type = 'DOAS',
                          main_heat_fuel,
                          zone_heat_fuel,
                          cool_fuel,
                          zones)

  when 'Ground Source Heat Pumps with ERVs'
    model_add_hvac_system(model,
                          system_type = 'Ground Source Heat Pumps',
                          main_heat_fuel,
                          zone_heat_fuel,
                          cool_fuel,
                          zones)

    model_add_hvac_system(model,
                          system_type = 'ERVs',
                          main_heat_fuel,
                          zone_heat_fuel,
                          cool_fuel,
                          zones)

  when 'Ground Source Heat Pumps with DOAS'
    model_add_hvac_system(model,
                          system_type = 'Ground Source Heat Pumps',
                          main_heat_fuel,
                          zone_heat_fuel,
                          cool_fuel,
                          zones)

    model_add_hvac_system(model,
                          system_type = 'DOAS',
                          main_heat_fuel,
                          zone_heat_fuel,
                          cool_fuel,
                          zones)

  when 'Fan Coil with DOAS'
    model_add_hvac_system(model,
                          system_type = 'Fan Coil',
                          main_heat_fuel,
                          zone_heat_fuel,
                          cool_fuel,
                          zones)

    model_add_hvac_system(model,
                          system_type = 'DOAS',
                          main_heat_fuel,
                          zone_heat_fuel,
                          cool_fuel,
                          zones)

  when 'Fan Coil with ERVs'
    model_add_hvac_system(model,
                          system_type = 'Fan Coil',
                          main_heat_fuel,
                          zone_heat_fuel,
                          cool_fuel,
                          zones)

    model_add_hvac_system(model,
                          system_type = 'ERVs',
                          main_heat_fuel,
                          zone_heat_fuel,
                          cool_fuel,
                          zones)

  else
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "HVAC system type '#{system_type}' not recognized")
    return false
  end
end

#model_add_hw_loop(model, boiler_fuel_type, building_type = nil, ambient_loop = 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.

Only used when boiler_fuel_type is HeatPump.

Parameters:

  • boiler_fuel_type (String)

    valid choices are Electricity, NaturalGas, PropaneGas, FuelOil#1, FuelOil#2, DistrictHeating, HeatPump

  • ambient_loop (OpenStudio::Model::PlantLoop) (defaults to: nil)

    The condenser loop for the heat pump.

Returns:



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 11

def model_add_hw_loop(model, boiler_fuel_type, building_type = nil, ambient_loop = nil)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding hot water loop.')

  # hot water loop
  hot_water_loop = OpenStudio::Model::PlantLoop.new(model)
  hot_water_loop.setName('Hot Water Loop')
  hot_water_loop.setMinimumLoopTemperature(10)

  # hot water loop controls
  # TODO: Yixing check other building types and add the parameter to the prototype input if more values comes out.
  hw_temp_f = if building_type == 'LargeHotel'
                140 # HW setpoint 140F
              else
                180 # HW setpoint 180F
              end

  hw_delta_t_r = 20 # 20F delta-T
  hw_temp_c = OpenStudio.convert(hw_temp_f, 'F', 'C').get
  hw_delta_t_k = OpenStudio.convert(hw_delta_t_r, 'R', 'K').get
  hw_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  hw_temp_sch.setName("Hot Water Loop Temp - #{hw_temp_f}F")
  hw_temp_sch.defaultDaySchedule.setName("Hot Water Loop Temp - #{hw_temp_f}F Default")
  hw_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), hw_temp_c)
  hw_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, hw_temp_sch)
  hw_stpt_manager.setName('Hot water loop setpoint manager')
  hw_stpt_manager.addToNode(hot_water_loop.supplyOutletNode)
  sizing_plant = hot_water_loop.sizingPlant
  sizing_plant.setLoopType('Heating')
  sizing_plant.setDesignLoopExitTemperature(hw_temp_c)
  sizing_plant.setLoopDesignTemperatureDifference(hw_delta_t_k)

  # hot water pump
  hw_pump = if building_type == 'Outpatient'
              OpenStudio::Model::PumpConstantSpeed.new(model)
            else
              OpenStudio::Model::PumpVariableSpeed.new(model)
            end
  hw_pump.setName('Hot Water Loop Pump')
  hw_pump_head_ft_h2o = 60.0
  hw_pump_head_press_pa = OpenStudio.convert(hw_pump_head_ft_h2o, 'ftH_{2}O', 'Pa').get
  hw_pump.setRatedPumpHead(hw_pump_head_press_pa)
  hw_pump.setMotorEfficiency(0.9)
  hw_pump.setPumpControlType('Intermittent')
  hw_pump.addToNode(hot_water_loop.supplyInletNode)

  case boiler_fuel_type
  # District Heating
  when 'DistrictHeating'
    dist_ht = OpenStudio::Model::DistrictHeating.new(model)
    dist_ht.setName('Purchased Heating')
    dist_ht.autosizeNominalCapacity
    hot_water_loop.addSupplyBranchForComponent(dist_ht)
  # Ambient Loop
  when 'HeatPump'
    water_to_water_hp = OpenStudio::Model::HeatPumpWaterToWaterEquationFitHeating.new(model)
    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)
  # Boiler
  when 'Electricity', 'NaturalGas', 'PropaneGas', 'FuelOil#1', 'FuelOil#2'
    boiler_max_t_f = 203
    boiler_max_t_c = OpenStudio.convert(boiler_max_t_f, 'F', 'C').get
    boiler = OpenStudio::Model::BoilerHotWater.new(model)
    boiler.setName('Hot Water Loop Boiler')
    boiler.setEfficiencyCurveTemperatureEvaluationVariable('LeavingBoiler')
    boiler.setFuelType(boiler_fuel_type)
    boiler.setDesignWaterOutletTemperature(hw_temp_c)
    boiler.setNominalThermalEfficiency(0.78)
    boiler.setMaximumPartLoadRatio(1.2)
    boiler.setWaterOutletUpperTemperatureLimit(boiler_max_t_c)
    boiler.setBoilerFlowMode('LeavingSetpointModulated')
    hot_water_loop.addSupplyBranchForComponent(boiler)

    if building_type == 'LargeHotel'
      boiler.setEfficiencyCurveTemperatureEvaluationVariable('LeavingBoiler')
      boiler.setDesignWaterOutletTemperature(81)
      boiler.setMaximumPartLoadRatio(1.2)
      boiler.setSizingFactor(1.2)
      boiler.setWaterOutletUpperTemperatureLimit(95)
    end

    # TODO: Yixing. Add the temperature setpoint will cost the simulation with
    # thousands of Severe Errors. Need to figure this out later.
    # 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

  # hot water loop pipes
  boiler_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  hot_water_loop.addSupplyBranchForComponent(boiler_bypass_pipe)
  coil_bypass_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  hot_water_loop.addDemandBranchForComponent(coil_bypass_pipe)
  supply_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  supply_outlet_pipe.addToNode(hot_water_loop.supplyOutletNode)
  demand_inlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_inlet_pipe.addToNode(hot_water_loop.demandInletNode)
  demand_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_outlet_pipe.addToNode(hot_water_loop.demandOutletNode)

  return hot_water_loop
end

#model_add_ideal_air_loads(model, thermal_zones) ⇒ Array<OpenStudio::Model::ZoneHVACIdealLoadsAirSystem>

TODO:

review the default ventilation settings

Adds ideal air loads systems for each zone.

Parameters:

Returns:



5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5564

def model_add_ideal_air_loads(model, thermal_zones)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding ideal air loads for #{thermal_zones.size} zones.")

  ideal_systems = []
  thermal_zones.each do |zone|
    ideal_loads = OpenStudio::Model::ZoneHVACIdealLoadsAirSystem.new(model)
    ideal_loads.addToThermalZone(zone)
    ideal_systems << ideal_loads
  end

  return ideal_systems
end

#model_add_material(model, material_name) ⇒ Object

TODO:

make return an OptionalMaterial

Create a material from the openstudio standards dataset.



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2287

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.setConductivity(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.setConductivity(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 == '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.setConductivity(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
    puts "Unknown material type #{material_type}"
    exit
  end

  return material
end

#model_add_prm_baseline_system(model, system_type, main_heat_fuel, zone_heat_fuel, cool_fuel, zones) ⇒ Object

TODO:

add 90.1-2013 systems 11-13

Add the specified baseline system type to the specified zons 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.

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. Electricity, NaturalGas, DistrictHeating Electricity, NaturalGas, DistrictHeating Electricity, DistrictCooling

Parameters:

  • system_type (String)

    The system type. Valid choices are

  • main_heat_fuel (String)

    main heating fuel. Valid choices are

  • zone_heat_fuel (String)

    zone heating/reheat fuel. Valid choices are

  • cool_fuel (String)

    cooling fuel. Valid choices are



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
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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 771

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,
                       nil,
                       hot_water_loop,
                       zones,
                       'ConstantVolume',
                       'Water',
                       'Single Speed DX AC')
      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,
                       nil,
                       zones,
                       '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,
                                                    'const_pri',
                                                    chiller_cooling_type = nil,
                                                    chiller_condenser_type = nil,
                                                    chiller_compressor_type = nil,
                                                    cool_fuel,
                                                    condenser_water_loop = nil,
                                                    building_type = nil)

                               end
        end

        # Add a gas-fired PSZ-AC to each zone
        # hvac_op_sch=nil means always on
        # oa_damper_sch to nil means always open
        model_add_psz_ac(model,
                         sys_name = nil,
                         hot_water_loop,
                         chilled_water_loop,
                         zones,
                         hvac_op_sch = nil,
                         oa_damper_sch = nil,
                         fan_location = 'DrawThrough',
                         fan_type = 'ConstantVolume',
                         heating_type,
                         supplemental_heating_type = 'Gas', # Should we really add supplemental heating here?
                         cooling_type,
                         building_type = nil)

      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,
                         'PSZ-HP',
                         nil,
                         nil,
                         zones,
                         nil,
                         nil,
                         'DrawThrough',
                         'ConstantVolume',
                         'Single Speed Heat Pump',
                         'Electric',
                         'Single Speed Heat Pump',
                         building_type = nil)

      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,
                                                  'const_pri',
                                                  chiller_cooling_type = nil,
                                                  chiller_condenser_type = nil,
                                                  chiller_compressor_type = nil,
                                                  cool_fuel,
                                                  condenser_water_loop = nil,
                                                  building_type = nil)
                             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.sort_by { |nm, z| z }[0][0]
        sys_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,
                         sys_name,
                         pri_zones,
                         nil,
                         nil,
                         electric_reheat,
                         hot_water_loop,
                         chilled_water_loop,
                         nil,
                         nil)
        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,
                                                  'const_pri',
                                                  chiller_cooling_type = nil,
                                                  chiller_condenser_type = nil,
                                                  chiller_compressor_type = nil,
                                                  cool_fuel,
                                                  condenser_water_loop = nil,
                                                  building_type = nil)
                             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.sort_by { |nm, z| z }[0][0]
        sys_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,
                                   sys_name,
                                   pri_zones,
                                   nil,
                                   nil,
                                   0.62,
                                   0.9,
                                   OpenStudio.convert(4.0, 'inH_{2}O', 'Pa').get,
                                   chilled_water_loop,
                                   nil)
        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,
                                                  'const_pri',
                                                  chiller_cooling_type = nil,
                                                  chiller_condenser_type = nil,
                                                  chiller_compressor_type = nil,
                                                  cool_fuel,
                                                  condenser_water_loop = nil,
                                                  building_type = nil)
        else
          fan_type = model_cw_loop_cooling_tower_fan_type(model)
          condenser_water_loop = model_add_cw_loop(model,
                                                   'Open Cooling Tower',
                                                   'Propeller or Axial',
                                                   fan_type,
                                                   1,
                                                   1,
                                                   nil)
          chilled_water_loop = model_add_chw_loop(model,
                                                  'const_pri_var_sec',
                                                  'WaterCooled',
                                                  chiller_condenser_type = nil,
                                                  'Rotary Screw',
                                                  cooling_fuel = nil,
                                                  condenser_water_loop,
                                                  building_type = nil)
        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.sort_by { |nm, z| z }[0][0]
        sys_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,
                               sys_name,
                               hot_water_loop,
                               chilled_water_loop,
                               pri_zones,
                               nil,
                               nil,
                               0.62,
                               0.9,
                               OpenStudio.convert(4.0, 'inH_{2}O', 'Pa').get,
                               nil,
                               reheat_type,
                               nil)
        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,
                                                  'const_pri',
                                                  chiller_cooling_type = nil,
                                                  chiller_condenser_type = nil,
                                                  chiller_compressor_type = nil,
                                                  cool_fuel,
                                                  condenser_water_loop = nil,
                                                  building_type = nil)
        else
          fan_type = model_cw_loop_cooling_tower_fan_type(model)
          condenser_water_loop = model_add_cw_loop(model,
                                                   'Open Cooling Tower',
                                                   'Propeller or Axial',
                                                   fan_type,
                                                   1,
                                                   1,
                                                   nil)
          chilled_water_loop = model_add_chw_loop(model,
                                                  'const_pri_var_sec',
                                                  'WaterCooled',
                                                  chiller_condenser_type = nil,
                                                  'Rotary Screw',
                                                  cool_fueling = nil,
                                                  condenser_water_loop,
                                                  building_type = nil)
        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.sort_by { |nm, z| z }[0][0]
        sys_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,
                                  sys_name,
                                  chilled_water_loop,
                                  pri_zones,
                                  nil,
                                  nil,
                                  0.62,
                                  0.9,
                                  OpenStudio.convert(4.0, 'inH_{2}O', 'Pa').get)
        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,
                             nil,
                             zones,
                             nil,
                             'ConstantVolume',
                             OpenStudio.convert(0.2, 'inH_{2}O', 'Pa').get,
                             main_heat_fuel,
                             hot_water_loop,
                             nil)

      end

    when 'Electric_Furnace' # System 10

      unless zones.empty?

        # Add a System 10 - Electric Unit Heater to each zone
        model_add_unitheater(model,
                             nil,
                             zones,
                             nil,
                             'ConstantVolume',
                             OpenStudio.convert(0.2, 'inH_{2}O', 'Pa').get,
                             main_heat_fuel,
                             nil,
                             nil)

      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_prm_construction_set(model, category) ⇒ OpenStudio::Model::DefaultConstructionSet

Creates a construction set with the construction types specified in the Performance Rating Method (aka Appendix G aka LEED) and adds it to the model. This method creates and adds the constructions and their materials as well.

Valid choices are Nonresidential, Residential, and Semiheated construction set populated with the specified constructions.

Parameters:

  • category (String)

    the construction set category desired.

Returns:

  • (OpenStudio::Model::DefaultConstructionSet)

    returns a default



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
1795
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1617

def model_add_prm_construction_set(model, category)
  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
    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
      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)

  # Specify the types of constructions
  # Exterior surfaces constructions
  exterior_floor_standards_construction_type = 'SteelFramed'
  exterior_wall_standards_construction_type = 'SteelFramed'
  exterior_roof_standards_construction_type = 'IEAD'

  # Ground contact surfaces constructions
  ground_contact_floor_standards_construction_type = 'Unheated'
  ground_contact_wall_standards_construction_type = 'Mass'

  # Exterior sub surfaces constructions
  exterior_fixed_window_standards_construction_type = 'IEAD'
  exterior_operable_window_standards_construction_type = 'IEAD'
  exterior_door_standards_construction_type = 'IEAD'
  exterior_overhead_door_standards_construction_type = 'IEAD'
  exterior_skylight_standards_construction_type = 'IEAD'

  # Exterior surfaces constructions
  exterior_surfaces = OpenStudio::Model::DefaultSurfaceConstructions.new(model)
  construction_set.setDefaultExteriorSurfaceConstructions(exterior_surfaces)
  exterior_surfaces.setFloorConstruction(model_find_and_add_construction(model,
                                                                         climate_zone_set,
                                                                         'ExteriorFloor',
                                                                         exterior_floor_standards_construction_type,
                                                                         category))

  exterior_surfaces.setWallConstruction(model_find_and_add_construction(model,
                                                                        climate_zone_set,
                                                                        'ExteriorWall',
                                                                        exterior_wall_standards_construction_type,
                                                                        category))

  exterior_surfaces.setRoofCeilingConstruction(model_find_and_add_construction(model,
                                                                               climate_zone_set,
                                                                               'ExteriorRoof',
                                                                               exterior_roof_standards_construction_type,
                                                                               category))

  # Interior surfaces constructions
  interior_surfaces = OpenStudio::Model::DefaultSurfaceConstructions.new(model)
  construction_set.setDefaultInteriorSurfaceConstructions(interior_surfaces)
  construction_name = interior_floors
  unless construction_name.nil?
    interior_surfaces.setFloorConstruction(model_add_construction(model, construction_name))
  end
  construction_name = interior_walls
  unless construction_name.nil?
    interior_surfaces.setWallConstruction(model_add_construction(model, construction_name))
  end
  construction_name = 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)
  ground_surfaces.setFloorConstruction(model_find_and_add_construction(model,
                                                                       climate_zone_set,
                                                                       'GroundContactFloor',
                                                                       ground_contact_floor_standards_construction_type,
                                                                       category))

  ground_surfaces.setWallConstruction(model_find_and_add_construction(model,
                                                                      climate_zone_set,
                                                                      'GroundContactWall',
                                                                      ground_contact_wall_standards_construction_type,
                                                                      category))

  # Exterior sub surfaces constructions
  exterior_subsurfaces = OpenStudio::Model::DefaultSubSurfaceConstructions.new(model)
  construction_set.setDefaultExteriorSubSurfaceConstructions(exterior_subsurfaces)
  if exterior_fixed_window_standards_construction_type && exterior_fixed_window_building_category
    exterior_subsurfaces.setFixedWindowConstruction(model_find_and_add_construction(model,
                                                                                    climate_zone_set,
                                                                                    'ExteriorWindow',
                                                                                    exterior_fixed_window_standards_construction_type,
                                                                                    category))
  end
  if exterior_operable_window_standards_construction_type && exterior_operable_window_building_category
    exterior_subsurfaces.setOperableWindowConstruction(model_find_and_add_construction(model,
                                                                                       climate_zone_set,
                                                                                       'ExteriorWindow',
                                                                                       exterior_operable_window_standards_construction_type,
                                                                                       category))
  end
  if exterior_door_standards_construction_type && exterior_door_building_category
    exterior_subsurfaces.setDoorConstruction(model_find_and_add_construction(model,
                                                                             climate_zone_set,
                                                                             'ExteriorDoor',
                                                                             exterior_door_standards_construction_type,
                                                                             category))
  end
  construction_name = exterior_glass_doors
  unless construction_name.nil?
    exterior_subsurfaces.setGlassDoorConstruction(model_add_construction(model, construction_name))
  end
  if exterior_overhead_door_standards_construction_type && exterior_overhead_door_building_category
    exterior_subsurfaces.setOverheadDoorConstruction(model_find_and_add_construction(model,
                                                                                     climate_zone_set,
                                                                                     'ExteriorDoor',
                                                                                     exterior_overhead_door_standards_construction_type,
                                                                                     category))
  end
  if exterior_skylight_standards_construction_type && exterior_skylight_building_category
    exterior_subsurfaces.setSkylightConstruction(model_find_and_add_construction(model,
                                                                                 climate_zone_set,
                                                                                 'Skylight',
                                                                                 exterior_skylight_standards_construction_type,
                                                                                 category))
  end
  if construction_name == tubular_daylight_domes
    exterior_subsurfaces.setTubularDaylightDomeConstruction(model_add_construction(model, construction_name))
  end
  if construction_name == 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 == interior_fixed_windows
    interior_subsurfaces.setFixedWindowConstruction(model_add_construction(model, construction_name))
  end
  if construction_name == interior_operable_windows
    interior_subsurfaces.setOperableWindowConstruction(model_add_construction(model, construction_name))
  end
  if construction_name == interior_doors
    interior_subsurfaces.setDoorConstruction(model_add_construction(model, construction_name))
  end

  # Other constructions
  if construction_name == interior_partitions
    construction_set.setInteriorPartitionConstruction(model_add_construction(model, construction_name))
  end
  if construction_name == space_shading
    construction_set.setSpaceShadingConstruction(model_add_construction(model, construction_name))
  end
  if construction_name == building_shading
    construction_set.setBuildingShadingConstruction(model_add_construction(model, construction_name))
  end
  if construction_name == 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)

  # Create a constuction set that is all
end

#model_add_psz_ac(model, sys_name, hot_water_loop, chilled_water_loop, thermal_zones, hvac_op_sch, oa_damper_sch, fan_location, fan_type, heating_type, supplemental_heating_type, cooling_type, building_type = nil) ⇒ Array<OpenStudio::Model::AirLoopHVAC>

Creates a PSZ-AC system for each zone 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 Single Speed Heat Pump, Water To Air Heat Pump Single Speed DX AC, Single Speed Heat Pump, Water To Air Heat Pump Todo: clarify where these default curves coefficients are coming from Todo: I (jmarrec) believe it is the DOE Ref curves (“DOE Ref DX Clg Coil Cool-Cap-fT”)

Parameters:

  • sys_name (String)

    the name of the system, or nil in which case it will be defaulted

  • hot_water_loop (String)

    hot water loop to connect heating coil to, or nil

  • chilled_water_loop (String)

    chilled water loop to connect cooling coil to, or nil

  • thermal_zones (String)

    zones to connect to this system

  • hvac_op_sch (String)

    name of the HVAC operation schedule

  • oa_damper_sch (Double)

    name of the oa damper schedule,

  • fan_location (Double)

    valid choices are BlowThrough, DrawThrough

  • fan_type (Double)

    valid choices are ConstantVolume, Cycling

  • heating_type (Double)

    valid choices are NaturalGas, Electricity, Water, nil (no heat)

  • supplemental_heating_type (Double)

    valid choices are Electricity, NaturalGas, nil (no heat)

  • cooling_type (String)

    valid choices are Water, Two Speed DX AC,

  • building_type (String) (defaults to: nil)

    the building type

Returns:



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
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
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
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
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
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 1718

def model_add_psz_ac(model,
                     sys_name,
                     hot_water_loop,
                     chilled_water_loop,
                     thermal_zones,
                     hvac_op_sch,
                     oa_damper_sch,
                     fan_location,
                     fan_type,
                     heating_type,
                     supplemental_heating_type,
                     cooling_type,
                     building_type = nil)

  hw_temp_f = 180 # HW setpoint 180F
  hw_delta_t_r = 20 # 20F delta-T
  hw_temp_c = OpenStudio.convert(hw_temp_f, 'F', 'C').get
  hw_delta_t_k = OpenStudio.convert(hw_delta_t_r, 'R', 'K').get

  # control temps used across all air handlers
  clg_sa_temp_f = 55 # Central deck clg temp 55F
  prehtg_sa_temp_f = 44.6 # Preheat to 44.6F
  htg_sa_temp_f = 55 # Central deck htg temp 55F
  rht_sa_temp_f = 104 # VAV box reheat to 104F

  clg_sa_temp_c = OpenStudio.convert(clg_sa_temp_f, 'F', 'C').get
  prehtg_sa_temp_c = OpenStudio.convert(prehtg_sa_temp_f, 'F', 'C').get
  htg_sa_temp_c = OpenStudio.convert(htg_sa_temp_f, 'F', 'C').get
  rht_sa_temp_c = OpenStudio.convert(rht_sa_temp_f, 'F', 'C').get

  # hvac operation schedule
  hvac_op_sch = if hvac_op_sch.nil?
                  model.alwaysOnDiscreteSchedule
                else
                  model_add_schedule(model, hvac_op_sch)
                end

  # oa damper schedule
  oa_damper_sch = if oa_damper_sch.nil?
                    model.alwaysOnDiscreteSchedule
                  else
                    model_add_schedule(model, oa_damper_sch)
                  end

  # Make 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 sys_name.nil?
      air_loop.setName("#{zone.name} PSZ-AC")
    else
      air_loop.setName("#{zone.name} #{sys_name}")
    end
    air_loop.setAvailabilitySchedule(hvac_op_sch)
    air_loops << air_loop

    # When an air_loop is contructed, its constructor creates a sizing:system object
    # the default sizing:system contstructor makes a system:sizing object
    # appropriate for a multizone VAV system
    # this systems is a constant volume system with no VAV terminals,
    # and therfore needs different default settings
    air_loop_sizing = air_loop.sizingSystem # TODO units
    air_loop_sizing.setTypeofLoadtoSizeOn('Sensible')
    air_loop_sizing.autosizeDesignOutdoorAirFlowRate
    air_loop_sizing.setMinimumSystemAirFlowRatio(1.0)
    air_loop_sizing.setPreheatDesignTemperature(7.0)
    air_loop_sizing.setPreheatDesignHumidityRatio(0.008)
    air_loop_sizing.setPrecoolDesignTemperature(12.8)
    air_loop_sizing.setPrecoolDesignHumidityRatio(0.008)
    air_loop_sizing.setCentralCoolingDesignSupplyAirTemperature(12.8)
    air_loop_sizing.setCentralHeatingDesignSupplyAirTemperature(40.0)
    air_loop_sizing.setSizingOption('Coincident')
    air_loop_sizing.setAllOutdoorAirinCooling(false)
    air_loop_sizing.setAllOutdoorAirinHeating(false)
    air_loop_sizing.setCentralCoolingDesignSupplyAirHumidityRatio(0.0085)
    air_loop_sizing.setCentralHeatingDesignSupplyAirHumidityRatio(0.0080)
    air_loop_sizing.setCoolingDesignAirFlowMethod('DesignDay')
    air_loop_sizing.setCoolingDesignAirFlowRate(0.0)
    air_loop_sizing.setHeatingDesignAirFlowMethod('DesignDay')
    air_loop_sizing.setHeatingDesignAirFlowRate(0.0)
    air_loop_sizing.setSystemOutdoorAirMethod('ZoneSum')

    # Zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(12.8)
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(40.0)

    # Add a setpoint manager single zone reheat to control the
    # supply air temperature based on the needs of this zone
    setpoint_mgr_single_zone_reheat = OpenStudio::Model::SetpointManagerSingleZoneReheat.new(model)
    setpoint_mgr_single_zone_reheat.setControlZone(zone)

    fan = nil
    # ConstantVolume: Packaged Rooftop Single Zone Air conditioner;
    # Cycling: Unitary System;
    # CyclingHeatPump: Unitary Heat Pump system
    if fan_type == 'ConstantVolume'
      fan = OpenStudio::Model::FanConstantVolume.new(model, hvac_op_sch)
      fan.setName("#{air_loop.name} Fan")
      fan_static_pressure_in_h2o = 2.5
      fan_static_pressure_pa = OpenStudio.convert(fan_static_pressure_in_h2o, 'inH_{2}O', 'Pa').get
      fan.setPressureRise(fan_static_pressure_pa)
      fan.setFanEfficiency(0.54)
      fan.setMotorEfficiency(0.90)
    elsif fan_type == 'Cycling'

      fan = OpenStudio::Model::FanOnOff.new(model, hvac_op_sch) # Set fan op sch manually since fwd translator doesn't
      fan.setName("#{air_loop.name} Fan")
      fan_static_pressure_in_h2o = 2.5
      fan_static_pressure_pa = OpenStudio.convert(fan_static_pressure_in_h2o, 'inH_{2}O', 'Pa').get
      fan.setPressureRise(fan_static_pressure_pa)
      fan.setFanEfficiency(0.54)
      fan.setMotorEfficiency(0.90)
    else
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Fan type '#{fan_type}' not recognized, cannot add PSZ-AC.")
      return []
    end

    htg_coil = nil
    case heating_type
    when 'NaturalGas', 'Gas'
      htg_coil = OpenStudio::Model::CoilHeatingGas.new(model, model.alwaysOnDiscreteSchedule)
      htg_coil.setName("#{air_loop.name} Gas Htg Coil")
    when nil
      # Zero-capacity, always-off electric heating coil
      htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOffDiscreteSchedule)
      htg_coil.setName("#{air_loop.name} No Heat")
      htg_coil.setNominalCapacity(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 = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule)
      htg_coil.setName("#{air_loop.name} Water Htg Coil")
      htg_coil.setRatedInletWaterTemperature(hw_temp_c)
      htg_coil.setRatedInletAirTemperature(prehtg_sa_temp_c)
      htg_coil.setRatedOutletWaterTemperature(hw_temp_c - hw_delta_t_k)
      htg_coil.setRatedOutletAirTemperature(htg_sa_temp_c)
      hot_water_loop.addDemandBranchForComponent(htg_coil)
    when 'Single Speed Heat Pump'
      htg_cap_f_of_temp = OpenStudio::Model::CurveCubic.new(model)
      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.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.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.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.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)

      htg_coil = OpenStudio::Model::CoilHeatingDXSingleSpeed.new(model,
                                                                 model.alwaysOnDiscreteSchedule,
                                                                 htg_cap_f_of_temp,
                                                                 htg_cap_f_of_flow,
                                                                 htg_energy_input_ratio_f_of_temp,
                                                                 htg_energy_input_ratio_f_of_flow,
                                                                 htg_part_load_fraction)

      htg_coil.setName("#{air_loop.name} HP Htg Coil")
      htg_coil.setRatedCOP(3.3) # TODO: add this to standards
      htg_coil.setMinimumOutdoorDryBulbTemperatureforCompressorOperation(-12.2)
      htg_coil.setMaximumOutdoorDryBulbTemperatureforDefrostOperation(1.67)
      htg_coil.setCrankcaseHeaterCapacity(50.0)
      htg_coil.setMaximumOutdoorDryBulbTemperatureforCrankcaseHeaterOperation(4.4)

      htg_coil.setDefrostStrategy('ReverseCycle')
      htg_coil.setDefrostControl('OnDemand')

      def_eir_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)
      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(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)

      htg_coil.setDefrostEnergyInputRatioFunctionofTemperatureCurve(def_eir_f_of_temp)
    when 'Water To Air Heat Pump'
      if hot_water_loop.nil?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'No hot water plant loop supplied')
        return false
      end
      htg_coil = OpenStudio::Model::CoilHeatingWaterToAirHeatPumpEquationFit.new(model)
      htg_coil.setName("#{air_loop.name} Water-to-Air HP Htg Coil")
      htg_coil.setRatedHeatingCoefficientofPerformance(4.2) # TODO: add this to standards
      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)

      hot_water_loop.addDemandBranchForComponent(htg_coil)
    when 'Electricity', 'Electric'
      htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)
      htg_coil.setName("#{air_loop.name} Electric Htg Coil")
    end

    supplemental_htg_coil = nil
    case supplemental_heating_type
    when 'Electricity', 'Electric' # TODO: change spreadsheet to Electricity
      supplemental_htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)
      supplemental_htg_coil.setName("#{air_loop.name} Electric Backup Htg Coil")
    when 'NaturalGas', 'Gas'
      supplemental_htg_coil = OpenStudio::Model::CoilHeatingGas.new(model, model.alwaysOnDiscreteSchedule)
      supplemental_htg_coil.setName("#{air_loop.name} Gas Backup Htg Coil")
    when nil
      # Zero-capacity, always-off electric heating coil
      supplemental_htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOffDiscreteSchedule)
      supplemental_htg_coil.setName("#{air_loop.name} No Backup Heat")
      supplemental_htg_coil.setNominalCapacity(0)
    end

    clg_coil = nil
    if cooling_type == 'Water'
      if chilled_water_loop.nil?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'No chilled water plant loop supplied')
        return false
      end
      clg_coil = OpenStudio::Model::CoilCoolingWater.new(model, model.alwaysOnDiscreteSchedule)
      clg_coil.setName("#{air_loop.name} Water Clg Coil")
      chilled_water_loop.addDemandBranchForComponent(clg_coil)
    elsif cooling_type == 'Two Speed DX AC'

      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 = OpenStudio::Model::CoilCoolingDXTwoSpeed.new(model,
                                                              model.alwaysOnDiscreteSchedule,
                                                              clg_cap_f_of_temp,
                                                              clg_cap_f_of_flow,
                                                              clg_energy_input_ratio_f_of_temp,
                                                              clg_energy_input_ratio_f_of_flow,
                                                              clg_part_load_ratio,
                                                              clg_cap_f_of_temp_low_spd,
                                                              clg_energy_input_ratio_f_of_temp_low_spd)

      clg_coil.setName("#{air_loop.name} 2spd DX AC Clg Coil")
      clg_coil.setRatedLowSpeedSensibleHeatRatio(OpenStudio::OptionalDouble.new(0.69))
      clg_coil.setBasinHeaterCapacity(10)
      clg_coil.setBasinHeaterSetpointTemperature(2.0)

    elsif cooling_type == 'Single Speed DX 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)

      clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model,
                                                                 model.alwaysOnDiscreteSchedule,
                                                                 clg_cap_f_of_temp,
                                                                 clg_cap_f_of_flow,
                                                                 clg_energy_input_ratio_f_of_temp,
                                                                 clg_energy_input_ratio_f_of_flow,
                                                                 clg_part_load_ratio)

      clg_coil.setName("#{air_loop.name} 1spd DX AC Clg Coil")

    elsif cooling_type == 'Single Speed 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)

      clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model,
                                                                 model.alwaysOnDiscreteSchedule,
                                                                 clg_cap_f_of_temp,
                                                                 clg_cap_f_of_flow,
                                                                 clg_energy_input_ratio_f_of_temp,
                                                                 clg_energy_input_ratio_f_of_flow,
                                                                 clg_part_load_ratio)

      clg_coil.setName("#{air_loop.name} 1spd DX HP Clg Coil")
      # clg_coil.setMaximumOutdoorDryBulbTemperatureForCrankcaseHeaterOperation(OpenStudio::OptionalDouble.new(10.0))
      # clg_coil.setRatedSensibleHeatRatio(0.69)
      # clg_coil.setBasinHeaterCapacity(10)
      # clg_coil.setBasinHeaterSetpointTemperature(2.0)

    elsif cooling_type == '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 = OpenStudio::Model::CoilCoolingWaterToAirHeatPumpEquationFit.new(model)
      clg_coil.setName("#{air_loop.name} Water-to-Air HP Clg Coil")
      clg_coil.setRatedCoolingCoefficientofPerformance(3.4) # TODO: add this to standards

      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)

      chilled_water_loop.addDemandBranchForComponent(clg_coil)
    end

    oa_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
    oa_controller.setName("#{air_loop.name} OA Sys Controller")
    oa_controller.setMinimumOutdoorAirSchedule(oa_damper_sch)
    oa_system = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_controller)
    oa_system.setName("#{air_loop.name} OA Sys")
    econ_eff_sch = model_add_schedule(model, 'RetailStandalone PSZ_Econ_MaxOAFrac_Sch')

    # Add the components to the air loop
    # in order from closest to zone to furthest from zone
    supply_inlet_node = air_loop.supplyInletNode

    # Wrap coils in a unitary system or not, depending
    # on the system type.
    if fan_type == 'Cycling'

      if heating_type == 'Water To Air Heat Pump'
        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 HP")
        unitary_system.setControllingZoneorThermostatLocation(zone)
        unitary_system.setMaximumSupplyAirTemperature(50)
        unitary_system.setFanPlacement('BlowThrough')
        unitary_system.setSupplyAirFlowRateMethodDuringCoolingOperation('SupplyAirFlowRate')
        unitary_system.setSupplyAirFlowRateMethodDuringHeatingOperation('SupplyAirFlowRate')
        unitary_system.setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired('SupplyAirFlowRate')
        unitary_system.setSupplyAirFanOperatingModeSchedule(model.alwaysOnDiscreteSchedule)
        unitary_system.addToNode(supply_inlet_node)
        setpoint_mgr_single_zone_reheat.setMaximumSupplyAirTemperature(50)
      else
        unitary_system = OpenStudio::Model::AirLoopHVACUnitaryHeatPumpAirToAir.new(model,
                                                                                   model.alwaysOnDiscreteSchedule,
                                                                                   fan,
                                                                                   htg_coil,
                                                                                   clg_coil,
                                                                                   supplemental_htg_coil)
        unitary_system.setName("#{air_loop.name} Unitary HP")
        unitary_system.setControllingZone(zone)
        unitary_system.setMaximumOutdoorDryBulbTemperatureforSupplementalHeaterOperation(OpenStudio.convert(40, 'F', 'C').get)
        unitary_system.setFanPlacement(fan_location)
        unitary_system.setSupplyAirFanOperatingModeSchedule(hvac_op_sch)
        unitary_system.addToNode(supply_inlet_node)

        setpoint_mgr_single_zone_reheat.setMinimumSupplyAirTemperature(OpenStudio.convert(55, 'F', 'C').get)
        setpoint_mgr_single_zone_reheat.setMaximumSupplyAirTemperature(OpenStudio.convert(104, 'F', 'C').get)
      end

    else
      if fan_location == 'DrawThrough'
        # Add the fan
        unless fan.nil?
          fan.addToNode(supply_inlet_node)
        end

        # Add the supplemental heating coil
        unless supplemental_htg_coil.nil?
          supplemental_htg_coil.addToNode(supply_inlet_node)
        end

        # Add the heating coil
        unless htg_coil.nil?
          htg_coil.addToNode(supply_inlet_node)
        end

        # Add the cooling coil
        unless clg_coil.nil?
          clg_coil.addToNode(supply_inlet_node)
        end
      elsif fan_location == 'BlowThrough'
        # Add the supplemental heating coil
        unless supplemental_htg_coil.nil?
          supplemental_htg_coil.addToNode(supply_inlet_node)
        end

        # Add the cooling coil
        unless clg_coil.nil?
          clg_coil.addToNode(supply_inlet_node)
        end

        # Add the heating coil
        unless htg_coil.nil?
          htg_coil.addToNode(supply_inlet_node)
        end

        # Add the fan
        unless fan.nil?
          fan.addToNode(supply_inlet_node)
        end
      else
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'Invalid fan location')
        return false
      end

      setpoint_mgr_single_zone_reheat.setMinimumSupplyAirTemperature(OpenStudio.convert(50, 'F', 'C').get)
      setpoint_mgr_single_zone_reheat.setMaximumSupplyAirTemperature(OpenStudio.convert(122, 'F', 'C').get)

    end

    # Add the OA system
    oa_system.addToNode(supply_inlet_node)

    # Attach the nightcycle manager to the supply outlet node
    setpoint_mgr_single_zone_reheat.addToNode(air_loop.supplyOutletNode)
    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.addBranchForZone(zone, diffuser.to_StraightComponent)
  end

  return air_loops
end

#model_add_psz_vav(model, sys_name, thermal_zones, hvac_op_sch, oa_damper_sch, heating_type, supplemental_heating_type, building_type = nil) ⇒ Array<OpenStudio::Model::AirLoopHVAC>

Creates a packaged single zone VAV system for each zone 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

Parameters:

  • sys_name (String)

    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)

    name of the HVAC operation schedule

  • oa_damper_sch (Double)

    name of the oa damper schedule,

  • heating_type (Double)

    valid choices are NaturalGas, Electricity, Water, nil (no heat)

  • supplemental_heating_type (Double)

    valid choices are Electricity, NaturalGas, nil (no heat)

  • building_type (String) (defaults to: nil)

    the building type

Returns:



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
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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 2344

def model_add_psz_vav(model,
                      sys_name,
                      thermal_zones,
                      hvac_op_sch,
                      oa_damper_sch,
                      heating_type,
                      supplemental_heating_type,
                      building_type = nil)

  # control temps used across all air handlers
  clg_sa_temp_f = 55 # Central deck clg temp 55F
  prehtg_sa_temp_f = 44.6 # Preheat to 44.6F
  htg_sa_temp_f = 55 # Central deck htg temp 55F
  rht_sa_temp_f = 104 # VAV box reheat to 104F

  clg_sa_temp_c = OpenStudio.convert(clg_sa_temp_f, 'F', 'C').get
  prehtg_sa_temp_c = OpenStudio.convert(prehtg_sa_temp_f, 'F', 'C').get
  htg_sa_temp_c = OpenStudio.convert(htg_sa_temp_f, 'F', 'C').get
  rht_sa_temp_c = OpenStudio.convert(rht_sa_temp_f, 'F', 'C').get

  # hvac operation schedule
  hvac_op_sch = if hvac_op_sch.nil?
                  model.alwaysOnDiscreteSchedule
                else
                  model_add_schedule(model, hvac_op_sch)
                end

  # oa damper schedule
  oa_damper_sch = if oa_damper_sch.nil?
                    model.alwaysOnDiscreteSchedule
                  else
                    model_add_schedule(model, oa_damper_sch)
                  end

  # Make 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 sys_name.nil?
      air_loop.setName("#{zone.name} PSZ-VAV")
    else
      air_loop.setName("#{zone.name} #{sys_name}")
    end
    air_loop.setAvailabilitySchedule(hvac_op_sch)
    air_loops << air_loop

    # Sizing
    air_loop_sizing = air_loop.sizingSystem
    air_loop_sizing.setTypeofLoadtoSizeOn('Sensible')
    air_loop_sizing.autosizeDesignOutdoorAirFlowRate
    air_loop_sizing.setMinimumSystemAirFlowRatio(0.0)
    air_loop_sizing.setPreheatDesignTemperature(7.0)
    air_loop_sizing.setPreheatDesignHumidityRatio(0.008)
    air_loop_sizing.setPrecoolDesignTemperature(12.8)
    air_loop_sizing.setPrecoolDesignHumidityRatio(0.008)
    air_loop_sizing.setCentralCoolingDesignSupplyAirTemperature(12.8)
    air_loop_sizing.setCentralHeatingDesignSupplyAirTemperature(40.0)
    air_loop_sizing.setSizingOption('Coincident')
    air_loop_sizing.setAllOutdoorAirinCooling(false)
    air_loop_sizing.setAllOutdoorAirinHeating(false)
    air_loop_sizing.setCentralCoolingDesignSupplyAirHumidityRatio(0.0085)
    air_loop_sizing.setCentralHeatingDesignSupplyAirHumidityRatio(0.0080)
    air_loop_sizing.setCoolingDesignAirFlowMethod('DesignDay')
    air_loop_sizing.setCoolingDesignAirFlowRate(0.0)
    air_loop_sizing.setHeatingDesignAirFlowMethod('DesignDay')
    air_loop_sizing.setHeatingDesignAirFlowRate(0.0)
    air_loop_sizing.setSystemOutdoorAirMethod('ZoneSum')

    # Zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(14)
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(40.0)

    # Add a setpoint manager single zone reheat to control the
    # supply air temperature based on the needs of this zone
    setpoint_mgr_single_zone_reheat = OpenStudio::Model::SetpointManagerSingleZoneReheat.new(model)
    setpoint_mgr_single_zone_reheat.setControlZone(zone)

    # Fan
    fan = OpenStudio::Model::FanVariableVolume.new(model, hvac_op_sch)
    fan.setName("#{air_loop.name} Fan")
    fan_static_pressure_in_h2o = 2.5
    fan_static_pressure_pa = OpenStudio.convert(fan_static_pressure_in_h2o, 'inH_{2}O', 'Pa').get
    fan.setPressureRise(fan_static_pressure_pa)
    fan.setFanEfficiency(0.54)
    fan.setMotorEfficiency(0.90)

    # Heating coil
    htg_coil = nil
    case heating_type
    when 'NaturalGas', 'Gas'
      htg_coil = OpenStudio::Model::CoilHeatingGas.new(model, model.alwaysOnDiscreteSchedule)
      htg_coil.setName("#{air_loop.name} Gas Htg Coil")
    when nil
      # Zero-capacity, always-off electric heating coil
      htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOffDiscreteSchedule)
      htg_coil.setName("#{air_loop.name} No Heat")
      htg_coil.setNominalCapacity(0)
    when 'Electricity', 'Electric'
      htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)
      htg_coil.setName("#{air_loop.name} Electric Htg Coil")
    end

    supplemental_htg_coil = nil
    case supplemental_heating_type
    when 'Electricity', 'Electric' # TODO change spreadsheet to Electricity
      supplemental_htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)
      supplemental_htg_coil.setName("#{air_loop.name} Electric Backup Htg Coil")
    when 'NaturalGas', 'Gas'
      supplemental_htg_coil = OpenStudio::Model::CoilHeatingGas.new(model, model.alwaysOnDiscreteSchedule)
      supplemental_htg_coil.setName("#{air_loop.name} Gas Backup Htg Coil")
    when nil
      # Zero-capacity, always-off electric heating coil
      supplemental_htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOffDiscreteSchedule)
      supplemental_htg_coil.setName("#{air_loop.name} No Backup Heat")
      supplemental_htg_coil.setNominalCapacity(0)
    end

    # 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)
    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)

    # 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.setHeatRecoveryBypassControlType('BypassWhenOAFlowGreaterThanMinimum')
    oa_system = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_controller)
    oa_system.setName("#{air_loop.name} OA Sys")
    econ_eff_sch = model_add_schedule(model, 'RetailStandalone PSZ_Econ_MaxOAFrac_Sch')

    # Add the components to the air loop
    # in order from closest to zone to furthest from zone
    supply_inlet_node = air_loop.supplyInletNode

    # 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(50)
    unitary_system.setFanPlacement('BlowThrough')
    unitary_system.setSupplyAirFlowRateMethodDuringCoolingOperation('SupplyAirFlowRate')
    unitary_system.setSupplyAirFlowRateMethodDuringHeatingOperation('SupplyAirFlowRate')
    unitary_system.setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired('SupplyAirFlowRate')
    unitary_system.setSupplyAirFanOperatingModeSchedule(model.alwaysOnDiscreteSchedule)
    unitary_system.addToNode(supply_inlet_node)

    # Add the OA system
    oa_system.addToNode(supply_inlet_node)

    # Set up nightcycling
    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.addBranchForZone(zone, diffuser.to_StraightComponent)
  end

  return air_loops
end

#model_add_ptac(model, sys_name, hot_water_loop, thermal_zones, fan_type, heating_type, cooling_type, building_type = nil) ⇒ Array<OpenStudio::Model::ZoneHVACPackagedTerminalAirConditioner>

Creates a PTAC system for each zone and adds it to the model.

NaturalGas, Electricity, Water, nil (no heat) Two Speed DX AC, Single Speed DX AC array of the resulting PTACs.

Parameters:

  • sys_name (String)

    the name of the system, or nil in which case it will be defaulted

  • hot_water_loop (String)

    hot water loop to connect heating coil to. Set to nil for heating types besides water.

  • thermal_zones (String)

    zones to connect to this system

  • fan_type (Double)

    valid choices are ConstantVolume, Cycling

  • heating_type (Double)

    valid choices are

  • cooling_type (String)

    valid choices are

  • building_type (String) (defaults to: nil)

    the building type

Returns:



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
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
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
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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 3242

def model_add_ptac(model,
                   sys_name,
                   hot_water_loop,
                   thermal_zones,
                   fan_type,
                   heating_type,
                   cooling_type,
                   building_type = nil)

  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding PTAC for #{zone.name}.")
  end

  # schedule: always off
  always_off = OpenStudio::Model::ScheduleRuleset.new(model)
  always_off.setName('ALWAYS_OFF')
  always_off.defaultDaySchedule.setName('ALWAYS_OFF day')
  always_off.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0.0)
  always_off.setSummerDesignDaySchedule(always_off.defaultDaySchedule)
  always_off.setWinterDesignDaySchedule(always_off.defaultDaySchedule)

  # Make a PTAC for each zone
  ptacs = []
  thermal_zones.each do |zone|
    # Zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(14)
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(50.0)
    sizing_zone.setZoneCoolingDesignSupplyAirHumidityRatio(0.008)
    sizing_zone.setZoneHeatingDesignSupplyAirHumidityRatio(0.008)

    # add fan
    fan = nil
    if fan_type == 'ConstantVolume'
      fan = OpenStudio::Model::FanConstantVolume.new(model, model.alwaysOnDiscreteSchedule)
      fan.setName("#{zone.name} PTAC Fan")
      fan_static_pressure_in_h2o = 1.33
      fan_static_pressure_pa = OpenStudio.convert(fan_static_pressure_in_h2o, 'inH_{2}O', 'Pa').get
      fan.setPressureRise(fan_static_pressure_pa)
      fan.setFanEfficiency(0.52)
      fan.setMotorEfficiency(0.8)
    elsif fan_type == 'Cycling'
      fan = OpenStudio::Model::FanOnOff.new(model, model.alwaysOnDiscreteSchedule)
      fan.setName("#{zone.name} PTAC Fan")
      fan_static_pressure_in_h2o = 1.33
      fan_static_pressure_pa = OpenStudio.convert(fan_static_pressure_in_h2o, 'inH_{2}O', 'Pa').get
      fan.setPressureRise(fan_static_pressure_pa)
      fan.setFanEfficiency(0.52)
      fan.setMotorEfficiency(0.8)
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', "ptac_fan_type of #{fan_type} is not recognized.")
    end

    # add heating coil
    htg_coil = nil
    case heating_type
    when 'NaturalGas', 'Gas'
      htg_coil = OpenStudio::Model::CoilHeatingGas.new(model, model.alwaysOnDiscreteSchedule)
      htg_coil.setName("#{zone.name} PTAC Gas Htg Coil")
    when 'Electricity', 'Electric'
      htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)
      htg_coil.setName("#{zone.name} PTAC Electric Htg Coil")
    when nil
      htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOffDiscreteSchedule)
      htg_coil.setName("#{zone.name} PTAC No Heat")
      htg_coil.setNominalCapacity(0)
    when 'Water'
      if hot_water_loop.nil?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', 'No hot water plant loop supplied')
        return false
      end

      hw_sizing = hot_water_loop.sizingPlant
      hw_temp_c = hw_sizing.designLoopExitTemperature
      hw_delta_t_k = hw_sizing.loopDesignTemperatureDifference

      # Using openstudio defaults for now...
      prehtg_sa_temp_c = 16.6
      htg_sa_temp_c = 32.2

      htg_coil = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule)
      htg_coil.setName("#{hot_water_loop.name} Water Htg Coil")
      # None of these temperatures are defined
      htg_coil.setRatedInletWaterTemperature(hw_temp_c)
      htg_coil.setRatedInletAirTemperature(prehtg_sa_temp_c)
      htg_coil.setRatedOutletWaterTemperature(hw_temp_c - hw_delta_t_k)
      htg_coil.setRatedOutletAirTemperature(htg_sa_temp_c)
      hot_water_loop.addDemandBranchForComponent(htg_coil)
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', "ptac_heating_type of #{heating_type} is not recognized.")
    end

    # add cooling coil
    clg_coil = nil
    if cooling_type == 'Two Speed DX AC'

      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 = OpenStudio::Model::CoilCoolingDXTwoSpeed.new(model,
                                                              model.alwaysOnDiscreteSchedule,
                                                              clg_cap_f_of_temp,
                                                              clg_cap_f_of_flow,
                                                              clg_energy_input_ratio_f_of_temp,
                                                              clg_energy_input_ratio_f_of_flow,
                                                              clg_part_load_ratio,
                                                              clg_cap_f_of_temp_low_spd,
                                                              clg_energy_input_ratio_f_of_temp_low_spd)

      clg_coil.setName("#{zone.name} PTAC 2spd DX AC Clg Coil")
      clg_coil.setRatedLowSpeedSensibleHeatRatio(OpenStudio::OptionalDouble.new(0.69))
      clg_coil.setBasinHeaterCapacity(10)
      clg_coil.setBasinHeaterSetpointTemperature(2.0)

    elsif cooling_type == 'Single Speed DX AC' # for small hotel

      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.000683770)
      clg_cap_f_of_temp.setCoefficient4y(-0.011042676)
      clg_cap_f_of_temp.setCoefficient5yPOW2(0.000005249)
      clg_cap_f_of_temp.setCoefficient6xTIMESY(-0.000009720)
      clg_cap_f_of_temp.setMinimumValueofx(12.77778)
      clg_cap_f_of_temp.setMaximumValueofx(23.88889)
      clg_cap_f_of_temp.setMinimumValueofy(18.3)
      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.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.000623700)
      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(18.3)
      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)

      clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model,
                                                                 model.alwaysOnDiscreteSchedule,
                                                                 clg_cap_f_of_temp,
                                                                 clg_cap_f_of_flow,
                                                                 clg_energy_input_ratio_f_of_temp,
                                                                 clg_energy_input_ratio_f_of_flow,
                                                                 clg_part_load_ratio)

      clg_coil.setName("#{zone.name} PTAC 1spd DX AC Clg Coil")

    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', "ptac_cooling_type of #{heating_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)
    elsif fan_type == 'Cycling'
      ptac_system.setSupplyAirFanOperatingModeSchedule(always_off)
    end
    ptac_system.addToThermalZone(zone)

    ptacs << ptac_system
  end

  return ptacs
end

#model_add_pthp(model, sys_name, thermal_zones, fan_type, building_type = nil) ⇒ Array<OpenStudio::Model::ZoneHVACPackagedTerminalAirConditioner>

Creates a PTHP system for each zone and adds it to the model.

array of the resulting PTACs.

Parameters:

  • sys_name (String)

    the name of the system, or nil in which case it will be defaulted

  • thermal_zones (String)

    zones to connect to this system

  • fan_type (Double)

    valid choices are ConstantVolume, Cycling

  • building_type (String) (defaults to: nil)

    the building type

Returns:



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
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
3690
3691
3692
3693
3694
3695
3696
3697
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 3515

def model_add_pthp(model,
                   sys_name,
                   thermal_zones,
                   fan_type,
                   building_type = nil)

  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding PTHP for #{zone.name}.")
  end

  # schedule: always off
  always_off = OpenStudio::Model::ScheduleRuleset.new(model)
  always_off.setName('ALWAYS_OFF')
  always_off.defaultDaySchedule.setName('ALWAYS_OFF day')
  always_off.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0.0)
  always_off.setSummerDesignDaySchedule(always_off.defaultDaySchedule)
  always_off.setWinterDesignDaySchedule(always_off.defaultDaySchedule)

  # Make a PTHP for each zone
  pthps = []
  thermal_zones.each do |zone|
    # Zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(14)
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(50.0)
    sizing_zone.setZoneCoolingDesignSupplyAirHumidityRatio(0.008)
    sizing_zone.setZoneHeatingDesignSupplyAirHumidityRatio(0.008)

    # add fan
    fan = nil
    if fan_type == 'ConstantVolume'
      fan = OpenStudio::Model::FanConstantVolume.new(model, model.alwaysOnDiscreteSchedule)
      fan.setName("#{zone.name} PTAC Fan")
      fan_static_pressure_in_h2o = 1.33
      fan_static_pressure_pa = OpenStudio.convert(fan_static_pressure_in_h2o, 'inH_{2}O', 'Pa').get
      fan.setPressureRise(fan_static_pressure_pa)
      fan.setFanEfficiency(0.52)
      fan.setMotorEfficiency(0.8)
    elsif fan_type == 'Cycling'
      fan = OpenStudio::Model::FanOnOff.new(model, model.alwaysOnDiscreteSchedule)
      fan.setName("#{zone.name} PTAC Fan")
      fan_static_pressure_in_h2o = 1.33
      fan_static_pressure_pa = OpenStudio.convert(fan_static_pressure_in_h2o, 'inH_{2}O', 'Pa').get
      fan.setPressureRise(fan_static_pressure_pa)
      fan.setFanEfficiency(0.52)
      fan.setMotorEfficiency(0.8)
    else
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', "ptac_fan_type of #{fan_type} is not recognized.")
    end

    # add heating coil
    htg_cap_f_of_temp = OpenStudio::Model::CurveCubic.new(model)
    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.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.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.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.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)

    htg_coil = OpenStudio::Model::CoilHeatingDXSingleSpeed.new(model,
                                                               model.alwaysOnDiscreteSchedule,
                                                               htg_cap_f_of_temp,
                                                               htg_cap_f_of_flow,
                                                               htg_energy_input_ratio_f_of_temp,
                                                               htg_energy_input_ratio_f_of_flow,
                                                               htg_part_load_fraction)

    htg_coil.setName("#{zone.name} PTHP Htg Coil")

    # add cooling coil
    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)

    clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model,
                                                               model.alwaysOnDiscreteSchedule,
                                                               clg_cap_f_of_temp,
                                                               clg_cap_f_of_flow,
                                                               clg_energy_input_ratio_f_of_temp,
                                                               clg_energy_input_ratio_f_of_flow,
                                                               clg_part_load_ratio)

    clg_coil.setName("#{zone.name} PTHP Clg Coil")
    # clg_coil.setRatedSensibleHeatRatio(0.69)
    # clg_coil.setBasinHeaterCapacity(10)
    # clg_coil.setBasinHeaterSetpointTemperature(2.0)

    # Supplemental heating coil
    supplemental_htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)

    # 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')
    if fan_type == 'ConstantVolume'
      pthp_system.setSupplyAirFanOperatingModeSchedule(model.alwaysOnDiscreteSchedule)
    elsif fan_type == 'Cycling'
      pthp_system.setSupplyAirFanOperatingModeSchedule(always_off)
    end
    pthp_system.addToThermalZone(zone)

    pthps << pthp_system
  end

  return pthps
end

#model_add_pvav(model, sys_name, thermal_zones, hvac_op_sch, oa_damper_sch, electric_reheat = false, hot_water_loop = nil, chilled_water_loop = nil, return_plenum = nil, building_type = nil) ⇒ OpenStudio::Model::AirLoopHVAC

Creates a packaged VAV system 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 but if false, the reheat coils will be served by the hot_water_loop. the supply plenum, or nil, in which case no return plenum will be used.

Parameters:

  • sys_name (String)

    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)

    name of the HVAC operation schedule

  • oa_damper_sch (Double)

    name of the oa damper schedule,

  • electric_reheat (Bool) (defaults to: false)

    if true, this system will have electric reheat coils,

  • hot_water_loop (String) (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 (String) (defaults to: nil)

    chilled water loop to connect cooling coils to. if nil, will be DX cooling.

  • return_plenum (OpenStudio::Model::ThermalZone) (defaults to: nil)

    the zone to attach as

  • building_type (String) (defaults to: nil)

    the building type

Returns:



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
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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 1136

def model_add_pvav(model,
                   sys_name,
                   thermal_zones,
                   hvac_op_sch,
                   oa_damper_sch,
                   electric_reheat = false,
                   hot_water_loop = nil,
                   chilled_water_loop = nil,
                   return_plenum = nil,
                   building_type = nil)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding Packaged VAV for #{thermal_zones.size} zones.")
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "---#{zone.name}")
  end

  # hvac operation schedule
  hvac_op_sch = if hvac_op_sch.nil?
                  model.alwaysOnDiscreteSchedule
                else
                  model_add_schedule(model, hvac_op_sch)
                end

  # oa damper schedule
  oa_damper_sch = if oa_damper_sch.nil?
                    model.alwaysOnDiscreteSchedule
                  else
                    model_add_schedule(model, oa_damper_sch)
                  end

  # Control temps for HW loop
  # will only be used when hot_water_loop is provided.
  hw_temp_f = 180 # HW setpoint 180F
  hw_delta_t_r = 20 # 20F delta-T

  hw_temp_c = OpenStudio.convert(hw_temp_f, 'F', 'C').get
  hw_delta_t_k = OpenStudio.convert(hw_delta_t_r, 'R', 'K').get

  # Control temps used across all air handlers
  sys_dsn_prhtg_temp_f = 44.6 # Design central deck to preheat to 44.6F
  sys_dsn_clg_sa_temp_f = 55 # Design central deck to cool to 55F
  sys_dsn_htg_sa_temp_f = 55 # Central heat to 55F
  zn_dsn_clg_sa_temp_f = 55 # Design VAV box for 55F from central deck
  zn_dsn_htg_sa_temp_f = 122 # Design VAV box to reheat to 122F
  rht_rated_air_in_temp_f = 55 # Reheat coils designed to receive 55F
  rht_rated_air_out_temp_f = 122 # Reheat coils designed to supply 122F
  clg_sa_temp_f = 55 # Central deck clg temp operates at 55F

  sys_dsn_prhtg_temp_c = OpenStudio.convert(sys_dsn_prhtg_temp_f, 'F', 'C').get
  sys_dsn_clg_sa_temp_c = OpenStudio.convert(sys_dsn_clg_sa_temp_f, 'F', 'C').get
  sys_dsn_htg_sa_temp_c = OpenStudio.convert(sys_dsn_htg_sa_temp_f, 'F', 'C').get
  zn_dsn_clg_sa_temp_c = OpenStudio.convert(zn_dsn_clg_sa_temp_f, 'F', 'C').get
  zn_dsn_htg_sa_temp_c = OpenStudio.convert(zn_dsn_htg_sa_temp_f, 'F', 'C').get
  rht_rated_air_in_temp_c = OpenStudio.convert(rht_rated_air_in_temp_f, 'F', 'C').get
  rht_rated_air_out_temp_c = OpenStudio.convert(rht_rated_air_out_temp_f, 'F', 'C').get
  clg_sa_temp_c = OpenStudio.convert(clg_sa_temp_f, 'F', 'C').get

  sa_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  sa_temp_sch.setName("Supply Air Temp - #{clg_sa_temp_f}F")
  sa_temp_sch.defaultDaySchedule.setName("Supply Air Temp - #{clg_sa_temp_f}F Default")
  sa_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), clg_sa_temp_c)

  # Air handler
  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  if sys_name.nil?
    sys_name = "#{thermal_zones.size} Zone PVAV"
    air_loop.setName(sys_name)
  else
    air_loop.setName(sys_name)
  end
  air_loop.setAvailabilitySchedule(hvac_op_sch)

  # Air handler controls
  stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, sa_temp_sch)
  stpt_manager.addToNode(air_loop.supplyOutletNode)
  sizing_system = air_loop.sizingSystem
  # sizing_system.setPreheatDesignTemperature(sys_dsn_prhtg_temp_c)
  sizing_system.setCentralCoolingDesignSupplyAirTemperature(sys_dsn_clg_sa_temp_c)
  sizing_system.setCentralHeatingDesignSupplyAirTemperature(sys_dsn_htg_sa_temp_c)
  sizing_system.setSizingOption('Coincident')
  sizing_system.setAllOutdoorAirinCooling(false)
  sizing_system.setAllOutdoorAirinHeating(false)
  air_loop.setNightCycleControlType('CycleOnAny')

  # Fan
  fan = OpenStudio::Model::FanVariableVolume.new(model, model.alwaysOnDiscreteSchedule)
  fan.setName("#{air_loop.name} Fan")
  fan.addToNode(air_loop.supplyInletNode)

  # Heating coil - depends on whether heating is hot water or electric,
  # which is determined by whether or not a hot water loop is provided.
  if hot_water_loop.nil?
    htg_coil = OpenStudio::Model::CoilHeatingGas.new(model, model.alwaysOnDiscreteSchedule)
    htg_coil.setName("#{air_loop.name} Main Htg Coil")
    htg_coil.addToNode(air_loop.supplyInletNode)
  else
    htg_coil = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule)
    htg_coil.setName("#{air_loop.name} Main Htg Coil")
    htg_coil.setRatedInletWaterTemperature(hw_temp_c)
    htg_coil.setRatedInletAirTemperature(sys_dsn_prhtg_temp_c)
    htg_coil.setRatedOutletWaterTemperature(hw_temp_c - hw_delta_t_k)
    htg_coil.setRatedOutletAirTemperature(rht_rated_air_out_temp_c)
    htg_coil.addToNode(air_loop.supplyInletNode)
    hot_water_loop.addDemandBranchForComponent(htg_coil)
  end

  # Cooling coil
  if chilled_water_loop.nil?
    clg_coil = OpenStudio::Model::CoilCoolingDXTwoSpeed.new(model)
    clg_coil.setName("#{air_loop.name} Clg Coil")
    clg_coil.addToNode(air_loop.supplyInletNode)
  else
    clg_coil = OpenStudio::Model::CoilCoolingWater.new(model, model.alwaysOnDiscreteSchedule)
    clg_coil.setName("#{air_loop.name} Clg Coil")
    clg_coil.addToNode(air_loop.supplyInletNode)
    clg_coil.setHeatExchangerConfiguration('CrossFlow')
    chilled_water_loop.addDemandBranchForComponent(clg_coil)
    clg_coil.controllerWaterCoil.get.setName("#{air_loop.name} Clg Coil Controller")
  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 = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
  oa_intake.setName("#{air_loop.name} OA Sys")
  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)

  # Hook the VAV system to each zone
  thermal_zones.each do |zone|
    # Reheat coil
    rht_coil = nil
    # sys_name.include? "Outpatient F2 F3"  is only for reheat coil of Outpatient Floor2&3
    if electric_reheat || hot_water_loop.nil? || sys_name.include?('Outpatient F2 F3')
      rht_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)
      rht_coil.setName("#{zone.name} Rht Coil")
    else
      rht_coil = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule)
      rht_coil.setName("#{zone.name} Rht Coil")
      rht_coil.setRatedInletWaterTemperature(hw_temp_c)
      rht_coil.setRatedInletAirTemperature(rht_rated_air_in_temp_c)
      rht_coil.setRatedOutletWaterTemperature(hw_temp_c - hw_delta_t_k)
      rht_coil.setRatedOutletAirTemperature(rht_rated_air_out_temp_c)
      hot_water_loop.addDemandBranchForComponent(rht_coil)
    end

    # VAV terminal
    terminal = OpenStudio::Model::AirTerminalSingleDuctVAVReheat.new(model, model.alwaysOnDiscreteSchedule, rht_coil)
    terminal.setName("#{zone.name} VAV Term")
    terminal.setZoneMinimumAirFlowMethod('Constant')
    terminal.setMaximumReheatAirTemperature(rht_rated_air_out_temp_c)
    air_terminal_single_duct_vav_reheat_apply_initial_prototype_damper_position(terminal, building_type, thermal_zone_outdoor_airflow_rate_per_area(zone))
    air_loop.addBranchForZone(zone, terminal.to_StraightComponent)

    unless return_plenum.nil?
      zone.setReturnPlenum(return_plenum)
    end

    # Zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(zn_dsn_clg_sa_temp_c)
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(zn_dsn_htg_sa_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_pvav_pfp_boxes(model, sys_name, thermal_zones, hvac_op_sch, oa_damper_sch, vav_fan_efficiency, vav_fan_motor_efficiency, vav_fan_pressure_rise, chilled_water_loop = nil, building_type = nil) ⇒ OpenStudio::Model::AirLoopHVAC

Creates a packaged VAV system with parallel fan powered boxes 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

Parameters:

  • sys_name (String)

    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)

    name of the HVAC operation schedule

  • oa_damper_sch (Double)

    name of the oa damper schedule,

  • vav_fan_efficiency (Double)

    fan total efficiency, including motor and impeller

  • vav_fan_motor_efficiency (Double)

    fan motor efficiency

  • vav_fan_pressure_rise (Double)

    fan pressure rise, in Pa

  • chilled_water_loop (String) (defaults to: nil)

    chilled water loop to connect cooling coils to. if nil, will be DX cooling.

  • building_type (String) (defaults to: nil)

    the building type

Returns:



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 1325

def model_add_pvav_pfp_boxes(model,
                             sys_name,
                             thermal_zones,
                             hvac_op_sch,
                             oa_damper_sch,
                             vav_fan_efficiency,
                             vav_fan_motor_efficiency,
                             vav_fan_pressure_rise,
                             chilled_water_loop = nil,
                             building_type = nil)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding PVAV with PFP Boxes and Reheat system for #{thermal_zones.size} zones.")
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "---#{zone.name}")
  end

  # hvac operation schedule
  hvac_op_sch = if hvac_op_sch.nil?
                  model.alwaysOnDiscreteSchedule
                else
                  model_add_schedule(model, hvac_op_sch)
                end

  # oa damper schedule
  oa_damper_sch = if oa_damper_sch.nil?
                    model.alwaysOnDiscreteSchedule
                  else
                    model_add_schedule(model, oa_damper_sch)
                  end

  # control temps used across all air handlers
  clg_sa_temp_f = 55.04 # Central deck clg temp 55F
  prehtg_sa_temp_f = 44.6 # Preheat to 44.6F
  preclg_sa_temp_f = 55.04 # Precool to 55F
  htg_sa_temp_f = 55.04 # Central deck htg temp 55F
  rht_sa_temp_f = 104 # VAV box reheat to 104F
  zone_htg_sa_temp_f = 104 # Zone heating design supply air temperature to 104 F

  clg_sa_temp_c = OpenStudio.convert(clg_sa_temp_f, 'F', 'C').get
  prehtg_sa_temp_c = OpenStudio.convert(prehtg_sa_temp_f, 'F', 'C').get
  preclg_sa_temp_c = OpenStudio.convert(preclg_sa_temp_f, 'F', 'C').get
  htg_sa_temp_c = OpenStudio.convert(htg_sa_temp_f, 'F', 'C').get
  rht_sa_temp_c = OpenStudio.convert(rht_sa_temp_f, 'F', 'C').get
  zone_htg_sa_temp_c = OpenStudio.convert(zone_htg_sa_temp_f, 'F', 'C').get

  sa_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  sa_temp_sch.setName("Supply Air Temp - #{clg_sa_temp_f}F")
  sa_temp_sch.defaultDaySchedule.setName("Supply Air Temp - #{clg_sa_temp_f}F Default")
  sa_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), clg_sa_temp_c)

  # air handler
  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  if sys_name.nil?
    air_loop.setName("#{thermal_zones.size} Zone VAV with PFP Boxes and Reheat")
  else
    air_loop.setName(sys_name)
  end
  air_loop.setAvailabilitySchedule(hvac_op_sch)

  sa_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, sa_temp_sch)
  sa_stpt_manager.setName("#{thermal_zones.size} Zone VAV supply air setpoint manager")
  sa_stpt_manager.addToNode(air_loop.supplyOutletNode)

  # air handler controls
  sizing_system = air_loop.sizingSystem
  sizing_system.setPreheatDesignTemperature(prehtg_sa_temp_c)
  sizing_system.setPrecoolDesignTemperature(preclg_sa_temp_c)
  sizing_system.setCentralCoolingDesignSupplyAirTemperature(clg_sa_temp_c)
  sizing_system.setCentralHeatingDesignSupplyAirTemperature(htg_sa_temp_c)
  sizing_system.setSizingOption('Coincident')
  sizing_system.setAllOutdoorAirinCooling(false)
  sizing_system.setAllOutdoorAirinHeating(false)
  sizing_system.setSystemOutdoorAirMethod('ZoneSum')

  # fan
  fan = OpenStudio::Model::FanVariableVolume.new(model, model.alwaysOnDiscreteSchedule)
  fan.setName("#{air_loop.name} Fan")
  fan.setFanEfficiency(vav_fan_efficiency)
  fan.setMotorEfficiency(vav_fan_motor_efficiency)
  fan.setPressureRise(vav_fan_pressure_rise)
  fan.setFanPowerMinimumFlowRateInputMethod('fraction')
  fan.setFanPowerMinimumFlowFraction(0.25)
  fan.addToNode(air_loop.supplyInletNode)
  fan.setEndUseSubcategory('VAV system Fans')

  # heating coil
  htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)
  htg_coil.setName("#{air_loop.name} Main Htg Coil")
  htg_coil.addToNode(air_loop.supplyInletNode)

  # Cooling coil
  if chilled_water_loop.nil?
    clg_coil = OpenStudio::Model::CoilCoolingDXTwoSpeed.new(model)
    clg_coil.setName("#{air_loop.name} Clg Coil")
    clg_coil.addToNode(air_loop.supplyInletNode)
  else
    clg_coil = OpenStudio::Model::CoilCoolingWater.new(model, model.alwaysOnDiscreteSchedule)
    clg_coil.setName("#{air_loop.name} Clg Coil")
    clg_coil.addToNode(air_loop.supplyInletNode)
    clg_coil.setHeatExchangerConfiguration('CrossFlow')
    chilled_water_loop.addDemandBranchForComponent(clg_coil)
    clg_coil.controllerWaterCoil.get.setName("#{air_loop.name} Clg Coil Controller")
  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.setMinimumOutdoorAirSchedule(oa_damper_sch)

  controller_mv = oa_intake_controller.controllerMechanicalVentilation
  controller_mv.setName("#{air_loop.name} Vent Controller")
  controller_mv.setSystemOutdoorAirMethod('VentilationRateProcedure')

  oa_intake = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
  oa_intake.setName("#{air_loop.name} OA Sys")
  oa_intake.addToNode(air_loop.supplyInletNode)

  # The oa system need to be added before setting the night cycle control
  air_loop.setNightCycleControlType('CycleOnAny')

  # hook the VAV system to each zone
  thermal_zones.each do |zone|
    # reheat coil
    rht_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)
    rht_coil.setName("#{zone.name} Rht Coil")

    # terminal fan
    pfp_fan = OpenStudio::Model::FanConstantVolume.new(model, model.alwaysOnDiscreteSchedule)
    pfp_fan.setName("#{zone.name} PFP Term Fan")
    pfp_fan.setPressureRise(300)

    # 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.addBranchForZone(zone, pfp_terminal.to_StraightComponent)

    # Zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setCoolingDesignAirFlowMethod('DesignDay')
    sizing_zone.setHeatingDesignAirFlowMethod('DesignDay')
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(clg_sa_temp_c)
    # sizing_zone.setZoneHeatingDesignSupplyAirTemperature(rht_sa_temp_c)
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(zone_htg_sa_temp_c)
  end

  return air_loop
end

#model_add_refrigeration(model, case_type, cooling_capacity_per_length, length, evaporator_fan_pwr_per_length, lighting_per_length, lighting_sch_name, defrost_pwr_per_length, restocking_sch_name, cop, cop_f_of_t_curve_name, condenser_fan_pwr, condenser_fan_pwr_curve_name, thermal_zone) ⇒ Object

TODO:

Set compressor properties since prototypes use simple

TODO:

fix latent case credit curve setter

TODO:

Should probably use the model_add_refrigeration_walkin

Note:

The legacy prototype IDF files use the simplified

Adds a single refrigerated case connected to a rack composed of a single compressor and a single air-cooled condenser.

Refrigeration:CompressorRack object, but this object is not included in OpenStudio. Instead, a detailed rack with similar performance is added. refrigeration rack instead of detailed and lookups from the spreadsheet instead of hard-coded values.



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.refrigeration.rb', line 16

def model_add_refrigeration(model,
                            case_type,
                            cooling_capacity_per_length,
                            length,
                            evaporator_fan_pwr_per_length,
                            lighting_per_length,
                            lighting_sch_name,
                            defrost_pwr_per_length,
                            restocking_sch_name,
                            cop,
                            cop_f_of_t_curve_name,
                            condenser_fan_pwr,
                            condenser_fan_pwr_curve_name,
                            thermal_zone)

  # Default properties based on the case type
  # case_type = 'Walkin Freezer', 'Display Case'
  case_temp = nil
  latent_heat_ratio = nil
  runtime_fraction = nil
  fraction_antisweat_to_case = nil
  under_case_return_air_fraction = nil
  latent_case_credit_curve_name = nil
  defrost_type = nil
  if case_type == 'Walkin Freezer'
    case_temp = OpenStudio.convert(-9.4, 'F', 'C').get
    latent_heat_ratio = 0.1
    runtime_fraction = 0.4
    fraction_antisweat_to_case = 0.0
    under_case_return_air_fraction = 0.0
    latent_case_credit_curve_name = model_walkin_freezer_latent_case_credit_curve(model)
    defrost_type = 'Electric'
  elsif case_type == 'Display Case'
    case_temp = OpenStudio.convert(35.6, 'F', 'C').get
    latent_heat_ratio = 0.08
    runtime_fraction = 0.85
    fraction_antisweat_to_case = 0.2
    under_case_return_air_fraction = 0.05
    latent_case_credit_curve_name = 'Multi Shelf Vertical Latent Energy Multiplier'
    defrost_type = 'None'
  end

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started Adding Refrigeration System')

  # Defrost schedule
  defrost_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  defrost_sch.setName('Refrigeration Defrost Schedule')
  defrost_sch.defaultDaySchedule.setName('Refrigeration Defrost Schedule Default')
  if case_type == 'Walkin Freezer'
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 11, 0, 0), 0)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 11, 20, 0), 1)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 23, 0, 0), 0)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 23, 20, 0), 1)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
  elsif case_type == 'Display Case'
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 23, 20, 0), 0)
  end

  # Dripdown schedule
  defrost_dripdown_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  defrost_dripdown_sch.setName('Refrigeration Defrost DripDown Schedule')
  defrost_dripdown_sch.defaultDaySchedule.setName('Refrigeration Defrost DripDown Schedule Default')
  defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 11, 0, 0), 0)
  defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 11, 30, 0), 1)
  defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 23, 0, 0), 0)
  defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 23, 30, 0), 1)
  defrost_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)

  # Case
  ref_case = OpenStudio::Model::RefrigerationCase.new(model, defrost_sch)
  ref_case.setName("#{thermal_zone.name} #{case_type}")
  ref_case.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  ref_case.setThermalZone(thermal_zone)
  ref_case.setRatedTotalCoolingCapacityperUnitLength(cooling_capacity_per_length)
  ref_case.setCaseLength(length)
  ref_case.setCaseOperatingTemperature(case_temp)
  ref_case.setStandardCaseFanPowerperUnitLength(evaporator_fan_pwr_per_length)
  ref_case.setOperatingCaseFanPowerperUnitLength(evaporator_fan_pwr_per_length)
  ref_case.setStandardCaseLightingPowerperUnitLength(lighting_per_length)
  ref_case.resetInstalledCaseLightingPowerperUnitLength
  ref_case.setCaseLightingSchedule(model_add_schedule(model, lighting_sch_name))
  ref_case.setHumidityatZeroAntiSweatHeaterEnergy(0)
  unless defrost_type == 'None'
    ref_case.setCaseDefrostType('Electric')
    ref_case.setCaseDefrostPowerperUnitLength(defrost_pwr_per_length)
    ref_case.setCaseDefrostDripDownSchedule(defrost_dripdown_sch)
  end
  ref_case.setUnderCaseHVACReturnAirFraction(under_case_return_air_fraction)
  ref_case.setFractionofAntiSweatHeaterEnergytoCase(fraction_antisweat_to_case)
  ref_case.resetDesignEvaporatorTemperatureorBrineInletTemperature
  ref_case.setRatedAmbientTemperature(OpenStudio.convert(75, 'F', 'C').get)
  ref_case.setRatedLatentHeatRatio(latent_heat_ratio)
  ref_case.setRatedRuntimeFraction(runtime_fraction)
  # TODO: enable ref_case.setLatentCaseCreditCurve(model_add_curve(model, latent_case_credit_curve_name))
  ref_case.setLatentCaseCreditCurve(model_add_curve(model, latent_case_credit_curve_name))
  ref_case.setCaseHeight(0)
  # TODO: setRefrigeratedCaseRestockingSchedule is not working
  ref_case.setRefrigeratedCaseRestockingSchedule(model_add_schedule(model, restocking_sch_name))
  if case_type == 'Walkin Freezer'
    ref_case.setCaseCreditFractionSchedule(case_credit_sch)
  end

  # Compressor
  # TODO set compressor properties since prototypes use simple
  # refrigeration rack instead of detailed
  compressor = OpenStudio::Model::RefrigerationCompressor.new(model)

  # Condenser
  condenser = OpenStudio::Model::RefrigerationCondenserAirCooled.new(model)
  condenser.setRatedFanPower(condenser_fan_pwr)

  # Refrigeration system
  ref_sys = OpenStudio::Model::RefrigerationSystem.new(model)
  ref_sys.addCompressor(compressor)
  ref_sys.addCase(ref_case)
  ref_sys.setRefrigerationCondenser(condenser)
  ref_sys.setSuctionPipingZone(thermal_zone)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Finished adding Refrigeration System')

  return true
end

#model_add_refrigeration_case(model, case_type, case_name, length, thermal_zone) ⇒ Object

Add refrigerated case to the model.

LT Coffin Ice Cream, LT Coffin Frozen Food, LT Reach-In Ice Cream, LT Reach-In Frozen Food, MT Coffin, MT Vertical Open, MT Service, MT Reach-In case is located, and which will be impacted by the case’s thermal load.

Parameters:

  • case_type (String)

    the case type. Valid choices include:

  • case_name (String)

    the name of the case

  • length (Double)

    the length of the case, in m

  • thermal_zone (OpenStudio::Model::ThermalZone)

    the thermal zone where the



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.refrigeration.rb', line 165

def model_add_refrigeration_case(model, case_type, case_name, length, thermal_zone)
  # Get the case properties
  search_criteria = {
    'template' => template,
    'case_type' => case_type
  }

  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_temp = props['case_temp']
  latent_heat_ratio = props['latent_heat_ratio']
  cooling_capacity_per_length = props['cooling_capacity_per_length']
  evaporator_fan_pwr_per_length = props['evap_fan_power_per_length']
  evapo_temp = props['evap_temp']
  lighting_per_length = props['lighting_per_length']
  latent_case_credit_curve_name = props['latent_case_credit_curve_name']
  defrost_pwr_per_length = props['defrost_power_per_length']
  defrost_type = props['defrost_type']
  defrost_correction_type = props['defrost_correction_type']
  defrost_correction_curve_name = props['defrost_correction_curve_name']
  anti_power = props['anti_sweat_power']

  runtime_fraction = 0.85
  restocking_sch_name = 'Always Off'

  # Defrost schedule
  defrost_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  defrost_sch.setName('Refrigeration Defrost Schedule')
  defrost_sch.defaultDaySchedule.setName('Refrigeration Defrost Schedule Default')
  if case_type == 'MT Vertical Open'
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 0, 30, 0), 1)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 6, 0, 0), 0)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 6, 30, 0), 1)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 12, 0, 0), 0)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 12, 30, 0), 1)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 18, 0, 0), 0)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 18, 30, 0), 1)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
  elsif case_type == 'MT Service'
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 0, 40, 0), 1)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 6, 0, 0), 0)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 6, 40, 0), 1)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 12, 0, 0), 0)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 12, 40, 0), 1)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 18, 0, 0), 0)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 18, 40, 0), 1)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
  else # when 'LT Coffin Frozen Food','LT Coffin Ice Cream','LT Reach-In Ice Cream','LT Reach-In Frozen Food',
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 0, 45, 0), 1)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
  end

  # Dripdown schedule
  defrost_dripdown_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  defrost_dripdown_sch.setName('Refrigeration Case Defrost DripDown Schedule')
  defrost_dripdown_sch.defaultDaySchedule.setName('Refrigeration Defrost DripDown Schedule Default')
  if case_type == 'MT Vertical Open'
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 0, 40, 0), 1)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 6, 0, 0), 0)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 6, 40, 0), 1)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 12, 0, 0), 0)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 12, 40, 0), 1)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 18, 0, 0), 0)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 18, 40, 0), 1)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
  elsif case_type == 'MT Service'
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 0, 50, 0), 1)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 6, 0, 0), 0)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 6, 50, 0), 1)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 12, 0, 0), 0)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 12, 50, 0), 1)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 18, 0, 0), 0)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 18, 50, 0), 1)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
  else # when 'LT Coffin Frozen Food','LT Coffin Ice Cream','LT Reach-In Ice Cream','LT Reach-In Frozen Food',
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 0, 55, 0), 1)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
  end

  # Case
  ref_case = OpenStudio::Model::RefrigerationCase.new(model, defrost_sch)
  ref_case.setName(case_name.to_s)
  ref_case.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  ref_case.setThermalZone(thermal_zone)
  ref_case.setRatedTotalCoolingCapacityperUnitLength(cooling_capacity_per_length)
  ref_case.setCaseLength(length)
  ref_case.setCaseOperatingTemperature(case_temp)
  ref_case.setStandardCaseFanPowerperUnitLength(evaporator_fan_pwr_per_length)
  ref_case.setOperatingCaseFanPowerperUnitLength(evaporator_fan_pwr_per_length)
  ref_case.setStandardCaseLightingPowerperUnitLength(lighting_per_length) unless lighting_per_length.nil?
  ref_case.resetInstalledCaseLightingPowerperUnitLength
  ref_case.setCaseLightingSchedule(model.alwaysOnDiscreteSchedule)
  ref_case.setHumidityatZeroAntiSweatHeaterEnergy(anti_power)
  ref_case.setCaseDefrostType(defrost_type)
  ref_case.setCaseDefrostPowerperUnitLength(defrost_pwr_per_length) unless defrost_pwr_per_length.nil?
  ref_case.setCaseDefrostDripDownSchedule(defrost_dripdown_sch)
  ref_case.setUnderCaseHVACReturnAirFraction(0)
  ref_case.setFractionofAntiSweatHeaterEnergytoCase(0.7)
  ref_case.setDesignEvaporatorTemperatureorBrineInletTemperature(evapo_temp)
  ref_case.setRatedAmbientTemperature(OpenStudio.convert(75, 'F', 'C').get)
  ref_case.setRatedLatentHeatRatio(latent_heat_ratio)
  ref_case.setRatedRuntimeFraction(runtime_fraction)
  ref_case.setLatentCaseCreditCurve(model_add_curve(model, latent_case_credit_curve_name))
  ref_case.setCaseHeight(0)
  ref_case.setRefrigeratedCaseRestockingSchedule(model_add_schedule(model, restocking_sch_name))
  ref_case.setDefrostEnergyCorrectionCurveType(defrost_correction_type)
  ref_case.setDefrostEnergyCorrectionCurve(model_add_curve(model, defrost_correction_curve_name))

  length_ft = OpenStudio.convert(length, 'm', 'ft').get
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Added #{length_ft.round} ft #{case_type} called #{case_name} to #{thermal_zone.name}.")

  return ref_case
end

#model_add_refrigeration_compressor(model, compressor_type) ⇒ Object

Adds a refrigeration compressor to the model.



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 413

def model_add_refrigeration_compressor(model, compressor_type)
  # Get the compressor properties
  search_criteria = {
    'template' => template,
    'compressor_type' => compressor_type
  }

  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, sys_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, case_name, length, number_of_cases, and space_names. walkin_type, walkin_name, insulated_floor_area, space_names, and number_of_walkins refrigeration piping is located.

Parameters:

  • compressor_type (String)

    the system temperature range. valid choices are:

  • sys_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



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/prototypes/common/objects/Prototype.refrigeration.rb', line 451

def model_add_refrigeration_system(model,
                                   compressor_type,
                                   sys_name,
                                   cases,
                                   walkins,
                                   thermal_zone)

  # Refrigeration system
  ref_sys = OpenStudio::Model::RefrigerationSystem.new(model)
  ref_sys.setName(sys_name.to_s)
  ref_sys.setSuctionPipingZone(thermal_zone)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Adding #{compressor_type} refrigeration system called #{sys_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

  # Cases
  cooling_cap = 0
  cases.each do |case_|
    for i in 0...case_['number_of_cases']
      zone = model_get_zones_from_spaces_on_system(model, case_)[0]
      ref_case = model_add_refrigeration_case(model,
                                              case_['case_type'],
                                              "#{case_['case_name']} #{i + 1}",
                                              case_['length'],
                                              zone)
      ref_sys.addCase(ref_case)
      cooling_cap += (ref_case.ratedTotalCoolingCapacityperUnitLength * ref_case.caseLength) # calculate total cooling capacity of the cases
    end
  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,
                                                  walkin['walkin_type'],
                                                  "#{walkin['walkin_name']} #{i + 1}",
                                                  walkin['insulated_floor_area'],
                                                  zone)
      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, walkin_type, walkin_name, insulated_floor_area, thermal_zone) ⇒ Object

Adds walkin to the model. The following characteristics are defaulted based on user input.

- Rated coil cooling capacity (function of floor area)
- Rated cooling coil fan power (function of cooling capacity)
- Rated total lighting power (function of floor area)
- Defrost power (function of cooling capacity)

Coil fan power and total lighting power are given for both old (2004, 2007, and 2010) and new (2013) walk-ins. It is assumed that only walk-in freezers have electric defrost while walk-in coolers use off-cycle defrost.

Walk-In Freezer, Walk-In Cooler, Walk-In Cooler Glass Door walkin is located, and which will be impacted by the walkin’s thermal load.

Parameters:

  • walkin_type (String)

    the walkin type. valid choices are:

  • walkin_name (String)

    the name of the walkin

  • insulated_floor_area (Double)

    the floor area of the walkin, in m^2

  • thermal_zone (OpenStudio::Model::ThermalZone)

    the thermal zone where the



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.refrigeration.rb', line 298

def model_add_refrigeration_walkin(model, walkin_type, walkin_name, insulated_floor_area, thermal_zone)
  # Get the walkin properties
  search_criteria = {
    'template' => template,
    'walkin_type' => walkin_type
  }

  props = model_find_object(standards_data['walkin_refrigeration'], search_criteria)
  if props.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Could not find walkin refrigeration properties for: #{search_criteria}.")
    return nil
  end

  # Capacity, defrost, lighting
  cooling_capacity_c2 = props['cooling_capacity_c2']
  cooling_capacity_c1 = props['cooling_capacity_c1']
  cooling_capacity_c0 = props['cooling_capacity_c0']
  operating_temp = props['operating_temp']
  source_temp = props['source_temp']
  defrost_control_type = props['defrost_control_type']
  defrost_type = props['defrost_type']
  defrost_power_mult = props['defrost_power_mult']
  insulated_floor_u = props['insulated_floor_u']
  insulated_surface_u = props['insulated_surface_u']
  stocking_door_u = props['insulated_door_u']
  reachin_door_area_mult = props['reachin_door_area_mult']
  fan_power_mult = props['fan_power_mult']
  lighting_power_mult = props['lighting_power_mult']

  always_off_name = 'Always Off'

  # Calculated properties
  cooling_capacity = cooling_capacity_c2 * (insulated_floor_area ^ 2) + cooling_capacity_c1 * insulated_floor_area + cooling_capacity_c0
  defrost_power = defrost_power_mult * cooling_capacity
  insulated_surface_area = 1.7226 * insulated_floor_area + 28.653
  reachin_door_area = reachin_door_area_mult * insulated_floor_area
  fan_power = fan_power_mult * cooling_capacity
  lighting_power = lighting_power_mult * insulated_floor_area

  # Defrost schedule
  defrost_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  defrost_sch.setName('Refrigeration WaklIn Defrost Schedule')
  defrost_sch.defaultDaySchedule.setName('Refrigeration Defrost Schedule Default')
  if walkin_type == 'Walk-In Freezer'
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 0, 45, 0), 1)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 12, 0, 0), 0)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 12, 45, 0), 1)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
  else
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 1, 0, 0), 1)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 12, 0, 0), 0)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 13, 0, 0), 1)
    defrost_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
  end

  # Dripdown schedule
  defrost_dripdown_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  defrost_dripdown_sch.setName('Refrigeration WalkIn Defrost DripDown Schedule')
  defrost_dripdown_sch.defaultDaySchedule.setName('Refrigeration Defrost DripDown Schedule Default')
  if walkin_type == 'Walk-In Freezer'
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 0, 55, 0), 1)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 12, 0, 0), 0)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 12, 55, 0), 1)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
  else
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 1, 0, 0), 1)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 12, 0, 0), 0)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 13, 0, 0), 1)
    defrost_dripdown_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
  end

  # Door schedule
  walkin_door_sch = 'SuperMarket Walk-In Door Sch'

  # Walk-In
  ref_walkin = OpenStudio::Model::RefrigerationWalkIn.new(model, defrost_sch)
  ref_walkin.setName(walkin_name.to_s)
  ref_walkin.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  ref_walkin.setRatedCoilCoolingCapacity(cooling_capacity)
  ref_walkin.setOperatingTemperature(operating_temp)
  ref_walkin.setRatedCoolingSourceTemperature(source_temp)
  ref_walkin.setRatedTotalHeatingPower(0)
  ref_walkin.setHeatingPowerSchedule(model_add_schedule(model, always_off_name))
  ref_walkin.setRatedCoolingCoilFanPower(fan_power)
  ref_walkin.setRatedCirculationFanPower(0)
  ref_walkin.setRatedTotalLightingPower(lighting_power)
  ref_walkin.setLightingSchedule(model.alwaysOnDiscreteSchedule)
  ref_walkin.setDefrostType(defrost_type)
  ref_walkin.setDefrostControlType(defrost_control_type)
  ref_walkin.setDefrostSchedule(defrost_sch)
  ref_walkin.setDefrostDripDownSchedule(defrost_dripdown_sch)
  ref_walkin.setDefrostPower(defrost_power)
  ref_walkin.setTemperatureTerminationDefrostFractiontoIce(0.7)
  ref_walkin.setRestockingSchedule(model_add_schedule(model, always_off_name))
  ref_walkin.setInsulatedFloorSurfaceArea(insulated_floor_area)
  ref_walkin.setInsulatedFloorUValue(insulated_floor_u)
  ref_walkin.setZoneBoundaryThermalZone(thermal_zone)
  ref_walkin.setZoneBoundaryTotalInsulatedSurfaceAreaFacingZone(insulated_surface_area)
  ref_walkin.setZoneBoundaryInsulatedSurfaceUValueFacingZone(insulated_surface_u)
  ref_walkin.setZoneBoundaryAreaofGlassReachInDoorsFacingZone(reachin_door_area)
  ref_walkin.setZoneBoundaryHeightofGlassReachInDoorsFacingZone(1.83)
  ref_walkin.setZoneBoundaryGlassReachInDoorUValueFacingZone(2.27)
  ref_walkin.setZoneBoundaryAreaofStockingDoorsFacingZone(3.3)
  ref_walkin.setZoneBoundaryHeightofStockingDoorsFacingZone(2.1)
  ref_walkin.setZoneBoundaryStockingDoorUValueFacingZone(stocking_door_u)
  ref_walkin.setZoneBoundaryStockingDoorOpeningScheduleFacingZone(model_add_schedule(model, walkin_door_sch))

  insulated_floor_area_ft2 = OpenStudio.convert(insulated_floor_area, 'm^2', 'ft^2').get
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Added #{insulated_floor_area_ft2.round} ft2 #{walkin_type} called #{walkin_name} 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



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
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2176

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.")
    sch_ruleset = OpenStudio::Model::ScheduleRuleset.new(model)
    sch_ruleset.setName("NOT ACTUALLY #{schedule_name}")
    return sch_ruleset
  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_split_ac(model, sys_name, thermal_zones, hvac_op_sch, oa_damper_sch, fan_type, heating_type, supplemental_heating_type, cooling_type, building_type = nil) ⇒ OpenStudio::Model::AirLoopHVAC

Creates a split DX AC system for each zone 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 Single Speed DX AC, Single Speed Heat Pump

Parameters:

  • sys_name (String)

    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)

    name of the HVAC operation schedule

  • oa_damper_sch (Double)

    name of the oa damper schedule,

  • fan_type (Double)

    valid choices are ConstantVolume, Cycling

  • heating_type (Double)

    valid choices are Gas, Single Speed Heat Pump

  • supplemental_heating_type (Double)

    valid choices are Electric, Gas

  • cooling_type (String)

    valid choices are Two Speed DX AC,a

  • building_type (String) (defaults to: nil)

    the building type

Returns:



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
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
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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 2786

def model_add_split_ac(model,
                       sys_name,
                       thermal_zones,
                       hvac_op_sch,
                       oa_damper_sch,
                       fan_type,
                       heating_type,
                       supplemental_heating_type,
                       cooling_type,
                       building_type = nil)

  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding split DX AC for #{zone.name}.")
  end

  # hvac operation schedule
  hvac_op_sch = if hvac_op_sch.nil?
                  model.alwaysOnDiscreteSchedule
                else
                  model_add_schedule(model, hvac_op_sch)
                end

  # oa damper schedule
  oa_damper_sch = if oa_damper_sch.nil?
                    model.alwaysOnDiscreteSchedule
                  else
                    model_add_schedule(model, oa_damper_sch)
                  end

  # OA_controller Maximum OA Fraction schedule
  econ_max_oa_frac_sch = model_add_schedule(model, 'HotelSmall SAC_Econ_MaxOAFrac_Sch')

  # Make a SAC for each group of thermal zones
  parts = []
  space_type_names = []
  thermal_zones.each do |zone|
    name = zone.name
    parts << name.get
    # get space types
    zone.spaces.each do |space|
      space_type_name = space.spaceType.get.standardsSpaceType.get
      space_type_names << space_type_name
    end

    # Zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(14)
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(50.0)
    sizing_zone.setZoneCoolingDesignSupplyAirHumidityRatio(0.008)
    sizing_zone.setZoneHeatingDesignSupplyAirHumidityRatio(0.008)
  end
  thermal_zone_name = parts.join(' - ')

  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  air_loop.setName("#{thermal_zone_name} SAC")
  air_loop.setAvailabilitySchedule(hvac_op_sch)

  # When an air_loop is contructed, its constructor creates a sizing:system object
  # the default sizing:system contstructor makes a system:sizing object
  # appropriate for a multizone VAV system
  # this systems is a constant volume system with no VAV terminals,
  # and therfore needs different default settings
  air_loop_sizing = air_loop.sizingSystem # TODO units
  air_loop_sizing.setTypeofLoadtoSizeOn('Sensible')
  air_loop_sizing.autosizeDesignOutdoorAirFlowRate
  air_loop_sizing.setMinimumSystemAirFlowRatio(1.0)
  air_loop_sizing.setPreheatDesignTemperature(7.0)
  air_loop_sizing.setPreheatDesignHumidityRatio(0.008)
  air_loop_sizing.setPrecoolDesignTemperature(11)
  air_loop_sizing.setPrecoolDesignHumidityRatio(0.008)
  air_loop_sizing.setCentralCoolingDesignSupplyAirTemperature(12)
  air_loop_sizing.setCentralHeatingDesignSupplyAirTemperature(50)
  air_loop_sizing.setSizingOption('NonCoincident')
  air_loop_sizing.setAllOutdoorAirinCooling(false)
  air_loop_sizing.setAllOutdoorAirinHeating(false)
  air_loop_sizing.setCentralCoolingDesignSupplyAirHumidityRatio(0.008)
  air_loop_sizing.setCentralHeatingDesignSupplyAirHumidityRatio(0.0080)
  air_loop_sizing.setCoolingDesignAirFlowMethod('DesignDay')
  air_loop_sizing.setCoolingDesignAirFlowRate(0.0)
  air_loop_sizing.setHeatingDesignAirFlowMethod('DesignDay')
  air_loop_sizing.setHeatingDesignAirFlowRate(0.0)
  air_loop_sizing.setSystemOutdoorAirMethod('ZoneSum')

  # Add a setpoint manager single zone reheat to control the
  # supply air temperature based on the needs of this zone
  controlzone = thermal_zones[0]
  setpoint_mgr_single_zone_reheat = OpenStudio::Model::SetpointManagerSingleZoneReheat.new(model)
  setpoint_mgr_single_zone_reheat.setControlZone(controlzone)

  # Fan
  fan = nil
  if fan_type == 'ConstantVolume'
    fan = OpenStudio::Model::FanConstantVolume.new(model, model.alwaysOnDiscreteSchedule)
    fan.setName("#{thermal_zone_name} SAC Fan")
    fan_static_pressure_in_h2o = 2.5
    fan_static_pressure_pa = OpenStudio.convert(fan_static_pressure_in_h2o, 'inH_{2}O', 'Pa').get
    fan.setPressureRise(fan_static_pressure_pa)
    fan.setFanEfficiency(0.56) # get the average of four fans
    fan.setMotorEfficiency(0.86) # get the average of four fans
  elsif fan_type == 'Cycling'
    fan = OpenStudio::Model::FanOnOff.new(model, model.alwaysOnDiscreteSchedule)
    fan.setName("#{thermal_zone_name} SAC Fan")
    fan_static_pressure_in_h2o = 2.5
    fan_static_pressure_pa = OpenStudio.convert(fan_static_pressure_in_h2o, 'inH_{2}O', 'Pa').get
    fan.setPressureRise(fan_static_pressure_pa)
    fan.setFanEfficiency(0.53625)
    fan.setMotorEfficiency(0.825)
  end

  # Heating Coil
  htg_coil = nil
  if heating_type == 'Gas'
    htg_coil = OpenStudio::Model::CoilHeatingGas.new(model, model.alwaysOnDiscreteSchedule)
    htg_coil.setName("#{thermal_zone_name} SAC Gas Htg Coil")
    htg_coil.setGasBurnerEfficiency(0.8)
    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)
    htg_part_load_fraction_correlation.setCoefficient4xPOW3(0)
    htg_part_load_fraction_correlation.setMinimumValueofx(0)
    htg_part_load_fraction_correlation.setMaximumValueofx(1)
    htg_coil.setPartLoadFractionCorrelationCurve(htg_part_load_fraction_correlation)
  elsif heating_type == 'Single Speed Heat Pump'
    htg_cap_f_of_temp = OpenStudio::Model::CurveCubic.new(model)
    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.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.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.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.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)

    htg_coil = OpenStudio::Model::CoilHeatingDXSingleSpeed.new(model,
                                                               model.alwaysOnDiscreteSchedule,
                                                               htg_cap_f_of_temp,
                                                               htg_cap_f_of_flow,
                                                               htg_energy_input_ratio_f_of_temp,
                                                               htg_energy_input_ratio_f_of_flow,
                                                               htg_part_load_fraction)

    htg_coil.setName("#{thermal_zone_name} SAC HP Htg Coil")
  end

  # Supplemental Heating Coil
  supplemental_htg_coil = nil
  if supplemental_heating_type == 'Electric'
    supplemental_htg_coil = OpenStudio::Model::CoilHeatingGas.new(model, model.alwaysOnDiscreteSchedule)
    supplemental_htg_coil.setName("#{thermal_zone_name} PSZ-AC Electric Backup Htg Coil")
  elsif supplemental_heating_type == 'Gas'
    supplemental_htg_coil = OpenStudio::Model::CoilHeatingGas.new(model, model.alwaysOnDiscreteSchedule)
    supplemental_htg_coil.setName("#{thermal_zone_name} PSZ-AC Gas Backup Htg Coil")
  end

  # Cooling Coil
  clg_coil = nil
  if cooling_type == 'Two Speed DX AC'

    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 = OpenStudio::Model::CoilCoolingDXTwoSpeed.new(model,
                                                            model.alwaysOnDiscreteSchedule,
                                                            clg_cap_f_of_temp,
                                                            clg_cap_f_of_flow,
                                                            clg_energy_input_ratio_f_of_temp,
                                                            clg_energy_input_ratio_f_of_flow,
                                                            clg_part_load_ratio,
                                                            clg_cap_f_of_temp_low_spd,
                                                            clg_energy_input_ratio_f_of_temp_low_spd)

    clg_coil.setName("#{thermal_zone_name} SAC 2spd DX AC Clg Coil")
    clg_coil.setRatedLowSpeedSensibleHeatRatio(OpenStudio::OptionalDouble.new(0.69))
    clg_coil.setBasinHeaterCapacity(10)
    clg_coil.setBasinHeaterSetpointTemperature(2.0)

  elsif cooling_type == 'Single Speed DX AC'

    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)

    clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model,
                                                               model.alwaysOnDiscreteSchedule,
                                                               clg_cap_f_of_temp,
                                                               clg_cap_f_of_flow,
                                                               clg_energy_input_ratio_f_of_temp,
                                                               clg_energy_input_ratio_f_of_flow,
                                                               clg_part_load_ratio)

    clg_coil.setName("#{thermal_zone_name} SAC 1spd DX AC Clg Coil")

  elsif cooling_type == 'Single Speed Heat Pump'

    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)

    clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model,
                                                               model.alwaysOnDiscreteSchedule,
                                                               clg_cap_f_of_temp,
                                                               clg_cap_f_of_flow,
                                                               clg_energy_input_ratio_f_of_temp,
                                                               clg_energy_input_ratio_f_of_flow,
                                                               clg_part_load_ratio)

    clg_coil.setName("#{thermal_zone_name} SAC 1spd DX HP Clg Coil")
    # clg_coil.setRatedSensibleHeatRatio(0.69)
    # clg_coil.setBasinHeaterCapacity(10)
    # clg_coil.setBasinHeaterSetpointTemperature(2.0)

  end

  oa_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
  oa_controller.setName("#{thermal_zone_name} SAC OA Sys Controller")
  oa_controller.setMinimumOutdoorAirSchedule(oa_damper_sch)
  oa_controller.autosizeMinimumOutdoorAirFlowRate
  oa_controller.setMaximumFractionofOutdoorAirSchedule(econ_max_oa_frac_sch)
  oa_system = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_controller)
  oa_system.setName("#{thermal_zone_name} SAC OA Sys")

  # Add the components to the air loop
  # in order from closest to zone to furthest from zone
  supply_inlet_node = air_loop.supplyInletNode

  # Add the fan
  unless fan.nil?
    fan.addToNode(supply_inlet_node)
  end

  # Add the supplemental heating coil
  unless supplemental_htg_coil.nil?
    supplemental_htg_coil.addToNode(supply_inlet_node)
  end

  # Add the heating coil
  unless htg_coil.nil?
    htg_coil.addToNode(supply_inlet_node)
  end

  # Add the cooling coil
  unless clg_coil.nil?
    clg_coil.addToNode(supply_inlet_node)
  end

  setpoint_mgr_single_zone_reheat.setMinimumSupplyAirTemperature(OpenStudio.convert(55.4, 'F', 'C').get)
  setpoint_mgr_single_zone_reheat.setMaximumSupplyAirTemperature(OpenStudio.convert(113, 'F', 'C').get)

  setpoint_mgr_single_zone_reheat.addToNode(air_loop.supplyOutletNode)

  # Add the OA system
  oa_system.addToNode(supply_inlet_node)

  # Create a diffuser and attach the zone/diffuser pair to the air loop
  thermal_zones.each do |zone|
    diffuser = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule)
    diffuser.setName("#{zone.name} SAC Diffuser")
    air_loop.addBranchForZone(zone, diffuser.to_StraightComponent)
  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
# 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
  unless prototype_input['main_water_heater_volume'].nil?
    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',
                                         nil,
                                         OpenStudio.convert(prototype_input['main_service_water_temperature'], 'F', 'C').get,
                                         prototype_input['main_service_water_pump_head'],
                                         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,
                                         building_type)
    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,
                               building_type)
      end
    elsif building_type == 'LargeOfficeDetail' && 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,
                               building_type)
      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'],
                                           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,
                                           building_type)

        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,
                               building_type)
      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,
                             building_type)

    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 = model_find_object(standards_data['space_types'], 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, model_get_lookup_name(building_type),
                                          climate_zone,
                                          main_swh_loop,
                                          space_type_name,
                                          space_name,
                                          space_multiplier)
          if !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
  unless prototype_input['booster_water_heater_volume'].nil?

    # 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,
                                             building_type)

    # 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,
                                   building_type)

  end

  # Add the laundry water heater, if specified
  unless prototype_input['laundry_water_heater_volume'].nil?

    # 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'],
                                          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,
                                          building_type)

    # 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,
                           building_type)

  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, building_type = nil) ⇒ 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)
  • building_type (String) (defaults to: nil)

    the building type

Returns:



4268
4269
4270
4271
4272
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
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
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
4407
4408
4409
4410
4411
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4268

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,
                          building_type = nil)

  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 = OpenStudio::Model::ScheduleTypeLimits.new(model)
  temp_sch_type_limits.setName('Temperature Schedule Type Limits')
  temp_sch_type_limits.setLowerLimitValue(0.0)
  temp_sch_type_limits.setUpperLimitValue(100.0)
  temp_sch_type_limits.setNumericType('Continuous')
  temp_sch_type_limits.setUnitType('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 = OpenStudio::Model::ScheduleRuleset.new(model)
  swh_temp_sch.setName("Service Water Booster Temp - #{swh_temp_f}F")
  swh_temp_sch.defaultDaySchedule.setName("Service Water Booster Temp - #{swh_temp_f}F Default")
  swh_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), swh_temp_c)
  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::PumpConstantSpeed.new(model)
  swh_pump.setName('Booster Water Loop Pump')
  swh_pump_head_press_pa = 0.0 # As if there is no circulation pump
  swh_pump.setRatedPumpHead(swh_pump_head_press_pa)
  swh_pump.setMotorEfficiency(1)
  swh_pump.setPumpControlType('Intermittent')
  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)

  if booster_water_heater_thermal_zone.nil?
    # Assume the water heater is indoors at 70F for now
    default_water_heater_ambient_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
    default_water_heater_ambient_temp_sch.setName('Water Heater Ambient Temp Schedule - 70F')
    default_water_heater_ambient_temp_sch.defaultDaySchedule.setName('Water Heater Ambient Temp Schedule - 70F Default')
    default_water_heater_ambient_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), OpenStudio.convert(70, 'F', 'C').get)
    default_water_heater_ambient_temp_sch.setScheduleTypeLimits(temp_sch_type_limits)
    water_heater.setAmbientTemperatureIndicator('Schedule')
    water_heater.setAmbientTemperatureSchedule(default_water_heater_ambient_temp_sch)
  else
    water_heater.setAmbientTemperatureIndicator('ThermalZone')
    water_heater.setAmbientTemperatureThermalZone booster_water_heater_thermal_zone
  end

  water_heater.setMaximumTemperatureLimit(OpenStudio.convert(180, 'F', 'C').get)
  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.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

  if water_heater_fuel == 'Electricity'
    water_heater.setHeaterFuelType('Electricity')
    water_heater.setOffCycleParasiticFuelType('Electricity')
    water_heater.setOnCycleParasiticFuelType('Electricity')
  elsif water_heater_fuel == 'Natural Gas'
    water_heater.setHeaterFuelType('Gas')
    water_heater.setOffCycleParasiticFuelType('Gas')
    water_heater.setOnCycleParasiticFuelType('Gas')
  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)

  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, building_type = nil) ⇒ 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,

  • building_type (String) (defaults to: nil)

    the building type

Returns:

  • (OpenStudio::Model::WaterUseEquipment)


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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4428

def model_add_swh_end_uses(model,
                           use_name,
                           swh_loop,
                           peak_flowrate,
                           flowrate_schedule,
                           water_use_temperature,
                           space_name,
                           building_type = nil)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding water fixture to #{swh_loop.name}.")

  # 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
  frac_sensible = 0.2
  frac_latent = 0.05
  # 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)
  water_use_sensible_frac_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  water_use_sensible_frac_sch.setName("Fraction Sensible - #{frac_sensible}")
  water_use_sensible_frac_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), frac_sensible)
  water_use_latent_frac_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  water_use_latent_frac_sch.setName("Fraction Latent - #{frac_latent}")
  water_use_latent_frac_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), frac_latent)
  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.capitalize} Service Water Use Def #{rated_flow_rate_gal_per_min.round(2)}gal/min")
  # Target mixed water temperature
  mixed_water_temp_f = OpenStudio.convert(water_use_temperature, 'C', 'F').get
  mixed_water_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  mixed_water_temp_sch.setName("Mixed Water At Faucet Temp - #{mixed_water_temp_f.round}F")
  mixed_water_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), OpenStudio.convert(mixed_water_temp_f, 'F', 'C').get)
  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.capitalize} Service Water Use #{rated_flow_rate_gal_per_min.round(2)}gal/min")
  else
    water_fixture.setName("#{space_name.capitalize} Service Water Use #{rated_flow_rate_gal_per_min.round(2)}gal/min")
  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
  swh_loop.addDemandBranchForComponent(swh_connection)

  return water_fixture
end

#model_add_swh_end_uses_by_space(model, building_type, climate_zone, swh_loop, space_type_name, space_name, space_multiplier = nil, is_flow_per_area = true) ⇒ 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.



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4496

def model_add_swh_end_uses_by_space(model, building_type, climate_zone, swh_loop, space_type_name, space_name, space_multiplier = nil, is_flow_per_area = true)
  # find the specific space_type properties from standard.json
  search_criteria = {
    'template' => template,
    'building_type' => building_type,
    'space_type' => space_type_name
  }
  data = model_find_object(standards_data['space_types'], search_criteria)
  if data.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.Model.Model', "Could not find space type for: #{search_criteria}.")
    return nil
  end
  space = model.getSpaceByName(space_name)
  space = space.get
  space_area = OpenStudio.convert(space.floorArea, 'm^2', 'ft^2').get # ft2
  if space_multiplier.nil?
    space_multiplier = 1
  end

  # 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 = 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)
  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(rated_flow_rate_m3_per_s)
  water_fixture_def.setName("#{space_name.capitalize} Service Water Use Def #{rated_flow_rate_gal_per_min.round(2)}gal/min")
  # Target mixed water temperature
  mixed_water_temp_c = data['service_water_heating_target_temperature']
  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, data['service_water_heating_schedule'])
  water_fixture.setFlowRateFractionSchedule(schedule)
  water_fixture.setName("#{space_name.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) 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, sys_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, building_type = nil) ⇒ OpenStudio::Model::PlantLoop

Creates a service water heating loop.

zones to place water heater in. If nil, will be assumed in 70F air for heat loss. service water pump motor efficiency, as decimal. Valid choices are Natural Gas, Electricity rate of the water heater, in W the resulting service water loop.

Parameters:

  • sys_name (String)

    the name of the system, or nil in which case it will be defaulted

  • water_heater_thermal_zone (OpenStudio::Model::ThermalZone)
  • 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)
  • 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.

  • parasitic_fuel_consumption_rate (Double)

    the parasitic fuel consumption

  • building_type (String) (defaults to: nil)

    the building type

Returns:



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
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
4113
4114
4115
4116
4117
4118
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4018

def model_add_swh_loop(model,
                       sys_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,
                       building_type = nil)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding service water loop')

  # Service water heating loop
  service_water_loop = OpenStudio::Model::PlantLoop.new(model)
  service_water_loop.setMinimumLoopTemperature(10)
  service_water_loop.setMaximumLoopTemperature(60)

  if sys_name.nil?
    service_water_loop.setName('Service Water Loop')
  else
    service_water_loop.setName(sys_name)
  end

  # Temperature schedule type limits
  temp_sch_type_limits = OpenStudio::Model::ScheduleTypeLimits.new(model)
  temp_sch_type_limits.setName('Temperature Schedule Type Limits')
  temp_sch_type_limits.setLowerLimitValue(0.0)
  temp_sch_type_limits.setUpperLimitValue(100.0)
  temp_sch_type_limits.setNumericType('Continuous')
  temp_sch_type_limits.setUnitType('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 # 9F delta-T
  swh_delta_t_k = OpenStudio.convert(swh_delta_t_r, 'R', 'K').get
  swh_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  swh_temp_sch.setName("Service Water Loop Temp - #{swh_temp_f.round}F")
  swh_temp_sch.defaultDaySchedule.setName("Service Water Loop Temp - #{swh_temp_f.round}F Default")
  swh_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), swh_temp_c)
  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)

  # Service water heating pump
  swh_pump_head_press_pa = service_water_pump_head
  swh_pump_motor_efficiency = service_water_pump_motor_efficiency
  if swh_pump_head_press_pa.nil?
    # As if there is no circulation pump
    swh_pump_head_press_pa = 0.001
    swh_pump_motor_efficiency = 1
  end

  swh_pump = case model_swh_pump_type(model, building_type)
             when 'ConstantSpeed'
               OpenStudio::Model::PumpConstantSpeed.new(model)
             when 'VariableSpeed'
               OpenStudio::Model::PumpVariableSpeed.new(model)
             end
  swh_pump.setName('Service Water Loop Pump')
  swh_pump.setRatedPumpHead(swh_pump_head_press_pa.to_f)
  swh_pump.setMotorEfficiency(swh_pump_motor_efficiency)
  swh_pump.setPumpControlType('Intermittent')
  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,
                                        building_type)

  service_water_loop.addSupplyBranchForComponent(water_heater)

  # 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_inlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_inlet_pipe.addToNode(service_water_loop.demandInletNode)
  demand_outlet_pipe = OpenStudio::Model::PipeAdiabatic.new(model)
  demand_outlet_pipe.addToNode(service_water_loop.demandOutletNode)

  return service_water_loop
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 = model_find_object(standards_data['exterior_lighting'], 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} 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} 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} 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} 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} drie 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. Wil 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_swh(model, trust_effective_num_spaces = false, 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:

  • trust_effective_num_spaces (Bool) (defaults to: false)
  • fuel (String) (defaults to: nil)

    (gas, electric, nil) nil is smart

  • pipe_insul_in (Double) (defaults to: nil)
  • circulating (String) (defaults to: nil)

    (circulating, noncirculating, nil) nil is smart

Returns:

  • (Array)

    hot water loops



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.swh.rb', line 229

def model_add_typical_swh(model, trust_effective_num_spaces = false, 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)

  # add temperate schedules to hash so they can be shared across water use equipment
  water_use_def_schedules = {} # key is temp C value is schedule

  # 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.standardsSpaceType.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
    stds_space_type = space_type.standardsSpaceType.get

    # lookup space_type_properties
    space_type_properties = space_type_get_standards_data(space_type)
    gal_hr_per_area = space_type_properties['service_water_heating_peak_flow_per_area']
    gal_hr_peak_flow_rate = space_type_properties['service_water_heating_peak_flow_rate']
    flow_rate_fraction_schedule = model_add_schedule(model, space_type_properties['service_water_heating_schedule'])
    service_water_temperature_si = space_type_properties['service_water_heating_target_temperature']
    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_si = space_type_hash[space_type][:floor_area]
    floor_area_ip = OpenStudio.convert(floor_area_si, 'm^2', 'ft^2').get

    # next if no service water heating demand
    next unless gal_hr_per_area.to_f > 0.0 || gal_hr_peak_flow_rate.to_f > 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

    if (stds_bldg_type == 'MidriseApartment' && stds_space_type.include?('Apartment')) || stds_bldg_type == 'StripMall'
      num_units = space_type_hash[space_type][:num_units].round
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Adding dedicated water heating fpr #{num_units} #{space_type.name} units, each with max flow rate of #{gal_hr_peak_flow_rate} gal/hr per.")

      # add water use equipment definition
      water_use_equip_def = OpenStudio::Model::WaterUseEquipmentDefinition.new(model)
      water_use_equip_def.setName("#{space_type.name} SWH def")
      peak_flow_rate_si = OpenStudio.convert(gal_hr_peak_flow_rate, 'gal/hr', 'm^3/s').get
      water_use_equip_def.setPeakFlowRate(peak_flow_rate_si)
      target_temp = service_water_temperature_si # in spreadsheet in si, no conversion needed unless that changes
      name = "#{target_temp} C"
      if water_use_def_schedules.key?(name)
        target_temperature_sch = water_use_def_schedules[name]
      else
        target_temperature_sch = model_add_constant_schedule_ruleset(model, target_temp, name)
        water_use_def_schedules[name] = target_temperature_sch
      end
      water_use_equip_def.setTargetTemperatureSchedule(target_temperature_sch)
      name = "#{service_water_fraction_sensible} Fraction"
      if water_use_def_schedules.key?(name)
        service_water_fraction_sensible_sch = water_use_def_schedules[name]
      else
        service_water_fraction_sensible_sch = model_add_constant_schedule_ruleset(model, service_water_fraction_sensible, name)
        water_use_def_schedules[name] = service_water_fraction_sensible_sch
      end
      water_use_equip_def.setSensibleFractionSchedule(service_water_fraction_sensible_sch)
      name = "#{service_water_fraction_latent} Fraction"
      if water_use_def_schedules.key?(name)
        service_water_fraction_latent_sch = water_use_def_schedules[name]
      else
        service_water_fraction_latent_sch = model_add_constant_schedule_ruleset(model, service_water_fraction_sensible, name)
        water_use_def_schedules[name] = service_water_fraction_latent_sch
      end
      water_use_equip_def.setLatentFractionSchedule(service_water_fraction_latent_sch)

      # add water use equipment, connection, and loop for each unit
      num_units.times do |i|
        # add water use equipment
        water_use_equip = OpenStudio::Model::WaterUseEquipment.new(water_use_equip_def)
        water_use_equip.setFlowRateFractionSchedule(flow_rate_fraction_schedule)
        water_use_equip.setName("#{space_type.name} SWH #{i + 1}")

        # add water use connection
        water_use_connection = OpenStudio::Model::WaterUseConnections.new(model)
        water_use_connection.addWaterUseEquipment(water_use_equip)
        water_use_connection.setName("#{space_type.name} WUC #{i + 1}")

        # gather inputs for add_swh_loop
        # default fuel, capacity, and volume from Table A.1. Water Heating Equipment Enhancements to ASHRAE Standard 90.1 Prototype Building Models
        # temperature, pump head, motor efficiency, and parasitic load from Prototype Inputs
        sys_name = "#{space_type.name} Service Water Loop #{i + 1}"
        water_heater_thermal_zone = nil
        service_water_temperature = service_water_temperature_si
        service_water_pump_head = 0.01
        service_water_pump_motor_efficiency = 1.0
        water_heater_fuel = if fuel.nil?
                              'Electric'
                            else
                              fuel
                            end
        if stds_bldg_type == 'MidriseApartment'
          water_heater_capacity = OpenStudio.convert(15.0, 'kBtu/hr', 'W').get
          water_heater_volume = OpenStudio.convert(50.0, 'gal', 'm^3').get
          parasitic_fuel_consumption_rate = 0.0 # Prototype inputs has 87.75W but prototype IDF's use 0
        else # StripMall
          water_heater_capacity = OpenStudio.convert(12.0, 'kBtu/hr', 'W').get
          water_heater_volume = OpenStudio.convert(40.0, 'gal', 'm^3').get
          parasitic_fuel_consumption_rate = 173.0
        end

        # make loop for each unit and add on water use equipment
        unit_hot_water_loop = model_add_swh_loop(model,
                                                 sys_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,
                                                 stds_bldg_type)

        # Connect the water use connection to the SWH loop
        unit_hot_water_loop.addDemandBranchForComponent(water_use_connection)

        # apply efficiency to hot water heater
        unit_hot_water_loop.supplyComponents.sort.each do |component|
          next if component.to_WaterHeaterMixed.empty?
          component = component.to_WaterHeaterMixed.get
          water_heater_mixed_apply_efficiency(component)
        end

        # add to list of systems
        swh_systems << unit_hot_water_loop
      end

    elsif stds_space_type.include?('Kitchen') || stds_space_type.include?('Laundry')
      gal_hr_peak_flow_rate = gal_hr_per_area * floor_area_ip
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Adding dedicated water heating for #{space_type.name} space type with max flow rate of #{gal_hr_peak_flow_rate.round} gal/hr.")

      # add water use equipment definition
      water_use_equip_def = OpenStudio::Model::WaterUseEquipmentDefinition.new(model)
      water_use_equip_def.setName("#{space_type.name} SWH def")
      peak_flow_rate_si = OpenStudio.convert(gal_hr_peak_flow_rate, 'gal/hr', 'm^3/s').get
      water_use_equip_def.setPeakFlowRate(peak_flow_rate_si)
      target_temp = service_water_temperature_si # in spreadsheet in si, no conversion needed unless that changes
      name = "#{target_temp} C"
      if water_use_def_schedules.key?(name)
        target_temperature_sch = water_use_def_schedules[name]
      else
        target_temperature_sch = model_add_constant_schedule_ruleset(model, target_temp, name)
        water_use_def_schedules[name] = target_temperature_sch
      end
      water_use_equip_def.setTargetTemperatureSchedule(target_temperature_sch)
      name = "#{service_water_fraction_sensible} Fraction"
      if water_use_def_schedules.key?(name)
        service_water_fraction_sensible_sch = water_use_def_schedules[name]
      else
        service_water_fraction_sensible_sch = model_add_constant_schedule_ruleset(model, service_water_fraction_sensible, name)
        water_use_def_schedules[name] = service_water_fraction_sensible_sch
      end
      water_use_equip_def.setSensibleFractionSchedule(service_water_fraction_sensible_sch)
      name = "#{service_water_fraction_latent} Fraction"
      if water_use_def_schedules.key?(name)
        service_water_fraction_latent_sch = water_use_def_schedules[name]
      else
        service_water_fraction_latent_sch = model_add_constant_schedule_ruleset(model, service_water_fraction_sensible, name)
        water_use_def_schedules[name] = service_water_fraction_latent_sch
      end
      water_use_equip_def.setLatentFractionSchedule(service_water_fraction_latent_sch)

      # add water use equipment
      water_use_equip = OpenStudio::Model::WaterUseEquipment.new(water_use_equip_def)
      water_use_equip.setFlowRateFractionSchedule(flow_rate_fraction_schedule)
      water_use_equip.setName("#{space_type.name} SWH")

      # add water use connection
      water_use_connection = OpenStudio::Model::WaterUseConnections.new(model)
      water_use_connection.addWaterUseEquipment(water_use_equip)
      water_use_connection.setName("#{space_type.name} WUC")

      # gather inputs for add_swh_loop
      sys_name = "#{space_type.name} Service Water Loop"
      water_heater_thermal_zone = nil
      water_heater_temp_si = 60.0 # C
      service_water_pump_head = 0.01
      service_water_pump_motor_efficiency = 1.0
      water_heater_fuel = if fuel.nil?
                            'Gas'
                          else
                            fuel
                          end

      # find_water_heater_capacity_volume_and_parasitic
      water_use_equipment_array = [water_use_equip]
      water_heater_sizing = model_find_water_heater_capacity_volume_and_parasitic(model, water_use_equipment_array)
      water_heater_capacity = water_heater_sizing[:water_heater_capacity]
      water_heater_volume = water_heater_sizing[:water_heater_volume]
      parasitic_fuel_consumption_rate = water_heater_sizing[:parasitic_fuel_consumption_rate]

      # make loop for each unit and add on water use equipment
      dedicated_hot_water_loop = model_add_swh_loop(model,
                                                    sys_name,
                                                    water_heater_thermal_zone,
                                                    water_heater_temp_si,
                                                    service_water_pump_head,
                                                    service_water_pump_motor_efficiency,
                                                    water_heater_capacity,
                                                    water_heater_volume,
                                                    water_heater_fuel,
                                                    parasitic_fuel_consumption_rate,
                                                    stds_bldg_type)

      # Connect the water use connection to the SWH loop
      dedicated_hot_water_loop.addDemandBranchForComponent(water_use_connection)

      # find water heater
      dedicated_hot_water_loop.supplyComponents.sort.each do |component|
        next if component.to_WaterHeaterMixed.empty?
        water_heater = component.to_WaterHeaterMixed.get

        # apply efficiency to hot water heater
        water_heater_mixed_apply_efficiency(water_heater)
      end

      # add to list of systems
      swh_systems << dedicated_hot_water_loop

      # add booster to all kitchens except for QuickServiceRestaurant (QuickServiceRestaurant assumed to use chemicals instead of hotter water)
      # boosters are all 6 gal elec but heating capacity varies from 3 to 19 (kBtu/hr) for prototype buildings
      if stds_space_type.include?('Kitchen') && stds_bldg_type != 'QuickServiceRestaurant'

        # find_water_heater_capacity_volume_and_parasitic
        water_use_equipment_array = [water_use_equip]
        inlet_temp_ip = OpenStudio.convert(service_water_temperature_si, 'C', 'F').get # pre-booster temp
        outlet_temp_ip = inlet_temp_ip + 40.0
        peak_flow_fraction = 0.6 # assume 60% of peak for dish washing
        water_heater_sizing = model_find_water_heater_capacity_volume_and_parasitic(model, water_use_equipment_array, pipe_hash = {}, 1.0, 1.0, inlet_temp_ip, outlet_temp_ip, peak_flow_fraction)
        water_heater_capacity = water_heater_sizing[:water_heater_capacity]

        # gather additional inputs for add_swh_booster
        water_heater_volume = OpenStudio.convert(6, 'gal', 'm^3').get
        water_heater_fuel = 'Electric'
        booster_water_temperature = 82.22 # C
        parasitic_fuel_consumption_rate = 0.0
        booster_water_heater_thermal_zone = nil

        # add_swh_booster
        booster_service_water_loop = model_add_swh_booster(model,
                                                           dedicated_hot_water_loop,
                                                           water_heater_capacity,
                                                           water_heater_volume,
                                                           water_heater_fuel,
                                                           booster_water_temperature,
                                                           parasitic_fuel_consumption_rate,
                                                           booster_water_heater_thermal_zone,
                                                           stds_bldg_type)

        # find water heater
        booster_service_water_loop.supplyComponents.sort.each do |component|
          next if component.to_WaterHeaterMixed.empty?
          water_heater = component.to_WaterHeaterMixed.get

          # apply efficiency to hot water heater
          water_heater_mixed_apply_efficiency(water_heater)
        end

        # rename booster loop
        booster_service_water_loop.setName("#{space_type.name} Booster Service Water Loop")
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Adding Electric Booster water heater for #{space_type.name} on a loop named #{booster_service_water_loop.name}.")

      end

    else # store water use equip by building type in hash so can add general building type hot water loop

      gal_hr_peak_flow_rate = gal_hr_per_area * floor_area_ip
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Adding water heating for #{space_type.name} space type with max flow rate of #{gal_hr_peak_flow_rate.round} gal/hr on a shared loop.")

      # add water use equipment definition
      water_use_equip_def = OpenStudio::Model::WaterUseEquipmentDefinition.new(model)
      water_use_equip_def.setName("#{space_type.name} SWH def")
      peak_flow_rate_si = OpenStudio.convert(gal_hr_peak_flow_rate, 'gal/hr', 'm^3/s').get
      water_use_equip_def.setPeakFlowRate(peak_flow_rate_si)
      target_temp = service_water_temperature_si # in spreadsheet in si, no conversion needed unless that changes
      name = "#{target_temp} C"
      if water_use_def_schedules.key?(name)
        target_temperature_sch = water_use_def_schedules[name]
      else
        target_temperature_sch = model_add_constant_schedule_ruleset(model, target_temp, name)
        water_use_def_schedules[name] = target_temperature_sch
      end
      water_use_equip_def.setTargetTemperatureSchedule(target_temperature_sch)
      name = "#{service_water_fraction_sensible} Fraction"
      if water_use_def_schedules.key?(name)
        service_water_fraction_sensible_sch = water_use_def_schedules[name]
      else
        service_water_fraction_sensible_sch = model_add_constant_schedule_ruleset(model, service_water_fraction_sensible, name)
        water_use_def_schedules[name] = service_water_fraction_sensible_sch
      end
      water_use_equip_def.setSensibleFractionSchedule(service_water_fraction_sensible_sch)
      name = "#{service_water_fraction_latent} Fraction"
      if water_use_def_schedules.key?(name)
        service_water_fraction_latent_sch = water_use_def_schedules[name]
      else
        service_water_fraction_latent_sch = model_add_constant_schedule_ruleset(model, service_water_fraction_sensible, name)
        water_use_def_schedules[name] = service_water_fraction_latent_sch
      end
      water_use_equip_def.setLatentFractionSchedule(service_water_fraction_latent_sch)

      # add water use equipment
      water_use_equip = OpenStudio::Model::WaterUseEquipment.new(water_use_equip_def)
      water_use_equip.setFlowRateFractionSchedule(flow_rate_fraction_schedule)
      water_use_equip.setName("#{space_type.name} SWH")

      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

    end
  end

  # get building floor area and effective number of stories
  bldg_floor_area = 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|
    # gather inputs for add_swh_loop
    sys_name = "#{stds_bldg_type} Shared Service Water Loop"
    water_heater_thermal_zone = nil
    water_heater_temp_si = 60.0

    # find pump values
    # Table A.2 in PrototypeModelEnhancements_2014_0.pdf shows 10ft on everything except SecondarySchool which has 11.4ft
    # todo - if SmallOffice then shouldn't have circulating pump
    if ['Office', 'PrimarySchool', 'Outpatient', 'Hospital', 'SmallHotel', 'LargeHotel', 'FullServiceRestaurant', 'HighriseApartment'].include?(stds_bldg_type)
      service_water_pump_head = OpenStudio.convert(10.0, 'ftH_{2}O', 'Pa').get
      service_water_pump_motor_efficiency = 0.3
      if circulating.nil? then
        irculating = true
      end
      if pipe_insul_in.nil? then
        pipe_insul_in = 0.5
      end
    elsif ['SecondarySchool'].include?(stds_bldg_type)
      service_water_pump_head = OpenStudio.convert(11.4, 'ftH_{2}O', 'Pa').get
      service_water_pump_motor_efficiency = 0.3
      if circulating.nil? then
        irculating = true
      end
      if pipe_insul_in.nil? then
        pipe_insul_in = 0.5
      end
    else # values for non-circulating pump
      service_water_pump_head = 0.01
      service_water_pump_motor_efficiency = 1.0
      if circulating.nil? then
        irculating = false
      end
      if pipe_insul_in.nil? then
        pipe_insul_in = 0.0
      end
    end

    # 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 = if fuel.nil?
                          'Gas'
                        else
                          fuel
                        end

    bldg_type_floor_area = 0.0
    space_type_hash.sort.each do |space_type, hash|
      next if hash[:stds_bldg_type] != stds_bldg_type
      bldg_type_floor_area += hash[:floor_area]
    end

    # inputs for find_water_heater_capacity_volume_and_parasitic
    pipe_hash = {}
    pipe_hash[:floor_area] = bldg_type_floor_area
    pipe_hash[:effective_num_stories] = bldg_effective_num_stories * (bldg_type_floor_area / bldg_floor_area)
    pipe_hash[:circulating] = circulating
    pipe_hash[:insulation_thickness] = pipe_insul_in

    # find_water_heater_capacity_volume_and_parasitic
    water_heater_sizing = model_find_water_heater_capacity_volume_and_parasitic(model, water_use_equipment_array, pipe_hash)
    water_heater_capacity = water_heater_sizing[:water_heater_capacity]
    water_heater_volume = water_heater_sizing[:water_heater_volume]
    parasitic_fuel_consumption_rate = water_heater_sizing[:parasitic_fuel_consumption_rate]
    if parasitic_fuel_consumption_rate > 0
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Adding parasitic loss for #{stds_bldg_type} loop of #{parasitic_fuel_consumption_rate.round} Btu/hr.")
    end

    # make loop for each unit and add on water use equipment
    shared_hot_water_loop = model_add_swh_loop(model,
                                               sys_name,
                                               water_heater_thermal_zone,
                                               water_heater_temp_si,
                                               service_water_pump_head,
                                               service_water_pump_motor_efficiency,
                                               water_heater_capacity,
                                               water_heater_volume,
                                               water_heater_fuel,
                                               parasitic_fuel_consumption_rate,
                                               stds_bldg_type)

    # find water heater
    shared_hot_water_loop.supplyComponents.sort.each do |component|
      next if component.to_WaterHeaterMixed.empty?
      water_heater = component.to_WaterHeaterMixed.get

      # apply efficiency to hot water heater
      water_heater_mixed_apply_efficiency(water_heater)
    end

    # loop through water use equipment
    water_use_equipment_array.sort.each do |water_use_equip|
      # add water use connection
      water_use_connection = OpenStudio::Model::WaterUseConnections.new(model)
      water_use_connection.addWaterUseEquipment(water_use_equip)
      water_use_connection.setName(water_use_equip.name.get.gsub('SWH', 'WUC'))

      # Connect the water use connection to the SWH loop
      shared_hot_water_loop.addDemandBranchForComponent(water_use_connection)
    end

    # add to list of systems
    swh_systems << shared_hot_water_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, sys_name, thermal_zones, hvac_op_sch, fan_control_type, fan_pressure_rise, heating_type, hot_water_loop = nil, building_type = nil) ⇒ Array<OpenStudio::Model::ZoneHVACUnitHeater>

Creates a unit heater for each zone and adds it to the model.

or nil in which case will be defaulted to always on NaturalGas, Electricity, DistrictHeating array of the resulting unit heaters.

Parameters:

  • sys_name (String)

    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)

    name of the HVAC operation schedule

  • fan_control_type (Double)

    valid choices are Continuous, OnOff, Cycling

  • fan_pressure_rise (Double)

    fan pressure rise, in Pa

  • heating_type (Double)

    valid choices are

  • building_type (String) (defaults to: nil)

    the building type

Returns:



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 3712

def model_add_unitheater(model,
                         sys_name,
                         thermal_zones,
                         hvac_op_sch,
                         fan_control_type,
                         fan_pressure_rise,
                         heating_type,
                         hot_water_loop = nil,
                         building_type = nil)

  # Control temps for HW loop
  # will only be used when hot_water_loop is provided.
  hw_temp_f = 180 # HW setpoint 180F
  hw_delta_t_r = 20 # 20F delta-T
  htg_sa_temp_f = 100 # 100F air from unit heaters
  zn_temp_f = 60 # 60F entering unit heater from zone

  hw_temp_c = OpenStudio.convert(hw_temp_f, 'F', 'C').get
  hw_delta_t_k = OpenStudio.convert(hw_delta_t_r, 'R', 'K').get
  htg_sa_temp_c = OpenStudio.convert(htg_sa_temp_f, 'F', 'C').get
  zn_temp_c = OpenStudio.convert(zn_temp_f, 'F', 'C').get

  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding split unit heater for #{zone.name}.")
  end

  # hvac operation schedule
  hvac_op_sch = if hvac_op_sch.nil?
                  model.alwaysOnDiscreteSchedule
                else
                  model_add_schedule(model, hvac_op_sch)
                end

  # Make a unit heater for each zone
  unit_heaters = []
  thermal_zones.each do |zone|
    # Zone sizing
    sizing_zone = zone.sizingZone
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(14)
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(50.0)
    sizing_zone.setZoneCoolingDesignSupplyAirHumidityRatio(0.008)
    sizing_zone.setZoneHeatingDesignSupplyAirHumidityRatio(0.008)

    # add fan
    fan = OpenStudio::Model::FanConstantVolume.new(model, hvac_op_sch)
    fan.setName("#{zone.name} UnitHeater Fan")
    fan.setPressureRise(fan_pressure_rise)
    fan.setFanEfficiency(0.53625)
    fan.setMotorEfficiency(0.825)

    # add heating coil
    htg_coil = nil
    if heating_type == 'NaturalGas' || heating_type == 'Gas'
      htg_coil = OpenStudio::Model::CoilHeatingGas.new(model, hvac_op_sch)
      htg_coil.setName("#{zone.name} UnitHeater Gas Htg Coil")
    elsif heating_type == 'Electricity' || heating_type == 'Electric'
      htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, hvac_op_sch)
      htg_coil.setName("#{zone.name} UnitHeater Electric Htg Coil")
    elsif heating_type == 'DistrictHeating' && !hot_water_loop.nil?
      htg_coil = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule)
      htg_coil.setName("#{zone.name} UnitHeater Water Htg Coil")
      htg_coil.setRatedInletWaterTemperature(hw_temp_c)
      htg_coil.setRatedInletAirTemperature(zn_temp_c)
      htg_coil.setRatedOutletWaterTemperature(hw_temp_c - hw_delta_t_k)
      htg_coil.setRatedOutletAirTemperature(htg_sa_temp_c)
      hot_water_loop.addDemandBranchForComponent(htg_coil)
    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

    unit_heater = OpenStudio::Model::ZoneHVACUnitHeater.new(model,
                                                            hvac_op_sch,
                                                            fan,
                                                            htg_coil)
    unit_heater.setName("#{zone.name} UnitHeater")
    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, sys_name, chilled_water_loop, thermal_zones, hvac_op_sch, oa_damper_sch, vav_fan_efficiency, vav_fan_motor_efficiency, vav_fan_pressure_rise, building_type = nil) ⇒ OpenStudio::Model::AirLoopHVAC

or nil in which case will be defaulted to always on or nil in which case will be defaulted to always open

Parameters:

  • sys_name (String)

    the name of the system, or nil in which case it will be defaulted

  • chilled_water_loop (String)

    chilled water loop to connect cooling coil to

  • thermal_zones (String)

    zones to connect to this system

  • hvac_op_sch (String)

    name of the HVAC operation schedule

  • oa_damper_sch (Double)

    name of the oa damper schedule,

  • vav_fan_efficiency (Double)

    fan total efficiency, including motor and impeller

  • vav_fan_motor_efficiency (Double)

    fan motor efficiency

  • vav_fan_pressure_rise (Double)

    fan pressure rise, in Pa

  • building_type (String) (defaults to: nil)

    the building type

Returns:



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 969

def model_add_vav_pfp_boxes(model,
                            sys_name,
                            chilled_water_loop,
                            thermal_zones,
                            hvac_op_sch,
                            oa_damper_sch,
                            vav_fan_efficiency,
                            vav_fan_motor_efficiency,
                            vav_fan_pressure_rise,
                            building_type = nil)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding VAV with PFP Boxes and Reheat system for #{thermal_zones.size} zones.")
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "---#{zone.name}")
  end

  # hvac operation schedule
  hvac_op_sch = if hvac_op_sch.nil?
                  model.alwaysOnDiscreteSchedule
                else
                  model_add_schedule(model, hvac_op_sch)
                end

  # oa damper schedule
  oa_damper_sch = if oa_damper_sch.nil?
                    model.alwaysOnDiscreteSchedule
                  else
                    model_add_schedule(model, oa_damper_sch)
                  end

  # control temps used across all air handlers
  clg_sa_temp_f = 55.04 # Central deck clg temp 55F
  prehtg_sa_temp_f = 44.6 # Preheat to 44.6F
  preclg_sa_temp_f = 55.04 # Precool to 55F
  htg_sa_temp_f = 55.04 # Central deck htg temp 55F
  rht_sa_temp_f = 104 # VAV box reheat to 104F
  zone_htg_sa_temp_f = 104 # Zone heating design supply air temperature to 104 F

  clg_sa_temp_c = OpenStudio.convert(clg_sa_temp_f, 'F', 'C').get
  prehtg_sa_temp_c = OpenStudio.convert(prehtg_sa_temp_f, 'F', 'C').get
  preclg_sa_temp_c = OpenStudio.convert(preclg_sa_temp_f, 'F', 'C').get
  htg_sa_temp_c = OpenStudio.convert(htg_sa_temp_f, 'F', 'C').get
  rht_sa_temp_c = OpenStudio.convert(rht_sa_temp_f, 'F', 'C').get
  zone_htg_sa_temp_c = OpenStudio.convert(zone_htg_sa_temp_f, 'F', 'C').get

  sa_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  sa_temp_sch.setName("Supply Air Temp - #{clg_sa_temp_f}F")
  sa_temp_sch.defaultDaySchedule.setName("Supply Air Temp - #{clg_sa_temp_f}F Default")
  sa_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), clg_sa_temp_c)

  # air handler
  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  if sys_name.nil?
    air_loop.setName("#{thermal_zones.size} Zone VAV with PFP Boxes and Reheat")
  else
    air_loop.setName(sys_name)
  end
  air_loop.setAvailabilitySchedule(hvac_op_sch)

  sa_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, sa_temp_sch)
  sa_stpt_manager.setName("#{thermal_zones.size} Zone VAV supply air setpoint manager")
  sa_stpt_manager.addToNode(air_loop.supplyOutletNode)

  # air handler controls
  sizing_system = air_loop.sizingSystem
  sizing_system.setPreheatDesignTemperature(prehtg_sa_temp_c)
  sizing_system.setPrecoolDesignTemperature(preclg_sa_temp_c)
  sizing_system.setCentralCoolingDesignSupplyAirTemperature(clg_sa_temp_c)
  sizing_system.setCentralHeatingDesignSupplyAirTemperature(htg_sa_temp_c)
  sizing_system.setSizingOption('Coincident')
  sizing_system.setAllOutdoorAirinCooling(false)
  sizing_system.setAllOutdoorAirinHeating(false)
  sizing_system.setSystemOutdoorAirMethod('ZoneSum')

  # fan
  fan = OpenStudio::Model::FanVariableVolume.new(model, model.alwaysOnDiscreteSchedule)
  fan.setName("#{air_loop.name} Fan")
  fan.setFanEfficiency(vav_fan_efficiency)
  fan.setMotorEfficiency(vav_fan_motor_efficiency)
  fan.setPressureRise(vav_fan_pressure_rise)
  fan.setFanPowerMinimumFlowRateInputMethod('fraction')
  fan.setFanPowerMinimumFlowFraction(0.25)
  fan.addToNode(air_loop.supplyInletNode)
  fan.setEndUseSubcategory('VAV system Fans')

  # heating coil
  htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)
  htg_coil.setName("#{air_loop.name} Htg Coil")
  htg_coil.addToNode(air_loop.supplyInletNode)

  # cooling coil
  clg_coil = OpenStudio::Model::CoilCoolingWater.new(model, model.alwaysOnDiscreteSchedule)
  clg_coil.setName("#{air_loop.name} Clg Coil")
  clg_coil.addToNode(air_loop.supplyInletNode)
  clg_coil.setHeatExchangerConfiguration('CrossFlow')
  chilled_water_loop.addDemandBranchForComponent(clg_coil)
  clg_coil.controllerWaterCoil.get.setName("#{air_loop.name} Clg Coil Controller")

  # 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)

  controller_mv = oa_intake_controller.controllerMechanicalVentilation
  controller_mv.setName("#{air_loop.name} Vent Controller")
  controller_mv.setSystemOutdoorAirMethod('VentilationRateProcedure')

  oa_intake = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
  oa_intake.setName("#{air_loop.name} OA Sys")
  oa_intake.addToNode(air_loop.supplyInletNode)

  # The oa system need to be added before setting the night cycle control
  air_loop.setNightCycleControlType('CycleOnAny')

  # hook the VAV system to each zone
  thermal_zones.each do |zone|
    # reheat coil
    rht_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)
    rht_coil.setName("#{zone.name} Rht Coil")

    # terminal fan
    pfp_fan = OpenStudio::Model::FanConstantVolume.new(model, model.alwaysOnDiscreteSchedule)
    pfp_fan.setName("#{zone.name} PFP Term Fan")
    pfp_fan.setPressureRise(300)

    # 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.addBranchForZone(zone, pfp_terminal.to_StraightComponent)

    # Zone sizing
    # TODO Create general logic for cooling airflow method.
    # Large hotel uses design day with limit, school uses design day.
    sizing_zone = zone.sizingZone
    sizing_zone.setCoolingDesignAirFlowMethod('DesignDay')
    sizing_zone.setHeatingDesignAirFlowMethod('DesignDay')
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(clg_sa_temp_c)
    # sizing_zone.setZoneHeatingDesignSupplyAirTemperature(rht_sa_temp_c)
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(zone_htg_sa_temp_c)
  end

  return air_loop
end

#model_add_vav_reheat(model, sys_name, hot_water_loop, chilled_water_loop, thermal_zones, hvac_op_sch, oa_damper_sch, vav_fan_efficiency, vav_fan_motor_efficiency, vav_fan_pressure_rise, return_plenum, reheat_type = 'Water', building_type = nil) ⇒ OpenStudio::Model::AirLoopHVAC

or nil in which case will be defaulted to always on or nil in which case will be defaulted to always open the supply plenum, or nil, in which case no return plenum will be used.

Parameters:

  • sys_name (String)

    the name of the system, or nil in which case it will be defaulted

  • hot_water_loop (String)

    hot water loop to connect heating and reheat coils to

  • chilled_water_loop (String)

    chilled water loop to connect cooling coil to

  • thermal_zones (String)

    zones to connect to this system

  • hvac_op_sch (String)

    name of the HVAC operation schedule

  • oa_damper_sch (Double)

    name of the oa damper schedule,

  • vav_fan_efficiency (Double)

    fan total efficiency, including motor and impeller

  • vav_fan_motor_efficiency (Double)

    fan motor efficiency

  • vav_fan_pressure_rise (Double)

    fan pressure rise, in Pa

  • return_plenum (OpenStudio::Model::ThermalZone)

    the zone to attach as

  • reheat_type (String) (defaults to: 'Water')

    valid options are NaturalGas, Electricity, Water, nil (no heat)

  • building_type (String) (defaults to: nil)

    the building type

Returns:



726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 726

def model_add_vav_reheat(model,
                         sys_name,
                         hot_water_loop,
                         chilled_water_loop,
                         thermal_zones,
                         hvac_op_sch,
                         oa_damper_sch,
                         vav_fan_efficiency,
                         vav_fan_motor_efficiency,
                         vav_fan_pressure_rise,
                         return_plenum,
                         reheat_type = 'Water',
                         building_type = nil)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding VAV system for #{thermal_zones.size} zones.")
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "---#{zone.name}")
  end

  hw_temp_f = 180 # HW setpoint 180F
  hw_delta_t_r = 20 # 20F delta-T
  hw_temp_c = OpenStudio.convert(hw_temp_f, 'F', 'C').get
  hw_delta_t_k = OpenStudio.convert(hw_delta_t_r, 'R', 'K').get

  # hvac operation schedule
  hvac_op_sch = if hvac_op_sch.nil?
                  model.alwaysOnDiscreteSchedule
                else
                  model_add_schedule(model, hvac_op_sch)
                end

  # oa damper schedule
  oa_damper_sch = if oa_damper_sch.nil?
                    model.alwaysOnDiscreteSchedule
                  else
                    model_add_schedule(model, oa_damper_sch)
                  end

  # control temps used across all air handlers
  clg_sa_temp_f = 55.04 # Central deck clg temp 55F
  prehtg_sa_temp_f = 44.6 # Preheat to 44.6F
  preclg_sa_temp_f = 55.04 # Precool to 55F
  htg_sa_temp_f = 55.04 # Central deck htg temp 55F
  if building_type == 'LargeHotel'
    htg_sa_temp_f = 62 # Central deck htg temp 55F
  end
  zone_htg_sa_temp_f = 104 # Zone heating design supply air temperature to 104 F
  rht_sa_temp_f = if building_type == 'LargeHotel'
                    90 # VAV box reheat to 90F for large hotel
                  else
                    104 # VAV box reheat to 104F
                  end

  clg_sa_temp_c = OpenStudio.convert(clg_sa_temp_f, 'F', 'C').get
  prehtg_sa_temp_c = OpenStudio.convert(prehtg_sa_temp_f, 'F', 'C').get
  preclg_sa_temp_c = OpenStudio.convert(preclg_sa_temp_f, 'F', 'C').get
  htg_sa_temp_c = OpenStudio.convert(htg_sa_temp_f, 'F', 'C').get
  rht_sa_temp_c = OpenStudio.convert(rht_sa_temp_f, 'F', 'C').get
  zone_htg_sa_temp_c = OpenStudio.convert(zone_htg_sa_temp_f, 'F', 'C').get
  sa_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
  sa_temp_sch.setName("Supply Air Temp - #{clg_sa_temp_f}F")
  sa_temp_sch.defaultDaySchedule.setName("Supply Air Temp - #{clg_sa_temp_f}F Default")
  sa_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), clg_sa_temp_c)

  air_flow_ratio = if building_type == 'Hospital'
                     if sys_name == 'VAV_PATRMS'
                       0.5
                     elsif sys_name == 'VAV_1' || sys_name == 'VAV_2'
                       0.3
                     else
                       1
                     end
                   else
                     0.3
                   end

  # air handler
  air_loop = OpenStudio::Model::AirLoopHVAC.new(model)
  if sys_name.nil?
    air_loop.setName("#{thermal_zones.size} Zone VAV")
  else
    air_loop.setName(sys_name)
  end
  air_loop.setAvailabilitySchedule(hvac_op_sch)

  sa_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, sa_temp_sch)
  sa_stpt_manager.setName("#{thermal_zones.size} Zone VAV supply air setpoint manager")
  sa_stpt_manager.addToNode(air_loop.supplyOutletNode)

  # air handler controls
  sizing_system = air_loop.sizingSystem
  sizing_system.setMinimumSystemAirFlowRatio(air_flow_ratio)
  # sizing_system.setPreheatDesignTemperature(htg_oa_tdb_c)
  sizing_system.setPrecoolDesignTemperature(preclg_sa_temp_c)
  sizing_system.setCentralCoolingDesignSupplyAirTemperature(clg_sa_temp_c)
  sizing_system.setCentralHeatingDesignSupplyAirTemperature(htg_sa_temp_c)
  if building_type == 'Hospital'
    if sys_name == 'VAV_2' || sys_name == 'VAV_1'
      sizing_system.setSizingOption('Coincident')
    else
      sizing_system.setSizingOption('NonCoincident')
    end
  else
    sizing_system.setSizingOption('Coincident')
  end
  sizing_system.setAllOutdoorAirinCooling(false)
  sizing_system.setAllOutdoorAirinHeating(false)
  sizing_system.setSystemOutdoorAirMethod('ZoneSum')

  # fan
  fan = OpenStudio::Model::FanVariableVolume.new(model, model.alwaysOnDiscreteSchedule)
  fan.setName("#{air_loop.name} Fan")
  fan.setFanEfficiency(vav_fan_efficiency)
  fan.setMotorEfficiency(vav_fan_motor_efficiency)
  fan.setPressureRise(vav_fan_pressure_rise)
  fan.setFanPowerMinimumFlowRateInputMethod('fraction')
  fan.setFanPowerMinimumFlowFraction(0.25)
  fan.addToNode(air_loop.supplyInletNode)
  fan.setEndUseSubcategory('VAV system Fans')

  # heating coil
  if hot_water_loop.nil?
    htg_coil = OpenStudio::Model::CoilHeatingGas.new(model, model.alwaysOnDiscreteSchedule)
    htg_coil.setName("#{air_loop.name} Main Htg Coil")
    htg_coil.addToNode(air_loop.supplyInletNode)
  else
    htg_coil = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule)
    htg_coil.addToNode(air_loop.supplyInletNode)
    hot_water_loop.addDemandBranchForComponent(htg_coil)
    htg_coil.setName("#{air_loop.name} Main Htg Coil")
    htg_coil.controllerWaterCoil.get.setName("#{air_loop.name} Main Htg Coil Controller")
    htg_coil.setRatedInletWaterTemperature(hw_temp_c)
    htg_coil.setRatedOutletWaterTemperature(hw_temp_c - hw_delta_t_k)
    htg_coil.setRatedInletAirTemperature(htg_sa_temp_c)
    htg_coil.setRatedOutletAirTemperature(rht_sa_temp_c)
  end

  # cooling coil
  clg_coil = OpenStudio::Model::CoilCoolingWater.new(model, model.alwaysOnDiscreteSchedule)
  clg_coil.setName("#{air_loop.name} Clg Coil")
  clg_coil.addToNode(air_loop.supplyInletNode)
  clg_coil.setHeatExchangerConfiguration('CrossFlow')
  chilled_water_loop.addDemandBranchForComponent(clg_coil)
  clg_coil.controllerWaterCoil.get.setName("#{air_loop.name} Clg Coil Controller")

  # 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)

  controller_mv = oa_intake_controller.controllerMechanicalVentilation
  controller_mv.setName("#{air_loop.name} Vent Controller")
  controller_mv.setSystemOutdoorAirMethod('VentilationRateProcedure')

  if building_type == 'LargeHotel'
    oa_intake_controller.setEconomizerControlType('DifferentialEnthalpy')
    oa_intake_controller.resetMaximumFractionofOutdoorAirSchedule
    oa_intake_controller.resetEconomizerMinimumLimitDryBulbTemperature
  end

  oa_intake = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
  oa_intake.setName("#{air_loop.name} OA Sys")
  oa_intake.addToNode(air_loop.supplyInletNode)

  # The oa system need to be added before setting the night cycle control
  air_loop.setNightCycleControlType('CycleOnAny')

  # hook the VAV system to each zone
  thermal_zones.each do |zone|
    # reheat coil
    rht_coil = nil
    case reheat_type
    when 'NaturalGas'
      rht_coil = OpenStudio::Model::CoilHeatingGas.new(model, model.alwaysOnDiscreteSchedule)
      rht_coil.setName("#{zone.name} Rht Coil")
    when 'Electricity'
      rht_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)
      rht_coil.setName("#{zone.name} Rht Coil")
    when 'Water'
      rht_coil = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule)
      rht_coil.setName("#{zone.name} Rht Coil")
      rht_coil.setRatedInletWaterTemperature(hw_temp_c)
      rht_coil.setRatedInletAirTemperature(htg_sa_temp_c)
      rht_coil.setRatedOutletWaterTemperature(hw_temp_c - hw_delta_t_k)
      rht_coil.setRatedOutletAirTemperature(rht_sa_temp_c)
      hot_water_loop.addDemandBranchForComponent(rht_coil)
    when nil
      # Zero-capacity, always-off electric heating coil
      rht_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOffDiscreteSchedule)
      rht_coil.setName("#{zone.name} No Reheat")
      rht_coil.setNominalCapacity(0)
    end

    # vav terminal
    terminal = OpenStudio::Model::AirTerminalSingleDuctVAVReheat.new(model, model.alwaysOnDiscreteSchedule, rht_coil)
    terminal.setName("#{zone.name} VAV Term")
    terminal.setZoneMinimumAirFlowMethod('Constant')
    air_terminal_single_duct_vav_reheat_apply_initial_prototype_damper_position(terminal, building_type, thermal_zone_outdoor_airflow_rate_per_area(zone))
    terminal.setMaximumFlowFractionDuringReheat(0.5)
    terminal.setMaximumReheatAirTemperature(rht_sa_temp_c)
    air_loop.addBranchForZone(zone, terminal.to_StraightComponent)

    # Zone sizing
    # TODO Create general logic for cooling airflow method.
    # Large hotel uses design day with limit, school uses design day.
    sizing_zone = zone.sizingZone
    if building_type == 'SecondarySchool'
      sizing_zone.setCoolingDesignAirFlowMethod('DesignDay')
    else
      sizing_zone.setCoolingDesignAirFlowMethod('DesignDayWithLimit')
    end
    sizing_zone.setHeatingDesignAirFlowMethod('DesignDay')
    sizing_zone.setZoneCoolingDesignSupplyAirTemperature(clg_sa_temp_c)
    sizing_zone.setZoneHeatingDesignSupplyAirTemperature(zone_htg_sa_temp_c)

    unless return_plenum.nil?
      zone.setReturnPlenum(return_plenum)
    end
  end

  # Set the damper action based on the template.
  air_loop_hvac_apply_vav_damper_action(air_loop)

  return air_loop
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, building_type = nil) ⇒ OpenStudio::Model::WaterHeaterMixed

Creates a water heater and attaches it to the supplied service water heating loop.

Natural Gas, Electricity fuel consumption rate, in W schedule. If nil, will be defaulted. and flow rate schedule will be set. zones to place water heater in. If nil, will be assumed in 70F air for heat loss. the resulting water heater.

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

  • service_water_temperature (Double)

    water heater temperature, in C

  • parasitic_fuel_consumption_rate (Double)

    water heater parasitic

  • swh_temp_sch (OpenStudio::Model::Schedule)

    the service water heating

  • set_peak_use_flowrate (Bool)

    if true, the peak flow rate

  • peak_flowrate (Double)

    in m^3/s

  • flowrate_schedule (String)

    name of the flow rate schedule

  • water_heater_thermal_zone (OpenStudio::Model::ThermalZone)
  • building_type (String) (defaults to: nil)

    the building type

Returns:



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
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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4149

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,
                           building_type = nil)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', 'Adding water heater')

  # 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 = OpenStudio::Model::ScheduleTypeLimits.new(model)
  temp_sch_type_limits.setName('Temperature Schedule Type Limits')
  temp_sch_type_limits.setLowerLimitValue(0.0)
  temp_sch_type_limits.setUpperLimitValue(100.0)
  temp_sch_type_limits.setNumericType('Continuous')
  temp_sch_type_limits.setUnitType('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 = OpenStudio::Model::ScheduleRuleset.new(model)
    swh_temp_sch.setName("Service Water Loop Temp - #{swh_temp_f.round}F")
    swh_temp_sch.defaultDaySchedule.setName("Service Water Loop Temp - #{swh_temp_f.round}F Default")
    swh_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), swh_temp_c)
    swh_temp_sch.setScheduleTypeLimits(temp_sch_type_limits)
  end

  # Water heater depends on the fuel type
  water_heater = OpenStudio::Model::WaterHeaterMixed.new(model)
  water_heater.setName("#{water_heater_vol_gal.round}gal #{water_heater_fuel} 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)

  if water_heater_thermal_zone.nil?
    # Assume the water heater is indoors at 70F for now
    default_water_heater_ambient_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)
    default_water_heater_ambient_temp_sch.setName('Water Heater Ambient Temp Schedule - 70F')
    default_water_heater_ambient_temp_sch.defaultDaySchedule.setName('Water Heater Ambient Temp Schedule - 70F Default')
    default_water_heater_ambient_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), OpenStudio.convert(70, 'F', 'C').get)
    default_water_heater_ambient_temp_sch.setScheduleTypeLimits(temp_sch_type_limits)
    water_heater.setAmbientTemperatureIndicator('Schedule')
    water_heater.setAmbientTemperatureSchedule(default_water_heater_ambient_temp_sch)
  else
    water_heater.setAmbientTemperatureIndicator('ThermalZone')
    water_heater.setAmbientTemperatureThermalZone water_heater_thermal_zone
  end

  water_heater.setMaximumTemperatureLimit(OpenStudio.convert(180, 'F', 'C').get)
  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.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)
  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

  return water_heater
end

#model_add_water_source_hp(model, condenser_loop, thermal_zones, ventilation = true) ⇒ Array<OpenStudio::Model::ZoneHVACWaterToAirHeatPump>

Adds zone level water-to-air heat pumps for each zone.

no ventilation will be supplied through the unit, with the expectation that it will be provided by a DOAS or separate system.

Parameters:

  • condenser_loop (OpenStudio::Model::PlantLoop)

    the condenser loop for the heat pumps

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    array of zones to add heat pumps to.

  • ventilation (Bool) (defaults to: true)

    if true, ventilation will be supplied through the unit. If false,

Returns:



5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5398

def model_add_water_source_hp(model, condenser_loop,
                              thermal_zones,
                              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 = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)

    htg_coil = OpenStudio::Model::CoilHeatingWaterToAirHeatPumpEquationFit.new(model)
    htg_coil.setName('WSHP Htg Coil')
    htg_coil.setRatedHeatingCoefficientofPerformance(4.2)
    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)

    condenser_loop.addDemandBranchForComponent(htg_coil)

    clg_coil = OpenStudio::Model::CoilCoolingWaterToAirHeatPumpEquationFit.new(model)
    clg_coil.setName('WSHP Clg Coil')
    clg_coil.setRatedCoolingCoefficientofPerformance(3.4)
    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)

    condenser_loop.addDemandBranchForComponent(clg_coil)

    # add fan
    fan = OpenStudio::Model::FanOnOff.new(model, model.alwaysOnDiscreteSchedule)
    fan.setName("#{zone.name} WSHP Fan")
    fan_static_pressure_in_h2o = 1.33
    fan_static_pressure_pa = OpenStudio.convert(fan_static_pressure_in_h2o, 'inH_{2}O', 'Pa').get
    fan.setPressureRise(fan_static_pressure_pa)
    fan.setFanEfficiency(0.52)
    fan.setMotorEfficiency(0.8)

    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(OpenStudio::OptionalDouble.new(0))
      water_to_air_hp_system.setOutdoorAirFlowRateDuringCoolingOperation(OpenStudio::OptionalDouble.new(0))
      water_to_air_hp_system.setOutdoorAirFlowRateWhenNoCoolingorHeatingisNeeded(OpenStudio::OptionalDouble.new(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_window_ac(model, thermal_zones) ⇒ Array<OpenStudio::Model::ZoneHVACPackagedTerminalAirConditioner>

Parameters:

Returns:



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
5044
5045
5046
5047
5048
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4982

def model_add_window_ac(model,
                        thermal_zones)

  # Defaults
  eer = 8.5 # Btu/W-h
  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

  # 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
  roomac_cap_ft = create_curve_biquadratic(cool_cap_ft_coeffs_si, 'RoomAC-Cap-fT', 0, 100, 0, 100, nil, nil)
  roomac_cap_fff = create_curve_quadratic(cool_cap_fflow_coeffs, 'RoomAC-Cap-fFF', 0, 2, 0, 2, is_dimensionless = true)
  roomac_eir_ft = create_curve_biquadratic(cool_eir_ft_coeffs_si, 'RoomAC-EIR-fT', 0, 100, 0, 100, nil, nil)
  roomac_eir_fff = create_curve_quadratic(cool_eir_fflow_coeffs, 'RoomAC-EIR-fFF', 0, 2, 0, 2, is_dimensionless = true)
  roomac_plf_fplr = create_curve_quadratic(cool_plf_fplr_coeffs, 'RoomAC-PLF-fPLR', 0, 1, 0, 1, is_dimensionless = true)

  acs = []
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding window AC for #{zone.name}.")

    clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model,
                                                               model.alwaysOnDiscreteSchedule,
                                                               roomac_cap_ft,
                                                               roomac_cap_fff,
                                                               roomac_eir_ft,
                                                               roomac_eir_fff,
                                                               roomac_plf_fplr)
    clg_coil.setName('Window AC Clg Coil')
    clg_coil.setRatedSensibleHeatRatio(shr)
    clg_coil.setRatedCOP(OpenStudio::OptionalDouble.new(OpenStudio.convert(eer, 'Btu/h', 'W').get))
    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 = OpenStudio::Model::FanOnOff.new(model, model.alwaysOnDiscreteSchedule)
    fan.setName('Window AC Supply Fan')
    fan.setFanEfficiency(1)
    fan.setPressureRise(0)
    fan.setMotorEfficiency(1)
    fan.setMotorInAirstreamFraction(0)

    htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOffDiscreteSchedule)
    htg_coil.setName('Window AC Always Off Htg Coil')

    ptac = OpenStudio::Model::ZoneHVACPackagedTerminalAirConditioner.new(model,
                                                                         model.alwaysOnDiscreteSchedule,
                                                                         fan,
                                                                         htg_coil,
                                                                         clg_coil)
    ptac.setName("#{zone.name} Window AC")
    ptac.setSupplyAirFanOperatingModeSchedule(alwaysOffDiscreteSchedule)
    ptac.addToThermalZone(zone)

    acs << ptac
  end

  return acs
end

#model_add_zone_erv(model, thermal_zones) ⇒ Array<OpenStudio::Model::ZoneHVACEnergyRecoveryVentilator>

TODO:

review the static pressure rise for the ERV

Adds zone level ERVs for each zone.

Parameters:

Returns:

  • (Array<OpenStudio::Model::ZoneHVACEnergyRecoveryVentilator>)

    an array of zone ERVs



5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
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
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5475

def model_add_zone_erv(model, thermal_zones)
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Model.Model', "Adding zone ERV for #{thermal_zones.size} zones.")
  thermal_zones.each do |zone|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.Model.Model', "---#{zone.name}")
  end

  # ERV properties
  fan_static_pressure_in_h2o = 0.25
  fan_static_pressure_pa = OpenStudio.convert(fan_static_pressure_in_h2o, 'inH_{2}O', 'Pa').get
  fan_motor_efficiency = 0.8

  erv_systems = []
  thermal_zones.each do |zone|
    # 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 = OpenStudio::Model::FanOnOff.new(model)
    supply_fan.setName("#{zone.name} ERV Supply Fan")
    supply_fan.setMotorEfficiency(fan_motor_efficiency)
    impeller_eff = fan_baseline_impeller_efficiency(supply_fan)
    fan_change_impeller_efficiency(supply_fan, impeller_eff)
    supply_fan.setPressureRise(fan_static_pressure_pa)
    supply_fan.setMotorInAirstreamFraction(1)

    exhaust_fan = OpenStudio::Model::FanOnOff.new(model)
    exhaust_fan.setName("#{zone.name} ERV Exhaust Fan")
    exhaust_fan.setMotorEfficiency(fan_motor_efficiency)
    fan_change_impeller_efficiency(exhaust_fan, impeller_eff)
    exhaust_fan.setPressureRise(fan_static_pressure_pa)
    exhaust_fan.setMotorInAirstreamFraction(1)

    erv_controller = OpenStudio::Model::ZoneHVACEnergyRecoveryVentilatorController.new(model)
    # 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.setHeatExchangerType("Plate")
    # heat_exchanger.setEconomizerLockout(true)
    # 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)

    # Calculate ERV SAT during sizing periods
    # Heating design day
    oat_f = 0
    return_air_f = 68
    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 day
    oat_f = 110
    return_air_f = 75
    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
    zone_sizing = zone.sizingZone
    zone_sizing.setAccountforDedicatedOutdoorAirSystem(true)
    zone_sizing.setDedicatedOutdoorAirSystemControlStrategy('ColdSupplyAir')
    zone_sizing.setDedicatedOutdoorAirLowSetpointTemperatureforDesign(coldest_erv_supply_c)
    zone_sizing.setDedicatedOutdoorAirHighSetpointTemperatureforDesign(hottest_erv_supply_c)

    erv_systems << zone_hvac
  end

  return erv_systems
end

#model_add_zone_ventilation(model, availability_sch_name, flow_rate, ventilation_type, thermal_zones) ⇒ Array<OpenStudio::Model::ZoneVentilationDesignFlowRate>

Adds a zone ventilation design flow rate to each zone.

Flow Rate per Zone Floor Area in m^3/s-m^2 for Intake

Parameters:

  • availability_sch_name (String)

    the name of the fan availability schedule

  • flow_rate (Double)

    the ventilation design flow rate in m^3/s for Exhaust/Natural or

  • ventilation_type (String)

    the zone ventilation type either Exhaust, Natural, or Intake

  • thermal_zones (Array<OpenStudio::Model::ThermalZone>)

    an array of thermal zones

Returns:

  • (Array<OpenStudio::Model::ZoneVentilationDesignFlowRate>)

    an array of zone ventilation objects created



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5630

def model_add_zone_ventilation(model, availability_sch_name,
                               flow_rate,
                               ventilation_type,
                               thermal_zones)

  # Make an exhaust fan for each zone
  zone_ventilations = []
  thermal_zones.each do |zone|
    ventilation = OpenStudio::Model::ZoneVentilationDesignFlowRate.new(model)
    ventilation.setName("#{zone.name} Ventilation")
    ventilation.setSchedule(model_add_schedule(model, availability_sch_name))
    ventilation.setVentilationType(ventilation_type)

    ventilation.setAirChangesperHour(0)
    ventilation.setTemperatureTermCoefficient(0)

    if ventilation_type == 'Exhaust'
      ventilation.setDesignFlowRateCalculationMethod('Flow/Zone')
      ventilation.setDesignFlowRate(flow_rate)
      ventilation.setFanPressureRise(31.1361206455786)
      ventilation.setFanTotalEfficiency(0.51)
      ventilation.setConstantTermCoefficient(1)
      ventilation.setVelocityTermCoefficient(0)
      ventilation.setMinimumIndoorTemperature(29.4444452244559)
      ventilation.setMaximumIndoorTemperature(100)
      ventilation.setDeltaTemperature(-100)
    elsif ventilation_type == 'Natural'
      ventilation.setDesignFlowRateCalculationMethod('Flow/Zone')
      ventilation.setDesignFlowRate(flow_rate)
      ventilation.setFanPressureRise(0)
      ventilation.setFanTotalEfficiency(1)
      ventilation.setConstantTermCoefficient(0)
      ventilation.setVelocityTermCoefficient(0.224)
      ventilation.setMinimumIndoorTemperature(-73.3333352760033)
      ventilation.setMaximumIndoorTemperature(29.4444452244559)
      ventilation.setDeltaTemperature(-100)
    elsif ventilation_type == 'Intake'
      ventilation.setDesignFlowRateCalculationMethod('Flow/Area')
      ventilation.setFlowRateperZoneFloorArea(flow_rate)
      ventilation.setFanPressureRise(49.8)
      ventilation.setFanTotalEfficiency(0.53625)
      ventilation.setConstantTermCoefficient(1)
      ventilation.setVelocityTermCoefficient(0)
      ventilation.setMinimumIndoorTemperature(7.5)
      ventilation.setMaximumIndoorTemperature(35)
      ventilation.setDeltaTemperature(-27.5)
      ventilation.setMinimumOutdoorTemperature(-30.0)
      ventilation.setMaximumOutdoorTemperature(50.0)
      ventilation.setMaximumWindSpeed(6.0)
    end
    ventilation.addToThermalZone(zone)
    zone_ventilations << ventilation
  end

  return zone_ventilations
end

#model_apply_hvac_efficiency_standard(model, climate_zone) ⇒ Object

Applies the HVAC parts of the template to all objects in the model using the the template specified in the model.



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1813

def model_apply_hvac_efficiency_standard(model, climate_zone)
  sql_db_vars_map = {}

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started applying HVAC efficiency standards.')

  # Air Loop Controls
  model.getAirLoopHVACs.sort.each { |obj| air_loop_hvac_apply_standard_controls(obj, climate_zone) }

  # Plant Loop Controls
  # TODO refactor: enable this code (missing before refactor)
  # getPlantLoops.sort.each { |obj| plant_loop_apply_standard_controls(obj, template, climate_zone) }

  ##### 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 paried 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) }

  # 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) }

  # ERVs
  model.getHeatExchangerAirToAirSensibleAndLatents.each { |obj| heat_exchanger_air_to_air_sensible_and_latent_apply_efficiency(obj) }

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Finished applying HVAC efficiency standards.')
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



1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1892

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

Applies the multi-zone VAV outdoor air sizing requirements to all applicable air loops in the model.

it impacts component sizes, which in turn impact efficiencies.



1802
1803
1804
1805
1806
1807
1808
1809
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1802

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_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.



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
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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3644

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

TODO:

support 90.1-2004 requirement that windows be modeled as

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.

type specific values horizontal bands. Currently just using existing window geometry, and shrinking as necessary if WWR is above limit.



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
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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3480

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



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3287

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.



3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3826

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



3372
3373
3374
3375
3376
3377
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
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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3372

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.



1574
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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1574

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)


4568
4569
4570
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4568

def model_attach_water_fixtures_to_spaces?(model)
  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



1255
1256
1257
1258
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1255

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
# 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)
  area_length_count_hash = {}

  # populate building_type_hash, used to remap office
  building_type_hash = {}
  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
  end
  # rename Office to SmallOffice MediumOffice or LargeOffice
  office_type = nil
  if building_type_hash.key?('Office')
    office_type = model_remap_office(model, building_type_hash['Office'])
  end

  # parking areas and drives area
  parking_area_and_drives_area = 0.0
  main_entries = 0.0
  other_doors = 0.0
  canopy_entry_area = 0.0
  canopy_emergency_area = 0.0
  drive_through_windows = 0.0
  # run space_type_hash to get number of students and units and building type floor area totals
  space_type_hash.each do |space_type, hash|
    # rename space types as needed
    building_type = if hash[:stds_bldg_type] == 'Office'
                      office_type
                    else
                      hash[:stds_bldg_type]
                    end

    # store floor area ip
    floor_area_ip = OpenStudio.convert(hash[:floor_area], 'm^2', 'ft^2').get
    num_spots = 0.0

    # load illuminated_parking_area_properties
    search_criteria = { 'building_type' => building_type }
    illuminated_parking_area_lookup = model_find_object(standards_data['parking'], search_criteria)
    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
    parking_area_and_drives_area += num_spots * illuminated_parking_area_lookup['parking_area_per_spot']

    # load illuninated_parking_area_properties
    search_criteria = { 'building_type' => building_type }
    exterior_lighting_assumptions_lookup = model_find_object(standards_data['entryways'], search_criteria)

    # lookup doors
    if use_model_for_entries_and_canopies
      # TODO: - get number of entries and canopy size from model geometry
    else

      # no source for width of different entry types
      main_entry_width_ip = 8 # ft
      other_doors_width_ip = 4 # ft

      # rollup not used
      main_entries += (floor_area_ip / 10_000.0) * exterior_lighting_assumptions_lookup['entrance_doors_per_10,000'] * main_entry_width_ip
      other_doors += (floor_area_ip / 10_000.0) * exterior_lighting_assumptions_lookup['others_doors_per_10,000'] * other_doors_width_ip
      unless exterior_lighting_assumptions_lookup['floor_area_per_drive_through_window'].nil?
        drive_through_windows += floor_area_ip / exterior_lighting_assumptions_lookup['floor_area_per_drive_through_window'].to_f
      end

      # if any space types of building type that has canopy, then use that value, don't add to count for additional space types
      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
      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

  # populate hash
  area_length_count_hash[:parking_area_and_drives_area] = parking_area_and_drives_area
  area_length_count_hash[:main_entries] = main_entries
  area_length_count_hash[:other_doors] = other_doors
  area_length_count_hash[:canopy_entry_area] = canopy_entry_area
  area_length_count_hash[:canopy_emergency_area] = canopy_emergency_area
  area_length_count_hash[:drive_through_windows] = drive_through_windows

  # 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 facde 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

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.

compliance path for minimum standard compliance.“ This means you can’t use this method for code compliance to get a permit. If nothing is specified, no custom logic will be applied; the process will follow the template logic explicitly.

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’.

  • 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



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 24

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)

  # 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 curves
  model.getCurves.sort.each do |curve|
    if curve.directUseCount == 0
      OpenStudio::logFree(OpenStudio::Debug, 'openstudio.standards.Model', "#{curve.name} is unused; it will be removed.")
      model.removeObject(curve.handle)
    end
  end

  # 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.



250
251
252
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 250

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



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
4268
4269
4270
4271
4272
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
4300
4301
4302
4303
4304
4305
4306
4307
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4224

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
      end

      # determine number of beds
      if stds_bldg_type == 'Hospital' && ['PatRoom', 'ICU_PatRm', 'ICU_Open'].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)
      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 buidling 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



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4109

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



5758
5759
5760
5761
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5758

def model_cw_loop_cooling_tower_fan_type(model)
  fan_type = 'TwoSpeed 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,



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1409

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)
    # 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



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4191

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 ventilaton fan power (W)



131
132
133
134
135
136
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.elevators.rb', line 131

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



104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.elevators.rb', line 104

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.



122
123
124
125
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.elevators.rb', line 122

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

with the keys ‘zone’,

Parameters:

  • array_of_zones (Array)

    an array of Hashes for each zone,



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1336

def model_eliminate_outlier_zones(model, array_of_zones, key_to_inspect, tolerance, field_name, units)
  # Sort the zones by the desired key
  array_of_zones = array_of_zones.sort_by { |hsh| hsh[key_to_inspect] }

  # 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
  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 = nil
  biggest_delta = 0.0
  worst = nil
  array_of_zones.each_with_index do |zn, i|
    val = zn[key_to_inspect]
    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
    # OpenStudio::logFree(OpenStudio::Debug, 'openstudio.standards.Model', "#{worst.round(1)} - #{avg.round(1)} = #{biggest_delta.round(1)} #{units} < tolerance of #{tolerance} #{units}, stopping elimination process.")
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.Model', "#{worst} - #{avg} = #{biggest_delta} #{units} < 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.



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2507

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 Handobook - HVAC Applications Table 7 section 60.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



3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3873

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'].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}.")
  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.



4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4034

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}")
  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 cliimate 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 when #{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



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
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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3162

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; contructions 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



3925
3926
3927
3928
3929
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3925

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



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3935

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_value = ''
  model.getClimateZones.climateZones.each do |cz|
    if cz.institution == 'ASHRAE'
      climate_zone_value = cz.value
      next
    end
  end

  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) ⇒ 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:

  • 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.

Returns:

  • (Hash)

    Return tbe first matching object hash if successful, nil if not.



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
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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2056

def model_find_object(hash_of_objects, search_criteria, capacity = nil, date = nil)
  #    new_matching_objects = model_find_objects(self, hash_of_objects, search_criteria, capacity)

  if hash_of_objects.is_a?(Hash) and hash_of_objects.key?('table')
    hash_of_objects = hash_of_objects['table']
  end
  desired_object = nil
  search_criteria_matching_objects = []
  matching_objects = []

  # 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
    search_criteria_matching_objects << object
  end

  # If capacity was specified, narrow down the matching objects
  if capacity.nil?
    matching_objects = search_criteria_matching_objects
  else
    # Round up if capacity is an integer
    if capacity == capacity.round
      capacity += (capacity * 0.01)
    end
    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
    # If no object was found, round the capacity down a little
    # to avoid issues where the number fell between the limits
    # in the json file.
    if matching_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
  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

  # Check the number of matching objects found
  if matching_objects.size.zero?
    desired_object = nil
    # OpenStudio::logFree(OpenStudio::Warn, 'openstudio.standards.Model', "Find object search criteria returned no results. Search criteria: #{search_criteria}, capacity = #{capacity}.  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) ⇒ 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(self, standards_data['schedules'], {'name'=>schedule_name})
if rules.size == 0
  OpenStudio::logFree(OpenStudio::Warn, 'openstudio.standards.Model', "Cannot find data for schedule: #{schedule_name}, will not be created.")
  return false #TODO change to return empty optional schedule:ruleset?
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.

Returns:

  • (Array)

    returns an array of hashes, one hash per object. Array is empty if no results.



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
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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1922

def model_find_objects(hash_of_objects, search_criteria, capacity = nil)
  #    matching_objects = hash_of_objects.clone
  #    #new
  #    puts "searching"
  #    puts search_criteria
  #    raise ("hash of objects is nil or empty. #{hash_of_objects}") if hash_of_objects.nil? || hash_of_objects.empty? || matching_objects[0].nil?
  #
  #    search_criteria.each do |key,value|
  #      puts "#{key}-#{value}"
  #      puts matching_objects.size
  #      #if size has already reduced to zero. Get out of loop.
  #      break if matching_objects.size == 0
  #      #if there are no keys that match, skip search... (This seems odd)
  #      next unless  matching_objects[0].has_key?(key)
  #      matching_objects.select!{ |k| k[key] == value }
  #    end
  #    if not capacity.nil?
  #      puts "Capacity = #{capacity}"
  #      capacity = capacity + (capacity * 0.01) if capacity == capacity.round
  #      matching_objects.select!{|k| capacity.to_f > k['minimum_capacity'].to_f}
  #      matching_objects.select!{|k| capacity.to_f <= k['maximum_capacity'].to_f}
  #    end
  #
  #
  #    # Check the number of matching objects found
  #    if matching_objects.size == 0
  #      OpenStudio::logFree(OpenStudio::Warn, 'openstudio.standards.Model', "Find objects search criteria returned no results. Search criteria: #{search_criteria}, capacity = #{capacity}.  Called from #{caller(0)[1]}.")
  #
  #    end
  #    new_matching_objects =  matching_objects

  # old
  desired_object = nil
  search_criteria_matching_objects = []
  matching_objects = []

  if hash_of_objects.is_a?(Hash) and hash_of_objects.key?('table')
    hash_of_objects = hash_of_objects['table']
  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 if meets_all_search_criteria == false
    # If made it here, object matches all search criteria
    search_criteria_matching_objects << object
  end

  # If capacity was specified, narrow down the matching objects
  if capacity.nil?
    matching_objects = search_criteria_matching_objects
  else
    # Round up if capacity is an integer
    if capacity == capacity.round
      capacity += (capacity * 0.01)
    end
    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.to_f <= object['minimum_capacity'].to_f
      # Skip objects whose max
      next if capacity.to_f > object['maximum_capacity'].to_f
      # Found a matching object
      matching_objects << object
    end
    # If no object was found, round the capacity down a little
    # to avoid issues where the number fell between the limits
    # in the json file.
    if matching_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
  end

  # Check the number of matching objects found
  if matching_objects.size.zero?
    desired_object = nil
    # OpenStudio::logFree(OpenStudio::Warn, 'openstudio.standards.Model', "Find objects search criteria returned no results. Search criteria: #{search_criteria}, capacity = #{capacity}.  Called from #{caller(0)[1]}.")
  end

  #    if new_matching_objects != matching_objects
  #      puts "new..."
  #      puts new_matching_objects
  #      puts "is not.."
  #      puts matching_objects
  #      raise ("Hell")
  #    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



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2957

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 == '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 == '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
  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



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3062

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



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3093

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, pipe_hash = {}, storage_to_cap_ratio = 1.0, htg_eff = 0.8, inlet_temp_ip = 40.0, target_temp_ip = 140.0, peak_flow_fraction = 1.0) ⇒ Hash

set capacity, volume, and parasitic

Parameters:

  • water_use_equipment_array (Array)

    array of water use equipment objects that will be using this water heater

  • storage_to_cap_ratio (Double) (defaults to: 1.0)

    gal of storage to kBtu/hr of capacitiy

  • htg_eff (Double) (defaults to: 0.8)

    fraction

  • inlet_temp_ip (Double) (defaults to: 40.0)

    cold water temperature F

  • target_temp_ip (Double) (defaults to: 140.0)

    F

Returns:

  • (Hash)

    hash with values needed to size water heater made with downstream method



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
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.Model.swh.rb', line 678

def model_find_water_heater_capacity_volume_and_parasitic(model, water_use_equipment_array, pipe_hash = {}, storage_to_cap_ratio = 1.0, htg_eff = 0.8, inlet_temp_ip = 40.0, target_temp_ip = 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 water use equipment
  max_flow_rate_array = [] # 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']
    end

    # get water_use_equip_def to get max flow rate
    water_use_equip_def = water_use_equip.waterUseEquipmentDefinition
    peak_flow_rate = water_use_equip_def.peakFlowRate

    # calculate adjusted flow rate
    adjusted_peak_flow_rate_si = max_sch_value * peak_flow_rate
    adjusted_peak_flow_rate_ip = OpenStudio.convert(adjusted_peak_flow_rate_si, 'm^3/s', 'gal/min').get
    max_flow_rate_array << adjusted_peak_flow_rate_ip * 60.0 # min per hour
  end

  # warn if max_flow_rate_array size doesn't match equipment size (one or more didn't have ruleset schedule)
  if max_flow_rate_array.size != water_use_equipment_array.size
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', 'One or more Water Use Equipment Fraction Flow Rate Scheules were not Schedule Rulestes and were excluding from Water Heating Sizing.')
  end

  # sum gpm values from water use equipment to use in formula
  adjusted_flow_rate_sum = max_flow_rate_array.inject(:+)

  # use formula to calculate volume and 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_ip = peak_flow_fraction * adjusted_flow_rate_sum * 8.4 * 1.0 * (target_temp_ip - inlet_temp_ip) / htg_eff
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Capacity of #{water_heater_capacity_ip} Btu/hr = #{peak_flow_fraction} peak fraction * #{adjusted_flow_rate_sum.round} gal/hr * 8.4 lb/gal * 1.0 Btu/lb F * (#{target_temp_ip.round} - #{inlet_temp_ip.round} deltaF / #{htg_eff} htg eff).")
  water_heater_capacity_si = OpenStudio.convert(water_heater_capacity_ip, 'Btu/hr', 'W').get
  # Assume 1 gal of volume per 1 kBtu/hr of heating capacity
  water_heater_volume_ip = OpenStudio.convert(water_heater_capacity_ip, 'Btu/hr', 'kBtu/hr').get
  # increase tank size to 40 galons if calculated value is smaller
  if water_heater_volume_ip < 40.0 # gal
    water_heater_volume_ip = 40.0
  end
  water_heater_volume_si = OpenStudio.convert(water_heater_volume_ip, 'gal', 'm^3').get

  # populate return hash
  water_heater_sizing[:water_heater_capacity] = water_heater_capacity_si
  water_heater_sizing[:water_heater_volume] = water_heater_volume_si

  # get pipe length (formula from A.3.1 PrototypeModelEnhancements_2014_0.pdf)
  if !pipe_hash.empty?

    pipe_length = 2.0 * (Math.sqrt(pipe_hash[:floor_area] / pipe_hash[:effective_num_stories]) + (10.0 * (pipe_hash[:effective_num_stories] - 1.0)))
    pipe_length_ip = OpenStudio.convert(pipe_length, 'm', 'ft').get

    # calculate pipe dump (from A.4.1)
    pipe_dump = pipe_length_ip * 0.689 # Btu/hr

    pipe_loss_per_foot = if pipe_hash[:circulating]
                           if pipe_hash[:insulation_thickness] >= 1.0
                             16.10
                           elsif pipe_hash[:insulation_thickness] >= 0.5
                             17.5
                           else
                             30.8
                           end
                         else
                           if pipe_hash[:insulation_thickness] >= 1.0
                             11.27
                           elsif pipe_hash[:insulation_thickness] >= 0.5
                             12.25
                           else
                             28.07
                           end
                         end

    # calculate pipe loss (from Table A.3 in section A.4.2)
    pipe_loss = pipe_length * pipe_loss_per_foot # Btu/hr

    # calculate parasitic loss
    water_heater_sizing[:parasitic_fuel_consumption_rate] = pipe_dump + pipe_loss
  else
    water_heater_sizing[:parasitic_fuel_consumption_rate] = 0.0
  end

  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



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1266

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 clinzte aone 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



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3005

def model_get_building_climate_zone_and_building_type(model, remap_office = true)
  # get climate zone from model
  # get ashrae climate zone from model
  climate_zone = ''
  model.getClimateZones.climateZones.each do |cz|
    if cz.institution == 'ASHRAE'
      climate_zone = if cz.value == '7' || cz.value == '8'
                       "ASHRAE 169-2006-#{cz.value}A"
                     else
                       "ASHRAE 169-2006-#{cz.value}"
                     end
    elsif cz.institution == 'CEC'
      climate_zone = "CEC T24-CEC#{cz.value}"
    end
  end

  # 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.



4065
4066
4067
4068
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4065

def model_get_climate_zone_set_from_list(model, possible_climate_zone_sets)
  climate_zone_set = possible_climate_zone_sets.sort.first
  return climate_zone_set
end

#model_get_construction_properties(model, intended_surface_type, standards_construction_type, building_category = 'Nonresidential') ⇒ 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) (defaults to: 'Nonresidential')

    the type of building

Returns:

  • (hash)

    hash of construction properties



3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3449

def model_get_construction_properties(model, intended_surface_type, standards_construction_type, building_category = 'Nonresidential')
  # get climate_zone_set
  climate_zone = model_get_building_climate_zone_and_building_type(model)['climate_zone']
  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_full_weather_file_path(model) ⇒ OpenStudio::OptionalPath

Get the full path to the weather file that is specified in the model.

Returns:

  • (OpenStudio::OptionalPath)


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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2845

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



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

def model_get_lookup_name(building_type)
  lookup_name = building_type
  case building_type
    when 'SmallOffice'
      lookup_name = 'Office'
    when 'MediumOffice'
      lookup_name = 'Office'
    when 'LargeOffice'
      lookup_name = 'Office'
    when 'LargeOfficeDetail'
      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_or_add_ambient_water_loop(model) ⇒ Object

Either get the existing ambient water loop in the model or add a new one if there isn’t one already.



5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5784

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 = nil
  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, air_cooled = true) ⇒ Object

Either get the existing chilled water loop in the model or add a new one if there isn’t one already.

Electricity, DistrictCooling, and HeatPump.

Parameters:

  • cool_fuel (String)

    the cooling fuel. Valid choices are

  • air_cooled (Bool) (defaults to: true)

    if true, the chiller will be air-cooled. if false, it will be water-cooled.



5694
5695
5696
5697
5698
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
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5694

def model_get_or_add_chilled_water_loop(model, cool_fuel, air_cooled = true)
  # 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,
                                              'const_pri',
                                              chiller_cooling_type = nil,
                                              chiller_condenser_type = nil,
                                              chiller_compressor_type = nil,
                                              cool_fuel,
                                              condenser_water_loop = nil,
                                              building_type = nil)
    when 'HeatPump'
      condenser_water_loop = model_get_or_add_ambient_water_loop(model)
      chilled_water_loop = model_add_chw_loop(model,
                                              'const_pri_var_sec',
                                              'WaterCooled',
                                              chiller_condenser_type = nil,
                                              'Rotary Screw',
                                              cooling_fuel = nil,
                                              condenser_water_loop,
                                              building_type = nil)
    when 'Electricity'
      if air_cooled
        chilled_water_loop = model_add_chw_loop(model,
                                                'const_pri',
                                                chiller_cooling_type = nil,
                                                chiller_condenser_type = nil,
                                                chiller_compressor_type = nil,
                                                cool_fuel,
                                                condenser_water_loop = nil,
                                                building_type = nil)
      else
        fan_type = model_cw_loop_cooling_tower_fan_type(model)
        condenser_water_loop = model_add_cw_loop(model,
                                                 'Open Cooling Tower',
                                                 'Propeller or Axial',
                                                 fan_type,
                                                 1,
                                                 1,
                                                 nil)
        chilled_water_loop = model_add_chw_loop(model,
                                                'const_pri_var_sec',
                                                'WaterCooled',
                                                chiller_condenser_type = nil,
                                                'Rotary Screw',
                                                cooling_fuel = nil,
                                                condenser_water_loop,
                                                building_type = nil)
      end
    end
  end

  return chilled_water_loop
end

#model_get_or_add_ground_hx_loop(model) ⇒ Object

Either get the existing ground heat exchanger loop in the model or add a new one if there isn’t one already.



5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5800

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 = nil
  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) ⇒ Object

Either get the existing heat pump loop in the model or add a new one if there isn’t one already.



5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5816

def model_get_or_add_heat_pump_loop(model)
  # Retrieve the existing heat pump loop
  # or add a new one if necessary.
  heat_pump_loop = nil
  heat_pump_loop = if model.getPlantLoopByName('Heat Pump Loop').is_initialized
                     model.getPlantLoopByName('Heat Pump Loop').get
                   else
                     model_add_hp_loop(model)
                   end

  return heat_pump_loop
end

#model_get_or_add_hot_water_loop(model, heat_fuel) ⇒ Object

Either get the existing hot water loop in the model or add a new one if there isn’t one already.

Valid choices are NaturalGas, Electricity, DistrictHeating

Parameters:

  • heat_fuel (String)

    the heating fuel.



5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 5768

def model_get_or_add_hot_water_loop(model, heat_fuel)
  # 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, heat_fuel)
                   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 cooresponds to a specific minimum z value. Makes a new story if none found at this height.

desired story, in meters. Default is 0.3 m ~1ft

Parameters:

  • minz (Double)

    the z value (height) of the

  • tolerance (Double) (defaults to: 0.3)

    tolerance for comparison, in m.

Returns:

  • (OpenStudio::Model::BuildingStory)

    the story



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 3847

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:



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
1560
1561
1562
1563
1564
1565
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 1529

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_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.



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
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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3969

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'
  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



281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 281

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



748
749
750
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 748

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)



629
630
631
632
633
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 629

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,



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 352

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. 5_or_6, 7_or_8, 9_or_10

Returns:

  • (String)

    the system number: 1_or_2, 3_or_4,



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 716

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

TODO:

add 90.1-2013 systems 11-13

Determine the baseline system type given the inputs. Logic is different for different standards.

90.1-2007, 90.1-2010, 90.1-2013 nonresidential, and heatedonly electric, fossil, fossilandelectric, purchasedheat, purchasedcooling, purchasedheatandcooling PTHP, PTAC, PSZ_AC, PSZ_HP, PVAV_Reheat, PVAV_PFP_Boxes, VAV_Reheat, VAV_PFP_Boxes, Gas_Furnace, Electric_Furnace

Parameters:

  • area_type (String)

    Valid choices are residential,

  • fuel_type (String)

    Valid choices are

  • area_ft2 (Double)

    Area in ft^2

  • num_stories (Integer)

    Number of stories

Returns:

  • (String)

    The system type. Possibilities are



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 650

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%



3771
3772
3773
3774
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3771

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



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 2878

def model_process_results_for_datapoint(model, climate_zone, building_type)
  # Combine the data from the JSON files into a single hash
  top_dir = File.expand_path('../../..', File.dirname(__FILE__))
  standards_data_dir = "#{top_dir}/data/standards"

  # Load the legacy idf results JSON file into a ruby hash
  temp = ''
  begin
    temp = load_resource_relative('../../../data/standards/legacy_idf_results.json', 'r:UTF-8')
  rescue NoMethodError
    temp = File.read("#{standards_data_dir}/legacy_idf_results.json")
  end
  legacy_idf_results = JSON.parse(temp)

  # 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']

  # Get legacy idf results
  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'] = {}
  fuel_types.each do |fuel_type|
    end_uses.each do |end_use|
      next if end_use == 'Exterior Equipment'

      # Get the legacy results number
      legacy_val = legacy_idf_results.dig(building_type, template, climate_zone, fuel_type, end_use)

      # Combine the exterior lighting and exterior equipment
      if end_use == 'Exterior Lighting'
        legacy_exterior_equipment = legacy_idf_results.dig(building_type, template, climate_zone, fuel_type, 'Exterior Equipment')
        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 # Next end use
  end # Next fuel type

  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



3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3043

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.



3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3810

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_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



3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 3782

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_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



259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 259

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_swh_pump_type(model, building_type) ⇒ String

Determine the type of SWH pump that a model will have. Defaults to ConstantSpeed.

Returns:

  • (String)

    the SWH pump type: ConstantSpeed, VariableSpeed



4123
4124
4125
4126
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 4123

def model_swh_pump_type(model, building_type)
  swh_pump_type = 'ConstantSpeed'
  return swh_pump_type
end

#model_typical_hvac_system_type(model, climate_zone, area_type, delivery_type, heating_source, cooling_source, area_m2, num_stories) ⇒ String

Determine the typical system type given the inputs.

and nonresidential Valid choices are air and hydronic Electricity, NaturalGas, DistrictHeating, DistrictAmbient Electricity, DistrictCooling, DistrictAmbient PTHP, PTAC, PSZ_AC, PSZ_HP, PVAV_Reheat, PVAV_PFP_Boxes, VAV_Reheat, VAV_PFP_Boxes, Gas_Furnace, Electric_Furnace

Parameters:

  • area_type (String)

    Valid choices are residential

  • delivery_type (String)

    Conditioning delivery type.

  • heating_source (String)

    Valid choices are

  • cooling_source (String)

    Valid choices are

  • area_m2 (Double)

    Area in m^2

  • num_stories (Integer)

    Number of stories

Returns:

  • (String)

    The system type. Possibilities are



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
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.hvac_systems.rb', line 6287

def model_typical_hvac_system_type(model,
                                   climate_zone,
                                   area_type,
                                   delivery_type,
                                   heating_source,
                                   cooling_source,
                                   area_m2,
                                   num_stories)
  #             [type, central_heating_fuel, zone_heating_fuel, cooling_fuel]
  system_type = [nil, nil, nil, nil]

  # Convert area to ft^2
  area_ft2 = OpenStudio.convert(area_m2, 'm^2', 'ft^2').get

  # categorize building by type & size
  size_category = nil
  case area_type
  when 'residential'
    # residential and less than 4 stories
    size_category = if num_stories <= 3
                      'res_small'
                    # residential and more than 4 stories
                    else
                      'res_med'
                    end
  when 'nonresidential', 'retail', 'publicassembly', 'heatedonly'
    # nonresidential and 3 floors or less and < 75,000 ft2
    if num_stories <= 3 && area_ft2 < 75_000
      size_category = 'nonres_small'
    # nonresidential and 4 or 5 floors OR 5 floors or less and 75,000 ft2 to 150,000 ft2
    elsif ((num_stories == 4 || num_stories == 5) && area_ft2 < 75_000) || (num_stories <= 5 && (area_ft2 >= 75_000 && area_ft2 <= 150_000))
      size_category = 'nonres_med'
    # nonresidential and more than 5 floors or >150,000 ft2
    elsif num_stories >= 5 || area_ft2 > 150_000
      size_category = 'nonres_lg'
    end
  end

  # Define the lookup by row and by fuel type
  syts = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
  # [heating_source][cooling_source][delivery_type][size_category]
  #  = [type, central_heating_fuel, zone_heating_fuel, cooling_fuel]

  ## Forced Air ##

  # Gas, Electric, forced air
  syts['NaturalGas']['Electricity']['air']['res_small'] = ['PTAC', 'NaturalGas', nil, 'Electricity']
  syts['NaturalGas']['Electricity']['air']['res_med'] = ['PTAC', 'NaturalGas', nil, 'Electricity']
  syts['NaturalGas']['Electricity']['air']['nonres_small'] = ['PSZ-AC', 'NaturalGas', nil, 'Electricity']
  syts['NaturalGas']['Electricity']['air']['nonres_med'] = ['PVAV Reheat', 'NaturalGas', 'NaturalGas', 'Electricity']
  syts['NaturalGas']['Electricity']['air']['nonres_lg'] = ['VAV Reheat', 'NaturalGas', 'NaturalGas', 'Electricity']

  # Electric, Electric, forced air
  syts['Electricity']['Electricity']['air']['res_small'] = ['PTHP', 'Electricity', nil, 'Electricity']
  syts['Electricity']['Electricity']['air']['res_med'] = ['PTHP', 'Electricity', nil, 'Electricity']
  syts['Electricity']['Electricity']['air']['nonres_small'] = ['PSZ-HP', 'Electricity', nil, 'Electricity']
  syts['Electricity']['Electricity']['air']['nonres_med'] = ['PVAV PFP Boxes', 'Electricity', 'Electricity', 'Electricity']
  syts['Electricity']['Electricity']['air']['nonres_lg'] = ['VAV PFP Boxes', 'Electricity', 'Electricity', 'Electricity']

  # District Hot Water, Electric, forced air
  syts['DistrictHeating']['Electricity']['air']['res_small'] = ['PTAC', 'DistrictHeating', nil, 'Electricity']
  syts['DistrictHeating']['Electricity']['air']['res_med'] = ['PTAC', 'DistrictHeating', nil, 'Electricity']
  syts['DistrictHeating']['Electricity']['air']['nonres_small'] = ['PVAV Reheat', 'DistrictHeating', 'DistrictHeating', 'Electricity']
  syts['DistrictHeating']['Electricity']['air']['nonres_med'] = ['PVAV Reheat', 'DistrictHeating', 'DistrictHeating', 'Electricity']
  syts['DistrictHeating']['Electricity']['air']['nonres_lg'] = ['VAV Reheat', 'DistrictHeating', 'DistrictHeating', 'Electricity']

  # Ambient Loop, Ambient Loop, forced air
  syts['DistrictAmbient']['DistrictAmbient']['air']['res_small'] = ['Water Source Heat Pumps with ERVs', 'HeatPump', nil, 'HeatPump']
  syts['DistrictAmbient']['DistrictAmbient']['air']['res_med'] = ['Water Source Heat Pumps with DOAS', 'HeatPump', nil, 'HeatPump']
  syts['DistrictAmbient']['DistrictAmbient']['air']['nonres_small'] = ['PVAV Reheat', 'HeatPump', 'HeatPump', 'HeatPump']
  syts['DistrictAmbient']['DistrictAmbient']['air']['nonres_med'] = ['PVAV Reheat', 'HeatPump', 'HeatPump', 'HeatPump']
  syts['DistrictAmbient']['DistrictAmbient']['air']['nonres_lg'] = ['VAV Reheat', 'HeatPump', 'HeatPump', 'HeatPump']

  # Gas, District Chilled Water, forced air
  syts['NaturalGas']['DistrictCooling']['air']['res_small'] = ['PSZ-AC', 'NaturalGas', nil, 'DistrictCooling']
  syts['NaturalGas']['DistrictCooling']['air']['res_med'] = ['PSZ-AC', 'NaturalGas', nil, 'DistrictCooling']
  syts['NaturalGas']['DistrictCooling']['air']['nonres_small'] = ['PSZ-AC', 'NaturalGas', nil, 'DistrictCooling']
  syts['NaturalGas']['DistrictCooling']['air']['nonres_med'] = ['PVAV Reheat', 'NaturalGas', 'NaturalGas', 'DistrictCooling']
  syts['NaturalGas']['DistrictCooling']['air']['nonres_lg'] = ['VAV Reheat', 'NaturalGas', 'NaturalGas', 'DistrictCooling']

  # Electric, District Chilled Water, forced air
  syts['Electricity']['DistrictCooling']['air']['res_small'] = ['PSZ-AC', 'Electricity', nil, 'DistrictCooling']
  syts['Electricity']['DistrictCooling']['air']['res_med'] = ['PSZ-AC', 'Electricity', nil, 'DistrictCooling']
  syts['Electricity']['DistrictCooling']['air']['nonres_small'] = ['PSZ-AC', 'Electricity', nil, 'DistrictCooling']
  syts['Electricity']['DistrictCooling']['air']['nonres_med'] = ['PVAV Reheat', 'Electricity', 'Electricity', 'DistrictCooling']
  syts['Electricity']['DistrictCooling']['air']['nonres_lg'] = ['VAV Reheat', 'Electricity', 'Electricity', 'DistrictCooling']

  # District Hot Water, District Chilled Water, forced air
  syts['DistrictHeating']['DistrictCooling']['air']['res_small'] = ['PSZ-AC', 'DistrictHeating', nil, 'DistrictCooling']
  syts['DistrictHeating']['DistrictCooling']['air']['res_med'] = ['PSZ-AC', 'DistrictHeating', nil, 'DistrictCooling']
  syts['DistrictHeating']['DistrictCooling']['air']['nonres_small'] = ['PVAV Reheat', 'DistrictHeating', 'DistrictHeating', 'DistrictCooling']
  syts['DistrictHeating']['DistrictCooling']['air']['nonres_med'] = ['PVAV Reheat', 'DistrictHeating', 'DistrictHeating', 'DistrictCooling']
  syts['DistrictHeating']['DistrictCooling']['air']['nonres_lg'] = ['VAV Reheat', 'DistrictHeating', 'DistrictHeating', 'DistrictCooling']

  ## Hydronic ##

  # Gas, Electric, hydronic
  syts['NaturalGas']['Electricity']['hydronic']['res_med'] = ['Fan Coil with DOAS', 'NaturalGas', nil, 'Electricity']
  syts['NaturalGas']['Electricity']['hydronic']['nonres_small'] = ['Water Source Heat Pumps with DOAS', 'NaturalGas', nil, 'Electricity']
  syts['NaturalGas']['Electricity']['hydronic']['nonres_med'] = ['Fan Coil with DOAS', 'NaturalGas', 'NaturalGas', 'Electricity']
  syts['NaturalGas']['Electricity']['hydronic']['nonres_lg'] = ['Fan Coil with DOAS', 'NaturalGas', 'NaturalGas', 'Electricity']

  # Electric, Electric, hydronic
  syts['Electricity']['Electricity']['hydronic']['res_small'] = ['Ground Source Heat Pumps with ERVs', 'Electricity', nil, 'Electricity']
  syts['Electricity']['Electricity']['hydronic']['res_med'] = ['Ground Source Heat Pumps with DOAS', 'Electricity', nil, 'Electricity']
  syts['Electricity']['Electricity']['hydronic']['nonres_small'] = ['Ground Source Heat Pumps with DOAS', 'Electricity', nil, 'Electricity']
  syts['Electricity']['Electricity']['hydronic']['nonres_med'] = ['Ground Source Heat Pumps with DOAS', 'Electricity', 'Electricity', 'Electricity']
  syts['Electricity']['Electricity']['hydronic']['nonres_lg'] = ['Ground Source Heat Pumps with DOAS', 'Electricity', 'Electricity', 'Electricity']

  # District Hot Water, Electric, hydronic
  syts['DistrictHeating']['Electricity']['hydronic']['res_small'] = [] # TODO decide if there is anything reasonable for this
  syts['DistrictHeating']['Electricity']['hydronic']['res_med'] = ['Fan Coil with DOAS', 'DistrictHeating', nil, 'Electricity']
  syts['DistrictHeating']['Electricity']['hydronic']['nonres_small'] = ['Water Source Heat Pumps with DOAS', 'DistrictHeating', 'DistrictHeating', 'Electricity']
  syts['DistrictHeating']['Electricity']['hydronic']['nonres_med'] = ['Fan Coil with DOAS', 'DistrictHeating', 'DistrictHeating', 'Electricity']
  syts['DistrictHeating']['Electricity']['hydronic']['nonres_lg'] = ['Fan Coil with DOAS', 'DistrictHeating', 'DistrictHeating', 'Electricity']

  # Ambient Loop, Ambient Loop, hydronic
  syts['DistrictAmbient']['DistrictAmbient']['hydronic']['res_small'] = ['Water Source Heat Pumps with ERVs', 'HeatPump', nil, 'HeatPump']
  syts['DistrictAmbient']['DistrictAmbient']['hydronic']['res_med'] = ['Water Source Heat Pumps with DOAS', 'HeatPump', nil, 'HeatPump']
  syts['DistrictAmbient']['DistrictAmbient']['hydronic']['nonres_small'] = ['Water Source Heat Pumps with DOAS', 'HeatPump', 'HeatPump', 'HeatPump']
  syts['DistrictAmbient']['DistrictAmbient']['hydronic']['nonres_med'] = ['Water Source Heat Pumps with DOAS', 'HeatPump', 'HeatPump', 'HeatPump']
  syts['DistrictAmbient']['DistrictAmbient']['hydronic']['nonres_lg'] = ['Fan Coil with DOAS', 'DistrictHeating', nil, 'Electricity'] # TODO: is this reasonable?

  # Gas, District Chilled Water, hydronic
  syts['NaturalGas']['DistrictCooling']['hydronic']['res_med'] = ['Fan Coil with DOAS', 'NaturalGas', nil, 'DistrictCooling']
  syts['NaturalGas']['DistrictCooling']['hydronic']['nonres_small'] = ['Fan Coil with DOAS', 'NaturalGas', nil, 'DistrictCooling']
  syts['NaturalGas']['DistrictCooling']['hydronic']['nonres_med'] = ['Fan Coil with DOAS', 'NaturalGas', 'NaturalGas', 'DistrictCooling']
  syts['NaturalGas']['DistrictCooling']['hydronic']['nonres_lg'] = ['Fan Coil with DOAS', 'NaturalGas', 'NaturalGas', 'DistrictCooling']

  # Electric, District Chilled Water, hydronic
  syts['Electricity']['DistrictCooling']['hydronic']['res_med'] = ['Fan Coil with ERVs', 'Electricity', nil, 'DistrictCooling']
  syts['Electricity']['DistrictCooling']['hydronic']['nonres_small'] = ['Fan Coil with DOAS', 'Electricity', nil, 'DistrictCooling']
  syts['Electricity']['DistrictCooling']['hydronic']['nonres_med'] = ['Fan Coil with DOAS', 'Electricity', 'Electricity', 'DistrictCooling']
  syts['Electricity']['DistrictCooling']['hydronic']['nonres_lg'] = ['Fan Coil with DOAS', 'Electricity', 'Electricity', 'DistrictCooling']

  # District Hot Water, District Chilled Water, hydronic
  syts['DistrictHeating']['DistrictCooling']['hydronic']['res_small'] = ['Fan Coil with ERVs', 'DistrictHeating', nil, 'DistrictCooling']
  syts['DistrictHeating']['DistrictCooling']['hydronic']['res_med'] = ['Fan Coil with DOAS', 'DistrictHeating', nil, 'DistrictCooling']
  syts['DistrictHeating']['DistrictCooling']['hydronic']['nonres_small'] = ['Fan Coil with DOAS', 'DistrictHeating', 'DistrictHeating', 'DistrictCooling']
  syts['DistrictHeating']['DistrictCooling']['hydronic']['nonres_med'] = ['Fan Coil with DOAS', 'DistrictHeating', 'DistrictHeating', 'DistrictCooling']
  syts['DistrictHeating']['DistrictCooling']['hydronic']['nonres_lg'] = ['Fan Coil with DOAS', 'DistrictHeating', 'DistrictHeating', 'DistrictCooling']

  # Get the system type
  system_type = syts[heating_source][cooling_source][delivery_type][size_category]

  if system_type.nil? || system_type.empty?
    system_type = [nil, nil, nil, nil]
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', "Could not determine system type for #{template}, #{area_type}, #{heating_source} heating, #{cooling_source} cooling, #{delivery_type} delivery, #{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}, #{heating_source} heating, #{cooling_source} cooling, #{delivery_type} delivery, #{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_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.



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 4074

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_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.



151
152
153
154
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.refrigeration.rb', line 151

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.

with the keys ‘zone’, ‘type’ (occ type), ‘fuel’, and ‘area’

Returns:

  • (Array<Hash>)

    an array of hashes, one for each zone,



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
# File 'lib/openstudio-standards/standards/Standards.Model.rb', line 309

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)

    # 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
# 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.model.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.model.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.model.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.model.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.model.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.model.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.model.PlanarSurface', "Set the construction for #{planar_surface.name} to #{new_construction.name}.")
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.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.



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
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 687

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.AirLoopHVAC', "For #{plant_loop.name}, primary pump type is #{pri_control_type}.")
  end

  unless sec_control_type.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "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.



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
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 182

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.



788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 788

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.AirLoopHVAC', "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.



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
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 222

def plant_loop_apply_prm_baseline_condenser_water_temperatures(plant_loop)
  sizing_plant = plant_loop.sizingPlant

  # 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
  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} 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 = OpenStudio::Model::SetpointManagerFollowOutdoorAirTemperature.new(plant_loop.model)
  cw_t_stpt_manager.setName("CW Temp Follows OATwb w/ #{approach_r} plant_loop.deltaF approach min #{float_down_to_f.round(1)} F to max #{leaving_cw_t_f.round(1)}")
  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)
  cw_t_stpt_manager.addToNode(plant_loop.supplyOutletNode)

  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.



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
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 756

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.AirLoopHVAC', "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
# 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
  plant_loop.supplyComponents.each do |sc|
    if sc.to_BoilerHotWater.is_initialized
      boiler = sc.to_BoilerHotWater.get
      boiler.setDesignWaterOutletTemperature(hw_temp_c)
    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.



670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 670

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.



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
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 813

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.



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
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 874

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.



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
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 1019

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_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:



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
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 416

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



1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 1204

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


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/standards/Standards.PlantLoop.rb', line 348

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)


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
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 375

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



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/standards/Standards.PlantLoop.rb', line 1222

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:



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
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 1261

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)


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.PlantLoop.rb', line 509

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.AirLoopHVAC', "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.AirLoopHVAC', "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.



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
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 608

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.AirLoopHVAC', "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)


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
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 550

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 # End loop on plant_loop.supplyComponents

  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)



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
# File 'lib/openstudio-standards/standards/Standards.PlantLoop.rb', line 1155

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.Pump', "'#{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.Pump', "'#{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.Pump', "'#{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.Pump', "'#{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.Loop', "'#{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

#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



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/standards/Standards.PumpVariableSpeed.rb', line 12

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

#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_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.



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
# File 'lib/openstudio-standards/standards/Standards.ScheduleCompact.rb', line 9

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



11
12
13
14
15
# File 'lib/openstudio-standards/standards/Standards.ScheduleConstant.rb', line 11

def schedule_constant_annual_equivalent_full_load_hrs(schedule_constant)
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.ScheduleRuleset', "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.



22
23
24
25
26
# File 'lib/openstudio-standards/standards/Standards.ScheduleConstant.rb', line 22

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.

Returns:

  • (Double)

    The total number of full load hours for this schedule.

Author:

  • Andrew Parker, NREL. Matt Leach, NORESCO.



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
# File 'lib/openstudio-standards/standards/Standards.ScheduleRuleset.rb', line 11

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::Info, 'openstudio.standards.ScheduleRuleset', 'WARNING: Year description is not specified; assuming 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}")

    # 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")

    # 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_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.



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
# File 'lib/openstudio-standards/standards/Standards.ScheduleRuleset.rb', line 152

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::Info, 'openstudio.standards.ScheduleRuleset', 'WARNING: Year description is not specified; assuming 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

Returns:

  • (Hash)

    Hash has two keys, min and max.

Author:

  • David Goldwasser, NREL.



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/standards/Standards.ScheduleRuleset.rb', line 113

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

#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)



132
133
134
135
136
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 132

def seer_to_cop_cooling_no_fan(seer)
  cop = -0.0076 * seer * seer + 0.3796 * seer

  return cop
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’



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
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.Space.rb', line 795

def space_add_daylighting_controls(space, remove_existing_controls, draw_daylight_areas_for_debugging = false)
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.model.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.model.Space', "For #{space.name}, removed #{existing_daylighting_controls.size} existing daylight controls before adding new controls.")
    else
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.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.model.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.model.Space', "For #{space.name}, toplighting control required = #{req_top_ctrl}")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.model.Space', "For #{space.name}, primary sidelighting control required = #{req_pri_ctrl}")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.model.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.model.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.model.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.model.Space', "Cannot currently handle non-horizontal roofs; skipping skylights on #{surface.name} in #{space.name} for daylight sensor positioning.")
          OpenStudio.logFree(OpenStudio::Debug, 'openstudio.model.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.model.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.model.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.model.Space', "Space #{name.get} 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.model.Space', "For #{space.name}, Skylights:")
  sorted_skylights.each do |sky, p|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.model.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.model.Space', "For #{space.name}, Windows:")
  sorted_windows.each do |win, p|
    OpenStudio.logFree(OpenStudio::Debug, 'openstudio.model.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.model.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.model.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.model.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.model.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.model.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



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
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
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1215

def space_apply_infiltration_rate(space)
  # Determine the total building baseline infiltration rate
  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.Model', "For #{template}, no exterior wall area was found, no infiltration will be added.")
    return true
  end
  OpenStudio.logFree(OpenStudio::Info, 'openstudio.Standards.Model', "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)
  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



1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1459

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



1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1501

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.model.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.model.Space', "Could not find a floor in space #{name.get}, 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.model.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.model.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.model.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.model.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.model.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.model.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.model.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.model.Space", "#{vertex.x.round(2)}, #{vertex.y.round(2)}, #{vertex.z.round(2)} ==> #{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.model.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.model.Space', "Cannot currently handle non-horizontal roofs; skipping skylights on #{surface.name} in #{space.name}.")
          OpenStudio.logFree(OpenStudio::Debug, 'openstudio.model.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.model.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.model.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.model.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.model.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.model.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.model.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.model.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.model.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.model.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.model.Space', "toplighted_area_ft2 = #{toplighted_area_ft2.round(1)}")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.model.Space', "primary_sidelighted_area_ft2 = #{primary_sidelighted_area_ft2.round(1)}")
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.model.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



1181
1182
1183
1184
1185
1186
1187
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1181

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



1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1195

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



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
1560
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1524

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.model.Space', "#{space.name} people activity schedule is not a Schedule:Ruleset.  Assuming #{w_per_person}W/person.")
      end
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Space', "#{space.name} people activity schedule not found.  Assuming #{w_per_person}W/person.")
    end

    num_ppl = people.getNumberOfPeople(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.model.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



1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1327

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



1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1303

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.



1619
1620
1621
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1619

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)



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
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
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1563

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



1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1480

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_infiltration_rate_75_pa(space) ⇒ Double

Determine the base infiltration rate at 75 PA.

defaults to no infiltration.

Returns:

  • (Double)

    the baseline infiltration rate, in cfm/ft^2



1294
1295
1296
1297
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1294

def space_infiltration_rate_75_pa(space)
  basic_infil_rate_cfm_per_ft2 = 0
  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)


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
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1355

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)


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
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1397

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
# 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_name = construction.get.name.get.upcase
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.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?

        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

      # Get the VT from the map
      vt = construction_name_to_vt_map[construction_name]
      if vt.nil?
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Space', "For #{space.name}, could not determine VLT for #{construction_name}, will not be included in sidelighting effective aperture caluclation.")
        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



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
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 668

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.model.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_name = construction.get.name.get.upcase
      else
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Space', "For #{space.name}, ")
        next
      end

      # Store VT for this construction in map if not already looked up
      if construction_name_to_vt_map[construction_name].nil?

        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.model.Model', "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.model.Model', 'Model has no sql file containing results, cannot lookup data.')
        end

      end

      # Get the VT from the map
      vt = construction_name_to_vt_map[construction_name]
      if vt.nil?
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Space', "For #{space.name}, could not determine VLT for #{construction_name}, will not be included in skylight effective aperture caluclation.")
        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



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.SpaceType.rb', line 464

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']
    puts space_type_properties
    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

    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

  # 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



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
# File 'lib/openstudio-standards/standards/Standards.SpaceType.rb', line 80

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?
    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'].to_f
  lights_frac_radiant = space_type_properties['lighting_fraction_radiant'].to_f
  lights_frac_visible = space_type_properties['lighting_fraction_visible'].to_f
  lights_frac_replaceable = space_type_properties['lighting_fraction_replaceable'].to_f
  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)
      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|
      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
      unless lights_frac_to_return_air.zero?
        definition.setReturnAirFraction(lights_frac_to_return_air)
      end
      unless lights_frac_radiant.zero?
        definition.setFractionRadiant(lights_frac_radiant)
      end
      unless lights_frac_visible.zero?
        definition.setFractionVisible(lights_frac_visible)
      end
      # unless lights_frac_replaceable.zero?
      #  definition.setFractionReplaceable(lights_frac_replaceable)
      # end
    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)

      # 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'].to_f
  elec_equip_frac_radiant = space_type_properties['electric_equipment_fraction_radiant'].to_f
  elec_equip_frac_lost = space_type_properties['electric_equipment_fraction_lost'].to_f
  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
      unless elec_equip_frac_latent.zero?
        definition.setFractionLatent(elec_equip_frac_latent)
      end
      unless elec_equip_frac_radiant.zero?
        definition.setFractionRadiant(elec_equip_frac_radiant)
      end
      unless elec_equip_frac_lost.zero?
        definition.setFractionLost(elec_equip_frac_lost)
      end
    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'].to_f
  gas_equip_frac_radiant = space_type_properties['gas_equipment_fraction_radiant'].to_f
  gas_equip_frac_lost = space_type_properties['gas_equipment_fraction_lost'].to_f
  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
      unless gas_equip_frac_latent.zero?
        definition.setFractionLatent(gas_equip_frac_latent)
      end
      unless gas_equip_frac_radiant.zero?
        definition.setFractionRadiant(gas_equip_frac_radiant)
      end
      unless gas_equip_frac_lost.zero?
        definition.setFractionLost(gas_equip_frac_lost)
      end
    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.setOutdoorAirMethod('Sum')
    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)
        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.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/openstudio-standards/standards/Standards.SpaceType.rb', line 39

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



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
# File 'lib/openstudio-standards/standards/Standards.SpaceType.rb', line 568

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



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
# File 'lib/openstudio-standards/standards/Standards.SpaceType.rb', line 8

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

#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
# 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(&:remove)

  # 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_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_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.Model', "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

#thermal_eff_to_afue(teff) ⇒ Double

A helper method to convert from thermal efficiency to AFUE

Parameters:

  • teff (Double)

    Thermal Efficiency

Returns:

  • (Double)

    AFUE



268
269
270
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 268

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



286
287
288
# File 'lib/openstudio-standards/prototypes/common/objects/Prototype.utilities.rb', line 286

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



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
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1402

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_schedule'].nil?
      exhaust_schedule = thermal_zone.model.alwaysOnDiscreteSchedule
    else
      sch_name = space_type_properties['exhaust_schedule']
      exhaust_schedule = model_add_schedule(thermal_zone.model, 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)
    # 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?



1536
1537
1538
1539
1540
1541
1542
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1536

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?()



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
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1237

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



1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1210

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_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



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
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1009

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-1A',
      'ASHRAE 169-2006-1B',
      'ASHRAE 169-2006-2A',
      'ASHRAE 169-2006-2B'
    htg_lim_btu_per_ft2 = 5
  when 'ASHRAE 169-2006-3A',
      'ASHRAE 169-2006-3B',
      'ASHRAE 169-2006-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',
    htg_lim_btu_per_ft2 = 15
  when 'ASHRAE 169-2006-6A',
      'ASHRAE 169-2006-6B',
      'ASHRAE 169-2006-7A',
      'ASHRAE 169-2006-7B',
    htg_lim_btu_per_ft2 = 20
  when
      'ASHRAE 169-2006-8A',
      'ASHRAE 169-2006-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
# 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
  thermal_zone.spaces.each do |space|
    dsn_oa = space.designSpecificationOutdoorAir
    next if dsn_oa.empty?
    dsn_oa = dsn_oa.get

    # 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

    # Set the per-area requirement
    dsn_oa.setOutdoorAirFlowperFloorArea(tot_oa_per_area)
    # Zero-out the per-person, ACH, and flow requirements
    dsn_oa.setOutdoorAirFlowperPerson(0.0)
    dsn_oa.setOutdoorAirFlowAirChangesperHour(0.0)
    dsn_oa.setOutdoorAirFlowRate(0.0)
  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



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
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 851

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.heatingCoil
      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.heatingCoil
      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



1391
1392
1393
1394
1395
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1391

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.



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.ThermalZone.rb', line 1332

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
  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



1272
1273
1274
1275
1276
1277
1278
1279
1280
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1272

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



1531
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1531

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)



549
550
551
552
553
554
555
556
557
558
559
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 549

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)


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
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 391

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, FuelOil#1, FuelOil#2,
  # Coal, Diesel, Gasoline, DistrictHeating,
  # and SolarEnergy.
  htg_fuels = thermal_zone.heating_fuels

  if htg_fuels.include?('NaturalGas') ||
     htg_fuels.include?('PropaneGas') ||
     htg_fuels.include?('FuelOil#1') ||
     htg_fuels.include?('FuelOil#2') ||
     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



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
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 428

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?('FuelOil#1') ||
     htg_fuels.include?('FuelOil#2') ||
     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.Model', "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



1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1510

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, occupied_percentage_threshold = 0.05) ⇒ ScheduleRuleset

TODO:

Speed up this method. Bottleneck is ScheduleRule.getDaySchedules

This method creates a schedule where the value is zero when the overall occupancy for 1 zone is below the specified threshold, and one when the overall occupancy is greater than or equal to the threshold. This method is designed to use the total number of people in the zone.

Parameters:

  • 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



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
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 143

def thermal_zone_get_occupancy_schedule(thermal_zone, occupied_percentage_threshold = 0.05)
  # Get all the occupancy schedules in every space in the zone
  # Include people added via the SpaceType
  # in addition to people hard-assigned to the Space itself.
  occ_schedules_num_occ = {}
  max_occ_on_thermal_zone = 0

  # Get the people objects
  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_on_thermal_zone += 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_on_thermal_zone += num_ppl
      end
    end
  end

  # For each day of the year, determine
  # time_value_pairs = []
  year = thermal_zone.model.getYearDescription
  yearly_data = []
  yearly_times = OpenStudio::DateTimeVector.new
  yearly_values = []
  (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
    occ_schedules_day_schs = {}
    day_sch_num_occ = {}
    occ_schedules_num_occ.each do |occ_sch, num_occ|
      # Get the day schedules for this day
      # (there should only be one)
      day_schs = occ_sch.getDaySchedules(os_date, os_date)
      day_schs[0].times.each do |time|
        times_on_this_day << time.toString
      end
      day_sch_num_occ[day_schs[0]] = num_occ
    end

    # Determine the total fraction for the airloop 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)
      os_date_time = OpenStudio::DateTime.new(os_date, os_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 airloop at each time
      thermal_zone_occ_frac = tot_occ_at_time / max_occ_on_thermal_zone
      occ_status = 0 # unoccupied
      if thermal_zone_occ_frac >= occupied_percentage_threshold
        occ_status = 1
      end

      # Add this data to the daily arrays
      daily_times << time
      daily_os_times << os_time
      daily_values << occ_status
      daily_occs << thermal_zone_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
  sch_name = "#{thermal_zone.name} Occ Sch"
  sch_ruleset = OpenStudio::Model::ScheduleRuleset.new(thermal_zone.model)
  sch_ruleset.setName(sch_name.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(thermal_zone.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(thermal_zone.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_occs = daily_data['daily_occs']

      # 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

      daily_os_times = daily_data['daily_os_times']
      daily_occs = daily_data['daily_occs']

      # If here, we need to make a rule to cover from the previous
      # rule to today

      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, l|
        value = values[l]
        next if value == values[l + 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)
      sch_rule.setEndDate(date)

      # 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

  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



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
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 710

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



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
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 569

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



1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1286

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)


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.ThermalZone.rb', line 493

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, FuelOil#1, FuelOil#2,
  # 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?('FuelOil#1') ||
     htg_fuels.include?('FuelOil#2') ||
     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.Model', "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.Model', "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.Model', "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.Model', "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



1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1312

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 obects in all spaces in the zone.

Returns:

  • (Double)

    the zone outdoor air flow rate @units cubic meters per second (m^3/s)



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 11

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.Model', "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



982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 982

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



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
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1153

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



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
# File 'lib/openstudio-standards/standards/Standards.ThermalZone.rb', line 1096

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)


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.ThermalZone.rb', line 358

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

#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



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
# File 'lib/openstudio-standards/standards/Standards.WaterHeaterMixed.rb', line 11

def water_heater_mixed_apply_efficiency(water_heater_mixed)
  # 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
  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 = volume_m3.get
  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.BoilerHotWater', "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
      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
      cap = 75_000.0
      re = (Math.sqrt(6724 * ef**2 * cap**2 + 40_409_100 * ef**2 * cap - 28_080_900 * ef * cap + 29_318_000_625 * ef**2 - 58_636_001_250 * ef + 29_318_000_625) + 82 * ef * cap + 171_225 * ef - 171_225) / (200 * ef * cap)
      # Calculate the skin loss coefficient (UA)
      # based on the actual capacity.
      ua_btu_per_hr_per_f = (water_heater_eff - re) * capacity_btu_per_hr / 67.5
    end
  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
    # 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 = sl_btu_per_hr / 70
  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
    # 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
    # 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']
    # Calculate the max allowable standby loss (SL)
    sl_btu_per_hr = (capacity_btu_per_hr / sl_cap_adj + sl_vol_drt * Math.sqrt(volume_gal))
    # 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 + capacity_btu_per_hr * et) / capacity_btu_per_hr
  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

  # 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.8)

  # 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.model.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.



182
183
184
185
# File 'lib/openstudio-standards/standards/Standards.WaterHeaterMixed.rb', line 182

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



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/openstudio-standards/standards/Standards.WaterHeaterMixed.rb', line 190

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 (PTACs, PTHPs, Fan Coils, and Unit Heaters) based on the W/cfm specified in the standard.

Returns:

  • (Bool)

    returns true if successful, false if not



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
# File 'lib/openstudio-standards/standards/Standards.ZoneHVACComponent.rb', line 9

def zone_hvac_component_apply_prm_baseline_fan_power(zone_hvac_component)
  OpenStudio.logFree(OpenStudio::Debug, 'openstudio.model.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
              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 = 0.3

  # 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.model.ZoneHVACComponent', "For #{zone_hvac_component.name}: fan efficacy set to #{fan_efficacy_new_w_per_cfm.round(2)} W/cfm.")

  return true
end