Something is wrong with the Newton system in the last step. You can see that the LU residual is steadily increasing. At the last step it is 10^-6. The iteration appears to be approaching a singular Jacobian. This seems like a formulation problem. Thanks, Matt On Sun, Jun 27, 2021 at 11:24 AM Bhavesh Shrimali < bhavesh.shrimali@gmail.com> wrote:
I think I mistakenly clicked reply instead of reply all. Attached is my response:
--
Thanks Matt,
Thanks for the swift response. These are the logs with basic, backtracking, cp and nleqerr. If I don't specify 'snes_linesearch_type' it defaults to 'basic'. At least that's what I could gather from the log.
- `cp` seemingly diverges the fastest. Of course I haven't touched the other options. - `nleqerr` goes the furthest I believe, but not that far from `basic` or `bt`.
My concern was that since the forms are essentially the same, and I am passing "seemingly" the same parameters in FEniCS and Firedrake (both of which are using PETSc's SNES), what is it that is different which causes the solver to fail in one but not the other.
Edit: Just saw Ed's message. Indeed it defaults to `basic`
For definiteness this was the dictionary of solver parameters I am passing to NLVS in Firedrake
solver_params={ "snes_type": "newtonls", "ksp_type": "preonly", "pc_type": "lu", "snes_max_it": 100, # "snes_stol": 1.e-6, # "snes_rtol": 1.e-6, # "snes_atol": 1.e-6, "snes_view": None, # "ksp_atol": 1.e-10, # "ksp_rtol":1.e-8, "ksp_view": None, "snes_linesearch_type": "bt", "snes_converged_reason": None, "snes_monitor": None, "ksp_converged_reason": None, "ksp_monitor_true_residual": None }
On Sun, 27 Jun 2021 at 11:22, Bhavesh Shrimali <bhavesh.shrimali@gmail.com> wrote:
Thanks Matt,
Thanks for the swift response. These are the logs with basic, backtracking, cp and nleqerr. If I don't specify 'snes_linesearch_type' it defaults to 'basic'. At least that's what I could gather from the log.
- `cp` seemingly diverges the fastest. Of course I haven't touched the other options. - `nleqerr` goes the furthest I believe, but not that far from `basic` or `bt`.
My concern was that since the forms are essentially the same, and I am passing "seemingly" the same parameters in FEniCS and Firedrake (both of which are using PETSc's SNES), what is it that is different which causes the solver to fail in one but not the other.
Edit: Just saw Ed's message. Indeed it defaults to `basic`
For definiteness this was the dictionary of solver parameters I am passing to NLVS in Firedrake
solver_params={ "snes_type": "newtonls", "ksp_type": "preonly", "pc_type": "lu", "snes_max_it": 100, # "snes_stol": 1.e-6, # "snes_rtol": 1.e-6, # "snes_atol": 1.e-6, "snes_view": None, # "ksp_atol": 1.e-10, # "ksp_rtol":1.e-8, "ksp_view": None, "snes_linesearch_type": "bt", "snes_converged_reason": None, "snes_monitor": None, "ksp_converged_reason": None, "ksp_monitor_true_residual": None }
On Sun, 27 Jun 2021 at 06:00, Matthew Knepley <knepley@gmail.com> wrote:
Give
-snes_view -snes_converged_reason -snes_monitor -ksp_converged_reason -ksp_monitor_true_residual
and send all the output. That way I might be able to see what is happening when you do not converge. Also, line search 'basic' is not a good choice usually. I would either use the default, or 'cp', or maybe 'nleqerr' that Patrick added.
Thanks,
Matt
On Sat, Jun 26, 2021 at 10:14 PM Bhavesh Shrimali < bhavesh.shrimali@gmail.com> wrote:
Hi everyone,
I am trying to understand the usage of solver parameters that are passed to the NonlinearVariationalSolver in firedrake. In order to do some tests, I decided to reproduce some of my previous calculations done in FEniCS for nonlinear viscoelasticity. In old dolfin, I had the following for solver parameters to be passed to PETSc's SNES:
snes_solver_parameters = {"nonlinear_solver": "snes", "snes_solver": {"linear_solver": "lu", "maximum_iterations": 50, "report": True, "line_search": 'basic', "error_on_nonconvergence": False, "relative_tolerance": 1e-7, "absolute_tolerance": 1e-8}} ... ... solver = NonlinearVariationalSolver(problem) solver.parameters.update(snes_solver_parameters)
Now as I understand, in Firedrake the options passed to the solver are consistent with the corresponding names in PETSc (correct me if I am wrong), and therefore I did:
solver_params={ "snes_type": "newtonls", "ksp_type": "preonly", "pc_type": "lu", "snes_max_it": 100, "snes_rtol": 1.e-7, "snes_atol": 1.e-8, "snes_view": None, "ksp_atol": 1.e-10, # not needed? "ksp_rtol":1.e-8, "ksp_view": None, "snes_linesearch_type": "basic", "snes_no_convergence_test": 1 # this has no effect } solver = NonlinearVariationalSolver(problem, solver_parameters=solver_params)
However, for some reason, I am unable to get the solver to converge when trying to solve the exact same problem as FEniCS. I experimented with different quadrature degrees as well as tweaked the solver parameters for SNES to best match what I am doing in dolfin. I understand that the form compiler is different hence the precise code that is generated may be different (I am not an expert on code generation) even though the python scripts may look similar due to UFL syntax.
In fact the weird part is that the solver seems to converge fine till a certain point in my input (loading). You can see this in the plot below where I plot the final stress-stretch relation obtained at a point in my domain from dolfin and firedrake..
[image: firedrake_vs_fenics.png]
I have marked the abscissa beyond which the solver fails to converge in Firedrake. The complete codes are here: https://github.com/bhaveshshrimali/comparingFiredrakeFEniCS
I tried setting the option `snes_no_convergence_test` to 1/True but that had no effect as the SNES solver still diverges with ` DIVERGED_DTOL`. In the end I put the call to solve inside a try/catch block to at least be able to see the solution till that point. And it surprisingly is accurate till that point.
Would anyone have any clue of what could be going wrong? I wouldn't expect that you go through the entire code(s) as that could be fairly long, but any pointers would be helpful :)
I am using firedrake via Docker on windows.
Thanks
--
_______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
--
*Bhavesh Shrimali* *Ph.D. Student, **Civil and Environmental Engineering,*
*University of Illinois Urbana-Champaign*
*Champaign, IL, United States*
*Email : bshrima2@illinois.edu <bshrima2@illinois.edu>* *Web : **https://bhaveshshrimali.github.io/ <https://bhaveshshrimali.github.io/>*
--
*Bhavesh Shrimali* *Ph.D. Student, **Civil and Environmental Engineering,*
*University of Illinois Urbana-Champaign*
*Champaign, IL, United States*
*Email : bshrima2@illinois.edu <bshrima2@illinois.edu>* *Web : **https://bhaveshshrimali.github.io/ <https://bhaveshshrimali.github.io/>* _______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>