module URBANopt::GeoJSON::Model

Public Class Methods

change_adjacent_surfaces_to_adiabatic(model, runner) click to toggle source

This method loops through each surface of the model for adjacent surfaces. It sets the outside boundary condition to these surfaces as Adiabatic and hard assigns the construction.

Returns an instance of OpenStudio::Model::Model with surfaces changed to adiabatic.

Parameters
  • model - Type:String - An instance of OpenStudio::Model::Model .

  • runner - Type:String - Measure run's instance of OpenStudio::Measure::OSRunner .

# File lib/urbanopt/geojson/model.rb, line 41
def self.change_adjacent_surfaces_to_adiabatic(model, runner)
  runner.registerInfo('Changing adjacent surfaces to adiabatic')
  model.getSurfaces.sort.each do |surface|
    adjacent_surface = surface.adjacentSurface
    if !adjacent_surface.empty?
      surface_construction = surface.construction
      if !surface_construction.empty?
        surface.setConstruction(surface_construction.get)
      end
      adjacent_surface_construction = adjacent_surface.get.construction
      if !adjacent_surface_construction.empty?
        surface.setOutsideBoundaryCondition('Adiabatic')
        adjacent_surface.get.setConstruction(adjacent_surface_construction.get)
      end
      adjacent_surface.get.setOutsideBoundaryCondition('Adiabatic')
    end
  end
  return model
end
create_construction_set(model, runner) click to toggle source

Used to add construction to the model. This method uses the default construction to the building, or creates a new+OpenStudio::Model::DefaultConstructionSet+ if no construction set is assigned.

Returns an instance of OpenStudio::Model::DefaultConstructionSet .

Parameters
  • model - Type:String - An instance of OpenStudio::Model::Model .

  • runner - Type:String - Measure run's instance of OpenStudio::Measure::OSRunner .

# File lib/urbanopt/geojson/model.rb, line 20
def self.create_construction_set(model, runner)
  default_construction_set = model.getBuilding.defaultConstructionSet
  if !default_construction_set.is_initialized
    runner.registerInfo('Starting model does not have a default construction set, creating new one')
    default_construction_set = OpenStudio::Model::DefaultConstructionSet.new(model)
  else
    default_construction_set = default_construction_set.get
  end
  return default_construction_set
end
create_space_type(bldg_use, space_use, model) click to toggle source

Returns instance of OpenStudio::Model::SpaceType.

Parameters
  • bldg_use - Type:String - Indicates the building use.

  • space_use - Type:String - Indicates the space use.

  • model - Type:String - An instance of OpenStudio::Model::Model .

# File lib/urbanopt/geojson/model.rb, line 92
def self.create_space_type(bldg_use, space_use, model)
  name = "#{bldg_use}:#{space_use}"
  model.getSpaceTypes.each do |s|
    if s.name.get == name
      return s
    end
  end
  space_type = OpenStudio::Model::SpaceType.new(model)
  space_type.setName(name)
  space_type.setStandardsBuildingType(bldg_use)
  space_type.setStandardsSpaceType(space_use)
  return space_type
end
transfer_prev_model_data(model, space_types) click to toggle source

Loops through all the building stories in the model and for each space sets space type from the building story if no space type is assigned.

Returns an Array of instances of OpenStudio::Model::Story .

Parameters
  • model - Type:String - An instance of OpenStudio::Model::Model .

  • space_types - Type:Array - Instances of OpenStudio::Model::SpaceType .

# File lib/urbanopt/geojson/model.rb, line 70
def self.transfer_prev_model_data(model, space_types)
  stories = []
  model.getBuildingStorys.each { |story| stories << story }
  stories.sort! { |x, y| x.nominalZCoordinate.to_s.to_f <=> y.nominalZCoordinate.to_s.to_f }

  stories.each_index do |i|
    space_type = space_types[i]
    next if space_type.nil?
    stories[i].spaces.each do |space|
      space.setSpaceType(space_type)
    end
  end
  return stories
end