Skip to content

Commit e310141

Browse files
committed
add test
1 parent 3e7fa80 commit e310141

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/variable_rate.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,30 @@ x₀ = 1.0 + 0.0im
144144
prob = ODEProblem(f4, [x₀], Δt)
145145
jumpProblem = JumpProblem(prob, Direct(), jump)
146146
sol = solve(jumpProblem, Tsit5())
147+
148+
# test to check lack of dependency graphs is caught in Coevolve for systems with non-maj
149+
# jumps
150+
let
151+
maj_rate = [1.]
152+
react_stoich_ = [Vector{Pair{Int, Int}}()]
153+
net_stoich_ = [[1 => 1]]
154+
mass_action_jump_ = MassActionJump(maj_rate, react_stoich_, net_stoich_; scale_rates=false)
155+
156+
affect! = function (integrator)
157+
integrator.u[1] -= 1
158+
end
159+
cs_rate1(u,p,t) = 0.2 * u[1]
160+
constant_rate_jump = ConstantRateJump(cs_rate1, affect!)
161+
jumpset_ = JumpSet((), (constant_rate_jump,), nothing, mass_action_jump_)
162+
163+
u0 = [0]
164+
tspan = (0.0, 30.0)
165+
dprob_ = DiscreteProblem(u0, tspan)
166+
alg = Coevolve()
167+
@test_throws ErrorException JumpProblem(dprob_, alg, jumpset_, save_positions=(false, false))
168+
169+
vrj = VariableRateJump(cs_rate1, affect!; urate = ((u, p, t) -> 1.0),
170+
rateinterval = ((u,p,t) -> 1.0))
171+
@test_throws ErrorException JumpProblem(dprob_, alg, mass_action_jump_, vrj;
172+
save_positions=(false, false))
173+
end

0 commit comments

Comments
 (0)