packageExamplePI

Extends from Modelica.Icons.ExamplesPackage (Icon for packages containing runnable examples).

Information

PI Controller Example

This package demonstrates how to replace a traditional PI controller with Recurrent Neural Networks (RNNs) within a Modelica simulation.

Two types of neural networks are integrated as surrogates for the PI controller:

  • A standard RNN using 250 historical input values
  • A stateful RNN (sRNN) that maintains internal state across simulation steps

Both networks are provided in TensorFlow Lite and ONNX formats and are incorporated into Modelica via SMArtInt interface blocks.

To validate the neural controllers, a step test applies a constant control deviation after 10 seconds. This allows observation of the proportional and integral actions compared to the traditional PI controller.

Additionally, a more complex scenario models a two-room temperature regulation system. Here, the PI controller adjusts heating based on an external temperature profile provided through a CombiTable. A physical reference model is included to compare against the neural network controllers.


Key Variables for Analysis

Step Test Model

For the step test where a constant control deviation is applied, monitor the following variables:

  • Controller input (controller.u): The step input applied after 10 seconds.
  • Controller output (controller.y): Output signal of the PI controller and the neural network surrogates.

Two-Room Temperature Control Model

For the two-room temperature regulation scenario, important variables to observe include:

  • Controller input (controller.u): Difference between temperature setpoint and measured temperature (controller error).
  • Controller output (controller.y): Output signal of the PI controller and the neural network surrogates.
  • Room temperature [K] (temperature.T): Temperature in each room controlled by the PI or neural network controller.
  • Temperature Setpoint [K] (combiTimeTable.y[1]): Table output defining the setpoint for the room temperature. (Useful to plot alongside the actual room temperature.)

Contents

NameDescription
ReferenceModels
TFLiteTensor Flow Lite Tester
ONNXONNX Tester