Skip to content

Getting Started with Model Measures Part 2: Creating Actuators

Maggie Sullivan edited this page Jun 29, 2023 · 2 revisions

This tutorial will lead you through the process of creating an actuator which you can control through Alfalfa.

Note: This tutorial assumes you have already completed Getting Started with Model Measures Part 1: Creating Inputs and Outputs

1. Creating an Actuator

As in the previous tutorial code will be inserted into the run(...) method. The below code will create an actuator which controls the outdoor air temperature of the model.

# The actuator must be attached to the model's outdoor air node, so here we get that object
outdoor_air_node = model.outdoorAirNode

# Create the actuator 
outdoor_air_temp_actuator = create_actuator(create_ems_str('Outdoor Air Temperature'), # EMS name of the input to create
                                            outdoor_air_node, # Component to actuate
                                            'Outdoor Air System Node', # Component type
                                            'Drybulb Temperature', # Control Type
                                            true) # Set up actuator for external control

# Set the display name of the actuator
outdoor_air_temp_actuator.display_name = 'Outdoor Air Temperature'

# Register the actuator
register_input(outdoor_air_temp_actuator)

At this point you have an actuator which controls the outdoor air temperature of your model. However, you may notice that when you read the value of this point after you start the site it is 0. This is because by default the value reported is from the input variable, not from the component you are actuating. The next step will go over how to fix this.

2. Override the Reported Value of the Actuator

In this step we will create an OutputVariable which listens to the temperature of the outdoor air node and tell Alfalfa that this is the value we want reported for the point we created in the previous step.

# Create the output variable for the outdoor air node's temperature
outdoor_air_temp = create_output_variable(outdoor_air_node.name.get, 'System Node Temperature')

# Set this variable as the echo for our point
outdoor_air_temp_actuator.echo = outdoor_air_temp

Now if we upload and start our site again we can see that the value of our point reflects the outdoor air temperature.


Model Configuration

Openstudio

Tutorials

Guides

Reference

Modelica

Guides

Alfalfa Interaction

Tutorials

Guides

Reference

Explanation

Alfalfa Development

Guides

General

Reference

Explanation

Clone this wiki locally