Kinetic models module#
The kinetic models module provides functions for simulating chemical reaction kinetics using various kinetic models. To create the global kinetic of reaction, multiple elements are available:
rate model : describing the rate of purely chemical reaction
vitrification model : describing a rate depending on vitrification and diffusion phenomenon
coupling law : describing the relation between rate model and vitrification model
tg law : describing the evolution of glass transition temperature with respect to extent
- kinetic_models.arrhenius_rate_constant(T, A, Ea)[source]#
Compute the value of rate constant with the Arrhenius equation.
- Parameters:
T (Float) – Temperature of reaction.
A (Float) – Pre-exponential factor.
Ea (Float) – Activation energy.
- Returns:
k – Rate constant for the Arrhenius equation.
- Return type:
Float
Notes
The Arrhenius rate constant is given by:
\[k = A e^{ \left( \frac{-E_a}{RT} \right)}\]
- kinetic_models.compute_extent_and_rate(time, temperature, rate_law=None, rate_law_args=None, vitrification_law=None, vitrification_law_args=None, tg_law=None, tg_law_args=None, coupling_law=None, coupling_law_args=None, initial_extent=0)[source]#
Compute the evolution of extent and rate during a reaction, with or without vitrification.
- Parameters:
time (array-like) – List or array containing the times during the reaction.
temperature (array-like) – List or array containing the temperatures during the reaction.
rate_law (function) – The rate law function that calculates the rate of reaction.
rate_law_args (tuple) – Additional arguments to be passed to the rate law function.
vitrification_law (function, optional) – The vitrification law function that calculates the vitrification term.
vitrification_args (tuple, optional) – Additional arguments to be passed to the vitrification law function.
tg_law (function, optional) – The glass transition temperature law function that calculates the Tg.
tg_law_args (tuple, optional) – Additional arguments to be passed to the Tg law function.
coupling_law (function, optional) – Law used to mix the rate of chemical reaction and rate of vitrification.
coupling_law_args (tuple, optional) – Additional arguments to be passed to the coupling law function.
initial_extent (float, optional) – The initial extent of reaction. Default is 0. It must be positive and inferior to 1.
- Returns:
extent (ndarray) – Evolution of extent during the reaction.
global_rate (ndarray) – Evolution of the global rate of reaction.
chemical_rate (ndarray) – Evolution of the chemical rate of reaction.
vitrification_term (ndarray, optional) – Evolution of the vitrification rate of reaction (if vitrification parameters are provided).
tg (ndarray, optional) – Evolution of the Tg (if Tg parameters are provided).
- kinetic_models.compute_extent_and_rate_using_scipy(t0, tf, temperature_program, rate_law, rate_law_args, vitrification_law=None, vitrification_args=None, tg_law=None, tg_law_args=None, coupling_law=None, coupling_law_args=None, initial_extent=0)[source]#
Compute extent and rate using scipy’s solve_ivp.
- Parameters:
t0 (float) – Initial time.
tf (float) – Final time.
temperature_program (callable) – A function that takes time as input and returns temperature.
rate_law (callable) – Rate law function.
rate_law_args (tuple) – Arguments for the rate law function.
vitrification_law (callable) – Vitrification law function.
vitrification_args (tuple) – Arguments for the vitrification law function.
tg_law (callable) – Tg law function.
tg_law_args (tuple) – Arguments for the Tg law function.
coupling_law (callable) – Coupling law function.
coupling_law_args (tuple) – Arguments for the coupling law function.
initial_extent (float, optional) – Initial extent. Default is 0.
- Returns:
Solution object from solve_ivp.
- Return type:
scipy.integrate.OdeResult
- kinetic_models.coupling_harmonic_mean(kc, kv, experimental_parameters=None)[source]#
Return the harmonic mean of a chemical rate and vitrification rate.
\[\dfrac{ d\alpha }{dt} = \dfrac{1}{\dfrac{1}{k_c } + \dfrac{1}{k_v}}\]- Parameters:
kc (1-D array) – Rate of chemical reaction
kv (1-D array) – Vitrification term
experimental_parameters (NoneType) – NoneType argument to stick with guideline of function creation
- Returns:
Rate – Rate of reaction
- Return type:
1-D array
References
[1] G. Wisanrakkit et J. K. Gillham, « The glass transition temperature (Tg) as an index of chemical conversion for a high-Tg amine/epoxy system: Chemical and diffusion-controlled reaction kinetics », Journal of Applied Polymer Science, vol. 41, nᵒ 11‑12, p. 2885‑2929, 1990, doi: 10.1002/app.1990.070411129.
- kinetic_models.coupling_product(kc, kv, experimental_parameters=None)[source]#
Return the product of a chemical rate and vitrification rate.
\[\dfrac{ d\alpha }{dt} = k_c * k_v\]- Parameters:
kc (1-D array) – Rate of chemical reaction
kv (1-D array) – Vitrification term
experimental_parameters (NoneType) – NoneType argument to stick with guideline of function creation
- Returns:
Rate – Rate of reaction
- Return type:
1-D array
- kinetic_models.hess_for_rate_for_kamal(extent, T, A1, E1, A2, E2, m, n)[source]#
Compute the Hessian matrix for the Kamal equation.
- Parameters:
extent (float) – Extent of the reaction.
T (float) – Temperature in Kelvin.
A1 (float) – Pre-exponential factor for reaction 1.
E1 (float) – Activation energy for reaction 1 in J/mol.
A2 (float) – Pre-exponential factor for reaction 2.
E2 (float) – Activation energy for reaction 2 in J/mol.
m (int) – Power term for reaction 2.
n (int) – Power term for both reactions.
- Returns:
hessian – Hessian matrix of shape (6, 6) representing the second derivatives of the rate expression with respect to (A1, E1, A2, E2, m, n).
- Return type:
ndarray
Notes
The Hessian matrix H is given by:
\[\begin{split}H = \begin{bmatrix} 0 & -\frac{(1 - x)^n e^{-E_1/(RT)}}{RT} & 0 & 0 & 0 & (1 - x)^n \log(1 - x) e^{-E_1/(RT)} \\ -\frac{(1 - x)^n e^{-E_1/(RT)}}{RT} & \frac{A_1 (1 - x)^n e^{-E_1/(RT)}}{(R^2 T^2)} & 0 & 0 & 0 & -\frac{A_1 (1 - x)^n \log(1 - x) e^{-E_1/(RT)}}{RT} \\ 0 & 0 & 0 & -\frac{x^m (1 - x)^n e^{-E_2/(RT)}}{RT} & x^m (1 - x)^n \log(x) e^{-E_2/(RT)} & x^m (1 - x)^n \log(1 - x) e^{-E_2/(RT)} \\ 0 & 0 & -\frac{x^m (1 - x)^n e^{-E_2/(RT)}}{RT} & \frac{A_2 x^m (1 - x)^n e^{-E_2/(RT)}}{(R^2 T^2)} & -\frac{A_2 x^m (1 - x)^n \log(x) e^{-E_2/(RT)}}{RT} & -\frac{A_2 x^m (1 - x)^n \log(1 - x) e^{-E_2/(RT)}}{RT} \\ 0 & 0 & x^m (1 - x)^n \log(x) e^{-E_2/(RT)} & -\frac{A_2 x^m (1 - x)^n \log(x) e^{-E_2/(RT)}}{RT} & A_2 x^m (1 - x)^n \log^2(x) e^{-E_2/(RT)} & A_2 x^m (1 - x)^n \log(1 - x) \log(x) e^{-E_2/(RT)} \\ (1 - x)^n \log(1 - x) e^{-E_1/(RT)} & -\frac{A_1 (1 - x)^n \log(1 - x) e^{-E_1/(RT)}}{RT} & x^m (1 - x)^n \log(1 - x) e^{-E_2/(RT)} & -\frac{A_2 x^m (1 - x)^n \log(1 - x) e^{-E_2/(RT)}}{RT} & A_2 x^m (1 - x)^n \log(1 - x) \log(x) e^{-E_2/(RT)} & (1 - x)^n \log^2(1 - x) (A_2 x^m e^{-E_2/(RT)} + A_1 e^{-E_1/(RT)}) \end{bmatrix}\end{split}\]
- kinetic_models.jac_for_rate_for_kamal(extent, T, A1, E1, A2, E2, m, n)[source]#
Compute the Jacobian vector for the Kamal equation.
- Parameters:
extent (float) – Extent of the reaction.
T (float) – Temperature in Kelvin.
A1 (float) – Pre-exponential factor for reaction 1.
E1 (float) – Activation energy for reaction 1 in J/mol.
A2 (float) – Pre-exponential factor for reaction 2.
E2 (float) – Activation energy for reaction 2 in J/mol.
m (int) – Power term for reaction 2.
n (int) – Power term for both reactions.
- Returns:
jac – Jacobian vector of shape (6,) representing the first derivatives of the rate expression with respect to (A1, E1, A2, E2, m, n).
- Return type:
ndarray
Notes
This function computes the Jacobian vector for a rate expression based on the extent of the reaction, temperature, pre-exponential factors, activation energies, and power terms for two reactions. The Jacobian vector represents the first derivatives of the rate expression with respect to the extent of the reaction.
The Jacobian vector J is given by:
\[\begin{split}J = \begin{bmatrix} (1 - x)^n e^{-\frac{E_1}{RT}} \\ -\frac{A_1 (1 - x)^n e^{-\frac{E_1}{RT}}}{RT} \\ x^m (1 - x)^n e^{-\frac{E_2}{RT}} \\ -\frac{A_2 x^m (1 - x)^n e^{-\frac{E_2}{RT}}}{RT} \\ A_2 x^m (1 - x)^n \log(x) e^{-\frac{E_2}{RT}} \\ (1 - x)^n \log(1 - x) (A_2 x^m e^{-\frac{E_2}{RT}} + A_1 e^{-\frac{E_1}{RT}}) \end{bmatrix}\end{split}\]
- kinetic_models.rate_for_autocatalytic(extent, T, A, Ea, m, n)[source]#
Compute the rate of reaction for an autocatalytic reaction.
- Parameters:
extent (ndarray) – Extent of reaction.
T (ndarray) – Temperature of reaction.
A (float) – Pre-exponential factor of the reaction.
Ea (float) – Activation energy of the reaction.
m (float) – Order of reaction for the autocatalyzed reaction.
n (float) – Order of reaction for the regular reaction.
- Returns:
rate – Rate of reaction for an autocatalytic equation.
- Return type:
ndarray
Notes
The rate for an autocatalytic reaction is given by:
\[\frac{d\alpha}{dt} = A e^{ \left( \frac{-E_a}{RT} \right)} \alpha^m (1-\alpha)^n\]References
[1] M. R. Keenan, « Autocatalytic cure kinetics from DSC measurements: Zero initial cure rate », J. Appl. Polym. Sci., vol. 33, nᵒ 5, p. 1725‑1734, avr. 1987, doi: 10.1002/app.1987.070330525.
- kinetic_models.rate_for_kamal(extent, T, A1, E1, A2, E2, m, n)[source]#
Compute the value of the rate of reaction for a Kamal equation.
- Parameters:
extent (ndarray) – Extent of reaction.
T (ndarray) – Temperature of reaction.
A1 (float) – Pre-exponential factor of the regular reaction.
E1 (float) – Activation energy of the regular reaction.
A2 (float) – Pre-exponential factor of the autocatalyzed reaction.
E2 (float) – Activation energy of the autocatalyzed reaction.
m (float) – Order of reaction for the autocatalyzed reaction.
n (float) – Order of reaction for the regular reaction.
- Returns:
rate – Rate of reaction for a Kamal equation.
- Return type:
ndarray
Notes
The Kamal equation is given by:
\[\frac{d\alpha}{dt} = \left( A_1 e^{ \left( \frac{-E_1}{RT} \right)} + A_2 e^{ \left( \frac{-E_2}{RT} \right) } \alpha^m \right) (1-\alpha)^n\]References
[1] G. J. Tsamasphyros, Th. K. Papathanassiou, et S. I. Markolefas, « Some Analytical Solutions of the Kamal Equation for Isothermal Curing With Applications to Composite Patch Repair », Journal of Engineering Materials and Technology, vol. 131, no 1, Dec. 2008, doi: 10.1115/1.3026550.
Examples
>>> import time as t >>> import numpy as np >>> import matplotlib.pyplot as plt ... >>> number_of_points = 10000 >>> time_points = np.linspace(0, 1800, number_of_points) # 30 minutes >>> temperatures = [ np.linspace(293, 443, number_of_points), # 5°C/min np.linspace(293, 593, number_of_points), # 10°C/min np.linspace(293, 743, number_of_points), # 15°C/min np.linspace(293, 1093, number_of_points) # 20°C/min ] >>> conversions = [] >>> rates = [] ... >>> fig, ax1 = plt.subplots(num=1) >>> ax1_bis = ax1.twinx() >>> ax1.set_xlabel("time") >>> ax1.set_ylabel("conversion") >>> ax1_bis.set_ylabel("rate") ... >>> for i, temperature in enumerate(temperatures): >>> t0 = t.time() >>> extent, rate = compute_extent_and_rate(time_points, temperature, rate_for_kamal, (1.666e8, 80000, 1.666e13, 120000, 1, 0.7)) >>> t1 = t.time() >>> execution_time = t1 - t0 >>> print("Time:", execution_time, "s") >>> conversions.append(extent) >>> rates.append(rate) >>> ax1.plot(time_points, extent, label=f"conversion for a heating rate of {(i+1)*5}°/min", linestyle='dotted') >>> ax1_bis.plot(time_points, rate, label=f"rate for a heating rate of {(i+1)*5}°/min") >>> ax1.legend() >>> ax1_bis.legend() ... >>> plt.show()
- kinetic_models.rate_for_nth_order(extent, T, A1, E1, n)[source]#
Compute the value of the rate of reaction for a nth order reaction.
\[\dfrac{ d\alpha }{dt} = A e^{ \left( \dfrac{-E_a}{RT} \right) } (1-\alpha)^n\]- Parameters:
extent (1-D array) – Extent of reaction.
T (1-D array) – Temperature of reaction.
A (Float) – Pre-exponential factor of the reaction.
Ea (Float) – Activation energy of the reaction.
n (Float) – Order of reaction.
- Returns:
rate – Rate of reaction for a nth order reaction.
- Return type:
1-D array
- kinetic_models.tg_diBennedetto(extent, Tg_0, Tg_inf, coeff)[source]#
Compute the glass transition temperature using the DiBennedetto equation.
- Parameters:
alpha (array-like) – conversion or extent of reaction
Tg_0 (Float) – glass transition temperature of unreacted material
Tg_inf (Float) – glass transition temperature of fully reacted material
coeff (Float) – ratio of the changes in isobaric heat capacities at Tg of the fully reacted material and of the initial unreacted material
- Returns:
Tg – Glass transition temperature
- Return type:
array-like
Notes
The DiBennedetto equation is given by:
\[\begin{split}Tg = Tg_{0} + \dfrac{ (Tg_{\infty}-Tg_{0}). \lambda .\alpha}{1-(1-\lambda)\alpha} \\ with: \\ Tg_{0}: \textrm{The glass transition temperature of unreacted material} \\ Tg_{\infty}: \textrm{The glass transition temperature of completely cured material} \\ \lambda : \dfrac{\Delta C_{p_{\infty}}}{\Delta C_{p_{0}}} \textrm{the ratio of the changes in isobaric heat capacities at} \\ \textrm{Tg of the fully reacted material and of the initial unreacted material}\\\end{split}\]
- kinetic_models.vitrification_WLF_rate(T, Tg, Ad, C1, C2)[source]#
Compute the vitrification term for a WLF-like model.
The vitrification term is given by the WLF model:
\[k_v = A_d e^{ \left( \frac{C_1(T - T_g(\alpha))}{C_2 + |T - T_g(\alpha)|} \right) }\]- where:
\(T\) is the temperature of the reaction (in Kelvin).
\(A_d\) is the pre-exponential factor of the vitrification term
\(C_1\) is Constant 1 of the WLF model
\(C_2\) is Constant 2 of the WLF model
\(T_g\) is the glass transition temperature (in Kelvin).
Usually, the glass transition temperature is determined by using the DiBenedetto equation.
- Parameters:
T (array-like) – Temperature of the reaction (in Kelvin)
Ad (float) – Pre-exponential factor of the vitrification term
C1 (float) – Constant 1 of the WLF model
C2 (float) – Constant 2 of the WLF model
Tg (float) – Glass transition temperature (in Kelvin)
- Returns:
rate – Rate of the reaction
- Return type:
array-like
References
[1] G. Wisanrakkit et J. K. Gillham, “The glass transition temperature (Tg) as an index of chemical conversion for a high-Tg amine/epoxy system: Chemical and diffusion-controlled reaction kinetics”, Journal of Applied Polymer Science, vol. 41, no. 11-12, p. 2885-2929, 1990, doi: 10.1002/app.1990.070411129.
- kinetic_models.vitrification_WLF_rate_no_reaction_below_Tg(T, Tg, Ad, C1, C2)[source]#
Compute the vitrification term for a WLF-like model when the reaction temperature is above Tg. The vitrification term is equal to 0 when below Tg.
\[k_v = A_d e^{ \left( \dfrac{C_1(T-T_g(\alpha))}{C_2+ |T-T_g(\alpha)|} \right) }\]Usually the glass transition temperature is determined by using the DiBenedetto equation See: G. Wisanrakkit et J. K. Gillham, « The glass transition temperature (Tg) as an index of chemical conversion for a high-Tg amine/epoxy system: Chemical and diffusion-controlled reaction kinetics », Journal of Applied Polymer Science, vol. 41, nᵒ 11‑12, p. 2885‑2929, 1990, doi: 10.1002/app.1990.070411129.
- Parameters:
T (Array-like) – Temperature of reaction (in Kelvin)
Ad (Float) – Pre-exponential factor of the vitrification term
C1 (Float) – Constant 1 of WLF model
C2 (Float) – Constant 2 of WLF model
Tg (Float) – Glass transition temperature (in Kelvin)
- Returns:
Rate – Rate of reaction
- Return type:
Array-like
References
[1] G. Wisanrakkit et J. K. Gillham, “The glass transition temperature (Tg) as an index of chemical conversion for a high-Tg amine/epoxy system: Chemical and diffusion-controlled reaction kinetics”, Journal of Applied Polymer Science, vol. 41, no. 11-12, p. 2885-2929, 1990, doi: 10.1002/app.1990.070411129.