NatLabRockies / NatLabRockies/OpenStudio
OS:ShadingControl with multiple subsurfaces in different zones creates dupicate WindowShadingControl objects
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 646
- Forks
- 237
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 10
Description
Issue overview
Assigning the same ShadingControl object to windows in different zones results in multiple WindowShadingControl idf objects that reference just one Zone Name, all with the same collection of windows.
Current Behavior
MCVE:
require 'openstudio'
include OpenStudio::Model
model = Model.new
# create a couple zones with spaces and windows
windows = []
length, width, height = [3.0] * 3
2.times do |i|
floor_vertices = [
OpenStudio::Point3d.new((i * width),0,0),
OpenStudio::Point3d.new((i * width),length, 0),
OpenStudio::Point3d.new(width + (i * width),length,0),
OpenStudio::Point3d.new(width + (i * width),0,0)
]
space = Space.fromFloorPrint(floor_vertices, height, model, "Space #{i}").get
south_wall = space.surfaces.select {|s| s.outwardNormal.y.abs > 0.9}.min_by {|s| s.vertices.map(&:y).min }
window_vertices = [
OpenStudio::Point3d.new((i * width) + (width / 2) - 1, 0, 1),
OpenStudio::Point3d.new((i * width) + (width / 2) + 1, 0, 1),
OpenStudio::Point3d.new((i * width) + (width / 2) + 1, 0, 2),
OpenStudio::Point3d.new((i * width) + (width / 2) - 1, 0, 2)
]
window = SubSurface.new(window_vertices, model)
window.setSubSurfaceType('FixedWindow')
window.setSurface(south_wall)
windows << window
tz = ThermalZone.new(model)
space.setThermalZone(tz)
end
model.getThermalZones.each do |tz|
puts tz.name
tz.spaces.first.surfaces.each {|s| s.subSurfaces.each {|w| puts w.name}}
end
# =>
# Thermal Zone 1
# Sub Surface 1
# Thermal Zone 2
# Sub Surface 2
# add shading control
shading_mat = Blind.new(model)
shading_control = ShadingControl.new(shading_mat)
# control both windows
windows.each {|w| w.addShadingControl(shading_control)}
ft = OpenStudio::EnergyPlus::ForwardTranslator.new
idf = ft.translateModel(model)
# =>
# [openstudio.model.ShadingControl] <0> For Object of type 'OS:ShadingControl' and named 'Shading Control 2', SubSurface already exists.
# [openstudio.energyplus.ForwardTranslator] <0> Object of type 'OS:ShadingControl' and named 'Shading Control 1' controls SubSurfaces in multiple zones
# [openstudio.energyplus.ForwardTranslator] <0> Object of type 'OS:ShadingControl' and named 'Shading Control 2' controls SubSurfaces in multiple zones
idf.getObjectsByType('WindowShadingControl').each do |o|
puts o.getString(1)
o.extensibleGroups.each do |g|
puts g.getString(0)
end
end
# =>
# Thermal Zone 1
# Sub Surface 1
# Sub Surface 2
# Thermal Zone 1
# Sub Surface 1
# Sub Surface 2
Expected Behavior
Field: Zone Name
Name of the zone where this shading control is used.
Field: Fenestration Surface Name
The name of a FenestrationSurface:Detailed, Window, or GlazedDoor object controlled by this WindowShadingControl. This field can be repeated to apply the same shading control to more than one fenestration surface. When Multiple Surface Control Type is set to Sequential, the order of the Fenestration Surface Names is the order that the shades will be deployed. The object is extensible so additional fields of fenestration surface names can be added to the object. All of the fenestration surfaces must be either in the zone specified in the Zone Name field or in an adjacent zone connected by an interior window.
Note: despite the bolded section, EnergyPlus will run just fine with multiple WindowShadingControls where the referenced Zone doesn't contain the FenestrationSurface, and appears to apply the shading to all surfaces (maybe it only cares if shading is connected to a daylighting control?).
I think where windows in different zones are added to the same ShadingControl object, OpenStudio should make one WindowShadingControl per zone (with Zone Name field set accordingly), and only that zone's windows as the Fenestration Surface Name(s).
Possible Solution
Details
Environment
Some additional details about your environment for this issue (if relevant):
- Platform (Operating system, version): Windows 11
- Version of OpenStudio (if using an intermediate build, include SHA): 3.9.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Ruby MCVE through OpenStudio::EnergyPlus::ForwardTranslator and inspect the generated WindowShadingControl objects. Trace how OS::ShadingControl assignments are grouped by zone. Done means each zone gets its own control object containing only that zone's windows, with the issue's duplicate-object warnings no longer occurring.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100