Skip to main content

ClockDrift

Struct ClockDrift 

Source
pub struct ClockDrift { /* 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 TSpan type, which guarantees 36-digit precision with no floating-point rounding errors even over centuries of integration.

Implementations§

Source§

impl ClockDrift

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: TSpan, rate: TSpan, accel: TSpan) -> Self

Creates a new ClockDrift polynomial from its three exact coefficients.

Source

pub const fn from_constant(c: TSpan) -> Self

Creates a ClockDrift 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: TSpan, rate: TSpan) -> Self

Creates a ClockDrift 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 constant(&self) -> &TSpan

Source

pub const fn rate(&self) -> &TSpan

Source

pub const fn accel(&self) -> &TSpan

Source

pub const fn set_constant(&mut self, constant: TSpan) -> &mut Self

Source

pub const fn set_rate(&mut self, rate: TSpan) -> &mut Self

Source

pub const fn set_accel(&mut self, accel: TSpan) -> &mut Self

Source

pub const fn with_constant(self, constant: TSpan) -> Self

Source

pub const fn with_rate(self, rate: TSpan) -> Self

Source

pub const fn with_accel(self, accel: TSpan) -> Self

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

Source

pub const fn time_diff_after(&self, span: &TSpan) -> TSpan

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.

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 ClockDrift 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 ClockDrift 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.
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_local_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 ClockDrift polynomial.

Source

pub const fn from_local_spacetime(spacetime: &LocalSpacetime) -> Self

Creates a ClockDrift from a fully resolved LocalSpacetime snapshot.

This is the canonical high-level entry point when you already hold a LocalSpacetime 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 ClockDrift polynomial ready for evaluation at any future time.

Trait Implementations§

Source§

impl Clone for ClockDrift

Source§

fn clone(&self) -> ClockDrift

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 ClockDrift

Source§

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

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

impl Hash for ClockDrift

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 ClockDrift

Source§

fn cmp(&self, other: &ClockDrift) -> 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 ClockDrift

Source§

fn eq(&self, other: &ClockDrift) -> 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 ClockDrift

Source§

fn partial_cmp(&self, other: &ClockDrift) -> 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 Copy for ClockDrift

Source§

impl Eq for ClockDrift

Source§

impl StructuralPartialEq for ClockDrift

Auto Trait Implementations§

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