Skip to content
Merged
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: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ bundle exec boss help [COMMAND]
- `-w`, `--epw_path` (optional): path to a weather `.epw` file, relative to the current working directory or absolute; BOSS stores it as an absolute path in the generated OSW. If omitted, BOSS derives weather from the BuildingSync file when possible
- `-v`, `--standard_version` (optional): modeling standard used by BOSS, such as `ASHRAE90.1` or `CaliforniaTitle24` (defaults to `ASHRAE90.1`)
- `-r`, `--run` (optional, `write_baseline_osw` only): run the baseline workflow after writing the OSW
- `--require_l200` (optional, `write_baseline_osw` only): fail instead of falling back to `create_typical_building_from_model` HVAC when the BuildingSync HVAC records cannot be mapped to the split HVAC measures
- `--[no-]allow_approximations` (optional, `write_baseline_osw` only, default on): accept HVAC records that BOSS models by policy or as an approximation, such as ComStock heat or energy recovery, and log them as warnings. `--no-allow_approximations` keeps the mapping document's blocking rules for those records. Records that name no separate ventilation equipment or integrate outdoor air with the conditioning system do not block when their `LinkedDeliveryIDs` resolve to conditioned deliveries (mapping document rows 88 and 89). Every note is listed in `baseline/hvac_mapping_report.json`. Combine `--no-allow_approximations --require_l200` for a run that uses the audited HVAC exactly as the mapping document allows, or fails

### CLI Example: Write a baseline OSW

Expand Down
57 changes: 45 additions & 12 deletions lib/BOSS/baseline_hvac_planner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,37 @@ class BaselineHvacPlanner
RECOVERY_HOST_MEASURES = ['hvac_packaged_rooftop_ac', 'hvac_packaged_rooftop_heat_pump', 'hvac_warm_air_furnace',
'hvac_packaged_rooftop_vav_hw_reheat', 'hvac_vav_hw_reheat'].freeze

Plan = Struct.new(:status, :steps, :messages, keyword_init: true) do
WARN_BASES = [:policy, :approximation].freeze

# messages are the fallback reasons (empty on a topology plan). notes are the selector results
# worth reporting on either path: non-blocking records, and matches that carry a basis or a message.
Plan = Struct.new(:status, :steps, :messages, :notes, keyword_init: true) do
def initialize(notes: [], **members)
super(notes:, **members)
end

def topology? = status == :topology

# Notes deduplicated by configuration, status, basis and text, listing every record ID.
# A match on a fallback plan built nothing, so it is marked as not applied.
# @return [Array<Hash>] { level: :info | :warn, basis:, applied:, text: }
def note_entries
notes.group_by { |n| [n.configuration || n.hvac_system_id, n.status, n.basis, n.messages] }.map do |(label, status, basis, messages), members|
applied = members.first.status != :match || topology?
kind = [status, basis].compact.join(', ')
ids = members.flat_map(&:record_ids).uniq
text = "#{label} (#{kind}; #{ids.join(', ')}): #{messages.join(' ')}"
text += ' (not applied)' unless applied
{ level: WARN_BASES.include?(basis) ? :warn : :info, basis:, applied:, text: }
end
end
end

def initialize(selector: HvacTopologySelector.new, binder: HvacTargetBinder.new)
@selector = selector
# @param selector [HvacTopologySelector, nil] defaults to one built with allow_approximations
# @param allow_approximations [Boolean] whether records BOSS accepts by policy or as an
# approximation are allowed; when false they keep the mapping doc's blocking status
def initialize(selector: nil, binder: HvacTargetBinder.new, allow_approximations: true)
@selector = selector || HvacTopologySelector.new(allow_approximations:)
@binder = binder
end

Expand All @@ -59,15 +84,21 @@ def plan(hvac_systems, standards_template, operation: 'create', include_system_i
end
return fallback(['No HVACSystem records.']) if results.empty?

unmatched = results.reject { |result| result.status == :match }
return fallback(unmatched.map { |result| describe(result, result.status, result.messages) }) if !unmatched.empty?
# Notes are collected before merge, which keeps only the first member of a group.
notes = results.select { |result| !result.blocking? || (result.status == :match && (result.basis || !result.messages.empty?)) }
matches = results.select { |result| result.status == :match }
blocking = results.select { |result| result.status != :match && result.blocking? }
return fallback(blocking.map { |result| describe(result, result.status, result.messages) }, notes) if !blocking.empty?

recovery, results = results.partition { |result| result.measure == RECOVERY_MEASURE }
recovery, results = matches.partition { |result| result.measure == RECOVERY_MEASURE }
groups = results.group_by { |result| [result.measure, result.measure_arguments || {}] }.values
.map { |members| merge(members, hvac_systems) }
ventilation, conditioning = groups.partition { |result| VENTILATION_MEASURES.include?(result.measure) }
problems = []
if conditioning.length != 1
if conditioning.empty?
only_notes = ventilation.empty? && recovery.empty?
problems << "Expected one conditioning configuration, found 0#{'; the HVAC records carry only notes' if only_notes}."
elsif conditioning.length > 1
problems << "Expected one conditioning configuration, found #{conditioning.length}; " \
'zone-level binding is not supported.'
end
Expand All @@ -77,19 +108,21 @@ def plan(hvac_systems, standards_template, operation: 'create', include_system_i
"#{conditioning.first.configuration} air loops."
end
problems += recovery_problems(recovery, results, conditioning, ventilation, hvac_systems) if !recovery.empty?
return fallback(problems) if !problems.empty?
return fallback(problems, notes) if !problems.empty?

bindings = conditioning.map { |result| [result, @binder.bind(result, operation:, standards_template:)] } +
ventilation.map { |result| [result, @binder.bind(result, operation: 'create', standards_template:)] }
unbound = bindings.reject { |_, binding| binding.status == :bound }
return fallback(unbound.map { |result, binding| describe(result, binding.status, binding.messages) }) if !unbound.empty?
if !unbound.empty?
return fallback(unbound.map { |result, binding| describe(result, binding.status, binding.messages) }, notes)
end

sizing_step = { measure_dir_name: SIZING_MEASURE, arguments: { standards_template: } }
steps = bindings.map { |_, binding| binding.step } + [sizing_step]
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: (results + recovery).flat_map(&:messages).uniq)
Plan.new(status: :topology, steps:, messages: [], notes:)
end

# @return [Array<String>] HVACSystem IDs that measures name as alternatives or modified systems
Expand Down Expand Up @@ -185,8 +218,8 @@ def merge(members, hvac_systems)
merged
end

def fallback(messages)
Plan.new(status: :fallback, steps: [], messages:)
def fallback(messages, notes = [])
Plan.new(status: :fallback, steps: [], messages:, notes:)
end

def describe(result, status, messages)
Expand Down
20 changes: 14 additions & 6 deletions lib/BOSS/boss.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ class Boss
# @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
# @param allow_approximations [Boolean] allow HVAC records BOSS accepts by policy or as an
# approximation (logged at WARN); false keeps the mapping doc's blocking status for them
class << self
def write_baseline_osw(xml_file_path, output_dir, epw_file_path, standard_to_be_used, require_l200: false)
def write_baseline_osw(xml_file_path, output_dir, epw_file_path, standard_to_be_used, require_l200: false,
allow_approximations: true)
# check file exists
if !File.exist?(xml_file_path)
message = "File '#{xml_file_path}' does not exist"
Expand All @@ -37,7 +40,7 @@ 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)

hvac_plan = plan_baseline_hvac(bsync_reader)
hvac_plan = plan_baseline_hvac(bsync_reader, allow_approximations:)
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)
Expand All @@ -52,8 +55,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 }
report = { status: hvac_plan.status, allow_approximations:,
hvac_steps: hvac_plan.steps.map { |step| step[:measure_dir_name] },
messages: hvac_plan.messages, notes: hvac_plan.note_entries }
File.write(File.join(workflow_dir, 'hvac_mapping_report.json'), JSON.pretty_generate(report))
osw_path
end
Expand Down Expand Up @@ -81,9 +85,9 @@ def run_baseline_osw(osw_dir)

private

def plan_baseline_hvac(bsync_reader)
def plan_baseline_hvac(bsync_reader, allow_approximations: true)
hvac_systems = bsync_reader.get_hvac_systems_xml
BaselineHvacPlanner.new
BaselineHvacPlanner.new(allow_approximations:)
.plan(hvac_systems, bsync_reader.get_standard_template,
exclude_system_ids: BaselineHvacPlanner.proposed_system_ids(hvac_systems))
end
Expand All @@ -108,6 +112,10 @@ def build_baseline_osw(bsync_reader, hvac_plan: plan_baseline_hvac(bsync_reader)
BOSS.BOSS_logger.warn("BOSS.Boss: Keeping create_typical_building_from_model HVAC: #{message}")
end
end
# Interim note logging; D4 moves this into the planning log block.
hvac_plan.note_entries.each do |note|
BOSS.BOSS_logger.send(note[:level], "BOSS.Boss: HVAC note: #{note[:text]}")
end

OSWArgPopulator::populate_set_lighting_loads_by_LPD_args(baseline_osw, bsync_reader)
OSWArgPopulator::populate_set_electric_equipment_loads_by_epd_args(baseline_osw, bsync_reader)
Expand Down
Loading
Loading