urbanopt-reopt 0.8.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,31 +1,6 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  require 'urbanopt/reporting/default_reports'
@@ -1,37 +1,11 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  require 'net/https'
32
7
  require 'openssl'
33
8
  require 'uri'
34
- require 'uri'
35
9
  require 'json'
36
10
  require 'securerandom'
37
11
  require 'certified'
@@ -55,8 +29,8 @@ module URBANopt # :nodoc:
55
29
  def initialize(nrel_developer_key = nil, use_localhost = false)
56
30
  @use_localhost = use_localhost
57
31
  if @use_localhost
58
- @uri_submit = URI.parse('http//:127.0.0.1:8000/v1/job/')
59
- @uri_submit_outagesimjob = URI.parse('http//:127.0.0.1:8000/v1/outagesimjob/')
32
+ @uri_submit = URI.parse('http//:127.0.0.1:8000/v2/job/')
33
+ @uri_submit_outagesimjob = URI.parse('http//:127.0.0.1:8000/v2/outagesimjob/')
60
34
  else
61
35
  if [nil, '', '<insert your key here>'].include? nrel_developer_key
62
36
  if [nil, '', '<insert your key here>'].include? DEVELOPER_NREL_KEY
@@ -66,8 +40,8 @@ module URBANopt # :nodoc:
66
40
  end
67
41
  end
68
42
  @nrel_developer_key = nrel_developer_key
69
- @uri_submit = URI.parse("https://developer.nrel.gov/api/reopt/v1/job/?api_key=#{@nrel_developer_key}")
70
- @uri_submit_outagesimjob = URI.parse("https://developer.nrel.gov/api/reopt/v1/outagesimjob/?api_key=#{@nrel_developer_key}")
43
+ @uri_submit = URI.parse("https://developer.nrel.gov/api/reopt/v2/job?api_key=#{@nrel_developer_key}")
44
+ @uri_submit_outagesimjob = URI.parse("https://developer.nrel.gov/api/reopt/v2/outagesimjob?api_key=#{@nrel_developer_key}")
71
45
  # initialize @@logger
72
46
  @@logger ||= URBANopt::REopt.reopt_logger
73
47
  end
@@ -85,10 +59,10 @@ module URBANopt # :nodoc:
85
59
  ##
86
60
  def uri_results(run_uuid) # :nodoc:
87
61
  if @use_localhost
88
- return URI.parse("http://127.0.0.1:8000/v1/job/#{run_uuid}/results")
62
+ return URI.parse("http://127.0.0.1:8000/v2/job/#{run_uuid}/results")
89
63
  end
90
64
 
91
- return URI.parse("https://developer.nrel.gov/api/reopt/v1/job/#{run_uuid}/results?api_key=#{@nrel_developer_key}")
65
+ return URI.parse("https://developer.nrel.gov/api/reopt/v2/job/#{run_uuid}/results?api_key=#{@nrel_developer_key}")
92
66
  end
93
67
 
94
68
  ##
@@ -103,26 +77,31 @@ module URBANopt # :nodoc:
103
77
  ##
104
78
  def uri_resilience(run_uuid) # :nodoc:
105
79
  if @use_localhost
106
- return URI.parse("http://127.0.0.1:8000/v1/job/#{run_uuid}/resilience_stats")
80
+ return URI.parse("http://127.0.0.1:8000/v2/job/#{run_uuid}/resilience_stats")
107
81
  end
108
82
 
109
- return URI.parse("https://developer.nrel.gov/api/reopt/v1/job/#{run_uuid}/resilience_stats?api_key=#{@nrel_developer_key}")
83
+ return URI.parse("https://developer.nrel.gov/api/reopt/v2/job/#{run_uuid}/resilience_stats?api_key=#{@nrel_developer_key}")
110
84
  end
111
85
 
112
- def make_request(http, r, max_tries = 3)
86
+ def make_request(http, req, max_tries = 3)
113
87
  result = nil
114
88
  tries = 0
115
89
  while tries < max_tries
116
90
  begin
117
- result = http.request(r)
91
+ result = http.request(req)
118
92
  # Result codes sourced from https://developer.nrel.gov/docs/errors/
119
93
  if result.code == '429'
120
94
  @@logger.fatal('Exceeded the REopt-Lite API limit of 300 requests per hour')
121
95
  puts 'Using the URBANopt CLI to submit a Scenario optimization counts as one request per scenario'
122
96
  puts 'Using the URBANopt CLI to submit a Feature optimization counts as one request per feature'
123
97
  abort('Please wait and try again once the time period has elapsed. The URBANopt CLI flag --reopt-keep-existing can be used to resume the optimization')
98
+ elsif result.code == '404'
99
+ @@logger.info("REOpt is still calculating. We'll give it a moment and check again")
100
+ sleep 15
101
+ tries += 1
102
+ next
124
103
  elsif (result.code != '201') && (result.code != '200') # Anything in the 200s is success
125
- @@logger.debug("REopt-Lite has returned a '#{result.code}' status code. Visit https://developer.nrel.gov/docs/errors/ for more status code information")
104
+ @@logger.warn("REopt-Lite has returned a '#{result.code}' status code. Visit https://developer.nrel.gov/docs/errors/ for more status code information")
126
105
  # display error messages
127
106
  json_res = JSON.parse(result.body, allow_nan: true)
128
107
  json_res['messages'].delete('warnings') if json_res['messages']['warnings']
@@ -341,10 +320,10 @@ module URBANopt # :nodoc:
341
320
  sleep 5
342
321
  end
343
322
 
344
- _max_retry = 5
345
- _tries = 0
323
+ max_retry = 5
324
+ tries = 0
346
325
  (check_complete = sizes == 0) && ((data['outputs']['Scenario']['Site']['Financial']['npv_us_dollars'] || 0) > 0)
347
- while (_tries < _max_retry) && check_complete
326
+ while (tries < max_retry) && check_complete
348
327
  sleep 3
349
328
  response = make_request(http, get_request)
350
329
  data = JSON.parse(response.body, allow_nan: true)
@@ -358,7 +337,7 @@ module URBANopt # :nodoc:
358
337
  end
359
338
  sizes = pv_sizes + (data['outputs']['Scenario']['Site']['Storage']['size_kw'] || 0) + (data['outputs']['Scenario']['Site']['Wind']['size_kw'] || 0) + (data['outputs']['Scenario']['Site']['Generator']['size_kw'] || 0)
360
339
  (check_complete = sizes == 0) && ((data['outputs']['Scenario']['Site']['Financial']['npv_us_dollars'] || 0) > 0)
361
- _tries += 1
340
+ tries += 1
362
341
  end
363
342
 
364
343
  data = JSON.parse(response.body, allow_nan: true)
@@ -1,31 +1,6 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  require 'logger'
@@ -33,6 +8,9 @@ require 'logger'
33
8
  module URBANopt
34
9
  module REopt
35
10
  @@reopt_logger = Logger.new($stdout)
11
+
12
+ # Set Logger::DEBUG for development
13
+ @@reopt_logger.level = Logger::WARN
36
14
  ##
37
15
  # Definining class variable "@@logger" to log errors, info and warning messages.
38
16
  def self.reopt_logger
@@ -1,31 +1,6 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  require 'bundler/setup'
@@ -83,9 +58,6 @@ module URBANopt # :nodoc:
83
58
  @@logger.info("Created directory: #{File.join(fr.directory_name, 'reopt')}")
84
59
  end
85
60
  @feature_reports_reopt_default_output_files << File.join(fr.directory_name, "reopt/feature_report_#{fr.id}_reopt_run.json")
86
- end
87
-
88
- @scenario_report.feature_reports.each do |fr|
89
61
  @feature_reports_timeseries_default_output_files << File.join(fr.directory_name, "feature_report_#{fr.id}_timeseries.csv")
90
62
  end
91
63
  end
@@ -129,13 +101,13 @@ module URBANopt # :nodoc:
129
101
  reopt_output_file = File.join(feature_report.directory_name, 'reopt')
130
102
  end
131
103
  reopt_output = api.reopt_request(reopt_input, reopt_output_file)
132
- print("REOPT OUTPUT FILE: #{reopt_output_file}")
104
+ @@logger.debug("REOpt output file: #{reopt_output_file}")
133
105
  if run_resilience
134
106
  run_uuid = reopt_output['outputs']['Scenario']['run_uuid']
135
107
  if File.directory? reopt_output_file
136
108
  resilience_stats = api.resilience_request(run_uuid, reopt_output_file)
137
109
  else
138
- resilience_stats = api.resilience_request(run_uuid, reopt_output_file.sub!('.json', '_resilience.json'))
110
+ resilience_stats = api.resilience_request(run_uuid, reopt_output_file.sub('.json', '_resilience.json'))
139
111
  end
140
112
  else
141
113
  resilience_stats = nil
@@ -160,7 +132,7 @@ module URBANopt # :nodoc:
160
132
  #
161
133
  # [*return:*] _URBANopt::Scenario::DefaultReports::ScenarioReport_ Returns an updated ScenarioReport
162
134
  def run_scenario_report(scenario_report:, reopt_assumptions_hash: nil, reopt_output_file: nil, timeseries_csv_path: nil, save_name: nil, run_resilience: true, community_photovoltaic: nil)
163
- puts "run scenario report"
135
+ puts 'run scenario report'
164
136
  @save_assumptions_filepath = false
165
137
  if !reopt_assumptions_hash.nil?
166
138
  @scenario_reopt_default_assumptions_hash = reopt_assumptions_hash
@@ -185,7 +157,7 @@ module URBANopt # :nodoc:
185
157
  if File.directory? @scenario_reopt_default_output_file
186
158
  resilience_stats = api.resilience_request(run_uuid, @scenario_reopt_default_output_file)
187
159
  else
188
- resilience_stats = api.resilience_request(run_uuid, @scenario_reopt_default_output_file.sub!('.json', '_resilience.json'))
160
+ resilience_stats = api.resilience_request(run_uuid, @scenario_reopt_default_output_file.sub('.json', '_resilience.json'))
189
161
  end
190
162
  else
191
163
  resilience_stats = nil
@@ -254,7 +226,7 @@ module URBANopt # :nodoc:
254
226
  if File.directory? @feature_reports_reopt_default_output_files[idx]
255
227
  resilience_stats = api.resilience_request(run_uuid, @feature_reports_reopt_default_output_files[idx])
256
228
  else
257
- resilience_stats = api.resilience_request(run_uuid, @feature_reports_reopt_default_output_files[idx].sub!('.json', '_resilience.json'))
229
+ resilience_stats = api.resilience_request(run_uuid, @feature_reports_reopt_default_output_files[idx].sub('.json', '_resilience.json'))
258
230
  end
259
231
  else
260
232
  resilience_stats = nil
@@ -577,7 +577,6 @@
577
577
  }
578
578
  }
579
579
  },
580
-
581
580
  "Storage": {
582
581
  "type": "object",
583
582
  "properties": {
@@ -1113,4 +1112,4 @@
1113
1112
  }
1114
1113
  }
1115
1114
  }
1116
- }
1115
+ }
@@ -1,31 +1,6 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  require 'urbanopt/scenario/scenario_base'
@@ -1,31 +1,6 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  require 'urbanopt/reporting/default_reports'
@@ -75,7 +50,7 @@ module URBANopt # :nodoc:
75
50
  lats = []
76
51
  longs = []
77
52
  scenario_report.feature_reports.each do |x|
78
- @@logger.info(" ERROR: #{x.location.latitude_deg}")
53
+ @@logger.debug("Latitude '#{x.location.latitude_deg}' in feature report but not in scenario report. Adding it now.")
79
54
  if ![nil].include?(x.location.latitude_deg) && ![nil].include?(x.location.longitude_deg)
80
55
  lats.push(x.location.latitude_deg)
81
56
  longs.push(x.location.longitude_deg)
@@ -190,6 +165,29 @@ module URBANopt # :nodoc:
190
165
  return results
191
166
  end
192
167
 
168
+ def modrow(data, idx) # :nodoc:
169
+ data[$generation_timeseries_kwh_col] = $generation_timeseries_kwh[idx] || 0
170
+ data[$load_col] = $load[idx] || 0
171
+ data[$utility_to_load_col] = $utility_to_load[idx] || 0
172
+ data[$utility_to_battery_col] = $utility_to_battery[idx] || 0
173
+ data[$storage_to_load_col] = $storage_to_load[idx] || 0
174
+ data[$storage_to_grid_col] = $storage_to_grid[idx] || 0
175
+ data[$storage_soc_col] = $storage_soc[idx] || 0
176
+ data[$generator_total_col] = $generator_total[idx] || 0
177
+ data[$generator_to_battery_col] = $generator_to_battery[idx] || 0
178
+ data[$generator_to_load_col] = $generator_to_load[idx] || 0
179
+ data[$generator_to_grid_col] = $generator_to_grid[idx] || 0
180
+ data[$pv_total_col] = $pv_total[idx] || 0
181
+ data[$pv_to_battery_col] = $pv_to_battery[idx] || 0
182
+ data[$pv_to_load_col] = $pv_to_load[idx] || 0
183
+ data[$pv_to_grid_col] = $pv_to_grid[idx] || 0
184
+ data[$wind_total_col] = $wind_total[idx] || 0
185
+ data[$wind_to_battery_col] = $wind_to_battery[idx] || 0
186
+ data[$wind_to_load_col] = $wind_to_load[idx] || 0
187
+ data[$wind_to_grid_col] = $wind_to_grid[idx] || 0
188
+ return data
189
+ end
190
+
193
191
  ##
194
192
  # Updates a ScenarioReport from a \REopt Lite response
195
193
  #
@@ -282,9 +280,6 @@ module URBANopt # :nodoc:
282
280
  module_type[pv['pv_name']] = pv_inputs[i]['module_type']
283
281
  end
284
282
  end
285
- end
286
-
287
- pv_outputs.each_with_index do |pv, i|
288
283
  scenario_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']] })
289
284
  end
290
285
 
@@ -475,36 +470,13 @@ module URBANopt # :nodoc:
475
470
  scenario_report.timeseries_csv.column_names.push('REopt:ElectricityProduced:Wind:ToGrid(kw)')
476
471
  end
477
472
 
478
- def modrow(x, i) # :nodoc:
479
- x[$generation_timeseries_kwh_col] = $generation_timeseries_kwh[i] || 0
480
- x[$load_col] = $load[i] || 0
481
- x[$utility_to_load_col] = $utility_to_load[i] || 0
482
- x[$utility_to_battery_col] = $utility_to_battery[i] || 0
483
- x[$storage_to_load_col] = $storage_to_load[i] || 0
484
- x[$storage_to_grid_col] = $storage_to_grid[i] || 0
485
- x[$storage_soc_col] = $storage_soc[i] || 0
486
- x[$generator_total_col] = $generator_total[i] || 0
487
- x[$generator_to_battery_col] = $generator_to_battery[i] || 0
488
- x[$generator_to_load_col] = $generator_to_load[i] || 0
489
- x[$generator_to_grid_col] = $generator_to_grid[i] || 0
490
- x[$pv_total_col] = $pv_total[i] || 0
491
- x[$pv_to_battery_col] = $pv_to_battery[i] || 0
492
- x[$pv_to_load_col] = $pv_to_load[i] || 0
493
- x[$pv_to_grid_col] = $pv_to_grid[i] || 0
494
- x[$wind_total_col] = $wind_total[i] || 0
495
- x[$wind_to_battery_col] = $wind_to_battery[i] || 0
496
- x[$wind_to_load_col] = $wind_to_load[i] || 0
497
- x[$wind_to_grid_col] = $wind_to_grid[i] || 0
498
- return x
499
- end
500
-
501
473
  old_data = CSV.open(scenario_report.timeseries_csv.path).read
502
474
  start_date = Time.parse(old_data[1][0]) # Time is the end of the timestep
503
475
  start_ts = (
504
476
  (
505
477
  ((start_date.yday - 1) * 60.0 * 60.0 * 24) +
506
478
  ((start_date.hour - 1) * 60.0 * 60.0) +
507
- (start_date.min * 60.0) + start_date.sec) /
479
+ (start_date.min * 60.0) + start_date.sec) / \
508
480
  ((60 / scenario_report.timesteps_per_hour) * 60)
509
481
  ).to_int
510
482
  mod_data = old_data.map.with_index do |x, i|
@@ -1,31 +1,6 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  def convert_powerflow_resolution(timeseries_kw, original_res, destination_res)
@@ -1,35 +1,10 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  module URBANopt # :nodoc:
32
7
  module REopt # :nodoc:
33
- VERSION = '0.8.0'.freeze
8
+ VERSION = '0.10.0'.freeze
34
9
  end
35
10
  end
@@ -1,31 +1,6 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  require 'urbanopt/reopt/extension'
@@ -1,31 +1,6 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  require 'urbanopt/reopt/scenario/reopt_scenario_csv'
@@ -1,31 +1,6 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  require_relative 'urbanopt/reopt'