LAMMPS from scratch · 15 min

Packages

Most of LAMMPS is optional: 94 packages, each a folder of styles that is compiled only if you switch it on. You find out which packages the LAMMPS in this page was built with, count by hand how many styles that should give, and check the count against LAMMPS. Then you paste a script, predict which packages it needs and which line will fail, and run it to see.

1 · Understand: a core and many packages

Page B.1 showed that src/ holds the core (always compiled) and 94 upper-case folders. Each folder is a package: a group of styles that belong together. You choose them when you build (page 0.4):

cmake -D PKG_MOLECULE=on -D PKG_KSPACE=on -D PKG_RIGID=on ../cmake
cmake --build . -j 4

Why not compile everything? Some packages need outside libraries (GPU drivers, Python, a machine-learning library), each one adds compile time, and every package switched on is code that must compile on your machine. Most users need five or six.

PackageWhat it addsYou need it for
MOLECULEbonds, angles, dihedrals, impropers; atom_style full, bond, angleany molecule
KSPACElong-range Coulomb: Ewald, PPPM, and the pair styles that go with them (…/coul/long)charged systems, water
RIGIDrigid bodies, and fix shake / rattle for rigid bondsrigid water models
MANYBODYmany-body potentials: EAM, Tersoff, Stillinger–Weber …metals, semiconductors
EXTRA-PAIR, EXTRA-FIX, EXTRA-COMPUTE, EXTRA-MOLECULEless common styles of each familywhen the manual names one
DRUDEDrude-oscillator polarizable modelspolarizable force fields
ML-SNAP, ML-PACE, ML-IAP …machine-learning potentialsMLIPs
OPENMP, INTEL, OPT, GPU, KOKKOSthe same styles again, faster on threads or GPUs (suffix /omp, /intel, /opt, /gpu, /kk)speed (page F.6)

A style's package is written nowhere in the script. It is decided by which folder its file sits in. The registration step (page B.3) only collects styles from folders that were switched on; for all other styles the build writes a list of names and their packages (packages_pair.h and so on, read in src/lammps.cpp:1050), so that an unknown style can be answered with the package to add (src/utils.cpp:444).

2 · Observe: what is in this LAMMPS?

On your own computer, lmp -h prints the same list near the end, under "Installed packages".

3 · Match: count the styles by hand

If only the core and MOLECULE are built in, the styles available must be exactly those registered in src/*.h plus those in src/MOLECULE/*.h. Count them from the source tree of page B.1, then ask LAMMPS with info styles.

4 · Modify: which packages does a script need?

Choose a script or paste your own. The page reads every style it names, finds its file in the source tree, and predicts the first line this LAMMPS (core + MOLECULE) will stop at. Then run it.

What the packages show

Your turn

1. Which packages does a script with pair_style eam/alloy, fix nvt and compute msd need?

2. The core has 24 pair styles and MOLECULE adds 7. KSPACE adds how many pair styles? Find out from the source tree of page B.1.

3. You switch on OPENMP. Does the number of physical models you can use go up?