diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f567a15d25..263b5a566d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -269,6 +269,7 @@ endif() set(ENABLE_IWYU OFF CACHE BOOL "Add 'iwyu' build target to call the include-what-you-use tool") mark_as_advanced(ENABLE_IWYU) if(ENABLE_IWYU) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) find_program(IWYU_EXE NAMES include-what-you-use iwyu) find_program(IWYU_TOOL NAMES iwyu_tool iwyu-tool iwyu_tool.py) if (IWYU_EXE AND IWYU_TOOL) @@ -730,7 +731,7 @@ get_target_property(DEFINES lammps COMPILE_DEFINITIONS) include(FeatureSummary) feature_summary(DESCRIPTION "The following tools and libraries have been found and configured:" WHAT PACKAGES_FOUND) message(STATUS "<<< Build configuration >>> - Operating System: ${CMAKE_SYSTEM_NAME} + Operating System: ${CMAKE_SYSTEM_NAME} ${CMAKE_LINUX_DISTRO} ${CMAKE_DISTRO_VERSION} Build type: ${CMAKE_BUILD_TYPE} Install path: ${CMAKE_INSTALL_PREFIX} Generator: ${CMAKE_GENERATOR} using ${CMAKE_MAKE_PROGRAM}") diff --git a/cmake/Modules/LAMMPSUtils.cmake b/cmake/Modules/LAMMPSUtils.cmake index acaef19498..41dcfc5b2f 100644 --- a/cmake/Modules/LAMMPSUtils.cmake +++ b/cmake/Modules/LAMMPSUtils.cmake @@ -104,3 +104,13 @@ function(FetchPotentials pkgfolder potfolder) endforeach() endif() endfunction(FetchPotentials) + +# set CMAKE_LINUX_DISTRO and CMAKE_DISTRO_VERSION on Linux +if((CMAKE_SYSTEM_NAME STREQUAL Linux) AND (EXISTS /etc/os-release)) + file(STRINGS /etc/os-release distro REGEX "^NAME=") + string(REGEX REPLACE "NAME=\"?([^\"]*)\"?" "\\1" distro "${distro}") + file(STRINGS /etc/os-release disversion REGEX "^VERSION_ID=") + string(REGEX REPLACE "VERSION_ID=\"?([^\"]*)\"?" "\\1" disversion "${disversion}") + set(CMAKE_LINUX_DISTRO ${distro}) + set(CMAKE_DISTRO_VERSION ${disversion}) +endif() diff --git a/cmake/Modules/Packages/USER-PLUMED.cmake b/cmake/Modules/Packages/USER-PLUMED.cmake index 8719e8179d..e71542cfc5 100644 --- a/cmake/Modules/Packages/USER-PLUMED.cmake +++ b/cmake/Modules/Packages/USER-PLUMED.cmake @@ -54,8 +54,9 @@ if(DOWNLOAD_PLUMED) set(PLUMED_BUILD_BYPRODUCTS "/lib/libplumedWrapper.a") endif() - set(PLUMED_URL "https://github.com/plumed/plumed2/releases/download/v2.7.0/plumed-src-2.7.0.tgz" CACHE STRING "URL for PLUMED tarball") - set(PLUMED_MD5 "95f29dd0c067577f11972ff90dfc7d12" CACHE STRING "MD5 checksum of PLUMED tarball") + set(PLUMED_URL "https://github.com/plumed/plumed2/releases/download/v2.7.1/plumed-src-2.7.1.tgz" CACHE STRING "URL for PLUMED tarball") + set(PLUMED_MD5 "4eac6a462ec84dfe0cec96c82421b8e8" CACHE STRING "MD5 checksum of PLUMED tarball") + mark_as_advanced(PLUMED_URL) mark_as_advanced(PLUMED_MD5) diff --git a/cmake/Modules/Testing.cmake b/cmake/Modules/Testing.cmake index 6d2f39b0f3..7fbd8212de 100644 --- a/cmake/Modules/Testing.cmake +++ b/cmake/Modules/Testing.cmake @@ -16,11 +16,14 @@ if(ENABLE_TESTING) set(MEMORYCHECK_COMMAND "${VALGRIND_BINARY}" CACHE FILEPATH "Memory Check Command") set(MEMORYCHECK_COMMAND_OPTIONS "${VALGRIND_DEFAULT_OPTIONS}" CACHE STRING "Memory Check Command Options") - # check if a faster linker is available. - # only verified with GNU and Clang compilers and new CMake - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) - if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) + # we need to build and link a LOT of tester executables, so it is worth checking if + # a faster linker is available. requires GNU or Clang compiler, newer CMake. + # also only verified with Fedora Linux > 30 and Ubuntu <= 18.04 (Ubuntu 20.04 fails) + if((CMAKE_SYSTEM_NAME STREQUAL Linux) AND (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) + AND ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))) + if (((CMAKE_LINUX_DISTRO STREQUAL Ubuntu) AND (CMAKE_DISTRO_VERSION VERSION_LESS_EQUAL 18.04)) + OR ((CMAKE_LINUX_DISTRO STREQUAL Fedora) AND (CMAKE_DISTRO_VERSION VERSION_GREATER 30))) include(CheckCXXCompilerFlag) set(CMAKE_CUSTOM_LINKER_DEFAULT default) check_cxx_compiler_flag(-fuse-ld=lld HAVE_LLD_LINKER_FLAG) diff --git a/doc/graphviz/lammps-classes.dot b/doc/graphviz/lammps-classes.dot index 3c2d2f418d..390dd2cc4b 100644 --- a/doc/graphviz/lammps-classes.dot +++ b/doc/graphviz/lammps-classes.dot @@ -18,8 +18,8 @@ digraph lammps { Up [shape=box label="Update" color=blue] Un [shape=box label="Universe" color=blue] Ti [shape=box label="Timer" color=blue] - Lt [label="Lattice"] Rg [label="Region" color=red] + Lt [label="Lattice"] Rb [shape=box label="RegionBlock"] Rs [shape=box label="RegionSphere"] Av [label="AtomVec" color=red] @@ -34,6 +34,7 @@ digraph lammps { Du [label="Dump" color=red] Fi [label="Fix" color=red] Cp [label="Compute" color=red] + Cm [label="Command" color=red] Th [label="Thermo"] Va [label="Variable"] Ew [shape=box label="Ewald"] @@ -71,16 +72,19 @@ digraph lammps { Dg [shape=box label="DumpCFG"] Ve [shape=box label="Verlet"] Rr [shape=box label="Respa"] + Ru [shape=box label="Run"] + Se [shape=box label="Set"] Pt [shape=box label="PPPMTIP4P"] Vs [shape=box label="VerletSplit"] Ro [shape=box label="RespaOMP"] Mc [shape=box label="MinCG"] Mf [shape=box label="MinFire"] La -> {At Ci Co Do Er Fo Gr In Me Mo Ne Ou Ti Up Un} [penwidth=2] - Do -> {Lt Rg} [penwidth=2] + Do -> {Rg Lt} [penwidth=2] Rg -> {Rb Rs} [style=dashed penwidth=2] Co -> {Cb Ct} [style=dashed penwidth=2] - In -> Va [penwidth=2] + In -> {Va Cm} [penwidth=2] + Cm -> {Ru Se} [style=dashed penwidth=2] Mo -> {Fi Cp} [penwidth=2] Fo -> {Pa Bo An Di Im Ks} [penwidth=2] Ks -> {Ew Pp} [style=dashed penwidth=2] diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 12bb33f264..d375d33e56 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -1253,8 +1253,8 @@ be built for the most part with all major versions of the C++ language. USER-PACE package ----------------------------- -This package requires a library that can be downloaded and built -in lib/pace or somewhere else, which must be done before building +This package requires a library that can be downloaded and built +in lib/pace or somewhere else, which must be done before building LAMMPS with this package. The code for the library can be found at: `https://github.com/ICAMS/lammps-user-pace/ `_ @@ -1276,8 +1276,8 @@ at: `https://github.com/ICAMS/lammps-user-pace/ `. -- As discussed above, command style classes are directly derived from - the Pointers class. They provide input script commands that perform - one-time operations before/after/between simulations or which invoke a - simulation. They are instantiated from within the Input class, - invoked, then immediately destructed. +- Command style classes are derived from the Command class. They provide + input script commands that perform one-time operations + before/after/between simulations or which invoke a simulation. They + are usually instantiated from within the Input class, its ``command`` + method invoked, and then immediately destructed. - The Finish class is instantiated to print statistics to the screen after a simulation is performed, by commands like run and minimize. diff --git a/doc/src/Developer_plugins.rst b/doc/src/Developer_plugins.rst index 68f1f1387c..1beedcf213 100644 --- a/doc/src/Developer_plugins.rst +++ b/doc/src/Developer_plugins.rst @@ -59,31 +59,25 @@ Members of ``lammpsplugin_t`` * - author - String with the name and email of the author * - creator.v1 - - Pointer to factory function for pair, bond, angle, dihedral, or improper styles + - Pointer to factory function for pair, bond, angle, dihedral, improper or command styles * - creator.v2 - Pointer to factory function for compute, fix, or region styles - * - creator.v3 - - Pointer to factory function for command styles * - handle - Pointer to the open DSO file handle Only one of the three alternate creator entries can be used at a time -and which of those is determined by the style of plugin. The "creator.v1" -element is for factory functions of supported styles computing forces (i.e. -pair, bond, angle, dihedral, or improper styles) and the function takes -as single argument the pointer to the LAMMPS instance. The factory function -is cast to the ``lammpsplugin_factory1`` type before assignment. The -"creator.v2" element is for factory functions creating an instance of -a fix, compute, or region style and takes three arguments: a pointer to -the LAMMPS instance, an integer with the length of the argument list and -a ``char **`` pointer to the list of arguments. The factory function pointer -needs to be cast to the ``lammpsplugin_factory2`` type before assignment. -The "creator.v3" element takes the same arguments as "creator.v3" but is -specific to creating command styles: the factory function has to instantiate -the command style locally passing the LAMMPS pointer as argument and then -call its "command" member function with the number and list of arguments. -The factory function pointer needs to be cast to the -``lammpsplugin_factory3`` type before assignment. +and which of those is determined by the style of plugin. The +"creator.v1" element is for factory functions of supported styles +computing forces (i.e. command, pair, bond, angle, dihedral, or +improper styles) and the function takes as single argument the pointer +to the LAMMPS instance. The factory function is cast to the +``lammpsplugin_factory1`` type before assignment. The "creator.v2" +element is for factory functions creating an instance of a fix, compute, +or region style and takes three arguments: a pointer to the LAMMPS +instance, an integer with the length of the argument list and a ``char +**`` pointer to the list of arguments. The factory function pointer +needs to be cast to the ``lammpsplugin_factory2`` type before +assignment. Pair style example ^^^^^^^^^^^^^^^^^^ @@ -123,12 +117,12 @@ function would look like this: The factory function in this example is called ``morse2creator()``. It receives a pointer to the LAMMPS class as only argument and thus has to -be assigned to the *creator.v1* member of the plugin struct and cast to the -``lammpsplugin_factory1`` pointer type. It returns a +be assigned to the *creator.v1* member of the plugin struct and cast to +the ``lammpsplugin_factory1`` function pointer type. It returns a pointer to the allocated class instance derived from the ``Pair`` class. -This function may be declared static to avoid clashes with other plugins. -The name of the derived class, ``PairMorse2``, must be unique inside -the entire LAMMPS executable. +This function may be declared static to avoid clashes with other +plugins. The name of the derived class, ``PairMorse2``, however must be +unique inside the entire LAMMPS executable. Fix style example ^^^^^^^^^^^^^^^^^ @@ -169,9 +163,9 @@ Below is an example for that: Command style example ^^^^^^^^^^^^^^^^^^^^^ -For command styles there is a third variant of factory function as +Command styles also use the first variant of factory function as demonstrated in the following example, which also shows that the -implementation of the plugin class may also be within the same +implementation of the plugin class may be within the same source file as the plugin interface code: .. code-block:: C++ @@ -180,15 +174,15 @@ file as the plugin interface code: #include "comm.h" #include "error.h" - #include "pointers.h" + #include "command.h" #include "version.h" #include namespace LAMMPS_NS { - class Hello : protected Pointers { + class Hello : public Command { public: - Hello(class LAMMPS *lmp) : Pointers(lmp) {}; + Hello(class LAMMPS *lmp) : Command(lmp) {}; void command(int, char **); }; } @@ -202,10 +196,9 @@ file as the plugin interface code: utils::logmesg(lmp,fmt::format("Hello, {}!\n",argv[0])); } - static void hellocreator(LAMMPS *lmp, int argc, char **argv) + static void hellocreator(LAMMPS *lmp) { - Hello hello(lmp); - hello.command(argc,argv); + return new Hello(lmp); } extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc) @@ -216,9 +209,9 @@ file as the plugin interface code: plugin.version = LAMMPS_VERSION; plugin.style = "command"; plugin.name = "hello"; - plugin.info = "Hello world command v1.0"; + plugin.info = "Hello world command v1.1"; plugin.author = "Axel Kohlmeyer (akohlmey@gmail.com)"; - plugin.creator.v3 = (lammpsplugin_factory3 *) &hellocreator; + plugin.creator.v1 = (lammpsplugin_factory1 *) &hellocreator; plugin.handle = handle; (*register_plugin)(&plugin,lmp); } diff --git a/doc/src/Howto_spins.rst b/doc/src/Howto_spins.rst index 0afcc12c91..87e30a5f6f 100644 --- a/doc/src/Howto_spins.rst +++ b/doc/src/Howto_spins.rst @@ -21,8 +21,8 @@ orientations and their associated inter-atomic distances. The command :doc:`fix precession/spin ` allows to apply a constant magnetic torque on all the spins in the system. This -torque can be an external magnetic field (Zeeman interaction), or an -uniaxial magnetic anisotropy. +torque can be an external magnetic field (Zeeman interaction), and an +uniaxial or cubic magnetic anisotropy. A Langevin thermostat can be applied to those magnetic spins using :doc:`fix langevin/spin `. Typically, this thermostat diff --git a/doc/src/JPG/lammps-classes.png b/doc/src/JPG/lammps-classes.png index e401328783..71b5af9ccc 100644 Binary files a/doc/src/JPG/lammps-classes.png and b/doc/src/JPG/lammps-classes.png differ diff --git a/doc/src/Modify_command.rst b/doc/src/Modify_command.rst index 2d0a1d99d9..e0e3ecbb8d 100644 --- a/doc/src/Modify_command.rst +++ b/doc/src/Modify_command.rst @@ -1,14 +1,15 @@ Input script command style ========================== -New commands can be added to LAMMPS input scripts by adding new -classes that have a "command" method. For example, the create_atoms, -read_data, velocity, and run commands are all implemented in this -fashion. When such a command is encountered in the LAMMPS input -script, LAMMPS simply creates a class with the corresponding name, -invokes the "command" method of the class, and passes it the arguments -from the input script. The command method can perform whatever -operations it wishes on LAMMPS data structures. +New commands can be added to LAMMPS input scripts by adding new classes +that are derived from the Command class and thus must have a "command" +method. For example, the create_atoms, read_data, velocity, and run +commands are all implemented in this fashion. When such a command is +encountered in the LAMMPS input script, LAMMPS simply creates a class +instance with the corresponding name, invokes the "command" method of +the class, and passes it the arguments from the input script. The +command method can perform whatever operations it wishes on LAMMPS data +structures. The single method your new class must define is as follows: diff --git a/doc/src/atom_style.rst b/doc/src/atom_style.rst index a250f44b25..dff222b053 100644 --- a/doc/src/atom_style.rst +++ b/doc/src/atom_style.rst @@ -27,7 +27,7 @@ Syntax template-ID = ID of molecule template specified in a separate :doc:`molecule ` command *hybrid* args = list of one or more sub-styles, each with their args -* accelerated styles (with same args) = *angle/kk* or *atomic/kk* or *bond/kk* or *charge/kk* or *full/kk* or *molecular/kk* +* accelerated styles (with same args) = *angle/kk* or *atomic/kk* or *bond/kk* or *charge/kk* or *full/kk* or *molecular/kk* or *spin/kk* Examples """""""" diff --git a/doc/src/fix_qeq.rst b/doc/src/fix_qeq.rst index 56fde059e8..c655076ce8 100644 --- a/doc/src/fix_qeq.rst +++ b/doc/src/fix_qeq.rst @@ -56,27 +56,28 @@ Examples Description """"""""""" -Perform the charge equilibration (QEq) method as described in :ref:`(Rappe and Goddard) ` and formulated in :ref:`(Nakano) ` (also known -as the matrix inversion method) and in :ref:`(Rick and Stuart) ` (also -known as the extended Lagrangian method) based on the -electronegativity equilization principle. +Perform the charge equilibration (QEq) method as described in +:ref:`(Rappe and Goddard) ` and formulated in :ref:`(Nakano) +` (also known as the matrix inversion method) and in +:ref:`(Rick and Stuart) ` (also known as the extended Lagrangian +method) based on the electronegativity equilization principle. These fixes can be used with any :doc:`pair style ` in LAMMPS, so long as per-atom charges are defined. The most typical use-case is in conjunction with a :doc:`pair style ` that performs charge equilibration periodically (e.g. every timestep), such -as the ReaxFF or Streitz-Mintmire potential. -But these fixes can also be used with -potentials that normally assume per-atom charges are fixed, e.g. a -:doc:`Buckingham ` or :doc:`LJ/Coulombic ` potential. +as the ReaxFF or Streitz-Mintmire potential. But these fixes can also +be used with potentials that normally assume per-atom charges are fixed, +e.g. a :doc:`Buckingham ` or :doc:`LJ/Coulombic ` +potential. -Because the charge equilibration calculation is effectively -independent of the pair style, these fixes can also be used to perform -a one-time assignment of charges to atoms. For example, you could -define the QEq fix, perform a zero-timestep run via the :doc:`run ` -command without any pair style defined which would set per-atom -charges (based on the current atom configuration), then remove the fix -via the :doc:`unfix ` command before performing further dynamics. +Because the charge equilibration calculation is effectively independent +of the pair style, these fixes can also be used to perform a one-time +assignment of charges to atoms. For example, you could define the QEq +fix, perform a zero-timestep run via the :doc:`run ` command +without any pair style defined which would set per-atom charges (based +on the current atom configuration), then remove the fix via the +:doc:`unfix ` command before performing further dynamics. .. note:: @@ -87,11 +88,14 @@ via the :doc:`unfix ` command before performing further dynamics. .. note:: - The :doc:`fix qeq/comb ` command must still be used - to perform charge equilibration with the :doc:`COMB potential `. The :doc:`fix qeq/reax ` - command can be used to perform charge equilibration with the :doc:`ReaxFF force field `, although fix qeq/shielded yields the - same results as fix qeq/reax if *Nevery*\ , *cutoff*\ , and *tolerance* - are the same. Eventually the fix qeq/reax command will be deprecated. + The :doc:`fix qeq/comb ` command must still be used to + perform charge equilibration with the :doc:`COMB potential + `. The :doc:`fix qeq/reax ` command can be + used to perform charge equilibration with the :doc:`ReaxFF force + field `, although fix qeq/shielded yields the same + results as fix qeq/reax if *Nevery*\ , *cutoff*\ , and *tolerance* + are the same. Eventually the fix qeq/reax command will be + deprecated. The QEq method minimizes the electrostatic energy of the system (or equalizes the derivative of energy with respect to charge of all the @@ -134,55 +138,57 @@ usually a good number. The *qeq/shielded* style describes partial charges on atoms also as point charges, but uses a shielded Coulomb potential to describe the interaction between a pair of charged particles. Interaction through -the shielded Coulomb is given by equation (13) of the :ref:`ReaxFF force field ` paper. The shielding accounts for charge overlap +the shielded Coulomb is given by equation (13) of the :ref:`ReaxFF force +field ` paper. The shielding accounts for charge overlap between charged particles at small separation. This style is the same -as :doc:`fix qeq/reax `, and can be used with :doc:`pair_style reax/c `. Only the *chi*\ , *eta*\ , and *gamma* -parameters from the *qfile* file are used. When using the string -*reax/c* as filename, these parameters are extracted directly from -an active *reax/c* pair style. This style solves partial -charges on atoms via the matrix inversion method. A tolerance of -1.0e-6 is usually a good number. +as :doc:`fix qeq/reax `, and can be used with +:doc:`pair_style reax/c `. Only the *chi*\ , *eta*\ , and +*gamma* parameters from the *qfile* file are used. When using the string +*reax/c* as filename, these parameters are extracted directly from an +active *reax/c* pair style. This style solves partial charges on atoms +via the matrix inversion method. A tolerance of 1.0e-6 is usually a +good number. The *qeq/slater* style describes partial charges on atoms as spherical charge densities centered around atoms via the Slater 1\ *s* orbital, so -that the interaction between a pair of charged particles is the -product of two Slater 1\ *s* orbitals. The expression for the Slater -1\ *s* orbital is given under equation (6) of the -:ref:`Streitz-Mintmire ` paper. Only the *chi*\ , *eta*\ , *zeta*\ , and -*qcore* parameters from the *qfile* file are used. When using the string +that the interaction between a pair of charged particles is the product +of two Slater 1\ *s* orbitals. The expression for the Slater 1\ *s* +orbital is given under equation (6) of the :ref:`Streitz-Mintmire +` paper. Only the *chi*\ , *eta*\ , *zeta*\ , and *qcore* +parameters from the *qfile* file are used. When using the string *coul/streitz* as filename, these parameters are extracted directly from -an active *coul/streitz* pair style. This style solves -partial charges on atoms via the matrix inversion method. A tolerance -of 1.0e-6 is usually a good number. Keyword *alpha* can be used to -change the Slater type orbital exponent. +an active *coul/streitz* pair style. This style solves partial charges +on atoms via the matrix inversion method. A tolerance of 1.0e-6 is +usually a good number. Keyword *alpha* can be used to change the Slater +type orbital exponent. The *qeq/dynamic* style describes partial charges on atoms as point -charges that interact through 1/r, but the extended Lagrangian method -is used to solve partial charges on atoms. Only the *chi* and *eta* +charges that interact through 1/r, but the extended Lagrangian method is +used to solve partial charges on atoms. Only the *chi* and *eta* parameters from the *qfile* file are used. Note that Coulomb -catastrophe can occur if repulsion between the pair of charged -particles is too weak. A tolerance of 1.0e-3 is usually a good -number. Keyword *qdamp* can be used to change the damping factor, while -keyword *qstep* can be used to change the time step size. +catastrophe can occur if repulsion between the pair of charged particles +is too weak. A tolerance of 1.0e-3 is usually a good number. Keyword +*qdamp* can be used to change the damping factor, while keyword *qstep* +can be used to change the time step size. -The :ref:`\ *qeq/fire*\ ` style describes the same charge model and charge -solver as the *qeq/dynamic* style, but employs a FIRE minimization -algorithm to solve for equilibrium charges. -Keyword *qdamp* can be used to change the damping factor, while -keyword *qstep* can be used to change the time step size. +The :ref:`\ *qeq/fire*\ ` style describes the same charge model +and charge solver as the *qeq/dynamic* style, but employs a FIRE +minimization algorithm to solve for equilibrium charges. Keyword +*qdamp* can be used to change the damping factor, while keyword *qstep* +can be used to change the time step size. Note that *qeq/point*\ , *qeq/shielded*\ , and *qeq/slater* describe different charge models, whereas the matrix inversion method and the extended Lagrangian method (\ *qeq/dynamic* and *qeq/fire*\ ) are different solvers. -Note that *qeq/point*\ , *qeq/dynamic* and *qeq/fire* styles all describe -charges as point charges that interact through 1/r relationship, but -solve partial charges on atoms using different solvers. These three -styles should yield comparable results if -the QEq parameters and *Nevery*\ , *cutoff*\ , and *tolerance* are the -same. Style *qeq/point* is typically faster, *qeq/dynamic* scales -better on larger sizes, and *qeq/fire* is faster than *qeq/dynamic*\ . +Note that *qeq/point*\ , *qeq/dynamic* and *qeq/fire* styles all +describe charges as point charges that interact through 1/r +relationship, but solve partial charges on atoms using different +solvers. These three styles should yield comparable results if the QEq +parameters and *Nevery*\ , *cutoff*\ , and *tolerance* are the same. +Style *qeq/point* is typically faster, *qeq/dynamic* scales better on +larger sizes, and *qeq/fire* is faster than *qeq/dynamic*\ . .. note:: @@ -200,9 +206,11 @@ better on larger sizes, and *qeq/fire* is faster than *qeq/dynamic*\ . Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" -No information about these fixes is written to :doc:`binary restart files `. No global scalar or vector or per-atom -quantities are stored by these fixes for access by various :doc:`output commands `. No parameter of these fixes can be used -with the *start/stop* keywords of the :doc:`run ` command. +No information about these fixes is written to :doc:`binary restart +files `. No global scalar or vector or per-atom quantities are +stored by these fixes for access by various :doc:`output commands +`. No parameter of these fixes can be used with the +*start/stop* keywords of the :doc:`run ` command. Thexe fixes are invoked during :doc:`energy minimization `. @@ -210,7 +218,8 @@ Restrictions """""""""""" These fixes are part of the QEQ package. They are only enabled if -LAMMPS was built with that package. See the :doc:`Build package ` doc page for more info. +LAMMPS was built with that package. See the :doc:`Build package +` doc page for more info. Related commands """""""""""""""" diff --git a/examples/SPIN/test_problems/validation_damped_exchange/llg_exchange.py b/examples/SPIN/test_problems/validation_damped_exchange/llg_exchange.py index 5b93ac5c2d..a4cba3a940 100755 --- a/examples/SPIN/test_problems/validation_damped_exchange/llg_exchange.py +++ b/examples/SPIN/test_problems/validation_damped_exchange/llg_exchange.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import mpmath as mp hbar=0.658212 # Planck's constant (eV.fs/rad) -# J0=0.05 # per-neighbor exchange interaction (eV) +J0=0.05 # per-neighbor exchange interaction (eV) # exchange interaction parameters J1 = 11.254 # in eV diff --git a/examples/SPIN/test_problems/validation_damped_exchange/run-test-exchange.sh b/examples/SPIN/test_problems/validation_damped_exchange/run-test-exchange.sh index bd878a52de..9d00318473 100755 --- a/examples/SPIN/test_problems/validation_damped_exchange/run-test-exchange.sh +++ b/examples/SPIN/test_problems/validation_damped_exchange/run-test-exchange.sh @@ -3,9 +3,15 @@ # clean old res rm res_*.dat -# compute Lammps +# test standard Lammps ./../../../../src/lmp_serial \ -in test-spin-precession.in + +# test spin/kk with Kokkos Lammps +# mpirun -np 1 ../../../../src/lmp_kokkos_mpi_only \ +# -k on -sf kk -in test-spin-precession.in + +# extract data from Lammps run in="$(grep -n Step log.lammps | awk -F ':' '{print $1}')" en="$(grep -n Loop log.lammps | awk -F ':' '{print $1}')" in="$(echo "$in+1" | bc -l)" diff --git a/examples/SPIN/test_problems/validation_damped_exchange/test-spin-precession.in b/examples/SPIN/test_problems/validation_damped_exchange/test-spin-precession.in index 9dfb4a98d6..c195c046ec 100644 --- a/examples/SPIN/test_problems/validation_damped_exchange/test-spin-precession.in +++ b/examples/SPIN/test_problems/validation_damped_exchange/test-spin-precession.in @@ -2,8 +2,10 @@ units metal atom_style spin +# atom_style spin/kk atom_modify map array boundary f f f +shell echo "test1" atom_modify map array lattice sc 3.0 diff --git a/examples/SPIN/test_problems/validation_damped_precession/run-test-prec.sh b/examples/SPIN/test_problems/validation_damped_precession/run-test-prec.sh index 8609179376..e7a943beef 100755 --- a/examples/SPIN/test_problems/validation_damped_precession/run-test-prec.sh +++ b/examples/SPIN/test_problems/validation_damped_precession/run-test-prec.sh @@ -3,9 +3,15 @@ # clean old res rm res_*.dat -# compute Lammps +# test standard Lammps ./../../../../src/lmp_serial \ -in test-spin-precession.in + +# test spin/kk with Kokkos Lammps +# mpirun -np 1 ../../../../src/lmp_kokkos_mpi_only \ +# -k on -sf kk -in test-spin-precession.in + +# extract data from Lammps run in="$(grep -n Step log.lammps | awk -F ':' '{print $1}')" en="$(grep -n Loop log.lammps | awk -F ':' '{print $1}')" in="$(echo "$in+1" | bc -l)" diff --git a/examples/SPIN/test_problems/validation_damped_precession/test-spin-precession.in b/examples/SPIN/test_problems/validation_damped_precession/test-spin-precession.in index b8e943e579..56abdded15 100644 --- a/examples/SPIN/test_problems/validation_damped_precession/test-spin-precession.in +++ b/examples/SPIN/test_problems/validation_damped_precession/test-spin-precession.in @@ -2,6 +2,7 @@ units metal atom_style spin +# atom_style spin/kk atom_modify map array boundary f f f diff --git a/examples/SPIN/test_problems/validation_langevin_precession/run-test-prec.sh b/examples/SPIN/test_problems/validation_langevin_precession/run-test-prec.sh index bcdd337903..ecdbb2c156 100755 --- a/examples/SPIN/test_problems/validation_langevin_precession/run-test-prec.sh +++ b/examples/SPIN/test_problems/validation_langevin_precession/run-test-prec.sh @@ -12,7 +12,14 @@ do temp="$(echo "$tempi+$i*($tempf-$tempi)/$N" | bc -l)" sed s/temperature/${temp}/g test-prec-spin.template > \ test-prec-spin.in + + # test standard Lammps ./../../../../src/lmp_serial -in test-prec-spin.in + + # test spin/kk with Kokkos Lammps + # mpirun -np 1 ../../../../src/lmp_kokkos_mpi_only \ + # -k on -sf kk -in test-prec-spin.in + Hz="$(tail -n 1 average_spin | awk -F " " '{print $3}')" sz="$(tail -n 1 average_spin | awk -F " " '{print $5}')" en="$(tail -n 1 average_spin | awk -F " " '{print $6}')" diff --git a/examples/SPIN/test_problems/validation_langevin_precession/test-prec-spin.template b/examples/SPIN/test_problems/validation_langevin_precession/test-prec-spin.template index 52f6a105ea..bec7126e69 100644 --- a/examples/SPIN/test_problems/validation_langevin_precession/test-prec-spin.template +++ b/examples/SPIN/test_problems/validation_langevin_precession/test-prec-spin.template @@ -2,6 +2,7 @@ units metal atom_style spin +# atom_style spin/kk atom_modify map array boundary p p p diff --git a/examples/SPIN/test_problems/validation_nve/in.spin.iron-nve b/examples/SPIN/test_problems/validation_nve/in.spin.iron-nve index f00fb1ec12..38c669e166 100644 --- a/examples/SPIN/test_problems/validation_nve/in.spin.iron-nve +++ b/examples/SPIN/test_problems/validation_nve/in.spin.iron-nve @@ -3,6 +3,7 @@ clear units metal atom_style spin +# atom_style spin/kk dimension 3 boundary p p p @@ -46,4 +47,8 @@ variable tmag equal c_out_mag[6] thermo_style custom step time v_tmag temp v_emag ke pe etotal thermo 200 +compute outsp all property/atom spx spy spz sp fmx fmy fmz +dump 1 all custom 10 dump_iron.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3] + run 100000 +# run 1 diff --git a/examples/SPIN/test_problems/validation_nve/run-test-nve.sh b/examples/SPIN/test_problems/validation_nve/run-test-nve.sh index 18cedd9503..04d3d60847 100755 --- a/examples/SPIN/test_problems/validation_nve/run-test-nve.sh +++ b/examples/SPIN/test_problems/validation_nve/run-test-nve.sh @@ -3,9 +3,14 @@ # clean old res rm res_*.dat -# compute Lammps -./../../../../src/lmp_serial \ - -in in.spin.iron-nve +# test standard Lammps +../../../../src/lmp_serial -in in.spin.iron-nve + +# test spin/kk with Kokkos Lammps +# mpirun -np 1 ../../../../src/lmp_kokkos_mpi_only \ +# -k on -sf kk -in in.spin.iron-nve + +# extract data from Lammps run in="$(grep -n Step log.lammps | awk -F ':' '{print $1}')" en="$(grep -n Loop log.lammps | awk -F ':' '{print $1}')" in="$(echo "$in+1" | bc -l)" diff --git a/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_lattice b/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_lattice index 2375c0ff8d..cc7bcfa68d 100644 --- a/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_lattice +++ b/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_lattice @@ -3,6 +3,7 @@ clear units metal atom_style spin +# atom_style spin/kk dimension 3 boundary p p p diff --git a/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_spin b/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_spin index 6b65df7109..7e8152f481 100644 --- a/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_spin +++ b/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_spin @@ -3,6 +3,7 @@ clear units metal atom_style spin +# atom_style spin/kk dimension 3 boundary p p p diff --git a/examples/SPIN/test_problems/validation_nvt/run-test-nvt.sh b/examples/SPIN/test_problems/validation_nvt/run-test-nvt.sh index d3abbbe1a5..1372e1bd2c 100755 --- a/examples/SPIN/test_problems/validation_nvt/run-test-nvt.sh +++ b/examples/SPIN/test_problems/validation_nvt/run-test-nvt.sh @@ -3,16 +3,32 @@ # clean old res rm res_*.dat -# compute NVT Spin -> Lattice +### compute NVT Spin -> Lattice + +# test standard Lammps ./../../../../src/lmp_serial -in in.spin.nvt_spin + +# test spin/kk with Kokkos Lammps +# mpirun -np 1 ../../../../src/lmp_kokkos_mpi_only \ +# -k on -sf kk -in in.spin.nvt_spin + +# extract data from Lammps run in="$(grep -n Step log.lammps | awk -F ':' '{print $1}')" en="$(grep -n Loop log.lammps | awk -F ':' '{print $1}')" in="$(echo "$in+1" | bc -l)" en="$(echo "$en-$in" | bc -l)" tail -n +$in log.lammps | head -n $en > res_nvt_spin.dat -# compute NVT Lattice -> Spin +### compute NVT Lattice -> Spin + +# test standard Lammps ./../../../../src/lmp_serial -in in.spin.nvt_lattice + +# test spin/kk with Kokkos Lammps +# mpirun -np 1 ../../../../src/lmp_kokkos_mpi_only \ +# -k on -sf kk -in in.spin.nvt_lattice + +# extract data from Lammps run in="$(grep -n Step log.lammps | awk -F ':' '{print $1}')" en="$(grep -n Loop log.lammps | awk -F ':' '{print $1}')" in="$(echo "$in+1" | bc -l)" diff --git a/examples/plugins/helloplugin.cpp b/examples/plugins/helloplugin.cpp index 11f2cfb891..f4a49c1a5a 100644 --- a/examples/plugins/helloplugin.cpp +++ b/examples/plugins/helloplugin.cpp @@ -2,16 +2,16 @@ #include "lammpsplugin.h" #include "comm.h" +#include "command.h" #include "error.h" -#include "pointers.h" #include "version.h" #include namespace LAMMPS_NS { - class Hello : protected Pointers { + class Hello : public Command { public: - Hello(class LAMMPS *lmp) : Pointers(lmp) {}; + Hello(class LAMMPS *lmp) : Command(lmp) {}; void command(int, char **); }; } @@ -25,10 +25,9 @@ void Hello::command(int argc, char **argv) utils::logmesg(lmp,fmt::format("Hello, {}!\n",argv[0])); } -static void hellocreator(LAMMPS *lmp, int argc, char **argv) +static Command *hellocreator(LAMMPS *lmp) { - Hello hello(lmp); - hello.command(argc,argv); + return new Hello(lmp); } extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc) @@ -39,9 +38,9 @@ extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc) plugin.version = LAMMPS_VERSION; plugin.style = "command"; plugin.name = "hello"; - plugin.info = "Hello world command v1.0"; + plugin.info = "Hello world command v1.1"; plugin.author = "Axel Kohlmeyer (akohlmey@gmail.com)"; - plugin.creator.v3 = (lammpsplugin_factory3 *) &hellocreator; + plugin.creator.v1 = (lammpsplugin_factory1 *) &hellocreator; plugin.handle = handle; (*register_plugin)(&plugin,lmp); } diff --git a/lib/plumed/Install.py b/lib/plumed/Install.py index c11d5bfee9..e3858b39d3 100644 --- a/lib/plumed/Install.py +++ b/lib/plumed/Install.py @@ -17,7 +17,7 @@ parser = ArgumentParser(prog='Install.py', # settings -version = "2.7.0" +version = "2.7.1" mode = "static" # help message @@ -47,9 +47,12 @@ checksums = { \ '2.5.2' : 'bd2f18346c788eb54e1e52f4f6acf41a', \ '2.5.3' : 'de30d6e7c2dcc0973298e24a6da24286', \ '2.5.4' : 'f31b7d16a4be2e30aa7d5c19c3d37853', \ + '2.5.7' : '1ca36226fdb8110b1009aa61d615d4e5', \ '2.6.0' : '204d2edae58d9b10ba3ad460cad64191', \ '2.6.1' : '89a9a450fc6025299fe16af235957163', \ + '2.6.3' : 'a9f8028fd74528c2024781ea1fdefeee', \ '2.7.0' : '95f29dd0c067577f11972ff90dfc7d12', \ + '2.7.1' : '4eac6a462ec84dfe0cec96c82421b8e8', \ } # parse and process arguments diff --git a/python/install.py b/python/install.py index 6e4c509f07..fbff02a1b5 100644 --- a/python/install.py +++ b/python/install.py @@ -10,7 +10,7 @@ build target in the conventional and CMake based build systems # copy LAMMPS shared library and lammps package to system dirs from __future__ import print_function -import sys,os,shutil +import sys,os,shutil,time from argparse import ArgumentParser parser = ArgumentParser(prog='install.py', @@ -80,13 +80,15 @@ if args.dir: sys.exit() -# extract version string from header +# extract LAMMPS version string from header +# and convert to python packaging compatible version def get_lammps_version(header): with open(header, 'r') as f: line = f.readline() start_pos = line.find('"')+1 end_pos = line.find('"', start_pos) - return "".join(line[start_pos:end_pos].split()) + t = time.strptime("".join(line[start_pos:end_pos].split()), "%d%b%Y") + return "{}.{}.{}".format(t.tm_year,t.tm_mon,t.tm_mday) verstr = get_lammps_version(args.version) diff --git a/python/lammps/__init__.py b/python/lammps/__init__.py index e6ffd779a9..2c0e7a6fe3 100644 --- a/python/lammps/__init__.py +++ b/python/lammps/__init__.py @@ -13,10 +13,16 @@ from .core import * from .data import * from .pylammps import * -# convert module string version to numeric version +# convert installed module string version to numeric version def get_version_number(): import time + from os.path import join from sys import version_info + + # must report 0 when inside LAMMPS source tree + if __file__.find(join('python', 'lammps', '__init__.py')) > 0: + return 0 + vstring = None if version_info.major == 3 and version_info.minor >= 8: from importlib.metadata import version @@ -32,7 +38,7 @@ def get_version_number(): if not vstring: return 0 - t = time.strptime(vstring, "%d%b%Y") + t = time.strptime(vstring, "%Y.%m.%d") return t.tm_year*10000 + t.tm_mon*100 + t.tm_mday __version__ = get_version_number() diff --git a/python/setup.py b/python/setup.py index aff0b14671..2f2b67b6f1 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,7 +1,8 @@ # this only installs the LAMMPS python package # it assumes the LAMMPS shared library is already installed from distutils.core import setup -import os +from sys import version_info +import os,time LAMMPS_PYTHON_DIR = os.path.dirname(os.path.realpath(__file__)) LAMMPS_DIR = os.path.dirname(LAMMPS_PYTHON_DIR) @@ -12,7 +13,13 @@ def get_lammps_version(): line = f.readline() start_pos = line.find('"')+1 end_pos = line.find('"', start_pos) - return "".join(line[start_pos:end_pos].split()) + t = time.strptime("".join(line[start_pos:end_pos].split()), "%d%b%Y") + return "{}.{}.{}".format(t.tm_year,t.tm_mon,t.tm_mday) + +if version_info.major >= 3: + pkgs = ['lammps', 'lammps.mliap'] +else: + pkgs = ['lammps'] setup( name = "lammps", @@ -22,5 +29,5 @@ setup( url = "https://lammps.sandia.gov", description = "LAMMPS Molecular Dynamics Python package", license = "GPL", - packages=["lammps","lammps.mliap"], + packages=pkgs, ) diff --git a/src/COMPRESS/gz_file_writer.cpp b/src/COMPRESS/gz_file_writer.cpp index d24d77b21a..36b9161cc1 100644 --- a/src/COMPRESS/gz_file_writer.cpp +++ b/src/COMPRESS/gz_file_writer.cpp @@ -67,7 +67,7 @@ size_t GzFileWriter::write(const void * buffer, size_t length) void GzFileWriter::flush() { if (!isopen()) return; - + gzflush(gzFp, Z_SYNC_FLUSH); } diff --git a/src/KIM/kim_command.h b/src/KIM/kim_command.h index f327e4f2f3..b27b0e0873 100644 --- a/src/KIM/kim_command.h +++ b/src/KIM/kim_command.h @@ -62,13 +62,13 @@ CommandStyle(kim,KimCommand) #ifndef LMP_KIM_COMMAND_H #define LMP_KIM_COMMAND_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class KimCommand : protected Pointers { +class KimCommand : public Command { public: - KimCommand(class LAMMPS *lmp) : Pointers(lmp) {}; + KimCommand(class LAMMPS *lmp) : Command(lmp) {}; void command(int, char **); }; diff --git a/src/KOKKOS/Install.sh b/src/KOKKOS/Install.sh index 7c35f81891..0ac90a53f2 100755 --- a/src/KOKKOS/Install.sh +++ b/src/KOKKOS/Install.sh @@ -63,6 +63,8 @@ action atom_vec_bond_kokkos.cpp atom_vec_bond.cpp action atom_vec_bond_kokkos.h atom_vec_bond.h action atom_vec_charge_kokkos.cpp action atom_vec_charge_kokkos.h +action atom_vec_spin_kokkos.cpp +action atom_vec_spin_kokkos.h action atom_vec_dpd_kokkos.cpp atom_vec_dpd.cpp action atom_vec_dpd_kokkos.h atom_vec_dpd.h action atom_vec_full_kokkos.cpp atom_vec_full.cpp diff --git a/src/KOKKOS/atom_kokkos.cpp b/src/KOKKOS/atom_kokkos.cpp index 19cfe02c96..98b33368b7 100644 --- a/src/KOKKOS/atom_kokkos.cpp +++ b/src/KOKKOS/atom_kokkos.cpp @@ -76,6 +76,12 @@ AtomKokkos::~AtomKokkos() memoryKK->destroy_kokkos(k_improper_atom3, improper_atom3); memoryKK->destroy_kokkos(k_improper_atom4, improper_atom4); + // SPIN package + + memoryKK->destroy_kokkos(k_sp, sp); + memoryKK->destroy_kokkos(k_fm, fm); + memoryKK->destroy_kokkos(k_fm_long, fm_long); + // USER-DPD package memoryKK->destroy_kokkos(k_uCond,uCond); memoryKK->destroy_kokkos(k_uMech,uMech); diff --git a/src/KOKKOS/atom_kokkos.h b/src/KOKKOS/atom_kokkos.h index c875817a70..f5cf4916cf 100644 --- a/src/KOKKOS/atom_kokkos.h +++ b/src/KOKKOS/atom_kokkos.h @@ -54,6 +54,11 @@ class AtomKokkos : public Atom { DAT::tdual_float_2d k_dvector; + // SPIN package + + DAT::tdual_float_1d_4 k_sp; + DAT::tdual_f_array k_fm; + DAT::tdual_f_array k_fm_long; // USER-DPD package DAT::tdual_efloat_1d k_uCond, k_uMech, k_uChem, k_uCG, k_uCGnew, diff --git a/src/KOKKOS/atom_vec_spin_kokkos.cpp b/src/KOKKOS/atom_vec_spin_kokkos.cpp new file mode 100644 index 0000000000..399ab23a5f --- /dev/null +++ b/src/KOKKOS/atom_vec_spin_kokkos.cpp @@ -0,0 +1,1310 @@ +/* ---------------------------------------------------------------------- + + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. + +------------------------------------------------------------------------- */ + +/* ------------------------------------------------------------------------ + Contributing authors: Julien Tranchida (SNL) + Aidan Thompson (SNL) + + Please cite the related publication: + Tranchida, J., Plimpton, S. J., Thibaudeau, P., & Thompson, A. P. (2018). + Massively parallel symplectic algorithm for coupled magnetic spin dynamics + and molecular dynamics. Journal of Computational Physics. +------------------------------------------------------------------------- */ + +#include "atom_vec_spin_kokkos.h" + +#include "atom_kokkos.h" +#include "atom_masks.h" +#include "comm_kokkos.h" +#include "domain.h" +#include "error.h" +#include "fix.h" +#include "memory_kokkos.h" +#include "modify.h" + +using namespace LAMMPS_NS; + +#define DELTA 10 + +/* ---------------------------------------------------------------------- */ + +AtomVecSpinKokkos::AtomVecSpinKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) +{ + molecular = 0; + mass_type = 1; + forceclearflag = 1; + + comm_x_only = comm_f_only = 0; + size_forward = 7; + size_reverse = 9; + size_border = 10; + size_velocity = 3; + size_data_atom = 9; + size_data_vel = 4; + xcol_data = 4; + + atom->sp_flag = 1; + + k_count = DAT::tdual_int_1d("atom::k_count",1); + atomKK = (AtomKokkos *) atom; + commKK = (CommKokkos *) comm; +} + +/* ---------------------------------------------------------------------- + grow atom arrays + n = 0 grows arrays by a chunk + n > 0 allocates arrays to size n +------------------------------------------------------------------------- */ + +void AtomVecSpinKokkos::grow(int n) +{ + int step = MAX(DELTA,nmax*0.01); + if (n == 0) nmax += step; + else nmax = n; + atomKK->nmax = nmax; + if (nmax < 0 || nmax > MAXSMALLINT) + error->one(FLERR,"Per-processor system is too big"); + + atomKK->sync(Device,ALL_MASK); + atomKK->modified(Device,ALL_MASK); + + memoryKK->grow_kokkos(atomKK->k_tag,atomKK->tag,nmax,"atom:tag"); + memoryKK->grow_kokkos(atomKK->k_type,atomKK->type,nmax,"atom:type"); + memoryKK->grow_kokkos(atomKK->k_mask,atomKK->mask,nmax,"atom:mask"); + memoryKK->grow_kokkos(atomKK->k_image,atomKK->image,nmax,"atom:image"); + + // allocating mech. quantities + + memoryKK->grow_kokkos(atomKK->k_x,atomKK->x,nmax,"atom:x"); + memoryKK->grow_kokkos(atomKK->k_v,atomKK->v,nmax,"atom:v"); + memoryKK->grow_kokkos(atomKK->k_f,atomKK->f,nmax,"atom:f"); + + // allocating mag. quantities + + memoryKK->grow_kokkos(atomKK->k_sp,atomKK->sp,nmax,"atom:sp"); + memoryKK->grow_kokkos(atomKK->k_fm,atomKK->fm,nmax,"atom:fm"); + memoryKK->grow_kokkos(atomKK->k_fm_long,atomKK->fm_long,nmax,"atom:fm_long"); + + grow_pointers(); + atomKK->sync(Host,ALL_MASK); + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); +} + +/* ---------------------------------------------------------------------- + reset local array ptrs +------------------------------------------------------------------------- */ + +void AtomVecSpinKokkos::grow_pointers() +{ + tag = atomKK->tag; + d_tag = atomKK->k_tag.d_view; + h_tag = atomKK->k_tag.h_view; + + type = atomKK->type; + d_type = atomKK->k_type.d_view; + h_type = atomKK->k_type.h_view; + mask = atomKK->mask; + d_mask = atomKK->k_mask.d_view; + h_mask = atomKK->k_mask.h_view; + image = atomKK->image; + d_image = atomKK->k_image.d_view; + h_image = atomKK->k_image.h_view; + + x = atomKK->x; + d_x = atomKK->k_x.d_view; + h_x = atomKK->k_x.h_view; + v = atomKK->v; + d_v = atomKK->k_v.d_view; + h_v = atomKK->k_v.h_view; + f = atomKK->f; + d_f = atomKK->k_f.d_view; + h_f = atomKK->k_f.h_view; + + sp = atomKK->sp; + d_sp = atomKK->k_sp.d_view; + h_sp = atomKK->k_sp.h_view; + fm = atomKK->fm; + d_fm = atomKK->k_fm.d_view; + h_fm = atomKK->k_fm.h_view; + fm_long = atomKK->fm_long; + d_fm_long = atomKK->k_fm_long.d_view; + h_fm_long = atomKK->k_fm_long.h_view; +} + +/* ---------------------------------------------------------------------- + copy atom I info to atom J +------------------------------------------------------------------------- */ + +void AtomVecSpinKokkos::copy(int i, int j, int delflag) +{ + h_tag[j] = h_tag[i]; + h_type[j] = h_type[i]; + mask[j] = mask[i]; + h_image[j] = h_image[i]; + h_x(j,0) = h_x(i,0); + h_x(j,1) = h_x(i,1); + h_x(j,2) = h_x(i,2); + h_v(j,0) = h_v(i,0); + h_v(j,1) = h_v(i,1); + h_v(j,2) = h_v(i,2); + + h_sp(j,0) = h_sp(i,0); + h_sp(j,1) = h_sp(i,1); + h_sp(j,2) = h_sp(i,2); + h_sp(j,3) = h_sp(i,3); + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag); +} + +/* ---------------------------------------------------------------------- */ + +template +struct AtomVecSpinKokkos_PackComm { + typedef DeviceType device_type; + + typename ArrayTypes::t_x_array_randomread _x; + typename ArrayTypes::t_sp_array_randomread _sp; + typename ArrayTypes::t_xfloat_2d_um _buf; + typename ArrayTypes::t_int_2d_const _list; + const int _iswap; + X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; + X_FLOAT _pbc[6]; + + AtomVecSpinKokkos_PackComm( + const typename DAT::tdual_x_array &x, + const typename DAT::tdual_float_1d_4 &sp, + const typename DAT::tdual_xfloat_2d &buf, + const typename DAT::tdual_int_2d &list, + const int & iswap, + const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, + const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc): + _x(x.view()),_sp(sp.view()), + _list(list.view()),_iswap(iswap), + _xprd(xprd),_yprd(yprd),_zprd(zprd), + _xy(xy),_xz(xz),_yz(yz) { + const size_t maxsend = (buf.view().extent(0)*buf.view().extent(1))/3; + const size_t elements = 7; + buffer_view(_buf,buf,maxsend,elements); + _pbc[0] = pbc[0]; _pbc[1] = pbc[1]; _pbc[2] = pbc[2]; + _pbc[3] = pbc[3]; _pbc[4] = pbc[4]; _pbc[5] = pbc[5]; + }; + + KOKKOS_INLINE_FUNCTION + void operator() (const int& i) const { + const int j = _list(_iswap,i); + if (PBC_FLAG == 0) { + _buf(i,0) = _x(j,0); + _buf(i,1) = _x(j,1); + _buf(i,2) = _x(j,2); + _buf(i,3) = _sp(j,0); + _buf(i,4) = _sp(j,1); + _buf(i,5) = _sp(j,2); + _buf(i,6) = _sp(j,3); + } else { + if (TRICLINIC == 0) { + _buf(i,0) = _x(j,0) + _pbc[0]*_xprd; + _buf(i,1) = _x(j,1) + _pbc[1]*_yprd; + _buf(i,2) = _x(j,2) + _pbc[2]*_zprd; + _buf(i,3) = _sp(j,0); + _buf(i,4) = _sp(j,1); + _buf(i,5) = _sp(j,2); + _buf(i,6) = _sp(j,3); + } else { + _buf(i,0) = _x(j,0) + _pbc[0]*_xprd + _pbc[5]*_xy + _pbc[4]*_xz; + _buf(i,1) = _x(j,1) + _pbc[1]*_yprd + _pbc[3]*_yz; + _buf(i,2) = _x(j,2) + _pbc[2]*_zprd; + _buf(i,3) = _sp(j,0); + _buf(i,4) = _sp(j,1); + _buf(i,5) = _sp(j,2); + _buf(i,6) = _sp(j,3); + } + } + } +}; + +/* ---------------------------------------------------------------------- */ + +template +struct AtomVecSpinKokkos_PackBorder { + typedef DeviceType device_type; + + typename ArrayTypes::t_xfloat_2d _buf; + const typename ArrayTypes::t_int_2d_const _list; + const int _iswap; + const typename ArrayTypes::t_x_array_randomread _x; + const typename ArrayTypes::t_tagint_1d _tag; + const typename ArrayTypes::t_int_1d _type; + const typename ArrayTypes::t_int_1d _mask; + const typename ArrayTypes::t_sp_array_randomread _sp; + X_FLOAT _dx,_dy,_dz; + + AtomVecSpinKokkos_PackBorder( + const typename ArrayTypes::t_xfloat_2d &buf, + const typename ArrayTypes::t_int_2d_const &list, + const int & iswap, + const typename ArrayTypes::t_x_array &x, + const typename ArrayTypes::t_tagint_1d &tag, + const typename ArrayTypes::t_int_1d &type, + const typename ArrayTypes::t_int_1d &mask, + const typename ArrayTypes::t_sp_array &sp, + const X_FLOAT &dx, const X_FLOAT &dy, const X_FLOAT &dz): + _buf(buf),_list(list),_iswap(iswap), + _x(x),_tag(tag),_type(type),_mask(mask),_sp(sp), + _dx(dx),_dy(dy),_dz(dz) {} + + KOKKOS_INLINE_FUNCTION + void operator() (const int& i) const { + const int j = _list(_iswap,i); + if (PBC_FLAG == 0) { + _buf(i,0) = _x(j,0); + _buf(i,1) = _x(j,1); + _buf(i,2) = _x(j,2); + _buf(i,3) = d_ubuf(_tag(j)).d; + _buf(i,4) = d_ubuf(_type(j)).d; + _buf(i,5) = d_ubuf(_mask(j)).d; + _buf(i,6) = _sp(j,0); + _buf(i,7) = _sp(j,1); + _buf(i,8) = _sp(j,2); + _buf(i,9) = _sp(j,3); + } else { + _buf(i,0) = _x(j,0) + _dx; + _buf(i,1) = _x(j,1) + _dy; + _buf(i,2) = _x(j,2) + _dz; + _buf(i,3) = d_ubuf(_tag(j)).d; + _buf(i,4) = d_ubuf(_type(j)).d; + _buf(i,5) = d_ubuf(_mask(j)).d; + _buf(i,6) = _sp(j,0); + _buf(i,7) = _sp(j,1); + _buf(i,8) = _sp(j,2); + _buf(i,9) = _sp(j,3); + } + } +}; + +/* ---------------------------------------------------------------------- */ + +int AtomVecSpinKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DAT::tdual_xfloat_2d buf,int iswap, + int pbc_flag, int *pbc, ExecutionSpace space) +{ + X_FLOAT dx,dy,dz; + + if (pbc_flag != 0) { + if (domain->triclinic == 0) { + dx = pbc[0]*domain->xprd; + dy = pbc[1]*domain->yprd; + dz = pbc[2]*domain->zprd; + } else { + dx = pbc[0]; + dy = pbc[1]; + dz = pbc[2]; + } + if(space==Host) { + AtomVecSpinKokkos_PackBorder f( + buf.view(), k_sendlist.view(), + iswap,h_x,h_tag,h_type,h_mask,h_sp,dx,dy,dz); + Kokkos::parallel_for(n,f); + } else { + AtomVecSpinKokkos_PackBorder f( + buf.view(), k_sendlist.view(), + iswap,d_x,d_tag,d_type,d_mask,d_sp,dx,dy,dz); + Kokkos::parallel_for(n,f); + } + + } else { + dx = dy = dz = 0; + if(space==Host) { + AtomVecSpinKokkos_PackBorder f( + buf.view(), k_sendlist.view(), + iswap,h_x,h_tag,h_type,h_mask,h_sp,dx,dy,dz); + Kokkos::parallel_for(n,f); + } else { + AtomVecSpinKokkos_PackBorder f( + buf.view(), k_sendlist.view(), + iswap,d_x,d_tag,d_type,d_mask,d_sp,dx,dy,dz); + Kokkos::parallel_for(n,f); + } + } + return n*size_border; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecSpinKokkos::pack_border(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m; + double dx,dy,dz; + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = h_x(j,0); + buf[m++] = h_x(j,1); + buf[m++] = h_x(j,2); + buf[m++] = ubuf(h_tag(j)).d; + buf[m++] = ubuf(h_type(j)).d; + buf[m++] = ubuf(h_mask(j)).d; + buf[m++] = h_sp(j,0); + buf[m++] = h_sp(j,1); + buf[m++] = h_sp(j,2); + buf[m++] = h_sp(j,3); + } + } else { + if (domain->triclinic == 0) { + dx = pbc[0]*domain->xprd; + dy = pbc[1]*domain->yprd; + dz = pbc[2]*domain->zprd; + } else { + dx = pbc[0]; + dy = pbc[1]; + dz = pbc[2]; + } + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = h_x(j,0) + dx; + buf[m++] = h_x(j,1) + dy; + buf[m++] = h_x(j,2) + dz; + buf[m++] = ubuf(h_tag(j)).d; + buf[m++] = ubuf(h_type(j)).d; + buf[m++] = ubuf(h_mask(j)).d; + buf[m++] = h_sp(j,0); + buf[m++] = h_sp(j,1); + buf[m++] = h_sp(j,2); + buf[m++] = h_sp(j,3); + } + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); + + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecSpinKokkos::pack_border_vel(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m; + double dx,dy,dz,dvx,dvy,dvz; + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = h_x(j,0); + buf[m++] = h_x(j,1); + buf[m++] = h_x(j,2); + buf[m++] = ubuf(h_tag(j)).d; + buf[m++] = ubuf(h_type(j)).d; + buf[m++] = ubuf(h_mask(j)).d; + buf[m++] = h_sp(j,0); + buf[m++] = h_sp(j,1); + buf[m++] = h_sp(j,2); + buf[m++] = h_sp(j,3); + buf[m++] = h_v(j,0); + buf[m++] = h_v(j,1); + buf[m++] = h_v(j,2); + } + } else { + if (domain->triclinic == 0) { + dx = pbc[0]*domain->xprd; + dy = pbc[1]*domain->yprd; + dz = pbc[2]*domain->zprd; + } else { + dx = pbc[0]; + dy = pbc[1]; + dz = pbc[2]; + } + if (!deform_vremap) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = h_x(j,0) + dx; + buf[m++] = h_x(j,1) + dy; + buf[m++] = h_x(j,2) + dz; + buf[m++] = ubuf(h_tag(j)).d; + buf[m++] = ubuf(h_type(j)).d; + buf[m++] = ubuf(h_mask(j)).d; + buf[m++] = h_sp(j,0); + buf[m++] = h_sp(j,1); + buf[m++] = h_sp(j,2); + buf[m++] = h_sp(j,3); + buf[m++] = h_v(j,0); + buf[m++] = h_v(j,1); + buf[m++] = h_v(j,2); + } + } else { + dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; + dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; + dvz = pbc[2]*h_rate[2]; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = h_x(j,0) + dx; + buf[m++] = h_x(j,1) + dy; + buf[m++] = h_x(j,2) + dz; + buf[m++] = ubuf(h_tag(j)).d; + buf[m++] = ubuf(h_type(j)).d; + buf[m++] = ubuf(h_mask(j)).d; + buf[m++] = h_sp(j,0); + buf[m++] = h_sp(j,1); + buf[m++] = h_sp(j,2); + buf[m++] = h_sp(j,3); + if (mask[i] & deform_groupbit) { + buf[m++] = h_v(j,0) + dvx; + buf[m++] = h_v(j,1) + dvy; + buf[m++] = h_v(j,2) + dvz; + } else { + buf[m++] = h_v(j,0); + buf[m++] = h_v(j,1); + buf[m++] = h_v(j,2); + } + } + } + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); + + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecSpinKokkos::pack_border_hybrid(int n, int *list, double *buf) +{ + int i,j,m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = h_sp(j,0); + buf[m++] = h_sp(j,1); + buf[m++] = h_sp(j,2); + buf[m++] = h_sp(j,3); + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +template +struct AtomVecSpinKokkos_UnpackBorder { + typedef DeviceType device_type; + + const typename ArrayTypes::t_xfloat_2d_const _buf; + typename ArrayTypes::t_x_array _x; + typename ArrayTypes::t_tagint_1d _tag; + typename ArrayTypes::t_int_1d _type; + typename ArrayTypes::t_int_1d _mask; + typename ArrayTypes::t_sp_array _sp; + int _first; + + + AtomVecSpinKokkos_UnpackBorder( + const typename ArrayTypes::t_xfloat_2d_const &buf, + typename ArrayTypes::t_x_array &x, + typename ArrayTypes::t_tagint_1d &tag, + typename ArrayTypes::t_int_1d &type, + typename ArrayTypes::t_int_1d &mask, + typename ArrayTypes::t_sp_array &sp, + const int& first): + _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_sp(sp),_first(first){ + }; + + KOKKOS_INLINE_FUNCTION + void operator() (const int& i) const { + _x(i+_first,0) = _buf(i,0); + _x(i+_first,1) = _buf(i,1); + _x(i+_first,2) = _buf(i,2); + _tag(i+_first) = (tagint) d_ubuf(_buf(i,3)).i; + _type(i+_first) = (int) d_ubuf(_buf(i,4)).i; + _mask(i+_first) = (int) d_ubuf(_buf(i,5)).i; + _sp(i+_first,0) = _buf(i,6); + _sp(i+_first,1) = _buf(i,7); + _sp(i+_first,2) = _buf(i,8); + _sp(i+_first,3) = _buf(i,9); + } +}; + +/* ---------------------------------------------------------------------- */ + +void AtomVecSpinKokkos::unpack_border_kokkos(const int &n, const int &first, + const DAT::tdual_xfloat_2d &buf,ExecutionSpace space) { + if (first+n >= nmax) { + grow(first+n+100); + } + if(space==Host) { + struct AtomVecSpinKokkos_UnpackBorder + f(buf.view(),h_x,h_tag,h_type,h_mask,h_sp,first); + Kokkos::parallel_for(n,f); + } else { + struct AtomVecSpinKokkos_UnpackBorder + f(buf.view(),d_x,d_tag,d_type,d_mask,d_sp,first); + Kokkos::parallel_for(n,f); + } + atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|SP_MASK); +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecSpinKokkos::unpack_border(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + + for (i = first; i < last; i++) { + if (i == nmax) { + grow(0); + } + atomKK->modified(Host,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|SP_MASK); + h_x(i,0) = buf[m++]; + h_x(i,1) = buf[m++]; + h_x(i,2) = buf[m++]; + h_tag(i) = (tagint) ubuf(buf[m++]).i; + h_type(i) = (int) ubuf(buf[m++]).i; + h_mask(i) = (int) ubuf(buf[m++]).i; + h_sp(i,0) = buf[m++]; + h_sp(i,1) = buf[m++]; + h_sp(i,2) = buf[m++]; + h_sp(i,3) = buf[m++]; + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]-> + unpack_border(n,first,&buf[m]); +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecSpinKokkos::unpack_border_vel(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + if (i == nmax) grow(0); + atomKK->modified(Host,X_MASK|V_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|SP_MASK); + h_x(i,0) = buf[m++]; + h_x(i,1) = buf[m++]; + h_x(i,2) = buf[m++]; + h_tag(i) = (tagint) ubuf(buf[m++]).i; + h_type(i) = (int) ubuf(buf[m++]).i; + h_mask(i) = (int) ubuf(buf[m++]).i; + h_sp(i,0) = buf[m++]; + h_sp(i,1) = buf[m++]; + h_sp(i,2) = buf[m++]; + h_sp(i,3) = buf[m++]; + h_v(i,0) = buf[m++]; + h_v(i,1) = buf[m++]; + h_v(i,2) = buf[m++]; + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]-> + unpack_border(n,first,&buf[m]); +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecSpinKokkos::unpack_border_hybrid(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) + h_sp(i,0) = buf[m++]; + h_sp(i,1) = buf[m++]; + h_sp(i,2) = buf[m++]; + h_sp(i,3) = buf[m++]; + return m; +} + +/* ---------------------------------------------------------------------- */ + +template +struct AtomVecSpinKokkos_PackExchangeFunctor { + typedef DeviceType device_type; + typedef ArrayTypes AT; + typename AT::t_x_array_randomread _x; + typename AT::t_v_array_randomread _v; + typename AT::t_tagint_1d_randomread _tag; + typename AT::t_int_1d_randomread _type; + typename AT::t_int_1d_randomread _mask; + typename AT::t_imageint_1d_randomread _image; + typename AT::t_sp_array_randomread _sp; + typename AT::t_x_array _xw; + typename AT::t_v_array _vw; + typename AT::t_tagint_1d _tagw; + typename AT::t_int_1d _typew; + typename AT::t_int_1d _maskw; + typename AT::t_imageint_1d _imagew; + typename AT::t_sp_array _spw; + + typename AT::t_xfloat_2d_um _buf; + typename AT::t_int_1d_const _sendlist; + typename AT::t_int_1d_const _copylist; + int _nlocal,_dim; + X_FLOAT _lo,_hi; + + AtomVecSpinKokkos_PackExchangeFunctor( + const AtomKokkos* atom, + const typename AT::tdual_xfloat_2d buf, + typename AT::tdual_int_1d sendlist, + typename AT::tdual_int_1d copylist,int nlocal, int dim, + X_FLOAT lo, X_FLOAT hi): + _x(atom->k_x.view()), + _v(atom->k_v.view()), + _tag(atom->k_tag.view()), + _type(atom->k_type.view()), + _mask(atom->k_mask.view()), + _image(atom->k_image.view()), + _sp(atom->k_sp.view()), + _xw(atom->k_x.view()), + _vw(atom->k_v.view()), + _tagw(atom->k_tag.view()), + _typew(atom->k_type.view()), + _maskw(atom->k_mask.view()), + _imagew(atom->k_image.view()), + _spw(atom->k_sp.view()), + _sendlist(sendlist.template view()), + _copylist(copylist.template view()), + _nlocal(nlocal),_dim(dim), + _lo(lo),_hi(hi){ + const size_t elements = 15; + const int maxsendlist = (buf.template view().extent(0)* + buf.template view().extent(1))/elements; + + buffer_view(_buf,buf,maxsendlist,elements); + } + + KOKKOS_INLINE_FUNCTION + void operator() (const int &mysend) const { + const int i = _sendlist(mysend); + _buf(mysend,0) = 15; + _buf(mysend,1) = _x(i,0); + _buf(mysend,2) = _x(i,1); + _buf(mysend,3) = _x(i,2); + _buf(mysend,4) = _v(i,0); + _buf(mysend,5) = _v(i,1); + _buf(mysend,6) = _v(i,2); + _buf(mysend,7) = d_ubuf(_tag[i]).d; + _buf(mysend,8) = d_ubuf(_type[i]).d; + _buf(mysend,9) = d_ubuf(_mask[i]).d; + _buf(mysend,10) = d_ubuf(_image[i]).d; + _buf(mysend,11) = _sp(i,0); + _buf(mysend,12) = _sp(i,1); + _buf(mysend,13) = _sp(i,2); + _buf(mysend,14) = _sp(i,3); + const int j = _copylist(mysend); + + if(j>-1) { + _xw(i,0) = _x(j,0); + _xw(i,1) = _x(j,1); + _xw(i,2) = _x(j,2); + _vw(i,0) = _v(j,0); + _vw(i,1) = _v(j,1); + _vw(i,2) = _v(j,2); + _tagw(i) = _tag(j); + _typew(i) = _type(j); + _maskw(i) = _mask(j); + _imagew(i) = _image(j); + _spw(i,0) = _sp(j,0); + _spw(i,1) = _sp(j,1); + _spw(i,2) = _sp(j,2); + _spw(i,3) = _sp(j,3); + } + } +}; + +/* ---------------------------------------------------------------------- */ + +int AtomVecSpinKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2d &k_buf, + DAT::tdual_int_1d k_sendlist, + DAT::tdual_int_1d k_copylist, + ExecutionSpace space,int dim, + X_FLOAT lo,X_FLOAT hi ) +{ + if(nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/15) { + int newsize = nsend*15/k_buf.view().extent(1)+1; + k_buf.resize(newsize,k_buf.view().extent(1)); + } + if(space == Host) { + AtomVecSpinKokkos_PackExchangeFunctor + f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); + Kokkos::parallel_for(nsend,f); + return nsend*15; + } else { + AtomVecSpinKokkos_PackExchangeFunctor + f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); + Kokkos::parallel_for(nsend,f); + return nsend*15; + } +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecSpinKokkos::pack_exchange(int i, double *buf) +{ + int m = 1; + buf[m++] = h_x(i,0); + buf[m++] = h_x(i,1); + buf[m++] = h_x(i,2); + buf[m++] = h_v(i,0); + buf[m++] = h_v(i,1); + buf[m++] = h_v(i,2); + buf[m++] = ubuf(h_tag(i)).d; + buf[m++] = ubuf(h_type(i)).d; + buf[m++] = ubuf(h_mask(i)).d; + buf[m++] = ubuf(h_image(i)).d; + buf[m++] = h_sp(i,0); + buf[m++] = h_sp(i,1); + buf[m++] = h_sp(i,2); + buf[m++] = h_sp(i,3); + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]); + + buf[0] = m; + return m; +} + +/* ---------------------------------------------------------------------- */ + +template +struct AtomVecSpinKokkos_UnpackExchangeFunctor { + typedef DeviceType device_type; + typedef ArrayTypes AT; + typename AT::t_x_array _x; + typename AT::t_v_array _v; + typename AT::t_tagint_1d _tag; + typename AT::t_int_1d _type; + typename AT::t_int_1d _mask; + typename AT::t_imageint_1d _image; + typename AT::t_sp_array _sp; + typename AT::t_xfloat_2d_um _buf; + typename AT::t_int_1d _nlocal; + int _dim; + X_FLOAT _lo,_hi; + + AtomVecSpinKokkos_UnpackExchangeFunctor( + const AtomKokkos* atom, + const typename AT::tdual_xfloat_2d buf, + typename AT::tdual_int_1d nlocal, + int dim, X_FLOAT lo, X_FLOAT hi): + _x(atom->k_x.view()), + _v(atom->k_v.view()), + _tag(atom->k_tag.view()), + _type(atom->k_type.view()), + _mask(atom->k_mask.view()), + _image(atom->k_image.view()), + _sp(atom->k_sp.view()), + _nlocal(nlocal.template view()),_dim(dim), + _lo(lo),_hi(hi){ + const size_t elements = 15; + const int maxsendlist = (buf.template view().extent(0)*buf.template view().extent(1))/elements; + + buffer_view(_buf,buf,maxsendlist,elements); + } + + KOKKOS_INLINE_FUNCTION + void operator() (const int &myrecv) const { + X_FLOAT x = _buf(myrecv,_dim+1); + if (x >= _lo && x < _hi) { + int i = Kokkos::atomic_fetch_add(&_nlocal(0),1); + _x(i,0) = _buf(myrecv,1); + _x(i,1) = _buf(myrecv,2); + _x(i,2) = _buf(myrecv,3); + _v(i,0) = _buf(myrecv,4); + _v(i,1) = _buf(myrecv,5); + _v(i,2) = _buf(myrecv,6); + _tag[i] = (tagint) d_ubuf(_buf(myrecv,7)).i; + _type[i] = (int) d_ubuf(_buf(myrecv,8)).i; + _mask[i] = (int) d_ubuf(_buf(myrecv,9)).i; + _image[i] = (imageint) d_ubuf(_buf(myrecv,10)).i; + _sp(i,0) = _buf(myrecv,11); + _sp(i,1) = _buf(myrecv,12); + _sp(i,2) = _buf(myrecv,13); + _sp(i,3) = _buf(myrecv,14); + } + } +}; + +/* ---------------------------------------------------------------------- */ + +int AtomVecSpinKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int nrecv, + int nlocal,int dim,X_FLOAT lo,X_FLOAT hi, + ExecutionSpace space) { + if(space == Host) { + k_count.h_view(0) = nlocal; + AtomVecSpinKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); + Kokkos::parallel_for(nrecv/15,f); + return k_count.h_view(0); + } else { + k_count.h_view(0) = nlocal; + k_count.modify(); + k_count.sync(); + AtomVecSpinKokkos_UnpackExchangeFunctor + f(atomKK,k_buf,k_count,dim,lo,hi); + Kokkos::parallel_for(nrecv/15,f); + k_count.modify(); + k_count.sync(); + + return k_count.h_view(0); + } +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecSpinKokkos::unpack_exchange(double *buf) +{ + int nlocal = atom->nlocal; + if (nlocal == nmax) grow(0); + atomKK->modified(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK | + MASK_MASK | IMAGE_MASK | SP_MASK); + + int m = 1; + h_x(nlocal,0) = buf[m++]; + h_x(nlocal,1) = buf[m++]; + h_x(nlocal,2) = buf[m++]; + h_v(nlocal,0) = buf[m++]; + h_v(nlocal,1) = buf[m++]; + h_v(nlocal,2) = buf[m++]; + h_tag(nlocal) = (tagint) ubuf(buf[m++]).i; + h_type(nlocal) = (int) ubuf(buf[m++]).i; + h_mask(nlocal) = (int) ubuf(buf[m++]).i; + h_image(nlocal) = (imageint) ubuf(buf[m++]).i; + h_sp(nlocal,0) = buf[m++]; + h_sp(nlocal,1) = buf[m++]; + h_sp(nlocal,2) = buf[m++]; + h_sp(nlocal,3) = buf[m++]; + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + m += modify->fix[atom->extra_grow[iextra]]-> + unpack_exchange(nlocal,&buf[m]); + + atom->nlocal++; + return m; +} + +/* ---------------------------------------------------------------------- + size of restart data for all atoms owned by this proc + include extra data stored by fixes +------------------------------------------------------------------------- */ + +int AtomVecSpinKokkos::size_restart() +{ + int i; + + int nlocal = atom->nlocal; + int n = 15 * nlocal; + + if (atom->nextra_restart) + for (int iextra = 0; iextra < atom->nextra_restart; iextra++) + for (i = 0; i < nlocal; i++) + n += modify->fix[atom->extra_restart[iextra]]->size_restart(i); + + return n; +} + +/* ---------------------------------------------------------------------- + pack atom I's data for restart file including extra quantities + xyz must be 1st 3 values, so that read_restart can test on them + molecular types may be negative, but write as positive +------------------------------------------------------------------------- */ + +int AtomVecSpinKokkos::pack_restart(int i, double *buf) +{ + atomKK->sync(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK | + MASK_MASK | IMAGE_MASK | SP_MASK); + + int m = 1; + buf[m++] = h_x(i,0); + buf[m++] = h_x(i,1); + buf[m++] = h_x(i,2); + buf[m++] = ubuf(h_tag(i)).d; + buf[m++] = ubuf(h_type(i)).d; + buf[m++] = ubuf(h_mask(i)).d; + buf[m++] = ubuf(h_image(i)).d; + buf[m++] = h_v(i,0); + buf[m++] = h_v(i,1); + buf[m++] = h_v(i,2); + + buf[m++] = h_sp(i,0); + buf[m++] = h_sp(i,1); + buf[m++] = h_sp(i,2); + buf[m++] = h_sp(i,3); + + if (atom->nextra_restart) + for (int iextra = 0; iextra < atom->nextra_restart; iextra++) + m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]); + + buf[0] = m; + return m; +} + +/* ---------------------------------------------------------------------- + unpack data for one atom from restart file including extra quantities +------------------------------------------------------------------------- */ + +int AtomVecSpinKokkos::unpack_restart(double *buf) +{ + int nlocal = atom->nlocal; + if (nlocal == nmax) { + grow(0); + if (atom->nextra_store) + memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra"); + } + + atomKK->modified(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK | + MASK_MASK | IMAGE_MASK | SP_MASK); + + int m = 1; + h_x(nlocal,0) = buf[m++]; + h_x(nlocal,1) = buf[m++]; + h_x(nlocal,2) = buf[m++]; + h_tag(nlocal) = (tagint) ubuf(buf[m++]).i; + h_type(nlocal) = (int) ubuf(buf[m++]).i; + h_mask(nlocal) = (int) ubuf(buf[m++]).i; + h_image(nlocal) = (imageint) ubuf(buf[m++]).i; + h_v(nlocal,0) = buf[m++]; + h_v(nlocal,1) = buf[m++]; + h_v(nlocal,2) = buf[m++]; + + h_sp(nlocal,0) = buf[m++]; + h_sp(nlocal,1) = buf[m++]; + h_sp(nlocal,2) = buf[m++]; + h_sp(nlocal,3) = buf[m++]; + + double **extra = atom->extra; + if (atom->nextra_store) { + int size = static_cast (buf[0]) - m; + for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++]; + } + + atom->nlocal++; + return m; +} + +/* ---------------------------------------------------------------------- + create one atom of itype at coord + set other values to defaults +------------------------------------------------------------------------- */ + +void AtomVecSpinKokkos::create_atom(int itype, double *coord) +{ + int nlocal = atom->nlocal; + if (nlocal == nmax) { + atomKK->modified(Host,ALL_MASK); + grow(0); + } + atomKK->sync(Host,ALL_MASK); + atomKK->modified(Host,ALL_MASK); + + h_tag[nlocal] = 0; + h_type[nlocal] = itype; + h_x(nlocal,0) = coord[0]; + h_x(nlocal,1) = coord[1]; + h_x(nlocal,2) = coord[2]; + h_mask[nlocal] = 1; + h_image[nlocal] = ((imageint) IMGMAX << IMG2BITS) | + ((imageint) IMGMAX << IMGBITS) | IMGMAX; + h_v(nlocal,0) = 0.0; + h_v(nlocal,1) = 0.0; + h_v(nlocal,2) = 0.0; + + h_sp(nlocal,0) = 0.0; + h_sp(nlocal,1) = 0.0; + h_sp(nlocal,2) = 0.0; + h_sp(nlocal,3) = 0.0; + + atom->nlocal++; +} + +/* ---------------------------------------------------------------------- + unpack one line from Atoms section of data file + initialize other atom quantities +------------------------------------------------------------------------- */ + +void AtomVecSpinKokkos::data_atom(double *coord, imageint imagetmp, + char **values) +{ + int nlocal = atom->nlocal; + if (nlocal == nmax) grow(0); + + h_tag[nlocal] = utils::inumeric(FLERR,values[0],true,lmp); + h_type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp); + if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) + error->one(FLERR,"Invalid atom type in Atoms section of data file"); + + h_sp(nlocal,3) = utils::numeric(FLERR,values[2],true,lmp); + h_sp(nlocal,0) = utils::numeric(FLERR,values[6],true,lmp); + h_sp(nlocal,1) = utils::numeric(FLERR,values[7],true,lmp); + h_sp(nlocal,2) = utils::numeric(FLERR,values[8],true,lmp); + double inorm = 1.0/sqrt(sp[nlocal][0]*sp[nlocal][0] + + sp[nlocal][1]*sp[nlocal][1] + + sp[nlocal][2]*sp[nlocal][2]); + h_sp(nlocal,0) *= inorm; + h_sp(nlocal,1) *= inorm; + h_sp(nlocal,2) *= inorm; + + h_x(nlocal,0) = coord[0]; + h_x(nlocal,1) = coord[1]; + h_x(nlocal,2) = coord[2]; + + h_image[nlocal] = imagetmp; + + h_mask[nlocal] = 1; + h_v(nlocal,0) = 0.0; + h_v(nlocal,1) = 0.0; + h_v(nlocal,2) = 0.0; + + atomKK->modified(Host,ALL_MASK); + + atom->nlocal++; +} + +/* ---------------------------------------------------------------------- + unpack hybrid quantities from one line in Atoms section of data file + initialize other atom quantities for this sub-style +------------------------------------------------------------------------- */ + +int AtomVecSpinKokkos::data_atom_hybrid(int nlocal, char **values) +{ + h_sp(nlocal,3) = utils::numeric(FLERR,values[0],true,lmp); + h_sp(nlocal,0) = utils::numeric(FLERR,values[1],true,lmp); + h_sp(nlocal,1) = utils::numeric(FLERR,values[2],true,lmp); + h_sp(nlocal,2) = utils::numeric(FLERR,values[3],true,lmp); + double inorm = 1.0/sqrt(sp[nlocal][0]*sp[nlocal][0] + + sp[nlocal][1]*sp[nlocal][1] + + sp[nlocal][2]*sp[nlocal][2]); + sp[nlocal][0] *= inorm; + sp[nlocal][1] *= inorm; + sp[nlocal][2] *= inorm; + + return 4; +} + +/* ---------------------------------------------------------------------- + pack atom info for data file including 3 image flags +------------------------------------------------------------------------- */ + +void AtomVecSpinKokkos::pack_data(double **buf) +{ + int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) { + buf[i][0] = h_tag[i]; + buf[i][1] = h_type[i]; + buf[i][2] = h_sp(i,0); + buf[i][3] = h_x(i,0); + buf[i][4] = h_x(i,1); + buf[i][5] = h_x(i,2); + buf[i][2] = h_sp(i,1); + buf[i][2] = h_sp(i,2); + buf[i][2] = h_sp(i,3); + buf[i][6] = (h_image[i] & IMGMASK) - IMGMAX; + buf[i][7] = (h_image[i] >> IMGBITS & IMGMASK) - IMGMAX; + buf[i][8] = (h_image[i] >> IMG2BITS) - IMGMAX; + } +} + +/* ---------------------------------------------------------------------- + pack hybrid atom info for data file +------------------------------------------------------------------------- */ + +int AtomVecSpinKokkos::pack_data_hybrid(int i, double *buf) +{ + buf[0] = h_sp(i,3); + buf[1] = h_sp(i,0); + buf[2] = h_sp(i,1); + buf[3] = h_sp(i,2); + return 4; +} + +/* ---------------------------------------------------------------------- + write atom info to data file including 3 image flags +------------------------------------------------------------------------- */ + +void AtomVecSpinKokkos::write_data(FILE *fp, int n, double **buf) +{ + for (int i = 0; i < n; i++) + fprintf(fp,"%d %d %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d\n", + (int) buf[i][0],(int) buf[i][1],buf[i][2],buf[i][3],buf[i][4], + buf[i][5],(int) buf[i][6],(int) buf[i][7],(int) buf[i][8]); +} + +/* ---------------------------------------------------------------------- + write hybrid atom info to data file +------------------------------------------------------------------------- */ + +int AtomVecSpinKokkos::write_data_hybrid(FILE *fp, double *buf) +{ + fprintf(fp," %-1.16e %-1.16e %-1.16e %-1.16e",buf[0],buf[1],buf[2],buf[3]); + return 4; +} + +/* ---------------------------------------------------------------------- + return # of bytes of allocated memory +------------------------------------------------------------------------- */ + +double AtomVecSpinKokkos::memory_usage() +{ + bigint bytes = 0; + + if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); + if (atom->memcheck("type")) bytes += memory->usage(type,nmax); + if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); + if (atom->memcheck("image")) bytes += memory->usage(image,nmax); + if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); + if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); + if (atom->memcheck("f")) bytes += memory->usage(f,nmax*commKK->nthreads,3); + + if (atom->memcheck("sp")) bytes += memory->usage(sp,nmax,4); + if (atom->memcheck("fm")) bytes += memory->usage(fm,nmax*comm->nthreads,3); + if (atom->memcheck("fm_long")) bytes += memory->usage(fm_long,nmax*comm->nthreads,3); + + return bytes; +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecSpinKokkos::sync(ExecutionSpace space, unsigned int mask) +{ + if (space == Device) { + if (mask & X_MASK) atomKK->k_x.sync(); + if (mask & V_MASK) atomKK->k_v.sync(); + if (mask & F_MASK) atomKK->k_f.sync(); + if (mask & TAG_MASK) atomKK->k_tag.sync(); + if (mask & TYPE_MASK) atomKK->k_type.sync(); + if (mask & MASK_MASK) atomKK->k_mask.sync(); + if (mask & IMAGE_MASK) atomKK->k_image.sync(); + if (mask & SP_MASK) atomKK->k_sp.sync(); + if (mask & FM_MASK) atomKK->k_fm.sync(); + if (mask & FML_MASK) atomKK->k_fm_long.sync(); + } else { + if (mask & X_MASK) atomKK->k_x.sync(); + if (mask & V_MASK) atomKK->k_v.sync(); + if (mask & F_MASK) atomKK->k_f.sync(); + if (mask & TAG_MASK) atomKK->k_tag.sync(); + if (mask & TYPE_MASK) atomKK->k_type.sync(); + if (mask & MASK_MASK) atomKK->k_mask.sync(); + if (mask & IMAGE_MASK) atomKK->k_image.sync(); + if (mask & SP_MASK) atomKK->k_sp.sync(); + if (mask & FM_MASK) atomKK->k_fm.sync(); + if (mask & FML_MASK) atomKK->k_fm_long.sync(); + } +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecSpinKokkos::modified(ExecutionSpace space, unsigned int mask) +{ + if (space == Device) { + if (mask & X_MASK) atomKK->k_x.modify(); + if (mask & V_MASK) atomKK->k_v.modify(); + if (mask & F_MASK) atomKK->k_f.modify(); + if (mask & TAG_MASK) atomKK->k_tag.modify(); + if (mask & TYPE_MASK) atomKK->k_type.modify(); + if (mask & MASK_MASK) atomKK->k_mask.modify(); + if (mask & IMAGE_MASK) atomKK->k_image.modify(); + if (mask & SP_MASK) atomKK->k_sp.modify(); + if (mask & FM_MASK) atomKK->k_fm.modify(); + if (mask & FML_MASK) atomKK->k_fm_long.modify(); + } else { + if (mask & X_MASK) atomKK->k_x.modify(); + if (mask & V_MASK) atomKK->k_v.modify(); + if (mask & F_MASK) atomKK->k_f.modify(); + if (mask & TAG_MASK) atomKK->k_tag.modify(); + if (mask & TYPE_MASK) atomKK->k_type.modify(); + if (mask & MASK_MASK) atomKK->k_mask.modify(); + if (mask & IMAGE_MASK) atomKK->k_image.modify(); + if (mask & SP_MASK) atomKK->k_sp.modify(); + if (mask & FM_MASK) atomKK->k_fm.modify(); + if (mask & FML_MASK) atomKK->k_fm_long.modify(); + } +} + +void AtomVecSpinKokkos::sync_overlapping_device(ExecutionSpace space, unsigned int mask) +{ + if (space == Device) { + if ((mask & X_MASK) && atomKK->k_x.need_sync()) + perform_async_copy(atomKK->k_x,space); + if ((mask & V_MASK) && atomKK->k_v.need_sync()) + perform_async_copy(atomKK->k_v,space); + if ((mask & F_MASK) && atomKK->k_f.need_sync()) + perform_async_copy(atomKK->k_f,space); + if ((mask & TAG_MASK) && atomKK->k_tag.need_sync()) + perform_async_copy(atomKK->k_tag,space); + if ((mask & TYPE_MASK) && atomKK->k_type.need_sync()) + perform_async_copy(atomKK->k_type,space); + if ((mask & MASK_MASK) && atomKK->k_mask.need_sync()) + perform_async_copy(atomKK->k_mask,space); + if ((mask & IMAGE_MASK) && atomKK->k_image.need_sync()) + perform_async_copy(atomKK->k_image,space); + if ((mask & SP_MASK) && atomKK->k_sp.need_sync()) + perform_async_copy(atomKK->k_sp,space); + if ((mask & FM_MASK) && atomKK->k_sp.need_sync()) + perform_async_copy(atomKK->k_fm,space); + if ((mask & FML_MASK) && atomKK->k_fm_long.need_sync()) + perform_async_copy(atomKK->k_fm_long,space); + } else { + if ((mask & X_MASK) && atomKK->k_x.need_sync()) + perform_async_copy(atomKK->k_x,space); + if ((mask & V_MASK) && atomKK->k_v.need_sync()) + perform_async_copy(atomKK->k_v,space); + if ((mask & F_MASK) && atomKK->k_f.need_sync()) + perform_async_copy(atomKK->k_f,space); + if ((mask & TAG_MASK) && atomKK->k_tag.need_sync()) + perform_async_copy(atomKK->k_tag,space); + if ((mask & TYPE_MASK) && atomKK->k_type.need_sync()) + perform_async_copy(atomKK->k_type,space); + if ((mask & MASK_MASK) && atomKK->k_mask.need_sync()) + perform_async_copy(atomKK->k_mask,space); + if ((mask & IMAGE_MASK) && atomKK->k_image.need_sync()) + perform_async_copy(atomKK->k_image,space); + if ((mask & SP_MASK) && atomKK->k_sp.need_sync()) + perform_async_copy(atomKK->k_sp,space); + if ((mask & FM_MASK) && atomKK->k_fm.need_sync()) + perform_async_copy(atomKK->k_fm,space); + if ((mask & FML_MASK) && atomKK->k_fm_long.need_sync()) + perform_async_copy(atomKK->k_fm_long,space); + } +} + +/* ---------------------------------------------------------------------- + clear all forces (mech and mag) +------------------------------------------------------------------------- */ + +void AtomVecSpinKokkos::force_clear(int n, size_t nbytes) +{ + memset(&f[n][0],0,3*nbytes); + memset(&fm[n][0],0,3*nbytes); + memset(&fm_long[n][0],0,3*nbytes); +} diff --git a/src/KOKKOS/atom_vec_spin_kokkos.h b/src/KOKKOS/atom_vec_spin_kokkos.h new file mode 100644 index 0000000000..bcb5ea3b45 --- /dev/null +++ b/src/KOKKOS/atom_vec_spin_kokkos.h @@ -0,0 +1,132 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef ATOM_CLASS + +AtomStyle(spin/kk,AtomVecSpinKokkos) +AtomStyle(spin/kk/device,AtomVecSpinKokkos) +AtomStyle(spin/kk/host,AtomVecSpinKokkos) + +#else + +#ifndef LMP_ATOM_VEC_SPIN_KOKKOS_H +#define LMP_ATOM_VEC_SPIN_KOKKOS_H + +#include "atom_vec_kokkos.h" +#include "kokkos_type.h" + +namespace LAMMPS_NS { + +class AtomVecSpinKokkos : public AtomVecKokkos { + public: + AtomVecSpinKokkos(class LAMMPS *); + void grow(int); + void copy(int, int, int); + int pack_border(int, int *, double *, int, int *); + int pack_border_vel(int, int *, double *, int, int *); + int pack_border_hybrid(int, int *, double *); + void unpack_border(int, int, double *); + void unpack_border_vel(int, int, double *); + int unpack_border_hybrid(int, int, double *); + int pack_exchange(int, double *); + int unpack_exchange(double *); + int size_restart(); + int pack_restart(int, double *); + int unpack_restart(double *); + void create_atom(int, double *); + void data_atom(double *, imageint, char **); + int data_atom_hybrid(int, char **); + void pack_data(double **); + int pack_data_hybrid(int, double *); + void write_data(FILE *, int, double **); + int write_data_hybrid(FILE *, double *); + double memory_usage(); + + // clear magnetic and mechanic forces + + void force_clear(int, size_t); + + void grow_pointers(); + // input lists to be checked + int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, + DAT::tdual_xfloat_2d buf,int iswap, + int pbc_flag, int *pbc, ExecutionSpace space); + void unpack_border_kokkos(const int &n, const int &nfirst, + const DAT::tdual_xfloat_2d &buf, + ExecutionSpace space); + int pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2d &buf, + DAT::tdual_int_1d k_sendlist, + DAT::tdual_int_1d k_copylist, + ExecutionSpace space, int dim, + X_FLOAT lo, X_FLOAT hi); + int unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf, int nrecv, + int nlocal, int dim, X_FLOAT lo, X_FLOAT hi, + ExecutionSpace space); + + void sync(ExecutionSpace space, unsigned int mask); + void modified(ExecutionSpace space, unsigned int mask); + void sync_overlapping_device(ExecutionSpace space, unsigned int mask); + + protected: + tagint *tag; + int *type,*mask; + imageint *image; + double **x,**v,**f; // lattice quantities + + // spin quantities + double **sp; // sp[i][0-2] direction of the spin i + // sp[i][3] atomic magnetic moment of the spin i + double **fm; // fm[i][0-2] direction of magnetic precession + double **fm_long; // storage of long-range spin prec. components + + DAT::t_tagint_1d d_tag; + HAT::t_tagint_1d h_tag; + + DAT::t_int_1d d_type, d_mask; + HAT::t_int_1d h_type, h_mask; + + DAT::t_imageint_1d d_image; + HAT::t_imageint_1d h_image; + + DAT::t_x_array d_x; + DAT::t_v_array d_v; + DAT::t_f_array d_f; + + DAT::t_sp_array d_sp; + DAT::t_fm_array d_fm; + DAT::t_fm_long_array d_fm_long; + + HAT::t_sp_array h_sp; + HAT::t_fm_array h_fm; + HAT::t_fm_long_array h_fm_long; + + DAT::tdual_int_1d k_count; +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Per-processor system is too big + +The number of owned atoms plus ghost atoms on a single +processor must fit in 32-bit integer. + +E: Invalid atom type in Atoms section of data file + +Atom types must range from 1 to specified # of types. + +*/ diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index b555cc5a03..af5adeee73 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -769,6 +769,36 @@ typedef tdual_virial_array::t_dev_um t_virial_array_um; typedef tdual_virial_array::t_dev_const_um t_virial_array_const_um; typedef tdual_virial_array::t_dev_const_randomread t_virial_array_randomread; +// Spin Types + +//3d SP_FLOAT array n*4 +#ifdef LMP_KOKKOS_NO_LEGACY +typedef Kokkos::DualView tdual_float_1d_4; +#else +typedef Kokkos::DualView tdual_float_1d_4; +#endif +typedef tdual_float_1d_4::t_dev t_sp_array; +typedef tdual_float_1d_4::t_dev_const t_sp_array_const; +typedef tdual_float_1d_4::t_dev_um t_sp_array_um; +typedef tdual_float_1d_4::t_dev_const_um t_sp_array_const_um; +typedef tdual_float_1d_4::t_dev_const_randomread t_sp_array_randomread; + +//3d FM_FLOAT array n*3 + +typedef tdual_f_array::t_dev t_fm_array; +typedef tdual_f_array::t_dev_const t_fm_array_const; +typedef tdual_f_array::t_dev_um t_fm_array_um; +typedef tdual_f_array::t_dev_const_um t_fm_array_const_um; +typedef tdual_f_array::t_dev_const_randomread t_fm_array_randomread; + +//3d FML_FLOAT array n*3 + +typedef tdual_f_array::t_dev t_fm_long_array; +typedef tdual_f_array::t_dev_const t_fm_long_array_const; +typedef tdual_f_array::t_dev_um t_fm_long_array_um; +typedef tdual_f_array::t_dev_const_um t_fm_long_array_const_um; +typedef tdual_f_array::t_dev_const_randomread t_fm_long_array_randomread; + //Energy Types //1d E_FLOAT array n @@ -1005,6 +1035,28 @@ typedef tdual_virial_array::t_host_um t_virial_array_um; typedef tdual_virial_array::t_host_const_um t_virial_array_const_um; typedef tdual_virial_array::t_host_const_randomread t_virial_array_randomread; +// Spin types + +//2d X_FLOAT array n*4 +typedef tdual_float_1d_4::t_host t_sp_array; +typedef tdual_float_1d_4::t_host_const t_sp_array_const; +typedef tdual_float_1d_4::t_host_um t_sp_array_um; +typedef tdual_float_1d_4::t_host_const_um t_sp_array_const_um; +typedef tdual_float_1d_4::t_host_const_randomread t_sp_array_randomread; + +//2d F_FLOAT array n*3 +typedef tdual_f_array::t_host t_fm_array; +typedef tdual_f_array::t_host_const t_fm_array_const; +typedef tdual_f_array::t_host_um t_fm_array_um; +typedef tdual_f_array::t_host_const_um t_fm_array_const_um; +typedef tdual_f_array::t_host_const_randomread t_fm_array_randomread; + +//2d F_FLOAT array n*3 +typedef tdual_f_array::t_host t_fm_long_array; +typedef tdual_f_array::t_host_const t_fm_long_array_const; +typedef tdual_f_array::t_host_um t_fm_long_array_um; +typedef tdual_f_array::t_host_const_um t_fm_long_array_const_um; +typedef tdual_f_array::t_host_const_randomread t_fm_long_array_randomread; //Energy Types diff --git a/src/KOKKOS/verlet_kokkos.cpp b/src/KOKKOS/verlet_kokkos.cpp index 3aa7a3575a..254e269671 100644 --- a/src/KOKKOS/verlet_kokkos.cpp +++ b/src/KOKKOS/verlet_kokkos.cpp @@ -595,6 +595,15 @@ void VerletKokkos::force_clear() atomKK->modified(Device,TORQUE_MASK); } + // reset SPIN forces + + if (extraflag) { + Kokkos::parallel_for(nall, Zero::t_fm_array>(atomKK->k_fm.view())); + atomKK->modified(Device,FM_MASK); + Kokkos::parallel_for(nall, Zero::t_fm_array>(atomKK->k_fm_long.view())); + atomKK->modified(Device,FML_MASK); + } + // neighbor includegroup flag is set // clear force only on initial nfirst particles // if either newton flag is set, also include ghosts @@ -608,6 +617,15 @@ void VerletKokkos::force_clear() atomKK->modified(Device,TORQUE_MASK); } + // reset SPIN forces + + if (extraflag) { + Kokkos::parallel_for(atomKK->nfirst, Zero::t_fm_array>(atomKK->k_fm.view())); + atomKK->modified(Device,FM_MASK); + Kokkos::parallel_for(atomKK->nfirst, Zero::t_fm_array>(atomKK->k_fm_long.view())); + atomKK->modified(Device,FML_MASK); + } + if (force->newton) { auto range = Kokkos::RangePolicy(atomKK->nlocal, atomKK->nlocal + atomKK->nghost); Kokkos::parallel_for(range, Zero::t_f_array>(atomKK->k_f.view())); @@ -617,6 +635,15 @@ void VerletKokkos::force_clear() Kokkos::parallel_for(range, Zero::t_f_array>(atomKK->k_torque.view())); atomKK->modified(Device,TORQUE_MASK); } + + // reset SPIN forces + + if (extraflag) { + Kokkos::parallel_for(range, Zero::t_fm_array>(atomKK->k_fm.view())); + atomKK->modified(Device,FM_MASK); + Kokkos::parallel_for(range, Zero::t_fm_array>(atomKK->k_fm_long.view())); + atomKK->modified(Device,FML_MASK); + } } } } diff --git a/src/MANYBODY/fix_qeq_comb.cpp b/src/MANYBODY/fix_qeq_comb.cpp index 910db90822..7c23e6c218 100644 --- a/src/MANYBODY/fix_qeq_comb.cpp +++ b/src/MANYBODY/fix_qeq_comb.cpp @@ -17,21 +17,21 @@ #include "fix_qeq_comb.h" -#include -#include -#include "pair_comb.h" -#include "pair_comb3.h" -#include "neigh_list.h" #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" #include "group.h" +#include "memory.h" +#include "neigh_list.h" #include "respa.h" #include "update.h" -#include "memory.h" -#include "error.h" +#include +#include +#include "pair_comb.h" +#include "pair_comb3.h" using namespace LAMMPS_NS; using namespace FixConst; @@ -85,9 +85,6 @@ FixQEQComb::FixQEQComb(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) qf[i] = 0.0; - comb = nullptr; - comb3 = nullptr; - comm_forward = 1; } @@ -119,8 +116,9 @@ void FixQEQComb::init() if (!atom->q_flag) error->all(FLERR,"Fix qeq/comb requires atom attribute q"); - comb = (PairComb *) force->pair_match("^comb",0); comb3 = (PairComb3 *) force->pair_match("^comb3",0); + if (!comb3) comb = (PairComb *) force->pair_match("^comb",0); + if (comb == nullptr && comb3 == nullptr) error->all(FLERR,"Must use pair_style comb or comb3 with fix qeq/comb"); @@ -204,14 +202,17 @@ void FixQEQComb::post_force(int /*vflag*/) double *q = atom->q; int *mask = atom->mask; - if (comb) { + if (comb) { inum = comb->list->inum; ilist = comb->list->ilist; - } - if (comb3) { + } else if (comb3) { inum = comb3->list->inum; ilist = comb3->list->ilist; + } else { + inum = 0; + ilist = nullptr; } + for (ii = 0; ii < inum; ii++) { i = ilist[ii]; q1[i] = q2[i] = qf[i] = 0.0; @@ -227,8 +228,9 @@ void FixQEQComb::post_force(int /*vflag*/) } comm->forward_comm_fix(this); + enegtot = 0.0; if (comb) enegtot = comb->yasu_char(qf,igroup); - if (comb3) enegtot = comb3->combqeq(qf,igroup); + else if (comb3) enegtot = comb3->combqeq(qf,igroup); enegtot /= ngroup; enegchk = enegmax = 0.0; diff --git a/src/MC/fix_charge_regulation.cpp b/src/MC/fix_charge_regulation.cpp index 34391b86fb..4e7e5ab5a0 100644 --- a/src/MC/fix_charge_regulation.cpp +++ b/src/MC/fix_charge_regulation.cpp @@ -147,7 +147,7 @@ int FixChargeRegulation::setmask() { void FixChargeRegulation::init() { - triclinic = domain->triclinic; + triclinic = domain->triclinic; int ipe = modify->find_compute("thermo_pe"); c_pe = modify->compute[ipe]; @@ -187,14 +187,7 @@ void FixChargeRegulation::init() { // neighbor list exclusion setup // turn off interactions between group all and the exclusion group - int narg = 4; - char **arg = new char*[narg];; - arg[0] = (char *) "exclude"; - arg[1] = (char *) "group"; - arg[2] = (char *) group_id.c_str(); - arg[3] = (char *) "all"; - neighbor->modify_params(narg,arg); - delete [] arg; + neighbor->modify_params(fmt::format("exclude group {} all",group_id)); } // check that no deletable atoms are in atom->firstgroup @@ -356,7 +349,7 @@ void FixChargeRegulation::forward_acid() { double energy_before = energy_stored; double factor; - double *dummyp = nullptr; + double dummyp[3]; double pos[3]; pos[0] = 0; pos[1] = 0; @@ -415,7 +408,7 @@ void FixChargeRegulation::backward_acid() { double energy_before = energy_stored; double factor; int mask_tmp; - double *dummyp = nullptr; + double dummyp[3]; double pos[3]; pos[0] = 0; pos[1] = 0; @@ -488,7 +481,7 @@ void FixChargeRegulation::forward_base() { double energy_before = energy_stored; double factor; - double *dummyp = nullptr; + double dummyp[3]; double pos[3]; pos[0] = 0; pos[1] = 0; @@ -546,7 +539,7 @@ void FixChargeRegulation::backward_base() { double energy_before = energy_stored; double factor; - double *dummyp = nullptr; + double dummyp[3]; int mask_tmp; double pos[3]; pos[0] = 0; @@ -619,7 +612,7 @@ void FixChargeRegulation::forward_ions() { double energy_before = energy_stored; double factor; - double *dummyp = nullptr; + double dummyp[3]; int m1 = -1, m2 = -1; factor = volume_rx * volume_rx * c10pI_plus * c10pI_minus / ((1 + ncation) * (1 + nanion)); @@ -654,7 +647,7 @@ void FixChargeRegulation::backward_ions() { double energy_before = energy_stored; double factor; int mask1_tmp = 0, mask2_tmp = 0; - double *dummyp = nullptr; + double dummyp[3]; int m1 = -1, m2 = -1; m1 = get_random_particle(cation_type, +1, 0, dummyp); @@ -733,7 +726,7 @@ void FixChargeRegulation::forward_ions_multival() { double energy_before = energy_stored; double factor = 1; - double *dummyp = nullptr; + double dummyp[3]; int mm[salt_charge_ratio + 1];// particle ID array for all ions to be inserted if (salt_charge[0] <= -salt_charge[1]) { @@ -787,7 +780,7 @@ void FixChargeRegulation::backward_ions_multival() { double energy_before = energy_stored; double factor = 1; - double *dummyp = nullptr; // dummy pointer + double dummyp[3]; // dummy particle int mm[salt_charge_ratio + 1]; // particle ID array for all deleted ions double qq[salt_charge_ratio + 1]; // charge array for all deleted ions int mask_tmp[salt_charge_ratio + 1]; // temporary mask array diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp index b946615b04..3ab6327404 100644 --- a/src/MC/fix_gcmc.cpp +++ b/src/MC/fix_gcmc.cpp @@ -580,14 +580,7 @@ void FixGCMC::init() // neighbor list exclusion setup // turn off interactions between group all and the exclusion group - int narg = 4; - char **arg = new char*[narg];; - arg[0] = (char *) "exclude"; - arg[1] = (char *) "group"; - arg[2] = (char *) group_id.c_str(); - arg[3] = (char *) "all"; - neighbor->modify_params(narg,arg); - delete [] arg; + neighbor->modify_params(fmt::format("exclude group {} all",group_id)); } // create a new group for temporary use with selected molecules diff --git a/src/MC/fix_widom.cpp b/src/MC/fix_widom.cpp index e898196e14..65f00811c1 100644 --- a/src/MC/fix_widom.cpp +++ b/src/MC/fix_widom.cpp @@ -342,14 +342,7 @@ void FixWidom::init() // neighbor list exclusion setup // turn off interactions between group all and the exclusion group - int narg = 4; - char **arg = new char*[narg];; - arg[0] = (char *) "exclude"; - arg[1] = (char *) "group"; - arg[2] = (char *) group_id.c_str(); - arg[3] = (char *) "all"; - neighbor->modify_params(narg,arg); - delete [] arg; + neighbor->modify_params(fmt::format("exclude group {} all",group_id)); } // create a new group for temporary use with selected molecules diff --git a/src/MESSAGE/message.h b/src/MESSAGE/message.h index f8b2d47a21..88c658e44b 100644 --- a/src/MESSAGE/message.h +++ b/src/MESSAGE/message.h @@ -20,13 +20,13 @@ CommandStyle(message,Message) #ifndef LMP_MESSAGE_H #define LMP_MESSAGE_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class Message : protected Pointers { +class Message : public Command { public: - Message(class LAMMPS *lmp) : Pointers(lmp) {}; + Message(class LAMMPS *lmp) : Command(lmp) {}; void command(int, char **); private: diff --git a/src/MESSAGE/server.h b/src/MESSAGE/server.h index 579f6ab6f1..7c93db8c64 100644 --- a/src/MESSAGE/server.h +++ b/src/MESSAGE/server.h @@ -20,13 +20,13 @@ CommandStyle(server,Server) #ifndef LMP_SERVER_H #define LMP_SERVER_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class Server : protected Pointers { +class Server : public Command { public: - Server(class LAMMPS *lmp) : Pointers(lmp) {}; + Server(class LAMMPS *lmp) : Command(lmp) {}; void command(int, char **); }; diff --git a/src/PLUGIN/plugin.cpp b/src/PLUGIN/plugin.cpp index b52e1a1959..d311b64520 100644 --- a/src/PLUGIN/plugin.cpp +++ b/src/PLUGIN/plugin.cpp @@ -41,7 +41,7 @@ namespace LAMMPS_NS /* ---------------------------------------------------------------------- */ - Plugin::Plugin(LAMMPS *lmp) : Pointers(lmp) {} + Plugin::Plugin(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ @@ -257,7 +257,7 @@ namespace LAMMPS_NS "style {} from plugin", plugin->name)); } - (*command_map)[plugin->name] = (Input::CommandCreator)plugin->creator.v3; + (*command_map)[plugin->name] = (Input::CommandCreator)plugin->creator.v1; } else { utils::logmesg(lmp,fmt::format("Loading plugin for {} styles not " diff --git a/src/PLUGIN/plugin.h b/src/PLUGIN/plugin.h index 946b08db1a..4b4bca9878 100644 --- a/src/PLUGIN/plugin.h +++ b/src/PLUGIN/plugin.h @@ -21,12 +21,12 @@ CommandStyle(plugin,Plugin) #define LMP_PLUGIN_H #include "lammpsplugin.h" -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { - class Plugin : protected Pointers { + class Plugin : public Command { public: Plugin(class LAMMPS *); void command(int, char **); diff --git a/src/PYTHON/fix_python_invoke.cpp b/src/PYTHON/fix_python_invoke.cpp index 6483e21f91..82baef909b 100644 --- a/src/PYTHON/fix_python_invoke.cpp +++ b/src/PYTHON/fix_python_invoke.cpp @@ -93,7 +93,7 @@ void FixPythonInvoke::end_of_step() { PyUtils::GIL lock; - PyObject * result = PyObject_CallFunction((PyObject*)pFunc, "O", (PyObject*)lmpPtr); + PyObject * result = PyObject_CallFunction((PyObject*)pFunc, (char *)"O", (PyObject*)lmpPtr); if (!result) { PyUtils::Print_Errors(); @@ -110,8 +110,9 @@ void FixPythonInvoke::post_force(int vflag) if (update->ntimestep % nevery != 0) return; PyUtils::GIL lock; + char fmt[] = "Oi"; - PyObject * result = PyObject_CallFunction((PyObject*)pFunc, "Oi", (PyObject*)lmpPtr, vflag); + PyObject * result = PyObject_CallFunction((PyObject*)pFunc, fmt, (PyObject*)lmpPtr, vflag); if (!result) { PyUtils::Print_Errors(); diff --git a/src/PYTHON/fix_python_move.cpp b/src/PYTHON/fix_python_move.cpp index e04a32afe4..8ec2e1b74d 100644 --- a/src/PYTHON/fix_python_move.cpp +++ b/src/PYTHON/fix_python_move.cpp @@ -75,7 +75,7 @@ FixPythonMove::FixPythonMove(LAMMPS *lmp, int narg, char **arg) : } PyObject *ptr = PY_VOID_POINTER(lmp); - PyObject *py_move_obj = PyObject_CallFunction(py_move_type, "O", ptr); + PyObject *py_move_obj = PyObject_CallFunction(py_move_type, (char *)"O", ptr); Py_CLEAR(ptr); if (!py_move_obj) { @@ -112,7 +112,7 @@ int FixPythonMove::setmask() void FixPythonMove::init() { PyUtils::GIL lock; - PyObject * result = PyObject_CallMethod((PyObject *)py_move, "init", nullptr); + PyObject * result = PyObject_CallMethod((PyObject *)py_move, (char *)"init", nullptr); if (!result) { PyUtils::Print_Errors(); @@ -126,7 +126,7 @@ void FixPythonMove::init() void FixPythonMove::initial_integrate(int vflag) { PyUtils::GIL lock; - PyObject * result = PyObject_CallMethod((PyObject*)py_move, "initial_integrate", "i", vflag); + PyObject * result = PyObject_CallMethod((PyObject*)py_move, (char *)"initial_integrate", (char *)"i", vflag); if (!result) { PyUtils::Print_Errors(); @@ -140,7 +140,7 @@ void FixPythonMove::initial_integrate(int vflag) void FixPythonMove::final_integrate() { PyUtils::GIL lock; - PyObject * result = PyObject_CallMethod((PyObject*)py_move, "final_integrate", nullptr); + PyObject * result = PyObject_CallMethod((PyObject*)py_move, (char *)"final_integrate", nullptr); if (!result) { PyUtils::Print_Errors(); @@ -154,7 +154,7 @@ void FixPythonMove::final_integrate() void FixPythonMove::initial_integrate_respa(int vflag, int ilevel, int iloop) { PyUtils::GIL lock; - PyObject * result = PyObject_CallMethod((PyObject*)py_move, "initial_integrate_respa", "iii", vflag, ilevel, iloop); + PyObject * result = PyObject_CallMethod((PyObject*)py_move, (char *)"initial_integrate_respa", (char *)"iii", vflag, ilevel, iloop); if (!result) { PyUtils::Print_Errors(); @@ -168,7 +168,7 @@ void FixPythonMove::initial_integrate_respa(int vflag, int ilevel, int iloop) void FixPythonMove::final_integrate_respa(int ilevel, int iloop) { PyUtils::GIL lock; - PyObject * result = PyObject_CallMethod((PyObject*)py_move, "final_integrate_respa", "ii", ilevel, iloop); + PyObject * result = PyObject_CallMethod((PyObject*)py_move, (char *)"final_integrate_respa", (char *)"ii", ilevel, iloop); if (!result) { PyUtils::Print_Errors(); @@ -182,7 +182,7 @@ void FixPythonMove::final_integrate_respa(int ilevel, int iloop) void FixPythonMove::reset_dt() { PyUtils::GIL lock; - PyObject * result = PyObject_CallMethod((PyObject*)py_move, "reset_dt", nullptr); + PyObject * result = PyObject_CallMethod((PyObject*)py_move, (char *)"reset_dt", nullptr); if (!result) { PyUtils::Print_Errors(); diff --git a/src/PYTHON/pair_python.cpp b/src/PYTHON/pair_python.cpp index b147c9cb79..5020119e0d 100644 --- a/src/PYTHON/pair_python.cpp +++ b/src/PYTHON/pair_python.cpp @@ -288,7 +288,7 @@ void PairPython::coeff(int narg, char **arg) py_potential = (void *) py_pair_instance; - PyObject *py_value = PyObject_CallMethod(py_pair_instance, "check_units", "s", update->unit_style); + PyObject *py_value = PyObject_CallMethod(py_pair_instance, (char *)"check_units", (char *)"s", update->unit_style); if (!py_value) { PyUtils::Print_Errors(); error->all(FLERR,"Calling 'check_units' function failed"); @@ -306,7 +306,7 @@ void PairPython::coeff(int narg, char **arg) } else skip_types[i] = 0; const int type = i; const char * name = arg[2+i]; - py_value = PyObject_CallMethod(py_pair_instance, "map_coeff", "si", name, type); + py_value = PyObject_CallMethod(py_pair_instance, (char *)"map_coeff", (char *)"si", name, type); if (!py_value) { PyUtils::Print_Errors(); error->all(FLERR,"Calling 'map_coeff' function failed"); diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index a63e008b36..e592ed2af4 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -18,16 +18,16 @@ #include "fix_qeq.h" -#include -#include #include "atom.h" #include "comm.h" -#include "neigh_list.h" -#include "update.h" +#include "error.h" #include "force.h" #include "memory.h" -#include "error.h" +#include "neigh_list.h" +#include "update.h" +#include +#include using namespace LAMMPS_NS; using namespace FixConst; @@ -386,13 +386,11 @@ int FixQEq::CG( double *b, double *x ) vector_sum( d, 1., p, beta, d, inum ); } - if (loop >= maxiter && comm->me == 0) { - char str[128]; - sprintf(str,"Fix qeq CG convergence failed (%g) after %d iterations " - "at " BIGINT_FORMAT " step",sqrt(sig_new)/b_norm,loop,update->ntimestep); - error->warning(FLERR,str); - } - + if ((comm->me == 0) && (loop >= maxiter)) + error->warning(FLERR,fmt::format("Fix qeq CG convergence failed ({}) " + "after {} iterations at step {}", + sqrt(sig_new)/b_norm,loop, + update->ntimestep)); return loop; } @@ -708,11 +706,9 @@ void FixQEq::read_file(char *file) FILE *fp; if (comm->me == 0) { fp = utils::open_potential(file,lmp,nullptr); - if (fp == nullptr) { - char str[128]; - snprintf(str,128,"Cannot open fix qeq parameter file %s",file); - error->one(FLERR,str); - } + if (fp == nullptr) + error->one(FLERR,fmt::format("Cannot open fix qeq parameter file {}: {}", + file,utils::getsyserror())); } // read each line out of file, skipping blank lines or leading '#' diff --git a/src/QEQ/fix_qeq_dynamic.cpp b/src/QEQ/fix_qeq_dynamic.cpp index b06bde223b..397393b786 100644 --- a/src/QEQ/fix_qeq_dynamic.cpp +++ b/src/QEQ/fix_qeq_dynamic.cpp @@ -17,20 +17,20 @@ #include "fix_qeq_dynamic.h" -#include - -#include #include "atom.h" #include "comm.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "update.h" +#include "error.h" #include "force.h" #include "group.h" #include "kspace.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" #include "respa.h" -#include "error.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; @@ -154,14 +154,9 @@ void FixQEqDynamic::pre_force(int /*vflag*/) } } - if (comm->me == 0) { - if (iloop == maxiter) { - char str[128]; - sprintf(str,"Charges did not converge at step " BIGINT_FORMAT - ": %lg",update->ntimestep,enegchk); - error->warning(FLERR,str); - } - } + if ((comm->me == 0) && (iloop >= maxiter)) + error->warning(FLERR,fmt::format("Charges did not converge at step " + "{}: {}",update->ntimestep,enegchk)); if (force->kspace) force->kspace->qsum_qsq(); } diff --git a/src/QEQ/fix_qeq_fire.cpp b/src/QEQ/fix_qeq_fire.cpp index b33a7745e0..0bdf65dc18 100644 --- a/src/QEQ/fix_qeq_fire.cpp +++ b/src/QEQ/fix_qeq_fire.cpp @@ -17,22 +17,22 @@ #include "fix_qeq_fire.h" -#include - -#include #include "atom.h" #include "comm.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "update.h" +#include "error.h" #include "force.h" #include "group.h" +#include "kspace.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" #include "pair_comb.h" #include "pair_comb3.h" -#include "kspace.h" #include "respa.h" -#include "error.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; using namespace FixConst; @@ -47,7 +47,7 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ FixQEqFire::FixQEqFire(LAMMPS *lmp, int narg, char **arg) : - FixQEq(lmp, narg, arg) + FixQEq(lmp, narg, arg), comb(nullptr), comb3(nullptr) { qdamp = 0.20; qstep = 0.20; @@ -65,9 +65,6 @@ FixQEqFire::FixQEqFire(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else error->all(FLERR,"Illegal fix qeq/fire command"); } - - comb = nullptr; - comb3 = nullptr; } /* ---------------------------------------------------------------------- */ @@ -94,9 +91,8 @@ void FixQEqFire::init() if (utils::strmatch(update->integrate_style,"^respa")) nlevels_respa = ((Respa *) update->integrate)->nlevels; - comb = (PairComb *) force->pair_match("comb",1); - comb3 = (PairComb3 *) force->pair_match("comb3",1); - + comb3 = (PairComb3 *) force->pair_match("^comb3",0); + if (!comb3) comb = (PairComb *) force->pair_match("^comb",0); } /* ---------------------------------------------------------------------- */ @@ -218,14 +214,9 @@ void FixQEqFire::pre_force(int /*vflag*/) if (enegchk < tolerance) break; } - if (comm->me == 0) { - if (iloop == maxiter) { - char str[128]; - sprintf(str,"Charges did not converge at step " BIGINT_FORMAT - ": %lg",update->ntimestep,enegchk); - error->warning(FLERR,str); - } - } + if ((comm->me == 0) && (iloop >= maxiter)) + error->warning(FLERR,fmt::format("Charges did not converge at step " + "{}: {}",update->ntimestep,enegchk)); if (force->kspace) force->kspace->qsum_qsq(); } diff --git a/src/QEQ/fix_qeq_point.cpp b/src/QEQ/fix_qeq_point.cpp index 3d71135ae1..ac31f906e0 100644 --- a/src/QEQ/fix_qeq_point.cpp +++ b/src/QEQ/fix_qeq_point.cpp @@ -16,20 +16,22 @@ ------------------------------------------------------------------------- */ #include "fix_qeq_point.h" -#include -#include + #include "atom.h" #include "comm.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "update.h" +#include "error.h" #include "force.h" #include "group.h" #include "kspace.h" -#include "respa.h" #include "memory.h" -#include "error.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "respa.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; @@ -158,13 +160,9 @@ void FixQEqPoint::compute_H() } } - if (m_fill >= H.m) { - char str[128]; - sprintf(str,"H matrix size has been exceeded: m_fill=%d H.m=%d\n", - m_fill, H.m ); - error->warning(FLERR,str); - error->all(FLERR,"Fix qeq/point has insufficient QEq matrix size"); - } + if (m_fill >= H.m) + error->all(FLERR,fmt::format("Fix qeq/point has insufficient H matrix " + "size: m_fill={} H.m={}\n",m_fill, H.m)); } /* ---------------------------------------------------------------------- */ diff --git a/src/QEQ/fix_qeq_shielded.cpp b/src/QEQ/fix_qeq_shielded.cpp index 356a747ed3..ad6202abd8 100644 --- a/src/QEQ/fix_qeq_shielded.cpp +++ b/src/QEQ/fix_qeq_shielded.cpp @@ -16,21 +16,23 @@ ------------------------------------------------------------------------- */ #include "fix_qeq_shielded.h" -#include -#include + #include "atom.h" #include "comm.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "update.h" +#include "error.h" #include "force.h" #include "group.h" -#include "pair.h" #include "kspace.h" -#include "respa.h" #include "memory.h" -#include "error.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "pair.h" +#include "respa.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; @@ -223,13 +225,9 @@ void FixQEqShielded::compute_H() } } - if (m_fill >= H.m) { - char str[128]; - sprintf(str,"H matrix size has been exceeded: m_fill=%d H.m=%d\n", - m_fill, H.m ); - error->warning(FLERR,str); - error->all(FLERR,"Fix qeq/shielded has insufficient QEq matrix size"); - } + if (m_fill >= H.m) + error->all(FLERR,fmt::format("Fix qeq/shielded has insufficient H matrix " + "size: m_fill={} H.m={}\n",m_fill,H.m)); } /* ---------------------------------------------------------------------- */ @@ -247,7 +245,7 @@ double FixQEqShielded::calculate_H( double r, double gamma ) Taper = Taper * r + Tap[0]; denom = r * r * r + gamma; - denom = pow(denom,0.3333333333333); + denom = pow(denom,1.0/3.0); return Taper * EV_TO_KCAL_PER_MOL / denom; } diff --git a/src/QEQ/fix_qeq_slater.cpp b/src/QEQ/fix_qeq_slater.cpp index 9b90f78d7a..326d71c93b 100644 --- a/src/QEQ/fix_qeq_slater.cpp +++ b/src/QEQ/fix_qeq_slater.cpp @@ -16,22 +16,23 @@ ------------------------------------------------------------------------- */ #include "fix_qeq_slater.h" -#include -#include #include "atom.h" #include "comm.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "update.h" +#include "error.h" #include "force.h" #include "group.h" -#include "pair.h" #include "kspace.h" -#include "respa.h" #include "math_const.h" -#include "error.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "pair.h" +#include "respa.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; using namespace MathConst; @@ -207,14 +208,9 @@ void FixQEqSlater::compute_H() chizj[i] = zjtmp; } - if (m_fill >= H.m) { - char str[128]; - sprintf(str,"H matrix size has been exceeded: m_fill=%d H.m=%d\n", - m_fill, H.m ); - error->warning(FLERR,str); - error->all(FLERR,"Fix qeq/slater has insufficient QEq matrix size"); - } - + if (m_fill >= H.m) + error->all(FLERR,fmt::format(FLERR,"Fix qeq/slater has insufficient H " + "matrix size:m_fill={} H.m={}\n",m_fill,H.m)); } /* ---------------------------------------------------------------------- */ diff --git a/src/REPLICA/hyper.cpp b/src/REPLICA/hyper.cpp index 5a9cf8520e..8eb1c143e9 100644 --- a/src/REPLICA/hyper.cpp +++ b/src/REPLICA/hyper.cpp @@ -38,7 +38,7 @@ enum{NOHYPER,GLOBAL,LOCAL}; /* ---------------------------------------------------------------------- */ -Hyper::Hyper(LAMMPS *lmp) : Pointers(lmp), dumplist(nullptr) {} +Hyper::Hyper(LAMMPS *lmp) : Command(lmp), dumplist(nullptr) {} /* ---------------------------------------------------------------------- perform hyperdynamics simulation diff --git a/src/REPLICA/hyper.h b/src/REPLICA/hyper.h index 1b05172bcf..a96ccf3727 100644 --- a/src/REPLICA/hyper.h +++ b/src/REPLICA/hyper.h @@ -20,11 +20,11 @@ CommandStyle(hyper,Hyper) #ifndef LMP_HYPER_H #define LMP_HYPER_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class Hyper : protected Pointers { +class Hyper : public Command { public: Hyper(class LAMMPS *); ~Hyper() {} diff --git a/src/REPLICA/neb.cpp b/src/REPLICA/neb.cpp index a6a70fde38..7183bdd168 100644 --- a/src/REPLICA/neb.cpp +++ b/src/REPLICA/neb.cpp @@ -42,7 +42,7 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ -NEB::NEB(LAMMPS *lmp) : Pointers(lmp), all(nullptr), rdist(nullptr) {} +NEB::NEB(LAMMPS *lmp) : Command(lmp), all(nullptr), rdist(nullptr) {} /* ---------------------------------------------------------------------- internal NEB constructor, called from TAD @@ -50,7 +50,7 @@ NEB::NEB(LAMMPS *lmp) : Pointers(lmp), all(nullptr), rdist(nullptr) {} NEB::NEB(LAMMPS *lmp, double etol_in, double ftol_in, int n1steps_in, int n2steps_in, int nevery_in, double *buf_init, double *buf_final) - : Pointers(lmp), all(nullptr), rdist(nullptr) + : Command(lmp), all(nullptr), rdist(nullptr) { double delx,dely,delz; diff --git a/src/REPLICA/neb.h b/src/REPLICA/neb.h index b53992711c..8298766ccf 100644 --- a/src/REPLICA/neb.h +++ b/src/REPLICA/neb.h @@ -20,11 +20,11 @@ CommandStyle(neb,NEB) #ifndef LMP_NEB_H #define LMP_NEB_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class NEB : protected Pointers { +class NEB : public Command { public: NEB(class LAMMPS *); NEB(class LAMMPS *, double, double, int, int, int, double *, double *); diff --git a/src/REPLICA/prd.cpp b/src/REPLICA/prd.cpp index 40e5fc8833..2ba0340109 100644 --- a/src/REPLICA/prd.cpp +++ b/src/REPLICA/prd.cpp @@ -46,7 +46,7 @@ enum{SINGLE_PROC_DIRECT,SINGLE_PROC_MAP,MULTI_PROC}; /* ---------------------------------------------------------------------- */ -PRD::PRD(LAMMPS *lmp) : Pointers(lmp) {} +PRD::PRD(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- perform PRD simulation on one or more replicas diff --git a/src/REPLICA/prd.h b/src/REPLICA/prd.h index 3539987093..0d8fde1bfe 100644 --- a/src/REPLICA/prd.h +++ b/src/REPLICA/prd.h @@ -20,11 +20,11 @@ CommandStyle(prd,PRD) #ifndef LMP_PRD_H #define LMP_PRD_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class PRD : protected Pointers { +class PRD : public Command { public: PRD(class LAMMPS *); ~PRD() {} diff --git a/src/REPLICA/tad.cpp b/src/REPLICA/tad.cpp index 0bab7a31c8..a849e7a242 100644 --- a/src/REPLICA/tad.cpp +++ b/src/REPLICA/tad.cpp @@ -43,7 +43,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -TAD::TAD(LAMMPS *lmp) : Pointers(lmp) {} +TAD::TAD(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ diff --git a/src/REPLICA/tad.h b/src/REPLICA/tad.h index d44b226643..91e570c707 100644 --- a/src/REPLICA/tad.h +++ b/src/REPLICA/tad.h @@ -20,11 +20,11 @@ CommandStyle(tad,TAD) #ifndef LMP_TAD_H #define LMP_TAD_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class TAD : protected Pointers { +class TAD : public Command { public: TAD(class LAMMPS *); ~TAD(); diff --git a/src/REPLICA/temper.cpp b/src/REPLICA/temper.cpp index 63b34b9b1d..d3894060a3 100644 --- a/src/REPLICA/temper.cpp +++ b/src/REPLICA/temper.cpp @@ -40,7 +40,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -Temper::Temper(LAMMPS *lmp) : Pointers(lmp) {} +Temper::Temper(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ diff --git a/src/REPLICA/temper.h b/src/REPLICA/temper.h index 883ec30b94..3f7d813f2a 100644 --- a/src/REPLICA/temper.h +++ b/src/REPLICA/temper.h @@ -20,11 +20,11 @@ CommandStyle(temper,Temper) #ifndef LMP_TEMPER_H #define LMP_TEMPER_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class Temper : protected Pointers { +class Temper : public Command { public: Temper(class LAMMPS *); ~Temper(); diff --git a/src/SPIN/fix_nve_spin.cpp b/src/SPIN/fix_nve_spin.cpp index 30a18fb301..eb6d918ab0 100644 --- a/src/SPIN/fix_nve_spin.cpp +++ b/src/SPIN/fix_nve_spin.cpp @@ -507,11 +507,23 @@ void FixNVESpin::sectoring() { int sec[3]; double sublo[3],subhi[3]; - double* sublotmp = domain->sublo; - double* subhitmp = domain->subhi; - for (int dim = 0 ; dim < 3 ; dim++) { - sublo[dim]=sublotmp[dim]; - subhi[dim]=subhitmp[dim]; + + if (domain->triclinic == 1){ + double* sublotmp = domain->sublo_lamda; + double* subhitmp = domain->subhi_lamda; + for (int dim = 0 ; dim < 3 ; dim++) { + sublo[dim]=sublotmp[dim]*domain->boxhi[dim]; + subhi[dim]=subhitmp[dim]*domain->boxhi[dim]; + } + } + + else { + double* sublotmp = domain->sublo; + double* subhitmp = domain->subhi; + for (int dim = 0 ; dim < 3 ; dim++) { + sublo[dim]=sublotmp[dim]; + subhi[dim]=subhitmp[dim]; + } } const double rsx = subhi[0] - sublo[0]; diff --git a/src/SPIN/neb_spin.cpp b/src/SPIN/neb_spin.cpp index cbb495db8e..88a0ffc402 100644 --- a/src/SPIN/neb_spin.cpp +++ b/src/SPIN/neb_spin.cpp @@ -67,7 +67,7 @@ static const char cite_neb_spin[] = /* ---------------------------------------------------------------------- */ -NEBSpin::NEBSpin(LAMMPS *lmp) : Pointers(lmp) { +NEBSpin::NEBSpin(LAMMPS *lmp) : Command(lmp) { if (lmp->citeme) lmp->citeme->add(cite_neb_spin); } diff --git a/src/SPIN/neb_spin.h b/src/SPIN/neb_spin.h index 568eca0957..54d85093a5 100644 --- a/src/SPIN/neb_spin.h +++ b/src/SPIN/neb_spin.h @@ -20,11 +20,11 @@ CommandStyle(neb/spin,NEBSpin) #ifndef LMP_NEB_SPIN_H #define LMP_NEB_SPIN_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class NEBSpin : protected Pointers { +class NEBSpin : public Command { public: NEBSpin(class LAMMPS *); ~NEBSpin(); diff --git a/src/SPIN/pair_spin_exchange_biquadratic.cpp b/src/SPIN/pair_spin_exchange_biquadratic.cpp index 352949e5c3..a00d1cc8b0 100644 --- a/src/SPIN/pair_spin_exchange_biquadratic.cpp +++ b/src/SPIN/pair_spin_exchange_biquadratic.cpp @@ -393,7 +393,7 @@ void PairSpinExchangeBiquadratic::compute_exchange(int i, int j, double rsq, jtype = type[j]; r2j = rsq/J3[itype][jtype]/J3[itype][jtype]; - r2k = rsq/J3[itype][jtype]/J3[itype][jtype]; + r2k = rsq/K3[itype][jtype]/K3[itype][jtype]; Jex = 4.0*J1_mag[itype][jtype]*r2j; Jex *= (1.0-J2[itype][jtype]*r2j); diff --git a/src/USER-COLVARS/group_ndx.h b/src/USER-COLVARS/group_ndx.h index fa15f0e82e..58b210937a 100644 --- a/src/USER-COLVARS/group_ndx.h +++ b/src/USER-COLVARS/group_ndx.h @@ -22,13 +22,13 @@ CommandStyle(group2ndx,Group2Ndx) #ifndef LMP_GROUP_NDX_H #define LMP_GROUP_NDX_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class Group2Ndx : protected Pointers { +class Group2Ndx : public Command { public: - Group2Ndx(class LAMMPS *lmp) : Pointers(lmp) {}; + Group2Ndx(class LAMMPS *lmp) : Command(lmp) {}; void command(int, char **); private: void write_group(FILE *, int); diff --git a/src/USER-COLVARS/ndx_group.h b/src/USER-COLVARS/ndx_group.h index ceca1f9570..91b2e471ba 100644 --- a/src/USER-COLVARS/ndx_group.h +++ b/src/USER-COLVARS/ndx_group.h @@ -22,15 +22,16 @@ CommandStyle(ndx2group,Ndx2Group) #ifndef LMP_NDX_GROUP_H #define LMP_NDX_GROUP_H -#include "pointers.h" +#include "command.h" #include namespace LAMMPS_NS { -class Ndx2Group : protected Pointers { +class Ndx2Group : public Command { public: - Ndx2Group(class LAMMPS *lmp) : Pointers(lmp) {}; + Ndx2Group(class LAMMPS *lmp) : Command(lmp) {}; void command(int, char **); + private: void create(const std::string &, const std::vector &); }; diff --git a/src/USER-MISC/fix_srp.cpp b/src/USER-MISC/fix_srp.cpp index eb57da30e9..51047dfaa6 100644 --- a/src/USER-MISC/fix_srp.cpp +++ b/src/USER-MISC/fix_srp.cpp @@ -128,20 +128,10 @@ void FixSRP::init() // bond particles do not interact with other types // type bptype only interacts with itself - char* arg1[4]; - arg1[0] = (char *) "exclude"; - arg1[1] = (char *) "type"; - char c0[20]; - char c1[20]; - for (int z = 1; z < atom->ntypes; z++) { if (z == bptype) continue; - sprintf(c0, "%d", z); - arg1[2] = c0; - sprintf(c1, "%d", bptype); - arg1[3] = c1; - neighbor->modify_params(4, arg1); + neighbor->modify_params(fmt::format("exclude type {} {}",z,bptype)); } } diff --git a/src/USER-MISC/temper_grem.cpp b/src/USER-MISC/temper_grem.cpp index 3b987aaad2..ee60ab375d 100644 --- a/src/USER-MISC/temper_grem.cpp +++ b/src/USER-MISC/temper_grem.cpp @@ -40,7 +40,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -TemperGrem::TemperGrem(LAMMPS *lmp) : Pointers(lmp) {} +TemperGrem::TemperGrem(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ diff --git a/src/USER-MISC/temper_grem.h b/src/USER-MISC/temper_grem.h index f379814c61..3c1891f22d 100644 --- a/src/USER-MISC/temper_grem.h +++ b/src/USER-MISC/temper_grem.h @@ -20,11 +20,11 @@ CommandStyle(temper/grem,TemperGrem) #ifndef LMP_TEMPER_GREM_H #define LMP_TEMPER_GREM_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class TemperGrem : protected Pointers { +class TemperGrem : public Command { public: TemperGrem(class LAMMPS *); ~TemperGrem(); diff --git a/src/USER-MISC/temper_npt.cpp b/src/USER-MISC/temper_npt.cpp index 08fa2246c3..1ed55a9cf3 100644 --- a/src/USER-MISC/temper_npt.cpp +++ b/src/USER-MISC/temper_npt.cpp @@ -42,7 +42,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -TemperNPT::TemperNPT(LAMMPS *lmp) : Pointers(lmp) {} +TemperNPT::TemperNPT(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ diff --git a/src/USER-MISC/temper_npt.h b/src/USER-MISC/temper_npt.h index 6beae68c6a..a0eb1c1e9b 100644 --- a/src/USER-MISC/temper_npt.h +++ b/src/USER-MISC/temper_npt.h @@ -21,11 +21,11 @@ CommandStyle(temper/npt,TemperNPT) #ifndef LMP_TEMPERNPT_H #define LMP_TEMPERNPT_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class TemperNPT : protected Pointers { +class TemperNPT : public Command { public: TemperNPT(class LAMMPS *); ~TemperNPT(); diff --git a/src/USER-PACE/README b/src/USER-PACE/README index 3d85c806e9..c701a615f7 100644 --- a/src/USER-PACE/README +++ b/src/USER-PACE/README @@ -1,23 +1,23 @@ -The USER-PACE package provides the pace pair style, -an efficient implementation of the Atomic Cluster Expansion +The USER-PACE package provides the pace pair style, +an efficient implementation of the Atomic Cluster Expansion potential (ACE). -ACE is a methodology for deriving a highly accurate classical -potential fit to a large archive of quantum mechanical (DFT) data. +ACE is a methodology for deriving a highly accurate classical +potential fit to a large archive of quantum mechanical (DFT) data. This package was written by Yury Lysogorskiy and others -at ICAMS, the Interdisciplinary Centre for Advanced Materials Simulation, +at ICAMS, the Interdisciplinary Centre for Advanced Materials Simulation, Ruhr University Bochum, Germany (http://www.icams.de). -This package requires a library that can be downloaded and built -in lib/pace or somewhere else, which must be done before building -LAMMPS with this package. Details of the download, build, and -install process for this package using traditional make (not CMake) +This package requires a library that can be downloaded and built +in lib/pace or somewhere else, which must be done before building +LAMMPS with this package. Details of the download, build, and +install process for this package using traditional make (not CMake) are given in the lib/pace/README file, and scripts are provided to help automate the process. Also see the LAMMPS manual for general information on building LAMMPS with external libraries using either traditional make or CMake. -More information about the USER-PACE implementation of ACE +More information about the USER-PACE implementation of ACE is available here: https://github.com/ICAMS/lammps-user-pace diff --git a/src/USER-PHONON/dynamical_matrix.cpp b/src/USER-PHONON/dynamical_matrix.cpp index 798b50fdf7..0476c734a5 100644 --- a/src/USER-PHONON/dynamical_matrix.cpp +++ b/src/USER-PHONON/dynamical_matrix.cpp @@ -32,7 +32,7 @@ enum{REGULAR,ESKM}; /* ---------------------------------------------------------------------- */ -DynamicalMatrix::DynamicalMatrix(LAMMPS *lmp) : Pointers(lmp), fp(nullptr) +DynamicalMatrix::DynamicalMatrix(LAMMPS *lmp) : Command(lmp), fp(nullptr) { external_force_clear = 1; } diff --git a/src/USER-PHONON/dynamical_matrix.h b/src/USER-PHONON/dynamical_matrix.h index 8ff11044ea..d8c3ad411b 100644 --- a/src/USER-PHONON/dynamical_matrix.h +++ b/src/USER-PHONON/dynamical_matrix.h @@ -11,62 +11,62 @@ CommandStyle(dynamical_matrix,DynamicalMatrix) #ifndef LMP_DYNAMICAL_MATRIX_H #define LMP_DYNAMICAL_MATRIX_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { - class DynamicalMatrix : protected Pointers { - public: - DynamicalMatrix(class LAMMPS *); - virtual ~DynamicalMatrix(); - void command(int, char **); - void setup(); +class DynamicalMatrix : public Command { + public: + DynamicalMatrix(class LAMMPS *); + virtual ~DynamicalMatrix(); + void command(int, char **); + void setup(); - protected: - int eflag,vflag; // flags for energy/virial computation - int external_force_clear; // clear forces locally or externally + protected: + int eflag,vflag; // flags for energy/virial computation + int external_force_clear; // clear forces locally or externally - int triclinic; // 0 if domain is orthog, 1 if triclinic - int pairflag; + int triclinic; // 0 if domain is orthog, 1 if triclinic + int pairflag; - int pair_compute_flag; // 0 if pair->compute is skipped - int kspace_compute_flag; // 0 if kspace->compute is skipped + int pair_compute_flag; // 0 if pair->compute is skipped + int kspace_compute_flag; // 0 if kspace->compute is skipped - int nvec; // local atomic dof = length of xvec + int nvec; // local atomic dof = length of xvec - void update_force(); - void force_clear(); - virtual void openfile(const char* filename); + void update_force(); + void force_clear(); + virtual void openfile(const char* filename); - private: - void options(int, char **); - void calculateMatrix(); - void dynmat_clear(double **dynmat); - void create_groupmap(); - void writeMatrix(double **dynmat); - void convert_units(const char *style); - void displace_atom(int local_idx, int direction, int magnitude); + private: + void options(int, char **); + void calculateMatrix(); + void dynmat_clear(double **dynmat); + void create_groupmap(); + void writeMatrix(double **dynmat); + void convert_units(const char *style); + void displace_atom(int local_idx, int direction, int magnitude); - double conversion; - double conv_energy; - double conv_distance; - double conv_mass; - double del; - int igroup,groupbit; - bigint gcount; // number of atoms in group - bigint dynlen; // rank of dynamical matrix - int scaleflag; - int me; - bigint *groupmap; + double conversion; + double conv_energy; + double conv_distance; + double conv_mass; + double del; + int igroup,groupbit; + bigint gcount; // number of atoms in group + bigint dynlen; // rank of dynamical matrix + int scaleflag; + int me; + bigint *groupmap; - int compressed; // 1 if dump file is written compressed, 0 no - int binaryflag; // 1 if dump file is written binary, 0 no - int file_opened; // 1 if openfile method has been called, 0 no - int file_flag; // 1 custom file name, 0 dynmat.dat + int compressed; // 1 if dump file is written compressed, 0 no + int binaryflag; // 1 if dump file is written binary, 0 no + int file_opened; // 1 if openfile method has been called, 0 no + int file_flag; // 1 custom file name, 0 dynmat.dat - FILE *fp; - }; + FILE *fp; +}; } diff --git a/src/USER-PHONON/third_order.cpp b/src/USER-PHONON/third_order.cpp index 875490d643..ebcc682d7a 100644 --- a/src/USER-PHONON/third_order.cpp +++ b/src/USER-PHONON/third_order.cpp @@ -32,7 +32,7 @@ enum{REGULAR,BALLISTICO}; /* ---------------------------------------------------------------------- */ -ThirdOrder::ThirdOrder(LAMMPS *lmp) : Pointers(lmp), fp(nullptr) +ThirdOrder::ThirdOrder(LAMMPS *lmp) : Command(lmp), fp(nullptr) { external_force_clear = 1; } diff --git a/src/USER-PHONON/third_order.h b/src/USER-PHONON/third_order.h index 83062b6b1f..56a0266937 100644 --- a/src/USER-PHONON/third_order.h +++ b/src/USER-PHONON/third_order.h @@ -12,11 +12,11 @@ CommandStyle(third_order,ThirdOrder) #ifndef LMP_THIRD_ORDER_H #define LMP_THIRD_ORDER_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { - class ThirdOrder : protected Pointers { + class ThirdOrder : public Command { public: ThirdOrder(class LAMMPS *); virtual ~ThirdOrder(); diff --git a/src/balance.cpp b/src/balance.cpp index 6294e023b3..bf037e8f8f 100644 --- a/src/balance.cpp +++ b/src/balance.cpp @@ -51,7 +51,7 @@ enum{X,Y,Z}; /* ---------------------------------------------------------------------- */ -Balance::Balance(LAMMPS *lmp) : Pointers(lmp) +Balance::Balance(LAMMPS *lmp) : Command(lmp) { MPI_Comm_rank(world,&me); MPI_Comm_size(world,&nprocs); diff --git a/src/balance.h b/src/balance.h index 424da33757..0642fe04f6 100644 --- a/src/balance.h +++ b/src/balance.h @@ -20,11 +20,11 @@ CommandStyle(balance,Balance) #ifndef LMP_BALANCE_H #define LMP_BALANCE_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class Balance : protected Pointers { +class Balance : public Command { public: class RCB *rcb; class FixStore *fixstore; // per-atom weights stored in FixStore diff --git a/src/body.cpp b/src/body.cpp index 89bb2fc1d9..2c4121b0cc 100644 --- a/src/body.cpp +++ b/src/body.cpp @@ -12,7 +12,6 @@ ------------------------------------------------------------------------- */ #include "body.h" -#include using namespace LAMMPS_NS; diff --git a/src/change_box.cpp b/src/change_box.cpp index ba99e1b6e1..4471d85132 100644 --- a/src/change_box.cpp +++ b/src/change_box.cpp @@ -35,7 +35,7 @@ enum{X=0,Y,Z,YZ,XZ,XY}; /* ---------------------------------------------------------------------- */ -ChangeBox::ChangeBox(LAMMPS *lmp) : Pointers(lmp) {} +ChangeBox::ChangeBox(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ diff --git a/src/change_box.h b/src/change_box.h index d8a057f9a6..f48edb2d9f 100644 --- a/src/change_box.h +++ b/src/change_box.h @@ -20,11 +20,11 @@ CommandStyle(change_box,ChangeBox) #ifndef LMP_CHANGE_BOX_H #define LMP_CHANGE_BOX_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class ChangeBox : protected Pointers { +class ChangeBox : public Command { public: ChangeBox(class LAMMPS *); void command(int, char **); diff --git a/src/command.h b/src/command.h new file mode 100644 index 0000000000..6abbc167ac --- /dev/null +++ b/src/command.h @@ -0,0 +1,29 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifndef LMP_COMMAND_H +#define LMP_COMMAND_H + +#include "pointers.h" + +namespace LAMMPS_NS { + +class Command : protected Pointers { + public: + Command(class LAMMPS *lmp) : Pointers(lmp) {}; + virtual void command(int, char **) = 0; +}; + +} + +#endif diff --git a/src/compute.cpp b/src/compute.cpp index 81e317076c..46bd0d0fc8 100644 --- a/src/compute.cpp +++ b/src/compute.cpp @@ -22,7 +22,6 @@ #include "modify.h" #include -#include using namespace LAMMPS_NS; diff --git a/src/compute_chunk_spread_atom.cpp b/src/compute_chunk_spread_atom.cpp index d817141064..f552454e72 100644 --- a/src/compute_chunk_spread_atom.cpp +++ b/src/compute_chunk_spread_atom.cpp @@ -23,6 +23,8 @@ #include "modify.h" #include "update.h" +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/compute_reduce.cpp b/src/compute_reduce.cpp index 30b4fcb98a..6e961df47a 100644 --- a/src/compute_reduce.cpp +++ b/src/compute_reduce.cpp @@ -25,6 +25,8 @@ #include "update.h" #include "variable.h" +#include + using namespace LAMMPS_NS; #define BIG 1.0e20 diff --git a/src/compute_temp_region.cpp b/src/compute_temp_region.cpp index 036f118a30..535a0166c5 100644 --- a/src/compute_temp_region.cpp +++ b/src/compute_temp_region.cpp @@ -13,15 +13,14 @@ #include "compute_temp_region.h" -#include #include "atom.h" -#include "update.h" -#include "force.h" #include "domain.h" -#include "region.h" +#include "error.h" +#include "force.h" #include "group.h" #include "memory.h" -#include "error.h" +#include "region.h" +#include "update.h" using namespace LAMMPS_NS; diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index 46aff081d9..7591ae7587 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -52,7 +52,7 @@ enum{NONE,RATIO,SUBSET}; /* ---------------------------------------------------------------------- */ -CreateAtoms::CreateAtoms(LAMMPS *lmp) : Pointers(lmp), basistype(nullptr) {} +CreateAtoms::CreateAtoms(LAMMPS *lmp) : Command(lmp), basistype(nullptr) {} /* ---------------------------------------------------------------------- */ diff --git a/src/create_atoms.h b/src/create_atoms.h index 5508752f00..deb155b96a 100644 --- a/src/create_atoms.h +++ b/src/create_atoms.h @@ -20,11 +20,11 @@ CommandStyle(create_atoms,CreateAtoms) #ifndef LMP_CREATE_ATOMS_H #define LMP_CREATE_ATOMS_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class CreateAtoms : protected Pointers { +class CreateAtoms : public Command { public: CreateAtoms(class LAMMPS *); void command(int, char **); diff --git a/src/create_bonds.cpp b/src/create_bonds.cpp index 494e743c05..bedbe4b436 100644 --- a/src/create_bonds.cpp +++ b/src/create_bonds.cpp @@ -38,7 +38,7 @@ enum{MANY,SBOND,SANGLE,SDIHEDRAL,SIMPROPER}; /* ---------------------------------------------------------------------- */ -CreateBonds::CreateBonds(LAMMPS *lmp) : Pointers(lmp) {} +CreateBonds::CreateBonds(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ diff --git a/src/create_bonds.h b/src/create_bonds.h index eea99b0113..d2d50c86c6 100644 --- a/src/create_bonds.h +++ b/src/create_bonds.h @@ -20,11 +20,11 @@ CommandStyle(create_bonds,CreateBonds) #ifndef LMP_CREATE_BONDS_H #define LMP_CREATE_BONDS_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class CreateBonds : protected Pointers { +class CreateBonds : public Command { public: CreateBonds(class LAMMPS *); void command(int, char **); diff --git a/src/create_box.cpp b/src/create_box.cpp index 000fb42495..1350b6f392 100644 --- a/src/create_box.cpp +++ b/src/create_box.cpp @@ -12,22 +12,24 @@ ------------------------------------------------------------------------- */ #include "create_box.h" -#include + #include "atom.h" #include "atom_vec.h" +#include "comm.h" #include "domain.h" +#include "error.h" +#include "force.h" #include "region.h" #include "region_prism.h" -#include "force.h" -#include "comm.h" #include "update.h" -#include "error.h" + +#include using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -CreateBox::CreateBox(LAMMPS *lmp) : Pointers(lmp) {} +CreateBox::CreateBox(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ diff --git a/src/create_box.h b/src/create_box.h index 740769b4de..26a2be6fe1 100644 --- a/src/create_box.h +++ b/src/create_box.h @@ -20,11 +20,11 @@ CommandStyle(create_box,CreateBox) #ifndef LMP_CREATE_BOX_H #define LMP_CREATE_BOX_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class CreateBox : protected Pointers { +class CreateBox : public Command { public: CreateBox(class LAMMPS *); void command(int, char **); diff --git a/src/delete_atoms.cpp b/src/delete_atoms.cpp index 3dbf21ae59..326201c9a2 100644 --- a/src/delete_atoms.cpp +++ b/src/delete_atoms.cpp @@ -41,7 +41,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -DeleteAtoms::DeleteAtoms(LAMMPS *lmp) : Pointers(lmp) {} +DeleteAtoms::DeleteAtoms(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ diff --git a/src/delete_atoms.h b/src/delete_atoms.h index 5eab7f6ba7..5ff1d12f65 100644 --- a/src/delete_atoms.h +++ b/src/delete_atoms.h @@ -20,12 +20,12 @@ CommandStyle(delete_atoms,DeleteAtoms) #ifndef LMP_DELETE_ATOMS_H #define LMP_DELETE_ATOMS_H -#include "pointers.h" +#include "command.h" #include namespace LAMMPS_NS { -class DeleteAtoms : protected Pointers { +class DeleteAtoms : public Command { public: DeleteAtoms(class LAMMPS *); void command(int, char **); diff --git a/src/delete_bonds.cpp b/src/delete_bonds.cpp index 5a487743e1..2bb46e7564 100644 --- a/src/delete_bonds.cpp +++ b/src/delete_bonds.cpp @@ -30,7 +30,7 @@ enum{MULTI,ATOM,BOND,ANGLE,DIHEDRAL,IMPROPER,STATS}; /* ---------------------------------------------------------------------- */ -DeleteBonds::DeleteBonds(LAMMPS *lmp) : Pointers(lmp) {} +DeleteBonds::DeleteBonds(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ diff --git a/src/delete_bonds.h b/src/delete_bonds.h index 60d76b9086..5c56a67f68 100644 --- a/src/delete_bonds.h +++ b/src/delete_bonds.h @@ -20,11 +20,11 @@ CommandStyle(delete_bonds,DeleteBonds) #ifndef LMP_DELETE_BONDS_H #define LMP_DELETE_BONDS_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class DeleteBonds : protected Pointers { +class DeleteBonds : public Command { public: DeleteBonds(class LAMMPS *); void command(int, char **); diff --git a/src/deprecated.h b/src/deprecated.h index aceb1181c1..d5997d7199 100644 --- a/src/deprecated.h +++ b/src/deprecated.h @@ -26,13 +26,13 @@ CommandStyle(kim_query,Deprecated) #ifndef LMP_DEPRECATED_H #define LMP_DEPRECATED_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class Deprecated : protected Pointers { +class Deprecated : public Command { public: - Deprecated(class LAMMPS *lmp) : Pointers(lmp) {}; + Deprecated(class LAMMPS *lmp) : Command(lmp) {}; void command(int, char **); }; diff --git a/src/displace_atoms.cpp b/src/displace_atoms.cpp index dd71e944ef..6bc3b0ab35 100644 --- a/src/displace_atoms.cpp +++ b/src/displace_atoms.cpp @@ -42,7 +42,7 @@ enum{MOVE,RAMP,RANDOM,ROTATE}; /* ---------------------------------------------------------------------- */ -DisplaceAtoms::DisplaceAtoms(LAMMPS *lmp) : Pointers(lmp) +DisplaceAtoms::DisplaceAtoms(LAMMPS *lmp) : Command(lmp) { mvec = nullptr; } diff --git a/src/displace_atoms.h b/src/displace_atoms.h index 737d55dbdd..c2c2e8306f 100644 --- a/src/displace_atoms.h +++ b/src/displace_atoms.h @@ -20,11 +20,11 @@ CommandStyle(displace_atoms,DisplaceAtoms) #ifndef LMP_DISPLACE_ATOMS_H #define LMP_DISPLACE_ATOMS_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class DisplaceAtoms : protected Pointers { +class DisplaceAtoms : public Command { public: DisplaceAtoms(class LAMMPS *); ~DisplaceAtoms(); diff --git a/src/fix.cpp b/src/fix.cpp index 32a76cc125..14c04bf4b5 100644 --- a/src/fix.cpp +++ b/src/fix.cpp @@ -21,7 +21,6 @@ #include "memory.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_controller.cpp b/src/fix_controller.cpp index 21d1ccf751..c611dee271 100644 --- a/src/fix_controller.cpp +++ b/src/fix_controller.cpp @@ -21,8 +21,6 @@ #include "update.h" #include "variable.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_enforce2d.cpp b/src/fix_enforce2d.cpp index 1284a9b78c..11e041fcf4 100644 --- a/src/fix_enforce2d.cpp +++ b/src/fix_enforce2d.cpp @@ -12,14 +12,13 @@ ------------------------------------------------------------------------- */ #include "fix_enforce2d.h" -#include + #include "atom.h" -#include "update.h" #include "domain.h" +#include "error.h" #include "modify.h" #include "respa.h" -#include "error.h" - +#include "update.h" using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_lineforce.cpp b/src/fix_lineforce.cpp index 6a77442ea4..d95aacfd93 100644 --- a/src/fix_lineforce.cpp +++ b/src/fix_lineforce.cpp @@ -19,7 +19,6 @@ #include "update.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_nph_sphere.cpp b/src/fix_nph_sphere.cpp index 20e072d5b5..1266cb2b9d 100644 --- a/src/fix_nph_sphere.cpp +++ b/src/fix_nph_sphere.cpp @@ -16,8 +16,6 @@ #include "error.h" #include "modify.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_npt_sphere.cpp b/src/fix_npt_sphere.cpp index a6dfeba425..8bbd43d4cf 100644 --- a/src/fix_npt_sphere.cpp +++ b/src/fix_npt_sphere.cpp @@ -16,8 +16,6 @@ #include "error.h" #include "modify.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_nve_limit.cpp b/src/fix_nve_limit.cpp index 58db5e25d9..58dc023991 100644 --- a/src/fix_nve_limit.cpp +++ b/src/fix_nve_limit.cpp @@ -13,16 +13,15 @@ #include "fix_nve_limit.h" -#include -#include #include "atom.h" -#include "force.h" -#include "update.h" -#include "respa.h" -#include "modify.h" #include "comm.h" #include "error.h" +#include "force.h" +#include "modify.h" +#include "respa.h" +#include "update.h" +#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_nve_noforce.cpp b/src/fix_nve_noforce.cpp index 61528a0024..e6bca3b608 100644 --- a/src/fix_nve_noforce.cpp +++ b/src/fix_nve_noforce.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "fix_nve_noforce.h" -#include + #include "atom.h" -#include "update.h" -#include "respa.h" #include "error.h" +#include "respa.h" +#include "update.h" using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_planeforce.cpp b/src/fix_planeforce.cpp index 783d26ac9e..fe6f3d6500 100644 --- a/src/fix_planeforce.cpp +++ b/src/fix_planeforce.cpp @@ -19,7 +19,6 @@ #include "update.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_store_force.cpp b/src/fix_store_force.cpp index 1541294f6c..7ebd4db75a 100644 --- a/src/fix_store_force.cpp +++ b/src/fix_store_force.cpp @@ -12,12 +12,12 @@ ------------------------------------------------------------------------- */ #include "fix_store_force.h" -#include + #include "atom.h" -#include "update.h" -#include "respa.h" -#include "memory.h" #include "error.h" +#include "memory.h" +#include "respa.h" +#include "update.h" using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_vector.cpp b/src/fix_vector.cpp index afd3778841..71a8bb3d3c 100644 --- a/src/fix_vector.cpp +++ b/src/fix_vector.cpp @@ -22,8 +22,6 @@ #include "update.h" #include "variable.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/group.cpp b/src/group.cpp index ebab78dd0f..0143008a72 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -35,7 +35,6 @@ #include #include #include -#include using namespace LAMMPS_NS; diff --git a/src/imbalance_store.cpp b/src/imbalance_store.cpp index 879b434bfd..e72ef4d50b 100644 --- a/src/imbalance_store.cpp +++ b/src/imbalance_store.cpp @@ -16,8 +16,6 @@ #include "atom.h" #include "error.h" -#include - using namespace LAMMPS_NS; /* -------------------------------------------------------------------- */ diff --git a/src/imbalance_var.cpp b/src/imbalance_var.cpp index d2a4f0d691..64f98a6a26 100644 --- a/src/imbalance_var.cpp +++ b/src/imbalance_var.cpp @@ -20,8 +20,6 @@ #include "memory.h" #include "variable.h" -#include - using namespace LAMMPS_NS; /* -------------------------------------------------------------------- */ diff --git a/src/info.cpp b/src/info.cpp index 948073bb10..f1ee327191 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -39,7 +39,6 @@ #include "pair.h" #include "pair_hybrid.h" #include "region.h" -#include "universe.h" #include "update.h" #include "variable.h" diff --git a/src/info.h b/src/info.h index d8fa23489e..386d38c39f 100644 --- a/src/info.h +++ b/src/info.h @@ -20,15 +20,15 @@ CommandStyle(info,Info) #ifndef LMP_INFO_H #define LMP_INFO_H -#include "pointers.h" +#include "command.h" #include namespace LAMMPS_NS { -class Info : protected Pointers { +class Info : public Command { public: - Info(class LAMMPS *lmp) : Pointers(lmp) {}; + Info(class LAMMPS *lmp) : Command(lmp) {}; void command(int, char **); bool is_active(const char *, const char *); diff --git a/src/input.cpp b/src/input.cpp index 9079cdd76c..d3352b380a 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -21,6 +21,7 @@ #include "comm.h" #include "comm_brick.h" #include "comm_tiled.h" +#include "command.h" #include "compute.h" #include "dihedral.h" #include "domain.h" @@ -82,7 +83,7 @@ command line flags, holds the factory of commands and creates and initializes an instance of the Variable class. To execute a command, a specific class instance, derived from -:cpp:class:`Pointers`, is created, then its ``command()`` member +:cpp:class:`Command`, is created, then its ``command()`` member function executed, and finally the class instance is deleted. \endverbatim @@ -789,7 +790,9 @@ int Input::execute_command() if (command_map->find(command) != command_map->end()) { CommandCreator &command_creator = (*command_map)[command]; - command_creator(lmp,narg,arg); + Command *cmd = command_creator(lmp); + cmd->command(narg,arg); + delete cmd; return 0; } @@ -803,10 +806,9 @@ int Input::execute_command() ------------------------------------------------------------------------- */ template -void Input::command_creator(LAMMPS *lmp, int narg, char **arg) +Command *Input::command_creator(LAMMPS *lmp) { - T cmd(lmp); - cmd.command(narg,arg); + return new T(lmp); } /* ---------------------------------------------------------------------- */ diff --git a/src/input.h b/src/input.h index 809a7a5f94..59be026640 100644 --- a/src/input.h +++ b/src/input.h @@ -19,6 +19,7 @@ #include namespace LAMMPS_NS { + class Command; class Input : protected Pointers { friend class Info; @@ -59,12 +60,12 @@ class Input : protected Pointers { FILE **infiles; // list of open input files public: - typedef void (*CommandCreator)(LAMMPS *, int, char **); + typedef Command * (*CommandCreator)(LAMMPS *); typedef std::map CommandCreatorMap; CommandCreatorMap *command_map; protected: - template static void command_creator(LAMMPS *, int, char **); + template static Command *command_creator(LAMMPS *); private: void parse(); // parse an input text line diff --git a/src/lammpsplugin.h b/src/lammpsplugin.h index 1baed9799d..e544e8bffe 100644 --- a/src/lammpsplugin.h +++ b/src/lammpsplugin.h @@ -20,7 +20,6 @@ extern "C" { typedef void *(lammpsplugin_factory1)(void *); typedef void *(lammpsplugin_factory2)(void *, int, char **); - typedef void (lammpsplugin_factory3)(void *, int, char **); typedef struct { const char *version; @@ -31,7 +30,6 @@ extern "C" { union { lammpsplugin_factory1 *v1; lammpsplugin_factory2 *v2; - lammpsplugin_factory3 *v3; } creator; void *handle; } lammpsplugin_t; diff --git a/src/library.cpp b/src/library.cpp index 300aafc293..c51006f8d8 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -31,7 +31,6 @@ #include "group.h" #include "info.h" #include "input.h" -#include "integrate.h" #include "memory.h" #include "modify.h" #include "molecule.h" diff --git a/src/math_eigen.cpp b/src/math_eigen.cpp index ab00e42ae0..10caccd0e5 100644 --- a/src/math_eigen.cpp +++ b/src/math_eigen.cpp @@ -18,7 +18,9 @@ #include "math_eigen.h" #include "math_eigen_impl.h" -#include +#include +#include +#include using std::vector; using std::array; diff --git a/src/math_special.cpp b/src/math_special.cpp index 243d5a05f3..8d48158e72 100644 --- a/src/math_special.cpp +++ b/src/math_special.cpp @@ -4,8 +4,6 @@ #include // IWYU pragma: keep #include -#include "error.h" - using namespace LAMMPS_NS; static constexpr int nmaxfactorial = 167; diff --git a/src/minimize.cpp b/src/minimize.cpp index 8e55d6e0ea..1fb0d219cd 100644 --- a/src/minimize.cpp +++ b/src/minimize.cpp @@ -25,7 +25,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -Minimize::Minimize(LAMMPS *lmp) : Pointers(lmp) {} +Minimize::Minimize(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ diff --git a/src/minimize.h b/src/minimize.h index 42a2fcaf02..32d08c5f52 100644 --- a/src/minimize.h +++ b/src/minimize.h @@ -20,11 +20,11 @@ CommandStyle(minimize,Minimize) #ifndef LMP_MINIMIZE_H #define LMP_MINIMIZE_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class Minimize : protected Pointers { +class Minimize : public Command { public: Minimize(class LAMMPS *); void command(int, char **); diff --git a/src/my_pool_chunk.cpp b/src/my_pool_chunk.cpp index d866804adc..d824b0557b 100644 --- a/src/my_pool_chunk.cpp +++ b/src/my_pool_chunk.cpp @@ -14,7 +14,6 @@ #include "my_pool_chunk.h" #include -#include #if defined(LMP_USER_INTEL) && !defined(LAMMPS_MEMALIGN) && !defined(_WIN32) #define LAMMPS_MEMALIGN 64 diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 704d94c77c..ee4226f43e 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -2356,6 +2356,22 @@ void Neighbor::modify_params(int narg, char **arg) } } +/* ---------------------------------------------------------------------- + convenience function to allow modifying parameters from a single string +------------------------------------------------------------------------- */ + +void Neighbor::modify_params(const std::string &modcmd) +{ + auto args = utils::split_words(modcmd); + char **newarg = new char*[args.size()]; + int i=0; + for (const auto &arg : args) { + newarg[i++] = (char *)arg.c_str(); + } + modify_params(args.size(),newarg); + delete[] newarg; +} + /* ---------------------------------------------------------------------- remove the first group-group exclusion matching group1, group2 ------------------------------------------------------------------------- */ diff --git a/src/neighbor.h b/src/neighbor.h index b9b40bcf1a..0babfae9ef 100644 --- a/src/neighbor.h +++ b/src/neighbor.h @@ -118,6 +118,7 @@ class Neighbor : protected Pointers { void set(int, char **); // set neighbor style and skin distance void reset_timestep(bigint); // reset of timestep counter void modify_params(int, char**); // modify params that control builds + void modify_params(const std::string &); // convenience overload void exclusion_group_group_delete(int, int); // rm a group-group exclusion int exclude_setting(); // return exclude value to accelerator pkg diff --git a/src/npair_full_bin_atomonly.cpp b/src/npair_full_bin_atomonly.cpp index 4e05c2c17a..8ace197e30 100644 --- a/src/npair_full_bin_atomonly.cpp +++ b/src/npair_full_bin_atomonly.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_full_bin_atomonly.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_bin_atomonly_newton.cpp b/src/npair_half_bin_atomonly_newton.cpp index 2dd0bd0b96..2007bda728 100644 --- a/src/npair_half_bin_atomonly_newton.cpp +++ b/src/npair_half_bin_atomonly_newton.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_half_bin_atomonly_newton.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_bin_newtoff.cpp b/src/npair_half_size_bin_newtoff.cpp index 2d406d533c..5b9eee3672 100644 --- a/src/npair_half_size_bin_newtoff.cpp +++ b/src/npair_half_size_bin_newtoff.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_bin_newtoff.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_bin_newton.cpp b/src/npair_half_size_bin_newton.cpp index 820b293414..9cf4e744ab 100644 --- a/src/npair_half_size_bin_newton.cpp +++ b/src/npair_half_size_bin_newton.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_bin_newton.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_bin_newton_tri.cpp b/src/npair_half_size_bin_newton_tri.cpp index ea878ef440..83f903c864 100644 --- a/src/npair_half_size_bin_newton_tri.cpp +++ b/src/npair_half_size_bin_newton_tri.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_bin_newton_tri.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_multi_newtoff.cpp b/src/npair_half_size_multi_newtoff.cpp index d57542f562..f1bc93de38 100644 --- a/src/npair_half_size_multi_newtoff.cpp +++ b/src/npair_half_size_multi_newtoff.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_multi_newtoff.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_multi_newton.cpp b/src/npair_half_size_multi_newton.cpp index 01065876af..22a02899ca 100644 --- a/src/npair_half_size_multi_newton.cpp +++ b/src/npair_half_size_multi_newton.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_multi_newton.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_multi_newton_tri.cpp b/src/npair_half_size_multi_newton_tri.cpp index 361c0ba260..268ca81f3d 100644 --- a/src/npair_half_size_multi_newton_tri.cpp +++ b/src/npair_half_size_multi_newton_tri.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_multi_newton_tri.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_nsq_newtoff.cpp b/src/npair_half_size_nsq_newtoff.cpp index 38594ebcb1..79302042a6 100644 --- a/src/npair_half_size_nsq_newtoff.cpp +++ b/src/npair_half_size_nsq_newtoff.cpp @@ -12,12 +12,12 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_nsq_newtoff.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" +#include "error.h" #include "group.h" #include "my_page.h" -#include "error.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_nsq_newton.cpp b/src/npair_half_size_nsq_newton.cpp index 9010ca9a86..1ac6223afa 100644 --- a/src/npair_half_size_nsq_newton.cpp +++ b/src/npair_half_size_nsq_newton.cpp @@ -12,12 +12,12 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_nsq_newton.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" +#include "error.h" #include "group.h" #include "my_page.h" -#include "error.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_halffull_newtoff.cpp b/src/npair_halffull_newtoff.cpp index e2965b4a46..52f981e843 100644 --- a/src/npair_halffull_newtoff.cpp +++ b/src/npair_halffull_newtoff.cpp @@ -12,10 +12,10 @@ ------------------------------------------------------------------------- */ #include "npair_halffull_newtoff.h" -#include "neigh_list.h" -#include "atom_vec.h" -#include "my_page.h" + #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_halffull_newton.cpp b/src/npair_halffull_newton.cpp index 99b5493f3e..cf15af8f18 100644 --- a/src/npair_halffull_newton.cpp +++ b/src/npair_halffull_newton.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_halffull_newton.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_skip.cpp b/src/npair_skip.cpp index 45540ab2fa..6046464ecf 100644 --- a/src/npair_skip.cpp +++ b/src/npair_skip.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_skip.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_skip_respa.cpp b/src/npair_skip_respa.cpp index 3479a5d8ce..d24a30794e 100644 --- a/src/npair_skip_respa.cpp +++ b/src/npair_skip_respa.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_skip_respa.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_skip_size.cpp b/src/npair_skip_size.cpp index d3810e6acc..40b70aed21 100644 --- a/src/npair_skip_size.cpp +++ b/src/npair_skip_size.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_skip_size.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_skip_size_off2on.cpp b/src/npair_skip_size_off2on.cpp index 0d7630aaa9..994910852b 100644 --- a/src/npair_skip_size_off2on.cpp +++ b/src/npair_skip_size_off2on.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_skip_size_off2on.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_skip_size_off2on_oneside.cpp b/src/npair_skip_size_off2on_oneside.cpp index eab98de035..30ee2ff6ba 100644 --- a/src/npair_skip_size_off2on_oneside.cpp +++ b/src/npair_skip_size_off2on_oneside.cpp @@ -12,12 +12,12 @@ ------------------------------------------------------------------------- */ #include "npair_skip_size_off2on_oneside.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" #include "domain.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/output.cpp b/src/output.cpp index 988ef04409..d7be9b8cd6 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -14,18 +14,15 @@ #include "output.h" #include "style_dump.h" // IWYU pragma: keep -#include "atom.h" #include "comm.h" #include "domain.h" #include "dump.h" #include "error.h" -#include "force.h" #include "group.h" #include "info.h" #include "input.h" #include "memory.h" #include "modify.h" -#include "neighbor.h" #include "thermo.h" #include "update.h" #include "variable.h" diff --git a/src/pair_coul_cut.cpp b/src/pair_coul_cut.cpp index 428c12c2e0..629d39a9c5 100644 --- a/src/pair_coul_cut.cpp +++ b/src/pair_coul_cut.cpp @@ -260,7 +260,7 @@ void PairCoulCut::read_restart(FILE *fp) MPI_Bcast(&scale[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); if (setflag[i][j]) { - if (me == 0) + if (me == 0) utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,nullptr,error); MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); } diff --git a/src/pair_hybrid_scaled.cpp b/src/pair_hybrid_scaled.cpp index 7a30c9a3ee..de8801fe24 100644 --- a/src/pair_hybrid_scaled.cpp +++ b/src/pair_hybrid_scaled.cpp @@ -396,6 +396,9 @@ double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq, double *vals = new double[nvars]; for (i = 0; i < nvars; ++i) { j = input->variable->find(scalevars[i].c_str()); + if (j < 0) + error->all(FLERR,fmt::format("Variable '{}' not found when updating " + "scale factors",scalevars[i])); vals[i] = input->variable->compute_equal(j); } for (i = 0; i < nstyles; ++i) { @@ -457,8 +460,6 @@ void PairHybridScaled::coeff(int narg, char **arg) if (multiple[m]) { multflag = 1; if (narg < 4) error->all(FLERR,"Incorrect args for pair coefficients"); - if (!isdigit(arg[3][0])) - error->all(FLERR,"Incorrect args for pair coefficients"); int index = utils::inumeric(FLERR,arg[3],false,lmp); if (index == multiple[m]) break; else continue; diff --git a/src/pair_lj96_cut.cpp b/src/pair_lj96_cut.cpp index 65f2d40e00..92cbb47440 100644 --- a/src/pair_lj96_cut.cpp +++ b/src/pair_lj96_cut.cpp @@ -17,20 +17,19 @@ #include "pair_lj96_cut.h" -#include -#include #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "update.h" -#include "respa.h" #include "math_const.h" #include "memory.h" -#include "error.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "respa.h" +#include "update.h" +#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/pair_lj_relres.cpp b/src/pair_lj_relres.cpp index 1f40d03aa9..2131907f3a 100644 --- a/src/pair_lj_relres.cpp +++ b/src/pair_lj_relres.cpp @@ -26,7 +26,6 @@ #include "memory.h" #include -#include using namespace LAMMPS_NS; @@ -608,18 +607,18 @@ void PairLJRelRes::read_restart(FILE *fp) int me = comm->me; for (i = 1; i <= atom->ntypes; i++) for (j = i; j <= atom->ntypes; j++) { - if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); + if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,nullptr,error); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); if (setflag[i][j]) { if (me == 0) { - fread(&epsilonf[i][j],sizeof(double),1,fp); - fread(&sigmaf[i][j],sizeof(double),1,fp); - fread(&epsilon[i][j],sizeof(double),1,fp); - fread(&sigma[i][j],sizeof(double),1,fp); - fread(&cutf_inner[i][j],sizeof(double),1,fp); - fread(&cutf[i][j],sizeof(double),1,fp); - fread(&cut_inner[i][j],sizeof(double),1,fp); - fread(&cut[i][j],sizeof(double),1,fp); + utils::sfread(FLERR,&epsilonf[i][j],sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&sigmaf[i][j],sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&cutf_inner[i][j],sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&cutf[i][j],sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&cut_inner[i][j],sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,nullptr,error); } MPI_Bcast(&epsilonf[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigmaf[i][j],1,MPI_DOUBLE,0,world); @@ -655,12 +654,12 @@ void PairLJRelRes::read_restart_settings(FILE *fp) { int me = comm->me; if (me == 0) { - fread(&cutf_inner_global,sizeof(double),1,fp); - fread(&cutf_global,sizeof(double),1,fp); - fread(&cut_inner_global,sizeof(double),1,fp); - fread(&cut_global,sizeof(double),1,fp); - fread(&offset_flag,sizeof(int),1,fp); - fread(&mix_flag,sizeof(int),1,fp); + utils::sfread(FLERR,&cutf_inner_global,sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&cutf_global,sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&cut_inner_global,sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,nullptr,error); + utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,nullptr,error); } MPI_Bcast(&cutf_inner_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cutf_global,1,MPI_DOUBLE,0,world); diff --git a/src/pair_morse.cpp b/src/pair_morse.cpp index 6c67a8ef55..e6d924dab6 100644 --- a/src/pair_morse.cpp +++ b/src/pair_morse.cpp @@ -13,14 +13,15 @@ #include "pair_morse.h" -#include -#include #include "atom.h" #include "comm.h" -#include "force.h" -#include "neigh_list.h" -#include "memory.h" #include "error.h" +#include "force.h" +#include "memory.h" +#include "neigh_list.h" + +#include +#include using namespace LAMMPS_NS; diff --git a/src/potential_file_reader.cpp b/src/potential_file_reader.cpp index 2730a3d109..bddfca9bce 100644 --- a/src/potential_file_reader.cpp +++ b/src/potential_file_reader.cpp @@ -62,7 +62,8 @@ PotentialFileReader::PotentialFileReader(LAMMPS *lmp, try { reader = open_potential(filename); if (!reader) { - error->one(FLERR, fmt::format("cannot open {} potential file {}", potential_name, filename)); + error->one(FLERR, fmt::format("cannot open {} potential file {}: {}", + potential_name, filename, utils::getsyserror())); } } catch (FileReaderException &e) { error->one(FLERR, e.what()); diff --git a/src/read_data.cpp b/src/read_data.cpp index cc3b2e5965..c0085f19d1 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -11,10 +11,6 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -// lmptype.h must be first b/c this file uses MAXBIGINT and includes mpi.h -// due to OpenMPI bug which sets INT64_MAX via its mpi.h -// before lmptype.h can set flags to insure it is done correctly - #include "read_data.h" #include "angle.h" @@ -66,7 +62,7 @@ const char *suffixes[] = {"/cuda","/gpu","/opt","/omp","/kk", /* ---------------------------------------------------------------------- */ -ReadData::ReadData(LAMMPS *lmp) : Pointers(lmp) +ReadData::ReadData(LAMMPS *lmp) : Command(lmp) { MPI_Comm_rank(world,&me); line = new char[MAXLINE]; diff --git a/src/read_data.h b/src/read_data.h index 68b40fc529..7ccbeebd58 100644 --- a/src/read_data.h +++ b/src/read_data.h @@ -20,11 +20,11 @@ CommandStyle(read_data,ReadData) #ifndef LMP_READ_DATA_H #define LMP_READ_DATA_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class ReadData : protected Pointers { +class ReadData : public Command { public: ReadData(class LAMMPS *); ~ReadData(); diff --git a/src/read_dump.cpp b/src/read_dump.cpp index 0282e2d039..ddb793c629 100644 --- a/src/read_dump.cpp +++ b/src/read_dump.cpp @@ -15,10 +15,6 @@ Contributing author: Timothy Sirk (ARL) ------------------------------------------------------------------------- */ -// lmptype.h must be first b/c this file uses MAXBIGINT and includes mpi.h -// due to OpenMPI bug which sets INT64_MAX via its mpi.h -// before lmptype.h can set flags to insure it is done correctly - #include "read_dump.h" #include "atom.h" @@ -46,7 +42,7 @@ enum{NOADD,YESADD,KEEPADD}; /* ---------------------------------------------------------------------- */ -ReadDump::ReadDump(LAMMPS *lmp) : Pointers(lmp) +ReadDump::ReadDump(LAMMPS *lmp) : Command(lmp) { MPI_Comm_rank(world,&me); MPI_Comm_size(world,&nprocs); diff --git a/src/read_dump.h b/src/read_dump.h index 93fb4bc713..842b629fa4 100644 --- a/src/read_dump.h +++ b/src/read_dump.h @@ -22,11 +22,11 @@ CommandStyle(read_dump,ReadDump) #ifndef LMP_READ_DUMP_H #define LMP_READ_DUMP_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class ReadDump : protected Pointers { +class ReadDump : public Command { public: ReadDump(class LAMMPS *); ~ReadDump(); diff --git a/src/read_restart.cpp b/src/read_restart.cpp index 9e8fbce91c..2742dc5e4e 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -43,7 +43,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -ReadRestart::ReadRestart(LAMMPS *lmp) : Pointers(lmp) {} +ReadRestart::ReadRestart(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ @@ -1195,7 +1195,7 @@ void ReadRestart::check_eof_magic() if (me == 0) { long curpos = ftell(fp); fseek(fp,(long)-n,SEEK_END); - fread(str,sizeof(char),n,fp); + utils::sfread(FLERR,str,sizeof(char),n,fp,nullptr,error); fseek(fp,curpos,SEEK_SET); } diff --git a/src/read_restart.h b/src/read_restart.h index 99b37cfa45..fc2a27fa67 100644 --- a/src/read_restart.h +++ b/src/read_restart.h @@ -20,11 +20,11 @@ CommandStyle(read_restart,ReadRestart) #ifndef LMP_READ_RESTART_H #define LMP_READ_RESTART_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class ReadRestart : protected Pointers { +class ReadRestart : public Command { public: ReadRestart(class LAMMPS *); void command(int, char **); diff --git a/src/reader.cpp b/src/reader.cpp index c22a9f7e5d..ba172f58ee 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -15,8 +15,6 @@ #include "error.h" -#include - using namespace LAMMPS_NS; // only proc 0 calls methods of this class, except for constructor/destructor diff --git a/src/region_sphere.cpp b/src/region_sphere.cpp index 8921cbd456..3a5a51834b 100644 --- a/src/region_sphere.cpp +++ b/src/region_sphere.cpp @@ -19,7 +19,6 @@ #include "variable.h" #include -#include using namespace LAMMPS_NS; diff --git a/src/replicate.cpp b/src/replicate.cpp index 6877ec091c..95bf615d04 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -Replicate::Replicate(LAMMPS *lmp) : Pointers(lmp) {} +Replicate::Replicate(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ diff --git a/src/replicate.h b/src/replicate.h index 58c0010aa3..b4be578b23 100644 --- a/src/replicate.h +++ b/src/replicate.h @@ -20,11 +20,11 @@ CommandStyle(replicate,Replicate) #ifndef LMP_REPLICATE_H #define LMP_REPLICATE_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class Replicate : protected Pointers { +class Replicate : public Command { public: Replicate(class LAMMPS *); void command(int, char **); diff --git a/src/rerun.cpp b/src/rerun.cpp index 8615b02d95..9571724e2d 100644 --- a/src/rerun.cpp +++ b/src/rerun.cpp @@ -29,7 +29,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -Rerun::Rerun(LAMMPS *lmp) : Pointers(lmp) {} +Rerun::Rerun(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ diff --git a/src/rerun.h b/src/rerun.h index ea1d0221c3..c10ca8780e 100644 --- a/src/rerun.h +++ b/src/rerun.h @@ -20,11 +20,11 @@ CommandStyle(rerun,Rerun) #ifndef LMP_RERUN_H #define LMP_RERUN_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class Rerun : protected Pointers { +class Rerun : public Command { public: Rerun(class LAMMPS *); void command(int, char **); diff --git a/src/reset_atom_ids.cpp b/src/reset_atom_ids.cpp index 7298103b80..47dae3cb56 100644 --- a/src/reset_atom_ids.cpp +++ b/src/reset_atom_ids.cpp @@ -43,7 +43,7 @@ static int compare_coords(const int, const int, void *); /* ---------------------------------------------------------------------- */ -ResetIDs::ResetIDs(LAMMPS *lmp) : Pointers(lmp) {} +ResetIDs::ResetIDs(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ diff --git a/src/reset_atom_ids.h b/src/reset_atom_ids.h index 02a7f77e8d..6c262f2bd8 100644 --- a/src/reset_atom_ids.h +++ b/src/reset_atom_ids.h @@ -20,11 +20,11 @@ CommandStyle(reset_atom_ids,ResetIDs) #ifndef LMP_RESET_IDS_H #define LMP_RESET_IDS_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class ResetIDs : protected Pointers { +class ResetIDs : public Command { public: struct AtomRvous { bigint ibin; diff --git a/src/reset_mol_ids.cpp b/src/reset_mol_ids.cpp index aed26b4568..39f7307ca1 100644 --- a/src/reset_mol_ids.cpp +++ b/src/reset_mol_ids.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -ResetMolIDs::ResetMolIDs(LAMMPS *lmp) : Pointers(lmp) { +ResetMolIDs::ResetMolIDs(LAMMPS *lmp) : Command(lmp) { cfa = nullptr; cca = nullptr; diff --git a/src/reset_mol_ids.h b/src/reset_mol_ids.h index fbb6fceb03..5759cf8b4e 100644 --- a/src/reset_mol_ids.h +++ b/src/reset_mol_ids.h @@ -20,11 +20,11 @@ CommandStyle(reset_mol_ids,ResetMolIDs) #ifndef LMP_RESET_MOL_IDS_H #define LMP_RESET_MOL_IDS_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class ResetMolIDs : protected Pointers { +class ResetMolIDs : public Command { public: ResetMolIDs(class LAMMPS *); ~ResetMolIDs(); diff --git a/src/run.cpp b/src/run.cpp index c503e174ff..379cf8015a 100644 --- a/src/run.cpp +++ b/src/run.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -Run::Run(LAMMPS *lmp) : Pointers(lmp) {} +Run::Run(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ diff --git a/src/run.h b/src/run.h index 5578ea9598..747af6a61c 100644 --- a/src/run.h +++ b/src/run.h @@ -20,11 +20,11 @@ CommandStyle(run,Run) #ifndef LMP_RUN_H #define LMP_RUN_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class Run : protected Pointers { +class Run : public Command { public: Run(class LAMMPS *); void command(int, char **); diff --git a/src/set.h b/src/set.h index 29f1ea526e..330bd484a3 100644 --- a/src/set.h +++ b/src/set.h @@ -20,13 +20,13 @@ CommandStyle(set,Set) #ifndef LMP_SET_H #define LMP_SET_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class Set : protected Pointers { +class Set : public Command { public: - Set(class LAMMPS *lmp) : Pointers(lmp) {}; + Set(class LAMMPS *lmp) : Command(lmp) {}; void command(int, char **); private: diff --git a/src/text_file_reader.cpp b/src/text_file_reader.cpp index af27bfb16d..7a6e914639 100644 --- a/src/text_file_reader.cpp +++ b/src/text_file_reader.cpp @@ -46,7 +46,8 @@ TextFileReader::TextFileReader(const std::string &filename, const std::string &f fp = fopen(filename.c_str(), "r"); if (fp == nullptr) { - throw FileReaderException(fmt::format("cannot open {} file {}", filetype, filename)); + throw FileReaderException(fmt::format("cannot open {} file {}: {}", + filetype, filename, utils::getsyserror())); } } diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index d26a5199f9..ea8ff2ce43 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -19,7 +19,6 @@ #include "utils.h" #include "fmt/format.h" -#include #include using namespace LAMMPS_NS; diff --git a/src/universe.cpp b/src/universe.cpp index a7fa8fc2e2..79de6948df 100644 --- a/src/universe.cpp +++ b/src/universe.cpp @@ -15,9 +15,7 @@ #include "error.h" #include "memory.h" -#include "version.h" -#include #include using namespace LAMMPS_NS; diff --git a/src/variable.cpp b/src/variable.cpp index 1306061875..3e93a33797 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -40,7 +40,6 @@ #include #include #include -#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/velocity.cpp b/src/velocity.cpp index f4483074aa..e0c80baa91 100644 --- a/src/velocity.cpp +++ b/src/velocity.cpp @@ -42,7 +42,7 @@ enum{NONE,CONSTANT,EQUAL,ATOM}; /* ---------------------------------------------------------------------- */ -Velocity::Velocity(LAMMPS *lmp) : Pointers(lmp) {} +Velocity::Velocity(LAMMPS *lmp) : Command(lmp) {} /* ---------------------------------------------------------------------- */ diff --git a/src/velocity.h b/src/velocity.h index e14c0d0d1c..d7405f87fd 100644 --- a/src/velocity.h +++ b/src/velocity.h @@ -20,11 +20,11 @@ CommandStyle(velocity,Velocity) #ifndef LMP_VELOCITY_H #define LMP_VELOCITY_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class Velocity : protected Pointers { +class Velocity : public Command { public: Velocity(class LAMMPS *); void command(int, char **); diff --git a/src/write_coeff.cpp b/src/write_coeff.cpp index 485bc3b29b..79a99502a6 100644 --- a/src/write_coeff.cpp +++ b/src/write_coeff.cpp @@ -22,7 +22,6 @@ #include "force.h" #include "improper.h" #include "pair.h" -#include "universe.h" #include #include diff --git a/src/write_coeff.h b/src/write_coeff.h index b995e60d63..8815162c48 100644 --- a/src/write_coeff.h +++ b/src/write_coeff.h @@ -20,13 +20,13 @@ CommandStyle(write_coeff,WriteCoeff) #ifndef LMP_WRITE_COEFF_H #define LMP_WRITE_COEFF_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class WriteCoeff : protected Pointers { +class WriteCoeff : public Command { public: - WriteCoeff(class LAMMPS *lmp) : Pointers(lmp) {}; + WriteCoeff(class LAMMPS *lmp) : Command(lmp) {}; void command(int, char **); }; diff --git a/src/write_data.cpp b/src/write_data.cpp index 6d10359e8b..388fab1183 100644 --- a/src/write_data.cpp +++ b/src/write_data.cpp @@ -29,7 +29,6 @@ #include "output.h" #include "pair.h" #include "thermo.h" -#include "universe.h" #include "update.h" #include @@ -41,7 +40,7 @@ enum{ELLIPSOID,LINE,TRIANGLE,BODY}; // also in AtomVecHybrid /* ---------------------------------------------------------------------- */ -WriteData::WriteData(LAMMPS *lmp) : Pointers(lmp) +WriteData::WriteData(LAMMPS *lmp) : Command(lmp) { MPI_Comm_rank(world,&me); MPI_Comm_size(world,&nprocs); diff --git a/src/write_data.h b/src/write_data.h index a4e71c9cda..cecfaa4800 100644 --- a/src/write_data.h +++ b/src/write_data.h @@ -20,11 +20,11 @@ CommandStyle(write_data,WriteData) #ifndef LMP_WRITE_DATA_H #define LMP_WRITE_DATA_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class WriteData : protected Pointers { +class WriteData : public Command { public: WriteData(class LAMMPS *); void command(int, char **); diff --git a/src/write_dump.h b/src/write_dump.h index db39a75d4b..763fd12f60 100644 --- a/src/write_dump.h +++ b/src/write_dump.h @@ -20,13 +20,13 @@ CommandStyle(write_dump,WriteDump) #ifndef LMP_WRITE_DUMP_H #define LMP_WRITE_DUMP_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class WriteDump : protected Pointers { +class WriteDump : public Command { public: - WriteDump(class LAMMPS *lmp) : Pointers(lmp) {}; + WriteDump(class LAMMPS *lmp) : Command(lmp) {}; void command(int, char **); }; diff --git a/src/write_restart.cpp b/src/write_restart.cpp index afe1d2d528..350f083be2 100644 --- a/src/write_restart.cpp +++ b/src/write_restart.cpp @@ -32,7 +32,6 @@ #include "output.h" #include "pair.h" #include "thermo.h" -#include "universe.h" #include "update.h" #include @@ -43,7 +42,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -WriteRestart::WriteRestart(LAMMPS *lmp) : Pointers(lmp) +WriteRestart::WriteRestart(LAMMPS *lmp) : Command(lmp) { MPI_Comm_rank(world,&me); MPI_Comm_size(world,&nprocs); diff --git a/src/write_restart.h b/src/write_restart.h index a4a606482e..05f5c45ec6 100644 --- a/src/write_restart.h +++ b/src/write_restart.h @@ -20,11 +20,11 @@ CommandStyle(write_restart,WriteRestart) #ifndef LMP_WRITE_RESTART_H #define LMP_WRITE_RESTART_H -#include "pointers.h" +#include "command.h" namespace LAMMPS_NS { -class WriteRestart : protected Pointers { +class WriteRestart : public Command { public: WriteRestart(class LAMMPS *); void command(int, char **);