Table of Contents
Install lammps
Instructions on how to install lammps using cmake are here: https://lammps.sandia.gov/doc/Build_cmake.html and all sorts of package options are here: https://lammps.sandia.gov/doc/Build_package.html
In general, it follows the very same (git) recipe for any installation:
cd programs/ git clone https://github.com/lammps/lammps.git cd lammps/ mkdir build cd build/ cmake ../cmake -DCMAKE_INSTALL_PREFIX="~/Programs/lammps-19Sep2019" -DPKG_MOLECULE=yes -DPKG_OPT=yes make install
Lammps stores its cmake files NOT in the main directory but in a subdirectory called cmake
, so ../cmake
has to be used to tell cmake where to look for them.
Use ccmake .
after you executed cmake to see all the options ( -DPKG_…=yes
) there are for configuring lammps packages.
You can do make install -j4
to use four cores for compiling, it should be faster. The lammps executable will be in the folder '~/Programs/lammps-19Sep2019/bin' and is commonly called 'lmp'.
Install lammps with MPI
Lammps will need MPI to run efficiently, so load the appropriate modules on the cluster.
For compiling Lammps with MPI add the flag -DBUILD_MPI=yes
to the cmake
above.
When running the cmake
command, it should include output like
-- Found MPI_CXX: /usr/local/Cellar/open-mpi/4.0.5/lib/libmpi.dylib (found version "3.1") -- Found MPI: TRUE (found version "3.1")
After compiling, the executable now should be able to be run in parallel
mpirun -n 2 ~/Programs/lammps-19Sep2019/bin/lmp -i lammps.init
without modificiations to the input scripts. It should tell you 1 by 1 by 2 MPI processor grid
and 97.1% CPU use with 2 MPI tasks x no OpenMP threads
or similar when you run it.
A possible problem with lammps MPI
Even though installation and cmake outputs seem normal mpirun -np 4
may run 4 of the same simulation instead of parallelizing the same simulation by 4. If that is the case below can be the solution:
- Remove the current lammps build
- Reinstall/install open-MPI with
sudo apt-get install openmpi-bin libopenmpi-dev
- Rebuild lammps as before
Run lammps
To get started, this is a typical lammps input file:
# Create simulation box and initialize system units lj atom_style atomic boundary p p p pair_style lj/cut 1.12246 pair_modify shift yes region box block 0 13.6798 0 13.6798 0 13.6798 units box create_box 1 box # Set model parameters mass 1 1 pair_coeff 1 1 1.0 1.0 1.12246 # Run settings timestep 0.005 run_style verlet # Create atoms create_atoms 1 random 2048 59175 box # Output and dump settings thermo 10000 thermo_style custom step temp epair pe etotal lx ly lz vol pxx pyy pzz press atoms thermo_modify norm no fix thermo_print all print 10000 "$(step) $(temp) $(epair) $(pe) $(etotal) $(lx) $(ly) $(lz) $(vol) $(pxx) $(pyy) $(pzz) $(press) $(atoms)" append thermo.out screen no title "# step temp epair pe etotal lx ly lz vol pxx pyy pzz press atoms" dump 1 all custom 100000 tg.lmpdump id type x y z dump_modify 1 sort id append yes restart 50000 restart.1 restart.2 # Apply initial velocities, minimize initial config, define integrator neigh_modify every 1 delay 0 check yes velocity all create 1.0 73241 dist gaussian units box minimize 1.0e-4 1.0e-6 1000000 100000000 # Equilibrate fix nvt all nvt temp 1.0 1.0 1.0 fix mom all momentum 1 linear 1 1 1 rescale write_data data.init run 1000000 write_data data.inter write_restart restart.inter
It will run a WCA (i.e, LJ with cutoff 1.12246 shifted to zero at cutoff) fluid with 2048 particles in a 13.6798^3 box.
Useful introduction to run the first simulation and understand input scripts/outputs : https://icme.hpc.msstate.edu/mediawiki/index.php/LAMMPS_Polymer.html