Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates for OS 3.9 #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# OpenStudio GEB Gem

## Version 0.5.0
- Support for OpenStudio 3.9 (upgrade to Ruby 3.2.2, standards gem 0.7.0, extension gem 0.8.2)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated for OS3.9


## Version 0.4.0
- Support for OpenStudio 3.7 (upgrade to standards gem 0.5.0, extension gem 0.7.0)

Expand Down
21 changes: 7 additions & 14 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +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.7.0'
end

gem 'openstudio_measure_tester', '= 0.3.1' # This includes the dependencies for running unit tests, coverage, and rubocop

# simplecov has an unnecessary dependency on native json gem, use fork that does not require this
gem 'simplecov', '~> 0.18.2'
# 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

# pin this dependency to avoid unicode_normalize error
gem 'addressable', '2.8.1'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a future version this dependency will be handled by openstudio-extension-gem

# pin this dependency to avoid using racc dependency (which has native extensions)
gem 'parser', '3.2.2.2'
4 changes: 2 additions & 2 deletions lib/measures/add_chilled_water_storage_tank/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,9 @@ def hardsize_cooling_tower_two_speed(tower)
# return false
# end
run_output_path = runner.getPathArgumentValue('run_output_path', user_arguments)
Dir.mkdir(run_output_path.to_s) unless File.exists?(run_output_path.to_s)
Dir.mkdir(run_output_path.to_s) unless File.exist?(run_output_path.to_s)
sizing_output_path = File.expand_path(File.join(run_output_path.to_s, 'sizing_run'))
Dir.mkdir(sizing_output_path.to_s) unless File.exists?(sizing_output_path.to_s)
Dir.mkdir(sizing_output_path.to_s) unless File.exist?(sizing_output_path.to_s)

# Change the simulation to only run the sizing days
sim_control = model.getSimulationControl
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
4 changes: 2 additions & 2 deletions lib/measures/enable_occupancy_driven_lighting/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def run_osw(osw_path)
end
runner.registerInfo("Pre-run output path: #{run_output_path}")

Dir.mkdir(run_output_path) unless File.exists?(run_output_path)
Dir.mkdir(run_output_path) unless File.exist?(run_output_path)
prerun_dir = File.join(run_output_path, 'pre-run')
Dir.mkdir(prerun_dir) unless File.exists?(prerun_dir)
Dir.mkdir(prerun_dir) unless File.exist?(prerun_dir)
prerun_osw_path = File.join(prerun_dir, 'sizing.osm')
model.save(prerun_osw_path, true) # true is overwrite

Expand Down
2 changes: 1 addition & 1 deletion lib/openstudio/geb/utilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def rm_old_folder_and_create_new(folder_path)
def postprocess_out_osw(outdir)

out_osw = File.join(outdir, 'out.osw')
raise "Cannot find file #{out_osw}" if !File.exists?(out_osw)
raise "Cannot find file #{out_osw}" if !File.exist?(out_osw)

result_osw = nil
File.open(out_osw, 'r') do |f|
Expand Down
2 changes: 1 addition & 1 deletion lib/openstudio/geb/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

module OpenStudio
module Geb
VERSION = '0.4.0'.freeze
VERSION = '0.5.0'.freeze
end
end
13 changes: 7 additions & 6 deletions openstudio-geb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_development_dependency 'bundler', '~> 2.1'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '3.7.0'
spec.add_development_dependency 'rubocop', '~> 1.15.0'
spec.required_ruby_version = '3.2.2'

spec.add_dependency 'openstudio-extension', '~> 0.8.2'
spec.add_dependency 'openstudio-standards', '0.7.0'
spec.add_dependency 'simplecov', '0.22.0'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooo, fancy new dependency versions!

spec.add_development_dependency 'rspec', '~> 3.9'

spec.add_dependency 'openstudio-extension', '~> 0.7.0'
spec.add_dependency 'openstudio-standards', '~> 0.5.0'
end
Loading