Adaptive Brownian Dynamics - Adaptive Brownian Dynamics
←
→
Page content transcription
If your browser does not render page correctly, please read the page content below
Adaptive Brownian Dynamics Adaptive Brownian Dynamics Florian Sammüller and Matthias Schmidt Theoretische Physik II, Physikalisches Institut, Universität Bayreuth, D-95447 Bayreuth, Germany (*Electronic mail: Matthias.Schmidt@uni-bayreuth.de) (Dated: August 10, 2021) A framework for performant Brownian Dynamics (BD) many-body simulations with adaptive timestepping is presented. Contrary to the Euler-Maruyama scheme in common non-adaptive BD, we employ an embedded Heun-Euler integrator for the propagation of the overdamped coupled Langevin equations of motion. This enables the derivation of a local arXiv:2108.03399v1 [cond-mat.stat-mech] 7 Aug 2021 error estimate and the formulation of criteria for the acceptance or rejection of trial steps and for the control of optimal stepsize. Introducing erroneous bias in the random forces is avoided by Rejection Sampling with Memory (RSwM) due to Rackauckas and Nie, which makes use of the Brownian bridge theorem and guarantees the correct generation of a specified random process even when rejecting trial steps. For test cases of Lennard-Jones fluids in bulk and in confinement, it is shown that adaptive BD solves performance and stability issues of conventional BD, already outperforming the latter even in standard situations. We expect this novel computational approach to BD to be especially helpful in long-time simulations of complex systems, e.g. in non-equilibrium, where concurrent slow and fast processes occur. I. INTRODUCTION thermodynamic coupling10,11 , event-driven algorithms which enable both MD and BD in hard-particle systems12,13 , and the adaptation of molecular algorithms to modern hardware14 . Computer simulations have long become an established Improvements in the calculation of observables from the re- tool in the investigation of physical phenomena1–3 . Com- sulting particle configurations have been made as well, e.g. by plementing experimental results, they build the foundation modifying their generation in MC (umbrella sampling, transi- for the exploration of increasingly complex dynamical sys- tion matrix MC15 , Wang-Landau sampling16 ) or by utilizing tems. From the standpoint of classical statistical mechanics, advanced evaluation schemes in MD and BD, such as force the simulation of a many-body system consisting of discrete sampling17–19 or adaptive resolution MD20 . interacting particles can reveal information about its structural correlation as well as its thermodynamic properties. Natu- The efficiency and accuracy of a certain algorithm are al- rally, this opens up the possibility of tackling many problems ways primary concerns, as these properties are essential for in the fields of material science, soft matter and biophysics, applicability and practicability in real-world problems. One such as investigating the dynamics of macromolecules4 , pre- therefore aims to design procedures that are both as fast and dicting rheological properties of fluids5–7 , or exploring non- as precise as possible – yet it is no surprise that those two goals equilibrium processes which occur e.g. in colloidal suspen- might often be conflicting. Especially in BD, where stochas- sions under the influence of external forcing8 . tic processes complicate the numerical treatment, the devel- With the ever-increasing capabilities of computer hardware, opment of more sophisticated algorithms apparently lacks be- a variety of different computational methods have emerged hind that of MD, for example, and one often resorts to al- since the middle of the last century. Conceptually, at least ternative or combined simulation techniques21,22 . If the full three distinct classes of particle-based simulation frameworks dynamical description of BD is indeed considered, the equa- can be identified: i) Monte-Carlo (MC), which relies on the tions of motion are usually integrated with the simple Euler- stochastic exploration of phase space, ii) Molecular Dynam- Maruyama method23 , where stochasticity is accounted for in ics (MD), in which the set of ordinary differential equations each equidistant step via normally distributed random num- (ODEs) of Hamiltonian dynamics is integrated to obtain par- bers. This can lead to inaccuracies and stability problems, ticle trajectories, and iii) Langevin Dynamics, where random making BD seem inferior to other computational methods. processes are incorporated into the Newtonian equations of In this work, we propose a novel approach to BD simula- motion so that the evolution of a system is obtained by nu- tions which rectifies the above shortcomings of conventional merical integration of then stochastic differential equations BD. To achieve this, we employ an adaptive timestepping (SDEs). Brownian Dynamics (BD) can be seen as a special algorithm that enables the control of the numerical error as case of iii), since the underlying stochastic Langevin equation follows. The common Euler-Maruyama method is comple- is thereby considered in the overdamped limit where particle mented with a higher-order Heun step to obtain an embedded inertia vanishes and only particle coordinates remain as the integrator pair for an estimation of the local discretisation er- sole microscopic degrees of freedom. ror per trial step. By comparison of this error estimate with Notably, a broad range of refined methods have been de- a prescribed tolerance, the trial step is either accepted or it veloped in all three categories, sometimes even intersecting is rejected and then retried with a smaller stepsize. Particu- those. Important examples of such extensions are kinetic lar care is required after rejections so as to not introduce a Monte-Carlo for the approximation of time evolution from bias in the random forces which would violate their desired reaction rates9 , the addition of thermostats in MD to model properties. We therefore use Rejection Sampling with Mem-
Adaptive Brownian Dynamics 2 ory (RSwM)24 to retain a Gaussian random process even in ticle i satisfies a scenario where already determined random increments may s conditionally be discarded. RSwM is a recently developed al- (i) 1 (i) N 2kB T (i) gorithm for the adaptive generation of random processes in ṙ (t) = F (r (t)) + R (t) (1) γ (i) γ (i) the numerical solution of SDEs, which we improve and spe- cialize to our context of overdamped Brownian motion and where F(i) (rN (t)) is the total force (composed of external and thereby formulate a method for adaptive BD simulations. interparticle contributions) acting on particle i, γ (i) is the fric- We demonstrate the practical advantages of adaptive BD tion coefficient of particle i and kB is Boltzmann’s constant; over common BD in simulation results for prototypical bulk the dot denotes a time derivative. In eq. (1), the right-hand equilibrium systems and for more involved cases in non- side consists of a deterministic (first summand) and a random equilibrium. A notable example which we investigate is the contribution (second summand). The random forces are mod- drying of colloidal films at planar surfaces. Especially when eled via multivariate Gaussian white noise processes R(i) (t) dealing with non-trivial mixtures, as e.g. present in common which satisfy paints and coatings, the dynamics of this process can be in- herently complex and its quantitative description turns out to hR(i) (t)i = 0, (2) be a major challenge25,26 . This stands in contrast to the neces- (i) ( j) 0 0 sity of understanding and predicting stratification processes in hR (t)R (t )i = Iδi j δ (t − t ), (3) those systems. Stratification leads to a dried film that has mul- tiple layers differing in the concentration of constituent parti- where h·i denotes an average over realizations of the random cle species, thereby influencing macroscopic properties of the process, I is the d × d unit matrix, δi j denotes the Kronecker resulting colloidal film. Therefore, controlling this process is delta, and δ (·) is the Dirac delta function. an important measure to tailor colloidal suspensions to their One can recognize that eq. (1) has the typical form of an field of application. Advances in this area have been made SDE experimentally27,28 , by utilizing functional many-body frame- works like dynamical density functional theory (DDFT)29 , dX(t) = f (X(t),t) dt + g(X(t),t) dW (t), (4) and with molecular simulations such as conventional BD30 . By employing the adaptive BD method, we are able to cap- if the dependent random variable X is identified with the par- ture the complex dynamical processes occuring in those sys- ticle positions rN and W is a Wiener process corresponding to tems even in the final dense state. Close particle collisions and the integral of the Gaussian processes RN = (R(1) , . . . , R(N) ). jammed states are resolved with the required adjustment of the As we do not consider hydrodynamic interactions, the random (i) timestep, necessary for the stability and accuracy of the sim- p by a mere scaling of R (t) with forces in eq. (1) are obtained (i) the constant prefactors 2kB T /γ . Therefore, the noise in ulation run in those circumstances. This can not be achieved easily with common BD. BD is additive, since g(X(t),t) = const. in the sense of eq. This paper is structured as follows. In Sec. II, a brief and (4). This is a crucial property for the construction of a simple non-rigorous mathematical introduction to the numerical so- higher-order integrator below in Sec. III. lution of SDEs is given. Particularly, we illustrate the prereq- In computer simulations, particle trajectories are obtained uisites for adaptive and higher-order algorithms in the case of from eq. (1) by numerical integration. Contrary to the numer- general SDEs and emphasize certain pitfalls. In Sec. III, these ics of ODEs, where higher-order schemes and adaptivity are considerations are applied to the case of Brownian motion. textbook material, the derivation of corresponding methods We construct the embedded Heun-Euler integration scheme in for SDEs poses several difficulties which we address below. Sec. III A and incorporate RSwM in Sec. III B, which yields Due to the complications, SDEs of type (4) are often inte- the adaptive BD method. Observables can then be sampled grated via the Euler-Maruyama method instead, which follows from the resulting particle trajectories with the means illus- the notion of the explicit Euler scheme for ODEs. Thereby, trated in Sec. III C. In Sec. IV, simulation results of the above the true solution of eq. (4) with initial value X(0) = X0 is mentioned Lennard-Jones systems are shown and the practi- approximated in t ∈ [0, T ] by partitioning the time interval cal use of adaptive BD is confirmed. In Sec. V, we conclude into n equidistant subintervals of length ∆t = T /n. Then, for with a summary of the shown concepts, propose possible im- 0 ≤ k < n, a timestep is defined by provements for the adaptation of timesteps, and present fur- ther ideas for use cases. Xk+1 = Xk + f (Xk ,tk )∆t + g(Xk ,tk )∆Wk (5) with Wiener increments ∆Wk . An Euler-Maruyama step is also incorporated in the adaptive BD method which we construct II. NUMERICS OF STOCHASTIC DIFFERENTIAL below, applying eq. (5) to the overdamped Langevin equation EQUATIONS (1). Crucially, the random increments ∆Wk in each Euler- Brownian Dynamics of a classical many-body system of Maruyama step (5) have to be constructed from independent N particles in d spatial dimensions with positions rN (t) = and identically distributed normal random variables with ex- (r(1) (t), . . . , r(N) (t)) at time t and temperature T is described pectation value E(∆Wk ) = 0 and variance Var(∆Wk ) = ∆t. In by the overdamped Langevin equation. The trajectory of par- practice, this is realized by drawing a new random number R
Adaptive Brownian Dynamics 3 (or vector thereof) from a pseudo-random number√ generator duction of an undesired bias. Since large random increments obeying the normal distribution N (0, ∆t) = ∆tN (0, 1) in (generally causing larger errors) get rejected more often, the each step k and setting ∆Wk = R in eq. (5). The process of variance of the Wiener process would be systematically de- obtaining such a scalar (or vectorial) random increment R will creased, ultimately violating its desired properties. To avoid be denoted in the following by this effect, it must be guaranteed that once a random incre- ment is chosen, it will not be discarded until the time interval R ∼ N (µ, η) (6) it originally applied to has passed. Consequently, when re- jecting a trial step and retrying the numerical propagation of where N (µ, η) is a scalar (or multivariate) normal distribu- the SDE with smaller time intervals, new random increments tion with expectation value µ and variance η. cannot be drawn independently for those substeps anymore. As in the case of ODEs, an important measure for the qual- The new random increments must instead be created based on ity of an integration method is its order of convergence. How- the rejected original timestep such that an unbiased Brownian ever, what convergence exactly means in the case of SDEs path is still followed. must be carefully reconsidered due to their stochasticity. We The formal framework to the above procedure is given by refer the reader to the pertinent literature (see e.g. Ref. 23) the so-called Brownian bridge theorem35 , which interpolates and only summarize the key concepts and main results in the a Wiener process between known values at two timepoints. following. If W (0) = 0 and W (∆t) = R are given (e.g. due to the previ- Since both the approximation Xk and the true solution X(tk ) ous rejection of a timestep of length ∆t where the random in- are random variables, one can define two distinct convergence crement R has been drawn), then a new intermediate random criteria. For a certain method with discretisation ∆t → 0, weak value must be constructed by convergence captures the error of average values whereas strong convergence assesses the error of following a specific W (q∆t) ∼ N (qR, (1 − q)q∆t), 0 < q < 1, (7) realization of a random process. One can show that the Euler- Maruyama method has a strong convergence order of 0.5, i.e. such that the statistical properties of the to-be-simulated when increasing or decreasing the stepsize ∆t, the error of Wiener process are left intact and a substep q∆t can be tried. the numerical solution only scales with ∆t 0.5 . For general The value of q thereby sets the fraction of the original time g(X(t),t) in eq. (4), the construction of schemes with higher interval to which the Wiener process shall be interpolated. strong order is complicated due to the occurence of higher- Equation (7) extends naturally (i.e. component-wise) to the order stochastic integrals. Practically, this means that the care- multivariate case and it hence enables the construction of in- ful evaluation of additional random variables is necessary in terpolating random vectors in a straightforward manner. each iteration step. These random variables then enable the With this idea in mind, several adaptive timestepping algo- approximation of the stochastic integrals. There exist schemes rithms for SDEs have been designed36–42 . Still, most of these of Runge-Kutta type with strong orders up to 2, although only approaches are quite restrictive in the choice of timesteps strong order 1 and 1.5 Runge-Kutta methods are mostly used (e.g. only allowing discrete variations such as halving or due to practical concerns31,32 . doubling)36,42 , involve the deterministic or random part only In order to incorporate adaptivity, one needs a means of separately into an a-priori error estimation39,41,43 , or store re- comparison of two integration schemes of different strong or- jected timesteps in a costly manner, e.g. in the form of Brow- der to formulate a local error estimate for the proposed step. nian trees36 . In particular, the above methods rely on precom- If the error that occurs in a specific timestep is too large puted Brownian paths and do not illustrate an ad hoc genera- (we define below precisely what we mean by that), the step tion, which is desirable from a performance and memory con- is rejected and a retrial with a smaller value of ∆t is per- sumption standpoint in a high-dimensional setting like BD. formed. Otherwise, the step is accepted and, based on the pre- In contrast, a very flexible and performant class of adap- viously calculated error, a new optimized stepsize is chosen tive timestepping algorithms called Rejection Sampling with for the next step, which hence can be larger than the previous Memory (RSwM) has recently been developed by Rackauckas one. This protocol makes an optimal and automatic control and Nie 24 . Their work provides the arguably optimal means of the stepsize possible, meaning that ∆t can both be reduced for the adaptive numerical solution of SDEs while still being when the propagation of the SDE is difficult and it can be in- computationally efficient in the generation of random incre- creased when the error estimate allows to do so. Similar to ments as well as in the handling of rejections. We therefore the case of ODEs, it is computationally advantageous to con- use RSwM in the construction of an adaptive algorithm and struct so-called embedded integration schemes, analogous to specialize the method to Brownian motion in the following. e.g. Runge-Kutta-Fehlberg integrators33 , which minimize the number of costly evaluations of the right-hand side of eq. (4). Developments have been made in this direction e.g. with em- III. APPLICATION TO BROWNIAN DYNAMICS bedded stochastic Runge-Kutta methods34 . There is still one caveat to consider when rejecting a step, Based on the remarks of Sec. II, we next proceed to ap- in that one has to be careful to preserve the properties of the ply the general framework to the case of BD with the over- Wiener process. In the naive approach of simply redrawing damped Langevin equation (1) forming the underlying SDE. new uncorrelated random increments, rejections would alter An embedded integration scheme is constructed which allows the random process implicitly. The reason lies in the intro- the derivation of an error estimate and an acceptance criterion
Adaptive Brownian Dynamics 4 in each step. Furthermore, the application of RSwM for han- and Iniesta and de la Torre 47 . Several further higher-order dling rejected timesteps in BD is shown and discussed. We schemes, mostly of Runge-Kutta type, have been used in BD also illustrate how the calculation of observables from sam- simulations45,48 . These methods often lead to increased ac- pling of phase space functions has to be altered in a variable curacy and even efficiency due to bigger timesteps becoming timestep scenario. achievable, which outweighs the increased computational cost per step. Since the prefactor of the random force is trivial (i.e. constant) in the overdamped Langevin equation (1), higher A. Embedded Heun-Euler method strong-order schemes are easily constructable. This situation stands in contrast to the more complicated SDEs of type (4) Regarding the overdamped Langevin equation (1), a major with general noise term g(X(t),t). simplification exists compared to the general remarks made in Secondly, with two approximations of different order at Sec. II. Due to the noise term being trivial, some higher-order hand, assessing their discrepancy allows to obtain an estimate schemes can be constructed by only evaluating the determinis- of the discretisation error in each step, which is a fundamen- tic forces for different particle configurations. Crucially, no it- tal prerequisite in the construction of adaptive timestepping erated stochastic integrals are needed, which would have to be algorithms. For this, we exploit the additive structure of the approximated in general higher strong-order integrators by us- noise term in eq. (1) again and recognize that such an error ing additional random variables32 . In the following, we apply estimate can be obtained by only comparing the deterministic a scheme similar to the one suggested by Lamba, Mattingly, parts of eqs. (8) and (9). Nevertheless, note that the random and Stuart 41 for general SDEs to eq. (1) and term it embedded displacements are already contained in r̄Nk+1 . This makes the Heun-Euler method due to its resemblance to the correspond- deterministic part of eq. (9) implicitly dependent on the re- ing ODE integrators. Two different approximations r̄Nk+1 and alization of RNk , which is opposed to Ref. 41 where an error rNk+1 are calculated in each trial step by estimate is defined without involving the random increments at all. At a given step k → k + 1, one can construct the automatic s (i) (i) 1 (i) 2kB T (i) r̄k+1 = rk + F (rNk )∆tk +R , (8) choice of an appropriate ∆tk . For this, the error of a trial step γ (i) γ (i) k with length ∆t is evaluated. (i) (i) 1 We define a particle-wise error rk+1 = rk + (i) F(i) (rNk ) + F(i) (r̄Nk+1 ) ∆tk 2γ ∆t (9) E (i) = k∆r̄(i) − ∆r(i) k = kF(i) (r̄Nk+1 ) − F(i) (rNk )k (10) s 2kB T (i) 2γ (i) + R . γ (i) k (i) (i) (i) (i) with ∆r̄(i) = r̄k+1 − rk and ∆r(i) = rk+1 − rk . For each par- Equation (8) is the conventional Euler-Maruyama step, and ticle i, this error is compared to a tolerance hence constitutes the application of eq. (5) to the overdamped Langevin equation (1). Equation (9) resembles the second or- τ (i) = εabs + εrel k∆r(i) k (11) der Heun algorithm or midpoint scheme for ODEs44 and has been formally derived for SDEs in the context of stochastic consisting of an absolute and a relative part with user-defined Runge-Kutta methods45 . Since the deterministic forces FN coefficients εabs and εrel . Note that ∆r(i) is used in eq. (11), are evaluated at the initial particle configuration rNk both in eq. since it captures the true particle displacement more accu- (8) and eq. (9), we have constructed an embedded integration rately than ∆r̄(i) due to its higher order. Additionally, we stress method. This is favorable regarding computational cost, since that ∆r(i) decreases on average for shorter timesteps, such that the numerical result of FN (rNk ) is evaluated once in eq. (8) τ (i) indirectly depends on the trial ∆t, which limits the accu- and reused in eq. (9). Only one additional computation of the mulation of errors after multiple small steps. deterministic forces at the intermediate particle configuration Then a total error estimate r̄Nk+1 is then needed in the Heun step (9). ! In each trial step, the same realization of random vectors E (i) RNk must be used in both eqs. (8) and (9). Recall that the ran- E = (12) τ (i) dom displacements have to obey the properties of multivari- 1≤i≤N ate Wiener increments to model the non-deterministic forces. In conventional BD with fixed stepsize ∆tk = ∆t = const., can be calculated for the trial step. While the Euclidean norm these random vectors can therefore be drawn independently is the canonical choice in eq. (10), there is a certain freedom (i) of choosing an appropriate norm k·k in eq. (12). The 2- or via Rk ∼ N (0, ∆t) for each particle i. If rejections of trial ∞-norm defined respectively as (i) steps are possible, Rk must instead be constructed as de- s scribed in Sec. III B. 1 N (i) 2 When the embedded Heun-Euler step (8) and (9) is ap- (x(i) )1≤i≤N = ∑ |x | , (13) 2 N i=1 plied to BD, the improvement over the conventional method is twofold. Firstly, the Heun step (9) can be used as a (x(i) )1≤i≤N = max |x(i) |, (14) better propagation method as already analyzed by Fixman 46 ∞ 1≤i≤N
Adaptive Brownian Dynamics 5 may both come up as natural and valid √ options (note that One can also impose limits for the range of values of ∆t, we normalise the standard 2-norm by N to obtain an inten- such as a maximum bound ∆tmax ≥ ∆t. Restriction by a min- sive quantity). However, in eq. (12), where a reduction from imum value ∆tmin ≤ ∆t, however, could lead to a forced con- particle-wise errors to a global scalar error takes place, this tinuation of the simulation with an actual local error that lies has crucial implications to the kind of error that is being con- above the user-defined tolerance. Thus, this is not recom- trolled. If the 2-norm is used, then εabs and εrel set the mean mended. In our test cases described below, we see no need to absolute and relative tolerance for all particles. In practice for restrict the timestep as the adaptive algorithm does not show large particle number N, this can lead to substantial single- unstable behavior without such a restriction. particle errors becoming lost in the global average. Therefore, Most concepts of this section can be generalized in a it is advisable to use the ∞-norm for the reduction in eq. (12) straightforward manner to non-overdamped Langevin dynam- to be able to set a maximum single-particle absolute and rela- ics, where particle inertia is explicitly considered in the tive tolerance, i.e. if E < 1, E (i) < τ (i) for all i = 1, . . . , N. stochastic equations of motion. However, the embedded Following the design of adaptive ODE solvers and ignoring Heun-Euler method (8) and (9) might not be a suitable in- stochasticity, an expansion of an embedded pair of methods tegration scheme in this case. We therefore outline the modi- with orders p and p − 1 shows that an error estimate of type fications that are necessary in the construction of an adaptive (12) is of order p. Thus, a timestep of length q∆t with algorithm for general Langevin dynamics in Appendix A. 1 q = E−p (15) B. Rejection Sampling with Memory in BD could have been chosen to marginally satisfy the tolerance re- quirement E < 1. Considering the recommendation of Ref. 24 which dis- We still have to prescribe the generation of the random vec- cusses the application of such a timestep scaling factor to em- tors RNk that appear both in eqs. (8) and (9). For clarity, we bedded methods for SDEs, we set consider a single trial step and denote the set of correspond- ing random increments with R (the sub- and superscript is 1 2 dropped). Obviously, R can no longer be chosen indepen- q= . (16) dently in general but has to incorporate previously rejected αE timesteps as long as they are relevant, i.e. as long as their Here both a more conservative exponent is chosen than in eq. original time interval has not passed yet. For this, we apply (15) and also a safety factor α = 2 is introduced, as we want the Rejection Sampling with Memory (RSwM) algorithm to to account for stochasticity and for the low order of our in- BD. Rackauckas and Nie 24 describe three variants of RSwM tegrators, which results in a low order of the error estimate which they refer to as RSwM1, RSwM2, and RSwM3, and (12). which differ in generality of the possible timesteps and algo- With the choice (16), one can distinguish two possible sce- rithmic complexity. We aim to reproduce RSwM3 because it narios in each trial step: enables optimal timestepping and still ensures correctness in special but rare cases such as re-rejections. • q ≥ 1: Accept the trial step, i.e. set ∆tk = ∆t and ad- vance the particle positions with eq. (9), and then con- Common to all of the RSwM algorithms is storing parts of tinue with k + 1 → k + 2. rejected random increments onto a stack S f . We refer to ele- ments of this stack as future information, since they have to be • q < 1: Reject the trial step and retry k → k + 1 with a considered in the construction of future steps. This becomes smaller timestep. relevant as soon as a step is rejected due to a too large er- ror. Then a retrial is performed by decreasing ∆t and drawing In both cases, the timestep is adapted afterwards via ∆t ← bridging random vectors via eq. (7). The difference between q∆t. Here and in the following, the notation a ← b denotes an rejected and bridging random vectors must not be forgotten assignment of the value b to the variable a. but rather be stored on the future information stack, cf. fig. 1. It is advisable to restrict the permissible range of values for On the other hand, if a step is accepted, new random vectors q by defining lower and upper bounds qmin ≤ q ≤ qmax such have to be prepared for the next time interval ∆t. If no future that the adaptation of ∆t is done with information is on the stack, this can be done conventionally q ← min(qmax , max(qmin , q)) (17) via drawing Gaussian distributed random vectors according to R ∼ N (0, ∆t). If the stack S f is not empty and thus future in- While commonly chosen as qmax ≈ 10 and qmin ≈ 0.2 for ODE formation is available, then elements of the stack are popped solvers, due to stochasticity and the possibility of drawing one after another, i.e. they are taken successively from the top. “difficult” random increments, qmin should certainly be de- The random vectors as well as the time interval of each popped creased in the case of SDEs to avoid multiple re-rejections. element are accumulated in temporary variables which then Vice versa, a conservative choice of qmax prevents an overcor- hold the sum of those respective time intervals and random rection of the timestep in case of “fortunate” random events. vectors. The stack could be empty before the accumulated We set qmax = 1.2 and qmin = 0.001 in practical applications time reaches ∆t, i.e. there could still be a difference ∆tgap . In to achieve a rapid adaptation in case of rejected trial steps and this case, one draws new random vectors Rgap ∼ N (0, ∆tgap ) a careful approach to larger timesteps after accepted moves. to compensate for the difference and adds them to the accu-
Adaptive Brownian Dynamics 6 (a) Try step with ∆t x x p ) t ga Previous steps Current trial step ,∆ (0 and random forces N Sf ∼ Sf R E un He le r Eu ∆tgap ∆t t ∆t t (b) q < 1. Retry with ∆t ← q∆t Figure 2. After an accepted step has been performed, a new random x increment is prepared for the next trial step of length ∆t. If available, future information – stemming from previously rejected trial steps – has to be incorporated in the generation of new random vectors in order to retain the properties of Brownian motion. In the shown case, Sf the future information stack contains one element, which is popped and accumulated to the new random increment and time interval. The stack is now empty and a difference ∆tgap to the goal timestep ∆t E remains. For this gap, a new uncorrelated random increment has to BB be generated from N (0, ∆tgap ) to complete the preparation of the ∼ next trial step. Ref. 24. If future information is popped from the stack to pre- ∆t t pare R for the next step, and this next step is then rejected, we have lost all popped information unrecoverably. To circum- Figure 1. The trial step is rejected (a) and a retrial with a smaller vent this, one adds a second stack Su that stores information value of ∆t is performed (b) if the discrepancy between eq. (8) and which is currently used for the construction of R. We refer eq. (9) is large. To preserve the properties of the Brownian motion, to elements of this stack as information in use. If a step is the Brownian bridge (BB) theorem (7) is used to interpolate the ran- dom process at the intermediate timepoint q∆t. The difference be- rejected, the information in use can be moved back to the fu- tween the bridged random sample and the rejected original random ture information stack so that no elements are lost in multiple sample is stored along with the remaining time difference onto the retries, cf. fig. 4. With this additional bookkeeping, correct- stack S f . This is indicated in (b), where S f now contains one ele- ness and generality is ensured in all cases and the RSwM3 ment that holds the residual time interval (horizontal segment) and algorithm is complete. random increment (vertical arrow). Thus, in future steps, the Brown- ian path can be reconstructed from elements on S f and the properties Notably, with the structuring of information into stacks of the Wiener process remain intact. Note that for correctness in case where only the top element is directly accessible (“last in first of re-rejections, one requires a second stack Su as explained below out”), the chronological time order is automatically kept in- and in fig. 4. tact so that one only has to store time intervals and no absolute timepoints. Furthermore, searching or sorting of elements is prevented entirely which makes all operations O(1) and leads mulated ones, cf. fig. 2, before attempting the trial step. Oth- to efficient implementations. erwise, if the future information reaches further than ∆t, then We point out that the original RSwM3 rejection branch as there is one element that passes ∆t. One takes this element, given in Ref. 24 was not entirely correct and draw a com- splits it in “before ∆t” and “after ∆t” and draws bridging ran- parison to our rectifications in Appendix B, which have been dom vectors for “before ∆t” according to eq. (7) which are brought to attention49 and have since been fixed in the refer- again added to the accumulated ones. The rest of this element ence implementation DifferentialEquations.jl50 . Crucially, the (“after ∆t”) can be pushed back to the future information stack correction not only applies to the case of BD, but it rather is and the step ∆t can be tried with the accumulated vectors set relevant for the solution of general SDEs as well. A full pseu- as R in eqs. (8) and (9), cf. fig. 3. docode listing of one adaptive BD trial step utilizing RSwM3 At this stage, we have constructed RSwM2 for BD, which is given in alg. 2 in Appendix C along with further explanation is not capable of handling all edge cases yet as pointed out in of technical details.51
Adaptive Brownian Dynamics 7 (a) (a) R ) t ap (0, ∆ g x ∼N Su Sf Sf (b) rejection Su Sf Figure 4. To keep track of the random increments that are used in ∆t t the construction of R, a second stack Su is introduced. In (a), the situation of fig. 2 is shown as an example, where R consists of an (b) element of S f (stemming from a previous rejection) and a Gaussian x contribution Rgap ∼ N (0, ∆tgap ). In case of rejection, the elements that were popped from S f as well as newly drawn increments such as Rgap would be lost unrecoverably. By using Su as an intermediate storage, all contributions to R can be transferred back to S f such that no information about drawn random increments is lost and the same Sf Brownian path is still followed. These considerations apply as well BB when random vectors are drawn via the Brownian bridge theorem, as ∼ e.g. in figs. 1 and 3. ple, X = (r, r0 ) or X = r for general two- or one-body fields, X = r for the isotropic radial distribution function or X = 0/ for bulk quantities such as pressure or heat capacity. Practically, Â(X, rN ) is evaluated in each step and an X- ∆t t resolved histogram is accumulated which yields A(X) after normalization. Considering the numerical discretisation of Figure 3. The situation is similar to fig. 2, where a step is rejected [0, T ] into n timesteps of constant length ∆t within a conven- (a) and then retried (b). Here, the future information reaches further tional BD simulation, eq. (18) is usually implemented as than the goal timestep ∆t. In this case, the Brownian bridge (BB) has to be applied for the interpolation of an element from the future 1 n information stack. Generally, one pops the elements of the future A(X) ≈ ∑ Â(X, rNk ). n k=1 (19) stack S f one after another and accumulates the random increments and time intervals until the element which crosses ∆t is reached, to which the bridging theorem is then applied. In the shown example, In adaptive BD with varying timestep length, one cannot the interpolation is done with the first element of S f , since it already use eq. (19) directly, since this would cause disproportionately surpasses ∆t. Similar to fig. 1, the remainder of the bridged increment many contributions to A(X) from small timesteps and would and time interval is pushed back onto S f . thus lead to a biased evaluation of any observable. Formally, the quadrature in eq. (18) now has to be evaluated numerically at non-equidistant integration points. C. Sampling of observables Therefore, if the time interval [0, T ] is discretized into n non-equidistant timepoints 0 = t1 < t2 < · · · < tn < tn+1 = T Within BD, observables can be obtained from the sampling and ∆tk = tk+1 − tk , of configuration space functions. As an example, consider the n one-body density profile ρ(r), which is defined as the average 1 of the density operator ρ̂(r, rN ) = ∑Ni=1 δ (r − ri ). A(X) ≈ T ∑ ∆tk Â(X, rNk ) (20) k=1 In simulations of equilibrium or steady states, one can use a time-average over a suitably long interval [0, T ] to measure constitutes a generalization of eq. (19) for this case that en- such quantities, i.e. for a general operator Â(X, rN ), ables a straightforward sampling of observables within adap- Z T tive BD. 1 A(X) ≈ dt Â(X, rN (t)). (18) An alternative technique can be employed in scenarios T 0 where the state of the system shall be sampled on a sparser Note that the remaining dependence on X can consist of arbi- time grid than the one given by the integration timesteps. trary scalar or vectorial quantities or also be empty. For exam- Then, regular sampling points can be defined that must be
Adaptive Brownian Dynamics 8 hit by the timestepping procedure (e.g. by artificially short- A. Lennard-Jones bulk fluid in equilibrium ening the preceding step). On this regular time grid, eq. (19) can be used again. Especially in non-equilibrium situations In the following, we compare results from conventional BD and for the measurement of time-dependent correlation func- to those obtained with adaptive BD. We first consider a bulk tions such as the van Hove two-body correlation function52–57 , system of size 7 × 7 × 6σ 3 with periodic boundary conditions this method might be beneficial since quantities can still be at temperature kB T = 0.8ε consisting of N = 100 Lennard- evaluated at certain timepoints rather than having to construct Jones particles initialized on a simple cubic lattice. In the a time-resolved histogram consisting of finite time intervals. process of equilibration, a gaseous and a liquid phase emerge, Note however, that timestepping to predefined halting points and the system therefore becomes inhomogeneous. is not yet considered in alg. 2. With non-adaptive Euler-Maruyama BD, a timestep ∆tfix = 10−4 τ is chosen to consistently converge to this state. This value is small enough to avoid severe problems which occur IV. SIMULATION RESULTS reproducibly for ∆tfix & 5 · 10−4 τ, where the simulation occa- sionally crashes or produces sudden jumps in energy due to To test and illustrate the adaptive BD algorithm, we investi- faulty particle displacements. gate the truncated and shifted Lennard-Jones fluid with inter- In contrast, the timestepping of an adaptive BD simulation action potential run is shown both as a timeseries and as a histogram in fig. ( 5. The tolerance coefficients in eq. (11) are thereby set to ΦLJ (r) − ΦLJ (rc ), r < rc εabs = 0.05σ and εrel = 0.05 and the ∞-norm is used in the ΦLJTS (r) = (21) reduction from particle-wise to global error (12). One can 0, r ≥ rc see that large stepsizes up to ∆t ≈ 6 · 10−4 τ occur without the error exceeding the tolerance threshold. The majority of where steps can be executed with a timestep larger than the value σ 12 σ 6 ∆tfix = 10−4 τ. On the other hand, the algorithm is able to de- ΦLJ (r) = 4ε − (22) tect moves that would cause large errors where it decreases r r ∆t appropriately. It is striking that in the shown sample, mini- and r is the interparticle distance. We set a cutoff radius mum timesteps as small as ∆t = 3·10−6 τ occur. This is far be- of rc = 2.5σ throughout the next sections and use reduced low the stepsize of ∆tfix = 10−4 τ chosen in the fixed-timestep Lennard-Jones units which yield the reduced timescale τ = BD run above, which indicates that although the simulation σ 2 γ/ε. is stable for this value, there are still steps which produce A common problem in conventional BD simulations is the substatial local errors in the particle trajectories. For even choice of an appropriate timestep. Obviously, a too small larger values of ∆tfix , it is those unresolved collision events value of ∆t – while leading to accurate trajectories – has a that cause unphysical particle displacements which then cas- strong performance impact, hindering runs which would re- cade and crash the simulation run. In comparison, the adap- veal long time behavior and prohibiting extensive sampling tive BD run yields a mean timestep of ∆t = 3 · 10−4 τ, which periods, which are desirable from the viewpoint of the time is larger than the heuristically chosen fixed timestep. average (20). Still, ∆t must be kept below a certain thresh- old above which results might be wrong or the simulation Performance and overhead Per step, due to an addi- becomes unstable. Unfortunately, due to the absence of any tional evaluation via the Heun method (9), twice the compu- intrinsic error estimates, judgement of a chosen ∆t is gener- tational effort is needed to calculate the deterministic forces ally not straightforward. For instance, one can merely observe compared to a single evaluation of the Euler-Maruyama step the stability of a single simulation run and accept ∆t if sensi- (8). This procedure alone has the benefit of increased accu- ble output is produced and certain properties of the system racy though, and it hence makes larger timesteps feasible. (such as its energy) are well-behaved. Another possibility is The computational overhead due to adaptivity with RSwM3 the costly conduction of several simulation runs with differing comes mainly from storing random increments on both stacks timesteps, thereby cross-validating gathered results. Conse- and applying this information in the construction of new ran- quently, a true a priori choice of the timestep is not possible in dom forces. Therefore, potential for further optimization lies general and test runs cannot always be avoided. in a cache-friendly organization of the stacks in memory as With adaptive timestepping, this problem is entirely pre- well as in circumventing superfluous access and copy instruc- vented as one does not need to make a conscious choice for ∆t tions altogether. The latter considerations suggest that avoid- at all. Instead, the maximum local error of a step is restricted ing rejections and more importantly avoiding re-rejections is by the user-defined tolerance (11), ensuring correctness of re- crucial for good performance and reasonable memory con- sults up to a controllable discretisation error. This does come sumption of the algorithm. As already noted, in practice this at the moderate cost of overhead due to the additional opera- can be accomplished with a small value of qmin that allows tions per step necessary in the embedded Heun-Euler method for a rapid reduction of ∆t in the case of unfortunate ran- and the RSwM algorithm. However, as we demonstrate in the dom events and a conservative value of qmax to avoid too following, the benefits of this method far outweigh the cost large timestepping after moves with fortunate random incre- even in simple situations. ments. In our implementation, the cost of RSwM routines is
Adaptive Brownian Dynamics 9 fraction. navg = 20 In the following, we apply adaptive BD to systems of navg = 100 Lennard-Jones particles and simulate evaporation of the im- navg = 1000 plicit solvent. This is done by introducing an external poten- tial that models the fixed substrate surface as well as a moving 10−3 air-solvent interface. As in Ref. 29, we set (i) (i) (i) Vext (z,t) = B e−κ(z−σ /2) + eκ(z+σ /2−L(t)) (23) to only vary in the z-direction and assume periodic boundary 10−4 conditions in the remaining two directions. The value of κ controls the softness of the substrate and the air-solvent in- ∆t/τ terface while B sets their strength. We distinguish between the different particle sizes σ (i) to account for the offset of the particle centers where the external potential is evaluated. The position L(t) of the air-solvent interface is time-dependent and 10−5 follows a linear motion L(t) = L0 − vt with initial position L0 10−4 and constant velocity v. 10−5 In the following, systems in a box which is elon- gated in z-direction are considered. To ensure dominat- (a) 5.88 5.90 5.92 (b) ing non-equilibrium effects, values for the air-solvent inter- 10−6 face velocities are chosen which yield large Péclet numbers 0 10 20 0.0 0.2 Pe(i) = L0 v/D(i) 1 where D(i) = kB T /γ (i) is the Einstein- t/τ rel. count Smoluchowski diffusion coefficient and γ (i) ∝ σ (i) due to Stokes. When attempting molecular simulations of such systems in Figure 5. The evolution of chosen timesteps for accepted moves is shown in (a). To accentuate the distribution of values of ∆t fur- a conventional approach, one is faced with a non-trivial choice ther, moving averages taken over the surrounding navg points of of the timestep length ∆tfix since it has to be large enough to be a respective timestep record are depicted. One can see that the efficient in the dilute phase but also small enough to capture timestep ∆t varies rapidly in a broad range between ∆t ≈ 3 · 10−6 τ the motion of the dense final state of the system. A cumber- and ∆t ≈ 6 · 10−4 τ around a mean value of ∆t ≈ 2.8 · 10−4 τ. In the some solution would be a subdivision of the simulation into inset of (a), a close-up of the timestep behaviour is given, which subsequent time intervals, thereby choosing timesteps that suit reveals the rapid reduction of ∆t at jammed states and the quick re- the density of the current state. This method is beset by prob- covery afterwards. In (b), the relative distribution of the data in (a) lems as the density profile becomes inhomogeneous and is not is illustrated. It is evident that the majority of steps can be executed known a priori. with a large timestep, leading to increased performance of the BD simulation. On the other hand, in the rare event of a step which We show that by employing the adaptive BD method of Sec. would produce large errors, the timestep is decreased appropriately III, these issues become non-existent. Concerning the physi- to values far below those that would be chosen in a fixed-timestep cal results of the simulation runs, the automatically chosen BD run. timestep is indeed closely connected to the increasing packing fraction as well as to the structural properties of the respective colloidal system, as will be discussed below. Similar test runs estimated to lie below 10% of the total runtime in common as the ones shown in the following but carried out with con- situations. stant timestepping and a naive choice of ∆tfix frequently lead to instabilities in the high-density regimes, ultimately result- ing in unphysical trajectories or crashes of the program. Due B. Non-equilibrium – formation of colloidal films to the possiblity of stable and accurate simulations of closely packed phases with adaptive BD, we focus on the investiga- tion of the final conformation of the colloidal suspension. While the benefits of adaptive BD are already significant in equilibrium, its real advantages over conventional BD be- come particularly clear in non-equilibrium situations. Due to the rich phenomenology – which still lacks a thorough under- 1. Single species, moderate driving standing – and the important practical applications, the dy- namics of colloidal suspensions near substrates and interfaces Firstly, a single species Lennard-Jones system is studied has been the center of attention in many recent works25–30,58 . and the box size is chosen as 8 × 8 × 50σ 3 . The Lennard- Nevertheless, the simulation of time-dependent interfacial Jones particles are initialized on a simple cubic lattice with processes is far from straightforward and especially for com- lattice constant 2σ and the velocity of the air-solvent inter- mon BD, stability issues are expected with increasing packing face is set to v = 1σ /τ. We set εabs = 0.01σ to accomodate
Adaptive Brownian Dynamics 10 for smaller particle displacements in the dense phase and relax A B C the relative tolerance to εrel = 0.1. As one can see in fig. 6, the timestep is automatically ad- justed as a reaction to the increasing density. In the course of the simulation run, the average number density increases from approximately 0.07σ −3 to 1.4σ −3 , although the particles first accumulate near the air-solvent interface. Astonishingly, even the freezing transition at the end of the simulation run can be captured effortlessly. This illustrates the influence of collec- tive order on the chosen timestep. With rising density of the Lennard-Jones fluid, the timestep decreases on average due to the shorter mean free path of the particles and more fre- quent collisions. At this stage, ∆t varies significantly and very A B C small timesteps maneuver the system safely through jammed 10−3 states of the disordered fluid. In the process of crystallization, navg = 1000 the timestep decreases rapidly to accomodate for the reduced free path of the particles before it shortly relaxes to a plateau when crystal order is achieved. Additionally, the variance of ∆t decreases and, contrary to the behaviour in the liquid phase, 10−4 fewer jammed states can be observed. This is due to the crys- ∆t/τ tal order of the solid phase, which prevents frequent close en- counters of particles and hence alleviates the need for a rapid reduction of ∆t. 10−5 2. Single species, strong driving If the evaporation rate is increased via a faster moving air- 10−6 solvent interface, the final structure of the colloidal suspen- 0 10 20 30 40 sion is altered. Particularly, with rising air-solvent velocity t/τ v, a perfect crystallization process is hindered and defects in the crystal structure occur. This is reflected in the timestep- ping evolution, as jammed states still happen frequently in the Figure 6. The timestepping evolution in a system with moving in- dense regime due to misaligned particles. Therefore, unlike terface modeled via eq. (23) with parameters B = 7000ε, κ = 1/σ in the previous case of no defects, sudden jumps to very small (adopted from Ref. 29), and v = 1σ /τ is shown. We depict both the timesteps can still be observed as depicted in fig. 7. actual timeseries whose envelope visualizes the maximum and mini- mum values of ∆t as well as a moving average over the surrounding If the velocity of the air-solvent interface is increased even navg points to uncover the mean chosen timestep. As the density further, amorphous states can be reached, where no crystal or- increases and the propagation of the overdamped Langevin equa- der prevails. Nevertheless, our method is still able to resolve tion becomes more difficult, the timestep is systematically decreased. the particle trajectories of those quenched particle configura- This is an automatic process that needs no user input and that can tions so that the simulation remains both stable and accurate even handle the freezing transition which occurs at the end of the even in such demanding circumstances. simulation. To illustrate this process, typical snapshots of the system are given at different timepoints which are marked in the timestep- ping plot as A, B, and C and correspond to a dilute, a prefreezing and 3. Binary mixture a crystallized state. Especially in the transition from B to C, frequent particle collisions occur which are resolved carefully by the adaptive BD method. Returning to stratification phenomena, we consider mix- tures of particles differing in size. Depending on the Péclet numbers of the big (subscript b) and small (subscript s) parti- cle species and their absolute value (i.e. if Pe 1 or Pe 1), In the following, a binary mixture of Lennard-Jones parti- different structures of the final phase can emerge, ranging cles with diameters σb = σ and σs = 0.5σ is simulated in a from “small-on-top” or “big-on-top” layering to more compli- system of size 10 × 10 × 100σ 3 and the velocity of the air- cated conformations29 . For large Péclet numbers 1 Pes < solvent interface is set to v = 1σ /τ as before. We initialize Peb , studies of Fortini et al. 58 have shown the formation of Nb = 768 big and Ns = 4145 small particles uniformly in the a “small-on-top” structure, i.e. the accumulation of the small simulation domain and particularly focus in our analysis on particle species near the moving interface. Additionally, in the the structure of the final dense phase. immediate vicinity of the air-solvent boundary, a thin layer of As the simulation advances in time, the observations of For- big particles remains trapped due to their low mobility. tini et al. 58 can be verified. A thin layer of big particles at
Adaptive Brownian Dynamics 11 velops a concentration gradient in the positive z-direction, out- navg = 100 lined by peaks of the respective density profile close to the big 10−4 particle layers. The formation of the described final state is illustrated in fig. 8, where the density profiles of both particle species are shown for two timepoints at the end of the simula- tion run. 10−5 ∆t/τ ρb ρs 10−5 10 (a) t = 81.3τ 10−6 −6 10 σ −3 5 1.8995 1.9 10−7 0.5 1.0 1.5 0 t/τ 10 (b) t = 86.6τ Figure 7. Time evolution and moving average of the timestep ∆t for σ −3 the air-solvent interface velocity being increased to v = 50σ /τ in a 5 larger system of box size 10 × 10 × 100σ 3 . In this case, defects are induced during the crystallization process which prevent a perfect crystal order of the final particle configuration. Jammed states still 0 occur frequently, and the timestep has to accomodate rapidly to re- solve particle displacements correctly. This is depicted in the inset, 0 5 10 15 which shows that sudden jumps to small values of ∆t still occur in z/σ the high-density regime, indicating error-prone force evaluations due to prevailing defects in the crystal structure. Figure 8. The density profiles ρb (z) and ρs (z) of the big and small particle species in a stratifying colloidal suspension of a bi- the air-solvent interface followed by a broad accumulation of nary Lennard-Jones mixture with particle diameters σb = σ and σs = 0.5σ is shown at two timepoints of the simulation. In (a), single small particles emerges. The timestepping evolution shows layers of the big species have already emerged near the substrate and similar behaviour to the single species case shown in fig. 6. the air-solvent interface, which enclose the dominating small parti- On average, the value of ∆t decreases and throughout the sim- cles in the middle of the box. At a later time (b) when the air-solvent ulation, jumps to low values occur repeatedly when interpar- interface has moved further towards the substrate and the packing ticle collisions have to be resolved accurately. fraction has hence increased, a second layer of the big particles forms As the system approaches the dense regime, the finalizing at both interfaces and the final concentration gradient of the small particle distribution of the dried colloidal suspension can be species manifests within the dried film. Crucially, the intricate de- investigated. One can see that a thin layer of big particles tails of the final conformation demand an accurate numerical treat- develops in close proximity to the substrate, similar to the one ment of the dynamics of the closely packed colloidal suspension, to forming throughout the simulation at the air-solvent interface. which adaptive BD offers a feasible solution. This process can again be explained by the lower mobility of the big particles compared to the small ones, which prevents a uniform diffusion away from the substrate. Moreover, as the packing fraction increases further, the V. CONCLUSION structure of the interfacial layers of the trapped big species changes. While only a single peak is visible at first, a second In this work, we have constructed a novel method for BD peak develops in the last stages of the evaporation process. simulations by employing recently developed algorithms for This phenomenon occurs both at the substrate as well as at the the adaptive numerical solution of SDEs to the case of Brow- air-solvent interface, although its appearance happens earlier nian motion as described on the level of the overdamped and more pronounced at the former. Langevin equation (1). For the evaluation of a local error Even for this simple model mixture of colloidal particles estimate in each trial step, we have complemented the sim- which differ only in diameter, the final conformation after ple Euler-Maruyama scheme (8) found in common BD with a evaporation of the implicit solvent possesses an intricate struc- higher-order Heun step (9). By comparison of their discrep- ture. Both at the substrate as well as at the top of the film, a ancy with a user-defined tolerance (11) composed of an abso- primary and secondary layer of the big particle species build lute and a relative contribution, we were able to impose a cri- up. Those layers enclose a broad accumulation of the small terion (16) for the acceptance or rejection of the trial step and particle species, which is by no means uniform but rather de- for the adaptation of ∆t. Special care was thereby required in
You can also read