pub struct LennardJones;Expand description
Lennard-Jones 12-6 potential for Van der Waals interactions.
§Physics
Models the short-range repulsion and long-range attraction between non-bonded atoms.
- Formula: $$ E = D_0 \left[ \left( \frac{R_0}{r} \right)^{12} - 2 \left( \frac{R_0}{r} \right)^6 \right] $$
- Derivative Factor (
diff): $$ D = -\frac{1}{r} \frac{dE}{dr} = \frac{12 D_0}{r^2} \left[ \left( \frac{R_0}{r} \right)^{12} - \left( \frac{R_0}{r} \right)^6 \right] $$
§Parameters
d0: The energy well depth $D_0$.r0_sq: The squared equilibrium distance $R_0^2$.
§Inputs
r_sq: Squared distance $r^2$ between two atoms.
§Implementation Notes
- This implementation avoids
sqrtentirely by operating on squared distances. - The power chain
s -> s3 -> s6is used for efficient calculation of $r^{-6}$ and $r^{-12}$ terms. - All intermediate calculations are shared between energy and force computations.
- Branchless and panic-free.
Trait Implementations§
Source§impl Clone for LennardJones
impl Clone for LennardJones
Source§fn clone(&self) -> LennardJones
fn clone(&self) -> LennardJones
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LennardJones
impl Debug for LennardJones
Source§impl Default for LennardJones
impl Default for LennardJones
Source§fn default() -> LennardJones
fn default() -> LennardJones
Returns the “default value” for a type. Read more
Source§impl<T: Real> PairKernel<T> for LennardJones
impl<T: Real> PairKernel<T> for LennardJones
Source§fn energy(r_sq: T, (d0, r0_sq): Self::Params) -> T
fn energy(r_sq: T, (d0, r0_sq): Self::Params) -> T
Computes only the potential energy.
§Formula
$$ E = D_0 (s^6 - 2s^3), \quad \text{where } s = (R_0/r)^2 $$
Source§fn diff(r_sq: T, (d0, r0_sq): Self::Params) -> T
fn diff(r_sq: T, (d0, r0_sq): Self::Params) -> T
Computes only the force pre-factor $D$.
§Formula
$$ D = \frac{12 D_0}{r^2} (s^6 - s^3), \quad \text{where } s = (R_0/r)^2 $$
This factor is defined such that the force vector can be computed by a single vector multiplication: $\vec{F} = -D \cdot \vec{r}$.
Source§fn compute(r_sq: T, (d0, r0_sq): Self::Params) -> EnergyDiff<T>
fn compute(r_sq: T, (d0, r0_sq): Self::Params) -> EnergyDiff<T>
Computes both energy and force pre-factor efficiently.
This method reuses intermediate calculations to minimize operations.
impl Copy for LennardJones
Auto Trait Implementations§
impl Freeze for LennardJones
impl RefUnwindSafe for LennardJones
impl Send for LennardJones
impl Sync for LennardJones
impl Unpin for LennardJones
impl UnwindSafe for LennardJones
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
Mutably borrows from an owned value. Read more