Merge branch 'develop' into Elastic_stress

This commit is contained in:
Axel Kohlmeyer
2022-04-23 04:35:23 -04:00
138 changed files with 2294 additions and 2361 deletions

View File

@ -105,8 +105,28 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
endif() endif()
endif() endif()
# silence excessive warnings for new Intel Compilers
if(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
set(CMAKE_TUNE_DEFAULT "-Wno-tautological-constant-compare")
endif()
# silence excessive warnings for PGI/NVHPC compilers
if((CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC") OR (CMAKE_CXX_COMPILER_ID STREQUAL "PGI"))
set(CMAKE_TUNE_DEFAULT "-Minform=severe")
endif()
# silence nvcc warnings
if((PKG_KOKKOS) AND (Kokkos_ENABLE_CUDA))
set(CMAKE_TUNE_DEFAULT "${CMAKE_TUNE_DEFAULT} -Xcudafe --diag_suppress=unrecognized_pragma")
endif()
# we require C++11 without extensions. Kokkos requires at least C++14 (currently) # we require C++11 without extensions. Kokkos requires at least C++14 (currently)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
endif()
if(CMAKE_CXX_STANDARD LESS 11)
message(FATAL_ERROR "C++ standard must be set to at least 11")
endif()
if(PKG_KOKKOS AND (CMAKE_CXX_STANDARD LESS 14)) if(PKG_KOKKOS AND (CMAKE_CXX_STANDARD LESS 14))
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
endif() endif()
@ -468,6 +488,7 @@ set(CMAKE_TUNE_FLAGS "${CMAKE_TUNE_DEFAULT}" CACHE STRING "Compiler and machine
separate_arguments(CMAKE_TUNE_FLAGS) separate_arguments(CMAKE_TUNE_FLAGS)
foreach(_FLAG ${CMAKE_TUNE_FLAGS}) foreach(_FLAG ${CMAKE_TUNE_FLAGS})
target_compile_options(lammps PRIVATE ${_FLAG}) target_compile_options(lammps PRIVATE ${_FLAG})
target_compile_options(lmp PRIVATE ${_FLAG})
endforeach() endforeach()
######################################################################## ########################################################################
# Basic system tests (standard libraries, headers, functions, types) # # Basic system tests (standard libraries, headers, functions, types) #

View File

@ -7,13 +7,13 @@ if(BUILD_DOC)
# Sphinx 3.x requires at least Python 3.5 # Sphinx 3.x requires at least Python 3.5
if(CMAKE_VERSION VERSION_LESS 3.12) if(CMAKE_VERSION VERSION_LESS 3.12)
find_package(PythonInterp 3.5 REQUIRED) find_package(PythonInterp 3.5 REQUIRED)
set(VIRTUALENV ${PYTHON_EXECUTABLE} -m virtualenv -p ${PYTHON_EXECUTABLE}) set(VIRTUALENV ${PYTHON_EXECUTABLE} -m venv)
else() else()
find_package(Python3 REQUIRED COMPONENTS Interpreter) find_package(Python3 REQUIRED COMPONENTS Interpreter)
if(Python3_VERSION VERSION_LESS 3.5) if(Python3_VERSION VERSION_LESS 3.5)
message(FATAL_ERROR "Python 3.5 and up is required to build the HTML documentation") message(FATAL_ERROR "Python 3.5 and up is required to build the HTML documentation")
endif() endif()
set(VIRTUALENV ${Python3_EXECUTABLE} -m virtualenv -p ${Python3_EXECUTABLE}) set(VIRTUALENV ${Python3_EXECUTABLE} -m venv)
endif() endif()
find_package(Doxygen 1.8.10 REQUIRED) find_package(Doxygen 1.8.10 REQUIRED)

View File

@ -19,6 +19,10 @@ endif()
add_library(colvars STATIC ${COLVARS_SOURCES}) add_library(colvars STATIC ${COLVARS_SOURCES})
target_compile_definitions(colvars PRIVATE -DCOLVARS_LAMMPS) target_compile_definitions(colvars PRIVATE -DCOLVARS_LAMMPS)
separate_arguments(CMAKE_TUNE_FLAGS)
foreach(_FLAG ${CMAKE_TUNE_FLAGS})
target_compile_options(colvars PRIVATE ${_FLAG})
endforeach()
set_target_properties(colvars PROPERTIES OUTPUT_NAME lammps_colvars${LAMMPS_MACHINE}) set_target_properties(colvars PROPERTIES OUTPUT_NAME lammps_colvars${LAMMPS_MACHINE})
target_include_directories(colvars PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/colvars) target_include_directories(colvars PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/colvars)
# The line below is needed to locate math_eigen_impl.h # The line below is needed to locate math_eigen_impl.h

View File

@ -36,3 +36,5 @@ endif()
if((CMAKE_CXX_COMPILER_ID STREQUAL "PGI") OR (CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC")) if((CMAKE_CXX_COMPILER_ID STREQUAL "PGI") OR (CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC"))
target_compile_definitions(lammps PRIVATE -DEIGEN_DONT_VECTORIZE) target_compile_definitions(lammps PRIVATE -DEIGEN_DONT_VECTORIZE)
endif() endif()
target_compile_definitions(lammps PRIVATE -DEIGEN_NO_CUDA)

View File

@ -5,7 +5,5 @@ set(PKG_KOKKOS ON CACHE BOOL "" FORCE)
set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "" FORCE) set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "" FORCE)
set(Kokkos_ENABLE_OPENMP ON CACHE BOOL "" FORCE) set(Kokkos_ENABLE_OPENMP ON CACHE BOOL "" FORCE)
set(Kokkos_ENABLE_CUDA ON CACHE BOOL "" FORCE) set(Kokkos_ENABLE_CUDA ON CACHE BOOL "" FORCE)
set(Kokkos_ARCH_MAXWELL50 on CACHE BOOL "" FORCE) set(Kokkos_ARCH_PASCAL60 ON CACHE BOOL "" FORCE)
set(BUILD_OMP ON CACHE BOOL "" FORCE) set(BUILD_OMP ON CACHE BOOL "" FORCE)
get_filename_component(NVCC_WRAPPER_CMD ${CMAKE_CURRENT_SOURCE_DIR}/../lib/kokkos/bin/nvcc_wrapper ABSOLUTE)
set(CMAKE_CXX_COMPILER ${NVCC_WRAPPER_CMD} CACHE FILEPATH "" FORCE)

View File

@ -1,4 +1,4 @@
# preset that will enable clang/clang++ with support for MPI and OpenMP (on Linux boxes) # preset that will enable PGI (Nvidia) compilers with support for MPI and OpenMP (on Linux boxes)
set(CMAKE_CXX_COMPILER "pgc++" CACHE STRING "" FORCE) set(CMAKE_CXX_COMPILER "pgc++" CACHE STRING "" FORCE)
set(CMAKE_C_COMPILER "pgcc" CACHE STRING "" FORCE) set(CMAKE_C_COMPILER "pgcc" CACHE STRING "" FORCE)

View File

@ -14,23 +14,22 @@ ANCHORCHECK = $(VENV)/bin/rst_anchor_check
SPHINXCONFIG = $(BUILDDIR)/utils/sphinx-config SPHINXCONFIG = $(BUILDDIR)/utils/sphinx-config
MATHJAX = $(SPHINXCONFIG)/_static/mathjax MATHJAX = $(SPHINXCONFIG)/_static/mathjax
PYTHON = $(shell which python3) PYTHON = $(word 3,$(shell type python3))
DOXYGEN = $(shell which doxygen) DOXYGEN = $(word 3,$(shell type doxygen))
VIRTUALENV = virtualenv
HAS_PYTHON3 = NO HAS_PYTHON3 = NO
HAS_DOXYGEN = NO HAS_DOXYGEN = NO
HAS_PDFLATEX = NO HAS_PDFLATEX = NO
ifeq ($(shell which python3 >/dev/null 2>&1; echo $$?), 0) ifeq ($(shell type python3 >/dev/null 2>&1; echo $$?), 0)
HAS_PYTHON3 = YES HAS_PYTHON3 = YES
endif endif
ifeq ($(shell which doxygen >/dev/null 2>&1; echo $$?), 0) ifeq ($(shell type doxygen >/dev/null 2>&1; echo $$?), 0)
HAS_DOXYGEN = YES HAS_DOXYGEN = YES
endif endif
ifeq ($(shell which pdflatex >/dev/null 2>&1; echo $$?), 0) ifeq ($(shell type pdflatex >/dev/null 2>&1; echo $$?), 0)
ifeq ($(shell which latexmk >/dev/null 2>&1; echo $$?), 0) ifeq ($(shell type latexmk >/dev/null 2>&1; echo $$?), 0)
HAS_PDFLATEX = YES HAS_PDFLATEX = YES
endif endif
endif endif

View File

@ -211,6 +211,9 @@ Convenience functions
.. doxygenfunction:: logmesg(LAMMPS *lmp, const std::string &mesg) .. doxygenfunction:: logmesg(LAMMPS *lmp, const std::string &mesg)
:project: progguide :project: progguide
.. doxygenfunction:: errorurl
:project: progguide
.. doxygenfunction:: flush_buffers(LAMMPS *lmp) .. doxygenfunction:: flush_buffers(LAMMPS *lmp)
:project: progguide :project: progguide

View File

@ -11,6 +11,7 @@ them.
:maxdepth: 1 :maxdepth: 1
Errors_common Errors_common
Errors_details
Errors_bugs Errors_bugs
Errors_debug Errors_debug
Errors_messages Errors_messages

View File

@ -0,0 +1,27 @@
Detailed discussion of errors and warnings
==========================================
Many errors or warnings are self-explanatory and thus straightforward to
resolve. However, there are also cases, where there is no single cause
and explanation, where LAMMPS can only detect symptoms of an error but
not the exact cause, or where the explanation needs to be more detailed than
what can be fit into a message printed by the program. The following are
discussions of such cases.
.. _err0001:
Unknown identifier in data file
-------------------------------
This error happens when LAMMPS encounters a line of text in an unexpected format
while reading a data file. This is most commonly cause by inconsistent header and
section data. The header section informs LAMMPS how many entries or lines are expected in the
various sections (like Atoms, Masses, Pair Coeffs, *etc.*\ ) of the data file.
If there is a mismatch, LAMMPS will either keep reading beyond the end of a section
or stop reading before the section has ended.
Such a mismatch can happen unexpectedly when the first line of the data
is *not* a comment as required by the format. That would result in
LAMMPS expecting, for instance, 0 atoms because the "atoms" header line
is treated as a comment.

View File

@ -9,34 +9,34 @@ A new atom style can be created if one of the existing atom styles
does not define all the attributes you need to store and communicate does not define all the attributes you need to store and communicate
with atoms. with atoms.
Atom_vec_atomic.cpp is the simplest example of an atom style. The file ``atom_vec_atomic.cpp`` is the simplest example of an atom style.
Examining the code for others will make these instructions more clear. Examining the code for others will make these instructions more clear.
Note that the :doc:`atom style hybrid <atom_style>` command can be Note that the :doc:`atom style hybrid <atom_style>` command can be used
used to define atoms or particles which have the union of properties to define atoms or particles which have the union of properties of
of individual styles. Also the :doc:`fix property/atom <fix_property_atom>` individual styles. Also the :doc:`fix property/atom
command can be used to add a single property (e.g. charge <fix_property_atom>` command can be used to add a single property
or a molecule ID) to a style that does not have it. It can also be (e.g. charge or a molecule ID) to a style that does not have it. It can
used to add custom properties to an atom, with options to communicate also be used to add custom properties to an atom, with options to
them with ghost atoms or read them from a data file. Other LAMMPS communicate them with ghost atoms or read them from a data file. Other
commands can access these custom properties, as can new pair, fix, LAMMPS commands can access these custom properties, as can new pair,
compute styles that are written to work with these properties. For fix, compute styles that are written to work with these properties. For
example, the :doc:`set <set>` command can be used to set the values of example, the :doc:`set <set>` command can be used to set the values of
custom per-atom properties from an input script. All of these methods custom per-atom properties from an input script. All of these methods
are less work than writing code for a new atom style. are less work than writing and testing(!) code for a new atom style.
If you follow these directions your new style will automatically work If you follow these directions your new style will automatically work
in tandem with others via the :doc:`atom_style hybrid <atom_style>` in tandem with others via the :doc:`atom_style hybrid <atom_style>`
command. command.
The first step is to define a set of strings in the constructor of the The first step is to define a set of string lists in the constructor of
new derived class. Each string will have zero or more space-separated the new derived class. Each list will have zero or more comma-separated
variable names which are identical to those used in the atom.h header strings that correspond to the variable names used in the ``atom.h``
file for per-atom properties. Note that some represent per-atom header file for per-atom properties. Note that some represent per-atom
vectors (q, molecule) while other are per-atom arrays (x,v). For all vectors (q, molecule) while other are per-atom arrays (x,v). For all
but the last 2 strings you do not need to specify any of but the last two lists you do not need to specify any of
(id,type,x,v,f). Those are included automatically as needed in the (id,type,x,v,f). Those are included automatically as needed in the
other strings. other lists.
.. list-table:: .. list-table::
@ -65,16 +65,16 @@ other strings.
* - fields_data_vel * - fields_data_vel
- list of properties (in order) in the Velocities section of a data file, as read by :doc:`read_data <read_data>` - list of properties (in order) in the Velocities section of a data file, as read by :doc:`read_data <read_data>`
In these strings you can list variable names which LAMMPS already In these lists you can list variable names which LAMMPS already defines
defines (in some other atom style), or you can create new variable (in some other atom style), or you can create new variable names. You
names. You should not re-use a LAMMPS variable for something with should not re-use a LAMMPS variable in your atom style that is used for
different meaning in your atom style. If the meaning is related, but something with a different meaning in another atom style. If the
interpreted differently by your atom style, then using the same meaning is related, but interpreted differently by your atom style, then
variable name means a user should not use your style and the other using the same variable name means a user must not use your style and
style together in a :doc:`atom_style hybrid <atom_style>` command. the other style together in a :doc:`atom_style hybrid <atom_style>`
Because there will only be one value of the variable and different command. Because there will only be one value of the variable and
parts of LAMMPS will then likely use it differently. LAMMPS has different parts of LAMMPS will then likely use it differently. LAMMPS
no way of checking for this. has no way of checking for this.
If you are defining new variable names then make them descriptive and If you are defining new variable names then make them descriptive and
unique to your new atom style. For example choosing "e" for energy is unique to your new atom style. For example choosing "e" for energy is
@ -85,32 +85,31 @@ If any of the variable names in your new atom style do not exist in
LAMMPS, you need to add them to the src/atom.h and atom.cpp files. LAMMPS, you need to add them to the src/atom.h and atom.cpp files.
Search for the word "customize" or "customization" in these 2 files to Search for the word "customize" or "customization" in these 2 files to
see where to add your variable. Adding a flag to the 2nd see where to add your variable. Adding a flag to the 2nd customization
customization section in atom.h is only necessary if your code (e.g. a section in ``atom.h`` is only necessary if your code (e.g. a pair style)
pair style) needs to check that a per-atom property is defined. These needs to check that a per-atom property is defined. These flags should
flags should also be set in the constructor of the atom style child also be set in the constructor of the atom style child class.
class.
In atom.cpp, aside from the constructor and destructor, there are 3 In ``atom.cpp``, aside from the constructor and destructor, there are 3
methods that a new variable name or flag needs to be added to. methods that a new variable name or flag needs to be added to.
In Atom::peratom_create() when using the add_peratom() method, a In ``Atom::peratom_create()`` when using the ``Atom::add_peratom()``
final length argument of 0 is for per-atom vectors, a length > 1 is method, a cols argument of 0 is for per-atom vectors, a length >
for per-atom arrays. Note the use of an extra per-thread flag and the 1 is for per-atom arrays. Note the use of the extra per-thread flag and
add_peratom_vary() method when last dimension of the array is the add_peratom_vary() method when last dimension of the array is
variable-length. variable-length.
Adding the variable name to Atom::extract() enable the per-atom data Adding the variable name to Atom::extract() enables the per-atom data
to be accessed through the :doc:`LAMMPS library interface to be accessed through the :doc:`LAMMPS library interface
<Howto_library>` by a calling code, including from :doc:`Python <Howto_library>` by a calling code, including from :doc:`Python
<Python_head>`. <Python_head>`.
The constructor of the new atom style will also typically set a few The constructor of the new atom style will also typically set a few
flags which are defined at the top of atom_vec.h. If these are flags which are defined at the top of ``atom_vec.h``. If these are
unclear, see how other atom styles use them. unclear, see how other atom styles use them.
The grow_pointers() method is also required to make The grow_pointers() method is also required to make a copy of peratom
a copy of peratom data pointers, as explained in the code. data pointers, as explained in the code.
There are a number of other optional methods which your atom style can There are a number of other optional methods which your atom style can
implement. These are only needed if you need to do something implement. These are only needed if you need to do something

View File

@ -127,19 +127,16 @@ The *vx*, *vy*, *vz*, *fx*, *fy*, *fz* attributes are components of
the COM velocity and force on the COM of the body. the COM velocity and force on the COM of the body.
The *omegax*, *omegay*, and *omegaz* attributes are the angular The *omegax*, *omegay*, and *omegaz* attributes are the angular
velocity components of the body around its COM. velocity components of the body in the system frame around its COM.
The *angmomx*, *angmomy*, and *angmomz* attributes are the angular The *angmomx*, *angmomy*, and *angmomz* attributes are the angular
momentum components of the body around its COM. momentum components of the body in the system frame around its COM.
The *quatw*, *quati*, *quatj*, and *quatk* attributes are the The *quatw*, *quati*, *quatj*, and *quatk* attributes are the
components of the 4-vector quaternion representing the orientation of components of the 4-vector quaternion representing the orientation of
the rigid body. See the :doc:`set <set>` command for an explanation of the rigid body. See the :doc:`set <set>` command for an explanation of
the quaternion vector. the quaternion vector.
The *angmomx*, *angmomy*, and *angmomz* attributes are the angular
momentum components of the body around its COM.
The *tqx*, *tqy*, *tqz* attributes are components of the torque acting The *tqx*, *tqy*, *tqz* attributes are components of the torque acting
on the body around its COM. on the body around its COM.

View File

@ -76,21 +76,28 @@ velocity for each atom. Note that if there is only one atom in the
bin, its thermal velocity will thus be 0.0. bin, its thermal velocity will thus be 0.0.
After the spatially-averaged velocity field has been subtracted from After the spatially-averaged velocity field has been subtracted from
each atom, the temperature is calculated by the formula KE = (dim\*N each atom, the temperature is calculated by the formula
- dim\*Nx\*Ny\*Nz) k T/2, where KE = total kinetic energy of the group of *KE* = (*dim\*N* - *Ns\*Nx\*Ny\*Nz* - *extra* ) *k* *T*/2, where *KE* = total
atoms (sum of 1/2 m v\^2), dim = 2 or 3 = dimensionality of the kinetic energy of the group of atoms (sum of 1/2 *m* *v*\^2), *dim* = 2
simulation, N = number of atoms in the group, k = Boltzmann constant, or 3 = dimensionality of the simulation, *Ns* = 0, 1, 2 or 3 for
and T = temperature. The dim\*Nx\*Ny\*Nz term are degrees of freedom streaming velocity subtracted in 0, 1, 2 or 3 dimensions, *extra* = extra
subtracted to adjust for the removal of the center-of-mass velocity in degrees-of-freedom, *N* = number of atoms in the group, *k* = Boltzmann
each of Nx\*Ny\*Nz bins, as discussed in the :ref:`(Evans) <Evans1>` paper. constant, and *T* = temperature. The *Ns\*Nx\*Ny\*Nz* term is degrees
of freedom subtracted to adjust for the removal of the center-of-mass
velocity in each direction of the *Nx\*Ny\*Nz* bins, as discussed in the
:ref:`(Evans) <Evans1>` paper. The extra term defaults to (*dim* - *Ns*)
and accounts for overall conservation of center-of-mass velocity across
the group in directions where streaming velocity is *not* subtracted. This
can be altered using the *extra* option of the
:doc:`compute_modify <compute_modify>` command.
If the *out* keyword is used with a *tensor* value, which is the If the *out* keyword is used with a *tensor* value, which is the
default, a kinetic energy tensor, stored as a 6-element vector, is default, a kinetic energy tensor, stored as a 6-element vector, is
also calculated by this compute for use in the computation of a also calculated by this compute for use in the computation of a
pressure tensor. The formula for the components of the tensor is the pressure tensor. The formula for the components of the tensor is the
same as the above formula, except that v\^2 is replaced by vx\*vy for same as the above formula, except that *v*\^2 is replaced by *vx\*vy* for
the xy component, etc. The 6 components of the vector are ordered xx, the xy component, etc. The 6 components of the vector are ordered *xx,
yy, zz, xy, xz, yz. yy, zz, xy, xz, yz.*
If the *out* keyword is used with a *bin* value, the count of atoms If the *out* keyword is used with a *bin* value, the count of atoms
and computed temperature for each bin are stored for output, as an and computed temperature for each bin are stored for output, as an
@ -123,10 +130,20 @@ needed, the subtracted degrees-of-freedom can be altered using the
.. note:: .. note::
When using the *out* keyword with a value of *bin*, the When using the *out* keyword with a value of *bin*, the
calculated temperature for each bin does not include the calculated temperature for each bin includes the degrees-of-freedom
degrees-of-freedom adjustment described in the preceding paragraph, adjustment described in the preceding paragraph for fixes that
for fixes that constrain molecular motion. It does include the constrain molecular motion, as well as the adjustment due to
adjustment due to the *extra* option, which is applied to each bin. the *extra* option (which defaults to *dim* - *Ns* as described above),
by fractionally applying them based on the fraction of atoms in each
bin. As a result, the bin degrees-of-freedom summed over all bins exactly
equals the degrees-of-freedom used in the scalar temperature calculation,
:math:`\Sigma N_{DOF_i} = N_{DOF}` and the corresponding relation for temperature
is also satisfied :math:`\Sigma N_{DOF_i} T_i = N_{DOF} T`.
These relations will breakdown in cases where the adjustment
exceeds the actual number of degrees-of-freedom in a bin. This could happen
if a bin is empty or in situations where rigid molecules
are non-uniformly distributed, in which case the reported
temperature within a bin may not be accurate.
See the :doc:`Howto thermostat <Howto_thermostat>` page for a See the :doc:`Howto thermostat <Howto_thermostat>` page for a
discussion of different ways to compute temperature and perform discussion of different ways to compute temperature and perform

View File

@ -14,7 +14,7 @@ Syntax
* adapt = style name of this fix command * adapt = style name of this fix command
* N = adapt simulation settings every this many timesteps * N = adapt simulation settings every this many timesteps
* one or more attribute/arg pairs may be appended * one or more attribute/arg pairs may be appended
* attribute = *pair* or *bond* or *kspace* or *atom* * attribute = *pair* or *bond* or *angle* or *kspace* or *atom*
.. parsed-literal:: .. parsed-literal::
@ -28,11 +28,16 @@ Syntax
bparam = parameter to adapt over time bparam = parameter to adapt over time
I = type bond to set parameter for I = type bond to set parameter for
v_name = variable with name that calculates value of bparam v_name = variable with name that calculates value of bparam
*angle* args = astyle aparam I v_name
astyle = angle style name, e.g. harmonic
aparam = parameter to adapt over time
I = type angle to set parameter for
v_name = variable with name that calculates value of aparam
*kspace* arg = v_name *kspace* arg = v_name
v_name = variable with name that calculates scale factor on K-space terms v_name = variable with name that calculates scale factor on K-space terms
*atom* args = aparam v_name *atom* args = atomparam v_name
aparam = parameter to adapt over time atomparam = parameter to adapt over time
v_name = variable with name that calculates value of aparam v_name = variable with name that calculates value of atomparam
* zero or more keyword/value pairs may be appended * zero or more keyword/value pairs may be appended
* keyword = *scale* or *reset* or *mass* * keyword = *scale* or *reset* or *mass*
@ -283,30 +288,62 @@ operates. The only difference is that now a bond coefficient for a
given bond type is adapted. given bond type is adapted.
A wild-card asterisk can be used in place of or in conjunction with A wild-card asterisk can be used in place of or in conjunction with
the bond type argument to set the coefficients for multiple bond types. the bond type argument to set the coefficients for multiple bond
This takes the form "\*" or "\*n" or "n\*" or "m\*n". If N = the number of types. This takes the form "\*" or "\*n" or "n\*" or "m\*n". If N =
atom types, then an asterisk with no numeric values means all types the number of bond types, then an asterisk with no numeric values
from 1 to N. A leading asterisk means all types from 1 to n (inclusive). means all types from 1 to N. A leading asterisk means all types from
A trailing asterisk means all types from n to N (inclusive). A middle 1 to n (inclusive). A trailing asterisk means all types from n to N
asterisk means all types from m to n (inclusive). (inclusive). A middle asterisk means all types from m to n
(inclusive).
Currently *bond* does not support bond_style hybrid nor bond_style Currently *bond* does not support bond_style hybrid nor bond_style
hybrid/overlay as bond styles. The only bonds that currently are hybrid/overlay as bond styles. The bond styles that currently work
working with fix_adapt are with fix_adapt are
+------------------------------------+-------+------------+ +------------------------------------+-------+-----------------+
| :doc:`class2 <bond_class2>` | r0 | type bonds | | :doc:`class2 <bond_class2>` | r0 | type bonds |
+------------------------------------+-------+------------+ +------------------------------------+-------+-----------------+
| :doc:`fene <bond_fene>` | k,r0 | type bonds | | :doc:`fene <bond_fene>` | k,r0 | type bonds |
+------------------------------------+-------+------------+ +------------------------------------+-------+-----------------+
| :doc:`fene/nm <bond_fene_nm>` | k,r0 | type bonds |
+------------------------------------+-------+-----------------+
| :doc:`gromos <bond_gromos>` | k,r0 | type bonds | | :doc:`gromos <bond_gromos>` | k,r0 | type bonds |
+------------------------------------+-------+------------+ +------------------------------------+-------+-----------------+
| :doc:`harmonic <bond_harmonic>` | k,r0 | type bonds | | :doc:`harmonic <bond_harmonic>` | k,r0 | type bonds |
+------------------------------------+-------+------------+ +------------------------------------+-------+-----------------+
| :doc:`morse <bond_morse>` | r0 | type bonds | | :doc:`morse <bond_morse>` | r0 | type bonds |
+------------------------------------+-------+------------+ +------------------------------------+-------+-----------------+
| :doc:`nonlinear <bond_nonlinear>` | r0 | type bonds | | :doc:`nonlinear <bond_nonlinear>` | epsilon,r0 | type bonds |
+------------------------------------+-------+------------+ +------------------------------------+-------+-----------------+
----------
The *angle* keyword uses the specified variable to change the value of
an angle coefficient over time, very similar to how the *pair* keyword
operates. The only difference is that now an angle coefficient for a
given angle type is adapted.
A wild-card asterisk can be used in place of or in conjunction with
the angle type argument to set the coefficients for multiple angle
types. This takes the form "\*" or "\*n" or "n\*" or "m\*n". If N =
the number of angle types, then an asterisk with no numeric values
means all types from 1 to N. A leading asterisk means all types from
1 to n (inclusive). A trailing asterisk means all types from n to N
(inclusive). A middle asterisk means all types from m to n
(inclusive).
Currently *angle* does not support angle_style hybrid nor angle_style
hybrid/overlay as angle styles. The angle styles that currently work
with fix_adapt are
+------------------------------------+-------+-----------------+
| :doc:`harmonic <angle_harmonic>` | k,theta0 | type angles |
+------------------------------------+-------+-----------------+
| :doc:`cosine <angle_cosine>` | k | type angles |
+------------------------------------+-------+-----------------+
Note that internally, theta0 is stored in radians, so the variable
this fix uses to reset theta0 needs to generate values in radians.
---------- ----------

View File

@ -35,6 +35,10 @@ consistent with the microcanonical ensemble (NVE) provided there
are (full) periodic boundary conditions and no other "manipulations" are (full) periodic boundary conditions and no other "manipulations"
of the system (e.g. fixes that modify forces or velocities). of the system (e.g. fixes that modify forces or velocities).
This fix invokes the velocity form of the
Störmer-Verlet time integration algorithm (velocity-Verlet). Other
time integration options can be invoked using the :doc:`run_style <run_style>` command.
---------- ----------
.. include:: accel_styles.rst .. include:: accel_styles.rst
@ -57,7 +61,7 @@ Restrictions
Related commands Related commands
"""""""""""""""" """"""""""""""""
:doc:`fix nvt <fix_nh>`, :doc:`fix npt <fix_nh>` :doc:`fix nvt <fix_nh>`, :doc:`fix npt <fix_nh>`, :doc:`run_style <run_style>`
Default Default
""""""" """""""

View File

@ -304,13 +304,15 @@ uninterrupted fashion.
.. warning:: .. warning::
When reading data from a restart file, this fix command has to be When reading data from a restart file, this fix command has to be
specified **exactly** the same was in the input script that created specified **after** the *read_restart* command and **exactly** the
the restart file. LAMMPS will only check whether a fix is of the same was in the input script that created the restart file. LAMMPS
same style and has the same fix ID and in case of a match will then will only check whether a fix is of the same style and has the same
try to initialize the fix with the data stored in the binary fix ID and in case of a match will then try to initialize the fix
restart file. If the names and associated date types in the new with the data stored in the binary restart file. If the names and
fix property/atom command do not match the old one exactly, data associated date types in the new fix property/atom command do not
can be corrupted or LAMMPS may crash. match the old one exactly, data can be corrupted or LAMMPS may crash.
If the fix is specified **before** the *read_restart* command its
data will not be restored.
None of the :doc:`fix_modify <fix_modify>` options are relevant to None of the :doc:`fix_modify <fix_modify>` options are relevant to
this fix. No global or per-atom quantities are stored by this fix for this fix. No global or per-atom quantities are stored by this fix for

View File

@ -217,7 +217,7 @@ units used.
.. note:: .. note::
The electronic temperature at each grid point must be a non-zero The electronic temperature at each grid point must be a non-zero
positive value, both initially, and as the temperature evovles over positive value, both initially, and as the temperature evolves over
time. Thus you must use either the *set* or *infile* keyword or be time. Thus you must use either the *set* or *infile* keyword or be
restarting a simulation that used this fix previously. restarting a simulation that used this fix previously.

View File

@ -258,11 +258,17 @@ assignment is made at the beginning of the minimization, but not
during the iterations of the minimizer. during the iterations of the minimizer.
The point in the timestep at which atoms are assigned to a dynamic The point in the timestep at which atoms are assigned to a dynamic
group is after the initial stage of velocity Verlet time integration group is after interatomic forces have been computed, but before any
has been performed, and before neighbor lists or forces are computed. fixes which alter forces or otherwise update the system have been
This is the point in the timestep where atom positions have just invoked. This means that atom positions have been updated, neighbor
changed due to the time integration, so the region criterion should be lists and ghost atoms are current, and both intermolecular and
accurate, if applied. intramolecular forces have been calculated based on the new
coordinates. Thus the region criterion, if applied, should be
accurate. Also, any computes invoked by an atom-style variable should
use updated information for that timestep, e.g. potential energy/atom
or coordination number/atom. Similarly, fixes or computes which are
invoked after that point in the timestep, should operate on the new
group of atoms.
.. note:: .. note::

View File

@ -67,7 +67,8 @@ Description
Choose the style of time integrator used for molecular dynamics Choose the style of time integrator used for molecular dynamics
simulations performed by LAMMPS. simulations performed by LAMMPS.
The *verlet* style is a standard velocity-Verlet integrator. The *verlet* style is the velocity form of the
Störmer-Verlet time integration algorithm (velocity-Verlet)
---------- ----------

View File

@ -252,6 +252,6 @@ flush = no, and temp/press = compute IDs defined by thermo_style.
The defaults for the line and format options depend on the thermo style. The defaults for the line and format options depend on the thermo style.
For styles "one" and "custom", the line and format defaults are "one", For styles "one" and "custom", the line and format defaults are "one",
"%10d", and "%12.8g". For style "multi", the line and format defaults "%10d", and "%14.8g". For style "multi", the line and format defaults
are "multi", "%14d", and "%14.4f". For style "yaml", the line and format are "multi", "%14d", and "%14.4f". For style "yaml", the line and format
defaults are "%d" and "%.15g". defaults are "%d" and "%.15g".

View File

@ -10,7 +10,7 @@ Syntax
thermo_style style args thermo_style style args
* style = *one* or *multi* *yaml* or *custom* * style = *one* or *multi* or *yaml* or *custom*
* args = list of arguments for a particular style * args = list of arguments for a particular style
.. parsed-literal:: .. parsed-literal::

View File

@ -6,3 +6,4 @@ breathe
Pygments Pygments
six six
pyyaml pyyaml
wheel

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -20,8 +19,6 @@
#include "atom.h" #include "atom.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -32,12 +29,9 @@ AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp)
molecular = Atom::ATOMIC; molecular = Atom::ATOMIC;
forceclearflag = 1; forceclearflag = 1;
atom->wavepacket_flag = 1;
atom->electron_flag = 1; // compatible with eff atom->electron_flag = 1; // compatible with eff
atom->q_flag = atom->spin_flag = atom->eradius_flag = atom->wavepacket_flag = atom->q_flag = atom->spin_flag = atom->eradius_flag = 1;
atom->ervel_flag = atom->erforce_flag = 1; atom->ervel_flag = atom->erforce_flag = atom->cs_flag = atom->csforce_flag = 1;
atom->cs_flag = atom->csforce_flag =
atom->vforce_flag = atom->ervelforce_flag = atom->etag_flag = 1; atom->vforce_flag = atom->ervelforce_flag = atom->etag_flag = 1;
// strings with peratom variables to include in each AtomVec method // strings with peratom variables to include in each AtomVec method
@ -45,20 +39,19 @@ AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) fields_grow = {"q", "spin", "eradius", "ervel", "erforce",
"q spin eradius ervel erforce cs csforce " "cs", "csforce", "vforce", "ervelforce", "etag"};
"vforce ervelforce etag"; fields_copy = {"q", "spin", "eradius", "ervel", "cs", "etag"};
fields_copy = (char *) "q spin eradius ervel cs etag"; fields_comm = {"eradius"};
fields_comm = (char *) "eradius"; fields_comm_vel = {"eradius", "ervel", "cs"};
fields_comm_vel = (char *) "eradius ervel cs"; fields_reverse = {"erforce", "ervelforce", "vforce", "csforce"};
fields_reverse = (char *) "erforce ervelforce vforce csforce"; fields_border = {"q", "spin", "eradius", "etag"};
fields_border = (char *) "q spin eradius etag"; fields_border_vel = {"q", "spin", "eradius", "etag", "ervel", "cs"};
fields_border_vel = (char *) "q spin eradius etag ervel cs"; fields_exchange = {"q", "spin", "eradius", "ervel", "etag", "cs"};
fields_exchange = (char *) "q spin eradius ervel etag cs"; fields_restart = {"q", "spin", "eradius", "ervel", "etag", "cs"};
fields_restart = (char *) "q spin eradius ervel etag cs"; fields_create = {"q", "spin", "eradius", "ervel", "etag", "cs"};
fields_create = (char *) "q spin eradius ervel etag cs"; fields_data_atom = {"id", "type", "q", "spin", "eradius", "etag", "cs", "x"};
fields_data_atom = (char *) "id type q spin eradius etag cs x"; fields_data_vel = {"id", "v", "ervel"};
fields_data_vel = (char *) "id v ervel";
setup_fields(); setup_fields();
} }
@ -112,12 +105,12 @@ void AtomVecWavepacket::data_atom_post(int ilocal)
return -1 if name is unknown to this atom style return -1 if name is unknown to this atom style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int AtomVecWavepacket::property_atom(char *name) int AtomVecWavepacket::property_atom(const std::string &name)
{ {
if (strcmp(name,"spin") == 0) return 0; if (name == "spin") return 0;
if (strcmp(name,"eradius") == 0) return 1; if (name == "eradius") return 1;
if (strcmp(name,"ervel") == 0) return 2; if (name == "ervel") return 2;
if (strcmp(name,"erforce") == 0) return 3; if (name == "erforce") return 3;
return -1; return -1;
} }
@ -126,34 +119,41 @@ int AtomVecWavepacket::property_atom(char *name)
index maps to data specific to this atom style index maps to data specific to this atom style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecWavepacket::pack_property_atom(int index, double *buf, void AtomVecWavepacket::pack_property_atom(int index, double *buf, int nvalues, int groupbit)
int nvalues, int groupbit)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
int n = 0; int n = 0;
if (index == 0) { if (index == 0) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = spin[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = spin[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 1) { } else if (index == 1) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = eradius[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = eradius[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 2) { } else if (index == 2) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = ervel[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = ervel[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 3) { } else if (index == 3) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = erforce[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = erforce[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} }

View File

@ -32,7 +32,7 @@ class AtomVecWavepacket : public AtomVec {
void force_clear(int, size_t) override; void force_clear(int, size_t) override;
void create_atom_post(int) override; void create_atom_post(int) override;
void data_atom_post(int) override; void data_atom_post(int) override;
int property_atom(char *) override; int property_atom(const std::string &) override;
void pack_property_atom(int, double *, int, int) override; void pack_property_atom(int, double *, int, int) override;
private: private:

View File

@ -14,6 +14,7 @@
#include "atom_vec_bpm_sphere.h" #include "atom_vec_bpm_sphere.h"
#include "atom.h" #include "atom.h"
#include "comm.h"
#include "error.h" #include "error.h"
#include "fix.h" #include "fix.h"
#include "fix_adapt.h" #include "fix_adapt.h"
@ -43,23 +44,21 @@ AtomVecBPMSphere::AtomVecBPMSphere(LAMMPS *_lmp) : AtomVec(_lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
// clang-format off fields_grow = {"molecule", "num_bond", "bond_type", "bond_atom", "nspecial", "special",
fields_grow = (char *) "molecule num_bond bond_type bond_atom nspecial special radius rmass " "radius", "rmass", "omega", "torque", "quat"};
"omega torque quat"; fields_copy = {"molecule", "num_bond", "bond_type", "bond_atom", "nspecial",
fields_copy = (char *) "molecule num_bond bond_type bond_atom nspecial special radius rmass " "special", "radius", "rmass", "omega", "quat"};
"omega quat"; fields_comm_vel = {"omega", "quat"};
fields_comm = (char *) ""; fields_reverse = {"torque"};
fields_comm_vel = (char *) "omega quat"; fields_border = {"molecule", "radius", "rmass"};
fields_reverse = (char *) "torque"; fields_border_vel = {"molecule", "radius", "rmass", "omega", "quat"};
fields_border = (char *) "molecule radius rmass"; fields_exchange = {"molecule", "num_bond", "bond_type", "bond_atom", "nspecial",
fields_border_vel = (char *) "molecule radius rmass omega quat"; "special", "radius", "rmass", "omega", "quat"};
fields_exchange = (char *) "molecule num_bond bond_type bond_atom nspecial special radius rmass " fields_restart = {"molecule", "num_bond", "bond_type", "bond_atom",
"omega quat"; "radius", "rmass", "omega", "quat"};
fields_restart = (char *) "molecule num_bond bond_type bond_atom radius rmass omega quat"; fields_create = {"molecule", "num_bond", "nspecial", "radius", "rmass", "omega", "quat"};
fields_create = (char *) "molecule num_bond nspecial radius rmass omega quat"; fields_data_atom = {"id", "molecule", "type", "radius", "rmass", "x"};
fields_data_atom = (char *) "id molecule type radius rmass x"; fields_data_vel = {"id", "v", "omega"};
fields_data_vel = (char *) "id v omega";
// clang-format on
bond_per_atom = 0; bond_per_atom = 0;
bond_negative = NULL; bond_negative = NULL;
@ -83,8 +82,8 @@ void AtomVecBPMSphere::process_args(int narg, char **arg)
// dynamic particle radius and mass must be communicated every step // dynamic particle radius and mass must be communicated every step
if (radvary) { if (radvary) {
fields_comm = (char *) "radius rmass"; fields_comm = {"radius", "rmass"};
fields_comm_vel = (char *) "radius rmass omega"; fields_comm_vel = {"radius", "rmass", "omega"};
} }
// delay setting up of fields until now // delay setting up of fields until now
@ -100,11 +99,15 @@ void AtomVecBPMSphere::init()
// check if optional radvary setting should have been set to 1 // check if optional radvary setting should have been set to 1
for (int i = 0; i < modify->nfix; i++) for (auto ifix : modify->get_fix_by_style("^adapt")) {
if (strcmp(modify->fix[i]->style, "adapt") == 0) { if (radvary == 0) {
FixAdapt *fix = (FixAdapt *) modify->fix[i]; if ((strcmp(ifix->style, "adapt") == 0) && (dynamic_cast<FixAdapt *>(ifix)->diamflag))
if (fix->diamflag && radvary == 0)
error->all(FLERR, "Fix adapt changes atom radii but atom_style bpm/sphere is not dynamic"); error->all(FLERR, "Fix adapt changes atom radii but atom_style bpm/sphere is not dynamic");
// cannot properly check for fix adapt/fep since its header is optional
if ((strcmp(ifix->style, "adapt/fep") == 0) && (comm->me == 0))
error->warning(
FLERR, "Fix adapt/fep may change atom radii but atom_style bpm/sphere is not dynamic");
}
} }
} }

View File

@ -45,7 +45,7 @@ class AtomVecBPMSphere : public AtomVec {
int **nspecial; int **nspecial;
double *radius, *rmass; double *radius, *rmass;
double **omega, **torque, **quat; double **omega, **quat;
int any_bond_negative; int any_bond_negative;
int bond_per_atom; int bond_per_atom;

View File

@ -253,13 +253,13 @@ void PairBPMSpring::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j], sizeof(int), 1, fp); if (me == 0) utils::sfread(FLERR, &setflag[i][j], sizeof(int), 1, fp, nullptr, error);
MPI_Bcast(&setflag[i][j], 1, MPI_INT, 0, world); MPI_Bcast(&setflag[i][j], 1, MPI_INT, 0, world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&k[i][j], sizeof(double), 1, fp); utils::sfread(FLERR, &k[i][j], sizeof(double), 1, fp, nullptr, error);
fread(&cut[i][j], sizeof(double), 1, fp); utils::sfread(FLERR, &cut[i][j], sizeof(double), 1, fp, nullptr, error);
fread(&gamma[i][j], sizeof(double), 1, fp); utils::sfread(FLERR, &gamma[i][j], sizeof(double), 1, fp, nullptr, error);
} }
MPI_Bcast(&k[i][j], 1, MPI_DOUBLE, 0, world); MPI_Bcast(&k[i][j], 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&cut[i][j], 1, MPI_DOUBLE, 0, world); MPI_Bcast(&cut[i][j], 1, MPI_DOUBLE, 0, world);

View File

@ -33,18 +33,13 @@ AtomVecOxdna::AtomVecOxdna(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "id5p"; fields_grow = {"id5p"};
fields_copy = (char *) "id5p"; fields_copy = {"id5p"};
fields_comm = (char *) ""; fields_border = {"id5p"};
fields_comm_vel = (char *) ""; fields_exchange = {"id5p"};
fields_reverse = (char *) ""; fields_restart = {"id5p"};
fields_border = (char *) "id5p"; fields_data_atom = {"id", "type", "x"};
fields_border_vel = (char *) ""; fields_data_vel = {"id", "v"};
fields_exchange = (char *) "id5p";
fields_restart = (char *) "id5p";
fields_create = (char *) "";
fields_data_atom = (char *) "id type x";
fields_data_vel = (char *) "id v";
setup_fields(); setup_fields();

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/ Sandia National Laboratories https://www.lammps.org/ Sandia National Laboratories
@ -18,7 +17,6 @@
#include "citeme.h" #include "citeme.h"
#include <cmath> #include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -33,8 +31,7 @@ static const char cite_user_dielectric_package[] =
" year = 2019,\n" " year = 2019,\n"
" volume = 241,\n" " volume = 241,\n"
" pages = {80--91}\n" " pages = {80--91}\n"
"}\n\n" "}\n\n";
;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -54,55 +51,39 @@ AtomVecDielectric::AtomVecDielectric(LAMMPS *_lmp) : AtomVec(_lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) // clang-format off
"q molecule num_bond bond_type bond_atom " fields_grow = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
"dihedral_atom3 dihedral_atom4 " "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special",
"num_improper improper_type improper_atom1 improper_atom2 " "mu", "area", "ed", "em", "epsilon", "curvature", "q_unscaled"};
"improper_atom3 improper_atom4 " fields_copy = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
"nspecial special " "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
"mu area ed em epsilon curvature q_unscaled"; "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
fields_copy = (char *) "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special",
"q molecule num_bond bond_type bond_atom " "mu", "area", "ed", "em", "epsilon", "curvature", "q_unscaled"};
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " fields_comm = {"q", "mu", "area", "ed", "em", "epsilon", "curvature", "q_unscaled"};
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " fields_border = {"q", "molecule", "mu", "area", "ed", "em", "epsilon", "curvature", "q_unscaled"};
"dihedral_atom3 dihedral_atom4 " fields_border_vel = {"q", "molecule", "mu", "area", "ed", "em", "epsilon", "curvature",
"num_improper improper_type improper_atom1 improper_atom2 " "q_unscaled"};
"improper_atom3 improper_atom4 " fields_exchange = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle",
"nspecial special " "angle_type", "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type",
"mu area ed em epsilon curvature q_unscaled"; "dihedral_atom1", "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper",
fields_comm = (char *) "q mu area ed em epsilon curvature q_unscaled"; "improper_type", "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4",
fields_comm_vel = (char *) ""; "nspecial", "special", "mu", "area", "ed", "em", "epsilon", "curvature", "q_unscaled"};
fields_reverse = (char *) ""; fields_restart = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle",
fields_border = (char *) "q molecule mu area ed em epsilon curvature q_unscaled"; "angle_type", "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type",
fields_border_vel = (char *) "q molecule mu area ed em epsilon curvature q_unscaled"; "dihedral_atom1", "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper",
fields_exchange = (char *) "improper_type", "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4",
"q molecule num_bond bond_type bond_atom " "mu", "area", "ed", "em", "epsilon", "curvature", "q_unscaled"};
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " fields_create = {"q", "molecule", "num_bond", "num_angle", "num_dihedral", "num_improper",
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " "nspecial", "mu", "area", "ed", "em", "epsilon", "curvature", "q_unscaled"};
"dihedral_atom3 dihedral_atom4 " fields_data_atom = { "id", "molecule", "type", "q", "x", "mu3", "area", "ed", "em", "epsilon",
"num_improper improper_type improper_atom1 improper_atom2 " "curvature"};
"improper_atom3 improper_atom4 " fields_data_vel = {"id v"};
"nspecial special " // clang-format on
"mu area ed em epsilon curvature q_unscaled";
fields_restart = (char *)
"q molecule num_bond bond_type bond_atom "
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
"dihedral_atom3 dihedral_atom4 "
"num_improper improper_type improper_atom1 improper_atom2 "
"improper_atom3 improper_atom4 "
"mu area ed em epsilon curvature q_unscaled";
fields_create = (char *)
"q molecule num_bond num_angle num_dihedral num_improper nspecial "
"mu area ed em epsilon curvature q_unscaled";
fields_data_atom = (char *) "id molecule type q x "
"mu3 area ed em epsilon curvature";
fields_data_vel = (char *) "id v";
setup_fields(); setup_fields();
bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0; bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0;
} }
@ -163,8 +144,7 @@ void AtomVecDielectric::data_atom_post(int ilocal)
q[ilocal] /= epsilon[ilocal]; q[ilocal] /= epsilon[ilocal];
double *mu_one = mu[ilocal]; double *mu_one = mu[ilocal];
mu_one[3] = mu_one[3] = sqrt(mu_one[0] * mu_one[0] + mu_one[1] * mu_one[1] + mu_one[2] * mu_one[2]);
sqrt(mu_one[0]*mu_one[0] + mu_one[1]*mu_one[1] + mu_one[2]*mu_one[2]);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -183,14 +163,14 @@ void AtomVecDielectric::unpack_restart_init(int ilocal)
return -1 if name is unknown to this atom style return -1 if name is unknown to this atom style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int AtomVecDielectric::property_atom(char *name) int AtomVecDielectric::property_atom(const std::string &name)
{ {
if (strcmp(name,"area") == 0) return 0; if (name == "area") return 0;
if (strcmp(name,"ed") == 0) return 1; if (name == "ed") return 1;
if (strcmp(name,"em") == 0) return 2; if (name == "em") return 2;
if (strcmp(name,"epsilon") == 0) return 3; if (name == "epsilon") return 3;
if (strcmp(name,"curvature") == 0) return 4; if (name == "curvature") return 4;
if (strcmp(name,"q_unscaled") == 0) return 5; if (name == "q_unscaled") return 5;
return -1; return -1;
} }
@ -199,8 +179,7 @@ int AtomVecDielectric::property_atom(char *name)
index maps to data specific to this atom style index maps to data specific to this atom style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecDielectric::pack_property_atom(int index, double *buf, void AtomVecDielectric::pack_property_atom(int index, double *buf, int nvalues, int groupbit)
int nvalues, int groupbit)
{ {
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
@ -208,38 +187,50 @@ void AtomVecDielectric::pack_property_atom(int index, double *buf,
if (index == 0) { if (index == 0) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = area[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = area[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 1) { } else if (index == 1) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = ed[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = ed[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 2) { } else if (index == 2) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = em[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = em[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 3) { } else if (index == 3) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = epsilon[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = epsilon[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 4) { } else if (index == 4) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = curvature[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = curvature[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 5) { } else if (index == 5) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = q_unscaled[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = q_unscaled[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} }

View File

@ -35,7 +35,7 @@ class AtomVecDielectric : public AtomVec {
void create_atom_post(int) override; void create_atom_post(int) override;
void data_atom_post(int) override; void data_atom_post(int) override;
void unpack_restart_init(int) override; void unpack_restart_init(int) override;
int property_atom(char *) override; int property_atom(const std::string &) override;
void pack_property_atom(int, double *, int, int) override; void pack_property_atom(int, double *, int, int) override;
protected: protected:

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -34,18 +33,17 @@ AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "q mu"; fields_grow = {"q", "mu"};
fields_copy = (char *) "q mu"; fields_copy = {"q", "mu"};
fields_comm = (char *) "mu3"; fields_comm = {"mu3"};
fields_comm_vel = (char *) "mu3"; fields_comm_vel = {"mu3"};
fields_reverse = (char *) ""; fields_border = {"q", "mu"};
fields_border = (char *) "q mu"; fields_border_vel = {"q", "mu"};
fields_border_vel = (char *) "q mu"; fields_exchange = {"q", "mu"};
fields_exchange = (char *) "q mu"; fields_restart = {"q", "mu"};
fields_restart = (char *) "q mu"; fields_create = {"q", "mu"};
fields_create = (char *) "q mu"; fields_data_atom = {"id", "type", "q", "x", "mu3"};
fields_data_atom = (char *) "id type q x mu3"; fields_data_vel = {"id", "v"};
fields_data_vel = (char *) "id v";
setup_fields(); setup_fields();
} }
@ -68,6 +66,5 @@ void AtomVecDipole::grow_pointers()
void AtomVecDipole::data_atom_post(int ilocal) void AtomVecDipole::data_atom_post(int ilocal)
{ {
double *mu_one = mu[ilocal]; double *mu_one = mu[ilocal];
mu_one[3] = mu_one[3] = sqrt(mu_one[0] * mu_one[0] + mu_one[1] * mu_one[1] + mu_one[2] * mu_one[2]);
sqrt(mu_one[0]*mu_one[0] + mu_one[1]*mu_one[1] + mu_one[2]*mu_one[2]);
} }

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -38,18 +37,18 @@ AtomVecEDPD::AtomVecEDPD(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "edpd_cv edpd_temp edpd_flux vest vest_temp"; fields_grow = {"edpd_cv", "edpd_temp", "edpd_flux", "vest", "vest_temp"};
fields_copy = (char *) "edpd_cv edpd_temp edpd_flux vest vest_temp"; fields_copy = {"edpd_cv", "edpd_temp", "edpd_flux", "vest", "vest_temp"};
fields_comm = (char *) "edpd_temp vest vest_temp"; fields_comm = {"edpd_temp", "vest", "vest_temp"};
fields_comm_vel = (char *) "edpd_temp vest vest_temp"; fields_comm_vel = {"edpd_temp", "vest", "vest_temp"};
fields_reverse = (char *) "edpd_flux"; fields_reverse = {"edpd_flux"};
fields_border = (char *) "edpd_cv edpd_temp vest vest_temp"; fields_border = {"edpd_cv", "edpd_temp", "vest", "vest_temp"};
fields_border_vel = (char *) "edpd_cv edpd_temp vest vest_temp"; fields_border_vel = {"edpd_cv", "edpd_temp", "vest", "vest_temp"};
fields_exchange = (char *) "edpd_cv edpd_temp vest vest_temp"; fields_exchange = {"edpd_cv", "edpd_temp", "vest", "vest_temp"};
fields_restart = (char * ) "edpd_cv edpd_temp vest vest_temp"; fields_restart = {"edpd_cv", "edpd_temp", "vest", "vest_temp"};
fields_create = (char *) "edpd_cv edpd_temp edpd_flux vest vest_temp"; fields_create = {"edpd_cv", "edpd_temp", "edpd_flux", "vest", "vest_temp"};
fields_data_atom = (char *) "id type edpd_temp edpd_cv x"; fields_data_atom = {"id", "type", "edpd_temp", "edpd_cv", "x"};
fields_data_vel = (char *) "id v"; fields_data_vel = {"id", "v"};
setup_fields(); setup_fields();
} }
@ -60,8 +59,7 @@ void AtomVecEDPD::init()
{ {
AtomVec::init(); AtomVec::init();
if (strcmp(update->unit_style,"lj") != 0) if (strcmp(update->unit_style, "lj") != 0) error->all(FLERR, "Atom style edpd requires lj units");
error->all(FLERR,"Atom style edpd requires lj units");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -13,10 +12,12 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "atom_vec_mdpd.h" #include "atom_vec_mdpd.h"
#include <cstring>
#include "atom.h" #include "atom.h"
#include "update.h"
#include "error.h" #include "error.h"
#include "update.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -36,18 +37,18 @@ AtomVecMDPD::AtomVecMDPD(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "rho drho vest"; fields_grow = {"rho", "drho", "vest"};
fields_copy = (char *) "rho drho vest"; fields_copy = {"rho", "drho", "vest"};
fields_comm = (char *) "rho vest"; fields_comm = {"rho", "vest"};
fields_comm_vel = (char *) "rho vest"; fields_comm_vel = {"rho", "vest"};
fields_reverse = (char *) "drho"; fields_reverse = {"drho"};
fields_border = (char *) "rho vest"; fields_border = {"rho", "vest"};
fields_border_vel = (char *) "rho vest"; fields_border_vel = {"rho", "vest"};
fields_exchange = (char *) "rho vest"; fields_exchange = {"rho", "vest"};
fields_restart = (char * ) "rho vest"; fields_restart = {"rho", "vest"};
fields_create = (char *) "rho drho vest"; fields_create = {"rho", "drho", "vest"};
fields_data_atom = (char *) "id type rho x"; fields_data_atom = {"id", "type", "rho", "x"};
fields_data_vel = (char *) "id v"; fields_data_vel = {"id", "v"};
setup_fields(); setup_fields();
} }
@ -58,8 +59,7 @@ void AtomVecMDPD::init()
{ {
AtomVec::init(); AtomVec::init();
if (strcmp(update->unit_style,"lj") != 0) if (strcmp(update->unit_style, "lj") != 0) error->all(FLERR, "Atom style mdpd requires lj units");
error->all(FLERR,"Atom style mdpd requires lj units");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -102,10 +102,10 @@ void AtomVecMDPD::data_atom_post(int ilocal)
return -1 if name is unknown to this atom style return -1 if name is unknown to this atom style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int AtomVecMDPD::property_atom(char *name) int AtomVecMDPD::property_atom(const std::string &name)
{ {
if (strcmp(name,"rho") == 0) return 0; if (name == "rho") return 0;
if (strcmp(name,"drho") == 0) return 1; if (name == "drho") return 1;
return -1; return -1;
} }
@ -114,8 +114,7 @@ int AtomVecMDPD::property_atom(char *name)
index maps to data specific to this atom style index maps to data specific to this atom style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecMDPD::pack_property_atom(int index, double *buf, void AtomVecMDPD::pack_property_atom(int index, double *buf, int nvalues, int groupbit)
int nvalues, int groupbit)
{ {
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
@ -123,14 +122,18 @@ void AtomVecMDPD::pack_property_atom(int index, double *buf,
int n = 0; int n = 0;
if (index == 0) { if (index == 0) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = rho[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = rho[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 1) { } else if (index == 1) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = drho[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = drho[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} }

View File

@ -32,7 +32,7 @@ class AtomVecMDPD : public AtomVec {
void grow_pointers() override; void grow_pointers() override;
void force_clear(int, size_t) override; void force_clear(int, size_t) override;
void data_atom_post(int) override; void data_atom_post(int) override;
int property_atom(char *) override; int property_atom(const std::string &) override;
void pack_property_atom(int, double *, int, int) override; void pack_property_atom(int, double *, int, int) override;
private: private:

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -13,11 +12,12 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "atom_vec_tdpd.h" #include "atom_vec_tdpd.h"
#include <cstring>
#include "atom.h"
#include "update.h"
#include "error.h"
#include "atom.h"
#include "error.h"
#include "update.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -37,18 +37,18 @@ AtomVecTDPD::AtomVecTDPD(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "cc cc_flux vest"; fields_grow = {"cc", "cc_flux", "vest"};
fields_copy = (char *) "cc vest"; fields_copy = {"cc", "vest"};
fields_comm = (char *) "cc vest"; fields_comm = {"cc", "vest"};
fields_comm_vel = (char *) "cc vest"; fields_comm_vel = {"cc", "vest"};
fields_reverse = (char *) "cc_flux"; fields_reverse = {"cc_flux"};
fields_border = (char *) "cc vest"; fields_border = {"cc", "vest"};
fields_border_vel = (char *) "cc vest"; fields_border_vel = {"cc", "vest"};
fields_exchange = (char *) "cc vest"; fields_exchange = {"cc", "vest"};
fields_restart = (char * ) "cc vest"; fields_restart = {"cc", "vest"};
fields_create = (char *) "cc vest"; fields_create = {"cc", "vest"};
fields_data_atom = (char *) "id type x cc"; fields_data_atom = {"id", "type", "x", "cc"};
fields_data_vel = (char *) "id v"; fields_data_vel = {"id", "v"};
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -77,8 +77,7 @@ void AtomVecTDPD::init()
{ {
AtomVec::init(); AtomVec::init();
if (strcmp(update->unit_style,"lj") != 0) if (strcmp(update->unit_style, "lj") != 0) error->all(FLERR, "Atom style tdpd requires lj units");
error->all(FLERR,"Atom style tdpd requires lj units");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -92,7 +91,6 @@ void AtomVecTDPD::grow_pointers()
vest = atom->vest; vest = atom->vest;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
clear extra forces starting at atom N clear extra forces starting at atom N
nbytes = # of bytes to clear for a per-atom vector nbytes = # of bytes to clear for a per-atom vector

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -17,6 +16,7 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "atom_vec_dpd.h" #include "atom_vec_dpd.h"
#include "atom.h" #include "atom.h"
#include "error.h" #include "error.h"
@ -37,18 +37,17 @@ AtomVecDPD::AtomVecDPD(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "rho dpdTheta uCond uMech uChem uCG uCGnew duChem"; fields_grow = {"rho", "dpdTheta", "uCond", "uMech", "uChem", "uCG", "uCGnew", "duChem"};
fields_copy = (char *) "dpdTheta uCond uMech uChem uCG uCGnew"; fields_copy = {"dpdTheta", "uCond", "uMech", "uChem", "uCG", "uCGnew"};
fields_comm = (char *) "dpdTheta uCond uMech uChem"; fields_comm = {"dpdTheta", "uCond", "uMech", "uChem"};
fields_comm_vel = (char *) "dpdTheta uCond uMech uChem"; fields_comm_vel = {"dpdTheta", "uCond", "uMech", "uChem"};
fields_reverse = (char *) ""; fields_border = {"dpdTheta", "uCond", "uMech", "uChem", "uCG", "uCGnew"};
fields_border = (char *) "dpdTheta uCond uMech uChem uCG uCGnew"; fields_border_vel = {"dpdTheta", "uCond", "uMech", "uChem", "uCG", "uCGnew"};
fields_border_vel = (char *) "dpdTheta uCond uMech uChem uCG uCGnew"; fields_exchange = {"dpdTheta", "uCond", "uMech", "uChem", "uCG", "uCGnew"};
fields_exchange = (char *) "dpdTheta uCond uMech uChem uCG uCGnew"; fields_restart = {"dpdTheta", "uCond", "uMech", "uChem"};
fields_restart = (char *) "dpdTheta uCond uMech uChem"; fields_create = {"rho", "dpdTheta", "uCond", "uMech", "uChem", "uCG", "uCGnew", "duChem"};
fields_create = (char *) "rho dpdTheta uCond uMech uChem uCG uCGnew duChem"; fields_data_atom = {"id", "type", "dpdTheta", "x"};
fields_data_atom = (char *) "id type dpdTheta x"; fields_data_vel = {"id", "v"};
fields_data_vel = (char *) "id v";
setup_fields(); setup_fields();
} }
@ -94,6 +93,5 @@ void AtomVecDPD::data_atom_post(int ilocal)
uCGnew[ilocal] = 0.0; uCGnew[ilocal] = 0.0;
if (dpdTheta[ilocal] <= 0) if (dpdTheta[ilocal] <= 0)
error->one(FLERR,"Internal temperature in Atoms section of date file " error->one(FLERR, "Internal temperature in Atoms section of date file must be > zero");
"must be > zero");
} }

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -21,15 +20,14 @@
#include "atom.h" #include "atom.h"
#include "citeme.h" #include "citeme.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
static const char cite_user_eff_package[] = static const char cite_user_eff_package[] =
"EFF package:\n\n" "EFF package:\n\n"
"@Article{Jaramillo-Botero11,\n" "@Article{Jaramillo-Botero11,\n"
" author = {A. Jaramillo-Botero, J. Su, A. Qi, W. A. Goddard III},\n" " author = {A. Jaramillo-Botero, J. Su, A. Qi, W. A. Goddard III},\n"
" title = {Large-Scale, Long-Term Nonadiabatic Electron Molecular Dynamics for Describing Material Properties and Phenomena in Extreme Environments},\n" " title = {Large-Scale, Long-Term Nonadiabatic Electron Molecular Dynamics for Describing "
"Material Properties and Phenomena in Extreme Environments},\n"
" journal = {J.~Comp.~Chem.},\n" " journal = {J.~Comp.~Chem.},\n"
" year = 2011,\n" " year = 2011,\n"
" volume = 32,\n" " volume = 32,\n"
@ -47,26 +45,25 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp)
forceclearflag = 1; forceclearflag = 1;
atom->electron_flag = 1; atom->electron_flag = 1;
atom->q_flag = atom->spin_flag = atom->eradius_flag = atom->q_flag = atom->spin_flag = atom->eradius_flag = atom->ervel_flag = atom->erforce_flag = 1;
atom->ervel_flag = atom->erforce_flag = 1;
// strings with peratom variables to include in each AtomVec method // strings with peratom variables to include in each AtomVec method
// strings cannot contain fields in corresponding AtomVec default strings // strings cannot contain fields in corresponding AtomVec default strings
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "q spin eradius ervel erforce"; fields_grow = {"q", "spin", "eradius", "ervel", "erforce"};
fields_copy = (char *) "q spin eradius ervel"; fields_copy = {"q", "spin", "eradius", "ervel"};
fields_comm = (char *) "eradius"; fields_comm = {"eradius"};
fields_comm_vel = (char *) "eradius"; fields_comm_vel = {"eradius"};
fields_reverse = (char *) "erforce"; fields_reverse = {"erforce"};
fields_border = (char *) "q spin eradius"; fields_border = {"q", "spin", "eradius"};
fields_border_vel = (char *) "q spin eradius"; fields_border_vel = {"q", "spin", "eradius"};
fields_exchange = (char *) "q spin eradius ervel"; fields_exchange = {"q", "spin", "eradius", "ervel"};
fields_restart = (char *) "q spin eradius ervel"; fields_restart = {"q", "spin", "eradius", "ervel"};
fields_create = (char *) "q spin eradius ervel"; fields_create = {"q", "spin", "eradius", "ervel"};
fields_data_atom = (char *) "id type q spin eradius x"; fields_data_atom = {"id", "type", "q", "spin", "eradius", "x"};
fields_data_vel = (char *) "id v ervel"; fields_data_vel = {"id", "v", "ervel"};
setup_fields(); setup_fields();
} }
@ -119,12 +116,12 @@ void AtomVecElectron::data_atom_post(int ilocal)
return -1 if name is unknown to this atom style return -1 if name is unknown to this atom style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int AtomVecElectron::property_atom(char *name) int AtomVecElectron::property_atom(const std::string &name)
{ {
if (strcmp(name,"spin") == 0) return 0; if (name == "spin") return 0;
if (strcmp(name,"eradius") == 0) return 1; if (name == "eradius") return 1;
if (strcmp(name,"ervel") == 0) return 2; if (name == "ervel") return 2;
if (strcmp(name,"erforce") == 0) return 3; if (name == "erforce") return 3;
return -1; return -1;
} }
@ -133,8 +130,7 @@ int AtomVecElectron::property_atom(char *name)
index maps to data specific to this atom style index maps to data specific to this atom style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecElectron::pack_property_atom(int index, double *buf, void AtomVecElectron::pack_property_atom(int index, double *buf, int nvalues, int groupbit)
int nvalues, int groupbit)
{ {
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
@ -142,26 +138,34 @@ void AtomVecElectron::pack_property_atom(int index, double *buf,
if (index == 0) { if (index == 0) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = spin[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = spin[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 1) { } else if (index == 1) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = eradius[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = eradius[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 2) { } else if (index == 2) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = ervel[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = ervel[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 3) { } else if (index == 3) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = erforce[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = erforce[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} }

View File

@ -32,7 +32,7 @@ class AtomVecElectron : public AtomVec {
void force_clear(int, size_t) override; void force_clear(int, size_t) override;
void create_atom_post(int) override; void create_atom_post(int) override;
void data_atom_post(int) override; void data_atom_post(int) override;
int property_atom(char *) override; int property_atom(const std::string &) override;
void pack_property_atom(int, double *, int, int) override; void pack_property_atom(int, double *, int, int) override;
private: private:

View File

@ -273,7 +273,7 @@ double BondFENENM::single(int type, double rsq, int /*i*/, int /*j*/, double &ff
void *BondFENENM::extract(const char *str, int &dim) void *BondFENENM::extract(const char *str, int &dim)
{ {
dim = 1; dim = 1;
if (strcmp(str, "kappa") == 0) return (void *) k; if (strcmp(str, "k") == 0) return (void *) k;
if (strcmp(str, "r0") == 0) return (void *) r0; if (strcmp(str, "r0") == 0) return (void *) r0;
return nullptr; return nullptr;
} }

View File

@ -34,9 +34,7 @@ using namespace MathConst;
BondGaussian::BondGaussian(LAMMPS *lmp) : BondGaussian::BondGaussian(LAMMPS *lmp) :
Bond(lmp), nterms(nullptr), bond_temperature(nullptr), alpha(nullptr), width(nullptr), Bond(lmp), nterms(nullptr), bond_temperature(nullptr), alpha(nullptr), width(nullptr),
r0(nullptr) r0(nullptr)
{ {}
reinitflag = 1;
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -45,7 +45,6 @@ using namespace LAMMPS_NS;
PairCoulSlaterLong::PairCoulSlaterLong(LAMMPS *lmp) : Pair(lmp) PairCoulSlaterLong::PairCoulSlaterLong(LAMMPS *lmp) : Pair(lmp)
{ {
ewaldflag = pppmflag = 1; ewaldflag = pppmflag = 1;
//ftable = nullptr;
qdist = 0.0; qdist = 0.0;
} }
@ -117,7 +116,6 @@ void PairCoulSlaterLong::compute(int eflag, int vflag)
if (rsq < cut_coulsq) { if (rsq < cut_coulsq) {
r2inv = 1.0/rsq; r2inv = 1.0/rsq;
// if (!ncoultablebits || rsq <= tabinnersq) {
r = sqrt(rsq); r = sqrt(rsq);
grij = g_ewald * r; grij = g_ewald * r;
expm2 = exp(-grij*grij); expm2 = exp(-grij*grij);
@ -127,22 +125,6 @@ void PairCoulSlaterLong::compute(int eflag, int vflag)
prefactor = qqrd2e * scale[itype][jtype] * qtmp*q[j]/r; prefactor = qqrd2e * scale[itype][jtype] * qtmp*q[j]/r;
forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - slater_term); forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - slater_term);
if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor;
/*
} else {
union_int_float_t rsq_lookup;
rsq_lookup.f = rsq;
itable = rsq_lookup.i & ncoulmask;
itable >>= ncoulshiftbits;
fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable];
table = ftable[itable] + fraction*dftable[itable];
forcecoul = scale[itype][jtype] * qtmp*q[j] * table;
if (factor_coul < 1.0) {
table = ctable[itable] + fraction*dctable[itable];
prefactor = scale[itype][jtype] * qtmp*q[j] * table;
forcecoul -= (1.0-factor_coul)*prefactor;
}
}
*/
fpair = forcecoul * r2inv; fpair = forcecoul * r2inv;
@ -156,14 +138,7 @@ void PairCoulSlaterLong::compute(int eflag, int vflag)
} }
if (eflag) { if (eflag) {
// if (!ncoultablebits || rsq <= tabinnersq)
ecoul = prefactor*(erfc - (1 + r/lamda)*exp(-2*r/lamda)); ecoul = prefactor*(erfc - (1 + r/lamda)*exp(-2*r/lamda));
/*
else {
table = etable[itable] + fraction*detable[itable];
ecoul = scale[itype][jtype] * qtmp*q[j] * table;
}
*/
if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor;
} }
@ -296,10 +271,10 @@ void PairCoulSlaterLong::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR, &setflag[i][j],sizeof(int),1,fp, nullptr, error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) fread(&scale[i][j],sizeof(double),1,fp); if (me == 0) utils::sfread(FLERR, &scale[i][j],sizeof(double),1,fp, nullptr, error);
MPI_Bcast(&scale[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&scale[i][j],1,MPI_DOUBLE,0,world);
} }
} }
@ -315,8 +290,6 @@ void PairCoulSlaterLong::write_restart_settings(FILE *fp)
fwrite(&lamda,sizeof(double),1,fp); fwrite(&lamda,sizeof(double),1,fp);
fwrite(&offset_flag,sizeof(int),1,fp); fwrite(&offset_flag,sizeof(int),1,fp);
fwrite(&mix_flag,sizeof(int),1,fp); fwrite(&mix_flag,sizeof(int),1,fp);
//fwrite(&ncoultablebits,sizeof(int),1,fp);
//fwrite(&tabinner,sizeof(double),1,fp);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -326,36 +299,27 @@ void PairCoulSlaterLong::write_restart_settings(FILE *fp)
void PairCoulSlaterLong::read_restart_settings(FILE *fp) void PairCoulSlaterLong::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR, &cut_coul,sizeof(double),1,fp,nullptr,error);
fread(&lamda,sizeof(double),1,fp); utils::sfread(FLERR, &lamda,sizeof(double),1,fp,nullptr,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR, &offset_flag,sizeof(int),1,fp,nullptr,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR, &mix_flag,sizeof(int),1,fp,nullptr,error);
//fread(&ncoultablebits,sizeof(int),1,fp);
//fread(&tabinner,sizeof(double),1,fp);
} }
MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world);
MPI_Bcast(&lamda,1,MPI_DOUBLE,0,world); MPI_Bcast(&lamda,1,MPI_DOUBLE,0,world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world); MPI_Bcast(&offset_flag,1,MPI_INT,0,world);
MPI_Bcast(&mix_flag,1,MPI_INT,0,world); MPI_Bcast(&mix_flag,1,MPI_INT,0,world);
//MPI_Bcast(&ncoultablebits,1,MPI_INT,0,world);
//MPI_Bcast(&tabinner,1,MPI_DOUBLE,0,world);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
double PairCoulSlaterLong::single(int i, int j, int /*itype*/, int /*jtype*/, double PairCoulSlaterLong::single(int i, int j, int /*itype*/, int /*jtype*/, double rsq,
double rsq, double factor_coul, double /*factor_lj*/, double &fforce)
double factor_coul, double /*factor_lj*/,
double &fforce)
{ {
double r2inv,r,grij,expm2,t,erfc,prefactor; double r2inv,r,grij,expm2,t,erfc,prefactor;
double slater_term; double slater_term;
// double fraction,table;
double forcecoul,phicoul; double forcecoul,phicoul;
// int itable;
r2inv = 1.0/rsq; r2inv = 1.0/rsq;
// if (!ncoultablebits || rsq <= tabinnersq) {
r = sqrt(rsq); r = sqrt(rsq);
grij = g_ewald * r; grij = g_ewald * r;
expm2 = exp(-grij*grij); expm2 = exp(-grij*grij);
@ -365,32 +329,9 @@ double PairCoulSlaterLong::single(int i, int j, int /*itype*/, int /*jtype*/,
prefactor = force->qqrd2e * atom->q[i]*atom->q[j]/r; prefactor = force->qqrd2e * atom->q[i]*atom->q[j]/r;
forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - slater_term); forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - slater_term);
if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor;
/*
} else {
union_int_float_t rsq_lookup;
rsq_lookup.f = rsq;
itable = rsq_lookup.i & ncoulmask;
itable >>= ncoulshiftbits;
fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable];
table = ftable[itable] + fraction*dftable[itable];
forcecoul = atom->q[i]*atom->q[j] * table;
if (factor_coul < 1.0) {
table = ctable[itable] + fraction*dctable[itable];
prefactor = atom->q[i]*atom->q[j] * table;
forcecoul -= (1.0-factor_coul)*prefactor;
}
}
*/
fforce = forcecoul * r2inv; fforce = forcecoul * r2inv;
// if (!ncoultablebits || rsq <= tabinnersq)
phicoul = prefactor*(erfc - (1 + r/lamda)*exp(-2*r/lamda)); phicoul = prefactor*(erfc - (1 + r/lamda)*exp(-2*r/lamda));
/*
else {
table = etable[itable] + fraction*detable[itable];
phicoul = atom->q[i]*atom->q[j] * table;
}
*/
if (factor_coul < 1.0) phicoul -= (1.0-factor_coul)*prefactor; if (factor_coul < 1.0) phicoul -= (1.0-factor_coul)*prefactor;
return phicoul; return phicoul;

View File

@ -43,7 +43,6 @@ class PairCoulSlaterLong : public Pair {
protected: protected:
double cut_coul, cut_coulsq, qdist; double cut_coul, cut_coulsq, qdist;
double lamda; double lamda;
//double *cut_respa;
double g_ewald; double g_ewald;
double **scale; double **scale;

View File

@ -294,15 +294,15 @@ void PairWFCut::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR, &setflag[i][j],sizeof(int),1,fp, nullptr, error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR, &epsilon[i][j],sizeof(double),1,fp, nullptr, error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR, &sigma[i][j],sizeof(double),1,fp, nullptr, error);
fread(&nu[i][j],sizeof(int),1,fp); utils::sfread(FLERR, &nu[i][j],sizeof(int),1,fp, nullptr, error);
fread(&mu[i][j],sizeof(int),1,fp); utils::sfread(FLERR, &mu[i][j],sizeof(int),1,fp, nullptr, error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR, &cut[i][j],sizeof(double),1,fp, nullptr, error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -331,9 +331,9 @@ void PairWFCut::write_restart_settings(FILE *fp)
void PairWFCut::read_restart_settings(FILE *fp) void PairWFCut::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR, &cut_global,sizeof(double),1,fp,nullptr,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR, &offset_flag,sizeof(int),1,fp,nullptr,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR, &mix_flag,sizeof(int),1,fp,nullptr,error);
} }
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world); MPI_Bcast(&offset_flag,1,MPI_INT,0,world);

View File

@ -215,7 +215,7 @@ void VerletLRTIntel::run(int n)
int n_pre_neighbor = modify->n_pre_neighbor; int n_pre_neighbor = modify->n_pre_neighbor;
int n_pre_force = modify->n_pre_force; int n_pre_force = modify->n_pre_force;
int n_pre_reverse = modify->n_pre_reverse; int n_pre_reverse = modify->n_pre_reverse;
int n_post_force = modify->n_post_force; int n_post_force = modify->n_post_force_any;
int n_end_of_step = modify->n_end_of_step; int n_end_of_step = modify->n_end_of_step;
if (atom->sortfreq > 0) sortflag = 1; if (atom->sortfreq > 0) sortflag = 1;

View File

@ -1073,17 +1073,14 @@ void AtomVecHybridKokkos::write_data(FILE *fp, int n, double **buf)
int k,m; int k,m;
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
fprintf(fp,TAGINT_FORMAT " %d %-1.16e %-1.16e %-1.16e", fmt::print(fp,"{} {} {:.16e} {:.16e} {:.16e}", ubuf(buf[i][0]).i, ubuf(buf[i][1]).i,
(tagint) ubuf(buf[i][0]).i,(int) ubuf(buf[i][1]).i,
buf[i][2], buf[i][3], buf[i][4]); buf[i][2], buf[i][3], buf[i][4]);
m = 5; m = 5;
for (k = 0; k < nstyles; k++) for (k = 0; k < nstyles; k++)
m += styles[k]->write_data_hybrid(fp,&buf[i][m]); m += styles[k]->write_data_hybrid(fp,&buf[i][m]);
fprintf(fp," %d %d %d\n", fmt::print(fp," {} {} {}\n", ubuf(buf[i][m]).i, ubuf(buf[i][m+1]).i, ubuf(buf[i][m+2]).i);
(int) ubuf(buf[i][m]).i,(int) ubuf(buf[i][m+1]).i,
(int) ubuf(buf[i][m+2]).i);
} }
} }
@ -1119,8 +1116,7 @@ void AtomVecHybridKokkos::write_vel(FILE *fp, int n, double **buf)
int k,m; int k,m;
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
fprintf(fp,TAGINT_FORMAT " %g %g %g", fmt::print(fp,"{} {} {} {}", (tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3]);
(tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3]);
m = 4; m = 4;
for (k = 0; k < nstyles; k++) for (k = 0; k < nstyles; k++)
@ -1136,7 +1132,7 @@ void AtomVecHybridKokkos::write_vel(FILE *fp, int n, double **buf)
return -1 if name is unknown to any sub-styles return -1 if name is unknown to any sub-styles
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int AtomVecHybridKokkos::property_atom(char *name) int AtomVecHybridKokkos::property_atom(const std::string &name)
{ {
for (int k = 0; k < nstyles; k++) { for (int k = 0; k < nstyles; k++) {
int index = styles[k]->property_atom(name); int index = styles[k]->property_atom(name);
@ -1150,8 +1146,7 @@ int AtomVecHybridKokkos::property_atom(char *name)
index maps to data specific to this atom style index maps to data specific to this atom style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecHybridKokkos::pack_property_atom(int multiindex, double *buf, void AtomVecHybridKokkos::pack_property_atom(int multiindex, double *buf, int nvalues, int groupbit)
int nvalues, int groupbit)
{ {
int k = multiindex % nstyles; int k = multiindex % nstyles;
int index = multiindex/nstyles; int index = multiindex/nstyles;

View File

@ -64,7 +64,7 @@ class AtomVecHybridKokkos : public AtomVecKokkos {
void write_data(FILE *, int, double **) override; void write_data(FILE *, int, double **) override;
void pack_vel(double **) override; void pack_vel(double **) override;
void write_vel(FILE *, int, double **) override; void write_vel(FILE *, int, double **) override;
int property_atom(char *) override; int property_atom(const std::string &) override;
void pack_property_atom(int, double *, int, int) override; void pack_property_atom(int, double *, int, int) override;
double memory_usage() override; double memory_usage() override;

View File

@ -159,7 +159,7 @@ void DynamicalMatrixKokkos::update_force()
{ {
int n_pre_force = modify->n_pre_force; int n_pre_force = modify->n_pre_force;
int n_pre_reverse = modify->n_pre_reverse; int n_pre_reverse = modify->n_pre_reverse;
int n_post_force = modify->n_post_force; int n_post_force = modify->n_post_force_any;
lmp->kokkos->auto_sync = 0; lmp->kokkos->auto_sync = 0;

View File

@ -160,7 +160,7 @@ void ThirdOrderKokkos::update_force()
{ {
int n_pre_force = modify->n_pre_force; int n_pre_force = modify->n_pre_force;
int n_pre_reverse = modify->n_pre_reverse; int n_pre_reverse = modify->n_pre_reverse;
int n_post_force = modify->n_post_force; int n_post_force = modify->n_post_force_any;
lmp->kokkos->auto_sync = 0; lmp->kokkos->auto_sync = 0;

View File

@ -271,7 +271,7 @@ void VerletKokkos::run(int n)
int n_post_neighbor = modify->n_post_neighbor; int n_post_neighbor = modify->n_post_neighbor;
int n_pre_force = modify->n_pre_force; int n_pre_force = modify->n_pre_force;
int n_pre_reverse = modify->n_pre_reverse; int n_pre_reverse = modify->n_pre_reverse;
int n_post_force = modify->n_post_force; int n_post_force = modify->n_post_force_any;
int n_end_of_step = modify->n_end_of_step; int n_end_of_step = modify->n_end_of_step;
lmp->kokkos->auto_sync = 0; lmp->kokkos->auto_sync = 0;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
* *
* *** Smooth Mach Dynamics *** * *** Smooth Mach Dynamics ***
@ -27,8 +26,6 @@
#include "atom.h" #include "atom.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define NMAT_FULL 9 #define NMAT_FULL 9
@ -63,37 +60,28 @@ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) // clang-format off
"esph desph vfrac rmass x0 radius contact_radius molecule " fields_grow = {"esph", "desph", "vfrac", "rmass", "x0", "radius", "contact_radius", "molecule",
"smd_data_9 vest smd_stress " "smd_data_9", "vest", "smd_stress", "eff_plastic_strain", "eff_plastic_strain_rate", "damage"};
"eff_plastic_strain eff_plastic_strain_rate damage"; fields_copy = {"esph", "vfrac", "rmass", "x0", "radius", "contact_radius", "molecule",
fields_copy = (char *) "eff_plastic_strain", "eff_plastic_strain_rate", "vest", "smd_data_9", "smd_stress", "damage"};
"esph vfrac rmass x0 radius contact_radius molecule " fields_comm = {"radius", "vfrac", "vest", "esph"};
"eff_plastic_strain eff_plastic_strain_rate vest " fields_comm_vel = {"radius", "vfrac", "vest", "esph"};
"smd_data_9 smd_stress damage"; fields_reverse = {"desph"};
fields_comm = (char *) "radius vfrac vest esph"; fields_border = {"x0", "molecule", "radius", "rmass", "vfrac", "contact_radius", "esph",
fields_comm_vel = (char *) "radius vfrac vest esph"; "eff_plastic_strain", "smd_data_9", "smd_stress"};
fields_reverse = (char *) "desph"; fields_border_vel = {"x0", "molecule", "radius", "rmass", "vfrac", "contact_radius", "esph",
fields_border = (char *) "eff_plastic_strain", "smd_data_9", "smd_stress", "vest"};
"x0 molecule radius rmass vfrac contact_radius esph " fields_exchange = {"x0", "molecule", "radius", "rmass", "vfrac", "contact_radius", "esph",
"eff_plastic_strain smd_data_9 smd_stress"; "eff_plastic_strain", "eff_plastic_strain_rate", "smd_data_9", "smd_stress", "vest", "damage"};
fields_border_vel = (char *) fields_restart ={"x0", "molecule", "radius", "rmass", "vfrac", "contact_radius", "esph",
"x0 molecule radius rmass vfrac contact_radius esph " "eff_plastic_strain", "eff_plastic_strain_rate", "smd_data_9", "smd_stress", "vest", "damage"};
"eff_plastic_strain smd_data_9 smd_stress vest"; fields_create = {"x0", "vest", "vfrac", "rmass", "radius", "contact_radius", "molecule",
fields_exchange = (char *) "esph", "eff_plastic_strain", "eff_plastic_strain_rate", "smd_data_9", "smd_stress", "damage"};
"x0 molecule radius rmass vfrac contact_radius esph " fields_data_atom = {"id", "type", "molecule", "vfrac", "rmass", "radius", "contact_radius",
"eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress " "x0", "x"};
"vest damage"; fields_data_vel = {"id", "v"};
fields_restart = (char *) // clang-format on
"x0 molecule radius rmass vfrac contact_radius esph "
"eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress "
"vest damage";
fields_create = (char *)
"x0 vest vfrac rmass radius contact_radius molecule esph "
"eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress damage";
fields_data_atom = (char *)
"id type molecule vfrac rmass radius contact_radius x0 x";
fields_data_vel = (char *) "id v";
// set these array sizes based on defines // set these array sizes based on defines
@ -179,11 +167,9 @@ void AtomVecSMD::data_atom_post(int ilocal)
eff_plastic_strain[ilocal] = 0.0; eff_plastic_strain[ilocal] = 0.0;
eff_plastic_strain_rate[ilocal] = 0.0; eff_plastic_strain_rate[ilocal] = 0.0;
for (int k = 0; k < NMAT_FULL; k++) for (int k = 0; k < NMAT_FULL; k++) smd_data_9[ilocal][k] = 0.0;
smd_data_9[ilocal][k] = 0.0;
for (int k = 0; k < NMAT_SYMM; k++) for (int k = 0; k < NMAT_SYMM; k++) smd_stress[ilocal][k] = 0.0;
smd_stress[ilocal][k] = 0.0;
smd_data_9[ilocal][0] = 1.0; // xx smd_data_9[ilocal][0] = 1.0; // xx
smd_data_9[ilocal][4] = 1.0; // yy smd_data_9[ilocal][4] = 1.0; // yy

View File

@ -9,7 +9,7 @@ SHELL = /bin/sh
KOKKOS_ABSOLUTE_PATH = $(shell cd $(KOKKOS_PATH); pwd) KOKKOS_ABSOLUTE_PATH = $(shell cd $(KOKKOS_PATH); pwd)
CC = $(KOKKOS_ABSOLUTE_PATH)/bin/nvcc_wrapper CC = $(KOKKOS_ABSOLUTE_PATH)/bin/nvcc_wrapper
CCFLAGS = -g -O3 -DNDEBUG CCFLAGS = -g -O3 -DNDEBUG -Xcudafe --diag_suppress=unrecognized_pragma
SHFLAGS = -fPIC SHFLAGS = -fPIC
DEPFLAGS = -M DEPFLAGS = -M

View File

@ -10,7 +10,7 @@ KOKKOS_ABSOLUTE_PATH = $(shell cd $(KOKKOS_PATH); pwd)
export MPICH_CXX = $(KOKKOS_ABSOLUTE_PATH)/bin/nvcc_wrapper export MPICH_CXX = $(KOKKOS_ABSOLUTE_PATH)/bin/nvcc_wrapper
export OMPI_CXX = $(KOKKOS_ABSOLUTE_PATH)/bin/nvcc_wrapper export OMPI_CXX = $(KOKKOS_ABSOLUTE_PATH)/bin/nvcc_wrapper
CC = mpicxx CC = mpicxx
CCFLAGS = -g -O3 -DNDEBUG CCFLAGS = -g -O3 -DNDEBUG -Xcudafe --diag_suppress=unrecognized_pragma
SHFLAGS = -fPIC SHFLAGS = -fPIC
DEPFLAGS = -M DEPFLAGS = -M

View File

@ -532,7 +532,7 @@ double FixAtomSwap::energy_full()
if (force->kspace) force->kspace->compute(eflag,vflag); if (force->kspace) force->kspace->compute(eflag,vflag);
if (modify->n_post_force) modify->post_force(vflag); if (modify->n_post_force_any) modify->post_force(vflag);
update->eflag_global = update->ntimestep; update->eflag_global = update->ntimestep;
double total_energy = c_pe->compute_scalar(); double total_energy = c_pe->compute_scalar();

View File

@ -1129,7 +1129,7 @@ double FixChargeRegulation::energy_full() {
if (force->kspace) force->kspace->compute(eflag, vflag); if (force->kspace) force->kspace->compute(eflag, vflag);
if (modify->n_pre_reverse) modify->pre_reverse(eflag,vflag); if (modify->n_pre_reverse) modify->pre_reverse(eflag,vflag);
if (modify->n_post_force) modify->post_force(vflag); if (modify->n_post_force_any) modify->post_force(vflag);
update->eflag_global = update->ntimestep; update->eflag_global = update->ntimestep;
double total_energy = c_pe->compute_scalar(); double total_energy = c_pe->compute_scalar();

View File

@ -2316,7 +2316,7 @@ double FixGCMC::energy_full()
// but Modify::pre_reverse() is needed for INTEL // but Modify::pre_reverse() is needed for INTEL
if (modify->n_pre_reverse) modify->pre_reverse(eflag,vflag); if (modify->n_pre_reverse) modify->pre_reverse(eflag,vflag);
if (modify->n_post_force) modify->post_force(vflag); if (modify->n_post_force_any) modify->post_force(vflag);
// NOTE: all fixes with energy_global_flag set and which // NOTE: all fixes with energy_global_flag set and which
// operate at pre_force() or post_force() // operate at pre_force() or post_force()

View File

@ -390,7 +390,7 @@ double FixMolSwap::energy_full()
if (force->kspace) force->kspace->compute(eflag,vflag); if (force->kspace) force->kspace->compute(eflag,vflag);
if (modify->n_post_force) modify->post_force(vflag); if (modify->n_post_force_any) modify->post_force(vflag);
update->eflag_global = update->ntimestep; update->eflag_global = update->ntimestep;
double total_energy = c_pe->compute_scalar(); double total_energy = c_pe->compute_scalar();

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -33,18 +32,16 @@ AtomVecMesoNT::AtomVecMesoNT(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "rmass radius length buckling bond_nt molecule"; fields_grow = {"rmass", "radius", "length", "buckling", "bond_nt", "molecule"};
fields_copy = (char *) "rmass radius length buckling bond_nt molecule"; fields_copy = {"rmass", "radius", "length", "buckling", "bond_nt", "molecule"};
fields_comm = (char *) ""; fields_border = {"rmass", "radius", "length", "buckling", "bond_nt", "molecule"};
fields_comm_vel = (char *) ""; fields_border_vel = {"rmass", "radius", "length", "buckling", "bond_nt", "molecule"};
fields_reverse = (char *) ""; fields_exchange = {"rmass", "radius", "length", "buckling", "bond_nt", "molecule"};
fields_border = (char *) "rmass radius length buckling bond_nt molecule"; fields_restart = {"rmass", "radius", "length", "buckling", "bond_nt", "molecule"};
fields_border_vel = (char *) "rmass radius length buckling bond_nt molecule"; fields_create = {"rmass", "radius", "length", "buckling", "bond_nt", "molecule"};
fields_exchange = (char *) "rmass radius length buckling bond_nt molecule"; fields_data_atom = {"id", "molecule", "type", "bond_nt", "rmass",
fields_restart = (char *) "rmass radius length buckling bond_nt molecule"; "radius", "length", "buckling", "x"};
fields_create = (char *) "rmass radius length buckling bond_nt molecule"; fields_data_vel = {"id", "v"};
fields_data_atom = (char *) "id molecule type bond_nt rmass radius length buckling x";
fields_data_vel = (char *) "id v";
setup_fields(); setup_fields();
} }

View File

@ -703,7 +703,6 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename)
if (keywd == "rinner") { if (keywd == "rinner") {
keyval = words[iword]; keyval = words[iword];
for (int ielem = 0; ielem < nelements; ielem++) { for (int ielem = 0; ielem < nelements; ielem++) {
printf("rinnerelem = %p ielem = %d nelements = %d iword = %d nwords = %d\n",rinnerelem, ielem, nelements, iword, nwords);
rinnerelem[ielem] = utils::numeric(FLERR,keyval,false,lmp); rinnerelem[ielem] = utils::numeric(FLERR,keyval,false,lmp);
iword++; iword++;
} }

View File

@ -237,10 +237,21 @@ double AngleCosine::single(int type, int i1, int i2, int i3)
return k[type] * (1.0 + c); return k[type] * (1.0 + c);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AngleCosine::born_matrix(int type, int i1, int i2, int i3, double& du, double& du2) void AngleCosine::born_matrix(int type, int i1, int i2, int i3, double& du, double& du2)
{ {
du2 = 0; du2 = 0;
du = k[type]; du = k[type];
/* ----------------------------------------------------------------------
return ptr to internal members upon request
------------------------------------------------------------------------ */
void *AngleCosine::extract(const char *str, int &dim)
{
dim = 1;
if (strcmp(str, "k") == 0) return (void *) k;
return nullptr;
} }

View File

@ -36,6 +36,7 @@ class AngleCosine : public Angle {
void write_data(FILE *) override; void write_data(FILE *) override;
double single(int, int, int, int) override; double single(int, int, int, int) override;
void born_matrix(int type, int i1, int i2, int i3, double& du, double& du2) override; void born_matrix(int type, int i1, int i2, int i3, double& du, double& du2) override;
void *extract(const char *, int &) override;
protected: protected:
double *k; double *k;

View File

@ -264,3 +264,15 @@ double AngleHarmonic::single(int type, int i1, int i2, int i3)
double tk = k[type] * dtheta; double tk = k[type] * dtheta;
return tk * dtheta; return tk * dtheta;
} }
/* ----------------------------------------------------------------------
return ptr to internal members upon request
------------------------------------------------------------------------ */
void *AngleHarmonic::extract(const char *str, int &dim)
{
dim = 1;
if (strcmp(str, "k") == 0) return (void *) k;
if (strcmp(str, "theta0") == 0) return (void *) theta0;
return nullptr;
}

View File

@ -35,6 +35,7 @@ class AngleHarmonic : public Angle {
void read_restart(FILE *) override; void read_restart(FILE *) override;
void write_data(FILE *) override; void write_data(FILE *) override;
double single(int, int, int, int) override; double single(int, int, int, int) override;
void *extract(const char *, int &) override;
protected: protected:
double *k, *theta0; double *k, *theta0;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -32,26 +31,22 @@ AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) fields_grow = {"molecule", "num_bond", "bond_type", "bond_atom",
"molecule num_bond bond_type bond_atom " "num_angle", "angle_type", "angle_atom1", "angle_atom2",
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 nspecial special"; "angle_atom3", "nspecial", "special"};
fields_copy = (char *) fields_copy = {"molecule", "num_bond", "bond_type", "bond_atom",
"molecule num_bond bond_type bond_atom " "num_angle", "angle_type", "angle_atom1", "angle_atom2",
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 nspecial special"; "angle_atom3", "nspecial", "special"};
fields_comm = (char *) ""; fields_border = {"molecule"};
fields_comm_vel = (char *) ""; fields_border_vel = {"molecule"};
fields_reverse = (char *) ""; fields_exchange = {"molecule", "num_bond", "bond_type", "bond_atom",
fields_border = (char *) "molecule"; "num_angle", "angle_type", "angle_atom1", "angle_atom2",
fields_border_vel = (char *) "molecule"; "angle_atom3", "nspecial", "special"};
fields_exchange = (char *) fields_restart = {"molecule", "num_bond", "bond_type", "bond_atom", "num_angle",
"molecule num_bond bond_type bond_atom " "angle_type", "angle_atom1", "angle_atom2", "angle_atom3"};
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 nspecial special"; fields_create = {"molecule", "num_bond", "num_angle", "nspecial"};
fields_restart = (char *) fields_data_atom = {"id", "molecule", "type", "x"};
"molecule num_bond bond_type bond_atom " fields_data_vel = {"id", "v"};
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3";
fields_create = (char *) "molecule num_bond num_angle nspecial";
fields_data_atom = (char *) "id molecule type x";
fields_data_vel = (char *) "id v";
setup_fields(); setup_fields();
@ -108,7 +103,8 @@ void AtomVecAngle::pack_restart_pre(int ilocal)
bond_negative[m] = 1; bond_negative[m] = 1;
bond_type[ilocal][m] = -bond_type[ilocal][m]; bond_type[ilocal][m] = -bond_type[ilocal][m];
any_bond_negative = 1; any_bond_negative = 1;
} else bond_negative[m] = 0; } else
bond_negative[m] = 0;
} }
any_angle_negative = 0; any_angle_negative = 0;
@ -117,7 +113,8 @@ void AtomVecAngle::pack_restart_pre(int ilocal)
angle_negative[m] = 1; angle_negative[m] = 1;
angle_type[ilocal][m] = -angle_type[ilocal][m]; angle_type[ilocal][m] = -angle_type[ilocal][m];
any_angle_negative = 1; any_angle_negative = 1;
} else angle_negative[m] = 0; } else
angle_negative[m] = 0;
} }
} }

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -32,21 +31,15 @@ AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) fields_grow = {"molecule", "num_bond", "bond_type", "bond_atom", "nspecial", "special"};
"molecule num_bond bond_type bond_atom nspecial special"; fields_copy = {"molecule", "num_bond", "bond_type", "bond_atom", "nspecial", "special"};
fields_copy = (char *) fields_border = {"molecule"};
"molecule num_bond bond_type bond_atom nspecial special"; fields_border_vel = {"molecule"};
fields_comm = (char *) ""; fields_exchange = {"molecule", "num_bond", "bond_type", "bond_atom", "nspecial", "special"};
fields_comm_vel = (char *) ""; fields_restart = {"molecule", "num_bond", "bond_type", "bond_atom"};
fields_reverse = (char *) ""; fields_create = {"molecule", "num_bond", "nspecial"};
fields_border = (char *) "molecule"; fields_data_atom = {"id", "molecule", "type", "x"};
fields_border_vel = (char *) "molecule"; fields_data_vel = {"id", "v"};
fields_exchange = (char *)
"molecule num_bond bond_type bond_atom nspecial special";
fields_restart = (char *) "molecule num_bond bond_type bond_atom";
fields_create = (char *) "molecule num_bond nspecial";
fields_data_atom = (char *) "id molecule type x";
fields_data_vel = (char *) "id v";
setup_fields(); setup_fields();
@ -95,7 +88,8 @@ void AtomVecBond::pack_restart_pre(int ilocal)
bond_negative[m] = 1; bond_negative[m] = 1;
bond_type[ilocal][m] = -bond_type[ilocal][m]; bond_type[ilocal][m] = -bond_type[ilocal][m];
any_bond_negative = 1; any_bond_negative = 1;
} else bond_negative[m] = 0; } else
bond_negative[m] = 0;
} }
} }

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -32,47 +31,31 @@ AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) // clang-format off
"q molecule num_bond bond_type bond_atom " fields_grow = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
"dihedral_atom3 dihedral_atom4 " "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special"};
"num_improper improper_type improper_atom1 improper_atom2 " fields_copy = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
"improper_atom3 improper_atom4 " "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
"nspecial special"; "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
fields_copy = (char *) "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special"};
"q molecule num_bond bond_type bond_atom " fields_border = {"q", "molecule"};
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " fields_border_vel = {"q", "molecule"};
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " fields_exchange = {"q", "molecule", "num_bond", "bond_type", "bond_atom",
"dihedral_atom3 dihedral_atom4 " "num_angle", "angle_type", "angle_atom1", "angle_atom2", "angle_atom3",
"num_improper improper_type improper_atom1 improper_atom2 " "num_dihedral", "dihedral_type", "dihedral_atom1", "dihedral_atom2",
"improper_atom3 improper_atom4 " "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type", "improper_atom1",
"nspecial special"; "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special"};
fields_comm = (char *) ""; fields_restart = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle",
fields_comm_vel = (char *) ""; "angle_type", "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type",
fields_reverse = (char *) ""; "dihedral_atom1", "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper",
fields_border = (char *) "q molecule"; "improper_type", "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4"};
fields_border_vel = (char *) "q molecule"; fields_create = {"q", "molecule", "num_bond", "num_angle",
fields_exchange = (char *) "num_dihedral", "num_improper", "nspecial"};
"q molecule num_bond bond_type bond_atom " fields_data_atom = {"id", "molecule", "type", "q", "x"};
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " fields_data_vel = {"id", "v"};
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " // clang-format on
"dihedral_atom3 dihedral_atom4 "
"num_improper improper_type improper_atom1 improper_atom2 "
"improper_atom3 improper_atom4 "
"nspecial special";
fields_restart = (char *)
"q molecule num_bond bond_type bond_atom "
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
"dihedral_atom3 dihedral_atom4 "
"num_improper improper_type improper_atom1 improper_atom2 "
"improper_atom3 improper_atom4";
fields_create = (char *)
"q molecule num_bond num_angle num_dihedral num_improper nspecial";
fields_data_atom = (char *) "id molecule type q x";
fields_data_vel = (char *) "id v";
setup_fields(); setup_fields();
bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0; bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0;
@ -144,7 +127,8 @@ void AtomVecFull::pack_restart_pre(int ilocal)
bond_negative[m] = 1; bond_negative[m] = 1;
bond_type[ilocal][m] = -bond_type[ilocal][m]; bond_type[ilocal][m] = -bond_type[ilocal][m];
any_bond_negative = 1; any_bond_negative = 1;
} else bond_negative[m] = 0; } else
bond_negative[m] = 0;
} }
any_angle_negative = 0; any_angle_negative = 0;
@ -153,7 +137,8 @@ void AtomVecFull::pack_restart_pre(int ilocal)
angle_negative[m] = 1; angle_negative[m] = 1;
angle_type[ilocal][m] = -angle_type[ilocal][m]; angle_type[ilocal][m] = -angle_type[ilocal][m];
any_angle_negative = 1; any_angle_negative = 1;
} else angle_negative[m] = 0; } else
angle_negative[m] = 0;
} }
any_dihedral_negative = 0; any_dihedral_negative = 0;
@ -162,7 +147,8 @@ void AtomVecFull::pack_restart_pre(int ilocal)
dihedral_negative[m] = 1; dihedral_negative[m] = 1;
dihedral_type[ilocal][m] = -dihedral_type[ilocal][m]; dihedral_type[ilocal][m] = -dihedral_type[ilocal][m];
any_dihedral_negative = 1; any_dihedral_negative = 1;
} else dihedral_negative[m] = 0; } else
dihedral_negative[m] = 0;
} }
any_improper_negative = 0; any_improper_negative = 0;
@ -171,7 +157,8 @@ void AtomVecFull::pack_restart_pre(int ilocal)
improper_negative[m] = 1; improper_negative[m] = 1;
improper_type[ilocal][m] = -improper_type[ilocal][m]; improper_type[ilocal][m] = -improper_type[ilocal][m];
any_improper_negative = 1; any_improper_negative = 1;
} else improper_negative[m] = 0; } else
improper_negative[m] = 0;
} }
} }
@ -195,14 +182,12 @@ void AtomVecFull::pack_restart_post(int ilocal)
if (any_dihedral_negative) { if (any_dihedral_negative) {
for (int m = 0; m < num_dihedral[ilocal]; m++) for (int m = 0; m < num_dihedral[ilocal]; m++)
if (dihedral_negative[m]) if (dihedral_negative[m]) dihedral_type[ilocal][m] = -dihedral_type[ilocal][m];
dihedral_type[ilocal][m] = -dihedral_type[ilocal][m];
} }
if (any_improper_negative) { if (any_improper_negative) {
for (int m = 0; m < num_improper[ilocal]; m++) for (int m = 0; m < num_improper[ilocal]; m++)
if (improper_negative[m]) if (improper_negative[m]) improper_type[ilocal][m] = -improper_type[ilocal][m];
improper_type[ilocal][m] = -improper_type[ilocal][m];
} }
} }

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -32,46 +31,29 @@ AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) // clang-format off
"molecule num_bond bond_type bond_atom " fields_grow = {"molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
"dihedral_atom3 dihedral_atom4 " "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special"};
"num_improper improper_type improper_atom1 improper_atom2 " fields_copy = {"molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
"improper_atom3 improper_atom4 " "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
"nspecial special"; "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
fields_copy = (char *) "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special"};
"molecule num_bond bond_type bond_atom " fields_border = {"molecule"};
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " fields_border_vel = {"molecule"};
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " fields_exchange = {"molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
"dihedral_atom3 dihedral_atom4 " "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
"num_improper improper_type improper_atom1 improper_atom2 " "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
"improper_atom3 improper_atom4 " "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special"};
"nspecial special"; fields_restart = {"molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
fields_comm = (char *) ""; "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
fields_comm_vel = (char *) ""; "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
fields_reverse = (char *) ""; "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4"};
fields_border = (char *) "molecule"; fields_create = {"molecule", "num_bond", "num_angle", "num_dihedral", "num_improper", "nspecial"};
fields_border_vel = (char *) "molecule"; fields_data_atom = {"id", "molecule", "type", "x"};
fields_exchange = (char *) fields_data_vel = {"id", "v"};
"molecule num_bond bond_type bond_atom " // clang-format on
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
"dihedral_atom3 dihedral_atom4 "
"num_improper improper_type improper_atom1 improper_atom2 "
"improper_atom3 improper_atom4 "
"nspecial special";
fields_restart = (char *)
"molecule num_bond bond_type bond_atom "
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
"dihedral_atom3 dihedral_atom4 "
"num_improper improper_type improper_atom1 improper_atom2 "
"improper_atom3 improper_atom4";
fields_create = (char *)
"molecule num_bond num_angle num_dihedral num_improper nspecial";
fields_data_atom = (char *) "id molecule type x";
fields_data_vel = (char *) "id v";
setup_fields(); setup_fields();
@ -144,7 +126,8 @@ void AtomVecMolecular::pack_restart_pre(int ilocal)
bond_negative[m] = 1; bond_negative[m] = 1;
bond_type[ilocal][m] = -bond_type[ilocal][m]; bond_type[ilocal][m] = -bond_type[ilocal][m];
any_bond_negative = 1; any_bond_negative = 1;
} else bond_negative[m] = 0; } else
bond_negative[m] = 0;
} }
any_angle_negative = 0; any_angle_negative = 0;
@ -153,7 +136,8 @@ void AtomVecMolecular::pack_restart_pre(int ilocal)
angle_negative[m] = 1; angle_negative[m] = 1;
angle_type[ilocal][m] = -angle_type[ilocal][m]; angle_type[ilocal][m] = -angle_type[ilocal][m];
any_angle_negative = 1; any_angle_negative = 1;
} else angle_negative[m] = 0; } else
angle_negative[m] = 0;
} }
any_dihedral_negative = 0; any_dihedral_negative = 0;
@ -162,7 +146,8 @@ void AtomVecMolecular::pack_restart_pre(int ilocal)
dihedral_negative[m] = 1; dihedral_negative[m] = 1;
dihedral_type[ilocal][m] = -dihedral_type[ilocal][m]; dihedral_type[ilocal][m] = -dihedral_type[ilocal][m];
any_dihedral_negative = 1; any_dihedral_negative = 1;
} else dihedral_negative[m] = 0; } else
dihedral_negative[m] = 0;
} }
any_improper_negative = 0; any_improper_negative = 0;
@ -171,7 +156,8 @@ void AtomVecMolecular::pack_restart_pre(int ilocal)
improper_negative[m] = 1; improper_negative[m] = 1;
improper_type[ilocal][m] = -improper_type[ilocal][m]; improper_type[ilocal][m] = -improper_type[ilocal][m];
any_improper_negative = 1; any_improper_negative = 1;
} else improper_negative[m] = 0; } else
improper_negative[m] = 0;
} }
} }
@ -195,14 +181,12 @@ void AtomVecMolecular::pack_restart_post(int ilocal)
if (any_dihedral_negative) { if (any_dihedral_negative) {
for (int m = 0; m < num_dihedral[ilocal]; m++) for (int m = 0; m < num_dihedral[ilocal]; m++)
if (dihedral_negative[m]) if (dihedral_negative[m]) dihedral_type[ilocal][m] = -dihedral_type[ilocal][m];
dihedral_type[ilocal][m] = -dihedral_type[ilocal][m];
} }
if (any_improper_negative) { if (any_improper_negative) {
for (int m = 0; m < num_improper[ilocal]; m++) for (int m = 0; m < num_improper[ilocal]; m++)
if (improper_negative[m]) if (improper_negative[m]) improper_type[ilocal][m] = -improper_type[ilocal][m];
improper_type[ilocal][m] = -improper_type[ilocal][m];
} }
} }

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -36,18 +35,15 @@ AtomVecTemplate::AtomVecTemplate(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in the string does not matter // order of fields in the string does not matter
// except fields_data_atom and fields_data_vel which must match data file // except fields_data_atom and fields_data_vel which must match data file
fields_grow = (char *) "molecule molindex molatom"; fields_grow = {"molecule", "molindex", "molatom"};
fields_copy = (char *) "molecule molindex molatom"; fields_copy = {"molecule", "molindex", "molatom"};
fields_comm = (char *) ""; fields_border = {"molecule", "molindex", "molatom"};
fields_comm_vel = (char *) ""; fields_border_vel = {"molecule", "molindex", "molatom"};
fields_reverse = (char *) ""; fields_exchange = {"molecule", "molindex", "molatom"};
fields_border = (char *) "molecule molindex molatom"; fields_restart = {"molecule", "molindex", "molatom"};
fields_border_vel = (char *) "molecule molindex molatom"; fields_create = {"molecule", "molindex", "molatom"};
fields_exchange = (char *) "molecule molindex molatom"; fields_data_atom = {"id", "molecule", "molindex", "molatom", "type", "x"};
fields_restart = (char *) "molecule molindex molatom"; fields_data_vel = {"id", "v"};
fields_create = (char *) "molecule molindex molatom";
fields_data_atom = (char *) "id molecule molindex molatom type x";
fields_data_vel = (char *) "id v";
setup_fields(); setup_fields();
} }
@ -61,8 +57,7 @@ void AtomVecTemplate::process_args(int narg, char **arg)
if (narg != 1) error->all(FLERR, "Illegal atom_style template command"); if (narg != 1) error->all(FLERR, "Illegal atom_style template command");
int imol = atom->find_molecule(arg[0]); int imol = atom->find_molecule(arg[0]);
if (imol == -1) error->all(FLERR,"Molecule template ID for " if (imol == -1) error->all(FLERR, "Molecule template ID for atom_style template does not exist");
"atom_style template does not exist");
onemols = &atom->molecules[imol]; onemols = &atom->molecules[imol];
nset = atom->molecules[imol]->nset; nset = atom->molecules[imol]->nset;
@ -129,7 +124,6 @@ void AtomVecTemplate::pack_data_post(int ilocal)
molatom[ilocal]--; molatom[ilocal]--;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
modify what AtomVec::data_atom() just unpacked modify what AtomVec::data_atom() just unpacked
or initialize other atom quantities or initialize other atom quantities

View File

@ -265,7 +265,7 @@ double BondFENE::single(int type, double rsq, int /*i*/, int /*j*/, double &ffor
void *BondFENE::extract(const char *str, int &dim) void *BondFENE::extract(const char *str, int &dim)
{ {
dim = 1; dim = 1;
if (strcmp(str, "kappa") == 0) return (void *) k; if (strcmp(str, "k") == 0) return (void *) k;
if (strcmp(str, "r0") == 0) return (void *) r0; if (strcmp(str, "r0") == 0) return (void *) r0;
return nullptr; return nullptr;
} }

View File

@ -30,10 +30,7 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
BondGromos::BondGromos(LAMMPS *_lmp) : Bond(_lmp) BondGromos::BondGromos(LAMMPS *_lmp) : Bond(_lmp) {}
{
reinitflag = 1;
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -200,7 +197,7 @@ double BondGromos::single(int type, double rsq, int /*i*/, int /*j*/, double &ff
void *BondGromos::extract(const char *str, int &dim) void *BondGromos::extract(const char *str, int &dim)
{ {
dim = 1; dim = 1;
if (strcmp(str, "kappa") == 0) return (void *) k; if (strcmp(str, "k") == 0) return (void *) k;
if (strcmp(str, "r0") == 0) return (void *) r0; if (strcmp(str, "r0") == 0) return (void *) r0;
return nullptr; return nullptr;
} }

View File

@ -29,7 +29,6 @@ using namespace LAMMPS_NS;
BondHarmonic::BondHarmonic(LAMMPS *_lmp) : Bond(_lmp) BondHarmonic::BondHarmonic(LAMMPS *_lmp) : Bond(_lmp)
{ {
reinitflag = 1;
born_matrix_enable = 1; born_matrix_enable = 1;
} }
@ -216,12 +215,13 @@ void BondHarmonic::born_matrix(int type, double rsq, int /*i*/, int /*j*/,
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
Return ptr to internal members upon request. return ptr to internal members upon request
------------------------------------------------------------------------ */ ------------------------------------------------------------------------ */
void *BondHarmonic::extract(const char *str, int &dim) void *BondHarmonic::extract(const char *str, int &dim)
{ {
dim = 1; dim = 1;
if (strcmp(str, "kappa") == 0) return (void *) k; if (strcmp(str, "k") == 0) return (void *) k;
if (strcmp(str, "r0") == 0) return (void *) r0; if (strcmp(str, "r0") == 0) return (void *) r0;
return nullptr; return nullptr;
} }

View File

@ -77,7 +77,7 @@ void RespaOMP::setup(int flag)
mesg += fmt::format(" {}:{}", ilevel + 1, step[ilevel]); mesg += fmt::format(" {}:{}", ilevel + 1, step[ilevel]);
mesg += "\n r-RESPA fixes :"; mesg += "\n r-RESPA fixes :";
for (int l = 0; l < modify->n_post_force_respa; ++l) { for (int l = 0; l < modify->n_post_force_respa_any; ++l) {
Fix *f = modify->get_fix_by_index(modify->list_post_force_respa[l]); Fix *f = modify->get_fix_by_index(modify->list_post_force_respa[l]);
if (f->respa_level >= 0) if (f->respa_level >= 0)
mesg += fmt::format(" {}:{}[{}]", MIN(f->respa_level + 1, nlevels), f->style, f->id); mesg += fmt::format(" {}:{}[{}]", MIN(f->respa_level + 1, nlevels), f->style, f->id);
@ -420,7 +420,7 @@ void RespaOMP::recurse(int ilevel)
timer->stamp(Timer::COMM); timer->stamp(Timer::COMM);
} }
timer->stamp(); timer->stamp();
if (modify->n_post_force_respa) if (modify->n_post_force_respa_any)
modify->post_force_respa(vflag,ilevel,iloop); modify->post_force_respa(vflag,ilevel,iloop);
modify->final_integrate_respa(ilevel,iloop); modify->final_integrate_respa(ilevel,iloop);
timer->stamp(Timer::MODIFY); timer->stamp(Timer::MODIFY);

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -23,7 +22,6 @@
#include "error.h" #include "error.h"
#include <cfloat> #include <cfloat>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -55,18 +53,17 @@ AtomVecPeri::AtomVecPeri(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "rmass vfrac s0 x0"; fields_grow = {"rmass", "vfrac", "s0", "x0"};
fields_copy = (char *) "rmass vfrac s0 x0"; fields_copy = {"rmass", "vfrac", "s0", "x0"};
fields_comm = (char *) "s0"; fields_comm = {"s0"};
fields_comm_vel = (char *) "s0"; fields_comm_vel = {"s0"};
fields_reverse = (char *) ""; fields_border = {"rmass", "vfrac", "s0", "x0"};
fields_border = (char *) "rmass vfrac s0 x0"; fields_border_vel = {"rmass", "vfrac", "s0", "x0"};
fields_border_vel = (char *) "rmass vfrac s0 x0"; fields_exchange = {"rmass", "vfrac", "s0", "x0"};
fields_exchange = (char *) "rmass vfrac s0 x0"; fields_restart = {"rmass", "vfrac", "s0", "x0"};
fields_restart = (char *) "rmass vfrac s0 x0"; fields_create = {"rmass", "vfrac", "s0", "x0"};
fields_create = (char *) "rmass vfrac s0 x0"; fields_data_atom = {"id", "type", "vfrac", "rmass", "x"};
fields_data_atom = (char *) "id type vfrac rmass x"; fields_data_vel = {"id", "v"};
fields_data_vel = (char *) "id v";
setup_fields(); setup_fields();
} }
@ -110,8 +107,7 @@ void AtomVecPeri::data_atom_post(int ilocal)
x0[ilocal][1] = x[ilocal][1]; x0[ilocal][1] = x[ilocal][1];
x0[ilocal][2] = x[ilocal][2]; x0[ilocal][2] = x[ilocal][2];
if (rmass[ilocal] <= 0.0) if (rmass[ilocal] <= 0.0) error->one(FLERR, "Invalid mass in Atoms section of data file");
error->one(FLERR,"Invalid mass in Atoms section of data file");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -119,10 +115,10 @@ void AtomVecPeri::data_atom_post(int ilocal)
return -1 if name is unknown to this atom style return -1 if name is unknown to this atom style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int AtomVecPeri::property_atom(char *name) int AtomVecPeri::property_atom(const std::string &name)
{ {
if (strcmp(name,"vfrac") == 0) return 0; if (name == "vfrac") return 0;
if (strcmp(name,"s0") == 0) return 1; if (name == "s0") return 1;
return -1; return -1;
} }
@ -131,8 +127,7 @@ int AtomVecPeri::property_atom(char *name)
index maps to data specific to this atom style index maps to data specific to this atom style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecPeri::pack_property_atom(int index, double *buf, void AtomVecPeri::pack_property_atom(int index, double *buf, int nvalues, int groupbit)
int nvalues, int groupbit)
{ {
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
@ -140,14 +135,18 @@ void AtomVecPeri::pack_property_atom(int index, double *buf,
if (index == 0) { if (index == 0) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = vfrac[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = vfrac[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 1) { } else if (index == 1) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = s0[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = s0[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} }

View File

@ -31,7 +31,7 @@ class AtomVecPeri : public AtomVec {
void grow_pointers() override; void grow_pointers() override;
void create_atom_post(int) override; void create_atom_post(int) override;
void data_atom_post(int) override; void data_atom_post(int) override;
int property_atom(char *) override; int property_atom(const std::string &) override;
void pack_property_atom(int, double *, int, int) override; void pack_property_atom(int, double *, int, int) override;
private: private:

View File

@ -431,7 +431,7 @@ void DynamicalMatrix::update_force()
force_clear(); force_clear();
int n_pre_force = modify->n_pre_force; int n_pre_force = modify->n_pre_force;
int n_pre_reverse = modify->n_pre_reverse; int n_pre_reverse = modify->n_pre_reverse;
int n_post_force = modify->n_post_force; int n_post_force = modify->n_post_force_any;
if (n_pre_force) { if (n_pre_force) {
modify->pre_force(vflag); modify->pre_force(vflag);

View File

@ -487,7 +487,7 @@ void ThirdOrder::update_force()
neighbor->ago = 0; neighbor->ago = 0;
if (modify->get_fix_by_id("package_intel")) neighbor->decide(); if (modify->get_fix_by_id("package_intel")) neighbor->decide();
force_clear(); force_clear();
int n_post_force = modify->n_post_force; int n_post_force = modify->n_post_force_any;
int n_pre_force = modify->n_pre_force; int n_pre_force = modify->n_pre_force;
int n_pre_reverse = modify->n_pre_reverse; int n_pre_reverse = modify->n_pre_reverse;

View File

@ -300,7 +300,7 @@ void VerletSplit::run(int n)
int n_pre_neighbor = modify->n_pre_neighbor; int n_pre_neighbor = modify->n_pre_neighbor;
int n_pre_force = modify->n_pre_force; int n_pre_force = modify->n_pre_force;
int n_pre_reverse = modify->n_pre_reverse; int n_pre_reverse = modify->n_pre_reverse;
int n_post_force = modify->n_post_force; int n_post_force = modify->n_post_force_any;
int n_end_of_step = modify->n_end_of_step; int n_end_of_step = modify->n_end_of_step;
if (atom->sortfreq > 0) sortflag = 1; if (atom->sortfreq > 0) sortflag = 1;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -16,8 +15,6 @@
#include "atom.h" #include "atom.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -38,18 +35,18 @@ AtomVecSPH::AtomVecSPH(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "rho drho esph desph cv vest"; fields_grow = {"rho", "drho", "esph", "desph", "cv", "vest"};
fields_copy = (char *) "rho drho esph desph cv vest"; fields_copy = {"rho", "drho", "esph", "desph", "cv", "vest"};
fields_comm = (char *) "rho esph vest"; fields_comm = {"rho", "esph", "vest"};
fields_comm_vel = (char *) "rho esph vest"; fields_comm_vel = {"rho", "esph", "vest"};
fields_reverse = (char *) "drho desph"; fields_reverse = {"drho", "desph"};
fields_border = (char *) "rho esph cv vest"; fields_border = {"rho", "esph", "cv", "vest"};
fields_border_vel = (char *) "rho esph cv vest"; fields_border_vel = {"rho", "esph", "cv", "vest"};
fields_exchange = (char *) "rho esph cv vest"; fields_exchange = {"rho", "esph", "cv", "vest"};
fields_restart = (char * ) "rho esph cv vest"; fields_restart = {"rho", "esph", "cv", "vest"};
fields_create = (char *) "rho esph cv vest desph drho"; fields_create = {"rho", "esph", "cv", "vest", "desph", "drho"};
fields_data_atom = (char *) "id type rho esph cv x"; fields_data_atom = {"id", "type", "rho", "esph", "cv", "x"};
fields_data_vel = (char *) "id v"; fields_data_vel = {"id", "v"};
setup_fields(); setup_fields();
} }
@ -108,13 +105,13 @@ void AtomVecSPH::data_atom_post(int ilocal)
return -1 if name is unknown to this atom style return -1 if name is unknown to this atom style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int AtomVecSPH::property_atom(char *name) int AtomVecSPH::property_atom(const std::string &name)
{ {
if (strcmp(name,"rho") == 0) return 0; if (name == "rho") return 0;
if (strcmp(name,"drho") == 0) return 1; if (name == "drho") return 1;
if (strcmp(name,"esph") == 0) return 2; if (name == "esph") return 2;
if (strcmp(name,"desph") == 0) return 3; if (name == "desph") return 3;
if (strcmp(name,"cv") == 0) return 4; if (name == "cv") return 4;
return -1; return -1;
} }
@ -123,8 +120,7 @@ int AtomVecSPH::property_atom(char *name)
index maps to data specific to this atom style index maps to data specific to this atom style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecSPH::pack_property_atom(int index, double *buf, void AtomVecSPH::pack_property_atom(int index, double *buf, int nvalues, int groupbit)
int nvalues, int groupbit)
{ {
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
@ -132,32 +128,42 @@ void AtomVecSPH::pack_property_atom(int index, double *buf,
if (index == 0) { if (index == 0) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = rho[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = rho[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 1) { } else if (index == 1) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = drho[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = drho[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 2) { } else if (index == 2) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = esph[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = esph[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 3) { } else if (index == 3) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = desph[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = desph[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} else if (index == 4) { } else if (index == 4) {
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = cv[i]; if (mask[i] & groupbit)
else buf[n] = 0.0; buf[n] = cv[i];
else
buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
} }

View File

@ -32,7 +32,7 @@ class AtomVecSPH : public AtomVec {
void force_clear(int, size_t) override; void force_clear(int, size_t) override;
void create_atom_post(int) override; void create_atom_post(int) override;
void data_atom_post(int) override; void data_atom_post(int) override;
int property_atom(char *) override; int property_atom(const std::string &) override;
void pack_property_atom(int, double *, int, int) override; void pack_property_atom(int, double *, int, int) override;
private: private:

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
@ -25,10 +24,11 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "atom_vec_spin.h" #include "atom_vec_spin.h"
#include <cmath>
#include <cstring>
#include "atom.h" #include "atom.h"
#include <cmath>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -46,18 +46,18 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "sp fm fm_long"; fields_grow = {"sp", "fm", "fm_long"};
fields_copy = (char *) "sp"; fields_copy = {"sp"};
fields_comm = (char *) "sp"; fields_comm = {"sp"};
fields_comm_vel = (char *) "sp"; fields_comm_vel = {"sp"};
fields_reverse = (char *) "fm fm_long"; fields_reverse = {"fm", "fm_long"};
fields_border = (char *) "sp"; fields_border = {"sp"};
fields_border_vel = (char *) "sp"; fields_border_vel = {"sp"};
fields_exchange = (char *) "sp"; fields_exchange = {"sp"};
fields_restart = (char *) "sp"; fields_restart = {"sp"};
fields_create = (char *) "sp"; fields_create = {"sp"};
fields_data_atom = (char *) "id type x sp"; fields_data_atom = {"id", "type", "x", "sp"};
fields_data_vel = (char *) "id v"; fields_data_vel = {"id", "v"};
setup_fields(); setup_fields();
} }
@ -94,8 +94,7 @@ void AtomVecSpin::force_clear(int n, size_t nbytes)
void AtomVecSpin::data_atom_post(int ilocal) void AtomVecSpin::data_atom_post(int ilocal)
{ {
double *sp_one = sp[ilocal]; double *sp_one = sp[ilocal];
double norm = double norm = 1.0 / sqrt(sp_one[0] * sp_one[0] + sp_one[1] * sp_one[1] + sp_one[2] * sp_one[2]);
1.0/sqrt(sp_one[0]*sp_one[0] + sp_one[1]*sp_one[1] + sp_one[2]*sp_one[2]);
sp_one[0] *= norm; sp_one[0] *= norm;
sp_one[1] *= norm; sp_one[1] *= norm;
sp_one[2] *= norm; sp_one[2] *= norm;

View File

@ -354,3 +354,15 @@ double Angle::memory_usage()
bytes += (double) comm->nthreads * maxcvatom * 9 * sizeof(double); bytes += (double) comm->nthreads * maxcvatom * 9 * sizeof(double);
return bytes; return bytes;
} }
/* -----------------------------------------------------------------------
reset all type-based angle params via init()
-------------------------------------------------------------------------- */
void Angle::reinit()
{
if (!reinitflag)
error->all(FLERR, "Fix adapt interface to this angle style not supported");
init();
}

View File

@ -37,6 +37,9 @@ class Angle : protected Pointers {
// CENTROID_AVAIL = different and implemented // CENTROID_AVAIL = different and implemented
// CENTROID_NOTAVAIL = different, not yet implemented // CENTROID_NOTAVAIL = different, not yet implemented
int reinitflag; // 0 if not compatible with fix adapt
// extract() method may still need to be added
// KOKKOS host/device flag and data masks // KOKKOS host/device flag and data masks
ExecutionSpace execution_space; ExecutionSpace execution_space;
@ -63,6 +66,8 @@ class Angle : protected Pointers {
du2 = 0.0; du2 = 0.0;
} }
virtual double memory_usage(); virtual double memory_usage();
virtual void *extract(const char *, int &) { return nullptr; }
void reinit();
protected: protected:
int suffix_flag; // suffix compatibility flag int suffix_flag; // suffix compatibility flag

View File

@ -47,7 +47,6 @@ using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
#define DELTA 1 #define DELTA 1
#define DELTA_PERATOM 64
#define EPSILON 1.0e-6 #define EPSILON 1.0e-6
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -105,11 +104,6 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
binhead = nullptr; binhead = nullptr;
next = permute = nullptr; next = permute = nullptr;
// data structure with info on per-atom vectors/arrays
nperatom = maxperatom = 0;
peratom = nullptr;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// 1st customization section: customize by adding new per-atom variables // 1st customization section: customize by adding new per-atom variables
@ -303,12 +297,6 @@ Atom::~Atom()
memory->destroy(v); memory->destroy(v);
memory->destroy(f); memory->destroy(f);
// delete peratom data struct
for (int i = 0; i < nperatom; i++)
delete [] peratom[i].name;
memory->sfree(peratom);
// delete custom atom arrays // delete custom atom arrays
for (int i = 0; i < nivector; i++) { for (int i = 0; i < nivector; i++) {
@ -385,12 +373,7 @@ void Atom::settings(Atom *old)
void Atom::peratom_create() void Atom::peratom_create()
{ {
for (int i = 0; i < nperatom; i++) peratom.clear();
delete [] peratom[i].name;
memory->sfree(peratom);
peratom = nullptr;
nperatom = maxperatom = 0;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// 2nd customization section: add peratom variables here, order does not matter // 2nd customization section: add peratom variables here, order does not matter
@ -571,23 +554,11 @@ void Atom::peratom_create()
use add_peratom_vary() when column count varies per atom use add_peratom_vary() when column count varies per atom
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Atom::add_peratom(const char *name, void *address, void Atom::add_peratom(const std::string &name, void *address,
int datatype, int cols, int threadflag) int datatype, int cols, int threadflag)
{ {
if (nperatom == maxperatom) { PerAtom item = {name, address, nullptr, nullptr, datatype, cols, 0, threadflag};
maxperatom += DELTA_PERATOM; peratom.push_back(item);
peratom = (PerAtom *)
memory->srealloc(peratom,maxperatom*sizeof(PerAtom),"atom:peratom");
}
peratom[nperatom].name = utils::strdup(name);
peratom[nperatom].address = address;
peratom[nperatom].datatype = datatype;
peratom[nperatom].cols = cols;
peratom[nperatom].threadflag = threadflag;
peratom[nperatom].address_length = nullptr;
nperatom++;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -596,15 +567,13 @@ void Atom::add_peratom(const char *name, void *address,
see atom_style tdpd as an example see atom_style tdpd as an example
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Atom::add_peratom_change_columns(const char *name, int cols) void Atom::add_peratom_change_columns(const std::string &name, int cols)
{ {
for (int i = 0; i < nperatom; i++) { auto match = std::find_if(peratom.begin(), peratom.end(),
if (strcmp(name,peratom[i].name) == 0) { [&name] (const PerAtom &p) { return p.name == name; });
peratom[i].cols = cols;
return; if (match != peratom.end()) (*match).cols = cols;
} else error->all(FLERR,"Could not find per-atom array name {} for column change", name);
}
error->all(FLERR,"Could not find name of peratom array for column change");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -619,25 +588,11 @@ void Atom::add_peratom_change_columns(const char *name, int cols)
e.g. nspecial e.g. nspecial
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Atom::add_peratom_vary(const char *name, void *address, void Atom::add_peratom_vary(const std::string &name, void *address,
int datatype, int *cols, void *length, int collength) int datatype, int *cols, void *length, int collength)
{ {
if (nperatom == maxperatom) { PerAtom item = {name, address, length, cols, datatype, -1, collength, 0};
maxperatom += DELTA_PERATOM; peratom.push_back(item);
peratom = (PerAtom *)
memory->srealloc(peratom,maxperatom*sizeof(PerAtom),"atom:peratom");
}
peratom[nperatom].name = utils::strdup(name);
peratom[nperatom].address = address;
peratom[nperatom].datatype = datatype;
peratom[nperatom].cols = -1;
peratom[nperatom].threadflag = 0;
peratom[nperatom].address_maxcols = cols;
peratom[nperatom].address_length = length;
peratom[nperatom].collength = collength;
nperatom++;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -2917,4 +2872,3 @@ double Atom::memory_usage()
return bytes; return bytes;
} }

View File

@ -213,7 +213,7 @@ class Atom : protected Pointers {
// per-atom data struct describing all per-atom vectors/arrays // per-atom data struct describing all per-atom vectors/arrays
struct PerAtom { struct PerAtom {
char *name; std::string name;
void *address; void *address;
void *address_length; void *address_length;
int *address_maxcols; int *address_maxcols;
@ -223,8 +223,7 @@ class Atom : protected Pointers {
int threadflag; int threadflag;
}; };
PerAtom *peratom; std::vector<PerAtom> peratom;
int nperatom, maxperatom;
// custom vectors and arrays used by fix property/atom // custom vectors and arrays used by fix property/atom
@ -293,9 +292,9 @@ class Atom : protected Pointers {
void settings(class Atom *); void settings(class Atom *);
void peratom_create(); void peratom_create();
void add_peratom(const char *, void *, int, int, int threadflag = 0); void add_peratom(const std::string &, void *, int, int, int threadflag = 0);
void add_peratom_change_columns(const char *, int); void add_peratom_change_columns(const std::string &, int);
void add_peratom_vary(const char *, void *, int, int *, void *, int collength = 0); void add_peratom_vary(const std::string &, void *, int, int *, void *, int collength = 0);
void create_avec(const std::string &, int, char **, int); void create_avec(const std::string &, int, char **, int);
virtual AtomVec *new_avec(const std::string &, int, int &); virtual AtomVec *new_avec(const std::string &, int, int &);

File diff suppressed because it is too large Load Diff

View File

@ -59,11 +59,10 @@ class AtomVec : protected Pointers {
// additional list of peratom fields operated on by different methods // additional list of peratom fields operated on by different methods
// set or created by child styles // set or created by child styles
char *fields_grow, *fields_copy; std::vector<std::string> fields_grow, fields_copy, fields_comm, fields_comm_vel;
char *fields_comm, *fields_comm_vel, *fields_reverse; std::vector<std::string> fields_reverse, fields_border, fields_border_vel;
char *fields_border, *fields_border_vel; std::vector<std::string> fields_exchange, fields_restart, fields_create;
char *fields_exchange, *fields_restart; std::vector<std::string> fields_data_atom, fields_data_vel;
char *fields_create, *fields_data_atom, *fields_data_vel;
// methods // methods
@ -152,7 +151,7 @@ class AtomVec : protected Pointers {
virtual int pack_data_bonus(double *, int) { return 0; } virtual int pack_data_bonus(double *, int) { return 0; }
virtual void write_data_bonus(FILE *, int, double *, int) {} virtual void write_data_bonus(FILE *, int, double *, int) {}
virtual int property_atom(char *) { return -1; } virtual int property_atom(const std::string &) { return -1; }
virtual void pack_property_atom(int, double *, int, int) {} virtual void pack_property_atom(int, double *, int, int) {}
virtual double memory_usage(); virtual double memory_usage();
@ -187,11 +186,10 @@ class AtomVec : protected Pointers {
// standard list of peratom fields always operated on by different methods // standard list of peratom fields always operated on by different methods
// common to all styles, so not listed in field strings // common to all styles, so not listed in field strings
const char *default_grow, *default_copy; static const std::vector<std::string> default_grow, default_copy, default_comm, default_comm_vel;
const char *default_comm, *default_comm_vel, *default_reverse; static const std::vector<std::string> default_reverse, default_border, default_border_vel;
const char *default_border, *default_border_vel; static const std::vector<std::string> default_exchange, default_restart, default_create;
const char *default_exchange, *default_restart; static const std::vector<std::string> default_data_atom, default_data_vel;
const char *default_create, *default_data_atom, *default_data_vel;
struct Method { struct Method {
std::vector<void *> pdata; std::vector<void *> pdata;
@ -223,7 +221,7 @@ class AtomVec : protected Pointers {
void grow_nmax(); void grow_nmax();
int grow_nmax_bonus(int); int grow_nmax_bonus(int);
void setup_fields(); void setup_fields();
int process_fields(char *, const char *, Method *); int process_fields(const std::vector<std::string> &, const std::vector<std::string> &, Method *);
void init_method(int, Method *); void init_method(int, Method *);
}; };

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -30,18 +29,8 @@ AtomVecAtomic::AtomVecAtomic(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) ""; fields_data_atom = {"id", "type", "x"};
fields_copy = (char *) ""; fields_data_vel = {"id", "v"};
fields_comm = (char *) "";
fields_comm_vel = (char *) "";
fields_reverse = (char *) "";
fields_border = (char *) "";
fields_border_vel = (char *) "";
fields_exchange = (char *) "";
fields_restart = (char *) "";
fields_create = (char *) "";
fields_data_atom = (char *) "id type x";
fields_data_vel = (char *) "id v";
setup_fields(); setup_fields();
} }

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -23,8 +22,6 @@
#include "modify.h" #include "modify.h"
#include "my_pool_chunk.h" #include "my_pool_chunk.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -54,27 +51,29 @@ AtomVecBody::AtomVecBody(LAMMPS *lmp) : AtomVec(lmp)
bptr = nullptr; bptr = nullptr;
if (sizeof(double) == sizeof(int)) intdoubleratio = 1; if (sizeof(double) == sizeof(int))
else if (sizeof(double) == 2*sizeof(int)) intdoubleratio = 2; intdoubleratio = 1;
else error->all(FLERR,"Internal error in atom_style body"); else if (sizeof(double) == 2 * sizeof(int))
intdoubleratio = 2;
else
error->all(FLERR, "Internal error in atom_style body");
// strings with peratom variables to include in each AtomVec method // strings with peratom variables to include in each AtomVec method
// strings cannot contain fields in corresponding AtomVec default strings // strings cannot contain fields in corresponding AtomVec default strings
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "radius rmass angmom torque body"; fields_grow = {"radius", "rmass", "angmom", "torque", "body"};
fields_copy = (char *) "radius rmass angmom"; fields_copy = {"radius", "rmass", "angmom"};
fields_comm = (char *) ""; fields_comm_vel = {"angmom"};
fields_comm_vel = (char *) "angmom"; fields_reverse = {"torque"};
fields_reverse = (char *) "torque"; fields_border = {"radius", "rmass"};
fields_border = (char *) "radius rmass"; fields_border_vel = {"radius", "rmass", "angmom"};
fields_border_vel = (char *) "radius rmass angmom"; fields_exchange = {"radius", "rmass", "angmom"};
fields_exchange = (char *) "radius rmass angmom"; fields_restart = {"radius", "rmass", "angmom"};
fields_restart = (char *) "radius rmass angmom"; fields_create = {"radius", "rmass", "angmom", "body"};
fields_create = (char *) "radius rmass angmom body"; fields_data_atom = {"id", "type", "body", "rmass", "x"};
fields_data_atom = (char *) "id type body rmass x"; fields_data_vel = {"id", "v", "angmom"};
fields_data_vel = (char *) "id v angmom";
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -110,14 +109,16 @@ void AtomVecBody::process_args(int narg, char **arg)
#define BODY_CLASS #define BODY_CLASS
#define BodyStyle(key, Class) \ #define BodyStyle(key, Class) \
} else if (strcmp(arg[0],#key) == 0) { \ } \
else if (strcmp(arg[0], #key) == 0) \
{ \
bptr = new Class(lmp, narg, arg); bptr = new Class(lmp, narg, arg);
#include "style_body.h" // IWYU pragma: keep #include "style_body.h" // IWYU pragma: keep
#undef BodyStyle #undef BodyStyle
#undef BODY_CLASS #undef BODY_CLASS
} else error->all(FLERR,utils:: } else
check_packages_for_style("body",arg[0],lmp).c_str()); error->all(FLERR, utils::check_packages_for_style("body", arg[0], lmp).c_str());
bptr->avec = this; bptr->avec = this;
icp = bptr->icp; icp = bptr->icp;
@ -153,11 +154,9 @@ void AtomVecBody::grow_pointers()
void AtomVecBody::grow_bonus() void AtomVecBody::grow_bonus()
{ {
nmax_bonus = grow_nmax_bonus(nmax_bonus); nmax_bonus = grow_nmax_bonus(nmax_bonus);
if (nmax_bonus < 0) if (nmax_bonus < 0) error->one(FLERR, "Per-processor system is too big");
error->one(FLERR,"Per-processor system is too big");
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus), bonus = (Bonus *) memory->srealloc(bonus, nmax_bonus * sizeof(Bonus), "atom:bonus");
"atom:bonus");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -268,7 +267,8 @@ int AtomVecBody::pack_border_bonus(int n, int *list, double *buf)
m = 0; m = 0;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
j = list[i]; j = list[i];
if (body[j] < 0) buf[m++] = ubuf(0).d; if (body[j] < 0)
buf[m++] = ubuf(0).d;
else { else {
buf[m++] = ubuf(1).d; buf[m++] = ubuf(1).d;
quat = bonus[body[j]].quat; quat = bonus[body[j]].quat;
@ -300,7 +300,8 @@ int AtomVecBody::unpack_border_bonus(int n, int first, double *buf)
last = first + n; last = first + n;
for (i = first; i < last; i++) { for (i = first; i < last; i++) {
body[i] = (int) ubuf(buf[m++]).i; body[i] = (int) ubuf(buf[m++]).i;
if (body[i] == 0) body[i] = -1; if (body[i] == 0)
body[i] = -1;
else { else {
j = nlocal_bonus + nghost_bonus; j = nlocal_bonus + nghost_bonus;
if (j == nmax_bonus) grow_bonus(); if (j == nmax_bonus) grow_bonus();
@ -337,7 +338,8 @@ int AtomVecBody::pack_exchange_bonus(int i, double *buf)
{ {
int m = 0; int m = 0;
if (body[i] < 0) buf[m++] = ubuf(0).d; if (body[i] < 0)
buf[m++] = ubuf(0).d;
else { else {
buf[m++] = ubuf(1).d; buf[m++] = ubuf(1).d;
int j = body[i]; int j = body[i];
@ -353,8 +355,10 @@ int AtomVecBody::pack_exchange_bonus(int i, double *buf)
buf[m++] = ubuf(bonus[j].ninteger).d; buf[m++] = ubuf(bonus[j].ninteger).d;
buf[m++] = ubuf(bonus[j].ndouble).d; buf[m++] = ubuf(bonus[j].ndouble).d;
memcpy(&buf[m], bonus[j].ivalue, bonus[j].ninteger * sizeof(int)); memcpy(&buf[m], bonus[j].ivalue, bonus[j].ninteger * sizeof(int));
if (intdoubleratio == 1) m += bonus[j].ninteger; if (intdoubleratio == 1)
else m += (bonus[j].ninteger+1)/2; m += bonus[j].ninteger;
else
m += (bonus[j].ninteger + 1) / 2;
memcpy(&buf[m], bonus[j].dvalue, bonus[j].ndouble * sizeof(double)); memcpy(&buf[m], bonus[j].dvalue, bonus[j].ndouble * sizeof(double));
m += bonus[j].ndouble; m += bonus[j].ndouble;
} }
@ -369,7 +373,8 @@ int AtomVecBody::unpack_exchange_bonus(int ilocal, double *buf)
int m = 0; int m = 0;
body[ilocal] = (int) ubuf(buf[m++]).i; body[ilocal] = (int) ubuf(buf[m++]).i;
if (body[ilocal] == 0) body[ilocal] = -1; if (body[ilocal] == 0)
body[ilocal] = -1;
else { else {
if (nlocal_bonus == nmax_bonus) grow_bonus(); if (nlocal_bonus == nmax_bonus) grow_bonus();
double *quat = bonus[nlocal_bonus].quat; double *quat = bonus[nlocal_bonus].quat;
@ -384,16 +389,14 @@ int AtomVecBody::unpack_exchange_bonus(int ilocal, double *buf)
bonus[nlocal_bonus].ninteger = (int) ubuf(buf[m++]).i; bonus[nlocal_bonus].ninteger = (int) ubuf(buf[m++]).i;
bonus[nlocal_bonus].ndouble = (int) ubuf(buf[m++]).i; bonus[nlocal_bonus].ndouble = (int) ubuf(buf[m++]).i;
// corresponding put() calls are in copy() // corresponding put() calls are in copy()
bonus[nlocal_bonus].ivalue = icp->get(bonus[nlocal_bonus].ninteger, bonus[nlocal_bonus].ivalue = icp->get(bonus[nlocal_bonus].ninteger, bonus[nlocal_bonus].iindex);
bonus[nlocal_bonus].iindex); bonus[nlocal_bonus].dvalue = dcp->get(bonus[nlocal_bonus].ndouble, bonus[nlocal_bonus].dindex);
bonus[nlocal_bonus].dvalue = dcp->get(bonus[nlocal_bonus].ndouble, memcpy(bonus[nlocal_bonus].ivalue, &buf[m], bonus[nlocal_bonus].ninteger * sizeof(int));
bonus[nlocal_bonus].dindex); if (intdoubleratio == 1)
memcpy(bonus[nlocal_bonus].ivalue,&buf[m], m += bonus[nlocal_bonus].ninteger;
bonus[nlocal_bonus].ninteger*sizeof(int)); else
if (intdoubleratio == 1) m += bonus[nlocal_bonus].ninteger; m += (bonus[nlocal_bonus].ninteger + 1) / 2;
else m += (bonus[nlocal_bonus].ninteger+1)/2; memcpy(bonus[nlocal_bonus].dvalue, &buf[m], bonus[nlocal_bonus].ndouble * sizeof(double));
memcpy(bonus[nlocal_bonus].dvalue,&buf[m],
bonus[nlocal_bonus].ndouble*sizeof(double));
m += bonus[nlocal_bonus].ndouble; m += bonus[nlocal_bonus].ndouble;
bonus[nlocal_bonus].ilocal = ilocal; bonus[nlocal_bonus].ilocal = ilocal;
@ -416,10 +419,13 @@ int AtomVecBody::size_restart_bonus()
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (body[i] >= 0) { if (body[i] >= 0) {
n += size_restart_bonus_one; n += size_restart_bonus_one;
if (intdoubleratio == 1) n += bonus[body[i]].ninteger; if (intdoubleratio == 1)
else n += (bonus[body[i]].ninteger+1)/2; n += bonus[body[i]].ninteger;
else
n += (bonus[body[i]].ninteger + 1) / 2;
n += bonus[body[i]].ndouble; n += bonus[body[i]].ndouble;
} else n++; } else
n++;
} }
return n; return n;
@ -435,7 +441,8 @@ int AtomVecBody::pack_restart_bonus(int i, double *buf)
{ {
int m = 0; int m = 0;
if (body[i] < 0) buf[m++] = ubuf(0).d; if (body[i] < 0)
buf[m++] = ubuf(0).d;
else { else {
buf[m++] = ubuf(1).d; buf[m++] = ubuf(1).d;
int j = body[i]; int j = body[i];
@ -451,8 +458,10 @@ int AtomVecBody::pack_restart_bonus(int i, double *buf)
buf[m++] = ubuf(bonus[j].ninteger).d; buf[m++] = ubuf(bonus[j].ninteger).d;
buf[m++] = ubuf(bonus[j].ndouble).d; buf[m++] = ubuf(bonus[j].ndouble).d;
memcpy(&buf[m], bonus[j].ivalue, bonus[j].ninteger * sizeof(int)); memcpy(&buf[m], bonus[j].ivalue, bonus[j].ninteger * sizeof(int));
if (intdoubleratio == 1) m += bonus[j].ninteger; if (intdoubleratio == 1)
else m += (bonus[j].ninteger+1)/2; m += bonus[j].ninteger;
else
m += (bonus[j].ninteger + 1) / 2;
memcpy(&buf[m], bonus[j].dvalue, bonus[j].ndouble * sizeof(double)); memcpy(&buf[m], bonus[j].dvalue, bonus[j].ndouble * sizeof(double));
m += bonus[j].ndouble; m += bonus[j].ndouble;
} }
@ -469,7 +478,8 @@ int AtomVecBody::unpack_restart_bonus(int ilocal, double *buf)
int m = 0; int m = 0;
body[ilocal] = (int) ubuf(buf[m++]).i; body[ilocal] = (int) ubuf(buf[m++]).i;
if (body[ilocal] == 0) body[ilocal] = -1; if (body[ilocal] == 0)
body[ilocal] = -1;
else { else {
if (nlocal_bonus == nmax_bonus) grow_bonus(); if (nlocal_bonus == nmax_bonus) grow_bonus();
double *quat = bonus[nlocal_bonus].quat; double *quat = bonus[nlocal_bonus].quat;
@ -483,16 +493,14 @@ int AtomVecBody::unpack_restart_bonus(int ilocal, double *buf)
inertia[2] = buf[m++]; inertia[2] = buf[m++];
bonus[nlocal_bonus].ninteger = (int) ubuf(buf[m++]).i; bonus[nlocal_bonus].ninteger = (int) ubuf(buf[m++]).i;
bonus[nlocal_bonus].ndouble = (int) ubuf(buf[m++]).i; bonus[nlocal_bonus].ndouble = (int) ubuf(buf[m++]).i;
bonus[nlocal_bonus].ivalue = icp->get(bonus[nlocal_bonus].ninteger, bonus[nlocal_bonus].ivalue = icp->get(bonus[nlocal_bonus].ninteger, bonus[nlocal_bonus].iindex);
bonus[nlocal_bonus].iindex); bonus[nlocal_bonus].dvalue = dcp->get(bonus[nlocal_bonus].ndouble, bonus[nlocal_bonus].dindex);
bonus[nlocal_bonus].dvalue = dcp->get(bonus[nlocal_bonus].ndouble, memcpy(bonus[nlocal_bonus].ivalue, &buf[m], bonus[nlocal_bonus].ninteger * sizeof(int));
bonus[nlocal_bonus].dindex); if (intdoubleratio == 1)
memcpy(bonus[nlocal_bonus].ivalue,&buf[m], m += bonus[nlocal_bonus].ninteger;
bonus[nlocal_bonus].ninteger*sizeof(int)); else
if (intdoubleratio == 1) m += bonus[nlocal_bonus].ninteger; m += (bonus[nlocal_bonus].ninteger + 1) / 2;
else m += (bonus[nlocal_bonus].ninteger+1)/2; memcpy(bonus[nlocal_bonus].dvalue, &buf[m], bonus[nlocal_bonus].ndouble * sizeof(double));
memcpy(bonus[nlocal_bonus].dvalue,&buf[m],
bonus[nlocal_bonus].ndouble*sizeof(double));
m += bonus[nlocal_bonus].ndouble; m += bonus[nlocal_bonus].ndouble;
bonus[nlocal_bonus].ilocal = ilocal; bonus[nlocal_bonus].ilocal = ilocal;
body[ilocal] = nlocal_bonus++; body[ilocal] = nlocal_bonus++;
@ -521,13 +529,15 @@ void AtomVecBody::create_atom_post(int ilocal)
void AtomVecBody::data_atom_post(int ilocal) void AtomVecBody::data_atom_post(int ilocal)
{ {
body_flag = body[ilocal]; body_flag = body[ilocal];
if (body_flag == 0) body_flag = -1; if (body_flag == 0)
else if (body_flag == 1) body_flag = 0; body_flag = -1;
else error->one(FLERR,"Invalid body flag in Atoms section of data file"); else if (body_flag == 1)
body_flag = 0;
else
error->one(FLERR, "Invalid body flag in Atoms section of data file");
body[ilocal] = body_flag; body[ilocal] = body_flag;
if (rmass[ilocal] <= 0.0) if (rmass[ilocal] <= 0.0) error->one(FLERR, "Invalid density in Atoms section of data file");
error->one(FLERR,"Invalid density in Atoms section of data file");
radius[ilocal] = 0.5; radius[ilocal] = 0.5;
angmom[ilocal][0] = 0.0; angmom[ilocal][0] = 0.0;
@ -539,11 +549,9 @@ void AtomVecBody::data_atom_post(int ilocal)
unpack one body from Bodies section of data file unpack one body from Bodies section of data file
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecBody::data_body(int m, int ninteger, int ndouble, void AtomVecBody::data_body(int m, int ninteger, int ndouble, int *ivalues, double *dvalues)
int *ivalues, double *dvalues)
{ {
if (body[m]) if (body[m]) error->one(FLERR, "Assigning body parameters to non-body atom");
error->one(FLERR,"Assigning body parameters to non-body atom");
if (nlocal_bonus == nmax_bonus) grow_bonus(); if (nlocal_bonus == nmax_bonus) grow_bonus();
bonus[nlocal_bonus].ilocal = m; bonus[nlocal_bonus].ilocal = m;
bptr->data_body(nlocal_bonus, ninteger, ndouble, ivalues, dvalues); bptr->data_body(nlocal_bonus, ninteger, ndouble, ivalues, dvalues);
@ -579,8 +587,10 @@ void AtomVecBody::pack_data_pre(int ilocal)
{ {
body_flag = body[ilocal]; body_flag = body[ilocal];
if (body_flag < 0) body[ilocal] = 0; if (body_flag < 0)
else body[ilocal] = 1; body[ilocal] = 0;
else
body[ilocal] = 1;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -613,9 +623,7 @@ int AtomVecBody::pack_data_bonus(double *buf, int /*flag*/)
void AtomVecBody::write_data_bonus(FILE *fp, int n, double *buf, int /*flag*/) void AtomVecBody::write_data_bonus(FILE *fp, int n, double *buf, int /*flag*/)
{ {
int i = 0; int i = 0;
while (i < n) { while (i < n) { i += bptr->write_data_body(fp, &buf[i]); }
i += bptr->write_data_body(fp,&buf[i]);
}
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -631,8 +639,7 @@ void AtomVecBody::pack_data_post(int ilocal)
body computes its size based on ivalues/dvalues and returns it body computes its size based on ivalues/dvalues and returns it
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double AtomVecBody::radius_body(int ninteger, int ndouble, double AtomVecBody::radius_body(int ninteger, int ndouble, int *ivalues, double *dvalues)
int *ivalues, double *dvalues)
{ {
return bptr->radius_body(ninteger, ndouble, ivalues, dvalues); return bptr->radius_body(ninteger, ndouble, ivalues, dvalues);
} }
@ -646,8 +653,10 @@ void AtomVecBody::set_quat(int m, double *quat_external)
{ {
if (body[m] < 0) error->one(FLERR, "Assigning quat to non-body atom"); if (body[m] < 0) error->one(FLERR, "Assigning quat to non-body atom");
double *quat = bonus[body[m]].quat; double *quat = bonus[body[m]].quat;
quat[0] = quat_external[0]; quat[1] = quat_external[1]; quat[0] = quat_external[0];
quat[2] = quat_external[2]; quat[3] = quat_external[3]; quat[1] = quat_external[1];
quat[2] = quat_external[2];
quat[3] = quat_external[3];
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -31,18 +30,15 @@ AtomVecCharge::AtomVecCharge(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "q"; fields_grow = {"q"};
fields_copy = (char *) "q"; fields_copy = {"q"};
fields_comm = (char *) ""; fields_border = {"q"};
fields_comm_vel = (char *) ""; fields_border_vel = {"q"};
fields_reverse = (char *) ""; fields_exchange = {"q"};
fields_border = (char *) "q"; fields_restart = {"q"};
fields_border_vel = (char *) "q"; fields_create = {"q"};
fields_exchange = (char *) "q"; fields_data_atom = {"id", "type", "q", "x"};
fields_restart = (char *) "q"; fields_data_vel = {"id", "v"};
fields_create = (char *) "q";
fields_data_atom = (char *) "id type q x";
fields_data_vel = (char *) "id v";
setup_fields(); setup_fields();
} }

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -26,10 +25,8 @@
#include "memory.h" #include "memory.h"
#include "modify.h" #include "modify.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using MathConst::MY_PI;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -54,18 +51,17 @@ AtomVecEllipsoid::AtomVecEllipsoid(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "rmass angmom torque ellipsoid"; fields_grow = {"rmass", "angmom", "torque", "ellipsoid"};
fields_copy = (char *) "rmass angmom"; fields_copy = {"rmass", "angmom"};
fields_comm = (char *) ""; fields_comm_vel = {"angmom"};
fields_comm_vel = (char *) "angmom"; fields_reverse = {"torque"};
fields_reverse = (char *) "torque"; fields_border = {"rmass"};
fields_border = (char *) "rmass"; fields_border_vel = {"rmass", "angmom"};
fields_border_vel = (char *) "rmass angmom"; fields_exchange = {"rmass", "angmom"};
fields_exchange = (char *) "rmass angmom"; fields_restart = {"rmass", "angmom"};
fields_restart = (char *) "rmass angmom"; fields_create = {"rmass", "angmom", "ellipsoid"};
fields_create = (char *) "rmass angmom ellipsoid"; fields_data_atom = {"id", "type", "ellipsoid", "rmass", "x"};
fields_data_atom = (char *) "id type ellipsoid rmass x"; fields_data_vel = {"id", "v", "angmom"};
fields_data_vel = (char *) "id v angmom";
setup_fields(); setup_fields();
} }
@ -96,11 +92,9 @@ void AtomVecEllipsoid::grow_pointers()
void AtomVecEllipsoid::grow_bonus() void AtomVecEllipsoid::grow_bonus()
{ {
nmax_bonus = grow_nmax_bonus(nmax_bonus); nmax_bonus = grow_nmax_bonus(nmax_bonus);
if (nmax_bonus < 0) if (nmax_bonus < 0) error->one(FLERR, "Per-processor system is too big");
error->one(FLERR,"Per-processor system is too big");
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus), bonus = (Bonus *) memory->srealloc(bonus, nmax_bonus * sizeof(Bonus), "atom:bonus");
"atom:bonus");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -200,7 +194,8 @@ int AtomVecEllipsoid::pack_border_bonus(int n, int *list, double *buf)
m = 0; m = 0;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
j = list[i]; j = list[i];
if (ellipsoid[j] < 0) buf[m++] = ubuf(0).d; if (ellipsoid[j] < 0)
buf[m++] = ubuf(0).d;
else { else {
buf[m++] = ubuf(1).d; buf[m++] = ubuf(1).d;
shape = bonus[ellipsoid[j]].shape; shape = bonus[ellipsoid[j]].shape;
@ -229,7 +224,8 @@ int AtomVecEllipsoid::unpack_border_bonus(int n, int first, double *buf)
last = first + n; last = first + n;
for (i = first; i < last; i++) { for (i = first; i < last; i++) {
ellipsoid[i] = (int) ubuf(buf[m++]).i; ellipsoid[i] = (int) ubuf(buf[m++]).i;
if (ellipsoid[i] == 0) ellipsoid[i] = -1; if (ellipsoid[i] == 0)
ellipsoid[i] = -1;
else { else {
j = nlocal_bonus + nghost_bonus; j = nlocal_bonus + nghost_bonus;
if (j == nmax_bonus) grow_bonus(); if (j == nmax_bonus) grow_bonus();
@ -260,7 +256,8 @@ int AtomVecEllipsoid::pack_exchange_bonus(int i, double *buf)
{ {
int m = 0; int m = 0;
if (ellipsoid[i] < 0) buf[m++] = ubuf(0).d; if (ellipsoid[i] < 0)
buf[m++] = ubuf(0).d;
else { else {
buf[m++] = ubuf(1).d; buf[m++] = ubuf(1).d;
int j = ellipsoid[i]; int j = ellipsoid[i];
@ -285,7 +282,8 @@ int AtomVecEllipsoid::unpack_exchange_bonus(int ilocal, double *buf)
int m = 0; int m = 0;
ellipsoid[ilocal] = (int) ubuf(buf[m++]).i; ellipsoid[ilocal] = (int) ubuf(buf[m++]).i;
if (ellipsoid[ilocal] == 0) ellipsoid[ilocal] = -1; if (ellipsoid[ilocal] == 0)
ellipsoid[ilocal] = -1;
else { else {
if (nlocal_bonus == nmax_bonus) grow_bonus(); if (nlocal_bonus == nmax_bonus) grow_bonus();
double *shape = bonus[nlocal_bonus].shape; double *shape = bonus[nlocal_bonus].shape;
@ -316,8 +314,10 @@ int AtomVecEllipsoid::size_restart_bonus()
int n = 0; int n = 0;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (ellipsoid[i] >= 0) n += size_restart_bonus_one; if (ellipsoid[i] >= 0)
else n++; n += size_restart_bonus_one;
else
n++;
} }
return n; return n;
@ -333,7 +333,8 @@ int AtomVecEllipsoid::pack_restart_bonus(int i, double *buf)
{ {
int m = 0; int m = 0;
if (ellipsoid[i] < 0) buf[m++] = ubuf(0).d; if (ellipsoid[i] < 0)
buf[m++] = ubuf(0).d;
else { else {
buf[m++] = ubuf(1).d; buf[m++] = ubuf(1).d;
int j = ellipsoid[i]; int j = ellipsoid[i];
@ -358,7 +359,8 @@ int AtomVecEllipsoid::unpack_restart_bonus(int ilocal, double *buf)
int m = 0; int m = 0;
ellipsoid[ilocal] = (int) ubuf(buf[m++]).i; ellipsoid[ilocal] = (int) ubuf(buf[m++]).i;
if (ellipsoid[ilocal] == 0) ellipsoid[ilocal] = -1; if (ellipsoid[ilocal] == 0)
ellipsoid[ilocal] = -1;
else { else {
if (nlocal_bonus == nmax_bonus) grow_bonus(); if (nlocal_bonus == nmax_bonus) grow_bonus();
double *shape = bonus[nlocal_bonus].shape; double *shape = bonus[nlocal_bonus].shape;
@ -383,8 +385,7 @@ int AtomVecEllipsoid::unpack_restart_bonus(int ilocal, double *buf)
void AtomVecEllipsoid::data_atom_bonus(int m, const std::vector<std::string> &values) void AtomVecEllipsoid::data_atom_bonus(int m, const std::vector<std::string> &values)
{ {
if (ellipsoid[m]) if (ellipsoid[m]) error->one(FLERR, "Assigning ellipsoid parameters to non-ellipsoid atom");
error->one(FLERR,"Assigning ellipsoid parameters to non-ellipsoid atom");
if (nlocal_bonus == nmax_bonus) grow_bonus(); if (nlocal_bonus == nmax_bonus) grow_bonus();
@ -441,13 +442,15 @@ void AtomVecEllipsoid::create_atom_post(int ilocal)
void AtomVecEllipsoid::data_atom_post(int ilocal) void AtomVecEllipsoid::data_atom_post(int ilocal)
{ {
ellipsoid_flag = ellipsoid[ilocal]; ellipsoid_flag = ellipsoid[ilocal];
if (ellipsoid_flag == 0) ellipsoid_flag = -1; if (ellipsoid_flag == 0)
else if (ellipsoid_flag == 1) ellipsoid_flag = 0; ellipsoid_flag = -1;
else error->one(FLERR,"Invalid ellipsoid flag in Atoms section of data file"); else if (ellipsoid_flag == 1)
ellipsoid_flag = 0;
else
error->one(FLERR, "Invalid ellipsoid flag in Atoms section of data file");
ellipsoid[ilocal] = ellipsoid_flag; ellipsoid[ilocal] = ellipsoid_flag;
if (rmass[ilocal] <= 0.0) if (rmass[ilocal] <= 0.0) error->one(FLERR, "Invalid density in Atoms section of data file");
error->one(FLERR,"Invalid density in Atoms section of data file");
angmom[ilocal][0] = 0.0; angmom[ilocal][0] = 0.0;
angmom[ilocal][1] = 0.0; angmom[ilocal][1] = 0.0;
@ -465,8 +468,10 @@ void AtomVecEllipsoid::pack_data_pre(int ilocal)
ellipsoid_flag = atom->ellipsoid[ilocal]; ellipsoid_flag = atom->ellipsoid[ilocal];
rmass_one = atom->rmass[ilocal]; rmass_one = atom->rmass[ilocal];
if (ellipsoid_flag < 0) ellipsoid[ilocal] = 0; if (ellipsoid_flag < 0)
else ellipsoid[ilocal] = 1; ellipsoid[ilocal] = 0;
else
ellipsoid[ilocal] = 1;
if (ellipsoid_flag >= 0) { if (ellipsoid_flag >= 0) {
shape = bonus[ellipsoid_flag].shape; shape = bonus[ellipsoid_flag].shape;
@ -509,7 +514,8 @@ int AtomVecEllipsoid::pack_data_bonus(double *buf, int /*flag*/)
buf[m++] = bonus[j].quat[1]; buf[m++] = bonus[j].quat[1];
buf[m++] = bonus[j].quat[2]; buf[m++] = bonus[j].quat[2];
buf[m++] = bonus[j].quat[3]; buf[m++] = bonus[j].quat[3];
} else m += size_data_bonus; } else
m += size_data_bonus;
} }
return m; return m;
@ -523,8 +529,8 @@ void AtomVecEllipsoid::write_data_bonus(FILE *fp, int n, double *buf, int /*flag
{ {
int i = 0; int i = 0;
while (i < n) { while (i < n) {
fmt::print(fp,"{} {} {} {} {} {} {} {}\n",ubuf(buf[i]).i, fmt::print(fp, "{} {} {} {} {} {} {} {}\n", ubuf(buf[i]).i, buf[i + 1], buf[i + 2], buf[i + 3],
buf[i+1],buf[i+2],buf[i+3],buf[i+4],buf[i+5],buf[i+6],buf[i+7]); buf[i + 4], buf[i + 5], buf[i + 6], buf[i + 7]);
i += size_data_bonus; i += size_data_bonus;
} }
} }

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -19,11 +18,11 @@
#include "error.h" #include "error.h"
#include "tokenizer.h" #include "tokenizer.h"
#include <algorithm>
#include <cstring> #include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define NFIELDSTRINGS 12 // # of field strings
enum { ELLIPSOID, LINE, TRIANGLE, BODY }; // also in WriteData enum { ELLIPSOID, LINE, TRIANGLE, BODY }; // also in WriteData
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -33,22 +32,16 @@ AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp)
nstyles = 0; nstyles = 0;
styles = nullptr; styles = nullptr;
keywords = nullptr; keywords = nullptr;
fieldstrings = nullptr;
bonus_flag = 0; bonus_flag = 0;
nstyles_bonus = 0; nstyles_bonus = 0;
styles_bonus = nullptr; styles_bonus = nullptr;
// these strings will be concatenated from sub-style strings // field strings will be concatenated from sub-style strings
// fields_data_atom & fields_data_vel start with fields common to all styles // fields_data_atom & fields_data_vel start with fields common to all styles
fields_grow = fields_copy = fields_comm = fields_comm_vel = (char *) ""; fields_data_atom = {"id", "type", "x"};
fields_reverse = fields_border = fields_border_vel = (char *) ""; fields_data_vel = {"id", "v"};
fields_exchange = fields_restart = fields_create = (char *) "";
fields_data_atom = (char *) "id type x";
fields_data_vel = (char *) "id v";
fields_allocated = 0;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -60,24 +53,6 @@ AtomVecHybrid::~AtomVecHybrid()
for (int k = 0; k < nstyles; k++) delete[] keywords[k]; for (int k = 0; k < nstyles; k++) delete[] keywords[k];
delete[] keywords; delete[] keywords;
delete[] styles_bonus; delete[] styles_bonus;
if (!fields_allocated) return;
delete [] fields_grow;
delete [] fields_copy;
delete [] fields_comm;
delete [] fields_comm_vel;
delete [] fields_reverse;
delete [] fields_border;
delete [] fields_border_vel;
delete [] fields_exchange;
delete [] fields_restart;
delete [] fields_create;
delete [] fields_data_atom;
delete [] fields_data_vel;
for (int k = 0; k < nstyles; k++) delete [] fieldstrings[k].fstr;
delete [] fieldstrings;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -99,19 +74,18 @@ void AtomVecHybrid::process_args(int narg, char **arg)
// call process_args() with set of args that are not atom style names // call process_args() with set of args that are not atom style names
// use known_style() to determine which args these are // use known_style() to determine which args these are
int i,k,jarg,dummy; int dummy;
int iarg = 0; int iarg = 0;
nstyles = 0; nstyles = 0;
while (iarg < narg) { while (iarg < narg) {
if (strcmp(arg[iarg], "hybrid") == 0) if (strcmp(arg[iarg], "hybrid") == 0)
error->all(FLERR, "Atom style hybrid cannot have hybrid as an argument"); error->all(FLERR, "Atom style hybrid cannot have hybrid as an argument");
for (i = 0; i < nstyles; i++) for (int i = 0; i < nstyles; i++)
if (strcmp(arg[iarg], keywords[i]) == 0) if (strcmp(arg[iarg], keywords[i]) == 0)
error->all(FLERR, "Atom style hybrid cannot use same atom style twice"); error->all(FLERR, "Atom style hybrid cannot use same atom style twice");
styles[nstyles] = atom->new_avec(arg[iarg], 1, dummy); styles[nstyles] = atom->new_avec(arg[iarg], 1, dummy);
keywords[nstyles] = utils::strdup(arg[iarg]); keywords[nstyles] = utils::strdup(arg[iarg]);
jarg = iarg + 1; int jarg = iarg + 1;
while (jarg < narg && !known_style(arg[jarg])) jarg++; while (jarg < narg && !known_style(arg[jarg])) jarg++;
styles[nstyles]->process_args(jarg - iarg - 1, &arg[iarg + 1]); styles[nstyles]->process_args(jarg - iarg - 1, &arg[iarg + 1]);
iarg = jarg; iarg = jarg;
@ -124,11 +98,10 @@ void AtomVecHybrid::process_args(int narg, char **arg)
molecular = Atom::ATOMIC; molecular = Atom::ATOMIC;
maxexchange = 0; maxexchange = 0;
for (k = 0; k < nstyles; k++) { for (int k = 0; k < nstyles; k++) {
if ((styles[k]->molecular == Atom::MOLECULAR && molecular == Atom::TEMPLATE) || if ((styles[k]->molecular == Atom::MOLECULAR && molecular == Atom::TEMPLATE) ||
(styles[k]->molecular == Atom::TEMPLATE && molecular == Atom::MOLECULAR)) (styles[k]->molecular == Atom::TEMPLATE && molecular == Atom::MOLECULAR))
error->all(FLERR, error->all(FLERR, "Cannot mix molecular and molecule template atom styles");
"Cannot mix molecular and molecule template atom styles");
molecular = MAX(molecular, styles[k]->molecular); molecular = MAX(molecular, styles[k]->molecular);
bonds_allow = MAX(bonds_allow, styles[k]->bonds_allow); bonds_allow = MAX(bonds_allow, styles[k]->bonds_allow);
@ -148,86 +121,62 @@ void AtomVecHybrid::process_args(int narg, char **arg)
int mass_pertype = 0; int mass_pertype = 0;
int mass_peratom = 0; int mass_peratom = 0;
for (k = 0; k < nstyles; k++) { for (int k = 0; k < nstyles; k++) {
if (styles[k]->mass_type == 0) mass_peratom = 1; if (styles[k]->mass_type == 0) mass_peratom = 1;
if (styles[k]->mass_type == 1) mass_pertype = 1; if (styles[k]->mass_type == 1) mass_pertype = 1;
} }
if (mass_pertype && mass_peratom && comm->me == 0) if (mass_pertype && mass_peratom && comm->me == 0)
error->warning(FLERR, "Atom style hybrid defines both, per-type " error->warning(FLERR,
"Atom style hybrid defines both, per-type "
"and per-atom masses; both must be set, but only " "and per-atom masses; both must be set, but only "
"per-atom masses will be used"); "per-atom masses will be used");
// free allstyles created by build_styles() // free allstyles created by build_styles()
for (i = 0; i < nallstyles; i++) delete [] allstyles[i]; for (int i = 0; i < nallstyles; i++) delete[] allstyles[i];
delete[] allstyles; delete[] allstyles;
// set field strings from all substyles
fieldstrings = new FieldStrings[nstyles];
for (k = 0; k < nstyles; k++) {
fieldstrings[k].fstr = new char*[NFIELDSTRINGS];
fieldstrings[k].fstr[0] = styles[k]->fields_grow;
fieldstrings[k].fstr[1] = styles[k]->fields_copy;
fieldstrings[k].fstr[2] = styles[k]->fields_comm;
fieldstrings[k].fstr[3] = styles[k]->fields_comm_vel;
fieldstrings[k].fstr[4] = styles[k]->fields_reverse;
fieldstrings[k].fstr[5] = styles[k]->fields_border;
fieldstrings[k].fstr[6] = styles[k]->fields_border_vel;
fieldstrings[k].fstr[7] = styles[k]->fields_exchange;
fieldstrings[k].fstr[8] = styles[k]->fields_restart;
fieldstrings[k].fstr[9] = styles[k]->fields_create;
fieldstrings[k].fstr[10] = styles[k]->fields_data_atom;
fieldstrings[k].fstr[11] = styles[k]->fields_data_vel;
}
// merge field strings from all sub-styles // merge field strings from all sub-styles
// save concat_grow to check for duplicates of special-case fields // save concat_grow to check for duplicates of special-case fields
char *concat_grow;; std::vector<std::string> concat_grow;
char *dummyptr = nullptr; std::vector<std::string> concat_dummy;
fields_grow = merge_fields(0,fields_grow,1,concat_grow); for (int k = 0; k < nstyles; k++) {
fields_copy = merge_fields(1,fields_copy,0,dummyptr); merge_fields(fields_grow, styles[k]->fields_grow, 1, concat_grow);
fields_comm = merge_fields(2,fields_comm,0,dummyptr); merge_fields(fields_copy, styles[k]->fields_copy, 0, concat_dummy);
fields_comm_vel = merge_fields(3,fields_comm_vel,0,dummyptr); merge_fields(fields_comm, styles[k]->fields_comm, 0, concat_dummy);
fields_reverse = merge_fields(4,fields_reverse,0,dummyptr); merge_fields(fields_comm_vel, styles[k]->fields_comm_vel, 0, concat_dummy);
fields_border = merge_fields(5,fields_border,0,dummyptr); merge_fields(fields_reverse, styles[k]->fields_reverse, 0, concat_dummy);
fields_border_vel = merge_fields(6,fields_border_vel,0,dummyptr); merge_fields(fields_border, styles[k]->fields_border, 0, concat_dummy);
fields_exchange = merge_fields(7,fields_exchange,0,dummyptr); merge_fields(fields_border_vel, styles[k]->fields_border_vel, 0, concat_dummy);
fields_restart = merge_fields(8,fields_restart,0,dummyptr); merge_fields(fields_exchange, styles[k]->fields_exchange, 0, concat_dummy);
fields_create = merge_fields(9,fields_create,0,dummyptr); merge_fields(fields_restart, styles[k]->fields_restart, 0, concat_dummy);
fields_data_atom = merge_fields(10,fields_data_atom,0,dummyptr); merge_fields(fields_create, styles[k]->fields_create, 0, concat_dummy);
fields_data_vel = merge_fields(11,fields_data_vel,0,dummyptr); merge_fields(fields_data_atom, styles[k]->fields_data_atom, 0, concat_dummy);
merge_fields(fields_data_vel, styles[k]->fields_data_vel, 0, concat_dummy);
fields_allocated = 1; }
// check concat_grow for multiple special-case fields // check concat_grow for multiple special-case fields
// may cause issues with style-specific create_atom() and data_atom() methods // may cause issues with style-specific create_atom() and data_atom() methods
// issue warnings if appear in multiple sub-styles // issue warnings if appear in multiple sub-styles
const char *dupfield[] = {"radius","rmass"}; std::vector<std::string> dupfield = {"radius", "rmass"};
int ndupfield = 2;
char *ptr;
for (int idup = 0; idup < ndupfield; idup++) { for (const auto &idup : dupfield) {
auto dup = (char *) dupfield[idup]; if ((comm->me == 0) && (std::count(concat_grow.begin(), concat_grow.end(), idup) > 1))
ptr = strstr(concat_grow,dup); error->warning(FLERR,
if ((ptr && strstr(ptr+1,dup)) && (comm->me == 0)) "Per-atom field {} is used in multiple sub-styles; must be used consistently",
error->warning(FLERR,fmt::format("Per-atom {} is used in multiple sub-" idup);
"styles; must be used consistently",dup));
} }
delete [] concat_grow;
// set bonus_flag if any substyle has bonus data // set bonus_flag if any substyle has bonus data
// set nstyles_bonus & styles_bonus // set nstyles_bonus & styles_bonus
// sum two sizes over contributions from each substyle with bonus data. // sum two sizes over contributions from each substyle with bonus data.
nstyles_bonus = 0; nstyles_bonus = 0;
for (k = 0; k < nstyles; k++) for (int k = 0; k < nstyles; k++)
if (styles[k]->bonus_flag) nstyles_bonus++; if (styles[k]->bonus_flag) nstyles_bonus++;
if (nstyles_bonus) { if (nstyles_bonus) {
@ -236,7 +185,7 @@ void AtomVecHybrid::process_args(int narg, char **arg)
nstyles_bonus = 0; nstyles_bonus = 0;
size_forward_bonus = 0; size_forward_bonus = 0;
size_border_bonus = 0; size_border_bonus = 0;
for (k = 0; k < nstyles; k++) { for (int k = 0; k < nstyles; k++) {
if (styles[k]->bonus_flag) { if (styles[k]->bonus_flag) {
styles_bonus[nstyles_bonus++] = styles[k]; styles_bonus[nstyles_bonus++] = styles[k];
size_forward_bonus += styles[k]->size_forward_bonus; size_forward_bonus += styles[k]->size_forward_bonus;
@ -277,16 +226,14 @@ void AtomVecHybrid::force_clear(int n, size_t nbytes)
void AtomVecHybrid::copy_bonus(int i, int j, int delflag) void AtomVecHybrid::copy_bonus(int i, int j, int delflag)
{ {
for (int k = 0; k < nstyles_bonus; k++) for (int k = 0; k < nstyles_bonus; k++) styles_bonus[k]->copy_bonus(i, j, delflag);
styles_bonus[k]->copy_bonus(i,j,delflag);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AtomVecHybrid::clear_bonus() void AtomVecHybrid::clear_bonus()
{ {
for (int k = 0; k < nstyles_bonus; k++) for (int k = 0; k < nstyles_bonus; k++) styles_bonus[k]->clear_bonus();
styles_bonus[k]->clear_bonus();
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -294,8 +241,7 @@ void AtomVecHybrid::clear_bonus()
int AtomVecHybrid::pack_comm_bonus(int n, int *list, double *buf) int AtomVecHybrid::pack_comm_bonus(int n, int *list, double *buf)
{ {
int m = 0; int m = 0;
for (int k = 0; k < nstyles_bonus; k++) for (int k = 0; k < nstyles_bonus; k++) m += styles_bonus[k]->pack_comm_bonus(n, list, buf);
m += styles_bonus[k]->pack_comm_bonus(n,list,buf);
return m; return m;
} }
@ -303,8 +249,7 @@ int AtomVecHybrid::pack_comm_bonus(int n, int *list, double *buf)
void AtomVecHybrid::unpack_comm_bonus(int n, int first, double *buf) void AtomVecHybrid::unpack_comm_bonus(int n, int first, double *buf)
{ {
for (int k = 0; k < nstyles_bonus; k++) for (int k = 0; k < nstyles_bonus; k++) styles_bonus[k]->unpack_comm_bonus(n, first, buf);
styles_bonus[k]->unpack_comm_bonus(n,first,buf);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -312,8 +257,7 @@ void AtomVecHybrid::unpack_comm_bonus(int n, int first, double *buf)
int AtomVecHybrid::pack_border_bonus(int n, int *list, double *buf) int AtomVecHybrid::pack_border_bonus(int n, int *list, double *buf)
{ {
int m = 0; int m = 0;
for (int k = 0; k < nstyles_bonus; k++) for (int k = 0; k < nstyles_bonus; k++) m += styles_bonus[k]->pack_border_bonus(n, list, buf);
m += styles_bonus[k]->pack_border_bonus(n,list,buf);
return m; return m;
} }
@ -322,8 +266,7 @@ int AtomVecHybrid::pack_border_bonus(int n, int *list, double *buf)
int AtomVecHybrid::unpack_border_bonus(int n, int first, double *buf) int AtomVecHybrid::unpack_border_bonus(int n, int first, double *buf)
{ {
int m = 0; int m = 0;
for (int k = 0; k < nstyles_bonus; k++) for (int k = 0; k < nstyles_bonus; k++) m += styles_bonus[k]->unpack_border_bonus(n, first, buf);
m += styles_bonus[k]->unpack_border_bonus(n,first,buf);
return m; return m;
} }
@ -332,8 +275,7 @@ int AtomVecHybrid::unpack_border_bonus(int n, int first, double *buf)
int AtomVecHybrid::pack_exchange_bonus(int i, double *buf) int AtomVecHybrid::pack_exchange_bonus(int i, double *buf)
{ {
int m = 0; int m = 0;
for (int k = 0; k < nstyles_bonus; k++) for (int k = 0; k < nstyles_bonus; k++) m += styles_bonus[k]->pack_exchange_bonus(i, buf);
m += styles_bonus[k]->pack_exchange_bonus(i,buf);
return m; return m;
} }
@ -342,8 +284,7 @@ int AtomVecHybrid::pack_exchange_bonus(int i, double *buf)
int AtomVecHybrid::unpack_exchange_bonus(int ilocal, double *buf) int AtomVecHybrid::unpack_exchange_bonus(int ilocal, double *buf)
{ {
int m = 0; int m = 0;
for (int k = 0; k < nstyles_bonus; k++) for (int k = 0; k < nstyles_bonus; k++) m += styles_bonus[k]->unpack_exchange_bonus(ilocal, buf);
m += styles_bonus[k]->unpack_exchange_bonus(ilocal,buf);
return m; return m;
} }
@ -352,8 +293,7 @@ int AtomVecHybrid::unpack_exchange_bonus(int ilocal, double *buf)
int AtomVecHybrid::size_restart_bonus() int AtomVecHybrid::size_restart_bonus()
{ {
int n = 0; int n = 0;
for (int k = 0; k < nstyles_bonus; k++) for (int k = 0; k < nstyles_bonus; k++) n += styles_bonus[k]->size_restart_bonus();
n += styles_bonus[k]->size_restart_bonus();
return n; return n;
} }
@ -362,8 +302,7 @@ int AtomVecHybrid::size_restart_bonus()
int AtomVecHybrid::pack_restart_bonus(int i, double *buf) int AtomVecHybrid::pack_restart_bonus(int i, double *buf)
{ {
int m = 0; int m = 0;
for (int k = 0; k < nstyles_bonus; k++) for (int k = 0; k < nstyles_bonus; k++) m += styles_bonus[k]->pack_restart_bonus(i, buf);
m += styles_bonus[k]->pack_restart_bonus(i,buf);
return m; return m;
} }
@ -372,8 +311,7 @@ int AtomVecHybrid::pack_restart_bonus(int i, double *buf)
int AtomVecHybrid::unpack_restart_bonus(int ilocal, double *buf) int AtomVecHybrid::unpack_restart_bonus(int ilocal, double *buf)
{ {
int m = 0; int m = 0;
for (int k = 0; k < nstyles_bonus; k++) for (int k = 0; k < nstyles_bonus; k++) m += styles_bonus[k]->unpack_restart_bonus(ilocal, buf);
m += styles_bonus[k]->unpack_restart_bonus(ilocal,buf);
return m; return m;
} }
@ -382,8 +320,7 @@ int AtomVecHybrid::unpack_restart_bonus(int ilocal, double *buf)
double AtomVecHybrid::memory_usage_bonus() double AtomVecHybrid::memory_usage_bonus()
{ {
double bytes = 0; double bytes = 0;
for (int k = 0; k < nstyles_bonus; k++) for (int k = 0; k < nstyles_bonus; k++) bytes += styles_bonus[k]->memory_usage_bonus();
bytes += styles_bonus[k]->memory_usage_bonus();
return bytes; return bytes;
} }
@ -393,8 +330,7 @@ double AtomVecHybrid::memory_usage_bonus()
void AtomVecHybrid::pack_restart_pre(int ilocal) void AtomVecHybrid::pack_restart_pre(int ilocal)
{ {
for (int k = 0; k < nstyles; k++) for (int k = 0; k < nstyles; k++) styles[k]->pack_restart_pre(ilocal);
styles[k]->pack_restart_pre(ilocal);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -403,8 +339,7 @@ void AtomVecHybrid::pack_restart_pre(int ilocal)
void AtomVecHybrid::pack_restart_post(int ilocal) void AtomVecHybrid::pack_restart_post(int ilocal)
{ {
for (int k = 0; k < nstyles; k++) for (int k = 0; k < nstyles; k++) styles[k]->pack_restart_post(ilocal);
styles[k]->pack_restart_post(ilocal);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -413,8 +348,7 @@ void AtomVecHybrid::pack_restart_post(int ilocal)
void AtomVecHybrid::unpack_restart_init(int ilocal) void AtomVecHybrid::unpack_restart_init(int ilocal)
{ {
for (int k = 0; k < nstyles; k++) for (int k = 0; k < nstyles; k++) styles[k]->unpack_restart_init(ilocal);
styles[k]->unpack_restart_init(ilocal);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -423,8 +357,7 @@ void AtomVecHybrid::unpack_restart_init(int ilocal)
void AtomVecHybrid::create_atom_post(int ilocal) void AtomVecHybrid::create_atom_post(int ilocal)
{ {
for (int k = 0; k < nstyles; k++) for (int k = 0; k < nstyles; k++) styles[k]->create_atom_post(ilocal);
styles[k]->create_atom_post(ilocal);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -434,16 +367,15 @@ void AtomVecHybrid::create_atom_post(int ilocal)
void AtomVecHybrid::data_atom_post(int ilocal) void AtomVecHybrid::data_atom_post(int ilocal)
{ {
for (int k = 0; k < nstyles; k++) for (int k = 0; k < nstyles; k++) styles[k]->data_atom_post(ilocal);
styles[k]->data_atom_post(ilocal);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
modify what AtomVec::data_bonds() just unpacked modify what AtomVec::data_bonds() just unpacked
or initialize other bond quantities or initialize other bond quantities
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecHybrid::data_bonds_post(int m, int num_bond, tagint atom1, void AtomVecHybrid::data_bonds_post(int m, int num_bond, tagint atom1, tagint atom2,
tagint atom2, tagint id_offset) tagint id_offset)
{ {
for (int k = 0; k < nstyles; k++) for (int k = 0; k < nstyles; k++)
styles[k]->data_bonds_post(m, num_bond, atom1, atom2, id_offset); styles[k]->data_bonds_post(m, num_bond, atom1, atom2, id_offset);
@ -455,8 +387,7 @@ void AtomVecHybrid::data_bonds_post(int m, int num_bond, tagint atom1,
void AtomVecHybrid::pack_data_pre(int ilocal) void AtomVecHybrid::pack_data_pre(int ilocal)
{ {
for (int k = 0; k < nstyles; k++) for (int k = 0; k < nstyles; k++) styles[k]->pack_data_pre(ilocal);
styles[k]->pack_data_pre(ilocal);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -465,8 +396,7 @@ void AtomVecHybrid::pack_data_pre(int ilocal)
void AtomVecHybrid::pack_data_post(int ilocal) void AtomVecHybrid::pack_data_post(int ilocal)
{ {
for (int k = 0; k < nstyles; k++) for (int k = 0; k < nstyles; k++) styles[k]->pack_data_post(ilocal);
styles[k]->pack_data_post(ilocal);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -508,7 +438,7 @@ void AtomVecHybrid::write_data_bonus(FILE *fp, int n, double *buf, int flag)
return -1 if name is unknown to any sub-styles return -1 if name is unknown to any sub-styles
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int AtomVecHybrid::property_atom(char *name) int AtomVecHybrid::property_atom(const std::string &name)
{ {
for (int k = 0; k < nstyles; k++) { for (int k = 0; k < nstyles; k++) {
int index = styles[k]->property_atom(name); int index = styles[k]->property_atom(name);
@ -522,8 +452,7 @@ int AtomVecHybrid::property_atom(char *name)
index maps to data specific to this atom style index maps to data specific to this atom style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecHybrid::pack_property_atom(int multiindex, double *buf, void AtomVecHybrid::pack_property_atom(int multiindex, double *buf, int nvalues, int groupbit)
int nvalues, int groupbit)
{ {
int k = multiindex % nstyles; int k = multiindex % nstyles;
int index = multiindex / nstyles; int index = multiindex / nstyles;
@ -535,48 +464,21 @@ void AtomVecHybrid::pack_property_atom(int multiindex, double *buf,
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
merge fields and remove duplicate fields merge fields into root vector and remove duplicate fields
concat = root + Inum fields string from all substyles
return dedup = concat with duplicate fields removed
if concat_flag set, also return concat (w/ duplicates) if concat_flag set, also return concat (w/ duplicates)
so caller can check for problematic fields, call will free it so caller can check for problematic fields
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
char *AtomVecHybrid::merge_fields(int inum, char *root, void AtomVecHybrid::merge_fields(std::vector<std::string> &root,
int concat_flag, char *&concat_str) const std::vector<std::string> &fields, int concat_flag,
std::vector<std::string> &concat)
{ {
// create vector with all words combined // grow vector with all words combined with dedup and
std::string concat; for (const auto &field : fields) {
if (root) concat += root; if (concat_flag) concat.push_back(field);
for (int k = 0; k < nstyles; k++) { if (std::find(root.begin(), root.end(), field) == root.end()) root.push_back(field);
if (concat.size() > 0) concat += " ";
concat += fieldstrings[k].fstr[inum];
} }
if (concat_flag) concat_str = utils::strdup(concat);
// remove duplicate words without changing the order
auto words = Tokenizer(concat, " ").as_vector();
std::vector<std::string> dedup;
for (auto &w : words) {
bool found = false;
for (auto &d : dedup) {
if (w == d) found = true;
}
if (!found) dedup.push_back(w);
}
// create final concatenated, deduped string
concat.clear();
for (auto &d : dedup) {
concat += d;
concat += " ";
}
// remove trailing blank
if (concat.size() > 0) concat.pop_back();
return utils::strdup(concat);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -64,23 +64,18 @@ class AtomVecHybrid : public AtomVec {
int pack_data_bonus(double *, int) override; int pack_data_bonus(double *, int) override;
void write_data_bonus(FILE *, int, double *, int) override; void write_data_bonus(FILE *, int, double *, int) override;
int property_atom(char *) override; int property_atom(const std::string &) override;
void pack_property_atom(int, double *, int, int) override; void pack_property_atom(int, double *, int, int) override;
private: private:
int nallstyles; int nallstyles;
char **allstyles; char **allstyles;
int fields_allocated;
struct FieldStrings {
char **fstr;
};
FieldStrings *fieldstrings;
int nstyles_bonus; int nstyles_bonus;
class AtomVec **styles_bonus; class AtomVec **styles_bonus;
char *merge_fields(int, char *, int, char *&); void merge_fields(std::vector<std::string> &, const std::vector<std::string> &,
int, std::vector<std::string> &);
void build_styles(); void build_styles();
int known_style(char *); int known_style(char *);
}; };

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -23,12 +22,11 @@
#include "modify.h" #include "modify.h"
#include <cmath> #include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using MathConst::MY_PI;
#define EPSILON 0.001 static constexpr double EPSILON = 0.001;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -55,18 +53,17 @@ AtomVecLine::AtomVecLine(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "molecule radius rmass omega torque line"; fields_grow = {"molecule", "radius", "rmass", "omega", "torque", "line"};
fields_copy = (char *) "molecule radius rmass omega"; fields_copy = {"molecule", "radius", "rmass", "omega"};
fields_comm = (char *) ""; fields_comm_vel = {"omega"};
fields_comm_vel = (char *) "omega"; fields_reverse = {"torque"};
fields_reverse = (char *) "torque"; fields_border = {"molecule", "radius", "rmass"};
fields_border = (char *) "molecule radius rmass"; fields_border_vel = {"molecule", "radius", "rmass", "omega"};
fields_border_vel = (char *) "molecule radius rmass omega"; fields_exchange = {"molecule", "radius", "rmass", "omega"};
fields_exchange = (char *) "molecule radius rmass omega"; fields_restart = {"molecule", "radius", "rmass", "omega"};
fields_restart = (char *) "molecule radius rmass omega"; fields_create = {"molecule", "radius", "rmass", "omega", "line"};
fields_create = (char *) "molecule radius rmass omega line"; fields_data_atom = {"id", "molecule", "type", "line", "rmass", "x"};
fields_data_atom = (char *) "id molecule type line rmass x"; fields_data_vel = {"id", "v", "omega"};
fields_data_vel = (char *) "id v omega";
setup_fields(); setup_fields();
} }
@ -108,11 +105,9 @@ void AtomVecLine::grow_pointers()
void AtomVecLine::grow_bonus() void AtomVecLine::grow_bonus()
{ {
nmax_bonus = grow_nmax_bonus(nmax_bonus); nmax_bonus = grow_nmax_bonus(nmax_bonus);
if (nmax_bonus < 0) if (nmax_bonus < 0) error->one(FLERR, "Per-processor system is too big");
error->one(FLERR,"Per-processor system is too big");
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus), bonus = (Bonus *) memory->srealloc(bonus, nmax_bonus * sizeof(Bonus), "atom:bonus");
"atom:bonus");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -197,7 +192,8 @@ int AtomVecLine::pack_border_bonus(int n, int *list, double *buf)
m = 0; m = 0;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
j = list[i]; j = list[i];
if (line[j] < 0) buf[m++] = ubuf(0).d; if (line[j] < 0)
buf[m++] = ubuf(0).d;
else { else {
buf[m++] = ubuf(1).d; buf[m++] = ubuf(1).d;
buf[m++] = bonus[line[j]].length; buf[m++] = bonus[line[j]].length;
@ -218,7 +214,8 @@ int AtomVecLine::unpack_border_bonus(int n, int first, double *buf)
last = first + n; last = first + n;
for (i = first; i < last; i++) { for (i = first; i < last; i++) {
line[i] = (int) ubuf(buf[m++]).i; line[i] = (int) ubuf(buf[m++]).i;
if (line[i] == 0) line[i] = -1; if (line[i] == 0)
line[i] = -1;
else { else {
j = nlocal_bonus + nghost_bonus; j = nlocal_bonus + nghost_bonus;
if (j == nmax_bonus) grow_bonus(); if (j == nmax_bonus) grow_bonus();
@ -242,7 +239,8 @@ int AtomVecLine::pack_exchange_bonus(int i, double *buf)
{ {
int m = 0; int m = 0;
if (line[i] < 0) buf[m++] = ubuf(0).d; if (line[i] < 0)
buf[m++] = ubuf(0).d;
else { else {
buf[m++] = ubuf(1).d; buf[m++] = ubuf(1).d;
int j = line[i]; int j = line[i];
@ -260,7 +258,8 @@ int AtomVecLine::unpack_exchange_bonus(int ilocal, double *buf)
int m = 0; int m = 0;
line[ilocal] = (int) ubuf(buf[m++]).i; line[ilocal] = (int) ubuf(buf[m++]).i;
if (line[ilocal] == 0) line[ilocal] = -1; if (line[ilocal] == 0)
line[ilocal] = -1;
else { else {
if (nlocal_bonus == nmax_bonus) grow_bonus(); if (nlocal_bonus == nmax_bonus) grow_bonus();
bonus[nlocal_bonus].length = buf[m++]; bonus[nlocal_bonus].length = buf[m++];
@ -284,8 +283,10 @@ int AtomVecLine::size_restart_bonus()
int n = 0; int n = 0;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (line[i] >= 0) n += size_restart_bonus_one; if (line[i] >= 0)
else n++; n += size_restart_bonus_one;
else
n++;
} }
return n; return n;
@ -301,7 +302,8 @@ int AtomVecLine::pack_restart_bonus(int i, double *buf)
{ {
int m = 0; int m = 0;
if (line[i] < 0) buf[m++] = ubuf(0).d; if (line[i] < 0)
buf[m++] = ubuf(0).d;
else { else {
buf[m++] = ubuf(1).d; buf[m++] = ubuf(1).d;
int j = line[i]; int j = line[i];
@ -321,7 +323,8 @@ int AtomVecLine::unpack_restart_bonus(int ilocal, double *buf)
int m = 0; int m = 0;
line[ilocal] = (int) ubuf(buf[m++]).i; line[ilocal] = (int) ubuf(buf[m++]).i;
if (line[ilocal] == 0) line[ilocal] = -1; if (line[ilocal] == 0)
line[ilocal] = -1;
else { else {
if (nlocal_bonus == nmax_bonus) grow_bonus(); if (nlocal_bonus == nmax_bonus) grow_bonus();
bonus[nlocal_bonus].length = buf[m++]; bonus[nlocal_bonus].length = buf[m++];
@ -353,8 +356,10 @@ void AtomVecLine::data_atom_bonus(int m, const std::vector<std::string> &values)
double length = sqrt(dx * dx + dy * dy); double length = sqrt(dx * dx + dy * dy);
bonus[nlocal_bonus].length = length; bonus[nlocal_bonus].length = length;
if (dy >= 0.0) bonus[nlocal_bonus].theta = acos(dx/length); if (dy >= 0.0)
else bonus[nlocal_bonus].theta = -acos(dx/length); bonus[nlocal_bonus].theta = acos(dx / length);
else
bonus[nlocal_bonus].theta = -acos(dx / length);
double xc = 0.5 * (x1 + x2); double xc = 0.5 * (x1 + x2);
double yc = 0.5 * (y1 + y2); double yc = 0.5 * (y1 + y2);
@ -362,8 +367,7 @@ void AtomVecLine::data_atom_bonus(int m, const std::vector<std::string> &values)
dy = yc - x[m][1]; dy = yc - x[m][1];
double delta = sqrt(dx * dx + dy * dy); double delta = sqrt(dx * dx + dy * dy);
if (delta/length > EPSILON) if (delta / length > EPSILON) error->one(FLERR, "Inconsistent line segment in data file");
error->one(FLERR,"Inconsistent line segment in data file");
x[m][0] = xc; x[m][0] = xc;
x[m][1] = yc; x[m][1] = yc;
@ -410,19 +414,22 @@ void AtomVecLine::create_atom_post(int ilocal)
void AtomVecLine::data_atom_post(int ilocal) void AtomVecLine::data_atom_post(int ilocal)
{ {
line_flag = line[ilocal]; line_flag = line[ilocal];
if (line_flag == 0) line_flag = -1; if (line_flag == 0)
else if (line_flag == 1) line_flag = 0; line_flag = -1;
else error->one(FLERR,"Invalid line flag in Atoms section of data file"); else if (line_flag == 1)
line_flag = 0;
else
error->one(FLERR, "Invalid line flag in Atoms section of data file");
line[ilocal] = line_flag; line[ilocal] = line_flag;
if (rmass[ilocal] <= 0.0) if (rmass[ilocal] <= 0.0) error->one(FLERR, "Invalid density in Atoms section of data file");
error->one(FLERR,"Invalid density in Atoms section of data file");
if (line_flag < 0) { if (line_flag < 0) {
double radius_one = 0.5; double radius_one = 0.5;
radius[ilocal] = radius_one; radius[ilocal] = radius_one;
rmass[ilocal] *= 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one; rmass[ilocal] *= 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one;
} else radius[ilocal] = 0.0; } else
radius[ilocal] = 0.0;
omega[ilocal][0] = 0.0; omega[ilocal][0] = 0.0;
omega[ilocal][1] = 0.0; omega[ilocal][1] = 0.0;
@ -438,13 +445,16 @@ void AtomVecLine::pack_data_pre(int ilocal)
line_flag = line[ilocal]; line_flag = line[ilocal];
rmass_one = rmass[ilocal]; rmass_one = rmass[ilocal];
if (line_flag < 0) line[ilocal] = 0; if (line_flag < 0)
else line[ilocal] = 1; line[ilocal] = 0;
else
line[ilocal] = 1;
if (line_flag < 0) { if (line_flag < 0) {
double radius_one = radius[ilocal]; double radius_one = radius[ilocal];
rmass[ilocal] /= 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one; rmass[ilocal] /= 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one;
} else rmass[ilocal] /= bonus[line_flag].length; } else
rmass[ilocal] /= bonus[line_flag].length;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -490,7 +500,8 @@ int AtomVecLine::pack_data_bonus(double *buf, int /*flag*/)
buf[m++] = y1; buf[m++] = y1;
buf[m++] = x2; buf[m++] = x2;
buf[m++] = y2; buf[m++] = y2;
} else m += size_data_bonus; } else
m += size_data_bonus;
} }
return m; return m;
} }
@ -503,8 +514,8 @@ void AtomVecLine::write_data_bonus(FILE *fp, int n, double *buf, int /*flag*/)
{ {
int i = 0; int i = 0;
while (i < n) { while (i < n) {
fmt::print(fp,"{} {} {} {} {}\n",ubuf(buf[i]).i, fmt::print(fp, "{} {} {} {} {}\n", ubuf(buf[i]).i, buf[i + 1], buf[i + 2], buf[i + 3],
buf[i+1],buf[i+2],buf[i+3],buf[i+4]); buf[i + 4]);
i += size_data_bonus; i += size_data_bonus;
} }
} }
@ -528,7 +539,8 @@ void AtomVecLine::set_length(int i, double value)
copy_bonus_all(nlocal_bonus - 1, line[i]); copy_bonus_all(nlocal_bonus - 1, line[i]);
nlocal_bonus--; nlocal_bonus--;
line[i] = -1; line[i] = -1;
} else bonus[line[i]].length = value; } else
bonus[line[i]].length = value;
// also set radius = half of length // also set radius = half of length
// unless value = 0.0, then set diameter = 1.0 // unless value = 0.0, then set diameter = 1.0
@ -536,40 +548,3 @@ void AtomVecLine::set_length(int i, double value)
radius[i] = 0.5 * value; radius[i] = 0.5 * value;
if (value == 0.0) radius[i] = 0.5; if (value == 0.0) radius[i] = 0.5;
} }
/* ----------------------------------------------------------------------
check consistency of internal Bonus data structure
n = # of atoms in regular structure to check against
------------------------------------------------------------------------- */
/*
void AtomVecLine::consistency_check(int n, char *str)
{
int iflag = 0;
int count = 0;
for (int i = 0; i < n; i++) {
if (line[i] >= 0) {
count++;
if (line[i] >= nlocal_bonus) iflag++;
if (bonus[line[i]].ilocal != i) iflag++;
//if (comm->me == 1 && update->ntimestep == 873)
// printf("CCHK %s: %d %d: %d %d: %d %d\n",
// str,i,n,line[i],nlocal_bonus,bonus[line[i]].ilocal,iflag);
}
}
if (iflag) {
printf("BAD vecline ptrs: %s: %d %d: %d\n",str,comm->me,
update->ntimestep,iflag);
MPI_Abort(world,1);
}
if (count != nlocal_bonus) {
char msg[128];
printf("BAD vecline count: %s: %d %d: %d %d\n",
str,comm->me,update->ntimestep,count,nlocal_bonus);
MPI_Abort(world,1);
}
}
*/

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -21,8 +20,6 @@
#include "math_const.h" #include "math_const.h"
#include "modify.h" #include "modify.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -34,26 +31,24 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp)
molecular = Atom::ATOMIC; molecular = Atom::ATOMIC;
atom->sphere_flag = 1; atom->sphere_flag = 1;
atom->radius_flag = atom->rmass_flag = atom->omega_flag = atom->radius_flag = atom->rmass_flag = atom->omega_flag = atom->torque_flag = 1;
atom->torque_flag = 1;
// strings with peratom variables to include in each AtomVec method // strings with peratom variables to include in each AtomVec method
// strings cannot contain fields in corresponding AtomVec default strings // strings cannot contain fields in corresponding AtomVec default strings
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "radius rmass omega torque"; fields_grow = {"radius", "rmass", "omega", "torque"};
fields_copy = (char *) "radius rmass omega"; fields_copy = {"radius", "rmass", "omega"};
fields_comm = (char *) ""; fields_comm_vel = {"omega"};
fields_comm_vel = (char *) "omega"; fields_reverse = {"torque"};
fields_reverse = (char *) "torque"; fields_border = {"radius", "rmass"};
fields_border = (char *) "radius rmass"; fields_border_vel = {"radius", "rmass", "omega"};
fields_border_vel = (char *) "radius rmass omega"; fields_exchange = {"radius", "rmass", "omega"};
fields_exchange = (char *) "radius rmass omega"; fields_restart = {"radius", "rmass", "omega"};
fields_restart = (char *) "radius rmass omega"; fields_create = {"radius", "rmass", "omega"};
fields_create = (char *) "radius rmass omega"; fields_data_atom = {"id", "type", "radius", "rmass", "x"};
fields_data_atom = (char *) "id type radius rmass x"; fields_data_vel = {"id", "v", "omega"};
fields_data_vel = (char *) "id v omega";
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -63,21 +58,19 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp)
void AtomVecSphere::process_args(int narg, char **arg) void AtomVecSphere::process_args(int narg, char **arg)
{ {
if (narg != 0 && narg != 1) if (narg != 0 && narg != 1) error->all(FLERR, "Illegal atom_style sphere command");
error->all(FLERR,"Illegal atom_style sphere command");
radvary = 0; radvary = 0;
if (narg == 1) { if (narg == 1) {
radvary = utils::numeric(FLERR, arg[0], true, lmp); radvary = utils::numeric(FLERR, arg[0], true, lmp);
if (radvary < 0 || radvary > 1) if (radvary < 0 || radvary > 1) error->all(FLERR, "Illegal atom_style sphere command");
error->all(FLERR,"Illegal atom_style sphere command");
} }
// dynamic particle radius and mass must be communicated every step // dynamic particle radius and mass must be communicated every step
if (radvary) { if (radvary) {
fields_comm = (char *) "radius rmass"; fields_comm = {"radius", "rmass"};
fields_comm_vel = (char *) "radius rmass omega"; fields_comm_vel = {"radius", "rmass", "omega"};
} }
// delay setting up of fields until now // delay setting up of fields until now
@ -97,8 +90,7 @@ void AtomVecSphere::init()
if (strcmp(modify->fix[i]->style, "adapt") == 0) { if (strcmp(modify->fix[i]->style, "adapt") == 0) {
auto fix = dynamic_cast<FixAdapt *>(modify->fix[i]); auto fix = dynamic_cast<FixAdapt *>(modify->fix[i]);
if (fix->diamflag && radvary == 0) if (fix->diamflag && radvary == 0)
error->all(FLERR,"Fix adapt changes particle radii " error->all(FLERR, "Fix adapt changes particle radii but atom_style sphere is not dynamic");
"but atom_style sphere is not dynamic");
} }
} }
@ -133,11 +125,9 @@ void AtomVecSphere::data_atom_post(int ilocal)
{ {
radius_one = 0.5 * atom->radius[ilocal]; radius_one = 0.5 * atom->radius[ilocal];
radius[ilocal] = radius_one; radius[ilocal] = radius_one;
if (radius_one > 0.0) if (radius_one > 0.0) rmass[ilocal] *= 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one;
rmass[ilocal] *= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one;
if (rmass[ilocal] <= 0.0) if (rmass[ilocal] <= 0.0) error->one(FLERR, "Invalid density in Atoms section of data file");
error->one(FLERR,"Invalid density in Atoms section of data file");
omega[ilocal][0] = 0.0; omega[ilocal][0] = 0.0;
omega[ilocal][1] = 0.0; omega[ilocal][1] = 0.0;
@ -155,8 +145,7 @@ void AtomVecSphere::pack_data_pre(int ilocal)
radius[ilocal] *= 2.0; radius[ilocal] *= 2.0;
if (radius_one != 0.0) if (radius_one != 0.0)
rmass[ilocal] = rmass[ilocal] = rmass_one / (4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one);
rmass_one / (4.0*MY_PI/3.0 * radius_one*radius_one*radius_one);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -19,18 +18,17 @@
#include "error.h" #include "error.h"
#include "fix.h" #include "fix.h"
#include "math_const.h" #include "math_const.h"
#include "math_extra.h"
#include "math_eigen.h" #include "math_eigen.h"
#include "math_extra.h"
#include "memory.h" #include "memory.h"
#include "modify.h" #include "modify.h"
#include <cmath> #include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using MathConst::MY_PI;
#define EPSILON 0.001 static constexpr double EPSILON = 0.001;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -58,18 +56,17 @@ AtomVecTri::AtomVecTri(LAMMPS *lmp) : AtomVec(lmp)
// order of fields in a string does not matter // order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file // except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "molecule radius rmass omega angmom torque tri"; fields_grow = {"molecule", "radius", "rmass", "omega", "angmom", "torque", "tri"};
fields_copy = (char *) "molecule radius rmass omega angmom"; fields_copy = {"molecule", "radius", "rmass", "omega", "angmom"};
fields_comm = (char *) ""; fields_comm_vel = {"omega", "angmom"};
fields_comm_vel = (char *) "omega angmom"; fields_reverse = {"torque"};
fields_reverse = (char *) "torque"; fields_border = {"molecule", "radius", "rmass"};
fields_border = (char *) "molecule radius rmass"; fields_border_vel = {"molecule", "radius", "rmass", "omega"};
fields_border_vel = (char *) "molecule radius rmass omega"; fields_exchange = {"molecule", "radius", "rmass", "omega", "angmom"};
fields_exchange = (char *) "molecule radius rmass omega angmom"; fields_restart = {"molecule", "radius", "rmass", "omega", "angmom"};
fields_restart = (char *) "molecule radius rmass omega angmom"; fields_create = {"molecule", "radius", "rmass", "omega", "angmom", "tri"};
fields_create = (char *) "molecule radius rmass omega angmom tri"; fields_data_atom = {"id", "molecule", "type", "tri", "rmass", "x"};
fields_data_atom = (char *) "id molecule type tri rmass x"; fields_data_vel = {"id", "v", "omega", "angmom"};
fields_data_vel = (char *) "id v omega angmom";
setup_fields(); setup_fields();
} }
@ -112,11 +109,9 @@ void AtomVecTri::grow_pointers()
void AtomVecTri::grow_bonus() void AtomVecTri::grow_bonus()
{ {
nmax_bonus = grow_nmax_bonus(nmax_bonus); nmax_bonus = grow_nmax_bonus(nmax_bonus);
if (nmax_bonus < 0) if (nmax_bonus < 0) error->one(FLERR, "Per-processor system is too big");
error->one(FLERR,"Per-processor system is too big");
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus), bonus = (Bonus *) memory->srealloc(bonus, nmax_bonus * sizeof(Bonus), "atom:bonus");
"atom:bonus");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -217,7 +212,8 @@ int AtomVecTri::pack_border_bonus(int n, int *list, double *buf)
m = 0; m = 0;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
j = list[i]; j = list[i];
if (tri[j] < 0) buf[m++] = ubuf(0).d; if (tri[j] < 0)
buf[m++] = ubuf(0).d;
else { else {
buf[m++] = ubuf(1).d; buf[m++] = ubuf(1).d;
quat = bonus[tri[j]].quat; quat = bonus[tri[j]].quat;
@ -258,7 +254,8 @@ int AtomVecTri::unpack_border_bonus(int n, int first, double *buf)
last = first + n; last = first + n;
for (i = first; i < last; i++) { for (i = first; i < last; i++) {
tri[i] = (int) ubuf(buf[m++]).i; tri[i] = (int) ubuf(buf[m++]).i;
if (tri[i] == 0) tri[i] = -1; if (tri[i] == 0)
tri[i] = -1;
else { else {
j = nlocal_bonus + nghost_bonus; j = nlocal_bonus + nghost_bonus;
if (j == nmax_bonus) grow_bonus(); if (j == nmax_bonus) grow_bonus();
@ -301,7 +298,8 @@ int AtomVecTri::pack_exchange_bonus(int i, double *buf)
{ {
int m = 0; int m = 0;
if (tri[i] < 0) buf[m++] = ubuf(0).d; if (tri[i] < 0)
buf[m++] = ubuf(0).d;
else { else {
buf[m++] = ubuf(1).d; buf[m++] = ubuf(1).d;
int j = tri[i]; int j = tri[i];
@ -338,7 +336,8 @@ int AtomVecTri::unpack_exchange_bonus(int ilocal, double *buf)
int m = 0; int m = 0;
tri[ilocal] = (int) ubuf(buf[m++]).i; tri[ilocal] = (int) ubuf(buf[m++]).i;
if (tri[ilocal] == 0) tri[ilocal] = -1; if (tri[ilocal] == 0)
tri[ilocal] = -1;
else { else {
if (nlocal_bonus == nmax_bonus) grow_bonus(); if (nlocal_bonus == nmax_bonus) grow_bonus();
double *quat = bonus[nlocal_bonus].quat; double *quat = bonus[nlocal_bonus].quat;
@ -381,8 +380,10 @@ int AtomVecTri::size_restart_bonus()
int n = 0; int n = 0;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (tri[i] >= 0) n += size_restart_bonus_one; if (tri[i] >= 0)
else n++; n += size_restart_bonus_one;
else
n++;
} }
return n; return n;
@ -396,7 +397,8 @@ int AtomVecTri::pack_restart_bonus(int i, double *buf)
{ {
int m = 0; int m = 0;
if (tri[i] < 0) buf[m++] = ubuf(0).d; if (tri[i] < 0)
buf[m++] = ubuf(0).d;
else { else {
buf[m++] = ubuf(1).d; buf[m++] = ubuf(1).d;
int j = tri[i]; int j = tri[i];
@ -435,7 +437,8 @@ int AtomVecTri::unpack_restart_bonus(int ilocal, double *buf)
int m = 0; int m = 0;
tri[ilocal] = (int) ubuf(buf[m++]).i; tri[ilocal] = (int) ubuf(buf[m++]).i;
if (tri[ilocal] == 0) tri[ilocal] = -1; if (tri[ilocal] == 0)
tri[ilocal] = -1;
else { else {
if (nlocal_bonus == nmax_bonus) grow_bonus(); if (nlocal_bonus == nmax_bonus) grow_bonus();
double *quat = bonus[nlocal_bonus].quat; double *quat = bonus[nlocal_bonus].quat;
@ -516,8 +519,7 @@ void AtomVecTri::data_atom_bonus(int m, const std::vector<std::string> &values)
double dz = centroid[2] - x[m][2]; double dz = centroid[2] - x[m][2];
double delta = sqrt(dx * dx + dy * dy + dz * dz); double delta = sqrt(dx * dx + dy * dy + dz * dz);
if (delta/size > EPSILON) if (delta / size > EPSILON) error->one(FLERR, "Inconsistent triangle in data file");
error->one(FLERR,"Inconsistent triangle in data file");
x[m][0] = centroid[0]; x[m][0] = centroid[0];
x[m][1] = centroid[1]; x[m][1] = centroid[1];
@ -587,14 +589,11 @@ void AtomVecTri::data_atom_bonus(int m, const std::vector<std::string> &values)
double disp[3]; double disp[3];
MathExtra::sub3(c1, centroid, disp); MathExtra::sub3(c1, centroid, disp);
MathExtra::transpose_matvec(ex_space,ey_space,ez_space, MathExtra::transpose_matvec(ex_space, ey_space, ez_space, disp, bonus[nlocal_bonus].c1);
disp,bonus[nlocal_bonus].c1);
MathExtra::sub3(c2, centroid, disp); MathExtra::sub3(c2, centroid, disp);
MathExtra::transpose_matvec(ex_space,ey_space,ez_space, MathExtra::transpose_matvec(ex_space, ey_space, ez_space, disp, bonus[nlocal_bonus].c2);
disp,bonus[nlocal_bonus].c2);
MathExtra::sub3(c3, centroid, disp); MathExtra::sub3(c3, centroid, disp);
MathExtra::transpose_matvec(ex_space,ey_space,ez_space, MathExtra::transpose_matvec(ex_space, ey_space, ez_space, disp, bonus[nlocal_bonus].c3);
disp,bonus[nlocal_bonus].c3);
bonus[nlocal_bonus].ilocal = m; bonus[nlocal_bonus].ilocal = m;
tri[m] = nlocal_bonus++; tri[m] = nlocal_bonus++;
@ -632,19 +631,22 @@ void AtomVecTri::create_atom_post(int ilocal)
void AtomVecTri::data_atom_post(int ilocal) void AtomVecTri::data_atom_post(int ilocal)
{ {
tri_flag = tri[ilocal]; tri_flag = tri[ilocal];
if (tri_flag == 0) tri_flag = -1; if (tri_flag == 0)
else if (tri_flag == 1) tri_flag = 0; tri_flag = -1;
else error->one(FLERR,"Invalid tri flag in Atoms section of data file"); else if (tri_flag == 1)
tri_flag = 0;
else
error->one(FLERR, "Invalid tri flag in Atoms section of data file");
tri[ilocal] = tri_flag; tri[ilocal] = tri_flag;
if (rmass[ilocal] <= 0.0) if (rmass[ilocal] <= 0.0) error->one(FLERR, "Invalid density in Atoms section of data file");
error->one(FLERR,"Invalid density in Atoms section of data file");
if (tri_flag < 0) { if (tri_flag < 0) {
double radius_one = 0.5; double radius_one = 0.5;
radius[ilocal] = radius_one; radius[ilocal] = radius_one;
rmass[ilocal] *= 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one; rmass[ilocal] *= 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one;
} else radius[ilocal] = 0.0; } else
radius[ilocal] = 0.0;
omega[ilocal][0] = 0.0; omega[ilocal][0] = 0.0;
omega[ilocal][1] = 0.0; omega[ilocal][1] = 0.0;
@ -663,8 +665,10 @@ void AtomVecTri::pack_data_pre(int ilocal)
tri_flag = tri[ilocal]; tri_flag = tri[ilocal];
rmass_one = rmass[ilocal]; rmass_one = rmass[ilocal];
if (tri_flag < 0) tri[ilocal] = 0; if (tri_flag < 0)
else tri[ilocal] = 1; tri[ilocal] = 0;
else
tri[ilocal] = 1;
if (tri_flag < 0) { if (tri_flag < 0) {
double radius_one = radius[ilocal]; double radius_one = radius[ilocal];
@ -727,7 +731,8 @@ int AtomVecTri::pack_data_bonus(double *buf, int /*flag*/)
buf[m++] = xc + dc3[0]; buf[m++] = xc + dc3[0];
buf[m++] = yc + dc3[1]; buf[m++] = yc + dc3[1];
buf[m++] = zc + dc3[2]; buf[m++] = zc + dc3[2];
} else m += size_data_bonus; } else
m += size_data_bonus;
} }
return m; return m;
} }
@ -740,9 +745,8 @@ void AtomVecTri::write_data_bonus(FILE *fp, int n, double *buf, int /*flag*/)
{ {
int i = 0; int i = 0;
while (i < n) { while (i < n) {
fmt::print(fp,"{} {} {} {} {} {} {} {} {} {}\n", ubuf(buf[i]).i, fmt::print(fp, "{} {} {} {} {} {} {} {} {} {}\n", ubuf(buf[i]).i, buf[i + 1], buf[i + 2],
buf[i+1],buf[i+2],buf[i+3],buf[i+4],buf[i+5],buf[i+6], buf[i + 3], buf[i + 4], buf[i + 5], buf[i + 6], buf[i + 7], buf[i + 8], buf[i + 9]);
buf[i+7],buf[i+8],buf[i+9]);
i += size_data_bonus; i += size_data_bonus;
} }
} }

View File

@ -43,6 +43,7 @@ Bond::Bond(LAMMPS *_lmp) : Pointers(_lmp)
energy = 0.0; energy = 0.0;
virial[0] = virial[1] = virial[2] = virial[3] = virial[4] = virial[5] = 0.0; virial[0] = virial[1] = virial[2] = virial[3] = virial[4] = virial[5] = 0.0;
writedata = 1; writedata = 1;
reinitflag = 1;
comm_forward = comm_reverse = comm_reverse_off = 0; comm_forward = comm_reverse = comm_reverse_off = 0;
@ -337,11 +338,13 @@ double Bond::memory_usage()
} }
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
Reset all type-based bond params via init. reset all type-based bond params via init()
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
void Bond::reinit() void Bond::reinit()
{ {
if (!reinitflag) error->all(FLERR, "Fix adapt interface to this bond style not supported"); if (!reinitflag)
error->all(FLERR, "Fix adapt interface to this bond style not supported");
init(); init();
} }

View File

@ -39,7 +39,8 @@ class Bond : protected Pointers {
int comm_reverse; // size of reverse communication (0 if none) int comm_reverse; // size of reverse communication (0 if none)
int comm_reverse_off; // size of reverse comm even if newton off int comm_reverse_off; // size of reverse comm even if newton off
int reinitflag; // 1 if compatible with fix adapt and alike int reinitflag; // 0 if not compatible with fix adapt
// extract() method may still need to be added
// KOKKOS host/device flag and data masks // KOKKOS host/device flag and data masks
@ -63,7 +64,8 @@ class Bond : protected Pointers {
virtual double single(int, double, int, int, double &) = 0; virtual double single(int, double, int, int, double &) = 0;
virtual double memory_usage(); virtual double memory_usage();
virtual void *extract(const char *, int &) { return nullptr; } virtual void *extract(const char *, int &) { return nullptr; }
virtual void reinit(); void reinit();
virtual int pack_forward_comm(int, int *, double *, int, int *) {return 0;} virtual int pack_forward_comm(int, int *, double *, int, int *) {return 0;}
virtual void unpack_forward_comm(int, int, double *) {} virtual void unpack_forward_comm(int, int, double *) {}
virtual int pack_reverse_comm(int, int, double *) {return 0;} virtual int pack_reverse_comm(int, int, double *) {return 0;}

View File

@ -108,7 +108,7 @@ class Compute : protected Pointers {
Compute(class LAMMPS *, int, char **); Compute(class LAMMPS *, int, char **);
~Compute() override; ~Compute() override;
void modify_params(int, char **); void modify_params(int, char **);
void reset_extra_dof(); virtual void reset_extra_dof();
virtual void init() = 0; virtual void init() = 0;
virtual void init_list(int, class NeighList *) {} virtual void init_list(int, class NeighList *) {}

View File

@ -30,8 +30,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
enum { CLUSTER, MASK, COORDS };
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
ComputeClusterAtom::ComputeClusterAtom(LAMMPS *lmp, int narg, char **arg) : ComputeClusterAtom::ComputeClusterAtom(LAMMPS *lmp, int narg, char **arg) :
@ -44,7 +42,7 @@ ComputeClusterAtom::ComputeClusterAtom(LAMMPS *lmp, int narg, char **arg) :
peratom_flag = 1; peratom_flag = 1;
size_peratom_cols = 0; size_peratom_cols = 0;
comm_forward = 3; comm_forward = 1;
nmax = 0; nmax = 0;
} }
@ -117,22 +115,6 @@ void ComputeClusterAtom::compute_peratom()
numneigh = list->numneigh; numneigh = list->numneigh;
firstneigh = list->firstneigh; firstneigh = list->firstneigh;
// if update->post_integrate set:
// a dynamic group in FixGroup is invoking a variable with this compute
// thus ghost atom coords need to be up-to-date after initial_integrate()
if (update->post_integrate) {
commflag = COORDS;
comm->forward_comm(this);
}
// if group is dynamic, insure ghost atom masks are current
if (group->dynamic[igroup]) {
commflag = MASK;
comm->forward_comm(this);
}
// every atom starts in its own cluster, with clusterID = atomID // every atom starts in its own cluster, with clusterID = atomID
tagint *tag = atom->tag; tagint *tag = atom->tag;
@ -153,7 +135,6 @@ void ComputeClusterAtom::compute_peratom()
// iterate until no changes in my atoms // iterate until no changes in my atoms
// then check if any proc made changes // then check if any proc made changes
commflag = CLUSTER;
double **x = atom->x; double **x = atom->x;
int change, done, anychange; int change, done, anychange;
@ -203,32 +184,16 @@ void ComputeClusterAtom::compute_peratom()
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int ComputeClusterAtom::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int ComputeClusterAtom::pack_forward_comm(int n, int *list, double *buf,
int * /*pbc*/) int /*pbc_flag*/, int * /*pbc*/)
{ {
int i, j, m; int i, j, m;
m = 0; m = 0;
if (commflag == CLUSTER) {
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
j = list[i]; j = list[i];
buf[m++] = clusterID[j]; buf[m++] = clusterID[j];
} }
} else if (commflag == MASK) {
int *mask = atom->mask;
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = ubuf(mask[j]).d;
}
} else if (commflag == COORDS) {
double **x = atom->x;
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
}
}
return m; return m;
} }
@ -241,19 +206,7 @@ void ComputeClusterAtom::unpack_forward_comm(int n, int first, double *buf)
m = 0; m = 0;
last = first + n; last = first + n;
if (commflag == CLUSTER) {
for (i = first; i < last; i++) clusterID[i] = buf[m++]; for (i = first; i < last; i++) clusterID[i] = buf[m++];
} else if (commflag == MASK) {
int *mask = atom->mask;
for (i = first; i < last; i++) mask[i] = (int) ubuf(buf[m++]).i;
} else if (commflag == COORDS) {
double **x = atom->x;
for (i = first; i < last; i++) {
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
}
}
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -259,6 +259,7 @@ void ComputeCoordAtom::compute_peratom()
j = jlist[jj]; j = jlist[jj];
j &= NEIGHMASK; j &= NEIGHMASK;
if (mask[j] & jgroupbit) {
jtype = type[j]; jtype = type[j];
delx = xtmp - x[j][0]; delx = xtmp - x[j][0];
dely = ytmp - x[j][1]; dely = ytmp - x[j][1];
@ -272,6 +273,7 @@ void ComputeCoordAtom::compute_peratom()
} }
} }
} }
}
} else if (cstyle == ORIENT) { } else if (cstyle == ORIENT) {
@ -309,8 +311,8 @@ void ComputeCoordAtom::compute_peratom()
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int ComputeCoordAtom::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int ComputeCoordAtom::pack_forward_comm(int n, int *list, double *buf,
int * /*pbc*/) int /*pbc_flag*/, int * /*pbc*/)
{ {
int i, m = 0, j; int i, m = 0, j;
for (i = 0; i < n; ++i) { for (i = 0; i < n; ++i) {

View File

@ -119,6 +119,9 @@ ComputeTempProfile::ComputeTempProfile(LAMMPS *lmp, int narg, char **arg) :
nbins = nbinx*nbiny*nbinz; nbins = nbinx*nbiny*nbinz;
if (nbins <= 0) error->all(FLERR,"Illegal compute temp/profile command"); if (nbins <= 0) error->all(FLERR,"Illegal compute temp/profile command");
nstreaming = (xflag==0 ? 0 : 1) + (yflag==0 ? 0 : 1) + (zflag==0 ? 0 : 1);
reset_extra_dof();
memory->create(vbin,nbins,ncount,"temp/profile:vbin"); memory->create(vbin,nbins,ncount,"temp/profile:vbin");
memory->create(binave,nbins,ncount,"temp/profile:binave"); memory->create(binave,nbins,ncount,"temp/profile:binave");
@ -197,9 +200,10 @@ void ComputeTempProfile::dof_compute()
natoms_temp = group->count(igroup); natoms_temp = group->count(igroup);
dof = domain->dimension * natoms_temp; dof = domain->dimension * natoms_temp;
// subtract additional d*Nbins DOF, as in Evans and Morriss paper // subtract additional Nbins DOF for each adjusted direction,
// as in Evans and Morriss paper
dof -= extra_dof + fix_dof + domain->dimension*nbins; dof -= extra_dof + fix_dof + nstreaming*nbins;
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz); if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
else tfactor = 0.0; else tfactor = 0.0;
} }
@ -334,14 +338,19 @@ void ComputeTempProfile::compute_array()
MPI_Allreduce(tbin,tbinall,nbins,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(tbin,tbinall,nbins,MPI_DOUBLE,MPI_SUM,world);
int nper = domain->dimension; double totcount = 0.0;
for (i = 0; i < nbins; i++) { for (i = 0; i < nbins; i++) {
array[i][0] = binave[i][ncount-1]; array[i][0] = binave[i][ncount-1];
totcount += array[i][0];
}
double nper = domain->dimension - (extra_dof + fix_dof)/totcount;
double dofbin, tfactorbin;
for (i = 0; i < nbins; i++) {
if (array[i][0] > 0.0) { if (array[i][0] > 0.0) {
dof = nper*array[i][0] - extra_dof; dofbin = nper*array[i][0] - nstreaming;
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz); if (dofbin > 0) tfactorbin = force->mvv2e / (dofbin * force->boltz);
else tfactor = 0.0; else tfactorbin = 0.0;
array[i][1] = tfactor*tbinall[i]; array[i][1] = tfactorbin*tbinall[i];
} else array[i][1] = 0.0; } else array[i][1] = 0.0;
} }
} }
@ -576,6 +585,12 @@ void ComputeTempProfile::bin_assign()
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void ComputeTempProfile::reset_extra_dof() {
extra_dof = domain->dimension - nstreaming;
}
/* ---------------------------------------------------------------------- */
double ComputeTempProfile::memory_usage() double ComputeTempProfile::memory_usage()
{ {
double bytes = (double)maxatom * sizeof(int); double bytes = (double)maxatom * sizeof(int);

Some files were not shown because too many files have changed in this diff Show More