Skip to main content
The Journal of Chemical Physics logoLink to The Journal of Chemical Physics
. 2019 Dec 27;151(24):244117. doi: 10.1063/1.5125022

Stochastic self-tuning hybrid algorithm for reaction-diffusion systems

Á Ruiz-Martínez 1, T M Bartol 2, T J Sejnowski 2,a), D M Tartakovsky 3,b),
PMCID: PMC7341680  PMID: 31893874

Abstract

Many biochemical phenomena involve reactants with vastly different concentrations, some of which are amenable to continuum-level descriptions, while the others are not. We present a hybrid self-tuning algorithm to model such systems. The method combines microscopic (Brownian) dynamics for diffusion with mesoscopic (Gillespie-type) methods for reactions and remains efficient in a wide range of regimes and scenarios with large variations of concentrations. Its accuracy, robustness, and versatility are balanced by redefining propensities and optimizing the mesh size and time step. We use a bimolecular reaction to demonstrate the potential of our method in a broad spectrum of scenarios: from almost completely reaction-dominated systems to cases where reactions rarely occur or take place very slowly. The simulation results show that the number of particles present in the system does not degrade the performance of our method. This makes it an accurate and computationally efficient tool to model complex multireaction systems.

I. INTRODUCTION

Many mesoscopic models of reaction-diffusion phenomena split a spatial simulation domain into well-mixed compartments.1–5 Such compartment-based representations reduce the computational time required to study a system’s dynamics by keeping track of temporal variability of the numbers of independent particles in individual compartments, rather than the position of individual particles. Time-driven and event-driven approaches are two of the most common criteria used to define a time step in mesoscopic models. The former requires a time step Δt to be small enough for an “event” to happen,6 while the latter draws a waiting time for the next reaction to occur from the exponential distribution.7 In both cases, diffusion is described by the transition of species, either on regular4,5 or irregular3,8 meshes, from one compartment to its neighbor. For reactions, time-driven approaches use random numbers to determine if and which reactions take place; event-driven approaches or stochastic simulation algorithms (SSAs) calculate random numbers to determine which reaction happens first and the time until the next reaction takes place. Although such approaches are efficient for reaction and diffusion description at the mesoscale, they do not explicitly represent a diffusing particle’s position and trajectory.

Spatially extended models9 provide an alternative to their compartment-based counterparts by combining mesoscopic approaches with particle-based methods.10 Some of these hybrid models divide the system into different subdomains; wherein, reactants are described either as particles or as concentrations.11–15 Others classify species as mesoscopic or microscopic depending on the number of particles present in the system.16,17 Some particle-based models also use compartments to study the proximities to a specific particle to reduce the number of candidates that can react in a particular time step and, consequently, to minimize the computational time.18,19 Recent developments in multiscale hybrid simulations of reaction-diffusion systems include Spatiocyte,20 ReaDDy2,21 GFRD,22,23 Smoldyn,24 and other techniques.25–27 The operator-splitting algorithm of Choi et al.28 (henceforth referred to as CM) consists of a particle-based method to describe diffusion and a compartment-based method to represent reactions. Unlike compartment-based models of diffusion, particle tracking does not restrict particle movement to adjacent compartments. This allows for the use of longer time steps and provides a more realistic description of diffusion.

We present a self-tuning operator-splitting algorithm for mesoscopic reaction-diffusion systems, which improves CM. The latter was shown to be more efficient than the Gillespie multiparticle (GMP) method that employs the Gillespie algorithm29,30 and cellular automata31 to handle reactions and diffusion processes, respectively. The enhanced accuracy and efficiency of our method stem from its three features.

First, both accuracy and speed of the operator-splitting algorithms depend on the size and shape of compartments used in the reaction module, and our method redefines these features at every time step. This is important because the accuracy does not necessarily increase as the compartment size decreases; the number of potentially reacting particles and their spatial distribution are essential factors to redefine the compartment mesh. Second, rather than setting the time step to be proportional to the diffusion time,28 in our method, the maximum reaction time determines the time step. Since the reaction time is proportional to a compartment’s volume, the time step also changes proportionally to its size, which makes our method both spatially and temporally adaptive. Third, our algorithm requires neither predefined parameters to determine if the reaction nor diffusion effects are predominant or multiplicative factors to estimate a proper time step.

We demonstrate the proposed hybrid mesoscopic algorithm on an elemental bimolecular reaction. This setting is sufficient to highlight the importance of self-adaption in reaction-diffusion algorithms as a means of reducing the computational error. Our approach can also be used to study multireaction phenomena occurring in domains with complex geometry.

II. DESCRIPTION OF THE METHOD

Our stochastic operator-splitting method for reaction-diffusion systems consists of two parts. First, during a given time step, diffusion is modeled via Brownian dynamics in order to estimate particle locations within individual compartments. Second, the stochastic simulation algorithm (SSA)7 with propensities defined in terms of the particle locations before and after diffusion is used to compute the reaction time step during which the particles undergo additional Brownian motion. Thus, the first step (diffusion only) is an estimate that helps to make more accurate calculations in the second step (diffusion until reaction happens). The method’s workflow is as follows.

  • Space partition: The simulation domain is subdivided into a set of nonoverlapping compartments. Their size and spatial arrangement depend on the location and number of particles and on a first estimate of the compartment-scale Damköhler number, which is explicitly defined for our system in Eq. (6).

  • Time partition: The optimal time step is calculated. It is proportional to the maximum reaction time and, therefore, to the compartment volume. It is also inversely proportional to the reaction rate constants.

  • Diffusion process only: Diffusion of species between compartments is modeled via Brownian dynamics in order to estimate the concentration of species in each compartment after the optimal time step was previously estimated.

  • Combined diffusion-reaction process: Reactions within some compartments are simulated via SSA. Propensities are defined in terms of the concentrations before and after the time step from the diffusion-only scenario and according to the compartment-scale Damköhler number. The SSA-estimated time for every particle is assumed to be the time it takes for the particle to diffuse until it reacts.

  • Time is increased by the time step, and the above procedure is repeated until the final desired time.

Three key properties define our method: an appropriate choice of the compartments’ size and shape, the time-step proportional to the maximum reaction time, and the modified propensities for SSA. The synergy of these characteristics makes up a novel approach which, as we demonstrate below, stands out for its computational efficiency even in limiting cases with very slow diffusion or, conversely, a diffusion-dominated regime. We focus on a bimolecular reaction,

A+BC. (1)

Henceforth, mathematical expressions are defined in terms of the reactants A and B and their product C.

A. Compartment size and shape

A proper choice of the compartment size and shape is critical to prediction accuracy.32 If all Ncom compartments are regular and identical, a good initial estimate of the volume of the ith compartment at the kth time step is V~ik=Vtot/min{nkA,nkB}. Here, Vtot is the system’s total volume; nkA and nkB are, respectively, the total number of particles of species A and B at the kth time step. For the cases presented below, we use isotropic three-dimensional compartments, whose volume in a Cartesian coordinate system is V~ik=V~k=Δx~kΔy~kΔz~k for all i = 1, …, Ncom.

A compartment’s state is determined in terms of the dimensionless Damköhler number Dak,Δs~k, which is defined at the kth time step for the compartment scale Δs~k with s = x, y, z. The maximal diffusion time is estimated as

Tdiffkmax=V~k2/32dmin{DA,DB}=Δs~k22dmin{DA,DB}, (2)

where DA and DB are the diffusion coefficients of particles A and B, respectively; and d is the system’s dimensionality (d = 3 in three dimensions). The maximum reaction time, Treackmax, corresponds to the situation in which the minimum number of particles react in a compartment, i.e.,

Treackmax=1amin,k, (3)

where amin,k is the propensity at the kth time step. For the bimolecular reaction A + BC with reaction rate constant kr whose units are 1/(molar time), the minimum propensity is

amin,k=krnmin,kAnmin,kBNAvV~k. (4)

Here, NAv is the Avogadro number; nmin,kA=1 and nmin,kB=1 are, respectively, the minimum number of particles of A and B that react in a compartment. Thus,

Treackmax=NAvV~kkrnmin,kAnmin,kB=NAvΔs~k3kr. (5)

With these definitions, the compartment’s state at the kth time step is characterized by the Damköhler number,

Dak,Δs~k=TdiffkmaxTreackmax=kr6NAvΔs~kmin{DA,DB}. (6)

Both relative strength of the reaction and anisotropic variations of the concentrations determine the compartment’s size in every spatial direction. In the reaction-dominated regime, Dak,Δs~k10,33,34 the compartments are anisotropic, with smaller compartment dimensions in the directions in which the spatial variations of concentration are larger. In the diffusion-dominated regime, Dak,Δs~k0.1, the compartments are isotropic. For the intermediate regime, compartments are isotropic when 0.1<Dak,Δs~k1 and anisotropic when 1<Dak,Δs~k<10. For example, in a system with large variations of concentrations in the x direction and Dak,Δs~k>1, one could use compartments with large Δy~k and Δz~k, and small time-varying Δx~k. Thus, our first estimate for Δs~k must be redefined as

Δs~kVtot1/3/min{nkA,nkB},s=x,Δ~>Δx~k,s=y,z. (7)

Once the initial shape and size for the compartment is estimated and a mesh is created, the product of the number of particles A and B that are available for the bimolecular reaction A + BC in the ith compartment at the kth time step is Pik=nikAnikB. A criteria to decide whether the compartment size is adequate for accurate predictions is to ensure that S1,k, the number of compartments where Pik = 1, is at least as large as S2,k, the number of compartments where Pik > 1. These criteria facilitate the subsequent definitions of the time steps as being proportional to the compartment volume Vk and inversely proportional to the minimum propensity amin,k, i.e., the propensity of one particle of A and one particle of B reacting in a compartment. A mesh with the propensity amin,k in the majority of the compartments is discretized enough to guarantee that the time step is not too long and the number of reactions is not overestimated. Therefore, we establish a condition

S1,kS1,k+S2,kα, (8)

with α = 0.5 for isotropic compartments. Our numerical experiments show that this condition provides a good balance between accuracy and computational efficiency because the choice of large values for α could create a mesh with no pairs of molecules in any compartment. For anisotropic compartments, the choice of α is less restrictive because the optimal shape of the compartment already increases the efficiency of the mesh. In such a scenario, we found a value of α = 0.1 to provide a noticeable balance between accuracy and computational efficiency. If the criterion (8) is not met, our algorithm recalculates the size Δs~k of the compartments until the condition is satisfied. The value of Δs~k that meets the criterion (8) is the optimal size at the kth time step, Δsk=Δs~k, with s = x, y, z, and the compartment volume with optimal dimensions is Vk = ΔxkΔykΔzk.

B. Time-step selection

We define the reaction time as τreac,k=Treackmaxln(1/r), where r is a random number distributed uniformly on the unit interval [0, 1]. The probability of ln(1/r) ≤ 1, i.e., the probability of τreac,kTreackmax, is 0.63. Accounting for (3), this choice implies that on average 63% of the reactions occur in any compartment of propensity amin,k by time Treackmax. In other words, in a system of compartments with propensity amin,k, a reaction occurs in 63% of the compartments before time Treackmax.

Our algorithm estimates the compartments where particles end up after a diffusion time-step and assumes that a reaction occurs with a propensity amin,k any time one particle of A and one particle of B end up in the same compartment. That would result in an overestimated number of reactions since reactions occur only in 63% of the compartments with propensity amin,k. Let āk, with āk > amin,k, denote the average propensity of the system before diffusion, and Δtk = 1/āk define an optimal time step. We impose the condition amin,k = 0.63āk to guarantee that 100% of the particles reacting after diffusion be equivalent to 63% of the molecules of A reacting with B (or vice versa) before diffusion. Then, the optimal time step is

Δtk=1āk=0.63amin,k=0.63Treackmax. (9)

Further details on the time-step selection are provided in Appendix A.

C. System state at the compartment scale

The Damköhler number Dak,Δs~k, which is defined in (6) in terms of the initial compartment estimate Δs~k, provides one way to determine this regime. It depends on the maximum reaction and diffusion times because we choose the ideal compartment size and shape for the longest time step possible without losing accuracy.

We also use the Damköhler number Dak,Δsk with the optimal compartment size Δsk and the minimum reaction time to determine the system regime with higher accuracy. This number is defined in terms of the minimum diffusion and reaction times. We focus on the minimum magnitudes because we are not interested in the entire time step but only in the time that a particle diffuses until it reacts before the time step is complete. Thus,

  • the minimum time that a particle needs to move to observe variations in the concentration within a compartment due to diffusion is Tdiffkmin=(min{Δsk})2/(2dmax{DA,DB});

  • the minimum reaction time provides information about the time that a particle needs to move to notice variations in the concentration in a compartment mainly due to reaction. The compartment i with the maximum propensity determines the value of the minimum reaction time such that Treackmin=1/amax,k=VkNAv/(krmaxi{Pik}).

With these preliminaries, we define the global Damköhler number,

Dak,Δsk=TdiffkminTreackmin=kr(min{Δsk})2maxi{Pik}2dmax{DA,DB}VkNAv. (10)

D. Modified Gillespie algorithm

Once the compartments, the time step, and the system state at the compartment scale are defined, we count the number of particles per compartment before allowing the system to diffuse or react. Then, the particles undergo Brownian motion during the kth time step, and the number of particles in each compartment is counted again. From this information and knowing the volume of the compartments, the propensity functions along an lth particle’s trajectory is computed as

aikl=krVkNAv[χciklA+(1χ)ciklA][χciklB+(1χ)ciklB], (11)

where the subscripts i and i′ refer to the compartments where the particle l is located before and after diffusion during the kth time step, respectively; k and k′ = k + Δtk label the times before and after the time step Δtk; ciklA and ciklB are the concentrations of molecules A and B in the ith compartment and time k; ciklA, ciklB are the concentrations of molecules A and B in the compartment i′ and time k + Δtk; and χ is a factor that quantifies the probability of reaction of the molecule l at its initial location. In the diffusion-dominated regime (Dak,Δsk0.1), we set χ = 0.5 to ensure that diffusion dominates and that the probability of the lth particle to react is not affected by possible reactions of other particles. The propensity aikl is, therefore, defined in terms of the average of the initial and final concentrations.

In the reaction-dominated and intermediate regimes (Dak,Δsk>0.1), we chose χ = 0.37 to ensure that, according to the definition of the time step Δtk in (9), about 63% of the particles at the initial location i react fast and only 37% of them influence the particle l. Consequently, approximately 63% of molecules in the compartment i′ influence the particle l. Appendix B provides additional information about the selection of χ. Appendix C contains analytical and numerical justifications for the choice of Dak,Δsk=0.1 as the limit between the diffusion-dominated and intermediate regimes.

In the spirit of the Gillespie algorithm,7 for diffusion-dominated scenarios, we define a continuous random variable Δtikl,

Δtikl=1aiklln1rl, (12)

where rl is a random number distributed uniformly on the unit interval [0, 1]. It describes the time that the lth particle diffuses from the compartment i during the time step Δtk until it reacts, i.e., Δtikl = Δtk for the majority of the particles.

As reaction effects become dominant, i.e., for large values of the reaction rate constant kr, the cumulative distribution function of the continuous random variable Δtikl,

rl=1eaiklΔtiklwithaiklkr,

is approximated via a Taylor expansion by

Δtiklrlaikl. (13)

In this regime, reactions happen before particles move a time step Δtk. Thus, the larger the reaction effects, the smaller the values of Δtikl, such that Δtikl < Δtk for the majority of the particles.

If the system is diffusion-dominated (Dak,Δsk0.1), then

Δtikl=ln(1/rl)0.25krVkNAv(ciklA+ciklA)(ciklB+ciklB). (14)

If the system is in intermediate or reaction-dominated regimes (Dak,Δsk>0.1), then

Δtikl=rlkrVkNAv(0.37ciklA+0.63ciklA)(0.37ciklB+0.63ciklB). (15)

III. ALGORITHM

Numerical implementation of the above steps of our stochastic operator-splitting method, implemented for a bimolecular reaction A + BC, is provided below.

  • (1)

    Initialize t = 0.

  • (2)

    While ttfinal

    • (I)

      Set Δtk = 0 and define initial isotropic compartments.

    • (II)

      Calculate Dak,Δs~k.

      • If Dak,Δs~k>1, use initial anisotropic compartments and set α = 0.1;

      • If Dak,Δs~k1, use initial isotropic compartments and set α = 0.5;

      • end

    • (III)

      While Δtk = 0

      • (A)

        For each compartment i

      • (i) calculate nikA and nikB,

      • (ii) calculate Pik,

      • end

      • (B)

        Count compartments with Pik = 1 to obtain S1,k.

      • (C)

        Count compartments with Pik > 1 to obtain S2,k.

      • (D)

        If S1,k/(S1,k + S2,k) < α,

      • reduce compartment size,

      • else,

      • Δtk = 0.63 × VkNAv/kr,

      • end

    • end

    • (IV)

      Calculate concentration in all compartments before advancing species.

    • (V)

      Use Brownian dynamics to advance species with time step Δtk and estimate their concentrations with no reaction effects.

    • (VI)

      Assign an initial time ti = t to all compartments i and reset told,i = ti.

    • (VII)

      Calculate Dak,Δsk.

    • (VIII)

      Define particle counters Ai and Bi for all compartments i and set them to zero, Ai = Bi = 0.

    • (IX)

      For each particle l (randomly selected from all the existent particles of species A or B; let’s suppose a particle of A is selected)

      • (A)

        If the system is in the diffusion-dominated regime at the compartment scale (Dak,Δsk0.1),

      • use (14) to determine Δtikl,

      • if the system is in the intermediate or reaction-dominated regime at the compartment scale (Dak,Δsk>0.1),

      • use (15) to determine Δtikl,

      • end

      • (B)

        If Δtikl < Δtk,

      • use Brownian dynamics to advance particle l along the trajectory calculated in step (V) but with time step Δtikl,

      • else,

      • assume that the particle is at the location calculated in step (V), i.e., Δtikl = Δtk,

      • end

      • (C)

        Determine in which compartment i* the particle l is located after Δtikl.

      • (D)

        If ti*Δtk+told,i*,

        • (i)

          Ai*=Ai*+1,

        • (ii)

          define the reaction time associated with the particle l in the compartment i* as ti*lA=Δtikl,

        • (iii)

          if Ai*>0 and Bi*>0,

      • (a)

        the reaction is fired and t*=min{ti*lA,ti*lB} determines the reaction time of a pair of particles l and l′ from A and B species, respectively, in cell i*,

      • (b)

        update ti* such that ti*=t*+ti*,

      • (c)

        remove particle l of species A and molecule l′ of species B and generate a particle of C in a location halfway between the positions where this pair of particles was located,

      • (d)

        Ai*=Ai*1 and Bi*=Bi*1,

      • (e)

        if ni*kA>0 and ni*kB>0,

      • ni*kA=ni*kA1 and ni*kB=ni*kB1 and, consequently, update concentrations ci*kA and ci*kB,

      • else,

    • do not update ni*kA, ni*kB, ci*kA, and ci*kB,

    • end

    • else,

    • do not update, no reaction is fired,

    • end

    • else,

    • do not update, no reaction is fired,

    • end

    • end

  • (3)

    Set t = t + Δtk.

    • end

IV. RESULTS AND DISCUSSION

We demonstrate that our method possesses a better balance of accuracy, computational speed, and versatility than CM. The Douglas Gunn alternating-direction-implicit (ADI) numerical method35 is used to calculate a deterministic solution that we treat as a reference for validation (Appendix D). Henceforth, we use interchangeably the terms deterministic solution and partial differential equation (PDE) solution to refer to the ADI method solution.

We consider a cubic domain D with volume V = 10−18 m3, such that D{0xL,0yL,0zL} with L = V1/3. At time t = 0, NA0 molecules of species A and NB0 molecules of species B are randomly placed in the region D{0xL/2,0yL,0zL} (Fig. 1). These molecules then diffuse with the same diffusion coefficient D and bounce off the boundaries, so they never leave the domain. They also react according to the chemical reaction A + BC with the reaction rate kr. Molecules of species C are also assumed to diffuse with the same diffusion coefficient D.

FIG. 1.

FIG. 1.

Graphical representation of the system. Initially, molecules of A and B are only present in the half-domain D.

This computational setting is similar to the case used to analyze the performance of CM.28 The initial placement of all molecules in a half of the domain facilitates comparison of the diffusion- and reaction-dominated scenarios. In the former, the number of molecules of C in the region D does not reach a stable value of 300 until steady state. In the latter, the number of molecules of C in the region D exceeds 300, reaches a maximum value, and then decreases over time until steady state.

The system regime for all cases presented in this work is determined by the system-scale Damköhler number DaL. It defines the system regime at t = 0 and at the scale of the characteristic length L. Thus,

  • the characteristic diffusion time is defined as Tdiffmin=L2/(6max{DA,DB}); and

  • the characteristic reaction time of the system is Treacmin=L3NAv/(krmax{NA0,NB0}).

The Damköhler number for the whole system is

DaL=TdiffminTreacmin=krmax{NA0,NB0}6max{DA,DB}LNAv. (16)

Henceforth, unless stated otherwise, all results are based on the sample average of 5000 trials. The reaction rate for all cases is kr = 6 × 104 mM−1 s−1.

A. Performance analysis

We start by demonstrating how the choice of appropriate compartment size and shape affects the simulation accuracy. We study the temporal evolution of the number of C molecules in the region D in three different scenarios: diffusion-dominated (Fig. 2), comparable diffusion and reaction effects (Fig. 3), and reaction-dominated (Fig. 4). The initial number of molecules of species A and B is NA0=NB0=600. By studying the system at early times, we estimate the dimensions of initial isotropic and anisotropic compartments and demonstrate how their dimensions can be modified to define optimal compartments.

FIG. 2.

FIG. 2.

Temporal evolution of the number of C molecules in domain D for the diffusion-dominated regime (DaL = 0.01) and NA0=NB0=600. The solid line in both graphs is the PDE solution. Top: Circles indicate the solution obtained by our method. Bottom: Squares, circles, and diamonds are the solutions obtained by CM with Δx = Δy = Δz = L/4, L/8, and L/16, respectively.

FIG. 3.

FIG. 3.

Temporal evolution of the number of C molecules in domain D for the intermediate regime (DaL = 1) and NA0=NB0=600. The solid line is the PDE solution in both graphics. Top: Circles are the solution obtained by our method. Bottom: Squares, circles, and diamonds are the solutions obtained by CM with Δx = Δy = Δz = L/4, L/8, and L/16, respectively.

FIG. 4.

FIG. 4.

Temporal evolution of the number of C molecules in domain D for the reaction-dominated regime (DaL = 100) and NA0=NB0=600. The solid line is the PDE solution in both graphics. Top: Circles are the solution obtained by our method. Bottom: Squares, circles, and diamonds are the solutions obtained by CM with Δx = Δy = Δz = L/4, L/8, and L/16, respectively.

1. Isotropic compartments

For bimolecular reactions, the number of molecules of species A in the system equals that of species B, nkA=nkB, at all times tk. We define the initial regular compartment estimate for any time step Δtk as

V~k=Vtot/min{nkA,nkB}=L3/nkA. (17)

Since the volume of an isotropic compartment is V~k=Δx~kΔy~kΔz~k=(Δx~k)3, it follows from (17) that Δx~k=L/(nkA)1/3. To enforce condition (8), we use the above result to introduce an integer domain-partition parameter,

κkL/Δx~k=(nkA)1/3. (18)

Since we are interested in the number of C molecules in the left half of the domain, we set the minimal value of κk to 2; this ensures that the compartments are not larger than half of the domain. Furthermore, we take κk to be an even number that increases by 2 so that Δs~k=L/κk with s = x, y, z is continually modified in step (III) of our algorithm until condition (8) is met. Once the optimal compartment volume Vk is estimated, the optimal time step Δtk is defined.

2. Anisotropic compartments

For the problem under consideration, one can expect the average concentration of molecules to change in the x-direction during the entire process. In order to define the initial anisotropic compartment estimate, we focus on the compartment dimension along the x-direction, Δx~k, and assume that molecules are uniformly distributed in the region D along this direction at t = 0. Then, Δx~k is defined as

Δx~k=L2min{nkA,nkB}=L2nkA. (19)

Therefore, parameter κk for anisotropic compartments is

κkL/Δx~k=2min{nkA,nkB}=2nkA. (20)

Analogously to isotropic compartments, we take κk ≥ 2 to be an even integer that increases by 2 until condition (8) is met. The values of Δyk and Δzk are constant and equal to L during the entire process.

We use the root mean square error (RMSE) to measure the difference between the number of C molecules in the region D predicted by the two operator-splitting algorithms, N^Ck, and the PDE solution, NCk. To facilitate the comparison, we discretize time into averaging time steps Δt¯k and, for each method, calculate the average of N^Ck during the time step (t,t+Δt¯k). Next, we average over the number of trials to obtain an estimate N^Ck¯ for every Δt¯k. The RMSE is defined as

RMSE=1k¯fk¯=1k¯f(N^Ck¯NCk¯)2, (21)

where k¯f denotes the index of the final averaged time step. To maintain the desired accuracy, the value of Δt¯k must decrease as the variation of molecules in time increases and vice versa.

Table I shows the RMSE values for CM and our method. Three transport regimes are considered: diffusion-dominated (DaL = 0.01 and D = 10−9 m2/s), intermediate (DaL = 1 and D = 10−11 m2/s), and reaction-dominated (DaL = 100 and D = 10−13 m2/s). These results lead to the following observations.

  • Our method is fully specified by the system’s inherent characteristics, i.e., the number of molecules, their spatial distribution, diffusion coefficients, and reaction rates. That is in contrast with CM, which requires two user-specified parameters to determine if a system is in the reaction-dominated, intermediate, or diffusion-dominated regime and two parameters to estimate a proper time step.

  • Our algorithm optimizes both compartment dimensions and time step to guarantee accuracy during the entire process in any transport regime.

TABLE I.

Root mean square error (RMSE) for our operator-splitting algorithm and CM. The superscript * represents the sample average of 20 000 trials, and Δ denotes the size of cubic compartments relative to the system’s size L. Units of RMSE are in the number of molecules of species C, averaged over 20 000 trials for the diffusion-dominated case and over 5000 for the other two scenarios.

RMSE
Regime DaL CM, Δ = L/4 CM, Δ = L/8 CM, Δ = L/16 Our method
Diffusion-dominated* 0.01 0.3949 0.4150 1.0855 1.2141
Intermediate 1 3.3558 1.6514 3.6082 0.7374
Reaction-dominated 100 17.9951 34.9453 63.9988 3.8607

Except for the diffusion-dominated regime, our algorithm outperforms CM in terms of accuracy, with the latter method’s error increasing with the decrement in the diffusion coefficient (for a fixed reaction rate), i.e., as the system becomes more reaction-dominated (Figs. 2–4 and Table I).

Next, we explore the relative efficiency of our method vis-à-vis CM. To this end, we select the compartment size Δx = Δy = Δz = L/6 that maximizes the latter method’s efficiency. Table II and Figure 5 present the RMSE and computational time for both methods. As before, the initial number of molecules for both species is NA0=NB0=600.

TABLE II.

Root mean square error (RMSE) for our operator-splitting algorithm and CM. The superscript * represents the sample average of 20 000 trials. Both the time to reach the steady state, tkss, and the computational time are in seconds. Units of the RMSE are in the number of molecules of species C. Both the computational time and the RMSE are averaged over 20 000 trials for the diffusion-dominated cases and over 5000 for the other scenarios. All simulations have been performed using MATLAB software.

CM Our method
Regime DaL tkss (s) RMSE Computational time (s) RMSE Computational time (s)
Diffusion-dominated* 0.01 1 0.5909 9.6988 0.9975 0.0441
Diffusion-dominated* 0.02 1 0.5159 4.5942 0.7768 0.0428
Diffusion-dominated/intermediate transition* 0.1 1 0.5370 0.9275 1.0670 0.0435
Intermediate 1 1 0.7997 0.1015 0.5520 0.0421
Reaction-dominated/intermediate transition 10 1.5 3.2728 0.0455 2.2674 0.0405
Reaction-dominated 50 3 9.9077 0.0253 3.1173 0.0412
Reaction-dominated 100 6 14.0846 0.0250 3.0902 0.0388
FIG. 5.

FIG. 5.

Root mean square error or RMSE (top) and computational time (bottom) as a function of the Damköhler number DaL. Solid lines correspond to our algorithm, and dashed lines represent CM.

The results in Table II and Figure 5 demonstrate that our method is more accurate than CM when diffusion does not dominate. The highest differences in accuracy are reached for DaL = 100, with the RMSE of our method being 4–5 times smaller than that of CM. In the diffusion-dominated regime, the RMSE of CM is twice smaller than that of our algorithm although both methods increase their performance by reducing the RMSE to values around 1 molecule of C or less. The computational time required by our method does not depend on the regime of the system. That is in contrast to CM, whose computational time increases as the diffusion effects become stronger, eventually becoming 220 times less efficient than our algorithm for DaL = 0.01. In the reaction-dominated regime, CM is faster, but its accuracy declines much more than our method’s.

Our method is also appreciably faster than MCell,36 a Monte Carlo simulator that predicts reactions at a particle level (Appendix E). This finding holds regardless of whether a small (rint = 5 × 10−3 μm) or large (rint = 0.1 μm) interaction radius between molecules is imposed by MCell.

B. Robustness in limiting conditions

To explore the robustness of our algorithm, we consider two extreme cases with the concentrations varying rapidly in space and/or time. Figure 6 shows a fast variation of the number of C molecules: in less than 0.1 s almost all molecules of A and B react in the half-domain D before diffusion manifests itself. It is, therefore, an almost completely reaction-dominated scenario with DaL = 104.

FIG. 6.

FIG. 6.

Temporal evolution of the number of C molecules in the region D for a case with highly dominant reaction effects (DaL = 104). The solid line is the PDE solution in both graphics. Top: Dashed and dashed-dotted lines are the solutions obtained by CM with Δx = Δy = Δz = L/6 and our method with anisotropic compartments. Bottom: Close-up view of the first time-steps.

Figure 6 also demonstrates that in the reaction-dominated regime, our algorithm significantly outperforms its competitor in terms of accuracy. This is despite the fact that the simulations are carried out with the compartment size optimized for CM. Our algorithm autonomously selects narrow compartments and smaller time steps to make better predictions. Figure 6 shows that by using compartments with time-varying Δxk and constant Δy = Δz = L, our algorithm captures variations in the concentration due to low diffusion.

Figure 7 exhibits a fast decay in the number of A molecules due to diffusion: in less than 10−4 s, almost half of the A molecules leave the half-domain D before the reaction takes place. This is an example of the strongly diffusion-dominated regime with DaL = 10−4. In this regime, the CM predictions are accurate provided an appropriate compartment size is selected. Nevertheless, such an accuracy comes at a high computational cost. That is because the time steps in the CM algorithm are proportional to the diffusion time so that larger diffusion coefficients lead to smaller time steps.

FIG. 7.

FIG. 7.

Temporal evolution of the number of A molecules in the region D for a case with highly dominant diffusion effects (DaL = 10−4). The solid line is the PDE solution in both graphics. Top: Squares and circles are the solutions obtained by CM with Δx = Δy = Δz = L/6 and our method based on the sample average of 20 000 trials. Bottom: Close-up view of the first time-steps.

Figure 7 illustrates that our method does not need small time steps to guarantee high accuracy as the diffusion effects increase. Large time steps still provide high levels of accuracy and computational speed. Also, in contrast to CM, step (a) of our algorithm provides information about the system’s state during the first time step. It determines when and where reactions occur. Specifically, t*=min{ti*lA,ti*lB} determines the reaction time of any pair of particles l and l′ from A and B species at the compartment i*, during any time step Δtk.

C. Effect of number of molecules

In this section, we study the influence of the number of particles present in the system on the accuracy and computational speed of our method. Figures 8–10 show the temporal evolution of the relative number of C molecules, i.e., NC/NA0, in the region D for different initial numbers of molecules NA0 and NB0, until the steady state is reached. In these simulations, we set the diffusion coefficient to D = 2 × 10−13 m2/s. As the number of reacting particles increases, more interactions occur in shorter times, and the maximum number of C particles is reached faster. For the first time steps (t < 0.1 s), our algorithm chooses anisotropic compartments, which provides better results than those obtained with CM. For longer times (t > 0.1 s), the predominant process is diffusion of species C and both CM and our algorithm are accurate. These results show that our method is able to describe processes that occur at different time scales: from short time scales, 10−4 s ≤ t ≤ 10−2 s, to long-term reactions and variations of concentrations, 10−2 s ≤ t ≤ 10 s.

FIG. 8.

FIG. 8.

Temporal evolution of the relative number of C molecules for NA0=NB0=6×102 particles (DaL = 50). Solid, dashed, and dashed-dotted lines are the PDE solution, the solution obtained by CM with Δx = Δy = Δz = L/8, and the solution obtained by our method, respectively.

FIG. 9.

FIG. 9.

Temporal evolution of the relative number of C molecules for NA0=NB0=6×103 particles (DaL = 500). Solid, dashed, and dashed-dotted lines are the PDE solution, the solution obtained by CM with Δx = Δy = Δz = L/16, and the solution obtained by our method, respectively.

FIG. 10.

FIG. 10.

Temporal evolution of the relative number of C molecules for NA0=NB0=6×104 particles (DaL = 5000). Solid, dashed, and dashed-dotted lines are the PDE solution, the solution obtained by CM with Δx = Δy = Δz = L/32, and the solution obtained by our method, respectively.

Let NC* denote the maximum number of C molecules present in the subdomain D relative to the initial number of molecules of A or B,

NC*=1NA0maxk¯{NCk¯}. (22)

Furthermore, let φ be the relative error/discrepancy between the times it takes to reach NC*, as predicted with the solution of the partial differential equations (tPDE) and one of the particle methods (tm with m designating either CM or our method) estimates,

φ=|tPDEtm|tPDE. (23)

Table III shows that both NC* and the time-to-equilibrium predicted with our method are in close agreement with those predicted by the deterministic PDEs, while CM underestimates NC* and overestimates the time-to-equilibrium in all scenarios. Moreover, the relative error φ of CM increases with the number of reacting molecules. On the contrary, the errors in our method do not increase with the number of molecules and the relative error φ is virtually negligible. Table IV collates the computational times (CT) required by both methods to reach the steady state. The computational time required by CM increases much faster with the number of molecules than our method. For the latter, the scenario with 6 × 104 molecules, our method is 12 times faster than CM.

TABLE III.

Relative maximum number of molecules of species C, NC*, and relative time error, φ, corresponding to CM and our method for different initial number of molecules, NA0 and NB0.

PDE CM Our method
NA0 and NB0 NC* NC* φ NC* φ
6 × 102 0.769 0.710 0.489 0.761 ∼0
6 × 103 0.895 0.834 1.269 0.887 ∼0
6 × 104 0.955 0.903 3.050 0.950 ∼0

TABLE IV.

Values of the computational times until steady state is reached correspondent to CM and our method for different initial number of molecules, NA0 and NB0.

Computational time (s)
NA0 and NB0 CM Our method
6 × 102 0.027 0.043
6 × 103 1.356 0.380
6 × 104 46.639 3.671

For CM, we have chosen compartment sizes that maximize its efficiency. The more the particles react, the smaller the optimal compartment is. Nevertheless, despite choosing compartment sizes that guarantee high accuracy, there are still differences between the PDE solution and the CM estimates. Moreover, a fixed compartment size used in CM implies that, after reaching the maximum number of C particles, this size is not optimal anymore in terms of computational speed. When diffusion of nonreactive particles becomes dominant, it is more convenient to resize the mesh and define larger compartments and time steps.

Our algorithm refines both the compartment size and the time step and makes more accurate estimates during the entire process in all presented cases. Also, the computational time necessary to compute the solution until the steady state is reached is lower than the one required by CM. That is also due to the self-tuning nature of our method. Compartments and time steps are refined according to the number and spatial distribution of reactive molecules A and B. When diffusion of nonreactive particles C is dominant, our method moves forward in time much faster than CM.

It is important to remark that our method becomes much more efficient than CM as the number of molecules increases because mesoscopic models are ideal for systems with medium-to-large numbers of particles with noticeable stochastic effects. The presence of large numbers of reactive molecules in a system increases reaction effects that our method describes more accurately and faster than CM does. On the contrary, the presence of a large number of nonreactive molecules increases diffusion effects; highly refined compartments and time steps in CM undermine its efficiency.

V. CONCLUSIONS

We developed a hybrid mesoscopic model of reaction-diffusion systems that improves upon CM by refining the balance between accuracy and computational speed, by making it more versatile, and by increasing its range of applicability. By optimizing compartment dimensions and time steps, we avoid unnecessary calculations in both diffusion- and reaction-dominated systems. Also, the present modified Gillespie algorithm describes reactions more realistically since they can happen at any point along particle trajectories. The presence of a high number of molecules in the system emphasizes the efficiency of our algorithm when it is compared to CM and MCell. These characteristics make our method a better choice to model mesoscopic systems with noticeable stochastic phenomena. In terms of accuracy and computational cost, our method shines in systems with predominant diffusion effects and a high number of particles. In cases with predominant reaction effects and a high number of particles, it also keeps a solid and optimal balance.

The Gillespie algorithm implicitly assumes that compartments are well-mixed, which is not realistic at a basic particle level. Combining our method with particle-based methods for reactions would improve estimates of highly reactive systems and would describe scenarios with a low number of molecules that cannot be validated with PDE solutions. On the other hand, PDE-based methods would accelerate calculations for scenarios with a very large number of particles. Since our method provides an efficient mesoscopic description of a basic bimolecular reaction A + BC, it naturally fits into hybrid particle/PDE models where species A and B could be defined as deterministic and stochastic, respectively.

The self-tuning nature of our algorithm and its applicability to a wide range of regimes make it useful for more complex scenarios with nonregular geometries and additional reactions. By guaranteeing a considerable level of efficiency for a simple system, we ensure a smaller propagation of errors than its direct competitor, CM.

An example of a MATLAB code developed for this study and the MATLAB code for the PDE solution is available for download in the Github repository “https://github.com/AlvaroRuizMartinez/hybridalgorithm.”

ACKNOWLEDGMENTS

This work was supported in part by the Air Force Office of Scientific Research under Award No. FA9550-17-1-0417, by the U.S. Department of Energy under Award No. DE-SC0019130, and by a gift from TOTAL.

APPENDIX A: TIME-STEP SELECTION

  • (1)
    We follow the CM approach to define a characteristic reaction time at a kth time step for the entire system:
    • For an ith compartment (i = 1, …, Ñcomp with ÑcompNcomp, where Ñcomp and Ncomp are the number of compartments with propensities larger than 0 and the total number of compartments, respectively) at a kth time step, we define a macroscopic time constant
      Treacik=1aik, (A1)
      where aik is a propensity function.
    • At each time step, we find the maximum value of the macroscopic time constants over all compartments,
      Treackmax=maxi{Treacik}. (A2)
      While CM uses the minimum value of the macroscopic time constants over all compartments, we employ the maximum time value. We consider the maximum reaction time, Treackmax (or minimum propensity, amin,k=krnikAnikB/(NAvVk) with nikAnikB=1), to be the characteristic reaction time in the compartments. That is because of the condition imposed by our method in Sec. II A: the majority of the compartments must have one pair of molecules of A and B, i.e., nikA=nikB=1.
    • Taking the Gillespie algorithm7 as a reference, we define a continuous random variable τreac,k in terms of the maximum time Treackmax,
      τreac,k=Treackmaxln1r, (A3)
      where r is a random number distributed uniformly on the unit interval [0, 1]. Figure 11 shows a frequency chart of ln(1/r) and the corresponding cumulative distribution function. It reveals that the probability of ln(1/r) ≤ 1, i.e., the probability of τreac,kTreackmax, is 0.63. This is equivalent to a system of compartments of propensity amin,k in which a reaction occurs in 63% of the compartments before time Treackmax.
  • (2)
    Step (IX) of our algorithm (see Sec. III) uses the modified Gillespie algorithm (Sec. II D) to calculate the time Δtikl it takes for the lth particle to diffuse in the kth time step, Δtk, until it reacts in the ith compartment. Thus, our algorithm estimates the compartments where particles end up after diffusion and assumes that any time one particle of A and one particle of B end up in the same compartment: (i) a reaction happens with propensity amin,k and (ii) the time in such a compartment advances by a time step equal to min{Δtikl, Δtk}. That overestimates the number of reactions since in a system with the characteristic minimum propensity, amin,k (or characteristic time Treackmax), reactions occur only in 63% of the compartments. In order to avoid such overestimation, the appropriate time step must be shorter than Treackmax and is calculated as follows:
    • Let us define the average propensity of any compartment before diffusion is
      āk=krn¯kAn¯kBNAvVk, (A4)
      where n¯kA and n¯kB are the average values of molecules of A and B over all compartments at the kth time step.
    • Let us also define the average time step is the inverse of the average propensity before diffusion, Δtk = 1/āk. We impose the condition that the characteristic propensity before diffusion, āk, and the characteristic propensity after diffusion, amin,k, satisfy
      amin,k=0.63āk. (A5)
      This condition guarantees that 100% of molecules reacting after diffusion are equivalent to 63% of the molecules of A reacting with B (or vice versa) before diffusion. Thus, the optimal time step is expressed as
      Δtk=1āk=0.63amin,k=0.63Treackmax. (A6)

FIG. 11.

FIG. 11.

Top: Histogram of ln(1/r), where r is a uniformly distributed random variable in [0, 1]. Bottom: Cumulative fraction of counts out of the total 106 counts. About 63% of the numbers have values less than 1.

APPENDIX B: ESTIMATION OF PARAMETER χ

Consider an lth molecule of A that diffuses from a compartment i to a compartment i′ during the time interval [t, t + Δtk]. Our algorithm estimates n¯iklB, the average number of collisions of A with molecules of B between compartments i and i′, as

n¯iklB=Pcollision,iniklB+Pcollision,iniklB. (B1)

Here, niklB and niklB are the number of collisions (or molecules of B) in compartments i and i′, respectively; and Pcollision,i and Pcollision,i are the probabilities of A colliding with any molecule of B in compartments i and i′, respectively. Let ciklB denote the concentration of molecules B in the ith compartment at time k and ciklB be the concentration of molecules B in the compartment i′ at time k′ = k + Δtk assuming that no reaction occurs during time step Δtk (our algorithm calculates these concentrations in Step (V) of Sec. III). Dividing (B1) by the volume of a compartment and the Avogadro number, we obtain the average concentration of B molecules that can react with A along its trajectory,

c¯iklB=χciklB+(1χ)ciklB, (B2)

where χ = Pcollision,i and 1 − χ = Pcollision,i. Thus, the propensity of the lth molecule of A in the ith compartment to react with any molecule of B or vice versa is defined as

aikl=krVkNAvc¯iklAc¯iklB. (B3)

Here, Vk is the volume of the ith compartment at the kth time step, assuming that all compartments are similar (Vk = Vik, for all i).

Next, we consider a continuous random variable Δtikl defined in terms of the propensity aikl from the Gillespie algorithm,7

Δtikl=1aiklln1rl. (B4)

It describes the time that the lth particle diffuses from the compartment i during the time step Δtk until it reacts. Depending on the regime of the compartment, we make different assumptions for (B2)–(B4) to define the values for the parameter χ:

  • Diffusion-dominated regime (Dak,Δsk0.1). In this regime, molecules are likely to move to adjacent compartments or even further. Since we do not have information about the variations of concentrations between compartments i and i′ during the time step Δtk, we assume similar probabilities for collision in both compartments, i.e., set χ = 0.5 in (B2). With this value, we obtain an estimate of the propensity aikl that, consequently, gives us an estimate of the reaction time, Δtikl, for any molecule l in (B4). This time is used in Step (B) of our algorithm (Sec. III) to estimate the location of the reaction via Brownian motion,

x(t+Δtikl)=x(t)+2DΔtiklrn, (B5)

where D is the diffusion coefficient of the particle, rn is a normal random displacement vector, and x(t) and x(t + Δtikl) are the position vectors of the particle at times t and t + Δtikl, respectively.

For infinitely fast diffusion, i.e., large diffusion coefficient D or Dak,Δsk0.1, our algorithm predicts that molecules diffuse long distances because x(t+Δtikl)x(t)D.

The value χ = 0.5 is also consistent with the limiting scenario, Dak,Δsk=0.1, where molecules move to the adjacent compartments but not further. In the absence of both large variations of concentrations between adjacent compartments (ciklcikl) and noticeable variations of concentrations in time due to diffusion or reaction because none of those phenomena dominate when Dak,Δsk=0.1 (ciklcikl), we express (B2) for any molecule A or B as

c¯ikl=cikl2+cikl2cikl2+cikl2=cikl. (B6)

This concentration defines the propensity in a well-mixed compartment with no other molecules coming from neighbor compartments.

  • Reaction-dominated and intermediate regimes (Dak,Δsk>0.1). In these regimes, molecules are likely to stay in the same compartment while diffusing. The average percentage of molecules that react in a compartment in a time step Δtk is 63%. If reactions happen fast in these regimes, then the concentration of molecules left in the compartment i after the reactions happen is 0.37 · cikl, i.e., χ = 0.37 in (B2). Then, in the compartment i′, the concentration of molecules after diffusion and after reaction, i.e., the concentration of molecules that will react in the time step following Δtk, is 0.63cikl.

For fast reactions, i.e., large deterministic reaction rate constant kr or Dak,Δsk0.1, the propensity defined in (B2) becomes very large. Consequently, the reaction time Δtikl takes small values and molecules do not diffuse far via Brownian motion.

The value χ = 0.37 is consistent with the limiting scenario Dak,Δsk=0.1, where molecules hardly move to adjacent compartments at short reaction times. In the absence of both high variations of concentrations between adjacent compartments (ciklcikl) and noticeable variations of concentrations in time due to diffusion or reaction because none of those phenomena dominate when Dak,Δsk=0.1 (ciklcikl), we express (B2) for any molecule A or B as

c¯ikl=0.37cikl+0.63cikl0.37cikl+0.63cikl=cikl. (B7)

This concentration defines the propensity in a well-mixed compartment with no other molecules coming from neighboring compartments.

APPENDIX C: TRANSITION BETWEEN DIFFUSION-DOMINATED AND INTERMEDIATE REGIMES, Dak,Δsk=0.1

The Damköhler number value of Dak,Δsk=0.1 has been suggested in the past33,34 to delineate the diffusion-dominated and intermediate regimes; CM relies on it to define the time step for the diffusion-dominated regime. Below, we demonstrate analytically and numerically that there is a transition from a regime with dominant diffusion effects to a regime with noticeable reaction effects when Dak,Δsk0.1, where Δsk is the characteristic length of a compartment at the kth time step.

1. Analytical explanation

  • Suppose that a molecule moves from one compartment to another without reaction via Brownian motion,
    x(t+Δtdiff)=x(t)+2DΔtdiffrn, (C1)
    where Δtdiff is the time during which the particle diffuses, rn is a random number distributed normally; x(t) and x(t + Δtdiff) are the locations of the particle at times t and t + Δtdiff, respectively. The distance that a particle moves to transition from one compartment of side Δsk (s = x, y, z) to an adjacent compartment is
    Δsk=r¯n2DΔt¯diff0.82DΔt¯diff,
    where rn¯ is the mean of the half-normal distribution, rn¯=2/π0.8. Therefore, the average diffusion time is estimated by
    Δt¯diff=Δsk21.28D. (C2)
  • Let us take the average reaction time (or time step) defined as the inverse of the average propensity in (A6) and assume that the compartments are isotropic. Then, the average reaction time is
    Δt¯reac=0.63amin,k=0.63NAvVkkr=0.63NAvΔsk3kr. (C3)
    Let us introduce a condition
    Δt¯diffΔt¯reac=kr0.806DNAvΔsk=1. (C4)
    Then, a molecule reacts before leaving the compartment when Δt¯diff/Δt¯reac>1 or it leaves the compartment before it reacts when Δt¯diff/Δt¯reac<1. Assuming that a particle reacts with another one of similar diffusion coefficient and the compartment is isotropic, the compartment-scale Damköhler number defined in Sec. II C has the general form
    Dak,Δsk=kr6DNAvΔsk. (C5)
    It follows from (C4) and (C5) that
    Dak,Δsk=0.806Δt¯diff6Δt¯reac.
    Condition (C4) implies
    Dak,Δsk=0.80660.134, (C6)
    which is close to the reported value of Dak,Δsk=0.1.

2. Numerical calculation

Figure 12 exhibits the temporal evolution of the number of C molecules in domain D for three different scenarios: (a) the diffusion-dominated regime with D = 10−11 m2/s, (b) transition from the intermediate regime to the diffusion-dominated regime with D = 2 × 10−11 m2/s, and (c) the intermediate regime with D = 10−12 m2/s; the regimes are defined at the compartment scale, Dak,Δsk. The solution calculated with MCell36 differs from the PDE solution and the solution estimated by our method when the reaction effects become relevant and the well-mixed compartment assumption breaks down. Figure 12(d) reveals that Dak,Δsk=0.1 is a good estimate to characterize the transition between intermediate and diffusion-dominated regimes. In the diffusion-dominated regime (D = 10−11 m2/s), Dak,Δsk<0.1 during the entire process and MCell yields a solution close to the PDE solution. In the intermediate regime (D = 2 × 10−11 m2/s), the MCell solution differs from the PDE solution before time t ∼ 0.15 s and the temporal evolution of the compartment-scale Damköhler number is consistent with that finding, i.e., Dak,Δsk>0.1 for t < 0.15 s and Dak,Δsk<0.1 for t > 0.15 s. Finally, in the intermediate regime (D = 10−12 m2/s), Dak,Δsk>0.1 during the entire process and the MCell solution differs from the PDE solution.

FIG. 12.

FIG. 12.

Temporal evolution of the number of C molecules in domain D for three different scenarios: (a) the diffusion-dominated regime with D = 10−11 m2/s, (b) transition from the intermediate regime to the diffusion-dominated regime with D = 2 × 10−11 m2/s, and (c) the intermediate regime with D = 10−12 m2/s. In all cases, NA0=NB0=600 and the results are based on the sample average of 100 trials. Also shown is (d) temporal evolution of the compartment-scale Damköhler number Dak,Δsk, based on the sample average of 100 trials; the dashed black line represents the transition Damköhler number between the intermediate regime (0.1<Dak,Δsk10) and the diffusion-dominated regime (Dak,Δsk0.1).

APPENDIX D: DOUGLAS-GUNN ADI METHOD

Spatiotemporal evolution of a species concentration f(x, t) is described, at the continuum scale, by a reaction-diffusion equation,

ft=D2fx2+2fy2+2fz2+R(f,t), (D1)

where D is the diffusion coefficient, x = (x, y, z) is the coordinate vector, and R(f, t) denotes the reaction term. We solve this equation by using the Alternating Direction Implicit (ADI) method,35

1Ax2fn*=1+Ax2+Ay+Azfn+ΔtRn, (D2a)
1Ay2fn**=fn*Ay2fn, (D2b)
1Az2fn+1=fn**Az2fn+Δt2(Rn+1Rn), (D2c)

where fn = fijk = f(xi, yj, zk, tn), n = 0, …, tmaxt, i = j = k = 1, …, Ls with s = x, y, z. The value of Ls is an even number, and L is the length in any direction x, y, and z of a cubic simulation domain. In (D2),

Ax=νxδx2,  Ay=νyδy2,  Az=νzδz2,

where

νx=DΔtΔx2,  νy=DΔtΔy2,  νz=DΔtΔz2

and, for i, j, k = 2, …, Ls − 1,

δx2fn=fi1,j,kn2fi,j,kn+fi+1,j,kn,δy2fn=fi,j1,kn2fi,j,kn+fi,j+1,kn,δz2fn=fi,j,k1n2fi,j,kn+fi,j,k+1n.

Finally, RnR(fn) and Rn+1 = Rn + R′(fn) (fn+1fn).

For the problem formulated in Sec. IV, [A] = [B] ≡ f, where [A] and [B] are the concentrations of species A and B, respectively. We use the ADI method with fn = [A]n, Rn=kr[A]n[B]n=kr(fn)2, and D = DA = DB. The initial conditions are

fi,j,k0=[A](t=0),fori=0,,imid, (D3)

where imid = L/(2Δx). The boundary conditions are

f0,j,kn=f2,j,kn,fL/Δs+1,j,kn=fL/Δs1,j,kn,fi,0,kn=fi,2,kn,fi,L/Δs+1,kn=fi,L/Δs1,kn,fi,j,0n=fi,j,2n,fi,j,L/Δs+1n=fi,j,L/Δs1n. (D4)

Spatiotemporal evolution of the concentration of species C is computed via (D2)–(D4) with [C] ≡ f, Rn=kr([A]n)2, D = DC, and fi,j,k0=0.

APPENDIX E: COMPARISON OF COMPUTATIONAL TIMES

Table V collates computational times for MCell and our method. As expected, when MCell predicts reactions at a particle level, i.e., when its interaction radius is set to rint = 5 × 10−3 μm, the time steps are very short and the computational times are much higher than the ones required by our method. As reaction effects become dominant, the well-mixed assumption breaks down and MCell represents a realistic scenario at a large computational cost if rint is small. When the latter is set to a larger value (rint = 0.1 μm), MCell works like a mesoscopic method, but its computational times are still larger than those of our method. That is because of the self-adaptive nature of our method in terms of the compartment dimensions and the time step. In future versions, we will adapt our algorithm to describe reactions at a particle level in order to represent the non-well-mixed scenarios with the accuracy similar to MCell’s but at smaller computational times.

TABLE V.

Computational times (CT) required by MCell with rint = 5 × 10−3 μm and rint = 0.1 μm and our method for different Damköhler number DaL to reach the steady state. The superscript * indicates the sample average of 100 trials. The time to reach the steady state (tkss), the time step, and the computational time is in seconds.

MCell (rint = 5 × 10−3 μm) MCell (rint = 0.1 μm) Our method
Regime DaL tkss (s) Time step (s) CT (s) Time step (s) CT (s) CT (s)
Diffusion-dominated 0.01 1 10−2 1.1524 0.1 0.6367 0.0441
Diffusion-dominated/intermediate transition 0.1 1 10−3 1.7071 0.1 0.2149 0.0435
Intermediate 1 1 10−4 2.8125 0.1 0.0821 0.0421
Reaction-dominated/intermediate transition* 10 1.5 10−5 20.4414 0.1 0.0625 0.0405
Reaction-dominated* 100 6 10−6 228.9688 0.1 0.0521 0.0388

REFERENCES

  • 1.Hattne J., Fange D., and Elf J., Bioinformatics 21, 2923–2924 (2005). 10.1093/bioinformatics/bti431 [DOI] [PubMed] [Google Scholar]
  • 2.Roberts E., Stone J. E., and Luthey-Schulten Z., J. Comput. Chem. 34, 245–255 (2013). 10.1002/jcc.23130 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 3.Wils S. and de Schutter E., Front. Neuroinf. 3, 15 (2009). 10.3389/neuro.11.015.2009 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 4.Lampoudi S., Gillespie D. T., and Petzold L. R., J. Chem. Phys. 130, 094104 (2009). 10.1063/1.3074302 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 5.Rossinelli D., Bayati B., and Koumoutsakos P., Chem. Phys. Lett. 451, 136–140 (2008). 10.1016/j.cplett.2007.11.055 [DOI] [Google Scholar]
  • 6.Erban R., Chapman S. J., and Maini P., e-print arXiv:0704.1908v2 (2007).
  • 7.Gillespie D. T., J. Phys. Chem. 81, 2340–2361 (1977). 10.1021/j100540a008 [DOI] [Google Scholar]
  • 8.Drawert B., Engblom S., and Hellander A., BMC Syst. Biol. 6, 76 (2012). 10.1186/1752-0509-6-76 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 9.Smith C. A. and Yates C. A., “Spatially extended hybrid methods: A review,” J. R. Soc., Interface 15, 20170931 (2018). 10.1098/rsif.2017.0931 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 10.Severino G., Tartakovsky D. M., Srinivasan G., and Viswanathan H., “Lagrangian models of reactive transport in heterogeneous porous media with uncertain properties,” Proc. R. Soc. A 468, 1154–1174 (2012). 10.1098/rspa.2011.0375 [DOI] [Google Scholar]
  • 11.Flegg M. B., Chapman S. J., and Erban R., J. R. Soc., Interface 9, 859–868 (2012). 10.1098/rsif.2011.0574 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 12.Flegg M. B., Hellander S., and Erban R., J. Comput. Phys. 289, 1–17 (2015). 10.1016/j.jcp.2015.01.030 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 13.Robinson M., Flegg M. B., and Erban R., J. Chem. Phys. 140, 124109 (2014). 10.1063/1.4868652 [DOI] [PubMed] [Google Scholar]
  • 14.Flegg M. B., Chapman S. J., Zheng L., and Erban R., SIAM J. Sci. Comput. 36, B561–B588 (2014). 10.1137/130915844 [DOI] [Google Scholar]
  • 15.Dobramysl U., Rüdiger S., and Erban R., Multiscale Model. Simul. 14, 997–1016 (2015). 10.1137/15m1015030 [DOI] [Google Scholar]
  • 16.Hellander A., Hellander S., and Lotstedt P., Multiscale Model. Simul. 10, 585–611 (2012). 10.1137/110832148 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 17.Klann M., Ganguly A., and Koeppl H., Bioinformatics 28, i549–i555 (2012). 10.1093/bioinformatics/bts384 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 18.Stiles J. and Bartol T., in Computational Neuroscience, Realistic Modelling for Experimentalists (CRC Press, 2001), Chap. 4, pp. 87–127. [Google Scholar]
  • 19.Andrews S. A. and Bray D., Phys. Biol. 1, 137–151 (2004). 10.1088/1478-3967/1/3/001 [DOI] [PubMed] [Google Scholar]
  • 20.Arjunan S. and Takahashi K., Methods Mol. Biol. 1611, 219–236 (2017). 10.1007/978-1-4939-7015-5_16 [DOI] [PubMed] [Google Scholar]
  • 21.Hoffmann M., Fröhner C., and Noé F., PLoS Comput. Biol. 15, e1006830 (2019). 10.1371/journal.pcbi.1006830 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 22.Sokolowski T., Paijmans J., Bossen L., Miedema T., Wehrens M., Becker N., Kaizu K., Takahashi K., Dogterom M., and ten Wolde P. R., J. Chem. Phys. 150, 054108 (2019). 10.1063/1.5064867 [DOI] [PubMed] [Google Scholar]
  • 23.Vijaykumar A., Bolhuis P. G., and Rein ten Wolde P., “Combining molecular dynamics with mesoscopic Green’s function reaction dynamics simulations,” J. Chem. Phys. 143, 214102 (2015). 10.1063/1.4936254 [DOI] [PubMed] [Google Scholar]
  • 24.Robinson M., Andrews S. S., and Erban R., “Multiscale reaction-diffusion simulations with Smoldyn,” Bioinformatics 31, 2406–2408 (2015). 10.1093/bioinformatics/btv149 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 25.Franz B., Flegg M. B., Chapman S., and Erban R., “Multiscale reaction-diffusion algorithms: PDE-assisted Brownian dynamics,” SIAM J. Appl. Math. 73, 1224–1247 (2014). 10.1137/120882469 [DOI] [Google Scholar]
  • 26.Sayyidmousavi A., Rohlf K., and Ilie S., Math. Biosci. 312, 23–32 (2019). 10.1016/j.mbs.2019.04.001 [DOI] [PubMed] [Google Scholar]
  • 27.Sadeghu M., Weikl T., and Noé F., J. Chem. Phys. 148, 044901 (2018). 10.1063/1.5009107 [DOI] [PubMed] [Google Scholar]
  • 28.Choi T. J., Maurya M. R., Tartakovsky D. M., and Subramaniam S., J. Chem. Phys. 137, 184102 (2012). 10.1063/1.4764108 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 29.Dobrzyński M., Rodríguez J. V., Kaandorp J. A., and Blom J. G., Bioinformatics 23, 1969–1977 (2007). 10.1093/bioinformatics/btm278 [DOI] [PubMed] [Google Scholar]
  • 30.Rodríguez J. V., Kaandorp J. A., Dobrzyński M., and Blom J. G., Bioinformatics 22, 1895–1901 (2006). 10.1093/bioinformatics/btl271 [DOI] [PubMed] [Google Scholar]
  • 31.Chopard B. and Droz M., Cellular Automata Modeling of Physical Systems (Cambridge University Press, New York, 1998). [Google Scholar]
  • 32.Hellander S., Hellander A., and Petzold L., Phys. Rev. E 91, 023312 (2015). 10.1103/physreve.91.023312 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 33.Hout M. S. and Federspiel W. J., Biotechnol. Prog. 19, 1553–1561 (2003). 10.1021/bp025796f [DOI] [PubMed] [Google Scholar]
  • 34.Grandin H. M. and Textor M., Intelligent Surfaces in Biotechnology (John Wiley & Sons, Inc., New Jersey, 2012). [Google Scholar]
  • 35.J. Douglas, Jr. and Gunn J., J. Assoc. Comput. Mach. 9, 450–456 (1962). 10.1145/321138.321142 [DOI] [Google Scholar]
  • 36.Kerr R. A., Bartol T. M., Kaminsky B., Dittrich M., Chang J.-C. J., Baden S. B., Sejnowski T. J., and Stiles J. R., SIAM J. Sci. Comput. 30, 3126–3149 (2008). 10.1137/070692017 [DOI] [PMC free article] [PubMed] [Google Scholar]

Articles from The Journal of Chemical Physics are provided here courtesy of American Institute of Physics

RESOURCES