Computer simulation of chemical systems
Ab Initio Methods
# Example: Velocity Verlet integration
def velocity_verlet(r, v, a, dt, potential_fn):
"""Integrate Newton's equations of motion."""
# Half-step velocity update
v_half = v + 0.5 * a * dt
# Full position update
r_new = r + v_half * dt
# Calculate new forces
a_new = -grad(potential_fn, r_new) / mass
# Full velocity update
v_new = v_half + 0.5 * a_new * dt
return r_new, v_new, a_new