Created
April 27, 2013 12:06
-
-
Save andersx/5472874 to your computer and use it in GitHub Desktop.
MD//lennard-jones simulation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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