Compilation of lammps with MPI, OpenMP, Python, and ASE lammpslib support
396
LAMMPS is a classical molecular dynamics code that supports a very large number of interaction models. The full documentation can be found here. This repository provides images with precompiled lammps versions that are set up to allow LAMMPS to be run both from the command line and as a calculator via ase.
When inside the container, the LAMMPS installation files can be found in /lammps/. This includes potential input files, which reside in /lammps/potentials/ and examples in /lammps/examples, which you can use to test the image.
Running the following command will launch an interactive shell
docker run -it -v $PWD:/data materialsmodeling/lammps
Here, the current directory has been mounted in order to enable reading from and writing data to disk during the session. One can now simply run LAMMPS as follows
lmp -in <input_file>
Here <input_file> is the main LAMMPS input file, which must reside in the directory from which the container is launched along with all other pertinent input files.
As a practical test you can try the following
cp -r /lammps/examples/indent/ .
cd indent
lmp -in in.indent
To utilize MPI parallelization run
mpirun -np <n_cores> lmp -in <input_file>
To utilize OpenMP parallelization set the number of threads before starting LAMMPS
export OMP_NUM_THREADS=4
LAMMPS can also be run without launching a shell via
docker run -v $PWD:/data materialsmodeling/lammps <command>
Here, <command> is the usual command used to launch, as for example in
docker run -v $PWD:/data materialsmodeling/lammps lmp -in my_input_file.in
or
docker run -v $PWD:/data materialsmodeling/lammps mpirun -np4 lmp -in my_input_file.in
LAMMPS can also be run as a calculator via ase. The following script serves as a simple example
from ase.build import bulk
from ase.calculators.lammpslib import LAMMPSlib
calc = LAMMPSlib(lmpcmds=['pair_style sw',
'pair_coeff * * /lammps/potentials/Si.sw Si'],
log_file='lammps.log',
keep_alive=True,
atom_types={'Si': 1})
atoms = bulk('Si')
atoms.set_calculator(calc)
energy = atoms.get_potential_energy()
print(f'energy: {energy}')
This script (ase-lammpslib-sw.py) can be launched as follows
docker run -v $PWD:/data materialsmodeling/lammps-ase:patch_8Feb2019 python3 ase-lammpslib-sw.py
Content type
Image
Digest
Size
1 GB
Last updated
over 7 years ago
docker pull materialsmodeling/lammps-ase