urbanopt-scenario 0.2.0.pre2 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/pull_request_template.md +2 -2
- data/.gitignore +2 -0
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +82 -1
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +28 -18
- data/Jenkinsfile +1 -1
- data/LICENSE.md +1 -1
- data/RDOC_MAIN.md +1 -1
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/docs/README.md +1 -1
- data/docs/package-lock.json +2499 -2322
- data/docs/package.json +13 -9
- data/lib/urbanopt-scenario.rb +1 -1
- data/lib/urbanopt/scenario.rb +3 -1
- data/lib/urbanopt/scenario/default_reports.rb +3 -8
- data/lib/urbanopt/scenario/extension.rb +1 -1
- data/lib/urbanopt/scenario/logger.rb +1 -1
- data/lib/urbanopt/scenario/scenario_base.rb +1 -1
- data/lib/urbanopt/scenario/scenario_csv.rb +22 -9
- data/lib/urbanopt/scenario/scenario_datapoint_base.rb +8 -1
- data/lib/urbanopt/scenario/scenario_post_processor_base.rb +1 -1
- data/lib/urbanopt/scenario/scenario_post_processor_default.rb +99 -8
- data/lib/urbanopt/scenario/scenario_post_processor_opendss.rb +275 -0
- data/lib/urbanopt/scenario/scenario_runner_base.rb +2 -2
- data/lib/urbanopt/scenario/scenario_runner_osw.rb +23 -9
- data/lib/urbanopt/scenario/scenario_visualization.rb +236 -0
- data/lib/urbanopt/scenario/simulation_dir_base.rb +1 -1
- data/lib/urbanopt/scenario/simulation_dir_osw.rb +2 -9
- data/lib/urbanopt/scenario/simulation_mapper_base.rb +1 -1
- data/lib/urbanopt/scenario/version.rb +2 -2
- data/package-lock.json +3 -0
- data/urbanopt-scenario-gem.gemspec +15 -15
- metadata +78 -82
- data/doc_templates/LICENSE.md +0 -27
- data/doc_templates/README.md.erb +0 -42
- data/doc_templates/copyright_erb.txt +0 -31
- data/doc_templates/copyright_js.txt +0 -4
- data/doc_templates/copyright_ruby.txt +0 -29
- data/lib/change_log.rb +0 -147
- data/lib/measures/.rubocop.yml +0 -5
- data/lib/measures/default_feature_reports/LICENSE.md +0 -27
- data/lib/measures/default_feature_reports/README.md +0 -56
- data/lib/measures/default_feature_reports/README.md.erb +0 -42
- data/lib/measures/default_feature_reports/measure.rb +0 -957
- data/lib/measures/default_feature_reports/measure.xml +0 -143
- data/lib/measures/default_feature_reports/tests/USA_CO_Golden-NREL.724666_TMY3.epw +0 -8768
- data/lib/measures/default_feature_reports/tests/default_feature_reports_test.rb +0 -238
- data/lib/measures/default_feature_reports/tests/example_model.osm +0 -4378
- data/lib/urbanopt/scenario/default_reports/construction_cost.rb +0 -169
- data/lib/urbanopt/scenario/default_reports/date.rb +0 -97
- data/lib/urbanopt/scenario/default_reports/distributed_generation.rb +0 -374
- data/lib/urbanopt/scenario/default_reports/end_use.rb +0 -159
- data/lib/urbanopt/scenario/default_reports/end_uses.rb +0 -140
- data/lib/urbanopt/scenario/default_reports/feature_report.rb +0 -260
- data/lib/urbanopt/scenario/default_reports/generator.rb +0 -92
- data/lib/urbanopt/scenario/default_reports/location.rb +0 -99
- data/lib/urbanopt/scenario/default_reports/logger.rb +0 -44
- data/lib/urbanopt/scenario/default_reports/program.rb +0 -266
- data/lib/urbanopt/scenario/default_reports/reporting_period.rb +0 -301
- data/lib/urbanopt/scenario/default_reports/scenario_report.rb +0 -311
- data/lib/urbanopt/scenario/default_reports/schema/README.md +0 -33
- data/lib/urbanopt/scenario/default_reports/schema/scenario_csv_columns.txt +0 -21
- data/lib/urbanopt/scenario/default_reports/schema/scenario_schema.json +0 -839
- data/lib/urbanopt/scenario/default_reports/solar_pv.rb +0 -93
- data/lib/urbanopt/scenario/default_reports/storage.rb +0 -105
- data/lib/urbanopt/scenario/default_reports/timeseries_csv.rb +0 -284
- data/lib/urbanopt/scenario/default_reports/validator.rb +0 -97
- data/lib/urbanopt/scenario/default_reports/wind.rb +0 -92
@@ -1,92 +0,0 @@
|
|
1
|
-
# *********************************************************************************
|
2
|
-
# URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
|
3
|
-
# contributors. All rights reserved.
|
4
|
-
#
|
5
|
-
# Redistribution and use in source and binary forms, with or without modification,
|
6
|
-
# are permitted provided that the following conditions are met:
|
7
|
-
#
|
8
|
-
# Redistributions of source code must retain the above copyright notice, this list
|
9
|
-
# of conditions and the following disclaimer.
|
10
|
-
#
|
11
|
-
# Redistributions in binary form must reproduce the above copyright notice, this
|
12
|
-
# list of conditions and the following disclaimer in the documentation and/or other
|
13
|
-
# materials provided with the distribution.
|
14
|
-
#
|
15
|
-
# Neither the name of the copyright holder nor the names of its contributors may be
|
16
|
-
# used to endorse or promote products derived from this software without specific
|
17
|
-
# prior written permission.
|
18
|
-
#
|
19
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
|
-
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
|
-
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
22
|
-
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
23
|
-
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
24
|
-
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
-
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
26
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
27
|
-
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
28
|
-
# OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
# *********************************************************************************
|
30
|
-
|
31
|
-
require 'json'
|
32
|
-
require 'json-schema'
|
33
|
-
|
34
|
-
module URBANopt
|
35
|
-
module Scenario
|
36
|
-
module DefaultReports
|
37
|
-
##
|
38
|
-
# Onsite generator system attributes
|
39
|
-
##
|
40
|
-
class Generator
|
41
|
-
##
|
42
|
-
# _Float_ - power capacity in kilowatts
|
43
|
-
#
|
44
|
-
attr_accessor :size_kw
|
45
|
-
|
46
|
-
##
|
47
|
-
# Intialize Generator attributes from a hash. Generator attributes currently are limited to power capacity.
|
48
|
-
##
|
49
|
-
# [parameters:]
|
50
|
-
#
|
51
|
-
# * +hash+ - _Hash_ - A hash containting a +:size_kw+ key/value pair which represents the nameplate capacity in kilowatts (kW)
|
52
|
-
#
|
53
|
-
def initialize(hash = {})
|
54
|
-
hash.delete_if { |k, v| v.nil? }
|
55
|
-
|
56
|
-
@size_kw = hash[:size_kw]
|
57
|
-
|
58
|
-
# initialize class variables @@validator and @@schema
|
59
|
-
@@validator ||= Validator.new
|
60
|
-
@@schema ||= @@validator.schema
|
61
|
-
|
62
|
-
# initialize @@logger
|
63
|
-
@@logger ||= URBANopt::Scenario::DefaultReports.logger
|
64
|
-
end
|
65
|
-
|
66
|
-
##
|
67
|
-
# Convert to a Hash equivalent for JSON serialization
|
68
|
-
##
|
69
|
-
def to_hash
|
70
|
-
result = {}
|
71
|
-
|
72
|
-
result[:size_kw] = @size_kw if @size_kw
|
73
|
-
|
74
|
-
return result
|
75
|
-
end
|
76
|
-
|
77
|
-
##
|
78
|
-
# Merge Generator systems
|
79
|
-
##
|
80
|
-
def self.add_generator(existing_generator, new_generator)
|
81
|
-
if existing_generator.size_kw.nil? && new_generator.size_kw.nil?
|
82
|
-
existing_generator.size_kw = nil
|
83
|
-
else
|
84
|
-
existing_generator.size_kw = (existing_generator.size_kw || 0) + (new_generator.size_kw || 0)
|
85
|
-
end
|
86
|
-
|
87
|
-
return existing_generator
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
# *********************************************************************************
|
2
|
-
# URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
|
3
|
-
# contributors. All rights reserved.
|
4
|
-
#
|
5
|
-
# Redistribution and use in source and binary forms, with or without modification,
|
6
|
-
# are permitted provided that the following conditions are met:
|
7
|
-
#
|
8
|
-
# Redistributions of source code must retain the above copyright notice, this list
|
9
|
-
# of conditions and the following disclaimer.
|
10
|
-
#
|
11
|
-
# Redistributions in binary form must reproduce the above copyright notice, this
|
12
|
-
# list of conditions and the following disclaimer in the documentation and/or other
|
13
|
-
# materials provided with the distribution.
|
14
|
-
#
|
15
|
-
# Neither the name of the copyright holder nor the names of its contributors may be
|
16
|
-
# used to endorse or promote products derived from this software without specific
|
17
|
-
# prior written permission.
|
18
|
-
#
|
19
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
|
-
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
|
-
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
22
|
-
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
23
|
-
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
24
|
-
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
-
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
26
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
27
|
-
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
28
|
-
# OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
# *********************************************************************************
|
30
|
-
|
31
|
-
require 'urbanopt/scenario/default_reports/validator'
|
32
|
-
require 'json-schema'
|
33
|
-
require 'json'
|
34
|
-
|
35
|
-
module URBANopt
|
36
|
-
module Scenario
|
37
|
-
module DefaultReports
|
38
|
-
##
|
39
|
-
# Location include all location information.
|
40
|
-
##
|
41
|
-
class Location
|
42
|
-
attr_accessor :latitude, :longitude, :surface_elevation, :weather_filename #:nodoc:
|
43
|
-
##
|
44
|
-
# Location class initialize location attributes: +:latitude+ , +:longitude+ , +:surface_elevation+ , +:weather_filename+
|
45
|
-
##
|
46
|
-
# [parameters:]
|
47
|
-
# +hash+ - _Hash_ - A hash which may contain a deserialized location.
|
48
|
-
##
|
49
|
-
def initialize(hash = {})
|
50
|
-
hash.delete_if { |k, v| v.nil? }
|
51
|
-
hash = defaults.merge(hash)
|
52
|
-
|
53
|
-
@latitude = hash[:latitude]
|
54
|
-
@longitude = hash[:longitude]
|
55
|
-
@surface_elevation = hash[:surface_elevation]
|
56
|
-
@weather_filename = hash[:weather_filename]
|
57
|
-
|
58
|
-
# initialize class variables @@validator and @@schema
|
59
|
-
@@validator ||= Validator.new
|
60
|
-
@@schema ||= @@validator.schema
|
61
|
-
end
|
62
|
-
|
63
|
-
##
|
64
|
-
# Convert to a Hash equivalent for JSON serialization.
|
65
|
-
##
|
66
|
-
# - Exclude attributes with nil values.
|
67
|
-
# - Validate location hash properties against schema.
|
68
|
-
##
|
69
|
-
def to_hash
|
70
|
-
result = {}
|
71
|
-
result[:latitude] = @latitude if @latitude
|
72
|
-
result[:longitude] = @longitude if @longitude
|
73
|
-
result[:surface_elevation] = @surface_elevation if @surface_elevation
|
74
|
-
result[:weather_filename] = @weather_filename if @weather_filename
|
75
|
-
|
76
|
-
# validate location properties against schema
|
77
|
-
if @@validator.validate(@@schema[:definitions][:Location][:properties], result).any?
|
78
|
-
raise "end_uses properties does not match schema: #{@@validator.validate(@@schema[:definitions][:Location][:properties], result)}"
|
79
|
-
end
|
80
|
-
|
81
|
-
return result
|
82
|
-
end
|
83
|
-
|
84
|
-
##
|
85
|
-
# Assign default values if values does not exist
|
86
|
-
##
|
87
|
-
def defaults
|
88
|
-
hash = {}
|
89
|
-
hash[:latitude] = nil
|
90
|
-
hash[:longitude] = nil
|
91
|
-
hash[:surface_elevation] = nil
|
92
|
-
hash[:weather_filename] = nil
|
93
|
-
|
94
|
-
return hash
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# *********************************************************************************
|
2
|
-
# URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
|
3
|
-
# contributors. All rights reserved.
|
4
|
-
#
|
5
|
-
# Redistribution and use in source and binary forms, with or without modification,
|
6
|
-
# are permitted provided that the following conditions are met:
|
7
|
-
#
|
8
|
-
# Redistributions of source code must retain the above copyright notice, this list
|
9
|
-
# of conditions and the following disclaimer.
|
10
|
-
#
|
11
|
-
# Redistributions in binary form must reproduce the above copyright notice, this
|
12
|
-
# list of conditions and the following disclaimer in the documentation and/or other
|
13
|
-
# materials provided with the distribution.
|
14
|
-
#
|
15
|
-
# Neither the name of the copyright holder nor the names of its contributors may be
|
16
|
-
# used to endorse or promote products derived from this software without specific
|
17
|
-
# prior written permission.
|
18
|
-
#
|
19
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
|
-
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
|
-
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
22
|
-
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
23
|
-
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
24
|
-
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
-
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
26
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
27
|
-
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
28
|
-
# OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
# *********************************************************************************
|
30
|
-
|
31
|
-
require 'logger'
|
32
|
-
|
33
|
-
module URBANopt
|
34
|
-
module Scenario
|
35
|
-
module DefaultReports
|
36
|
-
@@logger = Logger.new(STDOUT)
|
37
|
-
##
|
38
|
-
# Definining class variable "@@logger" to log errors, info and warning messages.
|
39
|
-
def self.logger
|
40
|
-
@@logger
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,266 +0,0 @@
|
|
1
|
-
# *********************************************************************************
|
2
|
-
# URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
|
3
|
-
# contributors. All rights reserved.
|
4
|
-
#
|
5
|
-
# Redistribution and use in source and binary forms, with or without modification,
|
6
|
-
# are permitted provided that the following conditions are met:
|
7
|
-
#
|
8
|
-
# Redistributions of source code must retain the above copyright notice, this list
|
9
|
-
# of conditions and the following disclaimer.
|
10
|
-
#
|
11
|
-
# Redistributions in binary form must reproduce the above copyright notice, this
|
12
|
-
# list of conditions and the following disclaimer in the documentation and/or other
|
13
|
-
# materials provided with the distribution.
|
14
|
-
#
|
15
|
-
# Neither the name of the copyright holder nor the names of its contributors may be
|
16
|
-
# used to endorse or promote products derived from this software without specific
|
17
|
-
# prior written permission.
|
18
|
-
#
|
19
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
|
-
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
|
-
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
22
|
-
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
23
|
-
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
24
|
-
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
-
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
26
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
27
|
-
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
28
|
-
# OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
# *********************************************************************************
|
30
|
-
|
31
|
-
require 'urbanopt/scenario/default_reports/validator'
|
32
|
-
require 'json-schema'
|
33
|
-
require 'json'
|
34
|
-
|
35
|
-
module URBANopt
|
36
|
-
module Scenario
|
37
|
-
module DefaultReports
|
38
|
-
##
|
39
|
-
# Program includes all building program related information.
|
40
|
-
##
|
41
|
-
class Program
|
42
|
-
attr_accessor :site_area, :floor_area, :conditioned_area, :unconditioned_area, :footprint_area, :maximum_roof_height,
|
43
|
-
:maximum_number_of_stories, :maximum_number_of_stories_above_ground, :parking_area, :number_of_parking_spaces,
|
44
|
-
:number_of_parking_spaces_charging, :parking_footprint_area, :maximum_parking_height, :maximum_number_of_parking_stories,
|
45
|
-
:maximum_number_of_parking_stories_above_ground, :number_of_residential_units, :building_types, :building_type, :maximum_occupancy,
|
46
|
-
:area, :window_area, :north_window_area, :south_window_area, :east_window_area, :west_window_area, :wall_area, :roof_area, :equipment_roof_area,
|
47
|
-
:photovoltaic_roof_area, :available_roof_area, :total_roof_area, :orientation, :aspect_ratio, :total_construction_cost # :nodoc:
|
48
|
-
# Program class initialize building program attributes: +:site_area+ , +:floor_area+ , +:conditioned_area+ , +:unconditioned_area+ ,
|
49
|
-
# +:footprint_area+ , +:maximum_roof_height, +:maximum_number_of_stories+ , +:maximum_number_of_stories_above_ground+ , +:parking_area+ ,
|
50
|
-
# +:number_of_parking_spaces+ , +:number_of_parking_spaces_charging+ , +:parking_footprint_area+ , +:maximum_parking_height+ , +:maximum_number_of_parking_stories+ ,
|
51
|
-
# +:maximum_number_of_parking_stories_above_ground+ , +:number_of_residential_units+ , +:building_types+ , +:building_type+ , +:maximum_occupancy+ ,
|
52
|
-
# +:area+ , +:window_area+ , +:north_window_area+ , +:south_window_area+ , +:east_window_area+ , +:west_window_area+ , +:wall_area+ , +:roof_area+ ,
|
53
|
-
# +:equipment_roof_area+ , +:photovoltaic_roof_area+ , +:available_roof_area+ , +:total_roof_area+ , +:orientation+ , +:aspect_ratio+
|
54
|
-
##
|
55
|
-
# [parameters:]
|
56
|
-
# +hash+ - _Hash_ - A hash which may contain a deserialized program.
|
57
|
-
##
|
58
|
-
def initialize(hash = {})
|
59
|
-
hash.delete_if { |k, v| v.nil? }
|
60
|
-
hash = defaults.merge(hash)
|
61
|
-
|
62
|
-
@site_area = hash[:site_area]
|
63
|
-
@floor_area = hash[:floor_area]
|
64
|
-
@conditioned_area = hash[:conditioned_area]
|
65
|
-
@unconditioned_area = hash[:unconditioned_area]
|
66
|
-
@footprint_area = hash[:footprint_area]
|
67
|
-
@maximum_roof_height = hash[:maximum_roof_height]
|
68
|
-
@maximum_number_of_stories = hash[:maximum_number_of_stories]
|
69
|
-
@maximum_number_of_stories_above_ground = hash[:maximum_number_of_stories_above_ground]
|
70
|
-
@parking_area = hash[:parking_area]
|
71
|
-
@number_of_parking_spaces = hash[:number_of_parking_spaces]
|
72
|
-
@number_of_parking_spaces_charging = hash[:number_of_parking_spaces_charging]
|
73
|
-
@parking_footprint_area = hash[:parking_footprint_area]
|
74
|
-
@maximum_parking_height = hash[:maximum_parking_height]
|
75
|
-
@maximum_number_of_parking_stories = hash[:maximum_number_of_parking_stories]
|
76
|
-
@maximum_number_of_parking_stories_above_ground = hash[:maximum_number_of_parking_stories_above_ground]
|
77
|
-
@number_of_residential_units = hash[:number_of_residential_units]
|
78
|
-
@building_types = hash[:building_types]
|
79
|
-
@window_area = hash[:window_area]
|
80
|
-
@wall_area = hash[:wall_area]
|
81
|
-
@roof_area = hash[:roof_area]
|
82
|
-
@orientation = hash[:orientation]
|
83
|
-
@aspect_ratio = hash[:aspect_ratio]
|
84
|
-
@total_construction_cost = hash[:total_construction_cost]
|
85
|
-
|
86
|
-
# initialize class variables @@validator and @@schema
|
87
|
-
@@validator ||= Validator.new
|
88
|
-
@@schema ||= @@validator.schema
|
89
|
-
end
|
90
|
-
|
91
|
-
##
|
92
|
-
# Assigns default values if values do not exist.
|
93
|
-
##
|
94
|
-
def defaults
|
95
|
-
hash = {}
|
96
|
-
hash[:site_area] = nil
|
97
|
-
hash[:floor_area] = nil
|
98
|
-
hash[:conditioned_area] = nil
|
99
|
-
hash[:unconditioned_area] = nil
|
100
|
-
hash[:footprint_area] = nil
|
101
|
-
hash[:maximum_roof_height] = nil
|
102
|
-
hash[:maximum_number_of_stories] = nil
|
103
|
-
hash[:maximum_number_of_stories_above_ground] = nil
|
104
|
-
hash[:parking_area] = nil
|
105
|
-
hash[:number_of_parking_spaces] = nil
|
106
|
-
hash[:number_of_parking_spaces_charging] = nil
|
107
|
-
hash[:parking_footprint_area] = nil
|
108
|
-
hash[:maximum_parking_height] = nil
|
109
|
-
hash[:maximum_number_of_parking_stories] = nil
|
110
|
-
hash[:maximum_number_of_parking_stories_above_ground] = nil
|
111
|
-
hash[:number_of_residential_units] = nil
|
112
|
-
hash[:building_types] = [{ building_type: nil, maximum_occupancy: nil, floor_area: nil }]
|
113
|
-
hash[:window_area] = { north_window_area: nil, south_window_area: nil, east_window_area: nil, west_window_area: nil, total_window_area: nil }
|
114
|
-
hash[:wall_area] = { north_wall_area: nil, south_wall_area: nil, east_wall_area: nil, west_wall_area: nil, total_wall_area: nil }
|
115
|
-
hash[:roof_area] = { equipment_roof_area: nil, photovoltaic_roof_area: nil, available_roof_area: nil, total_roof_area: nil }
|
116
|
-
hash[:orientation] = nil
|
117
|
-
hash[:aspect_ratio] = nil
|
118
|
-
hash[:total_construction_cost] = nil
|
119
|
-
return hash
|
120
|
-
end
|
121
|
-
|
122
|
-
##
|
123
|
-
# Convert to a Hash equivalent for JSON serialization.
|
124
|
-
##
|
125
|
-
# - Exclude attributes with nil values.
|
126
|
-
# - Validate program hash properties against schema.
|
127
|
-
##
|
128
|
-
def to_hash
|
129
|
-
result = {}
|
130
|
-
result[:site_area] = @site_area if @site_area
|
131
|
-
result[:floor_area] = @floor_area if @floor_area
|
132
|
-
result[:conditioned_area] = @conditioned_area if @conditioned_area
|
133
|
-
result[:unconditioned_area] = @unconditioned_area if @unconditioned_area
|
134
|
-
result[:footprint_area] = @footprint_area if @footprint_area
|
135
|
-
result[:maximum_roof_height] = @maximum_roof_height if @maximum_roof_height
|
136
|
-
result[:maximum_number_of_stories] = @maximum_number_of_stories if @maximum_number_of_stories
|
137
|
-
result[:maximum_number_of_stories_above_ground] = @maximum_number_of_stories_above_ground if @maximum_number_of_parking_stories_above_ground
|
138
|
-
result[:parking_area] = @parking_area if @parking_area
|
139
|
-
result[:number_of_parking_spaces] = @number_of_parking_spaces if @number_of_parking_spaces
|
140
|
-
result[:number_of_parking_spaces_charging] = @number_of_parking_spaces_charging if @number_of_parking_spaces_charging
|
141
|
-
result[:parking_footprint_area] = @parking_footprint_area if @parking_footprint_area
|
142
|
-
result[:maximum_parking_height] = @maximum_parking_height if @maximum_parking_height
|
143
|
-
result[:maximum_number_of_parking_stories] = @maximum_number_of_parking_stories if @maximum_number_of_parking_stories
|
144
|
-
result[:maximum_number_of_parking_stories_above_ground] = @maximum_number_of_parking_stories_above_ground if @maximum_number_of_parking_stories_above_ground
|
145
|
-
result[:number_of_residential_units] = @number_of_residential_units if @number_of_residential_units
|
146
|
-
|
147
|
-
if @building_types.any?
|
148
|
-
result[:building_types] = @building_types
|
149
|
-
@building_types.each do |bt|
|
150
|
-
bt.delete_if { |k, v| v.nil? } if bt
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
# result[:window_area] = @window_area if @window_area
|
155
|
-
window_area_hash = @window_area if @window_area
|
156
|
-
window_area_hash.delete_if { |k, v| v.nil? }
|
157
|
-
result[:window_area] = window_area_hash if @window_area
|
158
|
-
|
159
|
-
# result[:wall_area] = @wall_area if @wall_area
|
160
|
-
wall_area_hash = @wall_area if @wall_area
|
161
|
-
wall_area_hash.delete_if { |k, v| v.nil? }
|
162
|
-
result[:wall_area] = wall_area_hash if @wall_area
|
163
|
-
|
164
|
-
# result[:roof_area] = @roof_area if @roof_area
|
165
|
-
roof_area_hash = @roof_area if @roof_area
|
166
|
-
roof_area_hash.delete_if { |k, v| v.nil? }
|
167
|
-
result[:roof_area] = roof_area_hash if @roof_area
|
168
|
-
|
169
|
-
result[:orientation] = @orientation if @orientation
|
170
|
-
result[:aspect_ratio] = @aspect_ratio if @aspect_ratio
|
171
|
-
|
172
|
-
result[:total_construction_cost] = @total_construction_cost if @total_construction_cost
|
173
|
-
|
174
|
-
# validate program properties against schema
|
175
|
-
if @@validator.validate(@@schema[:definitions][:Program][:properties], result).any?
|
176
|
-
raise "program properties does not match schema: #{@@validator.validate(@@schema[:definitions][:Program][:properties], result)}"
|
177
|
-
end
|
178
|
-
|
179
|
-
return result
|
180
|
-
end
|
181
|
-
|
182
|
-
##
|
183
|
-
# Return the maximum value from +existing_value+ and +new_value+.
|
184
|
-
##
|
185
|
-
# [parameters:]
|
186
|
-
# +existing_value+ - _Float_ - A value corresponding to a Program attribute.
|
187
|
-
##
|
188
|
-
# +new_value+ - _Float_ - A value corresponding to a Program attribute.
|
189
|
-
##
|
190
|
-
def max_value(existing_value, new_value)
|
191
|
-
if existing_value && new_value
|
192
|
-
[existing_value, new_value].max
|
193
|
-
elsif new_value
|
194
|
-
existing_value = new_value
|
195
|
-
end
|
196
|
-
return existing_value
|
197
|
-
end
|
198
|
-
|
199
|
-
##
|
200
|
-
# Adds up +existing_value+ and +new_values+ if not nill.
|
201
|
-
##
|
202
|
-
# [parameters:]
|
203
|
-
# +existing_value+ - _Float_ - A value corresponding to a Program attribute.
|
204
|
-
##
|
205
|
-
# +new_value+ - _Float_ - A value corresponding to a Program attribute.
|
206
|
-
##
|
207
|
-
def add_values(existing_value, new_value)
|
208
|
-
if existing_value && new_value
|
209
|
-
existing_value += new_value
|
210
|
-
elsif new_value
|
211
|
-
existing_value = new_value
|
212
|
-
end
|
213
|
-
return existing_value
|
214
|
-
end
|
215
|
-
|
216
|
-
##
|
217
|
-
# Merges program objects to each other by summing up values or taking the maximum value of the attributes.
|
218
|
-
##
|
219
|
-
# [parameters:]
|
220
|
-
# +other+ - _Program_ - An object of Program class.
|
221
|
-
##
|
222
|
-
# rubocop:disable Metrics/AbcSize # :nodoc:
|
223
|
-
def add_program(other)
|
224
|
-
@site_area = add_values(@site_area, other.site_area)
|
225
|
-
|
226
|
-
@floor_area = add_values(@floor_area, other.floor_area)
|
227
|
-
@conditioned_area = add_values(@conditioned_area, other.conditioned_area)
|
228
|
-
@unconditioned_area = add_values(@unconditioned_area, other.unconditioned_area)
|
229
|
-
@footprint_area = add_values(@footprint_area, other.footprint_area)
|
230
|
-
@maximum_roof_height = max_value(@maximum_roof_height, other.maximum_roof_height)
|
231
|
-
@maximum_number_of_stories = max_value(@maximum_number_of_stories, other.maximum_number_of_stories)
|
232
|
-
@maximum_number_of_stories_above_ground = max_value(@maximum_number_of_stories_above_ground, other.maximum_number_of_stories_above_ground)
|
233
|
-
@parking_area = add_values(@parking_area, other.parking_area)
|
234
|
-
@number_of_parking_spaces = add_values(@number_of_parking_spaces, other.number_of_parking_spaces)
|
235
|
-
@number_of_parking_spaces_charging = add_values(@number_of_parking_spaces_charging, other.number_of_parking_spaces_charging)
|
236
|
-
@parking_footprint_area = add_values(@parkig_footprint_area, other.parking_footprint_area)
|
237
|
-
@maximum_parking_height = max_value(@maximum_parking_height, other.maximum_parking_height)
|
238
|
-
@maximum_number_of_parking_stories = max_value(@maximum_number_of_parking_stories, other.maximum_number_of_parking_stories)
|
239
|
-
@maximum_number_of_parking_stories_above_ground = max_value(maximum_number_of_parking_stories_above_ground, other.maximum_number_of_parking_stories_above_ground)
|
240
|
-
@number_of_residential_units = add_values(@number_of_residential_units, other.number_of_residential_units)
|
241
|
-
@total_construction_cost = add_values(@total_construction_cost, other.total_construction_cost)
|
242
|
-
|
243
|
-
@building_types = other.building_types
|
244
|
-
|
245
|
-
@window_area[:north_window_area] = add_values(@window_area[:north_window_area], other.window_area[:north_window_area])
|
246
|
-
@window_area[:south_window_area] = add_values(@window_area[:south_window_area], other.window_area[:south_window_area])
|
247
|
-
@window_area[:east_window_area] = add_values(@window_area[:east_window_area], other.window_area[:east_window_area])
|
248
|
-
@window_area[:west_window_area] = add_values(@window_area[:west_window_area], other.window_area[:west_window_area])
|
249
|
-
@window_area[:total_window_area] = add_values(@window_area[:total_window_area], other.window_area[:total_window_area])
|
250
|
-
|
251
|
-
@wall_area[:north_wall_area] = add_values(@wall_area[:north_wall_area], other.wall_area[:north_wall_area])
|
252
|
-
@wall_area[:south_wall_area] = add_values(@wall_area[:south_wall_area], other.wall_area[:south_wall_area])
|
253
|
-
@wall_area[:east_wall_area] = add_values(@wall_area[:east_wall_area], other.wall_area[:east_wall_area])
|
254
|
-
@wall_area[:west_wall_area] = add_values(@wall_area[:west_wall_area], other.wall_area[:west_wall_area])
|
255
|
-
@wall_area[:total_wall_area] = add_values(@wall_area[:total_wall_area], other.wall_area[:total_wall_area])
|
256
|
-
|
257
|
-
@roof_area[:equipment_roof_area] = add_values(@roof_area[:equipment_roof_area], other.roof_area[:equipment_roof_area])
|
258
|
-
@roof_area[:photovoltaic_roof_area] = add_values(@roof_area[:photovoltaic_roof_area], other.roof_area[:photovoltaic_roof_area])
|
259
|
-
@roof_area[:available_roof_area] = add_values(@roof_area[:available_roof_area], other.roof_area[:available_roof_area])
|
260
|
-
@roof_area[:total_roof_area] = add_values(@roof_area[:total_roof_area], other.roof_area[:total_roof_area])
|
261
|
-
end
|
262
|
-
# rubocop:enable Metrics/AbcSize
|
263
|
-
end
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|