Generally, real systems are nonlinear. To design an MPC controller of a nonlinear system, you must model the plant in Simulink®.
Although an MPC controller can regulate a nonlinear plant, the model used within the controller must be linear. In other words, the controller employs a linear approximation of the nonlinear plant. The accuracy of this approximation significantly affects controller performance.
This raises the question: how to obtain the approximation? The usual approach is to linearize the nonlinear plant at a specified operating point. The Simulink environment provides two ways to accomplish this:
This example shows how to programmatically obtain a linear model of a plant.
For this example, linearize the CSTR model, CSTR_OpenLoop. The model inputs are the coolant temperature (manipulated variable of the MPC controller), limiting reactant concentration in the feed stream, and feed temperature. The model states are the temperature and concentration of the limiting reactant in the product stream. You measure both states and use them for feedback control.
Obtain a steady-state operating point.
The operating point defines the nominal conditions at which you will linearize. It is usually a steady state condition.
Suppose you plan to operate the CSTR with the output concentration at 2 kmol/m3. The nominal feed concentration is 10 kmol/m3 and the nominal feed temperature is 300 K. Create an operating point specification object to define the steady state.
opspec = operspec('CSTR_OpenLoop'); opspec = addoutputspec(opspec,'CSTR_OpenLoop/CSTR',2); opspec.Outputs(1).Known = true; opspec.Outputs(1).y = 2; op1 = findop('CSTR_OpenLoop',opspec);
The calculated operating point is C_A = 2 kmol/m3 and T_K = 373 K. Notice that the coolant temperature at steady state is also given as 299 K, which is the nominal value of the manipulated variable of the model predictive controller.
Values of known inputs, use the Input.Known and Input.u fields of opspec
Initial guesses for state values, use the State.x field of opspec
For example, the following code specifies the coolant temperature as 305K and initial guess values of the C_A and T_K states before calculating the steady-state operating point:
opspec = operspec('CSTR_OpenLoop'); opspec.States(1).x = 1; opspec.States(2).x = 400; opspec.Inputs(1).Known = true; opspec.Inputs(1).u = 305; op2 = findop('CSTR_OpenLoop',opspec);
Specify linearization inputs/outputs.
If the linearization input /output signals are already defined in the model, as in CSTR_OpenLoop, then use the following to programmatically obtain the signal set:
io = getlinio('CSTR_OpenLoop');
Otherwise, specify the input/output signals as shown:
io(1) = linio('CSTR_OpenLoop/Feed Concentration', 1, 'input'); io(2) = linio('CSTR_OpenLoop/Feed Temperature', 1, 'input'); io(3) = linio('CSTR_OpenLoop/Coolant Temperature', 1, 'input'); io(4) = linio('CSTR_OpenLoop/CSTR', 1, 'output'); io(5) = linio('CSTR_OpenLoop/CSTR', 2, 'output');
Linearize the model at the specified operating point.
sys = linearize('CSTR_OpenLoop', op1, io)
sys a = c_a t_k c_a -5 -0.3427 t_k 47.68 2.785 b = coolant temp feed concent feed tempera c_a 0 1 0 t_k 0.3 0 1 c = c_a t_k cstr/1 0 1 cstr/2 1 0 d = coolant temp feed concent feed tempera cstr/1 0 0 0 cstr/2 0 0 0
sys is a continuous-time state-space model.
This example shows how to linearize a Simulink model using the Linear Analysis Tool. The Linear Analysis Tool, provided by Simulink Control Design, is a graphical interface for model linearization.
Open the Simulink model.
sys = 'CSTR_OpenLoop'; open_system(sys)
Open the Linear Analysis Tool for the model.
In the Simulink model window, select Analysis > Control Design > Linear Analysis.
Specify linearization input/output signals.
In the Simulink model window, right-click the output signal from the Feed Concentration block. Select Linear Analysis Points > Input Perturbation.
In the Simulink model window, right-click the output signal from the Feed Temperature block. Select Linear Analysis Points > Input Perturbation.
In the Simulink model window, right-click the output signal from the Coolant Temperature block. Select Linear Analysis Points > Input Perturbation.
In the Simulink model window, right-click the input signal to the CSTR Temperature block. Select Linear Analysis Points > Output Measurement.
In the Simulink model window, right-click the input signal to the Residual Concentration block. Select Linear Analysis Points > Output Measurement.
Specify the residual concentration as a trim constraint.
In the Simulink model window, right-click the CA output signal from the CSTR block. Select Linear Analysis Points > Trim Output Constraint.
Opens the Specifications for trim dialog box.
In the Linear Analysis Tool, click the Exact Linearization tab. In the Operating Point list, select Trim model. The Trim Model tab opens. Click Specifications.
Specify the residual concentration as a known output.
Select the Outputs tab and set the value of the CSTR_OpenLoop/CSTR (CA) to 2 kmol/m3.
Select the Known check box.
Create and verify the operating point.
In the Trim Model tab, click Trim.
The operating point op_trim1 appears in the Linear Analysis Workspace.
Double click op_trim1 to view the resulting operating point. This action opens the Edit trim point dialog box. Select the Input tab.
The coolant temperature at steady state is 299 K, as desired.
In the Exact Linearization tab, select op_trim1 from the Operating Point list.
This action creates the linear model linsys1 in the Linear Anaysis Workspace. linsys1 uses op_trim1 as its operating point.
The step response from feed concentration to output CSTR/2 displays an interesting inverse response. An examination of the linear model shows that CSTR/2 is the residual CSTR concentration, C_A. When the feed concentration increases, C_A increases initially (more reactant is entering), which increases the reaction rate. This increases the reactor temperature (output CSTR/1), which further increases the reaction rate and C_A decreases dramatically.
Export the linearization result to the MATLAB® workspace.
If necessary, you can repeat any of the above steps. Once you are satisfied with your linear model, drag and drop it from the Linear Anaysis Workspace to the MATLAB Workspace in the Linear Analysis Tool. You may now use the linearization result with other tools, such as the controller design.