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/9f0814f99fe23fa57ead87012a554210678a7f50/Inconsistency/?at=master


Best wishes,

Fryderyk