added subroutines for calculating velocities and coping with boundaries
merge done