Skip to content

Commit

Permalink
add converter for space infiltration and ventilation
Browse files Browse the repository at this point in the history
@pflaumingo
Uses the following gbxml fields, some of which needed to be added to the data model:
InfiltrationFlowPerSpace
InfiltrationFlowPerSpaceArea
InfiltrationFlowPerExteriorSurfaceArea
InfiltrationFlowPerExteriorWallArea
InfiltrationFlowAirChangesPerHour
OAFlowPerPerson
OAFlowPerArea
OAFlowPerSpace
OAFlowAirChangesPerHour
  • Loading branch information
mdahlhausen committed Dec 14, 2018
1 parent 88d62aa commit e6de0f5
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
Binary file added gbxmls/VentilationAndInfiltration.xml
Binary file not shown.
48 changes: 48 additions & 0 deletions measures/advanced_import_gbxml/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def run(model, runner, user_arguments)

# Populate hash for space load instances for people, lights, and electric equipment.
# Don't duplicate load definitions if an equivalent one has already been made.

# gather lights
unless element.elements['LightPowerPerArea'].nil?
# todo - add code for different unit types, for now assuming value is W/ft^2
Expand All @@ -151,6 +152,7 @@ def run(model, runner, user_arguments)
end
advanced_inputs[:spaces][element.attributes['id']][:light_defs] = light_power_per_area
end

# gather electric equipment
unless element.elements['EquipPowerPerArea'].nil?
# todo - add code for different unit types, for now assuming value is W/ft^2
Expand All @@ -160,6 +162,7 @@ def run(model, runner, user_arguments)
end
advanced_inputs[:spaces][element.attributes['id']][:equip_defs] = equip_power_per_area
end

# gather people
# unlike lights and equipment, there are multiple people objects in the space to inspect
space_people_attributes = {}
Expand All @@ -179,6 +182,51 @@ def run(model, runner, user_arguments)
advanced_inputs[:spaces][element.attributes['id']][:people_defs] = space_people_attributes
end

# gather infiltration
# todo - add code for different unit types
infiltration_def = { infiltration_flow_per_space: 0.0, # cfm
infiltration_flow_per_space_area: 0.0, # cfm/ft2
infiltration_flow_per_exterior_surface_area: 0.0, # cfm/ft2
infiltration_flow_per_exterior_wall_area: 0.0, # cfm/ft2
infiltration_flow_air_changes_per_hour: 0.0 } # 1/h
# todo - add support for infiltration coefficients
if !element.elements['InfiltrationFlowPerSpace'].nil?
infiltration_def[:infiltration_flow_per_space] = element.elements['InfiltrationFlowPerSpace'].text.to_f
end
if !element.elements['InfiltrationFlowPerSpaceArea'].nil?
infiltration_def[:infiltration_flow_per_space_area] = element.elements['InfiltrationFlowPerSpaceArea'].text.to_f
end
if !element.elements['InfiltrationFlowPerExteriorSurfaceArea'].nil?
infiltration_def[:infiltration_flow_per_exterior_surface_area] = element.elements['InfiltrationFlowPerExteriorSurfaceArea'].text.to_f
end
if !element.elements['InfiltrationFlowPerExteriorWallArea'].nil?
infiltration_def[:infiltration_flow_per_exterior_wall_area] = element.elements['InfiltrationFlowPerExteriorWallArea'].text.to_f
end
if !element.elements['InfiltrationFlowAirChangesPerHour'].nil?
infiltration_def[:infiltration_flow_air_changes_per_hour] = element.elements['InfiltrationFlowAirChangesPerHour'].text.to_f
end
advanced_inputs[:spaces][element.attributes['id']][:infiltration_def] = infiltration_def

# gather ventilation
# todo - add code for different unit types
ventilation_def = { ventilation_flow_per_person: 0.0, # cfm
ventilation_flow_per_area: 0.0, # cfm/ft2
ventilation_flow_per_space: 0.0, # cfm
ventilation_flow_air_changes_per_hour: 0.0 } # 1/h
if !element.elements['OAFlowPerPerson'].nil?
ventilation_def[:ventilation_flow_per_person] = element.elements['OAFlowPerPerson'].text.to_f
end
if !element.elements['OAFlowPerArea'].nil?
ventilation_def[:ventilation_flow_per_area] = element.elements['OAFlowPerArea'].text.to_f
end
if !element.elements['OAFlowPerSpace'].nil?
ventilation_def[:ventilation_flow_per_space] = element.elements['OAFlowPerSpace'].text.to_f
end
if !element.elements['OAFlowAirChangesPerHour'].nil?
ventilation_def[:ventilation_flow_air_changes_per_hour] = element.elements['OAFlowAirChangesPerHour'].text.to_f
end
advanced_inputs[:spaces][element.attributes['id']][:ventilation_def] = ventilation_def

# Noah: Adding hard coding of volume to spaces
# Todo: check units of the gbXML file
id_element = element.elements['CADObjectId']
Expand Down
35 changes: 35 additions & 0 deletions measures/advanced_import_gbxml/resources/os_lib_adv_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def self.add_objects_from_adv_import_hash(runner, model, advanced_inputs)
def self.assign_space_attributes(runner, model, spaces, schedule_sets, lights, elec_equipment, people)

# loop through spaces and assign attributes
# ventilation and infiltration do not have separate load definitions, and are assigned directly to the space
# note that spaces in model may use name element if it exist instead of id attribute
modified_spaces = {}
spaces.each do |id, space_data|
Expand Down Expand Up @@ -136,6 +137,40 @@ def self.assign_space_attributes(runner, model, spaces, schedule_sets, lights, e
load_inst.setActivityLevelSchedule(sch_ruleset)
end

# create infiltration load instances
if space_data.has_key?(:infiltration_def)
load_inst = OpenStudio::Model::SpaceInfiltrationDesignFlowRate.new(model)
# include guard clause for valid infiltration input
value_m3_s = OpenStudio.convert(space_data[:infiltration_def][:infiltration_flow_per_space], 'cfm', 'm^3/s').get
load_inst.setDesignFlowRate(value_m3_s)
value_m_s = OpenStudio.convert(space_data[:infiltration_def][:infiltration_flow_per_space_area], 'cfm/ft^2', 'm/s').get
load_inst.setFlowperSpaceFloorArea(value_m_s)
value_m_s = OpenStudio.convert(space_data[:infiltration_def][:infiltration_flow_per_exterior_surface_area], 'cfm/ft^2', 'm/s').get
load_inst.setFlowperExteriorSurfaceArea(value_m_s)
value_m_s = OpenStudio.convert(space_data[:infiltration_def][:infiltration_flow_per_exterior_wall_area], 'cfm/ft^2', 'm/s').get
load_inst.setFlowperExteriorWallArea(value_m_s)
load_inst.setAirChangesperHour(space_data[:infiltration_def][:infiltration_flow_air_changes_per_hour])
load_inst.setName("#{space.name.to_s}_infiltration")
load_inst.setSpace(space)
modified = true
end

# create ventilation instances
if space_data.has_key?(:ventilation_def)
vent_inst = OpenStudio::Model::DesignSpecificationOutdoorAir.new(model)
# include guard clause for valid ventilation input
value_m3_s = OpenStudio.convert(space_data[:ventilation_def][:ventilation_flow_per_person], 'cfm', 'm^3/s').get
vent_inst.setOutdoorAirFlowperPerson(value_m3_s)
value_m_s = OpenStudio.convert(space_data[:ventilation_def][:ventilation_flow_per_area], 'cfm/ft^2', 'm/s').get
vent_inst.setOutdoorAirFlowperFloorArea(value_m_s)
value_m3_s = OpenStudio.convert(space_data[:ventilation_def][:ventilation_flow_per_space], 'cfm', 'm^3/s').get
vent_inst.setOutdoorAirFlowRate(value_m3_s)
vent_inst.setOutdoorAirFlowAirChangesperHour(space_data[:ventilation_def][:ventilation_flow_air_changes_per_hour])
vent_inst.setName("#{space.name.to_s}_ventilation")
vent_inst.setSpace(space)
modified = true
end

# if modified add to modified_spaces hash
if modified
modified_spaces[id] = space
Expand Down

0 comments on commit e6de0f5

Please sign in to comment.