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
32 changes: 26 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

env:
# Pinned commit of the sibling checkout that config/external_measure_repos.yml loads via local_path.
BSYNC_MEASURES_REF: 789bd50ec0ba42559f85e5cac23fcbbf8f9bdfbe

jobs:
unit:
name: unit
Expand All @@ -38,11 +42,16 @@ jobs:
uses: actions/checkout@v4
with:
repository: BuildingSync/buildingsync-measures-gem
ref: 789bd50ec0ba42559f85e5cac23fcbbf8f9bdfbe
ref: ${{ env.BSYNC_MEASURES_REF }}
path: buildingsync-measures-gem
- name: Cache gems
uses: actions/cache@v4
with:
path: .bundle/install
key: gems-${{ runner.os }}-os3.10.0-${{ hashFiles('BOSS/Gemfile.lock', 'BOSS/*.gemspec') }}
- name: Setup
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config --global --add safe.directory '*'
gem install bundler -v 2.4.10
bundle config set --local path "$GITHUB_WORKSPACE/.bundle/install"
bundle install
Expand Down Expand Up @@ -97,19 +106,30 @@ jobs:
LC_ALL: C.UTF-8
BOSS_SHARD: ${{ matrix.shard }}
BOSS_SHARDS: '4'
defaults:
run:
working-directory: BOSS
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
path: BOSS
- name: Checkout buildingsync-measures-gem
uses: actions/checkout@v4
with:
repository: BuildingSync/buildingsync-measures-gem
ref: ${{ env.BSYNC_MEASURES_REF }}
path: buildingsync-measures-gem
- name: Cache gems
uses: actions/cache@v4
with:
path: .bundle/install
key: gems-${{ runner.os }}-os3.10.0-${{ hashFiles('Gemfile.lock', '*.gemspec') }}
key: gems-${{ runner.os }}-os3.10.0-${{ hashFiles('BOSS/Gemfile.lock', 'BOSS/*.gemspec') }}
- name: Cache external measures
uses: actions/cache@v4
with:
path: vendor/external_measures
key: ext-measures-${{ hashFiles('config/external_measure_repos.yml') }}
path: BOSS/vendor/external_measures
key: ext-measures-${{ hashFiles('BOSS/config/external_measure_repos.yml') }}
- name: Setup
run: |
git config --global --add safe.directory '*'
Expand All @@ -124,4 +144,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: integration-output-shard-${{ matrix.shard }}
path: spec/output
path: BOSS/spec/output
9 changes: 8 additions & 1 deletion docs/scenario_workflow_translation_plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,19 @@ Use this roadmap as the tracker. Keep `Status` and `Delivered by` current when a

### PR 14E: Scenario HVAC Mappings

- Status: Planned
- Status: In progress (series close pending)
- Delivered by: -
- Depends on: PR 14D.
- Scope: Map HVAC retrofit measures onto the steps `HvacTargetBinder` already produces (`bind` for topology `replace`, `bind_modifier` for `modify_existing_*`) through the PR 9 result contract. No new binding work belongs here. Order conditioning, then DOAS/ventilation, then modifiers. Keep existing economizer, DCV, and thermostat mappings from other gems.
- Done when: One topology replacement and one modifier case run end to end, partial shared-system replacement is rejected, and mixed-source packages still write and run.
- Avoid: Mapping "Replace boiler" or "Replace burner" to an efficiency edit, guessing values, or partial HVAC graphs.
- Decision: `BOSS::ScenarioHvacPlanner` (`lib/BOSS/scenario_hvac_planner.rb`) runs before the JSON map in `ScenarioMeasureMapper.map_measure`. It returns `:mapped` (its steps replace the JSON lookup), `:unmapped` (`hvac_measure_unmapped` warning; the scenario is skipped), or `:not_hvac` (fall through to the JSON map). It tries, in order:
- Replacement: the measure's `TechnologyCategories` reference `ExistingSystemReplaced` and `AlternativeSystemReplacement` HVACSystem IDrefs. `BaselineHvacPlanner#plan` reruns on the alternative systems with `operation: 'replace'` for conditioning (ventilation stays `create`). Every baseline HVACSystem must be in `ExistingSystemReplaced`; otherwise the measure is unmapped as a partial replacement.
- Modification: `ExistingSystemAffected` plus a `ModifiedSystem` HVACSystem. Efficiencies come from the modified system and bind through `bind_modifier` into the new `hvac_modifiers` phase (after `hvac_equipment`). DX cooling COP, heat pump heating COP, furnace `Thermal Efficiency`, and electric resistance map; other units (EER, SEER, AFUE, HSPF, kW/ton) are unmapped with no unit conversion.
- Named topology: with no IDrefs, only `Install variable refrigerant flow system` maps (VRF replace on the measure's premises, then sizing). This deviates from the 14B MeasureName rule with user approval; GSHP stays a mapping gap.
- Decision: proposed systems (`AlternativeSystemReplacement`/`ModifiedSystem` IDrefs) are excluded from baseline HVAC planning. `write_baseline_and_scenario_osws` accepts `hvac_retrofit_template:` (one of `HvacTargetBinder::STANDARDS_TEMPLATES`), defaulting to the baseline template.
- Fixture: `spec/files/v2.7.0/example-smalloffice-level2-hvac-retrofits.xml` adds proposed RTU and COP systems and scenarios `Scenario-POM-HVAC-RTU` (replacement), `-COP` (modifier), `-VRF` (named), and `-mixed` (COP modifier plus LEDs). `write_and_run_osws_spec.rb` writes and runs them.
- Limitations: a modifier and a replacement in the same package can target equipment the replacement removed, and `apply_hvac_modifier_to_object_scope` fails when nothing matches; such packages are not guarded yet. The named VRF replacement adds no DOAS.
- Series close: merge the `buildingsync-measures-gem` branch upstream (`apply_hvac_topology_to_zone_scope`, `apply_standard_hvac_sizing_and_efficiency`, and any 14E measures), replace the CI branch-commit pin with the merged commit, and rerun the unit and integration suites.

### PR 15: CLI Command
Expand Down
40 changes: 25 additions & 15 deletions lib/BOSS/baseline_hvac_planner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,22 @@ def initialize(selector: HvacTopologySelector.new, binder: HvacTargetBinder.new)

# @param hvac_systems [REXML::Element, nil] the facility HVACSystems element
# @param standards_template [String] baseline create_typical template
# @param operation [String] binder operation for the conditioning step; ventilation is always created
# @param include_system_ids [Array<String>, nil] when given, only these HVACSystems are planned
# @param exclude_system_ids [Array<String>] HVACSystems left out, such as proposed scenario systems
# @return [Plan] :topology with ordered OSW steps, or :fallback with the reasons
def plan(hvac_systems, standards_template)
def plan(hvac_systems, standards_template, operation: 'create', include_system_ids: nil, exclude_system_ids: [])
return fallback(['No HVACSystems in the facility.']) if hvac_systems.nil?

if !HvacTargetBinder::STANDARDS_TEMPLATES.include?(standards_template)
return fallback(["Template '#{standards_template}' is not supported by the split HVAC measures " \
"(#{HvacTargetBinder::STANDARDS_TEMPLATES.join(', ')})."])
end

results = @selector.select(hvac_systems)
results = @selector.select(hvac_systems).select do |result|
(include_system_ids.nil? || include_system_ids.include?(result.hvac_system_id)) &&
!exclude_system_ids.include?(result.hvac_system_id)
end
return fallback(['No HVACSystem records.']) if results.empty?

unmatched = results.reject { |result| result.status == :match }
Expand All @@ -65,33 +71,28 @@ def plan(hvac_systems, standards_template)
end
return fallback(problems) if !problems.empty?

bindings = (conditioning + ventilation).map do |result|
[result, @binder.bind(result, operation: 'create', standards_template:)]
end
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?

sizing_step = { measure_dir_name: SIZING_MEASURE, arguments: { standards_template: } }
Plan.new(status: :topology, steps: bindings.map { |_, binding| binding.step } + [sizing_step], messages: [])
end

private

def merge(members, hvac_systems)
merged = members.first.dup
merged.premises = members.flat_map { |member| member.premises || [] }.uniq
building_id = covered_building_id(merged.premises, hvac_systems)
merged.premises = [{ type: 'Building', id: building_id }] if building_id
merged
# @return [Array<Hash>] premises, or one Building premise when Section links cover the building
def self.normalize_premises(premises, document)
building_id = covered_building_id(premises, document)
building_id ? [{ type: 'Building', id: building_id }] : premises
end

# @return [String, nil] the building ID when every premise is a Section of the one
# building and they include its 'Whole building' section or all of its other
# non-empty sections
def covered_building_id(premises, hvac_systems)
def self.covered_building_id(premises, document)
return nil if premises.empty? || !premises.all? { |premise| premise[:type] == 'Section' }

buildings = REXML::XPath.match(hvac_systems.document, "//*[local-name()='Building'][@ID]")
buildings = REXML::XPath.match(document, "//*[local-name()='Building'][@ID]")
return nil if buildings.length != 1

sections = REXML::XPath.match(buildings.first, "*[local-name()='Sections']/*[local-name()='Section'][@ID]")
Expand All @@ -109,6 +110,15 @@ def covered_building_id(premises, hvac_systems)
whole_linked || parts_linked ? buildings.first.attributes['ID'] : nil
end

private

def merge(members, hvac_systems)
merged = members.first.dup
merged.premises = self.class.normalize_premises(members.flat_map { |member| member.premises || [] }.uniq,
hvac_systems.document)
merged
end

def fallback(messages)
Plan.new(status: :fallback, steps: [], messages:)
end
Expand Down
18 changes: 15 additions & 3 deletions lib/BOSS/boss.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
require 'BOSS/external_measure_repo_manager'
require 'BOSS/scenario_measure_mapper'
require 'BOSS/baseline_hvac_planner'
require 'BOSS/scenario_hvac_planner'

require 'openstudio/common_measures'
require 'openstudio/model_articulation'
Expand Down Expand Up @@ -59,7 +60,14 @@ def write_baseline_osw(xml_file_path, output_dir, epw_file_path, standard_to_be_
# @return [Hash] { baseline_osw_path:, scenario_results: [ { scenario_id:, scenario_name:,
# report_id:, package_id:, status: :written | :skipped, osw_path:, skipped_measure_ids:,
# warnings: } ], parser_warnings: }
def write_baseline_and_scenario_osws(xml_file_path, output_dir, epw_file_path, standard_to_be_used)
# @param hvac_retrofit_template [String, nil] standards template for scenario HVAC retrofits;
# defaults to the baseline template
def write_baseline_and_scenario_osws(xml_file_path, output_dir, epw_file_path, standard_to_be_used,
hvac_retrofit_template: nil)
if !hvac_retrofit_template.nil? && !HvacTargetBinder::STANDARDS_TEMPLATES.include?(hvac_retrofit_template)
raise ArgumentError, "hvac_retrofit_template must be one of #{HvacTargetBinder::STANDARDS_TEMPLATES.join(', ')}"
end

if !File.exist?(xml_file_path)
message = "File '#{xml_file_path}' does not exist"
OpenStudio.logFree(OpenStudio::Error, 'BOSS.write_baseline_and_scenario_osws', message)
Expand Down Expand Up @@ -93,6 +101,8 @@ def write_baseline_and_scenario_osws(xml_file_path, output_dir, epw_file_path, s
measures = bsync_reader.get_measures
scenarios = bsync_reader.get_package_measure_scenarios
id_warnings = scenario_output_id_warnings(scenarios)
hvac_planner = ScenarioHvacPlanner.new(bsync_reader.get_hvac_systems_xml, bsync_doc,
hvac_retrofit_template || bsync_reader.get_standard_template)

scenario_results = []
scenario_osws = []
Expand All @@ -107,7 +117,7 @@ def write_baseline_and_scenario_osws(xml_file_path, output_dir, epw_file_path, s
next
end

mapped = mapper.map_package_scenario(scenario, measures, context:)
mapped = mapper.map_package_scenario(scenario, measures, context:, hvac_planner:)
result = mapped.slice(:scenario_id, :scenario_name, :report_id, :package_id)
.merge(status: :skipped, osw_path: nil,
skipped_measure_ids: mapped[:skipped_measure_ids], warnings: mapped[:warnings])
Expand Down Expand Up @@ -202,7 +212,9 @@ 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_plan = BaselineHvacPlanner.new.plan(bsync_reader.get_hvac_systems_xml, bsync_reader.get_standard_template)
hvac_systems = bsync_reader.get_hvac_systems_xml
hvac_plan = BaselineHvacPlanner.new.plan(hvac_systems, bsync_reader.get_standard_template,
exclude_system_ids: ScenarioHvacPlanner.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
Loading
Loading