Skip to main content
. 2019 Jun 4;81(8):3185–3213. doi: 10.1007/s11538-019-00613-0

Table 1.

Pseudocode for the multiscale reaction–diffusion algorithm with Scheme 1 applied to simulation of diffusion

[A] Set t=0 and ts=Δt. Initialize species numbers, X(0), in Ωm and Ωs. Then, generate random numbers r1 and r2 uniformly distributed in (0, 1). Set τ so that τ=-a0-1logr1, where a0 is defined in Eq. (11). Set the next time when the diffusion occurs in Ωm as tm=τ
[B] If tmts
Set t=tm
Use r2 to determine which diffusive jump occurs. Each diffusive jump to the left (resp. to the right) has the probability a-,ik/a0 (resp. a+,ik/a0) to occur
If the selected diffusive jump only includes internal compartments in Ωm, update species numbers in the corresponding compartments
If the diffusion occurs across the interface from Ωm to Ωs, update the species number in CKs by transferring one molecules from CKs+1 to the corresponding grid point in Ωs
If the diffusion occurs across the interface from Ωs to Ωm, update the species number in CKs+1 by adding one molecule and subtracting one from the corresponding grid point in Ωs
Generate random numbers r1 and r2 uniformly distributed in (0, 1). Set τ so that τ=-a0-1logr1, where a0 is defined in Eq. (11). Set the next time when the diffusion occurs in Ωm as tm=t+τ
[C] If tstm
Set t=ts
Use Eq. (12) to update the SPDE part of the system from t to t+Δt
Set the next time of the update of the SPDE part as ts=t+Δt
[D] Repeat steps [B][C] until the simulation ends