# Numerical Simulation of Non-Linear Models of Reaction--Diffusion for a DGT Sensor
## 2 The Model
### Mathematical Model  
Consider the complexation of different metals and ligands in solution, that react according to the elementary schema represented in the Equation (7):  
\[\mathrm{A}+\mathrm{B}\ \xrightleftharpoons{k_{\mathrm{a}}}{k_{\mathrm{d}}}\ \ \mathrm{AB}\, \tag{7}\]  
where A and B can represent a metal, a ligand, or any combination of them, and \(k_{\mathrm{a}}\) and \(k_{\mathrm{d}}\) represent the kinetic constants of association and dissociation, respectively. The equilibrium conditions for this reaction are expressed in the form  
\[K=\frac{k_{\mathrm{a}}}{k_{\mathrm{d}}}=\frac{c_{\mathrm{AB}}^{*}}{c_{ \mathrm{A}}^{*}c_{\mathrm{B}}^{*}}\, \tag{8}\]  
where \(K\) is the equilibrium constant, and \(c_{i}^{*}\) indicates the concentration of species \(i\) in the solution (bulk concentration). When a DGT sensor is deployed in solution, the species diffuse to the resin (located between \(0<x<r\)), through the gel layer between \(r<x<r+g\) (see Figure 3). Inside the DGT, the concentration \(c(x,t)\) of each species is modified by diffusion, reaction with other species present in the solution, and by the possible reaction with the resin. Before presenting the mathematical formulation, we will make some assumptions. * Since the resin discs are made of complexing material embedded in the same type of gel that composes the diffusive layer, it is reasonable to consider that species that diffuse through the gel can penetrate the resin [8]. * Species that diffuse through the gel can bind the resin after. They do it by the described schema in Equation (9): \[\mathrm{A}+\mathrm{R}\ \xrightleftharpoons[k_{\mathrm{d,R}}]{k_{\mathrm{d,R}}} \mathrm{\ AR}\,\] (9) where R denotes the free-sites in the interior of the resin, and \(k_{\mathrm{a,R}}\), \(k_{\mathrm{d,R}}\) and \(K_{\mathrm{R}}=k_{\mathrm{a,R}}/k_{\mathrm{d,R}}\) represent the corresponding kinetic and stability constants. * When the material used for the resin is Chelex, the grains of resin are located mainly in the layer adjacent to the diffusion gel [9]. In a first approach, we consider that binding sites in the resin are uniformly distributed. * Because diffusion coefficients in the gel, the filter and diffusive boundary layer (DBL) are similar [10], the diffusive layer width \(g\) in Figure 3 includes the size of all these layers. * Migration forces or any electrostatic effects due to the charge of resin are not considered, i.e., the background salt is enough to screen these interactions. Under these conditions, diffusion is the most relevant transport mechanism in the system and, therefore, the transport equations for each species \(i\) can be  
The _mreac_ array is constructed in such a way that, if in the \(j\)-th reaction the substance 5 is combined with the 7 to produce 8, the indices of the row \(j\) will be \(5\;7\;8\); that is, the first two columns contain the components and the third indicates the formed compound. The _kreac_ matrix contains the same number of rows as the _mreac_ matrix, but only two columns. The first column indicates the value of the association constant (\(k_{\text{a},j}\)), and the second one the value of the dissociation constant (\(k_{\text{d},j}\)) of each \(j\) reaction, with \(j=1,2,\ldots,numreac\),  
\[kreac= \begin{pmatrix}k_{\text{a1}}&k_{\text{d1}}\\ k_{\text{a2}}&k_{\text{d2}}\\ \vdots&\vdots\\ k_{\text{aj}}&k_{\text{dj}}\\ \vdots&\vdots\end{pmatrix} \;. \tag{13}\]  
The strategy to solve the problem is to express the non-pure of species (i.e., species that are listed in the third column of _mreac_, because they are the result of a reaction), as a combination of the total concentrations of the pure substances, which are known for the system. The result is a system of nonlinear equations, which is solved using a variation of the Newton-Raphson method. Once the equilibrium problem is solved, that is to say, once the bulk concentration values are obtained for each species at \(t=0\) and \(x=r+g\), it is necessary to pose the problem of transport for an arbitrary number of chemical species.