fn k_space_forces(&mut self, configuration: &Configuration, forces: &mut [Vector3D]) {
        assert_eq!(forces.len(), configuration.size());
        self.eik_dot_r(configuration);

        let natoms = configuration.size();
        self.field.clear();
        self.field.resize(natoms, Vector3D::zero());

        let thread_local_field = ThreadLocalVec::with_size(natoms);
        self.factors.index
            .par_iter()
            .zip_eq(&self.factors.field)
            .zip_eq(&self.rho)
            .for_each(|((&(ikx, iky, ikz), factor), rho)| {
                let mut field = thread_local_field.borrow_mut();
                for i in 0..natoms {
                    let eikr = self.eikr[(ikx, 0, i)] *
                               self.eikr[(iky, 1, i)] *
                               self.eikr[(ikz, 2, i)];
                    let partial = eikr * rho.conj();
                    field[i] += partial.imag() * factor;
                }
            });

            thread_local_field.sum_into(&mut self.field);

        let charges = configuration.particles().charge;
        for (force, &charge, field) in zip!(&mut *forces, charges, &self.field) {
            *force += charge * field / FOUR_PI_EPSILON_0;
        }
    }
/// k-space contribution to the forces
k-space contribution to the forces
k - space contribution to the forces
fn k_space_forces(&mut self, configuration: &Configuration, forces: &mut [Vector3D]) {
        assert_eq!(forces.len(), configuration.size());
        self.eik_dot_r(configuration);
        let natoms = configuration.size();
        self.field.clear();
        self.field.resize(natoms, Vector3D::zero());
        let thread_local_field = ThreadLocalVec::with_size(natoms);
        self.factors.index
            .par_iter()
            .zip_eq(&self.factors.field)
            .zip_eq(&self.rho)
            .for_each(|((&(ikx, iky, ikz), factor), rho)| {
                let mut field = thread_local_field.borrow_mut();
                for i in 0..natoms {
                    let eikr = self.eikr[(ikx, 0, i)] *
                               self.eikr[(iky, 1, i)] *
                               self.eikr[(ikz, 2, i)];
                    let partial = eikr * rho.conj();
                    field[i] += partial.imag() * factor;
                }
            });
            thread_local_field.sum_into(&mut self.field);
        let charges = configuration.particles().charge;
        for (force, &charge, field) in zip!(&mut *forces, charges, &self.field) {
            *force += charge * field / FOUR_PI_EPSILON_0;
        }
    }
fn k_space_forces ( & mut self , configuration : & Configuration , forces : & mut [ Vector3D ] ) { assert_eq ! ( forces len ( ) configuration size ( ) ) ; self . eik_dot_r ( configuration ) ; let natoms = configuration . size ( ) ; self . field . clear ( ) ; self . field . resize ( natoms , Vector3D :: zero ( ) ) ; let thread_local_field = ThreadLocalVec :: with_size ( natoms ) ; self . factors . index . par_iter ( ) . zip_eq ( & self . factors . field ) . zip_eq ( & self . rho ) . for_each ( | ( ( & ( ikx , iky , ikz ) , factor ) , rho ) | { let mut field = thread_local_field . borrow_mut ( ) ; for i in 0 .. natoms { let eikr = self . eikr [ ( ikx , 0 , i ) ] * self . eikr [ ( iky , 1 , i ) ] * self . eikr [ ( ikz , 2 , i ) ] ; let partial = eikr * rho . conj ( ) ; field [ i ] += partial . imag ( ) * factor ; } } ) ; thread_local_field . sum_into ( & mut self . field ) ; let charges = configuration . particles ( ) . charge ; for ( force , & charge , field ) in zip ! ( mut forces charges self field ) { * force += charge * field / FOUR_PI_EPSILON_0 ; } }
k-space contribution to the forces
k - space contribution to the forces
&mut self
configuration
&Configuration
forces
&mut [Vector3D]