Skip to content

Commit

Permalink
Merge pull request #24 from isaacsas/diffusion-jump-ex
Browse files Browse the repository at this point in the history
add diffusion by CTRW example
  • Loading branch information
ChrisRackauckas authored May 8, 2018
2 parents 21f5a76 + a4427ce commit 88c63f3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/DiffEqProblemLibrary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export prob_jump_dnarepressor, prob_jump_constproduct, prob_jump_nonlinrxs,
# examples mixing mass action and constant rate jumps
prob_jump_osc_mixed_jumptypes,
# examples used in published benchmarks / comparisions
prob_jump_multistate, prob_jump_twentygenes, prob_jump_dnadimer_repressor
prob_jump_multistate, prob_jump_twentygenes, prob_jump_dnadimer_repressor,
# examples approximating diffusion by continuous time random walks
prob_jump_diffnetwork

end # module
24 changes: 24 additions & 0 deletions src/jump_premade_problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,27 @@ prob = DiscreteProblem(u0, (0.0, tf), rnpar)
prob_jump_dnadimer_repressor = JumpProblemNetwork(rn, rnpar, tf, u0, prob,
Dict("specs_names" => varlabels))


"""
Continuous time random walk (i.e. diffusion approximation) example.
Here the network in the JumpProblemNetwork is a function that returns a
network given the number of lattice sites.
u0 is a similar function that returns the initial condition vector.
"""
# diffusion model
function getDiffNetwork(N)
diffnetwork = "@reaction_network dpldifftype begin\n"
for i in 1:(N-1)
diffnetwork *= "\t K, X$(i) --> X$(i+1)\n"
diffnetwork *= "\t K, X$(i+1) --> X$(i)\n"
end
diffnetwork *= "end K"
rs = eval( parse(diffnetwork) )
rs
end
params = (1.,)
function getDiffu0(N)
10*ones(Int64, N)
end
tf = 10.
prob_jump_diffnetwork = JumpProblemNetwork(getDiffNetwork, params, tf, getDiffu0, nothing, nothing)

0 comments on commit 88c63f3

Please sign in to comment.