Tools

group ToolsRebFunctions

List of the helper functions for REBOUND

Functions

double reb_random_uniform(double min, double max)

Return uniformly distributed random variable in a given range.

Return
A random variable
Parameters
  • min -

    Minimum value.

  • max -

    Maximum value.

double reb_random_powerlaw(double min, double max, double slope)

Returns a random variable drawn form a powerlaw distribution.

Return
A random variable
Parameters
  • min -

    Minimum value.

  • max -

    Maximum value.

  • slope -

    Slope of powerlaw distribution.

double reb_random_normal(double variance)

Return a random number with normal distribution.

Algorithm by D.E. Knut, 1997, The Art of Computer Programmin, Addison-Wesley.

Return
A random variable
Parameters
  • variance -

    Variance of normal distribution.

double reb_random_rayleigh(double sigma)

Return a random variable drawn form a Rayleigh distribution.

Calculated as described on Rayleigh distribution wikipedia page

Return
A random variable
Parameters
  • sigma -

    Scale parameter.

void reb_move_to_com(struct reb_simulation *r)

Move to center of momentum and center of mass frame.

This function moved all particles to the center of mass frame (sometimes also called center of momentum frame). In this frame the center of mass is at rest. It is recommended to call this function before you are doing a long term orbit integration. If the particles are slowly drifting away from the coordinate origin, numerical errors might build up.

Parameters
  • r -

    The rebound simulation to be considered

struct reb_particle reb_get_com(struct reb_simulation *r)

Returns the center of mass.

Return
The center of mass as a particle (mass, position and velocity correspond to the center of mass)
Parameters
  • r -

    The rebound simulation to be considered

struct reb_particle reb_get_com_of_pair(struct reb_particle p1, struct reb_particle p2)

Returns the center of mass of two particles.

Return
The center of mass as a particle (mass, position and velocity correspond to the center of mass)
Parameters
  • p1 -

    One of the two particles

  • p2 -

    One of the two particles

void reb_serialize_particle_data(struct reb_simulation * r, uint32_t * hash, double * m, double * radius, double(*) xyz, double(*) vxvyvz)

Sets arrays to particle data.

This function can be used to quickly access particle data in a serialized form. NULL pointers will not be set.

Parameters
  • r -

    The rebound simulation to be considered

  • hash -

    1D array to to hold particle hashes

  • mass -

    1D array to to hold particle masses

  • radius -

    1D array to to hold particle radii

  • xyz -

    3D array to to hold particle positions

  • vxvyvz -

    3D array to to hold particle velocities

struct reb_particle reb_get_com_without_particle(struct reb_particle com, struct reb_particle p)

Takes the center of mass of a system of particles and returns the center of mass with one of the particles removed.

Return
The center of mass with particle p removed.
Parameters
  • com -

    A particle structure that holds the center of mass state for a system of particles (mass, position, velocity).

  • p -

    The particle to be removed from com.

int reb_get_particle_index(struct reb_particle *p)

Returns a particle pointer’s index in the simulation it’s in.

Return
The integer index of the particle in its simulation (will return -1 if not found in the simulation).
Parameters
  • p -

    A pointer to the particle

struct reb_particle reb_get_com_range(struct reb_simulation *r, int first, int last)

Returns the center of mass for particles with indices between first (inclusive) and last (exclusive).

For example, reb_get_com_range(r, 6, 9) returns COM for particles 6, 7 and 8.

Return
A reb_particle structure for the center of mass of all particles in range [first, last). Returns particle filled with zeros if passed last <= first.
Parameters
  • r -

    A pointer to the simulation structure.

  • first -

    First index in range to consider.

  • last -

    Will consider particles with indices < last (i.e., particle with index last not considered).

struct reb_particle reb_get_jacobi_com(struct reb_particle *p)

Returns the jacobi center of mass for a given particle.

Return
A reb_particle structure for the center of mass of all particles with lower index. Returns particles[0] if passed the 0th particle.
Parameters
  • p -

    A pointer to the particle