Module: BTAP::Geometry::Spaces
- Defined in:
- lib/openstudio-standards/btap/geometry.rb
Overview
This module contains helper functions that deal with Space objects.
Class Method Summary collapse
-
.assign_spaces_to_thermal_zone(model, spaces_array, thermal_zone) ⇒ Object
to do write test.
-
.filter_core_spaces(model, spaces_array) ⇒ Object
This method will filter an array of spaces that have no external wall passed floors.
-
.filter_perimeter_spaces(model, spaces_array) ⇒ Object
This method will filter an array of spaces that have an external wall passed floors.
- .filter_spaces_by_space_types(model, spaces_array, spacetype_array) ⇒ Object
-
.get_space_placement(space) ⇒ Object
This method will return the horizontal placement type.
-
.get_spaces_from_storeys(model, floors) ⇒ Array<OpenStudio::Model::Space>
This method will return a SpaceArray of surfaces that are contained within the passed floors.
-
.get_surfaces_from_spaces(model, spaces_array) ⇒ Object
This method will return a Array of surfaces that are contained within the passed spaces.
- .hide(model, space) ⇒ Object
- .is_perimeter_space?(model, space) ⇒ Boolean
- .show(model, space) ⇒ Object
Class Method Details
.assign_spaces_to_thermal_zone(model, spaces_array, thermal_zone) ⇒ Object
to do write test.
2477 2478 2479 2480 2481 2482 2483 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2477 def self.assign_spaces_to_thermal_zone(model,spaces_array,thermal_zone) spaces_array = BTAP::Common::validate_array(model,spaces_array,"Space") thermal_zone = BTAP::Common::validate_array(model,thermal_zone,"ThermalZone")[0] spaces_array.each do|space| space.setThermalZone(thermal_zone) end end |
.filter_core_spaces(model, spaces_array) ⇒ Object
This method will filter an array of spaces that have no external wall passed floors. Note: if you wish to avoid to create an array of spaces, simply put the space variable in [] brackets Ex: get_all_surfaces_from_spaces( [space1,space2] )
2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2453 def self.filter_core_spaces(model,spaces_array) spaces_array = BTAP::Common::validate_array(model,spaces_array,"Space") array = Array.new() spaces_array.each do |space| unless space.is_a_perimeter_space?() array.push(space) end end return array end |
.filter_perimeter_spaces(model, spaces_array) ⇒ Object
This method will filter an array of spaces that have an external wall passed floors. Note: if you wish to avoid to create an array of spaces, simply put the space variable in [] brackets Ex: get_all_surfaces_from_spaces( [space1,space2] )
2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2436 def self.filter_perimeter_spaces(model, spaces_array) spaces_array = BTAP::Common::validate_array(model,spaces_array,"Space") array = Array.new() spaces_array.each do |space| if space.is_a_perimeter_space?() array.push(space) end end return array end |
.filter_spaces_by_space_types(model, spaces_array, spacetype_array) ⇒ Object
2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2465 def self.filter_spaces_by_space_types(model,spaces_array,spacetype_array) spaces_array = BTAP::Common::validate_array(model,spaces_array,"Space") spacetype_array = BTAP::Common::validate_array(model,spacetype_array,"SpaceType") #validate space array returnarray = Array.new() spaces_array.each do |space| returnarray << spacetype_array.include?(space.spaceType()) end return returnarray end |
.get_space_placement(space) ⇒ Object
This method will return the horizontal placement type. (N,S,W,E,C) In the case of a corner, it will take whatever surface area it faces is the largest. It will also return the top, bottom or middle conditions.
2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2272 def self.get_space_placement(space) horizontal_placement = nil vertical_placement = nil #get all exterior surfaces. surfaces = BTAP::Geometry::Surfaces::filter_by_boundary_condition(space.surfaces, ["Outdoors", "Ground", "GroundFCfactorMethod", "GroundSlabPreprocessorAverage", "GroundSlabPreprocessorCore", "GroundSlabPreprocessorPerimeter", "GroundBasementPreprocessorAverageWall", "GroundBasementPreprocessorAverageFloor", "GroundBasementPreprocessorUpperWall", "GroundBasementPreprocessorLowerWall"]) #exterior Surfaces ext_wall_surfaces = BTAP::Geometry::Surfaces::filter_by_surface_types(surfaces,["Wall"]) ext_bottom_surface = BTAP::Geometry::Surfaces::filter_by_surface_types(surfaces,["Floor"]) ext_top_surface = BTAP::Geometry::Surfaces::filter_by_surface_types(surfaces,["RoofCeiling"]) #Interior Surfaces..if needed.... internal_surfaces = BTAP::Geometry::Surfaces::filter_by_boundary_condition( space.surfaces, ["Surface"] ) int_wall_surfaces = BTAP::Geometry::Surfaces::filter_by_surface_types( internal_surfaces,["Wall"] ) int_bottom_surface = BTAP::Geometry::Surfaces::filter_by_surface_types( internal_surfaces,["Floor"] ) int_top_surface = BTAP::Geometry::Surfaces::filter_by_surface_types( internal_surfaces,["RoofCeiling"] ) vertical_placement = "NA" #determine if space is a top or bottom, both or middle space. if ext_bottom_surface.size > 0 and ext_top_surface.size > 0 and int_bottom_surface.size == 0 and int_top_surface.size == 0 vertical_placement = "single_story_space" elsif int_bottom_surface.size > 0 and ext_top_surface.size > 0 and int_bottom_surface.size > 0 vertical_placement = "top" elsif ext_bottom_surface.size > 0 and ext_top_surface.size == 0 vertical_placement = "bottom" elsif ext_bottom_surface.size == 0 and ext_top_surface.size == 0 vertical_placement = "middle" end #determine if what cardinal direction has the majority of external #surface area of the space. walls_area_array = Array.new [0,1,2,3].each { |index| walls_area_array[index] = 0.0 } #east is defined as 315-45 degs BTAP::Geometry::Surfaces::filter_by_azimuth_and_tilt(ext_wall_surfaces, 0.00, 45.0, 0.00, 180.00).each do |surface| # puts "northern surface found 0-46: #{surface}" # puts surface.azimuth / ( Math::PI / 180.0 ) walls_area_array[0] = walls_area_array[0] + surface.grossArea end BTAP::Geometry::Surfaces::filter_by_azimuth_and_tilt(ext_wall_surfaces, 315.001, 360.0, 0.00, 180.00).each do |surface| # puts "northern surface found: #{surface}" # puts surface.azimuth / ( Math::PI / 180.0 ) walls_area_array[0] = walls_area_array[0] + surface.grossArea end BTAP::Geometry::Surfaces::filter_by_azimuth_and_tilt(ext_wall_surfaces, 45.001, 135.0, 0.00, 180.00).each do |surface| # puts "eastern surface found: #{surface}" # puts surface.azimuth / ( Math::PI / 180.0 ) walls_area_array[1] = walls_area_array[1] + surface.grossArea end BTAP::Geometry::Surfaces::filter_by_azimuth_and_tilt(ext_wall_surfaces, 135.001, 225.0, 0.00, 180.00).each do |surface| # puts "south surface found: #{surface}" # puts surface.azimuth / ( Math::PI / 180.0 ) walls_area_array[2] = walls_area_array[2] + surface.grossArea end BTAP::Geometry::Surfaces::filter_by_azimuth_and_tilt(ext_wall_surfaces, 225.001, 315.0, 0.00, 180.00).each do |surface| # puts "west surface found: #{surface}" # puts surface.azimuth / ( Math::PI / 180.0 ) walls_area_array[3] = walls_area_array[3] + surface.grossArea end #find our which cardinal driection has the most exterior surface and declare it that orientation. case walls_area_array.index(walls_area_array.max) when 0 horizontal_placement = "north" when 1 horizontal_placement = "east" when 2 horizontal_placement = "south" when 3 horizontal_placement = "west" end if walls_area_array.inject{|sum,x| sum + x } == 0.0 horizontal_placement = "core" end return horizontal_placement , vertical_placement end |
.get_spaces_from_storeys(model, floors) ⇒ Array<OpenStudio::Model::Space>
This method will return a SpaceArray of surfaces that are contained within the passed floors. Note: if you wish to avoid to create an array of spaces, simply put the space variable in [] brackets Ex: get_all_surfaces_from_spaces( [space1,space2] )
2423 2424 2425 2426 2427 2428 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2423 def self.get_spaces_from_storeys(model,floors) floors = BTAP::Common::validate_array(model,floors,"BuildingStory") spaces = Array.new() floors.each { |floor| spaces.concat(floor.spaces) } return spaces end |
.get_surfaces_from_spaces(model, spaces_array) ⇒ Object
This method will return a Array of surfaces that are contained within the passed spaces. Note: if you wish to avoid to create an array of spaces, simply put the space variable in [] brackets Ex: get_all_surfaces_from_spaces( [space1,space2] )
2412 2413 2414 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2412 def self.get_surfaces_from_spaces(model, spaces_array) BTAP::Geometry::Surfaces::get_surfaces_from_spaces(spaces_array) end |
.hide(model, space) ⇒ Object
2389 2390 2391 2392 2393 2394 2395 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2389 def self.hide(model,space) if drawing_interface = BTAP::Common::validate_array(model,space,"Space").first.drawing_interface if entity = drawing_interface.entity entity.visible = false end end end |
.is_perimeter_space?(model, space) ⇒ Boolean
2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2370 def self.is_perimeter_space?(model,space) return Array.new(BTAP::Common::validate_array(model,space,"Space").first.surfaces).filterByBoundaryConditions(["Outdoors","Ground", "GroundFCfactorMethod", "GroundSlabPreprocessorAverage", "GroundSlabPreprocessorCore", "GroundSlabPreprocessorPerimeter", "GroundBasementPreprocessorAverageWall", "GroundBasementPreprocessorAverageFloor", "GroundBasementPreprocessorUpperWall", "GroundBasementPreprocessorLowerWall"]).size > 0 end |
.show(model, space) ⇒ Object
2382 2383 2384 2385 2386 2387 2388 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2382 def self.show(model,space) if drawing_interface = BTAP::Common::validate_array(model,space,"Space").first.drawing_interface if entity = drawing_interface.entity entity.visible = true end end end |