LAMMPS from scratch · 15 min
From run 250 to the loop
Typing run 250 does much more than 250 steps: LAMMPS initialises every member, wraps and shares the atoms, builds the first neighbour list and computes the forces once before step 1, and prints a summary after the last. You follow the six stops in the code, then predict for two runs in a row which steps get a thermo line and how many neighbour builds the log reports, including the surprises of pre no and upto, and check them against LAMMPS.
- The path from the run command to Verlet::run(): parse, init, setup, loop, finish
- Why the first thermo line comes from setup, and forces are computed N + 1 times
- Predict thermo lines and neighbour builds for consecutive runs
- What run … upto and run … pre no change
1 · Understand: six stops from run to the loop
Three consequences you can see in every log:
- The thermo line at the starting step is printed by setup, not by the loop. A run of N steps computes the forces N + 1 times.
- The neighbour list built in setup is not counted: "Neighbor list builds" counts only the loop's builds.
- After the loop, thermo always prints the last step, whatever the
thermointerval (src/output.cpp:215).
2 · Predict: two runs in a row
in.melt with your settings, then a second run. The rules from the code: thermo prints the first step, every multiple of the interval, and the last step; the list is rebuilt when the steps since the last build reach a multiple of every (src/neighbor.cpp:2373: ago++; if (ago % every == 0)).
3 · Observe: what upto and pre no change
- run N upto: N is the step to stop at, not the number of steps (src/run.cpp:113). After run 250,
run 330 uptoruns 80 steps. Useful in scripts that are restarted: the end step stays the same. - run N pre no: skips
lmp->init()and setup (src/run.cpp:168). No new neighbour list, no force recomputation, and the build counter is not reset, so the log prints the builds of both runs added together. It saves time when a script runs many short runs in a loop, but only if nothing was changed between them: a changed pair_coeff or fix would be ignored without init. - Between two normal runs the step and the time carry on (page B.2), and the thermo line of the shared step is printed twice: once as the last line of run 1, once by setup of run 2.
Your turn
1. thermo 100, run 250. Which steps are printed?
2. neigh_modify every 20 check no, run 250, then run 30 pre no. What does the second run's log say for "Neighbor list builds"?
3. How many times are forces computed by run 0?
run 0 is the standard way to get the energy and pressure of a structure without moving it (pages A.5, A.8).