# How to solve variational problem by iteration methods

**URL:** <https://fenicsproject.discourse.group/t/how-to-solve-variational-problem-by-iteration-methods/9947>\
**Category:** General\
**Created:** [December 12, 2022, 2:55am UTC](https://fenicsproject.discourse.group/t/how-to-solve-variational-problem-by-iteration-methods/9947 "2022-12-12T02:55:29Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![adamson-lkx](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/adamson-lkx/32/4497_2.png) [@adamson-lkx](https://fenicsproject.discourse.group/u/adamson-lkx)\
**Post date:** [December 13, 2022, 2:41am UTC](https://fenicsproject.discourse.group/t/how-to-solve-variational-problem-by-iteration-methods/9947/7 "2022-12-13T02:41:23Z")

</div>

Actually, I’m trying to solve the equation in the from of “(B-rC)w=Bv” based on the ‘cg’ iteration method with the preconditioner ‘ilu’. In the equation, B is a 307724 \* 307724 PETScMatrix, and the corresponding code is:

```python
import dolfin as df

D = df.PETScMatrix(B.mat() - C.mat() * r[j])
solver = df.PETScKrylovSolver("cg", "ilu")
solver.parameters["absolute_tolerance"] = 1e-17
solver.parameters["maximum_iterations"] = 10000

```

After running the code, it reminded me an error shown in the figure.

 ![2022-12-13 10-35-03屏幕截图](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/a/a3cbc68be83757c065ae58d97665e636efa94a0e.png)  
So I’m thinking whether there is some parameters are set incorrectly or some other parameters like ‘Relaxation factor’ are missed to be set. So I wonder to know all Solver.parameters that should be set in such occasion.  
Thanks ahead!

---

_[View the full topic](https://fenicsproject.discourse.group/t/how-to-solve-variational-problem-by-iteration-methods/9947)._
