1 | #*--------------------------------------------------------------------- |
---|
2 | * EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC. |
---|
3 | * |
---|
4 | * This LIBRARY is free software; you can distribute it and/or modify |
---|
5 | * it under the therms of the ALSOC FREE LICENSE as available at |
---|
6 | * http://www.enq.ufrgs.br/alsoc. |
---|
7 | * |
---|
8 | * EMSO Copyright (C) 2004 - 2007 ALSOC, original code |
---|
9 | * from http://www.rps.eng.br Copyright (C) 2002-2004. |
---|
10 | * All rights reserved. |
---|
11 | * |
---|
12 | * EMSO is distributed under the therms of the ALSOC LICENSE as |
---|
13 | * available at http://www.enq.ufrgs.br/alsoc. |
---|
14 | * |
---|
15 | *---------------------------------------------------------------------- |
---|
16 | * 10. Dynamics of a heated tank with PI temperature control |
---|
17 | *---------------------------------------------------------------------- |
---|
18 | * |
---|
19 | * Description: |
---|
20 | * This problem is part of a collection of 10 representative |
---|
21 | * problems in Chemical Engineering for solution by numerical methods |
---|
22 | * developed for Cutlip (1998). |
---|
23 | * |
---|
24 | * Subject: |
---|
25 | * * Process Dynamics and Control |
---|
26 | * |
---|
27 | * Concepts utilized: |
---|
28 | * Closed loop dynamics of a process including first order lag |
---|
29 | * and dead time. Padé aprroximation of time delay. |
---|
30 | * |
---|
31 | * Numerical method: |
---|
32 | * * ODEs |
---|
33 | * * Generation of step functions |
---|
34 | * * Simulation of a proportional integral controller |
---|
35 | * |
---|
36 | * Reference: |
---|
37 | * * CUTLIP et al. A collection of 10 numerical problems in |
---|
38 | * chemical engineering solved by various mathematical software |
---|
39 | * packages. Comp. Appl. in Eng. Education. v. 6, 169-180, 1998. |
---|
40 | * * More informations and a detailed description of all problems |
---|
41 | * is available online in http://www.polymath-software.com/ASEE |
---|
42 | * |
---|
43 | *---------------------------------------------------------------------- |
---|
44 | * Author: Rodolfo Rodrigues |
---|
45 | * GIMSCOP/UFRGS - Group of Integration, Modeling, Simulation, |
---|
46 | * Control, and Optimization of Processes |
---|
47 | * $Id$ |
---|
48 | *--------------------------------------------------------------------*# |
---|
49 | using "types"; |
---|
50 | |
---|
51 | |
---|
52 | |
---|
53 | #*--------------------------------------------------------------------- |
---|
54 | * Model of the tank system |
---|
55 | *--------------------------------------------------------------------*# |
---|
56 | Model heated_tank |
---|
57 | PARAMETERS |
---|
58 | # Stirred-tank |
---|
59 | rhoVCp as Real (Default=4e3, Unit='kJ/K'); |
---|
60 | WCp as Real (Default=500, Unit='kJ/min/K'); |
---|
61 | Tis as temperature (Brief="Steady-state design temperature", Default=333.15); |
---|
62 | Tr as temperature (Brief="Set point temperature", Default=353.15); |
---|
63 | |
---|
64 | # Thermocouple |
---|
65 | tau_d as Real (Brief="Dead time", Default=1, Unit='min'); |
---|
66 | tau_m as Real (Brief="Time constant", Default=5, Unit='min'); |
---|
67 | |
---|
68 | # Heater and PI controller |
---|
69 | tau_I as Real (Brief="Integral time constant", Default=2, Unit='min'); |
---|
70 | Kc as Real (Brief="Proportional gain", Unit='kJ/min/K'); |
---|
71 | Integrator as Switcher (Brief="Integrator term to heat expression", Valid=["on","off"], Default="on"); |
---|
72 | |
---|
73 | VARIABLES |
---|
74 | # Stirred-tank |
---|
75 | T as temperature (Brief="Tank temperature"); |
---|
76 | Ti as temperature (Brief="Feed temperature"); |
---|
77 | |
---|
78 | # Thermocouple |
---|
79 | To as temperature (Brief="Input temperature"); |
---|
80 | Tm as temperature (Brief="Measured temperature"); |
---|
81 | |
---|
82 | # Heater and PI controller |
---|
83 | errsum as Real (Unit='K*s'); |
---|
84 | q as heat_rate (Brief="Heat input", DisplayUnit='kW'); |
---|
85 | qs as heat_rate (Brief="Steady-state heat input", DisplayUnit='kW'); |
---|
86 | |
---|
87 | EQUATIONS |
---|
88 | "Energy balance" |
---|
89 | diff(T) = (WCp*(Ti - T) + q)/rhoVCp; |
---|
90 | |
---|
91 | "Padé approximation" |
---|
92 | diff(To) = (T - To - 0.5*tau_d*diff(T))*2/tau_d; |
---|
93 | |
---|
94 | "Thermocouple equation" |
---|
95 | diff(Tm) = (To - Tm)/tau_m; |
---|
96 | |
---|
97 | switch Integrator |
---|
98 | case "on": |
---|
99 | "Heat input" |
---|
100 | q = qs + Kc*(Tr - Tm) + Kc*errsum/tau_I; |
---|
101 | |
---|
102 | case "off": |
---|
103 | "Heat input" |
---|
104 | q = qs + Kc*(Tr - Tm); |
---|
105 | end |
---|
106 | |
---|
107 | "Energy input required at steady-state" |
---|
108 | qs = WCp*(Tr - Tis); |
---|
109 | |
---|
110 | diff(errsum) = Tr - Tm; |
---|
111 | end |
---|
112 | |
---|
113 | |
---|
114 | #*--------------------------------------------------------------------- |
---|
115 | * (a) Dynamics of the heated tank |
---|
116 | *--------------------------------------------------------------------*# |
---|
117 | FlowSheet prob10a as heated_tank |
---|
118 | SET |
---|
119 | Kc = 0*'kJ/min/K'; |
---|
120 | |
---|
121 | EQUATIONS |
---|
122 | if time<10*'min' then |
---|
123 | Ti = 333.15*'K'; |
---|
124 | else |
---|
125 | Ti = 313.15*'K'; |
---|
126 | end |
---|
127 | |
---|
128 | INITIAL |
---|
129 | T = Tr; |
---|
130 | To = Tr; |
---|
131 | Tm = Tr; |
---|
132 | errsum = 0*'K*s'; |
---|
133 | |
---|
134 | OPTIONS |
---|
135 | TimeStart = 0; |
---|
136 | TimeStep = 0.5; |
---|
137 | TimeEnd = 60; |
---|
138 | TimeUnit = 'min'; |
---|
139 | end |
---|
140 | |
---|
141 | |
---|
142 | #*--------------------------------------------------------------------- |
---|
143 | * (b) Dynamics of the heated tank for PI control |
---|
144 | *--------------------------------------------------------------------*# |
---|
145 | FlowSheet prob10b as heated_tank |
---|
146 | SET |
---|
147 | Kc = 50*'kJ/min/K'; |
---|
148 | |
---|
149 | EQUATIONS |
---|
150 | if time<10*'min' then |
---|
151 | Ti = 333.15*'K'; |
---|
152 | else |
---|
153 | Ti = 313.15*'K'; |
---|
154 | end |
---|
155 | |
---|
156 | INITIAL |
---|
157 | T = Tr; |
---|
158 | To = Tr; |
---|
159 | Tm = Tr; |
---|
160 | errsum = 0*'K*s'; |
---|
161 | |
---|
162 | OPTIONS |
---|
163 | TimeStart = 0; |
---|
164 | TimeStep = 0.5; |
---|
165 | TimeEnd = 200; |
---|
166 | TimeUnit = 'min'; |
---|
167 | end |
---|
168 | |
---|
169 | |
---|
170 | #*--------------------------------------------------------------------- |
---|
171 | * (c) Dynamics of the heated tank for PI with Kc=500 |
---|
172 | *--------------------------------------------------------------------*# |
---|
173 | FlowSheet prob10c as heated_tank |
---|
174 | SET |
---|
175 | Kc = 500*'kJ/min/K'; |
---|
176 | |
---|
177 | EQUATIONS |
---|
178 | if time<10*'min' then |
---|
179 | Ti = 333.15*'K'; |
---|
180 | else |
---|
181 | Ti = 313.15*'K'; |
---|
182 | end |
---|
183 | |
---|
184 | INITIAL |
---|
185 | T = Tr; |
---|
186 | To = Tr; |
---|
187 | Tm = Tr; |
---|
188 | errsum = 0*'K*s'; |
---|
189 | |
---|
190 | OPTIONS |
---|
191 | TimeStart = 0; |
---|
192 | TimeStep = 0.5; |
---|
193 | TimeEnd = 200; |
---|
194 | TimeUnit = 'min'; |
---|
195 | end |
---|
196 | |
---|
197 | |
---|
198 | #*--------------------------------------------------------------------- |
---|
199 | * (d) Dynamics of the heated tank for P with Kc=500 |
---|
200 | *--------------------------------------------------------------------*# |
---|
201 | FlowSheet prob10d as heated_tank |
---|
202 | SET |
---|
203 | Kc = 500*'kJ/min/K'; |
---|
204 | Integrator = ["off"]; |
---|
205 | |
---|
206 | EQUATIONS |
---|
207 | if time<10*'min' then |
---|
208 | Ti = 333.15*'K'; |
---|
209 | else |
---|
210 | Ti = 313.15*'K'; |
---|
211 | end |
---|
212 | |
---|
213 | INITIAL |
---|
214 | T = Tr; |
---|
215 | To = Tr; |
---|
216 | Tm = Tr; |
---|
217 | errsum = 0*'K*s'; |
---|
218 | |
---|
219 | OPTIONS |
---|
220 | TimeStart = 0; |
---|
221 | TimeStep = 0.5; |
---|
222 | TimeEnd = 60; |
---|
223 | TimeUnit = 'min'; |
---|
224 | end |
---|
225 | |
---|
226 | |
---|
227 | #*--------------------------------------------------------------------- |
---|
228 | * (e) Dynamics of the heated tank for P with q limits |
---|
229 | *--------------------------------------------------------------------*# |
---|
230 | FlowSheet prob10e |
---|
231 | PARAMETERS |
---|
232 | # Stirred-tank |
---|
233 | rhoVCp as Real (Default=4e3, Unit='kJ/K'); |
---|
234 | WCp as Real (Default=500, Unit='kJ/min/K'); |
---|
235 | Tis as temperature (Brief="Steady-state design temperature", Default=333.15); |
---|
236 | Ti as temperature (Brief="Feed temperature"); |
---|
237 | |
---|
238 | # Thermocouple |
---|
239 | tau_d as Real (Brief="Dead time", Default=1, Unit='min'); |
---|
240 | tau_m as Real (Brief="Time constant", Default=5, Unit='min'); |
---|
241 | |
---|
242 | # Heater and PI controller |
---|
243 | tau_I as Real (Brief="Integral time constant", Default=2, Unit='min'); |
---|
244 | Kc as Real (Brief="Proportional gain", Unit='kJ/min/K'); |
---|
245 | |
---|
246 | VARIABLES |
---|
247 | # Stirred-tank |
---|
248 | T as temperature (Brief="Tank temperature"); |
---|
249 | Tr as temperature (Brief="Set point temperature"); |
---|
250 | |
---|
251 | # Thermocouple |
---|
252 | To as temperature (Brief="Input temperature"); |
---|
253 | Tm as temperature (Brief="Measured temperature"); |
---|
254 | |
---|
255 | # Heater and PI controller |
---|
256 | errsum as Real (Unit='K*s'); |
---|
257 | q as heat_rate (Brief="Heat input", DisplayUnit='kW'); |
---|
258 | qlim as heat_rate (Brief="Limit input energy", DisplayUnit='kW'); |
---|
259 | qs as heat_rate (Brief="Steady-state heat input", DisplayUnit='kW'); |
---|
260 | |
---|
261 | EQUATIONS |
---|
262 | "Energy balance" |
---|
263 | diff(T) = (WCp*(Ti - T) + qlim)/rhoVCp; |
---|
264 | |
---|
265 | "Padé approximation" |
---|
266 | diff(To) = (T - To - 0.5*tau_d*diff(T))*2/tau_d; |
---|
267 | |
---|
268 | "Thermocouple equation" |
---|
269 | diff(Tm) = (To - Tm)/tau_m; |
---|
270 | |
---|
271 | "Heat input" |
---|
272 | q = qs + Kc*(Tr - Tm); |
---|
273 | |
---|
274 | "Energy input required at steady-state" |
---|
275 | qs = WCp*(Tr - Tis); |
---|
276 | |
---|
277 | diff(errsum) = Tr - Tm; |
---|
278 | |
---|
279 | if time<10*'min' then |
---|
280 | Tr = 353.15*'K'; |
---|
281 | else |
---|
282 | Tr = 363.15*'K'; |
---|
283 | end |
---|
284 | |
---|
285 | if q<0 then |
---|
286 | qlim=0*'kW'; |
---|
287 | else |
---|
288 | if q>=2.6*qs then |
---|
289 | qlim=2.6*qs; |
---|
290 | else |
---|
291 | qlim=q; |
---|
292 | end |
---|
293 | end |
---|
294 | |
---|
295 | SET |
---|
296 | Kc = 5e3*'kJ/min/K'; |
---|
297 | Ti = 333.15*'K'; |
---|
298 | |
---|
299 | INITIAL |
---|
300 | T = 353.15*'K'; |
---|
301 | To = 353.15*'K'; |
---|
302 | Tm = 353.15*'K'; |
---|
303 | errsum = 0*'K*s'; |
---|
304 | |
---|
305 | OPTIONS |
---|
306 | TimeStart = 0; |
---|
307 | TimeStep = 0.5; |
---|
308 | TimeEnd = 200; |
---|
309 | TimeUnit = 'min'; |
---|
310 | end |
---|