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

Use ForwardDiff.jl to compute Christoffel symbols exactly #78

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tristanmontoya
Copy link
Member

@tristanmontoya tristanmontoya commented Mar 7, 2025

Previously, the collocation derivative was applied to the metric tensor components to evaluate the Christoffel symbols approximately. Since the rest of the geometric information for the covariant solver is computed analytically for the spherical shell, I would like the Christoffel symbols to also be exact. Because the expressions get quite messy when differentiating by hand, an easy way to compute them is to use automatic differentiation. Since reverse-mode automatic differentiation is not needed here and Trixi.jl already has ForwardDiff.jl as a dependency, I've used ForwardDiff.jl to do forward-mode automatic differentiation.

If the Christoffel symbols needed to be recomputed frequently (e.g. in an adaptive simulation, or for a time-varying metric), perhaps there would be an argument for coding them by hand for efficiency purposes, but, since for now they are only calculated once per simulation and stored at each node, using automatic differentiation makes the most sense to me.

Now that we are computing the Christoffel symbols exactly, the sensitivity of the covariant basis vector components described in #49 can be seen from the fact that ForwardDiff returns NaNs when using GlobalSphericalCoordinates and an even number of cells per dimension on each face of the cubed sphere, presumably due to this pole problem. The default option GlobalCartesianCoordinates avoids this problem, and should therefore always be used instead of GlobalSphericalCoordinates.

Note: The test values for the spherical shallow water equations have been updated accordingly. This will therefore affect the test values for the new cases added in #73. Also note that the coveralls tests fail due to there being less code to cover now, thus leading to the percentage of covered code dropping.

Copy link

codecov bot commented Mar 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.29%. Comparing base (a496119) to head (8121b38).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #78      +/-   ##
==========================================
- Coverage   90.39%   90.29%   -0.11%     
==========================================
  Files          22       22              
  Lines        2104     2082      -22     
==========================================
- Hits         1902     1880      -22     
  Misses        202      202              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tristanmontoya tristanmontoya marked this pull request as ready for review March 10, 2025 23:17
@tristanmontoya tristanmontoya changed the title Use ForwardDiff.jl to compute Christoffel symbols exactly for a spherical shell Use ForwardDiff.jl to compute Christoffel symbols exactly Mar 10, 2025
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