Figure 4.5:

First-order, reversible kinetics in a batch reactor, k_1=1, k_{-1}=0.5, c_{A0}=1, c_{B0}=0.

Figure 4.5

Code for Figure 4.5

Text of the GNU GPL.

main.py


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Converted from kca_rev.m
import numpy as np
from misc import save_ascii

k1 = 1.0
k_1 = 0.5
npts = 100
x = np.linspace(0, 5, npts)
y = np.column_stack([
    np.exp(-(k1+k_1)*x) + k_1/(k1+k_1)*(1 - np.exp(-(k1+k_1)*x)),
    1 - (np.exp(-(k1+k_1)*x) + k_1/(k1+k_1)*(1 - np.exp(-(k1+k_1)*x))),
    np.ones(npts)/3.0,
    2*np.ones(npts)/3.0
])
table = np.column_stack([x, y])
save_ascii('kca_rev.dat', table)