pub fn move_all_molecules_cost(&mut self, system: &System) -> f64 {
        let evaluator = system.energy_evaluator();

        let mut new_pairs = Array2::<f64>::zeros((system.size(), system.size()));
        let mut pairs_delta = 0.0;
        // Loop over all molecule pairs
        for (i, mol_i) in system.molecules().enumerate() {
            for mol_j in system.molecules().skip(i + 1) {
                // Loop over all particles in the molecules
                for part_i in mol_i.indexes() {
                    for part_j in mol_j.indexes() {
                        let r = system.distance(part_i, part_j);
                        let path = system.bond_path(part_i, part_j);
                        let energy = evaluator.pair(path, r, part_i, part_j);
                        pairs_delta += energy;
                        new_pairs[(part_i, part_j)] += energy;
                        new_pairs[(part_j, part_i)] += energy;
                        pairs_delta -= self.pairs_cache[(part_i, part_j)];
                    }
                }
            }
        }

        // temporarily, recompute all interactions
        let new_coulomb = evaluator.coulomb();
        let new_global = evaluator.global();

        // compute the new tail correction
        let pairs_tail = evaluator.pairs_tail();

        let cost = pairs_delta + (pairs_tail - self.pairs_tail) + (new_coulomb - self.coulomb)
            + (new_global - self.global);

        self.updater = Some(Box::new(move |cache, system| {
            cache.pairs += pairs_delta;
            cache.pairs_tail = pairs_tail;
            cache.coulomb = new_coulomb;
            cache.global = new_global;

            let (n, m) = new_pairs.dim();
            debug_assert_eq!(n, m);
            debug_assert_eq!((n, m), cache.pairs_cache.dim());
            for (i, mol_i) in system.molecules().enumerate() {
                for mol_j in system.molecules().skip(i + 1) {
                    for part_i in mol_i.indexes() {
                        for part_j in mol_j.indexes() {
                            cache.pairs_cache[(part_i, part_j)] = new_pairs[(part_i, part_j)];
                            cache.pairs_cache[(part_j, part_i)] = new_pairs[(part_i, part_j)];
                        }
                    }
                }
            }
        }));
        cost
    }
/// 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.
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.



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


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 . It ** DOES NOT ** recompute bonds angles and dihedral interactions . You must not use this function when the intramolecular configuration changed .
pub fn move_all_molecules_cost(&mut self, system: &System) -> f64 {
        let evaluator = system.energy_evaluator();
        let mut new_pairs = Array2::<f64>::zeros((system.size(), system.size()));
        let mut pairs_delta = 0.0;
        // Loop over all molecule pairs
        for (i, mol_i) in system.molecules().enumerate() {
            for mol_j in system.molecules().skip(i + 1) {
                // Loop over all particles in the molecules
                for part_i in mol_i.indexes() {
                    for part_j in mol_j.indexes() {
                        let r = system.distance(part_i, part_j);
                        let path = system.bond_path(part_i, part_j);
                        let energy = evaluator.pair(path, r, part_i, part_j);
                        pairs_delta += energy;
                        new_pairs[(part_i, part_j)] += energy;
                        new_pairs[(part_j, part_i)] += energy;
                        pairs_delta -= self.pairs_cache[(part_i, part_j)];
                    }
                }
            }
        }
        // temporarily, recompute all interactions
        let new_coulomb = evaluator.coulomb();
        let new_global = evaluator.global();
        // compute the new tail correction
        let pairs_tail = evaluator.pairs_tail();
        let cost = pairs_delta + (pairs_tail - self.pairs_tail) + (new_coulomb - self.coulomb)
            + (new_global - self.global);
        self.updater = Some(Box::new(move |cache, system| {
            cache.pairs += pairs_delta;
            cache.pairs_tail = pairs_tail;
            cache.coulomb = new_coulomb;
            cache.global = new_global;
            let (n, m) = new_pairs.dim();
            debug_assert_eq!(n, m);
            debug_assert_eq!((n, m), cache.pairs_cache.dim());
            for (i, mol_i) in system.molecules().enumerate() {
                for mol_j in system.molecules().skip(i + 1) {
                    for part_i in mol_i.indexes() {
                        for part_j in mol_j.indexes() {
                            cache.pairs_cache[(part_i, part_j)] = new_pairs[(part_i, part_j)];
                            cache.pairs_cache[(part_j, part_i)] = new_pairs[(part_i, part_j)];
                        }
                    }
                }
            }
        }));
        cost
    }
pub fn move_all_molecules_cost ( & mut self , system : & System ) -> f64 { let evaluator = system . energy_evaluator ( ) ; let mut new_pairs = Array2 :: < f64 > :: zeros ( ( system . size ( ) , system . size ( ) ) ) ; let mut pairs_delta = 0.0 ; // Loop over all molecule pairs for ( i , mol_i ) in system . molecules ( ) . enumerate ( ) { for mol_j in system . molecules ( ) . skip ( i + 1 ) { // Loop over all particles in the molecules for part_i in mol_i . indexes ( ) { for part_j in mol_j . indexes ( ) { let r = system . distance ( part_i , part_j ) ; let path = system . bond_path ( part_i , part_j ) ; let energy = evaluator . pair ( path , r , part_i , part_j ) ; pairs_delta += energy ; new_pairs [ ( part_i , part_j ) ] += energy ; new_pairs [ ( part_j , part_i ) ] += energy ; pairs_delta -= self . pairs_cache [ ( part_i , part_j ) ] ; } } } } // temporarily, recompute all interactions let new_coulomb = evaluator . coulomb ( ) ; let new_global = evaluator . global ( ) ; // compute the new tail correction let pairs_tail = evaluator . pairs_tail ( ) ; let cost = pairs_delta + ( pairs_tail - self . pairs_tail ) + ( new_coulomb - self . coulomb ) + ( new_global - self . global ) ; self . updater = Some ( Box :: new ( move | cache , system | { cache . pairs += pairs_delta ; cache . pairs_tail = pairs_tail ; cache . coulomb = new_coulomb ; cache . global = new_global ; let ( n , m ) = new_pairs . dim ( ) ; debug_assert_eq ! ( n m ) ; debug_assert_eq ! ( ( n m ) cache pairs_cache dim ( ) ) ; for ( i , mol_i ) in system . molecules ( ) . enumerate ( ) { for mol_j in system . molecules ( ) . skip ( i + 1 ) { for part_i in mol_i . indexes ( ) { for part_j in mol_j . indexes ( ) { cache . pairs_cache [ ( part_i , part_j ) ] = new_pairs [ ( part_i , part_j ) ] ; cache . pairs_cache [ ( part_j , part_i ) ] = new_pairs [ ( part_i , part_j ) ] ; } } } } } ) ) ; cost }
Return the cost for moving all **rigid** molecules of the system.
Return the cost for moving all ** rigid ** molecules of the system .
&mut self
system
&System