urbanopt-reopt 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
3
3
  # contributors. All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without modification,
@@ -29,7 +29,7 @@
29
29
  # *********************************************************************************
30
30
 
31
31
  require 'bundler/setup'
32
- require 'urbanopt/scenario/default_reports'
32
+ require 'urbanopt/reporting/default_reports'
33
33
  require 'urbanopt/reopt/reopt_logger'
34
34
  require 'urbanopt/reopt'
35
35
  require 'csv'
@@ -43,7 +43,7 @@ module URBANopt # :nodoc:
43
43
  #
44
44
  # [*parameters:*]
45
45
  #
46
- # * +scenario_report+ - _ScenarioReport_ - Optional. A scenario report that has been returned from the URBANopt::Scenario::ScenarioDefaultPostProcessor - used in creating default output file names in \REopt Lite optimizations.
46
+ # * +scenario_report+ - _ScenarioReport_ - Optional. A scenario report that has been returned from the URBANopt::Reporting::ScenarioDefaultPostProcessor - used in creating default output file names in \REopt Lite optimizations.
47
47
  # * +scenario_reopt_assumptions_file+ - _String_ - Optional. JSON file formatted for a \REopt Lite analysis containing custom input parameters for optimizations at the Scenario Report level
48
48
  # * +reopt_feature_assumptions+ - _Array_ - Optional. A list of JSON file formatted for a \REopt Lite analysis containing custom input parameters for optimizations at the Feature Report level. The order and number of files must match the Feature Reports in the scenario_report input.
49
49
  # * +use_localhost+ - _Bool_ - If this is true, requests will be sent to a version of the \REopt Lite API running on localhost. Default is false, such that the production version of \REopt Lite is accessed.
@@ -70,8 +70,9 @@ module URBANopt # :nodoc:
70
70
  if !scenario_report.nil?
71
71
  @scenario_report = scenario_report
72
72
 
73
- if !Dir.exist?(File.join(@scenario_report.directory_name, "reopt"))
73
+ if !Dir.exist?(File.join(@scenario_report.directory_name, "reopt"))
74
74
  Dir.mkdir(File.join(@scenario_report.directory_name, "reopt"))
75
+ @@logger.info("Created directory: " + File.join(@scenario_report.directory_name, "reopt"))
75
76
  end
76
77
 
77
78
  @scenario_reopt_default_output_file = File.join(@scenario_report.directory_name, "reopt/scenario_report_#{@scenario_report.id}_reopt_run.json")
@@ -80,6 +81,7 @@ module URBANopt # :nodoc:
80
81
  @scenario_report.feature_reports.each do |fr|
81
82
  if !Dir.exist?(File.join(fr.directory_name, "reopt"))
82
83
  Dir.mkdir(File.join(fr.directory_name, "reopt"))
84
+ @@logger.info("Created directory: " + File.join(fr.directory_name, "reopt"))
83
85
  end
84
86
  @feature_reports_reopt_default_output_files << File.join(fr.directory_name, "reopt/feature_report_#{fr.id}_reopt_run.json")
85
87
  end
@@ -111,23 +113,33 @@ module URBANopt # :nodoc:
111
113
  #
112
114
  # [*parameters:*]
113
115
  #
114
- # * +feature_report+ - _URBANopt::Scenario::DefaultReports::FeatureReport_ - FeatureReport which will be used in creating and then updated by a \REopt Lite opimization response.
116
+ # * +feature_report+ - _URBANopt::Reporting::DefaultReports::FeatureReport_ - FeatureReport which will be used in creating and then updated by a \REopt Lite opimization response.
115
117
  # * +reopt_assumptions_hash+ - _Hash_ - Optional. A \REopt Lite formatted hash containing default parameters (i.e. utility rate, escalation rate) which will be updated by the FeatureReport (i.e. location, roof availability)
116
118
  # * +reopt_output_file+ - _String_ - Optional. Path to a file at which REpopt Lite responses will be saved.
117
119
  # * +timeseries_csv_path+ - _String_ - Optional. Path to a file at which the new timeseries CSV for the FeatureReport will be saved.
118
120
  #
119
- # [*return:*] _URBANopt::Scenario::DefaultReports::FeatureReport_ - Returns an updated FeatureReport
121
+ # [*return:*] _URBANopt::Reporting::DefaultReports::FeatureReport_ - Returns an updated FeatureReport
120
122
  ##
121
- def run_feature_report(feature_report:, reopt_assumptions_hash:nil, reopt_output_file:nil, timeseries_csv_path:nil, save_name:nil)
123
+ def run_feature_report(feature_report:, reopt_assumptions_hash:nil, reopt_output_file:nil, timeseries_csv_path:nil, save_name:nil, run_resilience:true)
122
124
  api = URBANopt::REopt::REoptLiteAPI.new(@nrel_developer_key, @localhost)
123
125
  adapter = URBANopt::REopt::FeatureReportAdapter.new
124
126
 
125
127
  reopt_input = adapter.reopt_json_from_feature_report(feature_report, reopt_assumptions_hash)
126
128
  if reopt_output_file.nil?
127
- reopt_output_file = feature_report.directory_name
129
+ reopt_output_file = File.join(feature_report.directory_name, 'reopt')
128
130
  end
129
131
  reopt_output = api.reopt_request(reopt_input, reopt_output_file)
130
- result = adapter.update_feature_report(feature_report, reopt_output, timeseries_csv_path)
132
+ if run_resilience
133
+ run_uuid = reopt_output['outputs']['Scenario']['run_uuid']
134
+ if File.directory? reopt_output_file
135
+ resilience_stats = api.resilience_request(run_uuid, reopt_output_file)
136
+ else
137
+ resilience_stats = api.resilience_request(run_uuid, reopt_output_file.sub!('.json','_resilience.json'))
138
+ end
139
+ else
140
+ resilience_stats = nil
141
+ end
142
+ result = adapter.update_feature_report(feature_report, reopt_output, timeseries_csv_path, resilience_stats)
131
143
  if !save_name.nil?
132
144
  result.save_feature_report save_name
133
145
  end
@@ -140,13 +152,13 @@ module URBANopt # :nodoc:
140
152
  #
141
153
  # [*parameters:*]
142
154
  #
143
- # * +feature_report+ - _URBANopt::Scenario::DefaultReports::ScenarioReport_ - ScenarioReport which will be used in creating and then updated by a \REopt Lite opimization response.
155
+ # * +feature_report+ - _URBANopt::Reporting::DefaultReports::ScenarioReport_ - ScenarioReport which will be used in creating and then updated by a \REopt Lite opimization response.
144
156
  # * +reopt_assumptions_hash+ - _Hash_ - Optional. A \REopt Lite formatted hash containing default parameters (i.e. utility rate, escalation rate) which will be updated by the ScenarioReport (i.e. location, roof availability)
145
157
  # * +reopt_output_file+ - _String_ - Optional. Path to a file at which REpopt Lite responses will be saved.
146
158
  # * +timeseries_csv_path+ - _String_ - Optional. Path to a file at which the new timeseries CSV for the ScenarioReport will be saved.
147
159
  #
148
160
  # [*return:*] _URBANopt::Scenario::DefaultReports::ScenarioReport_ Returns an updated ScenarioReport
149
- def run_scenario_report(scenario_report:, reopt_assumptions_hash:nil, reopt_output_file:nil, timeseries_csv_path:nil, save_name:nil)
161
+ def run_scenario_report(scenario_report:, reopt_assumptions_hash:nil, reopt_output_file:nil, timeseries_csv_path:nil, save_name:nil, run_resilience:true)
150
162
  if !reopt_assumptions_hash.nil?
151
163
  @scenario_reopt_default_assumptions_hash = reopt_assumptions_hash
152
164
  end
@@ -163,8 +175,18 @@ module URBANopt # :nodoc:
163
175
  reopt_input = adapter.reopt_json_from_scenario_report(scenario_report, @scenario_reopt_default_assumptions_hash)
164
176
 
165
177
  reopt_output = api.reopt_request(reopt_input, @scenario_reopt_default_output_file)
178
+ if run_resilience
179
+ run_uuid = reopt_output['outputs']['Scenario']['run_uuid']
180
+ if File.directory? @scenario_reopt_default_output_file
181
+ resilience_stats = api.resilience_request(run_uuid, @scenario_reopt_default_output_file)
182
+ else
183
+ resilience_stats = api.resilience_request(run_uuid, @scenario_reopt_default_output_file.sub!('.json','_resilience.json'))
184
+ end
185
+ else
186
+ resilience_stats = nil
187
+ end
166
188
 
167
- result = adapter.update_scenario_report(scenario_report, reopt_output, @scenario_timeseries_default_output_file)
189
+ result = adapter.update_scenario_report(scenario_report, reopt_output, @scenario_timeseries_default_output_file, resilience_stats)
168
190
  if !save_name.nil?
169
191
  result.save save_name
170
192
  end
@@ -176,13 +198,13 @@ module URBANopt # :nodoc:
176
198
  #
177
199
  # [*parameters:*]
178
200
  #
179
- # * +feature_reports+ - _Array_ - An array of _URBANopt::Scenario::DefaultReports::FeatureReport_ objetcs which will each be used to create (and are subsquently updated by) a \REopt Lite opimization response.
201
+ # * +feature_reports+ - _Array_ - An array of _URBANopt::Reporting::DefaultReports::FeatureReport_ objetcs which will each be used to create (and are subsquently updated by) a \REopt Lite opimization response.
180
202
  # * +reopt_assumptions_hashes+ - _Array_ - Optional. An array of \REopt Lite formatted hashes containing default parameters (i.e. utility rate, escalation rate) which will be updated by the ScenarioReport (i.e. location, roof availability). The number and order of the hashes should match the feature_reports array.
181
203
  # * +reopt_output_files+ - _Array_ - Optional. A array of paths to files at which REpopt Lite responses will be saved. The number and order of the paths should match the feature_reports array.
182
204
  # * +timeseries_csv_path+ - _Array_ - Optional. A array of paths to files at which the new timeseries CSV for the FeatureReports will be saved. The number and order of the paths should match the feature_reports array.
183
205
  #
184
206
  # [*return:*] _Array_ Returns an array of updated _URBANopt::Scenario::DefaultReports::FeatureReport_ objects
185
- def run_feature_reports(feature_reports:, reopt_assumptions_hashes:[], reopt_output_files:[], timeseries_csv_paths:[], save_names:nil)
207
+ def run_feature_reports(feature_reports:, reopt_assumptions_hashes:[], reopt_output_files:[], timeseries_csv_paths:[], save_names:nil, run_resilience:true)
186
208
 
187
209
  if !reopt_assumptions_hashes.empty?
188
210
  @feature_reports_reopt_default_assumption_hashes = reopt_assumptions_hashes
@@ -215,7 +237,17 @@ module URBANopt # :nodoc:
215
237
  begin
216
238
  reopt_input = feature_adapter.reopt_json_from_feature_report(feature_report, @feature_reports_reopt_default_assumption_hashes[idx])
217
239
  reopt_output = api.reopt_request(reopt_input, @feature_reports_reopt_default_output_files[idx])
218
- new_feature_report = feature_adapter.update_feature_report(feature_report, reopt_output, @feature_reports_timeseries_default_output_files[idx])
240
+ if run_resilience
241
+ run_uuid = reopt_output['outputs']['Scenario']['run_uuid']
242
+ if File.directory? @feature_reports_reopt_default_output_files[idx]
243
+ resilience_stats = api.resilience_request(run_uuid, @feature_reports_reopt_default_output_files[idx])
244
+ else
245
+ resilience_stats = api.resilience_request(run_uuid, @feature_reports_reopt_default_output_files[idx].sub!('.json','_resilience.json'))
246
+ end
247
+ else
248
+ resilience_stats = nil
249
+ end
250
+ new_feature_report = feature_adapter.update_feature_report(feature_report, reopt_output, @feature_reports_timeseries_default_output_files[idx], resilience_stats)
219
251
  new_feature_reports.push(new_feature_report)
220
252
  if !save_names.nil?
221
253
  if save_names.length == feature_reports.length
@@ -228,7 +260,7 @@ module URBANopt # :nodoc:
228
260
  @@logger.info("Could not optimize Feature Report #{feature_report.name} #{feature_report.id}")
229
261
  end
230
262
  end
231
-
263
+
232
264
  return new_feature_reports
233
265
  end
234
266
 
@@ -237,22 +269,22 @@ module URBANopt # :nodoc:
237
269
  #
238
270
  # [*parameters:*]
239
271
  #
240
- # * +scenario_report+ - _Array_ - A _URBANopt::Scenario::DefaultReports::ScenarioReport_ which will each be used to create (and is subsquently updated by) \REopt Lite opimization responses for each of its FeatureReports.
272
+ # * +scenario_report+ - _Array_ - A _URBANopt::Reporting::DefaultReports::ScenarioReport_ which will each be used to create (and is subsquently updated by) \REopt Lite opimization responses for each of its FeatureReports.
241
273
  # * +reopt_assumptions_hashes+ - _Array_ - Optional. An array of \REopt Lite formatted hashes containing default parameters (i.e. utility rate, escalation rate) which will be updated by the ScenarioReport (i.e. location, roof availability). The number and order of the hashes should match the array in ScenarioReport.feature_reports.
242
274
  # * +reopt_output_files+ - _Array_ - Optional. An array of paths to files at which REpopt Lite responses will be saved. The number and order of the paths should match the array in ScenarioReport.feature_reports.
243
275
  # * +feature_report_timeseries_csv_paths+ - _Array_ - Optional. An array of paths to files at which the new timeseries CSV for the FeatureReports will be saved. The number and order of the paths should match the array in ScenarioReport.feature_reports.
244
276
  #
245
277
  # [*return:*] _URBANopt::Scenario::DefaultReports::ScenarioReport_ - Returns an updated ScenarioReport
246
- def run_scenario_report_features(scenario_report:, reopt_assumptions_hashes:[], reopt_output_files:[], feature_report_timeseries_csv_paths:[], save_names_feature_reports:nil, save_name_scenario_report:nil)
247
- new_feature_reports = run_feature_reports(feature_reports:scenario_report.feature_reports, reopt_assumptions_hashes:reopt_assumptions_hashes, reopt_output_files:reopt_output_files, timeseries_csv_paths:feature_report_timeseries_csv_paths,save_names:save_names_feature_reports)
278
+ def run_scenario_report_features(scenario_report:, reopt_assumptions_hashes:[], reopt_output_files:[], feature_report_timeseries_csv_paths:[], save_names_feature_reports:nil, save_name_scenario_report:nil, run_resilience:true)
279
+ new_feature_reports = run_feature_reports(feature_reports:scenario_report.feature_reports, reopt_assumptions_hashes:reopt_assumptions_hashes, reopt_output_files:reopt_output_files, timeseries_csv_paths:feature_report_timeseries_csv_paths,save_names:save_names_feature_reports, run_resilience:run_resilience)
248
280
 
249
- new_scenario_report = URBANopt::Scenario::DefaultReports::ScenarioReport.new
281
+ new_scenario_report = URBANopt::Reporting::DefaultReports::ScenarioReport.new
250
282
  new_scenario_report.id = scenario_report.id
251
283
  new_scenario_report.name = scenario_report.name
252
284
  new_scenario_report.directory_name = scenario_report.directory_name
253
285
 
254
286
  timeseries_hash = { column_names: scenario_report.timeseries_csv.column_names }
255
- new_scenario_report.timeseries_csv = URBANopt::Scenario::DefaultReports::TimeseriesCSV.new(timeseries_hash)
287
+ new_scenario_report.timeseries_csv = URBANopt::Reporting::DefaultReports::TimeseriesCSV.new(timeseries_hash)
256
288
 
257
289
  new_feature_reports.each do |feature_report|
258
290
  new_scenario_report.add_feature_report(feature_report)
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
3
3
  # contributors. All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without modification,
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
3
3
  # contributors. All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without modification,
@@ -28,7 +28,7 @@
28
28
  # OF THE POSSIBILITY OF SUCH DAMAGE.
29
29
  # *********************************************************************************
30
30
 
31
- require 'urbanopt/scenario/default_reports'
31
+ require 'urbanopt/reporting/default_reports'
32
32
  require 'urbanopt/reopt/reopt_logger'
33
33
  require 'matrix'
34
34
  require 'csv'
@@ -51,7 +51,7 @@ module URBANopt # :nodoc:
51
51
  #
52
52
  # [*parameters:*]
53
53
  #
54
- # * +scenario_report+ - _URBANopt::Scenario::DefaultReports::ScenarioReport_ - ScenarioReport to use in converting the +reopt_assumptions_hash+, if provided, to a \REopt Lite post. Otherwise, if the +reopt_assumptions_hash+ is nil a default post will be updated from this ScenarioReport and submitted to the \REopt Lite API.
54
+ # * +scenario_report+ - _URBANopt::Reporting::DefaultReports::ScenarioReport_ - ScenarioReport to use in converting the +reopt_assumptions_hash+, if provided, to a \REopt Lite post. Otherwise, if the +reopt_assumptions_hash+ is nil a default post will be updated from this ScenarioReport and submitted to the \REopt Lite API.
55
55
  # * +reopt_assumptions_hash+ - _Hash_ - Optional. A hash formatted for submittal to the \REopt Lite API containing default values. Values will be overwritten from the ScenarioReport where available (i.e. latitude, roof_squarefeet). Missing optional parameters will be filled in with default values by the API.
56
56
  #
57
57
  # [*return:*] _Hash_ - Returns hash formatted for submittal to the \REopt Lite API
@@ -126,10 +126,10 @@ module URBANopt # :nodoc:
126
126
  energy_timeseries_kw = t.by_col[col_num].map { |e| ((e * scenario_report.timesteps_per_hour || 0) ) }
127
127
  if energy_timeseries_kw.length < (scenario_report.timesteps_per_hour * 8760)
128
128
  start_date = Time.parse(t.by_col["Datetime"][0])
129
- start_ts = (((start_date.yday * 60.0 * 60.0 * 24) + (start_date.hour * 60.0 * 60.0) + (start_date.min * 60.0) + start_date.sec) /
129
+ start_ts = (((start_date.yday * 60.0 * 60.0 * 24) + (start_date.hour * 60.0 * 60.0) + (start_date.min * 60.0) + start_date.sec) / \
130
130
  (( 60 / scenario_report.timesteps_per_hour ) * 60)).to_int
131
131
  end_date = Time.parse(t.by_col["Datetime"][-1])
132
- end_ts = (((end_date.yday * 60.0 * 60.0 * 24) + (end_date.hour * 60.0 * 60.0) + (end_date.min * 60.0) + end_date.sec) /
132
+ end_ts = (((end_date.yday * 60.0 * 60.0 * 24) + (end_date.hour * 60.0 * 60.0) + (end_date.min * 60.0) + end_date.sec) / \
133
133
  (( 60 / scenario_report.timesteps_per_hour ) * 60)).to_int
134
134
  energy_timeseries_kw = [0.0]*(start_ts-1) + energy_timeseries_kw + [0.0]*((scenario_report.timesteps_per_hour * 8760) - end_ts)
135
135
  end
@@ -146,7 +146,7 @@ module URBANopt # :nodoc:
146
146
  #
147
147
  # [*parameters:*]
148
148
  #
149
- # * +scenario_report+ - _URBANopt::Scenario::DefaultReports::ScenarioReport_ - ScenarioReport to use in converting FeatureReports and respecitive +reopt_assumptions_hashes+, if provided, to a \REopt Lite post. If no +reopt_assumptions_hashes+ are provided default posts will be updated from these FeatureReports and submitted to the \REopt Lite API.
149
+ # * +scenario_report+ - _URBANopt::Reporting::DefaultReports::ScenarioReport_ - ScenarioReport to use in converting FeatureReports and respecitive +reopt_assumptions_hashes+, if provided, to a \REopt Lite post. If no +reopt_assumptions_hashes+ are provided default posts will be updated from these FeatureReports and submitted to the \REopt Lite API.
150
150
  # * +reopt_assumptions_hashes+ - _Array_ - Optional. An array of hashes formatted for submittal to the \REopt Lite API containing default values. Values will be overwritten from the ScenarioReport where available (i.e. latitude, roof_squarefeet). Missing optional parameters will be filled in with default values by the API. The order should match the list in ScenarioReport.feature_reports.
151
151
  #
152
152
  # [*return:*] _Array_ - Returns an array of hashes formatted for submittal to the \REopt Lite API in the order of the FeatureReports lited in ScenarioReport.feature_reports.
@@ -168,18 +168,18 @@ module URBANopt # :nodoc:
168
168
  #
169
169
  # [*parameters:*]
170
170
  #
171
- # * +scenario_report+ - _URBANopt::Scenario::DefaultReports::ScenarioReport_ - ScenarioReport to update from a \REopt Lite response.
171
+ # * +scenario_report+ - _URBANopt::Reporting::DefaultReports::ScenarioReport_ - ScenarioReport to update from a \REopt Lite response.
172
172
  # * +reopt_output+ - _Hash_ - A hash response from the \REopt Lite API.
173
173
  # * +timeseries_csv_path+ - _String_ - Optional. The path to a file at which new timeseries data will be written. If not provided a file is created based on the run_uuid of the \REopt Lite optimization task.
174
174
  #
175
- # [*return:*] _URBANopt::Scenario::DefaultReports::ScenarioReport_ - Returns an updated ScenarioReport
175
+ # [*return:*] _URBANopt::Reporting::DefaultReports::ScenarioReport_ - Returns an updated ScenarioReport
176
176
  ##
177
- def update_scenario_report(scenario_report, reopt_output, timeseries_csv_path = nil)
177
+ def update_scenario_report(scenario_report, reopt_output, timeseries_csv_path=nil, resilience_stats=nil)
178
178
  if reopt_output['outputs']['Scenario']['status'] != 'optimal'
179
179
  @@logger.info("Warning cannot Feature Report #{scenario_report.name} #{scenario_report.id} - REopt optimization was non-optimal")
180
180
  return scenario_report
181
181
  end
182
-
182
+
183
183
  $ts_per_hour = scenario_report.timesteps_per_hour
184
184
  def scale_timeseries(input, ts_per_hr=$ts_per_hour)
185
185
  if input.nil?
@@ -192,7 +192,7 @@ module URBANopt # :nodoc:
192
192
  return input
193
193
  end
194
194
  result = []
195
- input.each do |val|
195
+ input.each do |val|
196
196
  (1..ts_per_hr).each do |x|
197
197
  result.push(val/ts_per_hr.to_f)
198
198
  end
@@ -215,36 +215,50 @@ module URBANopt # :nodoc:
215
215
  scenario_report.distributed_generation.year_one_demand_cost_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['year_one_demand_cost_us_dollars'] || 0
216
216
  scenario_report.distributed_generation.year_one_bill_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['year_one_bill_us_dollars'] || 0
217
217
  scenario_report.distributed_generation.total_energy_cost_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['total_energy_cost_us_dollars'] || 0
218
-
218
+ scenario_report.distributed_generation.total_demand_cost_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['total_demand_cost_us_dollars'] || 0
219
+ scenario_report.distributed_generation.year_one_energy_cost_bau_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['year_one_energy_cost_bau_us_dollars'] || 0
220
+ scenario_report.distributed_generation.year_one_demand_cost_bau_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['year_one_demand_cost_bau_us_dollars'] || 0
221
+ scenario_report.distributed_generation.year_one_bill_bau_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['year_one_bill_bau_us_dollars'] || 0
222
+ scenario_report.distributed_generation.total_demand_cost_bau_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['total_demand_cost_bau_us_dollars'] || 0
223
+ scenario_report.distributed_generation.total_energy_cost_bau_us_dollars = reopt_output['outputs']['Scenario']['Site']['ElectricTariff']['total_energy_cost_bau_us_dollars'] || 0
224
+ if !resilience_stats.nil?
225
+ scenario_report.distributed_generation.resilience_hours_min = resilience_stats['resilience_hours_min']
226
+ scenario_report.distributed_generation.resilience_hours_max = resilience_stats['resilience_hours_max']
227
+ scenario_report.distributed_generation.resilience_hours_avg = resilience_stats['resilience_hours_avg']
228
+ scenario_report.distributed_generation.probs_of_surviving = resilience_stats['probs_of_surviving']
229
+ scenario_report.distributed_generation.probs_of_surviving_by_month = resilience_stats['probs_of_surviving_by_month']
230
+ scenario_report.distributed_generation.probs_of_surviving_by_hour_of_the_day = resilience_stats['probs_of_surviving_by_hour_of_the_day']
231
+ end
232
+
219
233
  if reopt_output['outputs']['Scenario']['Site']['PV'].class == Hash
220
234
  reopt_output['outputs']['Scenario']['Site']['PV'] = [reopt_output['outputs']['Scenario']['Site']['PV']]
221
235
  elsif reopt_output['outputs']['Scenario']['Site']['PV'].nil?
222
236
  reopt_output['outputs']['Scenario']['Site']['PV'] = []
223
237
  end
224
-
225
- reopt_output['outputs']['Scenario']['Site']['PV'].each_with_index do |pv, i|
226
- scenario_report.distributed_generation.add_tech 'solar_pv', URBANopt::Scenario::DefaultReports::SolarPV.new( {size_kw: (pv['size_kw'] || 0), id: i })
238
+
239
+ reopt_output['outputs']['Scenario']['Site']['PV'].each_with_index do |pv, i|
240
+ scenario_report.distributed_generation.add_tech 'solar_pv', URBANopt::Reporting::DefaultReports::SolarPV.new( {size_kw: (pv['size_kw'] || 0), id: i })
227
241
  end
228
242
 
229
243
  wind = reopt_output['outputs']['Scenario']['Site']['Wind']
230
244
  if !wind['size_kw'].nil? and wind['size_kw'] != 0
231
- scenario_report.distributed_generation.add_tech 'wind', URBANopt::Scenario::DefaultReports::Wind.new( {size_kw: (wind['size_kw'] || 0) })
245
+ scenario_report.distributed_generation.add_tech 'wind', URBANopt::Reporting::DefaultReports::Wind.new( {size_kw: (wind['size_kw'] || 0) })
232
246
  end
233
247
 
234
248
  generator = reopt_output['outputs']['Scenario']['Site']['Generator']
235
249
  if !generator['size_kw'].nil? and generator['size_kw'] != 0
236
- scenario_report.distributed_generation.add_tech 'generator', URBANopt::Scenario::DefaultReports::Generator.new( {size_kw: (generator['size_kw'] || 0) })
250
+ scenario_report.distributed_generation.add_tech 'generator', URBANopt::Reporting::DefaultReports::Generator.new( {size_kw: (generator['size_kw'] || 0) })
237
251
  end
238
252
 
239
253
  storage = reopt_output['outputs']['Scenario']['Site']['Storage']
240
254
  if !storage['size_kw'].nil? and storage['size_kw'] != 0
241
- scenario_report.distributed_generation.add_tech 'storage', URBANopt::Scenario::DefaultReports::Storage.new( {size_kwh: (storage['size_kwh'] || 0), size_kw: (storage['size_kw'] || 0) })
255
+ scenario_report.distributed_generation.add_tech 'storage', URBANopt::Reporting::DefaultReports::Storage.new( {size_kwh: (storage['size_kwh'] || 0), size_kw: (storage['size_kw'] || 0) })
242
256
  end
243
-
257
+
244
258
  generation_timeseries_kwh = Matrix[[0] * (8760 * scenario_report.timesteps_per_hour)]
245
259
 
246
-
247
- reopt_output['outputs']['Scenario']['Site']['PV'].each do |pv|
260
+
261
+ reopt_output['outputs']['Scenario']['Site']['PV'].each do |pv|
248
262
  if (pv['size_kw'] || 0) > 0
249
263
  if !pv['year_one_power_production_series_kw'].nil?
250
264
  generation_timeseries_kwh += Matrix[pv['year_one_power_production_series_kw']]
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
3
3
  # contributors. All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without modification,
@@ -30,6 +30,6 @@
30
30
 
31
31
  module URBANopt # :nodoc:
32
32
  module REopt # :nodoc:
33
- VERSION = '0.3.0'.freeze
33
+ VERSION = '0.4.0'.freeze
34
34
  end
35
35
  end
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
3
3
  # contributors. All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without modification,
@@ -8,8 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.version = URBANopt::REopt::VERSION
9
9
  spec.authors = ['']
10
10
  spec.email = ['']
11
+ spec.licenses = 'Nonstandard'
11
12
 
12
- spec.summary = 'Classes and measures for utilizing the REopt Lite API within OpenStudio workflows.'
13
+ spec.summary = 'Accessing the REopt Lite API within OpenStudio workflows.'
13
14
  spec.description = 'Classes and measures for utilizing the REopt Lite API within OpenStudio workflows.'
14
15
  spec.homepage = 'https://github.com/urbanopt/urbanopt-reopt-gem'
15
16
 
@@ -22,14 +23,14 @@ Gem::Specification.new do |spec|
22
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
24
  spec.require_paths = ['lib']
24
25
 
26
+ spec.required_ruby_version = '~> 2.5.0'
27
+
25
28
  spec.add_development_dependency 'bundler', '~> 2.1'
26
29
  spec.add_development_dependency 'rake', '~> 13.0'
27
30
  spec.add_development_dependency 'rspec', '~> 3.7'
28
-
29
31
  spec.add_development_dependency 'rubocop', '~> 0.54.0'
30
32
 
31
- spec.add_dependency 'certified'
32
- spec.add_dependency 'json_pure'
33
- spec.add_dependency 'urbanopt-scenario', '~> 0.3.0'
34
-
33
+ spec.add_dependency 'certified', '~> 1'
34
+ spec.add_dependency 'json_pure', '~> 2'
35
+ spec.add_dependency 'urbanopt-scenario', '~> 0.4.0'
35
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urbanopt-reopt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-05 00:00:00.000000000 Z
11
+ date: 2020-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,44 +70,44 @@ dependencies:
70
70
  name: certified
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '1'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: json_pure
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '2'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '2'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: urbanopt-scenario
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.3.0
103
+ version: 0.4.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.3.0
110
+ version: 0.4.0
111
111
  description: Classes and measures for utilizing the REopt Lite API within OpenStudio
112
112
  workflows.
113
113
  email:
@@ -133,6 +133,7 @@ files:
133
133
  - RDOC_MAIN.md
134
134
  - README.md
135
135
  - Rakefile
136
+ - a.txt
136
137
  - deploy_docs.sh
137
138
  - developer_nrel_key.rb
138
139
  - doc_templates/LICENSE.md
@@ -173,7 +174,8 @@ files:
173
174
  - lib/urbanopt/reopt_scenario.rb
174
175
  - urbanopt-reopt.gemspec
175
176
  homepage: https://github.com/urbanopt/urbanopt-reopt-gem
176
- licenses: []
177
+ licenses:
178
+ - Nonstandard
177
179
  metadata: {}
178
180
  post_install_message:
179
181
  rdoc_options: []
@@ -181,17 +183,17 @@ require_paths:
181
183
  - lib
182
184
  required_ruby_version: !ruby/object:Gem::Requirement
183
185
  requirements:
184
- - - ">="
186
+ - - "~>"
185
187
  - !ruby/object:Gem::Version
186
- version: '0'
188
+ version: 2.5.0
187
189
  required_rubygems_version: !ruby/object:Gem::Requirement
188
190
  requirements:
189
191
  - - ">="
190
192
  - !ruby/object:Gem::Version
191
193
  version: '0'
192
194
  requirements: []
193
- rubygems_version: 3.1.2
195
+ rubygems_version: 3.1.4
194
196
  signing_key:
195
197
  specification_version: 4
196
- summary: Classes and measures for utilizing the REopt Lite API within OpenStudio workflows.
198
+ summary: Accessing the REopt Lite API within OpenStudio workflows.
197
199
  test_files: []