hannorein / rebound

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

OrbitPlot no longer plots periastron correctly #632

Closed Anit5577 closed 1 year ago

Anit5577 commented 1 year ago

I am using a very simple fly-by of two stars. When plotting their orbits, the periastron should be their closest approach, if I am not mistaken. However, when adding "periastron=True" the line now appears nowhere near the very obvious periastron of the encounter.

It now appears to point to the COM of that snapshot (as this changes when plotting different snapshots), even though the orbit of the perturbing star is plotted correctly, so the periastron distance can be calculated and T (time of periastron) is still given properly as well.

import rebound
sim.G = 6.6743e-11
sim.units = ('days', 'AU', 'Msun')

sim.add(m=1)
sim.add(m=0.5, x=7300, y=3700, z=2200,\
        vx=-0.002, vy=-0.0010, vz=-0.0006)

fig= rebound.OrbitPlot(sim, unitlabel="[au]",color=True,periastron=True)

This used to provide a plot showing the periastron, which in this case would be ~11-12 au. However the periastron line does not connect with this.

Adding sim.move_to_com() just moves the encounter and then the periastron line is clearly pointing to the COM (which is then at 0,0,0). This seems to be a recent change as it used to be plotted properly

Weird_periastron_OrbitPlot Weird_periastron_OrbitPlot_zoomed

hannorein commented 1 year ago

Thanks! I'll try to fix it...

hannorein commented 1 year ago

This should be fixed now. Thanks for reporting it.

Anit5577 commented 1 year ago

Thanks so much for fixing this so quickly. Works now as it used to :-)