Skip to content

Commit cdb94da

Browse files
authored
Merge pull request #324 from NREL/os_v3
Update to OpenStudio v3.0.0
2 parents 4efddd1 + 951b3d9 commit cdb94da

107 files changed

Lines changed: 974 additions & 33300 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: nrel/openstudio:2.9.1
5+
- image: nrel/openstudio:3.0.0
66
steps:
77
- checkout
88
- run:

.rubocop.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
11
Layout/EndOfLine:
2-
Enabled: false
2+
Enabled: false
3+
Metrics/LineLength:
4+
AutoCorrect: false
5+
Enabled: false
6+
Layout/RescueEnsureAlignment:
7+
AutoCorrect: true
8+
Style/FrozenStringLiteralComment:
9+
AutoCorrect: true
10+
# Enable the cops below when rubocop is upgraded
11+
#Style/HashEachMethods:
12+
# Enabled: true
13+
#Style/HashTransformKeys:
14+
# Enabled: true
15+
#Style/HashTransformValues:
16+
# Enabled: true

Gemfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
# frozen_string_literal: true
2+
13
source 'http://rubygems.org'
24

3-
gem 'nokogiri', '~> 1.6', '<= 1.6.8.1'
5+
gem 'nokogiri', '~> 1.10'
6+
gem 'oga'
47
gem 'rake'
58
gem 'minitest', '~> 5.9'
69
gem 'ci_reporter_minitest', '~> 1.0.0'

Gemfile.lock

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ GEM
22
remote: http://rubygems.org/
33
specs:
44
ansi (1.5.0)
5+
ast (2.4.0)
56
builder (3.2.3)
67
ci_reporter (2.0.0)
78
builder (>= 2.1.2)
@@ -14,7 +15,7 @@ GEM
1415
url
1516
docile (1.3.2)
1617
json (2.2.0)
17-
mini_portile2 (2.1.0)
18+
mini_portile2 (2.4.0)
1819
minitest (5.11.3)
1920
minitest-ci (3.4.0)
2021
minitest (>= 5.0.6)
@@ -23,9 +24,17 @@ GEM
2324
builder
2425
minitest (>= 5.0)
2526
ruby-progressbar
26-
nokogiri (1.6.8.1-x64-mingw32)
27-
mini_portile2 (~> 2.1.0)
27+
nokogiri (1.10.9)
28+
mini_portile2 (~> 2.4.0)
29+
nokogiri (1.10.9-x64-mingw32)
30+
mini_portile2 (~> 2.4.0)
31+
oga (3.2)
32+
ast
33+
ruby-ll (~> 2.1)
2834
rake (13.0.1)
35+
ruby-ll (2.1.2)
36+
ansi
37+
ast
2938
ruby-progressbar (1.10.1)
3039
simplecov (0.17.0)
3140
docile (~> 1.1)
@@ -35,6 +44,7 @@ GEM
3544
url (0.3.2)
3645

3746
PLATFORMS
47+
ruby
3848
x64-mingw32
3949

4050
DEPENDENCIES
@@ -43,9 +53,10 @@ DEPENDENCIES
4353
minitest (~> 5.9)
4454
minitest-ci
4555
minitest-reporters
46-
nokogiri (~> 1.6, <= 1.6.8.1)
56+
nokogiri (~> 1.10)
57+
oga
4758
rake
4859
simplecov
4960

5061
BUNDLED WITH
51-
1.17.1
62+
2.1.4

HPXMLtoOpenStudio/measure.rb

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# see the URL below for information on how to write OpenStudio measures
24
# http://nrel.github.io/OpenStudio-user-documentation/reference/measure_writing_guide/
35

@@ -81,7 +83,7 @@ def run(model, runner, user_arguments)
8183
tear_down_model(model, runner)
8284

8385
# Check for correct versions of OS
84-
os_version = '2.9.1'
86+
os_version = '3.0.0'
8587
if OpenStudio.openStudioVersion != os_version
8688
fail "OpenStudio version #{os_version} is required."
8789
end
@@ -98,6 +100,7 @@ def run(model, runner, user_arguments)
98100
unless File.exist?(hpxml_path) && hpxml_path.downcase.end_with?('.xml')
99101
fail "'#{hpxml_path}' does not exist or is not an .xml file."
100102
end
103+
101104
unless (Pathname.new weather_dir).absolute?
102105
weather_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', weather_dir))
103106
end
@@ -147,7 +150,7 @@ def validate_hpxml(runner, hpxml_path, hpxml)
147150
is_valid = true
148151

149152
# Validate input HPXML against schema
150-
XMLHelper.validate(hpxml.doc.to_s, File.join(schemas_dir, 'HPXML.xsd'), runner).each do |error|
153+
XMLHelper.validate(hpxml.doc.to_xml, File.join(schemas_dir, 'HPXML.xsd'), runner).each do |error|
151154
runner.registerError("#{hpxml_path}: #{error}")
152155
is_valid = false
153156
end
@@ -420,17 +423,20 @@ def self.set_defaults_and_globals(runner)
420423
@hpxml.cooling_systems.each do |cooling_system|
421424
next unless cooling_system.cooling_system_type == HPXML::HVACTypeCentralAirConditioner
422425
next unless cooling_system.compressor_type.nil?
426+
423427
cooling_system.compressor_type = HVAC.get_default_compressor_type(cooling_system.cooling_efficiency_seer)
424428
end
425429
@hpxml.heat_pumps.each do |heat_pump|
426430
next unless heat_pump.heat_pump_type == HPXML::HVACTypeHeatPumpAirToAir
427431
next unless heat_pump.compressor_type.nil?
432+
428433
heat_pump.compressor_type = HVAC.get_default_compressor_type(heat_pump.cooling_efficiency_seer)
429434
end
430435

431436
# Default AC/HP sensible heat ratio
432437
@hpxml.cooling_systems.each do |cooling_system|
433438
next unless cooling_system.cooling_shr.nil?
439+
434440
if cooling_system.cooling_system_type == HPXML::HVACTypeCentralAirConditioner
435441
if cooling_system.compressor_type == HPXML::HVACCompressorTypeSingleStage
436442
cooling_system.cooling_shr = 0.73
@@ -445,6 +451,7 @@ def self.set_defaults_and_globals(runner)
445451
end
446452
@hpxml.heat_pumps.each do |heat_pump|
447453
next unless heat_pump.cooling_shr.nil?
454+
448455
if heat_pump.heat_pump_type == HPXML::HVACTypeHeatPumpAirToAir
449456
if heat_pump.compressor_type == HPXML::HVACCompressorTypeSingleStage
450457
heat_pump.cooling_shr = 0.73
@@ -730,7 +737,7 @@ def self.set_defaults_and_globals(runner)
730737
if @debug && (not @output_dir.nil?)
731738
# Write updated HPXML object to file
732739
hpxml_defaults_path = File.join(@output_dir, 'in.xml')
733-
XMLHelper.write_file(@hpxml.to_rexml, hpxml_defaults_path)
740+
XMLHelper.write_file(@hpxml.to_oga, hpxml_defaults_path)
734741
runner.registerInfo("Wrote file: #{hpxml_defaults_path}")
735742
end
736743
end
@@ -743,7 +750,7 @@ def self.add_simulation_params(model)
743750
tstep.setNumberOfTimestepsPerHour(60 / @hpxml.header.timestep)
744751

745752
shad = model.getShadowCalculation
746-
shad.setCalculationFrequency(20)
753+
shad.setShadingCalculationUpdateFrequency(20)
747754
shad.setMaximumFiguresInShadowOverlapCalculations(200)
748755

749756
outsurf = model.getOutsideSurfaceConvectionAlgorithm
@@ -1682,6 +1689,7 @@ def self.add_foundation_walls_slabs(runner, model, spaces)
16821689
found_foundation_wall = false
16831690
@hpxml.foundation_walls.each do |foundation_wall|
16841691
next if foundation_wall.net_area < 0.1 # skip modeling net surface area for surfaces comprised entirely of subsurface area
1692+
16851693
found_foundation_wall = true if slab.interior_adjacent_to == foundation_wall.interior_adjacent_to
16861694
end
16871695
next if found_foundation_wall
@@ -2392,7 +2400,7 @@ def self.add_hot_water_and_appliances(runner, model, weather, spaces)
23922400
capacity_kbtuh = water_heating_system.heating_capacity / 1000.0
23932401

23942402
Waterheater.apply_tank(model, space, fuel, capacity_kbtuh, tank_vol,
2395-
ef, re, setpoint_temp, ec_adj, @nbeds, @dhw_map,
2403+
ef, re, setpoint_temp, ec_adj, @dhw_map,
23962404
sys_id, desuperheater_clg_coil, jacket_r, solar_fraction)
23972405

23982406
elsif wh_type == HPXML::WaterHeaterTypeTankless
@@ -2408,7 +2416,7 @@ def self.add_hot_water_and_appliances(runner, model, weather, spaces)
24082416
tank_vol = water_heating_system.tank_volume
24092417

24102418
Waterheater.apply_heatpump(model, runner, space, weather, setpoint_temp, tank_vol, ef, ec_adj,
2411-
@nbeds, @dhw_map, sys_id, jacket_r, solar_fraction)
2419+
@dhw_map, sys_id, desuperheater_clg_coil, jacket_r, solar_fraction)
24122420

24132421
elsif (wh_type == HPXML::WaterHeaterTypeCombiStorage) || (wh_type == HPXML::WaterHeaterTypeCombiTankless)
24142422

@@ -2419,7 +2427,7 @@ def self.add_hot_water_and_appliances(runner, model, weather, spaces)
24192427
boiler_fuel_type = water_heating_system.related_hvac_system.heating_system_fuel
24202428
boiler, plant_loop = get_boiler_and_plant_loop(@hvac_map, water_heating_system.related_hvac_idref, sys_id)
24212429

2422-
Waterheater.apply_combi(model, runner, space, vol, setpoint_temp, ec_adj, @nbeds,
2430+
Waterheater.apply_combi(model, runner, space, vol, setpoint_temp, ec_adj,
24232431
boiler, plant_loop, boiler_fuel_type, boiler_afue, @dhw_map,
24242432
sys_id, wh_type, jacket_r, standby_loss, solar_fraction)
24252433

@@ -3443,6 +3451,10 @@ def self.add_component_loads_output(runner, model)
34433451
skylights: [],
34443452
internal_mass: [] }
34453453

3454+
# Output diagnostics needed for some output variables used below
3455+
output_diagnostics = model.getOutputDiagnostics
3456+
output_diagnostics.addKey('DisplayAdvancedReportVariables')
3457+
34463458
model.getSurfaces.sort.each_with_index do |s, idx|
34473459
next unless s.space.get.thermalZone.get.name.to_s == @living_zone.name.to_s
34483460

@@ -3460,17 +3472,20 @@ def self.add_component_loads_output(runner, model)
34603472
fail "Unexpected subsurface for component loads: '#{ss.name}'." if key.nil?
34613473

34623474
if (surface_type == 'Window') || (surface_type == 'Skylight')
3463-
vars = { 'Surface Window Net Heat Transfer Energy' => 'ss_net',
3464-
'Surface Inside Face Internal Gains Radiation Heat Gain Energy' => 'ss_ig',
3475+
vars = { 'Surface Window Transmitted Solar Radiation Energy' => 'ss_trans_in',
3476+
'Surface Window Shortwave from Zone Back Out Window Heat Transfer Rate' => 'ss_back_out',
34653477
'Surface Window Total Glazing Layers Absorbed Shortwave Radiation Rate' => 'ss_sw_abs',
34663478
'Surface Window Total Glazing Layers Absorbed Solar Radiation Energy' => 'ss_sol_abs',
3467-
'Surface Inside Face Initial Transmitted Diffuse Transmitted Out Window Solar Radiation Rate' => 'ss_sol_out' }
3479+
'Surface Inside Face Initial Transmitted Diffuse Transmitted Out Window Solar Radiation Rate' => 'ss_trans_out',
3480+
'Surface Inside Face Convection Heat Gain Energy' => 'ss_conv',
3481+
'Surface Inside Face Internal Gains Radiation Heat Gain Energy' => 'ss_ig',
3482+
'Surface Inside Face Net Surface Thermal Radiation Heat Gain Energy' => 'ss_surf' }
34683483
else
3469-
vars = { 'Surface Inside Face Convection Heat Gain Energy' => 'ss_conv',
3484+
vars = { 'Surface Inside Face Solar Radiation Heat Gain Energy' => 'ss_sol',
3485+
'Surface Inside Face Lights Radiation Heat Gain Energy' => 'ss_lgt',
3486+
'Surface Inside Face Convection Heat Gain Energy' => 'ss_conv',
34703487
'Surface Inside Face Internal Gains Radiation Heat Gain Energy' => 'ss_ig',
3471-
'Surface Inside Face Net Surface Thermal Radiation Heat Gain Energy' => 'ss_surf',
3472-
'Surface Inside Face Solar Radiation Heat Gain Energy' => 'ss_sol',
3473-
'Surface Inside Face Lights Radiation Heat Gain Energy' => 'ss_lgt' }
3488+
'Surface Inside Face Net Surface Thermal Radiation Heat Gain Energy' => 'ss_surf' }
34743489
end
34753490

34763491
surfaces_sensors[key] << []
@@ -3786,9 +3801,10 @@ def self.add_component_loads_output(runner, model)
37863801
surface_sensors.each do |sensors|
37873802
s = "Set hr_#{k} = hr_#{k}"
37883803
sensors.each do |sensor|
3789-
if sensor.name.to_s.start_with?('ss_net') || sensor.name.to_s.start_with?('ss_sol_abs')
3804+
# remove ss_net if switch
3805+
if sensor.name.to_s.start_with?('ss_net', 'ss_sol_abs', 'ss_trans_in')
37903806
s += " - #{sensor.name}"
3791-
elsif sensor.name.to_s.start_with?('ss_sw_abs') || sensor.name.to_s.start_with?('ss_sol_out')
3807+
elsif sensor.name.to_s.start_with?('ss_sw_abs', 'ss_trans_out', 'ss_back_out')
37923808
s += " + #{sensor.name} * ZoneTimestep * 3600"
37933809
else
37943810
s += " + #{sensor.name}"

0 commit comments

Comments
 (0)