pub struct SplinedPotential { /* private fields */ }Expand description
A splined version of any isotropic twobody potential.
Provides O(1) evaluation via cubic spline interpolation. Supports three grid types:
PowerLaw(p): Power-law spacing with denser sampling at short range (default, p=2.0)UniformR: Uniform spacing in rUniformRsq: Uniform spacing in r² (legacy, not recommended)
The splined potential is type-erased after construction—it stores only the precomputed coefficients, not the original potential.
Implementations§
Source§impl SplinedPotential
impl SplinedPotential
Sourcepub fn coefficients(&self) -> &[SplineCoeffs]
pub fn coefficients(&self) -> &[SplineCoeffs]
Returns a reference to the spline coefficients for all grid intervals.
Sourcepub const fn f_at_rmin(&self) -> f64
pub const fn f_at_rmin(&self) -> f64
Returns the force at r_min, used for linear extrapolation below the grid.
Sourcepub fn new<P: IsotropicTwobodyEnergy + Cutoff>(
potential: &P,
config: SplineConfig,
) -> Self
pub fn new<P: IsotropicTwobodyEnergy + Cutoff>( potential: &P, config: SplineConfig, ) -> Self
Sourcepub fn with_cutoff<P: IsotropicTwobodyEnergy + Cutoff>(
potential: &P,
cutoff: f64,
config: SplineConfig,
) -> Self
pub fn with_cutoff<P: IsotropicTwobodyEnergy + Cutoff>( potential: &P, cutoff: f64, config: SplineConfig, ) -> Self
Create a new splined potential with an explicit cutoff distance.
Use this for potentials that have infinite cutoff, or when you want to override the potential’s native cutoff.
§Arguments
potential- The analytical potential to tabulatecutoff- The cutoff distance (must be finite and positive)config- Configuration for the spline table
§Panics
Panics if n_points < 4, if rsq_min >= rsq_max, or if cutoff is not finite/positive
Source§impl SplinedPotential
impl SplinedPotential
Sourcepub const fn cutoff_squared(&self) -> f64
pub const fn cutoff_squared(&self) -> f64
Get the squared cutoff distance.
Sourcepub fn stats(&self) -> SplineStats
pub fn stats(&self) -> SplineStats
Get table statistics for debugging.
Sourcepub fn validate<P: IsotropicTwobodyEnergy>(
&self,
potential: &P,
n_test: usize,
) -> ValidationResult
pub fn validate<P: IsotropicTwobodyEnergy>( &self, potential: &P, n_test: usize, ) -> ValidationResult
Validate spline accuracy against the original potential.
Source§impl SplinedPotential
impl SplinedPotential
Sourcepub fn energies_batch(&self, rsq_values: &[f64], out: &mut [f64])
pub fn energies_batch(&self, rsq_values: &[f64], out: &mut [f64])
Evaluate energy for multiple distances at once (scalar loop).
Sourcepub fn evaluate_batch(
&self,
rsq_values: &[f64],
energies: &mut [f64],
forces: &mut [f64],
)
pub fn evaluate_batch( &self, rsq_values: &[f64], energies: &mut [f64], forces: &mut [f64], )
Evaluate energy and force for multiple distances (scalar loop).
Sourcepub fn to_simd(&self) -> SplineTableSimd
pub fn to_simd(&self) -> SplineTableSimd
Convert to SIMD-friendly SoA layout for batch evaluation (f64).
Sourcepub fn to_simd_f32(&self) -> SplineTableSimdF32
pub fn to_simd_f32(&self) -> SplineTableSimdF32
Convert to single-precision (f32) SIMD layout for faster evaluation.
Uses architecture-optimal SIMD width: f32x8 on x86_64, f32x4 on aarch64. Provides ~2x memory efficiency at the cost of reduced precision.
Trait Implementations§
Source§impl Clone for SplinedPotential
impl Clone for SplinedPotential
Source§fn clone(&self) -> SplinedPotential
fn clone(&self) -> SplinedPotential
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Cutoff for SplinedPotential
impl Cutoff for SplinedPotential
Source§impl Debug for SplinedPotential
impl Debug for SplinedPotential
Source§impl IsotropicTwobodyEnergy for SplinedPotential
impl IsotropicTwobodyEnergy for SplinedPotential
Source§fn isotropic_twobody_energy(&self, distance_squared: f64) -> f64
fn isotropic_twobody_energy(&self, distance_squared: f64) -> f64
Evaluate energy at squared distance using cubic spline interpolation.
Returns 0.0 if rsq >= cutoff². For rsq < rsq_min, linearly extrapolates using the slope at r_min to maintain repulsive behavior.
Source§fn isotropic_twobody_force(&self, distance_squared: f64) -> f64
fn isotropic_twobody_force(&self, distance_squared: f64) -> f64
Evaluate force at squared distance using cubic spline interpolation.
Returns 0.0 if rsq >= cutoff². Below r_min, scales as f(r_min) * r_min / r
to stay consistent with the linear energy extrapolation in real-force space.
Auto Trait Implementations§
impl Freeze for SplinedPotential
impl RefUnwindSafe for SplinedPotential
impl Send for SplinedPotential
impl Sync for SplinedPotential
impl Unpin for SplinedPotential
impl UnsafeUnpin for SplinedPotential
impl UnwindSafe for SplinedPotential
Blanket Implementations§
Source§impl<T> AnisotropicTwobodyEnergy for Twhere
T: IsotropicTwobodyEnergy,
impl<T> AnisotropicTwobodyEnergy for Twhere
T: IsotropicTwobodyEnergy,
Source§fn anisotropic_twobody_energy(&self, orientation: &RelativeOrientation) -> f64
fn anisotropic_twobody_energy(&self, orientation: &RelativeOrientation) -> f64
Source§fn anisotropic_twobody_force(
&self,
orientation: &RelativeOrientation,
) -> Vector3<f64>
fn anisotropic_twobody_force( &self, orientation: &RelativeOrientation, ) -> Vector3<f64>
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.