[SPH] Add PN (1, 1.5, 2, 2.5) terms for sink binaries#1904
[SPH] Add PN (1, 1.5, 2, 2.5) terms for sink binaries#1904AugustinDart wants to merge 8 commits into
Conversation
|
Thanks @AugustinDart for opening this PR! You can do multiple things directly here: Once the workflow completes a message will appear displaying informations related to the run. Also the PR gets automatically reviewed by gemini, you can: |
There was a problem hiding this comment.
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.
Workflow reportworkflow report corresponding to commit 0e0697a Pre-commit check reportSome failures were detected in base source checks checks. Suggested changesDetailed changes : |
| 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 |
There was a problem hiding this comment.
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
| 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; | ||
| } |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
è_____é
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) { |
| sum += s2.mass / M * term2; | ||
| } | ||
|
|
||
| if (SS) { |
| 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 |
|
Please translate all comments to English. Non ascii characters ("é"'s) will make the pre-commit test fail :) |
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.