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
- Spherical (point-mass) gravity:
calc_spherical,gravitation, andgravitation_with_scratchfromcompute. Output is aastrodyn_dynamics::GravityAccelerationcontaining acceleration, gradient, and potential — gradient and potential are filled even for the point- mass case so downstream consumers (gravity-gradient torque, energy diagnostics) have what they need. - Spherical harmonics:
calc_nonspherical,calc_nonspherical_typed,calc_nonspherical_with_scratch, andGottliebScratchfromspherical_harmonics_calc_nonspherical. This is the ported Gottlieb algorithm from JEODmodels/environment/gravity/src/spherical_harmonics_calc_nonspherical.cc— a numerically stable normalized Legendre recursion that scales to high degree and order without the underflow/overflow problems of the classical formulation. - Configuration types:
GravitySource,GravityModel, gravity-controls re-exports fromgravity_controlsandspherical_harmonics_gravity_controls, and theSphericalHarmonicsDatacoefficient container. - Tides and relativistic corrections:
tidesandrelativisticcarry the small post-Newtonian and luni-solar tide terms.
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 siblingGravityControlTyped). - 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
GravityControlsaggregator — the per-vehicle list ofGravityControlentries 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.