Module: Functions
- Defined in:
- lib/measures/SetWindowToWallRatioByFacade/resources/functions.rb
Class Method Summary collapse
-
.get_orig_sub_surf_const_for_target(subsurfaces) ⇒ Object
return a hash of subsurface constructions.
-
.get_surfaces_or_subsurfaces_by_facade(surfaces_or_subsurfaces, facade) ⇒ Object
return an array of surfaces or subsurfaces from a specific facade.
-
.rectangle?(surface) ⇒ Boolean
see if surface is rectangular (only checking non rotated on vertical wall) todo - add in more robust rectangle check that can look for rotate and tilted rectangles.
-
.requested_window_area_greater_than_max?(surface, viewGlassToWallRatio) ⇒ Boolean
return true if the requested window-to-wall area exceeds the maximum allowed area, false if not.
Class Method Details
.get_orig_sub_surf_const_for_target(subsurfaces) ⇒ Object
return a hash of subsurface constructions.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/measures/SetWindowToWallRatioByFacade/resources/functions.rb', line 57 def self.get_orig_sub_surf_const_for_target(subsurfaces) orig_sub_surf_const_for_target = {} subsurfaces.each do |subsurface| next if subsurface.subSurfaceType == 'Door' || subsurface.subSurfaceType == 'OverheadDoor' if subsurface.construction.is_initialized if orig_sub_surf_const_for_target.key?(subsurface.construction.get) orig_sub_surf_const_for_target[subsurface.construction.get] += 1 else orig_sub_surf_const_for_target[subsurface.construction.get] = 1 end end end return orig_sub_surf_const_for_target end |
.get_surfaces_or_subsurfaces_by_facade(surfaces_or_subsurfaces, facade) ⇒ Object
return an array of surfaces or subsurfaces from a specific facade.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/measures/SetWindowToWallRatioByFacade/resources/functions.rb', line 10 def self.get_surfaces_or_subsurfaces_by_facade(surfaces_or_subsurfaces, facade) surfaces_or_subsurfaces_by_facade = [] surfaces_or_subsurfaces.each do |surface_or_subsurface| case surface_or_subsurface.class.to_s.gsub('OpenStudio::Model::', '') when 'Surface' next if surface_or_subsurface.surfaceType != 'Wall' next if surface_or_subsurface.outsideBoundaryCondition != 'Outdoors' if surface_or_subsurface.space.empty? runner.registerWarning("#{surface_or_subsurface.name} doesn't have a parent space and won't be included in the measure reporting or modifications.") next end direction_of_relative_north = surface_or_subsurface.space.get.directionofRelativeNorth when 'SubSurface' next if surface_or_subsurface.subSurfaceType == 'Door' || surface_or_subsurface.subSurfaceType == 'OverheadDoor' direction_of_relative_north = surface_or_subsurface.surface.get.space.get.directionofRelativeNorth end # get the absoluteAzimuth for the surface so we can categorize it absoluteAzimuth = OpenStudio.convert(surface_or_subsurface.azimuth, 'rad', 'deg').get + direction_of_relative_north + surface_or_subsurface.model.getBuilding.northAxis absoluteAzimuth -= 360.0 until absoluteAzimuth < 360.0 case facade when 'North' next if !((absoluteAzimuth >= 315.0) || (absoluteAzimuth < 45.0)) when 'East' next if !((absoluteAzimuth >= 45.0) && (absoluteAzimuth < 135.0)) when 'South' next if !((absoluteAzimuth >= 135.0) && (absoluteAzimuth < 225.0)) when 'West' next if !((absoluteAzimuth >= 225.0) && (absoluteAzimuth < 315.0)) when 'All' # no next needed else runner.registerError("Unexpected value of facade: #{facade}.") return false end surfaces_or_subsurfaces_by_facade << surface_or_subsurface end return surfaces_or_subsurfaces_by_facade end |
.rectangle?(surface) ⇒ Boolean
see if surface is rectangular (only checking non rotated on vertical wall) todo - add in more robust rectangle check that can look for rotate and tilted rectangles
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/measures/SetWindowToWallRatioByFacade/resources/functions.rb', line 77 def self.rectangle?(surface) x_vals = [] y_vals = [] z_vals = [] vertices = surface.vertices vertices.each do |vertex| # initialize new vertex to old vertex # rounding values to address tolerance issue 10 digits digits in x_vals << vertex.x.round(4) y_vals << vertex.y.round(4) z_vals << vertex.z.round(4) end if x_vals.uniq.size <= 2 && y_vals.uniq.size <= 2 && z_vals.uniq.size <= 2 return true else return false end end |
.requested_window_area_greater_than_max?(surface, viewGlassToWallRatio) ⇒ Boolean
return true if the requested window-to-wall area exceeds the maximum allowed area, false if not. implements the following part of the applyViewAndDaylightingGlassRatios method, which is what setWindowToWallRatio uses. github.com/NREL/OpenStudio/blob/760613c7ac9c2093f7dbd65f947a6853356c558d/src/utilities/geometry/Geometry.cpp#L605-L695
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 |
# File 'lib/measures/SetWindowToWallRatioByFacade/resources/functions.rb', line 99 def self.requested_window_area_greater_than_max?(surface, viewGlassToWallRatio) daylightingGlassToWallRatio = 0 totalWWR = viewGlassToWallRatio + daylightingGlassToWallRatio vertices = surface.vertices transformation = OpenStudio::Transformation.alignFace(vertices) faceVertices = transformation.inverse * vertices # // new coordinate system has z' in direction of outward normal, y' is up xmin = 0 xmax = 0 ymin = 0 ymax = 0 faceVertices.each do |faceVertex| xmin = [xmin, faceVertex.x].min xmax = [xmax, faceVertex.x].max ymin = [ymin, faceVertex.y].min ymax = [ymax, faceVertex.y].max end oneInch = 0.0254 # meters # // DLM: preserve a 1" gap between window and edge to keep SketchUp happy minGlassToEdgeDistance = oneInch minViewToDaylightDistance = 0 # // wall parameters wallWidth = xmax - xmin wallHeight = ymax - ymin wallArea = wallWidth * wallHeight # return false if wallWidth < 2 * minGlassToEdgeDistance # return false if wallHeight < 2 * minGlassToEdgeDistance + minViewToDaylightDistance maxWindowArea = wallArea - 2 * wallHeight * minGlassToEdgeDistance - (wallWidth - 2 * minGlassToEdgeDistance) * (2 * minGlassToEdgeDistance + minViewToDaylightDistance) requestedViewArea = viewGlassToWallRatio * wallArea requestedDaylightingArea = daylightingGlassToWallRatio * wallArea requestedTotalWindowArea = totalWWR * wallArea if requestedTotalWindowArea > maxWindowArea return true else return false end end |