Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
2

Can i transmit the ventilation calculated by MATLAB to EnergyPlus to calculate the energy consumption?

asked 2018-06-24 21:09:59 -0600

HVAC-JAY's avatar

updated 2018-07-05 12:26:22 -0600

hello,everyone Can i transmit the ventilation calculated by MATLAB to EnergyPlus to calculate the energy consumption? Ventilation is calculated by reading the parameters in the meteorological document.

I mainly want to use bcvtb (or bcvtb and matlab)to realize the change in the internal ventilation of EnergyPlus. The model is running in the wrong way. image description

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2018-06-26 20:30:25 -0600

updated 2018-06-26 20:30:39 -0600

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.

edit flag offensive delete link more

Comments

Thanks a lot,now I mainly want to use bcvtb (or bcvtb and matlab)to realize the change in the internal ventilation of EnergyP``lus. The model is running in the wrong way.

HVAC-JAY's avatar HVAC-JAY  ( 2018-07-05 06:57:32 -0600 )edit

The wrong hints are in my answer

HVAC-JAY's avatar HVAC-JAY  ( 2018-07-05 07:05:02 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Careers

Question Tools

2 followers

Stats

Asked: 2018-06-24 21:09:59 -0600

Seen: 263 times

Last updated: Jul 05 '18