urbanopt-scenario 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/docs/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "is-svg": ">=4.3.1",
24
24
  "js-yaml": "^3.14.0",
25
25
  "minimist": ">=1.2.3",
26
- "node-forge": ">=0.10.0",
26
+ "node-forge": ">=1.3.0",
27
27
  "postcss": "^8.2.15",
28
28
  "serialize-javascript": "^5.0.1",
29
29
  "set-value": "^4.0.1",
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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,
@@ -71,6 +71,9 @@ module URBANopt
71
71
  # initialize feature_reports data
72
72
  @feature_reports_data = {}
73
73
 
74
+ # initialize opendss json results
75
+ @opendss_json_results = {}
76
+
74
77
  # initialize logger
75
78
  @@logger ||= URBANopt::Reporting::DefaultReports.logger
76
79
  end
@@ -85,6 +88,12 @@ module URBANopt
85
88
  @opendss_data[feature_report.id] = opendss_csv
86
89
  end
87
90
 
91
+ # load Model.json results (if exists)
92
+ opendss_json_filename = File.join(@opendss_results_dir, 'json_files', 'Model.json')
93
+ if File.exist?(opendss_json_filename)
94
+ @opendss_json_results = JSON.parse(File.read(opendss_json_filename))
95
+ end
96
+
88
97
  ## load transformers data
89
98
 
90
99
  # transformers results directory path
@@ -140,11 +149,46 @@ module URBANopt
140
149
  return output
141
150
  end
142
151
 
152
+ # computer transformer results
153
+ def compute_transformer_results
154
+ # using values from opendss Model.json
155
+ results = {}
156
+ # retrieve all transformers
157
+ trsfmrs = @opendss_json_results['model'].select { |d| d['class'] == 'PowerTransformer' }
158
+ trsfmrs.each do |item|
159
+ t = { 'nominal_capacity': nil, 'reactance_resistance_ratio': nil }
160
+ name = item['name']['value']
161
+
162
+ # nominal capacity in kVA (Model.json stores it in VA)
163
+ # TODO: assuming that all windings would have the same rated power, so grabbing first one
164
+ begin
165
+ t['nominal_capacity'] = item['windings']['value'][0]['rated_power']['value'] / 1000
166
+ rescue StandardError
167
+ end
168
+
169
+ # reactance to resistance ratio:
170
+ begin
171
+ # TODO: grabbing the first one for now. Handle when there are multiple reactances and winding resistances
172
+ reactance = item['reactances']['value'][0]['value']
173
+ resistance = item['windings']['value'][0]['resistance']['value']
174
+
175
+ t['reactance_resistance_ratio'] = reactance / resistance
176
+ rescue StandardError
177
+ end
178
+
179
+ results[name] = t
180
+ end
181
+
182
+ return results
183
+ end
184
+
143
185
  # add feature reports for transformers
144
186
  def save_transformers_reports
187
+ t_res = compute_transformer_results
188
+
145
189
  @opendss_data.each_key do |k|
146
190
  if k.include? 'Transformer'
147
-
191
+ t_key = k.sub('Transformer.', '')
148
192
  # create transformer directory
149
193
  transformer_dir = File.join(@scenario_report.directory_name, k)
150
194
  FileUtils.mkdir_p(File.join(transformer_dir, 'feature_reports'))
@@ -153,6 +197,13 @@ module URBANopt
153
197
  # store under voltages and over voltages
154
198
  under_voltage_hrs = 0
155
199
  over_voltage_hrs = 0
200
+ nominal_capacity = nil
201
+ r_r_ratio = nil
202
+ begin
203
+ nominal_capacity = t_res[t_key]['nominal_capacity']
204
+ r_r_ratio = t_res[t_key]['reactance_resistance_ratio']
205
+ rescue StandardError
206
+ end
156
207
 
157
208
  transformer_csv = CSV.generate do |csv|
158
209
  @opendss_data[k].each_with_index do |row, i|
@@ -178,9 +229,11 @@ module URBANopt
178
229
  timesteps_per_hour: @scenario_report.timesteps_per_hour,
179
230
  simulation_status: 'complete')
180
231
 
181
- # assign results to transfomrer report
232
+ # assign results to transformer report
182
233
  transformer_report.power_distribution.over_voltage_hours = over_voltage_hrs
183
234
  transformer_report.power_distribution.under_voltage_hours = under_voltage_hrs
235
+ transformer_report.power_distribution.nominal_capacity = nominal_capacity
236
+ transformer_report.power_distribution.reactance_resistance_ratio = r_r_ratio
184
237
 
185
238
  ## save transformer JSON file
186
239
  # transformer_hash
@@ -226,6 +279,9 @@ module URBANopt
226
279
  def add_summary_results(feature_report)
227
280
  under_voltage_hrs = 0
228
281
  over_voltage_hrs = 0
282
+ kw = nil
283
+ kvar = nil
284
+ nominal_voltage = nil
229
285
 
230
286
  id = feature_report.id
231
287
  @opendss_data[id].each_with_index do |row, i|
@@ -242,13 +298,107 @@ module URBANopt
242
298
  end
243
299
  end
244
300
 
301
+ # also add additional keys for OpenDSS Loads
302
+ loads = @opendss_json_results['model'].select { |d| d['class'] == 'Load' }
303
+ if loads
304
+ bld_load = loads.select { |d| d['name']['value'] == id }
305
+ if bld_load
306
+ if bld_load.is_a?(Array)
307
+ bld_load = bld_load[0]
308
+ end
309
+ kw = 0
310
+ kvar = 0
311
+ # nominal_voltage (V)
312
+ nominal_voltage = bld_load['nominal_voltage']['value']
313
+ if nominal_voltage < 300
314
+ nominal_voltage *= Math.sqrt(3)
315
+ end
316
+ nominal_voltage = nominal_voltage
317
+
318
+ # max_power_kw
319
+ # max_reactive_power_kvar
320
+ pls = bld_load['phase_loads']['value']
321
+ pls.each do |pl|
322
+ kw += pl['p']['value']
323
+ kvar += pl['q']['value']
324
+ end
325
+
326
+ kw /= 1000
327
+ kvar /= 1000
328
+ else
329
+ @@logger.info("No load matching id #{id} found in OpenDSS Model.json results")
330
+ end
331
+ else
332
+ @@logger.info('No loads information found in OpenDSS Model.json results file')
333
+ end
245
334
  # assign results to feature report
246
335
  feature_report.power_distribution.over_voltage_hours = over_voltage_hrs
247
336
  feature_report.power_distribution.under_voltage_hours = under_voltage_hrs
337
+ feature_report.power_distribution.nominal_voltage = nominal_voltage
338
+ feature_report.power_distribution.max_power_kw = kw
339
+ feature_report.power_distribution.max_reactive_power_kvar = kvar
248
340
 
249
341
  return feature_report
250
342
  end
251
343
 
344
+ ##
345
+ # save opendss scenario fields
346
+ ##
347
+ def save_opendss_scenario
348
+ @scenario_report.scenario_power_distribution = URBANopt::Reporting::DefaultReports::ScenarioPowerDistribution.new
349
+
350
+ ## SUBSTATION
351
+ subs = []
352
+ feeders = @opendss_json_results['model'].select { |d| d['class'] == 'Feeder_metadata' }
353
+
354
+ feeders.each do |item|
355
+ # nominal_voltage - RMS voltage low side (V)
356
+ substation = { nominal_voltage: item['nominal_voltage']['value'] }
357
+ subs.append(substation)
358
+ end
359
+ @scenario_report.scenario_power_distribution.substations = subs
360
+
361
+ ## LINES
362
+ # retrieve all lines
363
+ dist_lines = []
364
+ lines = @opendss_json_results['model'].select { |d| d['class'] == 'Line' }
365
+ lines.each do |item|
366
+ line = {}
367
+ # length (m)
368
+ line['length'] = item['length']['value']
369
+
370
+ # max ampacity: iterate through N-1 wires and add up ampacity
371
+ amps = 0
372
+ num_wires = item['wires']['value'].length
373
+ (0..(num_wires - 1)).each do |i|
374
+ amps += item['wires']['value'][i]['ampacity']['value']
375
+ end
376
+ line['ampacity'] = amps
377
+
378
+ # commercial line type
379
+ line['commercial_line_type'] = []
380
+ item['wires']['value'].each do |wire|
381
+ line['commercial_line_type'].append(wire['nameclass']['value'])
382
+ end
383
+ dist_lines.append(line)
384
+ end
385
+ @scenario_report.scenario_power_distribution.distribution_lines = dist_lines
386
+
387
+ # CAPACITORS
388
+ caps = []
389
+ capacitors = @opendss_json_results['model'].select { |d| d['class'] == 'Capacitors' }
390
+ capacitors.each do |item|
391
+ cap = 0
392
+ item['phase_capacitors']['value'].each do |pc|
393
+ if pc['var']['value']
394
+ cap += pc['var']['value']
395
+ end
396
+ end
397
+ caps.append({ nominal_capacity: cap })
398
+ end
399
+ @scenario_report.scenario_power_distribution.capacitors = caps
400
+ end
401
+
252
402
  ##
253
403
  # run opendss post_processor
254
404
  ##
@@ -266,7 +416,7 @@ module URBANopt
266
416
  id = feature_report.id
267
417
  updated_feature_csv = merge_data(@feature_reports_data[id], @opendss_data[id])
268
418
 
269
- # save fetaure reports
419
+ # save feature reports
270
420
  feature_report.save_json_report('default_feature_report_opendss')
271
421
 
272
422
  # resave updated csv report
@@ -276,6 +426,9 @@ module URBANopt
276
426
  # add transformer reports
277
427
  save_transformers_reports
278
428
 
429
+ # save additional global opendss fields
430
+ save_opendss_scenario
431
+
279
432
  # save the updated scenario reports
280
433
  # set save_feature_reports to false since only the scenario reports should be saved now
281
434
  @scenario_report.save(file_name = 'scenario_report_opendss', save_feature_reports = false)
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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,
@@ -174,9 +174,6 @@ module URBANopt
174
174
  # depends on the feature file
175
175
  dependencies << scenario.feature_file.path
176
176
 
177
- # depends on the csv file
178
- dependencies << scenario.csv_file
179
-
180
177
  # depends on the mapper classes
181
178
  Dir.glob(File.join(scenario.mapper_files_dir, '*')).each do |f|
182
179
  dependencies << f
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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,
@@ -40,6 +40,6 @@
40
40
 
41
41
  module URBANopt
42
42
  module Scenario
43
- VERSION = '0.7.0'.freeze
43
+ VERSION = '0.8.0'.freeze
44
44
  end
45
45
  end
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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-2021, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2022, 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,
@@ -31,8 +31,8 @@ Gem::Specification.new do |spec|
31
31
  spec.add_runtime_dependency 'json-schema', '~> 2.8'
32
32
 
33
33
  spec.add_runtime_dependency 'sqlite3', '1.4.2'
34
- spec.add_runtime_dependency 'urbanopt-core', '~> 0.7.0'
35
- spec.add_runtime_dependency 'urbanopt-reporting', '~> 0.5.0'
34
+ spec.add_runtime_dependency 'urbanopt-core', '~> 0.8.0'
35
+ spec.add_runtime_dependency 'urbanopt-reporting', '~> 0.6.0'
36
36
 
37
37
  # no longer need the below
38
38
  # need to include all measure gems listed in mappers in project gemfiles
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urbanopt-scenario
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rawad El Kontar
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-12-07 00:00:00.000000000 Z
12
+ date: 2022-05-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -101,28 +101,28 @@ dependencies:
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: 0.7.0
104
+ version: 0.8.0
105
105
  type: :runtime
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: 0.7.0
111
+ version: 0.8.0
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: urbanopt-reporting
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: 0.5.0
118
+ version: 0.6.0
119
119
  type: :runtime
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: 0.5.0
125
+ version: 0.6.0
126
126
  description: Library to export data point OSW files from URBANopt Scenario CSV
127
127
  email:
128
128
  - rawad.elkontar@nrel.gov
@@ -146,6 +146,11 @@ files:
146
146
  - README.md
147
147
  - Rakefile
148
148
  - deploy_docs.sh
149
+ - doc_templates/LICENSE.md
150
+ - doc_templates/README.md.erb
151
+ - doc_templates/copyright_erb.txt
152
+ - doc_templates/copyright_js.txt
153
+ - doc_templates/copyright_ruby.txt
149
154
  - docs/.gitignore
150
155
  - docs/.vuepress/components/InnerJsonSchema.vue
151
156
  - docs/.vuepress/components/JsonSchema.vue