Tabulated EAM and Finnis-Sinclair potentials -------------------------------------------- ``EAMTablePot`` reads an embedded atom method (EAM) potential from a DYNAMO table and evaluates :: E = sum_i F_a(rho_i) + sum_{i`_. .. table:: +--------------------+---------------+----------------+-------------------------------------------------------------+ | ``EAMTableFormat`` | LAMMPS style | Suffix | Arrays | +====================+===============+================+=============================================================+ | ``Funcfl`` | ``eam`` | ``.eam`` | F(rho), Z(r), rho(r), one element | +--------------------+---------------+----------------+-------------------------------------------------------------+ | ``Setfl`` | ``eam/alloy`` | ``.eam.alloy`` | F\ :sub:`a`\(rho), rho\ :sub:`b`\(r), r phi\ :sub:`ab`\(r) | +--------------------+---------------+----------------+-------------------------------------------------------------+ | ``FinnisSinclair`` | ``eam/fs`` | ``.eam.fs`` | F\ :sub:`a`\(rho), rho\ :sub:`ab`\(r), r phi\ :sub:`ab`\(r) | +--------------------+---------------+----------------+-------------------------------------------------------------+ A ``Setfl`` density depends only on the neighbor, so ``rho_ab = rho_b``. The ``FinnisSinclair`` layout carries a density for each ordered pair of elements. It is the form of Finnis and Sinclair, Philosophical Magazine A 50, 45 (1984). Section b of an ``.eam.fs`` file lists F\ :sub:`b`\ and then ``rho_1b`` to ``rho_Nb``, the density b puts at a site of each element in turn. The potential is opt-in. Meson builds it with ``-Dwith_eam_table=true`` and CMake with ``-DRGPOT_WITH_EAM_TABLE=ON``. Both define ``RGPOT_HAS_EAM_TABLE``. Without the option, no EAMTable code is compiled. .. code:: cpp #include "rgpot/EAMTable/EAMTablePot.hpp" rgpot::EAMTablePot pot({.path = "CuNi.eam.alloy", .format = rgpot::EAMTableFormat::Setfl, .periodic = true, .stress = true}); ``read_eam_table`` parses a stream into an ``EAMTable``, and a second constructor takes that table directly. Agreement with LAMMPS --------------------- The tables go through the steps of ``src/MANYBODY/pair_eam.cpp``, so a file gives the LAMMPS energy and forces to rounding. - A ``Funcfl`` file is resampled by four-point Lagrange interpolation onto ``lround((N - 1) d / d)`` points, one fewer than the file lists, as ``PairEAM::file2array`` does for a single file. - The pair term of a ``Funcfl`` file is ``r phi = 27.2 * 0.529 * Z(r)^2`` in eV Angstrom. 27.2 is the Hartree in eV and 0.529 the Bohr radius in Angstrom, the rounded values LAMMPS uses. - Each array becomes the seven-coefficient cubic of ``PairEAM::interpolate``. Its slopes are five-point central differences inside the table, three-point central differences at the second and second-to-last points, and one-sided differences at the ends. - Above ``rhomax = (Nrho - 1) drho`` of the file, the energy adds ``F'(rho) (rho - rhomax)`` with the slope at the last table point. Above the last distance point, both the value and the slope are those at the end of the table. - A pair counts when r is below the cutoff on the grid line. Two choices differ from LAMMPS. An atom picks its element by atomic number, matched against the first field of each element line, where LAMMPS maps types to the element names on line 4. A file whose element lines do not carry atomic numbers cannot be used as it is. Only one ``Funcfl`` file is read, so the LAMMPS mixing of several ``.eam`` files is not available. The ``eam/he`` and ``eam/cd`` layouts are not read. Periodic evaluation keeps one image of each partner, so it needs the cutoff under half of every face spacing of the cell. The constructor does not check the cutoff against a cell; it throws ``std::invalid_argument`` for a file it cannot open or parse. ``forceImpl`` throws ``std::invalid_argument`` for a smaller cell, for a periodic call without a cell, and for an atomic number that is in no element line. Stress ------ ``EAMTableConfig::stress`` is off by default. When it is set, ``forceImpl`` writes the Cauchy stress ``sigma = (1/V) dE/dstrain`` of ``stress.hpp`` and sets ``has_stress``. The force pass adds ``-fscale * d d^T`` for each pair, as ``SuttonChenPot`` does, because the embedding term enters fscale through F'. With the flag clear, the stress slots and ``has_stress`` are left as the caller set them, and the energy and forces are the same bits. Setting the flag changes ``paramsKey()``. Pair list --------- The spline tables and the map from atomic numbers to elements are made once, in the constructor. The potential has no setter for them, so they change only with a new potential. ``forceImpl`` and ``forcePerAtom`` keep one ``nlist::Neighbours`` list of the pairs within the cutoff plus ``EAMTableConfig::skin`` (1 Angstrom by default), and reuse it while every atom stays within half the skin of where it was at the last build. The move is measured to the nearest periodic image, so atoms that the caller wraps back into the cell keep the list. A new cell, another atom count, or a move past half the skin rebuilds it. Another element on a site does not, as the list holds positions only. The pairs within the cutoff are visited in the same order with any skin, so the skin changes how often the list is built, not the bits of the result, and it is not part of ``paramsKey()``. ``skin = 0`` rebuilds the list whenever an atom moves. ``setNeighbourMode(nlist::Mode::Stream)`` walks the cells on every call and keeps no list. ``listReused()`` tells whether the last call kept the list and ``listBuilds()`` counts the builds. The list is scratch that each call rewrites, so ``caps().reentrancy`` is ``Reentrancy::PerInstance``, as for the other potentials that keep one: give each thread its own instance. The two stages of ``Staged.hpp`` run on the host's list and do not touch it. Checks ------ ``EAMTablePotTest`` compares rgpot with LAMMPS version 22 Jul 2025. ``CppCore/tests/data/eam_table/make_lammps_ref.py`` writes two references from files in the LAMMPS ``potentials`` directory, copied unchanged. - ``Cu_u3.eam``, a ``Funcfl`` file for copper from Foiles, Baskes and Daw, Physical Review B 33, 7983 (1986). It has 500 points in rho and in r and a cutoff of 4.95 Angstrom. - ``CuNi.eam.alloy``, a ``Setfl`` file for copper and nickel from Onat and Durukanoglu, Journal of Physics: Condensed Matter 26, 035404 (2014). It has 500 points in rho and in r and a cutoff of 6.394332378 Angstrom. The ``Cu_u3`` case is a jittered 108-atom fcc copper cell in a cubic box. The ``CuNi`` case is a jittered 256-atom fcc cell in a sheared box, with nickel or copper at random on each site. A third case takes the Sutton-Chen platinum row as LAMMPS saw it. ``CppCore/tests/data/sutton_chen/make_lammps_ref.py`` writes that row as a 50001-point ``eam/fs`` table, and the case compares with its cubic reference. .. table:: +------------------+---------------+-----------------+---------------------------------+---------------------------------------------+ | Case | LAMMPS style | energy gap (eV) | largest force gap (eV/Angstrom) | largest stress gap (eV/Angstrom\ :sup:`3`\) | +==================+===============+=================+=================================+=============================================+ | ``Cu_u3`` cubic | ``eam`` | 2.3e-12 | 8.1e-15 | 7.3e-17 | +------------------+---------------+-----------------+---------------------------------+---------------------------------------------+ | ``CuNi`` sheared | ``eam/alloy`` | 3.1e-12 | 1.7e-14 | 1.5e-16 | +------------------+---------------+-----------------+---------------------------------+---------------------------------------------+ | Pt cubic | ``eam/fs`` | 1.7e-12 | 5.1e-12 | 1.0e-14 | +------------------+---------------+-----------------+---------------------------------+---------------------------------------------+ The test asks for 1e-10 eV, 1e-10 eV/Angstrom and 1e-13 eV/Angstrom\ :sup:`3`\. The test rebuilds the Sutton-Chen table in C++ from the formulas of that script rather than reading a file. ``[skin]`` follows the sheared ``CuNi`` cell through small moves, atoms shifted by cell vectors and wrapped back, another element on some sites, one atom past half the skin, a strained cell and one atom fewer. After each step the potential with its 1 Angstrom skin gives the energy, the forces, the stress and the per-atom energies and virials of a potential with skin 0 to the bit, and ``listReused()`` and ``listBuilds()`` show a rebuild exactly for the move past the skin, the strain and the atom count. On a free ``Cu_u3`` cluster the kept list matches skin 0 to the bit and a stream within 1e-10 eV and eV/Angstrom. A two-element ``eam/fs`` table of constants checks the order of the density blocks. The A-A, A-B and B-B dimers give -2, -11 and -28 in the documented order. Reading the sections or the blocks inside a section the other way round changes at least one of them.