Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ concurrency:
env:
# Pinned commit (buildingsync-measures-gem add-comstock-erv-preset, adds comstock_erv) of the
# sibling checkout that config/external_measure_repos.yml loads via local_path.
BSYNC_MEASURES_REF: 483efc02b5a6c2f1386afd9cae45b72ab4b0a37d
BSYNC_MEASURES_REF: 6ee630f71d5da01df79a2c0dab40b1e978c51556

jobs:
unit:
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ BOSS also falls back when:

On fallback, BOSS uses the `system_type` mapping below with `add_hvac` set to `true`, and logs a warning explaining why.

#### Central furnace with cooling-only PTACs

An HVACSystem whose heating and cooling are delivered separately maps to the gem's `hvac_heating_with_terminal_cooling` measure (`heating_source` `central_gas_furnace`). This is read from standard BuildingSync elements only:

- one Delivery with `CentralAirDistribution` that references only a gas `Furnace` HeatingSource (`HeatingMedium` `Air`);
- one Delivery with `ZoneEquipment` that references only a CoolingSource whose `DXSystemType` is `Packaged terminal air conditioner (PTAC)`;
- both serve the same premises. A `MechanicalVentilation` record without a `VentilationType` linked only to these deliveries is treated as an annotation.

The heating-only Delivery may instead be `ZoneEquipment/Convection` with `ConvectionType` `Perimeter baseboard`, heated by `ElectricResistance` (`electric_baseboard`) or by a `SourceHeatingPlantID` whose plant has `Boiler/BoilerType` `Hot water` (`hot_water_baseboard`, `boiler_fuel` from the plant `PrimaryFuel`). A single `ZoneEquipment` Delivery that references both the PTAC CoolingSource and such a hot-water HeatingSource maps to `hot_water_ptac_coil`.

See `spec/files/v2.7.0/l200_hvac/Example_NYC_Energy_Efficiency_Report_Property_2_l200.xml`, which restates the user-defined fields of `spec/files/v2.7.0/Example_NYC_Energy_Efficiency_Report_Property_2.xml` as standard elements. BOSS writes `baseline/hvac_mapping_report.json` with the plan status, the HVAC steps, and the messages. Add `--require_l200` (`require_l200: true`) to raise an error instead of falling back.

```bash
bundle exec boss write_baseline_osw my_buildingsync.xml -o ./output_dir --require_l200
```

Integration simulations currently cover the packaged rooftop heat pump, with and without recovery (`Example_ASHRAE_L2_Report_l200_erv.xml`, an edited derivative of `Example_ASHRAE_L2_Report.xml`); the other configurations are covered by unit specs.

## OpenStudio Compatibility Version
Expand Down
11 changes: 10 additions & 1 deletion lib/BOSS/baseline_hvac_planner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def plan(hvac_systems, standards_template, operation: 'create', include_system_i
steps << { measure_dir_name: RECOVERY_MEASURE, arguments: {} } if !recovery.empty?
# ComStock picks HRV or ERV by climate zone; an audited ERV gets ComStock's ERV values.
steps << ERV_STEP if recovery.any? { |r| r.measure_arguments['ventilation_type'] == ERV_TYPE }
Plan.new(status: :topology, steps:, messages: [])
Plan.new(status: :topology, steps:, messages: (results + recovery).flat_map(&:messages).uniq)
end

# @return [Array<String>] HVACSystem IDs that measures name as alternatives or modified systems
Expand All @@ -111,6 +111,15 @@ def self._system_ids(hvac_systems)

# @return [Array<Hash>] premises, or one Building premise when Section links cover the building
def self.normalize_premises(premises, document)
linked_buildings = premises.select { |premise| premise[:type] == 'Building' }
if linked_buildings.length == 1 && premises.length > 1
# A Building link already covers that building's Sections.
building_id = linked_buildings.first[:id]
section_ids = REXML::XPath.match(document, "//*[local-name()='Building'][@ID='#{building_id}']" \
"/*[local-name()='Sections']/*[local-name()='Section']/@ID").map(&:value)
others = premises - linked_buildings
return linked_buildings if others.all? { |premise| premise[:type] == 'Section' && section_ids.include?(premise[:id]) }
end
building_id = covered_building_id(premises, document)
building_id ? [{ type: 'Building', id: building_id }] : premises
end
Expand Down
26 changes: 20 additions & 6 deletions lib/BOSS/boss.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ class Boss
# @param output_dir [String]
# @param epw_file_path [String] if provided, full/path/to/my.epw
# @param standard_to_be_used [String]
# @param require_l200 [Boolean] raise instead of falling back to create_typical HVAC
class << self
def write_baseline_osw(xml_file_path, output_dir, epw_file_path, standard_to_be_used)
def write_baseline_osw(xml_file_path, output_dir, epw_file_path, standard_to_be_used, require_l200: false)
# check file exists
if !File.exist?(xml_file_path)
message = "File '#{xml_file_path}' does not exist"
Expand All @@ -36,7 +37,13 @@ def write_baseline_osw(xml_file_path, output_dir, epw_file_path, standard_to_be_
bsync_doc = REXML::Document.new(xml_data, ignore_whitespace_nodes: :all)
bsync_reader = BOSS::BuildingSyncReader.new(bsync_doc, epw_file_path, standard_to_be_used)

baseline_osw = build_baseline_osw(bsync_reader)
hvac_plan = plan_baseline_hvac(bsync_reader)
if require_l200 && !hvac_plan.topology?
message = "L200 HVAC topology required but the baseline would fall back: #{hvac_plan.messages.join(' ')}"
OpenStudio.logFree(OpenStudio::Error, 'BOSS.write_baseline_osw', message)
raise message
end
baseline_osw = build_baseline_osw(bsync_reader, hvac_plan:)

# write to file
workflow_dir = File.join(output_dir, 'baseline')
Expand All @@ -45,6 +52,9 @@ def write_baseline_osw(xml_file_path, output_dir, epw_file_path, standard_to_be_
File.open(osw_path, 'w') do |file|
file << JSON.pretty_generate(baseline_osw)
end
report = { status: hvac_plan.status, hvac_steps: hvac_plan.steps.map { |step| step[:measure_dir_name] },
messages: hvac_plan.messages }
File.write(File.join(workflow_dir, 'hvac_mapping_report.json'), JSON.pretty_generate(report))
osw_path
end

Expand All @@ -71,8 +81,15 @@ def run_baseline_osw(osw_dir)

private

def plan_baseline_hvac(bsync_reader)
hvac_systems = bsync_reader.get_hvac_systems_xml
BaselineHvacPlanner.new
.plan(hvac_systems, bsync_reader.get_standard_template,
exclude_system_ids: BaselineHvacPlanner.proposed_system_ids(hvac_systems))
end

# Returns a new, unsaved baseline OSW hash for the given reader.
def build_baseline_osw(bsync_reader)
def build_baseline_osw(bsync_reader, hvac_plan: plan_baseline_hvac(bsync_reader))
# start with an empty baseline workflow
file = File.read(EMPTY_BASELINE_OSW_PATH)
baseline_osw = JSON.parse(file, symbolize_names: true)
Expand All @@ -82,9 +99,6 @@ def build_baseline_osw(bsync_reader)
OSWArgPopulator::populate_change_building_location_args(baseline_osw, bsync_reader)

OSWArgPopulator::populate_create_bar_from_building_type_ratios_args(baseline_osw, bsync_reader)
hvac_systems = bsync_reader.get_hvac_systems_xml
hvac_plan = BaselineHvacPlanner.new.plan(hvac_systems, bsync_reader.get_standard_template,
exclude_system_ids: BaselineHvacPlanner.proposed_system_ids(hvac_systems))
OSWArgPopulator::populate_create_typical_building_from_model_args(baseline_osw, bsync_reader,
add_hvac: !hvac_plan.topology?)
if hvac_plan.topology?
Expand Down
121 changes: 118 additions & 3 deletions lib/BOSS/hvac_topology_selector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ def fan_based_distribution(el)
nodes(el, 'FanBased/FanBasedDistributionType').any? { |n| !n.elements.to_a.empty? }
end

# @return [String, nil] boiler_fuel argument when the source is fed by a hot-water boiler plant
def hot_water_boiler_fuel
return nil if hp.nil? || !eq(hp, 'Boiler/BoilerType', 'Hot water') || !guard(hs, 'HeatingMedium', 'Hot water')

fuels = self.class.texts(hp, 'PrimaryFuel')
fuels.length == 1 ? BOILER_FUELS[fuels.first] : nil
end

def ptac_cooling
eq(dx, 'DXSystemType', 'Packaged terminal air conditioner (PTAC)') && packaged_air_cooled_dx
end

def gas_air_furnace
exists(h, 'Furnace') && eq(hs, 'PrimaryFuel', 'Natural gas') && eq(hs, 'HeatingMedium', 'Air')
end
Expand All @@ -190,6 +202,9 @@ def conditioned
end

ELECTRIC = 'Electricity'
# BuildingSync PrimaryFuel => hvac_heating_with_terminal_cooling boiler_fuel
BOILER_FUELS = { 'Natural gas' => 'NaturalGas', 'Electricity' => 'Electricity',
'Fuel oil no 2' => 'FuelOilNo2', 'Propane' => 'Propane' }.freeze
AIR_REFRIGERANT = ['Air', 'Refrigerant'].freeze
FURNACE_TYPES = ['Warm air', 'Other'].freeze
# HeatPumpBackupSystemFuel => hvac_packaged_rooftop_heat_pump supplemental_heating_fuel
Expand All @@ -214,6 +229,20 @@ def conditioned
]
}
},
{
configuration: 'PTAC with hot water coil', measure: 'hvac_heating_with_terminal_cooling', status: :match,
group: :delivery,
required: ->(x) { x.zone_equipment_only && x.ptac_cooling && !x.hot_water_boiler_fuel.nil? },
arguments: ->(x) { { 'heating_source' => 'hot_water_ptac_coil', 'boiler_fuel' => x.hot_water_boiler_fuel } },
absent: ->(x) { x.fan_based_distribution(x.z) ? ['Z/FanBased/FanBasedDistributionType'] : [] },
guards: lambda { |x|
[
['CS/PrimaryFuel', x.guard(x.cs, 'PrimaryFuel', ELECTRIC)],
['CS/CoolingMedium', x.guard(x.cs, 'CoolingMedium', AIR_REFRIGERANT)],
['plant quantities', x.plant_quantities_one(x.hp)]
]
}
},
{
configuration: 'Four Pipe Fan Coil Unit', measure: 'hvac_four_pipe_fan_coil', status: :match, group: :plants,
required: lambda { |x|
Expand Down Expand Up @@ -483,6 +512,13 @@ def self.central_air_absent(x)
failed
end

TERMINAL_COOLING_MEASURE = 'hvac_heating_with_terminal_cooling'
TERMINAL_COOLING_CONFIGURATIONS = {
'central_gas_furnace' => 'Central furnace with cooling-only PTAC',
'hot_water_baseboard' => 'Hot water baseboard with cooling-only PTAC',
'electric_baseboard' => 'Electric baseboard with cooling-only PTAC'
}.freeze

# @param hvac_systems [REXML::Element] an HVACSystems element (or any parent of HVACSystem elements)
# @return [Array<Result>]
def select(hvac_systems)
Expand Down Expand Up @@ -521,9 +557,88 @@ def _select_system(sys)
end

folded = _economizer_folds(deliveries)
results = deliveries.reject { |d| ventilation_links.key?(d.attributes['ID']) || folded.key?(d.attributes['ID']) }
.map { |delivery| _select_delivery(sys, delivery, index) }
results + others.map { |other| _select_other(sys, other, index, ventilation_links, folded) }
open = deliveries.reject { |d| ventilation_links.key?(d.attributes['ID']) || folded.key?(d.attributes['ID']) }
pair, paired_ids = _heating_with_terminal_cooling(sys, open, index)
paired_ids ||= []
annotations, others = others.partition do |other|
links = Context.nodes(other, 'LinkedDeliveryIDs/LinkedDeliveryID').map { |l| l.attributes['IDref'] }
!paired_ids.empty? && _ventilation_annotation?(other) && !links.empty? && (links - paired_ids).empty?
end
unless annotations.empty?
pair.record_ids |= annotations.map { |o| o.attributes['ID'] }
pair.messages << 'MechanicalVentilation without a VentilationType names no separate ventilation equipment.'
end
results = open.reject { |d| paired_ids.include?(d.attributes['ID']) }
.map { |delivery| _select_delivery(sys, delivery, index) }
[pair].compact + results + others.map { |other| _select_other(sys, other, index, ventilation_links, folded) }
end

# The heating_with_terminal_cooling variant of a heating-only delivery, or nil.
def _separate_heating_variant(x)
return nil if x.hs.nil? || !x.ref_ids(x.d, 'CoolingSourceID').empty?
return 'central_gas_furnace' if !x.a.nil? && x.gas_air_furnace
return nil unless x.eq(x.z, 'Convection/ConvectionType', 'Perimeter baseboard')
return 'electric_baseboard' if x.exists(x.h, 'ElectricResistance')

'hot_water_baseboard' unless x.hot_water_boiler_fuel.nil?
end

# A heating-only delivery (central gas furnace, or hot-water or electric perimeter baseboard)
# plus a cooling-only zone-equipment delivery from PTACs, in the same HVACSystem and premises,
# is one heating_with_terminal_cooling configuration.
# @return [Array(Result, Array<String>), nil] the result and the delivery IDs it covers
def _heating_with_terminal_cooling(sys, deliveries, index)
contexts = deliveries.map { |d| Context.new(sys, d, index) }
return nil unless contexts.all? { |x| x.conflicts.empty? }

heating = contexts.filter_map { |x| (variant = _separate_heating_variant(x)) && [x, variant] }
cooling = contexts.select do |x|
!x.cs.nil? && x.ref_ids(x.d, 'HeatingSourceID').empty? && x.zone_equipment_only && x.ptac_cooling
end
return nil unless heating.length == 1 && cooling.length == 1

hx, variant = heating.first
cx = cooling.first
configuration = TERMINAL_COOLING_CONFIGURATIONS[variant]
delivery_ids = [hx.d, cx.d].map { |el| el.attributes['ID'] }
ids = delivery_ids + [hx.hs, cx.cs, hx.hp].compact.map { |el| el.attributes['ID'] }
premises = _premises(hx.d, sys)
order = ->(list) { list.sort_by { |p| [p[:type], p[:id]] } }
failures = []
failures << 'Missing LinkedPremises on Delivery or HVACSystem' if premises.empty?
failures << 'Heating and cooling deliveries must serve the same premises' if order.call(premises) != order.call(_premises(cx.d, sys))
failures << 'Z/FanBased/FanBasedDistributionType must be absent' if cx.fan_based_distribution(cx.z)
guards = [
['CS/PrimaryFuel', cx.guard(cx.cs, 'PrimaryFuel', ELECTRIC)],
['CS/CoolingMedium', cx.guard(cx.cs, 'CoolingMedium', AIR_REFRIGERANT)]
]
case variant
when 'central_gas_furnace'
failures += self.class.central_air_absent(hx).map { |p| "#{p} must be absent" }
guards += [
['A/AirDeliveryType', hx.guard(hx.a, 'AirDeliveryType', 'Central fan')],
['A/ReheatSource', hx.guard(hx.a, 'ReheatSource', 'None')],
['H/Furnace/FurnaceType', hx.guard(hx.h, 'Furnace/FurnaceType', FURNACE_TYPES)]
]
when 'electric_baseboard'
guards << ['HS/PrimaryFuel', hx.guard(hx.hs, 'PrimaryFuel', ELECTRIC)]
when 'hot_water_baseboard'
guards << ['plant quantities', hx.plant_quantities_one(hx.hp)]
end
guards.each { |name, ok| failures << "Guard failed: #{name}" unless ok }
sys_id = sys.attributes['ID']
unless failures.empty?
return [_result(:conflicting_input, sys_id, ids, premises, nil, failures, configuration:), delivery_ids]
end

arguments = { 'heating_source' => variant }
arguments['boiler_fuel'] = hx.hot_water_boiler_fuel if variant == 'hot_water_baseboard'
quantity = ->(record) { Context.texts(record, 'Quantity').first || '1' }
messages = ["Source inventory kept as recorded: #{hx.hs.attributes['ID']} quantity #{quantity.call(hx.hs)}, " \
"#{cx.cs.attributes['ID']} quantity #{quantity.call(cx.cs)}. Generated: one PTAC per model zone in scope."]
[_result(:match, sys_id, ids, premises, [:delivery_pair, *delivery_ids], messages,
configuration:, measure: TERMINAL_COOLING_MEASURE, measure_arguments: arguments),
delivery_ids]
end

ECONOMIZER_ONLY_CHILDREN = ['AirSideEconomizer', 'SupplyAirTemperatureResetControl', 'StaticPressureResetControl'].freeze
Expand Down
4 changes: 3 additions & 1 deletion lib/boss_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ class CLI < Thor
option :epw_path, :aliases => "-w", :desc => "path to weather file. If not given, one is derived from the BUILDINGSYNC_FILE."
option :standard_version, :aliases => "-v", :desc => "building standard to use (eg ASHRAE90.1 or CaliforniaTitle24). Defaults to ASHRAE90.1"
option :run, :aliases => "-r", :desc => "if set, will also run the baseline"
option :require_l200, :type => :boolean, :default => false, :desc => "fail instead of falling back to create_typical_building_from_model HVAC"
def write_baseline_osw(buildingsync_file)
standard_version = options[:standard_version] || ASHRAE90_1
osw_path = BOSS::Boss.write_baseline_osw(buildingsync_file, options[:output_path], options[:epw_path], standard_version)
osw_path = BOSS::Boss.write_baseline_osw(buildingsync_file, options[:output_path], options[:epw_path], standard_version,
require_l200: options[:require_l200])
puts "Baseline OSW written to: #{osw_path}"
if options[:run]
puts "running!"
Expand Down
Loading
Loading