pub fn energy(&self, r: f64) -> f64 {
        if r >= self.cutoff {
            0.0
        } else {
            let energy = self.potential.energy(r);
            match self.computation {
                PairComputation::Cutoff => energy,
                PairComputation::Shifted(shift) => energy - shift,
            }
        }
    }
/// Get the energy for this pair interaction at the distance `r`.
///
/// # Examples
///
/// ```
/// use lumol_core::energy::PairInteraction;
/// use lumol_core::energy::Harmonic;
///
/// let potential = Box::new(Harmonic{x0: 0.5, k: 4.2});
/// let interaction = PairInteraction::new(potential, 2.0);
///
/// assert_eq!(interaction.energy(1.0), 0.525);
/// // energy at and after the cutoff is zero
/// assert_eq!(interaction.energy(2.0), 0.0);
/// ```
Get the energy for this pair interaction at the distance `r`.
Get the energy for this pair interaction at the distance ` r ` .
pub fn energy(&self, r: f64) -> f64 {
        if r >= self.cutoff {
            0.0
        } else {
            let energy = self.potential.energy(r);
            match self.computation {
                PairComputation::Cutoff => energy,
                PairComputation::Shifted(shift) => energy - shift,
            }
        }
    }
pub fn energy ( & self , r : f64 ) -> f64 { if r >= self . cutoff { 0.0 } else { let energy = self . potential . energy ( r ) ; match self . computation { PairComputation :: Cutoff => energy , PairComputation :: Shifted ( shift ) => energy - shift , } } }
Get the energy for this pair interaction at the distance `r`.
Get the energy for this pair interaction at the distance ` r ` .
&self
r
f64
examples
```
use lumol_core::energy::PairInteraction;
use lumol_core::energy::Harmonic.

let potential = Box::new(Harmonic{x0: 0.5, k: 4.2});
let interaction = PairInteraction::new(potential, 2.0).

assert_eq!(interaction.energy(1.0), 0.525);
energy at and after the cutoff is zero
assert_eq!(interaction.energy(2.0), 0.0);
```
` ` ` use lumol_core :: energy :: PairInteraction ; use lumol_core :: energy :: Harmonic . let potential = Box :: new ( Harmonic { x0 : 0 . 5 k : 4 . 2 } ) ; let interaction = PairInteraction :: new ( potential 2 . 0 ) . assert_eq! ( interaction . energy ( 1 . 0 ) 0 . 525 ) ; energy at and after the cutoff is zero assert_eq! ( interaction . energy ( 2 . 0 ) 0 . 0 ) ; ` ` `