Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common_interface/integrator_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function DiffEqBase.savevalues!(
)::Tuple{Bool, Bool}
saved, savedexactly = false, false
!integrator.opts.save_on && return saved, savedexactly
uType = eltype(integrator.sol.u)
uType = typeof(integrator.sol.prob.u0)
# The call to first is an overload of Base.first implemented in DataStructures
while !isempty(integrator.opts.saveat) &&
integrator.tdir * first(integrator.opts.saveat) < integrator.tdir * integrator.t
Expand Down
21 changes: 11 additions & 10 deletions src/common_interface/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ function DiffEqBase.__solve(
ts = [],
ks = [],
recompile::Type{Val{recompile_flag}} = Val{true};
calculate_error = true,
kwargs...,
) where {algType <: Union{SundialsODEAlgorithm, SundialsDAEAlgorithm}, recompile_flag}

integrator = DiffEqBase.__init(prob, alg, timeseries, ts, ks; kwargs...)
if integrator.sol.retcode == :Default
solve!(integrator,early_free = true)
solve!(integrator, early_free = true, calculate_error = calculate_error)
end
integrator.sol
end
Expand Down Expand Up @@ -400,10 +401,10 @@ function DiffEqBase.__init(
save_value!(dures, utmp, uType, sizeu, save_idxs)
end
else
ures = u0[save_idxs]
ures = [u0[save_idxs]]
if dense
f!(_u0, u0, prob.p, tspan[1])
dures = _u0[save_idxs]
dures = [_u0[save_idxs]]
end
end
else
Expand Down Expand Up @@ -920,10 +921,10 @@ function DiffEqBase.__init(
save_value!(dures, utmp, uType, sizeu, save_idxs)
end
else
ures = u0[save_idxs]
ures = [u0[save_idxs]]
if dense
f!(_u0, u0, prob.p, tspan[1])
dures = _u0[save_idxs]
dures = [_u0[save_idxs]]
end
end
else
Expand Down Expand Up @@ -1373,9 +1374,9 @@ function DiffEqBase.__init(
save_value!(dures, du0, uType, sizedu, save_idxs)
end
else
ures = u0[save_idxs]
ures = [u0[save_idxs]]
if dense
dures = du0[save_idxs]
dures = [du0[save_idxs]]
end
end
else
Expand Down Expand Up @@ -1554,7 +1555,7 @@ function get_iters!(integrator::IDAIntegrator, iters)
IDAGetNumSteps(integrator.mem, iters)
end

function DiffEqBase.solve!(integrator::AbstractSundialsIntegrator; early_free = false)
function DiffEqBase.solve!(integrator::AbstractSundialsIntegrator; early_free = false, calculate_error = false)
uType = eltype(integrator.sol.u)
iters = Ref(Clong(-1))
while !isempty(integrator.opts.tstops)
Expand Down Expand Up @@ -1620,11 +1621,11 @@ function DiffEqBase.solve!(integrator::AbstractSundialsIntegrator; early_free =
integrator.LS !== nothing && empty!(integrator.LS)
end

if DiffEqBase.has_analytic(integrator.sol.prob.f)
if DiffEqBase.has_analytic(integrator.sol.prob.f) && calculate_error
DiffEqBase.calculate_solution_errors!(
integrator.sol;
timeseries_errors = integrator.opts.timeseries_errors,
dense_errors = integrator.opts.dense_errors,
dense_errors = integrator.opts.dense_errors
)
end

Expand Down
7 changes: 6 additions & 1 deletion test/common_interface/cvode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ sol = solve(prob, CVODE_Adams(), tstops = [0.9])
sol = solve(prob, CVODE_Adams())
sol_idxs = solve(prob, CVODE_Adams(), save_idxs = [1], timeseries_errors = false)

@test sol[1,:] == sol_idxs[:]
@test sol[1, :] == sol_idxs[1, :]

sol_idxs = solve(prob, CVODE_Adams(), save_idxs = [1, 2], timeseries_errors = false, calculate_error = false)
@test length(sol_idxs[1]) == 2
@test sol[1, :] == sol_idxs[1, :]
@test sol[2, :] == sol_idxs[2, :]

# Test the other function conversions
k = (du, u, p, t) -> du[1] = u[1]
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ end
SUPPORT_CFUNCTION && @testset "Roberts CVODE Direct" begin
include("cvode_Roberts_dns.jl")
end
@testset "CVODES Direct" begin include("cvodes_dns.jl") end
#@testset "CVODES Direct" begin include("cvodes_dns.jl") end
end

@testset "IDA" begin
Expand Down