honeybee-openstudio 2.35.2 → 2.36.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.
@@ -0,0 +1,42 @@
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/model_object'
33
+
34
+ module Honeybee
35
+ class ShadeMesh < ModelObject
36
+
37
+ def defaults
38
+ @@schema[:components][:schemas][:ShadeMeshEnergyPropertiesAbridged][:properties]
39
+ end
40
+
41
+ end #ShadeMesh
42
+ end #Honeybee
@@ -106,15 +106,21 @@ module Honeybee
106
106
  raise 'defaults not implemented for ModelObject, override in your class'
107
107
  end
108
108
 
109
+ def self.truncate(string, max)
110
+ string.length > max ? "#{string[0...max]}..." : string
111
+ end
112
+
109
113
  # remove illegal characters in identifier
110
114
  def self.clean_name(str)
111
115
  ascii = str.encode(Encoding.find('ASCII'), **@@encoding_options)
116
+ ascii = truncate(ascii, 97)
112
117
  end
113
118
 
114
119
  # remove illegal characters in identifier
115
120
  def self.clean_identifier(str)
116
121
  encode_str = str.encode(Encoding.find('ASCII'), **@@encoding_options)
117
122
  encode_str.gsub(/[^.A-Za-z0-9_-]/, '_').gsub(' ', '_')
123
+ encode_str = truncate(encode_str, 97)
118
124
  end
119
125
 
120
126
  # Create methods to get and set display name
data/lib/honeybee.rb CHANGED
@@ -44,6 +44,7 @@ require 'honeybee/geometry/door'
44
44
  require 'honeybee/geometry/aperture'
45
45
  require 'honeybee/geometry/face'
46
46
  require 'honeybee/geometry/room'
47
+ require 'honeybee/geometry/shademesh'
47
48
 
48
49
  # import the HVAC objects
49
50
  require 'honeybee/hvac/ideal_air'
@@ -56,12 +56,14 @@ module Honeybee
56
56
  os_vertices << OpenStudio::Point3d.new(vertex[0], vertex[1], vertex[2])
57
57
  end
58
58
 
59
- # create the openstudio surface and assign the type
59
+ # create the openstudio surface
60
60
  os_surface = OpenStudio::Model::Surface.new(os_vertices, openstudio_model)
61
61
  os_surface.setName(@hash[:identifier])
62
62
  unless @hash[:display_name].nil?
63
63
  os_surface.setDisplayName(@hash[:display_name])
64
64
  end
65
+
66
+ # assign the type
65
67
  os_surface.setSurfaceType(@hash[:face_type])
66
68
 
67
69
  if @hash[:properties].key?(:energy)
@@ -219,6 +219,28 @@ module Honeybee
219
219
  end
220
220
  end
221
221
 
222
+ # overwrite the face type if E+ is going to flip the surface on us and make the geometry incorrect
223
+ face_tilt = os_surface.tilt
224
+ if face[:face_type] == 'RoofCeiling' && face_tilt > 1.57079632679
225
+ if !face[:properties][:energy][:construction]
226
+ orig_construction = os_surface.construction
227
+ unless orig_construction.empty?
228
+ orig_construction = orig_construction.get
229
+ os_surface.setConstruction(orig_construction)
230
+ end
231
+ end
232
+ os_surface.setSurfaceType('Wall')
233
+ elsif face[:face_type] == 'Floor' && face_tilt < 1.57079632679
234
+ if !face[:properties][:energy][:construction]
235
+ orig_construction = os_surface.construction
236
+ unless orig_construction.empty?
237
+ orig_construction = orig_construction.get
238
+ os_surface.setConstruction(orig_construction)
239
+ end
240
+ end
241
+ os_surface.setSurfaceType('Wall')
242
+ end
243
+
222
244
  # assign air boundaries
223
245
  if face[:face_type] == 'AirBoundary'
224
246
  # assign default air boundary construction for AirBoundary face types
@@ -0,0 +1,91 @@
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/shademesh'
33
+
34
+ require 'to_openstudio/model_object'
35
+
36
+ module Honeybee
37
+ class ShadeMesh
38
+
39
+ def to_openstudio(openstudio_model)
40
+ # get the vertices from the face
41
+ hb_verts = @hash[:geometry][:vertices]
42
+ hb_faces = @hash[:geometry][:faces]
43
+
44
+ # loop through each mesh face and make it a shading surface
45
+ os_shading_surfaces = []
46
+ hb_faces.each_with_index do |face_indices, index|
47
+ # ensure that vertices are correctly ordered with the upper-left corner
48
+ os_vertices = OpenStudio::Point3dVector.new
49
+ face_indices.each do |vertex_index|
50
+ vertex = hb_verts[vertex_index]
51
+ os_vertices << OpenStudio::Point3d.new(vertex[0], vertex[1], vertex[2])
52
+ end
53
+ os_vertices = OpenStudio.reorderULC(os_vertices)
54
+
55
+ # create the openstudio shading surface
56
+ os_shading_surface = OpenStudio::Model::ShadingSurface.new(os_vertices, openstudio_model)
57
+ os_shading_surface.setName(@hash[:identifier] + "..#{index}")
58
+ unless @hash[:display_name].nil?
59
+ os_shading_surface.setDisplayName(@hash[:display_name])
60
+ end
61
+
62
+ if @hash[:properties].key?(:energy)
63
+ # assign the construction if it exists
64
+ if @hash[:properties][:energy][:construction]
65
+ construction_identifier = @hash[:properties][:energy][:construction]
66
+ construction = openstudio_model.getConstructionByName(construction_identifier)
67
+ unless construction.empty?
68
+ os_construction = construction.get
69
+ os_shading_surface.setConstruction(os_construction)
70
+ end
71
+ end
72
+
73
+ # assign the transmittance schedule if it exists
74
+ if @hash[:properties][:energy][:transmittance_schedule]
75
+ schedule_identifier = @hash[:properties][:energy][:transmittance_schedule]
76
+ schedule = openstudio_model.getScheduleByName(schedule_identifier)
77
+ unless schedule.empty?
78
+ os_schedule = schedule.get
79
+ os_shading_surface.setTransmittanceSchedule(os_schedule)
80
+ end
81
+ end
82
+ end
83
+
84
+ os_shading_surfaces << os_shading_surface
85
+ end
86
+
87
+ os_shading_surfaces
88
+ end
89
+
90
+ end #ShadeMesh
91
+ end #Honeybee
@@ -216,6 +216,7 @@ module Honeybee
216
216
  create_orphaned_faces
217
217
  create_orphaned_apertures
218
218
  create_orphaned_doors
219
+ create_shade_meshes
219
220
  end
220
221
 
221
222
  def create_materials(material_dicts, check_existing=false)
@@ -673,6 +674,27 @@ module Honeybee
673
674
  end
674
675
  end
675
676
 
677
+ def create_shade_meshes
678
+ if @hash[:shade_meshes]
679
+ @hash[:shade_meshes].each do |shade_mesh|
680
+ shade_mesh_object = ShadeMesh.new(shade_mesh)
681
+ openstudio_shades = shade_mesh_object.to_openstudio(@openstudio_model)
682
+
683
+ if $orphan_groups
684
+ shading_surface_group = OpenStudio::Model::ShadingSurfaceGroup.new(@openstudio_model)
685
+ shading_surface_group.setShadingSurfaceType('Building')
686
+ shading_surface_group.setName(shade_mesh[:identifier])
687
+ unless shade_mesh[:display_name].nil?
688
+ shading_surface_group.setDisplayName(shade_mesh[:display_name])
689
+ end
690
+ openstudio_shades.each do |openstudio_shade|
691
+ openstudio_shade.setShadingSurfaceGroup(shading_surface_group)
692
+ end
693
+ end
694
+ end
695
+ end
696
+ end
697
+
676
698
  #TODO: create runlog for errors.
677
699
 
678
700
  end # Model
@@ -157,10 +157,12 @@ module Honeybee
157
157
  end
158
158
  # set any design days
159
159
  if @hash[:sizing_parameter][:design_days]
160
- @hash[:sizing_parameter][:design_days].each do |des_day|
161
- des_day_object = DesignDay.new(des_day)
162
- os_des_day = des_day_object.to_openstudio(@openstudio_model)
163
- db_temps << des_day[:dry_bulb_condition][:dry_bulb_max]
160
+ if @hash[:simulation_control][:do_zone_sizing].nil? || @hash[:simulation_control][:do_zone_sizing] == true
161
+ @hash[:sizing_parameter][:design_days].each do |des_day|
162
+ des_day_object = DesignDay.new(des_day)
163
+ os_des_day = des_day_object.to_openstudio(@openstudio_model)
164
+ db_temps << des_day[:dry_bulb_condition][:dry_bulb_max]
165
+ end
164
166
  end
165
167
  end
166
168
  end
data/lib/to_openstudio.rb CHANGED
@@ -44,6 +44,7 @@ require 'to_openstudio/geometry/door'
44
44
  require 'to_openstudio/geometry/aperture'
45
45
  require 'to_openstudio/geometry/face'
46
46
  require 'to_openstudio/geometry/room'
47
+ require 'to_openstudio/geometry/shademesh'
47
48
 
48
49
  # extend the HVAC objects
49
50
  require 'to_openstudio/hvac/ideal_air'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeybee-openstudio
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.35.2
4
+ version: 2.36.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanushree Charan
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2023-11-10 00:00:00.000000000 Z
14
+ date: 2023-11-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: json_pure
@@ -138,6 +138,7 @@ files:
138
138
  - lib/honeybee/geometry/face.rb
139
139
  - lib/honeybee/geometry/room.rb
140
140
  - lib/honeybee/geometry/shade.rb
141
+ - lib/honeybee/geometry/shademesh.rb
141
142
  - lib/honeybee/hvac/ideal_air.rb
142
143
  - lib/honeybee/hvac/template.rb
143
144
  - lib/honeybee/internalmass.rb
@@ -229,6 +230,7 @@ files:
229
230
  - lib/to_openstudio/geometry/face.rb
230
231
  - lib/to_openstudio/geometry/room.rb
231
232
  - lib/to_openstudio/geometry/shade.rb
233
+ - lib/to_openstudio/geometry/shademesh.rb
232
234
  - lib/to_openstudio/hvac/Model.hvac.rb
233
235
  - lib/to_openstudio/hvac/ideal_air.rb
234
236
  - lib/to_openstudio/hvac/radiant.rb