Isotherm fitting module (pyAPEP.isofit
)
isofit
is a module used to define isotherm functions from pressure and uptake data samples. Three main functions are developed in this module—best_isomodel
, diff_T
, and IAST
. best_isomodel
automatically finds the best isotherm function for the pure component. diff_T
derives isotherms according to temperature and pressure, and IAST
derives mixture isotherms using single isotherms, respectively.
First, import isofit into Python after installation.
import pyapep.isofit as isofit
In this module, three main functions exist.
Finding best isotherm function (
isofit.best_isomodel
)Fitting isotherm for different temperature (
isofit.fit_diffT
)Developing mixuture isotherm with IAST (
isofit.IAST
)
Detailed description of each function are described in next senction. The explanation include function usage, algorithm (or related theroy), and function structure.
Usage
1. Finding best isotherm function
best_isomodel
automatically finds the best isotherm function from a given pressure-uptake dataset with multiple isotherm and optimizer candidates. In this usage example, the isotherm function is found from a dummy dataset with gas uptake at four pressures (2, 3, 4, 5 bar). The function best_isomodel
returns 4 elements: isotherm function, estimated parameters of isotherm function, the type of isotherm, and validation error of the model.
# Package import
import pyapep.isofit as isofit
# Generate dummy data
P = [2, 3, 4, 5]
q_comp1 = [1, 2, 3, 4] # Gas adsorption of a component
# Define pure isotherm of each component
iso1, param1, fntype1, err1 = isofit.best_isomodel(P, q_comp1)
2. Fitting isotherm for different temperature
To reflect the temperature influence on the adsorption equilibrium, adsorption isotherm data measured at different pressure and temperatures should be used in composing an isotherm model. fit_diffT
finds the isotherm model considering both pressure and temperature effects.
# Generate a data dummy data
qm_dum = 4.5 # mol/kg
K1_dum = 3.0 # 1/bar
K2_dum = 0.5 # 1/(bar^2)
P_dum = np.linspace(0, 2, 9)
T_dum = [280, 300, 305, 310, 320] # dummy T
dH_dum = 25000 # J/mol : heat of adsorption
R_gas = 8.3145
T_ref = T_dum[1] # Reference temperature = 300 K
q_dum = []
for T in T_dum:
P_norm = np.exp(dH_dum/R_gas*(1/T - 1/T_ref))*P_dum
err_dum = 0.05*np.random.rand(len(P_norm))
q_tmp = qm_dum*(K1_dum*P_norm + 2*K2_dum*P_norm**2)/(
1+ K1_dum*P_norm + K2_dum*P_norm**2)
q_w_err = q_tmp + err_dum
q_dum.append(q_w_err)
# Use isofit
P_list = [P_dum,]*len(q_dum)
res_diffT = isofit.fit_diffT(P_list,q_dum, T_dum, 1, tol = 2E-4)
iso_function, iso_param, zerr = res_diffT[:3]
fit_error, dH_found, Tref_found, theta_list = res_diffT [3:]
print("This data is fitted with {}.".format(zerr))
# Prediction for different T
P_pred = np.linspace(0,2.5, 51)
q_pred = []
for T in T_dum:
q_tmp =iso_function(P_pred, T)
q_pred.append(q_tmp)
3. Developing mixuture isotherm with IAST
IAST
provides Ideal adsorbed solution theory (IAST) calculation. IAST is widely used for predicting the isotherm of multiple components using pure isotherm models for each gas component.
# Pure isotherm functions
def iso1(P,T):
deno = 1 + 0.3*P
nume = 2*0.3*P
return nume/deno
def iso2(P,T):
deno = 1 + 0.3*P + 0.1*P**2
nume = 2*(0.3*P + 2*0.1*P**2)
return nume/deno
def iso3(P,T):
return 2*P**0.4
iso_list = [iso1, iso2, iso3]
P_arr = np.linspace(0,4,9) # pressure (bar)
T = 300 # temperature (K)
y_gas = [] # mole fraction (mol/mol)
y1 = [0, 0.2, 0.4, 0.6] # mol. frac. of 1 (mo/mol)
for y in y1:
y_tmp = np.array([y, 0.6-y, 0.4])
y_gas.append(y_tmp)
q_comp1 = []
q_comp2 = []
for yy in y_gas:
res_list = []
q1_tmp = []
q2_tmp = []
for p in P_arr:
res_tmp = isofit.IAST(iso_list,p*yy, T)
res_list.append(res_tmp)
q1_tmp.append(res_tmp[0])
q2_tmp.append(res_tmp[1])
q_comp1.append(q1_tmp)
q_comp2.append(q2_tmp)
Function structures
- pyAPEP.isofit.best_isomodel(P, q, iso_par_nums=[2, 3, 4], iso_fun_lists=None, iso_fun_index=None, tol=1e-05)[source]
Function to automatically find best isotherm model for given datast with multiple isotherm and optimizer candidates.
Models supported are as follows. Here, \(q\) is the gas uptake, \(P\) is partial pressure (fugacity technically).
- Parameters:
P – Partial pressure list
q – Acutal or simulated uptake list of given P
iso_par_nums – The number of parameters for isotherm models
iso_fun_lists – Isotherm function candidates
iso_fun_index – Each name for iso_fun_lists
tol – Tolerance
- Returns:
isotherm function, estimated parameters of isotherm function, the type of isotherm, and validation error of the model
- pyAPEP.isofit.fit_diffT(p_list, q_list, T_list, i_ref, iso_par_nums=[2, 3, 4], iso_fun_lists=None, iso_fun_index=None, tol=1e-05)[source]
Function to fit isotherm model for given datast based on the different temperatures.
- Parameters:
p_list – Partial pressure list
q_list – Acutal or simulated uptake list of given P
T_list – Temperature list
i_ref – Reference temperature index in T_list
iso_par_nums – The number of parameters for isotherm models
iso_fun_lists – Isotherm function candidates
iso_fun_index – Each name for iso_fun_lists
tol – Tolerance
- Returns:
var_return (isotherm function, isotherm parameters, errors, calculated heat of adsorption, reference temperature, a list of :math:` heta_{T_j}`)
Theory
Finding best isotherm function algorithm
A primary function, best_isomodel
, automatically determines the best isotherm function from a given pressure-uptake dataset. Figure below shows the algorithm of best_isomodel
. The algorithm consists of three main stages. First, the parameter was estimated using a given isotherm function and an optimization solver. In the next stage, the best optimization solver with the least error was identified by repeatedly solving the objective problems using five optimization solvers. Finally, the best isotherm function among the five isotherm candidates was found by repeating the first and second stages. A detailed explanation of each stage is provided below:
Figure shows the algorithm of isofit.best_isomodel
. The algorithm consists of three stages. First, the parameter estimation is carried out with a given isotherm function and an optimization solver. The next stage finds the best optimization solver with the least error by repeatedly solving the objective problems with five optimization solvers. Lastly, the best isotherm function is found among five isotherm candidates by repeating the first and second stages. A detailed explanation of each stage is described followings.
Parameters estimation of the isotherm function is the same as solving an optimization problem as followings:
where \(q\), \(N_{fit}\), and \(K\) refer to gas uptake, the number of data samples for isotherm fitting, and isotherm parameters, respectively. \(f\) means the isotherm function, and \(\hat{q}\) is the predicted uptake from \(f\). By solving the objective function, the isotherm parameters are derived that satisfy the minimum error between actual and predicted uptake data.
To find the best isotherm parameters, isofit.best_isomodel
function considers five optimization solvers. Optimization solvers are given by the public python package, scipy, and those are Nelder-mead, Powell, COBYLA, shgo, and differential evolution. The optimization solver (s) with the minimum objective function is selected and the isotherm function is derived as the following equation, and \(Opt\_list\) refers to the list of five solvers.
The best isotherm function with the smallest objective function value is derived by solving the above equations with to five isotherm functions. Five isotherm functions are described in Table __ and \(F\_list\) denotes the list of isotherm functions. Then, the best solver and parameters could be found for each isotherm function.
isofit
estimates the parameters for adsorption isotherm models. If the user provides a list of adsorption isotherm models to fit the data, the isofit
module uses the default list of isotherm models. The default list includes the following default isotherm models—Langmuir, Freundlich, Quadratic, Sips, and Dual-site Langmuir isotherm models. These isotherm models are described using the following equations as in below table.
parameters |
Name |
Equation |
---|---|---|
1 |
Arrh |
\(q(P) =e^{\frac{\vartriangle H}{R} \left (\frac {1}{T}-\frac {1}{T_{ref}} \right)}\) |
2 |
Lang |
\(q(P) = M\frac{KP}{1+KP}\) |
Freu |
\(q(P) = kP^n\) |
|
3 |
Quad |
\(q(P) = M \frac{(K_a + 2 K_b P)P}{1+K_aP+K_bP^2}\) |
Sips |
\(q(P) =\frac{q_m K P^n}{1+K P^n}\) |
|
4 |
DSLang |
\(q(P) = M_1 \frac{K_1 P}{1+K_1 P} + M_2 \frac{K_2 P}{1+K_2 P}\) |
Langmuir isotherm model is an isotherm model derived from the assumption that identical elementary adsorption sites exist on the adsorbent surface. The Langmuir isotherm model is also know as simple Langmuir or Single-site Langmuir isotherm model to be distinguished from multi-site Langmuir models. Freundlish model is an empirically deduced isotherm model. Although it is well know that Freundlich model is neither physically nor thermodynamically consistent, this model has been widely used still today. Moreover, Quadratic isotherm model is the simplest cooperative adsorption isotherm model. Quadratic isotherm model assumes identical adsorption sites hosting multiple adsorbate molecules. In addition, Sips model is a combination of Langmuir and Freundlich isotherm models. While Sips model follows Freundlich isotherm model at low pressure, the model predicts the saturation of the adsorbent at high pressure as Langmuir isotherm model does. Lastly, Dual-site Langmuir model is the most well-known multisite Langmuir isotherm model. Dual-site Langmuir isotherm model is derived from the assumption t that there exist two distinct types of adsorption sites. These default adsorption isotherm models are considered to select the best adsorption isotherm model for the given data in isofit
module.
Note
The user should provide a data sample in consideration of the number of parameters of the model to be used as candidates. For example, if you want to include the Dualsite Langmuir function in candates, the user needs more than three data samples.
Adosption at different temperature (using heat of adsorption)
This isofit
module also provides the function to derive the isotherm function depending on the different temperatures. Using the Arrhenius equation, gas uptake could be calculated at a given temperature.
where \(\Delta H\) and \(R\) are the heat of adsorption and gas constant, respectively. Subscript \(ref\) refers to the reference condition.
Since adsorption isotherm models have been suggested with uptake-pressure data at a constant temperature, the methods for estimating the isotherm parameters have been discussed in the previous section. However, the influence of temperature is also important to predict the adsorption behaviors in various applications such as the adsorption-based separation or storage processes.
To reflect the temperature influence on the adsorption equilibrium, adsorption isotherm data measured at different pressure and temperatures should be used in composing an isotherm model. The proposed package, pyAPEP, provides a function diff_T
where the isotherm model considering both pressure and temperature effects is found. The function assumes followings:
The influence of temperature on the adsorption isotherm follows the Clausius-Clapeyron relation since adsorption is considered as a phase change from gas phase to solid phase. This allows the temperature effect to be expressed as the Arrhenius equation.
Heat of adsorption is constant for different temperatures and pressure, which is a key parameter expressing the extent of the thermal sensitivity to the adsorption.
Once we have uptake-pressure data for different temperatures, the assumptions allow the pressure data to be normalized as expressed in follwing equation.
\(P_{norm}\), \(\Delta H_{ad}\), and \(R_{gas}\) are normalized pressure, heat of adsorption, and gas constants, respectively. As given data, temperature and pressure are expressed with \(P\) and \(T\).
The pressure should be normalized to make the uptake and normalized pressure data be aligned on a single reference curve, overlapping one another as shown in Figure {fig:sec3:qP_compare}. If the reference curve is expressed with \(f_{ref}\), assigning proper \(\theta\) to each temperature makes all the data overlapped in below equation.
The problem of finding the best \(\theta\) value is formulated as an optimization problem minimizing the difference between the uptake data and predicted uptake from the reference curve as shown in following equation.
The \(\theta_{T_{j}}\) values matches to each temperature (\(T_{j}\)), and they are correlated with a parameter, heat of adsorption (\(\Delta H_{ad}\)). From the first assumption, the parameter \(\theta_{T_{j}}\) can be expressed with following equation, which indicates that the heat of adsorption (\(\Delta H_{ad}\)) parameterizes the temperature influences of the adsorption isotherm curves.
Using the temperature and \(\theta_{T_{j}}\) data, therefore, the heat of adsorption can be obtained as a solution of below optimization problem.
To find an isotherm model as a function of both pressure and temperature, an isotherm model explaining the reference curve should be found. Since the normalized pressure can be expressed with a function of pressure, the algorithm is employed, which provides the best isotherm model for a reference function, \(f_{ref}(P)\).
Using the model and parameters found above, the prediction of uptake (\(q\)) is realized with the equation:
Ideal adsorbed solution theory (IAST)
To derive the mixture isotherm function, pyapep.isofit module provides Ideal adsorbed solution theory (IAST) calculation. IAST is widely used for predicting the isotherm of multiple components using pure isotherm models for each gas component. The assumptions in IAST are described below. Detailed descriptions of the theory refer to [46].
The temperature is fixed and the pure isotherm are measured at the same temperature.
The thermodynamic property of the adsorbent during the adsorption is negligible.
Each adsorbate has access to the same area of adsorbent surface.
A Gibbs dividing surface defines an adsorbed phase.
From Raoults’ law, we need to find solid mole fraction \(x_i\), which is the uptake.
where, \(\pi_{i}^{\circ}\) is the reduced spreading pressure, \(f_i(P)\) is the pure isotherm model. For components \(i = 1, 2, ..., n\), the pure component spreading pressure \(\pi_i\) at pressure \(P^{\circ}_i\) are all equal to the spreading pressure of the mixture \(\pi\).
The spreading pressures for all components are calculated with \(x_{guess}\) until the difference between the spreading pressure of each component is minimized. \(\pi_i\) and \(x_i\) are derived by solving above equation, and the gas uptake of each component is calculated by the followings,
During the implementation of IAST, implicit calculations are required to find the adsorption equilibrium. In pyAPEP proposed in this work, the implicit calculations are solved using the optimization method. The formulated optimization problem is illustrated in below equation.
Suppose that the function \(h_j\) is the computations of the spreading pressure of component \(j(π_i)\). The function \(h_j\) is a function of the given initial guess of solid phase mole fraction (\(x_j\)), gas phase mole fraction \(y_j\), pressure(\(P\)), and temperature(\(T\)).
For efficient computation, this work suggests a new method. Selecting the initial guess of solid phase mole fraction (\(x_{j}\)) is the most important part. To find the initial guess in an efficient way, this work proposes a new method. The method uses the extended Langmuir isotherm model for the initial guess.
Since the extended Langmuir isotherm has explicit equation structure, it takes significantly short time to calculate the Langmuir isotherm equation solution. However, the problem is that the extended Langmuir isotherm model is not applicable to the other isotherm models than Langmuir model as a pure isotherm model. For example, if one component follows Freundlich isotherm model, the Langmuir isotherm model parameters cannot be found.
To overcome this problem, the method proposed in this work estimates effective values of the Langmuir isotherm model parameters (\(q_{m,eff,i}\) and \(b_{eff,i}\)). This method firstly assumes that the isotherm model behaves in the similar way of Langmuir isotherm model. For given isotherm model \(f_{i}(P_{i})\), the effective Langmuir parameters are found as following equations.
In the equations, \(P_{high}\) is a huge pressure enough to saturate the adsorbent while \(P_{i}\) is current partial pressure. By applying those effective Langmuir parameters to extended Langmuir isotherm model as shown in below equations, practical initial guess (\(x_{i,init}\)) is found for solving the optimization problem.
The effective Langmuir parameters are similar to finding a hydraulic diameter for pipes with different shapes. Although various hydraulic dimensionless numbers are defined based on the pipe diameter, the diameter cannot be found in the pipes with other shapes than circle. As an important hydraulic feature, the hydraulic diameter of different cross-sectional shape is calculated with the ratio between the area and perimeter.