urbanopt-reopt 0.11.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,11 +36,20 @@ module URBANopt # :nodoc:
36
36
  def reopt_json_from_feature_report(feature_report, reopt_assumptions_hash = nil, groundmount_photovoltaic = nil)
37
37
  name = feature_report.name.delete ' '
38
38
  description = "feature_report_#{name}_#{feature_report.id}"
39
- 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 } } } }
40
39
  if !reopt_assumptions_hash.nil?
41
40
  reopt_inputs = reopt_assumptions_hash
42
41
  else
43
42
  @@logger.info('Using default REopt assumptions')
43
+ reopt_inputs = {
44
+ Settings: {},
45
+ Site: {},
46
+ Financial: {},
47
+ ElectricTariff: {
48
+ monthly_demand_rates: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
49
+ 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]
50
+ },
51
+ ElectricLoad: {}
52
+ }
44
53
  end
45
54
 
46
55
  # Check FeatureReport has required data
@@ -57,33 +66,33 @@ module URBANopt # :nodoc:
57
66
  end
58
67
  end
59
68
 
60
- reopt_inputs[:Scenario][:description] = description
69
+ reopt_inputs[:description] = description
61
70
 
62
71
  # Parse Location
63
- reopt_inputs[:Scenario][:Site][:latitude] = feature_report.location.latitude_deg
64
- reopt_inputs[:Scenario][:Site][:longitude] = feature_report.location.longitude_deg
72
+ reopt_inputs[:Site][:latitude] = feature_report.location.latitude_deg
73
+ reopt_inputs[:Site][:longitude] = feature_report.location.longitude_deg
65
74
 
66
75
  # Parse Optional FeatureReport metrics - do not overwrite from assumptions file
67
- if reopt_inputs[:Scenario][:Site][:roof_squarefeet].nil? && !feature_report.program.roof_area_sqft.nil?
68
- reopt_inputs[:Scenario][:Site][:roof_squarefeet] = feature_report.program.roof_area_sqft[:available_roof_area_sqft]
76
+ if reopt_inputs[:Site][:roof_squarefeet].nil? && !feature_report.program.roof_area_sqft.nil?
77
+ reopt_inputs[:Site][:roof_squarefeet] = feature_report.program.roof_area_sqft[:available_roof_area_sqft]
69
78
  end
70
79
 
71
- if reopt_inputs[:Scenario][:Site][:land_acres].nil?
80
+ if reopt_inputs[:Site][:land_acres].nil?
72
81
  # Check if ground-mount PV is specified with the Feature ID and take footprint area of PV
73
82
  # constrain for REopt optimization
74
83
  begin
75
84
  if !groundmount_photovoltaic[feature_report.id].nil?
76
- reopt_inputs[:Scenario][:Site][:land_acres] = groundmount_photovoltaic[feature_report.id] * 1.0 / 43560 # acres/sqft
85
+ reopt_inputs[:Site][:land_acres] = groundmount_photovoltaic[feature_report.id] * 1.0 / 43560 # acres/sqft
77
86
  # If no ground-mount PV associated with feature use site area as constrain for REopt optimization
78
87
  elsif !feature_report.program.site_area_sqft.nil?
79
- reopt_inputs[:Scenario][:Site][:land_acres] = feature_report.program.site_area_sqft * 1.0 / 43560 # acres/sqft
88
+ reopt_inputs[:Site][:land_acres] = feature_report.program.site_area_sqft * 1.0 / 43560 # acres/sqft
80
89
  end
81
90
  rescue StandardError
82
91
  end
83
92
  end
84
93
 
85
- if reopt_inputs[:Scenario][:time_steps_per_hour].nil?
86
- reopt_inputs[:Scenario][:time_steps_per_hour] = 1
94
+ if reopt_inputs[:Settings][:time_steps_per_hour].nil?
95
+ reopt_inputs[:Settings][:time_steps_per_hour] = 1
87
96
  end
88
97
 
89
98
  # Parse Load Profile
@@ -112,25 +121,27 @@ module URBANopt # :nodoc:
112
121
 
113
122
  # Convert load to REopt Resolution
114
123
  begin
115
- reopt_inputs[:Scenario][:Site][:LoadProfile][:loads_kw] = convert_powerflow_resolution(energy_timeseries_kw, feature_report.timesteps_per_hour, reopt_inputs[:Scenario][:time_steps_per_hour])
124
+ reopt_inputs[:ElectricLoad][:loads_kw] = convert_powerflow_resolution(energy_timeseries_kw, feature_report.timesteps_per_hour, reopt_inputs[:Settings][:time_steps_per_hour])
116
125
  rescue StandardError
117
- @@logger.error("Could not convert the annual electric load from a resolution of #{feature_report.timesteps_per_hour} to #{reopt_inputs[:Scenario][:time_steps_per_hour]}")
118
- raise "Could not convert the annual electric load from a resolution of #{feature_report.timesteps_per_hour} to #{reopt_inputs[:Scenario][:time_steps_per_hour]}"
119
- end
120
-
121
- if reopt_inputs[:Scenario][:Site][:ElectricTariff][:coincident_peak_load_active_timesteps].nil?
122
- n_top_values = 100
123
- tmp1 = reopt_inputs[:Scenario][:Site][:LoadProfile][:loads_kw]
124
- tmp2 = tmp1.each_index.max_by(n_top_values * reopt_inputs[:Scenario][:time_steps_per_hour]) { |i| tmp1[i] }
125
- for i in (0...tmp2.count)
126
- tmp2[i] += 1
127
- end
128
- reopt_inputs[:Scenario][:Site][:ElectricTariff][:coincident_peak_load_active_timesteps] = tmp2
129
- end
130
-
131
- if reopt_inputs[:Scenario][:Site][:ElectricTariff][:coincident_peak_load_charge_us_dollars_per_kw].nil?
132
- reopt_inputs[:Scenario][:Site][:ElectricTariff][:coincident_peak_load_charge_us_dollars_per_kw] = 0
133
- end
126
+ @@logger.error("Could not convert the annual electric load from a resolution of #{feature_report.timesteps_per_hour} to #{reopt_inputs[:Settings][:time_steps_per_hour]}")
127
+ raise "Could not convert the annual electric load from a resolution of #{feature_report.timesteps_per_hour} to #{reopt_inputs[:Settings][:time_steps_per_hour]}"
128
+ end
129
+
130
+ # TODO: Restore coincident_peak stuff here and in Scenario Report adapter
131
+ # if reopt_inputs[:ElectricTariff][:coincident_peak_load_active_time_steps].nil?
132
+ # n_top_values = 100
133
+ # tmp1 = reopt_inputs[:ElectricLoad][:loads_kw]
134
+ # tmp2 = tmp1.each_index.max_by(n_top_values * reopt_inputs[:Settings][:time_steps_per_hour]) { |i| tmp1[i] }
135
+ # for i in (0...tmp2.count)
136
+ # tmp2[i] += 1
137
+ # end
138
+ # # this needs to be a 2D array
139
+ # reopt_inputs[:ElectricTariff][:coincident_peak_load_active_time_steps] = [tmp2]
140
+ # end
141
+
142
+ # if reopt_inputs[:ElectricTariff][:coincident_peak_load_charge_per_kw].nil?
143
+ # reopt_inputs[:ElectricTariff][:coincident_peak_load_charge_per_kw] = 0
144
+ # end
134
145
 
135
146
  return reopt_inputs
136
147
  end
@@ -140,37 +151,37 @@ module URBANopt # :nodoc:
140
151
  #
141
152
  # [*parameters:*]
142
153
  #
143
- # * +feature_report+ - _URBANopt::Reporting::DefaultReports::FeatureReport_ - FeatureReport to update from a \REopt reponse hash.
144
- # * +reopt_output+ - _Hash_ - A reponse hash from the \REopt API to use in overwriting FeatureReport technology sizes, costs and dispatch strategies.
154
+ # * +feature_report+ - _URBANopt::Reporting::DefaultReports::FeatureReport_ - FeatureReport to update from a \REopt response hash.
155
+ # * +reopt_output+ - _Hash_ - A response hash from the \REopt API to use in overwriting FeatureReport technology sizes, costs and dispatch strategies.
145
156
  # * +timeseries_csv_path+ - _String_ - Optional. The path to a file at which a new timeseries CSV will be written. If not provided a file is created based on the run_uuid of the \REopt optimization task.
146
157
  #
147
158
  # [*return:*] _URBANopt::Reporting::DefaultReports::FeatureReport_ - Returns an updated FeatureReport.
148
159
  ##
149
160
  def update_feature_report(feature_report, reopt_output, timeseries_csv_path = nil, resilience_stats = nil)
150
161
  # Check if the \REopt response is valid
151
- if reopt_output['outputs']['Scenario']['status'] != 'optimal'
152
- @@logger.info("Warning cannot Feature Report #{feature_report.name} #{feature_report.id} - REopt optimization was non-optimal")
162
+ if reopt_output['status'] != 'optimal'
163
+ @@logger.error("ERROR cannot update Feature Report #{feature_report.name} #{feature_report.id} - REopt optimization was non-optimal")
153
164
  return feature_report
154
165
  end
155
166
 
156
167
  # Update location
157
- feature_report.location.latitude_deg = reopt_output['inputs']['Scenario']['Site']['latitude']
158
- feature_report.location.longitude_deg = reopt_output['inputs']['Scenario']['Site']['longitude']
168
+ feature_report.location.latitude_deg = reopt_output['inputs']['Site']['latitude']
169
+ feature_report.location.longitude_deg = reopt_output['inputs']['Site']['longitude']
159
170
 
160
171
  # Update distributed generation sizing and financials
161
- feature_report.distributed_generation.annual_renewable_electricity_pct = reopt_output['outputs']['Scenario']['Site']['annual_renewable_electricity_pct'] || 0
162
- feature_report.distributed_generation.lcc_us_dollars = reopt_output['outputs']['Scenario']['Site']['Financial']['lcc_us_dollars'] || 0
163
- feature_report.distributed_generation.npv_us_dollars = reopt_output['outputs']['Scenario']['Site']['Financial']['npv_us_dollars'] || 0
164
- feature_report.distributed_generation.year_one_energy_cost_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['year_one_energy_cost_us_dollars'] || 0
165
- feature_report.distributed_generation.year_one_demand_cost_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['year_one_demand_cost_us_dollars'] || 0
166
- feature_report.distributed_generation.year_one_bill_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['year_one_bill_us_dollars'] || 0
167
- feature_report.distributed_generation.total_energy_cost_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['total_energy_cost_us_dollars'] || 0
168
- feature_report.distributed_generation.total_demand_cost_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['total_demand_cost_us_dollars'] || 0
169
- feature_report.distributed_generation.year_one_energy_cost_bau_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['year_one_energy_cost_bau_us_dollars'] || 0
170
- feature_report.distributed_generation.year_one_demand_cost_bau_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['year_one_demand_cost_bau_us_dollars'] || 0
171
- feature_report.distributed_generation.year_one_bill_bau_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['year_one_bill_bau_us_dollars'] || 0
172
- feature_report.distributed_generation.total_demand_cost_bau_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['total_demand_cost_bau_us_dollars'] || 0
173
- feature_report.distributed_generation.total_energy_cost_bau_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['total_energy_cost_bau_us_dollars'] || 0
172
+ feature_report.distributed_generation.renewable_electricity_fraction = reopt_output['outputs']['Site']['renewable_electricity_fraction'] || 0
173
+ feature_report.distributed_generation.lcc = reopt_output['outputs']['Financial']['lcc'] || 0
174
+ feature_report.distributed_generation.npv = reopt_output['outputs']['Financial']['npv'] || 0
175
+ feature_report.distributed_generation.year_one_energy_cost_before_tax = reopt_output['outputs']['ElectricTariff']['year_one_energy_cost_before_tax'] || 0
176
+ feature_report.distributed_generation.year_one_demand_cost_before_tax = reopt_output['outputs']['ElectricTariff']['year_one_demand_cost_before_tax'] || 0
177
+ feature_report.distributed_generation.year_one_bill_before_tax = reopt_output['outputs']['ElectricTariff']['year_one_bill_before_tax'] || 0
178
+ feature_report.distributed_generation.lifecycle_energy_cost_after_tax = reopt_output['outputs']['ElectricTariff']['lifecycle_energy_cost_after_tax'] || 0
179
+ feature_report.distributed_generation.lifecycle_demand_cost_after_tax = reopt_output['outputs']['ElectricTariff']['lifecycle_demand_cost_after_tax'] || 0
180
+ feature_report.distributed_generation.year_one_energy_cost_before_tax_bau = reopt_output['outputs']['ElectricTariff']['year_one_energy_cost_before_tax_bau'] || 0
181
+ feature_report.distributed_generation.year_one_demand_cost_before_tax_bau = reopt_output['outputs']['ElectricTariff']['year_one_demand_cost_before_tax_bau'] || 0
182
+ feature_report.distributed_generation.year_one_bill_before_tax_bau = reopt_output['outputs']['ElectricTariff']['year_one_bill_before_tax_bau'] || 0
183
+ feature_report.distributed_generation.lifecycle_demand_cost_after_tax_bau = reopt_output['outputs']['ElectricTariff']['lifecycle_demand_cost_after_tax_bau'] || 0
184
+ feature_report.distributed_generation.lifecycle_energy_cost_after_tax_bau = reopt_output['outputs']['ElectricTariff']['lifecycle_energy_cost_after_tax_bau'] || 0
174
185
  if !resilience_stats.nil?
175
186
  feature_report.distributed_generation.resilience_hours_min = resilience_stats['resilience_hours_min']
176
187
  feature_report.distributed_generation.resilience_hours_max = resilience_stats['resilience_hours_max']
@@ -180,10 +191,10 @@ module URBANopt # :nodoc:
180
191
  feature_report.distributed_generation.probs_of_surviving_by_hour_of_the_day = resilience_stats['probs_of_surviving_by_hour_of_the_day']
181
192
  end
182
193
 
183
- if reopt_output['outputs']['Scenario']['Site']['PV'].instance_of?(Hash)
184
- reopt_output['outputs']['Scenario']['Site']['PV'] = [reopt_output['outputs']['Scenario']['Site']['PV']]
185
- elsif reopt_output['outputs']['Scenario']['Site']['PV'].nil?
186
- reopt_output['outputs']['Scenario']['Site']['PV'] = []
194
+ if reopt_output['outputs']['PV'].is_a?(Hash)
195
+ reopt_output['outputs']['PV'] = [reopt_output['outputs']['PV']]
196
+ elsif reopt_output['outputs']['PV'].nil?
197
+ reopt_output['outputs']['PV'] = []
187
198
  end
188
199
 
189
200
  # Store the PV name and location in a hash
@@ -194,58 +205,60 @@ module URBANopt # :nodoc:
194
205
  gcr = {}
195
206
 
196
207
  # Check whether multi PV assumption input file is used or single PV
197
- if reopt_output['inputs']['Scenario']['Site']['PV'].is_a?(Array)
198
- reopt_output['inputs']['Scenario']['Site']['PV'].each do |pv|
199
- location[pv['pv_name']] = pv['location']
200
- azimuth[pv['pv_name']] = pv['azimuth']
201
- tilt[pv['pv_name']] = pv['tilt']
202
- module_type[pv['pv_name']] = pv['module_type']
203
- gcr[pv['pv_name']] = pv['gcr']
208
+ if reopt_output['inputs'].key?('PV')
209
+ if reopt_output['inputs']['PV'].is_a?(Array)
210
+ reopt_output['inputs']['PV'].each do |pv|
211
+ location[pv['name']] = pv['location']
212
+ azimuth[pv['name']] = pv['azimuth']
213
+ tilt[pv['name']] = pv['tilt']
214
+ module_type[pv['name']] = pv['module_type']
215
+ gcr[pv['name']] = pv['gcr']
216
+ end
217
+ else
218
+ location[reopt_output['inputs']['PV']['name']] = reopt_output['inputs']['PV']['location']
219
+ azimuth[reopt_output['inputs']['PV']['name']] = reopt_output['inputs']['PV']['azimuth']
220
+ tilt[reopt_output['inputs']['PV']['name']] = reopt_output['inputs']['PV']['tilt']
221
+ module_type[reopt_output['inputs']['PV']['name']] = reopt_output['inputs']['PV']['module_type']
222
+ gcr[reopt_output['inputs']['PV']['name']] = reopt_output['inputs']['PV']['gcr']
204
223
  end
205
- else
206
- location[reopt_output['inputs']['Scenario']['Site']['PV']['pv_name']] = reopt_output['inputs']['Scenario']['Site']['PV']['location']
207
- azimuth[reopt_output['inputs']['Scenario']['Site']['PV']['pv_name']] = reopt_output['inputs']['Scenario']['Site']['PV']['azimuth']
208
- tilt[reopt_output['inputs']['Scenario']['Site']['PV']['pv_name']] = reopt_output['inputs']['Scenario']['Site']['PV']['tilt']
209
- module_type[reopt_output['inputs']['Scenario']['Site']['PV']['pv_name']] = reopt_output['inputs']['Scenario']['Site']['PV']['module_type']
210
- gcr[reopt_output['inputs']['Scenario']['Site']['PV']['pv_name']] = reopt_output['inputs']['Scenario']['Site']['PV']['gcr']
211
- end
212
224
 
213
- reopt_output['outputs']['Scenario']['Site']['PV'].each_with_index do |pv, i|
214
- 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']], average_yearly_energy_produced_kwh: pv['average_yearly_energy_produced_kwh'], azimuth: azimuth[pv['pv_name']], tilt: tilt[pv['pv_name']], module_type: module_type[pv['pv_name']], gcr: gcr[pv['pv_name']] })
225
+ reopt_output['outputs']['PV'].each_with_index do |pv, i|
226
+ feature_report.distributed_generation.add_tech 'solar_pv', URBANopt::Reporting::DefaultReports::SolarPV.new({ size_kw: (pv['size_kw'] || 0), id: i, location: location[pv['name']], average_yearly_energy_produced_kwh: pv['annual_energy_produced_kwh'], azimuth: azimuth[pv['name']], tilt: tilt[pv['name']], module_type: module_type[pv['name']], gcr: gcr[pv['name']] })
227
+ end
215
228
  end
216
229
 
217
- wind = reopt_output['outputs']['Scenario']['Site']['Wind']
218
- if !wind['size_kw'].nil? && (wind['size_kw'] != 0)
230
+ if reopt_output['outputs'].key?('Wind')
231
+ wind = reopt_output['outputs']['Wind']
219
232
  feature_report.distributed_generation.add_tech 'wind', URBANopt::Reporting::DefaultReports::Wind.new({ size_kw: (wind['size_kw'] || 0) })
220
233
  end
221
234
 
222
- generator = reopt_output['outputs']['Scenario']['Site']['Generator']
223
- if !generator['size_kw'].nil? && (generator['size_kw'] != 0)
235
+ if reopt_output['outputs'].key?('Generator')
236
+ generator = reopt_output['outputs']['Generator']
224
237
  feature_report.distributed_generation.add_tech 'generator', URBANopt::Reporting::DefaultReports::Generator.new({ size_kw: (generator['size_kw'] || 0) })
225
238
  end
226
239
 
227
- storage = reopt_output['outputs']['Scenario']['Site']['Storage']
228
- if !storage['size_kw'].nil? && (storage['size_kw'] != 0)
240
+ if reopt_output['outputs'].key?('ElectricStorage')
241
+ storage = reopt_output['outputs']['ElectricStorage']
229
242
  feature_report.distributed_generation.add_tech 'storage', URBANopt::Reporting::DefaultReports::Storage.new({ size_kwh: (storage['size_kwh'] || 0), size_kw: (storage['size_kw'] || 0) })
230
243
  end
231
244
 
232
245
  generation_timeseries_kwh = Matrix[[0] * (8760 * feature_report.timesteps_per_hour)]
233
- reopt_resolution = reopt_output['inputs']['Scenario']['time_steps_per_hour']
246
+ reopt_resolution = reopt_output['inputs']['Settings']['time_steps_per_hour']
234
247
 
235
- unless reopt_output['outputs']['Scenario']['Site']['PV'].nil?
236
- reopt_output['outputs']['Scenario']['Site']['PV'].each do |pv|
248
+ if reopt_output['outputs'].key?('PV') && !reopt_output['outputs']['PV'].nil?
249
+ reopt_output['outputs']['PV'].each do |pv|
237
250
  if (pv['size_kw'] || 0) > 0 && !pv['year_one_power_production_series_kw'].nil?
238
251
  generation_timeseries_kwh += Matrix[convert_powerflow_resolution(pv['year_one_power_production_series_kw'], reopt_resolution, feature_report.timesteps_per_hour)]
239
252
  end
240
253
  end
241
254
  end
242
255
 
243
- if !reopt_output['outputs']['Scenario']['Site']['Wind'].nil? && ((reopt_output['outputs']['Scenario']['Site']['Wind']['size_kw'] || 0) > 0) && !reopt_output['outputs']['Scenario']['Site']['Wind']['year_one_power_production_series_kw'].nil?
244
- generation_timeseries_kwh += Matrix[convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['Wind']['year_one_power_production_series_kw'], reopt_resolution, feature_report.timesteps_per_hour)]
256
+ if reopt_output['outputs'].key?('Wind') && !reopt_output['outputs']['Wind'].nil? && ((reopt_output['outputs']['Wind']['size_kw'] || 0) > 0) && !reopt_output['outputs']['Wind']['year_one_power_production_series_kw'].nil?
257
+ generation_timeseries_kwh += Matrix[convert_powerflow_resolution(reopt_output['outputs']['Wind']['year_one_power_production_series_kw'], reopt_resolution, feature_report.timesteps_per_hour)]
245
258
  end
246
259
 
247
- if !reopt_output['outputs']['Scenario']['Site']['Generator'].nil? && ((reopt_output['outputs']['Scenario']['Site']['Generator']['size_kw'] || 0) > 0) && !reopt_output['outputs']['Scenario']['Site']['Generator']['year_one_power_production_series_kw'].nil?
248
- generation_timeseries_kwh += Matrix[convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['Generator']['year_one_power_production_series_kw'], reopt_resolution, feature_report.timesteps_per_hour)]
260
+ if reopt_output['outputs'].key?('Generator') && !reopt_output['outputs']['Generator'].nil? && ((reopt_output['outputs']['Generator']['size_kw'] || 0) > 0) && !reopt_output['outputs']['Generator']['year_one_power_production_series_kw'].nil?
261
+ generation_timeseries_kwh += Matrix[convert_powerflow_resolution(reopt_output['outputs']['Generator']['year_one_power_production_series_kw'], reopt_resolution, feature_report.timesteps_per_hour)]
249
262
  end
250
263
 
251
264
  $generation_timeseries_kwh = generation_timeseries_kwh.to_a[0] || [0] * (8760 * feature_report.timesteps_per_hour)
@@ -255,167 +268,187 @@ module URBANopt # :nodoc:
255
268
  feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Total(kw)')
256
269
  end
257
270
 
258
- $load = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['LoadProfile']['year_one_electric_load_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
271
+ $load = convert_powerflow_resolution(reopt_output['outputs']['ElectricLoad']['load_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
259
272
  $load_col = feature_report.timeseries_csv.column_names.index('REopt:Electricity:Load:Total(kw)')
260
273
  if $load_col.nil?
261
274
  $load_col = feature_report.timeseries_csv.column_names.length
262
275
  feature_report.timeseries_csv.column_names.push('REopt:Electricity:Load:Total(kw)')
263
276
  end
264
277
 
265
- $utility_to_load = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['year_one_to_load_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
278
+ $utility_to_load = convert_powerflow_resolution(reopt_output['outputs']['ElectricUtility']['electric_to_load_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
266
279
  $utility_to_load_col = feature_report.timeseries_csv.column_names.index('REopt:Electricity:Grid:ToLoad(kw)')
267
280
  if $utility_to_load_col.nil?
268
281
  $utility_to_load_col = feature_report.timeseries_csv.column_names.length
269
282
  feature_report.timeseries_csv.column_names.push('REopt:Electricity:Grid:ToLoad(kw)')
270
283
  end
271
284
 
272
- $utility_to_battery = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['year_one_to_battery_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
273
- $utility_to_battery_col = feature_report.timeseries_csv.column_names.index('REopt:Electricity:Grid:ToBattery(kw)')
274
- if $utility_to_battery_col.nil?
275
- $utility_to_battery_col = feature_report.timeseries_csv.column_names.length
276
- feature_report.timeseries_csv.column_names.push('REopt:Electricity:Grid:ToBattery(kw)')
277
- end
285
+ if !storage.nil?
286
+ $utility_to_battery = convert_powerflow_resolution(reopt_output['outputs']['ElectricUtility']['electric_to_storage_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
287
+ $utility_to_battery_col = feature_report.timeseries_csv.column_names.index('REopt:Electricity:Grid:ToBattery(kw)')
288
+ if $utility_to_battery_col.nil?
289
+ $utility_to_battery_col = feature_report.timeseries_csv.column_names.length
290
+ feature_report.timeseries_csv.column_names.push('REopt:Electricity:Grid:ToBattery(kw)')
291
+ end
278
292
 
279
- $storage_to_load = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['Storage']['year_one_to_load_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
280
- $storage_to_load_col = feature_report.timeseries_csv.column_names.index('REopt:Electricity:Storage:ToLoad(kw)')
281
- if $storage_to_load_col.nil?
282
- $storage_to_load_col = feature_report.timeseries_csv.column_names.length
283
- feature_report.timeseries_csv.column_names.push('REopt:Electricity:Storage:ToLoad(kw)')
284
- end
293
+ $storage_to_load = convert_powerflow_resolution(reopt_output['outputs']['ElectricStorage']['storage_to_load_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
294
+ $storage_to_load_col = feature_report.timeseries_csv.column_names.index('REopt:Electricity:Storage:ToLoad(kw)')
295
+ if $storage_to_load_col.nil?
296
+ $storage_to_load_col = feature_report.timeseries_csv.column_names.length
297
+ feature_report.timeseries_csv.column_names.push('REopt:Electricity:Storage:ToLoad(kw)')
298
+ end
285
299
 
286
- $storage_to_grid = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['Storage']['year_one_to_grid_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
287
- $storage_to_grid_col = feature_report.timeseries_csv.column_names.index('REopt:Electricity:Storage:ToGrid(kw)')
288
- if $storage_to_grid_col.nil?
289
- $storage_to_grid_col = feature_report.timeseries_csv.column_names.length
290
- feature_report.timeseries_csv.column_names.push('REopt:Electricity:Storage:ToGrid(kw)')
291
- end
300
+ $storage_to_grid = convert_powerflow_resolution(reopt_output['outputs']['ElectricStorage']['electric_to_grid_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
301
+ $storage_to_grid_col = feature_report.timeseries_csv.column_names.index('REopt:Electricity:Storage:ToGrid(kw)')
302
+ if $storage_to_grid_col.nil?
303
+ $storage_to_grid_col = feature_report.timeseries_csv.column_names.length
304
+ feature_report.timeseries_csv.column_names.push('REopt:Electricity:Storage:ToGrid(kw)')
305
+ end
292
306
 
293
- $storage_soc = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['Storage']['year_one_soc_series_pct'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
294
- $storage_soc_col = feature_report.timeseries_csv.column_names.index('REopt:Electricity:Storage:StateOfCharge(pct)')
295
- if $storage_soc_col.nil?
296
- $storage_soc_col = feature_report.timeseries_csv.column_names.length
297
- feature_report.timeseries_csv.column_names.push('REopt:Electricity:Storage:StateOfCharge(pct)')
307
+ $storage_soc = convert_powerflow_resolution(reopt_output['outputs']['ElectricStorage']['soc_series_fraction'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
308
+ $storage_soc_col = feature_report.timeseries_csv.column_names.index('REopt:Electricity:Storage:StateOfCharge(pct)')
309
+ if $storage_soc_col.nil?
310
+ $storage_soc_col = feature_report.timeseries_csv.column_names.length
311
+ feature_report.timeseries_csv.column_names.push('REopt:Electricity:Storage:StateOfCharge(pct)')
312
+ end
298
313
  end
299
314
 
300
- $generator_total = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['Generator']['year_one_power_production_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
301
- $generator_total_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:Generator:Total(kw)')
302
- if $generator_total_col.nil?
303
- $generator_total_col = feature_report.timeseries_csv.column_names.length
304
- feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Generator:Total(kw)')
305
- end
315
+ if !generator.nil?
316
+ # $generator_total = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['Generator']['year_one_power_production_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
317
+ $generator_total_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:Generator:Total(kw)')
318
+ if $generator_total_col.nil?
319
+ $generator_total_col = feature_report.timeseries_csv.column_names.length
320
+ feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Generator:Total(kw)')
321
+ end
306
322
 
307
- $generator_to_battery = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['Generator']['year_one_to_battery_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
308
- $generator_to_battery_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:Generator:ToBattery(kw)')
309
- if $generator_to_battery_col.nil?
310
- $generator_to_battery_col = feature_report.timeseries_csv.column_names.length
311
- feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Generator:ToBattery(kw)')
312
- end
323
+ if !storage.nil?
324
+ $generator_to_battery = convert_powerflow_resolution(reopt_output['outputs']['Generator']['electric_to_storage_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
325
+ $generator_to_battery_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:Generator:ToBattery(kw)')
326
+ if $generator_to_battery_col.nil?
327
+ $generator_to_battery_col = feature_report.timeseries_csv.column_names.length
328
+ feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Generator:ToBattery(kw)')
329
+ end
330
+ end
313
331
 
314
- $generator_to_load = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['Generator']['year_one_to_load_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
315
- $generator_to_load_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:Generator:ToLoad(kw)')
316
- if $generator_to_load_col.nil?
317
- $generator_to_load_col = feature_report.timeseries_csv.column_names.length
318
- feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Generator:ToLoad(kw)')
319
- end
332
+ $generator_to_load = convert_powerflow_resolution(reopt_output['outputs']['Generator']['electric_to_load_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
333
+ $generator_to_load_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:Generator:ToLoad(kw)')
334
+ if $generator_to_load_col.nil?
335
+ $generator_to_load_col = feature_report.timeseries_csv.column_names.length
336
+ feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Generator:ToLoad(kw)')
337
+ end
320
338
 
321
- $generator_to_grid = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['Generator']['year_one_to_grid_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
322
- $generator_to_grid_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:Generator:ToGrid(kw)')
323
- if $generator_to_grid_col.nil?
324
- $generator_to_grid_col = feature_report.timeseries_csv.column_names.length
325
- feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Generator:ToGrid(kw)')
339
+ $generator_to_grid = convert_powerflow_resolution(reopt_output['outputs']['Generator']['electric_to_grid_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
340
+ $generator_to_grid_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:Generator:ToGrid(kw)')
341
+ if $generator_to_grid_col.nil?
342
+ $generator_to_grid_col = feature_report.timeseries_csv.column_names.length
343
+ feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Generator:ToGrid(kw)')
344
+ end
326
345
  end
327
346
 
328
- $pv_total_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:PV:Total(kw)')
329
- if $pv_total_col.nil?
330
- $pv_total_col = feature_report.timeseries_csv.column_names.length
331
- feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:PV:Total(kw)')
332
- end
347
+ if reopt_output['outputs'].key?('PV') && !reopt_output['outputs']['PV'].nil?
348
+ $pv_total_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:PV:Total(kw)')
349
+ if $pv_total_col.nil?
350
+ $pv_total_col = feature_report.timeseries_csv.column_names.length
351
+ feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:PV:Total(kw)')
352
+ end
333
353
 
334
- $pv_to_battery_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:PV:ToBattery(kw)')
335
- if $pv_to_battery_col.nil?
336
- $pv_to_battery_col = feature_report.timeseries_csv.column_names.length
337
- feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:PV:ToBattery(kw)')
338
- end
354
+ if !storage.nil?
355
+ $pv_to_battery_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:PV:ToBattery(kw)')
356
+ if $pv_to_battery_col.nil?
357
+ $pv_to_battery_col = feature_report.timeseries_csv.column_names.length
358
+ feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:PV:ToBattery(kw)')
359
+ end
360
+ end
339
361
 
340
- $pv_to_load_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:PV:ToLoad(kw)')
341
- if $pv_to_load_col.nil?
342
- $pv_to_load_col = feature_report.timeseries_csv.column_names.length
343
- feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:PV:ToLoad(kw)')
344
- end
362
+ $pv_to_load_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:PV:ToLoad(kw)')
363
+ if $pv_to_load_col.nil?
364
+ $pv_to_load_col = feature_report.timeseries_csv.column_names.length
365
+ feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:PV:ToLoad(kw)')
366
+ end
345
367
 
346
- $pv_to_grid_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:PV:ToGrid(kw)')
347
- if $pv_to_grid_col.nil?
348
- $pv_to_grid_col = feature_report.timeseries_csv.column_names.length
349
- feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:PV:ToGrid(kw)')
350
- end
368
+ $pv_to_grid_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:PV:ToGrid(kw)')
369
+ if $pv_to_grid_col.nil?
370
+ $pv_to_grid_col = feature_report.timeseries_csv.column_names.length
371
+ feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:PV:ToGrid(kw)')
372
+ end
351
373
 
352
- $pv_total = Matrix[[0] * (8760 * feature_report.timesteps_per_hour)]
353
- $pv_to_battery = Matrix[[0] * (8760 * feature_report.timesteps_per_hour)]
354
- $pv_to_load = Matrix[[0] * (8760 * feature_report.timesteps_per_hour)]
355
- $pv_to_grid = Matrix[[0] * (8760 * feature_report.timesteps_per_hour)]
356
-
357
- reopt_output['outputs']['Scenario']['Site']['PV'].each_with_index do |pv, i|
358
- if (pv['size_kw'] || 0) > 0
359
- $pv_total += Matrix[convert_powerflow_resolution(pv['year_one_power_production_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)]
360
- $pv_to_battery += Matrix[convert_powerflow_resolution(pv['year_one_to_battery_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)]
361
- $pv_to_load += Matrix[convert_powerflow_resolution(pv['year_one_to_load_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)]
362
- $pv_to_grid += Matrix[convert_powerflow_resolution(pv['year_one_to_grid_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)]
374
+ $pv_total = Matrix[[0] * (8760 * feature_report.timesteps_per_hour)]
375
+ if !storage.nil?
376
+ $pv_to_battery = Matrix[[0] * (8760 * feature_report.timesteps_per_hour)]
377
+ end
378
+ $pv_to_load = Matrix[[0] * (8760 * feature_report.timesteps_per_hour)]
379
+ $pv_to_grid = Matrix[[0] * (8760 * feature_report.timesteps_per_hour)]
380
+
381
+ reopt_output['outputs']['PV'].each_with_index do |pv, i|
382
+ if (pv['size_kw'] || 0) > 0
383
+ # $pv_total += Matrix[convert_powerflow_resolution(pv['year_one_power_production_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)]
384
+ if !storage.nil?
385
+ $pv_to_battery += Matrix[convert_powerflow_resolution(pv['electric_to_storage_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)]
386
+ end
387
+ $pv_to_load += Matrix[convert_powerflow_resolution(pv['electric_to_load_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)]
388
+ $pv_to_grid += Matrix[convert_powerflow_resolution(pv['electric_to_grid_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)]
389
+ end
363
390
  end
364
- end
365
391
 
366
- $pv_total = $pv_total.to_a[0]
367
- $pv_to_battery = $pv_to_battery.to_a[0]
368
- $pv_to_load = $pv_to_load.to_a[0]
369
- $pv_to_grid = $pv_to_grid.to_a[0]
392
+ $pv_total = $pv_total.to_a[0]
393
+ if !storage.nil?
394
+ $pv_to_battery = $pv_to_battery.to_a[0]
395
+ end
396
+ $pv_to_load = $pv_to_load.to_a[0]
397
+ $pv_to_grid = $pv_to_grid.to_a[0]
398
+ end
370
399
 
371
- $wind_total = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['Wind']['year_one_power_production_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
400
+ # $wind_total = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['Wind']['year_one_power_production_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
372
401
  $wind_total_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:Wind:Total(kw)')
373
402
  if $wind_total_col.nil?
374
403
  $wind_total_col = feature_report.timeseries_csv.column_names.length
375
404
  feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Wind:Total(kw)')
376
405
  end
377
406
 
378
- $wind_to_battery = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['Wind']['year_one_to_battery_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
379
- $wind_to_battery_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:Wind:ToBattery(kw)')
380
- if $wind_to_battery_col.nil?
381
- $wind_to_battery_col = feature_report.timeseries_csv.column_names.length
382
- feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Wind:ToBattery(kw)')
383
- end
407
+ if !wind.nil?
408
+ if !storage.nil?
409
+ $wind_to_battery = convert_powerflow_resolution(reopt_output['outputs']['Wind']['electric_to_storage_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
410
+ $wind_to_battery_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:Wind:ToBattery(kw)')
411
+ if $wind_to_battery_col.nil?
412
+ $wind_to_battery_col = feature_report.timeseries_csv.column_names.length
413
+ feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Wind:ToBattery(kw)')
414
+ end
415
+ end
384
416
 
385
- $wind_to_load = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['Wind']['year_one_to_load_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
386
- $wind_to_load_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:Wind:ToLoad(kw)')
387
- if $wind_to_load_col.nil?
388
- $wind_to_load_col = feature_report.timeseries_csv.column_names.length
389
- feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Wind:ToLoad(kw)')
390
- end
417
+ $wind_to_load = convert_powerflow_resolution(reopt_output['outputs']['Wind']['electric_to_load_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
418
+ $wind_to_load_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:Wind:ToLoad(kw)')
419
+ if $wind_to_load_col.nil?
420
+ $wind_to_load_col = feature_report.timeseries_csv.column_names.length
421
+ feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Wind:ToLoad(kw)')
422
+ end
391
423
 
392
- $wind_to_grid = convert_powerflow_resolution(reopt_output['outputs']['Scenario']['Site']['Wind']['year_one_to_grid_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
393
- $wind_to_grid_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:Wind:ToGrid(kw)')
394
- if $wind_to_grid_col.nil?
395
- $wind_to_grid_col = feature_report.timeseries_csv.column_names.length
396
- feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Wind:ToGrid(kw)')
424
+ $wind_to_grid = convert_powerflow_resolution(reopt_output['outputs']['Wind']['electric_to_grid_series_kw'], reopt_resolution, feature_report.timesteps_per_hour) || [0] * (8760 * feature_report.timesteps_per_hour)
425
+ $wind_to_grid_col = feature_report.timeseries_csv.column_names.index('REopt:ElectricityProduced:Wind:ToGrid(kw)')
426
+ if $wind_to_grid_col.nil?
427
+ $wind_to_grid_col = feature_report.timeseries_csv.column_names.length
428
+ feature_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Wind:ToGrid(kw)')
429
+ end
397
430
  end
398
431
 
399
432
  def modrow(x, i) # :nodoc:
400
433
  x[$generation_timeseries_kwh_col] = $generation_timeseries_kwh[i] || 0
401
434
  x[$load_col] = $load[i] || 0
402
435
  x[$utility_to_load_col] = $utility_to_load[i] || 0
403
- x[$utility_to_battery_col] = $utility_to_battery[i] || 0
404
- x[$storage_to_load_col] = $storage_to_load[i] || 0
405
- x[$storage_to_grid_col] = $storage_to_grid[i] || 0
406
- x[$storage_soc_col] = $storage_soc[i] || 0
407
- x[$generator_total_col] = $generator_total[i] || 0
408
- x[$generator_to_battery_col] = $generator_to_battery[i] || 0
409
- x[$generator_to_load_col] = $generator_to_load[i] || 0
410
- x[$generator_to_grid_col] = $generator_to_grid[i] || 0
436
+ x[$utility_to_battery_col] = $utility_to_battery[i] || 0 if defined?(storage)
437
+ x[$storage_to_load_col] = $storage_to_load[i] || 0 if defined?(storage)
438
+ x[$storage_to_grid_col] = $storage_to_grid[i] || 0 if defined?(storage)
439
+ x[$storage_soc_col] = $storage_soc[i] || 0 if defined?(storage)
440
+ x[$generator_total_col] = $generator_total[i] || 0 if defined?(generator)
441
+ x[$generator_to_battery_col] = $generator_to_battery[i] || 0 if defined?(generator) && defined?(storage)
442
+ x[$generator_to_load_col] = $generator_to_load[i] || 0 if defined?(generator)
443
+ x[$generator_to_grid_col] = $generator_to_grid[i] || 0 if defined?(generator)
411
444
  x[$pv_total_col] = $pv_total[i] || 0
412
- x[$pv_to_battery_col] = $pv_to_battery[i] || 0
445
+ x[$pv_to_battery_col] = $pv_to_battery[i] || 0 if defined?(storage)
413
446
  x[$pv_to_load_col] = $pv_to_load[i] || 0
414
447
  x[$pv_to_grid_col] = $pv_to_grid[i] || 0
415
- x[$wind_total_col] = $wind_total[i] || 0
416
- x[$wind_to_battery_col] = $wind_to_battery[i] || 0
417
- x[$wind_to_load_col] = $wind_to_load[i] || 0
418
- x[$wind_to_grid_col] = $wind_to_grid[i] || 0
448
+ x[$wind_total_col] = $wind_total[i] || 0 if defined?(wind)
449
+ x[$wind_to_battery_col] = $wind_to_battery[i] || 0 if defined?(wind) && defined?(storage)
450
+ x[$wind_to_load_col] = $wind_to_load[i] || 0 if defined?(wind)
451
+ x[$wind_to_grid_col] = $wind_to_grid[i] || 0 if defined?(wind)
419
452
  return x
420
453
  end
421
454
 
@@ -425,8 +458,7 @@ module URBANopt # :nodoc:
425
458
  (
426
459
  ((start_date.yday - 1) * 60.0 * 60.0 * 24) +
427
460
  ((start_date.hour - 1) * 60.0 * 60.0) +
428
- (start_date.min * 60.0) + start_date.sec) /
429
- ((60 / feature_report.timesteps_per_hour) * 60)
461
+ (start_date.min * 60.0) + start_date.sec) / ((60 / feature_report.timesteps_per_hour) * 60)
430
462
  ).to_int
431
463
 
432
464
  mod_data = old_data.map.with_index do |x, i|