Class: URBANopt::Scenario::DefaultReports::DistributedGeneration

Inherits:
Object
  • Object
show all
Defined in:
lib/urbanopt/scenario/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.



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/urbanopt/scenario/default_reports/distributed_generation.rb', line 106

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

  @lcc_us_dollars = hash[:lcc_us_dollars]
  @npv_us_dollars = hash[:npv_us_dollars]
  @year_one_energy_cost_us_dollars = hash[:year_one_energy_cost_us_dollars]
  @year_one_demand_cost_us_dollars = hash[:year_one_demand_cost_us_dollars]
  @year_one_bill_us_dollars = hash[:year_one_bill_us_dollars]
  @total_energy_cost_us_dollars = hash[:total_energy_cost_us_dollars]

  @solar_pv = SolarPV.new(hash[:solar_pv] || {})
  @wind = Wind.new(hash[:wind] || {})
  @generator = Generator.new(hash[:generator] || {})
  @storage = Storage.new(hash[:storage] || {})

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

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

Instance Attribute Details

#generatorObject

Generator - Installed generator attributes



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

def generator
  @generator
end

#lcc_us_dollarsObject

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



48
49
50
# File 'lib/urbanopt/scenario/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



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

def npv_us_dollars
  @npv_us_dollars
end

#solar_pvObject

SolarPV - Installed solar PV attributes



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

def solar_pv
  @solar_pv
end

#storageObject

Storage - Installed storage attributes



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

def storage
  @storage
end

#total_energy_cost_us_dollarsObject

Float - Total amount paid to the utility in US Dollars over the life of the system



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

def total_energy_cost_us_dollars
  @total_energy_cost_us_dollars
end

#windObject

Wind - Installed wind attributes



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

def wind
  @wind
end

#year_one_bill_us_dollarsObject

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



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

def year_one_bill_us_dollars
  @year_one_bill_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



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

def year_one_demand_cost_us_dollars
  @year_one_demand_cost_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



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

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



157
158
159
160
161
162
163
164
# File 'lib/urbanopt/scenario/default_reports/distributed_generation.rb', line 157

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



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/urbanopt/scenario/default_reports/distributed_generation.rb', line 169

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.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.solar_pv = SolarPV.add_pv existing_dgen.solar_pv, new_dgen.solar_pv
  existing_dgen.wind = Wind.add_wind existing_dgen.wind, new_dgen.wind
  existing_dgen.generator = Generator.add_generator existing_dgen.generator, new_dgen.generator
  existing_dgen.storage = Storage.add_storage existing_dgen.storage, new_dgen.storage

  return existing_dgen
end

Instance Method Details

#to_hashObject

Convert to a Hash equivalent for JSON serialization



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/urbanopt/scenario/default_reports/distributed_generation.rb', line 132

def to_hash
  result = {}

  result[:lcc_us_dollars] = @lcc_us_dollars if @lcc_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_energy_cost_us_dollars] = @total_energy_cost_us_dollars if @total_energy_cost_us_dollars
  result[:solar_pv] = @solar_pv.to_hash if @solar_pv
  result[:wind] = @wind.to_hash if @wind
  result[:generator] = @generator.to_hash if @generator
  result[:storage] = @storage.to_hash if @storage

  return result
end