pub struct Drift {
pub constant: Dt,
pub rate: Dt,
pub accel: Dt,
}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 Dt.
Fields§
§constant: DtConstant term a₀ expressed in seconds.
This represents any fixed time offset between the observer’s proper time
and the chosen coordinate time.
rate: DtLinear drift rate a₁ expressed in seconds per second.
This term captures a steady fractional rate difference (for example, a
clock that runs consistently fast or slow).
accel: DtQuadratic acceleration term a₂ expressed in seconds per second squared.
This term accounts for any changing drift rate, such as the gradual
acceleration caused by relativistic effects or hardware aging.
Implementations§
Source§impl Drift
impl Drift
Sourcepub const WIRE_VERSION: u8 = 1
pub const WIRE_VERSION: u8 = 1
Current wire format version.
Sourcepub fn to_wire_bytes(&self) -> [u8; 51]
pub fn to_wire_bytes(&self) -> [u8; 51]
Serializes this Drift polynomial into a fixed buffer.
The layout is the concatenation of the three Dt fields.
Sourcepub fn from_wire_bytes(bytes: &[u8]) -> Option<Self>
pub fn from_wire_bytes(bytes: &[u8]) -> Option<Self>
Deserializes a Drift from exactly WIRE_SIZE bytes of wire data.
Returns None if any nested Dt fails validation or if the version
byte is unknown.
§Security
Composes the safety guarantees of
from_wire_bytes.
Fixed size and layered validation make it safe for untrusted input.
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 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.
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
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 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.
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 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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Drift
impl<'de> Deserialize<'de> for Drift
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Ord for Drift
impl Ord for Drift
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Drift
impl PartialOrd for Drift
Source§impl Tsify for Drift
impl Tsify for Drift
const DECL: &'static str = "/**\n * Quadratic polynomial that describes the accumulated difference between an\n * observer\u{2019}s proper time (the time measured by a real clock moving through\n * spacetime) and a chosen coordinate time such as TT, TAI, or any other\n * `Scale`.\n *\n * The polynomial follows the classic form \n * \u{394}t = constant + rate\u{b7}\u{394}t + accel\u{b7}(\u{394}t)\u{b2} \n * where the three coefficients capture any fixed offset, constant drift, and\n * quadratic acceleration of the clock. This structure is used throughout\n * spacecraft navigation, GNSS systems, and relativistic timing pipelines to\n * steer clocks, predict time offsets, and maintain synchronization over long\n * durations.\n *\n * All three coefficients are stored using [`Dt`].\n */\nexport interface Drift {\n /**\n * Constant term a\u{2080} expressed in seconds. \n * This represents any fixed time offset between the observer\u{2019}s proper time\n * and the chosen coordinate time.\n */\n constant: Dt;\n /**\n * Linear drift rate a\u{2081} expressed in seconds per second. \n * This term captures a steady fractional rate difference (for example, a\n * clock that runs consistently fast or slow).\n */\n rate: Dt;\n /**\n * Quadratic acceleration term a\u{2082} expressed in seconds per second squared. \n * This term accounts for any changing drift rate, such as the gradual\n * acceleration caused by relativistic effects or hardware aging.\n */\n accel: Dt;\n}"
const SERIALIZATION_CONFIG: SerializationConfig
type JsType = JsType
fn into_js(&self) -> Result<Self::JsType, Error>where
Self: Serialize,
fn from_js<T>(js: T) -> Result<Self, Error>
impl Copy for Drift
impl Eq for Drift
impl StructuralPartialEq for Drift
Auto Trait Implementations§
impl Freeze for Drift
impl RefUnwindSafe for Drift
impl Send for Drift
impl Sync for Drift
impl Unpin for Drift
impl UnsafeUnpin for Drift
impl UnwindSafe for Drift
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.