Extend the Newton Diagnostics feature to also use numerical Jacobians
The current implementation of the Newton Diagnostics only works if analytic Jacobians are available:
https://github.com/OpenModelica/OpenModelica/blob/dffd48b921cd5f99e20322f0cf16e6932fdf83c3/OMCompiler/SimulationRuntime/c/simulation/solver/newton_diagnostics.c#L110-L118
In cases the analytic jacobian is not available, e.g. because there are functions involved, or because it is not generated for scalar equations, as in these two MWEs, a warning is printed and the the simulation executable crashes because the null pointers are really not handled.
model MWE2
Real x,y;
function f
input Real x;
output Real y;
algorithm
y := sin(x);
annotation(Inline = false);
end f;
equation
f(x) + cos(y) = 0;
x + y = 0;
annotation(__OpenModelica_simulationFlags(lv = "LOG_NLS_NEWTON_DIAGNOSTICS"),
__OpenModelica_commandLineOptions = "--maxSizeNonlinearTearing=0 --postOptModules-=wrapFunctionCalls");
end MWE2;
model MWE3
Real x;
equation
sin(x) + cos(x) = 0;
annotation(__OpenModelica_simulationFlags(lv = "LOG_NLS_NEWTON_DIAGNOSTICS"),
__OpenModelica_commandLineOptions = "--maxSizeNonlinearTearing=0 --postOptModules-=wrapFunctionCalls");
end MWE3;
We should make sure that we compute the numerical Jacobian values instead (also for Hessian computation) in these cases.
the simulation executable crashes because the null pointers are really not handled.
purely for cross-reference, this is filed in #13056