honeybee-openstudio 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +32 -0
- data/.releaserc.json +7 -0
- data/.travis.yml +41 -0
- data/Gemfile +18 -0
- data/LICENSE.md +23 -0
- data/README.md +95 -0
- data/Rakefile +21 -0
- data/doc_templates/LICENSE.md +23 -0
- data/doc_templates/copyright_erb.txt +32 -0
- data/doc_templates/copyright_js.txt +5 -0
- data/doc_templates/copyright_ruby.txt +30 -0
- data/honeybee-openstudio.gemspec +35 -0
- data/lib/files/Honeybee.rb +113 -0
- data/lib/files/honeybee_workflow.osw +48 -0
- data/lib/files/urbanopt_Gemfile +32 -0
- data/lib/from_honeybee.rb +86 -0
- data/lib/from_honeybee/_openapi/model.json +8127 -0
- data/lib/from_honeybee/_openapi/simulation-parameter.json +843 -0
- data/lib/from_honeybee/construction/air.rb +65 -0
- data/lib/from_honeybee/construction/opaque.rb +77 -0
- data/lib/from_honeybee/construction/shade.rb +108 -0
- data/lib/from_honeybee/construction/window.rb +80 -0
- data/lib/from_honeybee/construction_set.rb +278 -0
- data/lib/from_honeybee/extension.rb +109 -0
- data/lib/from_honeybee/geometry/aperture.rb +167 -0
- data/lib/from_honeybee/geometry/door.rb +160 -0
- data/lib/from_honeybee/geometry/face.rb +163 -0
- data/lib/from_honeybee/geometry/room.rb +392 -0
- data/lib/from_honeybee/geometry/shade.rb +89 -0
- data/lib/from_honeybee/hvac/ideal_air.rb +150 -0
- data/lib/from_honeybee/load/electric_equipment.rb +96 -0
- data/lib/from_honeybee/load/gas_equipment.rb +97 -0
- data/lib/from_honeybee/load/infiltration.rb +95 -0
- data/lib/from_honeybee/load/lighting.rb +98 -0
- data/lib/from_honeybee/load/people.rb +100 -0
- data/lib/from_honeybee/load/setpoint_humidistat.rb +75 -0
- data/lib/from_honeybee/load/setpoint_thermostat.rb +71 -0
- data/lib/from_honeybee/load/ventilation.rb +96 -0
- data/lib/from_honeybee/material/opaque.rb +94 -0
- data/lib/from_honeybee/material/opaque_no_mass.rb +94 -0
- data/lib/from_honeybee/material/window_blind.rb +238 -0
- data/lib/from_honeybee/material/window_gas.rb +76 -0
- data/lib/from_honeybee/material/window_gas_custom.rb +118 -0
- data/lib/from_honeybee/material/window_gas_mixture.rb +79 -0
- data/lib/from_honeybee/material/window_glazing.rb +166 -0
- data/lib/from_honeybee/material/window_shade.rb +160 -0
- data/lib/from_honeybee/material/window_simpleglazsys.rb +73 -0
- data/lib/from_honeybee/model.rb +434 -0
- data/lib/from_honeybee/model_object.rb +110 -0
- data/lib/from_honeybee/program_type.rb +124 -0
- data/lib/from_honeybee/schedule/fixed_interval.rb +115 -0
- data/lib/from_honeybee/schedule/ruleset.rb +164 -0
- data/lib/from_honeybee/schedule/type_limit.rb +88 -0
- data/lib/from_honeybee/simulation/designday.rb +105 -0
- data/lib/from_honeybee/simulation/extension.rb +46 -0
- data/lib/from_honeybee/simulation/parameter.rb +277 -0
- data/lib/from_honeybee/version.rb +34 -0
- data/lib/measures/.gitkeep +0 -0
- data/lib/measures/from_honeybee_model/LICENSE.md +27 -0
- data/lib/measures/from_honeybee_model/README.md +32 -0
- data/lib/measures/from_honeybee_model/measure.rb +91 -0
- data/lib/measures/from_honeybee_model/measure.xml +103 -0
- data/lib/measures/from_honeybee_model/tests/from_honeybee_model_test.rb +126 -0
- data/lib/measures/from_honeybee_simulation_parameter/LICENSE.md +27 -0
- data/lib/measures/from_honeybee_simulation_parameter/README.md +32 -0
- data/lib/measures/from_honeybee_simulation_parameter/measure.rb +95 -0
- data/lib/measures/from_honeybee_simulation_parameter/measure.xml +91 -0
- data/lib/measures/from_honeybee_simulation_parameter/tests/from_honeybee_simulation_parameter_test.rb +109 -0
- metadata +243 -0
@@ -0,0 +1,88 @@
|
|
1
|
+
# *******************************************************************************
|
2
|
+
# Honeybee OpenStudio Gem, Copyright (c) 2020, Alliance for Sustainable
|
3
|
+
# Energy, LLC, Ladybug Tools LLC and other contributors. All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# (1) Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# (3) Neither the name of the copyright holder nor the names of any contributors
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission from the respective party.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
|
20
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
21
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
|
23
|
+
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
|
24
|
+
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
25
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
26
|
+
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
28
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
29
|
+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
# *******************************************************************************
|
31
|
+
|
32
|
+
require 'from_honeybee/extension'
|
33
|
+
require 'from_honeybee/model_object'
|
34
|
+
|
35
|
+
require 'openstudio'
|
36
|
+
|
37
|
+
module FromHoneybee
|
38
|
+
class ScheduleTypeLimit < ModelObject
|
39
|
+
attr_reader :errors, :warnings
|
40
|
+
|
41
|
+
def initialize(hash = {})
|
42
|
+
super(hash)
|
43
|
+
|
44
|
+
raise "Incorrect model type '#{@type}'" unless @type == 'ScheduleTypeLimit'
|
45
|
+
end
|
46
|
+
|
47
|
+
def defaults
|
48
|
+
@@schema[:components][:schemas][:ScheduleTypeLimit][:properties]
|
49
|
+
end
|
50
|
+
|
51
|
+
def find_existing_openstudio_object(openstudio_model)
|
52
|
+
object = openstudio_model.getScheduleTypeLimitsByName(@hash[:identifier])
|
53
|
+
return object.get if object.is_initialized
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
|
57
|
+
def to_openstudio(openstudio_model)
|
58
|
+
# create schedule type limits openstudio object
|
59
|
+
os_type_limit = OpenStudio::Model::ScheduleTypeLimits.new(openstudio_model)
|
60
|
+
os_type_limit.setName(@hash[:identifier])
|
61
|
+
|
62
|
+
if @hash[:lower_limit] != nil and @hash[:lower_limit] != {'type': 'NoLimit'}
|
63
|
+
os_type_limit.setLowerLimitValue(@hash[:lower_limit])
|
64
|
+
end
|
65
|
+
|
66
|
+
if @hash[:upper_limit] != nil and @hash[:upper_limit] != {'type': 'NoLimit'}
|
67
|
+
os_type_limit.setUpperLimitValue(@hash[:upper_limit])
|
68
|
+
end
|
69
|
+
|
70
|
+
# assign numeric type
|
71
|
+
if @hash[:numeric_type]
|
72
|
+
os_type_limit.setNumericType(@hash[:numeric_type])
|
73
|
+
else
|
74
|
+
os_type_limit.setNumericType(defaults[:numeric_type])
|
75
|
+
end
|
76
|
+
|
77
|
+
# assign unit type
|
78
|
+
if @hash[:unit_type]
|
79
|
+
os_type_limit.setUnitType(@hash[:unit_type])
|
80
|
+
else
|
81
|
+
os_type_limit.setUnitType(defaults[:unit_type])
|
82
|
+
end
|
83
|
+
|
84
|
+
os_type_limit
|
85
|
+
end
|
86
|
+
|
87
|
+
end # ScheduleTypeLimit
|
88
|
+
end # FromHoneybee
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# *******************************************************************************
|
2
|
+
# Honeybee OpenStudio Gem, Copyright (c) 2020, Alliance for Sustainable
|
3
|
+
# Energy, LLC, Ladybug Tools LLC and other contributors. All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# (1) Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# (3) Neither the name of the copyright holder nor the names of any contributors
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission from the respective party.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
|
20
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
21
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
|
23
|
+
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
|
24
|
+
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
25
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
26
|
+
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
28
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
29
|
+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
# *******************************************************************************
|
31
|
+
|
32
|
+
require 'from_honeybee/model_object'
|
33
|
+
|
34
|
+
require 'openstudio'
|
35
|
+
|
36
|
+
module FromHoneybee
|
37
|
+
class DesignDay < ModelObject
|
38
|
+
attr_reader :errors, :warnings
|
39
|
+
|
40
|
+
def initialize(hash = {})
|
41
|
+
super(hash)
|
42
|
+
end
|
43
|
+
|
44
|
+
def defaults
|
45
|
+
@@schema[:components][:schemas][:DesignDay][:properties]
|
46
|
+
end
|
47
|
+
|
48
|
+
def find_existing_openstudio_object(openstudio_model)
|
49
|
+
object = openstudio_model.getDesignDayByName(@hash[:name])
|
50
|
+
return object.get if object.is_initialized
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_openstudio(openstudio_model)
|
55
|
+
# create the DesignDay object
|
56
|
+
os_des_day = OpenStudio::Model::DesignDay.new(openstudio_model)
|
57
|
+
os_des_day.setName(@hash[:name])
|
58
|
+
os_des_day.setDayType(@hash[:day_type])
|
59
|
+
|
60
|
+
# set the DryBulbCondition properties
|
61
|
+
os_des_day.setMaximumDryBulbTemperature(@hash[:dry_bulb_condition][:dry_bulb_max])
|
62
|
+
os_des_day.setDailyDryBulbTemperatureRange(@hash[:dry_bulb_condition][:dry_bulb_range])
|
63
|
+
|
64
|
+
# set the HumidityCondition properties
|
65
|
+
os_des_day.setHumidityIndicatingType(@hash[:humidity_condition][:humidity_type])
|
66
|
+
os_des_day.setHumidityIndicatingConditionsAtMaximumDryBulb(@hash[:humidity_condition][:humidity_value])
|
67
|
+
if @hash[:humidity_condition][:barometric_pressure]
|
68
|
+
os_des_day.setBarometricPressure(@hash[:humidity_condition][:barometric_pressure])
|
69
|
+
end
|
70
|
+
if @hash[:humidity_condition][:rain]
|
71
|
+
os_des_day.setRainIndicator(@hash[:humidity_condition][:rain])
|
72
|
+
end
|
73
|
+
if @hash[:humidity_condition][:snow_on_ground]
|
74
|
+
os_des_day.setSnowIndicator(@hash[:humidity_condition][:snow_on_ground])
|
75
|
+
end
|
76
|
+
|
77
|
+
# set the WindCondition properties
|
78
|
+
os_des_day.setWindSpeed(@hash[:wind_condition][:wind_speed])
|
79
|
+
if @hash[:wind_condition][:wind_direction]
|
80
|
+
os_des_day.setWindDirection(@hash[:wind_condition][:wind_direction])
|
81
|
+
end
|
82
|
+
|
83
|
+
# set the SkyCondition properties
|
84
|
+
os_des_day.setMonth(@hash[:sky_condition][:date][0])
|
85
|
+
os_des_day.setDayOfMonth(@hash[:sky_condition][:date][1])
|
86
|
+
os_des_day.setSolarModelIndicator(@hash[:sky_condition][:type])
|
87
|
+
if @hash[:sky_condition][:daylight_savings]
|
88
|
+
os_des_day.setDaylightSavingTimeIndicator(@hash[:sky_condition][:daylight_savings])
|
89
|
+
end
|
90
|
+
|
91
|
+
# ASHRAEClearSky SkyCondition
|
92
|
+
if @hash[:sky_condition][:type] == "ASHRAEClearSky"
|
93
|
+
os_des_day.setSkyClearness(@hash[:sky_condition][:clearness])
|
94
|
+
end
|
95
|
+
|
96
|
+
# ASHRAETau SkyCondition
|
97
|
+
if @hash[:sky_condition][:type] == "ASHRAETau"
|
98
|
+
os_des_day.setAshraeTaub(@hash[:sky_condition][:tau_b])
|
99
|
+
os_des_day.setAshraeTaud(@hash[:sky_condition][:tau_d])
|
100
|
+
end
|
101
|
+
|
102
|
+
os_des_day
|
103
|
+
end
|
104
|
+
end # DesignDay
|
105
|
+
end # FromHoneybee
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# *******************************************************************************
|
2
|
+
# Honeybee OpenStudio Gem, Copyright (c) 2020, Alliance for Sustainable
|
3
|
+
# Energy, LLC, Ladybug Tools LLC and other contributors. All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# (1) Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# (3) Neither the name of the copyright holder nor the names of any contributors
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission from the respective party.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
|
20
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
21
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
|
23
|
+
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
|
24
|
+
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
25
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
26
|
+
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
28
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
29
|
+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
# *******************************************************************************
|
31
|
+
|
32
|
+
require 'openstudio/extension'
|
33
|
+
|
34
|
+
require 'from_honeybee/extension'
|
35
|
+
|
36
|
+
|
37
|
+
module FromHoneybee
|
38
|
+
class ExtensionSimulationParameter < FromHoneybee::Extension
|
39
|
+
@@schema = nil
|
40
|
+
|
41
|
+
def schema_file
|
42
|
+
File.join(@lib_dir, 'from_honeybee', '_openapi', 'simulation-parameter.json')
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,277 @@
|
|
1
|
+
# *******************************************************************************
|
2
|
+
# Honeybee OpenStudio Gem, Copyright (c) 2020, Alliance for Sustainable
|
3
|
+
# Energy, LLC, Ladybug Tools LLC and other contributors. All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# (1) Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# (3) Neither the name of the copyright holder nor the names of any contributors
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission from the respective party.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
|
20
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
21
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
|
23
|
+
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
|
24
|
+
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
25
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
26
|
+
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
28
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
29
|
+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
# *******************************************************************************
|
31
|
+
|
32
|
+
require 'from_honeybee/model_object'
|
33
|
+
require 'from_honeybee/simulation/extension'
|
34
|
+
require 'from_honeybee/simulation/designday'
|
35
|
+
|
36
|
+
require 'openstudio'
|
37
|
+
|
38
|
+
module FromHoneybee
|
39
|
+
class SimulationParameter
|
40
|
+
attr_reader :errors, :warnings
|
41
|
+
|
42
|
+
# Read Simulation Parameter JSON from disk
|
43
|
+
def self.read_from_disk(file)
|
44
|
+
hash = nil
|
45
|
+
File.open(File.join(file), 'r') do |f|
|
46
|
+
hash = JSON.parse(f.read, symbolize_names: true)
|
47
|
+
end
|
48
|
+
|
49
|
+
SimulationParameter.new(hash)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Load ModelObject from symbolized hash
|
53
|
+
def initialize(hash)
|
54
|
+
# initialize class variable @@extension only once
|
55
|
+
@@extension = ExtensionSimulationParameter.new
|
56
|
+
@@schema = nil
|
57
|
+
File.open(@@extension.schema_file) do |f|
|
58
|
+
@@schema = JSON.parse(f.read, symbolize_names: true)
|
59
|
+
end
|
60
|
+
|
61
|
+
@hash = hash
|
62
|
+
@type = @hash[:type]
|
63
|
+
raise 'Unknown model type' if @type.nil?
|
64
|
+
raise "Incorrect model type for SimulationParameter '#{@type}'" unless @type == 'SimulationParameter'
|
65
|
+
end
|
66
|
+
|
67
|
+
# check if the model is valid
|
68
|
+
def valid?
|
69
|
+
if Gem.loaded_specs.has_key?("json-schema")
|
70
|
+
return validation_errors.empty?
|
71
|
+
else
|
72
|
+
return true
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# return detailed model validation errors
|
77
|
+
def validation_errors
|
78
|
+
if Gem.loaded_specs.has_key?("json-schema")
|
79
|
+
require 'json-schema'
|
80
|
+
JSON::Validator.fully_validate(@@schema, @hash)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def defaults
|
85
|
+
@@schema[:components][:schemas]
|
86
|
+
end
|
87
|
+
|
88
|
+
# convert to openstudio model, clears errors and warnings
|
89
|
+
def to_openstudio_model(openstudio_model=nil, log_report=false)
|
90
|
+
@errors = []
|
91
|
+
@warnings = []
|
92
|
+
|
93
|
+
if log_report
|
94
|
+
puts 'Starting SimulationParameter translation from Honeybee to OpenStudio'
|
95
|
+
end
|
96
|
+
@openstudio_model = if openstudio_model
|
97
|
+
openstudio_model
|
98
|
+
else
|
99
|
+
OpenStudio::Model::Model.new
|
100
|
+
end
|
101
|
+
|
102
|
+
create_openstudio_objects
|
103
|
+
|
104
|
+
if log_report
|
105
|
+
puts 'Done with SimulationParameter translation!'
|
106
|
+
end
|
107
|
+
|
108
|
+
@openstudio_model
|
109
|
+
end
|
110
|
+
|
111
|
+
def create_openstudio_objects
|
112
|
+
# get the defaults for each sub-object
|
113
|
+
simct_defaults = defaults[:SimulationControl][:properties]
|
114
|
+
shdw_defaults = defaults[:ShadowCalculation][:properties]
|
115
|
+
siz_defaults = defaults[:SizingParameter][:properties]
|
116
|
+
out_defaults = defaults[:SimulationOutput][:properties]
|
117
|
+
runper_defaults = defaults[:RunPeriod][:properties]
|
118
|
+
simpar_defaults = defaults[:SimulationParameter][:properties]
|
119
|
+
|
120
|
+
# set defaults for the Model's SimulationControl object
|
121
|
+
os_sim_control = @openstudio_model.getSimulationControl
|
122
|
+
os_sim_control.setDoZoneSizingCalculation(simct_defaults[:do_zone_sizing][:default])
|
123
|
+
os_sim_control.setDoSystemSizingCalculation(simct_defaults[:do_system_sizing][:default])
|
124
|
+
os_sim_control.setDoPlantSizingCalculation(simct_defaults[:do_plant_sizing][:default])
|
125
|
+
os_sim_control.setRunSimulationforWeatherFileRunPeriods(simct_defaults[:run_for_run_periods][:default])
|
126
|
+
os_sim_control.setRunSimulationforSizingPeriods(simct_defaults[:run_for_sizing_periods][:default])
|
127
|
+
os_sim_control.setSolarDistribution(shdw_defaults[:solar_distribution][:default])
|
128
|
+
|
129
|
+
# override any SimulationControl defaults with lodaded JSON
|
130
|
+
if @hash[:simulation_control]
|
131
|
+
unless @hash[:simulation_control][:do_zone_sizing].nil?
|
132
|
+
os_sim_control.setDoZoneSizingCalculation(@hash[:simulation_control][:do_zone_sizing])
|
133
|
+
end
|
134
|
+
unless @hash[:simulation_control][:do_system_sizing].nil?
|
135
|
+
os_sim_control.setDoSystemSizingCalculation(@hash[:simulation_control][:do_system_sizing])
|
136
|
+
end
|
137
|
+
unless @hash[:simulation_control][:do_plant_sizing].nil?
|
138
|
+
os_sim_control.setDoPlantSizingCalculation(@hash[:simulation_control][:do_plant_sizing])
|
139
|
+
end
|
140
|
+
unless @hash[:simulation_control][:run_for_run_periods].nil?
|
141
|
+
os_sim_control.setRunSimulationforWeatherFileRunPeriods(@hash[:simulation_control][:run_for_run_periods])
|
142
|
+
end
|
143
|
+
unless @hash[:simulation_control][:run_for_sizing_periods].nil?
|
144
|
+
os_sim_control.setRunSimulationforSizingPeriods(@hash[:simulation_control][:run_for_sizing_periods])
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# set defaults for the Model's ShadowCalculation object
|
149
|
+
os_shadow_calc = @openstudio_model.getShadowCalculation
|
150
|
+
os_shadow_calc.setCalculationFrequency(shdw_defaults[:calculation_frequency][:default])
|
151
|
+
os_shadow_calc.setMaximumFiguresInShadowOverlapCalculations(shdw_defaults[:maximum_figures][:default])
|
152
|
+
os_shadow_calc.setCalculationMethod(shdw_defaults[:calculation_method][:default])
|
153
|
+
|
154
|
+
# override any ShadowCalculation defaults with lodaded JSON
|
155
|
+
if @hash[:shadow_calculation]
|
156
|
+
if @hash[:shadow_calculation][:calculation_frequency]
|
157
|
+
os_shadow_calc.setCalculationFrequency(@hash[:shadow_calculation][:calculation_frequency])
|
158
|
+
end
|
159
|
+
if @hash[:shadow_calculation][:maximum_figures]
|
160
|
+
os_shadow_calc.setMaximumFiguresInShadowOverlapCalculations(@hash[:shadow_calculation][:maximum_figures])
|
161
|
+
end
|
162
|
+
if @hash[:shadow_calculation][:calculation_method]
|
163
|
+
os_shadow_calc.setCalculationMethod(@hash[:shadow_calculation][:calculation_method])
|
164
|
+
end
|
165
|
+
if @hash[:shadow_calculation][:solar_distribution]
|
166
|
+
os_sim_control.setSolarDistribution(@hash[:shadow_calculation][:solar_distribution])
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
# set defaults for the Model's SizingParameter object
|
171
|
+
os_sizing_par = @openstudio_model.getSizingParameters
|
172
|
+
os_sizing_par.setHeatingSizingFactor(siz_defaults[:heating_factor][:default])
|
173
|
+
os_sizing_par.setCoolingSizingFactor(siz_defaults[:cooling_factor][:default])
|
174
|
+
|
175
|
+
# override any SizingParameter defaults with lodaded JSON
|
176
|
+
if @hash[:sizing_parameter]
|
177
|
+
if @hash[:sizing_parameter][:heating_factor]
|
178
|
+
os_sizing_par.setHeatingSizingFactor(@hash[:sizing_parameter][:heating_factor])
|
179
|
+
end
|
180
|
+
if @hash[:sizing_parameter][:cooling_factor]
|
181
|
+
os_sizing_par.setCoolingSizingFactor(@hash[:sizing_parameter][:cooling_factor])
|
182
|
+
end
|
183
|
+
# set any design days
|
184
|
+
if @hash[:sizing_parameter][:design_days]
|
185
|
+
@hash[:sizing_parameter][:design_days].each do |des_day|
|
186
|
+
des_day_object = DesignDay.new(des_day)
|
187
|
+
os_des_day = des_day_object.to_openstudio(@openstudio_model)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
# set Outputs for the simulation
|
193
|
+
if @hash[:output]
|
194
|
+
if @hash[:output][:outputs]
|
195
|
+
@hash[:output][:outputs].each do |output|
|
196
|
+
os_output = OpenStudio::Model::OutputVariable.new(output, @openstudio_model)
|
197
|
+
if @hash[:output][:reporting_frequency]
|
198
|
+
os_output.setReportingFrequency(@hash[:output][:reporting_frequency])
|
199
|
+
else
|
200
|
+
os_output.setReportingFrequency(out_defaults[:reporting_frequency][:default])
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
if @hash[:output][:summary_reports]
|
205
|
+
begin
|
206
|
+
os_report = OpenStudio::Model::OutputTableSummaryReports.new(@openstudio_model)
|
207
|
+
rescue NameError
|
208
|
+
end
|
209
|
+
@hash[:output][:summary_reports].each do |report|
|
210
|
+
begin
|
211
|
+
os_report.addSummaryReport(report)
|
212
|
+
rescue NoMethodError
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
# set defaults for the year description
|
219
|
+
year_description = @openstudio_model.getYearDescription
|
220
|
+
year_description.setDayofWeekforStartDay(runper_defaults[:start_day_of_week][:default])
|
221
|
+
|
222
|
+
# set up the simulation RunPeriod
|
223
|
+
if @hash[:run_period]
|
224
|
+
# set the leap year
|
225
|
+
if @hash[:run_period][:leap_year]
|
226
|
+
year_description.setIsLeapYear(@hash[:run_period][:leap_year])
|
227
|
+
end
|
228
|
+
|
229
|
+
# set the start day of the week
|
230
|
+
if @hash[:run_period][:start_day_of_week]
|
231
|
+
year_description.setDayofWeekforStartDay(@hash[:run_period][:start_day_of_week])
|
232
|
+
end
|
233
|
+
|
234
|
+
# set the run preiod start and end dates
|
235
|
+
openstudio_runperiod = @openstudio_model.getRunPeriod
|
236
|
+
openstudio_runperiod.setBeginMonth(@hash[:run_period][:start_date][0])
|
237
|
+
openstudio_runperiod.setBeginDayOfMonth(@hash[:run_period][:start_date][1])
|
238
|
+
openstudio_runperiod.setEndMonth(@hash[:run_period][:end_date][0])
|
239
|
+
openstudio_runperiod.setEndDayOfMonth(@hash[:run_period][:end_date][1])
|
240
|
+
|
241
|
+
# set the daylight savings time
|
242
|
+
if @hash[:run_period][:daylight_saving_time]
|
243
|
+
os_dl_saving = @openstudio_model.getRunPeriodControlDaylightSavingTime
|
244
|
+
os_dl_saving.setStartDate(
|
245
|
+
OpenStudio::MonthOfYear.new(@hash[:run_period][:daylight_saving_time][:start_date][0]),
|
246
|
+
@hash[:run_period][:daylight_saving_time][:start_date][1])
|
247
|
+
os_dl_saving.setEndDate(
|
248
|
+
OpenStudio::MonthOfYear.new(@hash[:run_period][:daylight_saving_time][:end_date][0]),
|
249
|
+
@hash[:run_period][:daylight_saving_time][:end_date][1])
|
250
|
+
end
|
251
|
+
|
252
|
+
# TODO: set the holidays once they are available in OpenStudio SDK
|
253
|
+
end
|
254
|
+
|
255
|
+
# set the simulation timestep
|
256
|
+
os_timestep = @openstudio_model.getTimestep
|
257
|
+
if @hash[:timestep]
|
258
|
+
os_timestep.setNumberOfTimestepsPerHour(@hash[:timestep])
|
259
|
+
else
|
260
|
+
os_timestep.setNumberOfTimestepsPerHour(simpar_defaults[:timestep][:default])
|
261
|
+
end
|
262
|
+
|
263
|
+
# assign the north
|
264
|
+
if @hash[:north_angle]
|
265
|
+
@openstudio_model.getBuilding.setNorthAxis(-@hash[:north_angle])
|
266
|
+
end
|
267
|
+
|
268
|
+
# assign the terrain
|
269
|
+
os_site = @openstudio_model.getSite
|
270
|
+
os_site.setTerrain(simpar_defaults[:terrain_type][:default])
|
271
|
+
if @hash[:terrain_type]
|
272
|
+
os_site.setTerrain(@hash[:terrain_type])
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
end #SimulationParameter
|
277
|
+
end #FromHoneybee
|