Skip to content

Commit

Permalink
make test a little simpler
Browse files Browse the repository at this point in the history
the test was failing because the rate could go negative since u[2] could go negative, and this would make tstops go back in time giving an error. This is because the model is nonsensical, not the solver.
  • Loading branch information
ChrisRackauckas committed Feb 9, 2017
1 parent 1980fed commit c9aa902
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/variable_rate_reactions.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DiffEqBiological, DiffEqJump, DiffEqBase, OrdinaryDiffEq, StochasticDiffEq
using Base.Test

r1 = VariableRateReaction(1e-4,(1,2),((1,-1),(2,1)))
r2 = VariableRateReaction(0.01,[2],[(2,-1),(3,1)])
Expand Down Expand Up @@ -45,10 +46,10 @@ jump_prob = GillespieProblem(prob,Direct(),r1,r2,r3)
sol = solve(jump_prob,Tsit5())

g = function (t,u,du)
du[4] = 0.1u[4]
du[4] = 0.05u[4]
end

srand(330)
srand(331)
println("Turn Gillespie Problem into SDE")
prob = SDEProblem(f,g,[999.0,3.0,0.0,1.0],(0.0,250.0))
jump_prob = GillespieProblem(prob,Direct(),r1,r2,r3)
Expand All @@ -59,5 +60,6 @@ println("Now mix constant rate reactions")
r1 = Reaction(1e-4,(1,2),((1,-1),(2,1)))
r2 = Reaction(0.01,[2],[(2,-1),(3,1)])
jump_prob = GillespieProblem(prob,Direct(),r1,r2,r3)
sol = solve(jump_prob,SRIW1())
integrator = init(jump_prob,SRIW1())
solve!(integrator)
@test 650 <= sol[end][3] <= 1500

0 comments on commit c9aa902

Please sign in to comment.