close to fixing my nonlinear QG solver
Hello Firedrakers, Thanks everyone for a very interesting Workshop. It was great to meet everyone that was able to attend and learn about all the diverse range of problems people are working on. I have a question to follow up on discussions from the workshop. I am not sure if this quite of question is appropriate for Slack so I thought I would send an email. If you prefer Slack I will happily go there next time. On Wednesday morning David pointed out that my nonlinear solver for the Quasi-Geostrophic model has a problem in that I computed the Laplacian of a field, which is one too many derivatives. I now know that's bad and think this could really fix up my convergence issues. Thanks David! I rewrote the problem in terms of a velocity, a vorticity and a streamfunction and coded it up. There are three fields instead of one so it is bigger but at least I don't get any double derivatives. I am pretty sure that the linear part is correct since the solution looks identical to what I had before. Unfortunately, after spending a lot of time on the nonlinear problem, I can't seem to get the syntax right. Even when I try a much simpler nonlinear term it still gives me the same error. The version that I have now can be found at the following link: https://github.com/francispoulin/firedrakeQG/blob/master/QG1L_Stommel_psiuq.... The error can be found below. I tried putting a Constant(0)* in front of the nonlinear term, like I think Lawrence showed me how to do, but I seemed to get the syntax wrong on that as well. The fact that Linear and Nonlinear firedrake fail to converge means that it's not even trying because I messed up something. Any advice on how I can fix up my syntax? Cheers, Francis $ python QG1L_Stommel_psiuq.py Linear firedrake_1_ solve did not converge due to DIVERGED_PCSETUP_FAILED iterations 0 PCSETUP_FAILED due to FACTOR_NUMERIC_ZEROPIVOT Nonlinear firedrake_1_ solve did not converge due to DIVERGED_LINEAR_SOLVE iterations 0 Traceback (most recent call last): File "QG1L_Stommel_psiuq.py", line 114, in <module> nonlinear_solver.solve() File "/home/fpoulin/software/firedrake/src/firedrake/firedrake/variational_solver.py", line 223, in solve solving_utils.check_snes_convergence(self.snes) File "/home/fpoulin/software/firedrake/src/firedrake/firedrake/solving_utils.py", line 160, in check_snes_convergence %s""" % (snes.getIterationNumber(), msg)) firedrake.exceptions.ConvergenceError: Nonlinear solve failed to converge after 0 nonlinear iterations. Reason: Inner linear solve failed to converge after 0 iterations with reason: unknown reason (petsc4py enum incomplete?), try with -snes_convered_reason and -ksp_converged_reason ------------------ Francis Poulin Associate Professor Department of Applied Mathematics University of Waterloo email: fpoulin@uwaterloo.ca Web: https://uwaterloo.ca/poulin-research-group/ Telephone: +1 519 888 4567 x32637
Hi Francis,
On 30 Mar 2017, at 02:50, Francis Poulin <fpoulin@uwaterloo.ca> wrote:
$ python QG1L_Stommel_psiuq.py Linear firedrake_1_ solve did not converge due to DIVERGED_PCSETUP_FAILED iterations 0 PCSETUP_FAILED due to FACTOR_NUMERIC_ZEROPIVOT
The PETSc LU by default doesn't do any pivoting, and you may have a zero on the diagonal somewhere? Try using mumps instead, by adding 'pc_factor_mat_solver_package': 'mumps' to your nonlinear solver options. Cheers, Lawrence
Hello Lawrence, Thanks for the suggestion. Now the options that are have are the following: nonlinear_solver = NonlinearVariationalSolver(nonlinear_problem, solver_parameters={ 'ksp_type':'preonly', 'ksp_monitor': True, 'matnest': False, 'mat_type': 'aij', 'pc_type':'lu', 'snes_converged_reason': True, 'ksp_converged_reason': True, 'pc_factor_mat_solver_package': 'mumps' }) Unfortunately, as you can read below, I still seem to get a similar error. I am almost certainly doing something silly, I just can't quite tell what that is. If you have other ideas please let me know and I will happy give them a try. Cheers, Francis $ python QG1L_Stommel_psiuq.py Linear firedrake_1_ solve did not converge due to DIVERGED_PCSETUP_FAILED iterations 0 PCSETUP_FAILED due to FACTOR_OUTMEMORY Nonlinear firedrake_1_ solve did not converge due to DIVERGED_LINEAR_SOLVE iterations 0 Traceback (most recent call last): File "QG1L_Stommel_psiuq.py", line 115, in <module> nonlinear_solver.solve() File "/home/fpoulin/software/firedrake/src/firedrake/firedrake/variational_solver.py", line 223, in solve solving_utils.check_snes_convergence(self.snes) File "/home/fpoulin/software/firedrake/src/firedrake/firedrake/solving_utils.py", line 160, in check_snes_convergence %s""" % (snes.getIterationNumber(), msg)) firedrake.exceptions.ConvergenceError: Nonlinear solve failed to converge after 0 nonlinear iterations. Reason: Inner linear solve failed to converge after 0 iterations with reason: unknown reason (petsc4py enum incomplete?), try with -snes_convered_reason and -ksp_converged_reason ------------------ Francis Poulin Associate Professor Department of Applied Mathematics University of Waterloo email: fpoulin@uwaterloo.ca Web: https://uwaterloo.ca/poulin-research-group/ Telephone: +1 519 888 4567 x32637 ________________________________________ From: firedrake-bounces@imperial.ac.uk [firedrake-bounces@imperial.ac.uk] on behalf of Lawrence Mitchell [lawrence.mitchell@imperial.ac.uk] Sent: Thursday, March 30, 2017 4:24 AM To: firedrake Subject: Re: [firedrake] close to fixing my nonlinear QG solver Hi Francis,
On 30 Mar 2017, at 02:50, Francis Poulin <fpoulin@uwaterloo.ca> wrote:
$ python QG1L_Stommel_psiuq.py Linear firedrake_1_ solve did not converge due to DIVERGED_PCSETUP_FAILED iterations 0 PCSETUP_FAILED due to FACTOR_NUMERIC_ZEROPIVOT
The PETSc LU by default doesn't do any pivoting, and you may have a zero on the diagonal somewhere? Try using mumps instead, by adding 'pc_factor_mat_solver_package': 'mumps' to your nonlinear solver options. Cheers, Lawrence _______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake
Hi Francis, sorry, I now saw your problem. You do: soln1.assign(soln0) psi1, u1, q1 = soln1.split() Gnon = F(psi1, u1, q1) You've been bitten by the "wrong split" bug!! ARGH. Only use function.split() for output. If you're going to use the split values in a form, you need to use "split(function)" If you replace your lines: psi1, u1, q1 = soln1.split() Gnon = ... with: psi1, u1, q1 = split(soln1) Gnon = ... psi1, u1, q1 = soln1.split() Everything works. Lawrence
Houston, we have convergence! Thank you for the help Lawrence. I did see there were emails about the split passed around last week, which I clearly should have read more closely. Now that I have convergence on a course grid I will test a finder grid and let you know how robust this is. Cheers, Francis ------------------ Francis Poulin Associate Professor Department of Applied Mathematics University of Waterloo email: fpoulin@uwaterloo.ca Web: https://uwaterloo.ca/poulin-research-group/ Telephone: +1 519 888 4567 x32637 ________________________________________ From: firedrake-bounces@imperial.ac.uk [firedrake-bounces@imperial.ac.uk] on behalf of Lawrence Mitchell [lawrence.mitchell@imperial.ac.uk] Sent: Thursday, March 30, 2017 7:14 AM To: firedrake@imperial.ac.uk Subject: Re: [firedrake] close to fixing my nonlinear QG solver Hi Francis, sorry, I now saw your problem. You do: soln1.assign(soln0) psi1, u1, q1 = soln1.split() Gnon = F(psi1, u1, q1) You've been bitten by the "wrong split" bug!! ARGH. Only use function.split() for output. If you're going to use the split values in a form, you need to use "split(function)" If you replace your lines: psi1, u1, q1 = soln1.split() Gnon = ... with: psi1, u1, q1 = split(soln1) Gnon = ... psi1, u1, q1 = soln1.split() Everything works. Lawrence
participants (2)
- 
                
                Francis Poulin
- 
                
                Lawrence Mitchell