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

Class Method Details

.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] )

Parameters:

  • spaces_array

    an array of type [OpenStudio::Model::Space]

Returns:

  • an array of spaces.



481
482
483
484
485
486
487
488
489
490
# File 'lib/openstudio-standards/btap/geometry.rb', line 481

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] )

Parameters:

  • spaces_array

    an array of type [OpenStudio::Model::Space]

Returns:

  • an array of spaces.



464
465
466
467
468
469
470
471
472
473
# File 'lib/openstudio-standards/btap/geometry.rb', line 464

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



493
494
495
496
497
498
499
500
501
502
# File 'lib/openstudio-standards/btap/geometry.rb', line 493

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.



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'lib/openstudio-standards/btap/geometry.rb', line 294

def self.get_space_placement(space)
  horizontal_placement = nil
  vertical_placement = nil
  json_data = 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.
  #set this to 'core' by default and change it if it is found to be a space exposed to a cardinal direction.
  horizontal_placement = nil
  #set up summing hashes for each direction.
  json_data = Hash.new
  walls_area_array = Hash.new
  subsurface_area_array = Hash.new
  boundary_conditions = {}
  boundary_conditions[:outdoors] = ["Outdoors"]
  boundary_conditions[:ground] = [
      "Ground",
      "GroundFCfactorMethod",
      "GroundSlabPreprocessorAverage",
      "GroundSlabPreprocessorCore",
      "GroundSlabPreprocessorPerimeter",
      "GroundBasementPreprocessorAverageWall",
      "GroundBasementPreprocessorAverageFloor",
      "GroundBasementPreprocessorUpperWall",
      "GroundBasementPreprocessorLowerWall"]
  #go through all directions.. need to do north twice since that goes around zero degree mark.
  orientations = [
      {:surface_type => 'Wall', :direction => 'north', :azimuth_from => 0.00, :azimuth_to => 45.0, :tilt_from => 0.0, :tilt_to => 180.0},
      {:surface_type => 'Wall', :direction => 'north', :azimuth_from => 315.001, :azimuth_to => 360.0, :tilt_from => 0.0, :tilt_to => 180.0},
      {:surface_type => 'Wall', :direction => 'east', :azimuth_from => 45.001, :azimuth_to => 135.0, :tilt_from => 0.0, :tilt_to => 180.0},
      {:surface_type => 'Wall', :direction => 'south', :azimuth_from => 135.001, :azimuth_to => 225.0, :tilt_from => 0.0, :tilt_to => 180.0},
      {:surface_type => 'Wall', :direction => 'west', :azimuth_from => 225.001, :azimuth_to => 315.0, :tilt_from => 0.0, :tilt_to => 180.0},
      {:surface_type => 'RoofCeiling', :direction => 'top', :azimuth_from => 0.0, :azimuth_to => 360.0, :tilt_from => 0.0, :tilt_to => 180.0},
      {:surface_type => 'Floor', :direction => 'bottom', :azimuth_from => 0.0, :azimuth_to => 360.0, :tilt_from => 0.0, :tilt_to => 180.0}
  ]
  [:outdoors, :ground].each do |bc|
    orientations.each do |orientation|
      walls_area_array[orientation[:direction]] = 0.0
      subsurface_area_array[orientation[:direction]] = 0.0
      json_data[orientation[:direction]] = {} if json_data[orientation[:direction]].nil?
      json_data[orientation[:direction]][bc] = {:surface_area => 0.0,
                                                :glazed_subsurface_area => 0.0,
                                                :opaque_subsurface_area => 0.0}

    end
  end


  [:outdoors, :ground].each do |bc|
    orientations.each do |orientation|
      # puts "bc= #{bc}"
      # puts boundary_conditions[bc.to_sym]
      # puts boundary_conditions
      surfaces = BTAP::Geometry::Surfaces::filter_by_boundary_condition(space.surfaces, boundary_conditions[bc])
      selected_surfaces = BTAP::Geometry::Surfaces::filter_by_surface_types(surfaces, [orientation[:surface_type]])
      BTAP::Geometry::Surfaces::filter_by_azimuth_and_tilt(selected_surfaces, orientation[:azimuth_from], orientation[:azimuth_to], orientation[:tilt_from], orientation[:tilt_to]).each do |surface|
        #sum wall area and subsurface area by direction. This is the old way so excluding top and bottom surfaces.
        walls_area_array[orientation[:direction]] += surface.grossArea unless ['RoofCeiling', 'Floor'].include?(orientation[:surface_type])
        subsurface_area_array[orientation[:direction]] += surface.subSurfaces.map {|subsurface| subsurface.grossArea}.inject(0) {|sum, x| sum + x}
        json_data[orientation[:direction]][bc][:surface_area] += surface.grossArea
        glazings = BTAP::Geometry::Surfaces::filter_subsurfaces_by_types(surface.subSurfaces, ["FixedWindow", "OperableWindow", "GlassDoor", "Skylight", "TubularDaylightDiffuser", "TubularDaylightDome"])
        doors = BTAP::Geometry::Surfaces::filter_subsurfaces_by_types(surface.subSurfaces, ["Door", "OverheadDoor"])
        json_data[orientation[:direction]][bc][:glazed_subsurface_area] += glazings.map {|subsurface| subsurface.grossArea}.inject(0) {|sum, x| sum + x}
        json_data[orientation[:direction]][bc][:opaque_subsurface_area] += doors.map {|subsurface| subsurface.grossArea}.inject(0) {|sum, x| sum + x}
      end
    end
  end
  puts JSON.pretty_generate(json_data)

  puts walls_area_array
  #find if no direction
  sum= 0.0
  ['north','east','south','west'].each do |direction|
    [:outdoors,:ground].each do |bc|
      sum += json_data[direction][bc][:surface_area]
    end
  end
  if sum == 0.0
    horizontal_placement = "core"
  else
    #find our which cardinal direction has the most exterior surface and declare it that orientation.
    horizontal_placement = walls_area_array.max_by {|k, v| v}[0] #include ext and ground.
  end

  #save JSON data
  json_data = ({:horizontal_placement => horizontal_placement,
                :vertical_placement => vertical_placement,
  }).merge(json_data)
  puts JSON.pretty_generate(json_data)

  return json_data
end

.hide(model, space) ⇒ Object



450
451
452
453
454
455
456
# File 'lib/openstudio-standards/btap/geometry.rb', line 450

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

Returns:

  • (Boolean)


425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
# File 'lib/openstudio-standards/btap/geometry.rb', line 425

def self.is_perimeter_space?(model, space)
  exterior_surfaces = BTAP::Geometry::Surfaces::filter_by_boundary_condition(space.surfaces,
                                                                             ["Outdoors",
                                                                              "Ground",
                                                                              "GroundFCfactorMethod",
                                                                              "GroundSlabPreprocessorAverage",
                                                                              "GroundSlabPreprocessorCore",
                                                                              "GroundSlabPreprocessorPerimeter",
                                                                              "GroundBasementPreprocessorAverageWall",
                                                                              "GroundBasementPreprocessorAverageFloor",
                                                                              "GroundBasementPreprocessorUpperWall",
                                                                              "GroundBasementPreprocessorLowerWall"])

  return BTAP::Geometry::Surfaces::filter_by_surface_types(exterior_surfaces, ["Wall"]).size > 0

end

.show(model, space) ⇒ Object



442
443
444
445
446
447
448
# File 'lib/openstudio-standards/btap/geometry.rb', line 442

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