diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc67b53..bbf00d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -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 '*' @@ -124,4 +144,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: integration-output-shard-${{ matrix.shard }} - path: spec/output + path: BOSS/spec/output diff --git a/docs/scenario_workflow_translation_plan.md b/docs/scenario_workflow_translation_plan.md index 8a24232..cd03bf7 100644 --- a/docs/scenario_workflow_translation_plan.md +++ b/docs/scenario_workflow_translation_plan.md @@ -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 diff --git a/lib/BOSS/baseline_hvac_planner.rb b/lib/BOSS/baseline_hvac_planner.rb index 371ef55..c0b0421 100644 --- a/lib/BOSS/baseline_hvac_planner.rb +++ b/lib/BOSS/baseline_hvac_planner.rb @@ -35,8 +35,11 @@ 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, nil] when given, only these HVACSystems are planned + # @param exclude_system_ids [Array] 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) @@ -44,7 +47,10 @@ def plan(hvac_systems, standards_template) "(#{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 } @@ -65,9 +71,8 @@ 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? @@ -75,23 +80,19 @@ def plan(hvac_systems, 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] 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]") @@ -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 diff --git a/lib/BOSS/boss.rb b/lib/BOSS/boss.rb index e0cbec0..2256ed8 100644 --- a/lib/BOSS/boss.rb +++ b/lib/BOSS/boss.rb @@ -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' @@ -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) @@ -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 = [] @@ -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]) @@ -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? diff --git a/lib/BOSS/scenario_hvac_planner.rb b/lib/BOSS/scenario_hvac_planner.rb new file mode 100644 index 0000000..05ce3e4 --- /dev/null +++ b/lib/BOSS/scenario_hvac_planner.rb @@ -0,0 +1,260 @@ +# frozen_string_literal: true + +# ******************************************************************************* +# OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. +# BuildingSync(R), Copyright (c) Alliance for Energy Innovation, LLC. +# See also https://github.com/BuildingSync/BOSS/blob/develop/LICENSE.md +# ******************************************************************************* + +require 'rexml/document' +require 'BOSS/baseline_hvac_planner' +require 'BOSS/hvac_topology_selector' +require 'BOSS/hvac_target_binder' + +module BOSS + # Plans split HVAC measure steps for one BuildingSync scenario measure. + # + # - Replacement with AlternativeSystemReplacement HVACSystems: the alternative systems go + # through the topology selector and bind with operation 'replace'. The replaced systems + # must be every existing HVACSystem, because generated zones cannot be split. + # - ModificationRetrocommissioning with ModifiedSystem HVACSystems: source efficiencies + # stated as COP or Thermal Efficiency become modify_existing_hvac_equipment_efficiencies steps. + # - Otherwise, a MeasureName in NAMED_TOPOLOGIES names exactly one topology and replaces + # whole-building HVAC. + # + # Measures that match none of these are :not_hvac and fall through to the JSON map. + class ScenarioHvacPlanner + PHASE = 'hvac_equipment' + MODIFIER_PHASE = 'hvac_modifiers' + EFFICIENCY_MODIFIER = 'modify_existing_hvac_equipment_efficiencies' + # MeasureName => [configuration, topology measure]. Only names that identify one topology. + NAMED_TOPOLOGIES = { + 'Install variable refrigerant flow system' => ['VRF Terminal Unit', 'hvac_vrf'] + }.freeze + + Result = Struct.new(:status, :steps, :messages, keyword_init: true) + + # @return [Array] HVACSystem IDs that measures name as alternatives or modified systems + def self.proposed_system_ids(hvac_systems) + return [] if hvac_systems.nil? + + system_ids = _system_ids(hvac_systems) + refs = REXML::XPath.match( + hvac_systems.document, + "//*[local-name()='Measure']/*[local-name()='TypeOfMeasure']//" \ + "*[local-name()='AlternativeSystemReplacement' or local-name()='ModifiedSystem']/@IDref" + ).map(&:value) + refs.uniq & system_ids + end + + def self._system_ids(hvac_systems) + REXML::XPath.match(hvac_systems, "*[local-name()='HVACSystem']/@ID").map(&:value) + end + + # @param hvac_systems [REXML::Element, nil] the facility HVACSystems element + # @param document [REXML::Document] the BuildingSync document + # @param standards_template [String] template for retrofit HVAC + def initialize(hvac_systems, document, standards_template, planner: BaselineHvacPlanner.new, binder: HvacTargetBinder.new) + @hvac_systems = hvac_systems + @document = document + @standards_template = standards_template + @planner = planner + @binder = binder + @system_ids = hvac_systems.nil? ? [] : self.class._system_ids(hvac_systems) + @proposed_ids = self.class.proposed_system_ids(hvac_systems) + end + + # @param measure [Hash] symbol-keyed measure hash from BuildingSyncReader#get_measures + # @return [Result] :mapped with OSW steps, :unmapped with reasons, or :not_hvac + def plan(measure) + measure_xml = REXML::XPath.first(@document, "//*[local-name()='Measure'][@ID=$id]", nil, + { 'id' => measure[:measure_id].to_s }) + return not_hvac if measure_xml.nil? + + alternatives = refs(measure_xml, 'Replacements', 'Replacement', 'AlternativeSystemReplacement') + modified = refs(measure_xml, 'ModificationRetrocommissions', 'ModificationRetrocommissioning', 'ModifiedSystem') + return plan_replacement(measure_xml, alternatives) if !alternatives.empty? + return plan_modification(measure_xml, modified) if !modified.empty? + return plan_named_replacement(measure_xml, measure[:measure_name]) if NAMED_TOPOLOGIES.key?(measure[:measure_name]) + + not_hvac + end + + private + + # HVACSystem IDs referenced by TypeOfMeasure//@IDref. + def refs(measure_xml, *names) + path = (['TypeOfMeasure'] + names).map { |name| "*[local-name()='#{name}']" }.join('/') + REXML::XPath.match(measure_xml, "#{path}/@IDref").map(&:value).uniq & @system_ids + end + + def plan_replacement(measure_xml, alternatives) + return unmapped([template_message]) if template_message + + replaced = refs(measure_xml, 'Replacements', 'Replacement', 'ExistingSystemReplaced') + existing = @system_ids - @proposed_ids + if replaced.empty? + return unmapped(['Replacement names no ExistingSystemReplaced HVACSystem.']) + end + + if !(existing - replaced).empty? + return unmapped(["Replacement leaves #{(existing - replaced).join(', ')} in place; " \ + 'partial HVAC replacement is not supported.']) + end + + hvac_plan = @planner.plan(@hvac_systems, @standards_template, operation: 'replace', include_system_ids: alternatives) + return unmapped(hvac_plan.messages) if !hvac_plan.topology? + + mapped(hvac_plan.steps) + end + + def plan_named_replacement(measure_xml, measure_name) + return unmapped([template_message]) if template_message + + configuration, topology = NAMED_TOPOLOGIES.fetch(measure_name) + result = HvacTopologySelector::Result.new( + status: :match, configuration:, measure: topology, hvac_system_id: nil, record_ids: [], + premises: BaselineHvacPlanner.normalize_premises(linked_premises(measure_xml), @document), + group_key: nil, messages: [], measure_arguments: {} + ) + binding = @binder.bind(result, operation: 'replace', standards_template: @standards_template) + return unmapped(binding.messages) if binding.status != :bound + + mapped([binding.step, sizing_step]) + end + + def plan_modification(measure_xml, modified) + affected = refs(measure_xml, 'ModificationRetrocommissions', 'ModificationRetrocommissioning', 'ExistingSystemAffected') + return unmapped(['ModificationRetrocommissioning names no ExistingSystemAffected HVACSystem.']) if affected.empty? + + settings = {} + problems = [] + premises = [] + modified.each do |system_id| + system = REXML::XPath.first(@hvac_systems, "*[local-name()='HVACSystem'][@ID=$id]", nil, { 'id' => system_id }) + premises.concat(linked_premises(system)) + source_efficiencies(system).each do |metric, value, problem| + next problems << "#{system_id}: #{problem}" if problem + + if settings.key?(metric) && settings[metric] != value + problems << "#{system_id}: conflicting #{metric} values #{settings[metric]} and #{value}." + end + settings[metric] ||= value + end + end + return unmapped(problems) if !problems.empty? + return unmapped(['ModifiedSystem states no COP or Thermal Efficiency source values.']) if settings.empty? + + premises = BaselineHvacPlanner.normalize_premises(premises.uniq, @document) + bindings = settings.map do |metric, value| + @binder.bind_modifier(modifier_measure: EFFICIENCY_MODIFIER, + modifier_arguments: { efficiency_metric: metric, efficiency_value: value }, premises:) + end + unbound = bindings.reject { |binding| binding.status == :bound } + return unmapped(unbound.flat_map(&:messages).uniq) if !unbound.empty? + + Result.new(status: :mapped, steps: bindings.map { |binding| binding.step.merge(workflow_phase: MODIFIER_PHASE) }, + messages: []) + end + + # @return [Array] [metric, value, nil] or [nil, nil, problem] per source with an efficiency value + def source_efficiencies(system) + cooling = sources(system, 'CoolingSources/CoolingSource', 'AnnualCoolingEfficiency').map do |source, value, units| + dx = node(source, 'CoolingSourceType/DX') + next [nil, nil, "#{id(source)} is not DX; only DX cooling COP is supported."] if dx.nil? + + metric = text(dx, 'DXSystemType') == 'Variable refrigerant flow' ? 'vrf_cooling_cop' : 'dx_cooling_cop' + cop(source, metric, value, units) + end + heating = sources(system, 'HeatingSources/HeatingSource', 'AnnualHeatingEfficiency').map do |source, value, units| + heating_efficiency(source, value, units) + end + cooling + heating + end + + def heating_efficiency(source, value, units) + type = node(source, 'HeatingSourceType') + if node(type, 'HeatPump') + cooling_id = REXML::XPath.first(type, "*[local-name()='HeatPump']/*[local-name()='CoolingSourceID']/@IDref")&.value + cooling = cooling_id && REXML::XPath.first(@hvac_systems, "//*[local-name()='CoolingSource'][@ID=$id]", nil, + { 'id' => cooling_id }) + vrf = cooling && text(node(cooling, 'CoolingSourceType/DX'), 'DXSystemType') == 'Variable refrigerant flow' + return cop(source, vrf ? 'vrf_heating_cop' : 'dx_heating_cop', value, units) + end + if node(type, 'Furnace') && text(source, 'PrimaryFuel') == 'Natural gas' + return fraction(source, 'gas_burner_efficiency', value, units) + end + return fraction(source, 'electric_heating_efficiency', value, units) if node(type, 'ElectricResistance') + + [nil, nil, "#{id(source)} heating type is not supported for efficiency changes."] + end + + def cop(source, metric, value, units) + return [nil, nil, "#{id(source)} efficiency units '#{units}' are not COP."] if units != 'COP' + return [nil, nil, "#{id(source)} COP must be positive."] if value <= 0 + + [metric, value, nil] + end + + def fraction(source, metric, value, units) + return [nil, nil, "#{id(source)} efficiency units '#{units}' are not Thermal Efficiency."] if units != 'Thermal Efficiency' + return [nil, nil, "#{id(source)} Thermal Efficiency must be in (0, 1]."] if value <= 0 || value > 1 + + [metric, value, nil] + end + + # [source, value, units] for sources that state an efficiency value. + def sources(system, path, prefix) + parent, child = path.split('/') + REXML::XPath.match(system, "*[local-name()='HeatingAndCoolingSystems']/*[local-name()='#{parent}']/" \ + "*[local-name()='#{child}']").filter_map do |source| + raw = text(source, "#{prefix}Value") + next if raw.nil? || raw.strip.empty? + + value = Float(raw, exception: false) + next [source, -1.0, text(source, "#{prefix}Units")] if value.nil? + + [source, value, text(source, "#{prefix}Units")] + end + end + + def linked_premises(xml) + REXML::XPath.match(xml, "*[local-name()='LinkedPremises']/*").flat_map do |premise_type| + premise_type.elements.to_a.filter_map do |link| + link.attributes['IDref'] && { type: premise_type.name, id: link.attributes['IDref'] } + end + end + end + + def node(xml, path) + return nil if xml.nil? + + REXML::XPath.first(xml, path.split('/').map { |name| "*[local-name()='#{name}']" }.join('/')) + end + + def text(xml, path) = node(xml, path)&.text&.strip + def id(xml) = xml.attributes['ID'] || xml.name + + def template_message + return nil if HvacTargetBinder::STANDARDS_TEMPLATES.include?(@standards_template) + + "Template '#{@standards_template}' is not supported by the split HVAC measures." + end + + def sizing_step + { measure_dir_name: BaselineHvacPlanner::SIZING_MEASURE, arguments: { standards_template: @standards_template } } + end + + def mapped(steps) + Result.new(status: :mapped, steps: steps.map { |step| step.merge(workflow_phase: PHASE) }, messages: []) + end + + def unmapped(messages) + Result.new(status: :unmapped, steps: [], messages:) + end + + def not_hvac + Result.new(status: :not_hvac, steps: [], messages: []) + end + end +end diff --git a/lib/BOSS/scenario_measure_map.json b/lib/BOSS/scenario_measure_map.json index 487d784..e95cf95 100644 --- a/lib/BOSS/scenario_measure_map.json +++ b/lib/BOSS/scenario_measure_map.json @@ -4,6 +4,7 @@ "envelope", "internal_loads", "hvac_equipment", + "hvac_modifiers", "controls_operations" ], "lookup_order": [ diff --git a/lib/BOSS/scenario_measure_mapper.rb b/lib/BOSS/scenario_measure_mapper.rb index fbe1c27..dfae723 100644 --- a/lib/BOSS/scenario_measure_mapper.rb +++ b/lib/BOSS/scenario_measure_mapper.rb @@ -37,11 +37,20 @@ def initialize(map_path = SCENARIO_MEASURE_MAP_PATH) # @param measure [Hash] symbol-keyed measure hash from the reader # @param context [Hash, nil] { building_type:, hvac_system_type: } used by conditional_arguments + # @param hvac_planner [ScenarioHvacPlanner, nil] tried before the JSON map; :not_hvac falls through # @return [Hash] { measure_id:, steps: [ { measure_dir_name:, arguments: {} } ], warnings: [] } - def map_measure(measure, context: {}) + def map_measure(measure, context: {}, hvac_planner: nil) context ||= {} raise ArgumentError, 'context must be a Hash' if !context.is_a?(Hash) + hvac = hvac_planner&.plan(measure) + if hvac&.status == :mapped + return { measure_id: measure[:measure_id], steps: hvac.steps, warnings: [] } + elsif hvac&.status == :unmapped + return _unmapped_result(measure, :hvac_measure_unmapped, + "HVAC measure cannot be mapped: #{hvac.messages.join(' ')}") + end + technology_category_key = _lookup_key(measure[:technology_category_element_name], measure[:measure_name]) system_category_key = _lookup_key(measure[:system_category_affected], measure[:measure_name]) @@ -84,9 +93,10 @@ def map_measure(measure, context: {}) # @param scenario [Hash] one record from BuildingSyncReader#get_package_measure_scenarios # @param measures [Hash] BuildingSyncReader#get_measures, keyed by measure ID # @param context [Hash, nil] forwarded to #map_measure + # @param hvac_planner [ScenarioHvacPlanner, nil] forwarded to #map_measure # @return [Hash] { scenario_id:, scenario_name:, report_id:, package_id:, # status: :writable | :skipped, steps: [], skipped_measure_ids: [], warnings: [] } - def map_package_scenario(scenario, measures, context: {}) + def map_package_scenario(scenario, measures, context: {}, hvac_planner: nil) context ||= {} raise ArgumentError, 'scenario must be a Hash' if !scenario.is_a?(Hash) raise ArgumentError, 'measures must be a Hash' if !measures.is_a?(Hash) @@ -116,7 +126,7 @@ def map_package_scenario(scenario, measures, context: {}) next end - result = map_measure(measure, context:) + result = map_measure(measure, context:, hvac_planner:) steps.concat(result[:steps]) skipped_measure_ids << measure_idref if result[:steps].empty? warnings.concat(result[:warnings].map { |warning| warning.merge(scenario_context) }) diff --git a/spec/files/v2.7.0/example-smalloffice-level2-hvac-retrofits.xml b/spec/files/v2.7.0/example-smalloffice-level2-hvac-retrofits.xml new file mode 100644 index 0000000..784f379 --- /dev/null +++ b/spec/files/v2.7.0/example-smalloffice-level2-hvac-retrofits.xml @@ -0,0 +1,2905 @@ + + + + + + + + + Prototype Small Office in Denver + Here we record general problems / issues identified in a walkthrough survey. + + + City Custom Building ID + some ID + + + Custom ID 1 + some other ID + + +
+ + + Some address + + + Denver + CO + 80014 +
+ -104.830000 + 39.660000 + Commercial + Office + + 1 + 0 + 1 + 0 + true + false + + + Gross + 5500.000000 + + + + + + Conditioned + 5500.000000 + + + + + + 6500.000000 + 0.000000 + 0.213300 + 0.050000 + 2000 + 2000 + 2010 + 2020-03-01 + 2000 + +
+ Space function + Office + Office + + + Peak total occupants + 31.000000 + + + + + 40.000000 + Hours per week + + + 50.000000 + Weeks per year + + + + + Gross + 5500.000000 + + + Conditioned + 5500.000000 + + + Single zone +
+
+ Whole building + Rectangular + + + A1 + + + 909.012230 + + + + + 180.187860 + + + + + 42.086890 + + + + + B1 + + + 606.008200 + + + + + 120.125240 + + + + + 0.000000 + + + + + C1 + + + 909.012230 + + + + + 180.187860 + + + + + 0.000000 + + + + + D1 + + + 606.008200 + + + + + 120.125240 + + + + + 0.000000 + + + + + + + + 6444.999000 + Good + + + + + + + 3891.153600 + + + +
+
+ + + + + + + + + + Single zone + + + + + Packaged Unitary + Natural gas + 0.000000 + + + + 3.010000 + COP + 10311.100000 + 10311.100000 + W + Good + + + + + + + + + + 2000 + + + + + Packaged Unitary + Natural gas + 0.000000 + + + + 3.010000 + COP + 9801.300000 + 9801.300000 + W + Good + + + + + + + + + + 2000 + + + + + Packaged Unitary + Natural gas + 0.000000 + + + + 3.010000 + COP + 7858.100000 + 7858.100000 + W + Good + + + + + + + + + + 2000 + + + + + Packaged Unitary + Natural gas + 0.000000 + + + + 3.010000 + COP + 9067.800000 + 9067.800000 + W + Good + + + + + + + + + + 2000 + + + + + Packaged Unitary + Natural gas + 0.000000 + + + + 3.010000 + COP + 9855.400000 + 9855.400000 + W + Good + + + + + + + + + + 2000 + + + + + + + Packaged/unitary heat pump + Reciprocating + Single stage + + + 2.610000 + COP + 10198.900000 + W + Good + + + + + + + + + + 2000 + + + + + Packaged/unitary heat pump + Reciprocating + Single stage + + + 2.610000 + COP + 9847.200000 + W + Good + + + + + + + + + + 2000 + + + + + Packaged/unitary heat pump + Reciprocating + Single stage + + + 2.610000 + COP + 7737.100000 + W + Good + + + + + + + + + + 2000 + + + + + Packaged/unitary heat pump + Reciprocating + Single stage + + + 2.610000 + COP + 9143.800000 + W + Good + + + + + + + + + + 2000 + + + + + Packaged/unitary heat pump + Reciprocating + Single stage + + + 2.610000 + COP + 9847.200000 + W + Good + + + + + + + + + + 2000 + + + + + + + Central fan + CAV terminal box no reheat + None + + + None + Fixed + + + + + + + + + + + + + + + + 2000 + 1 + Good + + + + + Central fan + CAV terminal box no reheat + None + + + None + Fixed + + + + + + + + + + + + + + + + 2000 + 1 + Good + + + + + Central fan + CAV terminal box no reheat + None + + + None + Fixed + + + + + + + + + + + + + + + + 2000 + 1 + Good + + + + + Central fan + CAV terminal box no reheat + None + + + None + Fixed + + + + + + + + + + + + + + + + 2000 + 1 + Good + + + + + Central fan + CAV terminal box no reheat + None + + + None + Fixed + + + + + + + + + + + + + + + + 2000 + 1 + Good + + + + + + Single + Good + + + + + Single + Good + + + + + Single + Good + + + + + Single + Good + + + + + Single + Good + + + + + + Digital + + +
+ + + + + +
+
+
+ + + Single zone + + + + + Warm air + + + Natural gas + Air + + + + + + + Packaged/unitary direct expansion/RTU + + + Electricity + + + + + + + Central fan + CAV terminal box no reheat + None + + + + + + + + +
+ +
+
+
+ + + + + + + Packaged Unitary + + + + 3.800000 + COP + + + + + + + Packaged/unitary heat pump + + + 3.500000 + COP + + + + + + + + + +
+ + + + + T8 + + + Standard Electronic + + 0.200000 + + 100.000000 + 5.500000 + 32.000000 + 4 + 1.000000 + 43 + false + + + + + + + Programmable + + + + false + +
+ + + + + +
+
+
+ + + + T12 + + + Standard Electronic + 100.000000 + 1.582575 + 316.516000 + 1 + 1.000000 + 5 + true + + + + + + + Programmable + + + + false + +
+ + + + + +
+
+
+ + + + LED + + + Standard Electronic + + 0.100000 + + 100.000000 + 2.752000 + 16.000000 + 4 + 1.000000 + 43 + false + + + + + + + Photocell + Continuous + + + + false + +
+ + + + + +
+
+
+
+ + + + + + + + 40.000000 + 123.000000 + + + Notes + + 1 + 3.600000 + Continuous + 123.000000 + 1.870180 + + Looped + Thermal Efficiency + 1.000000 + 40.000000 + 140.000000 + 1950.520000 + 11722.840000 + W + + + + + + + + + + 2000 + Electricity + Good + + + + +
+ +
+
+ 1 +
+
+ + + 0.536000 + 880.000000 + 880.000000 + Constant Volume + + + + + + 0.536000 + 872.000000 + 872.000000 + Variable Volume + + + + + + 0.536000 + 836.000000 + 836.000000 + Constant Volume + + + + + + 0.536000 + 830.000000 + 830.000000 + Variable Volume + + + + + + 0.536000 + 671.000000 + 671.000000 + Constant Volume + + + + + + 0.536000 + 664.000000 + 664.000000 + Variable Volume + + + + + + 0.536000 + 774.000000 + 774.000000 + Constant Volume + + + + + + 0.536000 + 766.000000 + 766.000000 + Variable Volume + + + + + + 0.536000 + 841.000000 + 841.000000 + Constant Volume + + + + + + 0.536000 + 833.000000 + 833.000000 + Variable Volume + + + + + + + + Wood frame + 0.547000 + + + + + Wood frame + 4.706000 + + + + + + + + Vinyl + Clear uncoated + Single pane + 3.241000 + 0.391000 + 0.391000 + + + + + + Vinyl + Low e + Triple pane + 0.300000 + 0.391000 + 0.391000 + + + + + Insulated metal + 0.500000 + + + Steel + 2.839000 + + + + + + + + 0.345000 + + + + Concrete poured + + + + + Miscellaneous Electric Load + 0.630000 + +
+ + + + + +
+
+
+
+ + + Notes on test + Tight + 0.151000 + ACHnatural + Blower door + +
+ +
+
+
+
+ + + Notes on test + +
+ +
+
+
+
+
+ + + + + Weekday + Occupied + 00:00:00 + 06:00:00 + 0.000000 + + + Weekday + Occupied + 06:00:00 + 07:00:00 + 11.000000 + + + Weekday + Occupied + 07:00:00 + 08:00:00 + 21.000000 + + + Weekday + Occupied + 08:00:00 + 12:00:00 + 100.000000 + + + Weekday + Occupied + 12:00:00 + 13:00:00 + 53.000000 + + + Weekday + Occupied + 13:00:00 + 17:00:00 + 100.000000 + + + Weekday + Occupied + 17:00:00 + 18:00:00 + 32.000000 + + + Weekday + Occupied + 18:00:00 + 22:00:00 + 11.000000 + + + Weekday + Occupied + 22:00:00 + 23:00:00 + 5.000000 + + + Weekday + Occupied + 23:00:00 + 23:59:59 + 0.000000 + + + Weekend + Occupied + 00:00:00 + 23:59:59 + 0.000000 + + + Holiday + Occupied + 00:00:00 + 23:59:59 + 0.000000 + + + + + + +
+ +
+
+
+ + + + Weekday + Lighting + 00:00:00 + 05:00:00 + 18.000000 + + + Weekday + Lighting + 05:00:00 + 07:00:00 + 23.000000 + + + Weekday + Lighting + 07:00:00 + 08:00:00 + 42.000000 + + + Weekday + Lighting + 08:00:00 + 12:00:00 + 90.000000 + + + Weekday + Lighting + 12:00:00 + 13:00:00 + 80.000000 + + + Weekday + Lighting + 13:00:00 + 17:00:00 + 90.000000 + + + Weekday + Lighting + 17:00:00 + 18:00:00 + 61.000000 + + + Weekday + Lighting + 18:00:00 + 20:00:00 + 42.000000 + + + Weekday + Lighting + 20:00:00 + 22:00:00 + 32.000000 + + + Weekday + Lighting + 22:00:00 + 23:00:00 + 23.000000 + + + Weekday + Lighting + 23:00:00 + 23:59:59 + 18.000000 + + + Weekend + Lighting + 00:00:00 + 23:59:59 + 18.000000 + + + Holiday + Lighting + 00:00:00 + 23:59:59 + 18.000000 + + + + + + + + + + + + Weekday + Miscellaneous equipment + 00:00:00 + 08:00:00 + 50.000000 + + + Weekday + Miscellaneous equipment + 08:00:00 + 12:00:00 + 100.000000 + + + Weekday + Miscellaneous equipment + 12:00:00 + 13:00:00 + 94.000000 + + + Weekday + Miscellaneous equipment + 13:00:00 + 17:00:00 + 100.000000 + + + Weekday + Miscellaneous equipment + 17:00:00 + 18:00:00 + 50.000000 + + + Weekday + Miscellaneous equipment + 18:00:00 + 23:59:59 + 20.000000 + + + Weekend + Miscellaneous equipment + 00:00:00 + 23:59:59 + 20.000000 + + + Holiday + Miscellaneous equipment + 00:00:00 + 23:59:59 + 20.000000 + + + + + + + + + + + + Weekday + HVAC equipment + 00:00:00 + 06:00:00 + 0.000000 + + + Weekday + HVAC equipment + 06:00:00 + 19:00:00 + 100.000000 + + + Weekday + HVAC equipment + 19:00:00 + 23:59:59 + 0.000000 + + + Weekend + HVAC equipment + 00:00:00 + 23:59:59 + 0.000000 + + + Holiday + HVAC equipment + 00:00:00 + 23:59:59 + 0.000000 + + + + + + + + + + + + Weekday + HVAC equipment + 00:00:00 + 06:00:00 + 0.000000 + + + Weekday + HVAC equipment + 06:00:00 + 07:00:00 + 60.000000 + + + Weekday + HVAC equipment + 07:00:00 + 12:00:00 + 100.000000 + + + Weekday + HVAC equipment + 12:00:00 + 13:00:00 + 80.000000 + + + Weekday + HVAC equipment + 13:00:00 + 18:00:00 + 100.000000 + + + Weekday + HVAC equipment + 18:00:00 + 20:00:00 + 60.000000 + + + Weekday + HVAC equipment + 20:00:00 + 23:59:59 + 0.000000 + + + Weekend + HVAC equipment + 00:00:00 + 23:59:59 + 0.000000 + + + Holiday + HVAC equipment + 00:00:00 + 23:59:59 + 0.000000 + + + + + + + + +
+ + + + + + + + + + + Lighting + + + + Retrofit with light emitting diode technologies + + + + Individual system + This measure is designed to replace all fluorescent bulbs with LEDs + 1 + 50.000000 + 774.000000 + true + 2021-01-01 + 2021-12-30 + + + + + + + + + + + Fan + + + + Add VSD motor controller + + + + Individual system + This measure is designed to retrofit all RTU fans with a VSD + 1 + 750.000000 + 1250.000000 + true + 2021-01-01 + 2021-12-30 + + + + + + + + + + + Cooling System + + + + Replace package units + + + + + + + + + + + + + + Cooling System + + + + Replace package units + + + + + + Cooling System + + + + + + + + + Install variable refrigerant flow system + + + + + + + + + + + + + + + + + + + Electricity + This is required to document irregularities in monthly energy patterns (Std 211 6.1.2.1.j). No irregularities found. + kWh + All end uses + 67334.150000 + 229.753657 + + + + + + + + + + + + + + + kW + 26.040000 + 26.040000 + 4613.820000 + + + + + + Natural gas + No irregularities in monthly energy consumption found. + MMBtu + All end uses + 8.720000 + 8.720000 + + + + + + + + + + + + + + + 540.830000 + + + + + + Electricity + kWh + Interior lighting + 28.705000 + 20062.690000 + 68.453898 + + + + Electricity + kWh + Heating + 6.722000 + 4698.230000 + 16.030361 + + + + Electricity + kWh + Cooling + 8.769000 + 6128.870000 + 20.911704 + + + + Electricity + kWh + Domestic hot water + 10.281000 + 7185.370000 + 24.516482 + + + + Electricity + kWh + Plug load + 21.379000 + 14942.150000 + 50.982616 + + + + + + Total + Energy + 2019-01-01T00:00:00 + 2019-02-01T00:00:00 + 31 + Day + Month + 5933.100000 + + + + Total + Energy + 2019-02-01T00:00:00 + 2019-03-01T00:00:00 + 28 + Day + Month + 5446.100000 + + + + Total + Energy + 2019-03-01T00:00:00 + 2019-04-01T00:00:00 + 31 + Day + Month + 5736.490000 + + + + Total + Energy + 2019-04-01T00:00:00 + 2019-05-01T00:00:00 + 30 + Day + Month + 4980.500000 + + + + Total + Energy + 2019-05-01T00:00:00 + 2019-06-01T00:00:00 + 31 + Day + Month + 5187.210000 + + + + Total + Energy + 2019-06-01T00:00:00 + 2019-07-01T00:00:00 + 30 + Day + Month + 5842.950000 + + + + Total + Energy + 2019-07-01T00:00:00 + 2019-08-01T00:00:00 + 31 + Day + Month + 5801.730000 + + + + Total + Energy + 2019-08-01T00:00:00 + 2019-09-01T00:00:00 + 31 + Day + Month + 6220.160000 + + + + Total + Energy + 2019-09-01T00:00:00 + 2019-10-01T00:00:00 + 30 + Day + Month + 5682.870000 + + + + Total + Energy + 2019-10-01T00:00:00 + 2019-11-01T00:00:00 + 31 + Day + Month + 5571.930000 + + + + Total + Energy + 2019-11-01T00:00:00 + 2019-12-01T00:00:00 + 30 + Day + Month + 5525.150000 + + + + Total + Energy + 2019-12-01T00:00:00 + 2020-01-01T00:00:00 + 31 + Day + Month + 5405.940000 + + + + Total + Energy + 2019-01-01T00:00:00 + 2019-02-01T00:00:00 + 31 + Day + Month + 1.720000 + + + + Total + Energy + 2019-02-01T00:00:00 + 2019-03-01T00:00:00 + 28 + Day + Month + 1.250000 + + + + Total + Energy + 2019-03-01T00:00:00 + 2019-04-01T00:00:00 + 31 + Day + Month + 0.410000 + + + + Total + Energy + 2019-04-01T00:00:00 + 2019-05-01T00:00:00 + 30 + Day + Month + 0.430000 + + + + Total + Energy + 2019-05-01T00:00:00 + 2019-06-01T00:00:00 + 31 + Day + Month + 0.010000 + + + + Total + Energy + 2019-06-01T00:00:00 + 2019-07-01T00:00:00 + 30 + Day + Month + 0.000000 + + + + Total + Energy + 2019-07-01T00:00:00 + 2019-08-01T00:00:00 + 31 + Day + Month + 0.000000 + + + + Total + Energy + 2019-08-01T00:00:00 + 2019-09-01T00:00:00 + 31 + Day + Month + 0.000000 + + + + Total + Energy + 2019-09-01T00:00:00 + 2019-10-01T00:00:00 + 30 + Day + Month + 0.000000 + + + + Total + Energy + 2019-10-01T00:00:00 + 2019-11-01T00:00:00 + 31 + Day + Month + 0.200000 + + + + Total + Energy + 2019-11-01T00:00:00 + 2019-12-01T00:00:00 + 30 + Day + Month + 0.400000 + + + + Total + Energy + 2019-12-01T00:00:00 + 2020-01-01T00:00:00 + 31 + Day + Month + 4.300000 + + + + Peak + On-peak + Power + 2019-01-01T00:00:00 + 2019-02-01T00:00:00 + 31 + Day + Month + 23.580000 + + + + Peak + On-peak + Power + 2019-02-01T00:00:00 + 2019-03-01T00:00:00 + 28 + Day + Month + 25.380000 + + + + Peak + On-peak + Power + 2019-03-01T00:00:00 + 2019-04-01T00:00:00 + 31 + Day + Month + 26.040000 + + + + Peak + On-peak + Power + 2019-04-01T00:00:00 + 2019-05-01T00:00:00 + 30 + Day + Month + 24.450000 + + + + Peak + On-peak + Power + 2019-05-01T00:00:00 + 2019-06-01T00:00:00 + 31 + Day + Month + 17.030000 + + + + Peak + On-peak + Power + 2019-06-01T00:00:00 + 2019-07-01T00:00:00 + 30 + Day + Month + 22.710000 + + + + Peak + On-peak + Power + 2019-07-01T00:00:00 + 2019-08-01T00:00:00 + 31 + Day + Month + 22.010000 + + + + Peak + On-peak + Power + 2019-08-01T00:00:00 + 2019-09-01T00:00:00 + 31 + Day + Month + 21.810000 + + + + Peak + On-peak + Power + 2019-09-01T00:00:00 + 2019-10-01T00:00:00 + 30 + Day + Month + 20.630000 + + + + Peak + On-peak + Power + 2019-10-01T00:00:00 + 2019-11-01T00:00:00 + 31 + Day + Month + 21.870000 + + + + Peak + On-peak + Power + 2019-11-01T00:00:00 + 2019-12-01T00:00:00 + 30 + Day + Month + 21.630000 + + + + Peak + On-peak + Power + 2019-12-01T00:00:00 + 2020-01-01T00:00:00 + 31 + Day + Month + 21.780000 + + + + Load factor + Power + 2019-01-01T00:00:00 + 2019-02-01T00:00:00 + 31 + Day + Month + 0.340000 + + + + Load factor + Power + 2019-02-01T00:00:00 + 2019-03-01T00:00:00 + 28 + Day + Month + 0.320000 + + + + Load factor + Power + 2019-03-01T00:00:00 + 2019-04-01T00:00:00 + 31 + Day + Month + 0.300000 + + + + Load factor + Power + 2019-04-01T00:00:00 + 2019-05-01T00:00:00 + 30 + Day + Month + 0.280000 + + + + Load factor + Power + 2019-05-01T00:00:00 + 2019-06-01T00:00:00 + 31 + Day + Month + 0.410000 + + + + Load factor + Power + 2019-06-01T00:00:00 + 2019-07-01T00:00:00 + 30 + Day + Month + 0.360000 + + + + Load factor + Power + 2019-07-01T00:00:00 + 2019-08-01T00:00:00 + 31 + Day + Month + 0.350000 + + + + Load factor + Power + 2019-08-01T00:00:00 + 2019-09-01T00:00:00 + 31 + Day + Month + 0.380000 + + + + Load factor + Power + 2019-09-01T00:00:00 + 2019-10-01T00:00:00 + 30 + Day + Month + 0.380000 + + + + Load factor + Power + 2019-10-01T00:00:00 + 2019-11-01T00:00:00 + 31 + Day + Month + 0.340000 + + + + Load factor + Power + 2019-11-01T00:00:00 + 2019-12-01T00:00:00 + 30 + Day + Month + 0.350000 + + + + Load factor + Power + 2019-12-01T00:00:00 + 2020-01-01T00:00:00 + 31 + Day + Month + 0.330000 + + + + Cost + Cost + 2019-01-01T00:00:00 + 2019-02-01T00:00:00 + 31 + Day + Month + 332.160000 + + + + Cost + Cost + 2019-02-01T00:00:00 + 2019-03-01T00:00:00 + 28 + Day + Month + 306.290000 + + + + Cost + Cost + 2019-03-01T00:00:00 + 2019-04-01T00:00:00 + 31 + Day + Month + 321.720000 + + + + Cost + Cost + 2019-04-01T00:00:00 + 2019-05-01T00:00:00 + 30 + Day + Month + 281.540000 + + + + Cost + Cost + 2019-05-01T00:00:00 + 2019-06-01T00:00:00 + 31 + Day + Month + 292.530000 + + + + Cost + Cost + 2019-06-01T00:00:00 + 2019-07-01T00:00:00 + 30 + Day + Month + 534.100000 + + + + Cost + Cost + 2019-07-01T00:00:00 + 2019-08-01T00:00:00 + 31 + Day + Month + 530.450000 + + + + Cost + Cost + 2019-08-01T00:00:00 + 2019-09-01T00:00:00 + 31 + Day + Month + 567.490000 + + + + Cost + Cost + 2019-09-01T00:00:00 + 2019-10-01T00:00:00 + 30 + Day + Month + 519.930000 + + + + Cost + Cost + 2019-10-01T00:00:00 + 2019-11-01T00:00:00 + 31 + Day + Month + 312.970000 + + + + Cost + Cost + 2019-11-01T00:00:00 + 2019-12-01T00:00:00 + 30 + Day + Month + 310.490000 + + + + Cost + Cost + 2019-12-01T00:00:00 + 2020-01-01T00:00:00 + 31 + Day + Month + 304.150000 + + + + Cost + Cost + 2019-01-01T00:00:00 + 2019-02-01T00:00:00 + 31 + Day + Month + 46.690000 + + + + Cost + Cost + 2019-02-01T00:00:00 + 2019-03-01T00:00:00 + 28 + Day + Month + 45.930000 + + + + Cost + Cost + 2019-03-01T00:00:00 + 2019-04-01T00:00:00 + 31 + Day + Month + 44.550000 + + + + Cost + Cost + 2019-04-01T00:00:00 + 2019-05-01T00:00:00 + 30 + Day + Month + 44.580000 + + + + Cost + Cost + 2019-05-01T00:00:00 + 2019-06-01T00:00:00 + 31 + Day + Month + 43.900000 + + + + Cost + Cost + 2019-06-01T00:00:00 + 2019-07-01T00:00:00 + 30 + Day + Month + 43.880000 + + + + Cost + Cost + 2019-07-01T00:00:00 + 2019-08-01T00:00:00 + 31 + Day + Month + 43.880000 + + + + Cost + Cost + 2019-08-01T00:00:00 + 2019-09-01T00:00:00 + 31 + Day + Month + 43.880000 + + + + Cost + Cost + 2019-09-01T00:00:00 + 2019-10-01T00:00:00 + 30 + Day + Month + 43.880000 + + + + Cost + Cost + 2019-10-01T00:00:00 + 2019-11-01T00:00:00 + 31 + Day + Month + 44.210000 + + + + Cost + Cost + 2019-11-01T00:00:00 + 2019-12-01T00:00:00 + 30 + Day + Month + 44.530000 + + + + Cost + Cost + 2019-12-01T00:00:00 + 2020-01-01T00:00:00 + 31 + Day + Month + 50.920000 + + + + + + 238473.656550 + 43.358800 + 737088.900000 + 134.000000 + 238473.656550 + 43.358800 + 238.473657 + 0.000000 + 0.000000 + 0.000000 + 4952.480000 + 0.900000 + + + + + + + + + + + + + + 2022-06-01 + + + Portfolio Manager + 2019 + 80.000000 + + + + + 238473.656550 + 43.358800 + 4952.480000 + + + + + + + + + + + + + 39070.530000 + 995 + 89.000000 + + + + + 190348.600000 + 34.600000 + 4846.040000 + 0.881000 + + + + + + + + + + + + + + TMY3 + Finished + + + + + + + Electricity + kWh + All end uses + 67334.150000 + 229.753657 + kW + 26.040000 + 26.040000 + + + Natural gas + MMBtu + All end uses + 8.720000 + 8.720000 + + + + + + + + + + POM-LEDs + + + + + + + Capital + 35.713000 + 772 + + + Electricity + kWh + 11524.540000 + + + Natural gas + MMBtu + 0.000000 + + + 3.220000 + 0 + 0.000000 + 0.000000 + 1 + 824.000000 + 0.000000 + 0.000000 + 0.000000 + 0.000000 + 0.000000 + 0.000000 + 0.000000 + 0 + 0 + 1.070000 + 0.000000 + + + + + + + + + + POM-VSDs + + + + + + + Capital + 5.175000 + 9 + + + Electricity + kWh + 207.240000 + + + Natural gas + MMBtu + 4.460000 + + + 0.420000 + 0 + 0.000000 + 0.000000 + 1 + 2000.000000 + 0.000000 + 0.000000 + 0.000000 + 0.000000 + 0.000000 + 0.000000 + 0.000000 + 0 + 0 + 230.150000 + 0.000000 + + + + + + + + + + POM-LEDs-VSDs + + + + + + + + Capital + 41.827000 + 781 + + + Electricity + kWh + 11701.620000 + + + Natural gas + MMBtu + 1.890000 + + + 4.700000 + 0 + 0.000000 + 0.000000 + 1 + 2824.000000 + 0.000000 + 0.000000 + 0.000000 + 0.000000 + 0.000000 + 0.000000 + 0.000000 + 0 + 0 + 3.620000 + 0.000000 + + + + + + + + + + POM-HVAC-RTU + + + + + + + + + + + POM-HVAC-COP + + + + + + + + + + + POM-HVAC-VRF + + + + + + + + + + + POM-HVAC-mixed + + + + + + + + + + + + Level 2: Energy Survey and Analysis + + + + + + + + + --06-01 + --09-30 + --06-01 + --09-30 + 0.088520 + 0.000000 + + + --01-01 + --05-31 + --01-01 + --05-31 + 0.053140 + 0.000000 + + + --10-01 + --12-31 + --10-01 + --12-31 + 0.053140 + 0.000000 + + + + + https://www.xcelenergy.com/company/rates_and_regulations/rates/rate_books + 16.880000 + + + 12345 + Xcel Energy + + Some-meter-ID + + some-account-number + Building Owner + + + + + + + + + --01-01 + --12-31 + 0.163600 + + + + + https://www.xcelenergy.com/company/rates_and_regulations/rates/rate_books + 43.880000 + + + Xcel Energy + + Some-meter-ID + + some-other-account-number + Building Owner + + + + + + + + + + + + + + Owner + + The dude + Some big company + + + 123-456-7890 + + + + + the.dude@somebigco.net + + + + + + Energy Auditor + + The lady + Auditeers + + + 123-456-7890 + + + + + the.lady@the-three-auditeers.com + + + + + + + diff --git a/spec/tests/integration/write_and_run_osws_spec.rb b/spec/tests/integration/write_and_run_osws_spec.rb index d5ddedc..7caf985 100644 --- a/spec/tests/integration/write_and_run_osws_spec.rb +++ b/spec/tests/integration/write_and_run_osws_spec.rb @@ -39,12 +39,15 @@ test_configs = test_configs.select { |config| SMOKE_FILES.include?(config[0]) } if ENV['BOSS_SMOKE'] == '1' # BOSS_SHARD / BOSS_SHARDS split the fixtures across parallel CI jobs. +run_extra_examples = ENV['BOSS_SMOKE'] != '1' if ENV['BOSS_SHARDS'] shards = Integer(ENV['BOSS_SHARDS']) shard = Integer(ENV.fetch('BOSS_SHARD', '0')) raise ArgumentError, "BOSS_SHARD must be in 0...#{shards}" if shards < 1 || shard.negative? || shard >= shards test_configs = test_configs.select.with_index { |_config, index| index % shards == shard } + # Examples outside test_configs run once, in shard 0. + run_extra_examples &&= shard.zero? end RSpec.describe 'BOSS' do @@ -77,6 +80,8 @@ end + next unless run_extra_examples + { 'example-smalloffice-level2.xml' => ['smalloffice_l2_topology_doe_ref', 'DOE Ref 1980-2004'], 'example-smalloffice-level2-built-2012.xml' => ['smalloffice_l2_topology', '90.1-2013'] @@ -99,5 +104,31 @@ expect(steps['apply_standard_hvac_sizing_and_efficiency'][:result][:step_result]).to eq 'Success' end end + + it 'write and run HVAC retrofit scenarios. File: example-smalloffice-level2-hvac-retrofits.xml' do + xml_path = File.join(SPEC_FILES_DIR, 'v2.7.0', 'example-smalloffice-level2-hvac-retrofits.xml') + output_path = File.join(SPEC_OUTPUT_DIR, 'v2.7.0', 'example-smalloffice-level2-hvac-retrofits') + + result = BOSS::Boss.write_baseline_and_scenario_osws(xml_path, output_path, nil, ASHRAE90_1) + by_id = result[:scenario_results].to_h { |scenario| [scenario[:scenario_id], scenario] } + hvac_ids = ['Scenario-POM-HVAC-RTU', 'Scenario-POM-HVAC-COP', 'Scenario-POM-HVAC-VRF', 'Scenario-POM-HVAC-mixed'] + hvac_ids.each { |id| expect(by_id.fetch(id)[:status]).to eq(:written), by_id.fetch(id)[:warnings].inspect } + + failures = BOSS::Boss.run_baseline_and_scenario_osws(result) + expect(failures).to be_empty, failures.inspect + + out = ->(path) { JSON.parse(File.read(File.join(File.dirname(path), 'out.osw')), symbolize_names: true) } + expect(out.call(result[:baseline_osw_path])[:completed_status]).to eq 'Success' + hvac_ids.each do |id| + out_osw = out.call(by_id.fetch(id)[:osw_path]) + expect(out_osw[:completed_status]).to eq('Success'), id + end + + rtu = out.call(by_id.fetch('Scenario-POM-HVAC-RTU')[:osw_path])[:steps] + .select { |step| step[:measure_dir_name] == 'apply_hvac_topology_to_zone_scope' }.last + expect(rtu[:arguments]).to include(topology_measure: 'hvac_packaged_rooftop_ac', operation: 'replace') + mixed = out.call(by_id.fetch('Scenario-POM-HVAC-mixed')[:osw_path])[:steps].map { |step| step[:measure_dir_name] } + expect(mixed).to include('SetLightingLoadsByLPD', 'apply_hvac_modifier_to_object_scope') + end end end diff --git a/spec/tests/unit/baseline_hvac_planner_spec.rb b/spec/tests/unit/baseline_hvac_planner_spec.rb index 099dae0..79151cf 100644 --- a/spec/tests/unit/baseline_hvac_planner_spec.rb +++ b/spec/tests/unit/baseline_hvac_planner_spec.rb @@ -8,6 +8,7 @@ require 'rexml/document' require 'BOSS/baseline_hvac_planner' +require 'BOSS/scenario_hvac_planner' require 'BOSS/boss_logger' require 'BOSS/buildingsync_reader/buildingsync_reader' @@ -129,4 +130,16 @@ def plan_for(results, systems, template = '90.1-2019') arguments: { standards_template: template }) end end + + it 'plans the baseline without proposed scenario HVACSystems' do + path = File.expand_path('../../files/v2.7.0/example-smalloffice-level2-hvac-retrofits.xml', __dir__) + doc = REXML::Document.new(File.read(path), ignore_whitespace_nodes: :all) + hvac_systems = REXML::XPath.first(doc, "//*[local-name()='HVACSystems']") + + expect(described_class.new.plan(hvac_systems, 'DOE Ref 1980-2004').status).to eq(:fallback) + plan = described_class.new.plan(hvac_systems, 'DOE Ref 1980-2004', + exclude_system_ids: BOSS::ScenarioHvacPlanner.proposed_system_ids(hvac_systems)) + expect(plan.status).to eq(:topology), plan.messages.join("\n") + expect(plan.steps.first[:arguments]).to include(topology_measure: 'hvac_packaged_rooftop_heat_pump', operation: 'create') + end end diff --git a/spec/tests/unit/scenario_hvac_planner_spec.rb b/spec/tests/unit/scenario_hvac_planner_spec.rb new file mode 100644 index 0000000..374aed0 --- /dev/null +++ b/spec/tests/unit/scenario_hvac_planner_spec.rb @@ -0,0 +1,126 @@ +# frozen_string_literal: true + +# ******************************************************************************* +# OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. +# BuildingSync(R), Copyright (c) Alliance for Energy Innovation, LLC. +# See also https://github.com/BuildingSync/BOSS/blob/develop/LICENSE.md +# ******************************************************************************* + +require 'rexml/document' +require 'BOSS/scenario_hvac_planner' + +RSpec.describe BOSS::ScenarioHvacPlanner do + fixture = File.expand_path('../../files/v2.7.0/example-smalloffice-level2-hvac-retrofits.xml', __dir__) + template = 'DOE Ref 1980-2004' + sizing = { measure_dir_name: 'apply_standard_hvac_sizing_and_efficiency', arguments: { standards_template: template }, + workflow_phase: 'hvac_equipment' } + + let(:doc) { REXML::Document.new(File.read(fixture), ignore_whitespace_nodes: :all) } + let(:hvac_systems) { REXML::XPath.first(doc, "//*[local-name()='HVACSystems']") } + + def planner(doc, hvac_systems, template = 'DOE Ref 1980-2004') + described_class.new(hvac_systems, doc, template) + end + + def element(doc, id) + REXML::XPath.first(doc, "//*[@ID='#{id}']") + end + + it 'lists proposed HVACSystems named by measures' do + expect(described_class.proposed_system_ids(hvac_systems)) + .to contain_exactly('HVACSystem-proposed-RTU', 'HVACSystem-proposed-COP') + end + + it 'replaces HVAC with the alternative system topology' do + result = planner(doc, hvac_systems).plan(measure_id: 'Measure-HVAC-RTU', measure_name: 'Replace package units') + + expect(result.status).to eq(:mapped), result.messages.join("\n") + expect(result.steps.first).to eq( + measure_dir_name: 'apply_hvac_topology_to_zone_scope', workflow_phase: 'hvac_equipment', + arguments: { topology_measure: 'hvac_packaged_rooftop_ac', operation: 'replace', zone_scope: 'all_model_zones', + standards_template: template } + ) + expect(result.steps.last).to eq(sizing) + end + + it 'uses the configured retrofit template' do + result = planner(doc, hvac_systems, '90.1-2019').plan(measure_id: 'Measure-HVAC-RTU') + + expect(result.steps.map { |step| step[:arguments][:standards_template] }).to all(eq('90.1-2019')) + end + + it 'rejects an unsupported retrofit template' do + result = planner(doc, hvac_systems, 'DEER 2017').plan(measure_id: 'Measure-HVAC-RTU') + + expect(result.status).to eq(:unmapped) + expect(result.messages.join).to match(/DEER 2017/) + end + + it 'rejects partial replacement of existing HVAC' do + other = element(doc, 'HVACSystem-1').deep_clone + other.attributes['ID'] = 'HVACSystem-2' + hvac_systems.add_element(other) + result = planner(doc, hvac_systems).plan(measure_id: 'Measure-HVAC-RTU') + + expect(result.status).to eq(:unmapped) + expect(result.messages.join).to match(/HVACSystem-2 in place; partial HVAC replacement/) + end + + it 'rejects an alternative system that serves only part of the building' do + premises = REXML::XPath.first(element(doc, 'HVACSystem-proposed-RTU'), "*[local-name()='LinkedPremises']") + premises.elements.delete_all('*') + premises.add_element('ThermalZone').add_element('LinkedThermalZoneID', 'IDref' => 'TZ-1') + result = planner(doc, hvac_systems).plan(measure_id: 'Measure-HVAC-RTU') + + expect(result.status).to eq(:unmapped) + expect(result.messages.join).to match(/ThermalZone TZ-1.*only whole-building premises/) + end + + it 'maps ModifiedSystem COPs to efficiency modifier steps' do + result = planner(doc, hvac_systems).plan(measure_id: 'Measure-HVAC-COP') + + expect(result.status).to eq(:mapped), result.messages.join("\n") + expect(result.steps.map { |step| step[:arguments][:modifier_arguments_json] }).to eq( + ['{"efficiency_metric":"dx_cooling_cop","efficiency_value":3.5}', + '{"efficiency_metric":"dx_heating_cop","efficiency_value":3.8}'] + ) + expect(result.steps).to all(include(measure_dir_name: 'apply_hvac_modifier_to_object_scope', + workflow_phase: 'hvac_modifiers')) + expect(result.steps.first[:arguments]).to include(modifier_measure: 'modify_existing_hvac_equipment_efficiencies', + object_scope: 'all_matching_objects') + end + + it 'does not convert non-COP efficiency units' do + units = REXML::XPath.first(element(doc, 'CoolingSource-proposed-COP'), "*[local-name()='AnnualCoolingEfficiencyUnits']") + units.text = 'EER' + result = planner(doc, hvac_systems).plan(measure_id: 'Measure-HVAC-COP') + + expect(result.status).to eq(:unmapped) + expect(result.messages.join).to match(/units 'EER' are not COP/) + end + + it 'replaces HVAC with VRF from the MeasureName' do + result = planner(doc, hvac_systems).plan(measure_id: 'Measure-HVAC-VRF', + measure_name: 'Install variable refrigerant flow system') + + expect(result.status).to eq(:mapped), result.messages.join("\n") + expect(result.steps.first[:arguments]).to include(topology_measure: 'hvac_vrf', operation: 'replace') + expect(result.steps.last).to eq(sizing) + end + + it 'needs whole-building premises for a MeasureName topology' do + REXML::XPath.first(element(doc, 'Measure-HVAC-VRF'), "*[local-name()='LinkedPremises']").remove + result = planner(doc, hvac_systems).plan(measure_id: 'Measure-HVAC-VRF', + measure_name: 'Install variable refrigerant flow system') + + expect(result.status).to eq(:unmapped) + expect(result.messages.join).to match(/links no premises/) + end + + it 'leaves other measures to the JSON map' do + result = planner(doc, hvac_systems).plan(measure_id: 'Measure-LEDs', + measure_name: 'Retrofit with light emitting diode technologies') + + expect(result.status).to eq(:not_hvac) + end +end diff --git a/spec/tests/unit/scenario_measure_map_spec.rb b/spec/tests/unit/scenario_measure_map_spec.rb index 85ea441..e6fdd37 100644 --- a/spec/tests/unit/scenario_measure_map_spec.rb +++ b/spec/tests/unit/scenario_measure_map_spec.rb @@ -85,7 +85,7 @@ it 'assigns each step a declared workflow phase' do expect(scenario_measure_map.fetch('workflow_phases')).to eq [ - 'envelope', 'internal_loads', 'hvac_equipment', 'controls_operations' + 'envelope', 'internal_loads', 'hvac_equipment', 'hvac_modifiers', 'controls_operations' ] phases = mappings.to_h do |mapping| diff --git a/spec/tests/unit/scenario_measure_mapper_spec.rb b/spec/tests/unit/scenario_measure_mapper_spec.rb index 86e758c..b2ebbcc 100644 --- a/spec/tests/unit/scenario_measure_mapper_spec.rb +++ b/spec/tests/unit/scenario_measure_mapper_spec.rb @@ -11,6 +11,7 @@ require 'BOSS/constants' require 'BOSS/buildingsync_reader/buildingsync_reader' require 'BOSS/scenario_measure_mapper' +require 'BOSS/scenario_hvac_planner' RSpec.describe 'ScenarioMeasureMapper' do def mapper_fixture_path(*parts) @@ -575,6 +576,27 @@ def package_scenario(measure_ids) end end + it 'use the HVAC planner before the JSON map' do + reader = fixture_reader('example-smalloffice-level2-hvac-retrofits.xml') + doc = REXML::Document.new(File.read(mapper_fixture_path('v2.7.0', 'example-smalloffice-level2-hvac-retrofits.xml')), + ignore_whitespace_nodes: :all) + hvac_planner = BOSS::ScenarioHvacPlanner.new(REXML::XPath.first(doc, "//*[local-name()='HVACSystems']"), doc, + 'DOE Ref 1980-2004') + scenarios = reader.get_package_measure_scenarios.to_h { |scenario| [scenario[:scenario_id], scenario] } + map = ->(id) { mapper.map_package_scenario(scenarios.fetch(id), reader.get_measures, hvac_planner:) } + + expect(map.call('Scenario-POM-HVAC-RTU')[:steps].map { |step| step[:measure_dir_name] }) + .to eq ['apply_hvac_topology_to_zone_scope', 'apply_standard_hvac_sizing_and_efficiency'] + expect(map.call('Scenario-POM-HVAC-mixed')[:steps].map { |step| step[:workflow_phase] }) + .to eq ['hvac_modifiers', 'hvac_modifiers', 'internal_loads'] + expect(mapper.map_package_scenario(scenarios.fetch('Scenario-POM-HVAC-RTU'), reader.get_measures)[:status]).to eq :skipped + + hvac_planner = BOSS::ScenarioHvacPlanner.new(REXML::XPath.first(doc, "//*[local-name()='HVACSystems']"), doc, 'DEER 2017') + result = mapper.map_package_scenario(scenarios.fetch('Scenario-POM-HVAC-RTU'), reader.get_measures, hvac_planner:) + expect(result[:status]).to eq :skipped + expect(result[:warnings].first).to include(code: :hvac_measure_unmapped, message: /DEER 2017/) + end + it 'raise ArgumentError for invalid inputs' do expect { mapper.map_package_scenario(package_scenario([]), measures, context: 'x') }.to raise_error(ArgumentError, /context/) expect { mapper.map_package_scenario(nil, measures) }.to raise_error(ArgumentError, /scenario must be a Hash/) @@ -658,7 +680,7 @@ def package_scenario(measure_ids) end it 'expose the shipped workflow phases in order' do - expect(mapper.workflow_phases).to eq ['envelope', 'internal_loads', 'hvac_equipment', 'controls_operations'] + expect(mapper.workflow_phases).to eq ['envelope', 'internal_loads', 'hvac_equipment', 'hvac_modifiers', 'controls_operations'] end it 'allow legacy maps without workflow phases' do