www.gusucode.com > control_featured 案例源码程序 matlab代码 > control_featured/DesignInternalModelControllerForChemicalReactorPlantExample.m
%% Design Internal Model Controller for Chemical Reactor Plant % This example shows how to design a compensator in an IMC structure for % series chemical reactors, using Control System Designer. Model-based % control systems are often used to track setpoints and reject load % disturbances in process control applications. % Copyright 1986-2012 The MathWorks, Inc. %% Plant Model % The plant for this example is a chemical reactor system, comprised of two % well-mixed tanks. % % <<../IMCProcessDemo_01.png>> %% % The reactors are isothermal and the reaction in each reactor is first % order on component A: % % $$r_{A} = -kC_{A}$$ % % Material balance is applied to the system to generate a dynamic model of % the system. The tank levels are assumed to stay constant because of the % overflow nozzle and hence there is no level control involved. % % For details about this plant, see Example 3.3 in Chapter 3 of "Process % Control: Design Processes and Control Systems for Dynamic Performance" by % Thomas E. Marlin. %% % The following differential equations describe the component % balances: % % $$V\frac{dC_{A1}}{dt} = F(C_{A0} -C_{A1}) - VkC_{A1}$$ % % $$V\frac{dC_{A2}}{dt} = F(C_{A1} -C_{A2}) - VkC_{A2}$$ % % At steady state, % % $$ \frac{dC_{A1}}{dt} = 0 $$ % % $$ \frac{dC_{A2}}{dt} = 0 $$ % % the material balances are: % % $$F^*(C_{A0}^* - C_{A1}^*) - VkC_{A1}^* = 0$$ % % $$F^*(C_{A1}^* - C_{A2}^*) - VkC_{A2}^* = 0$$ % % where $C_{A0}^*$, $C_{A1}*$, and $C_{A2}*$ are steady-state values. % % Substitute, the following design specifications and reactor % parameters: % % $$F^*$$ = 0.085 $$mole/min$$ % % $$C_{A0}^*$$ = 0.925 $$mol/min$$ % % $$V$$ = 1.05 $$m^3$$ % % $$k$$ = 0.04 $$min^{-1}$$ % % The resulting steady-state concentrations in the two reactors are: % % $$C_{A1}^* = KC_{A0}^* = 0.6191 mol/m^3$$ % % $$C_{A2}^* = K^2C_{A0}^* = 0.4144 mol/m^3$$ % % where % % $$K = \frac{F^{*}}{F*+Vk} = 0.6693$$ %% % For this example, design a controller to maintain the outlet % concentration of reactant from the second reactor, $C_{A2}^*$, in the % presence of any disturbance in feed concentration, $C_{A0}$. The % manipulated variable is the molar flowrate of the reactant, |F|, entering % the first reactor. %% Linear Plant Models % In this control design problem, the plant model is % % $$ \frac{C_{A2}(s)}{ F(s)}$$ % % and the disturbance model is % % $$ \frac{C_{A0}(s)}{C_{A2}(s)}$$ % %% % This chemical process can be represented using the following block % diagram: % % <<../IMCProcessDemo_02.png>> % % where % % $$ G_{A1} = \frac{C_{A1}(s)}{C_{A0}(s)} = \frac{0.6693}{8.2677s+1}$$ % % $$ G_{F1} = \frac{C_{A1}(s)}{F(s)} = \frac{2.4087}{8.2677s+1}$$ % % $$ G_{A2} = \frac{C_{A2}(s)}{C_{A1}(s)} = \frac{0.6693}{8.2677s+1}$$ % % $$ G_{F2} = \frac{C_{A2}(s)}{F(s)} = \frac{1.6118}{8.2677s+1}$$ % % Based on the block diagram, obtain the plant and disturbance models as % follows: % % $$ \frac{C_{A2}(s)}{ F(s)} = G_{F1}G_{A2} + G_{F2} = \frac{13.3259s+3.2239}{(8.2677s+1)^2} $$ % % $$ \frac{C_{A2}}{C_{A0}} = G_{A1}G_{A2} = \frac{0.4480}{(8.2677s+1)^2}$$ % %% % Create the plant model at the command line: s = tf('s'); G1 = (13.3259*s+3.2239)/(8.2677*s+1)^2; G2 = G1; Gd = 0.4480/(8.2677*s+1)^2; %%% % G1 is the real plant used in controller evaluation. G2 is an % approximation of the real plant and it is used as the predictive model in % the IMC structure. |G2 = G1| means that there is no model mismatch. |Gd| % is the disturbance model. %% Define IMC Structure in Control System Designer % Open Control System Designer. % % controlSystemDesigner % % <<../IMCProcessDemo_03.png>> % %% % Select the IMC control architecture. In Control System Designer, click % *Edit Architecture*. In the Edit Architecture dialog box, select % Configuration 5. % % <<../IMCProcessDemo_04.png>> % %% % Load the system data. For *G1*, *G2*, and *Gd*, specify a model *Value*. %% % <<../IMCProcessDemo_06.png>> %% Tune Compensator % Plot the open-loop step response of |G1|. step(G1) %% % Right-click the plot and select *Characteristics > Rise Time* % submenu. Click the blue rise time marker. % % <<../IMCProcessDemo_07.png>> % % The rise time is about 25 seconds and we want to tune the IMC compensator % to achieve a faster closed-loop response time. % % To tune the IMC compensator, click *Tuning Methods*, and select % *Internal Model Control (IMC) Tuning*. % % <<../IMCProcessDemo_08.png>> % % Select a closed-loop time constant of |2| and specify |2| as the desired % compensator order. Click *Update Compensator*. % % <<../IMCProcessDemo_09.png>> %% % To view the closed-loop step response, in Control System Designer, % double-click the *IOTransfer_r2y:step* plot tab. % % <<../IMCProcessDemo_11.png>> % %% Control Performance with Model Mismatch % When designing the controller, we assumed G1 was equal to G2. In % practice, they are often different, and the controller needs to be robust % enough to track setpoints and reject disturbances. %% % Create model mismatches between G1 and G2 and examine the control % performance at the MATLAB command line in the presence of both setpoint % change and load disturbance. %% % Export the IMC Compensator to the MATLAB workspace. Click *Export*. In % the Export Model dialog box, select compensator model *C*. % % <<../IMCProcessDemo_12.png>> % % Click *Export*. %% % Convert the IMC structure to a classic feedback control structure with % the controller in the feedforward path and unit feedback. C = zpk([-0.121 -0.121],[-0.242, -0.466],2.39); C_new = feedback(C,G2,+1) %% % Define the following plant models: % % * No Model Mismatch: % G1p = (13.3259*s+3.2239)/(8.2677*s+1)^2; %% % % * |G1| time constant changed by 5%: % G1t = (13.3259*s+3.2239)/(8.7*s+1)^2; %% % % * |G1| gain is increased by 3 times: % G1g = 3*(13.3259*s+3.2239)/(8.2677*s+1)^2; %% % Evaluate the setpoint tracking performance. step(feedback(G1p*C_new,1),feedback(G1t*C_new,1),feedback(G1g*C_new,1)) legend('No Model Mismatch','Mismatch in Time Constant','Mismatch in Gain') %% % Evaluate the disturbance rejection performance. step(Gd*feedback(1,G1p*C_new),Gd*feedback(1,G1t*C_new),Gd*feedback(1,G1g*C_new)) legend('No Model Mismatch','Mismatch in Time Constant','Mismatch in Gain') %% % The controller is fairly robust to uncertainties in the plant parameters.