Class: OpenStudio::Model::Space

Inherits:
Object
  • Object
show all
Defined in:
lib/openstudio-standards/btap/btap.model.rb

Overview

open the class to add methods to size all HVAC equipment

Instance Method Summary collapse

Instance Method Details

#get_average_heightObject



682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
# File 'lib/openstudio-standards/btap/btap.model.rb', line 682

def get_average_height()
  roof_datum = 0
  total_roof_area = 0
  floor_datum = 0
  total_floor_area = 0
  average_height = 0
  #create a model to create a planar object.. Hopefully garbage collection deals with this right.
  temp_model =  OpenStudio::Model::Model.new()
  self.surfaces.each do |surface|
    projected_vertices = Array.new()
    if surface.surfaceType == "Floor"
      average_surface_height = 0
      surface.vertices.each do |point3d|
        average_surface_height += point3d.z / surface.vertices.size
        projected_vertices << OpenStudio::Point3d.new(point3d.x, point3d.y, 0)
      end
      projected_surface_area =  OpenStudio::Model::Surface.new(projected_vertices ,temp_model).grossArea
      total_roof_area += projected_surface_area
      floor_datum += average_surface_height * projected_surface_area
    elsif surface.surfaceType == "RoofCeiling"
      average_surface_height = 0
      surface.vertices.each do |point3d|
        average_surface_height += point3d.z / surface.vertices.size
        projected_vertices << OpenStudio::Point3d.new(point3d.x, point3d.y, 0)
      end
      projected_surface_area =  OpenStudio::Model::Surface.new(projected_vertices ,temp_model).grossArea
      total_roof_area += projected_surface_area
      roof_datum += average_surface_height * projected_surface_area
    end
  end
  if total_floor_area > 0 and total_roof_area > 0
    average_height = roof_datum / total_roof_area - floor_datum / total_floor_area
  end
  return average_height
end