pub struct Harmonic;Expand description
Harmonic potential implementation for 1-2 bond stretching.
§Physics
Models the bond stretching as a harmonic oscillator.
- Formula: $$ E = \frac{1}{2} K (R - R_0)^2 $$
- Derivative Factor (
diff): $$ D = -\frac{K (R - R_0)}{R} $$
§Parameters
k_half: Half force constant $K_{half} = K/2$.r0: Equilibrium distance $R_0$.
§Inputs
r_sq: Squared distance $r^2$ between two atoms.
§Implementation Notes
- Requires square root to obtain $R$.
- All intermediate calculations are shared between energy and force computations.
- Branchless and panic-free.
Trait Implementations§
Source§impl<T: Real> PairKernel<T> for Harmonic
impl<T: Real> PairKernel<T> for Harmonic
Source§fn diff(r_sq: T, (k_half, r0): Self::Params) -> T
fn diff(r_sq: T, (k_half, r0): Self::Params) -> T
Computes only the force pre-factor $D$.
§Formula
$$ D = -\frac{2 K_{half} (R - R_0)}{R} $$
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, (k_half, r0): Self::Params) -> EnergyDiff<T>
fn compute(r_sq: T, (k_half, r0): Self::Params) -> EnergyDiff<T>
Computes both energy and force pre-factor efficiently.
This method reuses intermediate calculations to minimize operations.
impl Copy for Harmonic
Auto Trait Implementations§
impl Freeze for Harmonic
impl RefUnwindSafe for Harmonic
impl Send for Harmonic
impl Sync for Harmonic
impl Unpin for Harmonic
impl UnwindSafe for Harmonic
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