Skip to content

Commit

Permalink
Merge pull request #44 from NREL/develop
Browse files Browse the repository at this point in the history
Release to main
  • Loading branch information
nllong authored May 6, 2022
2 parents 071e30e + b56c11f commit da65b68
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 40 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# OpenStudio Load Flexibility Measures Gem

## Version 0.5.0
* Updated OS Standards dependency to 0.2.16
* Fixed [#41](https://github.com/NREL/openstudio-load-flexibility-measures-gem/issues/41), Error in applying add_hpwh measure with "non-simplified" options to MF prototype building in OS 3.3

## Version 0.4.0
* Updated OS Extension dependency to 0.5.1
* Updated OS Standards dependency to 0.2.15
Expand Down
27 changes: 27 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

(1) Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.

(2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution.

(3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse
or promote products derived from this software without specific prior written permission from the
respective party.

(4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other
derivative works may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar
designation without specific prior written permission from Alliance for Sustainable Energy, LLC.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES GOVERNMENT,
OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Detailed instructions for usage are included in each measure's respective README

|OpenStudio Load Flexibility Measures Gem|OpenStudio|Ruby|
|:--------------:|:----------:|:--------:|
| 0.5 | 3.4 | 2.7 |
| 0.4 | 3.2 | 2.7 |
| 0.3.2 | 3.2 | 2.7 |
| 0.2.0 - 0.2.1 | 3.1 | 2.5 |
Expand All @@ -43,11 +44,14 @@ Please review the [OpenStudio Contribution Policy](https://openstudio.net/openst

# Releasing

* Update CHANGELOG.md
* Run rake rubocop:auto_correct
* Update version in `/lib/openstudio/openstudio-load-flexibility-measures/version.rb`
* Update `CHANGELOG.md`
* Run `rake rubocop:auto_correct`
* Run `rake openstudio:update_copyright`
* Run `rake openstudio:update_measures` (this has to be done last since prior tasks alter measure files)
* Update version in `readme.md`
* Update version in `openstudio-load-flexibility.gemspec`
* Update version in `/lib/openstudio/load-flexibility/version.rb`
* Create PR to master, after tests and reviews complete, then merge
* Locally - from the master branch, run rake release
* Release via github
* Locally - from the master branch, run `rake release`
* On GitHub, go to the releases page and update the latest release tag. Name it “Version x.y.z” and copy the CHANGELOG entry into the description box.

18 changes: 9 additions & 9 deletions lib/measures/add_central_ice_storage/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.0</schema_version>
<name>add_central_ice_storage</name>
<uid>48f37812-0cb6-4770-b695-beb8d8a5660d</uid>
<version_id>9f1db6c9-821d-4074-808f-f99782d223e9</version_id>
<version_modified>20211110T211234Z</version_modified>
<version_id>f8f68f4a-4f32-4051-8f1f-0ec842998763</version_id>
<version_modified>20220505T192248Z</version_modified>
<xml_checksum>6394841D</xml_checksum>
<class_name>AddCentralIceStorage</class_name>
<display_name>Add Central Ice Storage</display_name>
Expand Down Expand Up @@ -464,23 +464,23 @@
<usage_type>doc</usage_type>
<checksum>090841B0</checksum>
</file>
<file>
<filename>LICENSE.md</filename>
<filetype>md</filetype>
<usage_type>license</usage_type>
<checksum>E0468DD6</checksum>
</file>
<file>
<filename>README.md</filename>
<filetype>md</filetype>
<usage_type>readme</usage_type>
<checksum>962B1D2E</checksum>
</file>
<file>
<filename>LICENSE.md</filename>
<filetype>md</filetype>
<usage_type>license</usage_type>
<checksum>E0468DD6</checksum>
</file>
<file>
<filename>OsLib_Schedules.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>3E001F89</checksum>
<checksum>64AFEC72</checksum>
</file>
<file>
<filename>add_central_ice_storage_test.rb</filename>
Expand Down
17 changes: 14 additions & 3 deletions lib/measures/add_hpwh/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def arguments(model)

# find available water heaters and get default volume
default_vol = 80.0 # gallons
wheaters = []
wh_names = ['All Water Heaters (Simplified Only)']
if !model.getWaterHeaterMixeds.empty?
wheaters = model.getWaterHeaterMixeds
Expand Down Expand Up @@ -283,6 +284,18 @@ def run(model, runner, user_arguments)
db_temp = runner.getDoubleArgumentValue('db_temp', user_arguments)
sched = runner.getStringArgumentValue('sched', user_arguments)

# get zone of one was selected
if zone.to_s != 'N/A - Simplified'
if model.getThermalZoneByName(zone).is_initialized
zone = model.getThermalZoneByName(zone).get
else
runner.registerError("Could not find zone named #{zone} in the moodel")
return false
end
else
zone = 'N/A - Simplified'
end

4.times do |n|
flex << runner.getStringArgumentValue("flex#{n}", user_arguments)
flex_hrs << runner.getStringArgumentValue("flex_hrs#{n}", user_arguments)
Expand Down Expand Up @@ -531,12 +544,11 @@ def run(model, runner, user_arguments)
# => openstudio-standards/prototypes/common/objects/Prototype.ServiceWaterHeating.rb
if type != 'Simplified'
# convert zone name from STRING into OS model OBJECT
zone = model.getThermalZoneByName(zone).get
hpwh = std.model_add_heatpump_water_heater(model, # model
type: type, # type
water_heater_capacity: (cap * 1000 / cop), # water_heater_capacity
electric_backup_capacity: (bu_cap * 1000), # electric_backup_capacity
water_heater_volume: v, # water_heater_volume
water_heater_volume: v.to_f, # water_heater_volume
service_water_temperature: OpenStudio.convert(140.0, 'F', 'C').get, # service_water_temperature
parasitic_fuel_consumption_rate: 3.0, # parasitic_fuel_consumption_rate
swh_temp_sch: sched, # swh_temp_sch
Expand All @@ -548,7 +560,6 @@ def run(model, runner, user_arguments)
flowrate_schedule: nil, # flowrate_schedule
water_heater_thermal_zone: zone) # water_heater_thermal_zone
else
# zone = whtr.ambientTemperatureThermalZone.get
hpwh = std.model_add_water_heater(model, # model
(cap * 1000), # water_heater_capacity
v.to_f, # water_heater_volume
Expand Down
20 changes: 10 additions & 10 deletions lib/measures/add_hpwh/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.0</schema_version>
<name>add_hpwh</name>
<uid>518cde6f-1806-4b9a-bee9-ccaac49c7a53</uid>
<version_id>daec8b02-d60d-467c-bdea-201f81f56b8c</version_id>
<version_modified>20211110T211234Z</version_modified>
<version_id>67268596-50cb-4f0e-8fc2-9c6b5690ceb3</version_id>
<version_modified>20220505T192247Z</version_modified>
<xml_checksum>A374667A</xml_checksum>
<class_name>AddHpwh</class_name>
<display_name>Add HPWH for Domestic Hot Water</display_name>
Expand Down Expand Up @@ -363,12 +363,6 @@ The flexibility of the system is based on user-defined temperatures and times, w
<usage_type>test</usage_type>
<checksum>EB637B7E</checksum>
</file>
<file>
<filename>LICENSE.md</filename>
<filetype>md</filetype>
<usage_type>license</usage_type>
<checksum>E0468DD6</checksum>
</file>
<file>
<filename>Flexible Domestic Hot Water Implementation Guide.pdf</filename>
<filetype>pdf</filetype>
Expand All @@ -381,6 +375,12 @@ The flexibility of the system is based on user-defined temperatures and times, w
<usage_type>readme</usage_type>
<checksum>5E6E20CF</checksum>
</file>
<file>
<filename>LICENSE.md</filename>
<filetype>md</filetype>
<usage_type>license</usage_type>
<checksum>E0468DD6</checksum>
</file>
<file>
<version>
<software_program>OpenStudio</software_program>
Expand All @@ -390,13 +390,13 @@ The flexibility of the system is based on user-defined temperatures and times, w
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>B90CA863</checksum>
<checksum>B3DC865B</checksum>
</file>
<file>
<filename>add_hpwh_test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>35D3782E</checksum>
<checksum>DB9A9CE2</checksum>
</file>
</files>
</measure>
106 changes: 103 additions & 3 deletions lib/measures/add_hpwh/tests/add_hpwh_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ def test_good_argument_values
measure.run(model, runner, argument_map)
result = runner.result

# assert that it ran correctly
assert_equal('Success', result.value.valueName)

# show the output
show_output(result)

# assert that it ran correctly
assert_equal('Success', result.value.valueName)

# save the model to test output directory
output_file_path = "#{File.dirname(__FILE__)}//output/test_output.osm"
model.save(output_file_path, true)
Expand Down Expand Up @@ -134,4 +134,104 @@ def test_empty_model
assert_equal('Fail', result.value.valueName)
assert(result.errors.size == 1)
end

def test_custom_args_PumpedCondenser_specific_zone
# create an instance of the measure
measure = AddHpwh.new

# create runner with empty OSW
osw = OpenStudio::WorkflowJSON.new
runner = OpenStudio::Measure::OSRunner.new(osw)

# load the test model
translator = OpenStudio::OSVersion::VersionTranslator.new
path = "#{File.dirname(__FILE__)}/SmallHotel-2A.osm"
model = translator.loadModel(path)
assert(!model.empty?)
model = model.get

# get arguments
arguments = measure.arguments(model)
argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)

# create hash of argument values.
# If the argument has a default that you want to use, you don't need it in the hash
args_hash = {}
args_hash['zone'] = 'FrontOfficeFlr1 ZN'
args_hash['type'] = 'PumpedCondenser'
# using defaults values from measure.rb for other arguments

# populate argument with specified hash value if specified
arguments.each do |arg|
temp_arg_var = arg.clone
if args_hash.key?(arg.name)
assert(temp_arg_var.setValue(args_hash[arg.name]))
end
argument_map[arg.name] = temp_arg_var
end

# run the measure
measure.run(model, runner, argument_map)
result = runner.result

# show the output
show_output(result)

# assert that it ran correctly
assert_equal('Success', result.value.valueName)

# save the model to test output directory
output_file_path = "#{File.dirname(__FILE__)}//output/test_output.osm"
model.save(output_file_path, true)
end

def test_custom_args_WrappedCondenser_specific_zone
# create an instance of the measure
measure = AddHpwh.new

# create runner with empty OSW
osw = OpenStudio::WorkflowJSON.new
runner = OpenStudio::Measure::OSRunner.new(osw)

# load the test model
translator = OpenStudio::OSVersion::VersionTranslator.new
path = "#{File.dirname(__FILE__)}/SmallHotel-2A.osm"
model = translator.loadModel(path)
assert(!model.empty?)
model = model.get

# get arguments
arguments = measure.arguments(model)
argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)

# create hash of argument values.
# If the argument has a default that you want to use, you don't need it in the hash
args_hash = {}
args_hash['zone'] = 'FrontOfficeFlr1 ZN'
args_hash['type'] = 'WrappedCondenser'
# using defaults values from measure.rb for other arguments

# populate argument with specified hash value if specified
arguments.each do |arg|
temp_arg_var = arg.clone
if args_hash.key?(arg.name)
assert(temp_arg_var.setValue(args_hash[arg.name]))
end
argument_map[arg.name] = temp_arg_var
end

# run the measure
measure.run(model, runner, argument_map)
result = runner.result

# show the output
show_output(result)

# assert that it ran correctly
assert_equal('Success', result.value.valueName)

# save the model to test output directory
output_file_path = "#{File.dirname(__FILE__)}//output/test_output.osm"
model.save(output_file_path, true)
end
end
16 changes: 8 additions & 8 deletions lib/measures/add_packaged_ice_storage/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.0</schema_version>
<name>add_packaged_ice_storage</name>
<uid>2aa8c128-53b9-49fd-9aaf-9253a1f05936</uid>
<version_id>e2b362ea-1e2a-44b0-8f2b-add4d320b86d</version_id>
<version_modified>20211110T211235Z</version_modified>
<version_id>0169e58e-3682-493d-a4a3-60e58eca98d8</version_id>
<version_modified>20220505T192248Z</version_modified>
<xml_checksum>2617824F</xml_checksum>
<class_name>AddPackagedIceStorage</class_name>
<display_name>Add Packaged Ice Storage</display_name>
Expand Down Expand Up @@ -212,18 +212,18 @@ If 'AutoSize' is selected for ice capacity, these inputs set an ice capacity siz
<usage_type>test</usage_type>
<checksum>DC0DCC4B</checksum>
</file>
<file>
<filename>LICENSE.md</filename>
<filetype>md</filetype>
<usage_type>license</usage_type>
<checksum>E0468DD6</checksum>
</file>
<file>
<filename>README.md</filename>
<filetype>md</filetype>
<usage_type>readme</usage_type>
<checksum>E6FBC489</checksum>
</file>
<file>
<filename>LICENSE.md</filename>
<filetype>md</filetype>
<usage_type>license</usage_type>
<checksum>E0468DD6</checksum>
</file>
<file>
<filename>add_packaged_ice_storage_test.rb</filename>
<filetype>rb</filetype>
Expand Down
2 changes: 1 addition & 1 deletion lib/openstudio/load_flexibility_measures/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@

module OpenStudio
module LoadFlexibilityMeasures
VERSION = '0.4.0'.freeze
VERSION = '0.5.0'.freeze
end
end
2 changes: 1 addition & 1 deletion openstudio-load-flexibility-measures.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |spec|

spec.add_dependency 'bundler', '~> 2.1'
spec.add_dependency 'openstudio-extension', '~> 0.5.1'
spec.add_dependency 'openstudio-standards', '~> 0.2.15'
spec.add_dependency 'openstudio-standards', '~> 0.2.16'

spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '~> 3.9'
Expand Down

0 comments on commit da65b68

Please sign in to comment.