PDF

Process Control Using a PID Controller
Introduction
In the chemical process industry it is often important to control a specific process. PID control (proportional-integral-derivative control) is one way to achieve that, but it can be difficult to optimize the parameters in the PID algorithm. This example illustrates how you can implement a PID control algorithm to simulate a process control system and to find the optimal PID parameters.
This application is a generic example but could resemble the environment in a combustion chamber where the concentration at the ignition point is crucial. Two gas streams with different oxygen concentrations are mixed in the combustion chamber. The concentration is measured at the ignition point before complete mixing of the streams is reached. The control algorithm alters the inlet velocity of the gas with the lower oxygen content to achieve the desired total concentration at the ignition point. Since an increased flow of that gas will decrease the concentration, the PID coefficients will have a negative sign for this PID controller.
Model Definition
The model geometry appears in Figure 1. At the upper inlet, a gas stream with high oxygen content enters the reactor at a velocity of  10 mm/s, while a gas with a lower oxygen level enters from the left. The oxygen concentration is measured at a measurement point, and the inlet velocity of the less concentrated stream is altered by the PID control algorithm to achieve the desired concentration at that point.
Figure 1: Model geometry.
The model uses the Laminar Flow interface to describe the fluid flow and the Transport of Diluted Species interface for the mass balance. The corresponding equations read (assuming incompressible flow and absence of reactions)
To formulate the boundary conditions for the mass-transport equation, begin by assuming that you know the two inlet concentrations. In addition, assume that the reactant transport at the outlet is mainly driven by convection; that is, neglect diffusion in the main direction of the convective flow. A no-flux boundary condition describes all walls. The boundary conditions for the mass balance are:
c = cin,top
c = cin,inlet
n · (−Dc) = 0
N · n = 0
Here  c is the concentration; cin,top and cin,inlet are the inlet concentrations (SI unit: mol/m3) for the upper and controlled inlets, respectively; D is the applied diffusivity (SI unit: m2/s); and N is the molar flux (SI unit: mol/(m2·s)).
The model uses the following boundary conditions for the fluid flow:
u = (0, vin,top)
u = (uin, 0)
p0 = 0
n · u = 0
u = 0
Here u is the velocity vector (SI unit: m/s), vin,top is the inlet velocity at the top inlet, and uin is the PID-controlled velocity. At the outlet, set the pressure to 0. No Slip boundary conditions describe all walls except the inlet sections where slip conditions apply, allowing for a smooth transition to a laminar velocity profile.
The PID control algorithm used to calculate uin is the following, which is the standard PID control algorithm available in the PID Controller add-in:
(1)
with the following parameters:
cset
kP
-0.5 m4/(mol·s)
kI
-1 m4/(mol·s2)
kD
-10-3 m4/mol
As mentioned, the negative values of the coefficients reflect the fact that cset is lower than the concentration at the upper inlet, cin,top, and that the purpose of the gas stream at the controlled inlet thus is to reduce the concentration. In practice, the derivative constant, kD, is set to 0 in most cases as this parameter can be difficult to determine. Moreover, the derivative term may increase the fluctuations in the system because it amplifies noise in the measurement c. The PID Controller add-in includes the option to filter the derivative part, which reduced the influence of high-frequency noise and therefore makes the derivative part more useful.
Results and Discussion
The two plots in Figure 2 show the oxygen concentration and the velocity streamlines in the chamber after 0.05 s and 2 s, respectively. The figures show that the measured concentration depends strongly on the flow field. At startup, when the inlet velocity of the stream entering from the left is very low, the sensor is entirely exposed to the highly concentrated stream, and as the left inlet velocity increases the opposite relation occurs.
Figure 2: Oxygen concentration and velocity streamlines after 0.1 s (top) and 1.5 s (bottom).
Figure 3 shows the inlet velocity and concentration in the measurement point as a function of time for two different values for the kP parameter. The green line represents the results for a kP value of 0.5 m4/(mol·s) while the blue line corresponds to kP equal to 0.1 m4/(mol·s). The results evaluated for the smaller kP value oscillate more before stabilizing. Thus, it is clear that for this case the higher kP value yields a more stable process control.
Figure 3: PID-controlled inlet velocity (top) and concentration in the measurement point (bottom) as a function of time for kP = 0.5 m4/(mol·s) (green) and kP = 0.1 m4/(mol·s) (blue).
Application Library path: COMSOL_Multiphysics/Multiphysics/pid_control
Modeling Instructions
From the File menu, choose New.
New
In the New window, click  Model Wizard.
Model Wizard
1
In the Model Wizard window, click  2D.
2
In the Select Physics tree, select Fluid Flow>Single-Phase Flow>Laminar Flow (spf).
3
Click Add.
4
In the Select Physics tree, select Chemical Species Transport>Transport of Diluted Species (tds).
5
Click Add.
6
Click  Study.
7
In the Select Study tree, select General Studies>Time Dependent.
8
Global Definitions
Parameters 1
1
In the Model Builder window, under Global Definitions click Parameters 1.
2
In the Settings window for Parameters, locate the Parameters section.
3
-0.5 m4/(s·mol)
-1 m4/(s²·mol)
As mentioned in the Model Definition section, the PID parameters are negative because the setpoint concentration is lower than that at the upper inlet.
Geometry 1
Create the geometry. To simplify this step, insert a prepared geometry sequence.
1
In the Geometry toolbar, click Insert Sequence and choose Insert Sequence.
2
3
In the Geometry toolbar, click  Build All.
4
Click the  Zoom Extents button in the Graphics toolbar.
Definitions
Next, add a probe to sample the concentration and its time derivative at the point x = 0, y =  0.002.
Domain Point Probe 1
1
In the Definitions toolbar, click  Probes and choose Domain Point Probe.
2
In the Settings window for Domain Point Probe, locate the Point Selection section.
3
In row Coordinates, set y to -0.002.
Point Probe Expression 1 (ppb1)
1
In the Model Builder window, expand the Domain Point Probe 1 node, then click Point Probe Expression 1 (ppb1).
2
In the Settings window for Point Probe Expression, type c_mp in the Variable name text field.
3
Click Replace Expression in the upper-right corner of the Expression section. From the menu, choose Component 1 (comp1)>Transport of Diluted Species>Species c>c - Concentration - mol/m³.
Point Probe Expression 2 (ppb2)
1
In the Model Builder window, right-click Domain Point Probe 1 and choose Point Probe Expression.
2
In the Settings window for Point Probe Expression, type ct_mp in the Variable name text field.
3
Locate the Expression section. In the Expression text field, type ct.
Proceed to import the PID Controller add-in and set up the control algorithm.
4
In the Home toolbar, click  Windows and choose Add-in Libraries.
Add-in Libraries
1
In the Add-in Libraries window, in the tree, select the check box for the node COMSOL Multiphysics>pid_controller (if it is not already selected).
2
Developer
In the Developer toolbar, click  Add-ins and choose PID Controller>PID Controller.
Global Definitions
PID Controller 1
1
In the Model Builder window, under Global Definitions click PID Controller 1.
2
In the Settings window for PID Controller, locate the Controller Parameters section.
3
Keep the default values for the remaining parameters.
4
Click Create.
Materials
For the physics setup, you need to specify the density, ρ, and the dynamic viscosity, μ, of the fluid. For this purpose, define a material.
Fluid
1
In the Model Builder window, under Component 1 (comp1) right-click Materials and choose Blank Material.
2
In the Settings window for Material, type Fluid in the Label text field.
3
4
Locate the Material Contents section. In the table, enter the following settings:
You are now ready to set up the physics of the model.
Laminar Flow (spf)
Inlet 1
1
In the Model Builder window, under Component 1 (comp1) right-click Laminar Flow (spf) and choose Inlet.
2
3
In the Settings window for Inlet, locate the Velocity section.
4
In the U0 text field, type comp2.u_in_ctrl. This is the inlet velocity defined by the PID controller.
Inlet 2
1
In the Physics toolbar, click  Boundaries and choose Inlet.
2
3
In the Settings window for Inlet, locate the Velocity section.
4
In the U0 text field, type v_in_top.
Outlet 1
1
In the Physics toolbar, click  Boundaries and choose Outlet.
2
Wall 2
1
In the Physics toolbar, click  Boundaries and choose Wall.
2
3
In the Settings window for Wall, locate the Boundary Condition section.
4
From the Wall condition list, choose Slip.
Transport of Diluted Species (tds)
Transport Properties 1
1
In the Model Builder window, under Component 1 (comp1)>Transport of Diluted Species (tds) click Transport Properties 1.
2
In the Settings window for Transport Properties, locate the Convection section.
3
From the u list, choose Velocity field (spf).
4
Locate the Diffusion section. In the Dc text field, type D.
Initial Values 1
1
In the Model Builder window, click Initial Values 1.
2
In the Settings window for Initial Values, locate the Initial Values section.
3
In the c text field, type c00.
Inflow 1
1
In the Physics toolbar, click  Boundaries and choose Inflow.
2
3
In the Settings window for Inflow, locate the Concentration section.
4
In the c0,c text field, type c_in_inlet.
Inflow 2
1
In the Physics toolbar, click  Boundaries and choose Inflow.
2
3
In the Settings window for Inflow, locate the Concentration section.
4
In the c0,c text field, type c_in_top.
Outflow 1
1
In the Physics toolbar, click  Boundaries and choose Outflow.
2
Mesh 1
1
In the Model Builder window, under Component 1 (comp1) click Mesh 1.
2
In the Settings window for Mesh, locate the Physics-Controlled Mesh section.
3
From the Element size list, choose Finer.
4
Click  Build All.
Study 1
Use a parametric sweep to solve for two different values of the proportional parameter, k_P.
Parametric Sweep
1
In the Study toolbar, click  Parametric Sweep.
2
In the Settings window for Parametric Sweep, locate the Study Settings section.
3
4
Step 1: Time Dependent
1
In the Model Builder window, click Step 1: Time Dependent.
2
In the Settings window for Time Dependent, locate the Study Settings section.
3
In the Output times text field, type range(0,0.05,1) range(1.1,0.1,6).
Solution 1 (sol1)
1
In the Study toolbar, click  Show Default Solver.
2
In the Model Builder window, expand the Solution 1 (sol1) node, then click Time-Dependent Solver 1.
3
In the Settings window for Time-Dependent Solver, click to expand the Time Stepping section.
4
From the Method list, choose Generalized alpha.
5
From the Steps taken by solver list, choose Intermediate.
This forces the solver to take at least one step in each of the time intervals you specified.
6
Click to expand the Advanced section. In the Study toolbar, click  Compute.
Results
Concentration (tds)
The default Concentration plot group contains a surface plot that shows the concentration at the end of the simulated time span, as well as a streamline plot of the velocity. Study the solution at t = 0.05 s and t = 2 s.
First, however, adjust the streamline positioning so that the streamline density reflects the velocity magnitude.
Streamline 1
1
In the Model Builder window, expand the Concentration (tds) node, then click Streamline 1.
2
In the Settings window for Streamline, click Replace Expression in the upper-right corner of the Expression section. From the menu, choose Component 1 (comp1)>Laminar Flow>Velocity and pressure>u,v - Velocity field.
3
Locate the Streamline Positioning section. From the Positioning list, choose Magnitude controlled.
4
In the Density text field, type 10.
5
In the Concentration (tds) toolbar, click  Plot.
Concentration (tds)
1
In the Model Builder window, click Concentration (tds).
2
In the Settings window for 2D Plot Group, locate the Data section.
3
From the Time (s) list, choose 0.05.
4
In the Concentration (tds) toolbar, click  Plot.
5
Click the  Zoom Extents button in the Graphics toolbar.
6
From the Time (s) list, choose 3.
7
In the Concentration (tds) toolbar, click  Plot.
Compare the resulting plots with those in Figure 2.
Inlet Velocity
Plot the PID-controlled inlet velocity (Figure 3).
1
In the Model Builder window, under Results click 1D Plot Group 4.
2
In the Settings window for 1D Plot Group, type Inlet Velocity in the Label text field.
3
Click to expand the Title section. From the Title type list, choose Manual.
4
In the Title text area, type Inlet velocity.
5
Locate the Plot Settings section. Select the y-axis label check box.
6
In the associated text field, type u<sub>in,ctrl</sub> (mm/s).
Global 1
1
In the Model Builder window, expand the Inlet Velocity node, then click Global 1.
2
In the Settings window for Global, click Replace Expression in the upper-right corner of the y-Axis Data section. From the menu, choose Component 2 (comp2)>Definitions>Variables>comp2.u_in_ctrl - Control variable - m/s.
3
Click to expand the Legends section. Find the Include subsection. Clear the Description check box.
4
In the Inlet Velocity toolbar, click  Plot.
Proceed to plot the concentration at the measurement point as a function of time (Figure 3).
Concentration, Measurement Point
1
In the Model Builder window, right-click Inlet Velocity and choose Duplicate.
2
In the Settings window for 1D Plot Group, type Concentration, Measurement Point in the Label text field.
3
Locate the Title section. In the Title text area, type Concentration, measurement point.
4
Locate the Plot Settings section. In the y-axis label text field, type c<sub>mp</sub> (mol/m<sup>3</sup>).
Global 1
1
In the Model Builder window, expand the Concentration, Measurement Point node, then click Global 1.
2
In the Settings window for Global, click Replace Expression in the upper-right corner of the y-Axis Data section. From the menu, choose Component 1 (comp1)>Definitions>c_mp - Domain Point Probe 1, c - mol/m³.
3
In the Concentration, Measurement Point toolbar, click  Plot.
The resulting plot should look like that in the lower panel of Figure 3.