Support for adjoint simulations with no monitors (zero gradients) #2059
+106
−27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Idea is to allow functions like
min()
andmax()
in an objective function where some simulations (for example in an adjoint batch) might not get adjoint sources.Approach:
make_adjoint_sim
to returnNone
instead of erroring.run
andrun_async
, where by default we error inrun
and only warn inrun_async
:run
, the user is probably running only a single simulation. If that gets no adjoint sources, then there is a problem with the setup. However, it is possible that a user might be running multiple simulations serially, in which case we do offer the option to allow "empty" adjoint sims.run_async
, the user is expected to run a batch of multiple simulations, so it should generally be fine if some of those do not receive adjoint sources. We should probably error though if all simulations in a batch have no adjoint sources.