Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

3. Scaling to O(N): linked-cell lists and Verlet neighbor lists

School of Engineering and Digital Sciences, Nazarbayev University

Track: core  ·  Prerequisites: Chapters 1–2

This chapter builds and verifies the core algorithms for scaling to o(n): linked-cell lists and verlet neighbor lists in plain Python and NumPy, checking every result against an exact statistical-mechanics limit or published benchmark.

3.1 Physical principles and governing equations

Evaluating all N(N−1)/2N(N-1)/2 pairs scales as O(N2)O(N^2) and dominates runtime once N>300N > 300. Linked-cell lists partition the cubic box into cells of edge ≥rc\ge r_c so each particle checks only its own cell and 13 forward neighbor cells (O(N)O(N) scaling). Verlet neighbor lists store all pairs within rv=rc+rsr_v = r_c + r_s and rebuild automatically only when the maximum particle displacement since the last build exceeds rs/2r_s / 2.

3.2 Inside the algorithm

3.3 Checks

Max force discrepancy vs O(N^2): Linked-Cell = 7.11e-15, Verlet List = 7.11e-15
Total Verlet list rebuilds over 40 steps (skin=0.35): 4
<Figure size 1120x430 with 2 Axes>

Figure 3.1. (a) Primary physical or dynamical observable computed from scratch in engsim. (b) Quantitative verification against the analytical or benchmark reference.

3.4 What to trust

  • Numerical predictions are verified to the stated tolerances against exact analytical limits (engsim.reference).

  • Finite-size effects (NN, periodic image interactions) and timestep truncation (O(Δt2)O(\Delta t^2)) should always be checked before comparing against bulk experimental data.

Summary

  • The algorithm is implemented transparently in pure NumPy without hidden black-box routines.

  • All core physical invariants (conservation laws, ensemble variance, or scaling exponents) are verified quantitatively in code.

Exercises

  1. Skin radius trade-off: Compare vnl.n_rebuilds for skin = 0.15 vs skin = 0.50 over 40 steps.

  2. Virial parity: Verify that w_cl == w_n2 and w_vl == w_n2 to <10−11<10^{-11}.

  3. Small-box guard: Verify that when L/rc<3L / r_c < 3, lj_forces_cell_list safely falls back to exact all-pairs without double-counting periodic images.

Worked solutions are provided in 03_solutions.ipynb.

Suggested references

  • D. Frenkel and B. Smit, Understanding Molecular Simulation (3rd ed., Academic Press, 2023).

  • M. P. Allen and D. J. Tildesley, Computer Simulation of Liquids (2nd ed., Oxford University Press, 2017).