pub struct Shifted<F> {
pub f: F,
pub r_shift: f64,
}Expand description
Shift another potential to 0 at a given r.
U(r) = f(r) - f(r_\mathrm{shift})§Example
Shifted Lennard-Jones:
use approxim::{assert_abs_diff_eq, assert_relative_eq};
use hoomd_interaction::univariate::{
LennardJones, Shifted, UnivariateEnergy,
};
let epsilon = 1.5;
let sigma = 1.0;
let r_shift = 2.5;
let lj: LennardJones = LennardJones { epsilon, sigma };
let shifted_lj = Shifted {
f: lj.clone(),
r_shift,
};
assert_abs_diff_eq!(shifted_lj.energy(r_shift), 0.0);
assert_relative_eq!(
shifted_lj.energy(2.0_f64.powf(1.0 / 6.0) * sigma),
-epsilon - lj.energy(r_shift)
);Fields can be accessed directly, including those of the original potential f:
use hoomd_interaction::univariate::{LennardJones, Shifted};
let epsilon = 1.5;
let sigma = 1.0;
let r_shift = 2.5;
let mut shifted_lj = Shifted {
f: LennardJones::<12, 6> { epsilon, sigma },
r_shift,
};
shifted_lj.r_shift = 3.0;
shifted_lj.f.sigma = 1.2;Fields§
§f: FThe original potential.
r_shift: f64r value ([length]) where the shifted potential will be 0.
Trait Implementations§
Source§impl<'de, F> Deserialize<'de> for Shifted<F>where
F: Deserialize<'de>,
impl<'de, F> Deserialize<'de> for Shifted<F>where
F: Deserialize<'de>,
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<F: UnivariateEnergy> UnivariateEnergy for Shifted<F>
impl<F: UnivariateEnergy> UnivariateEnergy for Shifted<F>
Source§impl<F: UnivariateForce> UnivariateForce for Shifted<F>
impl<F: UnivariateForce> UnivariateForce for Shifted<F>
impl<F> StructuralPartialEq for Shifted<F>
Auto Trait Implementations§
impl<F> Freeze for Shifted<F>where
F: Freeze,
impl<F> RefUnwindSafe for Shifted<F>where
F: RefUnwindSafe,
impl<F> Send for Shifted<F>where
F: Send,
impl<F> Sync for Shifted<F>where
F: Sync,
impl<F> Unpin for Shifted<F>where
F: Unpin,
impl<F> UnwindSafe for Shifted<F>where
F: UnwindSafe,
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