pub struct Torsion;Expand description
Periodic torsion potential for dihedral angles.
§Physics
Models the rotational barrier around a bond axis using a periodic cosine function.
- Formula: $$ E = \frac{1}{2} V [1 - \cos(n(\phi - \phi_0))] $$
- Derivative (
diff): $$ T = \frac{dE}{d\phi} = \frac{1}{2} V \cdot n \cdot \sin(n(\phi - \phi_0)) $$
§Parameters
v_half: Half barrier height $V_{half} = V/2$.n: Periodicity/multiplicity.cos_n_phi0: $\cos(n\phi_0)$, pre-computed phase cosine.sin_n_phi0: $\sin(n\phi_0)$, pre-computed phase sine.
§Inputs
cos_phi: Cosine of the dihedral angle $\cos\phi$.sin_phi: Sine of the dihedral angle $\sin\phi$.
§Implementation Notes
- Uses optimized closed-form formulas for common periodicities ($n = 1, 2, 3$).
- Falls back to Chebyshev recurrence for higher periodicities.
- All intermediate calculations are shared between energy and torque computations.
- Branchless and panic-free.
Trait Implementations§
Source§impl<T: Real> TorsionKernel<T> for Torsion
impl<T: Real> TorsionKernel<T> for Torsion
Source§fn diff(
cos_phi: T,
sin_phi: T,
(v_half, n, cos_n_phi0, sin_n_phi0): Self::Params,
) -> T
fn diff( cos_phi: T, sin_phi: T, (v_half, n, cos_n_phi0, sin_n_phi0): Self::Params, ) -> T
Computes only the torque $T$.
§Formula
$$ T = V_{half} \cdot n \cdot \sin(n(\phi - \phi_0)) $$
This factor allows computing forces via the chain rule: $$ \vec{F} = -T \cdot \nabla \phi $$
Source§fn compute(
cos_phi: T,
sin_phi: T,
(v_half, n, cos_n_phi0, sin_n_phi0): Self::Params,
) -> EnergyDiff<T>
fn compute( cos_phi: T, sin_phi: T, (v_half, n, cos_n_phi0, sin_n_phi0): Self::Params, ) -> EnergyDiff<T>
Computes both energy and torque efficiently.
This method reuses intermediate calculations to minimize operations.
impl Copy for Torsion
Auto Trait Implementations§
impl Freeze for Torsion
impl RefUnwindSafe for Torsion
impl Send for Torsion
impl Sync for Torsion
impl Unpin for Torsion
impl UnwindSafe for Torsion
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