Class: Honeybee::Aperture
- Inherits:
-
ModelObject
show all
- Defined in:
- lib/honeybee/geometry/aperture.rb,
lib/to_openstudio/geometry/aperture.rb,
lib/from_openstudio/geometry/aperture.rb
Instance Attribute Summary
Attributes inherited from ModelObject
#errors, #openstudio_object, #warnings
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from ModelObject
#allowable_types, clean_identifier, clean_name, #initialize, #method_missing, read_from_disk, truncate
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Honeybee::ModelObject
Class Method Details
.boundary_condition_from_sub_surface(sub_surface) ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/from_openstudio/geometry/aperture.rb', line 100
def self.boundary_condition_from_sub_surface(sub_surface)
result = {}
surface = sub_surface.surface.get
surface_type = surface.surfaceType
adjacent_sub_surface = sub_surface.adjacentSubSurface
if !adjacent_sub_surface.empty?
adjacent_space = clean_identifier(adjacent_sub_surface.get.space.get.nameString)
adjacent_surface = clean_identifier(adjacent_sub_surface.get.surface.get.nameString)
adjacent_sub_surface = clean_identifier(adjacent_sub_surface.get.nameString)
result = {type: 'Surface', boundary_condition_objects: [adjacent_sub_surface, adjacent_surface, adjacent_space]}
elsif surface.isGroundSurface
result = {type: 'Ground'}
elsif surface_type == 'Adiabatic'
result = {type: 'Adiabatic'}
else
sun_exposure = (surface.sunExposure == 'SunExposed')
wind_exposure = (surface.windExposure == 'WindExposed')
view_factor = sub_surface.viewFactortoGround
if view_factor.empty?
view_factor = {type: 'Autocalculate'}
else
view_factor = view_factor.get
end
result = {type: 'Outdoors', sun_exposure: sun_exposure,
wind_exposure: wind_exposure, view_factor: view_factor}
end
result
end
|
.energy_properties_from_sub_surface(sub_surface) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/from_openstudio/geometry/aperture.rb', line 72
def self.energy_properties_from_sub_surface(sub_surface)
hash = {}
hash[:type] = 'ApertureEnergyPropertiesAbridged'
unless sub_surface.isConstructionDefaulted
construction = sub_surface.construction
if !construction.empty?
constr_id = clean_name(construction.get.nameString)
unless $window_constructions[constr_id].nil?
hash[:construction] = constr_id
end
end
end
hash
end
|
.from_sub_surface(sub_surface, site_transformation) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/from_openstudio/geometry/aperture.rb', line 39
def self.from_sub_surface(sub_surface, site_transformation)
hash = {}
hash[:type] = 'Aperture'
hash[:identifier] = clean_identifier(sub_surface.nameString)
unless sub_surface.displayName.empty?
hash[:display_name] = (sub_surface.displayName.get).force_encoding("UTF-8")
else
hash[:display_name] = sub_surface.nameString
end
hash[:user_data] = {handle: sub_surface.handle.to_s}
hash[:properties] = properties_from_sub_surface(sub_surface)
hash[:geometry] = geometry_from_sub_surface(sub_surface, site_transformation)
hash[:boundary_condition] = boundary_condition_from_sub_surface(sub_surface)
sub_surface_type = sub_surface.subSurfaceType
hash[:is_operable] = (sub_surface_type == 'OperableWindow')
indoor_shades = indoor_shades_from_sub_surface(sub_surface)
hash[:indoor_shades] = indoor_shades if !indoor_shades.empty?
outdoor_shades = outdoor_shades_from_sub_surface(sub_surface)
hash[:outdoor_shades] = outdoor_shades if !outdoor_shades.empty?
hash
end
|
.geometry_from_sub_surface(sub_surface, site_transformation) ⇒ Object
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/from_openstudio/geometry/aperture.rb', line 89
def self.geometry_from_sub_surface(sub_surface, site_transformation)
result = {}
result[:type] = 'Face3D'
result[:boundary] = []
vertices = site_transformation * sub_surface.vertices
vertices.each do |v|
result[:boundary] << [v.x, v.y, v.z]
end
result
end
|
.indoor_shades_from_sub_surface(sub_surface) ⇒ Object
129
130
131
|
# File 'lib/from_openstudio/geometry/aperture.rb', line 129
def self.indoor_shades_from_sub_surface(sub_surface)
[]
end
|
.outdoor_shades_from_sub_surface(sub_surface) ⇒ Object
133
134
135
136
137
138
139
140
141
142
|
# File 'lib/from_openstudio/geometry/aperture.rb', line 133
def self.outdoor_shades_from_sub_surface(sub_surface)
result = []
sub_surface.shadingSurfaceGroups.each do |shading_surface_group|
site_transformation = shading_surface_group.siteTransformation
shading_surface_group.shadingSurfaces.each do |shading_surface|
result << Shade.from_shading_surface(shading_surface, site_transformation)
end
end
result
end
|
.properties_from_sub_surface(sub_surface) ⇒ Object
65
66
67
68
69
70
|
# File 'lib/from_openstudio/geometry/aperture.rb', line 65
def self.properties_from_sub_surface(sub_surface)
hash = {}
hash[:type] = 'AperturePropertiesAbridged'
hash[:energy] = energy_properties_from_sub_surface(sub_surface)
hash
end
|
Instance Method Details
#defaults ⇒ Object
37
38
39
|
# File 'lib/honeybee/geometry/aperture.rb', line 37
def defaults
@@schema[:components][:schemas][:ApertureEnergyPropertiesAbridged][:properties]
end
|
#find_existing_openstudio_object(openstudio_model) ⇒ Object
39
40
41
42
43
|
# File 'lib/to_openstudio/geometry/aperture.rb', line 39
def find_existing_openstudio_object(openstudio_model)
object = openstudio_model.getSubSurfaceByName(@hash[:identifier])
return object.get if object.is_initialized
nil
end
|
#to_openstudio(openstudio_model) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
# File 'lib/to_openstudio/geometry/aperture.rb', line 45
def to_openstudio(openstudio_model)
os_vertices = OpenStudio::Point3dVector.new
@hash[:geometry][:boundary].each do |vertex|
os_vertices << OpenStudio::Point3d.new(vertex[0], vertex[1], vertex[2])
end
triangulated = false
final_vertices_list = []
matching_os_subsurfaces = []
matching_os_subsurface_indices = []
if $triangulate_sub_faces && os_vertices.size > 4
if @hash[:boundary_condition][:type] == 'Surface'
adj_srf_identifier = @hash[:boundary_condition][:boundary_condition_objects][0]
regex = Regexp.new("#{adj_srf_identifier}\.\.(\\d+)")
openstudio_model.getSubSurfaces.each do |subsurface|
if md = regex.match(subsurface.nameString)
final_vertices_list << OpenStudio.reorderULC(OpenStudio::reverse(subsurface.vertices))
matching_os_subsurfaces << subsurface
matching_os_subsurface_indices << md[1]
end
end
end
if final_vertices_list.empty?
t = OpenStudio::Transformation::alignFace(os_vertices)
tInv = t.inverse
face_vertices = OpenStudio::reverse(tInv*os_vertices)
holes = OpenStudio::Point3dVectorVector.new
triangles = OpenStudio::computeTriangulation(face_vertices, holes)
if triangles.empty?
raise "Failed to triangulate aperture #{@hash[:identifier]} with #{os_vertices.size} vertices"
end
triangles.each do |vertices|
final_vertices_list << OpenStudio.reorderULC(OpenStudio::reverse(t*vertices))
end
triangulated = true
end
else
final_vertices_list << os_vertices
end
result = []
final_vertices_list.each_with_index do |os_vertices, index|
os_subsurface = OpenStudio::Model::SubSurface.new(os_vertices, openstudio_model)
if !matching_os_subsurfaces.empty?
os_subsurface.setName(@hash[:identifier] + "..#{matching_os_subsurface_indices[index]}")
elsif triangulated
os_subsurface.setName(@hash[:identifier] + "..#{index}")
else
os_subsurface.setName(@hash[:identifier])
end
unless @hash[:display_name].nil?
os_subsurface.setDisplayName(@hash[:display_name])
end
if @hash[:properties].key?(:energy)
if @hash[:properties][:energy][:construction]
construction_identifier = @hash[:properties][:energy][:construction]
construction = openstudio_model.getConstructionByName(construction_identifier)
if !construction.empty?
os_construction = construction.get
os_subsurface.setConstruction(os_construction)
elsif $window_dynamic_hash[construction_identifier] != nil
os_construction = $window_dynamic_hash[construction_identifier].constructions[0]
os_subsurface.setConstruction(os_construction)
end
end
if @hash[:properties][:energy][:frame]
frame_identifier = @hash[:properties][:energy][:frame]
frame = openstudio_model.getWindowPropertyFrameAndDividerByName(frame_identifier)
unless frame.empty?
os_frame = frame.get
os_subsurface.setWindowPropertyFrameAndDivider(os_frame)
end
end
end
if @hash[:boundary_condition][:type] == 'Surface'
if !matching_os_subsurfaces.empty?
adj_srf_identifier = matching_os_subsurfaces[index].nameString
os_subsurface.additionalProperties.setFeature("AdjacentSubSurfaceName", adj_srf_identifier)
elsif triangulated
else
adj_srf_identifier = @hash[:boundary_condition][:boundary_condition_objects][0]
os_subsurface.additionalProperties.setFeature("AdjacentSubSurfaceName", adj_srf_identifier)
end
end
if @hash[:is_operable] == false
os_subsurface.setSubSurfaceType('FixedWindow')
else
os_subsurface.setSubSurfaceType('OperableWindow')
end
result << os_subsurface
end
return result
end
|
#to_openstudio_shade(openstudio_model) ⇒ Object
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
# File 'lib/to_openstudio/geometry/aperture.rb', line 173
def to_openstudio_shade(openstudio_model)
if @hash[:geometry][:vertices].nil?
hb_verts = @hash[:geometry][:boundary]
else
hb_verts = @hash[:geometry][:vertices]
end
os_vertices = OpenStudio::Point3dVector.new
hb_verts.each do |vertex|
os_vertices << OpenStudio::Point3d.new(vertex[0], vertex[1], vertex[2])
end
os_shading_surface = OpenStudio::Model::ShadingSurface.new(os_vertices, openstudio_model)
os_shading_surface.setName(@hash[:identifier])
unless @hash[:display_name].nil?
os_shading_surface.setDisplayName(@hash[:display_name])
end
construction_id = nil
if @hash[:properties].key?(:energy) && @hash[:properties][:energy][:construction]
construction_id = @hash[:properties][:energy][:construction]
else
construction_id = 'Generic Double Pane'
end
unless construction_id.nil?
construction = openstudio_model.getConstructionByName(construction_id)
unless construction.empty?
os_construction = construction.get
os_shading_surface.setConstruction(os_construction)
end
end
if @hash[:transmit]
schedule_identifier = 'Constant ' + @hash[:transmit] + ' Transmittance'
schedule = openstudio_model.getScheduleByName(schedule_identifier)
unless schedule.empty?
os_schedule = schedule.get
os_shading_surface.setTransmittanceSchedule(os_schedule)
end
end
os_shading_surface
end
|