honeybee-openstudio 0 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +5 -5
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +32 -33
  4. data/.releaserc.json +7 -7
  5. data/.travis.yml +41 -0
  6. data/Gemfile +18 -14
  7. data/LICENSE.md +23 -23
  8. data/README.md +95 -95
  9. data/Rakefile +21 -16
  10. data/doc_templates/LICENSE.md +23 -23
  11. data/doc_templates/copyright_erb.txt +31 -31
  12. data/doc_templates/copyright_js.txt +4 -4
  13. data/doc_templates/copyright_ruby.txt +29 -29
  14. data/honeybee-openstudio.gemspec +35 -38
  15. data/lib/files/Honeybee.rb +112 -112
  16. data/lib/files/honeybee_workflow.osw +47 -47
  17. data/lib/files/urbanopt_Gemfile +32 -32
  18. data/lib/{honeybee/_defaults → from_honeybee/_openapi}/model.json +8126 -11310
  19. data/lib/{honeybee/_defaults → from_honeybee/_openapi}/simulation-parameter.json +842 -972
  20. data/lib/{to_openstudio → from_honeybee}/construction/air.rb +65 -56
  21. data/lib/{to_openstudio → from_honeybee}/construction/opaque.rb +77 -67
  22. data/lib/{to_openstudio → from_honeybee}/construction/shade.rb +108 -99
  23. data/lib/{to_openstudio → from_honeybee}/construction/window.rb +80 -70
  24. data/lib/{to_openstudio → from_honeybee}/construction_set.rb +278 -266
  25. data/lib/{honeybee → from_honeybee}/extension.rb +109 -129
  26. data/lib/{to_openstudio → from_honeybee}/geometry/aperture.rb +167 -157
  27. data/lib/{to_openstudio → from_honeybee}/geometry/door.rb +160 -150
  28. data/lib/{to_openstudio → from_honeybee}/geometry/face.rb +163 -178
  29. data/lib/{to_openstudio → from_honeybee}/geometry/room.rb +392 -442
  30. data/lib/{to_openstudio → from_honeybee}/geometry/shade.rb +89 -79
  31. data/lib/{to_openstudio → from_honeybee}/hvac/ideal_air.rb +150 -141
  32. data/lib/{to_openstudio → from_honeybee}/load/electric_equipment.rb +96 -87
  33. data/lib/{to_openstudio → from_honeybee}/load/gas_equipment.rb +97 -88
  34. data/lib/{to_openstudio → from_honeybee}/load/infiltration.rb +94 -85
  35. data/lib/{to_openstudio → from_honeybee}/load/lighting.rb +98 -89
  36. data/lib/{to_openstudio → from_honeybee}/load/people.rb +100 -91
  37. data/lib/{to_openstudio → from_honeybee}/load/setpoint_humidistat.rb +75 -66
  38. data/lib/{to_openstudio → from_honeybee}/load/setpoint_thermostat.rb +71 -62
  39. data/lib/{to_openstudio → from_honeybee}/load/ventilation.rb +96 -87
  40. data/lib/{to_openstudio → from_honeybee}/material/opaque.rb +94 -85
  41. data/lib/{to_openstudio → from_honeybee}/material/opaque_no_mass.rb +94 -85
  42. data/lib/{to_openstudio → from_honeybee}/material/window_blind.rb +238 -229
  43. data/lib/{to_openstudio → from_honeybee}/material/window_gas.rb +76 -67
  44. data/lib/{to_openstudio → from_honeybee}/material/window_gas_custom.rb +118 -108
  45. data/lib/{to_openstudio → from_honeybee}/material/window_gas_mixture.rb +79 -70
  46. data/lib/{to_openstudio → from_honeybee}/material/window_glazing.rb +166 -157
  47. data/lib/{to_openstudio → from_honeybee}/material/window_shade.rb +160 -151
  48. data/lib/{to_openstudio → from_honeybee}/material/window_simpleglazsys.rb +73 -64
  49. data/lib/from_honeybee/model.rb +434 -0
  50. data/lib/{honeybee → from_honeybee}/model_object.rb +110 -108
  51. data/lib/{to_openstudio → from_honeybee}/program_type.rb +124 -104
  52. data/lib/{to_openstudio → from_honeybee}/schedule/fixed_interval.rb +115 -105
  53. data/lib/{to_openstudio → from_honeybee}/schedule/ruleset.rb +164 -164
  54. data/lib/{to_openstudio → from_honeybee}/schedule/type_limit.rb +88 -76
  55. data/lib/{to_openstudio/simulation/design_day.rb → from_honeybee/simulation/designday.rb} +105 -96
  56. data/lib/{honeybee/load/lighting.rb → from_honeybee/simulation/extension.rb} +46 -43
  57. data/lib/{to_openstudio/simulation/parameter_model.rb → from_honeybee/simulation/parameter.rb} +277 -243
  58. data/lib/{honeybee/simulation/design_day.rb → from_honeybee/version.rb} +34 -42
  59. data/lib/{honeybee.rb → from_honeybee.rb} +86 -93
  60. data/lib/measures/from_honeybee_model/LICENSE.md +27 -23
  61. data/lib/measures/from_honeybee_model/README.md +32 -32
  62. data/lib/measures/from_honeybee_model/measure.rb +91 -91
  63. data/lib/measures/from_honeybee_model/measure.xml +103 -80
  64. data/lib/measures/from_honeybee_model/tests/from_honeybee_model_test.rb +126 -126
  65. data/lib/measures/from_honeybee_simulation_parameter/LICENSE.md +27 -23
  66. data/lib/measures/from_honeybee_simulation_parameter/README.md +32 -32
  67. data/lib/measures/from_honeybee_simulation_parameter/measure.rb +95 -95
  68. data/lib/measures/from_honeybee_simulation_parameter/measure.xml +91 -86
  69. data/lib/measures/from_honeybee_simulation_parameter/tests/from_honeybee_simulation_parameter_test.rb +109 -109
  70. metadata +89 -147
  71. data/.github/workflows/ci.yaml +0 -88
  72. data/doc_templates/README.md.erb +0 -42
  73. data/lib/from_openstudio/geometry/aperture.rb +0 -136
  74. data/lib/from_openstudio/geometry/door.rb +0 -136
  75. data/lib/from_openstudio/geometry/face.rb +0 -174
  76. data/lib/from_openstudio/geometry/room.rb +0 -121
  77. data/lib/from_openstudio/geometry/shade.rb +0 -87
  78. data/lib/from_openstudio/model.rb +0 -123
  79. data/lib/from_openstudio/model_object.rb +0 -43
  80. data/lib/from_openstudio/simulation/design_day.rb +0 -123
  81. data/lib/from_openstudio/simulation/parameter_model.rb +0 -93
  82. data/lib/from_openstudio/simulation/simulation_output.rb +0 -67
  83. data/lib/from_openstudio.rb +0 -49
  84. data/lib/honeybee/_defaults/energy_default.json +0 -1682
  85. data/lib/honeybee/construction/air.rb +0 -42
  86. data/lib/honeybee/construction/opaque.rb +0 -42
  87. data/lib/honeybee/construction/shade.rb +0 -42
  88. data/lib/honeybee/construction/window.rb +0 -51
  89. data/lib/honeybee/construction/windowshade.rb +0 -43
  90. data/lib/honeybee/construction_set.rb +0 -42
  91. data/lib/honeybee/geometry/aperture.rb +0 -42
  92. data/lib/honeybee/geometry/door.rb +0 -42
  93. data/lib/honeybee/geometry/face.rb +0 -48
  94. data/lib/honeybee/geometry/room.rb +0 -56
  95. data/lib/honeybee/geometry/shade.rb +0 -42
  96. data/lib/honeybee/hvac/ideal_air.rb +0 -42
  97. data/lib/honeybee/hvac/template.rb +0 -73
  98. data/lib/honeybee/load/electric_equipment.rb +0 -42
  99. data/lib/honeybee/load/gas_equipment.rb +0 -42
  100. data/lib/honeybee/load/infiltration.rb +0 -42
  101. data/lib/honeybee/load/people.rb +0 -42
  102. data/lib/honeybee/load/setpoint_humidistat.rb +0 -46
  103. data/lib/honeybee/load/setpoint_thermostat.rb +0 -46
  104. data/lib/honeybee/load/ventilation.rb +0 -42
  105. data/lib/honeybee/material/opaque.rb +0 -42
  106. data/lib/honeybee/material/opaque_no_mass.rb +0 -42
  107. data/lib/honeybee/material/window_blind.rb +0 -42
  108. data/lib/honeybee/material/window_gas.rb +0 -42
  109. data/lib/honeybee/material/window_gas_custom.rb +0 -42
  110. data/lib/honeybee/material/window_gas_mixture.rb +0 -42
  111. data/lib/honeybee/material/window_glazing.rb +0 -42
  112. data/lib/honeybee/material/window_shade.rb +0 -42
  113. data/lib/honeybee/material/window_simpleglazsys.rb +0 -42
  114. data/lib/honeybee/model.rb +0 -87
  115. data/lib/honeybee/program_type.rb +0 -56
  116. data/lib/honeybee/schedule/fixed_interval.rb +0 -42
  117. data/lib/honeybee/schedule/ruleset.rb +0 -42
  118. data/lib/honeybee/schedule/type_limit.rb +0 -42
  119. data/lib/honeybee/simulation/parameter_model.rb +0 -86
  120. data/lib/honeybee/simulation/simulation_output.rb +0 -42
  121. data/lib/honeybee/ventcool/control.rb +0 -42
  122. data/lib/honeybee/ventcool/opening.rb +0 -46
  123. data/lib/honeybee/ventcool/simulation.rb +0 -42
  124. data/lib/to_openstudio/construction/windowshade.rb +0 -196
  125. data/lib/to_openstudio/hvac/Model.hvac.rb +0 -641
  126. data/lib/to_openstudio/hvac/template.rb +0 -169
  127. data/lib/to_openstudio/model.rb +0 -497
  128. data/lib/to_openstudio/model_object.rb +0 -52
  129. data/lib/to_openstudio/ventcool/control.rb +0 -185
  130. data/lib/to_openstudio/ventcool/opening.rb +0 -189
  131. data/lib/to_openstudio/ventcool/simulation.rb +0 -101
  132. data/lib/to_openstudio.rb +0 -92
@@ -1,129 +1,109 @@
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
- # NOTE: This file has been derived from one within the openStudio-extension gem
35
- # The properties here are a standard part of openstudio extensions
36
-
37
- module Honeybee
38
- class Extension < OpenStudio::Extension::Extension
39
- @@schema = nil
40
- @@standards = nil
41
-
42
- # Override parent class
43
- def initialize
44
- super
45
-
46
- # Note that the root_dir is only meaningful when the gem is in a github repository
47
- # When installed as a Ruby gem, the highest directory within the gem is the lib_dir
48
- @root_dir = File.absolute_path(File.join(File.dirname(__FILE__), '..', '..'))
49
- @lib_dir = File.absolute_path(File.join(File.dirname(__FILE__), '..'))
50
-
51
- @instance_lock = Mutex.new
52
- @@schema ||= schema
53
- @@standards ||= standards
54
- end
55
-
56
- # Return the absolute path of the measures or nil if there is none.
57
- # Can be used when configuring OSWs
58
- def measures_dir
59
- File.absolute_path(File.join(@lib_dir, 'measures'))
60
- end
61
-
62
- # Relevant files such as the openapi JSON schema files for the honeybee model.
63
- # Return the absolute path of the files or nil if there is none.
64
- # Used when configuring OSWs
65
- def files_dir
66
- File.absolute_path(File.join(@lib_dir, 'files'))
67
- end
68
-
69
- # Doc templates are common files like copyright files which are used to update measures
70
- # Doc templates will only be applied when the gem is a part of a repository
71
- # Return the absolute path of the doc templates dir or nil if there is none
72
- def doc_templates_dir
73
- File.absolute_path(File.join(@root_dir, 'doc_templates'))
74
- end
75
-
76
- # return path to the model schema file
77
- def schema_file
78
- File.join(@lib_dir, 'honeybee', '_defaults', 'model.json')
79
- end
80
-
81
- # return path to the model standards file
82
- def standards_file
83
- File.join(@lib_dir, 'honeybee', '_defaults', 'energy_default.json')
84
- end
85
-
86
- # return the model schema
87
- def schema
88
- @instance_lock.synchronize do
89
- if @@schema.nil?
90
- File.open(schema_file, 'r') do |f|
91
- @@schema = JSON.parse(f.read, symbolize_names: true)
92
- end
93
- end
94
- end
95
-
96
- @@schema
97
- end
98
-
99
- # return the JSON of default standards
100
- def standards
101
- @instance_lock.synchronize do
102
- if @@standards.nil?
103
- File.open(standards_file, 'r') do |f|
104
- @@standards = JSON.parse(f.read, symbolize_names: true)
105
- end
106
- end
107
- end
108
-
109
- @@standards
110
- end
111
-
112
- # check if the model schema is valid
113
- def schema_valid?
114
- if Gem.loaded_specs.has_key?("json-schema")
115
- require 'json-schema'
116
- metaschema = JSON::Validator.validator_for_name('draft6').metaschema
117
- JSON::Validator.validate(metaschema, @@schema)
118
- end
119
- end
120
-
121
- # return detailed schema validation errors
122
- def schema_validation_errors
123
- if Gem.loaded_specs.has_key?("json-schema")
124
- metaschema = JSON::Validator.validator_for_name('draft6').metaschema
125
- JSON::Validator.fully_validate(metaschema, @@schema)
126
- end
127
- end
128
- end
129
- end
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
+ # NOTE: This file has been derived from one within the openStudio-extension gem
35
+ # The properties here are a standard part of openstudio extensions
36
+
37
+ module FromHoneybee
38
+ class Extension < OpenStudio::Extension::Extension
39
+ @@schema = nil
40
+
41
+ # Override parent class
42
+ def initialize
43
+ super
44
+
45
+ # Note that the root_dir is only meaningful when the gem is in a github repository
46
+ # When installed as a Ruby gem, the highest directory within the gem is the lib_dir
47
+ @root_dir = File.absolute_path(File.join(File.dirname(__FILE__), '..', '..'))
48
+ @lib_dir = File.absolute_path(File.join(File.dirname(__FILE__), '..'))
49
+
50
+ @instance_lock = Mutex.new
51
+ @@schema ||= schema
52
+ end
53
+
54
+ # Return the absolute path of the measures or nil if there is none.
55
+ # Can be used when configuring OSWs
56
+ def measures_dir
57
+ File.absolute_path(File.join(@lib_dir, 'measures'))
58
+ end
59
+
60
+ # Relevant files such as the openapi JSON schema files for the honeybee model.
61
+ # Return the absolute path of the files or nil if there is none.
62
+ # Used when configuring OSWs
63
+ def files_dir
64
+ File.absolute_path(File.join(@lib_dir, 'files'))
65
+ end
66
+
67
+ # Doc templates are common files like copyright files which are used to update measures
68
+ # Doc templates will only be applied when the gem is a part of a repository
69
+ # Return the absolute path of the doc templates dir or nil if there is none
70
+ def doc_templates_dir
71
+ File.absolute_path(File.join(@root_dir, 'doc_templates'))
72
+ end
73
+
74
+ # return path to the model schema file
75
+ def schema_file
76
+ File.join(@lib_dir, 'from_honeybee', '_openapi', 'model.json')
77
+ end
78
+
79
+ # return the model schema
80
+ def schema
81
+ @instance_lock.synchronize do
82
+ if @@schema.nil?
83
+ File.open(schema_file, 'r') do |f|
84
+ @@schema = JSON.parse(f.read, symbolize_names: true)
85
+ end
86
+ end
87
+ end
88
+
89
+ @@schema
90
+ end
91
+
92
+ # check if the model schema is valid
93
+ def schema_valid?
94
+ if Gem.loaded_specs.has_key?("json-schema")
95
+ require 'json-schema'
96
+ metaschema = JSON::Validator.validator_for_name('draft6').metaschema
97
+ JSON::Validator.validate(metaschema, @@schema)
98
+ end
99
+ end
100
+
101
+ # return detailed schema validation errors
102
+ def schema_validation_errors
103
+ if Gem.loaded_specs.has_key?("json-schema")
104
+ metaschema = JSON::Validator.validator_for_name('draft6').metaschema
105
+ JSON::Validator.fully_validate(metaschema, @@schema)
106
+ end
107
+ end
108
+ end
109
+ end
@@ -1,157 +1,167 @@
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 'honeybee/geometry/aperture'
33
-
34
- require 'to_openstudio/model_object'
35
-
36
- module Honeybee
37
- class Aperture < ModelObject
38
-
39
- def find_existing_openstudio_object(openstudio_model)
40
- object = openstudio_model.getSubSurfaceByName(@hash[:identifier])
41
- return object.get if object.is_initialized
42
- nil
43
- end
44
-
45
- def to_openstudio(openstudio_model)
46
- # create the OpenStudio aperture object
47
- os_vertices = OpenStudio::Point3dVector.new
48
- @hash[:geometry][:boundary].each do |vertex|
49
- os_vertices << OpenStudio::Point3d.new(vertex[0], vertex[1], vertex[2])
50
- end
51
- reordered_vertices = OpenStudio.reorderULC(os_vertices)
52
-
53
- # triangulate subsurface if neccesary
54
- triangulated = false
55
- final_vertices_list = []
56
- matching_os_subsurfaces = []
57
- matching_os_subsurface_indices = []
58
- if reordered_vertices.size > 4
59
-
60
- # if this apeture has a matched apeture, see if the other one has already been created
61
- # the matched apeture should have been converted to multiple subsurfaces
62
- if @hash[:boundary_condition][:type] == 'Surface'
63
- adj_srf_identifier = @hash[:boundary_condition][:boundary_condition_objects][0]
64
- regex = Regexp.new("#{adj_srf_identifier}\.\.(\\d+)")
65
- openstudio_model.getSubSurfaces.each do |subsurface|
66
- if md = regex.match(subsurface.nameString)
67
- final_vertices_list << OpenStudio.reorderULC(OpenStudio::reverse(subsurface.vertices))
68
- matching_os_subsurfaces << subsurface
69
- matching_os_subsurface_indices << md[1]
70
- end
71
- end
72
- end
73
-
74
- # if other apeture is not already created, do the triangulation
75
- if final_vertices_list.empty?
76
-
77
- # transform to face coordinates
78
- t = OpenStudio::Transformation::alignFace(reordered_vertices)
79
- tInv = t.inverse
80
- face_vertices = OpenStudio::reverse(tInv*reordered_vertices)
81
-
82
- # no holes in the subsurface
83
- holes = OpenStudio::Point3dVectorVector.new
84
-
85
- # triangulate surface
86
- triangles = OpenStudio::computeTriangulation(face_vertices, holes)
87
- if triangles.empty?
88
- raise "Failed to triangulate aperture #{@hash[:identifier]} with #{reordered_vertices.size} vertices"
89
- end
90
-
91
- # create new list of surfaces
92
- triangles.each do |vertices|
93
- final_vertices_list << OpenStudio.reorderULC(OpenStudio::reverse(t*vertices))
94
- end
95
-
96
- triangulated = true
97
-
98
- end
99
-
100
- else
101
- # reordered_vertices are good as is
102
- final_vertices_list << reordered_vertices
103
- end
104
-
105
- result = []
106
- final_vertices_list.each_with_index do |reordered_vertices, index|
107
- os_subsurface = OpenStudio::Model::SubSurface.new(reordered_vertices, openstudio_model)
108
-
109
- if !matching_os_subsurfaces.empty?
110
- os_subsurface.setName(@hash[:identifier] + "..#{matching_os_subsurface_indices[index]}")
111
- elsif triangulated
112
- os_subsurface.setName(@hash[:identifier] + "..#{index}")
113
- else
114
- os_subsurface.setName(@hash[:identifier])
115
- end
116
-
117
- # assign the construction if it exists
118
- if @hash[:properties][:energy][:construction]
119
- construction_identifier = @hash[:properties][:energy][:construction]
120
- construction = openstudio_model.getConstructionByName(construction_identifier)
121
- unless construction.empty?
122
- os_construction = construction.get
123
- os_subsurface.setConstruction(os_construction)
124
- end
125
- end
126
-
127
- # assign the boundary condition object if it's a Surface
128
- if @hash[:boundary_condition][:type] == 'Surface'
129
- if !matching_os_subsurfaces.empty?
130
- # we already have the match because this was created from the matching_os_subsurfaces
131
- # setAdjacentSubSurface will fail at this point because sub surface is not assigned to surface yet, store data for later
132
- adj_srf_identifier = matching_os_subsurfaces[index].nameString
133
- os_subsurface.additionalProperties.setFeature("AdjacentSubSurfaceName", adj_srf_identifier)
134
- elsif triangulated
135
- # other subsurfaces haven't been created yet, no-op
136
- else
137
- # get adjacent sub surface by identifier from openstudio model
138
- # setAdjacentSubSurface will fail at this point because sub surface is not assigned to surface yet, store data for later
139
- adj_srf_identifier = @hash[:boundary_condition][:boundary_condition_objects][0]
140
- os_subsurface.additionalProperties.setFeature("AdjacentSubSurfaceName", adj_srf_identifier)
141
- end
142
- end
143
-
144
- # assign the operable property
145
- if @hash[:is_operable] == false
146
- os_subsurface.setSubSurfaceType('FixedWindow')
147
- else
148
- os_subsurface.setSubSurfaceType('OperableWindow')
149
- end
150
-
151
- result << os_subsurface
152
- end
153
-
154
- return result
155
- end
156
- end # Aperture
157
- end # Honeybee
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 Aperture < ModelObject
38
+ attr_reader :errors, :warnings
39
+
40
+ def initialize(hash)
41
+ super(hash)
42
+ raise "Incorrect model type '#{@type}'" unless @type == 'Aperture'
43
+ end
44
+
45
+ def defaults
46
+ @@schema[:components][:schemas][:ApertureEnergyPropertiesAbridged][:properties]
47
+ end
48
+
49
+ def find_existing_openstudio_object(openstudio_model)
50
+ object = openstudio_model.getSubSurfaceByName(@hash[:identifier])
51
+ return object.get if object.is_initialized
52
+ nil
53
+ end
54
+
55
+ def to_openstudio(openstudio_model)
56
+ # create the OpenStudio aperture object
57
+ os_vertices = OpenStudio::Point3dVector.new
58
+ @hash[:geometry][:boundary].each do |vertex|
59
+ os_vertices << OpenStudio::Point3d.new(vertex[0], vertex[1], vertex[2])
60
+ end
61
+ reordered_vertices = OpenStudio.reorderULC(os_vertices)
62
+
63
+ # triangulate subsurface if neccesary
64
+ triangulated = false
65
+ final_vertices_list = []
66
+ matching_os_subsurfaces = []
67
+ matching_os_subsurface_indices = []
68
+ if reordered_vertices.size > 4
69
+
70
+ # if this apeture has a matched apeture, see if the other one has already been created
71
+ # the matched apeture should have been converted to multiple subsurfaces
72
+ if @hash[:boundary_condition][:type] == 'Surface'
73
+ adj_srf_identifier = @hash[:boundary_condition][:boundary_condition_objects][0]
74
+ regex = Regexp.new("#{adj_srf_identifier}\.\.(\\d+)")
75
+ openstudio_model.getSubSurfaces.each do |subsurface|
76
+ if md = regex.match(subsurface.nameString)
77
+ final_vertices_list << OpenStudio.reorderULC(OpenStudio::reverse(subsurface.vertices))
78
+ matching_os_subsurfaces << subsurface
79
+ matching_os_subsurface_indices << md[1]
80
+ end
81
+ end
82
+ end
83
+
84
+ # if other apeture is not already created, do the triangulation
85
+ if final_vertices_list.empty?
86
+
87
+ # transform to face coordinates
88
+ t = OpenStudio::Transformation::alignFace(reordered_vertices)
89
+ tInv = t.inverse
90
+ face_vertices = OpenStudio::reverse(tInv*reordered_vertices)
91
+
92
+ # no holes in the subsurface
93
+ holes = OpenStudio::Point3dVectorVector.new
94
+
95
+ # triangulate surface
96
+ triangles = OpenStudio::computeTriangulation(face_vertices, holes)
97
+ if triangles.empty?
98
+ raise "Failed to triangulate aperture #{@hash[:identifier]} with #{reordered_vertices.size} vertices"
99
+ end
100
+
101
+ # create new list of surfaces
102
+ triangles.each do |vertices|
103
+ final_vertices_list << OpenStudio.reorderULC(OpenStudio::reverse(t*vertices))
104
+ end
105
+
106
+ triangulated = true
107
+
108
+ end
109
+
110
+ else
111
+ # reordered_vertices are good as is
112
+ final_vertices_list << reordered_vertices
113
+ end
114
+
115
+ result = []
116
+ final_vertices_list.each_with_index do |reordered_vertices, index|
117
+ os_subsurface = OpenStudio::Model::SubSurface.new(reordered_vertices, openstudio_model)
118
+
119
+ if !matching_os_subsurfaces.empty?
120
+ os_subsurface.setName(@hash[:identifier] + "..#{matching_os_subsurface_indices[index]}")
121
+ elsif triangulated
122
+ os_subsurface.setName(@hash[:identifier] + "..#{index}")
123
+ else
124
+ os_subsurface.setName(@hash[:identifier])
125
+ end
126
+
127
+ # assign the construction if it exists
128
+ if @hash[:properties][:energy][:construction]
129
+ construction_identifier = @hash[:properties][:energy][:construction]
130
+ construction = openstudio_model.getConstructionByName(construction_identifier)
131
+ unless construction.empty?
132
+ os_construction = construction.get
133
+ os_subsurface.setConstruction(os_construction)
134
+ end
135
+ end
136
+
137
+ # assign the boundary condition object if it's a Surface
138
+ if @hash[:boundary_condition][:type] == 'Surface'
139
+ if !matching_os_subsurfaces.empty?
140
+ # we already have the match because this was created from the matching_os_subsurfaces
141
+ # setAdjacentSubSurface will fail at this point because sub surface is not assigned to surface yet, store data for later
142
+ adj_srf_identifier = matching_os_subsurfaces[index].nameString
143
+ os_subsurface.additionalProperties.setFeature("AdjacentSubSurfaceName", adj_srf_identifier)
144
+ elsif triangulated
145
+ # other subsurfaces haven't been created yet, no-op
146
+ else
147
+ # get adjacent sub surface by identifier from openstudio model
148
+ # setAdjacentSubSurface will fail at this point because sub surface is not assigned to surface yet, store data for later
149
+ adj_srf_identifier = @hash[:boundary_condition][:boundary_condition_objects][0]
150
+ os_subsurface.additionalProperties.setFeature("AdjacentSubSurfaceName", adj_srf_identifier)
151
+ end
152
+ end
153
+
154
+ # assign the operable property
155
+ if @hash[:is_operable] == false
156
+ os_subsurface.setSubSurfaceType('FixedWindow')
157
+ else
158
+ os_subsurface.setSubSurfaceType('OperableWindow')
159
+ end
160
+
161
+ result << os_subsurface
162
+ end
163
+
164
+ return result
165
+ end
166
+ end # Aperture
167
+ end # FromHoneybee