main content

gain-凯发k8网页登录

this example shows how to design and tune a gain-scheduled controller for a chemical reactor transitioning from low to high conversion rate. for background, see seborg, d.e. et al., "process dynamics and control", 2nd ed., 2004, wiley, pp. 34-36.

continuous stirred tank reactor

the process considered here is a continuous stirred tank reactor (cstr) during transition from low to high conversion rate (high to low residual concentration). because the chemical reaction is exothermic (produces heat), the reactor temperature must be controlled to prevent a thermal runaway. the control task is complicated by the fact that the process dynamics are nonlinear and transition from stable to unstable and back to stable as the conversion rate increases. the reactor dynamics are modeled in simulink. the controlled variables are the residual concentration cr and the reactor temperature tr, and the manipulated variable is the temperature tc of the coolant circulating in the reactor's cooling jacket.

open_system('rct_cstr_ol')

we want to transition from a residual concentration of 8.57 kmol/m^3 initially down to 2 kmol/m^3. to understand how the process dynamics evolve with the residual concentration cr, find the equilibrium conditions for five values of cr between 8.57 and 2 and linearize the process dynamics around each equilibrium. log the reactor and coolant temperatures at each equilibrium point.

creq = linspace(8.57,2,5)';  % concentrations
treq = zeros(5,1);           % reactor temperatures
tceq = zeros(5,1);           % coolant temperatures
% specify trim conditions
opspec = operspec('rct_cstr_ol',5);
for k=1:5
   % set desired residual concentration
   opspec(k).outputs(1).y = creq(k);
   opspec(k).outputs(1).known = true;
end
% compute equilibrium condition and log corresponding temperatures
[op,report] = findop('rct_cstr_ol',opspec,...
   findopoptions('displayreport','off'));
for k=1:5
   treq(k) = report(k).outputs(2).y;
   tceq(k) = op(k).inputs.u;
end
% linearize process dynamics at trim conditions
g = linearize('rct_cstr_ol', 'rct_cstr_ol/cstr', op);
g.inputname = {'cf','tf','tc'};
g.outputname = {'cr','tr'};

plot the reactor and coolant temperatures at equilibrium as a function of concentration.

subplot(311), plot(creq,'b-*'), grid, title('residual concentration'), ylabel('creq')
subplot(312), plot(treq,'b-*'), grid, title('reactor temperature'), ylabel('treq')
subplot(313), plot(tceq,'b-*'), grid, title('coolant temperature'), ylabel('tceq')

an open-loop control strategy consists of following the coolant temperature profile above to smoothly transition between the cr=8.57 and cr=2 equilibria. however, this strategy is doomed by the fact that the reaction is unstable in the mid range and must be properly cooled to avoid thermal runaway. this is confirmed by inspecting the poles of the linearized models for the five equilibrium points considered above (three out of the five models are unstable).

pole(g)
ans(:,:,1) =
  -0.5225   0.0000i
  -0.8952   0.0000i
ans(:,:,2) =
   0.1733   0.0000i
  -0.8866   0.0000i
ans(:,:,3) =
   0.5114   0.0000i
  -0.8229   0.0000i
ans(:,:,4) =
   0.0453   0.0000i
  -0.4991   0.0000i
ans(:,:,5) =
  -1.1077   1.0901i
  -1.1077 - 1.0901i

the bode plot further highlights the significant variations in plant dynamics while transitioning from cr=8.57 to cr=2.

clf, bode(g(:,'tc'),{0.01,10})

feedback control strategy

to prevent thermal runaway while ramping down the residual concentration, use feedback control to adjust the coolant temperature tc based on measurements of the residual concentration cr and reactor temperature tr. for this application, we use a cascade control architecture where the inner loop regulates the reactor temperature and the outer loop tracks the concentration setpoint. both feedback loops are digital with a sampling period of 0.5 minutes.

open_system('rct_cstr')

the target concentration cref ramps down from 8.57 kmol/m^3 at t=10 to 2 kmol/m^3 at t=36 (the transition lasts 26 minutes). the corresponding profile tref for the reactor temperature is obtained by interpolating the equilibrium values treq from trim analysis. the controller computes the coolant temperature adjustment dtc relative to the initial equilibrium value tceq(1)=297.98 for cr=8.57. note that the model is set up so that initially, the output trsp of the "concentration controller" block matches the reactor temperature, the adjustment dtc is zero, and the coolant temperature tc is at its equilibrium value tceq(1).

clf
t = [0 10:36 45];
c = interp1([0 10 36 45],[8.57 8.57 2 2],t);
subplot(211), plot(t,c), grid, set(gca,'ylim',[0 10])
title('target residual concentration'), ylabel('cref')
subplot(212), plot(t,interp1(creq,treq,c))
title('corresponding reactor temperature at equilibrium'), ylabel('tref'), grid

control objectives

use tuninggoal objects to capture the design requirements. first, cr should follow setpoints cref with a response time of about 5 minutes.

r1 = tuninggoal.tracking('cref','cr',5);

the inner loop (temperature) should stabilize the reaction dynamics with sufficient damping and fast enough decay.

mindecay = 0.2;
mindamping = 0.5;
% constrain closed-loop poles of inner loop with the outer loop open
r2 = tuninggoal.poles('tc',mindecay,mindamping);
r2.openings = 'trsp';

the rate limit block at the controller output specifies that the coolant temperature tc cannot vary faster than 10 degrees per minute. this is a severe limitation on the controller authority which, when ignored, can lead to poor performance or instability. to take this rate limit into account, observe that cref varies at a rate of 0.25 kmol/m^3/min. to ensure that tc does not vary faster than 10 degrees/min, the gain from cref to tc should be less than 10/0.25=40.

r3 = tuninggoal.gain('cref','tc',40);

finally, require at least 7 db of gain margin and 45 degrees of phase margin at the plant input tc.

r4 = tuninggoal.margins('tc',7,45);

gain-scheduled controller

to achieve these requirements, we use a pi controller in the outer loop and a lead compensator in the inner loop. due to the slow sampling rate, the lead compensator is needed to adequately stabilize the chemical reaction at the mid-range concentration cr = 5.28 kmol/m^3/min. because the reaction dynamics vary substantially with concentration, we further schedule the controller gains as a function of concentration. this is modeled in simulink using lookup table blocks as shown in figures 1 and 2.

figure 1: gain-scheduled pi controller for concentration loop.

figure 2: gain-scheduled lead compensator for temperature loop.

tuning this gain-scheduled controller amounts to tuning the look-up table data over a range of concentration values. rather than tuning individual look-up table entries, parameterize the controller gains kp,ki,kt,a,b as quadratic polynomials in cr, for example,

$$ k_p(c_r) = k_{p0}   k_{p1} c_r   k_{p2} c_r^2 . $$

besides reducing the number of variables to tune, this approach ensures smooth gain transitions as cr varies. using systune, you can automatically tune the coefficients $k_{p0}, k_{p1}, k_{p2}, k_{i0}, \ldots$ to meet the requirements r1-r4 at the five equilibrium points computed above. this amounts to tuning the gain-scheduled controller at five design points along the cref trajectory. use the tunablesurface object to parameterize each gain as a quadratic function of cr. the "tuning grid" is set to the five concentrations creq and the basis functions for the quadratic parameterization are $c_r, c_r^2$. most gains are initialized to be identically zero.

tuninggrid = struct('cr',creq);
shapefcn = @(cr) [cr , cr^2];
kp = tunablesurface('kp', 0, tuninggrid, shapefcn);
ki = tunablesurface('ki', -2, tuninggrid, shapefcn);
kt = tunablesurface('kt', 0, tuninggrid, shapefcn);
a = tunablesurface('a', 0, tuninggrid, shapefcn);
b = tunablesurface('b', 0, tuninggrid, shapefcn);

controller tuning

because the target bandwidth is within a decade of the nyquist frequency, it is easier to tune the controller directly in the discrete domain. discretize the linearized process dynamics with sample time of 0.5 minutes. use the zoh method to reflect how the digital controller interacts with the continuous-time plant.

ts = 0.5;
gd = c2d(g,ts);

create an sltuner interface for tuning the quadratic gain schedules introduced above. use block substitution to replace the nonlinear plant model by the five discretized linear models gd obtained at the design points creq. use setblockparam to associate the tunable gain functions kp, ki, kt, a, b with the lookup table blocks of the same name.

blocksubs = struct('name','rct_cstr/cstr','value',gd);
st0 = sltuner('rct_cstr',{'kp','ki','kt','a','b'},blocksubs);
st0.ts = ts;  % sample time for tuning
% register points of interest
st0.addpoint({'cref','cr','tr','trsp','tc'})
% parameterize look-up table blocks
st0.setblockparam('kp',kp);
st0.setblockparam('ki',ki);
st0.setblockparam('kt',kt);
st0.setblockparam('a',a);
st0.setblockparam('b',b);

you can now use systune to tune the controller coefficients against the requirements r1-r4. make the stability margin requirement a hard constraints and optimize the remaining requirements.

st = systune(st0,[r1 r2 r3],r4);
final: soft = 1.23, hard = 0.99944, iterations = 208

the resulting design satisfies the hard constraint (hard<1) and nearly satisfies the remaining requirements (soft close to 1). to validate this design, simulate the responses to a ramp in concentration with the same slope as cref. each plot shows the linear responses at the five design points creq.

t = 0:ts:20;
uc = interp1([0 2 5 20],(-0.25)*[0 0 3 3],t);
subplot(211), lsim(getiotransfer(st,'cref','cr'),uc)
grid, set(gca,'ylim',[-1.5 0.5]), title('residual concentration')
subplot(212), lsim(getiotransfer(st,'cref','tc'),uc)
grid, title('coolant temperature variation')

note that rate of change of the coolant temperature remains within the physical limits (10 degrees per minute or 5 degrees per sample period).

controller validation

inspect how each gain varies with cr during the transition.

% access tuned gain schedules
tgs = getblockparam(st);
% plot gain profiles
clf
subplot(321), viewsurf(tgs.kp), ylabel('kp')
subplot(322), viewsurf(tgs.ki), ylabel('ki')
subplot(323), viewsurf(tgs.kt), ylabel('kt')
subplot(324), viewsurf(tgs.a), ylabel('a')
subplot(325), viewsurf(tgs.b), ylabel('b')

to validate the gain-scheduled controller in simulink, first use writeblockvalue to apply the tuning results to the simulink model. for each lookup table block, this evaluates the corresponding quadratic gain formula at the table breakpoints and updates the table data accordingly.

writeblockvalue(st)

next push the play button to simulate the response with the tuned gain schedules. the simulation results appear in figure 3. the gain-scheduled controller successfully drives the reaction through the transition with adequate response time and no saturation of the rate limits (controller output du matches effective temperature variation dtc). the reactor temperature stays close to its equilibrium value tref, indicating that the controller keeps the reaction near equilibrium while preventing thermal runaway.

figure 3: transition with gain-scheduled cascade controller.

controller tuning in matlab

alternatively, you can tune the gain schedules directly in matlab without using the sltuner interface. first parameterize the gains as quadratic functions of cr as done above.

tuninggrid = struct('cr',creq);
shapefcn = @(cr) [cr , cr^2];
kp = tunablesurface('kp', 0, tuninggrid, shapefcn);
ki = tunablesurface('ki', -2, tuninggrid, shapefcn);
kt = tunablesurface('kt', 0, tuninggrid, shapefcn);
a = tunablesurface('a', 0, tuninggrid, shapefcn);
b = tunablesurface('b', 0, tuninggrid, shapefcn);

use these gains to build the pi and lead controllers.

pi = pid(kp,ki,'ts',ts,'timeunit','min');
pi.u = 'ecr';   pi.y = 'trsp';
lead = kt * tf([1 -a],[1 -b],ts,'timeunit','min');
lead.u = 'etr';   lead.y = 'tc';

use connect to build a closed-loop model of the overall control system at the five design points. mark the controller outputs trsp and tc as "analysis points" so that loops can be opened and stability margins evaluated at these locations. the closed-loop model t0 is a 5-by-1 array of linear models depending on the tunable coefficients of kp,ki,kt,a,b. each model is discrete and sampled every half minute.

gd.timeunit = 'min';
s1 = sumblk('ecr = cref - cr');
s2 = sumblk('etr = trsp - tr');
t0 = connect(gd(:,'tc'),lead,pi,s1,s2,'cref','cr',{'trsp','tc'});

finally, use systune to tune the gain schedule coefficients.

t = systune(t0,[r1 r2 r3],r4);
final: soft = 1.23, hard = 0.99944, iterations = 208

the result is similar to the one obtained above. confirm by plotting the gains as a function of cr using the tuned coefficients in t.

clf
subplot(321), viewsurf(setblockvalue(kp,t)), ylabel('kp')
subplot(322), viewsurf(setblockvalue(ki,t)), ylabel('ki')
subplot(323), viewsurf(setblockvalue(kt,t)), ylabel('kt')
subplot(324), viewsurf(setblockvalue(a,t)), ylabel('a')
subplot(325), viewsurf(setblockvalue(b,t)), ylabel('b')

you can further validate the design by simulating the linear responses at each design point. however, you need to return to simulink to simulate the nonlinear response of the gain-scheduled controller.

see also

| |

related examples

more about

    网站地图