Figure 6.26:
Phase portrait of conversion versus temperature for feed initial condition; \tau =35~min.
Code for Figure 6.26
Text of the GNU GPL.
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 | # Converted from limit_cycle.m - CSTR limit cycle: theta=35
import numpy as np
from scipy.integrate import solve_ivp
from misc import save_ascii
p = dict(
k_m = 0.004,
T_m = 298.,
E = 15000.,
c_Af = 2.,
C_p = 4.,
rho = 1000.,
T_f = 298.,
T_a = 298.,
DeltaH_R = -2.2e5,
U = 340.,
theta = 35.,
T_set = 321.53,
c_set = 0.48995,
T_fs = 298.,
Kc = 0.,
)
p['C_ps'] = p['C_p'] * p['rho']
def rhs(t, x, p):
c_A = x[0]; T = x[1]
k = p['k_m'] * np.exp(-p['E'] * (1./T - 1./p['T_m']))
T_f = p['T_fs'] + p['Kc'] * (T - p['T_set'])
return [
(p['c_Af'] - c_A)/p['theta'] - k*c_A,
p['U']/p['C_ps']*(p['T_a']-T) + (T_f-T)/p['theta'] - k*c_A*p['DeltaH_R']/p['C_ps']
]
x0 = [p['c_Af'], p['T_f']]
tfinal = 15. * p['theta']
tout = np.linspace(0., tfinal, 1000)
sol = solve_ivp(lambda t, x: rhs(t, x, p), [0., tfinal], x0,
method='Radau', t_eval=tout,
rtol=np.sqrt(np.finfo(float).eps),
atol=np.sqrt(np.finfo(float).eps))
x = sol.y.T
u = (x[:, 1] - p['T_set']) * p['Kc'] + p['T_fs']
conv = (p['c_Af'] - x[:, 0]) / p['c_Af']
table = np.column_stack([tout, x, conv, u])
save_ascii('limit_cycle.dat', table)
|