Skip to content

[SPH] Add PN (1, 1.5, 2, 2.5) terms for sink binaries#1904

Open
AugustinDart wants to merge 8 commits into
Shamrock-code:mainfrom
AugustinDart:SPIN/RR
Open

[SPH] Add PN (1, 1.5, 2, 2.5) terms for sink binaries#1904
AugustinDart wants to merge 8 commits into
Shamrock-code:mainfrom
AugustinDart:SPIN/RR

Conversation

@AugustinDart

@AugustinDart AugustinDart commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

1PN added for sink-sink interaction (orbital precession)
1.5 PN added for sink-sink interaction (Lense thirring frame dragging effect)
2PN added for Sink-sink interaction (we only added the Spin-spin interaction and not the term 2PN of the orbital precession)
2.5 PN added (Radiation Reaction or emission of GW)

We added the equation of Spins evolution for the binary in SinkParticleUpdate.cpp

Run_sph_binary_orbit.py is also modified in order to see the different effects (with the visualisation of orbital elements --> a,e, i and w). Possible to observe the evolution of spins too.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Thanks @AugustinDart 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

@AugustinDart AugustinDart marked this pull request as draft July 6, 2026 15:30

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

Copy link
Copy Markdown
Contributor

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 Post-Newtonian (PN) corrections (including orbit precession, spin-orbit, spin-spin, and radiation reaction terms) and spin precession evolution for sink particles, along with new test and visualization scripts. The review feedback highlights a critical bug in compute_ext_forces where the force accumulation is incorrectly scaled inside the loop, as well as a performance issue caused by printing configuration logs to std::cout on every timestep.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/shammodels/sph/src/modules/SinkParticlesUpdate.cpp
Comment thread src/shammodels/sph/src/modules/SinkParticlesUpdate.cpp Outdated
@tdavidcl tdavidcl changed the title Spin/rr [SPH] Add PN (1, 1.5, 2, 2.5) terms for sink binaries Jul 6, 2026
@y-lapeyre y-lapeyre self-requested a review July 6, 2026 15:34
@y-lapeyre y-lapeyre added the draft label Jul 6, 2026
@AugustinDart AugustinDart marked this pull request as ready for review July 7, 2026 11:38
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Workflow report

workflow report corresponding to commit 0e0697a
Commiter email is 66853113+pre-commit-ci[bot]@users.noreply.github.com
You are using github private e-mail. This prevent proper tracing of who contributed what, please disable it (see Keep my email addresses private).

Pre-commit check report

Some failures were detected in base source checks checks.
Check the On PR / Linting / Base source checks (pull_request) job in the tests for more detailed output

Suggested changes

Detailed changes :

Comment on lines +402 to +406
bool OP = true; // true pour ajouter le terme 1PN (précesssion des orbites), ordre 1PN
bool SO = true; // true pour ajouter le terme Spin-Orbit (précession des spins), ordre 1.5PN
bool SS = true; // true pour ajouter le terme Spin-Spin (précession des spins), odre 2PN
bool RR = true; // true pour ajouter le terme Radiation Reaction (perte d'énergie par
// rayonnement gravitationnel), ordre 2.5PN

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These should be made optional. You can add this to ExternalForces.hpp

bool compute_OP = false;
    inline void use_OP(bool enable) { compute_OP = enable; 

the in this file, use

bool OP = solver_config.compute_OP;

and add apython binding to indeed change the value of the boolean form the python interface

.def("use_lOP", &TConfig::use_OP)

same thing for the others

Comment on lines +408 to +438
static bool config_printed = false;

if (!config_printed) {
config_printed = true;

std::cout << "===== CONFIG PHYSIQUE =====" << std::endl;

std::cout << "Newton : ACTIVÉ" << std::endl;

if (OP)
std::cout << "1PN : ACTIVÉ" << std::endl;
else
std::cout << "1PN : DÉSACTIVÉ" << std::endl;

if (SO)
std::cout << "Spin-Orbit (1.5PN) : ACTIVÉ" << std::endl;
else
std::cout << "Spin-Orbit (1.5PN) : DÉSACTIVÉ" << std::endl;

if (SS)
std::cout << "Spin-Spin (2PN) : ACTIVÉ" << std::endl;
else
std::cout << "Spin-Spin (2PN) : DÉSACTIVÉ" << std::endl;

if (RR)
std::cout << "Radiation Reaction (2.5PN) : ACTIVÉ" << std::endl;
else
std::cout << "Radiation Reaction (2.5PN) : DÉSACTIVÉ" << std::endl;

std::cout << "===========================" << std::endl;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Avoid if/else spaghetti

logger::info_ln("-------- SinkParticleUpdate: Post-Newtonian terms --------");
logger::info_ln("1PN", solver_config.use_onePN);
logger::info_ln("SO", solver_config.use_SO);
logger::info_ln("SS", solver_config.use_SS);
logger::info_ln("RR", solver_config.use_RR);

term0 = -G * M * rij / (rij_scal * rij_scal * rij_scal + epsilon_grav_sink);
sum += s2.mass / M * term0;

if (OP == true) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

è_____é
There is no need to do if bool = something. The boolean is already a boolean

if (use_OP)

sum += 1 / (c * c) * s2.mass / M * term1;
}

if (SO) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same

sum += s2.mass / M * term2;
}

if (SS) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same

Comment thread orbit.png Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove it

Comment thread orbit.png Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove it

Comment thread spins.png Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove it

Comment thread vitesse.png Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove it

template<class Tvec, template<class> class SPHKernel>
void shammodels::sph::modules::SinkParticlesUpdate<Tvec, SPHKernel>::update_sink_spins(Tscal dt) {

// Définition des constantes G et c pour les calculs de précession des spins

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In English please

@y-lapeyre

Copy link
Copy Markdown
Collaborator

Please translate all comments to English. Non ascii characters ("é"'s) will make the pre-commit test fail :)

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.

3 participants