hannorein / rebound

💫 An open-source multi-purpose N-body code.
https://rebound.readthedocs.io/
GNU General Public License v3.0
820 stars 217 forks source link

value of G modified by sim.add #707

Closed DorianSchuylerAbbot closed 12 months ago

DorianSchuylerAbbot commented 12 months ago

Hello, I am trying to get whfast512 working. It requires sim.G=1, but when I create a new simulation file using sim.add, sim.G is slightly modified. Here is my code:

sim = rebound.Simulation() print(sim.G) planet_names_list = ["Sun","Mercury","Venus","Earth","Mars","Jupiter","Saturn","Uranus","Neptune"] sim.add(planet_names_list,date="2018-02-10 00:00") sim.save("SolarSystem.bin") print(sim.G)

This prints out sim.G values of 1.0, then 0.9999999999999997.

When I try to integrate this file with sim.integrator = "whfast512" I get the following error:

RuntimeError: WHFast512 requires units in which G=1. Please rescale your system.

I can fix this error by setting sim2.G = 1.0 before I call sim.integrate, but I don't know if this is kosher. What do you recommend?

Thank you!

Dorian

hannorein commented 12 months ago

Just set it to 1. It's a ~1e-16 error. The observational constraints on the initial conditions are way worse than this!

hannorein commented 12 months ago

I see that this could be confusing to people. So I've just pushed a small change in 5ed7a59a to fix this. It's just setting manually G=1 to avoid the machine precision rounding error when we calculate G.

Thanks for pointing it out.

DorianSchuylerAbbot commented 12 months ago

Thank you so much Hanno!