Potential2

Trait Potential2 

Source
pub trait Potential2<T: Vector> {
    // Required methods
    fn energy(&self, r_sq: T) -> T;
    fn force_factor(&self, r_sq: T) -> T;

    // Provided method
    fn energy_force(&self, r_sq: T) -> (T, T) { ... }
}
Expand description

Two-body potential energy function.

Used for both non-bonded pair interactions (LJ, Coulomb) and bonded stretch interactions (harmonic, Morse).

§Input Convention

All methods accept r_sq (squared distance) rather than r to avoid unnecessary square root operations in the common case.

§Force Factor Convention

The force_factor method returns:

S = -(dV/dr) / r = -dV/d(r^2) * 2

To obtain the force vector from particle j to particle i:

F_ij = S * r_ij_vec

where r_ij_vec = r_i - r_j (vector from j to i).

Required Methods§

Source

fn energy(&self, r_sq: T) -> T

Computes the potential energy.

§Arguments
  • r_sq: Squared distance between particles (r^2)
§Returns

Potential energy V(r)

Source

fn force_factor(&self, r_sq: T) -> T

Computes the force factor.

§Arguments
  • r_sq: Squared distance between particles (r^2)
§Returns

Force factor S = -(dV/dr) / r

The actual force vector is: F = S * r_vec

Provided Methods§

Source

fn energy_force(&self, r_sq: T) -> (T, T)

Computes both energy and force factor simultaneously.

Default implementation calls both methods separately. Override for potentials with shared subexpressions.

§Returns

Tuple of (energy, force_factor)

Implementors§

Source§

impl<A: Potential2<T>, B: Potential2<T>, T: Vector> Potential2<T> for Sum<A, B, T>

Source§

impl<P: Potential2<T>, T: Vector> Potential2<T> for Cutoff<P, T>

Source§

impl<P: Potential2<T>, T: Vector> Potential2<T> for Scaled<P, T>

Source§

impl<P: Potential2<T>, T: Vector> Potential2<T> for Shift<P, T>

Source§

impl<P: Potential2<T>, T: Vector> Potential2<T> for Softcore<P, T>

Source§

impl<P: Potential2<T>, T: Vector> Potential2<T> for Switch<P, T>

Source§

impl<T: Vector> Potential2<T> for Cubic<T>

Source§

impl<T: Vector> Potential2<T> for Fene<T>

Source§

impl<T: Vector> Potential2<T> for G96<T>

Source§

impl<T: Vector> Potential2<T> for Harm<T>

Source§

impl<T: Vector> Potential2<T> for Morse<T>

Source§

impl<T: Vector> Potential2<T> for Quart<T>

Source§

impl<T: Vector> Potential2<T> for Buck<T>

Source§

impl<T: Vector> Potential2<T> for Coul<T>

Source§

impl<T: Vector> Potential2<T> for Gauss<T>

Source§

impl<T: Vector> Potential2<T> for Lj<T>

Source§

impl<T: Vector> Potential2<T> for Yukawa<T>

Source§

impl<T: Vector, const N: u32> Potential2<T> for Soft<T, N>

Source§

impl<T: Vector, const N: u32, const M: u32> Potential2<T> for Mie<T, N, M>