Skip to main content

parallel_pairwise_forces

Function parallel_pairwise_forces 

Source
pub fn parallel_pairwise_forces(
    positions: &[[f64; 3]],
    n: usize,
    force_fn: impl Fn(usize, usize, [f64; 3]) -> [f64; 3] + Sync,
) -> Vec<[f64; 3]>
Expand description

Parallel pairwise force accumulation.

Computes the net force on every particle. The outer loop (over particle i) runs in parallel; each thread independently sums the contributions from all j != i.

ยงArguments

  • positions - particle positions.
  • n - number of particles (must equal positions.len()).
  • force_fn - force_fn(i, j, r_ij) -> force_on_i_from_j.