pub struct Harmonic {
pub k: f64,
pub r_0: f64,
}Expand description
Quadratic potential well centered at a given separation distance.
U = \frac{1}{2} k (r - r_0)^2Compute the harmonic potential and force as a function of r with
equilibrium spring length r_0.
§Examples
use approxim::{assert_abs_diff_eq, assert_relative_eq};
use hoomd_interaction::univariate::{
Harmonic, UnivariateEnergy, UnivariateForce,
};
let k = 2.0;
let r_0 = 0.0;
let harmonic = Harmonic { k, r_0 };
assert_abs_diff_eq!(harmonic.energy(0.0), 0.0);
assert_relative_eq!(harmonic.energy(1.0), 1.0);
assert_abs_diff_eq!(harmonic.force(1.0), -2.0, epsilon = 1e-12);The parameters are public fields and may be accessed directly:
use hoomd_interaction::univariate::Harmonic;
let mut harmonic = Harmonic { k: 1.0, r_0: 0.0 };
harmonic.k = 5.0;
harmonic.r_0 = 1.0;Fields§
§k: f64Spring constant $[\mathrm{energy}] [\mathrm{length}]^{-2}$.
r_0: f64Equilibrium spring length $[\mathrm{length}]$.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Harmonic
impl<'de> Deserialize<'de> for Harmonic
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl UnivariateEnergy for Harmonic
impl UnivariateEnergy for Harmonic
Source§impl UnivariateForce for Harmonic
impl UnivariateForce for Harmonic
impl StructuralPartialEq 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more