Merge pull request #3548 from akohlmey/collected-small-changes

Collected small changes and fixes
This commit is contained in:
Axel Kohlmeyer
2022-12-06 20:13:19 -05:00
committed by GitHub
63 changed files with 263 additions and 232 deletions

View File

@ -50,7 +50,7 @@ parallel each MPI process creates such an instance. This can be seen
in the ``main.cpp`` file where the core steps of running a LAMMPS in the ``main.cpp`` file where the core steps of running a LAMMPS
simulation are the following 3 lines of code: simulation are the following 3 lines of code:
.. code-block:: C++ .. code-block:: c++
LAMMPS *lammps = new LAMMPS(argc, argv, lammps_comm); LAMMPS *lammps = new LAMMPS(argc, argv, lammps_comm);
lammps->input->file(); lammps->input->file();
@ -232,7 +232,7 @@ macro ``PairStyle()`` will associate the style name "lj/cut"
with a factory function creating an instance of the ``PairLJCut`` with a factory function creating an instance of the ``PairLJCut``
class. class.
.. code-block:: C++ .. code-block:: c++
// from force.h // from force.h
typedef Pair *(*PairCreator)(LAMMPS *); typedef Pair *(*PairCreator)(LAMMPS *);
@ -360,7 +360,7 @@ characters; "{:<8}" would do this as left aligned, "{:^8}" as centered,
argument type must be compatible or else the {fmt} formatting code will argument type must be compatible or else the {fmt} formatting code will
throw an exception. Some format string examples are given below: throw an exception. Some format string examples are given below:
.. code-block:: C .. code-block:: c++
auto mesg = fmt::format(" CPU time: {:4d}:{:02d}:{:02d}\n", cpuh, cpum, cpus); auto mesg = fmt::format(" CPU time: {:4d}:{:02d}:{:02d}\n", cpuh, cpum, cpus);
mesg = fmt::format("{:<8s}| {:<10.5g} | {:<10.5g} | {:<10.5g} |{:6.1f} |{:6.2f}\n", mesg = fmt::format("{:<8s}| {:<10.5g} | {:<10.5g} | {:<10.5g} |{:6.1f} |{:6.2f}\n",

View File

@ -105,7 +105,7 @@ list, where each pair of atoms is listed only once (except when the
pairs straddling sub-domains or periodic boundaries will be listed twice). pairs straddling sub-domains or periodic boundaries will be listed twice).
Thus these are the default settings when a neighbor list request is created in: Thus these are the default settings when a neighbor list request is created in:
.. code-block:: C++ .. code-block:: c++
void Pair::init_style() void Pair::init_style()
{ {
@ -129,7 +129,7 @@ neighbor list request to the specific needs of a style an additional
request flag is needed. The :doc:`tersoff <pair_tersoff>` pair style, request flag is needed. The :doc:`tersoff <pair_tersoff>` pair style,
for example, needs a "full" neighbor list: for example, needs a "full" neighbor list:
.. code-block:: C++ .. code-block:: c++
void PairTersoff::init_style() void PairTersoff::init_style()
{ {
@ -141,7 +141,7 @@ When a pair style supports r-RESPA time integration with different cutoff region
the request flag may depend on the corresponding r-RESPA settings. Here an example the request flag may depend on the corresponding r-RESPA settings. Here an example
from pair style lj/cut: from pair style lj/cut:
.. code-block:: C++ .. code-block:: c++
void PairLJCut::init_style() void PairLJCut::init_style()
{ {
@ -160,7 +160,7 @@ Granular pair styles need neighbor lists based on particle sizes and not cutoff
and also may require to have the list of previous neighbors available ("history"). and also may require to have the list of previous neighbors available ("history").
For example with: For example with:
.. code-block:: C++ .. code-block:: c++
if (use_history) neighbor->add_request(this, NeighConst::REQ_SIZE | NeighConst::REQ_HISTORY); if (use_history) neighbor->add_request(this, NeighConst::REQ_SIZE | NeighConst::REQ_HISTORY);
else neighbor->add_request(this, NeighConst::REQ_SIZE); else neighbor->add_request(this, NeighConst::REQ_SIZE);
@ -170,7 +170,7 @@ settings each request can set an id which is then used in the corresponding
``init_list()`` function to assign it to the suitable pointer variable. This is ``init_list()`` function to assign it to the suitable pointer variable. This is
done for example by the :doc:`pair style meam <pair_meam>`: done for example by the :doc:`pair style meam <pair_meam>`:
.. code-block:: C++ .. code-block:: c++
void PairMEAM::init_style() void PairMEAM::init_style()
{ {
@ -189,7 +189,7 @@ just once) and this can also be indicated by a flag. As an example here
is the request from the ``FixPeriNeigh`` class which is created is the request from the ``FixPeriNeigh`` class which is created
internally by :doc:`Peridynamics pair styles <pair_peri>`: internally by :doc:`Peridynamics pair styles <pair_peri>`:
.. code-block:: C++ .. code-block:: c++
neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL);
@ -198,7 +198,7 @@ than what is usually inferred from the pair style settings (largest cutoff of
all pair styles plus neighbor list skin). The following is used in the all pair styles plus neighbor list skin). The following is used in the
:doc:`compute rdf <compute_rdf>` command implementation: :doc:`compute rdf <compute_rdf>` command implementation:
.. code-block:: C++ .. code-block:: c++
if (cutflag) if (cutflag)
neighbor->add_request(this, NeighConst::REQ_OCCASIONAL)->set_cutoff(mycutneigh); neighbor->add_request(this, NeighConst::REQ_OCCASIONAL)->set_cutoff(mycutneigh);
@ -212,7 +212,7 @@ for printing the neighbor list summary the name of the requesting command
should be set. Below is the request from the :doc:`delete atoms <delete_atoms>` should be set. Below is the request from the :doc:`delete atoms <delete_atoms>`
command: command:
.. code-block:: C++ .. code-block:: c++
neighbor->add_request(this, "delete_atoms", NeighConst::REQ_FULL); neighbor->add_request(this, "delete_atoms", NeighConst::REQ_FULL);

View File

@ -95,7 +95,7 @@ a class ``PairMorse2`` in the files ``pair_morse2.h`` and
``pair_morse2.cpp`` with the factory function and initialization ``pair_morse2.cpp`` with the factory function and initialization
function would look like this: function would look like this:
.. code-block:: C++ .. code-block:: c++
#include "lammpsplugin.h" #include "lammpsplugin.h"
#include "version.h" #include "version.h"
@ -141,7 +141,7 @@ list of argument strings), then the pointer type is ``lammpsplugin_factory2``
and it must be assigned to the *creator.v2* member of the plugin struct. and it must be assigned to the *creator.v2* member of the plugin struct.
Below is an example for that: Below is an example for that:
.. code-block:: C++ .. code-block:: c++
#include "lammpsplugin.h" #include "lammpsplugin.h"
#include "version.h" #include "version.h"
@ -176,7 +176,7 @@ demonstrated in the following example, which also shows that the
implementation of the plugin class may be within the same source implementation of the plugin class may be within the same source
file as the plugin interface code: file as the plugin interface code:
.. code-block:: C++ .. code-block:: c++
#include "lammpsplugin.h" #include "lammpsplugin.h"

View File

@ -194,7 +194,7 @@ macro. These tests operate by capturing the screen output when executing
the failing command and then comparing that with a provided regular the failing command and then comparing that with a provided regular
expression string pattern. Example: expression string pattern. Example:
.. code-block:: C++ .. code-block:: c++
TEST_F(SimpleCommandsTest, UnknownCommand) TEST_F(SimpleCommandsTest, UnknownCommand)
{ {
@ -249,7 +249,7 @@ MPI support. These include tests where LAMMPS is run in multi-partition
mode or only on a subset of the MPI world communicator. The CMake mode or only on a subset of the MPI world communicator. The CMake
script code for adding this kind of test looks like this: script code for adding this kind of test looks like this:
.. code-block:: CMake .. code-block:: cmake
if (BUILD_MPI) if (BUILD_MPI)
add_executable(test_library_mpi test_library_mpi.cpp) add_executable(test_library_mpi test_library_mpi.cpp)

View File

@ -61,7 +61,7 @@ header file needs to be updated accordingly.
Old: Old:
.. code-block:: C++ .. code-block:: c++
int PairEAM::pack_comm(int n, int *list, double *buf, int pbc_flag, int *pbc) int PairEAM::pack_comm(int n, int *list, double *buf, int pbc_flag, int *pbc)
{ {
@ -75,7 +75,7 @@ Old:
New: New:
.. code-block:: C++ .. code-block:: c++
int PairEAM::pack_forward_comm(int n, int *list, double *buf, int pbc_flag, int *pbc) int PairEAM::pack_forward_comm(int n, int *list, double *buf, int pbc_flag, int *pbc)
{ {
@ -112,14 +112,14 @@ Example from a pair style:
Old: Old:
.. code-block:: C++ .. code-block:: c++
if (eflag || vflag) ev_setup(eflag, vflag); if (eflag || vflag) ev_setup(eflag, vflag);
else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; else evflag = vflag_fdotr = eflag_global = eflag_atom = 0;
New: New:
.. code-block:: C++ .. code-block:: c++
ev_init(eflag, vflag); ev_init(eflag, vflag);
@ -142,14 +142,14 @@ when they are called from only one or a subset of the MPI processes.
Old: Old:
.. code-block:: C++ .. code-block:: c++
val = force->numeric(FLERR, arg[1]); val = force->numeric(FLERR, arg[1]);
num = force->inumeric(FLERR, arg[2]); num = force->inumeric(FLERR, arg[2]);
New: New:
.. code-block:: C++ .. code-block:: c++
val = utils::numeric(FLERR, true, arg[1], lmp); val = utils::numeric(FLERR, true, arg[1], lmp);
num = utils::inumeric(FLERR, false, arg[2], lmp); num = utils::inumeric(FLERR, false, arg[2], lmp);
@ -183,14 +183,14 @@ copy them around for simulations.
Old: Old:
.. code-block:: C++ .. code-block:: c++
fp = force->open_potential(filename); fp = force->open_potential(filename);
fp = fopen(filename, "r"); fp = fopen(filename, "r");
New: New:
.. code-block:: C++ .. code-block:: c++
fp = utils::open_potential(filename, lmp); fp = utils::open_potential(filename, lmp);
@ -207,7 +207,7 @@ Example:
Old: Old:
.. code-block:: C++ .. code-block:: c++
if (fptr == NULL) { if (fptr == NULL) {
char str[128]; char str[128];
@ -217,7 +217,7 @@ Old:
New: New:
.. code-block:: C++ .. code-block:: c++
if (fptr == nullptr) if (fptr == nullptr)
error->one(FLERR, "Cannot open AEAM potential file {}: {}", filename, utils::getsyserror()); error->one(FLERR, "Cannot open AEAM potential file {}: {}", filename, utils::getsyserror());
@ -237,7 +237,7 @@ an example from the ``FixWallReflect`` class:
Old: Old:
.. code-block:: C++ .. code-block:: c++
FixWallReflect(class LAMMPS *, int, char **); FixWallReflect(class LAMMPS *, int, char **);
virtual ~FixWallReflect(); virtual ~FixWallReflect();
@ -247,7 +247,7 @@ Old:
New: New:
.. code-block:: C++ .. code-block:: c++
FixWallReflect(class LAMMPS *, int, char **); FixWallReflect(class LAMMPS *, int, char **);
~FixWallReflect() override; ~FixWallReflect() override;
@ -271,7 +271,7 @@ the type of the "this" pointer argument.
Old: Old:
.. code-block:: C++ .. code-block:: c++
comm->forward_comm_pair(this); comm->forward_comm_pair(this);
comm->forward_comm_fix(this); comm->forward_comm_fix(this);
@ -284,7 +284,7 @@ Old:
New: New:
.. code-block:: C++ .. code-block:: c++
comm->forward_comm(this); comm->forward_comm(this);
comm->reverse_comm(this); comm->reverse_comm(this);
@ -304,7 +304,7 @@ requests can be :doc:`found here <Developer_notes>`. Example from the
Old: Old:
.. code-block:: C++ .. code-block:: c++
int irequest = neighbor->request(this,instance_me); int irequest = neighbor->request(this,instance_me);
neighbor->requests[irequest]->pair = 0; neighbor->requests[irequest]->pair = 0;
@ -317,7 +317,7 @@ Old:
New: New:
.. code-block:: C++ .. code-block:: c++
auto req = neighbor->add_request(this, NeighConst::REQ_OCCASIONAL); auto req = neighbor->add_request(this, NeighConst::REQ_OCCASIONAL);
if (cutflag) req->set_cutoff(mycutneigh); if (cutflag) req->set_cutoff(mycutneigh);
@ -340,7 +340,7 @@ these are internal fixes, there is no user visible change.
Old: Old:
.. code-block:: C++ .. code-block:: c++
#include "fix_store.h" #include "fix_store.h"
@ -351,7 +351,7 @@ Old:
New: New:
.. code-block:: C++ .. code-block:: c++
#include "fix_store_peratom.h" #include "fix_store_peratom.h"
@ -362,7 +362,7 @@ New:
Old: Old:
.. code-block:: C++ .. code-block:: c++
#include "fix_store.h" #include "fix_store.h"
@ -373,7 +373,7 @@ Old:
New: New:
.. code-block:: C++ .. code-block:: c++
#include "fix_store_global.h" #include "fix_store_global.h"
@ -396,7 +396,7 @@ the dump directly. Example:
Old: Old:
.. code-block:: C++ .. code-block:: c++
int idump = output->find_dump(arg[iarg+1]); int idump = output->find_dump(arg[iarg+1]);
if (idump < 0) if (idump < 0)
@ -412,7 +412,7 @@ Old:
New: New:
.. code-block:: C++ .. code-block:: c++
auto idump = output->get_dump_by_id(arg[iarg+1]); auto idump = output->get_dump_by_id(arg[iarg+1]);
if (!idump) error->all(FLERR,"Dump ID {} in hyper command does not exist", arg[iarg+1]); if (!idump) error->all(FLERR,"Dump ID {} in hyper command does not exist", arg[iarg+1]);

View File

@ -317,7 +317,7 @@ are all "whitespace" characters, i.e. the space character, the tabulator
character, the carriage return character, the linefeed character, and character, the carriage return character, the linefeed character, and
the form feed character. the form feed character.
.. code-block:: C++ .. code-block:: c++
:caption: Tokenizer class example listing entries of the PATH environment variable :caption: Tokenizer class example listing entries of the PATH environment variable
#include "tokenizer.h" #include "tokenizer.h"
@ -349,7 +349,7 @@ tokenizer into a ``try`` / ``catch`` block to handle errors. The
when a (type of) number is requested as next token that is not when a (type of) number is requested as next token that is not
compatible with the string representing the next word. compatible with the string representing the next word.
.. code-block:: C++ .. code-block:: c++
:caption: ValueTokenizer class example with exception handling :caption: ValueTokenizer class example with exception handling
#include "tokenizer.h" #include "tokenizer.h"
@ -427,7 +427,7 @@ one or two array indices "[<number>]" with numbers > 0.
A typical code segment would look like this: A typical code segment would look like this:
.. code-block:: C++ .. code-block:: c++
:caption: Usage example for ArgInfo class :caption: Usage example for ArgInfo class
int nvalues = 0; int nvalues = 0;
@ -476,7 +476,7 @@ open the file, and will call the :cpp:class:`LAMMPS_NS::Error` class in
case of failures to read or to convert numbers, so that LAMMPS will be case of failures to read or to convert numbers, so that LAMMPS will be
aborted. aborted.
.. code-block:: C++ .. code-block:: c++
:caption: Use of PotentialFileReader class in pair style coul/streitz :caption: Use of PotentialFileReader class in pair style coul/streitz
PotentialFileReader reader(lmp, file, "coul/streitz"); PotentialFileReader reader(lmp, file, "coul/streitz");
@ -555,7 +555,7 @@ chunk size needs to be known in advance, 2) with :cpp:func:`MyPage::vget()
its size is registered later with :cpp:func:`MyPage::vgot() its size is registered later with :cpp:func:`MyPage::vgot()
<LAMMPS_NS::MyPage::vgot>`. <LAMMPS_NS::MyPage::vgot>`.
.. code-block:: C++ .. code-block:: c++
:caption: Example of using :cpp:class:`MyPage <LAMMPS_NS::MyPage>` :caption: Example of using :cpp:class:`MyPage <LAMMPS_NS::MyPage>`
#include "my_page.h" #include "my_page.h"

View File

@ -26,7 +26,7 @@ constructor with the signature: ``FixPrintVel(class LAMMPS *, int, char **)``.
Every fix must be registered in LAMMPS by writing the following lines Every fix must be registered in LAMMPS by writing the following lines
of code in the header before include guards: of code in the header before include guards:
.. code-block:: c .. code-block:: c++
#ifdef FIX_CLASS #ifdef FIX_CLASS
// clang-format off // clang-format off
@ -47,7 +47,7 @@ keyword when it parses the input script.
Let's write a simple fix which will print the average velocity at the end Let's write a simple fix which will print the average velocity at the end
of each timestep. First of all, implement a constructor: of each timestep. First of all, implement a constructor:
.. code-block:: C++ .. code-block:: c++
FixPrintVel::FixPrintVel(LAMMPS *lmp, int narg, char **arg) FixPrintVel::FixPrintVel(LAMMPS *lmp, int narg, char **arg)
: Fix(lmp, narg, arg) : Fix(lmp, narg, arg)
@ -72,7 +72,7 @@ in the Fix class called ``nevery`` which specifies how often the method
The next method we need to implement is ``setmask()``: The next method we need to implement is ``setmask()``:
.. code-block:: C++ .. code-block:: c++
int FixPrintVel::setmask() int FixPrintVel::setmask()
{ {
@ -87,7 +87,7 @@ during execution. The constant ``END_OF_STEP`` corresponds to the
are called during a timestep and the order in which they are called are called during a timestep and the order in which they are called
are shown in the previous section. are shown in the previous section.
.. code-block:: C++ .. code-block:: c++
void FixPrintVel::end_of_step() void FixPrintVel::end_of_step()
{ {
@ -143,7 +143,7 @@ The group membership information of an atom is contained in the *mask*
property of and atom and the bit corresponding to a given group is property of and atom and the bit corresponding to a given group is
stored in the groupbit variable which is defined in Fix base class: stored in the groupbit variable which is defined in Fix base class:
.. code-block:: C++ .. code-block:: c++
for (int i = 0; i < nlocal; ++i) { for (int i = 0; i < nlocal; ++i) {
if (atom->mask[i] & groupbit) { if (atom->mask[i] & groupbit) {
@ -174,7 +174,7 @@ to store positions of atoms from previous timestep, we need to add
``double** xold`` to the header file. Than add allocation code ``double** xold`` to the header file. Than add allocation code
to the constructor: to the constructor:
.. code-block:: C++ .. code-block:: c++
FixSavePos::FixSavePos(LAMMPS *lmp, int narg, char **arg), xold(nullptr) FixSavePos::FixSavePos(LAMMPS *lmp, int narg, char **arg), xold(nullptr)
{ {
@ -190,7 +190,7 @@ to the constructor:
Implement the aforementioned methods: Implement the aforementioned methods:
.. code-block:: C++ .. code-block:: c++
double FixSavePos::memory_usage() double FixSavePos::memory_usage()
{ {

View File

@ -152,14 +152,14 @@ Creating a new instance of PyLammps
To create a PyLammps object you need to first import the class from the lammps To create a PyLammps object you need to first import the class from the lammps
module. By using the default constructor, a new *lammps* instance is created. module. By using the default constructor, a new *lammps* instance is created.
.. code-block:: Python .. code-block:: python
from lammps import PyLammps from lammps import PyLammps
L = PyLammps() L = PyLammps()
You can also initialize PyLammps on top of this existing *lammps* object: You can also initialize PyLammps on top of this existing *lammps* object:
.. code-block:: Python .. code-block:: python
from lammps import lammps, PyLammps from lammps import lammps, PyLammps
lmp = lammps() lmp = lammps()
@ -180,14 +180,14 @@ For instance, let's take the following LAMMPS command:
In the original interface this command can be executed with the following In the original interface this command can be executed with the following
Python code if *L* was a lammps instance: Python code if *L* was a lammps instance:
.. code-block:: Python .. code-block:: python
L.command("region box block 0 10 0 5 -0.5 0.5") L.command("region box block 0 10 0 5 -0.5 0.5")
With the PyLammps interface, any command can be split up into arbitrary parts With the PyLammps interface, any command can be split up into arbitrary parts
separated by white-space, passed as individual arguments to a region method. separated by white-space, passed as individual arguments to a region method.
.. code-block:: Python .. code-block:: python
L.region("box block", 0, 10, 0, 5, -0.5, 0.5) L.region("box block", 0, 10, 0, 5, -0.5, 0.5)
@ -199,14 +199,14 @@ The benefit of this approach is avoiding redundant command calls and easier
parameterization. In the original interface parameterization needed to be done parameterization. In the original interface parameterization needed to be done
manually by creating formatted strings. manually by creating formatted strings.
.. code-block:: Python .. code-block:: python
L.command("region box block %f %f %f %f %f %f" % (xlo, xhi, ylo, yhi, zlo, zhi)) L.command("region box block %f %f %f %f %f %f" % (xlo, xhi, ylo, yhi, zlo, zhi))
In contrast, methods of PyLammps accept parameters directly and will convert In contrast, methods of PyLammps accept parameters directly and will convert
them automatically to a final command string. them automatically to a final command string.
.. code-block:: Python .. code-block:: python
L.region("box block", xlo, xhi, ylo, yhi, zlo, zhi) L.region("box block", xlo, xhi, ylo, yhi, zlo, zhi)
@ -256,7 +256,7 @@ LAMMPS variables can be both defined and accessed via the PyLammps interface.
To define a variable you can use the :doc:`variable <variable>` command: To define a variable you can use the :doc:`variable <variable>` command:
.. code-block:: Python .. code-block:: python
L.variable("a index 2") L.variable("a index 2")
@ -265,14 +265,14 @@ A dictionary of all variables is returned by L.variables
you can access an individual variable by retrieving a variable object from the you can access an individual variable by retrieving a variable object from the
L.variables dictionary by name L.variables dictionary by name
.. code-block:: Python .. code-block:: python
a = L.variables['a'] a = L.variables['a']
The variable value can then be easily read and written by accessing the value The variable value can then be easily read and written by accessing the value
property of this object. property of this object.
.. code-block:: Python .. code-block:: python
print(a.value) print(a.value)
a.value = 4 a.value = 4
@ -284,7 +284,7 @@ LAMMPS expressions can be immediately evaluated by using the eval method. The
passed string parameter can be any expression containing global thermo values, passed string parameter can be any expression containing global thermo values,
variables, compute or fix data. variables, compute or fix data.
.. code-block:: Python .. code-block:: python
result = L.eval("ke") # kinetic energy result = L.eval("ke") # kinetic energy
result = L.eval("pe") # potential energy result = L.eval("pe") # potential energy
@ -298,7 +298,7 @@ All atoms in the current simulation can be accessed by using the L.atoms list.
Each element of this list is an object which exposes its properties (id, type, Each element of this list is an object which exposes its properties (id, type,
position, velocity, force, etc.). position, velocity, force, etc.).
.. code-block:: Python .. code-block:: python
# access first atom # access first atom
L.atoms[0].id L.atoms[0].id
@ -311,7 +311,7 @@ position, velocity, force, etc.).
Some properties can also be used to set: Some properties can also be used to set:
.. code-block:: Python .. code-block:: python
# set position in 2D simulation # set position in 2D simulation
L.atoms[0].position = (1.0, 0.0) L.atoms[0].position = (1.0, 0.0)
@ -328,7 +328,7 @@ after a run via the L.runs list. This list contains a growing list of run data.
The first element is the output of the first run, the second element that of The first element is the output of the first run, the second element that of
the second run. the second run.
.. code-block:: Python .. code-block:: python
L.run(1000) L.run(1000)
L.runs[0] # data of first 1000 time steps L.runs[0] # data of first 1000 time steps
@ -339,14 +339,14 @@ the second run.
Each run contains a dictionary of all trajectories. Each trajectory is Each run contains a dictionary of all trajectories. Each trajectory is
accessible through its thermo name: accessible through its thermo name:
.. code-block:: Python .. code-block:: python
L.runs[0].thermo.Step # list of time steps in first run L.runs[0].thermo.Step # list of time steps in first run
L.runs[0].thermo.Ke # list of kinetic energy values in first run L.runs[0].thermo.Ke # list of kinetic energy values in first run
Together with matplotlib plotting data out of LAMMPS becomes simple: Together with matplotlib plotting data out of LAMMPS becomes simple:
.. code-block:: Python .. code-block:: python
import matplotlib.plot as plt import matplotlib.plot as plt
steps = L.runs[0].thermo.Step steps = L.runs[0].thermo.Step
@ -406,7 +406,7 @@ Four atoms are placed in the simulation and the dihedral potential is applied on
them using a datafile. Then one of the atoms is rotated along the central axis by them using a datafile. Then one of the atoms is rotated along the central axis by
setting its position from Python, which changes the dihedral angle. setting its position from Python, which changes the dihedral angle.
.. code-block:: Python .. code-block:: python
phi = [d \* math.pi / 180 for d in range(360)] phi = [d \* math.pi / 180 for d in range(360)]
@ -439,7 +439,7 @@ Initially, a 2D system is created in a state with minimal energy.
It is then disordered by moving each atom by a random delta. It is then disordered by moving each atom by a random delta.
.. code-block:: Python .. code-block:: python
random.seed(27848) random.seed(27848)
deltaperturb = 0.2 deltaperturb = 0.2
@ -458,7 +458,7 @@ It is then disordered by moving each atom by a random delta.
Finally, the Monte Carlo algorithm is implemented in Python. It continuously Finally, the Monte Carlo algorithm is implemented in Python. It continuously
moves random atoms by a random delta and only accepts certain moves. moves random atoms by a random delta and only accepts certain moves.
.. code-block:: Python .. code-block:: python
estart = L.eval("pe") estart = L.eval("pe")
elast = estart elast = estart
@ -517,7 +517,7 @@ PyLammps can be run in parallel using mpi4py. This python package can be install
The following is a short example which reads in an existing LAMMPS input file and The following is a short example which reads in an existing LAMMPS input file and
executes it in parallel. You can find in.melt in the examples/melt folder. executes it in parallel. You can find in.melt in the examples/melt folder.
.. code-block:: Python .. code-block:: python
from mpi4py import MPI from mpi4py import MPI
from lammps import PyLammps from lammps import PyLammps

View File

@ -43,7 +43,7 @@ JSON
"ke": $(ke) "ke": $(ke)
}""" file current_state.json screen no }""" file current_state.json screen no
.. code-block:: JSON .. code-block:: json
:caption: current_state.json :caption: current_state.json
{ {

View File

@ -39,7 +39,7 @@ crashes within LAMMPS may be recovered from by enabling
:ref:`exceptions <exceptions>`, avoiding them proactively is a safer :ref:`exceptions <exceptions>`, avoiding them proactively is a safer
approach. approach.
.. code-block:: C .. code-block:: c
:caption: Example for using configuration settings functions :caption: Example for using configuration settings functions
#include "library.h" #include "library.h"

View File

@ -22,7 +22,7 @@ as the "handle" argument in subsequent function calls until that
instance is destroyed by calling :cpp:func:`lammps_close`. Here is a instance is destroyed by calling :cpp:func:`lammps_close`. Here is a
simple example demonstrating its use: simple example demonstrating its use:
.. code-block:: C .. code-block:: c
#include "library.h" #include "library.h"
#include <stdio.h> #include <stdio.h>

View File

@ -30,7 +30,7 @@ be included in the file or strings, and expansion of variables with
``${name}`` or ``$(expression)`` syntax is performed. ``${name}`` or ``$(expression)`` syntax is performed.
Below is a short example using some of these functions. Below is a short example using some of these functions.
.. code-block:: C .. code-block:: c
/* define to make the otherwise hidden prototype for "lammps_open()" visible */ /* define to make the otherwise hidden prototype for "lammps_open()" visible */
#define LAMMPS_LIB_MPI #define LAMMPS_LIB_MPI

View File

@ -32,7 +32,7 @@ indexed accordingly. Per-atom data can change sizes and ordering at
every neighbor list rebuild or atom sort event as atoms migrate between every neighbor list rebuild or atom sort event as atoms migrate between
sub-domains and processors. sub-domains and processors.
.. code-block:: C .. code-block:: c
#include "library.h" #include "library.h"
#include <stdio.h> #include <stdio.h>

View File

@ -58,7 +58,7 @@ against invalid accesses.
Each element of this list is a :py:class:`Atom <lammps.Atom>` or :py:class:`Atom2D <lammps.Atom2D>` object. The attributes of Each element of this list is a :py:class:`Atom <lammps.Atom>` or :py:class:`Atom2D <lammps.Atom2D>` object. The attributes of
these objects provide access to their data (id, type, position, velocity, force, etc.): these objects provide access to their data (id, type, position, velocity, force, etc.):
.. code-block:: Python .. code-block:: python
# access first atom # access first atom
L.atoms[0].id L.atoms[0].id
@ -71,7 +71,7 @@ against invalid accesses.
Some attributes can be changed: Some attributes can be changed:
.. code-block:: Python .. code-block:: python
# set position in 2D simulation # set position in 2D simulation
L.atoms[0].position = (1.0, 0.0) L.atoms[0].position = (1.0, 0.0)

View File

@ -4,7 +4,7 @@ Configuration information
The following methods can be used to query the LAMMPS library The following methods can be used to query the LAMMPS library
about compile time settings and included packages and styles. about compile time settings and included packages and styles.
.. code-block:: Python .. code-block:: python
:caption: Example for using configuration settings functions :caption: Example for using configuration settings functions
from lammps import lammps from lammps import lammps

View File

@ -74,7 +74,7 @@ Here are simple examples using all three Python interfaces:
:py:class:`PyLammps <lammps.PyLammps>` objects can also be created on top of an existing :py:class:`PyLammps <lammps.PyLammps>` objects can also be created on top of an existing
:py:class:`lammps <lammps.lammps>` object: :py:class:`lammps <lammps.lammps>` object:
.. code-block:: Python .. code-block:: python
from lammps import lammps, PyLammps from lammps import lammps, PyLammps
... ...
@ -113,7 +113,7 @@ Here are simple examples using all three Python interfaces:
You can also initialize IPyLammps on top of an existing :py:class:`lammps` or :py:class:`PyLammps` object: You can also initialize IPyLammps on top of an existing :py:class:`lammps` or :py:class:`PyLammps` object:
.. code-block:: Python .. code-block:: python
from lammps import lammps, IPyLammps from lammps import lammps, IPyLammps
... ...
@ -142,7 +142,7 @@ the MPI and/or Kokkos environment if enabled and active.
Note that you can create multiple LAMMPS objects in your Python Note that you can create multiple LAMMPS objects in your Python
script, and coordinate and run multiple simulations, e.g. script, and coordinate and run multiple simulations, e.g.
.. code-block:: Python .. code-block:: python
from lammps import lammps from lammps import lammps
lmp1 = lammps() lmp1 = lammps()

View File

@ -7,7 +7,7 @@ current Python process with an error message. C++ exceptions allow capturing
them on the C++ side and rethrowing them on the Python side. This way them on the C++ side and rethrowing them on the Python side. This way
LAMMPS errors can be handled through the Python exception handling mechanism. LAMMPS errors can be handled through the Python exception handling mechanism.
.. code-block:: Python .. code-block:: python
from lammps import lammps, MPIAbortException from lammps import lammps, MPIAbortException

View File

@ -60,7 +60,7 @@ it is possible to "compute" what the next LAMMPS command should be.
can be executed using with the lammps API with the following Python code if ``lmp`` is an can be executed using with the lammps API with the following Python code if ``lmp`` is an
instance of :py:class:`lammps <lammps.lammps>`: instance of :py:class:`lammps <lammps.lammps>`:
.. code-block:: Python .. code-block:: python
from lammps import lammps from lammps import lammps
@ -73,7 +73,7 @@ it is possible to "compute" what the next LAMMPS command should be.
The arguments of the command can be passed as one string, or The arguments of the command can be passed as one string, or
individually. individually.
.. code-block:: Python .. code-block:: python
from lammps import PyLammps from lammps import PyLammps
@ -93,14 +93,14 @@ it is possible to "compute" what the next LAMMPS command should be.
parameterization. In the lammps API parameterization needed to be done parameterization. In the lammps API parameterization needed to be done
manually by creating formatted command strings. manually by creating formatted command strings.
.. code-block:: Python .. code-block:: python
lmp.command("region box block %f %f %f %f %f %f" % (xlo, xhi, ylo, yhi, zlo, zhi)) lmp.command("region box block %f %f %f %f %f %f" % (xlo, xhi, ylo, yhi, zlo, zhi))
In contrast, methods of PyLammps accept parameters directly and will convert In contrast, methods of PyLammps accept parameters directly and will convert
them automatically to a final command string. them automatically to a final command string.
.. code-block:: Python .. code-block:: python
L.region("box block", xlo, xhi, ylo, yhi, zlo, zhi) L.region("box block", xlo, xhi, ylo, yhi, zlo, zhi)

View File

@ -56,7 +56,7 @@ and you should see the same output as if you had typed
Note that without the mpi4py specific lines from ``test.py`` Note that without the mpi4py specific lines from ``test.py``
.. code-block:: Python .. code-block:: python
from lammps import lammps from lammps import lammps
lmp = lammps() lmp = lammps()

View File

@ -76,7 +76,7 @@ computes, fixes, or variables in LAMMPS using the :py:mod:`lammps` module.
To define a variable you can use the :doc:`variable <variable>` command: To define a variable you can use the :doc:`variable <variable>` command:
.. code-block:: Python .. code-block:: python
L.variable("a index 2") L.variable("a index 2")
@ -85,14 +85,14 @@ computes, fixes, or variables in LAMMPS using the :py:mod:`lammps` module.
you can access an individual variable by retrieving a variable object from the you can access an individual variable by retrieving a variable object from the
``L.variables`` dictionary by name ``L.variables`` dictionary by name
.. code-block:: Python .. code-block:: python
a = L.variables['a'] a = L.variables['a']
The variable value can then be easily read and written by accessing the value The variable value can then be easily read and written by accessing the value
property of this object. property of this object.
.. code-block:: Python .. code-block:: python
print(a.value) print(a.value)
a.value = 4 a.value = 4

View File

@ -105,7 +105,7 @@ against invalid accesses.
variables, compute or fix data (see :doc:`Howto_output`): variables, compute or fix data (see :doc:`Howto_output`):
.. code-block:: Python .. code-block:: python
result = L.eval("ke") # kinetic energy result = L.eval("ke") # kinetic energy
result = L.eval("pe") # potential energy result = L.eval("pe") # potential energy

View File

@ -1,7 +1,7 @@
Scatter/gather operations Scatter/gather operations
========================= =========================
.. code-block:: Python .. code-block:: python
data = lmp.gather_atoms(name,type,count) # return per-atom property of all atoms gathered into data, ordered by atom ID data = lmp.gather_atoms(name,type,count) # return per-atom property of all atoms gathered into data, ordered by atom ID
# name = "x", "charge", "type", etc # name = "x", "charge", "type", etc
@ -42,7 +42,7 @@ For the scatter methods, the array of coordinates passed to must be a
ctypes vector of ints or doubles, allocated and initialized something ctypes vector of ints or doubles, allocated and initialized something
like this: like this:
.. code-block:: Python .. code-block:: python
from ctypes import c_double from ctypes import c_double
natoms = lmp.get_natoms() natoms = lmp.get_natoms()

View File

@ -1,25 +1,33 @@
from pygments.lexer import RegexLexer, words, include, default from pygments.lexer import RegexLexer, words, include, default
from pygments.token import * from pygments.token import *
LAMMPS_COMMANDS = ("angle_coeff", "angle_style", "atom_modify", "atom_style", LAMMPS_COMMANDS = ("angle_coeff", "angle_style", "atom_modify",
"balance", "bond_coeff", "bond_style", "bond_write", "boundary", "box", "atom_style", "balance", "bond_coeff", "bond_style",
"clear", "comm_modify", "comm_style", "bond_write", "boundary", "clear", "comm_modify",
"compute_modify", "create_atoms", "create_bonds", "create_box", "delete_atoms", "comm_style", "compute_modify", "create_atoms",
"delete_bonds", "dielectric", "dihedral_coeff", "dihedral_style", "dimension", "create_bonds", "create_box", "delete_atoms",
"displace_atoms", "dump_modify", "dynamical_matrix", "echo", "elif", "else", "delete_bonds", "dielectric", "dihedral_coeff",
"fix_modify", "group2ndx", "hyper", "if", "improper_coeff", "dihedral_style", "dimension", "displace_atoms",
"improper_style", "include", "info", "jump", "kim", "dump_modify", "dynamical_matrix", "echo", "elif",
"kspace_modify", "kspace_style", "label", "labelmap", "lattice", "log", "else", "fix_modify", "group2ndx", "hyper", "if",
"mass", "mdi", "message", "minimize", "min_modify", "min_style", "molecule", "improper_coeff", "improper_style", "include",
"ndx2group", "neb", "neb/spin", "neighbor", "neigh_modify", "newton", "next", "info", "jump", "kim", "kspace_modify",
"package", "pair_coeff", "pair_modify", "pair_style", "pair_write", "kspace_style", "label", "labelmap", "lattice",
"partition", "prd", "print", "processors", "python", "quit", "read_data", "log", "mass", "mdi", "message", "minimize",
"read_dump", "read_restart", "replicate", "rerun", "reset_ids", "min_modify", "min_style", "molecule", "ndx2group",
"reset_timestep", "restart", "run", "run_style", "server", "set", "shell", "neb", "neb/spin", "neighbor", "neigh_modify",
"special_bonds", "suffix", "tad", "temper", "temper/grem", "temper/npt", "then", "newton", "next", "package", "pair_coeff",
"thermo", "thermo_modify", "thermo_style", "third_order", "timer", "timestep", "pair_modify", "pair_style", "pair_write",
"units", "velocity", "write_coeff", "partition", "plugin", "prd", "print", "processors",
"write_data", "write_restart") "python", "quit", "read_data", "read_dump",
"read_restart", "replicate", "rerun", "reset_atoms",
"reset_timestep", "restart", "run", "run_style",
"server", "set", "shell", "special_bonds", "suffix",
"tad", "temper", "temper/grem", "temper/npt", "then",
"thermo", "thermo_modify", "thermo_style",
"third_order", "timer", "timestep", "units",
"velocity", "write_coeff", "write_data",
"write_restart")
#fix ID group-ID style args #fix ID group-ID style args
#compute ID group-ID style args #compute ID group-ID style args

4
src/.gitignore vendored
View File

@ -59,8 +59,8 @@
/pair_pod.cpp /pair_pod.cpp
/pair_pod.h /pair_pod.h
/fitpod.cpp /fitpod_command.cpp
/fitpod.h /fitpod_command.h
/mlpod.cpp /mlpod.cpp
/mlpod.h /mlpod.h

View File

@ -69,7 +69,7 @@ adios_SYSLIB=${ADIOS2_LIB}
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*ADIOS.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*ADIOS.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ../ADIOS/Makefile.lammps include ../ADIOS/Makefile.lammps
@ -85,7 +85,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*ADIOS.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*ADIOS.*$/d' ../Makefile.package.settings
fi fi
rm -f Makefile.lammps rm -f Makefile.lammps

View File

@ -60,7 +60,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*atc.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*atc.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/atc\/Makefile.lammps include ..\/..\/lib\/atc\/Makefile.lammps
@ -74,7 +74,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*atc.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*atc.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -46,7 +46,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*awpmd.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*awpmd.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/awpmd\/Makefile.lammps include ..\/..\/lib\/awpmd\/Makefile.lammps
@ -60,7 +60,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*awpmd.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*awpmd.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -47,7 +47,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*colvars.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*colvars.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/colvars\/Makefile.lammps include ..\/..\/lib\/colvars\/Makefile.lammps
@ -62,7 +62,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*colvars.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*colvars.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -44,7 +44,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*compress.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*compress.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/compress\/Makefile.lammps include ..\/..\/lib\/compress\/Makefile.lammps
@ -58,7 +58,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*compress.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*compress.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -49,11 +49,11 @@ if (test $1 = 1) then
sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(electrode_SYSLIB) |' ../Makefile.package sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(electrode_SYSLIB) |' ../Makefile.package
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*electrode.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*electrode.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/electrode\/Makefile.lammps include ..\/..\/lib\/electrode\/Makefile.lammps
' ../Makefile.package.settings ' ../Makefile.package.settings
fi fi
elif (test $1 = 0) then elif (test $1 = 0) then
@ -61,7 +61,7 @@ elif (test $1 = 0) then
sed -i -e 's/[^ \t]*electrode[^ \t]* //g' ../Makefile.package sed -i -e 's/[^ \t]*electrode[^ \t]* //g' ../Makefile.package
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*electrode.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*electrode.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -678,7 +678,7 @@ void PPPMElectrode::compute_matrix(bigint *imat, double **matrix, bool timer_fla
// fft green's function k -> r (double) // fft green's function k -> r (double)
double *greens_real; double *greens_real;
memory->create(greens_real, nz_pppm * ny_pppm * nx_pppm, "pppm/electrode:greens_real"); memory->create(greens_real, nz_pppm * ny_pppm * nx_pppm, "pppm/electrode:greens_real");
memset(greens_real, 0, nz_pppm * ny_pppm * nx_pppm * sizeof(double)); memset(greens_real, 0, (std::size_t)nz_pppm * (std::size_t)ny_pppm * (std::size_t)nx_pppm * sizeof(double));
for (int i = 0, n = 0; i < nfft; i++) { for (int i = 0, n = 0; i < nfft; i++) {
work2[n++] = greensfn[i]; work2[n++] = greensfn[i];
work2[n++] = ZEROF; work2[n++] = ZEROF;
@ -871,7 +871,7 @@ void PPPMElectrode::two_step_multiplication(bigint *imat, double *greens_real, d
double **gw; double **gw;
memory->create(gw, nmat, nxyz, "pppm/electrode:gw"); memory->create(gw, nmat, nxyz, "pppm/electrode:gw");
memset(&(gw[0][0]), 0, nmat * nxyz * sizeof(double)); memset(&(gw[0][0]), 0, (std::size_t)nmat * (std::size_t)nxyz * sizeof(double));
auto fmod = [](int x, int n) { // fast unsigned mod auto fmod = [](int x, int n) { // fast unsigned mod
int r = abs(x); int r = abs(x);

View File

@ -176,7 +176,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*gpu.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*gpu.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/gpu\/Makefile.lammps include ..\/..\/lib\/gpu\/Makefile.lammps
@ -191,7 +191,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*gpu.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*gpu.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -45,7 +45,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*h5md.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*h5md.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/h5md\/Makefile.lammps include ..\/..\/lib\/h5md\/Makefile.lammps
@ -60,7 +60,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*h5md.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*h5md.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -44,7 +44,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*kim.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*kim.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/kim\/Makefile.lammps include ..\/..\/lib\/kim\/Makefile.lammps
@ -58,7 +58,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*kim.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*kim.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -374,7 +374,7 @@ if (test $1 = 1) then
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/CXX\ =\ \$(CC)/d' ../Makefile.package.settings sed -i -e '/CXX\ =\ \$(CC)/d' ../Makefile.package.settings
sed -i -e '/^include.*kokkos.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*kokkos.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
CXX = $(CC) CXX = $(CC)
@ -401,7 +401,7 @@ elif (test $1 = 0) then
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/CXX\ =\ \$(CC)/d' ../Makefile.package.settings sed -i -e '/CXX\ =\ \$(CC)/d' ../Makefile.package.settings
sed -i -e '/^include.*kokkos.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*kokkos.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -47,7 +47,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*latte.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*latte.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/latte\/Makefile.lammps include ..\/..\/lib\/latte\/Makefile.lammps
@ -61,7 +61,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*latte.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*latte.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -45,7 +45,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*machdyn.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*machdyn.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/machdyn\/Makefile.lammps include ..\/..\/lib\/machdyn\/Makefile.lammps
@ -59,7 +59,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*machdyn.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*machdyn.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -49,7 +49,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*mdi.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*mdi.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/mdi\/Makefile.lammps include ..\/..\/lib\/mdi\/Makefile.lammps
@ -65,7 +65,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*mdi.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*mdi.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -47,7 +47,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*mesont.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*mesont.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/mesont\/Makefile.lammps include ..\/..\/lib\/mesont\/Makefile.lammps
@ -61,7 +61,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*mesont.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*mesont.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -46,7 +46,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*hdnnp.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*hdnnp.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/hdnnp\/Makefile.lammps include ..\/..\/lib\/hdnnp\/Makefile.lammps
@ -60,7 +60,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*hdnnp.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*hdnnp.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -52,7 +52,7 @@ if (test $1 = 1) then
sed -i -e 's|^PKG_INC =[ \t]*|&-DMLIAP_PYTHON |' ../Makefile.package sed -i -e 's|^PKG_INC =[ \t]*|&-DMLIAP_PYTHON |' ../Makefile.package
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*python.*mliap_python.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*python.*mliap_python.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/python\/Makefile.mliap_python include ..\/..\/lib\/python\/Makefile.mliap_python
@ -68,7 +68,7 @@ elif (test $1 = 0) then
fi fi
rm -f ../mliap_model_python_couple.cpp ../mliap_model_python_couple.h \ rm -f ../mliap_model_python_couple.cpp ../mliap_model_python_couple.h \
../mliap_unified_couple.cpp ../mliap_unified_couple.h ../mliap_unified_couple.cpp ../mliap_unified_couple.h
sed -i -e '/^include.*python.*mliap_python.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*python.*mliap_python.*$/d' ../Makefile.package.settings
elif (test $1 = 2) then elif (test $1 = 2) then
if (type cythonize > /dev/null 2>&1 && test -e ../python_impl.cpp) then if (type cythonize > /dev/null 2>&1 && test -e ../python_impl.cpp) then
@ -77,12 +77,12 @@ elif (test $1 = 2) then
fi fi
rm -f ../mliap_model_python_couple.cpp ../mliap_model_python_couple.h \ rm -f ../mliap_model_python_couple.cpp ../mliap_model_python_couple.h \
../mliap_unified_couple.cpp ../mliap_unified_couple.h ../mliap_unified_couple.cpp ../mliap_unified_couple.h
sed -i -e '/^include.*python.*mliap_python.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*python.*mliap_python.*$/d' ../Makefile.package.settings
if (test -e ../Makefile.package) then if (test -e ../Makefile.package) then
sed -i -e 's|^PKG_INC =[ \t]*|&-DMLIAP_PYTHON |' ../Makefile.package sed -i -e 's|^PKG_INC =[ \t]*|&-DMLIAP_PYTHON |' ../Makefile.package
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*python.*mliap_python.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*python.*mliap_python.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/python\/Makefile.mliap_python include ..\/..\/lib\/python\/Makefile.mliap_python

View File

@ -44,7 +44,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*pace.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*pace.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/pace\/Makefile.lammps include ..\/..\/lib\/pace\/Makefile.lammps
@ -58,7 +58,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*pace.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*pace.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -46,6 +46,10 @@ using MathSpecial::powint;
static constexpr double SMALL = 1.0e-10; static constexpr double SMALL = 1.0e-10;
FitPOD::FitPOD(LAMMPS *_lmp) : Command(_lmp), podptr(nullptr)
{
}
void FitPOD::command(int narg, char **arg) void FitPOD::command(int narg, char **arg)
{ {
if (narg < 2) utils::missing_cmd_args(FLERR, "fitpod", error); if (narg < 2) utils::missing_cmd_args(FLERR, "fitpod", error);
@ -241,7 +245,7 @@ void FitPOD::get_exyz_files(std::vector<std::string>& files, const std::string &
{ {
auto allfiles = platform::list_directory(datapath); auto allfiles = platform::list_directory(datapath);
std::sort(allfiles.begin(), allfiles.end()); std::sort(allfiles.begin(), allfiles.end());
for (auto fname : allfiles) { for (const auto &fname : allfiles) {
if (utils::strmatch(fname, fmt::format(".*\\.{}$", extension))) if (utils::strmatch(fname, fmt::format(".*\\.{}$", extension)))
files.push_back(datapath + platform::filepathsep + fname); files.push_back(datapath + platform::filepathsep + fname);
} }
@ -252,7 +256,6 @@ int FitPOD::get_number_atom_exyz(std::vector<int>& num_atom, int& num_atom_sum,
std::string filename = file; std::string filename = file;
FILE *fp; FILE *fp;
if (comm->me == 0) { if (comm->me == 0) {
fp = utils::open_potential(filename,lmp,nullptr); fp = utils::open_potential(filename,lmp,nullptr);
if (fp == nullptr) if (fp == nullptr)
error->one(FLERR,"Cannot open POD coefficient file {}: ", filename, utils::getsyserror()); error->one(FLERR,"Cannot open POD coefficient file {}: ", filename, utils::getsyserror());
@ -469,7 +472,7 @@ void FitPOD::get_data(datastruct &data, std::vector<std::string> species)
utils::logmesg(lmp, "{}\n {:^{}} | number of configurations | number of atoms\n{}\n", utils::logmesg(lmp, "{}\n {:^{}} | number of configurations | number of atoms\n{}\n",
sepline, "data file", maxname, sepline); sepline, "data file", maxname, sepline);
int i = 0; int i = 0;
for (auto fname : data.data_files) { for (const auto &fname : data.data_files) {
std::string filename = fname.substr(data.data_path.size()+1); std::string filename = fname.substr(data.data_path.size()+1);
data.filenames.push_back(filename); data.filenames.push_back(filename);
if (comm->me == 0) if (comm->me == 0)
@ -695,7 +698,7 @@ void FitPOD::select_data(datastruct &newdata, datastruct data)
data.copydatainfo(newdata); data.copydatainfo(newdata);
size_t maxname = 9; size_t maxname = 9;
for (auto fname : data.data_files) maxname = MAX(maxname,fname.size()); for (const auto &fname : data.data_files) maxname = MAX(maxname,fname.size());
maxname -= data.data_path.size()+1; maxname -= data.data_path.size()+1;
if (comm->me == 0) if (comm->me == 0)
@ -872,7 +875,7 @@ int FitPOD::podfullneighborlist(double *y, int *alist, int *neighlist, int *numn
return nn; return nn;
} }
void FitPOD::allocate_memory(datastruct data) void FitPOD::allocate_memory(const datastruct &data)
{ {
int nd = podptr->pod.nd; int nd = podptr->pod.nd;
memory->create(desc.gd, nd, "fitpod:desc_gd"); memory->create(desc.gd, nd, "fitpod:desc_gd");
@ -989,7 +992,7 @@ void FitPOD::allocate_memory(datastruct data)
} }
} }
void FitPOD::linear_descriptors(datastruct data, int ci) void FitPOD::linear_descriptors(const datastruct &data, int ci)
{ {
int dim = 3; int dim = 3;
int nd1 = podptr->pod.nd1; int nd1 = podptr->pod.nd1;
@ -1020,7 +1023,7 @@ void FitPOD::linear_descriptors(datastruct data, int ci)
} }
void FitPOD::quadratic_descriptors(datastruct data, int ci) void FitPOD::quadratic_descriptors(const datastruct &data, int ci)
{ {
int dim = 3; int dim = 3;
int natom = data.num_atom[ci]; int natom = data.num_atom[ci];
@ -1101,7 +1104,7 @@ void FitPOD::quadratic_descriptors(datastruct data, int ci)
desc.gdd[dim*natom*nd1234+i] = desc.gdd[dim*natom*nd1234+i]/(natom); desc.gdd[dim*natom*nd1234+i] = desc.gdd[dim*natom*nd1234+i]/(natom);
} }
void FitPOD::cubic_descriptors(datastruct data, int ci) void FitPOD::cubic_descriptors(const datastruct &data, int ci)
{ {
int dim = 3; int dim = 3;
int natom = data.num_atom[ci]; int natom = data.num_atom[ci];
@ -1168,7 +1171,7 @@ void FitPOD::cubic_descriptors(datastruct data, int ci)
desc.gdd[i] = desc.gdd[i]/(natom*natom); desc.gdd[i] = desc.gdd[i]/(natom*natom);
} }
void FitPOD::least_squares_matrix(datastruct data, int ci) void FitPOD::least_squares_matrix(const datastruct &data, int ci)
{ {
int dim = 3; int dim = 3;
int natom = data.num_atom[ci]; int natom = data.num_atom[ci];
@ -1214,7 +1217,7 @@ void FitPOD::least_squares_matrix(datastruct data, int ci)
} }
void FitPOD::least_squares_fit(datastruct data) void FitPOD::least_squares_fit(const datastruct &data)
{ {
if (comm->me == 0) if (comm->me == 0)
utils::logmesg(lmp, "**************** Begin of Least-Squares Fitting ****************\n"); utils::logmesg(lmp, "**************** Begin of Least-Squares Fitting ****************\n");
@ -1308,7 +1311,7 @@ void FitPOD::least_squares_fit(datastruct data)
} }
} }
double FitPOD::energyforce_calculation(double *force, double *coeff, datastruct data, int ci) double FitPOD::energyforce_calculation(double *force, double *coeff, const datastruct &data, int ci)
{ {
int dim = 3; int dim = 3;
int *pbc = podptr->pod.pbc; int *pbc = podptr->pod.pbc;
@ -1348,7 +1351,7 @@ double FitPOD::energyforce_calculation(double *force, double *coeff, datastruct
return energy; return energy;
} }
void FitPOD::print_analysis(datastruct data, double *outarray, double *errors) void FitPOD::print_analysis(const datastruct &data, double *outarray, double *errors)
{ {
int nfiles = data.data_files.size(); // number of files int nfiles = data.data_files.size(); // number of files
int lm = 10; int lm = 10;
@ -1422,7 +1425,7 @@ void FitPOD::print_analysis(datastruct data, double *outarray, double *errors)
fclose(fp_analysis); fclose(fp_analysis);
} }
void FitPOD::error_analysis(datastruct data, double *coeff) void FitPOD::error_analysis(const datastruct &data, double *coeff)
{ {
int dim = 3; int dim = 3;
double energy; double energy;
@ -1537,7 +1540,10 @@ void FitPOD::error_analysis(datastruct data, double *coeff)
nforceall += nforce; nforceall += nforce;
ci += 1; ci += 1;
} }
int q = file + 1; int q = file + 1;
if (nconfigs == 0) nconfigs = 1;
if (nforceall == 0) nforceall = 1;
errors[0 + 4*q] = emae/nconfigs; errors[0 + 4*q] = emae/nconfigs;
errors[1 + 4*q] = sqrt(essr/nconfigs); errors[1 + 4*q] = sqrt(essr/nconfigs);
errors[2 + 4*q] = fmae/nforceall; errors[2 + 4*q] = fmae/nforceall;
@ -1550,6 +1556,8 @@ void FitPOD::error_analysis(datastruct data, double *coeff)
errors[3] += fssr; errors[3] += fssr;
} }
if (nc == 0) nc = 1;
if (nf == 0) nf = 1;
errors[0] = errors[0]/nc; errors[0] = errors[0]/nc;
errors[1] = sqrt(errors[1]/nc); errors[1] = sqrt(errors[1]/nc);
errors[2] = errors[2]/nf; errors[2] = errors[2]/nf;
@ -1561,7 +1569,7 @@ void FitPOD::error_analysis(datastruct data, double *coeff)
} }
} }
void FitPOD::energyforce_calculation(datastruct data, double *coeff) void FitPOD::energyforce_calculation(const datastruct &data, double *coeff)
{ {
int dim = 3; int dim = 3;
double energy; double energy;
@ -1816,4 +1824,3 @@ void FitPOD::triclinic_lattice_conversion(double *a, double *b, double *c, doubl
b[0] = bx; b[1] = by; b[2] = 0.0; b[0] = bx; b[1] = by; b[2] = 0.0;
c[0] = cx; c[1] = cy; c[2] = cz; c[0] = cx; c[1] = cy; c[2] = cz;
} }

View File

@ -26,9 +26,11 @@ CommandStyle(fitpod,FitPOD);
namespace LAMMPS_NS { namespace LAMMPS_NS {
class FitPOD : public Command { class FitPOD : public Command {
private:
public: public:
FitPOD(LAMMPS *);
void command(int, char **) override;
private:
struct datastruct { struct datastruct {
std::string file_format = "extxyz"; std::string file_format = "extxyz";
std::string file_extension = "xyz"; std::string file_extension = "xyz";
@ -120,9 +122,6 @@ public:
neighborstruct nb; neighborstruct nb;
class MLPOD *podptr; class MLPOD *podptr;
FitPOD(LAMMPS *lmp) : Command(lmp) {}
// functions for collecting/collating arrays // functions for collecting/collating arrays
void print_matrix(const char *desc, int m, int n, int *a, int lda); void print_matrix(const char *desc, int m, int n, int *a, int lda);
@ -148,7 +147,7 @@ public:
// functions for reading input files and fitting // functions for reading input files and fitting
void command(int, char **) override;
int read_data_file(double *fitting_weights, std::string &file_format, std::string &file_extension, int read_data_file(double *fitting_weights, std::string &file_format, std::string &file_extension,
std::string &test_path, std::string &training_path, std::string &filenametag, const std::string &data_file); std::string &test_path, std::string &training_path, std::string &filenametag, const std::string &data_file);
void get_exyz_files(std::vector<std::string> &, const std::string &, const std::string &); void get_exyz_files(std::vector<std::string> &, const std::string &, const std::string &);
@ -166,16 +165,16 @@ public:
int podneighborlist(int *neighlist, int *numneigh, double *r, double rcutsq, int nx, int N, int dim); int podneighborlist(int *neighlist, int *numneigh, double *r, double rcutsq, int nx, int N, int dim);
int podfullneighborlist(double *y, int *alist, int *neighlist, int *numneigh, int *numneighsum, int podfullneighborlist(double *y, int *alist, int *neighlist, int *numneigh, int *numneighsum,
double *x, double *a1, double *a2, double *a3, double rcut, int *pbc, int nx); double *x, double *a1, double *a2, double *a3, double rcut, int *pbc, int nx);
void allocate_memory(datastruct data); void allocate_memory(const datastruct &data);
void linear_descriptors(datastruct data, int ci); void linear_descriptors(const datastruct &data, int ci);
void quadratic_descriptors(datastruct data, int ci); void quadratic_descriptors(const datastruct &data, int ci);
void cubic_descriptors(datastruct data, int ci); void cubic_descriptors(const datastruct &data, int ci);
void least_squares_matrix(datastruct data, int ci); void least_squares_matrix(const datastruct &data, int ci);
void least_squares_fit(datastruct data); void least_squares_fit(const datastruct &data);
void print_analysis(datastruct data, double *outarray, double *errors); void print_analysis(const datastruct &data, double *outarray, double *errors);
void error_analysis(datastruct data, double *coeff); void error_analysis(const datastruct &data, double *coeff);
double energyforce_calculation(double *force, double *coeff, datastruct data, int ci); double energyforce_calculation(double *force, double *coeff, const datastruct &data, int ci);
void energyforce_calculation(datastruct data, double *coeff); void energyforce_calculation(const datastruct &data, double *coeff);
}; };
} // namespace LAMMPS_NS } // namespace LAMMPS_NS

View File

@ -695,8 +695,9 @@ void MLPOD::read_coeff_file(const std::string &coeff_file)
/*********************************************************************************************************/ /*********************************************************************************************************/
void MLPOD::linear_descriptors(double *gd, double *efatom, double *y, double *tmpmem, int *atomtype, void MLPOD::linear_descriptors(double *gd, double *efatom, double *y, double *tmpmem,
int *alist, int *pairlist, int *pairnum, int *pairnumsum, int *tmpint, int natom, int Nij) int *atomtype, int *alist, int *pairlist, int * /*pairnum*/,
int *pairnumsum, int *tmpint, int natom, int Nij)
{ {
int dim = 3; int dim = 3;
int nelements = pod.nelements; int nelements = pod.nelements;
@ -1644,32 +1645,30 @@ void MLPOD::InitSnap()
rcutmax = MAX(2.0*elemradius[ielem]*rcutfac,rcutmax); rcutmax = MAX(2.0*elemradius[ielem]*rcutfac,rcutmax);
snapSetup(twojmax, ntypes); snapSetup(twojmax, ntypes);
//TemplateCopytoDevice(&sna.radelem[1], elemradius, ntypes, backend);
//TemplateCopytoDevice(&sna.wjelem[1], elemweight, ntypes, backend);
for (int i=0; i<ntypes; i++) { for (int i=0; i<ntypes; i++) {
sna.radelem[1+i] = elemradius[i]; sna.radelem[1+i] = elemradius[i];
sna.wjelem[1+i] = elemweight[i]; sna.wjelem[1+i] = elemweight[i];
} }
podArrayFill(&sna.map[1], (int) 0, ntypes); podArrayFill(&sna.map[1], (int) 0, ntypes);
//double cutsq[100]; for (int i=0; i<ntypes; i++) {
for (int i=0; i<ntypes; i++)
for (int j=0; j<ntypes; j++) { for (int j=0; j<ntypes; j++) {
double cut = (elemradius[i] + elemradius[j])*rcutfac; double cut = (elemradius[i] + elemradius[j])*rcutfac;
sna.rcutsq[j+1 + (i+1)*(ntypes+1)] = cut*cut; sna.rcutsq[j+1 + (i+1)*(ntypes+1)] = cut*cut;
} }
//TemplateCopytoDevice(sna.rcutsq, cutsq, (ntypes+1)*(ntypes+1), backend); }
// bzeroflag is currently always 0
#if 0
if (bzeroflag) { if (bzeroflag) {
double www = wself*wself*wself; double www = wself*wself*wself;
//double bzero[100];
for (int j = 0; j <= twojmax; j++) for (int j = 0; j <= twojmax; j++)
if (bnormflag) if (bnormflag)
sna.bzero[j] = www; sna.bzero[j] = www;
else else
sna.bzero[j] = www*(j+1); sna.bzero[j] = www*(j+1);
//TemplateCopytoDevice(sna.bzero, bzero, twojmax+1, backend);
} }
#endif
int nelements = ntypes; int nelements = ntypes;
if (!chemflag) if (!chemflag)
@ -1902,8 +1901,8 @@ void MLPOD::snapComputeUlist(double *Sr, double *Si, double *dSr, double *dSi, d
}; };
void MLPOD::snapZeroUarraytot2(double *Stotr, double *Stoti, double wself, int *idxu_block, void MLPOD::snapZeroUarraytot2(double *Stotr, double *Stoti, double wself, int *idxu_block,
int *type, int *map, int *ai, int wselfall_flag, int chemflag, int idxu_max, int nelements, int *type, int *map, int * /*ai*/, int wselfall_flag, int chemflag,
int twojmax, int inum) int idxu_max, int nelements, int twojmax, int inum)
{ {
int N1 = inum; int N1 = inum;
int N2 = N1*(twojmax+1); int N2 = N1*(twojmax+1);
@ -2554,8 +2553,9 @@ void MLPOD::pod1body(double *eatom, int *atomtype, int nelements, int natom)
eatom[i + natom*(m-1)] = (atomtype[i] == m) ? 1.0 : 0.0; eatom[i + natom*(m-1)] = (atomtype[i] == m) ? 1.0 : 0.0;
} }
void MLPOD::pod3body(double *eatom, double *yij, double *e2ij, double *tmpmem, int *elemindex, int *pairnumsum, void MLPOD::pod3body(double *eatom, double *yij, double *e2ij, double *tmpmem, int *elemindex,
int *idxi, int *ti, int *tj, int nrbf, int nabf, int nelements, int natom, int Nij) int *pairnumsum, int * /*idxi*/, int *ti, int *tj, int nrbf, int nabf,
int nelements, int natom, int Nij)
{ {
int dim = 3, nabf1 = nabf + 1; int dim = 3, nabf1 = nabf + 1;
int nelements2 = nelements*(nelements+1)/2; int nelements2 = nelements*(nelements+1)/2;
@ -2599,7 +2599,6 @@ void MLPOD::pod3body(double *eatom, double *yij, double *e2ij, double *tmpmem, i
costhe = xdot/(rij*rik); costhe = xdot/(rij*rik);
costhe = costhe > 1.0 ? 1.0 : costhe; costhe = costhe > 1.0 ? 1.0 : costhe;
costhe = costhe < -1.0 ? -1.0 : costhe; costhe = costhe < -1.0 ? -1.0 : costhe;
xdot = costhe*(rij*rik);
theta = acos(costhe); theta = acos(costhe);
for (int p=0; p <nabf1; p++) for (int p=0; p <nabf1; p++)
@ -3070,8 +3069,8 @@ double MLPOD::calculate_energy(double *energycoeff, double *forcecoeff, double *
return energy; return energy;
} }
void MLPOD::pod2body_force(double *force, double *fij, double *coeff2, int *ai, int *aj, void MLPOD::pod2body_force(double *force, double *fij, double *coeff2, int *ai, int *aj, int *ti,
int *ti, int *tj, int *elemindex, int nelements, int nbf, int natom, int N) int *tj, int *elemindex, int nelements, int nbf, int /*natom*/, int N)
{ {
int nelements2 = nelements*(nelements+1)/2; int nelements2 = nelements*(nelements+1)/2;
for (int n=0; n<N; n++) { for (int n=0; n<N; n++) {
@ -3236,7 +3235,7 @@ void MLPOD::pod3body_force(double *force, double *yij, double *e2ij, double *f2i
} }
void MLPOD::snapTallyForce(double *force, double *dbdr, double *coeff4, void MLPOD::snapTallyForce(double *force, double *dbdr, double *coeff4,
int *ai, int *aj, int *ti, int ijnum, int ncoeff, int ntype) int *ai, int *aj, int *ti, int ijnum, int ncoeff, int /*ntype*/)
{ {
int N2 = ijnum*ncoeff; int N2 = ijnum*ncoeff;
for (int idx=0; idx<N2; idx++) { for (int idx=0; idx<N2; idx++) {
@ -3396,8 +3395,8 @@ double MLPOD::energyforce_calculation(double *force, double *podcoeff, double *e
} }
void MLPOD::pod2body_force(double **force, double *fij, double *coeff2, int *ai, int *aj, void MLPOD::pod2body_force(double **force, double *fij, double *coeff2, int *ai, int *aj, int *ti,
int *ti, int *tj, int *elemindex, int nelements, int nbf, int natom, int N) int *tj, int *elemindex, int nelements, int nbf, int /*natom*/, int N)
{ {
int nelements2 = nelements*(nelements+1)/2; int nelements2 = nelements*(nelements+1)/2;
for (int n=0; n<N; n++) { for (int n=0; n<N; n++) {
@ -3559,7 +3558,7 @@ void MLPOD::pod3body_force(double **force, double *yij, double *e2ij, double *f2
} }
void MLPOD::snapTallyForce(double **force, double *dbdr, double *coeff4, void MLPOD::snapTallyForce(double **force, double *dbdr, double *coeff4,
int *ai, int *aj, int *ti, int ijnum, int ncoeff, int ntype) int *ai, int *aj, int *ti, int ijnum, int ncoeff, int /*ntype*/)
{ {
int N2 = ijnum*ncoeff; int N2 = ijnum*ncoeff;
for (int idx=0; idx<N2; idx++) { for (int idx=0; idx<N2; idx++) {

View File

@ -44,7 +44,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*quip.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*quip.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/quip\/Makefile.lammps\ include ..\/..\/lib\/quip\/Makefile.lammps\
@ -58,7 +58,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*quip.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*quip.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -405,6 +405,9 @@ void AngleTable::read_table(Table *tb, char *file, char *keyword)
reader.skip_line(); reader.skip_line();
for (int i = 0; i < tb->ninput; i++) { for (int i = 0; i < tb->ninput; i++) {
line = reader.next_line(); line = reader.next_line();
if (!line)
error->one(FLERR, "Data missing when parsing angle table '{}' line {} of {}.", keyword, i + 1,
tb->ninput);
try { try {
ValueTokenizer values(line); ValueTokenizer values(line);
values.next_int(); values.next_int();

View File

@ -330,6 +330,9 @@ void BondTable::read_table(Table *tb, char *file, char *keyword)
reader.skip_line(); reader.skip_line();
for (int i = 0; i < tb->ninput; i++) { for (int i = 0; i < tb->ninput; i++) {
line = reader.next_line(); line = reader.next_line();
if (!line)
error->one(FLERR, "Data missing when parsing bond table '{}' line {} of {}.", keyword, i + 1,
tb->ninput);
try { try {
ValueTokenizer values(line); ValueTokenizer values(line);
values.next_int(); values.next_int();

View File

@ -1021,6 +1021,9 @@ void DihedralTable::read_table(Table *tb, char *file, char *keyword)
for (int i = 0; i < tb->ninput; i++) { for (int i = 0; i < tb->ninput; i++) {
line = reader.next_line(); line = reader.next_line();
if (!line)
error->one(FLERR, "Data missing when parsing dihedral table '{}' line {} of {}.",
keyword, i + 1, tb->ninput);
try { try {
ValueTokenizer values(line); ValueTokenizer values(line);
if (tb->f_unspecified) { if (tb->f_unspecified) {

View File

@ -44,7 +44,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*molfile.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*molfile.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/molfile\/Makefile.lammps include ..\/..\/lib\/molfile\/Makefile.lammps
@ -58,7 +58,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*molfile.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*molfile.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -43,7 +43,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*mscg.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*mscg.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/mscg\/Makefile.lammps include ..\/..\/lib\/mscg\/Makefile.lammps
@ -57,7 +57,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*mscg.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*mscg.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -42,7 +42,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*netcdf.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*netcdf.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/netcdf\/Makefile.lammps include ..\/..\/lib\/netcdf\/Makefile.lammps
@ -57,7 +57,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*netcdf.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*netcdf.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -44,7 +44,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*plugin.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*plugin.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/plugin\/Makefile.lammps include ..\/..\/lib\/plugin\/Makefile.lammps
@ -58,7 +58,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*plugin.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*plugin.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -45,7 +45,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*plumed.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*plumed.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/plumed\/Makefile.lammps include ..\/..\/lib\/plumed\/Makefile.lammps
@ -59,7 +59,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*plumed.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*plumed.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -44,7 +44,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*poems.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*poems.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/poems\/Makefile.lammps include ..\/..\/lib\/poems\/Makefile.lammps
@ -58,7 +58,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*poems.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*poems.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -50,7 +50,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*python.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*python.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/python\/Makefile.lammps include ..\/..\/lib\/python\/Makefile.lammps
@ -65,7 +65,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*python.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*python.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -47,7 +47,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*qmmm.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*qmmm.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/qmmm\/Makefile.lammps include ..\/..\/lib\/qmmm\/Makefile.lammps
@ -62,7 +62,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*qmmm.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*qmmm.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -48,7 +48,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*voronoi.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*voronoi.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/voronoi\/Makefile.lammps include ..\/..\/lib\/voronoi\/Makefile.lammps
@ -63,7 +63,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*voronoi.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*voronoi.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -43,7 +43,7 @@ if (test $1 = 1) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*vtk.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*vtk.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs # multiline form needed for BSD sed on Macs
sed -i -e '4 i \ sed -i -e '4 i \
include ..\/..\/lib\/vtk\/Makefile.lammps include ..\/..\/lib\/vtk\/Makefile.lammps
@ -58,7 +58,7 @@ elif (test $1 = 0) then
fi fi
if (test -e ../Makefile.package.settings) then if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*vtk.*$/d' ../Makefile.package.settings sed -i -e '/^[ \t]*include.*vtk.*$/d' ../Makefile.package.settings
fi fi
fi fi

View File

@ -398,6 +398,9 @@ void PairTable::read_table(Table *tb, char *file, char *keyword)
reader.skip_line(); reader.skip_line();
for (int i = 0; i < tb->ninput; i++) { for (int i = 0; i < tb->ninput; i++) {
line = reader.next_line(); line = reader.next_line();
if (!line)
error->one(FLERR, "Data missing when parsing pair table '{}' line {} of {}.", keyword, i + 1,
tb->ninput);
try { try {
ValueTokenizer values(line); ValueTokenizer values(line);
values.next_int(); values.next_int();

View File

@ -43,7 +43,9 @@ static int compare_coords(const int, const int, void *);
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
ResetAtomsID::ResetAtomsID(LAMMPS *lmp) : Command(lmp) {} ResetAtomsID::ResetAtomsID(LAMMPS *lmp) : Command(lmp) {
binlo = binhi = -1;
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -480,6 +482,9 @@ int ResetAtomsID::sort_bins(int n, char *inbuf, int &flag, int *&proclist, char
bigint binlo = rptr->binlo; bigint binlo = rptr->binlo;
bigint binhi = rptr->binhi; bigint binhi = rptr->binhi;
if ((binlo < 0) || (binhi < 0))
error->one(FLERR, "Called sort_bins without previous setup of bins");
// nbins = my subset of bins from binlo to binhi-1 // nbins = my subset of bins from binlo to binhi-1
// initialize linked lists of my Rvous atoms in each bin // initialize linked lists of my Rvous atoms in each bin

View File

@ -6,6 +6,7 @@ skip_tests:
prerequisites: ! | prerequisites: ! |
atom full atom full
pair coul/slater/long pair coul/slater/long
kspace ewald
pre_commands: ! "" pre_commands: ! ""
post_commands: ! | post_commands: ! |
pair_modify mix arithmetic pair_modify mix arithmetic