Class: URBANopt::Reporting::DefaultReports::DistributedGeneration

Inherits:
Object
  • Object
show all
Defined in:
lib/urbanopt/reporting/default_reports/distributed_generation.rb

Overview

Onsite distributed generation system (i.e. SolarPV, Wind, Storage, Generator) design attributes and financial metrics.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ DistributedGeneration

Initialize distributed generation system design and financial metrics.

  • Technologies include :solar_pv, :wind, :generator, and :storage.

  • Financial metrics include :lcc_us_dollars, :npv_us_dollars, :year_one_energy_cost_us_dollars, :year_one_demand_cost_us_dollars,

:year_one_bill_us_dollars, and :total_energy_cost_us_dollars

parameters:
  • hash - Hash - A hash containting key/value pairs for the distributed generation system attributes listed above.



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 196

def initialize(hash = {})
  hash.delete_if { |k, v| v.nil? }

  @lcc_us_dollars = hash[:lcc_us_dollars]
  @lcc_bau_us_dollars = hash[:lcc_bau_us_dollars]
  @npv_us_dollars = hash[:npv_us_dollars]
  @year_one_energy_cost_us_dollars = hash[:year_one_energy_cost_us_dollars]
  @year_one_energy_cost_bau_us_dollars = hash[:year_one_energy_cost_bau_us_dollars]
  @year_one_demand_cost_us_dollars = hash[:year_one_demand_cost_us_dollars]
  @year_one_demand_cost_bau_us_dollars = hash[:year_one_demand_cost_bau_us_dollars]
  @year_one_bill_us_dollars = hash[:year_one_bill_us_dollars]
  @year_one_bill_bau_us_dollars = hash[:year_one_bill_bau_us_dollars]
  @total_energy_cost_us_dollars = hash[:total_energy_cost_us_dollars]
  @total_energy_cost_bau_us_dollars = hash[:total_energy_cost_bau_us_dollars]
  @total_demand_cost_us_dollars = hash[:total_demand_cost_us_dollars]
  @total_demand_cost_bau_us_dollars = hash[:total_demand_cost_bau_us_dollars]

  @resilience_hours_min = hash[:resilience_hours_min]
  @resilience_hours_max = hash[:resilience_hours_max]
  @resilience_hours_avg = hash[:resilience_hours_avg]
  @probs_of_surviving = hash[:probs_of_surviving]
  @probs_of_surviving_by_month = hash[:probs_of_surviving_by_month]
  @probs_of_surviving_by_hour_of_the_day = hash[:probs_of_surviving_by_hour_of_the_day]

  @total_solar_pv_kw = nil
  @total_wind_kw = nil
  @total_generator_kw = nil
  @total_storage_kw = nil
  @total_storage_kwh = nil

  @solar_pv = []
  if hash[:solar_pv].class == Hash
    hash[:solar_pv] = [hash[:solar_pv]]
  elsif hash[:solar_pv].nil?
    hash[:solar_pv] = []
  end

  hash[:solar_pv].each do |s|
    if !s[:size_kw].nil? && (s[:size_kw] != 0)
      @solar_pv.push SolarPV.new(s)
      if @total_solar_pv_kw.nil?
        @total_solar_pv_kw = @solar_pv[-1].size_kw
      else
        @total_solar_pv_kw += @solar_pv[-1].size_kw
      end
    end
  end

  @wind = []
  if hash[:wind].class == Hash
    hash[:wind] = [hash[:wind]]
  elsif hash[:wind].nil?
    hash[:wind] = []
  end

  hash[:wind].each do |s|
    if !s[:size_kw].nil? && (s[:size_kw] != 0)
      @wind.push Wind.new(s)
      if @total_wind_kw.nil?
        @total_wind_kw = @wind[-1].size_kw
      else
        @total_wind_kw += @wind[-1].size_kw
      end
    end
  end

  @generator = []
  if hash[:generator].class == Hash
    hash[:generator] = [hash[:generator]]
  elsif hash[:generator].nil?
    hash[:generator] = []
  end

  hash[:generator].each do |s|
    if !s[:size_kw].nil? && (s[:size_kw] != 0)
      @generator.push Generator.new(s)
      if @total_generator_kw.nil?
        @total_generator_kw = @generator[-1].size_kw
      else
        @total_generator_kw += @generator[-1].size_kw
      end
    end
  end

  @storage = []
  if hash[:storage].class == Hash
    hash[:storage] = [hash[:storage]]
  elsif hash[:storage].nil?
    hash[:storage] = []
  end

  hash[:storage].each do |s|
    if !s[:size_kw].nil? && (s[:size_kw] != 0)
      @storage.push Storage.new(s)
      if @total_storage_kw.nil?
        @total_storage_kw = @storage[-1].size_kw
        @total_storage_kwh = @storage[-1].size_kwh
      else
        @total_storage_kw += @storage[-1].size_kw
        @total_storage_kwh += @storage[-1].size_kwh
      end
    end
  end

  # initialize class variables @@validator and @@schema
  @@validator ||= Validator.new
  @@schema ||= @@validator.schema

  # initialize @@logger
  @@logger ||= URBANopt::Reporting::DefaultReports.logger
end

Instance Attribute Details

#generatorObject

Array - List of Generator systems



123
124
125
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 123

def generator
  @generator
end

#lcc_bau_us_dollarsObject

Float - Lifecycle costs for the complete distributed generation system in US Dollars



53
54
55
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 53

def lcc_bau_us_dollars
  @lcc_bau_us_dollars
end

#lcc_us_dollarsObject

Float - Lifecycle costs for the complete distributed generation system in US Dollars



48
49
50
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 48

def lcc_us_dollars
  @lcc_us_dollars
end

#npv_us_dollarsObject

Float - Net present value of the complete distributed generation system in US Dollars



58
59
60
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 58

def npv_us_dollars
  @npv_us_dollars
end

#probs_of_survivingObject

Float - Average probability the system can sustain critical load during a grid outage



173
174
175
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 173

def probs_of_surviving
  @probs_of_surviving
end

#probs_of_surviving_by_hour_of_the_dayObject

Float - Average hourly probabiliies that the system can sustain critical load during a grid outage



183
184
185
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 183

def probs_of_surviving_by_hour_of_the_day
  @probs_of_surviving_by_hour_of_the_day
end

#probs_of_surviving_by_monthObject

Float - Average monthly probabiliies that the system can sustain critical load during a grid outage



178
179
180
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 178

def probs_of_surviving_by_month
  @probs_of_surviving_by_month
end

#resilience_hours_avgObject

Float - Average hour the system can support critical load during a grid outage



168
169
170
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 168

def resilience_hours_avg
  @resilience_hours_avg
end

#resilience_hours_maxObject

Float - Maximum hour the system can support critical load during a grid outage



163
164
165
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 163

def resilience_hours_max
  @resilience_hours_max
end

#resilience_hours_minObject

Float - Minimum hour the system can support critical load during a grid outage



158
159
160
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 158

def resilience_hours_min
  @resilience_hours_min
end

#solar_pvObject

Array - List of SolarPV systems



113
114
115
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 113

def solar_pv
  @solar_pv
end

#storageObject

Array - List of Storage systems



128
129
130
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 128

def storage
  @storage
end

#total_demand_cost_bau_us_dollarsObject

Float - Total lifetime demand costs in the business as usual scenario (i.e no new system) after tax, us dollars



103
104
105
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 103

def total_demand_cost_bau_us_dollars
  @total_demand_cost_bau_us_dollars
end

#total_demand_cost_us_dollarsObject

Float - Total demand costs in US Dollars over the life of the system after tax



83
84
85
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 83

def total_demand_cost_us_dollars
  @total_demand_cost_us_dollars
end

#total_energy_cost_bau_us_dollarsObject

Float - Total lifetime energy costs in the business as usual scenario (i.e no new system) after tax, us dollars



108
109
110
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 108

def total_energy_cost_bau_us_dollars
  @total_energy_cost_bau_us_dollars
end

#total_energy_cost_us_dollarsObject

Float - Total energy costs in US Dollars over the life of the system after tax



78
79
80
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 78

def total_energy_cost_us_dollars
  @total_energy_cost_us_dollars
end

#total_generator_kwObject

Float - Installed generator capacity



153
154
155
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 153

def total_generator_kw
  @total_generator_kw
end

#total_solar_pv_kwObject

Float - Installed solar PV capacity



133
134
135
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 133

def total_solar_pv_kw
  @total_solar_pv_kw
end

#total_storage_kwObject

Float - Installed storage capacity



143
144
145
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 143

def total_storage_kw
  @total_storage_kw
end

#total_storage_kwhObject

Float - Installed storage capacity



148
149
150
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 148

def total_storage_kwh
  @total_storage_kwh
end

#total_wind_kwObject

Float - Installed wind capacity



138
139
140
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 138

def total_wind_kw
  @total_wind_kw
end

#windObject

Array - List of Wind systems



118
119
120
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 118

def wind
  @wind
end

#year_one_bill_bau_us_dollarsObject

Float - Year one demand energy bill in the business as usual scenario (i.e no new system), us dollars



98
99
100
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 98

def year_one_bill_bau_us_dollars
  @year_one_bill_bau_us_dollars
end

#year_one_bill_us_dollarsObject

Float - Total amount paid to the utility in US Dollars in the first year of operation



73
74
75
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 73

def year_one_bill_us_dollars
  @year_one_bill_us_dollars
end

#year_one_demand_cost_bau_us_dollarsObject

Float - Year one demand cost in the business as usual scenario (i.e no new system), us dollars



93
94
95
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 93

def year_one_demand_cost_bau_us_dollars
  @year_one_demand_cost_bau_us_dollars
end

#year_one_demand_cost_us_dollarsObject

Float - Total amount paid in utility demand charges in US Dollars in the first year of operation



68
69
70
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 68

def year_one_demand_cost_us_dollars
  @year_one_demand_cost_us_dollars
end

#year_one_energy_cost_bau_us_dollarsObject

Float - Year one energy cost in the business as usual scenario (i.e no new system) after tax, us dollars



88
89
90
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 88

def year_one_energy_cost_bau_us_dollars
  @year_one_energy_cost_bau_us_dollars
end

#year_one_energy_cost_us_dollarsObject

Float - Total amount paid for utility energy in US Dollars in the first year of operation



63
64
65
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 63

def year_one_energy_cost_us_dollars
  @year_one_energy_cost_us_dollars
end

Class Method Details

.add_values(existing_value, new_value) ⇒ Object

Add up old and new values



413
414
415
416
417
418
419
420
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 413

def self.add_values(existing_value, new_value) #:nodoc:
  if existing_value && new_value
    existing_value += new_value
  elsif new_value
    existing_value = new_value
  end
  return existing_value
end

.merge_distributed_generation(existing_dgen, new_dgen) ⇒ Object

Merge a distributed generation system with a new system



425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 425

def self.merge_distributed_generation(existing_dgen, new_dgen)
  existing_dgen.lcc_us_dollars = add_values(existing_dgen.lcc_us_dollars, new_dgen.lcc_us_dollars)
  existing_dgen.lcc_bau_us_dollars = add_values(existing_dgen.lcc_bau_us_dollars, new_dgen.lcc_bau_us_dollars)
  existing_dgen.npv_us_dollars = add_values(existing_dgen.npv_us_dollars, new_dgen.npv_us_dollars)

  existing_dgen.year_one_energy_cost_us_dollars = add_values(existing_dgen.year_one_energy_cost_us_dollars, new_dgen.year_one_energy_cost_us_dollars)
  existing_dgen.year_one_demand_cost_us_dollars = add_values(existing_dgen.year_one_demand_cost_us_dollars, new_dgen.year_one_demand_cost_us_dollars)
  existing_dgen.year_one_bill_us_dollars = add_values(existing_dgen.year_one_bill_us_dollars, new_dgen.year_one_bill_us_dollars)
  existing_dgen.total_energy_cost_us_dollars = add_values(existing_dgen.total_energy_cost_us_dollars, new_dgen.total_energy_cost_us_dollars)
  existing_dgen.total_demand_cost_us_dollars = add_values(existing_dgen.total_demand_cost_us_dollars, new_dgen.total_demand_cost_us_dollars)

  existing_dgen.year_one_energy_cost_bau_us_dollars = add_values(existing_dgen.year_one_energy_cost_bau_us_dollars, new_dgen.year_one_energy_cost_bau_us_dollars)
  existing_dgen.year_one_demand_cost_bau_us_dollars = add_values(existing_dgen.year_one_demand_cost_bau_us_dollars, new_dgen.year_one_demand_cost_bau_us_dollars)
  existing_dgen.year_one_bill_bau_us_dollars = add_values(existing_dgen.year_one_bill_bau_us_dollars, new_dgen.year_one_bill_bau_us_dollars)
  existing_dgen.total_energy_cost_bau_us_dollars = add_values(existing_dgen.total_energy_cost_bau_us_dollars, new_dgen.total_energy_cost_bau_us_dollars)
  existing_dgen.total_demand_cost_bau_us_dollars = add_values(existing_dgen.total_demand_cost_bau_us_dollars, new_dgen.total_demand_cost_bau_us_dollars)

  existing_dgen.resilience_hours_min = add_values(existing_dgen.resilience_hours_min, new_dgen.resilience_hours_min)
  existing_dgen.resilience_hours_max = add_values(existing_dgen.resilience_hours_max, new_dgen.resilience_hours_max)
  existing_dgen.resilience_hours_avg = add_values(existing_dgen.resilience_hours_avg, new_dgen.resilience_hours_avg)
  existing_dgen.probs_of_surviving = add_values(existing_dgen.probs_of_surviving, new_dgen.probs_of_surviving)
  existing_dgen.probs_of_surviving_by_month = add_values(existing_dgen.probs_of_surviving_by_month, new_dgen.probs_of_surviving_by_month)
  existing_dgen.probs_of_surviving_by_hour_of_the_day = add_values(existing_dgen.probs_of_surviving_by_hour_of_the_day, new_dgen.probs_of_surviving_by_hour_of_the_day)

  new_dgen.solar_pv.each do |pv|
    existing_dgen.solar_pv.push pv
    if existing_dgen.total_solar_pv_kw.nil?
      existing_dgen.total_solar_pv_kw = pv.size_kw
    else
      existing_dgen.total_solar_pv_kw += pv.size_kw
    end
  end

  new_dgen.wind.each do |wind|
    existing_dgen.wind.push wind
    if existing_dgen.total_wind_kw.nil?
      existing_dgen.total_wind_kw = wind.size_kw
    else
      existing_dgen.total_wind_kw += wind.size_kw
    end
  end

  new_dgen.storage.each do |storage|
    existing_dgen.storage.push storage
    if existing_dgen.total_wind_kw.nil?
      existing_dgen.total_storage_kw = storage.size_kw
      existing_dgen.total_storage_kwh = storage.size_kwh
    else
      existing_dgen.total_storage_kw += storage.size_kw
      existing_dgen.total_storage_kwh += storage.size_kwh
    end
  end

  new_dgen.generator.each do |generator|
    existing_dgen.generator.push generator
    if existing_dgen.total_wind_kw.nil?
      existing_dgen.total_generator_kw = generator.size_kw
    else
      existing_dgen.total_generator_kw += generator.size_kw
    end
  end

  return existing_dgen
end

Instance Method Details

#add_tech(name, tech) ⇒ Object

Add a tech



311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 311

def add_tech(name, tech)
  if name == 'solar_pv'
    @solar_pv.push tech
    if @total_solar_pv_kw.nil?
      @total_solar_pv_kw = tech.size_kw
    else
      @total_solar_pv_kw += tech.size_kw
    end
  end

  if name == 'wind'
    @wind.push tech
    if @total_wind_kw.nil?
      @total_wind_kw = tech.size_kw
    else
      @total_wind_kw += tech.size_kw
    end
  end

  if name == 'storage'
    @storage.push tech
    if @total_storage_kw.nil?
      @total_storage_kw = tech.size_kw
      @total_storage_kwh = tech.size_kwh
    else
      @total_storage_kw += tech.size_kw
      @total_storage_kwh += tech.size_kwh
    end
  end

  if name == 'generator'
    @generator.push tech
    if @total_generator_kw.nil?
      @total_generator_kw = tech.size_kw
    else
      @total_generator_kw += tech.size_kw
    end
  end
end

#to_hashObject

Convert to a Hash equivalent for JSON serialization



354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 354

def to_hash
  result = {}

  result[:lcc_us_dollars] = @lcc_us_dollars if @lcc_us_dollars
  result[:lcc_bau_us_dollars] = @lcc_bau_us_dollars if @lcc_bau_us_dollars
  result[:npv_us_dollars] = @npv_us_dollars if @npv_us_dollars

  result[:year_one_energy_cost_us_dollars] = @year_one_energy_cost_us_dollars if @year_one_energy_cost_us_dollars
  result[:year_one_demand_cost_us_dollars] = @year_one_demand_cost_us_dollars if @year_one_demand_cost_us_dollars
  result[:year_one_bill_us_dollars] = @year_one_bill_us_dollars if @year_one_bill_us_dollars
  result[:total_demand_cost_us_dollars] = @total_demand_cost_us_dollars if @total_demand_cost_us_dollars
  result[:total_energy_cost_us_dollars] = @total_energy_cost_us_dollars if @total_energy_cost_us_dollars

  result[:year_one_energy_cost_bau_us_dollars] = @year_one_energy_cost_bau_us_dollars if @year_one_energy_cost_bau_us_dollars
  result[:year_one_demand_cost_bau_us_dollars] = @year_one_demand_cost_bau_us_dollars if @year_one_demand_cost_bau_us_dollars
  result[:year_one_bill_bau_us_dollars] = @year_one_bill_bau_us_dollars if @year_one_bill_bau_us_dollars
  result[:total_energy_cost_bau_us_dollars] = @total_energy_cost_bau_us_dollars if @total_energy_cost_bau_us_dollars
  result[:total_demand_cost_bau_us_dollars] = @total_demand_cost_bau_us_dollars if @total_demand_cost_bau_us_dollars

  result[:total_solar_pv_kw] = @total_solar_pv_kw if @total_solar_pv_kw
  result[:total_wind_kw] = @total_wind_kw if @total_wind_kw
  result[:total_generator_kw] = @total_generator_kw if @total_generator_kw
  result[:total_storage_kw] = @total_storage_kw if @total_storage_kw
  result[:total_storage_kwh] = @total_storage_kwh if @total_storage_kwh

  result[:resilience_hours_min] = @resilience_hours_min if @resilience_hours_min
  result[:resilience_hours_max] = @resilience_hours_max if @resilience_hours_max
  result[:resilience_hours_avg] = @resilience_hours_avg if @resilience_hours_avg
  result[:probs_of_surviving] = @probs_of_surviving if @probs_of_surviving
  result[:probs_of_surviving_by_month] = @probs_of_surviving_by_month if @probs_of_surviving_by_month
  result[:probs_of_surviving_by_hour_of_the_day] = @probs_of_surviving_by_hour_of_the_day if @probs_of_surviving_by_hour_of_the_day

  result[:solar_pv] = []
  @solar_pv.each do |pv|
    result[:solar_pv].push pv.to_hash
  end
  result[:wind] = []
  @wind.each do |wind|
    result[:wind].push wind.to_hash
  end
  result[:generator] = []
  @generator.each do |generator|
    result[:generator].push generator.to_hash
  end
  result[:storage] = []
  @storage.each do |storage|
    result[:storage].push storage.to_hash
  end
  return result
end