diff --git a/.gitignore b/.gitignore index 29648886a7..ae708ff184 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ Thumbs.db /build* /CMakeCache.txt /CMakeFiles/ +/Testing /Makefile /Testing /cmake_install.cmake diff --git a/cmake/Modules/Packages/OPENMP.cmake b/cmake/Modules/Packages/OPENMP.cmake index 922df86ef6..0a23e58b4b 100644 --- a/cmake/Modules/Packages/OPENMP.cmake +++ b/cmake/Modules/Packages/OPENMP.cmake @@ -25,15 +25,15 @@ endif() if(PKG_REAXFF) - list(APPEND OPENMP_SOURCES ${OPENMP_SOURCES_DIR}/reaxc_bond_orders_omp.cpp - ${OPENMP_SOURCES_DIR}/reaxc_hydrogen_bonds_omp.cpp - ${OPENMP_SOURCES_DIR}/reaxc_nonbonded_omp.cpp - ${OPENMP_SOURCES_DIR}/reaxc_bonds_omp.cpp - ${OPENMP_SOURCES_DIR}/reaxc_init_md_omp.cpp - ${OPENMP_SOURCES_DIR}/reaxc_torsion_angles_omp.cpp - ${OPENMP_SOURCES_DIR}/reaxc_forces_omp.cpp - ${OPENMP_SOURCES_DIR}/reaxc_multi_body_omp.cpp - ${OPENMP_SOURCES_DIR}/reaxc_valence_angles_omp.cpp) + list(APPEND OPENMP_SOURCES ${OPENMP_SOURCES_DIR}/reaxff_bond_orders_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_hydrogen_bonds_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_nonbonded_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_bonds_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_init_md_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_torsion_angles_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_forces_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_multi_body_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_valence_angles_omp.cpp) endif() target_sources(lammps PRIVATE ${OPENMP_SOURCES}) diff --git a/doc/src/Commands_fix.rst b/doc/src/Commands_fix.rst index 0ca71699a3..45a75ff394 100644 --- a/doc/src/Commands_fix.rst +++ b/doc/src/Commands_fix.rst @@ -179,14 +179,14 @@ OPT. * :doc:`qeq/dynamic ` * :doc:`qeq/fire ` * :doc:`qeq/point ` - * :doc:`qeq/reax (ko) ` + * :doc:`qeq/reaxff (ko) ` * :doc:`qeq/shielded ` * :doc:`qeq/slater ` * :doc:`qmmm ` * :doc:`qtb ` * :doc:`rattle ` - * :doc:`reax/c/bonds (k) ` - * :doc:`reax/c/species (k) ` + * :doc:`reaxff/bonds (k) ` + * :doc:`reaxff/species (k) ` * :doc:`recenter ` * :doc:`restrain ` * :doc:`rhok ` diff --git a/doc/src/Commands_pair.rst b/doc/src/Commands_pair.rst index 7abb1d582a..db3d947892 100644 --- a/doc/src/Commands_pair.rst +++ b/doc/src/Commands_pair.rst @@ -235,7 +235,7 @@ OPT. * :doc:`python ` * :doc:`quip ` * :doc:`rann ` - * :doc:`reax/c (ko) ` + * :doc:`reaxff (ko) ` * :doc:`rebo (io) ` * :doc:`resquared (go) ` * :doc:`sdpd/taitwater/isothermal ` diff --git a/doc/src/Errors_warnings.rst b/doc/src/Errors_warnings.rst index 68d6b0451a..806dec024b 100644 --- a/doc/src/Errors_warnings.rst +++ b/doc/src/Errors_warnings.rst @@ -514,7 +514,7 @@ This will most likely cause errors in kinetic fluctuations. will integrate the body motion, but it would be more efficient to use fix rigid. -*Not using real units with pair reax* +*Not using real units with pair reaxff* This is most likely an error, unless you have created your own ReaxFF parameter file in a different set of units. @@ -805,5 +805,3 @@ This will most likely cause errors in kinetic fluctuations. *Using pair tail corrections with pair_modify compute no* The tail corrections will thus not be computed. -*pair style reax is now deprecated and will soon be retired. Users should switch to pair_style reax/c* - Self-explanatory. diff --git a/doc/src/Library_utility.rst b/doc/src/Library_utility.rst index b2f3666f88..32fac6bcc8 100644 --- a/doc/src/Library_utility.rst +++ b/doc/src/Library_utility.rst @@ -8,7 +8,11 @@ functions. They do not directly call the LAMMPS library. - :cpp:func:`lammps_decode_image_flags` - :cpp:func:`lammps_set_fix_external_callback` - :cpp:func:`lammps_fix_external_set_energy_global` +- :cpp:func:`lammps_fix_external_set_energy_peratom` - :cpp:func:`lammps_fix_external_set_virial_global` +- :cpp:func:`lammps_fix_external_set_virial_peratom` +- :cpp:func:`lammps_fix_external_set_vector_length` +- :cpp:func:`lammps_fix_external_set_vector` - :cpp:func:`lammps_free` - :cpp:func:`lammps_is_running` - :cpp:func:`lammps_force_timeout` @@ -33,7 +37,7 @@ where such memory buffers were allocated that require the use of ----------------------- -.. doxygenfunction:: lammps_set_fix_external_callback(void *, char *, FixExternalFnPtr, void*) +.. doxygenfunction:: lammps_set_fix_external_callback(void *, const char *, FixExternalFnPtr, void*) :project: progguide ----------------------- @@ -43,11 +47,31 @@ where such memory buffers were allocated that require the use of ----------------------- +.. doxygenfunction:: lammps_fix_external_set_energy_peratom + :project: progguide + +----------------------- + .. doxygenfunction:: lammps_fix_external_set_virial_global :project: progguide ----------------------- +.. doxygenfunction:: lammps_fix_external_set_virial_peratom + :project: progguide + +----------------------- + +.. doxygenfunction:: lammps_fix_external_set_vector_length + :project: progguide + +----------------------- + +.. doxygenfunction:: lammps_fix_external_set_vector + :project: progguide + +----------------------- + .. doxygenfunction:: lammps_free :project: progguide diff --git a/doc/src/Packages_details.rst b/doc/src/Packages_details.rst index 90537e9c0f..6d3df5c955 100644 --- a/doc/src/Packages_details.rst +++ b/doc/src/Packages_details.rst @@ -2297,10 +2297,10 @@ for monitoring molecules as bonds are created and destroyed. * src/REAXFF: filenames -> commands * src/REAXFF/README -* :doc:`pair_style reax/c ` -* :doc:`fix reax/c/bonds ` -* :doc:`fix reax/c/species ` -* examples/reax +* :doc:`pair_style reaxff ` +* :doc:`fix reaxff/bonds ` +* :doc:`fix reaxff/species ` +* examples/reaxff ---------- diff --git a/doc/src/Packages_list.rst b/doc/src/Packages_list.rst index 0724c7ab44..913389dcc6 100644 --- a/doc/src/Packages_list.rst +++ b/doc/src/Packages_list.rst @@ -375,7 +375,7 @@ whether an extra library is needed to build and use the package: - no * - :ref:`REAXFF ` - ReaxFF potential (C/C++) - - :doc:`pair_style reaxc ` + - :doc:`pair_style reaxff ` - reax - no * - :ref:`REPLICA ` diff --git a/doc/src/Tools.rst b/doc/src/Tools.rst index 65a96ce44a..e7cd87aa78 100644 --- a/doc/src/Tools.rst +++ b/doc/src/Tools.rst @@ -76,7 +76,6 @@ Post-processing tools * :ref:`phonon ` * :ref:`pymol_asphere ` * :ref:`python ` - * :ref:`reax ` * :ref:`replica ` * :ref:`smd ` * :ref:`spin ` @@ -947,20 +946,6 @@ while at the Shell lab at UC Santa Barbara. (tanmoy dot 7989 at gmail.com) ---------- -.. _reax_tool: - -reax tool --------------------------- - -The reax sub-directory contains stand-alone codes that can -post-process the output of the :doc:`fix reax/c/bonds ` -command from a LAMMPS simulation using :doc:`ReaxFF `. See -the README.txt file for more info. - -These tools were written by Aidan Thompson at Sandia. - ----------- - .. _smd: smd tool diff --git a/doc/src/compute_pair.rst b/doc/src/compute_pair.rst index 1b074203aa..abfd1ebed4 100644 --- a/doc/src/compute_pair.rst +++ b/doc/src/compute_pair.rst @@ -24,7 +24,7 @@ Examples compute 1 all pair gauss compute 1 all pair lj/cut/coul/cut ecoul compute 1 all pair tersoff 2 epair - compute 1 all pair reax/c + compute 1 all pair reaxff Description """"""""""" @@ -64,7 +64,8 @@ is stored as a global scalar. :doc:`pair_modify ` command. Some pair styles tally additional quantities, e.g. a breakdown of -potential energy into 14 components is tallied by the :doc:`pair_style reax/c ` command. These values (1 or more) +potential energy into 14 components is tallied by the +:doc:`pair_style reaxff ` command. These values (1 or more) are stored as a global vector by this compute. See the doc page for :doc:`individual pair styles ` for info on these values. diff --git a/doc/src/fix.rst b/doc/src/fix.rst index 912cfad255..07a663c789 100644 --- a/doc/src/fix.rst +++ b/doc/src/fix.rst @@ -322,14 +322,14 @@ accelerated styles exist. * :doc:`qeq/dynamic ` - charge equilibration via dynamic method * :doc:`qeq/fire ` - charge equilibration via FIRE minimizer * :doc:`qeq/point ` - charge equilibration via point method -* :doc:`qeq/reax ` - charge equilibration for ReaxFF potential +* :doc:`qeq/reaxff ` - charge equilibration for ReaxFF potential * :doc:`qeq/shielded ` - charge equilibration via shielded method * :doc:`qeq/slater ` - charge equilibration via Slater method * :doc:`qmmm ` - functionality to enable a quantum mechanics/molecular mechanics coupling * :doc:`qtb ` - implement quantum thermal bath scheme * :doc:`rattle ` - RATTLE constraints on bonds and/or angles -* :doc:`reax/c/bonds ` - write out ReaxFF bond information -* :doc:`reax/c/species ` - write out ReaxFF molecule information +* :doc:`reaxff/bonds ` - write out ReaxFF bond information +* :doc:`reaxff/species ` - write out ReaxFF molecule information * :doc:`recenter ` - constrain the center-of-mass position of a group of atoms * :doc:`restrain ` - constrain a bond, angle, dihedral * :doc:`rhok ` - add bias potential for long-range ordered systems diff --git a/doc/src/fix_adapt.rst b/doc/src/fix_adapt.rst index a110d93a8d..58d86f8472 100644 --- a/doc/src/fix_adapt.rst +++ b/doc/src/fix_adapt.rst @@ -186,7 +186,7 @@ formulas for the meaning of these parameters: +------------------------------------------------------------------------------+--------------------------------------------------+-------------+ | :doc:`nm/cut/coul/cut, nm/cut/coul/long ` | E0,R0,m,n,coulombic_cutoff | type pairs | +------------------------------------------------------------------------------+--------------------------------------------------+-------------+ -| :doc:`reax/c ` | chi, eta, gamma | type global | +| :doc:`reaxff ` | chi, eta, gamma | type global | +------------------------------------------------------------------------------+--------------------------------------------------+-------------+ | :doc:`snap ` | scale | type pairs | +------------------------------------------------------------------------------+--------------------------------------------------+-------------+ diff --git a/doc/src/fix_gcmc.rst b/doc/src/fix_gcmc.rst index c65dace601..e360fab86e 100644 --- a/doc/src/fix_gcmc.rst +++ b/doc/src/fix_gcmc.rst @@ -374,7 +374,7 @@ in the context of NVT dynamics. has been reached. With some pair_styles, such as :doc:`Buckingham `, -:doc:`Born-Mayer-Huggins ` and :doc:`ReaxFF `, two +:doc:`Born-Mayer-Huggins ` and :doc:`ReaxFF `, two atoms placed close to each other may have an arbitrary large, negative potential energy due to the functional form of the potential. While these unphysical configurations are inaccessible to typical dynamical diff --git a/doc/src/fix_qeq.rst b/doc/src/fix_qeq.rst index c655076ce8..113692da9b 100644 --- a/doc/src/fix_qeq.rst +++ b/doc/src/fix_qeq.rst @@ -32,15 +32,16 @@ Syntax * cutoff = global cutoff for charge-charge interactions (distance unit) * tolerance = precision to which charges will be equilibrated * maxiter = maximum iterations to perform charge equilibration -* qfile = a filename with QEq parameters or *coul/streitz* or *reax/c* +* qfile = a filename with QEq parameters or *coul/streitz* or *reaxff* * zero or more keyword/value pairs may be appended -* keyword = *alpha* or *qdamp* or *qstep* +* keyword = *alpha* or *qdamp* or *qstep* or *warn* .. parsed-literal:: *alpha* value = Slater type orbital exponent (qeq/slater only) *qdamp* value = damping factor for damped dynamics charge solver (qeq/dynamic and qeq/fire only) *qstep* value = time step size for damped dynamics charge solver (qeq/dynamic and qeq/fire only) + *warn* value = do (=yes) or do not (=no) print a warning when the maximum number of iterations is reached Examples """""""" @@ -90,19 +91,19 @@ on the current atom configuration), then remove the fix via the 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 + `. The :doc:`fix qeq/reaxff ` 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 + field `, although fix qeq/shielded yields the same + results as fix qeq/reaxff if *Nevery*\ , *cutoff*\ , and *tolerance* + are the same. Eventually the fix qeq/reaxff 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 atoms) by adjusting the partial charge on individual atoms based on interactions with their neighbors within *cutoff*\ . It requires a few -parameters, in *metal* units, for each atom type which provided in a -file specified by *qfile*\ . The file has the following format +parameters in the appropriate units for each atom type which are read +from a file specified by *qfile*\ . The file has the following format .. parsed-literal:: @@ -112,7 +113,7 @@ file specified by *qfile*\ . The file has the following format Ntype chi eta gamma zeta qcore There have to be parameters given for every atom type. Wildcard entries -are possible using the same syntax as elsewhere in LAMMPS +are possible using the same type range syntax as for "coeff" commands (i.e., n\*m, n\*, \*m, \*). Later entries will overwrite previous ones. Empty lines or any text following the pound sign (#) are ignored. Each line starts with the atom type followed by five parameters. @@ -126,6 +127,14 @@ entries per line are required. * *zeta* = Slater type orbital exponent defined by the :ref:`Streitz-Mintmire ` potential in reverse distance units * *qcore* = charge of the nucleus defined by the :ref:`Streitz-Mintmire potential ` potential in charge units +The fix qeq styles will print a warning if the charges are not +equilibrated within *tolerance* by *maxiter* steps, unless the +*warn* keyword is used with "no" as argument. This latter option +may be useful for testing and benchmarking purposes, as it allows +to use a fixed number of QEq iterations when *tolerance* is set +to a small enough value to always reach the *maxiter* limit. Turning +off warnings will avoid the excessive output in that case. + The *qeq/point* style describes partial charges on atoms as point charges. Interaction between a pair of charged particles is 1/r, which is the simplest description of the interaction between charges. @@ -141,11 +150,11 @@ 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 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 +as :doc:`fix qeq/reaxff `, and can be used with +:doc:`pair_style reaxff `. 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 +*reaxff* as filename, these parameters are extracted directly from an +active *reaxff* 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. @@ -221,15 +230,17 @@ 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. +The qeq fixes are not compatible with the GPU and USER-INTEL packages. + Related commands """""""""""""""" -:doc:`fix qeq/reax `, :doc:`fix qeq/comb ` +:doc:`fix qeq/reaxff `, :doc:`fix qeq/comb ` Default """"""" -none +warn yes ---------- diff --git a/doc/src/fix_qeq_comb.rst b/doc/src/fix_qeq_comb.rst index 74a97720dc..8eeea6c5b4 100644 --- a/doc/src/fix_qeq_comb.rst +++ b/doc/src/fix_qeq_comb.rst @@ -41,7 +41,7 @@ Perform charge equilibration (QeQ) in conjunction with the COMB equilibration portion of the calculation using the so-called QEq method, whereby the charge on each atom is adjusted to minimize the energy of the system. This fix can only be used with the COMB -potential; see the :doc:`fix qeq/reax ` command for a QeQ +potential; see the :doc:`fix qeq/reaxff ` command for a QeQ calculation that can be used with any potential. Only charges on the atoms in the specified group are equilibrated. diff --git a/doc/src/fix_qeq_reax.rst b/doc/src/fix_qeq_reaxff.rst similarity index 52% rename from doc/src/fix_qeq_reax.rst rename to doc/src/fix_qeq_reaxff.rst index 1b0f4c37e5..96a20d4ca6 100644 --- a/doc/src/fix_qeq_reax.rst +++ b/doc/src/fix_qeq_reaxff.rst @@ -1,59 +1,61 @@ -.. index:: fix qeq/reax -.. index:: fix qeq/reax/kk -.. index:: fix qeq/reax/omp +.. index:: fix qeq/reaxff +.. index:: fix qeq/reaxff/kk +.. index:: fix qeq/reaxff/omp -fix qeq/reax command -==================== +fix qeq/reaxff command +====================== -Accelerator Variants: *qeq/reax/kk*, *qeq/reax/omp* +Accelerator Variants: *qeq/reaxff/kk*, *qeq/reaxff/omp* Syntax """""" .. parsed-literal:: - fix ID group-ID qeq/reax Nevery cutlo cuthi tolerance params args + fix ID group-ID qeq/reaxff Nevery cutlo cuthi tolerance params args * ID, group-ID are documented in :doc:`fix ` command -* qeq/reax = style name of this fix command +* qeq/reaxff = style name of this fix command * Nevery = perform QEq every this many steps * cutlo,cuthi = lo and hi cutoff for Taper radius * tolerance = precision to which charges will be equilibrated -* params = reax/c or a filename +* params = reaxff or a filename * one or more keywords or keyword/value pairs may be appended .. parsed-literal:: - keyword = *dual* or *maxiter* - *dual* = process S and T matrix in parallel (only for qeq/reax/omp) + keyword = *dual* or *maxiter* or *nowarn* + *dual* = process S and T matrix in parallel (only for qeq/reaxff/omp) *maxiter* N = limit the number of iterations to *N* - + *nowarn* = do not print a warning message if the maximum number of iterations was reached Examples """""""" .. code-block:: LAMMPS - fix 1 all qeq/reax 1 0.0 10.0 1.0e-6 reax/c - fix 1 all qeq/reax 1 0.0 10.0 1.0e-6 param.qeq maxiter 500 + fix 1 all qeq/reaxff 1 0.0 10.0 1.0e-6 reaxff + fix 1 all qeq/reaxff 1 0.0 10.0 1.0e-6 param.qeq maxiter 500 Description """"""""""" -Perform the charge equilibration (QEq) method as described in :ref:`(Rappe and Goddard) ` and formulated in :ref:`(Nakano) `. It is -typically used in conjunction with the ReaxFF force field model as -implemented in the :doc:`pair_style reax/c ` command, but -it can be used with any potential in LAMMPS, so long as it defines and -uses charges on each atom. The :doc:`fix qeq/comb ` -command should be used to perform charge equilibration with the :doc:`COMB potential `. For more technical details about the -charge equilibration performed by fix qeq/reax, see the +Perform the charge equilibration (QEq) method as described in +:ref:`(Rappe and Goddard) ` and formulated in :ref:`(Nakano) +`. It is typically used in conjunction with the ReaxFF force +field model as implemented in the :doc:`pair_style reaxff ` +command, but it can be used with any potential in LAMMPS, so long as it +defines and uses charges on each atom. The :doc:`fix qeq/comb +` command should be used to perform charge equilibration +with the :doc:`COMB potential `. For more technical details +about the charge equilibration performed by fix qeq/reaxff, see the :ref:`(Aktulga) ` paper. The QEq method minimizes the electrostatic energy of the system by adjusting the partial charge on individual atoms based on interactions with their neighbors. It requires some parameters for each atom type. -If the *params* setting above is the word "reax/c", then these are -extracted from the :doc:`pair_style reax/c ` command and +If the *params* setting above is the word "reaxff", then these are +extracted from the :doc:`pair_style reaxff ` command and the ReaxFF force field file it reads in. If a file name is specified for *params*\ , then the parameters are taken from the specified file and the file must contain one line for each atom type. The latter @@ -74,17 +76,26 @@ of this fix are hard-coded to be A, eV, and electronic charge. The optional *dual* keyword allows to perform the optimization of the S and T matrices in parallel. This is only supported for -the *qeq/reax/omp* style. Otherwise they are processed separately. +the *qeq/reaxff/omp* style. Otherwise they are processed separately. The optional *maxiter* keyword allows changing the max number of iterations in the linear solver. The default value is 200. +The optional *nowarn* keyword silences the warning message printed +when the maximum number of iterations was reached. This can be +useful for comparing serial and parallel results where having the +same fixed number of QEq iterations is desired, which can be achieved +by using a very small tolerance and setting *maxiter* to the desired +number of iterations. + Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" -No information about this fix is written to :doc:`binary restart files `. No global scalar or vector or per-atom -quantities are stored by this fix for access by various :doc:`output commands `. No parameter of this fix can be used -with the *start/stop* keywords of the :doc:`run ` command. +No information about this fix is written to :doc:`binary restart files +`. This fix computes a global scalar (the number of +iterations) for access by various :doc:`output commands `. +No parameter of this fix can be used with the *start/stop* keywords of +the :doc:`run ` command. This fix is invoked during :doc:`energy minimization `. @@ -98,16 +109,17 @@ Restrictions """""""""""" This fix is part of the REAXFF package. It is 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. -This fix does not correctly handle interactions -involving multiple periodic images of the same atom. Hence, it should not -be used for periodic cell dimensions less than 10 angstroms. +This fix does not correctly handle interactions involving multiple +periodic images of the same atom. Hence, it should not be used for +periodic cell dimensions less than 10 angstroms. Related commands """""""""""""""" -:doc:`pair_style reax/c ` +:doc:`pair_style reaxff `, :doc:`fix qeq/shielded ` Default """"""" diff --git a/doc/src/fix_reaxc_bonds.rst b/doc/src/fix_reaxff_bonds.rst similarity index 79% rename from doc/src/fix_reaxc_bonds.rst rename to doc/src/fix_reaxff_bonds.rst index 9207ee7a63..5dd4df7765 100644 --- a/doc/src/fix_reaxc_bonds.rst +++ b/doc/src/fix_reaxff_bonds.rst @@ -1,17 +1,17 @@ -.. index:: fix reax/c/bonds -.. index:: fix reax/c/bonds/kk +.. index:: fix reaxff/bonds +.. index:: fix reaxff/bonds/kk -fix reax/c/bonds command +fix reaxff/bonds command ======================== -Accelerator Variants: *reax/c/bonds/kk* +Accelerator Variants: *reaxff/bonds/kk* Syntax """""" .. parsed-literal:: - fix ID group-ID reaxc/bonds Nevery filename + fix ID group-ID reaxff/bonds Nevery filename * ID, group-ID are documented in :doc:`fix ` command * reax/bonds = style name of this fix command @@ -23,17 +23,17 @@ Examples .. code-block:: LAMMPS - fix 1 all reax/c/bonds 100 bonds.reaxc + fix 1 all reaxff/bonds 100 bonds.reaxff Description """"""""""" Write out the bond information computed by the ReaxFF potential specified -by :doc:`pair_style reax/c ` in the exact same format as the +by :doc:`pair_style reaxff ` in the exact same format as the original stand-alone ReaxFF code of Adri van Duin. The bond information is written to *filename* on timesteps that are multiples of *Nevery*\ , including timestep 0. For time-averaged chemical species analysis, -please see the :doc:`fix reaxc/c/species ` command. +please see the :doc:`fix reaxff/species ` command. The specified group-ID is ignored by this fix. @@ -76,7 +76,7 @@ the :doc:`run ` command. This fix is not invoked during :doc:`energy minim Restrictions """""""""""" -The fix reax/c/bonds command requires that the :doc:`pair_style reax/c ` is invoked. This fix is part of the +The fix reaxff/bonds command requires that the :doc:`pair_style reaxff ` is invoked. This fix is part of the REAXFF package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` doc page for more info. @@ -87,7 +87,7 @@ To write gzipped bond files, you must compile LAMMPS with the Related commands """""""""""""""" -:doc:`pair_style reax/c `, :doc:`fix reax/c/species ` +:doc:`pair_style reaxff `, :doc:`fix reaxff/species ` Default """"""" diff --git a/doc/src/fix_reaxc_species.rst b/doc/src/fix_reaxff_species.rst similarity index 77% rename from doc/src/fix_reaxc_species.rst rename to doc/src/fix_reaxff_species.rst index bce140a9af..bca9c2c726 100644 --- a/doc/src/fix_reaxc_species.rst +++ b/doc/src/fix_reaxff_species.rst @@ -1,20 +1,20 @@ -.. index:: fix reax/c/species -.. index:: fix reax/c/species/kk +.. index:: fix reaxff/species +.. index:: fix reaxff/species/kk -fix reax/c/species command +fix reaxff/species command ========================== -Accelerator Variants: *reax/c/species/kk* +Accelerator Variants: *reaxff/species/kk* Syntax """""" .. parsed-literal:: - fix ID group-ID reax/c/species Nevery Nrepeat Nfreq filename keyword value ... + fix ID group-ID reaxff/species Nevery Nrepeat Nfreq filename keyword value ... * ID, group-ID are documented in :doc:`fix ` command -* reax/c/species = style name of this command +* reaxff/species = style name of this command * Nevery = sample bond-order every this many timesteps * Nrepeat = # of bond-order samples used for calculating averages * Nfreq = calculate average bond-order every this many timesteps @@ -37,15 +37,15 @@ Examples .. code-block:: LAMMPS - fix 1 all reax/c/species 10 10 100 species.out - fix 1 all reax/c/species 1 2 20 species.out cutoff 1 1 0.40 cutoff 1 2 0.55 - fix 1 all reax/c/species 1 100 100 species.out element Au O H position 1000 AuOH.pos + fix 1 all reaxff/species 10 10 100 species.out + fix 1 all reaxff/species 1 2 20 species.out cutoff 1 1 0.40 cutoff 1 2 0.55 + fix 1 all reaxff/species 1 100 100 species.out element Au O H position 1000 AuOH.pos Description """"""""""" Write out the chemical species information computed by the ReaxFF -potential specified by :doc:`pair_style reax/c `. +potential specified by :doc:`pair_style reaxff `. Bond-order values (either averaged or instantaneous, depending on value of *Nrepeat*\ ) are used to determine chemical bonds. Every *Nfreq* timesteps, chemical species information is written to @@ -73,7 +73,7 @@ symbol printed for each LAMMPS atom type. The number of symbols must match the number of LAMMPS atom types and each symbol must consist of 1 or 2 alphanumeric characters. Normally, these symbols should be chosen to match the chemical identity of each LAMMPS atom type, as -specified using the :doc:`reax/c pair_coeff ` command and +specified using the :doc:`reaxff pair_coeff ` command and the ReaxFF force field file. The optional keyword *position* writes center-of-mass positions of @@ -115,12 +115,12 @@ average bond-order for the species analysis output on timestep 100. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" -No information about this fix is written to :doc:`binary restart files `. None of the :doc:`fix_modify ` options -are relevant to this fix. +No information about this fix is written to :doc:`binary restart files `. +None of the :doc:`fix_modify ` options are relevant to this fix. -This fix computes both a global vector of length 2 and a per-atom -vector, either of which can be accessed by various :doc:`output commands `. The values in the global vector are -"intensive". +This fix computes both a global vector of length 2 and a per-atom vector, +either of which can be accessed by various :doc:`output commands `. +The values in the global vector are "intensive". The 2 values in the global vector are as follows: @@ -134,7 +134,8 @@ will be the same and will be equal to the smallest atom ID of any atom in the molecule. No parameter of this fix can be used with the *start/stop* keywords of -the :doc:`run ` command. This fix is not invoked during :doc:`energy minimization `. +the :doc:`run ` command. +This fix is not invoked during :doc:`energy minimization `. ---------- @@ -145,26 +146,20 @@ the :doc:`run ` command. This fix is not invoked during :doc:`energy minim Restrictions """""""""""" -The "fix reax/c/species" currently only works with :doc:`pair_style reax/c ` and it requires that the :doc:`pair_style reax/c ` be invoked. This fix is part of the -REAXFF package. It is only enabled if LAMMPS was built with that -package. See the :doc:`Build package ` doc page for more -info. +The "fix reaxff/species" requires that :doc:`pair_style reaxff ` is used. +This fix is part of the REAXFF package. It is only enabled if LAMMPS was built with that +package. See the :doc:`Build package ` doc page for more info. -To write gzipped species files, you must compile LAMMPS with the --DLAMMPS_GZIP option. - -It should be possible to extend it to other reactive pair_styles (such as -:doc:`rebo `, :doc:`airebo `, -:doc:`comb `, and :doc:`bop `), but this has not yet been done. +To write gzipped species files, you must compile LAMMPS with the -DLAMMPS_GZIP option. Related commands """""""""""""""" -:doc:`pair_style reax/c `, :doc:`fix reax/c/bonds ` +:doc:`pair_style reaxff `, :doc:`fix reaxff/bonds ` Default """"""" -The default values for bond-order cutoffs are 0.3 for all I-J pairs. The -default element symbols are C, H, O, N. Position files are not written -by default. +The default values for bond-order cutoffs are 0.3 for all I-J pairs. +The default element symbols are C, H, O, N. +Position files are not written by default. diff --git a/doc/src/kim_commands.rst b/doc/src/kim_commands.rst index f116a70922..fc00a574d2 100644 --- a/doc/src/kim_commands.rst +++ b/doc/src/kim_commands.rst @@ -372,9 +372,9 @@ the *kim interactions* command executes the following LAMMPS input commands: .. code-block:: LAMMPS - pair_style reax/c lmp_control safezone 2.0 mincap 100 + pair_style reaxff lmp_control safezone 2.0 mincap 100 pair_coeff * * ffield.reax.rdx C H N O - fix reaxqeq all qeq/reax 1 0.0 10.0 1.0e-6 param.qeq + fix reaxqeq all qeq/reaxff 1 0.0 10.0 1.0e-6 param.qeq .. note:: diff --git a/doc/src/package.rst b/doc/src/package.rst index e997dc6147..54cf74f5be 100644 --- a/doc/src/package.rst +++ b/doc/src/package.rst @@ -448,7 +448,8 @@ does not require atomic operations in the calculation of pair forces. For that reason, *full* is the default setting for GPUs. However, when running on CPUs, a *half* neighbor list is the default because it are often faster, just as it is for non-accelerated pair styles. Similarly, -the *neigh/qeq* keyword determines how neighbor lists are built for :doc:`fix qeq/reax/kk `. +the *neigh/qeq* keyword determines how neighbor lists are built for +:doc:`fix qeq/reaxff/kk `. If the *neigh/thread* keyword is set to *off*\ , then the KOKKOS package threads only over atoms. However, for small systems, this may not expose diff --git a/doc/src/pair_reaxc.rst b/doc/src/pair_reaxff.rst similarity index 76% rename from doc/src/pair_reaxc.rst rename to doc/src/pair_reaxff.rst index 352bcb4847..0389742ea5 100644 --- a/doc/src/pair_reaxc.rst +++ b/doc/src/pair_reaxff.rst @@ -1,18 +1,18 @@ -.. index:: pair_style reax/c -.. index:: pair_style reax/c/kk -.. index:: pair_style reax/c/omp +.. index:: pair_style reaxff +.. index:: pair_style reaxff/kk +.. index:: pair_style reaxff/omp -pair_style reax/c command +pair_style reaxff command ========================= -Accelerator Variants: *reax/c/kk*, *reax/c/omp* +Accelerator Variants: *reaxff/kk*, *reaxff/omp* Syntax """""" .. code-block:: LAMMPS - pair_style reax/c cfile keyword value + pair_style reaxff cfile keyword value * cfile = NULL or name of a control file * zero or more keyword/value pairs may be appended @@ -20,7 +20,7 @@ Syntax .. parsed-literal:: keyword = *checkqeq* or *lgvdw* or *safezone* or *mincap* or *minhbonds* - *checkqeq* value = *yes* or *no* = whether or not to require qeq/reax fix + *checkqeq* value = *yes* or *no* = whether or not to require qeq/reaxff fix *enobonds* value = *yes* or *no* = whether or not to tally energy of atoms with no bonds *lgvdw* value = *yes* or *no* = whether or not to use a low gradient vdW correction *safezone* = factor used for array allocation @@ -32,37 +32,38 @@ Examples .. code-block:: LAMMPS - pair_style reax/c NULL - pair_style reax/c controlfile checkqeq no - pair_style reax/c NULL lgvdw yes - pair_style reax/c NULL safezone 1.6 mincap 100 + pair_style reaxff NULL + pair_style reaxff controlfile checkqeq no + pair_style reaxff NULL lgvdw yes + pair_style reaxff NULL safezone 1.6 mincap 100 pair_coeff * * ffield.reax C H O N Description """"""""""" -Style *reax/c* computes the ReaxFF potential of van Duin, Goddard and +Style *reaxff* computes the ReaxFF potential of van Duin, Goddard and co-workers. ReaxFF uses distance-dependent bond-order functions to represent the contributions of chemical bonding to the potential energy. There is more than one version of ReaxFF. The version implemented in LAMMPS uses the functional forms documented in the -supplemental information of the following paper: :ref:`(Chenoweth et al., 2008) `. The version integrated into LAMMPS matches -the most up-to-date version of ReaxFF as of summer 2010. For more -technical details about the pair reax/c implementation of ReaxFF, see -the :ref:`(Aktulga) ` paper. The *reax/c* style was initially -implemented as a stand-alone C code and is now integrated into LAMMPS -as a package. +supplemental information of the following paper: +:ref:`(Chenoweth et al., 2008) `. The version integrated +into LAMMPS matches the version of ReaxFF From Summer 2010. For more +technical details about the pair reaxff implementation of ReaxFF, see +the :ref:`(Aktulga) ` paper. The *reaxff* style was initially +implemented as a stand-alone C code and is now converted to C++ and +integrated into LAMMPS as a package. -The *reax/c/kk* style is a Kokkos version of the ReaxFF potential that -is derived from the *reax/c* style. The Kokkos version can run on GPUs +The *reaxff/kk* style is a Kokkos version of the ReaxFF potential that +is derived from the *reaxff* style. The Kokkos version can run on GPUs and can also use OpenMP multithreading. For more information about the Kokkos package, see :doc:`Packages details ` and :doc:`Speed kokkos ` doc pages. One important -consideration when using the *reax/c/kk* style is the choice of either +consideration when using the *reaxff/kk* style is the choice of either half or full neighbor lists. This setting can be changed using the Kokkos :doc:`package ` command. -The *reax/c* style differs from the (obsolete) "pair_style reax" +The *reaxff* style differs from the (obsolete) "pair_style reax" command in the implementation details. The *reax* style was a Fortran library, linked to LAMMPS. The *reax* style has been removed from LAMMPS after the 12 December 2018 version. @@ -73,7 +74,7 @@ documented in potentials/README.reax. The default ffield.reax contains parameterizations for the following elements: C, H, O, N. The format of these files is identical to that used originally by van -Duin. We have tested the accuracy of *pair_style reax/c* potential +Duin. We have tested the accuracy of *pair_style reaxff* potential against the original ReaxFF code for the systems mentioned above. You can use other ffield files for specific chemical systems that may be available elsewhere (but note that their accuracy may not have been @@ -102,10 +103,11 @@ control variable. The format of the control file is described below. The LAMMPS default values for the ReaxFF global parameters correspond to those used by Adri van Duin's stand-alone serial - code. If these are changed by setting control variables in the control - file, the results from LAMMPS and the serial code will not agree. + code. If these are changed by setting control variables in the + control file, the results from LAMMPS and the serial code will + not agree. -Examples using *pair_style reax/c* are provided in the examples/reax +Examples using *pair_style reaxff* are provided in the examples/reax sub-directory. Use of this pair style requires that a charge be defined for every @@ -115,25 +117,28 @@ charges. The ReaxFF parameter files provided were created using a charge equilibration (QEq) model for handling the electrostatic interactions. -Therefore, by default, LAMMPS requires that the :doc:`fix qeq/reax ` command be used with *pair_style reax/c* -when simulating a ReaxFF model, to equilibrate charge each timestep. -Using the keyword *checkqeq* with the value *no* -turns off the check for *fix qeq/reax*\ , -allowing a simulation to be run without charge equilibration. -In this case, the static charges you -assign to each atom will be used for computing the electrostatic -interactions in the system. -See the :doc:`fix qeq/reax ` command for details. +Therefore, by default, LAMMPS requires that either the +:doc:`fix qeq/reaxff ` or the +:doc:`fix qeq/shielded ` command be used with +*pair_style reaxff* when simulating a ReaxFF model, to equilibrate +the charges each timestep. + +Using the keyword *checkqeq* with the value *no* turns off the check +for the QEq fixes, allowing a simulation to be run without charge +equilibration. In this case, the static charges you assign to each +atom will be used for computing the electrostatic interactions in +the system. See the :doc:`fix qeq/reaxff ` or +:doc:`fix qeq/shielded ` command documentation for more details. Using the optional keyword *lgvdw* with the value *yes* turns on the -low-gradient correction of the ReaxFF/C for long-range London -Dispersion, as described in the :ref:`(Liu) ` paper. Force field -file *ffield.reax.lg* is designed for this correction, and is trained -for several energetic materials (see "Liu"). When using lg-correction, -recommended value for parameter *thb* is 0.01, which can be set in the +low-gradient correction of ReaxFF for long-range London Dispersion, +as described in the :ref:`(Liu) ` paper. The bundled force +field file *ffield.reax.lg* is designed for this correction, and is +trained for several energetic materials (see "Liu"). When using *lgvdw yes*, +the recommended value for parameter *thb* is 0.01, which can be set in the control file. Note: Force field files are different for the original -or lg corrected pair styles, using wrong ffield file generates an -error message. +or lg corrected pair styles, using the wrong ffield file generates an +error. Using the optional keyword *enobonds* with the value *yes*\ , the energy of atoms with no bonds (i.e. isolated atoms) is included in the total @@ -144,7 +149,7 @@ discontinuities in the potential energy when the bonding of an atom drops to zero. Optional keywords *safezone*\ , *mincap*\ , and *minhbonds* are used -for allocating reax/c arrays. Increasing these values can avoid memory +for allocating reaxff arrays. Increasing these values can avoid memory problems, such as segmentation faults and bondchk failed errors, that could occur under certain conditions. These keywords are not used by the Kokkos version, which instead uses a more robust memory allocation @@ -158,7 +163,8 @@ equilibration contributions which are stored in the thermo variable :doc:`thermo ` command. This pair style tallies a breakdown of the total ReaxFF potential -energy into sub-categories, which can be accessed via the :doc:`compute pair ` command as a vector of values of length 14. +energy into sub-categories, which can be accessed via the +:doc:`compute pair ` command as a vector of values of length 14. The 14 values correspond to the following sub-categories (the variable names in italics match those used in the original FORTRAN ReaxFF code): @@ -183,14 +189,14 @@ headings) the following commands could be included in an input script: .. code-block:: LAMMPS - compute reax all pair reax/c + compute reax all pair reaxff variable eb equal c_reax[1] variable ea equal c_reax[2] [...] variable eqeq equal c_reax[14] thermo_style custom step temp epair v_eb v_ea [...] v_eqeq -Only a single pair_coeff command is used with the *reax/c* style which +Only a single pair_coeff command is used with the *reaxff* style which specifies a ReaxFF potential file with parameters for all needed elements. These are mapped to LAMMPS atom types by specifying N additional arguments after the filename in the pair_coeff command, @@ -209,7 +215,7 @@ to M. Each of the N indices you specify for the N atom types of LAMMPS atoms must be an integer from 1 to M. Atoms with LAMMPS type 1 will be mapped to whatever element you specify as the first index value, etc. If a mapping value is specified as NULL, the mapping is not -performed. This can be used when the *reax/c* style is used as part +performed. This can be used when the *reaxff* style is used as part of the *hybrid* pair style. The NULL values are placeholders for atom types that will be used with other potentials. @@ -241,7 +247,7 @@ brief description of their use and default values. *simulation_name* - Output files produced by *pair_style reax/c* carry + Output files produced by *pair_style reaxff* carry this name + extensions specific to their contents. Partial energies are reported with a ".pot" extension, while the trajectory file has ".trj" extension. @@ -286,8 +292,7 @@ brief description of their use and default values. to be considered in three body interactions. (default value = 0.00001) *write_freq* - Frequency of writes into the trajectory file. (default - value = 0) + Frequency of writes into the trajectory file. (default value = 0) *traj_title* Title of the trajectory - not the name of the trajectory file. @@ -315,7 +320,8 @@ Mixing, shift, table, tail correction, restart, rRESPA info This pair style does not support the :doc:`pair_modify ` mix, shift, table, and tail options. -This pair style does not write its information to :doc:`binary restart files `, since it is stored in potential files. Thus, you +This pair style does not write its information to :doc:`binary restart files `, +since it is stored in potential files. Thus, you need to re-specify the pair_style and pair_coeff commands in an input script that reads a restart file. @@ -333,18 +339,20 @@ Restrictions """""""""""" This pair style is part of the REAXFF package. It is only enabled -if LAMMPS was built with that package. See the :doc:`Build package ` doc page for more info. +if LAMMPS was built with that package. +See the :doc:`Build package ` doc page for more info. The ReaxFF potential files provided with LAMMPS in the potentials -directory are parameterized for real :doc:`units `. You can use -the ReaxFF potential with any LAMMPS units, but you would need to +directory are parameterized for *real* :doc:`units `. You can use +the ReaxFF pair style with any LAMMPS units, but you would need to create your own potential file with coefficients listed in the appropriate units if your simulation does not use "real" units. Related commands """""""""""""""" -:doc:`pair_coeff `, :doc:`fix qeq/reax `, :doc:`fix reax/c/bonds `, :doc:`fix reax/c/species ` +:doc:`pair_coeff `, :doc:`fix qeq/reaxff `, +:doc:`fix reaxff/bonds `, :doc:`fix reaxff/species ` Default """"""" diff --git a/doc/src/pair_style.rst b/doc/src/pair_style.rst index f0497cb931..50f49c87c9 100644 --- a/doc/src/pair_style.rst +++ b/doc/src/pair_style.rst @@ -299,7 +299,7 @@ accelerated styles exist. * :doc:`python ` - * :doc:`quip ` - * :doc:`rann ` - -* :doc:`reax/c ` - ReaxFF potential in C +* :doc:`reaxff ` - ReaxFF potential * :doc:`rebo ` - second generation REBO potential of Brenner * :doc:`resquared ` - Everaers RE-Squared ellipsoidal potential * :doc:`sdpd/taitwater/isothermal ` - smoothed dissipative particle dynamics for water at isothermal conditions diff --git a/doc/utils/check-styles.py b/doc/utils/check-styles.py index 16a7cf2a5c..6c1fd6dd35 100755 --- a/doc/utils/check-styles.py +++ b/doc/utils/check-styles.py @@ -254,40 +254,27 @@ for command_type, entries in index.items(): print("Total number of style index entries:", total_index) +skip_fix = ('python', 'NEIGH_HISTORY/omp','qeq/reax','reax/c/bonds','reax/c/species') +skip_pair = ('meam/c','lj/sf','reax/c') + counter = 0 -counter += check_style('Commands_all.rst', doc_dir, ":doc:`(.+) <.+>`", - command,'Command',suffix=False) -counter += check_style('Commands_compute.rst', doc_dir, ":doc:`(.+) `", - compute,'Compute',suffix=True) -counter += check_style('compute.rst', doc_dir, ":doc:`(.+) ` -", - compute,'Compute',suffix=False) -counter += check_style('Commands_fix.rst', doc_dir, ":doc:`(.+) `", - fix,'Fix',skip=('python', 'NEIGH_HISTORY/omp'),suffix=True) -counter += check_style('fix.rst', doc_dir, ":doc:`(.+) ` -", - fix,'Fix',skip=('python', 'NEIGH_HISTORY/omp'),suffix=False) -counter += check_style('Commands_pair.rst', doc_dir, ":doc:`(.+) `", - pair,'Pair',skip=('meam/c','lj/sf'),suffix=True) -counter += check_style('pair_style.rst', doc_dir, ":doc:`(.+) ` -", - pair,'Pair',skip=('meam/c','lj/sf'),suffix=False) -counter += check_style('Commands_bond.rst', doc_dir, ":doc:`(.+) `", - bond,'Bond',suffix=True) -counter += check_style('bond_style.rst', doc_dir, ":doc:`(.+) ` -", - bond,'Bond',suffix=False) -counter += check_style('Commands_bond.rst', doc_dir, ":doc:`(.+) `", - angle,'Angle',suffix=True) -counter += check_style('angle_style.rst', doc_dir, ":doc:`(.+) ` -", - angle,'Angle',suffix=False) -counter += check_style('Commands_bond.rst', doc_dir, ":doc:`(.+) `", - dihedral,'Dihedral',suffix=True) -counter += check_style('dihedral_style.rst', doc_dir, ":doc:`(.+) ` -", - dihedral,'Dihedral',suffix=False) -counter += check_style('Commands_bond.rst', doc_dir, ":doc:`(.+) `", - improper,'Improper',suffix=True) -counter += check_style('improper_style.rst', doc_dir, ":doc:`(.+) ` -", - improper,'Improper',suffix=False) -counter += check_style('Commands_kspace.rst', doc_dir, ":doc:`(.+) `", - kspace,'KSpace',suffix=True) +counter += check_style('Commands_all.rst', doc_dir, ":doc:`(.+) <.+>`",command,'Command',suffix=False) +counter += check_style('Commands_compute.rst', doc_dir, ":doc:`(.+) `",compute,'Compute',suffix=True) +counter += check_style('compute.rst', doc_dir, ":doc:`(.+) ` -",compute,'Compute',suffix=False) +counter += check_style('Commands_fix.rst', doc_dir, ":doc:`(.+) `",fix,'Fix',skip=skip_fix,suffix=True) +counter += check_style('fix.rst', doc_dir, ":doc:`(.+) ` -",fix,'Fix',skip=skip_fix,suffix=False) +counter += check_style('Commands_pair.rst', doc_dir, ":doc:`(.+) `",pair,'Pair',skip=skip_pair,suffix=True) +counter += check_style('pair_style.rst', doc_dir, ":doc:`(.+) ` -",pair,'Pair',skip=skip_pair,suffix=False) +counter += check_style('Commands_bond.rst', doc_dir, ":doc:`(.+) `",bond,'Bond',suffix=True) +counter += check_style('bond_style.rst', doc_dir, ":doc:`(.+) ` -",bond,'Bond',suffix=False) +counter += check_style('Commands_bond.rst', doc_dir, ":doc:`(.+) `",angle,'Angle',suffix=True) +counter += check_style('angle_style.rst', doc_dir, ":doc:`(.+) ` -",angle,'Angle',suffix=False) +counter += check_style('Commands_bond.rst', doc_dir, ":doc:`(.+) `",dihedral,'Dihedral',suffix=True) +counter += check_style('dihedral_style.rst', doc_dir, ":doc:`(.+) ` -",dihedral,'Dihedral',suffix=False) +counter += check_style('Commands_bond.rst', doc_dir, ":doc:`(.+) `",improper,'Improper',suffix=True) +counter += check_style('improper_style.rst', doc_dir, ":doc:`(.+) ` -",improper,'Improper',suffix=False) +counter += check_style('Commands_kspace.rst', doc_dir, ":doc:`(.+) `",kspace,'KSpace',suffix=True) if counter: print(f"Found {counter} issue(s) with style lists") @@ -295,13 +282,13 @@ if counter: counter = 0 counter += check_style_index("compute", compute, index["compute"]) -counter += check_style_index("fix", fix, index["fix"], skip=['python']) +counter += check_style_index("fix", fix, index["fix"], skip=['python','qeq/reax','reax/c/bonds','reax/c/species']) counter += check_style_index("angle_style", angle, index["angle_style"]) counter += check_style_index("bond_style", bond, index["bond_style"]) counter += check_style_index("dihedral_style", dihedral, index["dihedral_style"]) counter += check_style_index("improper_style", improper, index["improper_style"]) counter += check_style_index("kspace_style", kspace, index["kspace_style"]) -counter += check_style_index("pair_style", pair, index["pair_style"], skip=['meam/c', 'lj/sf']) +counter += check_style_index("pair_style", pair, index["pair_style"], skip=['meam/c', 'lj/sf','reax/c']) if counter: print(f"Found {counter} issue(s) with style index") diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 45728b5caf..778fa93e84 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -2744,6 +2744,7 @@ reamin reax REAXFF ReaxFF +reaxff rebo recursing Ree diff --git a/examples/README b/examples/README index 4f4f671a29..68825a7dbd 100644 --- a/examples/README +++ b/examples/README @@ -103,7 +103,7 @@ pour: pouring of granular particles into a 3d box, then chute flow prd: parallel replica dynamics of vacancy diffusion in bulk Si python: use of PYTHON package to invoke Python code from input script qeq: use of QEQ package for charge equilibration -reax: RDX and TATB and several other models using ReaxFF +reaxff: RDX and TATB and several other models using ReaxFF rerun: use of rerun and read_dump commands rigid: rigid bodies modeled as independent or coupled shear: sideways shear applied to 2d solid, with and without a void diff --git a/examples/qeq/buck.inc b/examples/qeq/buck.inc new file mode 100644 index 0000000000..af3fe3dfb6 --- /dev/null +++ b/examples/qeq/buck.inc @@ -0,0 +1,22 @@ + +kspace_style pppm 1e-6 + +neighbor 1.0 bin +neigh_modify delay 0 every 1 check yes + +group type1 type 1 +compute charge1 type1 property/atom q +compute q1 type1 reduce ave c_charge1 +group type2 type 2 +compute charge2 type2 property/atom q +compute q2 type2 reduce ave c_charge2 +variable qtot equal count(type1)*c_q1+count(type2)*c_q2 +variable nqeq equal f_2 + +thermo_style custom step pe c_q1 c_q2 v_qtot v_nqeq +thermo 10 +thermo_modify format line "%4d %12.9g %12.8f %12.8f %16.12f %6.0f" + +timestep 0.0001 + +fix 1 all nve diff --git a/examples/qeq/in.qeq.buck b/examples/qeq/in.qeq.buck index 2258a9e2ae..4b74b44186 100644 --- a/examples/qeq/in.qeq.buck +++ b/examples/qeq/in.qeq.buck @@ -1,41 +1,68 @@ # This example demonstrates the use of various fix qeq variants with -# that defines and uses charges, in this case pair_style buck/coul/long +# a pair style using charges, in this case pair_style buck/coul/long units metal atom_style charge read_data data.aC -replicate 2 2 2 +#replicate 2 2 2 pair_style buck/coul/long 12.0 pair_coeff 2 2 1388.77 .3623188 175.0 pair_coeff 1 2 18003 .2052124 133.5381 pair_coeff 1 1 0 .1 0 -kspace_style ewald 1e-6 -neighbor 1.0 bin -neigh_modify delay 0 every 1 check yes +fix 2 all qeq/shielded 1 10 1.0e-20 10 param.qeq2 -group type1 type 1 -compute charge1 type1 property/atom q -compute q1 type1 reduce ave c_charge1 -group type2 type 2 -compute charge2 type2 property/atom q -compute q2 type2 reduce ave c_charge2 -variable qtot equal count(type1)*c_q1+count(type2)*c_q2 - -thermo_style custom step pe c_q1 c_q2 v_qtot -thermo 10 - -timestep 0.0001 +include buck.inc velocity all create 300.0 1281937 -fix 1 all nve +run 0 post no -#fix 2 all qeq/point 1 10 1.0e-6 100 param.qeq2 -#fix 2 all qeq/shielded 1 10 1.0e-6 100 param.qeq2 -#fix 2 all qeq/slater 1 10 1.0e-6 100 param.qeq2 -#fix 2 all qeq/dynamic 1 10 1.0e-4 100 param.qeq2 -fix 2 all qeq/fire 1 10 1.0e-4 100 param.qeq2 +write_restart qeq.restart -run 100 +clear + +print "Using fix qeq/point" +read_restart qeq.restart +fix 2 all qeq/point 1 10 1.0e-6 100 param.qeq2 +include buck.inc + +run 100 + +clear + +print "Using fix qeq/shielded" +read_restart qeq.restart +fix 2 all qeq/shielded 1 10 1.0e-6 100 param.qeq2 +include buck.inc + +run 100 + + +clear + +print "Using fix qeq/slater" +read_restart qeq.restart +fix 2 all qeq/shielded 1 10 1.0e-6 100 param.qeq2 +include buck.inc + +run 100 + +clear + +print "Using fix qeq/dynamic" +read_restart qeq.restart +fix 2 all qeq/dynamic 1 10 1.0e-3 100 param.qeq2 +include buck.inc + +run 100 + +clear + +print "Using fix qeq/fire" +read_restart qeq.restart +fix 2 all qeq/fire 1 10 1.0e-3 100 param.qeq2 +include buck.inc + +run 100 diff --git a/examples/qeq/log.20Apr21.qeq.buck.g++.1 b/examples/qeq/log.20Apr21.qeq.buck.g++.1 new file mode 100644 index 0000000000..d5b41867b1 --- /dev/null +++ b/examples/qeq/log.20Apr21.qeq.buck.g++.1 @@ -0,0 +1,650 @@ +LAMMPS (8 Apr 2021) + using 1 OpenMP thread(s) per MPI task +# This example demonstrates the use of various fix qeq variants with +# a pair style using charges, in this case pair_style buck/coul/long + +units metal +atom_style charge + +read_data data.aC +Reading data file ... + orthogonal box = (0.0000000 0.0000000 0.0000000) to (25.158320 25.158320 28.020256) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 1200 atoms + read_data CPU = 0.009 seconds +#replicate 2 2 2 + +pair_style buck/coul/long 12.0 +pair_coeff 2 2 1388.77 .3623188 175.0 +pair_coeff 1 2 18003 .2052124 133.5381 +pair_coeff 1 1 0 .1 0 + +fix 2 all qeq/shielded 1 10 1.0e-20 10 param.qeq2 + +include buck.inc + +kspace_style pppm 1e-6 + +neighbor 1.0 bin +neigh_modify delay 0 every 1 check yes + +group type1 type 1 +400 atoms in group type1 +compute charge1 type1 property/atom q +compute q1 type1 reduce ave c_charge1 +group type2 type 2 +800 atoms in group type2 +compute charge2 type2 property/atom q +compute q2 type2 reduce ave c_charge2 +variable qtot equal count(type1)*c_q1+count(type2)*c_q2 +variable nqeq equal f_2 + +thermo_style custom step pe c_q1 c_q2 v_qtot v_nqeq +thermo 10 +thermo_modify format line "%4d %12.9g %12.8f %12.8f %16.12f %6.0f" + +timestep 0.0001 + +fix 1 all nve + +velocity all create 300.0 1281937 +run 0 post no +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:339) + G vector (1/distance) = 0.30705229 + grid = 48 48 54 + stencil order = 5 + estimated absolute RMS force accuracy = 1.8909403e-05 + estimated relative force accuracy = 1.3131854e-06 + using double precision FFTW3 + 3d grid and FFT values/proc = 184525 124416 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13 + ghost atom cutoff = 13 + binsize = 6.5, bins = 4 4 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair buck/coul/long, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) fix qeq/shielded, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +WARNING: Fix qeq CG convergence failed (4.357840257025601e-19) after 10 iterations at step 0 (src/QEQ/fix_qeq.cpp:410) +WARNING: Fix qeq CG convergence failed (5.274094378414531e-18) after 10 iterations at step 0 (src/QEQ/fix_qeq.cpp:410) +Per MPI rank memory allocation (min/avg/max) = 38.75 | 38.75 | 38.75 Mbytes +Step PotEng c_q1 c_q2 v_qtot v_nqeq + 0 -2879.00327 0.76536977 -0.38268489 0.000000000000 10 +Loop time of 1.66893e-06 on 1 procs for 0 steps with 1200 atoms + + +write_restart qeq.restart +System init for write_restart ... +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:339) + G vector (1/distance) = 0.27644401 + grid = 27 27 30 + stencil order = 5 + estimated absolute RMS force accuracy = 1.4502702e-05 + estimated relative force accuracy = 1.0071569e-06 + using double precision FFTW3 + 3d grid and FFT values/proc = 42772 21870 + +clear + using 1 OpenMP thread(s) per MPI task + +print "Using fix qeq/point" +Using fix qeq/point +read_restart qeq.restart +Reading restart file ... + restart file = 8 Apr 2021, LAMMPS = 8 Apr 2021 + restoring atom style charge from restart + orthogonal box = (0.0000000 0.0000000 0.0000000) to (25.158320 25.158320 28.020256) + 1 by 1 by 1 MPI processor grid + restoring pair style buck/coul/long from restart + 1200 atoms + read_restart CPU = 0.001 seconds +fix 2 all qeq/point 1 10 1.0e-6 100 param.qeq2 +include buck.inc + +kspace_style pppm 1e-6 + +neighbor 1.0 bin +neigh_modify delay 0 every 1 check yes + +group type1 type 1 +400 atoms in group type1 +compute charge1 type1 property/atom q +compute q1 type1 reduce ave c_charge1 +group type2 type 2 +800 atoms in group type2 +compute charge2 type2 property/atom q +compute q2 type2 reduce ave c_charge2 +variable qtot equal count(type1)*c_q1+count(type2)*c_q2 +variable nqeq equal f_2 + +thermo_style custom step pe c_q1 c_q2 v_qtot v_nqeq +thermo 10 +thermo_modify format line "%4d %12.9g %12.8f %12.8f %16.12f %6.0f" + +timestep 0.0001 + +fix 1 all nve + +run 100 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:339) + G vector (1/distance) = 0.27644401 + grid = 27 27 30 + stencil order = 5 + estimated absolute RMS force accuracy = 1.4502702e-05 + estimated relative force accuracy = 1.0071569e-06 + using double precision FFTW3 + 3d grid and FFT values/proc = 42772 21870 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13 + ghost atom cutoff = 13 + binsize = 6.5, bins = 4 4 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair buck/coul/long, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) fix qeq/point, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 24.69 | 24.69 | 24.69 Mbytes +Step PotEng c_q1 c_q2 v_qtot v_nqeq + 0 -3432.17988 0.85228288 -0.42614144 -0.000000000000 3 + 10 -3452.03328 0.85475605 -0.42737803 -0.000000000000 8 + 20 -3497.57515 0.85994936 -0.42997468 0.000000000000 8 + 30 -3568.22095 0.86767937 -0.43383969 0.000000000001 8 + 40 -3633.24956 0.87335551 -0.43667775 0.000000000000 8 + 50 -3700.10219 0.87805056 -0.43902528 0.000000000000 8 + 60 -3784.36769 0.88402303 -0.44201151 -0.000000000000 8 + 70 -3877.51378 0.89008950 -0.44504475 0.000000000000 8 + 80 -3965.29722 0.89431515 -0.44715757 -0.000000000001 8 + 90 -4048.36764 0.89698588 -0.44849294 0.000000000000 8 + 100 -4118.65809 0.89719102 -0.44859551 0.000000000000 8 +Loop time of 11.5935 on 1 procs for 100 steps with 1200 atoms + +Performance: 0.075 ns/day, 322.041 hours/ns, 8.626 timesteps/s +99.9% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 2.8257 | 2.8257 | 2.8257 | 0.0 | 24.37 +Kspace | 1.2136 | 1.2136 | 1.2136 | 0.0 | 10.47 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.015541 | 0.015541 | 0.015541 | 0.0 | 0.13 +Output | 0.0014489 | 0.0014489 | 0.0014489 | 0.0 | 0.01 +Modify | 7.5351 | 7.5351 | 7.5351 | 0.0 | 64.99 +Other | | 0.00206 | | | 0.02 + +Nlocal: 1200.00 ave 1200 max 1200 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 8100.00 ave 8100 max 8100 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 367600.0 ave 367600 max 367600 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 735200.0 ave 735200 max 735200 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 735200 +Ave neighs/atom = 612.66667 +Neighbor list builds = 0 +Dangerous builds = 0 + +clear + using 1 OpenMP thread(s) per MPI task + +print "Using fix qeq/shielded" +Using fix qeq/shielded +read_restart qeq.restart +Reading restart file ... + restart file = 8 Apr 2021, LAMMPS = 8 Apr 2021 + restoring atom style charge from restart + orthogonal box = (0.0000000 0.0000000 0.0000000) to (25.158320 25.158320 28.020256) + 1 by 1 by 1 MPI processor grid + restoring pair style buck/coul/long from restart + 1200 atoms + read_restart CPU = 0.001 seconds +fix 2 all qeq/shielded 1 10 1.0e-6 100 param.qeq2 +include buck.inc + +kspace_style pppm 1e-6 + +neighbor 1.0 bin +neigh_modify delay 0 every 1 check yes + +group type1 type 1 +400 atoms in group type1 +compute charge1 type1 property/atom q +compute q1 type1 reduce ave c_charge1 +group type2 type 2 +800 atoms in group type2 +compute charge2 type2 property/atom q +compute q2 type2 reduce ave c_charge2 +variable qtot equal count(type1)*c_q1+count(type2)*c_q2 +variable nqeq equal f_2 + +thermo_style custom step pe c_q1 c_q2 v_qtot v_nqeq +thermo 10 +thermo_modify format line "%4d %12.9g %12.8f %12.8f %16.12f %6.0f" + +timestep 0.0001 + +fix 1 all nve + +run 100 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:339) + G vector (1/distance) = 0.27644401 + grid = 27 27 30 + stencil order = 5 + estimated absolute RMS force accuracy = 1.4502702e-05 + estimated relative force accuracy = 1.0071569e-06 + using double precision FFTW3 + 3d grid and FFT values/proc = 42772 21870 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13 + ghost atom cutoff = 13 + binsize = 6.5, bins = 4 4 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair buck/coul/long, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) fix qeq/shielded, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 24.69 | 24.69 | 24.69 Mbytes +Step PotEng c_q1 c_q2 v_qtot v_nqeq + 0 -2879.00309 0.76536977 -0.38268489 -0.000000000000 3 + 10 -2882.50998 0.76536972 -0.38268486 0.000000000000 2 + 20 -2893.89472 0.76536950 -0.38268475 0.000000000000 2 + 30 -2913.6181 0.76536875 -0.38268438 0.000000000001 1 + 40 -2942.24129 0.76536939 -0.38268470 -0.000000000001 1 + 50 -2980.18817 0.76536780 -0.38268390 0.000000000000 2 + 60 -3027.60957 0.76536804 -0.38268402 0.000000000000 2 + 70 -3084.12552 0.76536573 -0.38268287 0.000000000000 2 + 80 -3148.8697 0.76536550 -0.38268275 0.000000000001 1 + 90 -3220.43086 0.76536380 -0.38268190 0.000000000000 2 + 100 -3297.0618 0.76536251 -0.38268126 0.000000000000 2 +Loop time of 7.93936 on 1 procs for 100 steps with 1200 atoms + +Performance: 0.109 ns/day, 220.538 hours/ns, 12.595 timesteps/s +99.9% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 2.8061 | 2.8061 | 2.8061 | 0.0 | 35.34 +Kspace | 1.2176 | 1.2176 | 1.2176 | 0.0 | 15.34 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.015528 | 0.015528 | 0.015528 | 0.0 | 0.20 +Output | 0.0014365 | 0.0014365 | 0.0014365 | 0.0 | 0.02 +Modify | 3.8966 | 3.8966 | 3.8966 | 0.0 | 49.08 +Other | | 0.002076 | | | 0.03 + +Nlocal: 1200.00 ave 1200 max 1200 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 8100.00 ave 8100 max 8100 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 367600.0 ave 367600 max 367600 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 735200.0 ave 735200 max 735200 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 735200 +Ave neighs/atom = 612.66667 +Neighbor list builds = 0 +Dangerous builds = 0 + + +clear + using 1 OpenMP thread(s) per MPI task + +print "Using fix qeq/slater" +Using fix qeq/slater +read_restart qeq.restart +Reading restart file ... + restart file = 8 Apr 2021, LAMMPS = 8 Apr 2021 + restoring atom style charge from restart + orthogonal box = (0.0000000 0.0000000 0.0000000) to (25.158320 25.158320 28.020256) + 1 by 1 by 1 MPI processor grid + restoring pair style buck/coul/long from restart + 1200 atoms + read_restart CPU = 0.001 seconds +fix 2 all qeq/shielded 1 10 1.0e-6 100 param.qeq2 +include buck.inc + +kspace_style pppm 1e-6 + +neighbor 1.0 bin +neigh_modify delay 0 every 1 check yes + +group type1 type 1 +400 atoms in group type1 +compute charge1 type1 property/atom q +compute q1 type1 reduce ave c_charge1 +group type2 type 2 +800 atoms in group type2 +compute charge2 type2 property/atom q +compute q2 type2 reduce ave c_charge2 +variable qtot equal count(type1)*c_q1+count(type2)*c_q2 +variable nqeq equal f_2 + +thermo_style custom step pe c_q1 c_q2 v_qtot v_nqeq +thermo 10 +thermo_modify format line "%4d %12.9g %12.8f %12.8f %16.12f %6.0f" + +timestep 0.0001 + +fix 1 all nve + +run 100 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:339) + G vector (1/distance) = 0.27644401 + grid = 27 27 30 + stencil order = 5 + estimated absolute RMS force accuracy = 1.4502702e-05 + estimated relative force accuracy = 1.0071569e-06 + using double precision FFTW3 + 3d grid and FFT values/proc = 42772 21870 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13 + ghost atom cutoff = 13 + binsize = 6.5, bins = 4 4 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair buck/coul/long, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) fix qeq/shielded, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 24.69 | 24.69 | 24.69 Mbytes +Step PotEng c_q1 c_q2 v_qtot v_nqeq + 0 -2879.00309 0.76536977 -0.38268489 -0.000000000000 3 + 10 -2882.50998 0.76536972 -0.38268486 0.000000000000 2 + 20 -2893.89472 0.76536950 -0.38268475 0.000000000000 2 + 30 -2913.6181 0.76536875 -0.38268438 0.000000000001 1 + 40 -2942.24129 0.76536939 -0.38268470 -0.000000000001 1 + 50 -2980.18817 0.76536780 -0.38268390 0.000000000000 2 + 60 -3027.60957 0.76536804 -0.38268402 0.000000000000 2 + 70 -3084.12552 0.76536573 -0.38268287 0.000000000000 2 + 80 -3148.8697 0.76536550 -0.38268275 0.000000000001 1 + 90 -3220.43086 0.76536380 -0.38268190 0.000000000000 2 + 100 -3297.0618 0.76536251 -0.38268126 0.000000000000 2 +Loop time of 7.9652 on 1 procs for 100 steps with 1200 atoms + +Performance: 0.108 ns/day, 221.256 hours/ns, 12.555 timesteps/s +99.9% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 2.809 | 2.809 | 2.809 | 0.0 | 35.27 +Kspace | 1.2214 | 1.2214 | 1.2214 | 0.0 | 15.33 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.015635 | 0.015635 | 0.015635 | 0.0 | 0.20 +Output | 0.0014393 | 0.0014393 | 0.0014393 | 0.0 | 0.02 +Modify | 3.9157 | 3.9157 | 3.9157 | 0.0 | 49.16 +Other | | 0.002091 | | | 0.03 + +Nlocal: 1200.00 ave 1200 max 1200 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 8100.00 ave 8100 max 8100 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 367600.0 ave 367600 max 367600 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 735200.0 ave 735200 max 735200 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 735200 +Ave neighs/atom = 612.66667 +Neighbor list builds = 0 +Dangerous builds = 0 + +clear + using 1 OpenMP thread(s) per MPI task + +print "Using fix qeq/dynamic" +Using fix qeq/dynamic +read_restart qeq.restart +Reading restart file ... + restart file = 8 Apr 2021, LAMMPS = 8 Apr 2021 + restoring atom style charge from restart + orthogonal box = (0.0000000 0.0000000 0.0000000) to (25.158320 25.158320 28.020256) + 1 by 1 by 1 MPI processor grid + restoring pair style buck/coul/long from restart + 1200 atoms + read_restart CPU = 0.001 seconds +fix 2 all qeq/dynamic 1 10 1.0e-3 100 param.qeq2 +include buck.inc + +kspace_style pppm 1e-6 + +neighbor 1.0 bin +neigh_modify delay 0 every 1 check yes + +group type1 type 1 +400 atoms in group type1 +compute charge1 type1 property/atom q +compute q1 type1 reduce ave c_charge1 +group type2 type 2 +800 atoms in group type2 +compute charge2 type2 property/atom q +compute q2 type2 reduce ave c_charge2 +variable qtot equal count(type1)*c_q1+count(type2)*c_q2 +variable nqeq equal f_2 + +thermo_style custom step pe c_q1 c_q2 v_qtot v_nqeq +thermo 10 +thermo_modify format line "%4d %12.9g %12.8f %12.8f %16.12f %6.0f" + +timestep 0.0001 + +fix 1 all nve + +run 100 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:339) + G vector (1/distance) = 0.27644401 + grid = 27 27 30 + stencil order = 5 + estimated absolute RMS force accuracy = 1.4502702e-05 + estimated relative force accuracy = 1.0071569e-06 + using double precision FFTW3 + 3d grid and FFT values/proc = 42772 21870 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13 + ghost atom cutoff = 13 + binsize = 6.5, bins = 4 4 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair buck/coul/long, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d/newton + bin: standard + (2) fix qeq/dynamic, perpetual, copy from (1) + attributes: half, newton on + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 17.87 | 17.87 | 17.87 Mbytes +Step PotEng c_q1 c_q2 v_qtot v_nqeq + 0 -3432.38094 0.85231286 -0.42615643 0.000000000001 43 + 10 -3452.05217 0.85475894 -0.42737947 -0.000000000001 17 + 20 -3497.8643 0.85999180 -0.42999590 -0.000000000007 22 + 30 -3568.53169 0.86772479 -0.43386239 -0.000000000006 22 + 40 -3633.43753 0.87338291 -0.43669146 -0.000000000006 22 + 50 -3700.27953 0.87807632 -0.43903816 -0.000000000005 22 + 60 -3784.4004 0.88402822 -0.44201411 0.000000000002 17 + 70 -3877.73706 0.89012201 -0.44506100 0.000000000002 22 + 80 -3965.36111 0.89432486 -0.44716243 0.000000000008 17 + 90 -4048.57901 0.89701688 -0.44850844 -0.000000000004 22 + 100 -4118.62736 0.89718691 -0.44859346 -0.000000000026 17 +Loop time of 18.5333 on 1 procs for 100 steps with 1200 atoms + +Performance: 0.047 ns/day, 514.815 hours/ns, 5.396 timesteps/s +99.9% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 2.8268 | 2.8268 | 2.8268 | 0.0 | 15.25 +Kspace | 1.2138 | 1.2138 | 1.2138 | 0.0 | 6.55 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.015407 | 0.015407 | 0.015407 | 0.0 | 0.08 +Output | 0.0014303 | 0.0014303 | 0.0014303 | 0.0 | 0.01 +Modify | 14.474 | 14.474 | 14.474 | 0.0 | 78.10 +Other | | 0.001973 | | | 0.01 + +Nlocal: 1200.00 ave 1200 max 1200 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 8100.00 ave 8100 max 8100 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 367600.0 ave 367600 max 367600 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 367600 +Ave neighs/atom = 306.33333 +Neighbor list builds = 0 +Dangerous builds = 0 + +clear + using 1 OpenMP thread(s) per MPI task + +print "Using fix qeq/fire" +Using fix qeq/fire +read_restart qeq.restart +Reading restart file ... + restart file = 8 Apr 2021, LAMMPS = 8 Apr 2021 + restoring atom style charge from restart + orthogonal box = (0.0000000 0.0000000 0.0000000) to (25.158320 25.158320 28.020256) + 1 by 1 by 1 MPI processor grid + restoring pair style buck/coul/long from restart + 1200 atoms + read_restart CPU = 0.001 seconds +fix 2 all qeq/fire 1 10 1.0e-3 100 param.qeq2 +include buck.inc + +kspace_style pppm 1e-6 + +neighbor 1.0 bin +neigh_modify delay 0 every 1 check yes + +group type1 type 1 +400 atoms in group type1 +compute charge1 type1 property/atom q +compute q1 type1 reduce ave c_charge1 +group type2 type 2 +800 atoms in group type2 +compute charge2 type2 property/atom q +compute q2 type2 reduce ave c_charge2 +variable qtot equal count(type1)*c_q1+count(type2)*c_q2 +variable nqeq equal f_2 + +thermo_style custom step pe c_q1 c_q2 v_qtot v_nqeq +thermo 10 +thermo_modify format line "%4d %12.9g %12.8f %12.8f %16.12f %6.0f" + +timestep 0.0001 + +fix 1 all nve + +run 100 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:339) + G vector (1/distance) = 0.27644401 + grid = 27 27 30 + stencil order = 5 + estimated absolute RMS force accuracy = 1.4502702e-05 + estimated relative force accuracy = 1.0071569e-06 + using double precision FFTW3 + 3d grid and FFT values/proc = 42772 21870 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13 + ghost atom cutoff = 13 + binsize = 6.5, bins = 4 4 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair buck/coul/long, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d/newton + bin: standard + (2) fix qeq/fire, perpetual, copy from (1) + attributes: half, newton on + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 17.87 | 17.87 | 17.87 Mbytes +Step PotEng c_q1 c_q2 v_qtot v_nqeq + 0 -3432.06113 0.85226679 -0.42613339 0.000000000004 37 + 10 -3452.0494 0.85475813 -0.42737906 0.000000000001 10 + 20 -3497.83503 0.85998739 -0.42999370 0.000000000003 13 + 30 -3568.47507 0.86771599 -0.43385799 0.000000000004 13 + 40 -3633.35368 0.87337029 -0.43668514 0.000000000004 13 + 50 -3700.15601 0.87805847 -0.43902924 0.000000000005 13 + 60 -3784.32042 0.88401635 -0.44200818 0.000000000000 11 + 70 -3877.59818 0.89010162 -0.44505081 0.000000000000 13 + 80 -3965.28426 0.89431356 -0.44715678 0.000000000000 11 + 90 -4048.3338 0.89698069 -0.44849034 0.000000000001 13 + 100 -4118.63638 0.89718818 -0.44859409 0.000000000003 12 +Loop time of 13.0492 on 1 procs for 100 steps with 1200 atoms + +Performance: 0.066 ns/day, 362.479 hours/ns, 7.663 timesteps/s +99.9% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 2.7996 | 2.7996 | 2.7996 | 0.0 | 21.45 +Kspace | 1.2141 | 1.2141 | 1.2141 | 0.0 | 9.30 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.015527 | 0.015527 | 0.015527 | 0.0 | 0.12 +Output | 0.0014405 | 0.0014405 | 0.0014405 | 0.0 | 0.01 +Modify | 9.0166 | 9.0166 | 9.0166 | 0.0 | 69.10 +Other | | 0.001981 | | | 0.02 + +Nlocal: 1200.00 ave 1200 max 1200 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 8100.00 ave 8100 max 8100 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 367600.0 ave 367600 max 367600 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 367600 +Ave neighs/atom = 306.33333 +Neighbor list builds = 0 +Dangerous builds = 0 +Total wall time: 0:01:00 diff --git a/examples/qeq/log.20Apr21.qeq.buck.g++.4 b/examples/qeq/log.20Apr21.qeq.buck.g++.4 new file mode 100644 index 0000000000..cafa94bae9 --- /dev/null +++ b/examples/qeq/log.20Apr21.qeq.buck.g++.4 @@ -0,0 +1,650 @@ +LAMMPS (8 Apr 2021) + using 1 OpenMP thread(s) per MPI task +# This example demonstrates the use of various fix qeq variants with +# a pair style using charges, in this case pair_style buck/coul/long + +units metal +atom_style charge + +read_data data.aC +Reading data file ... + orthogonal box = (0.0000000 0.0000000 0.0000000) to (25.158320 25.158320 28.020256) + 1 by 2 by 2 MPI processor grid + reading atoms ... + 1200 atoms + read_data CPU = 0.009 seconds +#replicate 2 2 2 + +pair_style buck/coul/long 12.0 +pair_coeff 2 2 1388.77 .3623188 175.0 +pair_coeff 1 2 18003 .2052124 133.5381 +pair_coeff 1 1 0 .1 0 + +fix 2 all qeq/shielded 1 10 1.0e-20 10 param.qeq2 + +include buck.inc + +kspace_style pppm 1e-6 + +neighbor 1.0 bin +neigh_modify delay 0 every 1 check yes + +group type1 type 1 +400 atoms in group type1 +compute charge1 type1 property/atom q +compute q1 type1 reduce ave c_charge1 +group type2 type 2 +800 atoms in group type2 +compute charge2 type2 property/atom q +compute q2 type2 reduce ave c_charge2 +variable qtot equal count(type1)*c_q1+count(type2)*c_q2 +variable nqeq equal f_2 + +thermo_style custom step pe c_q1 c_q2 v_qtot v_nqeq +thermo 10 +thermo_modify format line "%4d %12.9g %12.8f %12.8f %16.12f %6.0f" + +timestep 0.0001 + +fix 1 all nve + +velocity all create 300.0 1281937 +run 0 post no +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:339) + G vector (1/distance) = 0.30705229 + grid = 48 48 54 + stencil order = 5 + estimated absolute RMS force accuracy = 1.8909403e-05 + estimated relative force accuracy = 1.3131854e-06 + using double precision FFTW3 + 3d grid and FFT values/proc = 57970 32256 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13 + ghost atom cutoff = 13 + binsize = 6.5, bins = 4 4 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair buck/coul/long, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) fix qeq/shielded, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +WARNING: Fix qeq CG convergence failed (4.299911728887494e-19) after 10 iterations at step 0 (src/QEQ/fix_qeq.cpp:410) +WARNING: Fix qeq CG convergence failed (5.273380778822746e-18) after 10 iterations at step 0 (src/QEQ/fix_qeq.cpp:410) +Per MPI rank memory allocation (min/avg/max) = 14.97 | 15.02 | 15.08 Mbytes +Step PotEng c_q1 c_q2 v_qtot v_nqeq + 0 -2879.00327 0.76536977 -0.38268489 0.000000000000 10 +Loop time of 3.33786e-06 on 4 procs for 0 steps with 1200 atoms + + +write_restart qeq.restart +System init for write_restart ... +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:339) + G vector (1/distance) = 0.27644401 + grid = 27 27 30 + stencil order = 5 + estimated absolute RMS force accuracy = 1.4502702e-05 + estimated relative force accuracy = 1.0071569e-06 + using double precision FFTW3 + 3d grid and FFT values/proc = 14960 5832 + +clear + using 1 OpenMP thread(s) per MPI task + +print "Using fix qeq/point" +Using fix qeq/point +read_restart qeq.restart +Reading restart file ... + restart file = 8 Apr 2021, LAMMPS = 8 Apr 2021 + restoring atom style charge from restart + orthogonal box = (0.0000000 0.0000000 0.0000000) to (25.158320 25.158320 28.020256) + 1 by 2 by 2 MPI processor grid + restoring pair style buck/coul/long from restart + 1200 atoms + read_restart CPU = 0.001 seconds +fix 2 all qeq/point 1 10 1.0e-6 100 param.qeq2 +include buck.inc + +kspace_style pppm 1e-6 + +neighbor 1.0 bin +neigh_modify delay 0 every 1 check yes + +group type1 type 1 +400 atoms in group type1 +compute charge1 type1 property/atom q +compute q1 type1 reduce ave c_charge1 +group type2 type 2 +800 atoms in group type2 +compute charge2 type2 property/atom q +compute q2 type2 reduce ave c_charge2 +variable qtot equal count(type1)*c_q1+count(type2)*c_q2 +variable nqeq equal f_2 + +thermo_style custom step pe c_q1 c_q2 v_qtot v_nqeq +thermo 10 +thermo_modify format line "%4d %12.9g %12.8f %12.8f %16.12f %6.0f" + +timestep 0.0001 + +fix 1 all nve + +run 100 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:339) + G vector (1/distance) = 0.27644401 + grid = 27 27 30 + stencil order = 5 + estimated absolute RMS force accuracy = 1.4502702e-05 + estimated relative force accuracy = 1.0071569e-06 + using double precision FFTW3 + 3d grid and FFT values/proc = 14960 5832 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13 + ghost atom cutoff = 13 + binsize = 6.5, bins = 4 4 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair buck/coul/long, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) fix qeq/point, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 11.10 | 11.14 | 11.16 Mbytes +Step PotEng c_q1 c_q2 v_qtot v_nqeq + 0 -3432.17988 0.85228288 -0.42614144 -0.000000000000 3 + 10 -3452.03328 0.85475605 -0.42737803 -0.000000000000 8 + 20 -3497.57515 0.85994936 -0.42997468 0.000000000000 8 + 30 -3568.22095 0.86767937 -0.43383969 0.000000000000 8 + 40 -3633.24956 0.87335551 -0.43667775 -0.000000000000 8 + 50 -3700.10219 0.87805056 -0.43902528 0.000000000000 8 + 60 -3784.36769 0.88402303 -0.44201151 0.000000000000 8 + 70 -3877.51378 0.89008950 -0.44504475 0.000000000000 8 + 80 -3965.29722 0.89431515 -0.44715757 0.000000000000 8 + 90 -4048.36764 0.89698588 -0.44849294 -0.000000000000 8 + 100 -4118.65809 0.89719102 -0.44859551 0.000000000000 8 +Loop time of 3.30911 on 4 procs for 100 steps with 1200 atoms + +Performance: 0.261 ns/day, 91.920 hours/ns, 30.220 timesteps/s +99.0% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.67613 | 0.68904 | 0.71562 | 1.9 | 20.82 +Kspace | 0.36056 | 0.3881 | 0.39892 | 2.6 | 11.73 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.013339 | 0.017982 | 0.019974 | 2.0 | 0.54 +Output | 0.0006721 | 0.00099713 | 0.0019572 | 0.0 | 0.03 +Modify | 2.2109 | 2.211 | 2.211 | 0.0 | 66.81 +Other | | 0.002041 | | | 0.06 + +Nlocal: 300.000 ave 300 max 300 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Nghost: 4875.00 ave 4880 max 4870 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +Neighs: 91900.0 ave 91900 max 91900 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +FullNghs: 183800.0 ave 183800 max 183800 min +Histogram: 4 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 735200 +Ave neighs/atom = 612.66667 +Neighbor list builds = 0 +Dangerous builds = 0 + +clear + using 1 OpenMP thread(s) per MPI task + +print "Using fix qeq/shielded" +Using fix qeq/shielded +read_restart qeq.restart +Reading restart file ... + restart file = 8 Apr 2021, LAMMPS = 8 Apr 2021 + restoring atom style charge from restart + orthogonal box = (0.0000000 0.0000000 0.0000000) to (25.158320 25.158320 28.020256) + 1 by 2 by 2 MPI processor grid + restoring pair style buck/coul/long from restart + 1200 atoms + read_restart CPU = 0.006 seconds +fix 2 all qeq/shielded 1 10 1.0e-6 100 param.qeq2 +include buck.inc + +kspace_style pppm 1e-6 + +neighbor 1.0 bin +neigh_modify delay 0 every 1 check yes + +group type1 type 1 +400 atoms in group type1 +compute charge1 type1 property/atom q +compute q1 type1 reduce ave c_charge1 +group type2 type 2 +800 atoms in group type2 +compute charge2 type2 property/atom q +compute q2 type2 reduce ave c_charge2 +variable qtot equal count(type1)*c_q1+count(type2)*c_q2 +variable nqeq equal f_2 + +thermo_style custom step pe c_q1 c_q2 v_qtot v_nqeq +thermo 10 +thermo_modify format line "%4d %12.9g %12.8f %12.8f %16.12f %6.0f" + +timestep 0.0001 + +fix 1 all nve + +run 100 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:339) + G vector (1/distance) = 0.27644401 + grid = 27 27 30 + stencil order = 5 + estimated absolute RMS force accuracy = 1.4502702e-05 + estimated relative force accuracy = 1.0071569e-06 + using double precision FFTW3 + 3d grid and FFT values/proc = 14960 5832 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13 + ghost atom cutoff = 13 + binsize = 6.5, bins = 4 4 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair buck/coul/long, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) fix qeq/shielded, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 11.10 | 11.14 | 11.16 Mbytes +Step PotEng c_q1 c_q2 v_qtot v_nqeq + 0 -2879.00309 0.76536977 -0.38268489 0.000000000000 3 + 10 -2882.50998 0.76536972 -0.38268486 0.000000000000 2 + 20 -2893.89472 0.76536950 -0.38268475 -0.000000000000 2 + 30 -2913.6181 0.76536875 -0.38268438 -0.000000000000 1 + 40 -2942.24129 0.76536939 -0.38268470 0.000000000000 1 + 50 -2980.18817 0.76536780 -0.38268390 0.000000000000 2 + 60 -3027.60957 0.76536804 -0.38268402 -0.000000000000 2 + 70 -3084.12552 0.76536573 -0.38268287 0.000000000000 2 + 80 -3148.8697 0.76536550 -0.38268275 0.000000000000 1 + 90 -3220.43086 0.76536380 -0.38268190 0.000000000000 2 + 100 -3297.0618 0.76536251 -0.38268126 0.000000000000 2 +Loop time of 2.25559 on 4 procs for 100 steps with 1200 atoms + +Performance: 0.383 ns/day, 62.655 hours/ns, 44.334 timesteps/s +97.9% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.67442 | 0.69181 | 0.70907 | 2.0 | 30.67 +Kspace | 0.39381 | 0.41151 | 0.43023 | 2.6 | 18.24 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.012851 | 0.01426 | 0.015146 | 0.7 | 0.63 +Output | 0.00066686 | 0.00098681 | 0.0019395 | 0.0 | 0.04 +Modify | 1.1349 | 1.135 | 1.135 | 0.0 | 50.32 +Other | | 0.002035 | | | 0.09 + +Nlocal: 300.000 ave 300 max 300 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Nghost: 4875.00 ave 4880 max 4870 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +Neighs: 91900.0 ave 91900 max 91900 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +FullNghs: 183800.0 ave 183800 max 183800 min +Histogram: 4 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 735200 +Ave neighs/atom = 612.66667 +Neighbor list builds = 0 +Dangerous builds = 0 + + +clear + using 1 OpenMP thread(s) per MPI task + +print "Using fix qeq/slater" +Using fix qeq/slater +read_restart qeq.restart +Reading restart file ... + restart file = 8 Apr 2021, LAMMPS = 8 Apr 2021 + restoring atom style charge from restart + orthogonal box = (0.0000000 0.0000000 0.0000000) to (25.158320 25.158320 28.020256) + 1 by 2 by 2 MPI processor grid + restoring pair style buck/coul/long from restart + 1200 atoms + read_restart CPU = 0.012 seconds +fix 2 all qeq/shielded 1 10 1.0e-6 100 param.qeq2 +include buck.inc + +kspace_style pppm 1e-6 + +neighbor 1.0 bin +neigh_modify delay 0 every 1 check yes + +group type1 type 1 +400 atoms in group type1 +compute charge1 type1 property/atom q +compute q1 type1 reduce ave c_charge1 +group type2 type 2 +800 atoms in group type2 +compute charge2 type2 property/atom q +compute q2 type2 reduce ave c_charge2 +variable qtot equal count(type1)*c_q1+count(type2)*c_q2 +variable nqeq equal f_2 + +thermo_style custom step pe c_q1 c_q2 v_qtot v_nqeq +thermo 10 +thermo_modify format line "%4d %12.9g %12.8f %12.8f %16.12f %6.0f" + +timestep 0.0001 + +fix 1 all nve + +run 100 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:339) + G vector (1/distance) = 0.27644401 + grid = 27 27 30 + stencil order = 5 + estimated absolute RMS force accuracy = 1.4502702e-05 + estimated relative force accuracy = 1.0071569e-06 + using double precision FFTW3 + 3d grid and FFT values/proc = 14960 5832 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13 + ghost atom cutoff = 13 + binsize = 6.5, bins = 4 4 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair buck/coul/long, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) fix qeq/shielded, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 11.10 | 11.14 | 11.16 Mbytes +Step PotEng c_q1 c_q2 v_qtot v_nqeq + 0 -2879.00309 0.76536977 -0.38268489 0.000000000000 3 + 10 -2882.50998 0.76536972 -0.38268486 0.000000000000 2 + 20 -2893.89472 0.76536950 -0.38268475 -0.000000000000 2 + 30 -2913.6181 0.76536875 -0.38268438 -0.000000000000 1 + 40 -2942.24129 0.76536939 -0.38268470 0.000000000000 1 + 50 -2980.18817 0.76536780 -0.38268390 0.000000000000 2 + 60 -3027.60957 0.76536804 -0.38268402 -0.000000000000 2 + 70 -3084.12552 0.76536573 -0.38268287 0.000000000000 2 + 80 -3148.8697 0.76536550 -0.38268275 0.000000000000 1 + 90 -3220.43086 0.76536380 -0.38268190 0.000000000000 2 + 100 -3297.0618 0.76536251 -0.38268126 0.000000000000 2 +Loop time of 2.39249 on 4 procs for 100 steps with 1200 atoms + +Performance: 0.361 ns/day, 66.458 hours/ns, 41.797 timesteps/s +96.0% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.6751 | 0.70301 | 0.71919 | 2.1 | 29.38 +Kspace | 0.45569 | 0.47315 | 0.49885 | 2.6 | 19.78 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.012967 | 0.018681 | 0.020909 | 2.4 | 0.78 +Output | 0.00066733 | 0.00099397 | 0.0019579 | 0.0 | 0.04 +Modify | 1.1945 | 1.1946 | 1.1947 | 0.0 | 49.93 +Other | | 0.002046 | | | 0.09 + +Nlocal: 300.000 ave 300 max 300 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Nghost: 4875.00 ave 4880 max 4870 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +Neighs: 91900.0 ave 91900 max 91900 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +FullNghs: 183800.0 ave 183800 max 183800 min +Histogram: 4 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 735200 +Ave neighs/atom = 612.66667 +Neighbor list builds = 0 +Dangerous builds = 0 + +clear + using 1 OpenMP thread(s) per MPI task + +print "Using fix qeq/dynamic" +Using fix qeq/dynamic +read_restart qeq.restart +Reading restart file ... + restart file = 8 Apr 2021, LAMMPS = 8 Apr 2021 + restoring atom style charge from restart + orthogonal box = (0.0000000 0.0000000 0.0000000) to (25.158320 25.158320 28.020256) + 1 by 2 by 2 MPI processor grid + restoring pair style buck/coul/long from restart + 1200 atoms + read_restart CPU = 0.002 seconds +fix 2 all qeq/dynamic 1 10 1.0e-3 100 param.qeq2 +include buck.inc + +kspace_style pppm 1e-6 + +neighbor 1.0 bin +neigh_modify delay 0 every 1 check yes + +group type1 type 1 +400 atoms in group type1 +compute charge1 type1 property/atom q +compute q1 type1 reduce ave c_charge1 +group type2 type 2 +800 atoms in group type2 +compute charge2 type2 property/atom q +compute q2 type2 reduce ave c_charge2 +variable qtot equal count(type1)*c_q1+count(type2)*c_q2 +variable nqeq equal f_2 + +thermo_style custom step pe c_q1 c_q2 v_qtot v_nqeq +thermo 10 +thermo_modify format line "%4d %12.9g %12.8f %12.8f %16.12f %6.0f" + +timestep 0.0001 + +fix 1 all nve + +run 100 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:339) + G vector (1/distance) = 0.27644401 + grid = 27 27 30 + stencil order = 5 + estimated absolute RMS force accuracy = 1.4502702e-05 + estimated relative force accuracy = 1.0071569e-06 + using double precision FFTW3 + 3d grid and FFT values/proc = 14960 5832 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13 + ghost atom cutoff = 13 + binsize = 6.5, bins = 4 4 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair buck/coul/long, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d/newton + bin: standard + (2) fix qeq/dynamic, perpetual, copy from (1) + attributes: half, newton on + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 9.195 | 9.246 | 9.278 Mbytes +Step PotEng c_q1 c_q2 v_qtot v_nqeq + 0 -3432.38094 0.85231286 -0.42615643 -0.000000000001 43 + 10 -3452.05217 0.85475894 -0.42737947 -0.000000000003 17 + 20 -3497.8643 0.85999180 -0.42999590 0.000000000000 22 + 30 -3568.53169 0.86772479 -0.43386239 -0.000000000000 22 + 40 -3633.43753 0.87338291 -0.43669146 0.000000000006 22 + 50 -3700.27953 0.87807632 -0.43903816 0.000000000003 22 + 60 -3784.4004 0.88402822 -0.44201411 0.000000000009 17 + 70 -3877.73706 0.89012201 -0.44506100 0.000000000010 22 + 80 -3965.36111 0.89432486 -0.44716243 0.000000000011 17 + 90 -4048.57901 0.89701688 -0.44850844 0.000000000012 22 + 100 -4118.62736 0.89718691 -0.44859346 0.000000000013 17 +Loop time of 5.27704 on 4 procs for 100 steps with 1200 atoms + +Performance: 0.164 ns/day, 146.584 hours/ns, 18.950 timesteps/s +98.5% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.68437 | 0.69096 | 0.69826 | 0.7 | 13.09 +Kspace | 0.38484 | 0.38941 | 0.39524 | 0.7 | 7.38 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.012609 | 0.01529 | 0.016842 | 1.3 | 0.29 +Output | 0.00067735 | 0.0010006 | 0.0019588 | 1.7 | 0.02 +Modify | 4.1783 | 4.1783 | 4.1784 | 0.0 | 79.18 +Other | | 0.002027 | | | 0.04 + +Nlocal: 300.000 ave 300 max 300 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Nghost: 4875.00 ave 4880 max 4870 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +Neighs: 91900.0 ave 93081 max 90719 min +Histogram: 2 0 0 0 0 0 0 0 0 2 + +Total # of neighbors = 367600 +Ave neighs/atom = 306.33333 +Neighbor list builds = 0 +Dangerous builds = 0 + +clear + using 1 OpenMP thread(s) per MPI task + +print "Using fix qeq/fire" +Using fix qeq/fire +read_restart qeq.restart +Reading restart file ... + restart file = 8 Apr 2021, LAMMPS = 8 Apr 2021 + restoring atom style charge from restart + orthogonal box = (0.0000000 0.0000000 0.0000000) to (25.158320 25.158320 28.020256) + 1 by 2 by 2 MPI processor grid + restoring pair style buck/coul/long from restart + 1200 atoms + read_restart CPU = 0.001 seconds +fix 2 all qeq/fire 1 10 1.0e-3 100 param.qeq2 +include buck.inc + +kspace_style pppm 1e-6 + +neighbor 1.0 bin +neigh_modify delay 0 every 1 check yes + +group type1 type 1 +400 atoms in group type1 +compute charge1 type1 property/atom q +compute q1 type1 reduce ave c_charge1 +group type2 type 2 +800 atoms in group type2 +compute charge2 type2 property/atom q +compute q2 type2 reduce ave c_charge2 +variable qtot equal count(type1)*c_q1+count(type2)*c_q2 +variable nqeq equal f_2 + +thermo_style custom step pe c_q1 c_q2 v_qtot v_nqeq +thermo 10 +thermo_modify format line "%4d %12.9g %12.8f %12.8f %16.12f %6.0f" + +timestep 0.0001 + +fix 1 all nve + +run 100 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:339) + G vector (1/distance) = 0.27644401 + grid = 27 27 30 + stencil order = 5 + estimated absolute RMS force accuracy = 1.4502702e-05 + estimated relative force accuracy = 1.0071569e-06 + using double precision FFTW3 + 3d grid and FFT values/proc = 14960 5832 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13 + ghost atom cutoff = 13 + binsize = 6.5, bins = 4 4 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair buck/coul/long, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d/newton + bin: standard + (2) fix qeq/fire, perpetual, copy from (1) + attributes: half, newton on + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 9.195 | 9.246 | 9.278 Mbytes +Step PotEng c_q1 c_q2 v_qtot v_nqeq + 0 -3432.05316 0.85226679 -0.42613339 0.000000000001 37 + 10 -3452.04937 0.85475813 -0.42737906 0.000000000001 10 + 20 -3497.83659 0.85998739 -0.42999370 0.000000000002 13 + 30 -3568.47793 0.86771599 -0.43385799 0.000000000002 13 + 40 -3633.35326 0.87337029 -0.43668514 0.000000000002 13 + 50 -3700.16079 0.87805847 -0.43902924 0.000000000000 13 + 60 -3784.31906 0.88401635 -0.44200818 -0.000000000001 11 + 70 -3877.60163 0.89010162 -0.44505081 -0.000000000000 13 + 80 -3965.28179 0.89431356 -0.44715678 0.000000000001 11 + 90 -4048.33861 0.89698069 -0.44849034 0.000000000001 13 + 100 -4118.63861 0.89718818 -0.44859409 0.000000000002 12 +Loop time of 3.88026 on 4 procs for 100 steps with 1200 atoms + +Performance: 0.223 ns/day, 107.785 hours/ns, 25.771 timesteps/s +98.0% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.68424 | 0.69912 | 0.73572 | 2.5 | 18.02 +Kspace | 0.38093 | 0.41715 | 0.43168 | 3.2 | 10.75 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.012711 | 0.013318 | 0.014003 | 0.4 | 0.34 +Output | 0.00066566 | 0.00098735 | 0.0019317 | 0.0 | 0.03 +Modify | 2.7477 | 2.7477 | 2.7477 | 0.0 | 70.81 +Other | | 0.002004 | | | 0.05 + +Nlocal: 300.000 ave 300 max 300 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Nghost: 4875.00 ave 4880 max 4870 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +Neighs: 91900.0 ave 93081 max 90719 min +Histogram: 2 0 0 0 0 0 0 0 0 2 + +Total # of neighbors = 367600 +Ave neighs/atom = 306.33333 +Neighbor list builds = 0 +Dangerous builds = 0 +Total wall time: 0:00:17 diff --git a/examples/qeq/log.27Nov18.qeq.buck.g++.1 b/examples/qeq/log.27Nov18.qeq.buck.g++.1 deleted file mode 100644 index 4d5225ccc3..0000000000 --- a/examples/qeq/log.27Nov18.qeq.buck.g++.1 +++ /dev/null @@ -1,118 +0,0 @@ -LAMMPS (27 Nov 2018) - using 1 OpenMP thread(s) per MPI task -# This example demonstrates the use of various fix qeq variants with -# that defines and uses charges, in this case pair_style buck/coul/long - -units metal -atom_style charge - -read_data data.aC - orthogonal box = (0 0 0) to (25.1583 25.1583 28.0203) - 1 by 1 by 1 MPI processor grid - reading atoms ... - 1200 atoms -replicate 2 2 2 - orthogonal box = (0 0 0) to (50.3166 50.3166 56.0405) - 1 by 1 by 1 MPI processor grid - 9600 atoms - Time spent = 0.00114894 secs - -pair_style buck/coul/long 12.0 -pair_coeff 2 2 1388.77 .3623188 175.0 -pair_coeff 1 2 18003 .2052124 133.5381 -pair_coeff 1 1 0 .1 0 -kspace_style ewald 1e-6 - -neighbor 1.0 bin -neigh_modify delay 0 every 1 check yes - -group type1 type 1 -3200 atoms in group type1 -compute charge1 type1 property/atom q -compute q1 type1 reduce ave c_charge1 -group type2 type 2 -6400 atoms in group type2 -compute charge2 type2 property/atom q -compute q2 type2 reduce ave c_charge2 -variable qtot equal count(type1)*c_q1+count(type2)*c_q2 - -thermo_style custom step pe c_q1 c_q2 v_qtot spcpu -thermo 10 - -timestep 0.0001 - -velocity all create 300.0 1281937 -fix 1 all nve - -#fix 2 all qeq/point 1 10 1.0e-6 100 param.qeq2 -#fix 2 all qeq/shielded 1 10 1.0e-6 100 param.qeq2 -#fix 2 all qeq/slater 1 10 1.0e-6 100 param.qeq2 -#fix 2 all qeq/dynamic 1 10 1.0e-4 100 param.qeq2 -fix 2 all qeq/fire 1 10 1.0e-4 100 param.qeq2 - -run 100 -Ewald initialization ... - using 12-bit tables for long-range coulomb (src/kspace.cpp:321) - G vector (1/distance) = 0.305064 - estimated absolute RMS force accuracy = 2.07629e-05 - estimated relative force accuracy = 1.44191e-06 - KSpace vectors: actual max1d max3d = 13556 20 34460 - kxmax kymax kzmax = 18 18 20 -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 13 - ghost atom cutoff = 13 - binsize = 6.5, bins = 8 8 9 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair buck/coul/long, perpetual - attributes: half, newton on - pair build: half/bin/atomonly/newton - stencil: half/bin/3d/newton - bin: standard - (2) fix qeq/fire, perpetual, copy from (1) - attributes: half, newton on - pair build: copy - stencil: none - bin: none -Per MPI rank memory allocation (min/avg/max) = 134 | 134 | 134 Mbytes -Step PotEng c_q1 c_q2 v_qtot S/CPU - 0 -27457.219 0.85227886 -0.42613943 -2.1827873e-10 0 - 10 -27626.057 0.85486228 -0.42743114 -2.0372681e-10 0.64313877 - 20 -27975.085 0.85968531 -0.42984266 -1.036824e-10 0.55119179 - 30 -28552.628 0.86755661 -0.4337783 1.3051249e-10 0.53160643 - 40 -29133.643 0.87426387 -0.43713193 1.1368684e-10 0.53075341 - 50 -29697.011 0.8794039 -0.43970195 1.200533e-10 0.52358127 - 60 -30342.001 0.88478594 -0.44239297 6.002665e-11 0.5366762 - 70 -31081.138 0.8906973 -0.44534865 -4.7293724e-11 0.55904546 - 80 -31792.732 0.89506635 -0.44753317 -4.3200998e-11 0.59606079 - 90 -32424.749 0.89714841 -0.44857421 -1.1596057e-10 0.58047419 - 100 -32998.353 0.89755721 -0.44877861 -1.0231815e-10 0.59444001 -Loop time of 177.79 on 1 procs for 100 steps with 9600 atoms - -Performance: 0.005 ns/day, 4938.612 hours/ns, 0.562 timesteps/s -99.8% CPU use with 1 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 11.518 | 11.518 | 11.518 | 0.0 | 6.48 -Kspace | 107.37 | 107.37 | 107.37 | 0.0 | 60.39 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.019721 | 0.019721 | 0.019721 | 0.0 | 0.01 -Output | 0.002218 | 0.002218 | 0.002218 | 0.0 | 0.00 -Modify | 58.869 | 58.869 | 58.869 | 0.0 | 33.11 -Other | | 0.007197 | | | 0.00 - -Nlocal: 9600 ave 9600 max 9600 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 22125 ave 22125 max 22125 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 2.9408e+06 ave 2.9408e+06 max 2.9408e+06 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 2940800 -Ave neighs/atom = 306.333 -Neighbor list builds = 0 -Dangerous builds = 0 -Total wall time: 0:03:01 diff --git a/examples/qeq/log.27Nov18.qeq.buck.g++.4 b/examples/qeq/log.27Nov18.qeq.buck.g++.4 deleted file mode 100644 index 947c3caeaf..0000000000 --- a/examples/qeq/log.27Nov18.qeq.buck.g++.4 +++ /dev/null @@ -1,118 +0,0 @@ -LAMMPS (27 Nov 2018) - using 1 OpenMP thread(s) per MPI task -# This example demonstrates the use of various fix qeq variants with -# that defines and uses charges, in this case pair_style buck/coul/long - -units metal -atom_style charge - -read_data data.aC - orthogonal box = (0 0 0) to (25.1583 25.1583 28.0203) - 1 by 2 by 2 MPI processor grid - reading atoms ... - 1200 atoms -replicate 2 2 2 - orthogonal box = (0 0 0) to (50.3166 50.3166 56.0405) - 1 by 2 by 2 MPI processor grid - 9600 atoms - Time spent = 0.000675201 secs - -pair_style buck/coul/long 12.0 -pair_coeff 2 2 1388.77 .3623188 175.0 -pair_coeff 1 2 18003 .2052124 133.5381 -pair_coeff 1 1 0 .1 0 -kspace_style ewald 1e-6 - -neighbor 1.0 bin -neigh_modify delay 0 every 1 check yes - -group type1 type 1 -3200 atoms in group type1 -compute charge1 type1 property/atom q -compute q1 type1 reduce ave c_charge1 -group type2 type 2 -6400 atoms in group type2 -compute charge2 type2 property/atom q -compute q2 type2 reduce ave c_charge2 -variable qtot equal count(type1)*c_q1+count(type2)*c_q2 - -thermo_style custom step pe c_q1 c_q2 v_qtot spcpu -thermo 10 - -timestep 0.0001 - -velocity all create 300.0 1281937 -fix 1 all nve - -#fix 2 all qeq/point 1 10 1.0e-6 100 param.qeq2 -#fix 2 all qeq/shielded 1 10 1.0e-6 100 param.qeq2 -#fix 2 all qeq/slater 1 10 1.0e-6 100 param.qeq2 -#fix 2 all qeq/dynamic 1 10 1.0e-4 100 param.qeq2 -fix 2 all qeq/fire 1 10 1.0e-4 100 param.qeq2 - -run 100 -Ewald initialization ... - using 12-bit tables for long-range coulomb (src/kspace.cpp:321) - G vector (1/distance) = 0.305064 - estimated absolute RMS force accuracy = 2.07629e-05 - estimated relative force accuracy = 1.44191e-06 - KSpace vectors: actual max1d max3d = 13556 20 34460 - kxmax kymax kzmax = 18 18 20 -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 13 - ghost atom cutoff = 13 - binsize = 6.5, bins = 8 8 9 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair buck/coul/long, perpetual - attributes: half, newton on - pair build: half/bin/atomonly/newton - stencil: half/bin/3d/newton - bin: standard - (2) fix qeq/fire, perpetual, copy from (1) - attributes: half, newton on - pair build: copy - stencil: none - bin: none -Per MPI rank memory allocation (min/avg/max) = 53.06 | 53.13 | 53.21 Mbytes -Step PotEng c_q1 c_q2 v_qtot S/CPU - 0 -27457.215 0.85227886 -0.42613943 2.1373125e-11 0 - 10 -27626.057 0.85486228 -0.42743114 3.0468073e-11 2.4245312 - 20 -27975.085 0.85968531 -0.42984266 1.0095391e-10 2.0185316 - 30 -28552.627 0.86755661 -0.4337783 1.3096724e-10 1.9605335 - 40 -29133.643 0.87426387 -0.43713193 1.5279511e-10 1.9624139 - 50 -29697.01 0.8794039 -0.43970195 1.6461854e-10 1.8113263 - 60 -30342 0.88478594 -0.44239297 1.7826096e-10 1.9537722 - 70 -31081.139 0.89069733 -0.44534866 1.4733814e-10 2.058406 - 80 -31792.732 0.89506635 -0.44753317 1.3824319e-10 2.2160813 - 90 -32424.752 0.89714841 -0.44857421 1.2914825e-10 2.0952145 - 100 -32998.353 0.89755721 -0.44877861 1.4824764e-10 2.1292486 -Loop time of 48.7541 on 4 procs for 100 steps with 9600 atoms - -Performance: 0.018 ns/day, 1354.281 hours/ns, 2.051 timesteps/s -97.4% CPU use with 4 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 2.9747 | 3.0315 | 3.0758 | 2.1 | 6.22 -Kspace | 27.873 | 28.264 | 28.63 | 5.3 | 57.97 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.53835 | 0.8523 | 1.2286 | 28.2 | 1.75 -Output | 0.0012984 | 0.001591 | 0.0024178 | 1.2 | 0.00 -Modify | 16.58 | 16.59 | 16.601 | 0.3 | 34.03 -Other | | 0.01409 | | | 0.03 - -Nlocal: 2400 ave 2400 max 2400 min -Histogram: 4 0 0 0 0 0 0 0 0 0 -Nghost: 11550 ave 11550 max 11550 min -Histogram: 4 0 0 0 0 0 0 0 0 0 -Neighs: 735200 ave 740758 max 729642 min -Histogram: 2 0 0 0 0 0 0 0 0 2 - -Total # of neighbors = 2940800 -Ave neighs/atom = 306.333 -Neighbor list builds = 0 -Dangerous builds = 0 -Total wall time: 0:00:49 diff --git a/examples/qeq/param.qeq1 b/examples/qeq/param.qeq1 index 9c8514b021..b49705194c 100644 --- a/examples/qeq/param.qeq1 +++ b/examples/qeq/param.qeq1 @@ -1,3 +1,4 @@ +# UNITS: real 1 5.3200 14.8732 1.0206 0.0 0.0 2 5.8678 14.0000 0.9000 0.0 0.0 3 8.5000 17.9978 1.0503 0.0 0.0 diff --git a/examples/qeq/param.qeq2 b/examples/qeq/param.qeq2 index 7e2fdeb8f2..1d77b7d3a6 100644 --- a/examples/qeq/param.qeq2 +++ b/examples/qeq/param.qeq2 @@ -1,2 +1,3 @@ +# UNITS: metal 1 0.00000 7.25028 0.01 0.772871 0.000000 2 11.26882 15.37920 0.01 0.243072 0.000000 diff --git a/examples/reax/in.reaxc.rdx b/examples/reax/in.reaxc.rdx deleted file mode 100644 index 4874ea2dbb..0000000000 --- a/examples/reax/in.reaxc.rdx +++ /dev/null @@ -1,52 +0,0 @@ -# ReaxFF potential for RDX system -# this run is equivalent to reax/in.reax.rdx - -units real - -atom_style charge -read_data data.rdx - -pair_style reax/c control.reax_c.rdx -pair_coeff * * ffield.reax C H O N - -compute reax all pair reax/c - -variable eb equal c_reax[1] -variable ea equal c_reax[2] -variable elp equal c_reax[3] -variable emol equal c_reax[4] -variable ev equal c_reax[5] -variable epen equal c_reax[6] -variable ecoa equal c_reax[7] -variable ehb equal c_reax[8] -variable et equal c_reax[9] -variable eco equal c_reax[10] -variable ew equal c_reax[11] -variable ep equal c_reax[12] -variable efi equal c_reax[13] -variable eqeq equal c_reax[14] - -neighbor 2.5 bin -neigh_modify every 10 delay 0 check no - -fix 1 all nve -fix 2 all qeq/reax 1 0.0 10.0 1.0e-6 reax/c - -thermo 10 -thermo_style custom step temp epair etotal press & - v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa & - v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - -timestep 1.0 - -#dump 1 all atom 10 dump.reaxc.rdx - -#dump 2 all image 25 image.*.jpg type type & -# axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 25 movie.mpg type type & -# axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 - -run 100 diff --git a/examples/reax/in.reaxc.rdx-shielded b/examples/reax/in.reaxc.rdx-shielded deleted file mode 100644 index 3354b92eab..0000000000 --- a/examples/reax/in.reaxc.rdx-shielded +++ /dev/null @@ -1,52 +0,0 @@ -# ReaxFF potential for RDX system -# this run is equivalent to reax/in.reax.rdx - -units real - -atom_style charge -read_data data.rdx - -pair_style reax/c control.reax_c.rdx -pair_coeff * * ffield.reax C H O N - -compute reax all pair reax/c - -variable eb equal c_reax[1] -variable ea equal c_reax[2] -variable elp equal c_reax[3] -variable emol equal c_reax[4] -variable ev equal c_reax[5] -variable epen equal c_reax[6] -variable ecoa equal c_reax[7] -variable ehb equal c_reax[8] -variable et equal c_reax[9] -variable eco equal c_reax[10] -variable ew equal c_reax[11] -variable ep equal c_reax[12] -variable efi equal c_reax[13] -variable eqeq equal c_reax[14] - -neighbor 2.5 bin -neigh_modify every 10 delay 0 check no - -fix 1 all nve -fix 2 all qeq/shielded 1 10.0 1.0e-6 100 reax/c - -thermo 10 -thermo_style custom step temp epair etotal press & - v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa & - v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - -timestep 1.0 - -#dump 1 all atom 10 dump.reaxc.rdx - -#dump 2 all image 25 image.*.jpg type type & -# axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 25 movie.mpg type type & -# axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 - -run 100 diff --git a/examples/reax/in.reaxc.tatb b/examples/reax/in.reaxc.tatb deleted file mode 100644 index a166613b85..0000000000 --- a/examples/reax/in.reaxc.tatb +++ /dev/null @@ -1,55 +0,0 @@ -# ReaxFF potential for TATB system -# this run is equivalent to reax/in.reax.tatb, - -units real - -atom_style charge -read_data data.tatb - -pair_style reax/c control.reax_c.tatb -pair_coeff * * ffield.reax C H O N - -compute reax all pair reax/c - -variable eb equal c_reax[1] -variable ea equal c_reax[2] -variable elp equal c_reax[3] -variable emol equal c_reax[4] -variable ev equal c_reax[5] -variable epen equal c_reax[6] -variable ecoa equal c_reax[7] -variable ehb equal c_reax[8] -variable et equal c_reax[9] -variable eco equal c_reax[10] -variable ew equal c_reax[11] -variable ep equal c_reax[12] -variable efi equal c_reax[13] -variable eqeq equal c_reax[14] - -neighbor 2.5 bin -neigh_modify delay 0 every 5 check no - -fix 1 all nve -fix 2 all qeq/reax 1 0.0 10.0 1.0e-6 reax/c -fix 4 all reax/c/bonds 5 bonds.reaxc - -thermo 5 -thermo_style custom step temp epair etotal press & - v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa & - v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - -timestep 0.0625 - -#dump 1 all custom 100 dump.reaxc.tatb id type q x y z - -#dump 2 all image 5 image.*.jpg type type & -# axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 5 movie.mpg type type & -# axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 - -fix 3 all reax/c/species 1 5 5 species.tatb - -run 25 diff --git a/examples/reax/in.reaxc.tatb-shielded b/examples/reax/in.reaxc.tatb-shielded deleted file mode 100644 index 2ff4d34f7a..0000000000 --- a/examples/reax/in.reaxc.tatb-shielded +++ /dev/null @@ -1,55 +0,0 @@ -# ReaxFF potential for TATB system -# this run is equivalent to reax/in.reax.tatb, - -units real - -atom_style charge -read_data data.tatb - -pair_style reax/c control.reax_c.tatb -pair_coeff * * ffield.reax C H O N - -compute reax all pair reax/c - -variable eb equal c_reax[1] -variable ea equal c_reax[2] -variable elp equal c_reax[3] -variable emol equal c_reax[4] -variable ev equal c_reax[5] -variable epen equal c_reax[6] -variable ecoa equal c_reax[7] -variable ehb equal c_reax[8] -variable et equal c_reax[9] -variable eco equal c_reax[10] -variable ew equal c_reax[11] -variable ep equal c_reax[12] -variable efi equal c_reax[13] -variable eqeq equal c_reax[14] - -neighbor 2.5 bin -neigh_modify delay 0 every 5 check no - -fix 1 all nve -fix 2 all qeq/shielded 1 10.0 1.0e-6 100 reax/c -fix 4 all reax/c/bonds 5 bonds.reaxc - -thermo 5 -thermo_style custom step temp epair etotal press & - v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa & - v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - -timestep 0.0625 - -#dump 1 all custom 100 dump.reaxc.tatb id type q x y z - -#dump 2 all image 5 image.*.jpg type type & -# axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 5 movie.mpg type type & -# axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 - -fix 3 all reax/c/species 1 5 5 species.tatb - -run 25 diff --git a/examples/reax/log.4Jan19.reaxc.rdx-shielded.g++.1 b/examples/reax/log.4Jan19.reaxc.rdx-shielded.g++.1 deleted file mode 100644 index 9e991a5d6e..0000000000 --- a/examples/reax/log.4Jan19.reaxc.rdx-shielded.g++.1 +++ /dev/null @@ -1,116 +0,0 @@ -LAMMPS (4 Jan 2019) -# ReaxFF potential for RDX system -# this run is equivalent to reax/in.reax.rdx - -units real - -atom_style charge -read_data data.rdx - orthogonal box = (35 35 35) to (48 48 48) - 1 by 1 by 1 MPI processor grid - reading atoms ... - 21 atoms - -pair_style reax/c control.reax_c.rdx -pair_coeff * * ffield.reax C H O N -Reading potential file ffield.reax with DATE: 2010-02-19 - -compute reax all pair reax/c - -variable eb equal c_reax[1] -variable ea equal c_reax[2] -variable elp equal c_reax[3] -variable emol equal c_reax[4] -variable ev equal c_reax[5] -variable epen equal c_reax[6] -variable ecoa equal c_reax[7] -variable ehb equal c_reax[8] -variable et equal c_reax[9] -variable eco equal c_reax[10] -variable ew equal c_reax[11] -variable ep equal c_reax[12] -variable efi equal c_reax[13] -variable eqeq equal c_reax[14] - -neighbor 2.5 bin -neigh_modify every 10 delay 0 check no - -fix 1 all nve -fix 2 all qeq/shielded 1 10.0 1.0e-6 100 reax/c - -thermo 10 -thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - -timestep 1.0 - -#dump 1 all atom 10 dump.reaxc.rdx - -#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 - -run 100 -Neighbor list info ... - update every 10 steps, delay 0 steps, check no - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 12.5 - ghost atom cutoff = 12.5 - binsize = 6.25, bins = 3 3 3 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair reax/c, perpetual - attributes: half, newton off, ghost - pair build: half/bin/newtoff/ghost - stencil: half/ghost/bin/3d/newtoff - bin: standard - (2) fix qeq/shielded, perpetual - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 15.54 | 15.54 | 15.54 Mbytes -Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - 0 0 -1884.3081 -1884.3081 27186.181 -2958.4712 79.527715 0.31082031 0 98.589783 25.846176 -0.18034154 0 16.709078 -9.1620736 938.43732 -244.79939 0 168.88404 - 10 1288.6115 -1989.6644 -1912.8422 -19456.353 -2734.6769 -15.60722 0.2017796 0 54.629557 3.1252289 -77.7067 0 14.933901 -5.8108542 843.92073 -180.43321 0 107.75934 - 20 538.95832 -1942.7037 -1910.5731 -10725.665 -2803.7395 7.9078296 0.077926657 0 81.61005 0.22951928 -57.5571 0 30.331204 -10.178049 878.99014 -159.69088 0 89.31512 - 30 463.09535 -1933.5765 -1905.9685 -33255.521 -2749.8591 -8.0154561 0.027628873 0 81.62739 0.11972409 -50.262289 0 20.820315 -9.6327029 851.88723 -149.49502 0 79.205749 - 40 885.49232 -1958.9126 -1906.1229 -4814.704 -2795.644 9.1506683 0.13747502 0 70.947988 0.2436053 -57.862679 0 19.076499 -11.141216 873.73896 -159.99392 0 92.434085 - 50 861.16622 -1954.4599 -1903.1204 -1896.7878 -2784.8448 3.8269901 0.15793272 0 79.851828 3.3492155 -78.066128 0 32.628996 -7.9565333 872.81832 -190.98567 0 114.75995 - 60 1167.7852 -1971.843 -1902.2241 -3482.6875 -2705.8632 -17.121673 0.22749075 0 44.507672 7.856086 -74.788945 0 16.256491 -4.6046463 835.83056 -188.33693 0 114.19414 - 70 1439.997 -1989.3024 -1903.4553 23845.434 -2890.7895 31.958869 0.26671726 0 85.758681 3.1803462 -71.002898 0 24.35711 -10.311314 905.86781 -175.38471 0 106.79648 - 80 502.39629 -1930.7545 -1900.8035 -20356.384 -2703.8111 -18.66263 0.11286065 0 99.804114 2.0329076 -76.171338 0 19.23692 -6.2786691 826.47429 -166.03132 0 92.539464 - 90 749.08722 -1946.9837 -1902.3259 17798.557 -2863.7579 42.068808 0.24338058 0 96.181716 0.96183793 -69.955449 0 24.615308 -11.58277 903.68837 -190.13841 0 120.6914 - 100 1109.6997 -1968.5874 -1902.4313 -4490.2776 -2755.896 -7.1232734 0.21757686 0 61.806176 7.0827207 -75.645383 0 20.114879 -6.2371839 863.56324 -198.56967 0 122.09951 -Loop time of 0.657427 on 1 procs for 100 steps with 21 atoms - -Performance: 13.142 ns/day, 1.826 hours/ns, 152.108 timesteps/s -99.3% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0.59308 | 0.59308 | 0.59308 | 0.0 | 90.21 -Neigh | 0.020665 | 0.020665 | 0.020665 | 0.0 | 3.14 -Comm | 0.0015757 | 0.0015757 | 0.0015757 | 0.0 | 0.24 -Output | 0.00039387 | 0.00039387 | 0.00039387 | 0.0 | 0.06 -Modify | 0.04156 | 0.04156 | 0.04156 | 0.0 | 6.32 -Other | | 0.000154 | | | 0.02 - -Nlocal: 21 ave 21 max 21 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 546 ave 546 max 546 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 1096 ave 1096 max 1096 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 1306 ave 1306 max 1306 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 1306 -Ave neighs/atom = 62.1905 -Neighbor list builds = 10 -Dangerous builds not checked - -Please see the log.cite file for references relevant to this simulation - -Total wall time: 0:00:00 diff --git a/examples/reax/log.4Jan19.reaxc.rdx-shielded.g++.4 b/examples/reax/log.4Jan19.reaxc.rdx-shielded.g++.4 deleted file mode 100644 index 1492865c17..0000000000 --- a/examples/reax/log.4Jan19.reaxc.rdx-shielded.g++.4 +++ /dev/null @@ -1,116 +0,0 @@ -LAMMPS (4 Jan 2019) -# ReaxFF potential for RDX system -# this run is equivalent to reax/in.reax.rdx - -units real - -atom_style charge -read_data data.rdx - orthogonal box = (35 35 35) to (48 48 48) - 1 by 2 by 2 MPI processor grid - reading atoms ... - 21 atoms - -pair_style reax/c control.reax_c.rdx -pair_coeff * * ffield.reax C H O N -Reading potential file ffield.reax with DATE: 2010-02-19 - -compute reax all pair reax/c - -variable eb equal c_reax[1] -variable ea equal c_reax[2] -variable elp equal c_reax[3] -variable emol equal c_reax[4] -variable ev equal c_reax[5] -variable epen equal c_reax[6] -variable ecoa equal c_reax[7] -variable ehb equal c_reax[8] -variable et equal c_reax[9] -variable eco equal c_reax[10] -variable ew equal c_reax[11] -variable ep equal c_reax[12] -variable efi equal c_reax[13] -variable eqeq equal c_reax[14] - -neighbor 2.5 bin -neigh_modify every 10 delay 0 check no - -fix 1 all nve -fix 2 all qeq/shielded 1 10.0 1.0e-6 100 reax/c - -thermo 10 -thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - -timestep 1.0 - -#dump 1 all atom 10 dump.reaxc.rdx - -#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 - -run 100 -Neighbor list info ... - update every 10 steps, delay 0 steps, check no - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 12.5 - ghost atom cutoff = 12.5 - binsize = 6.25, bins = 3 3 3 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair reax/c, perpetual - attributes: half, newton off, ghost - pair build: half/bin/newtoff/ghost - stencil: half/ghost/bin/3d/newtoff - bin: standard - (2) fix qeq/shielded, perpetual - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 10.62 | 12.08 | 13.84 Mbytes -Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - 0 0 -1884.3081 -1884.3081 27186.178 -2958.4712 79.527715 0.31082031 0 98.589783 25.846176 -0.18034154 0 16.709078 -9.1620736 938.43732 -244.79987 0 168.88452 - 10 1288.6116 -1989.6644 -1912.8422 -19456.355 -2734.6769 -15.60722 0.2017796 0 54.629559 3.1252284 -77.7067 0 14.933902 -5.8108544 843.92073 -180.43321 0 107.75934 - 20 538.95818 -1942.7037 -1910.5731 -10725.629 -2803.7394 7.9078295 0.077926694 0 81.61005 0.22951941 -57.557106 0 30.331206 -10.178049 878.9901 -159.68969 0 89.313929 - 30 463.09529 -1933.5765 -1905.9685 -33255.529 -2749.859 -8.0154758 0.027628845 0 81.627406 0.1197241 -50.26229 0 20.82031 -9.6327013 851.88715 -149.49497 0 79.205706 - 40 885.49462 -1958.9125 -1906.1227 -4814.6528 -2795.6439 9.1506212 0.13747486 0 70.94804 0.24360501 -57.862675 0 19.076509 -11.141214 873.7389 -159.99391 0 92.434076 - 50 861.16112 -1954.4601 -1903.121 -1896.6704 -2784.8452 3.8270543 0.15793292 0 79.851662 3.3492078 -78.066133 0 32.628979 -7.9565431 872.81857 -190.9857 0 114.75999 - 60 1167.7837 -1971.8434 -1902.2245 -3482.8961 -2705.8635 -17.121601 0.22749083 0 44.507696 7.8559922 -74.789025 0 16.256492 -4.6046625 835.83053 -188.33688 0 114.19412 - 70 1439.9917 -1989.3024 -1903.4555 23845.887 -2890.7894 31.958677 0.26671714 0 85.758424 3.1804092 -71.002955 0 24.357221 -10.311284 905.86805 -175.38496 0 106.7967 - 80 502.39695 -1930.7548 -1900.8039 -20356.331 -2703.8113 -18.662598 0.11286102 0 99.803743 2.0329429 -76.171299 0 19.236922 -6.2786652 826.4744 -166.03139 0 92.539525 - 90 749.08478 -1946.984 -1902.3264 17798.605 -2863.7581 42.068587 0.24338052 0 96.181622 0.96184063 -69.955519 0 24.615456 -11.582749 903.68853 -190.13827 0 120.69126 - 100 1109.6952 -1968.5879 -1902.4321 -4490.2728 -2755.8985 -7.1225966 0.21757682 0 61.805902 7.0826502 -75.64544 0 20.115369 -6.2372513 863.56451 -198.56956 0 122.09944 -Loop time of 0.634333 on 4 procs for 100 steps with 21 atoms - -Performance: 13.621 ns/day, 1.762 hours/ns, 157.646 timesteps/s -93.8% CPU use with 4 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0.53395 | 0.5352 | 0.53805 | 0.2 | 84.37 -Neigh | 0.0088253 | 0.012023 | 0.016203 | 2.4 | 1.90 -Comm | 0.0051677 | 0.0081 | 0.0093861 | 1.9 | 1.28 -Output | 0.00049353 | 0.00054371 | 0.00058222 | 0.0 | 0.09 -Modify | 0.074155 | 0.078299 | 0.081472 | 0.9 | 12.34 -Other | | 0.0001715 | | | 0.03 - -Nlocal: 5.25 ave 15 max 0 min -Histogram: 1 0 2 0 0 0 0 0 0 1 -Nghost: 355.5 ave 432 max 282 min -Histogram: 1 0 0 0 1 1 0 0 0 1 -Neighs: 298.75 ave 822 max 0 min -Histogram: 1 0 2 0 0 0 0 0 0 1 -FullNghs: 326.5 ave 927 max 0 min -Histogram: 1 0 2 0 0 0 0 0 0 1 - -Total # of neighbors = 1306 -Ave neighs/atom = 62.1905 -Neighbor list builds = 10 -Dangerous builds not checked - -Please see the log.cite file for references relevant to this simulation - -Total wall time: 0:00:00 diff --git a/examples/reax/log.4Jan19.reaxc.tatb-shielded.g++.1 b/examples/reax/log.4Jan19.reaxc.tatb-shielded.g++.1 deleted file mode 100644 index 86dc1c323a..0000000000 --- a/examples/reax/log.4Jan19.reaxc.tatb-shielded.g++.1 +++ /dev/null @@ -1,114 +0,0 @@ -LAMMPS (4 Jan 2019) -# ReaxFF potential for TATB system -# this run is equivalent to reax/in.reax.tatb, - -units real - -atom_style charge -read_data data.tatb - triclinic box = (0 0 0) to (13.624 17.1149 15.1826) with tilt (-5.75316 -6.32547 7.42573) - 1 by 1 by 1 MPI processor grid - reading atoms ... - 384 atoms - -pair_style reax/c control.reax_c.tatb -pair_coeff * * ffield.reax C H O N -Reading potential file ffield.reax with DATE: 2010-02-19 - -compute reax all pair reax/c - -variable eb equal c_reax[1] -variable ea equal c_reax[2] -variable elp equal c_reax[3] -variable emol equal c_reax[4] -variable ev equal c_reax[5] -variable epen equal c_reax[6] -variable ecoa equal c_reax[7] -variable ehb equal c_reax[8] -variable et equal c_reax[9] -variable eco equal c_reax[10] -variable ew equal c_reax[11] -variable ep equal c_reax[12] -variable efi equal c_reax[13] -variable eqeq equal c_reax[14] - -neighbor 2.5 bin -neigh_modify delay 0 every 5 check no - -fix 1 all nve -fix 2 all qeq/shielded 1 10.0 1.0e-6 100 reax/c -fix 4 all reax/c/bonds 5 bonds.reaxc - -thermo 5 -thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - -timestep 0.0625 - -#dump 1 all custom 100 dump.reaxc.tatb id type q x y z - -#dump 2 all image 5 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 5 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 - -fix 3 all reax/c/species 1 5 5 species.tatb - -run 25 -Neighbor list info ... - update every 5 steps, delay 0 steps, check no - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 12.5 - ghost atom cutoff = 12.5 - binsize = 6.25, bins = 5 4 3 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair reax/c, perpetual - attributes: half, newton off, ghost - pair build: half/bin/newtoff/ghost - stencil: half/ghost/bin/3d/newtoff - bin: standard - (2) fix qeq/shielded, perpetual - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 169.6 | 169.6 | 169.6 Mbytes -Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - 0 0 -44760.998 -44760.998 7827.7879 -61120.591 486.4378 4.7236377 0 1574.1033 20.788929 -279.51642 -1556.4696 252.57147 -655.84699 18862.412 -8740.6394 0 6391.0274 - 5 0.61603942 -44761.698 -44760.994 8934.628 -61118.769 486.81263 4.7234094 0 1573.9241 20.768834 -278.24084 -1557.6713 252.64377 -655.74435 18859.379 -8738.193 0 6388.6691 - 10 2.3525549 -44763.227 -44760.541 12288.614 -61113.174 487.82738 4.7226863 0 1573.411 20.705939 -274.50358 -1560.7569 252.85309 -655.44063 18850.391 -8730.9684 0 6381.7061 - 15 4.9013311 -44766.36 -44760.764 17716.982 -61103.434 489.14721 4.7213644 0 1572.6349 20.593139 -268.56847 -1566.3829 252.95174 -654.96611 18835.777 -8719.2449 0 6370.4111 - 20 7.8294673 -44769.686 -44760.747 25205.558 -61089.006 490.21313 4.719302 0 1571.7022 20.420943 -260.85565 -1573.7378 253.3539 -654.31623 18816.07 -8703.5142 0 6355.2654 - 25 10.697904 -44772.904 -44760.691 34232.821 -61069.308 490.25886 4.7163736 0 1570.7397 20.181346 -251.91378 -1582.3261 253.82253 -653.53184 18791.975 -8684.3541 0 6336.8349 -Loop time of 7.80985 on 1 procs for 25 steps with 384 atoms - -Performance: 0.017 ns/day, 1388.418 hours/ns, 3.201 timesteps/s -100.0% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 5.003 | 5.003 | 5.003 | 0.0 | 64.06 -Neigh | 1.1164 | 1.1164 | 1.1164 | 0.0 | 14.29 -Comm | 0.0065806 | 0.0065806 | 0.0065806 | 0.0 | 0.08 -Output | 0.00029969 | 0.00029969 | 0.00029969 | 0.0 | 0.00 -Modify | 1.6831 | 1.6831 | 1.6831 | 0.0 | 21.55 -Other | | 0.0004976 | | | 0.01 - -Nlocal: 384 ave 384 max 384 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 7559 ave 7559 max 7559 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 286828 ave 286828 max 286828 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 336304 ave 336304 max 336304 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 336304 -Ave neighs/atom = 875.792 -Neighbor list builds = 5 -Dangerous builds not checked - -Please see the log.cite file for references relevant to this simulation - -Total wall time: 0:00:08 diff --git a/examples/reax/log.4Jan19.reaxc.tatb-shielded.g++.4 b/examples/reax/log.4Jan19.reaxc.tatb-shielded.g++.4 deleted file mode 100644 index 7dc9867f5a..0000000000 --- a/examples/reax/log.4Jan19.reaxc.tatb-shielded.g++.4 +++ /dev/null @@ -1,114 +0,0 @@ -LAMMPS (4 Jan 2019) -# ReaxFF potential for TATB system -# this run is equivalent to reax/in.reax.tatb, - -units real - -atom_style charge -read_data data.tatb - triclinic box = (0 0 0) to (13.624 17.1149 15.1826) with tilt (-5.75316 -6.32547 7.42573) - 1 by 2 by 2 MPI processor grid - reading atoms ... - 384 atoms - -pair_style reax/c control.reax_c.tatb -pair_coeff * * ffield.reax C H O N -Reading potential file ffield.reax with DATE: 2010-02-19 - -compute reax all pair reax/c - -variable eb equal c_reax[1] -variable ea equal c_reax[2] -variable elp equal c_reax[3] -variable emol equal c_reax[4] -variable ev equal c_reax[5] -variable epen equal c_reax[6] -variable ecoa equal c_reax[7] -variable ehb equal c_reax[8] -variable et equal c_reax[9] -variable eco equal c_reax[10] -variable ew equal c_reax[11] -variable ep equal c_reax[12] -variable efi equal c_reax[13] -variable eqeq equal c_reax[14] - -neighbor 2.5 bin -neigh_modify delay 0 every 5 check no - -fix 1 all nve -fix 2 all qeq/shielded 1 10.0 1.0e-6 100 reax/c -fix 4 all reax/c/bonds 5 bonds.reaxc - -thermo 5 -thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - -timestep 0.0625 - -#dump 1 all custom 100 dump.reaxc.tatb id type q x y z - -#dump 2 all image 5 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 5 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 - -fix 3 all reax/c/species 1 5 5 species.tatb - -run 25 -Neighbor list info ... - update every 5 steps, delay 0 steps, check no - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 12.5 - ghost atom cutoff = 12.5 - binsize = 6.25, bins = 5 4 3 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair reax/c, perpetual - attributes: half, newton off, ghost - pair build: half/bin/newtoff/ghost - stencil: half/ghost/bin/3d/newtoff - bin: standard - (2) fix qeq/shielded, perpetual - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 113 | 113 | 113 Mbytes -Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - 0 0 -44760.998 -44760.998 7827.7866 -61120.591 486.4378 4.7236377 0 1574.1033 20.788929 -279.51642 -1556.4696 252.57147 -655.84699 18862.412 -8740.6398 0 6391.0277 - 5 0.61603968 -44761.698 -44760.994 8934.6336 -61118.769 486.81263 4.7234094 0 1573.9241 20.768834 -278.24084 -1557.6713 252.64377 -655.74435 18859.379 -8738.1906 0 6388.6666 - 10 2.3525543 -44763.227 -44760.541 12288.588 -61113.174 487.82738 4.7226863 0 1573.411 20.705939 -274.50357 -1560.7569 252.85309 -655.44063 18850.391 -8730.9756 0 6381.7133 - 15 4.9013233 -44766.36 -44760.764 17716.934 -61103.434 489.14722 4.7213644 0 1572.6349 20.593139 -268.56847 -1566.3829 252.95174 -654.96611 18835.777 -8719.2627 0 6370.4289 - 20 7.8294615 -44769.686 -44760.747 25205.586 -61089.006 490.21314 4.7193021 0 1571.7022 20.420943 -260.85565 -1573.7378 253.3539 -654.31623 18816.07 -8703.4958 0 6355.2471 - 25 10.697919 -44772.904 -44760.691 34232.898 -61069.308 490.25887 4.7163736 0 1570.7397 20.181347 -251.91377 -1582.3261 253.82253 -653.53184 18791.975 -8684.3285 0 6336.8093 -Loop time of 4.34178 on 4 procs for 25 steps with 384 atoms - -Performance: 0.031 ns/day, 771.872 hours/ns, 5.758 timesteps/s -96.8% CPU use with 4 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 3.1756 | 3.1763 | 3.1771 | 0.0 | 73.16 -Neigh | 0.58917 | 0.59661 | 0.6035 | 0.9 | 13.74 -Comm | 0.0088837 | 0.010178 | 0.011116 | 0.8 | 0.23 -Output | 0.00036407 | 0.0019013 | 0.003552 | 2.7 | 0.04 -Modify | 0.54882 | 0.55637 | 0.56413 | 0.8 | 12.81 -Other | | 0.0004123 | | | 0.01 - -Nlocal: 96 ave 96 max 96 min -Histogram: 4 0 0 0 0 0 0 0 0 0 -Nghost: 5118 ave 5118 max 5118 min -Histogram: 4 0 0 0 0 0 0 0 0 0 -Neighs: 79754 ave 79754 max 79754 min -Histogram: 4 0 0 0 0 0 0 0 0 0 -FullNghs: 84076 ave 84076 max 84076 min -Histogram: 4 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 336304 -Ave neighs/atom = 875.792 -Neighbor list builds = 5 -Dangerous builds not checked - -Please see the log.cite file for references relevant to this simulation - -Total wall time: 0:00:04 diff --git a/examples/reax/log.8March18.reaxc.rdx.g++.1 b/examples/reax/log.8March18.reaxc.rdx.g++.1 deleted file mode 100644 index 4ae10e3f52..0000000000 --- a/examples/reax/log.8March18.reaxc.rdx.g++.1 +++ /dev/null @@ -1,115 +0,0 @@ -LAMMPS (8 Mar 2018) - using 1 OpenMP thread(s) per MPI task -# ReaxFF potential for RDX system -# this run is equivalent to reax/in.reax.rdx - -units real - -atom_style charge -read_data data.rdx - orthogonal box = (35 35 35) to (48 48 48) - 1 by 1 by 1 MPI processor grid - reading atoms ... - 21 atoms - -pair_style reax/c control.reax_c.rdx -pair_coeff * * ffield.reax C H O N -Reading potential file ffield.reax with DATE: 2010-02-19 - -compute reax all pair reax/c - -variable eb equal c_reax[1] -variable ea equal c_reax[2] -variable elp equal c_reax[3] -variable emol equal c_reax[4] -variable ev equal c_reax[5] -variable epen equal c_reax[6] -variable ecoa equal c_reax[7] -variable ehb equal c_reax[8] -variable et equal c_reax[9] -variable eco equal c_reax[10] -variable ew equal c_reax[11] -variable ep equal c_reax[12] -variable efi equal c_reax[13] -variable eqeq equal c_reax[14] - -neighbor 2.5 bin -neigh_modify every 10 delay 0 check no - -fix 1 all nve -fix 2 all qeq/reax 1 0.0 10.0 1.0e-6 reax/c - -thermo 10 -thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - -timestep 1.0 - -#dump 1 all atom 10 dump.reaxc.rdx - -#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 - -run 100 -Neighbor list info ... - update every 10 steps, delay 0 steps, check no - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 12.5 - ghost atom cutoff = 12.5 - binsize = 6.25, bins = 3 3 3 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair reax/c, perpetual - attributes: half, newton off, ghost - pair build: half/bin/newtoff/ghost - stencil: half/ghost/bin/3d/newtoff - bin: standard - (2) fix qeq/reax, perpetual, copy from (1) - attributes: half, newton off, ghost - pair build: copy - stencil: none - bin: none -Per MPI rank memory allocation (min/avg/max) = 15.28 | 15.28 | 15.28 Mbytes -Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - 0 0 -1884.3081 -1884.3081 27186.181 -2958.4712 79.527715 0.31082031 0 98.589783 25.846176 -0.18034154 0 16.709078 -9.1620736 938.43732 -244.79937 0 168.88402 - 10 1288.6114 -1989.6644 -1912.8422 -19456.35 -2734.6769 -15.607219 0.20177961 0 54.629556 3.1252294 -77.7067 0 14.933901 -5.8108541 843.92074 -180.43322 0 107.75935 - 20 538.95849 -1942.7037 -1910.5731 -10725.658 -2803.7395 7.9078331 0.077926702 0 81.610043 0.22951937 -57.557104 0 30.331203 -10.178049 878.99015 -159.69092 0 89.315159 - 30 463.09542 -1933.5765 -1905.9685 -33255.507 -2749.8591 -8.0154628 0.027628767 0 81.627403 0.11972403 -50.262284 0 20.82032 -9.6327022 851.88722 -149.495 0 79.205731 - 40 885.49449 -1958.9126 -1906.1228 -4814.7123 -2795.644 9.1506221 0.1374749 0 70.948046 0.24360579 -57.8627 0 19.076515 -11.141211 873.73892 -159.9939 0 92.434059 - 50 861.1646 -1954.4599 -1903.1206 -1896.7387 -2784.8446 3.8269113 0.1579328 0 79.851775 3.3492107 -78.066127 0 32.628975 -7.9565255 872.81826 -190.98565 0 114.75994 - 60 1167.785 -1971.8432 -1902.2243 -3482.6975 -2705.8638 -17.121582 0.22749067 0 44.507705 7.856069 -74.788959 0 16.256519 -4.6046602 835.8308 -188.33691 0 114.19414 - 70 1439.9947 -1989.3024 -1903.4554 23845.067 -2890.7896 31.958874 0.26671735 0 85.758608 3.1803486 -71.002907 0 24.357106 -10.311315 905.86799 -175.38482 0 106.79659 - 80 502.40024 -1930.7547 -1900.8035 -20356.557 -2703.8096 -18.663105 0.11286226 0 99.803799 2.0329394 -76.171387 0 19.236609 -6.2786041 826.47358 -166.03157 0 92.539694 - 90 749.09267 -1946.9834 -1902.3254 17798.812 -2863.7586 42.068927 0.24338042 0 96.18195 0.96181754 -69.955528 0 24.61541 -11.58277 903.68895 -190.13838 0 120.69139 - 100 1109.7046 -1968.5875 -1902.4311 -4490.6736 -2755.8953 -7.1235173 0.21757663 0 61.806405 7.0825933 -75.645487 0 20.114745 -6.2371664 863.56285 -198.56939 0 122.09923 -Loop time of 0.395195 on 1 procs for 100 steps with 21 atoms - -Performance: 21.863 ns/day, 1.098 hours/ns, 253.039 timesteps/s -99.3% CPU use with 1 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0.3722 | 0.3722 | 0.3722 | 0.0 | 94.18 -Neigh | 0.0098455 | 0.0098455 | 0.0098455 | 0.0 | 2.49 -Comm | 0.00047445 | 0.00047445 | 0.00047445 | 0.0 | 0.12 -Output | 0.00034022 | 0.00034022 | 0.00034022 | 0.0 | 0.09 -Modify | 0.012187 | 0.012187 | 0.012187 | 0.0 | 3.08 -Other | | 0.0001521 | | | 0.04 - -Nlocal: 21 ave 21 max 21 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 546 ave 546 max 546 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 1096 ave 1096 max 1096 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 1096 -Ave neighs/atom = 52.1905 -Neighbor list builds = 10 -Dangerous builds not checked - -Please see the log.cite file for references relevant to this simulation - -Total wall time: 0:00:00 diff --git a/examples/reax/log.8March18.reaxc.rdx.g++.4 b/examples/reax/log.8March18.reaxc.rdx.g++.4 deleted file mode 100644 index 6ea4835402..0000000000 --- a/examples/reax/log.8March18.reaxc.rdx.g++.4 +++ /dev/null @@ -1,115 +0,0 @@ -LAMMPS (8 Mar 2018) - using 1 OpenMP thread(s) per MPI task -# ReaxFF potential for RDX system -# this run is equivalent to reax/in.reax.rdx - -units real - -atom_style charge -read_data data.rdx - orthogonal box = (35 35 35) to (48 48 48) - 1 by 2 by 2 MPI processor grid - reading atoms ... - 21 atoms - -pair_style reax/c control.reax_c.rdx -pair_coeff * * ffield.reax C H O N -Reading potential file ffield.reax with DATE: 2010-02-19 - -compute reax all pair reax/c - -variable eb equal c_reax[1] -variable ea equal c_reax[2] -variable elp equal c_reax[3] -variable emol equal c_reax[4] -variable ev equal c_reax[5] -variable epen equal c_reax[6] -variable ecoa equal c_reax[7] -variable ehb equal c_reax[8] -variable et equal c_reax[9] -variable eco equal c_reax[10] -variable ew equal c_reax[11] -variable ep equal c_reax[12] -variable efi equal c_reax[13] -variable eqeq equal c_reax[14] - -neighbor 2.5 bin -neigh_modify every 10 delay 0 check no - -fix 1 all nve -fix 2 all qeq/reax 1 0.0 10.0 1.0e-6 reax/c - -thermo 10 -thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - -timestep 1.0 - -#dump 1 all atom 10 dump.reaxc.rdx - -#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 - -run 100 -Neighbor list info ... - update every 10 steps, delay 0 steps, check no - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 12.5 - ghost atom cutoff = 12.5 - binsize = 6.25, bins = 3 3 3 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair reax/c, perpetual - attributes: half, newton off, ghost - pair build: half/bin/newtoff/ghost - stencil: half/ghost/bin/3d/newtoff - bin: standard - (2) fix qeq/reax, perpetual, copy from (1) - attributes: half, newton off, ghost - pair build: copy - stencil: none - bin: none -Per MPI rank memory allocation (min/avg/max) = 10.37 | 11.76 | 13.34 Mbytes -Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - 0 0 -1884.3081 -1884.3081 27186.178 -2958.4712 79.527715 0.31082031 0 98.589783 25.846176 -0.18034154 0 16.709078 -9.1620736 938.43732 -244.79988 0 168.88453 - 10 1288.6115 -1989.6644 -1912.8422 -19456.354 -2734.6769 -15.60722 0.2017796 0 54.629558 3.1252286 -77.7067 0 14.933902 -5.8108544 843.92073 -180.43321 0 107.75934 - 20 538.95818 -1942.7037 -1910.5731 -10725.623 -2803.7394 7.9078307 0.077926702 0 81.61005 0.22951942 -57.557107 0 30.331206 -10.178049 878.9901 -159.68951 0 89.313749 - 30 463.09514 -1933.5765 -1905.9685 -33255.525 -2749.859 -8.0154737 0.027628797 0 81.627408 0.11972402 -50.262283 0 20.82031 -9.6327021 851.88715 -149.49499 0 79.205724 - 40 885.49412 -1958.9125 -1906.1227 -4814.6606 -2795.6439 9.150622 0.13747487 0 70.948029 0.24360517 -57.862679 0 19.076509 -11.141214 873.7389 -159.99392 0 92.434078 - 50 861.16393 -1954.46 -1903.1207 -1896.7323 -2784.8449 3.8270197 0.1579328 0 79.851743 3.3492115 -78.066132 0 32.628992 -7.9565379 872.81841 -190.98568 0 114.75996 - 60 1167.7846 -1971.8432 -1902.2243 -3482.8111 -2705.8633 -17.121657 0.2274907 0 44.507681 7.8560366 -74.788989 0 16.256493 -4.6046537 835.8305 -188.33687 0 114.1941 - 70 1439.9942 -1989.3023 -1903.4554 23845.444 -2890.7894 31.958784 0.26671721 0 85.758586 3.1803655 -71.002918 0 24.357158 -10.311304 905.86792 -175.38481 0 106.79657 - 80 502.3975 -1930.7546 -1900.8036 -20356.439 -2703.8105 -18.662812 0.11286123 0 99.80391 2.0329293 -76.171334 0 19.236803 -6.2786439 826.47397 -166.03141 0 92.539551 - 90 749.09048 -1946.9837 -1902.3258 17798.718 -2863.7582 42.068719 0.24338057 0 96.181773 0.96183581 -69.955529 0 24.615414 -11.582758 903.68862 -190.1384 0 120.69139 - 100 1109.6999 -1968.5875 -1902.4314 -4490.3728 -2755.8964 -7.1231468 0.21757685 0 61.806149 7.0826648 -75.645428 0 20.115002 -6.2371958 863.56343 -198.56957 0 122.09942 -Loop time of 0.329552 on 4 procs for 100 steps with 21 atoms - -Performance: 26.217 ns/day, 0.915 hours/ns, 303.443 timesteps/s -96.9% CPU use with 4 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0.26372 | 0.26499 | 0.26754 | 0.3 | 80.41 -Neigh | 0.0045478 | 0.0062494 | 0.0076699 | 1.5 | 1.90 -Comm | 0.0041637 | 0.0064691 | 0.0080271 | 1.8 | 1.96 -Output | 0.00054169 | 0.00056636 | 0.00060368 | 0.0 | 0.17 -Modify | 0.049433 | 0.051134 | 0.05311 | 0.6 | 15.52 -Other | | 0.000141 | | | 0.04 - -Nlocal: 5.25 ave 15 max 0 min -Histogram: 1 0 2 0 0 0 0 0 0 1 -Nghost: 355.5 ave 432 max 282 min -Histogram: 1 0 0 0 1 1 0 0 0 1 -Neighs: 298.75 ave 822 max 0 min -Histogram: 1 0 2 0 0 0 0 0 0 1 - -Total # of neighbors = 1195 -Ave neighs/atom = 56.9048 -Neighbor list builds = 10 -Dangerous builds not checked - -Please see the log.cite file for references relevant to this simulation - -Total wall time: 0:00:00 diff --git a/examples/reax/log.8March18.reaxc.tatb.g++.1 b/examples/reax/log.8March18.reaxc.tatb.g++.1 deleted file mode 100644 index ac5537bba4..0000000000 --- a/examples/reax/log.8March18.reaxc.tatb.g++.1 +++ /dev/null @@ -1,113 +0,0 @@ -LAMMPS (8 Mar 2018) - using 1 OpenMP thread(s) per MPI task -# ReaxFF potential for TATB system -# this run is equivalent to reax/in.reax.tatb, - -units real - -atom_style charge -read_data data.tatb - triclinic box = (0 0 0) to (13.624 17.1149 15.1826) with tilt (-5.75316 -6.32547 7.42573) - 1 by 1 by 1 MPI processor grid - reading atoms ... - 384 atoms - -pair_style reax/c control.reax_c.tatb -pair_coeff * * ffield.reax C H O N -Reading potential file ffield.reax with DATE: 2010-02-19 - -compute reax all pair reax/c - -variable eb equal c_reax[1] -variable ea equal c_reax[2] -variable elp equal c_reax[3] -variable emol equal c_reax[4] -variable ev equal c_reax[5] -variable epen equal c_reax[6] -variable ecoa equal c_reax[7] -variable ehb equal c_reax[8] -variable et equal c_reax[9] -variable eco equal c_reax[10] -variable ew equal c_reax[11] -variable ep equal c_reax[12] -variable efi equal c_reax[13] -variable eqeq equal c_reax[14] - -neighbor 2.5 bin -neigh_modify delay 0 every 5 check no - -fix 1 all nve -fix 2 all qeq/reax 1 0.0 10.0 1.0e-6 reax/c -fix 4 all reax/c/bonds 5 bonds.reaxc - -thermo 5 -thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - -timestep 0.0625 - -#dump 1 all custom 100 dump.reaxc.tatb id type q x y z - -#dump 2 all image 5 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 5 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 - -fix 3 all reax/c/species 1 5 5 species.tatb - -run 25 -Neighbor list info ... - update every 5 steps, delay 0 steps, check no - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 12.5 - ghost atom cutoff = 12.5 - binsize = 6.25, bins = 5 4 3 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair reax/c, perpetual - attributes: half, newton off, ghost - pair build: half/bin/newtoff/ghost - stencil: half/ghost/bin/3d/newtoff - bin: standard - (2) fix qeq/reax, perpetual, copy from (1) - attributes: half, newton off, ghost - pair build: copy - stencil: none - bin: none -Per MPI rank memory allocation (min/avg/max) = 176.7 | 176.7 | 176.7 Mbytes -Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - 0 0 -44760.998 -44760.998 7827.7874 -61120.591 486.4378 4.7236377 0 1574.1033 20.788929 -279.51642 -1556.4696 252.57147 -655.84699 18862.412 -8740.6395 0 6391.0275 - 5 0.61603968 -44761.698 -44760.994 8934.6347 -61118.769 486.81263 4.7234094 0 1573.9241 20.768834 -278.24084 -1557.6713 252.64377 -655.74435 18859.379 -8738.1911 0 6388.6671 - 10 2.3525551 -44763.227 -44760.541 12288.583 -61113.174 487.82738 4.7226863 0 1573.411 20.705939 -274.50357 -1560.7569 252.85309 -655.44063 18850.391 -8730.9768 0 6381.7146 - 15 4.9013279 -44766.36 -44760.764 17717.01 -61103.434 489.14722 4.7213644 0 1572.6349 20.593139 -268.56847 -1566.3829 252.95174 -654.96611 18835.777 -8719.2375 0 6370.4038 - 20 7.8294645 -44769.686 -44760.747 25205.624 -61089.006 490.21314 4.719302 0 1571.7022 20.420943 -260.85564 -1573.7378 253.3539 -654.31623 18816.07 -8703.4889 0 6355.2402 - 25 10.697904 -44772.904 -44760.691 34232.965 -61069.308 490.25888 4.7163736 0 1570.7397 20.181346 -251.91377 -1582.3261 253.82253 -653.53184 18791.975 -8684.3125 0 6336.7934 -Loop time of 4.72562 on 1 procs for 25 steps with 384 atoms - -Performance: 0.029 ns/day, 840.110 hours/ns, 5.290 timesteps/s -99.4% CPU use with 1 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 3.775 | 3.775 | 3.775 | 0.0 | 79.88 -Neigh | 0.47047 | 0.47047 | 0.47047 | 0.0 | 9.96 -Comm | 0.0025151 | 0.0025151 | 0.0025151 | 0.0 | 0.05 -Output | 0.0003159 | 0.0003159 | 0.0003159 | 0.0 | 0.01 -Modify | 0.47676 | 0.47676 | 0.47676 | 0.0 | 10.09 -Other | | 0.0005293 | | | 0.01 - -Nlocal: 384 ave 384 max 384 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 7559 ave 7559 max 7559 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 286828 ave 286828 max 286828 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 286828 -Ave neighs/atom = 746.948 -Neighbor list builds = 5 -Dangerous builds not checked - -Please see the log.cite file for references relevant to this simulation - -Total wall time: 0:00:05 diff --git a/examples/reax/log.8March18.reaxc.tatb.g++.4 b/examples/reax/log.8March18.reaxc.tatb.g++.4 deleted file mode 100644 index 12558be68a..0000000000 --- a/examples/reax/log.8March18.reaxc.tatb.g++.4 +++ /dev/null @@ -1,113 +0,0 @@ -LAMMPS (8 Mar 2018) - using 1 OpenMP thread(s) per MPI task -# ReaxFF potential for TATB system -# this run is equivalent to reax/in.reax.tatb, - -units real - -atom_style charge -read_data data.tatb - triclinic box = (0 0 0) to (13.624 17.1149 15.1826) with tilt (-5.75316 -6.32547 7.42573) - 1 by 2 by 2 MPI processor grid - reading atoms ... - 384 atoms - -pair_style reax/c control.reax_c.tatb -pair_coeff * * ffield.reax C H O N -Reading potential file ffield.reax with DATE: 2010-02-19 - -compute reax all pair reax/c - -variable eb equal c_reax[1] -variable ea equal c_reax[2] -variable elp equal c_reax[3] -variable emol equal c_reax[4] -variable ev equal c_reax[5] -variable epen equal c_reax[6] -variable ecoa equal c_reax[7] -variable ehb equal c_reax[8] -variable et equal c_reax[9] -variable eco equal c_reax[10] -variable ew equal c_reax[11] -variable ep equal c_reax[12] -variable efi equal c_reax[13] -variable eqeq equal c_reax[14] - -neighbor 2.5 bin -neigh_modify delay 0 every 5 check no - -fix 1 all nve -fix 2 all qeq/reax 1 0.0 10.0 1.0e-6 reax/c -fix 4 all reax/c/bonds 5 bonds.reaxc - -thermo 5 -thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - -timestep 0.0625 - -#dump 1 all custom 100 dump.reaxc.tatb id type q x y z - -#dump 2 all image 5 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 5 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 - -fix 3 all reax/c/species 1 5 5 species.tatb - -run 25 -Neighbor list info ... - update every 5 steps, delay 0 steps, check no - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 12.5 - ghost atom cutoff = 12.5 - binsize = 6.25, bins = 5 4 3 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair reax/c, perpetual - attributes: half, newton off, ghost - pair build: half/bin/newtoff/ghost - stencil: half/ghost/bin/3d/newtoff - bin: standard - (2) fix qeq/reax, perpetual, copy from (1) - attributes: half, newton off, ghost - pair build: copy - stencil: none - bin: none -Per MPI rank memory allocation (min/avg/max) = 118 | 118 | 118 Mbytes -Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq - 0 0 -44760.998 -44760.998 7827.7866 -61120.591 486.4378 4.7236377 0 1574.1033 20.788929 -279.51642 -1556.4696 252.57147 -655.84699 18862.412 -8740.6398 0 6391.0277 - 5 0.61603968 -44761.698 -44760.994 8934.6335 -61118.769 486.81263 4.7234094 0 1573.9241 20.768834 -278.24084 -1557.6713 252.64377 -655.74435 18859.379 -8738.1906 0 6388.6666 - 10 2.3525544 -44763.227 -44760.541 12288.587 -61113.174 487.82738 4.7226863 0 1573.411 20.705939 -274.50357 -1560.7569 252.85309 -655.44063 18850.391 -8730.9764 0 6381.7141 - 15 4.9013311 -44766.36 -44760.764 17716.955 -61103.434 489.14721 4.7213644 0 1572.6349 20.593139 -268.56847 -1566.3829 252.95174 -654.96611 18835.777 -8719.2558 0 6370.4221 - 20 7.8294715 -44769.686 -44760.747 25205.613 -61089.006 490.21314 4.7193021 0 1571.7022 20.420943 -260.85564 -1573.7378 253.3539 -654.31623 18816.07 -8703.4906 0 6355.2419 - 25 10.697924 -44772.904 -44760.691 34232.794 -61069.308 490.25886 4.7163736 0 1570.7397 20.181347 -251.91376 -1582.3261 253.82253 -653.53183 18791.975 -8684.3641 0 6336.8449 -Loop time of 2.84068 on 4 procs for 25 steps with 384 atoms - -Performance: 0.048 ns/day, 505.009 hours/ns, 8.801 timesteps/s -98.4% CPU use with 4 MPI tasks x 1 OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 2.3253 | 2.328 | 2.3305 | 0.2 | 81.95 -Neigh | 0.2589 | 0.26458 | 0.26897 | 0.7 | 9.31 -Comm | 0.0094428 | 0.012062 | 0.014872 | 2.3 | 0.42 -Output | 0.00043392 | 0.0042209 | 0.0054941 | 3.4 | 0.15 -Modify | 0.22563 | 0.23134 | 0.23579 | 0.8 | 8.14 -Other | | 0.0005122 | | | 0.02 - -Nlocal: 96 ave 96 max 96 min -Histogram: 4 0 0 0 0 0 0 0 0 0 -Nghost: 5118 ave 5118 max 5118 min -Histogram: 4 0 0 0 0 0 0 0 0 0 -Neighs: 79754 ave 79754 max 79754 min -Histogram: 4 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 319016 -Ave neighs/atom = 830.771 -Neighbor list builds = 5 -Dangerous builds not checked - -Please see the log.cite file for references relevant to this simulation - -Total wall time: 0:00:03 diff --git a/examples/reax/AB/README b/examples/reaxff/AB/README similarity index 100% rename from examples/reax/AB/README rename to examples/reaxff/AB/README diff --git a/examples/reax/AB/data.AB b/examples/reaxff/AB/data.AB similarity index 100% rename from examples/reax/AB/data.AB rename to examples/reaxff/AB/data.AB diff --git a/examples/reax/AB/ffield.reax.AB b/examples/reaxff/AB/ffield.reax.AB similarity index 100% rename from examples/reax/AB/ffield.reax.AB rename to examples/reaxff/AB/ffield.reax.AB diff --git a/examples/reax/AB/in.AB b/examples/reaxff/AB/in.AB similarity index 100% rename from examples/reax/AB/in.AB rename to examples/reaxff/AB/in.AB diff --git a/examples/reax/AB/lmp_control b/examples/reaxff/AB/lmp_control similarity index 100% rename from examples/reax/AB/lmp_control rename to examples/reaxff/AB/lmp_control diff --git a/examples/reax/AB/log.8Mar18.AB.g++.1 b/examples/reaxff/AB/log.8Mar18.AB.g++.1 similarity index 100% rename from examples/reax/AB/log.8Mar18.AB.g++.1 rename to examples/reaxff/AB/log.8Mar18.AB.g++.1 diff --git a/examples/reax/AB/log.8Mar18.AB.g++.4 b/examples/reaxff/AB/log.8Mar18.AB.g++.4 similarity index 100% rename from examples/reax/AB/log.8Mar18.AB.g++.4 rename to examples/reaxff/AB/log.8Mar18.AB.g++.4 diff --git a/examples/reax/AB/param.qeq b/examples/reaxff/AB/param.qeq similarity index 100% rename from examples/reax/AB/param.qeq rename to examples/reaxff/AB/param.qeq diff --git a/examples/reax/AuO/README b/examples/reaxff/AuO/README similarity index 100% rename from examples/reax/AuO/README rename to examples/reaxff/AuO/README diff --git a/examples/reax/AuO/data.AuO b/examples/reaxff/AuO/data.AuO similarity index 100% rename from examples/reax/AuO/data.AuO rename to examples/reaxff/AuO/data.AuO diff --git a/examples/reax/AuO/ffield.reax.AuO b/examples/reaxff/AuO/ffield.reax.AuO similarity index 100% rename from examples/reax/AuO/ffield.reax.AuO rename to examples/reaxff/AuO/ffield.reax.AuO diff --git a/examples/reax/AuO/in.AuO b/examples/reaxff/AuO/in.AuO similarity index 100% rename from examples/reax/AuO/in.AuO rename to examples/reaxff/AuO/in.AuO diff --git a/examples/reax/AuO/lmp_control b/examples/reaxff/AuO/lmp_control similarity index 100% rename from examples/reax/AuO/lmp_control rename to examples/reaxff/AuO/lmp_control diff --git a/examples/reax/AuO/log.8Mar18.AuO.g++.1 b/examples/reaxff/AuO/log.8Mar18.AuO.g++.1 similarity index 100% rename from examples/reax/AuO/log.8Mar18.AuO.g++.1 rename to examples/reaxff/AuO/log.8Mar18.AuO.g++.1 diff --git a/examples/reax/AuO/log.8Mar18.AuO.g++.4 b/examples/reaxff/AuO/log.8Mar18.AuO.g++.4 similarity index 100% rename from examples/reax/AuO/log.8Mar18.AuO.g++.4 rename to examples/reaxff/AuO/log.8Mar18.AuO.g++.4 diff --git a/examples/reax/AuO/param.qeq b/examples/reaxff/AuO/param.qeq similarity index 100% rename from examples/reax/AuO/param.qeq rename to examples/reaxff/AuO/param.qeq diff --git a/examples/reax/CHO/README b/examples/reaxff/CHO/README similarity index 100% rename from examples/reax/CHO/README rename to examples/reaxff/CHO/README diff --git a/examples/reax/CHO/data.CHO b/examples/reaxff/CHO/data.CHO similarity index 100% rename from examples/reax/CHO/data.CHO rename to examples/reaxff/CHO/data.CHO diff --git a/examples/reax/CHO/ffield.reax.cho b/examples/reaxff/CHO/ffield.reax.cho similarity index 100% rename from examples/reax/CHO/ffield.reax.cho rename to examples/reaxff/CHO/ffield.reax.cho diff --git a/examples/reax/CHO/in.CHO b/examples/reaxff/CHO/in.CHO similarity index 100% rename from examples/reax/CHO/in.CHO rename to examples/reaxff/CHO/in.CHO diff --git a/examples/reax/CHO/lmp_control b/examples/reaxff/CHO/lmp_control similarity index 100% rename from examples/reax/CHO/lmp_control rename to examples/reaxff/CHO/lmp_control diff --git a/examples/reax/CHO/log.8Mar18.CHO.g++.1 b/examples/reaxff/CHO/log.8Mar18.CHO.g++.1 similarity index 100% rename from examples/reax/CHO/log.8Mar18.CHO.g++.1 rename to examples/reaxff/CHO/log.8Mar18.CHO.g++.1 diff --git a/examples/reax/CHO/log.8Mar18.CHO.g++.4 b/examples/reaxff/CHO/log.8Mar18.CHO.g++.4 similarity index 100% rename from examples/reax/CHO/log.8Mar18.CHO.g++.4 rename to examples/reaxff/CHO/log.8Mar18.CHO.g++.4 diff --git a/examples/reax/CHO/param.qeq b/examples/reaxff/CHO/param.qeq similarity index 100% rename from examples/reax/CHO/param.qeq rename to examples/reaxff/CHO/param.qeq diff --git a/examples/reax/FC/README b/examples/reaxff/FC/README similarity index 100% rename from examples/reax/FC/README rename to examples/reaxff/FC/README diff --git a/examples/reax/FC/data.FC b/examples/reaxff/FC/data.FC similarity index 100% rename from examples/reax/FC/data.FC rename to examples/reaxff/FC/data.FC diff --git a/examples/reax/FC/ffield.reax.FC b/examples/reaxff/FC/ffield.reax.FC similarity index 100% rename from examples/reax/FC/ffield.reax.FC rename to examples/reaxff/FC/ffield.reax.FC diff --git a/examples/reax/FC/in.FC b/examples/reaxff/FC/in.FC similarity index 100% rename from examples/reax/FC/in.FC rename to examples/reaxff/FC/in.FC diff --git a/examples/reax/FC/log.8Mar18.FC.g++.1 b/examples/reaxff/FC/log.8Mar18.FC.g++.1 similarity index 100% rename from examples/reax/FC/log.8Mar18.FC.g++.1 rename to examples/reaxff/FC/log.8Mar18.FC.g++.1 diff --git a/examples/reax/FC/log.8Mar18.FC.g++.4 b/examples/reaxff/FC/log.8Mar18.FC.g++.4 similarity index 100% rename from examples/reax/FC/log.8Mar18.FC.g++.4 rename to examples/reaxff/FC/log.8Mar18.FC.g++.4 diff --git a/examples/reax/FeOH3/README b/examples/reaxff/FeOH3/README similarity index 100% rename from examples/reax/FeOH3/README rename to examples/reaxff/FeOH3/README diff --git a/examples/reax/FeOH3/data.FeOH3 b/examples/reaxff/FeOH3/data.FeOH3 similarity index 100% rename from examples/reax/FeOH3/data.FeOH3 rename to examples/reaxff/FeOH3/data.FeOH3 diff --git a/examples/reax/FeOH3/ffield.reax.Fe_O_C_H b/examples/reaxff/FeOH3/ffield.reax.Fe_O_C_H similarity index 100% rename from examples/reax/FeOH3/ffield.reax.Fe_O_C_H rename to examples/reaxff/FeOH3/ffield.reax.Fe_O_C_H diff --git a/examples/reax/FeOH3/in.FeOH3 b/examples/reaxff/FeOH3/in.FeOH3 similarity index 100% rename from examples/reax/FeOH3/in.FeOH3 rename to examples/reaxff/FeOH3/in.FeOH3 diff --git a/examples/reax/FeOH3/lmp_control b/examples/reaxff/FeOH3/lmp_control similarity index 100% rename from examples/reax/FeOH3/lmp_control rename to examples/reaxff/FeOH3/lmp_control diff --git a/examples/reax/FeOH3/log.5Oct16.FeOH3.g++.1 b/examples/reaxff/FeOH3/log.5Oct16.FeOH3.g++.1 similarity index 100% rename from examples/reax/FeOH3/log.5Oct16.FeOH3.g++.1 rename to examples/reaxff/FeOH3/log.5Oct16.FeOH3.g++.1 diff --git a/examples/reax/FeOH3/log.5Oct16.FeOH3.g++.4 b/examples/reaxff/FeOH3/log.5Oct16.FeOH3.g++.4 similarity index 100% rename from examples/reax/FeOH3/log.5Oct16.FeOH3.g++.4 rename to examples/reaxff/FeOH3/log.5Oct16.FeOH3.g++.4 diff --git a/examples/reax/FeOH3/param.qeq b/examples/reaxff/FeOH3/param.qeq similarity index 100% rename from examples/reax/FeOH3/param.qeq rename to examples/reaxff/FeOH3/param.qeq diff --git a/examples/reax/HNS/README.txt b/examples/reaxff/HNS/README.txt similarity index 100% rename from examples/reax/HNS/README.txt rename to examples/reaxff/HNS/README.txt diff --git a/examples/reax/HNS/data.hns-equil b/examples/reaxff/HNS/data.hns-equil similarity index 100% rename from examples/reax/HNS/data.hns-equil rename to examples/reaxff/HNS/data.hns-equil diff --git a/examples/reax/HNS/ffield.reax.hns b/examples/reaxff/HNS/ffield.reax.hns similarity index 100% rename from examples/reax/HNS/ffield.reax.hns rename to examples/reaxff/HNS/ffield.reax.hns diff --git a/examples/reax/HNS/in.reaxc.hns b/examples/reaxff/HNS/in.reaxc.hns similarity index 100% rename from examples/reax/HNS/in.reaxc.hns rename to examples/reaxff/HNS/in.reaxc.hns diff --git a/examples/reax/HNS/log.8Mar18.reaxc.hns.g++.1 b/examples/reaxff/HNS/log.8Mar18.reaxc.hns.g++.1 similarity index 100% rename from examples/reax/HNS/log.8Mar18.reaxc.hns.g++.1 rename to examples/reaxff/HNS/log.8Mar18.reaxc.hns.g++.1 diff --git a/examples/reax/HNS/log.8Mar18.reaxc.hns.g++.4 b/examples/reaxff/HNS/log.8Mar18.reaxc.hns.g++.4 similarity index 100% rename from examples/reax/HNS/log.8Mar18.reaxc.hns.g++.4 rename to examples/reaxff/HNS/log.8Mar18.reaxc.hns.g++.4 diff --git a/examples/reax/RDX/README b/examples/reaxff/RDX/README similarity index 100% rename from examples/reax/RDX/README rename to examples/reaxff/RDX/README diff --git a/examples/reax/RDX/data.RDX b/examples/reaxff/RDX/data.RDX similarity index 100% rename from examples/reax/RDX/data.RDX rename to examples/reaxff/RDX/data.RDX diff --git a/examples/reax/RDX/ffield.reax.rdx b/examples/reaxff/RDX/ffield.reax.rdx similarity index 100% rename from examples/reax/RDX/ffield.reax.rdx rename to examples/reaxff/RDX/ffield.reax.rdx diff --git a/examples/reax/RDX/in.RDX b/examples/reaxff/RDX/in.RDX similarity index 100% rename from examples/reax/RDX/in.RDX rename to examples/reaxff/RDX/in.RDX diff --git a/examples/reax/RDX/lmp_control b/examples/reaxff/RDX/lmp_control similarity index 100% rename from examples/reax/RDX/lmp_control rename to examples/reaxff/RDX/lmp_control diff --git a/examples/reax/RDX/log.8Mar18.RDX.g++.1 b/examples/reaxff/RDX/log.8Mar18.RDX.g++.1 similarity index 100% rename from examples/reax/RDX/log.8Mar18.RDX.g++.1 rename to examples/reaxff/RDX/log.8Mar18.RDX.g++.1 diff --git a/examples/reax/RDX/log.8Mar18.RDX.g++.4 b/examples/reaxff/RDX/log.8Mar18.RDX.g++.4 similarity index 100% rename from examples/reax/RDX/log.8Mar18.RDX.g++.4 rename to examples/reaxff/RDX/log.8Mar18.RDX.g++.4 diff --git a/examples/reax/RDX/param.qeq b/examples/reaxff/RDX/param.qeq similarity index 100% rename from examples/reax/RDX/param.qeq rename to examples/reaxff/RDX/param.qeq diff --git a/examples/reax/README b/examples/reaxff/README similarity index 100% rename from examples/reax/README rename to examples/reaxff/README diff --git a/examples/reax/VOH/README b/examples/reaxff/VOH/README similarity index 100% rename from examples/reax/VOH/README rename to examples/reaxff/VOH/README diff --git a/examples/reax/VOH/data.VOH b/examples/reaxff/VOH/data.VOH similarity index 100% rename from examples/reax/VOH/data.VOH rename to examples/reaxff/VOH/data.VOH diff --git a/examples/reax/VOH/ffield.reax.V_O_C_H b/examples/reaxff/VOH/ffield.reax.V_O_C_H similarity index 100% rename from examples/reax/VOH/ffield.reax.V_O_C_H rename to examples/reaxff/VOH/ffield.reax.V_O_C_H diff --git a/examples/reax/VOH/in.VOH b/examples/reaxff/VOH/in.VOH similarity index 100% rename from examples/reax/VOH/in.VOH rename to examples/reaxff/VOH/in.VOH diff --git a/examples/reax/VOH/lmp_control b/examples/reaxff/VOH/lmp_control similarity index 100% rename from examples/reax/VOH/lmp_control rename to examples/reaxff/VOH/lmp_control diff --git a/examples/reax/VOH/log.8Mar18.VOH.g++.1 b/examples/reaxff/VOH/log.8Mar18.VOH.g++.1 similarity index 100% rename from examples/reax/VOH/log.8Mar18.VOH.g++.1 rename to examples/reaxff/VOH/log.8Mar18.VOH.g++.1 diff --git a/examples/reax/VOH/log.8Mar18.VOH.g++.4 b/examples/reaxff/VOH/log.8Mar18.VOH.g++.4 similarity index 100% rename from examples/reax/VOH/log.8Mar18.VOH.g++.4 rename to examples/reaxff/VOH/log.8Mar18.VOH.g++.4 diff --git a/examples/reax/VOH/param.qeq b/examples/reaxff/VOH/param.qeq similarity index 100% rename from examples/reax/VOH/param.qeq rename to examples/reaxff/VOH/param.qeq diff --git a/examples/reax/ZnOH2/README b/examples/reaxff/ZnOH2/README similarity index 100% rename from examples/reax/ZnOH2/README rename to examples/reaxff/ZnOH2/README diff --git a/examples/reax/ZnOH2/data.ZnOH2 b/examples/reaxff/ZnOH2/data.ZnOH2 similarity index 100% rename from examples/reax/ZnOH2/data.ZnOH2 rename to examples/reaxff/ZnOH2/data.ZnOH2 diff --git a/examples/reax/ZnOH2/ffield.reax.ZnOH b/examples/reaxff/ZnOH2/ffield.reax.ZnOH similarity index 100% rename from examples/reax/ZnOH2/ffield.reax.ZnOH rename to examples/reaxff/ZnOH2/ffield.reax.ZnOH diff --git a/examples/reax/ZnOH2/in.ZnOH2 b/examples/reaxff/ZnOH2/in.ZnOH2 similarity index 100% rename from examples/reax/ZnOH2/in.ZnOH2 rename to examples/reaxff/ZnOH2/in.ZnOH2 diff --git a/examples/reax/ZnOH2/lmp_control b/examples/reaxff/ZnOH2/lmp_control similarity index 100% rename from examples/reax/ZnOH2/lmp_control rename to examples/reaxff/ZnOH2/lmp_control diff --git a/examples/reax/ZnOH2/log.8Mar18.ZnOH2.g++.1 b/examples/reaxff/ZnOH2/log.8Mar18.ZnOH2.g++.1 similarity index 100% rename from examples/reax/ZnOH2/log.8Mar18.ZnOH2.g++.1 rename to examples/reaxff/ZnOH2/log.8Mar18.ZnOH2.g++.1 diff --git a/examples/reax/ZnOH2/log.8Mar18.ZnOH2.g++.4 b/examples/reaxff/ZnOH2/log.8Mar18.ZnOH2.g++.4 similarity index 100% rename from examples/reax/ZnOH2/log.8Mar18.ZnOH2.g++.4 rename to examples/reaxff/ZnOH2/log.8Mar18.ZnOH2.g++.4 diff --git a/examples/reax/ZnOH2/param.qeq b/examples/reaxff/ZnOH2/param.qeq similarity index 100% rename from examples/reax/ZnOH2/param.qeq rename to examples/reaxff/ZnOH2/param.qeq diff --git a/examples/reax/ci-reaxFF/CH4.dat b/examples/reaxff/ci-reaxFF/CH4.dat similarity index 100% rename from examples/reax/ci-reaxFF/CH4.dat rename to examples/reaxff/ci-reaxFF/CH4.dat diff --git a/examples/reax/ci-reaxFF/ci-reaxFF_ZBL.dat b/examples/reaxff/ci-reaxFF/ci-reaxFF_ZBL.dat similarity index 100% rename from examples/reax/ci-reaxFF/ci-reaxFF_ZBL.dat rename to examples/reaxff/ci-reaxFF/ci-reaxFF_ZBL.dat diff --git a/examples/reax/ci-reaxFF/control b/examples/reaxff/ci-reaxFF/control similarity index 100% rename from examples/reax/ci-reaxFF/control rename to examples/reaxff/ci-reaxFF/control diff --git a/examples/reax/ci-reaxFF/ffield.ci-reax.CH b/examples/reaxff/ci-reaxFF/ffield.ci-reax.CH similarity index 100% rename from examples/reax/ci-reaxFF/ffield.ci-reax.CH rename to examples/reaxff/ci-reaxFF/ffield.ci-reax.CH diff --git a/examples/reax/ci-reaxFF/in.ci-reax.CH b/examples/reaxff/ci-reaxFF/in.ci-reax.CH similarity index 100% rename from examples/reax/ci-reaxFF/in.ci-reax.CH rename to examples/reaxff/ci-reaxFF/in.ci-reax.CH diff --git a/examples/reax/ci-reaxFF/log.8Mar18.ci-reax.CH.g++.1 b/examples/reaxff/ci-reaxFF/log.8Mar18.ci-reax.CH.g++.1 similarity index 100% rename from examples/reax/ci-reaxFF/log.8Mar18.ci-reax.CH.g++.1 rename to examples/reaxff/ci-reaxFF/log.8Mar18.ci-reax.CH.g++.1 diff --git a/examples/reax/ci-reaxFF/log.8Mar18.ci-reax.CH.g++.4 b/examples/reaxff/ci-reaxFF/log.8Mar18.ci-reax.CH.g++.4 similarity index 100% rename from examples/reax/ci-reaxFF/log.8Mar18.ci-reax.CH.g++.4 rename to examples/reaxff/ci-reaxFF/log.8Mar18.ci-reax.CH.g++.4 diff --git a/examples/reax/control.reax_c.rdx b/examples/reaxff/control.reax_c.rdx similarity index 100% rename from examples/reax/control.reax_c.rdx rename to examples/reaxff/control.reax_c.rdx diff --git a/examples/reax/control.reax_c.tatb b/examples/reaxff/control.reax_c.tatb similarity index 100% rename from examples/reax/control.reax_c.tatb rename to examples/reaxff/control.reax_c.tatb diff --git a/examples/reax/data.rdx b/examples/reaxff/data.rdx similarity index 100% rename from examples/reax/data.rdx rename to examples/reaxff/data.rdx diff --git a/examples/reax/data.tatb b/examples/reaxff/data.tatb similarity index 100% rename from examples/reax/data.tatb rename to examples/reaxff/data.tatb diff --git a/examples/reax/ffield.reax b/examples/reaxff/ffield.reax similarity index 100% rename from examples/reax/ffield.reax rename to examples/reaxff/ffield.reax diff --git a/examples/reaxff/in.reaxff.rdx b/examples/reaxff/in.reaxff.rdx new file mode 100644 index 0000000000..82a582e958 --- /dev/null +++ b/examples/reaxff/in.reaxff.rdx @@ -0,0 +1,53 @@ +# ReaxFF potential for RDX system + +units real + +atom_style charge +read_data data.rdx + +pair_style reaxff control.reax_c.rdx +pair_coeff * * ffield.reax C H O N + +compute reax all pair reaxff + +variable eb equal c_reax[1] +variable ea equal c_reax[2] +variable elp equal c_reax[3] +variable emol equal c_reax[4] +variable ev equal c_reax[5] +variable epen equal c_reax[6] +variable ecoa equal c_reax[7] +variable ehb equal c_reax[8] +variable et equal c_reax[9] +variable eco equal c_reax[10] +variable ew equal c_reax[11] +variable ep equal c_reax[12] +variable efi equal c_reax[13] +variable eqeq equal c_reax[14] + +neighbor 2.5 bin +neigh_modify every 10 delay 0 check no + +fix 1 all nve +fix 2 all qeq/reaxff 1 0.0 10.0 1.0e-6 reaxff + +variable nqeq equal f_2 + +thermo 10 +thermo_style custom step temp epair etotal press & + v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa & + v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + +timestep 1.0 + +#dump 1 all atom 10 dump.reaxff.rdx + +#dump 2 all image 25 image.*.jpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +run 100 diff --git a/examples/reaxff/in.reaxff.rdx-shielded b/examples/reaxff/in.reaxff.rdx-shielded new file mode 100644 index 0000000000..d1a5f0beaa --- /dev/null +++ b/examples/reaxff/in.reaxff.rdx-shielded @@ -0,0 +1,52 @@ +# ReaxFF potential for RDX system + +units real + +atom_style charge +read_data data.rdx + +pair_style reaxff control.reax_c.rdx +pair_coeff * * ffield.reax C H O N + +compute reax all pair reaxff + +variable eb equal c_reax[1] +variable ea equal c_reax[2] +variable elp equal c_reax[3] +variable emol equal c_reax[4] +variable ev equal c_reax[5] +variable epen equal c_reax[6] +variable ecoa equal c_reax[7] +variable ehb equal c_reax[8] +variable et equal c_reax[9] +variable eco equal c_reax[10] +variable ew equal c_reax[11] +variable ep equal c_reax[12] +variable efi equal c_reax[13] +variable eqeq equal c_reax[14] + +neighbor 2.5 bin +neigh_modify every 10 delay 0 check no + +fix 1 all nve +fix 2 all qeq/shielded 1 10.0 1.0e-6 100 reaxff +variable nqeq equal f_2 + +thermo 10 +thermo_style custom step temp epair etotal press & + v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa & + v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + +timestep 1.0 + +#dump 1 all atom 10 dump.reaxff.rdx + +#dump 2 all image 25 image.*.jpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +run 100 diff --git a/examples/reaxff/in.reaxff.tatb b/examples/reaxff/in.reaxff.tatb new file mode 100644 index 0000000000..6cf7828cf1 --- /dev/null +++ b/examples/reaxff/in.reaxff.tatb @@ -0,0 +1,55 @@ +# ReaxFF potential for TATB system + +units real + +atom_style charge +read_data data.tatb + +pair_style reaxff control.reax_c.tatb +pair_coeff * * ffield.reax C H O N + +compute reax all pair reaxff + +variable eb equal c_reax[1] +variable ea equal c_reax[2] +variable elp equal c_reax[3] +variable emol equal c_reax[4] +variable ev equal c_reax[5] +variable epen equal c_reax[6] +variable ecoa equal c_reax[7] +variable ehb equal c_reax[8] +variable et equal c_reax[9] +variable eco equal c_reax[10] +variable ew equal c_reax[11] +variable ep equal c_reax[12] +variable efi equal c_reax[13] +variable eqeq equal c_reax[14] + +neighbor 2.5 bin +neigh_modify delay 0 every 5 check no + +fix 1 all nve +fix 2 all qeq/reaxff 1 0.0 10.0 1.0e-6 reaxff +fix 4 all reaxff/bonds 5 bonds.reaxff +variable nqeq equal f_2 + +thermo 5 +thermo_style custom step temp epair etotal press & + v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa & + v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + +timestep 0.0625 + +#dump 1 all custom 100 dump.reaxff.tatb id type q x y z + +#dump 2 all image 5 image.*.jpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 5 movie.mpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 3 all reaxff/species 1 5 5 species.tatb + +run 25 diff --git a/examples/reaxff/in.reaxff.tatb-shielded b/examples/reaxff/in.reaxff.tatb-shielded new file mode 100644 index 0000000000..5a809ecdd2 --- /dev/null +++ b/examples/reaxff/in.reaxff.tatb-shielded @@ -0,0 +1,55 @@ +# ReaxFF potential for TATB system + +units real + +atom_style charge +read_data data.tatb + +pair_style reaxff control.reax_c.tatb +pair_coeff * * ffield.reax C H O N + +compute reax all pair reaxff + +variable eb equal c_reax[1] +variable ea equal c_reax[2] +variable elp equal c_reax[3] +variable emol equal c_reax[4] +variable ev equal c_reax[5] +variable epen equal c_reax[6] +variable ecoa equal c_reax[7] +variable ehb equal c_reax[8] +variable et equal c_reax[9] +variable eco equal c_reax[10] +variable ew equal c_reax[11] +variable ep equal c_reax[12] +variable efi equal c_reax[13] +variable eqeq equal c_reax[14] + +neighbor 2.5 bin +neigh_modify delay 0 every 5 check no + +fix 1 all nve +fix 2 all qeq/shielded 1 10.0 1.0e-6 100 reaxff +fix 4 all reaxff/bonds 5 bonds.reaxff +variable nqeq equal f_2 + +thermo 5 +thermo_style custom step temp epair etotal press & + v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa & + v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + +timestep 0.0625 + +#dump 1 all custom 100 dump.reaxff.tatb id type q x y z + +#dump 2 all image 5 image.*.jpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 5 movie.mpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 3 all reaxff/species 1 5 5 species.tatb + +run 25 diff --git a/examples/reaxff/log.21Jul21.reaxff.rdx-shielded.g++.1 b/examples/reaxff/log.21Jul21.reaxff.rdx-shielded.g++.1 new file mode 100644 index 0000000000..7a0fcf53b5 --- /dev/null +++ b/examples/reaxff/log.21Jul21.reaxff.rdx-shielded.g++.1 @@ -0,0 +1,144 @@ +LAMMPS (2 Jul 2021) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# ReaxFF potential for RDX system + +units real + +atom_style charge +read_data data.rdx +Reading data file ... + orthogonal box = (35.000000 35.000000 35.000000) to (48.000000 48.000000 48.000000) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 21 atoms + read_data CPU = 0.001 seconds + +pair_style reaxff control.reax_c.rdx +WARNING: Ignoring inactive control parameter: simulation_name (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: energy_update_freq (src/REAXFF/reaxff_control.cpp:97) +WARNING: Support for writing native trajectories has been removed after LAMMPS version 8 April 2021 (src/REAXFF/reaxff_control.cpp:113) +WARNING: Ignoring inactive control parameter: traj_title (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_forces (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_velocities (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: bond_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: angle_info (src/REAXFF/reaxff_control.cpp:97) +pair_coeff * * ffield.reax C H O N +Reading potential file ffield.reax with DATE: 2010-02-19 + +compute reax all pair reaxff + +variable eb equal c_reax[1] +variable ea equal c_reax[2] +variable elp equal c_reax[3] +variable emol equal c_reax[4] +variable ev equal c_reax[5] +variable epen equal c_reax[6] +variable ecoa equal c_reax[7] +variable ehb equal c_reax[8] +variable et equal c_reax[9] +variable eco equal c_reax[10] +variable ew equal c_reax[11] +variable ep equal c_reax[12] +variable efi equal c_reax[13] +variable eqeq equal c_reax[14] + +neighbor 2.5 bin +neigh_modify every 10 delay 0 check no + +fix 1 all nve +fix 2 all qeq/shielded 1 10.0 1.0e-6 100 reaxff +variable nqeq equal f_2 + +thermo 10 +thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + +timestep 1.0 + +#dump 1 all atom 10 dump.reaxff.rdx + +#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +run 100 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- pair reaxff command: + +@Article{Aktulga12, + author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama}, + title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques}, + journal = {Parallel Computing}, + year = 2012, + volume = 38, + pages = {245--259} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Neighbor list info ... + update every 10 steps, delay 0 steps, check no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 12.5 + ghost atom cutoff = 12.5 + binsize = 6.25, bins = 3 3 3 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair reaxff, perpetual + attributes: half, newton off, ghost + pair build: half/bin/newtoff/ghost + stencil: full/ghost/bin/3d + bin: standard + (2) fix qeq/shielded, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 13.86 | 13.86 | 13.86 Mbytes +Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + 0 0 -1884.3081 -1884.3081 27186.181 -2958.4712 79.527715 0.31082031 0 98.589783 25.846176 -0.18034154 0 16.709078 -9.1620736 938.43732 -244.79932 0 168.88397 12 + 10 1288.6114 -1989.6644 -1912.8422 -19456.349 -2734.6769 -15.607218 0.20177961 0 54.629555 3.1252297 -77.7067 0 14.933901 -5.810854 843.92074 -180.43322 0 107.75935 8 + 20 538.95852 -1942.7037 -1910.5731 -10725.667 -2803.7395 7.9078343 0.077926704 0 81.610044 0.22951937 -57.557105 0 30.331203 -10.178049 878.99016 -159.69263 0 89.316862 7 + 30 463.09515 -1933.5765 -1905.9685 -33255.499 -2749.8591 -8.0154635 0.02762867 0 81.627413 0.1197239 -50.262272 0 20.82032 -9.632703 851.88721 -149.49497 0 79.205707 8 + 40 885.49689 -1958.9125 -1906.1226 -4814.6325 -2795.644 9.1505916 0.13747481 0 70.948074 0.24360544 -57.862695 0 19.076518 -11.14121 873.73893 -159.9939 0 92.434061 11 + 50 861.16008 -1954.4602 -1903.1211 -1896.648 -2784.8451 3.8269988 0.1579331 0 79.851597 3.349208 -78.066133 0 32.628942 -7.9565363 872.8186 -190.98572 0 114.76001 10 + 60 1167.7831 -1971.8435 -1902.2247 -3482.927 -2705.8639 -17.121541 0.22749081 0 44.507721 7.8559737 -74.789039 0 16.2565 -4.6046718 835.8307 -188.33687 0 114.19412 10 + 70 1439.9897 -1989.3024 -1903.4557 23845.83 -2890.7894 31.958658 0.26671716 0 85.758318 3.1804201 -71.002959 0 24.35723 -10.31128 905.86819 -175.38505 0 106.79678 10 + 80 502.39931 -1930.7551 -1900.804 -20356.375 -2703.8109 -18.66274 0.1128617 0 99.80351 2.0329611 -76.171312 0 19.236815 -6.2786426 826.47424 -166.03148 0 92.539616 9 + 90 749.08601 -1946.984 -1902.3264 17798.716 -2863.7585 42.068606 0.24338046 0 96.181674 0.96183581 -69.955564 0 24.615514 -11.582742 903.68878 -190.13822 0 120.69121 11 + 100 1109.6946 -1968.588 -1902.4322 -4490.4001 -2755.899 -7.1224954 0.21757676 0 61.805955 7.0825894 -75.645488 0 20.115437 -6.2372635 863.56481 -198.56946 0 122.09935 10 +Loop time of 0.23792 on 1 procs for 100 steps with 21 atoms + +Performance: 36.315 ns/day, 0.661 hours/ns, 420.310 timesteps/s +99.3% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.21046 | 0.21046 | 0.21046 | 0.0 | 88.46 +Neigh | 0.010947 | 0.010947 | 0.010947 | 0.0 | 4.60 +Comm | 0.00060345 | 0.00060345 | 0.00060345 | 0.0 | 0.25 +Output | 0.00071705 | 0.00071705 | 0.00071705 | 0.0 | 0.30 +Modify | 0.014873 | 0.014873 | 0.014873 | 0.0 | 6.25 +Other | | 0.0003213 | | | 0.14 + +Nlocal: 21.0000 ave 21 max 21 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 546.000 ave 546 max 546 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 1096.00 ave 1096 max 1096 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 1306.00 ave 1306 max 1306 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 1306 +Ave neighs/atom = 62.190476 +Neighbor list builds = 10 +Dangerous builds not checked +Total wall time: 0:00:00 diff --git a/examples/reaxff/log.21Jul21.reaxff.rdx-shielded.g++.4 b/examples/reaxff/log.21Jul21.reaxff.rdx-shielded.g++.4 new file mode 100644 index 0000000000..4840b5fa2b --- /dev/null +++ b/examples/reaxff/log.21Jul21.reaxff.rdx-shielded.g++.4 @@ -0,0 +1,144 @@ +LAMMPS (2 Jul 2021) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# ReaxFF potential for RDX system + +units real + +atom_style charge +read_data data.rdx +Reading data file ... + orthogonal box = (35.000000 35.000000 35.000000) to (48.000000 48.000000 48.000000) + 1 by 2 by 2 MPI processor grid + reading atoms ... + 21 atoms + read_data CPU = 0.003 seconds + +pair_style reaxff control.reax_c.rdx +WARNING: Ignoring inactive control parameter: simulation_name (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: energy_update_freq (src/REAXFF/reaxff_control.cpp:97) +WARNING: Support for writing native trajectories has been removed after LAMMPS version 8 April 2021 (src/REAXFF/reaxff_control.cpp:113) +WARNING: Ignoring inactive control parameter: traj_title (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_forces (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_velocities (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: bond_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: angle_info (src/REAXFF/reaxff_control.cpp:97) +pair_coeff * * ffield.reax C H O N +Reading potential file ffield.reax with DATE: 2010-02-19 + +compute reax all pair reaxff + +variable eb equal c_reax[1] +variable ea equal c_reax[2] +variable elp equal c_reax[3] +variable emol equal c_reax[4] +variable ev equal c_reax[5] +variable epen equal c_reax[6] +variable ecoa equal c_reax[7] +variable ehb equal c_reax[8] +variable et equal c_reax[9] +variable eco equal c_reax[10] +variable ew equal c_reax[11] +variable ep equal c_reax[12] +variable efi equal c_reax[13] +variable eqeq equal c_reax[14] + +neighbor 2.5 bin +neigh_modify every 10 delay 0 check no + +fix 1 all nve +fix 2 all qeq/shielded 1 10.0 1.0e-6 100 reaxff +variable nqeq equal f_2 + +thermo 10 +thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + +timestep 1.0 + +#dump 1 all atom 10 dump.reaxff.rdx + +#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +run 100 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- pair reaxff command: + +@Article{Aktulga12, + author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama}, + title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques}, + journal = {Parallel Computing}, + year = 2012, + volume = 38, + pages = {245--259} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Neighbor list info ... + update every 10 steps, delay 0 steps, check no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 12.5 + ghost atom cutoff = 12.5 + binsize = 6.25, bins = 3 3 3 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair reaxff, perpetual + attributes: half, newton off, ghost + pair build: half/bin/newtoff/ghost + stencil: full/ghost/bin/3d + bin: standard + (2) fix qeq/shielded, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 9.856 | 11.02 | 12.23 Mbytes +Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + 0 0 -1884.3081 -1884.3081 27186.179 -2958.4712 79.527715 0.31082031 0 98.589783 25.846176 -0.18034154 0 16.709078 -9.1620736 938.43732 -244.79963 0 168.88428 12 + 10 1288.6115 -1989.6644 -1912.8422 -19456.352 -2734.6769 -15.607219 0.20177961 0 54.629556 3.1252291 -77.7067 0 14.933901 -5.8108542 843.92074 -180.43321 0 107.75934 8 + 20 538.95831 -1942.7037 -1910.5731 -10725.628 -2803.7395 7.9078316 0.077926725 0 81.610046 0.22951948 -57.55711 0 30.331206 -10.178049 878.99011 -159.68964 0 89.313879 6 + 30 463.09528 -1933.5765 -1905.9685 -33255.523 -2749.859 -8.015479 0.027628772 0 81.627413 0.11972402 -50.262283 0 20.82031 -9.6327014 851.88714 -149.49498 0 79.205717 8 + 40 885.49492 -1958.9125 -1906.1227 -4814.6646 -2795.6439 9.1506063 0.13747482 0 70.948055 0.2436053 -57.862686 0 19.076515 -11.141211 873.73888 -159.99391 0 92.434067 11 + 50 861.15982 -1954.4602 -1903.1212 -1896.7209 -2784.845 3.8269674 0.15793308 0 79.851587 3.3492059 -78.06613 0 32.628933 -7.9565341 872.81849 -190.9857 0 114.75999 10 + 60 1167.7827 -1971.8436 -1902.2248 -3482.8501 -2705.8641 -17.121497 0.22749093 0 44.507698 7.8559911 -74.78902 0 16.256511 -4.6046743 835.83081 -188.33692 0 114.19416 10 + 70 1439.9904 -1989.3026 -1903.4558 23846.02 -2890.7894 31.95863 0.26671716 0 85.758232 3.1804311 -71.002978 0 24.357223 -10.311272 905.86809 -175.38506 0 106.79678 10 + 80 502.39774 -1930.7552 -1900.8041 -20356.27 -2703.8119 -18.66246 0.11286127 0 99.803504 2.0329528 -76.171312 0 19.236983 -6.278675 826.47474 -166.03143 0 92.539573 9 + 90 749.07673 -1946.984 -1902.3269 17798.497 -2863.7581 42.06868 0.24338043 0 96.181508 0.9618341 -69.955454 0 24.615416 -11.582759 903.68853 -190.13817 0 120.69116 11 + 100 1109.6909 -1968.5881 -1902.4325 -4490.3603 -2755.8994 -7.1223998 0.21757662 0 61.805909 7.0826145 -75.645472 0 20.115466 -6.2372802 863.565 -198.56948 0 122.09938 10 +Loop time of 0.427646 on 4 procs for 100 steps with 21 atoms + +Performance: 20.204 ns/day, 1.188 hours/ns, 233.838 timesteps/s +88.6% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.1373 | 0.20047 | 0.27938 | 11.8 | 46.88 +Neigh | 0.0067 | 0.009334 | 0.01249 | 2.1 | 2.18 +Comm | 0.057132 | 0.13685 | 0.19972 | 14.4 | 32.00 +Output | 0.00078935 | 0.0013884 | 0.0031266 | 2.7 | 0.32 +Modify | 0.075213 | 0.079164 | 0.082556 | 0.9 | 18.51 +Other | | 0.0004359 | | | 0.10 + +Nlocal: 5.25000 ave 15 max 0 min +Histogram: 1 0 2 0 0 0 0 0 0 1 +Nghost: 355.500 ave 432 max 282 min +Histogram: 1 0 0 0 1 1 0 0 0 1 +Neighs: 298.750 ave 822 max 0 min +Histogram: 1 0 2 0 0 0 0 0 0 1 +FullNghs: 326.500 ave 927 max 0 min +Histogram: 1 0 2 0 0 0 0 0 0 1 + +Total # of neighbors = 1306 +Ave neighs/atom = 62.190476 +Neighbor list builds = 10 +Dangerous builds not checked +Total wall time: 0:00:00 diff --git a/examples/reaxff/log.21Jul21.reaxff.rdx.g++.1 b/examples/reaxff/log.21Jul21.reaxff.rdx.g++.1 new file mode 100644 index 0000000000..89e5c606c2 --- /dev/null +++ b/examples/reaxff/log.21Jul21.reaxff.rdx.g++.1 @@ -0,0 +1,154 @@ +LAMMPS (2 Jul 2021) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# ReaxFF potential for RDX system + +units real + +atom_style charge +read_data data.rdx +Reading data file ... + orthogonal box = (35.000000 35.000000 35.000000) to (48.000000 48.000000 48.000000) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 21 atoms + read_data CPU = 0.001 seconds + +pair_style reaxff control.reax_c.rdx +WARNING: Ignoring inactive control parameter: simulation_name (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: energy_update_freq (src/REAXFF/reaxff_control.cpp:97) +WARNING: Support for writing native trajectories has been removed after LAMMPS version 8 April 2021 (src/REAXFF/reaxff_control.cpp:113) +WARNING: Ignoring inactive control parameter: traj_title (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_forces (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_velocities (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: bond_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: angle_info (src/REAXFF/reaxff_control.cpp:97) +pair_coeff * * ffield.reax C H O N +Reading potential file ffield.reax with DATE: 2010-02-19 + +compute reax all pair reaxff + +variable eb equal c_reax[1] +variable ea equal c_reax[2] +variable elp equal c_reax[3] +variable emol equal c_reax[4] +variable ev equal c_reax[5] +variable epen equal c_reax[6] +variable ecoa equal c_reax[7] +variable ehb equal c_reax[8] +variable et equal c_reax[9] +variable eco equal c_reax[10] +variable ew equal c_reax[11] +variable ep equal c_reax[12] +variable efi equal c_reax[13] +variable eqeq equal c_reax[14] + +neighbor 2.5 bin +neigh_modify every 10 delay 0 check no + +fix 1 all nve +fix 2 all qeq/reaxff 1 0.0 10.0 1.0e-6 reaxff + +variable nqeq equal f_2 + +thermo 10 +thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + +timestep 1.0 + +#dump 1 all atom 10 dump.reaxff.rdx + +#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +run 100 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- pair reaxff command: + +@Article{Aktulga12, + author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama}, + title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques}, + journal = {Parallel Computing}, + year = 2012, + volume = 38, + pages = {245--259} +} + +- fix qeq/reaxff command: + +@Article{Aktulga12, + author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama}, + title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques}, + journal = {Parallel Computing}, + year = 2012, + volume = 38, + pages = {245--259} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Neighbor list info ... + update every 10 steps, delay 0 steps, check no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 12.5 + ghost atom cutoff = 12.5 + binsize = 6.25, bins = 3 3 3 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair reaxff, perpetual + attributes: half, newton off, ghost + pair build: half/bin/newtoff/ghost + stencil: full/ghost/bin/3d + bin: standard + (2) fix qeq/reaxff, perpetual, copy from (1) + attributes: half, newton off, ghost + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 13.36 | 13.36 | 13.36 Mbytes +Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + 0 0 -1884.3081 -1884.3081 27186.181 -2958.4712 79.527715 0.31082031 0 98.589783 25.846176 -0.18034154 0 16.709078 -9.1620736 938.43732 -244.79931 0 168.88396 12.5 + 10 1288.6116 -1989.6644 -1912.8422 -19456.353 -2734.6769 -15.607221 0.2017796 0 54.629557 3.125229 -77.7067 0 14.933901 -5.8108541 843.92073 -180.43321 0 107.75935 8 + 20 538.95819 -1942.7037 -1910.5731 -10725.639 -2803.7394 7.9078269 0.07792668 0 81.610053 0.22951941 -57.557107 0 30.331207 -10.178049 878.99009 -159.68914 0 89.313379 7 + 30 463.09535 -1933.5765 -1905.9686 -33255.546 -2749.859 -8.0154745 0.02762893 0 81.627395 0.11972413 -50.262293 0 20.820303 -9.6327015 851.88715 -149.49499 0 79.205727 8 + 40 885.49171 -1958.9125 -1906.1229 -4814.6856 -2795.644 9.150669 0.13747498 0 70.947982 0.24360485 -57.862663 0 19.076496 -11.141218 873.73893 -159.99393 0 92.434096 11 + 50 861.16578 -1954.4599 -1903.1205 -1896.7713 -2784.845 3.8270515 0.15793266 0 79.851823 3.3492142 -78.06613 0 32.629016 -7.956541 872.81838 -190.98567 0 114.75995 10 + 60 1167.7852 -1971.8429 -1902.224 -3482.7305 -2705.863 -17.12171 0.22749077 0 44.507654 7.8560745 -74.788955 0 16.256483 -4.6046431 835.8304 -188.33691 0 114.19413 10 + 70 1439.9966 -1989.3024 -1903.4553 23845.651 -2890.7895 31.958845 0.26671721 0 85.758695 3.1803544 -71.002903 0 24.357134 -10.31131 905.86775 -175.38471 0 106.79648 10 + 80 502.39438 -1930.7544 -1900.8035 -20356.316 -2703.8115 -18.662467 0.11286011 0 99.804201 2.0329024 -76.171317 0 19.237028 -6.2786907 826.47451 -166.03125 0 92.539398 9 + 90 749.08499 -1946.9838 -1902.3262 17798.51 -2863.7576 42.068717 0.2433807 0 96.181613 0.96184887 -69.955448 0 24.615302 -11.582765 903.68818 -190.13843 0 120.69141 11 + 100 1109.6968 -1968.5874 -1902.4315 -4490.1018 -2755.8965 -7.1231014 0.21757699 0 61.806018 7.0827673 -75.645345 0 20.114997 -6.2371964 863.5635 -198.56976 0 122.09961 10.5 +Loop time of 0.231802 on 1 procs for 100 steps with 21 atoms + +Performance: 37.273 ns/day, 0.644 hours/ns, 431.402 timesteps/s +99.2% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.20857 | 0.20857 | 0.20857 | 0.0 | 89.98 +Neigh | 0.010489 | 0.010489 | 0.010489 | 0.0 | 4.52 +Comm | 0.00059632 | 0.00059632 | 0.00059632 | 0.0 | 0.26 +Output | 0.00067498 | 0.00067498 | 0.00067498 | 0.0 | 0.29 +Modify | 0.011161 | 0.011161 | 0.011161 | 0.0 | 4.82 +Other | | 0.000307 | | | 0.13 + +Nlocal: 21.0000 ave 21 max 21 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 546.000 ave 546 max 546 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 1096.00 ave 1096 max 1096 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 1096 +Ave neighs/atom = 52.190476 +Neighbor list builds = 10 +Dangerous builds not checked +Total wall time: 0:00:00 diff --git a/examples/reaxff/log.21Jul21.reaxff.rdx.g++.4 b/examples/reaxff/log.21Jul21.reaxff.rdx.g++.4 new file mode 100644 index 0000000000..29c36c54f0 --- /dev/null +++ b/examples/reaxff/log.21Jul21.reaxff.rdx.g++.4 @@ -0,0 +1,154 @@ +LAMMPS (2 Jul 2021) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# ReaxFF potential for RDX system + +units real + +atom_style charge +read_data data.rdx +Reading data file ... + orthogonal box = (35.000000 35.000000 35.000000) to (48.000000 48.000000 48.000000) + 1 by 2 by 2 MPI processor grid + reading atoms ... + 21 atoms + read_data CPU = 0.001 seconds + +pair_style reaxff control.reax_c.rdx +WARNING: Ignoring inactive control parameter: simulation_name (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: energy_update_freq (src/REAXFF/reaxff_control.cpp:97) +WARNING: Support for writing native trajectories has been removed after LAMMPS version 8 April 2021 (src/REAXFF/reaxff_control.cpp:113) +WARNING: Ignoring inactive control parameter: traj_title (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_forces (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_velocities (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: bond_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: angle_info (src/REAXFF/reaxff_control.cpp:97) +pair_coeff * * ffield.reax C H O N +Reading potential file ffield.reax with DATE: 2010-02-19 + +compute reax all pair reaxff + +variable eb equal c_reax[1] +variable ea equal c_reax[2] +variable elp equal c_reax[3] +variable emol equal c_reax[4] +variable ev equal c_reax[5] +variable epen equal c_reax[6] +variable ecoa equal c_reax[7] +variable ehb equal c_reax[8] +variable et equal c_reax[9] +variable eco equal c_reax[10] +variable ew equal c_reax[11] +variable ep equal c_reax[12] +variable efi equal c_reax[13] +variable eqeq equal c_reax[14] + +neighbor 2.5 bin +neigh_modify every 10 delay 0 check no + +fix 1 all nve +fix 2 all qeq/reaxff 1 0.0 10.0 1.0e-6 reaxff + +variable nqeq equal f_2 + +thermo 10 +thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + +timestep 1.0 + +#dump 1 all atom 10 dump.reaxff.rdx + +#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +run 100 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- pair reaxff command: + +@Article{Aktulga12, + author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama}, + title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques}, + journal = {Parallel Computing}, + year = 2012, + volume = 38, + pages = {245--259} +} + +- fix qeq/reaxff command: + +@Article{Aktulga12, + author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama}, + title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques}, + journal = {Parallel Computing}, + year = 2012, + volume = 38, + pages = {245--259} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Neighbor list info ... + update every 10 steps, delay 0 steps, check no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 12.5 + ghost atom cutoff = 12.5 + binsize = 6.25, bins = 3 3 3 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair reaxff, perpetual + attributes: half, newton off, ghost + pair build: half/bin/newtoff/ghost + stencil: full/ghost/bin/3d + bin: standard + (2) fix qeq/reaxff, perpetual, copy from (1) + attributes: half, newton off, ghost + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 9.353 | 10.52 | 11.73 Mbytes +Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + 0 0 -1884.3081 -1884.3081 27186.18 -2958.4712 79.527715 0.31082031 0 98.589783 25.846176 -0.18034154 0 16.709078 -9.1620736 938.43732 -244.79953 0 168.88418 12 + 10 1288.6115 -1989.6644 -1912.8422 -19456.352 -2734.6769 -15.607219 0.20177961 0 54.629556 3.1252292 -77.7067 0 14.933901 -5.8108542 843.92074 -180.43321 0 107.75934 8 + 20 538.95847 -1942.7037 -1910.5731 -10725.668 -2803.7395 7.9078328 0.077926688 0 81.610045 0.22951933 -57.557103 0 30.331203 -10.178049 878.99015 -159.69262 0 89.316856 7 + 30 463.09521 -1933.5765 -1905.9685 -33255.503 -2749.8591 -8.0154614 0.027628708 0 81.627408 0.11972393 -50.262275 0 20.820319 -9.6327031 851.88721 -149.49497 0 79.205707 8 + 40 885.49559 -1958.9126 -1906.1227 -4814.661 -2795.644 9.1506103 0.13747486 0 70.948058 0.24360549 -57.862693 0 19.076514 -11.141211 873.73894 -159.9939 0 92.434063 11 + 50 861.16222 -1954.4601 -1903.1209 -1896.7328 -2784.8449 3.8269573 0.15793301 0 79.851661 3.3492101 -78.066131 0 32.628939 -7.9565311 872.81847 -190.9857 0 114.75999 10 + 60 1167.7838 -1971.8434 -1902.2246 -3482.8253 -2705.8639 -17.121553 0.22749078 0 44.507707 7.8560156 -74.789002 0 16.256509 -4.6046674 835.83076 -188.33689 0 114.19413 10 + 70 1439.9922 -1989.3024 -1903.4556 23845.682 -2890.7894 31.958742 0.26671722 0 85.758402 3.1803955 -71.002937 0 24.357176 -10.311293 905.86805 -175.38494 0 106.79668 10 + 80 502.39847 -1930.7549 -1900.8038 -20356.357 -2703.8111 -18.662668 0.11286141 0 99.803668 2.0329484 -76.17132 0 19.236866 -6.2786536 826.47435 -166.03145 0 92.539587 9 + 90 749.0857 -1946.984 -1902.3263 17798.657 -2863.7584 42.068704 0.24338054 0 96.181666 0.96183837 -69.955527 0 24.615445 -11.58275 903.68864 -190.13828 0 120.69127 11 + 100 1109.695 -1968.5879 -1902.4321 -4490.3441 -2755.8984 -7.1226574 0.21757683 0 61.806014 7.0826278 -75.645456 0 20.115306 -6.2372466 863.56451 -198.56953 0 122.09941 10.5 +Loop time of 0.371707 on 4 procs for 100 steps with 21 atoms + +Performance: 23.244 ns/day, 1.033 hours/ns, 269.029 timesteps/s +91.8% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.13518 | 0.19123 | 0.24947 | 9.7 | 51.45 +Neigh | 0.0073075 | 0.0096968 | 0.012228 | 1.8 | 2.61 +Comm | 0.034511 | 0.093329 | 0.14912 | 14.0 | 25.11 +Output | 0.00081416 | 0.0011345 | 0.0019655 | 1.4 | 0.31 +Modify | 0.073177 | 0.075449 | 0.078618 | 0.7 | 20.30 +Other | | 0.0008711 | | | 0.23 + +Nlocal: 5.25000 ave 15 max 0 min +Histogram: 1 0 2 0 0 0 0 0 0 1 +Nghost: 355.500 ave 432 max 282 min +Histogram: 1 0 0 0 1 1 0 0 0 1 +Neighs: 298.750 ave 822 max 0 min +Histogram: 1 0 2 0 0 0 0 0 0 1 + +Total # of neighbors = 1195 +Ave neighs/atom = 56.904762 +Neighbor list builds = 10 +Dangerous builds not checked +Total wall time: 0:00:00 diff --git a/examples/reaxff/log.21Jul21.reaxff.tatb-shielded.g++.1 b/examples/reaxff/log.21Jul21.reaxff.tatb-shielded.g++.1 new file mode 100644 index 0000000000..4c84081d44 --- /dev/null +++ b/examples/reaxff/log.21Jul21.reaxff.tatb-shielded.g++.1 @@ -0,0 +1,142 @@ +LAMMPS (2 Jul 2021) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# ReaxFF potential for TATB system + +units real + +atom_style charge +read_data data.tatb +Reading data file ... + triclinic box = (0.0000000 0.0000000 0.0000000) to (13.624000 17.114915 15.182639) with tilt (-5.7531563 -6.3254660 7.4257288) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 384 atoms + read_data CPU = 0.002 seconds + +pair_style reaxff control.reax_c.tatb +WARNING: Ignoring inactive control parameter: simulation_name (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: energy_update_freq (src/REAXFF/reaxff_control.cpp:97) +WARNING: Support for writing native trajectories has been removed after LAMMPS version 8 April 2021 (src/REAXFF/reaxff_control.cpp:113) +WARNING: Ignoring inactive control parameter: traj_title (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_forces (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_velocities (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: bond_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: angle_info (src/REAXFF/reaxff_control.cpp:97) +pair_coeff * * ffield.reax C H O N +Reading potential file ffield.reax with DATE: 2010-02-19 + +compute reax all pair reaxff + +variable eb equal c_reax[1] +variable ea equal c_reax[2] +variable elp equal c_reax[3] +variable emol equal c_reax[4] +variable ev equal c_reax[5] +variable epen equal c_reax[6] +variable ecoa equal c_reax[7] +variable ehb equal c_reax[8] +variable et equal c_reax[9] +variable eco equal c_reax[10] +variable ew equal c_reax[11] +variable ep equal c_reax[12] +variable efi equal c_reax[13] +variable eqeq equal c_reax[14] + +neighbor 2.5 bin +neigh_modify delay 0 every 5 check no + +fix 1 all nve +fix 2 all qeq/shielded 1 10.0 1.0e-6 100 reaxff +fix 4 all reaxff/bonds 5 bonds.reaxff +variable nqeq equal f_2 + +thermo 5 +thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + +timestep 0.0625 + +#dump 1 all custom 100 dump.reaxff.tatb id type q x y z + +#dump 2 all image 5 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 5 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 3 all reaxff/species 1 5 5 species.tatb + +run 25 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- pair reaxff command: + +@Article{Aktulga12, + author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama}, + title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques}, + journal = {Parallel Computing}, + year = 2012, + volume = 38, + pages = {245--259} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Neighbor list info ... + update every 5 steps, delay 0 steps, check no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 12.5 + ghost atom cutoff = 12.5 + binsize = 6.25, bins = 5 4 3 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair reaxff, perpetual + attributes: half, newton off, ghost + pair build: half/bin/newtoff/ghost + stencil: full/ghost/bin/3d + bin: standard + (2) fix qeq/shielded, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 141.3 | 141.3 | 141.3 Mbytes +Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + 0 0 -44760.998 -44760.998 7827.7874 -61120.591 486.4378 4.7236377 0 1574.1033 20.788929 -279.51642 -1556.4696 252.57147 -655.84699 18862.412 -8740.6395 0 6391.0275 31 + 5 0.61603968 -44761.698 -44760.994 8934.6339 -61118.769 486.81263 4.7234094 0 1573.9241 20.768834 -278.24084 -1557.6713 252.64377 -655.74435 18859.379 -8738.1905 0 6388.6665 8 + 10 2.3525543 -44763.227 -44760.541 12288.589 -61113.174 487.82738 4.7226863 0 1573.411 20.705939 -274.50357 -1560.7569 252.85309 -655.44063 18850.391 -8730.9762 0 6381.714 10 + 15 4.9013256 -44766.36 -44760.764 17716.957 -61103.434 489.14721 4.7213644 0 1572.6349 20.593139 -268.56847 -1566.3829 252.95174 -654.96611 18835.777 -8719.2536 0 6370.4198 9 + 20 7.8294699 -44769.686 -44760.747 25205.552 -61089.006 490.21314 4.7193021 0 1571.7022 20.420943 -260.85565 -1573.7378 253.3539 -654.31623 18816.07 -8703.5055 0 6355.2567 8 + 25 10.697916 -44772.904 -44760.691 34232.955 -61069.308 490.25886 4.7163736 0 1570.7397 20.181347 -251.91377 -1582.3261 253.82253 -653.53184 18791.975 -8684.308 0 6336.7889 7 +Loop time of 3.31728 on 1 procs for 25 steps with 384 atoms + +Performance: 0.041 ns/day, 589.738 hours/ns, 7.536 timesteps/s +99.4% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 1.9321 | 1.9321 | 1.9321 | 0.0 | 58.24 +Neigh | 0.6452 | 0.6452 | 0.6452 | 0.0 | 19.45 +Comm | 0.0020122 | 0.0020122 | 0.0020122 | 0.0 | 0.06 +Output | 0.00030173 | 0.00030173 | 0.00030173 | 0.0 | 0.01 +Modify | 0.73726 | 0.73726 | 0.73726 | 0.0 | 22.22 +Other | | 0.0003829 | | | 0.01 + +Nlocal: 384.000 ave 384 max 384 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 7559.00 ave 7559 max 7559 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 286828.0 ave 286828 max 286828 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 336304.0 ave 336304 max 336304 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 336304 +Ave neighs/atom = 875.79167 +Neighbor list builds = 5 +Dangerous builds not checked +Total wall time: 0:00:03 diff --git a/examples/reaxff/log.21Jul21.reaxff.tatb-shielded.g++.4 b/examples/reaxff/log.21Jul21.reaxff.tatb-shielded.g++.4 new file mode 100644 index 0000000000..d4cb8a0190 --- /dev/null +++ b/examples/reaxff/log.21Jul21.reaxff.tatb-shielded.g++.4 @@ -0,0 +1,142 @@ +LAMMPS (2 Jul 2021) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# ReaxFF potential for TATB system + +units real + +atom_style charge +read_data data.tatb +Reading data file ... + triclinic box = (0.0000000 0.0000000 0.0000000) to (13.624000 17.114915 15.182639) with tilt (-5.7531563 -6.3254660 7.4257288) + 1 by 2 by 2 MPI processor grid + reading atoms ... + 384 atoms + read_data CPU = 0.004 seconds + +pair_style reaxff control.reax_c.tatb +WARNING: Ignoring inactive control parameter: simulation_name (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: energy_update_freq (src/REAXFF/reaxff_control.cpp:97) +WARNING: Support for writing native trajectories has been removed after LAMMPS version 8 April 2021 (src/REAXFF/reaxff_control.cpp:113) +WARNING: Ignoring inactive control parameter: traj_title (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_forces (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_velocities (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: bond_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: angle_info (src/REAXFF/reaxff_control.cpp:97) +pair_coeff * * ffield.reax C H O N +Reading potential file ffield.reax with DATE: 2010-02-19 + +compute reax all pair reaxff + +variable eb equal c_reax[1] +variable ea equal c_reax[2] +variable elp equal c_reax[3] +variable emol equal c_reax[4] +variable ev equal c_reax[5] +variable epen equal c_reax[6] +variable ecoa equal c_reax[7] +variable ehb equal c_reax[8] +variable et equal c_reax[9] +variable eco equal c_reax[10] +variable ew equal c_reax[11] +variable ep equal c_reax[12] +variable efi equal c_reax[13] +variable eqeq equal c_reax[14] + +neighbor 2.5 bin +neigh_modify delay 0 every 5 check no + +fix 1 all nve +fix 2 all qeq/shielded 1 10.0 1.0e-6 100 reaxff +fix 4 all reaxff/bonds 5 bonds.reaxff +variable nqeq equal f_2 + +thermo 5 +thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + +timestep 0.0625 + +#dump 1 all custom 100 dump.reaxff.tatb id type q x y z + +#dump 2 all image 5 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 5 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 3 all reaxff/species 1 5 5 species.tatb + +run 25 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- pair reaxff command: + +@Article{Aktulga12, + author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama}, + title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques}, + journal = {Parallel Computing}, + year = 2012, + volume = 38, + pages = {245--259} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Neighbor list info ... + update every 5 steps, delay 0 steps, check no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 12.5 + ghost atom cutoff = 12.5 + binsize = 6.25, bins = 5 4 3 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair reaxff, perpetual + attributes: half, newton off, ghost + pair build: half/bin/newtoff/ghost + stencil: full/ghost/bin/3d + bin: standard + (2) fix qeq/shielded, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 94.50 | 94.50 | 94.50 Mbytes +Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + 0 0 -44760.998 -44760.998 7827.7865 -61120.591 486.4378 4.7236377 0 1574.1033 20.788929 -279.51642 -1556.4696 252.57147 -655.84699 18862.412 -8740.6398 0 6391.0278 31 + 5 0.61603964 -44761.698 -44760.994 8934.6344 -61118.769 486.81263 4.7234094 0 1573.9241 20.768834 -278.24084 -1557.6713 252.64377 -655.74435 18859.379 -8738.1911 0 6388.6671 9 + 10 2.3525559 -44763.227 -44760.541 12288.611 -61113.174 487.82738 4.7226863 0 1573.411 20.705939 -274.50357 -1560.7569 252.85309 -655.44063 18850.391 -8730.9712 0 6381.7089 11 + 15 4.9013319 -44766.36 -44760.764 17716.965 -61103.434 489.14721 4.7213644 0 1572.6349 20.593139 -268.56847 -1566.3829 252.95174 -654.96611 18835.777 -8719.2514 0 6370.4176 9 + 20 7.8294706 -44769.686 -44760.747 25205.511 -61089.006 490.21313 4.719302 0 1571.7022 20.420943 -260.85565 -1573.7378 253.3539 -654.31623 18816.07 -8703.5196 0 6355.2708 7 + 25 10.69792 -44772.904 -44760.691 34232.831 -61069.308 490.25885 4.7163736 0 1570.7397 20.181346 -251.91377 -1582.3261 253.82253 -653.53184 18791.975 -8684.353 0 6336.8339 11 +Loop time of 2.66226 on 4 procs for 25 steps with 384 atoms + +Performance: 0.051 ns/day, 473.290 hours/ns, 9.391 timesteps/s +96.9% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 1.7311 | 1.7619 | 1.794 | 2.0 | 66.18 +Neigh | 0.46483 | 0.46901 | 0.47348 | 0.5 | 17.62 +Comm | 0.039253 | 0.073989 | 0.10705 | 10.7 | 2.78 +Output | 0.0012206 | 0.0080282 | 0.010299 | 4.4 | 0.30 +Modify | 0.34359 | 0.3488 | 0.36264 | 1.4 | 13.10 +Other | | 0.0005529 | | | 0.02 + +Nlocal: 96.0000 ave 96 max 96 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Nghost: 5118.00 ave 5118 max 5118 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Neighs: 79754.0 ave 79754 max 79754 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +FullNghs: 84076.0 ave 84076 max 84076 min +Histogram: 4 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 336304 +Ave neighs/atom = 875.79167 +Neighbor list builds = 5 +Dangerous builds not checked +Total wall time: 0:00:03 diff --git a/examples/reaxff/log.21Jul21.reaxff.tatb.g++.1 b/examples/reaxff/log.21Jul21.reaxff.tatb.g++.1 new file mode 100644 index 0000000000..2e1c7a5b26 --- /dev/null +++ b/examples/reaxff/log.21Jul21.reaxff.tatb.g++.1 @@ -0,0 +1,151 @@ +LAMMPS (2 Jul 2021) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# ReaxFF potential for TATB system + +units real + +atom_style charge +read_data data.tatb +Reading data file ... + triclinic box = (0.0000000 0.0000000 0.0000000) to (13.624000 17.114915 15.182639) with tilt (-5.7531563 -6.3254660 7.4257288) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 384 atoms + read_data CPU = 0.008 seconds + +pair_style reaxff control.reax_c.tatb +WARNING: Ignoring inactive control parameter: simulation_name (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: energy_update_freq (src/REAXFF/reaxff_control.cpp:97) +WARNING: Support for writing native trajectories has been removed after LAMMPS version 8 April 2021 (src/REAXFF/reaxff_control.cpp:113) +WARNING: Ignoring inactive control parameter: traj_title (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_forces (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_velocities (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: bond_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: angle_info (src/REAXFF/reaxff_control.cpp:97) +pair_coeff * * ffield.reax C H O N +Reading potential file ffield.reax with DATE: 2010-02-19 + +compute reax all pair reaxff + +variable eb equal c_reax[1] +variable ea equal c_reax[2] +variable elp equal c_reax[3] +variable emol equal c_reax[4] +variable ev equal c_reax[5] +variable epen equal c_reax[6] +variable ecoa equal c_reax[7] +variable ehb equal c_reax[8] +variable et equal c_reax[9] +variable eco equal c_reax[10] +variable ew equal c_reax[11] +variable ep equal c_reax[12] +variable efi equal c_reax[13] +variable eqeq equal c_reax[14] + +neighbor 2.5 bin +neigh_modify delay 0 every 5 check no + +fix 1 all nve +fix 2 all qeq/reaxff 1 0.0 10.0 1.0e-6 reaxff +fix 4 all reaxff/bonds 5 bonds.reaxff +variable nqeq equal f_2 + +thermo 5 +thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + +timestep 0.0625 + +#dump 1 all custom 100 dump.reaxff.tatb id type q x y z + +#dump 2 all image 5 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 5 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 3 all reaxff/species 1 5 5 species.tatb + +run 25 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- pair reaxff command: + +@Article{Aktulga12, + author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama}, + title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques}, + journal = {Parallel Computing}, + year = 2012, + volume = 38, + pages = {245--259} +} + +- fix qeq/reaxff command: + +@Article{Aktulga12, + author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama}, + title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques}, + journal = {Parallel Computing}, + year = 2012, + volume = 38, + pages = {245--259} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Neighbor list info ... + update every 5 steps, delay 0 steps, check no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 12.5 + ghost atom cutoff = 12.5 + binsize = 6.25, bins = 5 4 3 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair reaxff, perpetual + attributes: half, newton off, ghost + pair build: half/bin/newtoff/ghost + stencil: full/ghost/bin/3d + bin: standard + (2) fix qeq/reaxff, perpetual, copy from (1) + attributes: half, newton off, ghost + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 148.1 | 148.1 | 148.1 Mbytes +Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + 0 0 -44760.998 -44760.998 7827.7878 -61120.591 486.4378 4.7236377 0 1574.1033 20.788929 -279.51642 -1556.4696 252.57147 -655.84699 18862.412 -8740.6394 0 6391.0274 31.5 + 5 0.61603968 -44761.698 -44760.994 8934.6346 -61118.769 486.81263 4.7234094 0 1573.9241 20.768834 -278.24084 -1557.6713 252.64377 -655.74435 18859.379 -8738.1911 0 6388.6671 9 + 10 2.3525552 -44763.227 -44760.541 12288.581 -61113.174 487.82738 4.7226863 0 1573.411 20.705939 -274.50357 -1560.7569 252.85309 -655.44063 18850.391 -8730.9765 0 6381.7142 10.5 + 15 4.9013309 -44766.36 -44760.764 17716.918 -61103.434 489.14722 4.7213644 0 1572.6349 20.593139 -268.56847 -1566.3829 252.95174 -654.96611 18835.777 -8719.2622 0 6370.4284 9.5 + 20 7.829469 -44769.686 -44760.747 25205.568 -61089.006 490.21314 4.719302 0 1571.7022 20.420943 -260.85564 -1573.7378 253.3539 -654.31623 18816.07 -8703.5126 0 6355.2639 8 + 25 10.697899 -44772.904 -44760.691 34232.788 -61069.308 490.25886 4.7163736 0 1570.7397 20.181346 -251.91377 -1582.3261 253.82253 -653.53184 18791.975 -8684.3619 0 6336.8427 11 +Loop time of 2.91659 on 1 procs for 25 steps with 384 atoms + +Performance: 0.046 ns/day, 518.504 hours/ns, 8.572 timesteps/s +99.6% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 1.9139 | 1.9139 | 1.9139 | 0.0 | 65.62 +Neigh | 0.5948 | 0.5948 | 0.5948 | 0.0 | 20.39 +Comm | 0.0020205 | 0.0020205 | 0.0020205 | 0.0 | 0.07 +Output | 0.00031287 | 0.00031287 | 0.00031287 | 0.0 | 0.01 +Modify | 0.40513 | 0.40513 | 0.40513 | 0.0 | 13.89 +Other | | 0.0003856 | | | 0.01 + +Nlocal: 384.000 ave 384 max 384 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 7559.00 ave 7559 max 7559 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 286828.0 ave 286828 max 286828 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 286828 +Ave neighs/atom = 746.94792 +Neighbor list builds = 5 +Dangerous builds not checked +Total wall time: 0:00:03 diff --git a/examples/reaxff/log.21Jul21.reaxff.tatb.g++.4 b/examples/reaxff/log.21Jul21.reaxff.tatb.g++.4 new file mode 100644 index 0000000000..100c2f7ca4 --- /dev/null +++ b/examples/reaxff/log.21Jul21.reaxff.tatb.g++.4 @@ -0,0 +1,151 @@ +LAMMPS (2 Jul 2021) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# ReaxFF potential for TATB system + +units real + +atom_style charge +read_data data.tatb +Reading data file ... + triclinic box = (0.0000000 0.0000000 0.0000000) to (13.624000 17.114915 15.182639) with tilt (-5.7531563 -6.3254660 7.4257288) + 1 by 2 by 2 MPI processor grid + reading atoms ... + 384 atoms + read_data CPU = 0.002 seconds + +pair_style reaxff control.reax_c.tatb +WARNING: Ignoring inactive control parameter: simulation_name (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: energy_update_freq (src/REAXFF/reaxff_control.cpp:97) +WARNING: Support for writing native trajectories has been removed after LAMMPS version 8 April 2021 (src/REAXFF/reaxff_control.cpp:113) +WARNING: Ignoring inactive control parameter: traj_title (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_forces (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: atom_velocities (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: bond_info (src/REAXFF/reaxff_control.cpp:97) +WARNING: Ignoring inactive control parameter: angle_info (src/REAXFF/reaxff_control.cpp:97) +pair_coeff * * ffield.reax C H O N +Reading potential file ffield.reax with DATE: 2010-02-19 + +compute reax all pair reaxff + +variable eb equal c_reax[1] +variable ea equal c_reax[2] +variable elp equal c_reax[3] +variable emol equal c_reax[4] +variable ev equal c_reax[5] +variable epen equal c_reax[6] +variable ecoa equal c_reax[7] +variable ehb equal c_reax[8] +variable et equal c_reax[9] +variable eco equal c_reax[10] +variable ew equal c_reax[11] +variable ep equal c_reax[12] +variable efi equal c_reax[13] +variable eqeq equal c_reax[14] + +neighbor 2.5 bin +neigh_modify delay 0 every 5 check no + +fix 1 all nve +fix 2 all qeq/reaxff 1 0.0 10.0 1.0e-6 reaxff +fix 4 all reaxff/bonds 5 bonds.reaxff +variable nqeq equal f_2 + +thermo 5 +thermo_style custom step temp epair etotal press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + +timestep 0.0625 + +#dump 1 all custom 100 dump.reaxff.tatb id type q x y z + +#dump 2 all image 5 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 5 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 3 all reaxff/species 1 5 5 species.tatb + +run 25 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- pair reaxff command: + +@Article{Aktulga12, + author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama}, + title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques}, + journal = {Parallel Computing}, + year = 2012, + volume = 38, + pages = {245--259} +} + +- fix qeq/reaxff command: + +@Article{Aktulga12, + author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama}, + title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques}, + journal = {Parallel Computing}, + year = 2012, + volume = 38, + pages = {245--259} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Neighbor list info ... + update every 5 steps, delay 0 steps, check no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 12.5 + ghost atom cutoff = 12.5 + binsize = 6.25, bins = 5 4 3 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair reaxff, perpetual + attributes: half, newton off, ghost + pair build: half/bin/newtoff/ghost + stencil: full/ghost/bin/3d + bin: standard + (2) fix qeq/reaxff, perpetual, copy from (1) + attributes: half, newton off, ghost + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 99.27 | 99.27 | 99.27 Mbytes +Step Temp E_pair TotEng Press v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa v_ehb v_et v_eco v_ew v_ep v_efi v_eqeq v_nqeq + 0 0 -44760.998 -44760.998 7827.7866 -61120.591 486.4378 4.7236377 0 1574.1033 20.788929 -279.51642 -1556.4696 252.57147 -655.84699 18862.412 -8740.6397 0 6391.0277 31 + 5 0.61603941 -44761.698 -44760.994 8934.6279 -61118.769 486.81263 4.7234094 0 1573.9241 20.768834 -278.24084 -1557.6713 252.64377 -655.74435 18859.379 -8738.193 0 6388.6691 10 + 10 2.352555 -44763.227 -44760.541 12288.61 -61113.174 487.82738 4.7226863 0 1573.411 20.705939 -274.50358 -1560.7569 252.85309 -655.44063 18850.391 -8730.9686 0 6381.7064 9 + 15 4.9013339 -44766.36 -44760.764 17716.995 -61103.434 489.14721 4.7213644 0 1572.6349 20.593139 -268.56847 -1566.3829 252.95174 -654.96611 18835.777 -8719.2413 0 6370.4076 10.5 + 20 7.8294636 -44769.686 -44760.747 25205.611 -61089.006 490.21313 4.719302 0 1571.7022 20.420943 -260.85565 -1573.7378 253.3539 -654.31623 18816.07 -8703.4966 0 6355.2478 10 + 25 10.6979 -44772.904 -44760.691 34232.798 -61069.308 490.25886 4.7163736 0 1570.7397 20.181346 -251.91378 -1582.3261 253.82253 -653.53184 18791.975 -8684.3574 0 6336.8382 10.5 +Loop time of 2.53633 on 4 procs for 25 steps with 384 atoms + +Performance: 0.053 ns/day, 450.902 hours/ns, 9.857 timesteps/s +97.8% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 1.7343 | 1.7637 | 1.815 | 2.4 | 69.54 +Neigh | 0.44441 | 0.44869 | 0.45403 | 0.6 | 17.69 +Comm | 0.025287 | 0.074702 | 0.10592 | 11.9 | 2.95 +Output | 0.0016916 | 0.0080527 | 0.010178 | 4.1 | 0.32 +Modify | 0.23126 | 0.24065 | 0.25706 | 2.1 | 9.49 +Other | | 0.000566 | | | 0.02 + +Nlocal: 96.0000 ave 96 max 96 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Nghost: 5118.00 ave 5118 max 5118 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Neighs: 79754.0 ave 79754 max 79754 min +Histogram: 4 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 319016 +Ave neighs/atom = 830.77083 +Neighbor list builds = 5 +Dangerous builds not checked +Total wall time: 0:00:02 diff --git a/python/lammps/core.py b/python/lammps/core.py index 2f101f4eab..d981243503 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -295,9 +295,16 @@ class lammps(object): self.lib.lammps_extract_variable.argtypes = [c_void_p, c_char_p, c_char_p] - # TODO: NOT IMPLEMENTED IN PYTHON WRAPPER - self.lib.lammps_fix_external_set_energy_global = [c_void_p, c_char_p, c_double] - self.lib.lammps_fix_external_set_virial_global = [c_void_p, c_char_p, POINTER(c_double)] + self.lib.lammps_fix_external_get_force.argtypes = [c_void_p, c_char_p] + self.lib.lammps_fix_external_get_force.restype = POINTER(POINTER(c_double)) + + self.lib.lammps_fix_external_set_energy_global.argtypes = [c_void_p, c_char_p, c_double] + self.lib.lammps_fix_external_set_virial_global.argtypes = [c_void_p, c_char_p, POINTER(c_double)] + self.lib.lammps_fix_external_set_energy_peratom.argtypes = [c_void_p, c_char_p, POINTER(c_double)] + self.lib.lammps_fix_external_set_virial_peratom.argtypes = [c_void_p, c_char_p, POINTER(POINTER(c_double))] + + self.lib.lammps_fix_external_set_vector_length.argtypes = [c_void_p, c_char_p, c_int] + self.lib.lammps_fix_external_set_vector.argtypes = [c_void_p, c_char_p, c_int, c_double] # detect if Python is using a version of mpi4py that can pass communicators # only needed if LAMMPS has been compiled with MPI support. @@ -1725,7 +1732,33 @@ class lammps(object): # ------------------------------------------------------------------------- - def set_fix_external_callback(self, fix_name, callback, caller=None): + def set_fix_external_callback(self, fix_id, callback, caller=None): + """Set the callback function for a fix external instance with a given fix ID. + + Optionally also set a reference to the calling object. + + This is a wrapper around the :cpp:func:`lammps_set_fix_external_callback` function + of the C-library interface. However this is set up to call a Python function with + the following arguments. + + .. code-block: python + + def func(object, ntimestep, nlocal, tag, x, f): + + - object is the value of the "caller" argument + - ntimestep is the current timestep + - nlocal is the number of local atoms on the current MPI process + - tag is a 1d NumPy array of integers representing the atom IDs of the local atoms + - x is a 2d NumPy array of doubles of the coordinates of the local atoms + - f is a 2d NumPy array of doubles of the forces on the local atoms that will be added + + :param fix_id: Fix-ID of a fix external instance + :type: string + :param callback: Python function that will be called from fix external + :type: function + :param caller: reference to some object passed to the callback function + :type: object, optional + """ import numpy as np def callback_wrapper(caller, ntimestep, nlocal, tag_ptr, x_ptr, fext_ptr): @@ -1737,10 +1770,148 @@ class lammps(object): cFunc = self.FIX_EXTERNAL_CALLBACK_FUNC(callback_wrapper) cCaller = caller - self.callback[fix_name] = { 'function': cFunc, 'caller': caller } + self.callback[fix_id] = { 'function': cFunc, 'caller': caller } with ExceptionCheck(self): - self.lib.lammps_set_fix_external_callback(self.lmp, fix_name.encode(), cFunc, cCaller) + self.lib.lammps_set_fix_external_callback(self.lmp, fix_id.encode(), cFunc, cCaller) + # ------------------------------------------------------------------------- + + def fix_external_get_force(self, fix_id): + """Get access to the array with per-atom forces of a fix external instance with a given fix ID. + + This is a wrapper around the :cpp:func:`lammps_fix_external_get_force` function + of the C-library interface. + + :param fix_id: Fix-ID of a fix external instance + :type: string + :return: requested data + :rtype: ctypes.POINTER(ctypes.POINTER(ctypes.double)) + """ + + with ExceptionCheck(self): + return self.lib.lammps_fix_external_get_force(self.lmp, fix_id.encode()) + return None + + # ------------------------------------------------------------------------- + + def fix_external_set_energy_global(self, fix_id, eng): + """Set the global energy contribution for a fix external instance with the given ID. + + This is a wrapper around the :cpp:func:`lammps_fix_external_set_energy_global` function + of the C-library interface. + + :param fix_id: Fix-ID of a fix external instance + :type: string + :param eng: potential energy value to be added by fix external + :type: float + """ + + with ExceptionCheck(self): + return self.lib.lammps_fix_external_set_energy_global(self.lmp, fix_id.encode(), eng) + + # ------------------------------------------------------------------------- + + def fix_external_set_virial_global(self, fix_id, virial): + """Set the global virial contribution for a fix external instance with the given ID. + + This is a wrapper around the :cpp:func:`lammps_fix_external_set_virial_global` function + of the C-library interface. + + :param fix_id: Fix-ID of a fix external instance + :type: string + :param eng: list of 6 floating point numbers with the virial to be added by fix external + :type: float + """ + + cvirial = (6*c_double)(*virial) + with ExceptionCheck(self): + return self.lib.lammps_fix_external_set_virial_global(self.lmp, fix_id.encode(), cvirial) + + # ------------------------------------------------------------------------- + + def fix_external_set_energy_peratom(self, fix_id, eatom): + """Set the per-atom energy contribution for a fix external instance with the given ID. + + This is a wrapper around the :cpp:func:`lammps_fix_external_set_energy_peratom` function + of the C-library interface. + + :param fix_id: Fix-ID of a fix external instance + :type: string + :param eatom: list of potential energy values for local atoms to be added by fix external + :type: float + """ + + nlocal = self.extract_setting('nlocal') + if len(eatom) < nlocal: + raise Exception('per-atom energy list length must be at least nlocal') + ceatom = (nlocal*c_double)(*eatom) + with ExceptionCheck(self): + return self.lib.lammps_fix_external_set_energy_peratom(self.lmp, fix_id.encode(), ceatom) + + # ------------------------------------------------------------------------- + + def fix_external_set_virial_peratom(self, fix_id, vatom): + """Set the per-atom virial contribution for a fix external instance with the given ID. + + This is a wrapper around the :cpp:func:`lammps_fix_external_set_virial_peratom` function + of the C-library interface. + + :param fix_id: Fix-ID of a fix external instance + :type: string + :param vatom: list of natoms lists with 6 floating point numbers to be added by fix external + :type: float + """ + + # copy virial data to C compatible buffer + nlocal = self.extract_setting('nlocal') + if len(vatom) < nlocal: + raise Exception('per-atom virial first dimension must be at least nlocal') + if len(vatom[0]) != 6: + raise Exception('per-atom virial second dimension must be 6') + vbuf = (c_double * 6) + vptr = POINTER(c_double) + c_virial = (vptr * nlocal)() + for i in range(nlocal): + c_virial[i] = vbuf() + for j in range(6): + c_virial[i][j] = vatom[i][j] + + with ExceptionCheck(self): + return self.lib.lammps_fix_external_set_virial_peratom(self.lmp, fix_id.encode(), c_virial) + + # ------------------------------------------------------------------------- + def fix_external_set_vector_length(self, fix_id, length): + """Set the vector length for a global vector stored with fix external for analysis + + This is a wrapper around the :cpp:func:`lammps_fix_external_set_vector_length` function + of the C-library interface. + + :param fix_id: Fix-ID of a fix external instance + :type: string + :param length: length of the global vector + :type: int + """ + + with ExceptionCheck(self): + return self.lib.lammps_fix_external_set_vector_length(self.lmp, fix_id.encode(), length) + + # ------------------------------------------------------------------------- + def fix_external_set_vector(self, fix_id, idx, val): + """Store a global vector value for a fix external instance with the given ID. + + This is a wrapper around the :cpp:func:`lammps_fix_external_set_vector` function + of the C-library interface. + + :param fix_id: Fix-ID of a fix external instance + :type: string + :param idx: 1-based index of the value in the global vector + :type: int + :param val: value to be stored in the global vector + :type: float + """ + + with ExceptionCheck(self): + return self.lib.lammps_fix_external_set_vector(self.lmp, fix_id.encode(), idx, val) # ------------------------------------------------------------------------- diff --git a/python/lammps/numpy_wrapper.py b/python/lammps/numpy_wrapper.py index 20fdf4cc68..6f4503a9c8 100644 --- a/python/lammps/numpy_wrapper.py +++ b/python/lammps/numpy_wrapper.py @@ -17,7 +17,7 @@ ################################################################################ import warnings -from ctypes import POINTER, c_double, c_int, c_int32, c_int64, cast +from ctypes import POINTER, c_void_p, c_char_p, c_double, c_int, c_int32, c_int64, cast from .constants import * # lgtm [py/polluting-import] @@ -246,7 +246,85 @@ class numpy_wrapper: return np.ctypeslib.as_array(value) return value - # ------------------------------------------------------------------------- + # ------------------------------------------------------------------------- + + def fix_external_get_force(self, fix_id): + """Get access to the array with per-atom forces of a fix external instance with a given fix ID. + + This function is a wrapper around the + :py:meth:`lammps.fix_external_get_force() ` + method. It behaves the same as the original method, but returns a NumPy array instead + of a ``ctypes`` pointer. + + :param fix_id: Fix-ID of a fix external instance + :type: string + :return: requested data + :rtype: numpy.array + """ + import numpy as np + nlocal = self.lmp.extract_setting('nlocal') + value = self.lmp.fix_external_get_force(fix_id) + return self.darray(value,nlocal,3) + + # ------------------------------------------------------------------------- + + def fix_external_set_energy_peratom(self, fix_id, eatom): + """Set the per-atom energy contribution for a fix external instance with the given ID. + + This function is an alternative to + :py:meth:`lammps.fix_external_set_energy_peratom() ` + method. It behaves the same as the original method, but accepts a NumPy array + instead of a list as argument. + + :param fix_id: Fix-ID of a fix external instance + :type: string + :param eatom: per-atom potential energy + :type: numpy.array + """ + import numpy as np + nlocal = self.lmp.extract_setting('nlocal') + if len(eatom) < nlocal: + raise Exception('per-atom energy dimension must be at least nlocal') + + c_double_p = POINTER(c_double) + value = eatom.astype(np.double) + return self.lmp.lib.lammps_fix_external_set_energy_peratom(self.lmp.lmp, fix_id.encode(), + value.ctypes.data_as(c_double_p)) + + # ------------------------------------------------------------------------- + + def fix_external_set_virial_peratom(self, fix_id, vatom): + """Set the per-atom virial contribution for a fix external instance with the given ID. + + This function is an alternative to + :py:meth:`lammps.fix_external_set_virial_peratom() ` + method. It behaves the same as the original method, but accepts a NumPy array + instead of a list as argument. + + :param fix_id: Fix-ID of a fix external instance + :type: string + :param eatom: per-atom potential energy + :type: numpy.array + """ + import numpy as np + nlocal = self.lmp.extract_setting('nlocal') + if len(vatom) < nlocal: + raise Exception('per-atom virial first dimension must be at least nlocal') + if len(vatom[0]) != 6: + raise Exception('per-atom virial second dimension must be 6') + + c_double_pp = np.ctypeslib.ndpointer(dtype=np.uintp, ndim=1, flags='C') + + # recast numpy array to be compatible with library interface + value = (vatom.__array_interface__['data'][0] + + np.arange(vatom.shape[0])*vatom.strides[0]).astype(np.uintp) + + # change prototype to our custom type + self.lmp.lib.lammps_fix_external_set_virial_peratom.argtypes = [ c_void_p, c_char_p, c_double_pp ] + + self.lmp.lib.lammps_fix_external_set_virial_peratom(self.lmp.lmp, fix_id.encode(), value) + + # ------------------------------------------------------------------------- def get_neighlist(self, idx): """Returns an instance of :class:`NumPyNeighList` which wraps access to the neighbor list with the given index diff --git a/src/.gitignore b/src/.gitignore index 7a44bd726c..42e1548c43 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1224,49 +1224,27 @@ /reader_molfile.cpp /reader_molfile.h /reaxc_allocate.cpp -/reaxc_allocate.h /reaxc_basic_comm.cpp -/reaxc_basic_comm.h /reaxc_bond_orders.cpp -/reaxc_bond_orders.h /reaxc_bonds.cpp -/reaxc_bonds.h /reaxc_control.cpp -/reaxc_control.h -/reaxc_defs.h /reaxc_ffield.cpp -/reaxc_ffield.h /reaxc_forces.cpp -/reaxc_forces.h /reaxc_hydrogen_bonds.cpp -/reaxc_hydrogen_bonds.h /reaxc_init_md.cpp -/reaxc_init_md.h -/reaxc_io_tools.cpp -/reaxc_io_tools.h /reaxc_list.cpp -/reaxc_list.h /reaxc_lookup.cpp -/reaxc_lookup.h /reaxc_multi_body.cpp -/reaxc_multi_body.h /reaxc_nonbonded.cpp -/reaxc_nonbonded.h /reaxc_reset_tools.cpp -/reaxc_reset_tools.h -/reaxc_system_props.cpp -/reaxc_system_props.h /reaxc_tool_box.cpp -/reaxc_tool_box.h /reaxc_torsion_angles.cpp -/reaxc_torsion_angles.h -/reaxc_traj.cpp -/reaxc_traj.h -/reaxc_types.h /reaxc_valence_angles.cpp -/reaxc_valence_angles.h -/reaxc_vector.cpp -/reaxc_vector.h +/reaxff_api.h +/reaxff_defs.h +/reaxff_inline.h +/reaxff_omp.h +/reaxff_types.h /remap.cpp /remap.h /remap_wrap.cpp diff --git a/src/GRANULAR/fix_wall_gran.cpp b/src/GRANULAR/fix_wall_gran.cpp index 52311f64a7..a604782993 100644 --- a/src/GRANULAR/fix_wall_gran.cpp +++ b/src/GRANULAR/fix_wall_gran.cpp @@ -1193,7 +1193,7 @@ void FixWallGran::granular(double rsq, double dx, double dy, double dz, knfac = E; //Hooke a = sqrt(dR); Fne = knfac*delta; - if (normal_model != HOOKE) { + if (normal_model != NORMAL_HOOKE) { Fne *= a; knfac *= a; } diff --git a/src/INTERLAYER/pair_drip.cpp b/src/INTERLAYER/pair_drip.cpp index 97f5ca439e..a59d74bab9 100644 --- a/src/INTERLAYER/pair_drip.cpp +++ b/src/INTERLAYER/pair_drip.cpp @@ -366,10 +366,7 @@ void PairDRIP::compute(int eflag, int vflag) f[j][0] += fj[0]; f[j][1] += fj[1]; f[j][2] += fj[2]; - - // multiply 2 since v_tally has a 0.5 coeff - fj[0] *= 2; fj[1] *= 2; fj[2] *= 2; - if (vflag_atom) v_tally(j, fj, x[j]); + if (vflag_either) v_tally2_newton(j, fj, x[j]); } } //loop over jj @@ -377,10 +374,7 @@ void PairDRIP::compute(int eflag, int vflag) f[i][0] += fi[0]; f[i][1] += fi[1]; f[i][2] += fi[2]; - - // multiply 2 since v_tally has a 0.5 coeff - fi[0] *= 2; fi[1] *= 2; fi[2] *= 2; - if (vflag_atom) v_tally(i, fi, x[i]); + if (vflag_either) v_tally2_newton(i, fi, x[i]); } // loop over ii @@ -529,22 +523,13 @@ double PairDRIP::calc_repulsive(int const i, int const j, Param& p, f[nbj3][k] += fnbj3[k]; } - if (vflag_atom) { - // multiply since v_tally has a 0.5 coeff - for (int k = 0; k < DIM; k++) { - fnbi1[k] *= 2; - fnbi2[k] *= 2; - fnbi3[k] *= 2; - fnbj1[k] *= 2; - fnbj2[k] *= 2; - fnbj3[k] *= 2; - } - v_tally(nbi1, fnbi1, x[nbi1]); - v_tally(nbi2, fnbi2, x[nbi2]); - v_tally(nbi3, fnbi3, x[nbi3]); - v_tally(nbj1, fnbj1, x[nbj1]); - v_tally(nbj2, fnbj2, x[nbj2]); - v_tally(nbj3, fnbj3, x[nbj3]); + if (vflag_either) { + v_tally2_newton(nbi1, fnbi1, x[nbi1]); + v_tally2_newton(nbi2, fnbi2, x[nbi2]); + v_tally2_newton(nbi3, fnbi3, x[nbi3]); + v_tally2_newton(nbj1, fnbj1, x[nbj1]); + v_tally2_newton(nbj2, fnbj2, x[nbj2]); + v_tally2_newton(nbj3, fnbj3, x[nbj3]); } return phi; diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.cpp b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp similarity index 81% rename from src/KOKKOS/fix_qeq_reax_kokkos.cpp rename to src/KOKKOS/fix_qeq_reaxff_kokkos.cpp index cace20c098..77bd013ad4 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp @@ -17,7 +17,7 @@ Kamesh Arumugam (NVIDIA) ------------------------------------------------------------------------- */ -#include "fix_qeq_reax_kokkos.h" +#include "fix_qeq_reaxff_kokkos.h" #include "atom.h" #include "atom_kokkos.h" @@ -43,9 +43,9 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ template -FixQEqReaxKokkos:: -FixQEqReaxKokkos(LAMMPS *lmp, int narg, char **arg) : - FixQEqReax(lmp, narg, arg) +FixQEqReaxFFKokkos:: +FixQEqReaxFFKokkos(LAMMPS *lmp, int narg, char **arg) : + FixQEqReaxFF(lmp, narg, arg) { kokkosable = 1; forward_comm_device = 1; @@ -69,7 +69,7 @@ FixQEqReaxKokkos(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ template -FixQEqReaxKokkos::~FixQEqReaxKokkos() +FixQEqReaxFFKokkos::~FixQEqReaxFFKokkos() { if (copymode) return; @@ -80,11 +80,11 @@ FixQEqReaxKokkos::~FixQEqReaxKokkos() /* ---------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::init() +void FixQEqReaxFFKokkos::init() { atomKK->sync(execution_space,Q_MASK); - FixQEqReax::init(); + FixQEqReaxFF::init(); neighflag = lmp->kokkos->neighflag_qeq; int irequest = neighbor->nrequest - 1; @@ -110,7 +110,7 @@ void FixQEqReaxKokkos::init() int ntypes = atom->ntypes; k_params = Kokkos::DualView - ("FixQEqReax::params",ntypes+1); + ("FixQEqReaxFF::params",ntypes+1); params = k_params.template view(); for (int n = 1; n <= ntypes; n++) { @@ -131,7 +131,7 @@ void FixQEqReaxKokkos::init() /* ---------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::init_shielding_k() +void FixQEqReaxFFKokkos::init_shielding_k() { int i,j; int ntypes = atom->ntypes; @@ -141,7 +141,7 @@ void FixQEqReaxKokkos::init_shielding_k() for (i = 1; i <= ntypes; ++i) for (j = 1; j <= ntypes; ++j) - k_shield.h_view(i,j) = pow( gamma[i] * gamma[j], -1.5 ); + k_shield.h_view(i,j) = pow(gamma[i] * gamma[j], -1.5); k_shield.template modify(); k_shield.template sync(); @@ -159,7 +159,7 @@ void FixQEqReaxKokkos::init_shielding_k() /* ---------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::init_hist() +void FixQEqReaxFFKokkos::init_hist() { k_s_hist.clear_sync_state(); k_t_hist.clear_sync_state(); @@ -174,7 +174,7 @@ void FixQEqReaxKokkos::init_hist() /* ---------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::setup_pre_force(int vflag) +void FixQEqReaxFFKokkos::setup_pre_force(int vflag) { //neighbor->build_one(list); @@ -184,7 +184,7 @@ void FixQEqReaxKokkos::setup_pre_force(int vflag) /* ---------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::pre_force(int /*vflag*/) +void FixQEqReaxFFKokkos::pre_force(int /*vflag*/) { if (update->ntimestep % nevery) return; @@ -228,10 +228,10 @@ void FixQEqReaxKokkos::pre_force(int /*vflag*/) if (execution_space == Host) { // CPU if (neighflag == FULL) { - FixQEqReaxKokkosComputeHFunctor computeH_functor(this); + FixQEqReaxFFKokkosComputeHFunctor computeH_functor(this); Kokkos::parallel_scan(inum,computeH_functor); } else { // HALF and HALFTHREAD are the same - FixQEqReaxKokkosComputeHFunctor computeH_functor(this); + FixQEqReaxFFKokkosComputeHFunctor computeH_functor(this); Kokkos::parallel_scan(inum,computeH_functor); } } else { // GPU, use teams @@ -244,11 +244,11 @@ void FixQEqReaxKokkos::pre_force(int /*vflag*/) Kokkos::TeamPolicy policy(num_teams, atoms_per_team, vector_length); if (neighflag == FULL) { - FixQEqReaxKokkosComputeHFunctor computeH_functor( + FixQEqReaxFFKokkosComputeHFunctor computeH_functor( this, atoms_per_team, vector_length); Kokkos::parallel_for(policy, computeH_functor); } else { // HALF and HALFTHREAD are the same - FixQEqReaxKokkosComputeHFunctor computeH_functor( + FixQEqReaxFFKokkosComputeHFunctor computeH_functor( this, atoms_per_team, vector_length); Kokkos::parallel_for(policy, computeH_functor); } @@ -258,16 +258,16 @@ void FixQEqReaxKokkos::pre_force(int /*vflag*/) k_s_hist.template sync(); k_t_hist.template sync(); - FixQEqReaxKokkosMatVecFunctor matvec_functor(this); + FixQEqReaxFFKokkosMatVecFunctor matvec_functor(this); Kokkos::parallel_for(inum,matvec_functor); - // comm->forward_comm_fix(this); //Dist_vector( s ); + // comm->forward_comm_fix(this); //Dist_vector(s); pack_flag = 2; k_s.template modify(); comm->forward_comm_fix(this); k_s.template sync(); - // comm->forward_comm_fix(this); //Dist_vector( t ); + // comm->forward_comm_fix(this); //Dist_vector(t); pack_flag = 3; k_t.template modify(); comm->forward_comm_fix(this); @@ -282,11 +282,11 @@ void FixQEqReaxKokkos::pre_force(int /*vflag*/) // 1st cg solve over b_s, s - cg_solve1(); + matvecs = cg_solve1(); // 2nd cg solve over b_t, t - cg_solve2(); + matvecs += cg_solve2(); // calculate_Q(); @@ -313,7 +313,7 @@ void FixQEqReaxKokkos::pre_force(int /*vflag*/) template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::num_neigh_item(int ii, int &maxneigh) const +void FixQEqReaxFFKokkos::num_neigh_item(int ii, int &maxneigh) const { const int i = d_ilist[ii]; maxneigh += d_numneigh[i]; @@ -322,7 +322,7 @@ void FixQEqReaxKokkos::num_neigh_item(int ii, int &maxneigh) const /* ---------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::allocate_matrix() +void FixQEqReaxFFKokkos::allocate_matrix() { const int inum = list->inum; @@ -331,7 +331,7 @@ void FixQEqReaxKokkos::allocate_matrix() // determine the total space for the H matrix m_cap = 0; - FixQEqReaxKokkosNumNeighFunctor neigh_functor(this); + FixQEqReaxFFKokkosNumNeighFunctor neigh_functor(this); Kokkos::parallel_reduce(inum,neigh_functor,m_cap); d_firstnbr = typename AT::t_int_1d("qeq/kk:firstnbr",nmax); @@ -343,7 +343,7 @@ void FixQEqReaxKokkos::allocate_matrix() /* ---------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::allocate_array() +void FixQEqReaxFFKokkos::allocate_array() { if (atom->nmax > nmax) { nmax = atom->nmax; @@ -377,7 +377,7 @@ void FixQEqReaxKokkos::allocate_array() // init_storage - FixQEqReaxKokkosZeroFunctor zero_functor(this); + FixQEqReaxFFKokkosZeroFunctor zero_functor(this); Kokkos::parallel_for(ignum,zero_functor); } @@ -385,7 +385,7 @@ void FixQEqReaxKokkos::allocate_array() template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::zero_item(int ii) const +void FixQEqReaxFFKokkos::zero_item(int ii) const { const int i = d_ilist[ii]; const int itype = type(i); @@ -409,7 +409,7 @@ void FixQEqReaxKokkos::zero_item(int ii) const template template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::compute_h_item(int ii, int &m_fill, const bool &final) const +void FixQEqReaxFFKokkos::compute_h_item(int ii, int &m_fill, const bool &final) const { const int i = d_ilist[ii]; int j,jj,jtype; @@ -477,7 +477,7 @@ void FixQEqReaxKokkos::compute_h_item(int ii, int &m_fill, const boo template template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::compute_h_team( +void FixQEqReaxFFKokkos::compute_h_team( const typename Kokkos::TeamPolicy::member_type &team, int atoms_per_team, int vector_length) const { @@ -682,7 +682,7 @@ void FixQEqReaxKokkos::compute_h_team( template KOKKOS_INLINE_FUNCTION -double FixQEqReaxKokkos::calculate_H_k(const F_FLOAT &r, const F_FLOAT &shld) const +double FixQEqReaxFFKokkos::calculate_H_k(const F_FLOAT &r, const F_FLOAT &shld) const { F_FLOAT taper, denom; @@ -704,7 +704,7 @@ double FixQEqReaxKokkos::calculate_H_k(const F_FLOAT &r, const F_FLO template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::matvec_item(int ii) const +void FixQEqReaxFFKokkos::matvec_item(int ii) const { const int i = d_ilist[ii]; const int itype = type(i); @@ -722,7 +722,7 @@ void FixQEqReaxKokkos::matvec_item(int ii) const /* ---------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::cg_solve1() +int FixQEqReaxFFKokkos::cg_solve1() // b = b_s, x = s; { const int inum = list->inum; @@ -732,16 +732,16 @@ void FixQEqReaxKokkos::cg_solve1() if (execution_space == Host) teamsize = 1; else teamsize = 128; - // sparse_matvec( &H, x, q ); - FixQEqReaxKokkosSparse12Functor sparse12_functor(this); + // sparse_matvec(&H, x, q); + FixQEqReaxFFKokkosSparse12Functor sparse12_functor(this); Kokkos::parallel_for(inum,sparse12_functor); if (neighflag != FULL) { Kokkos::parallel_for(Kokkos::RangePolicy(inum,ignum),*this); if (neighflag == HALF) { - FixQEqReaxKokkosSparse13Functor sparse13_functor(this); + FixQEqReaxFFKokkosSparse13Functor sparse13_functor(this); Kokkos::parallel_for(inum,sparse13_functor); } else if (neighflag == HALFTHREAD) { - FixQEqReaxKokkosSparse13Functor sparse13_functor(this); + FixQEqReaxFFKokkosSparse13Functor sparse13_functor(this); Kokkos::parallel_for(inum,sparse13_functor); } if (need_dup) @@ -752,49 +752,49 @@ void FixQEqReaxKokkos::cg_solve1() if (neighflag != FULL) { k_o.template modify(); - comm->reverse_comm_fix(this); //Coll_vector( q ); + comm->reverse_comm_fix(this); //Coll_vector(q); k_o.template sync(); } - // vector_sum( r , 1., b, -1., q, nn ); + // vector_sum(r , 1., b, -1., q, nn); // preconditioning: d[j] = r[j] * Hdia_inv[j]; - // b_norm = parallel_norm( b, nn ); + // b_norm = parallel_norm(b, nn); F_FLOAT my_norm = 0.0; - FixQEqReaxKokkosNorm1Functor norm1_functor(this); + FixQEqReaxFFKokkosNorm1Functor norm1_functor(this); Kokkos::parallel_reduce(inum,norm1_functor,my_norm); F_FLOAT norm_sqr = 0.0; - MPI_Allreduce( &my_norm, &norm_sqr, 1, MPI_DOUBLE, MPI_SUM, world ); + MPI_Allreduce(&my_norm, &norm_sqr, 1, MPI_DOUBLE, MPI_SUM, world); b_norm = sqrt(norm_sqr); - // sig_new = parallel_dot( r, d, nn); + // sig_new = parallel_dot(r, d, nn); F_FLOAT my_dot = 0.0; - FixQEqReaxKokkosDot1Functor dot1_functor(this); + FixQEqReaxFFKokkosDot1Functor dot1_functor(this); Kokkos::parallel_reduce(inum,dot1_functor,my_dot); F_FLOAT dot_sqr = 0.0; - MPI_Allreduce( &my_dot, &dot_sqr, 1, MPI_DOUBLE, MPI_SUM, world ); + MPI_Allreduce(&my_dot, &dot_sqr, 1, MPI_DOUBLE, MPI_SUM, world); F_FLOAT sig_new = dot_sqr; int loop; for (loop = 1; (loop < imax) && (sqrt(sig_new)/b_norm > tolerance); loop++) { - // comm->forward_comm_fix(this); //Dist_vector( d ); + // comm->forward_comm_fix(this); //Dist_vector(d); pack_flag = 1; k_d.template modify(); comm->forward_comm_fix(this); k_d.template sync(); - // sparse_matvec( &H, d, q ); - FixQEqReaxKokkosSparse22Functor sparse22_functor(this); + // sparse_matvec(&H, d, q); + FixQEqReaxFFKokkosSparse22Functor sparse22_functor(this); Kokkos::parallel_for(inum,sparse22_functor); if (neighflag != FULL) { Kokkos::parallel_for(Kokkos::RangePolicy(inum,ignum),*this); if (need_dup) dup_o.reset_except(d_o); if (neighflag == HALF) { - FixQEqReaxKokkosSparse23Functor sparse23_functor(this); + FixQEqReaxFFKokkosSparse23Functor sparse23_functor(this); Kokkos::parallel_for(inum,sparse23_functor); } else if (neighflag == HALFTHREAD) { - FixQEqReaxKokkosSparse23Functor sparse23_functor(this); + FixQEqReaxFFKokkosSparse23Functor sparse23_functor(this); Kokkos::parallel_for(inum,sparse23_functor); } if (need_dup) @@ -805,54 +805,52 @@ void FixQEqReaxKokkos::cg_solve1() if (neighflag != FULL) { k_o.template modify(); - comm->reverse_comm_fix(this); //Coll_vector( q ); + comm->reverse_comm_fix(this); //Coll_vector(q); k_o.template sync(); } - // tmp = parallel_dot( d, q, nn); + // tmp = parallel_dot(d, q, nn); my_dot = dot_sqr = 0.0; - FixQEqReaxKokkosDot2Functor dot2_functor(this); + FixQEqReaxFFKokkosDot2Functor dot2_functor(this); Kokkos::parallel_reduce(inum,dot2_functor,my_dot); - MPI_Allreduce( &my_dot, &dot_sqr, 1, MPI_DOUBLE, MPI_SUM, world ); + MPI_Allreduce(&my_dot, &dot_sqr, 1, MPI_DOUBLE, MPI_SUM, world); tmp = dot_sqr; alpha = sig_new / tmp; sig_old = sig_new; - // vector_add( s, alpha, d, nn ); - // vector_add( r, -alpha, q, nn ); + // vector_add(s, alpha, d, nn); + // vector_add(r, -alpha, q, nn); my_dot = dot_sqr = 0.0; - FixQEqReaxKokkosPrecon1Functor precon1_functor(this); + FixQEqReaxFFKokkosPrecon1Functor precon1_functor(this); Kokkos::parallel_for(inum,precon1_functor); // preconditioning: p[j] = r[j] * Hdia_inv[j]; - // sig_new = parallel_dot( r, p, nn); - FixQEqReaxKokkosPreconFunctor precon_functor(this); + // sig_new = parallel_dot(r, p, nn); + FixQEqReaxFFKokkosPreconFunctor precon_functor(this); Kokkos::parallel_reduce(inum,precon_functor,my_dot); - MPI_Allreduce( &my_dot, &dot_sqr, 1, MPI_DOUBLE, MPI_SUM, world ); + MPI_Allreduce(&my_dot, &dot_sqr, 1, MPI_DOUBLE, MPI_SUM, world); sig_new = dot_sqr; beta = sig_new / sig_old; - // vector_sum( d, 1., p, beta, d, nn ); - FixQEqReaxKokkosVecSum2Functor vecsum2_functor(this); + // vector_sum(d, 1., p, beta, d, nn); + FixQEqReaxFFKokkosVecSum2Functor vecsum2_functor(this); Kokkos::parallel_for(inum,vecsum2_functor); } - if (loop >= imax && comm->me == 0) { - char str[128]; - sprintf(str,"Fix qeq/reax cg_solve1 convergence failed after %d iterations " - "at " BIGINT_FORMAT " step: %f",loop,update->ntimestep,sqrt(sig_new)/b_norm); - error->warning(FLERR,str); - //error->all(FLERR,str); - } - + if ((loop >= imax) && maxwarn && (comm->me == 0)) + error->warning(FLERR,fmt::format("Fix qeq/reaxff/kk cg_solve1 convergence " + "failed after {} iterations at step {}: " + "{}", loop, update->ntimestep, + sqrt(sig_new)/b_norm)); + return loop; } /* ---------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::cg_solve2() +int FixQEqReaxFFKokkos::cg_solve2() // b = b_t, x = t; { const int inum = list->inum; @@ -862,18 +860,18 @@ void FixQEqReaxKokkos::cg_solve2() if (execution_space == Host) teamsize = 1; else teamsize = 128; - // sparse_matvec( &H, x, q ); - FixQEqReaxKokkosSparse32Functor sparse32_functor(this); + // sparse_matvec(&H, x, q); + FixQEqReaxFFKokkosSparse32Functor sparse32_functor(this); Kokkos::parallel_for(inum,sparse32_functor); if (neighflag != FULL) { Kokkos::parallel_for(Kokkos::RangePolicy(inum,ignum),*this); if (need_dup) dup_o.reset_except(d_o); if (neighflag == HALF) { - FixQEqReaxKokkosSparse33Functor sparse33_functor(this); + FixQEqReaxFFKokkosSparse33Functor sparse33_functor(this); Kokkos::parallel_for(inum,sparse33_functor); } else if (neighflag == HALFTHREAD) { - FixQEqReaxKokkosSparse33Functor sparse33_functor(this); + FixQEqReaxFFKokkosSparse33Functor sparse33_functor(this); Kokkos::parallel_for(inum,sparse33_functor); } if (need_dup) @@ -884,49 +882,49 @@ void FixQEqReaxKokkos::cg_solve2() if (neighflag != FULL) { k_o.template modify(); - comm->reverse_comm_fix(this); //Coll_vector( q ); + comm->reverse_comm_fix(this); //Coll_vector(q); k_o.template sync(); } - // vector_sum( r , 1., b, -1., q, nn ); + // vector_sum(r , 1., b, -1., q, nn); // preconditioning: d[j] = r[j] * Hdia_inv[j]; - // b_norm = parallel_norm( b, nn ); + // b_norm = parallel_norm(b, nn); F_FLOAT my_norm = 0.0; - FixQEqReaxKokkosNorm2Functor norm2_functor(this); + FixQEqReaxFFKokkosNorm2Functor norm2_functor(this); Kokkos::parallel_reduce(inum,norm2_functor,my_norm); F_FLOAT norm_sqr = 0.0; - MPI_Allreduce( &my_norm, &norm_sqr, 1, MPI_DOUBLE, MPI_SUM, world ); + MPI_Allreduce(&my_norm, &norm_sqr, 1, MPI_DOUBLE, MPI_SUM, world); b_norm = sqrt(norm_sqr); - // sig_new = parallel_dot( r, d, nn); + // sig_new = parallel_dot(r, d, nn); F_FLOAT my_dot = 0.0; - FixQEqReaxKokkosDot1Functor dot1_functor(this); + FixQEqReaxFFKokkosDot1Functor dot1_functor(this); Kokkos::parallel_reduce(inum,dot1_functor,my_dot); F_FLOAT dot_sqr = 0.0; - MPI_Allreduce( &my_dot, &dot_sqr, 1, MPI_DOUBLE, MPI_SUM, world ); + MPI_Allreduce(&my_dot, &dot_sqr, 1, MPI_DOUBLE, MPI_SUM, world); F_FLOAT sig_new = dot_sqr; int loop; for (loop = 1; (loop < imax) && (sqrt(sig_new)/b_norm > tolerance); loop++) { - // comm->forward_comm_fix(this); //Dist_vector( d ); + // comm->forward_comm_fix(this); //Dist_vector(d); pack_flag = 1; k_d.template modify(); comm->forward_comm_fix(this); k_d.template sync(); - // sparse_matvec( &H, d, q ); - FixQEqReaxKokkosSparse22Functor sparse22_functor(this); + // sparse_matvec(&H, d, q); + FixQEqReaxFFKokkosSparse22Functor sparse22_functor(this); Kokkos::parallel_for(inum,sparse22_functor); if (neighflag != FULL) { Kokkos::parallel_for(Kokkos::RangePolicy(inum,ignum),*this); if (need_dup) dup_o.reset_except(d_o); if (neighflag == HALF) { - FixQEqReaxKokkosSparse23Functor sparse23_functor(this); + FixQEqReaxFFKokkosSparse23Functor sparse23_functor(this); Kokkos::parallel_for(inum,sparse23_functor); } else if (neighflag == HALFTHREAD) { - FixQEqReaxKokkosSparse23Functor sparse23_functor(this); + FixQEqReaxFFKokkosSparse23Functor sparse23_functor(this); Kokkos::parallel_for(inum,sparse23_functor); } if (need_dup) @@ -937,82 +935,80 @@ void FixQEqReaxKokkos::cg_solve2() if (neighflag != FULL) { k_o.template modify(); - comm->reverse_comm_fix(this); //Coll_vector( q ); + comm->reverse_comm_fix(this); //Coll_vector(q); k_o.template sync(); } - // tmp = parallel_dot( d, q, nn); + // tmp = parallel_dot(d, q, nn); my_dot = dot_sqr = 0.0; - FixQEqReaxKokkosDot2Functor dot2_functor(this); + FixQEqReaxFFKokkosDot2Functor dot2_functor(this); Kokkos::parallel_reduce(inum,dot2_functor,my_dot); - MPI_Allreduce( &my_dot, &dot_sqr, 1, MPI_DOUBLE, MPI_SUM, world ); + MPI_Allreduce(&my_dot, &dot_sqr, 1, MPI_DOUBLE, MPI_SUM, world); tmp = dot_sqr; alpha = sig_new / tmp; sig_old = sig_new; - // vector_add( t, alpha, d, nn ); - // vector_add( r, -alpha, q, nn ); + // vector_add(t, alpha, d, nn); + // vector_add(r, -alpha, q, nn); my_dot = dot_sqr = 0.0; - FixQEqReaxKokkosPrecon2Functor precon2_functor(this); + FixQEqReaxFFKokkosPrecon2Functor precon2_functor(this); Kokkos::parallel_for(inum,precon2_functor); // preconditioning: p[j] = r[j] * Hdia_inv[j]; - // sig_new = parallel_dot( r, p, nn); - FixQEqReaxKokkosPreconFunctor precon_functor(this); + // sig_new = parallel_dot(r, p, nn); + FixQEqReaxFFKokkosPreconFunctor precon_functor(this); Kokkos::parallel_reduce(inum,precon_functor,my_dot); - MPI_Allreduce( &my_dot, &dot_sqr, 1, MPI_DOUBLE, MPI_SUM, world ); + MPI_Allreduce(&my_dot, &dot_sqr, 1, MPI_DOUBLE, MPI_SUM, world); sig_new = dot_sqr; beta = sig_new / sig_old; - // vector_sum( d, 1., p, beta, d, nn ); - FixQEqReaxKokkosVecSum2Functor vecsum2_functor(this); + // vector_sum(d, 1., p, beta, d, nn); + FixQEqReaxFFKokkosVecSum2Functor vecsum2_functor(this); Kokkos::parallel_for(inum,vecsum2_functor); } - if (loop >= imax && comm->me == 0) { - char str[128]; - sprintf(str,"Fix qeq/reax cg_solve2 convergence failed after %d iterations " - "at " BIGINT_FORMAT " step: %f",loop,update->ntimestep,sqrt(sig_new)/b_norm); - error->warning(FLERR,str); - //error->all(FLERR,str); - } - + if ((loop >= imax) && maxwarn && (comm->me == 0)) + error->warning(FLERR,fmt::format("Fix qeq/reaxff/kk cg_solve2 convergence " + "failed after {} iterations at step {}: " + "{}", loop, update->ntimestep, + sqrt(sig_new)/b_norm)); + return loop; } /* ---------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::calculate_q() +void FixQEqReaxFFKokkos::calculate_q() { F_FLOAT sum, sum_all; const int inum = list->inum; - // s_sum = parallel_vector_acc( s, nn ); + // s_sum = parallel_vector_acc(s, nn); sum = sum_all = 0.0; - FixQEqReaxKokkosVecAcc1Functor vecacc1_functor(this); + FixQEqReaxFFKokkosVecAcc1Functor vecacc1_functor(this); Kokkos::parallel_reduce(inum,vecacc1_functor,sum); - MPI_Allreduce(&sum, &sum_all, 1, MPI_DOUBLE, MPI_SUM, world ); + MPI_Allreduce(&sum, &sum_all, 1, MPI_DOUBLE, MPI_SUM, world); const F_FLOAT s_sum = sum_all; - // t_sum = parallel_vector_acc( t, nn); + // t_sum = parallel_vector_acc(t, nn); sum = sum_all = 0.0; - FixQEqReaxKokkosVecAcc2Functor vecacc2_functor(this); + FixQEqReaxFFKokkosVecAcc2Functor vecacc2_functor(this); Kokkos::parallel_reduce(inum,vecacc2_functor,sum); - MPI_Allreduce(&sum, &sum_all, 1, MPI_DOUBLE, MPI_SUM, world ); + MPI_Allreduce(&sum, &sum_all, 1, MPI_DOUBLE, MPI_SUM, world); const F_FLOAT t_sum = sum_all; // u = s_sum / t_sum; delta = s_sum/t_sum; // q[i] = s[i] - u * t[i]; - FixQEqReaxKokkosCalculateQFunctor calculateQ_functor(this); + FixQEqReaxFFKokkosCalculateQFunctor calculateQ_functor(this); Kokkos::parallel_for(inum,calculateQ_functor); atomKK->modified(execution_space,Q_MASK); pack_flag = 4; - //comm->forward_comm_fix( this ); //Dist_vector( atom->q ); + //comm->forward_comm_fix(this); //Dist_vector(atom->q); comm->forward_comm_fix(this); } @@ -1020,7 +1016,7 @@ void FixQEqReaxKokkos::calculate_q() template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::sparse12_item(int ii) const +void FixQEqReaxFFKokkos::sparse12_item(int ii) const { const int i = d_ilist[ii]; const int itype = type(i); @@ -1034,7 +1030,7 @@ void FixQEqReaxKokkos::sparse12_item(int ii) const template template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::sparse13_item(int ii) const +void FixQEqReaxFFKokkos::sparse13_item(int ii) const { // The q array is duplicated for OpenMP, atomic for CUDA, and neither for Serial auto v_o = ScatterViewHelper::value,decltype(dup_o),decltype(ndup_o)>::get(dup_o,ndup_o); @@ -1056,7 +1052,7 @@ void FixQEqReaxKokkos::sparse13_item(int ii) const template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::operator() (TagSparseMatvec1, const membertype1 &team) const +void FixQEqReaxFFKokkos::operator() (TagSparseMatvec1, const membertype1 &team) const { const int i = d_ilist[team.league_rank()]; if (mask[i] & groupbit) { @@ -1073,7 +1069,7 @@ void FixQEqReaxKokkos::operator() (TagSparseMatvec1, const membertyp template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::sparse22_item(int ii) const +void FixQEqReaxFFKokkos::sparse22_item(int ii) const { const int i = d_ilist[ii]; const int itype = type(i); @@ -1087,7 +1083,7 @@ void FixQEqReaxKokkos::sparse22_item(int ii) const template template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::sparse23_item(int ii) const +void FixQEqReaxFFKokkos::sparse23_item(int ii) const { // The q array is duplicated for OpenMP, atomic for CUDA, and neither for Serial auto v_o = ScatterViewHelper::value,decltype(dup_o),decltype(ndup_o)>::get(dup_o,ndup_o); @@ -1109,7 +1105,7 @@ void FixQEqReaxKokkos::sparse23_item(int ii) const template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::operator() (TagSparseMatvec2, const membertype2 &team) const +void FixQEqReaxFFKokkos::operator() (TagSparseMatvec2, const membertype2 &team) const { const int i = d_ilist[team.league_rank()]; if (mask[i] & groupbit) { @@ -1124,7 +1120,7 @@ void FixQEqReaxKokkos::operator() (TagSparseMatvec2, const membertyp template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::operator() (TagZeroQGhosts, const int &i) const +void FixQEqReaxFFKokkos::operator() (TagZeroQGhosts, const int &i) const { if (mask[i] & groupbit) d_o[i] = 0.0; @@ -1134,7 +1130,7 @@ void FixQEqReaxKokkos::operator() (TagZeroQGhosts, const int &i) con template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::sparse32_item(int ii) const +void FixQEqReaxFFKokkos::sparse32_item(int ii) const { const int i = d_ilist[ii]; const int itype = type(i); @@ -1147,7 +1143,7 @@ void FixQEqReaxKokkos::sparse32_item(int ii) const template template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::sparse33_item(int ii) const +void FixQEqReaxFFKokkos::sparse33_item(int ii) const { // The q array is duplicated for OpenMP, atomic for CUDA, and neither for Serial auto v_o = ScatterViewHelper::value,decltype(dup_o),decltype(ndup_o)>::get(dup_o,ndup_o); @@ -1169,7 +1165,7 @@ void FixQEqReaxKokkos::sparse33_item(int ii) const template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::operator() (TagSparseMatvec3, const membertype3 &team) const +void FixQEqReaxFFKokkos::operator() (TagSparseMatvec3, const membertype3 &team) const { const int i = d_ilist[team.league_rank()]; if (mask[i] & groupbit) { @@ -1186,7 +1182,7 @@ void FixQEqReaxKokkos::operator() (TagSparseMatvec3, const membertyp template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::vecsum2_item(int ii) const +void FixQEqReaxFFKokkos::vecsum2_item(int ii) const { const int i = d_ilist[ii]; if (mask[i] & groupbit) @@ -1197,7 +1193,7 @@ void FixQEqReaxKokkos::vecsum2_item(int ii) const template KOKKOS_INLINE_FUNCTION -double FixQEqReaxKokkos::norm1_item(int ii) const +double FixQEqReaxFFKokkos::norm1_item(int ii) const { F_FLOAT tmp = 0; const int i = d_ilist[ii]; @@ -1213,7 +1209,7 @@ double FixQEqReaxKokkos::norm1_item(int ii) const template KOKKOS_INLINE_FUNCTION -double FixQEqReaxKokkos::norm2_item(int ii) const +double FixQEqReaxFFKokkos::norm2_item(int ii) const { F_FLOAT tmp = 0; const int i = d_ilist[ii]; @@ -1229,7 +1225,7 @@ double FixQEqReaxKokkos::norm2_item(int ii) const template KOKKOS_INLINE_FUNCTION -double FixQEqReaxKokkos::dot1_item(int ii) const +double FixQEqReaxFFKokkos::dot1_item(int ii) const { F_FLOAT tmp = 0.0; const int i = d_ilist[ii]; @@ -1242,7 +1238,7 @@ double FixQEqReaxKokkos::dot1_item(int ii) const template KOKKOS_INLINE_FUNCTION -double FixQEqReaxKokkos::dot2_item(int ii) const +double FixQEqReaxFFKokkos::dot2_item(int ii) const { double tmp = 0.0; const int i = d_ilist[ii]; @@ -1256,7 +1252,7 @@ double FixQEqReaxKokkos::dot2_item(int ii) const template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::precon1_item(int ii) const +void FixQEqReaxFFKokkos::precon1_item(int ii) const { const int i = d_ilist[ii]; if (mask[i] & groupbit) { @@ -1269,7 +1265,7 @@ void FixQEqReaxKokkos::precon1_item(int ii) const template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::precon2_item(int ii) const +void FixQEqReaxFFKokkos::precon2_item(int ii) const { const int i = d_ilist[ii]; if (mask[i] & groupbit) { @@ -1282,7 +1278,7 @@ void FixQEqReaxKokkos::precon2_item(int ii) const template KOKKOS_INLINE_FUNCTION -double FixQEqReaxKokkos::precon_item(int ii) const +double FixQEqReaxFFKokkos::precon_item(int ii) const { F_FLOAT tmp = 0.0; const int i = d_ilist[ii]; @@ -1297,7 +1293,7 @@ double FixQEqReaxKokkos::precon_item(int ii) const template KOKKOS_INLINE_FUNCTION -double FixQEqReaxKokkos::vecacc1_item(int ii) const +double FixQEqReaxFFKokkos::vecacc1_item(int ii) const { F_FLOAT tmp = 0.0; const int i = d_ilist[ii]; @@ -1310,7 +1306,7 @@ double FixQEqReaxKokkos::vecacc1_item(int ii) const template KOKKOS_INLINE_FUNCTION -double FixQEqReaxKokkos::vecacc2_item(int ii) const +double FixQEqReaxFFKokkos::vecacc2_item(int ii) const { F_FLOAT tmp = 0.0; const int i = d_ilist[ii]; @@ -1324,7 +1320,7 @@ double FixQEqReaxKokkos::vecacc2_item(int ii) const template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::calculate_q_item(int ii) const +void FixQEqReaxFFKokkos::calculate_q_item(int ii) const { const int i = d_ilist[ii]; if (mask[i] & groupbit) { @@ -1343,20 +1339,20 @@ void FixQEqReaxKokkos::calculate_q_item(int ii) const /* ---------------------------------------------------------------------- */ template -int FixQEqReaxKokkos::pack_forward_comm_fix_kokkos(int n, DAT::tdual_int_2d k_sendlist, +int FixQEqReaxFFKokkos::pack_forward_comm_fix_kokkos(int n, DAT::tdual_int_2d k_sendlist, int iswap_in, DAT::tdual_xfloat_1d &k_buf, int /*pbc_flag*/, int * /*pbc*/) { d_sendlist = k_sendlist.view(); iswap = iswap_in; d_buf = k_buf.view(); - Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); + Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); return n; } template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::operator()(TagFixQEqReaxPackForwardComm, const int &i) const { +void FixQEqReaxFFKokkos::operator()(TagFixQEqReaxFFPackForwardComm, const int &i) const { int j = d_sendlist(iswap, i); if (pack_flag == 1) @@ -1372,11 +1368,11 @@ void FixQEqReaxKokkos::operator()(TagFixQEqReaxPackForwardComm, cons /* ---------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::unpack_forward_comm_fix_kokkos(int n, int first_in, DAT::tdual_xfloat_1d &buf) +void FixQEqReaxFFKokkos::unpack_forward_comm_fix_kokkos(int n, int first_in, DAT::tdual_xfloat_1d &buf) { first = first_in; d_buf = buf.view(); - Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); + Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); if (pack_flag == 4) atomKK->modified(execution_space,Q_MASK); // needed for auto_sync @@ -1384,14 +1380,14 @@ void FixQEqReaxKokkos::unpack_forward_comm_fix_kokkos(int n, int fir template KOKKOS_INLINE_FUNCTION -void FixQEqReaxKokkos::operator()(TagFixQEqReaxUnpackForwardComm, const int &i) const { +void FixQEqReaxFFKokkos::operator()(TagFixQEqReaxFFUnpackForwardComm, const int &i) const { if (pack_flag == 1) d_d[i + first] = d_buf[i]; - else if ( pack_flag == 2) + else if (pack_flag == 2) d_s[i + first] = d_buf[i]; - else if ( pack_flag == 3) + else if (pack_flag == 3) d_t[i + first] = d_buf[i]; - else if ( pack_flag == 4) + else if (pack_flag == 4) q[i + first] = d_buf[i]; } @@ -1399,7 +1395,7 @@ void FixQEqReaxKokkos::operator()(TagFixQEqReaxUnpackForwardComm, co /* ---------------------------------------------------------------------- */ template -int FixQEqReaxKokkos::pack_forward_comm(int n, int *list, double *buf, +int FixQEqReaxFFKokkos::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { int m; @@ -1424,7 +1420,7 @@ int FixQEqReaxKokkos::pack_forward_comm(int n, int *list, double *bu /* ---------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::unpack_forward_comm(int n, int first, double *buf) +void FixQEqReaxFFKokkos::unpack_forward_comm(int n, int first, double *buf) { int i, m; @@ -1450,7 +1446,7 @@ void FixQEqReaxKokkos::unpack_forward_comm(int n, int first, double /* ---------------------------------------------------------------------- */ template -int FixQEqReaxKokkos::pack_reverse_comm(int n, int first, double *buf) +int FixQEqReaxFFKokkos::pack_reverse_comm(int n, int first, double *buf) { k_o.sync_host(); @@ -1464,7 +1460,7 @@ int FixQEqReaxKokkos::pack_reverse_comm(int n, int first, double *bu /* ---------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::unpack_reverse_comm(int n, int *list, double *buf) +void FixQEqReaxFFKokkos::unpack_reverse_comm(int n, int *list, double *buf) { k_o.sync_host(); @@ -1478,7 +1474,7 @@ void FixQEqReaxKokkos::unpack_reverse_comm(int n, int *list, double /* ---------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::cleanup_copy() +void FixQEqReaxFFKokkos::cleanup_copy() { id = style = nullptr; } @@ -1488,7 +1484,7 @@ void FixQEqReaxKokkos::cleanup_copy() ------------------------------------------------------------------------- */ template -double FixQEqReaxKokkos::memory_usage() +double FixQEqReaxFFKokkos::memory_usage() { double bytes; @@ -1506,7 +1502,7 @@ double FixQEqReaxKokkos::memory_usage() ------------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::grow_arrays(int nmax) +void FixQEqReaxFFKokkos::grow_arrays(int nmax) { k_s_hist.template sync(); k_t_hist.template sync(); @@ -1529,7 +1525,7 @@ void FixQEqReaxKokkos::grow_arrays(int nmax) ------------------------------------------------------------------------- */ template -void FixQEqReaxKokkos::copy_arrays(int i, int j, int /*delflag*/) +void FixQEqReaxFFKokkos::copy_arrays(int i, int j, int /*delflag*/) { k_s_hist.template sync(); k_t_hist.template sync(); @@ -1548,7 +1544,7 @@ void FixQEqReaxKokkos::copy_arrays(int i, int j, int /*delflag*/) ------------------------------------------------------------------------- */ template -int FixQEqReaxKokkos::pack_exchange(int i, double *buf) +int FixQEqReaxFFKokkos::pack_exchange(int i, double *buf) { k_s_hist.template sync(); k_t_hist.template sync(); @@ -1563,7 +1559,7 @@ int FixQEqReaxKokkos::pack_exchange(int i, double *buf) ------------------------------------------------------------------------- */ template -int FixQEqReaxKokkos::unpack_exchange(int nlocal, double *buf) +int FixQEqReaxFFKokkos::unpack_exchange(int nlocal, double *buf) { k_s_hist.template sync(); k_t_hist.template sync(); @@ -1580,8 +1576,8 @@ int FixQEqReaxKokkos::unpack_exchange(int nlocal, double *buf) /* ---------------------------------------------------------------------- */ namespace LAMMPS_NS { -template class FixQEqReaxKokkos; +template class FixQEqReaxFFKokkos; #ifdef LMP_KOKKOS_GPU -template class FixQEqReaxKokkos; +template class FixQEqReaxFFKokkos; #endif } diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.h b/src/KOKKOS/fix_qeq_reaxff_kokkos.h similarity index 74% rename from src/KOKKOS/fix_qeq_reax_kokkos.h rename to src/KOKKOS/fix_qeq_reaxff_kokkos.h index aa4ae354cd..71c0808b0f 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.h +++ b/src/KOKKOS/fix_qeq_reaxff_kokkos.h @@ -14,16 +14,19 @@ #ifdef FIX_CLASS // clang-format off -FixStyle(qeq/reax/kk,FixQEqReaxKokkos); -FixStyle(qeq/reax/kk/device,FixQEqReaxKokkos); -FixStyle(qeq/reax/kk/host,FixQEqReaxKokkos); +FixStyle(qeq/reaxff/kk,FixQEqReaxFFKokkos); +FixStyle(qeq/reaxff/kk/device,FixQEqReaxFFKokkos); +FixStyle(qeq/reaxff/kk/host,FixQEqReaxFFKokkos); +FixStyle(qeq/reax/kk,FixQEqReaxFFKokkos); +FixStyle(qeq/reax/kk/device,FixQEqReaxFFKokkos); +FixStyle(qeq/reax/kk/host,FixQEqReaxFFKokkos); // clang-format on #else -#ifndef LMP_FIX_QEQ_REAX_KOKKOS_H -#define LMP_FIX_QEQ_REAX_KOKKOS_H +#ifndef LMP_FIX_QEQ_REAXFF_KOKKOS_H +#define LMP_FIX_QEQ_REAXFF_KOKKOS_H -#include "fix_qeq_reax.h" +#include "fix_qeq_reaxff.h" #include "kokkos_type.h" #include "neigh_list.h" #include "neigh_list_kokkos.h" @@ -35,16 +38,16 @@ struct TagSparseMatvec1 {}; struct TagSparseMatvec2 {}; struct TagSparseMatvec3 {}; struct TagZeroQGhosts{}; -struct TagFixQEqReaxPackForwardComm {}; -struct TagFixQEqReaxUnpackForwardComm {}; +struct TagFixQEqReaxFFPackForwardComm {}; +struct TagFixQEqReaxFFUnpackForwardComm {}; template -class FixQEqReaxKokkos : public FixQEqReax, public KokkosBase { +class FixQEqReaxFFKokkos : public FixQEqReaxFF, public KokkosBase { public: typedef DeviceType device_type; typedef ArrayTypes AT; - FixQEqReaxKokkos(class LAMMPS *, int, char **); - ~FixQEqReaxKokkos(); + FixQEqReaxFFKokkos(class LAMMPS *, int, char **); + ~FixQEqReaxFFKokkos(); void cleanup_copy(); void init(); @@ -141,10 +144,10 @@ class FixQEqReaxKokkos : public FixQEqReax, public KokkosBase { double calculate_H_k(const F_FLOAT &r, const F_FLOAT &shld) const; KOKKOS_INLINE_FUNCTION - void operator()(TagFixQEqReaxPackForwardComm, const int&) const; + void operator()(TagFixQEqReaxFFPackForwardComm, const int&) const; KOKKOS_INLINE_FUNCTION - void operator()(TagFixQEqReaxUnpackForwardComm, const int&) const; + void operator()(TagFixQEqReaxFFUnpackForwardComm, const int&) const; struct params_qeq{ KOKKOS_INLINE_FUNCTION @@ -225,8 +228,8 @@ class FixQEqReaxKokkos : public FixQEqReax, public KokkosBase { void init_hist(); void allocate_matrix(); void allocate_array(); - void cg_solve1(); - void cg_solve2(); + int cg_solve1(); + int cg_solve2(); void calculate_q(); int neighflag, pack_flag; @@ -241,11 +244,11 @@ class FixQEqReaxKokkos : public FixQEqReax, public KokkosBase { }; template -struct FixQEqReaxKokkosNumNeighFunctor { +struct FixQEqReaxFFKokkosNumNeighFunctor { typedef DeviceType device_type ; typedef int value_type ; - FixQEqReaxKokkos c; - FixQEqReaxKokkosNumNeighFunctor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkos c; + FixQEqReaxFFKokkosNumNeighFunctor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -255,10 +258,10 @@ struct FixQEqReaxKokkosNumNeighFunctor { }; template -struct FixQEqReaxKokkosMatVecFunctor { +struct FixQEqReaxFFKokkosMatVecFunctor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; - FixQEqReaxKokkosMatVecFunctor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkos c; + FixQEqReaxFFKokkosMatVecFunctor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -268,17 +271,17 @@ struct FixQEqReaxKokkosMatVecFunctor { }; template -struct FixQEqReaxKokkosComputeHFunctor { +struct FixQEqReaxFFKokkosComputeHFunctor { int atoms_per_team, vector_length; typedef int value_type; typedef Kokkos::ScratchMemorySpace scratch_space; - FixQEqReaxKokkos c; + FixQEqReaxFFKokkos c; - FixQEqReaxKokkosComputeHFunctor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkosComputeHFunctor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; - FixQEqReaxKokkosComputeHFunctor(FixQEqReaxKokkos *c_ptr, + FixQEqReaxFFKokkosComputeHFunctor(FixQEqReaxFFKokkos *c_ptr, int _atoms_per_team, int _vector_length) : atoms_per_team(_atoms_per_team), vector_length(_vector_length), c(*c_ptr) { c.cleanup_copy(); @@ -315,10 +318,10 @@ struct FixQEqReaxKokkosComputeHFunctor { }; template -struct FixQEqReaxKokkosZeroFunctor { +struct FixQEqReaxFFKokkosZeroFunctor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; - FixQEqReaxKokkosZeroFunctor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkos c; + FixQEqReaxFFKokkosZeroFunctor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -328,10 +331,10 @@ struct FixQEqReaxKokkosZeroFunctor { }; template -struct FixQEqReaxKokkosSparse12Functor { +struct FixQEqReaxFFKokkosSparse12Functor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; - FixQEqReaxKokkosSparse12Functor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkos c; + FixQEqReaxFFKokkosSparse12Functor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -341,10 +344,10 @@ struct FixQEqReaxKokkosSparse12Functor { }; template -struct FixQEqReaxKokkosSparse13Functor { +struct FixQEqReaxFFKokkosSparse13Functor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; - FixQEqReaxKokkosSparse13Functor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkos c; + FixQEqReaxFFKokkosSparse13Functor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -354,10 +357,10 @@ struct FixQEqReaxKokkosSparse13Functor { }; template -struct FixQEqReaxKokkosSparse22Functor { +struct FixQEqReaxFFKokkosSparse22Functor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; - FixQEqReaxKokkosSparse22Functor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkos c; + FixQEqReaxFFKokkosSparse22Functor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -367,10 +370,10 @@ struct FixQEqReaxKokkosSparse22Functor { }; template -struct FixQEqReaxKokkosSparse23Functor { +struct FixQEqReaxFFKokkosSparse23Functor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; - FixQEqReaxKokkosSparse23Functor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkos c; + FixQEqReaxFFKokkosSparse23Functor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -380,10 +383,10 @@ struct FixQEqReaxKokkosSparse23Functor { }; template -struct FixQEqReaxKokkosSparse32Functor { +struct FixQEqReaxFFKokkosSparse32Functor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; - FixQEqReaxKokkosSparse32Functor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkos c; + FixQEqReaxFFKokkosSparse32Functor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -393,10 +396,10 @@ struct FixQEqReaxKokkosSparse32Functor { }; template -struct FixQEqReaxKokkosSparse33Functor { +struct FixQEqReaxFFKokkosSparse33Functor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; - FixQEqReaxKokkosSparse33Functor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkos c; + FixQEqReaxFFKokkosSparse33Functor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -406,10 +409,10 @@ struct FixQEqReaxKokkosSparse33Functor { }; template -struct FixQEqReaxKokkosVecSum2Functor { +struct FixQEqReaxFFKokkosVecSum2Functor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; - FixQEqReaxKokkosVecSum2Functor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkos c; + FixQEqReaxFFKokkosVecSum2Functor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -419,11 +422,11 @@ struct FixQEqReaxKokkosVecSum2Functor { }; template -struct FixQEqReaxKokkosNorm1Functor { +struct FixQEqReaxFFKokkosNorm1Functor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; + FixQEqReaxFFKokkos c; typedef double value_type; - FixQEqReaxKokkosNorm1Functor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkosNorm1Functor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -433,11 +436,11 @@ struct FixQEqReaxKokkosNorm1Functor { }; template -struct FixQEqReaxKokkosNorm2Functor { +struct FixQEqReaxFFKokkosNorm2Functor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; + FixQEqReaxFFKokkos c; typedef double value_type; - FixQEqReaxKokkosNorm2Functor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkosNorm2Functor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -447,11 +450,11 @@ struct FixQEqReaxKokkosNorm2Functor { }; template -struct FixQEqReaxKokkosDot1Functor { +struct FixQEqReaxFFKokkosDot1Functor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; + FixQEqReaxFFKokkos c; typedef double value_type; - FixQEqReaxKokkosDot1Functor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkosDot1Functor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -461,11 +464,11 @@ struct FixQEqReaxKokkosDot1Functor { }; template -struct FixQEqReaxKokkosDot2Functor { +struct FixQEqReaxFFKokkosDot2Functor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; + FixQEqReaxFFKokkos c; typedef double value_type; - FixQEqReaxKokkosDot2Functor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkosDot2Functor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -475,10 +478,10 @@ struct FixQEqReaxKokkosDot2Functor { }; template -struct FixQEqReaxKokkosPrecon1Functor { +struct FixQEqReaxFFKokkosPrecon1Functor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; - FixQEqReaxKokkosPrecon1Functor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkos c; + FixQEqReaxFFKokkosPrecon1Functor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -488,10 +491,10 @@ struct FixQEqReaxKokkosPrecon1Functor { }; template -struct FixQEqReaxKokkosPrecon2Functor { +struct FixQEqReaxFFKokkosPrecon2Functor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; - FixQEqReaxKokkosPrecon2Functor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkos c; + FixQEqReaxFFKokkosPrecon2Functor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -501,11 +504,11 @@ struct FixQEqReaxKokkosPrecon2Functor { }; template -struct FixQEqReaxKokkosPreconFunctor { +struct FixQEqReaxFFKokkosPreconFunctor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; + FixQEqReaxFFKokkos c; typedef double value_type; - FixQEqReaxKokkosPreconFunctor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkosPreconFunctor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -515,11 +518,11 @@ struct FixQEqReaxKokkosPreconFunctor { }; template -struct FixQEqReaxKokkosVecAcc1Functor { +struct FixQEqReaxFFKokkosVecAcc1Functor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; + FixQEqReaxFFKokkos c; typedef double value_type; - FixQEqReaxKokkosVecAcc1Functor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkosVecAcc1Functor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -529,11 +532,11 @@ struct FixQEqReaxKokkosVecAcc1Functor { }; template -struct FixQEqReaxKokkosVecAcc2Functor { +struct FixQEqReaxFFKokkosVecAcc2Functor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; + FixQEqReaxFFKokkos c; typedef double value_type; - FixQEqReaxKokkosVecAcc2Functor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkosVecAcc2Functor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION @@ -543,10 +546,10 @@ struct FixQEqReaxKokkosVecAcc2Functor { }; template -struct FixQEqReaxKokkosCalculateQFunctor { +struct FixQEqReaxFFKokkosCalculateQFunctor { typedef DeviceType device_type ; - FixQEqReaxKokkos c; - FixQEqReaxKokkosCalculateQFunctor(FixQEqReaxKokkos* c_ptr):c(*c_ptr) { + FixQEqReaxFFKokkos c; + FixQEqReaxFFKokkosCalculateQFunctor(FixQEqReaxFFKokkos* c_ptr):c(*c_ptr) { c.cleanup_copy(); }; KOKKOS_INLINE_FUNCTION diff --git a/src/KOKKOS/fix_reaxc_bonds_kokkos.cpp b/src/KOKKOS/fix_reaxff_bonds_kokkos.cpp similarity index 69% rename from src/KOKKOS/fix_reaxc_bonds_kokkos.cpp rename to src/KOKKOS/fix_reaxff_bonds_kokkos.cpp index 3da59ce972..2fc7d4639d 100644 --- a/src/KOKKOS/fix_reaxc_bonds_kokkos.cpp +++ b/src/KOKKOS/fix_reaxff_bonds_kokkos.cpp @@ -16,22 +16,22 @@ Contributing author: Stan Moore (Sandia) ------------------------------------------------------------------------- */ -#include "fix_reaxc_bonds_kokkos.h" +#include "fix_reaxff_bonds_kokkos.h" #include "atom.h" #include "atom_masks.h" #include "error.h" #include "force.h" #include "memory_kokkos.h" -#include "pair_reaxc_kokkos.h" +#include "pair_reaxff_kokkos.h" using namespace LAMMPS_NS; using namespace FixConst; /* ---------------------------------------------------------------------- */ -FixReaxCBondsKokkos::FixReaxCBondsKokkos(LAMMPS *lmp, int narg, char **arg) : - FixReaxCBonds(lmp, narg, arg) +FixReaxFFBondsKokkos::FixReaxFFBondsKokkos(LAMMPS *lmp, int narg, char **arg) : + FixReaxFFBonds(lmp, narg, arg) { kokkosable = 1; atomKK = (AtomKokkos *) atom; @@ -42,25 +42,25 @@ FixReaxCBondsKokkos::FixReaxCBondsKokkos(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ -FixReaxCBondsKokkos::~FixReaxCBondsKokkos() +FixReaxFFBondsKokkos::~FixReaxFFBondsKokkos() { } /* ---------------------------------------------------------------------- */ -void FixReaxCBondsKokkos::init() +void FixReaxFFBondsKokkos::init() { - Pair *pair_kk = force->pair_match("reax/c/kk",0); - if (pair_kk == nullptr) error->all(FLERR,"Cannot use fix reax/c/bonds without " - "pair_style reax/c/kk"); + Pair *pair_kk = force->pair_match("^reax../kk",0); + if (pair_kk == nullptr) error->all(FLERR,"Cannot use fix reaxff/bonds without " + "pair_style reaxff/kk"); - FixReaxCBonds::init(); + FixReaxFFBonds::init(); } /* ---------------------------------------------------------------------- */ -void FixReaxCBondsKokkos::Output_ReaxC_Bonds(bigint /*ntimestep*/, FILE * /*fp*/) +void FixReaxFFBondsKokkos::Output_ReaxFF_Bonds() { int nbuf_local; @@ -72,23 +72,23 @@ void FixReaxCBondsKokkos::Output_ReaxC_Bonds(bigint /*ntimestep*/, FILE * /*fp*/ int nlocal_tot = static_cast (atom->natoms); numbonds = 0; - if (reaxc->execution_space == Device) - ((PairReaxCKokkos*) reaxc)->FindBond(numbonds); + if (reaxff->execution_space == Device) + ((PairReaxFFKokkos*) reaxff)->FindBond(numbonds); else - ((PairReaxCKokkos*) reaxc)->FindBond(numbonds); + ((PairReaxFFKokkos*) reaxff)->FindBond(numbonds); // allocate a temporary buffer for the snapshot info MPI_Allreduce(&numbonds,&numbonds_max,1,MPI_INT,MPI_MAX,world); MPI_Allreduce(&nlocal,&nlocal_max,1,MPI_INT,MPI_MAX,world); nbuf = 1+(numbonds_max*2+10)*nlocal_max; - memoryKK->create_kokkos(k_buf,buf,nbuf,"reax/c/bonds:buf"); + memoryKK->create_kokkos(k_buf,buf,nbuf,"reaxff/bonds:buf"); // Pass information to buffer - if (reaxc->execution_space == Device) - ((PairReaxCKokkos*) reaxc)->PackBondBuffer(k_buf,nbuf_local); + if (reaxff->execution_space == Device) + ((PairReaxFFKokkos*) reaxff)->PackBondBuffer(k_buf,nbuf_local); else - ((PairReaxCKokkos*) reaxc)->PackBondBuffer(k_buf,nbuf_local); + ((PairReaxFFKokkos*) reaxff)->PackBondBuffer(k_buf,nbuf_local); buf[0] = nlocal; // Receive information from buffer for output @@ -99,12 +99,12 @@ void FixReaxCBondsKokkos::Output_ReaxC_Bonds(bigint /*ntimestep*/, FILE * /*fp*/ /* ---------------------------------------------------------------------- */ -double FixReaxCBondsKokkos::memory_usage() +double FixReaxFFBondsKokkos::memory_usage() { double bytes; bytes = nbuf*sizeof(double); - // These are accounted for in PairReaxCKokkos: + // These are accounted for in PairReaxFFKokkos: //bytes += nmax*sizeof(int); //bytes += 1.0*nmax*MAXREAXBOND*sizeof(double); //bytes += 1.0*nmax*MAXREAXBOND*sizeof(int); diff --git a/src/KOKKOS/fix_reaxc_bonds_kokkos.h b/src/KOKKOS/fix_reaxff_bonds_kokkos.h similarity index 59% rename from src/KOKKOS/fix_reaxc_bonds_kokkos.h rename to src/KOKKOS/fix_reaxff_bonds_kokkos.h index 8c1bb9bef9..b39dfa3c17 100644 --- a/src/KOKKOS/fix_reaxc_bonds_kokkos.h +++ b/src/KOKKOS/fix_reaxff_bonds_kokkos.h @@ -14,29 +14,32 @@ #ifdef FIX_CLASS // clang-format off -FixStyle(reax/c/bonds/kk,FixReaxCBondsKokkos); -FixStyle(reax/c/bonds/kk/device,FixReaxCBondsKokkos); -FixStyle(reax/c/bonds/kk/host,FixReaxCBondsKokkos); +FixStyle(reaxff/bonds/kk,FixReaxFFBondsKokkos); +FixStyle(reaxff/bonds/kk/device,FixReaxFFBondsKokkos); +FixStyle(reaxff/bonds/kk/host,FixReaxFFBondsKokkos); +FixStyle(reax/c/bonds/kk,FixReaxFFBondsKokkos); +FixStyle(reax/c/bonds/kk/device,FixReaxFFBondsKokkos); +FixStyle(reax/c/bonds/kk/host,FixReaxFFBondsKokkos); // clang-format on #else -#ifndef LMP_FIX_REAXC_BONDS_KOKKOS_H -#define LMP_FIX_REAXC_BONDS_KOKKOS_H +#ifndef LMP_FIX_REAXFF_BONDS_KOKKOS_H +#define LMP_FIX_REAXFF_BONDS_KOKKOS_H -#include "fix_reaxc_bonds.h" +#include "fix_reaxff_bonds.h" #include "kokkos_type.h" namespace LAMMPS_NS { -class FixReaxCBondsKokkos : public FixReaxCBonds { +class FixReaxFFBondsKokkos : public FixReaxFFBonds { public: - FixReaxCBondsKokkos(class LAMMPS *, int, char **); - virtual ~FixReaxCBondsKokkos(); + FixReaxFFBondsKokkos(class LAMMPS *, int, char **); + virtual ~FixReaxFFBondsKokkos(); void init(); private: int nbuf; - void Output_ReaxC_Bonds(bigint, FILE *); + void Output_ReaxFF_Bonds(); double memory_usage(); }; } diff --git a/src/KOKKOS/fix_reaxc_species_kokkos.cpp b/src/KOKKOS/fix_reaxff_species_kokkos.cpp similarity index 82% rename from src/KOKKOS/fix_reaxc_species_kokkos.cpp rename to src/KOKKOS/fix_reaxff_species_kokkos.cpp index 85cd3b23ba..d3d913eda8 100644 --- a/src/KOKKOS/fix_reaxc_species_kokkos.cpp +++ b/src/KOKKOS/fix_reaxff_species_kokkos.cpp @@ -16,27 +16,29 @@ Contributing authors: Stan Moore (Sandia) ------------------------------------------------------------------------- */ -#include "fix_reaxc_species_kokkos.h" +#include "fix_reaxff_species_kokkos.h" + #include "atom.h" -#include "fix_ave_atom.h" -#include "reaxc_defs.h" -#include "pair_reaxc_kokkos.h" -#include "neigh_list.h" -#include "neigh_request.h" +#include "atom_masks.h" #include "comm.h" +#include "error.h" #include "force.h" #include "input.h" #include "memory_kokkos.h" -#include "error.h" -#include "atom_masks.h" +#include "neigh_list.h" +#include "neigh_request.h" + +#include "fix_ave_atom.h" +#include "pair_reaxff_kokkos.h" +#include "reaxff_defs.h" using namespace LAMMPS_NS; using namespace FixConst; /* ---------------------------------------------------------------------- */ -FixReaxCSpeciesKokkos::FixReaxCSpeciesKokkos(LAMMPS *lmp, int narg, char **arg) : - FixReaxCSpecies(lmp, narg, arg) +FixReaxFFSpeciesKokkos::FixReaxFFSpeciesKokkos(LAMMPS *lmp, int narg, char **arg) : + FixReaxFFSpecies(lmp, narg, arg) { kokkosable = 1; atomKK = (AtomKokkos *) atom; @@ -49,25 +51,25 @@ FixReaxCSpeciesKokkos::FixReaxCSpeciesKokkos(LAMMPS *lmp, int narg, char **arg) /* ---------------------------------------------------------------------- */ -FixReaxCSpeciesKokkos::~FixReaxCSpeciesKokkos() +FixReaxFFSpeciesKokkos::~FixReaxFFSpeciesKokkos() { } /* ---------------------------------------------------------------------- */ -void FixReaxCSpeciesKokkos::init() +void FixReaxFFSpeciesKokkos::init() { - Pair* pair_kk = force->pair_match("reax/c/kk",0); - if (pair_kk == nullptr) error->all(FLERR,"Cannot use fix reax/c/species/kk without " - "pair_style reax/c/kk"); + Pair* pair_kk = force->pair_match("^reax../kk",0); + if (pair_kk == nullptr) error->all(FLERR,"Cannot use fix reaxff/species/kk without " + "pair_style reaxff/kk"); - FixReaxCSpecies::init(); + FixReaxFFSpecies::init(); } /* ---------------------------------------------------------------------- */ -void FixReaxCSpeciesKokkos::FindMolecule() +void FixReaxFFSpeciesKokkos::FindMolecule() { int i,j,ii,jj,inum,itype,jtype,loop,looptot; int change,done,anychange; @@ -75,14 +77,14 @@ void FixReaxCSpeciesKokkos::FindMolecule() double bo_tmp,bo_cut; double **spec_atom = f_SPECBOND->array_atom; - inum = reaxc->list->inum; + inum = reaxff->list->inum; typename ArrayTypes::t_int_1d ilist; - if (reaxc->execution_space == Host) { - NeighListKokkos* k_list = static_cast*>(reaxc->list); + if (reaxff->execution_space == Host) { + NeighListKokkos* k_list = static_cast*>(reaxff->list); k_list->k_ilist.sync(); ilist = k_list->k_ilist.h_view; } else { - NeighListKokkos* k_list = static_cast*>(reaxc->list); + NeighListKokkos* k_list = static_cast*>(reaxff->list); k_list->k_ilist.sync(); ilist = k_list->k_ilist.h_view; } @@ -114,7 +116,7 @@ void FixReaxCSpeciesKokkos::FindMolecule() itype = atom->type[i]; for (jj = 0; jj < MAXSPECBOND; jj++) { - j = reaxc->tmpid[i][jj]; + j = reaxff->tmpid[i][jj]; if ((j == 0) && (j < i)) continue; if (!(mask[j] & groupbit)) continue; diff --git a/src/KOKKOS/fix_reaxc_species_kokkos.h b/src/KOKKOS/fix_reaxff_species_kokkos.h similarity index 58% rename from src/KOKKOS/fix_reaxc_species_kokkos.h rename to src/KOKKOS/fix_reaxff_species_kokkos.h index 1a5f204132..ad9d02319d 100644 --- a/src/KOKKOS/fix_reaxc_species_kokkos.h +++ b/src/KOKKOS/fix_reaxff_species_kokkos.h @@ -14,25 +14,28 @@ #ifdef FIX_CLASS // clang-format off -FixStyle(reax/c/species/kk,FixReaxCSpeciesKokkos); -FixStyle(reax/c/species/kk/device,FixReaxCSpeciesKokkos); -FixStyle(reax/c/species/kk/host,FixReaxCSpeciesKokkos); +FixStyle(reaxff/species/kk,FixReaxFFSpeciesKokkos); +FixStyle(reaxff/species/kk/device,FixReaxFFSpeciesKokkos); +FixStyle(reaxff/species/kk/host,FixReaxFFSpeciesKokkos); +FixStyle(reax/c/species/kk,FixReaxFFSpeciesKokkos); +FixStyle(reax/c/species/kk/device,FixReaxFFSpeciesKokkos); +FixStyle(reax/c/species/kk/host,FixReaxFFSpeciesKokkos); // clang-format on #else -#ifndef LMP_FIX_REAXC_SPECIES_KOKKOS_H -#define LMP_FIX_REAXC_SPECIES_KOKKOS_H +#ifndef LMP_FIX_REAXFF_SPECIES_KOKKOS_H +#define LMP_FIX_REAXFF_SPECIES_KOKKOS_H -#include "fix_reaxc_species.h" +#include "fix_reaxff_species.h" #define BUFLEN 1000 namespace LAMMPS_NS { -class FixReaxCSpeciesKokkos : public FixReaxCSpecies { +class FixReaxFFSpeciesKokkos : public FixReaxFFSpecies { public: - FixReaxCSpeciesKokkos(class LAMMPS *, int, char **); - virtual ~FixReaxCSpeciesKokkos(); + FixReaxFFSpeciesKokkos(class LAMMPS *, int, char **); + virtual ~FixReaxFFSpeciesKokkos(); void init(); private: diff --git a/src/KOKKOS/pair_reaxc_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp similarity index 84% rename from src/KOKKOS/pair_reaxc_kokkos.cpp rename to src/KOKKOS/pair_reaxff_kokkos.cpp index de707fba3b..aac0229f87 100644 --- a/src/KOKKOS/pair_reaxc_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -16,7 +16,7 @@ Contributing author: Ray Shan (SNL), Stan Moore (SNL) ------------------------------------------------------------------------- */ -#include "pair_reaxc_kokkos.h" +#include "pair_reaxff_kokkos.h" #include "atom_kokkos.h" #include "atom_masks.h" @@ -28,23 +28,23 @@ #include "math_special.h" #include "neigh_request.h" #include "neighbor.h" -#include "reaxc_defs.h" -#include "reaxc_lookup.h" -#include "reaxc_tool_box.h" + +#include "reaxff_api.h" #include - #define TEAMSIZE 128 /* ---------------------------------------------------------------------- */ +using namespace ReaxFF; + namespace LAMMPS_NS { using namespace MathConst; using namespace MathSpecial; template -PairReaxCKokkos::PairReaxCKokkos(LAMMPS *lmp) : PairReaxC(lmp) +PairReaxFFKokkos::PairReaxFFKokkos(LAMMPS *lmp) : PairReaxFF(lmp) { respa_enable = 0; @@ -73,7 +73,7 @@ PairReaxCKokkos::PairReaxCKokkos(LAMMPS *lmp) : PairReaxC(lmp) /* ---------------------------------------------------------------------- */ template -PairReaxCKokkos::~PairReaxCKokkos() +PairReaxFFKokkos::~PairReaxFFKokkos() { if (copymode) return; @@ -100,28 +100,28 @@ PairReaxCKokkos::~PairReaxCKokkos() /* ---------------------------------------------------------------------- */ template -void PairReaxCKokkos::allocate() +void PairReaxFFKokkos::allocate() { int n = atom->ntypes; k_params_sing = Kokkos::DualView - ("PairReaxC::params_sing",n+1); + ("PairReaxFF::params_sing",n+1); paramssing = k_params_sing.template view(); k_params_twbp = Kokkos::DualView - ("PairReaxC::params_twbp",n+1,n+1); + ("PairReaxFF::params_twbp",n+1,n+1); paramstwbp = k_params_twbp.template view(); k_params_thbp = Kokkos::DualView - ("PairReaxC::params_thbp",n+1,n+1,n+1); + ("PairReaxFF::params_thbp",n+1,n+1,n+1); paramsthbp = k_params_thbp.template view(); k_params_fbp = Kokkos::DualView - ("PairReaxC::params_fbp",n+1,n+1,n+1,n+1); + ("PairReaxFF::params_fbp",n+1,n+1,n+1,n+1); paramsfbp = k_params_fbp.template view(); k_params_hbp = Kokkos::DualView - ("PairReaxC::params_hbp",n+1,n+1,n+1); + ("PairReaxFF::params_hbp",n+1,n+1,n+1); paramshbp = k_params_hbp.template view(); k_tap = DAT::tdual_ffloat_1d("pair:tap",8); @@ -135,11 +135,11 @@ void PairReaxCKokkos::allocate() ------------------------------------------------------------------------- */ template -void PairReaxCKokkos::init_style() +void PairReaxFFKokkos::init_style() { - PairReaxC::init_style(); - if (fix_reax) modify->delete_fix(fix_id); // not needed in the Kokkos version - fix_reax = nullptr; + PairReaxFF::init_style(); + if (fix_reaxff) modify->delete_fix(fix_id); // not needed in the Kokkos version + fix_reaxff = nullptr; // irequest = neigh request made by parent class @@ -157,7 +157,7 @@ void PairReaxCKokkos::init_style() neighbor->requests[irequest]->half = 1; neighbor->requests[irequest]->ghost = 1; } else { - error->all(FLERR,"Must use half neighbor list with pair style reax/c/kk"); + error->all(FLERR,"Must use half neighbor list with pair style reaxff/kk"); } allocate(); @@ -168,21 +168,21 @@ void PairReaxCKokkos::init_style() /* ---------------------------------------------------------------------- */ template -void PairReaxCKokkos::setup() +void PairReaxFFKokkos::setup() { int i,j,k,m; int n = atom->ntypes; // general parameters for (i = 0; i < 39; i ++) - gp[i] = system->reax_param.gp.l[i]; + gp[i] = api->system->reax_param.gp.l[i]; p_boc1 = gp[0]; p_boc2 = gp[1]; // vdw parameters - vdwflag = system->reax_param.gp.vdw_type; - lgflag = control->lgflag; + vdwflag = api->system->reax_param.gp.vdw_type; + lgflag = api->control->lgflag; // atom, bond, angle, dihedral, H-bond specific parameters two_body_parameters *twbp; @@ -202,38 +202,38 @@ void PairReaxCKokkos::setup() if (map[i] == -1) continue; // general - k_params_sing.h_view(i).mass = system->reax_param.sbp[map[i]].mass; + k_params_sing.h_view(i).mass = api->system->reax_param.sbp[map[i]].mass; // polarization - k_params_sing.h_view(i).chi = system->reax_param.sbp[map[i]].chi; - k_params_sing.h_view(i).eta = system->reax_param.sbp[map[i]].eta; + k_params_sing.h_view(i).chi = api->system->reax_param.sbp[map[i]].chi; + k_params_sing.h_view(i).eta = api->system->reax_param.sbp[map[i]].eta; // bond order - k_params_sing.h_view(i).r_s = system->reax_param.sbp[map[i]].r_s; - k_params_sing.h_view(i).r_pi = system->reax_param.sbp[map[i]].r_pi; - k_params_sing.h_view(i).r_pi2 = system->reax_param.sbp[map[i]].r_pi_pi; - k_params_sing.h_view(i).valency = system->reax_param.sbp[map[i]].valency; - k_params_sing.h_view(i).valency_val = system->reax_param.sbp[map[i]].valency_val; - k_params_sing.h_view(i).valency_boc = system->reax_param.sbp[map[i]].valency_boc; - k_params_sing.h_view(i).valency_e = system->reax_param.sbp[map[i]].valency_e; - k_params_sing.h_view(i).nlp_opt = system->reax_param.sbp[map[i]].nlp_opt; + k_params_sing.h_view(i).r_s = api->system->reax_param.sbp[map[i]].r_s; + k_params_sing.h_view(i).r_pi = api->system->reax_param.sbp[map[i]].r_pi; + k_params_sing.h_view(i).r_pi2 = api->system->reax_param.sbp[map[i]].r_pi_pi; + k_params_sing.h_view(i).valency = api->system->reax_param.sbp[map[i]].valency; + k_params_sing.h_view(i).valency_val = api->system->reax_param.sbp[map[i]].valency_val; + k_params_sing.h_view(i).valency_boc = api->system->reax_param.sbp[map[i]].valency_boc; + k_params_sing.h_view(i).valency_e = api->system->reax_param.sbp[map[i]].valency_e; + k_params_sing.h_view(i).nlp_opt = api->system->reax_param.sbp[map[i]].nlp_opt; // multibody - k_params_sing.h_view(i).p_lp2 = system->reax_param.sbp[map[i]].p_lp2; - k_params_sing.h_view(i).p_ovun2 = system->reax_param.sbp[map[i]].p_ovun2; - k_params_sing.h_view(i).p_ovun5 = system->reax_param.sbp[map[i]].p_ovun5; + k_params_sing.h_view(i).p_lp2 = api->system->reax_param.sbp[map[i]].p_lp2; + k_params_sing.h_view(i).p_ovun2 = api->system->reax_param.sbp[map[i]].p_ovun2; + k_params_sing.h_view(i).p_ovun5 = api->system->reax_param.sbp[map[i]].p_ovun5; // angular - k_params_sing.h_view(i).p_val3 = system->reax_param.sbp[map[i]].p_val3; - k_params_sing.h_view(i).p_val5 = system->reax_param.sbp[map[i]].p_val5; + k_params_sing.h_view(i).p_val3 = api->system->reax_param.sbp[map[i]].p_val3; + k_params_sing.h_view(i).p_val5 = api->system->reax_param.sbp[map[i]].p_val5; // hydrogen bond - k_params_sing.h_view(i).p_hbond = system->reax_param.sbp[map[i]].p_hbond; + k_params_sing.h_view(i).p_hbond = api->system->reax_param.sbp[map[i]].p_hbond; for (j = 1; j <= n; j++) { if (map[j] == -1) continue; - twbp = &(system->reax_param.tbp[map[i]][map[j]]); + twbp = &(api->system->reax_param.tbp[map[i]][map[j]]); // vdW k_params_twbp.h_view(i,j).gamma = twbp->gamma; @@ -277,7 +277,7 @@ void PairReaxCKokkos::setup() if (map[k] == -1) continue; // Angular - thbh = &(system->reax_param.thbp[map[i]][map[j]][map[k]]); + thbh = &(api->system->reax_param.thbp[map[i]][map[j]][map[k]]); thbp = &(thbh->prm[0]); k_params_thbp.h_view(i,j,k).cnt = thbh->cnt; k_params_thbp.h_view(i,j,k).theta_00 = thbp->theta_00; @@ -289,7 +289,7 @@ void PairReaxCKokkos::setup() k_params_thbp.h_view(i,j,k).p_coa1 = thbp->p_coa1; // Hydrogen Bond - hbp = &(system->reax_param.hbp[map[i]][map[j]][map[k]]); + hbp = &(api->system->reax_param.hbp[map[i]][map[j]][map[k]]); k_params_hbp.h_view(i,j,k).p_hb1 = hbp->p_hb1; k_params_hbp.h_view(i,j,k).p_hb2 = hbp->p_hb2; k_params_hbp.h_view(i,j,k).p_hb3 = hbp->p_hb3; @@ -299,7 +299,7 @@ void PairReaxCKokkos::setup() if (map[m] == -1) continue; // Torsion - fbh = &(system->reax_param.fbp[map[i]][map[j]][map[k]][map[m]]); + fbh = &(api->system->reax_param.fbp[map[i]][map[j]][map[k]][map[m]]); fbp = &(fbh->prm[0]); k_params_fbp.h_view(i,j,k,m).p_tor1 = fbp->p_tor1; k_params_fbp.h_view(i,j,k,m).p_cot1 = fbp->p_cot1; @@ -317,13 +317,13 @@ void PairReaxCKokkos::setup() k_params_hbp.template modify(); // cutoffs - cut_nbsq = control->nonb_cut * control->nonb_cut; - cut_hbsq = control->hbond_cut * control->hbond_cut; - cut_bosq = control->bond_cut * control->bond_cut; + cut_nbsq = api->control->nonb_cut * api->control->nonb_cut; + cut_hbsq = api->control->hbond_cut * api->control->hbond_cut; + cut_bosq = api->control->bond_cut * api->control->bond_cut; // bond order cutoffs bo_cut = 0.01 * gp[29]; - thb_cut = control->thb_cut; + thb_cut = api->control->thb_cut; thb_cutsq = 0.000010; //thb_cut*thb_cut; if (atom->nmax > nmax) { @@ -335,26 +335,24 @@ void PairReaxCKokkos::setup() /* ---------------------------------------------------------------------- */ template -void PairReaxCKokkos::init_md() +void PairReaxFFKokkos::init_md() { // init_taper() F_FLOAT d1, d7, swa, swa2, swa3, swb, swb2, swb3; - LR_lookup_table ** & LR = system->LR; + LR_lookup_table ** & LR = api->system->LR; - swa = control->nonb_low; - swb = control->nonb_cut; - enobondsflag = control->enobondsflag; + swa = api->control->nonb_low; + swb = api->control->nonb_cut; + enobondsflag = api->control->enobondsflag; - if (fabs(swa) > 0.01 ) + if (fabs(swa) > 0.01) error->warning(FLERR,"Warning: non-zero lower Taper-radius cutoff"); if (swb < 0) error->one(FLERR,"Negative upper Taper-radius cutoff"); - else if (swb < 5) { - char str[128]; - sprintf(str,"Warning: very low Taper-radius cutoff: %f\n", swb); - error->one(FLERR,str); - } + else if (swb < 5) + error->one(FLERR,fmt::format("Warning: very low Taper-radius cutoff: " + "{}\n", swb)); d1 = swb - swa; d7 = powint(d1,7); @@ -366,18 +364,18 @@ void PairReaxCKokkos::init_md() k_tap.h_view(7) = 20.0/d7; k_tap.h_view(6) = -70.0 * (swa + swb) / d7; k_tap.h_view(5) = 84.0 * (swa2 + 3.0*swa*swb + swb2) / d7; - k_tap.h_view(4) = -35.0 * (swa3 + 9.0*swa2*swb + 9.0*swa*swb2 + swb3 ) / d7; - k_tap.h_view(3) = 140.0 * (swa3*swb + 3.0*swa2*swb2 + swa*swb3 ) / d7; + k_tap.h_view(4) = -35.0 * (swa3 + 9.0*swa2*swb + 9.0*swa*swb2 + swb3) / d7; + k_tap.h_view(3) = 140.0 * (swa3*swb + 3.0*swa2*swb2 + swa*swb3) / d7; k_tap.h_view(2) =-210.0 * (swa3*swb2 + swa2*swb3) / d7; k_tap.h_view(1) = 140.0 * swa3 * swb3 / d7; k_tap.h_view(0) = (-35.0*swa3*swb2*swb2 + 21.0*swa2*swb3*swb2 - - 7.0*swa*swb3*swb3 + swb3*swb3*swb ) / d7; + 7.0*swa*swb3*swb3 + swb3*swb3*swb) / d7; k_tap.template modify(); k_tap.template sync(); - if (control->tabulate) { + if (api->control->tabulate) { int ntypes = atom->ntypes; Init_Lookup_Tables(); @@ -432,14 +430,14 @@ void PairReaxCKokkos::init_md() /* ---------------------------------------------------------------------- */ template -int PairReaxCKokkos::Init_Lookup_Tables() +int PairReaxFFKokkos::Init_Lookup_Tables() { int i, j, r; int num_atom_types; double dr; double *h, *fh, *fvdw, *fele, *fCEvd, *fCEclmb; double v0_vdw, v0_ele, vlast_vdw, vlast_ele; - LR_lookup_table ** & LR = system->LR; + LR_lookup_table ** & LR = api->system->LR; /* initializations */ v0_vdw = 0; @@ -448,49 +446,49 @@ int PairReaxCKokkos::Init_Lookup_Tables() vlast_ele = 0; num_atom_types = atom->ntypes; - dr = control->nonb_cut / control->tabulate; + dr = api->control->nonb_cut / api->control->tabulate; h = (double*) - smalloc( control->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:h"); + smalloc(api->control->error_ptr, (api->control->tabulate+2) * sizeof(double), "lookup:h"); fh = (double*) - smalloc( control->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:fh"); + smalloc(api->control->error_ptr, (api->control->tabulate+2) * sizeof(double), "lookup:fh"); fvdw = (double*) - smalloc( control->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:fvdw"); + smalloc(api->control->error_ptr, (api->control->tabulate+2) * sizeof(double), "lookup:fvdw"); fCEvd = (double*) - smalloc( control->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:fCEvd"); + smalloc(api->control->error_ptr, (api->control->tabulate+2) * sizeof(double), "lookup:fCEvd"); fele = (double*) - smalloc( control->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:fele"); + smalloc(api->control->error_ptr, (api->control->tabulate+2) * sizeof(double), "lookup:fele"); fCEclmb = (double*) - smalloc( control->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:fCEclmb"); + smalloc(api->control->error_ptr, (api->control->tabulate+2) * sizeof(double), "lookup:fCEclmb"); LR = (LR_lookup_table**) - scalloc( control->error_ptr, num_atom_types+1, sizeof(LR_lookup_table*), "lookup:LR"); + scalloc(api->control->error_ptr, num_atom_types+1, sizeof(LR_lookup_table*), "lookup:LR"); for (i = 0; i < num_atom_types+1; ++i) LR[i] = (LR_lookup_table*) - scalloc( control->error_ptr, num_atom_types+1, sizeof(LR_lookup_table), "lookup:LR[i]"); + scalloc(api->control->error_ptr, num_atom_types+1, sizeof(LR_lookup_table), "lookup:LR[i]"); for (i = 1; i <= num_atom_types; ++i) { for (j = i; j <= num_atom_types; ++j) { LR[i][j].xmin = 0; - LR[i][j].xmax = control->nonb_cut; - LR[i][j].n = control->tabulate + 2; + LR[i][j].xmax = api->control->nonb_cut; + LR[i][j].n = api->control->tabulate + 2; LR[i][j].dx = dr; - LR[i][j].inv_dx = control->tabulate / control->nonb_cut; + LR[i][j].inv_dx = api->control->tabulate / api->control->nonb_cut; LR[i][j].y = (LR_data*) - smalloc( control->error_ptr, LR[i][j].n * sizeof(LR_data), "lookup:LR[i,j].y"); + smalloc(api->control->error_ptr, LR[i][j].n * sizeof(LR_data), "lookup:LR[i,j].y"); LR[i][j].H = (cubic_spline_coef*) - smalloc( control->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].H"); + smalloc(api->control->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].H"); LR[i][j].vdW = (cubic_spline_coef*) - smalloc( control->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].vdW"); + smalloc(api->control->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].vdW"); LR[i][j].CEvd = (cubic_spline_coef*) - smalloc( control->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].CEvd"); + smalloc(api->control->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].CEvd"); LR[i][j].ele = (cubic_spline_coef*) - smalloc( control->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].ele"); + smalloc(api->control->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].ele"); LR[i][j].CEclmb = (cubic_spline_coef*) - smalloc( control->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef), + smalloc(api->control->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef), "lookup:LR[i,j].CEclmb"); - for (r = 1; r <= control->tabulate; ++r) { - LR_vdW_Coulomb(i, j, r * dr, &(LR[i][j].y[r]) ); + for (r = 1; r <= api->control->tabulate; ++r) { + LR_vdW_Coulomb(i, j, r * dr, &(LR[i][j].y[r])); h[r] = LR[i][j].dx; fh[r] = LR[i][j].y[r].H; fvdw[r] = LR[i][j].y[r].e_vdW; @@ -511,20 +509,20 @@ int PairReaxCKokkos::Init_Lookup_Tables() vlast_vdw = fCEvd[r-1]; vlast_ele = fele[r-1]; - Natural_Cubic_Spline( control->error_ptr, &h[1], &fh[1], - &(LR[i][j].H[1]), control->tabulate+1 ); + Natural_Cubic_Spline(api->control->error_ptr, &h[1], &fh[1], + &(LR[i][j].H[1]), api->control->tabulate+1); - Complete_Cubic_Spline( control->error_ptr, &h[1], &fvdw[1], v0_vdw, vlast_vdw, - &(LR[i][j].vdW[1]), control->tabulate+1 ); + Complete_Cubic_Spline(api->control->error_ptr, &h[1], &fvdw[1], v0_vdw, vlast_vdw, + &(LR[i][j].vdW[1]), api->control->tabulate+1); - Natural_Cubic_Spline( control->error_ptr, &h[1], &fCEvd[1], - &(LR[i][j].CEvd[1]), control->tabulate+1 ); + Natural_Cubic_Spline(api->control->error_ptr, &h[1], &fCEvd[1], + &(LR[i][j].CEvd[1]), api->control->tabulate+1); - Complete_Cubic_Spline( control->error_ptr, &h[1], &fele[1], v0_ele, vlast_ele, - &(LR[i][j].ele[1]), control->tabulate+1 ); + Complete_Cubic_Spline(api->control->error_ptr, &h[1], &fele[1], v0_ele, vlast_ele, + &(LR[i][j].ele[1]), api->control->tabulate+1); - Natural_Cubic_Spline( control->error_ptr, &h[1], &fCEclmb[1], - &(LR[i][j].CEclmb[1]), control->tabulate+1 ); + Natural_Cubic_Spline(api->control->error_ptr, &h[1], &fCEclmb[1], + &(LR[i][j].CEclmb[1]), api->control->tabulate+1); } } free(h); @@ -540,11 +538,11 @@ int PairReaxCKokkos::Init_Lookup_Tables() /* ---------------------------------------------------------------------- */ template -void PairReaxCKokkos::Deallocate_Lookup_Tables() +void PairReaxFFKokkos::Deallocate_Lookup_Tables() { int i, j; int ntypes; - LR_lookup_table ** & LR = system->LR; + LR_lookup_table ** & LR = api->system->LR; ntypes = atom->ntypes; @@ -553,25 +551,25 @@ void PairReaxCKokkos::Deallocate_Lookup_Tables() for (j = i; j <= ntypes; ++j) { if (map[i] == -1) continue; if (LR[i][j].n) { - sfree( control->error_ptr, LR[i][j].y, "LR[i,j].y" ); - sfree( control->error_ptr, LR[i][j].H, "LR[i,j].H" ); - sfree( control->error_ptr, LR[i][j].vdW, "LR[i,j].vdW" ); - sfree( control->error_ptr, LR[i][j].CEvd, "LR[i,j].CEvd" ); - sfree( control->error_ptr, LR[i][j].ele, "LR[i,j].ele" ); - sfree( control->error_ptr, LR[i][j].CEclmb, "LR[i,j].CEclmb" ); + sfree(api->control->error_ptr, LR[i][j].y, "LR[i,j].y"); + sfree(api->control->error_ptr, LR[i][j].H, "LR[i,j].H"); + sfree(api->control->error_ptr, LR[i][j].vdW, "LR[i,j].vdW"); + sfree(api->control->error_ptr, LR[i][j].CEvd, "LR[i,j].CEvd"); + sfree(api->control->error_ptr, LR[i][j].ele, "LR[i,j].ele"); + sfree(api->control->error_ptr, LR[i][j].CEclmb, "LR[i,j].CEclmb"); } } - sfree( control->error_ptr, LR[i], "LR[i]" ); + sfree(api->control->error_ptr, LR[i], "LR[i]"); } - sfree( control->error_ptr, LR, "LR" ); + sfree(api->control->error_ptr, LR, "LR"); } /* ---------------------------------------------------------------------- */ template -void PairReaxCKokkos::LR_vdW_Coulomb( int i, int j, double r_ij, LR_data *lr ) +void PairReaxFFKokkos::LR_vdW_Coulomb(int i, int j, double r_ij, LR_data *lr) { - double p_vdW1 = system->reax_param.gp.l[28]; + double p_vdW1 = api->system->reax_param.gp.l[28]; double p_vdW1i = 1.0 / p_vdW1; double powr_vdW1, powgi_vdW1; double tmp, fn13, exp1, exp2; @@ -581,7 +579,7 @@ void PairReaxCKokkos::LR_vdW_Coulomb( int i, int j, double r_ij, LR_ double e_lg, de_lg, r_ij5, r_ij6, re6; two_body_parameters *twbp; - twbp = &(system->reax_param.tbp[map[i]][map[j]]); + twbp = &(api->system->reax_param.tbp[map[i]][map[j]]); e_core = 0; de_core = 0; e_lg = de_lg = 0.0; @@ -603,32 +601,32 @@ void PairReaxCKokkos::LR_vdW_Coulomb( int i, int j, double r_ij, LR_ dTap += k_tap.h_view[1]/r_ij; /*vdWaals Calculations*/ - if (system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) + if (api->system->reax_param.gp.vdw_type==1 || api->system->reax_param.gp.vdw_type==3) { // shielding powr_vdW1 = pow(r_ij, p_vdW1); - powgi_vdW1 = pow( 1.0 / twbp->gamma_w, p_vdW1); + powgi_vdW1 = pow(1.0 / twbp->gamma_w, p_vdW1); - fn13 = pow( powr_vdW1 + powgi_vdW1, p_vdW1i ); - exp1 = exp( twbp->alpha * (1.0 - fn13 / twbp->r_vdW) ); - exp2 = exp( 0.5 * twbp->alpha * (1.0 - fn13 / twbp->r_vdW) ); + fn13 = pow(powr_vdW1 + powgi_vdW1, p_vdW1i); + exp1 = exp(twbp->alpha * (1.0 - fn13 / twbp->r_vdW)); + exp2 = exp(0.5 * twbp->alpha * (1.0 - fn13 / twbp->r_vdW)); lr->e_vdW = Tap * twbp->D * (exp1 - 2.0 * exp2); - dfn13 = pow( powr_vdW1 + powgi_vdW1, p_vdW1i-1.0) * pow(r_ij, p_vdW1-2.0); + dfn13 = pow(powr_vdW1 + powgi_vdW1, p_vdW1i-1.0) * pow(r_ij, p_vdW1-2.0); lr->CEvd = dTap * twbp->D * (exp1 - 2.0 * exp2) - Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) * dfn13; } else { // no shielding - exp1 = exp( twbp->alpha * (1.0 - r_ij / twbp->r_vdW) ); - exp2 = exp( 0.5 * twbp->alpha * (1.0 - r_ij / twbp->r_vdW) ); + exp1 = exp(twbp->alpha * (1.0 - r_ij / twbp->r_vdW)); + exp2 = exp(0.5 * twbp->alpha * (1.0 - r_ij / twbp->r_vdW)); lr->e_vdW = Tap * twbp->D * (exp1 - 2.0 * exp2); lr->CEvd = dTap * twbp->D * (exp1 - 2.0 * exp2) - Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; } - if (system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) + if (api->system->reax_param.gp.vdw_type==2 || api->system->reax_param.gp.vdw_type==3) { // inner wall e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); lr->e_vdW += Tap * e_core; @@ -637,14 +635,14 @@ void PairReaxCKokkos::LR_vdW_Coulomb( int i, int j, double r_ij, LR_ lr->CEvd += dTap * e_core + Tap * de_core / r_ij; // lg correction, only if lgvdw is yes - if (control->lgflag) { - r_ij5 = powint( r_ij, 5 ); - r_ij6 = powint( r_ij, 6 ); - re6 = powint( twbp->lgre, 6 ); - e_lg = -(twbp->lgcij/( r_ij6 + re6 )); + if (api->control->lgflag) { + r_ij5 = powint(r_ij, 5); + r_ij6 = powint(r_ij, 6); + re6 = powint(twbp->lgre, 6); + e_lg = -(twbp->lgcij/(r_ij6 + re6)); lr->e_vdW += Tap * e_lg; - de_lg = -6.0 * e_lg * r_ij5 / ( r_ij6 + re6 ) ; + de_lg = -6.0 * e_lg * r_ij5 / (r_ij6 + re6) ; lr->CEvd += dTap * e_lg + Tap * de_lg/r_ij; } @@ -652,20 +650,20 @@ void PairReaxCKokkos::LR_vdW_Coulomb( int i, int j, double r_ij, LR_ /* Coulomb calculations */ - dr3gamij_1 = ( r_ij * r_ij * r_ij + twbp->gamma ); - dr3gamij_3 = pow( dr3gamij_1 , 0.33333333333333 ); + dr3gamij_1 = (r_ij * r_ij * r_ij + twbp->gamma); + dr3gamij_3 = pow(dr3gamij_1 , 0.33333333333333); tmp = Tap / dr3gamij_3; lr->H = EV_to_KCALpMOL * tmp; lr->e_ele = C_ele * tmp; - lr->CEclmb = C_ele * ( dTap - Tap * r_ij / dr3gamij_1 ) / dr3gamij_3; + lr->CEclmb = C_ele * (dTap - Tap * r_ij / dr3gamij_1) / dr3gamij_3; } /* ---------------------------------------------------------------------- */ template -void PairReaxCKokkos::compute(int eflag_in, int vflag_in) +void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) { copymode = 1; @@ -726,42 +724,42 @@ void PairReaxCKokkos::compute(int eflag_in, int vflag_in) // Polarization (self) if (neighflag == HALF) { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); } else { //if (neighflag == HALFTHREAD) { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); } ev_all += ev; pvector[13] = ev.ecoul; // LJ + Coulomb - if (control->tabulate) { + if (api->control->tabulate) { if (neighflag == HALF) { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); } else if (neighflag == HALFTHREAD) { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); } } else { if (neighflag == HALF) { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); } else if (neighflag == HALFTHREAD) { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); } } ev_all += ev; @@ -855,34 +853,34 @@ void PairReaxCKokkos::compute(int eflag_in, int vflag_in) // Bond energy if (neighflag == HALF) { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); ev_all += ev; pvector[0] = ev.evdwl; } else { //if (neighflag == HALFTHREAD) { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); ev_all += ev; pvector[0] = ev.evdwl; } // Multi-body corrections if (neighflag == HALF) { - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); ev_all += ev; } else { //if (neighflag == HALFTHREAD) { - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); ev_all += ev; } pvector[2] = ev.ereax[0]; @@ -893,15 +891,15 @@ void PairReaxCKokkos::compute(int eflag_in, int vflag_in) // Angular if (neighflag == HALF) { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); ev_all += ev; } else { //if (neighflag == HALFTHREAD) { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); ev_all += ev; } pvector[4] = ev.ereax[3]; @@ -912,15 +910,15 @@ void PairReaxCKokkos::compute(int eflag_in, int vflag_in) // Torsion if (neighflag == HALF) { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); ev_all += ev; } else { //if (neighflag == HALFTHREAD) { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); ev_all += ev; } pvector[8] = ev.ereax[6]; @@ -931,15 +929,15 @@ void PairReaxCKokkos::compute(int eflag_in, int vflag_in) if (cut_hbsq > 0.0) { if (neighflag == HALF) { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); ev_all += ev; } else { //if (neighflag == HALFTHREAD) { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); ev_all += ev; } } @@ -971,9 +969,9 @@ void PairReaxCKokkos::compute(int eflag_in, int vflag_in) //} if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,ignum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,ignum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,ignum),*this); ev_all += ev; pvector[0] += ev.evdwl; } else { //if (neighflag == HALFTHREAD) { @@ -987,9 +985,9 @@ void PairReaxCKokkos::compute(int eflag_in, int vflag_in) //} if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,ignum),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,ignum),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy >(0,ignum),*this); ev_all += ev; pvector[0] += ev.evdwl; } @@ -1051,7 +1049,7 @@ void PairReaxCKokkos::compute(int eflag_in, int vflag_in) template template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputePolar, const int &ii, EV_FLOAT_REAX& ev) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputePolar, const int &ii, EV_FLOAT_REAX& ev) const { const int i = d_ilist[ii]; const int itype = type(i); @@ -1069,9 +1067,9 @@ void PairReaxCKokkos::operator()(PairReaxComputePolar template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputePolar, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputePolar, const int &ii) const { EV_FLOAT_REAX ev; - this->template operator()(PairReaxComputePolar(), ii, ev); + this->template operator()(PairReaxFFComputePolar(), ii, ev); } @@ -1080,7 +1078,7 @@ void PairReaxCKokkos::operator()(PairReaxComputePolar template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeLJCoulomb, const int &ii, EV_FLOAT_REAX& ev) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeLJCoulomb, const int &ii, EV_FLOAT_REAX& ev) const { // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial @@ -1222,9 +1220,9 @@ void PairReaxCKokkos::operator()(PairReaxComputeLJCoulomb template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeLJCoulomb, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeLJCoulomb, const int &ii) const { EV_FLOAT_REAX ev; - this->template operator()(PairReaxComputeLJCoulomb(), ii, ev); + this->template operator()(PairReaxFFComputeLJCoulomb(), ii, ev); } /* ---------------------------------------------------------------------- */ @@ -1232,7 +1230,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeLJCoulomb template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeTabulatedLJCoulomb, const int &ii, EV_FLOAT_REAX& ev) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeTabulatedLJCoulomb, const int &ii, EV_FLOAT_REAX& ev) const { // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial @@ -1279,8 +1277,8 @@ void PairReaxCKokkos::operator()(PairReaxComputeTabulatedLJCoulomb cut_nbsq) continue; const F_FLOAT rij = sqrt(rsq); - const int tmin = MIN( itype, jtype ); - const int tmax = MAX( itype, jtype ); + const int tmin = MIN(itype, jtype); + const int tmax = MAX(itype, jtype); const LR_lookup_table_kk& t = d_LR(tmin,tmax); @@ -1329,84 +1327,84 @@ void PairReaxCKokkos::operator()(PairReaxComputeTabulatedLJCoulomb template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeTabulatedLJCoulomb, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeTabulatedLJCoulomb, const int &ii) const { EV_FLOAT_REAX ev; - this->template operator()(PairReaxComputeTabulatedLJCoulomb(), ii, ev); + this->template operator()(PairReaxFFComputeTabulatedLJCoulomb(), ii, ev); } /* ---------------------------------------------------------------------- */ template -void PairReaxCKokkos::allocate_array() +void PairReaxFFKokkos::allocate_array() { if (cut_hbsq > 0.0) { - d_hb_first = typename AT::t_int_1d("reax/c/kk:hb_first",nmax); - d_hb_num = typename AT::t_int_1d("reax/c/kk:hb_num",nmax); - d_hb_list = typename AT::t_int_1d("reax/c/kk:hb_list",nmax*maxhb); + d_hb_first = typename AT::t_int_1d("reaxff/kk:hb_first",nmax); + d_hb_num = typename AT::t_int_1d("reaxff/kk:hb_num",nmax); + d_hb_list = typename AT::t_int_1d("reaxff/kk:hb_list",nmax*maxhb); } - d_bo_first = typename AT::t_int_1d("reax/c/kk:bo_first",nmax); - d_bo_num = typename AT::t_int_1d("reax/c/kk:bo_num",nmax); - d_bo_list = typename AT::t_int_1d("reax/c/kk:bo_list",nmax*maxbo); + d_bo_first = typename AT::t_int_1d("reaxff/kk:bo_first",nmax); + d_bo_num = typename AT::t_int_1d("reaxff/kk:bo_num",nmax); + d_bo_list = typename AT::t_int_1d("reaxff/kk:bo_list",nmax*maxbo); - d_BO = typename AT::t_ffloat_2d_dl("reax/c/kk:BO",nmax,maxbo); - d_BO_s = typename AT::t_ffloat_2d_dl("reax/c/kk:BO",nmax,maxbo); - d_BO_pi = typename AT::t_ffloat_2d_dl("reax/c/kk:BO_pi",nmax,maxbo); - d_BO_pi2 = typename AT::t_ffloat_2d_dl("reax/c/kk:BO_pi2",nmax,maxbo); + d_BO = typename AT::t_ffloat_2d_dl("reaxff/kk:BO",nmax,maxbo); + d_BO_s = typename AT::t_ffloat_2d_dl("reaxff/kk:BO",nmax,maxbo); + d_BO_pi = typename AT::t_ffloat_2d_dl("reaxff/kk:BO_pi",nmax,maxbo); + d_BO_pi2 = typename AT::t_ffloat_2d_dl("reaxff/kk:BO_pi2",nmax,maxbo); - d_dln_BOp_pix = typename AT::t_ffloat_2d_dl("reax/c/kk:d_dln_BOp_pix",nmax,maxbo); - d_dln_BOp_piy = typename AT::t_ffloat_2d_dl("reax/c/kk:d_dln_BOp_piy",nmax,maxbo); - d_dln_BOp_piz = typename AT::t_ffloat_2d_dl("reax/c/kk:d_dln_BOp_piz",nmax,maxbo); + d_dln_BOp_pix = typename AT::t_ffloat_2d_dl("reaxff/kk:d_dln_BOp_pix",nmax,maxbo); + d_dln_BOp_piy = typename AT::t_ffloat_2d_dl("reaxff/kk:d_dln_BOp_piy",nmax,maxbo); + d_dln_BOp_piz = typename AT::t_ffloat_2d_dl("reaxff/kk:d_dln_BOp_piz",nmax,maxbo); - d_dln_BOp_pi2x = typename AT::t_ffloat_2d_dl("reax/c/kk:d_dln_BOp_pi2x",nmax,maxbo); - d_dln_BOp_pi2y = typename AT::t_ffloat_2d_dl("reax/c/kk:d_dln_BOp_pi2y",nmax,maxbo); - d_dln_BOp_pi2z = typename AT::t_ffloat_2d_dl("reax/c/kk:d_dln_BOp_pi2z",nmax,maxbo); + d_dln_BOp_pi2x = typename AT::t_ffloat_2d_dl("reaxff/kk:d_dln_BOp_pi2x",nmax,maxbo); + d_dln_BOp_pi2y = typename AT::t_ffloat_2d_dl("reaxff/kk:d_dln_BOp_pi2y",nmax,maxbo); + d_dln_BOp_pi2z = typename AT::t_ffloat_2d_dl("reaxff/kk:d_dln_BOp_pi2z",nmax,maxbo); - d_C1dbo = typename AT::t_ffloat_2d_dl("reax/c/kk:d_C1dbo",nmax,maxbo); - d_C2dbo = typename AT::t_ffloat_2d_dl("reax/c/kk:d_C2dbo",nmax,maxbo); - d_C3dbo = typename AT::t_ffloat_2d_dl("reax/c/kk:d_C3dbo",nmax,maxbo); + d_C1dbo = typename AT::t_ffloat_2d_dl("reaxff/kk:d_C1dbo",nmax,maxbo); + d_C2dbo = typename AT::t_ffloat_2d_dl("reaxff/kk:d_C2dbo",nmax,maxbo); + d_C3dbo = typename AT::t_ffloat_2d_dl("reaxff/kk:d_C3dbo",nmax,maxbo); - d_C1dbopi = typename AT::t_ffloat_2d_dl("reax/c/kk:d_C1dbopi",nmax,maxbo); - d_C2dbopi = typename AT::t_ffloat_2d_dl("reax/c/kk:d_C2dbopi",nmax,maxbo); - d_C3dbopi = typename AT::t_ffloat_2d_dl("reax/c/kk:d_C3dbopi",nmax,maxbo); - d_C4dbopi = typename AT::t_ffloat_2d_dl("reax/c/kk:d_C4dbopi",nmax,maxbo); + d_C1dbopi = typename AT::t_ffloat_2d_dl("reaxff/kk:d_C1dbopi",nmax,maxbo); + d_C2dbopi = typename AT::t_ffloat_2d_dl("reaxff/kk:d_C2dbopi",nmax,maxbo); + d_C3dbopi = typename AT::t_ffloat_2d_dl("reaxff/kk:d_C3dbopi",nmax,maxbo); + d_C4dbopi = typename AT::t_ffloat_2d_dl("reaxff/kk:d_C4dbopi",nmax,maxbo); - d_C1dbopi2 = typename AT::t_ffloat_2d_dl("reax/c/kk:d_C1dbopi2",nmax,maxbo); - d_C2dbopi2 = typename AT::t_ffloat_2d_dl("reax/c/kk:d_C2dbopi2",nmax,maxbo); - d_C3dbopi2 = typename AT::t_ffloat_2d_dl("reax/c/kk:d_C3dbopi2",nmax,maxbo); - d_C4dbopi2 = typename AT::t_ffloat_2d_dl("reax/c/kk:d_C4dbopi2",nmax,maxbo); + d_C1dbopi2 = typename AT::t_ffloat_2d_dl("reaxff/kk:d_C1dbopi2",nmax,maxbo); + d_C2dbopi2 = typename AT::t_ffloat_2d_dl("reaxff/kk:d_C2dbopi2",nmax,maxbo); + d_C3dbopi2 = typename AT::t_ffloat_2d_dl("reaxff/kk:d_C3dbopi2",nmax,maxbo); + d_C4dbopi2 = typename AT::t_ffloat_2d_dl("reaxff/kk:d_C4dbopi2",nmax,maxbo); - d_dBOpx = typename AT::t_ffloat_2d_dl("reax/c/kk:dBOpx",nmax,maxbo); - d_dBOpy = typename AT::t_ffloat_2d_dl("reax/c/kk:dBOpy",nmax,maxbo); - d_dBOpz = typename AT::t_ffloat_2d_dl("reax/c/kk:dBOpz",nmax,maxbo); + d_dBOpx = typename AT::t_ffloat_2d_dl("reaxff/kk:dBOpx",nmax,maxbo); + d_dBOpy = typename AT::t_ffloat_2d_dl("reaxff/kk:dBOpy",nmax,maxbo); + d_dBOpz = typename AT::t_ffloat_2d_dl("reaxff/kk:dBOpz",nmax,maxbo); - d_dDeltap_self = typename AT::t_ffloat_2d_dl("reax/c/kk:dDeltap_self",nmax,3); - d_Deltap_boc = typename AT::t_ffloat_1d("reax/c/kk:Deltap_boc",nmax); - d_Deltap = typename AT::t_ffloat_1d("reax/c/kk:Deltap",nmax); - d_total_bo = typename AT::t_ffloat_1d("reax/c/kk:total_bo",nmax); + d_dDeltap_self = typename AT::t_ffloat_2d_dl("reaxff/kk:dDeltap_self",nmax,3); + d_Deltap_boc = typename AT::t_ffloat_1d("reaxff/kk:Deltap_boc",nmax); + d_Deltap = typename AT::t_ffloat_1d("reaxff/kk:Deltap",nmax); + d_total_bo = typename AT::t_ffloat_1d("reaxff/kk:total_bo",nmax); - d_Cdbo = typename AT::t_ffloat_2d_dl("reax/c/kk:Cdbo",nmax,3*maxbo); - d_Cdbopi = typename AT::t_ffloat_2d_dl("reax/c/kk:Cdbopi",nmax,3*maxbo); - d_Cdbopi2 = typename AT::t_ffloat_2d_dl("reax/c/kk:Cdbopi2",nmax,3*maxbo); + d_Cdbo = typename AT::t_ffloat_2d_dl("reaxff/kk:Cdbo",nmax,3*maxbo); + d_Cdbopi = typename AT::t_ffloat_2d_dl("reaxff/kk:Cdbopi",nmax,3*maxbo); + d_Cdbopi2 = typename AT::t_ffloat_2d_dl("reaxff/kk:Cdbopi2",nmax,3*maxbo); - d_Delta = typename AT::t_ffloat_1d("reax/c/kk:Delta",nmax); - d_Delta_boc = typename AT::t_ffloat_1d("reax/c/kk:Delta_boc",nmax); - d_dDelta_lp = typename AT::t_ffloat_1d("reax/c/kk:dDelta_lp",nmax); - d_Delta_lp = typename AT::t_ffloat_1d("reax/c/kk:Delta_lp",nmax); - d_Delta_lp_temp = typename AT::t_ffloat_1d("reax/c/kk:Delta_lp_temp",nmax); - d_CdDelta = typename AT::t_ffloat_1d("reax/c/kk:CdDelta",nmax); - d_sum_ovun = typename AT::t_ffloat_2d_dl("reax/c/kk:sum_ovun",nmax,3); + d_Delta = typename AT::t_ffloat_1d("reaxff/kk:Delta",nmax); + d_Delta_boc = typename AT::t_ffloat_1d("reaxff/kk:Delta_boc",nmax); + d_dDelta_lp = typename AT::t_ffloat_1d("reaxff/kk:dDelta_lp",nmax); + d_Delta_lp = typename AT::t_ffloat_1d("reaxff/kk:Delta_lp",nmax); + d_Delta_lp_temp = typename AT::t_ffloat_1d("reaxff/kk:Delta_lp_temp",nmax); + d_CdDelta = typename AT::t_ffloat_1d("reaxff/kk:CdDelta",nmax); + d_sum_ovun = typename AT::t_ffloat_2d_dl("reaxff/kk:sum_ovun",nmax,3); - // FixReaxCBonds - d_abo = typename AT::t_ffloat_2d("reax/c/kk:abo",nmax,maxbo); - d_neighid = typename AT::t_tagint_2d("reax/c/kk:neighid",nmax,maxbo); - d_numneigh_bonds = typename AT::t_int_1d("reax/c/kk:numneigh_bonds",nmax); + // FixReaxFFBonds + d_abo = typename AT::t_ffloat_2d("reaxff/kk:abo",nmax,maxbo); + d_neighid = typename AT::t_tagint_2d("reaxff/kk:neighid",nmax,maxbo); + d_numneigh_bonds = typename AT::t_int_1d("reaxff/kk:numneigh_bonds",nmax); } /* ---------------------------------------------------------------------- */ template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxZero, const int &n) const { +void PairReaxFFKokkos::operator()(PairReaxZero, const int &n) const { d_total_bo(n) = 0.0; d_CdDelta(n) = 0.0; d_bo_num(n) = 0.0; @@ -1417,13 +1415,13 @@ void PairReaxCKokkos::operator()(PairReaxZero, const int &n) const { template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxZeroEAtom, const int &i) const { +void PairReaxFFKokkos::operator()(PairReaxZeroEAtom, const int &i) const { d_eatom(i) = 0.0; } template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxZeroVAtom, const int &i) const { +void PairReaxFFKokkos::operator()(PairReaxZeroVAtom, const int &i) const { d_vatom(i,0) = 0.0; d_vatom(i,1) = 0.0; d_vatom(i,2) = 0.0; @@ -1436,7 +1434,7 @@ void PairReaxCKokkos::operator()(PairReaxZeroVAtom, const int &i) co template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxBuildListsFull, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxBuildListsFull, const int &ii) const { if (d_resize_bo() || d_resize_hb()) return; @@ -1594,7 +1592,7 @@ void PairReaxCKokkos::operator()(PairReaxBuildListsFull, const int & template template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxBuildListsHalf, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxBuildListsHalf, const int &ii) const { if (d_resize_bo() || d_resize_hb()) return; @@ -1668,7 +1666,7 @@ void PairReaxCKokkos::operator()(PairReaxBuildListsHalf, } d_hb_list[j_index] = j; - } else if ( j < nlocal && ihb == 2 && jhb == 1) { + } else if (j < nlocal && ihb == 2 && jhb == 1) { if (NEIGHFLAG == HALF) { i_index = d_hb_first[j] + d_hb_num[j]; d_hb_num[j]++; @@ -1807,7 +1805,7 @@ void PairReaxCKokkos::operator()(PairReaxBuildListsHalf, template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxBondOrder1, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxBondOrder1, const int &ii) const { const int i = d_ilist[ii]; const int itype = type(i); @@ -1821,7 +1819,7 @@ void PairReaxCKokkos::operator()(PairReaxBondOrder1, const int &ii) template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxBondOrder2, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxBondOrder2, const int &ii) const { F_FLOAT exp_p1i, exp_p2i, exp_p1j, exp_p2j, f1, f2, f3, u1_ij, u1_ji, Cf1A_ij, Cf1B_ij, Cf1_ij, Cf1_ji; F_FLOAT f4, f5, exp_f4, exp_f5, f4f5, Cf45_ij, Cf45_ji; @@ -1883,7 +1881,7 @@ void PairReaxCKokkos::operator()(PairReaxBondOrder2, const int &ii) (-p_boc1 * exp_p1i + exp_p2i / (exp_p2i + exp_p2j)) + -p_boc1 * exp_p1i / u1_ji - ((val_j+f2) / (u1_ji*u1_ji)) * (-p_boc1 * exp_p1i + exp_p2i / (exp_p2i + exp_p2j))); - Cf1_ji = -Cf1A_ij * p_boc1 * exp_p1j + Cf1B_ij * exp_p2j / ( exp_p2i + exp_p2j ); + Cf1_ji = -Cf1A_ij * p_boc1 * exp_p1j + Cf1B_ij * exp_p2j / (exp_p2i + exp_p2j); } else { f1 = 1.0; Cf1_ij = Cf1_ji = 0.0; @@ -1955,7 +1953,7 @@ void PairReaxCKokkos::operator()(PairReaxBondOrder2, const int &ii) template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxBondOrder3, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxBondOrder3, const int &ii) const { // bot part of BO() const int i = d_ilist[ii]; @@ -1991,7 +1989,7 @@ void PairReaxCKokkos::operator()(PairReaxBondOrder3, const int &ii) template template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeMulti1, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeMulti1, const int &ii) const { const int i = d_ilist[ii]; const int itype = type(i); @@ -2025,7 +2023,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeMulti1 template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeMulti2, const int &ii, EV_FLOAT_REAX& ev) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeMulti2, const int &ii, EV_FLOAT_REAX& ev) const { auto v_CdDelta = ScatterViewHelper::value,decltype(dup_CdDelta),decltype(ndup_CdDelta)>::get(dup_CdDelta,ndup_CdDelta); auto a_CdDelta = v_CdDelta.template access::value>(); @@ -2053,7 +2051,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeMulti2::operator()(PairReaxComputeMulti2template e_tally(ev,i,i,e_lp); // over coordination - const F_FLOAT exp_ovun1 = p_ovun3 * exp( p_ovun4 * d_sum_ovun(i,2) ); + const F_FLOAT exp_ovun1 = p_ovun3 * exp(p_ovun4 * d_sum_ovun(i,2)); const F_FLOAT inv_exp_ovun1 = 1.0 / (1 + exp_ovun1); const F_FLOAT Delta_lpcorr = d_Delta[i] - (dfvl * d_Delta_lp_temp[i]) * inv_exp_ovun1; - const F_FLOAT exp_ovun2 = exp( p_ovun2 * Delta_lpcorr ); + const F_FLOAT exp_ovun2 = exp(p_ovun2 * Delta_lpcorr); const F_FLOAT inv_exp_ovun2 = 1.0 / (1.0 + exp_ovun2); const F_FLOAT DlpVi = 1.0 / (Delta_lpcorr + val_i + 1e-8); @@ -2088,14 +2086,14 @@ void PairReaxCKokkos::operator()(PairReaxComputeMulti2template e_tally(ev,i,i,e_ov); CEover2 = d_sum_ovun(i,1) * DlpVi * inv_exp_ovun2 * - (1.0 - Delta_lpcorr * ( DlpVi + p_ovun2 * exp_ovun2 * inv_exp_ovun2 )); - CEover3 = CEover2 * (1.0 - dfvl * d_dDelta_lp[i] * inv_exp_ovun1 ); + (1.0 - Delta_lpcorr * (DlpVi + p_ovun2 * exp_ovun2 * inv_exp_ovun2)); + CEover3 = CEover2 * (1.0 - dfvl * d_dDelta_lp[i] * inv_exp_ovun1); CEover4 = CEover2 * (dfvl * d_Delta_lp_temp[i]) * p_ovun4 * exp_ovun1 * SQR(inv_exp_ovun1); // under coordination const F_FLOAT exp_ovun2n = 1.0 / exp_ovun2; - const F_FLOAT exp_ovun6 = exp( p_ovun6 * Delta_lpcorr ); + const F_FLOAT exp_ovun6 = exp(p_ovun6 * Delta_lpcorr); const F_FLOAT exp_ovun8 = p_ovun7 * exp(p_ovun8 * d_sum_ovun(i,2)); const F_FLOAT inv_exp_ovun2n = 1.0 / (1.0 + exp_ovun2n); const F_FLOAT inv_exp_ovun8 = 1.0 / (1.0 + exp_ovun8); @@ -2109,7 +2107,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeMulti2template e_tally(ev,i,i,e_un); CEunder1 = inv_exp_ovun2n * - ( p_ovun5 * p_ovun6 * exp_ovun6 * inv_exp_ovun8 + p_ovun2 * e_un * exp_ovun2n ); + (p_ovun5 * p_ovun6 * exp_ovun6 * inv_exp_ovun8 + p_ovun2 * e_un * exp_ovun2n); CEunder2 = -e_un * p_ovun8 * exp_ovun8 * inv_exp_ovun8; CEunder3 = CEunder1 * (1.0 - dfvl * d_dDelta_lp[i] * inv_exp_ovun1); CEunder4 = CEunder1 * (dfvl * d_Delta_lp_temp[i]) * @@ -2166,9 +2164,9 @@ void PairReaxCKokkos::operator()(PairReaxComputeMulti2 template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeMulti2, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeMulti2, const int &ii) const { EV_FLOAT_REAX ev; - this->template operator()(PairReaxComputeMulti2(), ii, ev); + this->template operator()(PairReaxFFComputeMulti2(), ii, ev); } @@ -2177,7 +2175,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeMulti2 template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeAngular, const int &ii, EV_FLOAT_REAX& ev) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeAngular, const int &ii, EV_FLOAT_REAX& ev) const { auto v_f = ScatterViewHelper::value,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access::value>(); @@ -2245,7 +2243,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeAngular::operator()(PairReaxComputeAngular 0.0 && SBO <= 1.0) { - SBO2 = pow( SBO, p_val9 ); - CSBO2 = p_val9 * pow( SBO, p_val9 - 1.0 ); + SBO2 = pow(SBO, p_val9); + CSBO2 = p_val9 * pow(SBO, p_val9 - 1.0); } else if (SBO > 1.0 && SBO < 2.0) { - SBO2 = 2.0 - pow( 2.0-SBO, p_val9 ); - CSBO2 = p_val9 * pow( 2.0 - SBO, p_val9 - 1.0 ); + SBO2 = 2.0 - pow(2.0-SBO, p_val9); + CSBO2 = p_val9 * pow(2.0 - SBO, p_val9 - 1.0); } else { SBO2 = 2.0; CSBO2 = 0.0; } - expval6 = exp( p_val6 * d_Delta_boc[i] ); + expval6 = exp(p_val6 * d_Delta_boc[i]); F_FLOAT CdDelta_i = 0.0; F_FLOAT fitmp[3],fjtmp[3]; @@ -2352,21 +2350,21 @@ void PairReaxCKokkos::operator()(PairReaxComputeAngular= 0) expval12theta = p_val1 * (1.0 - expval2theta); else // To avoid linear Me-H-Me angles (6/6/06) @@ -2376,7 +2374,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeAngular::operator()(PairReaxComputeAngular::operator()(PairReaxComputeAngular::operator()(PairReaxComputeAngular template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeAngular, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeAngular, const int &ii) const { EV_FLOAT_REAX ev; - this->template operator()(PairReaxComputeAngular(), ii, ev); + this->template operator()(PairReaxFFComputeAngular(), ii, ev); } @@ -2489,7 +2487,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeAngular template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeTorsion, const int &ii, EV_FLOAT_REAX& ev) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeTorsion, const int &ii, EV_FLOAT_REAX& ev) const { auto v_f = ScatterViewHelper::value,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access::value>(); @@ -2499,7 +2497,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeTorsion::value,Kokkos::MemoryTraits::value> > a_Cdbo = d_Cdbo; //auto a_Cdbo = dup_Cdbo.template access::value>(); - // in reaxc_torsion_angles: j = i, k = j, i = k; + // in reaxff_torsion_angles: j = i, k = j, i = k; F_FLOAT Delta_i, Delta_j, bo_ij, bo_ik, bo_jl, BOA_ij, BOA_ik, BOA_jl; F_FLOAT p_tor1, p_cot1, V1, V2, V3; @@ -2566,10 +2564,10 @@ void PairReaxCKokkos::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion= 0 && sin_ijk <= 1e-10) tan_ijk_i = cos_ijk / 1e-10; else if (sin_ijk <= 0 && sin_ijk >= -1e-10) tan_ijk_i = -cos_ijk / 1e-10; else tan_ijk_i = cos_ijk / sin_ijk; - exp_tor2_ik = exp( -p_tor2 * BOA_ik ); - exp_cot2_ik = exp( -p_cot2 * SQR(BOA_ik -1.5) ); + exp_tor2_ik = exp(-p_tor2 * BOA_ik); + exp_cot2_ik = exp(-p_cot2 * SQR(BOA_ik -1.5)); for (int l = 0; l < 3; l++) fktmp[l] = 0.0; @@ -2651,7 +2649,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeTorsion= 0 && sin_jil <= 1e-10) tan_jil_i = cos_jil / 1e-10; else if (sin_jil <= 0 && sin_jil >= -1e-10) @@ -2679,13 +2677,13 @@ void PairReaxCKokkos::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeTorsion, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeTorsion, const int &ii) const { EV_FLOAT_REAX ev; - this->template operator()(PairReaxComputeTorsion(), ii, ev); + this->template operator()(PairReaxFFComputeTorsion(), ii, ev); } @@ -2864,7 +2862,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeTorsion template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeHydrogen, const int &ii, EV_FLOAT_REAX& ev) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeHydrogen, const int &ii, EV_FLOAT_REAX& ev) const { auto v_f = ScatterViewHelper::value,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access::value>(); @@ -3000,9 +2998,9 @@ void PairReaxCKokkos::operator()(PairReaxComputeHydrogen template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeHydrogen, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeHydrogen, const int &ii) const { EV_FLOAT_REAX ev; - this->template operator()(PairReaxComputeHydrogen(), ii, ev); + this->template operator()(PairReaxFFComputeHydrogen(), ii, ev); } @@ -3011,7 +3009,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeHydrogen template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxUpdateBond, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxUpdateBond, const int &ii) const { Kokkos::View::value,Kokkos::MemoryTraits::value> > a_Cdbo = d_Cdbo; Kokkos::View::value,Kokkos::MemoryTraits::value> > a_Cdbopi = d_Cdbopi; @@ -3063,10 +3061,9 @@ void PairReaxCKokkos::operator()(PairReaxUpdateBond, cons template template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeBond1, const int &ii, EV_FLOAT_REAX& ev) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeBond1, const int &ii, EV_FLOAT_REAX& ev) const { auto v_f = ScatterViewHelper::value,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); - auto a_f = v_f.template access::value>(); auto v_CdDelta = ScatterViewHelper::value,decltype(dup_CdDelta),decltype(ndup_CdDelta)>::get(dup_CdDelta,ndup_CdDelta); auto a_CdDelta = v_CdDelta.template access::value>(); @@ -3139,7 +3136,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeBond1= 1.00) { if (gp[37] == 2 || (imass == 12.0000 && jmass == 15.9990) || (jmass == 12.0000 && imass == 15.9990)) { - const F_FLOAT exphu = exp(-gp[7] * SQR(BO_i - 2.50) ); + const F_FLOAT exphu = exp(-gp[7] * SQR(BO_i - 2.50)); const F_FLOAT exphua1 = exp(-gp[3] * (d_total_bo[i]-BO_i)); const F_FLOAT exphub1 = exp(-gp[3] * (d_total_bo[j]-BO_i)); const F_FLOAT exphuov = exp(gp[4] * (d_Delta[i] + d_Delta[j])); @@ -3151,7 +3148,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeBond1template e_tally(ev,i,j,estriph); const F_FLOAT decobdbo = gp[10] * exphu * hulpov * (exphua1 + exphub1) * - ( gp[3] - 2.0 * gp[7] * (BO_i-2.50) ); + (gp[3] - 2.0 * gp[7] * (BO_i-2.50)); const F_FLOAT decobdboua = -gp[10] * exphu * hulpov * (gp[3]*exphua1 + 25.0*gp[4]*exphuov*hulpov*(exphua1+exphub1)); const F_FLOAT decobdboub = -gp[10] * exphu * hulpov * @@ -3171,9 +3168,9 @@ void PairReaxCKokkos::operator()(PairReaxComputeBond1 template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeBond1, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeBond1, const int &ii) const { EV_FLOAT_REAX ev; - this->template operator()(PairReaxComputeBond1(), ii, ev); + this->template operator()(PairReaxFFComputeBond1(), ii, ev); } @@ -3182,7 +3179,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeBond1 template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeBond2, const int &ii, EV_FLOAT_REAX& ev) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeBond2, const int &ii, EV_FLOAT_REAX& ev) const { auto v_f = ScatterViewHelper::value,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access::value>(); @@ -3372,9 +3369,9 @@ void PairReaxCKokkos::operator()(PairReaxComputeBond2 template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxComputeBond2, const int &ii) const { +void PairReaxFFKokkos::operator()(PairReaxFFComputeBond2, const int &ii) const { EV_FLOAT_REAX ev; - this->template operator()(PairReaxComputeBond2(), ii, ev); + this->template operator()(PairReaxFFComputeBond2(), ii, ev); } @@ -3383,7 +3380,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeBond2 template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::ev_tally(EV_FLOAT_REAX &ev, const int &i, const int &j, +void PairReaxFFKokkos::ev_tally(EV_FLOAT_REAX &ev, const int &i, const int &j, const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { @@ -3442,7 +3439,7 @@ void PairReaxCKokkos::ev_tally(EV_FLOAT_REAX &ev, const int &i, cons template template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::e_tally(EV_FLOAT_REAX & /*ev*/, const int &i, const int &j, +void PairReaxFFKokkos::e_tally(EV_FLOAT_REAX & /*ev*/, const int &i, const int &j, const F_FLOAT &epair) const { @@ -3464,7 +3461,7 @@ void PairReaxCKokkos::e_tally(EV_FLOAT_REAX & /*ev*/, const int &i, template template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::e_tally_single(EV_FLOAT_REAX & /*ev*/, const int &i, +void PairReaxFFKokkos::e_tally_single(EV_FLOAT_REAX & /*ev*/, const int &i, const F_FLOAT &epair) const { // The eatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial @@ -3479,7 +3476,7 @@ void PairReaxCKokkos::e_tally_single(EV_FLOAT_REAX & /*ev*/, const i template template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::v_tally(EV_FLOAT_REAX &ev, const int &i, +void PairReaxFFKokkos::v_tally(EV_FLOAT_REAX &ev, const int &i, F_FLOAT *fi, F_FLOAT *drij) const { @@ -3515,7 +3512,7 @@ void PairReaxCKokkos::v_tally(EV_FLOAT_REAX &ev, const int &i, template template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::v_tally3(EV_FLOAT_REAX &ev, const int &i, const int &j, const int &k, +void PairReaxFFKokkos::v_tally3(EV_FLOAT_REAX &ev, const int &i, const int &j, const int &k, F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drij, F_FLOAT *drik) const { @@ -3557,7 +3554,7 @@ void PairReaxCKokkos::v_tally3(EV_FLOAT_REAX &ev, const int &i, cons template template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::v_tally4(EV_FLOAT_REAX &ev, const int &i, const int &j, const int &k, +void PairReaxFFKokkos::v_tally4(EV_FLOAT_REAX &ev, const int &i, const int &j, const int &k, const int &l, F_FLOAT *fi, F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *dril, F_FLOAT *drjl, F_FLOAT *drkl) const { @@ -3601,7 +3598,7 @@ void PairReaxCKokkos::v_tally4(EV_FLOAT_REAX &ev, const int &i, cons template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::v_tally3_atom(EV_FLOAT_REAX &ev, const int &i, const int & /*j*/, +void PairReaxFFKokkos::v_tally3_atom(EV_FLOAT_REAX &ev, const int &i, const int & /*j*/, const int & /*k*/, F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drji, F_FLOAT *drjk) const { @@ -3637,7 +3634,7 @@ void PairReaxCKokkos::v_tally3_atom(EV_FLOAT_REAX &ev, const int &i, ------------------------------------------------------------------------- */ template -void PairReaxCKokkos::ev_setup(int eflag, int vflag, int) +void PairReaxFFKokkos::ev_setup(int eflag, int vflag, int) { int i; @@ -3692,7 +3689,7 @@ void PairReaxCKokkos::ev_setup(int eflag, int vflag, int) /* ---------------------------------------------------------------------- */ template -double PairReaxCKokkos::memory_usage() +double PairReaxFFKokkos::memory_usage() { double bytes = 0.0; @@ -3706,13 +3703,13 @@ double PairReaxCKokkos::memory_usage() bytes += (double)nmax*17*sizeof(F_FLOAT); bytes += (double)maxbo*nmax*34*sizeof(F_FLOAT); - // FixReaxCSpecies + // FixReaxFFSpecies if (fixspecies_flag) { bytes += (double)MAXSPECBOND*nmax*sizeof(tagint); bytes += (double)MAXSPECBOND*nmax*sizeof(F_FLOAT); } - // FixReaxCBonds + // FixReaxFFBonds bytes += (double)maxbo*nmax*sizeof(tagint); bytes += (double)maxbo*nmax*sizeof(F_FLOAT); bytes += (double)nmax*sizeof(int); @@ -3723,12 +3720,12 @@ double PairReaxCKokkos::memory_usage() /* ---------------------------------------------------------------------- */ template -void PairReaxCKokkos::FindBond(int &numbonds) +void PairReaxFFKokkos::FindBond(int &numbonds) { copymode = 1; Kokkos::parallel_for(Kokkos::RangePolicy(0,nmax),*this); - bo_cut_bond = control->bg_cut; + bo_cut_bond = api->control->bg_cut; atomKK->sync(execution_space,TAG_MASK); tag = atomKK->k_tag.view(); @@ -3738,14 +3735,14 @@ void PairReaxCKokkos::FindBond(int &numbonds) d_ilist = k_list->d_ilist; numbonds = 0; - PairReaxCKokkosFindBondFunctor find_bond_functor(this); + PairReaxFFKokkosFindBondFunctor find_bond_functor(this); Kokkos::parallel_reduce(inum,find_bond_functor,numbonds); copymode = 0; } template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxFindBondZero, const int &i) const { +void PairReaxFFKokkos::operator()(PairReaxFindBondZero, const int &i) const { d_numneigh_bonds[i] = 0; for (int j = 0; j < maxbo; j++) { d_neighid(i,j) = 0; @@ -3755,7 +3752,7 @@ void PairReaxCKokkos::operator()(PairReaxFindBondZero, const int &i) template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::calculate_find_bond_item(int ii, int &numbonds) const +void PairReaxFFKokkos::calculate_find_bond_item(int ii, int &numbonds) const { const int i = d_ilist[ii]; int nj = 0; @@ -3782,7 +3779,7 @@ void PairReaxCKokkos::calculate_find_bond_item(int ii, int &numbonds /* ---------------------------------------------------------------------- */ template -void PairReaxCKokkos::PackBondBuffer(DAT::tdual_ffloat_1d k_buf, int &nbuf_local) +void PairReaxFFKokkos::PackBondBuffer(DAT::tdual_ffloat_1d k_buf, int &nbuf_local) { d_buf = k_buf.view(); k_params_sing.template sync(); @@ -3796,7 +3793,7 @@ void PairReaxCKokkos::PackBondBuffer(DAT::tdual_ffloat_1d k_buf, int copymode = 1; nlocal = atomKK->nlocal; - PairReaxCKokkosPackBondBufferFunctor pack_bond_buffer_functor(this); + PairReaxFFKokkosPackBondBufferFunctor pack_bond_buffer_functor(this); Kokkos::parallel_scan(nlocal,pack_bond_buffer_functor); copymode = 0; @@ -3810,7 +3807,7 @@ void PairReaxCKokkos::PackBondBuffer(DAT::tdual_ffloat_1d k_buf, int template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::pack_bond_buffer_item(int i, int &j, const bool &final) const +void PairReaxFFKokkos::pack_bond_buffer_item(int i, int &j, const bool &final) const { if (i == 0) j += 2; @@ -3852,7 +3849,7 @@ void PairReaxCKokkos::pack_bond_buffer_item(int i, int &j, const boo /* ---------------------------------------------------------------------- */ template -void PairReaxCKokkos::FindBondSpecies() +void PairReaxFFKokkos::FindBondSpecies() { if (nmax > (int)k_tmpid.extent(0)) { @@ -3880,12 +3877,12 @@ void PairReaxCKokkos::FindBondSpecies() k_error_flag.sync(); if (k_error_flag.h_view()) - error->all(FLERR,"Increase MAXSPECBOND in reaxc_defs.h"); + error->all(FLERR,"Increase MAXSPECBOND in reaxff_defs.h"); } template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxFindBondSpeciesZero, const int &i) const { +void PairReaxFFKokkos::operator()(PairReaxFindBondSpeciesZero, const int &i) const { for (int j = 0; j < MAXSPECBOND; j++) { k_tmpbo.view()(i,j) = 0.0; k_tmpid.view()(i,j) = 0; @@ -3894,7 +3891,7 @@ void PairReaxCKokkos::operator()(PairReaxFindBondSpeciesZero, const template KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxFindBondSpecies, const int &i) const { +void PairReaxFFKokkos::operator()(PairReaxFindBondSpecies, const int &i) const { int nj = 0; const int j_start = d_bo_first[i]; @@ -3916,8 +3913,8 @@ void PairReaxCKokkos::operator()(PairReaxFindBondSpecies, const int } } -template class PairReaxCKokkos; +template class PairReaxFFKokkos; #ifdef LMP_KOKKOS_GPU -template class PairReaxCKokkos; +template class PairReaxFFKokkos; #endif } diff --git a/src/KOKKOS/pair_reaxc_kokkos.h b/src/KOKKOS/pair_reaxff_kokkos.h similarity index 85% rename from src/KOKKOS/pair_reaxc_kokkos.h rename to src/KOKKOS/pair_reaxff_kokkos.h index 7caa270a80..e60533f61e 100644 --- a/src/KOKKOS/pair_reaxc_kokkos.h +++ b/src/KOKKOS/pair_reaxff_kokkos.h @@ -15,9 +15,12 @@ #ifdef PAIR_CLASS // clang-format off -PairStyle(reax/c/kk,PairReaxCKokkos); -PairStyle(reax/c/kk/device,PairReaxCKokkos); -PairStyle(reax/c/kk/host,PairReaxCKokkos); +PairStyle(reaxff/kk,PairReaxFFKokkos); +PairStyle(reaxff/kk/device,PairReaxFFKokkos); +PairStyle(reaxff/kk/host,PairReaxFFKokkos); +PairStyle(reax/c/kk,PairReaxFFKokkos); +PairStyle(reax/c/kk/device,PairReaxFFKokkos); +PairStyle(reax/c/kk/host,PairReaxFFKokkos); // clang-format on #else @@ -25,9 +28,8 @@ PairStyle(reax/c/kk/host,PairReaxCKokkos); #define LMP_PAIR_REAXC_KOKKOS_H #include "pair_kokkos.h" -#include "pair_reaxc.h" +#include "pair_reaxff.h" #include "neigh_list_kokkos.h" -#include "reaxc_types.h" #define C_ele 332.06371 #define SMALL 0.0001 @@ -37,12 +39,14 @@ PairStyle(reax/c/kk/host,PairReaxCKokkos); #define SQR(x) ((x)*(x)) +#include "reaxff_inline.h" + namespace LAMMPS_NS { template struct LR_lookup_table_kk { - typedef Kokkos::DualView tdual_cubic_spline_coef_1d; + typedef Kokkos::DualView tdual_cubic_spline_coef_1d; typedef typename tdual_cubic_spline_coef_1d::t_dev t_cubic_spline_coef_1d; double dx, inv_dx; @@ -52,13 +56,13 @@ struct LR_lookup_table_kk }; template -struct PairReaxComputePolar{}; +struct PairReaxFFComputePolar{}; template -struct PairReaxComputeLJCoulomb{}; +struct PairReaxFFComputeLJCoulomb{}; template -struct PairReaxComputeTabulatedLJCoulomb{}; +struct PairReaxFFComputeTabulatedLJCoulomb{}; struct PairReaxBuildListsFull{}; @@ -81,25 +85,25 @@ template struct PairReaxUpdateBond{}; template -struct PairReaxComputeBond1{}; +struct PairReaxFFComputeBond1{}; template -struct PairReaxComputeBond2{}; +struct PairReaxFFComputeBond2{}; template -struct PairReaxComputeMulti1{}; +struct PairReaxFFComputeMulti1{}; template -struct PairReaxComputeMulti2{}; +struct PairReaxFFComputeMulti2{}; template -struct PairReaxComputeAngular{}; +struct PairReaxFFComputeAngular{}; template -struct PairReaxComputeTorsion{}; +struct PairReaxFFComputeTorsion{}; template -struct PairReaxComputeHydrogen{}; +struct PairReaxFFComputeHydrogen{}; struct PairReaxFindBondZero{}; @@ -109,7 +113,7 @@ struct PairReaxFindBondSpecies{}; template -class PairReaxCKokkos : public PairReaxC { +class PairReaxFFKokkos : public PairReaxFF { public: enum {EnabledNeighFlags=FULL|HALF|HALFTHREAD}; enum {COUL_FLAG=1}; @@ -117,8 +121,8 @@ class PairReaxCKokkos : public PairReaxC { typedef ArrayTypes AT; typedef EV_FLOAT_REAX value_type; - PairReaxCKokkos(class LAMMPS *); - virtual ~PairReaxCKokkos(); + PairReaxFFKokkos(class LAMMPS *); + virtual ~PairReaxFFKokkos(); void ev_setup(int, int, int alloc = 1); void compute(int, int); @@ -130,27 +134,27 @@ class PairReaxCKokkos : public PairReaxC { template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputePolar, const int&, EV_FLOAT_REAX&) const; + void operator()(PairReaxFFComputePolar, const int&, EV_FLOAT_REAX&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputePolar, const int&) const; + void operator()(PairReaxFFComputePolar, const int&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeLJCoulomb, const int&, EV_FLOAT_REAX&) const; + void operator()(PairReaxFFComputeLJCoulomb, const int&, EV_FLOAT_REAX&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeLJCoulomb, const int&) const; + void operator()(PairReaxFFComputeLJCoulomb, const int&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeTabulatedLJCoulomb, const int&, EV_FLOAT_REAX&) const; + void operator()(PairReaxFFComputeTabulatedLJCoulomb, const int&, EV_FLOAT_REAX&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeTabulatedLJCoulomb, const int&) const; + void operator()(PairReaxFFComputeTabulatedLJCoulomb, const int&) const; KOKKOS_INLINE_FUNCTION void operator()(PairReaxBuildListsFull, const int&) const; @@ -183,55 +187,55 @@ class PairReaxCKokkos : public PairReaxC { template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeBond1, const int&, EV_FLOAT_REAX&) const; + void operator()(PairReaxFFComputeBond1, const int&, EV_FLOAT_REAX&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeBond1, const int&) const; + void operator()(PairReaxFFComputeBond1, const int&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeBond2, const int&, EV_FLOAT_REAX&) const; + void operator()(PairReaxFFComputeBond2, const int&, EV_FLOAT_REAX&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeBond2, const int&) const; + void operator()(PairReaxFFComputeBond2, const int&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeMulti1, const int&) const; + void operator()(PairReaxFFComputeMulti1, const int&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeMulti2, const int&, EV_FLOAT_REAX&) const; + void operator()(PairReaxFFComputeMulti2, const int&, EV_FLOAT_REAX&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeMulti2, const int&) const; + void operator()(PairReaxFFComputeMulti2, const int&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeAngular, const int&, EV_FLOAT_REAX&) const; + void operator()(PairReaxFFComputeAngular, const int&, EV_FLOAT_REAX&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeAngular, const int&) const; + void operator()(PairReaxFFComputeAngular, const int&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeTorsion, const int&, EV_FLOAT_REAX&) const; + void operator()(PairReaxFFComputeTorsion, const int&, EV_FLOAT_REAX&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeTorsion, const int&) const; + void operator()(PairReaxFFComputeTorsion, const int&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeHydrogen, const int&, EV_FLOAT_REAX&) const; + void operator()(PairReaxFFComputeHydrogen, const int&, EV_FLOAT_REAX&) const; template KOKKOS_INLINE_FUNCTION - void operator()(PairReaxComputeHydrogen, const int&) const; + void operator()(PairReaxFFComputeHydrogen, const int&) const; KOKKOS_INLINE_FUNCTION void operator()(PairReaxFindBondZero, const int&) const; @@ -338,7 +342,7 @@ class PairReaxCKokkos : public PairReaxC { void init_md(); int Init_Lookup_Tables(); void Deallocate_Lookup_Tables(); - void LR_vdW_Coulomb( int i, int j, double r_ij, LR_data *lr ); + void LR_vdW_Coulomb(int i, int j, double r_ij, ReaxFF::LR_data *lr); typedef Kokkos::DualView tdual_int_1d; Kokkos::DualView k_params_sing; @@ -432,7 +436,7 @@ class PairReaxCKokkos : public PairReaxC { int vdwflag, lgflag; F_FLOAT gp[39], p_boc1, p_boc2; - friend void pair_virial_fdotr_compute(PairReaxCKokkos*); + friend void pair_virial_fdotr_compute(PairReaxFFKokkos*); int bocnt,hbcnt,enobondsflag; @@ -457,11 +461,11 @@ class PairReaxCKokkos : public PairReaxC { }; template -struct PairReaxCKokkosFindBondFunctor { +struct PairReaxFFKokkosFindBondFunctor { typedef DeviceType device_type; typedef int value_type; - PairReaxCKokkos c; - PairReaxCKokkosFindBondFunctor(PairReaxCKokkos* c_ptr):c(*c_ptr) {}; + PairReaxFFKokkos c; + PairReaxFFKokkosFindBondFunctor(PairReaxFFKokkos* c_ptr):c(*c_ptr) {}; KOKKOS_INLINE_FUNCTION void join(volatile int &dst, @@ -476,11 +480,11 @@ struct PairReaxCKokkosFindBondFunctor { }; template -struct PairReaxCKokkosPackBondBufferFunctor { +struct PairReaxFFKokkosPackBondBufferFunctor { typedef DeviceType device_type; typedef int value_type; - PairReaxCKokkos c; - PairReaxCKokkosPackBondBufferFunctor(PairReaxCKokkos* c_ptr):c(*c_ptr) {}; + PairReaxFFKokkos c; + PairReaxFFKokkosPackBondBufferFunctor(PairReaxFFKokkos* c_ptr):c(*c_ptr) {}; KOKKOS_INLINE_FUNCTION void operator()(const int ii, int &j, const bool &final) const { diff --git a/src/MISC/fix_pair_tracker.cpp b/src/MISC/fix_pair_tracker.cpp index 7939485aff..755025baed 100644 --- a/src/MISC/fix_pair_tracker.cpp +++ b/src/MISC/fix_pair_tracker.cpp @@ -246,7 +246,7 @@ void FixPairTracker::reallocate(int n) double FixPairTracker::memory_usage() { - double bytes = nmax * nvalues * sizeof(double); + double bytes = nmax * (double) nvalues * sizeof(double); bytes += nmax * 2 * sizeof(int); return bytes; } diff --git a/src/ML-IAP/pair_mliap.cpp b/src/ML-IAP/pair_mliap.cpp index 0d2a80635a..64c5a547be 100644 --- a/src/ML-IAP/pair_mliap.cpp +++ b/src/ML-IAP/pair_mliap.cpp @@ -264,8 +264,7 @@ void PairMLIAP::e_tally(MLIAPData* data) add virial contribution into global and per-atom accumulators ------------------------------------------------------------------------- */ -void PairMLIAP::v_tally(int i, int j, - double *fij, double *rij) +void PairMLIAP::v_tally(int i, int j, double *fij, double *rij) { double v[6]; diff --git a/src/ML-RANN/pair_rann.cpp b/src/ML-RANN/pair_rann.cpp index f0d1dec876..73ff747c81 100644 --- a/src/ML-RANN/pair_rann.cpp +++ b/src/ML-RANN/pair_rann.cpp @@ -75,62 +75,131 @@ static const char cite_user_rann_package[] = PairRANN::PairRANN(LAMMPS *lmp) : Pair(lmp) { + //initialize ints and bools single_enable = 0; restartinfo = 0; one_coeff = 1; manybody_flag = 1; allocated = 0; nelements = -1; - elements = nullptr; - mass = nullptr; - - // set comm size needed by this Pair - // comm unused for now. - - comm_forward = 38; - comm_reverse = 30; + nelementsp = -1; + comm_forward = 0; + comm_reverse = 0; res = 10000; cutmax = 0; - //at least one of the following will change during fingerprint definition: + dospin = false; + memguess = 0; + nmax1 = 0; + nmax2 = 0; + fmax = 0; + fnmax = 0; + //at least one of the following two flags will change during fingerprint definition: doscreen = false; allscreen = true; - dospin = false; + + //null init for arrays with sizes not yet determined. + elements = nullptr; + mass = nullptr; + elementsp = nullptr; + map = nullptr; + fingerprintcount = nullptr; + fingerprintlength = nullptr; + fingerprintperelement = nullptr; + screening_min = nullptr; + screening_max = nullptr; + weightdefined = nullptr; + biasdefined = nullptr; + xn = nullptr; + yn = nullptr; + zn = nullptr; + Sik = nullptr; + dSikx = nullptr; + dSiky = nullptr; + dSikz = nullptr; + dSijkx = nullptr; + dSijky = nullptr; + dSijkz = nullptr; + sx = nullptr; + sy = nullptr; + sz = nullptr; + dSijkxc = nullptr; + dSijkyc = nullptr; + dSijkzc = nullptr; + dfeaturesx = nullptr; + dfeaturesy = nullptr; + dfeaturesz = nullptr; + features = nullptr; + layer = nullptr; + sum = nullptr; + sum1 = nullptr; + dlayerx = nullptr; + dlayery = nullptr; + dlayerz = nullptr; + dlayersumx = nullptr; + dlayersumy = nullptr; + dlayersumz = nullptr; + dsx = nullptr; + dsy = nullptr; + dsz = nullptr; + dssumx = nullptr; + dssumy = nullptr; + dssumz = nullptr; + tn = nullptr; + jl = nullptr; + Bij = nullptr; + sims = nullptr; + net = nullptr; + activation = nullptr; + fingerprints = nullptr; } PairRANN::~PairRANN() +{ + deallocate(); +} + +void PairRANN::deallocate() { //clear memory - delete [] mass; + delete[] mass; for (int i=0;i0) { for (int j=0;j0) { - delete [] fingerprints[i]; - delete [] activation[i]; + for (int j=0;jdestroy(xn); memory->destroy(yn); memory->destroy(zn); @@ -149,30 +218,28 @@ PairRANN::~PairRANN() memory->destroy(dlayersumx); memory->destroy(dlayersumy); memory->destroy(dlayersumz); - if (doscreen) { - memory->destroy(Sik); - memory->destroy(Bij); - memory->destroy(dSikx); - memory->destroy(dSiky); - memory->destroy(dSikz); - memory->destroy(dSijkx); - memory->destroy(dSijky); - memory->destroy(dSijkz); - memory->destroy(dSijkxc); - memory->destroy(dSijkyc); - memory->destroy(dSijkzc); - } - if (dospin) { - memory->destroy(sx); - memory->destroy(sy); - memory->destroy(sz); - memory->destroy(dsx); - memory->destroy(dsy); - memory->destroy(dsz); - memory->destroy(dssumx); - memory->destroy(dssumy); - memory->destroy(dssumz); - } + memory->destroy(Sik); + memory->destroy(Bij); + memory->destroy(dSikx); + memory->destroy(dSiky); + memory->destroy(dSikz); + memory->destroy(dSijkx); + memory->destroy(dSijky); + memory->destroy(dSijkz); + memory->destroy(dSijkxc); + memory->destroy(dSijkyc); + memory->destroy(dSijkzc); + memory->destroy(sx); + memory->destroy(sy); + memory->destroy(sz); + memory->destroy(dsx); + memory->destroy(dsy); + memory->destroy(dsz); + memory->destroy(dssumx); + memory->destroy(dssumy); + memory->destroy(dssumz); + memory->destroy(setflag); + memory->destroy(cutsq); } void PairRANN::allocate(const std::vector &elementwords) @@ -197,10 +264,10 @@ void PairRANN::allocate(const std::vector &elementwords) activation = new RANN::Activation**[nelementsp]; fingerprints = new RANN::Fingerprint**[nelementsp]; fingerprintlength = new int[nelementsp]; - fingerprintperelement = new int [nelementsp]; + fingerprintperelement = new int[nelementsp]; fingerprintcount = new int[nelementsp]; - screening_min = new double [nelements*nelements*nelements]; - screening_max = new double [nelements*nelements*nelements]; + screening_min = new double[nelements*nelements*nelements]; + screening_max = new double[nelements*nelements*nelements]; for (i=0;intypes+1]; + deallocate();//clear allocation from any previous coeff + map = new int[atom->ntypes+1]; if (narg != 3 + atom->ntypes) error->one(FLERR,"Incorrect args for pair coefficients"); if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) error->one(FLERR,"Incorrect args for pair coefficients"); nelements = -1; @@ -284,7 +352,7 @@ void PairRANN::read_file(char *filename) FILE *fp; int eof = 0; std::string line,line1; - int longline = 4096; + const int longline = 4096; int linenum; char linetemp[longline]; std::string strtemp; @@ -305,6 +373,7 @@ void PairRANN::read_file(char *filename) ptr=fgets(linetemp,longline,fp); linenum++; if (ptr == nullptr) { + fclose(fp); if (check_potential()) { error->one(FLERR,"Invalid syntax in potential file, values are inconsistent or missing"); } @@ -394,12 +463,12 @@ void PairRANN::read_fpe(std::vector line,std::vector l } void PairRANN::read_fingerprints(std::vector line,std::vector line1,char *filename,int linenum) { - int nwords1,nwords,i,j,k,i1; + int nwords1,nwords,i,j,k,i1,*atomtypes; bool found; nwords1 = line1.size(); nwords = line.size(); if (nelements == -1)error->one(filename,linenum-1,"atom types must be defined before fingerprints in potential file."); - int atomtypes[nwords-1]; + atomtypes = new int[nwords-1]; for (i=1;i line,std::vectorinit(atomtypes,utils::inumeric(filename,linenum,line1[k++].c_str(),1,lmp)); fingerprintcount[i]++; } + delete[] atomtypes; } void PairRANN::read_fingerprint_constants(std::vector line,std::vector line1,char *filename,int linenum) { - int i,j,k,i1; + int i,j,k,i1,*atomtypes; bool found; int nwords = line.size(); if (nelements == -1)error->one(filename,linenum-1,"atom types must be defined before fingerprints in potential file."); int n_body_type = nwords-4; - int atomtypes[n_body_type]; + atomtypes = new int[n_body_type]; for (i=1;i<=n_body_type;i++) { found = false; for (j=0;j line,std::vec } if (!found) {error->one(filename,linenum-1,"cannot define constants for unknown fingerprint");} fingerprints[i][i1]->fullydefined=fingerprints[i][i1]->parse_values(line[nwords-1],line1); + delete[] atomtypes; } void PairRANN::read_network_layers(std::vector line,std::vector line1,char *filename,int linenum) { @@ -472,16 +543,14 @@ void PairRANN::read_network_layers(std::vector line,std::vectorone(filename,linenum,"invalid number of network layers"); - delete [] net[i].dimensions; + delete[] net[i].dimensions; weightdefined[i] = new bool [net[i].layers]; biasdefined[i] = new bool [net[i].layers]; - net[i].dimensions = new int [net[i].layers]; + net[i].dimensions = new int[net[i].layers]; net[i].Weights = new double * [net[i].layers-1]; net[i].Biases = new double * [net[i].layers-1]; - net[i].activations = new int [net[i].layers-1]; for (j=0;j line,std::vector line,std::vector line1,FILE* fp,char *filename,int *linenum) { int i,j,k,l,nwords; char *ptr; - int longline = 4096; + const int longline = 4096; char linetemp [longline]; for (l=0;l line,std::vector=net[l].layers || i<0)error->one(filename,*linenum-1,"invalid weight layer"); if (net[l].dimensions[i]==0 || net[l].dimensions[i+1]==0) error->one(filename,*linenum-1,"network layer sizes must be defined before corresponding weight"); - net[l].Weights[i] = new double [net[l].dimensions[i]*net[l].dimensions[i+1]]; + net[l].Weights[i] = new double[net[l].dimensions[i]*net[l].dimensions[i+1]]; weightdefined[l][i] = true; nwords = line1.size(); if (nwords != net[l].dimensions[i])error->one(filename,*linenum,"invalid weights per line"); @@ -547,7 +616,7 @@ void PairRANN::read_weight(std::vector line,std::vector line,std::vector line1,FILE* fp,char *filename,int *linenum) { int i,j,l; - char linetemp[MAXLINE]; + char linetemp[MAXLINE],*ptr; for (l=0;lone(filename,*linenum-1,"networklayers must be defined before biases."); @@ -555,10 +624,11 @@ void PairRANN::read_bias(std::vector line,std::vector if (i>=net[l].layers || i<0)error->one(filename,*linenum-1,"invalid bias layer"); if (net[l].dimensions[i]==0) error->one(filename,*linenum-1,"network layer sizes must be defined before corresponding bias"); biasdefined[l][i] = true; - net[l].Biases[i] = new double [net[l].dimensions[i+1]]; + net[l].Biases[i] = new double[net[l].dimensions[i+1]]; net[l].Biases[i][0] = utils::numeric(filename,*linenum,line1[0].c_str(),1,lmp); for (j=1;jone(filename,*linenum,"unexpected end of potential file!"); (*linenum)++; Tokenizer values1 = Tokenizer(linetemp,": ,\t_\n"); line1 = values1.as_vector(); @@ -586,13 +656,13 @@ void PairRANN::read_activation_functions(std::vector line,std::vect } void PairRANN::read_screening(std::vector line,std::vector line1,char *filename,int linenum) { - int i,j,k; + int i,j,k,*atomtypes; bool found; int nwords = line.size(); if (nelements == -1)error->one(filename,linenum-1,"atom types must be defined before fingerprints in potential file."); if (nwords!=5)error->one(filename,linenum-1,"invalid screening command"); int n_body_type = 3; - int atomtypes[n_body_type]; + atomtypes = new int[n_body_type]; for (i=1;i<=n_body_type;i++) { found = false; for (j=0;j line,std::vectorone(filename,linenum-1,"unrecognized screening keyword"); + delete[] atomtypes; } //Called after finishing reading the potential file to make sure it is complete. True is bad. @@ -832,6 +903,7 @@ void PairRANN::compute(int eflag, int vflag) } } if (vflag_fdotr) virial_fdotr_compute(); + delete[] sims; } void PairRANN::cull_neighbor_list(int* jnum,int i,int sn) { diff --git a/src/ML-RANN/pair_rann.h b/src/ML-RANN/pair_rann.h index ceaa5f445c..6c047775d4 100644 --- a/src/ML-RANN/pair_rann.h +++ b/src/ML-RANN/pair_rann.h @@ -136,6 +136,7 @@ namespace LAMMPS_NS { private: //new functions void allocate(const std::vector &);//called after reading element list, but before reading the rest of the potential + void deallocate(); void read_file(char *);//read potential file void read_atom_types(std::vector,char*,int); void read_fpe(std::vector,std::vector,char*,int);//fingerprints per element. Count total fingerprints defined for each 1st element in element combinations diff --git a/src/ML-RANN/rann_fingerprint_bond.cpp b/src/ML-RANN/rann_fingerprint_bond.cpp index bf14828a7b..4b96a4f39d 100644 --- a/src/ML-RANN/rann_fingerprint_bond.cpp +++ b/src/ML-RANN/rann_fingerprint_bond.cpp @@ -40,35 +40,35 @@ Fingerprint_bond::Fingerprint_bond(PairRANN *_pair) : Fingerprint(_pair) dr = 0; re = 0; rc = 0; - alpha_k = new double [1]; + alpha_k = new double[1]; alpha_k[0] = -1; kmax = 0; mlength = 0; id = -1; style = "bond"; - atomtypes = new int [n_body_type]; + atomtypes = new int[n_body_type]; empty = true; _pair->allscreen = false; } Fingerprint_bond::~Fingerprint_bond() { - delete [] alpha_k; - delete [] atomtypes; - delete [] expcuttable; - delete [] dfctable; + delete[] alpha_k; + delete[] atomtypes; + delete[] expcuttable; + delete[] dfctable; for (int i=0;i<(mlength*(mlength+1))>>1;i++) { - delete [] coeff[i]; - delete [] coeffx[i]; - delete [] coeffy[i]; - delete [] coeffz[i]; - delete [] Mf[i]; + delete[] coeff[i]; + delete[] coeffx[i]; + delete[] coeffy[i]; + delete[] coeffz[i]; + delete[] Mf[i]; } - delete [] coeff; - delete [] coeffx; - delete [] coeffy; - delete [] coeffz; - delete [] Mf; - delete [] rinvsqrttable; + delete[] coeff; + delete[] coeffx; + delete[] coeffy; + delete[] coeffz; + delete[] Mf; + delete[] rinvsqrttable; } bool Fingerprint_bond::parse_values(std::string constant,std::vector line1) { @@ -81,8 +81,8 @@ bool Fingerprint_bond::parse_values(std::string constant,std::vectorres; double cutmax = pair->cutmax; - expcuttable = new double [(res+buf)*(kmax)]; - dfctable = new double [res+buf]; + expcuttable = new double[(res+buf)*(kmax)]; + dfctable = new double[res+buf]; for (m=0;m<(res+buf);m++) { r1 = cutmax*cutmax*(double)(m)/(double)(res); for (n=0;n<(kmax);n++) { @@ -282,6 +283,7 @@ void Fingerprint_bond::generate_coefficients() { //calculates multinomial c coeff[p1][p] = pair->factorial(p)/pair->factorial(coeffx[p1][p])/pair->factorial(coeffy[p1][p])/pair->factorial(coeffz[p1][p]); } } + delete[] M; } diff --git a/src/ML-RANN/rann_fingerprint_bondscreened.cpp b/src/ML-RANN/rann_fingerprint_bondscreened.cpp index 59fed322a3..2ed63a3655 100644 --- a/src/ML-RANN/rann_fingerprint_bondscreened.cpp +++ b/src/ML-RANN/rann_fingerprint_bondscreened.cpp @@ -39,36 +39,36 @@ Fingerprint_bondscreened::Fingerprint_bondscreened(PairRANN *_pair) : Fingerprin dr = 0; re = 0; rc = 0; - alpha_k = new double [1]; + alpha_k = new double[1]; alpha_k[0] = -1; kmax = 0; mlength = 0; id = -1; style = "bondscreened"; - atomtypes = new int [n_body_type]; + atomtypes = new int[n_body_type]; empty = true; _pair->doscreen = true; screen = true; } Fingerprint_bondscreened::~Fingerprint_bondscreened() { - delete [] alpha_k; - delete [] atomtypes; - delete [] expcuttable; - delete [] dfctable; + delete[] alpha_k; + delete[] atomtypes; + delete[] expcuttable; + delete[] dfctable; for (int i=0;i<(mlength*(mlength+1))>>1;i++) { - delete [] coeff[i]; - delete [] coeffx[i]; - delete [] coeffy[i]; - delete [] coeffz[i]; - delete [] Mf[i]; + delete[] coeff[i]; + delete[] coeffx[i]; + delete[] coeffy[i]; + delete[] coeffz[i]; + delete[] Mf[i]; } - delete [] coeff; - delete [] coeffx; - delete [] coeffy; - delete [] coeffz; - delete [] Mf; - delete [] rinvsqrttable; + delete[] coeff; + delete[] coeffx; + delete[] coeffy; + delete[] coeffz; + delete[] Mf; + delete[] rinvsqrttable; } bool Fingerprint_bondscreened::parse_values(std::string constant,std::vector line1) { @@ -81,8 +81,8 @@ bool Fingerprint_bondscreened::parse_values(std::string constant,std::vectorres; double cutmax = pair->cutmax; - expcuttable = new double [(res+buf)*(kmax)]; - dfctable = new double [res+buf]; + expcuttable = new double[(res+buf)*(kmax)]; + dfctable = new double[res+buf]; for (m=0;m<(res+buf);m++) { r1 = cutmax*cutmax*(double)(m)/(double)(res); for (n=0;n<(kmax);n++) { @@ -283,6 +284,7 @@ void Fingerprint_bondscreened::generate_coefficients() { //calculates multi coeff[p1][p] = pair->factorial(p)/pair->factorial(coeffx[p1][p])/pair->factorial(coeffy[p1][p])/pair->factorial(coeffz[p1][p]); } } + delete[] M; } diff --git a/src/ML-RANN/rann_fingerprint_bondscreenedspin.cpp b/src/ML-RANN/rann_fingerprint_bondscreenedspin.cpp index 0728b6a295..49829b41a1 100644 --- a/src/ML-RANN/rann_fingerprint_bondscreenedspin.cpp +++ b/src/ML-RANN/rann_fingerprint_bondscreenedspin.cpp @@ -39,13 +39,13 @@ Fingerprint_bondscreenedspin::Fingerprint_bondscreenedspin(PairRANN *_pair) : Fi dr = 0; re = 0; rc = 0; - alpha_k = new double [1]; + alpha_k = new double[1]; alpha_k[0] = -1; kmax = 0; mlength = 0; id = -1; style = "bondscreenedspin"; - atomtypes = new int [n_body_type]; + atomtypes = new int[n_body_type]; empty = true; _pair->doscreen = true; screen = true; @@ -54,23 +54,23 @@ Fingerprint_bondscreenedspin::Fingerprint_bondscreenedspin(PairRANN *_pair) : Fi } Fingerprint_bondscreenedspin::~Fingerprint_bondscreenedspin() { - delete [] alpha_k; - delete [] atomtypes; - delete [] expcuttable; - delete [] dfctable; + delete[] alpha_k; + delete[] atomtypes; + delete[] expcuttable; + delete[] dfctable; for (int i=0;i<(mlength*(mlength+1))>>1;i++) { - delete [] coeff[i]; - delete [] coeffx[i]; - delete [] coeffy[i]; - delete [] coeffz[i]; - delete [] Mf[i]; + delete[] coeff[i]; + delete[] coeffx[i]; + delete[] coeffy[i]; + delete[] coeffz[i]; + delete[] Mf[i]; } - delete [] coeff; - delete [] coeffx; - delete [] coeffy; - delete [] coeffz; - delete [] Mf; - delete [] rinvsqrttable; + delete[] coeff; + delete[] coeffx; + delete[] coeffy; + delete[] coeffz; + delete[] Mf; + delete[] rinvsqrttable; } bool Fingerprint_bondscreenedspin::parse_values(std::string constant,std::vector line1) { @@ -83,8 +83,8 @@ bool Fingerprint_bondscreenedspin::parse_values(std::string constant,std::vector rc = strtod(line1[0].c_str(),NULL); } else if (constant.compare("alphak")==0) { - delete [] alpha_k; - alpha_k = new double [nwords]; + delete[] alpha_k; + alpha_k = new double[nwords]; for (l=0;lres; double cutmax = pair->cutmax; - expcuttable = new double [(res+buf)*(kmax)]; - dfctable = new double [res+buf]; + expcuttable = new double[(res+buf)*(kmax)]; + dfctable = new double[res+buf]; for (m=0;m<(res+buf);m++) { r1 = cutmax*cutmax*(double)(m)/(double)(res); for (n=0;n<(kmax);n++) { @@ -285,6 +286,7 @@ void Fingerprint_bondscreenedspin::generate_coefficients() { //calculates m coeff[p1][p] = pair->factorial(p)/pair->factorial(coeffx[p1][p])/pair->factorial(coeffy[p1][p])/pair->factorial(coeffz[p1][p]); } } + delete[] M; } diff --git a/src/ML-RANN/rann_fingerprint_bondspin.cpp b/src/ML-RANN/rann_fingerprint_bondspin.cpp index 1005818217..452846cfb1 100644 --- a/src/ML-RANN/rann_fingerprint_bondspin.cpp +++ b/src/ML-RANN/rann_fingerprint_bondspin.cpp @@ -39,13 +39,13 @@ Fingerprint_bondspin::Fingerprint_bondspin(PairRANN *_pair) : Fingerprint(_pair) dr = 0; re = 0; rc = 0; - alpha_k = new double [1]; + alpha_k = new double[1]; alpha_k[0] = -1; kmax = 0; mlength = 0; id = -1; style = "bondspin"; - atomtypes = new int [n_body_type]; + atomtypes = new int[n_body_type]; empty = true; _pair->allscreen = false; _pair->dospin = true; @@ -53,23 +53,23 @@ Fingerprint_bondspin::Fingerprint_bondspin(PairRANN *_pair) : Fingerprint(_pair) } Fingerprint_bondspin::~Fingerprint_bondspin() { - delete [] alpha_k; - delete [] atomtypes; - delete [] expcuttable; - delete [] dfctable; + delete[] alpha_k; + delete[] atomtypes; + delete[] expcuttable; + delete[] dfctable; for (int i=0;i<(mlength*(mlength+1))>>1;i++) { - delete [] coeff[i]; - delete [] coeffx[i]; - delete [] coeffy[i]; - delete [] coeffz[i]; - delete [] Mf[i]; + delete[] coeff[i]; + delete[] coeffx[i]; + delete[] coeffy[i]; + delete[] coeffz[i]; + delete[] Mf[i]; } - delete [] coeff; - delete [] coeffx; - delete [] coeffy; - delete [] coeffz; - delete [] Mf; - delete [] rinvsqrttable; + delete[] coeff; + delete[] coeffx; + delete[] coeffy; + delete[] coeffz; + delete[] Mf; + delete[] rinvsqrttable; } bool Fingerprint_bondspin::parse_values(std::string constant,std::vector line1) { @@ -82,8 +82,8 @@ bool Fingerprint_bondspin::parse_values(std::string constant,std::vectorres; double cutmax = pair->cutmax; - expcuttable = new double [(res+buf)*(kmax)]; - dfctable = new double [res+buf]; + expcuttable = new double[(res+buf)*(kmax)]; + dfctable = new double[res+buf]; for (m=0;m<(res+buf);m++) { r1 = cutmax*cutmax*(double)(m)/(double)(res); for (n=0;n<(kmax);n++) { @@ -283,6 +284,7 @@ void Fingerprint_bondspin::generate_coefficients() { //calculates multinomi coeff[p1][p] = pair->factorial(p)/pair->factorial(coeffx[p1][p])/pair->factorial(coeffy[p1][p])/pair->factorial(coeffz[p1][p]); } } + delete[] M; } diff --git a/src/ML-RANN/rann_fingerprint_radial.cpp b/src/ML-RANN/rann_fingerprint_radial.cpp index f468ee2f6c..93cab2f363 100644 --- a/src/ML-RANN/rann_fingerprint_radial.cpp +++ b/src/ML-RANN/rann_fingerprint_radial.cpp @@ -41,13 +41,13 @@ Fingerprint_radial::Fingerprint_radial(PairRANN *_pair) : Fingerprint(_pair) dr = 0; re = 0; rc = 0; - alpha = new double [1]; + alpha = new double[1]; alpha[0] = -1; nmax = 0; omin = 0; id = -1; style = "radial"; - atomtypes = new int [n_body_type]; + atomtypes = new int[n_body_type]; empty = true; fullydefined = false; _pair->allscreen = false; @@ -55,11 +55,11 @@ Fingerprint_radial::Fingerprint_radial(PairRANN *_pair) : Fingerprint(_pair) Fingerprint_radial::~Fingerprint_radial() { - delete [] atomtypes; - delete [] radialtable; - delete [] alpha; - delete [] dfctable; - delete [] rinvsqrttable; + delete[] atomtypes; + delete[] radialtable; + delete[] alpha; + delete[] dfctable; + delete[] rinvsqrttable; } bool Fingerprint_radial::parse_values(std::string constant,std::vector line1) { @@ -72,8 +72,8 @@ bool Fingerprint_radial::parse_values(std::string constant,std::vectorres; double cutmax = pair->cutmax; - radialtable = new double [(res+buf)*get_length()]; - dfctable = new double [res+buf]; + radialtable = new double[(res+buf)*get_length()]; + dfctable = new double[res+buf]; for (k=0;k<(res+buf);k++) { r1 = cutmax*cutmax*(double)(k)/(double)(res); for (m=0;m<=(nmax-omin);m++) { diff --git a/src/ML-RANN/rann_fingerprint_radialscreened.cpp b/src/ML-RANN/rann_fingerprint_radialscreened.cpp index 126b83fc51..a933703db8 100644 --- a/src/ML-RANN/rann_fingerprint_radialscreened.cpp +++ b/src/ML-RANN/rann_fingerprint_radialscreened.cpp @@ -41,13 +41,13 @@ Fingerprint_radialscreened::Fingerprint_radialscreened(PairRANN *_pair) : Finger dr = 0; re = 0; rc = 0; - alpha = new double [1]; + alpha = new double[1]; alpha[0] = -1; nmax = 0; omin = 0; id = -1; style = "radialscreened"; - atomtypes = new int [n_body_type]; + atomtypes = new int[n_body_type]; empty = true; fullydefined = false; _pair->doscreen = true; @@ -56,11 +56,11 @@ Fingerprint_radialscreened::Fingerprint_radialscreened(PairRANN *_pair) : Finger Fingerprint_radialscreened::~Fingerprint_radialscreened() { - delete [] atomtypes; - delete [] radialtable; - delete [] alpha; - delete [] dfctable; - delete [] rinvsqrttable; + delete[] atomtypes; + delete[] radialtable; + delete[] alpha; + delete[] dfctable; + delete[] rinvsqrttable; } bool Fingerprint_radialscreened::parse_values(std::string constant,std::vector line1) { @@ -73,8 +73,8 @@ bool Fingerprint_radialscreened::parse_values(std::string constant,std::vectorres; double cutmax = pair->cutmax; - radialtable = new double [(res+buf)*get_length()]; - dfctable = new double [res+buf]; + radialtable = new double[(res+buf)*get_length()]; + dfctable = new double[res+buf]; for (k=0;k<(res+buf);k++) { r1 = cutmax*cutmax*(double)(k)/(double)(res); for (m=0;m<=(nmax-omin);m++) { diff --git a/src/ML-RANN/rann_fingerprint_radialscreenedspin.cpp b/src/ML-RANN/rann_fingerprint_radialscreenedspin.cpp index 11674190fb..ecd0e4a2f0 100644 --- a/src/ML-RANN/rann_fingerprint_radialscreenedspin.cpp +++ b/src/ML-RANN/rann_fingerprint_radialscreenedspin.cpp @@ -40,13 +40,13 @@ Fingerprint_radialscreenedspin::Fingerprint_radialscreenedspin(PairRANN *_pair) dr = 0; re = 0; rc = 0; - alpha = new double [1]; + alpha = new double[1]; alpha[0] = -1; nmax = 0; omin = 0; id = -1; style = "radialscreenedspin"; - atomtypes = new int [n_body_type]; + atomtypes = new int[n_body_type]; empty = true; fullydefined = false; _pair->doscreen = true; @@ -57,11 +57,11 @@ Fingerprint_radialscreenedspin::Fingerprint_radialscreenedspin(PairRANN *_pair) Fingerprint_radialscreenedspin::~Fingerprint_radialscreenedspin() { - delete [] atomtypes; - delete [] radialtable; - delete [] alpha; - delete [] dfctable; - delete [] rinvsqrttable; + delete[] atomtypes; + delete[] radialtable; + delete[] alpha; + delete[] dfctable; + delete[] rinvsqrttable; } bool Fingerprint_radialscreenedspin::parse_values(std::string constant,std::vector line1) { @@ -74,8 +74,8 @@ bool Fingerprint_radialscreenedspin::parse_values(std::string constant,std::vect rc = strtod(line1[0].c_str(),NULL); } else if (constant.compare("alpha")==0) { - delete [] alpha; - alpha = new double [nwords]; + delete[] alpha; + alpha = new double[nwords]; for (l=0;lres; double cutmax = pair->cutmax; - radialtable = new double [(res+buf)*get_length()]; - dfctable = new double [res+buf]; + radialtable = new double[(res+buf)*get_length()]; + dfctable = new double[res+buf]; for (k=0;k<(res+buf);k++) { r1 = cutmax*cutmax*(double)(k)/(double)(res); for (m=0;m<=(nmax-omin);m++) { diff --git a/src/ML-RANN/rann_fingerprint_radialspin.cpp b/src/ML-RANN/rann_fingerprint_radialspin.cpp index 2d0a2f68f1..137f7ac162 100644 --- a/src/ML-RANN/rann_fingerprint_radialspin.cpp +++ b/src/ML-RANN/rann_fingerprint_radialspin.cpp @@ -40,13 +40,13 @@ Fingerprint_radialspin::Fingerprint_radialspin(PairRANN *_pair) : Fingerprint(_p dr = 0; re = 0; rc = 0; - alpha = new double [1]; + alpha = new double[1]; alpha[0] = -1; nmax = 0; omin = 0; id = -1; style = "radialspin"; - atomtypes = new int [n_body_type]; + atomtypes = new int[n_body_type]; empty = true; fullydefined = false; _pair->allscreen = false; @@ -56,11 +56,11 @@ Fingerprint_radialspin::Fingerprint_radialspin(PairRANN *_pair) : Fingerprint(_p Fingerprint_radialspin::~Fingerprint_radialspin() { - delete [] atomtypes; - delete [] radialtable; - delete [] alpha; - delete [] dfctable; - delete [] rinvsqrttable; + delete[] atomtypes; + delete[] radialtable; + delete[] alpha; + delete[] dfctable; + delete[] rinvsqrttable; } bool Fingerprint_radialspin::parse_values(std::string constant,std::vector line1) { @@ -73,8 +73,8 @@ bool Fingerprint_radialspin::parse_values(std::string constant,std::vectorres; double cutmax = pair->cutmax; - radialtable = new double [(res+buf)*get_length()]; - dfctable = new double [res+buf]; + radialtable = new double[(res+buf)*get_length()]; + dfctable = new double[res+buf]; for (k=0;k<(res+buf);k++) { r1 = cutmax*cutmax*(double)(k)/(double)(res); for (m=0;m<=(nmax-omin);m++) { diff --git a/src/OPENMP/Install.sh b/src/OPENMP/Install.sh index bb4ef6c3aa..6d9423033e 100755 --- a/src/OPENMP/Install.sh +++ b/src/OPENMP/Install.sh @@ -37,10 +37,12 @@ done for file in *_omp.h; do test $file = thr_omp.h && continue + test $file = reaxff_omp.h && continue dep=${file%_omp.h}.h action $file $dep done +action reaxff_omp.h reaxff_api.h action thr_omp.h action thr_omp.cpp action thr_data.h diff --git a/src/OPENMP/fix_qeq_reax_omp.cpp b/src/OPENMP/fix_qeq_reaxff_omp.cpp similarity index 73% rename from src/OPENMP/fix_qeq_reax_omp.cpp rename to src/OPENMP/fix_qeq_reaxff_omp.cpp index 7fe9994fc6..89b75bfe7a 100644 --- a/src/OPENMP/fix_qeq_reax_omp.cpp +++ b/src/OPENMP/fix_qeq_reaxff_omp.cpp @@ -18,11 +18,11 @@ Hybrid & sub-group capabilities added by Ray Shan (Materials Design) - OpenMP based threading support for fix qeq/reax/omp added + OpenMP based threading support for fix qeq/reaxff/omp added by Hasan Metin Aktulga (MSU), Chris Knight (ALCF), Paul Coffman (ALCF), Kurt O'Hearn (MSU), Ray Shan (Materials Design), Wei Jiang (ALCF) - Integration of the pair_style reax/c/omp into the OPENMP package + Integration of the pair_style reaxff/omp into the OPENMP package by Axel Kohlmeyer (Temple U.) Please cite the related publication: @@ -32,18 +32,19 @@ High Performance Computing Applications, to appear. ------------------------------------------------------------------------- */ -#include "fix_qeq_reax_omp.h" +#include "fix_qeq_reaxff_omp.h" -#include -#include "pair_reaxc.h" #include "atom.h" #include "comm.h" +#include "error.h" +#include "memory.h" #include "neigh_list.h" #include "update.h" -#include "memory.h" -#include "error.h" -#include "reaxc_defs.h" -#include "reaxc_types.h" + +#include "pair_reaxff.h" +#include "reaxff_defs.h" + +#include #if defined(_OPENMP) #include @@ -52,17 +53,10 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define EV_TO_KCAL_PER_MOL 14.4 -//#define DANGER_ZONE 0.95 -//#define LOOSE_ZONE 0.7 -#define SQR(x) ((x)*(x)) -#define CUBE(x) ((x)*(x)*(x)) -#define MIN_NBRS 100 - /* ---------------------------------------------------------------------- */ -FixQEqReaxOMP::FixQEqReaxOMP(LAMMPS *lmp, int narg, char **arg) : - FixQEqReax(lmp, narg, arg) +FixQEqReaxFFOMP::FixQEqReaxFFOMP(LAMMPS *lmp, int narg, char **arg) : + FixQEqReaxFF(lmp, narg, arg) { b_temp = nullptr; @@ -75,14 +69,14 @@ FixQEqReaxOMP::FixQEqReaxOMP(LAMMPS *lmp, int narg, char **arg) : aspc_b = nullptr; } -FixQEqReaxOMP::~FixQEqReaxOMP() +FixQEqReaxFFOMP::~FixQEqReaxFFOMP() { memory->destroy(b_temp); } /* ---------------------------------------------------------------------- */ -void FixQEqReaxOMP::post_constructor() +void FixQEqReaxFFOMP::post_constructor() { grow_arrays(atom->nmax); for (int i = 0; i < atom->nmax; i++) @@ -94,34 +88,34 @@ void FixQEqReaxOMP::post_constructor() /* ---------------------------------------------------------------------- */ -void FixQEqReaxOMP::allocate_storage() +void FixQEqReaxFFOMP::allocate_storage() { - FixQEqReax::allocate_storage(); + FixQEqReaxFF::allocate_storage(); // dual CG support int size = nmax; if (dual_enabled) size*= 2; - memory->create(b_temp, comm->nthreads, size, "qeq/reax/omp:b_temp"); + memory->create(b_temp, comm->nthreads, size, "qeq/reaxff/omp:b_temp"); } /* ---------------------------------------------------------------------- */ -void FixQEqReaxOMP::deallocate_storage() +void FixQEqReaxFFOMP::deallocate_storage() { memory->destroy(b_temp); - FixQEqReax::deallocate_storage(); + FixQEqReaxFF::deallocate_storage(); } /* ---------------------------------------------------------------------- */ -void FixQEqReaxOMP::init() +void FixQEqReaxFFOMP::init() { - FixQEqReax::init(); + FixQEqReaxFF::init(); // APSC setup if (do_aspc) { - memory->create(aspc_b, aspc_order_max+2, "qeq/reax/aspc_b"); + memory->create(aspc_b, aspc_order_max+2, "qeq/reaxff/aspc_b"); // Calculate damping factor double o = double(aspc_order); @@ -150,7 +144,7 @@ void FixQEqReaxOMP::init() /* ---------------------------------------------------------------------- */ -void FixQEqReaxOMP::compute_H() +void FixQEqReaxFFOMP::compute_H() { double SMALL = 0.0001; @@ -219,7 +213,7 @@ void FixQEqReaxOMP::compute_H() if (flag) { H.jlist[mfill] = j; - H.val[mfill] = calculate_H( sqrt(r_sqr), shld[type[i]][type[j]] ); + H.val[mfill] = calculate_H(sqrt(r_sqr), shld[type[i]][type[j]]); mfill++; } } @@ -227,21 +221,16 @@ void FixQEqReaxOMP::compute_H() H.numnbrs[i] = mfill - H.firstnbr[i]; } } - - if (mfill >= H.m) { - char str[128]; - sprintf(str,"H matrix size has been exceeded: mfill=%d H.m=%d\n", - mfill, H.m); - error->warning(FLERR,str); - error->all(FLERR,"Fix qeq/reax/omp has insufficient QEq matrix size"); - } } // omp + if (m_fill >= H.m) + error->all(FLERR,fmt::format("Fix qeq/reaxff: H matrix size has been " + "exceeded: m_fill={} H.m={}\n", m_fill, H.m)); } /* ---------------------------------------------------------------------- */ -void FixQEqReaxOMP::init_storage() +void FixQEqReaxFFOMP::init_storage() { #if defined(_OPENMP) #pragma omp parallel for schedule(static) @@ -258,27 +247,18 @@ void FixQEqReaxOMP::init_storage() /* ---------------------------------------------------------------------- */ -void FixQEqReaxOMP::pre_force(int /* vflag */) +void FixQEqReaxFFOMP::pre_force(int /* vflag */) { - -#ifdef OMP_TIMING - double endTimeBase, startTimeBase, funcstartTimeBase; - funcstartTimeBase = MPI_Wtime(); -#endif - - double t_start, t_end; - if (update->ntimestep % nevery) return; - if (comm->me == 0) t_start = MPI_Wtime(); int n = atom->nlocal; - if (reaxc) { - nn = reaxc->list->inum; - NN = reaxc->list->inum + reaxc->list->gnum; - ilist = reaxc->list->ilist; - numneigh = reaxc->list->numneigh; - firstneigh = reaxc->list->firstneigh; + if (reaxff) { + nn = reaxff->list->inum; + NN = reaxff->list->inum + reaxff->list->gnum; + ilist = reaxff->list->ilist; + numneigh = reaxff->list->numneigh; + firstneigh = reaxff->list->firstneigh; } else { nn = list->inum; NN = list->inum + list->gnum; @@ -294,74 +274,23 @@ void FixQEqReaxOMP::pre_force(int /* vflag */) if (n > n_cap*DANGER_ZONE || m_fill > m_cap*DANGER_ZONE) reallocate_matrix(); -#ifdef OMP_TIMING - startTimeBase = MPI_Wtime(); -#endif - init_matvec(); -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTEINITMVINDEX] += (endTimeBase-startTimeBase); - startTimeBase = endTimeBase; -#endif - if (dual_enabled) { - matvecs = dual_CG(b_s, b_t, s, t); // OMP_TIMING inside dual_CG + matvecs = dual_CG(b_s, b_t, s, t); } else { matvecs_s = CG(b_s, s); // CG on s - parallel - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTECG1INDEX] += (endTimeBase-startTimeBase); - ompTimingCount[COMPUTECG1INDEX]++; - ompTimingCGCount[COMPUTECG1INDEX]+= matvecs_s; - startTimeBase = endTimeBase; -#endif - matvecs_t = CG(b_t, t); // CG on t - parallel - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTECG2INDEX] += (endTimeBase-startTimeBase); - ompTimingCount[COMPUTECG2INDEX]++; - ompTimingCGCount[COMPUTECG2INDEX]+= matvecs_t; - startTimeBase = endTimeBase; -#endif - + matvecs = matvecs_s + matvecs_t; } // if (dual_enabled) -#ifdef OMP_TIMING - startTimeBase = MPI_Wtime(); -#endif - calculate_Q(); - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTECALCQINDEX] += (endTimeBase-startTimeBase); -#endif - - if (comm->me == 0) { - t_end = MPI_Wtime(); - qeq_time = t_end - t_start; - } - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTEQEQINDEX] += (endTimeBase-funcstartTimeBase); -#endif } /* ---------------------------------------------------------------------- */ -void FixQEqReaxOMP::init_matvec() +void FixQEqReaxFFOMP::init_matvec() { -#ifdef OMP_TIMING - long endTimeBase, startTimeBase; - startTimeBase = MPI_Wtime(); -#endif - /* fill-in H matrix */ compute_H(); @@ -379,8 +308,8 @@ void FixQEqReaxOMP::init_matvec() if (atom->mask[i] & groupbit) { /* init pre-conditioner for H and init solution vectors */ - Hdia_inv[i] = 1. / eta[ atom->type[i] ]; - b_s[i] = -chi[ atom->type[i] ]; + Hdia_inv[i] = 1. / eta[atom->type[i]]; + b_s[i] = -chi[atom->type[i]]; b_t[i] = -1.0; // Predictor Step @@ -407,8 +336,8 @@ void FixQEqReaxOMP::init_matvec() if (atom->mask[i] & groupbit) { /* init pre-conditioner for H and init solution vectors */ - Hdia_inv[i] = 1. / eta[ atom->type[i] ]; - b_s[i] = -chi[ atom->type[i] ]; + Hdia_inv[i] = 1. / eta[atom->type[i]]; + b_s[i] = -chi[atom->type[i]]; b_t[i] = -1.0; /* linear extrapolation for s & t from previous solutions */ @@ -416,8 +345,8 @@ void FixQEqReaxOMP::init_matvec() //t[i] = 2 * t_hist[i][0] - t_hist[i][1]; /* quadratic extrapolation for s & t from previous solutions */ - //s[i] = s_hist[i][2] + 3 * ( s_hist[i][0] - s_hist[i][1] ); - t[i] = t_hist[i][2] + 3 * ( t_hist[i][0] - t_hist[i][1] ); + //s[i] = s_hist[i][2] + 3 * (s_hist[i][0] - s_hist[i][1]); + t[i] = t_hist[i][2] + 3 * (t_hist[i][0] - t_hist[i][1]); /* cubic extrapolation for s & t from previous solutions */ s[i] = 4*(s_hist[i][0]+s_hist[i][2])-(6*s_hist[i][1]+s_hist[i][3]); @@ -427,19 +356,14 @@ void FixQEqReaxOMP::init_matvec() } pack_flag = 2; - comm->forward_comm_fix(this); //Dist_vector( s ); + comm->forward_comm_fix(this); //Dist_vector(s); pack_flag = 3; - comm->forward_comm_fix(this); //Dist_vector( t ); - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTEMVCOMPINDEX] += (long) (endTimeBase-startTimeBase); -#endif + comm->forward_comm_fix(this); //Dist_vector(t); } /* ---------------------------------------------------------------------- */ -int FixQEqReaxOMP::CG( double *b, double *x) +int FixQEqReaxFFOMP::CG(double *b, double *x) { int i; double alpha, beta, b_norm; @@ -448,8 +372,8 @@ int FixQEqReaxOMP::CG( double *b, double *x) double my_buf[2], buf[2]; pack_flag = 1; - sparse_matvec( &H, x, q ); - comm->reverse_comm_fix( this); //Coll_Vector( q ); + sparse_matvec(&H, x, q); + comm->reverse_comm_fix(this); //Coll_Vector(q); double tmp1, tmp2; tmp1 = tmp2 = 0.0; @@ -477,9 +401,9 @@ int FixQEqReaxOMP::CG( double *b, double *x) sig_new = buf[1]; for (i = 1; i < imax && sqrt(sig_new) / b_norm > tolerance; ++i) { - comm->forward_comm_fix(this); //Dist_vector( d ); - sparse_matvec( &H, d, q ); - comm->reverse_comm_fix(this); //Coll_vector( q ); + comm->forward_comm_fix(this); //Dist_vector(d); + sparse_matvec(&H, d, q); + comm->reverse_comm_fix(this); //Coll_vector(q); tmp1 = 0.0; #if defined(_OPENMP) @@ -539,19 +463,16 @@ int FixQEqReaxOMP::CG( double *b, double *x) } } - if (i >= imax && comm->me == 0) { - char str[128]; - sprintf(str,"Fix qeq/reax CG convergence failed after %d iterations " - "at " BIGINT_FORMAT " step",i,update->ntimestep); - error->warning(FLERR,str); - } - + if ((i >= imax) && maxwarn && (comm->me == 0)) + error->warning(FLERR,fmt::format("Fix qeq/reaxff/omp CG convergence failed " + "after {} iterations at step {}", + i,update->ntimestep)); return i; } /* ---------------------------------------------------------------------- */ -void FixQEqReaxOMP::sparse_matvec( sparse_matrix *A, double *x, double *b) +void FixQEqReaxFFOMP::sparse_matvec(sparse_matrix *A, double *x, double *b) { #if defined(_OPENMP) #pragma omp parallel default(shared) @@ -571,7 +492,7 @@ void FixQEqReaxOMP::sparse_matvec( sparse_matrix *A, double *x, double *b) #endif for (ii = 0; ii < nn; ++ii) { i = ilist[ii]; - if (atom->mask[i] & groupbit) b[i] = eta[ atom->type[i] ] * x[i]; + if (atom->mask[i] & groupbit) b[i] = eta[atom->type[i]] * x[i]; } #if defined(_OPENMP) @@ -618,7 +539,7 @@ void FixQEqReaxOMP::sparse_matvec( sparse_matrix *A, double *x, double *b) /* ---------------------------------------------------------------------- */ -void FixQEqReaxOMP::calculate_Q() +void FixQEqReaxFFOMP::calculate_Q() { int i; double *q = atom->q; @@ -666,12 +587,12 @@ void FixQEqReaxOMP::calculate_Q() } pack_flag = 4; - comm->forward_comm_fix( this); //Dist_vector( atom->q ); + comm->forward_comm_fix(this); //Dist_vector(atom->q); } /* ---------------------------------------------------------------------- */ -void FixQEqReaxOMP::vector_sum( double* dest, double c, double* v, +void FixQEqReaxFFOMP::vector_sum(double* dest, double c, double* v, double d, double* y, int k) { int i; @@ -687,7 +608,7 @@ void FixQEqReaxOMP::vector_sum( double* dest, double c, double* v, /* ---------------------------------------------------------------------- */ -void FixQEqReaxOMP::vector_add( double* dest, double c, double* v, int k) +void FixQEqReaxFFOMP::vector_add(double* dest, double c, double* v, int k) { int i; @@ -706,14 +627,8 @@ void FixQEqReaxOMP::vector_add( double* dest, double c, double* v, int k) /* dual CG support */ /* ---------------------------------------------------------------------- */ -int FixQEqReaxOMP::dual_CG( double *b1, double *b2, double *x1, double *x2) +int FixQEqReaxFFOMP::dual_CG(double *b1, double *b2, double *x1, double *x2) { - -#ifdef OMP_TIMING - double endTimeBase, startTimeBase; - startTimeBase = MPI_Wtime(); -#endif - int i; double alpha_s, alpha_t, beta_s, beta_t, b_norm_s, b_norm_t; double sig_old_s, sig_old_t, sig_new_s, sig_new_t; @@ -721,8 +636,8 @@ int FixQEqReaxOMP::dual_CG( double *b1, double *b2, double *x1, double *x2) double my_buf[4], buf[4]; pack_flag = 5; // forward 2x d and reverse 2x q - dual_sparse_matvec( &H, x1, x2, q ); - comm->reverse_comm_fix(this); //Coll_Vector( q ); + dual_sparse_matvec(&H, x1, x2, q); + comm->reverse_comm_fix(this); //Coll_Vector(q); double tmp1, tmp2, tmp3, tmp4; tmp1 = tmp2 = tmp3 = tmp4 = 0.0; @@ -734,16 +649,16 @@ int FixQEqReaxOMP::dual_CG( double *b1, double *b2, double *x1, double *x2) int ii = ilist[jj]; if (atom->mask[ii] & groupbit) { int indxI = 2 * ii; - r[indxI ] = b1[ii] - q[indxI ]; + r[indxI] = b1[ii] - q[indxI]; r[indxI+1] = b2[ii] - q[indxI+1]; - d[indxI ] = r[indxI ] * Hdia_inv[ii]; //pre-condition + d[indxI] = r[indxI] * Hdia_inv[ii]; //pre-condition d[indxI+1] = r[indxI+1] * Hdia_inv[ii]; tmp1 += b1[ii] * b1[ii]; tmp2 += b2[ii] * b2[ii]; - tmp3 += r[indxI ] * d[indxI ]; + tmp3 += r[indxI] * d[indxI]; tmp4 += r[indxI+1] * d[indxI+1]; } } @@ -762,9 +677,9 @@ int FixQEqReaxOMP::dual_CG( double *b1, double *b2, double *x1, double *x2) sig_new_t = buf[3]; for (i = 1; i < imax; ++i) { - comm->forward_comm_fix(this); //Dist_vector( d ); - dual_sparse_matvec( &H, d, q ); - comm->reverse_comm_fix(this); //Coll_vector( q ); + comm->forward_comm_fix(this); //Dist_vector(d); + dual_sparse_matvec(&H, d, q); + comm->reverse_comm_fix(this); //Coll_vector(q); tmp1 = tmp2 = 0.0; #if defined(_OPENMP) @@ -779,7 +694,7 @@ int FixQEqReaxOMP::dual_CG( double *b1, double *b2, double *x1, double *x2) int ii = ilist[jj]; if (atom->mask[ii] & groupbit) { int indxI = 2 * ii; - tmp1 += d[indxI ] * q[indxI ]; + tmp1 += d[indxI] * q[indxI]; tmp2 += d[indxI+1] * q[indxI+1]; } } @@ -808,17 +723,17 @@ int FixQEqReaxOMP::dual_CG( double *b1, double *b2, double *x1, double *x2) int ii = ilist[jj]; if (atom->mask[ii] & groupbit) { int indxI = 2 * ii; - x1[ii] += alpha_s * d[indxI ]; + x1[ii] += alpha_s * d[indxI]; x2[ii] += alpha_t * d[indxI+1]; - r[indxI ] -= alpha_s * q[indxI ]; + r[indxI] -= alpha_s * q[indxI]; r[indxI+1] -= alpha_t * q[indxI+1]; // pre-conditioning - p[indxI ] = r[indxI ] * Hdia_inv[ii]; + p[indxI] = r[indxI] * Hdia_inv[ii]; p[indxI+1] = r[indxI+1] * Hdia_inv[ii]; - tmp1 += r[indxI ] * p[indxI ]; + tmp1 += r[indxI] * p[indxI]; tmp2 += r[indxI+1] * p[indxI+1]; } } @@ -849,63 +764,42 @@ int FixQEqReaxOMP::dual_CG( double *b1, double *b2, double *x1, double *x2) if (atom->mask[ii] & groupbit) { int indxI = 2 * ii; - d[indxI ] = p[indxI ] + beta_s * d[indxI ]; + d[indxI] = p[indxI] + beta_s * d[indxI]; d[indxI+1] = p[indxI+1] + beta_t * d[indxI+1]; } } } - i++; - matvecs_s = matvecs_t = i; // The plus one makes consistent with count from CG() - matvecs = i; + matvecs_s = matvecs_t = i; - // Timing info for iterating s&t together -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTECG1INDEX] += (endTimeBase-startTimeBase); - ompTimingCount[COMPUTECG1INDEX]++; - ompTimingCGCount[COMPUTECG1INDEX]+= i; - startTimeBase = endTimeBase; -#endif - - // If necessary, converge other system - if (sqrt(sig_new_s)/b_norm_s > tolerance) { + // If only one was converged and there are still iterations left, converge other system + if ((matvecs_s < imax) && (sqrt(sig_new_s)/b_norm_s > tolerance)) { pack_flag = 2; comm->forward_comm_fix(this); // x1 => s - i+= CG(b1, x1); - matvecs_s = i; - } - else if (sqrt(sig_new_t)/b_norm_t > tolerance) { + int saved_imax = imax; + imax -= matvecs_s; + matvecs_s += CG(b1, x1); + imax = saved_imax; + } else if ((matvecs_t < imax) && (sqrt(sig_new_t)/b_norm_t > tolerance)) { pack_flag = 3; comm->forward_comm_fix(this); // x2 => t - - i+= CG(b2, x2); - matvecs_t = i; + int saved_imax = imax; + imax -= matvecs_t; + matvecs_t += CG(b2, x2); + imax = saved_imax; } - // Timing info for remainder of s or t -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTECG2INDEX] += (endTimeBase-startTimeBase); - ompTimingCount[COMPUTECG2INDEX]++; - ompTimingCGCount[COMPUTECG2INDEX]+= i - matvecs; - startTimeBase = endTimeBase; -#endif - - if ( i >= imax && comm->me == 0) { - char str[128]; - sprintf(str,"Fix qeq/reax CG convergence failed after %d iterations " - "at " BIGINT_FORMAT " step",i,update->ntimestep); - error->warning(FLERR,str); - } - - return i; + if ((i >= imax) && maxwarn && (comm->me == 0)) + error->warning(FLERR,fmt::format("Fix qeq/reaxff/omp CG convergence failed " + "after {} iterations at step {}", + i,update->ntimestep)); + return matvecs_s + matvecs_t; } /* ---------------------------------------------------------------------- */ -void FixQEqReaxOMP::dual_sparse_matvec( sparse_matrix *A, double *x1, double *x2, double *b) +void FixQEqReaxFFOMP::dual_sparse_matvec(sparse_matrix *A, double *x1, double *x2, double *b) { #if defined(_OPENMP) #pragma omp parallel default(shared) @@ -929,8 +823,8 @@ void FixQEqReaxOMP::dual_sparse_matvec( sparse_matrix *A, double *x1, double *x2 i = ilist[ii]; if (atom->mask[i] & groupbit) { indxI = 2 * i; - b[indxI ] = eta[ atom->type[i] ] * x1[i]; - b[indxI+1] = eta[ atom->type[i] ] * x2[i]; + b[indxI] = eta[atom->type[i]] * x1[i]; + b[indxI+1] = eta[atom->type[i]] * x2[i]; } } @@ -952,7 +846,7 @@ void FixQEqReaxOMP::dual_sparse_matvec( sparse_matrix *A, double *x1, double *x2 for (i = 0; i < NN; ++i) { indxI = 2 * i; for (int t=0; tfirstnbr[i]; itr_jfirstnbr[i]+A->numnbrs[i]; itr_j++) { j = A->jlist[itr_j]; indxJ = 2 * j; - b[indxI ] += A->val[itr_j] * x1[j]; + b[indxI] += A->val[itr_j] * x1[j]; b[indxI+1] += A->val[itr_j] * x2[j]; - b_temp[tid][indxJ ] += A->val[itr_j] * x1[i]; + b_temp[tid][indxJ] += A->val[itr_j] * x1[i]; b_temp[tid][indxJ+1] += A->val[itr_j] * x2[i]; } } @@ -986,7 +880,7 @@ void FixQEqReaxOMP::dual_sparse_matvec( sparse_matrix *A, double *x1, double *x2 for (i = 0; i < NN; ++i) { indxI = 2 * i; for (int t = 0; t < nthreads; ++t) { - b[indxI ] += b_temp[t][indxI ]; + b[indxI] += b_temp[t][indxI]; b[indxI+1] += b_temp[t][indxI+1]; } } @@ -996,7 +890,7 @@ void FixQEqReaxOMP::dual_sparse_matvec( sparse_matrix *A, double *x1, double *x2 /* ---------------------------------------------------------------------- */ -void FixQEqReaxOMP::dual_sparse_matvec( sparse_matrix *A, double *x, double *b ) +void FixQEqReaxFFOMP::dual_sparse_matvec(sparse_matrix *A, double *x, double *b) { #if defined(_OPENMP) #pragma omp parallel default(shared) @@ -1020,8 +914,8 @@ void FixQEqReaxOMP::dual_sparse_matvec( sparse_matrix *A, double *x, double *b ) i = ilist[ii]; if (atom->mask[i] & groupbit) { indxI = 2 * i; - b[indxI ] = eta[ atom->type[i] ] * x[indxI ]; - b[indxI+1] = eta[ atom->type[i] ] * x[indxI+1]; + b[indxI] = eta[atom->type[i]] * x[indxI]; + b[indxI+1] = eta[atom->type[i]] * x[indxI+1]; } } @@ -1043,7 +937,7 @@ void FixQEqReaxOMP::dual_sparse_matvec( sparse_matrix *A, double *x, double *b ) for (i = 0; i < NN; ++i) { indxI = 2 * i; for (int t=0; tfirstnbr[i]; itr_jfirstnbr[i]+A->numnbrs[i]; itr_j++) { j = A->jlist[itr_j]; indxJ = 2 * j; - b[indxI ] += A->val[itr_j] * x[indxJ ]; + b[indxI] += A->val[itr_j] * x[indxJ]; b[indxI+1] += A->val[itr_j] * x[indxJ+1]; - b_temp[tid][indxJ ] += A->val[itr_j] * x[indxI ]; + b_temp[tid][indxJ] += A->val[itr_j] * x[indxI]; b_temp[tid][indxJ+1] += A->val[itr_j] * x[indxI+1]; } } @@ -1077,7 +971,7 @@ void FixQEqReaxOMP::dual_sparse_matvec( sparse_matrix *A, double *x, double *b ) for (i = 0; i < NN; ++i) { indxI = 2 * i; for (int t = 0; t < nthreads; ++t) { - b[indxI ] += b_temp[t][indxI ]; + b[indxI] += b_temp[t][indxI]; b[indxI+1] += b_temp[t][indxI+1]; } } diff --git a/src/OPENMP/fix_qeq_reax_omp.h b/src/OPENMP/fix_qeq_reaxff_omp.h similarity index 84% rename from src/OPENMP/fix_qeq_reax_omp.h rename to src/OPENMP/fix_qeq_reaxff_omp.h index 62855a6f78..b99034edf0 100644 --- a/src/OPENMP/fix_qeq_reax_omp.h +++ b/src/OPENMP/fix_qeq_reaxff_omp.h @@ -13,22 +13,23 @@ #ifdef FIX_CLASS // clang-format off -FixStyle(qeq/reax/omp,FixQEqReaxOMP); +FixStyle(qeq/reaxff/omp,FixQEqReaxFFOMP); +FixStyle(qeq/reax/omp,FixQEqReaxFFOMP); // clang-format on #else -#ifndef LMP_FIX_QEQ_REAX_OMP_H -#define LMP_FIX_QEQ_REAX_OMP_H +#ifndef LMP_FIX_QEQ_REAXFF_OMP_H +#define LMP_FIX_QEQ_REAXFF_OMP_H -#include "fix_qeq_reax.h" +#include "fix_qeq_reaxff.h" namespace LAMMPS_NS { -class FixQEqReaxOMP : public FixQEqReax { +class FixQEqReaxFFOMP : public FixQEqReaxFF { public: - FixQEqReaxOMP(class LAMMPS *, int, char **); - ~FixQEqReaxOMP(); + FixQEqReaxFFOMP(class LAMMPS *, int, char **); + ~FixQEqReaxFFOMP(); virtual void init(); virtual void init_storage(); virtual void pre_force(int); diff --git a/src/OPENMP/pair_reaxc_omp.cpp b/src/OPENMP/pair_reaxc_omp.cpp deleted file mode 100644 index 66e7a77c92..0000000000 --- a/src/OPENMP/pair_reaxc_omp.cpp +++ /dev/null @@ -1,641 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, 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 author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Per-atom energy/virial added by Ray Shan (Materials Design, Inc.) - Fix reax/c/bonds and fix reax/c/species for pair_style reax/c added - by Ray Shan (Materials Design) - - OpenMP based threading support for pair_style reax/c/omp added - by Hasan Metin Aktulga (MSU), Chris Knight (ALCF), Paul Coffman (ALCF), - Kurt O'Hearn (MSU), Ray Shan (Materials Design), Wei Jiang (ALCF) - - Integration of the pair_style reax/c/omp into the OPENMP package - by Axel Kohlmeyer (Temple U.) - - Please cite the related publication: - H. M. Aktulga, C. Knight, P. Coffman, K. A. O'Hearn, T. R. Shan, - W. Jiang, "Optimizing the performance of reactive molecular dynamics - simulations for multi-core architectures", International Journal of - High Performance Computing Applications, to appear. - ------------------------------------------------------------------------- */ - -#include "pair_reaxc_omp.h" - -#include -#include "atom.h" -#include "update.h" -#include "force.h" -#include "comm.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "modify.h" -#include "fix_reaxc.h" -#include "citeme.h" -#include "memory.h" -#include "error.h" - - -#include "reaxc_defs.h" -#include "reaxc_types.h" -#include "reaxc_allocate.h" -#include "reaxc_forces_omp.h" -#include "reaxc_init_md_omp.h" -#include "reaxc_io_tools.h" -#include "reaxc_list.h" -#include "reaxc_reset_tools.h" -#include "reaxc_tool_box.h" - -#if defined(_OPENMP) -#include -#endif - -#include "suffix.h" -using namespace LAMMPS_NS; - -#ifdef OMP_TIMING -double ompTimingData[LASTTIMINGINDEX]; -int ompTimingCount[LASTTIMINGINDEX]; -int ompTimingCGCount[LASTTIMINGINDEX]; -#endif - -static const char cite_pair_reax_c_omp[] = - "pair reax/c/omp and fix qeq/reax/omp command:\n\n" - "@Article{Aktulga17,\n" - " author = {H. M. Aktulga, C. Knight, P. Coffman, K. A. OHearn, T. R. Shan, W. Jiang},\n" - " title = {Optimizing the performance of reactive molecular dynamics simulations for multi-core architectures},\n" - " journal = {International Journal of High Performance Computing Applications},\n" - " year = to appear\n" - "}\n\n"; - -/* ---------------------------------------------------------------------- */ - -PairReaxCOMP::PairReaxCOMP(LAMMPS *lmp) : PairReaxC(lmp), ThrOMP(lmp, THR_PAIR) -{ - if (lmp->citeme) lmp->citeme->add(cite_pair_reax_c_omp); - - suffix_flag |= Suffix::OMP; - system->pair_ptr = this; - system->omp_active = 1; - - num_nbrs_offset = nullptr; - -#ifdef OMP_TIMING - for (int i=0;inum_intrs; ++i) - sfree(error, bonds->select.bond_list[i].bo_data.CdboReduction, "CdboReduction"); - } - memory->destroy(num_nbrs_offset); - -#ifdef OMP_TIMING - int myrank; - - MPI_Comm_rank(mpi_data->world,&myrank); - - // Write screen output - if (timer->has_full() && myrank == 0 && screen) { - fprintf(screen,"\n\nWrite_Lists took %11.3lf seconds", ompTimingData[COMPUTEWLINDEX]); - - fprintf(screen,"\n\nCompute_Forces took %11.3lf seconds:", ompTimingData[COMPUTEINDEX]); - fprintf(screen,"\n ->Initial Forces: %11.3lf seconds", ompTimingData[COMPUTEIFINDEX]); - fprintf(screen,"\n ->Bond Order: %11.3lf seconds", ompTimingData[COMPUTEBOINDEX]); - fprintf(screen,"\n ->Atom Energy: %11.3lf seconds", ompTimingData[COMPUTEATOMENERGYINDEX]); - fprintf(screen,"\n ->Bond: %11.3lf seconds", ompTimingData[COMPUTEBONDSINDEX]); - fprintf(screen,"\n ->Hydrogen bonds: %11.3lf seconds", ompTimingData[COMPUTEHBONDSINDEX]); - fprintf(screen,"\n ->Torsion Angles: %11.3lf seconds", ompTimingData[COMPUTETORSIONANGLESBOINDEX]); - fprintf(screen,"\n ->Valence Angles: %11.3lf seconds", ompTimingData[COMPUTEVALENCEANGLESBOINDEX]); - fprintf(screen,"\n ->Non-Bonded For: %11.3lf seconds", ompTimingData[COMPUTENBFINDEX]); - fprintf(screen,"\n ->Total Forces: %11.3lf seconds", ompTimingData[COMPUTETFINDEX]); - - fprintf(screen,"\n\nfixQEQ: %11.3lf seconds", ompTimingData[COMPUTEQEQINDEX]); - fprintf(screen,"\n ->QEQ init: %11.3lf seconds", ompTimingData[COMPUTEINITMVINDEX]); - - double avg = double(ompTimingCGCount[COMPUTECG1INDEX]) / double(ompTimingCount[COMPUTECG1INDEX]); - fprintf(screen,"\n ->QEQ CG1: %11.3lf seconds with %4.1lf iterations on average.", ompTimingData[COMPUTECG1INDEX], avg); - - avg = double(ompTimingCGCount[COMPUTECG2INDEX]) / double(ompTimingCount[COMPUTECG2INDEX]); - fprintf(screen,"\n ->QEQ CG2: %11.3lf seconds with %4.1lf iterations on average.", ompTimingData[COMPUTECG2INDEX], avg); - fprintf(screen,"\n ->QEQ CalcQ: %11.3lf seconds\n", ompTimingData[COMPUTECALCQINDEX]); - } - - // Write logfile output - if (timer->has_full() && myrank == 0 && logfile) { - fprintf(logfile,"\n\nWrite_Lists took %11.3lf seconds", ompTimingData[COMPUTEWLINDEX]); - - fprintf(logfile,"\n\nCompute_Forces took %11.3lf seconds:", ompTimingData[COMPUTEINDEX]); - fprintf(logfile,"\n ->Initial Forces: %11.3lf seconds", ompTimingData[COMPUTEIFINDEX]); - fprintf(logfile,"\n ->Bond Order: %11.3lf seconds", ompTimingData[COMPUTEBOINDEX]); - fprintf(logfile,"\n ->Atom Energy: %11.3lf seconds", ompTimingData[COMPUTEATOMENERGYINDEX]); - fprintf(logfile,"\n ->Bond: %11.3lf seconds", ompTimingData[COMPUTEBONDSINDEX]); - fprintf(logfile,"\n ->Hydrogen bonds: %11.3lf seconds", ompTimingData[COMPUTEHBONDSINDEX]); - fprintf(logfile,"\n ->Torsion Angles: %11.3lf seconds", ompTimingData[COMPUTETORSIONANGLESBOINDEX]); - fprintf(logfile,"\n ->Valence Angles: %11.3lf seconds", ompTimingData[COMPUTEVALENCEANGLESBOINDEX]); - fprintf(logfile,"\n ->Non-Bonded For: %11.3lf seconds", ompTimingData[COMPUTENBFINDEX]); - fprintf(logfile,"\n ->Total Forces: %11.3lf seconds", ompTimingData[COMPUTETFINDEX]); - - fprintf(logfile,"\n\nfixQEQ: %11.3lf seconds", ompTimingData[COMPUTEQEQINDEX]); - fprintf(logfile,"\n ->QEQ init: %11.3lf seconds", ompTimingData[COMPUTEINITMVINDEX]); - - double avg = double(ompTimingCGCount[COMPUTECG1INDEX]) / double(ompTimingCount[COMPUTECG1INDEX]); - fprintf(logfile,"\n ->QEQ CG1: %11.3lf seconds with %4.1lf iterations on average.", ompTimingData[COMPUTECG1INDEX], avg); - - avg = double(ompTimingCGCount[COMPUTECG2INDEX]) / double(ompTimingCount[COMPUTECG2INDEX]); - fprintf(logfile,"\n ->QEQ CG2: %11.3lf seconds with %4.1lf iterations on average.", ompTimingData[COMPUTECG2INDEX], avg); - fprintf(logfile,"\n ->QEQ CalcQ: %11.3lf seconds\n", ompTimingData[COMPUTECALCQINDEX]); - } -#endif -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxCOMP::compute(int eflag, int vflag) -{ - double evdwl,ecoul; - double t_start, t_end; - - // communicate num_bonds once every reneighboring - // 2 num arrays stored by fix, grab ptr to them - - if (neighbor->ago == 0) comm->forward_comm_fix(fix_reax); - int *num_bonds = fix_reax->num_bonds; - int *num_hbonds = fix_reax->num_hbonds; - - evdwl = ecoul = 0.0; - ev_init(eflag,vflag); - - if (vflag_global) control->virial = 1; - else control->virial = 0; - - if (vflag_atom) - error->all(FLERR,"Pair style reax/c/omp does not support " - "computing per-atom stress"); - - system->n = atom->nlocal; // my atoms - system->N = atom->nlocal + atom->nghost; // mine + ghosts - system->bigN = static_cast (atom->natoms); // all atoms in the system - - system->big_box.V = 0; - system->big_box.box_norms[0] = 0; - system->big_box.box_norms[1] = 0; - system->big_box.box_norms[2] = 0; - if (comm->me == 0 ) t_start = MPI_Wtime(); - // setup data structures - - setup(); - - Reset( system, control, data, workspace, &lists ); - - // Why not update workspace like in MPI-only code? - // Using the MPI-only way messes up the hb energy - //workspace->realloc.num_far = write_reax_lists(); - write_reax_lists(); - - // timing for filling in the reax lists - if (comm->me == 0) { - t_end = MPI_Wtime(); - data->timing.nbrs = t_end - t_start; - } - - // forces - -#ifdef OMP_TIMING - double startTimeBase,endTimeBase; - startTimeBase = MPI_Wtime(); -#endif - - Compute_ForcesOMP(system,control,data,workspace,&lists,out_control,mpi_data); - read_reax_forces(vflag); - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTEINDEX] += (endTimeBase-startTimeBase); -#endif - -#if defined(_OPENMP) -#pragma omp parallel for schedule(static) -#endif - for (int k = 0; k < system->N; ++k) { - num_bonds[k] = system->my_atoms[k].num_bonds; - num_hbonds[k] = system->my_atoms[k].num_hbonds; - } - - // energies and pressure - - if (eflag_global) { - evdwl += data->my_en.e_bond; - evdwl += data->my_en.e_ov; - evdwl += data->my_en.e_un; - evdwl += data->my_en.e_lp; - evdwl += data->my_en.e_ang; - evdwl += data->my_en.e_pen; - evdwl += data->my_en.e_coa; - evdwl += data->my_en.e_hb; - evdwl += data->my_en.e_tor; - evdwl += data->my_en.e_con; - evdwl += data->my_en.e_vdW; - - ecoul += data->my_en.e_ele; - ecoul += data->my_en.e_pol; - - // Store the different parts of the energy - // in a list for output by compute pair command - - pvector[0] = data->my_en.e_bond; - pvector[1] = data->my_en.e_ov + data->my_en.e_un; - pvector[2] = data->my_en.e_lp; - pvector[3] = 0.0; - pvector[4] = data->my_en.e_ang; - pvector[5] = data->my_en.e_pen; - pvector[6] = data->my_en.e_coa; - pvector[7] = data->my_en.e_hb; - pvector[8] = data->my_en.e_tor; - pvector[9] = data->my_en.e_con; - pvector[10] = data->my_en.e_vdW; - pvector[11] = data->my_en.e_ele; - pvector[12] = 0.0; - pvector[13] = data->my_en.e_pol; - } - - if (vflag_fdotr) virial_fdotr_compute(); - - // Set internal timestep counter to that of LAMMPS - - data->step = update->ntimestep; - - Output_Results( system, control, data, &lists, out_control, mpi_data ); - - // populate tmpid and tmpbo arrays for fix reax/c/species - - if (fixspecies_flag) { - if (system->N > nmax) { - memory->destroy(tmpid); - memory->destroy(tmpbo); - nmax = system->N; - memory->create(tmpid,nmax,MAXSPECBOND,"pair:tmpid"); - memory->create(tmpbo,nmax,MAXSPECBOND,"pair:tmpbo"); - } - -#if defined(_OPENMP) -#pragma omp parallel for collapse(2) schedule(static) default(shared) -#endif - for (int i = 0; i < system->N; i++) - for (int j = 0; j < MAXSPECBOND; j++) { - tmpbo[i][j] = 0.0; - tmpid[i][j] = 0; - } - - FindBond(); - } -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxCOMP::init_style( ) -{ - if (!atom->q_flag) - error->all(FLERR,"Pair reax/c/omp requires atom attribute q"); - - // firstwarn = 1; - - bool have_qeq = ((modify->find_fix_by_style("^qeq/reax") != -1) - || (modify->find_fix_by_style("^qeq/shielded") != -1)); - if (!have_qeq && qeqflag == 1) - error->all(FLERR,"Pair reax/c requires use of fix qeq/reax or qeq/shielded"); - - system->n = atom->nlocal; // my atoms - system->N = atom->nlocal + atom->nghost; // mine + ghosts - system->bigN = static_cast (atom->natoms); // all atoms in the system - system->wsize = comm->nprocs; - - system->big_box.V = 0; - system->big_box.box_norms[0] = 0; - system->big_box.box_norms[1] = 0; - system->big_box.box_norms[2] = 0; - - if (atom->tag_enable == 0) - error->all(FLERR,"Pair style reax/c/omp requires atom IDs"); - if (force->newton_pair == 0) - error->all(FLERR,"Pair style reax/c/omp requires newton pair on"); - - if ((atom->map_tag_max > 99999999) && (comm->me == 0)) - error->warning(FLERR,"Some Atom-IDs are too large. Pair style reax/c/omp " - "native output files may get misformatted or corrupted"); - - // because system->bigN is an int, we cannot have more atoms than MAXSMALLINT - - if (atom->natoms > MAXSMALLINT) - error->all(FLERR,"Too many atoms for pair style reax/c/omp"); - - // need a half neighbor list w/ Newton off and ghost neighbors - // built whenever re-neighboring occurs - - int irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->newton = 2; - neighbor->requests[irequest]->ghost = 1; - - cutmax = MAX3(control->nonb_cut, control->hbond_cut, control->bond_cut); - if ((cutmax < 2.0*control->bond_cut) && (comm->me == 0)) - error->warning(FLERR,"Total cutoff < 2*bond cutoff. May need to use an " - "increased neighbor list skin."); - - for (int i = 0; i < LIST_N; ++i) - lists[i].allocated = 0; - - if (fix_reax == nullptr) { - char **fixarg = new char*[3]; - fixarg[0] = (char *) fix_id; - fixarg[1] = (char *) "all"; - fixarg[2] = (char *) "REAXC"; - modify->add_fix(3,fixarg); - delete [] fixarg; - fix_reax = (FixReaxC *) modify->fix[modify->nfix-1]; - } - -#if defined(_OPENMP) - control->nthreads = omp_get_max_threads(); -#else - control->nthreads = 1; -#endif -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxCOMP::setup( ) -{ - int oldN; - int mincap = system->mincap; - double safezone = system->safezone; - - system->n = atom->nlocal; // my atoms - system->N = atom->nlocal + atom->nghost; // mine + ghosts - oldN = system->N; - system->bigN = static_cast (atom->natoms); // all atoms in the system - - if (system->N > nmax) { - memory->destroy(num_nbrs_offset); - // Don't update nmax here. It is updated at end of compute(). - memory->create(num_nbrs_offset, system->N, "pair:num_nbrs_offset"); - } - - if (setup_flag == 0) { - - setup_flag = 1; - - int *num_bonds = fix_reax->num_bonds; - int *num_hbonds = fix_reax->num_hbonds; - - control->vlist_cut = neighbor->cutneighmax; - - // determine the local and total capacity - - system->local_cap = MAX( (int)(system->n * safezone), mincap ); - system->total_cap = MAX( (int)(system->N * safezone), mincap ); - - // initialize my data structures - - PreAllocate_Space( system, control, workspace ); - write_reax_atoms(); - - int num_nbrs = estimate_reax_lists(); - if (!Make_List(system->total_cap, num_nbrs, TYP_FAR_NEIGHBOR, - lists+FAR_NBRS)) - error->all(FLERR,"Pair reax/c problem in far neighbor list"); - - write_reax_lists(); - - InitializeOMP( system, control, data, workspace, &lists, out_control, - mpi_data, world ); - - for (int k = 0; k < system->N; ++k) { - num_bonds[k] = system->my_atoms[k].num_bonds; - num_hbonds[k] = system->my_atoms[k].num_hbonds; - } - - } else { - - // fill in reax datastructures - - write_reax_atoms(); - - // reset the bond list info for new atoms - - for (int k = oldN; k < system->N; ++k) - Set_End_Index( k, Start_Index( k, lists+BONDS ), lists+BONDS ); - - // estimate far neighbor list size - // Not present in MPI-only version - workspace->realloc.num_far = estimate_reax_lists(); - - // check if I need to shrink/extend my data-structs - - ReAllocate( system, control, data, workspace, &lists ); - } -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxCOMP::write_reax_atoms() -{ - int *num_bonds = fix_reax->num_bonds; - int *num_hbonds = fix_reax->num_hbonds; - - if (system->N > system->total_cap) - error->all(FLERR,"Too many ghost atoms"); - -#if defined(_OPENMP) -#pragma omp parallel for schedule(static) default(shared) -#endif - for (int i = 0; i < system->N; ++i) { - system->my_atoms[i].orig_id = atom->tag[i]; - system->my_atoms[i].type = map[atom->type[i]]; - system->my_atoms[i].x[0] = atom->x[i][0]; - system->my_atoms[i].x[1] = atom->x[i][1]; - system->my_atoms[i].x[2] = atom->x[i][2]; - system->my_atoms[i].q = atom->q[i]; - system->my_atoms[i].num_bonds = num_bonds[i]; - system->my_atoms[i].num_hbonds = num_hbonds[i]; - } -} - -/* ---------------------------------------------------------------------- */ - -int PairReaxCOMP::estimate_reax_lists() -{ - int i; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int numall = list->inum + list->gnum; - int mincap = system->mincap; - - // for good performance in the OpenMP implementation, each thread needs - // to know where to place the neighbors of the atoms it is responsible for. - // The sumscan values for the list->numneigh will be used to determine the - // neighbor offset of each atom. Note that this may cause some significant - // memory overhead if delayed neighboring is used - so it may be desirable - // to work on this part to reduce the memory footprint of the far_nbrs list. - - int num_nbrs = 0; - - for (int itr_i = 0; itr_i < numall; ++itr_i) { - i = ilist[itr_i]; - num_nbrs += numneigh[i]; - } - - int new_estimate = MAX(num_nbrs, mincap*REAX_MIN_NBRS); - - return new_estimate; -} - -/* ---------------------------------------------------------------------- */ - -int PairReaxCOMP::write_reax_lists() -{ -#ifdef OMP_TIMING - double startTimeBase, endTimeBase; - startTimeBase = MPI_Wtime(); -#endif - - int itr_i, itr_j, i, j, num_mynbrs; - int *jlist; - double d_sqr, dist, cutoff_sqr; - rvec dvec; - - double **x = atom->x; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - reax_list *far_nbrs = lists + FAR_NBRS; - far_neighbor_data *far_list = far_nbrs->select.far_nbr_list; - - int num_nbrs = 0; - int inum = list->inum; - int gnum = list->gnum; - int numall = inum + gnum; - - // sumscan of the number of neighbors per atom to determine the offsets - // most likely, we are overallocating. desirable to work on this part - // to reduce the memory footprint of the far_nbrs list. - - num_nbrs = 0; - - for (itr_i = 0; itr_i < numall; ++itr_i) { - i = ilist[itr_i]; - num_nbrs_offset[i] = num_nbrs; - num_nbrs += numneigh[i]; - } - -#if defined(_OPENMP) -#pragma omp parallel for schedule(dynamic,50) default(shared) \ - private(itr_i, itr_j, i, j, jlist, cutoff_sqr, num_mynbrs, d_sqr, dvec, dist) -#endif - for (itr_i = 0; itr_i < numall; ++itr_i) { - i = ilist[itr_i]; - jlist = firstneigh[i]; - Set_Start_Index( i, num_nbrs_offset[i], far_nbrs ); - - if (i < inum) - cutoff_sqr = control->nonb_cut*control->nonb_cut; - else - cutoff_sqr = control->bond_cut*control->bond_cut; - - num_mynbrs = 0; - - for (itr_j = 0; itr_j < numneigh[i]; ++itr_j) { - j = jlist[itr_j]; - j &= NEIGHMASK; - get_distance( x[j], x[i], &d_sqr, &dvec ); - - if (d_sqr <= cutoff_sqr) { - dist = sqrt( d_sqr ); - set_far_nbr( &far_list[num_nbrs_offset[i] + num_mynbrs], j, dist, dvec ); - ++num_mynbrs; - } - } - Set_End_Index( i, num_nbrs_offset[i] + num_mynbrs, far_nbrs ); - } - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTEWLINDEX] += (endTimeBase-startTimeBase); -#endif - - return num_nbrs; -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxCOMP::read_reax_forces(int /* vflag */) -{ -#if defined(_OPENMP) -#pragma omp parallel for schedule(static) default(shared) -#endif - for (int i = 0; i < system->N; ++i) { - system->my_atoms[i].f[0] = workspace->f[i][0]; - system->my_atoms[i].f[1] = workspace->f[i][1]; - system->my_atoms[i].f[2] = workspace->f[i][2]; - - atom->f[i][0] = -workspace->f[i][0]; - atom->f[i][1] = -workspace->f[i][1]; - atom->f[i][2] = -workspace->f[i][2]; - } -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxCOMP::FindBond() -{ - const double bo_cut = 0.10; - -#if defined(_OPENMP) -#pragma omp parallel for schedule(static) default(shared) -#endif - for (int i = 0; i < system->n; i++) { - int j, pj, nj; - double bo_tmp; - bond_data *bo_ij; - - nj = 0; - for (pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj) { - bo_ij = &( lists->select.bond_list[pj] ); - j = bo_ij->nbr; - if (j < i) continue; - - bo_tmp = bo_ij->bo_data.BO; - - if (bo_tmp >= bo_cut) { - tmpid[i][nj] = j; - tmpbo[i][nj] = bo_tmp; - nj ++; - if (nj > MAXSPECBOND) error->all(FLERR,"Increase MAXSPECBOND in fix_reaxc_species.h"); - } - } - } -} diff --git a/src/OPENMP/pair_reaxff_omp.cpp b/src/OPENMP/pair_reaxff_omp.cpp new file mode 100644 index 0000000000..69d68e67e8 --- /dev/null +++ b/src/OPENMP/pair_reaxff_omp.cpp @@ -0,0 +1,535 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, 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 author: + Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu + + Per-atom energy/virial added by Ray Shan (Materials Design, Inc.) + Fix reaxff/bonds and fix reaxff/species for pair_style reaxff added + by Ray Shan (Materials Design) + + OpenMP based threading support for pair_style reaxff/omp added + by Hasan Metin Aktulga (MSU), Chris Knight (ALCF), Paul Coffman (ALCF), + Kurt O'Hearn (MSU), Ray Shan (Materials Design), Wei Jiang (ALCF) + + Integration of the pair_style reaxff/omp into the OPENMP package + by Axel Kohlmeyer (Temple U.) + + Please cite the related publication: + H. M. Aktulga, C. Knight, P. Coffman, K. A. O'Hearn, T. R. Shan, + W. Jiang, "Optimizing the performance of reactive molecular dynamics + simulations for multi-core architectures", International Journal of + High Performance Computing Applications, to appear. + ------------------------------------------------------------------------- */ + +#include "pair_reaxff_omp.h" + +#include "atom.h" +#include "citeme.h" +#include "comm.h" +#include "error.h" +#include "fix_reaxff.h" +#include "force.h" +#include "memory.h" +#include "modify.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "update.h" + +#include + +#include "reaxff_api.h" +#include "reaxff_omp.h" + +#if defined(_OPENMP) +#include +#endif + +#include "omp_compat.h" +#include "suffix.h" +using namespace LAMMPS_NS; +using namespace ReaxFF; + +static const char cite_pair_reaxff_omp[] = + "pair reaxff/omp and fix qeq/reaxff/omp command:\n\n" + "@Article{Aktulga17,\n" + " author = {H. M. Aktulga, C. Knight, P. Coffman, K. A. OHearn, T. R. Shan, W. Jiang},\n" + " title = {Optimizing the performance of reactive molecular dynamics simulations for multi-core architectures},\n" + " journal = {International Journal of High Performance Computing Applications},\n" + " year = to appear\n" + "}\n\n"; + +/* ---------------------------------------------------------------------- */ + +PairReaxFFOMP::PairReaxFFOMP(LAMMPS *lmp) : PairReaxFF(lmp), ThrOMP(lmp, THR_PAIR) +{ + if (lmp->citeme) lmp->citeme->add(cite_pair_reaxff_omp); + + suffix_flag |= Suffix::OMP; + api->system->pair_ptr = this; + api->system->omp_active = 1; + + num_nbrs_offset = nullptr; +} + +/* ---------------------------------------------------------------------- */ + +PairReaxFFOMP::~PairReaxFFOMP() +{ + if (setup_flag) { + reax_list * bonds = api->lists+BONDS; + for (int i=0; inum_intrs; ++i) + sfree(error, bonds->select.bond_list[i].bo_data.CdboReduction, "CdboReduction"); + } + memory->destroy(num_nbrs_offset); +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFFOMP::init_style() +{ + if (!atom->q_flag) + error->all(FLERR,"Pair style reaxff/omp requires atom attribute q"); + + bool have_qeq = ((modify->find_fix_by_style("^qeq/reax") != -1) + || (modify->find_fix_by_style("^qeq/shielded") != -1)); + if (!have_qeq && qeqflag == 1) + error->all(FLERR,"Pair reaxff/omp requires use of fix qeq/reaxff or qeq/shielded"); + + api->system->n = atom->nlocal; // my atoms + api->system->N = atom->nlocal + atom->nghost; // mine + ghosts + api->system->bigN = static_cast (atom->natoms); // all atoms in the system + api->system->wsize = comm->nprocs; + + if (atom->tag_enable == 0) + error->all(FLERR,"Pair style reaxff/omp requires atom IDs"); + if (force->newton_pair == 0) + error->all(FLERR,"Pair style reaxff/omp requires newton pair on"); + + // because system->bigN is an int, we cannot have more atoms than MAXSMALLINT + + if (atom->natoms > MAXSMALLINT) + error->all(FLERR,"Too many atoms for pair style reaxff/omp"); + + // need a half neighbor list w/ Newton off and ghost neighbors + // built whenever re-neighboring occurs + + int irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->newton = 2; + neighbor->requests[irequest]->ghost = 1; + + cutmax = MAX3(api->control->nonb_cut, api->control->hbond_cut, api->control->bond_cut); + if ((cutmax < 2.0*api->control->bond_cut) && (comm->me == 0)) + error->warning(FLERR,"Total cutoff < 2*bond cutoff. May need to use an " + "increased neighbor list skin."); + + if (fix_reaxff == nullptr) { + modify->add_fix(fmt::format("{} all REAXFF",fix_id)); + fix_reaxff = (FixReaxFF *) modify->fix[modify->nfix-1]; + } + + api->control->nthreads = comm->nthreads; +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFFOMP::setup() +{ + int oldN; + int mincap = api->system->mincap; + double safezone = api->system->safezone; + + api->system->n = atom->nlocal; // my atoms + api->system->N = atom->nlocal + atom->nghost; // mine + ghosts + oldN = api->system->N; + api->system->bigN = static_cast (atom->natoms); // all atoms in the system + + if (api->system->N > nmax) { + memory->destroy(num_nbrs_offset); + // Don't update nmax here. It is updated at end of compute(). + memory->create(num_nbrs_offset, api->system->N, "pair:num_nbrs_offset"); + } + + if (setup_flag == 0) { + + setup_flag = 1; + + int *num_bonds = fix_reaxff->num_bonds; + int *num_hbonds = fix_reaxff->num_hbonds; + + // determine the local and total capacity + + api->system->local_cap = MAX((int)(api->system->n * safezone), mincap); + api->system->total_cap = MAX((int)(api->system->N * safezone), mincap); + + // initialize my data structures + + PreAllocate_Space(api->system, api->workspace); + write_reax_atoms(); + + api->system->wsize = comm->nprocs; + + int num_nbrs = estimate_reax_lists(); + if (num_nbrs < 0) + error->all(FLERR,"Too many neighbors for pair style reaxff"); + + Make_List(api->system->total_cap,num_nbrs,TYP_FAR_NEIGHBOR,api->lists+FAR_NBRS); + (api->lists+FAR_NBRS)->error_ptr=error; + + write_reax_lists(); + + InitializeOMP(api->system,api->control,api->data,api->workspace,&api->lists,world); + for (int k = 0; k < api->system->N; ++k) { + num_bonds[k] = api->system->my_atoms[k].num_bonds; + num_hbonds[k] = api->system->my_atoms[k].num_hbonds; + } + + } else { + + // fill in reax datastructures + + write_reax_atoms(); + + // reset the bond list info for new atoms + + for (int k = oldN; k < api->system->N; ++k) + Set_End_Index(k, Start_Index(k, api->lists+BONDS), api->lists+BONDS); + + // estimate far neighbor list size + // Not present in MPI-only version + api->workspace->realloc.num_far = estimate_reax_lists(); + + // check if I need to shrink/extend my data-structs + + ReAllocate(api->system, api->control, api->data, api->workspace, &api->lists); + } +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFFOMP::compute(int eflag, int vflag) +{ + double evdwl,ecoul; + + // communicate num_bonds once every reneighboring + // 2 num arrays stored by fix, grab ptr to them + + if (neighbor->ago == 0) comm->forward_comm_fix(fix_reaxff); + int *num_bonds = fix_reaxff->num_bonds; + int *num_hbonds = fix_reaxff->num_hbonds; + + evdwl = ecoul = 0.0; + ev_init(eflag,vflag); + + api->system->n = atom->nlocal; // my atoms + api->system->N = atom->nlocal + atom->nghost; // mine + ghosts + api->system->bigN = static_cast (atom->natoms); // all atoms in the system + const int nall = api->system->N; + +#if defined(_OPENMP) +#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(eflag,vflag) +#endif + { +#if defined(_OPENMP) + int tid = omp_get_thread_num(); +#else + int tid = 0; +#endif + ThrData *thr = fix->get_thr(tid); + thr->timer(Timer::START); + ev_setup_thr(eflag, vflag, api->system->N, eatom, vatom, nullptr, thr); + } + // setup data structures + + setup(); + + Reset(api->system, api->control, api->data, api->workspace, &api->lists); + + // Why not update workspace like in MPI-only code? + // Using the MPI-only way messes up the hb energy + //workspace->realloc.num_far = write_reax_lists(); + write_reax_lists(); + + // forces + + Compute_ForcesOMP(api->system,api->control,api->data,api->workspace,&api->lists); + read_reax_forces(vflag); + + const int nthreads = comm->nthreads; +#if defined(_OPENMP) +#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(vflag) +#endif + { +#if defined(_OPENMP) + int tid = omp_get_thread_num(); +#else + int tid = 0; +#endif + ThrData *thr = fix->get_thr(tid); + thr->timer(Timer::PAIR); + + // the pair style reduces energy and forces directly. so only reduce virial/ + // per-atom virial and per-atom centroid virial are the same for two-body + // many-body pair styles not yet implemented + if (vflag & (VIRIAL_ATOM | VIRIAL_CENTROID)) { + data_reduce_thr(&(vatom[0][0]), nall , nthreads, 6, tid); + } + } + +#if defined(_OPENMP) +#pragma omp parallel for schedule(static) +#endif + for (int k = 0; k < api->system->N; ++k) { + num_bonds[k] = api->system->my_atoms[k].num_bonds; + num_hbonds[k] = api->system->my_atoms[k].num_hbonds; + } + + // energies and pressure + + if (eflag_global) { + evdwl += api->data->my_en.e_bond; + evdwl += api->data->my_en.e_ov; + evdwl += api->data->my_en.e_un; + evdwl += api->data->my_en.e_lp; + evdwl += api->data->my_en.e_ang; + evdwl += api->data->my_en.e_pen; + evdwl += api->data->my_en.e_coa; + evdwl += api->data->my_en.e_hb; + evdwl += api->data->my_en.e_tor; + evdwl += api->data->my_en.e_con; + evdwl += api->data->my_en.e_vdW; + + ecoul += api->data->my_en.e_ele; + ecoul += api->data->my_en.e_pol; + + // Store the different parts of the energy + // in a list for output by compute pair command + + pvector[0] = api->data->my_en.e_bond; + pvector[1] = api->data->my_en.e_ov + api->data->my_en.e_un; + pvector[2] = api->data->my_en.e_lp; + pvector[3] = 0.0; + pvector[4] = api->data->my_en.e_ang; + pvector[5] = api->data->my_en.e_pen; + pvector[6] = api->data->my_en.e_coa; + pvector[7] = api->data->my_en.e_hb; + pvector[8] = api->data->my_en.e_tor; + pvector[9] = api->data->my_en.e_con; + pvector[10] = api->data->my_en.e_vdW; + pvector[11] = api->data->my_en.e_ele; + pvector[12] = 0.0; + pvector[13] = api->data->my_en.e_pol; + } + + if (vflag_fdotr) virial_fdotr_compute(); + + // Set internal timestep counter to that of LAMMPS + + api->data->step = update->ntimestep; + + // populate tmpid and tmpbo arrays for fix reaxff/species + + if (fixspecies_flag) { + if (api->system->N > nmax) { + memory->destroy(tmpid); + memory->destroy(tmpbo); + nmax = api->system->N; + memory->create(tmpid,nmax,MAXSPECBOND,"pair:tmpid"); + memory->create(tmpbo,nmax,MAXSPECBOND,"pair:tmpbo"); + } + +#if defined(_OPENMP) +#pragma omp parallel for collapse(2) schedule(static) default(shared) +#endif + for (int i = 0; i < api->system->N; i++) + for (int j = 0; j < MAXSPECBOND; j++) { + tmpbo[i][j] = 0.0; + tmpid[i][j] = 0; + } + + FindBond(); + } +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFFOMP::write_reax_atoms() +{ + int *num_bonds = fix_reaxff->num_bonds; + int *num_hbonds = fix_reaxff->num_hbonds; + + if (api->system->N > api->system->total_cap) + error->all(FLERR,"Too many ghost atoms"); + +#if defined(_OPENMP) +#pragma omp parallel for schedule(static) default(shared) +#endif + for (int i = 0; i < api->system->N; ++i) { + api->system->my_atoms[i].orig_id = atom->tag[i]; + api->system->my_atoms[i].type = map[atom->type[i]]; + api->system->my_atoms[i].x[0] = atom->x[i][0]; + api->system->my_atoms[i].x[1] = atom->x[i][1]; + api->system->my_atoms[i].x[2] = atom->x[i][2]; + api->system->my_atoms[i].q = atom->q[i]; + api->system->my_atoms[i].num_bonds = num_bonds[i]; + api->system->my_atoms[i].num_hbonds = num_hbonds[i]; + } +} + +/* ---------------------------------------------------------------------- */ + +int PairReaxFFOMP::estimate_reax_lists() +{ + int i; + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int numall = list->inum + list->gnum; + int mincap = api->system->mincap; + + // for good performance in the OpenMP implementation, each thread needs + // to know where to place the neighbors of the atoms it is responsible for. + // The sumscan values for the list->numneigh will be used to determine the + // neighbor offset of each atom. Note that this may cause some significant + // memory overhead if delayed neighboring is used - so it may be desirable + // to work on this part to reduce the memory footprint of the far_nbrs list. + + int num_nbrs = 0; + + for (int itr_i = 0; itr_i < numall; ++itr_i) { + i = ilist[itr_i]; + num_nbrs += numneigh[i]; + } + + int new_estimate = MAX(num_nbrs, mincap*REAX_MIN_NBRS); + + return new_estimate; +} + +/* ---------------------------------------------------------------------- */ + +int PairReaxFFOMP::write_reax_lists() +{ + int itr_i, itr_j, i, j, num_mynbrs; + int *jlist; + double d_sqr, dist, cutoff_sqr; + rvec dvec; + + double **x = atom->x; + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + reax_list *far_nbrs = api->lists + FAR_NBRS; + far_neighbor_data *far_list = far_nbrs->select.far_nbr_list; + + int num_nbrs = 0; + int inum = list->inum; + int gnum = list->gnum; + int numall = inum + gnum; + + // sumscan of the number of neighbors per atom to determine the offsets + // most likely, we are overallocating. desirable to work on this part + // to reduce the memory footprint of the far_nbrs list. + + num_nbrs = 0; + + for (itr_i = 0; itr_i < numall; ++itr_i) { + i = ilist[itr_i]; + num_nbrs_offset[i] = num_nbrs; + num_nbrs += numneigh[i]; + } + +#if defined(_OPENMP) +#pragma omp parallel for schedule(dynamic,50) default(shared) \ + private(itr_i, itr_j, i, j, jlist, cutoff_sqr, num_mynbrs, d_sqr, dvec, dist) +#endif + for (itr_i = 0; itr_i < numall; ++itr_i) { + i = ilist[itr_i]; + jlist = firstneigh[i]; + Set_Start_Index(i, num_nbrs_offset[i], far_nbrs); + + if (i < inum) + cutoff_sqr = SQR(api->control->nonb_cut); + else + cutoff_sqr = SQR(api->control->bond_cut); + + num_mynbrs = 0; + + for (itr_j = 0; itr_j < numneigh[i]; ++itr_j) { + j = jlist[itr_j]; + j &= NEIGHMASK; + get_distance(x[j], x[i], &d_sqr, &dvec); + + if (d_sqr <= cutoff_sqr) { + dist = sqrt(d_sqr); + set_far_nbr(&far_list[num_nbrs_offset[i] + num_mynbrs], j, dist, dvec); + ++num_mynbrs; + } + } + Set_End_Index(i, num_nbrs_offset[i] + num_mynbrs, far_nbrs); + } + + return num_nbrs; +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFFOMP::read_reax_forces(int /* vflag */) +{ +#if defined(_OPENMP) +#pragma omp parallel for schedule(static) default(shared) +#endif + for (int i = 0; i < api->system->N; ++i) { + api->system->my_atoms[i].f[0] = api->workspace->f[i][0]; + api->system->my_atoms[i].f[1] = api->workspace->f[i][1]; + api->system->my_atoms[i].f[2] = api->workspace->f[i][2]; + + atom->f[i][0] = -api->workspace->f[i][0]; + atom->f[i][1] = -api->workspace->f[i][1]; + atom->f[i][2] = -api->workspace->f[i][2]; + } +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFFOMP::FindBond() +{ + const double bo_cut = 0.10; + +#if defined(_OPENMP) +#pragma omp parallel for schedule(static) default(shared) +#endif + for (int i = 0; i < api->system->n; i++) { + int j, pj, nj; + double bo_tmp; + bond_data *bo_ij; + + nj = 0; + for (pj = Start_Index(i, api->lists); pj < End_Index(i, api->lists); ++pj) { + bo_ij = &(api->lists->select.bond_list[pj]); + j = bo_ij->nbr; + if (j < i) continue; + + bo_tmp = bo_ij->bo_data.BO; + + if (bo_tmp >= bo_cut) { + tmpid[i][nj] = j; + tmpbo[i][nj] = bo_tmp; + nj ++; + if (nj > MAXSPECBOND) error->all(FLERR,"Increase MAXSPECBOND in fix_reaxff_species.h"); + } + } + } +} diff --git a/src/OPENMP/pair_reaxc_omp.h b/src/OPENMP/pair_reaxff_omp.h similarity index 62% rename from src/OPENMP/pair_reaxc_omp.h rename to src/OPENMP/pair_reaxff_omp.h index 895dc646af..cced5861be 100644 --- a/src/OPENMP/pair_reaxc_omp.h +++ b/src/OPENMP/pair_reaxff_omp.h @@ -13,22 +13,23 @@ #ifdef PAIR_CLASS // clang-format off -PairStyle(reax/c/omp,PairReaxCOMP); +PairStyle(reaxff/omp,PairReaxFFOMP); +PairStyle(reax/c/omp,PairReaxFFOMP); // clang-format on #else -#ifndef LMP_PAIR_REAXC_OMP_H -#define LMP_PAIR_REAXC_OMP_H +#ifndef LMP_PAIR_REAXFF_OMP_H +#define LMP_PAIR_REAXFF_OMP_H -#include "pair_reaxc.h" +#include "pair_reaxff.h" #include "thr_omp.h" namespace LAMMPS_NS { -class PairReaxCOMP : public PairReaxC, public ThrOMP { +class PairReaxFFOMP : public PairReaxFF, public ThrOMP { public: - PairReaxCOMP(class LAMMPS *); - ~PairReaxCOMP(); + PairReaxFFOMP(class LAMMPS *); + ~PairReaxFFOMP(); virtual void compute(int, int); virtual void init_style(); @@ -47,33 +48,55 @@ class PairReaxCOMP : public PairReaxC, public ThrOMP { reduce_thr(styleparm, eflagparm, vflagparm, thrparm); } - inline void ev_tally_thr_proxy(Pair *const pairparm, const int iparm, const int jparm, + inline void ev_tally_thr_proxy(const int iparm, const int jparm, const int nlocalparm, const int newton_pairparm, const double evdwlparm, const double ecoulparm, const double fpairparm, const double delxparm, const double delyparm, const double delzparm, ThrData *const thrparm) { - ev_tally_thr(pairparm, iparm, jparm, nlocalparm, newton_pairparm, evdwlparm, ecoulparm, + ev_tally_thr(this, iparm, jparm, nlocalparm, newton_pairparm, evdwlparm, ecoulparm, fpairparm, delxparm, delyparm, delzparm, thrparm); } - inline void ev_tally_xyz_thr_proxy(Pair *const pairparm, const int iparm, const int jparm, + inline void ev_tally_xyz_thr_proxy(const int iparm, const int jparm, const int nlocalparm, const int newton_pairparm, const double evdwlparm, const double ecoulparm, const double fxparm, const double fyparm, const double fzparm, const double delxparm, const double delyparm, const double delzparm, ThrData *const thrparm) { - ev_tally_xyz_thr(pairparm, iparm, jparm, nlocalparm, newton_pairparm, evdwlparm, ecoulparm, + ev_tally_xyz_thr(this, iparm, jparm, nlocalparm, newton_pairparm, evdwlparm, ecoulparm, fxparm, fyparm, fzparm, delxparm, delyparm, delzparm, thrparm); } - inline void ev_tally3_thr_proxy(Pair *const pairparm, int i, int j, int k, double evdwl, + inline void ev_tally3_thr_proxy(int i, int j, int k, double evdwl, double ecoul, double *fj, double *fk, double *drji, double *drki, ThrData *const thrparm) { - ev_tally3_thr(pairparm, i, j, k, evdwl, ecoul, fj, fk, drji, drki, thrparm); + ev_tally3_thr(this, i, j, k, evdwl, ecoul, fj, fk, drji, drki, thrparm); + } + + inline void v_tally2_newton_thr_proxy(const int i, const double *const fi, + const double *const deli, ThrData *const thrparm) + { + v_tally2_newton_thr(this, i, fi, deli, thrparm); + } + + inline void v_tally3_thr_proxy(const int i, const int j, const int k, const double *const fi, + const double *const fk, const double *const drij, + const double *const drkj, ThrData *const thrparm) + { + v_tally3_thr(this, i, j, k, fi, fk, drij, drkj, thrparm); + } + + inline void v_tally4_thr_proxy(const int i, const int j, const int k, const int l, + const double *const fi, const double *const fj, + const double *const fk, const double *const dril, + const double *const drjl, const double *const drkl, + ThrData *const thrparm) + { + v_tally4_thr(this, i, j, k, l, fi, fj, fk, dril, drjl, drkl, thrparm); } protected: @@ -98,7 +121,7 @@ class PairReaxCOMP : public PairReaxC, public ThrOMP { E: Too many ghost atoms Number of ghost atoms has increased too much during simulation and has exceeded -the size of reax/c arrays. Increase safe_zone and min_cap in pair_style reax/c +the size of reaxff arrays. Increase safe_zone and min_cap in pair_style reaxff command */ diff --git a/src/OPENMP/reaxc_bond_orders_omp.cpp b/src/OPENMP/reaxc_bond_orders_omp.cpp deleted file mode 100644 index ec94baced5..0000000000 --- a/src/OPENMP/reaxc_bond_orders_omp.cpp +++ /dev/null @@ -1,735 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_bond_orders_omp.h" -#include "reaxc_bond_orders.h" - -#include "fix_omp.h" -#include "reaxc_defs.h" -#include "pair_reaxc_omp.h" -#include "reaxc_types.h" -#include "reaxc_list.h" -#include "reaxc_vector.h" - -#include -#include - -#if defined(_OPENMP) -#include -#endif - -using namespace LAMMPS_NS; - -void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, - storage *workspace, reax_list **lists) { - reax_list *bonds = (*lists) + BONDS; - bond_data *nbr_j, *nbr_k; - bond_order_data *bo_ij, *bo_ji; - dbond_coefficients coef; - int pk, k, j; - - PairReaxCOMP *pair_reax_ptr = static_cast(system->pair_ptr); - -#if defined(_OPENMP) - int tid = omp_get_thread_num(); -#else - int tid = 0; -#endif - ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); - long reductionOffset = (system->N * tid); - - /* Virial Tallying variables */ - rvec fi_tmp, fj_tmp, fk_tmp, delij, delji, delki, delkj, temp; - - /* Initializations */ - nbr_j = &(bonds->select.bond_list[pj]); - j = nbr_j->nbr; - bo_ij = &(nbr_j->bo_data); - bo_ji = &(bonds->select.bond_list[ nbr_j->sym_index ].bo_data); - - double c = bo_ij->Cdbo + bo_ji->Cdbo; - coef.C1dbo = bo_ij->C1dbo * c; - coef.C2dbo = bo_ij->C2dbo * c; - coef.C3dbo = bo_ij->C3dbo * c; - - c = bo_ij->Cdbopi + bo_ji->Cdbopi; - coef.C1dbopi = bo_ij->C1dbopi * c; - coef.C2dbopi = bo_ij->C2dbopi * c; - coef.C3dbopi = bo_ij->C3dbopi * c; - coef.C4dbopi = bo_ij->C4dbopi * c; - - c = bo_ij->Cdbopi2 + bo_ji->Cdbopi2; - coef.C1dbopi2 = bo_ij->C1dbopi2 * c; - coef.C2dbopi2 = bo_ij->C2dbopi2 * c; - coef.C3dbopi2 = bo_ij->C3dbopi2 * c; - coef.C4dbopi2 = bo_ij->C4dbopi2 * c; - - c = workspace->CdDelta[i] + workspace->CdDelta[j]; - coef.C1dDelta = bo_ij->C1dbo * c; - coef.C2dDelta = bo_ij->C2dbo * c; - coef.C3dDelta = bo_ij->C3dbo * c; - - // The same "c" refactoring here can be replicated below in Add_dBond_to_Forces_NPTOMP(), but - // I'd prefer to wait for a test to verify changes before doing so (just to be safe). - - // forces on i - // rvec_Scale( temp, coef.C1dbo, bo_ij->dBOp ); - // rvec_ScaledAdd( temp, coef.C2dbo, workspace->dDeltap_self[i] ); - // rvec_ScaledAdd( temp, coef.C1dDelta, bo_ij->dBOp ); - // rvec_ScaledAdd( temp, coef.C2dDelta, workspace->dDeltap_self[i] ); - // rvec_ScaledAdd( temp, coef.C1dbopi, bo_ij->dln_BOp_pi ); - // rvec_ScaledAdd( temp, coef.C2dbopi, bo_ij->dBOp ); - // rvec_ScaledAdd( temp, coef.C3dbopi, workspace->dDeltap_self[i]); - // rvec_ScaledAdd( temp, coef.C1dbopi2, bo_ij->dln_BOp_pi2 ); - // rvec_ScaledAdd( temp, coef.C2dbopi2, bo_ij->dBOp ); - // rvec_ScaledAdd( temp, coef.C3dbopi2, workspace->dDeltap_self[i] ); - - c = (coef.C1dbo + coef.C1dDelta + coef.C2dbopi + coef.C2dbopi2); - rvec_Scale( temp, c, bo_ij->dBOp ); - - c = (coef.C2dbo + coef.C2dDelta + coef.C3dbopi + coef.C3dbopi2); - rvec_ScaledAdd( temp, c, workspace->dDeltap_self[i] ); - - rvec_ScaledAdd( temp, coef.C1dbopi, bo_ij->dln_BOp_pi ); - rvec_ScaledAdd( temp, coef.C1dbopi2, bo_ij->dln_BOp_pi2 ); - - rvec_Add(workspace->forceReduction[reductionOffset+i],temp ); - - if (system->pair_ptr->vflag_atom) { - rvec_Scale(fi_tmp, -1.0, temp); - rvec_ScaledSum( delij, 1., system->my_atoms[i].x,-1., system->my_atoms[j].x ); - - pair_reax_ptr->ev_tally_xyz_thr_proxy(system->pair_ptr,i,j,system->N,0,0,0, - fi_tmp[0],fi_tmp[1],fi_tmp[2], - delij[0],delij[1],delij[2],thr); - } - - // forces on j - // rvec_Scale( temp, -coef.C1dbo, bo_ij->dBOp ); - // rvec_ScaledAdd( temp, coef.C3dbo, workspace->dDeltap_self[j] ); - // rvec_ScaledAdd( temp, -coef.C1dDelta, bo_ij->dBOp ); - // rvec_ScaledAdd( temp, coef.C3dDelta, workspace->dDeltap_self[j]); - // rvec_ScaledAdd( temp, -coef.C1dbopi, bo_ij->dln_BOp_pi ); - // rvec_ScaledAdd( temp, -coef.C2dbopi, bo_ij->dBOp ); - // rvec_ScaledAdd( temp, coef.C4dbopi, workspace->dDeltap_self[j]); - // rvec_ScaledAdd( temp, -coef.C1dbopi2, bo_ij->dln_BOp_pi2 ); - // rvec_ScaledAdd( temp, -coef.C2dbopi2, bo_ij->dBOp ); - // rvec_ScaledAdd( temp, coef.C4dbopi2, workspace->dDeltap_self[j]); - - - c = -(coef.C1dbo + coef.C1dDelta + coef.C2dbopi + coef.C2dbopi2); - rvec_Scale( temp, c, bo_ij->dBOp ); - - c = (coef.C3dbo + coef.C3dDelta + coef.C4dbopi + coef.C4dbopi2); - rvec_ScaledAdd( temp, c, workspace->dDeltap_self[j] ); - - rvec_ScaledAdd( temp, -coef.C1dbopi, bo_ij->dln_BOp_pi ); - rvec_ScaledAdd( temp, -coef.C1dbopi2, bo_ij->dln_BOp_pi2 ); - - - rvec_Add(workspace->forceReduction[reductionOffset+j],temp ); - - if (system->pair_ptr->vflag_atom) { - rvec_Scale(fj_tmp, -1.0, temp); - rvec_ScaledSum( delji, 1., system->my_atoms[j].x,-1., system->my_atoms[i].x ); - - pair_reax_ptr->ev_tally_xyz_thr_proxy(system->pair_ptr,j,i,system->N,0,0,0, - fj_tmp[0],fj_tmp[1],fj_tmp[2], - delji[0],delji[1],delji[2],thr); - } - - // forces on k: i neighbor - for (pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk) { - nbr_k = &(bonds->select.bond_list[pk]); - k = nbr_k->nbr; - - // rvec_Scale( temp, -coef.C2dbo, nbr_k->bo_data.dBOp); - // rvec_ScaledAdd( temp, -coef.C2dDelta, nbr_k->bo_data.dBOp); - // rvec_ScaledAdd( temp, -coef.C3dbopi, nbr_k->bo_data.dBOp); - // rvec_ScaledAdd( temp, -coef.C3dbopi2, nbr_k->bo_data.dBOp); - - const double c = -(coef.C2dbo + coef.C2dDelta + coef.C3dbopi + coef.C3dbopi2); - rvec_Scale(temp, c, nbr_k->bo_data.dBOp); - - rvec_Add(workspace->forceReduction[reductionOffset+k],temp ); - - if (system->pair_ptr->vflag_atom) { - rvec_Scale(fk_tmp, -1.0, temp); - rvec_ScaledSum(delki,1.,system->my_atoms[k].x,-1.,system->my_atoms[i].x); - - pair_reax_ptr->ev_tally_xyz_thr_proxy(system->pair_ptr,k,i,system->N,0,0,0, - fk_tmp[0],fk_tmp[1],fk_tmp[2], - delki[0],delki[1],delki[2],thr); - rvec_ScaledSum(delkj,1.,system->my_atoms[k].x,-1.,system->my_atoms[j].x); - - pair_reax_ptr->ev_tally_xyz_thr_proxy(system->pair_ptr,k,j,system->N,0,0,0, - fk_tmp[0],fk_tmp[1],fk_tmp[2], - delkj[0],delkj[1],delkj[2],thr); - } - } - - // forces on k: j neighbor - for (pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk) { - nbr_k = &(bonds->select.bond_list[pk]); - k = nbr_k->nbr; - - // rvec_Scale( temp, -coef.C3dbo, nbr_k->bo_data.dBOp ); - // rvec_ScaledAdd( temp, -coef.C3dDelta, nbr_k->bo_data.dBOp); - // rvec_ScaledAdd( temp, -coef.C4dbopi, nbr_k->bo_data.dBOp); - // rvec_ScaledAdd( temp, -coef.C4dbopi2, nbr_k->bo_data.dBOp); - - const double c = -(coef.C3dbo + coef.C3dDelta + coef.C4dbopi + coef.C4dbopi2); - rvec_Scale(temp, c, nbr_k->bo_data.dBOp); - - rvec_Add(workspace->forceReduction[reductionOffset+k],temp ); - - if (system->pair_ptr->vflag_atom) { - rvec_Scale(fk_tmp, -1.0, temp); - rvec_ScaledSum(delki,1.,system->my_atoms[k].x,-1.,system->my_atoms[i].x); - - pair_reax_ptr->ev_tally_xyz_thr_proxy(system->pair_ptr,k,i,system->N,0,0,0, - fk_tmp[0],fk_tmp[1],fk_tmp[2], - delki[0],delki[1],delki[2],thr); - - rvec_ScaledSum(delkj,1.,system->my_atoms[k].x,-1.,system->my_atoms[j].x); - - pair_reax_ptr->ev_tally_xyz_thr_proxy(system->pair_ptr,k,j,system->N,0,0,0, - fk_tmp[0],fk_tmp[1],fk_tmp[2], - delkj[0],delkj[1],delkj[2],thr); - } - } -} - -/* ---------------------------------------------------------------------- */ - -void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj, - simulation_data * /* data */, - storage *workspace, reax_list **lists) { - reax_list *bonds = (*lists) + BONDS; - bond_data *nbr_j, *nbr_k; - bond_order_data *bo_ij, *bo_ji; - dbond_coefficients coef; - rvec temp, ext_press; - ivec rel_box; - int pk, k, j; - -#if defined(_OPENMP) - int tid = omp_get_thread_num(); -#else - int tid = 0; -#endif - long reductionOffset = (system->N * tid); - - /* Initializations */ - nbr_j = &(bonds->select.bond_list[pj]); - j = nbr_j->nbr; - bo_ij = &(nbr_j->bo_data); - bo_ji = &(bonds->select.bond_list[ nbr_j->sym_index ].bo_data); - - coef.C1dbo = bo_ij->C1dbo * (bo_ij->Cdbo + bo_ji->Cdbo); - coef.C2dbo = bo_ij->C2dbo * (bo_ij->Cdbo + bo_ji->Cdbo); - coef.C3dbo = bo_ij->C3dbo * (bo_ij->Cdbo + bo_ji->Cdbo); - - coef.C1dbopi = bo_ij->C1dbopi * (bo_ij->Cdbopi + bo_ji->Cdbopi); - coef.C2dbopi = bo_ij->C2dbopi * (bo_ij->Cdbopi + bo_ji->Cdbopi); - coef.C3dbopi = bo_ij->C3dbopi * (bo_ij->Cdbopi + bo_ji->Cdbopi); - coef.C4dbopi = bo_ij->C4dbopi * (bo_ij->Cdbopi + bo_ji->Cdbopi); - - coef.C1dbopi2 = bo_ij->C1dbopi2 * (bo_ij->Cdbopi2 + bo_ji->Cdbopi2); - coef.C2dbopi2 = bo_ij->C2dbopi2 * (bo_ij->Cdbopi2 + bo_ji->Cdbopi2); - coef.C3dbopi2 = bo_ij->C3dbopi2 * (bo_ij->Cdbopi2 + bo_ji->Cdbopi2); - coef.C4dbopi2 = bo_ij->C4dbopi2 * (bo_ij->Cdbopi2 + bo_ji->Cdbopi2); - - coef.C1dDelta = bo_ij->C1dbo * (workspace->CdDelta[i]+workspace->CdDelta[j]); - coef.C2dDelta = bo_ij->C2dbo * (workspace->CdDelta[i]+workspace->CdDelta[j]); - coef.C3dDelta = bo_ij->C3dbo * (workspace->CdDelta[i]+workspace->CdDelta[j]); - - - /************************************ - * forces related to atom i * - * first neighbors of atom i * - ************************************/ - for (pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk) { - nbr_k = &(bonds->select.bond_list[pk]); - k = nbr_k->nbr; - - rvec_Scale(temp, -coef.C2dbo, nbr_k->bo_data.dBOp); /*2nd, dBO*/ - rvec_ScaledAdd(temp, -coef.C2dDelta, nbr_k->bo_data.dBOp);/*dDelta*/ - rvec_ScaledAdd(temp, -coef.C3dbopi, nbr_k->bo_data.dBOp); /*3rd, dBOpi*/ - rvec_ScaledAdd(temp, -coef.C3dbopi2, nbr_k->bo_data.dBOp);/*3rd, dBOpi2*/ - - /* force */ - rvec_Add(workspace->forceReduction[reductionOffset+k],temp ); - - /* pressure */ - rvec_iMultiply( ext_press, nbr_k->rel_box, temp ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - } - - /* then atom i itself */ - rvec_Scale( temp, coef.C1dbo, bo_ij->dBOp ); /*1st,dBO*/ - rvec_ScaledAdd( temp, coef.C2dbo, workspace->dDeltap_self[i] ); /*2nd,dBO*/ - rvec_ScaledAdd( temp, coef.C1dDelta, bo_ij->dBOp ); /*1st,dBO*/ - rvec_ScaledAdd( temp, coef.C2dDelta, workspace->dDeltap_self[i] );/*2nd,dBO*/ - rvec_ScaledAdd( temp, coef.C1dbopi, bo_ij->dln_BOp_pi ); /*1st,dBOpi*/ - rvec_ScaledAdd( temp, coef.C2dbopi, bo_ij->dBOp ); /*2nd,dBOpi*/ - rvec_ScaledAdd( temp, coef.C3dbopi, workspace->dDeltap_self[i]);/*3rd,dBOpi*/ - - rvec_ScaledAdd( temp, coef.C1dbopi2, bo_ij->dln_BOp_pi2 ); /*1st,dBO_pi2*/ - rvec_ScaledAdd( temp, coef.C2dbopi2, bo_ij->dBOp ); /*2nd,dBO_pi2*/ - rvec_ScaledAdd( temp, coef.C3dbopi2, workspace->dDeltap_self[i] );/*3rd*/ - - /* force */ - rvec_Add(workspace->forceReduction[reductionOffset+i],temp ); - - for (pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk) { - nbr_k = &(bonds->select.bond_list[pk]); - k = nbr_k->nbr; - - rvec_Scale( temp, -coef.C3dbo, nbr_k->bo_data.dBOp ); /*3rd,dBO*/ - rvec_ScaledAdd( temp, -coef.C3dDelta, nbr_k->bo_data.dBOp);/*dDelta*/ - rvec_ScaledAdd( temp, -coef.C4dbopi, nbr_k->bo_data.dBOp); /*4th,dBOpi*/ - rvec_ScaledAdd( temp, -coef.C4dbopi2, nbr_k->bo_data.dBOp);/*4th,dBOpi2*/ - - /* force */ - rvec_Add(workspace->forceReduction[reductionOffset+k],temp ); - - /* pressure */ - if (k != i) { - ivec_Sum( rel_box, nbr_k->rel_box, nbr_j->rel_box ); //rel_box(k, i) - rvec_iMultiply( ext_press, rel_box, temp ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - } - } - - /* then atom j itself */ - rvec_Scale( temp, -coef.C1dbo, bo_ij->dBOp ); /*1st, dBO*/ - rvec_ScaledAdd( temp, coef.C3dbo, workspace->dDeltap_self[j] ); /*2nd, dBO*/ - rvec_ScaledAdd( temp, -coef.C1dDelta, bo_ij->dBOp ); /*1st, dBO*/ - rvec_ScaledAdd( temp, coef.C3dDelta, workspace->dDeltap_self[j]);/*2nd, dBO*/ - - rvec_ScaledAdd( temp, -coef.C1dbopi, bo_ij->dln_BOp_pi ); /*1st,dBOpi*/ - rvec_ScaledAdd( temp, -coef.C2dbopi, bo_ij->dBOp ); /*2nd,dBOpi*/ - rvec_ScaledAdd( temp, coef.C4dbopi, workspace->dDeltap_self[j]);/*3rd,dBOpi*/ - - rvec_ScaledAdd( temp, -coef.C1dbopi2, bo_ij->dln_BOp_pi2 ); /*1st,dBOpi2*/ - rvec_ScaledAdd( temp, -coef.C2dbopi2, bo_ij->dBOp ); /*2nd,dBOpi2*/ - rvec_ScaledAdd( temp,coef.C4dbopi2,workspace->dDeltap_self[j]);/*3rd,dBOpi2*/ - - /* force */ - rvec_Add(workspace->forceReduction[reductionOffset+j],temp ); - - /* pressure */ - rvec_iMultiply( ext_press, nbr_j->rel_box, temp ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); -} - -/* ---------------------------------------------------------------------- */ - -int BOp_OMP( storage * /* workspace */, reax_list *bonds, double bo_cut, - int i, int btop_i, far_neighbor_data *nbr_pj, - single_body_parameters * /* sbp_i */, single_body_parameters * /* sbp_j */, - two_body_parameters *twbp, - int btop_j, double C12, double C34, double C56, double BO, double BO_s, double BO_pi, double BO_pi2) { - int j; - double rr2; - double Cln_BOp_s, Cln_BOp_pi, Cln_BOp_pi2; - bond_data *ibond, *jbond; - bond_order_data *bo_ij, *bo_ji; - - j = nbr_pj->nbr; - rr2 = 1.0 / SQR(nbr_pj->d); - - // Top portion of BOp() moved to reaxc_forces_omp.cpp::Init_Forces_noQEq_OMP() - - /* Initially BO values are the uncorrected ones, page 1 */ - - /****** bonds i-j and j-i ******/ - ibond = &( bonds->select.bond_list[btop_i] ); - jbond = &( bonds->select.bond_list[btop_j] ); - - ibond->nbr = j; - jbond->nbr = i; - ibond->d = nbr_pj->d; - jbond->d = nbr_pj->d; - rvec_Copy( ibond->dvec, nbr_pj->dvec ); - rvec_Scale( jbond->dvec, -1, nbr_pj->dvec ); - ivec_Copy( ibond->rel_box, nbr_pj->rel_box ); - ivec_Scale( jbond->rel_box, -1, nbr_pj->rel_box ); - ibond->dbond_index = btop_i; - jbond->dbond_index = btop_i; - ibond->sym_index = btop_j; - jbond->sym_index = btop_i; - - bo_ij = &( ibond->bo_data ); - bo_ji = &( jbond->bo_data ); - bo_ji->BO = bo_ij->BO = BO; - bo_ji->BO_s = bo_ij->BO_s = BO_s; - bo_ji->BO_pi = bo_ij->BO_pi = BO_pi; - bo_ji->BO_pi2 = bo_ij->BO_pi2 = BO_pi2; - - /* Bond Order page2-3, derivative of total bond order prime */ - Cln_BOp_s = twbp->p_bo2 * C12 * rr2; - Cln_BOp_pi = twbp->p_bo4 * C34 * rr2; - Cln_BOp_pi2 = twbp->p_bo6 * C56 * rr2; - - /* Only dln_BOp_xx wrt. dr_i is stored here, note that - dln_BOp_xx/dr_i = -dln_BOp_xx/dr_j and all others are 0 */ - rvec_Scale(bo_ij->dln_BOp_s,-bo_ij->BO_s*Cln_BOp_s,ibond->dvec); - rvec_Scale(bo_ij->dln_BOp_pi,-bo_ij->BO_pi*Cln_BOp_pi,ibond->dvec); - rvec_Scale(bo_ij->dln_BOp_pi2, - -bo_ij->BO_pi2*Cln_BOp_pi2,ibond->dvec); - rvec_Scale(bo_ji->dln_BOp_s, -1., bo_ij->dln_BOp_s); - rvec_Scale(bo_ji->dln_BOp_pi, -1., bo_ij->dln_BOp_pi ); - rvec_Scale(bo_ji->dln_BOp_pi2, -1., bo_ij->dln_BOp_pi2 ); - - rvec_Scale( bo_ij->dBOp, - -(bo_ij->BO_s * Cln_BOp_s + - bo_ij->BO_pi * Cln_BOp_pi + - bo_ij->BO_pi2 * Cln_BOp_pi2), ibond->dvec ); - rvec_Scale( bo_ji->dBOp, -1., bo_ij->dBOp ); - - bo_ij->BO_s -= bo_cut; - bo_ij->BO -= bo_cut; - bo_ji->BO_s -= bo_cut; - bo_ji->BO -= bo_cut; - - bo_ij->Cdbo = bo_ij->Cdbopi = bo_ij->Cdbopi2 = 0.0; - bo_ji->Cdbo = bo_ji->Cdbopi = bo_ji->Cdbopi2 = 0.0; - - return 1; -} - -/* ---------------------------------------------------------------------- */ - -void BOOMP( reax_system *system, control_params * /* control */, simulation_data * /* data */, - storage *workspace, reax_list **lists, output_controls * /* out_control */) -{ -#ifdef OMP_TIMING - double endTimeBase, startTimeBase; - startTimeBase = MPI_Wtime(); -#endif - - double p_lp1 = system->reax_param.gp.l[15]; - double p_boc1 = system->reax_param.gp.l[0]; - double p_boc2 = system->reax_param.gp.l[1]; - reax_list *bonds = (*lists) + BONDS; - -#if defined(_OPENMP) -#pragma omp parallel default(shared) -#endif - { - int i, j, pj, type_i, type_j; - int start_i, end_i, sym_index; - double val_i, Deltap_i, Deltap_boc_i; - double val_j, Deltap_j, Deltap_boc_j; - double f1, f2, f3, f4, f5, f4f5, exp_f4, exp_f5; - double exp_p1i, exp_p2i, exp_p1j, exp_p2j, explp1; - double temp, u1_ij, u1_ji, Cf1A_ij, Cf1B_ij, Cf1_ij, Cf1_ji; - double Cf45_ij, Cf45_ji; //u_ij, u_ji - double A0_ij, A1_ij, A2_ij, A2_ji, A3_ij, A3_ji; - single_body_parameters *sbp_i, *sbp_j; - two_body_parameters *twbp; - bond_order_data *bo_ij, *bo_ji; - - /* Calculate Deltaprime, Deltaprime_boc values */ -#if defined(_OPENMP) -#pragma omp for schedule(static) -#endif - for (i = 0; i < system->N; ++i) { - type_i = system->my_atoms[i].type; - if (type_i < 0) continue; - sbp_i = &(system->reax_param.sbp[type_i]); - workspace->Deltap[i] = workspace->total_bond_order[i] - sbp_i->valency; - workspace->Deltap_boc[i] = - workspace->total_bond_order[i] - sbp_i->valency_val; - - workspace->total_bond_order[i] = 0; - } - - // Wait till initialization complete -#if defined(_OPENMP) -#pragma omp barrier -#endif - - /* Corrected Bond Order calculations */ -#if defined(_OPENMP) -#pragma omp for schedule(guided) -#endif - for (i = 0; i < system->N; ++i) { - type_i = system->my_atoms[i].type; - if (type_i < 0) continue; - sbp_i = &(system->reax_param.sbp[type_i]); - val_i = sbp_i->valency; - Deltap_i = workspace->Deltap[i]; - Deltap_boc_i = workspace->Deltap_boc[i]; - start_i = Start_Index(i, bonds); - end_i = End_Index(i, bonds); - - for (pj = start_i; pj < end_i; ++pj) { - j = bonds->select.bond_list[pj].nbr; - type_j = system->my_atoms[j].type; - if (type_j < 0) continue; - bo_ij = &( bonds->select.bond_list[pj].bo_data ); - - if (i < j || workspace->bond_mark[j] > 3) { - twbp = &( system->reax_param.tbp[type_i][type_j] ); - - if (twbp->ovc < 0.001 && twbp->v13cor < 0.001) { - bo_ij->C1dbo = 1.000000; - bo_ij->C2dbo = 0.000000; - bo_ij->C3dbo = 0.000000; - - bo_ij->C1dbopi = 1.000000; - bo_ij->C2dbopi = 0.000000; - bo_ij->C3dbopi = 0.000000; - bo_ij->C4dbopi = 0.000000; - - bo_ij->C1dbopi2 = 1.000000; - bo_ij->C2dbopi2 = 0.000000; - bo_ij->C3dbopi2 = 0.000000; - bo_ij->C4dbopi2 = 0.000000; - - } - else { - val_j = system->reax_param.sbp[type_j].valency; - Deltap_j = workspace->Deltap[j]; - Deltap_boc_j = workspace->Deltap_boc[j]; - - /* on page 1 */ - if (twbp->ovc >= 0.001) { - /* Correction for overcoordination */ - exp_p1i = exp( -p_boc1 * Deltap_i ); - exp_p2i = exp( -p_boc2 * Deltap_i ); - exp_p1j = exp( -p_boc1 * Deltap_j ); - exp_p2j = exp( -p_boc2 * Deltap_j ); - - f2 = exp_p1i + exp_p1j; - f3 = -1.0 / p_boc2 * log( 0.5 * ( exp_p2i + exp_p2j ) ); - f1 = 0.5 * ( ( val_i + f2 )/( val_i + f2 + f3 ) + - ( val_j + f2 )/( val_j + f2 + f3 ) ); - - /* Now come the derivates */ - /* Bond Order pages 5-7, derivative of f1 */ - temp = f2 + f3; - u1_ij = val_i + temp; - u1_ji = val_j + temp; - Cf1A_ij = 0.5 * f3 * (1.0 / SQR( u1_ij ) + - 1.0 / SQR( u1_ji )); - Cf1B_ij = -0.5 * (( u1_ij - f3 ) / SQR( u1_ij ) + - ( u1_ji - f3 ) / SQR( u1_ji )); - - Cf1_ij = 0.50 * ( -p_boc1 * exp_p1i / u1_ij - - ((val_i+f2) / SQR(u1_ij)) * - ( -p_boc1 * exp_p1i + - exp_p2i / ( exp_p2i + exp_p2j ) ) + - -p_boc1 * exp_p1i / u1_ji - - ((val_j+f2) / SQR(u1_ji)) * - ( -p_boc1 * exp_p1i + - exp_p2i / ( exp_p2i + exp_p2j ) )); - - - Cf1_ji = -Cf1A_ij * p_boc1 * exp_p1j + - Cf1B_ij * exp_p2j / ( exp_p2i + exp_p2j ); - } - else { - /* No overcoordination correction! */ - f1 = 1.0; - Cf1_ij = Cf1_ji = 0.0; - } - - if (twbp->v13cor >= 0.001) { - /* Correction for 1-3 bond orders */ - exp_f4 =exp(-(twbp->p_boc4 * SQR( bo_ij->BO ) - - Deltap_boc_i) * twbp->p_boc3 + twbp->p_boc5); - exp_f5 =exp(-(twbp->p_boc4 * SQR( bo_ij->BO ) - - Deltap_boc_j) * twbp->p_boc3 + twbp->p_boc5); - - f4 = 1. / (1. + exp_f4); - f5 = 1. / (1. + exp_f5); - f4f5 = f4 * f5; - - /* Bond Order pages 8-9, derivative of f4 and f5 */ - Cf45_ij = -f4 * exp_f4; - Cf45_ji = -f5 * exp_f5; - } - else { - f4 = f5 = f4f5 = 1.0; - Cf45_ij = Cf45_ji = 0.0; - } - - /* Bond Order page 10, derivative of total bond order */ - A0_ij = f1 * f4f5; - A1_ij = -2 * twbp->p_boc3 * twbp->p_boc4 * bo_ij->BO * - (Cf45_ij + Cf45_ji); - A2_ij = Cf1_ij / f1 + twbp->p_boc3 * Cf45_ij; - A2_ji = Cf1_ji / f1 + twbp->p_boc3 * Cf45_ji; - A3_ij = A2_ij + Cf1_ij / f1; - A3_ji = A2_ji + Cf1_ji / f1; - - /* find corrected bond orders and their derivative coef */ - bo_ij->BO = bo_ij->BO * A0_ij; - bo_ij->BO_pi = bo_ij->BO_pi * A0_ij *f1; - bo_ij->BO_pi2= bo_ij->BO_pi2* A0_ij *f1; - bo_ij->BO_s = bo_ij->BO - ( bo_ij->BO_pi + bo_ij->BO_pi2 ); - - bo_ij->C1dbo = A0_ij + bo_ij->BO * A1_ij; - bo_ij->C2dbo = bo_ij->BO * A2_ij; - bo_ij->C3dbo = bo_ij->BO * A2_ji; - - bo_ij->C1dbopi = f1*f1*f4*f5; - bo_ij->C2dbopi = bo_ij->BO_pi * A1_ij; - bo_ij->C3dbopi = bo_ij->BO_pi * A3_ij; - bo_ij->C4dbopi = bo_ij->BO_pi * A3_ji; - - bo_ij->C1dbopi2 = f1*f1*f4*f5; - bo_ij->C2dbopi2 = bo_ij->BO_pi2 * A1_ij; - bo_ij->C3dbopi2 = bo_ij->BO_pi2 * A3_ij; - bo_ij->C4dbopi2 = bo_ij->BO_pi2 * A3_ji; - } - - /* neglect bonds that are < 1e-10 */ - if (bo_ij->BO < 1e-10) - bo_ij->BO = 0.0; - if (bo_ij->BO_s < 1e-10) - bo_ij->BO_s = 0.0; - if (bo_ij->BO_pi < 1e-10) - bo_ij->BO_pi = 0.0; - if (bo_ij->BO_pi2 < 1e-10) - bo_ij->BO_pi2 = 0.0; - - workspace->total_bond_order[i] += bo_ij->BO; //now keeps total_BO - } - // else { - // /* We only need to update bond orders from bo_ji - // everything else is set in uncorrected_bo calculations */ - // sym_index = bonds->select.bond_list[pj].sym_index; - // bo_ji = &(bonds->select.bond_list[ sym_index ].bo_data); - // bo_ij->BO = bo_ji->BO; - // bo_ij->BO_s = bo_ji->BO_s; - // bo_ij->BO_pi = bo_ji->BO_pi; - // bo_ij->BO_pi2 = bo_ji->BO_pi2; - - // workspace->total_bond_order[i] += bo_ij->BO;// now keeps total_BO - // } - } - - } - - // Wait for bo_ij to be updated -#if defined(_OPENMP) -#pragma omp barrier -#endif - // Try to combine the following for-loop back into the for-loop above - /*-------------------------*/ -#if defined(_OPENMP) -#pragma omp for schedule(guided) -#endif - for (i = 0; i < system->N; ++i) { - type_i = system->my_atoms[i].type; - if (type_i < 0) continue; - start_i = Start_Index(i, bonds); - end_i = End_Index(i, bonds); - - for (pj = start_i; pj < end_i; ++pj) { - j = bonds->select.bond_list[pj].nbr; - type_j = system->my_atoms[j].type; - if (type_j < 0) continue; - - if (i < j || workspace->bond_mark[j] > 3) { - // Computed in previous for-loop - } else { - /* We only need to update bond orders from bo_ji - everything else is set in uncorrected_bo calculations */ - sym_index = bonds->select.bond_list[pj].sym_index; - - bo_ij = &( bonds->select.bond_list[pj].bo_data ); - bo_ji = &(bonds->select.bond_list[ sym_index ].bo_data); - bo_ij->BO = bo_ji->BO; - bo_ij->BO_s = bo_ji->BO_s; - bo_ij->BO_pi = bo_ji->BO_pi; - bo_ij->BO_pi2 = bo_ji->BO_pi2; - - workspace->total_bond_order[i] += bo_ij->BO;// now keeps total_BO - } - } - - } - - /*-------------------------*/ - - // Need to wait for total_bond_order to be accumulated. -#if defined(_OPENMP) -#pragma omp barrier -#endif - /* Calculate some helper variables that are used at many places - throughout force calculations */ -#if defined(_OPENMP) -#pragma omp for schedule(guided) -#endif - for (j = 0; j < system->N; ++j) { - type_j = system->my_atoms[j].type; - if (type_j < 0) continue; - sbp_j = &(system->reax_param.sbp[ type_j ]); - - workspace->Delta[j] = workspace->total_bond_order[j] - sbp_j->valency; - workspace->Delta_e[j] = workspace->total_bond_order[j] - sbp_j->valency_e; - workspace->Delta_boc[j] = workspace->total_bond_order[j] - - sbp_j->valency_boc; - workspace->Delta_val[j] = workspace->total_bond_order[j] - - sbp_j->valency_val; - - workspace->vlpex[j] = workspace->Delta_e[j] - - 2.0 * (int)(workspace->Delta_e[j]/2.0); - explp1 = exp(-p_lp1 * SQR(2.0 + workspace->vlpex[j])); - workspace->nlp[j] = explp1 - (int)(workspace->Delta_e[j] / 2.0); - workspace->Delta_lp[j] = sbp_j->nlp_opt - workspace->nlp[j]; - workspace->Clp[j] = 2.0 * p_lp1 * explp1 * (2.0 + workspace->vlpex[j]); - workspace->dDelta_lp[j] = workspace->Clp[j]; - - if (sbp_j->mass > 21.0) { - workspace->nlp_temp[j] = 0.5 * (sbp_j->valency_e - sbp_j->valency); - workspace->Delta_lp_temp[j] = sbp_j->nlp_opt - workspace->nlp_temp[j]; - workspace->dDelta_lp_temp[j] = 0.; - } - else { - workspace->nlp_temp[j] = workspace->nlp[j]; - workspace->Delta_lp_temp[j] = sbp_j->nlp_opt - workspace->nlp_temp[j]; - workspace->dDelta_lp_temp[j] = workspace->Clp[j]; - } - } - - } // parallel region - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTEBOINDEX] += (endTimeBase-startTimeBase); - -#endif -} diff --git a/src/OPENMP/reaxc_bond_orders_omp.h b/src/OPENMP/reaxc_bond_orders_omp.h deleted file mode 100644 index 46dc25148d..0000000000 --- a/src/OPENMP/reaxc_bond_orders_omp.h +++ /dev/null @@ -1,44 +0,0 @@ -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __BOND_ORDERS_OMP_H_ -#define __BOND_ORDERS_OMP_H_ - -#include "reaxc_types.h" - -void Add_dBond_to_ForcesOMP(reax_system *, int, int, storage *, reax_list **); -void Add_dBond_to_Forces_NPTOMP(reax_system *system, int, int, simulation_data *, storage *, - reax_list **); - -int BOp_OMP(storage *, reax_list *, double, int, int, far_neighbor_data *, single_body_parameters *, - single_body_parameters *, two_body_parameters *, int, double, double, double, double, - double, double, double); - -void BOOMP(reax_system *, control_params *, simulation_data *, storage *, reax_list **, - output_controls *); -#endif diff --git a/src/OPENMP/reaxc_bonds_omp.cpp b/src/OPENMP/reaxc_bonds_omp.cpp deleted file mode 100644 index f7f0cf5c4f..0000000000 --- a/src/OPENMP/reaxc_bonds_omp.cpp +++ /dev/null @@ -1,189 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_bonds_omp.h" -#include -#include -#include "fix_omp.h" -#include "reaxc_defs.h" -#include "pair_reaxc_omp.h" -#include "reaxc_list.h" - -#if defined(_OPENMP) -#include -#endif - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -void BondsOMP( reax_system *system, control_params * /* control */, - simulation_data *data, storage *workspace, reax_list **lists, - output_controls * /* out_control */) -{ -#ifdef OMP_TIMING - double endTimeBase, startTimeBase; - startTimeBase = MPI_Wtime(); -#endif - - const int natoms = system->n; - reax_list *bonds = (*lists) + BONDS; - const double gp3 = system->reax_param.gp.l[3]; - const double gp4 = system->reax_param.gp.l[4]; - const double gp7 = system->reax_param.gp.l[7]; - const double gp10 = system->reax_param.gp.l[10]; - const int gp37 = (int) system->reax_param.gp.l[37]; - double total_Ebond = 0.0; - -#if defined(_OPENMP) -#pragma omp parallel default(shared) reduction(+: total_Ebond) -#endif - { - int i, j, pj; - int start_i, end_i; - int type_i, type_j; - double ebond, pow_BOs_be2, exp_be12, CEbo; - double exphu, exphua1, exphub1, exphuov, hulpov, estriph; - double decobdbo, decobdboua, decobdboub; - single_body_parameters *sbp_i, *sbp_j; - two_body_parameters *twbp; - bond_order_data *bo_ij; - -#if defined(_OPENMP) - int tid = omp_get_thread_num(); -#else - int tid = 0; -#endif - long reductionOffset = (system->N * tid); - - class PairReaxCOMP *pair_reax_ptr; - pair_reax_ptr = static_cast(system->pair_ptr); - class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); - - pair_reax_ptr->ev_setup_thr_proxy(system->pair_ptr->eflag_either, - system->pair_ptr->vflag_either, system->N, - system->pair_ptr->eatom, - system->pair_ptr->vatom, nullptr, thr); - -#if defined(_OPENMP) -#pragma omp for schedule(guided) -#endif - for (i = 0; i < natoms; ++i) { - start_i = Start_Index(i, bonds); - end_i = End_Index(i, bonds); - - for (pj = start_i; pj < end_i; ++pj) { - j = bonds->select.bond_list[pj].nbr; - - if (system->my_atoms[i].orig_id > system->my_atoms[j].orig_id) continue; - - if (system->my_atoms[i].orig_id == system->my_atoms[j].orig_id) { - if (system->my_atoms[j].x[2] < system->my_atoms[i].x[2]) continue; - if (system->my_atoms[j].x[2] == system->my_atoms[i].x[2] && - system->my_atoms[j].x[1] < system->my_atoms[i].x[1]) continue; - if (system->my_atoms[j].x[2] == system->my_atoms[i].x[2] && - system->my_atoms[j].x[1] == system->my_atoms[i].x[1] && - system->my_atoms[j].x[0] < system->my_atoms[i].x[0]) continue; - } - - /* set the pointers */ - type_i = system->my_atoms[i].type; - type_j = system->my_atoms[j].type; - sbp_i = &( system->reax_param.sbp[type_i] ); - sbp_j = &( system->reax_param.sbp[type_j] ); - twbp = &( system->reax_param.tbp[type_i][type_j] ); - bo_ij = &( bonds->select.bond_list[pj].bo_data ); - - /* calculate the constants */ - if (bo_ij->BO_s == 0.0) pow_BOs_be2 = 0.0; - else pow_BOs_be2 = pow( bo_ij->BO_s, twbp->p_be2 ); - exp_be12 = exp( twbp->p_be1 * ( 1.0 - pow_BOs_be2 ) ); - CEbo = -twbp->De_s * exp_be12 * - ( 1.0 - twbp->p_be1 * twbp->p_be2 * pow_BOs_be2 ); - - /* calculate the Bond Energy */ - total_Ebond += ebond = - -twbp->De_s * bo_ij->BO_s * exp_be12 - -twbp->De_p * bo_ij->BO_pi - -twbp->De_pp * bo_ij->BO_pi2; - - /* tally into per-atom energy */ - if (system->pair_ptr->evflag) - pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, j, natoms, 1, - ebond, 0.0, 0.0, 0.0, 0.0, 0.0, thr); - - /* calculate derivatives of Bond Orders */ - bo_ij->Cdbo += CEbo; - bo_ij->Cdbopi -= (CEbo + twbp->De_p); - bo_ij->Cdbopi2 -= (CEbo + twbp->De_pp); - - /* Stabilisation terminal triple bond */ - if (bo_ij->BO >= 1.00) { - if (gp37 == 2 || - (sbp_i->mass == 12.0000 && sbp_j->mass == 15.9990) || - (sbp_j->mass == 12.0000 && sbp_i->mass == 15.9990)) { - exphu = exp( -gp7 * SQR(bo_ij->BO - 2.50) ); - exphua1 = exp(-gp3 * (workspace->total_bond_order[i]-bo_ij->BO)); - exphub1 = exp(-gp3 * (workspace->total_bond_order[j]-bo_ij->BO)); - exphuov = exp(gp4 * (workspace->Delta[i] + workspace->Delta[j])); - hulpov = 1.0 / (1.0 + 25.0 * exphuov); - - estriph = gp10 * exphu * hulpov * (exphua1 + exphub1); - total_Ebond += estriph; - - decobdbo = gp10 * exphu * hulpov * (exphua1 + exphub1) * - ( gp3 - 2.0 * gp7 * (bo_ij->BO-2.50) ); - decobdboua = -gp10 * exphu * hulpov * - (gp3*exphua1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); - decobdboub = -gp10 * exphu * hulpov * - (gp3*exphub1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); - - /* tally into per-atom energy */ - if (system->pair_ptr->evflag) - pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, j, natoms, 1, - estriph, 0.0, 0.0, 0.0, 0.0, 0.0, thr); - - bo_ij->Cdbo += decobdbo; - workspace->CdDelta[i] += decobdboua; - workspace->CdDeltaReduction[reductionOffset+j] += decobdboub; - } - } - } - } // for (i) - - } // omp - - data->my_en.e_bond += total_Ebond; - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTEBONDSINDEX] += (endTimeBase-startTimeBase); -#endif - -} diff --git a/src/OPENMP/reaxc_bonds_omp.h b/src/OPENMP/reaxc_bonds_omp.h deleted file mode 100644 index 19403c35da..0000000000 --- a/src/OPENMP/reaxc_bonds_omp.h +++ /dev/null @@ -1,37 +0,0 @@ -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __BONDS_OMP_H_ -#define __BONDS_OMP_H_ - -#include "reaxc_types.h" - -void BondsOMP(reax_system *, control_params *, simulation_data *, storage *, reax_list **, - output_controls *); - -#endif diff --git a/src/OPENMP/reaxc_forces_omp.cpp b/src/OPENMP/reaxc_forces_omp.cpp deleted file mode 100644 index 05091c7eb5..0000000000 --- a/src/OPENMP/reaxc_forces_omp.cpp +++ /dev/null @@ -1,623 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_forces_omp.h" - -#include "error.h" -#include "fix_omp.h" -#include "pair_reaxc_omp.h" -#include "reaxc_defs.h" - -#include "reaxc_bond_orders_omp.h" -#include "reaxc_bonds_omp.h" -#include "reaxc_hydrogen_bonds_omp.h" -#include "reaxc_list.h" -#include "reaxc_multi_body_omp.h" -#include "reaxc_nonbonded_omp.h" -#include "reaxc_torsion_angles_omp.h" -#include "reaxc_valence_angles_omp.h" -#include "reaxc_vector.h" - -#include -#include - -#if defined(_OPENMP) -#include -#endif - -using namespace LAMMPS_NS; - -// Functions defined in reaxc_forces.cpp -extern interaction_function Interaction_Functions[]; -extern double Compute_H(double, double, double*); -extern double Compute_tabH(double, int, int); -extern void Dummy_Interaction(reax_system*, control_params*, simulation_data*, storage*, reax_list**, output_controls*); - -/* ---------------------------------------------------------------------- */ - -void Init_Force_FunctionsOMP( control_params *control ) -{ - Interaction_Functions[0] = BOOMP; - Interaction_Functions[1] = BondsOMP; //Dummy_Interaction; - Interaction_Functions[2] = Atom_EnergyOMP; //Dummy_Interaction; - Interaction_Functions[3] = Valence_AnglesOMP; //Dummy_Interaction; - Interaction_Functions[4] = Torsion_AnglesOMP; //Dummy_Interaction; - if (control->hbond_cut > 0) - Interaction_Functions[5] = Hydrogen_BondsOMP; - else Interaction_Functions[5] = Dummy_Interaction; - Interaction_Functions[6] = Dummy_Interaction; //empty - Interaction_Functions[7] = Dummy_Interaction; //empty - Interaction_Functions[8] = Dummy_Interaction; //empty - Interaction_Functions[9] = Dummy_Interaction; //empty -} - -/* ---------------------------------------------------------------------- */ - -// Only difference with MPI-only version is inclusion of OMP_TIMING statements -void Compute_Bonded_ForcesOMP( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls *out_control, - MPI_Comm /* comm */) -{ - int i; - -#ifdef OMP_TIMING - double startTimeBase, endTimeBase; - startTimeBase = MPI_Wtime(); -#endif - - /* Implement all force calls as function pointers */ - for (i = 0; i < NUM_INTRS; i++) { - (Interaction_Functions[i])( system, control, data, workspace, - lists, out_control ); - } - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTEBFINDEX] += (endTimeBase-startTimeBase); -#endif - -} - -// Only difference with MPI-only version is inclusion of OMP_TIMING statements -void Compute_NonBonded_ForcesOMP( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls *out_control, - MPI_Comm /* comm */) -{ - /* van der Waals and Coulomb interactions */ -#ifdef OMP_TIMING - double endTimeBase, startTimeBase; - startTimeBase = MPI_Wtime(); -#endif - - if (control->tabulate == 0) - vdW_Coulomb_Energy_OMP( system, control, data, workspace, - lists, out_control ); - else - Tabulated_vdW_Coulomb_Energy_OMP( system, control, data, workspace, - lists, out_control ); - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTENBFINDEX] += (endTimeBase-startTimeBase); -#endif -} - -/* ---------------------------------------------------------------------- */ - -/* this version of Compute_Total_Force computes forces from - coefficients accumulated by all interaction functions. - Saves enormous time & space! */ -void Compute_Total_ForceOMP( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, mpi_datatypes * /* mpi_data */) -{ -#ifdef OMP_TIMING - double startTimeBase,endTimeBase; - startTimeBase = MPI_Wtime(); -#endif - - int natoms = system->N; - int nthreads = control->nthreads; - long totalReductionSize = (bigint)system->N * nthreads; - reax_list *bonds = (*lists) + BONDS; - -#if defined(_OPENMP) -#pragma omp parallel default(shared) //LMP_DEFAULT_NONE -#endif - { - int i, j, k, pj, pk, start_j, end_j; -#if defined(_OPENMP) - int tid = omp_get_thread_num(); -#else - int tid = 0; -#endif - bond_order_data *bo_jk; - - class PairReaxCOMP *pair_reax_ptr; - pair_reax_ptr = static_cast(system->pair_ptr); - class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); - - pair_reax_ptr->ev_setup_thr_proxy(0, 1, natoms, system->pair_ptr->eatom, - system->pair_ptr->vatom, nullptr, thr); - -#if defined(_OPENMP) -#pragma omp for schedule(guided) -#endif - for (i = 0; i < system->N; ++i) { - for (j = 0; j < nthreads; ++j) - workspace->CdDelta[i] += workspace->CdDeltaReduction[system->N*j+i]; - } - -#if defined(_OPENMP) -#pragma omp for schedule(dynamic,50) -#endif - for (j = 0; j < system->N; ++j) { - start_j = Start_Index(j, bonds); - end_j = End_Index(j, bonds); - - for (pk = start_j; pk < end_j; ++pk) { - bo_jk = &( bonds->select.bond_list[pk].bo_data ); - for (k = 0; k < nthreads; ++k) - bo_jk->Cdbo += bo_jk->CdboReduction[k]; - } - } - -// #pragma omp for schedule(guided) //(dynamic,50) -// for (i = 0; i < system->N; ++i) -// for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) -// if (i < bonds->select.bond_list[pj].nbr) { -// if (control->virial == 0) -// Add_dBond_to_ForcesOMP( system, i, pj, workspace, lists ); -// else -// Add_dBond_to_Forces_NPTOMP(system, i, pj, data, workspace, lists ); -// } - - if (control->virial == 0) { - -#if defined(_OPENMP) -#pragma omp for schedule(dynamic,50) -#endif - for (i = 0; i < system->N; ++i) { - const int startj = Start_Index(i, bonds); - const int endj = End_Index(i, bonds); - for (pj = startj; pj < endj; ++pj) - if (i < bonds->select.bond_list[pj].nbr) - Add_dBond_to_ForcesOMP( system, i, pj, workspace, lists ); - } - - } else { - -#if defined(_OPENMP) -#pragma omp for schedule(dynamic,50) -#endif - for (i = 0; i < system->N; ++i) { - const int startj = Start_Index(i, bonds); - const int endj = End_Index(i, bonds); - for (pj = startj; pj < endj; ++pj) - if (i < bonds->select.bond_list[pj].nbr) - Add_dBond_to_Forces_NPTOMP(system, i, pj, data, workspace, lists ); - } - - } // if (virial == 0) - - pair_reax_ptr->reduce_thr_proxy(system->pair_ptr, 0, 1, thr); - -#if defined(_OPENMP) -#pragma omp for schedule(guided) -#endif - for (i = 0; i < system->N; ++i) { - for (j = 0; j < nthreads; ++j) - rvec_Add( workspace->f[i], workspace->forceReduction[system->N*j+i] ); - } - - -#if defined(_OPENMP) -#pragma omp for schedule(guided) -#endif - for (i = 0; i < totalReductionSize; i++) { - workspace->forceReduction[i][0] = 0; - workspace->forceReduction[i][1] = 0; - workspace->forceReduction[i][2] = 0; - workspace->CdDeltaReduction[i] = 0; - } - } // parallel region - - if (control->virial) - for (int i=0; i < nthreads; ++i) { - rvec_Add(data->my_ext_press, workspace->my_ext_pressReduction[i]); - workspace->my_ext_pressReduction[i][0] = 0; - workspace->my_ext_pressReduction[i][1] = 0; - workspace->my_ext_pressReduction[i][2] = 0; - } - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTETFINDEX] += (endTimeBase-startTimeBase); -#endif -} - -/* ---------------------------------------------------------------------- */ - -void Validate_ListsOMP(reax_system *system, storage * /*workspace*/, reax_list **lists, - int step, int n, int N, int numH, MPI_Comm /*comm*/) -{ - int comp, Hindex; - reax_list *bonds, *hbonds; - double saferzone = system->saferzone; - -#if defined(_OPENMP) -#pragma omp parallel default(shared) private(comp,Hindex) -#endif - { - - /* bond list */ - if (N > 0) { - bonds = *lists + BONDS; - -#if defined(_OPENMP) -#pragma omp for schedule(guided) -#endif - for (int i = 0; i < N; ++i) { - system->my_atoms[i].num_bonds = MAX(Num_Entries(i,bonds)*2, MIN_BONDS); - - if (i < N-1) - comp = Start_Index(i+1, bonds); - else comp = bonds->num_intrs; - - if (End_Index(i, bonds) > comp) { - char errmsg[256]; - snprintf(errmsg, 256, "step%d-bondchk failed: i=%d end(i)=%d str(i+1)=%d\n", - step, i, End_Index(i,bonds), comp ); - system->error_ptr->one(FLERR,errmsg); - } - } - } - - - /* hbonds list */ - if (numH > 0) { - hbonds = *lists + HBONDS; - -#if defined(_OPENMP) -#pragma omp for schedule(guided) -#endif - for (int i = 0; i < n; ++i) { - Hindex = system->my_atoms[i].Hindex; - if (Hindex > -1) { - system->my_atoms[i].num_hbonds = - (int)(MAX(Num_Entries(Hindex,hbonds)*saferzone,system->minhbonds)); - - if (Hindex < numH-1) - comp = Start_Index(Hindex+1, hbonds); - else comp = hbonds->num_intrs; - - if (End_Index(Hindex, hbonds) > comp) { - char errmsg[256]; - snprintf(errmsg, 256, "step%d-hbondchk failed: H=%d end(H)=%d str(H+1)=%d\n", - step, Hindex, End_Index(Hindex,hbonds), comp ); - system->error_ptr->one(FLERR, errmsg); - } - } - } - } - - } // omp parallel -} - - -void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls * /* out_control */, - MPI_Comm comm) { -#ifdef OMP_TIMING - double startTimeBase, endTimeBase; - startTimeBase = MPI_Wtime(); -#endif - - int j, pj; - int start_i, end_i; - int type_i, type_j; - int ihb, jhb, ihb_top, jhb_top; - double cutoff; - single_body_parameters *sbp_i, *sbp_j; - two_body_parameters *twbp; - far_neighbor_data *nbr_pj; - reax_atom *atom_i, *atom_j; - reax_list *far_nbrs = *lists + FAR_NBRS; - reax_list *bonds = *lists + BONDS; - reax_list *hbonds = *lists + HBONDS; - int num_bonds = 0; - int num_hbonds = 0; - int btop_i = 0; - - // We will use CdDeltaReduction as a temporary (double) buffer to accumulate total_bond_order - // This is safe because CdDeltaReduction is currently zeroed and its accumulation doesn't start until BondsOMP() - double * tmp_bond_order = workspace->CdDeltaReduction; - - // We do the same with forceReduction as a temporary (rvec) buffer to accumulate dDeltap_self - // This is safe because forceReduction is currently zeroed and its accumulation does start until Hydrogen_BondsOMP() - rvec * tmp_ddelta = workspace->forceReduction; - - /* uncorrected bond orders */ - cutoff = control->bond_cut; - -#if defined(_OPENMP) -#pragma omp parallel default(shared) \ - private(atom_i, type_i, start_i, end_i, sbp_i, btop_i, ihb, ihb_top, \ - atom_j, type_j, pj, sbp_j, nbr_pj, jhb, twbp) -#endif - { - - int nthreads = control->nthreads; -#if defined(_OPENMP) - int tid = omp_get_thread_num(); -#else - int tid = 0; -#endif - long reductionOffset = (bigint)system->N * tid; - long totalReductionSize = (bigint)system->N * nthreads; - -#if defined(_OPENMP) -#pragma omp for schedule(dynamic,50) reduction(+:num_bonds) -#endif - for (int i = 0; i < system->N; ++i) { - atom_i = &(system->my_atoms[i]); - type_i = atom_i->type; - sbp_i = &(system->reax_param.sbp[type_i]); - - start_i = Start_Index(i, far_nbrs); - end_i = End_Index(i, far_nbrs); - - for (pj = start_i; pj < end_i; ++pj) { - nbr_pj = &( far_nbrs->select.far_nbr_list[pj] ); - if (nbr_pj->d <= cutoff) { - int j = nbr_pj->nbr; - atom_j = &(system->my_atoms[j]); - type_j = atom_j->type; - sbp_j = &(system->reax_param.sbp[type_j]); - twbp = &(system->reax_param.tbp[type_i][type_j]); - -// #pragma omp critical -// { -// btop_i = End_Index(i, bonds); -// if (BOp(workspace, bonds, control->bo_cut, i, btop_i, nbr_pj, sbp_i, sbp_j, twbp)) { -// num_bonds++; -// btop_i++; -// Set_End_Index(i, btop_i, bonds); -// } - -// } - - // Trying to minimize time spent in critical section by moving initial part of BOp() - // outside of critical section. - - // Start top portion of BOp() - double C12, C34, C56; - double BO, BO_s, BO_pi, BO_pi2; - double bo_cut = control->bo_cut; - - if (sbp_i->r_s > 0.0 && sbp_j->r_s > 0.0) { - C12 = twbp->p_bo1 * pow( nbr_pj->d / twbp->r_s, twbp->p_bo2 ); - BO_s = (1.0 + bo_cut) * exp( C12 ); - } - else BO_s = C12 = 0.0; - - if (sbp_i->r_pi > 0.0 && sbp_j->r_pi > 0.0) { - C34 = twbp->p_bo3 * pow( nbr_pj->d / twbp->r_p, twbp->p_bo4 ); - BO_pi = exp( C34 ); - } - else BO_pi = C34 = 0.0; - - if (sbp_i->r_pi_pi > 0.0 && sbp_j->r_pi_pi > 0.0) { - C56 = twbp->p_bo5 * pow( nbr_pj->d / twbp->r_pp, twbp->p_bo6 ); - BO_pi2= exp( C56 ); - } - else BO_pi2 = C56 = 0.0; - - /* Initially BO values are the uncorrected ones, page 1 */ - BO = BO_s + BO_pi + BO_pi2; - // End top portion of BOp() - - if (BO >= bo_cut) { - int btop_j; - - // Update indices in critical section -#if defined(_OPENMP) -#pragma omp critical -#endif - { - btop_i = End_Index( i, bonds ); - btop_j = End_Index( j, bonds ); - Set_End_Index( j, btop_j+1, bonds ); - Set_End_Index( i, btop_i+1, bonds ); - } // omp critical - - // Finish remaining BOp() work - BOp_OMP(workspace, bonds, bo_cut, - i , btop_i, nbr_pj, sbp_i, sbp_j, twbp, btop_j, - C12, C34, C56, BO, BO_s, BO_pi, BO_pi2); - - bond_data * ibond = &(bonds->select.bond_list[btop_i]); - bond_order_data * bo_ij = &(ibond->bo_data); - - bond_data * jbond = &(bonds->select.bond_list[btop_j]); - bond_order_data * bo_ji = &(jbond->bo_data); - - workspace->total_bond_order[i] += bo_ij->BO; - tmp_bond_order[reductionOffset + j] += bo_ji->BO; - - rvec_Add(workspace->dDeltap_self[i], bo_ij->dBOp); - rvec_Add(tmp_ddelta[reductionOffset + j], bo_ji->dBOp); - - btop_i++; - num_bonds++; - } // if (BO>=bo_cut) - - } // if (cutoff) - - } // for (pj) - } // for (i) - - // Need to wait for all indices and tmp arrays accumulated. -#if defined(_OPENMP) -#pragma omp barrier -#endif - -#if defined(_OPENMP) -#pragma omp for schedule(dynamic,50) -#endif - for (int i=0; iN; i++) - for (int t=0; tN + i; - workspace->dDeltap_self[i][0] += tmp_ddelta[indx][0]; - workspace->dDeltap_self[i][1] += tmp_ddelta[indx][1]; - workspace->dDeltap_self[i][2] += tmp_ddelta[indx][2]; - workspace->total_bond_order[i] += tmp_bond_order[indx]; - } - - /* hydrogen bond list */ - if (control->hbond_cut > 0) { - cutoff = control->hbond_cut; - -#if defined(_OPENMP) -#pragma omp for schedule(dynamic,50) reduction(+ : num_hbonds) -#endif - for (int i = 0; i < system->n; ++i) { - atom_i = &(system->my_atoms[i]); - type_i = atom_i->type; - sbp_i = &(system->reax_param.sbp[type_i]); - ihb = sbp_i->p_hbond; - -#if defined(_OPENMP) -#pragma omp critical -#endif - { - - if (ihb == 1 || ihb == 2) { - start_i = Start_Index(i, far_nbrs); - end_i = End_Index(i, far_nbrs); - - for (pj = start_i; pj < end_i; ++pj) { - nbr_pj = &( far_nbrs->select.far_nbr_list[pj] ); - j = nbr_pj->nbr; - atom_j = &(system->my_atoms[j]); - type_j = atom_j->type; - if (type_j < 0) continue; - sbp_j = &(system->reax_param.sbp[type_j]); - jhb = sbp_j->p_hbond; - - if (nbr_pj->d <= control->hbond_cut) { - int iflag = 0; - int jflag = 0; - - if (ihb==1 && jhb==2) iflag = 1; - else if (jn && ihb == 2 && jhb == 1) jflag = 1; - - if (iflag || jflag) { - if (iflag) { - ihb_top = End_Index(atom_i->Hindex, hbonds); - Set_End_Index(atom_i->Hindex, ihb_top+1, hbonds); - } else if (jflag) { - jhb_top = End_Index(atom_j->Hindex, hbonds); - Set_End_Index(atom_j->Hindex, jhb_top+1, hbonds); - } - - if (iflag) { - hbonds->select.hbond_list[ihb_top].nbr = j; - hbonds->select.hbond_list[ihb_top].scl = 1; - hbonds->select.hbond_list[ihb_top].ptr = nbr_pj; - } else if (jflag) { - hbonds->select.hbond_list[jhb_top].nbr = i; - hbonds->select.hbond_list[jhb_top].scl = -1; - hbonds->select.hbond_list[jhb_top].ptr = nbr_pj; - } - - num_hbonds++; - } // if (iflag || jflag) - - } - } - } - - } // omp critical - } - - } // if (control->hbond > 0) - - // Zero buffers for others to use as intended. -#if defined(_OPENMP) -#pragma omp for schedule(guided) -#endif - for (int i=0; irealloc.num_bonds = num_bonds; - workspace->realloc.num_hbonds = num_hbonds; - - Validate_ListsOMP( system, workspace, lists, data->step, - system->n, system->N, system->numH, comm ); - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTEIFINDEX] += (endTimeBase-startTimeBase); -#endif -} - -/* ---------------------------------------------------------------------- */ - -void Compute_ForcesOMP( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls *out_control, - mpi_datatypes *mpi_data ) -{ - MPI_Comm comm = mpi_data->world; - - // Init Forces - Init_Forces_noQEq_OMP( system, control, data, workspace, - lists, out_control, comm ); - - // Bonded Interactions - Compute_Bonded_ForcesOMP( system, control, data, workspace, - lists, out_control, mpi_data->world ); - - // Nonbonded Interactions - Compute_NonBonded_ForcesOMP( system, control, data, workspace, - lists, out_control, mpi_data->world ); - - // Total Force - Compute_Total_ForceOMP( system, control, data, workspace, lists, mpi_data ); -} diff --git a/src/OPENMP/reaxc_forces_omp.h b/src/OPENMP/reaxc_forces_omp.h deleted file mode 100644 index c42aed1282..0000000000 --- a/src/OPENMP/reaxc_forces_omp.h +++ /dev/null @@ -1,37 +0,0 @@ -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __FORCES_OMP_H_ -#define __FORCES_OMP_H_ - -#include "reaxc_types.h" - -void Init_Force_FunctionsOMP(control_params *); -void Compute_ForcesOMP(reax_system *, control_params *, simulation_data *, storage *, reax_list **, - output_controls *, mpi_datatypes *); -#endif diff --git a/src/OPENMP/reaxc_hydrogen_bonds_omp.cpp b/src/OPENMP/reaxc_hydrogen_bonds_omp.cpp deleted file mode 100644 index 7701063ebf..0000000000 --- a/src/OPENMP/reaxc_hydrogen_bonds_omp.cpp +++ /dev/null @@ -1,251 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_hydrogen_bonds_omp.h" - -#include "fix_omp.h" -#include "pair_reaxc_omp.h" -#include "reaxc_defs.h" -#include "reaxc_list.h" -#include "reaxc_valence_angles.h" // To access Calculate_Theta() -#include "reaxc_valence_angles_omp.h" // To access Calculate_dCos_ThetaOMP() -#include "reaxc_vector.h" - -#include -#include - -#if defined(_OPENMP) -#include -#endif - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -void Hydrogen_BondsOMP( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls * /* out_control */) -{ -#ifdef OMP_TIMING - double endTimeBase, startTimeBase; - startTimeBase = MPI_Wtime(); -#endif - - const int nthreads = control->nthreads; - -#if defined(_OPENMP) -#pragma omp parallel default(shared) //LMP_DEFAULT_NONE -#endif - { - int i, j, k, pi, pk; - int type_i, type_j, type_k; - int start_j, end_j, hb_start_j, hb_end_j; - int hblist[MAX_BONDS]; - int itr, top; - int num_hb_intrs = 0; - ivec rel_jk; - double r_jk, theta, cos_theta, sin_xhz4, cos_xhz1, sin_theta2; - double e_hb, e_hb_thr = 0.0, exp_hb2, exp_hb3, CEhb1, CEhb2, CEhb3; - rvec dcos_theta_di, dcos_theta_dj, dcos_theta_dk; - rvec dvec_jk, force, ext_press; - hbond_parameters *hbp; - bond_order_data *bo_ij; - bond_data *pbond_ij; - far_neighbor_data *nbr_jk; - reax_list *bonds, *hbonds; - bond_data *bond_list; - hbond_data *hbond_list; - - // tally variables - double fi_tmp[3], fk_tmp[3], delij[3], delkj[3]; - - bonds = (*lists) + BONDS; - bond_list = bonds->select.bond_list; - hbonds = (*lists) + HBONDS; - hbond_list = hbonds->select.hbond_list; - - int natoms = system->n; -#if defined(_OPENMP) - int tid = omp_get_thread_num(); -#else - int tid = 0; -#endif - const int idelta = 1 + natoms/nthreads; - int ifrom = tid*idelta; - int ito = ((ifrom + idelta) > natoms) ? natoms : ifrom + idelta; - - long reductionOffset = (system->N * tid); - - class PairReaxCOMP *pair_reax_ptr; - pair_reax_ptr = static_cast(system->pair_ptr); - - class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); - - /* loops below discover the Hydrogen bonds between i-j-k triplets. - here j is H atom and there has to be some bond between i and j. - Hydrogen bond is between j and k. - so in this function i->X, j->H, k->Z when we map - variables onto the ones in the handout.*/ - // for (j = 0; j < system->n; ++j) - for (j = ifrom; j < ito; ++j) { - /* j has to be of type H */ - if (system->reax_param.sbp[system->my_atoms[j].type].p_hbond == 1) { - /*set j's variables */ - type_j = system->my_atoms[j].type; - start_j = Start_Index(j, bonds); - end_j = End_Index(j, bonds); - hb_start_j = Start_Index( system->my_atoms[j].Hindex, hbonds ); - hb_end_j = End_Index( system->my_atoms[j].Hindex, hbonds ); - if (type_j < 0) continue; - - top = 0; - for (pi = start_j; pi < end_j; ++pi) { - pbond_ij = &( bond_list[pi] ); - i = pbond_ij->nbr; - type_i = system->my_atoms[i].type; - if (type_i < 0) continue; - bo_ij = &(pbond_ij->bo_data); - - if ( system->reax_param.sbp[type_i].p_hbond == 2 && - bo_ij->BO >= HB_THRESHOLD ) - hblist[top++] = pi; - } - - for (pk = hb_start_j; pk < hb_end_j; ++pk) { - /* set k's varibles */ - k = hbond_list[pk].nbr; - type_k = system->my_atoms[k].type; - if (type_k < 0) continue; - nbr_jk = hbond_list[pk].ptr; - r_jk = nbr_jk->d; - rvec_Scale( dvec_jk, hbond_list[pk].scl, nbr_jk->dvec ); - - for (itr = 0; itr < top; ++itr) { - pi = hblist[itr]; - pbond_ij = &( bonds->select.bond_list[pi] ); - i = pbond_ij->nbr; - - if (system->my_atoms[i].orig_id != system->my_atoms[k].orig_id) { - bo_ij = &(pbond_ij->bo_data); - type_i = system->my_atoms[i].type; - if (type_i < 0) continue; - hbp = &(system->reax_param.hbp[ type_i ][ type_j ][ type_k ]); - ++num_hb_intrs; - - Calculate_Theta( pbond_ij->dvec, pbond_ij->d, dvec_jk, r_jk, - &theta, &cos_theta ); - /* the derivative of cos(theta) */ - Calculate_dCos_ThetaOMP( pbond_ij->dvec, pbond_ij->d, dvec_jk, r_jk, - &dcos_theta_di, &dcos_theta_dj, - &dcos_theta_dk ); - - /* hydrogen bond energy*/ - sin_theta2 = sin( theta/2.0 ); - sin_xhz4 = SQR(sin_theta2); - sin_xhz4 *= sin_xhz4; - cos_xhz1 = ( 1.0 - cos_theta ); - exp_hb2 = exp( -hbp->p_hb2 * bo_ij->BO ); - exp_hb3 = exp( -hbp->p_hb3 * ( hbp->r0_hb / r_jk + - r_jk / hbp->r0_hb - 2.0 ) ); - - e_hb_thr += e_hb = hbp->p_hb1 * (1.0 - exp_hb2) * exp_hb3 * sin_xhz4; - - CEhb1 = hbp->p_hb1 * hbp->p_hb2 * exp_hb2 * exp_hb3 * sin_xhz4; - CEhb2 = -hbp->p_hb1/2.0 * (1.0 - exp_hb2) * exp_hb3 * cos_xhz1; - CEhb3 = -hbp->p_hb3 * - (-hbp->r0_hb / SQR(r_jk) + 1.0 / hbp->r0_hb) * e_hb; - - /* hydrogen bond forces */ - bo_ij->Cdbo += CEhb1; // dbo term - - if (control->virial == 0) { - // dcos terms - rvec_ScaledAdd(workspace->forceReduction[reductionOffset+i], +CEhb2, dcos_theta_di ); - rvec_ScaledAdd(workspace->forceReduction[reductionOffset+j], +CEhb2, dcos_theta_dj ); - rvec_ScaledAdd(workspace->forceReduction[reductionOffset+k], +CEhb2, dcos_theta_dk ); - // dr terms - rvec_ScaledAdd(workspace->forceReduction[reductionOffset+j], -CEhb3/r_jk, dvec_jk ); - rvec_ScaledAdd(workspace->forceReduction[reductionOffset+k], +CEhb3/r_jk, dvec_jk ); - } - else { - /* for pressure coupling, terms that are not related to bond order - derivatives are added directly into pressure vector/tensor */ - rvec_Scale( force, +CEhb2, dcos_theta_di ); // dcos terms - rvec_Add(workspace->forceReduction[reductionOffset+i], force ); - rvec_iMultiply( ext_press, pbond_ij->rel_box, force ); - rvec_ScaledAdd( workspace->my_ext_pressReduction[tid],1.0, ext_press ); - - rvec_ScaledAdd(workspace->forceReduction[reductionOffset+j], +CEhb2, dcos_theta_dj ); - - ivec_Scale( rel_jk, hbond_list[pk].scl, nbr_jk->rel_box ); - rvec_Scale( force, +CEhb2, dcos_theta_dk ); - rvec_Add(workspace->forceReduction[reductionOffset+k], force ); - rvec_iMultiply( ext_press, rel_jk, force ); - rvec_ScaledAdd( workspace->my_ext_pressReduction[tid],1.0, ext_press ); - // dr terms - rvec_ScaledAdd(workspace->forceReduction[reductionOffset+j],-CEhb3/r_jk, dvec_jk ); - - rvec_Scale( force, CEhb3/r_jk, dvec_jk ); - rvec_Add(workspace->forceReduction[reductionOffset+k], force ); - rvec_iMultiply( ext_press, rel_jk, force ); - rvec_ScaledAdd( workspace->my_ext_pressReduction[tid],1.0, ext_press ); - } - - /* tally into per-atom virials */ - if (system->pair_ptr->vflag_atom || system->pair_ptr->evflag) { - rvec_ScaledSum( delij, 1., system->my_atoms[j].x, - -1., system->my_atoms[i].x ); - rvec_ScaledSum( delkj, 1., system->my_atoms[j].x, - -1., system->my_atoms[k].x ); - - rvec_Scale(fi_tmp, CEhb2, dcos_theta_di); - rvec_Scale(fk_tmp, CEhb2, dcos_theta_dk); - rvec_ScaledAdd(fk_tmp, CEhb3/r_jk, dvec_jk); - - pair_reax_ptr->ev_tally3_thr_proxy(system->pair_ptr,i,j,k,e_hb,0.0,fi_tmp,fk_tmp,delij,delkj,thr); - } - } - } - } - - } - } -#if defined(_OPENMP) -#pragma omp critical -#endif - { - data->my_en.e_hb += e_hb_thr; - } -} - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTEHBONDSINDEX] += (endTimeBase-startTimeBase); -#endif -} diff --git a/src/OPENMP/reaxc_hydrogen_bonds_omp.h b/src/OPENMP/reaxc_hydrogen_bonds_omp.h deleted file mode 100644 index 3703b09058..0000000000 --- a/src/OPENMP/reaxc_hydrogen_bonds_omp.h +++ /dev/null @@ -1,37 +0,0 @@ -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __HBONDS_OMP_H_ -#define __HBONDS_OMP_H_ - -#include "reaxc_types.h" - -void Hydrogen_BondsOMP(reax_system *, control_params *, simulation_data *, storage *, reax_list **, - output_controls *); - -#endif diff --git a/src/OPENMP/reaxc_init_md_omp.cpp b/src/OPENMP/reaxc_init_md_omp.cpp deleted file mode 100644 index b1c6b5e3c6..0000000000 --- a/src/OPENMP/reaxc_init_md_omp.cpp +++ /dev/null @@ -1,159 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_init_md_omp.h" - -#include "reaxc_defs.h" -#include "reaxc_forces.h" -#include "reaxc_forces_omp.h" -#include "reaxc_io_tools.h" -#include "reaxc_list.h" -#include "reaxc_lookup.h" -#include "reaxc_tool_box.h" -#include "error.h" -#include "fmt/format.h" - -#include - -// Functions defined in reaxc_init_md.cpp -extern int Init_MPI_Datatypes(reax_system*, storage*, mpi_datatypes*, MPI_Comm, char*); -extern int Init_System(reax_system*, control_params*, char*); -extern int Init_Simulation_Data(reax_system*, control_params*, simulation_data*, char*); -extern int Init_Workspace(reax_system*, control_params*, storage*, char*); - -/* ---------------------------------------------------------------------- */ - -int Init_ListsOMP(reax_system *system, control_params *control, - simulation_data * /* data */, storage * /* workspace */, - reax_list **lists, mpi_datatypes * /* mpi_data */, char * /* msg */) -{ - int i, total_hbonds, total_bonds, bond_cap, num_3body, cap_3body, Htop; - int *hb_top, *bond_top; - - int mincap = system->mincap; - double safezone = system->safezone; - double saferzone = system->saferzone; - LAMMPS_NS::Error *error = system->error_ptr; - - bond_top = (int*) calloc(system->total_cap, sizeof(int)); - hb_top = (int*) calloc(system->local_cap, sizeof(int)); - Estimate_Storages(system, control, lists, - &Htop, hb_top, bond_top, &num_3body); - - if (control->hbond_cut > 0) { - /* init H indexes */ - total_hbonds = 0; - for (i = 0; i < system->n; ++i) { - system->my_atoms[i].num_hbonds = hb_top[i]; - total_hbonds += hb_top[i]; - } - total_hbonds = (int)(MAX(total_hbonds*saferzone,mincap*system->minhbonds)); - - if (!Make_List(system->Hcap, total_hbonds, TYP_HBOND, - *lists+HBONDS)) { - error->one(FLERR, "Not enough space for hbonds list. Terminating!"); - } - } - - total_bonds = 0; - for (i = 0; i < system->N; ++i) { - system->my_atoms[i].num_bonds = bond_top[i]; - total_bonds += bond_top[i]; - } - bond_cap = (int)(MAX(total_bonds*safezone, mincap*MIN_BONDS)); - - if (!Make_List(system->total_cap, bond_cap, TYP_BOND, - *lists+BONDS)) { - error->one(FLERR, "Not enough space for bonds list. Terminating!\n"); - } - - int nthreads = control->nthreads; - reax_list *bonds = (*lists)+BONDS; - - for (i = 0; i < bonds->num_intrs; ++i) - bonds->select.bond_list[i].bo_data.CdboReduction = - (double*) smalloc(error, sizeof(double)*nthreads, "CdboReduction"); - - /* 3bodies list */ - cap_3body = (int)(MAX(num_3body*safezone, MIN_3BODIES)); - if (!Make_List(bond_cap, cap_3body, TYP_THREE_BODY, - *lists+THREE_BODIES)) { - - error->one(FLERR, "Problem in initializing angles list. Terminating!"); - } - - free(hb_top); - free(bond_top); - - return REAXC_SUCCESS; -} - -/* ---------------------------------------------------------------------- */ - -// The only difference with the MPI-only function is calls to Init_ListsOMP and Init_Force_FunctionsOMP(). -void InitializeOMP(reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls *out_control, - mpi_datatypes *mpi_data, MPI_Comm comm) -{ - char msg[MAX_STR]; - LAMMPS_NS::Error *error = system->error_ptr; - - if (Init_MPI_Datatypes(system,workspace,mpi_data,comm,msg) == FAILURE) - error->one(FLERR,"init_mpi_datatypes: could not create datatypes. " - "Mpi_data could not be initialized! Terminating."); - - if (Init_System(system,control,msg) == FAILURE) - error->one(FLERR,"Error on: {}. System could not be " - "initialized! Terminating.",msg); - - if (Init_Simulation_Data(system,control,data,msg) == FAILURE) - error->one(FLERR,"Error on: {}. Sim_data could not be " - "initialized! Terminating.",msg); - - if (Init_Workspace(system,control,workspace,msg) == FAILURE) - error->one(FLERR,"init_workspace: not enough memory. " - "Workspace could not be initialized. Terminating."); - - if (Init_ListsOMP(system,control,data,workspace,lists,mpi_data,msg) == FAILURE) - error->one(FLERR,"Error on: {}. System could not be " - "initialized. Terminating.",msg); - - if (Init_Output_Files(system,control,out_control,mpi_data,msg)== FAILURE) - error->one(FLERR,"Error on: {}. Could not open output files! " - "Terminating.",msg); - - if (control->tabulate) - if (Init_Lookup_Tables(system,control,workspace,mpi_data,msg) == FAILURE) - error->one(FLERR,"Error on: {}. Could not create lookup " - "table. Terminating.",msg); - - Init_Force_FunctionsOMP(control); -} - diff --git a/src/OPENMP/reaxc_init_md_omp.h b/src/OPENMP/reaxc_init_md_omp.h deleted file mode 100644 index c4292ae4c0..0000000000 --- a/src/OPENMP/reaxc_init_md_omp.h +++ /dev/null @@ -1,38 +0,0 @@ -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __INIT_MD_OMP_H_ -#define __INIT_MD_OMP_H_ - -#include "reaxc_types.h" - -#include - -void InitializeOMP(reax_system *, control_params *, simulation_data *, storage *, reax_list **, - output_controls *, mpi_datatypes *, MPI_Comm); -#endif diff --git a/src/OPENMP/reaxc_multi_body_omp.cpp b/src/OPENMP/reaxc_multi_body_omp.cpp deleted file mode 100644 index d42a203044..0000000000 --- a/src/OPENMP/reaxc_multi_body_omp.cpp +++ /dev/null @@ -1,292 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_multi_body_omp.h" - -#include "fix_omp.h" -#include "pair_reaxc_omp.h" - -#include "reaxc_defs.h" -#include "reaxc_list.h" - -#include -#include - -#if defined(_OPENMP) -#include -#endif - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -void Atom_EnergyOMP( reax_system *system, control_params * /* control */, - simulation_data *data, storage *workspace, reax_list **lists, - output_controls * /* out_control */) -{ -#ifdef OMP_TIMING - double endTimeBase, startTimeBase; - startTimeBase = MPI_Wtime(); -#endif - - /* Initialize parameters */ - const double p_lp3 = system->reax_param.gp.l[5]; - const double p_ovun3 = system->reax_param.gp.l[32]; - const double p_ovun4 = system->reax_param.gp.l[31]; - const double p_ovun6 = system->reax_param.gp.l[6]; - const double p_ovun7 = system->reax_param.gp.l[8]; - const double p_ovun8 = system->reax_param.gp.l[9]; - - reax_list *bonds = (*lists) + BONDS; - - double total_Elp = 0.0; - double total_Eun = 0.0; - double total_Eov = 0.0; - -#if defined(_OPENMP) -#pragma omp parallel default(shared) reduction(+:total_Elp, total_Eun, total_Eov) -#endif -{ - int i, j, pj, type_i, type_j; - double Delta_lpcorr, dfvl; - double e_lp, expvd2, inv_expvd2, dElp, CElp, DlpVi; - double e_lph, Di, vov3, deahu2dbo, deahu2dsbo; - double e_ov, CEover1, CEover2, CEover3, CEover4; - double exp_ovun1, exp_ovun2, sum_ovun1, sum_ovun2; - double exp_ovun2n, exp_ovun6, exp_ovun8; - double inv_exp_ovun1, inv_exp_ovun2, inv_exp_ovun2n, inv_exp_ovun8; - double e_un, CEunder1, CEunder2, CEunder3, CEunder4; - double eng_tmp; - double p_lp2, p_ovun2, p_ovun5; - int numbonds; - - single_body_parameters *sbp_i; - two_body_parameters *twbp; - bond_data *pbond; - bond_order_data *bo_ij; - -#if defined(_OPENMP) - int tid = omp_get_thread_num(); -#else - int tid = 0; -#endif - - long reductionOffset = (system->N * tid); - class PairReaxCOMP *pair_reax_ptr; - pair_reax_ptr = static_cast(system->pair_ptr); - class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); - -#if defined(_OPENMP) -#pragma omp for schedule(guided) -#endif - for ( i = 0; i < system->n; ++i) { - type_i = system->my_atoms[i].type; - if (type_i < 0) continue; - sbp_i = &(system->reax_param.sbp[ type_i ]); - - /* lone-pair Energy */ - p_lp2 = sbp_i->p_lp2; - expvd2 = exp( -75 * workspace->Delta_lp[i] ); - inv_expvd2 = 1. / (1. + expvd2 ); - - numbonds = 0; - e_lp = 0.0; - for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) - numbonds ++; - - /* calculate the energy */ - if (numbonds > 0) - total_Elp += e_lp = - p_lp2 * workspace->Delta_lp[i] * inv_expvd2; - - dElp = p_lp2 * inv_expvd2 + - 75 * p_lp2 * workspace->Delta_lp[i] * expvd2 * SQR(inv_expvd2); - CElp = dElp * workspace->dDelta_lp[i]; - - if (numbonds > 0) workspace->CdDelta[i] += CElp; // lp - 1st term - - /* tally into per-atom energy */ - if (system->pair_ptr->evflag) - pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, i, system->n, 1, - e_lp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); - - /* correction for C2 */ - if (p_lp3 > 0.001 && !strcmp(system->reax_param.sbp[type_i].name, "C")) - for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { - j = bonds->select.bond_list[pj].nbr; - type_j = system->my_atoms[j].type; - if (type_j < 0) continue; - - if (!strcmp( system->reax_param.sbp[type_j].name, "C" )) { - twbp = &( system->reax_param.tbp[type_i][type_j]); - bo_ij = &( bonds->select.bond_list[pj].bo_data ); - Di = workspace->Delta[i]; - vov3 = bo_ij->BO - Di - 0.040*pow(Di, 4.); - - if (vov3 > 3.) { - total_Elp += e_lph = p_lp3 * SQR(vov3-3.0); - - deahu2dbo = 2.*p_lp3*(vov3 - 3.); - deahu2dsbo = 2.*p_lp3*(vov3 - 3.)*(-1. - 0.16*pow(Di, 3.)); - - bo_ij->Cdbo += deahu2dbo; - workspace->CdDelta[i] += deahu2dsbo; - - /* tally into per-atom energy */ - if (system->pair_ptr->evflag) - pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, j, system->n, 1, - e_lph, 0.0, 0.0, 0.0, 0.0, 0.0, thr); - } - } - } - } -#if defined(_OPENMP) -#pragma omp barrier -#pragma omp for schedule(guided) -#endif - for (i = 0; i < system->n; ++i) { - type_i = system->my_atoms[i].type; - if (type_i < 0) continue; - sbp_i = &(system->reax_param.sbp[ type_i ]); - - /* over-coordination energy */ - if (sbp_i->mass > 21.0) - dfvl = 0.0; - else dfvl = 1.0; // only for 1st-row elements - - p_ovun2 = sbp_i->p_ovun2; - sum_ovun1 = sum_ovun2 = 0; - for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { - j = bonds->select.bond_list[pj].nbr; - type_j = system->my_atoms[j].type; - if (type_j < 0) continue; - bo_ij = &(bonds->select.bond_list[pj].bo_data); - twbp = &(system->reax_param.tbp[ type_i ][ type_j ]); - - sum_ovun1 += twbp->p_ovun1 * twbp->De_s * bo_ij->BO; - sum_ovun2 += (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j])* - ( bo_ij->BO_pi + bo_ij->BO_pi2 ); - } - - exp_ovun1 = p_ovun3 * exp( p_ovun4 * sum_ovun2 ); - inv_exp_ovun1 = 1.0 / (1 + exp_ovun1); - Delta_lpcorr = workspace->Delta[i] - - (dfvl * workspace->Delta_lp_temp[i]) * inv_exp_ovun1; - - exp_ovun2 = exp( p_ovun2 * Delta_lpcorr ); - inv_exp_ovun2 = 1.0 / (1.0 + exp_ovun2); - - DlpVi = 1.0 / (Delta_lpcorr + sbp_i->valency + 1e-8); - CEover1 = Delta_lpcorr * DlpVi * inv_exp_ovun2; - - total_Eov += e_ov = sum_ovun1 * CEover1; - - CEover2 = sum_ovun1 * DlpVi * inv_exp_ovun2 * - (1.0 - Delta_lpcorr * ( DlpVi + p_ovun2 * exp_ovun2 * inv_exp_ovun2 )); - - CEover3 = CEover2 * (1.0 - dfvl * workspace->dDelta_lp[i] * inv_exp_ovun1 ); - - CEover4 = CEover2 * (dfvl * workspace->Delta_lp_temp[i]) * - p_ovun4 * exp_ovun1 * SQR(inv_exp_ovun1); - - - /* under-coordination potential */ - p_ovun2 = sbp_i->p_ovun2; - p_ovun5 = sbp_i->p_ovun5; - - exp_ovun2n = 1.0 / exp_ovun2; - exp_ovun6 = exp( p_ovun6 * Delta_lpcorr ); - exp_ovun8 = p_ovun7 * exp(p_ovun8 * sum_ovun2); - inv_exp_ovun2n = 1.0 / (1.0 + exp_ovun2n); - inv_exp_ovun8 = 1.0 / (1.0 + exp_ovun8); - - numbonds = 0; - e_un = 0.0; - for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) - numbonds ++; - - if (numbonds > 0) total_Eun += e_un = - -p_ovun5 * (1.0 - exp_ovun6) * inv_exp_ovun2n * inv_exp_ovun8; - - CEunder1 = inv_exp_ovun2n * - ( p_ovun5 * p_ovun6 * exp_ovun6 * inv_exp_ovun8 + - p_ovun2 * e_un * exp_ovun2n ); - CEunder2 = -e_un * p_ovun8 * exp_ovun8 * inv_exp_ovun8; - CEunder3 = CEunder1 * (1.0 - dfvl*workspace->dDelta_lp[i]*inv_exp_ovun1); - CEunder4 = CEunder1 * (dfvl*workspace->Delta_lp_temp[i]) * - p_ovun4 * exp_ovun1 * SQR(inv_exp_ovun1) + CEunder2; - - /* tally into per-atom energy */ - if (system->pair_ptr->evflag) { - eng_tmp = e_ov; - if (numbonds > 0) eng_tmp+= e_un; - pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, i, system->n, 1, - eng_tmp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); - } - - /* forces */ - workspace->CdDelta[i] += CEover3; // OvCoor - 2nd term - if (numbonds > 0) workspace->CdDelta[i] += CEunder3; // UnCoor - 1st term - - for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { - pbond = &(bonds->select.bond_list[pj]); - j = pbond->nbr; - bo_ij = &(pbond->bo_data); - twbp = &(system->reax_param.tbp[ system->my_atoms[i].type ] - [system->my_atoms[pbond->nbr].type]); - - bo_ij->Cdbo += CEover1 * twbp->p_ovun1 * twbp->De_s; // OvCoor-1st - workspace->CdDeltaReduction[reductionOffset+j] += - CEover4 * (1.0 - dfvl*workspace->dDelta_lp[j]) * (bo_ij->BO_pi + bo_ij->BO_pi2); // OvCoor-3a - - bo_ij->Cdbopi += CEover4 * - (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j]); // OvCoor-3b - bo_ij->Cdbopi2 += CEover4 * - (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j]); // OvCoor-3b - - workspace->CdDeltaReduction[reductionOffset+j] += - CEunder4 * (1.0 - dfvl*workspace->dDelta_lp[j]) * (bo_ij->BO_pi + bo_ij->BO_pi2); // UnCoor - 2a - - bo_ij->Cdbopi += CEunder4 * - (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j]); // UnCoor-2b - bo_ij->Cdbopi2 += CEunder4 * - (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j]); // UnCoor-2b - } - } - } - - data->my_en.e_lp += total_Elp; - data->my_en.e_ov += total_Eov; - data->my_en.e_un += total_Eun; - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTEATOMENERGYINDEX] += (endTimeBase-startTimeBase); -#endif -} diff --git a/src/OPENMP/reaxc_multi_body_omp.h b/src/OPENMP/reaxc_multi_body_omp.h deleted file mode 100644 index c5e7de6b57..0000000000 --- a/src/OPENMP/reaxc_multi_body_omp.h +++ /dev/null @@ -1,37 +0,0 @@ -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __MULTI_BODY_OMP_H_ -#define __MULTI_BODY_OMP_H_ - -#include "reaxc_types.h" - -void Atom_EnergyOMP(reax_system *, control_params *, simulation_data *, storage *, reax_list **, - output_controls *); - -#endif diff --git a/src/OPENMP/reaxc_nonbonded_omp.cpp b/src/OPENMP/reaxc_nonbonded_omp.cpp deleted file mode 100644 index 32f4d5f8b4..0000000000 --- a/src/OPENMP/reaxc_nonbonded_omp.cpp +++ /dev/null @@ -1,390 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "pair_reaxc_omp.h" - -#include "reaxc_defs.h" -#include "reaxc_types.h" - -#include "reaxc_nonbonded.h" -#include "reaxc_nonbonded_omp.h" -#include "reaxc_list.h" -#include "reaxc_vector.h" - -#include - -#if defined(_OPENMP) -#include -#endif - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls * /* out_control */ ) -{ - int natoms = system->n; - reax_list *far_nbrs = (*lists) + FAR_NBRS; - double p_vdW1 = system->reax_param.gp.l[28]; - double p_vdW1i = 1.0 / p_vdW1; - double total_EvdW = 0.; - double total_Eele = 0.; - -#if defined(_OPENMP) -#pragma omp parallel default(shared) reduction(+: total_EvdW, total_Eele) -#endif - { -#if defined(_OPENMP) - int tid = omp_get_thread_num(); -#else - int tid = 0; -#endif - int i, j, pj; - int start_i, end_i, orig_i, orig_j, flag; - double powr_vdW1, powgi_vdW1; - double tmp, r_ij, fn13, exp1, exp2; - double Tap, dTap, dfn13, CEvd, CEclmb, de_core; - double dr3gamij_1, dr3gamij_3; - double e_ele, e_vdW, e_core; - const double SMALL = 0.0001; - double e_lg, de_lg, r_ij5, r_ij6, re6; - rvec temp, ext_press; - two_body_parameters *twbp; - far_neighbor_data *nbr_pj; - - // Tallying variables: - double pe_vdw, f_tmp, delij[3]; - - long reductionOffset = (system->N * tid); - - class PairReaxCOMP *pair_reax_ptr; - pair_reax_ptr = static_cast(system->pair_ptr); - class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); - - e_core = 0; - e_vdW = 0; - e_lg = 0; - de_lg = 0.0; - -#if defined(_OPENMP) -#pragma omp for schedule(guided) -#endif - for (i = 0; i < natoms; ++i) { - if (system->my_atoms[i].type < 0) continue; - start_i = Start_Index(i, far_nbrs); - end_i = End_Index(i, far_nbrs); - orig_i = system->my_atoms[i].orig_id; - - for (pj = start_i; pj < end_i; ++pj) { - nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); - j = nbr_pj->nbr; - orig_j = system->my_atoms[j].orig_id; - - flag = 0; - if (nbr_pj->d <= control->nonb_cut) { - if (j < natoms) flag = 1; - else if (orig_i < orig_j) flag = 1; - else if (orig_i == orig_j) { - if (nbr_pj->dvec[2] > SMALL) flag = 1; - else if (fabs(nbr_pj->dvec[2]) < SMALL) { - if (nbr_pj->dvec[1] > SMALL) flag = 1; - else if (fabs(nbr_pj->dvec[1]) < SMALL && nbr_pj->dvec[0] > SMALL) - flag = 1; - } - } - } - - if (flag) { - - r_ij = nbr_pj->d; - twbp = &(system->reax_param.tbp[ system->my_atoms[i].type ] - [ system->my_atoms[j].type ]); - - /* Calculate Taper and its derivative */ - // Tap = nbr_pj->Tap; -- precomputed during compte_H - Tap = workspace->Tap[7] * r_ij + workspace->Tap[6]; - Tap = Tap * r_ij + workspace->Tap[5]; - Tap = Tap * r_ij + workspace->Tap[4]; - Tap = Tap * r_ij + workspace->Tap[3]; - Tap = Tap * r_ij + workspace->Tap[2]; - Tap = Tap * r_ij + workspace->Tap[1]; - Tap = Tap * r_ij + workspace->Tap[0]; - - dTap = 7*workspace->Tap[7] * r_ij + 6*workspace->Tap[6]; - dTap = dTap * r_ij + 5*workspace->Tap[5]; - dTap = dTap * r_ij + 4*workspace->Tap[4]; - dTap = dTap * r_ij + 3*workspace->Tap[3]; - dTap = dTap * r_ij + 2*workspace->Tap[2]; - dTap += workspace->Tap[1]/r_ij; - - /*vdWaals Calculations*/ - if (system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) - { // shielding - powr_vdW1 = pow(r_ij, p_vdW1); - powgi_vdW1 = pow( 1.0 / twbp->gamma_w, p_vdW1); - - fn13 = pow( powr_vdW1 + powgi_vdW1, p_vdW1i ); - exp1 = exp( twbp->alpha * (1.0 - fn13 / twbp->r_vdW) ); - exp2 = exp( 0.5 * twbp->alpha * (1.0 - fn13 / twbp->r_vdW) ); - - e_vdW = twbp->D * (exp1 - 2.0 * exp2); - total_EvdW += Tap * e_vdW; - - dfn13 = pow( powr_vdW1 + powgi_vdW1, p_vdW1i - 1.0) * - pow(r_ij, p_vdW1 - 2.0); - - CEvd = dTap * e_vdW - - Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) * dfn13; - } - else { // no shielding - exp1 = exp( twbp->alpha * (1.0 - r_ij / twbp->r_vdW) ); - exp2 = exp( 0.5 * twbp->alpha * (1.0 - r_ij / twbp->r_vdW) ); - - e_vdW = twbp->D * (exp1 - 2.0 * exp2); - total_EvdW += Tap * e_vdW; - - CEvd = dTap * e_vdW - - Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; - } - - if (system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) - { // innner wall - e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); - total_EvdW += Tap * e_core; - - de_core = -(twbp->acore/twbp->rcore) * e_core; - CEvd += dTap * e_core + Tap * de_core / r_ij; - - // lg correction, only if lgvdw is yes - if (control->lgflag) { - r_ij5 = pow( r_ij, 5.0 ); - r_ij6 = pow( r_ij, 6.0 ); - re6 = pow( twbp->lgre, 6.0 ); - - e_lg = -(twbp->lgcij/( r_ij6 + re6 )); - total_EvdW += Tap * e_lg; - - de_lg = -6.0 * e_lg * r_ij5 / ( r_ij6 + re6 ) ; - CEvd += dTap * e_lg + Tap * de_lg / r_ij; - } - - } - - /*Coulomb Calculations*/ - dr3gamij_1 = ( r_ij * r_ij * r_ij + twbp->gamma ); - dr3gamij_3 = pow( dr3gamij_1 , 0.33333333333333 ); - - tmp = Tap / dr3gamij_3; - total_Eele += e_ele = - C_ele * system->my_atoms[i].q * system->my_atoms[j].q * tmp; - - CEclmb = C_ele * system->my_atoms[i].q * system->my_atoms[j].q * - ( dTap - Tap * r_ij / dr3gamij_1 ) / dr3gamij_3; - - /* tally into per-atom energy */ - if (system->pair_ptr->evflag || system->pair_ptr->vflag_atom) { - pe_vdw = Tap * (e_vdW + e_core + e_lg); - rvec_ScaledSum( delij, 1., system->my_atoms[i].x, - -1., system->my_atoms[j].x ); - f_tmp = -(CEvd + CEclmb); - pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, j, natoms, - 1, pe_vdw, e_ele, f_tmp, - delij[0], delij[1], delij[2], thr); - } - - if (control->virial == 0) { - rvec_ScaledAdd( workspace->f[i], -(CEvd + CEclmb), nbr_pj->dvec ); - rvec_ScaledAdd( workspace->forceReduction[reductionOffset+j], - +(CEvd + CEclmb), nbr_pj->dvec ); - } else { /* NPT, iNPT or sNPT */ - /* for pressure coupling, terms not related to bond order - derivatives are added directly into pressure vector/tensor */ - - rvec_Scale( temp, CEvd + CEclmb, nbr_pj->dvec ); - rvec_ScaledAdd( workspace->f[reductionOffset+i], -1., temp ); - rvec_Add( workspace->forceReduction[reductionOffset+j], temp); - - rvec_iMultiply( ext_press, nbr_pj->rel_box, temp ); - - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - } - } - } - } - - pair_reax_ptr->reduce_thr_proxy(system->pair_ptr, system->pair_ptr->eflag_either, - system->pair_ptr->vflag_either, thr); - } // parallel region - - data->my_en.e_vdW = total_EvdW; - data->my_en.e_ele = total_Eele; - - Compute_Polarization_Energy( system, data ); -} - -/* ---------------------------------------------------------------------- */ - -void Tabulated_vdW_Coulomb_Energy_OMP(reax_system *system,control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, - output_controls * /* out_control */) { - - double SMALL = 0.0001; - int natoms = system->n; - reax_list *far_nbrs = (*lists) + FAR_NBRS; - double total_EvdW = 0.; - double total_Eele = 0.; - -#if defined(_OPENMP) -#pragma omp parallel default(shared) reduction(+:total_EvdW, total_Eele) -#endif - { - int i, j, pj, r; - int type_i, type_j, tmin, tmax; - int start_i, end_i, orig_i, orig_j, flag; - double r_ij, base, dif; - double e_vdW, e_ele; - double CEvd, CEclmb; - double f_tmp, delij[3]; - rvec temp, ext_press; - far_neighbor_data *nbr_pj; - LR_lookup_table *t; -#if defined(_OPENMP) - int tid = omp_get_thread_num(); - #else - int tid = 0; -#endif - long froffset = (system->N * tid); - LR_lookup_table ** & LR = system->LR; - - class PairReaxCOMP *pair_reax_ptr; - pair_reax_ptr = static_cast(system->pair_ptr); - class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); - -#if defined(_OPENMP) -#pragma omp for schedule(guided) -#endif - for (i = 0; i < natoms; ++i) { - type_i = system->my_atoms[i].type; - if (type_i < 0) continue; - start_i = Start_Index(i,far_nbrs); - end_i = End_Index(i,far_nbrs); - orig_i = system->my_atoms[i].orig_id; - - for (pj = start_i; pj < end_i; ++pj) { - nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); - j = nbr_pj->nbr; - type_j = system->my_atoms[j].type; - if (type_j < 0) continue; - orig_j = system->my_atoms[j].orig_id; - - flag = 0; - if (nbr_pj->d <= control->nonb_cut) { - if (j < natoms) flag = 1; - else if (orig_i < orig_j) flag = 1; - else if (orig_i == orig_j) { - if (nbr_pj->dvec[2] > SMALL) flag = 1; - else if (fabs(nbr_pj->dvec[2]) < SMALL) { - if (nbr_pj->dvec[1] > SMALL) flag = 1; - else if (fabs(nbr_pj->dvec[1]) < SMALL && nbr_pj->dvec[0] > SMALL) - flag = 1; - } - } - - } - - if (flag) { - - r_ij = nbr_pj->d; - tmin = MIN( type_i, type_j ); - tmax = MAX( type_i, type_j ); - t = &( LR[tmin][tmax] ); - - /* Cubic Spline Interpolation */ - r = (int)(r_ij * t->inv_dx); - if (r == 0) ++r; - base = (double)(r+1) * t->dx; - dif = r_ij - base; - - e_vdW = ((t->vdW[r].d*dif + t->vdW[r].c)*dif + t->vdW[r].b)*dif + - t->vdW[r].a; - - e_ele = ((t->ele[r].d*dif + t->ele[r].c)*dif + t->ele[r].b)*dif + - t->ele[r].a; - e_ele *= system->my_atoms[i].q * system->my_atoms[j].q; - - total_EvdW += e_vdW; - total_Eele += e_ele; - - CEvd = ((t->CEvd[r].d*dif + t->CEvd[r].c)*dif + t->CEvd[r].b)*dif + - t->CEvd[r].a; - - CEclmb = ((t->CEclmb[r].d*dif+t->CEclmb[r].c)*dif+t->CEclmb[r].b)*dif + - t->CEclmb[r].a; - CEclmb *= system->my_atoms[i].q * system->my_atoms[j].q; - - /* tally into per-atom energy */ - if (system->pair_ptr->evflag || system->pair_ptr->vflag_atom) { - rvec_ScaledSum( delij, 1., system->my_atoms[i].x, - -1., system->my_atoms[j].x ); - f_tmp = -(CEvd + CEclmb); - pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, j, natoms, 1, e_vdW, e_ele, - f_tmp, delij[0], delij[1], delij[2], thr); - } - - if (control->virial == 0) { - rvec_ScaledAdd( workspace->f[i], -(CEvd + CEclmb), nbr_pj->dvec ); - rvec_ScaledAdd( workspace->forceReduction[froffset+j], - +(CEvd + CEclmb), nbr_pj->dvec ); - } else { // NPT, iNPT or sNPT - /* for pressure coupling, terms not related to bond order derivatives - are added directly into pressure vector/tensor */ - rvec_Scale( temp, CEvd + CEclmb, nbr_pj->dvec ); - - rvec_ScaledAdd( workspace->f[i], -1., temp ); - rvec_Add( workspace->forceReduction[froffset+j], temp ); - - rvec_iMultiply( ext_press, nbr_pj->rel_box, temp ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - } - } - } - } - - pair_reax_ptr->reduce_thr_proxy(system->pair_ptr, system->pair_ptr->eflag_either, - system->pair_ptr->vflag_either, thr); - } // end omp parallel - - data->my_en.e_vdW = total_EvdW; - data->my_en.e_ele = total_Eele; - - Compute_Polarization_Energy( system, data ); -} diff --git a/src/OPENMP/reaxc_nonbonded_omp.h b/src/OPENMP/reaxc_nonbonded_omp.h deleted file mode 100644 index 779642b83d..0000000000 --- a/src/OPENMP/reaxc_nonbonded_omp.h +++ /dev/null @@ -1,39 +0,0 @@ -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __NONBONDED_OMP_H_ -#define __NONBONDED_OMP_H_ - -#include "reaxc_types.h" - -void vdW_Coulomb_Energy_OMP(reax_system *, control_params *, simulation_data *, storage *, - reax_list **, output_controls *); - -void Tabulated_vdW_Coulomb_Energy_OMP(reax_system *, control_params *, simulation_data *, storage *, - reax_list **, output_controls *); -#endif diff --git a/src/OPENMP/reaxc_torsion_angles_omp.cpp b/src/OPENMP/reaxc_torsion_angles_omp.cpp deleted file mode 100644 index 96d4966a00..0000000000 --- a/src/OPENMP/reaxc_torsion_angles_omp.cpp +++ /dev/null @@ -1,477 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_torsion_angles_omp.h" - -#include "fix_omp.h" -#include "pair_reaxc_omp.h" - -#include "reaxc_defs.h" -#include "reaxc_types.h" -#include "reaxc_list.h" -#include "reaxc_vector.h" - -#include - -#if defined(_OPENMP) -#include -#endif - -#define MIN_SINE 1e-10 - -using namespace LAMMPS_NS; - -// Functions defined in reaxc_torsion_angles.cpp -extern double Calculate_Omega(rvec, double, rvec, double, rvec, double, rvec, double, - three_body_interaction_data*, three_body_interaction_data*, - rvec, rvec, rvec, rvec, output_controls*); - -/* ---------------------------------------------------------------------- */ - -void Torsion_AnglesOMP( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls *out_control ) -{ -#ifdef OMP_TIMING - double endTimeBase, startTimeBase; - startTimeBase = MPI_Wtime(); -#endif - - int natoms = system->n; - reax_list *bonds = (*lists) + BONDS; - reax_list *thb_intrs = (*lists) + THREE_BODIES; - double p_tor2 = system->reax_param.gp.l[23]; - double p_tor3 = system->reax_param.gp.l[24]; - double p_tor4 = system->reax_param.gp.l[25]; - double p_cot2 = system->reax_param.gp.l[27]; - double total_Etor = 0; - double total_Econ = 0; - int nthreads = control->nthreads; - -#if defined(_OPENMP) -#pragma omp parallel default(shared) reduction(+: total_Etor, total_Econ) -#endif - { - int i, j, k, l, pi, pj, pk, pl, pij, plk; - int type_i, type_j, type_k, type_l; - int start_j, end_j; - int start_pj, end_pj, start_pk, end_pk; - int num_frb_intrs = 0; - - double Delta_j, Delta_k; - double r_ij, r_jk, r_kl, r_li; - double BOA_ij, BOA_jk, BOA_kl; - - double exp_tor2_ij, exp_tor2_jk, exp_tor2_kl; - double exp_tor1, exp_tor3_DjDk, exp_tor4_DjDk, exp_tor34_inv; - double exp_cot2_jk, exp_cot2_ij, exp_cot2_kl; - double fn10, f11_DjDk, dfn11, fn12; - double theta_ijk, theta_jkl; - double sin_ijk, sin_jkl; - double cos_ijk, cos_jkl; - double tan_ijk_i, tan_jkl_i; - double omega, cos_omega, cos2omega, cos3omega; - rvec dcos_omega_di, dcos_omega_dj, dcos_omega_dk, dcos_omega_dl; - double CV, cmn, CEtors1, CEtors2, CEtors3, CEtors4; - double CEtors5, CEtors6, CEtors7, CEtors8, CEtors9; - double Cconj, CEconj1, CEconj2, CEconj3; - double CEconj4, CEconj5, CEconj6; - double e_tor, e_con; - rvec dvec_li; - rvec force, ext_press; - ivec rel_box_jl; - // rtensor total_rtensor, temp_rtensor; - four_body_header *fbh; - four_body_parameters *fbp; - bond_data *pbond_ij, *pbond_jk, *pbond_kl; - bond_order_data *bo_ij, *bo_jk, *bo_kl; - three_body_interaction_data *p_ijk, *p_jkl; - - // Virial tallying variables - double delil[3], deljl[3], delkl[3]; - double eng_tmp, fi_tmp[3], fj_tmp[3], fk_tmp[3]; - -#if defined(_OPENMP) - int tid = omp_get_thread_num(); -#else - int tid = 0; -#endif - long reductionOffset = (system->N * tid); - class PairReaxCOMP *pair_reax_ptr; - pair_reax_ptr = static_cast(system->pair_ptr); - class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); - -#if defined(_OPENMP) -#pragma omp for schedule(static) -#endif - for (j = 0; j < system->N; ++j) { - start_j = Start_Index(j, bonds); - end_j = End_Index(j, bonds); - - for (pk = start_j; pk < end_j; ++pk) { - bo_jk = &( bonds->select.bond_list[pk].bo_data ); - for (k = 0; k < nthreads; ++k) - bo_jk->CdboReduction[k] = 0.; - } - } - -#if defined(_OPENMP) -#pragma omp for schedule(dynamic,50) -#endif - for (j = 0; j < natoms; ++j) { - type_j = system->my_atoms[j].type; - Delta_j = workspace->Delta_boc[j]; - start_j = Start_Index(j, bonds); - end_j = End_Index(j, bonds); - - for (pk = start_j; pk < end_j; ++pk) { - pbond_jk = &( bonds->select.bond_list[pk] ); - k = pbond_jk->nbr; - bo_jk = &( pbond_jk->bo_data ); - BOA_jk = bo_jk->BO - control->thb_cut; - - /* see if there are any 3-body interactions involving j&k - where j is the central atom. Otherwise there is no point in - trying to form a 4-body interaction out of this neighborhood */ - if (system->my_atoms[j].orig_id < system->my_atoms[k].orig_id && - bo_jk->BO > control->thb_cut/*0*/ && Num_Entries(pk, thb_intrs)) { - pj = pbond_jk->sym_index; // pj points to j on k's list - - /* do the same check as above: - are there any 3-body interactions involving k&j - where k is the central atom */ - if (Num_Entries(pj, thb_intrs)) { - type_k = system->my_atoms[k].type; - Delta_k = workspace->Delta_boc[k]; - r_jk = pbond_jk->d; - - start_pk = Start_Index(pk, thb_intrs ); - end_pk = End_Index(pk, thb_intrs ); - start_pj = Start_Index(pj, thb_intrs ); - end_pj = End_Index(pj, thb_intrs ); - - exp_tor2_jk = exp( -p_tor2 * BOA_jk ); - exp_cot2_jk = exp( -p_cot2 * SQR(BOA_jk - 1.5) ); - exp_tor3_DjDk = exp( -p_tor3 * (Delta_j + Delta_k) ); - exp_tor4_DjDk = exp( p_tor4 * (Delta_j + Delta_k) ); - exp_tor34_inv = 1.0 / (1.0 + exp_tor3_DjDk + exp_tor4_DjDk); - f11_DjDk = (2.0 + exp_tor3_DjDk) * exp_tor34_inv; - - - /* pick i up from j-k interaction where j is the central atom */ - for (pi = start_pk; pi < end_pk; ++pi) { - p_ijk = &( thb_intrs->select.three_body_list[pi] ); - pij = p_ijk->pthb; // pij is pointer to i on j's bond_list - pbond_ij = &( bonds->select.bond_list[pij] ); - bo_ij = &( pbond_ij->bo_data ); - - if (bo_ij->BO > control->thb_cut/*0*/) { - i = p_ijk->thb; - type_i = system->my_atoms[i].type; - r_ij = pbond_ij->d; - BOA_ij = bo_ij->BO - control->thb_cut; - - theta_ijk = p_ijk->theta; - sin_ijk = sin( theta_ijk ); - cos_ijk = cos( theta_ijk ); - //tan_ijk_i = 1. / tan( theta_ijk ); - if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) - tan_ijk_i = cos_ijk / MIN_SINE; - else if (sin_ijk <= 0 && sin_ijk >= -MIN_SINE) - tan_ijk_i = cos_ijk / -MIN_SINE; - else tan_ijk_i = cos_ijk / sin_ijk; - - exp_tor2_ij = exp( -p_tor2 * BOA_ij ); - exp_cot2_ij = exp( -p_cot2 * SQR(BOA_ij -1.5) ); - - - /* pick l up from j-k interaction where k is the central atom */ - for (pl = start_pj; pl < end_pj; ++pl) { - p_jkl = &( thb_intrs->select.three_body_list[pl] ); - l = p_jkl->thb; - plk = p_jkl->pthb; //pointer to l on k's bond_list! - pbond_kl = &( bonds->select.bond_list[plk] ); - bo_kl = &( pbond_kl->bo_data ); - type_l = system->my_atoms[l].type; - fbh = &(system->reax_param.fbp[type_i][type_j] - [type_k][type_l]); - fbp = &(system->reax_param.fbp[type_i][type_j] - [type_k][type_l].prm[0]); - - if (i != l && fbh->cnt && - bo_kl->BO > control->thb_cut/*0*/ && - bo_ij->BO * bo_jk->BO * bo_kl->BO > control->thb_cut/*0*/) { - ++num_frb_intrs; - //fprintf(stderr, - // "%5d: %6d %6d %6d %6d\n", num_frb_intrs, - // system->my_atoms[i].orig_id,system->my_atoms[j].orig_id, - // system->my_atoms[k].orig_id,system->my_atoms[l].orig_id); - - r_kl = pbond_kl->d; - BOA_kl = bo_kl->BO - control->thb_cut; - - theta_jkl = p_jkl->theta; - sin_jkl = sin( theta_jkl ); - cos_jkl = cos( theta_jkl ); - //tan_jkl_i = 1. / tan( theta_jkl ); - if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) - tan_jkl_i = cos_jkl / MIN_SINE; - else if (sin_jkl <= 0 && sin_jkl >= -MIN_SINE) - tan_jkl_i = cos_jkl / -MIN_SINE; - else tan_jkl_i = cos_jkl /sin_jkl; - - rvec_ScaledSum( dvec_li, 1., system->my_atoms[i].x, - -1., system->my_atoms[l].x ); - r_li = rvec_Norm( dvec_li ); - - - /* omega and its derivative */ - omega = Calculate_Omega( pbond_ij->dvec, r_ij, - pbond_jk->dvec, r_jk, - pbond_kl->dvec, r_kl, - dvec_li, r_li, - p_ijk, p_jkl, - dcos_omega_di, dcos_omega_dj, - dcos_omega_dk, dcos_omega_dl, - out_control ); - - cos_omega = cos( omega ); - cos2omega = cos( 2. * omega ); - cos3omega = cos( 3. * omega ); - /* end omega calculations */ - - /* torsion energy */ - exp_tor1 = exp( fbp->p_tor1 * - SQR(2.0 - bo_jk->BO_pi - f11_DjDk) ); - exp_tor2_kl = exp( -p_tor2 * BOA_kl ); - exp_cot2_kl = exp( -p_cot2 * SQR(BOA_kl - 1.5) ); - fn10 = (1.0 - exp_tor2_ij) * (1.0 - exp_tor2_jk) * - (1.0 - exp_tor2_kl); - - CV = 0.5 * ( fbp->V1 * (1.0 + cos_omega) + - fbp->V2 * exp_tor1 * (1.0 - cos2omega) + - fbp->V3 * (1.0 + cos3omega) ); - - total_Etor += e_tor = fn10 * sin_ijk * sin_jkl * CV; - - dfn11 = (-p_tor3 * exp_tor3_DjDk + - (p_tor3 * exp_tor3_DjDk - p_tor4 * exp_tor4_DjDk) * - (2.0 + exp_tor3_DjDk) * exp_tor34_inv) * - exp_tor34_inv; - - CEtors1 = sin_ijk * sin_jkl * CV; - - CEtors2 = -fn10 * 2.0 * fbp->p_tor1 * fbp->V2 * exp_tor1 * - (2.0 - bo_jk->BO_pi - f11_DjDk) * (1.0 - SQR(cos_omega)) * - sin_ijk * sin_jkl; - CEtors3 = CEtors2 * dfn11; - - CEtors4 = CEtors1 * p_tor2 * exp_tor2_ij * - (1.0 - exp_tor2_jk) * (1.0 - exp_tor2_kl); - CEtors5 = CEtors1 * p_tor2 * - (1.0 - exp_tor2_ij) * exp_tor2_jk * (1.0 - exp_tor2_kl); - CEtors6 = CEtors1 * p_tor2 * - (1.0 - exp_tor2_ij) * (1.0 - exp_tor2_jk) * exp_tor2_kl; - - cmn = -fn10 * CV; - CEtors7 = cmn * sin_jkl * tan_ijk_i; - CEtors8 = cmn * sin_ijk * tan_jkl_i; - - CEtors9 = fn10 * sin_ijk * sin_jkl * - (0.5 * fbp->V1 - 2.0 * fbp->V2 * exp_tor1 * cos_omega + - 1.5 * fbp->V3 * (cos2omega + 2.0 * SQR(cos_omega))); - /* end of torsion energy */ - - - /* 4-body conjugation energy */ - fn12 = exp_cot2_ij * exp_cot2_jk * exp_cot2_kl; - //data->my_en.e_con += e_con = - total_Econ += e_con = - fbp->p_cot1 * fn12 * - (1.0 + (SQR(cos_omega) - 1.0) * sin_ijk * sin_jkl); - - Cconj = -2.0 * fn12 * fbp->p_cot1 * p_cot2 * - (1.0 + (SQR(cos_omega) - 1.0) * sin_ijk * sin_jkl); - - CEconj1 = Cconj * (BOA_ij - 1.5e0); - CEconj2 = Cconj * (BOA_jk - 1.5e0); - CEconj3 = Cconj * (BOA_kl - 1.5e0); - - CEconj4 = -fbp->p_cot1 * fn12 * - (SQR(cos_omega) - 1.0) * sin_jkl * tan_ijk_i; - CEconj5 = -fbp->p_cot1 * fn12 * - (SQR(cos_omega) - 1.0) * sin_ijk * tan_jkl_i; - CEconj6 = 2.0 * fbp->p_cot1 * fn12 * - cos_omega * sin_ijk * sin_jkl; - /* end 4-body conjugation energy */ - - /* FORCES */ - bo_jk->Cdbopi += CEtors2; - workspace->CdDelta[j] += CEtors3; - //workspace->CdDelta[k] += CEtors3; - workspace->CdDeltaReduction[reductionOffset+k] += CEtors3; - bo_ij->Cdbo += (CEtors4 + CEconj1); - bo_jk->Cdbo += (CEtors5 + CEconj2); - //bo_kl->Cdbo += (CEtors6 + CEconj3); - bo_kl->CdboReduction[tid] += (CEtors6 + CEconj3); - - if (control->virial == 0) { - /* dcos_theta_ijk */ - rvec_ScaledAdd( workspace->f[j], - CEtors7 + CEconj4, p_ijk->dcos_dj ); - rvec_ScaledAdd( workspace->forceReduction[reductionOffset+i], - CEtors7 + CEconj4, p_ijk->dcos_dk ); - rvec_ScaledAdd( workspace->forceReduction[reductionOffset+k], - CEtors7 + CEconj4, p_ijk->dcos_di ); - - /* dcos_theta_jkl */ - rvec_ScaledAdd( workspace->f[j], - CEtors8 + CEconj5, p_jkl->dcos_di ); - rvec_ScaledAdd( workspace->forceReduction[reductionOffset+k], - CEtors8 + CEconj5, p_jkl->dcos_dj ); - rvec_ScaledAdd( workspace->forceReduction[reductionOffset+l], - CEtors8 + CEconj5, p_jkl->dcos_dk ); - - /* dcos_omega */ - rvec_ScaledAdd( workspace->f[j], - CEtors9 + CEconj6, dcos_omega_dj ); - rvec_ScaledAdd( workspace->forceReduction[reductionOffset+i], - CEtors9 + CEconj6, dcos_omega_di ); - rvec_ScaledAdd( workspace->forceReduction[reductionOffset+k], - CEtors9 + CEconj6, dcos_omega_dk ); - rvec_ScaledAdd( workspace->forceReduction[reductionOffset+l], - CEtors9 + CEconj6, dcos_omega_dl ); - } - else { - ivec_Sum(rel_box_jl, pbond_jk->rel_box, pbond_kl->rel_box); - - /* dcos_theta_ijk */ - rvec_Scale( force, CEtors7 + CEconj4, p_ijk->dcos_dk ); - rvec_Add( workspace->forceReduction[reductionOffset+i], force ); - rvec_iMultiply( ext_press, pbond_ij->rel_box, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - - rvec_ScaledAdd( workspace->f[j], - CEtors7 + CEconj4, p_ijk->dcos_dj ); - - rvec_Scale( force, CEtors7 + CEconj4, p_ijk->dcos_di ); - rvec_Add( workspace->forceReduction[reductionOffset+k], force ); - rvec_iMultiply( ext_press, pbond_jk->rel_box, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - - /* dcos_theta_jkl */ - rvec_ScaledAdd( workspace->f[j], - CEtors8 + CEconj5, p_jkl->dcos_di ); - - rvec_Scale( force, CEtors8 + CEconj5, p_jkl->dcos_dj ); - rvec_Add( workspace->forceReduction[reductionOffset+k], force ); - rvec_iMultiply( ext_press, pbond_jk->rel_box, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - - rvec_Scale( force, CEtors8 + CEconj5, p_jkl->dcos_dk ); - rvec_Add( workspace->forceReduction[reductionOffset+l], force ); - rvec_iMultiply( ext_press, rel_box_jl, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - - /* dcos_omega */ - rvec_Scale( force, CEtors9 + CEconj6, dcos_omega_di ); - rvec_Add( workspace->forceReduction[reductionOffset+i], force ); - rvec_iMultiply( ext_press, pbond_ij->rel_box, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - - rvec_ScaledAdd( workspace->f[j], - CEtors9 + CEconj6, dcos_omega_dj ); - - rvec_Scale( force, CEtors9 + CEconj6, dcos_omega_dk ); - rvec_Add( workspace->forceReduction[reductionOffset+k], force ); - rvec_iMultiply( ext_press, pbond_jk->rel_box, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - - rvec_Scale( force, CEtors9 + CEconj6, dcos_omega_dl ); - rvec_Add( workspace->forceReduction[reductionOffset+i], force ); - rvec_iMultiply( ext_press, rel_box_jl, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - } - - /* tally into per-atom virials */ - if (system->pair_ptr->vflag_atom || system->pair_ptr->evflag) { - - // acquire vectors - rvec_ScaledSum( delil, 1., system->my_atoms[l].x, - -1., system->my_atoms[i].x ); - rvec_ScaledSum( deljl, 1., system->my_atoms[l].x, - -1., system->my_atoms[j].x ); - rvec_ScaledSum( delkl, 1., system->my_atoms[l].x, - -1., system->my_atoms[k].x ); - // dcos_theta_ijk - rvec_Scale( fi_tmp, CEtors7 + CEconj4, p_ijk->dcos_dk ); - rvec_Scale( fj_tmp, CEtors7 + CEconj4, p_ijk->dcos_dj ); - rvec_Scale( fk_tmp, CEtors7 + CEconj4, p_ijk->dcos_di ); - - // dcos_theta_jkl - rvec_ScaledAdd( fj_tmp, CEtors8 + CEconj5, p_jkl->dcos_di ); - rvec_ScaledAdd( fk_tmp, CEtors8 + CEconj5, p_jkl->dcos_dj ); - - // dcos_omega - rvec_ScaledAdd( fi_tmp, CEtors9 + CEconj6, dcos_omega_di ); - rvec_ScaledAdd( fj_tmp, CEtors9 + CEconj6, dcos_omega_dj ); - rvec_ScaledAdd( fk_tmp, CEtors9 + CEconj6, dcos_omega_dk ); - - // tally - eng_tmp = e_tor + e_con; - - if (system->pair_ptr->evflag) - pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, j, k, system->n, 1, - eng_tmp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); - - // NEED TO MAKE AN OMP VERSION OF THIS CALL! - if (system->pair_ptr->vflag_atom) - system->pair_ptr->v_tally4(i, j, k, l, fi_tmp, fj_tmp, fk_tmp, - delil, deljl, delkl ); - } - - } // pl check ends - } // pl loop ends - } // pi check ends - } // pi loop ends - } // k-j neighbor check ends - } // jmy_en.e_tor = total_Etor; - data->my_en.e_con = total_Econ; - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTETORSIONANGLESBOINDEX] += (endTimeBase-startTimeBase); -#endif -} diff --git a/src/OPENMP/reaxc_torsion_angles_omp.h b/src/OPENMP/reaxc_torsion_angles_omp.h deleted file mode 100644 index 4b62f90241..0000000000 --- a/src/OPENMP/reaxc_torsion_angles_omp.h +++ /dev/null @@ -1,38 +0,0 @@ -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __TORSION_ANGLES_OMP_H_ -#define __TORSION_ANGLES_OMP_H_ - -#include "reaxc_torsion_angles.h" -#include "reaxc_types.h" - -void Torsion_AnglesOMP(reax_system *, control_params *, simulation_data *, storage *, reax_list **, - output_controls *); - -#endif diff --git a/src/OPENMP/reaxc_valence_angles_omp.cpp b/src/OPENMP/reaxc_valence_angles_omp.cpp deleted file mode 100644 index 49a7e874cd..0000000000 --- a/src/OPENMP/reaxc_valence_angles_omp.cpp +++ /dev/null @@ -1,620 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_valence_angles_omp.h" - -#include "error.h" -#include "fix_omp.h" -#include "pair_reaxc_omp.h" - -#include "reaxc_defs.h" -#include "reaxc_types.h" -#include "reaxc_valence_angles.h" -#include "reaxc_list.h" -#include "reaxc_vector.h" - -#include - -#if defined(_OPENMP) -#include -#endif - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -void Calculate_dCos_ThetaOMP( rvec dvec_ji, double d_ji, rvec dvec_jk, double d_jk, - rvec* dcos_theta_di, - rvec* dcos_theta_dj, - rvec* dcos_theta_dk ) -{ - double sqr_d_ji = SQR(d_ji); - double sqr_d_jk = SQR(d_jk); - double inv_dists = 1.0 / (d_ji * d_jk); - double inv_dists3 = inv_dists * inv_dists * inv_dists; - double dot_dvecs = dvec_ji[0]*dvec_jk[0] + dvec_ji[1]*dvec_jk[1] + dvec_ji[2]*dvec_jk[2]; - double Cdot_inv3 = dot_dvecs * inv_dists3; - - double csqr_jk = Cdot_inv3 * sqr_d_jk; - double csqr_ji = Cdot_inv3 * sqr_d_ji; - - // Try to help compiler out by unrolling - // x-component - double dinv_jk = dvec_jk[0] * inv_dists; - double dinv_ji = dvec_ji[0] * inv_dists; - - double cdev_ji = csqr_jk * dvec_ji[0]; - double cdev_jk = csqr_ji * dvec_jk[0]; - - (*dcos_theta_di)[0] = dinv_jk - cdev_ji; - (*dcos_theta_dj)[0] = -(dinv_jk + dinv_ji) + cdev_ji + cdev_jk; - (*dcos_theta_dk)[0] = dinv_ji - cdev_jk; - - // y-component - dinv_jk = dvec_jk[1] * inv_dists; - dinv_ji = dvec_ji[1] * inv_dists; - - cdev_ji = csqr_jk * dvec_ji[1]; - cdev_jk = csqr_ji * dvec_jk[1]; - - (*dcos_theta_di)[1] = dinv_jk - cdev_ji; - (*dcos_theta_dj)[1] = -(dinv_jk + dinv_ji) + cdev_ji + cdev_jk; - (*dcos_theta_dk)[1] = dinv_ji - cdev_jk; - - // z-component - dinv_jk = dvec_jk[2] * inv_dists; - dinv_ji = dvec_ji[2] * inv_dists; - - cdev_ji = csqr_jk * dvec_ji[2]; - cdev_jk = csqr_ji * dvec_jk[2]; - - (*dcos_theta_di)[2] = dinv_jk - cdev_ji; - (*dcos_theta_dj)[2] = -(dinv_jk + dinv_ji) + cdev_ji + cdev_jk; - (*dcos_theta_dk)[2] = dinv_ji - cdev_jk; -} - -/* ---------------------------------------------------------------------- */ - -/* this is a 3-body interaction in which the main role is - played by j which sits in the middle of the other two. */ -void Valence_AnglesOMP( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls * /* out_control */) -{ - -#ifdef OMP_TIMING - double endTimeBase, startTimeBase; - startTimeBase = MPI_Wtime(); -#endif - - reax_list *bonds = (*lists) + BONDS; - reax_list *thb_intrs = (*lists) + THREE_BODIES; - - // Precompute and store valence_angle offsets for OpenMP code. - int * _my_offset = workspace->valence_angle_atom_myoffset; - - /* global parameters used in these calculations */ - double p_val6 = system->reax_param.gp.l[14]; - double p_val8 = system->reax_param.gp.l[33]; - double p_val9 = system->reax_param.gp.l[16]; - double p_val10 = system->reax_param.gp.l[17]; - double total_Eang = 0; - double total_Epen = 0; - double total_Ecoa = 0; - - int nthreads = control->nthreads; - int num_thb_intrs = 0; - int TWICE = 2; -#if defined(_OPENMP) -#pragma omp parallel default(shared) reduction(+:total_Eang, total_Epen, total_Ecoa, num_thb_intrs) -#endif - { - int i, j, pi, k, pk, t; - int type_i, type_j, type_k; - int start_j, end_j, start_pk, end_pk; - int cnt, my_offset; - - double temp, temp_bo_jt, pBOjt7; - double p_val1, p_val2, p_val3, p_val4, p_val5, p_val7; - double p_pen1, p_pen2, p_pen3, p_pen4; - double p_coa1, p_coa2, p_coa3, p_coa4; - double trm8, expval6, expval7, expval2theta, expval12theta, exp3ij, exp3jk; - double exp_pen2ij, exp_pen2jk, exp_pen3, exp_pen4, trm_pen34, exp_coa2; - double dSBO1, dSBO2, SBO, SBO2, CSBO2, SBOp, prod_SBO, vlpadj; - double CEval1, CEval2, CEval3, CEval4, CEval5, CEval6, CEval7, CEval8; - double CEpen1, CEpen2, CEpen3; - double e_ang, e_coa, e_pen; - double CEcoa1, CEcoa2, CEcoa3, CEcoa4, CEcoa5; - double Cf7ij, Cf7jk, Cf8j, Cf9j; - double f7_ij, f7_jk, f8_Dj, f9_Dj; - double Ctheta_0, theta_0, theta_00, theta, cos_theta, sin_theta; - double BOA_ij, BOA_jk; - rvec force, ext_press; - // rtensor temp_rtensor, total_rtensor; - - // Tallying variables - double eng_tmp, fi_tmp[3], fj_tmp[3], fk_tmp[3]; - double delij[3], delkj[3]; - - three_body_header *thbh; - three_body_parameters *thbp; - three_body_interaction_data *p_ijk, *p_kji; - bond_data *pbond_ij, *pbond_jk, *pbond_jt; - bond_order_data *bo_ij, *bo_jk, *bo_jt; - -#if defined(_OPENMP) - int tid = omp_get_thread_num(); -#else - int tid = 0; -#endif - long reductionOffset = (system->N * tid); - class PairReaxCOMP *pair_reax_ptr; - pair_reax_ptr = static_cast(system->pair_ptr); - class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); - - // Run through a minimal for (jnum_intrs / nthreads; - -#if defined(_OPENMP) -#pragma omp for schedule(dynamic,50) -#endif - for (j = 0; j < system->N; ++j) { - type_j = system->my_atoms[j].type; - _my_offset[j] = 0; - if (type_j < 0) continue; - - start_j = Start_Index(j, bonds); - end_j = End_Index(j, bonds); - - // Always point to start of workspace to count angles - my_offset = tid * per_thread; - - for (pi = start_j; pi < end_j; ++pi) { - Set_Start_Index( pi, my_offset, thb_intrs ); - pbond_ij = &(bonds->select.bond_list[pi]); - bo_ij = &(pbond_ij->bo_data); - BOA_ij = bo_ij->BO - control->thb_cut; - - if (BOA_ij > 0.0) { - i = pbond_ij->nbr; - - /* first copy 3-body intrs from previously computed ones where i>k. - in the second for-loop below, - we compute only new 3-body intrs where i < k */ - for (pk = start_j; pk < pi; ++pk) { - start_pk = Start_Index( pk, thb_intrs ); - end_pk = End_Index( pk, thb_intrs ); - - for (t = start_pk; t < end_pk; ++t) - if (thb_intrs->select.three_body_list[t].thb == i) { - - p_ijk = &(thb_intrs->select.three_body_list[my_offset] ); - p_ijk->thb = bonds->select.bond_list[pk].nbr; - - ++my_offset; - break; - } - } // for (pk) - - /* and this is the second for loop mentioned above */ - for (pk = pi+1; pk < end_j; ++pk) { - pbond_jk = &(bonds->select.bond_list[pk]); - k = pbond_jk->nbr; - - if (j >= system->n && i >= system->n && k >= system->n) continue; - - p_ijk = &( thb_intrs->select.three_body_list[my_offset] ); - p_ijk->thb = k; - - ++my_offset; // add this to the list of 3-body interactions - } // for (pk) - } // if () - - Set_End_Index(pi, my_offset, thb_intrs ); - } // for (pi) - - // Confirm that thb_intrs->num_intrs / nthreads is enough to hold all angles from a single atom - if (my_offset >= (tid+1)*per_thread) { - char errmsg[512]; - snprintf( errmsg, 512, "step%d-ran out of space on angle_list for atom %i:\n" - " nthreads= %d, tid=%d, my_offset=%d, per_thread=%d\n" - " num_intrs= %i N= %i\n" - , data->step, j, nthreads, tid, my_offset, per_thread,thb_intrs->num_intrs , system->N); - control->error_ptr->one(FLERR, errmsg); - } - - // Number of angles owned by this atom - _my_offset[j] = my_offset - tid * per_thread; - } // for (j) - - // Wait for all threads to finish counting angles -#if defined(_OPENMP) && !defined(__NVCC__) -#pragma omp barrier -#endif - // Master thread uses angle counts to compute offsets - // This can be threaded -#if defined(_OPENMP) && !defined(__NVCC__) -#pragma omp master -#endif - { - int current_count = 0; - int m = _my_offset[0]; - _my_offset[0] = current_count; - for (j=1; jN; j++) { - current_count+= m; - m = _my_offset[j]; - _my_offset[j] = current_count; - } - _my_offset[system->N] = current_count + m; // Used to test if last particle has any angles - } - - // All threads wait till master thread finished computing offsets -#if defined(_OPENMP) && !defined(__NVCC__) -#pragma omp barrier -#endif - // Original loop, but now using precomputed offsets - // Safe to use all threads available, regardless of threads tasked above - // We also now skip over atoms that have no angles assigned -#if defined(_OPENMP) -#pragma omp for schedule(dynamic,50)//(dynamic,chunksize)//(guided) -#endif - for (j = 0; j < system->N; ++j) { // Ray: the first one with system->N - type_j = system->my_atoms[j].type; - if (type_j < 0) continue; - - // Skip if no angles for this atom - if (_my_offset[j] == _my_offset[j+1]) continue; - - start_j = Start_Index(j, bonds); - end_j = End_Index(j, bonds); - - type_j = system->my_atoms[j].type; - - my_offset = _my_offset[j]; - - p_val3 = system->reax_param.sbp[ type_j ].p_val3; - p_val5 = system->reax_param.sbp[ type_j ].p_val5; - - SBOp = 0, prod_SBO = 1; - for (t = start_j; t < end_j; ++t) { - bo_jt = &(bonds->select.bond_list[t].bo_data); - SBOp += (bo_jt->BO_pi + bo_jt->BO_pi2); - temp = SQR( bo_jt->BO ); - temp *= temp; - temp *= temp; - prod_SBO *= exp( -temp ); - } - - // modifications to match Adri's code - 09/01/09 - if (workspace->vlpex[j] >= 0) { - vlpadj = 0; - dSBO2 = prod_SBO - 1; - } else { - vlpadj = workspace->nlp[j]; - dSBO2 = (prod_SBO - 1) * (1 - p_val8 * workspace->dDelta_lp[j]); - } - - SBO = SBOp + (1 - prod_SBO) * (-workspace->Delta_boc[j] - p_val8 * vlpadj); - dSBO1 = -8 * prod_SBO * ( workspace->Delta_boc[j] + p_val8 * vlpadj ); - - if (SBO <= 0) - SBO2 = 0, CSBO2 = 0; - else if (SBO > 0 && SBO <= 1) { - SBO2 = pow( SBO, p_val9 ); - CSBO2 = p_val9 * pow( SBO, p_val9 - 1 ); - } - else if (SBO > 1 && SBO < 2) { - SBO2 = 2 - pow( 2-SBO, p_val9 ); - CSBO2 = p_val9 * pow( 2 - SBO, p_val9 - 1 ); - } - else - SBO2 = 2, CSBO2 = 0; - - expval6 = exp( p_val6 * workspace->Delta_boc[j] ); - - for (pi = start_j; pi < end_j; ++pi) { - Set_Start_Index( pi, my_offset, thb_intrs ); - pbond_ij = &(bonds->select.bond_list[pi]); - bo_ij = &(pbond_ij->bo_data); - BOA_ij = bo_ij->BO - control->thb_cut; - - - if (BOA_ij > 0.0) { - i = pbond_ij->nbr; - type_i = system->my_atoms[i].type; - - - /* first copy 3-body intrs from previously computed ones where i>k. - in the second for-loop below, - we compute only new 3-body intrs where i < k */ - for (pk = start_j; pk < pi; ++pk) { - start_pk = Start_Index( pk, thb_intrs ); - end_pk = End_Index( pk, thb_intrs ); - - for (t = start_pk; t < end_pk; ++t) - if (thb_intrs->select.three_body_list[t].thb == i) { - p_ijk = &(thb_intrs->select.three_body_list[my_offset] ); - p_kji = &(thb_intrs->select.three_body_list[t]); - - p_ijk->thb = bonds->select.bond_list[pk].nbr; - p_ijk->pthb = pk; - p_ijk->theta = p_kji->theta; - rvec_Copy( p_ijk->dcos_di, p_kji->dcos_dk ); - rvec_Copy( p_ijk->dcos_dj, p_kji->dcos_dj ); - rvec_Copy( p_ijk->dcos_dk, p_kji->dcos_di ); - - ++my_offset; - ++num_thb_intrs; - break; - } - } // for (pk) - - - /* and this is the second for loop mentioned above */ - for (pk = pi+1; pk < end_j; ++pk) { - pbond_jk = &(bonds->select.bond_list[pk]); - bo_jk = &(pbond_jk->bo_data); - BOA_jk = bo_jk->BO - control->thb_cut; - k = pbond_jk->nbr; - type_k = system->my_atoms[k].type; - p_ijk = &( thb_intrs->select.three_body_list[my_offset] ); - - // Fix by Sudhir - // if (BOA_jk <= 0) continue; - if (j >= system->n && i >= system->n && k >= system->n) continue; - - Calculate_Theta( pbond_ij->dvec, pbond_ij->d, - pbond_jk->dvec, pbond_jk->d, - &theta, &cos_theta ); - - Calculate_dCos_ThetaOMP( pbond_ij->dvec, pbond_ij->d, - pbond_jk->dvec, pbond_jk->d, - &(p_ijk->dcos_di), &(p_ijk->dcos_dj), - &(p_ijk->dcos_dk) ); - p_ijk->thb = k; - p_ijk->pthb = pk; - p_ijk->theta = theta; - - sin_theta = sin( theta ); - if (sin_theta < 1.0e-5) - sin_theta = 1.0e-5; - - ++my_offset; // add this to the list of 3-body interactions - ++num_thb_intrs; - - if ((j < system->n) && (BOA_jk > 0.0) && - (bo_ij->BO > control->thb_cut) && - (bo_jk->BO > control->thb_cut) && - (bo_ij->BO * bo_jk->BO > control->thb_cutsq)) { - thbh = &( system->reax_param.thbp[ type_i ][ type_j ][ type_k ] ); - - for (cnt = 0; cnt < thbh->cnt; ++cnt) { - - if (fabs(thbh->prm[cnt].p_val1) > 0.001) { - thbp = &( thbh->prm[cnt] ); - - /* ANGLE ENERGY */ - p_val1 = thbp->p_val1; - p_val2 = thbp->p_val2; - p_val4 = thbp->p_val4; - p_val7 = thbp->p_val7; - theta_00 = thbp->theta_00; - - exp3ij = exp( -p_val3 * pow( BOA_ij, p_val4 ) ); - f7_ij = 1.0 - exp3ij; - Cf7ij = p_val3 * p_val4 * pow( BOA_ij, p_val4 - 1.0 ) * exp3ij; - - exp3jk = exp( -p_val3 * pow( BOA_jk, p_val4 ) ); - f7_jk = 1.0 - exp3jk; - Cf7jk = p_val3 * p_val4 * pow( BOA_jk, p_val4 - 1.0 ) * exp3jk; - - expval7 = exp( -p_val7 * workspace->Delta_boc[j] ); - trm8 = 1.0 + expval6 + expval7; - f8_Dj = p_val5 - ( (p_val5 - 1.0) * (2.0 + expval6) / trm8 ); - Cf8j = ( (1.0 - p_val5) / SQR(trm8) ) * - ( p_val6 * expval6 * trm8 - - (2.0 + expval6) * ( p_val6*expval6 - p_val7*expval7 ) ); - - theta_0 = 180.0 - theta_00 * (1.0 - - exp(-p_val10 * (2.0 - SBO2))); - theta_0 = DEG2RAD( theta_0 ); - - expval2theta = exp( -p_val2 * SQR(theta_0 - theta) ); - if (p_val1 >= 0) - expval12theta = p_val1 * (1.0 - expval2theta); - else // To avoid linear Me-H-Me angles (6/6/06) - expval12theta = p_val1 * -expval2theta; - - CEval1 = Cf7ij * f7_jk * f8_Dj * expval12theta; - CEval2 = Cf7jk * f7_ij * f8_Dj * expval12theta; - CEval3 = Cf8j * f7_ij * f7_jk * expval12theta; - CEval4 = -2.0 * p_val1 * p_val2 * f7_ij * f7_jk * f8_Dj * - expval2theta * (theta_0 - theta); - - Ctheta_0 = p_val10 * DEG2RAD(theta_00) * - exp( -p_val10 * (2.0 - SBO2) ); - - CEval5 = -CEval4 * Ctheta_0 * CSBO2; - CEval6 = CEval5 * dSBO1; - CEval7 = CEval5 * dSBO2; - CEval8 = -CEval4 / sin_theta; - - total_Eang += e_ang = - f7_ij * f7_jk * f8_Dj * expval12theta; - /* END ANGLE ENERGY*/ - - - /* PENALTY ENERGY */ - p_pen1 = thbp->p_pen1; - p_pen2 = system->reax_param.gp.l[19]; - p_pen3 = system->reax_param.gp.l[20]; - p_pen4 = system->reax_param.gp.l[21]; - - exp_pen2ij = exp( -p_pen2 * SQR( BOA_ij - 2.0 ) ); - exp_pen2jk = exp( -p_pen2 * SQR( BOA_jk - 2.0 ) ); - exp_pen3 = exp( -p_pen3 * workspace->Delta[j] ); - exp_pen4 = exp( p_pen4 * workspace->Delta[j] ); - trm_pen34 = 1.0 + exp_pen3 + exp_pen4; - f9_Dj = ( 2.0 + exp_pen3 ) / trm_pen34; - Cf9j = ( -p_pen3 * exp_pen3 * trm_pen34 - - (2.0 + exp_pen3) * ( -p_pen3 * exp_pen3 + - p_pen4 * exp_pen4 ) ) / - SQR( trm_pen34 ); - - total_Epen += e_pen = - p_pen1 * f9_Dj * exp_pen2ij * exp_pen2jk; - - CEpen1 = e_pen * Cf9j / f9_Dj; - temp = -2.0 * p_pen2 * e_pen; - CEpen2 = temp * (BOA_ij - 2.0); - CEpen3 = temp * (BOA_jk - 2.0); - /* END PENALTY ENERGY */ - - - /* COALITION ENERGY */ - p_coa1 = thbp->p_coa1; - p_coa2 = system->reax_param.gp.l[2]; - p_coa3 = system->reax_param.gp.l[38]; - p_coa4 = system->reax_param.gp.l[30]; - - exp_coa2 = exp( p_coa2 * workspace->Delta_val[j] ); - total_Ecoa += e_coa = - p_coa1 / (1. + exp_coa2) * - exp( -p_coa3 * SQR(workspace->total_bond_order[i]-BOA_ij) ) * - exp( -p_coa3 * SQR(workspace->total_bond_order[k]-BOA_jk) ) * - exp( -p_coa4 * SQR(BOA_ij - 1.5) ) * - exp( -p_coa4 * SQR(BOA_jk - 1.5) ); - - CEcoa1 = -2 * p_coa4 * (BOA_ij - 1.5) * e_coa; - CEcoa2 = -2 * p_coa4 * (BOA_jk - 1.5) * e_coa; - CEcoa3 = -p_coa2 * exp_coa2 * e_coa / (1 + exp_coa2); - CEcoa4 = -2 * p_coa3 * - (workspace->total_bond_order[i]-BOA_ij) * e_coa; - CEcoa5 = -2 * p_coa3 * - (workspace->total_bond_order[k]-BOA_jk) * e_coa; - /* END COALITION ENERGY */ - - - /* FORCES */ - bo_ij->Cdbo += (CEval1 + CEpen2 + (CEcoa1 - CEcoa4)); - bo_jk->Cdbo += (CEval2 + CEpen3 + (CEcoa2 - CEcoa5)); - workspace->CdDelta[j] += ((CEval3 + CEval7) + CEpen1 + CEcoa3); - workspace->CdDeltaReduction[reductionOffset+i] += CEcoa4; - workspace->CdDeltaReduction[reductionOffset+k] += CEcoa5; - - for (t = start_j; t < end_j; ++t) { - pbond_jt = &( bonds->select.bond_list[t] ); - bo_jt = &(pbond_jt->bo_data); - temp_bo_jt = bo_jt->BO; - temp = CUBE( temp_bo_jt ); - pBOjt7 = temp * temp * temp_bo_jt; - - bo_jt->Cdbo += (CEval6 * pBOjt7); - bo_jt->Cdbopi += CEval5; - bo_jt->Cdbopi2 += CEval5; - } - - if (control->virial == 0) { - rvec_ScaledAdd( workspace->f[j], CEval8, p_ijk->dcos_dj ); - rvec_ScaledAdd( workspace->forceReduction[reductionOffset+i], - CEval8, p_ijk->dcos_di ); - rvec_ScaledAdd( workspace->forceReduction[reductionOffset+k], - CEval8, p_ijk->dcos_dk ); - } else { - /* terms not related to bond order derivatives are - added directly into forces and pressure vector/tensor */ - rvec_Scale( force, CEval8, p_ijk->dcos_di ); - rvec_Add( workspace->forceReduction[reductionOffset+i], force ); - - rvec_iMultiply( ext_press, pbond_ij->rel_box, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - - rvec_ScaledAdd( workspace->f[j], CEval8, p_ijk->dcos_dj ); - - rvec_Scale( force, CEval8, p_ijk->dcos_dk ); - rvec_Add( workspace->forceReduction[reductionOffset+k], force ); - - rvec_iMultiply( ext_press, pbond_jk->rel_box, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - } - - /* tally into per-atom virials */ - if (system->pair_ptr->vflag_atom || system->pair_ptr->evflag) { - - /* Acquire vectors */ - rvec_ScaledSum( delij, 1., system->my_atoms[i].x, - -1., system->my_atoms[j].x ); - rvec_ScaledSum( delkj, 1., system->my_atoms[k].x, - -1., system->my_atoms[j].x ); - - rvec_Scale( fi_tmp, -CEval8, p_ijk->dcos_di ); - rvec_Scale( fj_tmp, -CEval8, p_ijk->dcos_dj ); - rvec_Scale( fk_tmp, -CEval8, p_ijk->dcos_dk ); - - eng_tmp = e_ang + e_pen + e_coa; - - if (system->pair_ptr->evflag) - pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, j, j, system->N, 1, - eng_tmp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); - if (system->pair_ptr->vflag_atom) - // NEED TO MAKE AN OMP VERSION OF THIS CALL! - system->pair_ptr->v_tally3( i, j, k, fi_tmp, fk_tmp, delij, delkj); - } - - } // if (p_val1>0.001) - } // for (cnt) - } // if (j0) - } // for (pk) - } // if (BOA_ij>0) - - Set_End_Index(pi, my_offset, thb_intrs ); - } // for (pi) - } // for (j) - } // end omp parallel - - data->my_en.e_ang = total_Eang; - data->my_en.e_pen = total_Epen; - data->my_en.e_coa = total_Ecoa; - - if (num_thb_intrs >= thb_intrs->num_intrs * DANGER_ZONE) { - workspace->realloc.num_3body = num_thb_intrs * TWICE; - if (num_thb_intrs > thb_intrs->num_intrs) { - char errmsg[128]; - snprintf(errmsg, 128, "step%d-ran out of space on angle_list: top=%d, max=%d", - data->step, num_thb_intrs, thb_intrs->num_intrs); - control->error_ptr->one(FLERR, errmsg); - } - } - -#ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTEVALENCEANGLESBOINDEX] += (endTimeBase-startTimeBase); -#endif -} diff --git a/src/OPENMP/reaxc_valence_angles_omp.h b/src/OPENMP/reaxc_valence_angles_omp.h deleted file mode 100644 index f1a4fef505..0000000000 --- a/src/OPENMP/reaxc_valence_angles_omp.h +++ /dev/null @@ -1,39 +0,0 @@ -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - Website: https://www.cs.purdue.edu/puremd - - Copyright (2010) Purdue University - - Contributing authors: - H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama - Corresponding author: - Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __VALENCE_ANGLES_OMP_H_ -#define __VALENCE_ANGLES_OMP_H_ - -#include "reaxc_types.h" - -void Valence_AnglesOMP(reax_system *, control_params *, simulation_data *, storage *, reax_list **, - output_controls *); - -void Calculate_dCos_ThetaOMP(rvec, double, rvec, double, rvec *, rvec *, rvec *); - -#endif diff --git a/src/OPENMP/reaxff_bond_orders_omp.cpp b/src/OPENMP/reaxff_bond_orders_omp.cpp new file mode 100644 index 0000000000..2fe68280d1 --- /dev/null +++ b/src/OPENMP/reaxff_bond_orders_omp.cpp @@ -0,0 +1,515 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + + Contributing authors: + H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama + Corresponding author: + Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_omp.h" + +#include "fix_omp.h" +#include "pair_reaxff_omp.h" +#include "reaxff_api.h" + +#include + +using namespace LAMMPS_NS; + +namespace ReaxFF { + void Add_dBond_to_ForcesOMP(reax_system *system, int i, int pj, storage *workspace, reax_list **lists) + { + reax_list *bonds = (*lists) + BONDS; + bond_data *nbr_j, *nbr_k; + bond_order_data *bo_ij, *bo_ji; + dbond_coefficients coef; + int pk, k, j; + + PairReaxFFOMP *pair_reax_ptr = static_cast(system->pair_ptr); + + int tid = get_tid(); + ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); + long reductionOffset = (system->N * tid); + + /* Virial Tallying variables */ + rvec fi_tmp, fj_tmp, fk_tmp, delij, delji, delki, delkj, temp; + + /* Initializations */ + nbr_j = &(bonds->select.bond_list[pj]); + j = nbr_j->nbr; + bo_ij = &(nbr_j->bo_data); + bo_ji = &(bonds->select.bond_list[nbr_j->sym_index].bo_data); + + double c = bo_ij->Cdbo + bo_ji->Cdbo; + coef.C1dbo = bo_ij->C1dbo * c; + coef.C2dbo = bo_ij->C2dbo * c; + coef.C3dbo = bo_ij->C3dbo * c; + + c = bo_ij->Cdbopi + bo_ji->Cdbopi; + coef.C1dbopi = bo_ij->C1dbopi * c; + coef.C2dbopi = bo_ij->C2dbopi * c; + coef.C3dbopi = bo_ij->C3dbopi * c; + coef.C4dbopi = bo_ij->C4dbopi * c; + + c = bo_ij->Cdbopi2 + bo_ji->Cdbopi2; + coef.C1dbopi2 = bo_ij->C1dbopi2 * c; + coef.C2dbopi2 = bo_ij->C2dbopi2 * c; + coef.C3dbopi2 = bo_ij->C3dbopi2 * c; + coef.C4dbopi2 = bo_ij->C4dbopi2 * c; + + c = workspace->CdDelta[i] + workspace->CdDelta[j]; + coef.C1dDelta = bo_ij->C1dbo * c; + coef.C2dDelta = bo_ij->C2dbo * c; + coef.C3dDelta = bo_ij->C3dbo * c; + + c = (coef.C1dbo + coef.C1dDelta + coef.C2dbopi + coef.C2dbopi2); + rvec_Scale( temp, c, bo_ij->dBOp); + + c = (coef.C2dbo + coef.C2dDelta + coef.C3dbopi + coef.C3dbopi2); + rvec_ScaledAdd(temp, c, workspace->dDeltap_self[i]); + + rvec_ScaledAdd(temp, coef.C1dbopi, bo_ij->dln_BOp_pi); + rvec_ScaledAdd(temp, coef.C1dbopi2, bo_ij->dln_BOp_pi2); + + rvec_Add(workspace->forceReduction[reductionOffset+i],temp); + + if (system->pair_ptr->vflag_either) { + rvec_Scale(fi_tmp, -0.5, temp); + rvec_ScaledSum(delij, 1., system->my_atoms[i].x,-1., system->my_atoms[j].x); + + pair_reax_ptr->v_tally2_newton_thr_proxy(i,fi_tmp,delij,thr); + } + + c = -(coef.C1dbo + coef.C1dDelta + coef.C2dbopi + coef.C2dbopi2); + rvec_Scale( temp, c, bo_ij->dBOp); + + c = (coef.C3dbo + coef.C3dDelta + coef.C4dbopi + coef.C4dbopi2); + rvec_ScaledAdd(temp, c, workspace->dDeltap_self[j]); + + rvec_ScaledAdd(temp, -coef.C1dbopi, bo_ij->dln_BOp_pi); + rvec_ScaledAdd(temp, -coef.C1dbopi2, bo_ij->dln_BOp_pi2); + + + rvec_Add(workspace->forceReduction[reductionOffset+j],temp); + + if (system->pair_ptr->vflag_either) { + rvec_Scale(fj_tmp, -0.5, temp); + rvec_ScaledSum(delji, 1., system->my_atoms[j].x,-1., system->my_atoms[i].x); + pair_reax_ptr->v_tally2_newton_thr_proxy(j,fj_tmp,delji,thr); + } + + // forces on k: i neighbor + for (pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk) { + nbr_k = &(bonds->select.bond_list[pk]); + k = nbr_k->nbr; + + const double c = -(coef.C2dbo + coef.C2dDelta + coef.C3dbopi + coef.C3dbopi2); + rvec_Scale(temp, c, nbr_k->bo_data.dBOp); + + rvec_Add(workspace->forceReduction[reductionOffset+k],temp); + + if (system->pair_ptr->vflag_either) { + rvec_Scale(fk_tmp, -0.5, temp); + rvec_ScaledSum(delki,1.,system->my_atoms[k].x,-1.,system->my_atoms[i].x); + pair_reax_ptr->v_tally2_newton_thr_proxy(k,fk_tmp,delki,thr); + rvec_ScaledSum(delkj,1.,system->my_atoms[k].x,-1.,system->my_atoms[j].x); + pair_reax_ptr->v_tally2_newton_thr_proxy(k,fk_tmp,delkj,thr); + } + } + + // forces on k: j neighbor + for (pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk) { + nbr_k = &(bonds->select.bond_list[pk]); + k = nbr_k->nbr; + + const double c = -(coef.C3dbo + coef.C3dDelta + coef.C4dbopi + coef.C4dbopi2); + rvec_Scale(temp, c, nbr_k->bo_data.dBOp); + + rvec_Add(workspace->forceReduction[reductionOffset+k],temp); + + if (system->pair_ptr->vflag_either) { + rvec_Scale(fk_tmp, -0.5, temp); + rvec_ScaledSum(delki,1.,system->my_atoms[k].x,-1.,system->my_atoms[i].x); + pair_reax_ptr->v_tally2_newton_thr_proxy(k,fk_tmp,delki,thr); + rvec_ScaledSum(delkj,1.,system->my_atoms[k].x,-1.,system->my_atoms[j].x); + pair_reax_ptr->v_tally2_newton_thr_proxy(k,fk_tmp,delkj,thr); + } + } + } + +/* ---------------------------------------------------------------------- */ + + int BOp_OMP(storage * /* workspace */, reax_list *bonds, double bo_cut, + int i, int btop_i, far_neighbor_data *nbr_pj, + single_body_parameters * /* sbp_i */, single_body_parameters * /* sbp_j */, + two_body_parameters *twbp, + int btop_j, double C12, double C34, double C56, double BO, double BO_s, double BO_pi, double BO_pi2) { + int j; + double rr2; + double Cln_BOp_s, Cln_BOp_pi, Cln_BOp_pi2; + bond_data *ibond, *jbond; + bond_order_data *bo_ij, *bo_ji; + + j = nbr_pj->nbr; + rr2 = 1.0 / SQR(nbr_pj->d); + + // Top portion of BOp() moved to reaxff_forces_omp.cpp::Init_Forces_noQEq_OMP() + + /* Initially BO values are the uncorrected ones, page 1 */ + + /****** bonds i-j and j-i ******/ + ibond = &(bonds->select.bond_list[btop_i]); + jbond = &(bonds->select.bond_list[btop_j]); + + ibond->nbr = j; + jbond->nbr = i; + ibond->d = nbr_pj->d; + jbond->d = nbr_pj->d; + rvec_Copy(ibond->dvec, nbr_pj->dvec); + rvec_Scale(jbond->dvec, -1, nbr_pj->dvec); + ivec_Copy(ibond->rel_box, nbr_pj->rel_box); + ivec_Scale(jbond->rel_box, -1, nbr_pj->rel_box); + ibond->dbond_index = btop_i; + jbond->dbond_index = btop_i; + ibond->sym_index = btop_j; + jbond->sym_index = btop_i; + + bo_ij = &(ibond->bo_data); + bo_ji = &(jbond->bo_data); + bo_ji->BO = bo_ij->BO = BO; + bo_ji->BO_s = bo_ij->BO_s = BO_s; + bo_ji->BO_pi = bo_ij->BO_pi = BO_pi; + bo_ji->BO_pi2 = bo_ij->BO_pi2 = BO_pi2; + + /* Bond Order page2-3, derivative of total bond order prime */ + Cln_BOp_s = twbp->p_bo2 * C12 * rr2; + Cln_BOp_pi = twbp->p_bo4 * C34 * rr2; + Cln_BOp_pi2 = twbp->p_bo6 * C56 * rr2; + + /* Only dln_BOp_xx wrt. dr_i is stored here, note that + dln_BOp_xx/dr_i = -dln_BOp_xx/dr_j and all others are 0 */ + rvec_Scale(bo_ij->dln_BOp_s,-bo_ij->BO_s*Cln_BOp_s,ibond->dvec); + rvec_Scale(bo_ij->dln_BOp_pi,-bo_ij->BO_pi*Cln_BOp_pi,ibond->dvec); + rvec_Scale(bo_ij->dln_BOp_pi2, + -bo_ij->BO_pi2*Cln_BOp_pi2,ibond->dvec); + rvec_Scale(bo_ji->dln_BOp_s, -1., bo_ij->dln_BOp_s); + rvec_Scale(bo_ji->dln_BOp_pi, -1., bo_ij->dln_BOp_pi); + rvec_Scale(bo_ji->dln_BOp_pi2, -1., bo_ij->dln_BOp_pi2); + + rvec_Scale(bo_ij->dBOp, + -(bo_ij->BO_s * Cln_BOp_s + + bo_ij->BO_pi * Cln_BOp_pi + + bo_ij->BO_pi2 * Cln_BOp_pi2), ibond->dvec); + rvec_Scale(bo_ji->dBOp, -1., bo_ij->dBOp); + + bo_ij->BO_s -= bo_cut; + bo_ij->BO -= bo_cut; + bo_ji->BO_s -= bo_cut; + bo_ji->BO -= bo_cut; + + bo_ij->Cdbo = bo_ij->Cdbopi = bo_ij->Cdbopi2 = 0.0; + bo_ji->Cdbo = bo_ji->Cdbopi = bo_ji->Cdbopi2 = 0.0; + + return 1; + } + +/* ---------------------------------------------------------------------- */ + + void BOOMP(reax_system *system, storage *workspace, reax_list **lists) + { + double p_lp1 = system->reax_param.gp.l[15]; + double p_boc1 = system->reax_param.gp.l[0]; + double p_boc2 = system->reax_param.gp.l[1]; + reax_list *bonds = (*lists) + BONDS; + +#if defined(_OPENMP) +#pragma omp parallel default(shared) +#endif + { + int i, j, pj, type_i, type_j; + int start_i, end_i, sym_index; + double val_i, Deltap_i, Deltap_boc_i; + double val_j, Deltap_j, Deltap_boc_j; + double f1, f2, f3, f4, f5, f4f5, exp_f4, exp_f5; + double exp_p1i, exp_p2i, exp_p1j, exp_p2j, explp1; + double temp, u1_ij, u1_ji, Cf1A_ij, Cf1B_ij, Cf1_ij, Cf1_ji; + double Cf45_ij, Cf45_ji; //u_ij, u_ji + double A0_ij, A1_ij, A2_ij, A2_ji, A3_ij, A3_ji; + single_body_parameters *sbp_i, *sbp_j; + two_body_parameters *twbp; + bond_order_data *bo_ij, *bo_ji; + + /* Calculate Deltaprime, Deltaprime_boc values */ +#if defined(_OPENMP) +#pragma omp for schedule(static) +#endif + for (i = 0; i < system->N; ++i) { + type_i = system->my_atoms[i].type; + if (type_i < 0) continue; + sbp_i = &(system->reax_param.sbp[type_i]); + workspace->Deltap[i] = workspace->total_bond_order[i] - sbp_i->valency; + workspace->Deltap_boc[i] = + workspace->total_bond_order[i] - sbp_i->valency_val; + + workspace->total_bond_order[i] = 0; + } + + // Wait till initialization complete +#if defined(_OPENMP) +#pragma omp barrier +#endif + + /* Corrected Bond Order calculations */ +#if defined(_OPENMP) +#pragma omp for schedule(guided) +#endif + for (i = 0; i < system->N; ++i) { + type_i = system->my_atoms[i].type; + if (type_i < 0) continue; + sbp_i = &(system->reax_param.sbp[type_i]); + val_i = sbp_i->valency; + Deltap_i = workspace->Deltap[i]; + Deltap_boc_i = workspace->Deltap_boc[i]; + start_i = Start_Index(i, bonds); + end_i = End_Index(i, bonds); + + for (pj = start_i; pj < end_i; ++pj) { + j = bonds->select.bond_list[pj].nbr; + type_j = system->my_atoms[j].type; + if (type_j < 0) continue; + bo_ij = &(bonds->select.bond_list[pj].bo_data); + + if (i < j || workspace->bond_mark[j] > 3) { + twbp = &(system->reax_param.tbp[type_i][type_j]); + + if (twbp->ovc < 0.001 && twbp->v13cor < 0.001) { + bo_ij->C1dbo = 1.000000; + bo_ij->C2dbo = 0.000000; + bo_ij->C3dbo = 0.000000; + + bo_ij->C1dbopi = 1.000000; + bo_ij->C2dbopi = 0.000000; + bo_ij->C3dbopi = 0.000000; + bo_ij->C4dbopi = 0.000000; + + bo_ij->C1dbopi2 = 1.000000; + bo_ij->C2dbopi2 = 0.000000; + bo_ij->C3dbopi2 = 0.000000; + bo_ij->C4dbopi2 = 0.000000; + + } else { + val_j = system->reax_param.sbp[type_j].valency; + Deltap_j = workspace->Deltap[j]; + Deltap_boc_j = workspace->Deltap_boc[j]; + + /* on page 1 */ + if (twbp->ovc >= 0.001) { + /* Correction for overcoordination */ + exp_p1i = exp(-p_boc1 * Deltap_i); + exp_p2i = exp(-p_boc2 * Deltap_i); + exp_p1j = exp(-p_boc1 * Deltap_j); + exp_p2j = exp(-p_boc2 * Deltap_j); + + f2 = exp_p1i + exp_p1j; + f3 = -1.0 / p_boc2 * log(0.5 * (exp_p2i + exp_p2j)); + f1 = 0.5 * ((val_i + f2)/(val_i + f2 + f3) + + (val_j + f2)/(val_j + f2 + f3)); + + /* Now come the derivates */ + /* Bond Order pages 5-7, derivative of f1 */ + temp = f2 + f3; + u1_ij = val_i + temp; + u1_ji = val_j + temp; + Cf1A_ij = 0.5 * f3 * (1.0 / SQR(u1_ij) + + 1.0 / SQR(u1_ji)); + Cf1B_ij = -0.5 * ((u1_ij - f3) / SQR(u1_ij) + + (u1_ji - f3) / SQR(u1_ji)); + + Cf1_ij = 0.50 * (-p_boc1 * exp_p1i / u1_ij - + ((val_i+f2) / SQR(u1_ij)) * + (-p_boc1 * exp_p1i + + exp_p2i / (exp_p2i + exp_p2j)) + + -p_boc1 * exp_p1i / u1_ji - + ((val_j+f2) / SQR(u1_ji)) * + (-p_boc1 * exp_p1i + + exp_p2i / (exp_p2i + exp_p2j))); + + + Cf1_ji = -Cf1A_ij * p_boc1 * exp_p1j + + Cf1B_ij * exp_p2j / (exp_p2i + exp_p2j); + } else { + /* No overcoordination correction! */ + f1 = 1.0; + Cf1_ij = Cf1_ji = 0.0; + } + + if (twbp->v13cor >= 0.001) { + /* Correction for 1-3 bond orders */ + exp_f4 =exp(-(twbp->p_boc4 * SQR(bo_ij->BO) - + Deltap_boc_i) * twbp->p_boc3 + twbp->p_boc5); + exp_f5 =exp(-(twbp->p_boc4 * SQR(bo_ij->BO) - + Deltap_boc_j) * twbp->p_boc3 + twbp->p_boc5); + + f4 = 1. / (1. + exp_f4); + f5 = 1. / (1. + exp_f5); + f4f5 = f4 * f5; + + /* Bond Order pages 8-9, derivative of f4 and f5 */ + Cf45_ij = -f4 * exp_f4; + Cf45_ji = -f5 * exp_f5; + } else { + f4 = f5 = f4f5 = 1.0; + Cf45_ij = Cf45_ji = 0.0; + } + + /* Bond Order page 10, derivative of total bond order */ + A0_ij = f1 * f4f5; + A1_ij = -2 * twbp->p_boc3 * twbp->p_boc4 * bo_ij->BO * + (Cf45_ij + Cf45_ji); + A2_ij = Cf1_ij / f1 + twbp->p_boc3 * Cf45_ij; + A2_ji = Cf1_ji / f1 + twbp->p_boc3 * Cf45_ji; + A3_ij = A2_ij + Cf1_ij / f1; + A3_ji = A2_ji + Cf1_ji / f1; + + /* find corrected bond orders and their derivative coef */ + bo_ij->BO = bo_ij->BO * A0_ij; + bo_ij->BO_pi = bo_ij->BO_pi * A0_ij *f1; + bo_ij->BO_pi2= bo_ij->BO_pi2* A0_ij *f1; + bo_ij->BO_s = bo_ij->BO - (bo_ij->BO_pi + bo_ij->BO_pi2); + + bo_ij->C1dbo = A0_ij + bo_ij->BO * A1_ij; + bo_ij->C2dbo = bo_ij->BO * A2_ij; + bo_ij->C3dbo = bo_ij->BO * A2_ji; + + bo_ij->C1dbopi = f1*f1*f4*f5; + bo_ij->C2dbopi = bo_ij->BO_pi * A1_ij; + bo_ij->C3dbopi = bo_ij->BO_pi * A3_ij; + bo_ij->C4dbopi = bo_ij->BO_pi * A3_ji; + + bo_ij->C1dbopi2 = f1*f1*f4*f5; + bo_ij->C2dbopi2 = bo_ij->BO_pi2 * A1_ij; + bo_ij->C3dbopi2 = bo_ij->BO_pi2 * A3_ij; + bo_ij->C4dbopi2 = bo_ij->BO_pi2 * A3_ji; + } + + /* neglect bonds that are < 1e-10 */ + if (bo_ij->BO < 1e-10) + bo_ij->BO = 0.0; + if (bo_ij->BO_s < 1e-10) + bo_ij->BO_s = 0.0; + if (bo_ij->BO_pi < 1e-10) + bo_ij->BO_pi = 0.0; + if (bo_ij->BO_pi2 < 1e-10) + bo_ij->BO_pi2 = 0.0; + + workspace->total_bond_order[i] += bo_ij->BO; //now keeps total_BO + } + } + } + + // Wait for bo_ij to be updated +#if defined(_OPENMP) +#pragma omp barrier +#endif + // Try to combine the following for-loop back into the for-loop above + /*-------------------------*/ +#if defined(_OPENMP) +#pragma omp for schedule(guided) +#endif + for (i = 0; i < system->N; ++i) { + type_i = system->my_atoms[i].type; + if (type_i < 0) continue; + start_i = Start_Index(i, bonds); + end_i = End_Index(i, bonds); + + for (pj = start_i; pj < end_i; ++pj) { + j = bonds->select.bond_list[pj].nbr; + type_j = system->my_atoms[j].type; + if (type_j < 0) continue; + + if (i < j || workspace->bond_mark[j] > 3) { + // Computed in previous for-loop + } else { + /* We only need to update bond orders from bo_ji + everything else is set in uncorrected_bo calculations */ + sym_index = bonds->select.bond_list[pj].sym_index; + + bo_ij = &(bonds->select.bond_list[pj].bo_data); + bo_ji = &(bonds->select.bond_list[sym_index].bo_data); + bo_ij->BO = bo_ji->BO; + bo_ij->BO_s = bo_ji->BO_s; + bo_ij->BO_pi = bo_ji->BO_pi; + bo_ij->BO_pi2 = bo_ji->BO_pi2; + + workspace->total_bond_order[i] += bo_ij->BO;// now keeps total_BO + } + } + + } + + /*-------------------------*/ + + // Need to wait for total_bond_order to be accumulated. +#if defined(_OPENMP) +#pragma omp barrier +#endif + /* Calculate some helper variables that are used at many places + throughout force calculations */ +#if defined(_OPENMP) +#pragma omp for schedule(guided) +#endif + for (j = 0; j < system->N; ++j) { + type_j = system->my_atoms[j].type; + if (type_j < 0) continue; + sbp_j = &(system->reax_param.sbp[type_j]); + + workspace->Delta[j] = workspace->total_bond_order[j] - sbp_j->valency; + workspace->Delta_e[j] = workspace->total_bond_order[j] - sbp_j->valency_e; + workspace->Delta_boc[j] = workspace->total_bond_order[j] - + sbp_j->valency_boc; + workspace->Delta_val[j] = workspace->total_bond_order[j] - + sbp_j->valency_val; + + workspace->vlpex[j] = workspace->Delta_e[j] - + 2.0 * (int)(workspace->Delta_e[j]/2.0); + explp1 = exp(-p_lp1 * SQR(2.0 + workspace->vlpex[j])); + workspace->nlp[j] = explp1 - (int)(workspace->Delta_e[j] / 2.0); + workspace->Delta_lp[j] = sbp_j->nlp_opt - workspace->nlp[j]; + workspace->Clp[j] = 2.0 * p_lp1 * explp1 * (2.0 + workspace->vlpex[j]); + workspace->dDelta_lp[j] = workspace->Clp[j]; + + if (sbp_j->mass > 21.0) { + workspace->nlp_temp[j] = 0.5 * (sbp_j->valency_e - sbp_j->valency); + workspace->Delta_lp_temp[j] = sbp_j->nlp_opt - workspace->nlp_temp[j]; + workspace->dDelta_lp_temp[j] = 0.; + } + else { + workspace->nlp_temp[j] = workspace->nlp[j]; + workspace->Delta_lp_temp[j] = sbp_j->nlp_opt - workspace->nlp_temp[j]; + workspace->dDelta_lp_temp[j] = workspace->Clp[j]; + } + } + + } // parallel region + } +} diff --git a/src/OPENMP/reaxff_bonds_omp.cpp b/src/OPENMP/reaxff_bonds_omp.cpp new file mode 100644 index 0000000000..1a97f2a6af --- /dev/null +++ b/src/OPENMP/reaxff_bonds_omp.cpp @@ -0,0 +1,167 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + Hasan Metin Aktulga, hmaktulga@lbl.gov + Joseph Fogarty, jcfogart@mail.usf.edu + Sagar Pandit, pandit@usf.edu + Ananth Y Grama, ayg@cs.purdue.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_omp.h" + +#include "fix_omp.h" +#include "pair_reaxff_omp.h" +#include "reaxff_api.h" + +#include + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +namespace ReaxFF { + void BondsOMP(reax_system *system, simulation_data *data, + storage *workspace, reax_list **lists) + { + const int natoms = system->n; + reax_list *bonds = (*lists) + BONDS; + const double gp3 = system->reax_param.gp.l[3]; + const double gp4 = system->reax_param.gp.l[4]; + const double gp7 = system->reax_param.gp.l[7]; + const double gp10 = system->reax_param.gp.l[10]; + const int gp37 = (int) system->reax_param.gp.l[37]; + double total_Ebond = 0.0; + +#if defined(_OPENMP) +#pragma omp parallel default(shared) reduction(+: total_Ebond) +#endif + { + int i, j, pj; + int start_i, end_i; + int type_i, type_j; + double ebond, pow_BOs_be2, exp_be12, CEbo; + double exphu, exphua1, exphub1, exphuov, hulpov, estriph; + double decobdbo, decobdboua, decobdboub; + single_body_parameters *sbp_i, *sbp_j; + two_body_parameters *twbp; + bond_order_data *bo_ij; + + int tid = get_tid(); + long reductionOffset = (system->N * tid); + + class PairReaxFFOMP *pair_reax_ptr; + pair_reax_ptr = static_cast(system->pair_ptr); + class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); + + pair_reax_ptr->ev_setup_thr_proxy(system->pair_ptr->eflag_either, + system->pair_ptr->vflag_either, system->N, + system->pair_ptr->eatom, + system->pair_ptr->vatom, nullptr, thr); + +#if defined(_OPENMP) +#pragma omp for schedule(guided) +#endif + for (i = 0; i < natoms; ++i) { + start_i = Start_Index(i, bonds); + end_i = End_Index(i, bonds); + + for (pj = start_i; pj < end_i; ++pj) { + j = bonds->select.bond_list[pj].nbr; + + if (system->my_atoms[i].orig_id > system->my_atoms[j].orig_id) continue; + + if (system->my_atoms[i].orig_id == system->my_atoms[j].orig_id) { + if (system->my_atoms[j].x[2] < system->my_atoms[i].x[2]) continue; + if (system->my_atoms[j].x[2] == system->my_atoms[i].x[2] && + system->my_atoms[j].x[1] < system->my_atoms[i].x[1]) continue; + if (system->my_atoms[j].x[2] == system->my_atoms[i].x[2] && + system->my_atoms[j].x[1] == system->my_atoms[i].x[1] && + system->my_atoms[j].x[0] < system->my_atoms[i].x[0]) continue; + } + + /* set the pointers */ + type_i = system->my_atoms[i].type; + type_j = system->my_atoms[j].type; + sbp_i = &(system->reax_param.sbp[type_i]); + sbp_j = &(system->reax_param.sbp[type_j]); + twbp = &(system->reax_param.tbp[type_i][type_j]); + bo_ij = &(bonds->select.bond_list[pj].bo_data); + + /* calculate the constants */ + if (bo_ij->BO_s == 0.0) pow_BOs_be2 = 0.0; + else pow_BOs_be2 = pow(bo_ij->BO_s, twbp->p_be2); + exp_be12 = exp(twbp->p_be1 * (1.0 - pow_BOs_be2)); + CEbo = -twbp->De_s * exp_be12 * + (1.0 - twbp->p_be1 * twbp->p_be2 * pow_BOs_be2); + + /* calculate the Bond Energy */ + total_Ebond += ebond = + -twbp->De_s * bo_ij->BO_s * exp_be12 + -twbp->De_p * bo_ij->BO_pi + -twbp->De_pp * bo_ij->BO_pi2; + + /* tally into per-atom energy */ + if (system->pair_ptr->eflag_either) + pair_reax_ptr->ev_tally_thr_proxy(i,j,natoms,1,ebond,0.0,0.0,0.0,0.0,0.0,thr); + + /* calculate derivatives of Bond Orders */ + bo_ij->Cdbo += CEbo; + bo_ij->Cdbopi -= (CEbo + twbp->De_p); + bo_ij->Cdbopi2 -= (CEbo + twbp->De_pp); + + /* Stabilisation terminal triple bond */ + if (bo_ij->BO >= 1.00) { + if (gp37 == 2 || + (sbp_i->mass == 12.0000 && sbp_j->mass == 15.9990) || + (sbp_j->mass == 12.0000 && sbp_i->mass == 15.9990)) { + exphu = exp(-gp7 * SQR(bo_ij->BO - 2.50)); + exphua1 = exp(-gp3 * (workspace->total_bond_order[i]-bo_ij->BO)); + exphub1 = exp(-gp3 * (workspace->total_bond_order[j]-bo_ij->BO)); + exphuov = exp(gp4 * (workspace->Delta[i] + workspace->Delta[j])); + hulpov = 1.0 / (1.0 + 25.0 * exphuov); + + estriph = gp10 * exphu * hulpov * (exphua1 + exphub1); + total_Ebond += estriph; + + decobdbo = gp10 * exphu * hulpov * (exphua1 + exphub1) * + (gp3 - 2.0 * gp7 * (bo_ij->BO-2.50)); + decobdboua = -gp10 * exphu * hulpov * + (gp3*exphua1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); + decobdboub = -gp10 * exphu * hulpov * + (gp3*exphub1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); + + /* tally into per-atom energy */ + if (system->pair_ptr->eflag_either) + pair_reax_ptr->ev_tally_thr_proxy(i,j,natoms,1,estriph,0.0,0.0,0.0,0.0,0.0,thr); + + bo_ij->Cdbo += decobdbo; + workspace->CdDelta[i] += decobdboua; + workspace->CdDeltaReduction[reductionOffset+j] += decobdboub; + } + } + } + } // for (i) + + } // omp + + data->my_en.e_bond += total_Ebond; + } +} diff --git a/src/OPENMP/reaxff_forces_omp.cpp b/src/OPENMP/reaxff_forces_omp.cpp new file mode 100644 index 0000000000..77106a5e44 --- /dev/null +++ b/src/OPENMP/reaxff_forces_omp.cpp @@ -0,0 +1,477 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + Website: https://www.cs.purdue.edu/puremd + + Copyright (2010) Purdue University + + Contributing authors: + H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama + Corresponding author: + Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_omp.h" + +#include "error.h" +#include "fix_omp.h" +#include "pair_reaxff_omp.h" + +#include "reaxff_api.h" + +#include + +using namespace LAMMPS_NS; + +namespace ReaxFF { +/* ---------------------------------------------------------------------- */ + + static void Compute_Bonded_ForcesOMP(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, + reax_list **lists) + { + + BOOMP(system, workspace, lists); + BondsOMP(system, data, workspace, lists); + Atom_EnergyOMP(system, data, workspace, lists); + Valence_AnglesOMP(system, control, data, workspace, lists); + Torsion_AnglesOMP(system, control, data, workspace, lists); + if (control->hbond_cut > 0) + Hydrogen_BondsOMP(system, control, data, workspace, lists); + } + + static void Compute_NonBonded_ForcesOMP(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, + reax_list **lists) + { + /* van der Waals and Coulomb interactions */ + + if (control->tabulate == 0) + vdW_Coulomb_Energy_OMP(system, control, data, workspace, lists); + else + Tabulated_vdW_Coulomb_Energy_OMP(system, control, data, workspace, lists); + } + +/* ---------------------------------------------------------------------- */ + +/* this version of Compute_Total_Force computes forces from + coefficients accumulated by all interaction functions. + Saves enormous time & space! */ + static void Compute_Total_ForceOMP(reax_system *system, control_params *control, + storage *workspace, reax_list **lists) + { + int natoms = system->N; + int nthreads = control->nthreads; + long totalReductionSize = (bigint)system->N * nthreads; + reax_list *bonds = (*lists) + BONDS; + +#if defined(_OPENMP) +#pragma omp parallel default(shared) //LMP_DEFAULT_NONE +#endif + { + int i, j, k, pj, pk, start_j, end_j; + + int tid = get_tid(); + bond_order_data *bo_jk; + + class PairReaxFFOMP *pair_reax_ptr; + pair_reax_ptr = static_cast(system->pair_ptr); + class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); + + pair_reax_ptr->ev_setup_thr_proxy(0, 1, natoms, system->pair_ptr->eatom, + system->pair_ptr->vatom, nullptr, thr); + +#if defined(_OPENMP) +#pragma omp for schedule(guided) +#endif + for (i = 0; i < system->N; ++i) { + for (j = 0; j < nthreads; ++j) + workspace->CdDelta[i] += workspace->CdDeltaReduction[system->N*j+i]; + } + +#if defined(_OPENMP) +#pragma omp for schedule(dynamic,50) +#endif + for (j = 0; j < system->N; ++j) { + start_j = Start_Index(j, bonds); + end_j = End_Index(j, bonds); + + for (pk = start_j; pk < end_j; ++pk) { + bo_jk = &(bonds->select.bond_list[pk].bo_data); + for (k = 0; k < nthreads; ++k) + bo_jk->Cdbo += bo_jk->CdboReduction[k]; + } + } + +#if defined(_OPENMP) +#pragma omp for schedule(dynamic,50) +#endif + for (i = 0; i < system->N; ++i) { + const int startj = Start_Index(i, bonds); + const int endj = End_Index(i, bonds); + for (pj = startj; pj < endj; ++pj) + if (i < bonds->select.bond_list[pj].nbr) + Add_dBond_to_ForcesOMP(system, i, pj, workspace, lists); + } + + pair_reax_ptr->reduce_thr_proxy(system->pair_ptr, 0, 1, thr); + +#if defined(_OPENMP) +#pragma omp for schedule(guided) +#endif + for (i = 0; i < system->N; ++i) { + for (j = 0; j < nthreads; ++j) + rvec_Add(workspace->f[i], workspace->forceReduction[system->N*j+i]); + } + + +#if defined(_OPENMP) +#pragma omp for schedule(guided) +#endif + for (i = 0; i < totalReductionSize; i++) { + workspace->forceReduction[i][0] = 0; + workspace->forceReduction[i][1] = 0; + workspace->forceReduction[i][2] = 0; + workspace->CdDeltaReduction[i] = 0; + } + } // parallel region + } + +/* ---------------------------------------------------------------------- */ + + static void Validate_ListsOMP(reax_system *system, reax_list **lists, + int step, int n, int N, int numH) + { + int comp, Hindex; + reax_list *bonds, *hbonds; + double saferzone = system->saferzone; + +#if defined(_OPENMP) +#pragma omp parallel default(shared) private(comp,Hindex) +#endif + { + + /* bond list */ + if (N > 0) { + bonds = *lists + BONDS; + +#if defined(_OPENMP) +#pragma omp for schedule(guided) +#endif + for (int i = 0; i < N; ++i) { + system->my_atoms[i].num_bonds = MAX(Num_Entries(i,bonds)*2, MIN_BONDS); + + if (i < N-1) + comp = Start_Index(i+1, bonds); + else comp = bonds->num_intrs; + + if (End_Index(i, bonds) > comp) + system->error_ptr->one(FLERR, fmt::format("step {}: bondchk failed: " + "i={} end(i)={} str(i+1)={}\n", + step,i,End_Index(i,bonds),comp)); + } + } + + + /* hbonds list */ + if (numH > 0) { + hbonds = *lists + HBONDS; + +#if defined(_OPENMP) +#pragma omp for schedule(guided) +#endif + for (int i = 0; i < n; ++i) { + Hindex = system->my_atoms[i].Hindex; + if (Hindex > -1) { + system->my_atoms[i].num_hbonds = + (int)(MAX(Num_Entries(Hindex,hbonds)*saferzone,system->minhbonds)); + + if (Hindex < numH-1) + comp = Start_Index(Hindex+1, hbonds); + else comp = hbonds->num_intrs; + + if (End_Index(Hindex, hbonds) > comp) + system->error_ptr->one(FLERR, fmt::format("step {}: hbondchk failed: " + "H={} end(H)={} str(H+1)={}\n", + step, Hindex,End_Index(Hindex,hbonds),comp)); + } + } + } + + } // omp parallel + } + + + void Init_Forces_noQEq_OMP(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, + reax_list **lists) { + int j, pj; + int start_i, end_i; + int type_i, type_j; + int ihb, jhb, ihb_top, jhb_top; + double cutoff; + single_body_parameters *sbp_i, *sbp_j; + two_body_parameters *twbp; + far_neighbor_data *nbr_pj; + reax_atom *atom_i, *atom_j; + reax_list *far_nbrs = *lists + FAR_NBRS; + reax_list *bonds = *lists + BONDS; + reax_list *hbonds = *lists + HBONDS; + int num_bonds = 0; + int num_hbonds = 0; + int btop_i = 0; + + // We will use CdDeltaReduction as a temporary (double) buffer to accumulate total_bond_order + // This is safe because CdDeltaReduction is currently zeroed and its accumulation doesn't start until BondsOMP() + double * tmp_bond_order = workspace->CdDeltaReduction; + + // We do the same with forceReduction as a temporary (rvec) buffer to accumulate dDeltap_self + // This is safe because forceReduction is currently zeroed and its accumulation does start until Hydrogen_BondsOMP() + rvec * tmp_ddelta = workspace->forceReduction; + + /* uncorrected bond orders */ + cutoff = control->bond_cut; + +#if defined(_OPENMP) +#pragma omp parallel default(shared) \ + private(atom_i, type_i, start_i, end_i, sbp_i, btop_i, ihb, ihb_top, \ + atom_j, type_j, pj, sbp_j, nbr_pj, jhb, twbp) +#endif + { + + int nthreads = control->nthreads; + int tid = get_tid(); + long reductionOffset = (bigint)system->N * tid; + long totalReductionSize = (bigint)system->N * nthreads; + +#if defined(_OPENMP) +#pragma omp for schedule(dynamic,50) reduction(+:num_bonds) +#endif + for (int i = 0; i < system->N; ++i) { + atom_i = &(system->my_atoms[i]); + type_i = atom_i->type; + sbp_i = &(system->reax_param.sbp[type_i]); + + start_i = Start_Index(i, far_nbrs); + end_i = End_Index(i, far_nbrs); + + for (pj = start_i; pj < end_i; ++pj) { + nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); + if (nbr_pj->d <= cutoff) { + int j = nbr_pj->nbr; + atom_j = &(system->my_atoms[j]); + type_j = atom_j->type; + sbp_j = &(system->reax_param.sbp[type_j]); + twbp = &(system->reax_param.tbp[type_i][type_j]); + + // Trying to minimize time spent in critical section by moving initial part of BOp() + // outside of critical section. + + // Start top portion of BOp() + double C12, C34, C56; + double BO, BO_s, BO_pi, BO_pi2; + double bo_cut = control->bo_cut; + + if (sbp_i->r_s > 0.0 && sbp_j->r_s > 0.0) { + C12 = twbp->p_bo1 * pow(nbr_pj->d / twbp->r_s, twbp->p_bo2); + BO_s = (1.0 + bo_cut) * exp(C12); + } + else BO_s = C12 = 0.0; + + if (sbp_i->r_pi > 0.0 && sbp_j->r_pi > 0.0) { + C34 = twbp->p_bo3 * pow(nbr_pj->d / twbp->r_p, twbp->p_bo4); + BO_pi = exp(C34); + } + else BO_pi = C34 = 0.0; + + if (sbp_i->r_pi_pi > 0.0 && sbp_j->r_pi_pi > 0.0) { + C56 = twbp->p_bo5 * pow(nbr_pj->d / twbp->r_pp, twbp->p_bo6); + BO_pi2= exp(C56); + } + else BO_pi2 = C56 = 0.0; + + /* Initially BO values are the uncorrected ones, page 1 */ + BO = BO_s + BO_pi + BO_pi2; + // End top portion of BOp() + + if (BO >= bo_cut) { + int btop_j; + + // Update indices in critical section +#if defined(_OPENMP) +#pragma omp critical +#endif + { + btop_i = End_Index(i, bonds); + btop_j = End_Index(j, bonds); + Set_End_Index(j, btop_j+1, bonds); + Set_End_Index(i, btop_i+1, bonds); + } // omp critical + + // Finish remaining BOp() work + BOp_OMP(workspace, bonds, bo_cut, + i , btop_i, nbr_pj, sbp_i, sbp_j, twbp, btop_j, + C12, C34, C56, BO, BO_s, BO_pi, BO_pi2); + + bond_data * ibond = &(bonds->select.bond_list[btop_i]); + bond_order_data * bo_ij = &(ibond->bo_data); + + bond_data * jbond = &(bonds->select.bond_list[btop_j]); + bond_order_data * bo_ji = &(jbond->bo_data); + + workspace->total_bond_order[i] += bo_ij->BO; + tmp_bond_order[reductionOffset + j] += bo_ji->BO; + + rvec_Add(workspace->dDeltap_self[i], bo_ij->dBOp); + rvec_Add(tmp_ddelta[reductionOffset + j], bo_ji->dBOp); + + btop_i++; + num_bonds++; + } // if (BO>=bo_cut) + + } // if (cutoff) + + } // for (pj) + } // for (i) + + // Need to wait for all indices and tmp arrays accumulated. +#if defined(_OPENMP) +#pragma omp barrier +#endif + +#if defined(_OPENMP) +#pragma omp for schedule(dynamic,50) +#endif + for (int i=0; iN; i++) + for (int t=0; tN + i; + workspace->dDeltap_self[i][0] += tmp_ddelta[indx][0]; + workspace->dDeltap_self[i][1] += tmp_ddelta[indx][1]; + workspace->dDeltap_self[i][2] += tmp_ddelta[indx][2]; + workspace->total_bond_order[i] += tmp_bond_order[indx]; + } + + /* hydrogen bond list */ + if (control->hbond_cut > 0) { + cutoff = control->hbond_cut; + +#if defined(_OPENMP) +#pragma omp for schedule(dynamic,50) reduction(+ : num_hbonds) +#endif + for (int i = 0; i < system->n; ++i) { + atom_i = &(system->my_atoms[i]); + type_i = atom_i->type; + sbp_i = &(system->reax_param.sbp[type_i]); + ihb = sbp_i->p_hbond; + +#if defined(_OPENMP) +#pragma omp critical +#endif + { + + if (ihb == 1 || ihb == 2) { + start_i = Start_Index(i, far_nbrs); + end_i = End_Index(i, far_nbrs); + + for (pj = start_i; pj < end_i; ++pj) { + nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); + j = nbr_pj->nbr; + atom_j = &(system->my_atoms[j]); + type_j = atom_j->type; + if (type_j < 0) continue; + sbp_j = &(system->reax_param.sbp[type_j]); + jhb = sbp_j->p_hbond; + + if (nbr_pj->d <= control->hbond_cut) { + int iflag = 0; + int jflag = 0; + + if (ihb==1 && jhb==2) iflag = 1; + else if (jn && ihb == 2 && jhb == 1) jflag = 1; + + if (iflag || jflag) { + if (iflag) { + ihb_top = End_Index(atom_i->Hindex, hbonds); + Set_End_Index(atom_i->Hindex, ihb_top+1, hbonds); + } else if (jflag) { + jhb_top = End_Index(atom_j->Hindex, hbonds); + Set_End_Index(atom_j->Hindex, jhb_top+1, hbonds); + } + + if (iflag) { + hbonds->select.hbond_list[ihb_top].nbr = j; + hbonds->select.hbond_list[ihb_top].scl = 1; + hbonds->select.hbond_list[ihb_top].ptr = nbr_pj; + } else if (jflag) { + hbonds->select.hbond_list[jhb_top].nbr = i; + hbonds->select.hbond_list[jhb_top].scl = -1; + hbonds->select.hbond_list[jhb_top].ptr = nbr_pj; + } + + num_hbonds++; + } // if (iflag || jflag) + + } + } + } + + } // omp critical + } + + } // if (control->hbond > 0) + + // Zero buffers for others to use as intended. +#if defined(_OPENMP) +#pragma omp for schedule(guided) +#endif + for (int i=0; irealloc.num_bonds = num_bonds; + workspace->realloc.num_hbonds = num_hbonds; + + Validate_ListsOMP(system, lists, data->step, + system->n, system->N, system->numH); + } + +/* ---------------------------------------------------------------------- */ + + void Compute_ForcesOMP(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, + reax_list **lists) + { + // Init Forces + Init_Forces_noQEq_OMP(system, control, data, workspace, lists); + + // Bonded Interactions + Compute_Bonded_ForcesOMP(system, control, data, workspace, lists); + + // Nonbonded Interactions + Compute_NonBonded_ForcesOMP(system, control, data, workspace, lists); + + // Total Force + Compute_Total_ForceOMP(system, control, workspace, lists); + } +} diff --git a/src/OPENMP/reaxff_hydrogen_bonds_omp.cpp b/src/OPENMP/reaxff_hydrogen_bonds_omp.cpp new file mode 100644 index 0000000000..64bbbf56b1 --- /dev/null +++ b/src/OPENMP/reaxff_hydrogen_bonds_omp.cpp @@ -0,0 +1,204 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + Website: https://www.cs.purdue.edu/puremd + + Copyright (2010) Purdue University + + Contributing authors: + H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama + Corresponding author: + Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_omp.h" + +#include "fix_omp.h" +#include "pair_reaxff_omp.h" + +#include "reaxff_api.h" + +#include + +using namespace LAMMPS_NS; + +namespace ReaxFF { + + /* ---------------------------------------------------------------------- */ + + void Hydrogen_BondsOMP(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, reax_list **lists) + { + + const int nthreads = control->nthreads; + +#if defined(_OPENMP) +#pragma omp parallel default(shared) //LMP_DEFAULT_NONE +#endif + { + int i, j, k, pi, pk; + int type_i, type_j, type_k; + int start_j, end_j, hb_start_j, hb_end_j; + int hblist[MAX_BONDS]; + int itr, top; + int num_hb_intrs = 0; + double r_jk, theta, cos_theta, sin_xhz4, cos_xhz1, sin_theta2; + double e_hb, e_hb_thr = 0.0, exp_hb2, exp_hb3, CEhb1, CEhb2, CEhb3; + rvec dcos_theta_di, dcos_theta_dj, dcos_theta_dk; + rvec dvec_jk; + hbond_parameters *hbp; + bond_order_data *bo_ij; + bond_data *pbond_ij; + far_neighbor_data *nbr_jk; + reax_list *bonds, *hbonds; + bond_data *bond_list; + hbond_data *hbond_list; + + // tally variables + double fi_tmp[3], fk_tmp[3], delij[3], delkj[3]; + + bonds = (*lists) + BONDS; + bond_list = bonds->select.bond_list; + hbonds = (*lists) + HBONDS; + hbond_list = hbonds->select.hbond_list; + + int natoms = system->n; + int tid = get_tid(); + + const int idelta = 1 + natoms/nthreads; + int ifrom = tid*idelta; + int ito = ((ifrom + idelta) > natoms) ? natoms : ifrom + idelta; + + long reductionOffset = (system->N * tid); + + class PairReaxFFOMP *pair_reax_ptr; + pair_reax_ptr = static_cast(system->pair_ptr); + + class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); + + /* loops below discover the Hydrogen bonds between i-j-k triplets. + here j is H atom and there has to be some bond between i and j. + Hydrogen bond is between j and k. + so in this function i->X, j->H, k->Z when we map + variables onto the ones in the handout.*/ + // for (j = 0; j < system->n; ++j) + for (j = ifrom; j < ito; ++j) { + /* j has to be of type H */ + if (system->reax_param.sbp[system->my_atoms[j].type].p_hbond == 1) { + /*set j's variables */ + type_j = system->my_atoms[j].type; + start_j = Start_Index(j, bonds); + end_j = End_Index(j, bonds); + hb_start_j = Start_Index(system->my_atoms[j].Hindex, hbonds); + hb_end_j = End_Index(system->my_atoms[j].Hindex, hbonds); + if (type_j < 0) continue; + + top = 0; + for (pi = start_j; pi < end_j; ++pi) { + pbond_ij = &(bond_list[pi]); + i = pbond_ij->nbr; + type_i = system->my_atoms[i].type; + if (type_i < 0) continue; + bo_ij = &(pbond_ij->bo_data); + + if (system->reax_param.sbp[type_i].p_hbond == 2 && + bo_ij->BO >= HB_THRESHOLD) + hblist[top++] = pi; + } + + for (pk = hb_start_j; pk < hb_end_j; ++pk) { + /* set k's varibles */ + k = hbond_list[pk].nbr; + type_k = system->my_atoms[k].type; + if (type_k < 0) continue; + nbr_jk = hbond_list[pk].ptr; + r_jk = nbr_jk->d; + rvec_Scale(dvec_jk, hbond_list[pk].scl, nbr_jk->dvec); + + for (itr = 0; itr < top; ++itr) { + pi = hblist[itr]; + pbond_ij = &(bonds->select.bond_list[pi]); + i = pbond_ij->nbr; + + if (system->my_atoms[i].orig_id != system->my_atoms[k].orig_id) { + bo_ij = &(pbond_ij->bo_data); + type_i = system->my_atoms[i].type; + if (type_i < 0) continue; + hbp = &(system->reax_param.hbp[type_i][type_j][type_k]); + ++num_hb_intrs; + + Calculate_Theta(pbond_ij->dvec, pbond_ij->d, dvec_jk, r_jk, + &theta, &cos_theta); + /* the derivative of cos(theta) */ + Calculate_dCos_ThetaOMP(pbond_ij->dvec, pbond_ij->d, dvec_jk, r_jk, + &dcos_theta_di, &dcos_theta_dj, + &dcos_theta_dk); + + /* hydrogen bond energy*/ + sin_theta2 = sin(theta/2.0); + sin_xhz4 = SQR(sin_theta2); + sin_xhz4 *= sin_xhz4; + cos_xhz1 = (1.0 - cos_theta); + exp_hb2 = exp(-hbp->p_hb2 * bo_ij->BO); + exp_hb3 = exp(-hbp->p_hb3 * (hbp->r0_hb / r_jk + + r_jk / hbp->r0_hb - 2.0)); + + e_hb_thr += e_hb = hbp->p_hb1 * (1.0 - exp_hb2) * exp_hb3 * sin_xhz4; + + CEhb1 = hbp->p_hb1 * hbp->p_hb2 * exp_hb2 * exp_hb3 * sin_xhz4; + CEhb2 = -hbp->p_hb1/2.0 * (1.0 - exp_hb2) * exp_hb3 * cos_xhz1; + CEhb3 = -hbp->p_hb3 * + (-hbp->r0_hb / SQR(r_jk) + 1.0 / hbp->r0_hb) * e_hb; + + /* hydrogen bond forces */ + bo_ij->Cdbo += CEhb1; // dbo term + + // dcos terms + rvec_ScaledAdd(workspace->forceReduction[reductionOffset+i], +CEhb2, dcos_theta_di); + rvec_ScaledAdd(workspace->forceReduction[reductionOffset+j], +CEhb2, dcos_theta_dj); + rvec_ScaledAdd(workspace->forceReduction[reductionOffset+k], +CEhb2, dcos_theta_dk); + // dr terms + rvec_ScaledAdd(workspace->forceReduction[reductionOffset+j], -CEhb3/r_jk, dvec_jk); + rvec_ScaledAdd(workspace->forceReduction[reductionOffset+k], +CEhb3/r_jk, dvec_jk); + + /* tally into per-atom virials */ + if (system->pair_ptr->vflag_either || system->pair_ptr->eflag_either) { + rvec_ScaledSum(delij, 1., system->my_atoms[j].x, -1., system->my_atoms[i].x); + rvec_ScaledSum(delkj, 1., system->my_atoms[j].x, -1., system->my_atoms[k].x); + + rvec_Scale(fi_tmp, CEhb2, dcos_theta_di); + rvec_Scale(fk_tmp, CEhb2, dcos_theta_dk); + rvec_ScaledAdd(fk_tmp, CEhb3/r_jk, dvec_jk); + + pair_reax_ptr->ev_tally3_thr_proxy(i,j,k,e_hb,0.0,fi_tmp,fk_tmp,delij,delkj,thr); + } + } + } + } + } + } +#if defined(_OPENMP) +#pragma omp critical +#endif + { + data->my_en.e_hb += e_hb_thr; + } + } + } +} diff --git a/src/OPENMP/reaxff_init_md_omp.cpp b/src/OPENMP/reaxff_init_md_omp.cpp new file mode 100644 index 0000000000..a0100e648a --- /dev/null +++ b/src/OPENMP/reaxff_init_md_omp.cpp @@ -0,0 +1,104 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + + Contributing authors: + H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama + Corresponding author: + Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_omp.h" +#include "reaxff_api.h" + +#include "error.h" + +#include +#include + +namespace ReaxFF { + static void Init_ListsOMP(reax_system *system, control_params *control, + reax_list **lists) + { + int i, total_hbonds, total_bonds, bond_cap, num_3body, cap_3body, Htop; + int *hb_top, *bond_top; + + int mincap = system->mincap; + double safezone = system->safezone; + double saferzone = system->saferzone; + auto error = system->error_ptr; + + bond_top = (int*) calloc(system->total_cap, sizeof(int)); + hb_top = (int*) calloc(system->local_cap, sizeof(int)); + Estimate_Storages(system, control, lists, + &Htop, hb_top, bond_top, &num_3body); + + if (control->hbond_cut > 0) { + /* init H indexes */ + total_hbonds = 0; + for (i = 0; i < system->n; ++i) { + system->my_atoms[i].num_hbonds = hb_top[i]; + total_hbonds += hb_top[i]; + } + total_hbonds = (int)(MAX(total_hbonds*saferzone,mincap*system->minhbonds)); + + Make_List(system->Hcap, total_hbonds, TYP_HBOND,*lists+HBONDS); + (*lists+HBONDS)->error_ptr = system->error_ptr; + } + + total_bonds = 0; + for (i = 0; i < system->N; ++i) { + system->my_atoms[i].num_bonds = bond_top[i]; + total_bonds += bond_top[i]; + } + bond_cap = (int)(MAX(total_bonds*safezone, mincap*MIN_BONDS)); + + Make_List(system->total_cap, bond_cap, TYP_BOND,*lists+BONDS); + (*lists+BONDS)->error_ptr = system->error_ptr; + + int nthreads = control->nthreads; + reax_list *bonds = (*lists)+BONDS; + + for (i = 0; i < bonds->num_intrs; ++i) + bonds->select.bond_list[i].bo_data.CdboReduction = + (double*) smalloc(error, sizeof(double)*nthreads, "CdboReduction"); + + /* 3bodies list */ + cap_3body = (int)(MAX(num_3body*safezone, MIN_3BODIES)); + Make_List(bond_cap, cap_3body, TYP_THREE_BODY,*lists+THREE_BODIES); + (*lists+THREE_BODIES)->error_ptr = system->error_ptr; + + free(hb_top); + free(bond_top); + } + + void InitializeOMP(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, + reax_list **lists, MPI_Comm world) + { + Init_System(system,control); + Init_Simulation_Data(data); + Init_Workspace(system,control,workspace); + Init_ListsOMP(system,control,lists); + if (control->tabulate) + Init_Lookup_Tables(system,control,workspace,world); + } +} diff --git a/src/OPENMP/reaxff_multi_body_omp.cpp b/src/OPENMP/reaxff_multi_body_omp.cpp new file mode 100644 index 0000000000..17b93d7487 --- /dev/null +++ b/src/OPENMP/reaxff_multi_body_omp.cpp @@ -0,0 +1,274 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + Website: https://www.cs.purdue.edu/puremd + + Copyright (2010) Purdue University + + Contributing authors: + H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama + Corresponding author: + Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_omp.h" + +#include "fix_omp.h" +#include "pair_reaxff_omp.h" + +#include "reaxff_api.h" + +#include +#include + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +namespace ReaxFF { + void Atom_EnergyOMP(reax_system *system, simulation_data *data, + storage *workspace, reax_list **lists) + { + /* Initialize parameters */ + const double p_lp3 = system->reax_param.gp.l[5]; + const double p_ovun3 = system->reax_param.gp.l[32]; + const double p_ovun4 = system->reax_param.gp.l[31]; + const double p_ovun6 = system->reax_param.gp.l[6]; + const double p_ovun7 = system->reax_param.gp.l[8]; + const double p_ovun8 = system->reax_param.gp.l[9]; + + reax_list *bonds = (*lists) + BONDS; + + double total_Elp = 0.0; + double total_Eun = 0.0; + double total_Eov = 0.0; + +#if defined(_OPENMP) +#pragma omp parallel default(shared) reduction(+:total_Elp, total_Eun, total_Eov) +#endif + { + int i, j, pj, type_i, type_j; + double Delta_lpcorr, dfvl; + double e_lp, expvd2, inv_expvd2, dElp, CElp, DlpVi; + double e_lph, Di, vov3, deahu2dbo, deahu2dsbo; + double e_ov, CEover1, CEover2, CEover3, CEover4; + double exp_ovun1, exp_ovun2, sum_ovun1, sum_ovun2; + double exp_ovun2n, exp_ovun6, exp_ovun8; + double inv_exp_ovun1, inv_exp_ovun2, inv_exp_ovun2n, inv_exp_ovun8; + double e_un, CEunder1, CEunder2, CEunder3, CEunder4; + double eng_tmp; + double p_lp2, p_ovun2, p_ovun5; + int numbonds; + + single_body_parameters *sbp_i; + two_body_parameters *twbp; + bond_data *pbond; + bond_order_data *bo_ij; + + int tid = get_tid(); + + long reductionOffset = (system->N * tid); + class PairReaxFFOMP *pair_reax_ptr; + pair_reax_ptr = static_cast(system->pair_ptr); + class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); + +#if defined(_OPENMP) +#pragma omp for schedule(guided) +#endif + for (i = 0; i < system->n; ++i) { + type_i = system->my_atoms[i].type; + if (type_i < 0) continue; + sbp_i = &(system->reax_param.sbp[type_i]); + + /* lone-pair Energy */ + p_lp2 = sbp_i->p_lp2; + expvd2 = exp(-75 * workspace->Delta_lp[i]); + inv_expvd2 = 1. / (1. + expvd2); + + numbonds = 0; + e_lp = 0.0; + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) + numbonds ++; + + /* calculate the energy */ + if (numbonds > 0) + total_Elp += e_lp = + p_lp2 * workspace->Delta_lp[i] * inv_expvd2; + + dElp = p_lp2 * inv_expvd2 + + 75 * p_lp2 * workspace->Delta_lp[i] * expvd2 * SQR(inv_expvd2); + CElp = dElp * workspace->dDelta_lp[i]; + + if (numbonds > 0) workspace->CdDelta[i] += CElp; // lp - 1st term + + /* tally into per-atom energy */ + if (system->pair_ptr->eflag_either) + pair_reax_ptr->ev_tally_thr_proxy( i, i, system->n, 1, + e_lp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); + + /* correction for C2 */ + if (p_lp3 > 0.001 && !strcmp(system->reax_param.sbp[type_i].name, "C")) + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { + j = bonds->select.bond_list[pj].nbr; + type_j = system->my_atoms[j].type; + if (type_j < 0) continue; + + if (!strcmp(system->reax_param.sbp[type_j].name, "C")) { + twbp = &(system->reax_param.tbp[type_i][type_j]); + bo_ij = &(bonds->select.bond_list[pj].bo_data); + Di = workspace->Delta[i]; + vov3 = bo_ij->BO - Di - 0.040*pow(Di, 4.); + + if (vov3 > 3.) { + total_Elp += e_lph = p_lp3 * SQR(vov3-3.0); + + deahu2dbo = 2.*p_lp3*(vov3 - 3.); + deahu2dsbo = 2.*p_lp3*(vov3 - 3.)*(-1. - 0.16*pow(Di, 3.)); + + bo_ij->Cdbo += deahu2dbo; + workspace->CdDelta[i] += deahu2dsbo; + + /* tally into per-atom energy */ + if (system->pair_ptr->eflag_either) + pair_reax_ptr->ev_tally_thr_proxy( i, j, system->n, 1, + e_lph, 0.0, 0.0, 0.0, 0.0, 0.0, thr); + } + } + } + } +#if defined(_OPENMP) +#pragma omp barrier +#pragma omp for schedule(guided) +#endif + for (i = 0; i < system->n; ++i) { + type_i = system->my_atoms[i].type; + if (type_i < 0) continue; + sbp_i = &(system->reax_param.sbp[type_i]); + + /* over-coordination energy */ + if (sbp_i->mass > 21.0) + dfvl = 0.0; + else dfvl = 1.0; // only for 1st-row elements + + p_ovun2 = sbp_i->p_ovun2; + sum_ovun1 = sum_ovun2 = 0; + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { + j = bonds->select.bond_list[pj].nbr; + type_j = system->my_atoms[j].type; + if (type_j < 0) continue; + bo_ij = &(bonds->select.bond_list[pj].bo_data); + twbp = &(system->reax_param.tbp[type_i][type_j]); + + sum_ovun1 += twbp->p_ovun1 * twbp->De_s * bo_ij->BO; + sum_ovun2 += (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j])* + (bo_ij->BO_pi + bo_ij->BO_pi2); + } + + exp_ovun1 = p_ovun3 * exp(p_ovun4 * sum_ovun2); + inv_exp_ovun1 = 1.0 / (1 + exp_ovun1); + Delta_lpcorr = workspace->Delta[i] - + (dfvl * workspace->Delta_lp_temp[i]) * inv_exp_ovun1; + + exp_ovun2 = exp(p_ovun2 * Delta_lpcorr); + inv_exp_ovun2 = 1.0 / (1.0 + exp_ovun2); + + DlpVi = 1.0 / (Delta_lpcorr + sbp_i->valency + 1e-8); + CEover1 = Delta_lpcorr * DlpVi * inv_exp_ovun2; + + total_Eov += e_ov = sum_ovun1 * CEover1; + + CEover2 = sum_ovun1 * DlpVi * inv_exp_ovun2 * + (1.0 - Delta_lpcorr * (DlpVi + p_ovun2 * exp_ovun2 * inv_exp_ovun2)); + + CEover3 = CEover2 * (1.0 - dfvl * workspace->dDelta_lp[i] * inv_exp_ovun1); + + CEover4 = CEover2 * (dfvl * workspace->Delta_lp_temp[i]) * + p_ovun4 * exp_ovun1 * SQR(inv_exp_ovun1); + + + /* under-coordination potential */ + p_ovun2 = sbp_i->p_ovun2; + p_ovun5 = sbp_i->p_ovun5; + + exp_ovun2n = 1.0 / exp_ovun2; + exp_ovun6 = exp(p_ovun6 * Delta_lpcorr); + exp_ovun8 = p_ovun7 * exp(p_ovun8 * sum_ovun2); + inv_exp_ovun2n = 1.0 / (1.0 + exp_ovun2n); + inv_exp_ovun8 = 1.0 / (1.0 + exp_ovun8); + + numbonds = 0; + e_un = 0.0; + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) + numbonds ++; + + if (numbonds > 0) total_Eun += e_un = + -p_ovun5 * (1.0 - exp_ovun6) * inv_exp_ovun2n * inv_exp_ovun8; + + CEunder1 = inv_exp_ovun2n * + (p_ovun5 * p_ovun6 * exp_ovun6 * inv_exp_ovun8 + + p_ovun2 * e_un * exp_ovun2n); + CEunder2 = -e_un * p_ovun8 * exp_ovun8 * inv_exp_ovun8; + CEunder3 = CEunder1 * (1.0 - dfvl*workspace->dDelta_lp[i]*inv_exp_ovun1); + CEunder4 = CEunder1 * (dfvl*workspace->Delta_lp_temp[i]) * + p_ovun4 * exp_ovun1 * SQR(inv_exp_ovun1) + CEunder2; + + /* tally into per-atom energy */ + if (system->pair_ptr->eflag_either) { + eng_tmp = e_ov; + if (numbonds > 0) eng_tmp+= e_un; + pair_reax_ptr->ev_tally_thr_proxy( i, i, system->n, 1, + eng_tmp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); + } + + /* forces */ + workspace->CdDelta[i] += CEover3; // OvCoor - 2nd term + if (numbonds > 0) workspace->CdDelta[i] += CEunder3; // UnCoor - 1st term + + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { + pbond = &(bonds->select.bond_list[pj]); + j = pbond->nbr; + bo_ij = &(pbond->bo_data); + twbp = &(system->reax_param.tbp[system->my_atoms[i].type] + [system->my_atoms[pbond->nbr].type]); + + bo_ij->Cdbo += CEover1 * twbp->p_ovun1 * twbp->De_s; // OvCoor-1st + workspace->CdDeltaReduction[reductionOffset+j] += + CEover4 * (1.0 - dfvl*workspace->dDelta_lp[j]) * (bo_ij->BO_pi + bo_ij->BO_pi2); // OvCoor-3a + + bo_ij->Cdbopi += CEover4 * + (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j]); // OvCoor-3b + bo_ij->Cdbopi2 += CEover4 * + (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j]); // OvCoor-3b + + workspace->CdDeltaReduction[reductionOffset+j] += + CEunder4 * (1.0 - dfvl*workspace->dDelta_lp[j]) * (bo_ij->BO_pi + bo_ij->BO_pi2); // UnCoor - 2a + + bo_ij->Cdbopi += CEunder4 * + (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j]); // UnCoor-2b + bo_ij->Cdbopi2 += CEunder4 * + (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j]); // UnCoor-2b + } + } + } + + data->my_en.e_lp += total_Elp; + data->my_en.e_ov += total_Eov; + data->my_en.e_un += total_Eun; + } +} diff --git a/src/OPENMP/reaxff_nonbonded_omp.cpp b/src/OPENMP/reaxff_nonbonded_omp.cpp new file mode 100644 index 0000000000..a57542f550 --- /dev/null +++ b/src/OPENMP/reaxff_nonbonded_omp.cpp @@ -0,0 +1,348 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + Website: https://www.cs.purdue.edu/puremd + + Copyright (2010) Purdue University + + Contributing authors: + H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama + Corresponding author: + Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_omp.h" + +#include "pair_reaxff_omp.h" +#include "reaxff_api.h" + +#include + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +namespace ReaxFF { + void vdW_Coulomb_Energy_OMP(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, + reax_list **lists) + { + int natoms = system->n; + reax_list *far_nbrs = (*lists) + FAR_NBRS; + double p_vdW1 = system->reax_param.gp.l[28]; + double p_vdW1i = 1.0 / p_vdW1; + double total_EvdW = 0.; + double total_Eele = 0.; + +#if defined(_OPENMP) +#pragma omp parallel default(shared) reduction(+: total_EvdW, total_Eele) +#endif + { + int tid = get_tid(); + int i, j, pj; + int start_i, end_i, orig_i, orig_j, flag; + double powr_vdW1, powgi_vdW1; + double tmp, r_ij, fn13, exp1, exp2; + double Tap, dTap, dfn13, CEvd, CEclmb, de_core; + double dr3gamij_1, dr3gamij_3; + double e_ele, e_vdW, e_core; + const double SMALL = 0.0001; + double e_lg, de_lg, r_ij5, r_ij6, re6; + two_body_parameters *twbp; + far_neighbor_data *nbr_pj; + + // Tallying variables: + double pe_vdw, f_tmp, delij[3]; + + long reductionOffset = (system->N * tid); + + class PairReaxFFOMP *pair_reax_ptr; + pair_reax_ptr = static_cast(system->pair_ptr); + class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); + + e_core = 0; + e_vdW = 0; + e_lg = 0; + de_lg = 0.0; + +#if defined(_OPENMP) +#pragma omp for schedule(guided) +#endif + for (i = 0; i < natoms; ++i) { + if (system->my_atoms[i].type < 0) continue; + start_i = Start_Index(i, far_nbrs); + end_i = End_Index(i, far_nbrs); + orig_i = system->my_atoms[i].orig_id; + + for (pj = start_i; pj < end_i; ++pj) { + nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); + j = nbr_pj->nbr; + orig_j = system->my_atoms[j].orig_id; + + flag = 0; + if (nbr_pj->d <= control->nonb_cut) { + if (j < natoms) flag = 1; + else if (orig_i < orig_j) flag = 1; + else if (orig_i == orig_j) { + if (nbr_pj->dvec[2] > SMALL) flag = 1; + else if (fabs(nbr_pj->dvec[2]) < SMALL) { + if (nbr_pj->dvec[1] > SMALL) flag = 1; + else if (fabs(nbr_pj->dvec[1]) < SMALL && nbr_pj->dvec[0] > SMALL) + flag = 1; + } + } + } + + if (flag) { + + r_ij = nbr_pj->d; + twbp = &(system->reax_param.tbp[system->my_atoms[i].type] + [system->my_atoms[j].type]); + + /* Calculate Taper and its derivative */ + // Tap = nbr_pj->Tap; -- precomputed during compte_H + Tap = workspace->Tap[7] * r_ij + workspace->Tap[6]; + Tap = Tap * r_ij + workspace->Tap[5]; + Tap = Tap * r_ij + workspace->Tap[4]; + Tap = Tap * r_ij + workspace->Tap[3]; + Tap = Tap * r_ij + workspace->Tap[2]; + Tap = Tap * r_ij + workspace->Tap[1]; + Tap = Tap * r_ij + workspace->Tap[0]; + + dTap = 7*workspace->Tap[7] * r_ij + 6*workspace->Tap[6]; + dTap = dTap * r_ij + 5*workspace->Tap[5]; + dTap = dTap * r_ij + 4*workspace->Tap[4]; + dTap = dTap * r_ij + 3*workspace->Tap[3]; + dTap = dTap * r_ij + 2*workspace->Tap[2]; + dTap += workspace->Tap[1]/r_ij; + + /*vdWaals Calculations*/ + if (system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) + { // shielding + powr_vdW1 = pow(r_ij, p_vdW1); + powgi_vdW1 = pow(1.0 / twbp->gamma_w, p_vdW1); + + fn13 = pow(powr_vdW1 + powgi_vdW1, p_vdW1i); + exp1 = exp(twbp->alpha * (1.0 - fn13 / twbp->r_vdW)); + exp2 = exp(0.5 * twbp->alpha * (1.0 - fn13 / twbp->r_vdW)); + + e_vdW = twbp->D * (exp1 - 2.0 * exp2); + total_EvdW += Tap * e_vdW; + + dfn13 = pow(powr_vdW1 + powgi_vdW1, p_vdW1i - 1.0) * + pow(r_ij, p_vdW1 - 2.0); + + CEvd = dTap * e_vdW - + Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) * dfn13; + } + else { // no shielding + exp1 = exp(twbp->alpha * (1.0 - r_ij / twbp->r_vdW)); + exp2 = exp(0.5 * twbp->alpha * (1.0 - r_ij / twbp->r_vdW)); + + e_vdW = twbp->D * (exp1 - 2.0 * exp2); + total_EvdW += Tap * e_vdW; + + CEvd = dTap * e_vdW - + Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; + } + + if (system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) + { // innner wall + e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); + total_EvdW += Tap * e_core; + + de_core = -(twbp->acore/twbp->rcore) * e_core; + CEvd += dTap * e_core + Tap * de_core / r_ij; + + // lg correction, only if lgvdw is yes + if (control->lgflag) { + r_ij5 = pow(r_ij, 5.0); + r_ij6 = pow(r_ij, 6.0); + re6 = pow(twbp->lgre, 6.0); + + e_lg = -(twbp->lgcij/(r_ij6 + re6)); + total_EvdW += Tap * e_lg; + + de_lg = -6.0 * e_lg * r_ij5 / (r_ij6 + re6) ; + CEvd += dTap * e_lg + Tap * de_lg / r_ij; + } + + } + + /*Coulomb Calculations*/ + dr3gamij_1 = (r_ij * r_ij * r_ij + twbp->gamma); + dr3gamij_3 = pow(dr3gamij_1 , 0.33333333333333); + + tmp = Tap / dr3gamij_3; + total_Eele += e_ele = + C_ele * system->my_atoms[i].q * system->my_atoms[j].q * tmp; + + CEclmb = C_ele * system->my_atoms[i].q * system->my_atoms[j].q * + (dTap - Tap * r_ij / dr3gamij_1) / dr3gamij_3; + + /* tally into per-atom energy */ + if (system->pair_ptr->evflag || system->pair_ptr->vflag_atom) { + pe_vdw = Tap * (e_vdW + e_core + e_lg); + rvec_ScaledSum(delij, 1., system->my_atoms[i].x, + -1., system->my_atoms[j].x); + f_tmp = -(CEvd + CEclmb); + pair_reax_ptr->ev_tally_thr_proxy( i, j, natoms, + 1, pe_vdw, e_ele, f_tmp, + delij[0], delij[1], delij[2], thr); + } + + rvec_ScaledAdd(workspace->f[i], -(CEvd + CEclmb), nbr_pj->dvec); + rvec_ScaledAdd(workspace->forceReduction[reductionOffset+j], + +(CEvd + CEclmb), nbr_pj->dvec); + } + } + } + + pair_reax_ptr->reduce_thr_proxy(system->pair_ptr, system->pair_ptr->eflag_either, + system->pair_ptr->vflag_either, thr); + } // parallel region + + data->my_en.e_vdW = total_EvdW; + data->my_en.e_ele = total_Eele; + + Compute_Polarization_Energy(system, data); + } + +/* ---------------------------------------------------------------------- */ + + void Tabulated_vdW_Coulomb_Energy_OMP(reax_system *system,control_params *control, + simulation_data *data, storage *workspace, + reax_list **lists) { + + double SMALL = 0.0001; + int natoms = system->n; + reax_list *far_nbrs = (*lists) + FAR_NBRS; + double total_EvdW = 0.; + double total_Eele = 0.; + +#if defined(_OPENMP) +#pragma omp parallel default(shared) reduction(+:total_EvdW, total_Eele) +#endif + { + int i, j, pj, r; + int type_i, type_j, tmin, tmax; + int start_i, end_i, orig_i, orig_j, flag; + double r_ij, base, dif; + double e_vdW, e_ele; + double CEvd, CEclmb; + double f_tmp, delij[3]; + far_neighbor_data *nbr_pj; + LR_lookup_table *t; + + int tid = get_tid(); + long froffset = (system->N * tid); + LR_lookup_table ** & LR = system->LR; + + class PairReaxFFOMP *pair_reax_ptr; + pair_reax_ptr = static_cast(system->pair_ptr); + class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); + +#if defined(_OPENMP) +#pragma omp for schedule(guided) +#endif + for (i = 0; i < natoms; ++i) { + type_i = system->my_atoms[i].type; + if (type_i < 0) continue; + start_i = Start_Index(i,far_nbrs); + end_i = End_Index(i,far_nbrs); + orig_i = system->my_atoms[i].orig_id; + + for (pj = start_i; pj < end_i; ++pj) { + nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); + j = nbr_pj->nbr; + type_j = system->my_atoms[j].type; + if (type_j < 0) continue; + orig_j = system->my_atoms[j].orig_id; + + flag = 0; + if (nbr_pj->d <= control->nonb_cut) { + if (j < natoms) flag = 1; + else if (orig_i < orig_j) flag = 1; + else if (orig_i == orig_j) { + if (nbr_pj->dvec[2] > SMALL) flag = 1; + else if (fabs(nbr_pj->dvec[2]) < SMALL) { + if (nbr_pj->dvec[1] > SMALL) flag = 1; + else if (fabs(nbr_pj->dvec[1]) < SMALL && nbr_pj->dvec[0] > SMALL) + flag = 1; + } + } + + } + + if (flag) { + + r_ij = nbr_pj->d; + tmin = MIN(type_i, type_j); + tmax = MAX(type_i, type_j); + t = &(LR[tmin][tmax]); + + /* Cubic Spline Interpolation */ + r = (int)(r_ij * t->inv_dx); + if (r == 0) ++r; + base = (double)(r+1) * t->dx; + dif = r_ij - base; + + e_vdW = ((t->vdW[r].d*dif + t->vdW[r].c)*dif + t->vdW[r].b)*dif + + t->vdW[r].a; + + e_ele = ((t->ele[r].d*dif + t->ele[r].c)*dif + t->ele[r].b)*dif + + t->ele[r].a; + e_ele *= system->my_atoms[i].q * system->my_atoms[j].q; + + total_EvdW += e_vdW; + total_Eele += e_ele; + + CEvd = ((t->CEvd[r].d*dif + t->CEvd[r].c)*dif + t->CEvd[r].b)*dif + + t->CEvd[r].a; + + CEclmb = ((t->CEclmb[r].d*dif+t->CEclmb[r].c)*dif+t->CEclmb[r].b)*dif + + t->CEclmb[r].a; + CEclmb *= system->my_atoms[i].q * system->my_atoms[j].q; + + /* tally into per-atom energy */ + if (system->pair_ptr->evflag) { + rvec_ScaledSum(delij, 1., system->my_atoms[i].x, + -1., system->my_atoms[j].x); + f_tmp = -(CEvd + CEclmb); + pair_reax_ptr->ev_tally_thr_proxy( i, j, natoms, 1, e_vdW, e_ele, + f_tmp, delij[0], delij[1], delij[2], thr); + } + + rvec_ScaledAdd(workspace->f[i], -(CEvd + CEclmb), nbr_pj->dvec); + rvec_ScaledAdd(workspace->forceReduction[froffset+j], + +(CEvd + CEclmb), nbr_pj->dvec); + } + } + } + + pair_reax_ptr->reduce_thr_proxy(system->pair_ptr, system->pair_ptr->eflag_either, + system->pair_ptr->vflag_either, thr); + } // end omp parallel + + data->my_en.e_vdW = total_EvdW; + data->my_en.e_ele = total_Eele; + + Compute_Polarization_Energy(system, data); + } +} diff --git a/src/OPENMP/reaxff_omp.h b/src/OPENMP/reaxff_omp.h new file mode 100644 index 0000000000..252e5f0e9d --- /dev/null +++ b/src/OPENMP/reaxff_omp.h @@ -0,0 +1,103 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/ 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 author: Hasan Metin Aktulga, Purdue University + (now at Lawrence Berkeley National Laboratory, hmaktulga@lbl.gov) + + Heavily modified and adapted for LAMMPS by the LAMMPS developers. +------------------------------------------------------------------------- */ + +#ifndef LMP_REAXFF_OMP_H +#define LMP_REAXFF_OMP_H + +#include "reaxff_types.h" + +#if defined(_OPENMP) +#include +#endif + +namespace ReaxFF +{ + // exported Functions + + // bond orders OpenMP + + extern void Add_dBond_to_ForcesOMP(reax_system *, int, int, storage *, reax_list **); + extern void Add_dBond_to_Forces_NPTOMP(reax_system *, int, int, storage *, reax_list **); + extern int BOp_OMP(storage *, reax_list *, double, int, int, far_neighbor_data *, + single_body_parameters *, single_body_parameters *, + two_body_parameters *, int, double, double, double, + double, double, double, double); + + extern void BOOMP(reax_system *, storage *, reax_list **); + + // bonds OpenMP + + extern void BondsOMP(reax_system *, simulation_data *, + storage *, reax_list **); + + // forces OpenMP + + extern void Compute_ForcesOMP(reax_system *, control_params *, + simulation_data *, storage *, reax_list **); + + // hydrogen bonds + + extern void Hydrogen_BondsOMP(reax_system *, control_params *, + simulation_data *, storage *, reax_list **); + + // init md OpenMP + + extern void InitializeOMP(reax_system *, control_params *, simulation_data *, + storage *, reax_list **,MPI_Comm); + + // multi body + + extern void Atom_EnergyOMP(reax_system *, simulation_data *, storage *, reax_list **); + + // nonbonded + + extern void vdW_Coulomb_Energy_OMP(reax_system *, control_params *, + simulation_data *, storage *, reax_list **); + extern void Tabulated_vdW_Coulomb_Energy_OMP(reax_system *, control_params *, + simulation_data *, storage *, + reax_list **); + extern void LR_vdW_CoulombOMP(reax_system *, storage *, control_params *, + int, int, double, LR_data *); + + // torsion angles + + extern void Torsion_AnglesOMP(reax_system *, control_params *, + simulation_data *, storage *, reax_list **); + + // valence angles + + extern void Calculate_ThetaOMP(rvec, double, rvec, double, double *, double *); + extern void Calculate_dCos_ThetaOMP(rvec, double, rvec, double, + rvec *, rvec *, rvec *); + extern void Valence_AnglesOMP(reax_system *, control_params *, simulation_data *, + storage *, reax_list **); + + // OpenMP helpers + + inline int get_tid() { +#if defined(_OPENMP) + return omp_get_thread_num(); +#else + return 0; +#endif + } +} + +#endif diff --git a/src/OPENMP/reaxff_torsion_angles_omp.cpp b/src/OPENMP/reaxff_torsion_angles_omp.cpp new file mode 100644 index 0000000000..648603b143 --- /dev/null +++ b/src/OPENMP/reaxff_torsion_angles_omp.cpp @@ -0,0 +1,396 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + Website: https://www.cs.purdue.edu/puremd + + Copyright (2010) Purdue University + + Contributing authors: + H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama + Corresponding author: + Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_omp.h" + +#include "fix_omp.h" +#include "pair_reaxff_omp.h" +#include "reaxff_api.h" + +#include + +#define MIN_SINE 1e-10 + +using namespace LAMMPS_NS; + +namespace ReaxFF { + + /* ---------------------------------------------------------------------- */ + void Torsion_AnglesOMP(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, + reax_list **lists) + { + int natoms = system->n; + reax_list *bonds = (*lists) + BONDS; + reax_list *thb_intrs = (*lists) + THREE_BODIES; + double p_tor2 = system->reax_param.gp.l[23]; + double p_tor3 = system->reax_param.gp.l[24]; + double p_tor4 = system->reax_param.gp.l[25]; + double p_cot2 = system->reax_param.gp.l[27]; + double total_Etor = 0; + double total_Econ = 0; + int nthreads = control->nthreads; + +#if defined(_OPENMP) +#pragma omp parallel default(shared) reduction(+: total_Etor, total_Econ) +#endif + { + int i, j, k, l, pi, pj, pk, pl, pij, plk; + int type_i, type_j, type_k, type_l; + int start_j, end_j; + int start_pj, end_pj, start_pk, end_pk; + int num_frb_intrs = 0; + + double Delta_j, Delta_k; + double r_ij, r_jk, r_kl, r_li; + double BOA_ij, BOA_jk, BOA_kl; + + double exp_tor2_ij, exp_tor2_jk, exp_tor2_kl; + double exp_tor1, exp_tor3_DjDk, exp_tor4_DjDk, exp_tor34_inv; + double exp_cot2_jk, exp_cot2_ij, exp_cot2_kl; + double fn10, f11_DjDk, dfn11, fn12; + double theta_ijk, theta_jkl; + double sin_ijk, sin_jkl; + double cos_ijk, cos_jkl; + double tan_ijk_i, tan_jkl_i; + double omega, cos_omega, cos2omega, cos3omega; + rvec dcos_omega_di, dcos_omega_dj, dcos_omega_dk, dcos_omega_dl; + double CV, cmn, CEtors1, CEtors2, CEtors3, CEtors4; + double CEtors5, CEtors6, CEtors7, CEtors8, CEtors9; + double Cconj, CEconj1, CEconj2, CEconj3; + double CEconj4, CEconj5, CEconj6; + double e_tor, e_con; + rvec dvec_li; + four_body_header *fbh; + four_body_parameters *fbp; + bond_data *pbond_ij, *pbond_jk, *pbond_kl; + bond_order_data *bo_ij, *bo_jk, *bo_kl; + three_body_interaction_data *p_ijk, *p_jkl; + + // Virial tallying variables + double delil[3], deljl[3], delkl[3]; + double eng_tmp, fi_tmp[3], fj_tmp[3], fk_tmp[3]; + + int tid = get_tid(); + + long reductionOffset = (system->N * tid); + class PairReaxFFOMP *pair_reax_ptr; + pair_reax_ptr = static_cast(system->pair_ptr); + class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); + +#if defined(_OPENMP) +#pragma omp for schedule(static) +#endif + for (j = 0; j < system->N; ++j) { + start_j = Start_Index(j, bonds); + end_j = End_Index(j, bonds); + + for (pk = start_j; pk < end_j; ++pk) { + bo_jk = &(bonds->select.bond_list[pk].bo_data); + for (k = 0; k < nthreads; ++k) + bo_jk->CdboReduction[k] = 0.; + } + } + +#if defined(_OPENMP) +#pragma omp for schedule(dynamic,50) +#endif + for (j = 0; j < natoms; ++j) { + type_j = system->my_atoms[j].type; + Delta_j = workspace->Delta_boc[j]; + start_j = Start_Index(j, bonds); + end_j = End_Index(j, bonds); + + for (pk = start_j; pk < end_j; ++pk) { + pbond_jk = &(bonds->select.bond_list[pk]); + k = pbond_jk->nbr; + bo_jk = &(pbond_jk->bo_data); + BOA_jk = bo_jk->BO - control->thb_cut; + + /* see if there are any 3-body interactions involving j&k + where j is the central atom. Otherwise there is no point in + trying to form a 4-body interaction out of this neighborhood */ + if (system->my_atoms[j].orig_id < system->my_atoms[k].orig_id && + bo_jk->BO > control->thb_cut/*0*/ && Num_Entries(pk, thb_intrs)) { + pj = pbond_jk->sym_index; // pj points to j on k's list + + /* do the same check as above: + are there any 3-body interactions involving k&j + where k is the central atom */ + if (Num_Entries(pj, thb_intrs)) { + type_k = system->my_atoms[k].type; + Delta_k = workspace->Delta_boc[k]; + r_jk = pbond_jk->d; + + start_pk = Start_Index(pk, thb_intrs); + end_pk = End_Index(pk, thb_intrs); + start_pj = Start_Index(pj, thb_intrs); + end_pj = End_Index(pj, thb_intrs); + + exp_tor2_jk = exp(-p_tor2 * BOA_jk); + exp_cot2_jk = exp(-p_cot2 * SQR(BOA_jk - 1.5)); + exp_tor3_DjDk = exp(-p_tor3 * (Delta_j + Delta_k)); + exp_tor4_DjDk = exp(p_tor4 * (Delta_j + Delta_k)); + exp_tor34_inv = 1.0 / (1.0 + exp_tor3_DjDk + exp_tor4_DjDk); + f11_DjDk = (2.0 + exp_tor3_DjDk) * exp_tor34_inv; + + + /* pick i up from j-k interaction where j is the central atom */ + for (pi = start_pk; pi < end_pk; ++pi) { + p_ijk = &(thb_intrs->select.three_body_list[pi]); + pij = p_ijk->pthb; // pij is pointer to i on j's bond_list + pbond_ij = &(bonds->select.bond_list[pij]); + bo_ij = &(pbond_ij->bo_data); + + if (bo_ij->BO > control->thb_cut/*0*/) { + i = p_ijk->thb; + type_i = system->my_atoms[i].type; + r_ij = pbond_ij->d; + BOA_ij = bo_ij->BO - control->thb_cut; + + theta_ijk = p_ijk->theta; + sin_ijk = sin(theta_ijk); + cos_ijk = cos(theta_ijk); + //tan_ijk_i = 1. / tan(theta_ijk); + if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) + tan_ijk_i = cos_ijk / MIN_SINE; + else if (sin_ijk <= 0 && sin_ijk >= -MIN_SINE) + tan_ijk_i = cos_ijk / -MIN_SINE; + else tan_ijk_i = cos_ijk / sin_ijk; + + exp_tor2_ij = exp(-p_tor2 * BOA_ij); + exp_cot2_ij = exp(-p_cot2 * SQR(BOA_ij -1.5)); + + + /* pick l up from j-k interaction where k is the central atom */ + for (pl = start_pj; pl < end_pj; ++pl) { + p_jkl = &(thb_intrs->select.three_body_list[pl]); + l = p_jkl->thb; + plk = p_jkl->pthb; //pointer to l on k's bond_list! + pbond_kl = &(bonds->select.bond_list[plk]); + bo_kl = &(pbond_kl->bo_data); + type_l = system->my_atoms[l].type; + fbh = &(system->reax_param.fbp[type_i][type_j] + [type_k][type_l]); + fbp = &(system->reax_param.fbp[type_i][type_j] + [type_k][type_l].prm[0]); + + if (i != l && fbh->cnt && + bo_kl->BO > control->thb_cut/*0*/ && + bo_ij->BO * bo_jk->BO * bo_kl->BO > control->thb_cut/*0*/) { + ++num_frb_intrs; + //fprintf(stderr, + // "%5d: %6d %6d %6d %6d\n", num_frb_intrs, + // system->my_atoms[i].orig_id,system->my_atoms[j].orig_id, + // system->my_atoms[k].orig_id,system->my_atoms[l].orig_id); + + r_kl = pbond_kl->d; + BOA_kl = bo_kl->BO - control->thb_cut; + + theta_jkl = p_jkl->theta; + sin_jkl = sin(theta_jkl); + cos_jkl = cos(theta_jkl); + //tan_jkl_i = 1. / tan(theta_jkl); + if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) + tan_jkl_i = cos_jkl / MIN_SINE; + else if (sin_jkl <= 0 && sin_jkl >= -MIN_SINE) + tan_jkl_i = cos_jkl / -MIN_SINE; + else tan_jkl_i = cos_jkl /sin_jkl; + + rvec_ScaledSum(dvec_li, 1., system->my_atoms[i].x, + -1., system->my_atoms[l].x); + r_li = rvec_Norm(dvec_li); + + + /* omega and its derivative */ + omega = Calculate_Omega(pbond_ij->dvec, r_ij, + pbond_jk->dvec, r_jk, + pbond_kl->dvec, r_kl, + dvec_li, r_li, + p_ijk, p_jkl, + dcos_omega_di, dcos_omega_dj, + dcos_omega_dk, dcos_omega_dl); + + cos_omega = cos(omega); + cos2omega = cos(2. * omega); + cos3omega = cos(3. * omega); + /* end omega calculations */ + + /* torsion energy */ + exp_tor1 = exp(fbp->p_tor1 * + SQR(2.0 - bo_jk->BO_pi - f11_DjDk)); + exp_tor2_kl = exp(-p_tor2 * BOA_kl); + exp_cot2_kl = exp(-p_cot2 * SQR(BOA_kl - 1.5)); + fn10 = (1.0 - exp_tor2_ij) * (1.0 - exp_tor2_jk) * + (1.0 - exp_tor2_kl); + + CV = 0.5 * (fbp->V1 * (1.0 + cos_omega) + + fbp->V2 * exp_tor1 * (1.0 - cos2omega) + + fbp->V3 * (1.0 + cos3omega)); + + total_Etor += e_tor = fn10 * sin_ijk * sin_jkl * CV; + + dfn11 = (-p_tor3 * exp_tor3_DjDk + + (p_tor3 * exp_tor3_DjDk - p_tor4 * exp_tor4_DjDk) * + (2.0 + exp_tor3_DjDk) * exp_tor34_inv) * + exp_tor34_inv; + + CEtors1 = sin_ijk * sin_jkl * CV; + + CEtors2 = -fn10 * 2.0 * fbp->p_tor1 * fbp->V2 * exp_tor1 * + (2.0 - bo_jk->BO_pi - f11_DjDk) * (1.0 - SQR(cos_omega)) * + sin_ijk * sin_jkl; + CEtors3 = CEtors2 * dfn11; + + CEtors4 = CEtors1 * p_tor2 * exp_tor2_ij * + (1.0 - exp_tor2_jk) * (1.0 - exp_tor2_kl); + CEtors5 = CEtors1 * p_tor2 * + (1.0 - exp_tor2_ij) * exp_tor2_jk * (1.0 - exp_tor2_kl); + CEtors6 = CEtors1 * p_tor2 * + (1.0 - exp_tor2_ij) * (1.0 - exp_tor2_jk) * exp_tor2_kl; + + cmn = -fn10 * CV; + CEtors7 = cmn * sin_jkl * tan_ijk_i; + CEtors8 = cmn * sin_ijk * tan_jkl_i; + + CEtors9 = fn10 * sin_ijk * sin_jkl * + (0.5 * fbp->V1 - 2.0 * fbp->V2 * exp_tor1 * cos_omega + + 1.5 * fbp->V3 * (cos2omega + 2.0 * SQR(cos_omega))); + /* end of torsion energy */ + + + /* 4-body conjugation energy */ + fn12 = exp_cot2_ij * exp_cot2_jk * exp_cot2_kl; + //data->my_en.e_con += e_con = + total_Econ += e_con = + fbp->p_cot1 * fn12 * + (1.0 + (SQR(cos_omega) - 1.0) * sin_ijk * sin_jkl); + + Cconj = -2.0 * fn12 * fbp->p_cot1 * p_cot2 * + (1.0 + (SQR(cos_omega) - 1.0) * sin_ijk * sin_jkl); + + CEconj1 = Cconj * (BOA_ij - 1.5e0); + CEconj2 = Cconj * (BOA_jk - 1.5e0); + CEconj3 = Cconj * (BOA_kl - 1.5e0); + + CEconj4 = -fbp->p_cot1 * fn12 * + (SQR(cos_omega) - 1.0) * sin_jkl * tan_ijk_i; + CEconj5 = -fbp->p_cot1 * fn12 * + (SQR(cos_omega) - 1.0) * sin_ijk * tan_jkl_i; + CEconj6 = 2.0 * fbp->p_cot1 * fn12 * + cos_omega * sin_ijk * sin_jkl; + /* end 4-body conjugation energy */ + + /* FORCES */ + bo_jk->Cdbopi += CEtors2; + workspace->CdDelta[j] += CEtors3; + //workspace->CdDelta[k] += CEtors3; + workspace->CdDeltaReduction[reductionOffset+k] += CEtors3; + bo_ij->Cdbo += (CEtors4 + CEconj1); + bo_jk->Cdbo += (CEtors5 + CEconj2); + //bo_kl->Cdbo += (CEtors6 + CEconj3); + bo_kl->CdboReduction[tid] += (CEtors6 + CEconj3); + + /* dcos_theta_ijk */ + rvec_ScaledAdd(workspace->f[j], + CEtors7 + CEconj4, p_ijk->dcos_dj); + rvec_ScaledAdd(workspace->forceReduction[reductionOffset+i], + CEtors7 + CEconj4, p_ijk->dcos_dk); + rvec_ScaledAdd(workspace->forceReduction[reductionOffset+k], + CEtors7 + CEconj4, p_ijk->dcos_di); + + /* dcos_theta_jkl */ + rvec_ScaledAdd(workspace->f[j], + CEtors8 + CEconj5, p_jkl->dcos_di); + rvec_ScaledAdd(workspace->forceReduction[reductionOffset+k], + CEtors8 + CEconj5, p_jkl->dcos_dj); + rvec_ScaledAdd(workspace->forceReduction[reductionOffset+l], + CEtors8 + CEconj5, p_jkl->dcos_dk); + + /* dcos_omega */ + rvec_ScaledAdd(workspace->f[j], + CEtors9 + CEconj6, dcos_omega_dj); + rvec_ScaledAdd(workspace->forceReduction[reductionOffset+i], + CEtors9 + CEconj6, dcos_omega_di); + rvec_ScaledAdd(workspace->forceReduction[reductionOffset+k], + CEtors9 + CEconj6, dcos_omega_dk); + rvec_ScaledAdd(workspace->forceReduction[reductionOffset+l], + CEtors9 + CEconj6, dcos_omega_dl); + + /* tally into per-atom virials */ + if (system->pair_ptr->evflag) { + + // acquire vectors + rvec_ScaledSum(delil, 1., system->my_atoms[l].x, + -1., system->my_atoms[i].x); + rvec_ScaledSum(deljl, 1., system->my_atoms[l].x, + -1., system->my_atoms[j].x); + rvec_ScaledSum(delkl, 1., system->my_atoms[l].x, + -1., system->my_atoms[k].x); + // dcos_theta_ijk + rvec_Scale(fi_tmp, CEtors7 + CEconj4, p_ijk->dcos_dk); + rvec_Scale(fj_tmp, CEtors7 + CEconj4, p_ijk->dcos_dj); + rvec_Scale(fk_tmp, CEtors7 + CEconj4, p_ijk->dcos_di); + + // dcos_theta_jkl + rvec_ScaledAdd(fj_tmp, CEtors8 + CEconj5, p_jkl->dcos_di); + rvec_ScaledAdd(fk_tmp, CEtors8 + CEconj5, p_jkl->dcos_dj); + + // dcos_omega + rvec_ScaledAdd(fi_tmp, CEtors9 + CEconj6, dcos_omega_di); + rvec_ScaledAdd(fj_tmp, CEtors9 + CEconj6, dcos_omega_dj); + rvec_ScaledAdd(fk_tmp, CEtors9 + CEconj6, dcos_omega_dk); + + // tally + eng_tmp = e_tor + e_con; + + if (system->pair_ptr->eflag_either) + pair_reax_ptr->ev_tally_thr_proxy( j, k, system->n, 1, + eng_tmp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); + + if (system->pair_ptr->vflag_either) + pair_reax_ptr->v_tally4_thr_proxy(i, j, k, l, fi_tmp, fj_tmp, fk_tmp, + delil, deljl, delkl, thr); + } + + } // pl check ends + } // pl loop ends + } // pi check ends + } // pi loop ends + } // k-j neighbor check ends + } // jmy_en.e_tor = total_Etor; + data->my_en.e_con = total_Econ; + } +} diff --git a/src/OPENMP/reaxff_valence_angles_omp.cpp b/src/OPENMP/reaxff_valence_angles_omp.cpp new file mode 100644 index 0000000000..423b6336df --- /dev/null +++ b/src/OPENMP/reaxff_valence_angles_omp.cpp @@ -0,0 +1,571 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + Website: https://www.cs.purdue.edu/puremd + + Copyright (2010) Purdue University + + Contributing authors: + H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama + Corresponding author: + Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_omp.h" + +#include "error.h" +#include "fix_omp.h" +#include "pair_reaxff_omp.h" +#include "reaxff_api.h" + +#include + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +namespace ReaxFF { + void Calculate_dCos_ThetaOMP(rvec dvec_ji, double d_ji, rvec dvec_jk, + double d_jk, rvec *dcos_theta_di, + rvec *dcos_theta_dj, rvec *dcos_theta_dk) + { + double sqr_d_ji = SQR(d_ji); + double sqr_d_jk = SQR(d_jk); + double inv_dists = 1.0 / (d_ji * d_jk); + double inv_dists3 = inv_dists * inv_dists * inv_dists; + double dot_dvecs = dvec_ji[0]*dvec_jk[0] + dvec_ji[1]*dvec_jk[1] + dvec_ji[2]*dvec_jk[2]; + double Cdot_inv3 = dot_dvecs * inv_dists3; + + double csqr_jk = Cdot_inv3 * sqr_d_jk; + double csqr_ji = Cdot_inv3 * sqr_d_ji; + + // Try to help compiler out by unrolling + // x-component + double dinv_jk = dvec_jk[0] * inv_dists; + double dinv_ji = dvec_ji[0] * inv_dists; + + double cdev_ji = csqr_jk * dvec_ji[0]; + double cdev_jk = csqr_ji * dvec_jk[0]; + + (*dcos_theta_di)[0] = dinv_jk - cdev_ji; + (*dcos_theta_dj)[0] = -(dinv_jk + dinv_ji) + cdev_ji + cdev_jk; + (*dcos_theta_dk)[0] = dinv_ji - cdev_jk; + + // y-component + dinv_jk = dvec_jk[1] * inv_dists; + dinv_ji = dvec_ji[1] * inv_dists; + + cdev_ji = csqr_jk * dvec_ji[1]; + cdev_jk = csqr_ji * dvec_jk[1]; + + (*dcos_theta_di)[1] = dinv_jk - cdev_ji; + (*dcos_theta_dj)[1] = -(dinv_jk + dinv_ji) + cdev_ji + cdev_jk; + (*dcos_theta_dk)[1] = dinv_ji - cdev_jk; + + // z-component + dinv_jk = dvec_jk[2] * inv_dists; + dinv_ji = dvec_ji[2] * inv_dists; + + cdev_ji = csqr_jk * dvec_ji[2]; + cdev_jk = csqr_ji * dvec_jk[2]; + + (*dcos_theta_di)[2] = dinv_jk - cdev_ji; + (*dcos_theta_dj)[2] = -(dinv_jk + dinv_ji) + cdev_ji + cdev_jk; + (*dcos_theta_dk)[2] = dinv_ji - cdev_jk; + } + + /* ---------------------------------------------------------------------- */ + + /* this is a 3-body interaction in which the main role is + played by j which sits in the middle of the other two. */ + void Valence_AnglesOMP(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, + reax_list **lists) + { + reax_list *bonds = (*lists) + BONDS; + reax_list *thb_intrs = (*lists) + THREE_BODIES; + + // Precompute and store valence_angle offsets for OpenMP code. + int * _my_offset = workspace->valence_angle_atom_myoffset; + + /* global parameters used in these calculations */ + double p_val6 = system->reax_param.gp.l[14]; + double p_val8 = system->reax_param.gp.l[33]; + double p_val9 = system->reax_param.gp.l[16]; + double p_val10 = system->reax_param.gp.l[17]; + double total_Eang = 0; + double total_Epen = 0; + double total_Ecoa = 0; + + int nthreads = control->nthreads; + int num_thb_intrs = 0; + int TWICE = 2; +#if defined(_OPENMP) +#pragma omp parallel default(shared) reduction(+:total_Eang, total_Epen, total_Ecoa, num_thb_intrs) +#endif + { + int i, j, pi, k, pk, t; + int type_i, type_j, type_k; + int start_j, end_j, start_pk, end_pk; + int cnt, my_offset; + + double temp, temp_bo_jt, pBOjt7; + double p_val1, p_val2, p_val3, p_val4, p_val5, p_val7; + double p_pen1, p_pen2, p_pen3, p_pen4; + double p_coa1, p_coa2, p_coa3, p_coa4; + double trm8, expval6, expval7, expval2theta, expval12theta, exp3ij, exp3jk; + double exp_pen2ij, exp_pen2jk, exp_pen3, exp_pen4, trm_pen34, exp_coa2; + double dSBO1, dSBO2, SBO, SBO2, CSBO2, SBOp, prod_SBO, vlpadj; + double CEval1, CEval2, CEval3, CEval4, CEval5, CEval6, CEval7, CEval8; + double CEpen1, CEpen2, CEpen3; + double e_ang, e_coa, e_pen; + double CEcoa1, CEcoa2, CEcoa3, CEcoa4, CEcoa5; + double Cf7ij, Cf7jk, Cf8j, Cf9j; + double f7_ij, f7_jk, f8_Dj, f9_Dj; + double Ctheta_0, theta_0, theta_00, theta, cos_theta, sin_theta; + double BOA_ij, BOA_jk; + + // Tallying variables + double eng_tmp, fi_tmp[3], fj_tmp[3], fk_tmp[3]; + double delij[3], delkj[3]; + + three_body_header *thbh; + three_body_parameters *thbp; + three_body_interaction_data *p_ijk, *p_kji; + bond_data *pbond_ij, *pbond_jk, *pbond_jt; + bond_order_data *bo_ij, *bo_jk, *bo_jt; + + int tid = get_tid(); + + long reductionOffset = (system->N * tid); + class PairReaxFFOMP *pair_reax_ptr; + pair_reax_ptr = static_cast(system->pair_ptr); + class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); + + // Run through a minimal for (jnum_intrs / nthreads; + +#if defined(_OPENMP) +#pragma omp for schedule(dynamic,50) +#endif + for (j = 0; j < system->N; ++j) { + type_j = system->my_atoms[j].type; + _my_offset[j] = 0; + if (type_j < 0) continue; + + start_j = Start_Index(j, bonds); + end_j = End_Index(j, bonds); + + // Always point to start of workspace to count angles + my_offset = tid * per_thread; + + for (pi = start_j; pi < end_j; ++pi) { + Set_Start_Index(pi, my_offset, thb_intrs); + pbond_ij = &(bonds->select.bond_list[pi]); + bo_ij = &(pbond_ij->bo_data); + BOA_ij = bo_ij->BO - control->thb_cut; + + if (BOA_ij > 0.0) { + i = pbond_ij->nbr; + + /* first copy 3-body intrs from previously computed ones where i>k. + in the second for-loop below, + we compute only new 3-body intrs where i < k */ + for (pk = start_j; pk < pi; ++pk) { + start_pk = Start_Index(pk, thb_intrs); + end_pk = End_Index(pk, thb_intrs); + + for (t = start_pk; t < end_pk; ++t) + if (thb_intrs->select.three_body_list[t].thb == i) { + + p_ijk = &(thb_intrs->select.three_body_list[my_offset]); + p_ijk->thb = bonds->select.bond_list[pk].nbr; + + ++my_offset; + break; + } + } // for (pk) + + /* and this is the second for loop mentioned above */ + for (pk = pi+1; pk < end_j; ++pk) { + pbond_jk = &(bonds->select.bond_list[pk]); + k = pbond_jk->nbr; + + if (j >= system->n && i >= system->n && k >= system->n) continue; + + p_ijk = &(thb_intrs->select.three_body_list[my_offset]); + p_ijk->thb = k; + + ++my_offset; // add this to the list of 3-body interactions + } // for (pk) + } // if () + + Set_End_Index(pi, my_offset, thb_intrs); + } // for (pi) + + // Confirm that thb_intrs->num_intrs / nthreads is enough to hold all angles from a single atom + if (my_offset >= (tid+1)*per_thread) + control->error_ptr->one(FLERR, fmt::format("step {}: ran out of space on " + "angle_list for atom {}:\n" + " nthreads={} tid={} my_offset={} per_thread={}\n" + " num_intrs={} N={}",data->step,j,nthreads,tid, + my_offset,per_thread,thb_intrs->num_intrs,system->N)); + // Number of angles owned by this atom + _my_offset[j] = my_offset - tid * per_thread; + } // for (j) + + // Wait for all threads to finish counting angles +#if defined(_OPENMP) && !defined(__NVCC__) +#pragma omp barrier +#endif + // Master thread uses angle counts to compute offsets + // This can be threaded +#if defined(_OPENMP) && !defined(__NVCC__) +#pragma omp master +#endif + { + int current_count = 0; + int m = _my_offset[0]; + _my_offset[0] = current_count; + for (j=1; jN; j++) { + current_count+= m; + m = _my_offset[j]; + _my_offset[j] = current_count; + } + _my_offset[system->N] = current_count + m; // Used to test if last particle has any angles + } + + // All threads wait till master thread finished computing offsets +#if defined(_OPENMP) && !defined(__NVCC__) +#pragma omp barrier +#endif + // Original loop, but now using precomputed offsets + // Safe to use all threads available, regardless of threads tasked above + // We also now skip over atoms that have no angles assigned +#if defined(_OPENMP) +#pragma omp for schedule(dynamic,50)//(dynamic,chunksize)//(guided) +#endif + for (j = 0; j < system->N; ++j) { // Ray: the first one with system->N + type_j = system->my_atoms[j].type; + if (type_j < 0) continue; + + // Skip if no angles for this atom + if (_my_offset[j] == _my_offset[j+1]) continue; + + start_j = Start_Index(j, bonds); + end_j = End_Index(j, bonds); + + type_j = system->my_atoms[j].type; + + my_offset = _my_offset[j]; + + p_val3 = system->reax_param.sbp[type_j].p_val3; + p_val5 = system->reax_param.sbp[type_j].p_val5; + + SBOp = 0, prod_SBO = 1; + for (t = start_j; t < end_j; ++t) { + bo_jt = &(bonds->select.bond_list[t].bo_data); + SBOp += (bo_jt->BO_pi + bo_jt->BO_pi2); + temp = SQR(bo_jt->BO); + temp *= temp; + temp *= temp; + prod_SBO *= exp(-temp); + } + + // modifications to match Adri's code - 09/01/09 + if (workspace->vlpex[j] >= 0) { + vlpadj = 0; + dSBO2 = prod_SBO - 1; + } else { + vlpadj = workspace->nlp[j]; + dSBO2 = (prod_SBO - 1) * (1 - p_val8 * workspace->dDelta_lp[j]); + } + + SBO = SBOp + (1 - prod_SBO) * (-workspace->Delta_boc[j] - p_val8 * vlpadj); + dSBO1 = -8 * prod_SBO * (workspace->Delta_boc[j] + p_val8 * vlpadj); + + if (SBO <= 0) + SBO2 = 0, CSBO2 = 0; + else if (SBO > 0 && SBO <= 1) { + SBO2 = pow(SBO, p_val9); + CSBO2 = p_val9 * pow(SBO, p_val9 - 1); + } + else if (SBO > 1 && SBO < 2) { + SBO2 = 2 - pow(2-SBO, p_val9); + CSBO2 = p_val9 * pow(2 - SBO, p_val9 - 1); + } + else + SBO2 = 2, CSBO2 = 0; + + expval6 = exp(p_val6 * workspace->Delta_boc[j]); + + for (pi = start_j; pi < end_j; ++pi) { + Set_Start_Index(pi, my_offset, thb_intrs); + pbond_ij = &(bonds->select.bond_list[pi]); + bo_ij = &(pbond_ij->bo_data); + BOA_ij = bo_ij->BO - control->thb_cut; + + + if (BOA_ij > 0.0) { + i = pbond_ij->nbr; + type_i = system->my_atoms[i].type; + + + /* first copy 3-body intrs from previously computed ones where i>k. + in the second for-loop below, + we compute only new 3-body intrs where i < k */ + for (pk = start_j; pk < pi; ++pk) { + start_pk = Start_Index(pk, thb_intrs); + end_pk = End_Index(pk, thb_intrs); + + for (t = start_pk; t < end_pk; ++t) + if (thb_intrs->select.three_body_list[t].thb == i) { + p_ijk = &(thb_intrs->select.three_body_list[my_offset]); + p_kji = &(thb_intrs->select.three_body_list[t]); + + p_ijk->thb = bonds->select.bond_list[pk].nbr; + p_ijk->pthb = pk; + p_ijk->theta = p_kji->theta; + rvec_Copy(p_ijk->dcos_di, p_kji->dcos_dk); + rvec_Copy(p_ijk->dcos_dj, p_kji->dcos_dj); + rvec_Copy(p_ijk->dcos_dk, p_kji->dcos_di); + + ++my_offset; + ++num_thb_intrs; + break; + } + } // for (pk) + + + /* and this is the second for loop mentioned above */ + for (pk = pi+1; pk < end_j; ++pk) { + pbond_jk = &(bonds->select.bond_list[pk]); + bo_jk = &(pbond_jk->bo_data); + BOA_jk = bo_jk->BO - control->thb_cut; + k = pbond_jk->nbr; + type_k = system->my_atoms[k].type; + p_ijk = &(thb_intrs->select.three_body_list[my_offset]); + + // Fix by Sudhir + // if (BOA_jk <= 0) continue; + if (j >= system->n && i >= system->n && k >= system->n) continue; + + Calculate_Theta(pbond_ij->dvec, pbond_ij->d, + pbond_jk->dvec, pbond_jk->d, + &theta, &cos_theta); + + Calculate_dCos_ThetaOMP(pbond_ij->dvec, pbond_ij->d, + pbond_jk->dvec, pbond_jk->d, + &(p_ijk->dcos_di), &(p_ijk->dcos_dj), + &(p_ijk->dcos_dk)); + p_ijk->thb = k; + p_ijk->pthb = pk; + p_ijk->theta = theta; + + sin_theta = sin(theta); + if (sin_theta < 1.0e-5) + sin_theta = 1.0e-5; + + ++my_offset; // add this to the list of 3-body interactions + ++num_thb_intrs; + + if ((j < system->n) && (BOA_jk > 0.0) && + (bo_ij->BO > control->thb_cut) && + (bo_jk->BO > control->thb_cut) && + (bo_ij->BO * bo_jk->BO > control->thb_cutsq)) { + thbh = &(system->reax_param.thbp[type_i][type_j][type_k]); + + for (cnt = 0; cnt < thbh->cnt; ++cnt) { + + if (fabs(thbh->prm[cnt].p_val1) > 0.001) { + thbp = &(thbh->prm[cnt]); + + /* ANGLE ENERGY */ + p_val1 = thbp->p_val1; + p_val2 = thbp->p_val2; + p_val4 = thbp->p_val4; + p_val7 = thbp->p_val7; + theta_00 = thbp->theta_00; + + exp3ij = exp(-p_val3 * pow(BOA_ij, p_val4)); + f7_ij = 1.0 - exp3ij; + Cf7ij = p_val3 * p_val4 * pow(BOA_ij, p_val4 - 1.0) * exp3ij; + + exp3jk = exp(-p_val3 * pow(BOA_jk, p_val4)); + f7_jk = 1.0 - exp3jk; + Cf7jk = p_val3 * p_val4 * pow(BOA_jk, p_val4 - 1.0) * exp3jk; + + expval7 = exp(-p_val7 * workspace->Delta_boc[j]); + trm8 = 1.0 + expval6 + expval7; + f8_Dj = p_val5 - ((p_val5 - 1.0) * (2.0 + expval6) / trm8); + Cf8j = ((1.0 - p_val5) / SQR(trm8)) * + (p_val6 * expval6 * trm8 - + (2.0 + expval6) * (p_val6*expval6 - p_val7*expval7)); + + theta_0 = 180.0 - theta_00 * (1.0 - + exp(-p_val10 * (2.0 - SBO2))); + theta_0 = DEG2RAD(theta_0); + + expval2theta = exp(-p_val2 * SQR(theta_0 - theta)); + if (p_val1 >= 0) + expval12theta = p_val1 * (1.0 - expval2theta); + else // To avoid linear Me-H-Me angles (6/6/06) + expval12theta = p_val1 * -expval2theta; + + CEval1 = Cf7ij * f7_jk * f8_Dj * expval12theta; + CEval2 = Cf7jk * f7_ij * f8_Dj * expval12theta; + CEval3 = Cf8j * f7_ij * f7_jk * expval12theta; + CEval4 = -2.0 * p_val1 * p_val2 * f7_ij * f7_jk * f8_Dj * + expval2theta * (theta_0 - theta); + + Ctheta_0 = p_val10 * DEG2RAD(theta_00) * + exp(-p_val10 * (2.0 - SBO2)); + + CEval5 = -CEval4 * Ctheta_0 * CSBO2; + CEval6 = CEval5 * dSBO1; + CEval7 = CEval5 * dSBO2; + CEval8 = -CEval4 / sin_theta; + + total_Eang += e_ang = + f7_ij * f7_jk * f8_Dj * expval12theta; + /* END ANGLE ENERGY*/ + + + /* PENALTY ENERGY */ + p_pen1 = thbp->p_pen1; + p_pen2 = system->reax_param.gp.l[19]; + p_pen3 = system->reax_param.gp.l[20]; + p_pen4 = system->reax_param.gp.l[21]; + + exp_pen2ij = exp(-p_pen2 * SQR(BOA_ij - 2.0)); + exp_pen2jk = exp(-p_pen2 * SQR(BOA_jk - 2.0)); + exp_pen3 = exp(-p_pen3 * workspace->Delta[j]); + exp_pen4 = exp(p_pen4 * workspace->Delta[j]); + trm_pen34 = 1.0 + exp_pen3 + exp_pen4; + f9_Dj = (2.0 + exp_pen3) / trm_pen34; + Cf9j = (-p_pen3 * exp_pen3 * trm_pen34 - + (2.0 + exp_pen3) * (-p_pen3 * exp_pen3 + + p_pen4 * exp_pen4)) / + SQR(trm_pen34); + + total_Epen += e_pen = + p_pen1 * f9_Dj * exp_pen2ij * exp_pen2jk; + + CEpen1 = e_pen * Cf9j / f9_Dj; + temp = -2.0 * p_pen2 * e_pen; + CEpen2 = temp * (BOA_ij - 2.0); + CEpen3 = temp * (BOA_jk - 2.0); + /* END PENALTY ENERGY */ + + + /* COALITION ENERGY */ + p_coa1 = thbp->p_coa1; + p_coa2 = system->reax_param.gp.l[2]; + p_coa3 = system->reax_param.gp.l[38]; + p_coa4 = system->reax_param.gp.l[30]; + + exp_coa2 = exp(p_coa2 * workspace->Delta_val[j]); + total_Ecoa += e_coa = + p_coa1 / (1. + exp_coa2) * + exp(-p_coa3 * SQR(workspace->total_bond_order[i]-BOA_ij)) * + exp(-p_coa3 * SQR(workspace->total_bond_order[k]-BOA_jk)) * + exp(-p_coa4 * SQR(BOA_ij - 1.5)) * + exp(-p_coa4 * SQR(BOA_jk - 1.5)); + + CEcoa1 = -2 * p_coa4 * (BOA_ij - 1.5) * e_coa; + CEcoa2 = -2 * p_coa4 * (BOA_jk - 1.5) * e_coa; + CEcoa3 = -p_coa2 * exp_coa2 * e_coa / (1 + exp_coa2); + CEcoa4 = -2 * p_coa3 * + (workspace->total_bond_order[i]-BOA_ij) * e_coa; + CEcoa5 = -2 * p_coa3 * + (workspace->total_bond_order[k]-BOA_jk) * e_coa; + /* END COALITION ENERGY */ + + + /* FORCES */ + bo_ij->Cdbo += (CEval1 + CEpen2 + (CEcoa1 - CEcoa4)); + bo_jk->Cdbo += (CEval2 + CEpen3 + (CEcoa2 - CEcoa5)); + workspace->CdDelta[j] += ((CEval3 + CEval7) + CEpen1 + CEcoa3); + workspace->CdDeltaReduction[reductionOffset+i] += CEcoa4; + workspace->CdDeltaReduction[reductionOffset+k] += CEcoa5; + + for (t = start_j; t < end_j; ++t) { + pbond_jt = &(bonds->select.bond_list[t]); + bo_jt = &(pbond_jt->bo_data); + temp_bo_jt = bo_jt->BO; + temp = CUBE(temp_bo_jt); + pBOjt7 = temp * temp * temp_bo_jt; + + bo_jt->Cdbo += (CEval6 * pBOjt7); + bo_jt->Cdbopi += CEval5; + bo_jt->Cdbopi2 += CEval5; + } + + rvec_ScaledAdd(workspace->f[j], CEval8, p_ijk->dcos_dj); + rvec_ScaledAdd(workspace->forceReduction[reductionOffset+i], CEval8, p_ijk->dcos_di); + rvec_ScaledAdd(workspace->forceReduction[reductionOffset+k], CEval8, p_ijk->dcos_dk); + + /* tally into per-atom virials */ + if (system->pair_ptr->evflag) { + + /* Acquire vectors */ + rvec_ScaledSum(delij, 1., system->my_atoms[i].x, + -1., system->my_atoms[j].x); + rvec_ScaledSum(delkj, 1., system->my_atoms[k].x, + -1., system->my_atoms[j].x); + + rvec_Scale(fi_tmp, -CEval8, p_ijk->dcos_di); + rvec_Scale(fj_tmp, -CEval8, p_ijk->dcos_dj); + rvec_Scale(fk_tmp, -CEval8, p_ijk->dcos_dk); + + eng_tmp = e_ang + e_pen + e_coa; + + if (system->pair_ptr->eflag_either) + pair_reax_ptr->ev_tally_thr_proxy( j, j, system->N, 1, + eng_tmp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); + if (system->pair_ptr->vflag_either) + pair_reax_ptr->v_tally3_thr_proxy(i, j, k, fi_tmp, fk_tmp, delij, delkj, thr); + } + + } // if (p_val1>0.001) + } // for (cnt) + } // if (j0) + } // for (pk) + } // if (BOA_ij>0) + + Set_End_Index(pi, my_offset, thb_intrs); + } // for (pi) + } // for (j) + } // end omp parallel + + data->my_en.e_ang = total_Eang; + data->my_en.e_pen = total_Epen; + data->my_en.e_coa = total_Ecoa; + + if (num_thb_intrs >= thb_intrs->num_intrs * DANGER_ZONE) { + workspace->realloc.num_3body = num_thb_intrs * TWICE; + if (num_thb_intrs > thb_intrs->num_intrs) + control->error_ptr->one(FLERR, fmt::format("step {}: ran out of space on " + "angle_list: top={}, max={}", + data->step, num_thb_intrs, + thb_intrs->num_intrs)); + } + } +} diff --git a/src/OPENMP/thr_omp.cpp b/src/OPENMP/thr_omp.cpp index 545e3bbe88..7f4bc95e8c 100644 --- a/src/OPENMP/thr_omp.cpp +++ b/src/OPENMP/thr_omp.cpp @@ -1499,6 +1499,28 @@ void ThrOMP::v_tally2_thr(Pair *const pair, const int i, const int j, const doub } } +/* ---------------------------------------------------------------------- + tally virial into per-atom accumulators + called by RexaFF potential, newton_pair is always on + fi is magnitude of force on atom i, deli is the direction + note that the other atom (j) is not updated, due to newton on +------------------------------------------------------------------------- */ + +void ThrOMP::v_tally2_newton_thr(Pair *const pair, const int i, const double * const fi, + const double * const deli, ThrData * const thr) +{ + double v[6]; + + v[0] = deli[0]*fi[0]; + v[1] = deli[1]*fi[1]; + v[2] = deli[2]*fi[2]; + v[3] = deli[0]*fi[1]; + v[4] = deli[0]*fi[2]; + v[5] = deli[1]*fi[2]; + if (pair->vflag_global) v_tally(thr->virial_pair,v); + if (pair->vflag_atom) v_tally(thr->vatom_pair[i],v); +} + /* ---------------------------------------------------------------------- tally virial into per-atom accumulators called by AIREBO and Tersoff potential, newton_pair is always on diff --git a/src/OPENMP/thr_omp.h b/src/OPENMP/thr_omp.h index 35cd43be5d..02fdbdf25b 100644 --- a/src/OPENMP/thr_omp.h +++ b/src/OPENMP/thr_omp.h @@ -135,8 +135,8 @@ class ThrOMP { void ev_tally_xyz_full_thr(Pair *const, const int, const double, const double, const double, const double, const double, const double, const double, const double, ThrData *const); - void v_tally2_thr(Pair *const, const int, const int, const double, const double *const, - ThrData *const); + void v_tally2_thr(Pair *const, const int, const int, const double, const double *const, ThrData *const); + void v_tally2_newton_thr(Pair *const, const int, const double *const, const double *const, ThrData *const); void ev_tally3_thr(Pair *const, const int, const int, const int, const double, const double, const double *const, const double *const, const double *const, const double *const, ThrData *const); diff --git a/src/Purge.list b/src/Purge.list index 3debc2ef6d..40bdc50d0d 100644 --- a/src/Purge.list +++ b/src/Purge.list @@ -51,6 +51,52 @@ lmpinstalledpkgs.h lmpgitversion.h mliap_model_python_couple.cpp mliap_model_python_couple.h +# renamed on 21 July 2021 +fix_qeq_reax_kokkos.cpp +fix_qeq_reax_kokkos.h +fix_reaxc_bonds_kokkos.cpp +fix_reaxc_bonds_kokkos.h +fix_reaxc_species_kokkos.cpp +fix_reaxc_species_kokkos.h +pair_reaxc_kokkos.cpp +pair_reaxc_kokkos.h +fix_qeq_reax_omp.cpp +fix_qeq_reax_omp.h +pair_reaxc_omp.cpp +pair_reaxc_omp.h +reaxc_bond_orders_omp.cpp +reaxc_bonds_omp.cpp +reaxc_forces_omp.cpp +reaxc_hydrogen_bonds_omp.cpp +reaxc_init_md_omp.cpp +reaxc_multi_body_omp.cpp +reaxc_nonbonded_omp.cpp +reaxc_torsion_angles_omp.cpp +reaxc_valence_angles_omp.cpp +fix_reaxc.cpp +fix_reaxc.h +fix_reaxc_bonds.cpp +fix_reaxc_bonds.h +fix_reaxc_species.cpp +fix_reaxc_species.h +pair_reaxc.cpp +pair_reaxc.h +reaxc_allocate.cpp +reaxc_bond_orders.cpp +reaxc_bonds.cpp +reaxc_control.cpp +reaxc_ffield.cpp +reaxc_forces.cpp +reaxc_hydrogen_bonds.cpp +reaxc_init_md.cpp +reaxc_list.cpp +reaxc_lookup.cpp +reaxc_multi_body.cpp +reaxc_nonbonded.cpp +reaxc_reset_tools.cpp +reaxc_tool_box.cpp +reaxc_torsion_angles.cpp +reaxc_valence_angles.cpp # moved to DPD-BASIC package on 1 July 2021 pair_dpd.cpp pair_dpd.h @@ -61,6 +107,42 @@ nstencil_half_bin_2d_newton_ssa.cpp nstencil_half_bin_2d_newton_ssa.h nstencil_half_bin_3d_newton_ssa.cpp nstencil_half_bin_3d_newton_ssa.h +# removed on 17 Apr 2021 +reaxc_allocate.h +reaxc_bond_orders.h +reaxc_bonds.h +reaxc_control.h +reaxc_defs.h +reaxc_ffield.h +reaxc_forces.h +reaxc_hydrogen_bonds.h +reaxc_init_md.h +reaxc_io_tools.h +reaxc_io_tools.cpp +reaxc_list.h +reaxc_lookup.h +reaxc_multi_body.h +reaxc_nonbonded.h +reaxc_reset_tools.h +reaxc_system_props.h +reaxc_system_props.cpp +reaxc_tool_box.h +reaxc_torsion_angles.h +reaxc_traj.h +reaxc_traj.cpp +reaxc_types.h +reaxc_valence_angles.h +reaxc_vector.h +reaxc_vector.cpp +reaxc_bond_orders_omp.h +reaxc_bonds_omp.h +reaxc_forces_omp.h +reaxc_hydrogen_bonds_omp.h +reaxc_init_md_omp.h +reaxc_multi_body_omp.h +reaxc_nonbonded_omp.h +reaxc_torsion_angles_omp.h +reaxc_valence_angles_omp.h # removed on 9 Sep 2020 mergesort.h # renamed on 8 May 2020 diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index 8f7baa23be..a0d012bb5b 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -25,16 +25,27 @@ #include "force.h" #include "memory.h" #include "neigh_list.h" +#include "pair.h" +#include "suffix.h" +#include "text_file_reader.h" #include "update.h" #include #include +#include using namespace LAMMPS_NS; using namespace FixConst; #define MAXLINE 1024 +class parser_error : public std::exception { + std::string message; +public: + parser_error(const std::string &mesg) { message = mesg; } + const char *what() const noexcept { return message.c_str(); } +}; + /* ---------------------------------------------------------------------- */ FixQEq::FixQEq(LAMMPS *lmp, int narg, char **arg) : @@ -46,10 +57,15 @@ FixQEq::FixQEq(LAMMPS *lmp, int narg, char **arg) : { if (narg < 8) error->all(FLERR,"Illegal fix qeq command"); + scalar_flag = 1; + extscalar = 0; + nevery = utils::inumeric(FLERR,arg[3],false,lmp); cutoff = utils::numeric(FLERR,arg[4],false,lmp); tolerance = utils::numeric(FLERR,arg[5],false,lmp); maxiter = utils::inumeric(FLERR,arg[6],false,lmp); + maxwarn = 1; + matvecs = 0; // check for sane arguments if ((nevery <= 0) || (cutoff <= 0.0) || (tolerance <= 0.0) || (maxiter <= 0)) @@ -105,17 +121,16 @@ FixQEq::FixQEq(LAMMPS *lmp, int narg, char **arg) : atom->add_callback(Atom::GROW); for (int i = 0; i < atom->nmax; i++) - for (int j = 0; j < nprev; ++j ) + for (int j = 0; j < nprev; ++j) s_hist[i][j] = t_hist[i][j] = atom->q[i]; if (strcmp(arg[7],"coul/streitz") == 0) { streitz_flag = 1; - } else if (strcmp(arg[7],"reax/c") == 0) { + } else if (utils::strmatch(arg[7],"^reax..")) { reax_flag = 1; } else { read_file(arg[7]); } - } /* ---------------------------------------------------------------------- */ @@ -185,21 +200,21 @@ void FixQEq::deallocate_storage() memory->destroy(s); memory->destroy(t); - memory->destroy( Hdia_inv ); - memory->destroy( b_s ); - memory->destroy( b_t ); + memory->destroy(Hdia_inv); + memory->destroy(b_s); + memory->destroy(b_t); - memory->destroy( p ); - memory->destroy( q ); - memory->destroy( r ); - memory->destroy( d ); + memory->destroy(p); + memory->destroy(q); + memory->destroy(r); + memory->destroy(d); - memory->destroy( chizj ); - memory->destroy( qf ); - memory->destroy( q1 ); - memory->destroy( q2 ); + memory->destroy(chizj); + memory->destroy(qf); + memory->destroy(q1); + memory->destroy(q2); - memory->destroy( qv ); + memory->destroy(qv); } /* ---------------------------------------------------------------------- */ @@ -225,7 +240,7 @@ void FixQEq::allocate_matrix() safezone = SAFE_ZONE; nlocal = atom->nlocal; - n_cap = MAX( (int)(nlocal * safezone), mincap ); + n_cap = MAX((int)(nlocal * safezone), mincap); nall = atom->nlocal + atom->nghost; // determine the total space for the H matrix @@ -239,7 +254,7 @@ void FixQEq::allocate_matrix() i = ilist[ii]; m += numneigh[i]; } - m_cap = MAX( (int)(m * safezone), mincap * MIN_NBRS ); + m_cap = MAX((int)(m * safezone), mincap * MIN_NBRS); H.n = n_cap; H.m = m_cap; @@ -253,10 +268,10 @@ void FixQEq::allocate_matrix() void FixQEq::deallocate_matrix() { - memory->destroy( H.firstnbr ); - memory->destroy( H.numnbrs ); - memory->destroy( H.jlist ); - memory->destroy( H.val ); + memory->destroy(H.firstnbr); + memory->destroy(H.numnbrs); + memory->destroy(H.jlist); + memory->destroy(H.val); } /* ---------------------------------------------------------------------- */ @@ -269,6 +284,13 @@ void FixQEq::reallocate_matrix() /* ---------------------------------------------------------------------- */ +double FixQEq::compute_scalar() +{ + return matvecs; +} + +/* ---------------------------------------------------------------------- */ + void FixQEq::init_list(int /*id*/, NeighList *ptr) { list = ptr; @@ -281,6 +303,12 @@ void FixQEq::setup_pre_force(int vflag) if (force->newton_pair == 0) error->all(FLERR,"QEQ with 'newton pair off' not supported"); + if (force->pair) { + if (force->pair->suffix_flag & (Suffix::INTEL|Suffix::GPU)) + error->all(FLERR,"QEQ is not compatiple with suffix version " + "of pair style"); + } + deallocate_storage(); allocate_storage(); @@ -338,7 +366,7 @@ void FixQEq::min_pre_force(int vflag) /* ---------------------------------------------------------------------- */ -int FixQEq::CG( double *b, double *x ) +int FixQEq::CG(double *b, double *x) { int loop, i, ii, inum, *ilist; double tmp, alfa, beta, b_norm; @@ -348,10 +376,10 @@ int FixQEq::CG( double *b, double *x ) ilist = list->ilist; pack_flag = 1; - sparse_matvec( &H, x, q ); - comm->reverse_comm_fix( this ); + sparse_matvec(&H, x, q); + comm->reverse_comm_fix(this); - vector_sum( r , 1., b, -1., q, inum ); + vector_sum(r , 1., b, -1., q, inum); for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; @@ -360,19 +388,19 @@ int FixQEq::CG( double *b, double *x ) else d[i] = 0.0; } - b_norm = parallel_norm( b, inum ); - sig_new = parallel_dot( r, d, inum); + b_norm = parallel_norm(b, inum); + sig_new = parallel_dot(r, d, inum); for (loop = 1; loop < maxiter && sqrt(sig_new)/b_norm > tolerance; ++loop) { comm->forward_comm_fix(this); - sparse_matvec( &H, d, q ); + sparse_matvec(&H, d, q); comm->reverse_comm_fix(this); - tmp = parallel_dot( d, q, inum); + tmp = parallel_dot(d, q, inum); alfa = sig_new / tmp; - vector_add( x, alfa, d, inum ); - vector_add( r, -alfa, q, inum ); + vector_add(x, alfa, d, inum); + vector_add(r, -alfa, q, inum); for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; @@ -381,13 +409,13 @@ int FixQEq::CG( double *b, double *x ) } sig_old = sig_new; - sig_new = parallel_dot( r, p, inum); + sig_new = parallel_dot(r, p, inum); beta = sig_new / sig_old; - vector_sum( d, 1., p, beta, d, inum ); + vector_sum(d, 1., p, beta, d, inum); } - if ((comm->me == 0) && (loop >= maxiter)) + if ((comm->me == 0) && maxwarn && (loop >= maxiter)) error->warning(FLERR,"Fix qeq CG convergence failed ({}) after {} " "iterations at step {}",sqrt(sig_new)/b_norm,loop, update->ntimestep); @@ -397,7 +425,7 @@ int FixQEq::CG( double *b, double *x ) /* ---------------------------------------------------------------------- */ -void FixQEq::sparse_matvec( sparse_matrix *A, double *x, double *b ) +void FixQEq::sparse_matvec(sparse_matrix *A, double *x, double *b) { int i, j, itr_j; @@ -406,7 +434,7 @@ void FixQEq::sparse_matvec( sparse_matrix *A, double *x, double *b ) for (i = 0; i < nlocal; ++i) { if (atom->mask[i] & groupbit) - b[i] = eta[ atom->type[i] ] * x[i]; + b[i] = eta[atom->type[i]] * x[i]; } for (i = nlocal; i < nall; ++i) { @@ -416,7 +444,7 @@ void FixQEq::sparse_matvec( sparse_matrix *A, double *x, double *b ) for (i = 0; i < nlocal; ++i) { if (atom->mask[i] & groupbit) { - for ( itr_j=A->firstnbr[i]; itr_jfirstnbr[i]+A->numnbrs[i]; itr_j++) { + for (itr_j=A->firstnbr[i]; itr_jfirstnbr[i]+A->numnbrs[i]; itr_j++) { j = A->jlist[itr_j]; b[i] += A->val[itr_j] * x[j]; b[j] += A->val[itr_j] * x[i]; @@ -438,8 +466,8 @@ void FixQEq::calculate_Q() inum = list->inum; ilist = list->ilist; - s_sum = parallel_vector_acc( s, inum ); - t_sum = parallel_vector_acc( t, inum); + s_sum = parallel_vector_acc(s, inum); + t_sum = parallel_vector_acc(t, inum); u = s_sum / t_sum; for (ii = 0; ii < inum; ++ii) { @@ -457,7 +485,7 @@ void FixQEq::calculate_Q() } pack_flag = 4; - comm->forward_comm_fix( this ); //Dist_vector( atom->q ); + comm->forward_comm_fix(this); //Dist_vector(atom->q); } /* ---------------------------------------------------------------------- */ @@ -488,11 +516,11 @@ void FixQEq::unpack_forward_comm(int n, int first, double *buf) if (pack_flag == 1) for (m = 0, i = first; m < n; m++, i++) d[i] = buf[m]; - else if ( pack_flag == 2) + else if (pack_flag == 2) for (m = 0, i = first; m < n; m++, i++) s[i] = buf[m]; - else if ( pack_flag == 3) + else if (pack_flag == 3) for (m = 0, i = first; m < n; m++, i++) t[i] = buf[m]; - else if ( pack_flag == 4) + else if (pack_flag == 4) for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; } @@ -577,7 +605,7 @@ int FixQEq::unpack_exchange(int n, double *buf) /* ---------------------------------------------------------------------- */ -double FixQEq::parallel_norm( double *v, int n ) +double FixQEq::parallel_norm(double *v, int n) { int i; double my_sum, norm_sqr; @@ -595,14 +623,14 @@ double FixQEq::parallel_norm( double *v, int n ) my_sum += v[i]*v[i]; } - MPI_Allreduce( &my_sum, &norm_sqr, 1, MPI_DOUBLE, MPI_SUM, world ); + MPI_Allreduce(&my_sum, &norm_sqr, 1, MPI_DOUBLE, MPI_SUM, world); - return sqrt( norm_sqr ); + return sqrt(norm_sqr); } /* ---------------------------------------------------------------------- */ -double FixQEq::parallel_dot( double *v1, double *v2, int n) +double FixQEq::parallel_dot(double *v1, double *v2, int n) { int i; double my_dot, res; @@ -620,14 +648,14 @@ double FixQEq::parallel_dot( double *v1, double *v2, int n) my_dot += v1[i] * v2[i]; } - MPI_Allreduce( &my_dot, &res, 1, MPI_DOUBLE, MPI_SUM, world ); + MPI_Allreduce(&my_dot, &res, 1, MPI_DOUBLE, MPI_SUM, world); return res; } /* ---------------------------------------------------------------------- */ -double FixQEq::parallel_vector_acc( double *v, int n ) +double FixQEq::parallel_vector_acc(double *v, int n) { int i; double my_acc, res; @@ -645,15 +673,15 @@ double FixQEq::parallel_vector_acc( double *v, int n ) my_acc += v[i]; } - MPI_Allreduce( &my_acc, &res, 1, MPI_DOUBLE, MPI_SUM, world ); + MPI_Allreduce(&my_acc, &res, 1, MPI_DOUBLE, MPI_SUM, world); return res; } /* ---------------------------------------------------------------------- */ -void FixQEq::vector_sum( double* dest, double c, double* v, - double d, double* y, int k ) +void FixQEq::vector_sum(double* dest, double c, double* v, + double d, double* y, int k) { int kk; int *ilist; @@ -669,7 +697,7 @@ void FixQEq::vector_sum( double* dest, double c, double* v, /* ---------------------------------------------------------------------- */ -void FixQEq::vector_add( double* dest, double c, double* v, int k ) +void FixQEq::vector_add(double* dest, double c, double* v, int k) { int kk; int *ilist; @@ -687,13 +715,7 @@ void FixQEq::vector_add( double* dest, double c, double* v, int k ) void FixQEq::read_file(char *file) { - int i; - int params_per_line = 6; - char **words = new char*[params_per_line+1]; - - int ntypes = atom->ntypes; - int *setflag = new int[ntypes+1]; - for (i=0; i <= ntypes; ++i) setflag[i] = 0; + const int ntypes = atom->ntypes; memory->create(chi,ntypes+1,"qeq:chi"); memory->create(eta,ntypes+1,"qeq:eta"); @@ -701,70 +723,66 @@ void FixQEq::read_file(char *file) memory->create(zeta,ntypes+1,"qeq:zeta"); memory->create(zcore,ntypes+1,"qeq:zcore"); - // open file on proc 0 - - FILE *fp; - if (comm->me == 0) { - fp = utils::open_potential(file,lmp,nullptr); - if (fp == nullptr) - error->one(FLERR,"Cannot open fix qeq parameter file {}: {}", - file,utils::getsyserror()); - } - // read each line out of file, skipping blank lines or leading '#' // store line of params if all 3 element tags are in element list - int n,nwords,eof,nlo,nhi; - char line[MAXLINE],*ptr; - - eof = 0; - - while (1) { - if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fp); - if (ptr == nullptr) { - eof = 1; - fclose(fp); - } else n = strlen(line) + 1; + if (comm->me == 0) { + int *setflag = new int[ntypes+1]; + for (int n=0; n <= ntypes; ++n) { + setflag[n] = 0; + chi[n] = eta[n] = gamma[n] = zeta[n] = zcore[n] = 0.0; } - MPI_Bcast(&eof,1,MPI_INT,0,world); - if (eof) break; - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - // strip comment, skip line if blank + try { + int nlo,nhi; + double val; - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = utils::count_words(line); - if (nwords == 0) continue; + FILE *fp = utils::open_potential(file,lmp,nullptr); + if (fp == nullptr) + throw parser_error(fmt::format("Cannot open fix qeq parameter file {}:" + " {}", file,utils::getsyserror())); + TextFileReader reader(fp, "qeq parameter"); - // must have 6 parameters per line. + while (1) { + auto values = reader.next_values(0); - if (nwords < 6) - error->all(FLERR,"Invalid fix qeq parameter file"); + if (values.count() == 0) continue; + if (values.count() < 6) + throw parser_error("Invalid qeq parameter file"); - // words = ptrs to first 6 words in line + auto word = values.next_string(); + utils::bounds(FLERR,word,1,ntypes,nlo,nhi,nullptr); + if ((nlo < 0) || (nhi < 0)) + throw parser_error("Invalid atom type range"); - for (n=0, words[n] = strtok(line," \t\n\r\f"); - n < 6; - words[++n] = strtok(nullptr," \t\n\r\f")); - - utils::bounds(FLERR,words[0],1,ntypes,nlo,nhi,error); - for (n=nlo; n <=nhi; ++n) { - chi[n] = utils::numeric(FLERR,words[1],false,lmp); - eta[n] = utils::numeric(FLERR,words[2],false,lmp); - gamma[n] = utils::numeric(FLERR,words[3],false,lmp); - zeta[n] = utils::numeric(FLERR,words[4],false,lmp); - zcore[n] = utils::numeric(FLERR,words[5],false,lmp); - setflag[n] = 1; + val = values.next_double(); + for (int n=nlo; n <= nhi; ++n) chi[n] = val; + val = values.next_double(); + for (int n=nlo; n <= nhi; ++n) eta[n] = val; + val = values.next_double(); + for (int n=nlo; n <= nhi; ++n) gamma[n] = val; + val = values.next_double(); + for (int n=nlo; n <= nhi; ++n) zeta[n] = val; + val = values.next_double(); + for (int n=nlo; n <= nhi; ++n) zcore[n] = val; + for (int n=nlo; n <= nhi; ++n) setflag[n] = 1; + } + } catch (EOFException &e) { + ; // catch and ignore to exit loop + } catch (std::exception &e) { + error->one(FLERR,e.what()); } + + for (int n=1; n <= ntypes; ++n) + if (setflag[n] == 0) + error->one(FLERR,fmt::format("Parameters for atom type {} missing in " + "qeq parameter file", n)); + delete[] setflag; } - // check if all types are set - for (n=1; n <= ntypes; ++n) - if (setflag[n] == 0) - error->all(FLERR,"Invalid fix qeq parameter file"); - - delete [] words; - delete [] setflag; + MPI_Bcast(chi,ntypes+1,MPI_DOUBLE,0,world); + MPI_Bcast(eta,ntypes+1,MPI_DOUBLE,0,world); + MPI_Bcast(gamma,ntypes+1,MPI_DOUBLE,0,world); + MPI_Bcast(zeta,ntypes+1,MPI_DOUBLE,0,world); + MPI_Bcast(zcore,ntypes+1,MPI_DOUBLE,0,world); } diff --git a/src/QEQ/fix_qeq.h b/src/QEQ/fix_qeq.h index add2c9996d..f2260cbf30 100644 --- a/src/QEQ/fix_qeq.h +++ b/src/QEQ/fix_qeq.h @@ -35,6 +35,8 @@ class FixQEq : public Fix { void pre_force_respa(int, int, int); void min_pre_force(int); + virtual double compute_scalar(); + // derived child classes must provide these functions virtual void init() = 0; @@ -65,6 +67,7 @@ class FixQEq : public Fix { double Tap[8]; // Taper function double tolerance; // tolerance for the norm of the rel residual in CG int maxiter; // maximum number of QEq iterations + int maxwarn; // print warning when max iterations was reached double cutoff, cutoff_sq; // neighbor cutoff double *chi, *eta, *gamma, *zeta, *zcore; // qeq parameters diff --git a/src/QEQ/fix_qeq_dynamic.cpp b/src/QEQ/fix_qeq_dynamic.cpp index 679739bb9c..b8fc08dc14 100644 --- a/src/QEQ/fix_qeq_dynamic.cpp +++ b/src/QEQ/fix_qeq_dynamic.cpp @@ -54,6 +54,12 @@ FixQEqDynamic::FixQEqDynamic(LAMMPS *lmp, int narg, char **arg) : if (iarg+2 > narg) error->all(FLERR,"Illegal fix qeq/dynamic command"); qstep = atof(arg[iarg+1]); iarg += 2; + } else if (strcmp(arg[iarg],"warn") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix qeq/dynamic command"); + if (strcmp(arg[iarg+1],"no") == 0) maxwarn = 0; + else if (strcmp(arg[iarg+1],"yes") == 0) maxwarn = 1; + else error->all(FLERR,"Illegal fix qeq/dynamic command"); + iarg += 2; } else error->all(FLERR,"Illegal fix qeq/dynamic command"); } } @@ -146,7 +152,7 @@ void FixQEqDynamic::pre_force(int /*vflag*/) MPI_Allreduce(&enegmax,&enegmaxall,1,MPI_DOUBLE,MPI_MAX,world); enegmax = enegmaxall; - if (enegchk <= tolerance && enegmax <= 100.0*tolerance) break; + if ((enegchk <= tolerance) && (enegmax <= 100.0*tolerance)) break; for (ii = 0; ii < inum; ii++) { i = ilist[ii]; @@ -154,8 +160,9 @@ void FixQEqDynamic::pre_force(int /*vflag*/) q1[i] += qf[i]*dtq2 - qdamp*q1[i]; } } + matvecs = iloop; - if ((comm->me == 0) && (iloop >= maxiter)) + if ((comm->me == 0) && maxwarn && (iloop >= maxiter)) error->warning(FLERR,"Charges did not converge at step {}: {}", update->ntimestep,enegchk); @@ -260,7 +267,7 @@ void FixQEqDynamic::unpack_forward_comm(int n, int first, double *buf) if (pack_flag == 1) for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; - else if ( pack_flag == 2) + else if (pack_flag == 2) for (m = 0, i = first; m < n; m++, i++) qf[i] = buf[m]; } diff --git a/src/QEQ/fix_qeq_fire.cpp b/src/QEQ/fix_qeq_fire.cpp index 1bc0ba32ea..eb206effc6 100644 --- a/src/QEQ/fix_qeq_fire.cpp +++ b/src/QEQ/fix_qeq_fire.cpp @@ -64,6 +64,12 @@ FixQEqFire::FixQEqFire(LAMMPS *lmp, int narg, char **arg) : if (iarg+2 > narg) error->all(FLERR,"Illegal fix qeq/fire command"); qstep = atof(arg[iarg+1]); iarg += 2; + } else if (strcmp(arg[iarg],"warn") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix qeq/fire command"); + if (strcmp(arg[iarg+1],"no") == 0) maxwarn = 0; + else if (strcmp(arg[iarg+1],"yes") == 0) maxwarn = 1; + else error->all(FLERR,"Illegal fix qeq/fire command"); + iarg += 2; } else error->all(FLERR,"Illegal fix qeq/fire command"); } } @@ -214,8 +220,9 @@ void FixQEqFire::pre_force(int /*vflag*/) if (enegchk < tolerance) break; } + matvecs = iloop; - if ((comm->me == 0) && (iloop >= maxiter)) + if ((comm->me == 0) && maxwarn && (iloop >= maxiter)) error->warning(FLERR,"Charges did not converge at step {}: {}", update->ntimestep,enegchk); @@ -320,7 +327,7 @@ void FixQEqFire::unpack_forward_comm(int n, int first, double *buf) if (pack_flag == 1) for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; - else if ( pack_flag == 2) + else if (pack_flag == 2) for (m = 0, i = first; m < n; m++, i++) qf[i] = buf[m]; } diff --git a/src/QEQ/fix_qeq_point.cpp b/src/QEQ/fix_qeq_point.cpp index f94eba1a77..6c22ab85cf 100644 --- a/src/QEQ/fix_qeq_point.cpp +++ b/src/QEQ/fix_qeq_point.cpp @@ -38,7 +38,15 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ FixQEqPoint::FixQEqPoint(LAMMPS *lmp, int narg, char **arg) : - FixQEq(lmp, narg, arg) {} + FixQEq(lmp, narg, arg) { + if (narg == 10) { + if (strcmp(arg[8],"warn") == 0) { + if (strcmp(arg[9],"no") == 0) maxwarn = 0; + else if (strcmp(arg[9],"yes") == 0) maxwarn = 1; + else error->all(FLERR,"Illegal fix qeq/point command"); + } else error->all(FLERR,"Illegal fix qeq/point command"); + } else if (narg > 8) error->all(FLERR,"Illegal fix qeq/point command"); +} /* ---------------------------------------------------------------------- */ @@ -80,6 +88,7 @@ void FixQEqPoint::pre_force(int /*vflag*/) init_matvec(); matvecs = CG(b_s, s); // CG on s - parallel matvecs += CG(b_t, t); // CG on t - parallel + matvecs /= 2; calculate_Q(); if (force->kspace) force->kspace->qsum_qsq(); @@ -100,18 +109,18 @@ void FixQEqPoint::init_matvec() for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) { - Hdia_inv[i] = 1. / eta[ atom->type[i] ]; - b_s[i] = -( chi[atom->type[i]] + chizj[i] ); + Hdia_inv[i] = 1. / eta[atom->type[i]]; + b_s[i] = -(chi[atom->type[i]] + chizj[i]); b_t[i] = -1.0; - t[i] = t_hist[i][2] + 3 * ( t_hist[i][0] - t_hist[i][1] ); + t[i] = t_hist[i][2] + 3 * (t_hist[i][0] - t_hist[i][1]); s[i] = 4*(s_hist[i][0]+s_hist[i][2])-(6*s_hist[i][1]+s_hist[i][3]); } } pack_flag = 2; - comm->forward_comm_fix(this); //Dist_vector( s ); + comm->forward_comm_fix(this); //Dist_vector(s); pack_flag = 3; - comm->forward_comm_fix(this); //Dist_vector( t ); + comm->forward_comm_fix(this); //Dist_vector(t); } /* ---------------------------------------------------------------------- */ diff --git a/src/QEQ/fix_qeq_shielded.cpp b/src/QEQ/fix_qeq_shielded.cpp index 355d0fb0d3..ff8c87ba4e 100644 --- a/src/QEQ/fix_qeq_shielded.cpp +++ b/src/QEQ/fix_qeq_shielded.cpp @@ -40,6 +40,13 @@ using namespace LAMMPS_NS; FixQEqShielded::FixQEqShielded(LAMMPS *lmp, int narg, char **arg) : FixQEq(lmp, narg, arg) { + if (narg == 10) { + if (strcmp(arg[8],"warn") == 0) { + if (strcmp(arg[9],"no") == 0) maxwarn = 0; + else if (strcmp(arg[9],"yes") == 0) maxwarn = 1; + else error->all(FLERR,"Illegal fix qeq/shielded command"); + } else error->all(FLERR,"Illegal fix qeq/shielded command"); + } else if (narg > 8) error->all(FLERR,"Illegal fix qeq/shielded command"); if (reax_flag) extract_reax(); } @@ -79,15 +86,14 @@ void FixQEqShielded::init() void FixQEqShielded::extract_reax() { - Pair *pair = force->pair_match("^reax/c",0); - if (pair == nullptr) error->all(FLERR,"No pair reax/c for fix qeq/shielded"); + Pair *pair = force->pair_match("^reax..",0); + if (pair == nullptr) error->all(FLERR,"No pair reaxff for fix qeq/shielded"); int tmp; chi = (double *) pair->extract("chi",tmp); eta = (double *) pair->extract("eta",tmp); gamma = (double *) pair->extract("gamma",tmp); if (chi == nullptr || eta == nullptr || gamma == nullptr) - error->all(FLERR, - "Fix qeq/slater could not extract params from pair reax/c"); + error->all(FLERR, "Fix qeq/shielded could not extract params from pair reaxff"); } @@ -101,7 +107,7 @@ void FixQEqShielded::init_shielding() int ntypes = atom->ntypes; for (i = 1; i <= ntypes; ++i) for (j = 1; j <= ntypes; ++j) - shld[i][j] = pow( gamma[i] * gamma[j], -1.5 ); + shld[i][j] = pow(gamma[i] * gamma[j], -1.5); if (fabs(swa) > 0.01 && comm->me == 0) error->warning(FLERR,"Fix qeq has non-zero lower Taper radius cutoff"); @@ -110,7 +116,7 @@ void FixQEqShielded::init_shielding() else if (swb < 5 && comm->me == 0) error->warning(FLERR,"Fix qeq has very low Taper radius cutoff"); - d7 = pow( swb - swa, 7 ); + d7 = pow(swb - swa, 7); swa2 = swa*swa; swa3 = swa2*swa; swb2 = swb*swb; @@ -119,12 +125,12 @@ void FixQEqShielded::init_shielding() Tap[7] = 20.0 / d7; Tap[6] = -70.0 * (swa + swb) / d7; Tap[5] = 84.0 * (swa2 + 3.0*swa*swb + swb2) / d7; - Tap[4] = -35.0 * (swa3 + 9.0*swa2*swb + 9.0*swa*swb2 + swb3 ) / d7; - Tap[3] = 140.0 * (swa3*swb + 3.0*swa2*swb2 + swa*swb3 ) / d7; + Tap[4] = -35.0 * (swa3 + 9.0*swa2*swb + 9.0*swa*swb2 + swb3) / d7; + Tap[3] = 140.0 * (swa3*swb + 3.0*swa2*swb2 + swa*swb3) / d7; Tap[2] =-210.0 * (swa3*swb2 + swa2*swb3) / d7; Tap[1] = 140.0 * swa3 * swb3 / d7; Tap[0] = (-35.0*swa3*swb2*swb2 + 21.0*swa2*swb3*swb2 - - 7.0*swa*swb3*swb3 + swb3*swb3*swb ) / d7; + 7.0*swa*swb3*swb3 + swb3*swb3*swb) / d7; } /* ---------------------------------------------------------------------- */ @@ -143,6 +149,7 @@ void FixQEqShielded::pre_force(int /*vflag*/) init_matvec(); matvecs = CG(b_s, s); // CG on s - parallel matvecs += CG(b_t, t); // CG on t - parallel + matvecs /= 2; calculate_Q(); if (force->kspace) force->kspace->qsum_qsq(); @@ -163,18 +170,18 @@ void FixQEqShielded::init_matvec() for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) { - Hdia_inv[i] = 1. / eta[ atom->type[i] ]; - b_s[i] = -( chi[atom->type[i]] + chizj[i] ); + Hdia_inv[i] = 1. / eta[atom->type[i]]; + b_s[i] = -(chi[atom->type[i]] + chizj[i]); b_t[i] = -1.0; - t[i] = t_hist[i][2] + 3 * ( t_hist[i][0] - t_hist[i][1] ); + t[i] = t_hist[i][2] + 3 * (t_hist[i][0] - t_hist[i][1]); s[i] = 4*(s_hist[i][0]+s_hist[i][2])-(6*s_hist[i][1]+s_hist[i][3]); } } pack_flag = 2; - comm->forward_comm_fix(this); //Dist_vector( s ); + comm->forward_comm_fix(this); //Dist_vector(s); pack_flag = 3; - comm->forward_comm_fix(this); //Dist_vector( t ); + comm->forward_comm_fix(this); //Dist_vector(t); } /* ---------------------------------------------------------------------- */ @@ -217,7 +224,7 @@ void FixQEqShielded::compute_H() if (r_sqr <= cutoff_sq) { H.jlist[m_fill] = j; r = sqrt(r_sqr); - H.val[m_fill] = 0.5 * calculate_H( r, shld[type[i]][type[j]] ); + H.val[m_fill] = 0.5 * calculate_H(r, shld[type[i]][type[j]]); m_fill++; } } @@ -232,7 +239,7 @@ void FixQEqShielded::compute_H() /* ---------------------------------------------------------------------- */ -double FixQEqShielded::calculate_H( double r, double gamma ) +double FixQEqShielded::calculate_H(double r, double gamma) { double Taper, denom; diff --git a/src/QEQ/fix_qeq_slater.cpp b/src/QEQ/fix_qeq_slater.cpp index 3426595c0d..4b4814d982 100644 --- a/src/QEQ/fix_qeq_slater.cpp +++ b/src/QEQ/fix_qeq_slater.cpp @@ -53,6 +53,12 @@ FixQEqSlater::FixQEqSlater(LAMMPS *lmp, int narg, char **arg) : if (iarg+2 > narg) error->all(FLERR,"Illegal fix qeq/slater command"); alpha = atof(arg[iarg+1]); iarg += 2; + } else if (strcmp(arg[iarg],"warn") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix qeq/slater command"); + if (strcmp(arg[iarg+1],"no") == 0) maxwarn = 0; + else if (strcmp(arg[iarg+1],"yes") == 0) maxwarn = 1; + else error->all(FLERR,"Illegal fix qeq/slater command"); + iarg += 2; } else error->all(FLERR,"Illegal fix qeq/slater command"); } @@ -121,6 +127,7 @@ void FixQEqSlater::pre_force(int /*vflag*/) init_matvec(); matvecs = CG(b_s, s); // CG on s - parallel matvecs += CG(b_t, t); // CG on t - parallel + matvecs /= 2; calculate_Q(); if (force->kspace) force->kspace->qsum_qsq(); @@ -141,18 +148,18 @@ void FixQEqSlater::init_matvec() for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) { - Hdia_inv[i] = 1. / eta[ atom->type[i] ]; - b_s[i] = -( chi[atom->type[i]] + chizj[i] ); + Hdia_inv[i] = 1. / eta[atom->type[i]]; + b_s[i] = -(chi[atom->type[i]] + chizj[i]); b_t[i] = -1.0; - t[i] = t_hist[i][2] + 3 * ( t_hist[i][0] - t_hist[i][1] ); + t[i] = t_hist[i][2] + 3 * (t_hist[i][0] - t_hist[i][1]); s[i] = 4*(s_hist[i][0]+s_hist[i][2])-(6*s_hist[i][1]+s_hist[i][3]); } } pack_flag = 2; - comm->forward_comm_fix(this); //Dist_vector( s ); + comm->forward_comm_fix(this); //Dist_vector(s); pack_flag = 3; - comm->forward_comm_fix(this); //Dist_vector( t ); + comm->forward_comm_fix(this); //Dist_vector(t); } /* ---------------------------------------------------------------------- */ @@ -340,7 +347,7 @@ double FixQEqSlater::calculate_H_wolf(double zei, double zej, double zj, /* ---------------------------------------------------------------------- */ -void FixQEqSlater::sparse_matvec( sparse_matrix *A, double *x, double *b ) +void FixQEqSlater::sparse_matvec(sparse_matrix *A, double *x, double *b) { int i, j, itr_j; @@ -362,7 +369,7 @@ void FixQEqSlater::sparse_matvec( sparse_matrix *A, double *x, double *b ) for (i = 0; i < nlocal; ++i) { if (atom->mask[i] & groupbit) { - for( itr_j=A->firstnbr[i]; itr_jfirstnbr[i]+A->numnbrs[i]; itr_j++) { + for(itr_j=A->firstnbr[i]; itr_jfirstnbr[i]+A->numnbrs[i]; itr_j++) { j = A->jlist[itr_j]; b[i] += A->val[itr_j] * x[j]; b[j] += A->val[itr_j] * x[i]; diff --git a/src/REAXFF/README b/src/REAXFF/README index 485a56785e..528b782932 100644 --- a/src/REAXFF/README +++ b/src/REAXFF/README @@ -4,16 +4,6 @@ represent the contributions of chemical bonding to the potential energy. It was originally developed by Adri van Duin and the Goddard group at CalTech. -The REAXFF version of ReaxFF (pair_style reax/c), implemented in -C, should give identical or very similar results to pair_style reax, -which is a ReaxFF implementation on top of a Fortran library, a -version of which library was originally authored by Adri van Duin. - -The reax/c version should be somewhat faster and more scalable, -particularly with respect to the charge equilibration calculation. It -should also be easier to build and use since there are no complicating -issues with Fortran memory allocation or linking to a Fortran library. - For technical details about this implementation of ReaxFF, see this paper: @@ -21,7 +11,7 @@ Parallel and Scalable Reactive Molecular Dynamics: Numerical Methods and Algorithmic Techniques, H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, Parallel Computing, in press (2011). -See the doc page for the pair_style reax/c command for details +See the doc page for the pair_style reaxff command for details of how to use it in LAMMPS. The person who created this package is Hasan Metin Aktulga (hmaktulga diff --git a/src/REAXFF/compute_spec_atom.cpp b/src/REAXFF/compute_spec_atom.cpp index 1381f2cf96..66886cd1e2 100644 --- a/src/REAXFF/compute_spec_atom.cpp +++ b/src/REAXFF/compute_spec_atom.cpp @@ -13,13 +13,15 @@ ------------------------------------------------------------------------- */ #include "compute_spec_atom.h" -#include + #include "atom.h" -#include "update.h" +#include "error.h" #include "force.h" #include "memory.h" -#include "error.h" -#include "pair_reaxc.h" +#include "pair_reaxff.h" +#include "update.h" + +#include using namespace LAMMPS_NS; @@ -30,15 +32,15 @@ enum{KEYWORD,COMPUTE,FIX,VARIABLE}; ComputeSpecAtom::ComputeSpecAtom(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg) { - if (narg < 4) error->all(FLERR,"Illegal compute reax/c/atom command"); + if (narg < 4) error->all(FLERR,"Illegal compute spec/atom command"); peratom_flag = 1; nvalues = narg - 3; if (nvalues == 1) size_peratom_cols = 0; else size_peratom_cols = nvalues; - // Initiate reaxc - reaxc = (PairReaxC *) force->pair_match("reax/c",0); + // get reference to ReaxFF pair style + reaxff = (PairReaxFF *) force->pair_match("^reax..",0); pack_choice = new FnPtrPack[nvalues]; @@ -64,7 +66,7 @@ ComputeSpecAtom::ComputeSpecAtom(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"vz") == 0) { pack_choice[i] = &ComputeSpecAtom::pack_vz; - // from pair_reaxc + // from pair_reaxff } else if (strcmp(arg[iarg],"abo01") == 0) { pack_choice[i] = &ComputeSpecAtom::pack_abo01; } else if (strcmp(arg[iarg],"abo02") == 0) { @@ -114,7 +116,7 @@ ComputeSpecAtom::ComputeSpecAtom(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"abo24") == 0) { pack_choice[i] = &ComputeSpecAtom::pack_abo24; - } else error->all(FLERR,"Invalid keyword in compute reax/c/atom command"); + } else error->all(FLERR,"Invalid keyword in compute spec/atom command"); } nmax = 0; @@ -310,7 +312,7 @@ void ComputeSpecAtom::pack_abo01(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][0]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][0]; else buf[n] = 0.0; n += nvalues; } @@ -324,7 +326,7 @@ void ComputeSpecAtom::pack_abo02(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][1]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][1]; else buf[n] = 0.0; n += nvalues; } @@ -338,7 +340,7 @@ void ComputeSpecAtom::pack_abo03(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][2]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][2]; else buf[n] = 0.0; n += nvalues; } @@ -352,7 +354,7 @@ void ComputeSpecAtom::pack_abo04(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][3]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][3]; else buf[n] = 0.0; n += nvalues; } @@ -366,7 +368,7 @@ void ComputeSpecAtom::pack_abo05(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][4]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][4]; else buf[n] = 0.0; n += nvalues; } @@ -380,7 +382,7 @@ void ComputeSpecAtom::pack_abo06(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][5]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][5]; else buf[n] = 0.0; n += nvalues; } @@ -394,7 +396,7 @@ void ComputeSpecAtom::pack_abo07(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][6]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][6]; else buf[n] = 0.0; n += nvalues; } @@ -408,7 +410,7 @@ void ComputeSpecAtom::pack_abo08(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][7]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][7]; else buf[n] = 0.0; n += nvalues; } @@ -422,7 +424,7 @@ void ComputeSpecAtom::pack_abo09(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][8]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][8]; else buf[n] = 0.0; n += nvalues; } @@ -436,7 +438,7 @@ void ComputeSpecAtom::pack_abo10(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][9]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][9]; else buf[n] = 0.0; n += nvalues; } @@ -450,7 +452,7 @@ void ComputeSpecAtom::pack_abo11(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][10]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][10]; else buf[n] = 0.0; n += nvalues; } @@ -464,7 +466,7 @@ void ComputeSpecAtom::pack_abo12(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][11]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][11]; else buf[n] = 0.0; n += nvalues; } @@ -478,7 +480,7 @@ void ComputeSpecAtom::pack_abo13(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][12]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][12]; else buf[n] = 0.0; n += nvalues; } @@ -492,7 +494,7 @@ void ComputeSpecAtom::pack_abo14(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][13]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][13]; else buf[n] = 0.0; n += nvalues; } @@ -506,7 +508,7 @@ void ComputeSpecAtom::pack_abo15(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][14]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][14]; else buf[n] = 0.0; n += nvalues; } @@ -520,7 +522,7 @@ void ComputeSpecAtom::pack_abo16(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][15]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][15]; else buf[n] = 0.0; n += nvalues; } @@ -534,7 +536,7 @@ void ComputeSpecAtom::pack_abo17(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][16]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][16]; else buf[n] = 0.0; n += nvalues; } @@ -548,7 +550,7 @@ void ComputeSpecAtom::pack_abo18(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][17]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][17]; else buf[n] = 0.0; n += nvalues; } @@ -562,7 +564,7 @@ void ComputeSpecAtom::pack_abo19(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][18]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][18]; else buf[n] = 0.0; n += nvalues; } @@ -576,7 +578,7 @@ void ComputeSpecAtom::pack_abo20(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][19]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][19]; else buf[n] = 0.0; n += nvalues; } @@ -590,7 +592,7 @@ void ComputeSpecAtom::pack_abo21(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][20]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][20]; else buf[n] = 0.0; n += nvalues; } @@ -604,7 +606,7 @@ void ComputeSpecAtom::pack_abo22(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][21]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][21]; else buf[n] = 0.0; n += nvalues; } @@ -618,7 +620,7 @@ void ComputeSpecAtom::pack_abo23(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][22]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][22]; else buf[n] = 0.0; n += nvalues; } @@ -632,7 +634,7 @@ void ComputeSpecAtom::pack_abo24(int n) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = reaxc->tmpbo[i][23]; + if (mask[i] & groupbit) buf[n] = reaxff->tmpbo[i][23]; else buf[n] = 0.0; n += nvalues; } diff --git a/src/REAXFF/compute_spec_atom.h b/src/REAXFF/compute_spec_atom.h index ce4ce5b1cc..61dd63e272 100644 --- a/src/REAXFF/compute_spec_atom.h +++ b/src/REAXFF/compute_spec_atom.h @@ -75,7 +75,7 @@ class ComputeSpecAtom : public Compute { void pack_abo23(int); void pack_abo24(int); - class PairReaxC *reaxc; + class PairReaxFF *reaxff; }; } diff --git a/src/REAXFF/fix_qeq_reax.cpp b/src/REAXFF/fix_qeq_reaxff.cpp similarity index 70% rename from src/REAXFF/fix_qeq_reax.cpp rename to src/REAXFF/fix_qeq_reaxff.cpp index e01c87a1e3..fd197a156a 100644 --- a/src/REAXFF/fix_qeq_reax.cpp +++ b/src/REAXFF/fix_qeq_reaxff.cpp @@ -19,7 +19,7 @@ Hybrid and sub-group capabilities: Ray Shan (Sandia) ------------------------------------------------------------------------- */ -#include "fix_qeq_reax.h" +#include "fix_qeq_reaxff.h" #include "atom.h" #include "citeme.h" @@ -32,25 +32,33 @@ #include "neigh_request.h" #include "neighbor.h" #include "pair.h" -#include "pair_reaxc.h" #include "respa.h" +#include "text_file_reader.h" +#include "tokenizer.h" #include "update.h" +#include "pair_reaxff.h" +#include "reaxff_api.h" + #include #include -#include "reaxc_defs.h" -#include "reaxc_types.h" - using namespace LAMMPS_NS; using namespace FixConst; +class parser_error : public std::exception { + std::string message; +public: + parser_error(const std::string &mesg) { message = mesg; } + const char *what() const noexcept { return message.c_str(); } +}; + #define EV_TO_KCAL_PER_MOL 14.4 #define SQR(x) ((x)*(x)) #define CUBE(x) ((x)*(x)*(x)) -static const char cite_fix_qeq_reax[] = - "fix qeq/reax command:\n\n" +static const char cite_fix_qeq_reaxff[] = + "fix qeq/reaxff command:\n\n" "@Article{Aktulga12,\n" " author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama},\n" " title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques},\n" @@ -62,13 +70,18 @@ static const char cite_fix_qeq_reax[] = /* ---------------------------------------------------------------------- */ -FixQEqReax::FixQEqReax(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), pertype_option(nullptr) +FixQEqReaxFF::FixQEqReaxFF(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg), matvecs(0), pertype_option(nullptr) { - if (narg<8 || narg>11) error->all(FLERR,"Illegal fix qeq/reax command"); + scalar_flag = 1; + extscalar = 0; + imax = 200; + maxwarn = 1; + + if ((narg < 8) || (narg > 12)) error->all(FLERR,"Illegal fix qeq/reaxff command"); nevery = utils::inumeric(FLERR,arg[3],false,lmp); - if (nevery <= 0) error->all(FLERR,"Illegal fix qeq/reax command"); + if (nevery <= 0) error->all(FLERR,"Illegal fix qeq/reaxff command"); swa = utils::numeric(FLERR,arg[4],false,lmp); swb = utils::numeric(FLERR,arg[5],false,lmp); @@ -77,18 +90,19 @@ FixQEqReax::FixQEqReax(LAMMPS *lmp, int narg, char **arg) : // dual CG support only available for OPENMP variant // check for compatibility is in Fix::post_constructor() + dual_enabled = 0; - imax = 200; int iarg = 8; while (iarg < narg) { if (strcmp(arg[iarg],"dual") == 0) dual_enabled = 1; + else if (strcmp(arg[iarg],"nowarn") == 0) maxwarn = 0; else if (strcmp(arg[iarg],"maxiter") == 0) { if (iarg+1 > narg-1) - error->all(FLERR,"Illegal fix qeq/reax command"); + error->all(FLERR,"Illegal fix qeq/reaxff command"); imax = utils::numeric(FLERR,arg[iarg+1],false,lmp); iarg++; - } else error->all(FLERR,"Illegal fix qeq/reax command"); + } else error->all(FLERR,"Illegal fix qeq/reaxff command"); iarg++; } shld = nullptr; @@ -108,12 +122,14 @@ FixQEqReax::FixQEqReax(LAMMPS *lmp, int narg, char **arg) : b_prm = nullptr; // CG + p = nullptr; q = nullptr; r = nullptr; d = nullptr; // H matrix + H.firstnbr = nullptr; H.numnbrs = nullptr; H.jlist = nullptr; @@ -121,14 +137,14 @@ FixQEqReax::FixQEqReax(LAMMPS *lmp, int narg, char **arg) : // dual CG support // Update comm sizes for this fix + if (dual_enabled) comm_forward = comm_reverse = 2; else comm_forward = comm_reverse = 1; // perform initial allocation of atom-based arrays // register with Atom class - reaxc = nullptr; - reaxc = (PairReaxC *) force->pair_match("^reax/c",0); + reaxff = (PairReaxFF *) force->pair_match("^reax..",0); s_hist = t_hist = nullptr; atom->add_callback(Atom::GROW); @@ -136,7 +152,7 @@ FixQEqReax::FixQEqReax(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ -FixQEqReax::~FixQEqReax() +FixQEqReaxFF::~FixQEqReaxFF() { if (copymode) return; @@ -163,9 +179,9 @@ FixQEqReax::~FixQEqReax() /* ---------------------------------------------------------------------- */ -void FixQEqReax::post_constructor() +void FixQEqReaxFF::post_constructor() { - if (lmp->citeme) lmp->citeme->add(cite_fix_qeq_reax); + if (lmp->citeme) lmp->citeme->add(cite_fix_qeq_reaxff); grow_arrays(atom->nmax); for (int i = 0; i < atom->nmax; i++) @@ -174,12 +190,12 @@ void FixQEqReax::post_constructor() pertype_parameters(pertype_option); if (dual_enabled) - error->all(FLERR,"Dual keyword only supported with fix qeq/reax/omp"); + error->all(FLERR,"Dual keyword only supported with fix qeq/reaxff/omp"); } /* ---------------------------------------------------------------------- */ -int FixQEqReax::setmask() +int FixQEqReaxFF::setmask() { int mask = 0; mask |= PRE_FORCE; @@ -190,60 +206,65 @@ int FixQEqReax::setmask() /* ---------------------------------------------------------------------- */ -void FixQEqReax::pertype_parameters(char *arg) +void FixQEqReaxFF::pertype_parameters(char *arg) { - if (strcmp(arg,"reax/c") == 0) { + // match either new keyword "reaxff" or old keyword "reax/c" + if (utils::strmatch(arg,"^reax..$")) { reaxflag = 1; - Pair *pair = force->pair_match("reax/c",0); - if (pair == nullptr) error->all(FLERR,"No pair reax/c for fix qeq/reax"); + Pair *pair = force->pair_match("^reax..",0); + if (!pair) error->all(FLERR,"No reaxff pair style for fix qeq/reaxff"); int tmp; chi = (double *) pair->extract("chi",tmp); eta = (double *) pair->extract("eta",tmp); gamma = (double *) pair->extract("gamma",tmp); if (chi == nullptr || eta == nullptr || gamma == nullptr) - error->all(FLERR, - "Fix qeq/reax could not extract params from pair reax/c"); + error->all(FLERR, "Fix qeq/reaxff could not extract params from pair reaxff"); return; } - int i,itype,ntypes,rv; - double v1,v2,v3; - FILE *pf; - reaxflag = 0; - ntypes = atom->ntypes; + const int ntypes = atom->ntypes; - memory->create(chi,ntypes+1,"qeq/reax:chi"); - memory->create(eta,ntypes+1,"qeq/reax:eta"); - memory->create(gamma,ntypes+1,"qeq/reax:gamma"); + memory->create(chi,ntypes+1,"qeq/reaxff:chi"); + memory->create(eta,ntypes+1,"qeq/reaxff:eta"); + memory->create(gamma,ntypes+1,"qeq/reaxff:gamma"); if (comm->me == 0) { - if ((pf = fopen(arg,"r")) == nullptr) - error->one(FLERR,"Fix qeq/reax parameter file could not be found"); + chi[0] = eta[0] = gamma[0] = 0.0; + try { + TextFileReader reader(arg,"qeq/reaxff parameter"); + reader.ignore_comments = false; + for (int i = 1; i <= ntypes; i++) { + const char *line = reader.next_line(); + if (!line) + throw parser_error("Invalid param file for fix qeq/reaxff"); + ValueTokenizer values(line); - for (i = 1; i <= ntypes && !feof(pf); i++) { - rv = fscanf(pf,"%d %lg %lg %lg",&itype,&v1,&v2,&v3); - if (rv != 4) - error->one(FLERR,"Fix qeq/reax: Incorrect format of param file"); - if (itype < 1 || itype > ntypes) - error->one(FLERR,"Fix qeq/reax: invalid atom type in param file"); - chi[itype] = v1; - eta[itype] = v2; - gamma[itype] = v3; + if (values.count() != 4) + throw parser_error("Fix qeq/reaxff: Incorrect format of param file"); + + int itype = values.next_int(); + if ((itype < 1) || (itype > ntypes)) + throw parser_error("Fix qeq/reaxff: invalid atom type in param file"); + + chi[itype] = values.next_double(); + eta[itype] = values.next_double(); + gamma[itype] = values.next_double(); + } + } catch (std::exception &e) { + error->one(FLERR,e.what()); } - if (i <= ntypes) error->one(FLERR,"Invalid param file for fix qeq/reax"); - fclose(pf); } - MPI_Bcast(&chi[1],ntypes,MPI_DOUBLE,0,world); - MPI_Bcast(&eta[1],ntypes,MPI_DOUBLE,0,world); - MPI_Bcast(&gamma[1],ntypes,MPI_DOUBLE,0,world); + MPI_Bcast(chi,ntypes+1,MPI_DOUBLE,0,world); + MPI_Bcast(eta,ntypes+1,MPI_DOUBLE,0,world); + MPI_Bcast(gamma,ntypes+1,MPI_DOUBLE,0,world); } /* ---------------------------------------------------------------------- */ -void FixQEqReax::allocate_storage() +void FixQEqReaxFF::allocate_storage() { nmax = atom->nmax; @@ -268,26 +289,26 @@ void FixQEqReax::allocate_storage() /* ---------------------------------------------------------------------- */ -void FixQEqReax::deallocate_storage() +void FixQEqReaxFF::deallocate_storage() { memory->destroy(s); memory->destroy(t); - memory->destroy( Hdia_inv ); - memory->destroy( b_s ); - memory->destroy( b_t ); - memory->destroy( b_prc ); - memory->destroy( b_prm ); + memory->destroy(Hdia_inv); + memory->destroy(b_s); + memory->destroy(b_t); + memory->destroy(b_prc); + memory->destroy(b_prm); - memory->destroy( p ); - memory->destroy( q ); - memory->destroy( r ); - memory->destroy( d ); + memory->destroy(p); + memory->destroy(q); + memory->destroy(r); + memory->destroy(d); } /* ---------------------------------------------------------------------- */ -void FixQEqReax::reallocate_storage() +void FixQEqReaxFF::reallocate_storage() { deallocate_storage(); allocate_storage(); @@ -296,7 +317,7 @@ void FixQEqReax::reallocate_storage() /* ---------------------------------------------------------------------- */ -void FixQEqReax::allocate_matrix() +void FixQEqReaxFF::allocate_matrix() { int i,ii,n,m; @@ -304,15 +325,15 @@ void FixQEqReax::allocate_matrix() double safezone; if (reaxflag) { - mincap = reaxc->system->mincap; - safezone = reaxc->system->safezone; + mincap = reaxff->api->system->mincap; + safezone = reaxff->api->system->safezone; } else { mincap = REAX_MIN_CAP; safezone = REAX_SAFE_ZONE; } n = atom->nlocal; - n_cap = MAX( (int)(n * safezone), mincap); + n_cap = MAX((int)(n * safezone), mincap); // determine the total space for the H matrix @@ -321,7 +342,7 @@ void FixQEqReax::allocate_matrix() i = ilist[ii]; m += numneigh[i]; } - m_cap = MAX( (int)(m * safezone), mincap * REAX_MIN_NBRS); + m_cap = MAX((int)(m * safezone), mincap * REAX_MIN_NBRS); H.n = n_cap; H.m = m_cap; @@ -333,17 +354,17 @@ void FixQEqReax::allocate_matrix() /* ---------------------------------------------------------------------- */ -void FixQEqReax::deallocate_matrix() +void FixQEqReaxFF::deallocate_matrix() { - memory->destroy( H.firstnbr ); - memory->destroy( H.numnbrs ); - memory->destroy( H.jlist ); - memory->destroy( H.val ); + memory->destroy(H.firstnbr); + memory->destroy(H.numnbrs); + memory->destroy(H.jlist); + memory->destroy(H.val); } /* ---------------------------------------------------------------------- */ -void FixQEqReax::reallocate_matrix() +void FixQEqReaxFF::reallocate_matrix() { deallocate_matrix(); allocate_matrix(); @@ -351,13 +372,13 @@ void FixQEqReax::reallocate_matrix() /* ---------------------------------------------------------------------- */ -void FixQEqReax::init() +void FixQEqReaxFF::init() { if (!atom->q_flag) - error->all(FLERR,"Fix qeq/reax requires atom attribute q"); + error->all(FLERR,"Fix qeq/reaxff requires atom attribute q"); - ngroup = group->count(igroup); - if (ngroup == 0) error->all(FLERR,"Fix qeq/reax group has no atoms"); + if (group->count(igroup) == 0) + error->all(FLERR,"Fix qeq/reaxff group has no atoms"); // need a half neighbor list w/ Newton off and ghost neighbors // built whenever re-neighboring occurs @@ -377,14 +398,21 @@ void FixQEqReax::init() /* ---------------------------------------------------------------------- */ -void FixQEqReax::init_list(int /*id*/, NeighList *ptr) +double FixQEqReaxFF::compute_scalar() +{ + return matvecs/2.0; +} + +/* ---------------------------------------------------------------------- */ + +void FixQEqReaxFF::init_list(int /*id*/, NeighList *ptr) { list = ptr; } /* ---------------------------------------------------------------------- */ -void FixQEqReax::init_shielding() +void FixQEqReaxFF::init_shielding() { int i,j; int ntypes; @@ -395,27 +423,27 @@ void FixQEqReax::init_shielding() for (i = 1; i <= ntypes; ++i) for (j = 1; j <= ntypes; ++j) - shld[i][j] = pow( gamma[i] * gamma[j], -1.5); + shld[i][j] = pow(gamma[i] * gamma[j], -1.5); } /* ---------------------------------------------------------------------- */ -void FixQEqReax::init_taper() +void FixQEqReaxFF::init_taper() { double d7, swa2, swa3, swb2, swb3; if (fabs(swa) > 0.01 && comm->me == 0) - error->warning(FLERR,"Fix qeq/reax has non-zero lower Taper radius cutoff"); + error->warning(FLERR,"Fix qeq/reaxff has non-zero lower Taper radius cutoff"); if (swb < 0) - error->all(FLERR, "Fix qeq/reax has negative upper Taper radius cutoff"); + error->all(FLERR, "Fix qeq/reaxff has negative upper Taper radius cutoff"); else if (swb < 5 && comm->me == 0) - error->warning(FLERR,"Fix qeq/reax has very low Taper radius cutoff"); + error->warning(FLERR,"Fix qeq/reaxff has very low Taper radius cutoff"); - d7 = pow( swb - swa, 7); - swa2 = SQR( swa); - swa3 = CUBE( swa); - swb2 = SQR( swb); - swb3 = CUBE( swb); + d7 = pow(swb - swa, 7); + swa2 = SQR(swa); + swa3 = CUBE(swa); + swb2 = SQR(swb); + swb3 = CUBE(swb); Tap[7] = 20.0 / d7; Tap[6] = -70.0 * (swa + swb) / d7; @@ -430,14 +458,14 @@ void FixQEqReax::init_taper() /* ---------------------------------------------------------------------- */ -void FixQEqReax::setup_pre_force(int vflag) +void FixQEqReaxFF::setup_pre_force(int vflag) { - if (reaxc) { - nn = reaxc->list->inum; - NN = reaxc->list->inum + reaxc->list->gnum; - ilist = reaxc->list->ilist; - numneigh = reaxc->list->numneigh; - firstneigh = reaxc->list->firstneigh; + if (reaxff) { + nn = reaxff->list->inum; + NN = reaxff->list->inum + reaxff->list->gnum; + ilist = reaxff->list->ilist; + numneigh = reaxff->list->numneigh; + firstneigh = reaxff->list->firstneigh; } else { nn = list->inum; NN = list->inum + list->gnum; @@ -459,7 +487,7 @@ void FixQEqReax::setup_pre_force(int vflag) /* ---------------------------------------------------------------------- */ -void FixQEqReax::setup_pre_force_respa(int vflag, int ilevel) +void FixQEqReaxFF::setup_pre_force_respa(int vflag, int ilevel) { if (ilevel < nlevels_respa-1) return; setup_pre_force(vflag); @@ -467,21 +495,21 @@ void FixQEqReax::setup_pre_force_respa(int vflag, int ilevel) /* ---------------------------------------------------------------------- */ -void FixQEqReax::min_setup_pre_force(int vflag) +void FixQEqReaxFF::min_setup_pre_force(int vflag) { setup_pre_force(vflag); } /* ---------------------------------------------------------------------- */ -void FixQEqReax::init_storage() +void FixQEqReaxFF::init_storage() { int NN; int *ilist; - if (reaxc) { - NN = reaxc->list->inum + reaxc->list->gnum; - ilist = reaxc->list->ilist; + if (reaxff) { + NN = reaxff->list->inum + reaxff->list->gnum; + ilist = reaxff->list->ilist; } else { NN = list->inum + list->gnum; ilist = list->ilist; @@ -502,21 +530,18 @@ void FixQEqReax::init_storage() /* ---------------------------------------------------------------------- */ -void FixQEqReax::pre_force(int /*vflag*/) +void FixQEqReaxFF::pre_force(int /*vflag*/) { - double t_start, t_end; - if (update->ntimestep % nevery) return; - if (comm->me == 0) t_start = MPI_Wtime(); int n = atom->nlocal; - if (reaxc) { - nn = reaxc->list->inum; - NN = reaxc->list->inum + reaxc->list->gnum; - ilist = reaxc->list->ilist; - numneigh = reaxc->list->numneigh; - firstneigh = reaxc->list->firstneigh; + if (reaxff) { + nn = reaxff->list->inum; + NN = reaxff->list->inum + reaxff->list->gnum; + ilist = reaxff->list->ilist; + numneigh = reaxff->list->numneigh; + firstneigh = reaxff->list->firstneigh; } else { nn = list->inum; NN = list->inum + list->gnum; @@ -539,30 +564,25 @@ void FixQEqReax::pre_force(int /*vflag*/) matvecs = matvecs_s + matvecs_t; calculate_Q(); - - if (comm->me == 0) { - t_end = MPI_Wtime(); - qeq_time = t_end - t_start; - } } /* ---------------------------------------------------------------------- */ -void FixQEqReax::pre_force_respa(int vflag, int ilevel, int /*iloop*/) +void FixQEqReaxFF::pre_force_respa(int vflag, int ilevel, int /*iloop*/) { if (ilevel == nlevels_respa-1) pre_force(vflag); } /* ---------------------------------------------------------------------- */ -void FixQEqReax::min_pre_force(int vflag) +void FixQEqReaxFF::min_pre_force(int vflag) { pre_force(vflag); } /* ---------------------------------------------------------------------- */ -void FixQEqReax::init_matvec() +void FixQEqReaxFF::init_matvec() { /* fill-in H matrix */ compute_H(); @@ -574,12 +594,12 @@ void FixQEqReax::init_matvec() if (atom->mask[i] & groupbit) { /* init pre-conditioner for H and init solution vectors */ - Hdia_inv[i] = 1. / eta[ atom->type[i] ]; - b_s[i] = -chi[ atom->type[i] ]; + Hdia_inv[i] = 1. / eta[atom->type[i]]; + b_s[i] = -chi[atom->type[i]]; b_t[i] = -1.0; /* quadratic extrapolation for s & t from previous solutions */ - t[i] = t_hist[i][2] + 3 * ( t_hist[i][0] - t_hist[i][1]); + t[i] = t_hist[i][2] + 3 * (t_hist[i][0] - t_hist[i][1]); /* cubic extrapolation for s & t from previous solutions */ s[i] = 4*(s_hist[i][0]+s_hist[i][2])-(6*s_hist[i][1]+s_hist[i][3]); @@ -587,14 +607,14 @@ void FixQEqReax::init_matvec() } pack_flag = 2; - comm->forward_comm_fix(this); //Dist_vector( s ); + comm->forward_comm_fix(this); //Dist_vector(s); pack_flag = 3; - comm->forward_comm_fix(this); //Dist_vector( t ); + comm->forward_comm_fix(this); //Dist_vector(t); } /* ---------------------------------------------------------------------- */ -void FixQEqReax::compute_H() +void FixQEqReaxFF::compute_H() { int jnum; int i, j, ii, jj, flag; @@ -641,7 +661,7 @@ void FixQEqReax::compute_H() if (flag) { H.jlist[m_fill] = j; - H.val[m_fill] = calculate_H( sqrt(r_sqr), shld[type[i]][type[j]]); + H.val[m_fill] = calculate_H(sqrt(r_sqr), shld[type[i]][type[j]]); m_fill++; } } @@ -649,18 +669,14 @@ void FixQEqReax::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/reax has insufficient QEq matrix size"); - } + if (m_fill >= H.m) + error->all(FLERR,fmt::format("Fix qeq/reaxff H matrix size has been " + "exceeded: m_fill={} H.m={}\n", m_fill, H.m)); } /* ---------------------------------------------------------------------- */ -double FixQEqReax::calculate_H( double r, double gamma) +double FixQEqReaxFF::calculate_H(double r, double gamma) { double Taper, denom; @@ -680,7 +696,7 @@ double FixQEqReax::calculate_H( double r, double gamma) /* ---------------------------------------------------------------------- */ -int FixQEqReax::CG( double *b, double *x) +int FixQEqReaxFF::CG(double *b, double *x) { int i, j; double tmp, alpha, beta, b_norm; @@ -689,10 +705,10 @@ int FixQEqReax::CG( double *b, double *x) int jj; pack_flag = 1; - sparse_matvec( &H, x, q); - comm->reverse_comm_fix(this); //Coll_Vector( q ); + sparse_matvec(&H, x, q); + comm->reverse_comm_fix(this); //Coll_Vector(q); - vector_sum( r , 1., b, -1., q, nn); + vector_sum(r , 1., b, -1., q, nn); for (jj = 0; jj < nn; ++jj) { j = ilist[jj]; @@ -700,19 +716,19 @@ int FixQEqReax::CG( double *b, double *x) d[j] = r[j] * Hdia_inv[j]; //pre-condition } - b_norm = parallel_norm( b, nn); - sig_new = parallel_dot( r, d, nn); + b_norm = parallel_norm(b, nn); + sig_new = parallel_dot(r, d, nn); for (i = 1; i < imax && sqrt(sig_new) / b_norm > tolerance; ++i) { - comm->forward_comm_fix(this); //Dist_vector( d ); - sparse_matvec( &H, d, q ); - comm->reverse_comm_fix(this); //Coll_vector( q ); + comm->forward_comm_fix(this); //Dist_vector(d); + sparse_matvec(&H, d, q); + comm->reverse_comm_fix(this); //Coll_vector(q); - tmp = parallel_dot( d, q, nn); + tmp = parallel_dot(d, q, nn); alpha = sig_new / tmp; - vector_add( x, alpha, d, nn ); - vector_add( r, -alpha, q, nn ); + vector_add(x, alpha, d, nn); + vector_add(r, -alpha, q, nn); // pre-conditioning for (jj = 0; jj < nn; ++jj) { @@ -722,26 +738,23 @@ int FixQEqReax::CG( double *b, double *x) } sig_old = sig_new; - sig_new = parallel_dot( r, p, nn); + sig_new = parallel_dot(r, p, nn); beta = sig_new / sig_old; - vector_sum( d, 1., p, beta, d, nn ); - } - - if (i >= imax && comm->me == 0) { - char str[128]; - sprintf(str,"Fix qeq/reax CG convergence failed after %d iterations " - "at " BIGINT_FORMAT " step",i,update->ntimestep); - error->warning(FLERR,str); + vector_sum(d, 1., p, beta, d, nn); } + if ((i >= imax) && maxwarn && (comm->me == 0)) + error->warning(FLERR,fmt::format("Fix qeq/reaxff CG convergence failed " + "after {} iterations at step {}", + i,update->ntimestep)); return i; } /* ---------------------------------------------------------------------- */ -void FixQEqReax::sparse_matvec( sparse_matrix *A, double *x, double *b) +void FixQEqReaxFF::sparse_matvec(sparse_matrix *A, double *x, double *b) { int i, j, itr_j; int ii; @@ -749,7 +762,7 @@ void FixQEqReax::sparse_matvec( sparse_matrix *A, double *x, double *b) for (ii = 0; ii < nn; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) - b[i] = eta[ atom->type[i] ] * x[i]; + b[i] = eta[atom->type[i]] * x[i]; } for (ii = nn; ii < NN; ++ii) { @@ -773,7 +786,7 @@ void FixQEqReax::sparse_matvec( sparse_matrix *A, double *x, double *b) /* ---------------------------------------------------------------------- */ -void FixQEqReax::calculate_Q() +void FixQEqReaxFF::calculate_Q() { int i, k; double u, s_sum, t_sum; @@ -781,8 +794,8 @@ void FixQEqReax::calculate_Q() int ii; - s_sum = parallel_vector_acc( s, nn); - t_sum = parallel_vector_acc( t, nn); + s_sum = parallel_vector_acc(s, nn); + t_sum = parallel_vector_acc(t, nn); u = s_sum / t_sum; for (ii = 0; ii < nn; ++ii) { @@ -801,12 +814,12 @@ void FixQEqReax::calculate_Q() } pack_flag = 4; - comm->forward_comm_fix(this); //Dist_vector( atom->q ); + comm->forward_comm_fix(this); //Dist_vector(atom->q); } /* ---------------------------------------------------------------------- */ -int FixQEqReax::pack_forward_comm(int n, int *list, double *buf, +int FixQEqReaxFF::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { int m; @@ -823,7 +836,7 @@ int FixQEqReax::pack_forward_comm(int n, int *list, double *buf, m = 0; for (int i = 0; i < n; i++) { int j = 2 * list[i]; - buf[m++] = d[j ]; + buf[m++] = d[j]; buf[m++] = d[j+1]; } return m; @@ -833,7 +846,7 @@ int FixQEqReax::pack_forward_comm(int n, int *list, double *buf, /* ---------------------------------------------------------------------- */ -void FixQEqReax::unpack_forward_comm(int n, int first, double *buf) +void FixQEqReaxFF::unpack_forward_comm(int n, int first, double *buf) { int i, m; @@ -850,7 +863,7 @@ void FixQEqReax::unpack_forward_comm(int n, int first, double *buf) m = 0; for (i = first; i < last; i++) { int j = 2 * i; - d[j ] = buf[m++]; + d[j] = buf[m++]; d[j+1] = buf[m++]; } } @@ -858,7 +871,7 @@ void FixQEqReax::unpack_forward_comm(int n, int first, double *buf) /* ---------------------------------------------------------------------- */ -int FixQEqReax::pack_reverse_comm(int n, int first, double *buf) +int FixQEqReaxFF::pack_reverse_comm(int n, int first, double *buf) { int i, m; if (pack_flag == 5) { @@ -866,7 +879,7 @@ int FixQEqReax::pack_reverse_comm(int n, int first, double *buf) int last = first + n; for (i = first; i < last; i++) { int indxI = 2 * i; - buf[m++] = q[indxI ]; + buf[m++] = q[indxI]; buf[m++] = q[indxI+1]; } return m; @@ -878,13 +891,13 @@ int FixQEqReax::pack_reverse_comm(int n, int first, double *buf) /* ---------------------------------------------------------------------- */ -void FixQEqReax::unpack_reverse_comm(int n, int *list, double *buf) +void FixQEqReaxFF::unpack_reverse_comm(int n, int *list, double *buf) { if (pack_flag == 5) { int m = 0; for (int i = 0; i < n; i++) { int indxI = 2 * list[i]; - q[indxI ] += buf[m++]; + q[indxI] += buf[m++]; q[indxI+1] += buf[m++]; } } else { @@ -896,7 +909,7 @@ void FixQEqReax::unpack_reverse_comm(int n, int *list, double *buf) memory usage of local atom-based arrays ------------------------------------------------------------------------- */ -double FixQEqReax::memory_usage() +double FixQEqReaxFF::memory_usage() { double bytes; @@ -916,7 +929,7 @@ double FixQEqReax::memory_usage() allocate fictitious charge arrays ------------------------------------------------------------------------- */ -void FixQEqReax::grow_arrays(int nmax) +void FixQEqReaxFF::grow_arrays(int nmax) { memory->grow(s_hist,nmax,nprev,"qeq:s_hist"); memory->grow(t_hist,nmax,nprev,"qeq:t_hist"); @@ -926,7 +939,7 @@ void FixQEqReax::grow_arrays(int nmax) copy values within fictitious charge arrays ------------------------------------------------------------------------- */ -void FixQEqReax::copy_arrays(int i, int j, int /*delflag*/) +void FixQEqReaxFF::copy_arrays(int i, int j, int /*delflag*/) { for (int m = 0; m < nprev; m++) { s_hist[j][m] = s_hist[i][m]; @@ -938,7 +951,7 @@ void FixQEqReax::copy_arrays(int i, int j, int /*delflag*/) pack values in local atom-based array for exchange with another proc ------------------------------------------------------------------------- */ -int FixQEqReax::pack_exchange(int i, double *buf) +int FixQEqReaxFF::pack_exchange(int i, double *buf) { for (int m = 0; m < nprev; m++) buf[m] = s_hist[i][m]; for (int m = 0; m < nprev; m++) buf[nprev+m] = t_hist[i][m]; @@ -949,7 +962,7 @@ int FixQEqReax::pack_exchange(int i, double *buf) unpack values in local atom-based array from exchange with another proc ------------------------------------------------------------------------- */ -int FixQEqReax::unpack_exchange(int nlocal, double *buf) +int FixQEqReaxFF::unpack_exchange(int nlocal, double *buf) { for (int m = 0; m < nprev; m++) s_hist[nlocal][m] = buf[m]; for (int m = 0; m < nprev; m++) t_hist[nlocal][m] = buf[nprev+m]; @@ -958,7 +971,7 @@ int FixQEqReax::unpack_exchange(int nlocal, double *buf) /* ---------------------------------------------------------------------- */ -double FixQEqReax::parallel_norm( double *v, int n) +double FixQEqReaxFF::parallel_norm(double *v, int n) { int i; double my_sum, norm_sqr; @@ -970,17 +983,17 @@ double FixQEqReax::parallel_norm( double *v, int n) for (ii = 0; ii < n; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) - my_sum += SQR( v[i]); + my_sum += SQR(v[i]); } - MPI_Allreduce( &my_sum, &norm_sqr, 1, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(&my_sum, &norm_sqr, 1, MPI_DOUBLE, MPI_SUM, world); - return sqrt( norm_sqr); + return sqrt(norm_sqr); } /* ---------------------------------------------------------------------- */ -double FixQEqReax::parallel_dot( double *v1, double *v2, int n) +double FixQEqReaxFF::parallel_dot(double *v1, double *v2, int n) { int i; double my_dot, res; @@ -995,14 +1008,14 @@ double FixQEqReax::parallel_dot( double *v1, double *v2, int n) my_dot += v1[i] * v2[i]; } - MPI_Allreduce( &my_dot, &res, 1, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(&my_dot, &res, 1, MPI_DOUBLE, MPI_SUM, world); return res; } /* ---------------------------------------------------------------------- */ -double FixQEqReax::parallel_vector_acc( double *v, int n) +double FixQEqReaxFF::parallel_vector_acc(double *v, int n) { int i; double my_acc, res; @@ -1017,14 +1030,14 @@ double FixQEqReax::parallel_vector_acc( double *v, int n) my_acc += v[i]; } - MPI_Allreduce( &my_acc, &res, 1, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(&my_acc, &res, 1, MPI_DOUBLE, MPI_SUM, world); return res; } /* ---------------------------------------------------------------------- */ -void FixQEqReax::vector_sum( double* dest, double c, double* v, +void FixQEqReaxFF::vector_sum(double* dest, double c, double* v, double d, double* y, int k) { int kk; @@ -1038,7 +1051,7 @@ void FixQEqReax::vector_sum( double* dest, double c, double* v, /* ---------------------------------------------------------------------- */ -void FixQEqReax::vector_add( double* dest, double c, double* v, int k) +void FixQEqReaxFF::vector_add(double* dest, double c, double* v, int k) { int kk; diff --git a/src/REAXFF/fix_qeq_reax.h b/src/REAXFF/fix_qeq_reaxff.h similarity index 87% rename from src/REAXFF/fix_qeq_reax.h rename to src/REAXFF/fix_qeq_reaxff.h index f87c7c6294..b787bb9c7a 100644 --- a/src/REAXFF/fix_qeq_reax.h +++ b/src/REAXFF/fix_qeq_reaxff.h @@ -24,21 +24,22 @@ #ifdef FIX_CLASS // clang-format off -FixStyle(qeq/reax,FixQEqReax); +FixStyle(qeq/reaxff,FixQEqReaxFF); +FixStyle(qeq/reax,FixQEqReaxFF); // clang-format on #else -#ifndef LMP_FIX_QEQ_REAX_H -#define LMP_FIX_QEQ_REAX_H +#ifndef LMP_FIX_QEQ_REAXFF_H +#define LMP_FIX_QEQ_REAXFF_H #include "fix.h" namespace LAMMPS_NS { -class FixQEqReax : public Fix { +class FixQEqReaxFF : public Fix { public: - FixQEqReax(class LAMMPS *, int, char **); - ~FixQEqReax(); + FixQEqReaxFF(class LAMMPS *, int, char **); + ~FixQEqReaxFF(); int setmask(); virtual void post_constructor(); virtual void init(); @@ -53,17 +54,17 @@ class FixQEqReax : public Fix { void min_setup_pre_force(int); void min_pre_force(int); - int matvecs; - double qeq_time; + virtual double compute_scalar(); protected: int nevery,reaxflag; + int matvecs; int nn, NN, m_fill; int n_cap, nmax, m_cap; int pack_flag; int nlevels_respa; class NeighList *list; - class PairReaxC *reaxc; + class PairReaxFF *reaxff; int *ilist, *jlist, *numneigh, **firstneigh; double swa, swb; // lower/upper Taper cutoff radius @@ -73,8 +74,6 @@ class FixQEqReax : public Fix { double *chi,*eta,*gamma; // qeq parameters double **shld; - bigint ngroup; - // fictitious charges double *s, *t; @@ -96,13 +95,7 @@ class FixQEqReax : public Fix { //CG storage double *p, *q, *r, *d; - int imax; - - //GMRES storage - //double *g,*y; - //double **v; - //double **h; - //double *hc, *hs; + int imax, maxwarn; char *pertype_option; // argument to determine how per-type info is obtained virtual void pertype_parameters(char*); @@ -122,7 +115,6 @@ class FixQEqReax : public Fix { virtual void calculate_Q(); virtual int CG(double*,double*); - //int GMRES(double*,double*); virtual void sparse_matvec(sparse_matrix*,double*,double*); virtual int pack_forward_comm(int, int *, double *, int, int *); @@ -135,9 +127,9 @@ class FixQEqReax : public Fix { virtual int pack_exchange(int, double *); virtual int unpack_exchange(int, double *); - virtual double parallel_norm( double*, int ); - virtual double parallel_dot( double*, double*, int ); - virtual double parallel_vector_acc( double*, int ); + virtual double parallel_norm(double*, int); + virtual double parallel_dot(double*, double*, int); + virtual double parallel_vector_acc(double*, int); virtual void vector_sum(double*,double,double*,double,double*,int); virtual void vector_add(double*, double, double*,int); diff --git a/src/REAXFF/fix_reaxc.cpp b/src/REAXFF/fix_reaxff.cpp similarity index 87% rename from src/REAXFF/fix_reaxc.cpp rename to src/REAXFF/fix_reaxff.cpp index 2b39ef5a0e..bd95dbcb38 100644 --- a/src/REAXFF/fix_reaxc.cpp +++ b/src/REAXFF/fix_reaxff.cpp @@ -22,7 +22,7 @@ Algorithmic Techniques", Parallel Computing, in press. ------------------------------------------------------------------------- */ -#include "fix_reaxc.h" +#include "fix_reaxff.h" #include "atom.h" #include "memory.h" @@ -35,7 +35,7 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ -FixReaxC::FixReaxC(LAMMPS *lmp,int narg, char **arg) : +FixReaxFF::FixReaxFF(LAMMPS *lmp,int narg, char **arg) : Fix(lmp, narg, arg) { // perform initial allocation of atom-based arrays @@ -57,7 +57,7 @@ FixReaxC::FixReaxC(LAMMPS *lmp,int narg, char **arg) : /* ---------------------------------------------------------------------- */ -FixReaxC::~FixReaxC() +FixReaxFF::~FixReaxFF() { // unregister this fix so atom class doesn't invoke it any more @@ -71,7 +71,7 @@ FixReaxC::~FixReaxC() /* ---------------------------------------------------------------------- */ -int FixReaxC::setmask() +int FixReaxFF::setmask() { int mask = 0; return mask; @@ -81,7 +81,7 @@ int FixReaxC::setmask() memory usage of local atom-based arrays ------------------------------------------------------------------------- */ -double FixReaxC::memory_usage() +double FixReaxFF::memory_usage() { int nmax = atom->nmax; double bytes = (double)nmax * 2 * sizeof(int); @@ -92,10 +92,10 @@ double FixReaxC::memory_usage() allocate local atom-based arrays ------------------------------------------------------------------------- */ -void FixReaxC::grow_arrays(int nmax) +void FixReaxFF::grow_arrays(int nmax) { - memory->grow(num_bonds,nmax,"reaxc:num_bonds"); - memory->grow(num_hbonds,nmax,"reaxc:num_hbonds"); + memory->grow(num_bonds,nmax,"reaxff:num_bonds"); + memory->grow(num_hbonds,nmax,"reaxff:num_hbonds"); for (int i = oldnmax; i < nmax; i++) { num_hbonds[i] = MIN_REAX_HBONDS; num_bonds[i] = MIN_REAX_BONDS; @@ -107,7 +107,7 @@ void FixReaxC::grow_arrays(int nmax) copy values within local atom-based arrays ------------------------------------------------------------------------- */ -void FixReaxC::copy_arrays(int i, int j, int /*delflag*/) +void FixReaxFF::copy_arrays(int i, int j, int /*delflag*/) { num_bonds[j] = num_bonds[i]; num_hbonds[j] = num_hbonds[i]; @@ -117,7 +117,7 @@ void FixReaxC::copy_arrays(int i, int j, int /*delflag*/) pack values in local atom-based arrays for exchange with another proc ------------------------------------------------------------------------- */ -int FixReaxC::pack_exchange(int i, double *buf) +int FixReaxFF::pack_exchange(int i, double *buf) { buf[0] = num_bonds[i]; buf[1] = num_hbonds[i]; @@ -128,7 +128,7 @@ int FixReaxC::pack_exchange(int i, double *buf) unpack values in local atom-based arrays from exchange with another proc ------------------------------------------------------------------------- */ -int FixReaxC::unpack_exchange(int nlocal, double *buf) +int FixReaxFF::unpack_exchange(int nlocal, double *buf) { num_bonds[nlocal] = static_cast (buf[0]); num_hbonds[nlocal] = static_cast (buf[1]); @@ -137,7 +137,7 @@ int FixReaxC::unpack_exchange(int nlocal, double *buf) /* ---------------------------------------------------------------------- */ -int FixReaxC::pack_forward_comm(int n, int *list, double *buf, +int FixReaxFF::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { int i,j,m; @@ -152,7 +152,7 @@ int FixReaxC::pack_forward_comm(int n, int *list, double *buf, /* ---------------------------------------------------------------------- */ -void FixReaxC::unpack_forward_comm(int n, int first, double *buf) +void FixReaxFF::unpack_forward_comm(int n, int first, double *buf) { int i,m,last; diff --git a/src/REAXFF/fix_reaxc.h b/src/REAXFF/fix_reaxff.h similarity index 89% rename from src/REAXFF/fix_reaxc.h rename to src/REAXFF/fix_reaxff.h index 6347f30c23..0b18f6d118 100644 --- a/src/REAXFF/fix_reaxc.h +++ b/src/REAXFF/fix_reaxff.h @@ -24,24 +24,24 @@ #ifdef FIX_CLASS // clang-format off -FixStyle(REAXC,FixReaxC); +FixStyle(REAXFF,FixReaxFF); // clang-format on #else -#ifndef LMP_FIX_REAXC_H -#define LMP_FIX_REAXC_H +#ifndef LMP_FIX_REAXFF_H +#define LMP_FIX_REAXFF_H #include "fix.h" namespace LAMMPS_NS { -class FixReaxC : public Fix { - friend class PairReaxC; - friend class PairReaxCOMP; +class FixReaxFF : public Fix { + friend class PairReaxFF; + friend class PairReaxFFOMP; public: - FixReaxC(class LAMMPS *,int, char **); - ~FixReaxC(); + FixReaxFF(class LAMMPS *,int, char **); + ~FixReaxFF(); int setmask(); double memory_usage(); diff --git a/src/REAXFF/fix_reaxc_bonds.cpp b/src/REAXFF/fix_reaxff_bonds.cpp similarity index 76% rename from src/REAXFF/fix_reaxc_bonds.cpp rename to src/REAXFF/fix_reaxff_bonds.cpp index 5fb095578c..f13056c5b6 100644 --- a/src/REAXFF/fix_reaxc_bonds.cpp +++ b/src/REAXFF/fix_reaxff_bonds.cpp @@ -16,29 +16,30 @@ Contributing author: Ray Shan (Sandia, tnshan@sandia.gov) ------------------------------------------------------------------------- */ -#include "fix_reaxc_bonds.h" +#include "fix_reaxff_bonds.h" -#include #include "atom.h" -#include "update.h" -#include "pair_reaxc.h" -#include "neigh_list.h" +#include "error.h" #include "force.h" #include "memory.h" -#include "error.h" -#include "reaxc_list.h" -#include "reaxc_types.h" -#include "reaxc_defs.h" +#include "neigh_list.h" +#include "update.h" + +#include "pair_reaxff.h" +#include "reaxff_api.h" + +#include using namespace LAMMPS_NS; using namespace FixConst; +using namespace ReaxFF; /* ---------------------------------------------------------------------- */ -FixReaxCBonds::FixReaxCBonds(LAMMPS *lmp, int narg, char **arg) : +FixReaxFFBonds::FixReaxFFBonds(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if (narg != 5) error->all(FLERR,"Illegal fix reax/c/bonds command"); + if (narg != 5) error->all(FLERR,"Illegal fix reaxff/bonds command"); MPI_Comm_rank(world,&me); MPI_Comm_size(world,&nprocs); @@ -47,34 +48,31 @@ FixReaxCBonds::FixReaxCBonds(LAMMPS *lmp, int narg, char **arg) : nevery = utils::inumeric(FLERR,arg[3],false,lmp); - if (nevery <= 0 ) - error->all(FLERR,"Illegal fix reax/c/bonds command"); + if (nevery <= 0) + error->all(FLERR,"Illegal fix reaxff/bonds command"); if (me == 0) { char *suffix = strrchr(arg[4],'.'); if (suffix && strcmp(suffix,".gz") == 0) { #ifdef LAMMPS_GZIP - char gzip[128]; - snprintf(gzip,128,"gzip -6 > %s",arg[4]); + auto gzip = fmt::format("gzip -6 > {}",arg[4]); #ifdef _WIN32 - fp = _popen(gzip,"wb"); + fp = _popen(gzip.c_str(),"wb"); #else - fp = popen(gzip,"w"); + fp = popen(gzip.c_str(),"w"); #endif #else error->one(FLERR,"Cannot open gzipped file"); #endif } else fp = fopen(arg[4],"w"); - if (fp == nullptr) { - char str[128]; - snprintf(str,128,"Cannot open fix reax/c/bonds file %s",arg[4]); - error->one(FLERR,str); - } + if (!fp) + error->one(FLERR,fmt::format("Cannot open fix reaxff/bonds file {}: " + "{}",arg[4],utils::getsyserror())); } if (atom->tag_consecutive() == 0) - error->all(FLERR,"Atom IDs must be consecutive for fix reax/c bonds"); + error->all(FLERR,"Atom IDs must be consecutive for fix reaxff bonds"); abo = nullptr; neighid = nullptr; @@ -85,7 +83,7 @@ FixReaxCBonds::FixReaxCBonds(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ -FixReaxCBonds::~FixReaxCBonds() +FixReaxFFBonds::~FixReaxFFBonds() { MPI_Comm_rank(world,&me); @@ -96,7 +94,7 @@ FixReaxCBonds::~FixReaxCBonds() /* ---------------------------------------------------------------------- */ -int FixReaxCBonds::setmask() +int FixReaxFFBonds::setmask() { int mask = 0; mask |= END_OF_STEP; @@ -105,32 +103,31 @@ int FixReaxCBonds::setmask() /* ---------------------------------------------------------------------- */ -void FixReaxCBonds::setup(int /*vflag*/) +void FixReaxFFBonds::setup(int /*vflag*/) { end_of_step(); } /* ---------------------------------------------------------------------- */ -void FixReaxCBonds::init() +void FixReaxFFBonds::init() { - reaxc = (PairReaxC *) force->pair_match("reax/c",0); - if (reaxc == nullptr) error->all(FLERR,"Cannot use fix reax/c/bonds without " - "pair_style reax/c, reax/c/kk, or reax/c/omp"); - + reaxff = (PairReaxFF *) force->pair_match("^reax..",0); + if (reaxff == nullptr) error->all(FLERR,"Cannot use fix reaxff/bonds without " + "pair_style reaxff, reaxff/kk, or reaxff/omp"); } /* ---------------------------------------------------------------------- */ -void FixReaxCBonds::end_of_step() +void FixReaxFFBonds::end_of_step() { - Output_ReaxC_Bonds(update->ntimestep,fp); + Output_ReaxFF_Bonds(); if (me == 0) fflush(fp); } /* ---------------------------------------------------------------------- */ -void FixReaxCBonds::Output_ReaxC_Bonds(bigint /*ntimestep*/, FILE * /*fp*/) +void FixReaxFFBonds::Output_ReaxFF_Bonds() { int i, j; @@ -154,16 +151,14 @@ void FixReaxCBonds::Output_ReaxC_Bonds(bigint /*ntimestep*/, FILE * /*fp*/) abo[i][j] = 0.0; } } - numbonds = 0; - - FindBond(lists, numbonds); + numbonds = FindBond(); // allocate a temporary buffer for the snapshot info MPI_Allreduce(&numbonds,&numbonds_max,1,MPI_INT,MPI_MAX,world); MPI_Allreduce(&nlocal,&nlocal_max,1,MPI_INT,MPI_MAX,world); nbuf = 1+(numbonds_max*2+10)*nlocal_max; - memory->create(buf,nbuf,"reax/c/bonds:buf"); + memory->create(buf,nbuf,"reaxff/bonds:buf"); for (i = 0; i < nbuf; i ++) buf[i] = 0.0; // Pass information to buffer @@ -178,26 +173,27 @@ void FixReaxCBonds::Output_ReaxC_Bonds(bigint /*ntimestep*/, FILE * /*fp*/) /* ---------------------------------------------------------------------- */ -void FixReaxCBonds::FindBond(struct _reax_list * /*lists*/, int &numbonds) +int FixReaxFFBonds::FindBond() { int *ilist, i, ii, inum; int j, pj, nj; tagint jtag; double bo_tmp,bo_cut; - inum = reaxc->list->inum; - ilist = reaxc->list->ilist; + inum = reaxff->list->inum; + ilist = reaxff->list->ilist; bond_data *bo_ij; - bo_cut = reaxc->control->bg_cut; + bo_cut = reaxff->api->control->bg_cut; tagint *tag = atom->tag; + int numbonds = 0; for (ii = 0; ii < inum; ii++) { i = ilist[ii]; nj = 0; - for (pj = Start_Index(i, reaxc->lists); pj < End_Index(i, reaxc->lists); ++pj) { - bo_ij = &( reaxc->lists->select.bond_list[pj] ); + for (pj = Start_Index(i, reaxff->api->lists); pj < End_Index(i, reaxff->api->lists); ++pj) { + bo_ij = &(reaxff->api->lists->select.bond_list[pj]); j = bo_ij->nbr; jtag = tag[j]; bo_tmp = bo_ij->bo_data.BO; @@ -211,11 +207,11 @@ void FixReaxCBonds::FindBond(struct _reax_list * /*lists*/, int &numbonds) numneigh[i] = nj; if (nj > numbonds) numbonds = nj; } - + return numbonds; } /* ---------------------------------------------------------------------- */ -void FixReaxCBonds::PassBuffer(double *buf, int &nbuf_local) +void FixReaxFFBonds::PassBuffer(double *buf, int &nbuf_local) { int i, j, k, numbonds; int nlocal = atom->nlocal; @@ -225,8 +221,8 @@ void FixReaxCBonds::PassBuffer(double *buf, int &nbuf_local) for (i = 0; i < nlocal; i++) { buf[j-1] = atom->tag[i]; buf[j+0] = atom->type[i]; - buf[j+1] = reaxc->workspace->total_bond_order[i]; - buf[j+2] = reaxc->workspace->nlp[i]; + buf[j+1] = reaxff->api->workspace->total_bond_order[i]; + buf[j+2] = reaxff->api->workspace->nlp[i]; buf[j+3] = atom->q[i]; buf[j+4] = numneigh[i]; numbonds = nint(buf[j+4]); @@ -236,7 +232,7 @@ void FixReaxCBonds::PassBuffer(double *buf, int &nbuf_local) } j += (5+numbonds); - if (atom->molecule == nullptr ) buf[j] = 0.0; + if (atom->molecule == nullptr) buf[j] = 0.0; else buf[j] = atom->molecule[i]; j ++; @@ -250,7 +246,7 @@ void FixReaxCBonds::PassBuffer(double *buf, int &nbuf_local) /* ---------------------------------------------------------------------- */ -void FixReaxCBonds::RecvBuffer(double *buf, int nbuf, int nbuf_local, +void FixReaxFFBonds::RecvBuffer(double *buf, int nbuf, int nbuf_local, int natoms, int maxnum) { int i, j, k, itype; @@ -260,7 +256,7 @@ void FixReaxCBonds::RecvBuffer(double *buf, int nbuf, int nbuf_local, bigint ntimestep = update->ntimestep; double sbotmp, nlptmp, avqtmp, abotmp; - double cutof3 = reaxc->control->bg_cut; + double cutof3 = reaxff->api->control->bg_cut; MPI_Request irequest, irequest2; if (me == 0) { @@ -322,7 +318,7 @@ void FixReaxCBonds::RecvBuffer(double *buf, int nbuf, int nbuf_local, /* ---------------------------------------------------------------------- */ -int FixReaxCBonds::nint(const double &r) +int FixReaxFFBonds::nint(const double &r) { int i = 0; if (r>0.0) i = static_cast(r+0.5); @@ -332,7 +328,7 @@ int FixReaxCBonds::nint(const double &r) /* ---------------------------------------------------------------------- */ -void FixReaxCBonds::destroy() +void FixReaxFFBonds::destroy() { memory->destroy(abo); memory->destroy(neighid); @@ -341,16 +337,16 @@ void FixReaxCBonds::destroy() /* ---------------------------------------------------------------------- */ -void FixReaxCBonds::allocate() +void FixReaxFFBonds::allocate() { - memory->create(abo,nmax,MAXREAXBOND,"reax/c/bonds:abo"); - memory->create(neighid,nmax,MAXREAXBOND,"reax/c/bonds:neighid"); - memory->create(numneigh,nmax,"reax/c/bonds:numneigh"); + memory->create(abo,nmax,MAXREAXBOND,"reaxff/bonds:abo"); + memory->create(neighid,nmax,MAXREAXBOND,"reaxff/bonds:neighid"); + memory->create(numneigh,nmax,"reaxff/bonds:numneigh"); } /* ---------------------------------------------------------------------- */ -double FixReaxCBonds::memory_usage() +double FixReaxFFBonds::memory_usage() { double bytes; diff --git a/src/REAXFF/fix_reaxc_bonds.h b/src/REAXFF/fix_reaxff_bonds.h similarity index 82% rename from src/REAXFF/fix_reaxc_bonds.h rename to src/REAXFF/fix_reaxff_bonds.h index fbca39fa95..ceb763b205 100644 --- a/src/REAXFF/fix_reaxc_bonds.h +++ b/src/REAXFF/fix_reaxff_bonds.h @@ -14,7 +14,8 @@ #ifdef FIX_CLASS // clang-format off -FixStyle(reax/c/bonds,FixReaxCBonds); +FixStyle(reaxff/bonds,FixReaxFFBonds); +FixStyle(reax/c/bonds,FixReaxFFBonds); // clang-format on #else @@ -25,10 +26,10 @@ FixStyle(reax/c/bonds,FixReaxCBonds); namespace LAMMPS_NS { -class FixReaxCBonds : public Fix { +class FixReaxFFBonds : public Fix { public: - FixReaxCBonds(class LAMMPS *, int, char **); - virtual ~FixReaxCBonds(); + FixReaxFFBonds(class LAMMPS *, int, char **); + virtual ~FixReaxFFBonds(); int setmask(); virtual void init(); void setup(int); @@ -43,8 +44,8 @@ class FixReaxCBonds : public Fix { void allocate(); void destroy(); - virtual void Output_ReaxC_Bonds(bigint, FILE *); - void FindBond(struct _reax_list*, int &); + virtual void Output_ReaxFF_Bonds(); + int FindBond(); void PassBuffer(double *, int &); void RecvBuffer(double *, int, int, int, int); int nint(const double &); @@ -52,7 +53,7 @@ class FixReaxCBonds : public Fix { bigint nvalid, nextvalid(); struct _reax_list *lists; - class PairReaxC *reaxc; + class PairReaxFF *reaxff; class NeighList *list; }; } diff --git a/src/REAXFF/fix_reaxc_species.cpp b/src/REAXFF/fix_reaxff_species.cpp similarity index 85% rename from src/REAXFF/fix_reaxc_species.cpp rename to src/REAXFF/fix_reaxff_species.cpp index be464f9a97..53746b968b 100644 --- a/src/REAXFF/fix_reaxc_species.cpp +++ b/src/REAXFF/fix_reaxff_species.cpp @@ -17,7 +17,7 @@ Oleg Sergeev (VNIIA, sergeev@vniia.ru) ------------------------------------------------------------------------- */ -#include "fix_reaxc_species.h" +#include "fix_reaxff_species.h" #include "atom.h" #include "comm.h" @@ -29,22 +29,22 @@ #include "modify.h" #include "neigh_list.h" #include "neighbor.h" -#include "pair_reaxc.h" #include "update.h" -#include +#include "pair_reaxff.h" +#include "reaxff_defs.h" -#include "reaxc_defs.h" +#include using namespace LAMMPS_NS; using namespace FixConst; /* ---------------------------------------------------------------------- */ -FixReaxCSpecies::FixReaxCSpecies(LAMMPS *lmp, int narg, char **arg) : +FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if (narg < 7) error->all(FLERR,"Illegal fix reax/c/species command"); + if (narg < 7) error->all(FLERR,"Illegal fix reaxff/species command"); force_reneighbor = 0; @@ -69,9 +69,9 @@ FixReaxCSpecies::FixReaxCSpecies(LAMMPS *lmp, int narg, char **arg) : comm_forward = 4; if (nevery <= 0 || nrepeat <= 0 || nfreq <= 0) - error->all(FLERR,"Illegal fix reax/c/species command"); + error->all(FLERR,"Illegal fix reaxff/species command"); if (nfreq % nevery || nrepeat*nevery > nfreq) - error->all(FLERR,"Illegal fix reax/c/species command"); + error->all(FLERR,"Illegal fix reaxff/species command"); // Neighbor lists must stay unchanged during averaging of bonds, // but may be updated when no averaging is performed. @@ -96,11 +96,11 @@ FixReaxCSpecies::FixReaxCSpecies(LAMMPS *lmp, int narg, char **arg) : } if (me == 0 && rene_flag) { - error->warning(FLERR,"Resetting reneighboring criteria for fix reax/c/species"); + error->warning(FLERR,"Resetting reneighboring criteria for fix reaxff/species"); } tmparg = nullptr; - memory->create(tmparg,4,4,"reax/c/species:tmparg"); + memory->create(tmparg,4,4,"reaxff/species:tmparg"); strcpy(tmparg[0],arg[3]); strcpy(tmparg[1],arg[4]); strcpy(tmparg[2],arg[5]); @@ -109,31 +109,28 @@ FixReaxCSpecies::FixReaxCSpecies(LAMMPS *lmp, int narg, char **arg) : char *suffix = strrchr(arg[6],'.'); if (suffix && strcmp(suffix,".gz") == 0) { #ifdef LAMMPS_GZIP - char gzip[128]; - sprintf(gzip,"gzip -6 > %s",arg[6]); + auto gzip = fmt::format("gzip -6 > {}",arg[6]); #ifdef _WIN32 - fp = _popen(gzip,"wb"); + fp = _popen(gzip.c_str(),"wb"); #else - fp = popen(gzip,"w"); + fp = popen(gzip.c_str(),"w"); #endif #else error->one(FLERR,"Cannot open gzipped file"); #endif } else fp = fopen(arg[6],"w"); - if (fp == nullptr) { - char str[128]; - snprintf(str,128,"Cannot open fix reax/c/species file %s",arg[6]); - error->one(FLERR,str); - } + if (!fp) + error->one(FLERR,fmt::format("Cannot open fix reaxff/species file {}: " + "{}",arg[6],utils::getsyserror())); } x0 = nullptr; clusterID = nullptr; int ntmp = 1; - memory->create(x0,ntmp,"reax/c/species:x0"); - memory->create(clusterID,ntmp,"reax/c/species:clusterID"); + memory->create(x0,ntmp,"reaxff/species:x0"); + memory->create(clusterID,ntmp,"reaxff/species:clusterID"); vector_atom = clusterID; BOCut = nullptr; @@ -152,7 +149,7 @@ FixReaxCSpecies::FixReaxCSpecies(LAMMPS *lmp, int narg, char **arg) : double bo_cut; bg_cut = 0.30; n = ntypes+1; - memory->create(BOCut,n,n,"reax/c/species:BOCut"); + memory->create(BOCut,n,n,"reaxff/species:BOCut"); for (i = 1; i < n; i ++) for (j = 1; j < n; j ++) BOCut[i][j] = bg_cut; @@ -171,16 +168,16 @@ FixReaxCSpecies::FixReaxCSpecies(LAMMPS *lmp, int narg, char **arg) : // set BO cutoff if (strcmp(arg[iarg],"cutoff") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix reax/c/species command"); + if (iarg+4 > narg) error->all(FLERR,"Illegal fix reaxff/species command"); itype = atoi(arg[iarg+1]); jtype = atoi(arg[iarg+2]); bo_cut = atof(arg[iarg+3]); if (itype > ntypes || jtype > ntypes) - error->all(FLERR,"Illegal fix reax/c/species command"); + error->all(FLERR,"Illegal fix reaxff/species command"); if (itype <= 0 || jtype <= 0) - error->all(FLERR,"Illegal fix reax/c/species command"); + error->all(FLERR,"Illegal fix reaxff/species command"); if (bo_cut > 1.0 || bo_cut < 0.0) - error->all(FLERR,"Illegal fix reax/c/species command"); + error->all(FLERR,"Illegal fix reaxff/species command"); BOCut[itype][jtype] = bo_cut; BOCut[jtype][itype] = bo_cut; @@ -188,7 +185,7 @@ FixReaxCSpecies::FixReaxCSpecies(LAMMPS *lmp, int narg, char **arg) : // modify element type names } else if (strcmp(arg[iarg],"element") == 0) { - if (iarg+ntypes+1 > narg) error->all(FLERR,"Illegal fix reax/c/species command"); + if (iarg+ntypes+1 > narg) error->all(FLERR,"Illegal fix reaxff/species command"); eletype = (char**) malloc(ntypes*sizeof(char*)); int len; @@ -202,11 +199,11 @@ FixReaxCSpecies::FixReaxCSpecies(LAMMPS *lmp, int narg, char **arg) : // position of molecules } else if (strcmp(arg[iarg],"position") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal fix reax/c/species command"); + if (iarg+3 > narg) error->all(FLERR,"Illegal fix reaxff/species command"); posflag = 1; posfreq = atoi(arg[iarg+1]); if (posfreq < nfreq || (posfreq%nfreq != 0)) - error->all(FLERR,"Illegal fix reax/c/species command"); + error->all(FLERR,"Illegal fix reaxff/species command"); filepos = new char[255]; strcpy(filepos,arg[iarg+2]); @@ -215,17 +212,17 @@ FixReaxCSpecies::FixReaxCSpecies(LAMMPS *lmp, int narg, char **arg) : } else { if (me == 0) { pos = fopen(filepos, "w"); - if (pos == nullptr) error->one(FLERR,"Cannot open fix reax/c/species position file"); + if (pos == nullptr) error->one(FLERR,"Cannot open fix reaxff/species position file"); } singlepos_opened = 1; multipos = 0; } iarg += 3; - } else error->all(FLERR,"Illegal fix reax/c/species command"); + } else error->all(FLERR,"Illegal fix reaxff/species command"); } if (!eleflag) { - memory->create(ele,ntypes+1,"reax/c/species:ele"); + memory->create(ele,ntypes+1,"reaxff/species:ele"); ele[0]='C'; if (ntypes > 1) ele[1]='H'; @@ -242,7 +239,7 @@ FixReaxCSpecies::FixReaxCSpecies(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ -FixReaxCSpecies::~FixReaxCSpecies() +FixReaxFFSpecies::~FixReaxFFSpecies() { memory->destroy(ele); memory->destroy(BOCut); @@ -268,7 +265,7 @@ FixReaxCSpecies::~FixReaxCSpecies() /* ---------------------------------------------------------------------- */ -int FixReaxCSpecies::setmask() +int FixReaxFFSpecies::setmask() { int mask = 0; mask |= POST_INTEGRATE; @@ -277,27 +274,27 @@ int FixReaxCSpecies::setmask() /* ---------------------------------------------------------------------- */ -void FixReaxCSpecies::setup(int /*vflag*/) +void FixReaxFFSpecies::setup(int /*vflag*/) { ntotal = static_cast (atom->natoms); if (Name == nullptr) - memory->create(Name,ntypes,"reax/c/species:Name"); + memory->create(Name,ntypes,"reaxff/species:Name"); post_integrate(); } /* ---------------------------------------------------------------------- */ -void FixReaxCSpecies::init() +void FixReaxFFSpecies::init() { if (atom->tag_enable == 0) - error->all(FLERR,"Cannot use fix reax/c/species unless atoms have IDs"); + error->all(FLERR,"Cannot use fix reaxff/species unless atoms have IDs"); - reaxc = (PairReaxC *) force->pair_match("reax/c",0); - if (reaxc == nullptr) error->all(FLERR,"Cannot use fix reax/c/species without " - "pair_style reax/c, reax/c/kk, or reax/c/omp"); + reaxff = (PairReaxFF *) force->pair_match("^reax..",0); + if (reaxff == nullptr) error->all(FLERR,"Cannot use fix reaxff/species without " + "pair_style reaxff, reaxff/kk, or reaxff/omp"); - reaxc->fixspecies_flag = 1; + reaxff->fixspecies_flag = 1; // reset next output timestep if not yet set or timestep has been reset if (nvalid != update->ntimestep) @@ -306,9 +303,9 @@ void FixReaxCSpecies::init() // check if this fix has been called twice int count = 0; for (int i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style,"reax/c/species") == 0) count++; + if (strcmp(modify->fix[i]->style,"reaxff/species") == 0) count++; if (count > 1 && comm->me == 0) - error->warning(FLERR,"More than one fix reax/c/species"); + error->warning(FLERR,"More than one fix reaxff/species"); if (!setupflag) { // create a compute to store properties @@ -324,7 +321,7 @@ void FixReaxCSpecies::init() /* ---------------------------------------------------------------------- */ -void FixReaxCSpecies::create_compute() +void FixReaxFFSpecies::create_compute() { int narg; char **args; @@ -371,7 +368,7 @@ void FixReaxCSpecies::create_compute() /* ---------------------------------------------------------------------- */ -void FixReaxCSpecies::create_fix() +void FixReaxFFSpecies::create_fix() { int narg; char **args; @@ -423,22 +420,22 @@ void FixReaxCSpecies::create_fix() /* ---------------------------------------------------------------------- */ -void FixReaxCSpecies::init_list(int /*id*/, NeighList *ptr) +void FixReaxFFSpecies::init_list(int /*id*/, NeighList *ptr) { list = ptr; } /* ---------------------------------------------------------------------- */ -void FixReaxCSpecies::post_integrate() +void FixReaxFFSpecies::post_integrate() { - Output_ReaxC_Bonds(update->ntimestep,fp); + Output_ReaxFF_Bonds(update->ntimestep,fp); if (me == 0) fflush(fp); } /* ---------------------------------------------------------------------- */ -void FixReaxCSpecies::Output_ReaxC_Bonds(bigint ntimestep, FILE * /*fp*/) +void FixReaxFFSpecies::Output_ReaxFF_Bonds(bigint ntimestep, FILE * /*fp*/) { int Nmole, Nspec; @@ -454,8 +451,8 @@ void FixReaxCSpecies::Output_ReaxC_Bonds(bigint ntimestep, FILE * /*fp*/) nmax = atom->nmax; memory->destroy(x0); memory->destroy(clusterID); - memory->create(x0,nmax,"reax/c/species:x0"); - memory->create(clusterID,nmax,"reax/c/species:clusterID"); + memory->create(x0,nmax,"reaxff/species:x0"); + memory->create(clusterID,nmax,"reaxff/species:clusterID"); vector_atom = clusterID; } @@ -487,7 +484,7 @@ void FixReaxCSpecies::Output_ReaxC_Bonds(bigint ntimestep, FILE * /*fp*/) /* ---------------------------------------------------------------------- */ -AtomCoord FixReaxCSpecies::chAnchor(AtomCoord in1, AtomCoord in2) +AtomCoord FixReaxFFSpecies::chAnchor(AtomCoord in1, AtomCoord in2) { if (in1.x < in2.x) return in1; @@ -504,7 +501,7 @@ AtomCoord FixReaxCSpecies::chAnchor(AtomCoord in1, AtomCoord in2) /* ---------------------------------------------------------------------- */ -void FixReaxCSpecies::FindMolecule () +void FixReaxFFSpecies::FindMolecule () { int i,j,ii,jj,inum,itype,jtype,loop,looptot; int change,done,anychange; @@ -513,8 +510,8 @@ void FixReaxCSpecies::FindMolecule () double bo_tmp,bo_cut; double **spec_atom = f_SPECBOND->array_atom; - inum = reaxc->list->inum; - ilist = reaxc->list->ilist; + inum = reaxff->list->inum; + ilist = reaxff->list->ilist; for (ii = 0; ii < inum; ii++) { i = ilist[ii]; @@ -543,7 +540,7 @@ void FixReaxCSpecies::FindMolecule () itype = atom->type[i]; for (jj = 0; jj < MAXSPECBOND; jj++) { - j = reaxc->tmpid[i][jj]; + j = reaxff->tmpid[i][jj]; if ((j == 0) || (j < i)) continue; if (!(mask[j] & groupbit)) continue; @@ -578,7 +575,7 @@ void FixReaxCSpecies::FindMolecule () /* ---------------------------------------------------------------------- */ -void FixReaxCSpecies::SortMolecule(int &Nmole) +void FixReaxFFSpecies::SortMolecule(int &Nmole) { memory->destroy(molmap); molmap = nullptr; @@ -598,16 +595,16 @@ void FixReaxCSpecies::SortMolecule(int &Nmole) MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); if (flagall && me == 0) error->warning(FLERR,"Atom with cluster ID = 0 included in " - "fix reax/c/species group"); + "fix reaxff/species group"); MPI_Allreduce(&lo,&idlo,1,MPI_INT,MPI_MIN,world); MPI_Allreduce(&hi,&idhi,1,MPI_INT,MPI_MAX,world); if (idlo == ntotal) if (me == 0) error->warning(FLERR,"Atom with cluster ID = maxmol " - "included in fix reax/c/species group"); + "included in fix reaxff/species group"); int nlen = idhi - idlo + 1; - memory->create(molmap,nlen,"reax/c/species:molmap"); + memory->create(molmap,nlen,"reaxff/species:molmap"); for (n = 0; n < nlen; n++) molmap[n] = 0; for (n = 0; n < nlocal; n++) { @@ -616,7 +613,7 @@ void FixReaxCSpecies::SortMolecule(int &Nmole) } int *molmapall; - memory->create(molmapall,nlen,"reax/c/species:molmapall"); + memory->create(molmapall,nlen,"reaxff/species:molmapall"); MPI_Allreduce(molmap,molmapall,nlen,MPI_INT,MPI_MAX,world); Nmole = 0; @@ -649,7 +646,7 @@ void FixReaxCSpecies::SortMolecule(int &Nmole) /* ---------------------------------------------------------------------- */ -void FixReaxCSpecies::FindSpecies(int Nmole, int &Nspec) +void FixReaxFFSpecies::FindSpecies(int Nmole, int &Nspec) { int k, l, m, n, itype, cid; int flag_identity, flag_mol, flag_spec; @@ -659,16 +656,16 @@ void FixReaxCSpecies::FindSpecies(int Nmole, int &Nspec) memory->destroy(MolName); MolName = nullptr; - memory->create(MolName,Nmole*(ntypes+1),"reax/c/species:MolName"); + memory->create(MolName,Nmole*(ntypes+1),"reaxff/species:MolName"); memory->destroy(NMol); NMol = nullptr; - memory->create(NMol,Nmole,"reax/c/species:NMol"); + memory->create(NMol,Nmole,"reaxff/species:NMol"); for (m = 0; m < Nmole; m ++) NMol[m] = 1; - memory->create(Nameall,ntypes,"reax/c/species:Nameall"); - memory->create(NMolall,Nmole,"reax/c/species:NMolall"); + memory->create(Nameall,ntypes,"reaxff/species:Nameall"); + memory->create(NMolall,Nmole,"reaxff/species:NMolall"); for (m = 1, Nspec = 0; m <= Nmole; m ++) { for (n = 0; n < ntypes; n ++) Name[n] = 0; @@ -708,16 +705,16 @@ void FixReaxCSpecies::FindSpecies(int Nmole, int &Nspec) memory->destroy(nd); nd = nullptr; - memory->create(nd,Nspec,"reax/c/species:nd"); + memory->create(nd,Nspec,"reaxff/species:nd"); memory->destroy(MolType); MolType = nullptr; - memory->create(MolType,Nspec*(ntypes+2),"reax/c/species:MolType"); + memory->create(MolType,Nspec*(ntypes+2),"reaxff/species:MolType"); } /* ---------------------------------------------------------------------- */ -int FixReaxCSpecies::CheckExistence(int id, int ntypes) +int FixReaxFFSpecies::CheckExistence(int id, int ntypes) { int i, j, molid, flag; @@ -738,7 +735,7 @@ int FixReaxCSpecies::CheckExistence(int id, int ntypes) /* ---------------------------------------------------------------------- */ -void FixReaxCSpecies::WriteFormulas(int Nmole, int Nspec) +void FixReaxFFSpecies::WriteFormulas(int Nmole, int Nspec) { int i, j, itemp; bigint ntimestep = update->ntimestep; @@ -774,7 +771,7 @@ void FixReaxCSpecies::WriteFormulas(int Nmole, int Nspec) /* ---------------------------------------------------------------------- */ -void FixReaxCSpecies::OpenPos() +void FixReaxFFSpecies::OpenPos() { char *filecurrent; bigint ntimestep = update->ntimestep; @@ -795,7 +792,7 @@ void FixReaxCSpecies::OpenPos() if (me == 0) { pos = fopen(filecurrent, "w"); - if (pos == nullptr) error->one(FLERR,"Cannot open fix reax/c/species position file"); + if (pos == nullptr) error->one(FLERR,"Cannot open fix reaxff/species position file"); } else pos = nullptr; multipos_opened = 1; @@ -804,7 +801,7 @@ void FixReaxCSpecies::OpenPos() /* ---------------------------------------------------------------------- */ -void FixReaxCSpecies::WritePos(int Nmole, int Nspec) +void FixReaxFFSpecies::WritePos(int Nmole, int Nspec) { int i, itype, cid; int count, count_tmp, m, n, k; @@ -834,7 +831,7 @@ void FixReaxCSpecies::WritePos(int Nmole, int Nspec) } Nameall = nullptr; - memory->create(Nameall,ntypes,"reax/c/species:Nameall"); + memory->create(Nameall,ntypes,"reaxff/species:Nameall"); for (m = 1; m <= Nmole; m ++) { @@ -919,7 +916,7 @@ void FixReaxCSpecies::WritePos(int Nmole, int Nspec) /* ---------------------------------------------------------------------- */ -double FixReaxCSpecies::compute_vector(int n) +double FixReaxFFSpecies::compute_vector(int n) { if (n == 0) return vector_nmole; @@ -931,7 +928,7 @@ double FixReaxCSpecies::compute_vector(int n) /* ---------------------------------------------------------------------- */ -int FixReaxCSpecies::nint(const double &r) +int FixReaxFFSpecies::nint(const double &r) { int i = 0; if (r>0.0) i = static_cast(r+0.5); @@ -941,7 +938,7 @@ int FixReaxCSpecies::nint(const double &r) /* ---------------------------------------------------------------------- */ -int FixReaxCSpecies::pack_forward_comm(int n, int *list, double *buf, +int FixReaxFFSpecies::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { int i,j,m; @@ -960,7 +957,7 @@ int FixReaxCSpecies::pack_forward_comm(int n, int *list, double *buf, /* ---------------------------------------------------------------------- */ -void FixReaxCSpecies::unpack_forward_comm(int n, int first, double *buf) +void FixReaxFFSpecies::unpack_forward_comm(int n, int first, double *buf) { int i,m,last; @@ -977,7 +974,7 @@ void FixReaxCSpecies::unpack_forward_comm(int n, int first, double *buf) /* ---------------------------------------------------------------------- */ -double FixReaxCSpecies::memory_usage() +double FixReaxFFSpecies::memory_usage() { double bytes; diff --git a/src/REAXFF/fix_reaxc_species.h b/src/REAXFF/fix_reaxff_species.h similarity index 87% rename from src/REAXFF/fix_reaxc_species.h rename to src/REAXFF/fix_reaxff_species.h index 225e0bcf24..1957c1f8b1 100644 --- a/src/REAXFF/fix_reaxc_species.h +++ b/src/REAXFF/fix_reaxff_species.h @@ -14,7 +14,8 @@ #ifdef FIX_CLASS // clang-format off -FixStyle(reax/c/species,FixReaxCSpecies); +FixStyle(reaxff/species,FixReaxFFSpecies); +FixStyle(reax/c/species,FixReaxFFSpecies); // clang-format on #else @@ -31,10 +32,10 @@ typedef struct { double x, y, z; } AtomCoord; -class FixReaxCSpecies : public Fix { +class FixReaxFFSpecies : public Fix { public: - FixReaxCSpecies(class LAMMPS *, int, char **); - virtual ~FixReaxCSpecies(); + FixReaxFFSpecies(class LAMMPS *, int, char **); + virtual ~FixReaxFFSpecies(); int setmask(); virtual void init(); void init_list(int, class NeighList *); @@ -59,7 +60,7 @@ class FixReaxCSpecies : public Fix { int singlepos_opened, multipos_opened; char *ele, **eletype, *filepos; - void Output_ReaxC_Bonds(bigint, FILE *); + void Output_ReaxFF_Bonds(bigint, FILE *); void create_compute(); void create_fix(); AtomCoord chAnchor(AtomCoord, AtomCoord); @@ -80,7 +81,7 @@ class FixReaxCSpecies : public Fix { class NeighList *list; class FixAveAtom *f_SPECBOND; - class PairReaxC *reaxc; + class PairReaxFF *reaxff; }; } diff --git a/src/REAXFF/pair_reaxc.cpp b/src/REAXFF/pair_reaxc.cpp deleted file mode 100644 index 100606e9e3..0000000000 --- a/src/REAXFF/pair_reaxc.cpp +++ /dev/null @@ -1,882 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, 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 author: Hasan Metin Aktulga, Purdue University - (now at Lawrence Berkeley National Laboratory, hmaktulga@lbl.gov) - Per-atom energy/virial added by Ray Shan (Sandia) - Fix reax/c/bonds and fix reax/c/species for pair_style reax/c added by - Ray Shan (Sandia) - Hybrid and hybrid/overlay compatibility added by Ray Shan (Sandia) -------------------------------------------------------------------------- */ - -#include "pair_reaxc.h" - -#include "atom.h" -#include "citeme.h" -#include "comm.h" -#include "error.h" -#include "fix.h" -#include "fix_reaxc.h" -#include "force.h" -#include "memory.h" -#include "modify.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "neighbor.h" -#include "update.h" - -#include -#include -#include // for strcasecmp() - -#include "reaxc_defs.h" -#include "reaxc_types.h" -#include "reaxc_allocate.h" -#include "reaxc_control.h" -#include "reaxc_ffield.h" -#include "reaxc_forces.h" -#include "reaxc_init_md.h" -#include "reaxc_io_tools.h" -#include "reaxc_list.h" -#include "reaxc_lookup.h" -#include "reaxc_reset_tools.h" -#include "reaxc_vector.h" - -using namespace LAMMPS_NS; - -static const char cite_pair_reax_c[] = - "pair reax/c command:\n\n" - "@Article{Aktulga12,\n" - " author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama},\n" - " title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques},\n" - " journal = {Parallel Computing},\n" - " year = 2012,\n" - " volume = 38,\n" - " pages = {245--259}\n" - "}\n\n"; - -/* ---------------------------------------------------------------------- */ - -PairReaxC::PairReaxC(LAMMPS *lmp) : Pair(lmp) -{ - if (lmp->citeme) lmp->citeme->add(cite_pair_reax_c); - - single_enable = 0; - restartinfo = 0; - one_coeff = 1; - manybody_flag = 1; - centroidstressflag = CENTROID_NOTAVAIL; - ghostneigh = 1; - - fix_id = new char[24]; - snprintf(fix_id,24,"REAXC_%d",instance_me); - - system = (reax_system *) - memory->smalloc(sizeof(reax_system),"reax:system"); - memset(system,0,sizeof(reax_system)); - control = (control_params *) - memory->smalloc(sizeof(control_params),"reax:control"); - memset(control,0,sizeof(control_params)); - data = (simulation_data *) - memory->smalloc(sizeof(simulation_data),"reax:data"); - workspace = (storage *) - memory->smalloc(sizeof(storage),"reax:storage"); - lists = (reax_list *) - memory->smalloc(LIST_N * sizeof(reax_list),"reax:lists"); - memset(lists,0,LIST_N * sizeof(reax_list)); - out_control = (output_controls *) - memory->smalloc(sizeof(output_controls),"reax:out_control"); - memset(out_control,0,sizeof(output_controls)); - mpi_data = (mpi_datatypes *) - memory->smalloc(sizeof(mpi_datatypes),"reax:mpi"); - - control->me = system->my_rank = comm->me; - - system->my_coords[0] = 0; - system->my_coords[1] = 0; - system->my_coords[2] = 0; - system->num_nbrs = 0; - system->n = 0; // my atoms - system->N = 0; // mine + ghosts - system->bigN = 0; // all atoms in the system - system->local_cap = 0; - system->total_cap = 0; - system->gcell_cap = 0; - system->bndry_cuts.ghost_nonb = 0; - system->bndry_cuts.ghost_hbond = 0; - system->bndry_cuts.ghost_bond = 0; - system->bndry_cuts.ghost_cutoff = 0; - system->my_atoms = nullptr; - system->pair_ptr = this; - system->error_ptr = error; - control->error_ptr = error; - - system->omp_active = 0; - - fix_reax = nullptr; - tmpid = nullptr; - tmpbo = nullptr; - - nextra = 14; - pvector = new double[nextra]; - - setup_flag = 0; - fixspecies_flag = 0; - - nmax = 0; -} - -/* ---------------------------------------------------------------------- */ - -PairReaxC::~PairReaxC() -{ - if (copymode) return; - - if (fix_reax) modify->delete_fix(fix_id); - delete[] fix_id; - - if (setup_flag) { - Close_Output_Files( system, control, out_control, mpi_data ); - - // deallocate reax data-structures - - if (control->tabulate ) Deallocate_Lookup_Tables( system); - - if (control->hbond_cut > 0 ) Delete_List( lists+HBONDS ); - Delete_List( lists+BONDS ); - Delete_List( lists+THREE_BODIES ); - Delete_List( lists+FAR_NBRS ); - - DeAllocate_Workspace( control, workspace ); - DeAllocate_System( system ); - } - - memory->destroy( system ); - memory->destroy( control ); - memory->destroy( data ); - memory->destroy( workspace ); - memory->destroy( lists ); - memory->destroy( out_control ); - memory->destroy( mpi_data ); - - // deallocate interface storage - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); - memory->destroy(cutghost); - - delete [] chi; - delete [] eta; - delete [] gamma; - } - - memory->destroy(tmpid); - memory->destroy(tmpbo); - - delete [] pvector; - -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxC::allocate( ) -{ - allocated = 1; - int n = atom->ntypes; - - memory->create(setflag,n+1,n+1,"pair:setflag"); - memory->create(cutsq,n+1,n+1,"pair:cutsq"); - memory->create(cutghost,n+1,n+1,"pair:cutghost"); - map = new int[n+1]; - - chi = new double[n+1]; - eta = new double[n+1]; - gamma = new double[n+1]; -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxC::settings(int narg, char **arg) -{ - if (narg < 1) error->all(FLERR,"Illegal pair_style command"); - - // read name of control file or use default controls - - if (strcmp(arg[0],"NULL") == 0) { - strcpy( control->sim_name, "simulate" ); - control->ensemble = 0; - out_control->energy_update_freq = 0; - control->tabulate = 0; - - control->reneighbor = 1; - control->vlist_cut = control->nonb_cut; - control->bond_cut = 5.; - control->hbond_cut = 7.50; - control->thb_cut = 0.001; - control->thb_cutsq = 0.00001; - control->bg_cut = 0.3; - - // Initialize for when omp style included - control->nthreads = 1; - - out_control->write_steps = 0; - out_control->traj_method = 0; - strcpy( out_control->traj_title, "default_title" ); - out_control->atom_info = 0; - out_control->bond_info = 0; - out_control->angle_info = 0; - } else Read_Control_File(arg[0], control, out_control); - - // default values - - qeqflag = 1; - control->lgflag = 0; - control->enobondsflag = 1; - system->mincap = REAX_MIN_CAP; - system->minhbonds = REAX_MIN_HBONDS; - system->safezone = REAX_SAFE_ZONE; - system->saferzone = REAX_SAFER_ZONE; - - // process optional keywords - - int iarg = 1; - - while (iarg < narg) { - if (strcmp(arg[iarg],"checkqeq") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reax/c command"); - if (strcmp(arg[iarg+1],"yes") == 0) qeqflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) qeqflag = 0; - else error->all(FLERR,"Illegal pair_style reax/c command"); - iarg += 2; - } else if (strcmp(arg[iarg],"enobonds") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reax/c command"); - if (strcmp(arg[iarg+1],"yes") == 0) control->enobondsflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) control->enobondsflag = 0; - else error->all(FLERR,"Illegal pair_style reax/c command"); - iarg += 2; - } else if (strcmp(arg[iarg],"lgvdw") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reax/c command"); - if (strcmp(arg[iarg+1],"yes") == 0) control->lgflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) control->lgflag = 0; - else error->all(FLERR,"Illegal pair_style reax/c command"); - iarg += 2; - } else if (strcmp(arg[iarg],"safezone") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reax/c command"); - system->safezone = utils::numeric(FLERR,arg[iarg+1],false,lmp); - if (system->safezone < 0.0) - error->all(FLERR,"Illegal pair_style reax/c safezone command"); - system->saferzone = system->safezone*1.2 + 0.2; - iarg += 2; - } else if (strcmp(arg[iarg],"mincap") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reax/c command"); - system->mincap = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (system->mincap < 0) - error->all(FLERR,"Illegal pair_style reax/c mincap command"); - iarg += 2; - } else if (strcmp(arg[iarg],"minhbonds") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reax/c command"); - system->minhbonds = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (system->minhbonds < 0) - error->all(FLERR,"Illegal pair_style reax/c minhbonds command"); - iarg += 2; - } else error->all(FLERR,"Illegal pair_style reax/c command"); - } - - // LAMMPS is responsible for generating nbrs - - control->reneighbor = 1; -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxC::coeff( int nargs, char **args ) -{ - if (!allocated) allocate(); - - if (nargs != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(args[0],"*") != 0 || strcmp(args[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read ffield file - - char *file = args[2]; - FILE *fp; - fp = utils::open_potential(file,lmp,nullptr); - if (fp != nullptr) - Read_Force_Field(fp, &(system->reax_param), control); - else { - char str[128]; - snprintf(str,128,"Cannot open ReaxFF potential file %s",file); - error->all(FLERR,str); - } - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - - int itmp = 0; - int nreax_types = system->reax_param.num_atom_types; - for (int i = 3; i < nargs; i++) { - if (strcmp(args[i],"NULL") == 0) { - map[i-2] = -1; - itmp ++; - continue; - } - } - - int n = atom->ntypes; - - // pair_coeff element map - for (int i = 3; i < nargs; i++) - for (int j = 0; j < nreax_types; j++) - if (strcasecmp(args[i],system->reax_param.sbp[j].name) == 0) { - map[i-2] = j; - itmp ++; - } - - // error check - if (itmp != n) - error->all(FLERR,"Non-existent ReaxFF type"); - - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); - -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxC::init_style( ) -{ - if (!atom->q_flag) - error->all(FLERR,"Pair style reax/c requires atom attribute q"); - - // firstwarn = 1; - - bool have_qeq = ((modify->find_fix_by_style("^qeq/reax") != -1) - || (modify->find_fix_by_style("^qeq/shielded") != -1)); - if (!have_qeq && qeqflag == 1) - error->all(FLERR,"Pair reax/c requires use of fix qeq/reax or qeq/shielded"); - - system->n = atom->nlocal; // my atoms - system->N = atom->nlocal + atom->nghost; // mine + ghosts - system->bigN = static_cast (atom->natoms); // all atoms in the system - system->wsize = comm->nprocs; - - system->big_box.V = 0; - system->big_box.box_norms[0] = 0; - system->big_box.box_norms[1] = 0; - system->big_box.box_norms[2] = 0; - - if (atom->tag_enable == 0) - error->all(FLERR,"Pair style reax/c requires atom IDs"); - if (force->newton_pair == 0) - error->all(FLERR,"Pair style reax/c requires newton pair on"); - if ((atom->map_tag_max > 99999999) && (comm->me == 0)) - error->warning(FLERR,"Some Atom-IDs are too large. Pair style reax/c " - "native output files may get misformatted or corrupted"); - - // because system->bigN is an int, we cannot have more atoms than MAXSMALLINT - - if (atom->natoms > MAXSMALLINT) - error->all(FLERR,"Too many atoms for pair style reax/c"); - - // need a half neighbor list w/ Newton off and ghost neighbors - // built whenever re-neighboring occurs - - int irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->newton = 2; - neighbor->requests[irequest]->ghost = 1; - - cutmax = MAX3(control->nonb_cut, control->hbond_cut, control->bond_cut); - if ((cutmax < 2.0*control->bond_cut) && (comm->me == 0)) - error->warning(FLERR,"Total cutoff < 2*bond cutoff. May need to use an " - "increased neighbor list skin."); - - for (int i = 0; i < LIST_N; ++i) - if (lists[i].allocated != 1) - lists[i].allocated = 0; - - if (fix_reax == nullptr) { - char **fixarg = new char*[3]; - fixarg[0] = (char *) fix_id; - fixarg[1] = (char *) "all"; - fixarg[2] = (char *) "REAXC"; - modify->add_fix(3,fixarg); - delete [] fixarg; - fix_reax = (FixReaxC *) modify->fix[modify->nfix-1]; - } -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxC::setup( ) -{ - int oldN; - int mincap = system->mincap; - double safezone = system->safezone; - - system->n = atom->nlocal; // my atoms - system->N = atom->nlocal + atom->nghost; // mine + ghosts - oldN = system->N; - system->bigN = static_cast (atom->natoms); // all atoms in the system - - if (setup_flag == 0) { - - setup_flag = 1; - - int *num_bonds = fix_reax->num_bonds; - int *num_hbonds = fix_reax->num_hbonds; - - control->vlist_cut = neighbor->cutneighmax; - - // determine the local and total capacity - - system->local_cap = MAX( (int)(system->n * safezone), mincap ); - system->total_cap = MAX( (int)(system->N * safezone), mincap ); - - // initialize my data structures - - PreAllocate_Space( system, control, workspace ); - write_reax_atoms(); - - int num_nbrs = estimate_reax_lists(); - if (num_nbrs < 0) - error->all(FLERR,"Too many neighbors for pair style reax/c"); - if (!Make_List(system->total_cap, num_nbrs, TYP_FAR_NEIGHBOR, - lists+FAR_NBRS)) - error->all(FLERR,"Pair reax/c problem in far neighbor list"); - (lists+FAR_NBRS)->error_ptr=error; - - write_reax_lists(); - Initialize( system, control, data, workspace, &lists, out_control, - mpi_data, world ); - for (int k = 0; k < system->N; ++k) { - num_bonds[k] = system->my_atoms[k].num_bonds; - num_hbonds[k] = system->my_atoms[k].num_hbonds; - } - - } else { - - // fill in reax datastructures - - write_reax_atoms(); - - // reset the bond list info for new atoms - - for (int k = oldN; k < system->N; ++k) - Set_End_Index( k, Start_Index( k, lists+BONDS ), lists+BONDS ); - - // check if I need to shrink/extend my data-structs - - ReAllocate( system, control, data, workspace, &lists ); - } - - bigint local_ngroup = list->inum; - MPI_Allreduce( &local_ngroup, &ngroup, 1, MPI_LMP_BIGINT, MPI_SUM, world ); -} - -/* ---------------------------------------------------------------------- */ - -double PairReaxC::init_one(int i, int j) -{ - if (setflag[i][j] == 0) error->all(FLERR,"All pair coeffs are not set"); - - cutghost[i][j] = cutghost[j][i] = cutmax; - return cutmax; -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxC::compute(int eflag, int vflag) -{ - double evdwl,ecoul; - double t_start, t_end; - - // communicate num_bonds once every reneighboring - // 2 num arrays stored by fix, grab ptr to them - - if (neighbor->ago == 0) comm->forward_comm_fix(fix_reax); - int *num_bonds = fix_reax->num_bonds; - int *num_hbonds = fix_reax->num_hbonds; - - evdwl = ecoul = 0.0; - ev_init(eflag,vflag); - - if (vflag_global) control->virial = 1; - else control->virial = 0; - - system->n = atom->nlocal; // my atoms - system->N = atom->nlocal + atom->nghost; // mine + ghosts - system->bigN = static_cast (atom->natoms); // all atoms in the system - - system->big_box.V = 0; - system->big_box.box_norms[0] = 0; - system->big_box.box_norms[1] = 0; - system->big_box.box_norms[2] = 0; - if (comm->me == 0 ) t_start = MPI_Wtime(); - - // setup data structures - - setup(); - - Reset( system, control, data, workspace, &lists ); - workspace->realloc.num_far = write_reax_lists(); - // timing for filling in the reax lists - if (comm->me == 0) { - t_end = MPI_Wtime(); - data->timing.nbrs = t_end - t_start; - } - - // forces - - Compute_Forces(system,control,data,workspace,&lists,out_control,mpi_data); - read_reax_forces(vflag); - - for (int k = 0; k < system->N; ++k) { - num_bonds[k] = system->my_atoms[k].num_bonds; - num_hbonds[k] = system->my_atoms[k].num_hbonds; - } - - // energies and pressure - - if (eflag_global) { - evdwl += data->my_en.e_bond; - evdwl += data->my_en.e_ov; - evdwl += data->my_en.e_un; - evdwl += data->my_en.e_lp; - evdwl += data->my_en.e_ang; - evdwl += data->my_en.e_pen; - evdwl += data->my_en.e_coa; - evdwl += data->my_en.e_hb; - evdwl += data->my_en.e_tor; - evdwl += data->my_en.e_con; - evdwl += data->my_en.e_vdW; - - ecoul += data->my_en.e_ele; - ecoul += data->my_en.e_pol; - - // eng_vdwl += evdwl; - // eng_coul += ecoul; - - // Store the different parts of the energy - // in a list for output by compute pair command - - pvector[0] = data->my_en.e_bond; - pvector[1] = data->my_en.e_ov + data->my_en.e_un; - pvector[2] = data->my_en.e_lp; - pvector[3] = 0.0; - pvector[4] = data->my_en.e_ang; - pvector[5] = data->my_en.e_pen; - pvector[6] = data->my_en.e_coa; - pvector[7] = data->my_en.e_hb; - pvector[8] = data->my_en.e_tor; - pvector[9] = data->my_en.e_con; - pvector[10] = data->my_en.e_vdW; - pvector[11] = data->my_en.e_ele; - pvector[12] = 0.0; - pvector[13] = data->my_en.e_pol; - } - - if (vflag_fdotr) virial_fdotr_compute(); - -// Set internal timestep counter to that of LAMMPS - - data->step = update->ntimestep; - - Output_Results( system, control, data, &lists, out_control, mpi_data ); - - // populate tmpid and tmpbo arrays for fix reax/c/species - int i, j; - - if (fixspecies_flag) { - if (system->N > nmax) { - memory->destroy(tmpid); - memory->destroy(tmpbo); - nmax = system->N; - memory->create(tmpid,nmax,MAXSPECBOND,"pair:tmpid"); - memory->create(tmpbo,nmax,MAXSPECBOND,"pair:tmpbo"); - } - - for (i = 0; i < system->N; i ++) - for (j = 0; j < MAXSPECBOND; j ++) { - tmpbo[i][j] = 0.0; - tmpid[i][j] = 0; - } - FindBond(); - } - -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxC::write_reax_atoms() -{ - int *num_bonds = fix_reax->num_bonds; - int *num_hbonds = fix_reax->num_hbonds; - - if (system->N > system->total_cap) - error->all(FLERR,"Too many ghost atoms"); - - for (int i = 0; i < system->N; ++i) { - system->my_atoms[i].orig_id = atom->tag[i]; - system->my_atoms[i].type = map[atom->type[i]]; - system->my_atoms[i].x[0] = atom->x[i][0]; - system->my_atoms[i].x[1] = atom->x[i][1]; - system->my_atoms[i].x[2] = atom->x[i][2]; - system->my_atoms[i].q = atom->q[i]; - system->my_atoms[i].num_bonds = num_bonds[i]; - system->my_atoms[i].num_hbonds = num_hbonds[i]; - } -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxC::get_distance( rvec xj, rvec xi, double *d_sqr, rvec *dvec ) -{ - (*dvec)[0] = xj[0] - xi[0]; - (*dvec)[1] = xj[1] - xi[1]; - (*dvec)[2] = xj[2] - xi[2]; - *d_sqr = SQR((*dvec)[0]) + SQR((*dvec)[1]) + SQR((*dvec)[2]); -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxC::set_far_nbr( far_neighbor_data *fdest, - int j, double d, rvec dvec ) -{ - fdest->nbr = j; - fdest->d = d; - rvec_Copy( fdest->dvec, dvec ); - ivec_MakeZero( fdest->rel_box ); -} - -/* ---------------------------------------------------------------------- */ - -int PairReaxC::estimate_reax_lists() -{ - int itr_i, itr_j, i, j; - int num_nbrs, num_marked; - int *ilist, *jlist, *numneigh, **firstneigh, *marked; - double d_sqr; - rvec dvec; - double **x; - - int mincap = system->mincap; - double safezone = system->safezone; - - x = atom->x; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - - num_nbrs = 0; - num_marked = 0; - marked = (int*) calloc( system->N, sizeof(int) ); - - int numall = list->inum + list->gnum; - - for (itr_i = 0; itr_i < numall; ++itr_i) { - i = ilist[itr_i]; - marked[i] = 1; - ++num_marked; - jlist = firstneigh[i]; - - for (itr_j = 0; itr_j < numneigh[i]; ++itr_j) { - j = jlist[itr_j]; - j &= NEIGHMASK; - get_distance( x[j], x[i], &d_sqr, &dvec ); - - if (d_sqr <= SQR(control->nonb_cut)) - ++num_nbrs; - } - } - - free( marked ); - - return static_cast (MAX(num_nbrs*safezone, mincap*REAX_MIN_NBRS)); -} - -/* ---------------------------------------------------------------------- */ - -int PairReaxC::write_reax_lists() -{ - int itr_i, itr_j, i, j; - int num_nbrs; - int *ilist, *jlist, *numneigh, **firstneigh; - double d_sqr, cutoff_sqr; - rvec dvec; - double *dist, **x; - reax_list *far_nbrs; - far_neighbor_data *far_list; - - x = atom->x; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - - far_nbrs = lists + FAR_NBRS; - far_list = far_nbrs->select.far_nbr_list; - - num_nbrs = 0; - int inum = list->inum; - dist = (double*) calloc( system->N, sizeof(double) ); - - int numall = list->inum + list->gnum; - - for (itr_i = 0; itr_i < numall; ++itr_i) { - i = ilist[itr_i]; - jlist = firstneigh[i]; - Set_Start_Index( i, num_nbrs, far_nbrs ); - - if (i < inum) - cutoff_sqr = control->nonb_cut*control->nonb_cut; - else - cutoff_sqr = control->bond_cut*control->bond_cut; - - for (itr_j = 0; itr_j < numneigh[i]; ++itr_j) { - j = jlist[itr_j]; - j &= NEIGHMASK; - get_distance( x[j], x[i], &d_sqr, &dvec ); - - if (d_sqr <= (cutoff_sqr)) { - dist[j] = sqrt( d_sqr ); - set_far_nbr( &far_list[num_nbrs], j, dist[j], dvec ); - ++num_nbrs; - } - } - Set_End_Index( i, num_nbrs, far_nbrs ); - } - - free( dist ); - - return num_nbrs; -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxC::read_reax_forces(int /*vflag*/) -{ - for (int i = 0; i < system->N; ++i) { - system->my_atoms[i].f[0] = workspace->f[i][0]; - system->my_atoms[i].f[1] = workspace->f[i][1]; - system->my_atoms[i].f[2] = workspace->f[i][2]; - - atom->f[i][0] += -workspace->f[i][0]; - atom->f[i][1] += -workspace->f[i][1]; - atom->f[i][2] += -workspace->f[i][2]; - } - -} - -/* ---------------------------------------------------------------------- */ - -void *PairReaxC::extract(const char *str, int &dim) -{ - dim = 1; - if (strcmp(str,"chi") == 0 && chi) { - for (int i = 1; i <= atom->ntypes; i++) - if (map[i] >= 0) chi[i] = system->reax_param.sbp[map[i]].chi; - else chi[i] = 0.0; - return (void *) chi; - } - if (strcmp(str,"eta") == 0 && eta) { - for (int i = 1; i <= atom->ntypes; i++) - if (map[i] >= 0) eta[i] = system->reax_param.sbp[map[i]].eta; - else eta[i] = 0.0; - return (void *) eta; - } - if (strcmp(str,"gamma") == 0 && gamma) { - for (int i = 1; i <= atom->ntypes; i++) - if (map[i] >= 0) gamma[i] = system->reax_param.sbp[map[i]].gamma; - else gamma[i] = 0.0; - return (void *) gamma; - } - return nullptr; -} - -/* ---------------------------------------------------------------------- */ - -double PairReaxC::memory_usage() -{ - double bytes = 0.0; - - // From pair_reax_c - bytes += (double)1.0 * system->N * sizeof(int); - bytes += (double)1.0 * system->N * sizeof(double); - - // From reaxc_allocate: BO - bytes += (double)1.0 * system->total_cap * sizeof(reax_atom); - bytes += (double)19.0 * system->total_cap * sizeof(double); - bytes += (double)3.0 * system->total_cap * sizeof(int); - - // From reaxc_lists - bytes += (double)2.0 * lists->n * sizeof(int); - bytes += (double)lists->num_intrs * sizeof(three_body_interaction_data); - bytes += (double)lists->num_intrs * sizeof(bond_data); - bytes += (double)lists->num_intrs * sizeof(dbond_data); - bytes += (double)lists->num_intrs * sizeof(dDelta_data); - bytes += (double)lists->num_intrs * sizeof(far_neighbor_data); - bytes += (double)lists->num_intrs * sizeof(hbond_data); - - if (fixspecies_flag) - bytes += (double)2 * nmax * MAXSPECBOND * sizeof(double); - - return bytes; -} - -/* ---------------------------------------------------------------------- */ - -void PairReaxC::FindBond() -{ - int i, j, pj, nj; - double bo_tmp, bo_cut; - - bond_data *bo_ij; - bo_cut = 0.10; - - for (i = 0; i < system->n; i++) { - nj = 0; - for (pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj) { - bo_ij = &( lists->select.bond_list[pj] ); - j = bo_ij->nbr; - if (j < i) continue; - - bo_tmp = bo_ij->bo_data.BO; - - if (bo_tmp >= bo_cut) { - tmpid[i][nj] = j; - tmpbo[i][nj] = bo_tmp; - nj ++; - if (nj > MAXSPECBOND) error->all(FLERR,"Increase MAXSPECBOND in reaxc_defs.h"); - } - } - } -} diff --git a/src/REAXFF/pair_reaxff.cpp b/src/REAXFF/pair_reaxff.cpp new file mode 100644 index 0000000000..0aea45b9cd --- /dev/null +++ b/src/REAXFF/pair_reaxff.cpp @@ -0,0 +1,795 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, 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 author: + Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu + + Per-atom energy/virial added by Ray Shan (Sandia) + Fix reaxff/bonds and fix reaxff/species for pair_style reaxff added by + Ray Shan (Sandia) + Hybrid and hybrid/overlay compatibility added by Ray Shan (Sandia) +------------------------------------------------------------------------- */ + +#include "pair_reaxff.h" + +#include "atom.h" +#include "citeme.h" +#include "comm.h" +#include "error.h" +#include "fix_reaxff.h" +#include "force.h" +#include "memory.h" +#include "modify.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "update.h" + +#include +#include +#include // for strcasecmp() + +#include "reaxff_api.h" + +using namespace LAMMPS_NS; +using namespace ReaxFF; + +static const char cite_pair_reax_c[] = + "pair reaxff command:\n\n" + "@Article{Aktulga12,\n" + " author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama},\n" + " title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques},\n" + " journal = {Parallel Computing},\n" + " year = 2012,\n" + " volume = 38,\n" + " pages = {245--259}\n" + "}\n\n"; + +/* ---------------------------------------------------------------------- */ + +PairReaxFF::PairReaxFF(LAMMPS *lmp) : Pair(lmp) +{ + if (lmp->citeme) lmp->citeme->add(cite_pair_reax_c); + + single_enable = 0; + restartinfo = 0; + one_coeff = 1; + manybody_flag = 1; + centroidstressflag = CENTROID_NOTAVAIL; + ghostneigh = 1; + + fix_id = utils::strdup("REAXFF_" + std::to_string(instance_me)); + + api = new API; + + api->system = new reax_system; + memset(api->system,0,sizeof(reax_system)); + api->control = new control_params; + memset(api->control,0,sizeof(control_params)); + api->data = new simulation_data; + memset(api->data,0,sizeof(simulation_data)); + api->workspace = new storage; + memset(api->workspace,0,sizeof(storage)); + memory->create(api->lists, LIST_N,"reaxff:lists"); + memset(api->lists,0,LIST_N * sizeof(reax_list)); + + api->control->me = api->system->my_rank = comm->me; + + api->system->num_nbrs = 0; + api->system->n = 0; // my atoms + api->system->N = 0; // mine + ghosts + api->system->bigN = 0; // all atoms in the system + api->system->local_cap = 0; + api->system->total_cap = 0; + api->system->my_atoms = nullptr; + api->system->pair_ptr = this; + api->system->mem_ptr = memory; + api->system->error_ptr = error; + api->control->error_ptr = error; + api->control->lmp_ptr = lmp; + + api->system->omp_active = 0; + + fix_reaxff = nullptr; + tmpid = nullptr; + tmpbo = nullptr; + + nextra = 14; + pvector = new double[nextra]; + + setup_flag = 0; + fixspecies_flag = 0; + + nmax = 0; +} + +/* ---------------------------------------------------------------------- */ + +PairReaxFF::~PairReaxFF() +{ + if (copymode) return; + + if (fix_reaxff) modify->delete_fix(fix_id); + delete[] fix_id; + + if (setup_flag) { + + // deallocate reax data-structures + + if (api->control->tabulate) Deallocate_Lookup_Tables(api->system); + + if (api->control->hbond_cut > 0) Delete_List(api->lists+HBONDS); + Delete_List(api->lists+BONDS); + Delete_List(api->lists+THREE_BODIES); + Delete_List(api->lists+FAR_NBRS); + + DeAllocate_Workspace(api->control, api->workspace); + DeAllocate_System(api->system); + } + + delete api->system; + delete api->control; + delete api->data; + delete api->workspace; + memory->destroy(api->lists); + delete api; + + // deallocate interface storage + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + memory->destroy(cutghost); + + delete [] chi; + delete [] eta; + delete [] gamma; + } + + memory->destroy(tmpid); + memory->destroy(tmpbo); + + delete [] pvector; + +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFF::allocate() +{ + allocated = 1; + int n = atom->ntypes; + + memory->create(setflag,n+1,n+1,"pair:setflag"); + memory->create(cutsq,n+1,n+1,"pair:cutsq"); + memory->create(cutghost,n+1,n+1,"pair:cutghost"); + map = new int[n+1]; + + chi = new double[n+1]; + eta = new double[n+1]; + gamma = new double[n+1]; +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFF::settings(int narg, char **arg) +{ + if (narg < 1) error->all(FLERR,"Illegal pair_style command"); + + if (comm->me == 0) { + // read name of control file or use default controls + + if (strcmp(arg[0],"NULL") == 0) { + api->control->tabulate = 0; + + api->control->bond_cut = 5.; + api->control->hbond_cut = 7.50; + api->control->thb_cut = 0.001; + api->control->thb_cutsq = 0.00001; + api->control->bg_cut = 0.3; + + api->control->nthreads = 1; + + } else Read_Control_File(arg[0], api->control); + } + MPI_Bcast(api->control,sizeof(control_params),MPI_CHAR,0,world); + + // must reset these to local values after broadcast + api->control->me = comm->me; + api->control->error_ptr = error; + api->control->lmp_ptr = lmp; + + // default values + + qeqflag = 1; + api->control->lgflag = 0; + api->control->enobondsflag = 1; + api->system->mincap = REAX_MIN_CAP; + api->system->minhbonds = REAX_MIN_HBONDS; + api->system->safezone = REAX_SAFE_ZONE; + api->system->saferzone = REAX_SAFER_ZONE; + + // process optional keywords + + int iarg = 1; + + while (iarg < narg) { + if (strcmp(arg[iarg],"checkqeq") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); + if (strcmp(arg[iarg+1],"yes") == 0) qeqflag = 1; + else if (strcmp(arg[iarg+1],"no") == 0) qeqflag = 0; + else error->all(FLERR,"Illegal pair_style reaxff command"); + iarg += 2; + } else if (strcmp(arg[iarg],"enobonds") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); + if (strcmp(arg[iarg+1],"yes") == 0) api->control->enobondsflag = 1; + else if (strcmp(arg[iarg+1],"no") == 0) api->control->enobondsflag = 0; + else error->all(FLERR,"Illegal pair_style reaxff command"); + iarg += 2; + } else if (strcmp(arg[iarg],"lgvdw") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); + if (strcmp(arg[iarg+1],"yes") == 0) api->control->lgflag = 1; + else if (strcmp(arg[iarg+1],"no") == 0) api->control->lgflag = 0; + else error->all(FLERR,"Illegal pair_style reaxff command"); + iarg += 2; + } else if (strcmp(arg[iarg],"safezone") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); + api->system->safezone = utils::numeric(FLERR,arg[iarg+1],false,lmp); + if (api->system->safezone < 0.0) + error->all(FLERR,"Illegal pair_style reaxff safezone command"); + api->system->saferzone = api->system->safezone*1.2 + 0.2; + iarg += 2; + } else if (strcmp(arg[iarg],"mincap") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); + api->system->mincap = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + if (api->system->mincap < 0) + error->all(FLERR,"Illegal pair_style reaxff mincap command"); + iarg += 2; + } else if (strcmp(arg[iarg],"minhbonds") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); + api->system->minhbonds = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + if (api->system->minhbonds < 0) + error->all(FLERR,"Illegal pair_style reaxff minhbonds command"); + iarg += 2; + } else error->all(FLERR,"Illegal pair_style reaxff command"); + } +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFF::coeff(int nargs, char **args) +{ + if (!allocated) allocate(); + + if (nargs != 3 + atom->ntypes) + error->all(FLERR,"Incorrect args for pair coefficients"); + + // insure I,J args are * * + + if (strcmp(args[0],"*") != 0 || strcmp(args[1],"*") != 0) + error->all(FLERR,"Incorrect args for pair coefficients"); + + // read ffield file + + Read_Force_Field(args[2], &(api->system->reax_param), api->control, world); + + // read args that map atom types to elements in potential file + // map[i] = which element the Ith atom type is, -1 if "NULL" + + int itmp = 0; + int nreax_types = api->system->reax_param.num_atom_types; + for (int i = 3; i < nargs; i++) { + if (strcmp(args[i],"NULL") == 0) { + map[i-2] = -1; + itmp ++; + continue; + } + } + + int n = atom->ntypes; + + // pair_coeff element map + for (int i = 3; i < nargs; i++) + for (int j = 0; j < nreax_types; j++) + if (strcasecmp(args[i],api->system->reax_param.sbp[j].name) == 0) { + map[i-2] = j; + itmp ++; + } + + // error check + if (itmp != n) + error->all(FLERR,"Non-existent ReaxFF type"); + + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; + + // set setflag i,j for type pairs where both are mapped to elements + + int count = 0; + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + if (map[i] >= 0 && map[j] >= 0) { + setflag[i][j] = 1; + count++; + } + + if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); + +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFF::init_style() +{ + if (!atom->q_flag) + error->all(FLERR,"Pair style reaxff requires atom attribute q"); + + bool have_qeq = ((modify->find_fix_by_style("^qeq/reax") != -1) + || (modify->find_fix_by_style("^qeq/shielded") != -1)); + if (!have_qeq && qeqflag == 1) + error->all(FLERR,"Pair reaxff requires use of fix qeq/reaxff or qeq/shielded"); + + api->system->n = atom->nlocal; // my atoms + api->system->N = atom->nlocal + atom->nghost; // mine + ghosts + api->system->bigN = static_cast (atom->natoms); // all atoms in the system + api->system->wsize = comm->nprocs; + + if (atom->tag_enable == 0) + error->all(FLERR,"Pair style reaxff requires atom IDs"); + if (force->newton_pair == 0) + error->all(FLERR,"Pair style reaxff requires newton pair on"); + + // because system->bigN is an int, we cannot have more atoms than MAXSMALLINT + + if (atom->natoms > MAXSMALLINT) + error->all(FLERR,"Too many atoms for pair style reaxff"); + + // need a half neighbor list w/ Newton off and ghost neighbors + // built whenever re-neighboring occurs + + int irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->newton = 2; + neighbor->requests[irequest]->ghost = 1; + + cutmax = MAX3(api->control->nonb_cut, api->control->hbond_cut, api->control->bond_cut); + if ((cutmax < 2.0*api->control->bond_cut) && (comm->me == 0)) + error->warning(FLERR,"Total cutoff < 2*bond cutoff. May need to use an " + "increased neighbor list skin."); + + if (fix_reaxff == nullptr) { + modify->add_fix(fmt::format("{} all REAXFF",fix_id)); + fix_reaxff = (FixReaxFF *) modify->fix[modify->nfix-1]; + } +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFF::setup() +{ + int oldN; + int mincap = api->system->mincap; + double safezone = api->system->safezone; + + api->system->n = atom->nlocal; // my atoms + api->system->N = atom->nlocal + atom->nghost; // mine + ghosts + oldN = api->system->N; + api->system->bigN = static_cast (atom->natoms); // all atoms in the system + + if (setup_flag == 0) { + + setup_flag = 1; + + int *num_bonds = fix_reaxff->num_bonds; + int *num_hbonds = fix_reaxff->num_hbonds; + + // determine the local and total capacity + + api->system->local_cap = MAX((int)(api->system->n * safezone), mincap); + api->system->total_cap = MAX((int)(api->system->N * safezone), mincap); + + // initialize my data structures + + PreAllocate_Space(api->system, api->workspace); + write_reax_atoms(); + + api->system->wsize = comm->nprocs; + + int num_nbrs = estimate_reax_lists(); + if (num_nbrs < 0) + error->all(FLERR,"Too many neighbors for pair style reaxff"); + + Make_List(api->system->total_cap,num_nbrs,TYP_FAR_NEIGHBOR,api->lists+FAR_NBRS); + (api->lists+FAR_NBRS)->error_ptr=error; + + write_reax_lists(); + + Initialize(api->system,api->control,api->data,api->workspace,&api->lists,world); + for (int k = 0; k < api->system->N; ++k) { + num_bonds[k] = api->system->my_atoms[k].num_bonds; + num_hbonds[k] = api->system->my_atoms[k].num_hbonds; + } + + } else { + + // fill in reax datastructures + + write_reax_atoms(); + + // reset the bond list info for new atoms + + for (int k = oldN; k < api->system->N; ++k) + Set_End_Index(k, Start_Index(k, api->lists+BONDS), api->lists+BONDS); + + // check if I need to shrink/extend my data-structs + + ReAllocate(api->system, api->control, api->data, api->workspace, &api->lists); + } +} + +/* ---------------------------------------------------------------------- */ + +double PairReaxFF::init_one(int i, int j) +{ + if (setflag[i][j] == 0) error->all(FLERR,"All pair coeffs are not set"); + + cutghost[i][j] = cutghost[j][i] = cutmax; + return cutmax; +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFF::compute(int eflag, int vflag) +{ + double evdwl,ecoul; + + // communicate num_bonds once every reneighboring + // 2 num arrays stored by fix, grab ptr to them + + if (neighbor->ago == 0) comm->forward_comm_fix(fix_reaxff); + int *num_bonds = fix_reaxff->num_bonds; + int *num_hbonds = fix_reaxff->num_hbonds; + + evdwl = ecoul = 0.0; + ev_init(eflag,vflag); + + api->system->n = atom->nlocal; // my atoms + api->system->N = atom->nlocal + atom->nghost; // mine + ghosts + api->system->bigN = static_cast (atom->natoms); // all atoms in the system + + // setup data structures + + setup(); + + Reset(api->system, api->control, api->data, api->workspace, &api->lists); + api->workspace->realloc.num_far = write_reax_lists(); + + // forces + + Compute_Forces(api->system,api->control,api->data,api->workspace,&api->lists); + read_reax_forces(vflag); + + for (int k = 0; k < api->system->N; ++k) { + num_bonds[k] = api->system->my_atoms[k].num_bonds; + num_hbonds[k] = api->system->my_atoms[k].num_hbonds; + } + + // energies and pressure + + if (eflag_global) { + evdwl += api->data->my_en.e_bond; + evdwl += api->data->my_en.e_ov; + evdwl += api->data->my_en.e_un; + evdwl += api->data->my_en.e_lp; + evdwl += api->data->my_en.e_ang; + evdwl += api->data->my_en.e_pen; + evdwl += api->data->my_en.e_coa; + evdwl += api->data->my_en.e_hb; + evdwl += api->data->my_en.e_tor; + evdwl += api->data->my_en.e_con; + evdwl += api->data->my_en.e_vdW; + + ecoul += api->data->my_en.e_ele; + ecoul += api->data->my_en.e_pol; + + // Store the different parts of the energy + // in a list for output by compute pair command + + pvector[0] = api->data->my_en.e_bond; + pvector[1] = api->data->my_en.e_ov + api->data->my_en.e_un; + pvector[2] = api->data->my_en.e_lp; + pvector[3] = 0.0; + pvector[4] = api->data->my_en.e_ang; + pvector[5] = api->data->my_en.e_pen; + pvector[6] = api->data->my_en.e_coa; + pvector[7] = api->data->my_en.e_hb; + pvector[8] = api->data->my_en.e_tor; + pvector[9] = api->data->my_en.e_con; + pvector[10] = api->data->my_en.e_vdW; + pvector[11] = api->data->my_en.e_ele; + pvector[12] = 0.0; + pvector[13] = api->data->my_en.e_pol; + } + + if (vflag_fdotr) virial_fdotr_compute(); + +// Set internal timestep counter to that of LAMMPS + + api->data->step = update->ntimestep; + + // populate tmpid and tmpbo arrays for fix reaxff/species + int i, j; + + if (fixspecies_flag) { + if (api->system->N > nmax) { + memory->destroy(tmpid); + memory->destroy(tmpbo); + nmax = api->system->N; + memory->create(tmpid,nmax,MAXSPECBOND,"pair:tmpid"); + memory->create(tmpbo,nmax,MAXSPECBOND,"pair:tmpbo"); + } + + for (i = 0; i < api->system->N; i ++) + for (j = 0; j < MAXSPECBOND; j ++) { + tmpbo[i][j] = 0.0; + tmpid[i][j] = 0; + } + FindBond(); + } + +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFF::write_reax_atoms() +{ + int *num_bonds = fix_reaxff->num_bonds; + int *num_hbonds = fix_reaxff->num_hbonds; + + if (api->system->N > api->system->total_cap) + error->all(FLERR,"Too many ghost atoms"); + + for (int i = 0; i < api->system->N; ++i) { + api->system->my_atoms[i].orig_id = atom->tag[i]; + api->system->my_atoms[i].type = map[atom->type[i]]; + api->system->my_atoms[i].x[0] = atom->x[i][0]; + api->system->my_atoms[i].x[1] = atom->x[i][1]; + api->system->my_atoms[i].x[2] = atom->x[i][2]; + api->system->my_atoms[i].q = atom->q[i]; + api->system->my_atoms[i].num_bonds = num_bonds[i]; + api->system->my_atoms[i].num_hbonds = num_hbonds[i]; + } +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFF::get_distance(rvec xj, rvec xi, double *d_sqr, rvec *dvec) +{ + (*dvec)[0] = xj[0] - xi[0]; + (*dvec)[1] = xj[1] - xi[1]; + (*dvec)[2] = xj[2] - xi[2]; + *d_sqr = SQR((*dvec)[0]) + SQR((*dvec)[1]) + SQR((*dvec)[2]); +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFF::set_far_nbr(far_neighbor_data *fdest, + int j, double d, rvec dvec) +{ + fdest->nbr = j; + fdest->d = d; + rvec_Copy(fdest->dvec, dvec); + ivec_MakeZero(fdest->rel_box); +} + +/* ---------------------------------------------------------------------- */ + +int PairReaxFF::estimate_reax_lists() +{ + int itr_i, itr_j, i, j; + int num_nbrs, num_marked; + int *ilist, *jlist, *numneigh, **firstneigh, *marked; + double d_sqr; + rvec dvec; + double **x; + + int mincap = api->system->mincap; + double safezone = api->system->safezone; + + x = atom->x; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + num_nbrs = 0; + num_marked = 0; + marked = (int*) calloc(api->system->N, sizeof(int)); + + int numall = list->inum + list->gnum; + + for (itr_i = 0; itr_i < numall; ++itr_i) { + i = ilist[itr_i]; + marked[i] = 1; + ++num_marked; + jlist = firstneigh[i]; + + for (itr_j = 0; itr_j < numneigh[i]; ++itr_j) { + j = jlist[itr_j]; + j &= NEIGHMASK; + get_distance(x[j], x[i], &d_sqr, &dvec); + + if (d_sqr <= SQR(api->control->nonb_cut)) + ++num_nbrs; + } + } + + free(marked); + + return static_cast (MAX(num_nbrs*safezone, mincap*REAX_MIN_NBRS)); +} + +/* ---------------------------------------------------------------------- */ + +int PairReaxFF::write_reax_lists() +{ + int itr_i, itr_j, i, j; + int num_nbrs; + int *ilist, *jlist, *numneigh, **firstneigh; + double d_sqr, cutoff_sqr; + rvec dvec; + double *dist, **x; + reax_list *far_nbrs; + far_neighbor_data *far_list; + + x = atom->x; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + far_nbrs = api->lists + FAR_NBRS; + far_list = far_nbrs->select.far_nbr_list; + + num_nbrs = 0; + int inum = list->inum; + dist = (double*) calloc(api->system->N, sizeof(double)); + + int numall = list->inum + list->gnum; + + for (itr_i = 0; itr_i < numall; ++itr_i) { + i = ilist[itr_i]; + jlist = firstneigh[i]; + Set_Start_Index(i, num_nbrs, far_nbrs); + + if (i < inum) + cutoff_sqr = SQR(api->control->nonb_cut); + else + cutoff_sqr = SQR(api->control->bond_cut); + + for (itr_j = 0; itr_j < numneigh[i]; ++itr_j) { + j = jlist[itr_j]; + j &= NEIGHMASK; + get_distance(x[j], x[i], &d_sqr, &dvec); + + if (d_sqr <= (cutoff_sqr)) { + dist[j] = sqrt(d_sqr); + set_far_nbr(&far_list[num_nbrs], j, dist[j], dvec); + ++num_nbrs; + } + } + Set_End_Index(i, num_nbrs, far_nbrs); + } + + free(dist); + + return num_nbrs; +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFF::read_reax_forces(int /*vflag*/) +{ + for (int i = 0; i < api->system->N; ++i) { + api->system->my_atoms[i].f[0] = api->workspace->f[i][0]; + api->system->my_atoms[i].f[1] = api->workspace->f[i][1]; + api->system->my_atoms[i].f[2] = api->workspace->f[i][2]; + + atom->f[i][0] += -api->workspace->f[i][0]; + atom->f[i][1] += -api->workspace->f[i][1]; + atom->f[i][2] += -api->workspace->f[i][2]; + } + +} + +/* ---------------------------------------------------------------------- */ + +void *PairReaxFF::extract(const char *str, int &dim) +{ + dim = 1; + if (strcmp(str,"chi") == 0 && chi) { + for (int i = 1; i <= atom->ntypes; i++) + if (map[i] >= 0) chi[i] = api->system->reax_param.sbp[map[i]].chi; + else chi[i] = 0.0; + return (void *) chi; + } + if (strcmp(str,"eta") == 0 && eta) { + for (int i = 1; i <= atom->ntypes; i++) + if (map[i] >= 0) eta[i] = api->system->reax_param.sbp[map[i]].eta; + else eta[i] = 0.0; + return (void *) eta; + } + if (strcmp(str,"gamma") == 0 && gamma) { + for (int i = 1; i <= atom->ntypes; i++) + if (map[i] >= 0) gamma[i] = api->system->reax_param.sbp[map[i]].gamma; + else gamma[i] = 0.0; + return (void *) gamma; + } + return nullptr; +} + +/* ---------------------------------------------------------------------- */ + +double PairReaxFF::memory_usage() +{ + double bytes = 0.0; + + // From pair_reax_c + bytes += (double)1.0 * api->system->N * sizeof(int); + bytes += (double)1.0 * api->system->N * sizeof(double); + + // From reaxff_allocate: BO + bytes += (double)1.0 * api->system->total_cap * sizeof(reax_atom); + bytes += (double)19.0 * api->system->total_cap * sizeof(double); + bytes += (double)3.0 * api->system->total_cap * sizeof(int); + + // From reaxff_lists + bytes += (double)2.0 * api->lists->n * sizeof(int); + bytes += (double)api->lists->num_intrs * sizeof(three_body_interaction_data); + bytes += (double)api->lists->num_intrs * sizeof(bond_data); + bytes += (double)api->lists->num_intrs * sizeof(far_neighbor_data); + bytes += (double)api->lists->num_intrs * sizeof(hbond_data); + + if (fixspecies_flag) + bytes += (double)2 * nmax * MAXSPECBOND * sizeof(double); + + return bytes; +} + +/* ---------------------------------------------------------------------- */ + +void PairReaxFF::FindBond() +{ + int i, j, pj, nj; + double bo_tmp, bo_cut; + + bond_data *bo_ij; + bo_cut = 0.10; + + for (i = 0; i < api->system->n; i++) { + nj = 0; + for (pj = Start_Index(i, api->lists); pj < End_Index(i, api->lists); ++pj) { + bo_ij = &(api->lists->select.bond_list[pj]); + j = bo_ij->nbr; + if (j < i) continue; + + bo_tmp = bo_ij->bo_data.BO; + + if (bo_tmp >= bo_cut) { + tmpid[i][nj] = j; + tmpbo[i][nj] = bo_tmp; + nj ++; + if (nj > MAXSPECBOND) error->all(FLERR,"Increase MAXSPECBOND in reaxff_defs.h"); + } + } + } +} diff --git a/src/REAXFF/pair_reaxc.h b/src/REAXFF/pair_reaxff.h similarity index 79% rename from src/REAXFF/pair_reaxc.h rename to src/REAXFF/pair_reaxff.h index c8293ef417..f9f3b636c3 100644 --- a/src/REAXFF/pair_reaxc.h +++ b/src/REAXFF/pair_reaxff.h @@ -24,22 +24,27 @@ #ifdef PAIR_CLASS // clang-format off -PairStyle(reax/c,PairReaxC); +PairStyle(reaxff,PairReaxFF); +PairStyle(reax/c,PairReaxFF); // clang-format on #else -#ifndef LMP_PAIR_REAXC_H -#define LMP_PAIR_REAXC_H +#ifndef LMP_PAIR_REAXFF_H +#define LMP_PAIR_REAXFF_H #include "pair.h" -#include "reaxc_types.h" + +namespace ReaxFF { + struct API; + struct far_neighbor_data; +} namespace LAMMPS_NS { -class PairReaxC : public Pair { +class PairReaxFF : public Pair { public: - PairReaxC(class LAMMPS *); - ~PairReaxC(); + PairReaxFF(class LAMMPS *); + ~PairReaxFF(); void compute(int, int); void settings(int, char **); void coeff(int, char **); @@ -50,20 +55,13 @@ class PairReaxC : public Pair { int **tmpid; double **tmpbo,**tmpr; - control_params *control; - reax_system *system; - output_controls *out_control; - simulation_data *data; - storage *workspace; - reax_list *lists; - mpi_datatypes *mpi_data; + ReaxFF::API *api; + typedef double rvec[3]; - bigint ngroup; - - protected: +protected: char *fix_id; double cutmax; - class FixReaxC *fix_reax; + class FixReaxFF *fix_reaxff; double *chi,*eta,*gamma; int qeqflag; @@ -76,7 +74,7 @@ class PairReaxC : public Pair { void create_fix(); void write_reax_atoms(); void get_distance(rvec, rvec, double *, rvec *); - void set_far_nbr(far_neighbor_data *, int, double, rvec); + void set_far_nbr(ReaxFF::far_neighbor_data *, int, double, rvec); int estimate_reax_lists(); int write_reax_lists(); void read_reax_forces(int); @@ -84,7 +82,6 @@ class PairReaxC : public Pair { int nmax; void FindBond(); double memory_usage(); - }; } @@ -97,7 +94,7 @@ class PairReaxC : public Pair { E: Too many ghost atoms Number of ghost atoms has increased too much during simulation and has exceeded -the size of reax/c arrays. Increase safe_zone and min_cap in pair_style reax/c +the size of reaxff arrays. Increase safe_zone and min_cap in pair_style reaxff command */ diff --git a/src/REAXFF/reaxc_allocate.cpp b/src/REAXFF/reaxc_allocate.cpp deleted file mode 100644 index 7a9fca4d08..0000000000 --- a/src/REAXFF/reaxc_allocate.cpp +++ /dev/null @@ -1,507 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_allocate.h" -#include -#include "reaxc_defs.h" -#include "reaxc_list.h" -#include "reaxc_tool_box.h" - -#if defined(LMP_USER_OMP) && defined(_OPENMP) -#include -#endif - -#include "error.h" - -/* allocate space for my_atoms - important: we cannot know the exact number of atoms that will fall into a - process's box throughout the whole simulation. therefore - we need to make upper bound estimates for various data structures */ -int PreAllocate_Space( reax_system *system, control_params * /*control*/, - storage * workspace ) -{ - int mincap = system->mincap; - double safezone = system->safezone; - - // determine the local and total capacity - - system->local_cap = MAX( (int)(system->n * safezone), mincap ); - system->total_cap = MAX( (int)(system->N * safezone), mincap ); - - system->my_atoms = (reax_atom*) - scalloc(system->error_ptr, system->total_cap, sizeof(reax_atom), "my_atoms"); - - // Nullify some arrays only used in omp styles - // Should be safe to do here since called in pair->setup(); -#ifdef LMP_USER_OMP - workspace->CdDeltaReduction = nullptr; - workspace->forceReduction = nullptr; - workspace->valence_angle_atom_myoffset = nullptr; - workspace->my_ext_pressReduction = nullptr; -#else - LMP_UNUSED_PARAM(workspace); -#endif - - return REAXC_SUCCESS; -} - - -/************* system *************/ - -int Allocate_System( reax_system *system, int /*local_cap*/, int total_cap, - char * /*msg*/ ) -{ - system->my_atoms = (reax_atom*) - realloc( system->my_atoms, total_cap*sizeof(reax_atom) ); - - return REAXC_SUCCESS; -} - - -void DeAllocate_System( reax_system *system ) -{ - int i, j, k; - int ntypes; - reax_interaction *ff_params; - - // deallocate the atom list - sfree(system->error_ptr, system->my_atoms, "system->my_atoms" ); - - // deallocate the ffield parameters storage - ff_params = &(system->reax_param); - ntypes = ff_params->num_atom_types; - - sfree(system->error_ptr, ff_params->gp.l, "ff:globals" ); - - for (i = 0; i < ntypes; ++i) { - for (j = 0; j < ntypes; ++j) { - for (k = 0; k < ntypes; ++k) { - sfree(system->error_ptr, ff_params->fbp[i][j][k], "ff:fbp[i,j,k]" ); - } - sfree(system->error_ptr, ff_params->fbp[i][j], "ff:fbp[i,j]" ); - sfree(system->error_ptr, ff_params->thbp[i][j], "ff:thbp[i,j]" ); - sfree(system->error_ptr, ff_params->hbp[i][j], "ff:hbp[i,j]" ); - } - sfree(system->error_ptr, ff_params->fbp[i], "ff:fbp[i]" ); - sfree(system->error_ptr, ff_params->thbp[i], "ff:thbp[i]" ); - sfree(system->error_ptr, ff_params->hbp[i], "ff:hbp[i]" ); - sfree(system->error_ptr, ff_params->tbp[i], "ff:tbp[i]" ); - } - sfree(system->error_ptr, ff_params->fbp, "ff:fbp" ); - sfree(system->error_ptr, ff_params->thbp, "ff:thbp" ); - sfree(system->error_ptr, ff_params->hbp, "ff:hbp" ); - sfree(system->error_ptr, ff_params->tbp, "ff:tbp" ); - sfree(system->error_ptr, ff_params->sbp, "ff:sbp" ); -} - - -/************* workspace *************/ -void DeAllocate_Workspace( control_params * control, storage *workspace ) -{ - int i; - - if (!workspace->allocated) - return; - - workspace->allocated = 0; - - /* communication storage */ - for (i = 0; i < MAX_NBRS; ++i) { - sfree(control->error_ptr, workspace->tmp_dbl[i], "tmp_dbl[i]" ); - sfree(control->error_ptr, workspace->tmp_rvec[i], "tmp_rvec[i]" ); - sfree(control->error_ptr, workspace->tmp_rvec2[i], "tmp_rvec2[i]" ); - } - - /* bond order storage */ - sfree(control->error_ptr, workspace->within_bond_box, "skin" ); - sfree(control->error_ptr, workspace->total_bond_order, "total_bo" ); - sfree(control->error_ptr, workspace->Deltap, "Deltap" ); - sfree(control->error_ptr, workspace->Deltap_boc, "Deltap_boc" ); - sfree(control->error_ptr, workspace->dDeltap_self, "dDeltap_self" ); - sfree(control->error_ptr, workspace->Delta, "Delta" ); - sfree(control->error_ptr, workspace->Delta_lp, "Delta_lp" ); - sfree(control->error_ptr, workspace->Delta_lp_temp, "Delta_lp_temp" ); - sfree(control->error_ptr, workspace->dDelta_lp, "dDelta_lp" ); - sfree(control->error_ptr, workspace->dDelta_lp_temp, "dDelta_lp_temp" ); - sfree(control->error_ptr, workspace->Delta_e, "Delta_e" ); - sfree(control->error_ptr, workspace->Delta_boc, "Delta_boc" ); - sfree(control->error_ptr, workspace->Delta_val, "Delta_val" ); - sfree(control->error_ptr, workspace->nlp, "nlp" ); - sfree(control->error_ptr, workspace->nlp_temp, "nlp_temp" ); - sfree(control->error_ptr, workspace->Clp, "Clp" ); - sfree(control->error_ptr, workspace->vlpex, "vlpex" ); - sfree(control->error_ptr, workspace->bond_mark, "bond_mark" ); - sfree(control->error_ptr, workspace->done_after, "done_after" ); - - /* QEq storage */ - sfree(control->error_ptr, workspace->Hdia_inv, "Hdia_inv" ); - sfree(control->error_ptr, workspace->b_s, "b_s" ); - sfree(control->error_ptr, workspace->b_t, "b_t" ); - sfree(control->error_ptr, workspace->b_prc, "b_prc" ); - sfree(control->error_ptr, workspace->b_prm, "b_prm" ); - sfree(control->error_ptr, workspace->s, "s" ); - sfree(control->error_ptr, workspace->t, "t" ); - sfree(control->error_ptr, workspace->droptol, "droptol" ); - sfree(control->error_ptr, workspace->b, "b" ); - sfree(control->error_ptr, workspace->x, "x" ); - - /* GMRES storage */ - for (i = 0; i < RESTART+1; ++i) { - sfree(control->error_ptr, workspace->h[i], "h[i]" ); - sfree(control->error_ptr, workspace->v[i], "v[i]" ); - } - sfree(control->error_ptr, workspace->h, "h" ); - sfree(control->error_ptr, workspace->v, "v" ); - sfree(control->error_ptr, workspace->y, "y" ); - sfree(control->error_ptr, workspace->z, "z" ); - sfree(control->error_ptr, workspace->g, "g" ); - sfree(control->error_ptr, workspace->hs, "hs" ); - sfree(control->error_ptr, workspace->hc, "hc" ); - /* CG storage */ - sfree(control->error_ptr, workspace->r, "r" ); - sfree(control->error_ptr, workspace->d, "d" ); - sfree(control->error_ptr, workspace->q, "q" ); - sfree(control->error_ptr, workspace->p, "p" ); - sfree(control->error_ptr, workspace->r2, "r2" ); - sfree(control->error_ptr, workspace->d2, "d2" ); - sfree(control->error_ptr, workspace->q2, "q2" ); - sfree(control->error_ptr, workspace->p2, "p2" ); - - /* integrator storage */ - sfree(control->error_ptr, workspace->v_const, "v_const" ); - - /* force related storage */ - sfree(control->error_ptr, workspace->f, "f" ); - sfree(control->error_ptr, workspace->CdDelta, "CdDelta" ); - - /* reductions */ -#ifdef LMP_USER_OMP - if (workspace->CdDeltaReduction) sfree(control->error_ptr, workspace->CdDeltaReduction, "cddelta_reduce" ); - if (workspace->forceReduction) sfree(control->error_ptr, workspace->forceReduction, "f_reduce" ); - if (workspace->valence_angle_atom_myoffset) sfree(control->error_ptr, workspace->valence_angle_atom_myoffset, "valence_angle_atom_myoffset"); - if (workspace->my_ext_pressReduction) sfree(control->error_ptr, workspace->my_ext_pressReduction, "ext_press_reduce"); -#endif -} - - -int Allocate_Workspace( reax_system * /*system*/, control_params * control, - storage *workspace, int local_cap, int total_cap, - char * /*msg*/ ) -{ - int i, total_real, total_rvec, local_rvec; - - workspace->allocated = 1; - total_real = total_cap * sizeof(double); - total_rvec = total_cap * sizeof(rvec); - local_rvec = local_cap * sizeof(rvec); - - /* communication storage */ - for (i = 0; i < MAX_NBRS; ++i) { - workspace->tmp_dbl[i] = (double*) - scalloc(control->error_ptr, total_cap, sizeof(double), "tmp_dbl"); - workspace->tmp_rvec[i] = (rvec*) - scalloc(control->error_ptr, total_cap, sizeof(rvec), "tmp_rvec"); - workspace->tmp_rvec2[i] = (rvec2*) - scalloc(control->error_ptr, total_cap, sizeof(rvec2), "tmp_rvec2"); - } - - /* bond order related storage */ - workspace->within_bond_box = (int*) - scalloc(control->error_ptr, total_cap, sizeof(int), "skin"); - workspace->total_bond_order = (double*) smalloc(control->error_ptr, total_real, "total_bo"); - workspace->Deltap = (double*) smalloc(control->error_ptr, total_real, "Deltap"); - workspace->Deltap_boc = (double*) smalloc(control->error_ptr, total_real, "Deltap_boc"); - workspace->dDeltap_self = (rvec*) smalloc(control->error_ptr, total_rvec, "dDeltap_self"); - workspace->Delta = (double*) smalloc(control->error_ptr, total_real, "Delta"); - workspace->Delta_lp = (double*) smalloc(control->error_ptr, total_real, "Delta_lp"); - workspace->Delta_lp_temp = (double*) - smalloc(control->error_ptr, total_real, "Delta_lp_temp"); - workspace->dDelta_lp = (double*) smalloc(control->error_ptr, total_real, "dDelta_lp"); - workspace->dDelta_lp_temp = (double*) - smalloc(control->error_ptr, total_real, "dDelta_lp_temp"); - workspace->Delta_e = (double*) smalloc(control->error_ptr, total_real, "Delta_e"); - workspace->Delta_boc = (double*) smalloc(control->error_ptr, total_real, "Delta_boc"); - workspace->Delta_val = (double*) smalloc(control->error_ptr, total_real, "Delta_val"); - workspace->nlp = (double*) smalloc(control->error_ptr, total_real, "nlp"); - workspace->nlp_temp = (double*) smalloc(control->error_ptr, total_real, "nlp_temp"); - workspace->Clp = (double*) smalloc(control->error_ptr, total_real, "Clp"); - workspace->vlpex = (double*) smalloc(control->error_ptr, total_real, "vlpex"); - workspace->bond_mark = (int*) - scalloc(control->error_ptr, total_cap, sizeof(int), "bond_mark"); - workspace->done_after = (int*) - scalloc(control->error_ptr, total_cap, sizeof(int), "done_after"); - - /* QEq storage */ - workspace->Hdia_inv = (double*) - scalloc(control->error_ptr, total_cap, sizeof(double), "Hdia_inv"); - workspace->b_s = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "b_s"); - workspace->b_t = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "b_t"); - workspace->b_prc = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "b_prc"); - workspace->b_prm = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "b_prm"); - workspace->s = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "s"); - workspace->t = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "t"); - workspace->droptol = (double*) - scalloc(control->error_ptr, total_cap, sizeof(double), "droptol"); - workspace->b = (rvec2*) scalloc(control->error_ptr, total_cap, sizeof(rvec2), "b"); - workspace->x = (rvec2*) scalloc(control->error_ptr, total_cap, sizeof(rvec2), "x"); - - /* GMRES storage */ - workspace->y = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "y"); - workspace->z = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "z"); - workspace->g = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "g"); - workspace->h = (double**) scalloc(control->error_ptr, RESTART+1, sizeof(double*), "h"); - workspace->hs = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "hs"); - workspace->hc = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "hc"); - workspace->v = (double**) scalloc(control->error_ptr, RESTART+1, sizeof(double*), "v"); - - for (i = 0; i < RESTART+1; ++i) { - workspace->h[i] = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "h[i]"); - workspace->v[i] = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "v[i]"); - } - - /* CG storage */ - workspace->r = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "r"); - workspace->d = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "d"); - workspace->q = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "q"); - workspace->p = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "p"); - workspace->r2 = (rvec2*) scalloc(control->error_ptr, total_cap, sizeof(rvec2), "r2"); - workspace->d2 = (rvec2*) scalloc(control->error_ptr, total_cap, sizeof(rvec2), "d2"); - workspace->q2 = (rvec2*) scalloc(control->error_ptr, total_cap, sizeof(rvec2), "q2"); - workspace->p2 = (rvec2*) scalloc(control->error_ptr, total_cap, sizeof(rvec2), "p2"); - - /* integrator storage */ - workspace->v_const = (rvec*) smalloc(control->error_ptr, local_rvec, "v_const"); - - /* force related storage */ - workspace->f = (rvec*) scalloc(control->error_ptr, total_cap, sizeof(rvec), "f"); - workspace->CdDelta = (double*) - scalloc(control->error_ptr, total_cap, sizeof(double), "CdDelta"); - - // storage for reductions with multiple threads -#ifdef LMP_USER_OMP - workspace->CdDeltaReduction = (double *) scalloc(control->error_ptr, sizeof(double), (rc_bigint)total_cap*control->nthreads, - "cddelta_reduce"); - - workspace->forceReduction = (rvec *) scalloc(control->error_ptr, sizeof(rvec), (rc_bigint)total_cap*control->nthreads, - "forceReduction"); - - workspace->valence_angle_atom_myoffset = (int *) scalloc(control->error_ptr, sizeof(int), total_cap, "valence_angle_atom_myoffset"); - workspace->my_ext_pressReduction = (rvec *) calloc(sizeof(rvec), control->nthreads); -#else - LMP_UNUSED_PARAM(control); -#endif - - return REAXC_SUCCESS; -} - - -static void Reallocate_Neighbor_List( reax_list *far_nbrs, int n, - int num_intrs ) -{ - Delete_List( far_nbrs); - if (!Make_List( n, num_intrs, TYP_FAR_NEIGHBOR, far_nbrs )) { - far_nbrs->error_ptr->one(FLERR,"Problem in initializing far neighbors list"); - } -} - - -static int Reallocate_HBonds_List( reax_system *system, reax_list *hbonds ) -{ - int i, total_hbonds; - - int mincap = system->mincap; - double saferzone = system->saferzone; - - total_hbonds = 0; - for (i = 0; i < system->n; ++i) - if ((system->my_atoms[i].Hindex) >= 0) { - total_hbonds += system->my_atoms[i].num_hbonds; - } - total_hbonds = (int)(MAX(total_hbonds*saferzone, mincap*system->minhbonds)); - - Delete_List( hbonds); - if (!Make_List( system->Hcap, total_hbonds, TYP_HBOND, hbonds )) { - hbonds->error_ptr->one(FLERR, "Not enough space for hydrogen bonds list"); - } - - return total_hbonds; -} - - -static int Reallocate_Bonds_List( reax_system *system, reax_list *bonds, - int *total_bonds, int *est_3body ) -{ - int i; - - int mincap = system->mincap; - double safezone = system->safezone; - - *total_bonds = 0; - *est_3body = 0; - for (i = 0; i < system->N; ++i) { - *est_3body += SQR(system->my_atoms[i].num_bonds); - *total_bonds += system->my_atoms[i].num_bonds; - } - *total_bonds = (int)(MAX( *total_bonds * safezone, mincap*MIN_BONDS )); - -#ifdef LMP_USER_OMP - if (system->omp_active) - for (i = 0; i < bonds->num_intrs; ++i) - sfree(system->error_ptr, bonds->select.bond_list[i].bo_data.CdboReduction, "CdboReduction"); -#endif - - Delete_List( bonds); - if (!Make_List(system->total_cap, *total_bonds, TYP_BOND, bonds)) { - bonds->error_ptr->one(FLERR, "Not enough space for bonds list"); - } - -#ifdef LMP_USER_OMP -#if defined(_OPENMP) - int nthreads = omp_get_num_threads(); -#else - int nthreads = 1; -#endif - - if (system->omp_active) - for (i = 0; i < bonds->num_intrs; ++i) - bonds->select.bond_list[i].bo_data.CdboReduction = - (double*) smalloc(system->error_ptr, sizeof(double)*nthreads, "CdboReduction"); -#endif - - return REAXC_SUCCESS; -} - - -void ReAllocate( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, reax_list **lists ) -{ - int num_bonds, est_3body, Hflag, ret; - int renbr, newsize; - reallocate_data *realloc; - reax_list *far_nbrs; - char msg[200]; - - int mincap = system->mincap; - double safezone = system->safezone; - double saferzone = system->saferzone; - - realloc = &(workspace->realloc); - - if ( system->n >= DANGER_ZONE * system->local_cap || - (0 && system->n <= LOOSE_ZONE * system->local_cap)) { - system->local_cap = MAX( (int)(system->n * safezone), mincap ); - } - - int Nflag = 0; - if ( system->N >= DANGER_ZONE * system->total_cap || - (0 && system->N <= LOOSE_ZONE * system->total_cap)) { - Nflag = 1; - system->total_cap = MAX( (int)(system->N * safezone), mincap ); - } - - if (Nflag) { - /* system */ - ret = Allocate_System( system, system->local_cap, system->total_cap, msg ); - if (ret != REAXC_SUCCESS) { - char errmsg[256]; - snprintf(errmsg, 256, "Not enough space for atom_list: total_cap=%d", system->total_cap); - system->error_ptr->one(FLERR, errmsg); - } - - /* workspace */ - DeAllocate_Workspace( control, workspace ); - ret = Allocate_Workspace( system, control, workspace, system->local_cap, - system->total_cap, msg ); - if (ret != REAXC_SUCCESS) { - char errmsg[256]; - snprintf(errmsg, 256, "Not enough space for workspace: local_cap=%d total_cap=%d", system->local_cap, system->total_cap); - system->error_ptr->one(FLERR, errmsg); - } - } - - - renbr = (data->step - data->prev_steps) % control->reneighbor == 0; - /* far neighbors */ - if (renbr) { - far_nbrs = *lists + FAR_NBRS; - - if (Nflag || realloc->num_far >= far_nbrs->num_intrs * DANGER_ZONE) { - if (realloc->num_far > far_nbrs->num_intrs) { - char errmsg[256]; - snprintf(errmsg, 256, "step%d-ran out of space on far_nbrs: top=%d, max=%d", data->step, realloc->num_far, far_nbrs->num_intrs); - system->error_ptr->one(FLERR, errmsg); - } - - newsize = static_cast - (MAX( realloc->num_far*safezone, mincap*REAX_MIN_NBRS)); - - Reallocate_Neighbor_List( far_nbrs, system->total_cap, newsize); - realloc->num_far = 0; - } - } - - /* hydrogen bonds list */ - if (control->hbond_cut > 0) { - Hflag = 0; - if ( system->numH >= DANGER_ZONE * system->Hcap || - (0 && system->numH <= LOOSE_ZONE * system->Hcap)) { - Hflag = 1; - system->Hcap = int(MAX( system->numH * saferzone, mincap )); - } - - if (Hflag || realloc->hbonds) { - ret = Reallocate_HBonds_List( system, (*lists)+HBONDS); - realloc->hbonds = 0; - } - } - - /* bonds list */ - num_bonds = est_3body = -1; - if (Nflag || realloc->bonds) { - Reallocate_Bonds_List( system, (*lists)+BONDS, &num_bonds, - &est_3body); - realloc->bonds = 0; - realloc->num_3body = MAX( realloc->num_3body, est_3body ) * 2; - } - - /* 3-body list */ - if (realloc->num_3body > 0) { - Delete_List( (*lists)+THREE_BODIES); - - if (num_bonds == -1) - num_bonds = ((*lists)+BONDS)->num_intrs; - - realloc->num_3body = (int)(MAX(realloc->num_3body*safezone, MIN_3BODIES)); - - if ( !Make_List( num_bonds, realloc->num_3body, TYP_THREE_BODY, - (*lists)+THREE_BODIES )) { - system->error_ptr->one(FLERR, "Problem in initializing angles list"); - } - realloc->num_3body = -1; - } - -} diff --git a/src/REAXFF/reaxc_allocate.h b/src/REAXFF/reaxc_allocate.h deleted file mode 100644 index b5e6f542ee..0000000000 --- a/src/REAXFF/reaxc_allocate.h +++ /dev/null @@ -1,43 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __ALLOCATE_H_ -#define __ALLOCATE_H_ - -#include "reaxc_types.h" -int PreAllocate_Space( reax_system*, control_params*, storage* ); - -int Allocate_System( reax_system*, int, int, char* ); -void DeAllocate_System( reax_system* ); - -int Allocate_Workspace( reax_system*, control_params*, storage*, - int, int, char* ); -void DeAllocate_Workspace( control_params*, storage* ); - -void ReAllocate( reax_system*, control_params*, simulation_data*, storage*, - reax_list** ); -#endif diff --git a/src/REAXFF/reaxc_bond_orders.cpp b/src/REAXFF/reaxc_bond_orders.cpp deleted file mode 100644 index bfc04d96a8..0000000000 --- a/src/REAXFF/reaxc_bond_orders.cpp +++ /dev/null @@ -1,595 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_bond_orders.h" -#include -#include "pair.h" -#include "reaxc_defs.h" -#include "reaxc_types.h" -#include "reaxc_list.h" -#include "reaxc_vector.h" - -void Add_dBond_to_Forces_NPT( int i, int pj, simulation_data *data, - storage *workspace, reax_list **lists ) -{ - reax_list *bonds = (*lists) + BONDS; - bond_data *nbr_j, *nbr_k; - bond_order_data *bo_ij, *bo_ji; - dbond_coefficients coef; - rvec temp, ext_press; - ivec rel_box; - int pk, k, j; - - /* Initializations */ - nbr_j = &(bonds->select.bond_list[pj]); - j = nbr_j->nbr; - bo_ij = &(nbr_j->bo_data); - bo_ji = &(bonds->select.bond_list[ nbr_j->sym_index ].bo_data); - - coef.C1dbo = bo_ij->C1dbo * (bo_ij->Cdbo + bo_ji->Cdbo); - coef.C2dbo = bo_ij->C2dbo * (bo_ij->Cdbo + bo_ji->Cdbo); - coef.C3dbo = bo_ij->C3dbo * (bo_ij->Cdbo + bo_ji->Cdbo); - - coef.C1dbopi = bo_ij->C1dbopi * (bo_ij->Cdbopi + bo_ji->Cdbopi); - coef.C2dbopi = bo_ij->C2dbopi * (bo_ij->Cdbopi + bo_ji->Cdbopi); - coef.C3dbopi = bo_ij->C3dbopi * (bo_ij->Cdbopi + bo_ji->Cdbopi); - coef.C4dbopi = bo_ij->C4dbopi * (bo_ij->Cdbopi + bo_ji->Cdbopi); - - coef.C1dbopi2 = bo_ij->C1dbopi2 * (bo_ij->Cdbopi2 + bo_ji->Cdbopi2); - coef.C2dbopi2 = bo_ij->C2dbopi2 * (bo_ij->Cdbopi2 + bo_ji->Cdbopi2); - coef.C3dbopi2 = bo_ij->C3dbopi2 * (bo_ij->Cdbopi2 + bo_ji->Cdbopi2); - coef.C4dbopi2 = bo_ij->C4dbopi2 * (bo_ij->Cdbopi2 + bo_ji->Cdbopi2); - - coef.C1dDelta = bo_ij->C1dbo * (workspace->CdDelta[i]+workspace->CdDelta[j]); - coef.C2dDelta = bo_ij->C2dbo * (workspace->CdDelta[i]+workspace->CdDelta[j]); - coef.C3dDelta = bo_ij->C3dbo * (workspace->CdDelta[i]+workspace->CdDelta[j]); - - for (pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk) { - nbr_k = &(bonds->select.bond_list[pk]); - k = nbr_k->nbr; - - rvec_Scale(temp, -coef.C2dbo, nbr_k->bo_data.dBOp); /*2nd, dBO*/ - rvec_ScaledAdd(temp, -coef.C2dDelta, nbr_k->bo_data.dBOp);/*dDelta*/ - rvec_ScaledAdd(temp, -coef.C3dbopi, nbr_k->bo_data.dBOp); /*3rd, dBOpi*/ - rvec_ScaledAdd(temp, -coef.C3dbopi2, nbr_k->bo_data.dBOp);/*3rd, dBOpi2*/ - - /* force */ - rvec_Add( workspace->f[k], temp ); - /* pressure */ - rvec_iMultiply( ext_press, nbr_k->rel_box, temp ); - rvec_Add( data->my_ext_press, ext_press ); - - } - - /* then atom i itself */ - rvec_Scale( temp, coef.C1dbo, bo_ij->dBOp ); /*1st,dBO*/ - rvec_ScaledAdd( temp, coef.C2dbo, workspace->dDeltap_self[i] ); /*2nd,dBO*/ - rvec_ScaledAdd( temp, coef.C1dDelta, bo_ij->dBOp ); /*1st,dBO*/ - rvec_ScaledAdd( temp, coef.C2dDelta, workspace->dDeltap_self[i] );/*2nd,dBO*/ - rvec_ScaledAdd( temp, coef.C1dbopi, bo_ij->dln_BOp_pi ); /*1st,dBOpi*/ - rvec_ScaledAdd( temp, coef.C2dbopi, bo_ij->dBOp ); /*2nd,dBOpi*/ - rvec_ScaledAdd( temp, coef.C3dbopi, workspace->dDeltap_self[i]);/*3rd,dBOpi*/ - - rvec_ScaledAdd( temp, coef.C1dbopi2, bo_ij->dln_BOp_pi2 ); /*1st,dBO_pi2*/ - rvec_ScaledAdd( temp, coef.C2dbopi2, bo_ij->dBOp ); /*2nd,dBO_pi2*/ - rvec_ScaledAdd( temp, coef.C3dbopi2, workspace->dDeltap_self[i] );/*3rd*/ - - /* force */ - rvec_Add( workspace->f[i], temp ); - - for (pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk) { - nbr_k = &(bonds->select.bond_list[pk]); - k = nbr_k->nbr; - - rvec_Scale( temp, -coef.C3dbo, nbr_k->bo_data.dBOp ); /*3rd,dBO*/ - rvec_ScaledAdd( temp, -coef.C3dDelta, nbr_k->bo_data.dBOp);/*dDelta*/ - rvec_ScaledAdd( temp, -coef.C4dbopi, nbr_k->bo_data.dBOp); /*4th,dBOpi*/ - rvec_ScaledAdd( temp, -coef.C4dbopi2, nbr_k->bo_data.dBOp);/*4th,dBOpi2*/ - - /* force */ - rvec_Add( workspace->f[k], temp ); - /* pressure */ - if (k != i) { - ivec_Sum( rel_box, nbr_k->rel_box, nbr_j->rel_box ); //rel_box(k, i) - rvec_iMultiply( ext_press, rel_box, temp ); - rvec_Add( data->my_ext_press, ext_press ); - - } - } - - /* then atom j itself */ - rvec_Scale( temp, -coef.C1dbo, bo_ij->dBOp ); /*1st, dBO*/ - rvec_ScaledAdd( temp, coef.C3dbo, workspace->dDeltap_self[j] ); /*2nd, dBO*/ - rvec_ScaledAdd( temp, -coef.C1dDelta, bo_ij->dBOp ); /*1st, dBO*/ - rvec_ScaledAdd( temp, coef.C3dDelta, workspace->dDeltap_self[j]);/*2nd, dBO*/ - - rvec_ScaledAdd( temp, -coef.C1dbopi, bo_ij->dln_BOp_pi ); /*1st,dBOpi*/ - rvec_ScaledAdd( temp, -coef.C2dbopi, bo_ij->dBOp ); /*2nd,dBOpi*/ - rvec_ScaledAdd( temp, coef.C4dbopi, workspace->dDeltap_self[j]);/*3rd,dBOpi*/ - - rvec_ScaledAdd( temp, -coef.C1dbopi2, bo_ij->dln_BOp_pi2 ); /*1st,dBOpi2*/ - rvec_ScaledAdd( temp, -coef.C2dbopi2, bo_ij->dBOp ); /*2nd,dBOpi2*/ - rvec_ScaledAdd( temp,coef.C4dbopi2,workspace->dDeltap_self[j]);/*3rd,dBOpi2*/ - - /* force */ - rvec_Add( workspace->f[j], temp ); - /* pressure */ - rvec_iMultiply( ext_press, nbr_j->rel_box, temp ); - rvec_Add( data->my_ext_press, ext_press ); - -} - -void Add_dBond_to_Forces( reax_system *system, int i, int pj, - storage *workspace, reax_list **lists ) -{ - reax_list *bonds = (*lists) + BONDS; - bond_data *nbr_j, *nbr_k; - bond_order_data *bo_ij, *bo_ji; - dbond_coefficients coef; - int pk, k, j; - - /* Virial Tallying variables */ - rvec fi_tmp, fj_tmp, fk_tmp, delij, delji, delki, delkj, temp; - - /* Initializations */ - nbr_j = &(bonds->select.bond_list[pj]); - j = nbr_j->nbr; - bo_ij = &(nbr_j->bo_data); - bo_ji = &(bonds->select.bond_list[ nbr_j->sym_index ].bo_data); - - coef.C1dbo = bo_ij->C1dbo * (bo_ij->Cdbo + bo_ji->Cdbo); - coef.C2dbo = bo_ij->C2dbo * (bo_ij->Cdbo + bo_ji->Cdbo); - coef.C3dbo = bo_ij->C3dbo * (bo_ij->Cdbo + bo_ji->Cdbo); - - coef.C1dbopi = bo_ij->C1dbopi * (bo_ij->Cdbopi + bo_ji->Cdbopi); - coef.C2dbopi = bo_ij->C2dbopi * (bo_ij->Cdbopi + bo_ji->Cdbopi); - coef.C3dbopi = bo_ij->C3dbopi * (bo_ij->Cdbopi + bo_ji->Cdbopi); - coef.C4dbopi = bo_ij->C4dbopi * (bo_ij->Cdbopi + bo_ji->Cdbopi); - - coef.C1dbopi2 = bo_ij->C1dbopi2 * (bo_ij->Cdbopi2 + bo_ji->Cdbopi2); - coef.C2dbopi2 = bo_ij->C2dbopi2 * (bo_ij->Cdbopi2 + bo_ji->Cdbopi2); - coef.C3dbopi2 = bo_ij->C3dbopi2 * (bo_ij->Cdbopi2 + bo_ji->Cdbopi2); - coef.C4dbopi2 = bo_ij->C4dbopi2 * (bo_ij->Cdbopi2 + bo_ji->Cdbopi2); - - coef.C1dDelta = bo_ij->C1dbo * (workspace->CdDelta[i]+workspace->CdDelta[j]); - coef.C2dDelta = bo_ij->C2dbo * (workspace->CdDelta[i]+workspace->CdDelta[j]); - coef.C3dDelta = bo_ij->C3dbo * (workspace->CdDelta[i]+workspace->CdDelta[j]); - - // forces on i - rvec_Scale( temp, coef.C1dbo, bo_ij->dBOp ); - rvec_ScaledAdd( temp, coef.C2dbo, workspace->dDeltap_self[i] ); - rvec_ScaledAdd( temp, coef.C1dDelta, bo_ij->dBOp ); - rvec_ScaledAdd( temp, coef.C2dDelta, workspace->dDeltap_self[i] ); - rvec_ScaledAdd( temp, coef.C1dbopi, bo_ij->dln_BOp_pi ); - rvec_ScaledAdd( temp, coef.C2dbopi, bo_ij->dBOp ); - rvec_ScaledAdd( temp, coef.C3dbopi, workspace->dDeltap_self[i]); - rvec_ScaledAdd( temp, coef.C1dbopi2, bo_ij->dln_BOp_pi2 ); - rvec_ScaledAdd( temp, coef.C2dbopi2, bo_ij->dBOp ); - rvec_ScaledAdd( temp, coef.C3dbopi2, workspace->dDeltap_self[i] ); - rvec_Add( workspace->f[i], temp ); - - if (system->pair_ptr->vflag_atom) { - rvec_Scale(fi_tmp, -1.0, temp); - rvec_ScaledSum( delij, 1., system->my_atoms[i].x,-1., system->my_atoms[j].x ); - system->pair_ptr->v_tally(i,fi_tmp,delij); - } - - // forces on j - rvec_Scale( temp, -coef.C1dbo, bo_ij->dBOp ); - rvec_ScaledAdd( temp, coef.C3dbo, workspace->dDeltap_self[j] ); - rvec_ScaledAdd( temp, -coef.C1dDelta, bo_ij->dBOp ); - rvec_ScaledAdd( temp, coef.C3dDelta, workspace->dDeltap_self[j]); - rvec_ScaledAdd( temp, -coef.C1dbopi, bo_ij->dln_BOp_pi ); - rvec_ScaledAdd( temp, -coef.C2dbopi, bo_ij->dBOp ); - rvec_ScaledAdd( temp, coef.C4dbopi, workspace->dDeltap_self[j]); - rvec_ScaledAdd( temp, -coef.C1dbopi2, bo_ij->dln_BOp_pi2 ); - rvec_ScaledAdd( temp, -coef.C2dbopi2, bo_ij->dBOp ); - rvec_ScaledAdd( temp, coef.C4dbopi2, workspace->dDeltap_self[j]); - rvec_Add( workspace->f[j], temp ); - - if (system->pair_ptr->vflag_atom) { - rvec_Scale(fj_tmp, -1.0, temp); - rvec_ScaledSum( delji, 1., system->my_atoms[j].x,-1., system->my_atoms[i].x ); - system->pair_ptr->v_tally(j,fj_tmp,delji); - } - - // forces on k: i neighbor - for (pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk) { - nbr_k = &(bonds->select.bond_list[pk]); - k = nbr_k->nbr; - - rvec_Scale( temp, -coef.C2dbo, nbr_k->bo_data.dBOp); - rvec_ScaledAdd( temp, -coef.C2dDelta, nbr_k->bo_data.dBOp); - rvec_ScaledAdd( temp, -coef.C3dbopi, nbr_k->bo_data.dBOp); - rvec_ScaledAdd( temp, -coef.C3dbopi2, nbr_k->bo_data.dBOp); - rvec_Add( workspace->f[k], temp ); - - if (system->pair_ptr->vflag_atom) { - rvec_Scale(fk_tmp, -1.0, temp); - rvec_ScaledSum(delki,1.,system->my_atoms[k].x,-1.,system->my_atoms[i].x); - system->pair_ptr->v_tally(k,fk_tmp,delki); - rvec_ScaledSum(delkj,1.,system->my_atoms[k].x,-1.,system->my_atoms[j].x); - system->pair_ptr->v_tally(k,fk_tmp,delkj); - } - } - - // forces on k: j neighbor - for (pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk) { - nbr_k = &(bonds->select.bond_list[pk]); - k = nbr_k->nbr; - - rvec_Scale( temp, -coef.C3dbo, nbr_k->bo_data.dBOp ); - rvec_ScaledAdd( temp, -coef.C3dDelta, nbr_k->bo_data.dBOp); - rvec_ScaledAdd( temp, -coef.C4dbopi, nbr_k->bo_data.dBOp); - rvec_ScaledAdd( temp, -coef.C4dbopi2, nbr_k->bo_data.dBOp); - rvec_Add( workspace->f[k], temp ); - - if (system->pair_ptr->vflag_atom) { - rvec_Scale(fk_tmp, -1.0, temp); - rvec_ScaledSum(delki,1.,system->my_atoms[k].x,-1.,system->my_atoms[i].x); - system->pair_ptr->v_tally(k,fk_tmp,delki); - rvec_ScaledSum(delkj,1.,system->my_atoms[k].x,-1.,system->my_atoms[j].x); - system->pair_ptr->v_tally(k,fk_tmp,delkj); - } - } - -} - - -int BOp( storage *workspace, reax_list *bonds, double bo_cut, - int i, int btop_i, far_neighbor_data *nbr_pj, - single_body_parameters *sbp_i, single_body_parameters *sbp_j, - two_body_parameters *twbp) { - int j, btop_j; - double r2, C12, C34, C56; - double Cln_BOp_s, Cln_BOp_pi, Cln_BOp_pi2; - double BO, BO_s, BO_pi, BO_pi2; - bond_data *ibond, *jbond; - bond_order_data *bo_ij, *bo_ji; - - j = nbr_pj->nbr; - r2 = SQR(nbr_pj->d); - - if (sbp_i->r_s > 0.0 && sbp_j->r_s > 0.0) { - C12 = twbp->p_bo1 * pow( nbr_pj->d / twbp->r_s, twbp->p_bo2 ); - BO_s = (1.0 + bo_cut) * exp( C12 ); - } - else BO_s = C12 = 0.0; - - if (sbp_i->r_pi > 0.0 && sbp_j->r_pi > 0.0) { - C34 = twbp->p_bo3 * pow( nbr_pj->d / twbp->r_p, twbp->p_bo4 ); - BO_pi = exp( C34 ); - } - else BO_pi = C34 = 0.0; - - if (sbp_i->r_pi_pi > 0.0 && sbp_j->r_pi_pi > 0.0) { - C56 = twbp->p_bo5 * pow( nbr_pj->d / twbp->r_pp, twbp->p_bo6 ); - BO_pi2= exp( C56 ); - } - else BO_pi2 = C56 = 0.0; - - /* Initially BO values are the uncorrected ones, page 1 */ - BO = BO_s + BO_pi + BO_pi2; - - if (BO >= bo_cut) { - /****** bonds i-j and j-i ******/ - ibond = &( bonds->select.bond_list[btop_i] ); - btop_j = End_Index( j, bonds ); - jbond = &(bonds->select.bond_list[btop_j]); - - ibond->nbr = j; - jbond->nbr = i; - ibond->d = nbr_pj->d; - jbond->d = nbr_pj->d; - rvec_Copy( ibond->dvec, nbr_pj->dvec ); - rvec_Scale( jbond->dvec, -1, nbr_pj->dvec ); - ivec_Copy( ibond->rel_box, nbr_pj->rel_box ); - ivec_Scale( jbond->rel_box, -1, nbr_pj->rel_box ); - ibond->dbond_index = btop_i; - jbond->dbond_index = btop_i; - ibond->sym_index = btop_j; - jbond->sym_index = btop_i; - Set_End_Index( j, btop_j+1, bonds ); - - bo_ij = &( ibond->bo_data ); - bo_ji = &( jbond->bo_data ); - bo_ji->BO = bo_ij->BO = BO; - bo_ji->BO_s = bo_ij->BO_s = BO_s; - bo_ji->BO_pi = bo_ij->BO_pi = BO_pi; - bo_ji->BO_pi2 = bo_ij->BO_pi2 = BO_pi2; - - /* Bond Order page2-3, derivative of total bond order prime */ - Cln_BOp_s = twbp->p_bo2 * C12 / r2; - Cln_BOp_pi = twbp->p_bo4 * C34 / r2; - Cln_BOp_pi2 = twbp->p_bo6 * C56 / r2; - - /* Only dln_BOp_xx wrt. dr_i is stored here, note that - dln_BOp_xx/dr_i = -dln_BOp_xx/dr_j and all others are 0 */ - rvec_Scale(bo_ij->dln_BOp_s,-bo_ij->BO_s*Cln_BOp_s,ibond->dvec); - rvec_Scale(bo_ij->dln_BOp_pi,-bo_ij->BO_pi*Cln_BOp_pi,ibond->dvec); - rvec_Scale(bo_ij->dln_BOp_pi2, - -bo_ij->BO_pi2*Cln_BOp_pi2,ibond->dvec); - rvec_Scale(bo_ji->dln_BOp_s, -1., bo_ij->dln_BOp_s); - rvec_Scale(bo_ji->dln_BOp_pi, -1., bo_ij->dln_BOp_pi ); - rvec_Scale(bo_ji->dln_BOp_pi2, -1., bo_ij->dln_BOp_pi2 ); - - rvec_Scale( bo_ij->dBOp, - -(bo_ij->BO_s * Cln_BOp_s + - bo_ij->BO_pi * Cln_BOp_pi + - bo_ij->BO_pi2 * Cln_BOp_pi2), ibond->dvec ); - rvec_Scale( bo_ji->dBOp, -1., bo_ij->dBOp ); - - rvec_Add( workspace->dDeltap_self[i], bo_ij->dBOp ); - rvec_Add( workspace->dDeltap_self[j], bo_ji->dBOp ); - - bo_ij->BO_s -= bo_cut; - bo_ij->BO -= bo_cut; - bo_ji->BO_s -= bo_cut; - bo_ji->BO -= bo_cut; - workspace->total_bond_order[i] += bo_ij->BO; //currently total_BOp - workspace->total_bond_order[j] += bo_ji->BO; //currently total_BOp - bo_ij->Cdbo = bo_ij->Cdbopi = bo_ij->Cdbopi2 = 0.0; - bo_ji->Cdbo = bo_ji->Cdbopi = bo_ji->Cdbopi2 = 0.0; - - return 1; - } - - return 0; -} - - -void BO( reax_system *system, control_params * /*control*/, simulation_data * /*data*/, - storage *workspace, reax_list **lists, output_controls * /*out_control*/ ) -{ - int i, j, pj, type_i, type_j; - int start_i, end_i, sym_index; - double val_i, Deltap_i, Deltap_boc_i; - double val_j, Deltap_j, Deltap_boc_j; - double f1, f2, f3, f4, f5, f4f5, exp_f4, exp_f5; - double exp_p1i, exp_p2i, exp_p1j, exp_p2j; - double temp, u1_ij, u1_ji, Cf1A_ij, Cf1B_ij, Cf1_ij, Cf1_ji; - double Cf45_ij, Cf45_ji, p_lp1; //u_ij, u_ji - double A0_ij, A1_ij, A2_ij, A2_ji, A3_ij, A3_ji; - double explp1, p_boc1, p_boc2; - single_body_parameters *sbp_i, *sbp_j; - two_body_parameters *twbp; - bond_order_data *bo_ij, *bo_ji; - reax_list *bonds = (*lists) + BONDS; - - p_boc1 = system->reax_param.gp.l[0]; - p_boc2 = system->reax_param.gp.l[1]; - - /* Calculate Deltaprime, Deltaprime_boc values */ - for (i = 0; i < system->N; ++i) { - type_i = system->my_atoms[i].type; - if (type_i < 0) continue; - sbp_i = &(system->reax_param.sbp[type_i]); - workspace->Deltap[i] = workspace->total_bond_order[i] - sbp_i->valency; - workspace->Deltap_boc[i] = - workspace->total_bond_order[i] - sbp_i->valency_val; - - workspace->total_bond_order[i] = 0; - } - - /* Corrected Bond Order calculations */ - for (i = 0; i < system->N; ++i) { - type_i = system->my_atoms[i].type; - if (type_i < 0) continue; - sbp_i = &(system->reax_param.sbp[type_i]); - val_i = sbp_i->valency; - Deltap_i = workspace->Deltap[i]; - Deltap_boc_i = workspace->Deltap_boc[i]; - start_i = Start_Index(i, bonds); - end_i = End_Index(i, bonds); - - for (pj = start_i; pj < end_i; ++pj) { - j = bonds->select.bond_list[pj].nbr; - type_j = system->my_atoms[j].type; - if (type_j < 0) continue; - bo_ij = &( bonds->select.bond_list[pj].bo_data ); - // fprintf( stderr, "\tj:%d - ubo: %8.3f\n", j+1, bo_ij->BO ); - - if (i < j || workspace->bond_mark[j] > 3) { - twbp = &( system->reax_param.tbp[type_i][type_j] ); - - if (twbp->ovc < 0.001 && twbp->v13cor < 0.001) { - bo_ij->C1dbo = 1.000000; - bo_ij->C2dbo = 0.000000; - bo_ij->C3dbo = 0.000000; - - bo_ij->C1dbopi = 1.000000; - bo_ij->C2dbopi = 0.000000; - bo_ij->C3dbopi = 0.000000; - bo_ij->C4dbopi = 0.000000; - - bo_ij->C1dbopi2 = 1.000000; - bo_ij->C2dbopi2 = 0.000000; - bo_ij->C3dbopi2 = 0.000000; - bo_ij->C4dbopi2 = 0.000000; - - } - else { - val_j = system->reax_param.sbp[type_j].valency; - Deltap_j = workspace->Deltap[j]; - Deltap_boc_j = workspace->Deltap_boc[j]; - - /* on page 1 */ - if (twbp->ovc >= 0.001) { - /* Correction for overcoordination */ - exp_p1i = exp( -p_boc1 * Deltap_i ); - exp_p2i = exp( -p_boc2 * Deltap_i ); - exp_p1j = exp( -p_boc1 * Deltap_j ); - exp_p2j = exp( -p_boc2 * Deltap_j ); - - f2 = exp_p1i + exp_p1j; - f3 = -1.0 / p_boc2 * log( 0.5 * ( exp_p2i + exp_p2j ) ); - f1 = 0.5 * ( ( val_i + f2 )/( val_i + f2 + f3 ) + - ( val_j + f2 )/( val_j + f2 + f3 ) ); - - temp = f2 + f3; - u1_ij = val_i + temp; - u1_ji = val_j + temp; - Cf1A_ij = 0.5 * f3 * (1.0 / SQR( u1_ij ) + - 1.0 / SQR( u1_ji )); - Cf1B_ij = -0.5 * (( u1_ij - f3 ) / SQR( u1_ij ) + - ( u1_ji - f3 ) / SQR( u1_ji )); - - Cf1_ij = 0.50 * ( -p_boc1 * exp_p1i / u1_ij - - ((val_i+f2) / SQR(u1_ij)) * - ( -p_boc1 * exp_p1i + - exp_p2i / ( exp_p2i + exp_p2j ) ) + - -p_boc1 * exp_p1i / u1_ji - - ((val_j+f2) / SQR(u1_ji)) * - ( -p_boc1 * exp_p1i + - exp_p2i / ( exp_p2i + exp_p2j ) )); - - - Cf1_ji = -Cf1A_ij * p_boc1 * exp_p1j + - Cf1B_ij * exp_p2j / ( exp_p2i + exp_p2j ); - - } - else { - /* No overcoordination correction! */ - f1 = 1.0; - Cf1_ij = Cf1_ji = 0.0; - } - - if (twbp->v13cor >= 0.001) { - /* Correction for 1-3 bond orders */ - exp_f4 =exp(-(twbp->p_boc4 * SQR( bo_ij->BO ) - - Deltap_boc_i) * twbp->p_boc3 + twbp->p_boc5); - exp_f5 =exp(-(twbp->p_boc4 * SQR( bo_ij->BO ) - - Deltap_boc_j) * twbp->p_boc3 + twbp->p_boc5); - - f4 = 1. / (1. + exp_f4); - f5 = 1. / (1. + exp_f5); - f4f5 = f4 * f5; - - /* Bond Order pages 8-9, derivative of f4 and f5 */ - Cf45_ij = -f4 * exp_f4; - Cf45_ji = -f5 * exp_f5; - } - else { - f4 = f5 = f4f5 = 1.0; - Cf45_ij = Cf45_ji = 0.0; - } - - /* Bond Order page 10, derivative of total bond order */ - A0_ij = f1 * f4f5; - A1_ij = -2 * twbp->p_boc3 * twbp->p_boc4 * bo_ij->BO * - (Cf45_ij + Cf45_ji); - A2_ij = Cf1_ij / f1 + twbp->p_boc3 * Cf45_ij; - A2_ji = Cf1_ji / f1 + twbp->p_boc3 * Cf45_ji; - A3_ij = A2_ij + Cf1_ij / f1; - A3_ji = A2_ji + Cf1_ji / f1; - - /* find corrected bond orders and their derivative coef */ - bo_ij->BO = bo_ij->BO * A0_ij; - bo_ij->BO_pi = bo_ij->BO_pi * A0_ij *f1; - bo_ij->BO_pi2= bo_ij->BO_pi2* A0_ij *f1; - bo_ij->BO_s = bo_ij->BO - ( bo_ij->BO_pi + bo_ij->BO_pi2 ); - - bo_ij->C1dbo = A0_ij + bo_ij->BO * A1_ij; - bo_ij->C2dbo = bo_ij->BO * A2_ij; - bo_ij->C3dbo = bo_ij->BO * A2_ji; - - bo_ij->C1dbopi = f1*f1*f4*f5; - bo_ij->C2dbopi = bo_ij->BO_pi * A1_ij; - bo_ij->C3dbopi = bo_ij->BO_pi * A3_ij; - bo_ij->C4dbopi = bo_ij->BO_pi * A3_ji; - - bo_ij->C1dbopi2 = f1*f1*f4*f5; - bo_ij->C2dbopi2 = bo_ij->BO_pi2 * A1_ij; - bo_ij->C3dbopi2 = bo_ij->BO_pi2 * A3_ij; - bo_ij->C4dbopi2 = bo_ij->BO_pi2 * A3_ji; - - } - - /* neglect bonds that are < 1e-10 */ - if (bo_ij->BO < 1e-10) - bo_ij->BO = 0.0; - if (bo_ij->BO_s < 1e-10) - bo_ij->BO_s = 0.0; - if (bo_ij->BO_pi < 1e-10) - bo_ij->BO_pi = 0.0; - if (bo_ij->BO_pi2 < 1e-10) - bo_ij->BO_pi2 = 0.0; - - workspace->total_bond_order[i] += bo_ij->BO; //now keeps total_BO - - } - else { - /* We only need to update bond orders from bo_ji - everything else is set in uncorrected_bo calculations */ - sym_index = bonds->select.bond_list[pj].sym_index; - bo_ji = &(bonds->select.bond_list[ sym_index ].bo_data); - bo_ij->BO = bo_ji->BO; - bo_ij->BO_s = bo_ji->BO_s; - bo_ij->BO_pi = bo_ji->BO_pi; - bo_ij->BO_pi2 = bo_ji->BO_pi2; - - workspace->total_bond_order[i] += bo_ij->BO;// now keeps total_BO - } - } - - } - - p_lp1 = system->reax_param.gp.l[15]; - for (j = 0; j < system->N; ++j) { - type_j = system->my_atoms[j].type; - if (type_j < 0) continue; - sbp_j = &(system->reax_param.sbp[ type_j ]); - - workspace->Delta[j] = workspace->total_bond_order[j] - sbp_j->valency; - workspace->Delta_e[j] = workspace->total_bond_order[j] - sbp_j->valency_e; - workspace->Delta_boc[j] = workspace->total_bond_order[j] - - sbp_j->valency_boc; - workspace->Delta_val[j] = workspace->total_bond_order[j] - - sbp_j->valency_val; - - workspace->vlpex[j] = workspace->Delta_e[j] - - 2.0 * (int)(workspace->Delta_e[j]/2.0); - explp1 = exp(-p_lp1 * SQR(2.0 + workspace->vlpex[j])); - workspace->nlp[j] = explp1 - (int)(workspace->Delta_e[j] / 2.0); - workspace->Delta_lp[j] = sbp_j->nlp_opt - workspace->nlp[j]; - workspace->Clp[j] = 2.0 * p_lp1 * explp1 * (2.0 + workspace->vlpex[j]); - workspace->dDelta_lp[j] = workspace->Clp[j]; - - if (sbp_j->mass > 21.0) { - workspace->nlp_temp[j] = 0.5 * (sbp_j->valency_e - sbp_j->valency); - workspace->Delta_lp_temp[j] = sbp_j->nlp_opt - workspace->nlp_temp[j]; - workspace->dDelta_lp_temp[j] = 0.; - } - else { - workspace->nlp_temp[j] = workspace->nlp[j]; - workspace->Delta_lp_temp[j] = sbp_j->nlp_opt - workspace->nlp_temp[j]; - workspace->dDelta_lp_temp[j] = workspace->Clp[j]; - } - - } - -} diff --git a/src/REAXFF/reaxc_bond_orders.h b/src/REAXFF/reaxc_bond_orders.h deleted file mode 100644 index 63550061d0..0000000000 --- a/src/REAXFF/reaxc_bond_orders.h +++ /dev/null @@ -1,47 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __BOND_ORDERS_H_ -#define __BOND_ORDERS_H_ - -#include "reaxc_types.h" - -typedef struct{ - double C1dbo, C2dbo, C3dbo; - double C1dbopi, C2dbopi, C3dbopi, C4dbopi; - double C1dbopi2, C2dbopi2, C3dbopi2, C4dbopi2; - double C1dDelta, C2dDelta, C3dDelta; -}dbond_coefficients; - -void Add_dBond_to_Forces( reax_system*, int, int, storage*, reax_list** ); -void Add_dBond_to_Forces_NPT( int, int, simulation_data*, - storage*, reax_list** ); -int BOp(storage*, reax_list*, double, int, int, far_neighbor_data*, - single_body_parameters*, single_body_parameters*, two_body_parameters*); -void BO( reax_system*, control_params*, simulation_data*, - storage*, reax_list**, output_controls* ); -#endif diff --git a/src/REAXFF/reaxc_bonds.cpp b/src/REAXFF/reaxc_bonds.cpp deleted file mode 100644 index 9ace195ee0..0000000000 --- a/src/REAXFF/reaxc_bonds.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_bonds.h" -#include -#include "pair.h" -#include "reaxc_defs.h" -#include "reaxc_list.h" - -void Bonds( reax_system *system, control_params * /*control*/, - simulation_data *data, storage *workspace, reax_list **lists, - output_controls * /*out_control*/ ) -{ - int i, j, pj, natoms; - int start_i, end_i; - int type_i, type_j; - double ebond, pow_BOs_be2, exp_be12, CEbo; - double gp3, gp4, gp7, gp10, gp37; - double exphu, exphua1, exphub1, exphuov, hulpov, estriph; - double decobdbo, decobdboua, decobdboub; - single_body_parameters *sbp_i, *sbp_j; - two_body_parameters *twbp; - bond_order_data *bo_ij; - reax_list *bonds; - - bonds = (*lists) + BONDS; - gp3 = system->reax_param.gp.l[3]; - gp4 = system->reax_param.gp.l[4]; - gp7 = system->reax_param.gp.l[7]; - gp10 = system->reax_param.gp.l[10]; - gp37 = (int) system->reax_param.gp.l[37]; - natoms = system->n; - - for (i = 0; i < natoms; ++i) { - start_i = Start_Index(i, bonds); - end_i = End_Index(i, bonds); - - for (pj = start_i; pj < end_i; ++pj) { - j = bonds->select.bond_list[pj].nbr; - - if (system->my_atoms[i].orig_id > system->my_atoms[j].orig_id) - continue; - if (system->my_atoms[i].orig_id == system->my_atoms[j].orig_id) { - if (system->my_atoms[j].x[2] < system->my_atoms[i].x[2]) continue; - if (system->my_atoms[j].x[2] == system->my_atoms[i].x[2] && - system->my_atoms[j].x[1] < system->my_atoms[i].x[1]) continue; - if (system->my_atoms[j].x[2] == system->my_atoms[i].x[2] && - system->my_atoms[j].x[1] == system->my_atoms[i].x[1] && - system->my_atoms[j].x[0] < system->my_atoms[i].x[0]) continue; - } - - /* set the pointers */ - type_i = system->my_atoms[i].type; - type_j = system->my_atoms[j].type; - sbp_i = &( system->reax_param.sbp[type_i] ); - sbp_j = &( system->reax_param.sbp[type_j] ); - twbp = &( system->reax_param.tbp[type_i][type_j] ); - bo_ij = &( bonds->select.bond_list[pj].bo_data ); - - /* calculate the constants */ - if (bo_ij->BO_s == 0.0) pow_BOs_be2 = 0.0; - else pow_BOs_be2 = pow( bo_ij->BO_s, twbp->p_be2 ); - exp_be12 = exp( twbp->p_be1 * ( 1.0 - pow_BOs_be2 ) ); - CEbo = -twbp->De_s * exp_be12 * - ( 1.0 - twbp->p_be1 * twbp->p_be2 * pow_BOs_be2 ); - - /* calculate the Bond Energy */ - data->my_en.e_bond += ebond = - -twbp->De_s * bo_ij->BO_s * exp_be12 - -twbp->De_p * bo_ij->BO_pi - -twbp->De_pp * bo_ij->BO_pi2; - - /* tally into per-atom energy */ - if (system->pair_ptr->evflag) - system->pair_ptr->ev_tally(i,j,natoms,1,ebond,0.0,0.0,0.0,0.0,0.0); - - /* calculate derivatives of Bond Orders */ - bo_ij->Cdbo += CEbo; - bo_ij->Cdbopi -= (CEbo + twbp->De_p); - bo_ij->Cdbopi2 -= (CEbo + twbp->De_pp); - - /* Stabilisation terminal triple bond */ - if (bo_ij->BO >= 1.00) { - if ( gp37 == 2 || - (sbp_i->mass == 12.0000 && sbp_j->mass == 15.9990) || - (sbp_j->mass == 12.0000 && sbp_i->mass == 15.9990)) { - exphu = exp( -gp7 * SQR(bo_ij->BO - 2.50) ); - exphua1 = exp(-gp3 * (workspace->total_bond_order[i]-bo_ij->BO)); - exphub1 = exp(-gp3 * (workspace->total_bond_order[j]-bo_ij->BO)); - exphuov = exp(gp4 * (workspace->Delta[i] + workspace->Delta[j])); - hulpov = 1.0 / (1.0 + 25.0 * exphuov); - - estriph = gp10 * exphu * hulpov * (exphua1 + exphub1); - data->my_en.e_bond += estriph; - - decobdbo = gp10 * exphu * hulpov * (exphua1 + exphub1) * - ( gp3 - 2.0 * gp7 * (bo_ij->BO-2.50) ); - decobdboua = -gp10 * exphu * hulpov * - (gp3*exphua1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); - decobdboub = -gp10 * exphu * hulpov * - (gp3*exphub1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); - - /* tally into per-atom energy */ - if (system->pair_ptr->evflag) - system->pair_ptr->ev_tally(i,j,natoms,1,estriph,0.0,0.0,0.0,0.0,0.0); - - bo_ij->Cdbo += decobdbo; - workspace->CdDelta[i] += decobdboua; - workspace->CdDelta[j] += decobdboub; - } - } - } - } -} diff --git a/src/REAXFF/reaxc_bonds.h b/src/REAXFF/reaxc_bonds.h deleted file mode 100644 index 49a869c766..0000000000 --- a/src/REAXFF/reaxc_bonds.h +++ /dev/null @@ -1,35 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __BONDS_H_ -#define __BONDS_H_ - -#include "reaxc_types.h" - -void Bonds( reax_system*, control_params*, simulation_data*, - storage*, reax_list**, output_controls* ); -#endif diff --git a/src/REAXFF/reaxc_control.cpp b/src/REAXFF/reaxc_control.cpp deleted file mode 100644 index af24d393d8..0000000000 --- a/src/REAXFF/reaxc_control.cpp +++ /dev/null @@ -1,391 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_control.h" -#include -#include -#include "reaxc_defs.h" -#include "reaxc_tool_box.h" - -#include "error.h" - -char Read_Control_File( char *control_file, control_params* control, - output_controls *out_control ) -{ - FILE *fp; - char *s, **tmp; - int i,ival; - double val; - - /* open control file */ - if ((fp = fopen( control_file, "r" ) ) == nullptr) { - control->error_ptr->all(FLERR, "The control file cannot be opened"); - } - - /* assign default values */ - strcpy( control->sim_name, "simulate" ); - control->ensemble = NVE; - control->nsteps = 0; - control->dt = 0.25; - control->nprocs = 1; - control->nthreads = 1; - control->procs_by_dim[0] = 1; - control->procs_by_dim[1] = 1; - control->procs_by_dim[2] = 1; - control->geo_format = 1; - - control->restart = 0; - out_control->restart_format = WRITE_BINARY; - out_control->restart_freq = 0; - control->reposition_atoms = 0; - control->restrict_bonds = 0; - control->remove_CoM_vel = 25; - out_control->debug_level = 0; - out_control->energy_update_freq = 0; - - control->reneighbor = 1; - control->vlist_cut = control->nonb_cut; - control->bond_cut = 5.0; - control->bg_cut = 0.3; - control->thb_cut = 0.001; - control->thb_cutsq = 0.00001; - control->hbond_cut = 7.5; - - control->tabulate = 0; - - control->qeq_freq = 1; - control->q_err = 1e-6; - control->refactor = 100; - control->droptol = 1e-2;; - - control->T_init = 0.; - control->T_final = 300.; - control->Tau_T = 500.0; - control->T_mode = 0; - control->T_rate = 1.; - control->T_freq = 1.; - - control->P[0] = control->P[1] = control->P[2] = 0.000101325; - control->Tau_P[0] = control->Tau_P[1] = control->Tau_P[2] = 500.0; - control->Tau_PT[0] = control->Tau_PT[1] = control->Tau_PT[2] = 500.0; - control->compressibility = 1.0; - control->press_mode = 0; - control->virial = 0; - - out_control->write_steps = 0; - out_control->traj_compress = 0; - out_control->traj_method = REG_TRAJ; - strcpy( out_control->traj_title, "default_title" ); - out_control->atom_info = 0; - out_control->bond_info = 0; - out_control->angle_info = 0; - - control->molecular_analysis = 0; - control->dipole_anal = 0; - control->freq_dipole_anal = 0; - control->diffusion_coef = 0; - control->freq_diffusion_coef = 0; - control->restrict_type = 0; - - /* memory allocations */ - s = (char*) malloc(sizeof(char)*MAX_LINE); - tmp = (char**) malloc(sizeof(char*)*MAX_TOKENS); - for (i=0; i < MAX_TOKENS; i++) - tmp[i] = (char*) malloc(sizeof(char)*MAX_LINE); - - /* read control parameters file */ - while (!feof(fp)) { - fgets( s, MAX_LINE, fp ); - Tokenize( s, &tmp ); - - if (strcmp(tmp[0], "simulation_name") == 0) { - strcpy( control->sim_name, tmp[1] ); - } - else if (strcmp(tmp[0], "ensemble_type") == 0) { - ival = atoi(tmp[1]); - control->ensemble = ival; - if (ival == iNPT || ival ==sNPT || ival == NPT) - control->virial = 1; - } - else if (strcmp(tmp[0], "nsteps") == 0) { - ival = atoi(tmp[1]); - control->nsteps = ival; - } - else if ( strcmp(tmp[0], "dt") == 0) { - val = atof(tmp[1]); - control->dt = val * 1.e-3; // convert dt from fs to ps! - } - else if (strcmp(tmp[0], "proc_by_dim") == 0) { - ival = atoi(tmp[1]); - control->procs_by_dim[0] = ival; - ival = atoi(tmp[2]); - control->procs_by_dim[1] = ival; - ival = atoi(tmp[3]); - control->procs_by_dim[2] = ival; - - control->nprocs = control->procs_by_dim[0]*control->procs_by_dim[1]* - control->procs_by_dim[2]; - } - else if (strcmp(tmp[0], "random_vel") == 0) { - ival = atoi(tmp[1]); - control->random_vel = ival; - } - else if (strcmp(tmp[0], "restart_format") == 0) { - ival = atoi(tmp[1]); - out_control->restart_format = ival; - } - else if (strcmp(tmp[0], "restart_freq") == 0) { - ival = atoi(tmp[1]); - out_control->restart_freq = ival; - } - else if (strcmp(tmp[0], "reposition_atoms") == 0) { - ival = atoi(tmp[1]); - control->reposition_atoms = ival; - } - else if (strcmp(tmp[0], "restrict_bonds") == 0) { - ival = atoi( tmp[1] ); - control->restrict_bonds = ival; - } - else if (strcmp(tmp[0], "remove_CoM_vel") == 0) { - ival = atoi(tmp[1]); - control->remove_CoM_vel = ival; - } - else if (strcmp(tmp[0], "debug_level") == 0) { - ival = atoi(tmp[1]); - out_control->debug_level = ival; - } - else if (strcmp(tmp[0], "energy_update_freq") == 0) { - ival = atoi(tmp[1]); - out_control->energy_update_freq = ival; - } - else if (strcmp(tmp[0], "reneighbor") == 0) { - ival = atoi( tmp[1] ); - control->reneighbor = ival; - } - else if (strcmp(tmp[0], "vlist_buffer") == 0) { - val = atof(tmp[1]); - control->vlist_cut= val + control->nonb_cut; - } - else if (strcmp(tmp[0], "nbrhood_cutoff") == 0) { - val = atof(tmp[1]); - control->bond_cut = val; - } - else if (strcmp(tmp[0], "bond_graph_cutoff") == 0) { - val = atof(tmp[1]); - control->bg_cut = val; - } - else if (strcmp(tmp[0], "thb_cutoff") == 0) { - val = atof(tmp[1]); - control->thb_cut = val; - } - else if (strcmp(tmp[0], "thb_cutoff_sq") == 0) { - val = atof(tmp[1]); - control->thb_cutsq = val; - } - else if (strcmp(tmp[0], "hbond_cutoff") == 0) { - val = atof( tmp[1] ); - control->hbond_cut = val; - } - else if (strcmp(tmp[0], "ghost_cutoff") == 0) { - val = atof(tmp[1]); - control->user_ghost_cut = val; - } - else if (strcmp(tmp[0], "tabulate_long_range") == 0) { - ival = atoi( tmp[1] ); - control->tabulate = ival; - } - else if (strcmp(tmp[0], "qeq_freq") == 0) { - ival = atoi( tmp[1] ); - control->qeq_freq = ival; - } - else if (strcmp(tmp[0], "q_err") == 0) { - val = atof( tmp[1] ); - control->q_err = val; - } - else if (strcmp(tmp[0], "ilu_refactor") == 0) { - ival = atoi( tmp[1] ); - control->refactor = ival; - } - else if (strcmp(tmp[0], "ilu_droptol") == 0) { - val = atof( tmp[1] ); - control->droptol = val; - } - else if (strcmp(tmp[0], "temp_init") == 0) { - val = atof(tmp[1]); - control->T_init = val; - - if (control->T_init < 0.1) - control->T_init = 0.1; - } - else if (strcmp(tmp[0], "temp_final") == 0) { - val = atof(tmp[1]); - control->T_final = val; - - if (control->T_final < 0.1) - control->T_final = 0.1; - } - else if (strcmp(tmp[0], "t_mass") == 0) { - val = atof(tmp[1]); - control->Tau_T = val * 1.e-3; // convert t_mass from fs to ps - } - else if (strcmp(tmp[0], "t_mode") == 0) { - ival = atoi(tmp[1]); - control->T_mode = ival; - } - else if (strcmp(tmp[0], "t_rate") == 0) { - val = atof(tmp[1]); - control->T_rate = val; - } - else if (strcmp(tmp[0], "t_freq") == 0) { - val = atof(tmp[1]); - control->T_freq = val; - } - else if (strcmp(tmp[0], "pressure") == 0) { - if (control->ensemble == iNPT) { - control->P[0] = control->P[1] = control->P[2] = atof(tmp[1]); - } - else if (control->ensemble == sNPT) { - control->P[0] = atof(tmp[1]); - control->P[1] = atof(tmp[2]); - control->P[2] = atof(tmp[3]); - } - } - else if (strcmp(tmp[0], "p_mass") == 0) { - // convert p_mass from fs to ps - if (control->ensemble == iNPT) { - control->Tau_P[0] = control->Tau_P[1] = control->Tau_P[2] = - atof(tmp[1]) * 1.e-3; - } - else if (control->ensemble == sNPT) { - control->Tau_P[0] = atof(tmp[1]) * 1.e-3; - control->Tau_P[1] = atof(tmp[2]) * 1.e-3; - control->Tau_P[2] = atof(tmp[3]) * 1.e-3; - } - } - else if (strcmp(tmp[0], "pt_mass") == 0) { - val = atof(tmp[1]); - control->Tau_PT[0] = control->Tau_PT[1] = control->Tau_PT[2] = - val * 1.e-3; // convert pt_mass from fs to ps - } - else if (strcmp(tmp[0], "compress") == 0) { - val = atof(tmp[1]); - control->compressibility = val; - } - else if (strcmp(tmp[0], "press_mode") == 0) { - ival = atoi(tmp[1]); - control->press_mode = ival; - } - else if (strcmp(tmp[0], "geo_format") == 0) { - ival = atoi( tmp[1] ); - control->geo_format = ival; - } - else if (strcmp(tmp[0], "write_freq") == 0) { - ival = atoi(tmp[1]); - out_control->write_steps = ival; - } - else if (strcmp(tmp[0], "traj_compress") == 0) { - ival = atoi(tmp[1]); - out_control->traj_compress = ival; - } - else if (strcmp(tmp[0], "traj_method") == 0) { - ival = atoi(tmp[1]); - out_control->traj_method = ival; - } - else if (strcmp(tmp[0], "traj_title") == 0) { - strcpy( out_control->traj_title, tmp[1] ); - } - else if (strcmp(tmp[0], "atom_info") == 0) { - ival = atoi(tmp[1]); - out_control->atom_info += ival * 4; - } - else if (strcmp(tmp[0], "atom_velocities") == 0) { - ival = atoi(tmp[1]); - out_control->atom_info += ival * 2; - } - else if (strcmp(tmp[0], "atom_forces") == 0) { - ival = atoi(tmp[1]); - out_control->atom_info += ival * 1; - } - else if (strcmp(tmp[0], "bond_info") == 0) { - ival = atoi(tmp[1]); - out_control->bond_info = ival; - } - else if (strcmp(tmp[0], "angle_info") == 0) { - ival = atoi(tmp[1]); - out_control->angle_info = ival; - } - else if (strcmp(tmp[0], "molecular_analysis") == 0) { - ival = atoi(tmp[1]); - control->molecular_analysis = ival; - } - else if (strcmp(tmp[0], "ignore") == 0) { - control->num_ignored = atoi(tmp[1]); - for (i = 0; i < control->num_ignored; ++i) - control->ignore[atoi(tmp[i+2])] = 1; - } - else if (strcmp(tmp[0], "dipole_anal") == 0) { - ival = atoi(tmp[1]); - control->dipole_anal = ival; - } - else if (strcmp(tmp[0], "freq_dipole_anal") == 0) { - ival = atoi(tmp[1]); - control->freq_dipole_anal = ival; - } - else if (strcmp(tmp[0], "diffusion_coef") == 0) { - ival = atoi(tmp[1]); - control->diffusion_coef = ival; - } - else if (strcmp(tmp[0], "freq_diffusion_coef") == 0) { - ival = atoi(tmp[1]); - control->freq_diffusion_coef = ival; - } - else if (strcmp(tmp[0], "restrict_type") == 0) { - ival = atoi(tmp[1]); - control->restrict_type = ival; - } - else { - char errmsg[128]; - snprintf(errmsg,128,"Unknown parameter %s in the control file", tmp[0]); - control->error_ptr->all(FLERR, errmsg); - } - } - - /* determine target T */ - if (control->T_mode == 0) - control->T = control->T_final; - else control->T = control->T_init; - - /* free memory allocations at the top */ - for (i = 0; i < MAX_TOKENS; i++) - free( tmp[i] ); - free( tmp ); - free( s ); - - fclose(fp); - - return REAXC_SUCCESS; -} diff --git a/src/REAXFF/reaxc_control.h b/src/REAXFF/reaxc_control.h deleted file mode 100644 index 9c818b0554..0000000000 --- a/src/REAXFF/reaxc_control.h +++ /dev/null @@ -1,35 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __CONTROL_H_ -#define __CONTROL_H_ - -#include "reaxc_types.h" - -char Read_Control_File( char*, control_params*, output_controls* ); - -#endif diff --git a/src/REAXFF/reaxc_defs.h b/src/REAXFF/reaxc_defs.h deleted file mode 100644 index a98e5b5300..0000000000 --- a/src/REAXFF/reaxc_defs.h +++ /dev/null @@ -1,155 +0,0 @@ -// clang-format off - - -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef REAX_DEFS_H -#define REAX_DEFS_H - -#if defined(__IBMC__) -#define inline __inline__ -#endif /*IBMC*/ - -#ifndef REAXC_SUCCESS -#define REAXC_SUCCESS 1 -#endif -#ifndef FAILURE -#define FAILURE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif - -#define SQR(x) ((x)*(x)) -#define CUBE(x) ((x)*(x)*(x)) -#define DEG2RAD(a) ((a)*constPI/180.0) -#define RAD2DEG(a) ((a)*180.0/constPI) -// #define MAX(x,y) (((x) > (y)) ? (x) : (y)) -// #define MIN(x,y) (((x) < (y)) ? (x) : (y)) -#define MAX3(x,y,z) MAX( MAX(x,y), z) - -#define constPI 3.14159265 -#define C_ele 332.06371 -//#define K_B 503.398008 // kcal/mol/K -#define K_B 0.831687 // amu A^2 / ps^2 / K -#define F_CONV 1e6 / 48.88821291 / 48.88821291 // --> amu A / ps^2 -#define E_CONV 0.002391 // amu A^2 / ps^2 --> kcal/mol -#define EV_to_KCALpMOL 14.400000 // ElectronVolt --> KCAL per MOLe -#define KCALpMOL_to_EV 23.02 // 23.060549 //KCAL per MOLe --> ElectronVolt -#define ECxA_to_DEBYE 4.803204 // elem. charge * Ang -> debye -#define CAL_to_JOULES 4.184000 // CALories --> JOULES -#define JOULES_to_CAL 1/4.184000 // JOULES --> CALories -#define AMU_to_GRAM 1.6605e-24 -#define ANG_to_CM 1e-8 -#define AVOGNR 6.0221367e23 -#define P_CONV 1e-24 * AVOGNR * JOULES_to_CAL - -#define MAX_STR 1024 -#define MAX_LINE 1024 -#define MAX_TOKENS 1024 -#define MAX_TOKEN_LEN 1024 - -#define NUM_INTRS 10 -#define ALMOST_ZERO 1e-10 -#define NEG_INF -1e10 -#define NO_BOND 1e-3 // 0.001 -#define HB_THRESHOLD 1e-2 // 0.01 - -#define REAX_MIN_CAP 50 -#define REAX_MIN_NBRS 100 -#define MIN_HENTRIES 100 -#define MAX_BONDS 30 -#define MIN_BONDS 25 -#define REAX_MIN_HBONDS 25 -#define MIN_3BODIES 1000 -#define MIN_GCELL_POPL 50 -#define MIN_SEND 100 -#define REAX_SAFE_ZONE 1.2 -#define REAX_SAFER_ZONE 1.4 -#define DANGER_ZONE 0.90 -#define LOOSE_ZONE 0.75 -#define MAX_3BODY_PARAM 5 -#define MAX_4BODY_PARAM 5 - -#define MAX_dV 1.01 -#define MIN_dV 0.99 -#define MAX_dT 4.00 -#define MIN_dT 0.00 - -#define MASTER_NODE 0 -#define MAX_NBRS 6 //27 -#define MYSELF 13 // encoding of relative coordinate (0,0,0) - -#define MAX_ITR 10 -#define RESTART 30 - -#define MAX_BOND 20 - -#define MAXREAXBOND 24 /* used in fix_reaxc_bonds.cpp and pair_reaxc.cpp */ -#define MAXSPECBOND 24 /* used in fix_reaxc_species.cpp and pair_reaxc.cpp */ - -/******************* ENUMERATIONS *************************/ -enum geo_formats { CUSTOM, PDB, ASCII_RESTART, BINARY_RESTART, GF_N }; - -enum restart_formats { WRITE_ASCII, WRITE_BINARY, RF_N }; - -enum ensembles { NVE, bNVT, nhNVT, sNPT, iNPT, NPT, ens_N }; - -enum lists { BONDS, OLD_BONDS, THREE_BODIES, - HBONDS, FAR_NBRS, DBOS, DDELTAS, LIST_N }; - -enum interactions { TYP_VOID, TYP_BOND, TYP_THREE_BODY, - TYP_HBOND, TYP_FAR_NEIGHBOR, TYP_DBO, TYP_DDELTA, TYP_N }; - -enum message_tags { INIT, UPDATE, BNDRY, UPDATE_BNDRY, - EXC_VEC1, EXC_VEC2, DIST_RVEC2, COLL_RVEC2, - DIST_RVECS, COLL_RVECS, INIT_DESCS, ATOM_LINES, - BOND_LINES, ANGLE_LINES, RESTART_ATOMS, TAGS_N }; - -enum errors { FILE_NOT_FOUND = -10, UNKNOWN_ATOM_TYPE = -11, - CANNOT_OPEN_FILE = -12, CANNOT_INITIALIZE = -13, - INSUFFICIENT_MEMORY = -14, UNKNOWN_OPTION = -15, - INVALID_INPUT = -16, INVALID_GEO = -17 }; - -enum exchanges { NONE, NEAR_EXCH, FULL_EXCH }; - -enum gcell_types { NO_NBRS=0, NEAR_ONLY=1, HBOND_ONLY=2, FAR_ONLY=4, - NEAR_HBOND=3, NEAR_FAR=5, HBOND_FAR=6, FULL_NBRS=7, - NATIVE=8 }; - -enum atoms { C_ATOM = 0, H_ATOM = 1, O_ATOM = 2, N_ATOM = 3, - S_ATOM = 4, SI_ATOM = 5, GE_ATOM = 6, X_ATOM = 7 }; - -enum traj_methods { REG_TRAJ, MPI_TRAJ, TF_N }; - -enum molecules { UNKNOWN, WATER }; - - -#endif diff --git a/src/REAXFF/reaxc_ffield.cpp b/src/REAXFF/reaxc_ffield.cpp deleted file mode 100644 index 0a3db31fc3..0000000000 --- a/src/REAXFF/reaxc_ffield.cpp +++ /dev/null @@ -1,740 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_ffield.h" -#include -#include -#include -#include -#include -#include "reaxc_defs.h" -#include "error.h" -#include "reaxc_tool_box.h" - -char Read_Force_Field( FILE *fp, reax_interaction *reax, - control_params *control ) -{ - char *s; - char **tmp; - char ****tor_flag; - int c, i, j, k, l, m, n, o, p, cnt; - int lgflag = control->lgflag; - int errorflag = 1; - double val; - int me = control->me; - - s = (char*) malloc(sizeof(char)*MAX_LINE); - tmp = (char**) malloc(sizeof(char*)*MAX_TOKENS); - for (i=0; i < MAX_TOKENS; i++) - tmp[i] = (char*) malloc(sizeof(char)*MAX_TOKEN_LEN); - - /* reading first header comment */ - fgets( s, MAX_LINE, fp ); - - /* line 2 is number of global parameters */ - fgets( s, MAX_LINE, fp ); - c = Tokenize( s, &tmp ); - - /* reading the number of global parameters */ - n = atoi(tmp[0]); - if (n < 1) { - if (me == 0) - control->error_ptr->warning( FLERR, "Number of globals in ffield file is 0. The file will not be read." ); - fclose(fp); - free(s); - free(tmp); - return 1; - } - - reax->gp.n_global = n; - reax->gp.l = (double*) malloc(sizeof(double)*n); - - /* see reax_types.h for mapping between l[i] and the lambdas used in ff */ - for (i=0; i < n; i++) { - fgets(s,MAX_LINE,fp); - c = Tokenize(s,&tmp); - - val = (double) atof(tmp[0]); - reax->gp.l[i] = val; - } - - control->bo_cut = 0.01 * reax->gp.l[29]; - control->nonb_low = reax->gp.l[11]; - control->nonb_cut = reax->gp.l[12]; - - /* next line is number of atom types and some comments */ - fgets( s, MAX_LINE, fp ); - c = Tokenize( s, &tmp ); - reax->num_atom_types = atoi(tmp[0]); - - /* 3 lines of comments */ - fgets(s,MAX_LINE,fp); - fgets(s,MAX_LINE,fp); - fgets(s,MAX_LINE,fp); - - /* Allocating structures in reax_interaction */ - reax->sbp = (single_body_parameters*) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(single_body_parameters), "sbp"); - reax->tbp = (two_body_parameters**) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(two_body_parameters*), "tbp"); - reax->thbp= (three_body_header***) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(three_body_header**), "thbp"); - reax->hbp = (hbond_parameters***) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(hbond_parameters**), "hbp"); - reax->fbp = (four_body_header****) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(four_body_header***), "fbp"); - tor_flag = (char****) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(char***), "tor_flag"); - - for (i = 0; i < reax->num_atom_types; i++) { - reax->tbp[i] = (two_body_parameters*) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(two_body_parameters), "tbp[i]"); - reax->thbp[i]= (three_body_header**) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(three_body_header*), "thbp[i]"); - reax->hbp[i] = (hbond_parameters**) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(hbond_parameters*), "hbp[i]"); - reax->fbp[i] = (four_body_header***) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(four_body_header**), "fbp[i]"); - tor_flag[i] = (char***) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(char**), "tor_flag[i]"); - - for (j = 0; j < reax->num_atom_types; j++) { - reax->thbp[i][j]= (three_body_header*) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(three_body_header), "thbp[i,j]"); - reax->hbp[i][j] = (hbond_parameters*) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(hbond_parameters), "hbp[i,j]"); - reax->fbp[i][j] = (four_body_header**) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(four_body_header*), "fbp[i,j]"); - tor_flag[i][j] = (char**) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(char*), "tor_flag[i,j]"); - - for (k=0; k < reax->num_atom_types; k++) { - reax->fbp[i][j][k] = (four_body_header*) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(four_body_header), "fbp[i,j,k]"); - tor_flag[i][j][k] = (char*) - scalloc(control->error_ptr, reax->num_atom_types, sizeof(char), "tor_flag[i,j,k]"); - } - } - } - - reax->gp.vdw_type = 0; - - char errmsg[1024]; - - for (i = 0; i < reax->num_atom_types; i++) { - /* line one */ - fgets( s, MAX_LINE, fp ); - c = Tokenize( s, &tmp ); - - /* Sanity checks */ - if (c == 2 && !lgflag) - control->error_ptr->all(FLERR, "Force field file requires using 'lgvdw yes'"); - - if (c < 9) { - snprintf (errmsg, 1024, "Missing parameter(s) in line %s", s); - control->error_ptr->all(FLERR, errmsg); - } - - for (j = 0; j < (int)(strlen(tmp[0])); ++j) - reax->sbp[i].name[j] = toupper( tmp[0][j] ); - - val = atof(tmp[1]); reax->sbp[i].r_s = val; - val = atof(tmp[2]); reax->sbp[i].valency = val; - val = atof(tmp[3]); reax->sbp[i].mass = val; - val = atof(tmp[4]); reax->sbp[i].r_vdw = val; - val = atof(tmp[5]); reax->sbp[i].epsilon = val; - val = atof(tmp[6]); reax->sbp[i].gamma = val; - val = atof(tmp[7]); reax->sbp[i].r_pi = val; - val = atof(tmp[8]); reax->sbp[i].valency_e = val; - reax->sbp[i].nlp_opt = 0.5 * (reax->sbp[i].valency_e-reax->sbp[i].valency); - - /* line two */ - fgets( s, MAX_LINE, fp ); - c = Tokenize( s, &tmp ); - - /* Sanity check */ - if (c < 8) { - snprintf (errmsg, 1024, "Missing parameter(s) in line %s", s); - control->error_ptr->all(FLERR, errmsg); - } - - val = atof(tmp[0]); reax->sbp[i].alpha = val; - val = atof(tmp[1]); reax->sbp[i].gamma_w = val; - val = atof(tmp[2]); reax->sbp[i].valency_boc= val; - val = atof(tmp[3]); reax->sbp[i].p_ovun5 = val; - val = atof(tmp[4]); - val = atof(tmp[5]); reax->sbp[i].chi = val; - val = atof(tmp[6]); reax->sbp[i].eta = 2.0 * val; - val = atof(tmp[7]); reax->sbp[i].p_hbond = (int) val; - - /* line 3 */ - fgets( s, MAX_LINE, fp ); - c = Tokenize( s, &tmp ); - - /* Sanity check */ - if (c < 8) { - snprintf (errmsg, 1024, "Missing parameter(s) in line %s", s); - control->error_ptr->all(FLERR, errmsg); - } - - val = atof(tmp[0]); reax->sbp[i].r_pi_pi = val; - val = atof(tmp[1]); reax->sbp[i].p_lp2 = val; - val = atof(tmp[2]); - val = atof(tmp[3]); reax->sbp[i].b_o_131 = val; - val = atof(tmp[4]); reax->sbp[i].b_o_132 = val; - val = atof(tmp[5]); reax->sbp[i].b_o_133 = val; - val = atof(tmp[6]); - val = atof(tmp[7]); - - /* line 4 */ - fgets( s, MAX_LINE, fp ); - c = Tokenize( s, &tmp ); - - /* Sanity check */ - if (c < 8) { - snprintf (errmsg, 1024, "Missing parameter(s) in line %s", s); - control->error_ptr->all(FLERR, errmsg); - } - - val = atof(tmp[0]); reax->sbp[i].p_ovun2 = val; - val = atof(tmp[1]); reax->sbp[i].p_val3 = val; - val = atof(tmp[2]); - val = atof(tmp[3]); reax->sbp[i].valency_val= val; - val = atof(tmp[4]); reax->sbp[i].p_val5 = val; - val = atof(tmp[5]); reax->sbp[i].rcore2 = val; - val = atof(tmp[6]); reax->sbp[i].ecore2 = val; - val = atof(tmp[7]); reax->sbp[i].acore2 = val; - - /* line 5, only if lgvdw is yes */ - if (lgflag) { - fgets( s, MAX_LINE, fp ); - c = Tokenize( s, &tmp ); - - /* Sanity check */ - if (c > 2) { - control->error_ptr->all(FLERR,"Force field file incompatible with 'lgvdw yes'"); - } - - val = atof(tmp[0]); reax->sbp[i].lgcij = val; - val = atof(tmp[1]); reax->sbp[i].lgre = val; - } - - if (reax->sbp[i].rcore2>0.01 && reax->sbp[i].acore2>0.01) { // Inner-wall - if (reax->sbp[i].gamma_w>0.5) { // Shielding vdWaals - if (reax->gp.vdw_type != 0 && reax->gp.vdw_type != 3) { - if (errorflag && (me == 0)) { - char errmsg[512]; - snprintf(errmsg, 512, "VdWaals-parameters for element %s " - "indicate inner wall+shielding, but earlier " - "atoms indicate different vdWaals-method. " - "This may cause division-by-zero errors. " - "Keeping vdWaals-setting for earlier atoms.", - reax->sbp[i].name); - control->error_ptr->warning(FLERR,errmsg); - } - errorflag = 0; - } else { - reax->gp.vdw_type = 3; - } - } else { // No shielding vdWaals parameters present - if (reax->gp.vdw_type != 0 && reax->gp.vdw_type != 2) { - if (me == 0) { - char errmsg[512]; - snprintf(errmsg, 512, "VdWaals-parameters for element %s " - "indicate inner wall without shielding, but earlier " - "atoms indicate different vdWaals-method. " - "This may cause division-by-zero errors. " - "Keeping vdWaals-setting for earlier atoms.", - reax->sbp[i].name); - control->error_ptr->warning(FLERR,errmsg); - } - } else { - reax->gp.vdw_type = 2; - } - } - } else { // No Inner wall parameters present - if (reax->sbp[i].gamma_w>0.5) { // Shielding vdWaals - if (reax->gp.vdw_type != 0 && reax->gp.vdw_type != 1) { - if (me == 0) { - char errmsg[512]; - snprintf(errmsg, 512, "VdWaals parameters for element %s " - "indicate shielding without inner wall, but earlier " - "elements indicate different vdWaals-method. " - "This may cause division-by-zero errors. " - "Keeping vdWaals-setting for earlier atoms.", - reax->sbp[i].name); - control->error_ptr->warning(FLERR,errmsg); - } - } else { - reax->gp.vdw_type = 1; - } - } else { - char errmsg[256]; - snprintf(errmsg, 256, "Inconsistent vdWaals-parameters: " - "No shielding or inner-wall set for element %s", - reax->sbp[i].name); - control->error_ptr->all(FLERR, errmsg); - } - } - } - - /* Equate vval3 to valf for first-row elements (25/10/2004) */ - for (i = 0; i < reax->num_atom_types; i++) - if ( reax->sbp[i].mass < 21 && - reax->sbp[i].valency_val != reax->sbp[i].valency_boc) { - if (me == 0) { - char errmsg[256]; - snprintf(errmsg, 256, "Changed valency_val to valency_boc for %s", - reax->sbp[i].name); - control->error_ptr->warning(FLERR,errmsg); - } - reax->sbp[i].valency_val = reax->sbp[i].valency_boc; - } - - /* next line is number of two body combination and some comments */ - fgets(s,MAX_LINE,fp); - c=Tokenize(s,&tmp); - - if (c == 2 && !lgflag) { - control->error_ptr->all(FLERR, "Force field file requires using 'lgvdw yes'"); - } - - l = atoi(tmp[0]); - - /* a line of comments */ - fgets(s,MAX_LINE,fp); - - for (i=0; i < l; i++) { - /* line 1 */ - fgets(s,MAX_LINE,fp); - c=Tokenize(s,&tmp); - - j = atoi(tmp[0]) - 1; - k = atoi(tmp[1]) - 1; - if ((c < 10) || (j < 0) || (k < 0)) - control->error_ptr->all(FLERR, "Inconsistent force field file"); - - if (j < reax->num_atom_types && k < reax->num_atom_types) { - - val = atof(tmp[2]); reax->tbp[j][k].De_s = val; - reax->tbp[k][j].De_s = val; - val = atof(tmp[3]); reax->tbp[j][k].De_p = val; - reax->tbp[k][j].De_p = val; - val = atof(tmp[4]); reax->tbp[j][k].De_pp = val; - reax->tbp[k][j].De_pp = val; - val = atof(tmp[5]); reax->tbp[j][k].p_be1 = val; - reax->tbp[k][j].p_be1 = val; - val = atof(tmp[6]); reax->tbp[j][k].p_bo5 = val; - reax->tbp[k][j].p_bo5 = val; - val = atof(tmp[7]); reax->tbp[j][k].v13cor = val; - reax->tbp[k][j].v13cor = val; - - val = atof(tmp[8]); reax->tbp[j][k].p_bo6 = val; - reax->tbp[k][j].p_bo6 = val; - val = atof(tmp[9]); reax->tbp[j][k].p_ovun1 = val; - reax->tbp[k][j].p_ovun1 = val; - - /* line 2 */ - fgets(s,MAX_LINE,fp); - c=Tokenize(s,&tmp); - if (c < 8) - control->error_ptr->all(FLERR, "Inconsistent force field file"); - - val = atof(tmp[0]); reax->tbp[j][k].p_be2 = val; - reax->tbp[k][j].p_be2 = val; - val = atof(tmp[1]); reax->tbp[j][k].p_bo3 = val; - reax->tbp[k][j].p_bo3 = val; - val = atof(tmp[2]); reax->tbp[j][k].p_bo4 = val; - reax->tbp[k][j].p_bo4 = val; - val = atof(tmp[3]); - - val = atof(tmp[4]); reax->tbp[j][k].p_bo1 = val; - reax->tbp[k][j].p_bo1 = val; - val = atof(tmp[5]); reax->tbp[j][k].p_bo2 = val; - reax->tbp[k][j].p_bo2 = val; - val = atof(tmp[6]); reax->tbp[j][k].ovc = val; - reax->tbp[k][j].ovc = val; - - val = atof(tmp[7]); - } - } - - for (i=0; i < reax->num_atom_types; i++) - for (j=i; j < reax->num_atom_types; j++) { - reax->tbp[i][j].r_s = 0.5 * - (reax->sbp[i].r_s + reax->sbp[j].r_s); - reax->tbp[j][i].r_s = 0.5 * - (reax->sbp[j].r_s + reax->sbp[i].r_s); - - reax->tbp[i][j].r_p = 0.5 * - (reax->sbp[i].r_pi + reax->sbp[j].r_pi); - reax->tbp[j][i].r_p = 0.5 * - (reax->sbp[j].r_pi + reax->sbp[i].r_pi); - - reax->tbp[i][j].r_pp = 0.5 * - (reax->sbp[i].r_pi_pi + reax->sbp[j].r_pi_pi); - reax->tbp[j][i].r_pp = 0.5 * - (reax->sbp[j].r_pi_pi + reax->sbp[i].r_pi_pi); - - - reax->tbp[i][j].p_boc3 = - sqrt(reax->sbp[i].b_o_132 * - reax->sbp[j].b_o_132); - reax->tbp[j][i].p_boc3 = - sqrt(reax->sbp[j].b_o_132 * - reax->sbp[i].b_o_132); - - reax->tbp[i][j].p_boc4 = - sqrt(reax->sbp[i].b_o_131 * - reax->sbp[j].b_o_131); - reax->tbp[j][i].p_boc4 = - sqrt(reax->sbp[j].b_o_131 * - reax->sbp[i].b_o_131); - - reax->tbp[i][j].p_boc5 = - sqrt(reax->sbp[i].b_o_133 * - reax->sbp[j].b_o_133); - reax->tbp[j][i].p_boc5 = - sqrt(reax->sbp[j].b_o_133 * - reax->sbp[i].b_o_133); - - - reax->tbp[i][j].D = - sqrt(reax->sbp[i].epsilon * - reax->sbp[j].epsilon); - - reax->tbp[j][i].D = - sqrt(reax->sbp[j].epsilon * - reax->sbp[i].epsilon); - - reax->tbp[i][j].alpha = - sqrt(reax->sbp[i].alpha * - reax->sbp[j].alpha); - - reax->tbp[j][i].alpha = - sqrt(reax->sbp[j].alpha * - reax->sbp[i].alpha); - - reax->tbp[i][j].r_vdW = - 2.0 * sqrt(reax->sbp[i].r_vdw * reax->sbp[j].r_vdw); - - reax->tbp[j][i].r_vdW = - 2.0 * sqrt(reax->sbp[j].r_vdw * reax->sbp[i].r_vdw); - - reax->tbp[i][j].gamma_w = - sqrt(reax->sbp[i].gamma_w * - reax->sbp[j].gamma_w); - - reax->tbp[j][i].gamma_w = - sqrt(reax->sbp[j].gamma_w * - reax->sbp[i].gamma_w); - - reax->tbp[i][j].gamma = - pow(reax->sbp[i].gamma * - reax->sbp[j].gamma,-1.5); - - reax->tbp[j][i].gamma = - pow(reax->sbp[j].gamma * - reax->sbp[i].gamma,-1.5); - - // additions for additional vdWaals interaction types - inner core - - reax->tbp[i][j].rcore = reax->tbp[j][i].rcore = - sqrt( reax->sbp[i].rcore2 * reax->sbp[j].rcore2 ); - - reax->tbp[i][j].ecore = reax->tbp[j][i].ecore = - sqrt( reax->sbp[i].ecore2 * reax->sbp[j].ecore2 ); - - reax->tbp[i][j].acore = reax->tbp[j][i].acore = - sqrt( reax->sbp[i].acore2 * reax->sbp[j].acore2 ); - - // additions for additional vdWalls interaction types lg correction - - reax->tbp[i][j].lgcij = reax->tbp[j][i].lgcij = - sqrt( reax->sbp[i].lgcij * reax->sbp[j].lgcij ); - - reax->tbp[i][j].lgre = reax->tbp[j][i].lgre = 2.0 * reax->gp.l[35] * - sqrt( reax->sbp[i].lgre*reax->sbp[j].lgre ); - - } - - fgets(s,MAX_LINE,fp); - c=Tokenize(s,&tmp); - l = atoi(tmp[0]); - - for (i=0; i < l; i++) { - fgets(s,MAX_LINE,fp); - c=Tokenize(s,&tmp); - - j = atoi(tmp[0]) - 1; - k = atoi(tmp[1]) - 1; - - if ((c < (lgflag ? 9 : 8)) || (j < 0) || (k < 0)) - control->error_ptr->all(FLERR, "Inconsistent force field file"); - - if (j < reax->num_atom_types && k < reax->num_atom_types) { - val = atof(tmp[2]); - if (val > 0.0) { - reax->tbp[j][k].D = val; - reax->tbp[k][j].D = val; - } - - val = atof(tmp[3]); - if (val > 0.0) { - reax->tbp[j][k].r_vdW = 2 * val; - reax->tbp[k][j].r_vdW = 2 * val; - } - - val = atof(tmp[4]); - if (val > 0.0) { - reax->tbp[j][k].alpha = val; - reax->tbp[k][j].alpha = val; - } - - val = atof(tmp[5]); - if (val > 0.0) { - reax->tbp[j][k].r_s = val; - reax->tbp[k][j].r_s = val; - } - - val = atof(tmp[6]); - if (val > 0.0) { - reax->tbp[j][k].r_p = val; - reax->tbp[k][j].r_p = val; - } - - val = atof(tmp[7]); - if (val > 0.0) { - reax->tbp[j][k].r_pp = val; - reax->tbp[k][j].r_pp = val; - } - - if (lgflag) { - val = atof(tmp[8]); - if (val >= 0.0) { - reax->tbp[j][k].lgcij = val; - reax->tbp[k][j].lgcij = val; - } - } - } - } - - for (i = 0; i < reax->num_atom_types; ++i) - for (j = 0; j < reax->num_atom_types; ++j) - for (k = 0; k < reax->num_atom_types; ++k) - reax->thbp[i][j][k].cnt = 0; - - fgets( s, MAX_LINE, fp ); - c = Tokenize( s, &tmp ); - l = atoi( tmp[0] ); - - for (i = 0; i < l; i++) { - fgets(s,MAX_LINE,fp); - c=Tokenize(s,&tmp); - - j = atoi(tmp[0]) - 1; - k = atoi(tmp[1]) - 1; - m = atoi(tmp[2]) - 1; - if ((c < 10) || (j < 0) || (k < 0) || (m < 0)) - control->error_ptr->all(FLERR, "Inconsistent force field file"); - - if (j < reax->num_atom_types && k < reax->num_atom_types && - m < reax->num_atom_types) { - cnt = reax->thbp[j][k][m].cnt; - reax->thbp[j][k][m].cnt++; - reax->thbp[m][k][j].cnt++; - - val = atof(tmp[3]); - reax->thbp[j][k][m].prm[cnt].theta_00 = val; - reax->thbp[m][k][j].prm[cnt].theta_00 = val; - - val = atof(tmp[4]); - reax->thbp[j][k][m].prm[cnt].p_val1 = val; - reax->thbp[m][k][j].prm[cnt].p_val1 = val; - - val = atof(tmp[5]); - reax->thbp[j][k][m].prm[cnt].p_val2 = val; - reax->thbp[m][k][j].prm[cnt].p_val2 = val; - - val = atof(tmp[6]); - reax->thbp[j][k][m].prm[cnt].p_coa1 = val; - reax->thbp[m][k][j].prm[cnt].p_coa1 = val; - - val = atof(tmp[7]); - reax->thbp[j][k][m].prm[cnt].p_val7 = val; - reax->thbp[m][k][j].prm[cnt].p_val7 = val; - - val = atof(tmp[8]); - reax->thbp[j][k][m].prm[cnt].p_pen1 = val; - reax->thbp[m][k][j].prm[cnt].p_pen1 = val; - - val = atof(tmp[9]); - reax->thbp[j][k][m].prm[cnt].p_val4 = val; - reax->thbp[m][k][j].prm[cnt].p_val4 = val; - } - } - - /* clear all entries first */ - for (i = 0; i < reax->num_atom_types; ++i) - for (j = 0; j < reax->num_atom_types; ++j) - for (k = 0; k < reax->num_atom_types; ++k) - for (m = 0; m < reax->num_atom_types; ++m) { - reax->fbp[i][j][k][m].cnt = 0; - tor_flag[i][j][k][m] = 0; - } - - /* next line is number of 4-body params and some comments */ - fgets( s, MAX_LINE, fp ); - c = Tokenize( s, &tmp ); - l = atoi( tmp[0] ); - - for (i = 0; i < l; i++) { - fgets( s, MAX_LINE, fp ); - c = Tokenize( s, &tmp ); - - j = atoi(tmp[0]) - 1; - k = atoi(tmp[1]) - 1; - m = atoi(tmp[2]) - 1; - n = atoi(tmp[3]) - 1; - if ((c < 9) || (k < 0) || (m < 0)) - control->error_ptr->all(FLERR, "Inconsistent force field file"); - - if (j >= 0 && n >= 0) { // this means the entry is not in compact form - if (j < reax->num_atom_types && k < reax->num_atom_types && - m < reax->num_atom_types && n < reax->num_atom_types) { - tor_flag[j][k][m][n] = 1; - tor_flag[n][m][k][j] = 1; - - reax->fbp[j][k][m][n].cnt = 1; - reax->fbp[n][m][k][j].cnt = 1; - - val = atof(tmp[4]); - reax->fbp[j][k][m][n].prm[0].V1 = val; - reax->fbp[n][m][k][j].prm[0].V1 = val; - - val = atof(tmp[5]); - reax->fbp[j][k][m][n].prm[0].V2 = val; - reax->fbp[n][m][k][j].prm[0].V2 = val; - - val = atof(tmp[6]); - reax->fbp[j][k][m][n].prm[0].V3 = val; - reax->fbp[n][m][k][j].prm[0].V3 = val; - - val = atof(tmp[7]); - reax->fbp[j][k][m][n].prm[0].p_tor1 = val; - reax->fbp[n][m][k][j].prm[0].p_tor1 = val; - - val = atof(tmp[8]); - reax->fbp[j][k][m][n].prm[0].p_cot1 = val; - reax->fbp[n][m][k][j].prm[0].p_cot1 = val; - } - } else { /* This means the entry is of the form 0-X-Y-0 */ - if (k < reax->num_atom_types && m < reax->num_atom_types) - for (p = 0; p < reax->num_atom_types; p++) - for (o = 0; o < reax->num_atom_types; o++) { - reax->fbp[p][k][m][o].cnt = 1; - reax->fbp[o][m][k][p].cnt = 1; - - if (tor_flag[p][k][m][o] == 0) { - reax->fbp[p][k][m][o].prm[0].V1 = atof(tmp[4]); - reax->fbp[p][k][m][o].prm[0].V2 = atof(tmp[5]); - reax->fbp[p][k][m][o].prm[0].V3 = atof(tmp[6]); - reax->fbp[p][k][m][o].prm[0].p_tor1 = atof(tmp[7]); - reax->fbp[p][k][m][o].prm[0].p_cot1 = atof(tmp[8]); - } - - if (tor_flag[o][m][k][p] == 0) { - reax->fbp[o][m][k][p].prm[0].V1 = atof(tmp[4]); - reax->fbp[o][m][k][p].prm[0].V2 = atof(tmp[5]); - reax->fbp[o][m][k][p].prm[0].V3 = atof(tmp[6]); - reax->fbp[o][m][k][p].prm[0].p_tor1 = atof(tmp[7]); - reax->fbp[o][m][k][p].prm[0].p_cot1 = atof(tmp[8]); - } - } - } - } - - /* next line is number of hydrogen bond params and some comments */ - fgets( s, MAX_LINE, fp ); - c = Tokenize( s, &tmp ); - l = atoi( tmp[0] ); - - for (i = 0; i < reax->num_atom_types; ++i) - for (j = 0; j < reax->num_atom_types; ++j) - for (k = 0; k < reax->num_atom_types; ++k) - reax->hbp[i][j][k].r0_hb = -1.0; - - for (i = 0; i < l; i++) { - fgets( s, MAX_LINE, fp ); - c = Tokenize( s, &tmp ); - - j = atoi(tmp[0]) - 1; - k = atoi(tmp[1]) - 1; - m = atoi(tmp[2]) - 1; - if ((c < 7) || (j < 0) || (k < 0) || (m < 0)) - control->error_ptr->all(FLERR, "Inconsistent force field file"); - - if (j < reax->num_atom_types && m < reax->num_atom_types) { - val = atof(tmp[3]); - reax->hbp[j][k][m].r0_hb = val; - - val = atof(tmp[4]); - reax->hbp[j][k][m].p_hb1 = val; - - val = atof(tmp[5]); - reax->hbp[j][k][m].p_hb2 = val; - - val = atof(tmp[6]); - reax->hbp[j][k][m].p_hb3 = val; - } - } - - /* deallocate helper storage */ - for (i = 0; i < MAX_TOKENS; i++) - free( tmp[i] ); - free( tmp ); - free( s ); - - - /* deallocate tor_flag */ - for (i = 0; i < reax->num_atom_types; i++) { - for (j = 0; j < reax->num_atom_types; j++) { - for (k = 0; k < reax->num_atom_types; k++) { - free( tor_flag[i][j][k] ); - } - free( tor_flag[i][j] ); - } - free( tor_flag[i] ); - } - free( tor_flag ); - - // close file - - fclose(fp); - - return REAXC_SUCCESS; -} diff --git a/src/REAXFF/reaxc_ffield.h b/src/REAXFF/reaxc_ffield.h deleted file mode 100644 index 76edfe8b7e..0000000000 --- a/src/REAXFF/reaxc_ffield.h +++ /dev/null @@ -1,36 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __FFIELD_H_ -#define __FFIELD_H_ - -#include "reaxc_types.h" -#include - -char Read_Force_Field( FILE*, reax_interaction*, control_params* ); - -#endif diff --git a/src/REAXFF/reaxc_forces.cpp b/src/REAXFF/reaxc_forces.cpp deleted file mode 100644 index 7860ab6b32..0000000000 --- a/src/REAXFF/reaxc_forces.cpp +++ /dev/null @@ -1,457 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_forces.h" -#include -#include -#include -#include "reaxc_bond_orders.h" -#include "reaxc_bonds.h" -#include "reaxc_hydrogen_bonds.h" -#include "reaxc_list.h" -#include "reaxc_multi_body.h" -#include "reaxc_nonbonded.h" -#include "reaxc_torsion_angles.h" -#include "reaxc_valence_angles.h" -#include "reaxc_vector.h" - -#include "error.h" - -interaction_function Interaction_Functions[NUM_INTRS]; - -void Dummy_Interaction( reax_system * /*system*/, control_params * /*control*/, - simulation_data * /*data*/, storage * /*workspace*/, - reax_list ** /*lists*/, output_controls * /*out_control*/ ) -{ -} - - -void Init_Force_Functions( control_params *control ) -{ - Interaction_Functions[0] = BO; - Interaction_Functions[1] = Bonds; //Dummy_Interaction; - Interaction_Functions[2] = Atom_Energy; //Dummy_Interaction; - Interaction_Functions[3] = Valence_Angles; //Dummy_Interaction; - Interaction_Functions[4] = Torsion_Angles; //Dummy_Interaction; - if (control->hbond_cut > 0) - Interaction_Functions[5] = Hydrogen_Bonds; - else Interaction_Functions[5] = Dummy_Interaction; - Interaction_Functions[6] = Dummy_Interaction; //empty - Interaction_Functions[7] = Dummy_Interaction; //empty - Interaction_Functions[8] = Dummy_Interaction; //empty - Interaction_Functions[9] = Dummy_Interaction; //empty -} - - -void Compute_Bonded_Forces( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls *out_control, - MPI_Comm /*comm*/ ) -{ - int i; - - /* Implement all force calls as function pointers */ - for (i = 0; i < NUM_INTRS; i++) { - (Interaction_Functions[i])( system, control, data, workspace, - lists, out_control ); - } -} - - -void Compute_NonBonded_Forces( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls *out_control, - MPI_Comm /*comm*/ ) -{ - - /* van der Waals and Coulomb interactions */ - if (control->tabulate == 0) - vdW_Coulomb_Energy( system, control, data, workspace, - lists, out_control ); - else - Tabulated_vdW_Coulomb_Energy( system, control, data, workspace, - lists, out_control ); -} - - -void Compute_Total_Force( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, mpi_datatypes * /*mpi_data*/ ) -{ - int i, pj; - reax_list *bonds = (*lists) + BONDS; - - for (i = 0; i < system->N; ++i) - for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) - if (i < bonds->select.bond_list[pj].nbr) { - if (control->virial == 0) - Add_dBond_to_Forces( system, i, pj, workspace, lists ); - else - Add_dBond_to_Forces_NPT( i, pj, data, workspace, lists ); - } - -} - -void Validate_Lists( reax_system *system, storage * /*workspace*/, reax_list **lists, - int step, int /*n*/, int N, int numH ) -{ - int i, comp, Hindex; - reax_list *bonds, *hbonds; - - double saferzone = system->saferzone; - - /* bond list */ - if (N > 0) { - bonds = *lists + BONDS; - - for (i = 0; i < N; ++i) { - system->my_atoms[i].num_bonds = MAX(Num_Entries(i,bonds)*2, MIN_BONDS); - - if (i < N-1) - comp = Start_Index(i+1, bonds); - else comp = bonds->num_intrs; - - if (End_Index(i, bonds) > comp) { - char errmsg[256]; - snprintf(errmsg, 256, "step%d-bondchk failed: i=%d end(i)=%d str(i+1)=%d\n", - step, i, End_Index(i,bonds), comp ); - system->error_ptr->one(FLERR,errmsg); - } - } - } - - - /* hbonds list */ - if (numH > 0) { - hbonds = *lists + HBONDS; - - for (i = 0; i < N; ++i) { - Hindex = system->my_atoms[i].Hindex; - if (Hindex > -1) { - system->my_atoms[i].num_hbonds = - (int)(MAX(Num_Entries(Hindex, hbonds)*saferzone, system->minhbonds)); - - //if( Num_Entries(i, hbonds) >= - //(Start_Index(i+1,hbonds)-Start_Index(i,hbonds))*0.90/*DANGER_ZONE*/) { - // workspace->realloc.hbonds = 1; - - if (Hindex < numH-1) - comp = Start_Index(Hindex+1, hbonds); - else comp = hbonds->num_intrs; - - if (End_Index(Hindex, hbonds) > comp) { - char errmsg[256]; - snprintf(errmsg, 256, "step%d-hbondchk failed: H=%d end(H)=%d str(H+1)=%d\n", - step, Hindex, End_Index(Hindex,hbonds), comp ); - system->error_ptr->one(FLERR, errmsg); - } - } - } - } -} - - -void Init_Forces_noQEq( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls * /*out_control*/) { - int i, j, pj; - int start_i, end_i; - int type_i, type_j; - int btop_i, num_bonds, num_hbonds; - int ihb, jhb, ihb_top, jhb_top; - int local, flag, renbr; - double cutoff; - reax_list *far_nbrs, *bonds, *hbonds; - single_body_parameters *sbp_i, *sbp_j; - two_body_parameters *twbp; - far_neighbor_data *nbr_pj; - reax_atom *atom_i, *atom_j; - - far_nbrs = *lists + FAR_NBRS; - bonds = *lists + BONDS; - hbonds = *lists + HBONDS; - - for (i = 0; i < system->n; ++i) - workspace->bond_mark[i] = 0; - for (i = system->n; i < system->N; ++i) { - workspace->bond_mark[i] = 1000; // put ghost atoms to an infinite distance - } - - num_bonds = 0; - num_hbonds = 0; - btop_i = 0; - renbr = (data->step-data->prev_steps) % control->reneighbor == 0; - - for (i = 0; i < system->N; ++i) { - atom_i = &(system->my_atoms[i]); - type_i = atom_i->type; - if (type_i < 0) continue; - start_i = Start_Index(i, far_nbrs); - end_i = End_Index(i, far_nbrs); - btop_i = End_Index( i, bonds ); - sbp_i = &(system->reax_param.sbp[type_i]); - - if (i < system->n) { - local = 1; - cutoff = MAX( control->hbond_cut, control->bond_cut ); - } else { - local = 0; - cutoff = control->bond_cut; - } - - ihb = -1; - ihb_top = -1; - if (local && control->hbond_cut > 0) { - ihb = sbp_i->p_hbond; - if (ihb == 1) - ihb_top = End_Index( atom_i->Hindex, hbonds ); - else ihb_top = -1; - } - - /* update i-j distance - check if j is within cutoff */ - for (pj = start_i; pj < end_i; ++pj) { - nbr_pj = &( far_nbrs->select.far_nbr_list[pj] ); - j = nbr_pj->nbr; - atom_j = &(system->my_atoms[j]); - - if (renbr) { - if (nbr_pj->d <= cutoff) - flag = 1; - else flag = 0; - } else { - nbr_pj->dvec[0] = atom_j->x[0] - atom_i->x[0]; - nbr_pj->dvec[1] = atom_j->x[1] - atom_i->x[1]; - nbr_pj->dvec[2] = atom_j->x[2] - atom_i->x[2]; - nbr_pj->d = rvec_Norm_Sqr( nbr_pj->dvec ); - if (nbr_pj->d <= SQR(cutoff)) { - nbr_pj->d = sqrt(nbr_pj->d); - flag = 1; - } else { - flag = 0; - } - } - - if (flag) { - type_j = atom_j->type; - if (type_j < 0) continue; - sbp_j = &(system->reax_param.sbp[type_j]); - twbp = &(system->reax_param.tbp[type_i][type_j]); - - if (local) { - /* hydrogen bond lists */ - if (control->hbond_cut > 0 && (ihb==1 || ihb==2) && - nbr_pj->d <= control->hbond_cut) { - // fprintf( stderr, "%d %d\n", atom1, atom2 ); - jhb = sbp_j->p_hbond; - if (ihb == 1 && jhb == 2) { - hbonds->select.hbond_list[ihb_top].nbr = j; - hbonds->select.hbond_list[ihb_top].scl = 1; - hbonds->select.hbond_list[ihb_top].ptr = nbr_pj; - ++ihb_top; - ++num_hbonds; - } - else if (j < system->n && ihb == 2 && jhb == 1) { - jhb_top = End_Index( atom_j->Hindex, hbonds ); - hbonds->select.hbond_list[jhb_top].nbr = i; - hbonds->select.hbond_list[jhb_top].scl = -1; - hbonds->select.hbond_list[jhb_top].ptr = nbr_pj; - Set_End_Index( atom_j->Hindex, jhb_top+1, hbonds ); - ++num_hbonds; - } - } - } - - if (//(workspace->bond_mark[i] < 3 || workspace->bond_mark[j] < 3) && - nbr_pj->d <= control->bond_cut && - BOp( workspace, bonds, control->bo_cut, - i , btop_i, nbr_pj, sbp_i, sbp_j, twbp )) { - num_bonds += 2; - ++btop_i; - - if (workspace->bond_mark[j] > workspace->bond_mark[i] + 1) - workspace->bond_mark[j] = workspace->bond_mark[i] + 1; - else if (workspace->bond_mark[i] > workspace->bond_mark[j] + 1) { - workspace->bond_mark[i] = workspace->bond_mark[j] + 1; - } - } - } - } - - Set_End_Index( i, btop_i, bonds ); - if (local && ihb == 1) - Set_End_Index( atom_i->Hindex, ihb_top, hbonds ); - } - - - workspace->realloc.num_bonds = num_bonds; - workspace->realloc.num_hbonds = num_hbonds; - - Validate_Lists( system, workspace, lists, data->step, - system->n, system->N, system->numH); -} - - -void Estimate_Storages( reax_system *system, control_params *control, - reax_list **lists, int *Htop, int *hb_top, - int *bond_top, int *num_3body ) -{ - int i, j, pj; - int start_i, end_i; - int type_i, type_j; - int ihb, jhb; - int local; - double cutoff; - double r_ij; - double C12, C34, C56; - double BO, BO_s, BO_pi, BO_pi2; - reax_list *far_nbrs; - single_body_parameters *sbp_i, *sbp_j; - two_body_parameters *twbp; - far_neighbor_data *nbr_pj; - reax_atom *atom_i, *atom_j; - - int mincap = system->mincap; - double safezone = system->safezone; - double saferzone = system->saferzone; - - far_nbrs = *lists + FAR_NBRS; - *Htop = 0; - memset( hb_top, 0, sizeof(int) * system->local_cap ); - memset( bond_top, 0, sizeof(int) * system->total_cap ); - *num_3body = 0; - - for (i = 0; i < system->N; ++i) { - atom_i = &(system->my_atoms[i]); - type_i = atom_i->type; - if (type_i < 0) continue; - start_i = Start_Index(i, far_nbrs); - end_i = End_Index(i, far_nbrs); - sbp_i = &(system->reax_param.sbp[type_i]); - - if (i < system->n) { - local = 1; - cutoff = control->nonb_cut; - ++(*Htop); - ihb = sbp_i->p_hbond; - } else { - local = 0; - cutoff = control->bond_cut; - ihb = -1; - } - - for (pj = start_i; pj < end_i; ++pj) { - nbr_pj = &( far_nbrs->select.far_nbr_list[pj] ); - j = nbr_pj->nbr; - atom_j = &(system->my_atoms[j]); - - if (nbr_pj->d <= cutoff) { - type_j = system->my_atoms[j].type; - if (type_j < 0) continue; - r_ij = nbr_pj->d; - sbp_j = &(system->reax_param.sbp[type_j]); - twbp = &(system->reax_param.tbp[type_i][type_j]); - - if (local) { - if (j < system->n || atom_i->orig_id < atom_j->orig_id) //tryQEq ||1 - ++(*Htop); - - /* hydrogen bond lists */ - if (control->hbond_cut > 0.1 && (ihb==1 || ihb==2) && - nbr_pj->d <= control->hbond_cut) { - jhb = sbp_j->p_hbond; - if (ihb == 1 && jhb == 2) - ++hb_top[i]; - else if (j < system->n && ihb == 2 && jhb == 1) - ++hb_top[j]; - } - } - - /* uncorrected bond orders */ - if (nbr_pj->d <= control->bond_cut) { - if (sbp_i->r_s > 0.0 && sbp_j->r_s > 0.0) { - C12 = twbp->p_bo1 * pow( r_ij / twbp->r_s, twbp->p_bo2 ); - BO_s = (1.0 + control->bo_cut) * exp( C12 ); - } - else BO_s = C12 = 0.0; - - if (sbp_i->r_pi > 0.0 && sbp_j->r_pi > 0.0) { - C34 = twbp->p_bo3 * pow( r_ij / twbp->r_p, twbp->p_bo4 ); - BO_pi = exp( C34 ); - } - else BO_pi = C34 = 0.0; - - if (sbp_i->r_pi_pi > 0.0 && sbp_j->r_pi_pi > 0.0) { - C56 = twbp->p_bo5 * pow( r_ij / twbp->r_pp, twbp->p_bo6 ); - BO_pi2= exp( C56 ); - } - else BO_pi2 = C56 = 0.0; - - /* Initially BO values are the uncorrected ones, page 1 */ - BO = BO_s + BO_pi + BO_pi2; - - if (BO >= control->bo_cut) { - ++bond_top[i]; - ++bond_top[j]; - } - } - } - } - } - - *Htop = (int)(MAX( *Htop * safezone, mincap * MIN_HENTRIES )); - for (i = 0; i < system->n; ++i) - hb_top[i] = (int)(MAX(hb_top[i] * saferzone, system->minhbonds)); - - for (i = 0; i < system->N; ++i) { - *num_3body += SQR(bond_top[i]); - bond_top[i] = MAX( bond_top[i] * 2, MIN_BONDS ); - } - -} - - -void Compute_Forces( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls *out_control, - mpi_datatypes *mpi_data ) -{ - - Init_Forces_noQEq( system, control, data, workspace, - lists, out_control); - - /********* bonded interactions ************/ - Compute_Bonded_Forces( system, control, data, workspace, - lists, out_control, mpi_data->world ); - - /********* nonbonded interactions ************/ - Compute_NonBonded_Forces( system, control, data, workspace, - lists, out_control, mpi_data->world ); - - /*********** total force ***************/ - Compute_Total_Force( system, control, data, workspace, lists, mpi_data ); - -} diff --git a/src/REAXFF/reaxc_forces.h b/src/REAXFF/reaxc_forces.h deleted file mode 100644 index ef23a84a18..0000000000 --- a/src/REAXFF/reaxc_forces.h +++ /dev/null @@ -1,41 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __FORCES_H_ -#define __FORCES_H_ - -#include "reaxc_types.h" -#include "reaxc_defs.h" - -extern interaction_function Interaction_Functions[NUM_INTRS]; - -void Init_Force_Functions( control_params* ); -void Compute_Forces( reax_system*, control_params*, simulation_data*, - storage*, reax_list**, output_controls*, mpi_datatypes* ); -void Estimate_Storages( reax_system*, control_params*, reax_list**, - int*, int*, int*, int* ); -#endif diff --git a/src/REAXFF/reaxc_hydrogen_bonds.cpp b/src/REAXFF/reaxc_hydrogen_bonds.cpp deleted file mode 100644 index 9d0cbbe97c..0000000000 --- a/src/REAXFF/reaxc_hydrogen_bonds.cpp +++ /dev/null @@ -1,186 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_hydrogen_bonds.h" -#include -#include "pair.h" -#include "reaxc_defs.h" -#include "reaxc_list.h" -#include "reaxc_valence_angles.h" -#include "reaxc_vector.h" - -void Hydrogen_Bonds( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls * /*out_control*/ ) -{ - int i, j, k, pi, pk; - int type_i, type_j, type_k; - int start_j, end_j, hb_start_j, hb_end_j; - int hblist[MAX_BONDS]; - int itr, top; - int num_hb_intrs = 0; - ivec rel_jk; - double r_jk, theta, cos_theta, sin_xhz4, cos_xhz1, sin_theta2; - double e_hb, exp_hb2, exp_hb3, CEhb1, CEhb2, CEhb3; - rvec dcos_theta_di, dcos_theta_dj, dcos_theta_dk; - rvec dvec_jk, force, ext_press; - hbond_parameters *hbp; - bond_order_data *bo_ij; - bond_data *pbond_ij; - far_neighbor_data *nbr_jk; - reax_list *bonds, *hbonds; - bond_data *bond_list; - hbond_data *hbond_list; - - // tally variables - double fi_tmp[3], fk_tmp[3], delij[3], delkj[3]; - - bonds = (*lists) + BONDS; - bond_list = bonds->select.bond_list; - hbonds = (*lists) + HBONDS; - hbond_list = hbonds->select.hbond_list; - - for (j = 0; j < system->n; ++j) - if (system->reax_param.sbp[system->my_atoms[j].type].p_hbond == 1) { - type_j = system->my_atoms[j].type; - start_j = Start_Index(j, bonds); - end_j = End_Index(j, bonds); - hb_start_j = Start_Index( system->my_atoms[j].Hindex, hbonds ); - hb_end_j = End_Index( system->my_atoms[j].Hindex, hbonds ); - if (type_j < 0) continue; - - top = 0; - for (pi = start_j; pi < end_j; ++pi) { - pbond_ij = &( bond_list[pi] ); - i = pbond_ij->nbr; - type_i = system->my_atoms[i].type; - if (type_i < 0) continue; - bo_ij = &(pbond_ij->bo_data); - - if ( system->reax_param.sbp[type_i].p_hbond == 2 && - bo_ij->BO >= HB_THRESHOLD ) - hblist[top++] = pi; - } - - for (pk = hb_start_j; pk < hb_end_j; ++pk) { - /* set k's varibles */ - k = hbond_list[pk].nbr; - type_k = system->my_atoms[k].type; - if (type_k < 0) continue; - nbr_jk = hbond_list[pk].ptr; - r_jk = nbr_jk->d; - rvec_Scale( dvec_jk, hbond_list[pk].scl, nbr_jk->dvec ); - - for (itr = 0; itr < top; ++itr) { - pi = hblist[itr]; - pbond_ij = &( bonds->select.bond_list[pi] ); - i = pbond_ij->nbr; - - if (system->my_atoms[i].orig_id != system->my_atoms[k].orig_id) { - bo_ij = &(pbond_ij->bo_data); - type_i = system->my_atoms[i].type; - if (type_i < 0) continue; - hbp = &(system->reax_param.hbp[ type_i ][ type_j ][ type_k ]); - if (hbp->r0_hb <= 0.0) continue; - ++num_hb_intrs; - - Calculate_Theta( pbond_ij->dvec, pbond_ij->d, dvec_jk, r_jk, - &theta, &cos_theta ); - /* the derivative of cos(theta) */ - Calculate_dCos_Theta( pbond_ij->dvec, pbond_ij->d, dvec_jk, r_jk, - &dcos_theta_di, &dcos_theta_dj, - &dcos_theta_dk ); - - /* hyrogen bond energy*/ - sin_theta2 = sin( theta/2.0 ); - sin_xhz4 = SQR(sin_theta2); - sin_xhz4 *= sin_xhz4; - cos_xhz1 = ( 1.0 - cos_theta ); - exp_hb2 = exp( -hbp->p_hb2 * bo_ij->BO ); - exp_hb3 = exp( -hbp->p_hb3 * ( hbp->r0_hb / r_jk + - r_jk / hbp->r0_hb - 2.0 ) ); - - data->my_en.e_hb += e_hb = - hbp->p_hb1 * (1.0 - exp_hb2) * exp_hb3 * sin_xhz4; - - CEhb1 = hbp->p_hb1 * hbp->p_hb2 * exp_hb2 * exp_hb3 * sin_xhz4; - CEhb2 = -hbp->p_hb1/2.0 * (1.0 - exp_hb2) * exp_hb3 * cos_xhz1; - CEhb3 = -hbp->p_hb3 * - (-hbp->r0_hb / SQR(r_jk) + 1.0 / hbp->r0_hb) * e_hb; - - /* hydrogen bond forces */ - bo_ij->Cdbo += CEhb1; // dbo term - - if (control->virial == 0) { - // dcos terms - rvec_ScaledAdd( workspace->f[i], +CEhb2, dcos_theta_di ); - rvec_ScaledAdd( workspace->f[j], +CEhb2, dcos_theta_dj ); - rvec_ScaledAdd( workspace->f[k], +CEhb2, dcos_theta_dk ); - // dr terms - rvec_ScaledAdd( workspace->f[j], -CEhb3/r_jk, dvec_jk ); - rvec_ScaledAdd( workspace->f[k], +CEhb3/r_jk, dvec_jk ); - } - else { - rvec_Scale( force, +CEhb2, dcos_theta_di ); // dcos terms - rvec_Add( workspace->f[i], force ); - rvec_iMultiply( ext_press, pbond_ij->rel_box, force ); - rvec_ScaledAdd( data->my_ext_press, 1.0, ext_press ); - - rvec_ScaledAdd( workspace->f[j], +CEhb2, dcos_theta_dj ); - - ivec_Scale( rel_jk, hbond_list[pk].scl, nbr_jk->rel_box ); - rvec_Scale( force, +CEhb2, dcos_theta_dk ); - rvec_Add( workspace->f[k], force ); - rvec_iMultiply( ext_press, rel_jk, force ); - rvec_ScaledAdd( data->my_ext_press, 1.0, ext_press ); - // dr terms - rvec_ScaledAdd( workspace->f[j], -CEhb3/r_jk, dvec_jk ); - - rvec_Scale( force, CEhb3/r_jk, dvec_jk ); - rvec_Add( workspace->f[k], force ); - rvec_iMultiply( ext_press, rel_jk, force ); - rvec_ScaledAdd( data->my_ext_press, 1.0, ext_press ); - } - - /* tally into per-atom virials */ - if (system->pair_ptr->vflag_atom || system->pair_ptr->evflag) { - rvec_ScaledSum( delij, 1., system->my_atoms[j].x, - -1., system->my_atoms[i].x ); - rvec_ScaledSum( delkj, 1., system->my_atoms[j].x, - -1., system->my_atoms[k].x ); - - rvec_Scale(fi_tmp, CEhb2, dcos_theta_di); - rvec_Scale(fk_tmp, CEhb2, dcos_theta_dk); - rvec_ScaledAdd(fk_tmp, CEhb3/r_jk, dvec_jk); - - system->pair_ptr->ev_tally3(i,j,k,e_hb,0.0,fi_tmp,fk_tmp,delij,delkj); - } - } - } - } - } -} diff --git a/src/REAXFF/reaxc_hydrogen_bonds.h b/src/REAXFF/reaxc_hydrogen_bonds.h deleted file mode 100644 index 1d88f1edcf..0000000000 --- a/src/REAXFF/reaxc_hydrogen_bonds.h +++ /dev/null @@ -1,36 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __HBONDS_H_ -#define __HBONDS_H_ - -#include "reaxc_types.h" - -void Hydrogen_Bonds( reax_system*, control_params*, simulation_data*, - storage*, reax_list**, output_controls* ); - -#endif diff --git a/src/REAXFF/reaxc_init_md.cpp b/src/REAXFF/reaxc_init_md.cpp deleted file mode 100644 index b08ca8a59d..0000000000 --- a/src/REAXFF/reaxc_init_md.cpp +++ /dev/null @@ -1,261 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_init_md.h" -#include -#include -#include -#include -#include "reaxc_defs.h" -#include "reaxc_allocate.h" -#include "reaxc_forces.h" -#include "reaxc_io_tools.h" -#include "reaxc_list.h" -#include "reaxc_lookup.h" -#include "reaxc_reset_tools.h" -#include "reaxc_tool_box.h" - -#include "error.h" -#include "fmt/format.h" - -int Init_System(reax_system *system, control_params *control, char * /*msg*/) -{ - int i; - reax_atom *atom; - - int mincap = system->mincap; - double safezone = system->safezone; - double saferzone = system->saferzone; - - // determine the local and total capacity - - system->local_cap = MAX((int)(system->n * safezone), mincap); - system->total_cap = MAX((int)(system->N * safezone), mincap); - - /* estimate numH and Hcap */ - system->numH = 0; - if (control->hbond_cut > 0) - for (i = 0; i < system->n; ++i) { - atom = &(system->my_atoms[i]); - if (system->reax_param.sbp[ atom->type ].p_hbond == 1 && atom->type >= 0) - atom->Hindex = system->numH++; - else atom->Hindex = -1; - } - system->Hcap = (int)(MAX(system->numH * saferzone, mincap)); - - return REAXC_SUCCESS; -} - - -int Init_Simulation_Data(reax_system *system, control_params *control, - simulation_data *data, char * /*msg*/) -{ - Reset_Simulation_Data(data, control->virial); - - /* initialize the timer(s) */ - if (system->my_rank == MASTER_NODE) { - data->timing.start = MPI_Wtime(); - } - - data->step = data->prev_steps = 0; - - return REAXC_SUCCESS; -} - -void Init_Taper(control_params *control, storage *workspace) -{ - double d1, d7; - double swa, swa2, swa3; - double swb, swb2, swb3; - LAMMPS_NS::Error *error = control->error_ptr; - - swa = control->nonb_low; - swb = control->nonb_cut; - - if (fabs(swa) > 0.01 && control->me == 0) - error->warning(FLERR, "Non-zero lower Taper-radius cutoff"); - - if (swb < 0) { - error->all(FLERR,"Negative upper Taper-radius cutoff"); - } - else if (swb < 5 && control->me == 0) { - char errmsg[256]; - snprintf(errmsg, 256, "Very low Taper-radius cutoff: %f", swb); - error->warning(FLERR, errmsg); - } - - d1 = swb - swa; - d7 = pow(d1, 7.0); - swa2 = SQR(swa); - swa3 = CUBE(swa); - swb2 = SQR(swb); - swb3 = CUBE(swb); - - workspace->Tap[7] = 20.0 / d7; - workspace->Tap[6] = -70.0 * (swa + swb) / d7; - workspace->Tap[5] = 84.0 * (swa2 + 3.0*swa*swb + swb2) / d7; - workspace->Tap[4] = -35.0 * (swa3 + 9.0*swa2*swb + 9.0*swa*swb2 + swb3) / d7; - workspace->Tap[3] = 140.0 * (swa3*swb + 3.0*swa2*swb2 + swa*swb3) / d7; - workspace->Tap[2] =-210.0 * (swa3*swb2 + swa2*swb3) / d7; - workspace->Tap[1] = 140.0 * swa3 * swb3 / d7; - workspace->Tap[0] = (-35.0*swa3*swb2*swb2 + 21.0*swa2*swb3*swb2 - - 7.0*swa*swb3*swb3 + swb3*swb3*swb) / d7; -} - - -int Init_Workspace(reax_system *system, control_params *control, - storage *workspace, char *msg) -{ - int ret; - - ret = Allocate_Workspace(system, control, workspace, - system->local_cap, system->total_cap, msg); - if (ret != REAXC_SUCCESS) - return ret; - - memset(&(workspace->realloc), 0, sizeof(reallocate_data)); - Reset_Workspace(system, workspace); - - /* Initialize the Taper function */ - Init_Taper(control, workspace); - - return REAXC_SUCCESS; -} - - -/************** setup communication data structures **************/ -int Init_MPI_Datatypes(reax_system *system, storage * /*workspace*/, - mpi_datatypes *mpi_data, MPI_Comm comm, char * /*msg*/) -{ - - /* setup the world */ - mpi_data->world = comm; - MPI_Comm_size(comm, &(system->wsize)); - - return REAXC_SUCCESS; -} - -int Init_Lists(reax_system *system, control_params *control, - simulation_data * /*data*/, storage * /*workspace*/, reax_list **lists, - mpi_datatypes * /*mpi_data*/, char * /*msg*/) -{ - int i, total_hbonds, total_bonds, bond_cap, num_3body, cap_3body, Htop; - int *hb_top, *bond_top; - - int mincap = system->mincap; - double safezone = system->safezone; - double saferzone = system->saferzone; - LAMMPS_NS::Error *error = system->error_ptr; - - bond_top = (int*) calloc(system->total_cap, sizeof(int)); - hb_top = (int*) calloc(system->local_cap, sizeof(int)); - Estimate_Storages(system, control, lists, - &Htop, hb_top, bond_top, &num_3body); - - if (control->hbond_cut > 0) { - /* init H indexes */ - total_hbonds = 0; - for (i = 0; i < system->n; ++i) { - system->my_atoms[i].num_hbonds = hb_top[i]; - total_hbonds += hb_top[i]; - } - total_hbonds = (int)(MAX(total_hbonds*saferzone,mincap*system->minhbonds)); - - if (!Make_List(system->Hcap, total_hbonds, TYP_HBOND, - *lists+HBONDS)) - error->one(FLERR, "Not enough space for hbonds list."); - - (*lists+HBONDS)->error_ptr = system->error_ptr; - } - - total_bonds = 0; - for (i = 0; i < system->N; ++i) { - system->my_atoms[i].num_bonds = bond_top[i]; - total_bonds += bond_top[i]; - } - bond_cap = (int)(MAX(total_bonds*safezone, mincap*MIN_BONDS)); - - if (!Make_List(system->total_cap, bond_cap, TYP_BOND, - *lists+BONDS)) - error->one(FLERR, "Not enough space for bonds list."); - - (*lists+BONDS)->error_ptr = system->error_ptr; - - /* 3bodies list */ - cap_3body = (int)(MAX(num_3body*safezone, MIN_3BODIES)); - if (!Make_List(bond_cap, cap_3body, TYP_THREE_BODY, - *lists+THREE_BODIES)) - error->one(FLERR,"Problem in initializing angles list."); - - (*lists+THREE_BODIES)->error_ptr = system->error_ptr; - - free(hb_top); - free(bond_top); - - return REAXC_SUCCESS; -} - -void Initialize(reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls *out_control, - mpi_datatypes *mpi_data, MPI_Comm comm) -{ - char msg[MAX_STR]; - LAMMPS_NS::Error *error = system->error_ptr; - - if (Init_MPI_Datatypes(system,workspace,mpi_data,comm,msg) == FAILURE) - error->one(FLERR,"init_mpi_datatypes: could not create datatypes. " - "Mpi_data could not be initialized! Terminating."); - - if (Init_System(system,control,msg) == FAILURE) - error->one(FLERR,"Error on: {}. System could not be " - "initialized! Terminating.",msg); - - if (Init_Simulation_Data( system,control,data,msg) == FAILURE) - error->one(FLERR,"Error on: {}. Sim_data could not be " - "initialized! Terminating.",msg); - - if (Init_Workspace( system,control,workspace,msg) == FAILURE) - error->one(FLERR,"init_workspace: not enough memory. " - "Workspace could not be initialized. Terminating."); - - if (Init_Lists(system, control, data, workspace, lists, mpi_data, msg) ==FAILURE) - error->one(FLERR,"Error on: {}. System could not be " - "initialized. Terminating.",msg); - - if (Init_Output_Files(system,control,out_control,mpi_data,msg)== FAILURE) - error->one(FLERR,"Error on: {}. Could not open output files! " - "Terminating.",msg); - - if (control->tabulate) - if (Init_Lookup_Tables(system,control,workspace,mpi_data,msg) == FAILURE) - error->one(FLERR,"Error on: {}. Could not create lookup " - "table. Terminating.",msg); - - - Init_Force_Functions(control); -} diff --git a/src/REAXFF/reaxc_init_md.h b/src/REAXFF/reaxc_init_md.h deleted file mode 100644 index b7c1d38bbc..0000000000 --- a/src/REAXFF/reaxc_init_md.h +++ /dev/null @@ -1,36 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __INIT_MD_H_ -#define __INIT_MD_H_ - -#include "reaxc_types.h" -#include - -void Initialize( reax_system*, control_params*, simulation_data*, storage*, - reax_list**, output_controls*, mpi_datatypes*, MPI_Comm ); -#endif diff --git a/src/REAXFF/reaxc_io_tools.cpp b/src/REAXFF/reaxc_io_tools.cpp deleted file mode 100644 index dc9cf55789..0000000000 --- a/src/REAXFF/reaxc_io_tools.cpp +++ /dev/null @@ -1,151 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_io_tools.h" -#include -#include -#include "reaxc_defs.h" -#include "reaxc_system_props.h" -#include "reaxc_traj.h" - -int Init_Output_Files( reax_system *system, control_params *control, - output_controls *out_control, mpi_datatypes *mpi_data, - char *msg ) -{ - char temp[MAX_STR+8]; - int ret; - - if (out_control->write_steps > 0) { - ret = Init_Traj( system, control, out_control, mpi_data, msg ); - if (ret == FAILURE) - return ret; - } - - if (system->my_rank == MASTER_NODE) { - /* These files are written only by the master node */ - if (out_control->energy_update_freq > 0) { - - /* init potentials file */ - sprintf( temp, "%s.pot", control->sim_name ); - if ((out_control->pot = fopen( temp, "w" )) != nullptr) { - fflush( out_control->pot ); - } else { - strcpy( msg, "init_out_controls: .pot file could not be opened\n" ); - return FAILURE; - } - - /* init log file */ - } - - /* init pressure file */ - if ( control->ensemble == NPT || - control->ensemble == iNPT || - control->ensemble == sNPT) { - sprintf( temp, "%s.prs", control->sim_name ); - if ((out_control->prs = fopen( temp, "w" )) != nullptr) { - fprintf(out_control->prs,"%8s%13s%13s%13s%13s%13s%13s%13s\n", - "step", "Pint/norm[x]", "Pint/norm[y]", "Pint/norm[z]", - "Pext/Ptot[x]", "Pext/Ptot[y]", "Pext/Ptot[z]", "Pkin/V" ); - fflush( out_control->prs ); - } else { - strcpy(msg,"init_out_controls: .prs file couldn't be opened\n"); - return FAILURE; - } - } - } - - return REAXC_SUCCESS; -} - - -/************************ close output files ************************/ -int Close_Output_Files( reax_system *system, control_params * /* control */, - output_controls *out_control, mpi_datatypes * /*mpi_data*/ ) -{ - if (out_control->write_steps > 0) - End_Traj( system->my_rank, out_control ); - - if (system->my_rank == MASTER_NODE) { - if (out_control->pot) { - fclose( out_control->pot ); - out_control->pot = nullptr; - } - - if (out_control->prs) { - fclose(out_control->prs); - out_control->prs = nullptr; - } - } - - return REAXC_SUCCESS; -} - - -void Output_Results( reax_system *system, control_params *control, - simulation_data *data, reax_list **lists, - output_controls *out_control, mpi_datatypes *mpi_data ) -{ - - if ((out_control->energy_update_freq > 0 && - data->step%out_control->energy_update_freq == 0) || - (out_control->write_steps > 0 && - data->step%out_control->write_steps == 0)) { - /* update system-wide energies */ - Compute_System_Energy( system, data, mpi_data->world ); - - /* output energies */ - if ( system->my_rank == MASTER_NODE && - out_control->energy_update_freq > 0 && - data->step % out_control->energy_update_freq == 0) { - - if (control->virial && out_control->prs) { - fprintf( out_control->prs, - "%8d%13.6f%13.6f%13.6f%13.6f%13.6f%13.6f%13.6f\n", - data->step, - data->int_press[0], data->int_press[1], data->int_press[2], - data->ext_press[0], data->ext_press[1], data->ext_press[2], - data->kin_press ); - - fprintf( out_control->prs, - "%8s%13.6f%13.6f%13.6f%13.6f%13.6f%13.6f%13.6f\n", - "",system->big_box.box_norms[0], system->big_box.box_norms[1], - system->big_box.box_norms[2], - data->tot_press[0], data->tot_press[1], data->tot_press[2], - system->big_box.V ); - - fflush( out_control->prs); - } - } - - /* write current frame */ - if ( out_control->write_steps > 0 && - (data->step-data->prev_steps) % out_control->write_steps == 0) { - Append_Frame( system, control, data, lists, out_control, mpi_data ); - } - } - -} diff --git a/src/REAXFF/reaxc_io_tools.h b/src/REAXFF/reaxc_io_tools.h deleted file mode 100644 index b43d6cd11f..0000000000 --- a/src/REAXFF/reaxc_io_tools.h +++ /dev/null @@ -1,39 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __IO_TOOLS_H_ -#define __IO_TOOLS_H_ - -#include "reaxc_types.h" - -int Init_Output_Files( reax_system*, control_params*, - output_controls*, mpi_datatypes*, char* ); -int Close_Output_Files( reax_system*, control_params*, - output_controls*, mpi_datatypes* ); -void Output_Results( reax_system*, control_params*, simulation_data*, - reax_list**, output_controls*, mpi_datatypes* ); -#endif diff --git a/src/REAXFF/reaxc_list.cpp b/src/REAXFF/reaxc_list.cpp deleted file mode 100644 index 4620a7a3c8..0000000000 --- a/src/REAXFF/reaxc_list.cpp +++ /dev/null @@ -1,149 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_list.h" -#include "reaxc_defs.h" -#include "reaxc_tool_box.h" - -#include "error.h" - -/************* allocate list space ******************/ -int Make_List(int n, int num_intrs, int type, reax_list *l ) -{ - l->allocated = 1; - - l->n = n; - l->num_intrs = num_intrs; - - if (l->index) sfree(l->error_ptr, l->index, "list:index"); - if (l->end_index) sfree(l->error_ptr, l->end_index, "list:end_index"); - l->index = (int*) smalloc(l->error_ptr, n * sizeof(int), "list:index"); - l->end_index = (int*) smalloc(l->error_ptr, n * sizeof(int), "list:end_index"); - - l->type = type; - - switch(l->type) { - case TYP_VOID: - if (l->select.v) sfree(l->error_ptr, l->select.v, "list:v"); - l->select.v = (void*) smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(void*), "list:v"); - break; - - case TYP_THREE_BODY: - if (l->select.three_body_list) sfree(l->error_ptr, l->select.three_body_list,"list:three_bodies"); - l->select.three_body_list = (three_body_interaction_data*) - smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(three_body_interaction_data), - "list:three_bodies"); - break; - - case TYP_BOND: - if (l->select.bond_list) sfree(l->error_ptr, l->select.bond_list,"list:bonds"); - l->select.bond_list = (bond_data*) - smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(bond_data), "list:bonds"); - break; - - case TYP_DBO: - if (l->select.dbo_list) sfree(l->error_ptr, l->select.dbo_list,"list:dbonds"); - l->select.dbo_list = (dbond_data*) - smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(dbond_data), "list:dbonds"); - break; - - case TYP_DDELTA: - if (l->select.dDelta_list) sfree(l->error_ptr, l->select.dDelta_list,"list:dDeltas"); - l->select.dDelta_list = (dDelta_data*) - smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(dDelta_data), "list:dDeltas"); - break; - - case TYP_FAR_NEIGHBOR: - if (l->select.far_nbr_list) sfree(l->error_ptr, l->select.far_nbr_list,"list:far_nbrs"); - l->select.far_nbr_list = (far_neighbor_data*) - smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(far_neighbor_data), "list:far_nbrs"); - break; - - case TYP_HBOND: - if (l->select.hbond_list) sfree(l->error_ptr, l->select.hbond_list,"list:hbonds"); - l->select.hbond_list = (hbond_data*) - smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(hbond_data), "list:hbonds"); - break; - - default: - char errmsg[128]; - snprintf(errmsg, 128, "No %d list type defined", l->type); - l->error_ptr->one(FLERR,errmsg); - } - - return REAXC_SUCCESS; -} - - -void Delete_List( reax_list *l ) -{ - if (l->allocated == 0) - return; - l->allocated = 0; - - sfree(l->error_ptr, l->index, "list:index" ); - sfree(l->error_ptr, l->end_index, "list:end_index" ); - l->index = nullptr; - l->end_index = nullptr; - - switch(l->type) { - case TYP_VOID: - sfree(l->error_ptr, l->select.v, "list:v" ); - l->select.v = nullptr; - break; - case TYP_HBOND: - sfree(l->error_ptr, l->select.hbond_list, "list:hbonds" ); - l->select.hbond_list = nullptr; - break; - case TYP_FAR_NEIGHBOR: - sfree(l->error_ptr, l->select.far_nbr_list, "list:far_nbrs" ); - l->select.far_nbr_list = nullptr; - break; - case TYP_BOND: - sfree(l->error_ptr, l->select.bond_list, "list:bonds" ); - l->select.bond_list = nullptr; - break; - case TYP_DBO: - sfree(l->error_ptr, l->select.dbo_list, "list:dbos" ); - l->select.dbo_list = nullptr; - break; - case TYP_DDELTA: - sfree(l->error_ptr, l->select.dDelta_list, "list:dDeltas" ); - l->select.dDelta_list = nullptr; - break; - case TYP_THREE_BODY: - sfree(l->error_ptr, l->select.three_body_list, "list:three_bodies" ); - l->select.three_body_list = nullptr; - break; - - default: - char errmsg[128]; - snprintf(errmsg, 128, "No %d list type defined", l->type); - l->error_ptr->all(FLERR,errmsg); - } -} - diff --git a/src/REAXFF/reaxc_list.h b/src/REAXFF/reaxc_list.h deleted file mode 100644 index 323656537d..0000000000 --- a/src/REAXFF/reaxc_list.h +++ /dev/null @@ -1,69 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __LIST_H_ -#define __LIST_H_ - -#include "reaxc_types.h" - -int Make_List( int, int, int, reax_list* ); -void Delete_List( reax_list* ); - -inline int Num_Entries(int,reax_list*); -inline int Start_Index( int, reax_list* ); -inline int End_Index( int, reax_list* ); -inline void Set_Start_Index(int,int,reax_list*); -inline void Set_End_Index(int,int,reax_list*); - -#if defined(LAMMPS_REAX) -inline int Num_Entries( int i, reax_list *l ) -{ - return l->end_index[i] - l->index[i]; -} - -inline int Start_Index( int i, reax_list *l ) -{ - return l->index[i]; -} - -inline int End_Index( int i, reax_list *l ) -{ - return l->end_index[i]; -} - -inline void Set_Start_Index( int i, int val, reax_list *l ) -{ - l->index[i] = val; -} - -inline void Set_End_Index( int i, int val, reax_list *l ) -{ - l->end_index[i] = val; -} -#endif // LAMMPS_REAX - -#endif diff --git a/src/REAXFF/reaxc_lookup.cpp b/src/REAXFF/reaxc_lookup.cpp deleted file mode 100644 index 33922e2022..0000000000 --- a/src/REAXFF/reaxc_lookup.cpp +++ /dev/null @@ -1,294 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_lookup.h" -#include -#include -#include "reaxc_nonbonded.h" -#include "reaxc_tool_box.h" - -void Tridiagonal_Solve( const double *a, const double *b, - double *c, double *d, double *x, unsigned int n) { - int i; - double id; - - c[0] /= b[0]; /* Division by zero risk. */ - d[0] /= b[0]; /* Division by zero would imply a singular matrix. */ - for (i = 1; i < (int)n; i++) { - id = (b[i] - c[i-1] * a[i]); /* Division by zero risk. */ - c[i] /= id; /* Last value calculated is redundant. */ - d[i] = (d[i] - d[i-1] * a[i])/id; - } - - x[n - 1] = d[n - 1]; - for (i = n - 2; i >= 0; i--) - x[i] = d[i] - c[i] * x[i + 1]; -} - - -void Natural_Cubic_Spline( LAMMPS_NS::Error* error_ptr, const double *h, const double *f, - cubic_spline_coef *coef, unsigned int n ) -{ - int i; - double *a, *b, *c, *d, *v; - - /* allocate space for the linear system */ - a = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); - b = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); - c = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); - d = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); - v = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); - - /* build the linear system */ - a[0] = a[1] = a[n-1] = 0; - for (i = 2; i < (int)n-1; ++i) - a[i] = h[i-1]; - - b[0] = b[n-1] = 0; - for (i = 1; i < (int)n-1; ++i) - b[i] = 2 * (h[i-1] + h[i]); - - c[0] = c[n-2] = c[n-1] = 0; - for (i = 1; i < (int)n-2; ++i) - c[i] = h[i]; - - d[0] = d[n-1] = 0; - for (i = 1; i < (int)n-1; ++i) - d[i] = 6 * ((f[i+1]-f[i])/h[i] - (f[i]-f[i-1])/h[i-1]); - - v[0] = 0; - v[n-1] = 0; - Tridiagonal_Solve( &(a[1]), &(b[1]), &(c[1]), &(d[1]), &(v[1]), n-2 ); - - for (i = 1; i < (int)n; ++i) { - coef[i-1].d = (v[i] - v[i-1]) / (6*h[i-1]); - coef[i-1].c = v[i]/2; - coef[i-1].b = (f[i]-f[i-1])/h[i-1] + h[i-1]*(2*v[i] + v[i-1])/6; - coef[i-1].a = f[i]; - } - - sfree(error_ptr, a, "cubic_spline:a" ); - sfree(error_ptr, b, "cubic_spline:b" ); - sfree(error_ptr, c, "cubic_spline:c" ); - sfree(error_ptr, d, "cubic_spline:d" ); - sfree(error_ptr, v, "cubic_spline:v" ); -} - - - -void Complete_Cubic_Spline( LAMMPS_NS::Error* error_ptr, const double *h, const double *f, double v0, double vlast, - cubic_spline_coef *coef, unsigned int n ) -{ - int i; - double *a, *b, *c, *d, *v; - - /* allocate space for the linear system */ - a = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); - b = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); - c = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); - d = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); - v = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); - - /* build the linear system */ - a[0] = 0; - for (i = 1; i < (int)n; ++i) - a[i] = h[i-1]; - - b[0] = 2*h[0]; - for (i = 1; i < (int)n; ++i) - b[i] = 2 * (h[i-1] + h[i]); - - c[n-1] = 0; - for (i = 0; i < (int)n-1; ++i) - c[i] = h[i]; - - d[0] = 6 * (f[1]-f[0])/h[0] - 6 * v0; - d[n-1] = 6 * vlast - 6 * (f[n-1]-f[n-2]/h[n-2]); - for (i = 1; i < (int)n-1; ++i) - d[i] = 6 * ((f[i+1]-f[i])/h[i] - (f[i]-f[i-1])/h[i-1]); - - Tridiagonal_Solve( &(a[0]), &(b[0]), &(c[0]), &(d[0]), &(v[0]), n ); - - for (i = 1; i < (int)n; ++i) { - coef[i-1].d = (v[i] - v[i-1]) / (6*h[i-1]); - coef[i-1].c = v[i]/2; - coef[i-1].b = (f[i]-f[i-1])/h[i-1] + h[i-1]*(2*v[i] + v[i-1])/6; - coef[i-1].a = f[i]; - } - - sfree(error_ptr, a, "cubic_spline:a" ); - sfree(error_ptr, b, "cubic_spline:b" ); - sfree(error_ptr, c, "cubic_spline:c" ); - sfree(error_ptr, d, "cubic_spline:d" ); - sfree(error_ptr, v, "cubic_spline:v" ); -} - - -int Init_Lookup_Tables( reax_system *system, control_params *control, - storage *workspace, mpi_datatypes *mpi_data, char * /*msg*/ ) -{ - int i, j, r; - int num_atom_types; - int existing_types[REAX_MAX_ATOM_TYPES], aggregated[REAX_MAX_ATOM_TYPES]; - double dr; - double *h, *fh, *fvdw, *fele, *fCEvd, *fCEclmb; - double v0_vdw, v0_ele, vlast_vdw, vlast_ele; - LR_lookup_table ** & LR = system->LR; - - /* initializations */ - v0_vdw = 0; - v0_ele = 0; - vlast_vdw = 0; - vlast_ele = 0; - - num_atom_types = system->reax_param.num_atom_types; - dr = control->nonb_cut / control->tabulate; - h = (double*) - smalloc(system->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:h"); - fh = (double*) - smalloc(system->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:fh"); - fvdw = (double*) - smalloc(system->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:fvdw"); - fCEvd = (double*) - smalloc(system->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:fCEvd"); - fele = (double*) - smalloc(system->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:fele"); - fCEclmb = (double*) - smalloc(system->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:fCEclmb"); - - LR = (LR_lookup_table**) - scalloc(system->error_ptr, num_atom_types, sizeof(LR_lookup_table*), "lookup:LR"); - for (i = 0; i < num_atom_types; ++i) - LR[i] = (LR_lookup_table*) - scalloc(system->error_ptr, num_atom_types, sizeof(LR_lookup_table), "lookup:LR[i]"); - - for (i = 0; i < REAX_MAX_ATOM_TYPES; ++i) - existing_types[i] = 0; - for (i = 0; i < system->n; ++i) - existing_types[ system->my_atoms[i].type ] = 1; - - MPI_Allreduce( existing_types, aggregated, REAX_MAX_ATOM_TYPES, - MPI_INT, MPI_SUM, mpi_data->world ); - - for (i = 0; i < num_atom_types; ++i) { - if (aggregated[i]) { - for (j = i; j < num_atom_types; ++j) { - if (aggregated[j]) { - LR[i][j].xmin = 0; - LR[i][j].xmax = control->nonb_cut; - LR[i][j].n = control->tabulate + 2; - LR[i][j].dx = dr; - LR[i][j].inv_dx = control->tabulate / control->nonb_cut; - LR[i][j].y = (LR_data*) - smalloc(system->error_ptr, LR[i][j].n * sizeof(LR_data), "lookup:LR[i,j].y"); - LR[i][j].H = (cubic_spline_coef*) - smalloc(system->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].H"); - LR[i][j].vdW = (cubic_spline_coef*) - smalloc(system->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].vdW"); - LR[i][j].CEvd = (cubic_spline_coef*) - smalloc(system->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].CEvd"); - LR[i][j].ele = (cubic_spline_coef*) - smalloc(system->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].ele"); - LR[i][j].CEclmb = (cubic_spline_coef*) - smalloc(system->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef), - "lookup:LR[i,j].CEclmb"); - - for (r = 1; r <= control->tabulate; ++r) { - LR_vdW_Coulomb( system, workspace, control, i, j, r * dr, &(LR[i][j].y[r]) ); - h[r] = LR[i][j].dx; - fh[r] = LR[i][j].y[r].H; - fvdw[r] = LR[i][j].y[r].e_vdW; - fCEvd[r] = LR[i][j].y[r].CEvd; - fele[r] = LR[i][j].y[r].e_ele; - fCEclmb[r] = LR[i][j].y[r].CEclmb; - } - - // init the start-end points - h[r] = LR[i][j].dx; - v0_vdw = LR[i][j].y[1].CEvd; - v0_ele = LR[i][j].y[1].CEclmb; - fh[r] = fh[r-1]; - fvdw[r] = fvdw[r-1]; - fCEvd[r] = fCEvd[r-1]; - fele[r] = fele[r-1]; - fCEclmb[r] = fCEclmb[r-1]; - vlast_vdw = fCEvd[r-1]; - vlast_ele = fele[r-1]; - - Natural_Cubic_Spline( control->error_ptr, &h[1], &fh[1], - &(LR[i][j].H[1]), control->tabulate+1); - - Complete_Cubic_Spline( control->error_ptr, &h[1], &fvdw[1], v0_vdw, vlast_vdw, - &(LR[i][j].vdW[1]), control->tabulate+1); - - Natural_Cubic_Spline( control->error_ptr, &h[1], &fCEvd[1], - &(LR[i][j].CEvd[1]), control->tabulate+1); - - Complete_Cubic_Spline( control->error_ptr, &h[1], &fele[1], v0_ele, vlast_ele, - &(LR[i][j].ele[1]), control->tabulate+1); - - Natural_Cubic_Spline( control->error_ptr, &h[1], &fCEclmb[1], - &(LR[i][j].CEclmb[1]), control->tabulate+1); - } else { - LR[i][j].n = 0; - } - } - } - } - free(h); - free(fh); - free(fvdw); - free(fCEvd); - free(fele); - free(fCEclmb); - - return 1; -} - - -void Deallocate_Lookup_Tables( reax_system *system ) -{ - int i, j; - int ntypes; - LR_lookup_table ** & LR = system->LR; - - ntypes = system->reax_param.num_atom_types; - - for (i = 0; i < ntypes; ++i) { - for (j = i; j < ntypes; ++j) - if (LR[i][j].n) { - sfree(system->error_ptr, LR[i][j].y, "LR[i,j].y" ); - sfree(system->error_ptr, LR[i][j].H, "LR[i,j].H" ); - sfree(system->error_ptr, LR[i][j].vdW, "LR[i,j].vdW" ); - sfree(system->error_ptr, LR[i][j].CEvd, "LR[i,j].CEvd" ); - sfree(system->error_ptr, LR[i][j].ele, "LR[i,j].ele" ); - sfree(system->error_ptr, LR[i][j].CEclmb, "LR[i,j].CEclmb" ); - } - sfree(system->error_ptr, LR[i], "LR[i]" ); - } - sfree(system->error_ptr, LR, "LR" ); -} diff --git a/src/REAXFF/reaxc_lookup.h b/src/REAXFF/reaxc_lookup.h deleted file mode 100644 index abbac23e1f..0000000000 --- a/src/REAXFF/reaxc_lookup.h +++ /dev/null @@ -1,49 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __LOOKUP_H_ -#define __LOOKUP_H_ - -#include "reaxc_types.h" -namespace LAMMPS_NS { class Error; } - -void Tridiagonal_Solve( const double *a, const double *b, - double *c, double *d, double *x, unsigned int n); - -void Natural_Cubic_Spline( LAMMPS_NS::Error*, const double *h, const double *f, - cubic_spline_coef *coef, unsigned int n ); - -void Complete_Cubic_Spline( LAMMPS_NS::Error*, const double *h, const double *f, - double v0, double vlast, cubic_spline_coef *coef, - unsigned int n ); - -int Init_Lookup_Tables( reax_system*, control_params*, storage*, - mpi_datatypes*, char* ); - -void Deallocate_Lookup_Tables( reax_system* ); - -#endif diff --git a/src/REAXFF/reaxc_multi_body.h b/src/REAXFF/reaxc_multi_body.h deleted file mode 100644 index 5d60140b44..0000000000 --- a/src/REAXFF/reaxc_multi_body.h +++ /dev/null @@ -1,36 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __MULTI_BODY_H_ -#define __MULTI_BODY_H_ - -#include "reaxc_types.h" - -void Atom_Energy( reax_system*, control_params*, simulation_data*, - storage*, reax_list**, output_controls* ); - -#endif diff --git a/src/REAXFF/reaxc_nonbonded.cpp b/src/REAXFF/reaxc_nonbonded.cpp deleted file mode 100644 index 31265bd2e8..0000000000 --- a/src/REAXFF/reaxc_nonbonded.cpp +++ /dev/null @@ -1,433 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_nonbonded.h" -#include -#include "pair.h" -#include "reaxc_defs.h" -#include "reaxc_types.h" -#include "reaxc_list.h" -#include "reaxc_vector.h" - -void vdW_Coulomb_Energy( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls * /*out_control*/ ) -{ - int i, j, pj, natoms; - int start_i, end_i, flag; - rc_tagint orig_i, orig_j; - double p_vdW1, p_vdW1i; - double powr_vdW1, powgi_vdW1; - double tmp, r_ij, fn13, exp1, exp2; - double Tap, dTap, dfn13, CEvd, CEclmb, de_core; - double dr3gamij_1, dr3gamij_3; - double e_ele, e_vdW, e_core, SMALL = 0.0001; - double e_lg, de_lg, r_ij5, r_ij6, re6; - rvec temp, ext_press; - two_body_parameters *twbp; - far_neighbor_data *nbr_pj; - reax_list *far_nbrs; - - // Tallying variables: - double pe_vdw, f_tmp, delij[3]; - - natoms = system->n; - far_nbrs = (*lists) + FAR_NBRS; - p_vdW1 = system->reax_param.gp.l[28]; - p_vdW1i = 1.0 / p_vdW1; - e_core = 0; - e_vdW = 0; - e_lg = de_lg = 0.0; - - for (i = 0; i < natoms; ++i) { - if (system->my_atoms[i].type < 0) continue; - start_i = Start_Index(i, far_nbrs); - end_i = End_Index(i, far_nbrs); - orig_i = system->my_atoms[i].orig_id; - - for (pj = start_i; pj < end_i; ++pj) { - nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); - j = nbr_pj->nbr; - if (system->my_atoms[j].type < 0) continue; - orig_j = system->my_atoms[j].orig_id; - - flag = 0; - if (nbr_pj->d <= control->nonb_cut) { - if (j < natoms) flag = 1; - else if (orig_i < orig_j) flag = 1; - else if (orig_i == orig_j) { - if (nbr_pj->dvec[2] > SMALL) flag = 1; - else if (fabs(nbr_pj->dvec[2]) < SMALL) { - if (nbr_pj->dvec[1] > SMALL) flag = 1; - else if (fabs(nbr_pj->dvec[1]) < SMALL && nbr_pj->dvec[0] > SMALL) - flag = 1; - } - } - } - - if (flag) { - - r_ij = nbr_pj->d; - twbp = &(system->reax_param.tbp[ system->my_atoms[i].type ] - [ system->my_atoms[j].type ]); - - Tap = workspace->Tap[7] * r_ij + workspace->Tap[6]; - Tap = Tap * r_ij + workspace->Tap[5]; - Tap = Tap * r_ij + workspace->Tap[4]; - Tap = Tap * r_ij + workspace->Tap[3]; - Tap = Tap * r_ij + workspace->Tap[2]; - Tap = Tap * r_ij + workspace->Tap[1]; - Tap = Tap * r_ij + workspace->Tap[0]; - - dTap = 7*workspace->Tap[7] * r_ij + 6*workspace->Tap[6]; - dTap = dTap * r_ij + 5*workspace->Tap[5]; - dTap = dTap * r_ij + 4*workspace->Tap[4]; - dTap = dTap * r_ij + 3*workspace->Tap[3]; - dTap = dTap * r_ij + 2*workspace->Tap[2]; - dTap += workspace->Tap[1]/r_ij; - - /*vdWaals Calculations*/ - if (system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) - { // shielding - powr_vdW1 = pow(r_ij, p_vdW1); - powgi_vdW1 = pow( 1.0 / twbp->gamma_w, p_vdW1); - - fn13 = pow( powr_vdW1 + powgi_vdW1, p_vdW1i ); - exp1 = exp( twbp->alpha * (1.0 - fn13 / twbp->r_vdW) ); - exp2 = exp( 0.5 * twbp->alpha * (1.0 - fn13 / twbp->r_vdW) ); - - e_vdW = twbp->D * (exp1 - 2.0 * exp2); - data->my_en.e_vdW += Tap * e_vdW; - - dfn13 = pow( powr_vdW1 + powgi_vdW1, p_vdW1i - 1.0) * - pow(r_ij, p_vdW1 - 2.0); - - CEvd = dTap * e_vdW - - Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) * dfn13; - } - else { // no shielding - exp1 = exp( twbp->alpha * (1.0 - r_ij / twbp->r_vdW) ); - exp2 = exp( 0.5 * twbp->alpha * (1.0 - r_ij / twbp->r_vdW) ); - - e_vdW = twbp->D * (exp1 - 2.0 * exp2); - data->my_en.e_vdW += Tap * e_vdW; - - CEvd = dTap * e_vdW - - Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; - } - - if (system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) - { // inner wall - e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); - data->my_en.e_vdW += Tap * e_core; - - de_core = -(twbp->acore/twbp->rcore) * e_core; - CEvd += dTap * e_core + Tap * de_core / r_ij; - - // lg correction, only if lgvdw is yes - if (control->lgflag) { - r_ij5 = pow( r_ij, 5.0 ); - r_ij6 = pow( r_ij, 6.0 ); - re6 = pow( twbp->lgre, 6.0 ); - e_lg = -(twbp->lgcij/( r_ij6 + re6 )); - data->my_en.e_vdW += Tap * e_lg; - - de_lg = -6.0 * e_lg * r_ij5 / ( r_ij6 + re6 ) ; - CEvd += dTap * e_lg + Tap * de_lg / r_ij; - } - - } - - /*Coulomb Calculations*/ - dr3gamij_1 = ( r_ij * r_ij * r_ij + twbp->gamma ); - dr3gamij_3 = pow( dr3gamij_1 , 0.33333333333333 ); - - tmp = Tap / dr3gamij_3; - data->my_en.e_ele += e_ele = - C_ele * system->my_atoms[i].q * system->my_atoms[j].q * tmp; - - CEclmb = C_ele * system->my_atoms[i].q * system->my_atoms[j].q * - ( dTap - Tap * r_ij / dr3gamij_1 ) / dr3gamij_3; - - /* tally into per-atom energy */ - if (system->pair_ptr->evflag || system->pair_ptr->vflag_atom) { - pe_vdw = Tap * (e_vdW + e_core + e_lg); - rvec_ScaledSum( delij, 1., system->my_atoms[i].x, - -1., system->my_atoms[j].x ); - f_tmp = -(CEvd + CEclmb); - system->pair_ptr->ev_tally(i,j,natoms,1,pe_vdw,e_ele, - f_tmp,delij[0],delij[1],delij[2]); - } - - if (control->virial == 0) { - rvec_ScaledAdd( workspace->f[i], -(CEvd + CEclmb), nbr_pj->dvec ); - rvec_ScaledAdd( workspace->f[j], +(CEvd + CEclmb), nbr_pj->dvec ); - } else { /* NPT, iNPT or sNPT */ - rvec_Scale( temp, CEvd + CEclmb, nbr_pj->dvec ); - - rvec_ScaledAdd( workspace->f[i], -1., temp ); - rvec_Add( workspace->f[j], temp ); - - rvec_iMultiply( ext_press, nbr_pj->rel_box, temp ); - rvec_Add( data->my_ext_press, ext_press ); - } - } - } - } - - Compute_Polarization_Energy( system, data ); -} - - - -void Tabulated_vdW_Coulomb_Energy( reax_system *system,control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, - output_controls * /*out_control*/ ) -{ - int i, j, pj, r, natoms; - int type_i, type_j, tmin, tmax; - int start_i, end_i, flag; - rc_tagint orig_i, orig_j; - double r_ij, base, dif; - double e_vdW, e_ele; - double CEvd, CEclmb, SMALL = 0.0001; - double f_tmp, delij[3]; - - rvec temp, ext_press; - far_neighbor_data *nbr_pj; - reax_list *far_nbrs; - LR_lookup_table *t; - LR_lookup_table ** & LR = system->LR; - - natoms = system->n; - far_nbrs = (*lists) + FAR_NBRS; - - e_ele = e_vdW = 0; - - for (i = 0; i < natoms; ++i) { - type_i = system->my_atoms[i].type; - if (type_i < 0) continue; - start_i = Start_Index(i,far_nbrs); - end_i = End_Index(i,far_nbrs); - orig_i = system->my_atoms[i].orig_id; - - for (pj = start_i; pj < end_i; ++pj) { - nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); - j = nbr_pj->nbr; - type_j = system->my_atoms[j].type; - if (type_j < 0) continue; - orig_j = system->my_atoms[j].orig_id; - - flag = 0; - if (nbr_pj->d <= control->nonb_cut) { - if (j < natoms) flag = 1; - else if (orig_i < orig_j) flag = 1; - else if (orig_i == orig_j) { - if (nbr_pj->dvec[2] > SMALL) flag = 1; - else if (fabs(nbr_pj->dvec[2]) < SMALL) { - if (nbr_pj->dvec[1] > SMALL) flag = 1; - else if (fabs(nbr_pj->dvec[1]) < SMALL && nbr_pj->dvec[0] > SMALL) - flag = 1; - } - } - } - - if (flag) { - - r_ij = nbr_pj->d; - tmin = MIN( type_i, type_j ); - tmax = MAX( type_i, type_j ); - t = &( LR[tmin][tmax] ); - - /* Cubic Spline Interpolation */ - r = (int)(r_ij * t->inv_dx); - if (r == 0) ++r; - base = (double)(r+1) * t->dx; - dif = r_ij - base; - - e_vdW = ((t->vdW[r].d*dif + t->vdW[r].c)*dif + t->vdW[r].b)*dif + - t->vdW[r].a; - - e_ele = ((t->ele[r].d*dif + t->ele[r].c)*dif + t->ele[r].b)*dif + - t->ele[r].a; - e_ele *= system->my_atoms[i].q * system->my_atoms[j].q; - - data->my_en.e_vdW += e_vdW; - data->my_en.e_ele += e_ele; - - CEvd = ((t->CEvd[r].d*dif + t->CEvd[r].c)*dif + t->CEvd[r].b)*dif + - t->CEvd[r].a; - - CEclmb = ((t->CEclmb[r].d*dif+t->CEclmb[r].c)*dif+t->CEclmb[r].b)*dif + - t->CEclmb[r].a; - CEclmb *= system->my_atoms[i].q * system->my_atoms[j].q; - - /* tally into per-atom energy */ - if (system->pair_ptr->evflag || system->pair_ptr->vflag_atom) { - rvec_ScaledSum( delij, 1., system->my_atoms[i].x, - -1., system->my_atoms[j].x ); - f_tmp = -(CEvd + CEclmb); - system->pair_ptr->ev_tally(i,j,natoms,1,e_vdW,e_ele, - f_tmp,delij[0],delij[1],delij[2]); - } - - if (control->virial == 0) { - rvec_ScaledAdd( workspace->f[i], -(CEvd + CEclmb), nbr_pj->dvec ); - rvec_ScaledAdd( workspace->f[j], +(CEvd + CEclmb), nbr_pj->dvec ); - } else { // NPT, iNPT or sNPT - rvec_Scale( temp, CEvd + CEclmb, nbr_pj->dvec ); - - rvec_ScaledAdd( workspace->f[i], -1., temp ); - rvec_Add( workspace->f[j], temp ); - - rvec_iMultiply( ext_press, nbr_pj->rel_box, temp ); - rvec_Add( data->my_ext_press, ext_press ); - } - } - } - } - - Compute_Polarization_Energy( system, data ); -} - - - -void Compute_Polarization_Energy( reax_system *system, simulation_data *data ) -{ - int i, type_i; - double q, en_tmp; - - data->my_en.e_pol = 0.0; - for (i = 0; i < system->n; i++) { - type_i = system->my_atoms[i].type; - if (type_i < 0) continue; - q = system->my_atoms[i].q; - - en_tmp = KCALpMOL_to_EV * (system->reax_param.sbp[type_i].chi * q + - (system->reax_param.sbp[type_i].eta / 2.) * SQR(q)); - data->my_en.e_pol += en_tmp; - - /* tally into per-atom energy */ - if (system->pair_ptr->evflag) - system->pair_ptr->ev_tally(i,i,system->n,1,0.0,en_tmp,0.0,0.0,0.0,0.0); - } -} - -void LR_vdW_Coulomb( reax_system *system, storage *workspace, - control_params *control, int i, int j, double r_ij, LR_data *lr ) -{ - double p_vdW1 = system->reax_param.gp.l[28]; - double p_vdW1i = 1.0 / p_vdW1; - double powr_vdW1, powgi_vdW1; - double tmp, fn13, exp1, exp2; - double Tap, dTap, dfn13; - double dr3gamij_1, dr3gamij_3; - double e_core, de_core; - double e_lg, de_lg, r_ij5, r_ij6, re6; - two_body_parameters *twbp; - - twbp = &(system->reax_param.tbp[i][j]); - e_core = 0; - de_core = 0; - e_lg = de_lg = 0.0; - - /* calculate taper and its derivative */ - Tap = workspace->Tap[7] * r_ij + workspace->Tap[6]; - Tap = Tap * r_ij + workspace->Tap[5]; - Tap = Tap * r_ij + workspace->Tap[4]; - Tap = Tap * r_ij + workspace->Tap[3]; - Tap = Tap * r_ij + workspace->Tap[2]; - Tap = Tap * r_ij + workspace->Tap[1]; - Tap = Tap * r_ij + workspace->Tap[0]; - - dTap = 7*workspace->Tap[7] * r_ij + 6*workspace->Tap[6]; - dTap = dTap * r_ij + 5*workspace->Tap[5]; - dTap = dTap * r_ij + 4*workspace->Tap[4]; - dTap = dTap * r_ij + 3*workspace->Tap[3]; - dTap = dTap * r_ij + 2*workspace->Tap[2]; - dTap += workspace->Tap[1]/r_ij; - - /*vdWaals Calculations*/ - if (system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) - { // shielding - powr_vdW1 = pow(r_ij, p_vdW1); - powgi_vdW1 = pow( 1.0 / twbp->gamma_w, p_vdW1); - - fn13 = pow( powr_vdW1 + powgi_vdW1, p_vdW1i ); - exp1 = exp( twbp->alpha * (1.0 - fn13 / twbp->r_vdW) ); - exp2 = exp( 0.5 * twbp->alpha * (1.0 - fn13 / twbp->r_vdW) ); - - lr->e_vdW = Tap * twbp->D * (exp1 - 2.0 * exp2); - - dfn13 = pow( powr_vdW1 + powgi_vdW1, p_vdW1i-1.0) * pow(r_ij, p_vdW1-2.0); - - lr->CEvd = dTap * twbp->D * (exp1 - 2.0 * exp2) - - Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) * dfn13; - } - else { // no shielding - exp1 = exp( twbp->alpha * (1.0 - r_ij / twbp->r_vdW) ); - exp2 = exp( 0.5 * twbp->alpha * (1.0 - r_ij / twbp->r_vdW) ); - - lr->e_vdW = Tap * twbp->D * (exp1 - 2.0 * exp2); - lr->CEvd = dTap * twbp->D * (exp1 - 2.0 * exp2) - - Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; - } - - if (system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) - { // inner wall - e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); - lr->e_vdW += Tap * e_core; - - de_core = -(twbp->acore/twbp->rcore) * e_core; - lr->CEvd += dTap * e_core + Tap * de_core / r_ij; - - // lg correction, only if lgvdw is yes - if (control->lgflag) { - r_ij5 = pow( r_ij, 5.0 ); - r_ij6 = pow( r_ij, 6.0 ); - re6 = pow( twbp->lgre, 6.0 ); - e_lg = -(twbp->lgcij/( r_ij6 + re6 )); - lr->e_vdW += Tap * e_lg; - - de_lg = -6.0 * e_lg * r_ij5 / ( r_ij6 + re6 ) ; - lr->CEvd += dTap * e_lg + Tap * de_lg/r_ij; - } - - } - - - /* Coulomb calculations */ - dr3gamij_1 = ( r_ij * r_ij * r_ij + twbp->gamma ); - dr3gamij_3 = pow( dr3gamij_1 , 0.33333333333333 ); - - tmp = Tap / dr3gamij_3; - lr->H = EV_to_KCALpMOL * tmp; - lr->e_ele = C_ele * tmp; - - lr->CEclmb = C_ele * ( dTap - Tap * r_ij / dr3gamij_1 ) / dr3gamij_3; -} diff --git a/src/REAXFF/reaxc_nonbonded.h b/src/REAXFF/reaxc_nonbonded.h deleted file mode 100644 index 64c69e9f30..0000000000 --- a/src/REAXFF/reaxc_nonbonded.h +++ /dev/null @@ -1,44 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __NONBONDED_H_ -#define __NONBONDED_H_ - -#include "reaxc_types.h" - -void vdW_Coulomb_Energy( reax_system*, control_params*, simulation_data*, - storage*, reax_list**, output_controls* ); - -void Tabulated_vdW_Coulomb_Energy( reax_system*, control_params*, - simulation_data*, storage*, - reax_list**, output_controls* ); - -void Compute_Polarization_Energy( reax_system*, simulation_data* ); - -void LR_vdW_Coulomb( reax_system*, storage*, control_params*, - int, int, double, LR_data* ); -#endif diff --git a/src/REAXFF/reaxc_reset_tools.cpp b/src/REAXFF/reaxc_reset_tools.cpp deleted file mode 100644 index adfde2494c..0000000000 --- a/src/REAXFF/reaxc_reset_tools.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_reset_tools.h" -#include "reaxc_defs.h" -#include "reaxc_list.h" -#include "reaxc_tool_box.h" -#include "reaxc_vector.h" - -#include "error.h" - -#include -#include - -void Reset_Atoms( reax_system* system, control_params *control ) -{ - int i; - reax_atom *atom; - - system->numH = 0; - if (control->hbond_cut > 0) - for (i = 0; i < system->n; ++i) { - atom = &(system->my_atoms[i]); - if (atom->type < 0) continue; - if (system->reax_param.sbp[ atom->type ].p_hbond == 1) - atom->Hindex = system->numH++; - else atom->Hindex = -1; - } -} - - -void Reset_Energies( energy_data *en ) -{ - en->e_bond = 0; - en->e_ov = 0; - en->e_un = 0; - en->e_lp = 0; - en->e_ang = 0; - en->e_pen = 0; - en->e_coa = 0; - en->e_hb = 0; - en->e_tor = 0; - en->e_con = 0; - en->e_vdW = 0; - en->e_ele = 0; - en->e_pol = 0; - - en->e_pot = 0; - en->e_kin = 0; - en->e_tot = 0; -} - - -void Reset_Temperatures( simulation_data *data ) -{ - data->therm.T = 0; -} - - -void Reset_Pressures( simulation_data *data ) -{ - data->flex_bar.P_scalar = 0; - rtensor_MakeZero( data->flex_bar.P ); - - data->iso_bar.P = 0; - rvec_MakeZero( data->int_press ); - rvec_MakeZero( data->my_ext_press ); - rvec_MakeZero( data->ext_press ); -} - - -void Reset_Simulation_Data( simulation_data* data, int /*virial*/ ) -{ - Reset_Energies( &data->my_en ); - Reset_Energies( &data->sys_en ); - Reset_Temperatures( data ); - Reset_Pressures( data ); -} - - -void Reset_Timing( reax_timing *rt ) -{ - rt->total = MPI_Wtime(); - rt->comm = 0; - rt->nbrs = 0; - rt->init_forces = 0; - rt->bonded = 0; - rt->nonb = 0; - rt->qEq = 0; - rt->s_matvecs = 0; - rt->t_matvecs = 0; -} - -void Reset_Workspace( reax_system *system, storage *workspace ) -{ - memset( workspace->total_bond_order, 0, system->total_cap * sizeof( double ) ); - memset( workspace->dDeltap_self, 0, system->total_cap * sizeof( rvec ) ); - memset( workspace->CdDelta, 0, system->total_cap * sizeof( double ) ); - memset( workspace->f, 0, system->total_cap * sizeof( rvec ) ); - -} - - -void Reset_Neighbor_Lists( reax_system *system, control_params *control, - storage *workspace, reax_list **lists ) -{ - int i, total_bonds, Hindex, total_hbonds; - reax_list *bonds, *hbonds; - - /* bonds list */ - if (system->N > 0) { - bonds = (*lists) + BONDS; - total_bonds = 0; - - /* reset start-end indexes */ - for (i = 0; i < system->N; ++i) { - Set_Start_Index( i, total_bonds, bonds ); - Set_End_Index( i, total_bonds, bonds ); - total_bonds += system->my_atoms[i].num_bonds; - } - - /* is reallocation needed? */ - if (total_bonds >= bonds->num_intrs * DANGER_ZONE) { - workspace->realloc.bonds = 1; - if (total_bonds >= bonds->num_intrs) { - char errmsg[256]; - snprintf(errmsg, 256, "Not enough space for bonds! total=%d allocated=%d\n", - total_bonds, bonds->num_intrs); - control->error_ptr->one(FLERR, errmsg); - } - } - } - - if (control->hbond_cut > 0 && system->numH > 0) { - hbonds = (*lists) + HBONDS; - total_hbonds = 0; - - /* reset start-end indexes */ - for (i = 0; i < system->n; ++i) { - Hindex = system->my_atoms[i].Hindex; - if (Hindex > -1) { - Set_Start_Index( Hindex, total_hbonds, hbonds ); - Set_End_Index( Hindex, total_hbonds, hbonds ); - total_hbonds += system->my_atoms[i].num_hbonds; - } - } - - /* is reallocation needed? */ - if (total_hbonds >= hbonds->num_intrs * 0.90/*DANGER_ZONE*/) { - workspace->realloc.hbonds = 1; - if (total_hbonds >= hbonds->num_intrs) { - char errmsg[256]; - snprintf(errmsg, 256, "Not enough space for hbonds! total=%d allocated=%d\n", - total_hbonds, hbonds->num_intrs); - control->error_ptr->one(FLERR, errmsg); - } - } - } -} - - -void Reset( reax_system *system, control_params *control, simulation_data *data, - storage *workspace, reax_list **lists ) -{ - Reset_Atoms( system, control ); - - Reset_Simulation_Data( data, control->virial ); - - Reset_Workspace( system, workspace ); - - Reset_Neighbor_Lists( system, control, workspace, lists ); - -} diff --git a/src/REAXFF/reaxc_reset_tools.h b/src/REAXFF/reaxc_reset_tools.h deleted file mode 100644 index 15e584eaac..0000000000 --- a/src/REAXFF/reaxc_reset_tools.h +++ /dev/null @@ -1,41 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __RESET_TOOLS_H_ -#define __RESET_TOOLS_H_ - -#include "reaxc_types.h" - -void Reset_Pressures( simulation_data* ); -void Reset_Simulation_Data( simulation_data*, int ); -void Reset_Timing( reax_timing* ); -void Reset_Workspace( reax_system*, storage* ); -void Reset_Neighbor_Lists( reax_system*, control_params*, storage*, - reax_list** ); -void Reset( reax_system*, control_params*, simulation_data*, storage*, - reax_list** ); -#endif diff --git a/src/REAXFF/reaxc_system_props.cpp b/src/REAXFF/reaxc_system_props.cpp deleted file mode 100644 index ec50692c6f..0000000000 --- a/src/REAXFF/reaxc_system_props.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_system_props.h" -#include -#include "reaxc_defs.h" - -void Compute_System_Energy( reax_system *system, simulation_data *data, - MPI_Comm comm ) -{ - double my_en[15], sys_en[15]; - - my_en[0] = data->my_en.e_bond; - my_en[1] = data->my_en.e_ov; - my_en[2] = data->my_en.e_un; - my_en[3] = data->my_en.e_lp; - my_en[4] = data->my_en.e_ang; - my_en[5] = data->my_en.e_pen; - my_en[6] = data->my_en.e_coa; - my_en[7] = data->my_en.e_hb; - my_en[8] = data->my_en.e_tor; - my_en[9] = data->my_en.e_con; - my_en[10] = data->my_en.e_vdW; - my_en[11] = data->my_en.e_ele; - my_en[12] = data->my_en.e_pol; - my_en[13] = data->my_en.e_kin; - MPI_Reduce( my_en, sys_en, 14, MPI_DOUBLE, MPI_SUM, MASTER_NODE, comm ); - - data->my_en.e_pot = data->my_en.e_bond + - data->my_en.e_ov + data->my_en.e_un + data->my_en.e_lp + - data->my_en.e_ang + data->my_en.e_pen + data->my_en.e_coa + - data->my_en.e_hb + - data->my_en.e_tor + data->my_en.e_con + - data->my_en.e_vdW + data->my_en.e_ele + data->my_en.e_pol; - - data->my_en.e_tot = data->my_en.e_pot + E_CONV * data->my_en.e_kin; - - if (system->my_rank == MASTER_NODE) { - data->sys_en.e_bond = sys_en[0]; - data->sys_en.e_ov = sys_en[1]; - data->sys_en.e_un = sys_en[2]; - data->sys_en.e_lp = sys_en[3]; - data->sys_en.e_ang = sys_en[4]; - data->sys_en.e_pen = sys_en[5]; - data->sys_en.e_coa = sys_en[6]; - data->sys_en.e_hb = sys_en[7]; - data->sys_en.e_tor = sys_en[8]; - data->sys_en.e_con = sys_en[9]; - data->sys_en.e_vdW = sys_en[10]; - data->sys_en.e_ele = sys_en[11]; - data->sys_en.e_pol = sys_en[12]; - data->sys_en.e_kin = sys_en[13]; - - data->sys_en.e_pot = data->sys_en.e_bond + - data->sys_en.e_ov + data->sys_en.e_un + data->sys_en.e_lp + - data->sys_en.e_ang + data->sys_en.e_pen + data->sys_en.e_coa + - data->sys_en.e_hb + - data->sys_en.e_tor + data->sys_en.e_con + - data->sys_en.e_vdW + data->sys_en.e_ele + data->sys_en.e_pol; - - data->sys_en.e_tot = data->sys_en.e_pot + E_CONV * data->sys_en.e_kin; - } -} diff --git a/src/REAXFF/reaxc_system_props.h b/src/REAXFF/reaxc_system_props.h deleted file mode 100644 index 27c80d02bf..0000000000 --- a/src/REAXFF/reaxc_system_props.h +++ /dev/null @@ -1,36 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __SYSTEM_PROP_H_ -#define __SYSTEM_PROP_H_ - -#include "reaxc_types.h" -#include - -void Compute_System_Energy( reax_system*, simulation_data*, MPI_Comm ); - -#endif diff --git a/src/REAXFF/reaxc_tool_box.cpp b/src/REAXFF/reaxc_tool_box.cpp deleted file mode 100644 index b047954d22..0000000000 --- a/src/REAXFF/reaxc_tool_box.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_tool_box.h" -#include "reaxc_defs.h" - -#include -#include -#include - -#include "error.h" - -int Tokenize( char* s, char*** tok ) -{ - char test[MAX_LINE]; - const char *sep = (const char *)"\t \n\r\f!="; - char *word; - int count=0; - - strncpy( test, s, MAX_LINE-1); - - for (word = strtok(test, sep); word; word = strtok(nullptr, sep)) { - strncpy( (*tok)[count], word, MAX_LINE ); - count++; - } - - return count; -} - -/* safe malloc */ -void *smalloc( LAMMPS_NS::Error *error_ptr, rc_bigint n, const char *name ) -{ - void *ptr; - - if (n <= 0) { - auto errmsg = fmt::format("Trying to allocate {} bytes for array {}. " - "returning NULL.", n, name); - if (error_ptr) error_ptr->one(FLERR,errmsg); - else fputs(errmsg.c_str(),stderr); - - return nullptr; - } - - ptr = malloc( n ); - if (ptr == nullptr) { - auto errmsg = fmt::format("Failed to allocate {} bytes for array {}", - n, name); - if (error_ptr) error_ptr->one(FLERR,errmsg); - else fputs(errmsg.c_str(),stderr); - } - - return ptr; -} - -/* safe calloc */ -void *scalloc( LAMMPS_NS::Error *error_ptr, rc_bigint n, rc_bigint size, const char *name ) -{ - void *ptr; - - if (n <= 0) { - auto errmsg = fmt::format("Trying to allocate {} elements for array {}. " - "returning NULL.\n", n, name); - if (error_ptr) error_ptr->one(FLERR,errmsg); - else fputs(errmsg.c_str(),stderr); - return nullptr; - } - - if (size <= 0) { - auto errmsg = fmt::format("Elements size for array {} is {}. " - "returning NULL", name, size); - if (error_ptr) error_ptr->one(FLERR,errmsg); - else fputs(errmsg.c_str(),stderr); - return nullptr; - } - - ptr = calloc( n, size ); - if (ptr == nullptr) { - auto errmsg = fmt::format("Failed to allocate {} bytes for array {}", - n*size, name); - if (error_ptr) error_ptr->one(FLERR,errmsg); - else fputs(errmsg.c_str(),stderr); - } - - return ptr; -} - - -/* safe free */ -void sfree( LAMMPS_NS::Error* error_ptr, void *ptr, const char *name ) -{ - if (ptr == nullptr) { - auto errmsg = fmt::format("Trying to free the already free()'d pointer {}", - name); - if (error_ptr) error_ptr->one(FLERR,errmsg); - else fputs(errmsg.c_str(),stderr); - return; - } - - free(ptr); - ptr = nullptr; -} - diff --git a/src/REAXFF/reaxc_tool_box.h b/src/REAXFF/reaxc_tool_box.h deleted file mode 100644 index 6dc6217c92..0000000000 --- a/src/REAXFF/reaxc_tool_box.h +++ /dev/null @@ -1,41 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __TOOL_BOX_H_ -#define __TOOL_BOX_H_ - -#include "reaxc_types.h" -namespace LAMMPS_NS { class Error; } - -/* from io_tools.h */ -int Tokenize( char*, char*** ); - -/* from lammps */ -void *smalloc( LAMMPS_NS::Error*, rc_bigint, const char* ); -void *scalloc( LAMMPS_NS::Error*, rc_bigint, rc_bigint, const char* ); -void sfree( LAMMPS_NS::Error*, void*, const char* ); -#endif diff --git a/src/REAXFF/reaxc_torsion_angles.cpp b/src/REAXFF/reaxc_torsion_angles.cpp deleted file mode 100644 index de23597fd8..0000000000 --- a/src/REAXFF/reaxc_torsion_angles.cpp +++ /dev/null @@ -1,480 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_torsion_angles.h" -#include -#include "pair.h" -#include "reaxc_defs.h" -#include "reaxc_list.h" -#include "reaxc_vector.h" - -#define MIN_SINE 1e-10 - -double Calculate_Omega( rvec dvec_ij, double r_ij, - rvec dvec_jk, double r_jk, - rvec dvec_kl, double r_kl, - rvec dvec_li, double r_li, - three_body_interaction_data *p_ijk, - three_body_interaction_data *p_jkl, - rvec dcos_omega_di, rvec dcos_omega_dj, - rvec dcos_omega_dk, rvec dcos_omega_dl, - output_controls * /*out_control*/ ) -{ - double unnorm_cos_omega, unnorm_sin_omega, omega; - double sin_ijk, cos_ijk, sin_jkl, cos_jkl; - double htra, htrb, htrc, hthd, hthe, hnra, hnrc, hnhd, hnhe; - double arg, poem, tel; - rvec cross_jk_kl; - - sin_ijk = sin( p_ijk->theta ); - cos_ijk = cos( p_ijk->theta ); - sin_jkl = sin( p_jkl->theta ); - cos_jkl = cos( p_jkl->theta ); - - /* omega */ - unnorm_cos_omega = -rvec_Dot(dvec_ij, dvec_jk) * rvec_Dot(dvec_jk, dvec_kl) + - SQR( r_jk ) * rvec_Dot( dvec_ij, dvec_kl ); - - rvec_Cross( cross_jk_kl, dvec_jk, dvec_kl ); - unnorm_sin_omega = -r_jk * rvec_Dot( dvec_ij, cross_jk_kl ); - - omega = atan2( unnorm_sin_omega, unnorm_cos_omega ); - - htra = r_ij + cos_ijk * ( r_kl * cos_jkl - r_jk ); - htrb = r_jk - r_ij * cos_ijk - r_kl * cos_jkl; - htrc = r_kl + cos_jkl * ( r_ij * cos_ijk - r_jk ); - hthd = r_ij * sin_ijk * ( r_jk - r_kl * cos_jkl ); - hthe = r_kl * sin_jkl * ( r_jk - r_ij * cos_ijk ); - hnra = r_kl * sin_ijk * sin_jkl; - hnrc = r_ij * sin_ijk * sin_jkl; - hnhd = r_ij * r_kl * cos_ijk * sin_jkl; - hnhe = r_ij * r_kl * sin_ijk * cos_jkl; - - poem = 2.0 * r_ij * r_kl * sin_ijk * sin_jkl; - if (poem < 1e-20) poem = 1e-20; - - tel = SQR( r_ij ) + SQR( r_jk ) + SQR( r_kl ) - SQR( r_li ) - - 2.0 * ( r_ij * r_jk * cos_ijk - r_ij * r_kl * cos_ijk * cos_jkl + - r_jk * r_kl * cos_jkl ); - - arg = tel / poem; - if (arg > 1.0) arg = 1.0; - if (arg < -1.0) arg = -1.0; - - if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) sin_ijk = MIN_SINE; - else if (sin_ijk <= 0 && sin_ijk >= -MIN_SINE) sin_ijk = -MIN_SINE; - if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) sin_jkl = MIN_SINE; - else if (sin_jkl <= 0 && sin_jkl >= -MIN_SINE) sin_jkl = -MIN_SINE; - - // dcos_omega_di - rvec_ScaledSum( dcos_omega_di, (htra-arg*hnra)/r_ij, dvec_ij, -1., dvec_li ); - rvec_ScaledAdd( dcos_omega_di,-(hthd-arg*hnhd)/sin_ijk, p_ijk->dcos_dk ); - rvec_Scale( dcos_omega_di, 2.0 / poem, dcos_omega_di ); - - // dcos_omega_dj - rvec_ScaledSum( dcos_omega_dj,-(htra-arg*hnra)/r_ij, dvec_ij, - -htrb / r_jk, dvec_jk ); - rvec_ScaledAdd( dcos_omega_dj,-(hthd-arg*hnhd)/sin_ijk, p_ijk->dcos_dj ); - rvec_ScaledAdd( dcos_omega_dj,-(hthe-arg*hnhe)/sin_jkl, p_jkl->dcos_di ); - rvec_Scale( dcos_omega_dj, 2.0 / poem, dcos_omega_dj ); - - // dcos_omega_dk - rvec_ScaledSum( dcos_omega_dk,-(htrc-arg*hnrc)/r_kl, dvec_kl, - htrb / r_jk, dvec_jk ); - rvec_ScaledAdd( dcos_omega_dk,-(hthd-arg*hnhd)/sin_ijk, p_ijk->dcos_di ); - rvec_ScaledAdd( dcos_omega_dk,-(hthe-arg*hnhe)/sin_jkl, p_jkl->dcos_dj ); - rvec_Scale( dcos_omega_dk, 2.0 / poem, dcos_omega_dk ); - - // dcos_omega_dl - rvec_ScaledSum( dcos_omega_dl, (htrc-arg*hnrc)/r_kl, dvec_kl, 1., dvec_li ); - rvec_ScaledAdd( dcos_omega_dl,-(hthe-arg*hnhe)/sin_jkl, p_jkl->dcos_dk ); - rvec_Scale( dcos_omega_dl, 2.0 / poem, dcos_omega_dl ); - - return omega; -} - - - -void Torsion_Angles( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls *out_control ) -{ - int i, j, k, l, pi, pj, pk, pl, pij, plk, natoms; - int type_i, type_j, type_k, type_l; - int start_j, end_j; - int start_pj, end_pj, start_pk, end_pk; - int num_frb_intrs = 0; - - double Delta_j, Delta_k; - double r_ij, r_jk, r_kl, r_li; - double BOA_ij, BOA_jk, BOA_kl; - - double exp_tor2_ij, exp_tor2_jk, exp_tor2_kl; - double exp_tor1, exp_tor3_DjDk, exp_tor4_DjDk, exp_tor34_inv; - double exp_cot2_jk, exp_cot2_ij, exp_cot2_kl; - double fn10, f11_DjDk, dfn11, fn12; - double theta_ijk, theta_jkl; - double sin_ijk, sin_jkl; - double cos_ijk, cos_jkl; - double tan_ijk_i, tan_jkl_i; - double omega, cos_omega, cos2omega, cos3omega; - rvec dcos_omega_di, dcos_omega_dj, dcos_omega_dk, dcos_omega_dl; - double CV, cmn, CEtors1, CEtors2, CEtors3, CEtors4; - double CEtors5, CEtors6, CEtors7, CEtors8, CEtors9; - double Cconj, CEconj1, CEconj2, CEconj3; - double CEconj4, CEconj5, CEconj6; - double e_tor, e_con; - rvec dvec_li; - rvec force, ext_press; - ivec rel_box_jl; - // rtensor total_rtensor, temp_rtensor; - four_body_header *fbh; - four_body_parameters *fbp; - bond_data *pbond_ij, *pbond_jk, *pbond_kl; - bond_order_data *bo_ij, *bo_jk, *bo_kl; - three_body_interaction_data *p_ijk, *p_jkl; - double p_tor2 = system->reax_param.gp.l[23]; - double p_tor3 = system->reax_param.gp.l[24]; - double p_tor4 = system->reax_param.gp.l[25]; - double p_cot2 = system->reax_param.gp.l[27]; - reax_list *bonds = (*lists) + BONDS; - reax_list *thb_intrs = (*lists) + THREE_BODIES; - - // Virial tallying variables - double delil[3], deljl[3], delkl[3]; - double eng_tmp, fi_tmp[3], fj_tmp[3], fk_tmp[3]; - - natoms = system->n; - - for (j = 0; j < natoms; ++j) { - type_j = system->my_atoms[j].type; - Delta_j = workspace->Delta_boc[j]; - start_j = Start_Index(j, bonds); - end_j = End_Index(j, bonds); - - for (pk = start_j; pk < end_j; ++pk) { - pbond_jk = &( bonds->select.bond_list[pk] ); - k = pbond_jk->nbr; - bo_jk = &( pbond_jk->bo_data ); - BOA_jk = bo_jk->BO - control->thb_cut; - - if (system->my_atoms[j].orig_id > system->my_atoms[k].orig_id) - continue; - if (system->my_atoms[j].orig_id == system->my_atoms[k].orig_id) { - if (system->my_atoms[k].x[2] < system->my_atoms[j].x[2]) continue; - if (system->my_atoms[k].x[2] == system->my_atoms[j].x[2] && - system->my_atoms[k].x[1] < system->my_atoms[j].x[1]) continue; - if (system->my_atoms[k].x[2] == system->my_atoms[j].x[2] && - system->my_atoms[k].x[1] == system->my_atoms[j].x[1] && - system->my_atoms[k].x[0] < system->my_atoms[j].x[0]) continue; - } - - if (bo_jk->BO > control->thb_cut/*0*/ && Num_Entries(pk, thb_intrs)) { - pj = pbond_jk->sym_index; // pj points to j on k's list - - if (Num_Entries(pj, thb_intrs)) { - type_k = system->my_atoms[k].type; - Delta_k = workspace->Delta_boc[k]; - r_jk = pbond_jk->d; - - start_pk = Start_Index(pk, thb_intrs ); - end_pk = End_Index(pk, thb_intrs ); - start_pj = Start_Index(pj, thb_intrs ); - end_pj = End_Index(pj, thb_intrs ); - - exp_tor2_jk = exp( -p_tor2 * BOA_jk ); - exp_cot2_jk = exp( -p_cot2 * SQR(BOA_jk - 1.5) ); - exp_tor3_DjDk = exp( -p_tor3 * (Delta_j + Delta_k) ); - exp_tor4_DjDk = exp( p_tor4 * (Delta_j + Delta_k) ); - exp_tor34_inv = 1.0 / (1.0 + exp_tor3_DjDk + exp_tor4_DjDk); - f11_DjDk = (2.0 + exp_tor3_DjDk) * exp_tor34_inv; - - for (pi = start_pk; pi < end_pk; ++pi) { - p_ijk = &( thb_intrs->select.three_body_list[pi] ); - pij = p_ijk->pthb; // pij is pointer to i on j's bond_list - pbond_ij = &( bonds->select.bond_list[pij] ); - bo_ij = &( pbond_ij->bo_data ); - - if (bo_ij->BO > control->thb_cut/*0*/) { - i = p_ijk->thb; - type_i = system->my_atoms[i].type; - r_ij = pbond_ij->d; - BOA_ij = bo_ij->BO - control->thb_cut; - - theta_ijk = p_ijk->theta; - sin_ijk = sin( theta_ijk ); - cos_ijk = cos( theta_ijk ); - //tan_ijk_i = 1. / tan( theta_ijk ); - if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) - tan_ijk_i = cos_ijk / MIN_SINE; - else if (sin_ijk <= 0 && sin_ijk >= -MIN_SINE) - tan_ijk_i = cos_ijk / -MIN_SINE; - else tan_ijk_i = cos_ijk / sin_ijk; - - exp_tor2_ij = exp( -p_tor2 * BOA_ij ); - exp_cot2_ij = exp( -p_cot2 * SQR(BOA_ij -1.5) ); - - for (pl = start_pj; pl < end_pj; ++pl) { - p_jkl = &( thb_intrs->select.three_body_list[pl] ); - l = p_jkl->thb; - plk = p_jkl->pthb; //pointer to l on k's bond_list! - pbond_kl = &( bonds->select.bond_list[plk] ); - bo_kl = &( pbond_kl->bo_data ); - type_l = system->my_atoms[l].type; - fbh = &(system->reax_param.fbp[type_i][type_j] - [type_k][type_l]); - fbp = &(system->reax_param.fbp[type_i][type_j] - [type_k][type_l].prm[0]); - - if ( i != l && fbh->cnt && - bo_kl->BO > control->thb_cut/*0*/ && - bo_ij->BO * bo_jk->BO * bo_kl->BO > control->thb_cut/*0*/) { - ++num_frb_intrs; - r_kl = pbond_kl->d; - BOA_kl = bo_kl->BO - control->thb_cut; - - theta_jkl = p_jkl->theta; - sin_jkl = sin( theta_jkl ); - cos_jkl = cos( theta_jkl ); - //tan_jkl_i = 1. / tan( theta_jkl ); - if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) - tan_jkl_i = cos_jkl / MIN_SINE; - else if (sin_jkl <= 0 && sin_jkl >= -MIN_SINE) - tan_jkl_i = cos_jkl / -MIN_SINE; - else tan_jkl_i = cos_jkl /sin_jkl; - - rvec_ScaledSum( dvec_li, 1., system->my_atoms[i].x, - -1., system->my_atoms[l].x ); - r_li = rvec_Norm( dvec_li ); - - - /* omega and its derivative */ - omega = Calculate_Omega( pbond_ij->dvec, r_ij, - pbond_jk->dvec, r_jk, - pbond_kl->dvec, r_kl, - dvec_li, r_li, - p_ijk, p_jkl, - dcos_omega_di, dcos_omega_dj, - dcos_omega_dk, dcos_omega_dl, - out_control ); - - cos_omega = cos( omega ); - cos2omega = cos( 2. * omega ); - cos3omega = cos( 3. * omega ); - /* end omega calculations */ - - /* torsion energy */ - exp_tor1 = exp( fbp->p_tor1 * - SQR(2.0 - bo_jk->BO_pi - f11_DjDk) ); - exp_tor2_kl = exp( -p_tor2 * BOA_kl ); - exp_cot2_kl = exp( -p_cot2 * SQR(BOA_kl - 1.5) ); - fn10 = (1.0 - exp_tor2_ij) * (1.0 - exp_tor2_jk) * - (1.0 - exp_tor2_kl); - - CV = 0.5 * ( fbp->V1 * (1.0 + cos_omega) + - fbp->V2 * exp_tor1 * (1.0 - cos2omega) + - fbp->V3 * (1.0 + cos3omega) ); - - data->my_en.e_tor += e_tor = fn10 * sin_ijk * sin_jkl * CV; - - dfn11 = (-p_tor3 * exp_tor3_DjDk + - (p_tor3 * exp_tor3_DjDk - p_tor4 * exp_tor4_DjDk) * - (2.0 + exp_tor3_DjDk) * exp_tor34_inv) * - exp_tor34_inv; - - CEtors1 = sin_ijk * sin_jkl * CV; - - CEtors2 = -fn10 * 2.0 * fbp->p_tor1 * fbp->V2 * exp_tor1 * - (2.0 - bo_jk->BO_pi - f11_DjDk) * (1.0 - SQR(cos_omega)) * - sin_ijk * sin_jkl; - CEtors3 = CEtors2 * dfn11; - - CEtors4 = CEtors1 * p_tor2 * exp_tor2_ij * - (1.0 - exp_tor2_jk) * (1.0 - exp_tor2_kl); - CEtors5 = CEtors1 * p_tor2 * - (1.0 - exp_tor2_ij) * exp_tor2_jk * (1.0 - exp_tor2_kl); - CEtors6 = CEtors1 * p_tor2 * - (1.0 - exp_tor2_ij) * (1.0 - exp_tor2_jk) * exp_tor2_kl; - - cmn = -fn10 * CV; - CEtors7 = cmn * sin_jkl * tan_ijk_i; - CEtors8 = cmn * sin_ijk * tan_jkl_i; - - CEtors9 = fn10 * sin_ijk * sin_jkl * - (0.5 * fbp->V1 - 2.0 * fbp->V2 * exp_tor1 * cos_omega + - 1.5 * fbp->V3 * (cos2omega + 2.0 * SQR(cos_omega))); - /* end of torsion energy */ - - /* 4-body conjugation energy */ - fn12 = exp_cot2_ij * exp_cot2_jk * exp_cot2_kl; - data->my_en.e_con += e_con = - fbp->p_cot1 * fn12 * - (1.0 + (SQR(cos_omega) - 1.0) * sin_ijk * sin_jkl); - - Cconj = -2.0 * fn12 * fbp->p_cot1 * p_cot2 * - (1.0 + (SQR(cos_omega) - 1.0) * sin_ijk * sin_jkl); - - CEconj1 = Cconj * (BOA_ij - 1.5e0); - CEconj2 = Cconj * (BOA_jk - 1.5e0); - CEconj3 = Cconj * (BOA_kl - 1.5e0); - - CEconj4 = -fbp->p_cot1 * fn12 * - (SQR(cos_omega) - 1.0) * sin_jkl * tan_ijk_i; - CEconj5 = -fbp->p_cot1 * fn12 * - (SQR(cos_omega) - 1.0) * sin_ijk * tan_jkl_i; - CEconj6 = 2.0 * fbp->p_cot1 * fn12 * - cos_omega * sin_ijk * sin_jkl; - /* end 4-body conjugation energy */ - - /* forces */ - bo_jk->Cdbopi += CEtors2; - workspace->CdDelta[j] += CEtors3; - workspace->CdDelta[k] += CEtors3; - bo_ij->Cdbo += (CEtors4 + CEconj1); - bo_jk->Cdbo += (CEtors5 + CEconj2); - bo_kl->Cdbo += (CEtors6 + CEconj3); - - if (control->virial == 0) { - /* dcos_theta_ijk */ - rvec_ScaledAdd( workspace->f[i], - CEtors7 + CEconj4, p_ijk->dcos_dk ); - rvec_ScaledAdd( workspace->f[j], - CEtors7 + CEconj4, p_ijk->dcos_dj ); - rvec_ScaledAdd( workspace->f[k], - CEtors7 + CEconj4, p_ijk->dcos_di ); - - /* dcos_theta_jkl */ - rvec_ScaledAdd( workspace->f[j], - CEtors8 + CEconj5, p_jkl->dcos_di ); - rvec_ScaledAdd( workspace->f[k], - CEtors8 + CEconj5, p_jkl->dcos_dj ); - rvec_ScaledAdd( workspace->f[l], - CEtors8 + CEconj5, p_jkl->dcos_dk ); - - /* dcos_omega */ - rvec_ScaledAdd( workspace->f[i], - CEtors9 + CEconj6, dcos_omega_di ); - rvec_ScaledAdd( workspace->f[j], - CEtors9 + CEconj6, dcos_omega_dj ); - rvec_ScaledAdd( workspace->f[k], - CEtors9 + CEconj6, dcos_omega_dk ); - rvec_ScaledAdd( workspace->f[l], - CEtors9 + CEconj6, dcos_omega_dl ); - } - else { - ivec_Sum(rel_box_jl, pbond_jk->rel_box, pbond_kl->rel_box); - - /* dcos_theta_ijk */ - rvec_Scale( force, CEtors7 + CEconj4, p_ijk->dcos_dk ); - rvec_Add( workspace->f[i], force ); - rvec_iMultiply( ext_press, pbond_ij->rel_box, force ); - rvec_Add( data->my_ext_press, ext_press ); - - rvec_ScaledAdd( workspace->f[j], - CEtors7 + CEconj4, p_ijk->dcos_dj ); - - rvec_Scale( force, CEtors7 + CEconj4, p_ijk->dcos_di ); - rvec_Add( workspace->f[k], force ); - rvec_iMultiply( ext_press, pbond_jk->rel_box, force ); - rvec_Add( data->my_ext_press, ext_press ); - - - /* dcos_theta_jkl */ - rvec_ScaledAdd( workspace->f[j], - CEtors8 + CEconj5, p_jkl->dcos_di ); - - rvec_Scale( force, CEtors8 + CEconj5, p_jkl->dcos_dj ); - rvec_Add( workspace->f[k], force ); - rvec_iMultiply( ext_press, pbond_jk->rel_box, force ); - rvec_Add( data->my_ext_press, ext_press ); - - rvec_Scale( force, CEtors8 + CEconj5, p_jkl->dcos_dk ); - rvec_Add( workspace->f[l], force ); - rvec_iMultiply( ext_press, rel_box_jl, force ); - rvec_Add( data->my_ext_press, ext_press ); - - - /* dcos_omega */ - rvec_Scale( force, CEtors9 + CEconj6, dcos_omega_di ); - rvec_Add( workspace->f[i], force ); - rvec_iMultiply( ext_press, pbond_ij->rel_box, force ); - rvec_Add( data->my_ext_press, ext_press ); - - rvec_ScaledAdd( workspace->f[j], - CEtors9 + CEconj6, dcos_omega_dj ); - - rvec_Scale( force, CEtors9 + CEconj6, dcos_omega_dk ); - rvec_Add( workspace->f[k], force ); - rvec_iMultiply( ext_press, pbond_jk->rel_box, force ); - rvec_Add( data->my_ext_press, ext_press ); - - rvec_Scale( force, CEtors9 + CEconj6, dcos_omega_dl ); - rvec_Add( workspace->f[l], force ); - rvec_iMultiply( ext_press, rel_box_jl, force ); - rvec_Add( data->my_ext_press, ext_press ); - } - - /* tally into per-atom virials */ - if (system->pair_ptr->vflag_atom || system->pair_ptr->evflag) { - - // acquire vectors - rvec_ScaledSum( delil, 1., system->my_atoms[l].x, - -1., system->my_atoms[i].x ); - rvec_ScaledSum( deljl, 1., system->my_atoms[l].x, - -1., system->my_atoms[j].x ); - rvec_ScaledSum( delkl, 1., system->my_atoms[l].x, - -1., system->my_atoms[k].x ); - // dcos_theta_ijk - rvec_Scale( fi_tmp, CEtors7 + CEconj4, p_ijk->dcos_dk ); - rvec_Scale( fj_tmp, CEtors7 + CEconj4, p_ijk->dcos_dj ); - rvec_Scale( fk_tmp, CEtors7 + CEconj4, p_ijk->dcos_di ); - - // dcos_theta_jkl - rvec_ScaledAdd( fj_tmp, CEtors8 + CEconj5, p_jkl->dcos_di ); - rvec_ScaledAdd( fk_tmp, CEtors8 + CEconj5, p_jkl->dcos_dj ); - - // dcos_omega - rvec_ScaledAdd( fi_tmp, CEtors9 + CEconj6, dcos_omega_di ); - rvec_ScaledAdd( fj_tmp, CEtors9 + CEconj6, dcos_omega_dj ); - rvec_ScaledAdd( fk_tmp, CEtors9 + CEconj6, dcos_omega_dk ); - - // tally - eng_tmp = e_tor + e_con; - if (system->pair_ptr->evflag) - system->pair_ptr->ev_tally(j,k,natoms,1,eng_tmp,0.0,0.0,0.0,0.0,0.0); - if (system->pair_ptr->vflag_atom) - system->pair_ptr->v_tally4(i,j,k,l,fi_tmp,fj_tmp,fk_tmp,delil,deljl,delkl); - } - } // pl check ends - } // pl loop ends - } // pi check ends - } // pi loop ends - } // k-j neighbor check ends - } // j-k neighbor check ends - } // pk loop ends - } // j loop -} diff --git a/src/REAXFF/reaxc_torsion_angles.h b/src/REAXFF/reaxc_torsion_angles.h deleted file mode 100644 index e18bc9d4c7..0000000000 --- a/src/REAXFF/reaxc_torsion_angles.h +++ /dev/null @@ -1,36 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __TORSION_ANGLES_H_ -#define __TORSION_ANGLES_H_ - -#include "reaxc_types.h" - -void Torsion_Angles( reax_system*, control_params*, simulation_data*, - storage*, reax_list**, output_controls* ); - -#endif diff --git a/src/REAXFF/reaxc_traj.cpp b/src/REAXFF/reaxc_traj.cpp deleted file mode 100644 index f6e2dafeee..0000000000 --- a/src/REAXFF/reaxc_traj.cpp +++ /dev/null @@ -1,777 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_traj.h" -#include -#include -#include -#include -#include "reaxc_defs.h" -#include "reaxc_list.h" - -#include "error.h" - -int Reallocate_Output_Buffer( LAMMPS_NS::Error *error_ptr, output_controls *out_control, int req_space ) -{ - if (out_control->buffer_len > 0) - free( out_control->buffer ); - - out_control->buffer_len = (int)(req_space*REAX_SAFE_ZONE); - out_control->buffer = (char*) malloc(out_control->buffer_len*sizeof(char)); - if (out_control->buffer == nullptr) { - char errmsg[256]; - snprintf(errmsg, 256, "Insufficient memory for required buffer size %d", (int) (req_space*REAX_SAFE_ZONE)); - error_ptr->one(FLERR,errmsg); - } - - return REAXC_SUCCESS; -} - - -void Write_Skip_Line( output_controls *out_control, mpi_datatypes * /*mpi_data*/, - int my_rank, int skip, int num_section ) -{ - if (my_rank == MASTER_NODE) - fprintf( out_control->strj, INT2_LINE, - "chars_to_skip_section:", skip, num_section ); -} - - -int Write_Header( reax_system *system, control_params *control, - output_controls *out_control, mpi_datatypes * /*mpi_data*/ ) -{ - int num_hdr_lines, my_hdr_lines, buffer_req; - char ensembles[ens_N][25] = { "NVE", "NVT", "fully flexible NPT", - "semi isotropic NPT", "isotropic NPT" }; - char reposition[3][25] = { "fit to periodic box", "CoM to center of box", - "CoM to origin" }; - char t_regime[3][25] = { "T-coupling only", "step-wise", "constant slope" }; - - char traj_methods[TF_N][10] = { "custom", "xyz" }; - char atom_formats[8][40] = { "none", "invalid", "invalid", "invalid", - "xyz_q", - "xyz_q_fxfyfz", - "xyz_q_vxvyvz", - "detailed_atom_info" }; - char bond_formats[3][30] = { "none", - "basic_bond_info", - "detailed_bond_info" }; - char angle_formats[2][30] = { "none", "basic_angle_info" }; - - /* set header lengths */ - num_hdr_lines = NUM_HEADER_LINES; - my_hdr_lines = num_hdr_lines * ( system->my_rank == MASTER_NODE ); - buffer_req = my_hdr_lines * HEADER_LINE_LEN; - if (buffer_req > out_control->buffer_len * DANGER_ZONE) - Reallocate_Output_Buffer( control->error_ptr, out_control, buffer_req ); - - /* only the master node writes into trajectory header */ - if (system->my_rank == MASTER_NODE) { - /* clear the contents of line & buffer */ - out_control->line[0] = 0; - out_control->buffer[0] = 0; - - /* to skip the header */ - sprintf( out_control->line, INT_LINE, "chars_to_skip_header:", - (num_hdr_lines-1) * HEADER_LINE_LEN ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - /* general simulation info */ - sprintf( out_control->line, STR_LINE, "simulation_name:", - out_control->traj_title ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, BIGINT_LINE, "number_of_atoms:", system->bigN ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, STR_LINE, "ensemble_type:", - ensembles[ control->ensemble ] ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, INT_LINE, "number_of_steps:", - control->nsteps ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "timestep_length_(in_fs):", - control->dt * 1000 ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - /* restart info */ - sprintf( out_control->line, STR_LINE, "is_this_a_restart?:", - (control->restart ? "yes" : "no") ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, STR_LINE, "write_restart_files?:", - ((out_control->restart_freq > 0) ? "yes" : "no") ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, INT_LINE, "frequency_to_write_restarts:", - out_control->restart_freq ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - /* preferences */ - sprintf( out_control->line, STR_LINE, "tabulate_long_range_intrs?:", - (control->tabulate ? "yes" : "no") ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, INT_LINE, "table_size:", control->tabulate ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, STR_LINE, "restrict_bonds?:", - (control->restrict_bonds ? "yes" : "no") ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, INT_LINE, "bond_restriction_length:", - control->restrict_bonds ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, STR_LINE, "reposition_atoms?:", - reposition[control->reposition_atoms] ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, INT_LINE, "remove_CoM_velocity?:", - (control->ensemble==NVE) ? 0 : control->remove_CoM_vel); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - - /* cut-off values */ - sprintf( out_control->line, REAL_LINE, "bonded_intr_dist_cutoff:", - control->bond_cut ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "nonbonded_intr_dist_cutoff:", - control->nonb_cut ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "hbond_dist_cutoff:", - control->hbond_cut ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "reax_bond_threshold:", - control->bo_cut ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "physical_bond_threshold:", - control->bg_cut ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "valence_angle_threshold:", - control->thb_cut ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, SCI_LINE, "QEq_tolerance:", control->q_err ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - /* temperature controls */ - sprintf( out_control->line, REAL_LINE, "initial_temperature:", - control->T_init ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "target_temperature:", - control->T_final ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "thermal_inertia:", - control->Tau_T ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, STR_LINE, "temperature_regime:", - t_regime[ control->T_mode ] ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "temperature_change_rate_(K/ps):", - control->T_rate / control->T_freq ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - /* pressure controls */ - sprintf( out_control->line, REAL3_LINE, "target_pressure_(GPa):", - control->P[0], control->P[1], control->P[2] ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL3_LINE, "virial_inertia:", - control->Tau_P[0], control->Tau_P[1], control->Tau_P[2] ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - /* trajectory */ - sprintf( out_control->line, INT_LINE, "energy_dumping_freq:", - out_control->energy_update_freq ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, INT_LINE, "trajectory_dumping_freq:", - out_control->write_steps ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, STR_LINE, "compress_trajectory_output?:", - (out_control->traj_compress ? "yes" : "no") ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, STR_LINE, "trajectory_format:", - traj_methods[ out_control->traj_method ] ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, STR_LINE, "atom_info:", - atom_formats[ out_control->atom_info ] ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, STR_LINE, "bond_info:", - bond_formats[ out_control->bond_info ] ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, STR_LINE, "angle_info:", - angle_formats[ out_control->angle_info ] ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - /* analysis */ - //sprintf( out_control->line, STR_LINE, "molecular_analysis:", - // (control->molec_anal ? "yes" : "no") ); - //strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, INT_LINE, "molecular_analysis_frequency:", - control->molecular_analysis ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - } - - /* dump out the buffer */ - if (system->my_rank == MASTER_NODE) - fprintf( out_control->strj, "%s", out_control->buffer ); - - return REAXC_SUCCESS; -} - - -int Write_Init_Desc( reax_system *system, control_params * /*control*/, - output_controls *out_control, mpi_datatypes *mpi_data ) -{ - int i, me, np, cnt, buffer_len, buffer_req; - reax_atom *p_atom; - MPI_Status status; - - me = system->my_rank; - np = system->wsize; - - /* skip info */ - Write_Skip_Line( out_control, mpi_data, me, - system->bigN * INIT_DESC_LEN, system->bigN ); - - if (out_control->traj_method == REG_TRAJ && me == MASTER_NODE) - buffer_req = system->bigN * INIT_DESC_LEN + 1; - else buffer_req = system->n * INIT_DESC_LEN + 1; - - if (buffer_req > out_control->buffer_len * DANGER_ZONE) - Reallocate_Output_Buffer( system->error_ptr, out_control, buffer_req ); - - out_control->line[0] = 0; - out_control->buffer[0] = 0; - for (i = 0; i < system->n; ++i) { - p_atom = &( system->my_atoms[i] ); - sprintf( out_control->line, INIT_DESC, - p_atom->orig_id, p_atom->type, p_atom->name, - system->reax_param.sbp[ p_atom->type ].mass ); - strncpy( out_control->buffer + i*INIT_DESC_LEN, - out_control->line, INIT_DESC_LEN+1 ); - } - - if (me != MASTER_NODE) { - MPI_Send( out_control->buffer, buffer_req-1, MPI_CHAR, MASTER_NODE, - np * INIT_DESCS + me, mpi_data->world ); - } else { - buffer_len = system->n * INIT_DESC_LEN; - for (i = 0; i < np; ++i) - if (i != MASTER_NODE) { - MPI_Recv( out_control->buffer + buffer_len, buffer_req - buffer_len, - MPI_CHAR, i, np*INIT_DESCS+i, mpi_data->world, &status ); - MPI_Get_count( &status, MPI_CHAR, &cnt ); - buffer_len += cnt; - } - out_control->buffer[buffer_len] = 0; - fprintf( out_control->strj, "%s", out_control->buffer ); - } - - return REAXC_SUCCESS; -} - - -int Init_Traj( reax_system *system, control_params *control, - output_controls *out_control, mpi_datatypes *mpi_data, - char *msg ) -{ - char fname[MAX_STR+8]; - int atom_line_len[ NR_OPT_ATOM ] = { 0, 0, 0, 0, - ATOM_BASIC_LEN, ATOM_wV_LEN, - ATOM_wF_LEN, ATOM_FULL_LEN }; - int bond_line_len[ NR_OPT_BOND ] = { 0, BOND_BASIC_LEN, BOND_FULL_LEN }; - int angle_line_len[ NR_OPT_ANGLE ] = { 0, ANGLE_BASIC_LEN }; - - /* generate trajectory name */ - sprintf( fname, "%s.trj", control->sim_name ); - - /* how should I write atoms? */ - out_control->atom_line_len = atom_line_len[ out_control->atom_info ]; - out_control->write_atoms = ( out_control->atom_line_len ? 1 : 0 ); - /* bonds? */ - out_control->bond_line_len = bond_line_len[ out_control->bond_info ]; - out_control->write_bonds = ( out_control->bond_line_len ? 1 : 0 ); - /* angles? */ - out_control->angle_line_len = angle_line_len[ out_control->angle_info ]; - out_control->write_angles = ( out_control->angle_line_len ? 1 : 0 ); - - /* allocate line & buffer space */ - out_control->line = (char*) calloc( MAX_TRJ_LINE_LEN + 1, sizeof(char) ); - out_control->buffer_len = 0; - out_control->buffer = nullptr; - - /* write trajectory header and atom info, if applicable */ - if (out_control->traj_method == REG_TRAJ) { - if (system->my_rank == MASTER_NODE) - out_control->strj = fopen( fname, "w" ); - } else { - strcpy( msg, "init_traj: unknown trajectory option" ); - return FAILURE; - } - Write_Header( system, control, out_control, mpi_data ); - Write_Init_Desc( system, control, out_control, mpi_data ); - - return REAXC_SUCCESS; -} - - -int Write_Frame_Header( reax_system *system, control_params *control, - simulation_data *data, output_controls *out_control, - mpi_datatypes * /*mpi_data*/ ) -{ - int me, num_frm_hdr_lines, my_frm_hdr_lines, buffer_req; - - me = system->my_rank; - /* frame header lengths */ - num_frm_hdr_lines = 22; - my_frm_hdr_lines = num_frm_hdr_lines * ( me == MASTER_NODE ); - buffer_req = my_frm_hdr_lines * HEADER_LINE_LEN; - if (buffer_req > out_control->buffer_len * DANGER_ZONE) - Reallocate_Output_Buffer( control->error_ptr, out_control, buffer_req ); - - /* only the master node writes into trajectory header */ - if (me == MASTER_NODE) { - /* clear the contents of line & buffer */ - out_control->line[0] = 0; - out_control->buffer[0] = 0; - - /* skip info */ - sprintf( out_control->line, INT_LINE, "chars_to_skip_frame_header:", - (num_frm_hdr_lines - 1) * HEADER_LINE_LEN ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - /* step & time */ - sprintf( out_control->line, INT_LINE, "step:", data->step ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "time_in_ps:", - data->step * control->dt ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - - /* box info */ - sprintf( out_control->line, REAL_LINE, "volume:", system->big_box.V ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL3_LINE, "box_dimensions:", - system->big_box.box_norms[0], - system->big_box.box_norms[1], - system->big_box.box_norms[2] ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL3_LINE, - "coordinate_angles:", 90.0, 90.0, 90.0 ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - - /* system T and P */ - sprintf( out_control->line, REAL_LINE, "temperature:", data->therm.T ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "pressure:", - (control->ensemble==iNPT) ? - data->iso_bar.P : data->flex_bar.P_scalar ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - - /* energies */ - sprintf( out_control->line, REAL_LINE, "total_energy:", - data->sys_en.e_tot ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "total_kinetic:", - data->sys_en.e_kin ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "total_potential:", - data->sys_en.e_pot ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "bond_energy:", - data->sys_en.e_bond ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "atom_energy:", - data->sys_en.e_ov + data->sys_en.e_un ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "lone_pair_energy:", - data->sys_en.e_lp ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "valence_angle_energy:", - data->sys_en.e_ang + data->sys_en.e_pen ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "3-body_conjugation:", - data->sys_en.e_coa ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "hydrogen_bond_energy:", - data->sys_en.e_hb ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "torsion_angle_energy:", - data->sys_en.e_tor ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "4-body_conjugation:", - data->sys_en.e_con ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "vdWaals_energy:", - data->sys_en.e_vdW ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "electrostatics_energy:", - data->sys_en.e_ele ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - - sprintf( out_control->line, REAL_LINE, "polarization_energy:", - data->sys_en.e_pol ); - strncat( out_control->buffer, out_control->line, HEADER_LINE_LEN+1 ); - } - - /* dump out the buffer */ - if (system->my_rank == MASTER_NODE) - fprintf( out_control->strj, "%s", out_control->buffer ); - - return REAXC_SUCCESS; -} - - - -int Write_Atoms( reax_system *system, control_params * /*control*/, - output_controls *out_control, mpi_datatypes *mpi_data ) -{ - int i, me, np, line_len, buffer_len, buffer_req, cnt; - MPI_Status status; - reax_atom *p_atom; - - me = system->my_rank; - np = system->wsize; - line_len = out_control->atom_line_len; - - Write_Skip_Line( out_control, mpi_data, me, - system->bigN*line_len, system->bigN ); - - if (out_control->traj_method == REG_TRAJ && me == MASTER_NODE) - buffer_req = system->bigN * line_len + 1; - else buffer_req = system->n * line_len + 1; - - if (buffer_req > out_control->buffer_len * DANGER_ZONE) - Reallocate_Output_Buffer( system->error_ptr, out_control, buffer_req ); - - /* fill in buffer */ - out_control->line[0] = 0; - out_control->buffer[0] = 0; - for (i = 0; i < system->n; ++i) { - p_atom = &( system->my_atoms[i] ); - - switch (out_control->atom_info) { - case OPT_ATOM_BASIC: - sprintf( out_control->line, ATOM_BASIC, - p_atom->orig_id, p_atom->x[0], p_atom->x[1], p_atom->x[2], - p_atom->q ); - break; - case OPT_ATOM_wF: - sprintf( out_control->line, ATOM_wF, - p_atom->orig_id, p_atom->x[0], p_atom->x[1], p_atom->x[2], - p_atom->f[0], p_atom->f[1], p_atom->f[2], p_atom->q ); - break; - case OPT_ATOM_wV: - sprintf( out_control->line, ATOM_wV, - p_atom->orig_id, p_atom->x[0], p_atom->x[1], p_atom->x[2], - p_atom->v[0], p_atom->v[1], p_atom->v[2], p_atom->q ); - break; - case OPT_ATOM_FULL: - sprintf( out_control->line, ATOM_FULL, - p_atom->orig_id, p_atom->x[0], p_atom->x[1], p_atom->x[2], - p_atom->v[0], p_atom->v[1], p_atom->v[2], - p_atom->f[0], p_atom->f[1], p_atom->f[2], p_atom->q ); - break; - default: - system->error_ptr->one(FLERR,"Write_traj_atoms: unknown atom trajectory format"); - } - - strncpy( out_control->buffer + i*line_len, out_control->line, line_len+1 ); - } - - if (me != MASTER_NODE) { - MPI_Send( out_control->buffer, buffer_req-1, MPI_CHAR, MASTER_NODE, - np*ATOM_LINES+me, mpi_data->world ); - } else { - buffer_len = system->n * line_len; - for (i = 0; i < np; ++i) - if (i != MASTER_NODE) { - MPI_Recv( out_control->buffer + buffer_len, buffer_req - buffer_len, - MPI_CHAR, i, np*ATOM_LINES+i, mpi_data->world, &status ); - MPI_Get_count( &status, MPI_CHAR, &cnt ); - buffer_len += cnt; - } - out_control->buffer[buffer_len] = 0; - fprintf( out_control->strj, "%s", out_control->buffer ); - } - - return REAXC_SUCCESS; -} - - -int Write_Bonds(reax_system *system, control_params *control, reax_list *bonds, - output_controls *out_control, mpi_datatypes *mpi_data) -{ - int i, j, pj, me, np; - int my_bonds, num_bonds; - int line_len, buffer_len, buffer_req, cnt; - MPI_Status status; - bond_data *bo_ij; - - me = system->my_rank; - np = system->wsize; - line_len = out_control->bond_line_len; - - /* count the number of bonds I will write */ - my_bonds = 0; - for (i=0; i < system->n; ++i) - for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { - j = bonds->select.bond_list[pj].nbr; - if ( system->my_atoms[i].orig_id <= system->my_atoms[j].orig_id && - bonds->select.bond_list[pj].bo_data.BO >= control->bg_cut ) - ++my_bonds; - } - - /* allreduce - total number of bonds */ - MPI_Allreduce( &my_bonds, &num_bonds, 1, MPI_INT, MPI_SUM, mpi_data->world ); - - Write_Skip_Line( out_control, mpi_data, me, num_bonds*line_len, num_bonds ); - - if (out_control->traj_method == REG_TRAJ && me == MASTER_NODE) - buffer_req = num_bonds * line_len + 1; - else buffer_req = my_bonds * line_len + 1; - - if (buffer_req > out_control->buffer_len * DANGER_ZONE) - Reallocate_Output_Buffer( system->error_ptr, out_control, buffer_req ); - - /* fill in the buffer */ - out_control->line[0] = 0; - out_control->buffer[0] = 0; - - my_bonds = 0; - for (i=0; i < system->n; ++i) { - for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { - bo_ij = &( bonds->select.bond_list[pj] ); - j = bo_ij->nbr; - - if ( system->my_atoms[i].orig_id <= system->my_atoms[j].orig_id && - bo_ij->bo_data.BO >= control->bg_cut) { - switch (out_control->bond_info) { - case OPT_BOND_BASIC: - sprintf( out_control->line, BOND_BASIC, - system->my_atoms[i].orig_id, system->my_atoms[j].orig_id, - bo_ij->d, bo_ij->bo_data.BO ); - break; - case OPT_BOND_FULL: - sprintf( out_control->line, BOND_FULL, - system->my_atoms[i].orig_id, system->my_atoms[j].orig_id, - bo_ij->d, bo_ij->bo_data.BO, bo_ij->bo_data.BO_s, - bo_ij->bo_data.BO_pi, bo_ij->bo_data.BO_pi2 ); - break; - default: - system->error_ptr->one(FLERR, "Write_traj_bonds: FATAL! invalid bond_info option"); - } - strncpy( out_control->buffer + my_bonds*line_len, - out_control->line, line_len+1 ); - ++my_bonds; - } - } - } - - if (me != MASTER_NODE) { - MPI_Send( out_control->buffer, buffer_req-1, MPI_CHAR, MASTER_NODE, - np*BOND_LINES+me, mpi_data->world ); - } else { - buffer_len = my_bonds * line_len; - for (i = 0; i < np; ++i) - if (i != MASTER_NODE) { - MPI_Recv( out_control->buffer + buffer_len, buffer_req - buffer_len, - MPI_CHAR, i, np*BOND_LINES+i, mpi_data->world, &status ); - MPI_Get_count( &status, MPI_CHAR, &cnt ); - buffer_len += cnt; - } - out_control->buffer[buffer_len] = 0; - fprintf( out_control->strj, "%s", out_control->buffer ); - } - - return REAXC_SUCCESS; -} - - -int Write_Angles( reax_system *system, control_params *control, - reax_list *bonds, reax_list *thb_intrs, - output_controls *out_control, mpi_datatypes *mpi_data ) -{ - int i, j, k, pi, pk, me, np; - int my_angles, num_angles; - int line_len, buffer_len, buffer_req, cnt; - bond_data *bo_ij, *bo_jk; - three_body_interaction_data *angle_ijk; - MPI_Status status; - - me = system->my_rank; - np = system->wsize; - line_len = out_control->angle_line_len; - - /* count the number of valence angles I will output */ - my_angles = 0; - for (j = 0; j < system->n; ++j) - for (pi = Start_Index(j, bonds); pi < End_Index(j, bonds); ++pi) { - bo_ij = &(bonds->select.bond_list[pi]); - i = bo_ij->nbr; - - if (bo_ij->bo_data.BO >= control->bg_cut) // physical j&i bond - for (pk = Start_Index( pi, thb_intrs); - pk < End_Index( pi, thb_intrs ); ++pk) { - angle_ijk = &(thb_intrs->select.three_body_list[pk]); - k = angle_ijk->thb; - bo_jk = &(bonds->select.bond_list[ angle_ijk->pthb ]); - - if ( system->my_atoms[i].orig_id < system->my_atoms[k].orig_id && - bo_jk->bo_data.BO >= control->bg_cut ) // physical j&k bond - ++my_angles; - } - } - /* total number of valences */ - MPI_Allreduce(&my_angles, &num_angles, 1, MPI_INT, MPI_SUM, mpi_data->world); - - Write_Skip_Line( out_control, mpi_data, me, num_angles*line_len, num_angles ); - - if (out_control->traj_method == REG_TRAJ && me == MASTER_NODE) - buffer_req = num_angles * line_len + 1; - else buffer_req = my_angles * line_len + 1; - - if (buffer_req > out_control->buffer_len * DANGER_ZONE) - Reallocate_Output_Buffer( system->error_ptr, out_control, buffer_req ); - - /* fill in the buffer */ - my_angles = 0; - out_control->line[0] = 0; - out_control->buffer[0] = 0; - for (j = 0; j < system->n; ++j) - for (pi = Start_Index(j, bonds); pi < End_Index(j, bonds); ++pi) { - bo_ij = &(bonds->select.bond_list[pi]); - i = bo_ij->nbr; - - if (bo_ij->bo_data.BO >= control->bg_cut) // physical j&i bond - for (pk = Start_Index( pi, thb_intrs); - pk < End_Index( pi, thb_intrs ); ++pk) { - angle_ijk = &(thb_intrs->select.three_body_list[pk]); - k = angle_ijk->thb; - bo_jk = &(bonds->select.bond_list[ angle_ijk->pthb ]); - - if ( system->my_atoms[i].orig_id < system->my_atoms[k].orig_id && - bo_jk->bo_data.BO >= control->bg_cut) { // physical j&k bond - sprintf( out_control->line, ANGLE_BASIC, - system->my_atoms[i].orig_id, system->my_atoms[j].orig_id, - system->my_atoms[k].orig_id, RAD2DEG( angle_ijk->theta ) ); - - strncpy( out_control->buffer + my_angles*line_len, - out_control->line, line_len+1 ); - ++my_angles; - } - } - } - - if (me != MASTER_NODE) { - MPI_Send( out_control->buffer, buffer_req-1, MPI_CHAR, MASTER_NODE, - np*ANGLE_LINES+me, mpi_data->world ); - } else { - buffer_len = my_angles * line_len; - for (i = 0; i < np; ++i) - if (i != MASTER_NODE) { - MPI_Recv( out_control->buffer + buffer_len, buffer_req - buffer_len, - MPI_CHAR, i, np*ANGLE_LINES+i, mpi_data->world, &status ); - MPI_Get_count( &status, MPI_CHAR, &cnt ); - buffer_len += cnt; - } - out_control->buffer[buffer_len] = 0; - fprintf( out_control->strj, "%s", out_control->buffer ); - } - - return REAXC_SUCCESS; -} - - -int Append_Frame( reax_system *system, control_params *control, - simulation_data *data, reax_list **lists, - output_controls *out_control, mpi_datatypes *mpi_data ) -{ - Write_Frame_Header( system, control, data, out_control, mpi_data ); - - if (out_control->write_atoms) - Write_Atoms( system, control, out_control, mpi_data ); - - if (out_control->write_bonds) - Write_Bonds( system, control, (*lists + BONDS), out_control, mpi_data ); - - if (out_control->write_angles) - Write_Angles( system, control, (*lists + BONDS), (*lists + THREE_BODIES), - out_control, mpi_data ); - - return REAXC_SUCCESS; -} - - -int End_Traj( int my_rank, output_controls *out_control ) -{ - if (my_rank == MASTER_NODE) - fclose( out_control->strj ); - - free( out_control->buffer ); - free( out_control->line ); - - return REAXC_SUCCESS; -} diff --git a/src/REAXFF/reaxc_traj.h b/src/REAXFF/reaxc_traj.h deleted file mode 100644 index 3321410a22..0000000000 --- a/src/REAXFF/reaxc_traj.h +++ /dev/null @@ -1,104 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __TRAJ_H__ -#define __TRAJ_H__ - -#include "reaxc_types.h" - -#define MAX_TRJ_LINE_LEN 120 -#define MAX_TRJ_BUFFER_SIZE (MAX_TRJ_LINE_LEN * 100) - -#define NUM_HEADER_LINES 37 -#define HEADER_LINE_LEN 62 -#define STR_LINE "%-37s%-24s\n" -#define INT_LINE "%-37s%-24d\n" -#if defined(LAMMPS_SMALLSMALL) -#define BIGINT_LINE "%-37s%-24d\n" -#else -#define BIGINT_LINE "%-37s%-24lld\n" -#endif -#define INT2_LINE "%-36s%-12d,%-12d\n" -#define REAL_LINE "%-37s%-24.3f\n" -#define SCI_LINE "%-37s%-24g\n" -#define REAL3_LINE "%-32s%9.3f,%9.3f,%9.3f\n" - -#if defined(LAMMPS_BIGBIG) -#define INIT_DESC "%9lld%3d%9s%10.3f\n" //AtomID - AtomType, AtomName, AtomMass -#else -#define INIT_DESC "%9d%3d%9s%10.3f\n" //AtomID - AtomType, AtomName, AtomMass -#endif -#define INIT_DESC_LEN 32 - -#define SIZE_INFO_LINE2 "%-10d%-10d\n" -#define SIZE_INFO_LEN2 21 - -#define SIZE_INFO_LINE3 "%-10d%-10d%-10d\n" -#define SIZE_INFO_LEN3 31 - -#if defined(LAMMPS_BIGBIG) -#define ATOM_BASIC "%9lld%10.3f%10.3f%10.3f%10.3f\n" //AtomID AtomType (X Y Z) Charge -#define ATOM_wV "%9ld%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n" //AtomID (X Y Z) (Vx Vy Vz) Charge -#define ATOM_wF "%9ld%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n" //AtomID (X Y Z) (Fx Fy Fz) Charge -#define ATOM_FULL "%9ld%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n" //AtomID (X Y Z) (Vx Vy Vz) (Fx Fy Fz) Charge -#else -#define ATOM_BASIC "%9d%10.3f%10.3f%10.3f%10.3f\n" //AtomID AtomType (X Y Z) Charge -#define ATOM_wV "%9d%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n" //AtomID (X Y Z) (Vx Vy Vz) Charge -#define ATOM_wF "%9d%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n" //AtomID (X Y Z) (Fx Fy Fz) Charge -#define ATOM_FULL "%9d%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n" //AtomID (X Y Z) (Vx Vy Vz) (Fx Fy Fz) Charge -#endif -#define ATOM_BASIC_LEN 50 -#define ATOM_wV_LEN 80 -#define ATOM_wF_LEN 80 -#define ATOM_FULL_LEN 110 - -#if defined(LAMMPS_BIGBIG) -#define BOND_BASIC "%9lld%9lld%10.3f%10.3f\n" // Atom1 Atom2 Dist Total_BO -#define BOND_FULL "%9lld%9lld%10.3f%10.3f%10.3f%10.3f%10.3f\n" // Atom1 Atom2 Dist Total_BO BOs BOpi BOpi2 -#define ANGLE_BASIC "%9lld%9lld%9lld%10.3f\n" // Atom1 Atom2 Atom3 Theta -#else -#define BOND_BASIC "%9d%9d%10.3f%10.3f\n" // Atom1 Atom2 Dist Total_BO -#define BOND_FULL "%9d%9d%10.3f%10.3f%10.3f%10.3f%10.3f\n" // Atom1 Atom2 Dist Total_BO BOs BOpi BOpi2 -#define ANGLE_BASIC "%9d%9d%9d%10.3f\n" // Atom1 Atom2 Atom3 Theta -#endif -#define BOND_BASIC_LEN 39 -#define BOND_FULL_LEN 69 -#define ANGLE_BASIC_LEN 38 - -enum ATOM_LINE_OPTS { OPT_NOATOM = 0, OPT_ATOM_BASIC = 4, OPT_ATOM_wF = 5, OPT_ATOM_wV = 6, OPT_ATOM_FULL = 7, NR_OPT_ATOM = 8 }; -enum BOND_LINE_OPTS { OPT_NOBOND, OPT_BOND_BASIC, OPT_BOND_FULL, NR_OPT_BOND }; -enum ANGLE_LINE_OPTS { OPT_NOANGLE, OPT_ANGLE_BASIC, NR_OPT_ANGLE }; - - -int Init_Traj( reax_system*, control_params*, output_controls*, - mpi_datatypes*, char* ); -int End_Traj( int, output_controls* ); - -int Append_Frame( reax_system*, control_params*, simulation_data*, - reax_list**, output_controls*, mpi_datatypes* ); - -#endif diff --git a/src/REAXFF/reaxc_types.h b/src/REAXFF/reaxc_types.h deleted file mode 100644 index f4b8bb0a2e..0000000000 --- a/src/REAXFF/reaxc_types.h +++ /dev/null @@ -1,927 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __REAX_TYPES_H_ -#define __REAX_TYPES_H_ - -#include "lmptype.h" -#include -#include -#include "accelerator_kokkos.h" - -namespace LAMMPS_NS { class Error;} - -#if defined LMP_USER_OMP -#define OMP_TIMING 0 - -#ifdef OMP_TIMING -// pkcoff timing fields -enum { - COMPUTEINDEX=0, - COMPUTEWLINDEX, - COMPUTEBFINDEX, - COMPUTEQEQINDEX, - COMPUTENBFINDEX, - COMPUTEIFINDEX, - COMPUTETFINDEX, - COMPUTEBOINDEX, - COMPUTEBONDSINDEX, - COMPUTEATOMENERGYINDEX, - COMPUTEVALENCEANGLESBOINDEX, - COMPUTETORSIONANGLESBOINDEX, - COMPUTEHBONDSINDEX, - COMPUTECG1INDEX, - COMPUTECG2INDEX, - COMPUTECGCOMPUTEINDEX, - COMPUTECALCQINDEX, - COMPUTEINITMVINDEX, - COMPUTEMVCOMPINDEX, - LASTTIMINGINDEX -}; - -extern double ompTimingData[LASTTIMINGINDEX]; -extern int ompTimingCount[LASTTIMINGINDEX]; -extern int ompTimingCGCount[LASTTIMINGINDEX]; -#endif -#endif - -/************* SOME DEFS - crucial for reax_types.h *********/ - -#define LAMMPS_REAX - -//#define DEBUG -//#define DEBUG_FOCUS -//#define TEST_ENERGY -//#define TEST_FORCES -//#define CG_PERFORMANCE -//#define LOG_PERFORMANCE -//#define STANDARD_BOUNDARIES -//#define OLD_BOUNDARIES -//#define MIDPOINT_BOUNDARIES - -#define REAX_MAX_STR 1024 -#define REAX_MAX_NBRS 6 -#define REAX_MAX_3BODY_PARAM 5 -#define REAX_MAX_4BODY_PARAM 5 -#define REAX_MAX_ATOM_TYPES 25 -#define REAX_MAX_MOLECULE_SIZE 20 -#define MAX_BOND 20 // same as reaxc_defs.h - -/********************** TYPE DEFINITIONS ********************/ -typedef int ivec[3]; -typedef double rvec[3]; -typedef double rtensor[3][3]; -typedef double rvec2[2]; -typedef double rvec4[4]; - -// import LAMMPS' definition of tagint and bigint -typedef LAMMPS_NS::tagint rc_tagint; -typedef LAMMPS_NS::bigint rc_bigint; - -typedef struct -{ - int cnt; - int *index; - void *out_atoms; -} mpi_out_data; - -typedef struct -{ - MPI_Comm world; - MPI_Comm comm_mesh3D; - - MPI_Datatype sys_info; - MPI_Datatype mpi_atom_type; - MPI_Datatype boundary_atom_type; - MPI_Datatype mpi_rvec, mpi_rvec2; - MPI_Datatype restart_atom_type; - - MPI_Datatype header_line; - MPI_Datatype header_view; - MPI_Datatype init_desc_line; - MPI_Datatype init_desc_view; - MPI_Datatype atom_line; - MPI_Datatype atom_view; - MPI_Datatype bond_line; - MPI_Datatype bond_view; - MPI_Datatype angle_line; - MPI_Datatype angle_view; - - mpi_out_data out_buffers[REAX_MAX_NBRS]; - void *in1_buffer; - void *in2_buffer; -} mpi_datatypes; - -typedef struct -{ - int n_global; - double* l; - int vdw_type; -} global_parameters; - -typedef struct -{ - /* Line one in field file */ - char name[15]; // Two character atom name - - double r_s; - double valency; // Valency of the atom - double mass; // Mass of atom - double r_vdw; - double epsilon; - double gamma; - double r_pi; - double valency_e; - double nlp_opt; - - /* Line two in field file */ - double alpha; - double gamma_w; - double valency_boc; - double p_ovun5; - double chi; - double eta; - int p_hbond; // 1 for H, 2 for hbonding atoms (O,S,P,N), 0 for others - - /* Line three in field file */ - double r_pi_pi; - double p_lp2; - double b_o_131; - double b_o_132; - double b_o_133; - - /* Line four in the field file */ - double p_ovun2; - double p_val3; - double valency_val; - double p_val5; - double rcore2; - double ecore2; - double acore2; - - /* Line five in the ffield file, only for lgvdw yes */ - double lgcij; - double lgre; - -} single_body_parameters; - -/* Two Body Parameters */ -typedef struct { - /* Bond Order parameters */ - double p_bo1,p_bo2,p_bo3,p_bo4,p_bo5,p_bo6; - double r_s, r_p, r_pp; // r_o distances in BO formula - double p_boc3, p_boc4, p_boc5; - - /* Bond Energy parameters */ - double p_be1, p_be2; - double De_s, De_p, De_pp; - - /* Over/Under coordination parameters */ - double p_ovun1; - - /* Van der Waal interaction parameters */ - double D; - double alpha; - double r_vdW; - double gamma_w; - double rcore, ecore, acore; - double lgcij, lgre; - - /* electrostatic parameters */ - double gamma; // note: this parameter is gamma^-3 and not gamma. - - double v13cor, ovc; -} two_body_parameters; - -/* 3-body parameters */ -typedef struct { - /* valence angle */ - double theta_00; - double p_val1, p_val2, p_val4, p_val7; - - /* penalty */ - double p_pen1; - - /* 3-body conjugation */ - double p_coa1; -} three_body_parameters; - - -typedef struct{ - int cnt; - three_body_parameters prm[REAX_MAX_3BODY_PARAM]; -} three_body_header; - -/* hydrogen-bond parameters */ -typedef struct{ - double r0_hb, p_hb1, p_hb2, p_hb3; -} hbond_parameters; - -/* 4-body parameters */ -typedef struct { - double V1, V2, V3; - - /* torsion angle */ - double p_tor1; - - /* 4-body conjugation */ - double p_cot1; -} four_body_parameters; - -typedef struct -{ - int cnt; - four_body_parameters prm[REAX_MAX_4BODY_PARAM]; -} four_body_header; - -typedef struct -{ - int num_atom_types; - global_parameters gp; - single_body_parameters *sbp; - two_body_parameters **tbp; - three_body_header ***thbp; - hbond_parameters ***hbp; - four_body_header ****fbp; -} reax_interaction; - -struct _reax_atom -{ - rc_tagint orig_id; - int imprt_id; - int type; - char name[8]; - - rvec x; // position - rvec v; // velocity - rvec f; // force - rvec f_old; - - double q; // charge - rvec4 s; // they take part in - rvec4 t; // computing q - - int Hindex; - int num_bonds; - int num_hbonds; - int renumber; - - int numbonds; // true number of bonds around atoms - int nbr_id[MAX_BOND]; // ids of neighbors around atoms - double nbr_bo[MAX_BOND]; // BO values of bond between i and nbr - double sum_bo, no_lp; // sum of BO values and no. of lone pairs -}; -typedef _reax_atom reax_atom; - -typedef struct -{ - double V; - rvec min, max, box_norms; - - rtensor box, box_inv; - rtensor trans, trans_inv; - rtensor g; -} simulation_box; - -struct grid_cell -{ - double cutoff; - rvec min, max; - ivec rel_box; - - int mark; - int type; - int str; - int end; - int top; - int* atoms; - struct grid_cell** nbrs; - ivec* nbrs_x; - rvec* nbrs_cp; -}; - -typedef struct grid_cell grid_cell; - - -typedef struct -{ - int total, max_atoms, max_nbrs; - ivec ncells; - rvec cell_len; - rvec inv_len; - - ivec bond_span; - ivec nonb_span; - ivec vlist_span; - - ivec native_cells; - ivec native_str; - ivec native_end; - - double ghost_cut; - ivec ghost_span; - ivec ghost_nonb_span; - ivec ghost_hbond_span; - ivec ghost_bond_span; - - grid_cell*** cells; - ivec *order; -} grid; - - -typedef struct -{ - int rank; - int est_send, est_recv; - int atoms_str, atoms_cnt; - ivec rltv, prdc; - rvec bndry_min, bndry_max; - - int send_type; - int recv_type; - ivec str_send; - ivec end_send; - ivec str_recv; - ivec end_recv; -} neighbor_proc; - - - -typedef struct -{ - int N; - int exc_gcells; - int exc_atoms; -} bound_estimate; - - - -typedef struct -{ - double ghost_nonb; - double ghost_hbond; - double ghost_bond; - double ghost_cutoff; -} boundary_cutoff; - - -struct _LR_lookup_table; // forward declaration -struct _reax_system -{ - reax_interaction reax_param; - - rc_bigint bigN; - int n, N, numH; - int local_cap, total_cap, gcell_cap, Hcap; - int est_recv, est_trans, max_recved; - int wsize, my_rank, num_nbrs; - ivec my_coords; - neighbor_proc my_nbrs[REAX_MAX_NBRS]; - int *global_offset; - simulation_box big_box, my_box, my_ext_box; - grid my_grid; - boundary_cutoff bndry_cuts; - reax_atom *my_atoms; - - class LAMMPS_NS::Error *error_ptr; - class LAMMPS_NS::Pair *pair_ptr; - int my_bonds; - int mincap,minhbonds; - double safezone, saferzone; - - _LR_lookup_table **LR; - - int omp_active; -}; -typedef _reax_system reax_system; - - - -/* system control parameters */ -typedef struct -{ - char sim_name[REAX_MAX_STR]; - int nprocs; - int nthreads; - ivec procs_by_dim; - /* ensemble values: - 0 : NVE - 1 : bNVT (Berendsen) - 2 : nhNVT (Nose-Hoover) - 3 : sNPT (Parrinello-Rehman-Nose-Hoover) semiisotropic - 4 : iNPT (Parrinello-Rehman-Nose-Hoover) isotropic - 5 : NPT (Parrinello-Rehman-Nose-Hoover) Anisotropic*/ - int ensemble; - int nsteps; - double dt; - int geo_format; - int restart; - - int restrict_bonds; - int remove_CoM_vel; - int random_vel; - int reposition_atoms; - - int reneighbor; - double vlist_cut; - double bond_cut; - double nonb_cut, nonb_low; - double hbond_cut; - double user_ghost_cut; - - double bg_cut; - double bo_cut; - double thb_cut; - double thb_cutsq; - - int tabulate; - - int qeq_freq; - double q_err; - int refactor; - double droptol; - - double T_init, T_final, T; - double Tau_T; - int T_mode; - double T_rate, T_freq; - - int virial; - rvec P, Tau_P, Tau_PT; - int press_mode; - double compressibility; - - int molecular_analysis; - int num_ignored; - int ignore[REAX_MAX_ATOM_TYPES]; - - int dipole_anal; - int freq_dipole_anal; - int diffusion_coef; - int freq_diffusion_coef; - int restrict_type; - - int lgflag; - int enobondsflag; - class LAMMPS_NS::Error *error_ptr; - int me; - -} control_params; - - -typedef struct -{ - double T; - double xi; - double v_xi; - double v_xi_old; - double G_xi; - -} thermostat; - - -typedef struct -{ - double P; - double eps; - double v_eps; - double v_eps_old; - double a_eps; - -} isotropic_barostat; - - -typedef struct -{ - rtensor P; - double P_scalar; - - double eps; - double v_eps; - double v_eps_old; - double a_eps; - - rtensor h0; - rtensor v_g0; - rtensor v_g0_old; - rtensor a_g0; - -} flexible_barostat; - - -typedef struct -{ - double start; - double end; - double elapsed; - - double total; - double comm; - double nbrs; - double init_forces; - double bonded; - double nonb; - double qEq; - int s_matvecs; - int t_matvecs; -} reax_timing; - - -typedef struct -{ - double e_tot; - double e_kin; // Total kinetic energy - double e_pot; - - double e_bond; // Total bond energy - double e_ov; // Total over coordination - double e_un; // Total under coordination energy - double e_lp; // Total under coordination energy - double e_ang; // Total valance angle energy - double e_pen; // Total penalty energy - double e_coa; // Total three body conjgation energy - double e_hb; // Total Hydrogen bond energy - double e_tor; // Total torsional energy - double e_con; // Total four body conjugation energy - double e_vdW; // Total van der Waals energy - double e_ele; // Total electrostatics energy - double e_pol; // Polarization energy -} energy_data; - -typedef struct -{ - int step; - int prev_steps; - double time; - - double M; // Total Mass - double inv_M; // 1 / Total Mass - - rvec xcm; // Center of mass - rvec vcm; // Center of mass velocity - rvec fcm; // Center of mass force - rvec amcm; // Angular momentum of CoM - rvec avcm; // Angular velocity of CoM - double etran_cm; // Translational kinetic energy of CoM - double erot_cm; // Rotational kinetic energy of CoM - - rtensor kinetic; // Kinetic energy tensor - rtensor virial; // Hydrodynamic virial - - energy_data my_en; - energy_data sys_en; - - double N_f; //Number of degrees of freedom - rvec t_scale; - rtensor p_scale; - thermostat therm; // Used in Nose_Hoover method - isotropic_barostat iso_bar; - flexible_barostat flex_bar; - double inv_W; - - double kin_press; - rvec int_press; - rvec my_ext_press; - rvec ext_press; - rvec tot_press; - - reax_timing timing; -} simulation_data; - - -typedef struct{ - int thb; - int pthb; // pointer to the third body on the central atom's nbrlist - double theta, cos_theta; - rvec dcos_di, dcos_dj, dcos_dk; -} three_body_interaction_data; - - -typedef struct { - int nbr; - ivec rel_box; - double d; - rvec dvec; -} far_neighbor_data; - - -typedef struct { - int nbr; - int scl; - far_neighbor_data *ptr; -} hbond_data; - - -typedef struct{ - int wrt; - rvec dVal; -} dDelta_data; - - -typedef struct{ - int wrt; - rvec dBO, dBOpi, dBOpi2; -} dbond_data; - -typedef struct{ - double BO, BO_s, BO_pi, BO_pi2; - double Cdbo, Cdbopi, Cdbopi2; - double C1dbo, C2dbo, C3dbo; - double C1dbopi, C2dbopi, C3dbopi, C4dbopi; - double C1dbopi2, C2dbopi2, C3dbopi2, C4dbopi2; - rvec dBOp, dln_BOp_s, dln_BOp_pi, dln_BOp_pi2; - double *CdboReduction; -} bond_order_data; - -typedef struct { - int nbr; - int sym_index; - int dbond_index; - ivec rel_box; - // rvec ext_factor; - double d; - rvec dvec; - bond_order_data bo_data; -} bond_data; - - -typedef struct { - int j; - double val; -} sparse_matrix_entry; - -typedef struct { - int cap, n, m; - int *start, *end; - sparse_matrix_entry *entries; -} sparse_matrix; - - -typedef struct { - int num_far; - int H, Htop; - int hbonds, num_hbonds; - int bonds, num_bonds; - int num_3body; - int gcell_atoms; -} reallocate_data; - - -typedef struct -{ - int allocated; - - /* communication storage */ - double *tmp_dbl[REAX_MAX_NBRS]; - rvec *tmp_rvec[REAX_MAX_NBRS]; - rvec2 *tmp_rvec2[REAX_MAX_NBRS]; - int *within_bond_box; - - /* bond order related storage */ - double *total_bond_order; - double *Deltap, *Deltap_boc; - double *Delta, *Delta_lp, *Delta_lp_temp, *Delta_e, *Delta_boc, *Delta_val; - double *dDelta_lp, *dDelta_lp_temp; - double *nlp, *nlp_temp, *Clp, *vlpex; - rvec *dDeltap_self; - int *bond_mark, *done_after; - - /* QEq storage */ - sparse_matrix *H, *L, *U; - double *Hdia_inv, *b_s, *b_t, *b_prc, *b_prm, *s, *t; - double *droptol; - rvec2 *b, *x; - - /* GMRES storage */ - double *y, *z, *g; - double *hc, *hs; - double **h, **v; - /* CG storage */ - double *r, *d, *q, *p; - rvec2 *r2, *d2, *q2, *p2; - /* Taper */ - double Tap[8]; //Tap7, Tap6, Tap5, Tap4, Tap3, Tap2, Tap1, Tap0; - - /* storage for analysis */ - int *mark, *old_mark; - rvec *x_old; - - /* storage space for bond restrictions */ - int *restricted; - int **restricted_list; - - /* integrator */ - rvec *v_const; - - /* force calculations */ - double *CdDelta; // coefficient of dDelta - rvec *f; - - /* omp */ - rvec *forceReduction; - rvec *my_ext_pressReduction; - double *CdDeltaReduction; - int *valence_angle_atom_myoffset; - - reallocate_data realloc; -} storage; - - -typedef union -{ - void *v; - three_body_interaction_data *three_body_list; - bond_data *bond_list; - dbond_data *dbo_list; - dDelta_data *dDelta_list; - far_neighbor_data *far_nbr_list; - hbond_data *hbond_list; -} list_type; - - -struct _reax_list -{ - int allocated; - - int n; - int num_intrs; - - int *index; - int *end_index; - - int type; - list_type select; - class LAMMPS_NS::Error *error_ptr; -}; -typedef _reax_list reax_list; - - -typedef struct -{ - FILE *strj; - int trj_offset; - int atom_line_len; - int bond_line_len; - int angle_line_len; - int write_atoms; - int write_bonds; - int write_angles; - char *line; - int buffer_len; - char *buffer; - - FILE *out; - FILE *pot; - FILE *log; - FILE *mol, *ign; - FILE *dpl; - FILE *drft; - FILE *pdb; - FILE *prs; - - int write_steps; - int traj_compress; - int traj_method; - char traj_title[81]; - int atom_info; - int bond_info; - int angle_info; - - int restart_format; - int restart_freq; - int debug_level; - int energy_update_freq; - -} output_controls; - - -typedef struct -{ - int atom_count; - int atom_list[REAX_MAX_MOLECULE_SIZE]; - int mtypes[REAX_MAX_ATOM_TYPES]; -} molecule; - - -struct LR_data -{ - double H; - double e_vdW, CEvd; - double e_ele, CEclmb; - - LAMMPS_INLINE - LR_data() {} - - LAMMPS_INLINE - void operator = (const LR_data& rhs) { - H = rhs.H; - e_vdW = rhs.e_vdW; - CEvd = rhs.CEvd; - e_ele = rhs.e_ele; - CEclmb = rhs.CEclmb; - } - LAMMPS_INLINE - void operator = (const LR_data& rhs) volatile { - H = rhs.H; - e_vdW = rhs.e_vdW; - CEvd = rhs.CEvd; - e_ele = rhs.e_ele; - CEclmb = rhs.CEclmb; - } -}; - - -struct cubic_spline_coef -{ - double a, b, c, d; - - LAMMPS_INLINE - cubic_spline_coef() {} - - LAMMPS_INLINE - cubic_spline_coef(const cubic_spline_coef &_c) { - a = _c.a; - b = _c.b; - c = _c.c; - d = _c.d; - } - - LAMMPS_INLINE - void operator=(const cubic_spline_coef &rhs) { - a = rhs.a; - b = rhs.b; - c = rhs.c; - d = rhs.d; - } - - LAMMPS_INLINE - void operator=(const cubic_spline_coef &rhs) volatile { - a = rhs.a; - b = rhs.b; - c = rhs.c; - d = rhs.d; - } -}; - - - -typedef struct _LR_lookup_table -{ - double xmin, xmax; - int n; - double dx, inv_dx; - double a; - double m; - double c; - - LR_data *y; - cubic_spline_coef *H; - cubic_spline_coef *vdW, *CEvd; - cubic_spline_coef *ele, *CEclmb; -} LR_lookup_table; - -/* function pointer defs */ -typedef void (*evolve_function)(reax_system*, control_params*, - simulation_data*, storage*, reax_list**, - output_controls*, mpi_datatypes* ); - -typedef void (*interaction_function) (reax_system*, control_params*, - simulation_data*, storage*, - reax_list**, output_controls*); - -typedef void (*print_interaction)(reax_system*, control_params*, - simulation_data*, storage*, - reax_list**, output_controls*); - -typedef double (*lookup_function)(double); - -typedef void (*message_sorter) (reax_system*, int, int, int, mpi_out_data*); -typedef void (*unpacker) ( reax_system*, int, void*, int, neighbor_proc*, int ); - -typedef void (*dist_packer) (void*, mpi_out_data*); -typedef void (*coll_unpacker) (void*, void*, mpi_out_data*); -#endif diff --git a/src/REAXFF/reaxc_valence_angles.cpp b/src/REAXFF/reaxc_valence_angles.cpp deleted file mode 100644 index 26dba52512..0000000000 --- a/src/REAXFF/reaxc_valence_angles.cpp +++ /dev/null @@ -1,419 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_valence_angles.h" -#include -#include "pair.h" -#include "reaxc_defs.h" -#include "reaxc_list.h" -#include "reaxc_vector.h" - -#include "error.h" - -static double Dot( double* v1, double* v2, int k ) -{ - double ret = 0.0; - - for (int i=0; i < k; ++i) - ret += v1[i] * v2[i]; - - return ret; -} - -void Calculate_Theta( rvec dvec_ji, double d_ji, rvec dvec_jk, double d_jk, - double *theta, double *cos_theta ) -{ - (*cos_theta) = Dot( dvec_ji, dvec_jk, 3 ) / ( d_ji * d_jk ); - if (*cos_theta > 1.) *cos_theta = 1.0; - if (*cos_theta < -1.) *cos_theta = -1.0; - - (*theta) = acos( *cos_theta ); -} - -void Calculate_dCos_Theta( rvec dvec_ji, double d_ji, rvec dvec_jk, double d_jk, - rvec* dcos_theta_di, - rvec* dcos_theta_dj, - rvec* dcos_theta_dk ) -{ - int t; - double sqr_d_ji = SQR(d_ji); - double sqr_d_jk = SQR(d_jk); - double inv_dists = 1.0 / (d_ji * d_jk); - double inv_dists3 = pow( inv_dists, 3.0 ); - double dot_dvecs = Dot( dvec_ji, dvec_jk, 3 ); - double Cdot_inv3 = dot_dvecs * inv_dists3; - - for (t = 0; t < 3; ++t) { - (*dcos_theta_di)[t] = dvec_jk[t] * inv_dists - - Cdot_inv3 * sqr_d_jk * dvec_ji[t]; - (*dcos_theta_dj)[t] = -(dvec_jk[t] + dvec_ji[t]) * inv_dists + - Cdot_inv3 * ( sqr_d_jk * dvec_ji[t] + sqr_d_ji * dvec_jk[t] ); - (*dcos_theta_dk)[t] = dvec_ji[t] * inv_dists - - Cdot_inv3 * sqr_d_ji * dvec_jk[t]; - } -} - - -void Valence_Angles( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls * /*out_control*/ ) -{ - int i, j, pi, k, pk, t; - int type_i, type_j, type_k; - int start_j, end_j, start_pk, end_pk; - int cnt, num_thb_intrs; - - double temp, temp_bo_jt, pBOjt7; - double p_val1, p_val2, p_val3, p_val4, p_val5; - double p_val6, p_val7, p_val8, p_val9, p_val10; - double p_pen1, p_pen2, p_pen3, p_pen4; - double p_coa1, p_coa2, p_coa3, p_coa4; - double trm8, expval6, expval7, expval2theta, expval12theta, exp3ij, exp3jk; - double exp_pen2ij, exp_pen2jk, exp_pen3, exp_pen4, trm_pen34, exp_coa2; - double dSBO1, dSBO2, SBO, SBO2, CSBO2, SBOp, prod_SBO, vlpadj; - double CEval1, CEval2, CEval3, CEval4, CEval5, CEval6, CEval7, CEval8; - double CEpen1, CEpen2, CEpen3; - double e_ang, e_coa, e_pen; - double CEcoa1, CEcoa2, CEcoa3, CEcoa4, CEcoa5; - double Cf7ij, Cf7jk, Cf8j, Cf9j; - double f7_ij, f7_jk, f8_Dj, f9_Dj; - double Ctheta_0, theta_0, theta_00, theta, cos_theta, sin_theta; - double BOA_ij, BOA_jk; - rvec force, ext_press; - - // Tallying variables - double eng_tmp, fi_tmp[3], fj_tmp[3], fk_tmp[3]; - double delij[3], delkj[3]; - - three_body_header *thbh; - three_body_parameters *thbp; - three_body_interaction_data *p_ijk, *p_kji; - bond_data *pbond_ij, *pbond_jk, *pbond_jt; - bond_order_data *bo_ij, *bo_jk, *bo_jt; - reax_list *bonds = (*lists) + BONDS; - reax_list *thb_intrs = (*lists) + THREE_BODIES; - - /* global parameters used in these calculations */ - p_val6 = system->reax_param.gp.l[14]; - p_val8 = system->reax_param.gp.l[33]; - p_val9 = system->reax_param.gp.l[16]; - p_val10 = system->reax_param.gp.l[17]; - num_thb_intrs = 0; - - - for (j = 0; j < system->N; ++j) { // Ray: the first one with system->N - type_j = system->my_atoms[j].type; - if (type_j < 0) continue; - start_j = Start_Index(j, bonds); - end_j = End_Index(j, bonds); - - p_val3 = system->reax_param.sbp[ type_j ].p_val3; - p_val5 = system->reax_param.sbp[ type_j ].p_val5; - - SBOp = 0, prod_SBO = 1; - for (t = start_j; t < end_j; ++t) { - bo_jt = &(bonds->select.bond_list[t].bo_data); - SBOp += (bo_jt->BO_pi + bo_jt->BO_pi2); - temp = SQR( bo_jt->BO ); - temp *= temp; - temp *= temp; - prod_SBO *= exp( -temp ); - } - - if (workspace->vlpex[j] >= 0) { - vlpadj = 0; - dSBO2 = prod_SBO - 1; - } else { - vlpadj = workspace->nlp[j]; - dSBO2 = (prod_SBO - 1) * (1 - p_val8 * workspace->dDelta_lp[j]); - } - - SBO = SBOp + (1 - prod_SBO) * (-workspace->Delta_boc[j] - p_val8 * vlpadj); - dSBO1 = -8 * prod_SBO * ( workspace->Delta_boc[j] + p_val8 * vlpadj ); - - if (SBO <= 0) - SBO2 = 0, CSBO2 = 0; - else if (SBO > 0 && SBO <= 1) { - SBO2 = pow( SBO, p_val9 ); - CSBO2 = p_val9 * pow( SBO, p_val9 - 1 ); - } - else if (SBO > 1 && SBO < 2) { - SBO2 = 2 - pow( 2-SBO, p_val9 ); - CSBO2 = p_val9 * pow( 2 - SBO, p_val9 - 1 ); - } - else - SBO2 = 2, CSBO2 = 0; - - expval6 = exp( p_val6 * workspace->Delta_boc[j] ); - - for (pi = start_j; pi < end_j; ++pi) { - Set_Start_Index( pi, num_thb_intrs, thb_intrs ); - pbond_ij = &(bonds->select.bond_list[pi]); - bo_ij = &(pbond_ij->bo_data); - BOA_ij = bo_ij->BO - control->thb_cut; - - - if ( BOA_ij/*bo_ij->BO*/ > 0.0 && - ( j < system->n || pbond_ij->nbr < system->n )) { - i = pbond_ij->nbr; - type_i = system->my_atoms[i].type; - - for (pk = start_j; pk < pi; ++pk) { - start_pk = Start_Index( pk, thb_intrs ); - end_pk = End_Index( pk, thb_intrs ); - - for (t = start_pk; t < end_pk; ++t) - if (thb_intrs->select.three_body_list[t].thb == i) { - p_ijk = &(thb_intrs->select.three_body_list[num_thb_intrs] ); - p_kji = &(thb_intrs->select.three_body_list[t]); - - p_ijk->thb = bonds->select.bond_list[pk].nbr; - p_ijk->pthb = pk; - p_ijk->theta = p_kji->theta; - rvec_Copy( p_ijk->dcos_di, p_kji->dcos_dk ); - rvec_Copy( p_ijk->dcos_dj, p_kji->dcos_dj ); - rvec_Copy( p_ijk->dcos_dk, p_kji->dcos_di ); - - ++num_thb_intrs; - break; - } - } - - for (pk = pi+1; pk < end_j; ++pk) { - pbond_jk = &(bonds->select.bond_list[pk]); - bo_jk = &(pbond_jk->bo_data); - BOA_jk = bo_jk->BO - control->thb_cut; - k = pbond_jk->nbr; - type_k = system->my_atoms[k].type; - p_ijk = &( thb_intrs->select.three_body_list[num_thb_intrs] ); - - Calculate_Theta( pbond_ij->dvec, pbond_ij->d, - pbond_jk->dvec, pbond_jk->d, - &theta, &cos_theta ); - - Calculate_dCos_Theta( pbond_ij->dvec, pbond_ij->d, - pbond_jk->dvec, pbond_jk->d, - &(p_ijk->dcos_di), &(p_ijk->dcos_dj), - &(p_ijk->dcos_dk) ); - p_ijk->thb = k; - p_ijk->pthb = pk; - p_ijk->theta = theta; - - sin_theta = sin( theta ); - if (sin_theta < 1.0e-5) - sin_theta = 1.0e-5; - - ++num_thb_intrs; - - - if ((j < system->n) && (BOA_jk > 0.0) && - (bo_ij->BO > control->thb_cut) && - (bo_jk->BO > control->thb_cut) && - (bo_ij->BO * bo_jk->BO > control->thb_cutsq)) { - thbh = &( system->reax_param.thbp[ type_i ][ type_j ][ type_k ] ); - - for (cnt = 0; cnt < thbh->cnt; ++cnt) { - if (fabs(thbh->prm[cnt].p_val1) > 0.001) { - thbp = &( thbh->prm[cnt] ); - - /* ANGLE ENERGY */ - p_val1 = thbp->p_val1; - p_val2 = thbp->p_val2; - p_val4 = thbp->p_val4; - p_val7 = thbp->p_val7; - theta_00 = thbp->theta_00; - - exp3ij = exp( -p_val3 * pow( BOA_ij, p_val4 ) ); - f7_ij = 1.0 - exp3ij; - Cf7ij = p_val3 * p_val4 * pow( BOA_ij, p_val4 - 1.0 ) * exp3ij; - - exp3jk = exp( -p_val3 * pow( BOA_jk, p_val4 ) ); - f7_jk = 1.0 - exp3jk; - Cf7jk = p_val3 * p_val4 * pow( BOA_jk, p_val4 - 1.0 ) * exp3jk; - - expval7 = exp( -p_val7 * workspace->Delta_boc[j] ); - trm8 = 1.0 + expval6 + expval7; - f8_Dj = p_val5 - ( (p_val5 - 1.0) * (2.0 + expval6) / trm8 ); - Cf8j = ( (1.0 - p_val5) / SQR(trm8) ) * - ( p_val6 * expval6 * trm8 - - (2.0 + expval6) * ( p_val6*expval6 - p_val7*expval7 ) ); - - theta_0 = 180.0 - theta_00 * (1.0 - - exp(-p_val10 * (2.0 - SBO2))); - theta_0 = DEG2RAD( theta_0 ); - - expval2theta = exp( -p_val2 * SQR(theta_0 - theta) ); - if (p_val1 >= 0) - expval12theta = p_val1 * (1.0 - expval2theta); - else // To avoid linear Me-H-Me angles (6/6/06) - expval12theta = p_val1 * -expval2theta; - - CEval1 = Cf7ij * f7_jk * f8_Dj * expval12theta; - CEval2 = Cf7jk * f7_ij * f8_Dj * expval12theta; - CEval3 = Cf8j * f7_ij * f7_jk * expval12theta; - CEval4 = -2.0 * p_val1 * p_val2 * f7_ij * f7_jk * f8_Dj * - expval2theta * (theta_0 - theta); - - Ctheta_0 = p_val10 * DEG2RAD(theta_00) * - exp( -p_val10 * (2.0 - SBO2) ); - - CEval5 = -CEval4 * Ctheta_0 * CSBO2; - CEval6 = CEval5 * dSBO1; - CEval7 = CEval5 * dSBO2; - CEval8 = -CEval4 / sin_theta; - - data->my_en.e_ang += e_ang = - f7_ij * f7_jk * f8_Dj * expval12theta; - /* END ANGLE ENERGY*/ - - /* PENALTY ENERGY */ - p_pen1 = thbp->p_pen1; - p_pen2 = system->reax_param.gp.l[19]; - p_pen3 = system->reax_param.gp.l[20]; - p_pen4 = system->reax_param.gp.l[21]; - - exp_pen2ij = exp( -p_pen2 * SQR( BOA_ij - 2.0 ) ); - exp_pen2jk = exp( -p_pen2 * SQR( BOA_jk - 2.0 ) ); - exp_pen3 = exp( -p_pen3 * workspace->Delta[j] ); - exp_pen4 = exp( p_pen4 * workspace->Delta[j] ); - trm_pen34 = 1.0 + exp_pen3 + exp_pen4; - f9_Dj = ( 2.0 + exp_pen3 ) / trm_pen34; - Cf9j = ( -p_pen3 * exp_pen3 * trm_pen34 - - (2.0 + exp_pen3) * ( -p_pen3 * exp_pen3 + - p_pen4 * exp_pen4 ) ) / - SQR( trm_pen34 ); - - data->my_en.e_pen += e_pen = - p_pen1 * f9_Dj * exp_pen2ij * exp_pen2jk; - - CEpen1 = e_pen * Cf9j / f9_Dj; - temp = -2.0 * p_pen2 * e_pen; - CEpen2 = temp * (BOA_ij - 2.0); - CEpen3 = temp * (BOA_jk - 2.0); - /* END PENALTY ENERGY */ - - /* COALITION ENERGY */ - p_coa1 = thbp->p_coa1; - p_coa2 = system->reax_param.gp.l[2]; - p_coa3 = system->reax_param.gp.l[38]; - p_coa4 = system->reax_param.gp.l[30]; - - exp_coa2 = exp( p_coa2 * workspace->Delta_val[j] ); - data->my_en.e_coa += e_coa = - p_coa1 / (1. + exp_coa2) * - exp( -p_coa3 * SQR(workspace->total_bond_order[i]-BOA_ij) ) * - exp( -p_coa3 * SQR(workspace->total_bond_order[k]-BOA_jk) ) * - exp( -p_coa4 * SQR(BOA_ij - 1.5) ) * - exp( -p_coa4 * SQR(BOA_jk - 1.5) ); - - CEcoa1 = -2 * p_coa4 * (BOA_ij - 1.5) * e_coa; - CEcoa2 = -2 * p_coa4 * (BOA_jk - 1.5) * e_coa; - CEcoa3 = -p_coa2 * exp_coa2 * e_coa / (1 + exp_coa2); - CEcoa4 = -2 * p_coa3 * - (workspace->total_bond_order[i]-BOA_ij) * e_coa; - CEcoa5 = -2 * p_coa3 * - (workspace->total_bond_order[k]-BOA_jk) * e_coa; - /* END COALITION ENERGY */ - - /* FORCES */ - bo_ij->Cdbo += (CEval1 + CEpen2 + (CEcoa1 - CEcoa4)); - bo_jk->Cdbo += (CEval2 + CEpen3 + (CEcoa2 - CEcoa5)); - workspace->CdDelta[j] += ((CEval3 + CEval7) + CEpen1 + CEcoa3); - workspace->CdDelta[i] += CEcoa4; - workspace->CdDelta[k] += CEcoa5; - - for (t = start_j; t < end_j; ++t) { - pbond_jt = &( bonds->select.bond_list[t] ); - bo_jt = &(pbond_jt->bo_data); - temp_bo_jt = bo_jt->BO; - temp = CUBE( temp_bo_jt ); - pBOjt7 = temp * temp * temp_bo_jt; - - bo_jt->Cdbo += (CEval6 * pBOjt7); - bo_jt->Cdbopi += CEval5; - bo_jt->Cdbopi2 += CEval5; - } - - if (control->virial == 0) { - rvec_ScaledAdd( workspace->f[i], CEval8, p_ijk->dcos_di ); - rvec_ScaledAdd( workspace->f[j], CEval8, p_ijk->dcos_dj ); - rvec_ScaledAdd( workspace->f[k], CEval8, p_ijk->dcos_dk ); - } else { - rvec_Scale( force, CEval8, p_ijk->dcos_di ); - rvec_Add( workspace->f[i], force ); - rvec_iMultiply( ext_press, pbond_ij->rel_box, force ); - rvec_Add( data->my_ext_press, ext_press ); - - rvec_ScaledAdd( workspace->f[j], CEval8, p_ijk->dcos_dj ); - - rvec_Scale( force, CEval8, p_ijk->dcos_dk ); - rvec_Add( workspace->f[k], force ); - rvec_iMultiply( ext_press, pbond_jk->rel_box, force ); - rvec_Add( data->my_ext_press, ext_press ); - } - - /* tally into per-atom virials */ - if (system->pair_ptr->vflag_atom || system->pair_ptr->evflag) { - - /* Acquire vectors */ - rvec_ScaledSum( delij, 1., system->my_atoms[i].x, - -1., system->my_atoms[j].x ); - rvec_ScaledSum( delkj, 1., system->my_atoms[k].x, - -1., system->my_atoms[j].x ); - - rvec_Scale( fi_tmp, -CEval8, p_ijk->dcos_di ); - rvec_Scale( fj_tmp, -CEval8, p_ijk->dcos_dj ); - rvec_Scale( fk_tmp, -CEval8, p_ijk->dcos_dk ); - - eng_tmp = e_ang + e_pen + e_coa; - - if (system->pair_ptr->evflag) - system->pair_ptr->ev_tally(j,j,system->N,1,eng_tmp,0.0,0.0,0.0,0.0,0.0); - if (system->pair_ptr->vflag_atom) - system->pair_ptr->v_tally3(i,j,k,fi_tmp,fk_tmp,delij,delkj); - } - } - } - } - } - } - - Set_End_Index(pi, num_thb_intrs, thb_intrs ); - } - } - - if (num_thb_intrs >= thb_intrs->num_intrs * DANGER_ZONE) { - workspace->realloc.num_3body = num_thb_intrs; - if (num_thb_intrs > thb_intrs->num_intrs) { - char errmsg[128]; - snprintf(errmsg, 128, "step%d-ran out of space on angle_list: top=%d, max=%d", - data->step, num_thb_intrs, thb_intrs->num_intrs); - control->error_ptr->one(FLERR, errmsg); - } - } - -} diff --git a/src/REAXFF/reaxc_valence_angles.h b/src/REAXFF/reaxc_valence_angles.h deleted file mode 100644 index a5dc12c16b..0000000000 --- a/src/REAXFF/reaxc_valence_angles.h +++ /dev/null @@ -1,40 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __VALENCE_ANGLES_H_ -#define __VALENCE_ANGLES_H_ - -#include "reaxc_types.h" - -void Valence_Angles( reax_system*, control_params*, simulation_data*, - storage*, reax_list**, output_controls* ); - -void Calculate_Theta( rvec, double, rvec, double, double*, double* ); - -void Calculate_dCos_Theta( rvec, double, rvec, double, rvec*, rvec*, rvec* ); - -#endif diff --git a/src/REAXFF/reaxc_vector.cpp b/src/REAXFF/reaxc_vector.cpp deleted file mode 100644 index 5497d41c9b..0000000000 --- a/src/REAXFF/reaxc_vector.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#include "reaxc_vector.h" -#include -#include "reaxc_defs.h" - -void rvec_Copy( rvec dest, rvec src ) -{ - dest[0] = src[0], dest[1] = src[1], dest[2] = src[2]; -} - - -void rvec_Scale( rvec ret, double c, rvec v ) -{ - ret[0] = c * v[0], ret[1] = c * v[1], ret[2] = c * v[2]; -} - - -void rvec_Add( rvec ret, rvec v ) -{ - ret[0] += v[0], ret[1] += v[1], ret[2] += v[2]; -} - - -void rvec_ScaledAdd( rvec ret, double c, rvec v ) -{ - ret[0] += c * v[0], ret[1] += c * v[1], ret[2] += c * v[2]; -} - - -void rvec_ScaledSum( rvec ret, double c1, rvec v1 ,double c2, rvec v2 ) -{ - ret[0] = c1 * v1[0] + c2 * v2[0]; - ret[1] = c1 * v1[1] + c2 * v2[1]; - ret[2] = c1 * v1[2] + c2 * v2[2]; -} - - -double rvec_Dot( rvec v1, rvec v2 ) -{ - return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]; -} - - -void rvec_iMultiply( rvec r, ivec v1, rvec v2 ) -{ - r[0] = v1[0] * v2[0]; - r[1] = v1[1] * v2[1]; - r[2] = v1[2] * v2[2]; -} - - -void rvec_Cross( rvec ret, rvec v1, rvec v2 ) -{ - ret[0] = v1[1] * v2[2] - v1[2] * v2[1]; - ret[1] = v1[2] * v2[0] - v1[0] * v2[2]; - ret[2] = v1[0] * v2[1] - v1[1] * v2[0]; -} - - -double rvec_Norm_Sqr( rvec v ) -{ - return SQR(v[0]) + SQR(v[1]) + SQR(v[2]); -} - - -double rvec_Norm( rvec v ) -{ - return sqrt( SQR(v[0]) + SQR(v[1]) + SQR(v[2]) ); -} - - -void rvec_MakeZero( rvec v ) -{ - v[0] = v[1] = v[2] = 0.000000000000000e+00; -} - - -void rtensor_MatVec( rvec ret, rtensor m, rvec v ) -{ - int i; - rvec temp; - - if (ret == v) - { - for (i = 0; i < 3; ++i) - temp[i] = m[i][0] * v[0] + m[i][1] * v[1] + m[i][2] * v[2]; - - for (i = 0; i < 3; ++i) - ret[i] = temp[i]; - } - else - { - for (i = 0; i < 3; ++i) - ret[i] = m[i][0] * v[0] + m[i][1] * v[1] + m[i][2] * v[2]; - } -} - - -void rtensor_MakeZero( rtensor t ) -{ - t[0][0] = t[0][1] = t[0][2] = 0; - t[1][0] = t[1][1] = t[1][2] = 0; - t[2][0] = t[2][1] = t[2][2] = 0; -} - - -void ivec_MakeZero( ivec v ) -{ - v[0] = v[1] = v[2] = 0; -} - - -void ivec_Copy( ivec dest, ivec src ) -{ - dest[0] = src[0], dest[1] = src[1], dest[2] = src[2]; -} - - -void ivec_Scale( ivec dest, double C, ivec src ) -{ - dest[0] = (int)(C * src[0]); - dest[1] = (int)(C * src[1]); - dest[2] = (int)(C * src[2]); -} - - -void ivec_Sum( ivec dest, ivec v1, ivec v2 ) -{ - dest[0] = v1[0] + v2[0]; - dest[1] = v1[1] + v2[1]; - dest[2] = v1[2] + v2[2]; -} - - diff --git a/src/REAXFF/reaxc_vector.h b/src/REAXFF/reaxc_vector.h deleted file mode 100644 index f2068d4d4f..0000000000 --- a/src/REAXFF/reaxc_vector.h +++ /dev/null @@ -1,54 +0,0 @@ -// clang-format off -/*---------------------------------------------------------------------- - PuReMD - Purdue ReaxFF Molecular Dynamics Program - - Copyright (2010) Purdue University - Hasan Metin Aktulga, hmaktulga@lbl.gov - Joseph Fogarty, jcfogart@mail.usf.edu - Sagar Pandit, pandit@usf.edu - Ananth Y Grama, ayg@cs.purdue.edu - - Please cite the related publication: - H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, - "Parallel Reactive Molecular Dynamics: Numerical Methods and - Algorithmic Techniques", Parallel Computing, in press. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details: - . - ----------------------------------------------------------------------*/ - -#ifndef __VECTOR_H_ -#define __VECTOR_H_ - -#include "reaxc_types.h" - -void rvec_Copy( rvec, rvec ); -void rvec_Scale( rvec, double, rvec ); -void rvec_Add( rvec, rvec ); -void rvec_ScaledAdd( rvec, double, rvec ); -void rvec_ScaledSum( rvec, double, rvec, double, rvec ); -double rvec_Dot( rvec, rvec ); -void rvec_iMultiply( rvec, ivec, rvec ); -void rvec_Cross( rvec, rvec, rvec ); -double rvec_Norm_Sqr( rvec ); -double rvec_Norm( rvec ); -void rvec_MakeZero( rvec ); -void rvec_Random( rvec ); - -void rtensor_MakeZero( rtensor ); -void rtensor_MatVec( rvec, rtensor, rvec ); - -void ivec_MakeZero( ivec ); -void ivec_Copy( ivec, ivec ); -void ivec_Scale( ivec, double, ivec ); -void ivec_Sum( ivec, ivec, ivec ); - -#endif diff --git a/src/REAXFF/reaxff_allocate.cpp b/src/REAXFF/reaxff_allocate.cpp new file mode 100644 index 0000000000..cbb53420ba --- /dev/null +++ b/src/REAXFF/reaxff_allocate.cpp @@ -0,0 +1,322 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + Hasan Metin Aktulga, hmaktulga@lbl.gov + Joseph Fogarty, jcfogart@mail.usf.edu + Sagar Pandit, pandit@usf.edu + Ananth Y Grama, ayg@cs.purdue.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, in press. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_api.h" + +#include "error.h" +#include "memory.h" +#include "pair.h" + +namespace ReaxFF { + + /* allocate space for my_atoms + important: we cannot know the exact number of atoms that will fall into a + process's box throughout the whole simulation. therefore + we need to make upper bound estimates for various data structures */ + void PreAllocate_Space(reax_system *system, storage * workspace) + { + const int mincap = system->mincap; + const double safezone = system->safezone; + + // determine the local and total capacity + + system->local_cap = MAX((int)(system->n * safezone), mincap); + system->total_cap = MAX((int)(system->N * safezone), mincap); + + system->my_atoms = (reax_atom*) scalloc(system->error_ptr, + system->total_cap, sizeof(reax_atom), "my_atoms"); + + // Nullify some arrays only used in omp styles + // Should be safe to do here since called in pair->setup(); + + workspace->CdDeltaReduction = nullptr; + workspace->forceReduction = nullptr; + workspace->valence_angle_atom_myoffset = nullptr; + } + + /************* system *************/ + + void DeAllocate_System(reax_system *system) + { + auto error = system->error_ptr; + auto memory = system->mem_ptr; + + // deallocate the atom list + sfree(error, system->my_atoms, "system->my_atoms"); + + // deallocate the ffield parameters storage + memory->destroy(system->reax_param.gp.l); + memory->destroy(system->reax_param.sbp); + memory->destroy(system->reax_param.tbp); + memory->destroy(system->reax_param.thbp); + memory->destroy(system->reax_param.hbp); + memory->destroy(system->reax_param.fbp); + } + + /************* workspace *************/ + void DeAllocate_Workspace(control_params *control, storage *workspace) + { + if (!workspace->allocated) + return; + + workspace->allocated = 0; + auto error = control->error_ptr; + + /* bond order storage */ + sfree(error, workspace->total_bond_order, "total_bo"); + sfree(error, workspace->Deltap, "Deltap"); + sfree(error, workspace->Deltap_boc, "Deltap_boc"); + sfree(error, workspace->dDeltap_self, "dDeltap_self"); + sfree(error, workspace->Delta, "Delta"); + sfree(error, workspace->Delta_lp, "Delta_lp"); + sfree(error, workspace->Delta_lp_temp, "Delta_lp_temp"); + sfree(error, workspace->dDelta_lp, "dDelta_lp"); + sfree(error, workspace->dDelta_lp_temp, "dDelta_lp_temp"); + sfree(error, workspace->Delta_e, "Delta_e"); + sfree(error, workspace->Delta_boc, "Delta_boc"); + sfree(error, workspace->Delta_val, "Delta_val"); + sfree(error, workspace->nlp, "nlp"); + sfree(error, workspace->nlp_temp, "nlp_temp"); + sfree(error, workspace->Clp, "Clp"); + sfree(error, workspace->vlpex, "vlpex"); + sfree(error, workspace->bond_mark, "bond_mark"); + + /* force related storage */ + sfree(error, workspace->f, "f"); + sfree(error, workspace->CdDelta, "CdDelta"); + + /* reductions */ + + if (workspace->CdDeltaReduction) + sfree(error, workspace->CdDeltaReduction, "cddelta_reduce"); + if (workspace->forceReduction) + sfree(error, workspace->forceReduction, "f_reduce"); + if (workspace->valence_angle_atom_myoffset) + sfree(error, workspace->valence_angle_atom_myoffset, "valence_angle_atom_myoffset"); + } + + void Allocate_Workspace(control_params *control, storage *workspace, int total_cap) + { + int total_real, total_rvec; + auto error = control->error_ptr; + + workspace->allocated = 1; + total_real = total_cap * sizeof(double); + total_rvec = total_cap * sizeof(rvec); + + /* bond order related storage */ + workspace->total_bond_order = (double*) smalloc(error, total_real, "total_bo"); + workspace->Deltap = (double*) smalloc(error, total_real, "Deltap"); + workspace->Deltap_boc = (double*) smalloc(error, total_real, "Deltap_boc"); + workspace->dDeltap_self = (rvec*) smalloc(error, total_rvec, "dDeltap_self"); + workspace->Delta = (double*) smalloc(error, total_real, "Delta"); + workspace->Delta_lp = (double*) smalloc(error, total_real, "Delta_lp"); + workspace->Delta_lp_temp = (double*) smalloc(error, total_real, "Delta_lp_temp"); + workspace->dDelta_lp = (double*) smalloc(error, total_real, "dDelta_lp"); + workspace->dDelta_lp_temp = (double*) smalloc(error, total_real, "dDelta_lp_temp"); + workspace->Delta_e = (double*) smalloc(error, total_real, "Delta_e"); + workspace->Delta_boc = (double*) smalloc(error, total_real, "Delta_boc"); + workspace->Delta_val = (double*) smalloc(error, total_real, "Delta_val"); + workspace->nlp = (double*) smalloc(error, total_real, "nlp"); + workspace->nlp_temp = (double*) smalloc(error, total_real, "nlp_temp"); + workspace->Clp = (double*) smalloc(error, total_real, "Clp"); + workspace->vlpex = (double*) smalloc(error, total_real, "vlpex"); + workspace->bond_mark = (int*) scalloc(error, total_cap, sizeof(int), "bond_mark"); + + /* force related storage */ + workspace->f = (rvec*) scalloc(error, total_cap, sizeof(rvec), "f"); + workspace->CdDelta = (double*) scalloc(error, total_cap, sizeof(double), "CdDelta"); + + // storage for reductions with multiple threads + + workspace->CdDeltaReduction = (double *) scalloc(error, + sizeof(double), (rc_bigint)total_cap*control->nthreads, "cddelta_reduce"); + workspace->forceReduction = (rvec *) scalloc(error, + sizeof(rvec), (rc_bigint)total_cap*control->nthreads, "forceReduction"); + workspace->valence_angle_atom_myoffset = (int *) scalloc(error, + sizeof(int), total_cap, "valence_angle_atom_myoffset"); + } + + + static void Reallocate_Neighbor_List(reax_list *far_nbrs, int n, int num_intrs) + { + Delete_List(far_nbrs); + Make_List(n, num_intrs, TYP_FAR_NEIGHBOR, far_nbrs); + } + + static int Reallocate_HBonds_List(reax_system *system, reax_list *hbonds) + { + int i, total_hbonds; + + int mincap = system->mincap; + double saferzone = system->saferzone; + + total_hbonds = 0; + for (i = 0; i < system->n; ++i) + if ((system->my_atoms[i].Hindex) >= 0) { + total_hbonds += system->my_atoms[i].num_hbonds; + } + total_hbonds = (int)(MAX(total_hbonds*saferzone, mincap*system->minhbonds)); + + Delete_List(hbonds); + Make_List(system->Hcap, total_hbonds, TYP_HBOND, hbonds); + + return total_hbonds; + } + + static void Reallocate_Bonds_List(control_params *control, reax_system *system, + reax_list *bonds, int *total_bonds, int *est_3body) + { + int i; + + int mincap = system->mincap; + double safezone = system->safezone; + + *total_bonds = 0; + *est_3body = 0; + for (i = 0; i < system->N; ++i) { + *est_3body += SQR(system->my_atoms[i].num_bonds); + *total_bonds += system->my_atoms[i].num_bonds; + } + *total_bonds = (int)(MAX(*total_bonds * safezone, mincap*MIN_BONDS)); + + if (system->omp_active) + for (i = 0; i < bonds->num_intrs; ++i) + sfree(system->error_ptr, bonds->select.bond_list[i].bo_data.CdboReduction, "CdboReduction"); + + Delete_List(bonds); + Make_List(system->total_cap, *total_bonds, TYP_BOND, bonds); + + if (system->omp_active) + for (i = 0; i < bonds->num_intrs; ++i) + bonds->select.bond_list[i].bo_data.CdboReduction = + (double*) smalloc(system->error_ptr, sizeof(double)*control->nthreads, "CdboReduction"); + } + + void ReAllocate(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, reax_list **lists) + { + int num_bonds, est_3body, Hflag; + int newsize; + reax_list *far_nbrs; + + int mincap = system->mincap; + double safezone = system->safezone; + double saferzone = system->saferzone; + + auto error = system->error_ptr; + reallocate_data *wsr = &(workspace->realloc); + + if (system->n >= DANGER_ZONE * system->local_cap || + (0 && system->n <= LOOSE_ZONE * system->local_cap)) { + system->local_cap = MAX((int)(system->n * safezone), mincap); + } + + int Nflag = 0; + if (system->N >= DANGER_ZONE * system->total_cap || + (0 && system->N <= LOOSE_ZONE * system->total_cap)) { + Nflag = 1; + system->total_cap = MAX((int)(system->N * safezone), mincap); + } + + if (Nflag) { + /* system */ + system->my_atoms = (reax_atom *)::realloc(system->my_atoms, + system->total_cap*sizeof(reax_atom)); + /* workspace */ + DeAllocate_Workspace(control, workspace); + Allocate_Workspace(control, workspace, system->total_cap); + } + + /* far neighbors */ + + far_nbrs = *lists + FAR_NBRS; + + if (Nflag || wsr->num_far >= far_nbrs->num_intrs * DANGER_ZONE) { + if (wsr->num_far > far_nbrs->num_intrs) + error->one(FLERR,fmt::format("step{}: ran out of space on far_nbrs: top={}, max={}", + data->step, wsr->num_far, far_nbrs->num_intrs)); + + newsize = static_cast + (MAX(wsr->num_far*safezone, mincap*REAX_MIN_NBRS)); + + Reallocate_Neighbor_List(far_nbrs, system->total_cap, newsize); + wsr->num_far = 0; + } + + /* hydrogen bonds list */ + if (control->hbond_cut > 0) { + Hflag = 0; + if (system->numH >= DANGER_ZONE * system->Hcap || + (0 && system->numH <= LOOSE_ZONE * system->Hcap)) { + Hflag = 1; + system->Hcap = int(MAX(system->numH * saferzone, mincap)); + } + + if (Hflag || wsr->hbonds) { + Reallocate_HBonds_List(system, (*lists)+HBONDS); + wsr->hbonds = 0; + } + } + + /* bonds list */ + num_bonds = est_3body = -1; + if (Nflag || wsr->bonds) { + Reallocate_Bonds_List(control, system, (*lists)+BONDS, &num_bonds, &est_3body); + wsr->bonds = 0; + wsr->num_3body = MAX(wsr->num_3body, est_3body) * 2; + + + if (system->omp_active) { + int nthreads = control->nthreads; + reax_list *bonds = (*lists)+BONDS; + + for (int i = 0; i < bonds->num_intrs; ++i) { + sfree(error, bonds->select.bond_list[i].bo_data.CdboReduction, + "CdboReduction"); + + bonds->select.bond_list[i].bo_data.CdboReduction = + (double*) smalloc(error, sizeof(double)*nthreads, "CdboReduction"); + } + } + } + + /* 3-body list */ + if (wsr->num_3body > 0) { + Delete_List((*lists)+THREE_BODIES); + + if (num_bonds == -1) + num_bonds = ((*lists)+BONDS)->num_intrs; + + wsr->num_3body = (int)(MAX(wsr->num_3body*safezone, MIN_3BODIES)); + + Make_List(num_bonds, wsr->num_3body, TYP_THREE_BODY, + (*lists)+THREE_BODIES); + wsr->num_3body = -1; + } + } +} diff --git a/src/REAXFF/reaxff_api.h b/src/REAXFF/reaxff_api.h new file mode 100644 index 0000000000..ae3b013541 --- /dev/null +++ b/src/REAXFF/reaxff_api.h @@ -0,0 +1,226 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/ 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 author: Hasan Metin Aktulga, Purdue University + (now at Lawrence Berkeley National Laboratory, hmaktulga@lbl.gov) + + Heavily modified and adapted for LAMMPS by the LAMMPS developers. +------------------------------------------------------------------------- */ + +#ifndef LMP_REAXFF_API_H +#define LMP_REAXFF_API_H + +#include "reaxff_types.h" + +#include + +namespace ReaxFF +{ + // per instance data + struct API { + control_params *control; + reax_system *system; + simulation_data *data; + storage *workspace; + reax_list *lists; + }; + + // exported Functions + + // allocate + + extern void Allocate_Workspace(control_params *, storage *, int); + extern void DeAllocate_System(reax_system *); + extern void DeAllocate_Workspace(control_params *, storage *); + extern void PreAllocate_Space(reax_system *, storage *); + extern void ReAllocate(reax_system *, control_params *, simulation_data *, + storage *, reax_list **); + + // bond orders + + extern void BO(reax_system *, storage *, reax_list **); + extern int BOp(storage *, reax_list *, double, int, int, far_neighbor_data *, + single_body_parameters *, single_body_parameters *, + two_body_parameters *); + extern void Add_dBond_to_Forces(reax_system*, int, int, storage*, reax_list**); + + // bonds + + extern void Bonds(reax_system *, simulation_data *, storage *, reax_list **); + + // control + + extern void Read_Control_File(const char *, control_params *); + + // ffield + + extern void Read_Force_Field(const char *, reax_interaction *, + control_params *, MPI_Comm); + + // forces + + extern void Compute_Forces(reax_system *, control_params *, + simulation_data *, storage *, reax_list **); + extern void Estimate_Storages(reax_system *, control_params *, reax_list **, + int *, int *, int *, int *); + + // hydrogen bonds + + extern void Hydrogen_Bonds(reax_system *, simulation_data *, storage *, reax_list **); + + // init md + + extern void Init_System(reax_system *, control_params *); + extern void Init_Simulation_Data(simulation_data *); + extern void Init_Workspace(reax_system *, control_params *, storage *); + extern void Initialize(reax_system *, control_params *, simulation_data *, + storage *, reax_list **, MPI_Comm); + + // lists + + extern void Make_List(int, int, int, reax_list *); + extern void Delete_List(reax_list*); + + inline int Start_Index(int i, reax_list *l) { return l->index[i]; } + inline int End_Index(int i, reax_list *l) { return l->end_index[i]; } + inline void Set_Start_Index(int i, int val, reax_list *l) { + l->index[i] = val; + } + inline void Set_End_Index(int i, int val, reax_list *l) { + l->end_index[i] = val; + } + inline int Num_Entries(int i, reax_list *l) { + return l->end_index[i] - l->index[i]; + } + + // lookup + + extern void Init_Lookup_Tables(reax_system *, control_params *, + storage *, MPI_Comm); + extern void Deallocate_Lookup_Tables(reax_system *); + extern void Natural_Cubic_Spline(LAMMPS_NS::Error*, const double *, + const double *, cubic_spline_coef *, + unsigned int); + extern void Complete_Cubic_Spline(LAMMPS_NS::Error*, const double *, + const double *, double v0, double vlast, + cubic_spline_coef *coef, unsigned int n); + + // multi body + + extern void Atom_Energy(reax_system *, control_params *, simulation_data *, + storage *, reax_list **); + + // nonbonded + + extern void Compute_Polarization_Energy(reax_system *, simulation_data *); + extern void vdW_Coulomb_Energy(reax_system *, control_params *, + simulation_data *, storage *, reax_list **); + extern void Tabulated_vdW_Coulomb_Energy(reax_system *, control_params *, + simulation_data *, storage *, + reax_list **); + extern void LR_vdW_Coulomb(reax_system *, storage *, control_params *, + int, int, double, LR_data *); + + // reset tools + + extern void Reset(reax_system *, control_params *, simulation_data *, + storage *, reax_list **); + extern void Reset_Simulation_Data(simulation_data *); + extern void Reset_Workspace(reax_system *, storage *); + + // toolbox + + extern void *scalloc(LAMMPS_NS::Error *, rc_bigint, rc_bigint, const char *); + extern void *smalloc(LAMMPS_NS::Error *, rc_bigint, const char *); + extern void sfree(LAMMPS_NS::Error *, void *, const char *); + + // torsion angles + + extern double Calculate_Omega(rvec, double, rvec, double, rvec, double, + rvec, double, three_body_interaction_data *, + three_body_interaction_data *, rvec, rvec, + rvec, rvec); + extern void Torsion_Angles(reax_system *, control_params *, + simulation_data *, storage *, reax_list **); + + // valence angles + + extern void Calculate_Theta(rvec, double, rvec, double, double *, double *); + extern void Calculate_dCos_Theta(rvec, double, rvec, double, + rvec *, rvec *, rvec *); + extern void Valence_Angles(reax_system *, control_params *, + simulation_data *, storage *, reax_list **); + + // vector + + inline void rvec_Add(rvec ret, rvec v) { + ret[0] += v[0]; ret[1] += v[1]; ret[2] += v[2]; + } + + inline void rvec_Copy(rvec dest, rvec src) { + dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2]; + } + + inline void rvec_Cross(rvec ret, rvec v1, rvec v2) + { + ret[0] = v1[1] * v2[2] - v1[2] * v2[1]; + ret[1] = v1[2] * v2[0] - v1[0] * v2[2]; + ret[2] = v1[0] * v2[1] - v1[1] * v2[0]; + } + + inline double rvec_Dot(rvec v1, rvec v2) { + return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]; + } + + inline double rvec_Norm(rvec v) { + return sqrt(SQR(v[0]) + SQR(v[1]) + SQR(v[2])); + } + + inline void rvec_Scale(rvec ret, double c, rvec v) { + ret[0] = c * v[0]; ret[1] = c * v[1]; ret[2] = c * v[2]; + } + + inline void rvec_ScaledAdd(rvec ret, double c, rvec v) { + ret[0] += c * v[0], ret[1] += c * v[1], ret[2] += c * v[2]; + } + + inline void rvec_ScaledSum(rvec ret, double c1, rvec v1 ,double c2, rvec v2) + { + ret[0] = c1 * v1[0] + c2 * v2[0]; + ret[1] = c1 * v1[1] + c2 * v2[1]; + ret[2] = c1 * v1[2] + c2 * v2[2]; + } + + inline void ivec_MakeZero(ivec v) { v[0] = v[1] = v[2] = 0; } + + inline void ivec_Copy(ivec dest, ivec src) { + dest[0] = src[0], dest[1] = src[1], dest[2] = src[2]; + } + + inline void ivec_Scale(ivec dest, double C, ivec src) + { + dest[0] = (int)(C * src[0]); + dest[1] = (int)(C * src[1]); + dest[2] = (int)(C * src[2]); + } + + inline void ivec_Sum(ivec dest, ivec v1, ivec v2) + { + dest[0] = v1[0] + v2[0]; + dest[1] = v1[1] + v2[1]; + dest[2] = v1[2] + v2[2]; + } +} + +#endif diff --git a/src/REAXFF/reaxff_bond_orders.cpp b/src/REAXFF/reaxff_bond_orders.cpp new file mode 100644 index 0000000000..d827e3753d --- /dev/null +++ b/src/REAXFF/reaxff_bond_orders.cpp @@ -0,0 +1,469 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + + Contributing authors: + H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama + Corresponding author: + Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_api.h" + +#include "pair.h" + +#include + +namespace ReaxFF { + void Add_dBond_to_Forces(reax_system *system, int i, int pj, storage *workspace, reax_list **lists) + { + reax_list *bonds = (*lists) + BONDS; + bond_data *nbr_j, *nbr_k; + bond_order_data *bo_ij, *bo_ji; + dbond_coefficients coef; + int pk, k, j; + + /* Virial Tallying variables */ + rvec fi_tmp, fj_tmp, fk_tmp, delij, delji, delki, delkj, temp; + + /* Initializations */ + nbr_j = &(bonds->select.bond_list[pj]); + j = nbr_j->nbr; + bo_ij = &(nbr_j->bo_data); + bo_ji = &(bonds->select.bond_list[nbr_j->sym_index].bo_data); + + double c = bo_ij->Cdbo + bo_ji->Cdbo; + coef.C1dbo = bo_ij->C1dbo * c; + coef.C2dbo = bo_ij->C2dbo * c; + coef.C3dbo = bo_ij->C3dbo * c; + + c = bo_ij->Cdbopi + bo_ji->Cdbopi; + coef.C1dbopi = bo_ij->C1dbopi * c; + coef.C2dbopi = bo_ij->C2dbopi * c; + coef.C3dbopi = bo_ij->C3dbopi * c; + coef.C4dbopi = bo_ij->C4dbopi * c; + + c = bo_ij->Cdbopi2 + bo_ji->Cdbopi2; + coef.C1dbopi2 = bo_ij->C1dbopi2 * c; + coef.C2dbopi2 = bo_ij->C2dbopi2 * c; + coef.C3dbopi2 = bo_ij->C3dbopi2 * c; + coef.C4dbopi2 = bo_ij->C4dbopi2 * c; + + c = workspace->CdDelta[i] + workspace->CdDelta[j]; + coef.C1dDelta = bo_ij->C1dbo * c; + coef.C2dDelta = bo_ij->C2dbo * c; + coef.C3dDelta = bo_ij->C3dbo * c; + + c = (coef.C1dbo + coef.C1dDelta + coef.C2dbopi + coef.C2dbopi2); + rvec_Scale( temp, c, bo_ij->dBOp); + + c = (coef.C2dbo + coef.C2dDelta + coef.C3dbopi + coef.C3dbopi2); + rvec_ScaledAdd(temp, c, workspace->dDeltap_self[i]); + + rvec_ScaledAdd(temp, coef.C1dbopi, bo_ij->dln_BOp_pi); + rvec_ScaledAdd(temp, coef.C1dbopi2, bo_ij->dln_BOp_pi2); + + rvec_Add(workspace->f[i], temp); + + if (system->pair_ptr->vflag_either) { + rvec_Scale(fi_tmp, -0.5, temp); + rvec_ScaledSum(delij, 1., system->my_atoms[i].x,-1., system->my_atoms[j].x); + system->pair_ptr->v_tally2_newton(i,fi_tmp,delij); + } + + c = -(coef.C1dbo + coef.C1dDelta + coef.C2dbopi + coef.C2dbopi2); + rvec_Scale( temp, c, bo_ij->dBOp); + + c = (coef.C3dbo + coef.C3dDelta + coef.C4dbopi + coef.C4dbopi2); + rvec_ScaledAdd(temp, c, workspace->dDeltap_self[j]); + + rvec_ScaledAdd(temp, -coef.C1dbopi, bo_ij->dln_BOp_pi); + rvec_ScaledAdd(temp, -coef.C1dbopi2, bo_ij->dln_BOp_pi2); + + rvec_Add(workspace->f[j], temp); + + if (system->pair_ptr->vflag_either) { + rvec_Scale(fj_tmp, -0.5, temp); + rvec_ScaledSum(delji, 1., system->my_atoms[j].x,-1., system->my_atoms[i].x); + system->pair_ptr->v_tally2_newton(j,fj_tmp,delji); + } + + // forces on k: i neighbor + for (pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk) { + nbr_k = &(bonds->select.bond_list[pk]); + k = nbr_k->nbr; + + const double c = -(coef.C2dbo + coef.C2dDelta + coef.C3dbopi + coef.C3dbopi2); + rvec_Scale(temp, c, nbr_k->bo_data.dBOp); + + rvec_Add(workspace->f[k], temp); + + if (system->pair_ptr->vflag_either) { + rvec_Scale(fk_tmp, -0.5, temp); + rvec_ScaledSum(delki,1.,system->my_atoms[k].x,-1.,system->my_atoms[i].x); + system->pair_ptr->v_tally2_newton(k,fk_tmp,delki); + rvec_ScaledSum(delkj,1.,system->my_atoms[k].x,-1.,system->my_atoms[j].x); + system->pair_ptr->v_tally2_newton(k,fk_tmp,delkj); + } + } + + // forces on k: j neighbor + for (pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk) { + nbr_k = &(bonds->select.bond_list[pk]); + k = nbr_k->nbr; + + const double c = -(coef.C3dbo + coef.C3dDelta + coef.C4dbopi + coef.C4dbopi2); + rvec_Scale(temp, c, nbr_k->bo_data.dBOp); + + rvec_Add(workspace->f[k], temp); + + if (system->pair_ptr->vflag_either) { + rvec_Scale(fk_tmp, -0.5, temp); + rvec_ScaledSum(delki,1.,system->my_atoms[k].x,-1.,system->my_atoms[i].x); + system->pair_ptr->v_tally2_newton(k,fk_tmp,delki); + rvec_ScaledSum(delkj,1.,system->my_atoms[k].x,-1.,system->my_atoms[j].x); + system->pair_ptr->v_tally2_newton(k,fk_tmp,delkj); + } + } + } + + int BOp(storage *workspace, reax_list *bonds, double bo_cut, + int i, int btop_i, far_neighbor_data *nbr_pj, + single_body_parameters *sbp_i, single_body_parameters *sbp_j, + two_body_parameters *twbp) { + int j, btop_j; + double rr2, C12, C34, C56; + double Cln_BOp_s, Cln_BOp_pi, Cln_BOp_pi2; + double BO, BO_s, BO_pi, BO_pi2; + bond_data *ibond, *jbond; + bond_order_data *bo_ij, *bo_ji; + + j = nbr_pj->nbr; + rr2 = 1.0 / SQR(nbr_pj->d); + + if (sbp_i->r_s > 0.0 && sbp_j->r_s > 0.0) { + C12 = twbp->p_bo1 * pow(nbr_pj->d / twbp->r_s, twbp->p_bo2); + BO_s = (1.0 + bo_cut) * exp(C12); + } else BO_s = C12 = 0.0; + + if (sbp_i->r_pi > 0.0 && sbp_j->r_pi > 0.0) { + C34 = twbp->p_bo3 * pow(nbr_pj->d / twbp->r_p, twbp->p_bo4); + BO_pi = exp(C34); + } else BO_pi = C34 = 0.0; + + if (sbp_i->r_pi_pi > 0.0 && sbp_j->r_pi_pi > 0.0) { + C56 = twbp->p_bo5 * pow(nbr_pj->d / twbp->r_pp, twbp->p_bo6); + BO_pi2= exp(C56); + } else BO_pi2 = C56 = 0.0; + + /* Initially BO values are the uncorrected ones, page 1 */ + BO = BO_s + BO_pi + BO_pi2; + + if (BO >= bo_cut) { + /****** bonds i-j and j-i ******/ + ibond = &(bonds->select.bond_list[btop_i]); + btop_j = End_Index(j, bonds); + jbond = &(bonds->select.bond_list[btop_j]); + + ibond->nbr = j; + jbond->nbr = i; + ibond->d = nbr_pj->d; + jbond->d = nbr_pj->d; + rvec_Copy(ibond->dvec, nbr_pj->dvec); + rvec_Scale(jbond->dvec, -1, nbr_pj->dvec); + ivec_Copy(ibond->rel_box, nbr_pj->rel_box); + ivec_Scale(jbond->rel_box, -1, nbr_pj->rel_box); + ibond->dbond_index = btop_i; + jbond->dbond_index = btop_i; + ibond->sym_index = btop_j; + jbond->sym_index = btop_i; + Set_End_Index(j, btop_j+1, bonds); + + bo_ij = &(ibond->bo_data); + bo_ji = &(jbond->bo_data); + bo_ji->BO = bo_ij->BO = BO; + bo_ji->BO_s = bo_ij->BO_s = BO_s; + bo_ji->BO_pi = bo_ij->BO_pi = BO_pi; + bo_ji->BO_pi2 = bo_ij->BO_pi2 = BO_pi2; + + /* Bond Order page2-3, derivative of total bond order prime */ + Cln_BOp_s = twbp->p_bo2 * C12 * rr2; + Cln_BOp_pi = twbp->p_bo4 * C34 * rr2; + Cln_BOp_pi2 = twbp->p_bo6 * C56 * rr2; + + /* Only dln_BOp_xx wrt. dr_i is stored here, note that + dln_BOp_xx/dr_i = -dln_BOp_xx/dr_j and all others are 0 */ + rvec_Scale(bo_ij->dln_BOp_s,-bo_ij->BO_s*Cln_BOp_s,ibond->dvec); + rvec_Scale(bo_ij->dln_BOp_pi,-bo_ij->BO_pi*Cln_BOp_pi,ibond->dvec); + rvec_Scale(bo_ij->dln_BOp_pi2, + -bo_ij->BO_pi2*Cln_BOp_pi2,ibond->dvec); + rvec_Scale(bo_ji->dln_BOp_s, -1., bo_ij->dln_BOp_s); + rvec_Scale(bo_ji->dln_BOp_pi, -1., bo_ij->dln_BOp_pi); + rvec_Scale(bo_ji->dln_BOp_pi2, -1., bo_ij->dln_BOp_pi2); + + rvec_Scale(bo_ij->dBOp, + -(bo_ij->BO_s * Cln_BOp_s + + bo_ij->BO_pi * Cln_BOp_pi + + bo_ij->BO_pi2 * Cln_BOp_pi2), ibond->dvec); + rvec_Scale(bo_ji->dBOp, -1., bo_ij->dBOp); + + rvec_Add(workspace->dDeltap_self[i], bo_ij->dBOp); + rvec_Add(workspace->dDeltap_self[j], bo_ji->dBOp); + + bo_ij->BO_s -= bo_cut; + bo_ij->BO -= bo_cut; + bo_ji->BO_s -= bo_cut; + bo_ji->BO -= bo_cut; + workspace->total_bond_order[i] += bo_ij->BO; //currently total_BOp + workspace->total_bond_order[j] += bo_ji->BO; //currently total_BOp + bo_ij->Cdbo = bo_ij->Cdbopi = bo_ij->Cdbopi2 = 0.0; + bo_ji->Cdbo = bo_ji->Cdbopi = bo_ji->Cdbopi2 = 0.0; + + return 1; + } + return 0; + } + + void BO(reax_system *system, storage *workspace, reax_list **lists) + { + int i, j, pj, type_i, type_j; + int start_i, end_i, sym_index; + double val_i, Deltap_i, Deltap_boc_i; + double val_j, Deltap_j, Deltap_boc_j; + double f1, f2, f3, f4, f5, f4f5, exp_f4, exp_f5; + double exp_p1i, exp_p2i, exp_p1j, exp_p2j; + double temp, u1_ij, u1_ji, Cf1A_ij, Cf1B_ij, Cf1_ij, Cf1_ji; + double Cf45_ij, Cf45_ji, p_lp1; //u_ij, u_ji + double A0_ij, A1_ij, A2_ij, A2_ji, A3_ij, A3_ji; + double explp1, p_boc1, p_boc2; + single_body_parameters *sbp_i, *sbp_j; + two_body_parameters *twbp; + bond_order_data *bo_ij, *bo_ji; + reax_list *bonds = (*lists) + BONDS; + + p_boc1 = system->reax_param.gp.l[0]; + p_boc2 = system->reax_param.gp.l[1]; + + /* Calculate Deltaprime, Deltaprime_boc values */ + for (i = 0; i < system->N; ++i) { + type_i = system->my_atoms[i].type; + if (type_i < 0) continue; + sbp_i = &(system->reax_param.sbp[type_i]); + workspace->Deltap[i] = workspace->total_bond_order[i] - sbp_i->valency; + workspace->Deltap_boc[i] = + workspace->total_bond_order[i] - sbp_i->valency_val; + + workspace->total_bond_order[i] = 0; + } + + /* Corrected Bond Order calculations */ + for (i = 0; i < system->N; ++i) { + type_i = system->my_atoms[i].type; + if (type_i < 0) continue; + sbp_i = &(system->reax_param.sbp[type_i]); + val_i = sbp_i->valency; + Deltap_i = workspace->Deltap[i]; + Deltap_boc_i = workspace->Deltap_boc[i]; + start_i = Start_Index(i, bonds); + end_i = End_Index(i, bonds); + + for (pj = start_i; pj < end_i; ++pj) { + j = bonds->select.bond_list[pj].nbr; + type_j = system->my_atoms[j].type; + if (type_j < 0) continue; + bo_ij = &(bonds->select.bond_list[pj].bo_data); + // fprintf(stderr, "\tj:%d - ubo: %8.3f\n", j+1, bo_ij->BO); + + if (i < j || workspace->bond_mark[j] > 3) { + twbp = &(system->reax_param.tbp[type_i][type_j]); + + if (twbp->ovc < 0.001 && twbp->v13cor < 0.001) { + bo_ij->C1dbo = 1.000000; + bo_ij->C2dbo = 0.000000; + bo_ij->C3dbo = 0.000000; + + bo_ij->C1dbopi = 1.000000; + bo_ij->C2dbopi = 0.000000; + bo_ij->C3dbopi = 0.000000; + bo_ij->C4dbopi = 0.000000; + + bo_ij->C1dbopi2 = 1.000000; + bo_ij->C2dbopi2 = 0.000000; + bo_ij->C3dbopi2 = 0.000000; + bo_ij->C4dbopi2 = 0.000000; + + } else { + val_j = system->reax_param.sbp[type_j].valency; + Deltap_j = workspace->Deltap[j]; + Deltap_boc_j = workspace->Deltap_boc[j]; + + /* on page 1 */ + if (twbp->ovc >= 0.001) { + /* Correction for overcoordination */ + exp_p1i = exp(-p_boc1 * Deltap_i); + exp_p2i = exp(-p_boc2 * Deltap_i); + exp_p1j = exp(-p_boc1 * Deltap_j); + exp_p2j = exp(-p_boc2 * Deltap_j); + + f2 = exp_p1i + exp_p1j; + f3 = -1.0 / p_boc2 * log(0.5 * (exp_p2i + exp_p2j)); + f1 = 0.5 * ((val_i + f2)/(val_i + f2 + f3) + + (val_j + f2)/(val_j + f2 + f3)); + + temp = f2 + f3; + u1_ij = val_i + temp; + u1_ji = val_j + temp; + Cf1A_ij = 0.5 * f3 * (1.0 / SQR(u1_ij) + + 1.0 / SQR(u1_ji)); + Cf1B_ij = -0.5 * ((u1_ij - f3) / SQR(u1_ij) + + (u1_ji - f3) / SQR(u1_ji)); + + Cf1_ij = 0.50 * (-p_boc1 * exp_p1i / u1_ij - + ((val_i+f2) / SQR(u1_ij)) * + (-p_boc1 * exp_p1i + + exp_p2i / (exp_p2i + exp_p2j)) + + -p_boc1 * exp_p1i / u1_ji - + ((val_j+f2) / SQR(u1_ji)) * + (-p_boc1 * exp_p1i + + exp_p2i / (exp_p2i + exp_p2j))); + + + Cf1_ji = -Cf1A_ij * p_boc1 * exp_p1j + + Cf1B_ij * exp_p2j / (exp_p2i + exp_p2j); + + } else { + /* No overcoordination correction! */ + f1 = 1.0; + Cf1_ij = Cf1_ji = 0.0; + } + + if (twbp->v13cor >= 0.001) { + /* Correction for 1-3 bond orders */ + exp_f4 =exp(-(twbp->p_boc4 * SQR(bo_ij->BO) - + Deltap_boc_i) * twbp->p_boc3 + twbp->p_boc5); + exp_f5 =exp(-(twbp->p_boc4 * SQR(bo_ij->BO) - + Deltap_boc_j) * twbp->p_boc3 + twbp->p_boc5); + + f4 = 1. / (1. + exp_f4); + f5 = 1. / (1. + exp_f5); + f4f5 = f4 * f5; + + /* Bond Order pages 8-9, derivative of f4 and f5 */ + Cf45_ij = -f4 * exp_f4; + Cf45_ji = -f5 * exp_f5; + } else { + f4 = f5 = f4f5 = 1.0; + Cf45_ij = Cf45_ji = 0.0; + } + + /* Bond Order page 10, derivative of total bond order */ + A0_ij = f1 * f4f5; + A1_ij = -2 * twbp->p_boc3 * twbp->p_boc4 * bo_ij->BO * + (Cf45_ij + Cf45_ji); + A2_ij = Cf1_ij / f1 + twbp->p_boc3 * Cf45_ij; + A2_ji = Cf1_ji / f1 + twbp->p_boc3 * Cf45_ji; + A3_ij = A2_ij + Cf1_ij / f1; + A3_ji = A2_ji + Cf1_ji / f1; + + /* find corrected bond orders and their derivative coef */ + bo_ij->BO = bo_ij->BO * A0_ij; + bo_ij->BO_pi = bo_ij->BO_pi * A0_ij *f1; + bo_ij->BO_pi2= bo_ij->BO_pi2* A0_ij *f1; + bo_ij->BO_s = bo_ij->BO - (bo_ij->BO_pi + bo_ij->BO_pi2); + + bo_ij->C1dbo = A0_ij + bo_ij->BO * A1_ij; + bo_ij->C2dbo = bo_ij->BO * A2_ij; + bo_ij->C3dbo = bo_ij->BO * A2_ji; + + bo_ij->C1dbopi = f1*f1*f4*f5; + bo_ij->C2dbopi = bo_ij->BO_pi * A1_ij; + bo_ij->C3dbopi = bo_ij->BO_pi * A3_ij; + bo_ij->C4dbopi = bo_ij->BO_pi * A3_ji; + + bo_ij->C1dbopi2 = f1*f1*f4*f5; + bo_ij->C2dbopi2 = bo_ij->BO_pi2 * A1_ij; + bo_ij->C3dbopi2 = bo_ij->BO_pi2 * A3_ij; + bo_ij->C4dbopi2 = bo_ij->BO_pi2 * A3_ji; + } + + /* neglect bonds that are < 1e-10 */ + if (bo_ij->BO < 1e-10) + bo_ij->BO = 0.0; + if (bo_ij->BO_s < 1e-10) + bo_ij->BO_s = 0.0; + if (bo_ij->BO_pi < 1e-10) + bo_ij->BO_pi = 0.0; + if (bo_ij->BO_pi2 < 1e-10) + bo_ij->BO_pi2 = 0.0; + + workspace->total_bond_order[i] += bo_ij->BO; //now keeps total_BO + + } + else { + /* We only need to update bond orders from bo_ji + everything else is set in uncorrected_bo calculations */ + sym_index = bonds->select.bond_list[pj].sym_index; + bo_ji = &(bonds->select.bond_list[sym_index].bo_data); + bo_ij->BO = bo_ji->BO; + bo_ij->BO_s = bo_ji->BO_s; + bo_ij->BO_pi = bo_ji->BO_pi; + bo_ij->BO_pi2 = bo_ji->BO_pi2; + + workspace->total_bond_order[i] += bo_ij->BO;// now keeps total_BO + } + } + + } + + p_lp1 = system->reax_param.gp.l[15]; + for (j = 0; j < system->N; ++j) { + type_j = system->my_atoms[j].type; + if (type_j < 0) continue; + sbp_j = &(system->reax_param.sbp[type_j]); + + workspace->Delta[j] = workspace->total_bond_order[j] - sbp_j->valency; + workspace->Delta_e[j] = workspace->total_bond_order[j] - sbp_j->valency_e; + workspace->Delta_boc[j] = workspace->total_bond_order[j] - + sbp_j->valency_boc; + workspace->Delta_val[j] = workspace->total_bond_order[j] - + sbp_j->valency_val; + + workspace->vlpex[j] = workspace->Delta_e[j] - + 2.0 * (int)(workspace->Delta_e[j]/2.0); + explp1 = exp(-p_lp1 * SQR(2.0 + workspace->vlpex[j])); + workspace->nlp[j] = explp1 - (int)(workspace->Delta_e[j] / 2.0); + workspace->Delta_lp[j] = sbp_j->nlp_opt - workspace->nlp[j]; + workspace->Clp[j] = 2.0 * p_lp1 * explp1 * (2.0 + workspace->vlpex[j]); + workspace->dDelta_lp[j] = workspace->Clp[j]; + + if (sbp_j->mass > 21.0) { + workspace->nlp_temp[j] = 0.5 * (sbp_j->valency_e - sbp_j->valency); + workspace->Delta_lp_temp[j] = sbp_j->nlp_opt - workspace->nlp_temp[j]; + workspace->dDelta_lp_temp[j] = 0.; + } + else { + workspace->nlp_temp[j] = workspace->nlp[j]; + workspace->Delta_lp_temp[j] = sbp_j->nlp_opt - workspace->nlp_temp[j]; + workspace->dDelta_lp_temp[j] = workspace->Clp[j]; + } + } + } +} diff --git a/src/REAXFF/reaxff_bonds.cpp b/src/REAXFF/reaxff_bonds.cpp new file mode 100644 index 0000000000..cb28aaa1ca --- /dev/null +++ b/src/REAXFF/reaxff_bonds.cpp @@ -0,0 +1,138 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + Hasan Metin Aktulga, hmaktulga@lbl.gov + Joseph Fogarty, jcfogart@mail.usf.edu + Sagar Pandit, pandit@usf.edu + Ananth Y Grama, ayg@cs.purdue.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_api.h" + +#include "pair.h" + +#include + +namespace ReaxFF { + void Bonds(reax_system *system, simulation_data *data, storage *workspace, reax_list **lists) + { + int i, j, pj, natoms; + int start_i, end_i; + int type_i, type_j; + double ebond, pow_BOs_be2, exp_be12, CEbo; + double gp3, gp4, gp7, gp10, gp37; + double exphu, exphua1, exphub1, exphuov, hulpov, estriph; + double decobdbo, decobdboua, decobdboub; + single_body_parameters *sbp_i, *sbp_j; + two_body_parameters *twbp; + bond_order_data *bo_ij; + reax_list *bonds; + + bonds = (*lists) + BONDS; + gp3 = system->reax_param.gp.l[3]; + gp4 = system->reax_param.gp.l[4]; + gp7 = system->reax_param.gp.l[7]; + gp10 = system->reax_param.gp.l[10]; + gp37 = (int) system->reax_param.gp.l[37]; + natoms = system->n; + + for (i = 0; i < natoms; ++i) { + start_i = Start_Index(i, bonds); + end_i = End_Index(i, bonds); + + for (pj = start_i; pj < end_i; ++pj) { + j = bonds->select.bond_list[pj].nbr; + + if (system->my_atoms[i].orig_id > system->my_atoms[j].orig_id) + continue; + if (system->my_atoms[i].orig_id == system->my_atoms[j].orig_id) { + if (system->my_atoms[j].x[2] < system->my_atoms[i].x[2]) continue; + if (system->my_atoms[j].x[2] == system->my_atoms[i].x[2] && + system->my_atoms[j].x[1] < system->my_atoms[i].x[1]) continue; + if (system->my_atoms[j].x[2] == system->my_atoms[i].x[2] && + system->my_atoms[j].x[1] == system->my_atoms[i].x[1] && + system->my_atoms[j].x[0] < system->my_atoms[i].x[0]) continue; + } + + /* set the pointers */ + type_i = system->my_atoms[i].type; + type_j = system->my_atoms[j].type; + sbp_i = &(system->reax_param.sbp[type_i]); + sbp_j = &(system->reax_param.sbp[type_j]); + twbp = &(system->reax_param.tbp[type_i][type_j]); + bo_ij = &(bonds->select.bond_list[pj].bo_data); + + /* calculate the constants */ + if (bo_ij->BO_s == 0.0) pow_BOs_be2 = 0.0; + else pow_BOs_be2 = pow(bo_ij->BO_s, twbp->p_be2); + exp_be12 = exp(twbp->p_be1 * (1.0 - pow_BOs_be2)); + CEbo = -twbp->De_s * exp_be12 * + (1.0 - twbp->p_be1 * twbp->p_be2 * pow_BOs_be2); + + /* calculate the Bond Energy */ + data->my_en.e_bond += ebond = + -twbp->De_s * bo_ij->BO_s * exp_be12 + -twbp->De_p * bo_ij->BO_pi + -twbp->De_pp * bo_ij->BO_pi2; + + /* tally energy into global or per-atom energy accumulators */ + if (system->pair_ptr->eflag_either) + system->pair_ptr->ev_tally(i,j,natoms,1,ebond,0.0,0.0,0.0,0.0,0.0); + + /* calculate derivatives of Bond Orders */ + bo_ij->Cdbo += CEbo; + bo_ij->Cdbopi -= (CEbo + twbp->De_p); + bo_ij->Cdbopi2 -= (CEbo + twbp->De_pp); + + /* Stabilisation terminal triple bond */ + if (bo_ij->BO >= 1.00) { + if (gp37 == 2 || + (sbp_i->mass == 12.0000 && sbp_j->mass == 15.9990) || + (sbp_j->mass == 12.0000 && sbp_i->mass == 15.9990)) { + exphu = exp(-gp7 * SQR(bo_ij->BO - 2.50)); + exphua1 = exp(-gp3 * (workspace->total_bond_order[i]-bo_ij->BO)); + exphub1 = exp(-gp3 * (workspace->total_bond_order[j]-bo_ij->BO)); + exphuov = exp(gp4 * (workspace->Delta[i] + workspace->Delta[j])); + hulpov = 1.0 / (1.0 + 25.0 * exphuov); + + estriph = gp10 * exphu * hulpov * (exphua1 + exphub1); + data->my_en.e_bond += estriph; + + decobdbo = gp10 * exphu * hulpov * (exphua1 + exphub1) * + (gp3 - 2.0 * gp7 * (bo_ij->BO-2.50)); + decobdboua = -gp10 * exphu * hulpov * + (gp3*exphua1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); + decobdboub = -gp10 * exphu * hulpov * + (gp3*exphub1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); + + /* tally energy into global or per-atom energy accumulators */ + if (system->pair_ptr->eflag_either) + system->pair_ptr->ev_tally(i,j,natoms,1,estriph,0.0,0.0,0.0,0.0,0.0); + + bo_ij->Cdbo += decobdbo; + workspace->CdDelta[i] += decobdboua; + workspace->CdDelta[j] += decobdboub; + } + } + } + } + } +} diff --git a/src/REAXFF/reaxff_control.cpp b/src/REAXFF/reaxff_control.cpp new file mode 100644 index 0000000000..c84c3afe9d --- /dev/null +++ b/src/REAXFF/reaxff_control.cpp @@ -0,0 +1,126 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + Hasan Metin Aktulga, hmaktulga@lbl.gov + Joseph Fogarty, jcfogart@mail.usf.edu + Sagar Pandit, pandit@usf.edu + Ananth Y Grama, ayg@cs.purdue.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, in press. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_api.h" + +#include "error.h" +#include "utils.h" +#include "text_file_reader.h" + +#include +#include +#include +#include + +using LAMMPS_NS::utils::getsyserror; +using LAMMPS_NS::utils::sfgets; +using LAMMPS_NS::utils::logmesg; +using LAMMPS_NS::ValueTokenizer; + +namespace ReaxFF { + static std::unordered_set inactive_keywords = { + "ensemble_type", "nsteps", "dt", "proc_by_dim", "random_vel", + "restart_format", "restart_freq", "reposition_atoms", + "restrict_bonds", "remove_CoM_vel", "debug_level", "reneighbor", + "vlist_buffer", "ghost_cutoff", "qeq_freq", "q_err", "ilu_refactor", + "ilu_droptol", "temp_init", "temp_final", "t_mass", "t_mode", "t_rate", + "t_freq", "pressure", "p_mass", "pt_mass", "compress", "press_mode", + "geo_format", "traj_compress", "traj_method", "molecular_analysis", + "ignore", "dipole_anal", "freq_dipole_anal", "diffusion_coef", + "freq_diffusion_coef", "restrict_type", "traj_title", "simulation_name", + "energy_update_freq", "atom_info", "atom_velocities", "atom_forces", + "bond_info", "angle_info" }; + + class parser_error : public std::exception { + std::string message; + public: + parser_error(const std::string &mesg) { message = mesg; } + const char *what() const noexcept { return message.c_str(); } + }; + + // NOTE: this function is run on MPI rank 0 only + + void Read_Control_File(const char *control_file, control_params *control) + { + auto error = control->error_ptr; + + /* assign default values */ + control->nthreads = 1; + control->tabulate = 0; + control->bond_cut = 5.0; + control->bg_cut = 0.3; + control->thb_cut = 0.001; + control->thb_cutsq = 0.00001; + control->hbond_cut = 7.5; + + /* read control parameters file */ + try { + LAMMPS_NS::TextFileReader reader(control_file, "ReaxFF control"); + reader.ignore_comments = false; + + while (1) { + auto values = reader.next_values(0); + + // empty line + if (values.count() == 0) continue; + + auto keyword = values.next_string(); + + if (!values.has_next()) + throw parser_error(fmt::format("No value(s) for control parameter: {}\n",keyword)); + + if (inactive_keywords.find(keyword) != inactive_keywords.end()) { + error->warning(FLERR,fmt::format("Ignoring inactive control " + "parameter: {}",keyword)); + } else if (keyword == "nbrhood_cutoff") { + control->bond_cut = values.next_double(); + } else if (keyword == "bond_graph_cutoff") { + control->bg_cut = values.next_double(); + } else if (keyword == "thb_cutoff") { + control->thb_cut = values.next_double(); + } else if (keyword == "thb_cutoff_sq") { + control->thb_cutsq = values.next_double(); + } else if (keyword == "hbond_cutoff") { + control->hbond_cut = values.next_double(); + } else if (keyword == "tabulate_long_range") { + control->tabulate = values.next_int(); + } else if (keyword == "write_freq") { + if (values.next_int() > 0) + error->warning(FLERR,"Support for writing native trajectories has " + "been removed after LAMMPS version 8 April 2021"); + } else { + throw parser_error(fmt::format("Unknown parameter {} in " + "control file", keyword)); + } + } + } catch (LAMMPS_NS::EOFException &) { + ; // catch and ignore + } catch (std::exception &e) { + error->one(FLERR, e.what()); + } + } +} diff --git a/src/REAXFF/reaxff_defs.h b/src/REAXFF/reaxff_defs.h new file mode 100644 index 0000000000..c6df5de0ea --- /dev/null +++ b/src/REAXFF/reaxff_defs.h @@ -0,0 +1,66 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/ 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 author: Hasan Metin Aktulga, Purdue University + (now at Lawrence Berkeley National Laboratory, hmaktulga@lbl.gov) + + Heavily modified and adapted for LAMMPS by the LAMMPS developers. +------------------------------------------------------------------------- */ + +#ifndef LMP_REAXFF_DEFS_H +#define LMP_REAXFF_DEFS_H + +#if defined(__IBMC__) +#define inline __inline__ +#endif /*IBMC*/ + +#define SQR(x) ((x)*(x)) +#define CUBE(x) ((x)*(x)*(x)) +#define DEG2RAD(a) ((a)*constPI/180.0) +#define RAD2DEG(a) ((a)*180.0/constPI) +#define MAX3(x,y,z) MAX(MAX(x,y), z) + +#define constPI 3.14159265 +#define C_ele 332.06371 +#define EV_to_KCALpMOL 14.400000 // ElectronVolt --> KCAL per MOLe +#define KCALpMOL_to_EV 23.02 // 23.060549 //KCAL per MOLe --> ElectronVolt + +#define HB_THRESHOLD 1e-2 // 0.01 + +#define REAX_MIN_CAP 50 +#define REAX_MIN_NBRS 100 +#define MIN_HENTRIES 100 +#define MAX_BONDS 30 +#define MIN_BONDS 25 +#define REAX_MIN_HBONDS 25 +#define MIN_3BODIES 1000 +#define REAX_SAFE_ZONE 1.2 +#define REAX_SAFER_ZONE 1.4 +#define DANGER_ZONE 0.90 +#define LOOSE_ZONE 0.75 + +#define MAXREAXBOND 24 /* used in fix_reaxff_bonds.cpp and pair_reaxff.cpp */ +#define MAXSPECBOND 24 /* used in fix_reaxff_species.cpp and pair_reaxff.cpp */ + +#define REAX_MAX_3BODY_PARAM 5 +#define REAX_MAX_4BODY_PARAM 5 + +namespace ReaxFF +{ + /******************* ENUMERATORS *************************/ + enum {BONDS, THREE_BODIES, HBONDS, FAR_NBRS, LIST_N}; + enum {TYP_BOND, TYP_THREE_BODY, TYP_HBOND, TYP_FAR_NEIGHBOR, TYP_N}; +} + +#endif diff --git a/src/REAXFF/reaxff_ffield.cpp b/src/REAXFF/reaxff_ffield.cpp new file mode 100644 index 0000000000..f43ab440ff --- /dev/null +++ b/src/REAXFF/reaxff_ffield.cpp @@ -0,0 +1,616 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + Hasan Metin Aktulga, hmaktulga@lbl.gov + Joseph Fogarty, jcfogart@mail.usf.edu + Sagar Pandit, pandit@usf.edu + Ananth Y Grama, ayg@cs.purdue.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, in press. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_api.h" + +#include "error.h" +#include "memory.h" +#include "text_file_reader.h" +#include "utils.h" + +#include +#include +#include + +using LAMMPS_NS::utils::open_potential; +using LAMMPS_NS::utils::getsyserror; + +namespace ReaxFF { + + class parser_error : public std::exception { + std::string message; + public: + parser_error(const std::string &mesg) { message = mesg; } + const char *what() const noexcept { return message.c_str(); } + }; + + void Read_Force_Field(const char *filename, reax_interaction *reax, + control_params *control, MPI_Comm world) + { + char ****tor_flag; + auto error = control->error_ptr; + auto lmp = control->lmp_ptr; + auto memory = control->lmp_ptr->memory; + + // read and parse the force field only on rank 0 + +#define THROW_ERROR(txt) \ + throw parser_error(fmt::format("{}:{}: {}",filename,lineno,txt)) + + if (control->me == 0) { + FILE *fp = LAMMPS_NS::utils::open_potential(filename, lmp, nullptr); + if (!fp) + error->one(FLERR,fmt::format("The ReaxFF parameter file {} cannot be opened: {}", + filename, getsyserror())); + LAMMPS_NS::TextFileReader reader(fp, "ReaxFF parameter"); + reader.ignore_comments = false; + + try { + int i,j,k,l,m,n,lineno = 0; + + // skip header comment line + + reader.skip_line(); + ++lineno; + + // set some defaults + auto &gp = reax->gp; + + gp.vdw_type = 0; + + // get number of global parameters + + auto values = reader.next_values(0); + n = values.next_int(); + gp.n_global = n; + ++lineno; + + if (n < 1) + THROW_ERROR("Invalid number of global parameters"); + + memory->destroy(gp.l); + memory->create(gp.l,n,"reaxff:gp.l"); + + // see reaxff_types.h for mapping between l[i] and the lambdas used in ff + + for (i = 0; i < n; ++i) { + values = reader.next_values(0); + ++lineno; + gp.l[i] = values.next_double(); + } + + // next line is number of atom types followed by 3 lines of comments + + values = reader.next_values(0); + n = values.next_int(); + reax->num_atom_types = n; + reader.skip_line(); + reader.skip_line(); + reader.skip_line(); + lineno += 4; + + // allocate and clear storage for ffield data + auto &sbp = reax->sbp; + auto &tbp = reax->tbp; + auto &thbp = reax->thbp; + auto &hbp = reax->hbp; + auto &fbp = reax->fbp; + + memory->destroy(sbp); + memory->destroy(tbp); + memory->destroy(thbp); + memory->destroy(hbp); + memory->destroy(fbp); + memory->create(sbp,n,"reaxff:sbp"); + memory->create(tbp,n,n,"reaxff:tbp"); + memory->create(thbp,n,n,n,"reaxff:thbp"); + memory->create(hbp,n,n,n,"reaxff:hbp"); + memory->create(fbp,n,n,n,n,"reaxff:fbp"); + memory->create(tor_flag,n,n,n,n,"reaxff:tor_flag"); + memset(&(sbp[0]),0,sizeof(single_body_parameters)*n); + memset(&(tbp[0][0]),0,sizeof(two_body_parameters)*n*n); + memset(&(thbp[0][0][0]),0,sizeof(three_body_header)*n*n*n); + memset(&(hbp[0][0][0]),0,sizeof(hbond_parameters)*n*n*n); + memset(&(fbp[0][0][0][0]),0,sizeof(four_body_header)*n*n*n*n); + memset(&tor_flag[0][0][0][0],0,sizeof(char)*n*n*n*n); + + // atomic parameters + // four lines per atom type, or 5 if lgvdw != 0 + // the first starts with the symbol and has 9 words + // the next three have 8 words + // the fifth will have 2 words, if present + + const int lgflag = control->lgflag; + const int ntypes = n; + + for (i = 0; i < ntypes; ++i) { + + // line one + + values = reader.next_values(0); + ++lineno; + + if ((values.count() < 8) && !lgflag) + THROW_ERROR("This force field file requires using 'lgvdw yes'"); + if (values.count() < 9) + THROW_ERROR("Invalid force field file format"); + + auto element = values.next_string(); + int len = MIN(element.size(),3); // truncate stored element symbol if necessary + for (j = 0; j < len; ++j) + sbp[i].name[j] = toupper(element[j]); + sbp[i].name[len] = '\0'; + + sbp[i].r_s = values.next_double(); + sbp[i].valency = values.next_double(); + sbp[i].mass = values.next_double(); + sbp[i].r_vdw = values.next_double(); + sbp[i].epsilon = values.next_double(); + sbp[i].gamma = values.next_double(); + sbp[i].r_pi = values.next_double(); + sbp[i].valency_e = values.next_double(); + sbp[i].nlp_opt = 0.5 * (sbp[i].valency_e-sbp[i].valency); + + // line two + + values = reader.next_values(0); + ++lineno; + if (values.count() < 8) + THROW_ERROR("Invalid force field file format"); + + sbp[i].alpha = values.next_double(); + sbp[i].gamma_w = values.next_double(); + sbp[i].valency_boc= values.next_double(); + sbp[i].p_ovun5 = values.next_double(); + values.skip(); + sbp[i].chi = values.next_double(); + sbp[i].eta = 2.0*values.next_double(); + sbp[i].p_hbond = (int) values.next_double(); + + // line three + + values = reader.next_values(0); + ++lineno; + if (values.count() < 8) + THROW_ERROR("Invalid force field file format"); + + sbp[i].r_pi_pi = values.next_double(); + sbp[i].p_lp2 = values.next_double(); + values.skip(); + sbp[i].b_o_131 = values.next_double(); + sbp[i].b_o_132 = values.next_double(); + sbp[i].b_o_133 = values.next_double(); + + // line four + + values = reader.next_values(0); + ++lineno; + if (values.count() < 8) + THROW_ERROR("Invalid force field file format"); + + sbp[i].p_ovun2 = values.next_double(); + sbp[i].p_val3 = values.next_double(); + values.skip(); + sbp[i].valency_val= values.next_double(); + sbp[i].p_val5 = values.next_double(); + sbp[i].rcore2 = values.next_double(); + sbp[i].ecore2 = values.next_double(); + sbp[i].acore2 = values.next_double(); + + // read line five only when lgflag != 0 + + if (lgflag) { + values = reader.next_values(0); + ++lineno; + if (values.count() < 2) + THROW_ERROR("Invalid force field file format"); + sbp[i].lgcij = values.next_double(); + sbp[i].lgre = values.next_double(); + } else sbp[i].lgcij = sbp[i].lgre = 0.0; + + // van der Waals settings check: + + // Inner-wall? + if ((sbp[i].rcore2 > 0.01) && (sbp[i].acore2 > 0.01)) { + // Shielding van der Waals? + if (sbp[i].gamma_w > 0.5) { + if (gp.vdw_type != 0 && gp.vdw_type != 3) { + const auto errmsg + = fmt::format("Van der Waals parameters for element {} " + "indicate inner wall+shielding, but earlier " + "atoms indicate a different van der Waals " + "method. This may cause division-by-zero " + "errors. Keeping van der Waals setting for " + "earlier atoms.",sbp[i].name); + error->warning(FLERR,errmsg); + } else { + gp.vdw_type = 3; + } + } else { // No shielding van der Waals parameters present + if ((gp.vdw_type != 0) && (gp.vdw_type != 2)) { + const auto errmsg + = fmt::format("Van der Waals parameters for element {} " + "indicate inner wall withou shielding, but " + "earlier atoms indicate a different van der " + "Waals-method. This may cause division-by-" + "zero errors. Keeping van der Waals setting " + "for earlier atoms.", sbp[i].name); + error->warning(FLERR,errmsg); + } else { + gp.vdw_type = 2; + } + } + } else { // No Inner wall parameters present + if (sbp[i].gamma_w > 0.5) { // Shielding vdWaals + if ((gp.vdw_type != 0) && (gp.vdw_type != 1)) { + const auto errmsg + = fmt::format("Van der Waals parameters for element {} " + "indicate shielding without inner wall, but " + "earlier elements indicate a different van der " + "Waals method. This may cause division-by-zero " + "errors. Keeping van der Waals setting for " + "earlier atoms.", sbp[i].name); + error->warning(FLERR,errmsg); + } else { + gp.vdw_type = 1; + } + } else { + error->one(FLERR,fmt::format("Inconsistent van der Waals " + "parameters: No shielding or inner " + "wall set for element {}", + sbp[i].name)); + } + } + } + + /* Equate vval3 to valf for first-row elements (25/10/2004) */ + for (i = 0; i < ntypes; i++) { + if ((sbp[i].mass < 21) && + (sbp[i].valency_val != sbp[i].valency_boc)) { + error->warning(FLERR,fmt::format("Changed valency_val to valency" + "_boc for {}", sbp[i].name)); + sbp[i].valency_val = sbp[i].valency_boc; + } + } + + // next line is number of two body parameters followed by 1 comment line + + values = reader.next_values(0); + n = values.next_int(); + reader.skip_line(); + lineno += 2; + + for (i = 0; i < n; ++i) { + + // first line + + values = reader.next_values(0); + ++lineno; + if (values.count() < 10) + THROW_ERROR("Invalid force field file format"); + + j = values.next_int() - 1; + k = values.next_int() - 1; + + if ((j < 0) || (k < 0)) + THROW_ERROR("Inconsistent force field file"); + + if ((j < ntypes) && (k < ntypes)) { + tbp[j][k].De_s = tbp[k][j].De_s = values.next_double(); + tbp[j][k].De_p = tbp[k][j].De_p = values.next_double(); + tbp[j][k].De_pp = tbp[k][j].De_pp = values.next_double(); + tbp[j][k].p_be1 = tbp[k][j].p_be1 = values.next_double(); + tbp[j][k].p_bo5 = tbp[k][j].p_bo5 = values.next_double(); + tbp[j][k].v13cor = tbp[k][j].v13cor = values.next_double(); + tbp[j][k].p_bo6 = tbp[k][j].p_bo6 = values.next_double(); + tbp[j][k].p_ovun1 = tbp[k][j].p_ovun1 = values.next_double(); + } + + // second line + + values = reader.next_values(0); + ++lineno; + if (values.count() < 8) + THROW_ERROR("Invalid force field file format"); + + if ((j < ntypes) && (k < ntypes)) { + tbp[j][k].p_be2 = tbp[k][j].p_be2 = values.next_double(); + tbp[j][k].p_bo3 = tbp[k][j].p_bo3 = values.next_double(); + tbp[j][k].p_bo4 = tbp[k][j].p_bo4 = values.next_double(); + values.skip(); + tbp[j][k].p_bo1 = tbp[k][j].p_bo1 = values.next_double(); + tbp[j][k].p_bo2 = tbp[k][j].p_bo2 = values.next_double(); + tbp[j][k].ovc = tbp[k][j].ovc = values.next_double(); + } + } + + for (i=0; i < ntypes; ++i) { + for (j=i; j < ntypes; ++j) { + tbp[i][j].r_s = tbp[j][i].r_s = 0.5*(sbp[j].r_s + sbp[i].r_s); + tbp[i][j].r_p = tbp[j][i].r_p = 0.5*(sbp[j].r_pi + sbp[i].r_pi); + tbp[i][j].r_pp = tbp[j][i].r_pp = 0.5*(sbp[j].r_pi_pi + sbp[i].r_pi_pi); + tbp[i][j].p_boc3 = tbp[j][i].p_boc3 = sqrt(sbp[j].b_o_132 * sbp[i].b_o_132); + tbp[i][j].p_boc4 = tbp[j][i].p_boc4 = sqrt(sbp[j].b_o_131 * sbp[i].b_o_131); + tbp[i][j].p_boc5 = tbp[j][i].p_boc5 = sqrt(sbp[j].b_o_133 * sbp[i].b_o_133); + tbp[i][j].D = tbp[j][i].D = sqrt(sbp[j].epsilon * sbp[i].epsilon); + tbp[i][j].alpha = tbp[j][i].alpha = sqrt(sbp[j].alpha * sbp[i].alpha); + tbp[i][j].r_vdW = tbp[j][i].r_vdW = 2.0*sqrt(sbp[j].r_vdw * sbp[i].r_vdw); + tbp[i][j].gamma_w = tbp[j][i].gamma_w = sqrt(sbp[j].gamma_w * sbp[i].gamma_w); + tbp[i][j].gamma = tbp[j][i].gamma = pow(sbp[j].gamma * sbp[i].gamma,-1.5); + + // additions for additional vdWaals interaction types - inner core + + tbp[i][j].rcore = tbp[j][i].rcore = sqrt(sbp[i].rcore2 * sbp[j].rcore2); + tbp[i][j].ecore = tbp[j][i].ecore = sqrt(sbp[i].ecore2 * sbp[j].ecore2); + tbp[i][j].acore = tbp[j][i].acore = sqrt(sbp[i].acore2 * sbp[j].acore2); + + // additions for additional vdWalls interaction types lg correction + + tbp[i][j].lgcij = tbp[j][i].lgcij = sqrt(sbp[i].lgcij * sbp[j].lgcij); + tbp[i][j].lgre = tbp[j][i].lgre = 2.0*gp.l[35]*sqrt(sbp[i].lgre*sbp[j].lgre); + } + } + + // next line is number of two body off-diagonal parameters + + values = reader.next_values(0); + n = values.next_int(); + ++lineno; + + double val; + for (i = 0; i < n; ++i) { + values = reader.next_values(0); + ++lineno; + if ((int)values.count() < 8 + lgflag) + THROW_ERROR("Invalid force field file format"); + + j = values.next_int() - 1; + k = values.next_int() - 1; + + if ((j < 0) || (k < 0)) + THROW_ERROR("Inconsistent force field file"); + + if ((j < ntypes) && (k < ntypes)) { + val = values.next_double(); + if (val > 0.0) tbp[j][k].D = tbp[k][j].D = val; + + val = values.next_double(); + if (val > 0.0) tbp[j][k].r_vdW = tbp[k][j].r_vdW = 2*val; + + val = values.next_double(); + if (val > 0.0) tbp[j][k].alpha = tbp[k][j].alpha = val; + + val = values.next_double(); + if (val > 0.0) tbp[j][k].r_s = tbp[k][j].r_s = val; + + val = values.next_double(); + if (val > 0.0) tbp[j][k].r_p = tbp[k][j].r_p = val; + + val = values.next_double(); + if (val > 0.0) tbp[j][k].r_pp = tbp[k][j].r_pp = val; + + if (lgflag) { + val = values.next_double(); + if (val >= 0.0) tbp[j][k].lgcij = tbp[k][j].lgcij = val; + } + } + } + + // next line is number of three body parameters + + values = reader.next_values(0); + n = values.next_int(); + ++lineno; + + int cnt; + for (i = 0; i < n; ++i) { + values = reader.next_values(0); + ++lineno; + if (values.count() < 10) + THROW_ERROR("Invalid force field file format"); + + j = values.next_int() - 1; + k = values.next_int() - 1; + l = values.next_int() - 1; + + if ((j < 0) || (k < 0) || (l < 0)) + THROW_ERROR("Inconsistent force field file"); + + if ((j < ntypes) && (k < ntypes) && (l < ntypes)) { + + cnt = thbp[j][k][l].cnt; + thbp[j][k][l].cnt++; + thbp[l][k][j].cnt++; + + val = values.next_double(); + thbp[j][k][l].prm[cnt].theta_00 = val; + thbp[l][k][j].prm[cnt].theta_00 = val; + + val = values.next_double(); + thbp[j][k][l].prm[cnt].p_val1 = val; + thbp[l][k][j].prm[cnt].p_val1 = val; + + val = values.next_double(); + thbp[j][k][l].prm[cnt].p_val2 = val; + thbp[l][k][j].prm[cnt].p_val2 = val; + + val = values.next_double(); + thbp[j][k][l].prm[cnt].p_coa1 = val; + thbp[l][k][j].prm[cnt].p_coa1 = val; + + val = values.next_double(); + thbp[j][k][l].prm[cnt].p_val7 = val; + thbp[l][k][j].prm[cnt].p_val7 = val; + + val = values.next_double(); + thbp[j][k][l].prm[cnt].p_pen1 = val; + thbp[l][k][j].prm[cnt].p_pen1 = val; + + val = values.next_double(); + thbp[j][k][l].prm[cnt].p_val4 = val; + thbp[l][k][j].prm[cnt].p_val4 = val; + } + } + + // next line is number of four body parameters + + values = reader.next_values(0); + n = values.next_int(); + ++lineno; + + for (i = 0; i < n; ++i) { + values = reader.next_values(0); + ++lineno; + if (values.count() < 9) + THROW_ERROR("Invalid force field file format"); + + j = values.next_int() - 1; + k = values.next_int() - 1; + l = values.next_int() - 1; + m = values.next_int() - 1; + + if ((j < -1) || (k < 0) || (l < 0) || (m < -1)) + THROW_ERROR("Inconsistent force field file"); + + const double val1 = values.next_double(); + const double val2 = values.next_double(); + const double val3 = values.next_double(); + const double val4 = values.next_double(); + const double val5 = values.next_double(); + + if ((j >= 0) && (m >= 0)) { // this means the entry is not in compact form + + if ((j < ntypes) && (k < ntypes) && (l < ntypes) && (m < ntypes)) { + + tor_flag[j][k][l][m] = tor_flag[m][l][k][j] = 1; + fbp[j][k][l][m].cnt = fbp[m][l][k][j].cnt = 1; + + fbp[j][k][l][m].prm[0].V1 = fbp[m][l][k][j].prm[0].V1 = val1; + fbp[j][k][l][m].prm[0].V2 = fbp[m][l][k][j].prm[0].V2 = val2; + fbp[j][k][l][m].prm[0].V3 = fbp[m][l][k][j].prm[0].V3 = val3; + fbp[j][k][l][m].prm[0].p_tor1 = fbp[m][l][k][j].prm[0].p_tor1 = val4; + fbp[j][k][l][m].prm[0].p_cot1 = fbp[m][l][k][j].prm[0].p_cot1 = val5; + } + + } else { /* This means the entry is of the form 0-X-Y-0 */ + + if ((k < ntypes) && (l < ntypes)) { + for (int p = 0; p < ntypes; ++p) { + for (int o = 0; o < ntypes; ++o) { + + if (tor_flag[p][k][l][o] == 0) { + fbp[p][k][l][o].cnt = 1; + fbp[p][k][l][o].prm[0].V1 = val1; + fbp[p][k][l][o].prm[0].V2 = val2; + fbp[p][k][l][o].prm[0].V3 = val3; + fbp[p][k][l][o].prm[0].p_tor1 = val4; + fbp[p][k][l][o].prm[0].p_cot1 = val5; + } + + if (tor_flag[o][l][k][p] == 0) { + fbp[o][l][k][p].cnt = 1; + fbp[o][l][k][p].prm[0].V1 = val1; + fbp[o][l][k][p].prm[0].V2 = val2; + fbp[o][l][k][p].prm[0].V3 = val3; + fbp[o][l][k][p].prm[0].p_tor1 = val4; + fbp[o][l][k][p].prm[0].p_cot1 = val5; + } + } + } + } + } + } + + // next line is number of hydrogen bond parameters + + values = reader.next_values(0); + n = values.next_int(); + ++lineno; + + for (i = 0; i < ntypes; ++i) + for (j = 0; j < ntypes; ++j) + for (k = 0; k < ntypes; ++k) + hbp[i][j][k].r0_hb = -1.0; + + for (i = 0; i < n; ++i) { + values = reader.next_values(0); + ++lineno; + if (values.count() < 7) + THROW_ERROR("Invalid force field file format"); + + j = values.next_int() - 1; + k = values.next_int() - 1; + l = values.next_int() - 1; + + if ((j < 0) || (k < 0) || (l < 0)) + THROW_ERROR("Inconsistent force field file"); + + if ((j < ntypes) && (k < ntypes) && (l < ntypes)) { + hbp[j][k][l].r0_hb = values.next_double(); + hbp[j][k][l].p_hb1 = values.next_double(); + hbp[j][k][l].p_hb2 = values.next_double(); + hbp[j][k][l].p_hb3 = values.next_double(); + } + } + + memory->destroy(tor_flag); + } catch (std::exception &e) { + error->one(FLERR,e.what()); + } + } + + // broadcast global parameters and allocate list on ranks != 0 + MPI_Bcast(&reax->gp,sizeof(global_parameters),MPI_CHAR,0,world); + if (control->me != 0) memory->create(reax->gp.l,reax->gp.n_global,"reaxff:gp.l"); + MPI_Bcast(reax->gp.l,reax->gp.n_global,MPI_DOUBLE,0,world); + + // allocate storage for atom type based data + MPI_Bcast(&reax->num_atom_types,1,MPI_INT,0,world); + const int n = reax->num_atom_types; + if (control->me != 0) { + memory->create(reax->sbp,n,"reaxff:sbp"); + memory->create(reax->tbp,n,n,"reaxff:tbp"); + memory->create(reax->thbp,n,n,n,"reaxff:thbp"); + memory->create(reax->hbp,n,n,n,"reaxff:hbp"); + memory->create(reax->fbp,n,n,n,n,"reaxff:fbp"); + } + + // broadcast type specific force field data + MPI_Bcast(&(reax->sbp[0]),sizeof(single_body_parameters)*n,MPI_CHAR,0,world); + MPI_Bcast(&(reax->tbp[0][0]),sizeof(two_body_parameters)*n*n,MPI_CHAR,0,world); + MPI_Bcast(&(reax->thbp[0][0][0]),sizeof(three_body_header)*n*n*n,MPI_CHAR,0,world); + MPI_Bcast(&(reax->hbp[0][0][0]),sizeof(hbond_parameters)*n*n*n,MPI_CHAR,0,world); + MPI_Bcast(&(reax->fbp[0][0][0][0]),sizeof(four_body_header)*n*n*n*n,MPI_CHAR,0,world); + + // apply global parameters to global control settings + + control->bo_cut = 0.01 * reax->gp.l[29]; + control->nonb_low = reax->gp.l[11]; + control->nonb_cut = reax->gp.l[12]; + } +#undef THROW_ERROR +} diff --git a/src/REAXFF/reaxff_forces.cpp b/src/REAXFF/reaxff_forces.cpp new file mode 100644 index 0000000000..ec783102b4 --- /dev/null +++ b/src/REAXFF/reaxff_forces.cpp @@ -0,0 +1,386 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + Hasan Metin Aktulga, hmaktulga@lbl.gov + Joseph Fogarty, jcfogart@mail.usf.edu + Sagar Pandit, pandit@usf.edu + Ananth Y Grama, ayg@cs.purdue.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, in press. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_api.h" + +#include +#include +#include + +#include "error.h" + +namespace ReaxFF { + + static void Compute_Bonded_Forces(reax_system *system, + control_params *control, + simulation_data *data, + storage *workspace, + reax_list **lists) + { + BO(system, workspace, lists); + Bonds(system, data, workspace, lists); + Atom_Energy(system, control, data, workspace, lists); + Valence_Angles(system, control, data, workspace, lists); + Torsion_Angles(system, control, data, workspace, lists); + if (control->hbond_cut > 0) + Hydrogen_Bonds(system, data, workspace, lists); + } + + static void Compute_NonBonded_Forces(reax_system *system, + control_params *control, + simulation_data *data, + storage *workspace, + reax_list **lists) + { + + /* van der Waals and Coulomb interactions */ + if (control->tabulate == 0) + vdW_Coulomb_Energy(system, control, data, workspace, lists); + else + Tabulated_vdW_Coulomb_Energy(system, control, data, workspace, lists); + } + + static void Compute_Total_Force(reax_system *system, storage *workspace, reax_list **lists) + { + int i, pj; + reax_list *bonds = (*lists) + BONDS; + + for (i = 0; i < system->N; ++i) + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) + if (i < bonds->select.bond_list[pj].nbr) + Add_dBond_to_Forces(system, i, pj, workspace, lists); + } + + static void Validate_Lists(reax_system *system, reax_list **lists, + int step, int N, int numH) + { + int i, comp, Hindex; + reax_list *bonds, *hbonds; + + double saferzone = system->saferzone; + + /* bond list */ + if (N > 0) { + bonds = *lists + BONDS; + + for (i = 0; i < N; ++i) { + system->my_atoms[i].num_bonds = MAX(Num_Entries(i,bonds)*2, MIN_BONDS); + + if (i < N-1) + comp = Start_Index(i+1, bonds); + else comp = bonds->num_intrs; + + if (End_Index(i, bonds) > comp) + system->error_ptr->one(FLERR, fmt::format("step {}: bondchk failed: " + "i={} end(i)={} str(i+1)={}\n", + step,i,End_Index(i,bonds),comp)); + } + } + + + /* hbonds list */ + if (numH > 0) { + hbonds = *lists + HBONDS; + + for (i = 0; i < N; ++i) { + Hindex = system->my_atoms[i].Hindex; + if (Hindex > -1) { + system->my_atoms[i].num_hbonds = + (int)(MAX(Num_Entries(Hindex, hbonds)*saferzone, system->minhbonds)); + + if (Hindex < numH-1) + comp = Start_Index(Hindex+1, hbonds); + else comp = hbonds->num_intrs; + + if (End_Index(Hindex, hbonds) > comp) + system->error_ptr->one(FLERR, fmt::format("step {}: hbondchk failed: " + "H={} end(H)={} str(H+1)={}\n", + step, Hindex,End_Index(Hindex,hbonds),comp)); + } + } + } + } + + static void Init_Forces_noQEq(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, + reax_list **lists) { + int i, j, pj; + int start_i, end_i; + int type_i, type_j; + int btop_i, num_bonds, num_hbonds; + int ihb, jhb, ihb_top, jhb_top; + int local, flag; + double cutoff; + reax_list *far_nbrs, *bonds, *hbonds; + single_body_parameters *sbp_i, *sbp_j; + two_body_parameters *twbp; + far_neighbor_data *nbr_pj; + reax_atom *atom_i, *atom_j; + + far_nbrs = *lists + FAR_NBRS; + bonds = *lists + BONDS; + hbonds = *lists + HBONDS; + + for (i = 0; i < system->n; ++i) + workspace->bond_mark[i] = 0; + for (i = system->n; i < system->N; ++i) { + workspace->bond_mark[i] = 1000; // put ghost atoms to an infinite distance + } + + num_bonds = 0; + num_hbonds = 0; + btop_i = 0; + + for (i = 0; i < system->N; ++i) { + atom_i = &(system->my_atoms[i]); + type_i = atom_i->type; + if (type_i < 0) continue; + start_i = Start_Index(i, far_nbrs); + end_i = End_Index(i, far_nbrs); + btop_i = End_Index(i, bonds); + sbp_i = &(system->reax_param.sbp[type_i]); + + if (i < system->n) { + local = 1; + cutoff = MAX(control->hbond_cut, control->bond_cut); + } else { + local = 0; + cutoff = control->bond_cut; + } + + ihb = -1; + ihb_top = -1; + if (local && control->hbond_cut > 0) { + ihb = sbp_i->p_hbond; + if (ihb == 1) + ihb_top = End_Index(atom_i->Hindex, hbonds); + else ihb_top = -1; + } + + /* update i-j distance - check if j is within cutoff */ + for (pj = start_i; pj < end_i; ++pj) { + nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); + j = nbr_pj->nbr; + atom_j = &(system->my_atoms[j]); + + if (nbr_pj->d <= cutoff) + flag = 1; + else flag = 0; + + if (flag) { + type_j = atom_j->type; + if (type_j < 0) continue; + sbp_j = &(system->reax_param.sbp[type_j]); + twbp = &(system->reax_param.tbp[type_i][type_j]); + + if (local) { + /* hydrogen bond lists */ + if (control->hbond_cut > 0 && (ihb==1 || ihb==2) && + nbr_pj->d <= control->hbond_cut) { + // fprintf(stderr, "%d %d\n", atom1, atom2); + jhb = sbp_j->p_hbond; + if (ihb == 1 && jhb == 2) { + hbonds->select.hbond_list[ihb_top].nbr = j; + hbonds->select.hbond_list[ihb_top].scl = 1; + hbonds->select.hbond_list[ihb_top].ptr = nbr_pj; + ++ihb_top; + ++num_hbonds; + } + else if (j < system->n && ihb == 2 && jhb == 1) { + jhb_top = End_Index(atom_j->Hindex, hbonds); + hbonds->select.hbond_list[jhb_top].nbr = i; + hbonds->select.hbond_list[jhb_top].scl = -1; + hbonds->select.hbond_list[jhb_top].ptr = nbr_pj; + Set_End_Index(atom_j->Hindex, jhb_top+1, hbonds); + ++num_hbonds; + } + } + } + + if (//(workspace->bond_mark[i] < 3 || workspace->bond_mark[j] < 3) && + nbr_pj->d <= control->bond_cut && + BOp(workspace, bonds, control->bo_cut, + i , btop_i, nbr_pj, sbp_i, sbp_j, twbp)) { + num_bonds += 2; + ++btop_i; + + if (workspace->bond_mark[j] > workspace->bond_mark[i] + 1) + workspace->bond_mark[j] = workspace->bond_mark[i] + 1; + else if (workspace->bond_mark[i] > workspace->bond_mark[j] + 1) { + workspace->bond_mark[i] = workspace->bond_mark[j] + 1; + } + } + } + } + + Set_End_Index(i, btop_i, bonds); + if (local && ihb == 1) + Set_End_Index(atom_i->Hindex, ihb_top, hbonds); + } + + + workspace->realloc.num_bonds = num_bonds; + workspace->realloc.num_hbonds = num_hbonds; + + Validate_Lists(system, lists, data->step, system->N, system->numH); + } + + void Estimate_Storages(reax_system *system, control_params *control, + reax_list **lists, int *Htop, int *hb_top, + int *bond_top, int *num_3body) + { + int i, j, pj; + int start_i, end_i; + int type_i, type_j; + int ihb, jhb; + int local; + double cutoff; + double r_ij; + double C12, C34, C56; + double BO, BO_s, BO_pi, BO_pi2; + reax_list *far_nbrs; + single_body_parameters *sbp_i, *sbp_j; + two_body_parameters *twbp; + far_neighbor_data *nbr_pj; + reax_atom *atom_i, *atom_j; + + int mincap = system->mincap; + double safezone = system->safezone; + double saferzone = system->saferzone; + + far_nbrs = *lists + FAR_NBRS; + *Htop = 0; + memset(hb_top, 0, sizeof(int) * system->local_cap); + memset(bond_top, 0, sizeof(int) * system->total_cap); + *num_3body = 0; + + for (i = 0; i < system->N; ++i) { + atom_i = &(system->my_atoms[i]); + type_i = atom_i->type; + if (type_i < 0) continue; + start_i = Start_Index(i, far_nbrs); + end_i = End_Index(i, far_nbrs); + sbp_i = &(system->reax_param.sbp[type_i]); + + if (i < system->n) { + local = 1; + cutoff = control->nonb_cut; + ++(*Htop); + ihb = sbp_i->p_hbond; + } else { + local = 0; + cutoff = control->bond_cut; + ihb = -1; + } + + for (pj = start_i; pj < end_i; ++pj) { + nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); + j = nbr_pj->nbr; + atom_j = &(system->my_atoms[j]); + + if (nbr_pj->d <= cutoff) { + type_j = system->my_atoms[j].type; + if (type_j < 0) continue; + r_ij = nbr_pj->d; + sbp_j = &(system->reax_param.sbp[type_j]); + twbp = &(system->reax_param.tbp[type_i][type_j]); + + if (local) { + if (j < system->n || atom_i->orig_id < atom_j->orig_id) //tryQEq ||1 + ++(*Htop); + + /* hydrogen bond lists */ + if (control->hbond_cut > 0.1 && (ihb==1 || ihb==2) && + nbr_pj->d <= control->hbond_cut) { + jhb = sbp_j->p_hbond; + if (ihb == 1 && jhb == 2) + ++hb_top[i]; + else if (j < system->n && ihb == 2 && jhb == 1) + ++hb_top[j]; + } + } + + /* uncorrected bond orders */ + if (nbr_pj->d <= control->bond_cut) { + if (sbp_i->r_s > 0.0 && sbp_j->r_s > 0.0) { + C12 = twbp->p_bo1 * pow(r_ij / twbp->r_s, twbp->p_bo2); + BO_s = (1.0 + control->bo_cut) * exp(C12); + } + else BO_s = C12 = 0.0; + + if (sbp_i->r_pi > 0.0 && sbp_j->r_pi > 0.0) { + C34 = twbp->p_bo3 * pow(r_ij / twbp->r_p, twbp->p_bo4); + BO_pi = exp(C34); + } + else BO_pi = C34 = 0.0; + + if (sbp_i->r_pi_pi > 0.0 && sbp_j->r_pi_pi > 0.0) { + C56 = twbp->p_bo5 * pow(r_ij / twbp->r_pp, twbp->p_bo6); + BO_pi2= exp(C56); + } + else BO_pi2 = C56 = 0.0; + + /* Initially BO values are the uncorrected ones, page 1 */ + BO = BO_s + BO_pi + BO_pi2; + + if (BO >= control->bo_cut) { + ++bond_top[i]; + ++bond_top[j]; + } + } + } + } + } + + *Htop = (int)(MAX(*Htop * safezone, mincap * MIN_HENTRIES)); + for (i = 0; i < system->n; ++i) + hb_top[i] = (int)(MAX(hb_top[i] * saferzone, system->minhbonds)); + + for (i = 0; i < system->N; ++i) { + *num_3body += SQR(bond_top[i]); + bond_top[i] = MAX(bond_top[i] * 2, MIN_BONDS); + } + + } + + void Compute_Forces(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, + reax_list **lists) + { + + Init_Forces_noQEq(system, control, data, workspace, lists); + + /********* bonded interactions ************/ + Compute_Bonded_Forces(system, control, data, workspace, lists); + + /********* nonbonded interactions ************/ + Compute_NonBonded_Forces(system, control, data, workspace, lists); + + /*********** total force ***************/ + Compute_Total_Force(system, workspace, lists); + } +} diff --git a/src/REAXFF/reaxff_hydrogen_bonds.cpp b/src/REAXFF/reaxff_hydrogen_bonds.cpp new file mode 100644 index 0000000000..5c7629ffb7 --- /dev/null +++ b/src/REAXFF/reaxff_hydrogen_bonds.cpp @@ -0,0 +1,160 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + Hasan Metin Aktulga, hmaktulga@lbl.gov + Joseph Fogarty, jcfogart@mail.usf.edu + Sagar Pandit, pandit@usf.edu + Ananth Y Grama, ayg@cs.purdue.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, in press. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_api.h" + +#include + +#include "pair.h" + +namespace ReaxFF { + void Hydrogen_Bonds(reax_system *system, simulation_data *data, storage *workspace, reax_list **lists) + { + int i, j, k, pi, pk; + int type_i, type_j, type_k; + int start_j, end_j, hb_start_j, hb_end_j; + int hblist[MAX_BONDS]; + int itr, top; + int num_hb_intrs = 0; + double r_jk, theta, cos_theta, sin_xhz4, cos_xhz1, sin_theta2; + double e_hb, exp_hb2, exp_hb3, CEhb1, CEhb2, CEhb3; + rvec dcos_theta_di, dcos_theta_dj, dcos_theta_dk; + rvec dvec_jk; + hbond_parameters *hbp; + bond_order_data *bo_ij; + bond_data *pbond_ij; + far_neighbor_data *nbr_jk; + reax_list *bonds, *hbonds; + bond_data *bond_list; + hbond_data *hbond_list; + + // tally variables + double fi_tmp[3], fk_tmp[3], delij[3], delkj[3]; + + bonds = (*lists) + BONDS; + bond_list = bonds->select.bond_list; + hbonds = (*lists) + HBONDS; + hbond_list = hbonds->select.hbond_list; + + for (j = 0; j < system->n; ++j) + if (system->reax_param.sbp[system->my_atoms[j].type].p_hbond == 1) { + type_j = system->my_atoms[j].type; + start_j = Start_Index(j, bonds); + end_j = End_Index(j, bonds); + hb_start_j = Start_Index(system->my_atoms[j].Hindex, hbonds); + hb_end_j = End_Index(system->my_atoms[j].Hindex, hbonds); + if (type_j < 0) continue; + + top = 0; + for (pi = start_j; pi < end_j; ++pi) { + pbond_ij = &(bond_list[pi]); + i = pbond_ij->nbr; + type_i = system->my_atoms[i].type; + if (type_i < 0) continue; + bo_ij = &(pbond_ij->bo_data); + + if (system->reax_param.sbp[type_i].p_hbond == 2 && + bo_ij->BO >= HB_THRESHOLD) + hblist[top++] = pi; + } + + for (pk = hb_start_j; pk < hb_end_j; ++pk) { + /* set k's varibles */ + k = hbond_list[pk].nbr; + type_k = system->my_atoms[k].type; + if (type_k < 0) continue; + nbr_jk = hbond_list[pk].ptr; + r_jk = nbr_jk->d; + rvec_Scale(dvec_jk, hbond_list[pk].scl, nbr_jk->dvec); + + for (itr = 0; itr < top; ++itr) { + pi = hblist[itr]; + pbond_ij = &(bonds->select.bond_list[pi]); + i = pbond_ij->nbr; + + if (system->my_atoms[i].orig_id != system->my_atoms[k].orig_id) { + bo_ij = &(pbond_ij->bo_data); + type_i = system->my_atoms[i].type; + if (type_i < 0) continue; + hbp = &(system->reax_param.hbp[type_i][type_j][type_k]); + if (hbp->r0_hb <= 0.0) continue; + ++num_hb_intrs; + + Calculate_Theta(pbond_ij->dvec, pbond_ij->d, dvec_jk, r_jk, + &theta, &cos_theta); + /* the derivative of cos(theta) */ + Calculate_dCos_Theta(pbond_ij->dvec, pbond_ij->d, dvec_jk, r_jk, + &dcos_theta_di, &dcos_theta_dj, + &dcos_theta_dk); + + /* hyrogen bond energy*/ + sin_theta2 = sin(theta/2.0); + sin_xhz4 = SQR(sin_theta2); + sin_xhz4 *= sin_xhz4; + cos_xhz1 = (1.0 - cos_theta); + exp_hb2 = exp(-hbp->p_hb2 * bo_ij->BO); + exp_hb3 = exp(-hbp->p_hb3 * (hbp->r0_hb / r_jk + + r_jk / hbp->r0_hb - 2.0)); + + data->my_en.e_hb += e_hb = + hbp->p_hb1 * (1.0 - exp_hb2) * exp_hb3 * sin_xhz4; + + CEhb1 = hbp->p_hb1 * hbp->p_hb2 * exp_hb2 * exp_hb3 * sin_xhz4; + CEhb2 = -hbp->p_hb1/2.0 * (1.0 - exp_hb2) * exp_hb3 * cos_xhz1; + CEhb3 = -hbp->p_hb3 * + (-hbp->r0_hb / SQR(r_jk) + 1.0 / hbp->r0_hb) * e_hb; + + /* hydrogen bond forces */ + bo_ij->Cdbo += CEhb1; // dbo term + + // dcos terms + rvec_ScaledAdd(workspace->f[i], +CEhb2, dcos_theta_di); + rvec_ScaledAdd(workspace->f[j], +CEhb2, dcos_theta_dj); + rvec_ScaledAdd(workspace->f[k], +CEhb2, dcos_theta_dk); + // dr terms + rvec_ScaledAdd(workspace->f[j], -CEhb3/r_jk, dvec_jk); + rvec_ScaledAdd(workspace->f[k], +CEhb3/r_jk, dvec_jk); + + /* tally into per-atom virials */ + if (system->pair_ptr->evflag) { + rvec_ScaledSum(delij, 1., system->my_atoms[j].x, + -1., system->my_atoms[i].x); + rvec_ScaledSum(delkj, 1., system->my_atoms[j].x, + -1., system->my_atoms[k].x); + + rvec_Scale(fi_tmp, CEhb2, dcos_theta_di); + rvec_Scale(fk_tmp, CEhb2, dcos_theta_dk); + rvec_ScaledAdd(fk_tmp, CEhb3/r_jk, dvec_jk); + + system->pair_ptr->ev_tally3(i,j,k,e_hb,0.0,fi_tmp,fk_tmp,delij,delkj); + } + } + } + } + } + } +} diff --git a/src/REAXFF/reaxff_init_md.cpp b/src/REAXFF/reaxff_init_md.cpp new file mode 100644 index 0000000000..268af75358 --- /dev/null +++ b/src/REAXFF/reaxff_init_md.cpp @@ -0,0 +1,177 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + + Contributing authors: + H. M. Aktulga, J. Fogarty, S. Pandit, A. Grama + Corresponding author: + Hasan Metin Aktulga, Michigan State University, hma@cse.msu.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, 38 (4-5), 245-259 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_api.h" + +#include "error.h" + +#include +#include +#include +#include + +namespace ReaxFF { + + void Init_System(reax_system *system, control_params *control) + { + int i; + reax_atom *atom; + + int mincap = system->mincap; + double safezone = system->safezone; + double saferzone = system->saferzone; + + // determine the local and total capacity + + system->local_cap = MAX((int)(system->n * safezone), mincap); + system->total_cap = MAX((int)(system->N * safezone), mincap); + + /* estimate numH and Hcap */ + system->numH = 0; + if (control->hbond_cut > 0) + for (i = 0; i < system->n; ++i) { + atom = &(system->my_atoms[i]); + if (system->reax_param.sbp[atom->type].p_hbond == 1 && atom->type >= 0) + atom->Hindex = system->numH++; + else atom->Hindex = -1; + } + system->Hcap = (int)(MAX(system->numH * saferzone, mincap)); + } + + void Init_Simulation_Data(simulation_data *data) + { + Reset_Simulation_Data(data); + data->step = 0; + } + + static void Init_Taper(control_params *control, storage *workspace) + { + double d1, d7; + double swa, swa2, swa3; + double swb, swb2, swb3; + LAMMPS_NS::Error *error = control->error_ptr; + + swa = control->nonb_low; + swb = control->nonb_cut; + + if (fabs(swa) > 0.01 && control->me == 0) + error->warning(FLERR, "Non-zero lower Taper-radius cutoff"); + + if (swb < 0) { + error->all(FLERR,"Negative upper Taper-radius cutoff"); + } + else if (swb < 5 && control->me == 0) + error->warning(FLERR,fmt::format("Warning: very low Taper-radius cutoff: " + "{}\n", swb)); + d1 = swb - swa; + d7 = pow(d1, 7.0); + swa2 = SQR(swa); + swa3 = CUBE(swa); + swb2 = SQR(swb); + swb3 = CUBE(swb); + + workspace->Tap[7] = 20.0 / d7; + workspace->Tap[6] = -70.0 * (swa + swb) / d7; + workspace->Tap[5] = 84.0 * (swa2 + 3.0*swa*swb + swb2) / d7; + workspace->Tap[4] = -35.0 * (swa3 + 9.0*swa2*swb + 9.0*swa*swb2 + swb3) / d7; + workspace->Tap[3] = 140.0 * (swa3*swb + 3.0*swa2*swb2 + swa*swb3) / d7; + workspace->Tap[2] =-210.0 * (swa3*swb2 + swa2*swb3) / d7; + workspace->Tap[1] = 140.0 * swa3 * swb3 / d7; + workspace->Tap[0] = (-35.0*swa3*swb2*swb2 + 21.0*swa2*swb3*swb2 - + 7.0*swa*swb3*swb3 + swb3*swb3*swb) / d7; + } + + void Init_Workspace(reax_system *system, control_params *control, storage *workspace) + { + Allocate_Workspace(control, workspace,system->total_cap); + + memset(&(workspace->realloc), 0, sizeof(reallocate_data)); + Reset_Workspace(system, workspace); + + /* Initialize the Taper function */ + Init_Taper(control, workspace); + } + + static void Init_Lists(reax_system *system, control_params *control, reax_list **lists) + { + int i, total_hbonds, total_bonds, bond_cap, num_3body, cap_3body, Htop; + int *hb_top, *bond_top; + + int mincap = system->mincap; + double safezone = system->safezone; + double saferzone = system->saferzone; + + bond_top = (int*) calloc(system->total_cap, sizeof(int)); + hb_top = (int*) calloc(system->local_cap, sizeof(int)); + Estimate_Storages(system, control, lists, + &Htop, hb_top, bond_top, &num_3body); + + if (control->hbond_cut > 0) { + /* init H indexes */ + total_hbonds = 0; + for (i = 0; i < system->n; ++i) { + system->my_atoms[i].num_hbonds = hb_top[i]; + total_hbonds += hb_top[i]; + } + total_hbonds = (int)(MAX(total_hbonds*saferzone,mincap*system->minhbonds)); + + Make_List(system->Hcap, total_hbonds, TYP_HBOND,*lists+HBONDS); + (*lists+HBONDS)->error_ptr = system->error_ptr; + } + + total_bonds = 0; + for (i = 0; i < system->N; ++i) { + system->my_atoms[i].num_bonds = bond_top[i]; + total_bonds += bond_top[i]; + } + bond_cap = (int)(MAX(total_bonds*safezone, mincap*MIN_BONDS)); + + Make_List(system->total_cap, bond_cap, TYP_BOND,*lists+BONDS); + (*lists+BONDS)->error_ptr = system->error_ptr; + + /* 3bodies list */ + cap_3body = (int)(MAX(num_3body*safezone, MIN_3BODIES)); + Make_List(bond_cap, cap_3body, TYP_THREE_BODY,*lists+THREE_BODIES); + (*lists+THREE_BODIES)->error_ptr = system->error_ptr; + + free(hb_top); + free(bond_top); + } + + void Initialize(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, + reax_list **lists, MPI_Comm world) + { + Init_System(system,control); + Init_Simulation_Data(data); + Init_Workspace(system,control,workspace); + Init_Lists(system,control,lists); + if (control->tabulate) + Init_Lookup_Tables(system,control,workspace,world); + } +} diff --git a/src/REAXFF/reaxff_inline.h b/src/REAXFF/reaxff_inline.h new file mode 100644 index 0000000000..a53ab4bb05 --- /dev/null +++ b/src/REAXFF/reaxff_inline.h @@ -0,0 +1,88 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/ 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 author: Hasan Metin Aktulga, Purdue University + (now at Lawrence Berkeley National Laboratory, hmaktulga@lbl.gov) + + Heavily modified and adapted for LAMMPS by the LAMMPS developers. +------------------------------------------------------------------------- */ + +#ifndef LMP_REAXFF_INLINE_H +#define LMP_REAXFF_INLINE_H + +#include "accelerator_kokkos.h" // for LAMMPS_INLINE + +namespace ReaxFF +{ + struct LR_data + { + double H; + double e_vdW, CEvd; + double e_ele, CEclmb; + + LAMMPS_INLINE + LR_data() {} + + LAMMPS_INLINE + void operator = (const LR_data& rhs) { + H = rhs.H; + e_vdW = rhs.e_vdW; + CEvd = rhs.CEvd; + e_ele = rhs.e_ele; + CEclmb = rhs.CEclmb; + } + LAMMPS_INLINE + void operator = (const LR_data& rhs) volatile { + H = rhs.H; + e_vdW = rhs.e_vdW; + CEvd = rhs.CEvd; + e_ele = rhs.e_ele; + CEclmb = rhs.CEclmb; + } + }; + + struct cubic_spline_coef + { + double a, b, c, d; + + LAMMPS_INLINE + cubic_spline_coef() {} + + LAMMPS_INLINE + cubic_spline_coef(const cubic_spline_coef &_c) { + a = _c.a; + b = _c.b; + c = _c.c; + d = _c.d; + } + + LAMMPS_INLINE + void operator=(const cubic_spline_coef &rhs) { + a = rhs.a; + b = rhs.b; + c = rhs.c; + d = rhs.d; + } + + LAMMPS_INLINE + void operator=(const cubic_spline_coef &rhs) volatile { + a = rhs.a; + b = rhs.b; + c = rhs.c; + d = rhs.d; + } + }; +} + +#endif diff --git a/src/REAXFF/reaxff_list.cpp b/src/REAXFF/reaxff_list.cpp new file mode 100644 index 0000000000..79d96bb9d9 --- /dev/null +++ b/src/REAXFF/reaxff_list.cpp @@ -0,0 +1,113 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + Hasan Metin Aktulga, hmaktulga@lbl.gov + Joseph Fogarty, jcfogart@mail.usf.edu + Sagar Pandit, pandit@usf.edu + Ananth Y Grama, ayg@cs.purdue.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, in press. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_api.h" + +#include "error.h" + +namespace ReaxFF { + + /************* allocate list space ******************/ + void Make_List(int n, int num_intrs, int type, reax_list *l) + { + l->allocated = 1; + + l->n = n; + l->num_intrs = num_intrs; + + if (l->index) sfree(l->error_ptr, l->index, "list:index"); + if (l->end_index) sfree(l->error_ptr, l->end_index, "list:end_index"); + l->index = (int*) smalloc(l->error_ptr, n * sizeof(int), "list:index"); + l->end_index = (int*) smalloc(l->error_ptr, n * sizeof(int), "list:end_index"); + + l->type = type; + + switch(l->type) { + case TYP_THREE_BODY: + if (l->select.three_body_list) sfree(l->error_ptr, l->select.three_body_list,"list:three_bodies"); + l->select.three_body_list = (three_body_interaction_data*) + smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(three_body_interaction_data), + "list:three_bodies"); + break; + + case TYP_BOND: + if (l->select.bond_list) sfree(l->error_ptr, l->select.bond_list,"list:bonds"); + l->select.bond_list = (bond_data*) + smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(bond_data), "list:bonds"); + break; + + case TYP_FAR_NEIGHBOR: + if (l->select.far_nbr_list) sfree(l->error_ptr, l->select.far_nbr_list,"list:far_nbrs"); + l->select.far_nbr_list = (far_neighbor_data*) + smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(far_neighbor_data), "list:far_nbrs"); + break; + + case TYP_HBOND: + if (l->select.hbond_list) sfree(l->error_ptr, l->select.hbond_list,"list:hbonds"); + l->select.hbond_list = (hbond_data*) + smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(hbond_data), "list:hbonds"); + break; + + default: + l->error_ptr->all(FLERR,fmt::format("No list type {} defined", l->type)); + } + } + + void Delete_List(reax_list *l) + { + if (l->allocated == 0) + return; + l->allocated = 0; + + sfree(l->error_ptr, l->index, "list:index"); + sfree(l->error_ptr, l->end_index, "list:end_index"); + l->index = nullptr; + l->end_index = nullptr; + + switch(l->type) { + case TYP_HBOND: + sfree(l->error_ptr, l->select.hbond_list, "list:hbonds"); + l->select.hbond_list = nullptr; + break; + case TYP_FAR_NEIGHBOR: + sfree(l->error_ptr, l->select.far_nbr_list, "list:far_nbrs"); + l->select.far_nbr_list = nullptr; + break; + case TYP_BOND: + sfree(l->error_ptr, l->select.bond_list, "list:bonds"); + l->select.bond_list = nullptr; + break; + case TYP_THREE_BODY: + sfree(l->error_ptr, l->select.three_body_list, "list:three_bodies"); + l->select.three_body_list = nullptr; + break; + + default: + l->error_ptr->all(FLERR,fmt::format("No list type {} defined", l->type)); + } + } +} diff --git a/src/REAXFF/reaxff_lookup.cpp b/src/REAXFF/reaxff_lookup.cpp new file mode 100644 index 0000000000..6471f1e6e2 --- /dev/null +++ b/src/REAXFF/reaxff_lookup.cpp @@ -0,0 +1,291 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + Hasan Metin Aktulga, hmaktulga@lbl.gov + Joseph Fogarty, jcfogart@mail.usf.edu + Sagar Pandit, pandit@usf.edu + Ananth Y Grama, ayg@cs.purdue.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, in press. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_api.h" + +#include +#include + +namespace ReaxFF { + static void Tridiagonal_Solve(const double *a, const double *b, + double *c, double *d, double *x, unsigned int n) { + int i; + double id; + + c[0] /= b[0]; /* Division by zero risk. */ + d[0] /= b[0]; /* Division by zero would imply a singular matrix. */ + for (i = 1; i < (int)n; i++) { + id = (b[i] - c[i-1] * a[i]); /* Division by zero risk. */ + c[i] /= id; /* Last value calculated is redundant. */ + d[i] = (d[i] - d[i-1] * a[i])/id; + } + + x[n - 1] = d[n - 1]; + for (i = n - 2; i >= 0; i--) + x[i] = d[i] - c[i] * x[i + 1]; + } + + void Natural_Cubic_Spline(LAMMPS_NS::Error* error_ptr, const double *h, const double *f, + cubic_spline_coef *coef, unsigned int n) + { + int i; + double *a, *b, *c, *d, *v; + + /* allocate space for the linear system */ + a = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); + b = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); + c = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); + d = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); + v = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); + + /* build the linear system */ + a[0] = a[1] = a[n-1] = 0; + for (i = 2; i < (int)n-1; ++i) + a[i] = h[i-1]; + + b[0] = b[n-1] = 0; + for (i = 1; i < (int)n-1; ++i) + b[i] = 2 * (h[i-1] + h[i]); + + c[0] = c[n-2] = c[n-1] = 0; + for (i = 1; i < (int)n-2; ++i) + c[i] = h[i]; + + d[0] = d[n-1] = 0; + for (i = 1; i < (int)n-1; ++i) + d[i] = 6 * ((f[i+1]-f[i])/h[i] - (f[i]-f[i-1])/h[i-1]); + + v[0] = 0; + v[n-1] = 0; + Tridiagonal_Solve(&(a[1]), &(b[1]), &(c[1]), &(d[1]), &(v[1]), n-2); + + for (i = 1; i < (int)n; ++i) { + coef[i-1].d = (v[i] - v[i-1]) / (6*h[i-1]); + coef[i-1].c = v[i]/2; + coef[i-1].b = (f[i]-f[i-1])/h[i-1] + h[i-1]*(2*v[i] + v[i-1])/6; + coef[i-1].a = f[i]; + } + + sfree(error_ptr, a, "cubic_spline:a"); + sfree(error_ptr, b, "cubic_spline:b"); + sfree(error_ptr, c, "cubic_spline:c"); + sfree(error_ptr, d, "cubic_spline:d"); + sfree(error_ptr, v, "cubic_spline:v"); + } + + void Complete_Cubic_Spline(LAMMPS_NS::Error* error_ptr, const double *h, + const double *f, double v0, double vlast, + cubic_spline_coef *coef, unsigned int n) + { + int i; + double *a, *b, *c, *d, *v; + + /* allocate space for the linear system */ + a = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); + b = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); + c = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); + d = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); + v = (double*) smalloc(error_ptr, n * sizeof(double), "cubic_spline:a"); + + /* build the linear system */ + a[0] = 0; + for (i = 1; i < (int)n; ++i) + a[i] = h[i-1]; + + b[0] = 2*h[0]; + for (i = 1; i < (int)n; ++i) + b[i] = 2 * (h[i-1] + h[i]); + + c[n-1] = 0; + for (i = 0; i < (int)n-1; ++i) + c[i] = h[i]; + + d[0] = 6 * (f[1]-f[0])/h[0] - 6 * v0; + d[n-1] = 6 * vlast - 6 * (f[n-1]-f[n-2]/h[n-2]); + for (i = 1; i < (int)n-1; ++i) + d[i] = 6 * ((f[i+1]-f[i])/h[i] - (f[i]-f[i-1])/h[i-1]); + + Tridiagonal_Solve(&(a[0]), &(b[0]), &(c[0]), &(d[0]), &(v[0]), n); + + for (i = 1; i < (int)n; ++i) { + coef[i-1].d = (v[i] - v[i-1]) / (6*h[i-1]); + coef[i-1].c = v[i]/2; + coef[i-1].b = (f[i]-f[i-1])/h[i-1] + h[i-1]*(2*v[i] + v[i-1])/6; + coef[i-1].a = f[i]; + } + + sfree(error_ptr, a, "cubic_spline:a"); + sfree(error_ptr, b, "cubic_spline:b"); + sfree(error_ptr, c, "cubic_spline:c"); + sfree(error_ptr, d, "cubic_spline:d"); + sfree(error_ptr, v, "cubic_spline:v"); + } + + void Init_Lookup_Tables(reax_system *system, control_params *control, + storage *workspace, MPI_Comm world) + { + int i, j, r; + double dr; + double *h, *fh, *fvdw, *fele, *fCEvd, *fCEclmb; + double v0_vdw, v0_ele, vlast_vdw, vlast_ele; + LR_lookup_table ** & LR = system->LR; + + /* initializations */ + v0_vdw = 0; + v0_ele = 0; + vlast_vdw = 0; + vlast_ele = 0; + + const int num_atom_types = system->reax_param.num_atom_types; + int *existing_types = new int[num_atom_types]; + int *aggregated = new int[num_atom_types]; + dr = control->nonb_cut / control->tabulate; + h = (double*) + smalloc(system->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:h"); + fh = (double*) + smalloc(system->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:fh"); + fvdw = (double*) + smalloc(system->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:fvdw"); + fCEvd = (double*) + smalloc(system->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:fCEvd"); + fele = (double*) + smalloc(system->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:fele"); + fCEclmb = (double*) + smalloc(system->error_ptr, (control->tabulate+2) * sizeof(double), "lookup:fCEclmb"); + + LR = (LR_lookup_table**) + scalloc(system->error_ptr, num_atom_types, sizeof(LR_lookup_table*), "lookup:LR"); + for (i = 0; i < num_atom_types; ++i) + LR[i] = (LR_lookup_table*) + scalloc(system->error_ptr, num_atom_types, sizeof(LR_lookup_table), "lookup:LR[i]"); + + for (i = 0; i < num_atom_types; ++i) + existing_types[i] = 0; + for (i = 0; i < system->n; ++i) + existing_types[system->my_atoms[i].type] = 1; + + MPI_Allreduce(existing_types, aggregated, num_atom_types, MPI_INT, MPI_SUM, world); + + for (i = 0; i < num_atom_types; ++i) { + if (aggregated[i]) { + for (j = i; j < num_atom_types; ++j) { + if (aggregated[j]) { + LR[i][j].xmin = 0; + LR[i][j].xmax = control->nonb_cut; + LR[i][j].n = control->tabulate + 2; + LR[i][j].dx = dr; + LR[i][j].inv_dx = control->tabulate / control->nonb_cut; + LR[i][j].y = (LR_data*) + smalloc(system->error_ptr, LR[i][j].n * sizeof(LR_data), "lookup:LR[i,j].y"); + LR[i][j].H = (cubic_spline_coef*) + smalloc(system->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].H"); + LR[i][j].vdW = (cubic_spline_coef*) + smalloc(system->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].vdW"); + LR[i][j].CEvd = (cubic_spline_coef*) + smalloc(system->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].CEvd"); + LR[i][j].ele = (cubic_spline_coef*) + smalloc(system->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].ele"); + LR[i][j].CEclmb = (cubic_spline_coef*) + smalloc(system->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef), + "lookup:LR[i,j].CEclmb"); + + for (r = 1; r <= control->tabulate; ++r) { + LR_vdW_Coulomb(system, workspace, control, i, j, r * dr, &(LR[i][j].y[r])); + h[r] = LR[i][j].dx; + fh[r] = LR[i][j].y[r].H; + fvdw[r] = LR[i][j].y[r].e_vdW; + fCEvd[r] = LR[i][j].y[r].CEvd; + fele[r] = LR[i][j].y[r].e_ele; + fCEclmb[r] = LR[i][j].y[r].CEclmb; + } + + // init the start-end points + h[r] = LR[i][j].dx; + v0_vdw = LR[i][j].y[1].CEvd; + v0_ele = LR[i][j].y[1].CEclmb; + fh[r] = fh[r-1]; + fvdw[r] = fvdw[r-1]; + fCEvd[r] = fCEvd[r-1]; + fele[r] = fele[r-1]; + fCEclmb[r] = fCEclmb[r-1]; + vlast_vdw = fCEvd[r-1]; + vlast_ele = fele[r-1]; + + Natural_Cubic_Spline(control->error_ptr, &h[1], &fh[1], + &(LR[i][j].H[1]), control->tabulate+1); + + Complete_Cubic_Spline(control->error_ptr, &h[1], &fvdw[1], v0_vdw, vlast_vdw, + &(LR[i][j].vdW[1]), control->tabulate+1); + + Natural_Cubic_Spline(control->error_ptr, &h[1], &fCEvd[1], + &(LR[i][j].CEvd[1]), control->tabulate+1); + + Complete_Cubic_Spline(control->error_ptr, &h[1], &fele[1], v0_ele, vlast_ele, + &(LR[i][j].ele[1]), control->tabulate+1); + + Natural_Cubic_Spline(control->error_ptr, &h[1], &fCEclmb[1], + &(LR[i][j].CEclmb[1]), control->tabulate+1); + } else { + LR[i][j].n = 0; + } + } + } + } + free(h); + free(fh); + free(fvdw); + free(fCEvd); + free(fele); + free(fCEclmb); + delete[] existing_types; + delete[] aggregated; + } + + void Deallocate_Lookup_Tables(reax_system *system) + { + int i, j; + int ntypes; + LR_lookup_table ** & LR = system->LR; + + ntypes = system->reax_param.num_atom_types; + + for (i = 0; i < ntypes; ++i) { + for (j = i; j < ntypes; ++j) + if (LR[i][j].n) { + sfree(system->error_ptr, LR[i][j].y, "LR[i,j].y"); + sfree(system->error_ptr, LR[i][j].H, "LR[i,j].H"); + sfree(system->error_ptr, LR[i][j].vdW, "LR[i,j].vdW"); + sfree(system->error_ptr, LR[i][j].CEvd, "LR[i,j].CEvd"); + sfree(system->error_ptr, LR[i][j].ele, "LR[i,j].ele"); + sfree(system->error_ptr, LR[i][j].CEclmb, "LR[i,j].CEclmb"); + } + sfree(system->error_ptr, LR[i], "LR[i]"); + } + sfree(system->error_ptr, LR, "LR"); + } +} + diff --git a/src/REAXFF/reaxc_multi_body.cpp b/src/REAXFF/reaxff_multi_body.cpp similarity index 84% rename from src/REAXFF/reaxc_multi_body.cpp rename to src/REAXFF/reaxff_multi_body.cpp index 778bb1ad41..2390b54474 100644 --- a/src/REAXFF/reaxc_multi_body.cpp +++ b/src/REAXFF/reaxff_multi_body.cpp @@ -25,17 +25,18 @@ . ----------------------------------------------------------------------*/ -#include "reaxc_multi_body.h" +#include "reaxff_api.h" + +#include "pair.h" + #include #include -#include "pair.h" -#include "reaxc_defs.h" -#include "reaxc_list.h" -void Atom_Energy( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, reax_list **lists, - output_controls * /*out_control*/ ) -{ +namespace ReaxFF { + + void Atom_Energy(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, reax_list **lists) + { int i, j, pj, type_i, type_j; double Delta_lpcorr, dfvl; double e_lp, expvd2, inv_expvd2, dElp, CElp, DlpVi; @@ -68,12 +69,12 @@ void Atom_Energy( reax_system *system, control_params *control, /* set the parameter pointer */ type_i = system->my_atoms[i].type; if (type_i < 0) continue; - sbp_i = &(system->reax_param.sbp[ type_i ]); + sbp_i = &(system->reax_param.sbp[type_i]); /* lone-pair Energy */ p_lp2 = sbp_i->p_lp2; - expvd2 = exp( -75 * workspace->Delta_lp[i] ); - inv_expvd2 = 1. / (1. + expvd2 ); + expvd2 = exp(-75 * workspace->Delta_lp[i]); + inv_expvd2 = 1. / (1. + expvd2); numbonds = 0; e_lp = 0.0; @@ -92,8 +93,8 @@ void Atom_Energy( reax_system *system, control_params *control, if (numbonds > 0 || control->enobondsflag) workspace->CdDelta[i] += CElp; // lp - 1st term - /* tally into per-atom energy */ - if (system->pair_ptr->evflag) + /* tally energy into global or per-atom energy accumulators */ + if (system->pair_ptr->eflag_either) system->pair_ptr->ev_tally(i,i,system->n,1,e_lp,0.0,0.0,0.0,0.0,0.0); /* correction for C2 */ @@ -103,9 +104,9 @@ void Atom_Energy( reax_system *system, control_params *control, type_j = system->my_atoms[j].type; if (type_j < 0) continue; - if (!strcmp( system->reax_param.sbp[type_j].name, "C" )) { - twbp = &( system->reax_param.tbp[type_i][type_j]); - bo_ij = &( bonds->select.bond_list[pj].bo_data ); + if (!strcmp(system->reax_param.sbp[type_j].name, "C")) { + twbp = &(system->reax_param.tbp[type_i][type_j]); + bo_ij = &(bonds->select.bond_list[pj].bo_data); Di = workspace->Delta[i]; vov3 = bo_ij->BO - Di - 0.040*pow(Di, 4.); @@ -118,8 +119,8 @@ void Atom_Energy( reax_system *system, control_params *control, bo_ij->Cdbo += deahu2dbo; workspace->CdDelta[i] += deahu2dsbo; - /* tally into per-atom energy */ - if (system->pair_ptr->evflag) + /* tally energy into global or per-atom energy accumulators */ + if (system->pair_ptr->eflag_either) system->pair_ptr->ev_tally(i,j,system->n,1,e_lph,0.0,0.0,0.0,0.0,0.0); } @@ -127,11 +128,10 @@ void Atom_Energy( reax_system *system, control_params *control, } } - for (i = 0; i < system->n; ++i) { type_i = system->my_atoms[i].type; if (type_i < 0) continue; - sbp_i = &(system->reax_param.sbp[ type_i ]); + sbp_i = &(system->reax_param.sbp[type_i]); /* over-coordination energy */ if (sbp_i->mass > 21.0) @@ -145,20 +145,20 @@ void Atom_Energy( reax_system *system, control_params *control, type_j = system->my_atoms[j].type; if (type_j < 0) continue; bo_ij = &(bonds->select.bond_list[pj].bo_data); - twbp = &(system->reax_param.tbp[ type_i ][ type_j ]); + twbp = &(system->reax_param.tbp[type_i][type_j]); sum_ovun1 += twbp->p_ovun1 * twbp->De_s * bo_ij->BO; sum_ovun2 += (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j])* - ( bo_ij->BO_pi + bo_ij->BO_pi2 ); + (bo_ij->BO_pi + bo_ij->BO_pi2); } - exp_ovun1 = p_ovun3 * exp( p_ovun4 * sum_ovun2 ); + exp_ovun1 = p_ovun3 * exp(p_ovun4 * sum_ovun2); inv_exp_ovun1 = 1.0 / (1 + exp_ovun1); Delta_lpcorr = workspace->Delta[i] - (dfvl * workspace->Delta_lp_temp[i]) * inv_exp_ovun1; - exp_ovun2 = exp( p_ovun2 * Delta_lpcorr ); + exp_ovun2 = exp(p_ovun2 * Delta_lpcorr); inv_exp_ovun2 = 1.0 / (1.0 + exp_ovun2); DlpVi = 1.0 / (Delta_lpcorr + sbp_i->valency + 1e-8); @@ -167,9 +167,9 @@ void Atom_Energy( reax_system *system, control_params *control, data->my_en.e_ov += e_ov = sum_ovun1 * CEover1; CEover2 = sum_ovun1 * DlpVi * inv_exp_ovun2 * - (1.0 - Delta_lpcorr * ( DlpVi + p_ovun2 * exp_ovun2 * inv_exp_ovun2 )); + (1.0 - Delta_lpcorr * (DlpVi + p_ovun2 * exp_ovun2 * inv_exp_ovun2)); - CEover3 = CEover2 * (1.0 - dfvl * workspace->dDelta_lp[i] * inv_exp_ovun1 ); + CEover3 = CEover2 * (1.0 - dfvl * workspace->dDelta_lp[i] * inv_exp_ovun1); CEover4 = CEover2 * (dfvl * workspace->Delta_lp_temp[i]) * p_ovun4 * exp_ovun1 * SQR(inv_exp_ovun1); @@ -180,7 +180,7 @@ void Atom_Energy( reax_system *system, control_params *control, p_ovun5 = sbp_i->p_ovun5; exp_ovun2n = 1.0 / exp_ovun2; - exp_ovun6 = exp( p_ovun6 * Delta_lpcorr ); + exp_ovun6 = exp(p_ovun6 * Delta_lpcorr); exp_ovun8 = p_ovun7 * exp(p_ovun8 * sum_ovun2); inv_exp_ovun2n = 1.0 / (1.0 + exp_ovun2n); inv_exp_ovun8 = 1.0 / (1.0 + exp_ovun8); @@ -195,15 +195,15 @@ void Atom_Energy( reax_system *system, control_params *control, -p_ovun5 * (1.0 - exp_ovun6) * inv_exp_ovun2n * inv_exp_ovun8; CEunder1 = inv_exp_ovun2n * - ( p_ovun5 * p_ovun6 * exp_ovun6 * inv_exp_ovun8 + - p_ovun2 * e_un * exp_ovun2n ); + (p_ovun5 * p_ovun6 * exp_ovun6 * inv_exp_ovun8 + + p_ovun2 * e_un * exp_ovun2n); CEunder2 = -e_un * p_ovun8 * exp_ovun8 * inv_exp_ovun8; CEunder3 = CEunder1 * (1.0 - dfvl*workspace->dDelta_lp[i]*inv_exp_ovun1); CEunder4 = CEunder1 * (dfvl*workspace->Delta_lp_temp[i]) * p_ovun4 * exp_ovun1 * SQR(inv_exp_ovun1) + CEunder2; - /* tally into per-atom energy */ - if (system->pair_ptr->evflag) { + /* tally energy into global or per-atom energy accumulators */ + if (system->pair_ptr->eflag_either) { eng_tmp = e_ov; if (numbonds > 0 || control->enobondsflag) eng_tmp += e_un; @@ -219,10 +219,9 @@ void Atom_Energy( reax_system *system, control_params *control, pbond = &(bonds->select.bond_list[pj]); j = pbond->nbr; bo_ij = &(pbond->bo_data); - twbp = &(system->reax_param.tbp[ system->my_atoms[i].type ] + twbp = &(system->reax_param.tbp[system->my_atoms[i].type] [system->my_atoms[pbond->nbr].type]); - bo_ij->Cdbo += CEover1 * twbp->p_ovun1 * twbp->De_s;// OvCoor-1st workspace->CdDelta[j] += CEover4 * (1.0 - dfvl*workspace->dDelta_lp[j]) * (bo_ij->BO_pi + bo_ij->BO_pi2); // OvCoor-3a @@ -231,15 +230,13 @@ void Atom_Energy( reax_system *system, control_params *control, bo_ij->Cdbopi2 += CEover4 * (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j]); // OvCoor-3b - workspace->CdDelta[j] += CEunder4 * (1.0 - dfvl*workspace->dDelta_lp[j]) * (bo_ij->BO_pi + bo_ij->BO_pi2); // UnCoor - 2a bo_ij->Cdbopi += CEunder4 * (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j]); // UnCoor-2b bo_ij->Cdbopi2 += CEunder4 * (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j]); // UnCoor-2b - } - } } +} diff --git a/src/REAXFF/reaxff_nonbonded.cpp b/src/REAXFF/reaxff_nonbonded.cpp new file mode 100644 index 0000000000..8a1e41da29 --- /dev/null +++ b/src/REAXFF/reaxff_nonbonded.cpp @@ -0,0 +1,407 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + Hasan Metin Aktulga, hmaktulga@lbl.gov + Joseph Fogarty, jcfogart@mail.usf.edu + Sagar Pandit, pandit@usf.edu + Ananth Y Grama, ayg@cs.purdue.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, in press. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_api.h" + +#include "pair.h" + +#include + +namespace ReaxFF { + void Compute_Polarization_Energy(reax_system *system, simulation_data *data) + { + int i, type_i; + double q, en_tmp; + + data->my_en.e_pol = 0.0; + for (i = 0; i < system->n; i++) { + type_i = system->my_atoms[i].type; + if (type_i < 0) continue; + q = system->my_atoms[i].q; + + en_tmp = KCALpMOL_to_EV * (system->reax_param.sbp[type_i].chi * q + + (system->reax_param.sbp[type_i].eta / 2.) * SQR(q)); + data->my_en.e_pol += en_tmp; + + /* tally energy into global or per-atom energy accumulators */ + if (system->pair_ptr->eflag_either) + system->pair_ptr->ev_tally(i,i,system->n,1,0.0,en_tmp,0.0,0.0,0.0,0.0); + } + } + + void vdW_Coulomb_Energy(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, + reax_list **lists) + { + int i, j, pj, natoms; + int start_i, end_i, flag; + rc_tagint orig_i, orig_j; + double p_vdW1, p_vdW1i; + double powr_vdW1, powgi_vdW1; + double tmp, r_ij, fn13, exp1, exp2; + double Tap, dTap, dfn13, CEvd, CEclmb, de_core; + double dr3gamij_1, dr3gamij_3; + double e_ele, e_vdW, e_core, SMALL = 0.0001; + double e_lg, de_lg, r_ij5, r_ij6, re6; + two_body_parameters *twbp; + far_neighbor_data *nbr_pj; + reax_list *far_nbrs; + + // Tallying variables: + double pe_vdw, f_tmp, delij[3]; + + natoms = system->n; + far_nbrs = (*lists) + FAR_NBRS; + p_vdW1 = system->reax_param.gp.l[28]; + p_vdW1i = 1.0 / p_vdW1; + e_core = 0; + e_vdW = 0; + e_lg = de_lg = 0.0; + + for (i = 0; i < natoms; ++i) { + if (system->my_atoms[i].type < 0) continue; + start_i = Start_Index(i, far_nbrs); + end_i = End_Index(i, far_nbrs); + orig_i = system->my_atoms[i].orig_id; + + for (pj = start_i; pj < end_i; ++pj) { + nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); + j = nbr_pj->nbr; + if (system->my_atoms[j].type < 0) continue; + orig_j = system->my_atoms[j].orig_id; + + flag = 0; + if (nbr_pj->d <= control->nonb_cut) { + if (j < natoms) flag = 1; + else if (orig_i < orig_j) flag = 1; + else if (orig_i == orig_j) { + if (nbr_pj->dvec[2] > SMALL) flag = 1; + else if (fabs(nbr_pj->dvec[2]) < SMALL) { + if (nbr_pj->dvec[1] > SMALL) flag = 1; + else if (fabs(nbr_pj->dvec[1]) < SMALL && nbr_pj->dvec[0] > SMALL) + flag = 1; + } + } + } + + if (flag) { + + r_ij = nbr_pj->d; + twbp = &(system->reax_param.tbp[system->my_atoms[i].type] + [system->my_atoms[j].type]); + + Tap = workspace->Tap[7] * r_ij + workspace->Tap[6]; + Tap = Tap * r_ij + workspace->Tap[5]; + Tap = Tap * r_ij + workspace->Tap[4]; + Tap = Tap * r_ij + workspace->Tap[3]; + Tap = Tap * r_ij + workspace->Tap[2]; + Tap = Tap * r_ij + workspace->Tap[1]; + Tap = Tap * r_ij + workspace->Tap[0]; + + dTap = 7*workspace->Tap[7] * r_ij + 6*workspace->Tap[6]; + dTap = dTap * r_ij + 5*workspace->Tap[5]; + dTap = dTap * r_ij + 4*workspace->Tap[4]; + dTap = dTap * r_ij + 3*workspace->Tap[3]; + dTap = dTap * r_ij + 2*workspace->Tap[2]; + dTap += workspace->Tap[1]/r_ij; + + /*vdWaals Calculations*/ + if (system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) + { // shielding + powr_vdW1 = pow(r_ij, p_vdW1); + powgi_vdW1 = pow(1.0 / twbp->gamma_w, p_vdW1); + + fn13 = pow(powr_vdW1 + powgi_vdW1, p_vdW1i); + exp1 = exp(twbp->alpha * (1.0 - fn13 / twbp->r_vdW)); + exp2 = exp(0.5 * twbp->alpha * (1.0 - fn13 / twbp->r_vdW)); + + e_vdW = twbp->D * (exp1 - 2.0 * exp2); + data->my_en.e_vdW += Tap * e_vdW; + + dfn13 = pow(powr_vdW1 + powgi_vdW1, p_vdW1i - 1.0) * + pow(r_ij, p_vdW1 - 2.0); + + CEvd = dTap * e_vdW - + Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) * dfn13; + } else { // no shielding + exp1 = exp(twbp->alpha * (1.0 - r_ij / twbp->r_vdW)); + exp2 = exp(0.5 * twbp->alpha * (1.0 - r_ij / twbp->r_vdW)); + + e_vdW = twbp->D * (exp1 - 2.0 * exp2); + data->my_en.e_vdW += Tap * e_vdW; + + CEvd = dTap * e_vdW - + Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; + } + + if (system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) + { // inner wall + e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); + data->my_en.e_vdW += Tap * e_core; + + de_core = -(twbp->acore/twbp->rcore) * e_core; + CEvd += dTap * e_core + Tap * de_core / r_ij; + + // lg correction, only if lgvdw is yes + if (control->lgflag) { + r_ij5 = pow(r_ij, 5.0); + r_ij6 = pow(r_ij, 6.0); + re6 = pow(twbp->lgre, 6.0); + e_lg = -(twbp->lgcij/(r_ij6 + re6)); + data->my_en.e_vdW += Tap * e_lg; + + de_lg = -6.0 * e_lg * r_ij5 / (r_ij6 + re6) ; + CEvd += dTap * e_lg + Tap * de_lg / r_ij; + } + + } + + /*Coulomb Calculations*/ + dr3gamij_1 = (r_ij * r_ij * r_ij + twbp->gamma); + dr3gamij_3 = pow(dr3gamij_1 , 0.33333333333333); + + tmp = Tap / dr3gamij_3; + data->my_en.e_ele += e_ele = + C_ele * system->my_atoms[i].q * system->my_atoms[j].q * tmp; + + CEclmb = C_ele * system->my_atoms[i].q * system->my_atoms[j].q * + (dTap - Tap * r_ij / dr3gamij_1) / dr3gamij_3; + + /* tally into per-atom energy */ + if (system->pair_ptr->evflag) { + pe_vdw = Tap * (e_vdW + e_core + e_lg); + rvec_ScaledSum(delij, 1., system->my_atoms[i].x, + -1., system->my_atoms[j].x); + f_tmp = -(CEvd + CEclmb); + system->pair_ptr->ev_tally(i,j,natoms,1,pe_vdw,e_ele, + f_tmp,delij[0],delij[1],delij[2]); + } + + rvec_ScaledAdd(workspace->f[i], -(CEvd + CEclmb), nbr_pj->dvec); + rvec_ScaledAdd(workspace->f[j], +(CEvd + CEclmb), nbr_pj->dvec); + } + } + } + + Compute_Polarization_Energy(system, data); + } + + void Tabulated_vdW_Coulomb_Energy(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, + reax_list **lists) + { + int i, j, pj, r, natoms; + int type_i, type_j, tmin, tmax; + int start_i, end_i, flag; + rc_tagint orig_i, orig_j; + double r_ij, base, dif; + double e_vdW, e_ele; + double CEvd, CEclmb, SMALL = 0.0001; + double f_tmp, delij[3]; + + far_neighbor_data *nbr_pj; + reax_list *far_nbrs; + LR_lookup_table *t; + LR_lookup_table ** & LR = system->LR; + + natoms = system->n; + far_nbrs = (*lists) + FAR_NBRS; + + e_ele = e_vdW = 0; + + for (i = 0; i < natoms; ++i) { + type_i = system->my_atoms[i].type; + if (type_i < 0) continue; + start_i = Start_Index(i,far_nbrs); + end_i = End_Index(i,far_nbrs); + orig_i = system->my_atoms[i].orig_id; + + for (pj = start_i; pj < end_i; ++pj) { + nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); + j = nbr_pj->nbr; + type_j = system->my_atoms[j].type; + if (type_j < 0) continue; + orig_j = system->my_atoms[j].orig_id; + + flag = 0; + if (nbr_pj->d <= control->nonb_cut) { + if (j < natoms) flag = 1; + else if (orig_i < orig_j) flag = 1; + else if (orig_i == orig_j) { + if (nbr_pj->dvec[2] > SMALL) flag = 1; + else if (fabs(nbr_pj->dvec[2]) < SMALL) { + if (nbr_pj->dvec[1] > SMALL) flag = 1; + else if (fabs(nbr_pj->dvec[1]) < SMALL && nbr_pj->dvec[0] > SMALL) + flag = 1; + } + } + } + + if (flag) { + + r_ij = nbr_pj->d; + tmin = MIN(type_i, type_j); + tmax = MAX(type_i, type_j); + t = &(LR[tmin][tmax]); + + /* Cubic Spline Interpolation */ + r = (int)(r_ij * t->inv_dx); + if (r == 0) ++r; + base = (double)(r+1) * t->dx; + dif = r_ij - base; + + e_vdW = ((t->vdW[r].d*dif + t->vdW[r].c)*dif + t->vdW[r].b)*dif + + t->vdW[r].a; + + e_ele = ((t->ele[r].d*dif + t->ele[r].c)*dif + t->ele[r].b)*dif + + t->ele[r].a; + e_ele *= system->my_atoms[i].q * system->my_atoms[j].q; + + data->my_en.e_vdW += e_vdW; + data->my_en.e_ele += e_ele; + + CEvd = ((t->CEvd[r].d*dif + t->CEvd[r].c)*dif + t->CEvd[r].b)*dif + + t->CEvd[r].a; + + CEclmb = ((t->CEclmb[r].d*dif+t->CEclmb[r].c)*dif+t->CEclmb[r].b)*dif + + t->CEclmb[r].a; + CEclmb *= system->my_atoms[i].q * system->my_atoms[j].q; + + /* tally into per-atom energy */ + if (system->pair_ptr->evflag) { + rvec_ScaledSum(delij, 1., system->my_atoms[i].x, + -1., system->my_atoms[j].x); + f_tmp = -(CEvd + CEclmb); + system->pair_ptr->ev_tally(i,j,natoms,1,e_vdW,e_ele, + f_tmp,delij[0],delij[1],delij[2]); + } + + rvec_ScaledAdd(workspace->f[i], -(CEvd + CEclmb), nbr_pj->dvec); + rvec_ScaledAdd(workspace->f[j], +(CEvd + CEclmb), nbr_pj->dvec); + } + } + } + + Compute_Polarization_Energy(system, data); + } + + void LR_vdW_Coulomb(reax_system *system, storage *workspace, + control_params *control, int i, int j, + double r_ij, LR_data *lr) + { + double p_vdW1 = system->reax_param.gp.l[28]; + double p_vdW1i = 1.0 / p_vdW1; + double powr_vdW1, powgi_vdW1; + double tmp, fn13, exp1, exp2; + double Tap, dTap, dfn13; + double dr3gamij_1, dr3gamij_3; + double e_core, de_core; + double e_lg, de_lg, r_ij5, r_ij6, re6; + two_body_parameters *twbp; + + twbp = &(system->reax_param.tbp[i][j]); + e_core = 0; + de_core = 0; + e_lg = de_lg = 0.0; + + /* calculate taper and its derivative */ + Tap = workspace->Tap[7] * r_ij + workspace->Tap[6]; + Tap = Tap * r_ij + workspace->Tap[5]; + Tap = Tap * r_ij + workspace->Tap[4]; + Tap = Tap * r_ij + workspace->Tap[3]; + Tap = Tap * r_ij + workspace->Tap[2]; + Tap = Tap * r_ij + workspace->Tap[1]; + Tap = Tap * r_ij + workspace->Tap[0]; + + dTap = 7*workspace->Tap[7] * r_ij + 6*workspace->Tap[6]; + dTap = dTap * r_ij + 5*workspace->Tap[5]; + dTap = dTap * r_ij + 4*workspace->Tap[4]; + dTap = dTap * r_ij + 3*workspace->Tap[3]; + dTap = dTap * r_ij + 2*workspace->Tap[2]; + dTap += workspace->Tap[1]/r_ij; + + /*vdWaals Calculations*/ + if (system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) + { // shielding + powr_vdW1 = pow(r_ij, p_vdW1); + powgi_vdW1 = pow(1.0 / twbp->gamma_w, p_vdW1); + + fn13 = pow(powr_vdW1 + powgi_vdW1, p_vdW1i); + exp1 = exp(twbp->alpha * (1.0 - fn13 / twbp->r_vdW)); + exp2 = exp(0.5 * twbp->alpha * (1.0 - fn13 / twbp->r_vdW)); + + lr->e_vdW = Tap * twbp->D * (exp1 - 2.0 * exp2); + + dfn13 = pow(powr_vdW1 + powgi_vdW1, p_vdW1i-1.0) * pow(r_ij, p_vdW1-2.0); + + lr->CEvd = dTap * twbp->D * (exp1 - 2.0 * exp2) - + Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) * dfn13; + } + else { // no shielding + exp1 = exp(twbp->alpha * (1.0 - r_ij / twbp->r_vdW)); + exp2 = exp(0.5 * twbp->alpha * (1.0 - r_ij / twbp->r_vdW)); + + lr->e_vdW = Tap * twbp->D * (exp1 - 2.0 * exp2); + lr->CEvd = dTap * twbp->D * (exp1 - 2.0 * exp2) - + Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; + } + + if (system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) + { // inner wall + e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); + lr->e_vdW += Tap * e_core; + + de_core = -(twbp->acore/twbp->rcore) * e_core; + lr->CEvd += dTap * e_core + Tap * de_core / r_ij; + + // lg correction, only if lgvdw is yes + if (control->lgflag) { + r_ij5 = pow(r_ij, 5.0); + r_ij6 = pow(r_ij, 6.0); + re6 = pow(twbp->lgre, 6.0); + e_lg = -(twbp->lgcij/(r_ij6 + re6)); + lr->e_vdW += Tap * e_lg; + + de_lg = -6.0 * e_lg * r_ij5 / (r_ij6 + re6) ; + lr->CEvd += dTap * e_lg + Tap * de_lg/r_ij; + } + + } + + + /* Coulomb calculations */ + dr3gamij_1 = (r_ij * r_ij * r_ij + twbp->gamma); + dr3gamij_3 = pow(dr3gamij_1 , 0.33333333333333); + + tmp = Tap / dr3gamij_3; + lr->H = EV_to_KCALpMOL * tmp; + lr->e_ele = C_ele * tmp; + + lr->CEclmb = C_ele * (dTap - Tap * r_ij / dr3gamij_1) / dr3gamij_3; + } +} + diff --git a/src/REAXFF/reaxff_reset_tools.cpp b/src/REAXFF/reaxff_reset_tools.cpp new file mode 100644 index 0000000000..30a58e84a5 --- /dev/null +++ b/src/REAXFF/reaxff_reset_tools.cpp @@ -0,0 +1,129 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + Hasan Metin Aktulga, hmaktulga@lbl.gov + Joseph Fogarty, jcfogart@mail.usf.edu + Sagar Pandit, pandit@usf.edu + Ananth Y Grama, ayg@cs.purdue.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, in press. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_api.h" + +#include "error.h" + +#include +#include + +namespace ReaxFF { + + static void Reset_Atoms(reax_system* system, control_params *control) + { + int i; + reax_atom *atom; + + system->numH = 0; + if (control->hbond_cut > 0) + for (i = 0; i < system->n; ++i) { + atom = &(system->my_atoms[i]); + if (atom->type < 0) continue; + if (system->reax_param.sbp[atom->type].p_hbond == 1) + atom->Hindex = system->numH++; + else atom->Hindex = -1; + } + } + + void Reset_Simulation_Data(simulation_data* data) + { + memset(&data->my_en,0,sizeof(energy_data)); + } + + void Reset_Workspace(reax_system *system, storage *workspace) + { + memset(workspace->total_bond_order, 0, system->total_cap * sizeof(double)); + memset(workspace->dDeltap_self, 0, system->total_cap * sizeof(rvec)); + memset(workspace->CdDelta, 0, system->total_cap * sizeof(double)); + memset(workspace->f, 0, system->total_cap * sizeof(rvec)); + + } + + static void Reset_Neighbor_Lists(reax_system *system, control_params *control, + storage *workspace, reax_list **lists) + { + int i, total_bonds, Hindex, total_hbonds; + reax_list *bonds, *hbonds; + + /* bonds list */ + if (system->N > 0) { + bonds = (*lists) + BONDS; + total_bonds = 0; + + /* reset start-end indexes */ + for (i = 0; i < system->N; ++i) { + Set_Start_Index(i, total_bonds, bonds); + Set_End_Index(i, total_bonds, bonds); + total_bonds += system->my_atoms[i].num_bonds; + } + + /* is reallocation needed? */ + if (total_bonds >= bonds->num_intrs * DANGER_ZONE) { + workspace->realloc.bonds = 1; + if (total_bonds >= bonds->num_intrs) + control->error_ptr->one(FLERR,fmt::format("Not enough space for bonds! " + "total={} allocated={}\n", + total_bonds, bonds->num_intrs)); + } + } + + if (control->hbond_cut > 0 && system->numH > 0) { + hbonds = (*lists) + HBONDS; + total_hbonds = 0; + + /* reset start-end indexes */ + for (i = 0; i < system->n; ++i) { + Hindex = system->my_atoms[i].Hindex; + if (Hindex > -1) { + Set_Start_Index(Hindex, total_hbonds, hbonds); + Set_End_Index(Hindex, total_hbonds, hbonds); + total_hbonds += system->my_atoms[i].num_hbonds; + } + } + + /* is reallocation needed? */ + if (total_hbonds >= hbonds->num_intrs * 0.90/*DANGER_ZONE*/) { + workspace->realloc.hbonds = 1; + if (total_hbonds >= hbonds->num_intrs) + control->error_ptr->one(FLERR,fmt::format("Not enough space for hbonds! " + "total={} allocated={}\n", + total_hbonds, hbonds->num_intrs)); + } + } + } + + + void Reset(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, reax_list **lists) + { + Reset_Atoms(system, control); + Reset_Simulation_Data(data); + Reset_Workspace(system, workspace); + Reset_Neighbor_Lists(system, control, workspace, lists); + } +} diff --git a/src/REAXFF/reaxff_tool_box.cpp b/src/REAXFF/reaxff_tool_box.cpp new file mode 100644 index 0000000000..15ad4b85e3 --- /dev/null +++ b/src/REAXFF/reaxff_tool_box.cpp @@ -0,0 +1,109 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + Hasan Metin Aktulga, hmaktulga@lbl.gov + Joseph Fogarty, jcfogart@mail.usf.edu + Sagar Pandit, pandit@usf.edu + Ananth Y Grama, ayg@cs.purdue.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, in press. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_api.h" + +#include +#include +#include + +#include "error.h" + +namespace ReaxFF { + + /* safe malloc */ + void *smalloc(LAMMPS_NS::Error *error_ptr, rc_bigint n, const char *name) + { + void *ptr; + + if (n <= 0) { + auto errmsg = fmt::format("Trying to allocate {} bytes for array {}. " + "returning NULL.", n, name); + if (error_ptr) error_ptr->one(FLERR,errmsg); + else fputs(errmsg.c_str(),stderr); + + return nullptr; + } + + ptr = malloc(n); + if (ptr == nullptr) { + auto errmsg = fmt::format("Failed to allocate {} bytes for array {}", + n, name); + if (error_ptr) error_ptr->one(FLERR,errmsg); + else fputs(errmsg.c_str(),stderr); + } + + return ptr; + } + + /* safe calloc */ + void *scalloc(LAMMPS_NS::Error *error_ptr, rc_bigint n, rc_bigint size, const char *name) + { + void *ptr; + + if (n <= 0) { + auto errmsg = fmt::format("Trying to allocate {} elements for array {}. " + "returning NULL.\n", n, name); + if (error_ptr) error_ptr->one(FLERR,errmsg); + else fputs(errmsg.c_str(),stderr); + return nullptr; + } + + if (size <= 0) { + auto errmsg = fmt::format("Elements size for array {} is {}. " + "returning NULL", name, size); + if (error_ptr) error_ptr->one(FLERR,errmsg); + else fputs(errmsg.c_str(),stderr); + return nullptr; + } + + ptr = calloc(n, size); + if (ptr == nullptr) { + auto errmsg = fmt::format("Failed to allocate {} bytes for array {}", + n*size, name); + if (error_ptr) error_ptr->one(FLERR,errmsg); + else fputs(errmsg.c_str(),stderr); + } + + return ptr; + } + + /* safe free */ + void sfree(LAMMPS_NS::Error* error_ptr, void *ptr, const char *name) + { + if (ptr == nullptr) { + auto errmsg = fmt::format("Trying to free the already free()'d pointer {}", + name); + if (error_ptr) error_ptr->one(FLERR,errmsg); + else fputs(errmsg.c_str(),stderr); + return; + } + + free(ptr); + ptr = nullptr; + } +} diff --git a/src/REAXFF/reaxff_torsion_angles.cpp b/src/REAXFF/reaxff_torsion_angles.cpp new file mode 100644 index 0000000000..329f7b8a7a --- /dev/null +++ b/src/REAXFF/reaxff_torsion_angles.cpp @@ -0,0 +1,405 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + Hasan Metin Aktulga, hmaktulga@lbl.gov + Joseph Fogarty, jcfogart@mail.usf.edu + Sagar Pandit, pandit@usf.edu + Ananth Y Grama, ayg@cs.purdue.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, in press. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_api.h" + +#include "pair.h" + +#include + +#define MIN_SINE 1e-10 + +namespace ReaxFF { + double Calculate_Omega(rvec dvec_ij, double r_ij, rvec dvec_jk, double r_jk, + rvec dvec_kl, double r_kl, rvec dvec_li, double r_li, + three_body_interaction_data *p_ijk, + three_body_interaction_data *p_jkl, + rvec dcos_omega_di, rvec dcos_omega_dj, + rvec dcos_omega_dk, rvec dcos_omega_dl) + { + double unnorm_cos_omega, unnorm_sin_omega, omega; + double sin_ijk, cos_ijk, sin_jkl, cos_jkl; + double htra, htrb, htrc, hthd, hthe, hnra, hnrc, hnhd, hnhe; + double arg, poem, tel; + rvec cross_jk_kl; + + sin_ijk = sin(p_ijk->theta); + cos_ijk = cos(p_ijk->theta); + sin_jkl = sin(p_jkl->theta); + cos_jkl = cos(p_jkl->theta); + + /* omega */ + unnorm_cos_omega = -rvec_Dot(dvec_ij, dvec_jk) * rvec_Dot(dvec_jk, dvec_kl) + + SQR(r_jk) * rvec_Dot(dvec_ij, dvec_kl); + + rvec_Cross(cross_jk_kl, dvec_jk, dvec_kl); + unnorm_sin_omega = -r_jk * rvec_Dot(dvec_ij, cross_jk_kl); + + omega = atan2(unnorm_sin_omega, unnorm_cos_omega); + + htra = r_ij + cos_ijk * (r_kl * cos_jkl - r_jk); + htrb = r_jk - r_ij * cos_ijk - r_kl * cos_jkl; + htrc = r_kl + cos_jkl * (r_ij * cos_ijk - r_jk); + hthd = r_ij * sin_ijk * (r_jk - r_kl * cos_jkl); + hthe = r_kl * sin_jkl * (r_jk - r_ij * cos_ijk); + hnra = r_kl * sin_ijk * sin_jkl; + hnrc = r_ij * sin_ijk * sin_jkl; + hnhd = r_ij * r_kl * cos_ijk * sin_jkl; + hnhe = r_ij * r_kl * sin_ijk * cos_jkl; + + poem = 2.0 * r_ij * r_kl * sin_ijk * sin_jkl; + if (poem < 1e-20) poem = 1e-20; + + tel = SQR(r_ij) + SQR(r_jk) + SQR(r_kl) - SQR(r_li) - + 2.0 * (r_ij * r_jk * cos_ijk - r_ij * r_kl * cos_ijk * cos_jkl + + r_jk * r_kl * cos_jkl); + + arg = tel / poem; + if (arg > 1.0) arg = 1.0; + if (arg < -1.0) arg = -1.0; + + if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) sin_ijk = MIN_SINE; + else if (sin_ijk <= 0 && sin_ijk >= -MIN_SINE) sin_ijk = -MIN_SINE; + if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) sin_jkl = MIN_SINE; + else if (sin_jkl <= 0 && sin_jkl >= -MIN_SINE) sin_jkl = -MIN_SINE; + + // dcos_omega_di + rvec_ScaledSum(dcos_omega_di, (htra-arg*hnra)/r_ij, dvec_ij, -1., dvec_li); + rvec_ScaledAdd(dcos_omega_di,-(hthd-arg*hnhd)/sin_ijk, p_ijk->dcos_dk); + rvec_Scale(dcos_omega_di, 2.0 / poem, dcos_omega_di); + + // dcos_omega_dj + rvec_ScaledSum(dcos_omega_dj,-(htra-arg*hnra)/r_ij, dvec_ij, + -htrb / r_jk, dvec_jk); + rvec_ScaledAdd(dcos_omega_dj,-(hthd-arg*hnhd)/sin_ijk, p_ijk->dcos_dj); + rvec_ScaledAdd(dcos_omega_dj,-(hthe-arg*hnhe)/sin_jkl, p_jkl->dcos_di); + rvec_Scale(dcos_omega_dj, 2.0 / poem, dcos_omega_dj); + + // dcos_omega_dk + rvec_ScaledSum(dcos_omega_dk,-(htrc-arg*hnrc)/r_kl, dvec_kl, + htrb / r_jk, dvec_jk); + rvec_ScaledAdd(dcos_omega_dk,-(hthd-arg*hnhd)/sin_ijk, p_ijk->dcos_di); + rvec_ScaledAdd(dcos_omega_dk,-(hthe-arg*hnhe)/sin_jkl, p_jkl->dcos_dj); + rvec_Scale(dcos_omega_dk, 2.0 / poem, dcos_omega_dk); + + // dcos_omega_dl + rvec_ScaledSum(dcos_omega_dl, (htrc-arg*hnrc)/r_kl, dvec_kl, 1., dvec_li); + rvec_ScaledAdd(dcos_omega_dl,-(hthe-arg*hnhe)/sin_jkl, p_jkl->dcos_dk); + rvec_Scale(dcos_omega_dl, 2.0 / poem, dcos_omega_dl); + + return omega; + } + + void Torsion_Angles(reax_system *system, control_params *control, + simulation_data *data, storage *workspace, + reax_list **lists) + { + int i, j, k, l, pi, pj, pk, pl, pij, plk, natoms; + int type_i, type_j, type_k, type_l; + int start_j, end_j; + int start_pj, end_pj, start_pk, end_pk; + int num_frb_intrs = 0; + + double Delta_j, Delta_k; + double r_ij, r_jk, r_kl, r_li; + double BOA_ij, BOA_jk, BOA_kl; + + double exp_tor2_ij, exp_tor2_jk, exp_tor2_kl; + double exp_tor1, exp_tor3_DjDk, exp_tor4_DjDk, exp_tor34_inv; + double exp_cot2_jk, exp_cot2_ij, exp_cot2_kl; + double fn10, f11_DjDk, dfn11, fn12; + double theta_ijk, theta_jkl; + double sin_ijk, sin_jkl; + double cos_ijk, cos_jkl; + double tan_ijk_i, tan_jkl_i; + double omega, cos_omega, cos2omega, cos3omega; + rvec dcos_omega_di, dcos_omega_dj, dcos_omega_dk, dcos_omega_dl; + double CV, cmn, CEtors1, CEtors2, CEtors3, CEtors4; + double CEtors5, CEtors6, CEtors7, CEtors8, CEtors9; + double Cconj, CEconj1, CEconj2, CEconj3; + double CEconj4, CEconj5, CEconj6; + double e_tor, e_con; + rvec dvec_li; + four_body_header *fbh; + four_body_parameters *fbp; + bond_data *pbond_ij, *pbond_jk, *pbond_kl; + bond_order_data *bo_ij, *bo_jk, *bo_kl; + three_body_interaction_data *p_ijk, *p_jkl; + double p_tor2 = system->reax_param.gp.l[23]; + double p_tor3 = system->reax_param.gp.l[24]; + double p_tor4 = system->reax_param.gp.l[25]; + double p_cot2 = system->reax_param.gp.l[27]; + reax_list *bonds = (*lists) + BONDS; + reax_list *thb_intrs = (*lists) + THREE_BODIES; + + // Virial tallying variables + double delil[3], deljl[3], delkl[3]; + double eng_tmp, fi_tmp[3], fj_tmp[3], fk_tmp[3]; + + natoms = system->n; + + for (j = 0; j < natoms; ++j) { + type_j = system->my_atoms[j].type; + Delta_j = workspace->Delta_boc[j]; + start_j = Start_Index(j, bonds); + end_j = End_Index(j, bonds); + + for (pk = start_j; pk < end_j; ++pk) { + pbond_jk = &(bonds->select.bond_list[pk]); + k = pbond_jk->nbr; + bo_jk = &(pbond_jk->bo_data); + BOA_jk = bo_jk->BO - control->thb_cut; + + if (system->my_atoms[j].orig_id > system->my_atoms[k].orig_id) + continue; + if (system->my_atoms[j].orig_id == system->my_atoms[k].orig_id) { + if (system->my_atoms[k].x[2] < system->my_atoms[j].x[2]) continue; + if (system->my_atoms[k].x[2] == system->my_atoms[j].x[2] && + system->my_atoms[k].x[1] < system->my_atoms[j].x[1]) continue; + if (system->my_atoms[k].x[2] == system->my_atoms[j].x[2] && + system->my_atoms[k].x[1] == system->my_atoms[j].x[1] && + system->my_atoms[k].x[0] < system->my_atoms[j].x[0]) continue; + } + + if (bo_jk->BO > control->thb_cut/*0*/ && Num_Entries(pk, thb_intrs)) { + pj = pbond_jk->sym_index; // pj points to j on k's list + + if (Num_Entries(pj, thb_intrs)) { + type_k = system->my_atoms[k].type; + Delta_k = workspace->Delta_boc[k]; + r_jk = pbond_jk->d; + + start_pk = Start_Index(pk, thb_intrs); + end_pk = End_Index(pk, thb_intrs); + start_pj = Start_Index(pj, thb_intrs); + end_pj = End_Index(pj, thb_intrs); + + exp_tor2_jk = exp(-p_tor2 * BOA_jk); + exp_cot2_jk = exp(-p_cot2 * SQR(BOA_jk - 1.5)); + exp_tor3_DjDk = exp(-p_tor3 * (Delta_j + Delta_k)); + exp_tor4_DjDk = exp(p_tor4 * (Delta_j + Delta_k)); + exp_tor34_inv = 1.0 / (1.0 + exp_tor3_DjDk + exp_tor4_DjDk); + f11_DjDk = (2.0 + exp_tor3_DjDk) * exp_tor34_inv; + + for (pi = start_pk; pi < end_pk; ++pi) { + p_ijk = &(thb_intrs->select.three_body_list[pi]); + pij = p_ijk->pthb; // pij is pointer to i on j's bond_list + pbond_ij = &(bonds->select.bond_list[pij]); + bo_ij = &(pbond_ij->bo_data); + + if (bo_ij->BO > control->thb_cut/*0*/) { + i = p_ijk->thb; + type_i = system->my_atoms[i].type; + r_ij = pbond_ij->d; + BOA_ij = bo_ij->BO - control->thb_cut; + + theta_ijk = p_ijk->theta; + sin_ijk = sin(theta_ijk); + cos_ijk = cos(theta_ijk); + //tan_ijk_i = 1. / tan(theta_ijk); + if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) + tan_ijk_i = cos_ijk / MIN_SINE; + else if (sin_ijk <= 0 && sin_ijk >= -MIN_SINE) + tan_ijk_i = cos_ijk / -MIN_SINE; + else tan_ijk_i = cos_ijk / sin_ijk; + + exp_tor2_ij = exp(-p_tor2 * BOA_ij); + exp_cot2_ij = exp(-p_cot2 * SQR(BOA_ij -1.5)); + + for (pl = start_pj; pl < end_pj; ++pl) { + p_jkl = &(thb_intrs->select.three_body_list[pl]); + l = p_jkl->thb; + plk = p_jkl->pthb; //pointer to l on k's bond_list! + pbond_kl = &(bonds->select.bond_list[plk]); + bo_kl = &(pbond_kl->bo_data); + type_l = system->my_atoms[l].type; + fbh = &(system->reax_param.fbp[type_i][type_j] + [type_k][type_l]); + fbp = &(system->reax_param.fbp[type_i][type_j] + [type_k][type_l].prm[0]); + + if (i != l && fbh->cnt && + bo_kl->BO > control->thb_cut/*0*/ && + bo_ij->BO * bo_jk->BO * bo_kl->BO > control->thb_cut/*0*/) { + ++num_frb_intrs; + r_kl = pbond_kl->d; + BOA_kl = bo_kl->BO - control->thb_cut; + + theta_jkl = p_jkl->theta; + sin_jkl = sin(theta_jkl); + cos_jkl = cos(theta_jkl); + //tan_jkl_i = 1. / tan(theta_jkl); + if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) + tan_jkl_i = cos_jkl / MIN_SINE; + else if (sin_jkl <= 0 && sin_jkl >= -MIN_SINE) + tan_jkl_i = cos_jkl / -MIN_SINE; + else tan_jkl_i = cos_jkl /sin_jkl; + + rvec_ScaledSum(dvec_li, 1., system->my_atoms[i].x, + -1., system->my_atoms[l].x); + r_li = rvec_Norm(dvec_li); + + + /* omega and its derivative */ + omega = Calculate_Omega(pbond_ij->dvec, r_ij, + pbond_jk->dvec, r_jk, + pbond_kl->dvec, r_kl, + dvec_li, r_li, + p_ijk, p_jkl, + dcos_omega_di, dcos_omega_dj, + dcos_omega_dk, dcos_omega_dl); + + cos_omega = cos(omega); + cos2omega = cos(2. * omega); + cos3omega = cos(3. * omega); + /* end omega calculations */ + + /* torsion energy */ + exp_tor1 = exp(fbp->p_tor1 * + SQR(2.0 - bo_jk->BO_pi - f11_DjDk)); + exp_tor2_kl = exp(-p_tor2 * BOA_kl); + exp_cot2_kl = exp(-p_cot2 * SQR(BOA_kl - 1.5)); + fn10 = (1.0 - exp_tor2_ij) * (1.0 - exp_tor2_jk) * + (1.0 - exp_tor2_kl); + + CV = 0.5 * (fbp->V1 * (1.0 + cos_omega) + + fbp->V2 * exp_tor1 * (1.0 - cos2omega) + + fbp->V3 * (1.0 + cos3omega)); + + data->my_en.e_tor += e_tor = fn10 * sin_ijk * sin_jkl * CV; + + dfn11 = (-p_tor3 * exp_tor3_DjDk + + (p_tor3 * exp_tor3_DjDk - p_tor4 * exp_tor4_DjDk) * + (2.0 + exp_tor3_DjDk) * exp_tor34_inv) * + exp_tor34_inv; + + CEtors1 = sin_ijk * sin_jkl * CV; + + CEtors2 = -fn10 * 2.0 * fbp->p_tor1 * fbp->V2 * exp_tor1 * + (2.0 - bo_jk->BO_pi - f11_DjDk) * (1.0 - SQR(cos_omega)) * + sin_ijk * sin_jkl; + CEtors3 = CEtors2 * dfn11; + + CEtors4 = CEtors1 * p_tor2 * exp_tor2_ij * + (1.0 - exp_tor2_jk) * (1.0 - exp_tor2_kl); + CEtors5 = CEtors1 * p_tor2 * + (1.0 - exp_tor2_ij) * exp_tor2_jk * (1.0 - exp_tor2_kl); + CEtors6 = CEtors1 * p_tor2 * + (1.0 - exp_tor2_ij) * (1.0 - exp_tor2_jk) * exp_tor2_kl; + + cmn = -fn10 * CV; + CEtors7 = cmn * sin_jkl * tan_ijk_i; + CEtors8 = cmn * sin_ijk * tan_jkl_i; + + CEtors9 = fn10 * sin_ijk * sin_jkl * + (0.5 * fbp->V1 - 2.0 * fbp->V2 * exp_tor1 * cos_omega + + 1.5 * fbp->V3 * (cos2omega + 2.0 * SQR(cos_omega))); + /* end of torsion energy */ + + /* 4-body conjugation energy */ + fn12 = exp_cot2_ij * exp_cot2_jk * exp_cot2_kl; + data->my_en.e_con += e_con = + fbp->p_cot1 * fn12 * + (1.0 + (SQR(cos_omega) - 1.0) * sin_ijk * sin_jkl); + + Cconj = -2.0 * fn12 * fbp->p_cot1 * p_cot2 * + (1.0 + (SQR(cos_omega) - 1.0) * sin_ijk * sin_jkl); + + CEconj1 = Cconj * (BOA_ij - 1.5e0); + CEconj2 = Cconj * (BOA_jk - 1.5e0); + CEconj3 = Cconj * (BOA_kl - 1.5e0); + + CEconj4 = -fbp->p_cot1 * fn12 * + (SQR(cos_omega) - 1.0) * sin_jkl * tan_ijk_i; + CEconj5 = -fbp->p_cot1 * fn12 * + (SQR(cos_omega) - 1.0) * sin_ijk * tan_jkl_i; + CEconj6 = 2.0 * fbp->p_cot1 * fn12 * + cos_omega * sin_ijk * sin_jkl; + /* end 4-body conjugation energy */ + + /* forces */ + bo_jk->Cdbopi += CEtors2; + workspace->CdDelta[j] += CEtors3; + workspace->CdDelta[k] += CEtors3; + bo_ij->Cdbo += (CEtors4 + CEconj1); + bo_jk->Cdbo += (CEtors5 + CEconj2); + bo_kl->Cdbo += (CEtors6 + CEconj3); + + /* dcos_theta_ijk */ + rvec_ScaledAdd(workspace->f[i], CEtors7 + CEconj4, p_ijk->dcos_dk); + rvec_ScaledAdd(workspace->f[j], CEtors7 + CEconj4, p_ijk->dcos_dj); + rvec_ScaledAdd(workspace->f[k], CEtors7 + CEconj4, p_ijk->dcos_di); + + /* dcos_theta_jkl */ + rvec_ScaledAdd(workspace->f[j], CEtors8 + CEconj5, p_jkl->dcos_di); + rvec_ScaledAdd(workspace->f[k], CEtors8 + CEconj5, p_jkl->dcos_dj); + rvec_ScaledAdd(workspace->f[l], CEtors8 + CEconj5, p_jkl->dcos_dk); + + /* dcos_omega */ + rvec_ScaledAdd(workspace->f[i], CEtors9 + CEconj6, dcos_omega_di); + rvec_ScaledAdd(workspace->f[j], CEtors9 + CEconj6, dcos_omega_dj); + rvec_ScaledAdd(workspace->f[k], CEtors9 + CEconj6, dcos_omega_dk); + rvec_ScaledAdd(workspace->f[l], CEtors9 + CEconj6, dcos_omega_dl); + + /* tally into per-atom virials */ + if (system->pair_ptr->evflag) { + + // acquire vectors + rvec_ScaledSum(delil, 1., system->my_atoms[l].x, -1., system->my_atoms[i].x); + rvec_ScaledSum(deljl, 1., system->my_atoms[l].x, -1., system->my_atoms[j].x); + rvec_ScaledSum(delkl, 1., system->my_atoms[l].x, -1., system->my_atoms[k].x); + // dcos_theta_ijk + rvec_Scale(fi_tmp, CEtors7 + CEconj4, p_ijk->dcos_dk); + rvec_Scale(fj_tmp, CEtors7 + CEconj4, p_ijk->dcos_dj); + rvec_Scale(fk_tmp, CEtors7 + CEconj4, p_ijk->dcos_di); + + // dcos_theta_jkl + rvec_ScaledAdd(fj_tmp, CEtors8 + CEconj5, p_jkl->dcos_di); + rvec_ScaledAdd(fk_tmp, CEtors8 + CEconj5, p_jkl->dcos_dj); + + // dcos_omega + rvec_ScaledAdd(fi_tmp, CEtors9 + CEconj6, dcos_omega_di); + rvec_ScaledAdd(fj_tmp, CEtors9 + CEconj6, dcos_omega_dj); + rvec_ScaledAdd(fk_tmp, CEtors9 + CEconj6, dcos_omega_dk); + + // tally + eng_tmp = e_tor + e_con; + if (system->pair_ptr->eflag_either) + system->pair_ptr->ev_tally(j,k,natoms,1,eng_tmp,0.0,0.0,0.0,0.0,0.0); + if (system->pair_ptr->vflag_either) + system->pair_ptr->v_tally4(i,j,k,l,fi_tmp,fj_tmp,fk_tmp,delil,deljl,delkl); + } + } // pl check ends + } // pl loop ends + } // pi check ends + } // pi loop ends + } // k-j neighbor check ends + } // j-k neighbor check ends + } // pk loop ends + } // j loop + } +} diff --git a/src/REAXFF/reaxff_types.h b/src/REAXFF/reaxff_types.h new file mode 100644 index 0000000000..e57244c66b --- /dev/null +++ b/src/REAXFF/reaxff_types.h @@ -0,0 +1,401 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/ 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 author: Hasan Metin Aktulga, Purdue University + (now at Lawrence Berkeley National Laboratory, hmaktulga@lbl.gov) + + Heavily modified and adapted for LAMMPS by the LAMMPS developers. +------------------------------------------------------------------------- */ + +#ifndef LMP_REAXFF_TYPES_H +#define LMP_REAXFF_TYPES_H + +#include "lmptype.h" + +#include "reaxff_defs.h" +#include "reaxff_inline.h" + +// forward declarations +namespace LAMMPS_NS { + class Error; + class LAMMPS; + class Memory; + class Pair; +} + +namespace ReaxFF +{ + /********************** TYPE DEFINITIONS ********************/ + typedef int ivec[3]; + typedef double rvec[3]; + typedef double rvec2[2]; + + // import LAMMPS' definition of tagint and bigint + typedef LAMMPS_NS::tagint rc_tagint; + typedef LAMMPS_NS::bigint rc_bigint; + + struct global_parameters + { + int n_global; + int vdw_type; + double *l; + }; + + struct single_body_parameters + { + char name[4]; // two character atom name + double r_s; + double valency; // Valency of the atom + double mass; // Mass of atom + double r_vdw; + double epsilon; + double gamma; + double r_pi; + double valency_e; + double nlp_opt; + + /* Line two in field file */ + double alpha; + double gamma_w; + double valency_boc; + double p_ovun5; + double chi; + double eta; + int p_hbond; // 1 for H, 2 for hbonding atoms (O,S,P,N), 0 for others + + /* Line three in field file */ + double r_pi_pi; + double p_lp2; + double b_o_131; + double b_o_132; + double b_o_133; + + /* Line four in the field file */ + double p_ovun2; + double p_val3; + double valency_val; + double p_val5; + double rcore2; + double ecore2; + double acore2; + + /* Line five in the ffield file, only for lgvdw yes */ + double lgcij; + double lgre; + + }; + + /* Two Body Parameters */ + struct two_body_parameters { + /* Bond Order parameters */ + double p_bo1,p_bo2,p_bo3,p_bo4,p_bo5,p_bo6; + double r_s, r_p, r_pp; // r_o distances in BO formula + double p_boc3, p_boc4, p_boc5; + + /* Bond Energy parameters */ + double p_be1, p_be2; + double De_s, De_p, De_pp; + + /* Over/Under coordination parameters */ + double p_ovun1; + + /* Van der Waal interaction parameters */ + double D; + double alpha; + double r_vdW; + double gamma_w; + double rcore, ecore, acore; + double lgcij, lgre; + + /* electrostatic parameters */ + double gamma; // note: this parameter is gamma^-3 and not gamma. + + double v13cor, ovc; + }; + + struct dbond_coefficients { + double C1dbo, C2dbo, C3dbo; + double C1dbopi, C2dbopi, C3dbopi, C4dbopi; + double C1dbopi2, C2dbopi2, C3dbopi2, C4dbopi2; + double C1dDelta, C2dDelta, C3dDelta; + }; + + /* 3-body parameters */ + struct three_body_parameters { + /* valence angle */ + double theta_00; + double p_val1, p_val2, p_val4, p_val7; + + /* penalty */ + double p_pen1; + + /* 3-body conjugation */ + double p_coa1; + }; + + struct three_body_header + { + int cnt; + three_body_parameters prm[REAX_MAX_3BODY_PARAM]; + }; + + /* hydrogen-bond parameters */ + struct hbond_parameters + { + double r0_hb, p_hb1, p_hb2, p_hb3; + }; + + /* 4-body parameters */ + struct four_body_parameters + { + double V1, V2, V3; + + /* torsion angle */ + double p_tor1; + + /* 4-body conjugation */ + double p_cot1; + }; + + struct four_body_header + { + int cnt; + four_body_parameters prm[REAX_MAX_4BODY_PARAM]; + }; + + struct reax_interaction + { + int num_atom_types; + global_parameters gp; + single_body_parameters *sbp; + two_body_parameters **tbp; + three_body_header ***thbp; + hbond_parameters ***hbp; + four_body_header ****fbp; + }; + + struct reax_atom + { + rc_tagint orig_id; + int type; + char name[8]; + + rvec x; // position + rvec v; // velocity + rvec f; // force + double q; // charge + + int Hindex; + int num_bonds; + int num_hbonds; + }; + + struct LR_lookup_table; // forward declaration + struct reax_system + { + reax_interaction reax_param; + + rc_bigint bigN; + int n, N, numH; + int local_cap, total_cap, Hcap; + int wsize, my_rank, num_nbrs; + reax_atom *my_atoms; + + LAMMPS_NS::Error *error_ptr; + LAMMPS_NS::Pair *pair_ptr; + LAMMPS_NS::Memory *mem_ptr; + + int my_bonds; + int mincap,minhbonds; + double safezone, saferzone; + + LR_lookup_table **LR; + + int omp_active; + }; + + /* system control parameters */ + struct control_params + { + int nthreads; + + double bond_cut; + double nonb_cut, nonb_low; + double hbond_cut; + + double bg_cut; + double bo_cut; + double thb_cut; + double thb_cutsq; + + int tabulate; + + int lgflag; + int enobondsflag; + LAMMPS_NS::Error *error_ptr; + LAMMPS_NS::LAMMPS *lmp_ptr; + int me; + }; + + struct energy_data + { + double e_bond; // Total bond energy + double e_ov; // Total over coordination + double e_un; // Total under coordination energy + double e_lp; // Total under coordination energy + double e_ang; // Total valance angle energy + double e_pen; // Total penalty energy + double e_coa; // Total three body conjgation energy + double e_hb; // Total Hydrogen bond energy + double e_tor; // Total torsional energy + double e_con; // Total four body conjugation energy + double e_vdW; // Total van der Waals energy + double e_ele; // Total electrostatics energy + double e_pol; // Polarization energy + }; + + struct simulation_data + { + rc_bigint step; + energy_data my_en; // per MPI rank energies + }; + + struct three_body_interaction_data + { + int thb; + int pthb; // pointer to the third body on the central atom's nbrlist + double theta, cos_theta; + rvec dcos_di, dcos_dj, dcos_dk; + }; + + struct far_neighbor_data { + int nbr; + ivec rel_box; + double d; + rvec dvec; + }; + + struct hbond_data { + int nbr; + int scl; + far_neighbor_data *ptr; + }; + + struct bond_order_data { + double BO, BO_s, BO_pi, BO_pi2; + double Cdbo, Cdbopi, Cdbopi2; + double C1dbo, C2dbo, C3dbo; + double C1dbopi, C2dbopi, C3dbopi, C4dbopi; + double C1dbopi2, C2dbopi2, C3dbopi2, C4dbopi2; + rvec dBOp, dln_BOp_s, dln_BOp_pi, dln_BOp_pi2; + double *CdboReduction; + }; + + struct bond_data { + int nbr; + int sym_index; + int dbond_index; + ivec rel_box; + double d; + rvec dvec; + bond_order_data bo_data; + }; + + struct sparse_matrix_entry { + int j; + double val; + }; + + struct sparse_matrix { + int cap, n, m; + int *start, *end; + sparse_matrix_entry *entries; + }; + + struct reallocate_data { + int num_far; + int H, Htop; + int hbonds, num_hbonds; + int bonds, num_bonds; + int num_3body; + }; + + struct storage + { + int allocated; + + /* bond order related storage */ + double *total_bond_order; + double *Deltap, *Deltap_boc; + double *Delta, *Delta_lp, *Delta_lp_temp, *Delta_e, *Delta_boc, *Delta_val; + double *dDelta_lp, *dDelta_lp_temp; + double *nlp, *nlp_temp, *Clp, *vlpex; + rvec *dDeltap_self; + int *bond_mark; + + /* Taper */ + double Tap[8]; //Tap7, Tap6, Tap5, Tap4, Tap3, Tap2, Tap1, Tap0; + + /* force calculations */ + double *CdDelta; // coefficient of dDelta + rvec *f; + + /* omp */ + rvec *forceReduction; + double *CdDeltaReduction; + int *valence_angle_atom_myoffset; + + reallocate_data realloc; + }; + + union list_type + { + three_body_interaction_data *three_body_list; + bond_data *bond_list; + far_neighbor_data *far_nbr_list; + hbond_data *hbond_list; + }; + + struct reax_list + { + int allocated; + + int n; + int num_intrs; + + int *index; + int *end_index; + + int type; + list_type select; + class LAMMPS_NS::Error *error_ptr; + }; + + struct LR_lookup_table + { + double xmin, xmax; + int n; + double dx, inv_dx; + double a; + double m; + double c; + + LR_data *y; + cubic_spline_coef *H; + cubic_spline_coef *vdW, *CEvd; + cubic_spline_coef *ele, *CEclmb; + }; +} + +#endif diff --git a/src/REAXFF/reaxff_valence_angles.cpp b/src/REAXFF/reaxff_valence_angles.cpp new file mode 100644 index 0000000000..ac3e2dbd1e --- /dev/null +++ b/src/REAXFF/reaxff_valence_angles.cpp @@ -0,0 +1,387 @@ +// clang-format off +/*---------------------------------------------------------------------- + PuReMD - Purdue ReaxFF Molecular Dynamics Program + + Copyright (2010) Purdue University + Hasan Metin Aktulga, hmaktulga@lbl.gov + Joseph Fogarty, jcfogart@mail.usf.edu + Sagar Pandit, pandit@usf.edu + Ananth Y Grama, ayg@cs.purdue.edu + + Please cite the related publication: + H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama, + "Parallel Reactive Molecular Dynamics: Numerical Methods and + Algorithmic Techniques", Parallel Computing, in press. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details: + . + ----------------------------------------------------------------------*/ + +#include "reaxff_api.h" + +#include + +#include "pair.h" +#include "error.h" + +namespace ReaxFF { + void Calculate_Theta(rvec dvec_ji, double d_ji, rvec dvec_jk, double d_jk, + double *theta, double *cos_theta) + { + (*cos_theta) = rvec_Dot(dvec_ji,dvec_jk) / (d_ji * d_jk); + if (*cos_theta > 1.) *cos_theta = 1.0; + if (*cos_theta < -1.) *cos_theta = -1.0; + + (*theta) = acos(*cos_theta); + } + + void Calculate_dCos_Theta(rvec dvec_ji, double d_ji, rvec dvec_jk, double d_jk, + rvec* dcos_theta_di, + rvec* dcos_theta_dj, + rvec* dcos_theta_dk) + { + int t; + double sqr_d_ji = SQR(d_ji); + double sqr_d_jk = SQR(d_jk); + double inv_dists = 1.0 / (d_ji * d_jk); + double inv_dists3 = CUBE(inv_dists); + double dot_dvecs = rvec_Dot(dvec_ji,dvec_jk); + double Cdot_inv3 = dot_dvecs * inv_dists3; + + for (t = 0; t < 3; ++t) { + (*dcos_theta_di)[t] = dvec_jk[t] * inv_dists - + Cdot_inv3 * sqr_d_jk * dvec_ji[t]; + (*dcos_theta_dj)[t] = -(dvec_jk[t] + dvec_ji[t]) * inv_dists + + Cdot_inv3 * (sqr_d_jk * dvec_ji[t] + sqr_d_ji * dvec_jk[t]); + (*dcos_theta_dk)[t] = dvec_ji[t] * inv_dists - + Cdot_inv3 * sqr_d_ji * dvec_jk[t]; + } + } + + + void Valence_Angles(reax_system *system, control_params *control, simulation_data *data, + storage *workspace, reax_list **lists) + { + int i, j, pi, k, pk, t; + int type_i, type_j, type_k; + int start_j, end_j, start_pk, end_pk; + int cnt, num_thb_intrs; + + double temp, temp_bo_jt, pBOjt7; + double p_val1, p_val2, p_val3, p_val4, p_val5; + double p_val6, p_val7, p_val8, p_val9, p_val10; + double p_pen1, p_pen2, p_pen3, p_pen4; + double p_coa1, p_coa2, p_coa3, p_coa4; + double trm8, expval6, expval7, expval2theta, expval12theta, exp3ij, exp3jk; + double exp_pen2ij, exp_pen2jk, exp_pen3, exp_pen4, trm_pen34, exp_coa2; + double dSBO1, dSBO2, SBO, SBO2, CSBO2, SBOp, prod_SBO, vlpadj; + double CEval1, CEval2, CEval3, CEval4, CEval5, CEval6, CEval7, CEval8; + double CEpen1, CEpen2, CEpen3; + double e_ang, e_coa, e_pen; + double CEcoa1, CEcoa2, CEcoa3, CEcoa4, CEcoa5; + double Cf7ij, Cf7jk, Cf8j, Cf9j; + double f7_ij, f7_jk, f8_Dj, f9_Dj; + double Ctheta_0, theta_0, theta_00, theta, cos_theta, sin_theta; + double BOA_ij, BOA_jk; + + // Tallying variables + double eng_tmp, fi_tmp[3], fj_tmp[3], fk_tmp[3]; + double delij[3], delkj[3]; + + three_body_header *thbh; + three_body_parameters *thbp; + three_body_interaction_data *p_ijk, *p_kji; + bond_data *pbond_ij, *pbond_jk, *pbond_jt; + bond_order_data *bo_ij, *bo_jk, *bo_jt; + reax_list *bonds = (*lists) + BONDS; + reax_list *thb_intrs = (*lists) + THREE_BODIES; + + /* global parameters used in these calculations */ + p_val6 = system->reax_param.gp.l[14]; + p_val8 = system->reax_param.gp.l[33]; + p_val9 = system->reax_param.gp.l[16]; + p_val10 = system->reax_param.gp.l[17]; + num_thb_intrs = 0; + + + for (j = 0; j < system->N; ++j) { + type_j = system->my_atoms[j].type; + if (type_j < 0) continue; + start_j = Start_Index(j, bonds); + end_j = End_Index(j, bonds); + + p_val3 = system->reax_param.sbp[type_j].p_val3; + p_val5 = system->reax_param.sbp[type_j].p_val5; + + SBOp = 0, prod_SBO = 1; + for (t = start_j; t < end_j; ++t) { + bo_jt = &(bonds->select.bond_list[t].bo_data); + SBOp += (bo_jt->BO_pi + bo_jt->BO_pi2); + temp = SQR(bo_jt->BO); + temp *= temp; + temp *= temp; + prod_SBO *= exp(-temp); + } + + if (workspace->vlpex[j] >= 0) { + vlpadj = 0; + dSBO2 = prod_SBO - 1; + } else { + vlpadj = workspace->nlp[j]; + dSBO2 = (prod_SBO - 1) * (1 - p_val8 * workspace->dDelta_lp[j]); + } + + SBO = SBOp + (1 - prod_SBO) * (-workspace->Delta_boc[j] - p_val8 * vlpadj); + dSBO1 = -8 * prod_SBO * (workspace->Delta_boc[j] + p_val8 * vlpadj); + + if (SBO <= 0) + SBO2 = 0, CSBO2 = 0; + else if (SBO > 0 && SBO <= 1) { + SBO2 = pow(SBO, p_val9); + CSBO2 = p_val9 * pow(SBO, p_val9 - 1); + } + else if (SBO > 1 && SBO < 2) { + SBO2 = 2 - pow(2-SBO, p_val9); + CSBO2 = p_val9 * pow(2 - SBO, p_val9 - 1); + } + else + SBO2 = 2, CSBO2 = 0; + + expval6 = exp(p_val6 * workspace->Delta_boc[j]); + + for (pi = start_j; pi < end_j; ++pi) { + Set_Start_Index(pi, num_thb_intrs, thb_intrs); + pbond_ij = &(bonds->select.bond_list[pi]); + bo_ij = &(pbond_ij->bo_data); + BOA_ij = bo_ij->BO - control->thb_cut; + + + if (BOA_ij/*bo_ij->BO*/ > 0.0 && + (j < system->n || pbond_ij->nbr < system->n)) { + i = pbond_ij->nbr; + type_i = system->my_atoms[i].type; + + for (pk = start_j; pk < pi; ++pk) { + start_pk = Start_Index(pk, thb_intrs); + end_pk = End_Index(pk, thb_intrs); + + for (t = start_pk; t < end_pk; ++t) + if (thb_intrs->select.three_body_list[t].thb == i) { + p_ijk = &(thb_intrs->select.three_body_list[num_thb_intrs]); + p_kji = &(thb_intrs->select.three_body_list[t]); + + p_ijk->thb = bonds->select.bond_list[pk].nbr; + p_ijk->pthb = pk; + p_ijk->theta = p_kji->theta; + rvec_Copy(p_ijk->dcos_di, p_kji->dcos_dk); + rvec_Copy(p_ijk->dcos_dj, p_kji->dcos_dj); + rvec_Copy(p_ijk->dcos_dk, p_kji->dcos_di); + + ++num_thb_intrs; + break; + } + } + + for (pk = pi+1; pk < end_j; ++pk) { + pbond_jk = &(bonds->select.bond_list[pk]); + bo_jk = &(pbond_jk->bo_data); + BOA_jk = bo_jk->BO - control->thb_cut; + k = pbond_jk->nbr; + type_k = system->my_atoms[k].type; + p_ijk = &(thb_intrs->select.three_body_list[num_thb_intrs]); + + Calculate_Theta(pbond_ij->dvec, pbond_ij->d, + pbond_jk->dvec, pbond_jk->d, + &theta, &cos_theta); + + Calculate_dCos_Theta(pbond_ij->dvec, pbond_ij->d, + pbond_jk->dvec, pbond_jk->d, + &(p_ijk->dcos_di), &(p_ijk->dcos_dj), + &(p_ijk->dcos_dk)); + p_ijk->thb = k; + p_ijk->pthb = pk; + p_ijk->theta = theta; + + sin_theta = sin(theta); + if (sin_theta < 1.0e-5) + sin_theta = 1.0e-5; + + ++num_thb_intrs; + + if ((j < system->n) && (BOA_jk > 0.0) && + (bo_ij->BO > control->thb_cut) && + (bo_jk->BO > control->thb_cut) && + (bo_ij->BO * bo_jk->BO > control->thb_cutsq)) { + thbh = &(system->reax_param.thbp[type_i][type_j][type_k]); + + for (cnt = 0; cnt < thbh->cnt; ++cnt) { + if (fabs(thbh->prm[cnt].p_val1) > 0.001) { + thbp = &(thbh->prm[cnt]); + + /* ANGLE ENERGY */ + p_val1 = thbp->p_val1; + p_val2 = thbp->p_val2; + p_val4 = thbp->p_val4; + p_val7 = thbp->p_val7; + theta_00 = thbp->theta_00; + + exp3ij = exp(-p_val3 * pow(BOA_ij, p_val4)); + f7_ij = 1.0 - exp3ij; + Cf7ij = p_val3 * p_val4 * pow(BOA_ij, p_val4 - 1.0) * exp3ij; + + exp3jk = exp(-p_val3 * pow(BOA_jk, p_val4)); + f7_jk = 1.0 - exp3jk; + Cf7jk = p_val3 * p_val4 * pow(BOA_jk, p_val4 - 1.0) * exp3jk; + + expval7 = exp(-p_val7 * workspace->Delta_boc[j]); + trm8 = 1.0 + expval6 + expval7; + f8_Dj = p_val5 - ((p_val5 - 1.0) * (2.0 + expval6) / trm8); + Cf8j = ((1.0 - p_val5) / SQR(trm8)) * + (p_val6 * expval6 * trm8 - + (2.0 + expval6) * (p_val6*expval6 - p_val7*expval7)); + + theta_0 = 180.0 - theta_00 * (1.0 - + exp(-p_val10 * (2.0 - SBO2))); + theta_0 = DEG2RAD(theta_0); + + expval2theta = exp(-p_val2 * SQR(theta_0 - theta)); + if (p_val1 >= 0) + expval12theta = p_val1 * (1.0 - expval2theta); + else // To avoid linear Me-H-Me angles (6/6/06) + expval12theta = p_val1 * -expval2theta; + + CEval1 = Cf7ij * f7_jk * f8_Dj * expval12theta; + CEval2 = Cf7jk * f7_ij * f8_Dj * expval12theta; + CEval3 = Cf8j * f7_ij * f7_jk * expval12theta; + CEval4 = -2.0 * p_val1 * p_val2 * f7_ij * f7_jk * f8_Dj * + expval2theta * (theta_0 - theta); + + Ctheta_0 = p_val10 * DEG2RAD(theta_00) * + exp(-p_val10 * (2.0 - SBO2)); + + CEval5 = -CEval4 * Ctheta_0 * CSBO2; + CEval6 = CEval5 * dSBO1; + CEval7 = CEval5 * dSBO2; + CEval8 = -CEval4 / sin_theta; + + data->my_en.e_ang += e_ang = + f7_ij * f7_jk * f8_Dj * expval12theta; + /* END ANGLE ENERGY*/ + + /* PENALTY ENERGY */ + p_pen1 = thbp->p_pen1; + p_pen2 = system->reax_param.gp.l[19]; + p_pen3 = system->reax_param.gp.l[20]; + p_pen4 = system->reax_param.gp.l[21]; + + exp_pen2ij = exp(-p_pen2 * SQR(BOA_ij - 2.0)); + exp_pen2jk = exp(-p_pen2 * SQR(BOA_jk - 2.0)); + exp_pen3 = exp(-p_pen3 * workspace->Delta[j]); + exp_pen4 = exp( p_pen4 * workspace->Delta[j]); + trm_pen34 = 1.0 + exp_pen3 + exp_pen4; + f9_Dj = (2.0 + exp_pen3) / trm_pen34; + Cf9j = (-p_pen3 * exp_pen3 * trm_pen34 - + (2.0 + exp_pen3) * (-p_pen3 * exp_pen3 + + p_pen4 * exp_pen4)) / + SQR(trm_pen34); + + data->my_en.e_pen += e_pen = + p_pen1 * f9_Dj * exp_pen2ij * exp_pen2jk; + + CEpen1 = e_pen * Cf9j / f9_Dj; + temp = -2.0 * p_pen2 * e_pen; + CEpen2 = temp * (BOA_ij - 2.0); + CEpen3 = temp * (BOA_jk - 2.0); + /* END PENALTY ENERGY */ + + /* COALITION ENERGY */ + p_coa1 = thbp->p_coa1; + p_coa2 = system->reax_param.gp.l[2]; + p_coa3 = system->reax_param.gp.l[38]; + p_coa4 = system->reax_param.gp.l[30]; + + exp_coa2 = exp(p_coa2 * workspace->Delta_val[j]); + data->my_en.e_coa += e_coa = + p_coa1 / (1. + exp_coa2) * + exp(-p_coa3 * SQR(workspace->total_bond_order[i]-BOA_ij)) * + exp(-p_coa3 * SQR(workspace->total_bond_order[k]-BOA_jk)) * + exp(-p_coa4 * SQR(BOA_ij - 1.5)) * + exp(-p_coa4 * SQR(BOA_jk - 1.5)); + + CEcoa1 = -2 * p_coa4 * (BOA_ij - 1.5) * e_coa; + CEcoa2 = -2 * p_coa4 * (BOA_jk - 1.5) * e_coa; + CEcoa3 = -p_coa2 * exp_coa2 * e_coa / (1 + exp_coa2); + CEcoa4 = -2 * p_coa3 * + (workspace->total_bond_order[i]-BOA_ij) * e_coa; + CEcoa5 = -2 * p_coa3 * + (workspace->total_bond_order[k]-BOA_jk) * e_coa; + /* END COALITION ENERGY */ + + /* FORCES */ + bo_ij->Cdbo += (CEval1 + CEpen2 + (CEcoa1 - CEcoa4)); + bo_jk->Cdbo += (CEval2 + CEpen3 + (CEcoa2 - CEcoa5)); + workspace->CdDelta[j] += ((CEval3 + CEval7) + CEpen1 + CEcoa3); + workspace->CdDelta[i] += CEcoa4; + workspace->CdDelta[k] += CEcoa5; + + for (t = start_j; t < end_j; ++t) { + pbond_jt = &(bonds->select.bond_list[t]); + bo_jt = &(pbond_jt->bo_data); + temp_bo_jt = bo_jt->BO; + temp = CUBE(temp_bo_jt); + pBOjt7 = temp * temp * temp_bo_jt; + + bo_jt->Cdbo += (CEval6 * pBOjt7); + bo_jt->Cdbopi += CEval5; + bo_jt->Cdbopi2 += CEval5; + } + + rvec_ScaledAdd(workspace->f[i], CEval8, p_ijk->dcos_di); + rvec_ScaledAdd(workspace->f[j], CEval8, p_ijk->dcos_dj); + rvec_ScaledAdd(workspace->f[k], CEval8, p_ijk->dcos_dk); + + /* tally energy */ + if (system->pair_ptr->eflag_either) { + eng_tmp = e_ang + e_pen + e_coa; + system->pair_ptr->ev_tally(j,j,system->N,1,eng_tmp,0.0,0.0,0.0,0.0,0.0); + } + + /* tally virial */ + if (system->pair_ptr->vflag_either) { + + /* Acquire vectors */ + rvec_ScaledSum(delij, 1., system->my_atoms[i].x, -1., system->my_atoms[j].x); + rvec_ScaledSum(delkj, 1., system->my_atoms[k].x, -1., system->my_atoms[j].x); + rvec_Scale(fi_tmp, -CEval8, p_ijk->dcos_di); + rvec_Scale(fj_tmp, -CEval8, p_ijk->dcos_dj); + rvec_Scale(fk_tmp, -CEval8, p_ijk->dcos_dk); + system->pair_ptr->v_tally3(i,j,k,fi_tmp,fk_tmp,delij,delkj); + } + } + } + } + } + } + + Set_End_Index(pi, num_thb_intrs, thb_intrs); + } + } + + if (num_thb_intrs >= thb_intrs->num_intrs * DANGER_ZONE) { + workspace->realloc.num_3body = num_thb_intrs; + if (num_thb_intrs > thb_intrs->num_intrs) + control->error_ptr->one(FLERR, fmt::format("step {}: ran out of space on " + "angle_list: top={}, max={}", + data->step, num_thb_intrs, + thb_intrs->num_intrs)); + } + } +} diff --git a/src/compute_pair.cpp b/src/compute_pair.cpp index a5bf54d5ef..7e1b6fc062 100644 --- a/src/compute_pair.cpp +++ b/src/compute_pair.cpp @@ -14,12 +14,13 @@ #include "compute_pair.h" -#include -#include -#include "update.h" +#include "error.h" #include "force.h" #include "pair.h" -#include "error.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; @@ -89,9 +90,9 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) : ComputePair::~ComputePair() { - delete [] pstyle; - delete [] one; - delete [] vector; + delete[] pstyle; + delete[] one; + delete[] vector; } /* ---------------------------------------------------------------------- */ diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index 02efba7e93..2d11a5a3bc 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -596,10 +596,13 @@ void CreateAtoms::command(int narg, char **arg) // print status MPI_Barrier(world); - if (me == 0) - utils::logmesg(lmp,"Created {} atoms\n" - " create_atoms CPU = {:.3f} seconds\n", - atom->natoms - natoms_previous, MPI_Wtime() - time1); + if (me == 0) { + utils::logmesg(lmp,"Created {} atoms\n", atom->natoms - natoms_previous); + if (scaleflag) domain->print_box(" using lattice units in "); + else domain->print_box(" using box units in "); + utils::logmesg(lmp," create_atoms CPU = {:.3f} seconds\n", + MPI_Wtime() - time1); + } } /* ---------------------------------------------------------------------- diff --git a/src/fix_external.cpp b/src/fix_external.cpp index 8bede4ee19..f95c30c28d 100644 --- a/src/fix_external.cpp +++ b/src/fix_external.cpp @@ -15,6 +15,7 @@ #include "fix_external.h" #include "atom.h" +#include "comm.h" #include "error.h" #include "memory.h" #include "update.h" @@ -80,7 +81,7 @@ FixExternal::~FixExternal() atom->delete_callback(id,Atom::GROW); memory->destroy(fexternal); - delete [] caller_vector; + delete[] caller_vector; } /* ---------------------------------------------------------------------- */ @@ -163,6 +164,12 @@ void FixExternal::post_force(int vflag) f[i][1] += fexternal[i][1]; f[i][2] += fexternal[i][2]; } + + // add contribution to global virial from previously stored value + + if (vflag_global) + for (int i = 0; i < 6; ++i) + virial[i] = user_virial[i]; } } @@ -179,10 +186,13 @@ void FixExternal::min_post_force(int vflag) /* ---------------------------------------------------------------------- caller invokes this method to set its contribution to global energy + this is the *total* energy across all MPI ranks of the external code + and must be set for all MPI ranks. unlike other energy/virial set methods: do not just return if eflag_global is not set b/c input script could access this quantity via compute_scalar() even if eflag is not set on a particular timestep + this function is compatible with CALLBACK and ARRAY mode ------------------------------------------------------------------------- */ void FixExternal::set_energy_global(double caller_energy) @@ -191,24 +201,32 @@ void FixExternal::set_energy_global(double caller_energy) } /* ---------------------------------------------------------------------- - caller invokes this method to set its contribution to global virial + caller invokes this method to set its contribution to the global virial + for all MPI ranks. the virial value is the *total* contribution across + all MPI ranks of the external code and thus we need to divide by the + number of MPI ranks since the tallying code expects per MPI rank contributions. + this function is compatible with PF_CALLBACK and PF_ARRAY mode ------------------------------------------------------------------------- */ void FixExternal::set_virial_global(double *caller_virial) { - if (!vflag_global) return; - + const double npscale = 1.0/(double)comm->nprocs; for (int i = 0; i < 6; i++) - virial[i] = caller_virial[i]; + user_virial[i] = npscale * caller_virial[i]; } /* ---------------------------------------------------------------------- - caller invokes this method to set its contribution to peratom energy + caller invokes this method to set its contribution to peratom energy. + this is applied to the *local* atoms only. + this function is compatible with PF_CALLBACK mode only since it tallies + its energy contributions directly into the accumulator arrays. ------------------------------------------------------------------------- */ void FixExternal::set_energy_peratom(double *caller_energy) { if (!eflag_atom) return; + if ((mode == PF_ARRAY) && (comm->me == 0)) + error->warning(FLERR,"Can only set energy/atom for fix external in pf/callback mode"); int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) @@ -217,6 +235,9 @@ void FixExternal::set_energy_peratom(double *caller_energy) /* ---------------------------------------------------------------------- caller invokes this method to set its contribution to peratom virial + this is applied to the *local* atoms only. + this function is compatible with PF_CALLBACK mode only since it tallies + its virial contributions directly into the accumulator arrays. ------------------------------------------------------------------------- */ void FixExternal::set_virial_peratom(double **caller_virial) @@ -224,6 +245,8 @@ void FixExternal::set_virial_peratom(double **caller_virial) int i,j; if (!vflag_atom) return; + if ((mode == PF_ARRAY) && (comm->me == 0)) + error->warning(FLERR,"Can only set virial/atom for fix external in pf/callback mode"); int nlocal = atom->nlocal; for (i = 0; i < nlocal; i++) @@ -232,13 +255,13 @@ void FixExternal::set_virial_peratom(double **caller_virial) } /* ---------------------------------------------------------------------- - caller invokes this method to set length of vector of values - assume all vector values are extensive, could make this an option + caller invokes this method to set length of global vector of values + assume all vector values are extensive. ------------------------------------------------------------------------- */ void FixExternal::set_vector_length(int n) { - delete [] caller_vector; + delete[] caller_vector; vector_flag = 1; size_vector = n; @@ -248,14 +271,15 @@ void FixExternal::set_vector_length(int n) } /* ---------------------------------------------------------------------- - caller invokes this method to set Index value in vector - index ranges from 1 to N inclusive + caller invokes this method to set value for item at "index" in vector + index is 1-based, thus index ranges from 1 to N inclusively. + Must be called from all MPI ranks. ------------------------------------------------------------------------- */ void FixExternal::set_vector(int index, double value) { - if (index >= size_vector) - error->all(FLERR,"Invalid set_vector index in fix external"); + if (index > size_vector) + error->all(FLERR,"Invalid set_vector index ({} of {}) in fix external",index,size_vector); caller_vector[index-1] = value; } @@ -286,6 +310,7 @@ double FixExternal::compute_vector(int n) double FixExternal::memory_usage() { double bytes = 3*atom->nmax * sizeof(double); + bytes += 6*sizeof(double); return bytes; } @@ -342,3 +367,16 @@ void FixExternal::set_callback(FnPtr caller_callback, void *caller_ptr) callback = caller_callback; ptr_caller = caller_ptr; } + +/* ---------------------------------------------------------------------- + get access to internal data structures +------------------------------------------------------------------------- */ + +void *FixExternal::extract(const char *str, int &dim) +{ + if (strcmp(str, "fexternal") == 0) { + dim = 2; + return (void *) fexternal; + } + return nullptr; +} diff --git a/src/fix_external.h b/src/fix_external.h index 0ace978f99..16db5d5015 100644 --- a/src/fix_external.h +++ b/src/fix_external.h @@ -57,11 +57,14 @@ class FixExternal : public Fix { typedef void (*FnPtr)(void *, bigint, int, tagint *, double **, double **); void set_callback(FnPtr, void *); + void *extract(const char *, int &); + private: int mode, ncall, napply, eflag_caller; FnPtr callback; void *ptr_caller; double user_energy; + double user_virial[6]; double *caller_vector; }; diff --git a/src/library.cpp b/src/library.cpp index d4a82489f0..4847c705af 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -4804,15 +4804,49 @@ void lammps_decode_image_flags(imageint image, int *flags) flags[2] = (image >> IMG2BITS) - IMGMAX; } -/* ---------------------------------------------------------------------- - find fix external with given ID and set the callback function - and caller pointer -------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- */ -void lammps_set_fix_external_callback(void *handle, char *id, FixExternalFnPtr callback_ptr, void * caller) +/** Set up the callback function for a fix external instance with the given ID. + +\verbatim embed:rst + +Fix :doc:`external ` allows programs that are running LAMMPS through +its library interface to modify certain LAMMPS properties on specific +timesteps, similar to the way other fixes do. + +This function sets the callback function for use with the "pf/callback" +mode. The function has to have C language bindings with the prototype: + +.. code-block:: c + + void func(void *ptr, bigint timestep, int nlocal, tagint *ids, double **x, double **fexternal); + +The argument *ptr* to this function will be stored in fix external and +the passed as the first argument calling the callback function `func()`. +This would usually be a pointer to the active LAMMPS instance, i.e. the same +pointer as the *handle* argument. This would be needed to call +functions that set the global or per-atom energy or virial contributions +from within the callback function. + +The callback mechanism is one of the two modes of how forces and can be +applied to a simulation with the help of fix external. The alternative +is the array mode where you call :cpp:func:`lammps_fix_external_get_force`. + +Please see the documentation for :doc:`fix external ` for +more information about how to use the fix and how to couple it with an +external code. + +\endverbatim + * + * \param handle pointer to a previously created LAMMPS instance cast to ``void *``. + * \param id fix ID of fix external instance + * \param funcptr pointer to callback function + * \param ptr pointer to object in calling code, passed to callback function as first argument */ + +void lammps_set_fix_external_callback(void *handle, const char *id, FixExternalFnPtr funcptr, void *ptr) { LAMMPS *lmp = (LAMMPS *) handle; - FixExternal::FnPtr callback = (FixExternal::FnPtr) callback_ptr; + FixExternal::FnPtr callback = (FixExternal::FnPtr) funcptr; BEGIN_CAPTURE { @@ -4823,18 +4857,103 @@ void lammps_set_fix_external_callback(void *handle, char *id, FixExternalFnPtr c Fix *fix = lmp->modify->fix[ifix]; if (strcmp("external",fix->style) != 0) - lmp->error->all(FLERR,"Fix '{}' is not of style " - "external!", id); + lmp->error->all(FLERR,"Fix '{}' is not of style 'external'", id); - FixExternal * fext = (FixExternal*) fix; - fext->set_callback(callback, caller); + FixExternal *fext = (FixExternal *) fix; + fext->set_callback(callback, ptr); } END_CAPTURE } -/* set global energy contribution from fix external */ -void lammps_fix_external_set_energy_global(void *handle, char *id, - double energy) +/** Get pointer to the force array storage in a fix external instance with the given ID. + +\verbatim embed:rst + +Fix :doc:`external ` allows programs that are running LAMMPS through +its library interface to add or modify certain LAMMPS properties on specific +timesteps, similar to the way other fixes do. + +This function provides access to the per-atom force storage in a fix +external instance with the given fix-ID to be added to the individual +atoms when using the "pf/array" mode. The *fexternal* array can be +accessed like other "native" per-atom arrays accessible via the +:cpp:func:`lammps_extract_atom` function. Please note that the array +stores holds the forces for *local* atoms for each MPI ranks, in the +order determined by the neighbor list build. Because the underlying +data structures can change as well as the order of atom as they migrate +between MPI processes because of the domain decomposition +parallelization, this function should be always called immediately +before the forces are going to be set to get an up-to-date pointer. + You can use e.g. :cpp:func:`lammps_get_natoms` to obtain the number +of local atoms `nlocal` and then assume the dimensions of the returned +force array as ``double force[nlocal][3]``. + +This is an alternative to the callback mechanism in fix external set up by +:cpp:func:`lammps_set_fix_external_callback`. The main difference is +that this mechanism can be used when forces are be pre-computed and the +control alternates between LAMMPS and the external code, while the +callback mechanism can call the external code to compute the force when +the fix is triggered and needs them. + +Please see the documentation for :doc:`fix external ` for +more information about how to use the fix and how to couple it with an +external code. + +\endverbatim + * + * \param handle pointer to a previously created LAMMPS instance cast to ``void *``. + * \param id fix ID of fix external instance + * \return a pointer to the per-atom force array allocated by the fix */ + +double **lammps_fix_external_get_force(void *handle, const char *id) +{ + LAMMPS *lmp = (LAMMPS *) handle; + double **fexternal = nullptr; + + BEGIN_CAPTURE + { + int ifix = lmp->modify->find_fix(id); + if (ifix < 0) + lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id); + + Fix *fix = lmp->modify->fix[ifix]; + + if (strcmp("external",fix->style) != 0) + lmp->error->all(FLERR,"Fix '{}' is not of style external!", id); + + fexternal = (double **)fix->extract("fexternal",ifix); + } + END_CAPTURE + return fexternal; +} + +/** Set the global energy contribution for a fix external instance with the given ID. + +\verbatim embed:rst + +This is a companion function to :cpp:func:`lammps_set_fix_external_callback` and +:cpp:func:`lammps_fix_external_get_force` to also set the contribution +to the global energy from the external code. The value of the *eng* +argument will be stored in the fix and applied on the current and all +following timesteps until changed by another call to this function. +The energy is in energy units as determined by the current :doc:`units ` +settings and is the **total** energy of the contribution. Thus when +running in parallel all MPI processes have to call this function with +the **same** value and this will be returned as scalar property of the +fix external instance when accessed in LAMMPS input commands or from +variables. + +Please see the documentation for :doc:`fix external ` for +more information about how to use the fix and how to couple it with an +external code. + +\endverbatim + * + * \param handle pointer to a previously created LAMMPS instance cast to ``void *``. + * \param id fix ID of fix external instance + * \param eng total energy to be added to the global energy */ + +void lammps_fix_external_set_energy_global(void *handle, const char *id, double eng) { LAMMPS *lmp = (LAMMPS *) handle; @@ -4849,15 +4968,41 @@ void lammps_fix_external_set_energy_global(void *handle, char *id, if (strcmp("external",fix->style) != 0) lmp->error->all(FLERR,"Fix '{}' is not of style external!", id); - FixExternal * fext = (FixExternal*) fix; - fext->set_energy_global(energy); + FixExternal *fext = (FixExternal*) fix; + fext->set_energy_global(eng); } END_CAPTURE } -/* set global virial contribution from fix external */ -void lammps_fix_external_set_virial_global(void *handle, char *id, - double *virial) +/** Set the global virial contribution for a fix external instance with the given ID. + +\verbatim embed:rst + +This is a companion function to :cpp:func:`lammps_set_fix_external_callback` +and :cpp:func:`lammps_fix_external_get_force` to set the contribution to +the global virial from the external code. + +The 6 values of the *virial* array will be stored in the fix and applied +on the current and all following timesteps until changed by another call +to this function. The components of the virial need to be stored in the +order: *xx*, *yy*, *zz*, *xy*, *xz*, *yz*. In LAMMPS the virial is +stored internally as `stress*volume` in units of `pressure*volume` as +determined by the current :doc:`units ` settings and is the +**total** contribution. Thus when running in parallel all MPI processes +have to call this function with the **same** value and this will then +be added by fix external. + +Please see the documentation for :doc:`fix external ` for +more information about how to use the fix and how to couple it with an +external code. + +\endverbatim + * + * \param handle pointer to a previously created LAMMPS instance cast to ``void *``. + * \param id fix ID of fix external instance + * \param virial the 6 global stress tensor components to be added to the global virial */ + +void lammps_fix_external_set_virial_global(void *handle, const char *id, double *virial) { LAMMPS *lmp = (LAMMPS *) handle; @@ -4878,6 +5023,207 @@ void lammps_fix_external_set_virial_global(void *handle, char *id, END_CAPTURE } +/** Set the per-atom energy contribution for a fix external instance with the given ID. + +\verbatim embed:rst + +This is a companion function to :cpp:func:`lammps_set_fix_external_callback` +to set the per-atom energy contribution due to the fix from the external code +as part of the callback function. For this to work, the handle to the +LAMMPS object must be passed as the *ptr* argument when registering the +callback function. + +.. note:: + + This function is fully independent from :cpp:func:`lammps_fix_external_set_energy_global` + and will **NOT** add any contributions to the global energy tally + and **NOT** check whether the sum of the contributions added here are + consistent with the global added energy. + + +Please see the documentation for :doc:`fix external ` for +more information about how to use the fix and how to couple it with an +external code. + +\endverbatim + * + * \param handle pointer to a previously created LAMMPS instance cast to ``void *``. + * \param id fix ID of fix external instance + * \param eng pointer to array of length nlocal with the energy to be added to the per-atom energy */ + +void lammps_fix_external_set_energy_peratom(void *handle, const char *id, double *eng) +{ + LAMMPS *lmp = (LAMMPS *) handle; + + BEGIN_CAPTURE + { + int ifix = lmp->modify->find_fix(id); + if (ifix < 0) + lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id); + + Fix *fix = lmp->modify->fix[ifix]; + + if (strcmp("external",fix->style) != 0) + lmp->error->all(FLERR,"Fix '{}' is not of style external!", id); + + FixExternal *fext = (FixExternal*) fix; + fext->set_energy_peratom(eng); + } + END_CAPTURE +} + +/** Set the per-atom virial contribution for a fix external instance with the given ID. + +\verbatim embed:rst + +This is a companion function to :cpp:func:`lammps_set_fix_external_callback` +to set the per-atom virial contribution due to the fix from the external code +as part of the callback function. For this to work, the handle to the +LAMMPS object must be passed as the *ptr* argument when registering the +callback function. + +.. note:: + + This function is fully independent from :cpp:func:`lammps_fix_external_set_virial_global` + and will **NOT** add any contributions to the global virial tally + and **NOT** check whether the sum of the contributions added here are + consistent with the global added virial. + +The order and units of the per-atom stress tensor elements are the same +as for the global virial. The code in fix external assumes the +dimensions of the per-atom virial array is ``double virial[nlocal][6]``. + +Please see the documentation for :doc:`fix external ` for +more information about how to use the fix and how to couple it with an +external code. + +\endverbatim + * + * \param handle pointer to a previously created LAMMPS instance cast to ``void *``. + * \param id fix ID of fix external instance + * \param virial a list of nlocal entries with the 6 per-atom stress tensor components to be added to the per-atom virial */ + +void lammps_fix_external_set_virial_peratom(void *handle, const char *id, double **virial) +{ + LAMMPS *lmp = (LAMMPS *) handle; + + BEGIN_CAPTURE + { + int ifix = lmp->modify->find_fix(id); + if (ifix < 0) + lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id); + + Fix *fix = lmp->modify->fix[ifix]; + + if (strcmp("external",fix->style) != 0) + lmp->error->all(FLERR,"Fix '{}' is not of style external!", id); + + FixExternal * fext = (FixExternal*) fix; + fext->set_virial_peratom(virial); + } + END_CAPTURE +} + +/** Set the vector length for a global vector stored with fix external for analysis + +\verbatim embed:rst + +This is a companion function to :cpp:func:`lammps_set_fix_external_callback` and +:cpp:func:`lammps_fix_external_get_force` to set the length of a global vector of +properties that will be stored with the fix via +:cpp:func:`lammps_fix_external_set_vector`. + +This function needs to be called **before** a call to +:cpp:func:`lammps_fix_external_set_vector` and **before** a run or minimize +command. When running in parallel it must be called from **all** MPI +processes and with the same length parameter. + +Please see the documentation for :doc:`fix external ` for +more information about how to use the fix and how to couple it with an +external code. + +\endverbatim + * + * \param handle pointer to a previously created LAMMPS instance cast to ``void *``. + * \param id fix ID of fix external instance + * \param len length of the global vector to be stored with the fix */ + +void lammps_fix_external_set_vector_length(void *handle, const char *id, int len) +{ + LAMMPS *lmp = (LAMMPS *) handle; + + BEGIN_CAPTURE + { + int ifix = lmp->modify->find_fix(id); + if (ifix < 0) + lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id); + + Fix *fix = lmp->modify->fix[ifix]; + + if (strcmp("external",fix->style) != 0) + lmp->error->all(FLERR,"Fix '{}' is not of style external!", id); + + FixExternal *fext = (FixExternal*) fix; + fext->set_vector_length(len); + } + END_CAPTURE +} + +/** Store a global vector value for a fix external instance with the given ID. + +\verbatim embed:rst + +This is a companion function to :cpp:func:`lammps_set_fix_external_callback` and +:cpp:func:`lammps_fix_external_get_force` to set the values of a global vector of +properties that will be stored with the fix. And can be accessed from +within LAMMPS input commands (e.g. fix ave/time or variables) when used +in a vector context. + +This function needs to be called **after** a call to +:cpp:func:`lammps_fix_external_set_vector_length` and the and **before** a run or minimize +command. When running in parallel it must be called from **all** MPI +processes and with the **same** index and value parameters. The value +is assumed to be extensive. + +.. note:: + + The index in the *idx* parameter is 1-based, i.e. the first element + is set with idx = 1 and the last element of the vector with idx = N, + where N is the value of the *len* parameter of the call to + :cpp:func:`lammps_fix_external_set_vector_length`. + +Please see the documentation for :doc:`fix external ` for +more information about how to use the fix and how to couple it with an +external code. + +\endverbatim + * + * \param handle pointer to a previously created LAMMPS instance cast to ``void *``. + * \param id fix ID of fix external instance + * \param idx 1-based index of in global vector + * \param val value to be stored in global vector */ + +void lammps_fix_external_set_vector(void *handle, const char *id, int idx, double val) +{ + LAMMPS *lmp = (LAMMPS *) handle; + + BEGIN_CAPTURE + { + int ifix = lmp->modify->find_fix(id); + if (ifix < 0) + lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id); + + Fix *fix = lmp->modify->fix[ifix]; + + if (strcmp("external",fix->style) != 0) + lmp->error->all(FLERR,"Fix '{}' is not of style external!", id); + + FixExternal * fext = (FixExternal*) fix; + fext->set_vector(idx, val); + } + END_CAPTURE +} + /* ---------------------------------------------------------------------- */ /** Free memory buffer allocated by LAMMPS. diff --git a/src/library.h b/src/library.h index a337d7b510..654eda38fa 100644 --- a/src/library.h +++ b/src/library.h @@ -226,16 +226,21 @@ void lammps_decode_image_flags(int64_t image, int *flags); #if defined(LAMMPS_BIGBIG) typedef void (*FixExternalFnPtr)(void *, int64_t, int, int64_t *, double **, double **); -void lammps_set_fix_external_callback(void *, char *, FixExternalFnPtr, void *); +void lammps_set_fix_external_callback(void *handle, const char *id, FixExternalFnPtr funcptr, void *ptr); #elif defined(LAMMPS_SMALLBIG) typedef void (*FixExternalFnPtr)(void *, int64_t, int, int *, double **, double **); -void lammps_set_fix_external_callback(void *, char *, FixExternalFnPtr, void *); +void lammps_set_fix_external_callback(void *, const char *, FixExternalFnPtr, void *); #else typedef void (*FixExternalFnPtr)(void *, int, int, int *, double **, double **); -void lammps_set_fix_external_callback(void *, char *, FixExternalFnPtr, void *); +void lammps_set_fix_external_callback(void *, const char *, FixExternalFnPtr, void *); #endif -void lammps_fix_external_set_energy_global(void *, char *, double); -void lammps_fix_external_set_virial_global(void *, char *, double *); +double **lammps_fix_external_get_force(void *handle, const char *id); +void lammps_fix_external_set_energy_global(void *handle, const char *id, double eng); +void lammps_fix_external_set_energy_peratom(void *handle, const char *id, double *eng); +void lammps_fix_external_set_virial_global(void *handle, const char *id, double *virial); +void lammps_fix_external_set_virial_peratom(void *handle, const char *id, double **virial); +void lammps_fix_external_set_vector_length(void *handle, const char *id, int len); +void lammps_fix_external_set_vector(void *handle, const char *id, int idx, double val); void lammps_free(void *ptr); diff --git a/src/pair.cpp b/src/pair.cpp index 5e8c666743..38c7922c17 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -991,7 +991,7 @@ void Pair::ev_unset() } /* ---------------------------------------------------------------------- - tally eng_vdwl and virial into global and per-atom accumulators + tally eng_vdwl and virial into global or per-atom accumulators need i < nlocal test since called by bond_quartic and dihedral_charmm ------------------------------------------------------------------------- */ @@ -1092,7 +1092,7 @@ void Pair::ev_tally(int i, int j, int nlocal, int newton_pair, } /* ---------------------------------------------------------------------- - tally eng_vdwl and virial into global and per-atom accumulators + tally eng_vdwl and virial into global or per-atom accumulators can use this version with full neighbor lists ------------------------------------------------------------------------- */ @@ -1138,7 +1138,7 @@ void Pair::ev_tally_full(int i, double evdwl, double ecoul, double fpair, } /* ---------------------------------------------------------------------- - tally eng_vdwl and virial into global and per-atom accumulators + tally eng_vdwl and virial into global or per-atom accumulators for virial, have delx,dely,delz and fx,fy,fz ------------------------------------------------------------------------- */ @@ -1232,7 +1232,7 @@ void Pair::ev_tally_xyz(int i, int j, int nlocal, int newton_pair, } /* ---------------------------------------------------------------------- - tally eng_vdwl and virial into global and per-atom accumulators + tally eng_vdwl and virial into global or per-atom accumulators for virial, have delx,dely,delz and fx,fy,fz called when using full neighbor lists ------------------------------------------------------------------------- */ @@ -1285,7 +1285,7 @@ void Pair::ev_tally_xyz_full(int i, double evdwl, double ecoul, } /* ---------------------------------------------------------------------- - tally eng_vdwl and virial into global and per-atom accumulators + tally eng_vdwl and virial into global or per-atom accumulators called by SW and hbond potentials, newton_pair is always on virial = riFi + rjFj + rkFk = (rj-ri) Fj + (rk-ri) Fk = drji*fj + drki*fk ------------------------------------------------------------------------- */ @@ -1342,7 +1342,7 @@ void Pair::ev_tally3(int i, int j, int k, double evdwl, double ecoul, } /* ---------------------------------------------------------------------- - tally eng_vdwl and virial into global and per-atom accumulators + tally eng_vdwl and virial into global or per-atom accumulators called by AIREBO potential, newton_pair is always on ------------------------------------------------------------------------- */ @@ -1487,28 +1487,40 @@ void Pair::ev_tally_tip4p(int key, int *list, double *v, } /* ---------------------------------------------------------------------- - tally virial into per-atom accumulators - called by REAX/C potential, newton_pair is always on - fi is magnitude of force on atom i + tally virial into global or per-atom accumulators + called by ReaxFF potential, newton_pair is always on + fi is magnitude of force on atom i, deli is the direction + note that the other atom (j) is not updated, due to newton on ------------------------------------------------------------------------- */ -void Pair::v_tally(int i, double *fi, double *deli) +void Pair::v_tally2_newton(int i, double *fi, double *deli) { double v[6]; - v[0] = 0.5*deli[0]*fi[0]; - v[1] = 0.5*deli[1]*fi[1]; - v[2] = 0.5*deli[2]*fi[2]; - v[3] = 0.5*deli[0]*fi[1]; - v[4] = 0.5*deli[0]*fi[2]; - v[5] = 0.5*deli[1]*fi[2]; + v[0] = deli[0]*fi[0]; + v[1] = deli[1]*fi[1]; + v[2] = deli[2]*fi[2]; + v[3] = deli[0]*fi[1]; + v[4] = deli[0]*fi[2]; + v[5] = deli[1]*fi[2]; - vatom[i][0] += v[0]; vatom[i][1] += v[1]; vatom[i][2] += v[2]; - vatom[i][3] += v[3]; vatom[i][4] += v[4]; vatom[i][5] += v[5]; + if (vflag_global) { + virial[0] += v[0]; + virial[1] += v[1]; + virial[2] += v[2]; + virial[3] += v[3]; + virial[4] += v[4]; + virial[5] += v[5]; + } + + if (vflag_atom) { + vatom[i][0] += v[0]; vatom[i][1] += v[1]; vatom[i][2] += v[2]; + vatom[i][3] += v[3]; vatom[i][4] += v[4]; vatom[i][5] += v[5]; + } } /* ---------------------------------------------------------------------- - tally virial into per-atom accumulators + tally virial into global or per-atom accumulators called by AIREBO potential, newton_pair is always on fpair is magnitude of force on atom I ------------------------------------------------------------------------- */ @@ -1549,7 +1561,7 @@ void Pair::v_tally2(int i, int j, double fpair, double *drij) /* ---------------------------------------------------------------------- tally virial into per-atom accumulators - called by AIREBO and Tersoff potential, newton_pair is always on + called by AIREBO and Tersoff potentials, newton_pair is always on ------------------------------------------------------------------------- */ void Pair::v_tally3(int i, int j, int k, double *fi, double *fj, double *drik, double *drjk) @@ -1589,8 +1601,8 @@ void Pair::v_tally3(int i, int j, int k, double *fi, double *fj, double *drik, d } /* ---------------------------------------------------------------------- - tally virial into per-atom accumulators - called by AIREBO potential, newton_pair is always on + tally virial into global or per-atom accumulators + called by AIREBO potential, Tersoff, ReaxFF potentials, newton_pair is always on ------------------------------------------------------------------------- */ void Pair::v_tally4(int i, int j, int k, int m, @@ -1634,7 +1646,7 @@ void Pair::v_tally4(int i, int j, int k, int m, } /* ---------------------------------------------------------------------- - tally virial into global and per-atom accumulators + tally virial into global or per-atom accumulators called by pair lubricate potential with 6 tensor components ------------------------------------------------------------------------- */ diff --git a/src/pair.h b/src/pair.h index 80d4fc11d1..c4a5d3678c 100644 --- a/src/pair.h +++ b/src/pair.h @@ -28,6 +28,8 @@ class Pair : protected Pointers { friend class FixGPU; friend class FixIntel; friend class FixOMP; + friend class FixQEq; + friend class PairHybrid; friend class ThrOMP; friend class Info; @@ -135,9 +137,9 @@ class Pair : protected Pointers { // need to be public, so can be called by pair_style reaxc - void v_tally(int, double *, double *); void ev_tally(int, int, int, int, double, double, double, double, double, double); void ev_tally3(int, int, int, double, double, double *, double *, double *, double *); + void v_tally2_newton(int, double *, double *); void v_tally3(int, int, int, double *, double *, double *, double *); void v_tally4(int, int, int, int, double *, double *, double *, double *, double *, double *); void ev_tally_xyz(int, int, int, int, double, double, double, double, double, double, double, diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 881e234df0..8f97451347 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -979,9 +979,7 @@ void PairHybrid::modify_special(int m, int /*narg*/, char **arg) special[2] = utils::numeric(FLERR,arg[2],false,lmp); special[3] = utils::numeric(FLERR,arg[3],false,lmp); - // have to cast to PairHybrid to work around C++ access restriction - - if (((PairHybrid *)styles[m])->suffix_flag & (Suffix::INTEL|Suffix::GPU)) + if (styles[m]->suffix_flag & (Suffix::INTEL|Suffix::GPU)) error->all(FLERR,"Pair_modify special is not compatible with " "suffix version of hybrid substyle"); diff --git a/tools/README b/tools/README index 0f6f36e78a..eb329e27cd 100644 --- a/tools/README +++ b/tools/README @@ -43,7 +43,6 @@ phonon post-process output of the fix phonon command polybond Python tool for programmable polymer bonding pymol_asphere convert LAMMPS output of ellipsoids to PyMol format python Python scripts for post-processing LAMMPS output -reax Tools for analyzing output of ReaxFF simulations replica tool to reorder LAMMPS replica trajectories according to temperature singularity Singularity container descriptions suitable for LAMMPS development smd convert Smooth Mach Dynamics triangles to VTK diff --git a/tools/offline/scripts/init_http_cache.sh b/tools/offline/scripts/init_http_cache.sh index 9bda6cdaa5..55856bbf21 100755 --- a/tools/offline/scripts/init_http_cache.sh +++ b/tools/offline/scripts/init_http_cache.sh @@ -40,26 +40,26 @@ echo "Dowloading thirdparty tarballs..." MPICH2_WIN64_DEVEL_URL="${LAMMPS_THIRDPARTY_URL}/mpich2-win64-devel.tar.gz" MPICH2_WIN32_DEVEL_URL="${LAMMPS_THIRDPARTY_URL}/mpich2-win32-devel.tar.gz" VORO_URL="${LAMMPS_THIRDPARTY_URL}/voro++-0.4.6.tar.gz" -OPENCL_LOADER_URL="${LAMMPS_THIRDPARTY_URL}/opencl-loader-2020.12.18.tar.gz" +OPENCL_LOADER_URL="${LAMMPS_THIRDPARTY_URL}/opencl-loader-2021.06.30.tar.gz" SCAFACOS_FIX_URL="${LAMMPS_THIRDPARTY_URL}/scafacos-1.0.1-fix.diff" GTEST_URL="https://github.com/google/googletest/archive/release-1.10.0.tar.gz" YAML_URL="https://pyyaml.org/download/libyaml/yaml-0.2.5.tar.gz" -MATHJAX_URL="https://github.com/mathjax/MathJax/archive/3.1.2.tar.gz" +MATHJAX_URL="https://github.com/mathjax/MathJax/archive/3.1.3.tar.gz" EIGEN3_URL="https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz" CUB_URL="https://github.com/NVlabs/cub/archive/1.12.0.tar.gz" -KOKKOS_URL="https://github.com/kokkos/kokkos/archive/3.3.01.tar.gz" +KOKKOS_URL="https://github.com/kokkos/kokkos/archive/3.4.01.tar.gz" KIM_URL="https://s3.openkim.org/kim-api/kim-api-2.2.1.txz" MSCG_URL="https://github.com/uchicago-voth/MSCG-release/archive/1.7.3.1.tar.gz" -PLUMED_URL="https://github.com/plumed/plumed2/releases/download/v2.7.0/plumed-src-2.7.0.tgz" +PLUMED_URL="https://github.com/plumed/plumed2/releases/download/v2.7.1/plumed-src-2.7.1.tgz" PACELIB_URL="https://github.com/ICAMS/lammps-user-pace/archive/refs/tags/v.2021.4.9.tar.gz" LATTE_URL="https://github.com/lanl/LATTE/archive/v1.2.2.tar.gz" SCAFACOS_URL="https://github.com/scafacos/scafacos/releases/download/v1.0.1/scafacos-1.0.1.tar.gz" MDI_URL="https://github.com/MolSSI-MDI/MDI_Library/archive/v1.2.9.tar.gz" GTEST_FILENAME="gtest-1.10.0.tar.gz" -MATHJAX_FILENAME="mathjax-3.1.2.tar.gz" +MATHJAX_FILENAME="mathjax-3.1.3.tar.gz" CUB_FILENAME="cub-1.12.0.tar.gz" -KOKKOS_FILENAME="kokkos-3.3.01.tar.gz" +KOKKOS_FILENAME="kokkos-3.4.01.tar.gz" MSCG_FILENAME="mscg-1.7.3.1.tar.gz" LATTE_FILENAME="latte-1.2.2.tar.gz" PACELIB_FILENAME="pacelib-2021.4.9.tar.gz" diff --git a/tools/offline/scripts/update_downloads.sh b/tools/offline/scripts/update_downloads.sh new file mode 100755 index 0000000000..247b92e562 --- /dev/null +++ b/tools/offline/scripts/update_downloads.sh @@ -0,0 +1,25 @@ +#!/bin/bash +#helper script to update URLs from CMake folder + +CMAKE_FOLDER=../../../cmake + +function extract_setting() +{ + export $1=$(grep -Rh "set($1" ../../../cmake/ | cut -d\" -f2) +} + +function update_setting() +{ + echo Setting $1 to $2 + sed -i "/^$1=/c$1=\"$2\"" init_http_cache.sh +} + + +URLS=$(grep -Rh "_URL=" init_http_cache.sh | grep -v ^LAMMPS | grep -v SCAFACOS_FIX | cut -d= -f1) + +# update URLs by grabbing the latest ones from cmake files +for URL in $URLS +do + extract_setting "$URL" + update_setting "$URL" ${!URL} +done diff --git a/tools/reax/Cutoff.dic b/tools/reax/Cutoff.dic deleted file mode 100644 index 7c52b74468..0000000000 --- a/tools/reax/Cutoff.dic +++ /dev/null @@ -1,14 +0,0 @@ -# Interesting name. This file contains -# the bond-order cut off for each -# pair of ReaxFF elements -C N 0.3 -C C 0.55 -C O 0.65 -C H 0.4 -O O 0.65 -N O 0.40 -O H 0.4 -H H 0.55 -H N 0.55 -N N 0.55 -# diff --git a/tools/reax/README.txt b/tools/reax/README.txt deleted file mode 100644 index 3c9fe4506b..0000000000 --- a/tools/reax/README.txt +++ /dev/null @@ -1,10 +0,0 @@ -=== ReaxFF tools === -=============================== - -The programs in this folder can be used to analyze the -output of simulations using the ReaxFF potentials; - -reaxc_bond.pl: reads the bonding information in the - .trj file produced by pair_style reax/c and - outputs molecule counts for each frame. - diff --git a/tools/reax/reaxc_bond.pl b/tools/reax/reaxc_bond.pl deleted file mode 100755 index cc0fd8f238..0000000000 --- a/tools/reax/reaxc_bond.pl +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/perl -use Getopt::Long; -Getopt::Long::Configure ('bundling'); - -################################################################# -# # -# This script is designed to take the bond information from a # -# Lammps/reaxc *.trj file and output a molecular fraction file # -# for each frame. # -# # -# written by Mike Russo, PSU # -# modified by Aidan Thompson, 5/12/2011 # -# # -# The required .trj file is generated by running LAMMPS # -# with pair_style reax/c and the following settings in # -# the corresponding reax/c control file # -# write_freq 25 ! write trajectory after so many steps -# traj_compress 0 ! 0: no compression 1: uses zlib to compress trajectory output -# traj_title TATB ! (no white spaces) -# atom_info 0 ! 0: no atom info, 1: print basic atom info in the trajectory file -# atom_forces 0 ! 0: basic atom format, 1: print force on each atom in the trajectory file -# atom_velocities 0 ! 0: basic atom format, 1: print the velocity of each atom in the trajectory file -# bond_info 1 ! 0: do not print bonds, 1: print bonds in the trajectory file -# angle_info 0 ! 0: do not print angles, 1: print angles in the trajectory file -# # -################################################################# - -################################################################# -# Setting up some default variables, and options for the user # -# to input. # -################################################################# -$in_file = "bonds.trj"; -@test = qw(C H O N); -GetOptions ('f|file=s' => \$in_file, 'a|atoms=s' => \@atoms, 'h|help' => \$help); -if($help) { - print "Options for this program:\n-f --file for input file default= bonds.trj\n-a --atoms atom types (in correct order and input separately) default= @test\n"; - exit; -} -open INPUT, "<$in_file" or die "Cannot open $in_file: $!"; -open OUTPUT, ">frac.dat" or die "Cannot open output file: $!"; - -if(@atoms) { - @test = @atoms; -} - -print "Input for this run:\n Input file = $in_file\n Atom types = @test\n"; -################################################################# - -################################################################# -# Main loop of the script. Goes through each frames bond list. # -################################################################# -$i = 0; -$section = 0; -$at_count = -1; -while() { - if(/chars_to_skip_section/) { - $section++; - &bonds if($section > 2); - next; - } - next if($section <= 0); #skipping the header section - next if(/\s*[A-Za-z]/); #skip text lines - - split; - if ($section == 1) { - $q = $_[0]; - $temp = $_[1]; - $q--; - $at_type[$q] = $temp; - next; - } - - $_[0]--; - $_[1]--; -# Add i-j and j-i entries - push @{$list[$_[0]]}, $_[1]; - push @{$list[$_[1]]}, $_[0]; - $at_count++ if($section == 2); -} -$section++; -&bonds; -close(INPUT); -################################################################# - -################################################################# -# Subroutine bonds: Uses the bond information to generate a # -# count for each species, put them into molecules, and then # -# count the number of each molecule type. # -################################################################# -sub bonds { - $flag = (); - $k = 0; - for(0..$#list) { - if($flag[$_] == 0) { - push @{$full_list[$k]}, $_; - foreach $atom (@{$full_list[$k]}) { - for($o = 0; $o <= $#{$list[$atom]}; $o++) { - unless(grep /^$list[$atom][$o]$/, @{$full_list[$k]}) { - push @{$full_list[$k]}, $list[$atom][$o]; - $flag[$list[$atom][$o]] = 1; - } - } - } - } else { - next; - } - $k++; - } - -### Output section ### - $frame = $section - 2; - open OUTPUT2, ">temp_$frame.dat" or die "Cannot open temp file: $!"; - print OUTPUT2 "Frame # $frame\n"; - for($m = 0; $m < $k; $m++) { #cycle through each molecule - foreach $atom ((@{$full_list[$m]})) { #for each atom in this molecule - ${"$test[$at_type[$atom]]"} += 1; #Create variable named C,H,O, etc and set it to count - } - print OUTPUT2 "Mol $m = "; - foreach $atom (@test) { - print OUTPUT2 "$atom${$atom}" if(${$atom} > 0); - } - print OUTPUT2 "\n"; - for($r = 0; $r <= $#test; $r++) { - ${"$test[$r]"} = 0; - } - } - - close (OUTPUT2); #close the temp file as output - open INPUT3, ") { - next if(/Frame/); - split; - push @mol_list, $_[3] unless(grep /^$_[3]$/, @mol_list); - ${"$_[3]"}++; - } - print OUTPUT "Frame # $frame\n"; - foreach $mol (@mol_list) { - printf OUTPUT "%4d %s\n", ${"$mol"}, $mol; - ${"$mol"} = 0; - } - @mol_list = (); -### - -### Cleanup between frames ### - for(0..$at_count) { - @{$full_list[$_]} = (); - @{$list[$_]} = (); - } -### -} -################################################################# - diff --git a/tools/swig/lammps.i b/tools/swig/lammps.i index 56547dda53..5bf47f2463 100644 --- a/tools/swig/lammps.i +++ b/tools/swig/lammps.i @@ -128,16 +128,27 @@ extern int lammps_id_name(void *, const char *, int, char *buffer, int buf_si extern int lammps_plugin_count(); extern int lammps_plugin_name(int, char *, char *, int); /* -extern int lammps_encode_image_flags(int ix, int iy, int iz); -extern void lammps_decode_image_flags(int image, int *flags); -extern int64_t lammps_encode_image_flags(int ix, int iy, int iz); -extern void lammps_decode_image_flags(int64_t image, int *flags); -extern void lammps_set_fix_external_callback(void *, char *, FixExternalFnPtr, void*); -extern void lammps_set_fix_external_callback(void *, char *, FixExternalFnPtr, void*); -extern void lammps_set_fix_external_callback(void *, char *, FixExternalFnPtr, void*); -extern void lammps_fix_external_set_energy_global(void *, char *, double); -extern void lammps_fix_external_set_virial_global(void *, char *, double *); + * Have not found a good way to map these functions in a general way. + * So some individual customization for the specific use case and compilation is needed. + * + extern int lammps_encode_image_flags(int ix, int iy, int iz); + extern void lammps_decode_image_flags(int image, int *flags); + extern int64_t lammps_encode_image_flags(int ix, int iy, int iz); + extern void lammps_decode_image_flags(int64_t image, int *flags); + + * Supporting the fix external callback mechanism will require extra code specific to the application. + typedef void (*FixExternalFnPtr)(void *, int64_t, int, int64_t *, double **, double **); + extern void lammps_set_fix_external_callback(void *handle, const char *id, FixExternalFnPtr funcptr, void *ptr); + * these two functions can only be used from the callback, so we don't support them either + extern void lammps_fix_external_set_energy_peratom(void *handle, const char *id, double *eng); + extern void lammps_fix_external_set_virial_peratom(void *handle, const char *id, double **virial); */ +extern double **lammps_fix_external_get_force(void *handle, const char *id); +extern void lammps_fix_external_set_energy_global(void *handle, const char *id, double eng); +extern void lammps_fix_external_set_virial_global(void *handle, const char *id, double *virial); +extern void lammps_fix_external_set_vector_length(void *handle, const char *id, int len); +extern void lammps_fix_external_set_vector(void *handle, const char *id, int idx, double val); + extern void lammps_free(void *ptr); extern int lammps_is_running(void *handle); extern void lammps_force_timeout(void *handle); @@ -255,16 +266,21 @@ extern int lammps_encode_image_flags(int ix, int iy, int iz); extern void lammps_decode_image_flags(int image, int *flags); extern int64_t lammps_encode_image_flags(int ix, int iy, int iz); extern void lammps_decode_image_flags(int64_t image, int *flags); -extern void lammps_set_fix_external_callback(void *, char *, FixExternalFnPtr, void*); -extern void lammps_set_fix_external_callback(void *, char *, FixExternalFnPtr, void*); -extern void lammps_set_fix_external_callback(void *, char *, FixExternalFnPtr, void*); -extern void lammps_fix_external_set_energy_global(void *, char *, double); -extern void lammps_fix_external_set_virial_global(void *, char *, double *); +typedef void (*FixExternalFnPtr)(void *, int64_t, int, int64_t *, double **, double **); +extern void lammps_set_fix_external_callback(void *handle, const char *id, FixExternalFnPtr funcptr, void *ptr); +extern void lammps_fix_external_set_energy_peratom(void *handle, const char *id, double *eng); +extern void lammps_fix_external_set_virial_peratom(void *handle, const char *id, double **virial); */ +extern double **lammps_fix_external_get_force(void *handle, const char *id); +extern void lammps_fix_external_set_energy_global(void *handle, const char *id, double eng); +extern void lammps_fix_external_set_virial_global(void *handle, const char *id, double *virial); +extern void lammps_fix_external_set_vector_length(void *handle, const char *id, int len); +extern void lammps_fix_external_set_vector(void *handle, const char *id, int idx, double val); + extern void lammps_free(void *ptr); extern int lammps_is_running(void *handle); extern void lammps_force_timeout(void *handle); extern int lammps_has_error(void *handle); extern int lammps_get_last_error_message(void *handle, char *buffer, int buf_size); -/* last revised for LAMMPS 8 April 2021 */ +/* last revised on 21 July 2021 */ diff --git a/unittest/c-library/CMakeLists.txt b/unittest/c-library/CMakeLists.txt index 3c24cdcff4..b01cd64677 100644 --- a/unittest/c-library/CMakeLists.txt +++ b/unittest/c-library/CMakeLists.txt @@ -7,6 +7,10 @@ add_executable(test_library_commands test_library_commands.cpp test_main.cpp) target_link_libraries(test_library_commands PRIVATE lammps GTest::GTest GTest::GMock) add_test(LibraryCommands test_library_commands) +add_executable(test_library_external test_library_external.cpp test_main.cpp) +target_link_libraries(test_library_external PRIVATE lammps GTest::GTest GTest::GMock) +add_test(LibraryExternal test_library_external) + add_executable(test_library_properties test_library_properties.cpp test_main.cpp) target_link_libraries(test_library_properties PRIVATE lammps GTest::GTest GTest::GMock) target_compile_definitions(test_library_properties PRIVATE -DTEST_INPUT_FOLDER=${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/unittest/c-library/test_library_external.cpp b/unittest/c-library/test_library_external.cpp new file mode 100644 index 0000000000..005b31fcab --- /dev/null +++ b/unittest/c-library/test_library_external.cpp @@ -0,0 +1,200 @@ +// unit tests creating LAMMPS instances via the library interface + +#include "library.h" + +#include +#include + +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include "test_main.h" + +using ::testing::HasSubstr; +using ::testing::StartsWith; + +extern "C" { +#ifdef LAMMPS_SMALLSMALL +typedef int32_t step_t; +typedef int32_t tag_t; +#elif LAMMPS_SMALLBIG +typedef int64_t step_t; +typedef int32_t tag_t; +#else +typedef int64_t step_t; +typedef int64_t tag_t; +#endif +static void callback(void *handle, step_t timestep, int nlocal, tag_t *, double **, double **f) +{ + for (int i = 0; i < nlocal; ++i) + f[i][0] = f[i][1] = f[i][2] = (double)timestep; + + double v[6] = {1.0, 1.0, 1.0, 0.0, 0.0, 0.0}; + lammps_fix_external_set_virial_global(handle, "ext", v); + if (timestep < 10) { + lammps_fix_external_set_energy_global(handle, "ext", 0.5); + lammps_fix_external_set_vector(handle, "ext", 1, timestep); + lammps_fix_external_set_vector(handle, "ext", 3, 1.0); + lammps_fix_external_set_vector(handle, "ext", 4, -0.25); + } else { + lammps_fix_external_set_energy_global(handle, "ext", 1.0); + lammps_fix_external_set_vector(handle, "ext", 2, timestep); + lammps_fix_external_set_vector(handle, "ext", 5, -1.0); + lammps_fix_external_set_vector(handle, "ext", 6, 0.25); + } + double *eatom = new double[nlocal]; + double **vatom = new double *[nlocal]; + vatom[0] = new double[nlocal * 6]; + eatom[0] = 0.0; + vatom[0][0] = vatom[0][1] = vatom[0][2] = vatom[0][3] = vatom[0][4] = vatom[0][5] = 0.0; + + for (int i = 1; i < nlocal; ++i) { + eatom[i] = 0.1 * i; + vatom[i] = vatom[0] + 6 * i; + vatom[i][0] = vatom[i][1] = vatom[i][2] = 0.1; + vatom[i][3] = vatom[i][4] = vatom[i][5] = -0.2; + } + lammps_fix_external_set_energy_peratom(handle, "ext", eatom); + lammps_fix_external_set_virial_peratom(handle, "ext", vatom); + delete[] eatom; + delete[] vatom[0]; + delete[] vatom; +} +} + +TEST(lammps_external, callback) +{ + const char *args[] = {"liblammps", "-log", "none", "-nocite"}; + char **argv = (char **)args; + int argc = sizeof(args) / sizeof(char *); + + ::testing::internal::CaptureStdout(); + void *handle = lammps_open_no_mpi(argc, argv, NULL); + std::string output = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << output; + + ::testing::internal::CaptureStdout(); + lammps_commands_string(handle, "lattice sc 1.0\n" + "region box block -1 1 -1 1 -1 1\n" + "create_box 1 box\n" + "create_atoms 1 box\n" + "mass 1 1.0\n" + "pair_style zero 0.1\n" + "pair_coeff 1 1\n" + "velocity all set 0.1 0.0 -0.1\n" + "fix 1 all nve\n" + "fix ext all external pf/callback 5 1\n" + "compute eatm all pe/atom fix\n" + "compute vatm all stress/atom NULL fix\n" + "compute sum all reduce sum c_eatm c_vatm[*]\n" + "thermo_style custom step temp pe ke etotal press c_sum[*]\n" + "thermo 5\n" + "fix_modify ext energy yes virial yes\n"); + lammps_fix_external_set_vector_length(handle, "ext", 6); + output = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << output; + + ::testing::internal::CaptureStdout(); + lammps_set_fix_external_callback(handle, "ext", &callback, handle); + lammps_command(handle, "run 10 post no"); + double temp = lammps_get_thermo(handle, "temp"); + double pe = lammps_get_thermo(handle, "pe"); + double press = lammps_get_thermo(handle, "press"); + double val = 0.0; + double *valp; + for (int i = 0; i < 6; ++i) { + valp = (double *)lammps_extract_fix(handle, "ext", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR, i, 0); + val += *valp; + lammps_free(valp); + } + double *reduce = + (double *)lammps_extract_compute(handle, "sum", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); + output = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << output; + EXPECT_DOUBLE_EQ(temp, 1.0 / 30.0); + EXPECT_DOUBLE_EQ(pe, 1.0 / 8.0); + EXPECT_DOUBLE_EQ(press, 0.15416666666666667); + EXPECT_DOUBLE_EQ(val, 15); + EXPECT_DOUBLE_EQ(reduce[0], 2.8); + EXPECT_DOUBLE_EQ(reduce[1], -0.7); + EXPECT_DOUBLE_EQ(reduce[2], -0.7); + EXPECT_DOUBLE_EQ(reduce[3], -0.7); + EXPECT_DOUBLE_EQ(reduce[4], 1.4); + EXPECT_DOUBLE_EQ(reduce[5], 1.4); + EXPECT_DOUBLE_EQ(reduce[6], 1.4); + + ::testing::internal::CaptureStdout(); + lammps_close(handle); + output = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << output; +} + +TEST(lammps_external, array) +{ + const char *args[] = {"liblammps", "-log", "none", "-nocite"}; + char **argv = (char **)args; + int argc = sizeof(args) / sizeof(char *); + + ::testing::internal::CaptureStdout(); + void *handle = lammps_open_no_mpi(argc, argv, NULL); + std::string output = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << output; + + ::testing::internal::CaptureStdout(); + lammps_commands_string(handle, "lattice sc 1.0\n" + "region box block -1 1 -1 1 -1 1\n" + "create_box 1 box\n" + "create_atoms 1 box\n" + "mass 1 1.0\n" + "pair_style zero 0.1\n" + "pair_coeff 1 1\n" + "velocity all set 0.1 0.0 -0.1\n" + "fix 1 all nve\n" + "fix ext all external pf/array 1\n" + "thermo 5\n"); + + output = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << output; + + ::testing::internal::CaptureStdout(); + double **force = lammps_fix_external_get_force(handle, "ext"); + int nlocal = lammps_extract_setting(handle, "nlocal"); + for (int i = 0; i < nlocal; ++i) + force[i][0] = force[i][1] = force[i][2] = 0.0; + lammps_fix_external_set_energy_global(handle, "ext", 0.5); + double v[6] = {0.5, 0.5, 0.5, 0.0, 0.0, 0.0}; + lammps_fix_external_set_virial_global(handle, "ext", v); + lammps_command(handle, "run 5 post no"); + double temp = lammps_get_thermo(handle, "temp"); + double pe = lammps_get_thermo(handle, "pe"); + double press = lammps_get_thermo(handle, "press"); + output = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << output; + EXPECT_DOUBLE_EQ(temp, 4.0 / 525.0); + EXPECT_DOUBLE_EQ(pe, 1.0 / 16.0); + EXPECT_DOUBLE_EQ(press, 0.069166666666666668); + + ::testing::internal::CaptureStdout(); + nlocal = lammps_extract_setting(handle, "nlocal"); + force = lammps_fix_external_get_force(handle, "ext"); + for (int i = 0; i < nlocal; ++i) + force[i][0] = force[i][1] = force[i][2] = 6.0; + lammps_fix_external_set_energy_global(handle, "ext", 1.0); + v[0] = v[1] = v[2] = 1.0; + v[3] = v[4] = v[5] = 0.0; + lammps_fix_external_set_virial_global(handle, "ext", v); + lammps_command(handle, "run 5 post no"); + temp = lammps_get_thermo(handle, "temp"); + pe = lammps_get_thermo(handle, "pe"); + press = lammps_get_thermo(handle, "press"); + output = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << output; + EXPECT_DOUBLE_EQ(temp, 1.0 / 30.0); + EXPECT_DOUBLE_EQ(pe, 1.0 / 8.0); + EXPECT_DOUBLE_EQ(press, 0.15416666666666667); + + ::testing::internal::CaptureStdout(); + lammps_close(handle); + output = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << output; +} diff --git a/unittest/commands/test_groups.cpp b/unittest/commands/test_groups.cpp index 51bbf63228..f938de3467 100644 --- a/unittest/commands/test_groups.cpp +++ b/unittest/commands/test_groups.cpp @@ -245,7 +245,7 @@ TEST_F(GroupTest, Molecular) ASSERT_EQ(group->count(group->find("three")), 15); ASSERT_DOUBLE_EQ(group->mass(group->find("half")), 40); ASSERT_DOUBLE_EQ(group->mass(group->find("half"), domain->find_region("top")), 10); - ASSERT_DOUBLE_EQ(group->charge(group->find("top")), 0); + ASSERT_NEAR(group->charge(group->find("top")), 0,1.0e-14); ASSERT_DOUBLE_EQ(group->charge(group->find("right"), domain->find_region("top")), 0); TEST_FAILURE(".*ERROR: Illegal group command.*", command("group three include xxx");); diff --git a/unittest/force-styles/test_pair_style.cpp b/unittest/force-styles/test_pair_style.cpp index b0221cf56e..23858f93b9 100644 --- a/unittest/force-styles/test_pair_style.cpp +++ b/unittest/force-styles/test_pair_style.cpp @@ -524,8 +524,7 @@ TEST(PairStyle, plain) if (print_stats) std::cerr << "restart_energy stats:" << stats << std::endl; // pair style rann does not support pair_modify nofdotr - // temporarily disable testing pair style reax/c until we merge the other fixes - if ((test_config.pair_style != "rann") && !(test_config.pair_style.find("reax") != std::string::npos)) { + if (test_config.pair_style != "rann") { if (!verbose) ::testing::internal::CaptureStdout(); restart_lammps(lmp, test_config, true); if (!verbose) ::testing::internal::GetCapturedStdout(); @@ -1297,21 +1296,6 @@ TEST(PairStyle, single) GTEST_SKIP(); } - // The single function in EAM is different from what we assume - // here, therefore we have to skip testing those pair styles. - // Pair styles colloid and yukawa/colloid are also not compatible with this single tester - if ((test_config.pair_style.substr(0, 7) == "colloid") || - (test_config.pair_style.substr(0, 14) == "yukawa/colloid") || - (test_config.pair_style.substr(0, 3) == "dpd") || - (test_config.pair_style.substr(0, 3) == "eam") || - ((test_config.pair_style.substr(0, 6) == "hybrid") && - (test_config.pair_style.find("eam") != std::string::npos))) { - if (!verbose) ::testing::internal::CaptureStdout(); - cleanup_lammps(lmp, test_config); - if (!verbose) ::testing::internal::GetCapturedStdout(); - GTEST_SKIP(); - } - // now start over if (!verbose) ::testing::internal::CaptureStdout(); diff --git a/unittest/force-styles/tests/atomic-pair-buck_coul_cut_qeq_point.yaml b/unittest/force-styles/tests/atomic-pair-buck_coul_cut_qeq_point.yaml new file mode 100644 index 0000000000..d3e6b38980 --- /dev/null +++ b/unittest/force-styles/tests/atomic-pair-buck_coul_cut_qeq_point.yaml @@ -0,0 +1,175 @@ +--- +lammps_version: 8 Apr 2021 +date_generated: Tue Apr 20 14:47:51 2021 +epsilon: 7.5e-13 +skip_tests: intel single +prerequisites: ! | + pair buck/coul/cut + fix qeq/point +pre_commands: ! | + echo screen + variable newton_pair delete + variable newton_pair index on + atom_modify map array + units metal + atom_style charge + lattice diamond 3.77 + region box block 0 2 0 2 0 2 + create_box 2 box + create_atoms 1 box + displace_atoms all random 0.1 0.1 0.1 623426 + mass 1 28.0 + mass 2 16.0 + set type 1 type/fraction 2 0.666667 998877 + set type 1 charge 0.8 + set type 2 charge 0.4 + velocity all create 100 4534624 loop geom +post_commands: ! | + fix qeq all qeq/point 1 6.0 1.0e-20 20 ${input_dir}/param.qeq2 warn no +input_file: in.empty +pair_style: buck/coul/cut 6.0 +pair_coeff: ! | + 1 1 0.0 0.1 00 + 1 2 18003.0 0.2052124 133.5381 + 2 2 1388.77 0.3623188 175.0 +extract: ! "" +natoms: 64 +init_vdwl: 106.41860675757 +init_coul: -129.9140700924124 +init_stress: ! |- + -2.8069812877025680e+02 -4.4806768911794171e+02 -5.0378472147221044e+02 3.9357896002405380e+02 -4.6782123097483543e+02 1.9690042286173212e+02 +init_forces: ! |2 + 1 7.9125122896296922e+00 -2.1014839690852849e+00 1.0994080971957654e+01 + 2 -8.6188789139298905e+00 -1.8333074427098923e+00 6.9043233196778493e+00 + 3 7.8498612200411868e+00 -2.1754399089581845e+01 -2.8862198492435933e+00 + 4 6.0059474900265855e+00 2.0200604615492711e+01 -3.6502720655785064e+00 + 5 -1.0414088486908696e+01 -1.2032673161543727e+01 -8.1683250459138641e+00 + 6 2.4526971509997360e+00 1.6151940503875748e+00 3.9699353225387135e+00 + 7 1.1484521325651471e+01 2.6251346011917382e+00 -5.0509149729671243e-01 + 8 -8.6634039445313658e+00 -8.3084485039834881e+00 3.9070922142448175e+00 + 9 7.9495750681929742e+00 -9.0507972374486361e+00 -4.4437699190231843e+00 + 10 -1.1184211738488107e+01 -2.0985043628368132e+00 8.0230797778549956e+00 + 11 2.8166289803609963e+01 -2.6396601038400636e+01 -7.0398077372607645e+01 + 12 1.8384817166363799e+01 4.9304421068745743e+00 -1.8773815008331542e+01 + 13 -8.5901832560112172e+00 -1.1830174021232128e+01 1.0687567118271307e+01 + 14 -2.7556923264654802e+00 1.7745847764979608e+00 -9.2066420206368988e+00 + 15 4.6735302548764643e+00 -3.2709618690940427e+00 -2.0693142194244816e+00 + 16 -6.0547965516444906e+00 -2.2600378957272116e+00 3.2677368381468008e-01 + 17 -9.1378380656225406e+00 1.1908878845184031e+01 -1.7535407559841292e+00 + 18 -1.2710024935571287e+00 -1.8390249623807247e+00 -5.0661022351703764e+00 + 19 4.7508234682845059e+00 -4.7660218202653398e-01 1.9578845982916517e+00 + 20 -2.4044494501312546e+00 1.3188349248766018e+01 -4.2723195450669484e+00 + 21 2.5545939677742822e+00 -7.6599926401155196e+00 -1.9913355105865760e+00 + 22 -1.2721065348405212e+01 2.2605336717084196e+01 -4.7468563523008402e+00 + 23 2.4611421112071081e+00 -1.4649327715865049e-01 3.5863258472083799e+00 + 24 -4.3893602786163104e+00 2.1969519282498890e+01 4.4720052177174487e+00 + 25 2.0238917888202160e+01 -1.5707849435118018e+01 5.7119813878581205e+00 + 26 -1.2244546012542273e+01 8.7637388770168165e+00 1.1554289778536326e+01 + 27 2.6315583772500917e+00 5.2366381109035203e+00 5.6567854473912291e+00 + 28 1.6069342319200945e+01 2.2379145739762505e+00 1.2146106338402367e+01 + 29 1.6156898389873891e+01 -1.3554238523505591e+01 -9.1896135574796052e+00 + 30 -8.4056006337974853e+00 7.0469844075145707e+00 6.3110771274676658e+00 + 31 -1.3273848195602289e-01 -6.8307139969335129e+00 7.6340671688916251e-01 + 32 -3.5499992242635152e+01 1.6857356356036899e+01 5.1954595281751772e+01 + 33 -1.5976858206617210e+01 -2.1986638912202295e+01 1.5916728791281200e+01 + 34 9.9892552480335084e+00 2.4910832782965171e+00 -3.5317186985424054e+00 + 35 7.0710369156676450e+01 -3.5579041343629925e+01 -5.3907803084513858e+01 + 36 -5.7367330604749455e+01 -7.0169041999492791e+01 7.3977418913261829e+01 + 37 5.5359814356241074e+01 7.2104773934571938e+01 -6.4062698737301162e+01 + 38 7.3137814516005992e+00 -6.9993845661823428e+00 -4.9786686785484031e+00 + 39 2.1766057858052013e+00 2.6649010324053237e+00 -5.5648981412947700e+00 + 40 -8.6278470191715790e+00 -6.1938287573923239e+00 -5.3007116622920181e-01 + 41 -2.1876614204878253e+00 -4.9711482834141876e+00 2.1023653625053651e+00 + 42 6.7356638591944380e+00 2.3811284335916083e+00 -2.6936658473425106e+00 + 43 -4.8166095077507318e+00 9.0096363628437235e+00 -3.5021097239659325e+00 + 44 4.5856314854049890e-01 -6.4502158514658676e+00 -2.2547412879230078e+00 + 45 -1.4050653828419732e+00 -2.7741840518241623e-01 5.9455907460299153e+00 + 46 1.7068092414266975e+00 3.0134108012937979e+00 -7.3633262984858643e+00 + 47 -8.5993680232001868e+00 3.9482405710461826e-02 -7.4020141073315715e-01 + 48 -1.4797111864775530e+02 9.0978008317055270e+01 8.8422607641864516e+01 + 49 1.2110838856400735e+01 1.0210083421020201e+01 -1.7064250014241885e+01 + 50 1.5673894480674800e+01 4.2472425008217618e+00 2.3874134866435037e-01 + 51 -1.0755978881146193e+03 9.4584826950708475e+02 -1.2161507490133176e+03 + 52 1.5238648316158450e+01 -1.4713914840395454e+01 1.0700180235730782e+01 + 53 1.0832818442423763e+03 -9.4512225095469830e+02 1.2182464933546009e+03 + 54 -1.2715521453452059e+00 1.0003156043833941e+00 -4.7435368103541586e+00 + 55 -1.2828505786775382e+01 2.4021051786462557e+01 -1.1214232355595612e+01 + 56 -7.6186543306062049e+01 2.6038364737554620e+01 4.6298155917897482e+01 + 57 1.0443716577117205e+02 3.6009056789261075e+02 2.1380802968687473e+02 + 58 -9.1275826241798370e+00 -1.3245000554098924e+01 -8.7148296348715926e-01 + 59 1.2840492718836813e+02 -1.0559491971264805e+02 -6.6237876488606588e+01 + 60 -2.1677737255323635e+00 -1.1892793887650410e+00 -8.1033360541735249e+00 + 61 -1.2148578617098147e+02 -3.5657463872647236e+02 -2.0401151842776562e+02 + 62 -2.7445863145191973e+00 1.2181869352734287e+01 6.0139221094528885e+00 + 63 -7.8700771372090834e+00 -3.1538926482273300e+00 1.0493868436023858e+01 + 64 2.5378792969187284e+01 3.2092052615283109e+01 -1.6443232536994536e+01 +run_vdwl: -1745.867185907274 +run_coul: -134.07506093090166 +run_stress: ! |- + -4.5872997550021264e+03 -3.9988755027842894e+03 -6.1188498400678936e+03 4.1760773642646591e+03 -5.3312812896810128e+03 4.4665905499115461e+03 +run_forces: ! |2 + 1 7.9285352946497758e+00 -2.1027294435031489e+00 1.1086825816163195e+01 + 2 -8.5419611035054892e+00 -1.8545741670495524e+00 7.0079173935199286e+00 + 3 8.4201002043041484e+00 -2.3236585201563706e+01 -3.5619050765611897e+00 + 4 5.8244272716577141e+00 2.0336700262604413e+01 -3.7991301665341801e+00 + 5 -1.0597147068623588e+01 -1.2052626644608324e+01 -8.3616620515931093e+00 + 6 2.3454925059969298e+00 1.9423650844033959e+00 4.1282352821875090e+00 + 7 1.1498130683730052e+01 2.7037305516932548e+00 -4.3590618591979624e-01 + 8 -8.7055079862119680e+00 -8.2080543611619063e+00 3.8502610802694401e+00 + 9 7.8905280043672006e+00 -9.1748249725951716e+00 -4.3595650830599473e+00 + 10 -1.1214544607539489e+01 -2.0450291190922241e+00 8.0819592940862215e+00 + 11 3.1110360595812111e+01 -3.0379448305557091e+01 -8.0086245459647699e+01 + 12 1.8159177163415904e+01 4.8329111811515117e+00 -1.8760362770452407e+01 + 13 -8.3967367015110703e+00 -1.1826424656028374e+01 1.0490586963619998e+01 + 14 -2.7403143901237863e+00 1.5146525228727186e+00 -9.5102191320553011e+00 + 15 4.6084095676492058e+00 -3.2455057110391716e+00 -2.0076394841639451e+00 + 16 -5.9971213141367166e+00 -2.1400797487747161e+00 3.8635660450105780e-01 + 17 -9.2777494354866672e+00 1.1929670372837402e+01 -1.5781112010078653e+00 + 18 -1.2640996234737609e+00 -1.8706861715670353e+00 -5.0907920358459542e+00 + 19 4.7710267464485367e+00 -4.0988795718884213e-01 1.9972858346581028e+00 + 20 -2.2378279249288067e+00 1.3107343895216937e+01 -4.2428037955197233e+00 + 21 2.5289893324335391e+00 -7.6558240340245325e+00 -1.9069419539704020e+00 + 22 -1.2728255711560161e+01 2.2449803210470662e+01 -4.4375794812338860e+00 + 23 2.2126988647283259e+00 -1.9107846463909647e-01 3.6978572940177510e+00 + 24 -4.9407746531577494e+00 2.3427146491434673e+01 5.0673415871481255e+00 + 25 2.0382651093146954e+01 -1.5777195827352591e+01 5.8844240401473211e+00 + 26 -1.2179841258863439e+01 8.7610073871936400e+00 1.1530406923973768e+01 + 27 2.6588676610969855e+00 5.1896378052166741e+00 5.6387483053555902e+00 + 28 1.5666189299730341e+01 1.6249815489114361e+00 1.1769883127324578e+01 + 29 1.6154781213323030e+01 -1.3566033536379088e+01 -9.1472138878710076e+00 + 30 -8.3472695417921603e+00 7.0562388858473168e+00 6.3337664999339882e+00 + 31 4.5583726078147091e-02 -6.8079173592470026e+00 8.8191267004599450e-01 + 32 -3.7970235777293169e+01 2.1379327045743118e+01 6.2117682066075531e+01 + 33 -1.6353741251628691e+01 -2.2709420959741056e+01 1.6304846015441370e+01 + 34 9.9972886088735162e+00 2.2643391331974536e+00 -3.4550103310401896e+00 + 35 7.6455556546064358e+01 -3.7809722812169873e+01 -5.8409719550108399e+01 + 36 -6.9348410375051216e+01 -8.5084762326803883e+01 8.7066878049116482e+01 + 37 6.7398486015543440e+01 8.6977799607188729e+01 -7.7261561475806531e+01 + 38 7.3284526937033183e+00 -7.6017536517090827e+00 -4.4692146119773133e+00 + 39 2.2039881666125036e+00 2.6712481163988575e+00 -5.4998118879989439e+00 + 40 -8.1920739102716507e+00 -5.6013665505583772e+00 -6.3906324471289055e-01 + 41 -9.6914424345020511e-01 -3.6895968531383003e+00 1.1100392846951848e+00 + 42 6.4344379128480211e+00 2.8919317863081786e+00 -2.0533867506787638e+00 + 43 -4.8969216688076900e+00 8.9173540382237473e+00 -3.4262725785712571e+00 + 44 3.9812820211199523e-01 -6.4925904498103826e+00 -2.2914632965466297e+00 + 45 -1.1701379586492111e+00 -6.8534375447769547e-01 5.2141786324779167e+00 + 46 1.7082488047076678e+00 2.9689192858013040e+00 -7.3986980836820644e+00 + 47 -8.4162004926885050e+00 -1.1549845996840341e-01 -6.9949420861709011e-01 + 48 -1.7140102399704551e+02 1.0954749031941631e+02 1.0215589866028962e+02 + 49 1.2958089986488774e+01 1.0763913519899868e+01 -1.6248816454541608e+01 + 50 1.4518431826929746e+01 5.0424709064095214e+00 5.3597634284364259e-02 + 51 -1.4015254817893208e+04 1.2504756770641432e+04 -1.5967183598544239e+04 + 52 1.5420056645525479e+01 -1.4998517432233239e+01 1.0961481290482833e+01 + 53 1.4023035080488416e+04 -1.2504964789519170e+04 1.5967622019398565e+04 + 54 -1.2443556258779074e+00 1.1935781697358863e+00 -4.7574145417182354e+00 + 55 -1.3066707495598941e+01 2.3943248755492228e+01 -1.1562546476831322e+01 + 56 -8.3304235816705628e+01 2.6818208086831827e+01 5.1686194842892000e+01 + 57 1.5120792842525938e+02 5.1705018806557780e+02 3.0849363663112024e+02 + 58 -9.2125676676377548e+00 -1.1733522325859413e+01 1.8639253510409390e-02 + 59 1.5201721677305994e+02 -1.2328671257917705e+02 -8.0267873143196880e+01 + 60 -2.1359354701455682e+00 -1.0122954230610202e+00 -7.9908260633230173e+00 + 61 -1.6847550389189405e+02 -5.1524925258885060e+02 -2.9923087564684147e+02 + 62 -2.7864227120115106e+00 1.2259886975143148e+01 5.9379812236948695e+00 + 63 -7.9097586153187249e+00 -3.2603634511507762e+00 1.0417329010466950e+01 + 64 2.5990005859488274e+01 3.2517151166598666e+01 -1.6862446054183820e+01 +... diff --git a/unittest/force-styles/tests/atomic-pair-buck_coul_cut_qeq_shielded.yaml b/unittest/force-styles/tests/atomic-pair-buck_coul_cut_qeq_shielded.yaml new file mode 100644 index 0000000000..2a80c30144 --- /dev/null +++ b/unittest/force-styles/tests/atomic-pair-buck_coul_cut_qeq_shielded.yaml @@ -0,0 +1,175 @@ +--- +lammps_version: 8 Apr 2021 +date_generated: Tue Apr 20 14:48:00 2021 +epsilon: 7.5e-13 +skip_tests: intel single +prerequisites: ! | + pair buck/coul/cut + fix qeq/shielded +pre_commands: ! | + echo screen + variable newton_pair delete + variable newton_pair index on + atom_modify map array + units metal + atom_style charge + lattice diamond 3.77 + region box block 0 2 0 2 0 2 + create_box 2 box + create_atoms 1 box + displace_atoms all random 0.1 0.1 0.1 623426 + mass 1 28.0 + mass 2 16.0 + set type 1 type/fraction 2 0.666667 998877 + set type 1 charge 0.8 + set type 2 charge 0.4 + velocity all create 100 4534624 loop geom +post_commands: ! | + fix qeq all qeq/shielded 1 6.0 1.0e-20 20 ${input_dir}/param.qeq2 warn no +input_file: in.empty +pair_style: buck/coul/cut 6.0 +pair_coeff: ! | + 1 1 0.0 0.1 00 + 1 2 18003.0 0.2052124 133.5381 + 2 2 1388.77 0.3623188 175.0 +extract: ! "" +natoms: 64 +init_vdwl: 106.41860675757 +init_coul: -92.45424973362312 +init_stress: ! |- + -2.6904173108770976e+02 -4.3428982773044442e+02 -4.9175916018347112e+02 3.9566088371930806e+02 -4.7262515517192719e+02 1.9591432292647838e+02 +init_forces: ! |2 + 1 7.9141417235740947e+00 -1.6575050231777215e+00 1.1247124417953305e+01 + 2 -8.1950643733925208e+00 -1.6928876509873696e+00 6.6818350912540652e+00 + 3 7.5215990692204731e+00 -2.1745595057982086e+01 -3.1301184475253381e+00 + 4 5.3917119324179188e+00 1.9732178742296160e+01 -3.7725042521095493e+00 + 5 -1.0136647320370246e+01 -1.2048794925281427e+01 -8.4425399256150335e+00 + 6 2.4664525420347161e+00 1.5156953299620182e+00 3.7546365998324012e+00 + 7 1.1539561031557810e+01 2.5652090902711979e+00 -4.3086648609162537e-01 + 8 -8.0662635175834705e+00 -8.3166158318636221e+00 4.2929691537457746e+00 + 9 7.8771720152697613e+00 -9.0024422542616396e+00 -4.5409532537229280e+00 + 10 -1.0964825127320315e+01 -1.7834328756310320e+00 7.8305203967741654e+00 + 11 2.8042061526336870e+01 -2.4878965644063260e+01 -6.9143265780487837e+01 + 12 1.8495615121211895e+01 4.3133827818564443e+00 -1.7691034897981336e+01 + 13 -8.4399728839306629e+00 -1.1518157999367906e+01 1.0295637396842004e+01 + 14 -2.7480646564437472e+00 1.8734968257465416e+00 -9.0973470213750058e+00 + 15 4.0225295371995529e+00 -4.0872787545152063e+00 -2.9384778611873470e+00 + 16 -5.9650138797306003e+00 -2.3087379423335772e+00 6.8308131661998561e-02 + 17 -9.1908442946528215e+00 1.1751276661643065e+01 -1.8408085151683529e+00 + 18 -1.3137718308179736e+00 -1.9012430640012012e+00 -5.1139666908059747e+00 + 19 4.4549255890758639e+00 -4.3939817417280941e-01 2.1886643387097751e+00 + 20 -2.0319203048741077e+00 1.2653408558732941e+01 -4.9917805891989406e+00 + 21 2.4950515142199343e+00 -7.8536749191430131e+00 -1.8304140855930795e+00 + 22 -1.2859663801965809e+01 2.2730915732234180e+01 -4.9479217011461092e+00 + 23 2.5459383618018023e+00 -2.9828026430000509e-01 3.4194490946030140e+00 + 24 -4.3638180485752436e+00 2.2376710173772068e+01 4.7532741402407801e+00 + 25 2.0836667788518888e+01 -1.6344888313048909e+01 5.6211876341385709e+00 + 26 -1.2607606955151248e+01 9.1008974375965153e+00 1.2019343399635865e+01 + 27 2.1952885206072059e+00 5.0665486907574895e+00 5.5237917166507362e+00 + 28 1.6488561582105199e+01 2.4906410951101425e+00 1.2426653974121137e+01 + 29 1.6251639920278514e+01 -1.4165524718233035e+01 -9.5519013725891924e+00 + 30 -8.5665322777305750e+00 6.5330097528312958e+00 6.7385937277364834e+00 + 31 -1.6266027468958288e-01 -6.6886609738962113e+00 8.8566519040115255e-01 + 32 -3.5245474890368847e+01 1.6495014756334484e+01 5.1078937232184522e+01 + 33 -1.5987226674008781e+01 -2.1890093847568011e+01 1.6032979914514094e+01 + 34 9.8711439787861472e+00 2.5536945969673872e+00 -3.3348635269507474e+00 + 35 7.0807263895311777e+01 -3.5539168497154421e+01 -5.3725574081330656e+01 + 36 -5.6877142152340149e+01 -6.9366823927578849e+01 7.2994971999025935e+01 + 37 5.4660108324736413e+01 7.1291615544338143e+01 -6.3759392720711894e+01 + 38 7.0743366174130307e+00 -7.6487647563486689e+00 -4.6878237559766189e+00 + 39 2.0381847012670646e+00 2.6755672967675741e+00 -5.2811442194348039e+00 + 40 -9.0185944759842691e+00 -5.7604357452722770e+00 -3.4337610522422546e-01 + 41 -2.7088447313443842e+00 -5.2782133055992473e+00 1.7885966807060194e+00 + 42 6.7732857687967325e+00 2.3205919970957725e+00 -2.4010131075334322e+00 + 43 -4.5927233661860249e+00 9.0529486933975445e+00 -3.6577320776925335e+00 + 44 2.8749921571080672e-01 -6.1319691267726260e+00 -1.7739459946345322e+00 + 45 -1.1845421822047435e+00 -1.2989558081946262e-01 5.4900076955978339e+00 + 46 1.3601159060680870e+00 3.5799207177313330e+00 -7.6189436341957544e+00 + 47 -8.1337841515165614e+00 -1.2629496960863673e-01 -8.8562060415993760e-01 + 48 -1.4860155650493951e+02 9.0963206813737870e+01 8.8856904799540899e+01 + 49 1.2639152627450446e+01 1.0359532596352693e+01 -1.7242867911828036e+01 + 50 1.5521880865901194e+01 4.2868543946915896e+00 3.1711848237800400e-01 + 51 -1.0735634351608480e+03 9.4537025515826099e+02 -1.2147493979398862e+03 + 52 1.5466658019682828e+01 -1.4895417892202326e+01 1.1112480680825493e+01 + 53 1.0819480450682750e+03 -9.4418452213503031e+02 1.2169212362594612e+03 + 54 -1.0894773002862821e+00 6.6706752208107978e-01 -4.8790516443905974e+00 + 55 -1.3844732593145427e+01 2.4648863250620490e+01 -1.1348546815898326e+01 + 56 -7.5962830973889339e+01 2.6101351295707214e+01 4.6341687389775707e+01 + 57 1.0485701291302608e+02 3.6058930749586290e+02 2.1396553624858470e+02 + 58 -8.9779882186764475e+00 -1.3244731779675908e+01 -1.3278080384995206e+00 + 59 1.2850554211073154e+02 -1.0591990510462425e+02 -6.6793350663870882e+01 + 60 -2.1508838217754374e+00 -9.5900020614540604e-01 -7.7855526817679328e+00 + 61 -1.2102976382849171e+02 -3.5660400748210526e+02 -2.0445983478947505e+02 + 62 -3.2250906445468925e+00 1.1774314121365196e+01 6.3355915377420322e+00 + 63 -7.6074695879604359e+00 -2.9040201639454253e+00 1.0880944642028627e+01 + 64 2.5065083017154684e+01 3.1881871782588231e+01 -1.6344906772607633e+01 +run_vdwl: -1738.504828461019 +run_coul: -94.95581768227976 +run_stress: ! |- + -4.5595453405449562e+03 -3.9713162676196043e+03 -6.0848825790480287e+03 4.1634964821175072e+03 -5.3172121985750009e+03 4.4482840126121810e+03 +run_forces: ! |2 + 1 7.9430648174104608e+00 -1.6505623585983651e+00 1.1353040695469964e+01 + 2 -8.0909470592272665e+00 -1.6949319849892177e+00 6.7767677870716474e+00 + 3 8.1078778180838125e+00 -2.3235717929919247e+01 -3.8090540398880952e+00 + 4 5.2184189853247993e+00 1.9883083402118530e+01 -3.9293647164607202e+00 + 5 -1.0315532797751688e+01 -1.2066521654437734e+01 -8.6235072008116074e+00 + 6 2.3527033402736865e+00 1.8434233133221647e+00 3.9200698665620468e+00 + 7 1.1558853330915097e+01 2.6482270737969671e+00 -3.5653539616982843e-01 + 8 -8.0944578895520376e+00 -8.2317015861577598e+00 4.2492167566992798e+00 + 9 7.7973204991242282e+00 -9.1232078942352679e+00 -4.4476458756957902e+00 + 10 -1.0992761089447495e+01 -1.7271203633765912e+00 7.8732627610722128e+00 + 11 3.0931722247747444e+01 -2.8786477048677739e+01 -7.8665114289916033e+01 + 12 1.8274394539545813e+01 4.2080021850140445e+00 -1.7702358881800027e+01 + 13 -8.2599586789888200e+00 -1.1515741006968879e+01 1.0107104927112278e+01 + 14 -2.7279898223061001e+00 1.6130541061743697e+00 -9.3952153337124464e+00 + 15 3.9515263062313335e+00 -4.0844589202051376e+00 -2.8866117721996689e+00 + 16 -5.8981678832905171e+00 -2.1804152314776850e+00 1.4275910534889458e-01 + 17 -9.3307269581232593e+00 1.1774312330333576e+01 -1.6692683576013803e+00 + 18 -1.3134558888695769e+00 -1.9382763777674961e+00 -5.1386794705347452e+00 + 19 4.4778449905197109e+00 -3.7332160506766110e-01 2.2265534122637054e+00 + 20 -1.9216161276856039e+00 1.2623039169837961e+01 -4.9985363809975647e+00 + 21 2.4738768947622880e+00 -7.8544243197235870e+00 -1.7482503763962445e+00 + 22 -1.2883029726566168e+01 2.2588117645764534e+01 -4.6467323617000371e+00 + 23 2.3091594744980535e+00 -3.5151849114507772e-01 3.5274744438543237e+00 + 24 -4.9018564244447180e+00 2.3838352476498073e+01 5.3460036982254815e+00 + 25 2.0948048851721442e+01 -1.6373698326971489e+01 5.7720446049694036e+00 + 26 -1.2578008211337877e+01 9.1211609042314503e+00 1.2008844944222867e+01 + 27 2.2045394963986160e+00 5.0247152904089880e+00 5.4827119887611868e+00 + 28 1.6104286139406646e+01 1.9002405388339891e+00 1.2069099381708440e+01 + 29 1.6263381250006539e+01 -1.4213704415061143e+01 -9.5280965445643737e+00 + 30 -8.5106296596336417e+00 6.5389339966331104e+00 6.7625294275517316e+00 + 31 1.4273319546851848e-02 -6.6747306136807882e+00 1.0093006407241376e+00 + 32 -3.7680672886741476e+01 2.0930462633195887e+01 6.1078153188510051e+01 + 33 -1.6365245005849875e+01 -2.2602871724758668e+01 1.6416398262575715e+01 + 34 9.8850471358845962e+00 2.3562304461945787e+00 -3.2796925462623761e+00 + 35 7.6552797346940821e+01 -3.7762973127437611e+01 -5.8230414917441593e+01 + 36 -6.8717983540165619e+01 -8.4097670136565384e+01 8.5940075687947427e+01 + 37 6.6554563114837478e+01 8.5966291567755746e+01 -7.6794896761790099e+01 + 38 7.1088003592849205e+00 -8.2230746263721581e+00 -4.2021171895312630e+00 + 39 2.0757879393792544e+00 2.6895810149309449e+00 -5.2209951864941644e+00 + 40 -8.5670330622826629e+00 -5.1877611476592262e+00 -4.7690438257845008e-01 + 41 -1.5274749236361123e+00 -4.0411587071835031e+00 7.8872850139034600e-01 + 42 6.4844518585745128e+00 2.8177957843382857e+00 -1.7924873100831999e+00 + 43 -4.6905478422001954e+00 8.9556578890169813e+00 -3.5942238071494108e+00 + 44 2.2519703741980698e-01 -6.1753412426980390e+00 -1.8022354020798390e+00 + 45 -9.1501325926584676e-01 -5.2347101045402322e-01 4.8068911677143360e+00 + 46 1.3779977952935716e+00 3.4995478428931444e+00 -7.6316648685752480e+00 + 47 -8.0609749909669581e+00 -2.1741420953096791e-01 -8.4151730986634521e-01 + 48 -1.7213184634714088e+02 1.0957659916624621e+02 1.0267576521252535e+02 + 49 1.3502214899750406e+01 1.0917576182238818e+01 -1.6482937758762418e+01 + 50 1.4379813283875713e+01 5.0553400873044820e+00 1.0683342950103625e-01 + 51 -1.3957521762635950e+04 1.2452654544174226e+04 -1.5900991752693422e+04 + 52 1.5633296407076536e+01 -1.5168118286747163e+01 1.1375722352219624e+01 + 53 1.3966019441343162e+04 -1.2452432702569762e+04 1.5901485612155189e+04 + 54 -1.0302010742237790e+00 8.0882593586606122e-01 -4.8342043026033270e+00 + 55 -1.4050317568063919e+01 2.4571746720771483e+01 -1.1619744995231775e+01 + 56 -8.3051825195541284e+01 2.6893430568070734e+01 5.1720488371951646e+01 + 57 1.5167680987925942e+02 5.1771459761745700e+02 3.0876046319206444e+02 + 58 -9.0684224428918387e+00 -1.1737173531443593e+01 -4.2815053798067343e-01 + 59 1.5222786378196815e+02 -1.2370024170265403e+02 -8.0875432712487481e+01 + 60 -2.1233147761897007e+00 -7.9017832727701498e-01 -7.6738212145982452e+00 + 61 -1.6808948242299991e+02 -5.1546658556632860e+02 -2.9975983407554941e+02 + 62 -3.2501332686207283e+00 1.1879860248088384e+01 6.2378391727747093e+00 + 63 -7.6393918044176985e+00 -2.9843682141469259e+00 1.0819122718511684e+01 + 64 2.5665406780155877e+01 3.2294883947912929e+01 -1.6760878883557520e+01 +... diff --git a/unittest/force-styles/tests/atomic-pair-colloid.yaml b/unittest/force-styles/tests/atomic-pair-colloid.yaml index 537ac447b5..b666021c91 100644 --- a/unittest/force-styles/tests/atomic-pair-colloid.yaml +++ b/unittest/force-styles/tests/atomic-pair-colloid.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:08:59 2021 epsilon: 5e-14 +skip_tests: single prerequisites: ! | pair colloid pre_commands: ! | diff --git a/unittest/force-styles/tests/atomic-pair-colloid_multi.yaml b/unittest/force-styles/tests/atomic-pair-colloid_multi.yaml index 025a7faa05..d224977a3e 100644 --- a/unittest/force-styles/tests/atomic-pair-colloid_multi.yaml +++ b/unittest/force-styles/tests/atomic-pair-colloid_multi.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:08:59 2021 epsilon: 5e-14 +skip_tests: single prerequisites: ! | pair colloid pre_commands: ! | diff --git a/unittest/force-styles/tests/atomic-pair-colloid_multi_tri.yaml b/unittest/force-styles/tests/atomic-pair-colloid_multi_tri.yaml index 9ead662a06..fa52a37ce7 100644 --- a/unittest/force-styles/tests/atomic-pair-colloid_multi_tri.yaml +++ b/unittest/force-styles/tests/atomic-pair-colloid_multi_tri.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:08:59 2021 epsilon: 5e-13 +skip_tests: single prerequisites: ! | pair colloid pre_commands: ! | diff --git a/unittest/force-styles/tests/atomic-pair-colloid_tiled.yaml b/unittest/force-styles/tests/atomic-pair-colloid_tiled.yaml index be3ba744d0..62e85584e7 100644 --- a/unittest/force-styles/tests/atomic-pair-colloid_tiled.yaml +++ b/unittest/force-styles/tests/atomic-pair-colloid_tiled.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:08:59 2021 epsilon: 5e-14 +skip_tests: single prerequisites: ! | pair colloid pre_commands: ! | diff --git a/unittest/force-styles/tests/atomic-pair-colloid_tiled_tri.yaml b/unittest/force-styles/tests/atomic-pair-colloid_tiled_tri.yaml index cd6c7595e8..b3f0b7a06d 100644 --- a/unittest/force-styles/tests/atomic-pair-colloid_tiled_tri.yaml +++ b/unittest/force-styles/tests/atomic-pair-colloid_tiled_tri.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:08:59 2021 epsilon: 5e-13 +skip_tests: single prerequisites: ! | pair colloid pre_commands: ! | diff --git a/unittest/force-styles/tests/atomic-pair-eam.yaml b/unittest/force-styles/tests/atomic-pair-eam.yaml index c606813d56..9c8c3ba8cd 100644 --- a/unittest/force-styles/tests/atomic-pair-eam.yaml +++ b/unittest/force-styles/tests/atomic-pair-eam.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:09:00 2021 epsilon: 6e-12 +skip_tests: single prerequisites: ! | pair eam pre_commands: ! | diff --git a/unittest/force-styles/tests/atomic-pair-eam_alloy.yaml b/unittest/force-styles/tests/atomic-pair-eam_alloy.yaml index 072a0a97c0..5ec5bef372 100644 --- a/unittest/force-styles/tests/atomic-pair-eam_alloy.yaml +++ b/unittest/force-styles/tests/atomic-pair-eam_alloy.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:09:00 2021 epsilon: 5e-12 +skip_tests: single prerequisites: ! | pair eam/alloy pre_commands: ! "" diff --git a/unittest/force-styles/tests/atomic-pair-eam_alloy_real.yaml b/unittest/force-styles/tests/atomic-pair-eam_alloy_real.yaml index 033c341f08..bff08e048b 100644 --- a/unittest/force-styles/tests/atomic-pair-eam_alloy_real.yaml +++ b/unittest/force-styles/tests/atomic-pair-eam_alloy_real.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:09:00 2021 epsilon: 7.5e-12 +skip_tests: single prerequisites: ! | pair eam/alloy pre_commands: ! | diff --git a/unittest/force-styles/tests/atomic-pair-eam_cd.yaml b/unittest/force-styles/tests/atomic-pair-eam_cd.yaml index bda14a9e5a..915253dce7 100644 --- a/unittest/force-styles/tests/atomic-pair-eam_cd.yaml +++ b/unittest/force-styles/tests/atomic-pair-eam_cd.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:09:00 2021 epsilon: 5e-12 +skip_tests: single prerequisites: ! | pair eam/cd pre_commands: ! "" diff --git a/unittest/force-styles/tests/atomic-pair-eam_cd_old.yaml b/unittest/force-styles/tests/atomic-pair-eam_cd_old.yaml index 4f6891bae6..a7fa727b7f 100644 --- a/unittest/force-styles/tests/atomic-pair-eam_cd_old.yaml +++ b/unittest/force-styles/tests/atomic-pair-eam_cd_old.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:09:00 2021 epsilon: 5e-12 +skip_tests: single prerequisites: ! | pair eam/cd/old pre_commands: ! "" diff --git a/unittest/force-styles/tests/atomic-pair-eam_cd_real.yaml b/unittest/force-styles/tests/atomic-pair-eam_cd_real.yaml index e2ac5f0cae..abe25cff95 100644 --- a/unittest/force-styles/tests/atomic-pair-eam_cd_real.yaml +++ b/unittest/force-styles/tests/atomic-pair-eam_cd_real.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:09:00 2021 epsilon: 5e-12 +skip_tests: single prerequisites: ! | pair eam/cd pre_commands: ! | diff --git a/unittest/force-styles/tests/atomic-pair-eam_fs.yaml b/unittest/force-styles/tests/atomic-pair-eam_fs.yaml index 89ad740424..58c533d7ec 100644 --- a/unittest/force-styles/tests/atomic-pair-eam_fs.yaml +++ b/unittest/force-styles/tests/atomic-pair-eam_fs.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:09:01 2021 epsilon: 5e-12 +skip_tests: single prerequisites: ! | pair eam/fs pre_commands: ! "" diff --git a/unittest/force-styles/tests/atomic-pair-eam_fs_real.yaml b/unittest/force-styles/tests/atomic-pair-eam_fs_real.yaml index bf7f4f338b..f7739ee824 100644 --- a/unittest/force-styles/tests/atomic-pair-eam_fs_real.yaml +++ b/unittest/force-styles/tests/atomic-pair-eam_fs_real.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:09:01 2021 epsilon: 7.5e-12 +skip_tests: single prerequisites: ! | pair eam/fs pre_commands: ! | diff --git a/unittest/force-styles/tests/atomic-pair-eam_he.yaml b/unittest/force-styles/tests/atomic-pair-eam_he.yaml index 001301fe1a..f2bf098b2f 100644 --- a/unittest/force-styles/tests/atomic-pair-eam_he.yaml +++ b/unittest/force-styles/tests/atomic-pair-eam_he.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:09:01 2021 epsilon: 5e-12 +skip_tests: single prerequisites: ! | pair eam/he pre_commands: ! "" diff --git a/unittest/force-styles/tests/atomic-pair-eam_he_real.yaml b/unittest/force-styles/tests/atomic-pair-eam_he_real.yaml index 236b9538a7..b2b198486e 100644 --- a/unittest/force-styles/tests/atomic-pair-eam_he_real.yaml +++ b/unittest/force-styles/tests/atomic-pair-eam_he_real.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:09:02 2021 epsilon: 7.5e-12 +skip_tests: single prerequisites: ! | pair eam/he pre_commands: ! | diff --git a/unittest/force-styles/tests/atomic-pair-eam_real.yaml b/unittest/force-styles/tests/atomic-pair-eam_real.yaml index 89e7c1ce0b..4d95f04edc 100644 --- a/unittest/force-styles/tests/atomic-pair-eam_real.yaml +++ b/unittest/force-styles/tests/atomic-pair-eam_real.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:09:02 2021 epsilon: 5e-12 +skip_tests: single prerequisites: ! | pair eam pre_commands: ! | diff --git a/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml b/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml index 4c8e040200..737b054dd0 100644 --- a/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml +++ b/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml @@ -2,6 +2,7 @@ lammps_version: 8 Apr 2021 date_generated: Mon Apr 19 08:49:08 2021 epsilon: 1e-11 +skip_tests: single prerequisites: ! | pair eam/fs pre_commands: ! "" diff --git a/unittest/force-styles/tests/atomic-pair-hybrid-eam_fs.yaml b/unittest/force-styles/tests/atomic-pair-hybrid-eam_fs.yaml index be3889de90..d45dc9190e 100644 --- a/unittest/force-styles/tests/atomic-pair-hybrid-eam_fs.yaml +++ b/unittest/force-styles/tests/atomic-pair-hybrid-eam_fs.yaml @@ -2,6 +2,7 @@ lammps_version: 8 Apr 2021 date_generated: Mon Apr 19 08:49:08 2021 epsilon: 5e-12 +skip_tests: single prerequisites: ! | pair eam/fs pre_commands: ! "" diff --git a/unittest/force-styles/tests/atomic-pair-reax_c.yaml b/unittest/force-styles/tests/atomic-pair-reax_c.yaml index ed0908beae..c4d41a2f2a 100644 --- a/unittest/force-styles/tests/atomic-pair-reax_c.yaml +++ b/unittest/force-styles/tests/atomic-pair-reax_c.yaml @@ -1,11 +1,10 @@ --- -lammps_version: 24 Aug 2020 -date_generated: Tue Sep 15 09:44:24 202 -epsilon: 5e-11 -skip_tests: omp +lammps_version: 2 Jul 2021 +date_generated: Wed Jul 21 15:49:45 2021 +epsilon: 1e-11 prerequisites: ! | - pair reax/c - fix qeq/reax + pair reaxff + fix qeq/reaxff pre_commands: ! | echo screen variable newton_pair delete @@ -15,159 +14,162 @@ pre_commands: ! | atom_style charge lattice diamond 3.77 region box block 0 2 0 2 0 2 - create_box 2 box + create_box 3 box create_atoms 1 box displace_atoms all random 0.1 0.1 0.1 623426 - mass 1 12.0 - mass 2 13.0 + mass 1 1.0 + mass 2 12.0 + mass 3 16.0 set type 1 type/fraction 2 0.5 998877 - set type 1 charge 0.01 - set type 2 charge -0.01 + set type 2 type/fraction 3 0.5 887766 + set type 1 charge 0.00 + set type 2 charge 0.01 + set type 3 charge -0.01 velocity all create 100 4534624 loop geom post_commands: ! | - fix qeq all qeq/reax 1 0.0 8.0 1.0e-12 reax/c + fix qeq all qeq/reaxff 1 0.0 8.0 1.0e-20 reaxff input_file: in.empty -pair_style: reax/c NULL checkqeq yes +pair_style: reaxff NULL checkqeq yes pair_coeff: ! | - * * ffield.reax.mattsson C O + * * ffield.reax.mattsson H C O extract: ! "" natoms: 64 -init_vdwl: -4208.20379453327 -init_coul: -268.025868109969 -init_stress: ! |2- - 2.3677048490920824e+03 3.0802122558803894e+03 1.2727815110256352e+03 -1.5387991688244833e+03 -1.0906364142624241e+03 1.1229877249520346e+03 +init_vdwl: -3296.3503506624793 +init_coul: -327.06551252279587 +init_stress: ! |- + -1.0522112314759656e+03 -1.2629480788292419e+03 -8.6765541430728797e+02 -2.5149818635822544e+02 2.0624598409299588e+02 -6.4309968343216440e+02 init_forces: ! |2 - 1 2.9634051452159092e+01 -5.6267761875030658e+02 -1.6668253255975264e+02 - 2 -1.5938437728854763e+02 -2.2076601831952277e+02 -1.7161994484506349e+02 - 3 -3.1194106231120934e+01 -3.0591930644164984e+02 4.4652570958886855e+01 - 4 4.4646653320086006e+02 1.7080811286682768e+02 1.7439026170464757e+02 - 5 -1.1512606621586120e+02 7.9716954463543715e+01 1.7959700550169842e+01 - 6 -7.1695199301551634e+02 4.0749156821010061e+01 2.1512037025864390e+02 - 7 2.3022543693157868e+02 -9.0170756873660693e+01 8.2190170006827103e+01 - 8 -2.1141251466323027e+01 -1.5635879347049067e+02 1.6101907187949953e+02 - 9 -1.2130842270575529e+02 -2.7960689135673749e+02 -1.9629114850260629e+02 - 10 -3.7631710890081683e+02 3.4103240548842098e+02 -1.8166279141141010e+02 - 11 -1.6154553323830120e+02 1.5743068117734555e+02 3.5832389058238908e+02 - 12 6.1602989065533677e+02 -1.4821564423137232e+02 1.0871005319359449e+02 - 13 -2.1366561068611992e+02 -3.0163595494862591e+02 5.2420406156009221e+02 - 14 2.5933950255870195e+02 -1.7967300062480934e+01 -2.7733367021033393e+02 - 15 1.7570537661851756e+02 1.7550639099552842e+02 -9.5789475936401502e+01 - 16 3.0588529285446674e+02 -4.7675556549182751e+01 -3.4330544488853229e+02 - 17 -1.5018545342641502e+02 1.3259542010622835e+02 2.3200545258695152e+02 - 18 1.6469564396901859e+02 -1.0816413254504512e+02 2.1207485840072781e+02 - 19 2.4759285902953567e+02 -4.8758383780475292e+01 -2.2494100786652814e+02 - 20 1.2418785577595527e+02 2.5137242577522335e+02 -1.5341186115707405e+01 - 21 -1.9556210564940739e+02 2.3152590535605817e+01 -1.2529729601983919e+02 - 22 2.4829386068621537e+02 -2.9828789153725000e+02 -4.0455445433034242e+01 - 23 8.2076007650246268e+01 1.3042103437660427e+02 1.5221389911908562e+02 - 24 -7.6912973583004117e+01 2.3539925428997182e+02 -1.7129603802759658e+02 - 25 -2.9782413878288601e+01 -1.8931910469290884e+02 6.7989202537834629e+01 - 26 -3.9488494691858733e+01 2.1025614474841166e+00 -2.0748963060927093e+02 - 27 -2.7704110443954568e+02 5.3736974078111837e+02 4.2318884882982655e+02 - 28 -2.9303219943086964e+02 -5.1154115419315801e+01 -2.3633993403319352e+02 - 29 1.2970484011863229e+02 -4.2266229540891523e+01 1.6350076615001245e+02 - 30 5.6925606430450244e+01 3.7880191852738363e+01 6.8636397133393515e+01 - 31 -1.9325596697344542e+02 -1.1645368911552394e+02 -2.0671692761029085e+01 - 32 1.2360965200003356e+02 -3.3253411369799544e+01 -1.0516118459008628e+02 - 33 6.5241847803264264e+01 3.7105112939426823e+02 6.0972558235487462e+01 - 34 -2.3124259597670152e+02 -1.1681740329837199e+02 -2.5838262648349195e+02 - 35 -4.1912226107435538e+02 7.9942920270919515e+01 3.1021023518178822e+02 - 36 -1.8561789047275289e+02 -1.1563628711158724e+02 -4.2360172436739234e+01 - 37 8.8271496723997984e+00 -3.5266450940740185e+02 -6.0505384072464253e+01 - 38 -1.9249505149150679e+01 1.1716319600328805e+02 -2.3477222840192979e+02 - 39 -1.0433878247256505e+01 -7.0902801856124668e+01 1.4264113912371403e+02 - 40 3.3265570779159901e+02 -8.8675933035708010e+02 1.6250845779831312e+01 - 41 -6.4537349815542413e+01 1.5189506353207591e+02 -1.8225353662815957e+02 - 42 2.3368723487133941e+01 1.1821526859991214e+02 4.1207323013177859e+02 - 43 -3.5145546474481449e+01 -3.6511647370571314e+00 2.4936793079195368e+02 - 44 -1.2881828259629406e+00 -2.4877240180809443e+02 7.9235766494652268e+01 - 45 2.0871504532583336e+02 -1.0817588901332421e+02 -4.1291808327418767e+02 - 46 -1.3837716960724282e+02 4.6114279241771982e+02 -2.4013801845132105e+02 - 47 1.3255320792807126e+02 2.8747276038957534e+02 -3.2896384987639095e+01 - 48 7.8145138718960652e+02 6.5215432481087248e+01 -6.2304789958695994e+02 - 49 2.4486314507349098e+02 1.9101300126648027e+01 3.7417037047533785e+02 - 50 2.9821275118609668e+02 3.0684252095011033e+02 5.6994896759607411e+02 - 51 -8.0052405736428466e+02 5.1024940640343124e+02 7.5829315450302556e+02 - 52 -9.2130898885920971e+01 1.1909837120722435e+02 -2.4118832391136704e+02 - 53 -3.6386926333492499e+02 -2.0729203700042348e+02 -3.4910517647674493e+02 - 54 -8.3399710534859324e+01 1.8942260327527066e+02 -1.2868598438441273e+02 - 55 -2.5305956575882524e+02 -1.1005916187119085e+02 -3.0893514828401271e+02 - 56 1.7364614503186098e+02 -2.5754370913466397e+02 -4.3744509948530059e+01 - 57 4.2667925201490533e+02 1.5529221173801471e+02 -3.9988499000695890e+02 - 58 -3.9656744140931579e+01 7.8953243693622596e+01 2.6135299122214326e+02 - 59 -2.7594240444747766e+02 1.9891763338576968e+02 2.4122500794444767e+02 - 60 -2.5675904361267118e+02 -1.1527171320999500e+02 9.9923550442604068e+01 - 61 3.0884427580032076e+02 4.9986415802554944e+02 -1.3369122169845875e+02 - 62 2.8530106503430972e+01 5.9540697567549117e-01 -2.7403025931165831e+02 - 63 2.5297054006405324e+02 -2.7640485799390927e+02 -1.9200503841891754e+02 - 64 -8.4680445259235810e+01 -1.5737027404334836e+02 1.5637808719891763e+02 -run_vdwl: -4208.20960310156 -run_coul: -268.025834774416 -run_stress: ! |2- - 2.3675903993358406e+03 3.0802227297812642e+03 1.2727311522665882e+03 -1.5388669378280856e+03 -1.0907269208274088e+03 1.1229243202747448e+03 + 1 -8.8484559491557889e+01 -2.5824737864578672e+01 1.0916228789487677e+02 + 2 -1.1227736122976222e+02 -1.8092349731667619e+02 -2.2420586526896258e+02 + 3 -1.7210817575849026e+02 1.8292439782308693e+02 1.3552618819720610e+01 + 4 3.2997500231085269e+01 -5.1076027616185407e+01 9.0475628837095528e+01 + 5 1.8144778146274791e+02 1.6797701000587494e+01 -8.1725507301127109e+01 + 6 1.3634094180728098e+02 -3.0056789474000180e+02 2.9661495129805985e+01 + 7 -5.3287158661291791e+01 -1.2872927610192625e+02 -1.6347871108897493e+02 + 8 -1.5334883257588757e+02 4.0171483324130705e+01 1.5317461163041000e+02 + 9 1.8364155867634015e+01 8.1986572088186833e+01 2.8272397798081524e+01 + 10 8.4246730110712562e+01 1.4177487113456959e+02 1.2330079878579957e+02 + 11 -4.3218423112520917e+01 6.5551082199289681e+01 1.3464882148706636e+02 + 12 -9.7317470492933836e+01 -2.6234999414154061e+01 7.2277941881646433e+00 + 13 -6.3183329836753892e+01 -4.7368101002971272e+01 -3.7592654029315028e+01 + 14 7.8642975316486144e+01 -6.7997612991897398e+01 -9.9044775614596077e+01 + 15 -6.6373732796038979e+01 2.1787558547532149e+02 8.0103149369093416e+01 + 16 1.9216166082224373e+02 5.3228015320734841e+01 6.6260214054210607e+01 + 17 1.4496007689503060e+02 -3.9700923044583725e+01 -9.7503851828130109e+01 + 18 -4.4989550233790240e+01 -1.9360605894359739e+02 1.1274792197022477e+02 + 19 2.6657528138945764e+02 3.7189510796650950e+02 -3.3847307488287709e+02 + 20 -7.6341040242469404e+01 -8.8478925962203348e+01 1.3557778212060665e+00 + 21 -7.1188591900926752e+01 -5.1591439985136596e+01 -1.2279442803769271e+02 + 22 1.5504836733039957e+02 -1.3094504458746079e+02 8.1474408030760628e+01 + 23 7.8015302036861712e+01 -1.3272310040521580e+01 -2.2771427736544119e+01 + 24 -2.0546718065741095e+02 2.1611071031053456e+02 -1.2423208053538964e+02 + 25 -1.1402686646199034e+02 1.9100238121128135e+02 -8.3504908417580054e+01 + 26 2.8663576552098777e+02 -2.1773884754170615e+02 2.3144300100087472e+02 + 27 -6.3247409025611177e+01 6.9122196748087077e+01 1.8606936744368775e+02 + 28 -3.5426011055935045e+00 3.8764809029451875e+01 3.2874001946768900e+01 + 29 -7.1069178571876577e+01 3.5485903180427727e+01 2.7311648896320222e+01 + 30 -1.7036987830119904e+02 -1.9851827590031277e+02 -1.1511401829123534e+02 + 31 -1.3970409889743331e+02 1.6660943915628047e+02 -1.2913930522474698e+02 + 32 2.7179130444112264e+01 -6.0169059447629905e+01 -1.7669495182022038e+02 + 33 -6.2659679124099576e+01 -6.4422131921795383e+01 6.4150928205326579e+01 + 34 -2.2119065265693525e+01 1.0450386886830510e+02 -7.3998379587547845e+01 + 35 2.6982987783286291e+02 -2.1519317040003423e+02 1.3051628460669625e+02 + 36 1.0368628874516659e+02 1.8817377639779619e+02 -1.9748944223870336e+02 + 37 -1.8009522406836996e+02 1.2993653092243866e+02 -6.3523043394051889e+01 + 38 -2.9571205878459978e+02 1.0441609933482223e+02 1.5582204859042622e+02 + 39 8.7398805727029284e+01 -6.0025559644669265e+01 2.2209742009837157e+01 + 40 2.0540672579010842e+01 -1.0735874009092362e+02 5.8655918369892206e+01 + 41 -5.8895846271372335e+01 1.1852345624639781e+01 -6.6147257724570267e+01 + 42 -9.6895512314642517e+01 3.8928741136688721e+01 -7.5791929957116153e+01 + 43 2.2476051812062425e+02 9.5505204283237461e+01 1.2309042240718746e+02 + 44 8.9817373579488660e+01 -1.0616333580628947e+02 -8.6321519086255464e+01 + 45 1.7202629662584418e+01 1.2890307246697841e+02 5.2916171301068438e+01 + 46 1.3547783972601877e+01 -2.9276223331260034e+01 2.2187412696867373e+01 + 47 3.3389762514712125e+01 -1.9217585014965050e+02 -6.9956213241088321e+01 + 48 7.3631720332112678e+01 -2.0953007324688531e+02 -2.3183566221404764e+01 + 49 -3.7589944473227263e+02 -2.4083165714763936e+01 1.0770339502610540e+02 + 50 3.8603083564823876e+01 -7.3616481568799330e+01 9.0414065019644610e+01 + 51 1.3736420686706188e+02 -1.0204157331506994e+02 1.5813725581150808e+02 + 52 -1.0797257051087827e+02 1.1876975735151170e+02 -1.3295758126486243e+02 + 53 -5.3807540206295386e+01 3.3259462625854701e+02 -3.8426833262903415e-03 + 54 -1.0690184616186778e+01 6.2820270853646484e+01 1.8343158343321133e+02 + 55 1.1231900459987581e+02 -1.7906654831317167e+02 7.6533681064340868e+01 + 56 -4.1027190034916501e+01 -1.4085413191133770e+02 3.7483064289953184e+01 + 57 9.9904315214040494e+01 7.0938939080461608e+01 -6.8654961257661554e+01 + 58 -2.7563642882026748e+01 -6.7445498717142298e+00 -1.8442640542823217e+01 + 59 -6.6628933617875447e+01 1.0613066354110043e+02 8.7736153919831693e+01 + 60 -1.7748415247438984e+01 6.3757605316872557e+01 -1.5086907478326543e+02 + 61 -3.3560907195791373e+01 -1.0076987083174085e+02 -7.4536106106935819e+01 + 62 1.5883428926665005e+01 -5.8433760297908881e+00 2.8392494016034934e+01 + 63 1.3294494001298784e+02 -1.2724568063770243e+02 -6.4886848316806294e+01 + 64 1.0738157273930993e+02 1.2062173788161542e+02 7.4541400611710799e+01 +run_vdwl: -3296.346882377749 +run_coul: -327.0653995073912 +run_stress: ! |- + -1.0521225462925122e+03 -1.2628780139889511e+03 -8.6757617693086104e+02 -2.5158592653603904e+02 2.0619472152426832e+02 -6.4312943979323666e+02 run_forces: ! |2 - 1 2.9635294281436092e+01 -5.6267712552700186e+02 -1.6667999923843206e+02 - 2 -1.5938673400140527e+02 -2.2076536449677653e+02 -1.7162354129440891e+02 - 3 -3.1189858281210785e+01 -3.0593580065887033e+02 4.4645958607345577e+01 - 4 4.4646581891377559e+02 1.7080959763779822e+02 1.7439093938229493e+02 - 5 -1.1512839796352765e+02 7.9717058687958001e+01 1.7957487669481100e+01 - 6 -7.1695602565953550e+02 4.0752829698478386e+01 2.1512533839223761e+02 - 7 2.3022644486507866e+02 -9.0168915600464501e+01 8.2194655874286369e+01 - 8 -2.1149264848910175e+01 -1.5637111051646082e+02 1.6102981315503155e+02 - 9 -1.2130987756625950e+02 -2.7961363383960696e+02 -1.9628960069621482e+02 - 10 -3.7631817089739258e+02 3.4103259385919483e+02 -1.8166532788364435e+02 - 11 -1.6154687915100456e+02 1.5742797820605873e+02 3.5832199951133140e+02 - 12 6.1603841944552107e+02 -1.4820397700260011e+02 1.0871524086045234e+02 - 13 -2.1367529106982624e+02 -3.0167446795645282e+02 5.2424091634214585e+02 - 14 2.5933827511245227e+02 -1.7968203382107991e+01 -2.7733114072560983e+02 - 15 1.7570793004227912e+02 1.7551005525189765e+02 -9.5784231788957229e+01 - 16 3.0586985592964720e+02 -4.7679566106090903e+01 -3.4332192731516005e+02 - 17 -1.5018636472319054e+02 1.3259146324636768e+02 2.3200578297682745e+02 - 18 1.6469881174797919e+02 -1.0816836176970681e+02 2.1207670716671672e+02 - 19 2.4759420520521982e+02 -4.8758383157848726e+01 -2.2494116682891169e+02 - 20 1.2419960666459312e+02 2.5137933265677643e+02 -1.5328241144786812e+01 - 21 -1.9556094492813440e+02 2.3151723981859487e+01 -1.2529581330695682e+02 - 22 2.4829941584472434e+02 -2.9829345245026002e+02 -4.0446702084680311e+01 - 23 8.2074458696897636e+01 1.3042100306278206e+02 1.5221371881645402e+02 - 24 -7.6917668833393961e+01 2.3540360228741474e+02 -1.7130192995348895e+02 - 25 -2.9742104523748988e+01 -1.8935699467866542e+02 6.7995874219778344e+01 - 26 -3.9494943772414118e+01 2.1074054700131106e+00 -2.0748981609909322e+02 - 27 -2.7704003655188802e+02 5.3736954143358219e+02 4.2318574013795291e+02 - 28 -2.9302855291141344e+02 -5.1149666119061756e+01 -2.3633679976969094e+02 - 29 1.2970505460316522e+02 -4.2266433901186595e+01 1.6349685185829642e+02 - 30 5.6925896868100061e+01 3.7880918758124416e+01 6.8637128510118643e+01 - 31 -1.9325534294267334e+02 -1.1645328076630720e+02 -2.0671892621504433e+01 - 32 1.2360198063047470e+02 -3.3253019999994883e+01 -1.0516936549572080e+02 - 33 6.5239383936127538e+01 3.7104662858441014e+02 6.0974455303813109e+01 - 34 -2.3124084085048867e+02 -1.1681523003062699e+02 -2.5837805461659735e+02 - 35 -4.1912113383003572e+02 7.9943750613190943e+01 3.1020725803699969e+02 - 36 -1.8561422052416717e+02 -1.1563434085907485e+02 -4.2360108129760114e+01 - 37 8.8275421439853545e+00 -3.5266971563414063e+02 -6.0507541452884695e+01 - 38 -1.9245036832008864e+01 1.1717726898956253e+02 -2.3478417248390394e+02 - 39 -1.0434224692455489e+01 -7.0902644440221152e+01 1.4263978421851866e+02 - 40 3.3271177801104579e+02 -8.8679293552758975e+02 1.6219742097522396e+01 - 41 -6.4538764985979284e+01 1.5189397693612446e+02 -1.8225441696827028e+02 - 42 2.3368235855950271e+01 1.1822246665265955e+02 4.1207745038608465e+02 - 43 -3.5145643416957128e+01 -3.6517162539675607e+00 2.4936784353003958e+02 - 44 -1.2879745401173426e+00 -2.4877345145177651e+02 7.9236449970532846e+01 - 45 2.0871643412343590e+02 -1.0817571271652029e+02 -4.1291831345583290e+02 - 46 -1.3836372705500636e+02 4.6117938292216792e+02 -2.4016736526257426e+02 - 47 1.3255125611053478e+02 2.8747591615862939e+02 -3.2895660248580036e+01 - 48 7.8145417759941688e+02 6.5214930060474302e+01 -6.2304930828901490e+02 - 49 2.4488281403350587e+02 1.9105496615734893e+01 3.7418605144315814e+02 - 50 2.9822129513623162e+02 3.0683153982649424e+02 5.6994490418787450e+02 - 51 -8.0058572063723739e+02 5.1028617285810617e+02 7.5832431569053767e+02 - 52 -9.2137024513584748e+01 1.1910687193191870e+02 -2.4119120858089093e+02 - 53 -3.6387082584370717e+02 -2.0729771077034724e+02 -3.4910499737703145e+02 - 54 -8.3401322475858819e+01 1.8942466656608883e+02 -1.2869045777950635e+02 - 55 -2.5309678413623661e+02 -1.1001947899860551e+02 -3.0896372370111590e+02 - 56 1.7364604573970860e+02 -2.5754429115057047e+02 -4.3743962049926409e+01 - 57 4.2666362581830975e+02 1.5528157995548534e+02 -3.9988032807883297e+02 - 58 -3.9656744873436978e+01 7.8953170998895359e+01 2.6135222052438655e+02 - 59 -2.7594581611220792e+02 1.9891770704106938e+02 2.4122933700028292e+02 - 60 -2.5675992319674720e+02 -1.1527235824442458e+02 9.9923831048598458e+01 - 61 3.0884428120727830e+02 4.9986711220603212e+02 -1.3369013376809971e+02 - 62 2.8530678742782751e+01 5.9283151666778267e-01 -2.7403002505086550e+02 - 63 2.5296775626792288e+02 -2.7640525289650611e+02 -1.9200401038421046e+02 - 64 -8.4674586435418931e+01 -1.5736397776818120e+02 1.5637348700606000e+02 + 1 -8.8486129396001502e+01 -2.5824483374473179e+01 1.0916517213634110e+02 + 2 -1.1227648453173391e+02 -1.8093214754186130e+02 -2.2420118533940348e+02 + 3 -1.7210894875994978e+02 1.8292263268451674e+02 1.3551979435686095e+01 + 4 3.2999405001009350e+01 -5.1077312719545880e+01 9.0478579144069585e+01 + 5 1.8144963583123231e+02 1.6798391906831846e+01 -8.1723378082075712e+01 + 6 1.3640835897739439e+02 -3.0059507544862095e+02 2.9594750460783359e+01 + 7 -5.3287619129789448e+01 -1.2872953167026756e+02 -1.6348317368624123e+02 + 8 -1.5334990952322434e+02 4.0171746946780829e+01 1.5317542403106131e+02 + 9 1.8362961213927182e+01 8.1984428717784269e+01 2.8273598253027302e+01 + 10 8.4245458094789058e+01 1.4177227430519352e+02 1.2329899933660965e+02 + 11 -4.3217035356344425e+01 6.5547850976510773e+01 1.3463983671946411e+02 + 12 -9.7319343004573128e+01 -2.6236499899232264e+01 7.2232061905742331e+00 + 13 -6.3184735475530417e+01 -4.7368090836538116e+01 -3.7590268076036132e+01 + 14 7.8642680121804005e+01 -6.7994653297646451e+01 -9.9042134233434012e+01 + 15 -6.6371195967082826e+01 2.1787700653339661e+02 8.0102624694807389e+01 + 16 1.9215832443892597e+02 5.3231888618093954e+01 6.6253846562695017e+01 + 17 1.4496126989603121e+02 -3.9700366098757279e+01 -9.7506725874209309e+01 + 18 -4.4989211400008635e+01 -1.9360716191976442e+02 1.1274798810455859e+02 + 19 2.6657546213782734e+02 3.7189369483257695e+02 -3.3847202166068030e+02 + 20 -7.6352829159880955e+01 -8.8469178952301633e+01 1.3384778817072787e+00 + 21 -7.1188597560667404e+01 -5.1592404200740077e+01 -1.2279357314243526e+02 + 22 1.5504965184741243e+02 -1.3094582932680530e+02 8.1473922626938020e+01 + 23 7.8017376001392918e+01 -1.3263023728607578e+01 -2.2771654676273979e+01 + 24 -2.0547634460482251e+02 2.1612342044348730e+02 -1.2423651650061711e+02 + 25 -1.1402944116091902e+02 1.9100648219391277e+02 -8.3505645569845370e+01 + 26 2.8664542299410527e+02 -2.1774609219880722e+02 2.3144720166994415e+02 + 27 -6.3243843868043086e+01 6.9123801262965259e+01 1.8607035157681676e+02 + 28 -3.5444604841998202e+00 3.8760531647714458e+01 3.2869123667281691e+01 + 29 -7.1069494158179211e+01 3.5486459158760596e+01 2.7311657876181030e+01 + 30 -1.7037059987992404e+02 -1.9851840131669360e+02 -1.1511410156295638e+02 + 31 -1.3970663440086005e+02 1.6660841802305001e+02 -1.2914070628112793e+02 + 32 2.7179939937138435e+01 -6.0162678551485499e+01 -1.7668459764117441e+02 + 33 -6.2659124615698147e+01 -6.4421915847941477e+01 6.4151176691093468e+01 + 34 -2.2118740875419469e+01 1.0450303589341145e+02 -7.3997370482692958e+01 + 35 2.6987081482968881e+02 -2.1523754104000349e+02 1.3052736086179610e+02 + 36 1.0368798521815542e+02 1.8816694370725344e+02 -1.9748485159172907e+02 + 37 -1.8012152564003850e+02 1.2997662140302853e+02 -6.3547259053587815e+01 + 38 -2.9571525697590823e+02 1.0441941743734586e+02 1.5582112543442355e+02 + 39 8.7399620724575229e+01 -6.0025787992411310e+01 2.2209357601282100e+01 + 40 2.0541458171950950e+01 -1.0735817059033015e+02 5.8656280350524284e+01 + 41 -5.8893965304899957e+01 1.1850504754314873e+01 -6.6138932259022440e+01 + 42 -9.6894702780992304e+01 3.8926449644174781e+01 -7.5794133002764809e+01 + 43 2.2475651760389385e+02 9.5503072846836503e+01 1.2308683766845402e+02 + 44 8.9821846939843127e+01 -1.0615882525757857e+02 -8.6326896770189890e+01 + 45 1.7193681344342274e+01 1.2889564928820624e+02 5.2922372841252461e+01 + 46 1.3549091739280328e+01 -2.9276447091757490e+01 2.2187152043656504e+01 + 47 3.3389460345593179e+01 -1.9217121673024417e+02 -6.9954603582952572e+01 + 48 7.3644268618852792e+01 -2.0953201921822824e+02 -2.3192562071413271e+01 + 49 -3.7593958318941031e+02 -2.4028439106859906e+01 1.0779151134441003e+02 + 50 3.8603926624328523e+01 -7.3615255297989492e+01 9.0412505212292430e+01 + 51 1.3736689552214156e+02 -1.0204490780187869e+02 1.5814099219652564e+02 + 52 -1.0797151154267748e+02 1.1876989597626186e+02 -1.3296150756377079e+02 + 53 -5.3843453069456565e+01 3.3257024143956778e+02 -2.3416395383840438e-02 + 54 -1.0678049522667443e+01 6.2807424617056597e+01 1.8344969045860518e+02 + 55 1.1232135576105661e+02 -1.7906994470561881e+02 7.6534265234548187e+01 + 56 -4.1035945990527694e+01 -1.4084577238065074e+02 3.7489705598247951e+01 + 57 9.9903872061946146e+01 7.0936213558024505e+01 -6.8656338416452499e+01 + 58 -2.7563844572724129e+01 -6.7426705471926915e+00 -1.8442803060445037e+01 + 59 -6.6637290503389465e+01 1.0613630918459928e+02 8.7741455199772943e+01 + 60 -1.7749706497437348e+01 6.3756413885635929e+01 -1.5086911682892702e+02 + 61 -3.3559889608749927e+01 -1.0076809277084796e+02 -7.4536003122046253e+01 + 62 1.5883833834736409e+01 -5.8439916924703361e+00 2.8393403991146915e+01 + 63 1.3294237052896716e+02 -1.2724619636183061e+02 -6.4882384014219113e+01 + 64 1.0738250214938944e+02 1.2062290362868877e+02 7.4541927445529197e+01 ... diff --git a/unittest/force-styles/tests/atomic-pair-reax_c_lgvdw.yaml b/unittest/force-styles/tests/atomic-pair-reax_c_lgvdw.yaml index bf71811de9..c766c242f9 100644 --- a/unittest/force-styles/tests/atomic-pair-reax_c_lgvdw.yaml +++ b/unittest/force-styles/tests/atomic-pair-reax_c_lgvdw.yaml @@ -1,11 +1,10 @@ --- -lammps_version: 10 Feb 2021 -date_generated: Fri Feb 26 23:09:06 2021 -epsilon: 2e-10 -skip_tests: omp +lammps_version: 2 Jul 2021 +date_generated: Wed Jul 21 15:49:47 2021 +epsilon: 1e-12 prerequisites: ! | - pair reax/c - fix qeq/reax + pair reaxff + fix qeq/reaxff pre_commands: ! | echo screen variable newton_pair delete @@ -15,159 +14,162 @@ pre_commands: ! | atom_style charge lattice diamond 3.77 region box block 0 2 0 2 0 2 - create_box 2 box + create_box 3 box create_atoms 1 box displace_atoms all random 0.1 0.1 0.1 623426 - mass 1 12.0 - mass 2 13.0 + mass 1 1.0 + mass 2 12.0 + mass 3 16.0 set type 1 type/fraction 2 0.5 998877 - set type 1 charge 0.01 - set type 2 charge -0.01 + set type 2 type/fraction 3 0.5 887766 + set type 1 charge 0.00 + set type 2 charge 0.01 + set type 3 charge -0.01 velocity all create 100 4534624 loop geom post_commands: ! | - fix qeq all qeq/reax 1 0.0 8.0 1.0e-12 reax/c + fix qeq all qeq/reaxff 1 0.0 8.0 1.0e-20 reaxff input_file: in.empty -pair_style: reax/c NULL checkqeq yes lgvdw yes safezone 1.6 +pair_style: reaxff NULL checkqeq yes lgvdw yes safezone 1.6 pair_coeff: ! | - * * ffield.reax.lg C O + * * ffield.reax.lg H C O extract: ! "" natoms: 64 -init_vdwl: -3780.05455778888 -init_coul: -279.915673357255 +init_vdwl: -2454.3149508399256 +init_coul: -344.1380904917976 init_stress: ! |2- - 3.6448951295886809e+03 3.7339747706707872e+03 3.9381618834038791e+03 -8.8619786783545931e+02 2.5350870087071300e+02 -5.2815321737906061e+02 + 4.8195587070292022e+03 4.4865954368949333e+03 3.2679588293062807e+03 -1.8469678134590695e+03 7.6556385424846383e+02 -4.9517278307742527e+02 init_forces: ! |2 - 1 -1.4572029645683264e+02 -2.2140279106291507e+02 -1.4808209307797372e+02 - 2 -1.7648559093934148e+02 -1.0146253457806542e+02 -1.7990394625657274e+01 - 3 -2.0615681734642330e+01 -4.0343795757803508e+02 -3.8603528931018054e+01 - 4 2.6614805335034998e+02 4.0003808276416684e+01 1.4690013778960667e+02 - 5 9.7835379063416177e+00 4.3883349405662791e+01 4.9796878717762787e+01 - 6 -2.6938292077229727e+02 3.3510334278335421e+00 2.2965715764113384e+02 - 7 3.2574907048037380e+02 -1.7976941537341810e+02 2.2179461677416583e+02 - 8 9.9964451146865471e+01 -2.8685082304987185e+02 1.4158552983794476e+02 - 9 1.6434754325282601e+01 -1.9355787416131696e+02 -9.4334270045756043e+01 - 10 -2.0854046881408067e+02 1.0026332198593936e+02 -1.5021108992594620e+02 - 11 -2.0573869228583661e+02 2.7604115414799344e+02 5.5777178022191936e+02 - 12 5.0287983468578147e+02 -6.0967301596834591e+02 3.9376960681073700e+02 - 13 -9.1248851272055674e+01 3.5482322889104140e+01 7.9771590707710800e+01 - 14 1.1722782444599024e+02 7.0786340536242163e+00 -1.1012937857655862e+02 - 15 2.0459798791677210e+02 1.1350278391711655e+01 -6.9643830810411416e+01 - 16 6.4801734481789666e+01 2.7717249468796996e+02 9.6968479199374073e+01 - 17 -1.1757359629210440e+02 7.5596700050451688e+01 8.2370289516995197e+00 - 18 1.4980090631536169e+02 4.6438235985629220e+01 1.9074239639237979e+02 - 19 9.9231823331994249e+01 -3.4161546701845765e+01 -9.3483634123621087e+01 - 20 3.4394881232874110e+02 1.8755825664166662e+02 1.8392127409682581e+02 - 21 -1.7639610172391272e+02 5.9887963695524753e+01 2.3192666899298981e+01 - 22 3.5943370198457734e+02 -4.9707358210204012e+02 2.0606470760846634e+02 - 23 1.7581454592506283e+01 2.1298589011272401e+02 1.9485076353331874e+02 - 24 -1.8644255768132263e+02 2.0152190140053236e+02 -1.5033309490489984e+02 - 25 6.6423577752363499e+01 -2.6628307450649118e+02 6.5041785228006987e+01 - 26 -2.9537785779457244e+02 1.8889631581804576e+02 8.6386764001190215e+01 - 27 1.0405918844455742e+02 -2.5941844595001200e+00 -6.3479328226780297e+01 - 28 -1.7940076477784703e+02 -1.9073773001560042e+02 -1.6921173789426470e+02 - 29 2.8517719341938289e+02 -9.8606325860704928e+01 -1.5865623093424992e+02 - 30 3.3012242903480393e-01 9.9396498728799443e+01 3.2850839694515677e+00 - 31 -1.8086381055199379e+00 -5.1096382098849077e+01 6.0017778789149006e+00 - 32 3.1529080422017097e+02 -1.2793618573898891e+02 -2.4176655958597905e+02 - 33 -5.4059845316529982e+00 1.7567793716993873e+02 -1.1807703472018468e+02 - 34 -1.9400422792080016e+02 -1.0951834015498645e+02 -1.5439493063315896e+02 - 35 -1.9195028872533084e+02 -1.2771069506738369e+01 1.3164511899864968e+02 - 36 2.1450496684040476e+02 4.8524211958783019e+02 -2.2938069671779124e+02 - 37 -3.3553470604466861e+02 -4.9645835564195778e+02 2.1990191695195585e+02 - 38 -3.2544634716452649e+01 2.4953051954442103e+01 -1.5693055302887637e+02 - 39 -1.5399380031833186e+01 2.3903552655945369e+01 9.6153869485537527e+01 - 40 -6.4358524883048119e+01 1.7841114478565163e+02 1.6199309566416363e+02 - 41 -2.4659875162869224e+02 2.3085714222291421e+02 -2.9640003056844074e+02 - 42 -2.9451816756430145e+02 4.3373137951523881e+02 4.3706447002809585e+02 - 43 1.3265813359025546e+02 -2.9267792386382844e+01 2.3063687596593061e+02 - 44 1.0054916914535585e+02 -2.0011423542533092e+02 1.1673423852526635e+02 - 45 1.5191419311763582e+02 -3.3909681846522182e+02 -6.8137727102148324e+02 - 46 -3.6974683734054048e+02 6.5878375129662163e+02 -1.2846618277461354e+02 - 47 7.0999436005486899e+01 2.6787204282530024e+02 -2.6037631699380153e+01 - 48 4.8459114652542161e+02 -1.6692984322713417e+02 -3.2654222496284581e+02 - 49 1.0015069521843192e+02 1.7138648274496632e+01 1.2769578723947120e+02 - 50 -2.5642349862470508e+02 4.8550182268850142e+02 1.7833824453195746e+02 - 51 1.5929454215699664e+03 -1.5099874513231559e+03 1.3757379604584460e+03 - 52 -3.9361841716365302e+02 2.9260629050190221e+02 -2.7081695001177656e+02 - 53 -1.2156822810124922e+03 1.0481194207223216e+03 -1.7260439380729260e+03 - 54 5.4550048561223889e+01 1.0309107570306772e+02 -6.1755737140629734e+01 - 55 -2.0237966584139775e+02 1.8109638545320627e+02 -4.9049185930881845e+02 - 56 2.0035852288703015e+02 -1.8905601495144680e+02 -1.3674988378339864e+02 - 57 -1.7850181832398803e+02 -3.3738128559238868e+02 -1.4864548151794997e+02 - 58 -2.5672973403862750e+02 -1.3337752501158548e+02 8.4361840521538781e+01 - 59 -1.7898419258529674e+02 1.8142061294130923e+02 2.7914590931082478e+02 - 60 -7.4397281468755821e+01 -6.8191313100547362e+01 5.7945873657168903e+01 - 61 9.6097455977519928e+01 4.4560160451051973e+02 5.3539867605744419e+01 - 62 3.3100209418397625e+01 1.3292271559420541e+02 -3.6118667405609742e+01 - 63 -2.5659895412732226e+01 -3.1619326785330378e+02 5.0013180663156710e+01 - 64 2.5886074093968855e+01 -6.0852122206871925e+01 7.5059691631914314e+00 -run_vdwl: -3780.05347390992 -run_coul: -279.915602843914 + 1 -1.9811664067580179e+02 -1.5618748554879582e+02 -1.0716617094919901e+02 + 2 -4.1075966889759549e+01 -6.7708246449675826e+01 -4.2506724189242625e+01 + 3 3.1596544789529435e+01 8.8571277602644230e+01 1.4850846557451499e+02 + 4 1.7447178183928099e+02 3.2866954415453542e+01 -3.1178861314762706e+01 + 5 1.1873199005659021e+02 5.9095115842131932e+01 2.3739439807686179e+02 + 6 1.3052453610124783e+03 -4.4208109447713036e+02 -1.4245452171137993e+03 + 7 -8.7153363585941023e+01 -1.0895261162467335e+02 -3.5604687372058106e+02 + 8 -9.1047579854191568e+01 4.4450937169776367e+01 1.1879559986803960e+02 + 9 4.7456602925193202e+01 1.7227642506022178e+02 -1.4638226748446902e+01 + 10 6.3508986324759796e+01 4.8590610415561791e+01 1.1075535682642935e+01 + 11 -5.1919052217198654e+01 7.3820742396411859e+01 5.1375340691983297e+01 + 12 -1.0171933720752882e+02 -1.9845958414353014e+01 -1.7437665462751710e+01 + 13 -7.3048376131504796e+01 -4.5586627360377697e+01 2.8533062846208718e+01 + 14 8.6287140258369817e+01 -4.1664353236768306e+01 1.7094340432182349e+01 + 15 -3.5690271737605421e+01 1.2671711108383721e+02 4.5865072089126137e+01 + 16 1.0608232372370769e+02 3.5980003156299816e+01 1.8676593635940495e+01 + 17 2.3577630118103411e+02 -9.8579505236746911e+01 4.1005658232556200e+01 + 18 -2.0815299273687735e+01 -1.1578579968450295e+02 6.5566787154472507e+01 + 19 4.3265264076046989e+01 1.0913234729250236e+02 3.0900987497773690e+02 + 20 -1.0086773950039242e+02 7.4841212143883340e+01 -1.6547856280073117e+02 + 21 -8.5974538718179744e+01 -4.5982868874733214e+00 -7.3066508052444064e+01 + 22 1.3343492132570225e+02 -1.2211943449611955e+02 9.0328124087551771e+01 + 23 5.2985077374887155e+01 2.0040750326966961e+01 -9.0416982004666124e+00 + 24 -1.8957025969382852e+02 8.1671696884795935e+01 -1.2920621849543528e+01 + 25 -1.0067836293726948e+02 1.3220054680372053e+02 -4.8975895235994550e+01 + 26 2.1849478729429609e+02 -1.9386903120078870e+02 1.7116657218419911e+02 + 27 -3.7478069218092713e+01 3.0044804022729696e+01 9.3872627169948643e+01 + 28 9.9359193467603504e+01 -5.5156189036814489e+01 -3.1541196450035862e+01 + 29 -3.9530012231991570e+01 5.6689953230829886e+01 2.5358584427671758e+01 + 30 -9.7652246814367359e+01 -2.2271920242502716e+02 -1.4460601547049507e+02 + 31 -4.6192346966779525e+01 7.2790084189834928e+01 3.1159158603346764e+01 + 32 1.2013060628467285e+01 -3.4474347848945321e+01 -1.0622600014669140e+02 + 33 5.2551051115345523e+01 4.2704675585248637e+01 -3.0154896799401911e+01 + 34 1.6822864099952500e+02 -1.6889974455004834e-02 1.1832622696299902e+02 + 35 5.1185090023661456e+02 -1.3214021604987863e+03 1.1319907541000696e+03 + 36 -1.4331382529302426e+01 9.9702896436313011e+01 -1.3159358421899239e+02 + 37 -8.9317756897655045e+02 1.3544128453102783e+03 -7.5922493710251524e+02 + 38 -3.8384748878233427e+02 1.2143676601363948e+02 1.7580047976723321e+02 + 39 1.6381134310552267e+02 -1.2998574463953721e+01 -7.8542909545441532e+01 + 40 6.1412235617277204e+01 -2.0153615037331058e+01 4.3186957794586569e+01 + 41 1.3114484088383939e+01 1.7854214885793560e+00 3.3683765652624942e+01 + 42 -6.4838533708029473e+01 5.2662237041257001e+01 -6.8645855319469405e+01 + 43 2.0925885626252014e+02 8.2942516657430232e+01 1.1786724503954686e+02 + 44 -3.8463410277622415e+01 -7.5319916775508815e+01 -1.3445887472637642e+02 + 45 -3.4797907366084097e+01 7.6266761873332939e+01 4.3023416525122514e+01 + 46 2.3463432665038606e+01 -1.5313857576705701e+01 -3.8707451594223872e+00 + 47 -3.7271493199629653e+01 -5.4876511333920178e+01 -1.9275411927395869e+01 + 48 2.8275275023555378e+02 -1.7973942289882839e+02 -6.0167953907638991e+02 + 49 -2.0529905689923417e+03 -6.7838314309842517e+01 7.6230272883402574e+02 + 50 1.3292222637274611e+02 -9.8795036249084106e+01 9.9132259532945980e+01 + 51 2.6168921895029303e+02 -1.9761595427509062e+02 2.4062513751852873e+02 + 52 -1.2257063176561179e+02 1.3353869954874421e+02 -1.1598337420807965e+02 + 53 3.8021621191835851e+02 8.1199705966172485e+02 2.7057346247419935e+02 + 54 6.9440336670547069e+01 -1.1592524541887394e+02 2.2072297942372259e+02 + 55 8.7300666059627744e+01 -1.3907353173150562e+02 5.9541107879138558e+01 + 56 3.4771676857170337e+02 -2.4546959502036671e+02 -3.5077189358394361e+02 + 57 6.1706174952483430e+01 7.9893925286373715e+01 3.4373445887630369e+00 + 58 3.7240798760941445e+01 -1.2919400623491822e+02 3.9695110774075808e+01 + 59 -5.2076445103995343e+02 2.1046582886974139e+02 1.7083299176148785e+02 + 60 -7.8657547105875310e+01 -2.3005356890255410e+01 -1.2454833328198774e+02 + 61 -3.9633103573229910e+01 -5.5165443660352402e+01 -4.0780192434587690e+01 + 62 -1.8742346202622748e+01 -1.3844690899539831e+01 2.2586546200036359e+00 + 63 6.5150947885422283e+01 7.1009493033300544e+01 -8.4093092375006009e+01 + 64 4.0079516427458060e+01 9.6476598333945972e+01 9.1213458480138428e+01 +run_vdwl: -2454.3233099608155 +run_coul: -344.1379608070739 run_stress: ! |2- - 3.6449190860682643e+03 3.7339547135739058e+03 3.9381731084171565e+03 -8.8617648240339543e+02 2.5350122212091981e+02 -5.2818520710537973e+02 + 4.8194587329953692e+03 4.4865895224706946e+03 3.2679446938086485e+03 -1.8471163065259320e+03 7.6545324620049041e+02 -4.9527853267789004e+02 run_forces: ! |2 - 1 -1.4571798162167252e+02 -2.2140580848061688e+02 -1.4808148933254313e+02 - 2 -1.7648308397779235e+02 -1.0146477741996672e+02 -1.7988558948131221e+01 - 3 -2.0614227228633823e+01 -4.0344097417855238e+02 -3.8604729133131215e+01 - 4 2.6614888483484418e+02 4.0003234613562718e+01 1.4690057491500562e+02 - 5 9.7845353993210757e+00 4.3882567909729040e+01 4.9797207642045677e+01 - 6 -2.6938082734775594e+02 3.3524823444182630e+00 2.2965816523899235e+02 - 7 3.2575187542507791e+02 -1.7977227944937169e+02 2.2179960580675152e+02 - 8 9.9964011515726739e+01 -2.8685358089601482e+02 1.4158731106157231e+02 - 9 1.6438524923736644e+01 -1.9355302991489253e+02 -9.4334960672514242e+01 - 10 -2.0853805940018381e+02 1.0026019274304203e+02 -1.5021521543813694e+02 - 11 -2.0574133907407125e+02 2.7604371539616938e+02 5.5777225388303532e+02 - 12 5.0285711778760270e+02 -6.0968357929450372e+02 3.9377681166481295e+02 - 13 -9.1246236584998883e+01 3.5490065792296186e+01 7.9756754045764964e+01 - 14 1.1722762015217488e+02 7.0777587800518864e+00 -1.1012808747152181e+02 - 15 2.0459886374792103e+02 1.1352434902632419e+01 -6.9641008537041586e+01 - 16 6.4819488894277626e+01 2.7717767285477504e+02 9.6971206512117831e+01 - 17 -1.1757145373858191e+02 7.5598283763031333e+01 8.2344537953401620e+00 - 18 1.4979763484000514e+02 4.6437981230754680e+01 1.9074030927267040e+02 - 19 9.9232177039551743e+01 -3.4161491191063057e+01 -9.3482743694123911e+01 - 20 3.4394272911489560e+02 1.8755951153575882e+02 1.8391751542140381e+02 - 21 -1.7639675023083032e+02 5.9884188602876513e+01 2.3197830826168012e+01 - 22 3.5944608335498276e+02 -4.9708524898876021e+02 2.0607149093293810e+02 - 23 1.7579271068638736e+01 2.1298728097754687e+02 1.9485168054795750e+02 - 24 -1.8644003680983860e+02 2.0152727772546126e+02 -1.5032646302314092e+02 - 25 6.6427890225862839e+01 -2.6628950112809588e+02 6.5040867172812568e+01 - 26 -2.9538210986747896e+02 1.8889963664467763e+02 8.6392520853920516e+01 - 27 1.0405463527343457e+02 -2.5883797810836899e+00 -6.3473815684801785e+01 - 28 -1.7939102939145226e+02 -1.9072998240489997e+02 -1.6920314161246782e+02 - 29 2.8518125846098656e+02 -9.8610707014135585e+01 -1.5865904861816750e+02 - 30 3.2948855593638848e-01 9.9396107066086955e+01 3.2866521919189089e+00 - 31 -1.8093342589558659e+00 -5.1090324665848712e+01 5.9965783206663161e+00 - 32 3.1528757881180007e+02 -1.2794634397194349e+02 -2.4177668881260021e+02 - 33 -5.4083133243805372e+00 1.7567908978406618e+02 -1.1807415000724265e+02 - 34 -1.9400316636479977e+02 -1.0951814437454595e+02 -1.5439329543504013e+02 - 35 -1.9195026719711194e+02 -1.2774392196243292e+01 1.3164394415174289e+02 - 36 2.1450819558036866e+02 4.8524393939315888e+02 -2.2938259760791684e+02 - 37 -3.3553755452540895e+02 -4.9646067746196536e+02 2.1990265059231979e+02 - 38 -3.2545680671007766e+01 2.4954714465771517e+01 -1.5693304654702996e+02 - 39 -1.5400979972013733e+01 2.3902925031181187e+01 9.6154974338013474e+01 - 40 -6.4361324286781183e+01 1.7841294566727018e+02 1.6199313424706546e+02 - 41 -2.4660579832547052e+02 2.3084997378288404e+02 -2.9640187773211630e+02 - 42 -2.9452038269198692e+02 4.3373690323403952e+02 4.3706797334309402e+02 - 43 1.3265462163819998e+02 -2.9274830054471895e+01 2.3064015623266641e+02 - 44 1.0054965815688162e+02 -2.0011417092775127e+02 1.1673395109270328e+02 - 45 1.5191488778751707e+02 -3.3909986813212635e+02 -6.8138447286529720e+02 - 46 -3.6974585651662977e+02 6.5877949821504194e+02 -1.2846140462208882e+02 - 47 7.0999522650120099e+01 2.6787232844301741e+02 -2.6037434470741427e+01 - 48 4.8457875917949451e+02 -1.6693867974736796e+02 -3.2653088508349691e+02 - 49 1.0016330847216284e+02 1.7144939472474533e+01 1.2769410377207676e+02 - 50 -2.5643045293874383e+02 4.8550578070475757e+02 1.7833571905770887e+02 - 51 1.5929685733709441e+03 -1.5100179731534890e+03 1.3757557210338409e+03 - 52 -3.9363155553927618e+02 2.9261413115276798e+02 -2.7081680938457316e+02 - 53 -1.2156938822751686e+03 1.0481428026908065e+03 -1.7260661331518384e+03 - 54 5.4545508362448210e+01 1.0309421723440155e+02 -6.1761185913629610e+01 - 55 -2.0239005919386466e+02 1.8108787078448725e+02 -4.9048334046900078e+02 - 56 2.0036614412052225e+02 -1.8905881350356012e+02 -1.3675071587645911e+02 - 57 -1.7850227402751372e+02 -3.3738314148552627e+02 -1.4864701622354673e+02 - 58 -2.5670676029812597e+02 -1.3336092440092364e+02 8.4345104538588089e+01 - 59 -1.7898804840101980e+02 1.8142384187504891e+02 2.7914484812152023e+02 - 60 -7.4398955008919714e+01 -6.8191485113974892e+01 5.7946912127557717e+01 - 61 9.6097667682189197e+01 4.4562130970058109e+02 5.3555842003747642e+01 - 62 3.3087710298162186e+01 1.3291451685900134e+02 -3.6140086918051345e+01 - 63 -2.5660817878335301e+01 -3.1619388904758910e+02 5.0012563149825205e+01 - 64 2.5890372243019073e+01 -6.0849122994338025e+01 7.5030153780264586e+00 + 1 -1.9811556407056102e+02 -1.5618143620847070e+02 -1.0716119874908739e+02 + 2 -4.1073968384374822e+01 -6.7710647015369261e+01 -4.2502864658157385e+01 + 3 3.1592798331689583e+01 8.8575236369726497e+01 1.4850890801985437e+02 + 4 1.7447282006187959e+02 3.2862369867970457e+01 -3.1175721266394834e+01 + 5 1.1873112974792329e+02 5.9090963929048314e+01 2.3738916225937453e+02 + 6 1.3053008444613586e+03 -4.4210323642713996e+02 -1.4246081409032695e+03 + 7 -8.7152343512651953e+01 -1.0895314566818776e+02 -3.5604721285130660e+02 + 8 -9.1046846091347703e+01 4.4451665481009499e+01 1.1879618751723051e+02 + 9 4.7463133585713919e+01 1.7228438483982211e+02 -1.4645071927693349e+01 + 10 6.3506921990797963e+01 4.8587688349158142e+01 1.1073324095443047e+01 + 11 -5.1917951887543467e+01 7.3818630188510312e+01 5.1369234828489176e+01 + 12 -1.0172154753205889e+02 -1.9847809999838830e+01 -1.7441731987232995e+01 + 13 -7.3048126072731876e+01 -4.5586545373889699e+01 2.8534758158919548e+01 + 14 8.6288077929554404e+01 -4.1660634795038867e+01 1.7096747148188040e+01 + 15 -3.5688114877422024e+01 1.2671728980619932e+02 4.5864235397118847e+01 + 16 1.0608395201173666e+02 3.5983845233526999e+01 1.8672925070386196e+01 + 17 2.3576828121395238e+02 -9.8577850318505440e+01 4.1004495565128614e+01 + 18 -2.0815095995902730e+01 -1.1578710179047432e+02 6.5566934287391277e+01 + 19 4.3264252619509840e+01 1.0912982970441865e+02 3.0901253523346554e+02 + 20 -1.0088948935029293e+02 7.4849484282711913e+01 -1.6550538409007382e+02 + 21 -8.5974038585183081e+01 -4.5987854992617692e+00 -7.3065890363335626e+01 + 22 1.3343130763213867e+02 -1.2211553430043763e+02 9.0325064574872258e+01 + 23 5.2984912690315262e+01 2.0042805349785073e+01 -9.0417924141684995e+00 + 24 -1.8954830238390488e+02 8.1645824240163975e+01 -1.2893974448861021e+01 + 25 -1.0068116183998590e+02 1.3220505876703564e+02 -4.8977129584747814e+01 + 26 2.1847179335289815e+02 -1.9385136258527231e+02 1.7114800244815055e+02 + 27 -3.7476307441658179e+01 3.0046433191315703e+01 9.3873685757283724e+01 + 28 9.9355970623229169e+01 -5.5158350569168121e+01 -3.1544144508393824e+01 + 29 -3.9530224377035040e+01 5.6690552166969916e+01 2.5358784555346112e+01 + 30 -9.7652510697052577e+01 -2.2271892169387456e+02 -1.4460597467192858e+02 + 31 -4.6194950503295701e+01 7.2792554749932393e+01 3.1151667586195508e+01 + 32 1.2014466624027643e+01 -3.4469133688337770e+01 -1.0621837802800977e+02 + 33 5.2553699854339705e+01 4.2706400148046903e+01 -3.0154323622364597e+01 + 34 1.6822906612351349e+02 -1.7651825961909302e-02 1.1832699040444521e+02 + 35 5.1193507571856611e+02 -1.3215008853106001e+03 1.1320319719742361e+03 + 36 -1.4340338085502884e+01 9.9690347849156851e+01 -1.3158127406978679e+02 + 37 -8.9323390159980192e+02 1.3545163222654817e+03 -7.5929442355796743e+02 + 38 -3.8384755818822509e+02 1.2143789174035302e+02 1.7579570815453908e+02 + 39 1.6381197094628516e+02 -1.2998258674043829e+01 -7.8543109639931160e+01 + 40 6.1411228642100035e+01 -2.0154566391139259e+01 4.3186834298875652e+01 + 41 1.3119781105415534e+01 1.7920555043075754e+00 3.3686007139293856e+01 + 42 -6.4838490750749202e+01 5.2660553302313680e+01 -6.8647362072367542e+01 + 43 2.0926308211689772e+02 8.2945847275902722e+01 1.1786850503407652e+02 + 44 -3.8461829626420936e+01 -7.5317323697263234e+01 -1.3445959877777375e+02 + 45 -3.4805239678702840e+01 7.6262295586966090e+01 4.3024220690600863e+01 + 46 2.3465031078234958e+01 -1.5312554894709733e+01 -3.8725170500358588e+00 + 47 -3.7271036720207924e+01 -5.4879638482209749e+01 -1.9275876359755912e+01 + 48 2.8270391245290489e+02 -1.7971102191169686e+02 -6.0165064633346822e+02 + 49 -2.0529526126133587e+03 -6.7744467074995427e+01 7.6241869031244289e+02 + 50 1.3291615685330387e+02 -9.8801239572742261e+01 9.9131933784099587e+01 + 51 2.6169570171244874e+02 -1.9762541199560968e+02 2.4063463246277209e+02 + 52 -1.2256816067286560e+02 1.3353356136884042e+02 -1.1597765595389475e+02 + 53 3.8012282364003789e+02 8.1194045374755683e+02 2.7050484440708351e+02 + 54 6.9456553969440762e+01 -1.1593864337324271e+02 2.2074869335520950e+02 + 55 8.7303368709848343e+01 -1.3907755259033479e+02 5.9542185087028599e+01 + 56 3.4769731101937145e+02 -2.4546533348164240e+02 -3.5075782168770780e+02 + 57 6.1706155820465291e+01 7.9892471516403972e+01 3.4375912204692454e+00 + 58 3.7237511516193933e+01 -1.2919240641738722e+02 3.9695822512620310e+01 + 59 -5.2071132643271164e+02 2.1045883047165898e+02 1.7082619476821390e+02 + 60 -7.8658294909200450e+01 -2.3007149625533501e+01 -1.2454738729229325e+02 + 61 -3.9624794908666537e+01 -5.5169201638846069e+01 -4.0777145486525072e+01 + 62 -1.8741606623350247e+01 -1.3845552517299250e+01 2.2601936169388566e+00 + 63 6.5142845574860644e+01 7.0992677773634597e+01 -8.4109461087571191e+01 + 64 4.0079794681812906e+01 9.6475030340595453e+01 9.1215541718322228e+01 ... diff --git a/unittest/force-styles/tests/atomic-pair-reax_c_noqeq.yaml b/unittest/force-styles/tests/atomic-pair-reax_c_noqeq.yaml index 8f4b8b81c3..de9527d99e 100644 --- a/unittest/force-styles/tests/atomic-pair-reax_c_noqeq.yaml +++ b/unittest/force-styles/tests/atomic-pair-reax_c_noqeq.yaml @@ -1,10 +1,9 @@ --- -lammps_version: 10 Feb 2021 -date_generated: Fri Feb 26 23:09:08 2021 +lammps_version: 2 Jul 2021 +date_generated: Wed Jul 21 15:49:48 2021 epsilon: 5e-13 -skip_tests: omp prerequisites: ! | - pair reax/c + pair reaxff pre_commands: ! | echo screen variable newton_pair delete @@ -25,147 +24,147 @@ pre_commands: ! | velocity all create 100 4534624 loop geom post_commands: ! "" input_file: in.empty -pair_style: reax/c NULL checkqeq no +pair_style: reaxff NULL checkqeq no pair_coeff: ! | * * ffield.reax.mattsson C C extract: ! "" natoms: 64 -init_vdwl: -8975.38106346063 -init_coul: 0.592852986871656 +init_vdwl: -8975.381063460629 +init_coul: 0.5928529868716559 init_stress: ! |- - -1.1526162173764681e+03 -4.6218014500723507e+02 3.1954383274884901e+02 -2.2197591028227616e+03 3.4480244373669785e+02 -1.2644452447488200e+03 + -1.1526162173764687e+03 -4.6218014500723211e+02 3.1954383274884714e+02 -2.2197591028227603e+03 3.4480244373669649e+02 -1.2644452447488172e+03 init_forces: ! |2 - 1 -2.0916057489019278e+02 -1.8819573882656792e+02 -2.2843342560290171e+02 - 2 -5.9711660034805291e+01 -1.3795294129596448e+02 -6.1450415050409106e+01 - 3 1.0924699545317881e+02 5.4683388561496884e+01 8.7122903226954129e+00 - 4 2.2394129214932286e+02 -1.2607110719575815e+02 5.6116628706921283e+01 - 5 2.1339173392425103e+01 2.3982132147793212e+02 -1.1311227256425612e+02 - 6 -2.3465218593173694e+02 8.7997863600775148e+01 7.1405034243397978e+01 - 7 1.7783507933620086e+02 3.8498185748852222e+01 -2.7669272643606155e+02 - 8 -2.1014288646597468e+01 -4.0711968506334620e+02 1.5140757706928005e+02 - 9 -5.9307137188585735e+01 2.6264734812019469e+02 1.7442573676385443e+01 - 10 -8.4525778086876372e+01 1.5450140994331881e+02 6.0015146335720981e+00 - 11 -1.1159775028831375e+02 1.8656236384929730e+02 3.4449805909515084e+02 - 12 3.3347376393571255e+02 -3.8243903563632881e+02 5.1141444486612528e+01 - 13 -3.9347479057410175e+02 -9.9340014971740487e+01 2.4784035090896253e+02 - 14 1.7611459182140416e+02 -2.8017601742944402e+02 -2.7997644562222024e+02 - 15 2.5245744141516636e+02 -5.4739900421247576e+01 -1.3455773775633745e+02 - 16 1.6595098746018405e+02 1.6278076690062335e+02 4.2176787064349710e+01 - 17 4.0560547690525915e+01 2.0278202415209444e+02 1.1655337573721710e+02 - 18 1.9349019934523830e+02 -3.1749998507536635e+01 -3.0048600991173725e+01 - 19 -5.9067561742604568e+01 1.7643823088626270e+01 -1.0450409059207502e+02 - 20 1.3106558748347643e+02 2.5186173846559516e+01 1.3540015692568889e+02 - 21 -3.2006237187616756e+02 -1.1510771805635616e+02 -2.5816513201572068e+01 - 22 -1.2737471666033539e+01 -1.3033080251953407e+02 -1.4399680837176066e+02 - 23 -1.0142123148353758e+02 2.3316671624708323e+02 2.3905950409694179e+02 - 24 4.1563056415358169e+01 -1.2911164666848796e+01 -3.1668646816892700e+01 - 25 2.1166667371090460e+02 -2.0418293867725825e+02 -3.1232107629433731e+01 - 26 -2.6320989589682608e+02 1.2065128452552987e+02 2.6277305997802796e+02 - 27 -7.4498892273813865e+01 1.0778676260209129e+02 1.6095170163345196e+02 - 28 -2.4911277843488330e+02 -9.8499434443852323e+01 2.2239731087969662e+02 - 29 4.5655943120047868e+02 -5.6181584973687457e+01 -2.7582701917178326e+02 - 30 -1.1441865289035461e+02 5.2275082681973409e+01 -1.7193995473573816e+02 - 31 -1.8373014671249769e+02 -1.0039330382749462e+02 -9.6978960598961947e+01 - 32 1.5285998335729258e+02 -1.2909970668700703e+02 -1.8526770753201481e+02 - 33 2.0676721005976013e+01 3.7957156269713232e+02 -3.0331770321178414e+01 - 34 -1.8483566994370270e+02 -8.4859568901690906e+01 -1.0334717791993535e+02 - 35 -4.3920895665271935e+01 1.3832065189158040e+00 3.2302673529697479e+01 - 36 6.0407395927653840e+02 6.3222430241983602e+02 -1.5530384927410198e+01 - 37 -1.7704334275340958e+02 -3.4711199127962510e+02 2.0757920588578631e+02 - 38 -1.5990280705026578e+02 3.4383476554695548e+01 -1.1348860416567172e+02 - 39 1.2481780186485386e+02 3.1854282379699551e+01 2.4141006149778542e+02 - 40 -3.3952439214884555e+02 -5.2081203805390805e+02 -3.2749145453037904e+01 - 41 1.5953768898032129e+01 -2.5259433402085026e+01 -6.0977489335468213e+01 - 42 -3.5152692860571921e+02 1.0103192674618649e+02 1.0057493004151380e+02 - 43 1.8325251692529525e+02 -1.7843397924740284e+01 3.5813821983655600e+01 - 44 -1.7148730839833942e+02 6.5823249480752622e+01 -3.9043544554425509e+01 - 45 6.8021934986582622e+01 -5.2957926506736321e+01 -1.1278207528809645e+02 - 46 -1.9814589514445538e+02 3.1899128186018817e+02 -1.7125192460144410e+02 - 47 2.3518092199846146e+02 1.7325250425397039e+02 -4.6491315549358909e+01 - 48 -7.0934283327750434e+00 -2.1510500994703639e+02 2.8256786369777672e+02 - 49 2.4924479910930853e+02 -2.5977407369868601e+01 -1.9539857038363738e+02 - 50 9.0194565818523955e+01 2.6674460312457484e+02 4.8188042682115714e+01 - 51 2.7001317908987642e+02 -2.5024437918679871e+02 3.3082272466414395e+02 - 52 2.6770006025654067e+02 -1.3486195976744685e+02 -1.0999251813934440e+02 - 53 -3.0038447974652507e+02 1.7427208891886863e+02 -2.8369940533043155e+02 - 54 -1.8044322949045332e+02 3.2006167622599366e+02 -2.1986764638272368e+02 - 55 -6.7026995338193800e+01 2.8420556560193825e+02 -1.8256943632991815e+02 - 56 -9.3944897793228427e+02 7.6593871052490795e+02 -4.5872941120666036e+02 - 57 -2.7671724574062154e+01 -1.7257977562305285e+02 -1.6210118849324644e+02 - 58 7.1032070297632515e+02 -8.0881938208311499e+02 4.6676948457734852e+02 - 59 1.5682857500225748e+02 5.9891527233627251e+01 1.2646558890105979e+02 - 60 9.4076874705709940e+01 -1.1749874299724539e+02 -2.9919368333582653e+01 - 61 -4.8945763699767674e+01 1.6634783727405593e+02 6.7645978441449785e+01 - 62 1.6618577867039602e+02 7.3503605317082460e+01 2.2193892218236812e+02 - 63 4.6491757293229652e+00 -3.5581179274724047e+02 -3.8944419279304846e+01 - 64 -2.0021113303887086e+02 -1.1223202348830976e+02 3.0276216112541510e+02 -run_vdwl: -8975.38042076783 -run_coul: 0.592853076313598 + 1 -2.0916057489019281e+02 -1.8819573882656800e+02 -2.2843342560290168e+02 + 2 -5.9711660034805249e+01 -1.3795294129596448e+02 -6.1450415050409148e+01 + 3 1.0924699545317881e+02 5.4683388561496862e+01 8.7122903226952957e+00 + 4 2.2394129214932281e+02 -1.2607110719575809e+02 5.6116628706921283e+01 + 5 2.1339173392425174e+01 2.3982132147793220e+02 -1.1311227256425610e+02 + 6 -2.3465218593173694e+02 8.7997863600775275e+01 7.1405034243397949e+01 + 7 1.7783507933620086e+02 3.8498185748852151e+01 -2.7669272643606143e+02 + 8 -2.1014288646597382e+01 -4.0711968506334631e+02 1.5140757706927999e+02 + 9 -5.9307137188585777e+01 2.6264734812019475e+02 1.7442573676385468e+01 + 10 -8.4525778086876414e+01 1.5450140994331875e+02 6.0015146335721816e+00 + 11 -1.1159775028831368e+02 1.8656236384929727e+02 3.4449805909515095e+02 + 12 3.3347376393571255e+02 -3.8243903563632887e+02 5.1141444486612457e+01 + 13 -3.9347479057410180e+02 -9.9340014971740459e+01 2.4784035090896259e+02 + 14 1.7611459182140419e+02 -2.8017601742944402e+02 -2.7997644562222013e+02 + 15 2.5245744141516630e+02 -5.4739900421247519e+01 -1.3455773775633745e+02 + 16 1.6595098746018419e+02 1.6278076690062332e+02 4.2176787064349682e+01 + 17 4.0560547690525858e+01 2.0278202415209441e+02 1.1655337573721701e+02 + 18 1.9349019934523832e+02 -3.1749998507536677e+01 -3.0048600991173775e+01 + 19 -5.9067561742604539e+01 1.7643823088626213e+01 -1.0450409059207507e+02 + 20 1.3106558748347641e+02 2.5186173846559530e+01 1.3540015692568889e+02 + 21 -3.2006237187616756e+02 -1.1510771805635612e+02 -2.5816513201572022e+01 + 22 -1.2737471666033581e+01 -1.3033080251953402e+02 -1.4399680837176064e+02 + 23 -1.0142123148353754e+02 2.3316671624708317e+02 2.3905950409694182e+02 + 24 4.1563056415358190e+01 -1.2911164666848924e+01 -3.1668646816892771e+01 + 25 2.1166667371090466e+02 -2.0418293867725822e+02 -3.1232107629433731e+01 + 26 -2.6320989589682620e+02 1.2065128452552996e+02 2.6277305997802802e+02 + 27 -7.4498892273813851e+01 1.0778676260209129e+02 1.6095170163345199e+02 + 28 -2.4911277843488335e+02 -9.8499434443852294e+01 2.2239731087969656e+02 + 29 4.5655943120047868e+02 -5.6181584973687627e+01 -2.7582701917178315e+02 + 30 -1.1441865289035459e+02 5.2275082681973402e+01 -1.7193995473573804e+02 + 31 -1.8373014671249769e+02 -1.0039330382749465e+02 -9.6978960598961947e+01 + 32 1.5285998335729258e+02 -1.2909970668700709e+02 -1.8526770753201484e+02 + 33 2.0676721005976084e+01 3.7957156269713232e+02 -3.0331770321178464e+01 + 34 -1.8483566994370267e+02 -8.4859568901690949e+01 -1.0334717791993538e+02 + 35 -4.3920895665272049e+01 1.3832065189158744e+00 3.2302673529697394e+01 + 36 6.0407395927653863e+02 6.3222430241983591e+02 -1.5530384927410136e+01 + 37 -1.7704334275340958e+02 -3.4711199127962510e+02 2.0757920588578634e+02 + 38 -1.5990280705026572e+02 3.4383476554695449e+01 -1.1348860416567172e+02 + 39 1.2481780186485392e+02 3.1854282379699594e+01 2.4141006149778536e+02 + 40 -3.3952439214884566e+02 -5.2081203805390805e+02 -3.2749145453037933e+01 + 41 1.5953768898032115e+01 -2.5259433402084984e+01 -6.0977489335468270e+01 + 42 -3.5152692860571921e+02 1.0103192674618646e+02 1.0057493004151388e+02 + 43 1.8325251692529523e+02 -1.7843397924740334e+01 3.5813821983655501e+01 + 44 -1.7148730839833948e+02 6.5823249480752679e+01 -3.9043544554425530e+01 + 45 6.8021934986582622e+01 -5.2957926506736349e+01 -1.1278207528809644e+02 + 46 -1.9814589514445535e+02 3.1899128186018834e+02 -1.7125192460144413e+02 + 47 2.3518092199846154e+02 1.7325250425397039e+02 -4.6491315549358909e+01 + 48 -7.0934283327749368e+00 -2.1510500994703631e+02 2.8256786369777683e+02 + 49 2.4924479910930842e+02 -2.5977407369868608e+01 -1.9539857038363732e+02 + 50 9.0194565818523870e+01 2.6674460312457489e+02 4.8188042682115714e+01 + 51 2.7001317908987642e+02 -2.5024437918679871e+02 3.3082272466414389e+02 + 52 2.6770006025654061e+02 -1.3486195976744682e+02 -1.0999251813934431e+02 + 53 -3.0038447974652496e+02 1.7427208891886863e+02 -2.8369940533043155e+02 + 54 -1.8044322949045329e+02 3.2006167622599372e+02 -2.1986764638272354e+02 + 55 -6.7026995338193800e+01 2.8420556560193813e+02 -1.8256943632991832e+02 + 56 -9.3944897793228449e+02 7.6593871052490772e+02 -4.5872941120666047e+02 + 57 -2.7671724574062118e+01 -1.7257977562305288e+02 -1.6210118849324647e+02 + 58 7.1032070297632538e+02 -8.0881938208311476e+02 4.6676948457734858e+02 + 59 1.5682857500225737e+02 5.9891527233627293e+01 1.2646558890105982e+02 + 60 9.4076874705709926e+01 -1.1749874299724534e+02 -2.9919368333582668e+01 + 61 -4.8945763699767689e+01 1.6634783727405593e+02 6.7645978441449742e+01 + 62 1.6618577867039599e+02 7.3503605317082489e+01 2.2193892218236817e+02 + 63 4.6491757293230078e+00 -3.5581179274724042e+02 -3.8944419279304846e+01 + 64 -2.0021113303887074e+02 -1.1223202348830974e+02 3.0276216112541510e+02 +run_vdwl: -8975.380420767826 +run_coul: 0.5928530763135977 run_stress: ! |- - -1.1524045146329236e+03 -4.6202672628887268e+02 3.1947257175242049e+02 -2.2198788293036200e+03 3.4537925625758328e+02 -1.2645006400276918e+03 + -1.1524045146329215e+03 -4.6202672628887183e+02 3.1947257175242123e+02 -2.2198788293036246e+03 3.4537925625758203e+02 -1.2645006400276918e+03 run_forces: ! |2 - 1 -2.0916271375742122e+02 -1.8819704628010820e+02 -2.2843189669574852e+02 - 2 -5.9713089401385787e+01 -1.3795344000202866e+02 -6.1452818077516426e+01 - 3 1.0924320976999630e+02 5.4687819694184142e+01 8.7119001425249518e+00 - 4 2.2394063345773969e+02 -1.2606895888134676e+02 5.6116327882122533e+01 - 5 2.1344393241529360e+01 2.3982487161745496e+02 -1.1311589687086055e+02 - 6 -2.3464311544028666e+02 8.7956955368837427e+01 7.1434549534144523e+01 - 7 1.7780879390887415e+02 3.8509431501988246e+01 -2.7664422105920835e+02 - 8 -2.1021838063645568e+01 -4.0712804090199722e+02 1.5141447171445833e+02 - 9 -5.9306114388327742e+01 2.6264890826456997e+02 1.7441651570743588e+01 - 10 -8.4526898873820201e+01 1.5450366474645668e+02 6.0033453272929940e+00 - 11 -1.1159943563282732e+02 1.8656190683525134e+02 3.4449923076959345e+02 - 12 3.3352091011374790e+02 -3.8250187755922349e+02 5.1084711927225143e+01 - 13 -3.9348220819701362e+02 -9.9340584671855098e+01 2.4784344215807911e+02 - 14 1.7611207455981244e+02 -2.8017472349270184e+02 -2.7998178961052838e+02 - 15 2.5245571069035290e+02 -5.4734821409382626e+01 -1.3455249096986566e+02 - 16 1.6596243938777351e+02 1.6278821061030078e+02 4.2193739172058962e+01 - 17 4.0563209609350160e+01 2.0278198687184394e+02 1.1655244113651584e+02 - 18 1.9349048420969314e+02 -3.1742251436587967e+01 -3.0059327012827964e+01 - 19 -5.9065305354749185e+01 1.7641117222083235e+01 -1.0450807266106713e+02 - 20 1.3106409577706648e+02 2.5186488486411651e+01 1.3539864929844231e+02 - 21 -3.2006405209533727e+02 -1.1510774059461794e+02 -2.5815972761838644e+01 - 22 -1.2758648770740034e+01 -1.3030598897381913e+02 -1.4401125298080763e+02 - 23 -1.0142069915754510e+02 2.3316707339244664e+02 2.3905997646640651e+02 - 24 4.1563103349612355e+01 -1.2912528416939978e+01 -3.1670350622584593e+01 - 25 2.1168614583214108e+02 -2.0420927517565983e+02 -3.1221859837734250e+01 - 26 -2.6321230702712649e+02 1.2065335797472036e+02 2.6277789068532360e+02 - 27 -7.4500805679154823e+01 1.0778230652943388e+02 1.6094824153641918e+02 - 28 -2.4910955893577807e+02 -9.8496280842320616e+01 2.2240251270644734e+02 - 29 4.5656377692784969e+02 -5.6186906107102686e+01 -2.7582984196898542e+02 - 30 -1.1442511837997856e+02 5.2288586072111144e+01 -1.7194888884507304e+02 - 31 -1.8372666861898105e+02 -1.0040300216200654e+02 -9.6974937189118549e+01 - 32 1.5285848611243131e+02 -1.2910298326427261e+02 -1.8526958855531907e+02 - 33 2.0676324457133298e+01 3.7958042970093453e+02 -3.0330268376879861e+01 - 34 -1.8482802426276322e+02 -8.4860106696650362e+01 -1.0335087798868081e+02 - 35 -4.3757312673305961e+01 1.3332543035332109e+00 3.2176626618113424e+01 - 36 6.0396434382165080e+02 6.3211513244050911e+02 -1.5608509994293938e+01 - 37 -1.7702865323607540e+02 -3.4710307878941217e+02 2.0756937792988572e+02 - 38 -1.5990155316495603e+02 3.4380405811165133e+01 -1.1348496857139023e+02 - 39 1.2481655186335834e+02 3.1838210934905270e+01 2.4138399128801109e+02 - 40 -3.3940174784427825e+02 -5.2071078889465889e+02 -3.2710078405858489e+01 - 41 1.5894692394219231e+01 -2.5287374067694170e+01 -6.0953115361932838e+01 - 42 -3.5153052244718293e+02 1.0102830549812477e+02 1.0056790310062641e+02 - 43 1.8327499597791055e+02 -1.7817142708111650e+01 3.5817319257754178e+01 - 44 -1.7148210647983669e+02 6.5813679084638309e+01 -3.9042611994879181e+01 - 45 6.8003425377666687e+01 -5.2977048819501960e+01 -1.1277968937633442e+02 - 46 -1.9814362259114762e+02 3.1898369061349177e+02 -1.7124898143652061e+02 - 47 2.3513270166768126e+02 1.7331295501003885e+02 -4.6450664399000594e+01 - 48 -7.0870567240296412e+00 -2.1510840134220808e+02 2.8256287551251631e+02 - 49 2.4924760680789768e+02 -2.5986199354026756e+01 -1.9539743684221278e+02 - 50 9.0194077117530043e+01 2.6674400385736777e+02 4.8189887304663067e+01 + 1 -2.0916271375742122e+02 -1.8819704628010817e+02 -2.2843189669574869e+02 + 2 -5.9713089401385758e+01 -1.3795344000202869e+02 -6.1452818077516390e+01 + 3 1.0924320976999630e+02 5.4687819694184149e+01 8.7119001425249856e+00 + 4 2.2394063345773964e+02 -1.2606895888134682e+02 5.6116327882122576e+01 + 5 2.1344393241529389e+01 2.3982487161745499e+02 -1.1311589687086055e+02 + 6 -2.3464311544028661e+02 8.7956955368837384e+01 7.1434549534144637e+01 + 7 1.7780879390887415e+02 3.8509431501988217e+01 -2.7664422105920829e+02 + 8 -2.1021838063645482e+01 -4.0712804090199722e+02 1.5141447171445827e+02 + 9 -5.9306114388327757e+01 2.6264890826456991e+02 1.7441651570743552e+01 + 10 -8.4526898873820215e+01 1.5450366474645668e+02 6.0033453272930384e+00 + 11 -1.1159943563282745e+02 1.8656190683525122e+02 3.4449923076959351e+02 + 12 3.3352091011374790e+02 -3.8250187755922354e+02 5.1084711927225193e+01 + 13 -3.9348220819701362e+02 -9.9340584671855169e+01 2.4784344215807909e+02 + 14 1.7611207455981241e+02 -2.8017472349270173e+02 -2.7998178961052844e+02 + 15 2.5245571069035296e+02 -5.4734821409382555e+01 -1.3455249096986572e+02 + 16 1.6596243938777354e+02 1.6278821061030078e+02 4.2193739172058905e+01 + 17 4.0563209609350160e+01 2.0278198687184386e+02 1.1655244113651577e+02 + 18 1.9349048420969311e+02 -3.1742251436588031e+01 -3.0059327012828049e+01 + 19 -5.9065305354749214e+01 1.7641117222083306e+01 -1.0450807266106700e+02 + 20 1.3106409577706646e+02 2.5186488486411605e+01 1.3539864929844234e+02 + 21 -3.2006405209533733e+02 -1.1510774059461774e+02 -2.5815972761838673e+01 + 22 -1.2758648770740059e+01 -1.3030598897381921e+02 -1.4401125298080763e+02 + 23 -1.0142069915754507e+02 2.3316707339244658e+02 2.3905997646640648e+02 + 24 4.1563103349612369e+01 -1.2912528416939935e+01 -3.1670350622584650e+01 + 25 2.1168614583214125e+02 -2.0420927517565985e+02 -3.1221859837734193e+01 + 26 -2.6321230702712660e+02 1.2065335797472045e+02 2.6277789068532365e+02 + 27 -7.4500805679154780e+01 1.0778230652943385e+02 1.6094824153641912e+02 + 28 -2.4910955893577795e+02 -9.8496280842320559e+01 2.2240251270644745e+02 + 29 4.5656377692784969e+02 -5.6186906107102686e+01 -2.7582984196898536e+02 + 30 -1.1442511837997850e+02 5.2288586072111215e+01 -1.7194888884507304e+02 + 31 -1.8372666861898102e+02 -1.0040300216200652e+02 -9.6974937189118549e+01 + 32 1.5285848611243128e+02 -1.2910298326427264e+02 -1.8526958855531913e+02 + 33 2.0676324457133269e+01 3.7958042970093453e+02 -3.0330268376879818e+01 + 34 -1.8482802426276319e+02 -8.4860106696650320e+01 -1.0335087798868084e+02 + 35 -4.3757312673306046e+01 1.3332543035332109e+00 3.2176626618113481e+01 + 36 6.0396434382165091e+02 6.3211513244050911e+02 -1.5608509994294000e+01 + 37 -1.7702865323607537e+02 -3.4710307878941217e+02 2.0756937792988569e+02 + 38 -1.5990155316495614e+02 3.4380405811165076e+01 -1.1348496857139016e+02 + 39 1.2481655186335830e+02 3.1838210934905284e+01 2.4138399128801106e+02 + 40 -3.3940174784427819e+02 -5.2071078889465889e+02 -3.2710078405858532e+01 + 41 1.5894692394219259e+01 -2.5287374067694170e+01 -6.0953115361932859e+01 + 42 -3.5153052244718299e+02 1.0102830549812481e+02 1.0056790310062642e+02 + 43 1.8327499597791055e+02 -1.7817142708111664e+01 3.5817319257754207e+01 + 44 -1.7148210647983674e+02 6.5813679084638309e+01 -3.9042611994879181e+01 + 45 6.8003425377666758e+01 -5.2977048819501903e+01 -1.1277968937633439e+02 + 46 -1.9814362259114759e+02 3.1898369061349172e+02 -1.7124898143652064e+02 + 47 2.3513270166768126e+02 1.7331295501003882e+02 -4.6450664399000594e+01 + 48 -7.0870567240295701e+00 -2.1510840134220823e+02 2.8256287551251637e+02 + 49 2.4924760680789757e+02 -2.5986199354026777e+01 -1.9539743684221281e+02 + 50 9.0194077117530171e+01 2.6674400385736777e+02 4.8189887304663053e+01 51 2.7001321252850289e+02 -2.5024728349358162e+02 3.3082537396992757e+02 - 52 2.6774804404985821e+02 -1.3486815275053038e+02 -1.0995893066873343e+02 - 53 -3.0038420314626603e+02 1.7427256870890602e+02 -2.8369883331393498e+02 - 54 -1.8044337650670002e+02 3.2006027628882646e+02 -2.1986948976707882e+02 - 55 -6.7001753892442011e+01 2.8430150309051572e+02 -1.8265115796763561e+02 - 56 -9.3985837397072532e+02 7.6632225180339810e+02 -4.5884355139046016e+02 - 57 -2.7678338148623979e+01 -1.7258885892537234e+02 -1.6210010817478292e+02 - 58 7.1048197789438450e+02 -8.0911013609888585e+02 4.6702832864248001e+02 - 59 1.5682431931196510e+02 5.9896412584257810e+01 1.2646734132724080e+02 - 60 9.4082766259421007e+01 -1.1751801568433156e+02 -2.9921033400739130e+01 - 61 -4.8935117837153584e+01 1.6627961752299834e+02 6.7603012413403007e+01 - 62 1.6622090697397982e+02 7.3539705289790803e+01 2.2199414281313432e+02 - 63 4.6500905620167821e+00 -3.5581268146467818e+02 -3.8945035187443878e+01 - 64 -2.0020316331354053e+02 -1.1222336846987974e+02 3.0276528613232387e+02 + 52 2.6774804404985809e+02 -1.3486815275053038e+02 -1.0995893066873337e+02 + 53 -3.0038420314626609e+02 1.7427256870890602e+02 -2.8369883331393498e+02 + 54 -1.8044337650670010e+02 3.2006027628882651e+02 -2.1986948976707873e+02 + 55 -6.7001753892442125e+01 2.8430150309051584e+02 -1.8265115796763567e+02 + 56 -9.3985837397072532e+02 7.6632225180339799e+02 -4.5884355139046050e+02 + 57 -2.7678338148624022e+01 -1.7258885892537234e+02 -1.6210010817478278e+02 + 58 7.1048197789438450e+02 -8.0911013609888573e+02 4.6702832864248001e+02 + 59 1.5682431931196504e+02 5.9896412584257810e+01 1.2646734132724080e+02 + 60 9.4082766259420993e+01 -1.1751801568433152e+02 -2.9921033400739145e+01 + 61 -4.8935117837153584e+01 1.6627961752299828e+02 6.7603012413403036e+01 + 62 1.6622090697397977e+02 7.3539705289790774e+01 2.2199414281313429e+02 + 63 4.6500905620168673e+00 -3.5581268146467818e+02 -3.8945035187443779e+01 + 64 -2.0020316331354053e+02 -1.1222336846987976e+02 3.0276528613232387e+02 ... diff --git a/unittest/force-styles/tests/atomic-pair-reax_c_tabulate.yaml b/unittest/force-styles/tests/atomic-pair-reax_c_tabulate.yaml new file mode 100644 index 0000000000..59a7f2eea4 --- /dev/null +++ b/unittest/force-styles/tests/atomic-pair-reax_c_tabulate.yaml @@ -0,0 +1,176 @@ +--- +lammps_version: 2 Jul 2021 +date_generated: Wed Jul 21 15:49:50 2021 +epsilon: 1e-12 +prerequisites: ! | + pair reaxff + fix qeq/reaxff +pre_commands: ! | + echo screen + shell cp ${input_dir}/reaxff.control reaxff-1.control + variable newton_pair delete + variable newton_pair index on + atom_modify map array + units real + atom_style charge + lattice diamond 3.77 + region box block 0 2 0 2 0 2 + create_box 3 box + create_atoms 1 box + displace_atoms all random 0.1 0.1 0.1 623426 + mass 1 1.0 + mass 2 12.0 + mass 3 16.0 + set type 1 type/fraction 2 0.5 998877 + set type 2 type/fraction 3 0.5 887766 + set type 1 charge 0.00 + set type 2 charge 0.01 + set type 3 charge -0.01 + velocity all create 100 4534624 loop geom +post_commands: ! | + fix qeq all qeq/reaxff 1 0.0 8.0 1.0e-20 reaxff +input_file: in.empty +pair_style: reaxff reaxff-1.control checkqeq yes +pair_coeff: ! | + * * ffield.reax.mattsson H C O +extract: ! "" +natoms: 64 +init_vdwl: -3248.7357862540734 +init_coul: -327.0655125227952 +init_stress: ! |- + -9.1835020319343971e+02 -1.1070721188680495e+03 -7.1558466813462803e+02 -2.3040889388184610e+02 1.9640581541966480e+02 -6.6002885423290161e+02 +init_forces: ! |2 + 1 -8.8484243142053771e+01 -2.5824351291806110e+01 1.0916231386685256e+02 + 2 -1.0451347832614756e+02 -1.8136974287862066e+02 -2.1792749625845636e+02 + 3 -1.7141330932870599e+02 1.8106971255162949e+02 1.2675253960497342e+01 + 4 3.2218812838204855e+01 -5.1411756251266183e+01 9.0007306757969360e+01 + 5 1.8144819687099243e+02 1.6798395592380508e+01 -8.1726053808337866e+01 + 6 1.3634126802325463e+02 -3.0056831863560092e+02 2.9662272655036702e+01 + 7 -5.2968391883957104e+01 -1.2850613949952665e+02 -1.6373506942005375e+02 + 8 -1.5240314403220790e+02 4.1133257093807174e+01 1.5386487473711946e+02 + 9 3.2812532468307580e+01 1.0176367686189141e+02 1.4294427965088833e+01 + 10 7.9509811085534523e+01 1.3053732532659751e+02 1.1246398073074913e+02 + 11 -4.3144361329385013e+01 6.5763458097239592e+01 1.3482625633510347e+02 + 12 -9.6706456479566398e+01 -2.5878068074726777e+01 7.8323180467847324e+00 + 13 -6.3851121453490386e+01 -4.6607020158192661e+01 -3.6458352736129626e+01 + 14 7.8283848679559611e+01 -6.3646790831912028e+01 -8.9030561188058030e+01 + 15 -6.4212540181982106e+01 2.1093128152294148e+02 7.9060299592798927e+01 + 16 1.8608410345576596e+02 5.8084942932974329e+01 5.8538920003760360e+01 + 17 1.4285494615811757e+02 -3.9754521764346144e+01 -9.7686742464543357e+01 + 18 -4.1881548239260340e+01 -1.8476992042512617e+02 1.0708048360801492e+02 + 19 2.6677589878662843e+02 3.7179534199157007e+02 -3.3866575926816614e+02 + 20 -7.3520359401756977e+01 -8.3905077072099573e+01 -2.3854316876052761e-01 + 21 -7.2528668519170537e+01 -5.5898051886914395e+01 -1.1976059789267006e+02 + 22 1.5613953224968657e+02 -1.3200393155013327e+02 8.2112641076919701e+01 + 23 8.1833165091702966e+01 -1.7531644917125725e+01 -2.5648343293479527e+01 + 24 -2.1833127742352659e+02 1.9453922798678227e+02 -1.0817823414171309e+02 + 25 -1.1414613109864892e+02 1.9088917707975912e+02 -8.3362585828151580e+01 + 26 2.8281696751420094e+02 -2.1478267582733662e+02 2.2873793580282313e+02 + 27 -5.9769124622217880e+01 6.5221508924768301e+01 1.7553584075622149e+02 + 28 -2.9606162623424428e+00 3.8183918395203612e+01 3.2190129571074365e+01 + 29 -7.1069178571897922e+01 3.5485903180456219e+01 2.7311648896337690e+01 + 30 -1.7036975157904502e+02 -1.9851849204561248e+02 -1.1511387046436192e+02 + 31 -1.3744101014029056e+02 1.6223817575815926e+02 -1.1915340963940670e+02 + 32 2.7247730686207166e+01 -6.0237587331413046e+01 -1.7664910575209962e+02 + 33 -6.1822971861324099e+01 -6.2648749988189138e+01 6.4194672454603221e+01 + 34 -1.7144145154614467e+01 9.9612835226783488e+01 -6.7437146990430065e+01 + 35 2.7024145652918202e+02 -2.1533864682645725e+02 1.3021380112890154e+02 + 36 1.0192185945862101e+02 1.8671686332443795e+02 -1.9864174410201804e+02 + 37 -1.7944122400067201e+02 1.2994089095714961e+02 -6.4321354857450956e+01 + 38 -2.9675055634802868e+02 1.0371104129720520e+02 1.5526989537725160e+02 + 39 8.6949523213895688e+01 -5.9975159120196956e+01 2.1780252234486241e+01 + 40 2.1612729980868444e+01 -1.0242580356371295e+02 5.7270724021457731e+01 + 41 -5.7836015722979198e+01 1.2268076597657853e+01 -6.6177893589402757e+01 + 42 -9.4774792026636959e+01 3.6872244003648007e+01 -7.5003138682741707e+01 + 43 2.2327470123469598e+02 9.5798787537490540e+01 1.2250410628715086e+02 + 44 8.7959342085865842e+01 -9.8740455124804612e+01 -8.4938709742755563e+01 + 45 1.4089093363544151e+01 1.2499300233485907e+02 5.5864237375372056e+01 + 46 1.3547776948110229e+01 -2.9276229642219498e+01 2.2187402435965936e+01 + 47 3.3448457824361142e+01 -1.9209977417392156e+02 -6.9989895706263411e+01 + 48 6.7827627502625162e+01 -2.0361789453088662e+02 -2.8571736118815590e+01 + 49 -3.7476005148434911e+02 -2.4452451195186555e+01 1.0764661193358336e+02 + 50 4.0090993029105427e+01 -7.3201402054245932e+01 8.9025922810974976e+01 + 51 1.3736420686697005e+02 -1.0204157331499377e+02 1.5813725581140889e+02 + 52 -1.1253479916199434e+02 1.2293268076535988e+02 -1.2940078007359961e+02 + 53 -5.3560738472921159e+01 3.3353082884518022e+02 -1.1314448604069298e+00 + 54 -1.0678339177259721e+01 6.2810937621378216e+01 1.8344988318246158e+02 + 55 1.1231900459987534e+02 -1.7906654831317346e+02 7.6533681064342304e+01 + 56 -4.7772143767870858e+01 -1.3536779754026813e+02 3.4054518546944287e+01 + 57 9.6541690594806283e+01 7.5093838528685495e+01 -6.0858704719314126e+01 + 58 -2.0459002696752535e+01 -1.1535051272093602e+01 -1.4282722385693351e+01 + 59 -6.9459404830701061e+01 1.0185761321965333e+02 8.3383492919159224e+01 + 60 -1.6658947285275733e+01 6.4062738321772926e+01 -1.5162708730048112e+02 + 61 -3.5221540644535281e+01 -1.0209415023871215e+02 -7.4154806308030501e+01 + 62 1.5375061601631639e+01 -6.3257038363614946e+00 2.7511178147389174e+01 + 63 1.3464841040549379e+02 -1.2416888785900632e+02 -5.8961420295344659e+01 + 64 1.0701063550375258e+02 1.1895268715876720e+02 7.4448770962530929e+01 +run_vdwl: -3248.732462206598 +run_coul: -327.0653994771387 +run_stress: ! |- + -9.1826184153105646e+02 -1.1070021528099112e+03 -7.1550580149015627e+02 -2.3049698812231000e+02 1.9635464153062134e+02 -6.6005793264639556e+02 +run_forces: ! |2 + 1 -8.8485813027206135e+01 -2.5824096764125731e+01 1.0916519811125200e+02 + 2 -1.0451269244764350e+02 -1.8137828885716391e+02 -2.1792302517211851e+02 + 3 -1.7141411648636486e+02 1.8106803267132440e+02 1.2674658958989427e+01 + 4 3.2220655253010918e+01 -5.1413086231064995e+01 9.0010227071396415e+01 + 5 1.8145005123751957e+02 1.6799086578426838e+01 -8.1723924656170610e+01 + 6 1.3640868425590003e+02 -3.0059549892327158e+02 2.9595528779455435e+01 + 7 -5.2968868171259714e+01 -1.2850640761855155e+02 -1.6373951876943804e+02 + 8 -1.5240417232930932e+02 4.1133578832982636e+01 1.5386572595284764e+02 + 9 3.2811395144161132e+01 1.0176141517530590e+02 1.4295529169373282e+01 + 10 7.9508569375402331e+01 1.3053469081285709e+02 1.1246210158699030e+02 + 11 -4.3142968406859097e+01 6.5760241919953813e+01 1.3481728343070949e+02 + 12 -9.6708250458847061e+01 -2.5879521605003742e+01 7.8278088000700370e+00 + 13 -6.3852523341823229e+01 -4.6607003335506541e+01 -3.6455965991574878e+01 + 14 7.8283534745824241e+01 -6.3643851884097224e+01 -8.9027881489336167e+01 + 15 -6.4209962316685690e+01 2.1093255387179667e+02 7.9059692211125295e+01 + 16 1.8608085162130908e+02 5.8088780803195142e+01 5.8532604899053133e+01 + 17 1.4285609630789864e+02 -3.9754014601715795e+01 -9.7689588113924316e+01 + 18 -4.1881237955183380e+01 -1.8477109777149900e+02 1.0708061287038571e+02 + 19 2.6677609377410010e+02 3.7179392086487712e+02 -3.3866472006706340e+02 + 20 -7.3532190353883053e+01 -8.3895301502997967e+01 -2.5591151698956521e-01 + 21 -7.2528695460850088e+01 -5.5899068566579977e+01 -1.1975970158720035e+02 + 22 1.5614083463623413e+02 -1.3200472837628527e+02 8.2112156159808862e+01 + 23 8.1835290134891864e+01 -1.7522433028942352e+01 -2.5648597332802964e+01 + 24 -2.1834038832017541e+02 1.9455197293610073e+02 -1.0818261235148486e+02 + 25 -1.1414871301032666e+02 1.9089327234338913e+02 -8.3363315092572321e+01 + 26 2.8282661127556162e+02 -2.1478990451658228e+02 2.2874215408671137e+02 + 27 -5.9765619577841541e+01 6.5223096224356439e+01 1.7553677772771840e+02 + 28 -2.9624987519851178e+00 3.8179667154298812e+01 3.2185280629057068e+01 + 29 -7.1069494187081830e+01 3.5486459200488405e+01 2.7311657807311473e+01 + 30 -1.7037047317028475e+02 -1.9851861739498079e+02 -1.1511395377375433e+02 + 31 -1.3744346258178373e+02 1.6223725554250467e+02 -1.1915482471876425e+02 + 32 2.7248541074999881e+01 -6.0231207974705420e+01 -1.7663875080811843e+02 + 33 -6.1822398570959159e+01 -6.2648503570177034e+01 6.4194898940197774e+01 + 34 -1.7143769208529751e+01 9.9611942509072080e+01 -6.7436075885014986e+01 + 35 2.7028238194296250e+02 -2.1538301386687783e+02 1.3022488558865331e+02 + 36 1.0192362247594350e+02 1.8671008619975410e+02 -1.9863711527085917e+02 + 37 -1.7946751638141498e+02 1.2998098195714172e+02 -6.4345576150932828e+01 + 38 -2.9675376021752186e+02 1.0371435865032235e+02 1.5526896750689886e+02 + 39 8.6950332148131110e+01 -5.9975388525042071e+01 2.1779869753193026e+01 + 40 2.1613442490343314e+01 -1.0242529062335393e+02 5.7271060256879871e+01 + 41 -5.7834219239599364e+01 1.2266148111030034e+01 -6.6169611760840596e+01 + 42 -9.4774021509187506e+01 3.6869981851995398e+01 -7.5005285702022690e+01 + 43 2.2327078175416062e+02 9.5796580610065675e+01 1.2250057895428364e+02 + 44 8.7963372590925985e+01 -9.8736166841311601e+01 -8.4943701327958038e+01 + 45 1.4080569929277486e+01 1.2498603359504315e+02 5.5870075675508232e+01 + 46 1.3549084713162147e+01 -2.9276453411015140e+01 2.2187141786216618e+01 + 47 3.3448153520154271e+01 -1.9209514330879989e+02 -6.9988284949882569e+01 + 48 6.7840148074199092e+01 -2.0361975956922109e+02 -2.8580806381848255e+01 + 49 -3.7480020999441365e+02 -2.4397739069897636e+01 1.0773474200196219e+02 + 50 4.0091767398974682e+01 -7.3200211843412504e+01 8.9024460533547696e+01 + 51 1.3736689552057061e+02 -1.0204490779999098e+02 1.5814099219631356e+02 + 52 -1.1253380764229996e+02 1.2293290174735381e+02 -1.2940467151627450e+02 + 53 -5.3596650492501162e+01 3.3350644289105031e+02 -1.1510223807932007e+00 + 54 -1.0666202581574661e+01 6.2798090272532008e+01 1.8346799239172421e+02 + 55 1.1232135575968968e+02 -1.7906994470748415e+02 7.6534265236354301e+01 + 56 -4.7780797026174810e+01 -1.3535955159718563e+02 3.4061208199866719e+01 + 57 9.6541265005138698e+01 7.5091144884198556e+01 -6.0860069746425658e+01 + 58 -2.0459328007572669e+01 -1.1533053731831259e+01 -1.4282938438265617e+01 + 59 -6.9467796604507981e+01 1.0186323697055799e+02 8.3388794196804326e+01 + 60 -1.6660217426514606e+01 6.4061566362647113e+01 -1.5162714312949211e+02 + 61 -3.5220536021452787e+01 -1.0209241739133054e+02 -7.4154706185261915e+01 + 62 1.5375483178245885e+01 -6.3263099051314251e+00 2.7512110875657893e+01 + 63 1.3464595988109866e+02 -1.2416936634154256e+02 -5.8957063242418101e+01 + 64 1.0701154605982798e+02 1.1895382951205715e+02 7.4449321163285845e+01 +... diff --git a/unittest/force-styles/tests/atomic-pair-yukawa_colloid.yaml b/unittest/force-styles/tests/atomic-pair-yukawa_colloid.yaml index 1c5c24832d..d807696e63 100644 --- a/unittest/force-styles/tests/atomic-pair-yukawa_colloid.yaml +++ b/unittest/force-styles/tests/atomic-pair-yukawa_colloid.yaml @@ -2,6 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:09:10 2021 epsilon: 2e-13 +skip_tests: single prerequisites: ! | atom sphere pair yukawa/colloid diff --git a/unittest/force-styles/tests/fix-timestep-adapt_pair.yaml b/unittest/force-styles/tests/fix-timestep-adapt_pair.yaml index 167f531b8e..58b25f6012 100644 --- a/unittest/force-styles/tests/fix-timestep-adapt_pair.yaml +++ b/unittest/force-styles/tests/fix-timestep-adapt_pair.yaml @@ -1,7 +1,7 @@ --- lammps_version: 10 Mar 2021 date_generated: Thu Mar 25 14:01:17 202 -epsilon: 1e-14 +epsilon: 2e-14 prerequisites: ! | atom full fix adapt diff --git a/unittest/force-styles/tests/mol-pair-dpd.yaml b/unittest/force-styles/tests/mol-pair-dpd.yaml index 4964a74e2a..c3900a3bc6 100644 --- a/unittest/force-styles/tests/mol-pair-dpd.yaml +++ b/unittest/force-styles/tests/mol-pair-dpd.yaml @@ -2,7 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:08:44 2021 epsilon: 5e-14 -skip_tests: gpu intel +skip_tests: gpu intel single prerequisites: ! | atom full pair dpd diff --git a/unittest/force-styles/tests/mol-pair-dpd_tstat.yaml b/unittest/force-styles/tests/mol-pair-dpd_tstat.yaml index 0348c0d601..09d52366ba 100644 --- a/unittest/force-styles/tests/mol-pair-dpd_tstat.yaml +++ b/unittest/force-styles/tests/mol-pair-dpd_tstat.yaml @@ -2,7 +2,7 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:08:44 2021 epsilon: 5e-14 -skip_tests: gpu intel +skip_tests: gpu intel single prerequisites: ! | atom full pair dpd/tstat diff --git a/unittest/force-styles/tests/param.qeq2 b/unittest/force-styles/tests/param.qeq2 new file mode 100644 index 0000000000..1d77b7d3a6 --- /dev/null +++ b/unittest/force-styles/tests/param.qeq2 @@ -0,0 +1,3 @@ +# UNITS: metal +1 0.00000 7.25028 0.01 0.772871 0.000000 +2 11.26882 15.37920 0.01 0.243072 0.000000 diff --git a/unittest/force-styles/tests/reaxff.control b/unittest/force-styles/tests/reaxff.control new file mode 100644 index 0000000000..ecf22940b7 --- /dev/null +++ b/unittest/force-styles/tests/reaxff.control @@ -0,0 +1,7 @@ +tabulate_long_range 10000 ! denotes the granularity of long range tabulation, 0 means no tabulation + +nbrhood_cutoff 4.5 ! near neighbors cutoff for bond calculations in A +hbond_cutoff 6.0 ! cutoff distance for hydrogen bond interactions +bond_graph_cutoff 0.3 ! bond strength cutoff for bond graphs +thb_cutoff 0.001 ! cutoff value for three body interactions + diff --git a/unittest/python/CMakeLists.txt b/unittest/python/CMakeLists.txt index b51d6e340a..9c9b7832ad 100644 --- a/unittest/python/CMakeLists.txt +++ b/unittest/python/CMakeLists.txt @@ -85,6 +85,11 @@ if(Python_EXECUTABLE) COMMAND ${PYTHON_TEST_RUNNER} ${CMAKE_CURRENT_SOURCE_DIR}/python-formats.py -v WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(PythonFormats PROPERTIES ENVIRONMENT "${PYTHON_TEST_ENVIRONMENT}") + + add_test(NAME PythonFixExternal + COMMAND ${PYTHON_TEST_RUNNER} ${CMAKE_CURRENT_SOURCE_DIR}/python-fix-external.py -v + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) + set_tests_properties(PythonFixExternal PROPERTIES ENVIRONMENT "${PYTHON_TEST_ENVIRONMENT}") else() message(STATUS "Skipping Tests for the LAMMPS Python Module: no suitable Python interpreter") endif() diff --git a/unittest/python/python-fix-external.py b/unittest/python/python-fix-external.py new file mode 100644 index 0000000000..c061b9f466 --- /dev/null +++ b/unittest/python/python-fix-external.py @@ -0,0 +1,176 @@ +import sys,os,unittest +from ctypes import * +from lammps import lammps, LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR + +try: + import numpy + NUMPY_INSTALLED = True +except ImportError: + NUMPY_INSTALLED = False + +# add timestep dependent force +def callback_one(lmp, ntimestep, nlocal, tag, x, f): + lmp.fix_external_set_virial_global("ext",[1.0, 1.0, 1.0, 0.0, 0.0, 0.0]) + for i in range(nlocal): + f[i][0] = float(ntimestep) + f[i][1] = float(ntimestep) + f[i][2] = float(ntimestep) + if ntimestep < 10: + lmp.fix_external_set_energy_global("ext", 0.5) + lmp.fix_external_set_vector("ext", 1, ntimestep) + lmp.fix_external_set_vector("ext", 3, 1.0) + lmp.fix_external_set_vector("ext", 4, -0.25) + else: + lmp.fix_external_set_energy_global("ext", 1.0) + lmp.fix_external_set_vector("ext", 2, ntimestep) + lmp.fix_external_set_vector("ext", 5, -1.0) + lmp.fix_external_set_vector("ext", 6, 0.25) + + eatom = [0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7] + vatom = [ [0.1,0.0,0.0,0.0,0.0,0.0], + [0.0,0.2,0.0,0.0,0.0,0.0], + [0.0,0.0,0.3,0.0,0.0,0.0], + [0.0,0.0,0.0,0.4,0.0,0.0], + [0.0,0.0,0.0,0.0,0.5,0.0], + [0.0,0.0,0.0,0.0,0.0,0.6], + [0.0,0.0,0.0,0.0,-7.0,0.0], + [0.0,-8.0,0.0,0.0,0.0,0.0] ] + if ntimestep < 5: + lmp.fix_external_set_energy_peratom("ext",eatom) + lmp.fix_external_set_virial_peratom("ext",vatom) + else: + import numpy as np + eng = np.array(eatom) + vir = np.array(vatom) + + lmp.numpy.fix_external_set_energy_peratom("ext",eng) + lmp.numpy.fix_external_set_virial_peratom("ext",vir) + + # ------------------------------------------------------------------------ + +class PythonExternal(unittest.TestCase): + @unittest.skipIf(not NUMPY_INSTALLED, "NumPy is not available") + def testExternalCallback(self): + """Test fix external from Python with pf/callback""" + + machine=None + if 'LAMMPS_MACHINE_NAME' in os.environ: + machine=os.environ['LAMMPS_MACHINE_NAME'] + lmp=lammps(name=machine, cmdargs=['-nocite', '-log','none', '-echo', 'screen']) + + # a few commands to set up simple system + basic_system="""lattice sc 1.0 + region box block -1 1 -1 1 -1 1 + create_box 1 box + create_atoms 1 box + mass 1 1.0 + pair_style zero 0.1 + pair_coeff 1 1 + velocity all set 0.1 0.0 -0.1 + thermo_style custom step temp pe ke etotal press + thermo 5 + fix 1 all nve + fix ext all external pf/callback 5 1 + compute eatm all pe/atom fix + compute vatm all stress/atom NULL fix + compute sum all reduce sum c_eatm c_vatm[*] + thermo_style custom step temp pe ke etotal press c_sum[*] + fix_modify ext energy yes virial yes +""" + lmp.commands_string(basic_system) + lmp.fix_external_set_vector_length("ext",6); + lmp.set_fix_external_callback("ext",callback_one,lmp) + + # check setting per-atom data with python lists + lmp.command("run 0 post no") + reduce = lmp.extract_compute("sum", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR) + self.assertAlmostEqual(reduce[0],2.8,14) + self.assertAlmostEqual(reduce[1],-0.1,14) + self.assertAlmostEqual(reduce[2],7.8,14) + self.assertAlmostEqual(reduce[3],-0.3,14) + self.assertAlmostEqual(reduce[4],-0.4,14) + self.assertAlmostEqual(reduce[5],6.5,14) + self.assertAlmostEqual(reduce[6],-0.6,14) + + lmp.command("run 10 post no") + self.assertAlmostEqual(lmp.get_thermo("temp"),1.0/30.0,14) + self.assertAlmostEqual(lmp.get_thermo("pe"),1.0/8.0,14) + self.assertAlmostEqual(lmp.get_thermo("press"),0.15416666666666667,14) + # check setting per-atom data numpy arrays + reduce = lmp.extract_compute("sum", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR) + self.assertAlmostEqual(reduce[0],2.8,14) + self.assertAlmostEqual(reduce[1],-0.1,14) + self.assertAlmostEqual(reduce[2],7.8,14) + self.assertAlmostEqual(reduce[3],-0.3,14) + self.assertAlmostEqual(reduce[4],-0.4,14) + self.assertAlmostEqual(reduce[5],6.5,14) + self.assertAlmostEqual(reduce[6],-0.6,14) + val = 0.0 + for i in range(0,6): + val += lmp.extract_fix("ext",LMP_STYLE_GLOBAL,LMP_TYPE_VECTOR,nrow=i) + self.assertAlmostEqual(val,15.0,14) + + def testExternalArray(self): + """Test fix external from Python with pf/array""" + + machine=None + if 'LAMMPS_MACHINE_NAME' in os.environ: + machine=os.environ['LAMMPS_MACHINE_NAME'] + lmp=lammps(name=machine, cmdargs=['-nocite', '-log','none', '-echo', 'screen']) + + # a few commands to set up simple system + basic_system="""lattice sc 1.0 + region box block -1 1 -1 1 -1 1 + create_box 1 box + create_atoms 1 box + mass 1 1.0 + pair_style zero 0.1 + pair_coeff 1 1 + velocity all set 0.1 0.0 -0.1 + fix 1 all nve + fix ext all external pf/array 1 + fix_modify ext energy yes virial yes + thermo_style custom step temp pe ke press + thermo 5 +""" + lmp.commands_string(basic_system) + force = lmp.fix_external_get_force("ext"); + nlocal = lmp.extract_setting("nlocal"); + for i in range(nlocal): + force[i][0] = 0.0 + force[i][1] = 0.0 + force[i][2] = 0.0 + lmp.fix_external_set_energy_global("ext", 0.5) + lmp.fix_external_set_virial_global("ext",[0.5, 0.5, 0.5, 0.0, 0.0, 0.0]) + + lmp.command("run 5 post no") + self.assertAlmostEqual(lmp.get_thermo("temp"),4.0/525.0,14) + self.assertAlmostEqual(lmp.get_thermo("pe"),1.0/16.0,14) + self.assertAlmostEqual(lmp.get_thermo("press"),0.06916666666666667,14) + if NUMPY_INSTALLED: + npforce = lmp.numpy.fix_external_get_force("ext") + self.assertEqual(len(npforce),8) + self.assertEqual(len(npforce[0]),3) + self.assertEqual(npforce[1][1],0.0) + + force = lmp.fix_external_get_force("ext"); + nlocal = lmp.extract_setting("nlocal"); + for i in range(nlocal): + force[i][0] = 6.0 + force[i][1] = 6.0 + force[i][2] = 6.0 + lmp.fix_external_set_energy_global("ext", 1.0) + lmp.fix_external_set_virial_global("ext",[1.0, 1.0, 1.0, 0.0, 0.0, 0.0]) + lmp.command("run 5 post no") + self.assertAlmostEqual(lmp.get_thermo("temp"),1.0/30.0,14) + self.assertAlmostEqual(lmp.get_thermo("pe"),1.0/8.0,14) + self.assertAlmostEqual(lmp.get_thermo("press"),0.15416666666666667,14) + if NUMPY_INSTALLED: + npforce = lmp.numpy.fix_external_get_force("ext") + self.assertEqual(npforce[0][0],6.0) + self.assertEqual(npforce[3][1],6.0) + self.assertEqual(npforce[7][2],6.0) + +############################## +if __name__ == "__main__": + unittest.main()