Skip to content
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

Adjoint variational solver #3723

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open

Adjoint variational solver #3723

wants to merge 48 commits into from

Conversation

Ig-dolci
Copy link
Contributor

@Ig-dolci Ig-dolci commented Aug 4, 2024

Description

This PR updates the adjoint solver by introducing a Linear Variational Solver to handle adjoint equations. It also addresses an issue arising when the Jacobian is constant and the tape recomputation is required after updating an equation parameter (a common scenario in optimisation solvers).

I have executed tests to compare computation time and memory usage between the master branch and this current branch. The tests consider three time-dependent cases:

  1. Forward solver: Burger equation

  2. Forward solver: Navier-Stokes equations

  3. Forward solver: Second-order wave equation

The test scripts are available here, and the plots comparing this branch with the master branch are shown below.

Feel free to add your review to anyone interested in this PR.

burgers
navier_stokes
wave_equation

@Ig-dolci Ig-dolci changed the title Adjoint linear variational solver Adjoint variational solver Aug 4, 2024
@Ig-dolci Ig-dolci marked this pull request as ready for review August 6, 2024 13:54
firedrake/adjoint_utils/blocks/solving.py Outdated Show resolved Hide resolved
firedrake/adjoint_utils/blocks/solving.py Outdated Show resolved Hide resolved
firedrake/adjoint_utils/blocks/solving.py Outdated Show resolved Hide resolved
firedrake/adjoint_utils/blocks/solving.py Show resolved Hide resolved
firedrake/adjoint_utils/blocks/solving.py Outdated Show resolved Hide resolved
tests/regression/test_adjoint_operators.py Outdated Show resolved Hide resolved
for block_variable in self.get_dependencies():
# The self.adj_F coefficients hold the forward output
# references.
if block_variable.output in self.adj_F.coefficients():
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is required. We are looping over self._dependencies that are not necessarily a self.adj_F coefficient.

@Ig-dolci Ig-dolci marked this pull request as draft September 11, 2024 15:30
Copy link

github-actions bot commented Sep 14, 2024

TestsPassed ✅Skipped ⏭️Failed ❌
Firedrake complex8078 ran6495 passed1583 skipped0 failed

Copy link

github-actions bot commented Sep 14, 2024

TestsPassed ✅Skipped ⏭️Failed ❌
Firedrake real8084 ran7298 passed786 skipped0 failed

@Ig-dolci
Copy link
Contributor Author

This PR is linked with pyadjoint PR #172.

@Ig-dolci Ig-dolci marked this pull request as ready for review October 14, 2024 18:12
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.

1 participant