# When to use NonLinearVariationalSolver?

**URL:** <https://fenicsproject.discourse.group/t/when-to-use-nonlinearvariationalsolver/252>\
**Category:** variational formulation\
**Created:** [February 21, 2019, 1:29pm UTC](https://fenicsproject.discourse.group/t/when-to-use-nonlinearvariationalsolver/252 "2019-02-21T13:29:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raboynics](https://avatars.discourse-cdn.com/v4/letter/r/4bbf92/32.png) [@raboynics](https://fenicsproject.discourse.group/u/raboynics)\
**Post date:** [February 21, 2019, 1:29pm UTC](https://fenicsproject.discourse.group/t/when-to-use-nonlinearvariationalsolver/252/1 "2019-02-21T13:29:53Z")

</div>

In the FEniCS tutorial, a case of nonlinear Poisson equation is treated. Once the weak form has been found, the nonlinear problem is solved using solve().

However, I found a few examples (and there is a documentation) of “NonLinearVariationalProblem” and an associated solver. I can find no use of this in the FEniCS tutorial.

My question is, is there any reason to use NonlinearVariationalSolver.solve() instead of just solve()? What are the differences exactly? Should we use one over the other in specific problems? If so, which kind of problems? Why has the FEniCS tutorial focused on solve() rather than the other alternative?

---

<div class="post-metadata">

**Author:** ![cdaversin](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/cdaversin/32/44_2.png) [@cdaversin](https://fenicsproject.discourse.group/u/cdaversin)\
**Post date:** [February 21, 2019, 2:29pm UTC](https://fenicsproject.discourse.group/t/when-to-use-nonlinearvariationalsolver/252/2 "2019-02-21T14:29:52Z")

</div>

I suppose the non-linear Poisson example you mention is the one in `demo/documented/nonlinear-poisson/demo_nonlinear-poisson.py`.

The `solve(....)` function distinguishes two cases  
(case 1) : `solve(A == L, u, bc)` corresponds to a linear problem, and uses `LinearVariationalProblem` and `LinearVariationalSolver` .  
(case 2) : `solve(F==0, u, bc)` which corresponds to a non-linear problem, and uses `NonLinearVariationalProblem` and `NonLinearVariationalSolver` as :

```auto
# Create problem
problem = NonlinearVariationalProblem([...])
# Create solver and call solve
solver = NonlinearVariationalSolver(problem)
solver.parameters.update(solver_parameters)
solver.solve()

```

The example you mention is solved using `solve(F == 0, u, bc,...)` (case 2 above). So I guess the answer to your question is : there is no difference between `NonlinearVariationalSolver.solve()` and just `solve()`, `solve(F==0, u, bc, ...)` is just a “shortcut”

---

<div class="post-metadata">

**Author:** ![raboynics](https://avatars.discourse-cdn.com/v4/letter/r/4bbf92/32.png) [@raboynics](https://fenicsproject.discourse.group/u/raboynics)\
**Post date:** [February 21, 2019, 2:52pm UTC](https://fenicsproject.discourse.group/t/when-to-use-nonlinearvariationalsolver/252/3 "2019-02-21T14:52:56Z")

</div>

Thank you very much, I did not know this at all! That’s very informative.
