orbix.kepler#

Kepler equation solvers: exact core + grid/fixed-e shortcuts.

Submodules#

Functions#

E_solve(M, e)

Vectorized orvara solver for eccentric anomaly.

diff_solve_trig(M, e)

Solve Kepler's equation, returning (sinE, cosE) with exact gradients.

solve_trig(M, e)

Wrapper around E_solve_trig that returns only (sinE, cosE).

get_grid_solver([level, jit, kind, E, trig, n_e, n_M])

Helper function to get a grid-based solver and cache it.

Package Contents#

orbix.kepler.E_solve(M, e)[source]#

Vectorized orvara solver for eccentric anomaly.

Parameters:
  • M (jnp.ndarray) – Mean anomaly. Shape: (n,).

  • e (float) – Eccentricity.

Returns:

Eccentric anomaly. Shape: (n,).

Return type:

E (jnp.ndarray)

The solver contract is 0 <= e < 1; e >= 1 or e < 0 silently produces NaN or garbage (unchecked to keep the hot path branch-free).

orbix.kepler.diff_solve_trig(M, e)[source]#

Solve Kepler’s equation, returning (sinE, cosE) with exact gradients.

Drop-in replacement for solve_trig() that supports reverse-mode autodiff (jax.grad, jax.vjp). Gradients come from the Implicit Function Theorem on M = E - e*sin(E), computed from (sinE, cosE, e) alone (no extra trig calls, no iterative re-solves).

Parameters:
  • M (jnp.ndarray) – Mean anomaly. Shape: (n,).

  • e (float) – Eccentricity.

Returns:

Sine of the eccentric anomaly. Shape: (n,). cosE (jnp.ndarray): Cosine of the eccentric anomaly. Shape: (n,).

Return type:

sinE (jnp.ndarray)

The solver contract is 0 <= e < 1; e >= 1 or e < 0 silently produces NaN or garbage (unchecked to keep the hot path branch-free).

orbix.kepler.solve_trig(M, e)[source]#

Wrapper around E_solve_trig that returns only (sinE, cosE).

Parameters:
  • M (jnp.ndarray) – Mean anomaly. Shape: (n,).

  • e (float) – Eccentricity.

Returns:

Sine of the eccentric anomaly. Shape: (n,). cosE (jnp.ndarray): Cosine of the eccentric anomaly. Shape: (n,).

Return type:

sinE (jnp.ndarray)

The solver contract is 0 <= e < 1; e >= 1 or e < 0 silently produces NaN or garbage (unchecked to keep the hot path branch-free).

orbix.kepler.get_grid_solver(level='scalar', jit=False, kind='bilinear', E=True, trig=True, n_e=512, n_M=2048)[source]#

Helper function to get a grid-based solver and cache it.

Parameters:
  • level –

    How the solver should be batching things.
    • ”scalar” means the inputs will be a single (M, e) pair and the output will be a single E, sinE, cosE value.

    • ”planet” will vectorize over times first and then over orbits.

      • M: (n_orbits, n_times)

      • e: (n_orbits,)

  • jit – Whether to jit the solver.

  • kind – The kind of solver to use, either “linear” or “bilinear”.

  • E – Whether to compute the eccentric anomaly.

  • trig – Whether to compute the sine and cosine of the eccentric anomaly.

  • n_e – The number of eccentricity steps in the grid.

  • n_M – The number of mean anomaly steps in the grid.