Elsevier Editorial System(tm) for Journal Of Computational Physics Manuscript Draft Manuscript Number: Title: Do we really need a large number of particles to simulate bimolecular reactive transport with random walk methods? A kernel density estimation approach Article Type: Regular Article Keywords: Reactive transport; Particle tracking; Kernel density estimators; Geochemical processes Corresponding Author: Mrs. Maryam Rahbaralam, M. S. Corresponding Author's Institution: Universitat Politecnica de Catalunya First Author: Maryam Rahbaralam, M. S. Order of Authors: Maryam Rahbaralam, M. S.; Daniel Fernández-Garcia, PhD; Xavier Sanchez-Vila, PhD Abstract: Groundwater reactive transport models are an essential tool for the analysis of coupled geochemical processes in Earth Systems. On a molecular level, chemical reactions are the result of collision and subsequent recombination of the molecules present in the system. One way to deal with reactive transport is using a continuum mechanics approach; for example, in a well-mixed system, reactions are a function of reactant concentrations. An alternative is to use a Lagrangian approach, by tracking all molecules and specifying reactions in terms of collision theory. A computationally efficient family of methods to solve the reactive transport problem is based on Particle Tracking (PT). While the number of particles in most realistic applications is in the order of 10^6 �- 10^9, the number of molecules even in diluted systems might be in the order of fractions of the Avogadro number. Thus, each particle actually represents a group of potentially reactive molecules. The use of a low number of particles may result not only in loss of accuracy, but also may lead to an improper reproduction of the mixing process, limited by diffusion. Recent works have used this effect as a proxy to model incomplete mixing in porous media. In this work, we propose using a Kernel Density Estimation (KDE) of the concentrations that allows getting the expected results for a well-mixed solution with a limited number of particles. The idea consists of treating each particle as a sample drawn from the pool of molecules that it represents; this way, the actual location of a tracked particle is seen as a sample drawn from the density function of the location of molecules represented by that given particle, rigorously represented by a kernel density function. The probability of reaction can be obtained by combining the kernels associated to two potentially reactive particles. We demonstrate that the observed deviation in the reaction vs time curves in numerical experiments reported in the literature could be attributed to a deficient estimation of the concentrations based on particles reconstruction, and not to the occurrence of true incomplete mixing. We further explore the evolution of the kernel size with time, linking it to the diffusion process. Our results show that KDEs are powerful tools to improve reactive transport simulations, and indicates that incomplete mixing in diluted systems should be modeled based on alternative mechanistic models and not on a limited number of particles. Suggested Reviewers: David Benson PhD Associate Professor, Department of Geology and Geological Engineering, Colorado School of Mines
[email protected] Alexandre Tartakovsky PhD
Scientist, Pacific Northwest National Laboratory
[email protected] Wolfgang Nowak PhD Head , Hydromechanics and Modelling of Hydrosystems, Institute for Modelling Hydraulic and Environmental Systems, Universität Stuttgart
[email protected] Philippe Renard PhD Head , The Centre for Hydrogeology and Geothermics of University of Neuchâtel
[email protected] Philippe Gouze PhD Géosciences Montpellier, Université de Montpellier
[email protected]
UPC, Campus Nord Edif. D2, Barcelona 08034 www.h2ogeo.upc.es Telf. 93.401.68.90 Fax. 93. 401.72.51 To: Journal of Computational Physics Barcelona, June 10, 2015 Dear Editor: Manuscript title: “Do we really need a large number of particles to simulate bimolecular reactive transport with random walk methods? A kernel density estimation approach” by M. Rahbaralam, D. Fernàndez-Garcia and X. Sanchez-Vila Hydrogeology Group, Dept. Geotechnical Engineering and Geosciences, Universitat Politecnica de Catalunya, Jordi Girona 1-3, 08034 Barcelona, Spain Corresponding author: Rahbaralam, M. Jordi Girona 1-3, UPC Campus Nord, 08034 Barcelona, Spain Phone: +34 93 401 1698 Fax: +34 93 401 7251 e-mail:
[email protected] A major challenge in reactive transport modeling is to properly simulate the interaction of the reactants in dynamic geochemical systems. Random walk particle tracking methods provide a computationally efficient and adaptable approach to simulate solute transport. However, to properly simulate non-linear reactions, an unfeasible number of particles is required. On the other hand, a finite number of particles leads to a poor-mixed system limited by diffusion. Recent works have used this effect to actually model incomplete mixing in naturally occurring porous media. In this work, we demonstrate that this effect in most cases should be attributed to a deficient estimation of the concentrations and not to the occurrence of true incomplete mixing. To illustrate this, we show that a Kernel Density Estimation (KDE) of the concentrations can approach the well-mixed solution with a small number of particles. KDEs provide weighting functions of each particle mass that expands its region of influence, hence providing a wider region for chemical reactions with time. Importantly, simulation results also show that KDEs are powerful tools to improve state-of-the-art simulations of chemical reactions. Respectfully, Daniel Fernàndez-Garcia Civil Engineering School, Barcelona Technical University of Catalonia Spain Significance and Novelty of this paper
Do we really need a large number of particles to simulate bimolecular reactive transport with random walk methods? A kernel density estimation approach M. Rahbaralam, D. Fern`andez-Garcia and X. Sanchez-Vila Hydrogeology Group, Dept. Geotechnical Engineering and Geosciences, Universitat Politecnica de Catalunya, Jord Girona 1-3, 08034 Barcelona, Spain Abstract Groundwater reactive transport models are an essential tool for the analysis of coupled geochemical processes in Earth Systems. On a molecular level, chemical reactions are the result of collision and subsequent recombination of the molecules present in the system. One way to deal with reactive transport is using a continuum mechanics approach; for example, in a well-mixed system, reactions are a function of reactant concentrations. An alternative is to use a Lagrangian approach, by tracking all molecules and specifying reactions in terms of collision theory. A computationally efficient family of methods to solve the reactive transport problem is based on Particle Tracking (PT). While the number of particles in most realistic applications is in the order of 106−109, the number of molecules even in diluted systems might be in the order of fractions of the Avogadro number. Thus, each particle actually represents a group of potentially reactive molecules. The use of a low number of particles may result not only in loss of accuracy, but also may lead to an improper reproduction of the mixing process, limited by diffusion. Preprint submitted to Journal of Computational Physics June 10, 2015 *Manuscript Click here to view linked References
Recent works have used this effect as a proxy to model incomplete mixing in porous media. In this work, we propose using a Kernel Density Estimation (KDE) of the concentrations that allows getting the expected results for a well-mixed solution with a limited number of particles. The idea consists of treating each particle as a sample drawn from the pool of molecules that it represents; this way, the actual location of a tracked particle is seen as a sample drawn from the density function of the location of molecules represented by that given particle, rigorously represented by a kernel density function. The probability of reaction can be obtained by combining the kernels associated to two potentially reactive particles. We demonstrate that the observed deviation in the reaction vs time curves in numerical experiments reported in the literature could be attributed to a deficient estimation of the concentrations based on particles reconstruction, and not to the occurrence of true incomplete mixing. We further explore the evolution of the kernel size with time, linking it to the diffusion process. Our results show that KDEs are powerful tools to improve reactive transport simulations, and indicates that incomplete mixing in diluted systems should be modeled based on alternative mechanistic models and not on a limited number of particles. Keywords: Reactive transport, Particle tracking, Kernel density estimators, Geochemical processes 1. Introduction The complexity associated with the simulation of contaminants in polluted groundwater systems, including geochemical and microbiological effects, requires developing reliable, as well as predictive, solute transport mod- 2
els. A major challenge in this area is the incorporation of the interaction of the reactants facilitated by pure diffusion into a dynamic geochemical system. This problem has traditionally been addressed in porous media using a diffusion-reaction equation. The main interest has typically relied on finding or fitting the proper parameters that describe the experimental or field observations. This generic problem, posed in terms of the spatial and temporal distribution of reactants and products, has practical applications especially in the groundwater remediation context, where the choice of remediation strategy is based on accurate modeling of the anticipated degradation rate of the contaminants. In most natural systems, the rate of reactions between the chemical species is limited by mixing because the molecules can only react when they come into physical contact to allow the corresponding bonds to occur. In well-mixed systems, like a stirred laboratory beaker, the spatial fluctuations in concentrations of the chemical species are negligible, and the rate of reaction is spatially uniform. However, if the mixing process is slow in comparison with the reaction rate, a mixing-limited regime will appear. In this regime, and when the initial spatial distribution of reactants is heterogeneous, the magnitude of concentrations as a function of time fluctuate significantly and segregated areas (islands) of one reacting species start to form in the domain [3,25]. This segregation of the species is dictated by the reduced area of contact between reactants and was described from theoretical and numerical viewpoints several decades ago [15,13]. Thus, it comes as no surprise that the prediction of reactions based on the well-mixed assumption associated with the classical transport and reaction equations within systems ranging 3
from homogeneous systems [10,20] to heterogeneous systems [27] are bound to failure. The study of solute transport driven by diffusion is one of the classical problems where the dichotomy between Eulerian and Lagrangian approaches has been traditionally well explained. An Eulerian approach implies setting the problem in terms of concentration of reactant species, and then postulating some macroscopic laws (either empirical or deduced from thermodynamic considerations) to describe the reaction rate based on such concentrations. The problem is then formulated from macroscopic mass balance equations such as, for example, the advection-dispersion-reaction equation (ADRE). Concentration is a macroscopic quantity (mass per unit volume) and thus it has no sense when the volume reduces to zero. An alternative is to study the process at the molecular level, theoretically tracking the movement and fate of each individual molecule, within a Lagrangian framework [7,8,9]. This alternative is obviously unfeasible, as even minute concentrations result in a extremely large number of molecules (1 mol equals 6.02×1023 molecules); furthermore, equations of the continuum are no more applicable, and reactions should be assessed from collision theory. Particle Tracking Methods (PTM) try to combine both approaches to provide an efficient solution to reactive transport simulations in the subsurface. The idea is to split the total mass into a number of particles (typical orders are 106−109), many orders of magnitude lower than the actual number of molecules, and devise a way to reconstruct the spatial and temporal distribution of concentrations of the different species from the location of particles at any given time. This methodology has obvious drawbacks such as: 4
(1) the estimation of macroscopic quantities (concentrations) from discrete particle information being a non-unique process, and (2) the need to set up reactive rules applied to a finite number of particles so that, when upscaled, they properly represent reaction rules observed at the macroscale. An additional drawback would be the modeler’s choice of the number of particles, and more, the meaning of the concept particle itself. Regarding the first problem, recently an optimal method for the reconstruction of concentrations and their functionals based on Kernel Density Estimators (KDE) was developed [6]. This method has been successfully applied to estimate concentrations of conservative and reactive species [11], heavily-tailed breakthrough curves [18], and reaction rates in precipitation/dissolution problems [6]. Regarding the second point, the translation of macroscopic rules to PTM, a technique was proposed by Benson and Meerschaert [1] to study reactive transport for a bimolecular reaction, introducing an algorithm that accounts for the probability that two individual particles react as a function of their relative distance; this method was an extension of the original algorithm proposed by Gillespie [7] to simulate batch reactions in a stochastic framework at the molecular level. The method avoids the need to continuously reconstruct concentration maps during the course of the simulation for each individual time step, considered the main disadvantage of PT methods [22,4]. Here we combine these two ideas to develop a KDE model that can be directly used to study bimolecular reaction in diffusive problems. The main idea is to use Kernels to provide a new weighting functions for particles to interact following Benson and Meerschaert [1] approach. In this case, when 5
particles are transformed into another species or mineral, the shape of the Kernel automatically adjust, expanding its region of influence and the region of interaction between particles [6]. This method increases the number of particles that could react at a given time. The introduction of this expanding Kernel provides some insights into a problem that has been recently raised in the literature. Benson and coworkers have studied the evolution of concentration with time in a bimolecular reactive problem susceptible to incomplete mixing [1,17,3,2]. These authors represented incomplete mixing by setting up a low number of particles into the reactive system; the lowest the number of particles the earliest reaction became limited. While this is an intelligent approach, we would like to stress that it is only valid when the number of molecules is really limited, but not in subsurface geochemical applications where the number of molecules available for reaction is always very high. We thus associate incomplete mixing in some applications to the combination of low number of particles combined with an estimation of concentrations based on the particles having a zero support size .e.g., [19,22]. We contend that the limited number of particles should not be considered as a tool for generating incomplete mixing systems. To make this point we show how our approach based on the inclusion of optimal KDEs allows reproducing complete mixing up to a very small number of particles. We content then that incomplete mixing in diluted systems should be modeled based on alternative mechanistic models (see [23]) and not on a limited number of particles. The paper is structured as follows. First, Section 2sets out the problem and the numerical approach proposed for the analysis of species concen- 6
Using this approach, the concentration c(x, t) of a given species at a given time tcan be reconstructed from the location of the particles present in the system by c(x, t) = N(t) X p=1 mp h(t)Kx−Xp(t) h(t),(9) where N(t) is the number of particles at time t,Xpis the particle location, h is the bandwidth (area of influence), and Kis a moving weighting function centered at the particle location chosen from functions of unitary area, i.e., ZK(τ)dτ = 1.(10) Optimal reconstruction involves a proper choice of the hparameter to account for both the diffusion process and the continuously diminishing number of particles in the system with time. In contrast to the traditional box model [24] which introduces discontinuities at the box edges, kernel estimator (9) produces smooth functions of space. These kernel functions define the region of influence of each particle. The kernel shape depends on the choice of the bandwidth or support size hand the type of kernels. A variety of kernel functions can be used, among them, Gaussian kernels are usually preferred for mathematical advantages [18]. 2.4.1. The optimal area of influence As stated before, Kernels can be seen as a way to introduce into the solution the effect of using a subset of particles to represent a very large number of molecules. The larger the degree of undersampling, the more information should be conveyed into the kernel estimator. The degree of 13
smoothing or the area of influence around a particle is controlled by the parameter h. If the number of particles is very large, there is no real need for kernels, and hshould be very small. On the contrary, hshould increase when the number of particles is not sufficient to account for a proper estimation of the spatial distribution of the concentrations. In general, a small support size combined with a finite number of particles leads to noisy estimates and the fluctuation of concentrations. Contrarily, an increase in the support size tends to oversmooth the estimated concentration distribution. Thus, an optimum choice of the support size, hopt, exists. Choosing it should be based on an objective criterion about the reconstruction effort, minimizing the variance error while controlling the biasedness in the estimation. Park and Marron [16] found the optimum bandwidth as hopt =R N−1/5,(11) where Ris given as R= ( kKk2 2 kp00(x)k2 2(µ2(K))2)1/5,(12) µ2(K) is the second moment of K,p00(x) is the second derivative of the concentration normalized by the total mass in the system, and the symbol k.k2 2is the L2-norm operator, i.e. kp(x)k2=Rp(x)2dt. It is clear that the optimal bandwidth hopt in (11) grows inversely proportional to the number of particles; the smaller the number of particles, the larger the bandwidth size. This feature is particularly beneficial for developing a chemical reaction model, as mentioned later in the paper. The second derivative of the density function p00(x) needs to be also estimated. Several methods can be used for 14
this purpose: (1) rule-of-thumb methods, (2) cross-validation methods, and (3) plug-in methods (see recent reviews of these methods in Ref. [12,16]). Following a recent work by Fern`andez-Garcia and Sanchez-Vila [6], we hereby employ the plug-in method to estimate the optimal bandwidth hopt. 3. The KDE-based chemical reaction model The DB model is characterized by a constant in time area of influence characterized by a constant diffusion, see Fig. (1). Therefore, when the number of particles is very low (occurring at late times), the probability of collocation is also very low and the segregation of particles of a given type (either Aor B) start occurring [1]. Alternatively, the KDE based method provides an area of influence that increases when particles are sparsely distributed in space, see equation (11). This results in an enhanced probability of reaction and in an overall reaction rate approaching to the well-mixed solution, even with a small number of particles. If the initial concentrations of the two reactants are equal, it is also logical to assign the same standard deviation to all of them, actually given by σ=hopt. This dynamic bandwidth in the KDE-based model implies a different probability of reaction at each time step, preventing the formation of segregated areas of particles. The actual expression for the probability of reaction should follow rigorously the principles of the law of mass action, and also be proportional to the thermodynamic rate kfas well as to the co-location probability density associated with the distance between particle pairs. Based on these principles, the probability of reaction for the KDE- based model is obtained as 15
P=kfmp∆t PKDE(r),(13) where PKDE is the convolution of the two Gaussian densities of particles A and Bbased on hopt. This convolution is a Gaussian function with zero mean and variance equal to 2(hopt)2, PKDE(r) = 1 2hopt√πexp(−r2 (2hopt)2).(14) From (14), the probability of reaction decreases by increasing hopt, preserving the unitary area under the co-location probability density. In other words, expanding the influential area of each particle by hopt comes at the expense of decreasing the probability of reaction. On the other hand, as demonstrated later, this effect is compensated by the increase in the number of potentially reactive pairs, as each individual particle samples a larger area for the presence of particles. This is particularly beneficial to avoid the segregation of particles resulting in artificial poor mixing. 4. Simulation results 4.1. DB model We first intend to simulate reactions with the DB model as a way to compare later on the performance of the KDE model with the DB model. A 1-D domain of size Ω = 64 (normalized units) is considered. Simulations are performed for 1000 time steps. The different scenarios analyzed combine different number of initial particles N(always equal for species Aand B), with two diffusion coefficients D= 10−2and D= 10−5. The remaining 16
parameters are set as: [A0] = [B0] = 1, kf= 50, and ∆t= 0.4. All values throughout the paper are reported in normalized units. Figure 2shows the normalized concentration [A0]/[A] as a function of the normalized time t0, defined as t0= [A0]kft. For comparison purposes, the analytical solution of the well-mixed system in (5) is also provided. At early times, due to the presence of a large number of particles in the system, the numerical and analytical solutions are identical. Therefore, the number of particles plays a negligible role and the actual concentration is closely approximated by the well-mixed solution, controlled simply by the thermodynamic rate coefficient kf. However, at late times, a deviation from the analytical solution occurs, as chemical reactions among particles become limited by diffusion. In this diffusion-limited regime, islands of segregated particles (only one of the two species present) start to form, leading to a poor-mixed solution. A lower number of initial particles or a smaller diffusion constant enhances particle segregation and thereby the deviation from the well-mixed solution. These results are in a good agreement with those presented by Benson and Meerschaert [1]. 4.2. KDE model To illustrate the potential of our proposed KDE model, a simulation of the irreversible chemical reaction is performed with a diffusion constant of D= 10−2and an initial number of particles of N= 4000. The rest of the parameters are chosen equal to those used in the previous section 4.1. Figure 3 shows the comparison between the KDE and two DB models, as well as the analytical solution. Results demonstrate that the KDE model approaches the well-mixed analytical solution in a wider range of times, resulting in a 17
100101 10 2103 10−3 10−2 10−1 100 Time Normalized concentration [A0]/[A] N=4000; D=10−5 N=400; D=10−2 N=4000; D=10−2 N=40000; D=10−2 Analytical solution Figure 2: Normalized concentration as a function of normalized time using the DB model. Analytical solution of the well-mixed system is also plotted for comparison purposes. The time where deviation is observed depends on the number of particles that were initially in the system. Notice that when particles are used to represent a group of molecules, the actual number used in the simulations is a modeler’s choice. 18
considerably lower dependency of the solution on the number of particles with respect to the DB model. In fact, the simulation results for N= 4000 using the KDE model follows closely the results of the DB model with N = 40,000. This is an obvious enhancement of the classical chemical reaction model, as reaction rates are predicted using a noticeable lower number of particles. 10010 1 10 2103 10−3 10−2 10−1 100 Time Normalized concentration [A0]/[A] N=4000, DB model N=4000, KDE model N=40000, DB model Analytical solution Figure 3: Normalized concentration as a function of normalized time using the KDE model, two DB models with different number of particles, and the corresponding analytical solution. To further illustrate the behavior of the KDE model, we perform additional simulations with different number of particles being present at time zero. The results in Fig. 4indicate that the decay of concentration of reac- 19
tants is significantly less sensitive to the number of particles as compared to the behavior of the DB model, c.f. Fig. 2. As the solution is almost independent of the number of particles, Ncan be adopted by the modeler a priori solely based on the computational effort needed for the application, rather than on its potential influence on the solution. Indirectly it also implies that it is possible to actually use a lower number of particles to achieve a given accuracy in the solution. 100101102103 10 − 3 10 − 2 10 − 1 100 Time Normalized concentration [A0]/[A] N=10000 N=5000 N=4000 N=2000 N=1000 Analytical solution Figure 4: Normalized concentration as a function of the normalized time using the KDE model for a varying number of particles representing the initial mass. The solution is quite insensitive to the choice of number of particles being initially present in the system. As already noted, the performance is strongly linked to the choice of the optimal bandwidth hopt. This value should be continuously updated. So, 20
there is a risk of loosing efficiency by updating hopt at each time step. Here, we propose to compute hopt efficiently throughout all the simulations period by extrapolating hopt from the data gathered at the initial steps (early times). Figure 5shows the true evolution of the optimal bandwidth hopt as a function of the number of particles for an initial particle number of N= 4000 (hopt is updated at each time step). It is found that the optimal bandwidth increases as the number of particles decreases, closely following the slope of -1/5 (recall equation (11)). Therefore, hopt as a number of the remaining particles in the system can be estimated by a linear extrapolation between the optimal values obtained at two different time steps (e.g., denoted by 1 and 2 in the figure). This extrapolation allows one to avoid the costly computation involved in solving (12) at each time step. An anomalous estimation of hopt at late times is also observed, corresponding to normalized concentrations of 10−2, in this problem being equivalent to the presence of only 40 particles of each species in the whole domain. 4.3. Performance analysis To systematically compare the performances of the DB and the KDE models, we define a performance factor Pf=tmax tc +Emax E,(15) where tcis the computational time, tmax is the maximum of tcamong all simulations, and Eis the error of the results with respect to the analytical solution, defined as 21
101 102 103 100 101 102 Number of particles hopt Particle A Particle B 12 5 1 Figure 5: Optimal bandwidth as a function of the number of particles remaining in the system (not yet reacted). The points 1 and 2 represent initial steps of the simulation for the linear extrapolation of the optimal bandwidth. An slope of 1/5 for the optimal bandwidth can be considered a very good approximation up to times corresponding to very low concentrations. 22
from particle distributions. Adv Water Resour 2013;59:52-65. doi:10.1016/j.advwatres.2013.05.006. [19] Pollock D. Semianalytical computation of path lines for finite-difference models. Ground Water 1988;26(6):743-50. [20] Raje DS, Kapoor V. Experimental Study of Bimolecular Reaction Kinetics in Porous Media. Environ Sci Technol 2000;34:1234-9. doi:10.1016:10.1021/es9908669. [21] Salamon P, Fern`andez-Garcia D, Gomez-Hernandez JJ. Modeling mass transfer processes using random walk particle tracking. Water Resour Res 2006;42. doi:10.1029/2006WR004927. [22] Salamon P, Fern`andez-Garcia D, Gomez-Hernandez JJ. A review and numerical assessment of the random walk particle tracking method. J Contam Hydrol 2006;87:277-305. doi:10.1016/j.jconhyd.2006.05.005. [23] Sanchez-Vila X, Fern`andez-Garcia D, Guadagnini A. Interpretation of column experiments of transport of solutes undergoing an irreversible bimolecular reaction using a continuum approximation. Water Resour Res 2010;46:1-7. doi:10.1029/2010WR009539. [24] Silverman BW, Density Estimation for Statistics and Data Analysis, London:Chapman and HallLondon 1986. [25] Tartakovsky AM, Meakin P. A smoothed particle hydrodynamics model for miscible flow in three-dimensional fractures and the twodimensional Rayleigh-Taylor instability. J Comput Phys 2005;207:610-24. doi:10.1016/j.jcp.2005.02.001. 29
[26] Tompson AFB, Dougherty DE. Particle-grid methods for reacting flows in porous media with application to Fisher’s equation. Appl Math Model 1992;16:374-83. doi:10.1016/0307-904X(92)90071-A. [27] Willmann M, Carrera J, Sanchez-Vila X, Silva O, Dentz M. Coupling of mass transfer and reactive transport for nonlinear reactions in heterogeneous media. Water Resour Res 2010;46:W07512. doi:10.1029/2009WR007739. 30