First time here? Check out the Help page!
1 | initial version |
Ventilation rates are specified with the DesignSpecification:OutdoorAir object in EnergyPlus.
You could write matlab script to write out the names of the DesignSpecification:OutdoorAir objects you want to change and the new ventilation rates to a .csv file, and then apply it with the OpenStudio SDK acting on an .idf file.
For example, your matlab script writes out a .csv (ventilation.csv in the example) like this:
design_oa_name,ventilation_per_area
Office WholeBuilding - Md Office Ventilation,0.000762
In this case I'm specifying ventilation per area in units of m^3/s-m^2.
You have an initial .idf file (office.idf in the example) with an existing DesignSpecification:OutdoorAir object:
DesignSpecification:OutdoorAir,
Office WholeBuilding - Md Office Ventilation, !- Name
Sum, !- Outdoor Air Method
0, !- Outdoor Air Flow per Person {m3/s-person}
0.0004318, !- Outdoor Air Flow per Zone Floor Area {m3/s-m2}
0, !- Outdoor Air Flow per Zone {m3/s}
0; !- Outdoor Air Flow Air Changes per Hour {1/hr}
Use the OpenStudio SDK in a ruby script to change the DesignSpecification:OutdoorAir .idf objects:
require 'openstudio'
require 'csv'
# load the idf
idf_path = OpenStudio::Path.new("C:/path/office.idf")
workspace = OpenStudio::Workspace.load(idf_path)
workspace = workspace.get
design_oas = workspace.getObjectsByType("DesignSpecification:OutdoorAir".to_IddObjectType)
# load the ventilation data
ventilation_csv_path = "C:/path/ventilation.csv"
raw_data = CSV.table(ventilation_csv_path)
ventilation_lookup = raw_data.map { |row| row.to_hash } # transform to array of hashes
# for each DesignSpecification:OutdoorAir object, lookup the new ventilation value in the .csv file and apply it if it is defined
design_oas.each do |design_oa|
design_oa_name = design_oa.getString(0).to_s
row = ventilation_lookup.select{|r| r[:design_oa_name] == design_oa_name}
if row.empty?
puts "design oa name: #{design_oa_name} not found in lookup"
else
old_ventilation_per_area = design_oa.getDouble(3).to_f
new_ventilation_per_area = row[0][:ventilation_per_area]
design_oa.setDouble(3,new_ventilation_per_area)
puts "Changed ventilation for #{design_oa_name} from #{old_ventilation_per_area} m3/s-m2 to #{new_ventilation_per_area} m3/s-m2"
end
end
new_idf_path = "C:/path/office_new.idf"
workspace.save(new_idf_path,true)
office.idf now looks like:
DesignSpecification:OutdoorAir,
Office WholeBuilding - Md Office Ventilation, !- Name
Sum, !- Outdoor Air Method
0, !- Outdoor Air Flow per Person {m3/s-person}
0.000762, !- Outdoor Air Flow per Zone Floor Area {m3/s-m2}
0, !- Outdoor Air Flow per Zone {m3/s}
0; !- Outdoor Air Flow Air Changes per Hour {1/hr}
For more information on manipulating .idf files with the OpenStudio SDK, see the OpenStudio measure writing guide on EnergyPlus Measures. You may also find the SDK reference for IdfObjects helpful.
2 | No.2 Revision |
Ventilation rates are specified with the DesignSpecification:OutdoorAir object in EnergyPlus.
You could write a matlab script to write out the names of the DesignSpecification:OutdoorAir objects you want to change and the new ventilation rates to a .csv file, and then apply it with the OpenStudio SDK acting on an .idf file.
For example, your matlab script writes out a .csv (ventilation.csv in the example) like this:
design_oa_name,ventilation_per_area
Office WholeBuilding - Md Office Ventilation,0.000762
In this case I'm specifying ventilation per area in units of m^3/s-m^2.
You have an initial .idf file (office.idf in the example) with an existing DesignSpecification:OutdoorAir object:
DesignSpecification:OutdoorAir,
Office WholeBuilding - Md Office Ventilation, !- Name
Sum, !- Outdoor Air Method
0, !- Outdoor Air Flow per Person {m3/s-person}
0.0004318, !- Outdoor Air Flow per Zone Floor Area {m3/s-m2}
0, !- Outdoor Air Flow per Zone {m3/s}
0; !- Outdoor Air Flow Air Changes per Hour {1/hr}
Use the OpenStudio SDK in a ruby script to change the DesignSpecification:OutdoorAir .idf objects:
require 'openstudio'
require 'csv'
# load the idf
idf_path = OpenStudio::Path.new("C:/path/office.idf")
workspace = OpenStudio::Workspace.load(idf_path)
workspace = workspace.get
design_oas = workspace.getObjectsByType("DesignSpecification:OutdoorAir".to_IddObjectType)
# load the ventilation data
ventilation_csv_path = "C:/path/ventilation.csv"
raw_data = CSV.table(ventilation_csv_path)
ventilation_lookup = raw_data.map { |row| row.to_hash } # transform to array of hashes
# for each DesignSpecification:OutdoorAir object, lookup the new ventilation value in the .csv file and apply it if it is defined
design_oas.each do |design_oa|
design_oa_name = design_oa.getString(0).to_s
row = ventilation_lookup.select{|r| r[:design_oa_name] == design_oa_name}
if row.empty?
puts "design oa name: #{design_oa_name} not found in lookup"
else
old_ventilation_per_area = design_oa.getDouble(3).to_f
new_ventilation_per_area = row[0][:ventilation_per_area]
design_oa.setDouble(3,new_ventilation_per_area)
puts "Changed ventilation for #{design_oa_name} from #{old_ventilation_per_area} m3/s-m2 to #{new_ventilation_per_area} m3/s-m2"
end
end
new_idf_path = "C:/path/office_new.idf"
workspace.save(new_idf_path,true)
office.idf now looks like:
DesignSpecification:OutdoorAir,
Office WholeBuilding - Md Office Ventilation, !- Name
Sum, !- Outdoor Air Method
0, !- Outdoor Air Flow per Person {m3/s-person}
0.000762, !- Outdoor Air Flow per Zone Floor Area {m3/s-m2}
0, !- Outdoor Air Flow per Zone {m3/s}
0; !- Outdoor Air Flow Air Changes per Hour {1/hr}
For more information on manipulating .idf files with the OpenStudio SDK, see the OpenStudio measure writing guide on EnergyPlus Measures. You may also find the SDK reference for IdfObjects helpful.