orbix.equations.orbit#

Common equations for orbital mechanics.

Attributes#

Functions#

period_a(a, mu)

Orbital period from semi-major axis and standard gravitational parameter.

period_n(n)

Orbital period from mean motion.

mean_motion(a, mu)

Mean motion from semi-major axis and standard gravitational parameter.

period_to_sma(T, Ms)

Semi-major axis from orbital period via Kepler's third law.

semi_amplitude(T, Ms, Mp, e, i)

Semi-amplitude of the radial velocity curve from base quantities.

semi_amplitude_reduced(T, Ms, minimum_mass, ...)

Semi-amplitude of the radial velocity curve from pre-calculated quantities.

mean_anomaly_t0(t, n, M0, t0)

Mean anomaly at time t (can be vector) from epoch.

mean_anomaly_tp(t, n, tp)

Mean anomaly at time t (can be vector) from periapsis passage.

AB_matrices(a, e, i, W, w)

Compute the A and B matrices for a given set of orbital elements.

AB_matrices_reduced(a, sqrt_one_minus_e2, sini, cosi, ...)

Compute the A and B matrices from the trig values of the orbital elements.

thiele_innes_constants(W, i, w)

Compute the Thiele-Innes constants from the orbital angles.

thiele_innes_constants_reduced(sinW, cosW, sinw, cosw, ...)

Compute the Thiele-Innes constants from the orbital angles.

_safe_norm(x)

Vector norm with a finite (zero) gradient at x == 0.

state_vector_to_keplerian(r, v, mu)

Convert state vectors (r, v) to Keplerian elements using JAX.

Module Contents#

orbix.equations.orbit.two_pi_G#
orbix.equations.orbit.period_a(a, mu)[source]#

Orbital period from semi-major axis and standard gravitational parameter.

Parameters:
  • a – Array Semi-major axis

  • mu – Array Standard gravitational parameter

Returns:

Array

Orbital period

Return type:

T

orbix.equations.orbit.period_n(n)[source]#

Orbital period from mean motion.

Parameters:

n – Array Mean motion

Returns:

Array

Orbital period

Return type:

T

orbix.equations.orbit.mean_motion(a, mu)[source]#

Mean motion from semi-major axis and standard gravitational parameter.

Parameters:
  • a – Array Semi-major axis

  • mu – Array Standard gravitational parameter

Returns:

Array

Mean motion

Return type:

n

orbix.equations.orbit.period_to_sma(T, Ms)[source]#

Semi-major axis from orbital period via Kepler’s third law.

Parameters:
  • T – Orbital period (days). Scalar or array.

  • Ms – Stellar mass (kg). Scalar or array.

Returns:

Semi-major axis (AU). Scalar or array.

Return type:

a

orbix.equations.orbit.semi_amplitude(T, Ms, Mp, e, i)[source]#

Semi-amplitude of the radial velocity curve from base quantities.

Parameters:
  • T – Array Orbital period

  • Ms – Array Mass of the star

  • Mp – Array Mass of the planet

  • e – Array Eccentricity

  • i – Array Inclination

Returns:

Array

Semi-amplitude of the radial velocity curve

Return type:

K

orbix.equations.orbit.semi_amplitude_reduced(T, Ms, minimum_mass, sqrt_one_minus_e2)[source]#

Semi-amplitude of the radial velocity curve from pre-calculated quantities.

Parameters:
  • T – Array Orbital period

  • Ms – Array Mass of the star

  • minimum_mass – Array Mass of the planet multiplied by sin(i)

  • sqrt_one_minus_e2 – Array Square root of (1 - eccentricity^2)

Returns:

Array

Semi-amplitude of the radial velocity curve

Return type:

K

orbix.equations.orbit.mean_anomaly_t0(t, n, M0, t0)[source]#

Mean anomaly at time t (can be vector) from epoch.

Requires that all units are consistent and does NOT clip the mean anomaly to the range [0, 2pi).

Parameters:
  • t – Array Time

  • n – Array Mean motion

  • M0 – Array Mean anomaly at epoch

  • t0 – Array Epoch

Returns:

Array

Mean anomaly at time t

Return type:

M

orbix.equations.orbit.mean_anomaly_tp(t, n, tp)[source]#

Mean anomaly at time t (can be vector) from periapsis passage.

Parameters:
  • t – Array Time

  • n – Array Mean motion

  • tp – Array Time of periapsis passage

Returns:

Array

Mean anomaly at time t

Return type:

M

orbix.equations.orbit.AB_matrices(a, e, i, W, w)[source]#

Compute the A and B matrices for a given set of orbital elements.

In keplertools Dmitry defines these as: “inertial frame components of perifocal frame unit vectors scaled by orbit semi-major and semi-minor axes.” and I wouldn’t dare disagree with him on this.

Parameters:
  • a – Array Semi-major axis

  • e – Array Eccentricity

  • i – Array Inclination

  • W – Array Longitude of the ascending node

  • w – Array Argument of periapsis

Returns:

jnp.ndarray

A matrix

B: jnp.ndarray

B matrix

Return type:

A

orbix.equations.orbit.AB_matrices_reduced(a, sqrt_one_minus_e2, sini, cosi, sinW, cosW, sinw, cosw)[source]#

Compute the A and B matrices from the trig values of the orbital elements.

Parameters:
  • a – Semi-major axis

  • sqrt_one_minus_e2 – Square root of (1 - eccentricity^2)

  • sini – Sine of the inclination

  • cosi – Cosine of the inclination

  • sinW – Sine of the longitude of the ascending node

  • cosW – Cosine of the longitude of the ascending node

  • sinw – Sine of the argument of periapsis

  • cosw – Cosine of the argument of periapsis

Returns:

jnp.ndarray

A matrix

B: jnp.ndarray

B matrix

Return type:

A

orbix.equations.orbit.thiele_innes_constants(W, i, w)[source]#

Compute the Thiele-Innes constants from the orbital angles.

Parameters:
  • W – Longitude of the ascending node

  • i – Inclination

  • w – Argument of periapsis

Returns:

A constant B: B constant F: F constant G: G constant

Return type:

A

orbix.equations.orbit.thiele_innes_constants_reduced(sinW, cosW, sinw, cosw, sinwcosi, coswcosi)[source]#

Compute the Thiele-Innes constants from the orbital angles.

Parameters:
  • sinW – Sine of the longitude of the ascending node

  • cosW – Cosine of the longitude of the ascending node

  • sinw – Sine of the argument of periapsis

  • cosw – Cosine of the argument of periapsis

  • sinwcosi – Sine of the argument of periapsis times cosine of the inclination

  • coswcosi – Cosine of the argument of periapsis times cosine of the inclination

Returns:

A constant B: B constant F: F constant G: G constant

Return type:

A

orbix.equations.orbit._TOL_E = 1e-09#
orbix.equations.orbit._TOL_N = 1e-09#
orbix.equations.orbit._ARC_EPS = 1e-07#
orbix.equations.orbit._safe_norm(x)[source]#

Vector norm with a finite (zero) gradient at x == 0.

jnp.linalg.norm has a NaN gradient at exactly the zero vector (x / norm(x) is 0 / 0 there). This computes the same value but evaluates the norm on a nonzero stand-in whenever x is zero, so the local derivative is finite; the jnp.where then zeroes the corresponding cotangent, giving a well-defined (zero) gradient.

orbix.equations.orbit.state_vector_to_keplerian(r, v, mu)[source]#

Convert state vectors (r, v) to Keplerian elements using JAX.

Robust implementation handling edge cases (circular, equatorial, and non-bound orbits) using jnp.where for JIT compatibility.

Unit-agnostic: r, v, and mu must be expressed in one consistent unit system (e.g. meters / m/s / m^3 s^-2, or the AU / day units used elsewhere in this library); the function does not enforce or convert any particular convention, and a is returned in the same length unit as r.

Parameters:
  • r – Stellar-centric position vector (3,).

  • v – Stellar-centric velocity vector (3,).

  • mu – Gravitational parameter G * M_total.

Returns:

(a, e, i, W, w, M) – semi-major axis (same length

unit as r), eccentricity, inclination [rad], longitude of ascending node [rad], argument of periapsis [rad], mean anomaly [rad].

Return type:

tuple