Jacobian matrix and residual - test cases and discrepancies

Dear all,

I am doing some tests with NGSolve and nonlinear case studies. I am playing a bit around adding my own jacobian.

I am running two test case studies, one using a.Apply(gfu.vec, res) to get the residual (testbis.py) and the other expressing directly the residual (test.py). It seems that there is a key difference that I do not grasp during the assembly and if possible I would need some help to understand what happens behind the hood explaining the difference that I get in the number of iteration of the Newton and result.

Best regards,

Frederic

testbis.py (1.7 KB)

test.py (1.7 KB)

Hi Frederic,

you need to assemble the linear form, res_nl.Assemble(), otherwise res_nl.vec is zero.
Then it should work. The values might not coincide because of different integration rules.

Best,
Michael

Dear Michael,

Thanks, indeed it seems that was the missing item. Now, the convergence is very similar as well as the results.

best,

Frederic