Ode integrator calls from user defined functions

It’s a documented “feature”, but it’s subtle to explain, especially in function contexts.

The core problem is that local variables will be autodiff variables rather than “data” variables if any of the types involved in the context (function arguments, or locals in transformed parameters or model) may be autodiff variables. The solution is tighter static analysis and code generation, where what you have would be inferred to be compatible with a double scalar type.