Skip to content

Make the system code automatic differentiation compatible. #2

@loonatick-src

Description

@loonatick-src

On trying to solve the system using an implicit solver from SciML such as RadauIIA3, we get the following error message.

  Got exception outside of a @test
  First call to automatic differentiation for the Jacobian
  failed. This means that the user `f` function is not compatible
  with automatic differentiation. Methods to fix this include:
  
  1. Turn off automatic differentiation (e.g. Rosenbrock23() becomes
     Rosenbrock23(autodiff=false)). More details can befound at
     https://docs.sciml.ai/DiffEqDocs/stable/features/performance_overloads/
  2. Improving the compatibility of `f` with ForwardDiff.jl automatic 
     differentiation (using tools like PreallocationTools.jl). More details
     can be found at https://docs.sciml.ai/DiffEqDocs/stable/basics/faq/#Autodifferentiation-and-Dual-Numbers
  3. Defining analytical Jacobians. More details can be
     found at https://docs.sciml.ai/DiffEqDocs/stable/types/ode_types/#SciMLBase.ODEFunction

Followed by

  MethodError: no method matching Float64(::ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1})

And the stack trace is entirely functions from SciML packages.

So, make the system AD compatible. Alternatives include using a finite difference approx Jacobian or analytical Jacobian by hand.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions