# Conjugate gradient solver for nonlinear variational Problem

**URL:** <https://fenicsproject.discourse.group/t/conjugate-gradient-solver-for-nonlinear-variational-problem/4707>\
**Category:** variational formulation\
**Created:** [December 9, 2020, 10:53pm UTC](https://fenicsproject.discourse.group/t/conjugate-gradient-solver-for-nonlinear-variational-problem/4707 "2020-12-09T22:53:18Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![bhaveshshrimali](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/bhaveshshrimali/32/124_2.png) [@bhaveshshrimali](https://fenicsproject.discourse.group/u/bhaveshshrimali)\
**Post date:** [December 12, 2020, 6:35pm UTC](https://fenicsproject.discourse.group/t/conjugate-gradient-solver-for-nonlinear-variational-problem/4707/6 "2020-12-12T18:35:52Z")

</div>

For scalable nonlinear solvers, you could take a look at [this paper](https://www.mcs.anl.gov/papers/P2010-0112.pdf) as a starting point. In general it can pin down to be highly specific to the problem you are solving.

Newton combined with a proper choice of linear solver (at each Newton-iteration) and a preconditioner should usually give you out of the box good performance for _many_. [PETScSNES](https://bitbucket.org/fenics-project/dolfin/src/master/dolfin/nls/PETScSNESSolver.cpp) is also a good place to start looking out for solvers available directly through PETSc. You could also take a look at [Non linear solver](https://fenicsproject.discourse.group/t/non-linear-solver/4499/3) to program the solver by yourself.

[https://github.com/FEniCS/dolfinx/blob/master/python/test/unit/nls/test\_newton.py](https://github.com/FEniCS/dolfinx/blob/master/python/test/unit/nls/test_newton.py) and a corresponding dolfin-equivalent [Set krylov linear solver paramters in newton solver](https://fenicsproject.discourse.group/t/set-krylov-linear-solver-paramters-in-newton-solver/1070/9) are also good pointers on how to setup your problem/solver and preconditioner.

My personal experience: Newton with a line search and a good preconditioner (e.g., AMG for hyperelasticity) should be pretty robust and scale well for larger problems. You can use CG as the Krylov solver if your system is SPD. Direct solvers (even MUMPS, SUPERLU\_DIST) will run out of memory for very large problems, and therefore unsuitable. For many problems, however, Newton is not a good choice and you have to go with a gradient-descent approach which has the disadvantage of being horribly slow.

Yet another alternative for Newton: [http://www.lmm.jussieu.fr/~corrado/articles/cm-a16-FarMau.pdf](http://www.lmm.jussieu.fr/~corrado/articles/cm-a16-FarMau.pdf), for variational phase-field, which is also a highly nonlinear and non-convex problem.

---

_[View the full topic](https://fenicsproject.discourse.group/t/conjugate-gradient-solver-for-nonlinear-variational-problem/4707)._
