# [−]Struct lumol::sys::EnergyCache

pub struct EnergyCache { /* fields omitted */ }

This is a cache for energy computation.

Cache integrity is left up to the user of this structure: any function with update_ prefix must be called as needed to ensure cache consistency.

## Implementations

### impl EnergyCache

#### pub fn new() -> EnergyCache

Create a new empty energy cache.

#### pub fn init(&mut self, system: &System)

Initialize the cache to be used with system. After a call to this function, the cache is only usable with the same system. To change the associated system, one must call this function again.

#### pub fn energy(&self) -> f64

Get the cached energy

#### pub fn update(&mut self, system: &mut System)

Update the cache after a call to a EnergyCache::*_cost function or EnergyCache::unused.

#### pub fn unused(&mut self)

This function should be called whenever the cache is not used, but one still want it to be updated. Future call to EnergyCache::update will recompute the full cache.

### impl EnergyCache

#### pub fn move_molecule_cost(    &mut self,     system: &System,     molecule_id: usize,     new_positions: &[Vector3D]) -> f64

Get the cost of moving a rigid molecule at molecule_id in the system to new_positions.

This function DOES NOT update the cache, the update function MUST be called if the particles are effectively moved.

#### pub fn move_all_molecules_cost(&mut self, system: &System) -> f64

Return the cost for moving all rigid molecules of the system.

This function is intended for use when all the molecules in the system are moved rigidly, for example when resizing the system in NPT Monte Carlo. It computes energy changes due to:

• non bonded pairs interactions;
• Coulomb interactions;
• global interactions;

It DOES NOT recompute bonds, angles and dihedral interactions. You must not use this function when the intramolecular configuration changed.

This function DOES NOT update the cache, the update function MUST be called if the molecules are effectively moved.

## Blanket Implementations

### impl<T> Pointable for T

#### type Init = T

The type for initializers.

### impl<T, U> TryFrom<U> for T where    U: Into<T>, [src]

#### type Error = Infallible

The type returned in the event of a conversion error.

### impl<T, U> TryInto<U> for T where    U: TryFrom<T>, [src]

#### type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.