Skip to content

Commit

Permalink
use different f to avoid overload
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed May 15, 2022
1 parent fb80c6c commit 65a516d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/common_interface/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ u2 = copy(integrator.u)
@test u1 != vec(prob.u0)
@test u1 == u2

f(u, p, t) = [2 * u[1]]
f_terminate(u, p, t) = [2 * u[1]]
u_positive(u, t, integrator) = u[1] > 0
terminate_if_u_pos = DiscreteCallback(u_positive, terminate!)

prob = ODEProblem(f, [1.0], (0.0, 1.0)) # positive initial condition > positive u > :Terminated
prob = ODEProblem(f_terminate, [1.0], (0.0, 1.0)) # positive initial condition > positive u > :Terminated
integrator = init(prob, CVODE_BDF(), callback=terminate_if_u_pos)
sol1 = solve!(integrator)
@test sol1.retcode === :Terminated
Expand All @@ -38,7 +38,7 @@ reinit!(integrator, [-1.0]) # negative initial condition > negative u > :Success
sol2 = solve!(integrator)
@test sol2.retcode == :Success

prob = ODEProblem(f, [-1.0], (0.0, 1.0)) # negative initial condition > negative u > :Success!
prob = ODEProblem(f_terminate, [-1.0], (0.0, 1.0)) # negative initial condition > negative u > :Success!
integrator = init(prob, CVODE_BDF(), callback=terminate_if_u_pos)
sol3 = solve!(integrator)
@test sol3.retcode == :Success

0 comments on commit 65a516d

Please sign in to comment.