Introduction
The boundary local time ℓ t \ell_t ℓ t plays the central role in the theory of stochastic processes [1–3]. For instance, reflected Brownian motion X t X_t X t inside a given Euclidean domain Ω ⊂ R d \Omega\subset\mathbb{R}^{d} Ω ⊂ R d with a smooth boundary ∂ Ω \partial\Omega ∂ Ω can be constructed as the solution of the Skorokhod stochastic equation [2, 3]
d X t = 2 D d W t + n ( X t ) d ℓ t , X 0 = x 0 , ℓ 0 = 0 , (1) \mathrm{d}X_t = \sqrt{2D}\,\mathrm{d}W_t + \boldsymbol{n}(X_t)\,\mathrm{d}\ell_t,\qquad X_0=x_0,\qquad\ell_0=0, \tag*{(1)} d X t = 2 D d W t + n ( X t ) d ℓ t , X 0 = x 0 , ℓ 0 = 0 , (1)
where W t W_t W t is the standard Wiener process in R d \mathbb{R}^{d} R d , D D D is the diffusion coefficient, x 0 ∈ Ω x_0 \in\Omega x 0 ∈ Ω is the starting point, n ( x ) \boldsymbol{n}(x) n ( x ) is the unit normal vector at a boundary point x ∈ ∂ Ω x \in\partial\Omega x ∈ ∂ Ω oriented inward the domain Ω \Omega Ω , and ℓ t \ell_t ℓ t is a nondecreasing stochastic process that increments at each encounter of X t X_t X t with the boundary. Qualitatively, the first term in Eq. (1) describes ordinary Brownian motion inside Ω \Omega Ω , whereas the second term ensures that X t X_t X t is reflected back normally into Ω \Omega Ω at each encounter with the boundary. From the physical point of view, one can think of the second term as an infinitely local force field that pushes the diffusing particle back to the confining domain [4]. Curiously, the single stochastic equation (1) determines simultaneously two tightly related stochastic processes: the position X t X_t X t and the boundary local time ℓ t \ell_t ℓ t (which has, despite its name, units of length). The latter should not be confused with a point local time, which represents the residence time of Brownian motion in a vicinity of a bulk point (see [5–7]). Note that the boundary local time can be expressed as
ℓ t = lim ε → 0 D ε ∫ 0 t d t ′ Θ ( ε − ∣ X t ′ − ∂ Ω ∣ ) , (2) \ell_t = \lim_{\varepsilon\to0} \frac{D}{\varepsilon}\int_0^t \mathrm{d}t'\,\Theta(\varepsilon-\lvert X_{t'}-\partial\Omega\rvert), \tag*{(2)} ℓ t = ε → 0 lim ε D ∫ 0 t d t ′ Θ ( ε − ∣ X t ′ − ∂ Ω ∣) , (2)
where ∣ x − ∂ Ω ∣ \lvert x-\partial\Omega\rvert ∣ x − ∂ Ω ∣ is the Euclidean distance between a point x x x and the boundary ∂ Ω \partial\Omega ∂ Ω , and Θ ( z ) \Theta(z) Θ ( z ) is the Heaviside step function: Θ ( z ) = 1 \Theta(z)=1 Θ ( z ) = 1 for z > 0 z>0 z > 0 and 0 otherwise. The integral represents the residence time of the process X t X_t X t in a thin layer ∂ Ω ε = { x ∈ Ω : ∣ x − ∂ Ω ∣ < ε } \partial\Omega_\varepsilon= \{x \in\Omega: |x - \partial\Omega| < \varepsilon\} ∂ Ω ε = { x ∈ Ω : ∣ x − ∂ Ω∣ < ε } of width ε \varepsilon ε near the boundary ∂ Ω \partial\Omega ∂ Ω , which is rescaled by ε \varepsilon ε to get a nontrivial limit, as ε → 0 \varepsilon\to0 ε → 0 . Alternatively, one has
ℓ t = lim ε → 0 ε N t ( ε ) , (3) \ell_t = \lim_{\varepsilon\to0} \varepsilon\mathcal{N}_t^{(\varepsilon)}, \tag*{(3)} ℓ t = ε → 0 lim ε N t ( ε ) , (3)
where N t ( ε ) \mathcal{N}_t^{(\varepsilon)} N t ( ε ) is the number of crossings of the layer ∂ Ω ε \partial\Omega_\varepsilon ∂ Ω ε up to time t t t . In other words, the boundary local time ℓ t \ell_t ℓ t can be understood either as the rescaled residence time in a thin boundary layer, or as the rescaled number of encounters with that boundary.
Apart from its major role in the theory of stochastic processes, the boundary local time was recently employed as the conceptual pillar to build the encounter-based approach to diffusion-controlled reactions [4]. This approach laid a theoretical ground for assessing the statistics of encounters between the diffusing particle and the boundary, provided an intuitively clear probabilistic interpretation of partial reactivity and allowed one to consider much more general surface reaction mechanisms [8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 ] . In fact, the reaction event of a diffusing particle on the boundary can be initiated when the boundary local time ℓ t \ell_t ℓ t exceeds a chosen random threshold ℓ ^ \hat{\ell} ℓ ^ . In this way, the probability distribution of the threshold determines the surface reaction mechanism independently of the diffusive dynamics. So, the exponential distribution of ℓ ^ \hat{\ell} ℓ ^ corresponds to the standard constant reactivity implemented via Robin boundary condition, whereas other distributions can describe, for instance, progressive activation or passivation of the boundary by the diffusing particle [15 , 16 ] . While the former setting can be simulated by conventional methods, implementation of more sophisticated surface reaction mechanisms requires the knowledge of the boundary local time. Moreover, these concepts were further extended to describe permeation across membranes [17 , 18 , 19 ] , diffusive exchange between adjacent compartments [20 ] , and the related snapping out Brownian motion [21 , 22 ] .
Despite these advances, the fundamental relation between the statistics of the boundary local time ℓ t \ell_t ℓ t and the geometrical structure of the confining domain Ω \Omega Ω remains poorly understood. For instance, the distribution of ℓ t \ell_t ℓ t is known explicitly only for two simple domains: a half-line and the exterior of a sphere [8 , 23 , 24 ] . Indeed, the symmetries of these domains allow for the separation of variables and thus reduction to a one-dimensional problem that can be solved exactly. In contrast, most diffusive processes in nature and industrial applications occur in multi-scale media with irregular, sophisticated boundaries, for which numerical tools are needed to access the statistics of encounters. Even though the spectral expansions developed in [4] are formally still applicable in such domains, their numerical implementation (e.g., by a finite-element method) can be very costly and time-consuming, especially in three dimensions. In this light, one may prefer Monte Carlo techniques that offer great flexibility and moderate computational costs [25 , 26 , 27 ] . While these techniques are broadly used for simulating stochastic processes and diffusion-controlled reactions in complex domains [28 , 29 , 30 , 31 , 32 , 33 , 34 , 35 , 36 , 37 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 , 48 , 49 , 50 ] , their adaptation for studying the boundary local time is not straightforward.
The most basic way to simulate the boundary local time consists in approximating reflected Brownian motion by a random walk on a lattice with spacing ε \varepsilon ε and counting the number N t ( ε ) \mathcal{N}_t^{(\varepsilon)} N t ( ε ) of its encounters with the discretized boundary ∂ Ω \partial\Omega ∂ Ω . According to Eq. (3) , ε N t ( ε ) \varepsilon\mathcal{N}_t^{(\varepsilon)} ε N t ( ε ) is an approximation of ℓ t \ell_t ℓ t , if ε \varepsilon ε is small enough. The need for boundary discretization and excessively long trajectories (with 2 d Δ t / ε 2 2d\Delta t/\varepsilon^2 2 d Δ t / ε 2 steps) are major drawbacks of this method. The first drawback can be relaxed by performing off-lattice random walks, i.e., a sequence of centered Gaussian jumps of variance σ 2 \sigma^2 σ 2 with normal reflections on the boundary. In this case, one can either count the number N t ( σ ) \mathcal{N}_t^{(\sigma)} N t ( σ ) of reflections and use again Eq. (3) with σ \sigma σ instead of ε \varepsilon ε , or calculate the residence time of this random walk inside a boundary layer of width ε ∼ σ \varepsilon\sim\sigma ε ∼ σ and use Eq. (2) to approximate ℓ t \ell_t ℓ t (see also [51 ] for the discussion of Euler schemes). Since a typical one-jump displacement σ \sigma σ should be the smallest length scale of the problem, this method can be efficient for simple domains (see, e.g., [52 ] ) but it becomes too time-consuming in multi-scale media. This issue was partly resolved by Zhou et al. who combined the standard walk-on-spheres (WOS) algorithm by Muller [53 ] and the fixed-length displacements in a thin layer near boundary [54 ] . Their hybrid method exploits the well-known advantages of the WOS algorithm for fast simulations of large-scale displacements far from the boundary (see details in § 2.1 ). As a consequence, the major remaining computational limitation is caused by modeling small displacements inside the boundary layer of small width ε \varepsilon ε . This method was further improved and adopted to simulating snapping out Brownian motion in planar bounded domains by Schumm and Bressloff [55 ] . In particular, they suggested using walk-on-spheres even inside the boundary layer of width ε \varepsilon ε , with the jump distance being fixed to be 2 ε 2\varepsilon 2 ε , in order to speed up simulations within that layer. Despite this progress, an accurate estimation of the boundary local time ℓ t \ell_t ℓ t within a boundary layer requires taking ε \varepsilon ε sufficient small so that modeling of reflected Brownian motion within this layer remains the critical bottleneck of these multi-scale Monte Carlo simulations.
In this paper, we propose a different approach to simulate the stochastic process ( X t , ℓ t ) (X_t, \ell_t) ( X t , ℓ t ) inside a confining domain. We still employ the WOS algorithm for fast simulations of large-scale displacements far from the boundary. In turn, we replace the detailed time-consuming simulation of the stochastic process within a boundary layer by a single escape event from that layer. A similar approach was recently implemented for simulating the escape of a sticky particle [56 , 57 ] . In fact, once the process arrives inside the layer, we introduce the random escape time τ \tau τ from that layer, i.e., the first-passage time to the set Γ ε = { x ∈ Ω : ∣ x − ∂ Ω ∣ = ε } \Gamma_{\varepsilon}=\{x\in\Omega:|x-\partial\Omega|=\varepsilon\} Γ ε = { x ∈ Ω : ∣ x − ∂ Ω∣ = ε } of points in Ω \Omega Ω that are equidistant to the boundary (Figure 1 a).
Figure 1. (a) A zoom near the boundary ∂ Ω \partial\Omega ∂ Ω : once the WOS arrives inside the boundary layer ∂ Ω ε \partial\Omega_{\varepsilon} ∂ Ω ε of width ε \varepsilon ε , one aims at replacing a costly detailed simulation of the random trajectory (in green) from the entrance point x k x_k x k to the exit point x k + 1 x_{k+1} x k + 1 by a single escape event. For this purpose, one needs to generate the escape position x k + 1 x_{k+1} x k + 1 , the escape time τ \tau τ , and the acquired boundary local time ℓ τ ′ \ell_{\tau}^{\prime} ℓ τ ′ . (b) Flat layer approximation: starting from a point ( 0 , y 0 ) (0,y_0) ( 0 , y 0 ) (yellow circle), a random trajectory (in blue) experiences numerous reflections on the flat boundary before escaping an infinite stripe of width ε \varepsilon ε at a random escape time τ \tau τ in a random escape position ( x τ , ε ) (x_{\tau},\varepsilon) ( x τ , ε ) (red circle). These reflections are characterized by the acquired boundary local time ℓ τ ′ \ell_{\tau}^{\prime} ℓ τ ′ . The random trajectory is thus replaced by a simple jump from ( 0 , y 0 ) (0,y_0) ( 0 , y 0 ) to ( x τ , ε ) (x_{\tau},\varepsilon) ( x τ , ε ) .
To realize an escape event, the central quantity of interest is the joint probability density of the escape time τ \tau τ , the escape position X τ X_{\tau} X τ , and the acquired boundary local time ℓ τ \ell_{\tau} ℓ τ . Its exact spectral expansion was recently derived by means of the encounter-based approach [58 ] . As a smooth boundary is locally flat, the spectral expansion takes a simple form that allows its direct implementation in Monte Carlo simulations. Moreover, when the boundary is composed of flat elements, the simulation of the escape event becomes almost exact. In addition, we propose an improvement to account for the curvature of the boundary in order to enable using a larger width ε \varepsilon ε of the boundary layer. In this way, there is no need for simulating multiple reflections on the boundary that was the most time-consuming step and the main source of accumulating errors in former techniques.
The paper is organized as follows. In § 2 , we describe the escape-from-a-layer (EFL) approach. We start with a simpler approximation of a flat boundary layer and then discuss its improvement to curved boundary layers. § 3 summarizes an algorithmic implementation of the EFL approach. § 4 validates this method for several confining domains by comparing simulated results to either exact values, or numerical values obtained by a finite-element method. We also compare the performance of our method to the state-of-the-art method by Schumm and Bressloff [55 ] . In § 5 , we discuss further improvements, extensions, applications and future perspectives of this method.
Escape-from-a-layer approach
Walk-on-spheres algorithm
We start by recalling the walk-on-spheres algorithm for simulating Brownian motion in a confining domain Ω ⊂ R d \Omega\subset\mathbb{R}^{d} Ω ⊂ R d with an absorbing boundary ∂ Ω \partial\Omega ∂ Ω [53 ] . From a prescribed starting point x 0 ∈ Ω x_0\in\Omega x 0 ∈ Ω , one determines the Euclidean distance ρ 0 = ∣ x 0 − ∂ Ω ∣ \rho_0=|x_0-\partial\Omega| ρ 0 = ∣ x 0 − ∂ Ω∣ to the boundary ∂ Ω \partial\Omega ∂ Ω and draws a ball B ρ 0 ( x 0 ) B_{\rho_0}(x_0) B ρ 0 ( x 0 ) of radius ρ 0 \rho_0 ρ 0 centered at x 0 x_0 x 0 . The continuity of Brownian motion implies that any trajectory must cross the boundary of this ball, ∂ B ρ 0 ( x 0 ) \partial B_{\rho_0}(x_0) ∂ B ρ 0 ( x 0 ) , before hitting the boundary ∂ Ω \partial\Omega ∂ Ω . One can therefore replace lengthy simulations of the trajectory inside the ball by an escape event, i.e., a jump to a uniformly distributed point x 1 x_1 x 1 on ∂ B ρ 0 ( x 0 ) \partial B_{\rho_0}(x_0) ∂ B ρ 0 ( x 0 ) . The probability distribution of the time τ 1 \tau_1 τ 1 needed to escape from the ball is known explicitly (see Appendix § 7 ) that allows one to easily generate the random variable τ 1 \tau_1 τ 1 . From the x 1 x_1 x 1 , the previous step is repeated, i.e., one determines the distance ρ 1 = ∣ x 1 − ∂ Ω ∣ \rho_1 = |x_1 - \partial\Omega| ρ 1 = ∣ x 1 − ∂ Ω∣ and generates the escape time τ 2 \tau_2 τ 2 and the escape position x 2 x_2 x 2 as a uniformly distributed point on the sphere ∂ B ρ 1 ( x 1 ) \partial B_{\rho_1}(x_1) ∂ B ρ 1 ( x 1 ) , and so on. The algorithm is stopped when the distance to the boundary becomes smaller than a prescribed threshold ε \varepsilon ε . This procedure samples a sequence of points X t 1 , X t 2 , … , X t k X_{t_1}, X_{t_2}, \ldots, X_{t_k} X t 1 , X t 2 , … , X t k of a random trajectory X t X_t X t at random times t 1 = τ 1 t_1 = \tau_1 t 1 = τ 1 , t 2 = t 1 + τ 2 , … , t k = t k − 1 + τ k t_2 = t_1 + \tau_2, \ldots, t_k = t_{k-1} + \tau_k t 2 = t 1 + τ 2 , … , t k = t k − 1 + τ k . As the jump length is progressively adapted according to the proximity to the boundary, large jumps can be performed far from the boundary. This variability ensures remarkably fast convergence of the method [59 ] and allows for efficient simulations of Brownian motion in multi-scale environments [29 , 30 , 31 , 32 , 35 , 36 , 37 , 38 ] .
The threshold ε \varepsilon ε determines the width of a boundary layer, which is considered as absorbing: the process is stopped once it arrives to this layer. The value of ε \varepsilon ε can be either assigned from the underlying microscopic model (e.g., the interaction range between the diffusing particle and the boundary), or treated as a numerical parameter of the method. As shown by Binder and Braverman [59 ] , the computational time scales linearly with ln ( 1 / ε ) \ln(1/\varepsilon) ln ( 1/ ε ) , i.e., one can choose an extremely small ε \varepsilon ε with almost no computational cost. This remarkably fast convergence explains the efficiency and popularity of the WOS algorithm in domains with absorbing boundaries. However, if the boundary is not absorbing, one loses such fast convergence. Indeed, if the process is not stopped upon the first arrival into the boundary layer, one needs to simulate reflections on the boundary that forms the critical bottleneck for an extension of the WOS method to reflecting boundaries. In the next subsections, we propose an efficient way to solve this problem.
The layer escape problem
One can run the WOS algorithm until some time t k t_k t k when the process arrives to a point x k x_k x k inside the boundary layer Ω ε \Omega_\varepsilon Ω ε of width ε \varepsilon ε : Ω ε = { x ∈ Ω : ∣ x − ∂ Ω ∣ < ε } \Omega_\varepsilon= \{x \in\Omega: |x - \partial\Omega| < \varepsilon\} Ω ε = { x ∈ Ω : ∣ x − ∂ Ω∣ < ε } . Our goal is to substitute a lengthy simulation of the trajectory X t ′ = X t + t k X'_t = X_{t+t_k} X t ′ = X t + t k inside this layer by a single displacement out of Ω ε \Omega_\varepsilon Ω ε (as reflected Brownian motion is Markovian, the trajectory X t X_t X t with t < t k t < t_k t < t k does not matter so that we can consider t k t_k t k as a new origin of time for the shifted in time process X t ′ X'_t X t ′ , denoted by prime). For this purpose, we aim at generating three random variables: (i) the escape time τ = inf { t > 0 : X t ′ ∉ Ω ε ∣ X 0 ′ = x k } \tau= \inf\{t > 0 : X'_t \notin\Omega_\varepsilon\mid X'_0 = x_k\} τ = inf { t > 0 : X t ′ ∈ / Ω ε ∣ X 0 ′ = x k } from the layer, i.e., the first instance when the process leaves Ω ε \Omega_\varepsilon Ω ε by crossing the surface Γ ε = { x ∈ Ω : ∣ x − ∂ Ω ∣ = ε } \Gamma_\varepsilon= \{x \in\Omega: |x - \partial\Omega| = \varepsilon\} Γ ε = { x ∈ Ω : ∣ x − ∂ Ω∣ = ε } ; (ii) the position X τ ′ X'_\tau X τ ′ at the escape time, and (iii) the boundary local time ℓ τ ′ \ell'_\tau ℓ τ ′ acquired during this escape event (Figure 1 a). If we manage to generate these random variables, one can execute a single escape event from the layer, without simulating the trajectory inside it. After the escape, the new position is X t k + 1 = x k + 1 = X τ ′ X_{t_{k+1}} = x_{k+1} = X'_\tau X t k + 1 = x k + 1 = X τ ′ , the time is incremented by τ \tau τ , t k + 1 = t k + τ t_{k+1} = t_k + \tau t k + 1 = t k + τ , and the boundary local time is incremented by ℓ τ ′ \ell'_\tau ℓ τ ′ : ℓ t k + 1 = ℓ t k + ℓ τ ′ \ell_{t_{k+1}} = \ell_{t_k} + \ell'_\tau ℓ t k + 1 = ℓ t k + ℓ τ ′ . From this position, the WOS algorithm is resumed, until the particle arrives again inside the layer, and so on. The simulation is stopped according to a prescribed stopping condition (see § 2.5 ).
This layer escape problem was solved in [58 ] . In fact, for any bounded domain with a smooth boundary, a formal spectral expansion was derived for the probability density flux j ( x , ℓ , t ∣ x k ) j(x,\ell,t|x_k) j ( x , ℓ , t ∣ x k ) , which is the joint probability density of the escape position X τ ′ ∈ Γ ε X'_\tau\in\Gamma_\varepsilon X τ ′ ∈ Γ ε , the acquired boundary local time ℓ τ ′ \ell'_\tau ℓ τ ′ , and the escape time τ \tau τ . In the Laplace domain, this spectral expansion reads for any x ∈ Γ ε x \in\Gamma_\varepsilon x ∈ Γ ε :
j ~ ( x , p , ℓ ∣ x k ) = ∫ 0 ∞ d t e − p t j ( x , ℓ , t ∣ x k ) = j ~ 0 ( x , p ∣ x k ) δ ( ℓ ) − ∑ k = 0 ∞ V k ( p ) ( x k ) ∗ ( ∂ n V k ( p ) ( x ) ) e − μ k ( p ) ℓ , (4) \begin{aligned}
\widetilde{j}(x,p,\ell|x_k) = \int_0^\infty\mathrm{d}t\,e^{-pt}j(x,\ell,t|x_k) \\
&= \widetilde{j}_0(x,p|x_k)\delta(\ell) - \sum_{k=0}^{\infty} V_k^{(p)}(x_k)^* \left(\partial_n V_k^{(p)}(x)\right)e^{-\mu_k^{(p)}\ell}, \tag*{(4)}
\end{aligned} j ( x , p , ℓ ∣ x k ) = ∫ 0 ∞ d t e − pt j ( x , ℓ , t ∣ x k ) = j 0 ( x , p ∣ x k ) δ ( ℓ ) − k = 0 ∑ ∞ V k ( p ) ( x k ) ∗ ( ∂ n V k ( p ) ( x ) ) e − μ k ( p ) ℓ , (4)
where ∂ n \partial_n ∂ n is the normal derivative on the boundary Γ ε \Gamma_\varepsilon Γ ε oriented outwards the domain Ω ε \Omega_\varepsilon Ω ε , asterisk denotes complex conjugate, p ≥ 0 p \ge0 p ≥ 0 is a scalar, j ~ 0 ( x , p ∣ x k ) \widetilde{j}_0(x,p|x_k) j 0 ( x , p ∣ x k ) is the Laplace transform of the probability density flux onto Γ ε \Gamma_\varepsilon Γ ε in the case of the absorbing boundary ∂ Ω \partial\Omega ∂ Ω , while μ k ( p ) \mu_k^{(p)} μ k ( p ) and V k ( p ) ( x ) V_k^{(p)}(x) V k ( p ) ( x ) with k = 0 , 1 , 2 , … k = 0,1,2,\ldots k = 0 , 1 , 2 , … are the eigenvalues and eigenfunctions of the generalized Steklov problem in the boundary layer Ω ε \Omega_\varepsilon Ω ε :
( p − D Δ ) V k ( p ) ( x ) = 0 ( x ∈ Ω ε ) , (5) (p - D\Delta)V_k^{(p)}(x) = 0 \quad(x \in\Omega_\varepsilon), \tag*{(5)} ( p − D Δ ) V k ( p ) ( x ) = 0 ( x ∈ Ω ε ) , (5)
∂ n V k ( p ) ( x ) = μ k ( p ) V k ( p ) ( x ) ( x ∈ ∂ Ω ) , (6) \partial_n V_k^{(p)}(x) = \mu_k^{(p)}V_k^{(p)}(x) \quad(x \in\partial\Omega), \tag*{(6)} ∂ n V k ( p ) ( x ) = μ k ( p ) V k ( p ) ( x ) ( x ∈ ∂ Ω ) , (6)
V k ( p ) ( x ) = 0 ( x ∈ Γ ε ) (7) V_k^{(p)}(x) = 0 \quad(x \in\Gamma_\varepsilon) \tag*{(7)} V k ( p ) ( x ) = 0 ( x ∈ Γ ε ) (7)
(for mathematical details about the Steklov problem, see [60 ] and references therein). The first term in Eq. (4) represents the contribution of trajectories that do not hit the boundary ∂ Ω \partial\Omega ∂ Ω until escaping the layer Ω ε \Omega_\varepsilon Ω ε . As a consequence, the acquired boundary local time ℓ τ ′ \ell_{\tau}^{\prime} ℓ τ ′ is zero, as represented by the Dirac distribution δ ( ℓ ) \delta(\ell) δ ( ℓ ) . In turn, the second term accounts for other trajectories that arrived onto ∂ Ω \partial\Omega ∂ Ω and thus yielded positive ℓ τ ′ \ell_{\tau}^{\prime} ℓ τ ′ . Note that all the “ingredients” of Eq. (4) depend on the shape of the boundary layer Ω ε \Omega_{\varepsilon} Ω ε , so that advanced numerical tools are in general needed to access these quantities. In practice, their computation is usually more challenging than that of the boundary local time ℓ t \ell_t ℓ t in the original domain Ω \Omega Ω . In other words, a direct application of this spectral expansion for Monte Carlo simulations is pointless. In the next subsection, we propose an approximate scheme that relies on the smallness of the width ε \varepsilon ε .
Flat layer approximation (FLA)
For clarity, we focus on the planar case (d = 2 d=2 d = 2 ) but the method is immediately applicable in any dimension d ≥ 2 d\geq2 d ≥ 2 (see below). We assume that the boundary ∂ Ω \partial\Omega ∂ Ω is smooth and can thus be considered as flat at a small scale ε \varepsilon ε . In other words, the boundary layer Ω ε \Omega_{\varepsilon} Ω ε in the vicinity of x k \boldsymbol{x}_k x k can be approximated by an infinite stripe of width ε \varepsilon ε : R × ( 0 , ε ) \mathbb{R}\times(0,\varepsilon) R × ( 0 , ε ) . Let x b ∈ ∂ Ω \boldsymbol{x}_b\in\partial\Omega x b ∈ ∂ Ω be the boundary point, which is the closest to x k \boldsymbol{x}_k x k . For simplicity of notations, we introduce local coordinates with the origin at x b \boldsymbol{x}_b x b and with y y y axis being perpendicular to the boundary (Figure 1 b). In other words, x b = ( 0 , 0 ) \boldsymbol{x}_b=(0,0) x b = ( 0 , 0 ) and x k = ( 0 , y 0 ) \boldsymbol{x}_k=(0,y_0) x k = ( 0 , y 0 ) , where y 0 = ∣ x k − ∂ Ω ∣ = ∣ x k − x b ∣ y_0=\lvert\boldsymbol{x}_k-\partial\Omega\rvert=\lvert\boldsymbol{x}_k-\boldsymbol{x}_b\rvert y 0 = ∣ x k − ∂ Ω ∣ = ∣ x k − x b ∣ is the distance to the boundary from x k \boldsymbol{x}_k x k . As lateral and transverse displacements in the stripe are independent, one can focus on diffusion on the interval ( 0 , ε ) (0,\varepsilon) ( 0 , ε ) with reflecting endpoint 0 0 0 and absorbing endpoint ε \varepsilon ε , so that the general spectral expansion can be considerably simplified. In fact, one has
j ( x , ε , ℓ , t ∣ x 0 , y 0 ) = e − ( x − x 0 ) 2 / ( 4 D t ) 4 π D t J ( ℓ , t ∣ y 0 ) , (8) j(x,\varepsilon,\ell,t\mid x_0,y_0)=\frac{e^{-(x-x_0)^2/(4Dt)}}{\sqrt{4\pi Dt}}J(\ell,t\mid y_0), \tag*{(8)} j ( x , ε , ℓ , t ∣ x 0 , y 0 ) = 4 π D t e − ( x − x 0 ) 2 / ( 4 D t ) J ( ℓ , t ∣ y 0 ) , (8)
where the first factor is the Gaussian probability density of the lateral displacement x τ x_{\tau} x τ , while the second factor describes the joint probability density of ℓ τ ′ \ell_{\tau}^{\prime} ℓ τ ′ and τ \tau τ for the transverse displacement. According to Eq. (4) , the latter admits the following representation in the Laplace domain:
J ~ ( ℓ , p ∣ y 0 ) = J ~ 0 ( p ∣ y 0 ) δ ( ℓ ) + ∑ k = 0 ∞ [ V k ( p ) ( y 0 ) ] ∗ e − μ k ( p ) ℓ C k ( p ) , (9) \widetilde{J}(\ell,p\mid y_0)=\widetilde{J}_0(p\mid y_0)\delta(\ell)+\sum_{k=0}^{\infty}\left[V_k^{(p)}(y_0)\right]^*e^{-\mu_k^{(p)}\ell}C_k^{(p)}, \tag*{(9)} J ( ℓ , p ∣ y 0 ) = J 0 ( p ∣ y 0 ) δ ( ℓ ) + k = 0 ∑ ∞ [ V k ( p ) ( y 0 ) ] ∗ e − μ k ( p ) ℓ C k ( p ) , (9)
where
C k ( p ) = − ∂ n V k ( p ) ∣ y = ε , (10) C_k^{(p)}=-\left.\partial_n V_k^{(p)}\right|_{y=\varepsilon}, \tag*{(10)} C k ( p ) = − ∂ n V k ( p ) y = ε , (10)
μ k ( p ) \mu_k^{(p)} μ k ( p ) and V k ( p ) ( y ) V_k^{(p)}(y) V k ( p ) ( y ) are the eigenvalues and eigenfunctions of the Steklov problem on the interval ( 0 , ε ) (0,\varepsilon) ( 0 , ε ) , and J ~ 0 ( p ∣ x 0 ) \widetilde{J}_0(p\mid x_0) J 0 ( p ∣ x 0 ) is the Laplace transform of the probability flux onto the absorbing endpoint ε \varepsilon ε of the interval under the condition of not hitting the endpoint 0 0 0 . In the case of an interval ( 0 , ε ) (0,\varepsilon) ( 0 , ε ) with one absorbing endpoint ε \varepsilon ε , the above spectral expansion includes only one eigenmode (k = 0 k=0 k = 0 ), and all the ingredients are known explicitly:
V 0 ( p ) ( y ) = sinh ( p / D ( ε − y ) ) sinh ( p / D ε ) , (11) V_0^{(p)}(y)=\frac{\sinh\left(\sqrt{p/D}(\varepsilon-y)\right)}{\sinh\left(\sqrt{p/D}\varepsilon\right)}, \tag*{(11)} V 0 ( p ) ( y ) = sinh ( p / D ε ) sinh ( p / D ( ε − y ) ) , (11)
μ 0 ( p ) = p / D tanh ( p / D ε ) , (12) \mu_0^{(p)}=\sqrt{p/D}\tanh\left(\sqrt{p/D}\varepsilon\right), \tag*{(12)} μ 0 ( p ) = p / D tanh ( p / D ε ) , (12)
C 0 ( p ) = p / D sinh ( p / D ε ) , (13) C_0^{(p)}=\frac{\sqrt{p/D}}{\sinh\left(\sqrt{p/D}\varepsilon\right)}, \tag*{(13)} C 0 ( p ) = sinh ( p / D ε ) p / D , (13)
J ~ 0 ( p ∣ y 0 ) = sinh ( p / D y 0 ) sinh ( p / D ε ) . (14) \widetilde{J}_0(p\mid y_0)=\frac{\sinh\left(\sqrt{p/D}y_0\right)}{\sinh\left(\sqrt{p/D}\varepsilon\right)}. \tag*{(14)} J 0 ( p ∣ y 0 ) = sinh ( p / D ε ) sinh ( p / D y 0 ) . (14)
As a consequence, one has
J ~ ( ℓ , p ∣ y 0 ) = sinh ( p / D y 0 ) sinh ( p / D ε ) δ ( ℓ ) + p / D sinh ( p / D ( ε − y 0 ) ) sinh 2 ( p / D ε ) e − ℓ p / D tanh ( p / D ε ) . (15) \widetilde{J}(\ell,p\mid y_0)=\frac{\sinh\left(\sqrt{p/D}y_0\right)}{\sinh\left(\sqrt{p/D}\varepsilon\right)}\delta(\ell)+\frac{\sqrt{p/D}\sinh\left(\sqrt{p/D}(\varepsilon-y_0)\right)}{\sinh^2\left(\sqrt{p/D}\varepsilon\right)}e^{-\ell\sqrt{p/D}\tanh\left(\sqrt{p/D}\varepsilon\right)}. \tag*{(15)} J ( ℓ , p ∣ y 0 ) = sinh ( p / D ε ) sinh ( p / D y 0 ) δ ( ℓ ) + sinh 2 ( p / D ε ) p / D sinh ( p / D ( ε − y 0 ) ) e − ℓ p / D t a n h ( p / D ε ) . (15)
In order to generate two random variables ℓ τ ′ \ell_{\tau}^{\prime} ℓ τ ′ and τ \tau τ , one can first generate ℓ τ ′ \ell_{\tau}^{\prime} ℓ τ ′ and then employ the conditional distribution of τ \tau τ . The marginal probability density ρ ( ℓ ∣ y 0 ) \rho(\ell\mid y_0) ρ ( ℓ ∣ y 0 ) of the random variable ℓ τ ′ \ell_{\tau}^{\prime} ℓ τ ′ is obtained by integrating the joint probability density J ( ℓ , t ∣ y 0 ) J(\ell,t|y_0) J ( ℓ , t ∣ y 0 ) over the second variable t t t , i.e., by setting p = 0 p=0 p = 0 in the Laplace transform:
ρ ( ℓ ∣ y 0 ) = ∫ 0 ∞ d t J ( ℓ , t ∣ y 0 ) = J ~ ( ℓ , 0 ∣ y 0 ) = π 0 δ ( ℓ ) + ( 1 − π 0 ) e − ℓ / ε ε . (16) \rho(\ell|y_0)=\int_0^\infty\mathrm{d}t\,J(\ell,t|y_0)=\widetilde{J}(\ell,0|y_0)=\pi_0\delta(\ell)+(1-\pi_0)\frac{e^{-\ell/\varepsilon}}{\varepsilon}. \tag*{(16)} ρ ( ℓ ∣ y 0 ) = ∫ 0 ∞ d t J ( ℓ , t ∣ y 0 ) = J ( ℓ , 0∣ y 0 ) = π 0 δ ( ℓ ) + ( 1 − π 0 ) ε e − ℓ / ε . (16)
where π 0 = J ~ 0 ( 0 ∣ y 0 ) = y 0 / ε \pi_0=\widetilde{J}_0(0|y_0)=y_0/\varepsilon π 0 = J 0 ( 0∣ y 0 ) = y 0 / ε is the splitting probability of reaching the endpoint ε \varepsilon ε first. This is a mixture of the Dirac distribution at 0 and the exponential distribution with mean ε \varepsilon ε . In other words, the random variable ℓ τ ′ \ell'_\tau ℓ τ ′ admits a simple form:
ℓ τ ′ = { 0 , with probability π 0 , ε η , with probability 1 − π 0 , (17) \ell'_\tau=
\begin{cases}
0, & \text{with probability }\pi_0,\\
\varepsilon\eta, & \text{with probability }1-\pi_0,
\end{cases} \tag*{(17)} ℓ τ ′ = { 0 , ε η , with probability π 0 , with probability 1 − π 0 , (17)
where η \eta η is the standard exponentially distributed random variable (with mean 1).
Even though the conditional distribution of the escape time τ \tau τ is found exactly in the Laplace domain (see below), the inversion of the Laplace transform and the consequent generation of τ \tau τ can be time-consuming (see Appendix § 8 ). To overcome this limitation, we propose a simple approximation, in which the random escape time τ \tau τ is replaced by its mean value, which can be found explicitly (see Appendix § 9 for discussion on its validity).
In practice, one can first generate a binary random variable that determines which endpoint of the interval ( 0 , ε ) (0,\varepsilon) ( 0 , ε ) is reached first: the endpoint ε \varepsilon ε (with probability π 0 \pi_0 π 0 ) or the endpoint 0 (with probability 1 − π 0 1-\pi_0 1 − π 0 ).
(i) If the endpoint ε \varepsilon ε is reached first, then the boundary local time ℓ τ ′ \ell'_\tau ℓ τ ′ is zero, while the escape time (denoted here as τ 0 \tau_0 τ 0 ) is determined by the conditional probability density H 0 ( t ∣ y 0 ) H_0(t|y_0) H 0 ( t ∣ y 0 ) (see Appendix § 8 ), whose Laplace transform is
⟨ e − p τ 0 ⟩ = H ~ 0 ( p ∣ y 0 ) = ε y 0 sinh ( p / D y 0 ) sinh ( p / D ε ) . (18) \left\langle e^{-p\tau_0}\right\rangle=\widetilde{H}_0(p|y_0)=\frac{\varepsilon}{y_0}\frac{\sinh\left(\sqrt{p/D}\,y_0\right)}{\sinh\left(\sqrt{p/D}\,\varepsilon\right)}. \tag*{(18)} ⟨ e − p τ 0 ⟩ = H 0 ( p ∣ y 0 ) = y 0 ε sinh ( p / D ε ) sinh ( p / D y 0 ) . (18)
The mean escape time is then
⟨ τ 0 ⟩ = − ( ∂ p H ~ 0 ( p ∣ y 0 ) ) p = 0 = ε 2 − y 0 2 6 D . (19) \langle\tau_0\rangle=-\left(\partial_p\widetilde{H}_0(p|y_0)\right)_{p=0}=\frac{\varepsilon^2-y_0^2}{6D}. \tag*{(19)} ⟨ τ 0 ⟩ = − ( ∂ p H 0 ( p ∣ y 0 ) ) p = 0 = 6 D ε 2 − y 0 2 . (19)
(ii) If the endpoint 0 is reached first, then the boundary local time ℓ τ ′ \ell'_\tau ℓ τ ′ is nonzero and can be generated from its marginal distribution (16) , i.e., by setting ℓ τ ′ = ε η \ell'_\tau=\varepsilon\eta ℓ τ ′ = ε η , where η \eta η is the standard exponential random variable. In turn, the Laplace transform of the conditional probability density of the escape time (denoted here as τ ℓ \tau_\ell τ ℓ ) is determined by the second term in Eq. (15) , which is divided by the second term in Eq. (16) :
⟨ e − p τ ℓ ⟩ = H ~ ( p ∣ y 0 , ℓ ) = 1 ( 1 − π 0 ) e − ℓ / ε / ε p / D sinh ( p / D ( ε − y 0 ) ) sinh 2 ( p / D ε ) e − ℓ p / D coth ( p / D ε ) . (20) \left\langle e^{-p\tau_\ell}\right\rangle=\widetilde{H}(p|y_0,\ell)=\frac{1}{(1-\pi_0)e^{-\ell/\varepsilon}/\varepsilon}\frac{\sqrt{p/D}\sinh\left(\sqrt{p/D}(\varepsilon-y_0)\right)}{\sinh^2\left(\sqrt{p/D}\,\varepsilon\right)}e^{-\ell\sqrt{p/D}\coth\left(\sqrt{p/D}\,\varepsilon\right)}. \tag*{(20)} ⟨ e − p τ ℓ ⟩ = H ( p ∣ y 0 , ℓ ) = ( 1 − π 0 ) e − ℓ / ε / ε 1 sinh 2 ( p / D ε ) p / D sinh ( p / D ( ε − y 0 ) ) e − ℓ p / D c o t h ( p / D ε ) . (20)
The mean escape time is then
⟨ τ ℓ ⟩ = − ( ∂ p H ~ ( p ∣ y 0 , ℓ ) ) p = 0 = 2 ℓ ε + 2 ε 2 − ( ε − y 0 ) 2 6 D . (21) \langle\tau_\ell\rangle=-\left(\partial_p\widetilde{H}(p|y_0,\ell)\right)_{p=0}=\frac{2\ell\varepsilon+2\varepsilon^2-(\varepsilon-y_0)^2}{6D}. \tag*{(21)} ⟨ τ ℓ ⟩ = − ( ∂ p H ( p ∣ y 0 , ℓ ) ) p = 0 = 6 D 2 ℓ ε + 2 ε 2 − ( ε − y 0 ) 2 . (21)
Finally, the lateral displacement x τ x_\tau x τ can be generated as the Gaussian random variable with mean zero and variance 2 D ⟨ τ 0 ⟩ 2D\langle\tau_0\rangle 2 D ⟨ τ 0 ⟩ or 2 D ⟨ τ ℓ ⟩ 2D\langle\tau_\ell\rangle 2 D ⟨ τ ℓ ⟩ .
In higher dimensions (d > 2 d>2 d > 2 ), the boundary layer near x k x_k x k is approximated by a slab R d − 1 × ( 0 , ε ) \mathbb{R}^{d-1}\times(0,\varepsilon) R d − 1 × ( 0 , ε ) between two parallel (hyper)planes. As the lateral and transverse displacements are still independent, the probability density flux j ( x , ℓ , t ∣ x k ) j(x,\ell,t|x_k) j ( x , ℓ , t ∣ x k ) is again factored into a Gaussian density for the lateral displacement and the same joint probability density J ( ℓ , t ∣ y 0 ) J(\ell,t|y_0) J ( ℓ , t ∣ y 0 ) for the interval ( 0 , ε ) (0,\varepsilon) ( 0 , ε ) , like in Eq. (8) . As a consequence, the generation of ℓ τ ′ \ell'_\tau ℓ τ ′ and τ \tau τ remains unchanged, whereas the displacement along each lateral coordinate is still an independent Gaussian random variable with mean 0 and variance 2 D ⟨ τ 0 ⟩ 2D\langle\tau_0\rangle 2 D ⟨ τ 0 ⟩ or 2 D ⟨ τ ℓ ⟩ 2D\langle\tau_\ell\rangle 2 D ⟨ τ ℓ ⟩ .
Curved layer approximation (CLA)
The above flat layer approximation ignores the curvature of the boundary, that is only valid for small enough ε \varepsilon ε . Such a choice may slow down simulations, as the process stays too long in the vicinity of the boundary. This approximation can be further improved by approximating the boundary layer by a circular annulus or a spherical shell, with the same radius of curvature. We start by the two-dimensional case and then extend it to three dimensions.
Convex boundary in two dimensions
We first consider the case of a convex boundary (Figure 2 a). Let R R R be the radius of curvature of the boundary at the boundary point x b \boldsymbol{x}_b x b , which is the closest to x k \boldsymbol{x}_k x k . The boundary layer can be approximated by a circular annulus between two circles of radii R − ε R-\varepsilon R − ε and R R R , separated by distance ε \varepsilon ε , i.e., Ω ε = { x ∈ R 2 : R − ε < ∣ x ∣ < R } \Omega_\varepsilon=\{\boldsymbol{x}\in\mathbb{R}^2:R-\varepsilon<|\boldsymbol{x}|<R\} Ω ε = { x ∈ R 2 : R − ε < ∣ x ∣ < R } . We are interested in the escape event from that annulus through the inner circle Γ ε = { x ∈ R 2 : ∣ x ∣ = R − ε } \Gamma_\varepsilon=\{\boldsymbol{x}\in\mathbb{R}^2:|\boldsymbol{x}|=R-\varepsilon\} Γ ε = { x ∈ R 2 : ∣ x ∣ = R − ε } of radius R − ε R-\varepsilon R − ε , which is thus absorbing. The joint probability density J ( ℓ , t ∣ x k ) J(\ell,t|\boldsymbol{x}_k) J ( ℓ , t ∣ x k ) of the escape time τ \tau τ and the boundary local time ℓ τ ′ \ell_\tau' ℓ τ ′ , acquired on the outer circle up to τ \tau τ , is determined by the radial displacements. This can also be seen by integrating the probability density flux j ( x , ℓ , t ∣ x k ) j(\boldsymbol{x},\ell,t|\boldsymbol{x}_k) j ( x , ℓ , t ∣ x k ) over the escape position X τ ′ \boldsymbol{X}'_\tau X τ ′ on the inner circle, in which case all terms in the sum of Eq. (4) with k ≠ 0 k\ne0 k = 0 vanish due to the periodic dependence of the Steklov eigenfunctions V k ( p ) V_k^{(p)} V k ( p ) on the angle [24 ] . In other words, we get
Figure 2. Curved layer approximation: starting from a point ( r 0 , ϕ 0 ) (r_0,\phi_0) ( r 0 , ϕ 0 ) in polar coordinates (yellow circle), a random trajectory (in blue) experiences numerous reflections on the circle of radius R R R before escaping a thin layer of width ε \varepsilon ε at a random escape time τ \tau τ in a random escape position ( R ± ε , ϕ τ ) (R \pm\varepsilon,\phi_\tau) ( R ± ε , ϕ τ ) (red circle), with sign minus corresponding to a convex boundary (a) and sign plus corresponding to a concave boundary (b). These reflections are characterized by the acquired boundary local time ℓ τ ′ \ell_\tau' ℓ τ ′ .
J ~ ( ℓ , p ∣ r 0 ) = J ~ 0 ( p ∣ r 0 ) δ ( ℓ ) + V 0 ( p ) ( r 0 ) C 0 ( p ) e − μ 0 ( p ) ℓ , (22) \widetilde{J}(\ell,p|r_0)=\widetilde{J}_0(p|r_0)\delta(\ell)+V_0^{(p)}(r_0)C_0^{(p)}e^{-\mu_0^{(p)}\ell}, \tag*{(22)} J ( ℓ , p ∣ r 0 ) = J 0 ( p ∣ r 0 ) δ ( ℓ ) + V 0 ( p ) ( r 0 ) C 0 ( p ) e − μ 0 ( p ) ℓ , (22)
where r 0 = ∣ x k ∣ r_0=|\boldsymbol{x}_k| r 0 = ∣ x k ∣ is the radial coordinate of the starting point (here, we do not employ local coordinates centered at x b \boldsymbol{x}_b x b so that r 0 ∈ ( R − ε , R ] r_0\in(R-\varepsilon,R] r 0 ∈ ( R − ε , R ] ), and
C 0 ( p ) = − ∫ Γ ε d x ( ∂ n V 0 ( p ) ) . (23) C_0^{(p)}=-\int_{\Gamma_\varepsilon}d\boldsymbol{x}\,(\partial_nV_0^{(p)}). \tag*{(23)} C 0 ( p ) = − ∫ Γ ε d x ( ∂ n V 0 ( p ) ) . (23)
For a circular annulus with an absorbing inner boundary, one has [24 ]
V 0 ( p ) ( r 0 ) = 1 2 π R K 0 ( α ( R − ε ) ) I 0 ( α r 0 ) − I 0 ( α ( R − ε ) ) K 0 ( α r 0 ) K 0 ( α ( R − ε ) ) I 0 ( α R ) − I 0 ( α ( R − ε ) ) K 0 ( α R ) , (24) V_0^{(p)}(r_0)=\frac{1}{\sqrt{2\pi R}}\frac{K_0(\alpha(R-\varepsilon))I_0(\alpha r_0)-I_0(\alpha(R-\varepsilon))K_0(\alpha r_0)}{K_0(\alpha(R-\varepsilon))I_0(\alpha R)-I_0(\alpha(R-\varepsilon))K_0(\alpha R)}, \tag*{(24)} V 0 ( p ) ( r 0 ) = 2 π R 1 K 0 ( α ( R − ε )) I 0 ( α R ) − I 0 ( α ( R − ε )) K 0 ( α R ) K 0 ( α ( R − ε )) I 0 ( α r 0 ) − I 0 ( α ( R − ε )) K 0 ( α r 0 ) , (24)
μ 0 ( p ) = α K 0 ( α ( R − ε ) ) I 1 ( α R ) + I 0 ( α ( R − ε ) ) K 1 ( α R ) K 0 ( α ( R − ε ) ) I 0 ( α R ) − I 0 ( α ( R − ε ) ) K 0 ( α R ) , (25) \mu_0^{(p)}=\alpha\frac{K_0(\alpha(R-\varepsilon))I_1(\alpha R)+I_0(\alpha(R-\varepsilon))K_1(\alpha R)}{K_0(\alpha(R-\varepsilon))I_0(\alpha R)-I_0(\alpha(R-\varepsilon))K_0(\alpha R)}, \tag*{(25)} μ 0 ( p ) = α K 0 ( α ( R − ε )) I 0 ( α R ) − I 0 ( α ( R − ε )) K 0 ( α R ) K 0 ( α ( R − ε )) I 1 ( α R ) + I 0 ( α ( R − ε )) K 1 ( α R ) , (25)
C 0 ( p ) = 2 π R 1 K 0 ( α ( R − ε ) ) I 0 ( α R ) − I 0 ( α ( R − ε ) ) K 0 ( α R ) , (26) C_0^{(p)}=\frac{\sqrt{2\pi}}{\sqrt{R}}\frac{1}{K_0(\alpha(R-\varepsilon))I_0(\alpha R)-I_0(\alpha(R-\varepsilon))K_0(\alpha R)}, \tag*{(26)} C 0 ( p ) = R 2 π K 0 ( α ( R − ε )) I 0 ( α R ) − I 0 ( α ( R − ε )) K 0 ( α R ) 1 , (26)
J ~ 0 ( p ∣ r 0 ) = K 0 ( α R ) I 0 ( α r 0 ) − I 0 ( α R ) K 0 ( α r 0 ) K 0 ( α R ) I 0 ( α ( R − ε ) ) − I 0 ( α R ) K 0 ( α ( R − ε ) ) , (27) \widetilde{J}_0(p|r_0)=\frac{K_0(\alpha R)I_0(\alpha r_0)-I_0(\alpha R)K_0(\alpha r_0)}{K_0(\alpha R)I_0(\alpha(R-\varepsilon))-I_0(\alpha R)K_0(\alpha(R-\varepsilon))}, \tag*{(27)} J 0 ( p ∣ r 0 ) = K 0 ( α R ) I 0 ( α ( R − ε )) − I 0 ( α R ) K 0 ( α ( R − ε )) K 0 ( α R ) I 0 ( α r 0 ) − I 0 ( α R ) K 0 ( α r 0 ) , (27)
where α = p / D \alpha=\sqrt{p/D} α = p / D , I ν ( z ) I_\nu(z) I ν ( z ) and K ν ( z ) K_\nu(z) K ν ( z ) are the modified Bessel functions of the first and second kind, and we used I 0 ′ ( z ) = I 1 ( z ) I_0'(z)=I_1(z) I 0 ′ ( z ) = I 1 ( z ) , K 0 ′ ( z ) = − K 1 ( z ) K_0'(z)=-K_1(z) K 0 ′ ( z ) = − K 1 ( z ) , and the Wronskian K ν ( z ) I ν ′ ( z ) − I ν ( z ) K ν ′ ( z ) = 1 / z K_\nu(z)I_\nu'(z)-I_\nu(z)K_\nu'(z)=1/z K ν ( z ) I ν ′ ( z ) − I ν ( z ) K ν ′ ( z ) = 1/ z .
In the limit p → 0 p\to0 p → 0 , we get the marginal probability density of the boundary local time ℓ τ ′ \ell_\tau' ℓ τ ′ :
ρ ( ℓ ∣ r 0 ) = J ~ ( ℓ , 0 ∣ r 0 ) = J ~ 0 ( 0 ∣ r 0 ) δ ( ℓ ) + V 0 ( 0 ) ( r 0 ) C 0 ( 0 ) e − μ 0 ( 0 ) ℓ , (28) \rho(\ell|r_0)=\widetilde{J}(\ell,0|r_0)=\widetilde{J}_0(0|r_0)\delta(\ell)+V_0^{(0)}(r_0)C_0^{(0)}e^{-\mu_0^{(0)}\ell}, \tag*{(28)} ρ ( ℓ ∣ r 0 ) = J ( ℓ , 0∣ r 0 ) = J 0 ( 0∣ r 0 ) δ ( ℓ ) + V 0 ( 0 ) ( r 0 ) C 0 ( 0 ) e − μ 0 ( 0 ) ℓ , (28)
where
V 0 ( 0 ) ( r 0 ) = 1 2 π R ln ( r 0 / ( R − ε ) ) ln ( R / ( R − ε ) ) , (29) V_0^{(0)}(r_0)=\frac{1}{\sqrt{2\pi R}}\frac{\ln(r_0/(R-\varepsilon))}{\ln(R/(R-\varepsilon))}, \tag*{(29)} V 0 ( 0 ) ( r 0 ) = 2 π R 1 ln ( R / ( R − ε )) ln ( r 0 / ( R − ε )) , (29)
μ 0 ( 0 ) = 1 R ln ( R / ( R − ε ) ) , (30) \mu_0^{(0)}=\frac{1}{R\ln(R/(R-\varepsilon))}, \tag*{(30)} μ 0 ( 0 ) = R ln ( R / ( R − ε )) 1 , (30)
C 0 ( 0 ) = 2 π R 1 ln ( R / ( R − ε ) ) , (31) C_0^{(0)}=\frac{\sqrt{2\pi}}{\sqrt{R}}\frac{1}{\ln(R/(R-\varepsilon))}, \tag*{(31)} C 0 ( 0 ) = R 2 π ln ( R / ( R − ε )) 1 , (31)
π 0 = J ~ 0 ( 0 ∣ r 0 ) = ln ( R / r 0 ) ln ( R / ( R − ε ) ) , (32) \pi_0=\widetilde{J}_0(0|r_0)=\frac{\ln(R/r_0)}{\ln(R/(R-\varepsilon))}, \tag*{(32)} π 0 = J 0 ( 0∣ r 0 ) = ln ( R / ( R − ε )) ln ( R / r 0 ) , (32)
and we used the asymptotic behavior of the modified Bessel functions. As a consequence, we find
ρ ( ℓ ∣ r 0 ) = π 0 δ ( ℓ ) + ( 1 − π 0 ) μ 0 ( 0 ) e − μ 0 ( 0 ) ℓ . (33) \rho(\ell|r_0)=\pi_0\delta(\ell)+(1-\pi_0)\mu_0^{(0)}e^{-\mu_0^{(0)}\ell}. \tag*{(33)} ρ ( ℓ ∣ r 0 ) = π 0 δ ( ℓ ) + ( 1 − π 0 ) μ 0 ( 0 ) e − μ 0 ( 0 ) ℓ . (33)
As in the case of the flat layer approximation, we get a mixture of the Dirac distribution at 0 0 0 and the exponential distribution with the mean 1 / μ 0 ( 0 ) 1/\mu_0^{(0)} 1/ μ 0 ( 0 ) , where π 0 \pi_0 π 0 is the splitting probability of the first arrival onto the absorbing (inner) circle, in which case the boundary local time is zero. Setting r 0 = R − y 0 r_0=R-y_0 r 0 = R − y 0 , one sees that π 0 ( r 0 ) ≈ y 0 / ε \pi_0(r_0)\approx y_0/\varepsilon π 0 ( r 0 ) ≈ y 0 / ε in the limit ε ≪ 1 \varepsilon\ll1 ε ≪ 1 and y 0 ≪ 1 y_0\ll1 y 0 ≪ 1 , as in the flat case.
By generating a binary random variable, one can choose between two options:
(i) with probability π 0 \pi_0 π 0 , one has ℓ τ ′ = 0 \ell_{\tau}^{\prime}=0 ℓ τ ′ = 0 , and the escape time τ 0 \tau_0 τ 0 is determined by
⟨ e − p τ 0 ⟩ = H ~ 0 ( p ∣ r 0 ) = J ~ 0 ( p ∣ r 0 ) π 0 . (34) \langle e^{-p\tau_0}\rangle=\widetilde{H}_0(p|r_0)=\frac{\widetilde{J}_0(p|r_0)}{\pi_0}. \tag*{(34)} ⟨ e − p τ 0 ⟩ = H 0 ( p ∣ r 0 ) = π 0 J 0 ( p ∣ r 0 ) . (34)
In particular, the mean escape time is
⟨ τ 0 ⟩ = − ( ∂ p H ~ 0 ( p ∣ r 0 ) ) p = 0 = 1 4 D ( ( R − ε ) 2 − r 0 2 + R 2 − r 0 2 ln ( R / r 0 ) − R 2 − ( R − ε ) 2 ln ( R / ( R − ε ) ) ) . (35) \langle\tau_0\rangle=-\left(\partial_p\widetilde{H}_0(p|r_0)\right)_{p=0}
=\frac{1}{4D}\left((R-\varepsilon)^2-r_0^2+\frac{R^2-r_0^2}{\ln(R/r_0)}-\frac{R^2-(R-\varepsilon)^2}{\ln(R/(R-\varepsilon))}\right). \tag*{(35)} ⟨ τ 0 ⟩ = − ( ∂ p H 0 ( p ∣ r 0 ) ) p = 0 = 4 D 1 ( ( R − ε ) 2 − r 0 2 + ln ( R / r 0 ) R 2 − r 0 2 − ln ( R / ( R − ε )) R 2 − ( R − ε ) 2 ) . (35)
(ii) with probability 1 − π 0 1-\pi_0 1 − π 0 , one has ℓ τ ′ = η / μ 0 ( 0 ) \ell_{\tau}^{\prime}=\eta/\mu_0^{(0)} ℓ τ ′ = η / μ 0 ( 0 ) (where η \eta η is the standard exponential random variable), while the escape time τ ℓ \tau_\ell τ ℓ is determined by
⟨ e − p τ ℓ ⟩ = H ~ ( p ∣ r 0 , ℓ ) = V 0 ( p ) ( r 0 ) C 0 ( p ) e − μ 0 ( p ) ℓ ( 1 − π 0 ) μ 0 ( 0 ) e − μ 0 ( 0 ) ℓ . (36) \langle e^{-p\tau_\ell}\rangle=\widetilde{H}(p|r_0,\ell)=\frac{V_0^{(p)}(r_0)C_0^{(p)}e^{-\mu_0^{(p)}\ell}}{(1-\pi_0)\mu_0^{(0)}e^{-\mu_0^{(0)}\ell}}. \tag*{(36)} ⟨ e − p τ ℓ ⟩ = H ( p ∣ r 0 , ℓ ) = ( 1 − π 0 ) μ 0 ( 0 ) e − μ 0 ( 0 ) ℓ V 0 ( p ) ( r 0 ) C 0 ( p ) e − μ 0 ( p ) ℓ . (36)
The mean escape time is then
⟨ τ ℓ ⟩ = − ( ∂ p H ~ ( p ∣ r 0 , ℓ ) ) p = 0 = ℓ V 0 ( 0 ) C 0 ( 0 ) ( ∂ p μ 0 ( p ) ) p = 0 − ( ∂ p V 0 ( p ) ( r 0 ) C 0 ( p ) ) p = 0 ( 1 − π 0 ) μ 0 ( 0 ) . (37) \langle\tau_\ell\rangle=-\left(\partial_p\widetilde{H}(p|r_0,\ell)\right)_{p=0}
=\frac{\ell V_0^{(0)}C_0^{(0)}\left(\partial_p\mu_0^{(p)}\right)_{p=0}-\left(\partial_pV_0^{(p)}(r_0)C_0^{(p)}\right)_{p=0}}{(1-\pi_0)\mu_0^{(0)}}. \tag*{(37)} ⟨ τ ℓ ⟩ = − ( ∂ p H ( p ∣ r 0 , ℓ ) ) p = 0 = ( 1 − π 0 ) μ 0 ( 0 ) ℓ V 0 ( 0 ) C 0 ( 0 ) ( ∂ p μ 0 ( p ) ) p = 0 − ( ∂ p V 0 ( p ) ( r 0 ) C 0 ( p ) ) p = 0 . (37)
where
( ∂ p μ 0 ( p ) ) p = 0 = R 1 − ( 1 − ε / R ) 2 + 2 ln ( 1 − ε / R ) ( ln ( 1 − ε / R ) + 1 ) 4 D ln 2 ( 1 − ε / R ) , (38) \left(\partial_p\mu_0^{(p)}\right)_{p=0}
=R\frac{1-(1-\varepsilon/R)^2+2\ln(1-\varepsilon/R)(\ln(1-\varepsilon/R)+1)}{4D\ln^2(1-\varepsilon/R)}, \tag*{(38)} ( ∂ p μ 0 ( p ) ) p = 0 = R 4 D ln 2 ( 1 − ε / R ) 1 − ( 1 − ε / R ) 2 + 2 ln ( 1 − ε / R ) ( ln ( 1 − ε / R ) + 1 ) , (38)
and
( ∂ p V 0 ( p ) ( r 0 ) C 0 ( p ) ) p = 0 = − 1 4 D R ln 3 ( R / ( R − ε ) ) ( ( ( 2 R 2 + ( R − ε ) 2 − r 0 2 ) ln ( r 0 / ( R − ε ) ) ln ( R / ( R − ε ) ) + 2 ( R 2 − ( R − ε ) 2 ) ln ( R / r 0 ) − ( 2 R 2 − ( R − ε ) 2 − r 0 2 ) ln ( R / ( R − ε ) ) ) . (39) \left(\partial_pV_0^{(p)}(r_0)C_0^{(p)}\right)_{p=0}
=-\frac{1}{4DR\ln^3(R/(R-\varepsilon))}
\left(((2R^2+(R-\varepsilon)^2-r_0^2)\ln(r_0/(R-\varepsilon))\ln(R/(R-\varepsilon))
+2(R^2-(R-\varepsilon)^2)\ln(R/r_0)
-(2R^2-(R-\varepsilon)^2-r_0^2)\ln(R/(R-\varepsilon))\right). \tag*{(39)} ( ∂ p V 0 ( p ) ( r 0 ) C 0 ( p ) ) p = 0 = − 4 D R ln 3 ( R / ( R − ε )) 1 ( (( 2 R 2 + ( R − ε ) 2 − r 0 2 ) ln ( r 0 / ( R − ε )) ln ( R / ( R − ε )) + 2 ( R 2 − ( R − ε ) 2 ) ln ( R / r 0 ) − ( 2 R 2 − ( R − ε ) 2 − r 0 2 ) ln ( R / ( R − ε )) ) . (39)
Substituting these expressions into Eq. (37) , one can evaluate the mean escape time ⟨ τ ℓ ⟩ \langle\tau_\ell\rangle ⟨ τ ℓ ⟩ .
The last step consists in generating the escape position X τ ′ X_\tau^{\prime} X τ ′ on the inner circle. In contrast to the flat case, “lateral” displacements along the tangential direction are not independent from the transverse (radial) displacements due to the curvature. The exact distribution of the escape position can be found from the probability density flux j ( x , ℓ , t ∣ x 0 ) j(x,\ell,t|x_0) j ( x , ℓ , t ∣ x 0 ) , but its practical computation could be too sophisticated. In turn, two approximations can be useful.
(i) The simplest approximation consists in replacing the random variable X τ X_\tau X τ by its mean value. By symmetry, one has ⟨ X τ ⟩ = ( R − ε , ϕ 0 ) \langle X_\tau\rangle=(R-\varepsilon,\phi_0) ⟨ X τ ⟩ = ( R − ε , ϕ 0 ) in polar coordinates, where ϕ 0 \phi_0 ϕ 0 is the angle of the starting position x k = ( r 0 , ϕ 0 ) x_k=(r_0,\phi_0) x k = ( r 0 , ϕ 0 ) . For a flat boundary, this approximation would correspond to replacing x τ x_\tau x τ by ⟨ x τ ⟩ = 0 \langle x_\tau\rangle=0 ⟨ x τ ⟩ = 0 .
(ii) This approximation can be improved for small ε \varepsilon ε , for which the lateral motion can be treated as lying on the inner circle of radius R − ε R-\varepsilon R − ε (instead of displacements inside the thin annulus of width ε \varepsilon ε ). In this approximation, the displacements on the circle are characterized by the angle ϕ t \phi_t ϕ t , which is independent of radial displacements, and can thus be generated from known distributions (see [61 , 62 ] ).
Concave boundary in two dimensions
The analysis for a locally concave boundary (Figure 2 b) is very similar. In this case, one considers a thin circular annulus Ω ε = { x ∈ R 2 : R < ∣ x ∣ < R + ε } \Omega_\varepsilon=\{x\in\mathbb{R}^2:R<|x|<R+\varepsilon\} Ω ε = { x ∈ R 2 : R < ∣ x ∣ < R + ε } with the absorbing outer boundary Γ ε = { x ∈ R 2 : ∣ x ∣ = R + ε } \Gamma_\varepsilon=\{x\in\mathbb{R}^2:|x|=R+\varepsilon\} Γ ε = { x ∈ R 2 : ∣ x ∣ = R + ε } . As the absorbing boundary is now located at R + ε R+\varepsilon R + ε instead of R − ε R-\varepsilon R − ε , one mainly needs to change the sign of ε \varepsilon ε :
V 0 ( p ) ( r 0 ) = 1 2 π R K 0 ( α ( R + ε ) ) I 0 ( α r 0 ) − I 0 ( α ( R + ε ) ) K 0 ( α r 0 ) K 0 ( α ( R + ε ) ) I 0 ( α R ) − I 0 ( α ( R + ε ) ) K 0 ( α R ) (40) V_0^{(p)}(r_0)=\frac{1}{\sqrt{2\pi R}}\frac{K_0(\alpha(R+\varepsilon))I_0(\alpha r_0)-I_0(\alpha(R+\varepsilon))K_0(\alpha r_0)}{K_0(\alpha(R+\varepsilon))I_0(\alpha R)-I_0(\alpha(R+\varepsilon))K_0(\alpha R)} \tag*{(40)} V 0 ( p ) ( r 0 ) = 2 π R 1 K 0 ( α ( R + ε )) I 0 ( α R ) − I 0 ( α ( R + ε )) K 0 ( α R ) K 0 ( α ( R + ε )) I 0 ( α r 0 ) − I 0 ( α ( R + ε )) K 0 ( α r 0 ) (40)
μ 0 ( p ) = − α K 0 ( α ( R + ε ) ) I 1 ( α R ) + I 0 ( α ( R + ε ) ) K 1 ( α R ) K 0 ( α ( R + ε ) ) I 0 ( α R ) − I 0 ( α ( R + ε ) ) K 0 ( α R ) (41) \mu_0^{(p)}=-\alpha\frac{K_0(\alpha(R+\varepsilon))I_1(\alpha R)+I_0(\alpha(R+\varepsilon))K_1(\alpha R)}{K_0(\alpha(R+\varepsilon))I_0(\alpha R)-I_0(\alpha(R+\varepsilon))K_0(\alpha R)} \tag*{(41)} μ 0 ( p ) = − α K 0 ( α ( R + ε )) I 0 ( α R ) − I 0 ( α ( R + ε )) K 0 ( α R ) K 0 ( α ( R + ε )) I 1 ( α R ) + I 0 ( α ( R + ε )) K 1 ( α R ) (41)
C 0 ( p ) = − 2 π R 1 K 0 ( α ( R + ε ) ) I 0 ( α R ) − I 0 ( α ( R + ε ) ) K 0 ( α R ) (42) C_0^{(p)}=-\frac{\sqrt{2\pi}}{\sqrt{R}}\frac{1}{K_0(\alpha(R+\varepsilon))I_0(\alpha R)-I_0(\alpha(R+\varepsilon))K_0(\alpha R)} \tag*{(42)} C 0 ( p ) = − R 2 π K 0 ( α ( R + ε )) I 0 ( α R ) − I 0 ( α ( R + ε )) K 0 ( α R ) 1 (42)
J ~ 0 ( p ∣ r 0 ) = K 0 ( α R ) I 0 ( α r 0 ) − I 0 ( α R ) K 0 ( α r 0 ) K 0 ( α R ) I 0 ( α ( R + ε ) ) − I 0 ( α R ) K 0 ( α ( R + ε ) ) (43) \widetilde{J}_0(p|r_0)=\frac{K_0(\alpha R)I_0(\alpha r_0)-I_0(\alpha R)K_0(\alpha r_0)}{K_0(\alpha R)I_0(\alpha(R+\varepsilon))-I_0(\alpha R)K_0(\alpha(R+\varepsilon))} \tag*{(43)} J 0 ( p ∣ r 0 ) = K 0 ( α R ) I 0 ( α ( R + ε )) − I 0 ( α R ) K 0 ( α ( R + ε )) K 0 ( α R ) I 0 ( α r 0 ) − I 0 ( α R ) K 0 ( α r 0 ) (43)
Note also that the signs in front of μ 0 ( p ) \mu_0^{(p)} μ 0 ( p ) and C 0 ( p ) C_0^{(p)} C 0 ( p ) are also changed due to the opposite direction of the normal derivative. These expressions determine J ~ ( ℓ , p ∣ r 0 ) \widetilde{J}(\ell,p|r_0) J ( ℓ , p ∣ r 0 ) via Eq. (22) . One also gets
V 0 ( 0 ) ( r 0 ) = 1 2 π R ln ( r 0 / ( R + ε ) ) ln ( R / ( R + ε ) ) (44) V_0^{(0)}(r_0)=\frac{1}{\sqrt{2\pi R}}\frac{\ln(r_0/(R+\varepsilon))}{\ln(R/(R+\varepsilon))} \tag*{(44)} V 0 ( 0 ) ( r 0 ) = 2 π R 1 ln ( R / ( R + ε )) ln ( r 0 / ( R + ε )) (44)
μ 0 ( 0 ) = − 1 R ln ( R / ( R + ε ) ) (45) \mu_0^{(0)}=-\frac{1}{R\ln(R/(R+\varepsilon))} \tag*{(45)} μ 0 ( 0 ) = − R ln ( R / ( R + ε )) 1 (45)
C 0 ( 0 ) = − 2 π R 1 ln ( R / ( R + ε ) ) (46) C_0^{(0)}=-\frac{\sqrt{2\pi}}{\sqrt{R}}\frac{1}{\ln(R/(R+\varepsilon))} \tag*{(46)} C 0 ( 0 ) = − R 2 π ln ( R / ( R + ε )) 1 (46)
π 0 = J ~ 0 ( 0 ∣ r 0 ) = ln ( R / r 0 ) ln ( R / ( R + ε ) ) (47) \pi_0=\widetilde{J}_0(0|r_0)=\frac{\ln(R/r_0)}{\ln(R/(R+\varepsilon))} \tag*{(47)} π 0 = J 0 ( 0∣ r 0 ) = ln ( R / ( R + ε )) ln ( R / r 0 ) (47)
that determine ρ ( ℓ ∣ r 0 ) \rho(\ell|r_0) ρ ( ℓ ∣ r 0 ) via Eq. (28) . Finally, the mean escape time is given by
⟨ τ 0 ⟩ = 1 4 D ( ( R + ε ) 2 − r 0 2 + R 2 − r 0 2 ln ( R / r 0 ) − ( R + ε ) 2 − R 2 ln ( 1 + ε / R ) ) (48) \langle\tau_0\rangle=\frac{1}{4D}\left((R+\varepsilon)^2-r_0^2+\frac{R^2-r_0^2}{\ln(R/r_0)}-\frac{(R+\varepsilon)^2-R^2}{\ln(1+\varepsilon/R)}\right) \tag*{(48)} ⟨ τ 0 ⟩ = 4 D 1 ( ( R + ε ) 2 − r 0 2 + ln ( R / r 0 ) R 2 − r 0 2 − ln ( 1 + ε / R ) ( R + ε ) 2 − R 2 ) (48)
whereas ⟨ τ ℓ ⟩ \langle\tau_\ell\rangle ⟨ τ ℓ ⟩ is still determined by Eq. (37) , in which
( ∂ p μ 0 ( p ) ) p = 0 = − R 1 − ( 1 + ε / R ) 2 + 2 ln ( 1 + ε / R ) ( ln ( 1 + ε / R ) + 1 ) 4 D ln 2 ( 1 + ε / R ) (49) (\partial_p\mu_0^{(p)})_{p=0}=-R\frac{1-(1+\varepsilon/R)^2+2\ln(1+\varepsilon/R)(\ln(1+\varepsilon/R)+1)}{4D\ln^2(1+\varepsilon/R)} \tag*{(49)} ( ∂ p μ 0 ( p ) ) p = 0 = − R 4 D ln 2 ( 1 + ε / R ) 1 − ( 1 + ε / R ) 2 + 2 ln ( 1 + ε / R ) ( ln ( 1 + ε / R ) + 1 ) (49)
and
( ∂ p V 0 ( p ) ( r 0 ) C 0 ( p ) ) p = 0 = 1 4 D R ln 3 ( R / ( R + ε ) ) ( ( 2 R 2 + ( R + ε ) 2 − r 0 2 ) ln ( r 0 / ( R + ε ) ) ln ( R / ( R + ε ) ) + 2 ( R 2 − ( R + ε ) 2 ) ln ( R / r 0 ) − ( 2 R 2 − ( R + ε ) 2 − r 0 2 ) ln ( R / ( R + ε ) ) ) . (50) (\partial_p V_0^{(p)}(r_0)C_0^{(p)})_{p=0}=\frac{1}{4DR\ln^3(R/(R+\varepsilon))}\left((2R^2+(R+\varepsilon)^2-r_0^2)\ln(r_0/(R+\varepsilon))\ln(R/(R+\varepsilon))+2(R^2-(R+\varepsilon)^2)\ln(R/r_0)-(2R^2-(R+\varepsilon)^2-r_0^2)\ln(R/(R+\varepsilon))\right). \tag*{(50)} ( ∂ p V 0 ( p ) ( r 0 ) C 0 ( p ) ) p = 0 = 4 D R ln 3 ( R / ( R + ε )) 1 ( ( 2 R 2 + ( R + ε ) 2 − r 0 2 ) ln ( r 0 / ( R + ε )) ln ( R / ( R + ε )) + 2 ( R 2 − ( R + ε ) 2 ) ln ( R / r 0 ) − ( 2 R 2 − ( R + ε ) 2 − r 0 2 ) ln ( R / ( R + ε )) ) . (50)
Convex boundary in three dimensions
A natural extension of the above analysis to the three-dimensional case would consist in approximating a smooth boundary with two radii of curvature by an ellipsoidal or hyperboloidal layer. Unfortunately, there is no explicit representation of the joint probability density of ℓ τ \ell_\tau ℓ τ and τ \tau τ in these cases. We therefore restrict the discussion to the particular setting, in which the smooth boundary can be locally approximated by a sphere of radius R R R (i.e. two radii of curvature are equal). In this case, the extension is straightforward, while the resulting formulas are actually simpler than in two dimensions.
A convex boundary is approximated by a spherical shell Ω ε = { x ∈ R 3 : R − ε < ∣ x ∣ < R } \Omega_\varepsilon= \{x \in\mathbb{R}^3 : R-\varepsilon< |x| < R\} Ω ε = { x ∈ R 3 : R − ε < ∣ x ∣ < R } with the absorbing inner sphere Γ ε = { x ∈ R 3 : ∣ x ∣ = R − ε } \Gamma_\varepsilon= \{x \in\mathbb{R}^3 : |x| = R-\varepsilon\} Γ ε = { x ∈ R 3 : ∣ x ∣ = R − ε } . In this case, the modified Bessel functions I ν ( z ) I_\nu(z) I ν ( z ) and K ν ( z ) K_\nu(z) K ν ( z ) are replaced by the modified spherical Bessel functions i ν ( z ) i_\nu(z) i ν ( z ) and k ν ( z ) k_\nu(z) k ν ( z ) , which admit simple expressions. Skipping technical steps, we get
V 0 ( p ) ( r 0 ) = sinh ( α ( r 0 − R + ε ) ) 4 π r 0 sinh ( α ε ) , (51) V_0^{(p)}(r_0) = \frac{\sinh\left(\alpha(r_0-R+\varepsilon)\right)}{\sqrt{4\pi}r_0\sinh(\alpha\varepsilon)}, \tag*{(51)} V 0 ( p ) ( r 0 ) = 4 π r 0 sinh ( α ε ) sinh ( α ( r 0 − R + ε ) ) , (51)
μ 0 ( p ) = α ctanh ( α ε ) − 1 R , (52) \mu_0^{(p)} = \alpha\operatorname{ctanh}(\alpha\varepsilon)-\frac{1}{R}, \tag*{(52)} μ 0 ( p ) = α ctanh ( α ε ) − R 1 , (52)
C 0 ( p ) = 4 π α ( R − ε ) sinh ( α ε ) , (53) C_0^{(p)} = \frac{\sqrt{4\pi}\alpha(R-\varepsilon)}{\sinh(\alpha\varepsilon)}, \tag*{(53)} C 0 ( p ) = sinh ( α ε ) 4 π α ( R − ε ) , (53)
J ~ 0 ( p ∣ r 0 ) = ( R − ε ) sinh ( α ( R − r 0 ) ) r 0 sinh ( α ε ) . (54) \widetilde{J}_0(p|r_0) = \frac{(R-\varepsilon)\sinh\left(\alpha(R-r_0)\right)}{r_0\sinh(\alpha\varepsilon)}. \tag*{(54)} J 0 ( p ∣ r 0 ) = r 0 sinh ( α ε ) ( R − ε ) sinh ( α ( R − r 0 ) ) . (54)
while their limits as p → 0 p \to0 p → 0 are
V 0 ( 0 ) ( r 0 ) = r 0 − R + ε 4 π r 0 ε , (55) V_0^{(0)}(r_0) = \frac{r_0-R+\varepsilon}{\sqrt{4\pi}r_0\varepsilon}, \tag*{(55)} V 0 ( 0 ) ( r 0 ) = 4 π r 0 ε r 0 − R + ε , (55)
μ 0 ( 0 ) = 1 ε − 1 R , (56) \mu_0^{(0)} = \frac{1}{\varepsilon}-\frac{1}{R}, \tag*{(56)} μ 0 ( 0 ) = ε 1 − R 1 , (56)
C 0 ( 0 ) = 4 π ( R − ε ) ε , (57) C_0^{(0)} = \frac{\sqrt{4\pi}(R-\varepsilon)}{\varepsilon}, \tag*{(57)} C 0 ( 0 ) = ε 4 π ( R − ε ) , (57)
π 0 = J ~ 0 ( 0 ∣ r 0 ) = ( R − ε ) ( R − r 0 ) ε r 0 . (58) \pi_0 = \widetilde{J}_0(0|r_0) = \frac{(R-\varepsilon)(R-r_0)}{\varepsilon r_0}. \tag*{(58)} π 0 = J 0 ( 0∣ r 0 ) = ε r 0 ( R − ε ) ( R − r 0 ) . (58)
As a consequence, one can easily evaluate the mean escape times:
⟨ τ 0 ⟩ = ε 2 − ( R − r 0 ) 2 6 D , (59) \langle\tau_0\rangle= \frac{\varepsilon^2-(R-r_0)^2}{6D}, \tag*{(59)} ⟨ τ 0 ⟩ = 6 D ε 2 − ( R − r 0 ) 2 , (59)
⟨ τ ℓ ⟩ = 2 ℓ ε + 2 ε 2 − ( r 0 − R + ε ) 2 6 D . (60) \langle\tau_\ell\rangle= \frac{2\ell\varepsilon+2\varepsilon^2-(r_0-R+\varepsilon)^2}{6D}. \tag*{(60)} ⟨ τ ℓ ⟩ = 6 D 2 ℓ ε + 2 ε 2 − ( r 0 − R + ε ) 2 . (60)
Setting y 0 = R − r 0 y_0=R-r_0 y 0 = R − r 0 as the distance to the boundary, one retrieves Eqs. (19) , (21) for the flat case. As previously, one first employs the splitting probability π 0 \pi_0 π 0 to choose between two options, generates the boundary local time ℓ τ \ell_\tau ℓ τ , and uses the mean escape time. The escape position can be either generated, or replaced by its mean value, which by symmetry is ( R − ε , θ 0 , ϕ 0 ) (R-\varepsilon,\theta_0,\phi_0) ( R − ε , θ 0 , ϕ 0 ) in spherical coordinates, where θ 0 \theta_0 θ 0 and ϕ 0 \phi_0 ϕ 0 are the angular coordinates of the starting position x k \boldsymbol{x}_k x k .
Concave boundary in three dimensions
A concave boundary is approximated by a spherical shell Ω ε = { x ∈ R 3 : R < ∣ x ∣ < R + ε } \Omega_\varepsilon= \{x \in\mathbb{R}^3 : R < |x| < R + \varepsilon\} Ω ε = { x ∈ R 3 : R < ∣ x ∣ < R + ε } with the absorbing outer sphere Γ ε = { x ∈ R 3 : ∣ x ∣ = R + ε } \Gamma_\varepsilon= \{x \in\mathbb{R}^3 : |x| = R + \varepsilon\} Γ ε = { x ∈ R 3 : ∣ x ∣ = R + ε } . One has
V 0 ( p ) ( r 0 ) = sinh ( α ( R − r 0 + ε ) ) 4 π r 0 sinh ( α ε ) , (61) V_0^{(p)}(r_0) = \frac{\sinh(\alpha(R-r_0+\varepsilon))}{\sqrt{4\pi}r_0\sinh(\alpha\varepsilon)}, \tag*{(61)} V 0 ( p ) ( r 0 ) = 4 π r 0 sinh ( α ε ) sinh ( α ( R − r 0 + ε )) , (61)
μ 0 ( p ) = α ctanh ( α ε ) + 1 R , (62) \mu_0^{(p)} = \alpha\operatorname{ctanh}(\alpha\varepsilon) + \frac{1}{R}, \tag*{(62)} μ 0 ( p ) = α ctanh ( α ε ) + R 1 , (62)
C 0 ( p ) = 4 π α ( R + ε ) sinh ( α ε ) , (63) C_0^{(p)} = \frac{\sqrt{4\pi}\alpha(R+\varepsilon)}{\sinh(\alpha\varepsilon)}, \tag*{(63)} C 0 ( p ) = sinh ( α ε ) 4 π α ( R + ε ) , (63)
J ~ 0 ( p ∣ r 0 ) = ( R + ε ) sinh ( α ( r 0 − R ) ) r 0 sinh ( α ε ) , (64) \widetilde{J}_0(p|r_0) = \frac{(R+\varepsilon)\sinh(\alpha(r_0-R))}{r_0\sinh(\alpha\varepsilon)}, \tag*{(64)} J 0 ( p ∣ r 0 ) = r 0 sinh ( α ε ) ( R + ε ) sinh ( α ( r 0 − R )) , (64)
and
V 0 ( 0 ) ( r 0 ) = R − r 0 + ε 4 π r 0 ε , (65) V_0^{(0)}(r_0) = \frac{R-r_0+\varepsilon}{\sqrt{4\pi}r_0\varepsilon}, \tag*{(65)} V 0 ( 0 ) ( r 0 ) = 4 π r 0 ε R − r 0 + ε , (65)
μ 0 ( 0 ) = 1 ε + 1 R , (66) \mu_0^{(0)} = \frac{1}{\varepsilon}+\frac{1}{R}, \tag*{(66)} μ 0 ( 0 ) = ε 1 + R 1 , (66)
C 0 ( 0 ) = 4 π ( R + ε ) ε , (67) C_0^{(0)} = \frac{\sqrt{4\pi}(R+\varepsilon)}{\varepsilon}, \tag*{(67)} C 0 ( 0 ) = ε 4 π ( R + ε ) , (67)
π 0 = J ~ 0 ( 0 ∣ r 0 ) = ( R + ε ) ( r 0 − R ) ε r 0 . (68) \pi_0 = \widetilde{J}_0(0|r_0) = \frac{(R+\varepsilon)(r_0-R)}{\varepsilon r_0}. \tag*{(68)} π 0 = J 0 ( 0∣ r 0 ) = ε r 0 ( R + ε ) ( r 0 − R ) . (68)
As a consequence, one can easily evaluate the mean escape times:
⟨ τ 0 ⟩ = ε 2 − ( r 0 − R ) 2 6 D , (69) \langle\tau_0\rangle= \frac{\varepsilon^2-(r_0-R)^2}{6D}, \tag*{(69)} ⟨ τ 0 ⟩ = 6 D ε 2 − ( r 0 − R ) 2 , (69)
⟨ τ ℓ ⟩ = 2 ℓ ε + 2 ε 2 − ( R − r 0 + ε ) 2 6 D . (70) \langle\tau_\ell\rangle= \frac{2\ell\varepsilon+2\varepsilon^2-(R-r_0+\varepsilon)^2}{6D}. \tag*{(70)} ⟨ τ ℓ ⟩ = 6 D 2 ℓ ε + 2 ε 2 − ( R − r 0 + ε ) 2 . (70)
Setting y 0 = r 0 − R y_0=r_0-R y 0 = r 0 − R as the distance to the boundary, one retrieves Eqs. (19) , (21) for the flat case.
Stopping conditions
In the conventional setting of domains with an absorbing boundary, the simulation was stopped upon the first arrival into the boundary layer of width ε \varepsilon ε . In turn, as we deal with reflected Brownian motion, the simulation would never stop without imposing a suitable stopping condition. In many applications, one employs one of the three conditions (or their combinations):
(i) at a fixed time T T T ;
(ii) at a random stopping time δ \delta δ with a prescribed probability distribution;
(iii) at a random time T \mathcal{T} T when the boundary local time ℓ t \ell_t ℓ t exceeds a fixed or random threshold ℓ ^ \hat{\ell} ℓ ^ with a prescribed probability distribution.
The first stopping condition allows one to characterize the diffusive dynamics in a confining domain Ω \Omega Ω , i.e., the position X T X_T X T and the boundary local time ℓ T \ell_T ℓ T at a given time T T T . In particular, one can obtain the empirical distributions of these quantities, their moments and correlations. The second stopping condition is often employed to simulate “mortal” particles with a finite random lifetime with a given distribution [63 , 64 , 65 ] . The most common choice is the exponential distribution of the stopping time δ \delta δ , P { δ > t } = e − p t \mathbb{P}\{\delta> t\}=e^{-pt} P { δ > t } = e − pt , with p p p being the decay rate or, equivalently, 1 / p 1/p 1/ p being the mean lifetime. Basic examples are nuclear radioactive disintegration, spin relaxation, photobleaching, first-order bulk reactions, etc. In this case, one generates the statistics of the position X δ X_\delta X δ and the acquired boundary local time ℓ δ \ell_\delta ℓ δ until the “death” time δ \delta δ . The third stopping condition was introduced in [52 ] [4] to describe various surface reactions which may occur after a sufficient number (represented by the threshold ℓ ^ \hat{\ell} ℓ ^ ) of failed reaction attempts. In this way, one can generate the statistics of the reaction times T \mathcal{T} T and of the reaction locations X T X_{\mathcal{T}} X T on the boundary. If the threshold ℓ ^ \hat{\ell} ℓ ^ is fixed, the surface reaction is triggered after ℓ ^ / ε \hat{\ell}/\varepsilon ℓ ^ / ε encounters of the diffusing particle with the reactive layer of width ε \varepsilon ε . More generally, the number of required encounters can be drawn from a given distribution. For instance, the most common setting of a constant partial reactivity κ \kappa κ in the Robin boundary condition corresponds to the exponential distribution of the threshold, P { ℓ ^ > ℓ } = e − q ℓ \mathbb{P}\{\hat{\ell}>\ell\}=e^{-q\ell} P { ℓ ^ > ℓ } = e − q ℓ , with q = κ / D q=\kappa/D q = κ / D [4]. In turn, other distributions can account for more sophisticated surface reactions such as activation or passivation of the reactive boundary, or non-Markovian binding [15 , 16 ] . The third stopping condition was also applied to describe permeation across the boundary [17 , 18 , 19 ] .
An accurate implementation of the stopping condition is known to be delicate even for the absorbing boundary, i.e., for the classical WOS algorithm. For instance, if the stopping time T \mathcal{T} T is fixed, the simulation does not actually stop at T \mathcal{T} T but when t k + 1 > T t_{k+1}>\mathcal{T} t k + 1 > T . However, if the last jump between t k t_k t k and t k + 1 t_{k+1} t k + 1 was big, the position X T X_{\mathcal{T}} X T lying inside the large ball B ρ k ( x k ) B_{\rho_k}(x_k) B ρ k ( x k ) can significantly differ from the last generated position X t k + 1 X_{t_{k+1}} X t k + 1 on the sphere ∂ B ρ k ( x k ) \partial B_{\rho_k}(x_k) ∂ B ρ k ( x k ) . To amend this problem, one often employs specific treatment of the last step such as, e.g., generating the random position X T X_{\mathcal{T}} X T for the intermediate time T \mathcal{T} T between t k t_k t k and t k + 1 t_{k+1} t k + 1 from the conditional probability density, an interpolation between X t k X_{t_k} X t k and X t k + 1 X_{t_{k+1}} X t k + 1 , the inclusion of the upper bound on the possible escape time, etc [66 , 67 ] . As this issue is classical, we do not discuss these improvements. In our work, we focus on the statistics of the boundary local time, for which the last step is less critical. Indeed, if the last step (after which the simulation is stopped) is a big jump to the sphere ∂ B ρ k ( x k ) \partial B_{\rho_k}(x_k) ∂ B ρ k ( x k ) , the bulk trajectory inside the ball B ρ k ( x k ) B_{\rho_k}(x_k) B ρ k ( x k ) cannot touch the boundary, so that the boundary local time has not changed during this jump: ℓ t k + 1 = ℓ T = ℓ t k \ell_{t_{k+1}}=\ell_{\mathcal{T}}=\ell_{t_k} ℓ t k + 1 = ℓ T = ℓ t k . In turn, if the last jump is an escape from the boundary layer Ω ε \Omega_\varepsilon Ω ε of width ε \varepsilon ε , the boundary local time can change, but its random increment ℓ ′ \ell' ℓ ′ is typically of the order of ε \varepsilon ε . If the width ε \varepsilon ε is small enough, the induced error of ℓ T \ell_{\mathcal{T}} ℓ T is small due to ℓ t k ≤ ℓ T ≤ ℓ t k + 1 \ell_{t_k}\leq\ell_{\mathcal{T}}\leq\ell_{t_{k+1}} ℓ t k ≤ ℓ T ≤ ℓ t k + 1 . As a consequence, either of these two bounds can be used to approximate ℓ T \ell_{\mathcal{T}} ℓ T (moreover, one can record both ℓ t k \ell_{t_k} ℓ t k and ℓ t k + 1 \ell_{t_{k+1}} ℓ t k + 1 to get lower and upper bounds). Alternatively, one can employ a suitable interpolation between ℓ t k \ell_{t_k} ℓ t k and ℓ t k + 1 \ell_{t_{k+1}} ℓ t k + 1 , e.g., the Skorokhod integral representation of the boundary local time (see Appendix § 10 ) suggests to set
ℓ T = ℓ t k + ( ℓ t k + 1 − ℓ t k ) T − t k t k + 1 − t k . (71) \ell_{\mathcal{T}}=\ell_{t_k}+\left(\ell_{t_{k+1}}-\ell_{t_k}\right)\frac{\sqrt{\mathcal{T}}-\sqrt{t_k}}{\sqrt{t_{k+1}}-\sqrt{t_k}}. \tag*{(71)} ℓ T = ℓ t k + ( ℓ t k + 1 − ℓ t k ) t k + 1 − t k T − t k . (71)
Finally, one can also attempt to derive the conditional probability density of ℓ T \ell_{\mathcal{T}} ℓ T . In the following numerical examples, we employ the simplest approximation by setting ℓ T = ℓ t k + 1 \ell_{\mathcal{T}}=\ell_{t_{k+1}} ℓ T = ℓ t k + 1 .
Implementation of the algorithm
We summarize the main steps of our method by focusing explicitly on domains in two and three dimensions. An extension to higher dimensions is immediately available for FLA; in turn, additional computations would be needed for implementing CLA (not present).
Consider a domain Ω \Omega Ω defined by a function ρ ( x ) \rho(x) ρ ( x ) , which determines the distance from any point x x x to the boundary ∂ Ω \partial\Omega ∂ Ω . Initialize all the parameters: initial position x i n i x_{\mathrm{ini}} x ini , diffusion coefficient D D D , number of particles N N N , width ε \varepsilon ε of the boundary layer, stopping condition, etc. Load the pre-computed data to generate the escape times for the unit disk in 2d, or the unit sphere in 3d (see Appendix § 7 ). For each particle (i = 1 , 2 , … , N i=1,2,\ldots,N i = 1 , 2 , … , N ), run the following simulation.
Initiate x 0 = x i n i x_0=x_{\mathrm{ini}} x 0 = x ini , t 0 = 0 t_0=0 t 0 = 0 , ℓ 0 = 0 \ell_0=0 ℓ 0 = 0 ; for the second stopping condition, generate the random stopping time δ \delta δ (e.g., if δ \delta δ obeys the exponentially distribution, set δ = − ln ( u ) / p \delta=-\ln(u)/p δ = − ln ( u ) / p , where u u u is the uniform random variable on ( 0 , 1 ) (0,1) ( 0 , 1 ) , and p > 0 p>0 p > 0 is a given parameter); for the third stopping condition, generate the random threshold ℓ ^ \hat{\ell} ℓ ^ (e.g., if ℓ ^ \hat{\ell} ℓ ^ obeys the exponentially distribution, set ℓ ^ = − ln ( u ) / q \hat{\ell}=-\ln(u)/q ℓ ^ = − ln ( u ) / q , where u u u is the uniform random variable on ( 0 , 1 ) (0,1) ( 0 , 1 ) , and q > 0 q>0 q > 0 is a given parameter).
At each step k = 0 , 1 , 2 , … k=0,1,2,\ldots k = 0 , 1 , 2 , … , the radius ρ k = ρ ( x k ) \rho_k=\rho(x_k) ρ k = ρ ( x k ) is determined by the current position x k x_k x k .
If ρ k > ε / 2 \rho_k>\varepsilon/2 ρ k > ε /2 , the new position x k + 1 x_{k+1} x k + 1 is generated to be uniformly distributed on ∂ B ρ k ( x k ) \partial B_{\rho_k}(x_k) ∂ B ρ k ( x k ) . In two dimensions, it is the circle of radius ρ k \rho_k ρ k , centered at x k x_k x k , so that
x k + 1 = x k + ρ k cos φ , y k + 1 = y k + ρ k sin φ , (72) \begin{aligned}
x_{k+1}&=x_k+\rho_k\cos\varphi,\\
y_{k+1}&=y_k+\rho_k\sin\varphi, \tag*{(72)}
\end{aligned} x k + 1 y k + 1 = x k + ρ k cos φ , = y k + ρ k sin φ , (72)
where φ \varphi φ is a random variable uniformly distributed in ( 0 , 2 π ) (0,2\pi) ( 0 , 2 π ) . In three dimensions, it is the sphere of radius ρ k \rho_k ρ k , centered at x k \boldsymbol{x}_k x k , so that
x k + 1 = x k + ρ k sin θ cos φ , y k + 1 = y k + ρ k sin θ sin φ , z k + 1 = z k + ρ k cos θ , (73) \begin{aligned}
x_{k+1} &= x_k+\rho_k\sin\theta\cos\varphi,\\
y_{k+1} &= y_k+\rho_k\sin\theta\sin\varphi,\\
z_{k+1} &= z_k+\rho_k\cos\theta, \tag*{(73)}
\end{aligned} x k + 1 y k + 1 z k + 1 = x k + ρ k sin θ cos φ , = y k + ρ k sin θ sin φ , = z k + ρ k cos θ , (73)
where φ \varphi φ is a random variable uniformly distributed in ( 0 , 2 π ) (0,2\pi) ( 0 , 2 π ) , and θ \theta θ is a random variable such that cos θ \cos\theta cos θ is uniformly distributed in ( − 1 , 1 ) (-1,1) ( − 1 , 1 ) .
The diffusion time is incremented by
t k + 1 = t k + ρ k 2 D τ c , (74) t_{k+1}=t_k+\frac{\rho_k^2}{D}\tau_c, \tag*{(74)} t k + 1 = t k + D ρ k 2 τ c , (74)
where τ c \tau_c τ c is the escape time either from the unit disk (in 2d) or from the unit ball (in 3d). This random variable is generated in a standard way (see Appendix § 7 ).
If ρ < ε / 2 \rho<\varepsilon/2 ρ < ε /2 , initiate the escape-from-a-layer event: generate a random variable w w w uniformly distributed in ( 0 , 1 ) (0,1) ( 0 , 1 ) .
If w ∈ ( 0 , π 0 ) w\in(0,\pi_0) w ∈ ( 0 , π 0 ) , the particle escapes the layer without touching the boundary, so that ℓ τ ′ = 0 \ell_\tau'=0 ℓ τ ′ = 0 . We set therefore t k + 1 = t k + ⟨ τ 0 ⟩ t_{k+1}=t_k+\langle\tau_0\rangle t k + 1 = t k + ⟨ τ 0 ⟩ and ℓ t k + 1 = ℓ t k \ell_{t_{k+1}}=\ell_{t_k} ℓ t k + 1 = ℓ t k .
If w ∈ ( π 0 , 1 ) w\in(\pi_0,1) w ∈ ( π 0 , 1 ) , the particle escapes the layer after reflections on the boundary. The boundary local time increases as ℓ t k + 1 = ℓ t k + η / μ 0 ( 0 ) \ell_{t_{k+1}}=\ell_{t_k}+\eta/\mu_0^{(0)} ℓ t k + 1 = ℓ t k + η / μ 0 ( 0 ) , where η \eta η is a standard exponentially random variable, and t k + 1 = t k + ⟨ τ ℓ ⟩ t_{k+1}=t_k+\langle\tau_\ell\rangle t k + 1 = t k + ⟨ τ ℓ ⟩ .
According to different approximations (FLA or CLA), the curvature sign (convex or concave), and space dimension (d = 2 d=2 d = 2 or d = 3 d=3 d = 3 ), π 0 \pi_0 π 0 , ⟨ τ 0 ⟩ \langle\tau_0\rangle ⟨ τ 0 ⟩ , ⟨ τ ℓ ⟩ \langle\tau_\ell\rangle ⟨ τ ℓ ⟩ , and μ 0 ( 0 ) \mu_0^{(0)} μ 0 ( 0 ) are given by equations listed in Table 1 , with R R R being the radius of curvature at the boundary point x b \boldsymbol{x}_b x b closest to x k \boldsymbol{x}_k x k , and r 0 = ∣ R − ρ k ∣ r_0=|R-\rho_k| r 0 = ∣ R − ρ k ∣ . The new position x k + 1 \boldsymbol{x}_{k+1} x k + 1 is located at distance ε \varepsilon ε from the boundary point x b \boldsymbol{x}_b x b .
Table 1. Summary of approximations for the quantities that determine the escape-from-a-layer event.
Check for the stopping condition (t k + 1 > T t_{k+1}>T t k + 1 > T , or t k + 1 > δ t_{k+1}>\delta t k + 1 > δ , or ℓ t k + 1 > ℓ ^ \ell_{t_{k+1}}>\hat{\ell} ℓ t k + 1 > ℓ ^ ): if it is not satisfied, return to step 3; otherwise, stop the simulation and record the boundary local time ℓ t k + 1 \ell_{t_{k+1}} ℓ t k + 1 for this particle.
Repeat the steps 2-4 for N N N particles to get an empirical statistics of boundary local times.
In the above implementation, the escape-from-a-layer event is triggered when the distance to the boundary ρ k \rho_k ρ k is below ε / 2 \varepsilon/2 ε /2 (instead of the earlier discussed condition ρ k < ε \rho_k<\varepsilon ρ k < ε ). This “trick” allows one to eliminate too often immediate returns to the layer after the escape. The choice of the fraction 1 / 2 1/2 1/2 in front of ε \varepsilon ε is somewhat arbitrary, it can be replaced by any number between 0 and 1.
Validation
In order to check the accuracy of the proposed algorithm and the role of its parameters (such as ε \varepsilon ε ), we consider reflected Brownian motion in a bounded domain Ω ⊂ R d \Omega\subset\mathbb{R}^d Ω ⊂ R d started from a fixed point x 0 ∈ Ω \boldsymbol{x}_0\in\Omega x 0 ∈ Ω . The probability density ρ ( ℓ , t ∣ x 0 ) \rho(\ell,t|\boldsymbol{x}_0) ρ ( ℓ , t ∣ x 0 ) of the boundary local time ℓ t \ell_t ℓ t reads in the Laplace domain as [23 ]
ρ ~ ( ℓ , p ∣ x 0 ) = ∫ 0 ∞ d t e − p t ρ ( ℓ , t ∣ x 0 ) = S ~ 0 ( p ∣ x 0 ) δ ( ℓ ) + ∑ k = 0 ∞ e − μ k ( p ) ℓ c k ( p ) ( x 0 ) , (75) \widetilde{\rho}(\ell,p|\boldsymbol{x}_0)=\int_0^\infty\mathrm{d}t\,e^{-pt}\rho(\ell,t|\boldsymbol{x}_0)=\widetilde{S}_0(p|\boldsymbol{x}_0)\delta(\ell)+\sum_{k=0}^{\infty}e^{-\mu_k^{(p)}\ell}c_k^{(p)}(\boldsymbol{x}_0), \tag*{(75)} ρ ( ℓ , p ∣ x 0 ) = ∫ 0 ∞ d t e − pt ρ ( ℓ , t ∣ x 0 ) = S 0 ( p ∣ x 0 ) δ ( ℓ ) + k = 0 ∑ ∞ e − μ k ( p ) ℓ c k ( p ) ( x 0 ) , (75)
where
c k ( p ) ( x 0 ) = [ V k ( p ) ( x 0 ) ] ∗ D ∫ Ω d x V k ( p ) ( x ) (76) c_k^{(p)}(x_0)=\frac{\left[V_k^{(p)}(x_0)\right]^*}{D}\int_{\Omega} dx\,V_k^{(p)}(x) \tag*{(76)} c k ( p ) ( x 0 ) = D [ V k ( p ) ( x 0 ) ] ∗ ∫ Ω d x V k ( p ) ( x ) (76)
and S ~ 0 ( p ∣ x 0 ) \widetilde{S}_0(p|x_0) S 0 ( p ∣ x 0 ) is the Laplace-transformed survival probability in the presence of an absorbing boundary ∂ Ω \partial\Omega ∂ Ω . While S ~ 0 ( p ∣ x 0 ) \widetilde{S}_0(p|x_0) S 0 ( p ∣ x 0 ) , μ k ( p ) \mu_k^{(p)} μ k ( p ) and V k ( p ) ( x ) V_k^{(p)}(x) V k ( p ) ( x ) can be found numerically for a given domain Ω \Omega Ω (e.g., by a finite-element method), the need for the Laplace transform inversion makes the above spectral expansion less suitable for validating Monte Carlo simulations.
To overcome this difficulty, we focus on the boundary local time ℓ δ \ell_\delta ℓ δ , stopped at an exponentially distributed random time δ \delta δ , i.e., P { δ > t } = e − p t P\{\delta>t\}=e^{-pt} P { δ > t } = e − pt , with a given rate p > 0 p>0 p > 0 (the second stopping condition). The probability density of ℓ δ \ell_\delta ℓ δ can be obtained by averaging ℓ t \ell_t ℓ t as
Ψ ( ℓ , p ∣ x 0 ) = ∫ 0 ∞ d t p e − p t ρ ( ℓ , t ∣ x 0 ) = p ρ ~ ( ℓ , p ∣ x 0 ) . (77) \Psi(\ell,p|x_0)=\int_0^\infty dt\;p e^{-pt}\rho(\ell,t|x_0)=p\widetilde{\rho}(\ell,p|x_0). \tag*{(77)} Ψ ( ℓ , p ∣ x 0 ) = ∫ 0 ∞ d t p e − pt ρ ( ℓ , t ∣ x 0 ) = p ρ ( ℓ , p ∣ x 0 ) . (77)
In other words, the statistics of ℓ δ \ell_\delta ℓ δ is directly accessible in the Laplace domain and can thus be obtained without Laplace transform inversion.
We test our approach for six domains shown in Figure 3 . For these domains, we obtain the empirical statistics of ℓ δ \ell_\delta ℓ δ by using FLA and CLA with different ϵ \epsilon ϵ and compare to either exactly known results, or numerical results obtained by a finite-element method [68 ] . We also implemented the Skorokhod integral method (SIM) considered as a benchmark state-of-the-art Monte Carlo technique [55 ] . In Appendix § 10 , we briefly describe the original method as being introduced by Schumm and Bressloff (and referred to as SIM1), and a minor variation of this method (referred to as SIM2). Throughout all cases, we fix D = 1 D=1 D = 1 . The discussion of cases shown in Figure 3 b, 3d, 3e is re-delegated to Appendix E.
Figure 3. Considered examples. (a) Unit disk centered at the origin; the initial point (in red) is located at ( r 0 = 0.5 , φ 0 = 0 ) (r_0=0.5,\varphi_0=0) ( r 0 = 0.5 , φ 0 = 0 ) . (b) Annulus between two concentric circles of radii R = 1 R=1 R = 1 , L = 2 L=2 L = 2 ; the initial point (in red) is located at ( r 0 = 1.5 , φ 0 = 0 ) (r_0=1.5,\varphi_0=0) ( r 0 = 1.5 , φ 0 = 0 ) . (c) Unit disk (R = 1 R=1 R = 1 ) centered at the origin and perforated by ten small circular holes of the same radius R 0 = 0.1 R_0=0.1 R 0 = 0.1 located randomly (their centers are at ( − 0.4167 , 0.4213 ) (-0.4167,0.4213) ( − 0.4167 , 0.4213 ) , ( 0.0973 , 0.6397 ) (0.0973,0.6397) ( 0.0973 , 0.6397 ) , ( 0.6418 , 0.4860 ) (0.6418,0.4860) ( 0.6418 , 0.4860 ) , ( − 0.7173 , 0.0827 ) (-0.7173,0.0827) ( − 0.7173 , 0.0827 ) , ( − 0.2075 , 0.0666 ) (-0.2075,0.0666) ( − 0.2075 , 0.0666 ) , ( 0.1105 , − 0.0605 ) (0.1105,-0.0605) ( 0.1105 , − 0.0605 ) , ( 0.6176 , 0.1071 ) (0.6176,0.1071) ( 0.6176 , 0.1071 ) , ( − 0.5381 , − 0.4460 ) (-0.5381,-0.4460) ( − 0.5381 , − 0.4460 ) , ( − 0.0731 , − 0.5457 ) (-0.0731,-0.5457) ( − 0.0731 , − 0.5457 ) , ( 0.3528 , − 0.5425 ) (0.3528,-0.5425) ( 0.3528 , − 0.5425 ) ); the initial points are: ( R , 0 ) (R,0) ( R , 0 ) , ( 0 , 0 ) (0,0) ( 0 , 0 ) . (d) Unit sphere (R = 1 R=1 R = 1 ) centered at the origin; the initial point (in red) is located at r 0 = 0.5 r_0=0.5 r 0 = 0.5 . (e) Spherical shell between two concentric spheres of radii R = 1 R=1 R = 1 and L = 2 L=2 L = 2 ; the initial point (in red) is located at r 0 = 1.5 r_0=1.5 r 0 = 1.5 . (f) Torus with R = 1.5 R=1.5 R = 1.5 , R 0 = 0.5 R_0=0.5 R 0 = 0.5 ; the initial point (in red) is located at ( 1.5 , 0 , 0 ) (1.5,0,0) ( 1.5 , 0 , 0 ) .
Disk
For a disk of radius R R R (Figure 3 a), the probability density Ψ ( ℓ , p ∣ x 0 ) \Psi(\ell,p|x_0) Ψ ( ℓ , p ∣ x 0 ) is known explicitly [23 , 24 ] :
Ψ ( ℓ , p ∣ x 0 ) = π 0 δ ( ℓ ) + ( 1 − π 0 ) μ 0 ( p ) e − μ 0 ( p ) ℓ . (78) \Psi(\ell,p|x_0)=\pi_0\delta(\ell)+(1-\pi_0)\mu_0^{(p)}e^{-\mu_0^{(p)}\ell}. \tag*{(78)} Ψ ( ℓ , p ∣ x 0 ) = π 0 δ ( ℓ ) + ( 1 − π 0 ) μ 0 ( p ) e − μ 0 ( p ) ℓ . (78)
where α = p / D \alpha= \sqrt{p/D} α = p / D and
μ 0 ( p ) = α I 1 ( α R ) I 0 ( α R ) , (79) \mu_0^{(p)} = \alpha\frac{I_1(\alpha R)}{I_0(\alpha R)}, \tag*{(79)} μ 0 ( p ) = α I 0 ( α R ) I 1 ( α R ) , (79)
π 0 = 1 − I 0 ( α r 0 ) I 0 ( α R ) . (80) \pi_0 = 1 - \frac{I_0(\alpha r_0)}{I_0(\alpha R)}. \tag*{(80)} π 0 = 1 − I 0 ( α R ) I 0 ( α r 0 ) . (80)
Once again, we have a mixture of the Dirac distribution and the exponential distribution. For this distribution, it is easy to compute all the moments of the ℓ δ \ell_\delta ℓ δ , in particular,
⟨ ℓ δ ⟩ = ( 1 − π 0 ) / μ 0 ( p ) , σ 2 = Var { ℓ δ } = ( 1 − π 0 2 ) / ( μ 0 ( p ) ) 2 . (81) \langle\ell_\delta\rangle= (1-\pi_0)/\mu_0^{(p)}, \qquad\sigma^2 = \operatorname{Var}\{\ell_\delta\} = (1-\pi_0^2)/(\mu_0^{(p)})^2. \tag*{(81)} ⟨ ℓ δ ⟩ = ( 1 − π 0 ) / μ 0 ( p ) , σ 2 = Var { ℓ δ } = ( 1 − π 0 2 ) / ( μ 0 ( p ) ) 2 . (81)
We fix p = 1 p = 1 p = 1 and the initial point r 0 = 0.5 r_0 = 0.5 r 0 = 0.5 inside the unit disk (R = 1 R = 1 R = 1 ). As the first test, we compute the empirical mean ⟨ ℓ δ ⟩ e m p \langle\ell_\delta\rangle_{\mathrm{emp}} ⟨ ℓ δ ⟩ emp by using N = 10 6 N = 10^6 N = 1 0 6 particles and evaluate its relative error with respect to ⟨ ℓ δ ⟩ \langle\ell_\delta\rangle ⟨ ℓ δ ⟩ by three methods (SIM, FLA, CLA) and three values of the layer width ε \varepsilon ε . Table 2 presents these results, as well as the CPU time for each simulation (all simulations were run on the same MacBook Pro with 1.4GHz quad-core Intel Core i5 processor and 8GB of 2133MHz LPDDR3 onboard memory). First of all, the three methods have similar CPU times for a given ε \varepsilon ε , the SIM being slightly faster. Importantly, the CPU time grows linearly with 1 / ε 1/\varepsilon 1/ ε for the three methods. This is in sharp contrast to the ln ( 1 / ε ) \ln(1/\varepsilon) ln ( 1/ ε ) scaling of the CPU time for absorbing boundaries. Indeed, according to Eq. (3) , the number of encounters with the boundary layer of width ε \varepsilon ε behaves as ℓ δ / ε \ell_\delta/\varepsilon ℓ δ / ε , requiring on average ⟨ ℓ δ ⟩ / ε \langle\ell_\delta\rangle/\varepsilon ⟨ ℓ δ ⟩ / ε escape events for each simulated trajectory. The expected linear scaling of the CPU time with 1 / ε 1/\varepsilon 1/ ε was the main motivation of our work, which aims at computing the boundary local time faster and more accurately by allowing larger ε \varepsilon ε .
Table 2. Comparison of SIM, FLA and CLA with N = 10 6 N = 10^{6} N = 1 0 6 and different ε \varepsilon ε for the unit disk (Figure 3 a) with p = 1 p = 1 p = 1 and r 0 = 0.5 r_{0} = 0.5 r 0 = 0.5 . The mean and standard deviation of ℓ δ \ell_\delta ℓ δ are ⟨ ℓ δ ⟩ = 1.8817 \langle\ell_\delta\rangle= 1.8817 ⟨ ℓ δ ⟩ = 1.8817 , and σ = 2.2113 \sigma= 2.2113 σ = 2.2113 , so that the relative statistical error is σ ⟨ ℓ δ ⟩ N ≃ 0.12 % \frac{\sigma}{\langle\ell_\delta\rangle\sqrt{N}} \simeq0.12\% ⟨ ℓ δ ⟩ N σ ≃ 0.12% .
Let us now compare the accuracy of the empirical mean computed by three methods. The relative error of the benchmark SIM1 changes from − 7.43 % -7.43\% − 7.43% to − 0.91 % -0.91\% − 0.91% and then to 1.80 % 1.80\% 1.80% as ε \varepsilon ε goes down from 10 − 1 10^{-1} 1 0 − 1 to 10 − 2 10^{-2} 1 0 − 2 and then to 10 − 3 10^{-3} 1 0 − 3 . It seems that there is an “optimal” width layer ε \varepsilon ε that minimizes the error, whereas further decreases of ε \varepsilon ε is counter-productive. Note that a similar trend can be noticed in Figure 3 b of [55 ] , when the relative error of the mean first-passage time is minimal at ε ≃ 0.01 \varepsilon\simeq0.01 ε ≃ 0.01 . Even though such accuracy can be sufficient for some applications, it significantly exceeds the relative statistical error, estimated as σ ⟨ ℓ δ ⟩ N ≃ 0.1 % \frac{\sigma}{\langle\ell_\delta\rangle\sqrt{N}} \simeq0.1\% ⟨ ℓ δ ⟩ N σ ≃ 0.1% . In other words, the relative error cannot be explained by statistical fluctuations (which are present in any finite sample) and thus originates from the employed approximations (e.g., finite ε \varepsilon ε ). The accuracy of our modification (SIM2) is worse for this example.
The situation is very different for the FLA, for which the relative error drops from 4.8 % 4.8\% 4.8% at ε = 10 − 1 \varepsilon= 10^{-1} ε = 1 0 − 1 to 0.1 % 0.1\% 0.1% at ε = 10 − 3 \varepsilon= 10^{-3} ε = 1 0 − 3 . In other words, we managed to reduce the relative error by factor ∼ 20 \sim20 ∼ 20 and to achieve the level of statistical errors by using almost the same CPU time as for the SIM1. The accuracy is further improved by CLA. Even for ε = 10 − 1 \varepsilon= 10^{-1} ε = 1 0 − 1 , the relative error of the empirical mean is 0.5 % 0.5\% 0.5% , i.e., one achieves a two-fold improvement in accuracy by a 7 times faster algorithm, as compared to the SIM1 with ε = 10 − 2 \varepsilon= 10^{-2} ε = 1 0 − 2 . We conclude that the CLA dramatically outperforms two other methods.
The comparison between three methods carries on for the probability density Ψ ( ℓ , p ∣ x 0 ) \Psi(\ell,p|x_0) Ψ ( ℓ , p ∣ x 0 ) of the ℓ δ \ell_\delta ℓ δ . Figure 4 shows the ratio between the empirical probability density obtained from the simulated sample of size N = 10 6 N = 10^6 N = 1 0 6 , and the exact result in Eq. (78) ; in both cases, we exclude the trajectories that never touched the boundary, for which ℓ δ = 0 \ell_\delta= 0 ℓ δ = 0 ; in other words, we compare only regular parts of the probability density. The SIM1 yields a systematic bias in the probability density at large ℓ \ell ℓ , which is attenuated by decreasing ε \varepsilon ε but still present even for ε = 10 − 3 \varepsilon= 10^{-3} ε = 1 0 − 3 (panel (a)). This bias is also present for the FLA at ε = 10 − 1 \varepsilon= 10^{-1} ε = 1 0 − 1 but it is already removed for ε = 10 − 2 \varepsilon= 10^{-2} ε = 1 0 − 2 and ε = 10 − 3 \varepsilon= 10^{-3} ε = 1 0 − 3 . Expectedly, there is no such a bias for the CLA, even at ε = 10 − 1 \varepsilon= 10^{-1} ε = 1 0 − 1 . A larger scatter of points at large ℓ \ell ℓ is a consequence of an insufficient statistics for rare trajectories with large ℓ \ell ℓ . Similar results were obtained for other simple domains such as a circular layer, a sphere, and a spherical shell, see Appendix E. We only mention that our modification SIM2 yields more accurate results in three dimensions than the original method SIM1 (see Appendix § 10 for further discussion).
Figure 4. Ratio Ψ e m p ( ℓ , p ∣ x 0 ) \Psi_{\mathrm{emp}}(\ell,p|x_{0}) Ψ emp ( ℓ , p ∣ x 0 ) over Ψ ( ℓ , p ∣ x 0 ) \Psi(\ell,p|x_{0}) Ψ ( ℓ , p ∣ x 0 ) as a function of ℓ / ⟨ ℓ δ ⟩ \ell/\langle\ell_\delta\rangle ℓ / ⟨ ℓ δ ⟩ for the unit disk (Figure 3 a), with p = 1 p = 1 p = 1 and r 0 = 0.5 r_{0} = 0.5 r 0 = 0.5 . The empirical PDF Ψ e m p \Psi_{\mathrm{emp}} Ψ emp was estimated from N = 10 6 N = 10^{6} N = 1 0 6 simulated values of ℓ δ \ell_\delta ℓ δ by (a) SIM1, (b) FLA, (c) CLA, with different choices of the boundary layer width: ε = 10 − 1 \varepsilon= 10^{-1} ε = 1 0 − 1 (triangles), ε = 10 − 2 \varepsilon= 10^{-2} ε = 1 0 − 2 (circles), and ε = 10 − 3 \varepsilon= 10^{-3} ε = 1 0 − 3 (squares). The trajectories that never touched the boundary and thus yielded ℓ δ = 0 \ell_\delta= 0 ℓ δ = 0 , were excluded.
Random pack of disks in 2D
We proceed the validation by computing the statistics of the boundary local time ℓ δ \ell_\delta ℓ δ of reflected Brownian motion outside a random pack of circular holed (disks) of the same radius R 0 R_0 R 0 , confined by a large circle of radius R R R . The positions of these holes were chosen randomly. In the considered example shown in Figure 3 c, we set R = 1 R = 1 R = 1 , and used 10 small holes of radius R 0 = 0.1 R_0 = 0.1 R 0 = 0.1 . In this setting, the probability density of ℓ δ \ell_\delta ℓ δ is still given by the spectral expansion (75) ; however, there is no explicit formula for the eigenvalues and eigenfunctions of the Steklov problem. We therefore compute them by a finite-element method [68 ] . The spectral expansion was truncated to 21 terms, and the maximal mesh size was 0.005 (244614 triangles). The accuracy of this computation was checked by changing the truncation order and the mesh size. In the following, we consider the probability density Ψ ( ℓ , p ∣ x 0 ) \Psi(\ell,p|x_{0}) Ψ ( ℓ , p ∣ x 0 ) from Eq. (75) as a benchmark solution, to which Monte Carlo simulations of the boundary local time ℓ δ \ell_\delta ℓ δ spent on the outer large circle of radius R R R will be compared with. In turn, the encounters with the circular obstacles were ignored. This choice allows us to illustrate the flexibility of the proposed method, which can access the statistics of encounters with either the whole boundary, or its subsets.
Table 3 summarizes the CPU time, the empirical mean ⟨ ℓ δ ⟩ e m p \langle\ell_\delta\rangle_{\mathrm{emp}} ⟨ ℓ δ ⟩ emp , and its relative error for three methods. As the boundary layer width ε \varepsilon ε should necessarily be (much) smaller than the radius R 0 = 0.1 R_{0} = 0.1 R 0 = 0.1 of circular holes, we provide results only for ε = 10 − 3 \varepsilon= 10^{-3} ε = 1 0 − 3 . The conclusions on the comparison between three methods are quite similar to those for the unit disk: while the CPUs of three methods are comparable, the FLA and especially CLA provide much more accurate results. Figure 5 shows the comparison of empirical densities with those derived by the finite-element method, for ε = 10 − 3 \varepsilon= 10^{-3} ε = 1 0 − 3 . As previously, the SIM1 yields a bias (which is consistent with the 2% relative error in the mean), whereas both FLA and CLA are not biased.
Table 3. Comparison of SIM, FLA, CLA with N = 10 6 N = 10^{6} N = 1 0 6 and ε = 10 − 3 \varepsilon= 10^{-3} ε = 1 0 − 3 for the unit disk perforated by 10 circular holes (Figure 3 c) with p = 1 p = 1 p = 1 and R 0 = 0.1 R_{0} = 0.1 R 0 = 0.1 . The “reference” mean value ⟨ ℓ σ ⟩ \langle\ell_\sigma\rangle ⟨ ℓ σ ⟩ was computed from the spectral expansion (75) whose elements being obtained by a finite-element method [68 ] : ⟨ ℓ δ ⟩ = 2.4783 \langle\ell_\delta\rangle= 2.4783 ⟨ ℓ δ ⟩ = 2.4783 for x 0 = ( 1 , 0 ) x_{0} = (1,0) x 0 = ( 1 , 0 ) ; ⟨ ℓ δ ⟩ = 1.9400 \langle\ell_\delta\rangle= 1.9400 ⟨ ℓ δ ⟩ = 1.9400 for x 0 = ( 0 , 0 ) x_{0} = (0,0) x 0 = ( 0 , 0 ) .
Figure 5. Ratio Ψ e m p ( ℓ , p ∣ x 0 ) \Psi_{\mathrm{emp}}(\ell,p\mid x_0) Ψ emp ( ℓ , p ∣ x 0 ) over Ψ ( ℓ , p ∣ x 0 ) \Psi(\ell,p\mid x_0) Ψ ( ℓ , p ∣ x 0 ) (obtained from the finite-element method) as a function of ℓ / ⟨ ℓ δ ⟩ \ell/\langle\ell_\delta\rangle ℓ / ⟨ ℓ δ ⟩ for the unit disk perforated by 10 circular holes (Figure 3 c), with p = 1 p=1 p = 1 , R 0 = 0.1 R_0=0.1 R 0 = 0.1 , and the boundary layer width ε = 10 − 3 \varepsilon=10^{-3} ε = 1 0 − 3 . The empirical PDF Ψ e m p \Psi_{\mathrm{emp}} Ψ emp was estimated from N = 10 6 N=10^6 N = 1 0 6 simulated values of ℓ δ \ell_\delta ℓ δ for different starting points: (a) x 0 = ( 1 , 0 ) x_0=(1,0) x 0 = ( 1 , 0 ) , (b) x 0 = ( 0 , 0 ) x_0=(0,0) x 0 = ( 0 , 0 ) , with different Monte Carlo methods: SIM1 (triangles), FLA (circles), and CLA (squares). The trajectories that never touched the boundary and thus yielded ℓ δ = 0 \ell_\delta=0 ℓ δ = 0 , were excluded.
Torus
As the last example, we consider a torus in three dimensions, which can be parameterized as:
{ x ( θ , φ ) = ( R + R 0 cos θ ) cos φ , y ( θ , φ ) = ( R + R 0 cos θ ) sin φ , z ( θ , φ ) = R 0 sin θ , (82) \begin{cases}
x(\theta,\varphi)=(R+R_0\cos\theta)\cos\varphi,\\
y(\theta,\varphi)=(R+R_0\cos\theta)\sin\varphi,\\
z(\theta,\varphi)=R_0\sin\theta, \tag*{(82)}
\end{cases} ⎩ ⎨ ⎧ x ( θ , φ ) = ( R + R 0 cos θ ) cos φ , y ( θ , φ ) = ( R + R 0 cos θ ) sin φ , z ( θ , φ ) = R 0 sin θ , (82)
using angular coordinates θ , φ ∈ [ 0 , 2 π ) \theta,\varphi\in[0,2\pi) θ , φ ∈ [ 0 , 2 π ) , where the minor radius R 0 R_0 R 0 is the radius of the tube, and the major radius R R R is the distance between the center of the tube and the center of the torus. We select the torus with R = 1.5 R=1.5 R = 1.5 and R 0 = 0.5 R_0=0.5 R 0 = 0.5 (Figure 3 f), and set p = 1 p=1 p = 1 . For this domain, we compute the eigenvalues and eigenfunctions of the Steklov problem by a finite-element method (adapted for axisymmetric three-dimensional problems) [68 ] . The spectral expansion ((75) ) is truncated to 4 terms, and the maximal mesh size was 0.005 (75314 triangles). This benchmark solution is compared to the empirical probability density obtained by Monte Carlo simulations.
As the boundary points on the torus have two different radii of curvature, the CLA is not applicable. We test therefore only the FLA and the SIM. Table 4 compares the empirical means with the “reference” one. In this three-dimensional setting, our modification SIM2 yields more accurate results than the original method SIM1. Curiously, the FLA at ε = 10 − 1 \varepsilon=10^{-1} ε = 1 0 − 1 yields a bigger relative error than the SIM2. However, as ε \varepsilon ε decreases, the relative error of the FLA drops much faster than that of both SIM1 and SIM2. Figure 6 presents the comparison of the PDFs of the boundary local time ℓ δ \ell_\delta ℓ δ , with similar conclusions.
Table 4. Comparison between SIM and FLA with N = 10 6 N=10^6 N = 1 0 6 and different ε \varepsilon ε for the torus (Figure 3 f) with p = 1 p=1 p = 1 , R 0 = 0.5 R_0=0.5 R 0 = 0.5 , R = 1.5 R=1.5 R = 1.5 , and the initial position ( 1.5 , 0 , 0 ) (1.5,0,0) ( 1.5 , 0 , 0 ) . The “reference” mean value ⟨ ℓ σ ⟩ = 3.8748 \langle\ell_\sigma\rangle=3.8748 ⟨ ℓ σ ⟩ = 3.8748 was computed from the spectral expansion ((75) ) whose elements being obtained by a finite-element method [68 ] .
Figure 6. Ratio Ψ e m p ( ℓ , p ∣ x 0 ) \Psi_{\mathrm{emp}}(\ell,p|x_0) Ψ emp ( ℓ , p ∣ x 0 ) over Ψ ( ℓ , p ∣ x 0 ) \Psi(\ell,p|x_0) Ψ ( ℓ , p ∣ x 0 ) (obtained by the finite-element method) as a function of ℓ / ⟨ ℓ δ ⟩ \ell/\langle\ell_\delta\rangle ℓ / ⟨ ℓ δ ⟩ for the torus (Figure 3 f), with p = 1 p=1 p = 1 , R 0 = 0.5 R_0=0.5 R 0 = 0.5 , R = 1.5 R=1.5 R = 1.5 , and the initial point located at ( 1.5 , 0 , 0 ) (1.5,0,0) ( 1.5 , 0 , 0 ) . The empirical PDF Ψ e m p \Psi_{\mathrm{emp}} Ψ emp was estimated from N = 10 6 N=10^6 N = 1 0 6 simulated values of ℓ δ \ell_\delta ℓ δ by (a) SIM1, (b) FLA, with different choices of the boundary layer width: ε = 10 − 1 \varepsilon=10^{-1} ε = 1 0 − 1 (triangles), ε = 10 − 2 \varepsilon=10^{-2} ε = 1 0 − 2 (circles), and ε = 10 − 3 \varepsilon=10^{-3} ε = 1 0 − 3 (squares). The trajectories that never touched the boundary and thus yielded ℓ δ = 0 \ell_\delta=0 ℓ δ = 0 , were excluded.
Discussion and conclusion
In this paper, we proposed an efficient numerical tool to access the statistics of the boundary local time ℓ t \ell_t ℓ t of reflected Brownian motion in Euclidean domains with smooth boundaries. Using the approximate solution of the escape problem for a thin boundary layer, we managed to replace a refined simulation of the random trajectory near the boundary by a single escape from that layer. This step eliminated the most time-consuming part of former Monte Carlo techniques and allowed us to relax the requirement of a too small layer width ε \varepsilon ε that was needed to control the accuracy of the estimated boundary local time. Our implementation of this step employed several approximations: (i) the boundary layer was locally approximated by either a flat layer (FLA), or a curved layer with a known curvature (CLA); (ii) the conditional escape times τ 0 \tau_0 τ 0 and τ ℓ \tau_\ell τ ℓ were replaced by their mean values ⟨ τ 0 ⟩ \langle\tau_0\rangle ⟨ τ 0 ⟩ and ⟨ τ ℓ ⟩ \langle\tau_\ell\rangle ⟨ τ ℓ ⟩ ; (iii) the escape position X τ X^\tau X τ was replaced by its mean value ⟨ X τ ⟩ \langle X^\tau\rangle ⟨ X τ ⟩ ; (iv) the exact stopping condition (e.g., t k + 1 = T t_{k+1}=T t k + 1 = T ) was replaced by a loose condition (e.g., t k + 1 > T t_{k+1}>T t k + 1 > T ). Despite these approximations, both FLA and CLA provided more accurate results than the state-of-the-art SIM under a comparable computational time. Moreover, the CLA was remarkably accurate even at relatively large boundary layer width (e.g., ε / R = 0.1 \varepsilon/R=0.1 ε / R = 0.1 ). Even though the approximations (ii)-(iv) can be further relaxed (see discussions in § 2.5 and Appendix § 8 ), the accuracy of the CLA was high enough to ignore these improvements.
At the same time, the approximation (i) was central to our approach. While the FLA is valid for any Euclidean domain in R d \mathbb{R}^d R d (d ≥ 2 d\geq2 d ≥ 2 ) with a smooth boundary, the applicability of the CLA is more restricted. In fact, it is valid for any planar domain with a smooth boundary, as well as for three-dimensional domains whose smooth boundary can be locally approximated by a sphere (i.e., with two equal radii of curvature). For instance, the CLA was not applicable for a torus that we discussed in § 4.3 . Further investigations of the escape problem from ellipsoidal or even more sophisticated layers, as well as to higher dimensions, present an interesting perspective of this work. Another important research direction is an extension of our approach to domains with angles (like polygons or prefactal domains) or more sophisticated singularities (e.g., cusps). In this case, one can consider escape events from triangular or rectangular regions, in analogy to efficient extensions of the WOS algorithm [39 , 42 ] . For this purpose, one would need to find an approximate solution of the underlying escape problem [58 ] .
As explained in § 1 , the boundary local time plays the central role in the theory of stochastic processes and has numerous applications. First of all, our numerical approach allows one to simulate reflected Brownian motion X t X_t X t and the associated boundary local time ℓ t \ell_t ℓ t in various confinements. For instance, random packs of monodisperse or polydisperse disks or spheres (as an example considered in § 4.2 ) are typical models of porous media in material sciences, chemistry, and biology. In this way, one can compute the statistics of encounters between the diffusing particle and the boundary or a specific region on that boundary (e.g., we considered separately the boundary local times on the inner and outer circles of a circular annulus in Appendix E.§ 1 ). Moreover, one can easily treat more general problems with multiple diffusing particles or/and multiple targets, and access the joint distribution of various boundary local times and their mutual correlations [14 , 69 ] . These quantities help to characterize the competition between particles for a target or the competition between targets for a particle. An extension of this numerical approach for simulating different functionals of the boundary local time presents an interesting perspective [70 ] [7]. From a broader perspective, one can study the boundary local time of a general diffusive process with given drift and covariance matrix [2, 3]. There are numerous Monte Carlo methods for simulating such stochastic processes as Markov chains at small timesteps (see [71 , 72 , 73 , 74 , 75 , 76 , 77 ] and references therein). While these methods can deal with much more general diffusive processes, their implementation in multi-scale media may be computationally prohibited due to small timesteps. However, if an applied potential and the induced drift are localized near the boundary, a combination of the above methods with the WOS algorithm can be beneficial. In this way, one could investigate the effect of the boundary potential (e.g., short-ranged electric attraction or repulsion) onto the boundary local time and the consequent surface reactions.
While the statistics of the boundary local time can be accessed by different numerical methods (e.g., by a finite-element method used in § 4.2 ), Monte Carlo simulations have numerous advantages:
One can directly generate the boundary local time ℓ t \ell_t ℓ t at a fixed time t t t , whereas the methods relying on the spectral expansion (75) are less suitable in time domain, as they would require the inverse Laplace transform. For this reason, we did not look at the probability density function of ℓ t \ell_t ℓ t that will be reported elsewhere.
Monte Carlo techniques are very flexible and can be easily implemented in any dimension; in contrast, an implementation of a finite-element method in dimensions d ≥ 3 d \ge3 d ≥ 3 can be rather sophisticated and very time-consuming.
One can easily treat multiple targets (as the example shown in Figure 3 c) and compute distributions of the boundary local times ℓ t i \ell_t^i ℓ t i on these targets. Such joint distributions are not easily accessible via other methods (see further discussions on multiple targets in [69 ] ).
Potential applications of the proposed method go far beyond the statistics of encounters. For instance, the position X T X_{\mathcal{T}} X T of the process at the stopping time T = inf { t > 0 : ℓ t > ℓ ^ } \mathcal{T}=\inf\{t>0:\ell_t>\hat{\ell}\} T = inf { t > 0 : ℓ t > ℓ ^ } when the boundary local time ℓ t \ell_t ℓ t exceeds a random threshold ℓ ^ \hat{\ell} ℓ ^ , determines the position of the reactive event. The exponential distribution of the threshold, P { ℓ ^ > ℓ } = e − q ℓ \mathbb{P}\{\hat{\ell}>\ell\}=e^{-q\ell} P { ℓ ^ > ℓ } = e − q ℓ , corresponds to the most common case of a constant partial reactivity κ = q D \kappa=qD κ = q D in diffusion-controlled reactions [15 ] . In this case, the distribution of the position X T X_{\mathcal{T}} X T is known as the spread harmonic measure [37 , 78 ] , whereas the stopping time T \mathcal{T} T is called the first-reaction time or the first-passage time to the reaction event [79 , 80 , 81 , 82 , 83 , 84 , 85 ] . Both quantities can be accessed by the proposed method. However, other choices for the threshold distribution allow one to represent more sophisticated surface reactions such as progressive passivation or activation of the reactive boundary by the diffusing particles [4]. Our numerical method allows one to investigate the distribution of the reaction positions and thus to identify the most prolific subsets of the boundary with the highest reaction probability. This information can be further used to address various optimization problems in chemical engineering. From an even more general perspective, as Monte Carlo techniques are often employed to solve partial differential equations, the escape-from-a-layer approach can thus be helpful in treating problems with Neumann and Robin boundary conditions [25 , 26 , 27 , 54 , 66 , 86 , 87 , 88 , 89 , 90 , 91 , 92 ] .
Acknowledgements
D.S.G. acknowledges a partial financial support from the Alexander von Humboldt Foundation through a Bessel Research Award.
Escape time distribution
The WOS algorithm required generation of the random escape time τ c \tau_c τ c from a disk or a ball. As this is a fairly standard procedure (see [93 ] and references therein), we only sketch the main steps. The survival probability of a particle located in the center of the unit disk, S c S_c S c , reads
S c ( t ) = P { τ c > t } = 2 ∑ k = 0 ∞ exp ( − α 0 k 2 t ) α 0 k J 1 ( α 0 k ) . (83) S_c(t)=\mathbb{P}\{\tau_c>t\}=2\sum_{k=0}^{\infty}\frac{\exp(-\alpha_{0k}^{2}t)}{\alpha_{0k}J_1(\alpha_{0k})}. \tag*{(83)} S c ( t ) = P { τ c > t } = 2 k = 0 ∑ ∞ α 0 k J 1 ( α 0 k ) exp ( − α 0 k 2 t ) . (83)
where α 0 k \alpha_{0k} α 0 k refers to the k k k -th zero of the Bessel function J 0 ( x ) J_0(x) J 0 ( x ) of the first kind, and we set D = 1 D=1 D = 1 . In turn, for the unit sphere with a particle located at center, the survival probability is
S c ( t ) = 2 ∑ k = 1 ∞ ( − 1 ) k + 1 e − π 2 k 2 t . (84) S_c(t)=2\sum_{k=1}^{\infty}(-1)^{k+1}e^{-\pi^2 k^2t}. \tag*{(84)} S c ( t ) = 2 k = 1 ∑ ∞ ( − 1 ) k + 1 e − π 2 k 2 t . (84)
Explicit formulas are also known in higher dimensions.
In order to generate the random variable τ c \tau_c τ c , one needs to invert the survival probability, i.e., to find the function T c ( x ) T_c(x) T c ( x ) such that S c [ T c ( x ) ] = x S_c[T_c(x)]=x S c [ T c ( x )] = x , for any x ∈ ( 0 , 1 ) x\in(0,1) x ∈ ( 0 , 1 ) . If η \eta η is uniformly distributed on ( 0 , 1 ) (0,1) ( 0 , 1 ) , then τ c = T c ( η ) \tau_c=T_c(\eta) τ c = T c ( η ) is the escape time. In practice, one can discretize the interval ( 0 , 1 ) (0,1) ( 0 , 1 ) into a sequence of points x k = k / K x_k=k/K x k = k / K , such as k = 1 , 2 , … , K − 1 k=1,2,\ldots,K-1 k = 1 , 2 , … , K − 1 with large enough K K K , solve the equation S c ( t k ) = x k S_c(t_k)=x_k S c ( t k ) = x k for each k k k (e.g. by the bisection method), and set T c ( x k ) = t k T_c(x_k)=t_k T c ( x k ) = t k . Since the survival probability is a smooth, monotonously decreasing function, this computation can be done rapidly even for large K K K . Most importantly, this computation has to be done only once and then the stored values of T c ( x k ) T_c(x_k) T c ( x k ) can be preloaded before running Monte Carlo simulations. Once a uniform random variable η ∈ ( 0 , 1 ) \eta\in(0,1) η ∈ ( 0 , 1 ) is generated, one rapidly gets τ c = T c ( η ) \tau_c=T_c(\eta) τ c = T c ( η ) by interpolation.
In order to be able to accurately generate large escape times, one can rely on the long-time behavior:
S c ( t ) ≃ { 2 α 00 J 1 ( α 00 ) e − α 00 2 t ( d = 2 ) , 2 e − π 2 t ( d = 3 ) . (85) S_c(t)\simeq
\begin{cases}
\frac{2}{\alpha_{00}J_1(\alpha_{00})}e^{-\alpha_{00}^2t} & (d=2),\\
2e^{-\pi^2t} & (d=3).
\end{cases} \tag*{(85)} S c ( t ) ≃ { α 00 J 1 ( α 00 ) 2 e − α 00 2 t 2 e − π 2 t ( d = 2 ) , ( d = 3 ) . (85)
If the random variable η \eta η is below x 1 = 1 / K x_1=1/K x 1 = 1/ K (i.e., τ \tau τ is large), one can use Eq. (A.3) to invert S c ( t ) S_c(t) S c ( t ) at large t t t , yielding an extrapolation relation
τ c = { − 1 α 00 2 ln [ η α 00 J 1 ( α 00 ) 2 ] ( d = 2 ) , − 1 π 2 ln ( η 2 ) ( d = 3 ) . (86) \tau_c=
\begin{cases}
-\frac{1}{\alpha_{00}^2}\ln\left[\frac{\eta\alpha_{00}J_1(\alpha_{00})}{2}\right] & (d=2),\\
-\frac{1}{\pi^2}\ln\left(\frac{\eta}{2}\right) & (d=3).
\end{cases} \tag*{(86)} τ c = { − α 00 2 1 ln [ 2 η α 00 J 1 ( α 00 ) ] − π 2 1 ln ( 2 η ) ( d = 2 ) , ( d = 3 ) . (86)
Replacing τ c \tau_c τ c by ρ 2 D τ c \frac{\rho^2}{D}\tau_c D ρ 2 τ c allows one to get the escape time from a disk or a ball of radius ρ \rho ρ and a given diffusion coefficient D D D .
To skip the above inversion of the survival probability, it is quite common to replace the random escape time τ c \tau_c τ c by its mean value, which is particularly simple for the escape from the center of a ball of radius ρ \rho ρ in R d \mathbb{R}^d R d : ⟨ τ c ⟩ = ρ 2 2 d D \langle\tau_c\rangle=\frac{\rho^2}{2dD} ⟨ τ c ⟩ = 2 d D ρ 2 . However, this simplification can lead to significant errors when the particle starts far from the boundary so that the first jump to a large distance ρ \rho ρ gives a large (fixed) contribution ρ 2 2 d D \frac{\rho^2}{2dD} 2 d D ρ 2 to the time counter (see further discussion in Appendix § 9 ). For this reason, we generated random escape times τ c \tau_c τ c in all simulations of this paper.
Conditional probability density
In this Appendix, we briefly discuss the difficulties in generating conditional escape times and their possible solutions. We focus here on the escape from a flat layer and consider separately two conditional escape times: without hitting the bottom surface and with reflections on it.
The inverse Laplace transform of Eq. (18) yields
H 0 ( t ∣ y 0 ) = 2 π D ε y 0 ∑ k = 1 ∞ ( − 1 ) k − 1 k sin ( k π y 0 ε ) e − D π 2 k 2 t / ε 2 . (87) H_0(t|y_0)=\frac{2\pi D}{\varepsilon y_0}\sum_{k=1}^{\infty}(-1)^{k-1}k\sin\left(\frac{k\pi y_0}{\varepsilon}\right)e^{-D\pi^2k^2t/\varepsilon^2}. \tag*{(87)} H 0 ( t ∣ y 0 ) = ε y 0 2 π D k = 1 ∑ ∞ ( − 1 ) k − 1 k sin ( ε k π y 0 ) e − D π 2 k 2 t / ε 2 . (87)
The survival probability of this random variable,
S 0 ( t ∣ y 0 ) = P y 0 { τ 0 > t } = ∫ t ∞ d t ′ H 0 ( t ′ ∣ y 0 ) = 2 ε π y 0 ∑ k = 1 ∞ ( − 1 ) k − 1 k sin ( k π y 0 ε ) e − D π 2 k 2 t / ε 2 . (88) S_0(t|y_0)=\mathbb{P}_{y_0}\{\tau_0>t\}=\int_t^\infty dt' H_0(t'|y_0)=\frac{2\varepsilon}{\pi y_0}\sum_{k=1}^{\infty}\frac{(-1)^{k-1}}{k}\sin\left(\frac{k\pi y_0}{\varepsilon}\right)e^{-D\pi^2k^2t/\varepsilon^2}. \tag*{(88)} S 0 ( t ∣ y 0 ) = P y 0 { τ 0 > t } = ∫ t ∞ d t ′ H 0 ( t ′ ∣ y 0 ) = π y 0 2 ε k = 1 ∑ ∞ k ( − 1 ) k − 1 sin ( ε k π y 0 ) e − D π 2 k 2 t / ε 2 . (88)
can be numerically inverted to generate the conditional escape time τ 0 \tau_0 τ 0 (see Appendix § 7 for a similar procedure for a disk). However, the main practical difficulty is that this survival probability depends on y 0 / ε y_0/\varepsilon y 0 / ε so that its inversion may be quite costly.
The situation is much more difficult for the second conditional escape time τ ℓ \tau_\ell τ ℓ , whose moment-generating function is given by Eq. (20) . There are two technical difficulties to perform its inverse Laplace transform: first, there is no simple explicit representation for this inversion (see, however, some related representations derived in [69 ] ); second, there are three parameters, t t t , y 0 y_0 y 0 and ℓ \ell ℓ , that determine this probability density. As a consequence, a direct computation of this quantity for the whole set of parameters could be problematic.
To partly overcome the second difficulty, one can employ the following simplification. The expression in Eq. (20) can be written as
H ~ ( p ∣ y 0 , ℓ ) = ε sinh ( p / D ( ε − y 0 ) ) ( ε − y 0 ) sinh ( p / D ε ) H ~ ( p ∣ 0 , ℓ ) . (89) \widetilde{H}(p|y_0,\ell) = \frac{\varepsilon\sinh\left(\sqrt{p/D}(\varepsilon-y_0)\right)}{(\varepsilon-y_0)\sinh\left(\sqrt{p/D}\varepsilon\right)}\widetilde{H}(p|0,\ell). \tag*{(89)} H ( p ∣ y 0 , ℓ ) = ( ε − y 0 ) sinh ( p / D ε ) ε sinh ( p / D ( ε − y 0 ) ) H ( p ∣0 , ℓ ) . (89)
The first factor is the Laplace transform of the probability density of the escape time, conditioned to the escape through the endpoint 0, which is actually equal to H 0 ( t ∣ ε − y 0 ) H_0(t|\varepsilon-y_0) H 0 ( t ∣ ε − y 0 ) due to the symmetry. In turn, the second factor is the Laplace transform of the conditional probability density H ( t ∣ 0 , ℓ ) H(t|0,\ell) H ( t ∣0 , ℓ ) when the starting point is at 0. The product of these factors indicates that the escape time τ ℓ \tau_\ell τ ℓ can be written as the sum of two independent random times: the time τ 1 \tau_1 τ 1 to reach the endpoint 0 and the time τ 2 \tau_2 τ 2 to cross the interval ( 0 , ε ) (0,\varepsilon) ( 0 , ε ) and to escape through the endpoint ε \varepsilon ε . The probability density of the latter time is then determined by the inverse Laplace transform:
H ( t ∣ 0 , ℓ ) = L − 1 { H ~ ( p ∣ 0 , ℓ ) } = L − 1 { ε p / D sinh ( p / D ε ) e − ℓ ( p / D coth ( p / D ε ) − 1 / ε ) } . (90) H(t|0,\ell)=\mathcal{L}^{-1}\left\{\widetilde{H}(p|0,\ell)\right\}=\mathcal{L}^{-1}\left\{\frac{\varepsilon\sqrt{p/D}}{\sinh\left(\sqrt{p/D}\varepsilon\right)}e^{-\ell\left(\sqrt{p/D}\coth\left(\sqrt{p/D}\varepsilon\right)-1/\varepsilon\right)}\right\}. \tag*{(90)} H ( t ∣0 , ℓ ) = L − 1 { H ( p ∣0 , ℓ ) } = L − 1 ⎩ ⎨ ⎧ sinh ( p / D ε ) ε p / D e − ℓ ( p / D c o t h ( p / D ε ) − 1/ ε ) ⎭ ⎬ ⎫ . (90)
Even though this inverse Laplace transform needs to be computed numerically, it does not depend on y 0 y_0 y 0 that simplifies its practical implementation. In the same way, one can compute the related survival probability:
S ( t ∣ 0 , ℓ ) = 1 − L − 1 { H ~ ( p ∣ 0 , ℓ ) p } = 1 − L − 1 { ε p / D p sinh ( p / D ε ) e − ℓ ( p / D coth ( p / D ε ) − 1 / ε ) } . (91) S(t|0,\ell)=1-\mathcal{L}^{-1}\left\{\frac{\widetilde{H}(p|0,\ell)}{p}\right\}=1-\mathcal{L}^{-1}\left\{\frac{\varepsilon\sqrt{p/D}}{p\sinh\left(\sqrt{p/D}\varepsilon\right)}e^{-\ell\left(\sqrt{p/D}\coth\left(\sqrt{p/D}\varepsilon\right)-1/\varepsilon\right)}\right\}. \tag*{(91)} S ( t ∣0 , ℓ ) = 1 − L − 1 { p H ( p ∣0 , ℓ ) } = 1 − L − 1 ⎩ ⎨ ⎧ p sinh ( p / D ε ) ε p / D e − ℓ ( p / D c o t h ( p / D ε ) − 1/ ε ) ⎭ ⎬ ⎫ . (91)
To avoid technical issues with Laplace transform inversion, we did not use these exact representations and replaced the random variables τ 0 \tau_0 τ 0 and τ ℓ \tau_\ell τ ℓ by their mean values, which were computed explicitly.
Justification of the approximation by means
One practically relevant approximation consists in replacing random escape times by their mean values. At a first thought, this approximation may sound rather crude. While a rigorous analysis of the accuracy of this approximation is beyond the scope of the manuscript, we provide some qualitative arguments and rationales.
To convey the idea, we consider a simpler, slightly different problem of estimating the first-passage time T T T to an absorbing boundary and assume that a random trajectory is simulated by generating a sequence of spheres of the same radius ρ \rho ρ . In other words, one draws a sphere of radius ρ \rho ρ centered at the starting position and moves the particle to a random point on that sphere. The escape time from the sphere, τ \tau τ , is a random variable, with explicitly known distribution (see Appendix § 7 ). The process is repeated again and again, until the newly drawn ( n + 1 ) (n+1) ( n + 1 ) th sphere crosses the boundary; the number n n n of generated spheres is thus also a random variable. The first-passage time T T T to the boundary is then estimated by summing independent random escape times generated until hitting the boundary: T = τ 1 + τ 2 + ⋯ + τ n T=\tau_1+\tau_2+\cdots+\tau_n T = τ 1 + τ 2 + ⋯ + τ n . In turn, the approximation consists in replacing random variables τ 1 , τ 2 , … , τ n \tau_1,\tau_2,\ldots,\tau_n τ 1 , τ 2 , … , τ n by their means, ⟨ τ ⟩ = ρ 2 / ( 6 D ) \langle\tau\rangle=\rho^2/(6D) ⟨ τ ⟩ = ρ 2 / ( 6 D ) , i.e., T a p p = n ⟨ τ ⟩ = n ρ 2 / ( 6 D ) T_{\mathrm{app}}=n\langle\tau\rangle=n\rho^2/(6D) T app = n ⟨ τ ⟩ = n ρ 2 / ( 6 D ) . While this approximation yields the correct mean FPT, ⟨ T ⟩ = ⟨ n ⟩ ⟨ τ ⟩ = ⟨ T a p p ⟩ \langle T\rangle=\langle n\rangle\langle\tau\rangle=\langle T_{\mathrm{app}}\rangle ⟨ T ⟩ = ⟨ n ⟩ ⟨ τ ⟩ = ⟨ T app ⟩ , the distributions of T T T and T a p p T_{\mathrm{app}} T app are different. How accurately can the distribution of T a p p T_{\mathrm{app}} T app approximate that of T T T ?
To estimate the error of this approximation, let us compute the variance of T T T . A straightforward computation gives:
Var { T } = ⟨ n ⟩ Var { τ } + Var { n } ⟨ τ ⟩ 2 . (92) \operatorname{Var}\{T\}=\langle n\rangle\operatorname{Var}\{\tau\}+\operatorname{Var}\{n\}\langle\tau\rangle^2. \tag*{(92)} Var { T } = ⟨ n ⟩ Var { τ } + Var { n } ⟨ τ ⟩ 2 . (92)
Figure D.7. Illustration of the reflection on a circular boundary. When a particle (red dot) is inside the boundary layer (light orange) of width ε \varepsilon ε , one draws a circle of radius ρ = 2 ε \rho= 2\varepsilon ρ = 2 ε and generates a random position on it. If this position (green dot) turns out to be outside the domain, the final position (blue dot) is either attached on the boundary along the normal direction (violet dashed line) in SIM1 (a), or obtained by a mirror reflection along the normal direction (violet dashed line) in SIM2 (b).
As the approximation replaces random variables τ 1 , τ 2 , … , τ n \tau_1, \tau_2, \ldots, \tau_n τ 1 , τ 2 , … , τ n by their means, the variance of the approximated first-passage time is Var { T a p p } = Var { n } ⟨ τ ⟩ 2 \operatorname{Var}\{T_{\mathrm{app}}\} = \operatorname{Var}\{n\}\langle\tau\rangle^2 Var { T app } = Var { n } ⟨ τ ⟩ 2 , i.e., it ignores the variance of τ \tau τ (the first term in Eq. (C.1)). We conclude that the proposed approximation always underestimates the variance of the first-passage time.
However, in many practical cases, the second term in Eq. (C.1) is dominant so that Var { T } ≈ Var { T a p p } \operatorname{Var}\{T\} \approx\operatorname{Var}\{T_{\mathrm{app}}\} Var { T } ≈ Var { T app } , suggesting that the approximation can be accurate. Indeed, the variance of the escape time from a sphere, Var { τ } \operatorname{Var}\{\tau\} Var { τ } , can be found explicitly; but even without an exact computation, it must be proportional to ( ρ 2 / D ) 2 (\rho^2/D)^2 ( ρ 2 / D ) 2 from dimensional analysis, and thus to ⟨ τ ⟩ 2 \langle\tau\rangle^2 ⟨ τ ⟩ 2 . Moreover, the variance of the FPT is also generally proportional to the square of its mean, Var { T } ∼ ⟨ T ⟩ 2 \operatorname{Var}\{T\} \sim\langle T\rangle^2 Var { T } ∼ ⟨ T ⟩ 2 , i.e., Eq. (C.1) reads as ⟨ n ⟩ 2 ∼ ⟨ n ⟩ + Var { n } \langle n\rangle^2 \sim\langle n\rangle+ \operatorname{Var}\{n\} ⟨ n ⟩ 2 ∼ ⟨ n ⟩ + Var { n } . If the mean number of generated spheres, ⟨ n ⟩ \langle n\rangle ⟨ n ⟩ , is large enough, the variance Var { n } \operatorname{Var}\{n\} Var { n } scales as ⟨ n ⟩ 2 \langle n\rangle^2 ⟨ n ⟩ 2 , i.e., the relative contribution of the first term to Eq. (C.1) is of the order of 1 / ⟨ n ⟩ 1/\langle n\rangle 1/ ⟨ n ⟩ and thus can be neglected.
We stress that the above arguments are qualitative and may not be valid in general. For instance, the relation Var { T } ∼ ⟨ T ⟩ 2 \operatorname{Var}\{T\} \sim\langle T\rangle^2 Var { T } ∼ ⟨ T ⟩ 2 may not hold. Moreover, when the radii of generated spheres are not fixed (as in the WOS algorithm), the contribution from few large spheres can be dominant. For this reason, we do not apply the approximation to simulate Brownian motion in the bulk, i.e., when using spheres of variable radii; in this part of the algorithm, we generate random escape times (see Appendix § 7 ). The approximation is only used to simulate the escape from a layer of a fixed small width ε \varepsilon ε .
Skorokhod integral method
For completeness, we briefly recall here the Skorokhod integral method developed in [55 ] . The WOS algorithm is employed until the particle enters the boundary layer of width ε \varepsilon ε . Then, the radius ρ \rho ρ is fixed to be proportional to ε \varepsilon ε : ρ = 2 ε \rho= 2\varepsilon ρ = 2 ε in two dimensions, and ρ = 3 ε \rho= 3\varepsilon ρ = 3 ε in three dimensions. After the jump to the distance ρ \rho ρ , the particle can leave the boundary layer, stay inside it, or exit the domain. In the first case, the WOS algorithm with variable-distance jumps is resumed; in the second case, one makes another jumps with the radius ρ = d ε \rho= d\varepsilon ρ = d ε . In turn, the latter option is treated as a reflection event. The current position generated outside the domain is reflected back with respect to the boundary (Fig. D.7a). The time counter is increased by δ = ρ 2 D τ c \delta= \frac{\rho^2}{D}\tau_c δ = D ρ 2 τ c , where τ c \tau_c τ c is the escape time from the unit disk or the unit ball. In turn, the Skorokhod integral representation allows one to increment the boundary local time as [54 , 55 ] :
ℓ t k + 1 = ℓ t k + π / 2 D δ . (93) \ell_{t_{k+1}} = \ell_{t_k} + \sqrt{\pi/2}\sqrt{D}\delta. \tag*{(93)} ℓ t k + 1 = ℓ t k + π /2 D δ . (93)
We refer to this method as SIM1.
Despite a number of tests realized in [54 , 55 ] , we provide an independent validation to check that our implementation of the SIM1 yields the correct results. In particular, we check and validate the choice ρ = d ε \rho= d\varepsilon ρ = d ε for the radius ρ \rho ρ inside the boundary layer. For this purpose, we compute numerically the spread harmonic measure density ω q ( x ∣ x 0 ) \omega_q(x|x_0) ω q ( x ∣ x 0 ) on the circle and on the sphere, for which exact solutions are available [78 ] . For a fixed starting point x 0 x_0 x 0 , ω q ( x ∣ x 0 ) d x \omega_q(x|x_0)dx ω q ( x ∣ x 0 ) d x is the probability that X T ∈ ( x , x + d x ) X_{\mathcal{T}} \in(x,x+dx) X T ∈ ( x , x + d x ) where T = inf { t > 0 : ℓ t > ℓ ^ } \mathcal{T} = \inf\{t > 0 : \ell_t > \hat{\ell}\} T = inf { t > 0 : ℓ t > ℓ ^ } is the first crossing time of a random threshold ℓ ^ \hat{\ell} ℓ ^ by the ℓ t \ell_t ℓ t . In other words, we employ here the third stopping condition (see § 2.5 ) with the exponential threshold ℓ ^ \hat{\ell} ℓ ^ such that P { ℓ ^ > ℓ } = e − q ℓ \mathbb{P}\{\hat{\ell} > \ell\} = e^{-q\ell} P { ℓ ^ > ℓ } = e − q ℓ , for a given q > 0 q > 0 q > 0 . From the applicative point of view, X T X_{\mathcal{T}} X T is the random position of the reaction event on the boundary with partial reactivity, κ = q D \kappa= qD κ = q D [24 ] [4].
Figure D.8. (a) Spread harmonic measure density on the unit circle (R = 1 R = 1 R = 1 ): comparison between the analytical expression (D.3) with K = 60 K = 60 K = 60 , truncated at j max = 50 j_{\max} = 50 j m a x = 50 , shown by the black line, and numerical estimates by SIM1. Parameters are: the boundary layer width ε = 10 − 3 \varepsilon= 10^{-3} ε = 1 0 − 3 , reactivity q = 10 q = 10 q = 10 , particle number N = 10 6 N = 10^{6} N = 1 0 6 , and the initial point is located at ( 0 , 0.9 ) (0, 0.9) ( 0 , 0.9 ) , with different choices of the ratio ρ / ε \rho/\varepsilon ρ / ε : ρ = ε \rho= \varepsilon ρ = ε (triangles), ρ = 2 ε \rho= 2\varepsilon ρ = 2 ε (squares), and ρ = 3 ε \rho= 3\varepsilon ρ = 3 ε (circles). (b) Spread harmonic measure density on the unit sphere (R = 1 R = 1 R = 1 ): comparison between the analytical expression (D.6) with K = 60 K = 60 K = 60 , truncated at n max = 60 n_{\max} = 60 n m a x = 60 , shown by black line, and numerical ones by SIM1. Parameters are: the boundary layer width ε = 10 − 3 \varepsilon= 10^{-3} ε = 1 0 − 3 , reactivity q = 10 q = 10 q = 10 , particle number N = 10 7 N = 10^{7} N = 1 0 7 , and the initial point is located at ( 0 , 0 , 0.9 ) (0, 0, 0.9) ( 0 , 0 , 0.9 ) , with different choices of the ratio ρ / ε \rho/\varepsilon ρ / ε : ρ = 2 ε \rho= 2\varepsilon ρ = 2 ε (squares), ρ = 3 ε \rho= 3\varepsilon ρ = 3 ε (circles), and ρ = 4 ε \rho= 4\varepsilon ρ = 4 ε (triangles). (c) Ratio of numerical estimates p k p_k p k shown in panel (a) to the analytical results (D.3), with different choices of the ratio ρ / ε \rho/\varepsilon ρ / ε : ρ = ε \rho= \varepsilon ρ = ε (triangles), ρ = 2 ε \rho= 2\varepsilon ρ = 2 ε (squares), and ρ = 3 ε \rho= 3\varepsilon ρ = 3 ε (circles). (d) Ratio of numerical estimates p k p_k p k shown in panel (b) to the analytical results (D.6), with different choices of the ratio ρ / ε \rho/\varepsilon ρ / ε : ρ = 2 ε \rho= 2\varepsilon ρ = 2 ε (squares), ρ = 3 ε \rho= 3\varepsilon ρ = 3 ε (circles), and ρ = 4 ε \rho= 4\varepsilon ρ = 4 ε (triangles). (e) Ratio of numerical estimates p k p_k p k obtained by SIM2 (not shown) to the analytical results (D.3), with different choices of the ratio ρ / ε \rho/\varepsilon ρ / ε : ρ = ε \rho= \varepsilon ρ = ε (triangles), ρ = 2 ε \rho= 2\varepsilon ρ = 2 ε (squares), and ρ = 3 ε \rho= 3\varepsilon ρ = 3 ε (circles). (f) Ratio of numerical estimates p k p_k p k obtained by SIM2 (not shown) to the analytical results (D.6), with different choices of the ratio ρ / ε \rho/\varepsilon ρ / ε : ρ = 2 ε \rho= 2\varepsilon ρ = 2 ε (squares), ρ = 3 ε \rho= 3\varepsilon ρ = 3 ε (circles), and ρ = 4 ε \rho= 4\varepsilon ρ = 4 ε (triangles).
Test for a disk
The spread harmonic measure density on the circle of radius R R R reads [78 ]
ω q ( θ ∣ r 0 , θ 0 ) = 1 2 π R { 1 + 2 ∑ j = 1 ∞ ( r 0 R ) j cos [ j ( θ − θ 0 ) ] 1 + j q R } . (94) \omega_q(\theta|r_0,\theta_0)=\frac{1}{2\pi R}\left\{1+2\sum_{j=1}^{\infty}\frac{\left(\frac{r_0}{R}\right)^j\cos\left[j(\theta-\theta_0)\right]}{1+\frac{j}{qR}}\right\}. \tag*{(94)} ω q ( θ ∣ r 0 , θ 0 ) = 2 π R 1 { 1 + 2 j = 1 ∑ ∞ 1 + q R j ( R r 0 ) j cos [ j ( θ − θ 0 ) ] } . (94)
where ( r 0 , θ 0 ) (r_0,\theta_0) ( r 0 , θ 0 ) is the starting point in polar coordinates. In order to estimate this density from Monte Carlo simulations, we divide the circle into K K K equal arcs such that the k k k -th arc contains θ ∈ [ ( k − 1 ) 2 π K , k 2 π K ) \theta\in[(k-1)\frac{2\pi}{K},k\frac{2\pi}{K}) θ ∈ [( k − 1 ) K 2 π , k K 2 π ) , k = 1 , 2 , 3 , . . . , K k = 1, 2, 3, ..., K k = 1 , 2 , 3 , ... , K . The probability p k p_k p k of the reaction event on this arc reads then
p k = R ∫ 2 π ( k − 1 ) / K 2 π k / K ω q ( θ ∣ r 0 , θ 0 ) d θ = 1 K + ∑ j = 1 ∞ 2 q R π j ( j + q R ) ( r 0 R ) j sin ( π j K ) cos ( j [ 2 π K ( k − 1 2 ) − θ 0 ] ) . (95) p_k=R\int_{2\pi(k-1)/K}^{2\pi k/K}\omega_q(\theta|r_0,\theta_0)\,d\theta=\frac{1}{K}+\sum_{j=1}^{\infty}\frac{2qR}{\pi j(j+qR)}\left(\frac{r_0}{R}\right)^j\sin\left(\frac{\pi j}{K}\right)\cos\left(j\left[\frac{2\pi}{K}\left(k-\frac{1}{2}\right)-\theta_0\right]\right). \tag*{(95)} p k = R ∫ 2 π ( k − 1 ) / K 2 π k / K ω q ( θ ∣ r 0 , θ 0 ) d θ = K 1 + j = 1 ∑ ∞ π j ( j + q R ) 2 q R ( R r 0 ) j sin ( K π j ) cos ( j [ K 2 π ( k − 2 1 ) − θ 0 ] ) . (95)
In turn, the probabilities p k p_k p k can be estimated by running Monte Carlo simulations with the third stopping condition and counting the number N k N_k N k of trajectories that stopped on the k k k -th arc, so that N k / N N_k/N N k / N approximates p k p_k p k .
Figure D.8a compares the exact probabilities p k p_k p k from Eq. (D.3) to the empirical ones obtained by Monte Carlo simulations with SIM1. We compare three choices for the radius ρ \rho ρ inside the boundary layer and illustrate that ρ = 2 ε \rho= 2\varepsilon ρ = 2 ε yields the most accurate results. Other starting points and values of q q q were tested and gave similar results (not shown).
Test for a sphere
For a sphere of radius R R R , the spread harmonic measure density reads [94 ] :
ω q ( x ∣ x 0 ) = 1 4 π R 2 ∑ n = 0 ∞ P n ( cos γ ) ( ∣ x 0 ∣ R ) n 2 n + 1 1 + n / ( q R ) , (96) \omega_q(\boldsymbol{x}|\boldsymbol{x}_0)=\frac{1}{4\pi R^2}\sum_{n=0}^{\infty}P_n(\cos\gamma)\left(\frac{|\boldsymbol{x}_0|}{R}\right)^n\frac{2n+1}{1+n/(qR)}, \tag*{(96)} ω q ( x ∣ x 0 ) = 4 π R 2 1 n = 0 ∑ ∞ P n ( cos γ ) ( R ∣ x 0 ∣ ) n 1 + n / ( q R ) 2 n + 1 , (96)
where x \boldsymbol{x} x is the position on the sphere, cos γ = ( x ⋅ x 0 ) ∣ x ∣ ∣ x 0 ∣ \cos\gamma=\frac{(\boldsymbol{x}\cdot\boldsymbol{x}_0)}{|\boldsymbol{x}||\boldsymbol{x}_0|} cos γ = ∣ x ∣∣ x 0 ∣ ( x ⋅ x 0 ) , P n ( x ) P_n(x) P n ( x ) is the Legendre polynomial. Using the spherical coordinates, x = ( R , θ , ϕ ) \boldsymbol{x}=(R,\theta,\phi) x = ( R , θ , ϕ ) , x 0 = ( ∣ x 0 ∣ , θ 0 , ϕ 0 ) \boldsymbol{x}_0=(|\boldsymbol{x}_0|,\theta_0,\phi_0) x 0 = ( ∣ x 0 ∣ , θ 0 , ϕ 0 ) , it is convenient to integrate over the angle ϕ \phi ϕ to get
ω ˉ ( θ ∣ θ 0 ) = 1 2 ∑ n = 0 ∞ P n ( cos θ ) P n ( cos θ 0 ) ( r 0 R ) n 2 n + 1 1 + n / ( q R ) . (97) \bar{\omega}(\theta|\theta_0)=\frac{1}{2}\sum_{n=0}^{\infty}P_n(\cos\theta)P_n(\cos\theta_0)\left(\frac{r_0}{R}\right)^n\frac{2n+1}{1+n/(qR)}. \tag*{(97)} ω ˉ ( θ ∣ θ 0 ) = 2 1 n = 0 ∑ ∞ P n ( cos θ ) P n ( cos θ 0 ) ( R r 0 ) n 1 + n / ( q R ) 2 n + 1 . (97)
As previously, we divide the sphere into K K K regions such that the k k k -th layer contains θ ∈ [ ( k − 1 ) , k ) × π K \theta\in[(k-1),k)\times\frac{\pi}{K} θ ∈ [( k − 1 ) , k ) × K π , with k = 1 , 2 , ⋯ , K k=1,2,\cdots,K k = 1 , 2 , ⋯ , K . The probability p k p_k p k of the reaction event on k k k -th region is thus expressed by
p k = ∫ ( k − 1 ) π / K k π / K ω ˉ ( θ ∣ θ 0 ) sin θ d θ = ξ k − 1 − ξ k 2 − 1 2 ∑ n = 1 ∞ ( r 0 / R ) n 1 + n / ( q R ) { [ P n + 1 ( ξ k ) − P n − 1 ( ξ k ) ] − [ P n + 1 ( ξ k − 1 ) − P n − 1 ( ξ k − 1 ) ] } , (98) p_k=\int_{(k-1)\pi/K}^{k\pi/K}\bar{\omega}(\theta|\theta_0)\sin\theta\,\mathrm{d}\theta=\frac{\xi_{k-1}-\xi_k}{2}-\frac{1}{2}\sum_{n=1}^{\infty}\frac{(r_0/R)^n}{1+n/(qR)}\left\{[P_{n+1}(\xi_k)-P_{n-1}(\xi_k)]-[P_{n+1}(\xi_{k-1})-P_{n-1}(\xi_{k-1})]\right\}, \tag*{(98)} p k = ∫ ( k − 1 ) π / K k π / K ω ˉ ( θ ∣ θ 0 ) sin θ d θ = 2 ξ k − 1 − ξ k − 2 1 n = 1 ∑ ∞ 1 + n / ( q R ) ( r 0 / R ) n { [ P n + 1 ( ξ k ) − P n − 1 ( ξ k )] − [ P n + 1 ( ξ k − 1 ) − P n − 1 ( ξ k − 1 )] } , (98)
with ξ k = cos ( k π / K ) \xi_k=\cos(k\pi/K) ξ k = cos ( k π / K ) .
We test different choices for the ratio ρ / ε \rho/\varepsilon ρ / ε by computing the spread harmonic measure on a unit sphere with R = 1 R=1 R = 1 , ε = 10 − 3 \varepsilon=10^{-3} ε = 1 0 − 3 , q = 10 q=10 q = 10 , and the initial point is located at ( 0 , 0 , 0.9 ) (0,0,0.9) ( 0 , 0 , 0.9 ) . Figure D.8b compares the exact probabilities p k p_k p k from Eq. (D.6) to the empirical ones obtained by Monte Carlo simulations with SIM1. In particular, panel (d) indicates that the choice ρ = 3 ε \rho=3\varepsilon ρ = 3 ε suggested in [43 ] , does not yield the most accurate results. Moreover, the results remain biased even for a larger value ρ = 4 ε \rho=4\varepsilon ρ = 4 ε . This bias can potentially explain higher relative errors of the SIM1 in three dimensions.
A modification of SIM
While Schumm and Bressloff designed and validated their SIM for planar domains [55 ] , its extension to three-dimensional domains was straightforward. However, no validation of this extension was performed. Our test for a sphere in Appendix § 10 .§ 2 revealed the accuracy issues of this extension. Moreover, the relative error of the mean ⟨ ℓ δ ⟩ \langle\ell_\delta\rangle ⟨ ℓ δ ⟩ was quite big for all the considered three-dimensional domains, even at ε = 10 − 3 \varepsilon=10^{-3} ε = 1 0 − 3 (see Table 4 , E.6, E.7). In an attempt to understand this discrepancy, we tried different ways of modeling the reflection event. In fact, the original method suggests to relocate the particle, which left the domain, to the boundary point along the normal direction (Fig. D.7a). To some extent, this is an arbitrary choice. For instance, most algorithms simulating reflected diffusion employ a mirror reflection across the boundary (see Fig. D.7b), but other choices are as well possible. It is generally believed that the choice of reflection, occuring at a small scale ε \varepsilon ε , provides only a minor effect onto simulation results. However, as the boundary local time is incremented only at such reflections, the minor errors potentially induced by the “wrong” choice, can accumulate and result in considerable bias.
In order to check this point, we propose a minor modification of the SIM, which consists in two steps: (i) the relocation to the boundary is replaced by a mirror reflection (compare Fig. D.7a and D.7b); (ii) after the reflection, we accumulated the durations of the consecutive jumps inside the boundary layer, until the particle leaves it. The accumulated duration δ \delta δ is then used to increment the boundary local time via Eq. (D.1). We refer to this method as SIM2. Figure D.8f shows that the SIM2 with ρ = d ε \rho=d\varepsilon ρ = d ε yields unbiased results for the spread harmonic measure in both two- and three-dimensional cases. We used this choice throughout all the manuscript. Table 4 , E.6, E.7 indicate that SIM2 yields more accurate results than SIM1 in three-dimensional examples, but less accurate results in two-dimensional examples. A more systematic analysis of this observation presents an interesting problem, which is, however, beyond the scope of this paper.
Table E.5. Comparison of the SIM, FLA, CLA with N = 10 6 N=10^{6} N = 1 0 6 and different ε \varepsilon ε for the annulus (Figure 3 b) with p = 1 p=1 p = 1 , R = 1 R=1 R = 1 , L = 2 L=2 L = 2 , and r 0 = 1.5 r_{0}=1.5 r 0 = 1.5 . The mean and standard deviation are: ⟨ ℓ δ i ⟩ = 0.6494 \langle\ell_{\delta}^{i}\rangle=0.6494 ⟨ ℓ δ i ⟩ = 0.6494 , σ i = 0.9112 \sigma^{i}=0.9112 σ i = 0.9112 , and ⟨ ℓ δ o ⟩ = 1.2660 \langle\ell_{\delta}^{o}\rangle=1.2660 ⟨ ℓ δ o ⟩ = 1.2660 , σ o = 1.5931 \sigma^{o}=1.5931 σ o = 1.5931 , so that the relative statistical errors are σ i ⟨ ℓ δ i ⟩ N ≃ 0.14 % \frac{\sigma^{i}}{\langle\ell_{\delta}^{i}\rangle\sqrt{N}}\simeq0.14\% ⟨ ℓ δ i ⟩ N σ i ≃ 0.14% , and σ o ⟨ ℓ δ o ⟩ N ≃ 0.13 % \frac{\sigma^{o}}{\langle\ell_{\delta}^{o}\rangle\sqrt{N}}\simeq0.13\% ⟨ ℓ δ o ⟩ N σ o ≃ 0.13% .
Validation for other domains
Annulus in 2D
We validate Monte Carlo simulations for a circular annulus of radii R R R and L L L (Figure 3 b). In this case, we evaluate separately the statistics of the boundary local times ℓ δ i \ell_{\delta}^{i} ℓ δ i and ℓ δ o \ell_{\delta}^{o} ℓ δ o on the inner and outer circles. The rotational symmetry of this domain implies again the simple form ((78) ), with the following parameters [24 ] :
(i) for the boundary local time ℓ δ i \ell_{\delta}^{i} ℓ δ i on the inner circle:
π 0 = 1 − I 1 ( α L ) K 0 ( α r 0 ) + K 1 ( α L ) I 0 ( α r 0 ) I 1 ( α L ) K 0 ( α R ) + K 1 ( α L ) I 0 ( α R ) , (99) \pi_{0}=1-\frac{I_{1}(\alpha L)K_{0}(\alpha r_{0})+K_{1}(\alpha L)I_{0}(\alpha r_{0})}{I_{1}(\alpha L)K_{0}(\alpha R)+K_{1}(\alpha L)I_{0}(\alpha R)}, \tag*{(99)} π 0 = 1 − I 1 ( α L ) K 0 ( α R ) + K 1 ( α L ) I 0 ( α R ) I 1 ( α L ) K 0 ( α r 0 ) + K 1 ( α L ) I 0 ( α r 0 ) , (99)
μ 0 ( p ) = α I 1 ( α L ) K 1 ( α R ) − K 1 ( α L ) I 1 ( α R ) I 1 ( α L ) K 0 ( α R ) + K 1 ( α L ) I 0 ( α R ) . (100) \mu_{0}^{(p)}=\alpha\frac{I_{1}(\alpha L)K_{1}(\alpha R)-K_{1}(\alpha L)I_{1}(\alpha R)}{I_{1}(\alpha L)K_{0}(\alpha R)+K_{1}(\alpha L)I_{0}(\alpha R)}. \tag*{(100)} μ 0 ( p ) = α I 1 ( α L ) K 0 ( α R ) + K 1 ( α L ) I 0 ( α R ) I 1 ( α L ) K 1 ( α R ) − K 1 ( α L ) I 1 ( α R ) . (100)
(ii) for the boundary local time ℓ δ o \ell_{\delta}^{o} ℓ δ o on the outer circle:
π 0 = 1 − K 1 ( α R ) I 0 ( α r 0 ) + I 1 ( α R ) K 0 ( α r 0 ) K 1 ( α R ) I 0 ( α L ) + I 1 ( α R ) K 0 ( α L ) , (101) \pi_{0}=1-\frac{K_{1}(\alpha R)I_{0}(\alpha r_{0})+I_{1}(\alpha R)K_{0}(\alpha r_{0})}{K_{1}(\alpha R)I_{0}(\alpha L)+I_{1}(\alpha R)K_{0}(\alpha L)}, \tag*{(101)} π 0 = 1 − K 1 ( α R ) I 0 ( α L ) + I 1 ( α R ) K 0 ( α L ) K 1 ( α R ) I 0 ( α r 0 ) + I 1 ( α R ) K 0 ( α r 0 ) , (101)
μ 0 ( p ) = α K 1 ( α R ) I 1 ( α L ) − I 1 ( α R ) K 1 ( α L ) K 1 ( α R ) I 0 ( α L ) + I 1 ( α R ) K 0 ( α L ) . (102) \mu_{0}^{(p)}=\alpha\frac{K_{1}(\alpha R)I_{1}(\alpha L)-I_{1}(\alpha R)K_{1}(\alpha L)}{K_{1}(\alpha R)I_{0}(\alpha L)+I_{1}(\alpha R)K_{0}(\alpha L)}. \tag*{(102)} μ 0 ( p ) = α K 1 ( α R ) I 0 ( α L ) + I 1 ( α R ) K 0 ( α L ) K 1 ( α R ) I 1 ( α L ) − I 1 ( α R ) K 1 ( α L ) . (102)
As previously for the case of a disk, Table E.5 compares the empirical mean values of ℓ δ i \ell_{\delta}^{i} ℓ δ i and ℓ δ o \ell_{\delta}^{o} ℓ δ o found by different methods and different widths ε \varepsilon ε with their analytical expectations, given by Eq. (81) . As in Table 2 , the most accurate results by the SIM1 are achieved at an intermediate width ε = 10 − 2 \varepsilon=10^{-2} ε = 1 0 − 2 , whereas its accuracy does not improve at smaller ε \varepsilon ε . For other methods, smaller ε \varepsilon ε results in more accurate values. The CLA outperforms two other methods for both ℓ δ i \ell_{\delta}^{i} ℓ δ i and ℓ δ o \ell_{\delta}^{o} ℓ δ o . Accidentally, the relative error of ⟨ ℓ δ i ⟩ e m p \langle\ell_{\delta}^{i}\rangle_{\mathrm{emp}} ⟨ ℓ δ i ⟩ emp for the SIM1 at ε = 10 − 2 \varepsilon=10^{-2} ε = 1 0 − 2 is comparable to that of the CLA. However, this is not true for ⟨ ℓ δ o ⟩ e m p \langle\ell_{\delta}^{o}\rangle_{\mathrm{emp}} ⟨ ℓ δ o ⟩ emp .
Figure E.9 shows the comparison of the statistics of two boundary local times, ℓ δ i \ell_{\delta}^{i} ℓ δ i and ℓ δ o \ell_{\delta}^{o} ℓ δ o , obtained by different Monte Carlo methods, with the exact solution ((78) ), for p = 1 p=1 p = 1 and several values of ε = 10 − 1 , 10 − 2 , 10 − 3 \varepsilon=10^{-1},10^{-2},10^{-3} ε = 1 0 − 1 , 1 0 − 2 , 1 0 − 3 . Curiously, the FLA presents opposite trends for ℓ δ i \ell_{\delta}^{i} ℓ δ i and ℓ δ o \ell_{\delta}^{o} ℓ δ o as ℓ \ell ℓ increases. The CLA yields accurate results even for ε = 10 − 1 \varepsilon=10^{-1} ε = 1 0 − 1 .
Sphere and spherical shell in 3D
The expression ((78) ) is also valid for the sphere of radius R R R , with
μ 0 ( p ) = α coth ( α R ) − 1 R , π 0 = 1 − R r 0 sinh ( α r 0 ) sinh ( α R ) . (103) \mu_{0}^{(p)}=\alpha\coth(\alpha R)-\frac{1}{R},\qquad\pi_{0}=1-\frac{R}{r_{0}}\frac{\sinh(\alpha r_{0})}{\sinh(\alpha R)}. \tag*{(103)} μ 0 ( p ) = α coth ( α R ) − R 1 , π 0 = 1 − r 0 R sinh ( α R ) sinh ( α r 0 ) . (103)
Figure E.9. Ratio Ψ e m p ( ℓ , p ∣ x 0 ) \Psi_{\mathrm{emp}}(\ell,p|x_0) Ψ emp ( ℓ , p ∣ x 0 ) over Ψ ( ℓ , p ∣ x 0 ) \Psi(\ell,p|x_0) Ψ ( ℓ , p ∣ x 0 ) as a function of ℓ / ⟨ ℓ δ ⟩ \ell/\langle\ell_\delta\rangle ℓ / ⟨ ℓ δ ⟩ for the circular annulus (Figure 3 b), with p = 1 p=1 p = 1 , R = 1 R=1 R = 1 , L = 2 L=2 L = 2 , and r 0 = 1.5 r_0=1.5 r 0 = 1.5 . The empirical PDF Ψ e m p \Psi_{\mathrm{emp}} Ψ emp was estimated from N = 10 6 N=10^6 N = 1 0 6 simulated values of ℓ δ \ell_\delta ℓ δ by (a,b) SIM1, (c,d) FLA, (e,f) CLA, with different choices of the boundary layer width: ε = 10 − 1 \varepsilon=10^{-1} ε = 1 0 − 1 (triangles), ε = 10 − 2 \varepsilon=10^{-2} ε = 1 0 − 2 (circles), and ε = 10 − 3 \varepsilon=10^{-3} ε = 1 0 − 3 (squares). (a,c,e) refer to ℓ δ i \ell_\delta^i ℓ δ i on the inner circle and (b,d,f) refer to ℓ δ o \ell_\delta^o ℓ δ o on the outer circle. The trajectories that never touched the boundary and thus yielded ℓ δ = 0 \ell_\delta=0 ℓ δ = 0 , were excluded.
Table E.6. Comparison of the SIM, FLA, CLA with N = 10 6 N=10^6 N = 1 0 6 and different ε \varepsilon ε for the unit sphere (Figure 3 d) with p = 1 p=1 p = 1 and r 0 = 0.5 r_0=0.5 r 0 = 0.5 . The mean and standard deviation of ℓ δ \ell_\delta ℓ δ are ⟨ ℓ δ ⟩ = 2.8330 \langle\ell_\delta\rangle=2.8330 ⟨ ℓ δ ⟩ = 2.8330 and σ = 3.1740 \sigma=3.1740 σ = 3.1740 , so that the relative statistical error is σ ⟨ ℓ δ ⟩ N ≃ 0.11 % \frac{\sigma}{\langle\ell_\delta\rangle\sqrt{N}}\simeq0.11\% ⟨ ℓ δ ⟩ N σ ≃ 0.11% .
where r 0 r_0 r 0 refers to the distance between the initial point and the sphere center, and α = p / D \alpha=\sqrt{p/D} α = p / D .
Figure E.10 presents the comparison of the exact PDF in Eq. (78) with the empirical ones obtained by different Monte Carlo methods. For ε = 10 − 1 \varepsilon=10^{-1} ε = 1 0 − 1 , both SIM and FLA present a bias, which is removed at smaller ε \varepsilon ε . In turn, the CLA shows again excellent agreement for all cases.
Table E.6 compares three methods for evaluating the mean value ⟨ ℓ δ ⟩ \langle\ell_\delta\rangle ⟨ ℓ δ ⟩ . As for the disk, the SIM is outperformed by the FLA (especially for small ε \varepsilon ε ), whereas the CLA yields the most accurate results. Curiously, the accuracies are higher in three dimensions than in two dimensions. Note that the SIM2 yields more accurate results than SIM1.
Furthermore, we also validate Monte Carlo simulations for a spherical shell between concentric spheres of radii R R R and L L L by evaluating ℓ δ i \ell_\delta^i ℓ δ i and ℓ δ o \ell_\delta^o ℓ δ o . Their PDFs are still given by Eq. (78) , with
(i) for the boundary local time ℓ δ i \ell_\delta^i ℓ δ i on the inner sphere:
π 0 = 1 − R r 0 α L cosh ( α ( L − r 0 ) ) − sinh ( α ( L − r 0 ) ) α L cosh ( α ( L − R ) ) − sinh ( α ( L − R ) ) (104) \pi_0=1-\frac{R}{r_0}\frac{\alpha L\cosh(\alpha(L-r_0))-\sinh(\alpha(L-r_0))}{\alpha L\cosh(\alpha(L-R))-\sinh(\alpha(L-R))} \tag*{(104)} π 0 = 1 − r 0 R α L cosh ( α ( L − R )) − sinh ( α ( L − R )) α L cosh ( α ( L − r 0 )) − sinh ( α ( L − r 0 )) (104)
μ 0 ( p ) = ( α 2 L R − 1 ) sinh ( α ( L − R ) ) + α ( L − R ) cosh ( α ( L − R ) ) R ( α L cosh ( α ( L − R ) ) − sinh ( α ( L − R ) ) ) . (105) \mu_0^{(p)}=\frac{(\alpha^2LR-1)\sinh(\alpha(L-R))+\alpha(L-R)\cosh(\alpha(L-R))}{R(\alpha L\cosh(\alpha(L-R))-\sinh(\alpha(L-R)))}. \tag*{(105)} μ 0 ( p ) = R ( α L cosh ( α ( L − R )) − sinh ( α ( L − R ))) ( α 2 L R − 1 ) sinh ( α ( L − R )) + α ( L − R ) cosh ( α ( L − R )) . (105)
Figure E.10. Ratio Ψ e m p ( ℓ , p ∣ x 0 ) \Psi_{\mathrm{emp}}(\ell,p|x_0) Ψ emp ( ℓ , p ∣ x 0 ) over Ψ ( ℓ , p ∣ x 0 ) \Psi(\ell,p|x_0) Ψ ( ℓ , p ∣ x 0 ) as a function of ℓ / ⟨ ℓ δ ⟩ \ell/\langle\ell_{\delta}\rangle ℓ / ⟨ ℓ δ ⟩ for the unit sphere (Figure 3 d), with p = 1 p=1 p = 1 and r 0 = 0.5 r_0=0.5 r 0 = 0.5 . The empirical PDF Ψ e m p \Psi_{\mathrm{emp}} Ψ emp was estimated from N = 10 6 N=10^6 N = 1 0 6 simulated values of ℓ δ \ell_{\delta} ℓ δ by (a) SIM1, (b) FLA, (c) CLA, with different choices of the boundary layer width: ε = 10 − 1 \varepsilon=10^{-1} ε = 1 0 − 1 (triangles), ε = 10 − 2 \varepsilon=10^{-2} ε = 1 0 − 2 (circles), and ε = 10 − 3 \varepsilon=10^{-3} ε = 1 0 − 3 (squares). The trajectories that never touched the boundary and thus yielded ℓ δ = 0 \ell_{\delta}=0 ℓ δ = 0 , were excluded.
Table E.7. Comparison of the SIM, FLA, CLA with N = 10 6 N=10^6 N = 1 0 6 and different ε \varepsilon ε for the spherical shell (Figure 3 e) with p = 1 p=1 p = 1 , R = 1 R=1 R = 1 , L = 2 L=2 L = 2 , and r 0 = 1.5 r_0=1.5 r 0 = 1.5 . The mean and standard deviation are: ⟨ ℓ δ i ⟩ = 0.4253 \langle\ell_{\delta}^{i}\rangle=0.4253 ⟨ ℓ δ i ⟩ = 0.4253 , σ i = 0.6458 \sigma^{i}=0.6458 σ i = 0.6458 , and ⟨ ℓ δ o ⟩ = 1.6174 \langle\ell_{\delta}^{o}\rangle=1.6174 ⟨ ℓ δ o ⟩ = 1.6174 , σ o = 1.9631 \sigma^{o}=1.9631 σ o = 1.9631 , so that the relative statistical errors are σ i ⟨ ℓ δ i ⟩ N ≃ 0.15 % \frac{\sigma^{i}}{\langle\ell_{\delta}^{i}\rangle\sqrt{N}}\simeq0.15\% ⟨ ℓ δ i ⟩ N σ i ≃ 0.15% , and σ o ⟨ ℓ δ o ⟩ N ≃ 0.12 % \frac{\sigma^{o}}{\langle\ell_{\delta}^{o}\rangle\sqrt{N}}\simeq0.12\% ⟨ ℓ δ o ⟩ N σ o ≃ 0.12% .
(ii) for the boundary local time ℓ δ o \ell_{\delta}^{o} ℓ δ o on the outer sphere:
π 0 = 1 − L r 0 α R cosh ( α ( r 0 − R ) ) + sinh ( α ( r 0 − R ) ) α R cosh ( α ( L − R ) ) + sinh ( α ( L − R ) ) (106) \pi_0=1-\frac{L}{r_0}\frac{\alpha R\cosh(\alpha(r_0-R))+\sinh(\alpha(r_0-R))}{\alpha R\cosh(\alpha(L-R))+\sinh(\alpha(L-R))} \tag*{(106)} π 0 = 1 − r 0 L α R cosh ( α ( L − R )) + sinh ( α ( L − R )) α R cosh ( α ( r 0 − R )) + sinh ( α ( r 0 − R )) (106)
μ 0 ( p ) = ( α 2 L R − 1 ) sinh ( α ( L − R ) ) + α ( L − R ) cosh ( α ( L − R ) ) L ( α R cosh ( α ( L − R ) ) + sinh ( α ( L − R ) ) ) (107) \mu_0^{(p)}=\frac{(\alpha^2LR-1)\sinh(\alpha(L-R))+\alpha(L-R)\cosh(\alpha(L-R))}{L(\alpha R\cosh(\alpha(L-R))+\sinh(\alpha(L-R)))} \tag*{(107)} μ 0 ( p ) = L ( α R cosh ( α ( L − R )) + sinh ( α ( L − R ))) ( α 2 L R − 1 ) sinh ( α ( L − R )) + α ( L − R ) cosh ( α ( L − R )) (107)
Table E.7 and Figure E.11 present the comparison between three methods, with the same trends as for the circular annulus.
Figure E.11. Ratio Ψ e m p ( ℓ , p ∣ x 0 ) \Psi_{\mathrm{emp}}(\ell,p|x_0) Ψ emp ( ℓ , p ∣ x 0 ) over Ψ ( ℓ , p ∣ x 0 ) \Psi(\ell,p|x_0) Ψ ( ℓ , p ∣ x 0 ) as a function of ℓ / ⟨ ℓ δ ⟩ \ell/ \langle\ell_\delta\rangle ℓ / ⟨ ℓ δ ⟩ for the spherical shell (Figure 3 e), with p = 1 p=1 p = 1 , R = 1 R=1 R = 1 , L = 2 L=2 L = 2 , and r 0 = 1.5 r_0=1.5 r 0 = 1.5 . The empirical PDF Ψ e m p \Psi_{\mathrm{emp}} Ψ emp was estimated from N = 10 6 N=10^6 N = 1 0 6 simulated values of ℓ δ \ell_\delta ℓ δ by (a,b) SIM1, (c,d) FLA, (e,f) CLA, with different choices of the boundary layer width: ε = 10 − 1 \varepsilon=10^{-1} ε = 1 0 − 1 (triangles), ε = 10 − 2 \varepsilon=10^{-2} ε = 1 0 − 2 (circles), and ε = 10 − 3 \varepsilon=10^{-3} ε = 1 0 − 3 (squares). (a,c,e) refer to ℓ δ i \ell_\delta^i ℓ δ i on the inner sphere and (b,d,f) refer to ℓ δ o \ell_\delta^o ℓ δ o on the outer sphere. The trajectories that never touched the boundary and thus yielded ℓ δ = 0 \ell_\delta=0 ℓ δ = 0 , were excluded.