Merge pull request #4215 from lammps/atom-map-bug

Ensure atom map is reset by fix pour and fix deposit
This commit is contained in:
Axel Kohlmeyer
2024-07-03 00:38:33 -04:00
committed by GitHub
3 changed files with 55 additions and 48 deletions

View File

@ -71,11 +71,11 @@ all atoms, e.g. in a data or restart file.
atom IDs are required, due to how neighbor lists are built. atom IDs are required, due to how neighbor lists are built.
The *map* keyword determines how atoms with specific IDs are found The *map* keyword determines how atoms with specific IDs are found
when required. An example are the bond (angle, etc) methods which when required. For example, the bond (angle, etc) methods need to
need to find the local index of an atom with a specific global ID find the local index of an atom with a specific global ID which is a
which is a bond (angle, etc) partner. LAMMPS performs this operation bond (angle, etc) partner. LAMMPS performs this operation efficiently
efficiently by creating a "map", which is either an *array* or *hash* by creating a "map", which is either an *array* or *hash* table, as
table, as described below. described below.
When the *map* keyword is not specified in your input script, LAMMPS When the *map* keyword is not specified in your input script, LAMMPS
only creates a map for :doc:`atom_styles <atom_style>` for molecular only creates a map for :doc:`atom_styles <atom_style>` for molecular
@ -83,34 +83,39 @@ systems which have permanent bonds (angles, etc). No map is created
for atomic systems, since it is normally not needed. However some for atomic systems, since it is normally not needed. However some
LAMMPS commands require a map, even for atomic systems, and will LAMMPS commands require a map, even for atomic systems, and will
generate an error if one does not exist. The *map* keyword thus generate an error if one does not exist. The *map* keyword thus
allows you to force the creation of a map. The *yes* value will allows you to force the creation of a map.
create either an *array* or *hash* style map, as explained in the next
paragraph. The *array* and *hash* values create an array-style or
hash-style map respectively.
For an *array*\ -style map, each processor stores a lookup table of Specifying a value of *yes* will create either an array-style or
length N, where N is the largest atom ID in the system. This is a hash-style map, depending on the size of the system. If no atom ID is
fast, simple method for many simulations, but requires too much memory larger than 1 million, then an array-style map is used, otherwise a
for large simulations. For a *hash*\ -style map, a hash table is hash-style map is used. Specifying a value of *array* or *hash*
created on each processor, which finds an atom ID in constant time creates an array-style or hash-style map respectively, regardless of
(independent of the global number of atom IDs). It can be slightly the size of the system.
slower than the *array* map, but its memory cost is proportional to
the number of atoms owned by a processor, i.e. N/P when N is the total
number of atoms in the system and P is the number of processors.
The *first* keyword allows a :doc:`group <group>` to be specified whose For an array-style map, each processor stores a lookup table of length
atoms will be maintained as the first atoms in each processor's list N, where N is the largest atom ID in the system. This is a fast,
of owned atoms. This in only useful when the specified group is a simple method for many simulations, but requires too much memory for
small fraction of all the atoms, and there are other operations LAMMPS large simulations. For a hash-style map, a hash table is created on
is performing that will be sped-up significantly by being able to loop each processor, which finds an atom ID in constant time (independent
over the smaller set of atoms. Otherwise the reordering required by of the global number of atom IDs). It can be slightly slower than the
this option will be a net slow-down. The :doc:`neigh_modify include <neigh_modify>` and :doc:`comm_modify group <comm_modify>` *array* map, but its memory cost is proportional to the number of
commands are two examples of commands that require this setting to atoms owned by a processor, i.e. N/P when N is the total number of
work efficiently. Several :doc:`fixes <fix>`, most notably time atoms in the system and P is the number of processors.
integration fixes like :doc:`fix nve <fix_nve>`, also take advantage of
this setting if the group they operate on is the group specified by The *first* keyword allows a :doc:`group <group>` to be specified
this command. Note that specifying "all" as the group-ID effectively whose atoms will be maintained as the first atoms in each processor's
turns off the *first* option. list of owned atoms. This in only useful when the specified group is
a small fraction of all the atoms, and there are other operations
LAMMPS is performing that will be sped-up significantly by being able
to loop over the smaller set of atoms. Otherwise the reordering
required by this option will be a net slow-down. The
:doc:`neigh_modify include <neigh_modify>` and :doc:`comm_modify group
<comm_modify>` commands are two examples of commands that require this
setting to work efficiently. Several :doc:`fixes <fix>`, most notably
time integration fixes like :doc:`fix nve <fix_nve>`, also take
advantage of this setting if the group they operate on is the group
specified by this command. Note that specifying "all" as the group-ID
effectively turns off the *first* option.
It is OK to use the *first* keyword with a group that has not yet been It is OK to use the *first* keyword with a group that has not yet been
defined, e.g. to use the atom_modify first command at the beginning of defined, e.g. to use the atom_modify first command at the beginning of
@ -148,15 +153,16 @@ cache locality will be undermined.
.. note:: .. note::
Running a simulation with sorting on versus off should not Running a simulation with sorting on versus off should not change
change the simulation results in a statistical sense. However, a the simulation results in a statistical sense. However, a
different ordering will induce round-off differences, which will lead different ordering will induce round-off differences, which will
to diverging trajectories over time when comparing two simulations. lead to diverging trajectories over time when comparing two
Various commands, particularly those which use random numbers simulations. Various commands, particularly those which use random
(e.g. :doc:`velocity create <velocity>`, and :doc:`fix langevin <fix_langevin>`), may generate (statistically identical) numbers (e.g. :doc:`velocity create <velocity>`, and :doc:`fix
results which depend on the order in which atoms are processed. The langevin <fix_langevin>`), may generate (statistically identical)
order of atoms in a :doc:`dump <dump>` file will also typically change results which depend on the order in which atoms are processed.
if sorting is enabled. The order of atoms in a :doc:`dump <dump>` file will also typically
change if sorting is enabled.
.. note:: .. note::
@ -183,12 +189,13 @@ Default
By default, *id* is yes. By default, atomic systems (no bond topology By default, *id* is yes. By default, atomic systems (no bond topology
info) do not use a map. For molecular systems (with bond topology info) do not use a map. For molecular systems (with bond topology
info), a map is used. The default map style is array if no atom ID is info), the default is to use a map of either *array* or *hash* style
larger than 1 million, otherwise the default is hash. By default, a depending on the size of the sustem, as explained above for the *map
"first" group is not defined. By default, sorting is enabled with a yes* keyword/value option. By default, a *first* group is not
frequency of 1000 and a binsize of 0.0, which means the neighbor defined. By default, sorting is enabled with a frequency of 1000 and
cutoff will be used to set the bin size. If no neighbor cutoff is a binsize of 0.0, which means the neighbor cutoff will be used to set
defined, sorting will be turned off. the bin size. If no neighbor cutoff is defined, sorting will be turned
off.
---------- ----------

View File

@ -703,7 +703,7 @@ void FixPour::pre_exchange()
// rebuild atom map // rebuild atom map
if (atom->map_style != Atom::MAP_NONE) { if (atom->map_style != Atom::MAP_NONE) {
if (success) atom->map_init(); atom->map_init();
atom->map_set(); atom->map_set();
} }

View File

@ -630,7 +630,7 @@ void FixDeposit::pre_exchange()
// rebuild atom map // rebuild atom map
if (atom->map_style != Atom::MAP_NONE) { if (atom->map_style != Atom::MAP_NONE) {
if (success) atom->map_init(); atom->map_init();
atom->map_set(); atom->map_set();
} }