Skip to content

Commit 3b01a97

Browse files
Merge pull request #20 from isaacsas/jump-problems
add JumpProblems to library
2 parents 7dba97d + 60821b4 commit 3b01a97

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

src/DiffEqProblemLibrary.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ include("ode/ode_premade_problems.jl")
88
include("dae_premade_problems.jl")
99
include("dde_premade_problems.jl")
1010
include("sde_premade_problems.jl")
11+
include("jump_premade_problems.jl")
1112

1213
#ODE Example Problems
1314
export prob_ode_linear, prob_ode_bigfloatlinear, prob_ode_2Dlinear,
@@ -45,4 +46,9 @@ export prob_dde_1delay, prob_dde_1delay_notinplace, prob_dde_1delay_scalar_notin
4546
# examples with vanishing state dependent delays
4647
prob_neves2, prob_dde_gatica
4748

49+
# Jump Example Problems
50+
export prob_jump_dnarepressor, prob_jump_constproduct, prob_jump_nonlinrxs,
51+
# examples mixing mass action and constant rate jumps
52+
prob_jump_osc_mixed_jumptypes
53+
4854
end # module

src/jump_premade_problems.jl

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
"""
2+
General structure to hold JumpProblem info. Needed since
3+
the JumpProblem constructor requires the algorithm, so we
4+
don't create the JumpProblem here.
5+
"""
6+
struct JumpProblemNetwork
7+
network # DiffEqBiological network
8+
rates # vector of rate constants or nothing
9+
tstop # time to end simulation
10+
u0 # initial values
11+
discrete_prob # initialized discrete problem
12+
prob_data # additional problem data, stored as a Dict
13+
end
14+
15+
"""
16+
DNA negative feedback autoregulatory model. Protein acts as repressor.
17+
"""
18+
rs = @reaction_network ptype begin
19+
k1, DNA --> mRNA + DNA
20+
k2, mRNA --> mRNA + P
21+
k3, mRNA --> 0
22+
k4, P --> 0
23+
k5, DNA + P --> DNAR
24+
k6, DNAR --> DNA + P
25+
end k1 k2 k3 k4 k5 k6
26+
rates = [.5, (20*log(2.)/120.), (log(2.)/120.), (log(2.)/600.), .025, 1.]
27+
tf = 1000.0
28+
u0 = [1,0,0,0]
29+
prob = DiscreteProblem(u0, (0.0, tf), rates)
30+
Nsims = 8000
31+
expected_avg = 5.926553750000000e+02
32+
prob_data = Dict("num_sims_for_mean" => Nsims, "expected_mean" => expected_avg)
33+
prob_jump_dnarepressor = JumpProblemNetwork(rs, rates, tf, u0, prob, prob_data)
34+
35+
36+
"""
37+
Simple constant production with degradation example
38+
"""
39+
rs = @reaction_network pdtype begin
40+
k1, 0 --> A
41+
k2, A --> 0
42+
end k1 k2
43+
rates = [1000., 10.]
44+
tf = 1.0
45+
u0 = [0]
46+
prob = DiscreteProblem(u0, (0., tf), rates)
47+
Nsims = 16000
48+
expected_avg = t -> rates[1] / rates[2] .* ( 1. - exp.(-rates[2] * t))
49+
prob_data = Dict("num_sims_for_mean" => Nsims, "expected_mean_at_t" => expected_avg)
50+
prob_jump_constproduct = JumpProblemNetwork(rs, rates, tf, u0, prob, prob_data)
51+
52+
53+
"""
54+
Example with a mix of nonlinear reactions, including third order
55+
"""
56+
rs = @reaction_network dtype begin
57+
k1, 2A --> B
58+
k2, B --> 2A
59+
k3, A + B --> C
60+
k4, C --> A + B
61+
k5, 3C --> 3A
62+
end k1 k2 k3 k4 k5
63+
rates = [1., 2., .5, .75, .25]
64+
tf = .01
65+
u0 = [200, 100, 150]
66+
prob = DiscreteProblem(u0, (0., tf), rates)
67+
Nsims = 32000
68+
expected_avg = 84.876015624999994
69+
prob_data = Dict("num_sims_for_mean" => Nsims, "expected_mean" => expected_avg)
70+
prob_jump_nonlinrxs = JumpProblemNetwork(rs, rates, tf, u0, prob, prob_data)
71+
72+
73+
"""
74+
Oscillatory system, uses a mixture of jump types.
75+
"""
76+
rs = @reaction_network rnType begin
77+
0.01, (X,Y,Z) --> 0
78+
hill(X,3.,100.,-4), 0 --> Y
79+
hill(Y,3.,100.,-4), 0 --> Z
80+
hill(Z,4.5,100.,-4), 0 --> X
81+
hill(X,2.,100.,6), 0 --> R
82+
hill(Y,15.,100.,4)*0.002, R --> 0
83+
20, 0 --> S
84+
R*0.005, S --> SP
85+
0.01, SP + SP --> SP2
86+
0.05, SP2 --> 0
87+
end
88+
u0 = [200.,60.,120.,100.,50.,50.,50.] # Hill equations force use of floats!
89+
tf = 4000.
90+
prob = DiscreteProblem(u0, (0.,tf))
91+
prob_jump_osc_mixed_jumptypes = JumpProblemNetwork(rs, nothing, tf, u0, prob, nothing)

0 commit comments

Comments
 (0)