Module: BTAP::Geometry::Surfaces

Defined in:
lib/openstudio-standards/btap/geometry.rb

Class Method Summary collapse

Class Method Details

.create_surface(model, name, os_point3d_array, boundary_condition = "", construction = "") ⇒ Object



2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
# File 'lib/openstudio-standards/btap/geometry.rb', line 2581

def self.create_surface(model, name, os_point3d_array, boundary_condition = "", construction = "")
  os_surface = OpenStudio::Model::Surface.new(os_point3d_array, model)
  os_surface.setName(name)
  if OpenStudio::Model::Surface::validOutsideBoundaryConditionValues.include?(boundary_condition)
    self.set_surfaces_boundary_condition([os_surface], boundary_condition)
  else
    puts "boundary condition not set for #{name}"
  end
  self.set_surfaces_construction([os_surface], construction)
  return os_surface
end

.filter_by_azimuth_and_tilt(surfaces, azimuth_from, azimuth_to, tilt_from, tilt_to, tolerance = 1.0) ⇒ Object

Azimuth start from Y axis, Tilts starts from Z-axis



2883
2884
2885
# File 'lib/openstudio-standards/btap/geometry.rb', line 2883

def self.filter_by_azimuth_and_tilt(surfaces, azimuth_from, azimuth_to, tilt_from, tilt_to, tolerance = 1.0)
  return OpenStudio::Model::PlanarSurface::findPlanarSurfaces(surfaces, OpenStudio::OptionalDouble.new(azimuth_from), OpenStudio::OptionalDouble.new(azimuth_to), OpenStudio::OptionalDouble.new(tilt_from), OpenStudio::OptionalDouble.new(tilt_to), tolerance)
end

.filter_by_boundary_condition(surfaces, boundary_conditions) ⇒ Object



2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
# File 'lib/openstudio-standards/btap/geometry.rb', line 2814

def self.filter_by_boundary_condition(surfaces, boundary_conditions)
  #check to see if a string or an array was passed.
  if boundary_conditions.kind_of?(String)
    temp = boundary_conditions
    boundary_conditions = Array.new()
    boundary_conditions.push(temp)
  end
  #ensure boundary conditions are valid
  boundary_conditions.each do |boundary_condition|
    unless OpenStudio::Model::Surface::validOutsideBoundaryConditionValues.include?(boundary_condition)
      raise "ERROR: Invalid Boundary Condition = " + boundary_condition + "Correct Values are:" + OpenStudio::Model::Surface::validOutsideBoundaryConditionValues.to_s
    end
  end
  #create return array.
  return_array = Array.new()

  if boundary_conditions.size == 0 or boundary_conditions[0].upcase == "All".upcase
    return_array = surfaces
  else
    surfaces.each do |surface|
      boundary_conditions.each do |condition|
        if surface.outsideBoundaryCondition == condition
          return_array.push(surface)
        end
      end
    end
  end
  return return_array
end

.filter_by_interzonal_surface(surfaces) ⇒ Object



2872
2873
2874
2875
2876
2877
2878
2879
2880
# File 'lib/openstudio-standards/btap/geometry.rb', line 2872

def self.filter_by_interzonal_surface(surfaces)
  return_array = Array.new()
  surfaces.each do |surface|
    unless surface.adjacentSurface().empty?
      return_array.push(surface)
    end
    return return_array
  end
end

.filter_by_non_defaulted_surfaces(surfaces) ⇒ Object



2807
2808
2809
2810
2811
# File 'lib/openstudio-standards/btap/geometry.rb', line 2807

def self.filter_by_non_defaulted_surfaces(surfaces)
  non_defaulted_surfaces = Array.new()
  surfaces.each {|surface| non_defaulted_surfaces << surface unless surface.isConstructionDefaulted}
  return non_defaulted_surfaces
end

.filter_by_surface_types(surfaces, surfaceTypes) ⇒ Object



2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
# File 'lib/openstudio-standards/btap/geometry.rb', line 2844

def self.filter_by_surface_types(surfaces, surfaceTypes)

  #check to see if a string or an array was passed.
  if surfaceTypes.kind_of?(String)
    temp = surfaceTypes
    surfaceTypes = Array.new()
    surfaceTypes.push(temp)
  end
  surfaceTypes.each do |surfaceType|
    unless OpenStudio::Model::Surface::validSurfaceTypeValues.include?(surfaceType)
      raise("ERROR: Invalid surface type = #{surfaceType} Correct Values are: #{OpenStudio::Model::Surface::validSurfaceTypeValues}")
    end
  end
  return_array = Array.new()
  if surfaceTypes.size == 0 or surfaceTypes[0].upcase == "All".upcase
    return_array = self
  else
    surfaces.each do |surface|
      surfaceTypes.each do |surfaceType|
        if surface.surfaceType == surfaceType
          return_array.push(surface)
        end
      end
    end
  end
  return return_array
end

.filter_subsurfaces_by_types(subsurfaces, subSurfaceTypes) ⇒ Object

“FixedWindow” , “OperableWindow” , “Door” , “GlassDoor”, “OverheadDoor” , “Skylight”, “TubularDaylightDiffuser”,“TubularDaylightDome”


2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
# File 'lib/openstudio-standards/btap/geometry.rb', line 2709

def self.filter_subsurfaces_by_types(subsurfaces, subSurfaceTypes)

  #check to see if a string or an array was passed.
  if subSurfaceTypes.kind_of?(String)
    temp = subSurfaceTypes
    subSurfaceTypes = Array.new()
    subSurfaceTypes.push(temp)
  end
  subSurfaceTypes.each do |subSurfaceType|
    unless OpenStudio::Model::SubSurface::validSubSurfaceTypeValues.include?(subSurfaceType)
      raise("ERROR: Invalid surface type = #{subSurfaceType} Correct Values are: #{OpenStudio::Model::SubSurface::validSubSurfaceTypeValues}")
    end
  end
  return_array = Array.new()
  if subSurfaceTypes.size == 0 or subSurfaceTypes[0].upcase == "All".upcase
    return_array = self
  else
    subsurfaces.each do |subsurface|
      subSurfaceTypes.each do |subSurfaceType|
        if subsurface.subSurfaceType == subSurfaceType
          return_array.push(subsurface)
        end
      end
    end
  end
  return return_array

end

.get_sub_surface_net_area(subsurface) ⇒ Object



2765
2766
2767
# File 'lib/openstudio-standards/btap/geometry.rb', line 2765

def self.get_sub_surface_net_area(subsurface)
  return subsurface.netArea()
end

.get_subsurfaces_from_surfaces(surface_array) ⇒ Object



2663
2664
2665
2666
2667
2668
2669
# File 'lib/openstudio-standards/btap/geometry.rb', line 2663

def self.get_subsurfaces_from_surfaces(surface_array)
  subsurfaces = Array.new()
  surface_array.each do |surface|
    subsurfaces.concat(surface.subSurfaces)
  end
  return subsurfaces
end

.get_surface_construction_conductance(surface) ⇒ Object

This method creates a new construction based on the current, changes the rsi and assign the construction to the current surface. Most of the meat of this method is in the construction class. Testing is done there.



2754
2755
2756
2757
2758
2759
# File 'lib/openstudio-standards/btap/geometry.rb', line 2754

def self.get_surface_construction_conductance(surface)
  #a bit of acrobatics to get the construction object from the ConstrustionBase object's name.
  construction = OpenStudio::Model::getConstructionByName(surface.model, surface.construction.get.name.to_s).get
  #create a new construction with the requested RSI value based on the current construction.
  return BTAP::Resources::Envelope::Constructions::get_conductance(construction)
end

.get_surface_net_area(surface) ⇒ Object



2761
2762
2763
# File 'lib/openstudio-standards/btap/geometry.rb', line 2761

def self.get_surface_net_area(surface)
  return surface.netArea()
end

.get_surfaces_from_building_stories(model, story_array) ⇒ Object



2645
2646
2647
2648
2649
2650
2651
# File 'lib/openstudio-standards/btap/geometry.rb', line 2645

def self.get_surfaces_from_building_stories(model, story_array)
  surfaces = Array.new()
  BTAP::Geometry::Spaces::get_spaces_from_storeys(model, story_array).each do |space|
    surfaces.concat(space.surfaces())
  end
  return surfaces
end

.get_surfaces_from_spaces(spaces_array) ⇒ Object



2637
2638
2639
2640
2641
2642
2643
# File 'lib/openstudio-standards/btap/geometry.rb', line 2637

def self.get_surfaces_from_spaces(spaces_array)
  surfaces = Array.new()
  spaces_array.each do |space|
    surfaces.concat(space.surfaces())
  end
  return surfaces
end

.get_surfaces_from_thermal_zones(thermal_zone_array) ⇒ Object



2653
2654
2655
2656
2657
2658
2659
2660
2661
# File 'lib/openstudio-standards/btap/geometry.rb', line 2653

def self.get_surfaces_from_thermal_zones(thermal_zone_array)
  surfaces = Array.new()
  thermal_zone_array.each do |thermal_zone|
    thermal_zone.spaces.sort.each do |space|
      surfaces.concat(space.surfaces())
    end
    return surfaces
  end
end

.get_total_ext_fenestration_area(model) ⇒ Object



2698
2699
2700
# File 'lib/openstudio-standards/btap/geometry.rb', line 2698

def self.get_total_ext_fenestration_area(model)

end

.get_total_ext_floor_area(model) ⇒ Object



2693
2694
2695
2696
# File 'lib/openstudio-standards/btap/geometry.rb', line 2693

def self.get_total_ext_floor_area(model)

  outdoor_floors = BTAP::Geometry::Surfaces::filter_by_surface_types(outdoor_surfaces, "Floor")
end

.get_total_ext_roof_area(model) ⇒ Object



2702
2703
2704
2705
# File 'lib/openstudio-standards/btap/geometry.rb', line 2702

def self.get_total_ext_roof_area(model)
  outdoor_roofs = BTAP::Geometry::Surfaces::filter_by_surface_types(outdoor_surfaces, "RoofCeiling")

end

.get_total_ext_wall_area(model) ⇒ Object

get total exterior surface area of building.



2686
2687
2688
2689
2690
2691
# File 'lib/openstudio-standards/btap/geometry.rb', line 2686

def self.get_total_ext_wall_area(model)
  outdoor_surfaces = BTAP::Geometry::Surfaces::filter_by_boundary_condition(model.getSurfaces(), "Outdoors")
  outdoor_walls = BTAP::Geometry::Surfaces::filter_by_surface_types(outdoor_surfaces, "Wall")


end

.get_weighted_average_surface_conductance(surfaces) ⇒ Object

determine average conductance on set of surfaces or subsurfaces.



2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
# File 'lib/openstudio-standards/btap/geometry.rb', line 2673

def self.get_weighted_average_surface_conductance(surfaces)
  total_area = 0.0
  temp = 0.0
  surfaces.each do |surface|
    temp = temp + BTAP::Geometry::Surfaces::get_surface_net_area(surface) * BTAP::Geometry::Surfaces::get_surface_construction_conductance(surface)
    total_area = total_area + BTAP::Geometry::Surfaces::get_surface_net_area(surface)
  end
  average_conductance = "NA"
  average_conductance = temp / total_area unless total_area == 0.0
  return average_conductance
end

.hide(surfaces) ⇒ Object



2898
2899
2900
2901
2902
2903
2904
2905
2906
# File 'lib/openstudio-standards/btap/geometry.rb', line 2898

def self.hide(surfaces)
  surfaces.each do |surface|
    if drawing_interface = surface.drawing_interface
      if entity = drawing_interface.entity
        entity.visible = false
      end
    end
  end
end

.remove_all_subsurfaces(surfaces) ⇒ OpenStudio::Model::Model

This Method removes all the subsurfaces in a model (Windows, Doors )

Returns:

Author:

  • Phylroy A. Lopez



2630
2631
2632
2633
2634
2635
# File 'lib/openstudio-standards/btap/geometry.rb', line 2630

def self.remove_all_subsurfaces(surfaces)
  surfaces.each do |subsurface|
    subsurface.remove
  end
  return surfaces
end

.rotate_tilt_translate_surfaces(planar_surfaces, azimuth_degrees, tilt_degrees = 0.0, translation_vector = OpenStudio::Vector3d.new(0.0, 0.0, 0.0)) ⇒ OpenStudio::Model::Model

This method will rotate a surface

Parameters:

  • planar_surfaces (Array<OpenStudio::Model::Surface>)

    an array of surfaces

  • azimuth_degrees (Float)

    rotation value

  • tilt_degrees (Float) (defaults to: 0.0)

    rotation value

  • translation_vector (OpenStudio::Vector3d) (defaults to: OpenStudio::Vector3d.new(0.0, 0.0, 0.0))

    a vector along which to move all surfaces

Returns:



2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
# File 'lib/openstudio-standards/btap/geometry.rb', line 2599

def self.rotate_tilt_translate_surfaces(planar_surfaces, azimuth_degrees, tilt_degrees = 0.0, translation_vector = OpenStudio::Vector3d.new(0.0, 0.0, 0.0))
  # Identity matrix for setting space origins
  azimuth_matrix = OpenStudio::Transformation::rotation(OpenStudio::Vector3d.new(0, 0, 1), azimuth_degrees*Math::PI/180)
  tilt_matrix = OpenStudio::Transformation::rotation(OpenStudio::Vector3d.new(0, 0, 1), tilt_degrees*Math::PI/180)
  translation_matrix = OpenStudio::createTranslation(translation_vector)
  planar_surfaces.each do |surface|
    surface.changeTransformation(azimuth_matrix)
    surface.changeTransformation(tilt_matrix)
    surface.changeTransformation(translation_matrix)
  end
  return planar_surfaces
end

.set_fenestration_to_wall_ratio(surfaces, ratio, offset = 0, height_offset_from_floor = true, floor = "all") ⇒ Object



2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
# File 'lib/openstudio-standards/btap/geometry.rb', line 2612

def self.set_fenestration_to_wall_ratio(surfaces, ratio, offset = 0, height_offset_from_floor = true, floor = "all")
  surfaces.each do |surface|
    result = surface.setWindowToWallRatio(ratio, offset, height_offset_from_floor)
    raise("Unable to set FWR for surface " +
              surface.name.get.to_s +
              " . Possible reasons are  if the surface is not a wall, if the surface
    is not rectangular in face coordinates, if requested ratio is too large
    (window area ~= surface area) or too small (min dimension of window < 1 foot),
    or if the window clips any remaining sub surfaces. Otherwise, removes all
    existing windows and adds new window to meet requested ratio.") unless result
  end
  return surfaces
end

.set_surfaces_boundary_condition(model, surfaces, boundaryCondition) ⇒ Object

This method sets the boundary condition for a surface and it’s matching surface.

If set to adiabatic, it will remove all subsurfaces since E+ cannot have adiabatic sub surfaces.


2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
# File 'lib/openstudio-standards/btap/geometry.rb', line 2779

def self.set_surfaces_boundary_condition(model, surfaces, boundaryCondition)
  surfaces = BTAP::Common::validate_array(model, surfaces, "Surface")
  if OpenStudio::Model::Surface::validOutsideBoundaryConditionValues.include?(boundaryCondition)
    surfaces.each do |surface|
      if boundaryCondition == "Adiabatic"
        #need to remove subsurface as you cannot have a adiabatic surface with a
        #subsurface.
        surface.subSurfaces.each do |subsurface|
          subsurface.remove
        end

        #A bug with adiabatic surfaces. They do not hold the default contruction. 
        surface.setConstruction(surface.construction.get()) if surface.isConstructionDefaulted
      end

      surface.setOutsideBoundaryCondition(boundaryCondition)
      adj_surface = surface.adjacentSurface
      unless adj_surface.empty?
        adj_surface.get.setOutsideBoundaryCondition(boundaryCondition)
      end
    end
  else
    puts "ERROR: Invalid Boundary Condition = " + boundary_condition
    puts "Correct Values are:"
    puts OpenStudio::Model::Surface::validOutsideBoundaryConditionValues
  end
end

.set_surfaces_construction(surfaces, construction) ⇒ Object



2770
2771
2772
2773
2774
2775
# File 'lib/openstudio-standards/btap/geometry.rb', line 2770

def self.set_surfaces_construction(surfaces, construction)
  surfaces.each do |surface|
    surface.setConstruction(construction)
  end
  return true
end

.set_surfaces_construction_conductance(surfaces, conductance) ⇒ Object

This method creates a new construction based on the current, changes the rsi and assign the construction to the current surface. Most of the meat of this method is in the construction class. Testing is done there.



2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
# File 'lib/openstudio-standards/btap/geometry.rb', line 2740

def self.set_surfaces_construction_conductance(surfaces, conductance)
  surfaces.each do |surface|
    #a bit of acrobatics to get the construction object from the ConstrustionBase object's name.
    construction = OpenStudio::Model::getConstructionByName(surface.model, surface.construction.get.name.to_s).get
    #create a new construction with the requested conductance value based on the current construction.

    new_construction = BTAP::Resources::Envelope::Constructions::customize_opaque_construction(surface.model, construction, conductance)
    surface.setConstruction(new_construction)
  end
  return surfaces
end

.show(surfaces) ⇒ Object



2888
2889
2890
2891
2892
2893
2894
2895
2896
# File 'lib/openstudio-standards/btap/geometry.rb', line 2888

def self.show(surfaces)
  surfaces.each do |surface|
    if drawing_interface = surface.drawing_interface
      if entity = drawing_interface.entity
        entity.visible = false
      end
    end
  end
end