Skip to main content

Crate astrodyn_gravity

Crate astrodyn_gravity 

Source
Expand description

Gravity: spherical, spherical harmonics (Gottlieb), tides, and relativistic terms.

Pure-Rust port of JEOD’s models/environment/gravity/. The crate produces gravitational acceleration, the gravity-gradient tensor, and the gravitational potential at a body’s position, given a configured set of gravity sources.

§Public surface

JEOD coefficient data lives in models/environment/gravity/data/include/earth_GGM05C.hh (and similar per-body files); coefficients contains the parsing logic that turns the C++ array headers into Vec<Vec<f64>> C and S coefficient tables. Coefficients are normalized as in JEOD; the recursion expects normalized input. Pure Rust, zero Bevy dependency.

§Example

Point-mass gravity at the equator of a body with Earth’s mu should point inward (toward the body’s centre):

use astrodyn_gravity::calc_spherical;
use glam::DVec3;

let mu = 3.986_004_415e14; // Earth GGM05C, m^3/s^2
let r = DVec3::new(6_778_137.0, 0.0, 0.0); // 400 km altitude on +X axis

let g = calc_spherical(mu, r);
// Acceleration points back toward the origin (-X) at ~8.7 m/s^2.
assert!(g.grav_accel.x < 0.0);
assert!((g.grav_accel.length() - mu / r.length().powi(2)).abs() < 1e-6);

Re-exports§

pub use accumulate::accumulate_gravity;
pub use accumulate::accumulate_gravity_typed;
pub use accumulate::accumulate_relativistic_corrections;
pub use accumulate::accumulate_relativistic_corrections_typed;
pub use accumulate::evaluate_body_gravity_typed;
pub use accumulate::run_gravity_stage;
pub use accumulate::GravityBodyInputs;
pub use accumulate::ResolvedRelativisticSource;
pub use accumulate::ResolvedSource;
pub use compute::calc_spherical;
pub use compute::gravitation;
pub use compute::gravitation_with_scratch;
pub use spherical_harmonics_calc_nonspherical::calc_nonspherical;
pub use spherical_harmonics_calc_nonspherical::calc_nonspherical_typed;
pub use spherical_harmonics_calc_nonspherical::calc_nonspherical_with_scratch;
pub use spherical_harmonics_calc_nonspherical::GottliebScratch;
pub use spherical_harmonics_gravity_source::SphericalHarmonicsData;
pub use gravity_controls::*;
pub use gravity_source::*;
pub use spherical_harmonics_gravity_controls::*;

Modules§

accumulate
Gravity stage: per-body gravity accumulation across multiple sources (point-mass, spherical-harmonics with optional tides, plus optional relativistic post-Newtonian corrections).
coefficients
Compact binary serialization for gravity coefficients.
compute
Top-level gravity-acceleration computation.
data
Embedded planetary gravity-coefficient blobs.
fixtures
Committed planetary gravity-coefficient fixtures.
gravity_controls
Per-source gravity-control configuration (GravityControl + typed sibling GravityControlTyped).
gravity_source
GravitySource / GravityModel — the per-body μ + model payload that gravity-control evaluation runs against.
jeod_cc
JEOD C++ source file parsers for gravity coefficient files.
relativistic
Post-Newtonian (PPN) relativistic gravity correction.
spherical_harmonics_calc_nonspherical
Gottlieb (1993) spherical harmonics gravity computation.
spherical_harmonics_gravity_controls
Multi-source GravityControls aggregator — the per-vehicle list of GravityControl entries the gravity pipeline iterates each step.
spherical_harmonics_gravity_source
SphericalHarmonicsData — coefficient table and precomputed Gottlieb helper arrays for spherical-harmonics gravity.
tides
Solid body tidal delta coefficients.
verif
Parser for JEOD’s static gravity-verification reference data.