Skip to content

Instantly share code, notes, and snippets.

@andersx
Created April 27, 2013 12:06
Show Gist options
  • Save andersx/5472874 to your computer and use it in GitHub Desktop.
Save andersx/5472874 to your computer and use it in GitHub Desktop.
MD//lennard-jones simulation
import numpy
from forces import lennardjones
# Initialize simulations (code not shown)
temperature = 2.0
n_atoms = 100
rho = 0.01
U = initialize_positions(n_atoms, rho)
box = initialize_box(n_atoms, rho)
V = initialize_velocities(U, temperature)
# Start simulation
n_steps = 10000
dt = 0.001
(epot,F,Vir) = lennardjones(U,box)
for i in range(n_steps):
U += V * dt + 0.5 * F * dt * dt
F0 = F[:]
(epot, F, Vir) = lennardjones(U, box)
V += 0.5 * (F + F0) * dt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment