Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] EUSS/SDR: roof/window measure updates and combining with HP-RTU measure #276

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

JanghyunJK
Copy link
Contributor

@JanghyunJK JanghyunJK commented Jan 24, 2025

Pull request overview

- roof upgrade measure update
- most functionality moved to ComStock\resources\measures\upgrade_env_roof_insul_aedg\resources\upgrade_env_roof_insul_aedg.rb

- window upgrade measure update
- most functionality moved to ComStock\resources\measures\upgrade_env_new_aedg_windows\resources\upgrade_env_new_aedg_windows.rb

- HP-RTU measure update
- the "exact same" two files above are saved under this measure folder: ComStock\resources\measures\upgrade_hvac_add_heat_pump_rtu\resources
- to provide the same functionality of roof/window upgrade measures inside of HP-RTU measure
- but to use HP-RTU applicability logic as the sole applicability logic
- minimum unit test added to check if window/roof measures are implemented or not implemented correctly

- so, based on the suggestion in this PR,
~~- whenever someone makes changes to either of these two files below, ~~
ComStock\resources\measures\upgrade_env_roof_insul_aedg\resources\upgrade_env_roof_insul_aedg.rb
ComStock\resources\measures\upgrade_env_new_aedg_windows\resources\upgrade_env_new_aedg_windows.rb
- then the same change should happen here:
ComStock\resources\measures\upgrade_hvac_add_heat_pump_rtu\resources
- and vise versa

Refer to a comment below for correct details

Pull Request Author

This pull request makes changes to (select all the apply):

  • Documentation
  • Infrastructure (includes apptainer image, buildstock batch, dependencies, continuous integration tests)
  • Sampling
  • Workflow Measures
  • Upgrade Measures
  • Reporting Measures
  • Postprocessing

Author pull request checklist:

  • Tagged the pull request with the appropriate label (documentation, infrastructure, sampling, workflow measure, upgrade measure, reporting measure, postprocessing) to help categorize changes in the release notes.
  • Added tests for new measures
  • Updated measure .xml(s)
  • Register values added to comstock_column_definitions.csv
  • Both options_lookup.tsv files updated
  • 10k+ test run
  • Change documentation written
  • Measure documentation written
  • ComStock documentation updated
  • Changes reflected in example .yml files
  • Changes reflected in README.md files
  • Added 'See ComStock License' language to first two lines of each code file
  • Implements corresponding measure tests and indexing path in test/reporting_measure_tests.txt, test/workflow_measure_tests.txt, or test/upgrade_measure_tests.txt
  • All new and existing tests pass the CI

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a code review on GitHub
  • All related changes have been implemented: data and method additions, changes, tests
  • If fixing a defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • Reviewed change documentation
  • Ensured code files contain License reference
  • Results differences are reasonable
  • Make sure the newly added measures has been added with tests and indexed properly
  • CI status: all tests pass

@JanghyunJK JanghyunJK added the upgrade measure PR improves or adds upgrade measures label Jan 24, 2025
@JanghyunJK JanghyunJK changed the title [WIP] roof/window measure updates and combining with HP-RTU measure roof/window measure updates and combining with HP-RTU measure Jan 27, 2025
@JanghyunJK
Copy link
Contributor Author

update options lookup!

@JanghyunJK JanghyunJK changed the title roof/window measure updates and combining with HP-RTU measure [WIP] roof/window measure updates and combining with HP-RTU measure Mar 3, 2025
@JanghyunJK JanghyunJK changed the title [WIP] roof/window measure updates and combining with HP-RTU measure [WIP] EUSS/SDR: roof/window measure updates and combining with HP-RTU measure Mar 3, 2025
@mdahlhausen mdahlhausen added the Do Not Merge Work in progress for code reviews label Mar 5, 2025
@JanghyunJK
Copy link
Contributor Author

made additional structural changes based on meetings with @ChristopherCaradonna @mpraprost @eringold. in short, it is (1) using parent/child runners, (2) call (child) measure within (parent) measure, and (3) better for minimizing redundant files. Examples shown below:

# call roof and/or window upgrades based on user input
condition_initial_roof = ''
condition_final_roof = ''
condition_initial_window = ''
condition_final_window = ''
if !selected_air_loops.empty?
if roof == true
runner.registerInfo('Running Roof Insulation measure....')
results_roof, runner = call_roof(model, runner)
condition_initial_roof = results_roof.stepInitialCondition.get
condition_final_roof = results_roof.stepFinalCondition.get
end
if window == true
runner.registerInfo('Running New Windows measure....')
results_window, runner = call_windows(model, runner)
condition_initial_window = results_window.stepInitialCondition.get
condition_final_window = results_window.stepFinalCondition.get
end
end

def child_to_parent_runner_logging(runner_parent, measure_name, results_child, registered_var_list = [])
# Register values from child runner to parent runner
registered_var_list.each do |registered_var|
JSON.parse(results_child.to_s)['step_values'].each do |step_value|
if step_value['name'].to_s == registered_var
runner_parent.registerValue(registered_var, step_value['value'], step_value['units'])
end
end
end
# Log warnings/infos/errors
results_child.warnings.each do |warning|
runner_parent.registerWarning(warning.logMessage)
end
results_child.info.each do |info|
runner_parent.registerInfo(info.logMessage)
end
results_child.errors.each do |error|
runner_parent.registerError(error.logMessage)
end
# Check if the measure ran successfully
if results_child.value.valueName == 'Success'
runner_parent.registerInfo("Child measure (#{measure_name}) was applied successfully.")
elsif results_child.value.valueName == 'NA'
runner_parent.registerInfo("Child measure (#{measure_name}) was not applicable.")
else
runner_parent.registerError("Child measure (#{measure_name}) failed.")
false
end
runner_parent
end
# create methods to call other measures for package runs
# putting this code in a resource file prevents issues with the OS app parsing
def call_roof(model, runner)
roof_measure_path = File.join(__dir__, '../../upgrade_env_roof_insul_aedg/measure.rb')
unless File.exist?(roof_measure_path)
runner.registerError('Roof Insulation measure not found. Check that this measure exists in your file structure and modify the measure path if necessary.')
return false
end
require roof_measure_path
roof_measure = EnvRoofInsulAedg.new
runner_roof = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
roof_measure.run(model, runner_roof, OpenStudio::Measure::OSArgumentMap.new)
roof_result = runner_roof.result
runner = child_to_parent_runner_logging(runner, roof_measure.name.to_s, roof_result, registered_var_list = ['env_roof_insul_roof_area_ft_2'])
return roof_result, runner
end
def call_windows(model, runner)
windows_measure_path = File.join(__dir__, '../../upgrade_env_new_aedg_windows/measure.rb')
unless File.exist?(windows_measure_path)
runner.registerError('New Windows measure not found. Check that this measure exists in your file structure and modify the measure path if necessary.')
return false
end
require windows_measure_path
windows_measure = EnvNewAedgWindows.new
runner_windows = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
windows_measure.run(model, runner_windows, OpenStudio::Measure::OSArgumentMap.new)
windows_result = runner_windows.result
runner = child_to_parent_runner_logging(runner, windows_measure.name.to_s, windows_result, registered_var_list = ['env_secondary_window_fen_area_ft_2'])
return windows_result, runner
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Do Not Merge Work in progress for code reviews upgrade measure PR improves or adds upgrade measures
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants