# A Neural Network-Inspired Matrix Formulation of Chemical Kinetics for Acceleration on GPUs
## 2 Methodology
### Matrix-Based Kinetics Equations
The remaining task, described below, is to obtain the rate constants \(\mathbf{K}_{f}\) and \(\mathbf{K}_{r}\). The forward rate constant \(\mathbf{K}_{f}\in\mathbb{R}^{N_{\mathbb{C}}\times N_{R}}\) is given by the Arrhenius expression  
\[\mathbf{K}_{f_{ij}}=A_{j}T_{i}^{\beta_{j}}\exp\left(-\frac{E_{j}}{RT_{i}}\right), \tag{5}\]  
where \(A\), \(\beta\), and \(E\) are vectors each of size \(N_{R}\) containing pre-exponential factors, temperature exponents, and activation energies respectively for the elementary reactions. These Arrhenius parameters are known to the user through the mechanism files. The natural logarithm of the forward rate (required in Equation (4)) usefully yields a form that can also be interpreted as a linear ANN layer,  
\[\log(\mathbf{K}_{f})=\mathbf{X}_{f}\mathbf{W}_{f}+B_{f},\text{ where} \tag{6}\]  
\[\mathbf{X}_{f}= \begin{bmatrix}\log T_{1}&1/T_{1}\\ \log T_{2}&1/T_{2}\\ \vdots&\vdots\\ \log T_{N_{\mathbb{C}}}&1/T_{N_{\mathbb{C}}}\end{bmatrix} ,\quad\mathbf{W}_{f} = \begin{bmatrix}\beta_{1}&\cdots&\beta_{N_{R}}\\ -E_{1}/R&\cdots&-E_{N_{R}}/R\end{bmatrix} ,\quad B_{f}= \begin{bmatrix}\log A_{1 }\\ \log A_{2}\\ \vdots\\ \log A_{N_{R}}\end{bmatrix} ^{T}.\]  
In Equation (6), \(\mathbf{X}_{f}\in\mathbb{R}^{N_{\mathbb{C}}\times 2}\) is the temperature-dependent input, \(\mathbf{W}_{f}\in\mathbb{R}^{2\times N_{R}}\) is a weight matrix consisting of temperature exponents and activation energies, and \(B_{f}\in\mathbb{R}^{1\times N_{R}}\) is a bias term of pre-exponential factors. In this sense, each row of the layer output \(\log(\mathbf{K}_{f})\) can be interpreted as a set of \(N_{R}\) Arrhenius neurons. The reverse rate constant \(\mathbf{K}_{r}\in\mathbb{R}^{N_{\mathbb{C}}\times N_{R}}\) is given by  
\[\mathbf{K}_{r_{ij}}=\mathbf{K}_{f_{ij}}/\mathbf{K}_{c_{ij}}, \tag{7}\]  
Figure 1: Illustrations of ANN-based formulations for \(N_{\mathbb{C}}=1\), \(N_{\mathbb{S}}=4\), and \(N_{R}=8\). Since \(N_{\mathbb{C}}=1\), input/outputs are vectors and cell indices are ignored. **(a)** Schematic of Equations (2) and (4). Exponential activation functions are used to produce forward/reverse rates. **(b)** Schematic of Arrhenius layer for forward rate constant (Equation (6)), which is interpreted as a bias term for the output of the forward rate layer in **(a)** (see Equation (4)). **(c)** Schematic of Gibbs layer equilibrium constant (Equation (11)). The schematics in both (b,c) produce the logarithm of the reverse rate constant, which is interpreted as a bias term for the output of the reverse rate layer in **(a)** (see Equation (4)). where \(\mathbf{K}_{c}\in\mathbb{R}^{N_{\mathrm{C}}\times N_{R}}\) contains the equilibrium rate constants. Since the expression for \(\log(\mathbf{K}_{f})\) is provided through the Arrhenius neurons (Equation (6)), the task of determining \(\log(\mathbf{K}_{r})\) required in Equation (4) is accomplished by considering only \(\log(\mathbf{K}_{c})\). The equilibrium constant for cell \(i\) and reaction \(j\) is [25]  
\[\mathbf{K}_{c_{ij}}=\left(\frac{p_{ref}}{RT_{i}}\right)^{\sum_{k}\
u_{kj}}\exp \left(\frac{\Delta S_{j}(T_{i})}{R}-\frac{\Delta H_{j}(T_{i})}{RT_{i}}\right), \tag{8}\]  
where \(\Delta S_{j}\) and \(\Delta H_{j}\) are changes in entropy and enthalpy for reaction \(j\), and \(p_{ref}\) is the reference pressure (1 bar). The logarithm of Equation (8) yields  
\[\log(\mathbf{K}_{c_{ij}})=\sum_{k=1}^{N_{\mathrm{S}}}\mathbf{\
u}_{jk}\left(- \mathbf{G}_{ik}+\frac{p_{ref}}{RT_{i}}\right), \tag{9}\]  
where \(\mathbf{G}\in\mathbb{R}^{N_{\mathrm{C}}\times N_{\mathrm{S}}}\) is the nondimensional Gibbs free energy matrix (hereafter referred to as the Gibbs matrix) obtained from the nondimensional enthalpy (\(\mathbf{H}\in\mathbb{R}^{N_{\mathrm{C}}\times N_{\mathrm{S}}}\)) and entropy (\(\mathbf{S}\in\mathbb{R}^{N_{\mathrm{C}}\times N_{\mathrm{S}}}\)) matrices. Each entry in the Gibbs matrix is determined from NASA polynomials which provide species enthalpy and entropy as tabulated functions of temperature.