LAMMPS can be run interactively using iPython easily. This tutorial shows how to set this up.
$LAMMPS_DIR
from now on)Compile LAMMPS as a shared library and enable PNG support
cd $LAMMPS_DIR/src
python2 Make.py -m mpi -png -a file
make mode=shlib auto
Create a python virtualenv
virtualenv testing
source testing/bin/activate
Inside the virtualenv install the lammps package
(testing) cd $LAMMPS_DIR/python
(testing) python install.py
(testing) cd # move to your working directory
Install jupyter and ipython in the virtualenv
(testing) pip install ipython jupyter
Run jupyter notebook
(testing) jupyter notebook
In [1]:
from lammps import IPyLammps
In [2]:
L = IPyLammps()
In [3]:
import math
# 3d Lennard-Jones melt
L.units("lj")
L.atom_style("atomic")
L.atom_modify("map array")
L.lattice("fcc", 0.8442)
L.region("box", "block", 0, 4, 0, 4, 0, 4)
L.create_box(1, "box")
L.create_atoms(1, "box")
L.mass(1, 1.0)
L.velocity("all", "create", 1.44, 87287, "loop geom")
L.pair_style("lj/cut", 2.5)
L.pair_coeff(1, 1, 1.0, 1.0, 2.5)
L.neighbor(0.3, "bin")
L.neigh_modify("delay", 0, "every", 20, "check no")
L.fix("1 all nve")
L.variable("fx atom fx")
L.info("all")
L.run(10)
Out[3]:
In [4]:
L.image(zoom=1.0)
Out[4]: