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

Revision history [back]

@kapils16 it is great to see cross simulation data being used in this way. Prior to OpenStudio 2.7.0 you would have to write this as an EnergyPlus measure to use it with OpenStudio, but scheduleFile is now part of the OpenStudio SDK. Your code would look something like this

model.spaces.each do |space|
  space.people.each do |people|
    # arguments are file, column, rows to skip
    schedule_file_new = OpenStudio::Model::ScheduleFile.new("ped_sim_fract.csv",25,1)
    people.setNumberofPeopleSchedule(schedule_file_new)
  end
end

The code above assumes you have a fractional schedule associated with the design level of people in the OpenStudio model. If your CSV file contains actual number of people, then you are still fine, you just need to add more code before you loop through people. Use standard ruby methods to create a new copy of the ped_sim_raw.csv file. Set the first row to the maximum number of people found in the column. Then convert all raw entries to a fractional value. You could create a unique people object for each space, but a better approach would be a people definition object that represents a single person. If your pedestrian simulation supports it you can have different people types with different activity levels. When you loop through the people objects in each space you can set the multiplier based on the maximum value from for that column from the raw data, or saved in the top of fractional csv. Code to change multiplier would look like this.

people.setMultiplier(max_num_people_for_room_from_ped_sim)

@kapils16 it is great to see cross simulation data being used in this way. Prior to OpenStudio 2.7.0 you would have to write this as an EnergyPlus measure to use it with OpenStudio, but scheduleFile is now part of the OpenStudio SDK. Your code would look something like this

model.spaces.each do |space|
  space.people.each do |people|
    # arguments are file, column, rows to skip
    schedule_file_new = OpenStudio::Model::ScheduleFile.new("ped_sim_fract.csv",25,1)
    people.setNumberofPeopleSchedule(schedule_file_new)
  end
end

The code above assumes you have a fractional schedule associated with the design level of people for each space in the OpenStudio model. If your CSV file contains actual number of people, then you are still fine, you just need to add more code before you loop through people. Use standard ruby methods to create a new copy of the ped_sim_raw.csv file. Set the first row to the maximum number of people found in the column. Then Next convert all raw entries to a fractional value based on the maximum value. You could create a unique people object for each space, but a better cleaner approach would be to create a people definition object that represents a single person. If your pedestrian simulation supports it you can have different people types with different activity levels. When you loop through the people objects in each space you can set the multiplier based on the maximum value from for that column from the raw data, or saved in the top of fractional csv. Code to change multiplier would look like this.

people.setMultiplier(max_num_people_for_room_from_ped_sim)

@kapils16 it is great to see cross simulation data being used in this way. Prior to OpenStudio 2.7.0 you would have to write this as an EnergyPlus measure to use it with OpenStudio, but scheduleFile is now part of the OpenStudio SDK. Your code would look something like this

model.spaces.each do |space|
  space.people.each do |people|
    # arguments are file, column, rows to skip
    schedule_file_new = OpenStudio::Model::ScheduleFile.new("ped_sim_fract.csv",25,1)
    people.setNumberofPeopleSchedule(schedule_file_new)
  end
end

The code above assumes you have a fractional schedule associated with the design level of people for each space in the OpenStudio model. If your CSV file contains actual number of people, then you are still fine, you just need to add more code before you loop through people. Use standard ruby methods to create a new copy of the ped_sim_raw.csvfile. Set the first row to the maximum number of people found in the column. Next convert all raw entries to a fractional value based on the maximum value. You could create a unique people object for each space, but a cleaner approach would be to create a people definition that represents a single person. If your pedestrian simulation supports it you can have different people types with different activity levels. When you loop through the people objects in each space you can set the multiplier based on the maximum value from for that column from the raw data, or saved in the top of fractional csv. Code to change multiplier would look like this.

people.setMultiplier(max_num_people_for_room_from_ped_sim)

Here is a link to the OpenStudio API documentation for scheduleFile. The fields should be similar to what is in the EnergyPlus ScheudleFile object.

@kapils16 it is great to see cross simulation data being used in this way. Prior to OpenStudio 2.7.0 you would have to write this as an EnergyPlus measure to use it with OpenStudio, but scheduleFile is now part of the OpenStudio SDK. Your code would look something like this

model.spaces.each model.getSpaces.each do |space|
  space.people.each do |people|
    # arguments are file, column, rows to skip
    schedule_file_new = OpenStudio::Model::ScheduleFile.new("ped_sim_fract.csv",25,1)
    people.setNumberofPeopleSchedule(schedule_file_new)
  end
end

The code above assumes you have a fractional schedule associated with the design level of people for each space in the OpenStudio model. If your CSV file contains actual number of people, then you are still fine, you just need to add more code before you loop through people. Use standard ruby methods to create a new copy of the ped_sim_raw.csvfile. Set the first row to the maximum number of people found in the column. Next convert all raw entries to a fractional value based on the maximum value. You could create a unique people object for each space, but a cleaner approach would be to create a people definition that represents a single person. If your pedestrian simulation supports it you can have different people types with different activity levels. When you loop through the people objects in each space you can set the multiplier based on the maximum value from for that column from the raw data, or saved in the top of fractional csv. Code to change multiplier would look like this.

people.setMultiplier(max_num_people_for_room_from_ped_sim)

Here is a link to the OpenStudio API documentation for scheduleFile. The fields should be similar to what is in the EnergyPlus ScheudleFile object.

@kapils16 it is great to see cross simulation data being used in this way. Prior to OpenStudio 2.7.0 you would have to write this as an EnergyPlus measure to use it with OpenStudio, but scheduleFile is now part of the OpenStudio SDK. Your code would look something like this

Note: Code updated to correctly use externalFile object instead of string with scheduleFile. externalFile copies the referenced file into the models "files" directory making the file easier to find at run time and more transportable.

ext_file = OpenStudio::Model::ExternalFile::getExternalFile(model,"/Users/myusername/Documents/temp.csv")
if ext_file.is_initialized
  ext_file = ext_file.get
  puts "Warning, could not find file"
end
model.getSpaces.each do |space|
  space.people.each do |people|
    # arguments are file, column, rows to skip
    schedule_file_new = OpenStudio::Model::ScheduleFile.new("ped_sim_fract.csv",25,1)
OpenStudio::Model::ScheduleFile.new(ext_file,25,1)
    people.setNumberofPeopleSchedule(schedule_file_new)
  end
end

The code above assumes you have a fractional schedule associated with the design level of people for each space in the OpenStudio model. If your CSV file contains actual number of people, then you are still fine, you just need to add more code before you loop through people. Use standard ruby methods to create a new copy of the ped_sim_raw.csvfile. Set the first row to the maximum number of people found in the column. Next convert all raw entries to a fractional value based on the maximum value. You could create a unique people object for each space, but a cleaner approach would be to create a people definition that represents a single person. If your pedestrian simulation supports it you can have different people types with different activity levels. When you loop through the people objects in each space you can set the multiplier based on the maximum value from for that column from the raw data, or saved in the top of fractional csv. Code to change multiplier would look like this.

people.setMultiplier(max_num_people_for_room_from_ped_sim)

Here is a link to the OpenStudio API documentation for scheduleFile. The fields should be similar to what is in the EnergyPlus ScheudleFile object.

@kapils16 it is great to see cross simulation data being used in this way. Prior to OpenStudio 2.7.0 you would have to write this as an EnergyPlus measure to use it with OpenStudio, but scheduleFile is now part of the OpenStudio SDK. Your code would look something like this

Note: Code updated to correctly use externalFile object instead of string with scheduleFile. externalFile copies the referenced file into the models "files" directory making the file easier to find at run time and more transportable.transportable. If the CSV is not found this will fail.

ext_file = OpenStudio::Model::ExternalFile::getExternalFile(model,"/Users/myusername/Documents/temp.csv")
if ext_file.is_initialized
  ext_file = ext_file.get
  puts "Warning, could not find file"
end
model.getSpaces.each do |space|
  space.people.each do |people|
    # arguments are file, column, rows to skip
    schedule_file_new = OpenStudio::Model::ScheduleFile.new(ext_file,25,1)
    people.setNumberofPeopleSchedule(schedule_file_new)
  end
end

The code above assumes you have a fractional schedule associated with the design level of people for each space in the OpenStudio model. If your CSV file contains actual number of people, then you are still fine, you just need to add more code before you loop through people. Use standard ruby methods to create a new copy of the ped_sim_raw.csvfile. Set the first row to the maximum number of people found in the column. Next convert all raw entries to a fractional value based on the maximum value. You could create a unique people object for each space, but a cleaner approach would be to create a people definition that represents a single person. If your pedestrian simulation supports it you can have different people types with different activity levels. When you loop through the people objects in each space you can set the multiplier based on the maximum value from for that column from the raw data, or saved in the top of fractional csv. Code to change multiplier would look like this.

people.setMultiplier(max_num_people_for_room_from_ped_sim)

Here is a link to the OpenStudio API documentation for scheduleFile. The fields should be similar to what is in the EnergyPlus ScheudleFile object.

@kapils16 it is great to see cross simulation data being used in this way. Prior to OpenStudio 2.7.0 you would have to write this as an EnergyPlus measure to use it with OpenStudio, but scheduleFile is now part of the OpenStudio SDK. Your code would look something like this

Note: Code updated to correctly use externalFile object instead of string with scheduleFile. externalFile copies the referenced file into the models "files" directory making the file easier to find at run time and more transportable. If the CSV is not found this will fail.

ext_file = OpenStudio::Model::ExternalFile::getExternalFile(model,"/Users/myusername/Documents/temp.csv")
if ext_file.is_initialized
  ext_file = ext_file.get
  puts "Warning, could not find file"
end
model.getSpaces.each do |space|
  space.people.each do |people|
    # arguments are file, column, rows to skip
    schedule_file_new = OpenStudio::Model::ScheduleFile.new(ext_file,25,1)
    people.setNumberofPeopleSchedule(schedule_file_new)
  end
end

The code above assumes you have a fractional schedule associated with the design level of people for each space in the OpenStudio model. If your CSV file contains actual number of people, then you are still fine, you just need to add more code before you loop through people. Use standard ruby methods to create a new copy of the ped_sim_raw.csvfile. Set the first row to the maximum number of people found in the column. Next convert all raw entries to a fractional value based on the maximum value. You could create a unique people object for each space, but a cleaner approach would be to create a people definition that represents a single person. If your pedestrian simulation supports it you can have different people types with different activity levels. When you loop through the people objects in each space you can set the multiplier based on the maximum value from for that column from the raw data, or saved in the top of fractional csv. Code to change multiplier would look like this.

people.setMultiplier(max_num_people_for_room_from_ped_sim)

Here is a link to the OpenStudio API documentation for scheduleFile. The fields should be similar to what is in the EnergyPlus ScheudleFile object.

@kapils16 it is great to see cross simulation data being used in this way. Prior to OpenStudio 2.7.0 you would have to write this as an EnergyPlus measure to use it with OpenStudio, but scheduleFile is now part of the OpenStudio SDK. Your code would look something like this

Note: Code updated to correctly use externalFile object instead of string with scheduleFile. externalFile copies the referenced file into the models "files" directory making the file easier to find at run time and more transportable. If the CSV is not found this will fail.fail. This function works in OpenStudio 2.7.0, but there were fixes in 2.7.1 related to its use in Apply Measures Now in the OpenStudio application. If you are using it in that way, please update to 2.7.1.

ext_file = OpenStudio::Model::ExternalFile::getExternalFile(model,"/Users/myusername/Documents/temp.csv")
if ext_file.is_initialized
  ext_file = ext_file.get
  puts "Warning, could not find file"
end
model.getSpaces.each do |space|
  space.people.each do |people|
    # arguments are file, column, rows to skip
    schedule_file_new = OpenStudio::Model::ScheduleFile.new(ext_file,25,1)
    people.setNumberofPeopleSchedule(schedule_file_new)
  end
end

The code above assumes you have a fractional schedule associated with the design level of people for each space in the OpenStudio model. If your CSV file contains actual number of people, then you are still fine, you just need to add more code before you loop through people. Use standard ruby methods to create a new copy of the ped_sim_raw.csvfile. Set the first row to the maximum number of people found in the column. Next convert all raw entries to a fractional value based on the maximum value. You could create a unique people object for each space, but a cleaner approach would be to create a people definition that represents a single person. If your pedestrian simulation supports it you can have different people types with different activity levels. When you loop through the people objects in each space you can set the multiplier based on the maximum value from for that column from the raw data, or saved in the top of fractional csv. Code to change multiplier would look like this.

people.setMultiplier(max_num_people_for_room_from_ped_sim)

Here is a link to the OpenStudio API documentation for scheduleFile. The fields should be similar to what is in the EnergyPlus ScheudleFile object.

@kapils16 it is great to see cross simulation data being used in this way. Prior to OpenStudio 2.7.0 you would have to write this as an EnergyPlus measure to use it with OpenStudio, but scheduleFile is now part of the OpenStudio SDK. Your code would look something like this

Note: Code updated to correctly use externalFile object instead of string with scheduleFile. externalFile copies the referenced file into the models "files" directory making the file easier to find at run time and more transportable. If the CSV is not found this will fail. This function works in OpenStudio 2.7.0, but there were fixes in 2.7.1 related to its use in Apply Measures Now in the OpenStudio application. If you are using it in that way, please update to 2.7.1.

ext_file = OpenStudio::Model::ExternalFile::getExternalFile(model,"/Users/myusername/Documents/temp.csv")
if ext_file.is_initialized
  ext_file = ext_file.get
else
  puts "Warning, could not find file"
  runner.registerError("File could not be found and can not be assigned to ScheduleFile objects")
  return false
end
model.getSpaces.each do |space|
  space.people.each do |people|
    # arguments are file, column, rows to skip
    schedule_file_new = OpenStudio::Model::ScheduleFile.new(ext_file,25,1)
    people.setNumberofPeopleSchedule(schedule_file_new)
  end
end

The code above assumes you have a fractional schedule associated with the design level of people for each space in the OpenStudio model. If your CSV file contains actual number of people, then you are still fine, you just need to add more code before you loop through people. Use standard ruby methods to create a new copy of the ped_sim_raw.csvfile. Set the first row to the maximum number of people found in the column. Next convert all raw entries to a fractional value based on the maximum value. You could create a unique people object for each space, but a cleaner approach would be to create a people definition that represents a single person. If your pedestrian simulation supports it you can have different people types with different activity levels. When you loop through the people objects in each space you can set the multiplier based on the maximum value from for that column from the raw data, or saved in the top of fractional csv. Code to change multiplier would look like this.

people.setMultiplier(max_num_people_for_room_from_ped_sim)

Here is a link to the OpenStudio API documentation for scheduleFile. The fields should be similar to what is in the EnergyPlus ScheudleFile object.