lib/urbanopt/reopt/feature_report_adapter.rb in urbanopt-reopt-0.6.1 vs lib/urbanopt/reopt/feature_report_adapter.rb in urbanopt-reopt-0.6.2

- old
+ new

@@ -66,11 +66,11 @@ # * +feature_report+ - _URBANopt::Reporting::DefaultReports::FeatureReport_ - FeatureReport to use in converting the optional +reopt_assumptions_hash+ to a \REopt Lite post. If a +reopt_assumptions_hash+ is not provided, a default post will be updated from this FeatureReport and submitted to the \REopt Lite API. # * +reopt_assumptions_hash+ - _Hash_ - Optional. A hash formatted for submittal to the \REopt Lite API containing default values. Values will be overwritten from the FeatureReport where available (i.e. latitude, roof_squarefeet). Missing optional parameters will be filled in with default values by the API. # # [*return:*] _Hash_ - Returns hash formatted for submittal to the \REopt Lite API ## - def reopt_json_from_feature_report(feature_report, reopt_assumptions_hash = nil) + def reopt_json_from_feature_report(feature_report, reopt_assumptions_hash = nil, groundmount_photovoltaic = nil) name = feature_report.name.delete ' ' description = "feature_report_#{name}_#{feature_report.id}" reopt_inputs = { Scenario: { Site: { ElectricTariff: { blended_monthly_demand_charges_us_dollars_per_kw: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], blended_monthly_rates_us_dollars_per_kwh: [0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13] }, LoadProfile: {}, Wind: { max_kw: 0 } } } } if !reopt_assumptions_hash.nil? reopt_inputs = reopt_assumptions_hash @@ -101,12 +101,22 @@ # Parse Optional FeatureReport metrics - do not overwrite from assumptions file if reopt_inputs[:Scenario][:Site][:roof_squarefeet].nil? && !feature_report.program.roof_area_sqft.nil? reopt_inputs[:Scenario][:Site][:roof_squarefeet] = feature_report.program.roof_area_sqft[:available_roof_area_sqft] end - if reopt_inputs[:Scenario][:Site][:land_acres].nil? && !feature_report.program.site_area_sqft.nil? - reopt_inputs[:Scenario][:Site][:land_acres] = feature_report.program.site_area_sqft * 1.0 / 43560 # acres/sqft + if reopt_inputs[:Scenario][:Site][:land_acres].nil? + # Check if ground-mount PV is specified with the Feature ID and take footprint area of PV + # constrain for REopt optimization + begin + if !groundmount_photovoltaic[feature_report.id].nil? + reopt_inputs[:Scenario][:Site][:land_acres] = groundmount_photovoltaic[feature_report.id] * 1.0 / 43560 # acres/sqft + # If no ground-mount PV associated with feature use site area as constrain for REopt optimization + elsif !feature_report.program.site_area_sqft.nil? + reopt_inputs[:Scenario][:Site][:land_acres] = feature_report.program.site_area_sqft * 1.0 / 43560 # acres/sqft + end + rescue StandardError + end end if reopt_inputs[:Scenario][:time_steps_per_hour].nil? reopt_inputs[:Scenario][:time_steps_per_hour] = 1 end @@ -208,11 +218,22 @@ reopt_output['outputs']['Scenario']['Site']['PV'] = [reopt_output['outputs']['Scenario']['Site']['PV']] elsif reopt_output['outputs']['Scenario']['Site']['PV'].nil? reopt_output['outputs']['Scenario']['Site']['PV'] = [] end + # Store the PV name and location in a hash + location = {} + # Check whether multi PV assumption input file is used or single PV + if reopt_output['inputs']['Scenario']['Site']['PV'].is_a?(Array) + reopt_output['inputs']['Scenario']['Site']['PV'].each do |pv| + location[pv['pv_name']] = pv['location'] + end + else + location[reopt_output['inputs']['Scenario']['Site']['PV']['pv_name']] = reopt_output['inputs']['Scenario']['Site']['PV']['location'] + end + reopt_output['outputs']['Scenario']['Site']['PV'].each_with_index do |pv, i| - feature_report.distributed_generation.add_tech 'solar_pv', URBANopt::Reporting::DefaultReports::SolarPV.new({ size_kw: (pv['size_kw'] || 0), id: i }) + feature_report.distributed_generation.add_tech 'solar_pv', URBANopt::Reporting::DefaultReports::SolarPV.new({ size_kw: (pv['size_kw'] || 0), id: i, location: location[pv['pv_name']] }) end wind = reopt_output['outputs']['Scenario']['Site']['Wind'] if !wind['size_kw'].nil? && (wind['size_kw'] != 0) feature_report.distributed_generation.add_tech 'wind', URBANopt::Reporting::DefaultReports::Wind.new({ size_kw: (wind['size_kw'] || 0) })