I am using the DifferentialEquations package to simulate Hodgkin Huxley neurons. This involves evaluating certain parameters inside the ODE function using dependent variables for which I need to make function calls from within the ODE function, e.g.
V = u;
[param1, param2] = my_function(V);
du = (V - param1) / param2;
To speed up the code I have made my_function accept only Float64 by type assertion:
The problem is while using certain solvers that use autodiff (e.g. QNDF() or Rodas4()) I get an error when instead of passing a Float64 a Dual type number is passed. The solution here describes two workarounds: 1st is obvious (turn off autodiff). However i don’t understand the second. Could anyone please explain it to me? If I just turn off autodiff the accuracy of the solution will take a hit right?