Closed lucapegolotti closed 2 years ago
Looks great! Should we add your input file to the test cases? It doesn't need to run the whole simulation, just a couple of time steps after the FD tangent kicks in.
Merged in #85 with always using FD tangent and some code cleanup
The current implementation of svOneDSolver uses an inconsistent Jacobian matrix in which some of the terms are assumed constant during the Newton iterations. This generally works well but sometimes the inexact Jacobian causes the area of certain segments to become negative, which causes the program to launch an uncaught exception. Considering a simple first-order finite differences approximation of the Jacobian seems to be a more stable solution in these cases. The finite-difference approximation has also the advantage of reducing the number of Newton iterations w.r.t. the inexact Jacobian. However, the computational cost of a single iteration is higher which causes the solver to be less performant (2 - 4 times). For this reason, the inexact Jacobian is kept the default choice and the finite difference approximation is used only when the solver fails for the first time. I attach an input file for which the default tangent fails in the first timestep and this version of the code automatically switches to the approximated tangent. failure_1sttimestep.in.zip