pub struct Drift { /* private fields */ }Expand description
Quadratic polynomial that describes the accumulated difference between an
observer’s proper time (the time measured by a real clock moving through
spacetime) and a chosen coordinate time such as TT, TAI, or any other
Scale.
The polynomial follows the classic form
Δt = constant + rate·Δt + accel·(Δt)²
where the three coefficients capture any fixed offset, constant drift, and
quadratic acceleration of the clock. This structure is used throughout
spacecraft navigation, GNSS systems, and relativistic timing pipelines to
steer clocks, predict time offsets, and maintain synchronization over long
durations.
All three coefficients are stored using the exact Dt type, which
guarantees 36-digit precision with no floating-point rounding errors even
over centuries of integration.
Implementations§
Source§impl Drift
impl Drift
Sourcepub const ZERO: Self
pub const ZERO: Self
The zero polynomial representing no correction at all.
Use this when the observer’s clock is already perfectly synchronized with
the chosen coordinate time.
Sourcepub const fn new(constant: Dt, rate: Dt, accel: Dt) -> Self
pub const fn new(constant: Dt, rate: Dt, accel: Dt) -> Self
Creates a new Drift polynomial from its three exact coefficients.
Sourcepub const fn from_constant(c: Dt) -> Self
pub const fn from_constant(c: Dt) -> Self
Creates a Drift consisting of a pure constant offset.
This is the most common constructor when only a fixed time bias is known
(for example, after a one-time clock synchronization or leap-second
adjustment).
Sourcepub const fn from_offset_and_rate(offset: Dt, rate: Dt) -> Self
pub const fn from_offset_and_rate(offset: Dt, rate: Dt) -> Self
Creates a Drift consisting of a constant offset together with a
constant linear drift rate.
This form is very common for GNSS receivers and spacecraft clock steering,
where a steady fractional frequency offset must be corrected in addition
to any fixed bias.
pub const fn constant(&self) -> &Dt
pub const fn rate(&self) -> &Dt
pub const fn accel(&self) -> &Dt
pub const fn set_constant(&mut self, constant: Dt) -> &mut Self
pub const fn set_rate(&mut self, rate: Dt) -> &mut Self
pub const fn set_accel(&mut self, accel: Dt) -> &mut Self
pub const fn with_constant(self, constant: Dt) -> Self
pub const fn with_rate(self, rate: Dt) -> Self
pub const fn with_accel(self, accel: Dt) -> Self
Sourcepub const fn proper_time_rate(&self) -> Real
pub const fn proper_time_rate(&self) -> Real
Returns the instantaneous proper-time rate dτ/dt (dimensionless).
This value tells you how fast a real physical clock (such as a spacecraft
onboard clock) is advancing compared to coordinate time. A value of exactly
1.0 means the clock runs at the normal rate. Values slightly below 1.0
are typical when the clock is moving or sitting in a gravitational well.
The rate includes special-relativistic velocity effects, gravitational time dilation, and the library’s built-in Planck-scale saturation term.
Sourcepub const fn time_diff_after(&self, span: &Dt) -> Dt
pub const fn time_diff_after(&self, span: &Dt) -> Dt
Evaluates the polynomial at the given elapsed coordinate time span.
Returns the exact accumulated time difference (in seconds) between proper time and coordinate time after the interval span has passed. All arithmetic is performed with full 36-digit precision, ensuring no loss of accuracy even for multi-year integrations.
Sourcepub fn time_diff_after_with_noise(
&self,
span: &Dt,
stochastic_offset_sec: Real,
) -> Dt
pub fn time_diff_after_with_noise( &self, span: &Dt, stochastic_offset_sec: Real, ) -> Dt
Evaluates the deterministic relativistic/polynomial correction and adds a user-supplied stochastic offset (in seconds).
This is the single production method for realistic stochastic clock modeling. In real mission pipelines the deterministic part (this polynomial) is kept perfectly clean; stochastic noise (white phase noise, random-walk frequency noise, Monte-Carlo realizations, Kalman process noise, measured clock residuals, etc.) is added at evaluation time.
Pass 0.0 (or simply call the original time_diff_after) when you
want purely deterministic behavior.
Sourcepub const fn from_velocity_potential_and_scale(
velocity_m_s: Real,
grav_potential_m2_s2: Real,
characteristic_length_scale: Real,
) -> Self
pub const fn from_velocity_potential_and_scale( velocity_m_s: Real, grav_potential_m2_s2: Real, characteristic_length_scale: Real, ) -> Self
Creates a Drift directly from an observer’s velocity and total
local gravitational potential using the library’s unified master-Lagrangian
proper-time rate.
This is the recommended high-level constructor for nearly all users. It
automatically computes the relativistic clock rate that includes both
special-relativistic velocity effects and gravitational time dilation,
then returns a Drift that can be evaluated at any future time.
The characteristic_length_scale parameter controls whether the
weak-field or strong-field formulation is used:
- In the weak-field regime (where |Φ|/c² ≪ 1), simply pass
characteristic_length_scale = 0.0. This returns exactly the same relativistic clock rate used by JPL, ESA, GNSS systems, and all modern solar-system navigation pipelines. - In strong-field conditions, supply a non-zero length scale (in meters) over which the gravitational potential changes at the observer’s location. This activates the library’s intrinsic Planck-scale saturation term when spacetime curvature becomes extreme.
Sourcepub const fn from_unified_proper_time_rate(u: Real, kretschmann: Real) -> Self
pub const fn from_unified_proper_time_rate(u: Real, kretschmann: Real) -> Self
Canonical low-level constructor that implements the exact intrinsic expression from the master Lagrangian.
This function is the single source of truth for the proper-time rate
calculation used throughout the library. Most users will never call it
directly; the high-level constructors from_velocity_potential_and_scale
and from_spacetime are the intended entry points.
The internal expression is
K_eff = [δ(1 + x) + x(1−δ)²] / (1 + x)
where δ = α²(1−β²) and x = ℓ_Pl⁴ 𝒦. The returned rate offset is then
applied as a linear term in the Drift polynomial.
Sourcepub const fn from_spacetime(spacetime: &Spacetime) -> Self
pub const fn from_spacetime(spacetime: &Spacetime) -> Self
Creates a Drift from a fully resolved Spacetime snapshot.
This is the canonical high-level entry point when you already hold a
Spacetime object containing the gravitational lapse factor α, the
local velocity β, and the Kretschmann scalar. It internally computes the
unified proper-time rate and packages the result as a Drift
polynomial ready for evaluation at any future time.