Skip to content

Commit

Permalink
fixes for DAEs and complex u0
Browse files Browse the repository at this point in the history
  • Loading branch information
jClugstor committed Nov 29, 2024
1 parent f9b5445 commit 29e2b1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/OrdinaryDiffEqDifferentiation/src/alg_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ function DiffEqBase.prepare_alg(
sparsity_detector = isnothing(sparsity) ? TracerSparsityDetector() : ADTypes.KnownJacobianSparsityDetector(sparsity)
color_alg = DiffEqBase.has_colorvec(prob.f) ? ADTypes.ConstantColoringAlgorithm(sparsity, prob.f.colorvec) : GreedyColoringAlgorithm()

if !(u0 isa SVector)
# don't use sparsity if the vectors are SVectors, or the eltype of u0 is Complex
if !(u0 isa SVector) && !(eltype(u0) <: Complex)
autodiff = AutoSparse(autodiff, sparsity_detector = sparsity_detector, coloring_algorithm = color_alg)
end

Expand Down
5 changes: 4 additions & 1 deletion lib/OrdinaryDiffEqDifferentiation/src/derivative_wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ function build_jac_config(alg, f::F1, uf::F2, du1, uprev,
@. @view(jac_prototype[idxs]) = @view(f.mass_matrix[idxs])
end
end
uf = SciMLBase.@set uf.f = SciMLBase.unwrapped_f(uf.f)
if uf.f.f isa FunctionWrappersWrappers.FunctionWrappersWrapper
uf = SciMLBase.@set uf.f = SciMLBase.unwrapped_f(uf.f)
end

jac_config = DI.prepare_jacobian(uf, du1, alg_autodiff(alg), u)
else
jac_config = nothing
Expand Down

0 comments on commit 29e2b1d

Please sign in to comment.