Skip to content

Commit

Permalink
rubocop formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
vtnate committed Jan 24, 2025
1 parent b3314d4 commit a5f48b8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 35 deletions.
9 changes: 4 additions & 5 deletions lib/urbanopt/reopt/feature_report_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def reopt_json_from_feature_report(feature_report, reopt_assumptions_hash = nil,
else
@@logger.info('Using default REopt assumptions')
reopt_inputs = {
Settings:{},
Settings: {},
Site: {},
Financial:{},
Financial: {},
ElectricTariff: {
monthly_demand_rates: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
monthly_energy_rates: [0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
Expand Down Expand Up @@ -158,7 +158,6 @@ def reopt_json_from_feature_report(feature_report, reopt_assumptions_hash = nil,
# [*return:*] _URBANopt::Reporting::DefaultReports::FeatureReport_ - Returns an updated FeatureReport.
##
def update_feature_report(feature_report, reopt_output, timeseries_csv_path = nil, resilience_stats = nil)

# Check if the \REopt response is valid
if reopt_output['status'] != 'optimal'
@@logger.error("ERROR cannot update Feature Report #{feature_report.name} #{feature_report.id} - REopt optimization was non-optimal")
Expand Down Expand Up @@ -439,15 +438,15 @@ def modrow(x, i) # :nodoc:
x[$storage_to_grid_col] = $storage_to_grid[i] || 0 if defined?(storage)
x[$storage_soc_col] = $storage_soc[i] || 0 if defined?(storage)
x[$generator_total_col] = $generator_total[i] || 0 if defined?(generator)
x[$generator_to_battery_col] = $generator_to_battery[i] || 0 if (defined?(generator) && defined?(storage))
x[$generator_to_battery_col] = $generator_to_battery[i] || 0 if defined?(generator) && defined?(storage)
x[$generator_to_load_col] = $generator_to_load[i] || 0 if defined?(generator)
x[$generator_to_grid_col] = $generator_to_grid[i] || 0 if defined?(generator)
x[$pv_total_col] = $pv_total[i] || 0
x[$pv_to_battery_col] = $pv_to_battery[i] || 0 if defined?(storage)
x[$pv_to_load_col] = $pv_to_load[i] || 0
x[$pv_to_grid_col] = $pv_to_grid[i] || 0
x[$wind_total_col] = $wind_total[i] || 0 if defined?(wind)
x[$wind_to_battery_col] = $wind_to_battery[i] || 0 if (defined?(wind) && defined?(storage))
x[$wind_to_battery_col] = $wind_to_battery[i] || 0 if defined?(wind) && defined?(storage)
x[$wind_to_load_col] = $wind_to_load[i] || 0 if defined?(wind)
x[$wind_to_grid_col] = $wind_to_grid[i] || 0 if defined?(wind)
return x
Expand Down
28 changes: 11 additions & 17 deletions lib/urbanopt/reopt/reopt_ghp_post_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
module URBANopt # :nodoc:
module REopt # :nodoc:
class REoptGHPPostProcessor

def initialize(run_dir, system_parameter, modelica_result, reopt_ghp_assumptions = nil, nrel_developer_key = nil, localhost)
# initialize @@logger
@@logger ||= URBANopt::REopt.reopt_logger
Expand Down Expand Up @@ -42,11 +41,11 @@ def initialize(run_dir, system_parameter, modelica_result, reopt_ghp_assumptions
File.open(system_parameter, 'r') do |file|
@system_parameter_input_hash = JSON.parse(file.read, symbolize_names: true)
end
#Determine loop order
# Determine loop order
loop_order = File.join(File.dirname(system_parameter), '_loop_order.json')
if File.exist?(loop_order)
File.open(loop_order, 'r') do |file|
loop_order_input= JSON.parse(file.read, symbolize_names: true)
loop_order_input = JSON.parse(file.read, symbolize_names: true)
# Check the type of the parsed data
if loop_order_input.is_a?(Array)
@loop_order_input_hash = loop_order_input
Expand All @@ -61,7 +60,7 @@ def initialize(run_dir, system_parameter, modelica_result, reopt_ghp_assumptions
puts "GHE IDs in group: #{item[:list_ghe_ids_in_group].inspect}"
end
else
puts "Unexpected JSON structure"
puts 'Unexpected JSON structure'
end
end
end
Expand All @@ -77,7 +76,6 @@ def initialize(run_dir, system_parameter, modelica_result, reopt_ghp_assumptions

# # Create REopt input and output building report
def run_reopt_lcca(system_parameter_hash: nil, reopt_ghp_assumptions_hash: nil, modelica_result: nil)

adapter = URBANopt::REopt::REoptGHPAdapter.new

# if these arguments are specified, use them
Expand All @@ -89,22 +87,21 @@ def run_reopt_lcca(system_parameter_hash: nil, reopt_ghp_assumptions_hash: nil,
@reopt_ghp_assumptions_input_hash = reopt_ghp_assumptions_hash
end


if !modelica_result.nil?
@modelica_result_input = modelica_result
end

# Create folder for REopt input files only if they dont exist
reopt_ghp_dir = File.join(@run_dir, "reopt_ghp")
reopt_ghp_input = File.join(reopt_ghp_dir, "reopt_ghp_inputs")
reopt_ghp_dir = File.join(@run_dir, 'reopt_ghp')
reopt_ghp_input = File.join(reopt_ghp_dir, 'reopt_ghp_inputs')
unless Dir.exist?(reopt_ghp_dir)
FileUtils.mkdir_p(reopt_ghp_dir)
end
unless Dir.exist?(reopt_ghp_input)
FileUtils.mkdir_p(reopt_ghp_input)
end

reopt_ghp_output = File.join(reopt_ghp_dir, "reopt_ghp_outputs")
reopt_ghp_output = File.join(reopt_ghp_dir, 'reopt_ghp_outputs')
unless Dir.exist?(reopt_ghp_output)
FileUtils.mkdir_p(reopt_ghp_output)
end
Expand Down Expand Up @@ -142,14 +139,11 @@ def run_reopt_lcca(system_parameter_hash: nil, reopt_ghp_assumptions_hash: nil,

# reopt_ghp_output_file
reopt_output_file = File.join(reopt_ghp_output, "#{base_name}_output.json")
#call the REopt API
# call the REopt API
api = URBANopt::REopt::REoptLiteGHPAPI.new(reopt_input_data, DEVELOPER_NREL_KEY, reopt_output_file, @localhost)
api.get_api_results()

api.get_api_results
end

end

end #REoptGHPPostProcessor
end #REopt
end #URBANopt
end # REoptGHPPostProcessor
end # REopt
end # URBANopt
5 changes: 2 additions & 3 deletions lib/urbanopt/reopt/reopt_schema/REopt-GHP-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"building_sqft": {
"type": "float",
"requierd": true,
"required": true,
"description": "to calculate cost of hydronic loop",
"note": "for the GHX iteration, set building_sqft to a number close to 0 but not exactly 0"
},
Expand All @@ -69,7 +69,7 @@
"number_of_boreholes": {
"type": "int",
"required": true,
"note": "in the GHP iteration, set this value to 0"
"note": "in the GHP iteration, set this value to 0"
},
"length_boreholes_ft": {
"type": "float",
Expand Down Expand Up @@ -146,4 +146,3 @@
}
}
}

16 changes: 6 additions & 10 deletions lib/urbanopt/reopt/scenario_report_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def reopt_json_from_scenario_report(scenario_report, reopt_assumptions_json = ni
else
@@logger.info('Using default REopt assumptions')
reopt_inputs = {
Settings:{},
Settings: {},
Site: {},
Financial:{},
Financial: {},
ElectricTariff: {
monthly_demand_rates: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
monthly_energy_rates: [0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
Expand Down Expand Up @@ -277,12 +277,8 @@ def update_scenario_report(scenario_report, reopt_output, timeseries_csv_path =
wind = reopt_output['outputs']['Wind']
# find size_class
size_class = nil
if reopt_output['inputs']['Wind']['size_class']
size_class = reopt_output['inputs']['Wind']['size_class']
else
size_class = 'commercial' # default
end
scenario_report.distributed_generation.add_tech 'wind', URBANopt::Reporting::DefaultReports::Wind.new({ size_kw: (wind['size_kw'] || 0), size_class: size_class, average_yearly_energy_produced_kwh: (wind['average_yearly_energy_produced_kwh'] || 0) })
size_class = reopt_output['inputs']['Wind']['size_class'] || 'commercial'
scenario_report.distributed_generation.add_tech 'wind', URBANopt::Reporting::DefaultReports::Wind.new({ size_kw: (wind['size_kw'] || 0), size_class:, average_yearly_energy_produced_kwh: (wind['average_yearly_energy_produced_kwh'] || 0) })
end

if reopt_output['outputs'].key?('Generator')
Expand Down Expand Up @@ -491,15 +487,15 @@ def modrow(data, idx) # :nodoc:
data[$storage_to_grid_col] = $storage_to_grid[idx] || 0 if defined?(storage)
data[$storage_soc_col] = $storage_soc[idx] || 0 if defined?(storage)
data[$generator_total_col] = $generator_total[idx] || 0 if defined?(generator)
data[$generator_to_battery_col] = $generator_to_battery[idx] || 0 if (defined?(generator) && defined?(storage))
data[$generator_to_battery_col] = $generator_to_battery[idx] || 0 if defined?(generator) && defined?(storage)
data[$generator_to_load_col] = $generator_to_load[idx] || 0 if defined?(generator)
data[$generator_to_grid_col] = $generator_to_grid[idx] || 0 if defined?(generator)
data[$pv_total_col] = $pv_total[idx] || 0
data[$pv_to_battery_col] = $pv_to_battery[idx] || 0 if defined?(storage)
data[$pv_to_load_col] = $pv_to_load[idx] || 0
data[$pv_to_grid_col] = $pv_to_grid[idx] || 0
data[$wind_total_col] = $wind_total[idx] || 0 if defined?(wind)
data[$wind_to_battery_col] = $wind_to_battery[idx] || 0 if (defined?(wind) && defined?(storage))
data[$wind_to_battery_col] = $wind_to_battery[idx] || 0 if defined?(wind) && defined?(storage)
data[$wind_to_load_col] = $wind_to_load[idx] || 0 if defined?(wind)
data[$wind_to_grid_col] = $wind_to_grid[idx] || 0 if defined?(wind)
return data
Expand Down

0 comments on commit a5f48b8

Please sign in to comment.