Skip to content

Commit

Permalink
Update ode_event_tests.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas authored Sep 14, 2023
1 parent 1e7ed2a commit 4fb7298
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions test/integrators/ode_event_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -411,21 +411,23 @@ step!(integrator, 1e-5, true)
@test all(u -> u > 1.5, integrator.u)

# https://github.com/SciML/OrdinaryDiffEq.jl/pull/1777
@testset "Callbacks with LinearExponential" begin
A = sprand(ComplexF64, 100, 100, 0.5)
A += A'

t_l = LinRange(0, 1, 100)

saved_values = SavedValues(Float64, Float64)
function save_func(u, t, integrator)
real(u' * A * u)
if VERSION >= v"1.7"
@testset "Callbacks with LinearExponential" begin
A = sprand(ComplexF64, 100, 100, 0.5)
A += A'

t_l = LinRange(0, 1, 100)

saved_values = SavedValues(Float64, Float64)
function save_func(u, t, integrator)
real(u' * A * u)
end
cb = SavingCallback(save_func, saved_values, saveat = t_l)

u0 = normalize(rand(ComplexF64, 100))
A = MatrixOperator(-1im * A)
prob = ODEProblem(A, u0, (0, 1.0))
solve(prob, LinearExponential(), dt = t_l[2] - t_l[1], callback = cb)
@test length(saved_values.saveval) == length(t_l)
end
cb = SavingCallback(save_func, saved_values, saveat = t_l)

u0 = normalize(rand(ComplexF64, 100))
A = MatrixOperator(-1im * A)
prob = ODEProblem(A, u0, (0, 1.0))
solve(prob, LinearExponential(), dt = t_l[2] - t_l[1], callback = cb)
@test length(saved_values.saveval) == length(t_l)
end

0 comments on commit 4fb7298

Please sign in to comment.