design controller using mpc designer
this example shows how to design a model predictive controller for a continuous stirred-tank reactor (cstr) using mpc designer.
cstr model
the linearized model of a continuously stirred tank reactor (cstr) is shown in . in the model, the first two state variables are the concentration of reagent (here referred to as ca and measured in kmol/m3) and the temperature of the reactor (here referred to as t, measured in k), while the first two inputs are the coolant temperature (tc, measured in k, used to control the plant), and the inflow feed reagent concentration caf measured in kmol/m3, (often considered as unmeasured disturbance).
for this example, the coolant temperature has a limited range of ±10 degrees from its nominal value and a limited rate of change of ±2 degrees per second.
create a state-space model of a cstr system.
a = [ -5 -0.3427; 47.68 2.785]; b = [ 0 1 0.3 0]; c = flipud(eye(2)); d = zeros(2); cstr = ss(a,b,c,d);
import plant and define mpc structure
mpcdesigner
on the mpc designer tab, in the structure section, click mpc structure.
in the define mpc structure by importing dialog box, in the select a plant
model or an mpc controller from matlab workspace table, select the
cstr
model.
since cstr
is a stable, continuous-time lti system, mpc
designer sets the controller sample time to 0.1 tr, where tr is the average rise
time of cstr
. for this example, in the specify mpc controller
sample time field, enter a sample time of 0.5
seconds.
by default, all plant inputs are defined as manipulated variables and all plant outputs as measured outputs. in the assign plant i/o channels section, assign the input and output channel indices such that:
the first input, coolant temperature, is a manipulated variable.
the second input, feed concentration, is an unmeasured disturbance.
the first output, reactor temperature, is a measured output.
the second output, reactant concentration, is an unmeasured output.
click import.
the app imports the cstr
plant to the data
browser. the following are also added to the data
browser:
mpc1
— default mpc controller created usingcstr
as its internal model.scenario1
— default simulation scenario.
the app runs the default simulation scenario and updates the input response and output response plots. the closed loop system is able to track the desired measured output successfully, while this is not the case for the unmeasured output. this behavior is expected as the plant has only one manipulated variable.
once you define the mpc structure, you cannot change it within the current mpc designer session. to use a different channel configuration, start a new session of the app.
define input and output channel attributes
on the mpc designer tab, select i/o attributes.
in the input and output channel specifications dialog box, in the name column, specify a meaningful name for each input and output channel.
in the unit column, optionally specify the units for each channel.
since the state-space model is defined using deviations from the nominal operating
point, keep the nominal value for each input and output channel to
0
.
keep the scale factor for each channel at the default value of
1
.
click ok.
the input response and output response plot labels update to reflect the new signal names and units.
configure simulation scenario
on the mpc designer tab, in the scenario section, click edit scenario > scenario1.
in the simulation scenario dialog box, set the simulation duration to 20 seconds.
in the reference signals table, in the first row, specify a step
size of 2
and a time of
5
.
in the signal column, in the second row, select a
constant
reference to hold the concentration setpoint at its
nominal value, defined in the input and output channel specifications dialog box (in this
case the nominal value is zero).
the default scenario is configured to simulate a step change of 2
degrees kelvin in the reference reactor temperature, t, at a time of
5
seconds.
click ok.
the response plots update to reflect the new simulation scenario configuration. the reference value for ca is no longer a step but a constant equal to zero.
in the scenarios section in the lower left part of mpc
designer, click scenario1
. click
scenario1
a second time, and rename the scenario to
stept
.
configure controller horizons
on the tuning tab, in the horizons section,
specify a prediction horizon of 15
and a
control horizon of 3
.
the response plots update to reflect the new horizons. the input response plot shows that the control actions violate the required constraint on the rate of change for the coolant temperature.
define input constraints
in the design section, click constraints.
in the constraints dialog box, in the input and output constraints section, in the inputs row, enter the coolant temperature upper and lower bounds in the min and max columns respectively.
specify the rate of change limits in the ratemin and ratemax columns.
click ok.
the input response plot shows the constrained manipulated variable control actions.
specify controller tuning weights
on the tuning tab, in the design section, click weights.
in the input weights table, increase the manipulated variable
(mv) rate weight to 0.3
. increasing the mv rate
weight penalizes large mv changes in the controller optimization cost function.
in the output weights table, keep the default weight values. by default, all unmeasured outputs have zero weights.
since there is only one manipulated variable, if the controller tries to hold both outputs at specific setpoints, one or both outputs will exhibit steady-state error in their responses. since the controller ignores setpoints for outputs with zero weight, setting the concentration output weight to zero allows reactor temperature setpoint tracking with zero steady-state error.
click ok.
the input response plot shows the more conservative control actions, which result in a slower output response.
eliminate output overshoot
suppose the application demands zero overshoot in the output response. on the performance tuning tab, drag the closed-loop performance slider to the left until the output response has no overshoot. moving this slider to the left simultaneously increases the manipulated variable rate weight of the controller and decreases the output variable weight, producing a more robust controller.
when you adjust the controller tuning weights using the closed-loop performance slider, mpc designer does not change the weights you specified in the weights dialog box. instead, the slider controls an adjustment factor, which is used with the user-specified weights to define the actual controller weights.
this factor is 1
when the slider is centered; its value decreases
as the slider moves left and increases as the slider moves right. the weighting factor
multiplies the manipulated variable and output variable weights and divides the
manipulated variable rate weights from the weights dialog box. therefore, moving the
slider to increase robustness decreases both ov and mv weights and increases mv rate
weights, which leads to relaxed control of outputs and more conservative control
moves.
to view the actual controller weights, export the controller to the matlab® workspace, and view the weights
property of the exported
controller object.
test controller disturbance rejection
in a process control application, disturbance rejection is often more important than setpoint tracking. simulate the controller response to a step change in the feed concentration unmeasured disturbance.
on the mpc designer tab, in the scenario section, click plot scenario > new scenario.
in the simulation scenario dialog box, set the simulation duration to 20 seconds.
in the reference signals table, in the first row, in the
signal drop-down list, select step
, then
specify a step size of 2
, and a
time of 5
. in the signal
column, in the second row, keep a constant
reference to hold
the concentration setpoint at its nominal value.
in the unmeasured disturbances row, in the
signal drop-down list, select step
. then
specify a step size of 0.2
and a
time of 5
.
click ok.
the app adds new scenario to the data browser and creates new corresponding input response and output response plots.
in the data browser, in the scenarios
section, rename newscenario
to distreject
.
as you can see from the output response plots, the closed-loop system is still able to reach the desired reactor temperature. in this case, the required control actions, combined with the input disturbance, cause a steady-state decrease in the output concentration, ca of 0.1 kmol/m3.
specify concentration output constraint
previously, you defined the controller tuning weights to achieve the primary control objective of tracking the reactor temperature setpoint with zero steady-state error. doing so enables the unmeasured reactor concentration to vary freely. suppose that unwanted reactions occur once the reactor concentration drops below 0.05 kmol/m3 with respect to its nominal value. to constrain the reactor concentration, specify an output constraint.
on the tuning tab, in the design section, click constraints.
in the constraints dialog box, in the input and output
constraints sections, in second row of the outputs
table, specify a min unmeasured output (uo) value of
-0.05
.
by default, all output constraints are soft, meaning that their minecr and maxecr values are greater than zero. to soften the unmeasured output (uo) constraint further, increase its maxecr value.
click ok.
in the output response plots, the reactor concentration, ca, stabilizes at -0.05 kmol/m3 after 10 seconds. since there is only one manipulated variable, the controller makes a compromise between the two competing control objectives: temperature tracking and constraint satisfaction. a softer output constraint enables the controller to sacrifice the constraint requirement more to improve the temperature tracking.
since the output constraint is soft, the controller maintains some level of temperature control by allowing small concentration constraint violations. in general, depending on your application requirements, you can experiment with different constraint settings to achieve an acceptable control objective compromise.
export controller
in the tuning tab, in the analysis section,
click export controller
to save the tuned controller, mpc1
, to
the matlab workspace.
delete plants, controllers, and scenarios
to delete a plant, controller, or scenario, in the data browser, right-click the item you want to delete, and select delete.
you cannot delete the current controller. also, you cannot delete a plant or scenario if it is the only listed plant or scenario.
if a plant is used by any controller or scenario, you cannot delete the plant.
to delete multiple plants, controllers, or scenarios, hold shift and click each item that you want to delete.
references
[1] seborg, d. e., t. f. edgar, and d. a. mellichamp, process dynamics and control, 2nd edition, wiley, 2004, pp. 34–36 and 94–95.