First time here? Check out the Help page!
1 | initial version |
will@stok.com, I just answered your previous question to show you how to add a sub space type that makes the measure happy and will run. If however anyone is interested in a measure that will create space types from the characteristics of loads assigned to a space,I did create a start at this for internal uses and would be happy to share that code for someone who wants to take it farther. The basic approach was to normalize most loads per area, but ventilation was left per person if it was setup that way to start with. I then make space type and move the existing load instances to it, assign the space to that space type which results hard assigned space loads being removed. The current form is basic and does a unique space type for every space. Ideally it could use some logic such as name to find all "conference rooms" and using weighted average create a single space type, assuming they have the same operational schedule. I also didn't attempt to look at construction sets, but that would be another next step.
model.getSpaces.each do |space|
# make a new space type
space_type = OpenStudio::Model::SpaceType.new(model)
space_type.setName(space.name.get)
# move internal loads from space to new space type
space.people.each do |load|
if load.numberOfPeople.is_initialized
target_people_per_area = load.numberOfPeople.get/space.floorArea
load.peopleDefinition.setPeopleperSpaceFloorArea(target_people_per_area)
else
# if setup per area no changes necessary
end
load.setSpaceType(space_type)
end
space.internalMass.each do |load|
if load.surfaceArea.is_initialized
target_area_per_area = load.surfaceArea.get/space.floorArea # doesn't look for zone multiplier
load.internalMassDefinition.setSurfaceAreaperSpaceFloorArea(target_area_per_area)
end
load.setSpaceType(space_type)
end
space.lights.each do |load|
if load.lightingLevel.is_initialized
target_power_per_area = load.lightingLevel.get/space.floorArea
load.lightsDefinition.setWattsperSpaceFloorArea(target_power_per_area)
else
# if setup per person or area no changes necessary
end
load.setSpaceType(space_type)
end
space.electricEquipment.each do |load|
if load.designLevel.is_initialized
target_power_per_area = load.designLevel.get/space.floorArea
load.electricEquipmentDefinition.setWattsperSpaceFloorArea(target_power_per_area)
else
# if setup per person or area no changes necessary
end
load.setSpaceType(space_type)
end
space.gasEquipment.each do |load|
if load.designLevel.is_initialized
target_power_per_area = load.designLevel.get/space.floorArea
load.gasEquipmentDefinition.setWattsperSpaceFloorArea(target_power_per_area)
else
# if setup per person or area no changes necessary
end
load.setSpaceType(space_type)
end
space.spaceInfiltrationDesignFlowRates.each do |load|
# todo - normalize outdoor air per floor area
load.setSpaceType(space_type)
end
if space.designSpecificationOutdoorAir.is_initialized
load = space.designSpecificationOutdoorAir.get
# assign outdoor air to space type and reset for space
# todo - normalize outdoor air per floor area, code below only works in specific cases
flow_rate = load.outdoorAirFlowRate
flow_rate_per_floor_area = load.outdoorAirFlowperFloorArea
load.resetOutdoorAirFlowRate
load.setOutdoorAirFlowperFloorArea(flow_rate_per_floor_area + flow_rate/space.floorArea)
space_type.setDesignSpecificationOutdoorAir(load)
space.resetDesignSpecificationOutdoorAir
end
# add space to newly made space type
space.setSpaceType(space_type)
end