Predicting Voltammetry Using Physics-Informed Neural Networks

We propose a discretization-free approach to simulation of cyclic voltammetry using Physics-Informed Neural Networks (PINNs) by constraining a feed-forward neutral network with the diffusion equation and electrochemically consistent boundary conditions. Using PINNs, we first predict one-dimensional voltammetry at a disc electrode with semi-infinite or thin layer boundary conditions. The voltammograms agree quantitatively with those obtained independently using the finite difference method and/or previously reported analytical expressions. Further, we predict the voltammetry at a microband electrode, solving the two-dimensional diffusion equation, obtaining results in close agreement with the literature. Last, we apply a PINN to voltammetry at the edges of a square electrode, quantifying the nonuniform current distribution near the corner of electrode. In general, we noticed the relative ease of developing PINNs for the solution of, in particular, the higher dimensional problem, and recommend PINNs as a potentially faster and easier alternative to existing approaches for voltammetric problems.


P hysics-informed neural networks (PINNs), introduced by
Raissi in 2018 to solve the Burger, Schrodinger, and Alan−Cahn equations among others, 1 form a class of neural networks that can integrate data and abstract mathematical operators, along with the laws of nature, to provide physically consistent solutions. PINNs have been applied widely in modeling, analysis, and parameter estimation to lithium-ion batteries 2−5 and fuel cells. 6−8 A PINN can also be informed by chemical kinetics 9,10 and thermodynamics 11 to solve the partial differential equations (PDEs) that describe diverse physical chemical models. With the growing application of PINN in scientific and engineering contexts, we note that there are no reports applying PINNs to solve electrochemical problems with coupled diffusional mass transport both in general and in particular in the context of voltammetry, the most generally applied electrochemical methodology. 12,13 Simulation of cyclic voltammetry conventionally employs finite difference, 14 finite element, 15,16 or random walk algorithms, 14 all needing discretization of simulation spaces leading to the difficulty that the requirements of discretization/simulation grow exponentially as simulations expand to higher dimensions. 17 In the following, a discretization-free simulation, empowered by data driven inference of PDEs using PINNs, of 1D and 2D cyclic voltammetry with Nernstian, no-flux, or fixed concentration boundary conditions is developed, offering a radically new approach to the modeling of voltammetry.
Cyclic voltammetry applies a time dependent potential, E, as a triangular waveform to a working electrode with measurement of the resulting current as a function of the applied potential resulting in a "voltammogram" in the form of a plot of current vs potential. The proofs-of-concept in this article focus on the simple electrode processes of the form: where A and B are stable, solution phase species. We assume that mass transport in solution to the macro electrode can be described as diffusion in one dimension with Fick's second law of diffusion: 18 Here D A and D B are the diffusion coefficients for A and B respectively. In the present work, the diffusion coefficients of both species are assumed to be equal, so solving only for species A is sufficient for simulation of cyclic voltammetry since it is easily shown that for this condition the sum c A + c B = c A * where c A * is the bulk concentration of A and the bulk concentration of B is assumed to be zero. We further assume that the boundary condition on the surface of electrode can be described using the Nernst equation: where E and E f 0 , are, respectively, the applied potential and the formal potential of the A/B couple. R, T, and F are the gas constant, temperature and the Faraday constant, respectively. For cyclic voltammetry, the triangular waveform of potential E is expressed as  (4) where E i is the starting potential of the forward scan, E switch is the potential at which the triangular sweep reverse direction, t switch is the start time of the reverse scan, and ν is the potential scan rate (V/s). Positive and negative potential scan rates are usually chosen corresponding to the study of reduction and oxidation processes, respectively. We first apply PINNs to predict two problems in cyclic voltammetry involving one spatial dimension (x). In the first of these, we consider cyclic voltammetry at a macroelectrode, specifically a disc electrode of radius, r e , with semi-infinite diffusion to allow comparison with the well-known response reported in many textbooks. 12,21 Second, we examine the thinlayer cyclic voltammetry corresponding to one-dimensional diffusion within a fixed and finite volume such as applied within thin layer cells 22,23 as are commonly encountered in spectro-electrochemistry. 24 We then, second, consider two problems involving two-spatial dimensions, (x, y). The first is cyclic voltammetry at a microband electrode where comparisons with previous finite difference simulations can be made. Second, we investigate a novel problem involving the twodimensional diffusion to the edges of a square electrode, as shown in Figure 1. The continuous time model proposed by Raissi et al. is used. 1 The modeling parameters for use in the PINNs are first converted to dimensionless form. Dimensionless parameters (see Table 1) are used to remove the dependence on bulk concentration, c*, electrode size (radius, r e , for the disc electrode; the width, w, for the microband electrode; and the edge length, a, of the square), and diffusion coefficient, D, so predictions are general as one prediction of the PINNs is compatible with any set of c*, electrode size, and D. Using dimensionless parameters can also reduce the vanishing/ exploding gradient problem commonly encountered during training of neural networks. 25 The range of scan is noted as [θ i , θ switch ], and θ i and θ switch are the starting potential and reverse potentials, respectively. The time for the full scan is thus = where σ is the dimensionless scan rate. The maximum spatial distance in the coordinate X for simulation is guided by Einstein's work on Brownian motion: 26 the rootmean-square displacement of a particle is = x Dt 2

RMS
. To ensure that the outer boundary is sufficiently remote as not to be affected by diffusion the outer boundary of the simulation, x sim is located at Dt 6 sim in dimensional form and equivalent to = X T 6 sim sim in dimensionless form. 27 At the electrode surface, since the dimensionless concentrations of A and B always sum to 1 at all points in space within the equal diffusion coefficient approximation, the Nernst equation predicts the dimensionless concentration of A as a function of dimensionless potential θ: The PINNs modeling of 1D voltammetry requires prediction of the evolution of the dimensionless concentration of A, C(T,X), as a function of dimensionless time T and dimensionless distance X from the electrode surface and is described by the dimensionless diffusion equation and boundary conditions in the following form: represents the temporal and one-dimensional spatial domains, respectively. Since the diffusion coefficients of A and B are assumed equal, the dimensionless diffusion coefficients are always 1 and so do not appear in the diffusion equation. Equations 6.2 and 6.3 are Dirichlet boundary conditions at the surface obeying the Nernst equation and at the outer boundary with a fixed concentration, respectively. Equation 6.4 represents the initial state at T = 0. Four training data sets are required to enforce the physical laws in the form of the diffusion equation and boundary conditions. For example, to enforce eq 6.1, a set of N collocation N is generated using a random uniform distribution throughout the temporal−spatial domain. Similarly, the data points for the Nernst boundary condition implied by eq 6.2 is also a set of N collocation points {T i ,0 } i=1 N randomly uniformly distributed only in the temporal domain. The data points for eq 6.3 and 6.4 Unlike a conventional neural network trained to predict C(T,X) from (T,X) with an enormous amount of known The Journal of Physical Chemistry Letters pubs.acs.org/JPCL Letter concentrations in × Ω X , in a PINN, a dense neural network is used to approximate the unknown solution C(T,X) with only known concentrations at the boundaries (X = 0 or X sim ) and for the initial state (T = 0). More importantly, eq 6.1 has to be satisfied for every point inside the whole × Ω X domain. To enforce the physics given by eq 6.1, and the known concentrations at the boundary and initial state, a loss function is composed as a linear combination of four mean square error (MSE) functions: where w j are hyperparameters for training to balance the weights of each MSEs since each MSEs may have different numerical scales. The first MSE f term represents the error of enforcing the diffusion equation as where C i is the concentration predicted by the neural network are the gradients calculated by the machine learning framework. The three other MSEs are the errors of the predicted concentrations at the boundary. For example, MSE surf represents the error of predicting the concentrations at the surface of electrode as and MSE outer and MSE ini are the errors of predicting the concentration at the outer boundary and at the initial state when T = 0. During training, the optimizer of the neural network minimizes the combined loss function by tuning the weights and biases of the neural network. Adam 28 was used as the optimizer with a learning rate of 10 −3 .
After training, the neural network predicts C(T,X) for cyclic voltammetry. For cyclic voltammetry with a dimensionless scan rate of σ = 40, the concentration is plotted as a function of T and X in Figure 2a. Figure 2a shows that C decreases with time near the surface of electrode (X = 0) when 0.25 < T < 0.75, which is expected since the overpotential θ is negative between 0.25 < T < 0.75 so reduction of A to B at the surface of electrode surfaces lowers the surface concentration. When T > < 0.75, A is regenerated via oxidation of B to A, observing a local high concentration of A near the electrode surface. The , 0 and dX is a small spatial step. Figure 2b compares the voltammogram predicted by PINN with simulation using the finite difference method. 14 The forward scan peak flux is also compared with the Randles−Sěvcǐ́k equation 29,30 in dimensionless form as A PINN can also be applied to solve cyclic voltammetry with a Neumann boundary condition which we illustrate for thinlayer cyclic voltammetry. Thin-layer cyclic voltammetry is a c j , D j are respectively the concentration and diffusion coefficients of species j. r e , w, b, and a are the radius of the disc electrode, the width and the length of the microband electrode, and the edge length of the square electrode, respectively. The Journal of Physical Chemistry Letters pubs.acs.org/JPCL Letter different from normal cyclic voltammetry by having a constrained diffusion layer. In experimental practice the constraint is provided by solid wall opposite the electrode through which material cannot pass. 31,32 Mathematically this corresponds to a no-flux boundary condition at the outer boundary of simulation. The diffusion equation and boundary conditions can be expressed as where the thin layer cell (dimensionless) thickness, δ, also the outer boundary of simulation, defines the scale of the cell thickness to the extent of the diffusion layer via δ λ = T sim where λ is a factor signaling thin-layer behavior (small λ) and semi-infinite behavior (large λ). The spatial domain Ω X is defined as where X i = δ represents the outer boundary for the PINN prediction.
Using PINN, the electrochemically reversible cyclic voltammetry when σ = 40 was simulated corresponding to a thin layer factor λ = 0.035. The temporal−spatial concentration profile predicted by the PINN is shown in Figure 3a, and the corresponding cyclic voltammogram is shown in Figure 3b. Figure 2a shows the thin-layer concentration pattern with A almost fully converted to B when 0.25 < T < 0.75.
To validate the results of PINN for thin layer cyclic voltammetry, the peak current and voltammogram is compared with analytical expression derived by Hubbard et al. 32 converted to dimensionless form as where J p is the peak flux for forward scan and J thin layer describes the shape of voltammogram as a function of dimensionless potential, θ, and the upper and lower signs refer to the cathodic and anodic scans, respectively. As is evident in Figure 3b, the PINN predicted voltammogram closely agrees with the voltammogram predicted by the analytical expression, suggesting that PINN can accurately predict thin-layer voltammetry. To further validate the model, the transition of thin-layer behavior to semi-infinite behavior with increasing λ is illustrated by plotting the dependency on λ of the peak flux, J p , and the peak to peak separation, θ pp . With increasing λ, J p is expected to transition from the Hubbard equation to the Randles−Sěvcǐ́k equation and θ pp is expected to increase from θ pp = 0 for thin-layer to θ pp = 2.218 for semi-infinite behavior. 14 The plot of J p vs λ and θ pp vs λ predicted by PINN is shown in Figure 4 and compared with the predictions from simulations using the finite difference method. 14 The excellent agreement shows that the PINN approach to thin-layer cyclic voltammetry worked well. Figure 4 shows that both PINN and the finite difference method predicts that when λ > 0.8, thin-layer cyclic voltammetry converges to semi-infinite cyclic voltammetry.
To further illustrate and validate the potential applications of PINN in electrochemistry, we explore the PINN prediction for cyclic voltammetry of a microband electrode under semiinfinite diffusion, aiming to predict C(T,X,Y) on a temporal-2D spatial domain (14) to account for diffusion in 2D. To enforce eq 14, a set of N collocation N are necessary. A mix of no-flux and fixed concentration boundary conditions are also required to describe the system and can be found in the Microband Electrode Voltammetry section in the Supporting Information. To improve optimization and generalization of two-dimensional problems, a learning rate scheduler was utilized to decrease the learning rate by 1% every epoch after 400 epochs. 33 To reduce the collocation points in the entire domain, the outer boundaries were reduced to = = X Y T 2 sim sim sim without significant influence to the results. PINN prediction at σ = 4 is performed to reveal the convergent diffusion expected at the microband electrode at which is reported accurate to within 2.1% error. The voltammogram can be extracted from the gradients at the electrode surface in the concentration profiles in the temporal domain, then filtered with a Savitzky−Golay filter 35 to reduce high-frequency noise. Figure 5b compares the PINN predicted voltammogram with the Aoki equation. The peak flux predicted by PINN is 3.3% higher than the Aoki equation, showing the PINN can solve the temporal−spatial problem for 2D simulation of microband electrode within an acceptable level of error. The PINN predictions take approximately 4 h with Nvidia P100 16G GPU. Last, we employ a PINN to generate new physical insights into the current distributions at nonuniformly accessible electrodes under electrochemically reversible conditions. Specifically, we investigate a model the previously unexplored voltammetric case in which species A and B undergo twodimensional diffusion in the (x, y) plane with a square electrode located flat in the plane so that electrolysis is confined to the edges of the electrode. In this way, the consequences to the electrode current distribution caused by the increased diffusional accessibility at the electrode corner were compared to the location on the edges distant from the corner. Interestingly, a clear maximum in the local flux will be seen, but not at the electrode corner as might be expected, and the insights have value for nanoparticle electrochemistry. 36−38 Specifically, we explore a PINN solution of cyclic voltammetry at the edges of the square electrode. As above, the twodimensional diffusion equation is enforced as the mode of mass transport for PINN. Two computational subdomains of diffusion equations are configured to obtain better accuracy and faster training. 39 The square electrode has two electrochemically reaction edges with a Nernstian boundary condition. Details of implementation of other no-flux and fixed concentration boundary conditions and an illustration of the PINN domains can be found in the Voltammetry at the Edges of a Square Electrode section in the Supporting Information. The PINN prediction of the concentration profile and cyclic voltammetry at the square electrode with two electrochemically active edges were performed at σ = 40, with the dimensionless edge length set as 1. Figure 6a illustrates the concentration profile at = T T sim 1 2 and θ = −10. Figure 6b shows the flux density at the edges when = T T sim 1 2 as a  The overlapping flux densities on the two edges reflect the symmetry of the square electrode, and thus, they partly validate the predictions. Interestingly, the magnitude of the flux density is largest for an X/Y coordinate of around 0.8, instead of exactly at the corner of the particle. Figure 6c shows the corresponding voltammograms inferred for the two edges that are almost identical, again confirming the validity of the PINN approach. The occurrence of the maximum current near but not at the corner was unexpected and shows the value of PINN simulations for extracting new semiquantitative physical insights. In the present case the location at the maximum reflects the increased diffusional accessibility near the corner as expected but also highlights, as inferred with hindsight, that the competition between the two edges plays a significant role. In summary, in the present work we have developed PINN to solve four problems: two one-dimensional cases including voltammetry with a semi-infinite or a thin-layer boundary condition and two two-dimensional simulations including the microband electrode and the square electrode. The resulting voltammograms are, where available, compared with analytical expressions or voltammograms simulated using finite difference method, proving that PINNs can correctly predict voltammetry, without using any discretization, but with only information on the underlying laws of physics, boundary conditions, and the initial state. When training PINNs to predict voltammograms, we found three major advantage of PINNs. First, with well-established neural network framework like TensorFlow or PyTorch, constructing a neural network is far less daunting than discretizing equations for finite difference or finite element methods. The implication of this is that the investigator can focus on considering the physical models rather than on the mechanics of solution. Instead they simply need to formulate the relevant transport equations and boundary conditions so facilitating a greater range of models to be explored. Second, we found that debugging and modifying PINN programs are relatively easy and relatively rapid. Users can pause the neural network with model check point and generate the concentration profile for visual or mathematical inspection. By generating new data sets and slightly modifying the loss function, PINNs can easily adapt to new prediction tasks. Third, PINNs, as a subclass of neural network, can be easily trained on GPU or CPU with minimal modification and less picky regarding computer hardware and are usually trained on GPU to take advantage of recent advances in GPU computing powers. In addition, PINNs can utilize transfer learning from trained neural network for possibly significant time saving. PINN can be applied to higher dimensions with greater ease, though exponentially more collocation points are necessary to spread the higher dimensional domain. Furthermore, hyperparameters for neural networks, like epochs, learning rate, loss weights, and choice of optimizers can also be tuned for better results. The success of PINN in predicting cyclic voltammetry as shown above signals further possible applications to solution of mass (or heat) transfer problems probably coupled with chemical or electrochemical kinetics, providing a powerful (and likely simpler) alternative to the conventional finite difference or finite element methods.

■ SIMULATION METHODS
The PINN program was written in Python using the TensorFlow framework on a workstation with Intel 6800K CPU with 32 GB of RAM and a Nvidia P100 16 GB graphic card. The program is available at https://github.com/ nmerovingian/PINN-CV with weights of neural networks for user's convenience. The validation voltammogram for 1D voltammetry was written in Python and the diffusion equation was solved using finite difference method by discretization of both temporal and spatial domains, and the resulting multidiagonal matrix was solved using the Newton−Raphson method. 14 ■ ASSOCIATED CONTENT