-
Notifications
You must be signed in to change notification settings - Fork 71
Add custom Newton's method example #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks perfect! Thanks for putting it together @jorgensd
It would be a good resource for anyone trying to implement their own Newton's method/nonlinear solver
# Compute norm of update | ||
correction_norm = dx.vector.norm(0) | ||
print(f"Iteration {i}: Correction norm {correction_norm}") | ||
if correction_norm < 1e-10: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is fine too, but shouldn't one check the norm of L
for a termination criterion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see that it is verified further down the line that L.norm(0)
is indeed small. Either way it fine!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many ways of terminering a Newton solver. I might add a section on that later, as one could Also compute the residual of the Newton solver (Which is different to L(uh), if uh does not satisfy the boundary condition).
dx_norm.append(correction_norm) | ||
|
||
print(f"Iteration {i}: Correction norm {correction_norm}, L2 error: {L2_error[-1]}") | ||
if correction_norm < 1e-10: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing this corresponds to "incremental" as the convergence_criterion
when using an inbuilt newton solver.
[Update] Indeed it is!
Addresses #60. @bhaveshshrimali could you have a look and see what you think?