Define the number of iterations for the Newton-Raphson algo

Asked by Nicolas Verdon

Hi,

I've a problem.
I am using the nonlinear solver from dolfin from the example of hyperelasticity

solve(F == 0, u, bc, J=J,
      form_compiler_parameters=ffc_options)

When I change the parameters, I have a problem of convergence of the Newton algorithm which seems to be fixed at a maximum number of iterations =10

I would simply know the syntax for setting up the tolerance, and the max number of iterations in the nonlinear solver.

Thanks in advance

Nicolas Verdon

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Chaffra Affouda
Solved:
Last query:
Last reply:
Revision history for this message
Best Chaffra Affouda (chaffra) said :
#1

You can try something like this:

problem = NonlinearVariationalProblem(F, u, bcs=None, J=J, form_compiler_parameters=ffc_options)
solver = NonlinearVariationalSolver(problem)
solver.parameters['newton_solver']['maximum_iterations'] = 20

Revision history for this message
Johan Hake (johan-hake) said :
#2

You can use:

 solve(F == 0, u, bc, J=J,
       form_compiler_parameters=ffc_options,
       solver_param=dict(newton_solver=dict(maximum_iterations=20)))

to get a full view of the parameters you can set you can look at the default
parameters for a NonlinearVariationalProblem

  solver_params = NonlinearVariationalProblem.default_params()
  info(solver_params, 1)
  solver_params.newton_solver.maximum_iterations = 20
  solve(F == 0, u, bc, J=J,
       form_compiler_parameters=ffc_options,
       solver_param=solver_params)

Johan

On Tuesday August 23 2011 07:25:54 Nicolas Verdon wrote:
> New question #168953 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/168953
>
> Hi,
>
>
> I've a problem.
> I am using the nonlinear solver from dolfin from the example of
> hyperelasticity
>
> solve(F == 0, u, bc, J=J,
> form_compiler_parameters=ffc_options)
>
> When I change the parameters, I have a problem of convergence of the Newton
> algorithm which seems to be fixed at a maximum number of iterations =10
>
> I would simply know the syntax for setting up the tolerance, and the max
> number of iterations in the nonlinear solver.
>
> Thanks in advance
>
>
> Nicolas Verdon

Revision history for this message
Johan Hake (johan-hake) said :
#3

I have now updated the docstring of solve so it should be easier to recognize
the available parameters to the underlying VariationalSolvers.

Johan

On Tuesday August 23 2011 07:25:54 Nicolas Verdon wrote:
> New question #168953 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/168953
>
> Hi,
>
>
> I've a problem.
> I am using the nonlinear solver from dolfin from the example of
> hyperelasticity
>
> solve(F == 0, u, bc, J=J,
> form_compiler_parameters=ffc_options)
>
> When I change the parameters, I have a problem of convergence of the Newton
> algorithm which seems to be fixed at a maximum number of iterations =10
>
> I would simply know the syntax for setting up the tolerance, and the max
> number of iterations in the nonlinear solver.
>
> Thanks in advance
>
>
> Nicolas Verdon

Revision history for this message
Nicolas Verdon (verdon-nicolas) said :
#4

Ok thanks for all your answers !

I have an additional question concerning this example of hyperelasticity..
In fact I just would like to evaluate the function F defined in the example as the derivative of the potential energy Pi

Pi = psi*dx - dot(B, u)*dx - dot(T, u)*ds
F = derivative(Pi, u, v)

at a given vector u1..

I don't know if it's possible and once again, thank you in advance for your fast reactivity !

Nicolas Verdon

Revision history for this message
Martin Sandve Alnæs (martinal) said :
#5

Niclas,
you do that simply by assigning the value of u1 to u before assembling F. F
is still defined in terms of u and keeps a reference to that concrete
function object.

Martin
Den 23. aug. 2011 20.05 skrev "Nicolas Verdon" <
<email address hidden>> følgende:
> Question #168953 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/168953
>
> Nicolas Verdon posted a new comment:
> Ok thanks for all your answers !
>
> I have an additional question concerning this example of hyperelasticity..
> In fact I just would like to evaluate the function F defined in the
example as the derivative of the potential energy Pi
>
> Pi = psi*dx - dot(B, u)*dx - dot(T, u)*ds
> F = derivative(Pi, u, v)
>
> at a given vector u1..
>
> I don't know if it's possible and once again, thank you in advance for
> your fast reactivity !
>
>
> Nicolas Verdon
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.

Revision history for this message
Nicolas Verdon (verdon-nicolas) said :
#6

Thanks Chaffra Affouda, that solved my question.