Description
When I provide the Jacobian
f = ODEFunction(fcn,mass_matrix=M,jac=f_jac)
why do I get different results (number of time steps,...) when I use different options for autodiff:
sol = solve(prob_ode,Rodas4P2(),
or
sol = solve(prob_ode,Rodas4P2(autodiff=false,diff_type=Val{:central}),
or
sol = solve(prob_ode,Rodas4P2(autodiff=false,diff_type=Val{:forward}),
In my opinion, these options should not play a role then.
Moreover, usage of a simple numerical f_jac
function f_jac(J,y,P,t)
#--
del = sqrt(eps(1.0)); n = length(y);
f0 = similar(y); f1 = similar(y); fcn(f0,y,P,t);
for i=1:n
del_1 = max(abs(y[i])*del,del);
if y[i]<0.0 del_1 = -del_1; end
y1 = copy(y); y1[i] = y1[i] + del_1;
fcn(f1,y1,P,t)
J[:,i] = (f1-f0)/del_1;
end
end
leads to 864 accepted steps compared to 4813 steps without providing the Jacobian and autodiff=false,diff_type=Val{:forward} option. The diff_type=Val{:central} option is similar to 860 steps.
Metadata
Metadata
Assignees
Labels
No labels