Two of the most important events taking place in biochemical systems are diffusion and reactions. Particles constantly diffuse throughout the system as a result of their thermal energy. In the meantime, particles also have collisions with one another, some of which may lead to chemical reactions. As long as there are a large number of reactive particles, the behavior of the system may be modeled using reaction-diffusion partial differential equations. However, a deterministic model may be inaccurate or even inapplicable for systems with a small abundance of particles . A remedy to this problem is to use stochastic models, which can take into consideration the innate randomness in the number of particles.
Different simulation algorithms for stochastic models of biochemical systems have so far been developed   . In modelling stochastic reaction-diffusion systems, the problem domain is usually divided into the so-called subcells or compartments and each compartment is assumed to be a well-mixed system in which particles can interact with one another. Particles can also move to their neighboring compartments. Such mesoscopic algorithms can be either time-driven or event-driven . In a time-driven algorithm, a fixed time step Δt is chosen during which at most one event, a reaction or a diffusion, can take place depending on a scaled uniform random number. In an event-driven algorithm, the system evolves by choosing the time step until the next event which is either a reaction or a diffusive jump. The most commonly used event-driven algorithms are the Gillespie algorithm , the next reaction method  and the next subvolume method . These compartment-based algorithms produce exact realizations of the Chemical Master Equation (CME) and the Reaction Diffusion Master Equation (RDME). Other stochastic simulation algorithms for the RDME have also been reported in the literature   .
The particles in a system also interact with the boundaries. In the deterministic regime, the governing partial differential equation of the system may be subject to different boundary conditions. Three main types of boundary conditions are defined for partial differential equations as follows:
(i) (ii) (iii) (1)
where denotes the derivative of u perpendicular to the boundary. Type (i) is called a Dirichlet boundary condition. Type (ii) is known as a Neumann boundary condition and type (iii) is referred to as a Robin boundary condition. When using stochastic techniques, these boundary conditions need to be translated from their deterministic to a stochastic framework . Certain types of the above-mentioned boundary conditions can be readily implemented in a stochastic regime. For instance, the Neumann boundary condition , also called the zero-flux condition, is represented as a reflective boundary, meaning that a particle gets reflected whenever it hits the boundary. The Dirichlet boundary condition , also called a fully-adsorbing boundary, is modelled such that upon hitting the boundary, the particle is totally removed from the system. However, other types of boundary conditions, in particular the so-called mixed or Robin boundary conditions, may not be easily implemented within a stochastic framework. The reason is that upon hitting this type of boundary, some particles are removed and some are reflected. As a result, the Robin boundary condition is also referred to as a radiative or a partially adsorbing boundary. Examples of Robin boundary condition in biology are cell membranes with receptors  and polymer coating of a virus surface  .
In accordance with Erban and Chapman , in a stochastic framework, any boundary condition may be formulated as follows: whenever a molecule hits the boundary, it is reflected with some probability, and removed (adsorbed) otherwise. As such, this probability is one and zero for the zero-flux and fully-adsorbing boundaries, respectively. Partially adsorbing boundary conditions have been implemented in both microscopic and mesoscopic stochastic algorithms. Andrew and Bray  and Singer et al.  derived expressions for the relationship between the particle adsorption probability of the boundary with the deterministic Robin boundary constant κ for Brownian Dynamics. Sayyidmousavi and Rohlf  modelled partial adsorption of the boundary in the Reactive Multi Particle Collision (RMPC) method by drawing an analogy between the RMPC and Brownian Dynamics through the mean free path of particles. Erban and Chapman  calculated the probability of a particle being adsorbed by the boundary to be
by developing a position jump process that corresponds to a time-driven mesoscopic stochastic algorithm. Here h denotes the compartment size, i.e., the distance between jumping positions, and D and κ represent the diffusion coefficient of the particle and the reactivity constant of the boundary, respectively. Lier and Marquez-Lago  argued that the probability R being bounded by the value of one from above imposes an upper limit on the size of the compartment h as .
This restriction on the compartment size will therefore result in excessive computational cost for low ratios between the diffusion coefficient and the Robin boundary constant. In addition, this upper limit may even require h to be too small for the RDME to be valid. To resolve this shortcoming, Lier and Marquez-Lago  presented an alternative approach by introducing a discretization permeability factor β for diffusive jumps across the partially adsorbing boundary such that the new propensity for diffusive jumps from the very subcell next to the boundary is given by . Note that β is calculated by imposing that the steady-state stochastic mean summed over all subcells be equal to a pre-defined value. In this paper, we have modified the derivation proposed by Erban and Chapman  through the position jump process, to obtain an adsorption probability of the boundary which relaxes the restriction on the compartment size to a great extent. This probability can be readily incorporated into the Gillespie algorithm for reaction-diffusion systems with reactive boundaries. The paper is organized as follows: Section 2 gives an overview of the Inhomogeneous Stochastic Simulation Algorithm. In Section 3, the adsorption probability of the reactive boundary is obtained through a modified position jump process. In Section 4, the obtained probability is applied to model three reaction-diffusion systems with partially adsorbing boundaries, and finally, the paper is concluded with a summary and discussion in Section 5.
2. Materials and Methods
2.1. Inhomogeneous Stochastic Simulation Algorithm
First, confirm that you have the correct template for your paper size. This template has been tailored for output on the custom paper size (21 cm * 28.5 cm). Stochastic Simulation Algorithm (SSA), initially developed by Gillespie , is one of the most commonly used stochastic algorithms for well-mixed biochemical systems. Other scholars   extended the SSA to account for the spatial variations in particle numbers in the problem domain and developed the so-called Inhomogeneous Stochastic Simulation Algorithm (ISSA) to solve the Reaction-Diffusion Master Equation. The ISSA has been enhanced in terms of speed through the development of hybrid and adaptive algorithms  - . Some scholars have also utilized the ISSA to simulate delayed reactions  . In the RDME, the problem domain is discretized into NV cubic subvolumes of length h, each being considered a well-mixed system. The system consists of Nsp species subject to M reactions. Rjk represents reaction Rj in subvolume Ωk that can occur with the propensity of . xik denotes the number of particles of type Si in subvolume Ωk, in the current state of the system. The occurrence of reaction Rjk changes the state of the system from x to . Here, vjk is an Nsp dimensional column vector that represents the system state due to reaction Rjk, while ek is an NV dimensional row vector with all entries being zero except for the k-th entry which is equal to 1.
Diffusion events are modeled as unimolecular reactions such that indicates the movement of one particle of species Si between two adjacent subvolumes k and l. The propensity of such a unimolecular reaction is denoted by , which amounts to with Di representing the diffusion constant for species Si. Each diffusion event changes the state of the system from x to , where Ei is an Nsp dimensional column vector with all entries being zero except the i-th entry which is equal to 1. The state change vector is characterized by an NV dimensional row vector. An inhomogeneous system can be modeled as a finite state continuous Markovian process. If is the probability of the system being in the state x at time t, provided that at time t0, the system was at state x0, the master equation for a system including only reactions and no diffusion may be written as:
For a system in which only diffusions and no reactions occurs, the master equation is
Subsequently, for a system in which both reactions and diffusions happen. The dynamics of the Markov Process is governed by the Reaction Diffusion Master equation as follows:
At each step of the ISSA, two uniformly distributed random numbers r1 and r2 between 0 and 1 are generated. With a0(x) representing the sum of the propensities for all the events in the system at state x including both reactions and diffusions, the time until the next event, δt, is calculated as
with a0 being
The next event is predicted as follows: if the index (j, k) is the minimum such that
then the reaction Rjk occurs first. If, however, the index follows
then diffusion event will take place first.
2.2. Modified Position Jump Process
As previously mentioned, diffusion or position jump in the ISSA is modelled as a unimolecular reaction, the probability of which is equal to . As a result, in a one dimensional case, a particle of type Si in subvolume Ωk, at time t + δt, can stay in its current position with a probability equal to or it can jump to its adjacent right or left subvolume, each with a probability of . Now, if a particle is located in a subvolume Ωk adjacent to a partially adsorbing boundary on its left side, the probability of the particle remaining in its current position at time t + δt can be calculated as:
Pads in the above-given equation is the adsorption probability of the boundary. It can be seen that Pads = 0 and 1 will correspond to a fully reflective and fully adsorbing boundary, respectively. Equation (10) can be rearranged as follows:
In order to comply with the diffusive limit , both sides of this equation are multiplied by and by letting both h and δt approach zero while is kept constant, the term in the right-hand side parenthesis of Equation (11) approaches zero which is analogous to the following deterministic Robin boundary condition with n(x,t) representing the particle density:
This analogy will result in the adsorption probability being
Unlike obtained by Erban and Chapman , the above-calculated probability imposes a lower bound on the compartment size h relaxing the restriction on the compartment size. However, it should be noted that, in order to ensure spatial variations in the system, h is restricted from above, i.e., where L denotes the size of the domain. Also, h has to be significantly larger than the binding radius for the molecular based Smoluchowski model , that is .
The ISSA can therefore be modified such that the propensity of diffusion jump over a partially adsorbing boundary is set equal to . Therefore, in Equation (7), the diffusive propensity is calculated as:
As can be seen, using Equation (14), the partially adsorbing boundary condition can be easily implemented into the ISSA algorithm as opposed to the probability approach developed by Erban and Chapman . In fact, in the latter approach, for each iteration, an additional uniformly distributed random number needs to be generated and compared to the adsorption probability in Equation (2).
3. Results and Discussions
3.1. Case Study I: Diffusion
The first system contains a number of particles that can diffuse throughout the domain. For this purpose, we assume that 100,000 particles exist in a computation domain [0, 5] such that initially, 75,000 of the particles are at x = 1 and the remaining 25,000 are at x = 2. The domain is discretized into 50 subvolumes of length h = 0.1. The left boundary, i.e., x = 0 is assumed to be subject to a Robin boundary condition with κ = 2. The boundary at x = 5 is considered to be fully reflective. The diffusion coefficient of the particles is set equal to D = 1. The given values of h, κ and D correspond to an adsorption probability of for the left hand-side boundary according to Erban and Chapman . Following Equation (13) obtained in this paper, the propensity of the diffusion jump over the partially adsorbing boundary in the ISSA algorithm is calculated to be . Figure 1 shows the distribution profile, obtained using the modified ISSA, at t = 1 compared to the PDE solution.
Now, if the diffusion coefficient is changed to D = 0.1, the adsorption probability of the boundary, as calculated by Equation (2), will be equal to , making it physically meaningless unless the compartment size h is considerably refined (h < 0.05) which results in additional computational cost. However, according to Equation (13), the new diffusion jump propensity over the left hand-side boundary remains , with h = 0.1, resulting in the distribution given in Figure 2 when applied to the ISSA. Figure 3 shows the distribution profiles obtained through the present method with h = 0.1 compared to using Equation (2) with h = 0.04. The results are seen to be in good agreement with one another. However, the use of the present method has resulted in a decrease of 87% in the computational time.
3.2. Case Study II: Reaction and Diffusion
In the second example , we consider a square domain of [0, 1] × [0, 1] in which the particles of type A can diffuse with a constant coefficient of D = 0.1. The system also consists of a production reaction as follows:
where . Such a system can be described by the following PDE in the deterministic framework
Figure 1. Stochastic simulation of diffusive system with D = 1 and κ = 2 at t = 1.
Figure 2. Stochastic simulation of diffusive system with D = 0.1 and κ = 2 at t = 1.
Figure 3. Stochastic simulation of diffusive system with D = 0.1 and κ = 2 at t = 1.
The left and right boundaries of the domain are subject to fully reflective and fully adsorbing conditions, respectively. The top and bottom boundaries satisfy the Robin condition with and . In order for the adsorption probability formula in  to be used, . In this paper, the problem is solved with applying the proposed formula. Figure 4 shows the solution to this system obtained with the modified ISSA at t = 10 compared to the PDE solution.
3.3. Case Study III: Schnakenberg System
The third system follows the Schnakenberg kinetics consisting of species U as the activator and V as the inhibitor, which undergoes the following reactions:
Figure 4. Particle density at t = 10; PDE solution (top), Stochastic solution (bottom).
In addition, species U and V diffuse throughout the domain [0, 1] with diffusion constants and , respectively . The system is described by a system of reaction-diffusion equations:
The boundary condition at is assumed to be fully reflective; whereas Robin boundary conditions are imposed at , namely:
The initial condition is defined as
Figure 5. (a) Stochastic simulation of species U in the Schnakenberg System at t = 1; (b) Stochastic simulation of species V in the Schnakenberg System at t = 1.
The problem domain is discretized into 50 subvolumes of length . Through comparison with Equation (12), the values for the reactivity constant κ are obtained; and . particles of each species, i.e., U and V are initially placed in each subvolume. Figure 5 shows how the particles of type U and V are distributed through the system at t = 1. It can be seen that the results from the modified ISSA are in very good agreement with the PDE solution.
Motivated by the existence of partially permeable boundaries in cell biology, the present paper proposed a modified position jump process leading to an expression for the propensity of a diffusion jump over a partially adsorbing boundary, which can be readily implemented into the ISSA. The proposed formula imposes a lower bound on the compartment size which relaxes the additional restriction on the compartment size as proposed by Erban and Chapman . It is noteworthy that the usual upper and lower bounds for the compartment size, i.e., and , will guarantee that the adsorption probability remains bounded between zero and unity. As indicated in case studies I and II, using the proposed formula, one can solve the problem with a larger compartment size, thus saving considerable computational cost. Also, the use of the present approach is computationally much simpler than calculating the factor β for diffusive jumps, which requires imposing that the steady-state stochastic mean summed over all subvolumes be equal to a pre-defined value as in reference . As can be seen in case study III, since the derivation of the propensity depends solely on the diffusive jump process, the existence of higher order reactions does not affect the boundary conditions. Another important point to notice is that, in general, for a small number of particles, the average stochastic solution of reaction-diffusion systems can be compared with deterministic, i.e., the PDE solution, only when the reactions are of zeroth and first orders . In the Schnakenberg model simulated in this paper, the number of particles has been chosen large enough to make such a comparison possible.
The authors would like to acknowledge the financial support provided by a grant (RGPIN/05723-2015) from the Natural Sciences and Engineering Research Council of Canada (NSERC).
 Andrews, S.S. and Bray, D. (2004) Stochastic Simulation of Chemical Reactions with Spatial Resolution and Single Molecule Detail. Physical Biology, 1, 137-151.
 Cao, Y., Gillespie, D.T. and Petzold, L.R. (2007) Adaptive Explicit-Implicit Tau-Leaping Method with Automatic Tau Selection. Journal of Chemical Physics, 126, Article ID: 224101.
 Gibson, M. and Bruck, J. (2000) Efficient Exact Stochastic Simulation of Chemical Systems with Many Species and Channels. Journal of Physical Chemistry, 104, 1876-1889.
 Elf, J. and Ehrenberg, M. (2004) Spontaneous Separation of Bi-Stable Biochemical Systems into Spatial Domains of Opposite Phases. Systems Biology, 1, 2230-2236.
 Lampoudi, S., Gillespie, D.T. and Petzold, L.R. (2009) The Multinomial Simulation Algorithm for Discrete Stochastic Simulation of Reaction-Diffusion Systems. Journal of Chemical Physics, 130, Article ID: 094104.
 Drawert, B., Lawson, M.J., Petzold, L.R. and Kammash, M. (2010) The Diffusive Finite State Projection Algorithm for Efficient Simulation of the Stochastic Reaction-Diffusion Master Equation. Journal of Chemical Physics, 132, Article ID: 074101.
 Koh, W. and Blackwell, K.T. (2012) An Accelerated Algorithm for Discrete Stochastic Simulation of Reaction-Diffusion Systems Using Gradient-Based Diffusion and Tau-Leaping. Journal of Chemical Physics, 134, Article ID: 154103.
 Boccardo, G., Sokolov, I.M. and Paster, A. (2018) A Second Order Scheme for a Robin Boundary Condition in Random Walk Algorithms. Journal of Computational Physics, 374, 1152-1165.
 Hoffmann, M. and Schawrz, U.S. (2014) Oscillations of Min-Proteins in Micropatterned Environments: A Three-Dimensional Particle-Based Stochastic Simulation Approach. Soft Matter, 10, 2388-2396.
 Erban, R., Chapman, S.J., Fisher, K., Kevrekidis, I. and Seymour, L.W. (2007) Dynamics of Polydisperse Irreversible Adsorption: A Pharmacological Example. Mathematical Models and Methods in Applied Sciences, 17, 759-781.
 Fisher, K., Stallwood, Y., Green, N., Ulbrich, K., Mautner, V. and Seymour, L.W. (2011) Polymer-Coated Adenovirus Permits Efficient Retargeting and Evades Neutralizing Antibodies. Gene Therapy, 8, 341-348.
 Sayyidmousavi, A. and Rohlf, K. (2018) Reactive Multi-Particle Collision Dynamics with Reactive Boundary Conditions. Physical Biology, 15, Article ID: 046007.
 Lier, A. and Marquez-Lago, T.T. (2011) Correction Factors for Boundary Diffusion in Reaction-Diffusion Master Equations. Journal of Chemical Physics, 135, Article ID: 134109.
 Isaacson, S.A. and Peskin, C.S. (2006) Incorporating Diffusion in Complex Geometries into Stochastic Chemical Kinetics Simulations. SIAM Journal on Scientific Computing, 28, 47-74.
 Chatterjee, A. and Vlachos, D.G. (2005) Binomial Distribution Based τ-Leap Accelerated Stochastic Simulation. Journal of Chemical Physics, 122, Article ID: 024112.
 Chiam, K.H., Tan, C.M., Bhargava, V. and Rajagopal, G. (2006) Hybrid Simulations of Stochastic Reaction-Diffusion Processes for Modeling Intracellular Signaling Pathways. Physical Review E, 74, Article ID: 051910.
 Rossinelli, D., Bayati, B. and Koumoutsakos, P. (2008) Accelerated Stochastic and Hybrid Methods for Spatial Simulations of Reaction-Diffusion Systems. Chemical Physics Letter, 451, 136-140.
 Ferm, L., Hellander, A. and Lotstedt, P. (2010) An Adaptive Algorithm for Simulation of Stochastic Reaction-Diffusion Processes. Journal of Computational Physics, 229, 343-360.
 Strehl, R. and Ilie, S. (2015) Hybrid Stochastic Simulation of Reaction-Diffusion Systems with Slow and Fast Dynamics. Journal of Chemical Physics, 143, Article ID: 234108.
 Padgett, J.M.A. and Ilie, S. (2016) An Adaptive Tau-Leaping Method for Stochastic Simulations of Reaction-Diffusion Systems. AIP Advances, 6, Article ID: 035217.
 Barrio, M., Burrage, K., Leier, A. and Tian, T. (2006) Oscillatory Regulation of Hes1: Discrete Stochastic Delay Modelling and Simulation. PLOS Computational Biology, 2, 1017-1030.
 Sayyidmousavi, A. and Ilie, S. (2017) An Efficient Hybrid Method for Stochastic Reaction-Diffusion Biochemical Systems with Delay. AIP Advances, 7, Article ID: 125305.
 Taylor, P.R., Baker, R.E. and Yates, C.A. (2014) Deriving Appropriate Boundary Conditions and Accelerating Position-Jump Simulations of Diffusion Using Non-Local Jumping. Physical Biology, 12, Article ID: 016006.
 Smith, S., Cianci, C. and Grima, R. (2015) Analytical Approximations for Spatial Stochastic Gene Expression in Single Cells and Tissues. Journal of the Royal Society Interface, 13, Article ID: 20151051.