JuliaDynamics / JuliaDynamics/DynamicalSystemsBase.jl
tangent_integrator not compatible with stiff solvers
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 56
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
as shown here https://discourse.julialang.org/t/chaostools-tangent-integrator-stiff-solvers/26464, the tangent_integrator errors, if one provides an algorithm, which uses ForwardDiff.jl to calculate the Jacobian, etc. This is the case for all stiff solvers. One can avoid using auto-differentiation by passing autodiff=false to the algorithm, e.g. Rodas5(autodiff=false) but we often want this feature!
The error is due to caching the Jacobi-matrix in the create_tangent function (https://github.com/JuliaDynamics/DynamicalSystemsBase.jl/blob/master/src/dynamicalsystem.jl#L343-L355)
# IIP Tangent Space dynamics
function create_tangent(@nospecialize(f::F), @nospecialize(jacobian::JAC), J::JM,
::Val{true}, ::Val{k}) where {F, JAC, JM, k}
J = deepcopy(J)
tangentf = (du, u, p, t) -> begin
uv = @view u[:, 1]
f(view(du, :, 1), uv, p, t)
jacobian(J, uv, p, t)
mul!((@view du[:, 2:(k+1)]), J, (@view u[:, 2:(k+1)]))
nothing
end
return tangentf
end
Especially line 346:
J = deepcopy(J).
A workaround is described here http://docs.juliadiffeq.org/latest/basics/faq.html#I-get-Dual-number-errors-when-I-solve-my-ODE-with-Rosenbrock-or-SDIRK-methods.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/dynamicalsystem.jl, especially create_tangent around lines 343-355, and review how the cached Jacobian is used with ForwardDiff.jl-based stiff solver algorithms. Reproduce the tangent_integrator failure with a stiff solver using autodiff, then verify that the integration works without requiring autodiff=false.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100