Skip to content
Merged
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
5 changes: 3 additions & 2 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- 'update_eplus_compare/**/*'
- 'weatherdata/**/*'
- 'model/refbuildingtests/measures/**/*'
- 'convert_ruby_to_python.rb'

jobs:
rubocop:
Expand All @@ -31,7 +32,7 @@ jobs:

- uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
ruby-version: '3.2.2'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use 3.2.2 in the action


- uses: actions/setup-python@v5
with:
Expand All @@ -43,6 +44,6 @@ jobs:
with:
autocorrect: true
commit-auto-correct: true
rubocop-version: 0.81.0
rubocop-version: 1.50.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

USe rubocop 1.50.0. So it's the same as the Current OpenStudio CLI

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 10 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Where a Cop is not listed, it uses the Rubocop defaults.

AllCops:
TargetRubyVersion: 2.5
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Configure TargetRubyVersion to 2.5 so we can still run backward in time down to OpenStudio 3.0.0 at least

NewCops: enable
Exclude:
- 'doc/**/*'
Expand All @@ -14,6 +15,7 @@ AllCops:
- 'update_eplus_compare/**/*'
- 'weatherdata/**/*'
- 'model/refbuildingtests/measures/**/*'
- 'convert_ruby_to_python.rb'

# inherit_from:
# - http://s3.amazonaws.com/openstudio-resources/styles/rubocop.yml
Expand Down Expand Up @@ -85,6 +87,9 @@ Metrics/BlockNesting:
#CountComments: false
#Severity: warning

Metrics/CollectionLiteralLength:
Enabled: false
Comment on lines +90 to +91
Copy link
Contributor Author

Choose a reason for hiding this comment

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

New config


Metrics/CyclomaticComplexity:
Max: 60
Severity: warning
Expand All @@ -96,7 +101,7 @@ Metrics/CyclomaticComplexity:
# Severity: warning

Metrics/MethodLength:
Max: 350
Max: 600
Comment on lines 103 to +104
Copy link
Contributor Author

Choose a reason for hiding this comment

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

tweak

CountComments: false
Severity: warning

Expand Down Expand Up @@ -124,6 +129,10 @@ Style/ClassAndModuleChildren:
Style/ClassVars:
Enabled: false

# Don't force an if to a case
Style/CaseLikeIf:
Enabled: false
Comment on lines +132 to +134
Copy link
Contributor Author

Choose a reason for hiding this comment

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

New config


# Allow this syntax -- do not autocorrect.
# a = if true
# 1
Expand Down
4 changes: 2 additions & 2 deletions highlevel_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_rbs_have_matching_osm_tests
'afn_single_zone_ac.rb']

content = File.read('model_tests.rb')
sim_test_commented_out_re = /TODO[ :\w]+(\d+\.\d+\.\d+).*?#\s*result = sim_test\('([\w\.]+)'\)/m
sim_test_commented_out_re = /TODO[ :\w]+(\d+\.\d+\.\d+).*?#\s*result = sim_test\('([\w.]+)'\)/m
# eg: [["3.1.0", "coil_cooling_dx.osm"], ["3.1.0", "swimmingpool_indoor.osm"]]
matches = content.scan(sim_test_commented_out_re)
files_with_todo = matches.map { |m| m[1] }
Expand Down Expand Up @@ -165,7 +165,7 @@ def test_ensure_pending_osms_are_added
end

content = File.read('model_tests.rb')
sim_test_commented_out_re = /TODO[ :\w]+(\d+\.\d+\.\d+).*?#\s*result = sim_test\('([\w\.]+)'\)/m
sim_test_commented_out_re = /TODO[ :\w]+(\d+\.\d+\.\d+).*?#\s*result = sim_test\('([\w.]+)'\)/m
# eg: [["3.1.0", "coil_cooling_dx.osm"], ["3.1.0", "swimmingpool_indoor.osm"]]
matches = content.scan(sim_test_commented_out_re)
matches.each do |v, t|
Expand Down
2 changes: 0 additions & 2 deletions model/simulationtests/afn_multiple_zones.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@
elsif surface.adjacentSurface.is_initialized
adjacent_surfaces << surface
end
end

space.surfaces.each do |surface|
surface.subSurfaces.each do |sub_surface|
sub_surfaces << sub_surface
end
Expand Down
12 changes: 6 additions & 6 deletions model/simulationtests/afn_single_zone_ac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def addSystemType3(model)
# this systems is a constant volume system with no VAV terminals, and needs different default settings

# get the sizing:system object associated with the airloophvac
sizingSystem = airLoopHVAC.sizingSystem()
sizingSystem = airLoopHVAC.sizingSystem

# set the default parameters correctly for a constant volume system with no VAV terminals
sizingSystem.setTypeofLoadtoSizeOn('Sensible')
Expand Down Expand Up @@ -84,7 +84,7 @@ def addSystemType3(model)

outdoorAirSystem = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, controllerOutdoorAir)

supplyOutletNode = airLoopHVAC.supplyOutletNode()
supplyOutletNode = airLoopHVAC.supplyOutletNode

outdoorAirSystem.addToNode(supplyOutletNode)
coilCooling.addToNode(supplyOutletNode)
Expand Down Expand Up @@ -120,7 +120,7 @@ def addSimpleSystem(model)
# this systems is a constant volume system with no VAV terminals, and needs different default settings

# get the sizing:system object associated with the airloophvac
sizingSystem = airLoopHVAC.sizingSystem()
sizingSystem = airLoopHVAC.sizingSystem

# set the default parameters correctly for a constant volume system with no VAV terminals
sizingSystem.setTypeofLoadtoSizeOn('Sensible')
Expand Down Expand Up @@ -156,7 +156,7 @@ def addSimpleSystem(model)

# outdoorAirSystem = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model,controllerOutdoorAir)

supplyOutletNode = airLoopHVAC.supplyOutletNode()
supplyOutletNode = airLoopHVAC.supplyOutletNode

# outdoorAirSystem.addToNode(supplyOutletNode)
fan.addToNode(supplyOutletNode)
Expand Down Expand Up @@ -191,7 +191,7 @@ def addSimpleSystemAFN(model)
# this systems is a constant volume system with no VAV terminals, and needs different default settings

# get the sizing:system object associated with the airloophvac
sizingSystem = airLoopHVAC.sizingSystem()
sizingSystem = airLoopHVAC.sizingSystem

# set the default parameters correctly for a constant volume system with no VAV terminals
sizingSystem.setTypeofLoadtoSizeOn('Sensible')
Expand Down Expand Up @@ -231,7 +231,7 @@ def addSimpleSystemAFN(model)

# outdoorAirSystem = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model,controllerOutdoorAir)

supplyOutletNode = airLoopHVAC.supplyOutletNode()
supplyOutletNode = airLoopHVAC.supplyOutletNode

# outdoorAirSystem.addToNode(supplyOutletNode)
fan.addToNode(supplyOutletNode)
Expand Down
2 changes: 1 addition & 1 deletion model/simulationtests/autosize_hvac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def make_tes_coil(model)

props = field.properties
olist = props.objectLists.first
setter = 'set' + field_name.gsub(' ', '')
setter = "set#{field_name.gsub(' ', '')}"
raise "Undefined method #{setter} for field_name=#{field_name} at index #{i}" unless tes_coil.respond_to?(setter)

tes_coil.send(setter, object_list_to_curve[olist])
Expand Down
4 changes: 2 additions & 2 deletions model/simulationtests/chiller_reformulated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# Chilled Water Plant
chilledWaterPlant = OpenStudio::Model::PlantLoop.new(model)
sizingPlant = chilledWaterPlant.sizingPlant()
sizingPlant = chilledWaterPlant.sizingPlant
sizingPlant.setLoopType('Cooling')
sizingPlant.setDesignLoopExitTemperature(7.22)
sizingPlant.setLoopDesignTemperatureDifference(6.67)
Expand Down Expand Up @@ -61,7 +61,7 @@

# Condenser System
condenserSystem = OpenStudio::Model::PlantLoop.new(model)
sizingPlant = condenserSystem.sizingPlant()
sizingPlant = condenserSystem.sizingPlant
sizingPlant.setLoopType('Condenser')
sizingPlant.setDesignLoopExitTemperature(29.4)
sizingPlant.setLoopDesignTemperatureDifference(5.6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def curve_quadratic(model, c_1constant, c_2x, c_3xPOW2, minx, maxx, miny = nil,
return curve
end

def curve_triquadratic(model, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, minx, maxx, miny, maxy, minz, maxz)
def curve_triquadratic(model, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, minx, maxx, miny, maxy, minz, maxz) # rubocop:disable Metrics/ParameterLists
curve = OpenStudio::Model::CurveTriquadratic.new(model)
curve.setCoefficient1Constant(c1)
curve.setCoefficient2xPOW2(c2)
Expand Down
2 changes: 1 addition & 1 deletion model/simulationtests/coil_userdefined.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
z = model.getThermalZones.min_by(&:nameString)
airLoop = model.getAirLoopHVACs.min_by(&:nameString)
# get supplyOutletNode
supplyOutletNode = airLoop.supplyOutletNode()
supplyOutletNode = airLoop.supplyOutletNode

# make CoilUserDefined
coil = OpenStudio::Model::CoilUserDefined.new(model)
Expand Down
2 changes: 1 addition & 1 deletion model/simulationtests/doas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
hw_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), hw_temp_c)
hw_stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, hw_temp_sch)
hw_stpt_manager.addToNode(hw_loop.supplyOutletNode)
sizingPlant = hw_loop.sizingPlant()
sizingPlant = hw_loop.sizingPlant
sizingPlant.setLoopType('Heating')
sizingPlant.setDesignLoopExitTemperature(82.0)
sizingPlant.setLoopDesignTemperatureDifference(11.0)
Expand Down
12 changes: 5 additions & 7 deletions model/simulationtests/epw_design_conditions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@

weather_files = Dir.glob('../../weatherdata/EPW/*.epw')
weather_files.each do |weather_file|
begin
epw_file = OpenStudio::EpwFile.new(weather_file)
epw_design_conditions = epw_file.designConditions
puts "#{File.basename(weather_file)}: success"
rescue StandardError
puts "#{File.basename(weather_file)}: FAILURE"
end
epw_file = OpenStudio::EpwFile.new(weather_file)
epw_design_conditions = epw_file.designConditions
puts "#{File.basename(weather_file)}: success"
rescue StandardError
puts "#{File.basename(weather_file)}: FAILURE"
end

else
Expand Down
2 changes: 1 addition & 1 deletion model/simulationtests/ghx_horizontal_trench_kusuda.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
condenserWaterPlant = OpenStudio::Model::PlantLoop.new(model)
condenserWaterPlant.setName('Condenser Water Plant')

sizingPlant = condenserWaterPlant.sizingPlant()
sizingPlant = condenserWaterPlant.sizingPlant
sizingPlant.setLoopType('Heating')
sizingPlant.setDesignLoopExitTemperature(30.0)
sizingPlant.setLoopDesignTemperatureDifference(11.0)
Expand Down
2 changes: 1 addition & 1 deletion model/simulationtests/ghx_horizontal_trench_xing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
condenserWaterPlant = OpenStudio::Model::PlantLoop.new(model)
condenserWaterPlant.setName('Condenser Water Plant')

sizingPlant = condenserWaterPlant.sizingPlant()
sizingPlant = condenserWaterPlant.sizingPlant
sizingPlant.setLoopType('Heating')
sizingPlant.setDesignLoopExitTemperature(30.0)
sizingPlant.setLoopDesignTemperatureDifference(11.0)
Expand Down
2 changes: 1 addition & 1 deletion model/simulationtests/ghx_vertical_kusuda.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
condenserWaterPlant = OpenStudio::Model::PlantLoop.new(model)
condenserWaterPlant.setName('Condenser Water Plant')

sizingPlant = condenserWaterPlant.sizingPlant()
sizingPlant = condenserWaterPlant.sizingPlant
sizingPlant.setLoopType('Heating')
sizingPlant.setDesignLoopExitTemperature(30.0)
sizingPlant.setLoopDesignTemperatureDifference(11.0)
Expand Down
2 changes: 1 addition & 1 deletion model/simulationtests/ghx_vertical_xing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
condenserWaterPlant = OpenStudio::Model::PlantLoop.new(model)
condenserWaterPlant.setName('Condenser Water Plant')

sizingPlant = condenserWaterPlant.sizingPlant()
sizingPlant = condenserWaterPlant.sizingPlant
sizingPlant.setLoopType('Heating')
sizingPlant.setDesignLoopExitTemperature(30.0)
sizingPlant.setLoopDesignTemperatureDifference(11.0)
Expand Down
2 changes: 1 addition & 1 deletion model/simulationtests/heatpump_hot_water.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

hot_water_heater = OpenStudio::Model::WaterHeaterHeatPumpWrappedCondenser.new(model)
hot_water_heater.addToThermalZone(zone)
tank = hot_water_heater.tank()
tank = hot_water_heater.tank
plant.addSupplyBranchForComponent(tank)

# hot_water_heater = OpenStudio::Model::WaterHeaterHeatPumpWrappedCondenser.new(model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
plhp_airsource_clg.electricInputtoOutputRatioModifierFunctionofTemperatureCurve.setName('EIRCurveFuncTemp2 Air Source')
plhp_airsource_clg.electricInputtoOutputRatioModifierFunctionofPartLoadRatioCurve.setName('EIRCurveFuncPLR2 Air Source')

# Note: Heat Recovery is ONLY available for 'AirSource' HeatPumpPlantLoopEIRs
# NOTE: Heat Recovery is ONLY available for 'AirSource' HeatPumpPlantLoopEIRs
tertiary = true
hw_loop.addSupplyBranchForComponent(plhp_airsource_htg)
# If not passing tertiary=true here, this would connect the Source Water Side
Expand Down
4 changes: 2 additions & 2 deletions model/simulationtests/interior_partitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
y = 1
interiorArea = 0
heights.each_index do |i|
new_x = x + lengths[i] * dir_x[i]
new_y = y + lengths[i] * dir_y[i]
new_x = x + (lengths[i] * dir_x[i])
new_y = y + (lengths[i] * dir_y[i])
points = OpenStudio::Point3dVector.new
points << OpenStudio::Point3d.new(x, y, 0)
points << OpenStudio::Point3d.new(new_x, new_y, 0)
Expand Down
4 changes: 2 additions & 2 deletions model/simulationtests/lib/baseline_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def add_geometry(params)
# Rename all surfaces with a unique name for easy diffing
space.surfaces.each do |s|
fromSpaceName = space.nameString
surfaceType = s.surfaceType()
surfaceType = s.surfaceType
boundaryCondition = s.outsideBoundaryCondition
if boundaryCondition.downcase == 'ground'
s.setName("#{fromSpaceName} Exterior Ground Floor")
Expand Down Expand Up @@ -994,7 +994,7 @@ def add_swh_loop(water_heater_type, ambient_temperature_thermal_zone = nil)
return service_water_loop
end

def add_water_heater(water_heater_type, water_heater_fuel, temp_sch_type_limits = nil, swh_temp_sch = nil, ambient_temperature_thermal_zone = nil, service_water_flowrate_schedule = nil)
def add_water_heater(water_heater_type, water_heater_fuel, temp_sch_type_limits = nil, swh_temp_sch = nil, ambient_temperature_thermal_zone = nil, service_water_flowrate_schedule = nil) # rubocop:disable Metrics/ParameterLists
# Water heater
# TODO Standards - Change water heater methodology to follow
# 'Model Enhancements Appendix A.'
Expand Down
4 changes: 2 additions & 2 deletions model/simulationtests/lowtemprad_constflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
hotWaterPlant = OpenStudio::Model::PlantLoop.new(model)
hotWaterPlant.setName('Hot Water Plant')

sizingPlant = hotWaterPlant.sizingPlant()
sizingPlant = hotWaterPlant.sizingPlant
sizingPlant.setLoopType('Heating')
sizingPlant.setDesignLoopExitTemperature(60.0)
sizingPlant.setLoopDesignTemperatureDifference(11.0)
Expand All @@ -42,7 +42,7 @@
chilledWaterPlant = OpenStudio::Model::PlantLoop.new(model)
chilledWaterPlant.setName('Chilled Water Plant')

sizingPlant = chilledWaterPlant.sizingPlant()
sizingPlant = chilledWaterPlant.sizingPlant
sizingPlant.setLoopType('Cooling')
sizingPlant.setDesignLoopExitTemperature(10.0)
sizingPlant.setLoopDesignTemperatureDifference(11.0)
Expand Down
4 changes: 2 additions & 2 deletions model/simulationtests/lowtemprad_varflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
hotWaterPlant = OpenStudio::Model::PlantLoop.new(model)
hotWaterPlant.setName('Hot Water Plant')

sizingPlant = hotWaterPlant.sizingPlant()
sizingPlant = hotWaterPlant.sizingPlant
sizingPlant.setLoopType('Heating')
sizingPlant.setDesignLoopExitTemperature(60.0)
sizingPlant.setLoopDesignTemperatureDifference(11.0)
Expand All @@ -42,7 +42,7 @@
chilledWaterPlant = OpenStudio::Model::PlantLoop.new(model)
chilledWaterPlant.setName('Chilled Water Plant')

sizingPlant = chilledWaterPlant.sizingPlant()
sizingPlant = chilledWaterPlant.sizingPlant
sizingPlant.setLoopType('Cooling')
sizingPlant.setDesignLoopExitTemperature(10.0)
sizingPlant.setLoopDesignTemperatureDifference(11.0)
Expand Down
6 changes: 3 additions & 3 deletions model/simulationtests/python_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

zone_names = model.getThermalZones.map(&:nameString).sort

zone_names_str_list = '["' + zone_names.join('", "') + '"]'
zone_names_str_list = "[\"#{zone_names.join('", "')}\"]"

# Add a PythonPlugin:Variable (all OS SDK PythonPluginVariable objects are
# translated to a single E+ PythonPlugin:Variables (extensible object))
Expand Down Expand Up @@ -69,7 +69,7 @@

pluginClassName = 'AverageZoneTemps'

python_plugin_file_content = ''"from pyenergyplus.plugin import EnergyPlusPlugin
python_plugin_file_content = "from pyenergyplus.plugin import EnergyPlusPlugin

class #{pluginClassName}(EnergyPlusPlugin):

Expand Down Expand Up @@ -107,7 +107,7 @@ def on_end_of_zone_timestep_before_zone_reporting(self, state) -> int:
past_daily_avg_temp = self.api.exchange.get_trend_average(state, self.data['trend'], #{n_timesteps})
self.api.exchange.set_global_value(state, self.data['running_avg_temp_variable'], past_daily_avg_temp)
return 0
"''
"

# Write it to a temporary directory so we don't pollute the current directory
# ExternalFile will copy it
Expand Down
6 changes: 3 additions & 3 deletions model/simulationtests/python_plugin_search_paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

zone_names = model.getThermalZones.map(&:nameString).sort

zone_names_str_list = '["' + zone_names.join('", "') + '"]'
zone_names_str_list = "[\"#{zone_names.join('", "')}\"]"

# Add a PythonPlugin:Variable (all OS SDK PythonPluginVariable objects are
# translated to a single E+ PythonPlugin:Variables (extensible object))
Expand Down Expand Up @@ -69,7 +69,7 @@

pluginClassName = 'AverageZoneTemps'

python_plugin_file_content = ''"from pyenergyplus.plugin import EnergyPlusPlugin
python_plugin_file_content = "from pyenergyplus.plugin import EnergyPlusPlugin
# NOTE: This external script must be locatable, so we'll add it to the PythonPluginSearchPaths
import python_plugin_search_paths_script

Expand Down Expand Up @@ -110,7 +110,7 @@ def on_end_of_zone_timestep_before_zone_reporting(self, state) -> int:
past_daily_avg_temp = self.api.exchange.get_trend_average(state, self.data['trend'], #{n_timesteps})
self.api.exchange.set_global_value(state, self.data['running_avg_temp_variable'], past_daily_avg_temp)
return 0
"''
"

# Write it to a temporary directory so we don't pollute the current directory
# ExternalFile will copy it
Expand Down
Loading
Loading