Skip to content

Commit

Permalink
Solve the changes of the OsLib_ functions used in the measures when u…
Browse files Browse the repository at this point in the history
…pgrading to OS 3.8
  • Loading branch information
wannizhang committed Aug 30, 2024
1 parent 65585b2 commit dd9b3e6
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 44 deletions.
14 changes: 7 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ gemspec
# Windows: set FAVOR_LOCAL_GEMS=1
# Note that if allow_local is true, but the gem is not found locally, then it will
# checkout the latest version (develop) from github.
allow_local = ENV['FAVOR_LOCAL_GEMS']

if allow_local && File.exists?('../OpenStudio-extension-gem')
gem 'openstudio-extension', path: '../OpenStudio-extension-gem'
else
gem 'openstudio-extension', github: 'NREL/OpenStudio-extension-gem', tag: 'v0.8.1'
end
# allow_local = ENV['FAVOR_LOCAL_GEMS']
#
# if allow_local && File.exists?('../OpenStudio-extension-gem')
# gem 'openstudio-extension', path: '../OpenStudio-extension-gem'
# else
# gem 'openstudio-extension', github: 'NREL/OpenStudio-extension-gem', tag: 'v0.8.1'
# end

# you shouldn't need this dependency directly...it is included in extension gem
# gem 'openstudio_measure_tester', '= 0.3.1' # This includes the dependencies for running unit tests, coverage, and rubocop
Expand Down
11 changes: 6 additions & 5 deletions lib/measures/add_exterior_blinds_and_control/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
# http://nrel.github.io/OpenStudio-user-documentation/reference/measure_writing_guide/

# start the measure
require 'openstudio/extension/core/os_lib_helper_methods'
require 'openstudio/extension/core/os_lib_schedules'
# require 'openstudio/extension/core/os_lib_helper_methods'
# require 'openstudio/extension/core/os_lib_schedules'
require 'openstudio-standards'
class AddExteriorBlindsAndControl < OpenStudio::Measure::ModelMeasure
include OsLib_HelperMethods
include OsLib_Schedules

# human readable name
def name
# Measure name should be the title case of the class name.
Expand Down Expand Up @@ -142,7 +142,8 @@ def run(model, runner, user_arguments)
'default_day' => ["default day"] + normal_day_data_pairs,
'rules' => [['Adjusted days', "#{start_month}/#{start_day}-#{end_month}/#{end_day}",
'Sun/Mon/Tue/Wed/Thu/Fri/Sat'] + adjusted_day_data_pairs] }
global_shading_schedule = OsLib_Schedules.createComplexSchedule(model, options)
# global_shading_schedule = OsLib_Schedules.createComplexSchedule(model, options)
global_shading_schedule = OpenstudioStandards::Schedules.create_complex_schedule(model, options)
runner.registerInfo("A new schedule 'Exterior blinds schedule' has been created for new shading control objects.")
end
unless space_shading_control
Expand Down
10 changes: 5 additions & 5 deletions lib/measures/add_interior_blinds_and_control/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
# http://nrel.github.io/OpenStudio-user-documentation/reference/measure_writing_guide/

# start the measure
require 'openstudio/extension/core/os_lib_helper_methods'
require 'openstudio/extension/core/os_lib_schedules'
# require 'openstudio/extension/core/os_lib_helper_methods'
# require 'openstudio/extension/core/os_lib_schedules'
require 'openstudio-standards'
class AddInteriorBlindsAndControl < OpenStudio::Measure::ModelMeasure
include OsLib_HelperMethods
include OsLib_Schedules
# human readable name
def name
# Measure name should be the title case of the class name.
Expand Down Expand Up @@ -144,7 +143,8 @@ def run(model, runner, user_arguments)
'default_day' => ["default day"] + normal_day_data_pairs,
'rules' => [['Adjusted days', "#{start_month}/#{start_day}-#{end_month}/#{end_day}",
'Sun/Mon/Tue/Wed/Thu/Fri/Sat'] + adjusted_day_data_pairs] }
global_shading_schedule = OsLib_Schedules.createComplexSchedule(model, options)
# global_shading_schedule = OsLib_Schedules.createComplexSchedule(model, options)
global_shading_schedule = OpenstudioStandards::Schedules.create_complex_schedule(model, options)
runner.registerInfo("A new schedule 'Interior blinds schedule' has been created for new shading control objects.")
end
unless space_shading_control
Expand Down
23 changes: 13 additions & 10 deletions lib/measures/add_rooftop_pv_simple/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
# http://nrel.github.io/OpenStudio-user-documentation/measures/measure_writing_guide/

# load OpenStudio measure libraries from openstudio-extension gem
require 'openstudio-extension'
require 'openstudio/extension/core/os_lib_helper_methods'
require 'openstudio/extension/core/os_lib_schedules'
# require 'openstudio-extension'
# require 'openstudio/extension/core/os_lib_helper_methods'
# require 'openstudio/extension/core/os_lib_schedules'
require 'openstudio-standards'

# start the measure
# this measure originally came from BCL (https://bcl.nrel.gov/results/?fq=bundle:measure&fq=measure_tags:Onsite%20Power%20Generation.Photovoltaic&show_rows=25)
Expand Down Expand Up @@ -69,8 +70,9 @@ def run(model, runner, user_arguments)
end

# assign the user inputs to variables
args = OsLib_HelperMethods.createRunVariables(runner, model, user_arguments, arguments(model))
if !args then return false end
# args = OsLib_HelperMethods.createRunVariables(runner, model, user_arguments, arguments(model))
args = runner. (arguments(model), user_arguments)
unless args then return false end

# check expected values of double arguments
# todo - not sure why this isn't working. Elsewhere it is used on E+ and reporting measures.
Expand All @@ -87,22 +89,23 @@ def run(model, runner, user_arguments)

# create the inverter
inverter = OpenStudio::Model::ElectricLoadCenterInverterSimple.new(model)
inverter.setInverterEfficiency(args['inverter_efficiency'])
inverter.setInverterEfficiency(args[:inverter_efficiency])
runner.registerInfo("Created inverter with efficiency of #{inverter.inverterEfficiency}")

# create the distribution system
elcd = OpenStudio::Model::ElectricLoadCenterDistribution.new(model)
elcd.setInverter(inverter)

# create shared shading transmittance schedule
target_transmittance = 1.0 - args['fraction_of_surface'].to_f
target_transmittance = 1.0 - args[:fraction_of_surface].to_f
inputs = {
'name' => 'PV Shading Transmittance Schedule',
'winterTimeValuePairs' => { 24.0 => target_transmittance },
'summerTimeValuePairs' => { 24.0 => target_transmittance },
'defaultTimeValuePairs' => { 24.0 => target_transmittance }
}
pv_shading_transmittance_schedule = OsLib_Schedules.createSimpleSchedule(model, inputs)
# pv_shading_transmittance_schedule = OsLib_Schedules.createSimpleSchedule(model, inputs)
pv_shading_transmittance_schedule = OpenstudioStandards::Schedules.create_simple_schedule(model, inputs)
runner.registerInfo("Created transmittance schedule for PV shading surfaces with constant value of #{target_transmittance}")

model.getSurfaces.each do |surface|
Expand All @@ -129,8 +132,8 @@ def run(model, runner, user_arguments)
panel = OpenStudio::Model::GeneratorPhotovoltaic.simple(model)
panel.setSurface(shading_surface)
performance = panel.photovoltaicPerformance.to_PhotovoltaicPerformanceSimple.get
performance.setFractionOfSurfaceAreaWithActiveSolarCells(args['fraction_of_surface'])
performance.setFixedEfficiency(args['cell_efficiency'])
performance.setFractionOfSurfaceAreaWithActiveSolarCells(args[:fraction_of_surface])
performance.setFixedEfficiency(args[:cell_efficiency])

# connect panel to electric load center distribution
elcd.addGenerator(panel)
Expand Down
10 changes: 5 additions & 5 deletions lib/measures/average_ventilation_for_peak_hours/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
# http://nrel.github.io/OpenStudio-user-documentation/reference/measure_writing_guide/

# start the measure
require 'openstudio/extension/core/os_lib_helper_methods'
require 'openstudio/extension/core/os_lib_schedules'
# require 'openstudio/extension/core/os_lib_helper_methods'
# require 'openstudio/extension/core/os_lib_schedules'
require 'openstudio-standards'
class AverageVentilationForPeakHours < OpenStudio::Measure::ModelMeasure
include OsLib_HelperMethods
include OsLib_Schedules
# human readable name
def name
return "Average Ventilation for Peak Hours"
Expand Down Expand Up @@ -188,7 +187,8 @@ def run(model, runner, user_arguments)
'default_day' => ["default day"] + normal_day_data_pairs,
'rules' => [['Adjusted days', "#{start_month1}/#{start_day1}-#{end_month1}/#{end_day1}",
'Sun/Mon/Tue/Wed/Thu/Fri/Sat'] + adjusted_day_data_pairs] }
new_oa_sch = OsLib_Schedules.createComplexSchedule(model, options)
# new_oa_sch = OsLib_Schedules.createComplexSchedule(model, options)
new_oa_sch = OpenstudioStandards::Schedules.create_complex_schedule(model, options)
outdoor_air_object.setOutdoorAirFlowRateFractionSchedule(new_oa_sch)
else
if schedules.key?(oa_sch.get.name.to_s)
Expand Down
24 changes: 12 additions & 12 deletions spec/tests/geb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,21 @@
# "ctrl_type" => 'MeetDaylightIlluminanceSetpoint'
# }
# },
"add_rooftop_pv_simple" => {
"measure_dir_name" => all_measures["add_rooftop_pv_simple"]["measure_dir_name"],
"arguments" => {
"fraction_of_surface" => 0.35
}
},
# "average_ventilation_for_peak_hours" => {
# "measure_dir_name" => all_measures["average_ventilation_for_peak_hours"]["measure_dir_name"],
# "add_rooftop_pv_simple" => {
# "measure_dir_name" => all_measures["add_rooftop_pv_simple"]["measure_dir_name"],
# "arguments" => {
# "start_time" => '13:00:00',
# "end_time" => '17:00:00',
# "start_date1" => '07-21',
# "end_date1" => '07-21'
# "fraction_of_surface" => 0.35
# }
# },
"average_ventilation_for_peak_hours" => {
"measure_dir_name" => all_measures["average_ventilation_for_peak_hours"]["measure_dir_name"],
"arguments" => {
"start_time" => '13:00:00',
"end_time" => '17:00:00',
"start_date1" => '07-21',
"end_date1" => '07-21'
}
},
# "add_exterior_blinds_and_control" => {
# "measure_dir_name" => all_measures["add_exterior_blinds_and_control"]["measure_dir_name"],
# "arguments" => {
Expand Down

0 comments on commit dd9b3e6

Please sign in to comment.