Figure 5.20:

Linear form of Langmuir isotherm for CO uptake on Ru.

Figure 5.20

Code for Figure 5.20

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
# Converted from assoc_isotherm_lin.m - linear Langmuir fit
import numpy as np
from misc import octave_save

Pdata = np.array([[100., 1.28], [150., 1.63], [200., 1.77],
                  [250., 1.94], [300., 2.06], [400., 2.21]])
ndata = Pdata.shape[0]
ngrid = 20
P     = Pdata[:, 0]
b     = 1e6 / (760 * 82.06 * 373)
CO    = b * P
CO_ratio = CO / Pdata[:, 1]
data = np.column_stack([CO, CO_ratio])

A = np.column_stack([CO, np.ones(ndata)])
x = np.linalg.lstsq(A, CO_ratio, rcond=None)[0]
c_m  = 1. / x[0]
K_CO = x[0] / x[1]

CO_grid     = np.linspace(CO[0], CO[ndata-1], ngrid)
CO_ratio_opt = CO_grid / c_m + 1. / (K_CO * c_m)
output = np.column_stack([CO_grid, CO_ratio_opt])

# save assoc_isotherm_lin.dat output data
octave_save('assoc_isotherm_lin.dat', ('output', output), ('data', data))