# Documentation

## Paper Machine Process Control

### System Model

Ying et al. [1] studied the control of consistency (percentage pulp fibers in aqueous suspension) and liquid level in a paper machine headbox, a schematic of which is shown in Schematic of Paper Machine Headbox Elements.

Schematic of Paper Machine Headbox Elements

The process is nonlinear, and has three outputs, two manipulated inputs, and two disturbance inputs, one of which is measured for feedforward control.

The process model is a set of ordinary differential equations (ODEs) in bilinear form. The states are

$x={\left[\begin{array}{cccc}{H}_{1}& {H}_{2}& {N}_{1}& {N}_{2}\end{array}\right]}^{T}$

where H1 is the liquid level in the feed tank, H2 is the headbox liquid level, N1 is the feed tank consistency, and N2 is the headbox consistency. The measured outputs are:

$y={\left[\begin{array}{ccc}{H}_{2}& {N}_{1}& {N}_{2}\end{array}\right]}^{T}$

The primary control objectives are to hold H2 and N2 at setpoints. There are two manipulated variables

$u={\left[\begin{array}{cc}{G}_{p}& {G}_{w}\end{array}\right]}^{T}$

where Gp is the flow rate of stock entering the feed tank, and Gw is the recycled white water flow rate. The consistency of stock entering the feed tank, Np, is a measured disturbance.

v = Np

The white water consistency is an unmeasured disturbance.

d = Nw

Variables are normalized. All are zero at the nominal steady state and have comparable numerical ranges. Time units are minutes. The process is open-loop stable.

The `mpcdemos` folder contains the file `mpc_pmmodel.m`, which implements the nonlinear model equations as a Simulink® S-function. The input sequence is Gp, Gw, Np, Nw, and the output sequence is 2, N1, N2.

### Linearizing the Nonlinear Model

The paper machine headbox model is easy to linearize analytically, yielding the following state space matrices:

```A = [-1.9300 0 0 0 0.3940 -0.4260 0 0 0 0 -0.6300 0 0.8200 -0.7840 0.4130 -0.4260]; B = [1.2740 1.2740 0 0 0 0 0 0 1.3400 -0.6500 0.2030 0.4060 0 0 0 0]; C = [0 1.0000 0 0 0 0 1.0000 0 0 0 0 1.0000]; D = zeros(3,4); ```

Use these to create a continuous-time LTI state-space model, as follows:

```PaperMach = ss(A, B, C, D); PaperMach.InputName = {'G_p', 'G_w', 'N_p', 'N_w'}; PaperMach.OutputName = {'H_2', 'N_1', 'N_2'}; ```

(The last two commands are optional; they improve plot labeling.)

As a quick check of model validity, plot its step responses as follows:

```step(PaperMach); ```

The results appear in the following figure. Note the following:

• The two manipulated variables affect all three outputs.

• They have nearly identical effects on H2.

• The GwN2 pairing exhibits an inverse response.

These features make it difficult to achieve accurate, independent control of H2 and N2.

Linearized Paper Machine Model's Step Responses

### MPC Design

Type

```mpctool ```

to open the MPC design tool. Import your LTI Paper Mach model as described in Opening MPCTOOL and Importing a Model.

Next, define signal properties, being sure to designate Np and Nw as measured and unmeasured disturbances, respectively. Your specifications should resemble Signal Properties for the Paper Machine Application.

Signal Properties for the Paper Machine Application

#### Initial Controller Design

If necessary, review Specifying Controller Properties. Then click the MPC1 node and specify the following controller parameters, leaving others at their default values:

• Models and Horizons. Control interval = 2 minutes

• Constraints. For both Gp and Gw, Minimum = –10, Maximum = 10, Max down rate = –2, Max up rate = 2.

• Weight Tuning. For both Gp and Gw, Weight = 0, Rate weight = 0.4.
For N1, Weight = 0. (Other outputs have Weight = 1.)

#### Servo Response

Finally, select the Scenario1 node and define a servo-response test:

• Duration = 30

• H2 setpoint = 1 (constant)

Simulate the scenario. You should obtain results like those shown in Servo Response for Unit Step in Headbox Level Setpoint and Manipulated Variable Moves.

Servo Response for Unit Step in Headbox Level Setpoint

Manipulated Variable Moves

#### Weight Tuning

The response time is about 8 minutes. We could reduce this by decreasing the control interval, reducing the manipulated variable rate weights, and/or eliminating the up/down rate constraints. The present design uses a conservative control effort, which would usually improve robustness, so we will continue with the current settings.

Note the steady-state error in N1 (it's about –0.25 units in Servo Response for Unit Step in Headbox Level Setpoint). There are only two manipulated variables, so it's impossible to hold three outputs at setpoints. We don't have a setpoint for N1 so we have set its weight to zero (see controller settings in Initial Controller Design). Otherwise, all three outputs would have exhibited steady-state error (try it).

Consistency control is more important than level control. Try decreasing the H2 weight from 1 to 0.2. You should find that the peak error in N2 decreases by almost an order of magnitude, but the H2 response time increases from 8 to about 18 minutes (not shown). Use these modified output weights in subsequent tests.

#### Feedforward Control

To configure a test of the controller's feedforward response, define a new scenario by clicking the Scenarios node, clicking the New button, and renaming the new scenario Feedforward (by editing its name in the tree or the summary list).

In the Feedforward scenario, define a step change in the measured disturbance, Np, with Initial value = 0, Size = 1, Time = 10. All output setpoints should be zero. Set the Duration to 30 time units.

If response plots from the above servo response tests are still open, close them. Simulate the Feedforward scenario. You should find that the H2 and N2 outputs deviate very little from their setpoints (not shown).

Experiment with the "look ahead" feature. First, observe that in the simulation just completed the manipulated variables didn't begin to move until the disturbance occurred at t = 10 minutes. Return to the Feedforward scenario, select the Look ahead option for the measured disturbance, and repeat the simulation.

Notice that the manipulated variables begin changing in advance of the disturbance. This happens because the look ahead option uses known future values of the disturbance when computing its control action. For example, at time t = 0 the controller is using a prediction horizon of 10 control intervals (20 time units), so it "sees" the impending disturbance at t = 10 and begins to prepare for it. The output setpoint tracking improves slightly, but it was already so good that the improvement is insignificant. Also, it's unlikely that there would be advanced knowledge of a consistency disturbance, so clear the Look ahead check box for subsequent simulations.

#### Unmeasured Input Disturbance

To test the response to unmeasured disturbances, define another new scenario called Feedback. Configure it as for Feedforward, but set the measured disturbance, Np, to zero (constant), and the unmeasured disturbance, Nw, to 1.0 (constant). This simulates a sudden, sustained, unmeasured disturbance occurring at time zero.

Running the simulation should yield results like those in Feedback Scenario: Unmeasured Disturbance Rejection. The two controlled outputs (H2 and N2 ) exhibit relatively small deviations from their setpoints (which are zero). The settling time is longer than for the servo response (compare to Servo Response for Unit Step in Headbox Level Setpoint) which is typical.

Feedback Scenario: Unmeasured Disturbance Rejection

One factor limiting performance is the chosen control interval of 2 time units. The controller can't respond to the disturbance until it first appears in the outputs, i.e., at t = 2. If you wish, experiment with larger and smaller intervals (modify the specification on the controller's Model and Horizons tab).

#### Effect of Estimator Assumptions

Another factor influencing the response to unmeasured disturbances (and model prediction error) is the estimator configuration. The results shown in Feedback Scenario: Unmeasured Disturbance Rejection are for the default configuration.

To view the default assumptions, select the controller node (MPC1), and click its Estimation tab. The resulting view should be as shown in Default Estimator Assumptions: Output Disturbances. The status message (bottom of figure) indicates that Model Predictive Control Toolbox™ default assumptions are being used.

Default Estimator Assumptions: Output Disturbances

Now consider the upper part of the figure. The Output Disturbances tab is active, and its Signal-by-signal option is selected. According to the tabular data, the controller is assuming independent, step-like disturbances (i.e., integrated white noise) in the first two outputs.

Click the Input Disturbances tab. Verify that the controller is also assuming independent step-like disturbances in the unmeasured disturbance input.

Thus, there are a total of three independent, sustained (step-like) disturbances. This allows the controller to eliminate offset in all three measured outputs.

The disturbance magnitudes are unity by default. Making one larger than the rest would signify a more important disturbance at that location.

Click the Measurement Noise tab. Verify that white noise (unit magnitude) is being added to each output. The noise magnitude governs how much influence each measurement has on the controller's decisions. For example, if a particular measurement is relatively noisy, the controller will give it less weight, relying instead upon the model predictions of that output. This provides a noise filtering capability.

In the paper machine application, the default disturbance assumptions are reasonable. It is difficult to improve disturbance rejection significantly by modifying them.

### Controlling the Nonlinear Plant in Simulink

It's good practice to run initial tests using the linear plant model as described in Servo Response and Unmeasured Input Disturbance. Such tests don't introduce prediction error, and are a useful benchmark for more demanding tests with a nonlinear plant model. The controller's prediction model is linear, so such tests introduce prediction error.

`mpc_papermachine`

Paper Machine Headbox Control Using MPC Tools in Simulink is a Simulink model in which the Model Predictive Control Toolbox controller is being used to regulate the nonlinear paper machine headbox model. The block labeled S-Function embodies the nonlinear model, which is coded in a file called `mpc_pmmodel.m`.

As shown in the following dialog box, the MPC block references a controller design called `MPC1`, which was exported to the MATLAB® workspace from the design tool. Note also that the measured disturbance inport is enabled, allowing the measured disturbance to be connected as shown in Paper Machine Headbox Control Using MPC Tools in Simulink.

Test, Output Variables shows the scope display from the "Outputs" block for the setup of Paper Machine Headbox Control Using MPC Tools in Simulink, i.e., an unmeasured disturbance. The yellow curve is H2, the magenta is N1, and the cyan is N2. Comparing to Feedback Scenario: Unmeasured Disturbance Rejection, the results are almost identical, indicating that the effects of nonlinearity and prediction error were insignificant in this case. Simulink Test, Manipulated Variables shows the corresponding manipulated variable moves (from the "MVs" scope in Paper Machine Headbox Control Using MPC Tools in Simulink) which are smooth yet reasonably fast.

As disturbance size increases, nonlinear effects begin to appear. For a disturbance size of 4, the results are still essentially the same as shown in Test, Output Variables and Simulink Test, Manipulated Variables (scaled by a factor of 4), but for a disturbance size of 6, the setpoint deviations are relatively larger, and the curve shapes differ (not shown). There are marked qualitative and quantitative differences when the disturbance size is 8. When it is 9, deviations become very large, and the MVs saturate. If such disturbances were likely, the controller would have to be retuned to accommodate them.

Test, Output Variables