Skip to content

Commit

Permalink
Merge pull request #95 from urbanopt/microgrid-fields
Browse files Browse the repository at this point in the history
adding additional PV fields to UO output reports
  • Loading branch information
kflemin committed May 5, 2022
2 parents 94766c6 + 233b5b8 commit cc56f56
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 8 deletions.
12 changes: 11 additions & 1 deletion lib/urbanopt/reporting/default_reports/distributed_generation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ class DistributedGeneration
#
attr_accessor :probs_of_surviving_by_hour_of_the_day

##
# _String_ - Filepath of reopt assumptions file used, if known
attr_accessor :reopt_assumptions_file_path

##
# _Float_ - Annual percentage of electricity supplied by renewable sources
#
Expand Down Expand Up @@ -233,6 +237,12 @@ def initialize(hash = {})
@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
Expand Down Expand Up @@ -369,7 +379,7 @@ def add_tech(name, tech)
##
def to_hash
result = {}

result[:reopt_assumptions_file_path] = @reopt_assumptions_file_path if @reopt_assumptions_file_path
result[:annual_renewable_electricity_pct] = @annual_renewable_electricity_pct if @annual_renewable_electricity_pct
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
Expand Down
2 changes: 1 addition & 1 deletion lib/urbanopt/reporting/default_reports/feature_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def save(file_name = 'default_feature_report')
FileUtils.mkdir_p File.dirname(@timeseries_csv.path)
@timeseries_csv.save_data

## save json rport
## save json report
# feature_hash
feature_hash = to_hash

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@
"DistributedGeneration": {
"type": "object",
"properties": {
"reopt_assumptions_file_path": {
"description": "File path of REopt assumptions file used to generate results, if known",
"type": "string"
},
"annual_renewable_electricity_pct": {
"description": "Percentage of annual renewable electricity generation",
"type": "number"
Expand Down
45 changes: 39 additions & 6 deletions lib/urbanopt/reporting/default_reports/solar_pv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,39 @@ def initialize(hash = {})
@size_kw = hash[:size_kw]
@id = hash[:id]
@location = hash[:location]
@tilt = hash[:tilt]
@azimuth = hash[:azimuth]
@module_type = hash[:module_type]
@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
Expand All @@ -87,12 +117,15 @@ def initialize(hash = {})
##
def to_hash
result = {}

result[:size_kw] = @size_kw if @size_kw
result[:location] = @location if @location
result[:tilt] = @tilt if @tilt
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
Expand All @@ -106,7 +139,7 @@ def self.add_pv(existing_pv, new_pv)
else
existing_pv.size_kw = (existing_pv.size_kw || 0) + (new_pv.size_kw || 0)
end

# KAF: todo, recalculate area?
return existing_pv
end
end
Expand Down

0 comments on commit cc56f56

Please sign in to comment.