Your code is much too long for me to look in detail. See for example how to create a MWE.
At a glance of the error message though it looks like you’re trying to solve a nonlinear problem as if it were linear. Somewhere you’re probably computing abs(u)
where u
is a ufl.TrialFunction
or ufl.TestFunction
. Clearly this doesn’t make sense and likely the reason you get the error.