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, :npv, :year_one_energy_cost_before_tax, :year_one_demand_cost_before_tax, :year_one_bill_before_tax, :lifecycle_energy_cost_after_tax, :initial_capital_costs, :initial_capital_costs_after_incentives, :lifecycle_capital_costs, :lifecycle_elecbill_after_tax, and :lifecycle_fuel_costs_after_tax

[parameters:]

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


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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 207

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

  @renewable_electricity_fraction = hash[:renewable_electricity_fraction]
  @lcc = hash[:lcc]
  @lcc_bau = hash[:lcc_bau]
  @npv = hash[:npv]
  @year_one_energy_cost_before_tax = hash[:year_one_energy_cost_before_tax]
  @year_one_energy_cost_before_tax_bau = hash[:year_one_energy_cost_before_tax_bau]
  @year_one_demand_cost_before_tax = hash[:year_one_demand_cost_before_tax]
  @year_one_demand_cost_before_tax_bau = hash[:year_one_demand_cost_before_tax_bau]
  @year_one_bill_before_tax = hash[:year_one_bill_before_tax]
  @year_one_bill_before_tax_bau = hash[:year_one_bill_before_tax_bau]
  @lifecycle_energy_cost_after_tax = hash[:lifecycle_energy_cost_after_tax]
  @lifecycle_energy_cost_after_tax_bau = hash[:lifecycle_energy_cost_after_tax_bau]
  @lifecycle_demand_cost_after_tax = hash[:lifecycle_demand_cost_after_tax]
  @lifecycle_demand_cost_after_tax_bau = hash[:lifecycle_demand_cost_after_tax_bau]
  @initial_capital_costs = hash[:initial_capital_costs]
  @initial_capital_costs_after_incentives = hash[:initial_capital_costs_after_incentives]
  @lifecycle_capital_costs = hash[:lifecycle_capital_costs]
  @lifecycle_fuel_costs_after_tax = hash[:lifecycle_fuel_costs_after_tax]
  @lifecycle_elecbill_after_tax = hash[:lifecycle_elecbill_after_tax]

  @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]

  # optional
  @reopt_assumptions_file_path = nil
  if hash[:reopt_assumptions_file_path]
    @reopt_assumptions_file_path = hash[:reopt_assumptions_file_path]
  end

  @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].instance_of?(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].instance_of?(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].instance_of?(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].instance_of?(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

#initial_capital_costsObject

Float - Up-front capital costs for all technologies, in present value, excluding replacement costs and incentives.



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

def initial_capital_costs
  @initial_capital_costs
end

#initial_capital_costs_after_incentivesObject

Float - Up-front capital costs for all technologies, in present value, excluding replacement costs, including incentives.



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

def initial_capital_costs_after_incentives
  @initial_capital_costs_after_incentives
end

#lccObject

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



23
24
25
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 23

def lcc
  @lcc
end

#lcc_bauObject

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



28
29
30
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 28

def lcc_bau
  @lcc_bau
end

#lifecycle_capital_costsObject

Float - Net capital costs for all technologies, in present value, including replacement costs and incentives.



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

def lifecycle_capital_costs
  @lifecycle_capital_costs
end

#lifecycle_demand_cost_after_taxObject

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



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

def lifecycle_demand_cost_after_tax
  @lifecycle_demand_cost_after_tax
end

#lifecycle_demand_cost_after_tax_bauObject

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



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

def lifecycle_demand_cost_after_tax_bau
  @lifecycle_demand_cost_after_tax_bau
end

#lifecycle_elecbill_after_taxObject

Float - Component of lifecycle costs (LCC). This value is the present value of all electric utility charges, after tax.



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

def lifecycle_elecbill_after_tax
  @lifecycle_elecbill_after_tax
end

#lifecycle_energy_cost_after_taxObject

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



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

def lifecycle_energy_cost_after_tax
  @lifecycle_energy_cost_after_tax
end

#lifecycle_energy_cost_after_tax_bauObject

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



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

def lifecycle_energy_cost_after_tax_bau
  @lifecycle_energy_cost_after_tax_bau
end

#lifecycle_fuel_costs_after_taxObject

Float - Component of lifecycle costs (LCC). This value is the present value of all fuel costs over the analysis period, after tax.



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

def lifecycle_fuel_costs_after_tax
  @lifecycle_fuel_costs_after_tax
end

#npvObject

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



33
34
35
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 33

def npv
  @npv
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

#renewable_electricity_fractionObject

Float - Annual fraction of electricity supplied by renewable sources



192
193
194
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 192

def renewable_electricity_fraction
  @renewable_electricity_fraction
end

#reopt_assumptions_file_pathObject

String - Filepath of reopt assumptions file used, if known



187
188
189
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 187

def reopt_assumptions_file_path
  @reopt_assumptions_file_path
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_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_before_taxObject

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



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

def year_one_bill_before_tax
  @year_one_bill_before_tax
end

#year_one_bill_before_tax_bauObject

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



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

def year_one_bill_before_tax_bau
  @year_one_bill_before_tax_bau
end

#year_one_demand_cost_before_taxObject

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



43
44
45
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 43

def year_one_demand_cost_before_tax
  @year_one_demand_cost_before_tax
end

#year_one_demand_cost_before_tax_bauObject

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



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

def year_one_demand_cost_before_tax_bau
  @year_one_demand_cost_before_tax_bau
end

#year_one_energy_cost_before_taxObject

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



38
39
40
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 38

def year_one_energy_cost_before_tax
  @year_one_energy_cost_before_tax
end

#year_one_energy_cost_before_tax_bauObject

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



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

def year_one_energy_cost_before_tax_bau
  @year_one_energy_cost_before_tax_bau
end

Class Method Details

.add_values(existing_value, new_value) ⇒ Object

Add up old and new values



443
444
445
446
447
448
449
450
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 443

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



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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 455

def self.merge_distributed_generation(existing_dgen, new_dgen)
  existing_dgen.renewable_electricity_fraction = add_values(existing_dgen.renewable_electricity_fraction, new_dgen.renewable_electricity_fraction)
  existing_dgen.lcc = add_values(existing_dgen.lcc, new_dgen.lcc)
  existing_dgen.lcc_bau = add_values(existing_dgen.lcc_bau, new_dgen.lcc_bau)
  existing_dgen.npv = add_values(existing_dgen.npv, new_dgen.npv)

  existing_dgen.year_one_energy_cost_before_tax = add_values(existing_dgen.year_one_energy_cost_before_tax, new_dgen.year_one_energy_cost_before_tax)
  existing_dgen.year_one_demand_cost_before_tax = add_values(existing_dgen.year_one_demand_cost_before_tax, new_dgen.year_one_demand_cost_before_tax)
  existing_dgen.year_one_bill_before_tax = add_values(existing_dgen.year_one_bill_before_tax, new_dgen.year_one_bill_before_tax)
  existing_dgen.lifecycle_energy_cost_after_tax = add_values(existing_dgen.lifecycle_energy_cost_after_tax, new_dgen.lifecycle_energy_cost_after_tax)
  existing_dgen.lifecycle_demand_cost_after_tax = add_values(existing_dgen.lifecycle_demand_cost_after_tax, new_dgen.lifecycle_demand_cost_after_tax)

  existing_dgen.year_one_energy_cost_before_tax_bau = add_values(existing_dgen.year_one_energy_cost_before_tax_bau, new_dgen.year_one_energy_cost_before_tax_bau)
  existing_dgen.year_one_demand_cost_before_tax_bau = add_values(existing_dgen.year_one_demand_cost_before_tax_bau, new_dgen.year_one_demand_cost_before_tax_bau)
  existing_dgen.year_one_bill_before_tax_bau = add_values(existing_dgen.year_one_bill_before_tax_bau, new_dgen.year_one_bill_before_tax_bau)
  existing_dgen.lifecycle_energy_cost_after_tax_bau = add_values(existing_dgen.lifecycle_energy_cost_after_tax_bau, new_dgen.lifecycle_energy_cost_after_tax_bau)
  existing_dgen.lifecycle_demand_cost_after_tax_bau = add_values(existing_dgen.lifecycle_demand_cost_after_tax_bau, new_dgen.lifecycle_demand_cost_after_tax_bau)

  existing_dgen.initial_capital_costs = add_values(existing_dgen.initial_capital_costs, new_dgen.initial_capital_costs)
  existing_dgen.initial_capital_costs_after_incentives = add_values(existing_dgen.initial_capital_costs_after_incentives, new_dgen.initial_capital_costs_after_incentives)
  existing_dgen.lifecycle_capital_costs = add_values(existing_dgen.lifecycle_capital_costs, new_dgen.lifecycle_capital_costs)
  existing_dgen.lifecycle_fuel_costs_after_tax = add_values(existing_dgen.lifecycle_fuel_costs_after_tax, new_dgen.lifecycle_fuel_costs_after_tax)
  existing_dgen.lifecycle_elecbill_after_tax = add_values(existing_dgen.lifecycle_elecbill_after_tax, new_dgen.lifecycle_elecbill_after_tax)

  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_storage_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_generator_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



334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 334

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



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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
# File 'lib/urbanopt/reporting/default_reports/distributed_generation.rb', line 377

def to_hash
  result = {}
  result[:reopt_assumptions_file_path] = @reopt_assumptions_file_path if @reopt_assumptions_file_path
  result[:renewable_electricity_fraction] = @renewable_electricity_fraction if @renewable_electricity_fraction
  result[:lcc] = @lcc if @lcc
  result[:lcc_bau] = @lcc_bau if @lcc_bau
  result[:npv] = @npv if @npv

  result[:year_one_energy_cost_before_tax] = @year_one_energy_cost_before_tax if @year_one_energy_cost_before_tax
  result[:year_one_demand_cost_before_tax] = @year_one_demand_cost_before_tax if @year_one_demand_cost_before_tax
  result[:year_one_bill_before_tax] = @year_one_bill_before_tax if @year_one_bill_before_tax
  result[:lifecycle_demand_cost_after_tax] = @lifecycle_demand_cost_after_tax if @lifecycle_demand_cost_after_tax
  result[:lifecycle_energy_cost_after_tax] = @lifecycle_energy_cost_after_tax if @lifecycle_energy_cost_after_tax

  result[:year_one_energy_cost_before_tax_bau] = @year_one_energy_cost_before_tax_bau if @year_one_energy_cost_before_tax_bau
  result[:year_one_demand_cost_before_tax_bau] = @year_one_demand_cost_before_tax_bau if @year_one_demand_cost_before_tax_bau
  result[:year_one_bill_before_tax_bau] = @year_one_bill_before_tax_bau if @year_one_bill_before_tax_bau
  result[:lifecycle_energy_cost_after_tax_bau] = @lifecycle_energy_cost_after_tax_bau if @lifecycle_energy_cost_after_tax_bau
  result[:lifecycle_demand_cost_after_tax_bau] = @lifecycle_demand_cost_after_tax_bau if @lifecycle_demand_cost_after_tax_bau

  result[:initial_capital_costs] = @initial_capital_costs if @initial_capital_costs
  result[:initial_capital_costs_after_incentives] = @initial_capital_costs_after_incentives if @initial_capital_costs_after_incentives
  result[:lifecycle_capital_costs] = @lifecycle_capital_costs if @lifecycle_capital_costs
  result[:lifecycle_fuel_costs_after_tax] = @lifecycle_fuel_costs_after_tax if @lifecycle_fuel_costs_after_tax
  result[:lifecycle_elecbill_after_tax] = @lifecycle_elecbill_after_tax if @lifecycle_elecbill_after_tax

  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