diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c139b8..5a799b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: uses: actions/checkout@v4 with: repository: BuildingSync/buildingsync-measures-gem - ref: 30cdd344db06a8708b79946b1a8b904fe9c3d6c4 + ref: 789bd50ec0ba42559f85e5cac23fcbbf8f9bdfbe path: buildingsync-measures-gem - name: Setup run: | diff --git a/docs/scenario_workflow_translation_plan.md b/docs/scenario_workflow_translation_plan.md index d11dda3..8a24232 100644 --- a/docs/scenario_workflow_translation_plan.md +++ b/docs/scenario_workflow_translation_plan.md @@ -116,9 +116,9 @@ Measure source order for new mappings: `buildingsync-measures-gem` is not released as a gem. BOSS loads it from a local sibling checkout (`../buildingsync-measures-gem`) configured in `config/external_measure_repos.yml`. Other sources keep their current install path. -HVAC mappings follow the upstream [HVAC Mapping and Migration Guide](https://github.com/BuildingSync/buildingsync-measures-gem/blob/develop/docs/HVAC_MAPPING_AND_MIGRATION.md): 17 topology measures (`operation` create/replace, comma-separated `target_zone_names`, `standards_template` 90.1-2013/2016/2019) plus 5 `modify_existing_*` modifiers that take exact OpenStudio object names. Do not map to the deprecated `modify_hvac`. A principal HVAC label alone is family evidence, not an exact match. Do not invent model object or zone names from BuildingSync IDs. +HVAC mappings follow the upstream [HVAC Mapping and Migration Guide](https://github.com/BuildingSync/buildingsync-measures-gem/blob/develop/docs/HVAC_MAPPING_AND_MIGRATION.md): 17 topology measures (`operation` create/replace, comma-separated `target_zone_names`, `standards_template` DOE Ref Pre-1980, DOE Ref 1980-2004, or 90.1-2004 through 90.1-2019) plus 5 `modify_existing_*` modifiers that take exact OpenStudio object names. Do not map to the deprecated `modify_hvac`. A principal HVAC label alone is family evidence, not an exact match. Do not invent model object or zone names from BuildingSync IDs. -Verify every measure directory and argument against the source BOSS will load: the `BOSS.gemspec` gem versions, or the merged `buildingsync-measures-gem` ref. Do not map to measures that exist only on an unmerged branch. +Verify every measure directory and argument against the source BOSS will load: the `BOSS.gemspec` gem versions, or the `buildingsync-measures-gem` commit pinned in CI. During PR 14A-14E, CI may pin an unmerged `buildingsync-measures-gem` branch commit; the upstream merge and CI ref bump are the last step of PR 14E. Outside that series, do not map to measures that exist only on an unmerged branch. Keep relative-change mappings (for example "reduce by percentage") on relative measures. Do not swap them for absolute-target measures unless the measure skips models that already meet the target. @@ -309,12 +309,22 @@ Use this roadmap as the tracker. Keep `Status` and `Delivered by` current when a ### PR 14D: Baseline HVAC Integration -- Status: Planned +- Status: Done - Delivered by: - - Depends on: PR 14A-14C. -- Scope: For exact-match files, run `create_typical_building_from_model` with `add_hvac: false`, then the split topology `create` steps. `add_hvac: false` also skips standards sizing and HVAC efficiency steps, so this PR must account for them. Otherwise keep the current baseline and warn (missing or family-only HVAC data, or templates other than 90.1-2013/2016/2019). +- Scope: For exact-match files, run `create_typical_building_from_model` with `add_hvac: false`, then the split topology `create` steps. `add_hvac: false` also skips standards sizing and HVAC efficiency steps, so this PR must account for them. Otherwise keep the current baseline and warn (missing or family-only HVAC data, or templates the split measures do not accept, such as DEER). - Done when: Exact-match baselines simulate with the expected HVAC; fallback files keep their current steps and log why; baseline-only and scenario-writer baselines match. - Avoid: Mapping DOE Ref, older 90.1, or DEER templates to 90.1-2019, or adding HVAC on top of `add_hvac: true`. +- Findings: with `add_hvac: false`, openstudio-standards 0.8.2 `create_typical_building_from_model` skips PRM sizing parameters, the sizing run, multizone VAV outdoor-air sizing, prototype HVAC assumptions, the HVAC efficiency standard, and NIST infiltration schedules; its night-cycle thermostat change then finds no managers. Topology measures do none of these. No existing measure runs this tail alone. +- Decision: `BOSS::BaselineHvacPlanner` (`lib/BOSS/baseline_hvac_planner.rb`) plans topology HVAC only when every selector result is `:match`, binds to whole-building premises, the template is in `HvacTargetBinder::STANDARDS_TEMPLATES` (DOE Ref Pre-1980, DOE Ref 1980-2004, 90.1-2004 through 90.1-2019), and there is exactly one conditioning configuration plus at most one ventilation configuration (ventilation only with zone-equipment topologies, since DOAS `create` rejects air-loop zones). Steps go right after `create_typical_building_from_model`: conditioning, then ventilation, then the new upstream measure `apply_standard_hvac_sizing_and_efficiency`, which mirrors the skipped tail. Otherwise `build_baseline_osw` keeps `add_hvac: true` and logs each reason. When topology steps are used, the baseline adds the scenario-only `buildingsync-measures-gem` measure path. Baseline-only and scenario writers share `build_baseline_osw`. +- Current fixture effect: `example-smalloffice-level2` (and its 2012 copy) plan topology HVAC; every other v2.7.0 fixture falls back. Files with no standard or a DEER template fail the template gate. The first HVAC reason for the rest is: family-only `PrincipalHVACSystemType` data (L100 files, `building_151_level1`, `example-smalloffice-level1`, `all_measures_applied_example`, BETTER); HVACSystems the selector sees without Delivery/OtherHVACSystem records (most ASHRAE-L2-style, Chula Vista, NYC, San Francisco, HOMES, Golden Test File, ASHRAE 211 Export); heat/energy-recovery ventilation (`not_mappable`: BuildingEQ, `Example_ASHRAE_L2_Report`); and detailed data that matches no known configuration (`Reference-PrimarySchool-L200-Audit`, `Example_NYC_Energy_Efficiency_Report_Property_2`). The gaps behind these are listed in `docs/hvac_mapping_gaps.md`. +- Follow-up: delivery premises inheritance and `None`/untyped ventilation handling landed in 14B and did not unlock a fixture. +- Configuration merging: the planner treats results with the same measure and `measure_arguments` as one configuration, whatever their group keys. Its premises count as whole-building (one `apply_hvac_topology_to_zone_scope` step with `all_model_zones`) when every link is a `Section` of the single `Building` and the links include its `Whole building` section or every other non-empty section. Partial section coverage still returns `missing_input`. +- First topology fixture: `example-smalloffice-level2` (built 2000, `DOE Ref 1980-2004`) plans one Packaged Rooftop Heat Pump step with `{"supplemental_heating_fuel":"NaturalGas"}`, then the sizing step. The test-only copy `spec/files/v2.7.0/example-smalloffice-level2-built-2012.xml` sets `YearOfConstruction` and `YearOfLastMajorRemodel` to 2012 and covers the same plan at `90.1-2013`. +- Older templates: the gem branch widened `standards_template` on every topology measure, the wrapper, and the sizing measure to DOE Ref Pre-1980, DOE Ref 1980-2004, and 90.1-2004 through 90.1-2019, and its shared topology test creates each measure's system at every older template. BOSS's reader never emits `90.1-2004` (2004-2006 maps to `90.1-2007`); changing that year mapping is out of scope. +- Remaining: `apply_standard_hvac_sizing_and_efficiency` is on the gem branch; CI now pins `789bd50`, which also adds older-template support. Its Minitest covers arguments and input checks only, and the BOSS integration spec below exercises the sizing path. The upstream merge moves to the end of PR 14E. +- Manual baseline run (OpenStudio 3.10.0, San Francisco TMY3): `boss write_baseline_osw` on the 2012 copy wrote the topology steps, and every step succeeded. The model has 9 single-zone PSZ-HP air loops with gas backup coils, 90.1-2013 efficiencies (14 SEER / 8.0 HSPF), 25.5 h heating and 25 h cooling setpoints not met, and EnergyPlus had 0 severe errors. The run log also shows one `Step already started` OSRunner error, apparently from the sizing step, which still succeeds; the cause is not investigated. +- Integration check: `spec/tests/integration/write_and_run_osws_spec.rb` writes and runs the baseline for `example-smalloffice-level2` (`DOE Ref 1980-2004`) and its 2012 copy (`90.1-2013`). Each asserts `add_hvac: false`, a successful topology step that reports PSZ-HP loops with NaturalGas supplemental heat at the expected template, and a successful sizing step (about 1.5 minutes each locally). ### PR 14E: Scenario HVAC Mappings @@ -324,6 +334,7 @@ Use this roadmap as the tracker. Keep `Status` and `Delivered by` current when a - 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. +- 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 new file mode 100644 index 0000000..371ef55 --- /dev/null +++ b/lib/BOSS/baseline_hvac_planner.rb @@ -0,0 +1,121 @@ +# 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/hvac_topology_selector' +require 'BOSS/hvac_target_binder' + +module BOSS + # Decides whether the baseline builds HVAC from split topology measures or keeps + # create_typical_building_from_model HVAC. + # + # Every binder step resolves to all model zones, so a topology plan allows one + # conditioning configuration plus, for zone-equipment configurations only, one + # ventilation configuration (DOAS create rejects zones already on an air loop). + # Results with the same measure and measure arguments are one configuration. Its + # Section links count as whole-building when they cover the building's sections. + class BaselineHvacPlanner + SIZING_MEASURE = 'apply_standard_hvac_sizing_and_efficiency' + VENTILATION_MEASURES = HvacTopologySelector::VENTILATION_MEASURES.values.map(&:last).freeze + ZONE_EQUIPMENT_MEASURES = ['hvac_ptac', 'hvac_pthp', 'hvac_four_pipe_fan_coil', 'hvac_vrf'].freeze + + Plan = Struct.new(:status, :steps, :messages, keyword_init: true) do + def topology? = status == :topology + end + + def initialize(selector: HvacTopologySelector.new, binder: HvacTargetBinder.new) + @selector = selector + @binder = binder + end + + # @param hvac_systems [REXML::Element, nil] the facility HVACSystems element + # @param standards_template [String] baseline create_typical template + # @return [Plan] :topology with ordered OSW steps, or :fallback with the reasons + def plan(hvac_systems, standards_template) + 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) + 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? + + 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 + problems << "Expected one conditioning configuration, found #{conditioning.length}; " \ + 'zone-level binding is not supported.' + end + problems << "Expected at most one ventilation configuration, found #{ventilation.length}." if ventilation.length > 1 + if !ventilation.empty? && conditioning.length == 1 && !ZONE_EQUIPMENT_MEASURES.include?(conditioning.first.measure) + problems << "#{ventilation.first.configuration} cannot be added to zones served by " \ + "#{conditioning.first.configuration} air loops." + end + return fallback(problems) if !problems.empty? + + bindings = (conditioning + ventilation).map do |result| + [result, @binder.bind(result, operation: 'create', standards_template:)] + end + 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 + 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) + return nil if premises.empty? || !premises.all? { |premise| premise[:type] == 'Section' } + + buildings = REXML::XPath.match(hvac_systems.document, "//*[local-name()='Building'][@ID]") + return nil if buildings.length != 1 + + sections = REXML::XPath.match(buildings.first, "*[local-name()='Sections']/*[local-name()='Section'][@ID]") + section_ids = sections.map { |section| section.attributes['ID'] } + linked = premises.map { |premise| premise[:id] } + return nil if !(linked - section_ids).empty? + + whole, parts = sections.partition do |section| + REXML::XPath.first(section, "*[local-name()='SectionType']")&.text == 'Whole building' + end + whole_linked = whole.any? { |section| linked.include?(section.attributes['ID']) } + parts_linked = !parts.empty? && parts.all? do |section| + section.elements.empty? || linked.include?(section.attributes['ID']) + end + whole_linked || parts_linked ? buildings.first.attributes['ID'] : nil + end + + def fallback(messages) + Plan.new(status: :fallback, steps: [], messages:) + end + + def describe(result, status, messages) + label = result.configuration || result.hvac_system_id || 'HVACSystem' + "#{label} (#{status}): #{messages.join(' ')}" + end + end +end diff --git a/lib/BOSS/boss.rb b/lib/BOSS/boss.rb index cabeb5f..e0cbec0 100644 --- a/lib/BOSS/boss.rb +++ b/lib/BOSS/boss.rb @@ -11,6 +11,7 @@ require 'BOSS/osw_arg_populator' require 'BOSS/external_measure_repo_manager' require 'BOSS/scenario_measure_mapper' +require 'BOSS/baseline_hvac_planner' require 'openstudio/common_measures' require 'openstudio/model_articulation' @@ -201,7 +202,16 @@ 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) - OSWArgPopulator::populate_create_typical_building_from_model_args(baseline_osw, bsync_reader) + hvac_plan = BaselineHvacPlanner.new.plan(bsync_reader.get_hvac_systems_xml, bsync_reader.get_standard_template) + OSWArgPopulator::populate_create_typical_building_from_model_args(baseline_osw, bsync_reader, + add_hvac: !hvac_plan.topology?) + if hvac_plan.topology? + hvac_plan.steps.each { |step| OSWArgPopulator.append_step(baseline_osw, step) } + else + hvac_plan.messages.each do |message| + BOSS.BOSS_logger.warn("BOSS.Boss: Keeping create_typical_building_from_model HVAC: #{message}") + end + 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) @@ -215,7 +225,8 @@ def build_baseline_osw(bsync_reader) # Force ordering: local BOSS measures, extension-discovered (gems), then external repos. manager = ExternalMeasureRepoManager.new local_measure_dirs = manager.local_measure_directories - external_measure_dirs = manager.resolved_measure_directories + # Topology HVAC steps need buildingsync-measures-gem, which is otherwise scenario-only. + external_measure_dirs = manager.resolved_measure_directories(include_scenario_only: hvac_plan.topology?) discovered_measure_dirs = baseline_osw[:measure_paths] || [] discovered_nonlocal_nonexternal = discovered_measure_dirs.reject do |path| diff --git a/lib/BOSS/buildingsync_reader/buildingsync_reader.rb b/lib/BOSS/buildingsync_reader/buildingsync_reader.rb index 021d098..9ddb68d 100644 --- a/lib/BOSS/buildingsync_reader/buildingsync_reader.rb +++ b/lib/BOSS/buildingsync_reader/buildingsync_reader.rb @@ -399,6 +399,11 @@ def get_aspect_ratio return aspect_ratio.to_f end + # @return [REXML::Element, nil] the facility HVACSystems element + def get_hvac_systems_xml + @facility_xml.elements["#{@ns}Systems/#{@ns}HVACSystems"] + end + # get principal hvac system type # @return [String] def get_principal_HVAC_system_type diff --git a/lib/BOSS/hvac_target_binder.rb b/lib/BOSS/hvac_target_binder.rb index 75f77d6..e0e4f02 100644 --- a/lib/BOSS/hvac_target_binder.rb +++ b/lib/BOSS/hvac_target_binder.rb @@ -30,7 +30,8 @@ class HvacTargetBinder }.freeze PLANT_LOOP_TYPES = ['Heating', 'Cooling', 'Condenser'].freeze WHOLE_BUILDING_PREMISES = ['Building', 'Site', 'Facility'].freeze - STANDARDS_TEMPLATES = ['90.1-2013', '90.1-2016', '90.1-2019'].freeze + STANDARDS_TEMPLATES = ['DOE Ref Pre-1980', 'DOE Ref 1980-2004', '90.1-2004', '90.1-2007', '90.1-2010', + '90.1-2013', '90.1-2016', '90.1-2019'].freeze OPERATIONS = ['create', 'replace'].freeze Binding = Struct.new(:status, :step, :messages, keyword_init: true) diff --git a/lib/BOSS/osw_arg_populator.rb b/lib/BOSS/osw_arg_populator.rb index b8057bd..b6acea3 100644 --- a/lib/BOSS/osw_arg_populator.rb +++ b/lib/BOSS/osw_arg_populator.rb @@ -145,7 +145,7 @@ def self.populate_create_bar_from_building_type_ratios_args(osw, bsync_reader) BOSS.BOSS_logger.info("") end - def self.populate_create_typical_building_from_model_args(osw, bsync_reader) + def self.populate_create_typical_building_from_model_args(osw, bsync_reader, add_hvac: true) BOSS.BOSS_logger.info("+++++ populating measure create_typical_building_from_model +++++++++++++++") set_measure_argument = step_argument_setter(osw, "create_typical_building_from_model") @@ -183,8 +183,8 @@ def self.populate_create_typical_building_from_model_args(osw, bsync_reader) # add_thermostat # add_hvac BOSS.BOSS_logger.info("|\t- setting arg 'add_hvac'...") - BOSS.BOSS_logger.info("|\t defaults to 'true'") - set_measure_argument.call("add_hvac", true) + BOSS.BOSS_logger.info("|\t set to '#{add_hvac}'") + set_measure_argument.call("add_hvac", add_hvac) # add_refrigeration # modify_wkdy_op_hrs # wkdy_op_hrs_start_time diff --git a/spec/files/v2.7.0/example-smalloffice-level2-built-2012.xml b/spec/files/v2.7.0/example-smalloffice-level2-built-2012.xml new file mode 100644 index 0000000..5af7ad4 --- /dev/null +++ b/spec/files/v2.7.0/example-smalloffice-level2-built-2012.xml @@ -0,0 +1,2733 @@ + + + + + + + + + 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 + 2012 + 2000 + 2010 + 2020-03-01 + 2012 + +
+ 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 + + +
+ + + + + +
+
+
+
+ + + + + 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 + + + + + + + + + + + + + + + + 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 + + + + + + + + + + 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 d45b4c3..308a4e0 100644 --- a/spec/tests/integration/write_and_run_osws_spec.rb +++ b/spec/tests/integration/write_and_run_osws_spec.rb @@ -63,5 +63,28 @@ end end + + { + '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'] + }.each do |file_name, (output_name, template)| + it "write and run a topology HVAC baseline. File: #{file_name}, Template: #{template}" do + xml_path = File.join(SPEC_FILES_DIR, 'v2.7.0', file_name) + output_path = File.join(SPEC_OUTPUT_DIR, 'v2.7.0', 'write_and_run_baseline_osw', output_name) + + BOSS::Boss.write_baseline_osw(xml_path, output_path, nil, ASHRAE90_1) + BOSS::Boss.run_baseline_osw(output_path) + + out_osw = JSON.parse(File.read(File.join(output_path, 'baseline', 'out.osw')), symbolize_names: true) + expect(out_osw[:completed_status]).to eq 'Success' + steps = out_osw[:steps].to_h { |step| [step[:measure_dir_name], step] } + expect(steps['create_typical_building_from_model'][:arguments][:add_hvac]).to be false + topology = steps['apply_hvac_topology_to_zone_scope'] + expect(topology[:result][:step_result]).to eq 'Success' + expect(topology[:result][:step_final_condition]) + .to match(/Created \d+ PSZ-HP loops \(NaturalGas supplemental heat\).*#{Regexp.escape(template)}/) + expect(steps['apply_standard_hvac_sizing_and_efficiency'][:result][:step_result]).to eq 'Success' + end + end end end diff --git a/spec/tests/unit/baseline_hvac_planner_spec.rb b/spec/tests/unit/baseline_hvac_planner_spec.rb new file mode 100644 index 0000000..099dae0 --- /dev/null +++ b/spec/tests/unit/baseline_hvac_planner_spec.rb @@ -0,0 +1,132 @@ +# 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/boss_logger' +require 'BOSS/buildingsync_reader/buildingsync_reader' + +RSpec.describe BOSS::BaselineHvacPlanner do + building = [{ type: 'Building', id: 'B-1' }] + result = lambda do |status: :match, measure: 'hvac_ptac', configuration: 'PTAC', group_key: [:delivery, 'D-1'], premises: building, messages: []| + BOSS::HvacTopologySelector::Result.new(status:, configuration:, measure:, hvac_system_id: 'HVAC-1', + record_ids: [], premises:, group_key:, messages:) + end + hvac_systems = REXML::Document.new('').root + + def plan_for(results, systems, template = '90.1-2019') + selector = instance_double(BOSS::HvacTopologySelector, select: results) + described_class.new(selector:).plan(systems, template) + end + + it 'plans whole-building create steps, ventilation last, then sizing' do + doas = result.call(measure: 'hvac_doas', configuration: 'DOAS', group_key: [:other, 'O-1']) + plan = plan_for([doas, result.call, result.call(group_key: [:delivery, 'D-1'])], hvac_systems, '90.1-2016') + + expect(plan.status).to eq(:topology) + expect(plan.steps.map { |step| step[:measure_dir_name] }).to eq( + ['apply_hvac_topology_to_zone_scope', 'apply_hvac_topology_to_zone_scope', 'apply_standard_hvac_sizing_and_efficiency'] + ) + expect(plan.steps.map { |step| step[:arguments][:topology_measure] }.compact).to eq(['hvac_ptac', 'hvac_doas']) + expect(plan.steps.map { |step| step[:arguments][:operation] }.compact).to eq(['create', 'create']) + expect(plan.steps.map { |step| step[:arguments][:standards_template] }.uniq).to eq(['90.1-2016']) + end + + { + 'no HVACSystems' => [[], nil, '90.1-2019', /No HVACSystems/], + 'an unsupported template' => [[], :systems, 'DEER 2017', /Template 'DEER 2017'/], + 'family-only data' => [[{ status: :missing_input, messages: ['Only family-level data'] }], :systems, '90.1-2019', + /missing_input.*family-level/], + 'two conditioning configurations' => [[{}, { measure: 'hvac_pthp', group_key: [:delivery, 'D-2'] }], :systems, '90.1-2019', + /one conditioning configuration, found 2/], + 'ventilation on air-loop HVAC' => [[{ measure: 'hvac_warm_air_furnace', configuration: 'Furnace' }, + { measure: 'hvac_doas', configuration: 'DOAS', group_key: [:other, 'O-1'] }], + :systems, '90.1-2019', /DOAS cannot be added.*Furnace/], + 'zone-linked premises' => [[{ premises: [{ type: 'ThermalZone', id: 'TZ-1' }] }], :systems, '90.1-2019', + /only whole-building premises/] + }.each do |label, (specs, systems, template, message)| + it "falls back for #{label}" do + plan = plan_for(specs.map { |spec| result.call(**spec) }, systems && hvac_systems, template) + + expect(plan.status).to eq(:fallback) + expect(plan.steps).to be_empty + expect(plan.messages.join("\n")).to match(message) + end + end + + it 'plans a building-linked PTAC from BuildingSync XML' do + xml = '' \ + '' \ + 'Packaged terminal air conditioner (PTAC)' \ + '' \ + '' \ + '' \ + '' \ + '' + plan = described_class.new.plan(REXML::Document.new(xml).root, '90.1-2019') + + expect(plan.status).to eq(:topology), plan.messages.join("\n") + expect(plan.steps.first[:arguments][:topology_measure]).to eq('hvac_ptac') + end + + sectioned = REXML::Document.new( + '' \ + '
Space function
' \ + '
Space function
' \ + '
' + ) + sectioned_systems = REXML::XPath.first(sectioned, '//HVACSystems') + section = ->(id) { [{ type: 'Section', id: }] } + + it 'merges same-configuration deliveries whose Section links cover the building' do + results = [result.call(premises: section.call('S-1')), + result.call(premises: section.call('S-2'), group_key: [:delivery, 'D-2'])] + plan = plan_for(results, sectioned_systems) + + expect(plan.status).to eq(:topology), plan.messages.join("\n") + expect(plan.steps.map { |step| step[:arguments][:topology_measure] }.compact).to eq(['hvac_ptac']) + expect(plan.steps.first[:arguments][:zone_scope]).to eq('all_model_zones') + end + + it 'falls back when Section links leave part of the building unserved' do + plan = plan_for([result.call(premises: section.call('S-1'))], sectioned_systems) + + expect(plan.status).to eq(:fallback) + expect(plan.messages.join("\n")).to match(/Section S-1.*only whole-building premises/) + end + + it 'keeps different measure arguments as separate configurations' do + results = [['D-1', 'NaturalGas'], ['D-2', 'Electricity']].map do |id, fuel| + result.call(measure: 'hvac_packaged_rooftop_heat_pump', group_key: [:delivery, id]) + .tap { |r| r.measure_arguments = { 'supplemental_heating_fuel' => fuel } } + end + plan = plan_for(results, hvac_systems) + + expect(plan.messages.join("\n")).to match(/one conditioning configuration, found 2/) + end + + { + 'example-smalloffice-level2.xml' => 'DOE Ref 1980-2004', + 'example-smalloffice-level2-built-2012.xml' => '90.1-2013' + }.each do |file_name, template| + it "plans topology HVAC for #{file_name} with #{template}" do + path = File.expand_path("../../files/v2.7.0/#{file_name}", __dir__) + doc = REXML::Document.new(File.read(path), ignore_whitespace_nodes: :all) + reader = BOSS::BuildingSyncReader.new(doc, nil, ASHRAE90_1) + plan = described_class.new.plan(reader.get_hvac_systems_xml, reader.get_standard_template) + + expect(plan.status).to eq(:topology), plan.messages.join("\n") + step = plan.steps.first[:arguments] + expect(step).to include(topology_measure: 'hvac_packaged_rooftop_heat_pump', zone_scope: 'all_model_zones', + standards_template: template, + topology_arguments_json: '{"supplemental_heating_fuel":"NaturalGas"}') + expect(plan.steps.last).to eq(measure_dir_name: 'apply_standard_hvac_sizing_and_efficiency', + arguments: { standards_template: template }) + end + end +end diff --git a/spec/tests/unit/boss_spec.rb b/spec/tests/unit/boss_spec.rb index 2b54652..83c6b8f 100644 --- a/spec/tests/unit/boss_spec.rb +++ b/spec/tests/unit/boss_spec.rb @@ -202,6 +202,24 @@ def common_steps(climate_zone) expect(second[:measure_paths]).not_to include('/mutated') expect(second[:file_paths]).not_to include('/mutated') end + + it 'replaces create_typical HVAC with planned topology steps and adds scenario-only measure paths' do + stub_measure_dirs(local: [LOCAL_MEASURES_DIR], external: [external_measure_dir], discovered: [gem_measure_dir], + scenario_only: ['/bsync/measures']) + steps = [{ measure_dir_name: 'apply_hvac_topology_to_zone_scope', arguments: { topology_measure: 'hvac_ptac' } }, + { measure_dir_name: 'apply_standard_hvac_sizing_and_efficiency', arguments: {} }] + plan = BOSS::BaselineHvacPlanner::Plan.new(status: :topology, steps: steps, messages: []) + allow_any_instance_of(BOSS::BaselineHvacPlanner).to receive(:plan).and_return(plan) + + osw = described_class.send(:build_baseline_osw, build_reader('all_measures_applied_example.xml')) + names = osw[:steps].map { |step| step[:measure_dir_name] } + typical = names.index('create_typical_building_from_model') + + expect(osw[:steps][typical][:arguments][:add_hvac]).to be false + expect(names[typical + 1, 2]).to eq(steps.map { |step| step[:measure_dir_name] }) + expect(names - steps.map { |step| step[:measure_dir_name] }).to eq(all_measures_steps.map { |step| step[:measure_dir_name] }) + expect(osw[:measure_paths]).to include('/bsync/measures') + end end describe '.write_baseline_osw measure_paths ordering' do diff --git a/spec/tests/unit/hvac_target_binder_spec.rb b/spec/tests/unit/hvac_target_binder_spec.rb index 3c618e0..074123d 100644 --- a/spec/tests/unit/hvac_target_binder_spec.rb +++ b/spec/tests/unit/hvac_target_binder_spec.rb @@ -84,7 +84,7 @@ def match_result(premises, measure: 'hvac_ptac') it 'rejects templates and operations the topology measures do not support' do result = match_result([{ type: 'Building', id: 'B-1' }]) - expect { binder.bind(result, operation: 'create', standards_template: 'DOE Ref Pre-1980') } + expect { binder.bind(result, operation: 'create', standards_template: 'DEER 2017') } .to raise_error(ArgumentError, /standards_template/) expect { binder.bind(result, operation: 'delete', standards_template: '90.1-2019') } .to raise_error(ArgumentError, /operation/)