Skip to content

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

Merged
merged 6 commits into from
Jul 3, 2022

Conversation

jorgensd
Copy link
Owner

Addresses #60. @bhaveshshrimali could you have a look and see what you think?

Copy link

@bhaveshshrimali bhaveshshrimali left a 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:

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.

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!

Copy link
Owner Author

@jorgensd jorgensd Jul 1, 2022

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:

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!

@jorgensd jorgensd merged commit ea20560 into dokken/jupyterbook Jul 3, 2022
@jorgensd jorgensd deleted the dokken/nonlinear-example branch July 3, 2022 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants