Class: URBANopt::Reporting::DefaultReports::SolarPV

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

Overview

Onsite solar PV system attributes

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ SolarPV

Initialize SolarPV attributes from a hash. Solar PV attributes currently are limited to power capacity.

parameters:
  • hash - Hash - A hash containting a :size_kw key/value pair which represents the nameplate capacity in kilowatts (kW)



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/urbanopt/reporting/default_reports/solar_pv.rb', line 64

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

  @size_kw = hash[:size_kw]
  @id = hash[:id]
  @location = hash[:location]
  @approx_area_m2 = 0

  if hash[:azimuth]
    @azimuth = hash[:azimuth]
  end
  if hash[:tilt]
    @tilt = hash[:tilt]
  end
  if hash[:module_type]
    @module_type = hash[:module_type]

    # calculate area with PVWatts formulas
    # Size (kW) = Array Area (m²) × 1 kW/m² × Module Efficiency (%)
    # also grab module efficiency: 0 (standard) = 15%, 1 (premium) = 19%, 2 (thin film) = 10%
    eff = 0
    case @module_type
    when 0
      eff = 0.15
    when 1
      eff = 0.19
    when 2
      eff = 0.10
    end
    if @size_kw != 0
      @approx_area_m2 = (@size_kw / eff).round(3)
    end
  end
  if hash[:gcr]
    @gcr = hash[:gcr]
  end
  if hash[:average_yearly_energy_produced_kwh]
    @annual_energy_produced = hash[:average_yearly_energy_produced_kwh]
  end

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

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

Instance Attribute Details

#azimuthObject

Returns the value of attribute azimuth.



55
56
57
# File 'lib/urbanopt/reporting/default_reports/solar_pv.rb', line 55

def azimuth
  @azimuth
end

#locationObject

Returns the value of attribute location.



55
56
57
# File 'lib/urbanopt/reporting/default_reports/solar_pv.rb', line 55

def location
  @location
end

#module_typeObject

Returns the value of attribute module_type.



55
56
57
# File 'lib/urbanopt/reporting/default_reports/solar_pv.rb', line 55

def module_type
  @module_type
end

#size_kwObject

Float - power capacity in kilowatts



54
55
56
# File 'lib/urbanopt/reporting/default_reports/solar_pv.rb', line 54

def size_kw
  @size_kw
end

#tiltObject

Returns the value of attribute tilt.



55
56
57
# File 'lib/urbanopt/reporting/default_reports/solar_pv.rb', line 55

def tilt
  @tilt
end

Class Method Details

.add_pv(existing_pv, new_pv) ⇒ Object

Merge PV systems



133
134
135
136
137
138
139
140
141
# File 'lib/urbanopt/reporting/default_reports/solar_pv.rb', line 133

def self.add_pv(existing_pv, new_pv)
  if existing_pv.size_kw.nil? && new_pv.size_kw.nil?
    existing_pv.size_kw = nil
  else
    existing_pv.size_kw = (existing_pv.size_kw || 0) + (new_pv.size_kw || 0)
  end
  # KAF: todo, recalculate area?
  return existing_pv
end

Instance Method Details

#to_hashObject

Convert to a Hash equivalent for JSON serialization



115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/urbanopt/reporting/default_reports/solar_pv.rb', line 115

def to_hash
  result = {}

  result[:size_kw] = @size_kw if @size_kw
  result[:location] = @location if @location
  result[:azimuth] = @azimuth if @azimuth
  result[:tilt] = @tilt if @tilt
  result[:module_type] = @module_type if @module_type
  result[:approximate_area_m2] = @approx_area_m2 if @approx_area_m2
  result[:gcr] = @gcr if @gcr
  result[:average_yearly_energy_produced_kwh] = @annual_energy_produced if @annual_energy_produced

  return result
end