Particle structure

A particle is represented by the reb_particle structure in C. The python class Particle is an abstraction of the reb_particle structure in C. We will refer to both the C structure and the python object interchangeably as the particle structure and particle object.

The particle object contains the following variables which can be directly manipulated:

double m
mass
double r
double x, y, z, vx, vy, vz
position and velocity coordinates
uint32_t hash
integer or hash value used to identify the particle

You can create a particle object which is not part of a REBOUND simulation.

struct reb_particle p = {.m=1., x=0., vy=0.};

p = rebound.Particle(m=1., x=0., vy=0.)


However, in most cases you will work with particles which have been added to a REBOUND simulation. You then access the particle using the simulation's particles array:

struct reb_simulation* r = reb_create_simulation();
// ... setup simulation, add particles ...
r->particles[0].x = 1;

sim = rebound.Simulation()
# ... setup simulation, add particles ...
sim.particles[0].x = 1


Alternatively you can assign a hash value to particles and access them using the following syntax:

struct reb_simulation* r = reb_create_simulation();

sim = rebound.Simulation()