system

Contents

system.c

Subroutines that control system-wide properties.

Author

Rory Barnes (RoryBarnes)

Date

May 7 2014

Functions

double fdMeanMotionToSemi(double dMass1, double dMass2, double dMeanMotion)
double fdPeriodToSemi(double dPeriod, double dMass)
double fdSemiToPeriod(double dSemi, double dMass)
double fdSemiToMeanMotion(double dSemi, double dMass)
double *fdOrbAngMom(BODY *body, CONTROL *control, int iBody)

Compute the orbital angular momentum of the iBodyth body as J = mu*sqrt(GMA(1-e^2)) for each orbiting body

double fdTotAngMom(BODY *body, CONTROL *control, SYSTEM *system)
double fdOrbPotEnergy(BODY *body, CONTROL *control, SYSTEM *system, int iBody)

Compute orbital potential energy neglecting planet-planet potential energy

double fdOrbKinEnergy(BODY *body, CONTROL *control, SYSTEM *system, int iBody)

Compute orbital kinetic energy of a body

double fdOrbEnergy(BODY *body, CONTROL *control, SYSTEM *system, int iBody)

Compute total orbital energy for a given body

double fdKinEnergy(BODY *body, CONTROL *control, SYSTEM *system, int iBody)

Compute total non-orbital kinetic energy of a body

double fdPotEnergy(BODY *body, CONTROL *control, SYSTEM *system, int iBody)

Compute a body’s non-orbital potential energy

double fdTotEnergy(BODY *body, CONTROL *control, SYSTEM *system)

Compute the total energy in the entire system, include lost energy

double fdTotOrbEnergy(BODY *body, CONTROL *control, SYSTEM *system)
int bPrimary(BODY *body, int iBody)
void CalcHK(BODY *body, int iBody)
void CalcPQ(BODY *body, int iBody)
double fdInstellation(BODY *body, int iBody)
double fdXUVFlux(BODY *body, int iBody)

Compute the XUV Flux.

Parameters
  • body – A pointer to the current BODY instance

  • iBody – The current BODY index

  • iXUV – Integer describing the XUV model

void kepler_eqn(BODY *body, int iBody)

Solves kepler’s equation for one body

Parameters
  • body – Struct containing all body information and variables

  • iBody – Index of body in question

void osc2cart(BODY *body, int iNumBodies)

Converts osculating orbital elements to Cartesian coordinates (in au & au/day)

Parameters
  • body – Struct containing all body information and variables

  • iNumBodies – Number of bodies in the system (star & planets)

void astro2bary(BODY *body, int iNumBodies)

Converts astrocentric Cartesian coordinates to barycentric

Parameters
  • body – Struct containing all body information and variables

  • iNumBodies – Number of bodies in the system (star & planets)

void bary2astro(BODY *body, int iNumBodies)

Converts barycentric Cartesian coordinates to astrocentric

Parameters
  • body – Struct containing all body information and variables

  • iNumBodies – Number of bodies in the system (star & planets)

void angularmom(BODY *body, double *AngMom, int iNumBodies)

Calculates angular momentum vector of planetary system

Parameters
  • body – Struct containing all body information and variables

  • AngMom – Resulting angular momentum vector

  • iNumBodies – Number of bodies in the system (star & planets)

void rotate_inv(BODY *body, SYSTEM *system, int iNumBodies)

Rotate coordinates into invariable plane

Parameters
  • body – Struct containing all body information and variables

  • system – Struct containing system information

  • iNumBodies – Number of bodies in the system (star & planets)

double normv(double *vector)

Calculates the magnitude of a vector

Parameters

vector – Any vector you what the magnitude of

Returns

The magnitude of vector

void cart2osc(BODY *body, int iNumBodies)

Converts Cartesian coordinates (in au & au/day) to osculating orbital elements

Parameters
  • body – Struct containing all body information and variables

  • iNumBodies – Number of bodies in the system (star & planets)

void inv_plane(BODY *body, SYSTEM *system, int iNumBodies)

Calculates coordinates of planetary system with respect to invariable plane

Parameters
  • body – Struct containing all body information and variables

  • system – Struct containing system information

  • iNumBodies – Number of bodies in the system (star & planets)

double fdMutualInclination(BODY *body, int iBody, int jBody)

Calculate the mutual or relative inclination of the orbital planes of iBody and jBody.

Parameters
  • body – A pointer to the current BODY instance

  • iBody – The index of the BODY struct for the 1st orbit

  • jBody – The index of the BODY struct for the 2nd orbit

Returns

The mutual inclination

int fbCheckMaxMutualInc(BODY *body, EVOLVE *evolve, HALT *halt, IO *io, int iBody, int jBody, int iReason)

Check the maximum allowed mutual inclination.

Parameters
  • body – A pointer to the BODY instance

  • evolve – A pointer to the integration EVOLVE instance

  • halt – A pointer to the HALT instance

  • io – A pointer to the IO instance

  • update – A pointer to the UPDATE instance

  • iBody – The current index in the BODY instance, irrelevant in this case because mutual inclination is by definition a multi-body variable

  • iReason – Was the subroutine called from CheckHalts (0) or CheckProgress (1)?

Returns

TRUE if the mutual incliantion is larger than dMaxMutualInc, FALSE if not

double fdSemiTidalLockEqSt(BODY *body, int iNumLocked, int iBody)

Compute rate of change of semi-major axis for tidally locked star(s) if iNumLocked = 2, both are locked, otherwise, iBody gives body struct index for star that is tidally locked

double fdSemiDtEqSt(BODY *body, SYSTEM *system, int *iaBody)

Compute change in binary semi-major axis when circular, tidally locked, w ~ n when EQTIDE and STELLAR are active

double fndUpdateSpiNBodyCoords(BODY *body, EVOLVE *evolve)
double fdLuminosityTotal(BODY *body, int iNumBodies)
void fdMergePlanet(BODY *body, UPDATE *update, fnUpdateVariable ***fnUpdate, int iBody)

Handle a merge by zeroing out lost planet’s derivatives, and adding its mass to the central body.

Parameters
  • body – A pointer to the current BODY instance

  • update – A pointer to the UPDATE struct

  • iBody – The index of the BODY struct for the lost planet

Returns

The mutual inclination

system.h

Subroutines that control system-wide properties.

Author

Rory Barnes (RoryBarnes)

Date

May 7 2014