Newton solver with Gridfunction as nonlinear term

Dear everyone,

I am working on a code that requires a nonlinear pde solve, where the nonlinearity is defined by a composition function that returns a Gridfunction. Trying the ngsolve Newton method the solve with the composition function was incorrect, which forced me to implement a slower own Newton solver.

Below is a code that displays the error we obtain when combining the composition with the ngsolve newton solver:

newton_compostion.ipynb (4.3 KB)

Is there an explanation or simple workaround for this issue?