diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index e0fca5bd9b..3af67bf8e0 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -90,8 +90,11 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") OR (CMAKE_CXX_COMPILER_ID STREQUAL " endif() endif() -# we require C++11 without extensions +# we require C++11 without extensions. Kokkos requires at least C++14 (currently) set(CMAKE_CXX_STANDARD 11) +if(PKG_KOKKOS AND (CMAKE_CXX_STANDARD LESS 14)) + set(CMAKE_CXX_STANDARD 14) +endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Use compiler extensions") # ugly hack for MSVC which by default always reports an old C++ standard in the __cplusplus macro diff --git a/cmake/Modules/Packages/KOKKOS.cmake b/cmake/Modules/Packages/KOKKOS.cmake index d5fccad4ba..fe6c17801e 100644 --- a/cmake/Modules/Packages/KOKKOS.cmake +++ b/cmake/Modules/Packages/KOKKOS.cmake @@ -1,7 +1,7 @@ ######################################################################## # As of version 3.3.0 Kokkos requires C++14 if(CMAKE_CXX_STANDARD LESS 14) - set(CMAKE_CXX_STANDARD 14) + message(FATAL_ERROR "The KOKKOS package requires the C++ standard to be set to at least C++14") endif() ######################################################################## # consistency checks and Kokkos options/settings required by LAMMPS diff --git a/cmake/Modules/Packages/MACHDYN.cmake b/cmake/Modules/Packages/MACHDYN.cmake index fab532541e..8729d80dbf 100644 --- a/cmake/Modules/Packages/MACHDYN.cmake +++ b/cmake/Modules/Packages/MACHDYN.cmake @@ -7,8 +7,9 @@ endif() option(DOWNLOAD_EIGEN3 "Download Eigen3 instead of using an already installed one)" ${DOWNLOAD_EIGEN3_DEFAULT}) if(DOWNLOAD_EIGEN3) message(STATUS "Eigen3 download requested - we will build our own") - set(EIGEN3_URL "https://gitlab.com/libeigen/eigen/-/archive/3.3.9/eigen-3.3.9.tar.gz" CACHE STRING "URL for Eigen3 tarball") - set(EIGEN3_MD5 "609286804b0f79be622ccf7f9ff2b660" CACHE STRING "MD5 checksum of Eigen3 tarball") + + set(EIGEN3_URL "https://download.lammps.org/thirdparty/eigen-3.4.0.tar.gz" CACHE STRING "URL for Eigen3 tarball") + set(EIGEN3_MD5 "4c527a9171d71a72a9d4186e65bea559" CACHE STRING "MD5 checksum of Eigen3 tarball") mark_as_advanced(EIGEN3_URL) mark_as_advanced(EIGEN3_MD5) include(ExternalProject) diff --git a/doc/src/Howto_thermostat.rst b/doc/src/Howto_thermostat.rst index fbeb1f7785..fe53fff540 100644 --- a/doc/src/Howto_thermostat.rst +++ b/doc/src/Howto_thermostat.rst @@ -2,8 +2,8 @@ Thermostats =========== Thermostatting means controlling the temperature of particles in an MD -simulation. :doc:`Barostatting ` means controlling the -pressure. Since the pressure includes a kinetic component due to +simulation. :doc:`Barostatting ` means controlling +the pressure. Since the pressure includes a kinetic component due to particle velocities, both these operations require calculation of the temperature. Typically a target temperature (T) and/or pressure (P) is specified by the user, and the thermostat or barostat attempts to @@ -26,11 +26,13 @@ can be invoked via the *dpd/tstat* pair style: * :doc:`pair_style dpd/tstat ` :doc:`Fix nvt ` only thermostats the translational velocity of -particles. :doc:`Fix nvt/sllod ` also does this, except -that it subtracts out a velocity bias due to a deforming box and -integrates the SLLOD equations of motion. See the :doc:`Howto nemd ` page for further details. :doc:`Fix nvt/sphere ` and :doc:`fix nvt/asphere ` thermostat not only translation -velocities but also rotational velocities for spherical and aspherical -particles. +particles. :doc:`Fix nvt/sllod ` also does this, +except that it subtracts out a velocity bias due to a deforming box +and integrates the SLLOD equations of motion. See the :doc:`Howto +nemd ` page for further details. :doc:`Fix nvt/sphere +` and :doc:`fix nvt/asphere ` +thermostat not only translation velocities but also rotational +velocities for spherical and aspherical particles. .. note:: @@ -40,25 +42,31 @@ particles. e.g. molecular systems. The latter can be tricky to do correctly. DPD thermostatting alters pairwise interactions in a manner analogous -to the per-particle thermostatting of :doc:`fix langevin `. +to the per-particle thermostatting of :doc:`fix langevin +`. -Any of the thermostatting fixes can be instructed to use custom temperature -computes that remove bias which has two effects: first, the current -calculated temperature, which is compared to the requested target temperature, -is calculated with the velocity bias removed; second, the thermostat adjusts -only the thermal temperature component of the particle's velocities, which are -the velocities with the bias removed. The removed bias is then added back -to the adjusted velocities. See the doc pages for the individual -fixes and for the :doc:`fix_modify ` command for -instructions on how to assign a temperature compute to a -thermostatting fix. For example, you can apply a thermostat to only -the x and z components of velocity by using it in conjunction with -:doc:`compute temp/partial `. Of you could -thermostat only the thermal temperature of a streaming flow of -particles without affecting the streaming velocity, by using -:doc:`compute temp/profile `. +Any of the thermostatting fixes can be instructed to use custom +temperature computes that remove bias which has two effects: first, +the current calculated temperature, which is compared to the requested +target temperature, is calculated with the velocity bias removed; +second, the thermostat adjusts only the thermal temperature component +of the particle's velocities, which are the velocities with the bias +removed. The removed bias is then added back to the adjusted +velocities. See the doc pages for the individual fixes and for the +:doc:`fix_modify ` command for instructions on how to +assign a temperature compute to a thermostatting fix. -Below is a list of some custom temperature computes that can be used like that: +For example, you can apply a thermostat only to atoms in a spatial +region by using it in conjunction with :doc:`compute temp/region +`. Or you can apply a thermostat to only the x +and z components of velocity by using it with :doc:`compute +temp/partial `. Of you could thermostat only +the thermal temperature of a streaming flow of particles without +affecting the streaming velocity, by using :doc:`compute temp/profile +`. + +Below is a list of custom temperature computes that can be used like +that: * :doc:`compute_temp_asphere` * :doc:`compute_temp_body` @@ -72,8 +80,6 @@ Below is a list of some custom temperature computes that can be used like that: * :doc:`compute_temp_rotate` * :doc:`compute_temp_sphere` - - .. note:: Only the nvt fixes perform time integration, meaning they update @@ -86,17 +92,17 @@ Below is a list of some custom temperature computes that can be used like that: * :doc:`fix nve/sphere ` * :doc:`fix nve/asphere ` -Thermodynamic output, which can be setup via the -:doc:`thermo_style ` command, often includes temperature -values. As explained on the page for the -:doc:`thermo_style ` command, the default temperature is -setup by the thermo command itself. It is NOT the temperature -associated with any thermostatting fix you have defined or with any -compute you have defined that calculates a temperature. The doc pages -for the thermostatting fixes explain the ID of the temperature compute -they create. Thus if you want to view these temperatures, you need to -specify them explicitly via the :doc:`thermo_style custom ` command. Or you can use the -:doc:`thermo_modify ` command to re-define what +Thermodynamic output, which can be setup via the :doc:`thermo_style +` command, often includes temperature values. As +explained on the page for the :doc:`thermo_style ` +command, the default temperature is setup by the thermo command +itself. It is NOT the temperature associated with any thermostatting +fix you have defined or with any compute you have defined that +calculates a temperature. The doc pages for the thermostatting fixes +explain the ID of the temperature compute they create. Thus if you +want to view these temperatures, you need to specify them explicitly +via the :doc:`thermo_style custom ` command. Or you can +use the :doc:`thermo_modify ` command to re-define what temperature compute is used for default thermodynamic output. ---------- diff --git a/doc/src/fix_langevin.rst b/doc/src/fix_langevin.rst index c8be9afc31..5979155799 100644 --- a/doc/src/fix_langevin.rst +++ b/doc/src/fix_langevin.rst @@ -138,16 +138,18 @@ temperature with optional time-dependence as well. Like other fixes that perform thermostatting, this fix can be used with :doc:`compute commands ` that remove a "bias" from the -atom velocities. E.g. removing the center-of-mass velocity from a -group of atoms or removing the x-component of velocity from the -calculation. This is not done by default, but only if the -:doc:`fix_modify ` command is used to assign a temperature -compute to this fix that includes such a bias term. See the doc pages -for individual :doc:`compute commands ` to determine which ones -include a bias. In this case, the thermostat works in the following -manner: bias is removed from each atom, thermostatting is performed on -the remaining thermal degrees of freedom, and the bias is added back -in. +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. The *damp* parameter is specified in time units and determines how rapidly the temperature is relaxed. For example, a value of 100.0 means @@ -183,7 +185,8 @@ omega (which is derived from the angular momentum in the case of aspherical particles). The rotational temperature of the particles can be monitored by the -:doc:`compute temp/sphere ` and :doc:`compute temp/asphere ` commands with their rotate +:doc:`compute temp/sphere ` and :doc:`compute +temp/asphere ` commands with their rotate options. For the *omega* keyword there is also a scale factor of diff --git a/doc/src/fix_langevin_drude.rst b/doc/src/fix_langevin_drude.rst index 3486723a67..89ea28cf08 100644 --- a/doc/src/fix_langevin_drude.rst +++ b/doc/src/fix_langevin_drude.rst @@ -167,17 +167,20 @@ functions, and include :doc:`thermo_style ` command keywords for the simulation box parameters and timestep and elapsed time. Thus it is easy to specify a time-dependent temperature. -Like other fixes that perform thermostatting, this fix can be used with -:doc:`compute commands ` that remove a "bias" from the atom -velocities. E.g. removing the center-of-mass velocity from a group of -atoms. This is not done by default, but only if the -:doc:`fix_modify ` command is used to assign a temperature -compute to this fix that includes such a bias term. See the doc pages -for individual :doc:`compute commands ` to determine which ones -include a bias. In this case, the thermostat works in the following -manner: bias is removed from each atom, thermostatting is performed on -the remaining thermal degrees of freedom, and the bias is added back -in. NOTE: this feature has not been tested. +Like other fixes that perform thermostatting, this fix can be used +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. Note: The temperature thermostatting the core-Drude particle pairs should be chosen low enough, so as to mimic as closely as possible the diff --git a/doc/src/fix_nh.rst b/doc/src/fix_nh.rst index 46b343fdce..cb9e6ba61e 100644 --- a/doc/src/fix_nh.rst +++ b/doc/src/fix_nh.rst @@ -486,19 +486,20 @@ temperature or pressure during thermodynamic output via the compute-ID. It also means that changing attributes of *thermo_temp* or *thermo_press* will have no effect on this fix. -Like other fixes that perform thermostatting, fix nvt and fix npt can -be used with :doc:`compute commands ` that calculate a -temperature after removing a "bias" from the atom velocities. -E.g. removing the center-of-mass velocity from a group of atoms or -only calculating temperature on the x-component of velocity or only -calculating temperature for atoms in a geometric region. This is not -done by default, but only if the :doc:`fix_modify ` command -is used to assign a temperature compute to this fix that includes such -a bias term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +Like other fixes that perform thermostatting, this fix can be used +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_npt_asphere.rst b/doc/src/fix_npt_asphere.rst index 28edb59f8d..64e1c45be7 100644 --- a/doc/src/fix_npt_asphere.rst +++ b/doc/src/fix_npt_asphere.rst @@ -48,8 +48,9 @@ can also have a bias velocity removed from them before thermostatting takes place; see the description below. Additional parameters affecting the thermostat and barostat are -specified by keywords and values documented with the :doc:`fix npt ` command. See, for example, discussion of the *temp*, -*iso*, *aniso*, and *dilate* keywords. +specified by keywords and values documented with the :doc:`fix npt +` command. See, for example, discussion of the *temp*, *iso*, +*aniso*, and *dilate* keywords. The particles in the fix group are the only ones whose velocities and positions are updated by the velocity/position update portion of the @@ -89,18 +90,19 @@ It also means that changing attributes of *thermo_temp* or *thermo_press* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_npt_body.rst b/doc/src/fix_npt_body.rst index d44870a4fb..ff98638b63 100644 --- a/doc/src/fix_npt_body.rst +++ b/doc/src/fix_npt_body.rst @@ -87,18 +87,19 @@ It also means that changing attributes of *thermo_temp* or *thermo_press* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_npt_cauchy.rst b/doc/src/fix_npt_cauchy.rst index 13b5b7bf70..6ff3dffba3 100644 --- a/doc/src/fix_npt_cauchy.rst +++ b/doc/src/fix_npt_cauchy.rst @@ -400,19 +400,20 @@ temperature or pressure during thermodynamic output via the compute-ID. It also means that changing attributes of *thermo_temp* or *thermo_press* will have no effect on this fix. -Like other fixes that perform thermostatting, fix npt/cauchy can -be used with :doc:`compute commands ` that calculate a -temperature after removing a "bias" from the atom velocities. -E.g. removing the center-of-mass velocity from a group of atoms or -only calculating temperature on the x-component of velocity or only -calculating temperature for atoms in a geometric region. This is not -done by default, but only if the :doc:`fix_modify ` command -is used to assign a temperature compute to this fix that includes such -a bias term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +Like other fixes that perform thermostatting, this fix can be used +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_npt_sphere.rst b/doc/src/fix_npt_sphere.rst index 75e4c9a4ec..bd52ca9dc5 100644 --- a/doc/src/fix_npt_sphere.rst +++ b/doc/src/fix_npt_sphere.rst @@ -103,18 +103,19 @@ appropriate compute-ID. It also means that changing attributes of *thermo_temp* or *thermo_press* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_nvt_asphere.rst b/doc/src/fix_nvt_asphere.rst index 00f4588f7f..7ce3aec125 100644 --- a/doc/src/fix_nvt_asphere.rst +++ b/doc/src/fix_nvt_asphere.rst @@ -72,18 +72,19 @@ It also means that changing attributes of *thermo_temp* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_nvt_body.rst b/doc/src/fix_nvt_body.rst index 28ad3e7857..7b9e996a5b 100644 --- a/doc/src/fix_nvt_body.rst +++ b/doc/src/fix_nvt_body.rst @@ -69,18 +69,19 @@ It also means that changing attributes of *thermo_temp* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_nvt_sllod.rst b/doc/src/fix_nvt_sllod.rst index 3d041ca767..4bb4478991 100644 --- a/doc/src/fix_nvt_sllod.rst +++ b/doc/src/fix_nvt_sllod.rst @@ -37,15 +37,16 @@ trajectory consistent with the canonical ensemble. This thermostat is used for a simulation box that is changing size and/or shape, for example in a non-equilibrium MD (NEMD) simulation. -The size/shape change is induced by use of the :doc:`fix deform ` command, so each point in the simulation box -can be thought of as having a "streaming" velocity. This -position-dependent streaming velocity is subtracted from each atom's -actual velocity to yield a thermal velocity which is used for -temperature computation and thermostatting. For example, if the box -is being sheared in x, relative to y, then points at the bottom of the -box (low y) have a small x velocity, while points at the top of the -box (hi y) have a large x velocity. These velocities do not -contribute to the thermal "temperature" of the atom. +The size/shape change is induced by use of the :doc:`fix deform +` command, so each point in the simulation box can be +thought of as having a "streaming" velocity. This position-dependent +streaming velocity is subtracted from each atom's actual velocity to +yield a thermal velocity which is used for temperature computation and +thermostatting. For example, if the box is being sheared in x, +relative to y, then points at the bottom of the box (low y) have a +small x velocity, while points at the top of the box (hi y) have a +large x velocity. These velocities do not contribute to the thermal +"temperature" of the atom. .. note:: @@ -60,13 +61,15 @@ contribute to the thermal "temperature" of the atom. consistent. The SLLOD equations of motion, originally proposed by Hoover and Ladd -(see :ref:`(Evans and Morriss) `), were proven to be equivalent to -Newton's equations of motion for shear flow by :ref:`(Evans and Morriss) `. They were later shown to generate the desired -velocity gradient and the correct production of work by stresses for -all forms of homogeneous flow by :ref:`(Daivis and Todd) `. As -implemented in LAMMPS, they are coupled to a Nose/Hoover chain -thermostat in a velocity Verlet formulation, closely following the -implementation used for the :doc:`fix nvt ` command. +(see :ref:`(Evans and Morriss) `), were proven to be +equivalent to Newton's equations of motion for shear flow by +:ref:`(Evans and Morriss) `. They were later shown to generate +the desired velocity gradient and the correct production of work by +stresses for all forms of homogeneous flow by :ref:`(Daivis and Todd) +`. As implemented in LAMMPS, they are coupled to a +Nose/Hoover chain thermostat in a velocity Verlet formulation, closely +following the implementation used for the :doc:`fix nvt ` +command. .. note:: @@ -94,27 +97,28 @@ underscore + "temp", and the group for the new compute is the same as the fix group. Note that this is NOT the compute used by thermodynamic output (see -the :doc:`thermo_style ` command) with ID = *thermo_temp*. -This means you can change the attributes of this fix's temperature -(e.g. its degrees-of-freedom) via the -:doc:`compute_modify ` command or print this temperature -during thermodynamic output via the :doc:`thermo_style custom ` command using the appropriate compute-ID. -It also means that changing attributes of *thermo_temp* will have no -effect on this fix. +the :doc:`thermo_style ` command) with ID = +*thermo_temp*. This means you can change the attributes of this fix's +temperature (e.g. its degrees-of-freedom) via the :doc:`compute_modify +` command or print this temperature during +thermodynamic output via the :doc:`thermo_style custom ` +command using the appropriate compute-ID. It also means that changing +attributes of *thermo_temp* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_nvt_sphere.rst b/doc/src/fix_nvt_sphere.rst index 31c8d91889..91575d4c48 100644 --- a/doc/src/fix_nvt_sphere.rst +++ b/doc/src/fix_nvt_sphere.rst @@ -86,18 +86,19 @@ It also means that changing attributes of *thermo_temp* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_temp_berendsen.rst b/doc/src/fix_temp_berendsen.rst index 89fc2392f4..473c30aced 100644 --- a/doc/src/fix_temp_berendsen.rst +++ b/doc/src/fix_temp_berendsen.rst @@ -102,18 +102,19 @@ It also means that changing attributes of *thermo_temp* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_temp_csvr.rst b/doc/src/fix_temp_csvr.rst index 81379f346b..5fc6e8eae7 100644 --- a/doc/src/fix_temp_csvr.rst +++ b/doc/src/fix_temp_csvr.rst @@ -110,28 +110,29 @@ during thermodynamic output via the :doc:`thermo_style custom ` co It also means that changing attributes of *thermo_temp* will have no effect on this fix. -Like other fixes that perform thermostatting, these fixes can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +Like other fixes that perform thermostatting, this fix can be used +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. An important feature of these thermostats is that they have an -associated effective energy that is a constant of motion. -The effective energy is the total energy (kinetic + potential) plus -the accumulated kinetic energy changes due to the thermostat. The -latter quantity is the global scalar computed by these fixes. This -feature is useful to check the integration of the equations of motion -against discretization errors. In other words, the conservation of -the effective energy can be used to choose an appropriate integration +associated effective energy that is a constant of motion. The +effective energy is the total energy (kinetic + potential) plus the +accumulated kinetic energy changes due to the thermostat. The latter +quantity is the global scalar computed by these fixes. This feature is +useful to check the integration of the equations of motion against +discretization errors. In other words, the conservation of the +effective energy can be used to choose an appropriate integration :doc:`timestep `. This is similar to the usual paradigm of checking the conservation of the total energy in the microcanonical ensemble. diff --git a/doc/src/fix_temp_rescale.rst b/doc/src/fix_temp_rescale.rst index a61773d2a2..41ad8709cc 100644 --- a/doc/src/fix_temp_rescale.rst +++ b/doc/src/fix_temp_rescale.rst @@ -109,19 +109,19 @@ command using the appropriate compute-ID. It also means that changing attributes of *thermo_temp* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is -used to assign a temperature compute to this fix that includes such a -bias term. See the doc pages for individual :doc:`compute commands -` to determine which ones include a bias. In this case, the -thermostat works in the following manner: the current temperature is -calculated taking the bias into account, bias is removed from each -atom, thermostatting is performed on the remaining thermal degrees of -freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_tgnh_drude.rst b/doc/src/fix_tgnh_drude.rst index 7088692353..d1f5cf19a4 100644 --- a/doc/src/fix_tgnh_drude.rst +++ b/doc/src/fix_tgnh_drude.rst @@ -187,26 +187,32 @@ barostatting. ---------- -Like other fixes that perform thermostatting, these fixes can -be used with :doc:`compute commands ` that calculate a -temperature after removing a "bias" from the atom velocities. -This is not done by default, but only if the :doc:`fix_modify ` command -is used to assign a temperature compute to this fix that includes such -a bias term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal DOF, and the bias is added back in. +Like other fixes that perform thermostatting, this fix can be used +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. .. note:: - However, not all temperature compute commands are valid to be used with these fixes. - Precisely, only temperature compute that does not modify the DOF of the group can be used. - E.g. :doc:`compute temp/ramp ` and :doc:`compute viscosity/cos ` - compute the kinetic energy after remove a velocity gradient without affecting the DOF of the group, - then they can be invoked in this way. - In contrast, :doc:`compute temp/partial ` may remove the DOF at one or more dimensions, - therefore it cannot be used with these fixes. + However, not all temperature compute commands are valid to be used + with these fixes. Precisely, only temperature compute that does + not modify the DOF of the group can be used. E.g. :doc:`compute + temp/ramp ` and :doc:`compute viscosity/cos + ` compute the kinetic energy after remove a + velocity gradient without affecting the DOF of the group, then they + can be invoked in this way. In contrast, :doc:`compute + temp/partial ` may remove the DOF at one or + more dimensions, therefore it cannot be used with these fixes. ---------- diff --git a/doc/utils/requirements.txt b/doc/utils/requirements.txt index f367727d20..9b8e106875 100644 --- a/doc/utils/requirements.txt +++ b/doc/utils/requirements.txt @@ -1,7 +1,7 @@ -Sphinx==4.0.3 -sphinxcontrib-spelling==7.2.1 +Sphinx +sphinxcontrib-spelling git+git://github.com/akohlmey/sphinx-fortran@parallel-read -sphinx_tabs==3.2.0 -breathe==4.31.0 -Pygments==2.10.0 -six==1.16.0 +sphinx_tabs +breathe +Pygments +six diff --git a/lib/machdyn/Install.py b/lib/machdyn/Install.py index 2e90c9ca0f..8471316401 100644 --- a/lib/machdyn/Install.py +++ b/lib/machdyn/Install.py @@ -17,11 +17,12 @@ parser = ArgumentParser(prog='Install.py', # settings -version = '3.3.9' +version = '3.4.0' tarball = "eigen.tar.gz" # known checksums for different Eigen versions. used to validate the download. checksums = { \ + '3.4.0' : '4c527a9171d71a72a9d4186e65bea559', \ '3.3.9' : '609286804b0f79be622ccf7f9ff2b660', \ '3.3.7' : '9e30f67e8531477de4117506fe44669b' \ } @@ -35,7 +36,7 @@ Syntax from src dir: make lib-smd args="-b" Syntax from lib dir: python Install.py -b or: python Install.py -p /usr/include/eigen3" - or: python Install.py -v 3.3.7 -b + or: python Install.py -v 3.4.0 -b Example: @@ -77,7 +78,7 @@ if pathflag: if buildflag: print("Downloading Eigen ...") eigentar = os.path.join(homepath, tarball) - url = "https://gitlab.com/libeigen/eigen/-/archive/%s/eigen-%s.tar.gz" % (version,version) + url = "https://download.lammps.org/thirdparty/eigen-%s.tar.gz" % version geturl(url, eigentar) # verify downloaded archive integrity via md5 checksum, if known. diff --git a/src/.gitignore b/src/.gitignore index e443f1e4d6..91990f77b8 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -27,6 +27,9 @@ /*_ssa.h /*_ssa.cpp +!accelerator_kokkos.h +!accelerator_omp.h + /fix_mdi_engine.cpp /fix_mdi_engine.h /library_mdi.cpp @@ -202,7 +205,6 @@ /plugin.cpp /plugin.h -/lammpsplugin.h /atom_vec_spin.cpp /atom_vec_spin.h @@ -265,8 +267,6 @@ /fix_drag.h /fix_numdiff.cpp /fix_numdiff.h -/fix_nve_noforce.cpp -/fix_nve_noforce.h /fix_spring_rg.cpp /fix_spring_rg.h /fix_temp_csld.cpp @@ -367,8 +367,6 @@ /atom_vec_dpd.h /atom_vec_electron.cpp /atom_vec_electron.h -/atom_vec_ellipsoid.cpp -/atom_vec_ellipsoid.h /atom_vec_full.cpp /atom_vec_full.h /atom_vec_full_hars.cpp @@ -535,8 +533,6 @@ /dihedral_harmonic.h /dihedral_helix.cpp /dihedral_helix.h -/dihedral_hybrid.cpp -/dihedral_hybrid.h /dihedral_multi_harmonic.cpp /dihedral_multi_harmonic.h /dihedral_nharmonic.cpp @@ -885,8 +881,6 @@ /fix_widom.cpp /fix_widom.h /gpu_extra.h -/gridcomm.cpp -/gridcomm.h /group_ndx.cpp /group_ndx.h /gz_file_writer.cpp @@ -911,8 +905,6 @@ /improper_fourier.h /improper_harmonic.cpp /improper_harmonic.h -/improper_hybrid.cpp -/improper_hybrid.h /improper_inversion_harmonic.cpp /improper_inversion_harmonic.h /improper_ring.cpp @@ -1334,8 +1326,6 @@ /thr_data.h /verlet_split.cpp /verlet_split.h -/write_dump.cpp -/write_dump.h /xdr_compat.cpp /xdr_compat.h /zstd_file_writer.cpp diff --git a/src/DPD-REACT/random_external_state.h b/src/DPD-REACT/random_external_state.h index 503118f0bf..9a69392a3b 100644 --- a/src/DPD-REACT/random_external_state.h +++ b/src/DPD-REACT/random_external_state.h @@ -78,8 +78,8 @@ namespace random_external_state { typedef uint64_t es_RNG_t; -enum { MAX_URAND = 0xffffffffU }; -enum { MAX_URAND64 = 0xffffffffffffffffULL - 1 }; +constexpr uint32_t MAX_URAND = 0xffffffffU; +constexpr uint64_t MAX_URAND64 = 0xffffffffffffffffULL - 1; LAMMPS_INLINE uint32_t es_urand(es_RNG_t &state_) diff --git a/src/EXTRA-MOLECULE/angle_gaussian.cpp b/src/EXTRA-MOLECULE/angle_gaussian.cpp index e4310e0a22..54c2aa1880 100644 --- a/src/EXTRA-MOLECULE/angle_gaussian.cpp +++ b/src/EXTRA-MOLECULE/angle_gaussian.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -34,9 +33,9 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ -AngleGaussian::AngleGaussian(LAMMPS *lmp) - : Angle(lmp), nterms(nullptr), angle_temperature(nullptr), - alpha(nullptr), width(nullptr), theta0(nullptr) +AngleGaussian::AngleGaussian(LAMMPS *lmp) : + Angle(lmp), nterms(nullptr), angle_temperature(nullptr), alpha(nullptr), width(nullptr), + theta0(nullptr) { } @@ -49,13 +48,13 @@ AngleGaussian::~AngleGaussian() memory->destroy(nterms); memory->destroy(angle_temperature); for (int i = 1; i <= atom->nangletypes; i++) { - delete [] alpha[i]; - delete [] width[i]; - delete [] theta0[i]; + delete[] alpha[i]; + delete[] width[i]; + delete[] theta0[i]; } - delete [] alpha; - delete [] width; - delete [] theta0; + delete[] alpha; + delete[] width; + delete[] theta0; } } @@ -63,15 +62,15 @@ AngleGaussian::~AngleGaussian() void AngleGaussian::compute(int eflag, int vflag) { - int i1,i2,i3,n,type; - double delx1,dely1,delz1,delx2,dely2,delz2; - double eangle,f1[3],f3[3]; + int i1, i2, i3, n, type; + double delx1, dely1, delz1, delx2, dely2, delz2; + double eangle, f1[3], f3[3]; double dtheta; - double rsq1,rsq2,r1,r2,c,s,a,a11,a12,a22; + double rsq1, rsq2, r1, r2, c, s, a, a11, a12, a22; double prefactor, exponent, g_i, sum_g_i, sum_numerator; eangle = 0.0; - ev_init(eflag,vflag); + ev_init(eflag, vflag); double **x = atom->x; double **f = atom->f; @@ -92,7 +91,7 @@ void AngleGaussian::compute(int eflag, int vflag) dely1 = x[i1][1] - x[i2][1]; delz1 = x[i1][2] - x[i2][2]; - rsq1 = delx1*delx1 + dely1*dely1 + delz1*delz1; + rsq1 = delx1 * delx1 + dely1 * dely1 + delz1 * delz1; r1 = sqrt(rsq1); // 2nd bond @@ -101,20 +100,20 @@ void AngleGaussian::compute(int eflag, int vflag) dely2 = x[i3][1] - x[i2][1]; delz2 = x[i3][2] - x[i2][2]; - rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2; + rsq2 = delx2 * delx2 + dely2 * dely2 + delz2 * delz2; r2 = sqrt(rsq2); // angle (cos and sin) - c = delx1*delx2 + dely1*dely2 + delz1*delz2; - c /= r1*r2; + c = delx1 * delx2 + dely1 * dely2 + delz1 * delz2; + c /= r1 * r2; if (c > 1.0) c = 1.0; if (c < -1.0) c = -1.0; - s = sqrt(1.0 - c*c); + s = sqrt(1.0 - c * c); if (s < SMAL) s = SMAL; - s = 1.0/s; + s = 1.0 / s; // force & energy double theta = acos(c); @@ -123,28 +122,28 @@ void AngleGaussian::compute(int eflag, int vflag) sum_numerator = 0.0; for (int i = 0; i < nterms[type]; i++) { dtheta = theta - theta0[type][i]; - prefactor = (alpha[type][i]/(width[type][i]*sqrt(MY_PI2))); - exponent = -2*dtheta*dtheta/(width[type][i]*width[type][i]); - g_i = prefactor*exp(exponent); + prefactor = (alpha[type][i] / (width[type][i] * sqrt(MY_PI2))); + exponent = -2 * dtheta * dtheta / (width[type][i] * width[type][i]); + g_i = prefactor * exp(exponent); sum_g_i += g_i; - sum_numerator += g_i*dtheta/(width[type][i]*width[type][i]); + sum_numerator += g_i * dtheta / (width[type][i] * width[type][i]); } if (sum_g_i < SMALL) sum_g_i = SMALL; - if (eflag) eangle = -(force->boltz*angle_temperature[type])*log(sum_g_i); + if (eflag) eangle = -(force->boltz * angle_temperature[type]) * log(sum_g_i); // I should check about the sign of this expression - a = -4.0*(force->boltz*angle_temperature[type])*(sum_numerator/sum_g_i)*s; - a11 = a*c / rsq1; - a12 = -a / (r1*r2); - a22 = a*c / rsq2; + a = -4.0 * (force->boltz * angle_temperature[type]) * (sum_numerator / sum_g_i) * s; + a11 = a * c / rsq1; + a12 = -a / (r1 * r2); + a22 = a * c / rsq2; - f1[0] = a11*delx1 + a12*delx2; - f1[1] = a11*dely1 + a12*dely2; - f1[2] = a11*delz1 + a12*delz2; - f3[0] = a22*delx2 + a12*delx1; - f3[1] = a22*dely2 + a12*dely1; - f3[2] = a22*delz2 + a12*delz1; + f1[0] = a11 * delx1 + a12 * delx2; + f1[1] = a11 * dely1 + a12 * dely2; + f1[2] = a11 * delz1 + a12 * delz2; + f3[0] = a22 * delx2 + a12 * delx1; + f3[1] = a22 * dely2 + a12 * dely1; + f3[2] = a22 * delz2 + a12 * delz1; // apply force to each of 3 atoms @@ -166,8 +165,9 @@ void AngleGaussian::compute(int eflag, int vflag) f[i3][2] += f3[2]; } - if (evflag) ev_tally(i1,i2,i3,nlocal,newton_bond,eangle,f1,f3, - delx1,dely1,delz1,delx2,dely2,delz2); + if (evflag) + ev_tally(i1, i2, i3, nlocal, newton_bond, eangle, f1, f3, delx1, dely1, delz1, delx2, dely2, + delz2); } } @@ -176,20 +176,20 @@ void AngleGaussian::compute(int eflag, int vflag) void AngleGaussian::allocate() { allocated = 1; - int n = atom->nangletypes; + int n = atom->nangletypes + 1; - memory->create(nterms,n+1,"angle:nterms"); - memory->create(angle_temperature,n+1,"angle:angle_temperature"); + memory->create(nterms, n, "angle:nterms"); + memory->create(angle_temperature, n, "angle:angle_temperature"); - alpha = new double *[n+1]; - width = new double *[n+1]; - theta0 = new double *[n+1]; - memset(alpha,0,sizeof(double)*(n+1)); - memset(width,0,sizeof(double)*(n+1)); - memset(theta0,0,sizeof(double)*(n+1)); + alpha = new double *[n]; + width = new double *[n]; + theta0 = new double *[n]; + memset(alpha, 0, sizeof(double *) * n); + memset(width, 0, sizeof(double *) * n); + memset(theta0, 0, sizeof(double *) * n); - memory->create(setflag,n+1,"angle:setflag"); - for (int i = 1; i <= n; i++) setflag[i] = 0; + memory->create(setflag, n, "angle:setflag"); + memset(setflag, 0, sizeof(int) * n); } /* ---------------------------------------------------------------------- @@ -198,15 +198,14 @@ void AngleGaussian::allocate() void AngleGaussian::coeff(int narg, char **arg) { - if (narg < 6) error->all(FLERR,"Incorrect args for angle coefficients"); + if (narg < 6) error->all(FLERR, "Incorrect args for angle coefficients"); - int ilo,ihi; - utils::bounds(FLERR,arg[0],1,atom->nangletypes,ilo,ihi,error); + int ilo, ihi; + utils::bounds(FLERR, arg[0], 1, atom->nangletypes, ilo, ihi, error); - double angle_temperature_one = utils::numeric(FLERR,arg[1],false,lmp); - int n = utils::inumeric(FLERR,arg[2],false,lmp); - if (narg != 3*n + 3) - error->all(FLERR,"Incorrect args for angle coefficients"); + double angle_temperature_one = utils::numeric(FLERR, arg[1], false, lmp); + int n = utils::inumeric(FLERR, arg[2], false, lmp); + if (narg != 3 * n + 3) error->all(FLERR, "Incorrect args for angle coefficients"); if (!allocated) allocate(); @@ -217,21 +216,21 @@ void AngleGaussian::coeff(int narg, char **arg) angle_temperature[i] = angle_temperature_one; nterms[i] = n; delete[] alpha[i]; - alpha[i] = new double [n]; + alpha[i] = new double[n]; delete[] width[i]; - width[i] = new double [n]; + width[i] = new double[n]; delete[] theta0[i]; - theta0[i] = new double [n]; + theta0[i] = new double[n]; for (int j = 0; j < n; j++) { - alpha[i][j] = utils::numeric(FLERR,arg[3+3*j],false,lmp); - width[i][j] = utils::numeric(FLERR,arg[4+3*j],false,lmp); - theta0[i][j] = utils::numeric(FLERR,arg[5+3*j],false,lmp)* MY_PI / 180.0; + alpha[i][j] = utils::numeric(FLERR, arg[3 + 3 * j], false, lmp); + width[i][j] = utils::numeric(FLERR, arg[4 + 3 * j], false, lmp); + theta0[i][j] = utils::numeric(FLERR, arg[5 + 3 * j], false, lmp) * MY_PI / 180.0; setflag[i] = 1; } count++; } - if (count == 0) error->all(FLERR,"Incorrect args for angle coefficients"); + if (count == 0) error->all(FLERR, "Incorrect args for angle coefficients"); } /* ---------------------------------------------------------------------- */ @@ -247,12 +246,12 @@ double AngleGaussian::equilibrium_angle(int i) void AngleGaussian::write_restart(FILE *fp) { - fwrite(&angle_temperature[1],sizeof(double),atom->nangletypes,fp); - fwrite(&nterms[1],sizeof(int),atom->nangletypes,fp); + fwrite(&angle_temperature[1], sizeof(double), atom->nangletypes, fp); + fwrite(&nterms[1], sizeof(int), atom->nangletypes, fp); for (int i = 1; i <= atom->nangletypes; i++) { - fwrite(alpha[i],sizeof(double),nterms[i],fp); - fwrite(width[i],sizeof(double),nterms[i],fp); - fwrite(theta0[i],sizeof(double),nterms[i],fp); + fwrite(alpha[i], sizeof(double), nterms[i], fp); + fwrite(width[i], sizeof(double), nterms[i], fp); + fwrite(theta0[i], sizeof(double), nterms[i], fp); } } @@ -265,31 +264,32 @@ void AngleGaussian::read_restart(FILE *fp) allocate(); if (comm->me == 0) { - utils::sfread(FLERR,&angle_temperature[1],sizeof(double),atom->nangletypes,fp,nullptr,error); - utils::sfread(FLERR,&nterms[1],sizeof(int),atom->nangletypes,fp,nullptr,error); + utils::sfread(FLERR, &angle_temperature[1], sizeof(double), atom->nangletypes, fp, nullptr, + error); + utils::sfread(FLERR, &nterms[1], sizeof(int), atom->nangletypes, fp, nullptr, error); } - MPI_Bcast(&angle_temperature[1],atom->nangletypes,MPI_DOUBLE,0,world); - MPI_Bcast(&nterms[1],atom->nangletypes,MPI_INT,0,world); + MPI_Bcast(&angle_temperature[1], atom->nangletypes, MPI_DOUBLE, 0, world); + MPI_Bcast(&nterms[1], atom->nangletypes, MPI_INT, 0, world); // allocate for (int i = 1; i <= atom->nangletypes; i++) { - alpha[i] = new double [nterms[i]]; - width[i] = new double [nterms[i]]; - theta0[i] = new double [nterms[i]]; + alpha[i] = new double[nterms[i]]; + width[i] = new double[nterms[i]]; + theta0[i] = new double[nterms[i]]; } if (comm->me == 0) { for (int i = 1; i <= atom->nangletypes; i++) { - utils::sfread(FLERR,alpha[i],sizeof(double),nterms[i],fp,nullptr,error); - utils::sfread(FLERR,width[i],sizeof(double),nterms[i],fp,nullptr,error); - utils::sfread(FLERR,theta0[i],sizeof(double),nterms[i],fp,nullptr,error); + utils::sfread(FLERR, alpha[i], sizeof(double), nterms[i], fp, nullptr, error); + utils::sfread(FLERR, width[i], sizeof(double), nterms[i], fp, nullptr, error); + utils::sfread(FLERR, theta0[i], sizeof(double), nterms[i], fp, nullptr, error); } } for (int i = 1; i <= atom->nangletypes; i++) { - MPI_Bcast(alpha[i],nterms[i],MPI_DOUBLE,0,world); - MPI_Bcast(width[i],nterms[i],MPI_DOUBLE,0,world); - MPI_Bcast(theta0[i],nterms[i],MPI_DOUBLE,0,world); + MPI_Bcast(alpha[i], nterms[i], MPI_DOUBLE, 0, world); + MPI_Bcast(width[i], nterms[i], MPI_DOUBLE, 0, world); + MPI_Bcast(theta0[i], nterms[i], MPI_DOUBLE, 0, world); } for (int i = 1; i <= atom->nangletypes; i++) setflag[i] = 1; @@ -302,13 +302,12 @@ void AngleGaussian::read_restart(FILE *fp) void AngleGaussian::write_data(FILE *fp) { for (int i = 1; i <= atom->nangletypes; i++) { - fprintf(fp,"%d %g %d",i,angle_temperature[i],nterms[i]); + fprintf(fp, "%d %g %d", i, angle_temperature[i], nterms[i]); for (int j = 0; j < nterms[i]; j++) { - fprintf(fp," %g %g %g",alpha[i][j],width[i][j],(theta0[i][j]/MY_PI)*180.0); + fprintf(fp, " %g %g %g", alpha[i][j], width[i][j], (theta0[i][j] / MY_PI) * 180.0); } fprintf(fp, "\n"); } - } /* ---------------------------------------------------------------------- */ @@ -320,30 +319,30 @@ double AngleGaussian::single(int type, int i1, int i2, int i3) double delx1 = x[i1][0] - x[i2][0]; double dely1 = x[i1][1] - x[i2][1]; double delz1 = x[i1][2] - x[i2][2]; - domain->minimum_image(delx1,dely1,delz1); - double r1 = sqrt(delx1*delx1 + dely1*dely1 + delz1*delz1); + domain->minimum_image(delx1, dely1, delz1); + double r1 = sqrt(delx1 * delx1 + dely1 * dely1 + delz1 * delz1); double delx2 = x[i3][0] - x[i2][0]; double dely2 = x[i3][1] - x[i2][1]; double delz2 = x[i3][2] - x[i2][2]; - domain->minimum_image(delx2,dely2,delz2); - double r2 = sqrt(delx2*delx2 + dely2*dely2 + delz2*delz2); + domain->minimum_image(delx2, dely2, delz2); + double r2 = sqrt(delx2 * delx2 + dely2 * dely2 + delz2 * delz2); - double c = delx1*delx2 + dely1*dely2 + delz1*delz2; - c /= r1*r2; + double c = delx1 * delx2 + dely1 * dely2 + delz1 * delz2; + c /= r1 * r2; if (c > 1.0) c = 1.0; if (c < -1.0) c = -1.0; - double theta = acos(c) ; + double theta = acos(c); double sum_g_i = 0.0; for (int i = 0; i < nterms[type]; i++) { double dtheta = theta - theta0[type][i]; - double prefactor = (alpha[type][i]/(width[type][i]*sqrt(MY_PI2))); - double exponent = -2*dtheta*dtheta/(width[type][i]*width[type][i]); - double g_i = prefactor*exp(exponent); + double prefactor = (alpha[type][i] / (width[type][i] * sqrt(MY_PI2))); + double exponent = -2 * dtheta * dtheta / (width[type][i] * width[type][i]); + double g_i = prefactor * exp(exponent); sum_g_i += g_i; } if (sum_g_i < SMALL) sum_g_i = SMALL; - return -(force->boltz*angle_temperature[type])*log(sum_g_i); + return -(force->boltz * angle_temperature[type]) * log(sum_g_i); } diff --git a/src/EXTRA-MOLECULE/bond_gaussian.cpp b/src/EXTRA-MOLECULE/bond_gaussian.cpp index ca0bd13df8..c2ab00dfde 100644 --- a/src/EXTRA-MOLECULE/bond_gaussian.cpp +++ b/src/EXTRA-MOLECULE/bond_gaussian.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -14,16 +13,16 @@ #include "bond_gaussian.h" -#include -#include #include "atom.h" -#include "neighbor.h" #include "comm.h" +#include "error.h" #include "force.h" #include "math_const.h" #include "memory.h" -#include "error.h" +#include "neighbor.h" +#include +#include using namespace LAMMPS_NS; using namespace MathConst; @@ -32,9 +31,9 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ -BondGaussian::BondGaussian(LAMMPS *lmp) - : Bond(lmp), nterms(nullptr), bond_temperature(nullptr), - alpha(nullptr), width(nullptr), r0(nullptr) +BondGaussian::BondGaussian(LAMMPS *lmp) : + Bond(lmp), nterms(nullptr), bond_temperature(nullptr), alpha(nullptr), width(nullptr), + r0(nullptr) { reinitflag = 1; } @@ -48,13 +47,13 @@ BondGaussian::~BondGaussian() memory->destroy(nterms); memory->destroy(bond_temperature); for (int i = 1; i <= atom->nbondtypes; i++) { - delete [] alpha[i]; - delete [] width[i]; - delete [] r0[i]; + delete[] alpha[i]; + delete[] width[i]; + delete[] r0[i]; } - delete [] alpha; - delete [] width; - delete [] r0; + delete[] alpha; + delete[] width; + delete[] r0; } } @@ -62,13 +61,13 @@ BondGaussian::~BondGaussian() void BondGaussian::compute(int eflag, int vflag) { - int i1,i2,n,type; - double delx,dely,delz,ebond,fbond; - double rsq,r,dr; + int i1, i2, n, type; + double delx, dely, delz, ebond, fbond; + double rsq, r, dr; double prefactor, exponent, g_i, sum_g_i, sum_numerator; ebond = 0.0; - ev_init(eflag,vflag); + ev_init(eflag, vflag); double **x = atom->x; double **f = atom->f; @@ -86,43 +85,45 @@ void BondGaussian::compute(int eflag, int vflag) dely = x[i1][1] - x[i2][1]; delz = x[i1][2] - x[i2][2]; - rsq = delx*delx + dely*dely + delz*delz; + rsq = delx * delx + dely * dely + delz * delz; r = sqrt(rsq); sum_g_i = 0.0; sum_numerator = 0.0; for (int i = 0; i < nterms[type]; i++) { dr = r - r0[type][i]; - prefactor = (alpha[type][i]/(width[type][i]*sqrt(MY_PI2))); - exponent = -2*dr*dr/(width[type][i]*width[type][i]); - g_i = prefactor*exp(exponent); + prefactor = (alpha[type][i] / (width[type][i] * sqrt(MY_PI2))); + exponent = -2 * dr * dr / (width[type][i] * width[type][i]); + g_i = prefactor * exp(exponent); sum_g_i += g_i; - sum_numerator += g_i*dr/(width[type][i]*width[type][i]); + sum_numerator += g_i * dr / (width[type][i] * width[type][i]); } // force & energy if (sum_g_i < SMALL) sum_g_i = SMALL; - if (r > 0.0) fbond = -4.0*(force->boltz*bond_temperature[type])*(sum_numerator/sum_g_i)/r; - else fbond = 0.0; + if (r > 0.0) + fbond = -4.0 * (force->boltz * bond_temperature[type]) * (sum_numerator / sum_g_i) / r; + else + fbond = 0.0; - if (eflag) ebond = -(force->boltz*bond_temperature[type])*log(sum_g_i); + if (eflag) ebond = -(force->boltz * bond_temperature[type]) * log(sum_g_i); // apply force to each of 2 atoms if (newton_bond || i1 < nlocal) { - f[i1][0] += delx*fbond; - f[i1][1] += dely*fbond; - f[i1][2] += delz*fbond; + f[i1][0] += delx * fbond; + f[i1][1] += dely * fbond; + f[i1][2] += delz * fbond; } if (newton_bond || i2 < nlocal) { - f[i2][0] -= delx*fbond; - f[i2][1] -= dely*fbond; - f[i2][2] -= delz*fbond; + f[i2][0] -= delx * fbond; + f[i2][1] -= dely * fbond; + f[i2][2] -= delz * fbond; } - if (evflag) ev_tally(i1,i2,nlocal,newton_bond,ebond,fbond,delx,dely,delz); + if (evflag) ev_tally(i1, i2, nlocal, newton_bond, ebond, fbond, delx, dely, delz); } } @@ -131,20 +132,20 @@ void BondGaussian::compute(int eflag, int vflag) void BondGaussian::allocate() { allocated = 1; - int n = atom->nbondtypes; + int n = atom->nbondtypes + 1; - memory->create(nterms,n+1,"bond:nterms"); - memory->create(bond_temperature,n+1,"bond:bond_temperature"); + memory->create(nterms, n, "bond:nterms"); + memory->create(bond_temperature, n, "bond:bond_temperature"); - alpha = new double *[n+1]; - width = new double *[n+1]; - r0 = new double *[n+1]; - memset(alpha,0,sizeof(double)*(n+1)); - memset(width,0,sizeof(double)*(n+1)); - memset(r0,0,sizeof(double)*(n+1)); + alpha = new double *[n]; + width = new double *[n]; + r0 = new double *[n]; + memset(alpha, 0, sizeof(double *) * n); + memset(width, 0, sizeof(double *) * n); + memset(r0, 0, sizeof(double *) * n); - memory->create(setflag,n+1,"bond:setflag"); - for (int i = 1; i <= n; i++) setflag[i] = 0; + memory->create(setflag, n, "bond:setflag"); + memset(setflag, 0, sizeof(int) * n); } /* ---------------------------------------------------------------------- @@ -153,15 +154,14 @@ void BondGaussian::allocate() void BondGaussian::coeff(int narg, char **arg) { - if (narg < 6) error->all(FLERR,"Incorrect args for bond coefficients"); + if (narg < 6) error->all(FLERR, "Incorrect args for bond coefficients"); - int ilo,ihi; - utils::bounds(FLERR,arg[0],1,atom->nbondtypes,ilo,ihi,error); + int ilo, ihi; + utils::bounds(FLERR, arg[0], 1, atom->nbondtypes, ilo, ihi, error); - double bond_temp_one = utils::numeric(FLERR,arg[1],false,lmp); - int n = utils::inumeric(FLERR,arg[2],false,lmp); - if (narg != 3*n + 3) - error->all(FLERR,"Incorrect args for bond coefficients"); + double bond_temp_one = utils::numeric(FLERR, arg[1], false, lmp); + int n = utils::inumeric(FLERR, arg[2], false, lmp); + if (narg != 3 * n + 3) error->all(FLERR, "Incorrect args for bond coefficients"); if (!allocated) allocate(); @@ -170,21 +170,21 @@ void BondGaussian::coeff(int narg, char **arg) bond_temperature[i] = bond_temp_one; nterms[i] = n; delete[] alpha[i]; - alpha[i] = new double [n]; + alpha[i] = new double[n]; delete[] width[i]; - width[i] = new double [n]; + width[i] = new double[n]; delete[] r0[i]; - r0[i] = new double [n]; + r0[i] = new double[n]; for (int j = 0; j < n; j++) { - alpha[i][j] = utils::numeric(FLERR,arg[3+3*j],false,lmp); - width[i][j] = utils::numeric(FLERR,arg[4+3*j],false,lmp); - r0[i][j] = utils::numeric(FLERR,arg[5+3*j],false,lmp); + alpha[i][j] = utils::numeric(FLERR, arg[3 + 3 * j], false, lmp); + width[i][j] = utils::numeric(FLERR, arg[4 + 3 * j], false, lmp); + r0[i][j] = utils::numeric(FLERR, arg[5 + 3 * j], false, lmp); setflag[i] = 1; } count++; } - if (count == 0) error->all(FLERR,"Incorrect args for bond coefficients"); + if (count == 0) error->all(FLERR, "Incorrect args for bond coefficients"); } /* ---------------------------------------------------------------------- @@ -202,12 +202,12 @@ double BondGaussian::equilibrium_distance(int i) void BondGaussian::write_restart(FILE *fp) { - fwrite(&bond_temperature[1],sizeof(double),atom->nbondtypes,fp); - fwrite(&nterms[1],sizeof(int),atom->nbondtypes,fp); + fwrite(&bond_temperature[1], sizeof(double), atom->nbondtypes, fp); + fwrite(&nterms[1], sizeof(int), atom->nbondtypes, fp); for (int i = 1; i <= atom->nbondtypes; i++) { - fwrite(alpha[i],sizeof(double),nterms[i],fp); - fwrite(width[i],sizeof(double),nterms[i],fp); - fwrite(r0[i],sizeof(double),nterms[i],fp); + fwrite(alpha[i], sizeof(double), nterms[i], fp); + fwrite(width[i], sizeof(double), nterms[i], fp); + fwrite(r0[i], sizeof(double), nterms[i], fp); } } @@ -220,31 +220,32 @@ void BondGaussian::read_restart(FILE *fp) allocate(); if (comm->me == 0) { - utils::sfread(FLERR,&bond_temperature[1],sizeof(double),atom->nbondtypes,fp,nullptr,error); - utils::sfread(FLERR,&nterms[1],sizeof(int),atom->nbondtypes,fp,nullptr,error); + utils::sfread(FLERR, &bond_temperature[1], sizeof(double), atom->nbondtypes, fp, nullptr, + error); + utils::sfread(FLERR, &nterms[1], sizeof(int), atom->nbondtypes, fp, nullptr, error); } - MPI_Bcast(&bond_temperature[1],atom->nbondtypes,MPI_DOUBLE,0,world); - MPI_Bcast(&nterms[1],atom->nbondtypes,MPI_INT,0,world); + MPI_Bcast(&bond_temperature[1], atom->nbondtypes, MPI_DOUBLE, 0, world); + MPI_Bcast(&nterms[1], atom->nbondtypes, MPI_INT, 0, world); // allocate for (int i = 1; i <= atom->nbondtypes; i++) { - alpha[i] = new double [nterms[i]]; - width[i] = new double [nterms[i]]; - r0[i] = new double [nterms[i]]; + alpha[i] = new double[nterms[i]]; + width[i] = new double[nterms[i]]; + r0[i] = new double[nterms[i]]; } if (comm->me == 0) { for (int i = 1; i <= atom->nbondtypes; i++) { - utils::sfread(FLERR,alpha[i],sizeof(double),nterms[i],fp,nullptr,error); - utils::sfread(FLERR,width[i],sizeof(double),nterms[i],fp,nullptr,error); - utils::sfread(FLERR,r0[i],sizeof(double),nterms[i],fp,nullptr,error); + utils::sfread(FLERR, alpha[i], sizeof(double), nterms[i], fp, nullptr, error); + utils::sfread(FLERR, width[i], sizeof(double), nterms[i], fp, nullptr, error); + utils::sfread(FLERR, r0[i], sizeof(double), nterms[i], fp, nullptr, error); } } for (int i = 1; i <= atom->nbondtypes; i++) { - MPI_Bcast(alpha[i],nterms[i],MPI_DOUBLE,0,world); - MPI_Bcast(width[i],nterms[i],MPI_DOUBLE,0,world); - MPI_Bcast(r0[i],nterms[i],MPI_DOUBLE,0,world); + MPI_Bcast(alpha[i], nterms[i], MPI_DOUBLE, 0, world); + MPI_Bcast(width[i], nterms[i], MPI_DOUBLE, 0, world); + MPI_Bcast(r0[i], nterms[i], MPI_DOUBLE, 0, world); } for (int i = 1; i <= atom->nbondtypes; i++) setflag[i] = 1; @@ -257,9 +258,9 @@ void BondGaussian::read_restart(FILE *fp) void BondGaussian::write_data(FILE *fp) { for (int i = 1; i <= atom->nbondtypes; i++) { - fprintf(fp,"%d %g %d",i,bond_temperature[i],nterms[i]); + fprintf(fp, "%d %g %d", i, bond_temperature[i], nterms[i]); for (int j = 0; j < nterms[i]; j++) { - fprintf(fp," %g %g %g",alpha[i][j],width[i][j],r0[i][j]); + fprintf(fp, " %g %g %g", alpha[i][j], width[i][j], r0[i][j]); } fprintf(fp, "\n"); } @@ -267,26 +268,25 @@ void BondGaussian::write_data(FILE *fp) /* ---------------------------------------------------------------------- */ -double BondGaussian::single(int type, double rsq, int /*i*/, int /*j*/, - double &fforce) +double BondGaussian::single(int type, double rsq, int /*i*/, int /*j*/, double &fforce) { double r = sqrt(rsq); fforce = 0; double sum_g_i = 0.0; double sum_numerator = 0.0; - for (int i = 0; i < nterms[type]; i++) { - double dr = r - r0[type][i]; - double prefactor = (alpha[type][i]/(width[type][i]*sqrt(MY_PI2))); - double exponent = -2*dr*dr/(width[type][i]*width[type][i]); - double g_i = prefactor*exp(exponent); - sum_g_i += g_i; - sum_numerator += g_i*dr/(width[type][i]*width[type][i]); - } + for (int i = 0; i < nterms[type]; i++) { + double dr = r - r0[type][i]; + double prefactor = (alpha[type][i] / (width[type][i] * sqrt(MY_PI2))); + double exponent = -2 * dr * dr / (width[type][i] * width[type][i]); + double g_i = prefactor * exp(exponent); + sum_g_i += g_i; + sum_numerator += g_i * dr / (width[type][i] * width[type][i]); + } if (sum_g_i < SMALL) sum_g_i = SMALL; - if (r > 0.0) fforce = -4.0*(force->boltz*bond_temperature[type])*(sum_numerator/sum_g_i)/r; + if (r > 0.0) + fforce = -4.0 * (force->boltz * bond_temperature[type]) * (sum_numerator / sum_g_i) / r; - return -(force->boltz*bond_temperature[type])*log(sum_g_i); + return -(force->boltz * bond_temperature[type]) * log(sum_g_i); } - diff --git a/src/INTERLAYER/pair_drip.cpp b/src/INTERLAYER/pair_drip.cpp index e9d32bdb8b..b9a4d1f05b 100644 --- a/src/INTERLAYER/pair_drip.cpp +++ b/src/INTERLAYER/pair_drip.cpp @@ -31,7 +31,6 @@ #include "neigh_request.h" #include "neighbor.h" #include "potential_file_reader.h" -#include "tokenizer.h" #include #include @@ -241,17 +240,17 @@ void PairDRIP::read_file(char *filename) nparams++; } - - MPI_Bcast(&nparams, 1, MPI_INT, 0, world); - MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - - if (comm->me != 0) { - params = (Param *) memory->srealloc(params, maxparam * sizeof(Param), "pair:params"); - } - - MPI_Bcast(params, maxparam * sizeof(Param), MPI_BYTE, 0, world); } + MPI_Bcast(&nparams, 1, MPI_INT, 0, world); + MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); + + if (comm->me != 0) { + params = (Param *) memory->srealloc(params, maxparam * sizeof(Param), "pair:params"); + } + + MPI_Bcast(params, maxparam * sizeof(Param), MPI_BYTE, 0, world); + memory->destroy(elem2param); memory->create(elem2param, nelements, nelements, "pair:elem2param"); for (int i = 0; i < nelements; i++) { diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index 05c839db3f..cd829ec3e4 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -25,7 +25,9 @@ #include #include -enum{FULL=1u,HALFTHREAD=2u,HALF=4u}; +constexpr int FULL = 1; +constexpr int HALFTHREAD = 2; +constexpr int HALF = 4; #if defined(KOKKOS_ENABLE_CXX11) #undef ISFINITE diff --git a/src/MISC/fix_ipi.cpp b/src/MISC/fix_ipi.cpp index b56c5eebcb..b82339713e 100644 --- a/src/MISC/fix_ipi.cpp +++ b/src/MISC/fix_ipi.cpp @@ -200,22 +200,10 @@ FixIPI::FixIPI(LAMMPS *lmp, int narg, char **arg) : hasdata = bsize = 0; // creates a temperature compute for all atoms - char** newarg = new char*[3]; - newarg[0] = (char *) "IPI_TEMP"; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "temp"; - modify->add_compute(3,newarg); - delete [] newarg; + modify->add_compute("IPI_TEMP all temp"); // creates a pressure compute to extract the virial - newarg = new char*[5]; - newarg[0] = (char *) "IPI_PRESS"; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "pressure"; - newarg[3] = (char *) "IPI_TEMP"; - newarg[4] = (char *) "virial"; - modify->add_compute(5,newarg); - delete [] newarg; + modify->add_compute("IPI_PRESS all pressure IPI_TEMP virial"); // create instance of Irregular class irregular = new Irregular(lmp); diff --git a/src/PLUMED/fix_plumed.cpp b/src/PLUMED/fix_plumed.cpp index b38e745b7a..7a142b57f8 100644 --- a/src/PLUMED/fix_plumed.cpp +++ b/src/PLUMED/fix_plumed.cpp @@ -215,31 +215,13 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) : // Define compute to calculate potential energy - id_pe = new char[8]; - strcpy(id_pe,"plmd_pe"); - char **newarg = new char*[3]; - newarg[0] = id_pe; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "pe"; - modify->add_compute(3,newarg); - delete [] newarg; - int ipe = modify->find_compute(id_pe); - c_pe = modify->compute[ipe]; + id_pe = utils::strdup("plmd_pe"); + c_pe = modify->add_compute(std::string(id_pe) + " all pe"); // Define compute to calculate pressure tensor - id_press = new char[11]; - strcpy(id_press,"plmd_press"); - newarg = new char*[5]; - newarg[0] = id_press; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "pressure"; - newarg[3] = (char *) "NULL"; - newarg[4] = (char *) "virial"; - modify->add_compute(5,newarg); - delete [] newarg; - int ipress = modify->find_compute(id_press); - c_press = modify->compute[ipress]; + id_press = utils::strdup("plmd_press"); + c_press = modify->add_compute(std::string(id_press) + " all pressure NULL virial"); for (int i = 0; i < modify->nfix; i++) { const char * const check_style = modify->fix[i]->style; diff --git a/src/exceptions.h b/src/exceptions.h index d05e14eeb7..1df6c5d1a3 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -35,8 +35,8 @@ class LAMMPSAbortException : public LAMMPSException { public: MPI_Comm universe; - LAMMPSAbortException(const std::string &msg, MPI_Comm universe) : - LAMMPSException(msg), universe(universe) + LAMMPSAbortException(const std::string &msg, MPI_Comm _universe) : + LAMMPSException(msg), universe(_universe) { } }; diff --git a/src/lammpsplugin.h b/src/lammpsplugin.h index 93bf418893..5df0172763 100644 --- a/src/lammpsplugin.h +++ b/src/lammpsplugin.h @@ -15,8 +15,9 @@ #define LMP_LAMMPSPLUGIN_H // C style API and data structure required for dynamic loading - +#ifdef __cplusplus extern "C" { +#endif typedef void *(lammpsplugin_factory1) (void *); typedef void *(lammpsplugin_factory2) (void *, int, char **); @@ -41,6 +42,9 @@ typedef void (*lammpsplugin_initfunc)(void *, void *, void *); // to load a plugin; uses C bindings void lammpsplugin_init(void *, void *, void *); + +#ifdef __cplusplus } +#endif #endif diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 538cd716ad..43660d68ec 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -49,8 +49,8 @@ TokenizerException::TokenizerException(const std::string &msg, const std::string * \param str string to be processed * \param separators string with separator characters (default: " \t\r\n\f") */ -Tokenizer::Tokenizer(const std::string &str, const std::string &separators) : - text(str), separators(separators), start(0), ntokens(std::string::npos) +Tokenizer::Tokenizer(const std::string &str, const std::string &_separators) : + text(str), separators(_separators), start(0), ntokens(std::string::npos) { // replace known UTF-8 characters with ASCII equivalents if (utils::has_utf8(text)) text = utils::utf8_subst(text); diff --git a/tools/singularity/README.md b/tools/singularity/README.md index 3f7b69d409..bd13d75ad7 100644 --- a/tools/singularity/README.md +++ b/tools/singularity/README.md @@ -10,12 +10,6 @@ workstation, e.g. when bugs are reported that can only be reproduced on a specific OS or with specific (mostly older) versions of tools, compilers, or libraries. -Ready-to-use container images built from some these definition files are -occasionally uploaded to the container library at sylabs.io. They -can be found here: https://cloud.sylabs.io/library/lammps/default/lammps_development# -and will be signed with a GPG key that has the fingerprint: -EEA103764C6C633EDC8AC428D9B44E93BF0C375A - Here is a workflow for testing a compilation of LAMMPS with a locally built CentOS 7.x singularity container. @@ -30,34 +24,3 @@ cmake -C ../cmake/presets/most.cmake ../cmake make ``` -And here is the equivalent workflow for testing a compilation of LAMMPS -using a pre-built Ubuntu 18.04LTS singularity container. - -``` -cd some/work/directory -git clone --depth 500 git://github.com/lammps/lammps.git lammps -mkdir build-ubuntu18 -cd build-ubuntu18 -singularity pull library://lammps/default/lammps_development:ubuntu18.04 -singularity exec lammps_development_ubuntu18.04.sif bash --login -cmake -C ../cmake/presets/most.cmake ../cmake -make -``` - -| Currently available: | Description | -| ------------------------------ | ---------------------------------------------- | -| centos7.def | CentOS 7.x with EPEL enabled, no LaTeX | -| centos8.def | CentOS 8.x with EPEL enabled | -| fedora34_mingw.def | Fedora 34 with MinGW cross-compiler toolchain | -| ubuntu16.04.def | Ubuntu 16.04LTS with MPI == OpenMPI, no LaTeX | -| ubuntu18.04.def | Ubuntu 18.04LTS with MPI == OpenMPI | -| ubuntu18.04_amd_rocm.def | Ubuntu 18.04LTS with AMD ROCm toolkit | -| ubuntu18.04_gpu.def | Ubuntu 18.04LTS with -"- plus Nvidia CUDA 11.0 | -| ubuntu18.04_nvidia.def | Ubuntu 18.04LTS with Nvidia CUDA 11.0 toolkit | -| ubuntu18.04_intel_opencl.def | Ubuntu 18.04LTS with Intel OpenCL runtime | -| ubuntu20.04.def | Ubuntu 20.04LTS with MPI == OpenMPI | -| ubuntu20.04_amd_rocm.def | Ubuntu 20.04LTS with AMD ROCm toolkit | -| ubuntu20.04_gpu.def | Ubuntu 20.04LTS with -"- plus Nvidia CUDA 11.0 | -| ubuntu20.04_nvidia.def | Ubuntu 20.04LTS with Nvidia CUDA 11.0 toolkit | -| ubuntu20.04_intel_opencl.def | Ubuntu 20.04LTS with Intel OpenCL runtime | -| ------------------------------ | ---------------------------------------------- | diff --git a/unittest/python/python-capabilities.py b/unittest/python/python-capabilities.py index 8f72c39670..4c14cac37d 100644 --- a/unittest/python/python-capabilities.py +++ b/unittest/python/python-capabilities.py @@ -166,9 +166,9 @@ class PythonCapabilities(unittest.TestCase): self.assertIn('single',settings['GPU']['precision']) if self.cmake_cache['PKG_KOKKOS']: - if self.cmake_cache['Kokkos_ENABLE_OPENMP']: + if 'Kokkos_ENABLE_OPENMP' in self.cmake_cache and self.cmake_cache['Kokkos_ENABLE_OPENMP']: self.assertIn('openmp',settings['KOKKOS']['api']) - if self.cmake_cache['Kokkos_ENABLE_SERIAL']: + if 'Kokkos_ENABLE_SERIAL' in self.cmake_cache and self.cmake_cache['Kokkos_ENABLE_SERIAL']: self.assertIn('serial',settings['KOKKOS']['api']) self.assertIn('double',settings['KOKKOS']['precision'])