71

Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

Anders LeirpollAdriaen VerheyleweghenKasper Linnestad

Control Project R:CSTR Reactor With CoolingJacket Dynamics

Trondheim, November 2013

Norwegian University of Science and TechnologyFaculty of Natural Sciences and TechnologyDepartment of Chemical Engineering

Page 2: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper
Page 3: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

i

Symbols

Symbol Unit Description

nA molNumber of moles of component A inthe reactor

t h Time

NA,f mol/hMolar feed rate of component A tothe reactor

NA mol/hMolar �ow rate of component A outof the reactor

GA mol/hAmount of A generated by thereactions in the reactor

V m3 Volume of the reactorrA mol/(m3h) Reaction rate of component A

νA,iStoichiometric coe�cient ofcomponent A in reaction i

k 1/h Reaction rate constantk0 1/h Parameter in Arrhenius' equationEa kJ/kmol Energy of activationR kJ/(kmol K) Gas constantT K Temperature of the reactor

CA mol/m3 Concentration of component A in thereactor

F m3/hVolumetric �ow rate out of thereactor

Ff m3/h Volumetric �ow rate in to the reactorFf,j m3/h Volumetric �ow rate in to the jacketH kJ/h Flow of enthalpy out of the reactorHR kJ Total enthalpy in the reactorHf kJ/h Flow of enthalpy in to the reactorQ kJ/h Heat added to the reactorp Pa PressureCp kJ/K Heat capacity at constant pressure

∆rxH kJ/molEnthalpy of reaction per mole ofreactant

Tf K Temperature of the feedρ kg/m3 Density of the �uid in the reactorU kJ/(m2hK) Total heat transfer coe�cientA m2 Area of heat transferTj K Temperature of the jacket

Page 4: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

ii

Symbols

Symbol Unit Description

Tf,j K Temperature of the feed to the jacketVj m3 Volume of the jacketρj kg/m3 Density of coolant in the jacket

C∗A mol/m3 Steady-state concentration ofcomponent A in the reactor

T ∗j KSteady-state temperature of thejacket

F ∗f,j m3/hSteady-state volumetric �ow rate into the jacket

T ∗ K Nominal temperature of the reactorK Steady-state gainKC Controller gainx Time derivative of the state variablesx State variablesy K Outputu m3/h Inputd DisturbancesA,B,C,E Coe�cient matrices

G(s)Open-loop transfer function frominput to output

s Laplace domain variable

H(s)Open-loop transfer function matrixfrom disturbances to output

ys Setpoint

Page 5: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

Contents

Contents iii

List of Figures iv

List of Tables v

1 Modelling and Simulation 1

1.1 Derivation of the balance equations . . . . . . . . . . . . . . . 1

1.2 Estimation of the Steady-State Values . . . . . . . . . . . . . 5

1.3 Classi�cation of the Variables . . . . . . . . . . . . . . . . . . 6

1.4 Simulation of step changes . . . . . . . . . . . . . . . . . . . . 6

1.5 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2 System Analysis 13

2.1 Linearisation of the model . . . . . . . . . . . . . . . . . . . . 13

2.2 Stability analysis . . . . . . . . . . . . . . . . . . . . . . . . . 20

2.3 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

3 Controller Design 23

3.1 Contol Structure . . . . . . . . . . . . . . . . . . . . . . . . . 23

3.2 Controller Tuning . . . . . . . . . . . . . . . . . . . . . . . . . 24

3.3 Controller simulations . . . . . . . . . . . . . . . . . . . . . . 25

Bibliography 27

Appendices 28

iii

Page 6: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

iv Contents

A MATLAB scripts 29

Page 7: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

List of Figures

1.1 The Simulink block-diagram used to simulate the non-linear model. 6

1.2 Step changes in Ff,j and Tf , and the corresponding temperatureresponse in the reactor. . . . . . . . . . . . . . . . . . . . . . . . 7

1.3 Step changes in Tf,j and CA,f , and the corresponding tempera-ture response in the reactor. . . . . . . . . . . . . . . . . . . . . 8

1.4 Step changes in Ff and the corresponding temperature responsein the reactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.1 The Simulink block-diagram used to simulate the linear model. . 15

2.2 Step changes in Ff,j corresponding temperature responses. Thenon-linear model is shown i red and the linearised model is shownin black. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.3 Step changes in Tf corresponding temperature responses. Thenon-linear model is shown i red and the linearised model is shownin black. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.4 Step changes in Tf,j corresponding temperature responses. Thenon-linear model is shown i red and the linearised model is shownin black. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.5 Step changes in CA,f corresponding temperature responses. Thenon-linear model is shown i red and the linearised model is shownin black. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

2.6 Step changes in Ff corresponding temperature responses. Thenon-linear model is shown i red and the linearised model is shownin black. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

2.7 Block diagram of the closed loop. . . . . . . . . . . . . . . . . . 21

v

Page 8: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

3.1 Block diagram of the cascade structure. . . . . . . . . . . . . . . 24

List of Tables

1.1 Classi�cation of the variables. . . . . . . . . . . . . . . . . . . . 61.2 Steady state gains. . . . . . . . . . . . . . . . . . . . . . . . . . 10

3.1 Tuning parameters. KC is the controller gain, τI is the integraltime, τD is the derivative time and Tf is the �lter time constant . 25

vi

Page 9: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

Chapter 1

Modelling and Simulation

1.1 Derivation of the balance equations

Component Balance of A

The general component balance for an arbitrary component can be writtenas

dnA

dt= NA,f −NA +GA (1.1)

where Ni are the molar �ows of component A in and out of the reactor andGA is the amount of A generated by the reactions. GA can be expressed asthe reaction rate of A integrated over the whole reactor volume

GA =

∫ V

0rA dv (1.2)

The overall reaction rate of A, rA, can be written as a the sum of reactionrates for all reactions i

rA =∑i

νA,iri (1.3)

where νA,i is the stoichiometric coe�cient of A in reaction i. Assuming a�rst order reaction, the reaction order can be written as

rA = −kCA (1.4)

The reaction rate constant k is assumed to follow Arrhenius' equation

k = k0e(−EaRT

) (1.5)

1

Page 10: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

2 Modelling and Simulation

Assuming that the mixing is perfect, the concentration of A in the re-actor, CA = nA/V , can be de�ned. In the same way, the inlet and outletconcentrations are de�ned as CA,f = NA,f/Ff and CA,out = NA/F . EquationEquation (1.1) can now be rewritten in terms of the concentrations as shownbelow

d(CAV )

dt= CA,fFf − CAF +

∫ V

0rA dv (1.6)

Since the volume in the reactor is assumed to be constant, the expressioncan be simpli�ed further. Constant reactor volume also implies that thevolumetric �ows in and out of the reactor must be equal. The �nal form ofthe component balance can thus be written as

dCA

dt= (CA,f − CA)

Ff

V− k0CAe(−Ea

RT) (1.7)

Energy Balance for the Reactor

The dynamic energy balance in enthalpy can be written as [1, p. 278]:

dHr

dt= Hf −H +Q (1.8)

Where Hr is the enthalpy for the reactor, Hf is the enthalpy of the feedstream, H is the enthalpy of the outlet stream and Q is the heat transferredfrom the jacket. Here it is assumed that the change internal energy inthe system is so big that the other energy forms can be neglected (kineticenergy, potential energy, etc.), that the rector volume, V is constant, thereactor pressure, p is constant, the system performs no work, W on thesurroundings (shaft work, electrical work, etc.) and that transferred heat tothe reactor is through the jacket. By neglecting the enthalpy of mixing, theenthalpy of stream m can be written as:

Hm(T, p, nA, nA) = nAHm,A(T, p) + nBHm,B(T, p),∀j ∈ {A,B}∀m ∈ {f, ∅}

(1.9)

where Hm,j is the molar enthalpy of component j in stream m. Hencethe change in enthalpy can be written as a total di�erential in pressure, pand temperature, T :

dHm,j =∂Hm,j

∂T dT +∂Hm,j

∂p dp

= Cp,m,j dT(1.10)

Page 11: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

1.1. Derivation of the balance equations 3

Where the de�nition of heat capacity at constant pressure, Cp has beenintroduced, and it has been assumed that the change in pressure is negligible.Thus the enthalpy can be written as

H(T, p)m,j = H(Tf , p)m,j +

∫ Tm

Tf

Cp,m,j dT

= H(Tf , p)m,j + Cp,m,j(Tm − Tf)

(1.11)

where it has been assumed constant heat capacities in the last equation.

Inserting all this into the enthalpy balance, Equation (1.8), yields:

d(nAHA(T ) + nBHB(T )

)dt

=Nf,AHA(Tf) +Nf,BHB(Tf)

−NAHA(T )−NBHB(T ) +Q

(1.12)

HA(T )dnA

dt+HB(T )

dnB

dt+ nA

dHA(T )

dt+ nB

dHB(T )

dt=

Nf,AHA(Tf) +Nf,BHB(Tf)−NAHA(T )−NBHB(T ) +Q(1.13)

Inserting the component balances for A and B, setting the enthalpyreference as Hj(Tf) = 0 and inserting the temperature dependence of theenthalpy Equation (1.11):

(nACp,A + nBCp,B

) dT

dt=(Nf,ACp,A +Nf,BCp,B

)(Tf − T )

−rV(νAHA(T ) + νBHB(T )

)+Q

(1.14)

The enthalpy of reaction is:

∆rxH(T ) =∑∀jνjHj(T ) (1.15)

Molar heat capacities have been used this far. By introducing the spe-ci�c heat capacities, enthalpy of reaction and assuming constant density, ρ,Equation (1.14) can be rearranged:

V ρcpdT

dt= ρFf cp,f (Tf − T )− rV∆rxH(T ) +Q (1.16)

where:

Page 12: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

4 Modelling and Simulation

cp = xAcp,A + xBcp,B (1.17a)

cp,f = xf,Acp,f,A + xf,Bcp,f,B (1.17b)

and xj is the mass fraction of component j. For the heat transfer, itis assumed that the both the reactor and the jacket are well mixed, whichyields the expression [1, p. 120]:

Q = UA(Tj − T ) (1.18)

where Tj is the temperature of the jacket, U is the total heat transfer co-e�cient (which is assumed to be independent of �ow rate and temperature)and A is the area of heat transfer. Inserting this into Equation (1.16) anddividing by the reactor volume, V :

ρcpdT

dt= ρ

Ff

Vcp,f (Tf − T )− r∆rxH(T ) +

UA

V

(Tj − T

)(1.19)

Furthermore it is assumed that the density multitplied with the speci�c

heat capacity is constant, which yields the �nal expression fordT

dt:

dT

dt=Ff

V(Tf − T )− k0CA

ρcpe−

EaRT ∆rxH +

UA

V ρcp

(Tj − T

)(1.20)

where the enthalpy of reaction is assumed to be independent of temper-ature.

Energy Balance for the Jacket

The equation for the jacket temperature, Tj is derived in the same manneras Equation (1.20), but there is no reaction in the jacket which leads to thisequation:

dTj

dt=Ff,j

Vj

(Tf,j − Tj

)+

UA

Vjρjcp,j

(T − Tj

)(1.21)

Page 13: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

1.2. Estimation of the Steady-State Values 5

1.2 Estimation of the Steady-State Values

The steady-state values for the concentration of A, C∗A, the temperature ofthe jacket, T ∗j and the volumetric �ow rate of the jacket, F ∗j where calculatedby setting the nominal temperature of the reactor, T ∗ = 38 ◦C. The steady-state equation were found by setting Equation (1.7), Equation (1.20) andEquation (1.21) equal to zero. The calculations were done in MATLABusing steadystate.m included in Appendix A.

Which produces:

>> steadystate

C_A = 1.054094 kmol/m3

F_j = 2.032484 m3/h

T_j = 303.121877 K

Page 14: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

6 Modelling and Simulation

1.3 Classi�cation of the Variables

The variables are classi�ed and listed in Table 1.1

Table 1.1: Classi�cation of the variables.

Classi�cation Variables

States, x T, CA, Tj

Inputs, u Fj

Disturbances, d Tf , Tj,f , Ff , CA,f

Outputs (measurements), y T

1.4 Simulation of step changes

Simulations

The step changes are simulated in Simulink. The block-diagram is shown inFigure 1.1. This simulation utilizes a MATLAB S-function, reactor_sfcn.m,shown in Appendix A.

CV

MV

DV

Caf increase

Tf increase

y

To Workspace

time

To Workspace1Clock

Scopereactor_sfcn

S-Function: CSTR reactor with jacket system

Tf

Tf nominal

Caf

Caf nominal

Ffj increase

Ffj

Ffj nominal

Tfj increase

Tfj

Tfj nominal

Ff increase

Ff

Ff nominal

u1

To Workspace2

d1

To Workspace3

d2

To Workspace4

d3

To Workspace5

d4

To Workspace6

u

Figure 1.1: The Simulink block-diagram used to simulate the non-linearmodel.

Page 15: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

1.4. Simulation of step changes 7

The simulation is run with the MATLAB script step_change.m in-cluded in Appendix A. The result is shown in the following �gures:

0 2 4 6 8 101.9

2

2.1

2.2

Step change in Ff ,j

Ff,j

[m3/h

]

t [h]

0 2 4 6 8 10

300

320

340

360

Step change in Ff ,j

T[K

]

t [h]

0 2 4 6 8 10280

300

320

Step change in Tf

T f[K

]

t [h]

0 2 4 6 8 10

300

320

340

360

Step change in Tf

T[K

]

t [h]

Figure 1.2: Step changes in Ff,j and Tf , and the corresponding temperatureresponse in the reactor.

Page 16: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

8 Modelling and Simulation

0 2 4 6 8 10250

260

270

280

290

Step change in Tf ,j

T f,j

[K]

t [h]

0 2 4 6 8 10

300

320

340

360

Step change in Tf ,j

T[K

]

t [h]

0 2 4 6 8 101.9

2

2.1

2.2

Step change in CA,f

CA,f

[kmol/m

3 ]

t [h]

0 2 4 6 8 10

300

320

340

360

Step change in CA,f

T[K

]

t [h]

Figure 1.3: Step changes in Tf,j and CA,f , and the corresponding tempera-ture response in the reactor.

Page 17: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

1.4. Simulation of step changes 9

0 1 2 3 4 5 6 7 8 9 1055

60

65

Step change in Ff

Ff

[m3/h

]

t [h]

0 1 2 3 4 5 6 7 8 9 10

300

320

340

360

Step change in Ff

T[K

]

t [h]

Figure 1.4: Step changes in Ff and the corresponding temperature responsein the reactor

Steady-state gain calculations

The steady-state gains are calculated by:

K =∆y

∆u(1.22)

where K is the steady-state gain, ∆y is the change in the controlled vari-able, T and ∆u is the change in the disturbance/manipulated variable. Thisis calculated for every disturbance/manipulated variable listed in Table 1.1with the MATLAB-script steady_step.m included in Appendix A. Theresults are summarized in Table 1.2.

Page 18: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

10 Modelling and Simulation

Table 1.2: Steady state gains.

Manipulated

variable and

disturbances

Steady-state

temperature, TSteady-state gain,K

Ff,j 296.65 K −71.361 K/(m3/h)Tf 364.06 K 1.8298 K/KTf,j 327.72 K 0.64708 K/KCA,f 335.23 K 120.38 K/(kmol/m3)Ff 295.35 K −2.8208 K/(m3/h)

1.5 Discussion

Critical analysis of the model

In the derivation of the component balance of component A, it is assumedthat the reaction is of �rst order. This assumption is reasonable since thereaction only involves one reactant, reacting to one product.

The reaction rate constant is assumed to follow the Arrhenius equation.This assumption is often valid, according to Chorkendor� and Niemantsver-driet [2, p. 50].

The reactor is assumed to be ideally mixed, which is not valid for a re-alistic reactor. However, the de�nition of a theoretical CSTR is that it isideally mixed. It is also assumed that the reactor doesn't expand or con-tract, such that the volume can be assumed to be constant. This is true,otherwise the reactor could explode.

In the energy balance for the reactor, it is assumed that the internal en-ergy of the system of much larger than the kinetic and potential energy ofthe system. No work is performed on the system by the surroundings, suchthat shaft work and electrical work can be neglected. Enthalpy of mixing isneglected because it is usually close to zero.

The heat capacity and density of the �uid are assumed to be constantthroughout the reactor. This is a good assumption for incompressible �uids,such as most liquids.

Page 19: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

1.5. Discussion 11

Analysis of the results

As seen in Figure 1.2, increase in the jacket �ow rate reduces the reactortemperature. This is expected since the jacket temperature is lower than thereactor temperature at nominal values. Compared to the other responses thetemperature change occurs slowly, as the �owrate through the jacket onlyappears in the temperature balance of the jacket, Equation (1.21). Whichin turn will a�ect the temperature in the reactor through Equation (1.20).

A step change in the feed temperature has a great e�ect on the temper-ature of the reactor as is evident in Figure 1.2. This e�ect is expected dueto the energy balance. By increasing the feed temperature the enthalpy ofthe feed is increased which in turn adds more enthalpy to the reactor. Thechange in the temperature of the reactor is very fast because the feed tem-perature directly a�ects the temperature as can be seen in Equation (1.20).

In Figure 1.3 it can be seen that increased temperature in the jacket feedresults in a higher reactor temperature. This is expected since the jacketcools the reactor, and a higher jacket temperature increases the temperatureof the jacket. This will in turn result in less cooling of the reactor whichleads to an increased reactor temperature.

A step change in the concentration of A in the feed to the reactor increasesthe temperature in the reactor as is evident from Figure 1.3. This is asexpected because the reaction is exothermic, and an increase in the concen-tration will increase the rate of reaction.

From Figure 1.4 it can be seen that an increase in feed �ow results in lowerreactor temperature. This is expected because the feed �ow has a lowertemperature than the nominal reactor temperature.

The steady-state gains are shown in Table 1.2. For the temperature dis-turbances the steady-state gains are positive, and the steady-state gain forthe feed temperature is higher than that of the jacket feed temperature. This�ts well with the responses shown in Figure 1.2 and Figure 1.3 respectively.The steady-state gain for the step change in feed �ow to the jacket and forthe feed �ow to the reactor are both negative. The gain for the feed �owto the jacket has a much larger value than that of the �ow to the reactor.The reason for this is that they both give similar steady state temperatures,but the change in the disturbance is much lower for the jacket feed. Thesteady-state gain for the step change in the concentration of component A

Page 20: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

12 Modelling and Simulation

to the reactor is positive, which coincides well with Figure 1.3.

Page 21: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

Chapter 2

System Analysis

2.1 Linearisation of the model

Derivation

The model is linearised using a �rst-order Taylor-expansion as shown inEquation (2.1) below:

f(x) ≈ f(x∗) +∑∀xi

∂f(x)∂xi

∣∣∣x=x∗

∆xi (2.1)

By taylor expansion in the deviation variables the non-linear component andenergy balances were linearized around nominal values to �t the state-spaceform, here ∗ denotes nominal (steady-state) values.

d∆CA

dt≈∂(d∆CA

dt )

∂T

∣∣∣∣∣∗

∆T +∂(d∆CA

dt )

∂Ff

∣∣∣∣∣∗

∆Ff

+∂(d∆CA

dt )

∂CA

∣∣∣∣∣∗

∆CA +∂(d∆CA

dt )

∂CA,f

∣∣∣∣∣∗

∆CA,f

(2.2)

Where the term d∆CAdt

∣∣∣∗is omitted because it is identical to zero (by de�ni-

tion of steady state).

d∆CA

dt≈ −

C∗Ak0Eae−EaRT∗

RT ∗2∆T +

C∗A,f − C∗AV

∆Ff

+

(−k0e−

EaRT∗ −

F ∗fV

)∆CA +

F ∗fV

∆CA,f

(2.3)

13

Page 22: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

14 System Analysis

Similarly for the energy balance of the reactor:

d∆T

dt≈

−F ∗fV− UA

V ρcp−

∆rxHk0C∗AEae−

EaRT∗

ρcpRT ∗2

∆T+

T ∗f − T ∗

V∆Ff +

F ∗fV

∆Tf −∆rxHk0e−

EaRT∗

ρcp∆CA +

UA

V ρcp∆Tj

(2.4)

And for the energy balance of the jacket:

d∆Tj

dt≈ UA

Vjρjcp,j∆T +

(− UA

Vjρjcp,j−F ∗f,jVj

)∆Tj

+F ∗f,jVj

∆Tf,j +T ∗f,j − T ∗j

Vj∆Ff,j

(2.5)

Introducing the state-space notation:

x ≈ Ax + Bu+ Ed (2.6)

x =dx

dt(2.7)

x =[∆CA ∆T ∆Tj

]T(2.8)

u = ∆Ff,j (2.9)

d =[∆Tf ∆Tj,f ∆Ff ∆CA,f

]T(2.10)

A =

−k0e

− EaRT∗ − F∗

fV −C∗

Ak0Eae− EaRT∗

RT∗2 0

−∆rxHk0e− EaRT∗

ρcp−F∗

fV − UA

V ρcp− ∆rxHk0CAEae

− EaRT∗

ρcpRT∗2UAV ρcp

0 UAVjρj cp,j

− UAVjρj cp,j

−F∗

f,jVj

(2.11)

B =

00

Tf,j−Tj

Vj

(2.12)

Page 23: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

2.1. Linearisation of the model 15

E =

0 0 −C∗A−C

∗A,f

VF ∗fV

F ∗fV 0

F ∗fV 0

0F ∗f,j

Vj0 0

(2.13)

y = Cx (2.14)

C =[0 1 0

](2.15)

Simulation

The linear model is implemented in Simulink in a similar fashion as thenon-linear model, the block diagram is shown in Figure 2.1. This simu-lation utilizes a MATLAB S-function, lin_reactor_sfcn.m, shown inAppendix A.

CV

MV

DV

Tf increase

Caf increase time

To Workspace1

y

To Workspace

Clock

Scopelin_reactor_sfcn

S-Function: CSTR reactor with jacket system

Tf

Tf nominal

Caf

Caf nominal

Ffj increase

Ffj

Ffj nominal

Tfj increase

Tfj

Tfj nominal

Ff increase

Ff

Ff nominal

u1

To Workspace2

d1

To Workspace3

d2

To Workspace4

d3

To Workspace5

d4

To Workspace6

u

Figure 2.1: The Simulink block-diagram used to simulate the linear model.

Page 24: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

16 System Analysis

The simulation is run with the MATLAB script lin_step_change.mincluded in Appendix A. The results are compared in Figure 2.2, Figure 2.3,Figure 2.4, Figure 2.5 and Figure 2.6.

0 1 2 3 4 5 6 7 8 9 10

300

310

320

330

340

350

360

370

380

390

400

Step on Ff ,j

T[K

]

t [h]

Figure 2.2: Step changes in Ff,j corresponding temperature responses. Thenon-linear model is shown i red and the linearised model is shown in black.

Page 25: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

2.1. Linearisation of the model 17

0 1 2 3 4 5 6 7 8 9 10

300

310

320

330

340

350

360

370

380

390

400

Step on TfT

[K]

t [h]

Figure 2.3: Step changes in Tf corresponding temperature responses. Thenon-linear model is shown i red and the linearised model is shown in black.

Page 26: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

18 System Analysis

0 1 2 3 4 5 6 7 8 9 10

300

310

320

330

340

350

360

370

380

390

400

Step on Tf ,j

T[K

]

t [h]

Figure 2.4: Step changes in Tf,j corresponding temperature responses. Thenon-linear model is shown i red and the linearised model is shown in black.

Page 27: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

2.1. Linearisation of the model 19

0 1 2 3 4 5 6 7 8 9 10

300

310

320

330

340

350

360

370

380

390

400

Step on CA,fT

[K]

t [h]

Figure 2.5: Step changes in CA,f corresponding temperature responses. Thenon-linear model is shown i red and the linearised model is shown in black.

Page 28: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

20 System Analysis

0 1 2 3 4 5 6 7 8 9 10

300

310

320

330

340

350

360

370

380

390

400

Step on Ff

T[K

]

t [h]

Figure 2.6: Step changes in Ff corresponding temperature responses. Thenon-linear model is shown i red and the linearised model is shown in black.

2.2 Stability analysis

Laplace transform

L(x(t)) = L(Ax(t) + Bu(t) + Ed(t)) (2.16)

s · x(s) = Ax(s) + Bu(s) + Ed(s) (2.17)

Solving for xx(s) = (sI−A)−1 ·

(Bu(s) + Ed(s)

)(2.18)

It is assumed that the term (sI−A(s)) is invertible.

Transforming y into the Laplace domain:

L(y(t)) = L(Cx(t)

)(2.19)

y(s) = C · (sI−A)−1 ·(Bu(s) + Ed(s)

)(2.20)

Page 29: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

2.2. Stability analysis 21

Closed-loop transfer function

Because of instability in the equilibrium point of the model, the half rulewas not used. Instead a closed-loop transfer function with a P-controllerwith gain KC was used. The block-diagram of the closed loop is shown inFigure 2.7.

Figure 2.7: Block diagram of the closed loop.

From the block diagram of the closed loop above, this equation is ob-tained for the output, y:

y = (ys − y)KCG(s) + H(s)d(s) (2.21)

which yields:

y =ysKCG(s) + H(s)d(s)

1 +KCG(s)(2.22)

where G(s) is given by:

G(s) = C(sI−A)−1B (2.23)

and H(s) is:

H(s) = C(sI−A)−1E (2.24)

Thus the closed-loop transfer function from the input (manipulated variable,MV) to the output (controlled variable, CV) is:

Gcl(s) =KCG(s)

1 +KCG(s)(2.25)

Page 30: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

22 System Analysis

Analytical derivation of the stability criterion

Routh�Hurwitz stability criterion [3, p. 283] is used to calculate the intervalfor KC at which the linear system is stable. The calculations are done inMATLAB with routh.m, given in Appendix A. It produces this result:>> routh

KC =

(-215.1715142726898193359375, -0.19101925179711543023586273193359)

The stability criterion for the closed-loop linear system is therefore:

KC ∈ (−215.171, −0.191019) (2.26)

The open-loop linear system has the following zero:

z = −7.5836

and the poles are:

p =

−4.2014 + 1.4757j−4.2014− 1.4757j0.8631

The gain of the open-loop linear system is:

Gain = 5.2351

2.3 Discussion

Comparison of models

As it can be observed in Figure 2.2, Figure 2.3, Figure 2.4, Figure 2.5 andFigure 2.6, the linearised model �ts the original model well until a certainpoint where it goes unstable and rises/decreases towards positive/negativein�nity.

Stability

The zero does not a�ect the stability of the open-loop linear system. Thesystem has two poles in the left half-plane (LHP) and one in the right half-plane (RHP). A pole in the RHP indicates that the system is unstable [3,p. 340].

Page 31: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

Chapter 3

Controller Design

3.1 Contol Structure

Proportional-Integral Control

A proportional integral controller (PI-controller) on the temperature of thereactor is shown in 2.7. This structure was chosen because it was the onlyoption available, due to the fact that there is only one CV and one MV. Thecontroller is represented as:

CPI = KC

(1 +

τI

s

)(3.1)

Cascade Control

The proportional controller was modi�ed into a cascade controller as shownin Figure 3.1. The setpoint of the PID jacket temperature controller is set bya PID controller on the reactor temperature. This choice was done becauseFf,j has direct e�ect on Tj as can be observed in Equation (2.12). The PIDcontrollers can be written as:

CPID = KC

(1 +

τI

s+ τD

s

Tfs+ 1

)(3.2)

23

Page 32: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

24 Controller Design

time

tClock

Gj

y

T

u

Ffj

siso_cj

Cj

GT

Ts_step

setpoint

Ts

siso_c

C

Figure 3.1: Block diagram of the cascade structure.

3.2 Controller Tuning

Proportional-Integral Controller

The PI-controller was tuned by obtaining a �rst order approximation ofthe transfer function with Sham's method [4], and then tuning it using theSIMC-rules [4]. The tuning and step-change simulations are performed inp_tuning.m which is included in Appendix A.

Cascade Controllers

The inner-loop PID controller was tuned using the SISO Design GUI inMATLAB using automated tuning. The tuning parameters were set to yieldfast control. Sham's method was considered, but since it was impossible toobtain oscillations in the system, which rendered Sham's method unsuitable.The outher-loop PID controller was tuned in a similar manner, but the tun-ing parameters were set to give robust control. The tuning and step-changesimulations are performed in cascade_controller_step.m which is in-cluded in Appendix A.

Page 33: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

3.2. Controller Tuning 25

Tuning parameters

Table 3.1: Tuning parameters. KC is the controller gain, τI is the integraltime, τD is the derivative time and Tf is the �lter time constant

Controller KC τI τD Tf

PI-controller -1.8324 0.3414 − −Inner-loop PIDcontroller

-1.8423 7.2593 -0.0037 0.0037

Outer-loop PIDcontroller

23.2383 0.1612 -0.0140 0.0544

Page 34: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

26 Controller Design

3.3 Controller simulations

PI-controller

0 2 4 6 8 10310

320

330

340

Step change in setpoint

T s[K

]

t [h]

0 2 4 6 8 10−50

0

50

Ff,j

[m3/h

]

t [h]

Figure 3.2: Step change in setpoint for the single loop PI-controller. Thesetpoint is changed by 10 K.

3.4 Controller analysis

BODE GOES HERE IAE GOES HERE

Page 35: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

Bibliography

[1] S. Skogestad, Chemical and Energy Process Engineering. Taylor & Fran-cis Group, 2009.

[2] I. Chorkendor� and J. W. Niemantsverdriet, Concepts of Modern Catal-

ysis and Kinetics. Wiley, 2006.

[3] D. Seborg, D. Mellichamp, T. Edgar, and F. Doyle, Process Dynamics

and Control. John Wiley & Sons, 2010.

[4] M. Shamsuzzoha, S. Skogestad, and I. Halvorsen, �A simple approachfor on-line pi controller tuning using closed-loop setpoint responses,�20th European Symposium on Computer Aided Process Engineering �

ESCAPE20, 2010.

27

Page 36: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper
Page 37: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

Appendix A

MATLAB scripts

steadystate.m

1 %% Steady State2 % dC_A/dt = (C_A,in - C_A)q_f/V - r_A = 03 % dT/dt = q_f/V(T_f-T) - k0/(rho c_p)4 % *exp(-Ea/RT)*DrxH + UA/(V rho cp)(T_j-T) = 05 % dT_j/dt = q_f,j/V_j(T_f,j-T_j) + UA/6 % (V_j rho_j cp_j)(T-T_j) = 07

8 % paramters:9 p.Ea = 75500; %[kJ/kmol]

10 p.k0 = 16.96e12; %[1/h]11 p.DrxH = -89700; %[kJ/kmol]12 p.UA = 44000; %[kJ/K h]13 p.rhocp = 3570; ... %[kJ/m3 K]14 p.R = 8.3144621; %[kJ/kmol K]15 p.V = 14; %[m3]16 p.F = p.V/0.25; %[h]17 p.C_Af = 2; %[kmol/m3]18 p.T_f = 16 + 273.15; %[K]19 p.Vj = 0.25*p.V;20 p.T_jf = -17 + 273.15; %[K]21 p.rhojcpj = 3700; %[kJ/m3 K]22 p.T = 38 + 273.15; %[K]23

29

Page 38: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

30 MATLAB scripts

24 % Solution:25 X = fsolve(@SS,[p.C_Af 1 p.T_jf],optimset( ...26 ’Display’,’Off’),p);27

28 C_A = X(1); %[kmol/m3]29 F_j = X(2); %[m3/h]30 T_j = X(3); %[K]31

32 fprintf(’C_A = %f kmol/m3\n’,C_A)33 fprintf(’F_j = %f m3/h\n’,F_j)34 fprintf(’T_j = %f K\n’,T_j)

SS.m

1 function resid = SS(X,p)2 % Function for evaluating the3 % residuals in the steady state equations4 C_A = X(1); %[kmol/m]5 F_j = X(2); %[m^3/h]6 T_j = X(3); %[K]7 %% Parameters8 Ea = p.Ea; %[kJ/kmol]9 k0 = p.k0; %[1/h]10 DrxH = p.DrxH; %[kJ/kmol]11 UA = p.UA; %[kJ/K h]12 rhocp = p.rhocp; %[kJ/m^3 K]13 R = p.R; %[kJ/kmol K]14 V = p.V; %[m^3]15 F = p.F; %[h]16 C_Af = p.C_Af; %[kmol/m^3]17 T_f = p.T_f; %[K]18 Vj = p.Vj; %[m^3]19 T_jf = p.T_jf; %[K]20 rhojcpj = p.rhojcpj; %[kJ/m^3K]21 T = p.T; %[K]22 %% residuals23 dC_A = (C_Af - C_A)*F/V - ...24 k0*exp(-Ea/(R*T))*C_A;25 dT = (T_f - T)*F/V - ...26 k0*exp(-Ea/(R*T))* ...

Page 39: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

31

27 C_A/(rhocp)*DrxH + UA/(V*rhocp) ...28 * (T_j - T);29 dT_j = (T_jf - T_j)*F_j/Vj + ...30 UA/(Vj * rhojcpj) ...31 * (T - T_j);32

33 resid = [dC_A dT dT_j];34 end

steadystate_step.m

1 %% Steady State for a step in F_j2 % dC_A/dt = (C_A,in - C_A)q_f/V - r_A = 03 % dT/dt = q_f/V(T_f-T) - k0/(rho c_p)4 % *exp(-Ea/RT)*DrxH + UA/(V rho cp)(T_j-T) = 05 % dT_j/dt = q_f,j/V_j(T_f,j-T_j)6 % + UA/(V_j rho_j cp_j)(T-T_j) = 07

8 % paramters:9 p.Ea = 75500; %[kJ/kmol]

10 p.k0 = 16.96e12; %[1/h]11 p.DrxH = -89700; %[kJ/kmol]12 p.UA = 44000; %[kJ/K h]13 p.rhocp = 3570; %[kJ/m3 K]14 p.R = 8.3144621; %[kJ/kmol K]15 p.V = 14; %[m3]16 p.F = p.V/0.25; %[h]17 p.C_Af = 2; %[kmol/m3]18 p.T_f = 16 + 273.15; %[K]19 p.Vj = 0.25*p.V;20 p.T_jf = -17 + 273.15; %[K]21 p.rhojcpj = 3700; %[kJ/m3 K]22 p.F_j = 1.1*2.032484; %[m3/h]23

24 % Steady state temperature befor step change25 T0 = 38 + 273.15; %[K]26

27 % Solution:28 X = fsolve(@SS_step,[p.C_Af 295 p.T_jf], ...29 optimset(’Display’,’Off’),p);

Page 40: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

32 MATLAB scripts

30

31 C_A = X(1); %[kmol/m3]32 T = X(2); %[m3/h]33 T_j = X(3); %[K]34 fprintf(’Step change in F_j:\n’)35 fprintf(’C_A = %f kmol/m3\n’,C_A)36 fprintf(’T = %f K\n’,T)37 fprintf(’T_j = %f K\n\n’,T_j)38 fprintf(’Steady-state gain: %f K/(m3/h)\n\n’ ...39 ,(T-T0)/(p.F_j - p.F_j/1.1));40 %% Steady State for a step in T_f41

42 p.T_f = p.T_f*1.1;43 p.F_j = 2.032484;44

45

46 X = fsolve(@SS_step,[p.C_Af 360 p.T_jf], ...47 optimset(’Display’,’Off’),p);48

49 C_A = X(1); %[kmol/m3]50 T = X(2); %[m3/h]51 T_j = X(3); %[K]52 fprintf(’Step change in T_f:\n’)53 fprintf(’C_A = %f kmol/m3\n’,C_A)54 fprintf(’T = %f K\n’,T)55 fprintf(’T_j = %f K\n\n’,T_j)56 fprintf(’Steady-state gain: %f K/K\n\n’ ...57 ,(T-T0)/(p.T_f - p.T_f/1.1));58 %% Steady State for a step in T_jf59

60 p.T_f = p.T_f/1.1;61 p.T_jf = p.T_jf*1.1;62

63

64 X = fsolve(@SS_step,[p.C_Af 330 p.T_jf], ...65 optimset(’Display’,’Off’),p);66

67 C_A = X(1); %[kmol/m3]68 T = X(2); %[m3/h]69 T_j = X(3); %[K]

Page 41: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

33

70 fprintf(’Step change in T_jf:\n’)71 fprintf(’C_A = %f kmol/m3\n’,C_A)72 fprintf(’T = %f K\n’,T)73 fprintf(’T_j = %f K\n\n’,T_j)74 fprintf(’Steady-state gain: %f K/K\n\n’, ...75 (T-T0)/(p.T_jf - p.T_jf/1.1));76 %% Steady State for a step in C_Af77

78 p.T_jf = p.T_jf/1.1;79 p.C_Af = p.C_Af*1.1;80

81

82 X = fsolve(@SS_step,[p.C_Af 330 p.T_jf], ...83 optimset(’Display’,’Off’),p);84

85 C_A = X(1); %[kmol/m3]86 T = X(2); %[m3/h]87 T_j = X(3); %[K]88 fprintf(’Step change in C_Af:\n’)89 fprintf(’C_A = %f kmol/m3\n’,C_A)90 fprintf(’T = %f K\n’,T)91 fprintf(’T_j = %f K\n\n’,T_j)92 fprintf(’Steady-state gain: %f K/(kmol/m3)\n\n’...93 ,(T-T0)/(p.C_Af - p.C_Af/1.1));94

95 %% Steady State for a step in F96

97 p.C_Af = p.C_Af/1.1;98 p.F = p.F*1.1;99

100

101 X = fsolve(@SS_step,[p.C_Af 295 p.T_jf], ...102 optimset(’Display’,’Off’),p);103

104 C_A = X(1); %[kmol/m3]105 T = X(2); %[m3/h]106 T_j = X(3); %[K]107 fprintf(’Step change in F:\n’)108 fprintf(’C_A = %f kmol/m3\n’,C_A)109 fprintf(’T = %f K\n’,T)

Page 42: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

34 MATLAB scripts

110 fprintf(’T_j = %f K\n’,T_j)111

112 fprintf(’Steady-state gain: %f K/(m3/h)\n\n’, ...113 (T-T0)/(p.F - p.F/1.1));

SS_step.m

1 function resid = SS_step(X,p)2 % Function for evaluating the3 % residuals in the steady state equations4 C_A = X(1); %[kmol/m3]5 T = X(2); %[K]6 T_j = X(3); %[K]7 %% Parameters8 Ea = p.Ea; %[kJ/kmol]9 k0 = p.k0; %[1/h]10 DrxH = p.DrxH; %[kJ/kmol]11 UA = p.UA; %[kJ/K h]12 rhocp = p.rhocp; %[kJ/m3 K]13 R = p.R; %[kJ/kmol K]14 V = p.V; %[m3]15 F = p.F; %[h]16 C_Af = p.C_Af; %[kmol/m3]17 T_f = p.T_f; %[K]18 Vj = p.Vj; %[m3]19 T_jf = p.T_jf; %[K]20 rhojcpj = p.rhojcpj; %[kJ/m3 K]21 F_j = p.F_j; %[m3/h]22 %% residuals23 dC_A = (C_Af - C_A)*F/V ...24 - k0*exp(-Ea/(R*T))*C_A;25 dT = (T_f - T)*F/V - k0*exp(-Ea/(R*T)) ...26 *C_A/(rhocp)*DrxH + UA/(V*rhocp) ...27 * (T_j - T);28 dT_j = (T_jf - T_j)*F_j/Vj + UA/(Vj ...29 * rhojcpj) * (T - T_j);30

31 resid = [dC_A dT dT_j];32 end

Page 43: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

35

reactor_sfcn.m

1 function [sys,x0,str,ts] = reactor_sfcn(t,x,u,flag)2 switch flag3 case 0 %initialize4 str=[];5 ts = [0 0];6 s = simsizes;7 s.NumContStates = 3;8 s.NumDiscStates = 0;9 s.NumOutputs = 1;

10 s.NumInputs = 5;11 s.DirFeedthrough = 0;12 s.NumSampleTimes = 1;13 sys = simsizes(s) ;14 x0 = [1.054902; 311.1500; 303.214192];15 case 1 %derivatives16 sys = reactor(t,x,u) ;17 case 3 %output18 sys = x(2);19 case {2 4 9}20 %2:discrete21 %4:calcTimeHit22 %9:termination23 sys =[];24 otherwise25 error([’unhandled flag =’, ...26 num2str(flag)]) ;27 end28 end

reactor.m

1 function dx = reactor(t,x,u)2 %3 % Model for reactor4 %5 % States:6 Ca = x(1); %[kmol/m3]

Page 44: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

36 MATLAB scripts

7 T = x(2); %[K]8 Tj = x(3); %[K]9

10 % Inputs (and disturbances):11 Ffj = u(1); %[m3/h]12 Tf = u(2); %[K]13 Tfj = u(3); %[K]14 Ff = u(4); %[m3/h]15 Caf = u(5); %[kmol/m3]16

17

18 % Parameters:19 Ea = 75500; %[kJ/kmol]20 k0 = 16.96e12; %[1/h]21 DrxH = -89700; %[kJ/kmol]22 UA = 44000; %[kJ/K h]23 rhocp = 3570; %[kJ/m3 K]24 rhojcpj = 3700; %[kJ/m3 K]25 R = 8.314; %[kJ/kmol K]26 V = 14; %[m3]27 r = k0*exp(-Ea/(R*T))*Ca; %[kmol/m3 h]28 Vj = 0.25*V; %[m3]29

30 % Derivatives:31 dCa = (Ff/V)*(Caf-Ca) - r;32 dT = (Ff/V)*(Tf-T) - ...33 (DrxH)/(rhocp)*r + ...34 (UA)/(rhocp*V)*(Tj-T);35 dTj = (Ffj/Vj)*(Tfj-Tj) + ...36 (UA)/(rhojcpj*Vj)*(T-Tj);37 dx = [dCa;dT;dTj];38 end

step_change.m

1 %% Initializing2 warning off3 clc4 clear all5 close all

Page 45: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

37

6

7 % Nominal (steady-state) values8 Ffj = 2.005171; %Jacket feed [m3/h]9 Tf = 289.15; %Feed temperature [K]

10 Tfj = 256.15; %Jacket feed temperature [K]11 Caf = 2; %Feed concentration [kmol/m3]12 Ff = 56; %Feed [m3/h]13

14 % Steps15 Ffj_step = 0;16 Tf_step = 0;17 Tfj_step = 0;18 Caf_step = 0;19 Ff_step = 0;20

21 %% Steady state simulation (test)22 sim(’model.slx’)23

24 h = figure(1);25 hold on26 plot([0 10],[325.15 325.15],’k:’)27 plot(time,y,’k’,’LineWidth’,2);28 title(’Steady-state test’,’Interpreter’,’LaTeX’)29 ylabel(’$T\quad [\mathrm{K}]$’, ...30 ’Interpreter’,’LaTeX’)31 xlabel(’$t\quad [\mathrm{h}]$’, ...32 ’Interpreter’,’LaTeX’)33 ylim([295 370])34

35 export_fig(’Steady_state’,’-pdf’,’-transparent’)36 %% Step on Ffj37

38 Ffj_step = 0.1*Ffj;39

40 %run simulink model41 sim(’model.slx’)42

43 figure(2)44 subplot(221)45 plot(time,u1,’r’,’LineWidth’,2);

Page 46: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

38 MATLAB scripts

46 title(’Step change in $F_{\mathrm{f,j}}$’, ...47 ’Interpreter’,’LaTeX’)48 ylabel([’$F_{\mathrm{f,j}}\quad’ ...49 ’[\mathrm{m^3/h}]$’],’Interpreter’,’LaTeX’)50 xlabel(’$t\quad [\mathrm{h}]$’, ...51 ’Interpreter’,’LaTeX’)52 ylim([1.9 2.3])53

54 subplot(223)55 hold on56 plot([0 10],[325.15 325.15],’k:’)57 plot(time,y,’k’,’LineWidth’,2);58 title(’Step change in $F_{\mathrm{f,j}}$’ ...59 ,’Interpreter’,’LaTeX’)60 ylabel(’$T\quad [\mathrm{K}]$’, ...61 ’Interpreter’,’LaTeX’)62 xlabel(’$t\quad [\mathrm{h}]$’, ...63 ’Interpreter’,’LaTeX’)64 ylim([295 370])65

66

67 Ffj_step = 0;68

69 %% Step on Tf70 Tf_step = 0.1*Tf;71

72 %run simulink model73 sim(’model.slx’)74

75 figure(2)76 subplot(222)77 plot(time,d1,’r’,’LineWidth’,2);78 title(’Step change in $T_{\mathrm{f}}$’ ...79 ,’Interpreter’,’LaTeX’)80 ylabel(’$T_{\mathrm{f}}\quad [\mathrm{K}]$’ ...81 ,’Interpreter’,’LaTeX’)82 xlabel(’$t\quad [\mathrm{h}]$’,’Interpreter’ ...83 ,’LaTeX’)84 ylim([280 320])85

Page 47: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

39

86 subplot(224)87 hold on88 plot([0 10],[325.15 325.15],’k:’)89 plot(time,y,’k’,’LineWidth’,2);90 title(’Step change in $T_{\mathrm{f}}$’, ...91 ’Interpreter’,’LaTeX’)92 ylabel(’$T\quad [\mathrm{K}]$’, ...93 ’Interpreter’,’LaTeX’)94 xlabel(’$t\quad [\mathrm{h}]$’, ...95 ’Interpreter’,’LaTeX’)96 ylim([295 370])97

98 export_fig(’Ffj_Tf’,’-pdf’, ...99 ’-transparent’)100

101 Tf_step = 0;102

103 %% Step on Tfj104

105 Tfj_step = 0.1*Tfj;106

107 %run simulink model108 sim(’model.slx’)109

110 figure(3)111 subplot(221)112 plot(time,d2,’r’,’LineWidth’,2);113 title(’Step change in $T_{\mathrm{f,j}}$’, ...114 ’Interpreter’,’LaTeX’)115 ylabel(’$T_{\mathrm{f,j}}\quad [\mathrm{K}]$’, ...116 ’Interpreter’,’LaTeX’)117 xlabel(’$t\quad [\mathrm{h}]$’,’Interpreter’, ...118 ’LaTeX’)119 ylim([250 290])120

121 subplot(223)122 hold on123 plot([0 10],[325.15 325.15],’k:’)124 plot(time,y,’k’,’LineWidth’,2);125 title(’Step change in $T_{\mathrm{f,j}}$’, ...

Page 48: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

40 MATLAB scripts

126 ’Interpreter’,’LaTeX’)127 ylabel(’$T\quad [\mathrm{K}]$’, ...128 ’Interpreter’,’LaTeX’)129 xlabel(’$t\quad [\mathrm{h}]$’, ...130 ’Interpreter’,’LaTeX’)131 ylim([295 370])132

133

134 Tfj_step = 0;135

136 %% Step on Caf137 Caf_step = 0.1*Caf;138

139 %run simulink model140 sim(’model.slx’)141

142 figure(3)143 subplot(222)144 plot(time,d3,’r’,’LineWidth’,2);145 title(’Step change in $C_{\mathrm{A,f}}$’, ...146 ’Interpreter’,’LaTeX’)147 ylabel([’$C_{\mathrm{A,f}}\quad’ ...148 ’[\mathrm{kmol/m^3}]$’],’Interpreter’,’LaTeX’)149 xlabel(’$t\quad [\mathrm{h}]$’, ...150 ’Interpreter’,’LaTeX’)151 ylim([1.9 2.3])152

153 subplot(224)154 hold on155 plot([0 10],[325.15 325.15],’k:’)156 plot(time,y,’k’,’LineWidth’,2);157 title(’Step change in $C_{\mathrm{A,f}}$’, ...158 ’Interpreter’,’LaTeX’)159 ylabel(’$T\quad [\mathrm{K}]$’, ...160 ’Interpreter’,’LaTeX’)161 xlabel(’$t\quad [\mathrm{h}]$’, ...162 ’Interpreter’,’LaTeX’)163 ylim([295 370])164

165 export_fig(’Tfj_Caf’,’-pdf’,’-transparent’)

Page 49: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

41

166

167 Caf_step = 0;168

169 %% Step on Ff170 Ff_step = 0.1*Ff;171

172 %run simulink model173 sim(’model.slx’)174

175 figure(4)176 subplot(211)177 plot(time,d4,’r’,’LineWidth’,2);178 title(’Step change in $F_{\mathrm{f}}$’, ...179 ’Interpreter’,’LaTeX’)180 ylabel(’$F_{\mathrm{f}}\quad [\mathrm{m^3/h}]$’...181 ,’Interpreter’,’LaTeX’)182 xlabel(’$t\quad [\mathrm{h}]$’, ...183 ’Interpreter’,’LaTeX’)184 ylim([55 65])185

186 subplot(212)187 hold on188 plot([0 10],[325.15 325.15],’k:’)189 plot(time,y,’k’,’LineWidth’,2);190 title(’Step change in $F_{\mathrm{f}}$’, ...191 ’Interpreter’,’LaTeX’)192 ylabel(’$T\quad [\mathrm{K}]$’, ...193 ’Interpreter’,’LaTeX’)194 xlabel(’$t\quad [\mathrm{h}]$’, ...195 ’Interpreter’,’LaTeX’)196 ylim([295 370])197

198 export_fig(’Ff’,’-pdf’,’-transparent’)199

200 Ff_step = 0;

lin_reactor_sfcn.m

1 function [sys,x0,str,ts] = ...2 lin_reactor_sfcn(t,x,u,flag)

Page 50: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

42 MATLAB scripts

3 switch flag4 case 0 % initialize5 str=[];6 ts = [0 0];7 s = simsizes;8 s.NumContStates = 3;9 s.NumDiscStates = 0;10 s.NumOutputs = 1;11 s.NumInputs = 5;12 s.DirFeedthrough = 0;13 s.NumSampleTimes = 1;14 sys = simsizes(s) ;15 x0 = [1.054902; 311.1500; 303.214192];16 case 1 % derivatives17 sys = lin_reactor(t,x,u) ;18 case 3 % output19 sys = x(2);20 case {2 4 9} % 2:discrete 4:calcTimeHit21 % 9:termination22 sys =[];23 otherwise24 error([’unhandled flag =’, ...25 num2str(flag)]) ;26 end27 end

lin_reactor.m

1 function dx = lin_reactor(~,x,u)2 %3 % Model for reactor4 %5 % States:6 Ca = x(1); %[kmol/m3]7 T = x(2); %[K]8 Tj = x(3); %[K]9 % Inputs (and disturbances):10 Ffj = u(1); %[m3/h]11 Tf = u(2); %[K]12 Tfj = u(3); %[K]

Page 51: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

43

13 Ff = u(4); %[m3/h]14 Caf = u(5); %[kmol/m3]15

16

17 % Parameters:18 Ea = 75500; %[kJ/kmol]19 k0 = 16.96e12 ; %[1/h]20 DrxH = -89700; %[kJ/kmol]21 UA = 44000; %[kJ/K h]22 rhocp = 3570; %[kJ/m3 K]23 rhojcpj = 3700; %[kJ/m3 K]24 R = 8.314; %[kJ/kmol K]25 V = 14; %[m3]26 Vj = 0.25*V; %[m3]27

28 % Steady-state (nominal) values29 Ca_ss = 1.054094;30 T_ss = 311.1500;31 Tj_ss = 303.121877;32 Ffj_ss = 2.032484;33 Ff_ss = 14/0.25;34 Caf_ss = 2;35 Tf_ss = 16 + 273.15;36 Tfj_ss = -17 + 273.15;37

38

39 % Derivatives:40 dCa = -Ca_ss*k0*Ea*exp(-Ea/(R* ...41 T_ss))/(R*T_ss^2)*(T-T_ss) + ...42 (Caf_ss - Ca_ss)/V*(Ff-Ff_ss) + ...43 (-k0*exp(-Ea/(R* ...44 T_ss)) - Ff_ss/V)*(Ca-Ca_ss) + ...45 Ff_ss/V*(Caf-Caf_ss);46 dT = (-Ff_ss/V - UA/(V*rhocp) - ...47 DrxH*Ca_ss*k0*Ea*exp(-Ea/(R* ...48 T_ss))/(rhocp*R*T_ss^2))*(T-T_ss)...49 +(Tf_ss-T_ss)/V*(Ff-Ff_ss) ...50 + Ff_ss/V*(Tf-Tf_ss) - ...51 DrxH*k0*exp(-Ea/(R*T_ss))/rhocp* ...52 (Ca-Ca_ss) + ...

Page 52: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

44 MATLAB scripts

53 UA/(V*rhocp)*(Tj-Tj_ss);54 dTj = UA/(Vj*rhojcpj)*(T-T_ss) + ...55 (-UA/(Vj*rhojcpj) ...56 - Ffj_ss/Vj)*(Tj-Tj_ss) + ...57 Ffj_ss/Vj*(Tfj-Tfj_ss) + (Tfj_ss ...58 - Tj_ss)/Vj*(Ffj-Ffj_ss);59 dx = [dCa;dT;dTj];60 end

lin_step_change.m

1 %% Initializing2 warning off3 clc4 clear all5 close all6

7 % Nominal (steady-state) values8 Ffj = 2.005171; %Jacket feed [m3/h]9 Tf = 289.15; %Feed temperature [K]10 Tfj = 256.15; %Jacket feed temperature [K]11 Caf = 2; %Feed concentration [kmol/m3]12 Ff = 56; %Feed [m3/h]13

14 % Steps15 Ffj_step = 0;16 Tf_step = 0;17 Tfj_step = 0;18 Caf_step = 0;19 Ff_step = 0;20

21 %% Steady state simulation (test)22 sim(’lin_model.slx’)23

24 h = figure(1);25 hold on26 plot([0 10],[325.15 325.15],’k:’)27 plot(time,y,’k’,’LineWidth’,2);28

29 sim(’model.slx’)

Page 53: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

45

30 plot(time,y,’r’,’LineWidth’,2);31

32 title(’Steady-state test’, ...33 ’Interpreter’,’LaTeX’)34 ylabel(’$T\quad [\mathrm{K}]$’, ...35 ’Interpreter’,’LaTeX’)36 xlabel(’$t\quad [\mathrm{h}]$’, ...37 ’Interpreter’,’LaTeX’)38

39 ylim([295 400])40

41 export_fig(’TEST’,’-pdf’,’-transparent’)42

43 %% Step on Ffj44

45 Ffj_step = 0.1*Ffj;46

47 %run simulink model48 sim(’lin_model.slx’)49

50 figure(2)51 hold on52 plot([0 10],[325.15 325.15],’k:’)53 plot(time,y,’k’,’LineWidth’,2);54

55 sim(’model.slx’)56 plot(time,y,’r’,’LineWidth’,2);57

58 title(’Step on $F_{\mathrm{f,j}}$’, ...59 ’Interpreter’,’LaTeX’)60 ylabel(’$T\quad [\mathrm{K}]$’, ...61 ’Interpreter’,’LaTeX’)62 xlabel(’$t\quad [\mathrm{h}]$’, ...63 ’Interpreter’,’LaTeX’)64

65 ylim([295 400])66

67 export_fig(’compare1’,’-pdf’,’-transparent’)68

69

Page 54: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

46 MATLAB scripts

70 Ffj_step = 0;71

72 %% Step on Tf73 Tf_step = 0.1*Tf;74

75 %run simulink model76 sim(’lin_model.slx’)77

78 figure(3)79 hold on80 plot([0 10],[325.15 325.15],’k:’)81 plot(time,y,’k’,’LineWidth’,2);82

83 sim(’model.slx’)84 plot(time,y,’r’,’LineWidth’,2);85

86 title(’Step on $T_{\mathrm{f}}$’,’Interpreter’ ...87 ,’LaTeX’)88 ylabel(’$T\quad [\mathrm{K}]$’,’Interpreter’ ...89 ,’LaTeX’)90 xlabel(’$t\quad [\mathrm{h}]$’,’Interpreter’ ...91 ,’LaTeX’)92

93 ylim([295 400])94

95 export_fig(’compare2’,’-pdf’,’-transparent’)96

97 Tf_step = 0;98

99 %% Step on Tfj100

101 Tfj_step = 0.1*Tfj;102

103 %run simulink model104 sim(’lin_model.slx’)105

106 figure(4)107 hold on108 plot([0 10],[325.15 325.15],’k:’)109 plot(time,y,’k’,’LineWidth’,2);

Page 55: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

47

110

111 sim(’model.slx’)112 plot(time,y,’r’,’LineWidth’,2);113

114 title(’Step on $T_{\mathrm{f,j}}$’, ...115 ’Interpreter’,’LaTeX’)116 ylabel(’$T\quad [\mathrm{K}]$’, ...117 ’Interpreter’,’LaTeX’)118 xlabel(’$t\quad [\mathrm{h}]$’, ...119 ’Interpreter’,’LaTeX’)120

121 ylim([295 400])122

123 export_fig(’compare3’,’-pdf’,’-transparent’)124

125

126 Tfj_step = 0;127

128 %% Step on Caf129 Caf_step = 0.1*Caf;130

131 %run simulink model132 sim(’lin_model.slx’)133

134 figure(5)135 hold on136 plot([0 10],[325.15 325.15],’k:’)137 plot(time,y,’k’,’LineWidth’,2);138

139 sim(’model.slx’)140 plot(time,y,’r’,’LineWidth’,2);141

142 title(’Step on $C_{\mathrm{A,f}}$’, ...143 ’Interpreter’,’LaTeX’)144 ylabel(’$T\quad [\mathrm{K}]$’, ...145 ’Interpreter’,’LaTeX’)146 xlabel(’$t\quad [\mathrm{h}]$’, ...147 ’Interpreter’,’LaTeX’)148

149 ylim([295 400])

Page 56: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

48 MATLAB scripts

150

151 export_fig(’compare4’,’-pdf’,’-transparent’)152

153 Caf_step = 0;154

155 %% Step on Ff156 Ff_step = 0.1*Ff;157

158 %run simulink model159 sim(’lin_model.slx’)160

161 figure(6)162 hold on163 plot([0 10],[325.15 325.15],’k:’)164 plot(time,y,’k’,’LineWidth’,2);165

166 sim(’model.slx’)167 plot(time,y,’r’,’LineWidth’,2);168

169 title(’Step on $F_{\mathrm{f}}$’, ...170 ’Interpreter’,’LaTeX’)171 ylabel(’$T\quad [\mathrm{K}]$’, ...172 ’Interpreter’,’LaTeX’)173 xlabel(’$t\quad [\mathrm{h}]$’, ...174 ’Interpreter’,’LaTeX’)175

176 ylim([295 400])177

178 export_fig(’compare5’,’-pdf’,’-transparent’)179

180 Ff_step = 0;181

182 %%183 close all

routh.m

1 clear all2 %% Routh-Hurwitz stability criterion3 % Parameters:

Page 57: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

49

4 Ea = 75500; %[kJ/kmol]5 k0 = 16.96e12 ; %[1/h]6 Hrx = -89700; %[kJ/kmol]7 UA = 44000; %[kJ/K h]8 rhocp = 3570; %[kJ/m3 K]9 rhocpj = 3700; %[kJ/m3 K]

10 R = 8.314; %[kJ/kmol K]11 V = 14; %[m3]12 Vj = 0.25*V; %[m3]13

14 % Steady-state (nominal) values15 CA = 1.054094;16 T = 311.1500;17 Tj = 303.121877;18 Ffj = 2.032484;19 Ff = 14/0.25;20 CAf= 2;21 Tf = 16 + 273.15;22 Tfj = -17 + 273.15;23 % Defining the vector B24 B1 = 0;25 B2 = 0;26 B3 = (Tfj-Tj)/Vj;27 B = [B1;B2;B3];28 % Defining the matrix A29 A11 = -k0*exp(-Ea/(R*T)) - Ff/V;30 A12 = -CA*k0*Ea*exp(-Ea/(R*T))/(R*T^2);31 A13 = 0;32 A21 = -Hrx*k0*exp(-Ea/(R*T))/rhocp;33 A22 = -Ff/V - UA/(V*rhocp) - ...34 (Hrx*k0*CA*Ea*exp(-Ea/(R*T)))/(rhocp*R*T^2);35 A23 = UA/(V*rhocp);36 A31 = 0;37 A32 = UA/(Vj*rhocpj);38 A33 = - UA/(Vj*rhocpj) - Ffj/Vj;39 A = [A11,A12,A13;A21,A22,A23;A31,A32,A33];40 % Defining the vector C41 C = [0 1 0];42

43 syms s KC

Page 58: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

50 MATLAB scripts

44 % Calculating G45 G = C*inv(s*eye(3)-A)*B;46 Gj = [0 0 1]*inv(s*eye(3)-A)*B;47 G = simplify(G);48 % Introducing the denominator in the49 % closed-loop transfer function50 polynomial = 1 + G*KC;51 polynomial = simplify(polynomial);52 % Collecting each coefficient53 % (multiplied by -1 so that a3 > 0)54 p = collect(polynomial);55 % Splitting the polynomial into a denominator56 % and a numerator57 [n, d] = numden(p);58 % Extracting the coefficients of the numerator59 coeff = fliplr(coeffs(n,s));60 Array = rharray(coeff);61 % Display the resulting interval for KC62 fprintf(’KC = ’)63 pretty(vpa(solve([Array(3,1)>0,Array(4,1)>0]),2));64 %% Calculate the zeroes and poles65 s = tf(’s’);66 G = C*inv(s*eye(3)-A)*B;67 zeros = zero(G)68 poles = pole(G)69 %% Calculate the gain70 G0 = evalfr(G,0)

rharray.m

1 function array = rharray(coeff)2 n = length(coeff);3 array = zeros(length(coeff),length(coeff)+2);4 array = sym(array);5 if mod(length(coeff),2) ~= 06 coeff(end+1) = 0;7 end8 for i = 1:ceil(length(coeff)/2);9 array(1,i) = coeff(2*i-1);10 array(2,i) = coeff(2*i);

Page 59: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

51

11 end12 for row = 3:n13 for i = 1:ceil(length(coeff/2));14 array(row,i) = ...15 (array(row-1,1)*array(row-2,i+1) - ...16 array(row-2,1)*array(row-1,i+1))/ ...17 array(row-1,1);18 end19 end20 array=collect(array);21 end

p_tuning.m

1 %% Initializing2 warning off3 clc4 clear all5 close all6

7 % Nominal (steady-state) values8 Ffj = 2.005171; %Jacket feed [m3/h]9 Tf = 289.15; %Feed temperature [K]

10 Tfj = 256.15; %Jacket feed temperature [K]11 Caf = 2; %Feed concentration [kmol/m3]12 Ff = 56; %Feed [m3/h]13 Tj = 303.121877; %Jacket temperature [K]14

15 % Steps16 Ffj_step = 0; %[m3/h]17 Tf_step = 0; %[K]18 Tfj_step = 0; %[K]19 Caf_step = 0; %[kmol/m3]20 Ff_step = 0; %[m3/h]21 Ts = 38 + 273.15; %[K]22

23 %% Step on setpoint for Shams’ method24 KC = -8;%Guess on KC that yields oscillations25 tauI = 0;26 Ts_step = -0.01*Ts;

Page 60: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

52 MATLAB scripts

27

28 %run simulink model29 sim(’p_controller.slx’)30

31 figure(1);32 subplot(211)33 hold on34 plot([0; time],[Ts; setpoint],’r’,’LineWidth’,2);35 plot([0 10],[325.15 325.15],’k:’)36 plot(time,y,’k’,’LineWidth’,2);37 title(’Step change in setpoint’, ...38 ’Interpreter’,’LaTeX’)39 ylabel(’$T_{\mathrm{s}}\quad [\mathrm{K}]$’, ...40 ’Interpreter’,’LaTeX’)41 xlabel(’$t\quad [\mathrm{h}]$’, ...42 ’Interpreter’,’LaTeX’)43

44 subplot(212)45 plot(time,u,’b’,’LineWidth’,2);46 ylabel([’$F_{\mathrm{f,j}}\quad’ ...47 ’[\mathrm{m^3/h}]$’], ...48 ’Interpreter’,’LaTeX’)49 xlabel(’$t\quad [\mathrm{h}]$’, ...50 ’Interpreter’,’LaTeX’)51

52 %% Shams’ method53 % [Height of peak, Index of peak]:54 [dyp, tpIndex] = min(y);55 dyp = dyp - y(1);56 tp = time(tpIndex); %Time of peak57 % Height of undershoot:58 dyu = max(y(tpIndex:end)) - y(1);59 %Estimation of steady state gain:60 dy = 0.45*(dyp + dyu);61 % Parameters:62 D = (dyp - dy)/dy;63 B = (Ts_step - dyp);64 A = 1.152*D^2 - 1.607*D + 1;65 r = 2*A/B;66 % First order + time-delay model:

Page 61: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

53

67 % k*exp(-theta*s)/(tau1*s+1)68 k = 1/(KC*B);69 theta = tp*(0.309 + 0.209*exp(-0.61*r));70 tau1 = r*theta;71 % SIMC rules:72 tauc = theta;73 KC = 1/k * tau1/(tauc+theta);74 tauI = min(tau1,4*(tauc+theta));75

76 %% Step on setpoint77 Ts_step = 10;78

79 sim(’p_controller.slx’)80

81 figure(2);82 subplot(211)83 hold on84 plot([0; time],[Ts; setpoint],’r’,’LineWidth’,2);85 plot([0 10],[325.15 325.15],’k:’)86 plot(time,y,’k’,’LineWidth’,2);87 title(’Step change in setpoint’, ...88 ’Interpreter’,’LaTeX’)89 ylabel(’$T_{\mathrm{s}}\quad [\mathrm{K}]$’, ...90 ’Interpreter’,’LaTeX’)91 xlabel(’$t\quad [\mathrm{h}]$’, ...92 ’Interpreter’,’LaTeX’)93 xlim([0 10])94 subplot(212)95 plot(time,u,’b’,’LineWidth’,2);96 ylabel([’$F_{\mathrm{f,j}}\quad’ ...97 ’[\mathrm{m^3/h}]$’], ...98 ’Interpreter’,’LaTeX’)99 xlabel(’$t\quad [\mathrm{h}]$’, ...100 ’Interpreter’,’LaTeX’)101

102 export_fig(’Ts_step_p’,’-pdf’,’-transparent’);103

104 Ts_step = 0;105

106 fprintf([’IAE for a step change in setpoint: ’ ...

Page 62: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

54 MATLAB scripts

107 ’%f\n’],e(end));108

109 %% Step on Tf110 Tf_step = 10;111

112 %run simulink model113 sim(’p_controller.slx’)114

115 h = figure(3);116 subplot(321)117 plot(time,d1,’r’,’LineWidth’,2);118 title(’Step change in $T_{\mathrm{f}}$’, ...119 ’Interpreter’,’LaTeX’)120 ylabel(’$T_{\mathrm{f}}\quad [\mathrm{K}]$’, ...121 ’Interpreter’,’LaTeX’)122 xlabel(’$t\quad [\mathrm{h}]$’, ...123 ’Interpreter’,’LaTeX’)124

125 subplot(323)126 hold on127 plot([0 10],[325.15 325.15],’k:’)128 plot(time,y,’k’,’LineWidth’,2);129 title(’Step change in $T_{\mathrm{f}}$’, ...130 ’Interpreter’,’LaTeX’)131 ylabel(’$T\quad [\mathrm{K}]$’, ...132 ’Interpreter’,’LaTeX’)133 xlabel(’$t\quad [\mathrm{h}]$’, ...134 ’Interpreter’,’LaTeX’)135

136 subplot(325)137 plot(time,u,’b’,’LineWidth’,2);138 ylabel([’$F_{\mathrm{f,j}}\quad’ ...139 ’[\mathrm{m^3/h}]$’], ...140 ’Interpreter’,’LaTeX’)141 xlabel(’$t\quad [\mathrm{h}]$’, ...142 ’Interpreter’,’LaTeX’)143

144 Tf_step = 0;145

146 fprintf([’IAE for a step change in feed ’ ...

Page 63: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

55

147 ’temperature: %f\n’],e(end));148

149 %% Step on Tfj150

151 Tfj_step = 0.1*Tfj;152

153 %run simulink model154 sim(’p_controller.slx’)155

156 subplot(322)157 plot(time,d2,’r’,’LineWidth’,2);158 title(’Step change in $T_{\mathrm{f,j}}$’, ...159 ’Interpreter’,’LaTeX’)160 ylabel(’$T_{\mathrm{f,j}}\quad [\mathrm{K}]$’, ...161 ’Interpreter’,’LaTeX’)162 xlabel(’$t\quad [\mathrm{h}]$’, ...163 ’Interpreter’,’LaTeX’)164

165 subplot(324)166 hold on167 plot([0 10],[325.15 325.15],’k:’)168 plot(time,y,’k’,’LineWidth’,2);169 title(’Step change in $T_{\mathrm{f,j}}$’, ...170 ’Interpreter’,’LaTeX’)171 ylabel(’$T\quad [\mathrm{K}]$’, ...172 ’Interpreter’,’LaTeX’)173 xlabel(’$t\quad [\mathrm{h}]$’, ...174 ’Interpreter’,’LaTeX’)175

176 subplot(326)177 plot(time,u,’b’,’LineWidth’,2);178 ylabel([’$F_{\mathrm{f,j}}\quad’ ...179 ’[\mathrm{m^3/h}]$’], ...180 ’Interpreter’,’LaTeX’)181 xlabel(’$t\quad [\mathrm{h}]$’, ...182 ’Interpreter’,’LaTeX’)183

184 set(h, ’Position’, [400 400 700 800])185

186 export_fig(’Tf_Tfj_step_p’,’-pdf’,’-transparent’);

Page 64: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

56 MATLAB scripts

187

188 Tfj_step = 0;189

190 fprintf([’IAE for a step change in jacket feed’...191 ’temperature: %f\n’],e(end));192

193 %% Step on Caf194 Caf_step = 0.1*Caf;195

196 %run simulink model197 sim(’p_controller.slx’)198

199 h = figure(4);200 subplot(321)201 plot(time,d3,’r’,’LineWidth’,2);202 title(’Step change in $C_{\mathrm{A,f}}$’, ...203 ’Interpreter’,’LaTeX’)204 ylabel([’$C_{\mathrm{A,f}}\quad’ ...205 ’[\mathrm{kmol/m^3}]$’], ...206 ’Interpreter’,’LaTeX’)207 xlabel(’$t\quad [\mathrm{h}]$’, ...208 ’Interpreter’,’LaTeX’)209

210 subplot(323)211 hold on212 plot([0 10],[325.15 325.15],’k:’)213 plot(time,y,’k’,’LineWidth’,2);214 title(’Step change in $C_{\mathrm{A,f}}$’, ...215 ’Interpreter’,’LaTeX’)216 ylabel(’$T\quad [\mathrm{K}]$’, ...217 ’Interpreter’,’LaTeX’)218 xlabel(’$t\quad [\mathrm{h}]$’, ...219 ’Interpreter’,’LaTeX’)220

221 subplot(325)222 plot(time,u,’b’,’LineWidth’,2);223 ylabel([’$F_{\mathrm{f,j}}\quad’ ...224 ’[\mathrm{m^3/h}]$’], ...225 ’Interpreter’,’LaTeX’)226 xlabel(’$t\quad [\mathrm{h}]$’, ...

Page 65: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

57

227 ’Interpreter’,’LaTeX’)228

229 Caf_step = 0;230

231 fprintf([’IAE for a step change in feed ’ ...232 ’concentration: %f\n’],e(end));233

234 %% Step on Ff235 Ff_step = 0.1*Ff;236

237 %run simulink model238 sim(’p_controller.slx’)239

240 subplot(322)241 plot(time,d4,’r’,’LineWidth’,2);242 title(’Step change in $F_{\mathrm{f}}$’, ...243 ’Interpreter’,’LaTeX’)244 ylabel(’$F_{\mathrm{f}}\quad [\mathrm{m^3/h}]$’,...245 ’Interpreter’,’LaTeX’)246 xlabel(’$t\quad [\mathrm{h}]$’, ...247 ’Interpreter’,’LaTeX’)248

249 subplot(324)250 hold on251 plot([0 10],[325.15 325.15],’k:’)252 plot(time,y,’k’,’LineWidth’,2);253 title(’Step change in $F_{\mathrm{f}}$’, ...254 ’Interpreter’,’LaTeX’)255 ylabel(’$T\quad [\mathrm{K}]$’, ...256 ’Interpreter’,’LaTeX’)257 xlabel(’$t\quad [\mathrm{h}]$’, ...258 ’Interpreter’,’LaTeX’)259

260 subplot(326)261 plot(time,u,’b’,’LineWidth’,2);262 ylabel([’$F_{\mathrm{f,j}}\quad’ ...263 ’[\mathrm{m^3/h}]$’], ...264 ’Interpreter’,’LaTeX’)265 xlabel(’$t\quad [\mathrm{h}]$’, ...266 ’Interpreter’,’LaTeX’)

Page 66: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

58 MATLAB scripts

267

268 set(h, ’Position’, [400 400 700 800])269

270 export_fig(’CAf_Ff_step_p’,’-pdf’,’-transparent’)271

272 Ff_step = 0;273

274 fprintf([’IAE for a step change in feed rate:’ ...275 ’%f\n’],e(end));

cascade_controller_step.m

1 %% Initializing2 warning off3 clc4 clear all5 close all6

7 % Nominal (steady-state) values8 Ffj = 2.005171; %Jacket feed [m3/h]9 Tf = 289.15; %Feed temperature [K]10 Tfj = 256.15; %Jacket feed temperature [K]11 Caf = 2; %Feed concentration [kmol/m3]12 Ff = 56; %Feed [m3/h]13 Tj = 303.121877; %Jacket temperature [K]14

15 % Steps16 Ffj_step = 0; %[m3/h]17 Tf_step = 0; %[K]18 Tfj_step = 0; %[K]19 Caf_step = 0; %[kmol/m3]20 Ff_step = 0; %[m3/h]21 Ts = 38 + 273.15; %[K]22 % Load the controllers23 load(’jacket_controller.mat’);24 load(’temp_controller.mat’);25 %% Step on setpoint26

27 Ts_step = 10;28

Page 67: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

59

29 %run simulink model30 sim(’cascade.slx’)31

32 h = figure(1);33 subplot(211)34 hold on35 plot(time,setpoint,’r’,’LineWidth’,2);36 plot([0 10],[325.15 325.15],’k:’)37 plot(time,y,’k’,’LineWidth’,2);38 title(’Step change in setpoint’, ...39 ’Interpreter’,’LaTeX’)40 ylabel([’$T_{\mathrm{s}},\quad T\quad’ ...41 ’[\mathrm{K}]$’],’Interpreter’,’LaTeX’)42 xlabel(’$t\quad [\mathrm{h}]$’, ...43 ’Interpreter’,’LaTeX’)44

45 subplot(212)46 plot(time,u,’b’,’LineWidth’,2);47 ylabel([’$F_{\mathrm{f,j}}\quad’ ...48 ’[\mathrm{m^3/h}]$’], ...49 ’Interpreter’,’LaTeX’)50 xlabel(’$t\quad [\mathrm{h}]$’, ...51 ’Interpreter’,’LaTeX’)52

53 export_fig(’Ts_step_cascade’,...54 ’-pdf’,’-transparent’);55

56 Ts_step = 0;57

58 fprintf([’IAE for a step change in setpoint: ’ ...59 ’%f\n’],e(end));60 %% Step on Tf61 Tf_step = 0.1*Tf;62

63 %run simulink model64 sim(’cascade.slx’)65

66 h = figure(2);67 subplot(321)68 plot(time,d1,’r’,’LineWidth’,2);

Page 68: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

60 MATLAB scripts

69 title(’Step change in $T_{\mathrm{f}}$’, ...70 ’Interpreter’,’LaTeX’)71 ylabel(’$T_{\mathrm{f}}\quad [\mathrm{K}]$’, ...72 ’Interpreter’,’LaTeX’)73 xlabel(’$t\quad [\mathrm{h}]$’, ...74 ’Interpreter’,’LaTeX’)75

76 subplot(323)77 hold on78 plot([0 10],[325.15 325.15],’k:’)79 plot(time,y,’k’,’LineWidth’,2);80 title(’Step change in $T_{\mathrm{f}}$’, ...81 ’Interpreter’,’LaTeX’)82 ylabel(’$T\quad [\mathrm{K}]$’, ...83 ’Interpreter’,’LaTeX’)84 xlabel(’$t\quad [\mathrm{h}]$’, ...85 ’Interpreter’,’LaTeX’)86

87 subplot(325)88 plot(time,u,’b’,’LineWidth’,2);89 ylabel([’$F_{\mathrm{f,j}}\quad’ ...90 ’[\mathrm{m^3/h}]$’], ...91 ’Interpreter’,’LaTeX’)92 xlabel(’$t\quad [\mathrm{h}]$’, ...93 ’Interpreter’,’LaTeX’)94

95 Tf_step = 0;96

97 fprintf([’IAE for a step change in feed ’ ...98 ’temperature: %f\n’],e(end));99

100 %% Step on Tfj101

102 Tfj_step = 0.1*Tfj;103

104 %run simulink model105 sim(’cascade.slx’)106

107 subplot(322)108 plot(time,d2,’r’,’LineWidth’,2);

Page 69: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

61

109 title(’Step change in $T_{\mathrm{f,j}}$’, ...110 ’Interpreter’,’LaTeX’)111 ylabel(’$T_{\mathrm{f,j}}\quad [\mathrm{K}]$’, ...112 ’Interpreter’,’LaTeX’)113 xlabel(’$t\quad [\mathrm{h}]$’, ...114 ’Interpreter’,’LaTeX’)115

116 subplot(324)117 hold on118 plot([0 10],[325.15 325.15],’k:’)119 plot(time,y,’k’,’LineWidth’,2);120 title(’Step change in $T_{\mathrm{f,j}}$’, ...121 ’Interpreter’,’LaTeX’)122 ylabel(’$T\quad [\mathrm{K}]$’, ...123 ’Interpreter’,’LaTeX’)124 xlabel(’$t\quad [\mathrm{h}]$’, ...125 ’Interpreter’,’LaTeX’)126

127 subplot(326)128 plot(time,u,’b’,’LineWidth’,2);129 ylabel([’$F_{\mathrm{f,j}}\quad’ ...130 ’[\mathrm{m^3/h}]$’], ...131 ’Interpreter’,’LaTeX’)132 xlabel(’$t\quad [\mathrm{h}]$’, ...133 ’Interpreter’,’LaTeX’)134

135 set(h, ’Position’, [400 400 700 800])136

137 export_fig(’Tf_Tfj_step_cascade’,...138 ’-pdf’,’-transparent’);139

140 Tfj_step = 0;141

142 fprintf([’IAE for a step change in jacket feed’...143 ’temperature: %f\n’],e(end));144 %% Step on Caf145 Caf_step = 0.1*Caf;146

147 %run simulink model148 sim(’cascade.slx’)

Page 70: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

62 MATLAB scripts

149

150 h = figure(3);151 subplot(321)152 plot(time,d3,’r’,’LineWidth’,2);153 title(’Step change in $C_{\mathrm{A,f}}$’, ...154 ’Interpreter’,’LaTeX’)155 ylabel([’$C_{\mathrm{A,f}}\quad’ ...156 ’[\mathrm{kmol/m^3}]$’], ...157 ’Interpreter’,’LaTeX’)158 xlabel(’$t\quad [\mathrm{h}]$’, ...159 ’Interpreter’,’LaTeX’)160

161 subplot(323)162 hold on163 plot([0 10],[325.15 325.15],’k:’)164 plot(time,y,’k’,’LineWidth’,2);165 title(’Step change in $C_{\mathrm{A,f}}$’, ...166 ’Interpreter’,’LaTeX’)167 ylabel(’$T\quad [\mathrm{K}]$’, ...168 ’Interpreter’,’LaTeX’)169 xlabel(’$t\quad [\mathrm{h}]$’, ...170 ’Interpreter’,’LaTeX’)171

172 subplot(325)173 plot(time,u,’b’,’LineWidth’,2);174 ylabel([’$F_{\mathrm{f,j}}\quad’ ...175 ’[\mathrm{m^3/h}]$’], ...176 ’Interpreter’,’LaTeX’)177 xlabel(’$t\quad [\mathrm{h}]$’, ...178 ’Interpreter’,’LaTeX’)179

180 Caf_step = 0;181

182 fprintf([’IAE for a step change in feed’ ...183 ’concentration: %f\n’],e(end));184

185 %% Step on Ff186 Ff_step = 0.1*Ff;187

188 %run simulink model

Page 71: Control Project R: CSTR Reactor With Cooling Jacket Dynamicsfolk.ntnu.no/andersty/4. Klasse/TKP4140 - Prosessregulering/project... · Anders Leirpoll Adriaen erheylewV eghen Kasper

63

189 sim(’cascade.slx’)190

191 subplot(322)192 plot(time,d4,’r’,’LineWidth’,2);193 title(’Step change in $F_{\mathrm{f}}$’, ...194 ’Interpreter’,’LaTeX’)195 ylabel([’$F_{\mathrm{f}}\quad’ ...196 ’[\mathrm{m^3/h}]$’], ...197 ’Interpreter’,’LaTeX’)198 xlabel(’$t\quad [\mathrm{h}]$’, ...199 ’Interpreter’,’LaTeX’)200

201 subplot(324)202 hold on203 plot([0 10],[325.15 325.15],’k:’)204 plot(time,y,’k’,’LineWidth’,2);205 title(’Step change in $F_{\mathrm{f}}$’, ...206 ’Interpreter’,’LaTeX’)207 ylabel(’$T\quad [\mathrm{K}]$’, ...208 ’Interpreter’,’LaTeX’)209 xlabel(’$t\quad [\mathrm{h}]$’, ...210 ’Interpreter’,’LaTeX’)211

212 subplot(326)213 plot(time,u,’b’,’LineWidth’,2);214 ylabel([’$F_{\mathrm{f,j}}\quad’ ...215 ’[\mathrm{m^3/h}]$’], ...216 ’Interpreter’,’LaTeX’)217 xlabel(’$t\quad [\mathrm{h}]$’, ...218 ’Interpreter’,’LaTeX’)219

220 set(h, ’Position’, [400 400 700 800])221

222 export_fig(’Caf_Ff_step_cascade’,...223 ’-pdf’,’-transparent’)224

225 Ff_step = 0;226

227 fprintf([’IAE for a step change in feed rate:’ ...228 ’%f\n’],e(end));