Inconsistency between bilinear and residual solve
Hello all, I'm solving a system of pdes that are linear in (n+1) terms (in time disretised system). When I write the equations in Firedrake as a bilinear form and solve using: ... solve(a == L, out_u, bcs=[bc0, bc1, bc2, bc3], solver_parameters={'pc_type': 'lu', 'pc_factor_mat_solver_package': 'mumps'}) I get a stable (energy dissipative) scheme, everything seems to be working fine. If I reformulate the equations so that I am solving the residual form: ... solve(F == 0, u, bcs=[bc0, bc1, bc2, bc3],solver_parameters={'pc_type': 'lu', 'pc_factor_mat_solver_package': 'mumps'} ) all other things remainimg equal; the scheme breaks down after a number of timesteps, and throws an exception: Traceback (most recent call last): File "NSCH_residual_form.py", line 149, in <module> solve(F(u,u0,u,u0,W,n,myparameters) == 0, u, bcs=[bc0, bc1, bc2, bc3],solver_parameters={'pc_type': 'lu', 'pc_factor_mat_solver_package': 'mumps'} ) # File "/home/cserv1_a/apps/install/firedrake/2016-03-el7/firedrake/lib/python2.7/site-packages/firedrake/solving.py", line 120, in solve _solve_varproblem(*args, **kwargs) File "/home/cserv1_a/apps/install/firedrake/2016-03-el7/firedrake/lib/python2.7/site-packages/firedrake/solving.py", line 164, in _solve_varproblem solver.solve() File "<decorator-gen-295>", line 2, in solve File "/home/cserv1_a/apps/install/firedrake/2016-03-el7/firedrake/lib/python2.7/site-packages/pyop2/profiling.py", line 203, in wrapper return f(*args, **kwargs) File "/home/cserv1_a/apps/install/firedrake/2016-03-el7/firedrake/lib/python2.7/site-packages/firedrake/variational_solver.py", line 190, in solve solving_utils.check_snes_convergence(self.snes) File "/home/cserv1_a/apps/install/firedrake/2016-03-el7/firedrake/lib/python2.7/site-packages/firedrake/solving_utils.py", line 62, in check_snes_convergence %s""" % (snes.getIterationNumber(), msg)) RuntimeError: Nonlinear solve failed to converge after 17 nonlinear iterations. Reason: DIVERGED_LINE_SEARCH Additionally, the results between the two methods are inconsistent (particularly the min, max ranges). What can I do to fix that? The scripts and pdf containing weak forms can be found on bitbucket: https://bitbucket.org/fryderyk216/navierstokes/src/9f0814f99fe23fa57ead87012... Best wishes, Fryderyk
Update: In the residual form case I tried: try: solve(F(u,u0,u,u0,W,n,myparameters) == 0, u, bcs=[bc0, bc1, bc2, bc3],solver_parameters={'pc_type': 'lu', 'pc_factor_mat_solver_package': 'mumps'} ) # except RuntimeError: pass that works in the sense that the exception is no longer a problem. However that slight inconsistency in results is still there. Is that to be expected because of the different solvers? If that is the case, how can one minimise that difference? Thanks, Fryderyk ________________________________ From: firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> on behalf of Fryderyk Wilczynski <scfw@leeds.ac.uk> Sent: 02 May 2016 09:44:16 To: firedrake@imperial.ac.uk Subject: [firedrake] Inconsistency between bilinear and residual solve Hello all, I'm solving a system of pdes that are linear in (n+1) terms (in time disretised system). When I write the equations in Firedrake as a bilinear form and solve using: ... solve(a == L, out_u, bcs=[bc0, bc1, bc2, bc3], solver_parameters={'pc_type': 'lu', 'pc_factor_mat_solver_package': 'mumps'}) I get a stable (energy dissipative) scheme, everything seems to be working fine. If I reformulate the equations so that I am solving the residual form: ... solve(F == 0, u, bcs=[bc0, bc1, bc2, bc3],solver_parameters={'pc_type': 'lu', 'pc_factor_mat_solver_package': 'mumps'} ) all other things remainimg equal; the scheme breaks down after a number of timesteps, and throws an exception: Traceback (most recent call last): File "NSCH_residual_form.py", line 149, in <module> solve(F(u,u0,u,u0,W,n,myparameters) == 0, u, bcs=[bc0, bc1, bc2, bc3],solver_parameters={'pc_type': 'lu', 'pc_factor_mat_solver_package': 'mumps'} ) # File "/home/cserv1_a/apps/install/firedrake/2016-03-el7/firedrake/lib/python2.7/site-packages/firedrake/solving.py", line 120, in solve _solve_varproblem(*args, **kwargs) File "/home/cserv1_a/apps/install/firedrake/2016-03-el7/firedrake/lib/python2.7/site-packages/firedrake/solving.py", line 164, in _solve_varproblem solver.solve() File "<decorator-gen-295>", line 2, in solve File "/home/cserv1_a/apps/install/firedrake/2016-03-el7/firedrake/lib/python2.7/site-packages/pyop2/profiling.py", line 203, in wrapper return f(*args, **kwargs) File "/home/cserv1_a/apps/install/firedrake/2016-03-el7/firedrake/lib/python2.7/site-packages/firedrake/variational_solver.py", line 190, in solve solving_utils.check_snes_convergence(self.snes) File "/home/cserv1_a/apps/install/firedrake/2016-03-el7/firedrake/lib/python2.7/site-packages/firedrake/solving_utils.py", line 62, in check_snes_convergence %s""" % (snes.getIterationNumber(), msg)) RuntimeError: Nonlinear solve failed to converge after 17 nonlinear iterations. Reason: DIVERGED_LINE_SEARCH Additionally, the results between the two methods are inconsistent (particularly the min, max ranges). What can I do to fix that? The scripts and pdf containing weak forms can be found on bitbucket: https://bitbucket.org/fryderyk216/navierstokes/src/9f0814f99fe23fa57ead87012... Best wishes, Fryderyk
On 02/05/16 09:44, Fryderyk Wilczynski wrote:
Hello all,
I'm solving a system of pdes that are linear in (n+1) terms (in time disretised system).
When I write the equations in Firedrake as a bilinear form and solve using:
...
solve(a == L, out_u, bcs=[bc0, bc1, bc2, bc3], solver_parameters={'pc_type': 'lu', 'pc_factor_mat_solver_package': 'mumps'})
I get a stable (energy dissipative) scheme, everything seems to be working fine.
If I reformulate the equations so that I am solving the residual form:
...
solve(F == 0, u, bcs=[bc0, bc1, bc2, bc3],solver_parameters={'pc_type': 'lu', 'pc_factor_mat_solver_package': 'mumps'} )
all other things remainimg equal; the scheme breaks down after a number of timesteps, and throws an exception:
If your formulation is actually linear, then these two (especially with an LU solver) should be equivalent. The fact that they're not suggests that maybe your problem as formulated has some nonlinearity that it shouldn't (I think your timestepping scheme results in a linear formulation) and as the system evolves this gets larger. Although eyeballing the formulation it doesn't look like this is the case. That they are not indicates that, possibly, they are not. Can you try some of the advice on debugging convergence failures we have here: http://firedrakeproject.org/solving-interface.html#debugging-convergence-fai... Moreover, something funky is going on. I don't know when your residual formulation breaks down, but I ran it for a while here (up to t=0.5) and had no problems. Additionally, if I refactor your bilinear form code such that I use a LinearVariationalProblem/LinearVariationalSolver pair. The only difference in this case being that you don't rebuild the operator and preconditioner on every solve, then the bilinear formulation blows up at t=0.245. So not sure! Cheers, Lawrence
participants (2)
- 
                
                Fryderyk Wilczynski
- 
                
                Lawrence Mitchell