Skip to content

Commit 13610ec

Browse files
committed
update code so that the erp runs w the uo cost changes
1 parent 9a55076 commit 13610ec

1 file changed

Lines changed: 47 additions & 46 deletions

File tree

lib/uo_cli.rb

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,8 @@ def self.install_python_dependencies
17681768
rescue StandardError => e
17691769
puts "\nERROR: #{e.message}"
17701770
end
1771+
# retrieve assumptions hash for modifications
1772+
assumptions_hash = JSON.parse(File.read(File.expand_path(scenario_assumptions)), symbolize_names: true)
17711773

17721774
# Configure Capital Costs Processing (retrieve from scenario CSV if they exist)
17731775
scenario_file = CSV.read(File.expand_path(@opthash.subopts[:scenario]), headers: true, header_converters: :symbol)
@@ -1777,9 +1779,7 @@ def self.install_python_dependencies
17771779
# assume cost analysis if either column is present
17781780
puts "\nINFO: Capital cost data found in ScenarioFile. Preparing wind capital costs for REopt Analysis...\n"
17791781

1780-
# retrieve assumptions hash for modifications
1781-
assumptions_hash = JSON.parse(File.read(File.expand_path(scenario_assumptions)), symbolize_names: true)
1782-
# check if both columns are present or just one
1782+
# check if both columns are present or just one
17831783
has_total_costs = scenario_file.headers.include?(:total_capital_costs)
17841784
has_cost_per_sqft = scenario_file.headers.include?(:capital_cost_per_floor_area_sqft)
17851785

@@ -1832,57 +1832,58 @@ def self.install_python_dependencies
18321832
assumptions_hash[:Wind][:macrs_bonus_fraction] = 0
18331833
assumptions_hash[:Wind][:federal_itc_fraction] = 0
18341834
assumptions_hash[:Wind][:production_factor_series] = Array.new(8760, 0)
1835-
end
1836-
1837-
if assumptions_hash.nil?
1838-
puts "[WARN] Assumptions hash is nil."
1839-
else
1840-
# Look for boiler assumptions (symbol or string keys)
1841-
boiler_assumptions =
1842-
assumptions_hash[:ExistingBoiler] ||
1843-
assumptions_hash['ExistingBoiler']
18441835

1845-
if boiler_assumptions.nil?
1846-
puts "[WARN] ExistingBoiler assumptions not found. Available keys: #{assumptions_hash.keys.inspect}"
1836+
if assumptions_hash.nil?
1837+
puts "[WARN] Assumptions hash is nil."
18471838
else
1848-
# Try to read fuel cost
1849-
fuel_cost =
1850-
boiler_assumptions[:fuel_cost_per_mmbtu] ||
1851-
boiler_assumptions['fuel_cost_per_mmbtu']
1852-
1853-
if fuel_cost.nil?
1854-
puts "WARNING: There is no 'ExistingBoiler.fuel_cost_per_mmbtu' value in the assumptions file."
1855-
elsif fuel_cost == 11.5
1856-
puts "WARNING: The 'fuel_cost_per_mmbtu' under 'ExistingBoiler' is still set to the default value of $11.5/MMBtu. Please update this value with a site-specific fuel cost."
1857-
else
1858-
puts "INFO: Using ExistingBoiler fuel cost of #{fuel_cost} $/MMBtu."
1859-
end
1839+
# Look for boiler assumptions (symbol or string keys)
1840+
boiler_assumptions =
1841+
assumptions_hash[:ExistingBoiler] ||
1842+
assumptions_hash['ExistingBoiler']
1843+
1844+
if boiler_assumptions.nil?
1845+
puts "[WARN] ExistingBoiler assumptions not found. Available keys: #{assumptions_hash.keys.inspect}"
1846+
else
1847+
# Try to read fuel cost
1848+
fuel_cost =
1849+
boiler_assumptions[:fuel_cost_per_mmbtu] ||
1850+
boiler_assumptions['fuel_cost_per_mmbtu']
1851+
1852+
if fuel_cost.nil?
1853+
puts "WARNING: There is no 'ExistingBoiler.fuel_cost_per_mmbtu' value in the assumptions file."
1854+
elsif fuel_cost == 11.5
1855+
puts "WARNING: The 'fuel_cost_per_mmbtu' under 'ExistingBoiler' is still set to the default value of $11.5/MMBtu. Please update this value with a site-specific fuel cost."
1856+
else
1857+
puts "INFO: Using ExistingBoiler fuel cost of #{fuel_cost} $/MMBtu."
1858+
end
18601859

1860+
end
18611861
end
1862-
end
18631862

1864-
# Add timeseries data for fuel consumption to assumptions file, if present
1865-
# read scenario csv report
1866-
if assumptions_hash.nil?
1867-
puts "[WARN] Assumptions hash is nil."
1868-
else
1869-
# Look for boiler assumptions (symbol or string keys)
1870-
assumptions_hash[:SpaceHeatingLoad] ||= {}
1871-
assumptions_hash[:SpaceHeatingLoad][:fuel_loads_mmbtu_per_hour] ||= []
1872-
scenario_csv = CSV.read(File.join(@root_dir, 'run', @scenario_name.downcase, 'default_scenario_report.csv'), headers: true)
1873-
1874-
column_name = 'NaturalGas:Facility(kBtu)'
1875-
1876-
# Read every row
1877-
if scenario_csv.headers.include?(column_name)
1878-
puts "\nINFO: Found '#{column_name}' column in default_scenario_report.csv. Adding space heating fuel load timeseries to REopt assumptions.\n"
1879-
scenario_csv.each do |row|
1880-
kbtu_value = row[column_name].to_f
1881-
mmbtu_value = kbtu_value / 1000.0
1882-
assumptions_hash[:SpaceHeatingLoad][:fuel_loads_mmbtu_per_hour] << mmbtu_value
1863+
# Add timeseries data for fuel consumption to assumptions file, if present
1864+
# read scenario csv report
1865+
if assumptions_hash.nil?
1866+
puts "[WARN] Assumptions hash is nil."
1867+
else
1868+
# Look for boiler assumptions (symbol or string keys)
1869+
assumptions_hash[:SpaceHeatingLoad] ||= {}
1870+
assumptions_hash[:SpaceHeatingLoad][:fuel_loads_mmbtu_per_hour] ||= []
1871+
scenario_csv = CSV.read(File.join(@root_dir, 'run', @scenario_name.downcase, 'default_scenario_report.csv'), headers: true)
1872+
1873+
column_name = 'NaturalGas:Facility(kBtu)'
1874+
1875+
# Read every row
1876+
if scenario_csv.headers.include?(column_name)
1877+
puts "\nINFO: Found '#{column_name}' column in default_scenario_report.csv. Adding space heating fuel load timeseries to REopt assumptions.\n"
1878+
scenario_csv.each do |row|
1879+
kbtu_value = row[column_name].to_f
1880+
mmbtu_value = kbtu_value / 1000.0
1881+
assumptions_hash[:SpaceHeatingLoad][:fuel_loads_mmbtu_per_hour] << mmbtu_value
1882+
end
18831883
end
18841884
end
18851885
end
1886+
18861887
# Write assumptions hash to file since REoptPostProcessor reads from file
18871888
updated_assumptions_file = File.join(@root_dir, 'run', @scenario_name.downcase, 'updated_reopt_scenario_assumptions.json')
18881889
File.open(updated_assumptions_file, 'w') { |f| f.write JSON.pretty_generate(assumptions_hash) }

0 commit comments

Comments
 (0)