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 Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Sundials"
uuid = "c3572dad-4567-51f8-b174-8c6c989267f4"
authors = ["Chris Rackauckas <[email protected]>"]
version = "4.23.0"
version = "4.23.1"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Expand Down
2 changes: 1 addition & 1 deletion src/common_interface/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Abstract Types
abstract type SundialsODEAlgorithm{Method, LinearSolver} <: DiffEqBase.AbstractODEAlgorithm end
abstract type SundialsDAEAlgorithm{LinearSolver} <: DiffEqBase.AbstractDAEAlgorithm end
abstract type SundialsNonlinearSolveAlgorithm{LinearSolver} end
abstract type SundialsNonlinearSolveAlgorithm{LinearSolver} <: SciMLBase.AbstractNonlinearAlgorithm end

SciMLBase.alg_order(alg::Union{SundialsODEAlgorithm, SundialsDAEAlgorithm}) = alg.max_order

Expand Down
6 changes: 5 additions & 1 deletion src/common_interface/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ function DiffEqBase.__solve(prob::Union{

f!(resid, u)
retcode = interpret_sundials_retcode(flag)
DiffEqBase.build_solution(prob, alg, u, resid; retcode = retcode)
if prob.u0 isa Number
DiffEqBase.build_solution(prob, alg, u[1], resid[1]; retcode = retcode)
else
DiffEqBase.build_solution(prob, alg, u, resid; retcode = retcode)
end
end

function DiffEqBase.__init(prob::DiffEqBase.AbstractODEProblem{uType, tupType, isinplace},
Expand Down
17 changes: 17 additions & 0 deletions test/kinsol_nonlinear_solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,20 @@ prob_oop = NonlinearProblem{false}(f_oop, u0)
f_oop(sol.u, nothing)
@test maximum(abs, du) < 1e-6
end

# Scalar
f_scalar(u, p) = 2 - 2u
u0 = 0.0
prob_scalar = NonlinearProblem{false}(f_scalar, u0)

@testset "linear_solver = $(linear_solver) | globalization_strategy = $(globalization_strategy)" for linear_solver in (:Dense,
:LapackDense, :GMRES, :FGMRES, :PCG, :TFQMR), globalization_strategy in (:LineSearch, :None)
local sol
alg = KINSOL(; linear_solver, globalization_strategy)
sol = solve(prob_scalar, alg; abstol)
@test SciMLBase.successful_retcode(sol.retcode)
@test sol.u isa Number

resid = f_scalar(sol.u, nothing)
@test abs(resid) < 1e-6
end