This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to set NonlinearVariationalSolver tolerance, what are solver options?

+4 votes

How to set NonlinearVariationalSolver tolerance, what are solver options? I look at NonlinearVariationalProblem/NonlinearVariationalSolver and see no tolerance or solver selection options. Are there any and how to set them?

asked Nov 5, 2014 by Panda FEniCS Novice (440 points)

1 Answer

+3 votes

Here are some relevant settings, taken from the Fenics book, Section 1.2:

problem = NonlinearVariationalProblem(F, u_, bcs, J)
solver = NonlinearVariationalSolver(problem)
prm = solver.parameters
prm["newton_solver"]["absolute_tolerance"] = 1E-8
prm["newton_solver"]["relative_tolerance"] = 1E-7
prm["newton_solver"]["maximum_iterations"] = 25
prm["newton_solver"]["relaxation_parameter"] = 1.0
if iterative_solver:
    prm["linear_solver"] = "gmres"
    prm["preconditioner"] = "ilu"
    prm["krylov_solver"]["absolute_tolerance"] = 1E-9
    prm["krylov_solver"]["relative_tolerance"] = 1E-7
    prm["krylov_solver"]["maximum_iterations"] = 1000
    prm["krylov_solver"]["gmres"]["restart"] = 40
    prm["krylov_solver"]["preconditioner"]["ilu"]["fill_level"] = 0

solver.solve()
answered Feb 10, 2015 by konstantin FEniCS Novice (900 points)
...