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