Skip to content

OpenStudio Measures for Alfalfa

Lauren Klun edited this page Apr 19, 2023 · 1 revision

Introduction:

The measures are designed to force equipment such as air conditioners, heat pumps, water heaters and other electric equipment to operate at reduced levels of electricity consumptions when an Alfalfa demand-response signal is received.

The demand-response signal is sent to the simulation from external programs which can be VTN/VEN devices. Two EnergyPlus EMS global variables are defined to allow the signal exchange: an Enable variable and an Enable Value variable. The Enable variable informs the EnergyPlus whether an overwrite happens or not. If an overwrite happens, the Enable Value variable will carry the value for EnergyPlus to use. If an overwrite does not happen, “null” will be used to inform EnergyPlus to simulate with existing settings.

The latest measures are here: https://github.com/NREL/CCTwin-scripts/tree/esif-demo-01/bldg_models/esif-demo-01/measures

Measures: The measures contain three main methods: collect relevant objects; create EMS actuators and sensors; create EMS program calling manager. In the collect relevant objects method, do loop is used to loop through EnergyPlus space/space_type and get method is used to get schedules of all relevant equipment such as air conditioners and water heaters.

space_types.each do |space_type|

In the shed_lights measure, model.getLights returns all instances related to lights in each space. Schedule.get further returns all schedules associated with each light object.

model.getLightss.each do |light|
      light_sch = light.schedule.get
      new_schedule = light_sch.clone(model)
      new_schedule = new_schedule.to_Schedule.get
      new_schedule.setName(light_sch.nameString() + '_clone')
      light_schs << light_sch
end

In the thermostat_adj measure, model.getThermostatSetpointDualSetpoints obtained all dual setpoint thermostat instances. Depending on heating and cooling equipment, coolingSetpointTemperatureSchedule.get returns cooling setpoint schedules of each thermostat; heatingSetpointTemperatureSchedule.get returns heating setpoint schedules of each thermostat.

model.getThermostatSetpointDualSetpoints.each do |thermostat|
        clgPoint_sch = thermostat.coolingSetpointTemperatureSchedule.get 
        htgPoint_sch = thermostat.heatingSetpointTemperatureSchedule.get

In the waterheater measure, model.getWaterHeaterMixeds returns all instances of mixed type water heaters; model.getWaterHeaterStratifieds returns all instances of stratified type water heaters; model.getWaterHeaterHeatPumps returns all instances of heat pump water heater and model.getWaterHeaterHeatPumpWrappedCondensers get all instances of heat pump water heaters that have wrapped condensers. setpointTemperatureSchedule returns water heater’s setpoint schedule for mixed type water heater. compressorSetpointTemperatureSchedule returns compressor setpoint schedule of heat pump water heaters and heat pump water heater using wrapped condensers. Heater1SetpointTemperatureSchedule and heater2SetpointTemperatureschedule return upper and lower heater setpoint of stratified water heaters.

water_heaters = model.getWaterHeaterMixeds + model.getWaterHeaterStratifieds + model.getWaterHeaterHeatPumps + model.getWaterHeaterHeatPumpWrappedCondensers 
temp_limit_sched = water_heater.setpointTemperatureSchedule.get.to_ScheduleRuleset.get
temp_limit_sched = water_heater.compressorSetpointTemperatureSchedule.to_ScheduleRuleset.get
temp_limit_sched = water_heater.heater1SetpointTemperatureSchedule.to_ScheduleRuleset.get
temp_limit_sched = water_heater.heater2SetpointTemperatureSchedule

In the equipment_adj measure, model.getSpaceTypes/model.getSpaces returns all space types and space. Do loop is then used to loop through all electricEquipment associated with space/space type. schedule returns all schedules of the electric equipment.

plug_objects =  space_type.electricEquipment

In the create EMS actuators and sensors method, do loop is used to create a pair of sensor and actuator for each schedule. To prevent an aggregate change of schedule setpoint, sensor needs to be created on a duplicated (clone method) schedule while the actuator has to act on the actual schedule to impact power consumptions of equipment. In all measures, EnergyManagementSystemActuator.new is used to create an actuator of each schedule and EnergyManagmentSystemSensor.new is used to create a sensor of each duplicated schedule. setName is used to identify sensor/actuator with schedule name and setKeyNameis needed in creating EMS sensors. The success of creating the pair of sensor and actuator will be reflected in the EnergyPlus idf files where such pair will be declared in blocks.

act_zone_plug = OpenStudio::Model::EnergyManagementSystemActuator.new(zone_plug_sched,
          'Schedule:Year', #from schedule:Ruleset
          'Schedule Value')
sens_zone_plug = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Schedule Value')
         sens_zone_plug.setName("z_#{space_type_name}_PLUG_SEN")
         sens_zone_plug.setKeyName(dummy_zone_plug_sched.name.get)

In the create EMS program calling manager method, EnergyManagementSystemProgram.new creates an instance of EMS program which is a block of codes in the EnergyPlus idf files. setName sets the EMS program name, addLine appends new lines in the block. Do loop is used to set each EMS actuator to a new schedule. SET EMS_actuator = new schedule. SET EMS_actuator = NULL will force the simulation to follow original schedule. EnergyManagementSystemProgramCallingManager is required at the end.

# EMS program
     equip_sch_prgm = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
     equip_sch_prgm.setName('Setback_equipment')
     equip_sch_prgm.addLine('SET load_shed = ShedSignal')
# create EMS program calling manager and add EMS program
     equip_sch_prgm_mngr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)
     equip_sch_prgm_mngr.setName("equip_adj_Mngr")
     equip_sch_prgm_mngr.setCallingPoint("BeginZoneTimestepBeforeInitHeatBalance")
     equip_sch_prgm_mngr.addProgram(equip_sch_prgm)
  # register the measure to be used by the application
  Equipmentsetback.new.registerWithApplication

Sample Results: Figure 1-4 compare the EnergyPlus simulation results with and without applying the demand reduction measures.

image

Figure 1: AC thermostat setback. Left, without the measure, room temperature peaks at 24.4C, right, with the measure, room temperature peaks at 25.4C

image

Figure 2: Water heater setpoint setback. Left, without the measure, water temperature peaks at 82.5C, right, with the measure, room temperature peaks at 80.5C

image

Figure 3: Lighting setback. Left, without the measure, lighting equipment energy consumption peaks at 13,400W, right, with the measure, room temperature peaks at 11,800W

image

Figure 4: Electric equipment setback. Left, without the measure, electric equipment energy consumption peaks at 39,000W, right, with the measure, room temperature peaks at 27,000W


Model Configuration

Openstudio

Tutorials

Guides

Reference

Modelica

Guides

Alfalfa Interaction

Tutorials

Guides

Reference

Explanation

Alfalfa Development

Guides

General

Reference

Explanation

Clone this wiki locally