Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
2

Optimal code to set window constructions by Orientation

asked 2018-12-03 18:29:08 -0500

antonszilasi's avatar

updated 2018-12-04 11:41:45 -0500

I need to set window constructions by orientation, at the moment I am using some code which I ripped from the ReplaceExteriorWindowConstruction measure and modified a bit. The code is as follows:

pi = 3.1415926
orientations = ["South","East","West","North"]

orientations.each do |orientation|

  case orientation
  when "South"
    max_azimuth = pi*5/4
    min_azimuth = pi*3/4
    max_1_azimuth = pi*5/4
    min_1_azimuth = pi*3/4
    max_2_azimuth = pi*5/4
    min_2_azimuth = pi*3/4

    winConstruction = WindowTypeSouth

  when "East"
    max_azimuth = pi*3/4
    min_azimuth = pi/4
    max_1_azimuth = pi*3/4
    min_1_azimuth = pi/4 #(0.78539815)
    max_2_azimuth = pi*3/4
    min_2_azimuth = pi/4

    winConstruction = WindowTypeEast

  when "West"
    max_azimuth = pi*7/4
    min_azimuth = pi*5/4
    max_1_azimuth = pi*7/4
    min_1_azimuth = pi*5/4
    max_2_azimuth = pi*7/4
    min_2_azimuth = pi*5/4

    winConstruction = WindowTypeWest

  else
    # "North"
    max_azimuth = pi/4
    min_azimuth = 0
    max_1_azimuth = pi*2
    min_1_azimuth = pi*7/4
    max_2_azimuth = pi*2
    min_2_azimuth = pi*7/4

    winConstruction = WindowTypeNorth

  end

  sub_surfaces.each do |sub_surface|
    next if not (sub_surface.outsideBoundaryCondition == "Outdoors" and sub_surface.subSurfaceType == "FixedWindow")

    if (sub_surface.azimuth < max_azimuth and sub_surface.azimuth >= min_azimuth) or (sub_surface.azimuth < max_1_azimuth and sub_surface.azimuth >= min_1_azimuth) or (sub_surface.azimuth < max_2_azimuth and sub_surface.azimuth >= min_2_azimuth)

      sub_surface.setConstruction(winConstruction)

    end # Large if statement
  end # sub_surfaces.each

As far as I can tell it works fine but what happens if we change the orientation of the building? That is why I was thinking of modifiying the getExteriorWindowAndWllAreaByOrientation function in os_lib_geometry.rb to produce

spaceArray.each do |space|

  space.surfaces.each do |s|
    next if s.surfaceType != 'Wall'
    next if s.outsideBoundaryCondition != 'Outdoors'

    # loop through sub surfaces and add area including multiplier

    absoluteAzimuth = OpenStudio.convert(s.azimuth, 'rad', 'deg').get + s.space.get.directionofRelativeNorth + model.getBuilding.northAxis
    absoluteAzimuth -= 360.0 until absoluteAzimuth < 360.0

    # add to exterior wall counter if north or south
    if (options['northEast'] <= absoluteAzimuth) && (absoluteAzimuth < options['southEast']) # East exterior walls

        winConstruction = WindowTypeEast

    elsif (options['southEast'] <= absoluteAzimuth) && (absoluteAzimuth < options['southWest']) # South exterior walls

        winConstruction = WindowTypeSouth

    elsif (options['southWest'] <= absoluteAzimuth) && (absoluteAzimuth < options['northWest']) # West exterior walls

        winConstruction = WindowTypeWest

    else # North exterior walls
        winConstruction = WindowTypeNorth
    end

    s.subSurfaces.each do |subSurface|

      sub_surface.setConstruction(winConstruction)

    end

  end
end

I think that the latter is the better option as I believe that it takes into account building orientation.

What does everyone recommend? Or is there some better code out there which Im missing? Suggestions are most appreciated!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-12-04 13:23:16 -0500

updated 2018-12-04 14:03:10 -0500

@antonszilasi that looks good, but if you are not filtering by spaces at all, then you can just loop through sub_surfaces directly, and then just set the constructions within the elsif statements.

model.getSubSurfaces.each do |sub_surface|
  # only alter exterior windows.
  next if sub_surface.subSurfaceType != 'FixedWindow'
  next if sub_surface.outsideBoundaryCondition != 'Outdoors'

  # store absoluteAzimuth
  absoluteAzimuth = OpenStudio.convert(sub_surface.azimuth, 'rad', 'deg').get + sub_surface.space.get.directionofRelativeNorth + model.getBuilding.northAxis
  absoluteAzimuth -= 360.0 until absoluteAzimuth < 360.0

  # check orientation and assign construction
  if (options['northEast'] <= absoluteAzimuth) && (absoluteAzimuth < options['southEast']) # East exterior walls
    sub_surface.setConstruction(WindowTypeEast)
  elsif (options['southEast'] <= absoluteAzimuth) && (absoluteAzimuth < options['southWest']) # South exterior walls
    sub_surface.setConstruction(WindowTypeSouth)
  elsif (options['southWest'] <= absoluteAzimuth) && (absoluteAzimuth < options['northWest']) # West exterior walls
    sub_surface.setConstruction(WindowTypeWest)
  else # North exterior walls
    sub_surface.setConstruction(WindowTypeNorth)
  end
end
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Careers

Question Tools

1 follower

Stats

Asked: 2018-12-03 18:29:08 -0500

Seen: 170 times

Last updated: Dec 04 '18