Fix energy conservation with sparse autodiff #3939
Open
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.
This PR fixes energy conservation when using
AutoSparseJacobian
by adding padding bands to most of the∂ᶜρe_totₜ/∂ᶜχ
blocks, and also by explicitly handling quaddiagonal bands of the∂ᶜρe_totₜ/∂ᶠu₃
block.Based on the dry and moist Float64 baroclinic wave conservation tests, errors in the
∂ᶜρe_totₜ/∂ᶠu₃
block as small as one part in a trillion seem to affect energy conservation. The new bands eliminate all such errors, so that energy conservation is even better than withManualSparseJacobian
. Further experiments may show that this is more precise than we need, so we could potentially improve performance by removing some of these new bands. For now, though, we can continue testing sparse autodiff with optimal energy conservation.This PR also adds a dry Float64 baroclinic wave conservation test with sparse autodiff to CI, removes the soft-fail annotation from the moist test, and clarifies the bandwidth tables printed when debugging the Jacobian.