Non linear solver fails to converge. Is there a thumb-rule to avoid this in the future?

Hi,

First thing I have noticed is that you use iterative solver. That could possibly affect the convergence of your nonlinear solver. I would suggest you to try the direct solver (e.g. mumps) first, and only when you get good convergence to switch to iterative one. It is worth to mention that if you use iterative solver, you should check if the correct initial guess is used

parameters['krylov_solver']['nonzero_initial_guess'] = True

Next, since you have not specified the tolerances and number of iterations for nonlinear solver, I assume it uses default ones. This could also affect the convergence. Try specifying absolute and relative tolerance for nonelinar solver as follows

solver.parameters['relative_tolerance'] = 1e-5
solver.parameters['absolute_tolerance'] = 1e-5

Furthermore, beside tweaking the tolerances or using the direct linear solver, I would suggest you to switch to affine-covariant error-oriented linesearch (see more about this method here and here). For my problem (drift-diffusion equations coupled with Poisson equation), I got an improvement in convergence when I started using it. You can switch to it by adding following line in the code:

PETScOptions.set("snes_linesearch_type", "nleqerr")
solver.set_from_options()

I am not certain whether this improves convergence in general or not, but I guess it is worth to try.

Finally, I would suggest you to check out this post about linear and nonlinear solvers, and this one about designing your own Newton solver, which might be useful to you. More about convergence of nonlinear solvers and iterative linear solver can be found here and here, respectively.

2 Likes