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.
- What a package is, and why LAMMPS is split into them
- Ask a LAMMPS binary which packages it has (info config, lmp -h)
- Count the styles a build should have, by hand, from the source tree
- Read a script and predict the packages it needs before you run it
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.
| Package | What it adds | You need it for |
|---|---|---|
MOLECULE | bonds, angles, dihedrals, impropers; atom_style full, bond, angle | any molecule |
KSPACE | long-range Coulomb: Ewald, PPPM, and the pair styles that go with them (…/coul/long) | charged systems, water |
RIGID | rigid bodies, and fix shake / rattle for rigid bonds | rigid water models |
MANYBODY | many-body potentials: EAM, Tersoff, Stillinger–Weber … | metals, semiconductors |
EXTRA-PAIR, EXTRA-FIX, EXTRA-COMPUTE, EXTRA-MOLECULE | less common styles of each family | when the manual names one |
DRUDE | Drude-oscillator polarizable models | polarizable force fields |
ML-SNAP, ML-PACE, ML-IAP … | machine-learning potentials | MLIPs |
OPENMP, INTEL, OPT, GPU, KOKKOS | the 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
- A rigid water model with long-range Coulomb needs three packages: MOLECULE for bonds, KSPACE for PPPM and the
coul/longpair style, RIGID forfix shake. The water script stops at its first missing one; delete that line (or switch tolj/cut/coul/cut) and it stops at the next. LAMMPS reports one problem at a time; reading the script against the source tree finds them all at once. - Some everyday styles are in the core even though they sound special:
fix nvt,fix npt,fix langevin,compute rdf,compute msd. - When you install LAMMPS from a package manager or use a cluster module, it was built by someone else. Run
lmp -honce and keep the list.
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.
…/coul/long, …/coul/msm and similar long-range versions. Building with KSPACE would raise the pair count by that number, which you can check with info styles on your own build.3. You switch on OPENMP. Does the number of physical models you can use go up?