Skip to content

Conversation

@y-lapeyre
Copy link
Collaborator

Is it ok with tags like this or should I use templates for the choice of metric?
I think of putting all terms of all metrics in this file. Yes it will be long, but at the end of the day it's just GR formulae we will never touch again.

@github-actions
Copy link
Contributor

Thanks @y-lapeyre for opening this PR!

You can do multiple things directly here:
1 - Comment pre-commit.ci run to run pre-commit checks.
2 - Comment pre-commit.ci autofix to apply fixes.
3 - Add label autofix.ci to fix authorship & pre-commit for every commit made.
4 - Add label light-ci to only trigger a reduced & faster version of the CI (need the full one before merge).
5 - Add label trigger-ci to create an empty commit to trigger the CI.

Once the workflow completes a message will appear displaying informations related to the run.

Also the PR gets automatically reviewed by gemini, you can:
1 - Comment /gemini review to trigger a review
2 - Comment /gemini summary for a summary
3 - Tag it using @gemini-code-assist either in the PR or in review comments on files

@gemini-code-assist
Copy link

Summary of Changes

Hello @y-lapeyre, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the shamphys library by introducing fundamental General Relativistic metric calculations. It specifically implements the Kerr metric, including its covariant and contravariant forms, along with their Cartesian derivatives. This foundational work paves the way for more advanced astrophysical simulations requiring accurate spacetime geometry. The author is also seeking input on the architectural choice for metric selection and has outlined a strategy for organizing these complex mathematical terms.

Highlights

  • Introduction of General Relativistic Metrics: Adds core functionality for handling spacetime metrics within the shamphys library.
  • Kerr Metric Implementation: Provides concrete implementations for the covariant and contravariant Kerr metric tensors in Cartesian-like coordinates.
  • Metric Derivatives: Includes functions to compute the Cartesian derivatives of the covariant Kerr metric.
  • Design Discussion: The author is considering using tags versus templates for metric selection and plans to centralize all metric terms in this file.
  • Known Issue: A comment notes that the contravariant metric expressions might not be regular at certain coordinate points (x=y=0 and z=r).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces calculations for the Kerr metric, including the covariant and contravariant metric tensors and their derivatives. The use of tag dispatching (e.g., struct Kerr {}) to select the metric is a good design choice.

However, the implementation has several significant issues that need to be addressed:

  • Critical bugs: There are uninitialized variables in get_cartesian_cov_metric_impl and get_cartesian_contrav_metric_impl due to incorrect coordinate unpacking, which will lead to undefined behavior.
  • Reusability: Metric parameters like spin and mass are hardcoded, which limits the use of these functions to a single specific black hole. These should be parameterized.
  • Correctness: The implementation for the contravariant metric contains a comment highlighting a known singularity issue that has not been addressed. This could lead to incorrect results or numerical instability.
  • Code Quality: There are some areas for improvement in code quality, such as very long and hard-to-read lines for the derivative calculations, and an unprofessional comment.

While I understand the sentiment that these GR formulae might not be touched again, ensuring their correctness, readability, and reusability from the start is crucial for the long-term health of the codebase. Please see the detailed comments for specific suggestions.

Copy link
Member

@tdavidcl tdavidcl left a comment

Choose a reason for hiding this comment

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

Looks very nice, what do you want to use in place of Tvec in practice ? Mat4x4 from the math library with mdspan ? (I'm fine with the template signature)

@github-actions
Copy link
Contributor

Workflow report

workflow report corresponding to commit a6c2863
Commiter email is yona.lapeyre@ens-lyon.fr

Light CI is enabled. This will only run the basic tests and not the full tests.
Merging a PR require the job "on PR / all" to pass which is disabled in this case.

Pre-commit check report

Pre-commit check: ✅

trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check for merge conflicts................................................Passed
check that executables have shebangs.....................................Passed
check that scripts with shebangs are executable..........................Passed
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check for broken symlinks................................................Passed
check yaml...............................................................Passed
detect private key.......................................................Passed
No-tabs checker..........................................................Passed
Tabs remover.............................................................Passed
Validate GitHub Workflows................................................Passed
clang-format.............................................................Passed
ruff check...............................................................Passed
ruff format..............................................................Passed
Check doxygen headers....................................................Passed
Check license headers....................................................Passed
Check #pragma once.......................................................Passed
Check SYCL #include......................................................Passed
No ssh in git submodules remote..........................................Passed
No UTF-8 in files (except for authors)...................................Passed

Test pipeline can run.

Doxygen diff with main

Removed warnings : 1
New warnings : 12
Warnings count : 7966 → 7977 (0.1%)

Detailed changes :
+ src/shamphys/include/shamphys/metrics.hpp:113: warning: Member get_cartesian_contravariant_metric_impl(const Kerr< Tscal > &kerr, const std::mdspan< Tscal, std::extents< SizeType, 4 >, Layout1, Accessor1 > &pos, std::mdspan< Tscal, std::extents< SizeType, 4, 4 >, Layout2, Accessor2 > &g) (function) of namespace shamphys is not documented.
+ src/shamphys/include/shamphys/metrics.hpp:181: warning: Member metric_cartesian_derivatives_impl(const Kerr< Tscal > &kerr, const std::mdspan< Tscal, std::extents< SizeType, 4 >, Layout1, Accessor1 > &pos, std::mdspan< Tscal, std::extents< SizeType, 4, 4 >, Layout2, Accessor2 > &dgcovdx, std::mdspan< Tscal, std::extents< SizeType, 4, 4 >, Layout2, Accessor2 > &dgcovdy, std::mdspan< Tscal, std::extents< SizeType, 4, 4 >, Layout2, Accessor2 > &dgcovdz) (function) of namespace shamphys is not documented.
+ src/shamphys/include/shamphys/metrics.hpp:27: warning: Compound shamphys::Kerr is not documented.
+ src/shamphys/include/shamphys/metrics.hpp:29: warning: Member a (variable) of struct shamphys::Kerr is not documented.
+ src/shamphys/include/shamphys/metrics.hpp:30: warning: Member bh_mass (variable) of struct shamphys::Kerr is not documented.
+ src/shamphys/include/shamphys/metrics.hpp:31: warning: Member rs (variable) of struct shamphys::Kerr is not documented.
+ src/shamphys/include/shamphys/metrics.hpp:33: warning: Member Kerr(Tscal spin=1, Tscal mass=1) (function) of struct shamphys::Kerr is not documented.
+ src/shamphys/include/shamphys/metrics.hpp:47: warning: Member get_cartesian_covariant_metric_impl(const Kerr< Tscal > &kerr, const std::mdspan< Tscal, std::extents< SizeType, 4 >, Layout1, Accessor1 > &pos, std::mdspan< Tscal, std::extents< SizeType, 4, 4 >, Layout2, Accessor2 > &g) (function) of namespace shamphys is not documented.
+ src/shamphys/include/shamphys/metrics.hpp:480: warning: Member get_cartesian_covariant_metric(const std::mdspan< Tscal, std::extents< SizeType, 4 >, Layout1, Accessor1 > pos, std::mdspan< Tscal, std::extents< SizeType, 4, 4 >, Layout2, Accessor2 > &g) (function) of namespace shamphys is not documented.
+ src/shamphys/include/shamphys/metrics.hpp:500: warning: Member get_cartesian_contravariant_metric(const std::mdspan< Tscal, std::extents< SizeType, 4 >, Layout1, Accessor1 > pos, std::mdspan< Tscal, std::extents< SizeType, 4, 4 >, Layout2, Accessor2 > &g) (function) of namespace shamphys is not documented.
+ src/shamphys/include/shamphys/metrics.hpp:520: warning: Member metric_cartesian_derivatives(const std::mdspan< Tscal, std::extents< SizeType, 4 >, Layout1, Accessor1 > pos, std::mdspan< Tscal, std::extents< SizeType, 4, 4 >, Layout2, Accessor2 > &dgcovdx, std::mdspan< Tscal, std::extents< SizeType, 4, 4 >, Layout2, Accessor2 > &dgcovdy, std::mdspan< Tscal, std::extents< SizeType, 4, 4 >, Layout2, Accessor2 > &dgcovdz) (function) of namespace shamphys is not documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants