# Optimizing Physics-Informed Neural Network in Dynamic System Simulation and Learning of Parameters
## 5 Computational Simulations of Dynamical Systems
### First-Order Irreversible Chain Reactions  
First-order irreversible chain reactions are a type of chemical reaction where a reactant undergoes a series of transformations to form a product, with the process continuing in a chain-like manner. A common example of such a reaction is the decomposition of hydrogen peroxide (H\({}_{2}\)O\({}_{2}\)) in the presence of an iodide ion as a catalyst. One of the most fundamental studies on chain reactions was conducted by [PERSON] and [PERSON] [PERSON] and [PERSON] (1935), who published a series of papers in the 1920s and 1930s on the theory of chain reactions. Consider the subsequent first-order irreversible chain reactions [PERSON] and [PERSON] (1935); [PERSON] (1935). \[\mathcal{A}\xrightarrow{k_{1}}\mathcal{B}\xrightarrow{k_{2}}\mathcal{C}\]  
The first step is a first-order reaction where species \(\mathcal{A}\) transforms into species \(\mathcal{B}\) at a rate determined by the rate constant \(k_{1}\). The second is another first-order reaction where species \(\mathcal{B}\) transforms into species \(\mathcal{C}\) at a rate determined by the rate constant \(k_{2}\). In both steps, the reaction rate depends on the concentration of a single reactant (either A or B), which is characteristic of first-order reactions and characterized by the following model:  
\[ \begin{split}\frac{dz_{1}(t)}{dt}&=-k_{1}(t)z_{1}(t )\\ \frac{dz_{2}(t)}{dt}&=k_{1}(t)z_{1}(t)-k_{2}(t)z_{2 }(t).\end{split}  \tag{6}\]  
where \(z_{1}\) and \(z_{2}\) symbolize the concentrations of chemical species \(\mathcal{A}\) and \(\mathcal{B}\), respectively and \(k_{1}\), \(k_{2}\) denote the rate constants which are the parameters required to be learned. Given that \(k_{1}=5\), \(k_{2}=1\) and \(z(t=0)=[1,0]\), then the observed data \(z_{1}\) and \(z_{2}\) are given in Table 1. The data was taken from reference [PERSON] and [PERSON] (1935). The analytical solution of (6) is given as follows:  
\[ \begin{split} z_{1}(t)&=e^{-5t}\\ z_{2}(t)&=\frac{5}{4}e^{-5t}(-1+e^{4t}),\end{split}  \tag{7}\]  
and the analytical derivatives of (7) are given by:  
\[ \begin{split}\frac{dz_{1}(t)}{dt}&=-5e^{-5t}\\ \frac{dz_{2}(t)}{dt}&=5e^{-t}-\frac{25}{4}e^{-5t}( -1+e^{4t}).\end{split}  \tag{8}\]  
The PINNs approach to solve and identify the parameters of the first-order irreversible chain reactions model is performed by finding the best network parameters, \(\omega\), which represents the biases and weights network that minimizes the loss function. We offer a physics-informed neural network (PINN) shown in Figure 3 with three networks to do this. \begin{table}
\begin{tabular}{c c c} \hline \hline \(t\) & \(z_{1}\) & \(z_{2}\) \\ \hline
0.0 & 1.00000 & 0.00000 \\
0.1 & 0.606531 & 0.372883 \\
0.2 & 0.367879 & 0.563564 \\
0.3 & 0.223130 & 0.647110 \\
0.4 &  
The first network outputs are \(z_{1 NN}(t_{n};\omega)\) and \(z_{2 NN}(t_{n};\omega)\), which admits \(t\) as the input data. The second and third networks learn the parameters \(k_{1}(t_{n};\Phi)\) and \(k_{2}(t_{n};\Phi)\) from the data. The neural network also obtains the optimal values for the model parameters. The \(z_{1}(t_{n})\) and \(z_{2}(t_{n})\) represent the loss function's training data. Finally, the first-order irreversible chain reaction model parameters' mean value was obtained using PINN with one layer of 40 neurons, 90,000 epochs, sigmoid activation function used, and \(10^{-3}\) learning rate. The PINN Algorithm 1 for learning the optimal parameters of the first-order irreversible chain reactions model (6) is shown above. We define the residual loss \(\zeta_{r}(\omega;\kappa_{r})\) and training loss \(\zeta_{t}(\omega;\kappa_{t})\) as follows:  
\[\zeta_{r}(\omega;\kappa_{r})=\frac{1}{\kappa_{r}}\sum_{i=1}^{2}\sum_{n=1}^{ \kappa_{r}}|r_{i}(t_{n})|^{2} \tag{9}\]  
where  
\[ \begin{split} r_{1}(t_{n})&=\frac{dz_{1 NN}(t_{n}; \omega)}{dt}+k_{1}(t_{n};\Phi)z_{1 NN}(t_{n};\omega)\\ r_{2}(t_{n})&=\frac{dz_{2 NN}(t_{n};\omega)}{dt}- \left(k_{1}(t_{n};\Phi)z_{1 NN}(t_{n};\omega)-k_{2}(t_{n};\Phi)z_{2 NN}(t_{n}; \omega)\right)\end{split}