Checkpoints

You can easily save and load particle positions to a binary file with REBOUND. The binary file includes the masses, positions and velocities of all particles, as well as the current simulation time (but nothing else!).

Let's add two particles to REBOUND and save them to a file.


In [1]:
import rebound
rebound.add(m=1.)
rebound.add(m=1e-6, a=1.)
rebound.add(a=2.)
rebound.save("checkpoint.bin")

The binary files are small in size and store every floating point number exactly, so you don't have to worry about efficiency or loosing precision. You can make lots of checkpoints if you want!

Let's reset REBOUND (that deletes the particles from memory) and then read the binary file we just saved.


In [2]:
rebound.reset()
rebound.load("checkpoint.bin")
rebound.status()


---------------------------------
Rebound version:     	0.3.1
Build on:            	May 16 2015 22:25:31
Number of particles: 	3
Simulation time:     	0.000000
---------------------------------
<rebound.Particle object, m=1.0 x=0.0 y=0.0 z=0.0 vx=0.0 vy=0.0 vz=0.0>
<rebound.Particle object, m=1e-06 x=1.0 y=0.0 z=0.0 vx=0.0 vy=1.0000005 vz=0.0>
<rebound.Particle object, m=0.0 x=2.000001 y=0.0 z=0.0 vx=0.0 vy=0.707108134739 vz=0.0>
---------------------------------

The checkpoint files only include the particle information and the time. They do not include the current settings of the integrator, the timestep and other other settings of REBOUND.