pub struct CosineHarmonic;Expand description
Cosine Harmonic potential for bond angles.
§Physics
Models the angle bending energy using a simple harmonic approximation on the cosine of the angle.
- Formula: $$ E = \frac{1}{2} C (\cos\theta - \cos\theta_0)^2 $$
- Derivative Factor (
diff): $$ \Gamma = \frac{dE}{d(\cos\theta)} = C (\cos\theta - \cos\theta_0) $$
§Parameters
k_half: Half force constant $C_{half} = C/2$.cos0: The cosine of the equilibrium angle $\cos\theta_0$.
§Inputs
cos_theta: Cosine of the bond angle $\theta_{ijk}$.
§Implementation Notes
- Pure polynomial evaluation; no
acos,sin, orsqrtrequired. - All intermediate calculations are shared between energy and force computations.
- Branchless and panic-free.
Trait Implementations§
Source§impl<T: Real> AngleKernel<T> for CosineHarmonic
impl<T: Real> AngleKernel<T> for CosineHarmonic
Source§fn energy(cos_theta: T, (k_half, cos0): Self::Params) -> T
fn energy(cos_theta: T, (k_half, cos0): Self::Params) -> T
Computes only the potential energy.
§Formula
$$ E = C_{half} (\Delta)^2, \quad \text{where } \Delta = \cos\theta - \cos\theta_0 $$
Source§fn diff(cos_theta: T, (k_half, cos0): Self::Params) -> T
fn diff(cos_theta: T, (k_half, cos0): Self::Params) -> T
Computes only the derivative factor $\Gamma$.
§Formula
$$ \Gamma = 2 C_{half} (\cos\theta - \cos\theta_0) $$
This factor allows computing forces via the chain rule: $$ \vec{F} = -\Gamma \cdot \nabla (\cos\theta) $$
Source§fn compute(cos_theta: T, (k_half, cos0): Self::Params) -> EnergyDiff<T>
fn compute(cos_theta: T, (k_half, cos0): Self::Params) -> EnergyDiff<T>
Computes both energy and derivative factor efficiently.
This method reuses intermediate calculations to minimize operations.
Source§impl Clone for CosineHarmonic
impl Clone for CosineHarmonic
Source§fn clone(&self) -> CosineHarmonic
fn clone(&self) -> CosineHarmonic
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 CosineHarmonic
impl Debug for CosineHarmonic
Source§impl Default for CosineHarmonic
impl Default for CosineHarmonic
Source§fn default() -> CosineHarmonic
fn default() -> CosineHarmonic
Returns the “default value” for a type. Read more
impl Copy for CosineHarmonic
Auto Trait Implementations§
impl Freeze for CosineHarmonic
impl RefUnwindSafe for CosineHarmonic
impl Send for CosineHarmonic
impl Sync for CosineHarmonic
impl Unpin for CosineHarmonic
impl UnwindSafe for CosineHarmonic
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