ControlledMixingUnitSimple example of a mixing unit where a (discretized) nonlinear inverse plant model is used as feedforward controller |
This information is part of the Modelica Standard Library maintained by the Modelica Association.
Since a long time, Modelica is used to model advanced nonlinear control systems. Especially, Modelica allows a semi-automatic treatment of inverse nonlinear plant models. In the fundamental article (Looye et.al. 2005, see Literature or Download) this approach is described and several controller structures are presented to utilize an inverse plant model in the controller. This approach is attractive because it results in a systematic procedure to design a controller for the whole operating range of a plant. This is in contrast to standard controller design techniques that usually design a linear controller for a plant model that is linearized at a specific operating point. Therefore the operating range of such controllers is inherently limited.
Up to Modelica 3.2, controllers with inverse plant models can only be defined as continuous-time systems. Via the export mechanism of a Modelica tool they could be exported with solvers embedded in the code and then used as sampled data system in other environments. However, it is not possible to re-import the sampled data system to Modelica.
The synchronous features of Modelica 3.3 together with the Modelica.Clocked library offer now completely new possibilities, so that the inverse model can be designed and evaluated as sampled data system within Modelica and a Modelica simulation environment. This approach is shown at hand of a simple example using a nonlinear plant model of a mixing unit (Föllinger O. (1998): Nichtlineare Regelungen I, Oldenbourg Verlag, 8. Auflage, page 279) and utilizing this plant model as nonlinear feed-forward controller according to (Looye et.al. 2005):
A substance A is flowing continuously into a mixing reactor. Due to a catalyst, the substance reacts and splits into several base substances that are continuously removed. The reaction generates energy and therefore the reactor is cooled with a cooling medium. The cooling temperature T_c(t) in [K] is the primary actuation signal. Substance A is described by its concentration c(t) in [mol/l] and its temperature T(t) in [K]. The concentration c(t) is the signal to be primarily controlled and the temperature T(t) is the signal that is measured. These equations are collected together in input/output block Utilities.ComponentsMixingUnit.MixingUnit.
The design of the control system proceeds now in the following steps:
Inverting a model usually means that equations need to be symbolically differentiated and that higher derivatives of the inputs are needed (that are usually not available). One approach is to filter the inputs, so that a Modelica tool can determine the derivatives of the filtered input from the filter states. The minimum needed filter order is determined by first inverting the continuous-time plant model from the variable to be primarily controlled (here: "c") to the actuator input (here: "T_c"). This is performed with the help of block Modelica.Blocks.Math.InverseBlockConstraints that allows connecting an external input to an output in the pre-filter design block Utilities.ComponentsMixingUnit.FilterOrder:
Translating this model will generate the continuous-time inverse plant model. However, a Modelica tool will give an error message that it has to differentiate the model, but this requires the second derivative of the external input c_ref and this derivative is not available. The conclusion is that a low pass filter of at least second order has to be connected between c_ref and c, for example Modelica.Blocks.Continuous.Filter. Only filter types should be used that do not have "vibrations" in the time domain for a step input. Therefore, parameter analogFilter of the component should be selected as CriticalDamping (= only real poles), or Bessel (= nearly no vibrations, but steeper frequency response as CriticalDamping). The cut-off frequency f_cut is manually selected by simulations of the closed loop system. In the example, a CriticalDamping filter of third order (the third order is selected to get smoother signals) and a cut-off frequency of 1/300 Hz is used.
The controller for the mixing unit is shown in the diagram layer of block at hand, as well as in the following figure:
It consists of the filter discussed above. The input to the filter is the reference concentration which is filtered by the low pass filter. The output of the filter is used as input to the concentration c in the inverse plant model. This model computes the desired cooling temperature T_c (which is used as desired cooling temperature at the output of the controller) and the desired temperature T (which is used as desired value for the feedback controller). This part of the control system is the "feed-forward" part that computes the desired actuator signal. As feedback controller a simple P-Controller with one gain is used.
This controller could be defined as continuous-time system in previous Modelica versions. However, with Modelica 3.3 it is now also possible to define the controller as sampled data system. For this, the two inputs are sampled (sample1 and sample2) and the actuator output is hold (hold1). The controller partition is then associated with a periodic clock (via sample2) that has a sample period of 1 s and a solverMethod = "ExplicitEuler". Since the controller partition is a continuous-time system, it is discretized and solved with an explicit Euler method at every clock tick (by integrating from the previous to the actual time instant of the clock).
The controller works perfectly if the same parameters for the plant and the inverse plant model are used (follows perfectly the filtered reference concentration). Changing all parameters of the inverse plant model by 50 % (with exception of parameter e since the plant is very sensitive to it) still results in a reasonable control behavior as shown in the next two figures:
The green curve in the upper window is the (clocked) output of the filter, that is, it is the desired concentration. The red curve in the upper window is the concentration of model mixingUnit, which is the concentration in the plant. Obviously, the concentration follows reasonably well the desired one. By using a more involved feedback controller, the control error could be substantially reduced.
freq |
Value: 1 / 300 Type: Frequency (Hz) Description: Critical frequency of filter |
---|---|
c0 |
Value: 0.848 Type: Real (mol/l) Description: Nominal concentration |
T0 |
Value: 308.5 Type: Temperature (K) Description: Nominal temperature |
a1_inv |
Value: 0.2674 Type: Real Description: Process parameter of inverse plant model (see references in help) |
a21_inv |
Value: 1.815 Type: Real Description: Process parameter of inverse plant model (see references in help) |
a22_inv |
Value: 0.4682 Type: Real Description: Process parameter of inverse plant model (see references in help) |
b_inv |
Value: 1.5476 Type: Real Description: Process parameter of inverse plant model (see references in help) |
k0_inv |
Value: 1.05e14 Type: Real Description: Process parameter of inverse plant model (see references in help) |
eps |
Value: 34.2894 Type: Real Description: Process parameter (see references in help) |
x10 |
Value: 0.42 Type: Real Description: Relative offset between nominal concentration and initial concentration |
x20 |
Value: 0.01 Type: Real Description: Relative offset between nominal temperature and initial temperature |
u0 |
Value: -0.0224 Type: Real Description: Relative offset between initial cooling temperature and nominal temperature |
c_start |
Value: c0 * (1 - x10) Type: Real (mol/l) Description: Initial concentration |
T_start |
Value: T0 * (1 + x20) Type: Temperature (K) Description: Initial temperature |
c_high_start |
Value: c0 * (1 - 0.72) Type: Real (mol/l) Description: Reference concentration |
T_c_start |
Value: T0 * (1 + u0) Type: Real Description: Initial cooling temperature |
pro |
Value: 1.5 Type: Real Description: Deviations of plant to inverse plant parameters |
a1 |
Value: a1_inv * pro Type: Real Description: Process parameter of plant model (see references in help) |
a21 |
Value: a21_inv * pro Type: Real Description: Process parameter of plant model (see references in help) |
a22 |
Value: a22_inv * pro Type: Real Description: Process parameter of plant model (see references in help) |
b |
Value: b_inv * pro Type: Real Description: Process parameter of plant model (see references in help) |
k0 |
Value: k0_inv * pro Type: Real Description: Process parameter of plant model (see references in help) |
invMixingUnit |
Type: MixingUnit |
|
---|---|---|
add |
Type: Add |
|
inverseBlockConstraints |
Type: InverseBlockConstraints |
|
mixingUnit |
Type: MixingUnit |
|
feedback |
Type: Feedback |
|
gain |
Type: Gain |
|
filter |
Type: CriticalDamping |
|
hold1 |
Type: Hold |
|
sample1 |
Type: Sample |
|
periodicClock1 |
Type: PeriodicRealClock |
|
step |
Type: Step |
|
sample2 |
Type: SampleClocked |