forked from navining/metadynamics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverlet.py
More file actions
20 lines (16 loc) · 698 Bytes
/
verlet.py
File metadata and controls
20 lines (16 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import numpy as np
# We have written the Verlet time-stepping functions for you below,
# `h` is the time step.
# -----------------------------------------------------------------
def VerletNextR(r_t, v_t, a_t, h):
"""Return new positions after one Verlet step"""
# Note that these are vector quantities.
# Numpy loops over the coordinates for us.
r_t_plus_h = r_t + v_t * h + 0.5 * a_t * h * h
return r_t_plus_h
def VerletNextV(v_t, a_t, a_t_plus_h, h):
"""Return new velocities after one Verlet step"""
# Note that these are vector quantities.
# Numpy loops over the coordinates for us.
v_t_plus_h = v_t + 0.5 * (a_t + a_t_plus_h) * h
return v_t_plus_h