import numpy as np
def verlet_integrate(x0, v0, F, steps=1000, dt=0.001):
"""
Integrates given force field with Velocity-Verlet integration
"""
x_traj = np.zeros(steps)
v_traj = np.zeros(steps)
[insert]
return x_traj, v_traj
import numpy as np
def verlet_integrate(x0, v0, F, steps=1000, dt=0.001):
"""
Integrates given force field with Velocity-Verlet integration
"""
x_traj = np.zeros(steps)
v_traj = np.zeros(steps)
x_traj[0] = x0
v_traj[0] = v0
for i in range(steps-1):
v_traj[i+1] = v_traj[i] + 0.5*dt*F(x_traj[i])
x_traj[i+1] = x_traj[i] + dt*v_traj[i+1]
v_traj[i+1] = v_traj[i+1] + 0.5*dt*F(x_traj[i+1])
return x_traj, v_traj
Go to Google Form