|
| 1 | +using DiffEqBiological, DiffEqJump, DiffEqBase, OrdinaryDiffEq |
| 2 | + |
| 3 | +k = rand() |
| 4 | +# First order |
| 5 | +r1 = Reaction(k,[1],((1,-1),(2,1))) |
| 6 | +jump = build_jumps_from_reaction(r1) |
| 7 | +@test jump.rate(0.0,[1,0]) == k |
| 8 | + |
| 9 | + |
| 10 | +# Second order |
| 11 | +r2 = Reaction(k,[1,1],((1,-2),(2,1))) |
| 12 | +jump2 = build_jumps_from_reaction(r2) |
| 13 | +@test jump2.rate(0.0,[1,0]) == 0 |
| 14 | +@test jump2.rate(0.0,[2,0]) == k*2*1 |
| 15 | + |
| 16 | +# Thrid order |
| 17 | +r3 = Reaction(k,[1,1,1],((1,-3),(2,1))) |
| 18 | +jump3 = build_jumps_from_reaction(r3) |
| 19 | +@test jump3.rate(0.0,[1,0]) == 0 |
| 20 | +@test jump3.rate(0.0,[2,0]) == 0 |
| 21 | +@test jump3.rate(0.0,[3,0]) == k*3*2*1 |
| 22 | + |
| 23 | +# Mixed Third order |
| 24 | +r21 = Reaction(k ,[1,1,2],((1,-2),(2,-1))) |
| 25 | +jump21 = build_jumps_from_reaction(r21) |
| 26 | +@test jump21.rate(0.0,[1,1]) == 0 |
| 27 | +@test jump21.rate(0.0,[2,1]) == k*2*1*1 |
| 28 | + |
| 29 | +# Mixed Third order different order |
| 30 | +r12 = Reaction(k ,[2,1,1],((1,-2),(2,-1))) |
| 31 | +jump12 = build_jumps_from_reaction(r12) |
| 32 | + jump12.rate(0.0,[1,1]) == 0 |
| 33 | +@test jump12.rate(0.0,[2,1]) == k*2*1*1 |
| 34 | + |
| 35 | + |
| 36 | +# Solve the dimerization problem |
| 37 | +prob = DiscreteProblem([1,0],(0.0,250.0)) |
| 38 | +jump_prob = GillespieProblem(prob,Direct(),r2) |
| 39 | +sol = solve(jump_prob,Discrete()) |
| 40 | +@test find( x-> x!=0 ,[u[2] for u in sol.u]) == [] |
0 commit comments