pub trait PairKernel<T: Real> {
type Params: Copy;
// Required methods
fn energy(r_sq: T, params: Self::Params) -> T;
fn diff(r_sq: T, params: Self::Params) -> T;
fn compute(r_sq: T, params: Self::Params) -> EnergyDiff<T>;
}Expand description
Trait for 2-body potentials (Bond Stretch, Van der Waals, Coulomb).
Models interaction energy as a function of squared distance $r^2$.
§Mathematical Contract
- Input: Squared distance $r^2$ (to avoid unnecessary square roots in cutoff checks).
- Output (Diff): The radial force pre-factor $D$ defined as: $$ D = -\frac{1}{r} \frac{dE}{dr} $$
Required Associated Types§
Required Methods§
Sourcefn compute(r_sq: T, params: Self::Params) -> EnergyDiff<T>
fn compute(r_sq: T, params: Self::Params) -> EnergyDiff<T>
Computes both energy and force pre-factor efficiently.
Should share intermediate calculations (e.g., sqrt, exp) where possible.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".