Computation of hydraulic balance-ODE fails with non-linear solver

If you want more control over the solver, you can also use solver = PETScSNESSolver() and (solve with solver.solve(problem, u.vector()), problem being an inherited class of NonlinearProblem, see the Cahn-Hilliard demo). PETSc SNES is documented here, see section 5.2 for options for the nonlinear solvers.

You can set any PETSc options with, for instance, PETScOption.set('snes_linesearch_monitor').
edit: to get the option accepted, you need then to do:

solver = PETScSNESSolver()
PETScOptions.set('snes_linesearch_monitor')    # for example some monitoring
PETScOptions.set('snes_view')                            # print the solver config
snes = solver.snes().create()
snes.setFromOptions()

solver.solve(problem, u.vector())

With solver.snes() and solver.snes().ksp you can access the underlying PETSc nonlinear and linear (ksp) solvers (petsc4py objects) and manipulate them, extract convergence history and such.

1 Like