Figure 5.15:

Comparison of the molar flowrates of C_2H_6 and C_2H_4 for the exact solution (solid lines) and the simplified kinetic scheme (dashed lines).

Figure 5.15

Code for Figure 5.15

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
48
49
50
51
# Converted from ethane_comparison.m
import numpy as np
from scipy.integrate import solve_ivp
from misc import save_ascii

Ao = np.array([1e17, 2e11, 3e14, 3.4e12, 1.6e13])
Ea = np.array([356000., 44000., 165000., 28000., 0.])
R  = 8.3144
R1 = 82.057
T  = 925.0
P  = 1.0

k = Ao * np.exp(-Ea/(R*T))
kp = (k[0]/(2*k[2]) + np.sqrt((k[0]/(2*k[2]))**2 + k[0]*k[3]/(k[2]*k[4])))

C1o = (50/760)/(82.057*T); C8o = (710/760)/(82.057*T)
Qf = 35.0
N1o = C1o*Qf; N8o = C8o*Qf

def rxrate(v, x):
    N1,N2,N3,N4,N5,N6,N7,N8 = x
    Ntot = sum(x)
    Ctot = P/(R1*T)
    C1 = N1/Ntot*Ctot; C2 = N2/Ntot*Ctot
    C4 = N4/Ntot*Ctot; C5 = N5/Ntot*Ctot
    r1 = k[0]*C1; r2 = k[1]*C1*C2; r3 = k[2]*C4
    r4 = k[3]*C1*C5; r5 = k[4]*C4*C5
    return [-r1-r2-r4+r5, 2*r1-r2, r2, r2-r3+r4-r5, r3-r4-r5, r3, r4, 0.]

def rate_s(v, x):
    N1,N6,N7,N8 = x
    Ntot = N1+N6+N7+N8
    Ctot = P/(R1*T)
    C1 = N1/Ntot*Ctot
    r = k[2]*kp*C1
    return [-r, r, r, 0.]

v = np.arange(0, 100.5, 0.5)
sqeps = np.sqrt(np.finfo(float).eps)
Initial = np.array([N1o, 0., 0., 0., 0., 0., 0., N8o])
sol = solve_ivp(rxrate, [0, 100], Initial, method='Radau',
                t_eval=v, rtol=sqeps, atol=sqeps)
solution = sol.y.T

Initial_s = np.array([N1o, 0., 0., N8o])
sol_s = solve_ivp(rate_s, [0, 100], Initial_s, method='Radau',
                  t_eval=v, rtol=sqeps, atol=sqeps)
solution_s = sol_s.y.T

temp = np.column_stack([v, solution, solution_s])
save_ascii('ethane_comparison.dat', temp)