Skip to main content

Drift

Struct Drift 

Source
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: Dt

Constant term a₀ expressed in seconds.
This represents any fixed time offset between the observer’s proper time and the chosen coordinate time.

§rate: Dt

Linear 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: Dt

Quadratic 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

Source

pub const WIRE_VERSION: u8 = 1

Current wire format version.

Source

pub const WIRE_SIZE: usize

Size of the canonical wire representation in bytes.

Source

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.

Source

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

Source

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.

Source

pub const fn new(constant: Dt, rate: Dt, accel: Dt) -> Self

Creates a new Drift polynomial from its three coefficients.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.
Source

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.

Source

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 Clone for Drift

Source§

fn clone(&self) -> Drift

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Drift

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Drift

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for Drift

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Drift

Source§

fn cmp(&self, other: &Drift) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Drift

Source§

fn eq(&self, other: &Drift) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Drift

Source§

fn partial_cmp(&self, other: &Drift) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Drift

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Tsify for Drift

Source§

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}"

Source§

const SERIALIZATION_CONFIG: SerializationConfig

Source§

type JsType = JsType

Source§

fn into_js(&self) -> Result<Self::JsType, Error>
where Self: Serialize,

Source§

fn from_js<T>(js: T) -> Result<Self, Error>
where T: Into<JsValue>, Self: DeserializeOwned,

Source§

impl Copy for Drift

Source§

impl Eq for Drift

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,