Skip to content

Boundary conditions

You can use different boundary conditions with REBOUND.

No boundaries

By default, REBOUND doesn't use boundary conditions. This means particle can have arbitrary coordinates in all three dimensions (as long as they can be represented as floating point numbers). Because this is the default setting, you don't need to do anything if you don't want boundary conditions. Nevertheless, here is the syntax to set this manually:

struct reb_simulation* r = reb_simulation_create();
r->boundary = REB_BOUNDARY_NONE;
sim = rebound.Simulation()
sim.boundary = "none"

Open

When open boundary conditions are selected, particles are removed from the simulation if they leave the simulation box. You therefore also need to set the size of the simulation box whenever you use open boundary conditions. The syntax is as follows:

struct reb_simulation* r = reb_simulation_create();
reb_simulation_configure_box(r, 10., 1, 1, 1); # confine the simulation to a box of size 10
r->boundary = REB_BOUNDARY_OPEN;
sim = rebound.Simulation()
sim.configure_box(10.)   # confine the simulation to a box of size 10
sim.boundary = "open"

Periodic

When periodic boundary conditions are uses, particles are reinserted on the opposite side if they leave a simulation box. You can use an arbitrary number of ghost-boxes with this module. The syntax is as follows:

struct reb_simulation* r = reb_simulation_create();
reb_simulation_configure_box(r, 10., 1, 2, 3); # confine the simulation to a box of size 10x20x30
r->boundary = reb_boundary_periodic;
sim = rebound.simulation()
sim.configure_box(10., 1, 2, 3)   # confine the simulation to a box of size 10x20x30
sim.boundary = "periodic"

Ghost boxes are supported for both periodic and shear-periodic boundary conditions. Ghost boxes can be used to allow particle collisions across boundaries and include gravitational forces from outside the box boundaries. This is particularly useful when simulating rings and disks. The following code sets up two rings of ghost boxes in the x and y directions.

r->N_ghost_x = 2;
r->N_ghost_y = 2;
r->N_ghost_z = 0;
sim.N_ghost_x = 2
sim.N_ghost_y = 2
sim.N_ghost_z = 0

See Rein & Liu for details on the ghost box implementation.

You might encounter the reb_vec6d structure in various parts of the code, for example in function related to gravity calculation and collision detection. It often contains the relative position and velocity of a ghost-box. If there are no ghost-boxes used, then all elements of this structure will be zero.

Shear

Shearing sheet

These are shear periodic boundary conditions. They are similar to periodic boundary conditions, but ghost-boxes are moving with constant speed, set by the shear. This is useful when simulation a small patch in a ring or disk. You also need to set the OMEGA variable in the simulation which set the epicyclic frequency. For more information on how to setup simulations of planetary rings in REBOUND, see Rein & Liu.

struct reb_simulation* r = reb_simulation_create();
reb_simulation_configure_box(r, 10., 1, 1, 1); 
r->OMEGA = 1.0;
r->boundary = REB_BOUNDARY_SHEAR;
sim = rebound.Simulation()
sim.configure_box(10.)
sim.OMEGA = 1.0
sim.boundary = "shear"