Default value for NewtonSolver relaxation parameter

Issue #836 invalid
Miguel Salazar created an issue

I noticed that in NewtonSolver.cpp:57 there is not an assigned default value to the parameter 'relaxation_parameter' like it used to. Now the following code returns None. Is there a reason for this behavior? Thanks.

import dolfin
newton_parameters = dolfin.NewtonSolver.default_parameters()
newton_parameters['relaxation_parameter'] # returns nothing

Comments (6)

  1. Jan Blechta

    That's correct. Value can be set by parameter but preferred is to access it by get/set_relaxation_parameter() members. None means unset which defaults, of course, to 1.

  2. Miguel Salazar reporter

    I see, then I will have to change the way I use it. Right now I would like to have the output of newton_parameters['relaxation_parameter'] above to be 1.0, not None. I guess I will just add

    import dolfin
    newton_parameters = dolfin.NewtonSolver.default_parameters()
    relax_param = newton_parameters['relaxation_parameter']
    if relax_param is None:
        relax_param = 1.0
    

    Thanks

  3. Jan Blechta

    You can use NewtonSolver::get_relaxation_parameter() which will yield 1.0 even when the parameter is unset. Or you can set the parameter to 1.0.

  4. Log in to comment