The reason for this code is to find the time it takes for a planetary system with 2 planets(particles) to have a close encounter between each other. I, however, would like to solve that time for a planetary system with 5 particles. This will be printed at the last line print(sim.t)
.
http://rebound.readthedocs.io/en/latest/examples.html Here is some documentation on the usage of REBOUND, where you can find the best explanation on some of the declarations I've made.
sim = setupSimulation()
sim.exit_min_distance = 0.01
Noutputs = 10000
year = 2.*np.pi
times = np.linspace(0.,10E+9.*year, Noutputs)
distances = np.zeros(Noutputs)
ps = sim.particles
try:
for i,time in enumerate(times):
sim.integrate(time)
dp = ps[1] - ps[2]
distances[i] = np.sqrt(dp.x*dp.x+dp.y*dp.y+dp.z*dp.z)
except rebound.Encounter as error:
print(error)
print(sim.t)
Line 2 defines a close encounter between the two particles (simulation will stop when this value is reached).
Line 11 takes the difference in coordinates of particles, if <= .01, prints that there is a close encounter.
I was thinking along the line of an if-then statement:
if ps[1] - ps[2] <= .01:
dp = ps[1] - ps[2]
else ps[2] - ps[3] <= .01:
dp = ps[2] - ps[3]
and so on...
I'd like to make sure this works before I run it simply because the simulation time is 10e+9 years, and can only be ran on a local supercomputer to obtain results in a reasonable amount of time.