Skip to content

Commit

Permalink
Merge pull request #50 from NREL/develop
Browse files Browse the repository at this point in the history
Release 0.3.0
  • Loading branch information
nllong authored Dec 4, 2020
2 parents 507dd6b + e34f48c commit f385358
Show file tree
Hide file tree
Showing 61 changed files with 37,015 additions and 33,064 deletions.
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
AllCops:
Exclude:
- 'spec/test_measures/**/*'

inherit_from:
- http://s3.amazonaws.com/openstudio-resources/styles/rubocop_v3.yml
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# OpenStudio Model Articulation Gems

## Version 0.3.0

* Support for OpenStudio 3.1
* Update OpenStudio Standards to 0.2.12
* Update OpenStudio Extension gem to 0.3.1
* Move errs array creation in radiant_slab_with_doas measure
* Fix radiant measure to work with Ruby 2.2 (remove Safe Navigation operator)

## Version 0.2.1

* Support for OpenStudio 3.1
* Update OpenStudio Standards to 0.2.12
* Update OpenStudio Extension gem to 0.3.1

## Version 0.2.0

* Support for OpenStudio 3.0
Expand Down
19 changes: 18 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,26 @@ RSpec::Core::RakeTask.new(:spec)
require 'openstudio/extension/rake_task'
require 'openstudio/model_articulation'
rake_task = OpenStudio::Extension::RakeTask.new
rake_task.set_extension_class(OpenStudio::ModelArticulation::Extension)
rake_task.set_extension_class(OpenStudio::ModelArticulation::Extension, 'nrel/openstudio-model-articulation-gem')

require 'openstudio_measure_tester/rake_task'
OpenStudioMeasureTester::RakeTask.new

task default: :spec

desc 'Delete measure test output'
task :delete_measure_test_outputs do
require 'fileutils'

puts 'Deleting tests/output directory from measures.'

# get measures in repo
measures = Dir.glob('**/**/**/measure.rb')

#create unique list of parent directories for measures.
measures.each do |i|
FileUtils.rm_rf(i.gsub("measure.rb","tests/output"))
end
puts "deleteting test outputs"

end
5 changes: 0 additions & 5 deletions lib/measures/.rubocop.yml

This file was deleted.

6 changes: 0 additions & 6 deletions lib/measures/BarAspectRatioSlicedBySpaceType/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@
<usage_type>test</usage_type>
<checksum>3FDFD18A</checksum>
</file>
<file>
<filename>test.osm</filename>
<filetype>osm</filetype>
<usage_type>test</usage_type>
<checksum>60715087</checksum>
</file>
<file>
<filename>README.md</filename>
<filetype>md</filetype>
Expand Down
32,892 changes: 0 additions & 32,892 deletions lib/measures/BarAspectRatioSlicedBySpaceType/tests/test.osm

This file was deleted.

18 changes: 9 additions & 9 deletions lib/measures/InjectOsmGeometryIntoAnExternalIdf/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>inject_osm_geometry_into_an_external_idf</name>
<uid>633cd1c5-5b55-4b50-ab20-cf2d2f7ddff8</uid>
<version_id>3f37233f-eeaf-47d0-8a13-27c86aaf7b0b</version_id>
<version_modified>20200509T155937Z</version_modified>
<version_id>280b80cc-c941-463b-bfd1-dbc3bd969f25</version_id>
<version_modified>20200624T003817Z</version_modified>
<xml_checksum>3BE1CF9C</xml_checksum>
<class_name>InjectOsmGeometryIntoAnExternalIdf</class_name>
<display_name>InjectOsmGeometryIntoAnExternalIdf</display_name>
Expand Down Expand Up @@ -136,7 +136,7 @@ Constructions and other resources won?t be moved back and forth but the surface
<checksum>56ED3E65</checksum>
</file>
<file>
<filename>test.osw</filename>
<filename>measure_test.osw</filename>
<filetype>osw</filetype>
<usage_type>test</usage_type>
<checksum>F5FABCCF</checksum>
Expand All @@ -159,12 +159,6 @@ Constructions and other resources won?t be moved back and forth but the surface
<usage_type>readme</usage_type>
<checksum>6FF2AF68</checksum>
</file>
<file>
<filename>InjectOsmGeometryIntoAnExternalIdf_Test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>91289177</checksum>
</file>
<file>
<version>
<software_program>OpenStudio</software_program>
Expand All @@ -176,5 +170,11 @@ Constructions and other resources won?t be moved back and forth but the surface
<usage_type>script</usage_type>
<checksum>A76C44E1</checksum>
</file>
<file>
<filename>InjectOsmGeometryIntoAnExternalIdf_Test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>A4070AAC</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_InjectOsmGeometryIntoAnExternalIdf_b
measure = InjectOsmGeometryIntoAnExternalIdf.new

# create an instance of a runner with OSW
osw_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/test.osw')
osw_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/measure_test.osw')
osw = OpenStudio::WorkflowJSON.load(osw_path).get
runner = OpenStudio::Measure::OSRunner.new(osw)

Expand Down Expand Up @@ -101,7 +101,7 @@ def test_InjectOsmGeometryIntoAnExternalIdf_c_NoNewGeometry
measure = InjectOsmGeometryIntoAnExternalIdf.new

# create an instance of a runner with OSW
osw_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/test.osw')
osw_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/measure_test.osw')
osw = OpenStudio::WorkflowJSON.load(osw_path).get
runner = OpenStudio::Measure::OSRunner.new(osw)

Expand Down Expand Up @@ -145,7 +145,7 @@ def test_InjectOsmGeometryIntoAnExternalIdf_d_Simple
measure = InjectOsmGeometryIntoAnExternalIdf.new

# create an instance of a runner with OSW
osw_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/test.osw')
osw_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/measure_test.osw')
osw = OpenStudio::WorkflowJSON.load(osw_path).get
runner = OpenStudio::Measure::OSRunner.new(osw)

Expand Down Expand Up @@ -185,7 +185,7 @@ def test_InjectOsmGeometryIntoAnExternalIdf_e_LinksToSurfaces
measure = InjectOsmGeometryIntoAnExternalIdf.new

# create an instance of a runner with OSW
osw_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/test.osw')
osw_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/measure_test.osw')
osw = OpenStudio::WorkflowJSON.load(osw_path).get
runner = OpenStudio::Measure::OSRunner.new(osw)

Expand Down
50 changes: 19 additions & 31 deletions lib/measures/SetWindowToWallRatioByFacade/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def run(model, runner, user_arguments)

# calculate initial envelope cost as negative value
envelope_cost = 0
constructions = model.getConstructions
constructions = model.getConstructions.sort
constructions.each do |construction|
const_llcs = construction.lifeCycleCosts
const_llcs.each do |const_llc|
Expand All @@ -190,22 +190,22 @@ def run(model, runner, user_arguments)
if exl_spaces_not_incl_fl_area
# loop through spaces to gather surfaces.
surfaces = []
model.getSpaces.each do |space|
model.getSpaces.sort.each do |space|
next if !space.partofTotalFloorArea
space.surfaces.each do |surface|
space.surfaces.sort.each do |surface|
surfaces << surface
end
end
else
surfaces = model.getSurfaces
surfaces = model.getSurfaces.sort
end

# used for new sub surfaces to find target construction
orig_sub_surf_const_for_target_facade = {}
orig_sub_surf_const_for_target_all_ext = {}

# pre-loop through sub-surfaces to store constructions
model.getSubSurfaces.each do |sub_surf|
model.getSubSurfaces.sort.each do |sub_surf|
# store constructions for entire building
next if sub_surf.subSurfaceType == 'Door' || sub_surf.subSurfaceType == 'OverheadDoor'
if sub_surf.construction.is_initialized
Expand Down Expand Up @@ -248,7 +248,7 @@ def run(model, runner, user_arguments)
# hash for sub surfaces removed from non rectangular surfaces
non_rect_parent = {}

surfaces.each do |s|
surfaces.sort.each do |s|
next if s.surfaceType != 'Wall'
next if s.outsideBoundaryCondition != 'Outdoors'
if s.space.empty?
Expand Down Expand Up @@ -296,7 +296,7 @@ def run(model, runner, user_arguments)
# loop through sub surfaces and add area including multiplier
ext_window_area = 0
has_doors = false
s.subSurfaces.each do |subSurface|
s.subSurfaces.sort.each do |subSurface|
# stop if non window or glass door
if subSurface.subSurfaceType == 'Door' || subSurface.subSurfaceType == 'OverheadDoor'
if split_at_doors == 'Remove Doors'
Expand All @@ -321,15 +321,15 @@ def run(model, runner, user_arguments)
split_surfaces = s.splitSurfaceForSubSurfaces.to_a # frozen array

# add original surface to new surfaces
split_surfaces.each do |ss|
split_surfaces.sort.each do |ss|
all_surfaces << ss
end
end

if wwr > 0 && triangulate

all_surfaces2 = []
all_surfaces.each do |ss|
all_surfaces.sort.each do |ss|
# see if surface is rectangular (only checking non rotated on vertical wall)
# todo - add in more robust rectangle check that can look for rotate and tilted rectangles
rect_tri = false
Expand All @@ -350,7 +350,7 @@ def run(model, runner, user_arguments)
end

has_doors = false
ss.subSurfaces.each do |subSurface|
ss.subSurfaces.sort.each do |subSurface|
if subSurface.subSurfaceType == 'Door' || subSurface.subSurfaceType == 'OverheadDoor'
has_doors = true
end
Expand All @@ -366,7 +366,7 @@ def run(model, runner, user_arguments)

# get construction from sub-surfaces and then delete them
pre_tri_sub_const = {}
ss.subSurfaces.each do |subSurface|
ss.subSurfaces.sort.each do |subSurface|
if subSurface.construction.is_initialized && !subSurface.isConstructionDefaulted
if pre_tri_sub_const.key?(subSurface.construction.get)
pre_tri_sub_const[subSurface.construction.get] = subSurface.grossArea
Expand Down Expand Up @@ -398,9 +398,9 @@ def run(model, runner, user_arguments)
end

# add windows
all_surfaces2.each do |ss|
all_surfaces2.sort.each do |ss|
orig_sub_surf_constructions = {}
ss.subSurfaces.each do |sub_surf|
ss.subSurfaces.sort.each do |sub_surf|
next if sub_surf.subSurfaceType == 'Door' || sub_surf.subSurfaceType == 'OverheadDoor'
if sub_surf.construction.is_initialized
if orig_sub_surf_constructions.key?(sub_surf.construction.get)
Expand All @@ -414,7 +414,7 @@ def run(model, runner, user_arguments)
# remove windows if ratio 0 or add in other cases
if wwr == 0
# remove all sub surfaces
ss.subSurfaces.each(&:remove)
ss.subSurfaces.sort.each(&:remove)
new_window = []
window_confirmed = true
else
Expand Down Expand Up @@ -522,7 +522,7 @@ def run(model, runner, user_arguments)
end

# data for final condition wwr
surfaces.each do |s|
surfaces.sort.each do |s|
next if s.surfaceType != 'Wall'
next if s.outsideBoundaryCondition != 'Outdoors'
if s.space.empty?
Expand Down Expand Up @@ -565,35 +565,23 @@ def run(model, runner, user_arguments)

# loop through sub surfaces and add area including multiplier
ext_window_area = 0
s.subSurfaces.each do |subSurface| # onlky one and should have multiplier of 1
s.subSurfaces.sort.each do |subSurface| # onlky one and should have multiplier of 1
ext_window_area += subSurface.grossArea * subSurface.multiplier * zone_multiplier
end

final_gross_ext_wall_area += surface_gross_area
final_ext_window_area += ext_window_area
end

# short def to make numbers pretty (converts 4125001.25641 to 4,125,001.26 or 4,125,001). The definition be called through this measure
def neat_numbers(number, roundto = 2) # round to 0 or 2)
# round to zero or two decimals
if roundto == 2
number = format '%.2f', number
else
number = number.round
end
# regex to add commas
number.to_s.reverse.gsub(/([0-9]{3}(?=([0-9])))/, '\\1,').reverse
end

# get delta in ft^2 for final - starting window area
increase_window_area_si = OpenStudio::Quantity.new(final_ext_window_area - starting_ext_window_area, unit_area_si)
increase_window_area_ip = OpenStudio.convert(increase_window_area_si, unit_area_ip).get

# calculate final envelope cost as positive value
constructions = model.getConstructions
constructions = model.getConstructions.sort
constructions.each do |construction|
const_llcs = construction.lifeCycleCosts
const_llcs.each do |const_llc|
const_llcs.sort.each do |const_llc|
if const_llc.category == 'Construction'
envelope_cost += const_llc.totalCost
end
Expand All @@ -602,7 +590,7 @@ def neat_numbers(number, roundto = 2) # round to 0 or 2)

# report final condition
final_wwr = format('%.02f', (final_ext_window_area / final_gross_ext_wall_area))
runner.registerFinalCondition("The model's final window to wall ratio for #{facade} facing exterior walls is #{final_wwr}. Window area increased by #{neat_numbers(increase_window_area_ip.value, 0)} (ft^2). The material and construction costs increased by $#{neat_numbers(envelope_cost, 0)}.")
runner.registerFinalCondition("The model's final window to wall ratio for #{facade} facing exterior walls is #{final_wwr}. Window area increased by #{OpenStudio.toNeatString(increase_window_area_ip.value, 0)} (ft^2). The material and construction costs increased by $#{OpenStudio.toNeatString(envelope_cost, 0)}.")

return true
end
Expand Down
8 changes: 4 additions & 4 deletions lib/measures/SetWindowToWallRatioByFacade/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>set_window_to_wall_ratio_by_facade</name>
<uid>c567a0bf-a7d9-4a06-afe9-bf7df79e6bf8</uid>
<version_id>69309ebe-fd01-407e-9332-ff5e0848a670</version_id>
<version_modified>20200421T224712Z</version_modified>
<version_id>ba8a1d2e-0d49-4e86-9aba-f4d55097f358</version_id>
<version_modified>20200928T200703Z</version_modified>
<xml_checksum>6DE831F7</xml_checksum>
<class_name>SetWindowToWallRatioByFacade</class_name>
<display_name>Set Window to Wall Ratio by Facade</display_name>
Expand Down Expand Up @@ -233,13 +233,13 @@ The measure doesn?t have any cost or lifecycle arguments, however If lifecycle o
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>FCC2E4DD</checksum>
<checksum>CB9895D2</checksum>
</file>
<file>
<filename>SetWindowToWallRatioByFacade_Test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>580F468D</checksum>
<checksum>268FC2B7</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,9 @@ def test_SetWindowToWallRatioByFacade_with_model_RotationTest
# assert(result.warnings.size == 2)
# assert(result.info.size == 2)

# save the model in an output directory
output_dir = File.expand_path('output', File.dirname(__FILE__))
FileUtils.mkdir output_dir unless Dir.exist? output_dir
model.save("#{output_dir}/rotation_test.osm", true)
# save the model
output_file_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/output/rotation.osm')
model.save(output_file_path, true)
end

def test_SetWindowToWallRatioByFacade_with_model_MinimalCost
Expand Down Expand Up @@ -690,10 +689,9 @@ def test_SetWindowToWallRatioByFacade_zero_target
# assert(result.warnings.size == 2)
# assert(result.info.size == 2)

# save the model in an output directory
output_dir = File.expand_path('output', File.dirname(__FILE__))
FileUtils.mkdir output_dir unless Dir.exist? output_dir
model.save("#{output_dir}/zero_test.osm", true)
# save the model
output_file_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/output/zero.osm')
model.save(output_file_path, true)
end

def test_SetWindowToWallRatioByFacade_all_orientations
Expand Down Expand Up @@ -735,9 +733,8 @@ def test_SetWindowToWallRatioByFacade_all_orientations
# assert(result.warnings.size == 2)
# assert(result.info.size == 2)

# save the model in an output directory
output_dir = File.expand_path('output', File.dirname(__FILE__))
FileUtils.mkdir output_dir unless Dir.exist? output_dir
model.save("#{output_dir}/zero_test.osm", true)
# save the model
output_file_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/output/all_orientations.osm')
model.save(output_file_path, true)
end
end
Loading

0 comments on commit f385358

Please sign in to comment.