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

Revision history [back]

here is some sample ruby code that you would use in a measure to create a sensor, an actuator and a program:

Sensor

Create an output variable for OATdb

output_var = "Site Outdoor Air Drybulb Temperature" output_var_oat = OpenStudio::Model::OutputVariable.new(output_var, model)

Create a sensor to sense the outdoor air temperature

oat_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, output_var_oat) oat_sensor_name = "OATdb Sensor" oat_sensor.setName(oat_sensor_name)

Actuator

create a fan

always_on = model.alwaysOnDiscreteSchedule fan = OpenStudio::Model::FanConstantVolume.new(model,always_on)

Create an actuator to set the fan pressure rise

fan_press = "Fan Pressure Rise" fan_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(fan, "fan", fan_press) fan_actuator.setName("#{fan.name} Press Actuator")

Programs

Create a program all at once

fan_program_1 = OpenStudio::Model::EnergyManagementSystemProgram.new(model) fan_program_1.setName("#{fan.name} Pressure Rise Program by Line") fan_program_1_body = <<-EMS SET mult = #{oat_sensor.handle} / 15.0 !- This is nonsense SET #{fan_actuator.handle} = 250 * mult !- More nonsense EMS fan_program_1.setBody(fan_program_1_body)

Create a third program from a vector of lines

fan_program_2 = OpenStudio::Model::EnergyManagementSystemProgram.new(model) fan_program_2.setName("#{fan.name} Pressure Rise Program by Line") fan_program_2.addLine("SET mult = #{oat_sensor.handle} / 15.0 !- This is nonsense") fan_program_2.addLine("SET #{fan_actuator.handle} = 250 * mult !- More nonsense")

Create a third program from vector of lines

fan_program_3 = OpenStudio::Model::EnergyManagementSystemProgram.new(model) fan_program_3.setName("#{fan.name} Pressure Rise Program by Vector of Lines") fan_program_3_lines = [] fan_program_3_lines << "SET mult = #{oat_sensor.handle} / 15.0 !- This is nonsense" fan_program_3_lines << "SET #{fan_actuator.handle} = 250 * mult !- More nonsense" fan_program_3.setLines(fan_program_3_lines)

here is some sample ruby code that you would use in a measure to create a sensor, an actuator and a program:

Sensor

Create an output variable for OATdb

output_var = "Site Outdoor Air Drybulb Temperature" Temperature"

output_var_oat = OpenStudio::Model::OutputVariable.new(output_var, model)

Create a sensor to sense the outdoor air temperature

oat_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, output_var_oat) output_var_oat)

oat_sensor_name = "OATdb Sensor" Sensor"

oat_sensor.setName(oat_sensor_name)

Actuator

create a fan

always_on = model.alwaysOnDiscreteSchedule model.alwaysOnDiscreteSchedule

fan = OpenStudio::Model::FanConstantVolume.new(model,always_on)

Create an actuator to set the fan pressure rise

fan_press = "Fan Pressure Rise" Rise"

fan_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(fan, "fan", fan_press) fan_press)

fan_actuator.setName("#{fan.name} Press Actuator")

Programs

Create a program all at once

fan_program_1 = OpenStudio::Model::EnergyManagementSystemProgram.new(model) OpenStudio::Model::EnergyManagementSystemProgram.new(model)

fan_program_1.setName("#{fan.name} Pressure Rise Program by Line") Line")

fan_program_1_body = <<-EMS <<-EMS

SET mult = #{oat_sensor.handle} / 15.0 !- This is nonsense nonsense

SET #{fan_actuator.handle} = 250 * mult !- More nonsense EMS nonsense

EMS

fan_program_1.setBody(fan_program_1_body)

Create a third program from a vector of lines

fan_program_2 = OpenStudio::Model::EnergyManagementSystemProgram.new(model) OpenStudio::Model::EnergyManagementSystemProgram.new(model)

fan_program_2.setName("#{fan.name} Pressure Rise Program by Line") Line")

fan_program_2.addLine("SET mult = #{oat_sensor.handle} / 15.0 !- This is nonsense") nonsense")

fan_program_2.addLine("SET #{fan_actuator.handle} = 250 * mult !- More nonsense")

Create a third program from vector of lines

fan_program_3 = OpenStudio::Model::EnergyManagementSystemProgram.new(model) OpenStudio::Model::EnergyManagementSystemProgram.new(model)

fan_program_3.setName("#{fan.name} Pressure Rise Program by Vector of Lines") Lines")

fan_program_3_lines = [] []

fan_program_3_lines << "SET mult = #{oat_sensor.handle} / 15.0 !- This is nonsense" nonsense"

fan_program_3_lines << "SET #{fan_actuator.handle} = 250 * mult !- More nonsense" nonsense"

fan_program_3.setLines(fan_program_3_lines)

here is some sample ruby code that you would use in a measure to create a sensor, an actuator and a program:

Sensor

Create an output variable for OATdb

output_var = "Site Outdoor Air Drybulb Temperature"

output_var_oat = OpenStudio::Model::OutputVariable.new(output_var, model)

Create a sensor to sense the outdoor air temperature

oat_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, output_var_oat)

oat_sensor_name = "OATdb Sensor"

oat_sensor.setName(oat_sensor_name)

Actuator

create a fan

always_on = model.alwaysOnDiscreteSchedule

fan = OpenStudio::Model::FanConstantVolume.new(model,always_on)

Create an actuator to set the fan pressure rise

fan_press = "Fan Pressure Rise"

fan_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(fan, "fan", fan_press)

fan_actuator.setName("#{fan.name} Press Actuator")

Programs

Create a program all at once

fan_program_1 = OpenStudio::Model::EnergyManagementSystemProgram.new(model)

fan_program_1.setName("#{fan.name} Pressure Rise Program by Line")

fan_program_1_body = <<-EMS

SET mult = #{oat_sensor.handle} / 15.0 !- This is nonsense

SET #{fan_actuator.handle} = 250 * mult !- More nonsense

EMS

fan_program_1.setBody(fan_program_1_body)

Create a third second program from a vector of linesline by line

fan_program_2 = OpenStudio::Model::EnergyManagementSystemProgram.new(model)

fan_program_2.setName("#{fan.name} Pressure Rise Program by Line")

fan_program_2.addLine("SET mult = #{oat_sensor.handle} / 15.0 !- This is nonsense")

fan_program_2.addLine("SET #{fan_actuator.handle} = 250 * mult !- More nonsense")

Create a third program from vector of lines

fan_program_3 = OpenStudio::Model::EnergyManagementSystemProgram.new(model)

fan_program_3.setName("#{fan.name} Pressure Rise Program by Vector of Lines")

fan_program_3_lines = []

fan_program_3_lines << "SET mult = #{oat_sensor.handle} / 15.0 !- This is nonsense"

fan_program_3_lines << "SET #{fan_actuator.handle} = 250 * mult !- More nonsense"

fan_program_3.setLines(fan_program_3_lines)

here is some sample ruby code that you would use in a measure to create a sensor, an actuator and a program:

Sensor

Create an output variable for OATdb

output_var = "Site Outdoor Air Drybulb Temperature"

Temperature" output_var_oat = OpenStudio::Model::OutputVariable.new(output_var, model)

model)

Create a sensor to sense the outdoor air temperature

oat_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, output_var_oat)

output_var_oat) oat_sensor_name = "OATdb Sensor"

oat_sensor.setName(oat_sensor_name)

Sensor" oat_sensor.setName(oat_sensor_name)

Actuator

create a fan

always_on = model.alwaysOnDiscreteSchedule

model.alwaysOnDiscreteSchedule fan = OpenStudio::Model::FanConstantVolume.new(model,always_on)

OpenStudio::Model::FanConstantVolume.new(model,always_on)

Create an actuator to set the fan pressure rise

fan_press = "Fan Pressure Rise"

Rise" fan_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(fan, "fan", fan_press)

fan_press) fan_actuator.setName("#{fan.name} Press Actuator")

Actuator")

Programs

Create a program all at once

fan_program_1 = OpenStudio::Model::EnergyManagementSystemProgram.new(model)

OpenStudio::Model::EnergyManagementSystemProgram.new(model) fan_program_1.setName("#{fan.name} Pressure Rise Program by Line")

Line") fan_program_1_body = <<-EMS

<<-EMS SET mult = #{oat_sensor.handle} / 15.0 !- This is nonsense

nonsense SET #{fan_actuator.handle} = 250 * mult !- More nonsense

EMS

fan_program_1.setBody(fan_program_1_body)

nonsense EMS fan_program_1.setBody(fan_program_1_body)

Create a second program line by line

fan_program_2 = OpenStudio::Model::EnergyManagementSystemProgram.new(model)

OpenStudio::Model::EnergyManagementSystemProgram.new(model) fan_program_2.setName("#{fan.name} Pressure Rise Program by Line")

Line") fan_program_2.addLine("SET mult = #{oat_sensor.handle} / 15.0 !- This is nonsense")

nonsense") fan_program_2.addLine("SET #{fan_actuator.handle} = 250 * mult !- More nonsense")

nonsense")

Create a third program from vector of lines

fan_program_3 = OpenStudio::Model::EnergyManagementSystemProgram.new(model)

OpenStudio::Model::EnergyManagementSystemProgram.new(model) fan_program_3.setName("#{fan.name} Pressure Rise Program by Vector of Lines")

Lines") fan_program_3_lines = []

[] fan_program_3_lines << "SET mult = #{oat_sensor.handle} / 15.0 !- This is nonsense"

nonsense" fan_program_3_lines << "SET #{fan_actuator.handle} = 250 * mult !- More nonsense"

fan_program_3.setLines(fan_program_3_lines)

nonsense" fan_program_3.setLines(fan_program_3_lines)