Class: URBANopt::Reporting::DefaultReports::ThermalStorage

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

Overview

Ice Thermal Storage Systems

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ ThermalStorage

Returns a new instance of ThermalStorage.



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 61

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

  @its_size = hash[:its_size_kwh]
  @ptes_size = hash[:ptes_size_kwh]

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

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

Instance Attribute Details

#its_size_kwhObject

Float - Total ice storage capacity on central plant loop in kWh



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

def its_size_kwh
  @its_size_kwh
end

#ptes_size_kwhObject

Float - Total ice storage capacity distributed to packaged systems in kWh



59
60
61
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 59

def ptes_size_kwh
  @ptes_size_kwh
end

Class Method Details

.add_values(existing_value, new_value) ⇒ Object

Add up old and new values



100
101
102
103
104
105
106
107
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 100

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_thermal_storage(existing_tes, new_tes) ⇒ Object

Merge thermal storage



112
113
114
115
116
117
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 112

def self.merge_thermal_storage(existing_tes, new_tes)
  existing_tes.its_size_kwh = add_values(existing_tes.its_size_kwh, new_tes.its_size_kwh)
  existing_tes.ptes_size_kwh = add_values(existing_tes.ptes_size_kwh, new_tes.ptes_size_kwh)

  return existing_tes
end

Instance Method Details

#defaultsObject

Assigns default values if attribute values do not exist.



78
79
80
81
82
83
84
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 78

def defaults
  hash = {}
  hash[:its_size_kwh] = nil
  hash[:ptes_size_kwh] = nil

  return hash
end

#to_hashObject

Convert to hash equivalent for JSON serialization



89
90
91
92
93
94
95
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 89

def to_hash
  result = {}
  result[:its_size_kwh] = @its_size_kwh if @its_size_kwh
  result[:ptes_size_kwh] = @ptes_size_kwh if @ptes_size_kwh

  return result
end