Skip to main content

leapfrog

Function leapfrog 

Source
pub fn leapfrog(
    positions: &[f64],
    velocities: &[f64],
    forces_fn: impl Fn(&[f64]) -> Vec<f64>,
    dt: f64,
    steps: usize,
) -> Vec<(Vec<f64>, Vec<f64>)>
Expand description

Leapfrog (Störmer-Verlet) symplectic integrator for N-body-style systems. positions and velocities are flat arrays of length 3*N. forces_fn takes positions and returns force vectors (acceleration). Returns steps of (positions, velocities).