got the script working to calculate dispersion with periodic boundary conditions