Hello,
I have a nonlinear variational problem and I am using legacy Fenics. I want to have a list of the available solvers for a nonlinear problem. I checked the existing posts, but it is quite unclear how to get this list.
What is the right command to call a list of solvers which yields a list of solver names, from which I can select a name name_of_the_solver that I can substitute in
<Parameter set "nonlinear_variational_solver" containing 6 parameter(s) and parameter set(s)>
nonlinear_variational_solver | type value range access change
------------------------------------------------------------------------------
nonlinear_solver | string newton [newton,snes] 0 0
print_matrix | bool 0 Not set 0 0
print_rhs | bool 0 Not set 0 0
symmetric | bool 0 Not set 0 0
<Parameter set "newton_solver" containing 11 parameter(s) and parameter set(s)>
newton_solver | type value range access change
---------------------------------------------------------------------
absolute_tolerance | double 0.000000 Not set 0 0
convergence_criterion | string residual Not set 0 0
error_on_nonconvergence | bool 1 Not set 0 0
linear_solver | string default Not set 0 0
maximum_iterations | int 50 Not set 0 0
preconditioner | string default Not set 0 0
relative_tolerance | double 0.000000 Not set 0 0
relaxation_parameter | double <unset> Not set 0 0
report | bool 1 Not set 0 0
<Parameter set "krylov_solver" containing 8 parameter(s) and parameter set(s)>
krylov_solver | type value range access change
--------------------------------------------------------------------
absolute_tolerance | double <unset> Not set 0 0
divergence_limit | double <unset> Not set 0 0
error_on_nonconvergence | bool <unset> Not set 0 0
maximum_iterations | int <unset> Not set 0 0
monitor_convergence | bool <unset> Not set 0 0
nonzero_initial_guess | bool <unset> Not set 0 0
relative_tolerance | double <unset> Not set 0 0
report | bool <unset> Not set 0 0
<Parameter set "lu_solver" containing 3 parameter(s) and parameter set(s)>
lu_solver | type value range access change
--------------------------------------------------
report | bool 1 Not set 0 0
symmetric | bool 0 Not set 0 0
verbose | bool 0 Not set 0 0
<Parameter set "snes_solver" containing 14 parameter(s) and parameter set(s)>
snes_solver | type value range access change
----------------------------------------------------------------------------------------------------
absolute_tolerance | double 0.000000 Not set 0 0
error_on_nonconvergence | bool 1 Not set 0 0
line_search | string basic [basic,bt,cp,l2,nleqerr] 0 0
linear_solver | string default Not set 0 0
maximum_iterations | int 50 Not set 0 0
maximum_residual_evaluations | int 2000 Not set 0 0
method | string default Not set 0 0
preconditioner | string default Not set 0 0
relative_tolerance | double 0.000000 Not set 0 0
report | bool 1 Not set 0 0
sign | string default [default,nonnegative,nonpositive] 0 0
solution_tolerance | double 0.000000 Not set 0 0
<Parameter set "krylov_solver" containing 8 parameter(s) and parameter set(s)>
krylov_solver | type value range access change
--------------------------------------------------------------------
absolute_tolerance | double <unset> Not set 0 0
divergence_limit | double <unset> Not set 0 0
error_on_nonconvergence | bool <unset> Not set 0 0
maximum_iterations | int <unset> Not set 0 0
monitor_convergence | bool <unset> Not set 0 0
nonzero_initial_guess | bool <unset> Not set 0 0
relative_tolerance | double <unset> Not set 0 0
report | bool <unset> Not set 0 0
<Parameter set "lu_solver" containing 3 parameter(s) and parameter set(s)>
lu_solver | type value range access change
--------------------------------------------------
report | bool 1 Not set 0 0
symmetric | bool 0 Not set 0 0
verbose | bool 0 Not set 0 0
$ python3 -c "from dolfin import *; info(NonlinearVariationalSolver.default_parameters(), True)"
<Parameter set "nonlinear_variational_solver" containing 6 parameter(s) and parameter set(s)>
nonlinear_variational_solver | type value range access change
------------------------------------------------------------------------------
nonlinear_solver | string newton [newton,snes] 0 0
print_matrix | bool 0 Not set 0 0
print_rhs | bool 0 Not set 0 0
symmetric | bool 0 Not set 0 0
<Parameter set "newton_solver" containing 11 parameter(s) and parameter set(s)>
newton_solver | type value range access change
---------------------------------------------------------------------
absolute_tolerance | double 0.000000 Not set 0 0
convergence_criterion | string residual Not set 0 0
error_on_nonconvergence | bool 1 Not set 0 0
linear_solver | string default Not set 0 0
maximum_iterations | int 50 Not set 0 0
preconditioner | string default Not set 0 0
relative_tolerance | double 0.000000 Not set 0 0
relaxation_parameter | double <unset> Not set 0 0
report | bool 1 Not set 0 0
<Parameter set "krylov_solver" containing 8 parameter(s) and parameter set(s)>
krylov_solver | type value range access change
--------------------------------------------------------------------
absolute_tolerance | double <unset> Not set 0 0
divergence_limit | double <unset> Not set 0 0
error_on_nonconvergence | bool <unset> Not set 0 0
maximum_iterations | int <unset> Not set 0 0
monitor_convergence | bool <unset> Not set 0 0
nonzero_initial_guess | bool <unset> Not set 0 0
relative_tolerance | double <unset> Not set 0 0
report | bool <unset> Not set 0 0
<Parameter set "lu_solver" containing 3 parameter(s) and parameter set(s)>
lu_solver | type value range access change
--------------------------------------------------
report | bool 1 Not set 0 0
symmetric | bool 0 Not set 0 0
verbose | bool 0 Not set 0 0
<Parameter set "snes_solver" containing 14 parameter(s) and parameter set(s)>
snes_solver | type value range access change
----------------------------------------------------------------------------------------------------
absolute_tolerance | double 0.000000 Not set 0 0
error_on_nonconvergence | bool 1 Not set 0 0
line_search | string basic [basic,bt,cp,l2,nleqerr] 0 0
linear_solver | string default Not set 0 0
maximum_iterations | int 50 Not set 0 0
maximum_residual_evaluations | int 2000 Not set 0 0
method | string default Not set 0 0
preconditioner | string default Not set 0 0
relative_tolerance | double 0.000000 Not set 0 0
report | bool 1 Not set 0 0
sign | string default [default,nonnegative,nonpositive] 0 0
solution_tolerance | double 0.000000 Not set 0 0
<Parameter set "krylov_solver" containing 8 parameter(s) and parameter set(s)>
krylov_solver | type value range access change
--------------------------------------------------------------------
absolute_tolerance | double <unset> Not set 0 0
divergence_limit | double <unset> Not set 0 0
error_on_nonconvergence | bool <unset> Not set 0 0
maximum_iterations | int <unset> Not set 0 0
monitor_convergence | bool <unset> Not set 0 0
nonzero_initial_guess | bool <unset> Not set 0 0
relative_tolerance | double <unset> Not set 0 0
report | bool <unset> Not set 0 0
<Parameter set "lu_solver" containing 3 parameter(s) and parameter set(s)>
lu_solver | type value range access change
--------------------------------------------------
report | bool 1 Not set 0 0
symmetric | bool 0 Not set 0 0
verbose | bool 0 Not set 0 0
As I asked in the original post, if I replace name_of_the_solver with a name obtained from this list, e.g., krylov_solver, as follows solve(F == 0, z_omega, bcs, solver_parameters={"krylov_solver": {"relative_tolerance": 1e-6}}), I get
$ python3 example.py
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Traceback (most recent call last):
File "example.py", line 132, in <module>
solve(F == 0, z_omega, bcs, solver_parameters={"krylov_solver": {"relative_tolerance": 1e-6}})
File "/usr/local/lib/python3.6/dist-packages/dolfin/fem/solving.py", line 220, in solve
_solve_varproblem(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/dolfin/fem/solving.py", line 265, in _solve_varproblem
solver.parameters.update(solver_parameters)
File "/usr/local/lib/python3.6/dist-packages/dolfin/parameter/__init__.py", line 38, in update
self[key].update(params[key])
File "/usr/local/lib/python3.6/dist-packages/dolfin/parameter/__init__.py", line 27, in __getitem__
raise RuntimeError("Invalid parameter: {}".format(key))
Krylov solver as an input argument for a non-linear problem doesn’t make sense.
You would have to choose: snes or newton and user their appropriate sub category for krylov solver.
Thank you. May you please tell me how to get a complete list of the values for each field? For instance, if I want to know all possible values for preconditioner of newton_solver.