Skip to content

Commit a4427ce

Browse files
committed
add diffusion example
1 parent 21f5a76 commit a4427ce

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/DiffEqProblemLibrary.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export prob_jump_dnarepressor, prob_jump_constproduct, prob_jump_nonlinrxs,
5151
# examples mixing mass action and constant rate jumps
5252
prob_jump_osc_mixed_jumptypes,
5353
# examples used in published benchmarks / comparisions
54-
prob_jump_multistate, prob_jump_twentygenes, prob_jump_dnadimer_repressor
54+
prob_jump_multistate, prob_jump_twentygenes, prob_jump_dnadimer_repressor,
55+
# examples approximating diffusion by continuous time random walks
56+
prob_jump_diffnetwork
5557

5658
end # module

src/jump_premade_problems.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,27 @@ prob = DiscreteProblem(u0, (0.0, tf), rnpar)
200200
prob_jump_dnadimer_repressor = JumpProblemNetwork(rn, rnpar, tf, u0, prob,
201201
Dict("specs_names" => varlabels))
202202

203+
204+
"""
205+
Continuous time random walk (i.e. diffusion approximation) example.
206+
Here the network in the JumpProblemNetwork is a function that returns a
207+
network given the number of lattice sites.
208+
u0 is a similar function that returns the initial condition vector.
209+
"""
210+
# diffusion model
211+
function getDiffNetwork(N)
212+
diffnetwork = "@reaction_network dpldifftype begin\n"
213+
for i in 1:(N-1)
214+
diffnetwork *= "\t K, X$(i) --> X$(i+1)\n"
215+
diffnetwork *= "\t K, X$(i+1) --> X$(i)\n"
216+
end
217+
diffnetwork *= "end K"
218+
rs = eval( parse(diffnetwork) )
219+
rs
220+
end
221+
params = (1.,)
222+
function getDiffu0(N)
223+
10*ones(Int64, N)
224+
end
225+
tf = 10.
226+
prob_jump_diffnetwork = JumpProblemNetwork(getDiffNetwork, params, tf, getDiffu0, nothing, nothing)

0 commit comments

Comments
 (0)