Skip to content

Commit

Permalink
Merge pull request #1342 from NREL/no_lib
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeee authored Feb 1, 2025
2 parents 1347681 + 9fd057d commit cd7cf2a
Show file tree
Hide file tree
Showing 20 changed files with 451 additions and 478 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Run ``openstudio workflow/run_analysis.rb -h`` to see all available commands/arg
-u, --upgrade_name NAME Only run this upgrade; can be called multiple times
-k, --keep_run_folders Preserve run folder for all datapoints; also populates run folder in cli_output.log and results-xxx.csv files
-s, --samplingonly Run the sampling only
-d, --debug Preserve lib folder and xml/osw files for existing building
-d, --debug Preserve xml/osw files for existing building
-o, --overwrite Overwrite existing project directory
-v, --version Display version
-h, --help Display help
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ completed_status,"Simulation Success, Fail, or Invalid."
build_existing_model.air_leakage_to_outside_ach_50,Total infiltration to the dwelling unit adjusted by ratio of exterior envelope surface area to total envelope surface area.
build_existing_model.applicable,The measure was applied to the workflow.
build_existing_model.buildstock_csv_path,Absolute/relative path of the buildstock CSV file. Relative is compared to the 'lib/housing_characteristics' directory.
build_existing_model.project_directory,The project directory containing the housing characteristics folder (e.g.
build_existing_model.sample_weight,Number of buildings this simulation represents.
build_existing_model.units_represented,The number of dwelling units this simulation represents. Should always be one.
build_existing_model.emissions_electricity_folders,"Relative paths of electricity emissions factor schedule files with hourly values. Paths are relative to the resources folder. If multiple scenarios, use a comma-separated list. File names must contain GEA region names."
Expand Down
11 changes: 11 additions & 0 deletions measures/ApplyUpgrade/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ User-specificed name that describes the upgrade.

<br/>

**Project Directory**

The directory containing the housing characteristics folder (e.g., project_national).

- **Name:** ``project_directory``
- **Type:** ``String``

- **Required:** ``true``

<br/>

**Option 1**

Specify the parameter|option as found in resources\options_lookup.tsv.
Expand Down
14 changes: 9 additions & 5 deletions measures/ApplyUpgrade/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ def arguments(model) # rubocop:disable Lint/UnusedMethodArgument
upgrade_name.setDefaultValue('My Upgrade')
args << upgrade_name

project_directory = OpenStudio::Measure::OSArgument::makeStringArgument('project_directory', true)
project_directory.setDisplayName('Project Directory')
project_directory.setDescription('The directory containing the housing characteristics folder (e.g., project_national).')
args << project_directory

for option_num in 1..num_options

# Option name argument
Expand Down Expand Up @@ -120,8 +125,7 @@ def run(model, runner, user_arguments)
return true
end

upgrade_name = runner.getStringArgumentValue('upgrade_name', user_arguments)

args = runner.getArgumentValues(arguments(model), user_arguments)
# Retrieve Option X argument values
options = {}
for option_num in 1..num_options
Expand Down Expand Up @@ -180,8 +184,8 @@ def run(model, runner, user_arguments)
end

# Get file/dir paths
resources_dir = File.absolute_path(File.join(File.dirname(__FILE__), '../../lib/resources'))
characteristics_dir = File.absolute_path(File.join(File.dirname(__FILE__), '../../lib/housing_characteristics'))
resources_dir = File.absolute_path(File.join(File.dirname(__FILE__), '../../resources'))
characteristics_dir = File.absolute_path(File.join(File.dirname(__FILE__), "../../#{args[:project_directory]}/housing_characteristics"))
measures_dir = File.join(File.dirname(__FILE__), '../../measures')
hpxml_measures_dir = File.join(File.dirname(__FILE__), '../../resources/hpxml-measures')
lookup_file = File.join(resources_dir, 'options_lookup.tsv')
Expand Down Expand Up @@ -306,7 +310,7 @@ def run(model, runner, user_arguments)
end # apply_package_upgrade

# Register the upgrade name
register_value(runner, 'upgrade_name', upgrade_name)
register_value(runner, 'upgrade_name', args[:upgrade_name])

if halt_workflow(runner, measures)
return false
Expand Down
16 changes: 12 additions & 4 deletions measures/ApplyUpgrade/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.1</schema_version>
<name>apply_upgrade</name>
<uid>33f1654c-f734-43d1-b35d-9d2856e41b5a</uid>
<version_id>b13107fd-04b8-4c79-948d-52b75ccc94a3</version_id>
<version_modified>2024-12-09T16:49:56Z</version_modified>
<version_id>9e554ddb-2d72-4a51-b9c1-fcd24c95f33d</version_id>
<version_modified>2025-01-30T17:46:21Z</version_modified>
<xml_checksum>9339BE01</xml_checksum>
<class_name>ApplyUpgrade</class_name>
<display_name>Apply Upgrade</display_name>
Expand All @@ -20,6 +20,14 @@
<model_dependent>false</model_dependent>
<default_value>My Upgrade</default_value>
</argument>
<argument>
<name>project_directory</name>
<display_name>Project Directory</display_name>
<description>The directory containing the housing characteristics folder (e.g., project_national).</description>
<type>String</type>
<required>true</required>
<model_dependent>false</model_dependent>
</argument>
<argument>
<name>option_1</name>
<display_name>Option 1</display_name>
Expand Down Expand Up @@ -25000,7 +25008,7 @@
<filename>README.md</filename>
<filetype>md</filetype>
<usage_type>readme</usage_type>
<checksum>2A0F08F6</checksum>
<checksum>601CF1E9</checksum>
</file>
<file>
<filename>README.md.erb</filename>
Expand All @@ -25017,7 +25025,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>F73DDD7C</checksum>
<checksum>42D55698</checksum>
</file>
<file>
<filename>constants.rb</filename>
Expand Down
11 changes: 11 additions & 0 deletions measures/BuildExistingModel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ Absolute/relative path of the buildstock CSV file. Relative is compared to the '

<br/>

**Project Directory**

The directory containing the housing characteristics folder (e.g., project_national).

- **Name:** ``project_directory``
- **Type:** ``String``

- **Required:** ``true``

<br/>

**Building Unit ID**

The building unit number (between 1 and the number of samples).
Expand Down
11 changes: 7 additions & 4 deletions measures/BuildExistingModel/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
require 'pathname'
require_relative '../../resources/buildstock'
require_relative '../../resources/hpxml-measures/HPXMLtoOpenStudio/resources/meta_measure'

# start the measure
class BuildExistingModel < OpenStudio::Measure::ModelMeasure
# human readable name
Expand Down Expand Up @@ -35,6 +34,11 @@ def arguments(model) # rubocop:disable Lint/UnusedMethodArgument
arg.setDescription("Absolute/relative path of the buildstock CSV file. Relative is compared to the 'lib/housing_characteristics' directory.")
args << arg

arg = OpenStudio::Measure::OSArgument.makeStringArgument('project_directory', true)
arg.setDisplayName('Project Directory')
arg.setDescription('The directory containing the housing characteristics folder (e.g., project_national).')
args << arg

arg = OpenStudio::Measure::OSArgument.makeIntegerArgument('building_id', true)
arg.setDisplayName('Building Unit ID')
arg.setDescription('The building unit number (between 1 and the number of samples).')
Expand Down Expand Up @@ -237,10 +241,9 @@ def run(model, runner, user_arguments)

# assign the user inputs to variables
args = runner.getArgumentValues(arguments(model), user_arguments)

# Get file/dir paths
resources_dir = File.absolute_path(File.join(File.dirname(__FILE__), '../../lib/resources'))
characteristics_dir = File.absolute_path(File.join(File.dirname(__FILE__), '../../lib/housing_characteristics'))
resources_dir = File.absolute_path(File.join(File.dirname(__FILE__), '../../resources'))
characteristics_dir = File.absolute_path(File.join(File.dirname(__FILE__), "../../#{args[:project_directory]}/housing_characteristics"))
measures_dir = File.join(File.dirname(__FILE__), '../../measures')
hpxml_measures_dir = File.join(File.dirname(__FILE__), '../../resources/hpxml-measures')
lookup_file = File.join(resources_dir, 'options_lookup.tsv')
Expand Down
16 changes: 12 additions & 4 deletions measures/BuildExistingModel/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.1</schema_version>
<name>build_existing_model</name>
<uid>dedf59bb-3b88-4f16-8755-2c1ff5519cbf</uid>
<version_id>0e78d978-0224-4cf4-a57b-9c0cb5b7c5b4</version_id>
<version_modified>2024-11-08T15:53:00Z</version_modified>
<version_id>8d7c2d5f-2ee5-4f23-bd93-debbead74238</version_id>
<version_modified>2025-01-30T17:46:22Z</version_modified>
<xml_checksum>2C38F48B</xml_checksum>
<class_name>BuildExistingModel</class_name>
<display_name>Build Existing Model</display_name>
Expand All @@ -20,6 +20,14 @@
<model_dependent>false</model_dependent>
<default_value>buildstock.csv</default_value>
</argument>
<argument>
<name>project_directory</name>
<display_name>Project Directory</display_name>
<description>The directory containing the housing characteristics folder (e.g., project_national).</description>
<type>String</type>
<required>true</required>
<model_dependent>false</model_dependent>
</argument>
<argument>
<name>building_id</name>
<display_name>Building Unit ID</display_name>
Expand Down Expand Up @@ -332,7 +340,7 @@
<filename>README.md</filename>
<filetype>md</filetype>
<usage_type>readme</usage_type>
<checksum>52F0E677</checksum>
<checksum>E4A69761</checksum>
</file>
<file>
<filename>README.md.erb</filename>
Expand All @@ -349,7 +357,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>9AE772B3</checksum>
<checksum>32867677</checksum>
</file>
</files>
</measure>
6 changes: 3 additions & 3 deletions measures/ResStockArguments/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.1</schema_version>
<name>res_stock_arguments</name>
<uid>c984bb9e-4ac4-4930-a399-9d23f8f6936a</uid>
<version_id>6551a88a-6788-4ff9-a7ce-1121bbc25831</version_id>
<version_modified>2025-01-06T19:50:11Z</version_modified>
<version_id>87f66003-9d8d-48be-9ea5-17006046955d</version_id>
<version_modified>2025-01-30T17:46:23Z</version_modified>
<xml_checksum>2C38F48B</xml_checksum>
<class_name>ResStockArguments</class_name>
<display_name>ResStock Arguments</display_name>
Expand Down Expand Up @@ -7713,7 +7713,7 @@
<filename>measure.txt</filename>
<filetype>txt</filetype>
<usage_type>resource</usage_type>
<checksum>5505BBDE</checksum>
<checksum>96A4BB9E</checksum>
</file>
<file>
<filename>resstock_arguments_test.rb</filename>
Expand Down
2 changes: 1 addition & 1 deletion measures/ResStockArguments/resources/measure.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
357944431a5a88e46e2b12c30da3f703
3827e629e35c9fbbbc53363b9886e22d
40 changes: 14 additions & 26 deletions measures/UpgradeCosts/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.1</schema_version>
<name>upgrade_costs</name>
<uid>ef51212c-acc4-48d7-9b29-cf2a5c6c4449</uid>
<version_id>8933734c-bf10-4373-ab9b-1da1ae0320fc</version_id>
<version_modified>2025-01-16T22:12:20Z</version_modified>
<version_id>73179d58-f009-4c1d-aa51-5d693db0af39</version_id>
<version_modified>2025-01-30T17:46:24Z</version_modified>
<xml_checksum>B1F14CB4</xml_checksum>
<class_name>UpgradeCosts</class_name>
<display_name>Upgrade Costs</display_name>
Expand Down Expand Up @@ -137,12 +137,6 @@
<usage_type>test</usage_type>
<checksum>F6EDB94F</checksum>
</file>
<file>
<filename>SFD_1story_FB_UA_GRG_MSHP_FuelTanklessWH.xml</filename>
<filetype>xml</filetype>
<usage_type>test</usage_type>
<checksum>042AD716</checksum>
</file>
<file>
<filename>SFD_1story_FB_UA_GRG_RoomAC_ElecBoiler_FuelTanklessWH.osw</filename>
<filetype>osw</filetype>
Expand All @@ -167,24 +161,12 @@
<usage_type>test</usage_type>
<checksum>D2426054</checksum>
</file>
<file>
<filename>SFD_1story_UB_UA_GRG_ACV_FuelFurnace_PortableHeater_HPWH.xml</filename>
<filetype>xml</filetype>
<usage_type>test</usage_type>
<checksum>90472515</checksum>
</file>
<file>
<filename>SFD_2story_CS_UA_AC2_FuelBoiler_FuelTankWH.osw</filename>
<filetype>osw</filetype>
<usage_type>test</usage_type>
<checksum>A32DA75D</checksum>
</file>
<file>
<filename>SFD_2story_CS_UA_AC2_FuelBoiler_FuelTankWH.xml</filename>
<filetype>xml</filetype>
<usage_type>test</usage_type>
<checksum>1A1A2554</checksum>
</file>
<file>
<filename>SFD_2story_CS_UA_GRG_ASHPV_FuelTanklessWH.osw</filename>
<filetype>osw</filetype>
Expand All @@ -197,12 +179,6 @@
<usage_type>test</usage_type>
<checksum>DB92211A</checksum>
</file>
<file>
<filename>SFD_2story_FB_UA_GRG_AC1_ElecBaseboard_FuelTankWH.xml</filename>
<filetype>xml</filetype>
<usage_type>test</usage_type>
<checksum>6F563BAF</checksum>
</file>
<file>
<filename>SFD_2story_FB_UA_GRG_AC1_UnitHeater_FuelTankWH.osw</filename>
<filetype>osw</filetype>
Expand Down Expand Up @@ -239,6 +215,18 @@
<usage_type>test</usage_type>
<checksum>083B023F</checksum>
</file>
<file>
<filename>results_annual.csv</filename>
<filetype>csv</filetype>
<usage_type>test</usage_type>
<checksum>5687044D</checksum>
</file>
<file>
<filename>results_design_load_details.csv</filename>
<filetype>csv</filetype>
<usage_type>test</usage_type>
<checksum>19F07CC2</checksum>
</file>
<file>
<filename>upgrade_costs_test.rb</filename>
<filetype>rb</filetype>
Expand Down
2 changes: 1 addition & 1 deletion project_national/national_baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ sampler:
workflow_generator:
# ResStock HPXML workflow generator
type: residential_hpxml
version: 2024.07.20
version: 2025.01.29
args:
# Annual simulation and timestep
build_existing_model:
Expand Down
2 changes: 1 addition & 1 deletion project_national/sdr_upgrades_tmy3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ postprocessing:
workflow_generator:
# ResStock HPXML workflow generator
type: residential_hpxml
version: 2024.07.20
version: 2025.01.29

args:
# Annual simulation and timestep
Expand Down
2 changes: 1 addition & 1 deletion project_testing/testing_baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ sampler:
workflow_generator:
# ResStock HPXML workflow generator
type: residential_hpxml
version: 2024.07.20
version: 2025.01.29
args:
# Annual simulation and timestep
build_existing_model:
Expand Down
2 changes: 1 addition & 1 deletion resources/buildstock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module Version
ResStock_Version = '3.4.0' # Version of ResStock
BuildStockBatch_Version = '2023.10.0' # Minimum required version of BuildStockBatch
WorkflowGenerator_Version = '2024.07.20' # Version of buildstockbatch workflow generator
WorkflowGenerator_Version = '2025.01.29' # Version of buildstockbatch workflow generator

def self.check_buildstockbatch_version
if ENV.keys.include?('BUILDSTOCKBATCH_VERSION') # buildstockbatch is installed
Expand Down
1 change: 1 addition & 0 deletions resources/data/dictionary/inputs.csv
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ completed_status,"Simulation Success, Fail, or Invalid."
build_existing_model.air_leakage_to_outside_ach_50,Total infiltration to the dwelling unit adjusted by ratio of exterior envelope surface area to total envelope surface area.
build_existing_model.applicable,The measure was applied to the workflow.
build_existing_model.buildstock_csv_path,Absolute/relative path of the buildstock CSV file. Relative is compared to the 'lib/housing_characteristics' directory.
build_existing_model.project_directory,The project directory containing the housing characteristics folder (e.g., project_national).
build_existing_model.sample_weight,Number of buildings this simulation represents.
build_existing_model.units_represented,The number of dwelling units this simulation represents. Should always be one.
build_existing_model.emissions_electricity_folders,"Relative paths of electricity emissions factor schedule files with hourly values. Paths are relative to the resources folder. If multiple scenarios, use a comma-separated list. File names must contain GEA region names."
Expand Down
11 changes: 7 additions & 4 deletions resources/run_sampling_lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

require 'csv'
require_relative 'buildstock'
require 'pathname'

class RunSampling
def run(project_dir_name, num_samples, outfile, housing_characteristics_dir = 'housing_characteristics', lookup_file = nil)
Expand Down Expand Up @@ -292,13 +293,15 @@ def distribute_samples(random_seed, results_data_param, sample_results, bldgs)

def write_csv(sample_results, outfile)
# Writes the csv output file.
out_file = File.absolute_path(File.join(File.dirname(__FILE__), outfile))
CSV.open(out_file, 'w') do |csv_object|
unless (Pathname.new outfile).absolute?
outfile = File.absolute_path(File.join(File.dirname(__FILE__), outfile))
end
CSV.open(outfile, 'w') do |csv_object|
sample_results.each do |sample_result|
csv_object << sample_result
end
end
puts "Wrote output file #{File.basename(out_file)}."
return out_file
puts "Wrote output file #{File.basename(outfile)}."
return outfile
end
end
Loading

0 comments on commit cd7cf2a

Please sign in to comment.