Miscellaneous Functions

group MiscRebFunctions

List of the miscellaneous helper functions for REBOUND

Functions

double reb_tools_energy(const struct reb_simulation *r)

Calculate the total energy (potential and kinetic).

Does not work for SEI (shearing sheet simulations). Calculate the total energy (potential and kinetic).

Return
Total energy.
Parameters
  • r -

    The rebound simulation to be considered.

struct reb_vec3d reb_tools_angular_momentum(const struct reb_simulation *r)

Calculate the system’s angular momentum.

Return
The angular momentum vector as a reb_vec3d struct.
Parameters
  • r -

    The rebound simulation to be considered.

int reb_add_var_1st_order(struct reb_simulation *r, int testparticle)

Add and initialize a set of first order variational particles.

Return
Returns the index of the first variational particle added
Parameters
  • r -

    The rebound simulation to be considered

  • testparticle -

    This flag determines if the set of variational particles is for a testparticle or not. If testparticle is >= 0, then only one variational particle (the test particle) will be added. If testparticle is -1, one variational particle for each real particle will be added.

int reb_add_var_2nd_order(struct reb_simulation *r, int testparticle, int index_1st_order_a, int index_1st_order_b)

Add and initialize a set of second order variational particles.

Note that a set of second order variational particles requires two sets of first order variational equations.

Return
Returns the index of the first variational particle added
Parameters
  • r -

    The rebound simulation to be considered

  • testparticle -

    This flag determines if the set of variational particles is for a testparticle or not. If testparticle is >= 0, then only one variational particle (the test particle) will be added. If testparticle is -1, one variational particle for each real particle will be added.

  • index_1st_order_a -

    The index of the corresponding first variational particles.

  • index_1st_order_b -

    The index of the corresponding first variational particles.

void reb_tools_megno_init(struct reb_simulation *r)

Init the MEGNO particles, enable MEGNO calculation.

Parameters
  • r -

    The rebound simulation to be considered

double reb_tools_calculate_megno(struct reb_simulation *r)

Get the current MEGNO value.

Return
Returns the current value of the MEGNO
Parameters
  • r -

    The rebound simulation to be considered

double reb_tools_calculate_lyapunov(struct reb_simulation *r)

Returns the largest Lyapunov characteristic number (LCN), or maximal Lyapunov exponent.

MEGNO needs to be enabled to calculate this value.

Return
Returns the current CN
Parameters
  • r -

    The rebound simulation to be considered

uint32_t reb_hash(const char *str)

Returns hash for passed string.

Return
hash for the passed string.
Parameters
  • str -

    String key.

struct reb_particle reb_particle_nan(void)

Returns a reb_particle structure with fields/hash/ptrs initialized to nan/0/NULL.

Return
reb_particle with fields initialized to nan.

void reb_exit(const char *msg)

Print out an error message, then exit in a semi-nice way.

void reb_warning(struct reb_simulation *r, const char *msg)

Print or store a warning message, then continue.

void reb_error(struct reb_simulation *r, const char *msg)

Print or store an error message, then continue.

int reb_get_next_message(struct reb_simulation *r, char *buf)

Get the next warning message stored. Used only if save_messages==1.

Return
Return value is 0 if no messages are present, 1 otherwise.
Parameters
  • r -

    The rebound simulation to be considered

  • buf -

    The buffer in which the error message it copied (needs to be at least reb_max_messages_length long).