module BTAP::Geometry

Public Class Methods

enumerate_spaces_model(model, prepend_name = false) click to toggle source
# File lib/openstudio-standards/btap/geometry.rb, line 23
def self.enumerate_spaces_model(model, prepend_name = false)
  #enumerate stories.
  BTAP::Geometry::BuildingStoreys::auto_assign_spaces_to_stories(model)
  #Enumerate spaces
  model.getBuildingStorys.sort.each do |story|
    spaces = Array.new
    spaces.concat(story.spaces)
    spaces.sort! do |a, b|
      (a.xOrigin <=> b.xOrigin).nonzero? ||
          (a.yOrigin <=> b.yOrigin)
    end
    counter = 1
    spaces.sort.each do |space|
      #puts "old space name : #{space.name}"
      if prepend_name == true
        space.setName("#{story.name}-#{counter.to_s}:#{space.name}")
      else
        space.setName("#{story.name}-#{counter.to_s}")
      end
      counter = counter + 1
      p #uts "new space name : #{space.name}"
    end
  end
end
get_fwdr(model) click to toggle source
# File lib/openstudio-standards/btap/geometry.rb, line 175
def self.get_fwdr(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")
  self.get_surface_to_subsurface_ratio(outdoor_walls)
end
get_srr(model) click to toggle source
# File lib/openstudio-standards/btap/geometry.rb, line 181
def self.get_srr(model)
  outdoor_surfaces = BTAP::Geometry::Surfaces::filter_by_boundary_condition(model.getSurfaces(), "Outdoors")
  outdoor_roofs = BTAP::Geometry::Surfaces::filter_by_surface_types(outdoor_surfaces, "RoofCeiling")
  self.get_surface_to_subsurface_ratio(outdoor_roofs)
end
get_surface_to_subsurface_ratio(surfaces) click to toggle source
# File lib/openstudio-standards/btap/geometry.rb, line 187
def self.get_surface_to_subsurface_ratio(surfaces)
  total_gross_surface_area = 0.0
  total_net_surface_area = 0.0
  surfaces.each do |surface|
    total_gross_surface_area = total_gross_surface_area + surface.grossArea
    total_net_surface_area = total_net_surface_area + surface.netArea
  end
  return 1.0 - (total_net_surface_area / total_gross_surface_area)
end
intersect_surfaces(model) click to toggle source
# File lib/openstudio-standards/btap/geometry.rb, line 145
def self.intersect_surfaces(model)
  model.getSpaces.sort.each do |space1|
    model.getSpaces.sort.each do |space2|
      space1.intersectSurfaces(space2)
    end
  end
  return model
end
match_surfaces(model) click to toggle source
# File lib/openstudio-standards/btap/geometry.rb, line 136
def self.match_surfaces(model)
  model.getSpaces.sort.each do |space1|
    model.getSpaces.sort.each do |space2|
      space1.matchSurfaces(space2)
    end
  end
  return model
end
prefix_equipment_with_zone_name(model) click to toggle source

This method will rename the zone equipment to have the zone name as a prefix for a model. It will also rename the hot water coils for:

AirTerminalSingleDuctVAVReheat
ZoneHVACBaseboardConvectiveWater
ZoneHVACUnitHeater
# File lib/openstudio-standards/btap/geometry.rb, line 98
def self.prefix_equipment_with_zone_name(model)
  #puts "Renaming zone equipment."
  # get all thermal zones
  thermal_zones = model.getThermalZones

  # loop through thermal zones
  thermal_zones.each do |thermal_zone| # this is going through all, not just selection

    thermal_zone.equipment.each do |equip|

      #For the hydronic conditions below only, it will rename the zonal coils as well.
      if not equip.to_AirTerminalSingleDuctVAVReheat.empty?

        equip.setName("#{thermal_zone.name}:AirTerminalSingleDuctVAVReheat")
        reheat_coil = equip.to_AirTerminalSingleDuctVAVReheat.get.reheatCoil
        reheat_coil.setName("#{thermal_zone.name}:ReheatCoil")
        #puts reheat_coil.name
      elsif not equip.to_ZoneHVACBaseboardConvectiveWater.empty?
        equip.setName("#{thermal_zone.name}:ZoneHVACBaseboardConvectiveWater")
        heatingCoil = equip.to_ZoneHVACBaseboardConvectiveWater.get.heatingCoil
        heatingCoil.setName("#{thermal_zone.name}:Baseboard HW Htg Coil")
        #puts heatingCoil.name
      elsif not equip.to_ZoneHVACUnitHeater.empty?
        equip.setName("#{thermal_zone.name}:ZoneHVACUnitHeater")
        heatingCoil = equip.to_ZoneHVACUnitHeater.get.heatingCoil
        heatingCoil.setName("#{thermal_zone.name}:Unit Heater Htg Coil")
        #puts heatingCoil.name
        #Add more cases if you wish!!!!!
      else #if the equipment does not follow the above cases, rename
        # it generically and not touch the underlying coils, etc.
        equip.setName("#{thermal_zone.name}:#{equip.name}")
      end

    end
  end
  #puts "Done zone renaming equipment"
end
rename_zones_based_on_spaces(model) click to toggle source

this was a copy of the sketchup plugin method.

# File lib/openstudio-standards/btap/geometry.rb, line 49
def self.rename_zones_based_on_spaces(model)

  # loop through thermal zones
  model.getThermalZones.sort.each do |thermal_zone| # this is going through all, not just selection
    #puts "old zone name : #{thermal_zone.name}"
    # reset the array of spaces to be empty
    spaces_in_thermal_zone = []
    # reset length of array of spaces
    number_of_spaces = 0

    # get list of spaces in thermal zone
    spaces = thermal_zone.spaces
    spaces.sort.each do |space|

      # make an array instead of the puts statement
      spaces_in_thermal_zone.push space.name.to_s

    end

    # store length of array
    number_of_spaces = spaces_in_thermal_zone.size

    # sort the array
    spaces_in_thermal_zone = spaces_in_thermal_zone.sort

    # setup a suffix if the thermal zone contains more than one space
    if number_of_spaces > 1
      multi = " - Plus"
    else
      multi = ""
    end

    # rename thermal zone based on first space with prefix added e.g. ThermalZone 203
    if number_of_spaces > 0
      new_name = "ZN:" + spaces_in_thermal_zone[0] + multi
      thermal_zone.setName(new_name)
    else
      puts "#{thermal_zone.name.to_s} did not have any spaces, and will not be renamed."
    end
    #puts "new zone name : #{thermal_zone.name}"
  end
end
rotate_building(model: , degrees: nil) click to toggle source
# File lib/openstudio-standards/btap/geometry.rb, line 208
def self.rotate_building(model: , degrees: nil)

  # report as not applicable if effective relative rotation is 0
  if degrees == 0 || degrees.nil?
    puts ('The requested rotation was 0 or nil degrees. The model was not rotated.')
    return
  end

  # check the relative_building_rotation for reasonableness
  degrees -= 360.0 * (degrees / 360.0).truncate if (degrees > 360) || (degrees < -360)

  # reporting initial condition of model
  building = model.getBuilding
  # rotate the building
  final_building_angle = building.setNorthAxis(building.northAxis + degrees)
end
rotate_model(model, degrees) click to toggle source

This method will rotate the model @param model [OpenStudio::Model::Model] OpenStudio model object @param degrees [Float] rotation value @return [OpenStudio::Model::Model] the model object.

# File lib/openstudio-standards/btap/geometry.rb, line 201
def self.rotate_model(model, degrees)
  # Identity matrix for setting space origins
  t = OpenStudio::Transformation::rotation(OpenStudio::Vector3d.new(0, 0, 1), degrees * Math::PI / 180)
  model.getPlanarSurfaceGroups().each {|planar_surface| planar_surface.changeTransformation(t)}
  return model
end
scale_model(model, x, y, z) click to toggle source

This method will scale the model @param model [OpenStudio::Model::Model] OpenStudio model object @param x [Float] x scalar multiplier. @param y [Float] y scalar multiplier. @param z [Float] z scalar multiplier. @return [OpenStudio::Model::Model] the model object.

# File lib/openstudio-standards/btap/geometry.rb, line 160
def self.scale_model(model, x, y, z)
  # Identity matrix for setting space origins
  m = OpenStudio::Matrix.new(4, 4, 0)

  m[0, 0] = 1.0 / x
  m[1, 1] = 1.0 / y
  m[2, 2] = 1.0 / z
  m[3, 3] = 1.0
  t = OpenStudio::Transformation.new(m)
  model.getPlanarSurfaceGroups().each do |planar_surface|
    planar_surface.changeTransformation(t)
  end
  return model
end