Uncovering cause of non-convergence

I have some code I made for Fenics legacy a couple of years ago. A translation to Fenicsx is not converging. I have checked it over a thousand times. It is a rather large, non-linear, monolithic problem with 4 or 6 fields. I suspect I have made a mistake and its not well-defined. I’ve tried reducing the relative tolerance to a ridiculous values. This is about a week of going crazy. I have the problem working in a 4-field setup and when I extend to six relatively trivially (using determinant of one field as a driving force) it just fails (not one solved timestep).

Direct vs iterative solver makes no difference.

Is there a way to inspect this in ufl? Presumably the jacobian/tangent matrix of the problem is singular somewhere, even symbolically. Or how would one narrow this down? The non-convergence message from PETSc is for obvious reasons not very revealing.

Without having the problem at hand, it’s hard to give guidance. The first thing you should check is that if you assemble the residual F, the norm should be the same (at least for lower order elements). You can also cap the number of newton iterations at 1 to see how the Newton solver is behaving.

Thanks for the tip.

In old fenics this means my residual F can be evaluated by:

fenics.assemble(dolfin.fem.form.Form(F))

whereas in fenicsx it would be

dolfinx.fem.assemble_vector( dolfinx.fem.form(F))

is that what you meant?

The new version actually has NaNs in the array.

Then you likely haven’t set the initial guess/initial condition of the system correctly. Please provide a reproducible example.

No worries. It will take me some time. Thanks