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] + F(x_traj[i]) * dt / 2
x_traj[i+1] = x_traj[i] + v_traj[i+1] * dt
v_traj[i+1] += F(x_traj[i+1]) * dt / 2
return x_traj, v_traj
Go to Google Form