Skip to main content
. 2010 Feb 16;132(7):074101. doi: 10.1063/1.3310809

 
Algorithm 3 RDME simulation algorithm using DFSP for diffusion and SSA for reactions
1: initialize system state: X, t=0
2: Calculate the propensity functions ajk(X) and a0k=1Kj=1Majk(X) {where M is the number of reactions and K is the number of voxels}
3: Generate two random numbers r1,r2U(0,1)
4: tnext_rxnt+1a0ln(1r1)
5: tnext_difftD
6: whilet<tfinaldo
7:  iftnext_rxn<tnext_diffthen
8:   Find μr, μx smallest integers to satisfy k=1μxj=1μrajk>r2a0
9:   Update Xμx(tnext_rxn)=Xμx(t)+νμr
10:   Generate two random numbers r1,r2U(0,1)
11:   ttnext_rxn
12:  else
13:   Xnext←∅
14:   fork∊(1…K) do
15:    fori∊(1…N) do
16:     XnextXnext+DFSP_Diffusion(Xk,i) {diffusion of species i in voxel k}
17:    end for
18:   end for
19:   XXnext
20:   ttnext_diff
21:   tnext_difftD
22:  end if
23:  Update propensity functions ajk(X) and a0k=1Kj=1Majk(X)
24:  tnext_rxnt+1a0ln(1r1)
25: end while