Vous êtes sur la page 1sur 12
®
®

Process Control Using a PID Controller

SOLVED WITH COMSOL MULTIPHYSICS 3.5a

© COPYRIGHT 2008. All right reserved. No part of this documentation may be photocopied or reproduced in any form without prior written consent from COMSOL AB. COMSOL, COMSOL Multiphysics, COMSOL Reac- tion Engineering Lab, and FEMLAB are registered trademarks of COMSOL AB. Other product or brand names are trademarks or registered trademarks of their respective holders.

trademarks of COMSOL AB. Other product or brand names are trademarks or registered trademarks of their

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 model 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.

Model Definition

The model geometry appears in the following figure. 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.

PROCESS

CONTROL

USING

A

PID

CONTROLLER

|

1

Upper inlet Measurement point Controlled inlet Outlet
Upper inlet
Measurement point
Controlled inlet
Outlet

The model uses the Navier-Stokes equations to describe the fluid flow and the Convection and Diffusion application mode for the mass balance.

u

ρ t

[

η∇u (

+

(∇u)

∇ ⋅ u

T

)] + ρu ⋅ ∇u + p

=

0

δ ts

c ----- t + ∇ ⋅ (Dc)

=

R u ⋅ ∇c

=

F

(1)

(2)

It is possible to formulate the boundary conditions for the mass-transport equation 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. An insulation/symmetry boundary condition describes all walls. The boundary conditions for the mass balance are:

BOUNDARY

CONSTRAINT

Upper inlet

c

= c in,top

Controlled inlet

c

= c in,inlet

PROCESS

CONTROL

USING

A

PID

CONTROLLER

|

2

BOUNDARY

CONSTRAINT

 

Outlet

n

⋅ (Dc)

=

0

Walls

N

·n = 0

Here c is the concentration; c

for the upper and controlled inlets, respectively; D is the applied diffusivity (m 2 /s); and N is the molar flux (mol/(m 2 ·s)).

and c in,inlet are the inlet concentrations (mol/m 3 )

in,top

The model uses the following boundary conditions for the fluid flow:

BOUNDARY

CONSTRAINT

Upper inlet

u

=(0, v in,top )

Controlled inlet

u

= (u in , 0)

Outlet

p 0 = 0

Inlet sections

n·u = 0

Walls

u

= 0

Here u is the velocity vector (m/s), v in,top is the inlet velocity at the top inlet, and u in is the PID controlled velocity. At the outlet, set the pressure to p 0 (Pa). 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 u in is

u in

=

k

P

(

c

c

set

)

+

k

I

with the following parameters:

t

0

(

c

c

set

) dt

+

k

D

-----

t

(

c

PARAMETER

VALUE

c

set

0.5

mol/m 3

k

P

0.5

m 4 /(mol·s)

k

I

1

m 4 /(mol·s 2 )

k

D

10

-3 m 4 /mol

c

set

)

(3)

In practice, the derivative constant, k D , is set to 0 in most cases as this parameter can be difficult to determine and the term may increase the fluctuations in the system.

PROCESS

CONTROL

USING

A

PID

CONTROLLER

|

3

Results

The two plots in Figure 1 show the oxygen concentration and the velocity stream lines in the chamber after approximately 0.01 s and 1.5 s, respectively. The figures show that the measured concentration depends strongly on the flow field. At start-up, 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.

left inlet velocity increases the opposite relation occurs. Figure 1: Oxygen concentration and velocity streamlines
left inlet velocity increases the opposite relation occurs. Figure 1: Oxygen concentration and velocity streamlines

Figure 1: Oxygen concentration and velocity streamlines after approximately 0.01 s (top) and 1.5 s (bottom).

Figure 2 shows the inlet velocity and concentration in the measurement point as a function of time for two different values for the k P parameter. The solid line represents the results for a k P value of 0.5 m 4 /(mol·s) while the dashed line corresponds to k P

PROCESS

CONTROL

USING

A

PID

CONTROLLER

|

4

equal to 0.1 m 4 /(mol·s). The results evaluated for the smaller k P value oscillate more before stabilizing. Thus, it is clear that for this case the higher k P value yields a more stable process control.

higher k P value yields a more stable process control. Figure 2: PID-controlled inlet velocity (top)
higher k P value yields a more stable process control. Figure 2: PID-controlled inlet velocity (top)

Figure 2: PID-controlled inlet velocity (top) and concentration in the measurement point (bottom) as a function of time for k P = 0.5 m 4 /(mol·s) (solid) and k P = 0.1 m 4 /(mol·s) (dashed).

Model Library path: COMSOL_Multiphysics/Multidisciplinary/PID_control

PROCESS

CONTROL

USING

A

PID

CONTROLLER

|

5

Modeling Using the Graphical User Interface

MODEL NAVIGATOR

1 Go to the Model Navigator and select 2D from the Space dimension list.

2 In the list of application modes select COMSOL Multiphysics>Fluid

Dynamics>Incompressible Navier-Stokes>Transient analysis.

3 Click the Multiphysics button in the lower right corner, then click Add.

4 Similarly, add the COMSOL Multiphysics>Convection and Diffusion>Convection and Diffusion>Transient analysis application mode.

5 Click OK.

OPTIONS AND SETTINGS

Constants

1 Go to the Options menu and choose Constants.

2 Make the following entries in the Constants dialog box; when finished, click OK.

NAME

EXPRESSION

DESCRIPTION

v_in_top

0.01[m/s]

Velocity, upper inlet

cin_top

1[mol/m^3]

Concentration, upper inlet

cin_inlet

0.2[mol/m^3]

Concentration, controlled inlet

c00

0.5[mol/m^3]

Initial concentration, chamber interior

eta

3e-5[Pa*s]

Dynamic viscosity

rho

1.2[kg/m^3]

Density

D

1e-4[m^2/s]

Diffusivity

c_set

0.5[mol/m^3]

Setpoint concentration

k_P_ctrl

0.5[m^4/(mol*s)]

Proportional parameter

k_I_ctrl

1[m^4/(mol*s^2)]

Integral parameter

k_D_ctrl

1e-3[m^4/mol]

Derivative parameter

Grid Settings

1 Go to the Options menu and select Axes/Grid Settings.

PROCESS

CONTROL

USING

A

PID

CONTROLLER

|

6

2

On the Axis page enter x-y limits (expressed in the default length unit meters) for the axes as displayed below.

AXIS

VALUE

x

min

-0.015

x

max

0.015

y

min

-0.01

y

max

0.02

3 Click the Grid tab.

4 Clear the Auto check box and enter the following extra grid values:

GRID

VALUE

Extra x

-0.014 -0.012 -0.01 -0.004 -0.002 0 0.002 0.008 0.01 0.012

Extra y

-0.004 -0.002 0 0.002 0.004 0.008

5 Click OK.

GEOMETRY MODELING

1 When creating the geometry you alternate between using the Line and 2nd Degree Bézier Curve tools located on the Draw toolbar to the left. For curved shapes use the curve tool, and for straight lines use the line tool. Click on the points given in the following table using the corresponding drawing tool. Use the coordinates displayed in the lower-left corner of the screen to find the points.

DRAW TOOL

POINTS (X, Y)

Line

(0.012,-0.002) (0.012,-0.004) (-0.01,-0.004)

Curve

(-0.01,-0.002) (-0.012,-0.002)

Line

(-0.014,-0.002) (-0.014,0) (-0.012,0)

Curve

(-0.01,0) (-0.01,0.002)

Line

(-0.004,0.002)

Curve

(-0.002,0.002) (-0.002,0.004)

Line

(-0.002,0.008) (0,0.008) (0,0.004)

Curve

(0,0.002) (0.002,0.002)

Line

(0.008,0.002) (0.008,0)

Curve

(0.008,-0.002) (0.01,-0.002)

Line

Right-click to close the geometry

PROCESS

CONTROL

USING

A

PID

CONTROLLER

|

7

2

To add the measurement point, click the Point button in the Draw toolbar to the left and click on the coordinates (0, 2·10 3 ).

3 Click the Zoom Extents button on the Main toolbar to center the geometry.

PHYSICS SETTINGS

Subdomain Settings—Incompressible Navier-Stokes

1 Go to the Multiphysics menu and select Incompressible Navier-Stokes (ns).

2 From the Physics menu, choose Subdomain Settings.

3 In the Subdomain Settings dialog box select Subdomain 1 and type rho in the Density edit field.

4 In the Dynamic viscosity edit field type eta. Click OK.

Boundary Conditions—Incompressible Navier-Stokes

1 From the Physics menu, choose Boundary Settings.

2 In the Boundary Settings dialog box enter the following boundary conditions:

SETTINGS

BOUNDARY 1

BOUNDARY 7

BOUNDARIES 2, 3, 6, 8

BOUNDARIES 4, 5, 9–11, 13–17

BOUNDARY 12

Boundary

Inlet

Inlet

Symmetry

Wall

Outlet

type

boundary

Boundary

Velocity

Velocity

-

No slip

Pressure, no

condition

viscous stress

u

0

u_in_ctrl*

0

     
 

(u_in_ctrl>=0)

v

0

0

-v_in_top

     

p

0

       

0

You will define u_in_ctrl as a scalar expression shortly.

3 Click OK.

Subdomain Settings—Convection and Diffusion

1 From the Multiphysics menu, choose Convection and Diffusion (cd).

2 From the Physics menu, choose Subdomain Settings select Subdomain 1.

3 In the D (isotropic) edit field type D to define an isotropic diffusion coefficient.

4 In the x-velocity edit field type u.

5 In the y-velocity edit field type v.

6 Click the Init tab.

PROCESS

CONTROL

USING

A

PID

CONTROLLER

|

8

7

In the c(t 0 ) edit field enter the initial concentration c00, then click OK.

Boundary Conditions—Convection and Diffusion

1 From the Physics menu, choose Boundary Settings.

2 In the Boundary Settings dialog box enter the following boundary conditions:

SETTINGS

BOUNDARY 1

BOUNDARIES 2–6,

BOUNDARY 7

BOUNDARY 12

8–11, 13–17

Type

Concentration

Insulation/

Concentration

Convective flux

Symmetry

c

0

cin_inlet

 

cin_top

 

3

Click OK.

PID ALGORITHM SETUP

It is possible to specify the PID algorithm as a scalar expression. However, some of the terms in the algorithm require some additional specifications. The algorithm contains the concentration in the measurement point, the time derivative of the concentration in the point, and the time integration of the concentration difference between the measured and wanted concentrations.

1 Go to the Options menu and choose Expressions>Scalar Expressions.

2 Set the Name to u_in_ctrl and define the Expression as

nojac(k_P_ctrl*(conc-c_set)+k_I_ctrl*Int+k_D_ctrl*ctime). The nojac

operator makes sure the above expression gives no Jacobian contribution. The resulting effect is the same as using nonideal weak constraints, namely a one-way coupling instead of the normal two-way coupling. Because of the use of a coupling variable, the unit becomes undefined for this variable and other quantities where you use it.

3 Click OK.

4 To specify the concentration and its time derivative in the point, go to the Options

menu and choose Integration Coupling Variables>Point Variables.

5 Select Point 10 and enter conc in the Name edit field and c in the Expression edit field.

6 For the same point enter ctime in the Name edit field and ct in the Expression edit field. ct is the predefined expression for the time derivative of the concentration.

7 Click OK.

8 To specify the time integral of the concentration difference in the point, go to the Physics menu and open the Global Equations dialog box.

PROCESS

CONTROL

USING

A

PID

CONTROLLER

|

9

9

Type Int in the Name (u) edit field.

10 In the Equation edit field type Intt-(conc-c_set).

11 Click OK to exit the Global Equations dialog box.

MESH GENERATION

1 Go to the Mesh menu and choose Free Mesh Parameters.

2 On the Global tab, select Finer in the Predefined mesh sizes list.

3 To reduce the number of elements along the curved boundaries, click the Custom mesh size button and type 0.5 in the Mesh curvature factor edit field.

4 Click Remesh, then click OK.

COMPUTING THE SOLUTION

1 Go to the Solve menu and select Solver Parameters.

2 On the General page, set the Times vector to range(0,0.04,6).

3 On the Time Stepping page, select Time steps from solver from the Times to store in

output list to make all time steps the solver takes available for postprocessing.

4 Select Intermediate from the Time steps taken by solver list to give the solver some freedom to set its own time steps. Using this option restricts the solver to take at least one time step in each subinterval of the time list.

5 Click OK to exit the Solver Parameters dialog box.

6 Click the Solve button on the Main toolbar to start the simulation.

POSTPROCESSING AND VISUALIZATION

The default visualization plots the magnitude of the velocity field at the end of the simulation interval. Follow the instructions below to reproduce the simultaneous plots of the oxygen concentration and the velocity stream lines at two different times presented in Figure 1 on page 4.

1 Go to the Postprocessing menu and choose Plot Parameters to open the Plot

Parameters dialog box.

2 On the General page, select the solution near t = 0.01 s from the Solution at time list.

3 On the Surface page, click the Surface Data tab.

4 In the Predefined quantities list, select Convection and Diffusion (cd)>Concentration, c.

5 Click the Streamline tab.

PROCESS

CONTROL

USING

A

PID

CONTROLLER

|

10

6

Select the Streamline plot check box. In the Predefined quantities list on the Streamline Data tab keep the default selection, Incompressible Navier-Stokes (ns)>Velocity field.

7 From the Streamline plot type list select Magnitude controlled.

8 Click Apply to view the upper plot in Figure 1.

9 Return to the General tab, then select the solution near t = 1.5 s from the Solution at time list. Click OK to generate the lower plot in Figure 1.

To visualize the inlet velocity and the measured concentration as functions of time, use domain plots:

1 Open the Domain Plot Parameters dialog box from the Postprocessing menu.

2 Click the Point tab.

3 Select Point 1 and enter u_in_ctrl*(u_in_ctrl>=0) in the Expression edit field.

4 Click Apply.

5 Click the General tab and select to plot in New figure in the Plot in list.

6 Click the Point tab, select Point 10, and select Concentration, c from the Predefined

quantities list.

7 Click OK.

To see the above plots for different values of k P , alter the k P value and solve the model again without closing the plot frames:

1 Open the Constants dialog box from the Options menu and change the value of

k_P_ctrl to 0.1 [m^4/(mol*s)].

2 Click the Solve button to solve the model for the new parameter value.

3 Open the Domain Plot Parameters dialog box from the Postprocessing menu.

4 On the General page, select to plot in Figure 2 and select the Keep current plot check box.

5 Click the Point tab and make sure Point 10 and Concentration, c are selected.

6 Click the Line Settings button. Set the Line style to Dashed line, then click OK.

7 Click Apply to generate the lower plot in Figure 2 on page 5.

8 On the General page, select to plot in Figure 1. Select the Keep current plot check box.

9 Click the Point tab, select Point 1, and type u_in_ctrl*(u_in_ctrl>=0) in the Expression edit field.

Click OK to close the dialog box and generate the upper plot in Figure 2.

PROCESS

CONTROL

USING

A

PID

CONTROLLER

|

11