First time here? Check our help page!
2

Optimal code to set window constructions by Orientation

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!

antonszilasi's avatar
1.5k
antonszilasi
asked 2018-12-03 18:29:08 -0500
__AmirRoth__'s avatar
4.4k
__AmirRoth__
updated 2018-12-04 11:41:45 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

2

@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
David Goldwasser's avatar
20.4k
David Goldwasser
answered 2018-12-04 13:23:16 -0500, updated 2018-12-04 14:03:10 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments