Merge pull request #1788 from lammps/atomvec-custom

Refactoring of AtomVec class
This commit is contained in:
Axel Kohlmeyer
2020-05-08 15:18:11 -04:00
committed by GitHub
164 changed files with 6341 additions and 24577 deletions

View File

@ -79,9 +79,6 @@ KOKKOS, o = USER-OMP, t = OPT.
* :doc:`ke/atom/eff <compute_ke_atom_eff>`
* :doc:`ke/eff <compute_ke_eff>`
* :doc:`ke/rigid <compute_ke_rigid>`
* :doc:`meso/e/atom <compute_meso_e_atom>`
* :doc:`meso/rho/atom <compute_meso_rho_atom>`
* :doc:`meso/t/atom <compute_meso_t_atom>`
* :doc:`momentum <compute_momentum>`
* :doc:`msd <compute_msd>`
* :doc:`msd/chunk <compute_msd_chunk>`
@ -133,6 +130,9 @@ KOKKOS, o = USER-OMP, t = OPT.
* :doc:`sna/atom <compute_sna_atom>`
* :doc:`snad/atom <compute_sna_atom>`
* :doc:`snav/atom <compute_sna_atom>`
* :doc:`sph/e/atom <compute_sph_e_atom>`
* :doc:`sph/rho/atom <compute_sph_rho_atom>`
* :doc:`sph/t/atom <compute_sph_t_atom>`
* :doc:`spin <compute_spin>`
* :doc:`stress/atom <compute_stress_atom>`
* :doc:`stress/mop <compute_stress_mop>`

View File

@ -95,9 +95,7 @@ OPT.
* :doc:`lb/viscous <fix_lb_viscous>`
* :doc:`lineforce <fix_lineforce>`
* :doc:`manifoldforce <fix_manifoldforce>`
* :doc:`meso <fix_meso>`
* :doc:`meso/move <fix_meso_move>`
* :doc:`meso/stationary <fix_meso_stationary>`
* :doc:`momentum (k) <fix_momentum>`
* :doc:`move <fix_move>`
* :doc:`mscg <fix_mscg>`
@ -202,6 +200,8 @@ OPT.
* :doc:`smd/move_tri_surf <fix_smd_move_triangulated_surface>`
* :doc:`smd/setvel <fix_smd_setvel>`
* :doc:`smd/wall_surface <fix_smd_wall_surface>`
* :doc:`sph <fix_sph>`
* :doc:`sph/stationary <fix_sph_stationary>`
* :doc:`spring <fix_spring>`
* :doc:`spring/chunk <fix_spring_chunk>`
* :doc:`spring/rg <fix_spring_rg>`

View File

@ -3,115 +3,169 @@ Atom styles
Classes that define an :doc:`atom style <atom_style>` are derived from
the AtomVec class and managed by the Atom class. The atom style
determines what attributes are associated with an atom. 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 with
atoms.
determines what attributes are associated with an atom and
communicated when it is a ghost atom or migrates to a new processor.
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
with atoms.
Atom_vec_atomic.cpp is a simple example of an atom style.
Atom_vec_atomic.cpp is the simplest example of an atom style.
Examining the code for others will make these instructions more clear.
Here is a brief description of methods you define in your new derived
class. See atom_vec.h for details.
Note that the :doc:`atom style hybrid <atom_style>` command can be
used to define atoms or particles which have the union of properties
of individual styles. Also the :doc:`fix property/atom <fix_property_atom>`
command can be used to add a single property (e.g. charge
or a molecule ID) to a style that does not have it. It can also be
used to add custom properties to an atom, with options to communicate
them with ghost atoms or read them from a data file. Other LAMMPS
commands can access these custom properties, as can new pair, 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
custom per-atom properties from an input script. All of these methods
are less work than writing code for a new atom style.
+-------------------------+--------------------------------------------------------------------------------+
| init | one time setup (optional) |
+-------------------------+--------------------------------------------------------------------------------+
| grow | re-allocate atom arrays to longer lengths (required) |
+-------------------------+--------------------------------------------------------------------------------+
| grow_reset | make array pointers in Atom and AtomVec classes consistent (required) |
+-------------------------+--------------------------------------------------------------------------------+
| copy | copy info for one atom to another atom's array locations (required) |
+-------------------------+--------------------------------------------------------------------------------+
| pack_comm | store an atom's info in a buffer communicated every timestep (required) |
+-------------------------+--------------------------------------------------------------------------------+
| pack_comm_vel | add velocity info to communication buffer (required) |
+-------------------------+--------------------------------------------------------------------------------+
| pack_comm_hybrid | store extra info unique to this atom style (optional) |
+-------------------------+--------------------------------------------------------------------------------+
| unpack_comm | retrieve an atom's info from the buffer (required) |
+-------------------------+--------------------------------------------------------------------------------+
| unpack_comm_vel | also retrieve velocity info (required) |
+-------------------------+--------------------------------------------------------------------------------+
| unpack_comm_hybrid | retrieve extra info unique to this atom style (optional) |
+-------------------------+--------------------------------------------------------------------------------+
| pack_reverse | store an atom's info in a buffer communicating partial forces (required) |
+-------------------------+--------------------------------------------------------------------------------+
| pack_reverse_hybrid | store extra info unique to this atom style (optional) |
+-------------------------+--------------------------------------------------------------------------------+
| unpack_reverse | retrieve an atom's info from the buffer (required) |
+-------------------------+--------------------------------------------------------------------------------+
| unpack_reverse_hybrid | retrieve extra info unique to this atom style (optional) |
+-------------------------+--------------------------------------------------------------------------------+
| pack_border | store an atom's info in a buffer communicated on neighbor re-builds (required) |
+-------------------------+--------------------------------------------------------------------------------+
| pack_border_vel | add velocity info to buffer (required) |
+-------------------------+--------------------------------------------------------------------------------+
| pack_border_hybrid | store extra info unique to this atom style (optional) |
+-------------------------+--------------------------------------------------------------------------------+
| unpack_border | retrieve an atom's info from the buffer (required) |
+-------------------------+--------------------------------------------------------------------------------+
| unpack_border_vel | also retrieve velocity info (required) |
+-------------------------+--------------------------------------------------------------------------------+
| unpack_border_hybrid | retrieve extra info unique to this atom style (optional) |
+-------------------------+--------------------------------------------------------------------------------+
| pack_exchange | store all an atom's info to migrate to another processor (required) |
+-------------------------+--------------------------------------------------------------------------------+
| unpack_exchange | retrieve an atom's info from the buffer (required) |
+-------------------------+--------------------------------------------------------------------------------+
| size_restart | number of restart quantities associated with proc's atoms (required) |
+-------------------------+--------------------------------------------------------------------------------+
| pack_restart | pack atom quantities into a buffer (required) |
+-------------------------+--------------------------------------------------------------------------------+
| unpack_restart | unpack atom quantities from a buffer (required) |
+-------------------------+--------------------------------------------------------------------------------+
| create_atom | create an individual atom of this style (required) |
+-------------------------+--------------------------------------------------------------------------------+
| data_atom | parse an atom line from the data file (required) |
+-------------------------+--------------------------------------------------------------------------------+
| data_atom_hybrid | parse additional atom info unique to this atom style (optional) |
+-------------------------+--------------------------------------------------------------------------------+
| data_vel | parse one line of velocity information from data file (optional) |
+-------------------------+--------------------------------------------------------------------------------+
| data_vel_hybrid | parse additional velocity data unique to this atom style (optional) |
+-------------------------+--------------------------------------------------------------------------------+
| memory_usage | tally memory allocated by atom arrays (required) |
+-------------------------+--------------------------------------------------------------------------------+
If you follow these directions your new style will automatically work
in tandem with others via the :doc:`atom_style hybrid <atom_style>`
command.
The constructor of the derived class sets values for several variables
that you must set when defining a new atom style, which are documented
in atom_vec.h. New atom arrays are defined in atom.cpp. Search for
the word "customize" and you will find locations you will need to
modify.
The first step is to define a set of strings in the constructor of the
new derived class. Each string will have zero or more space-separated
variable names which are identical to those used in the atom.h 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
but the last 2 strings you do not need to specify any of
(id,type,x,v,f). Those are included automatically as needed in the
other strings.
.. note::
.. list-table::
It is possible to add some attributes, such as a molecule ID, to
atom styles that do not have them via the :doc:`fix property/atom <fix_property_atom>` command. This command also
allows new custom attributes consisting of extra integer or
floating-point values to be added to atoms. See the :doc:`fix property/atom <fix_property_atom>` doc page for examples of cases
where this is useful and details on how to initialize, access, and
output the custom values.
* - fields_grow
- full list of properties which is allocated and stored
* - fields_copy
- list of properties to copy atoms are rearranged on-processor
* - fields_comm
- list of properties communicated to ghost atoms every step
* - fields_comm_vel
- additional properties communicated if :doc:`comm_modify vel <atom_style>` is used
* - fields_reverse
- list of properties summed from ghost atoms every step
* - fields_border
- list of properties communicated with ghost atoms every reneighboring step
* - fields_border_vel
- additional properties communicated if :doc:`comm_modify vel <atom_style>` is used
* - fields_exchange
- list of properties communicated when an atom migrates to another processor
* - fields_restart
- list of properties written/read to/from a restart file
* - fields_create
- list of properties defined when an atom is created by :doc:`create_atoms <create_atoms>`
* - fields_data_atom
- list of properties (in order) in the Atoms section of a data file, as read by :doc:`read_data <read_data>`
* - fields_data_vel
- list of properties (in order) in the Velocities section of a data file, as read by :doc:`read_data <read_data>`
New :doc:`pair styles <pair_style>`, :doc:`fixes <fix>`, or
:doc:`computes <compute>` can be added to LAMMPS, as discussed below.
The code for these classes can use the per-atom properties defined by
fix property/atom. The Atom class has a find_custom() method that is
useful in this context:
In these strings you can list variable names which LAMMPS already
defines (in some other atom style), or you can create new variable
names. You should not re-use a LAMMPS variable for something with
different meaning in your atom style. If the meaning is related, but
interpreted differently by your atom style, then using the same
variable name means a user should not use your style and the other
style together in a :doc:`atom_style hybrid <atom_style>` command.
Because there will only be one value of the variable and different
parts of LAMMPS will then likely use it differently. LAMMPS has
no way of checking for this.
.. code-block:: c++
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
a bad choice; it is too generic. A better choice would be "e_foo",
where "foo" is specific to your style.
int index = atom->find_custom(char *name, int &flag);
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.
The "name" of a custom attribute, as specified in the :doc:`fix property/atom <fix_property_atom>` command, is checked to verify
that it exists and its index is returned. The method also sets flag =
0/1 depending on whether it is an integer or floating-point attribute.
The vector of values associated with the attribute can then be
accessed using the returned index as
Search for the word "customize" or "customization" in these 2 files to
see where to add your variable. Adding a flag to the 2nd
customization section in atom.h is only necessary if your code (e.g. a
pair style) needs to check that a per-atom property is defined. These
flags should also be set in the constructor of the atom style child
class.
.. code-block:: c++
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.
int *ivector = atom->ivector[index];
double *dvector = atom->dvector[index];
In Atom::peratom_create() when using the add_peratom() method, a
final length argument of 0 is for per-atom vectors, a length > 1 is
for per-atom arrays. Note the use of an extra per-thread flag and the
add_peratom_vary() method when last dimension of the array is
variable-length.
Ivector or dvector are vectors of length Nlocal = # of owned atoms,
which store the attributes of individual atoms.
Adding the variable name to Atom::extract() enable the per-atom data
to be accessed through the :doc:`LAMMPS library interface
<Howto_library>` by a calling code, including from :doc:`Python
<Python_head>`.
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
unclear, see how other atom styles use them.
The grow_pointers() method is also required to make
a copy of peratom data pointers, as explained in the code.
There are a number of other optional methods which your atom style can
implement. These are only needed if you need to do something
out-of-the-ordinary which the default operation of the AtomVec parent
class does not take care of. The best way to figure out why they are
sometimes useful is to look at how other atom styles use them.
* process_args = use if the atom style has arguments
* init = called before each run
* force_clear = called before force computations each timestep
A few atom styles define "bonus" data associated with some or all of
their particles, such as :doc:`atom_style ellipsoid or tri
<atom_style>`. These methods work with that data:
* copy_bonus
* clear_bonus
* pack_comm_bonus
* unpack_comm_bonus
* pack_border_bonus
* unpack_border_bonus
* pack_exchange_bonus
* unpack_exchange_bonus
* size_restart_bonus
* pack_restart_bonus
* unpack_restart_bonus
* data_atom_bonus
* memory_usage_bonus
The :doc:`atom_style body <atom_style>` command can define a particle
geometry with an arbitrary number of values. This method reads it
from a data file:
* data_body
These methods are called before or after operations handled by the
parent AtomVec class. They allow an atom style to do customized
operations on the per-atom values. For example :doc:`atom_style
sphere <atom_style>` reads a diameter and density of each particle
from a data file. But these need to be converted internally to a
radius and mass. That operation is done in the data_atom_post()
method.
* pack_restart_pre
* pack_restart_post
* unpack_restart_init
* create_atom_post
* data_atom_post
* pack_data_pre
* pack_data_post
These methods enable the :doc:`compute property/atom <compute_property_atom>`
command to access per-atom variables it does not
already define as arguments, so that they can be written to a dump
file or used by other LAMMPS commands.
* property_atom
* pack_property_atom

View File

@ -10,7 +10,7 @@ Syntax
atom_style style args
* style = *angle* or *atomic* or *body* or *bond* or *charge* or *dipole* or *dpd* or *edpd* or *mdpd* or *tdpd* or *electron* or *ellipsoid* or *full* or *line* or *meso* or *molecular* or *peri* or *smd* or *sphere* or *spin* or *tri* or *template* or *hybrid*
* style = *angle* or *atomic* or *body* or *bond* or *charge* or *dipole* or *dpd* or *edpd* or *electron* or *ellipsoid* or *full* or *line* or *mdpd* or *molecular* or *peri* or *smd* or *sph* or *sphere* or *spin* or *tdpd* or *tri* or *template* or *hybrid*
.. parsed-literal::
@ -18,7 +18,9 @@ Syntax
*body* args = bstyle bstyle-args
bstyle = style of body particles
bstyle-args = additional arguments specific to the bstyle
see the :doc:`Howto body <Howto_body>` doc page for details
see the :doc:`Howto body <Howto_body>` doc
page for details
*sphere* arg = 0/1 (optional) for static/dynamic particle radii
*tdpd* arg = Nspecies
Nspecies = # of chemical species
*template* arg = template-ID
@ -91,10 +93,6 @@ quantities.
+--------------+-----------------------------------------------------+--------------------------------------+
| *edpd* | temperature and heat capacity | eDPD particles |
+--------------+-----------------------------------------------------+--------------------------------------+
| *mdpd* | density | mDPD particles |
+--------------+-----------------------------------------------------+--------------------------------------+
| *tdpd* | chemical concentration | tDPD particles |
+--------------+-----------------------------------------------------+--------------------------------------+
| *electron* | charge and spin and eradius | electronic force field |
+--------------+-----------------------------------------------------+--------------------------------------+
| *ellipsoid* | shape, quaternion, angular momentum | aspherical particles |
@ -103,7 +101,7 @@ quantities.
+--------------+-----------------------------------------------------+--------------------------------------+
| *line* | end points, angular velocity | rigid bodies |
+--------------+-----------------------------------------------------+--------------------------------------+
| *meso* | rho, e, cv | SPH particles |
| *mdpd* | density | mDPD particles |
+--------------+-----------------------------------------------------+--------------------------------------+
| *molecular* | bonds, angles, dihedrals, impropers | uncharged molecules |
+--------------+-----------------------------------------------------+--------------------------------------+
@ -111,10 +109,14 @@ quantities.
+--------------+-----------------------------------------------------+--------------------------------------+
| *smd* | volume, kernel diameter, contact radius, mass | solid and fluid SPH particles |
+--------------+-----------------------------------------------------+--------------------------------------+
| *sph* | rho, esph, cv | SPH particles |
+--------------+-----------------------------------------------------+--------------------------------------+
| *sphere* | diameter, mass, angular velocity | granular models |
+--------------+-----------------------------------------------------+--------------------------------------+
| *spin* | magnetic moment | system with magnetic particles |
+--------------+-----------------------------------------------------+--------------------------------------+
| *tdpd* | chemical concentration | tDPD particles |
+--------------+-----------------------------------------------------+--------------------------------------+
| *template* | template index, template atom | small molecules with fixed topology |
+--------------+-----------------------------------------------------+--------------------------------------+
| *tri* | corner points, angular momentum | rigid bodies |
@ -144,9 +146,16 @@ basis.
For the *sphere* style, the particles are spheres and each stores a
per-particle diameter and mass. If the diameter > 0.0, the particle
is a finite-size sphere. If the diameter = 0.0, it is a point
particle. Note that by use of the *disc* keyword with the :doc:`fix nve/sphere <fix_nve_sphere>`, :doc:`fix nvt/sphere <fix_nvt_sphere>`,
:doc:`fix nph/sphere <fix_nph_sphere>`, :doc:`fix npt/sphere <fix_npt_sphere>` commands, spheres can be effectively
treated as 2d discs for a 2d simulation if desired. See also the :doc:`set density/disc <set>` command.
particle. Note that by use of the *disc* keyword with the :doc:`fix
nve/sphere <fix_nve_sphere>`, :doc:`fix nvt/sphere <fix_nvt_sphere>`,
:doc:`fix nph/sphere <fix_nph_sphere>`, :doc:`fix npt/sphere
<fix_npt_sphere>` commands, spheres can be effectively treated as 2d
discs for a 2d simulation if desired. See also the :doc:`set
density/disc <set>` command. The *sphere* style takes an optional 0
or 1 argument. A value of 0 means the radius of each sphere is
constant for the duration of the simulation. A value of 1 means the
radii may vary dynamically during the simulation, e.g. due to use of
the :doc:`fix adapt <fix_adapt>` command.
For the *ellipsoid* style, the particles are ellipsoids and each
stores a flag which indicates whether it is a finite-size ellipsoid or
@ -189,8 +198,8 @@ particles which store a set of chemical concentration. An integer
"cc_species" is required to specify the number of chemical species
involved in a tDPD system.
The *meso* style is for smoothed particle hydrodynamics (SPH)
particles which store a density (rho), energy (e), and heat capacity
The *sph* style is for smoothed particle hydrodynamics (SPH)
particles which store a density (rho), energy (esph), and heat capacity
(cv).
The *smd* style is for a general formulation of Smooth Particle
@ -335,7 +344,7 @@ for energy-conserving dissipative particle dynamics (eDPD), many-body
dissipative particle dynamics (mDPD), and transport dissipative particle
dynamics (tDPD), respectively.
The *meso* style is part of the USER-SPH package for smoothed particle
The *sph* style is part of the USER-SPH package for smoothed particle
hydrodynamics (SPH). See `this PDF guide <USER/sph/SPH_LAMMPS_userguide.pdf>`_ to using SPH in LAMMPS.
The *spin* style is part of the SPIN package.
@ -351,7 +360,8 @@ Related commands
Default
"""""""
atom_style atomic
The default atom style is atomic. If atom_style sphere is used its
default argument is 0.
----------

View File

@ -225,9 +225,6 @@ The individual style names on the :doc:`Commands compute <Commands_compute>` doc
* :doc:`ke/atom/eff <compute_ke_atom_eff>` - per-atom translational and radial kinetic energy in the electron force field model
* :doc:`ke/eff <compute_ke_eff>` - kinetic energy of a group of nuclei and electrons in the electron force field model
* :doc:`ke/rigid <compute_ke_rigid>` - translational kinetic energy of rigid bodies
* :doc:`meso/e/atom <compute_meso_e_atom>` - per-atom internal energy of Smooth-Particle Hydrodynamics atoms
* :doc:`meso/rho/atom <compute_meso_rho_atom>` - per-atom mesoscopic density of Smooth-Particle Hydrodynamics atoms
* :doc:`meso/t/atom <compute_meso_t_atom>` - per-atom internal temperature of Smooth-Particle Hydrodynamics atoms
* :doc:`momentum <compute_momentum>` - translational momentum
* :doc:`msd <compute_msd>` - mean-squared displacement of group of atoms
* :doc:`msd/chunk <compute_msd_chunk>` - mean-squared displacement for each chunk
@ -279,6 +276,9 @@ The individual style names on the :doc:`Commands compute <Commands_compute>` doc
* :doc:`sna/atom <compute_sna_atom>` - bispectrum components for each atom
* :doc:`snad/atom <compute_sna_atom>` - derivative of bispectrum components for each atom
* :doc:`snav/atom <compute_sna_atom>` - virial contribution from bispectrum components for each atom
* :doc:`sph/e/atom <compute_sph_e_atom>` - per-atom internal energy of Smooth-Particle Hydrodynamics atoms
* :doc:`sph/rho/atom <compute_sph_rho_atom>` - per-atom density of Smooth-Particle Hydrodynamics atoms
* :doc:`sph/t/atom <compute_sph_t_atom>` - per-atom internal temperature of Smooth-Particle Hydrodynamics atoms
* :doc:`spin <compute_spin>` - magnetic quantities for a system of atoms having spins
* :doc:`stress/atom <compute_stress_atom>` - stress tensor for each atom
* :doc:`stress/mop <compute_stress_mop>` - normal components of the local stress tensor using the method of planes

View File

@ -67,8 +67,8 @@ Syntax
.. parsed-literal::
PERI package per-atom properties:
vfrac = ???
s0 = ???
vfrac = volume fraction
s0 = max stretch of any bond a particle is part of
.. parsed-literal::
@ -81,11 +81,11 @@ Syntax
.. parsed-literal::
USER-SPH package per-atom properties:
rho = ???
drho = ???
e = ???
de = ???
cv = ???
rho = density of SPH particles
drho = change in density
e = energy
de = change in thermal energy
cv = heat capacity
.. parsed-literal::
@ -108,13 +108,17 @@ Description
Define a computation that simply stores atom attributes for each atom
in the group. This is useful so that the values can be used by other
:doc:`output commands <Howto_output>` that take computes as inputs. See
for example, the :doc:`compute reduce <compute_reduce>`, :doc:`fix ave/atom <fix_ave_atom>`, :doc:`fix ave/histo <fix_ave_histo>`, :doc:`fix ave/chunk <fix_ave_chunk>`, and :doc:`atom-style variable <variable>`
commands.
:doc:`output commands <Howto_output>` that take computes as inputs.
See for example, the :doc:`compute reduce <compute_reduce>`, :doc:`fix
ave/atom <fix_ave_atom>`, :doc:`fix ave/histo <fix_ave_histo>`,
:doc:`fix ave/chunk <fix_ave_chunk>`, and :doc:`atom-style variable
<variable>` commands.
The list of possible attributes is the same as that used by the :doc:`dump custom <dump>` command, which describes their meaning, with some
additional quantities that are only defined for certain :doc:`atom styles <atom_style>`. Basically, this augmented list gives an
input script access to any per-atom quantity stored by LAMMPS.
The list of possible attributes is the same as that used by the
:doc:`dump custom <dump>` command, which describes their meaning, with
some additional quantities that are only defined for certain
:doc:`atom styles <atom_style>`. Basically, this augmented list gives
an input script access to any per-atom quantity stored by LAMMPS.
The values are stored in a per-atom vector or array as discussed
below. Zeroes are stored for atoms not in the specified group or for
@ -132,8 +136,9 @@ particles and body particles and store the 4-vector quaternion
representing the orientation of each particle. See the :doc:`set <set>`
command for an explanation of the quaternion vector.
*End1x*\ , *end1y*\ , *end1z*\ , *end2x*\ , *end2y*\ , *end2z*\ , are defined for
line segment particles and define the end points of each line segment.
*End1x*\ , *end1y*\ , *end1z*\ , *end2x*\ , *end2y*\ , *end2z*\ , are
defined for line segment particles and define the end points of each
line segment.
*Corner1x*\ , *corner1y*\ , *corner1z*\ , *corner2x*\ , *corner2y*\ ,
*corner2z*\ , *corner3x*\ , *corner3y*\ , *corner3z*\ , are defined for
@ -144,14 +149,14 @@ number of explicit bonds assigned to an atom. Note that if the
:doc:`newton bond <newton>` command is set to *on*\ , which is the
default, then every bond in the system is assigned to only one of the
two atoms in the bond. Thus a bond between atoms I,J may be tallied
for either atom I or atom J. If :doc:`newton bond off <newton>` is set,
it will be tallied with both atom I and atom J.
for either atom I or atom J. If :doc:`newton bond off <newton>` is
set, it will be tallied with both atom I and atom J.
The *i_name* and *d_name* attributes refer to custom integer and
floating-point properties that have been added to each atom via the
:doc:`fix property/atom <fix_property_atom>` command. When that command
is used specific names are given to each attribute which are what is
specified as the "name" portion of *i_name* or *d_name*.
:doc:`fix property/atom <fix_property_atom>` command. When that
command is used specific names are given to each attribute which are
what is specified as the "name" portion of *i_name* or *d_name*.
**Output info:**
@ -160,8 +165,8 @@ on the number of input values. If a single input is specified, a
per-atom vector is produced. If two or more inputs are specified, a
per-atom array is produced where the number of columns = the number of
inputs. The vector or array can be accessed by any command that uses
per-atom values from a compute as input. See the :doc:`Howto output <Howto_output>` doc page for an overview of LAMMPS output
options.
per-atom values from a compute as input. See the :doc:`Howto output
<Howto_output>` doc page for an overview of LAMMPS output options.
The vector or array values will be in whatever :doc:`units <units>` the
corresponding attribute is in, e.g. velocity units for vx, charge
@ -178,7 +183,8 @@ Restrictions
Related commands
""""""""""""""""
:doc:`dump custom <dump>`, :doc:`compute reduce <compute_reduce>`, :doc:`fix ave/atom <fix_ave_atom>`, :doc:`fix ave/chunk <fix_ave_chunk>`,
:doc:`fix property/atom <fix_property_atom>`
:doc:`dump custom <dump>`, :doc:`compute reduce <compute_reduce>`,
:doc::doc:`fix ave/atom <fix_ave_atom>`, :doc:`fix ave/chunk
:doc:<fix_ave_chunk>`, `fix property/atom <fix_property_atom>`
**Default:** none

View File

@ -1,6 +1,6 @@
.. index:: compute meso/e/atom
.. index:: compute sph/e/atom
compute meso/e/atom command
compute sph/e/atom command
===========================
Syntax
@ -8,17 +8,17 @@ Syntax
.. parsed-literal::
compute ID group-ID meso/e/atom
compute ID group-ID sph/e/atom
* ID, group-ID are documented in :doc:`compute <compute>` command
* meso/e/atom = style name of this compute command
* sph/e/atom = style name of this compute command
Examples
""""""""
.. code-block:: LAMMPS
compute 1 all meso/e/atom
compute 1 all sph/e/atom
Description
"""""""""""
@ -27,8 +27,8 @@ Define a computation that calculates the per-atom internal energy
for each atom in a group.
The internal energy is the energy associated with the internal degrees
of freedom of a mesoscopic particles, e.g. a Smooth-Particle
Hydrodynamics particle.
of freedom of an SPH particle, i.e. a Smooth-Particle Hydrodynamics
particle.
See `this PDF guide <USER/sph/SPH_LAMMPS_userguide.pdf>`_ to using SPH in
LAMMPS.

View File

@ -1,6 +1,6 @@
.. index:: compute meso/rho/atom
.. index:: compute sph/rho/atom
compute meso/rho/atom command
compute sph/rho/atom command
=============================
Syntax
@ -8,32 +8,31 @@ Syntax
.. parsed-literal::
compute ID group-ID meso/rho/atom
compute ID group-ID sph/rho/atom
* ID, group-ID are documented in :doc:`compute <compute>` command
* meso/rho/atom = style name of this compute command
* sph/rho/atom = style name of this compute command
Examples
""""""""
.. code-block:: LAMMPS
compute 1 all meso/rho/atom
compute 1 all sph/rho/atom
Description
"""""""""""
Define a computation that calculates the per-atom mesoscopic density
for each atom in a group.
Define a computation that calculates the per-atom SPH density for each
atom in a group, i.e. a Smooth-Particle Hydrodynamics density.
The mesoscopic density is the mass density of a mesoscopic particle,
calculated by kernel function interpolation using "pair style
sph/rhosum".
The SPH density is the mass density of an SPH particle, calculated by
kernel function interpolation using "pair style sph/rhosum".
See `this PDF guide <USER/sph/SPH_LAMMPS_userguide.pdf>`_ to using SPH in
LAMMPS.
The value of the mesoscopic density will be 0.0 for atoms not in the
The value of the SPH density will be 0.0 for atoms not in the
specified compute group.
**Output info:**

View File

@ -1,6 +1,6 @@
.. index:: compute meso/t/atom
.. index:: compute sph/t/atom
compute meso/t/atom command
compute sph/t/atom command
===========================
Syntax
@ -8,17 +8,17 @@ Syntax
.. parsed-literal::
compute ID group-ID meso/t/atom
compute ID group-ID sph/t/atom
* ID, group-ID are documented in :doc:`compute <compute>` command
* meso/t/atom = style name of this compute command
* sph/t/atom = style name of this compute command
Examples
""""""""
.. code-block:: LAMMPS
compute 1 all meso/t/atom
compute 1 all sph/t/atom
Description
"""""""""""
@ -27,8 +27,8 @@ Define a computation that calculates the per-atom internal temperature
for each atom in a group.
The internal temperature is the ratio of internal energy over the heat
capacity associated with the internal degrees of freedom of a mesoscopic
particles, e.g. a Smooth-Particle Hydrodynamics particle.
capacity associated with the internal degrees of freedom of an SPH
particles, i.e. a Smooth-Particle Hydrodynamics particle.
.. math::

View File

@ -238,9 +238,7 @@ accelerated styles exist.
* :doc:`lb/viscous <fix_lb_viscous>` -
* :doc:`lineforce <fix_lineforce>` - constrain atoms to move in a line
* :doc:`manifoldforce <fix_manifoldforce>` - restrain atoms to a manifold during minimization
* :doc:`meso <fix_meso>` - time integration for SPH/DPDE particles
* :doc:`meso/move <fix_meso_move>` - move mesoscopic SPH/SDPD particles in a prescribed fashion
* :doc:`meso/stationary <fix_meso_stationary>` -
* :doc:`momentum <fix_momentum>` - zero the linear and/or angular momentum of a group of atoms
* :doc:`move <fix_move>` - move atoms in a prescribed fashion
* :doc:`mscg <fix_mscg>` - apply MSCG method for force-matching to generate coarse grain models
@ -345,6 +343,8 @@ accelerated styles exist.
* :doc:`smd/move_tri_surf <fix_smd_move_triangulated_surface>` -
* :doc:`smd/setvel <fix_smd_setvel>` -
* :doc:`smd/wall_surface <fix_smd_wall_surface>` -
* :doc:`sph <fix_sph>` - time integration for SPH/DPDE particles
* :doc:`sph/stationary <fix_sph_stationary>` -
* :doc:`spring <fix_spring>` - apply harmonic spring force to group of atoms
* :doc:`spring/chunk <fix_spring_chunk>` - apply harmonic spring force to each chunk of atoms
* :doc:`spring/rg <fix_spring_rg>` - spring on radius of gyration of group of atoms

View File

@ -60,17 +60,19 @@ internal energy and extrapolated velocity are also updated.
.. note::
The particles affected by this fix should not be time integrated
by other fixes (e.g. :doc:`fix meso <fix_meso>`, :doc:`fix meso/stationary <fix_meso_stationary>`), since that will change their
The particles affected by this fix should not be time integrated by
other fixes (e.g. :doc:`fix sph <fix_sph>`, :doc:`fix
sph/stationary <fix_sph_stationary>`), since that will change their
positions and velocities twice.
.. note::
As particles move due to this fix, they will pass through periodic
boundaries and be remapped to the other side of the simulation box,
just as they would during normal time integration (e.g. via the :doc:`fix meso <fix_meso>` command). It is up to you to decide whether periodic
boundaries are appropriate with the kind of particle motion you are
prescribing with this fix.
just as they would during normal time integration (e.g. via the
:doc:`fix sph <fix_sph>` command). It is up to you to decide
whether periodic boundaries are appropriate with the kind of
particle motion you are prescribing with this fix.
.. note::
@ -100,7 +102,7 @@ specified, *V* is the specified velocity vector with components
specified. This style also sets the velocity of each particle to V =
(Vx,Vy,Vz). If any of the velocity components is specified as NULL,
then the position and velocity of that component is time integrated
the same as the :doc:`fix meso <fix_meso>` command would perform, using
the same as the :doc:`fix sph <fix_sph>` command would perform, using
the corresponding force component on the particle.
Note that the *linear* style is identical to using the *variable*
@ -128,7 +130,7 @@ elapsed since the fix was specified. This style also sets the
velocity of each particle to the time derivative of this expression.
If any of the amplitude components is specified as NULL, then the
position and velocity of that component is time integrated the same as
the :doc:`fix meso <fix_meso>` command would perform, using the
the :doc:`fix sph <fix_sph>` command would perform, using the
corresponding force component on the particle.
Note that the *wiggle* style is identical to using the *variable*
@ -180,15 +182,15 @@ particle.
Any of the 6 variables can be specified as NULL. If both the
displacement and velocity variables for a particular x,y,z component
are specified as NULL, then the position and velocity of that
component is time integrated the same as the :doc:`fix meso <fix_meso>`
component is time integrated the same as the :doc:`fix sph <fix_sph>`
command would perform, using the corresponding force component on the
particle. If only the velocity variable for a component is specified as
NULL, then the displacement variable will be used to set the position
of the particle, and its velocity component will not be changed. If only
the displacement variable for a component is specified as NULL, then
the velocity variable will be used to set the velocity of the particle,
and the position of the particle will be time integrated using that
velocity.
particle. If only the velocity variable for a component is specified
as NULL, then the displacement variable will be used to set the
position of the particle, and its velocity component will not be
changed. If only the displacement variable for a component is
specified as NULL, then the velocity variable will be used to set the
velocity of the particle, and the position of the particle will be
time integrated using that velocity.
The *units* keyword determines the meaning of the distance units used
to define the *linear* velocity and *wiggle* amplitude and *rotate*
@ -236,17 +238,18 @@ Restrictions
""""""""""""
This fix is part of the USER-SDPD package. It is only enabled if
LAMMPS was built with that package. See the :doc:`Build package <Build_package>` doc page for more info.
LAMMPS was built with that package. See the :doc:`Build package
<Build_package>` doc page for more info.
This fix requires that atoms store density and internal energy as
defined by the :doc:`atom_style meso <atom_style>` command.
defined by the :doc:`atom_style sph <atom_style>` command.
All particles in the group must be mesoscopic SPH/SDPD particles.
Related commands
""""""""""""""""
:doc:`fix move <fix_move>`, :doc:`fix meso <fix_meso>`,
:doc:`fix move <fix_move>`, :doc:`fix sph <fix_sph>`,
:doc:`displace_atoms <displace_atoms>`
Default

View File

@ -75,19 +75,21 @@ internal energy and extrapolated velocity are also updated.
.. note::
You should not update the particles in rigid bodies via other
time-integration fixes (e.g. :doc:`fix meso <fix_meso>`,
:doc:`fix meso/stationary <fix_meso_stationary>`), or you will have conflicting
updates to positions and velocities resulting in unphysical behavior in most
cases. When performing a hybrid simulation with some atoms in rigid bodies,
and some not, a separate time integration fix like :doc:`fix meso <fix_meso>`
should be used for the non-rigid particles.
time-integration fixes (e.g. :doc:`fix sph <fix_sph>`, :doc:`fix
sph/stationary <fix_sph_stationary>`), or you will have conflicting
updates to positions and velocities resulting in unphysical
behavior in most cases. When performing a hybrid simulation with
some atoms in rigid bodies, and some not, a separate time
integration fix like :doc:`fix sph <fix_sph>` should be used for
the non-rigid particles.
.. note::
These fixes are overkill if you simply want to hold a collection
of particles stationary or have them move with a constant velocity. To
hold particles stationary use :doc:`fix meso/stationary <fix_meso_stationary>` instead. If you would like to
move particles with a constant velocity use :doc:`fix meso/move <fix_meso_move>`.
These fixes are overkill if you simply want to hold a collection of
particles stationary or have them move with a constant velocity. To
hold particles stationary use :doc:`fix sph/stationary
<fix_sph_stationary>` instead. If you would like to move particles
with a constant velocity use :doc:`fix meso/move <fix_meso_move>`.
.. warning::
@ -346,7 +348,7 @@ package. It is only enabled if LAMMPS was built with both packages. See
the :doc:`Build package <Build_package>` doc page for more info.
This fix requires that atoms store density and internal energy as
defined by the :doc:`atom_style meso <atom_style>` command.
defined by the :doc:`atom_style sph <atom_style>` command.
All particles in the group must be mesoscopic SPH/SDPD particles.

View File

@ -1,6 +1,6 @@
.. index:: fix meso
.. index:: fix sph
fix meso command
fix sph command
================
Syntax
@ -8,25 +8,26 @@ Syntax
.. parsed-literal::
fix ID group-ID meso
fix ID group-ID sph
* ID, group-ID are documented in :doc:`fix <fix>` command
* meso = style name of this fix command
* sph = style name of this fix command
Examples
""""""""
.. code-block:: LAMMPS
fix 1 all meso
fix 1 all sph
Description
"""""""""""
Perform time integration to update position, velocity, internal energy
and local density for atoms in the group each timestep. This fix is
needed to time-integrate mesoscopic systems where particles carry
internal variables such as SPH or DPDE.
needed to time-integrate SPH systems where particles carry internal
variables such as internal energy. SPH stands for Smoothed Particle
Hydrodynamics.
See `this PDF guide <USER/sph/SPH_LAMMPS_userguide.pdf>`_ to using SPH in
LAMMPS.
@ -48,6 +49,6 @@ LAMMPS was built with that package. See the :doc:`Build package <Build_package>
Related commands
""""""""""""""""
"fix meso/stationary"
:doc:`fix sph/stationary <fix_sph_stationary>`
**Default:** none

View File

@ -1,6 +1,6 @@
.. index:: fix meso/stationary
.. index:: fix sph/stationary
fix meso/stationary command
fix sph/stationary command
===========================
Syntax
@ -8,17 +8,17 @@ Syntax
.. parsed-literal::
fix ID group-ID meso/stationary
fix ID group-ID sph/stationary
* ID, group-ID are documented in :doc:`fix <fix>` command
* meso = style name of this fix command
* sph = style name of this fix command
Examples
""""""""
.. code-block:: LAMMPS
fix 1 boundary meso/stationary
fix 1 boundary sph/stationary
Description
"""""""""""
@ -27,7 +27,7 @@ Perform time integration to update internal energy and local density,
but not position or velocity for atoms in the group each timestep.
This fix is needed for SPH simulations to correctly time-integrate
fixed boundary particles which constrain a fluid to a given region in
space.
space. SPH stands for Smoothed Particle Hydrodynamics.
See `this PDF guide <USER/sph/SPH_LAMMPS_userguide.pdf>`_ to using SPH in
LAMMPS.
@ -49,6 +49,6 @@ LAMMPS was built with that package. See the :doc:`Build package <Build_package>
Related commands
""""""""""""""""
"fix meso"
:doc:`fix sph <fix_sph>`
**Default:** none

View File

@ -107,11 +107,11 @@ command, after the third read_data command is used.
The *add*\ , *offset*\ , *shift*\ , *extra*\ , and *group* keywords are
useful in this context.
If a simulation box does not yet exist, the *add* keyword
cannot be used; the read_data command is being used for the first
time. If a simulation box does exist, due to using the
:doc:`create_box <create_box>` command, or a previous read_data command,
then the *add* keyword must be used.
If a simulation box does not yet exist, the *add* keyword cannot be
used; the read_data command is being used for the first time. If a
simulation box does exist, due to using the :doc:`create_box
<create_box>` command, or a previous read_data command, then the *add*
keyword must be used.
.. note::
@ -571,68 +571,69 @@ appended to it, which indicate which image of a periodic simulation
box the atom is in. These may be important to include for some kinds
of analysis.
+------------+---------------------------------------------------------------------------+
| angle | atom-ID molecule-ID atom-type x y z |
+------------+---------------------------------------------------------------------------+
| atomic | atom-ID atom-type x y z |
+------------+---------------------------------------------------------------------------+
| body | atom-ID atom-type bodyflag mass x y z |
+------------+---------------------------------------------------------------------------+
| bond | atom-ID molecule-ID atom-type x y z |
+------------+---------------------------------------------------------------------------+
| charge | atom-ID atom-type q x y z |
+------------+---------------------------------------------------------------------------+
| dipole | atom-ID atom-type q x y z mux muy muz |
+------------+---------------------------------------------------------------------------+
| dpd | atom-ID atom-type theta x y z |
+------------+---------------------------------------------------------------------------+
| edpd | atom-ID atom-type edpd_temp edpd_cv x y z |
+------------+---------------------------------------------------------------------------+
| mdpd | atom-ID atom-type rho x y z |
+------------+---------------------------------------------------------------------------+
| tdpd | atom-ID atom-type x y z cc1 cc2 ... ccNspecies |
+------------+---------------------------------------------------------------------------+
| electron | atom-ID atom-type q spin eradius x y z |
+------------+---------------------------------------------------------------------------+
| ellipsoid | atom-ID atom-type ellipsoidflag density x y z |
+------------+---------------------------------------------------------------------------+
| full | atom-ID molecule-ID atom-type q x y z |
+------------+---------------------------------------------------------------------------+
| line | atom-ID molecule-ID atom-type lineflag density x y z |
+------------+---------------------------------------------------------------------------+
| meso | atom-ID atom-type rho e cv x y z |
+------------+---------------------------------------------------------------------------+
| molecular | atom-ID molecule-ID atom-type x y z |
+------------+---------------------------------------------------------------------------+
| peri | atom-ID atom-type volume density x y z |
+------------+---------------------------------------------------------------------------+
| smd | atom-ID atom-type molecule volume mass kernel-radius contact-radius x y z |
+------------+---------------------------------------------------------------------------+
| sphere | atom-ID atom-type diameter density x y z |
+------------+---------------------------------------------------------------------------+
| spin | atom-ID atom-type sp x y z spx spy spz |
+------------+---------------------------------------------------------------------------+
| template | atom-ID molecule-ID template-index template-atom atom-type x y z |
+------------+---------------------------------------------------------------------------+
| tri | atom-ID molecule-ID atom-type triangleflag density x y z |
+------------+---------------------------------------------------------------------------+
| wavepacket | atom-ID atom-type charge spin eradius etag cs_re cs_im x y z |
+------------+---------------------------------------------------------------------------+
| hybrid | atom-ID atom-type x y z sub-style1 sub-style2 ... |
+------------+---------------------------------------------------------------------------+
.. list-table::
* - angle
- atom-ID molecule-ID atom-type x y z
* - atomic
- atom-ID atom-type x y z
* - body
- atom-ID atom-type bodyflag mass x y z
* - bond
- atom-ID molecule-ID atom-type x y z
* - charge
- atom-type q x y z
* - dipole
- atom-ID atom-type q x y z mux muy muz
* - dpd
- atom-ID atom-type theta x y z
* - edpd
- atom-ID atom-type edpd_temp edpd_cv x y z
* - electron
- atom-ID atom-type q spin eradius x y z
* - ellipsoid
- atom-ID atom-type ellipsoidflag density x y z
* - full
- atom-ID molecule-ID atom-type q x y z
* - line
- atom-ID molecule-ID atom-type lineflag density x y z
* - mdpd
- atom-ID atom-type rho x y z
* - molecular
- atom-ID molecule-ID atom-type x y z
* - peri
- atom-ID atom-type volume density x y z
* - smd
- atom-ID atom-type molecule volume mass kernel-radius contact-radius x0 y0 z0 x y z
* - sph
- atom-ID atom-type rho esph cv x y z
* - sphere
- atom-ID atom-type diameter density x y z
* - spin
- atom-ID atom-type x y z spx spy spz sp
* - tdpd
- atom-ID atom-type x y z cc1 cc2 ... ccNspecies
* - template
- atom-ID molecule-ID template-index template-atom atom-type x y z
* - tri
- atom-ID molecule-ID atom-type triangleflag density x y z
* - wavepacket
- atom-ID atom-type charge spin eradius etag cs_re cs_im x y z
* - hybrid
- atom-ID atom-type x y z sub-style1 sub-style2 ...
The per-atom values have these meanings and units, listed alphabetically:
* atom-ID = integer ID of atom
* atom-type = type of atom (1-Ntype)
* bodyflag = 1 for body particles, 0 for point particles
* cc = chemical concentration for tDPD particles for each species (mole/volume units)
* ccN = chemical concentration for tDPD particles for each species (mole/volume units)
* contact-radius = ??? (distance units)
* cs_re,cs_im = real/imaginary parts of wave packet coefficients
* cv = heat capacity (need units) for SPH particles
* density = density of particle (mass/distance\^3 or mass/distance\^2 or mass/distance units, depending on dimensionality of particle)
* diameter = diameter of spherical atom (distance units)
* e = energy (need units) for SPH particles
* esph = energy (need units) for SPH particles
* edpd_temp = temperature for eDPD particles (temperature units)
* edpd_cv = volumetric heat capacity for eDPD particles (energy/temperature/volume units)
* ellipsoidflag = 1 for ellipsoidal particles, 0 for point particles
@ -646,14 +647,15 @@ The per-atom values have these meanings and units, listed alphabetically:
* q = charge on atom (charge units)
* rho = density (need units) for SPH particles
* spin = electron spin (+1/-1), 0 = nuclei, 2 = fixed-core, 3 = pseudo-cores (i.e. ECP)
* sp = norm of magnetic spin of atom (in number of Bohr magnetons)
* spx,spy,spz = components of magnetic spin of atom (adim normalized vector)
* sp = magnitude of magnetic spin of atom (Bohr magnetons)
* spx,spy,spz = components of magnetic spin of atom (unit vector)
* template-atom = which atom within a template molecule the atom is
* template-index = which molecule within the molecule template the atom is part of
* theta = internal temperature of a DPD particle
* triangleflag = 1 for triangular particles, 0 for point or spherical particles
* volume = volume of Peridynamic particle (distance\^3 units)
* x,y,z = coordinates of atom (distance units)
* x0,y0,z0 = original (strain-free) coordinates of atom (distance units)
The units for these quantities depend on the unit style; see the
:doc:`units <units>` command for details.
@ -715,17 +717,18 @@ as spheres when converting density to mass. However, they can also be
modeled as 2d discs (circles) if the :doc:`set density/disc <set>`
command is used to reset their mass after the read_data command is
used. A *disc* keyword can also be used with time integration fixes,
such as :doc:`fix nve/sphere <fix_nve_sphere>` and :doc:`fix nvt/sphere <fix_nve_sphere>` to time integrate their motion as 2d
such as :doc:`fix nve/sphere <fix_nve_sphere>` and :doc:`fix
nvt/sphere <fix_nve_sphere>` to time integrate their motion as 2d
discs (not 3d spheres), by changing their moment of inertia.
For atom_style hybrid, following the 5 initial values (ID,type,x,y,z),
specific values for each sub-style must be listed. The order of the
sub-styles is the same as they were listed in the
:doc:`atom_style <atom_style>` command. The sub-style specific values
are those that are not the 5 standard ones (ID,type,x,y,z). For
example, for the "charge" sub-style, a "q" value would appear. For
the "full" sub-style, a "molecule-ID" and "q" would appear. These are
listed in the same order they appear as listed above. Thus if
For atom\_style hybrid, following the 5 initial values
(ID,type,x,y,z), specific values for each sub-style must be listed.
The order of the sub-styles is the same as they were listed in the
:doc:`atom_style <atom_style>` command. The specific values for each
sub-style are those that are not the 5 standard ones (ID,type,x,y,z).
For example, for the "charge" sub-style, a "q" value would appear.
For the "full" sub-style, a "molecule-ID" and "q" would appear. These
are listed in the same order they appear as listed above. Thus if
.. parsed-literal::
@ -738,12 +741,14 @@ were used in the input script, each atom line would have these fields:
atom-ID atom-type x y z q diameter density
Note that if a non-standard value is defined by multiple sub-styles,
it must appear multiple times in the atom line. E.g. the atom line
for atom_style hybrid dipole full would list "q" twice:
it only appears once in the atom line. E.g. the atom line for
atom_style hybrid dipole full would list "q" only once, with the
dipole sub-style fields; "q" does not appear with the full sub-style
fields.
.. parsed-literal::
atom-ID atom-type x y z q mux muy myz molecule-ID q
atom-ID atom-type x y z q mux muy myz molecule-ID
Atom lines specify the (x,y,z) coordinates of atoms. These can be
inside or outside the simulation box. When the data file is read,
@ -1176,9 +1181,9 @@ pair style. See the :doc:`pair_style <pair_style>` and
:doc:`pair_coeff <pair_coeff>` commands for details. Since pair
coefficients for types I != J are not specified, these will be
generated automatically by the pair style's mixing rule. See the
individual pair_style doc pages and the :doc:`pair_modify mix <pair_modify>` command for details. Pair coefficients can also
be set via the :doc:`pair_coeff <pair_coeff>` command in the input
script.
individual pair_style doc pages and the :doc:`pair_modify mix
<pair_modify>` command for details. Pair coefficients can also be set
via the :doc:`pair_coeff <pair_coeff>` command in the input script.
----------
@ -1200,15 +1205,15 @@ script.
3 3 0.022 2.35197 0.022 2.35197
3 5 0.022 2.35197 0.022 2.35197
This section must have N\*(N+1)/2 lines where N = # of atom types. The
number and meaning of the coefficients are specific to the defined
This section must have N\*(N+1)/2 lines where N = # of atom types.
The number and meaning of the coefficients are specific to the defined
pair style. See the :doc:`pair_style <pair_style>` and
:doc:`pair_coeff <pair_coeff>` commands for details. Since pair
coefficients for types I != J are all specified, these values will
turn off the default mixing rule defined by the pair style. See the
individual pair_style doc pages and the :doc:`pair_modify mix <pair_modify>` command for details. Pair coefficients can also
be set via the :doc:`pair_coeff <pair_coeff>` command in the input
script.
individual pair_style doc pages and the :doc:`pair_modify mix
<pair_modify>` command for details. Pair coefficients can also be set
via the :doc:`pair_coeff <pair_coeff>` command in the input script.
----------

View File

@ -13,7 +13,7 @@ Syntax
* style = *atom* or *type* or *mol* or *group* or *region*
* ID = atom ID range or type range or mol ID range or group ID or region ID
* one or more keyword/value pairs may be appended
* keyword = *type* or *type/fraction* or *type/ratio* or *type/subset* or *mol* or *x* or *y* or *z* or *charge* or *dipole* or *dipole/random* or *quat* or *spin* or *spin/random* or *quat* or *quat/random* or *diameter* or *shape* or *length* or *tri* or *theta* or *theta/random* or *angmom* or *omega* or *mass* or *density* or *density/disc* or *volume* or *image* or *bond* or *angle* or *dihedral* or *improper* or *meso/e* or *meso/cv* or *meso/rho* or *smd/contact/radius* or *smd/mass/density* or *dpd/theta* or *edpd/temp* or *edpd/cv* or *cc* or *i_name* or *d_name*
* keyword = *type* or *type/fraction* or *type/ratio* or *type/subset* or *mol* or *x* or *y* or *z* or *charge* or *dipole* or *dipole/random* or *quat* or *spin* or *spin/random* or *quat* or *quat/random* or *diameter* or *shape* or *length* or *tri* or *theta* or *theta/random* or *angmom* or *omega* or *mass* or *density* or *density/disc* or *volume* or *image* or *bond* or *angle* or *dihedral* or *improper* or *sph/e* or *sph/cv* or *sph/rho* or *smd/contact/radius* or *smd/mass/density* or *dpd/theta* or *edpd/temp* or *edpd/cv* or *cc* or *i_name* or *d_name*
.. parsed-literal::
@ -94,11 +94,11 @@ Syntax
*angle* value = angle type for all angles between selected atoms
*dihedral* value = dihedral type for all dihedrals between selected atoms
*improper* value = improper type for all impropers between selected atoms
*meso/e* value = energy of SPH particles (need units)
*sph/e* value = energy of SPH particles (need units)
value can be an atom-style variable (see below)
*meso/cv* value = heat capacity of SPH particles (need units)
*sph/cv* value = heat capacity of SPH particles (need units)
value can be an atom-style variable (see below)
*meso/rho* value = density of SPH particles (need units)
*sph/rho* value = density of SPH particles (need units)
value can be an atom-style variable (see below)
*smd/contact/radius* = radius for short range interactions, i.e. contact and friction
value can be an atom-style variable (see below)
@ -299,29 +299,31 @@ for each particle set by this command. This keyword does not allow
use of an atom-style variable.
Keyword *diameter* sets the size of the selected atoms. The particles
must be finite-size spheres as defined by the :doc:`atom_style sphere <atom_style>` command. The diameter of a particle can be
set to 0.0, which means they will be treated as point particles. Note
that this command does not adjust the particle mass, even if it was
defined with a density, e.g. via the :doc:`read_data <read_data>`
command.
must be finite-size spheres as defined by the :doc:`atom_style sphere
<atom_style>` command. The diameter of a particle can be set to 0.0,
which means they will be treated as point particles. Note that this
command does not adjust the particle mass, even if it was defined with
a density, e.g. via the :doc:`read_data <read_data>` command.
Keyword *shape* sets the size and shape of the selected atoms. The
particles must be ellipsoids as defined by the :doc:`atom_style ellipsoid <atom_style>` command. The *Sx*\ , *Sy*\ , *Sz* settings are
the 3 diameters of the ellipsoid in each direction. All 3 can be set
to the same value, which means the ellipsoid is effectively a sphere.
They can also all be set to 0.0 which means the particle will be
treated as a point particle. Note that this command does not adjust
the particle mass, even if it was defined with a density, e.g. via the
:doc:`read_data <read_data>` command.
particles must be ellipsoids as defined by the :doc:`atom_style
ellipsoid <atom_style>` command. The *Sx*\ , *Sy*\ , *Sz* settings
are the 3 diameters of the ellipsoid in each direction. All 3 can be
set to the same value, which means the ellipsoid is effectively a
sphere. They can also all be set to 0.0 which means the particle will
be treated as a point particle. Note that this command does not
adjust the particle mass, even if it was defined with a density,
e.g. via the :doc:`read_data <read_data>` command.
Keyword *length* sets the length of selected atoms. The particles
must be line segments as defined by the :doc:`atom_style line <atom_style>` command. If the specified value is non-zero the
line segment is (re)set to a length = the specified value, centered
around the particle position, with an orientation along the x-axis.
If the specified value is 0.0, the particle will become a point
particle. Note that this command does not adjust the particle mass,
even if it was defined with a density, e.g. via the
:doc:`read_data <read_data>` command.
must be line segments as defined by the :doc:`atom_style line
<atom_style>` command. If the specified value is non-zero the line
segment is (re)set to a length = the specified value, centered around
the particle position, with an orientation along the x-axis. If the
specified value is 0.0, the particle will become a point particle.
Note that this command does not adjust the particle mass, even if it
was defined with a density, e.g. via the :doc:`read_data <read_data>`
command.
Keyword *tri* sets the size of selected atoms. The particles must be
triangles as defined by the :doc:`atom_style tri <atom_style>` command.
@ -335,7 +337,8 @@ does not adjust the particle mass, even if it was defined with a
density, e.g. via the :doc:`read_data <read_data>` command.
Keyword *theta* sets the orientation of selected atoms. The particles
must be line segments as defined by the :doc:`atom_style line <atom_style>` command. The specified value is used to set the
must be line segments as defined by the :doc:`atom_style line
<atom_style>` command. The specified value is used to set the
orientation angle of the line segments with respect to the x axis.
Keyword *theta/random* randomizes the orientation of theta for the
@ -346,44 +349,47 @@ regardless of how many processors are being used. This keyword does
not allow use of an atom-style variable.
Keyword *angmom* sets the angular momentum of selected atoms. The
particles must be ellipsoids as defined by the :doc:`atom_style ellipsoid <atom_style>` command or triangles as defined by the
:doc:`atom_style tri <atom_style>` command. The angular momentum vector
of the particles is set to the 3 specified components.
particles must be ellipsoids as defined by the :doc:`atom_style
ellipsoid <atom_style>` command or triangles as defined by the
:doc:`atom_style tri <atom_style>` command. The angular momentum
vector of the particles is set to the 3 specified components.
Keyword *omega* sets the angular velocity of selected atoms. The
particles must be spheres as defined by the
:doc:`atom_style sphere <atom_style>` command. The angular velocity
vector of the particles is set to the 3 specified components.
particles must be spheres as defined by the :doc:`atom_style sphere
<atom_style>` command. The angular velocity vector of the particles
is set to the 3 specified components.
Keyword *mass* sets the mass of all selected particles. The particles
must have a per-atom mass attribute, as defined by the
:doc:`atom_style <atom_style>` command. See the "mass" command for how
to set mass values on a per-type basis.
:doc:`atom_style <atom_style>` command. See the "mass" command for
how to set mass values on a per-type basis.
Keyword *density* or *density/disc* also sets the mass of all selected
particles, but in a different way. The particles must have a per-atom
mass attribute, as defined by the :doc:`atom_style <atom_style>`
command. If the atom has a radius attribute (see :doc:`atom_style sphere <atom_style>`) and its radius is non-zero, its mass is set
from the density and particle volume for 3d systems (the input density
is assumed to be in mass/distance\^3 units). For 2d, the default is
for LAMMPS to model particles with a radius attribute as spheres.
command. If the atom has a radius attribute (see :doc:`atom_style
sphere <atom_style>`) and its radius is non-zero, its mass is set from
the density and particle volume for 3d systems (the input density is
assumed to be in mass/distance\^3 units). For 2d, the default is for
LAMMPS to model particles with a radius attribute as spheres.
However, if the *density/disc* keyword is used, then they can be
modeled as 2d discs (circles). Their mass is set from the density and
particle area (the input density is assumed to be in mass/distance\^2
units).
If the atom has a shape attribute (see :doc:`atom_style ellipsoid <atom_style>`) and its 3 shape parameters are non-zero,
then its mass is set from the density and particle volume (the input
density is assumed to be in mass/distance\^3 units). The
*density/disc* keyword has no effect; it does not (yet) treat 3d
ellipsoids as 2d ellipses.
If the atom has a shape attribute (see :doc:`atom_style ellipsoid
<atom_style>`) and its 3 shape parameters are non-zero, then its mass
is set from the density and particle volume (the input density is
assumed to be in mass/distance\^3 units). The *density/disc* keyword
has no effect; it does not (yet) treat 3d ellipsoids as 2d ellipses.
If the atom has a length attribute (see :doc:`atom_style line <atom_style>`) and its length is non-zero, then its mass is
set from the density and line segment length (the input density is
assumed to be in mass/distance units). If the atom has an area
attribute (see :doc:`atom_style tri <atom_style>`) and its area is
non-zero, then its mass is set from the density and triangle area (the
input density is assumed to be in mass/distance\^2 units).
If the atom has a length attribute (see :doc:`atom_style line
<atom_style>`) and its length is non-zero, then its mass is set from
the density and line segment length (the input density is assumed to
be in mass/distance units). If the atom has an area attribute (see
:doc:`atom_style tri <atom_style>`) and its area is non-zero, then its
mass is set from the density and triangle area (the input density is
assumed to be in mass/distance\^2 units).
If none of these cases are valid, then the mass is set to the density
value directly (the input density is assumed to be in mass units).
@ -399,14 +405,15 @@ defined. A value of 2 means add 2 box lengths to get the true value.
A value of -1 means subtract 1 box length to get the true value.
LAMMPS updates these flags as atoms cross periodic boundaries during
the simulation. The flags can be output with atom snapshots via the
:doc:`dump <dump>` command. If a value of NULL is specified for any of
nx,ny,nz, then the current image value for that dimension is unchanged.
For non-periodic dimensions only a value of 0 can be specified.
This command can be useful after a system has been equilibrated and
atoms have diffused one or more box lengths in various directions.
This command can then reset the image values for atoms so that they
are effectively inside the simulation box, e.g if a diffusion
coefficient is about to be measured via the :doc:`compute msd <compute_msd>` command. Care should be taken not to reset the
:doc:`dump <dump>` command. If a value of NULL is specified for any
of nx,ny,nz, then the current image value for that dimension is
unchanged. For non-periodic dimensions only a value of 0 can be
specified. This command can be useful after a system has been
equilibrated and atoms have diffused one or more box lengths in
various directions. This command can then reset the image values for
atoms so that they are effectively inside the simulation box, e.g if a
diffusion coefficient is about to be measured via the :doc:`compute
msd <compute_msd>` command. Care should be taken not to reset the
image flags of two atoms in a bond to the same value if the bond
straddles a periodic boundary (rather they should be different by +/-
1). This will not affect the dynamics of a simulation, but may mess
@ -423,10 +430,10 @@ etc) was set by the *bond types* (\ *angle types*\ , etc) field in the
header of the data file read by the :doc:`read_data <read_data>`
command. These keywords do not allow use of an atom-style variable.
Keywords *meso/e*\ , *meso/cv*\ , and *meso/rho* set the energy, heat
Keywords *sph/e*\ , *sph/cv*\ , and *sph/rho* set the energy, heat
capacity, and density of smoothed particle hydrodynamics (SPH)
particles. See `this PDF guide <USER/sph/SPH_LAMMPS_userguide.pdf>`_ to
using SPH in LAMMPS.
particles. See `this PDF guide <USER/sph/SPH_LAMMPS_userguide.pdf>`_
to using SPH in LAMMPS.
Keyword *smd/mass/density* sets the mass of all selected particles,
but it is only applicable to the Smooth Mach Dynamics package

View File

@ -327,6 +327,7 @@ ccache
ccachepiecewise
ccl
ccmake
ccN
ccNspecies
CCu
cd
@ -593,6 +594,7 @@ Derjaguin
Derlet
Deserno
Destree
destructor
detils
Devanathan
devel
@ -833,6 +835,7 @@ Espanol
Eshelby
eshelby
eskm
esph
esu
esub
esw

View File

@ -10,7 +10,7 @@ velocity all create 1.44 320984 loop geom
neighbor 0.3 bin
neigh_modify delay 0 every 1 check yes
neigh_modify exclude molecule all
neigh_modify exclude molecule/intra all
pair_style line/lj 2.5
pair_coeff * * 1.0 1.0 1.0 0.25 2.5
@ -33,8 +33,10 @@ compute 2 all ke
compute 3 all pe
variable toteng equal (c_1+c_2+c_3)/atoms
compute_modify thermo_temp extra/dof -350
thermo 1000
thermo_style custom step temp f_2 pe ke c_1 c_2 c_3 v_toteng
thermo_style custom step f_2 pe ke c_1 c_2 c_3 v_toteng
run 10000

View File

@ -36,7 +36,7 @@ velocity small create 1.44 87287 loop geom
neighbor 0.3 bin
neigh_modify delay 0 every 1 check yes
neigh_modify exclude molecule big include big
neigh_modify exclude molecule/intra big include big
comm_modify mode multi group big vel yes
neigh_modify include big
@ -68,13 +68,15 @@ compute tbig big temp
variable pebig equal pe*atoms/count(big)
variable ebig equal etotal*atoms/count(big)
compute_modify tbig extra/dof -350
compute 1 big erotate/asphere
compute 2 all ke
compute 3 all pe
variable toteng equal (c_1+c_2+c_3)/atoms
thermo 1000
thermo_style custom step temp c_tsmall f_2[9] c_1 etotal &
thermo_style custom step c_tsmall f_2[9] c_1 etotal &
v_pebig v_ebig press
thermo_modify temp tbig

View File

@ -35,7 +35,7 @@ velocity small create 1.44 87287 loop geom
neighbor 0.3 bin
neigh_modify delay 0 every 1 check yes
neigh_modify exclude molecule big include big
neigh_modify exclude molecule/intra big include big
comm_modify mode multi group big vel yes
neigh_modify include big
@ -66,6 +66,8 @@ compute tbig big temp
variable pebig equal pe*atoms/count(big)
variable ebig equal etotal*atoms/count(big)
compute_modify tbig extra/dof -4500
compute 1 big erotate/asphere
compute 2 all ke
compute 3 all pe

View File

@ -1,5 +1,5 @@
# Input File for DPD fluid under isothermal conditions using the VV-SSA integration scheme
log log.dpd-shardlow
boundary p p p
units metal

View File

@ -1,6 +1,5 @@
# INPUT FILE FOR DPD_Fluid
log log.dpd-vv
boundary p p p
units metal # ev, ps

View File

@ -1,5 +1,5 @@
# Input File for DPD fluid under isoenergetic conditions using the VV-SSA integration scheme
log log.dpde-shardlow
boundary p p p
units metal # ev, ps

View File

@ -1,6 +1,5 @@
# INPUT FILE FOR DPD_Fluid
log log.dpde-vv
boundary p p p
units metal # ev, ps

View File

@ -1,5 +1,5 @@
# Input File for DPD fluid under isoenthalpic conditions using the VV-SSA integration scheme
log log.dpdh-shardlow
boundary p p p
units metal # ev, ps

View File

@ -1,5 +1,5 @@
# Input File for DPD fluid under isobaric conditions using the VV-SSA integration scheme
log log.dpdp-shardlow
boundary p p p
units metal

View File

@ -1,6 +1,5 @@
# Example for running DPD-RX
log log.dpdrx-shardlow
boundary p p p
units metal # ev, ps
atom_style dpd

View File

@ -1,5 +1,5 @@
# RDX coarse-grain model
log log.multi-lucy
units metal # ev, ps
atom_style dpd
atom_modify map array

View File

@ -1,5 +1,4 @@
variable sname index adamantane_ionized
log ${sname}.nve.log
units electron
newton on

View File

@ -1,5 +1,4 @@
variable sname index Be-solid
log ${sname}.spe.log
units electron
newton on

View File

@ -1,5 +1,4 @@
variable sname index ch4
log ${sname}.nve.log
units electron
newton on

View File

@ -1,5 +1,4 @@
variable sname index ch4
log ${sname}.nve.log
units electron
newton on

View File

@ -1,5 +1,4 @@
variable sname index ch4_ionized
log ${sname}.nvt.log
units electron
newton on
@ -15,6 +14,7 @@ pair_coeff * *
comm_modify vel yes
# minimize
min_style cg
min_modify line quadratic
minimize 0 1.0e-6 10000 100000

View File

@ -1,5 +1,4 @@
variable sname index h_atom.ang
log ${sname}.spe.log
units real
newton on

View File

@ -1,5 +1,4 @@
variable sname index h_atom.bohr
log ${sname}.spe.log
units electron
newton on

View File

@ -1,5 +1,4 @@
variable sname index h2
log ${sname}.spe.log
units electron
newton on
@ -47,4 +46,4 @@ unfix 3
#fix 1 all nve/eff
run 100000
run 10000

View File

@ -1,5 +1,4 @@
variable sname index h2bulk
log ${sname}.npt.log
units electron
newton on
@ -41,7 +40,8 @@ dump 2 all xyz 10000 ${sname}.npt.xyz
compute 1 all property/atom spin eradius
dump 3 all custom 10000 ${sname}.npt.lammpstrj id type x y z c_1[1] c_1[2]
run 10000000
thermo 1
run 10
unfix 1
undump 2

View File

@ -1,5 +1,4 @@
variable sname index h2bulk
log ${sname}.nve.log
units electron
newton on
@ -18,13 +17,13 @@ comm_modify vel yes
compute effTemp all temp/eff
thermo 1000
thermo 10
thermo_style custom step pe temp press
thermo_modify temp effTemp
# structure minimization
min_style cg
minimize 0 1.0e-4 1000 10000
minimize 0 1.0e-4 10 10
timestep 0.001
@ -41,7 +40,7 @@ dump 2 all xyz 1000 ${sname}.nve.xyz
compute 1 all property/atom spin eradius
dump 3 all custom 1000 ${sname}.nve.lammpstrj id type x y z c_1[1] c_1[2] c_peatom c_keatom
run 100000
run 10
unfix 1
#unfix 2

View File

@ -1,5 +1,4 @@
variable sname index h2bulk.ang
log ${sname}.nve.log
units real
newton on
@ -29,13 +28,13 @@ variable epauli equal c_energies[2]
variable ecoul equal c_energies[3]
variable erres equal c_energies[4]
thermo 100
thermo 10
thermo_style custom step etotal pe ke v_eke v_epauli v_ecoul v_erres press v_press temp
thermo_modify temp effTemp press effPress flush yes
# structure minimization
min_style cg
minimize 0 1.0e-4 1000 10000
minimize 0 1.0e-4 10 10
timestep 0.001
@ -52,7 +51,7 @@ dump 2 all xyz 1000 ${sname}.nve.xyz
compute 1 all property/atom spin eradius
dump 3 all custom 1000 ${sname}.nve.lammpstrj id type x y z c_1[1] c_1[2] c_peatom c_keatom
run 100000
run 10
unfix 1
#unfix 2

View File

@ -1,5 +1,4 @@
variable sname index Li-dendritic
log ${sname}.min.log
units electron
newton on
@ -7,8 +6,8 @@ boundary p p p
atom_style electron
#read_data data.${sname}
read_restart ${sname}.min.restart2
read_data data.${sname}
#read_restart ${sname}.min.restart2
pair_style eff/cut 50.112
pair_coeff * *

View File

@ -1,5 +1,4 @@
variable sname index Li-dendritic
log ${sname}.min.log
units electron
newton on
@ -29,7 +28,7 @@ compute 1 all property/atom spin eradius
#dump 1 all custom 100 ${sname}.min.lammpstrj id type x y z q c_1[1] c_1[2]
#dump 2 all xyz 100 ${sname}.min.xyz
min_modify line quadratic dmax 0.05
minimize 0 1.0e-7 1000 2000
minimize 0 1.0e-7 100 100
write_restart ${sname}.min.restart
@ -46,7 +45,7 @@ dump 1 all custom 100 ${sname}.nvt.lammpstrj id type x y z c_1[1] c_1
dump 2 all xyz 100 ${sname}.nvt.xyz
restart 100 ${sname}.nvt.restart1 ${sname}.nvt.restart2
run 10000
run 100
undump 1
undump 2

View File

@ -1,5 +1,4 @@
variable sname index Li.ang
log ${sname}.spe.log
units real
newton on
@ -46,13 +45,13 @@ fix 0 all temp/rescale/eff 1 10.0 3000.0 0.05 1.0
#fix 0 all langevin/eff 3000.0 3000.0 10.0 699483
fix 1 all nve/eff
run 1000
run 200
unfix 0
unfix 1
fix 1 all nvt/eff temp 3000.0 3000.0 100.0
compute 1 all property/atom spin eradius ervel
dump 1 all custom 1000 ${sname}.nvt.lammpstrj id type q c_1[1] c_1[2] x y z vx vy vz c_1[3]
dump 1 all custom 500 ${sname}.nvt.lammpstrj id type q c_1[1] c_1[2] x y z vx vy vz c_1[3]
run 100000
run 500

View File

@ -1,5 +1,4 @@
variable sname index Li.bohr
log ${sname}.spe.log
units electron
newton off
@ -35,15 +34,15 @@ thermo_style custom step etotal pe ke v_eke v_epauli v_estatics v_errestrain
thermo_modify temp effTemp press effPress
min_style cg
minimize 0 1e-6 100 2000
minimize 0 1e-6 100 200
fix 0 all temp/rescale/eff 1 0.0 3000.0 0.02 0.5
fix 1 all npt/eff temp 3000.0 3000.0 0.1 iso 1e7 1e7 1.0
compute 1 all property/atom spin eradius
dump 1 all custom 1 ${sname}.spe.lammpstrj &
dump 1 all custom 100 ${sname}.spe.lammpstrj &
id type q c_1[1] c_1[2] x y z
run 1000
run 100

View File

@ -1,6 +1,6 @@
dimension 2
units si
atom_style meso
atom_style sph
# create simulation box
region box block -0.050e-3 1.044e-3 -0.05e-3 1.044e-3 -1.0e-6 1.0e-6 units box
@ -28,7 +28,7 @@ group integrate_full union fluid driver
mass 3 2.0e-7
mass 2 2.0e-7
mass 1 4.0e-7
set group all meso/rho 1000.0
set group all sph/rho 1000.0
# use Tait's EOS in combination with Morris' laminar viscosity.
# We set rho_0 = 1000 kg/m^3, c = 0.1 m/s, h = 6.5e-5 m.
@ -37,8 +37,8 @@ pair_style hybrid sph/taitwater/morris
pair_coeff * * sph/taitwater/morris 1000 0.1 1.0e-3 6.5e-5
pair_coeff 2 3 none # exclude interaction between walls and shear driver
compute rho_peratom all meso/rho/atom
compute e_peratom all meso/e/atom
compute rho_peratom all sph/rho/atom
compute e_peratom all sph/e/atom
compute ke_peratom all ke/atom
compute esph all reduce sum c_e_peratom
compute ke all ke
@ -49,8 +49,8 @@ velocity driver set 0.001 0.0 0.0 units box
fix freeze_fix driver setforce 0.0 0.0 0.0
# do full time integration for shear driver and fluid, but keep walls stationary
fix integrate_fix_full integrate_full meso
fix integrate_fix_stationary walls meso/stationary
fix integrate_fix_full integrate_full sph
fix integrate_fix_stationary walls sph/stationary
dump dump_id all custom 100 dump.lammpstrj id type xs ys zs vx vy c_rho_peratom c_e_peratom
dump_modify dump_id first yes

View File

@ -1,4 +1,4 @@
# mesoscopic heat conduction
# SPH heat conduction
# heat flow from hot right region to cold left region
# compare the temperature profile at the end opf the simulation,
# contained in file dump.last, to analytic solution.
@ -6,7 +6,7 @@
#
dimension 2
units si
atom_style meso
atom_style sph
boundary f p p
lattice sq 0.01
@ -17,23 +17,23 @@ mass 1 1.0e-5
region left block EDGE 49.9 EDGE EDGE EDGE EDGE
region right block 50 EDGE EDGE EDGE EDGE EDGE
set region left meso/e 1.0 # internal energies
set region right meso/e 2.0
set group all meso/rho 0.1 # mesoscopic density is also needed for this pair style
set region left sph/e 1.0 # internal energies
set region right sph/e 2.0
set group all sph/rho 0.1 # SPH density is also needed for this pair style
# For correct temperature profiles, mescoscopic density and mass * number density must coincide!
pair_style sph/heatconduction
# i j diffusion coeff. cutoff
pair_coeff 1 1 1.0e-4 2.0e-2
compute ie_atom all meso/e/atom
compute ie_atom all sph/e/atom
compute ie all reduce sum c_ie_atom
thermo 10
thermo_style custom step temp c_ie
timestep 0.25e-1
neighbor 0.2e-2 bin
fix integrate_fix all meso/stationary
fix integrate_fix all sph/stationary
dump dump_fix all custom 10 dump.heat id type x y z c_ie_atom
dump_modify dump_fix first yes

View File

@ -1,11 +1,11 @@
# mesoscopic heat conduction
# SPH heat conduction
# heat flow from hot right region to cold left region
# compare the temperature profile at the end opf the simulation,
# contained in file dump.last, to analytic solution.
#
#
units si
atom_style meso
atom_style sph
newton on
boundary f p p
@ -17,9 +17,9 @@ mass 1 1.0e-5
region left block EDGE 49.9 EDGE EDGE EDGE EDGE
region right block 50 EDGE EDGE EDGE EDGE EDGE
set region left meso/e 1.0 # internal energies
set region right meso/e 2.0
set group all meso/rho 10.0 # mesoscopic density is also needed for this pair style
set region left sph/e 1.0 # internal energies
set region right sph/e 2.0
set group all sph/rho 10.0 # SPH density is also needed for this pair style
# For correct temperature profiles, mescoscopic density and mass * number density must coincide!
pair_style sph/heatconduction
@ -28,13 +28,13 @@ pair_coeff 1 1 1.0e-4 2.0e-2
neighbor 0.2e-2 bin
neigh_modify every 20 delay 0 check no
compute ie_atom all meso/e/atom
compute ie_atom all sph/e/atom
compute ie all reduce sum c_ie_atom
thermo_style custom step temp c_ie
thermo_modify norm no
fix integrate_fix all meso/stationary
fix integrate_fix all sph/stationary
thermo 10
timestep 0.25e-1

View File

@ -1,4 +1,4 @@
atom_style meso
atom_style sph
dimension 2
boundary s p p
@ -13,20 +13,20 @@ set region right type 2
mass 1 1
mass 2 0.25
set type 1 meso/e 2.5 # internal energy corresponding to p=1, rho=1
set type 2 meso/e 0.625 # internal energy corresponding to p=0.25, rho=0.25
set type 1 meso/rho 1.0
set type 2 meso/rho 0.25
set type 1 sph/e 2.5 # internal energy corresponding to p=1, rho=1
set type 2 sph/e 0.625 # internal energy corresponding to p=0.25, rho=0.25
set type 1 sph/rho 1.0
set type 2 sph/rho 0.25
pair_style hybrid/overlay sph/rhosum 1 sph/idealgas
pair_coeff * * sph/rhosum 4.0
pair_coeff * * sph/idealgas 0.75 4.0
compute rhoatom all meso/rho/atom
compute ieatom all meso/e/atom
compute emeso all reduce sum c_ieatom # total internal energy
compute rhoatom all shp/rho/atom
compute ieatom all sph/e/atom
compute esph all reduce sum c_ieatom # total internal energy
compute ke all ke
variable etot equal c_ke+c_emeso # total energy
variable etot equal c_ke+c_esph # total energy
# dump positions and local density
dump dump_id all custom 100 dump.2d id type x z y c_rhoatom
@ -35,10 +35,10 @@ dump_modify dump_id first yes
neighbor 0.5 bin
neigh_modify every 5 delay 0 check yes
thermo 10
thermo_style custom step c_ke c_emeso v_etot
thermo_style custom step c_ke c_esph v_etot
thermo_modify norm no
fix integration_fix all meso
fix integration_fix all sph
fix 1 all setforce NULL 0.0 0.0 # treat as a quasi 1d problem
timestep 0.05
log log.2d

View File

@ -1,4 +1,4 @@
atom_style meso
atom_style sph
boundary s p p
region box block -100 150 -4 4 -4 4 units box
@ -12,20 +12,20 @@ set region right type 2
mass 1 1
mass 2 0.25
set type 1 meso/e 2.5 # internal energy corresponding to p=1, rho=1
set type 2 meso/e 0.625 # internal energy corresponding to p=0.25, rho=0.25
set type 1 meso/rho 1.0
set type 2 meso/rho 0.25
set type 1 sph/e 2.5 # internal energy corresponding to p=1, rho=1
set type 2 sph/e 0.625 # internal energy corresponding to p=0.25, rho=0.25
set type 1 sph/rho 1.0
set type 2 sph/rho 0.25
pair_style hybrid/overlay sph/rhosum 1 sph/idealgas
pair_coeff * * sph/rhosum 4.0
pair_coeff * * sph/idealgas 0.75 4.0
compute rhoatom all meso/rho/atom
compute ieatom all meso/e/atom
compute emeso all reduce sum c_ieatom # total internal energy
compute rhoatom all sph/rho/atom
compute ieatom all sph/e/atom
compute esph all reduce sum c_ieatom # total internal energy
compute ke all ke
variable etot equal c_ke+c_emeso # total energy
variable etot equal c_ke+c_esph # total energy
# dump positions and local density
dump dump_id all custom 100 dump.3d id type x z y c_rhoatom
@ -34,10 +34,10 @@ dump_modify dump_id first yes
neighbor 0.5 bin
neigh_modify every 5 delay 0 check yes
thermo 10
thermo_style custom step c_ke c_emeso v_etot
thermo_style custom step c_ke c_esph v_etot
thermo_modify norm no
fix integration_fix all meso
fix integration_fix all sph
fix 1 all setforce NULL 0.0 0.0 # treat as a quasi 1d problem
timestep 0.05
log log.3d

View File

@ -1,5 +1,5 @@
processors * 1 1 # manually assign processors to spatial regions
atom_style meso
atom_style sph
dimension 2
newton on
boundary f f p
@ -22,8 +22,8 @@ pair_coeff 1 1 sph/rhosum ${h}
fix gfix water gravity -9.81 vector 0 1 0 # add gravity. This fix also computes potential energy of mass in gravity field.
fix 2d_fix all enforce2d
compute rho_peratom all meso/rho/atom
compute e_peratom all meso/e/atom
compute rho_peratom all sph/rho/atom
compute e_peratom all sph/e/atom
compute esph all reduce sum c_e_peratom
compute ke all ke
variable etot equal c_esph+c_ke+f_gfix
@ -32,10 +32,10 @@ variable etot equal c_esph+c_ke+f_gfix
fix dtfix all dt/reset 1 NULL ${dt} 0.0005 units box # use a variable timestep
# time-integrate position, velocities, internal energy and density of water particles
fix integrate_water_fix water meso
fix integrate_water_fix water sph
# time-integrate only internal energy and density of boundary particles
fix integrate_bc_fix bc meso/stationary
fix integrate_bc_fix bc sph/stationary
dump dump_id all custom 100 dump.lammpstrj id type xs ys zs c_rho_peratom c_e_peratom fx fy
dump_modify dump_id first yes
thermo 10

View File

@ -92,6 +92,8 @@ fix 5 all wall/gran/region granular hertz/material 1e5 0.1 0.3 tangential mindl
# 'Turn' drum by switching the direction of gravity
unfix grav
unfix ins1
unfix ins2
fix grav all gravity 10 vector 0 -1 0
variable theta equal 2*PI*elapsed/20000.0

View File

@ -24,7 +24,7 @@ compute charge2 type2 property/atom q
compute q2 type2 reduce ave c_charge2
variable qtot equal count(type1)*c_q1+count(type2)*c_q2
thermo_style custom step pe c_q1 c_q2 v_qtot spcpu
thermo_style custom step pe c_q1 c_q2 v_qtot
thermo 10
timestep 0.0001

View File

@ -39,7 +39,7 @@ neigh_modify every 10 delay 0 check yes
timestep 0.0004
thermo_style custom step temp etotal pe evdwl ecoul elong &
c_q1 c_q2 v_qsum press spcpu
c_q1 c_q2 v_qsum press
thermo_modify norm yes
thermo 10

26
src/.gitignore vendored
View File

@ -37,6 +37,7 @@
/kokkos_type.h
/kokkos_few.h
/kokkos_base.h
/kokkos_base_fft.h
/manifold*.cpp
/manifold*.h
@ -84,6 +85,15 @@
/intel_preprocess.h
/intel_simd.h
/atom_vec_sph.cpp
/atom_vec_sph.h
/compute_sph_*.cpp
/compute_sph_*.h
/fix_sph.cpp
/fix_sph.h
/fix_sph_stationary.cpp
/fix_sph_stationary.h
/atom_vec_edpd.cpp
/atom_vec_edpd.h
/atom_vec_mdpd.cpp
@ -247,8 +257,6 @@
/atom_vec_full_hars.h
/atom_vec_granular.cpp
/atom_vec_granular.h
/atom_vec_meso.cpp
/atom_vec_meso.h
/atom_vec_molecular.cpp
/atom_vec_molecular.h
/atom_vec_peri.cpp
@ -385,6 +393,8 @@
/compute_temp_rotate.h
/compute_ti.cpp
/compute_ti.h
/compute_viscosity_cos.cpp
/compute_viscosity_cos.h
/compute_voronoi_atom.cpp
/compute_voronoi_atom.h
/dihedral_charmm.cpp
@ -465,6 +475,8 @@
/fft3d.h
/fft3d_wrap.cpp
/fft3d_wrap.h
/fix_accelerate_cos.cpp
/fix_accelerate_cos.h
/fix_adapt_fep.cpp
/fix_adapt_fep.h
/fix_addtorque.cpp
@ -635,6 +647,8 @@
/fix_poems.h
/fix_pour.cpp
/fix_pour.h
/fix_propel_self.cpp
/fix_propel_self.h
/fix_qeq_comb.cpp
/fix_qeq_comb.h
/fix_qeq_reax.cpp
@ -838,6 +852,10 @@
/pair_coul_msm.h
/pair_coul_shield.cpp
/pair_coul_shield.h
/pair_coul_slater_cut.cpp
/pair_coul_slater_cut.h
/pair_coul_slater_long.cpp
/pair_coul_slater_long.h
/pair_dipole_cut.cpp
/pair_dipole_cut.h
/pair_dipole_sf.cpp
@ -1101,6 +1119,8 @@
/fix_python_invoke.h
/pair_python.cpp
/pair_python.h
/reader_adios.cpp
/reader_adios.h
/reader_molfile.cpp
/reader_molfile.h
/reaxc_allocate.cpp
@ -1325,6 +1345,8 @@
/pair_lennard_mdf.h
/pair_lj_cut_coul_long_cs.cpp
/pair_lj_cut_coul_long_cs.h
/pair_lj_class2_coul_long_cs.cpp
/pair_lj_class2_coul_long_cs.h
/pair_lj_mdf.cpp
/pair_lj_mdf.h
/pair_mgpt.cpp

View File

@ -31,880 +31,47 @@ AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp)
molecular = 0;
mass_type = 1;
comm_x_only = 0;
comm_f_only = 1;
size_forward = 6;
size_reverse = 3;
size_border = 11;
size_velocity = 3;
size_data_atom = 9;
size_data_vel = 4;
xcol_data = 4;
atom->q_flag = atom->mu_flag = 1;
// strings with peratom variables to include in each AtomVec method
// strings cannot contain fields in corresponding AtomVec default strings
// order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "q mu";
fields_copy = (char *) "q mu";
fields_comm = (char *) "mu3";
fields_comm_vel = (char *) "mu3";
fields_reverse = (char *) "";
fields_border = (char *) "q mu";
fields_border_vel = (char *) "q mu";
fields_exchange = (char *) "q mu";
fields_restart = (char *) "q mu";
fields_create = (char *) "q mu";
fields_data_atom = (char *) "id type q x mu3";
fields_data_vel = (char *) "id v";
setup_fields();
}
/* ----------------------------------------------------------------------
grow atom arrays
n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n
set local copies of all grow ptrs used by this class, except defaults
needed in replicate when 2 atom classes exist and it calls pack_restart()
------------------------------------------------------------------------- */
void AtomVecDipole::grow(int n)
void AtomVecDipole::grow_pointers()
{
if (n == 0) grow_nmax();
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one(FLERR,"Per-processor system is too big");
tag = memory->grow(atom->tag,nmax,"atom:tag");
type = memory->grow(atom->type,nmax,"atom:type");
mask = memory->grow(atom->mask,nmax,"atom:mask");
image = memory->grow(atom->image,nmax,"atom:image");
x = memory->grow(atom->x,nmax,3,"atom:x");
v = memory->grow(atom->v,nmax,3,"atom:v");
f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f");
q = memory->grow(atom->q,nmax,"atom:q");
mu = memory->grow(atom->mu,nmax,4,"atom:mu");
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
mu = atom->mu;
}
/* ----------------------------------------------------------------------
reset local array ptrs
modify what AtomVec::data_atom() just unpacked
or initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecDipole::grow_reset()
void AtomVecDipole::data_atom_post(int ilocal)
{
tag = atom->tag; type = atom->type;
mask = atom->mask; image = atom->image;
x = atom->x; v = atom->v; f = atom->f;
q = atom->q; mu = atom->mu;
}
/* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecDipole::copy(int i, int j, int delflag)
{
tag[j] = tag[i];
type[j] = type[i];
mask[j] = mask[i];
image[j] = image[i];
x[j][0] = x[i][0];
x[j][1] = x[i][1];
x[j][2] = x[i][2];
v[j][0] = v[i][0];
v[j][1] = v[i][1];
v[j][2] = v[i][2];
q[j] = q[i];
mu[j][0] = mu[i][0];
mu[j][1] = mu[i][1];
mu[j][2] = mu[i][2];
mu[j][3] = mu[i][3];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag);
}
/* ---------------------------------------------------------------------- */
int AtomVecDipole::pack_comm(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = mu[j][0];
buf[m++] = mu[j][1];
buf[m++] = mu[j][2];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz;
dy = pbc[1]*domain->yprd + pbc[3]*domain->yz;
dz = pbc[2]*domain->zprd;
}
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = mu[j][0];
buf[m++] = mu[j][1];
buf[m++] = mu[j][2];
}
}
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecDipole::pack_comm_vel(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz,dvx,dvy,dvz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = mu[j][0];
buf[m++] = mu[j][1];
buf[m++] = mu[j][2];
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz;
dy = pbc[1]*domain->yprd + pbc[3]*domain->yz;
dz = pbc[2]*domain->zprd;
}
if (!deform_vremap) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = mu[j][0];
buf[m++] = mu[j][1];
buf[m++] = mu[j][2];
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4];
dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3];
dvz = pbc[2]*h_rate[2];
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = mu[j][0];
buf[m++] = mu[j][1];
buf[m++] = mu[j][2];
if (mask[i] & deform_groupbit) {
buf[m++] = v[j][0] + dvx;
buf[m++] = v[j][1] + dvy;
buf[m++] = v[j][2] + dvz;
} else {
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
}
}
}
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecDipole::pack_comm_hybrid(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = mu[j][0];
buf[m++] = mu[j][1];
buf[m++] = mu[j][2];
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecDipole::unpack_comm(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
mu[i][0] = buf[m++];
mu[i][1] = buf[m++];
mu[i][2] = buf[m++];
}
}
/* ---------------------------------------------------------------------- */
void AtomVecDipole::unpack_comm_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
mu[i][0] = buf[m++];
mu[i][1] = buf[m++];
mu[i][2] = buf[m++];
v[i][0] = buf[m++];
v[i][1] = buf[m++];
v[i][2] = buf[m++];
}
}
/* ---------------------------------------------------------------------- */
int AtomVecDipole::unpack_comm_hybrid(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
mu[i][0] = buf[m++];
mu[i][1] = buf[m++];
mu[i][2] = buf[m++];
}
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecDipole::pack_reverse(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
buf[m++] = f[i][0];
buf[m++] = f[i][1];
buf[m++] = f[i][2];
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecDipole::unpack_reverse(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
f[j][0] += buf[m++];
f[j][1] += buf[m++];
f[j][2] += buf[m++];
}
}
/* ---------------------------------------------------------------------- */
int AtomVecDipole::pack_border(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = q[j];
buf[m++] = mu[j][0];
buf[m++] = mu[j][1];
buf[m++] = mu[j][2];
buf[m++] = mu[j][3];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0];
dy = pbc[1];
dz = pbc[2];
}
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = q[j];
buf[m++] = mu[j][0];
buf[m++] = mu[j][1];
buf[m++] = mu[j][2];
buf[m++] = mu[j][3];
}
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]);
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecDipole::pack_border_vel(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz,dvx,dvy,dvz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = q[j];
buf[m++] = mu[j][0];
buf[m++] = mu[j][1];
buf[m++] = mu[j][2];
buf[m++] = mu[j][3];
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0];
dy = pbc[1];
dz = pbc[2];
}
if (!deform_vremap) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = q[j];
buf[m++] = mu[j][0];
buf[m++] = mu[j][1];
buf[m++] = mu[j][2];
buf[m++] = mu[j][3];
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4];
dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3];
dvz = pbc[2]*h_rate[2];
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = q[j];
buf[m++] = mu[j][0];
buf[m++] = mu[j][1];
buf[m++] = mu[j][2];
buf[m++] = mu[j][3];
if (mask[i] & deform_groupbit) {
buf[m++] = v[j][0] + dvx;
buf[m++] = v[j][1] + dvy;
buf[m++] = v[j][2] + dvz;
} else {
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
}
}
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]);
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecDipole::pack_border_hybrid(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = q[j];
buf[m++] = mu[j][0];
buf[m++] = mu[j][1];
buf[m++] = mu[j][2];
buf[m++] = mu[j][3];
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecDipole::unpack_border(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
if (i == nmax) grow(0);
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
tag[i] = (tagint) ubuf(buf[m++]).i;
type[i] = (int) ubuf(buf[m++]).i;
mask[i] = (int) ubuf(buf[m++]).i;
q[i] = buf[m++];
mu[i][0] = buf[m++];
mu[i][1] = buf[m++];
mu[i][2] = buf[m++];
mu[i][3] = buf[m++];
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->
unpack_border(n,first,&buf[m]);
}
/* ---------------------------------------------------------------------- */
void AtomVecDipole::unpack_border_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
if (i == nmax) grow(0);
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
tag[i] = (tagint) ubuf(buf[m++]).i;
type[i] = (int) ubuf(buf[m++]).i;
mask[i] = (int) ubuf(buf[m++]).i;
q[i] = buf[m++];
mu[i][0] = buf[m++];
mu[i][1] = buf[m++];
mu[i][2] = buf[m++];
mu[i][3] = buf[m++];
v[i][0] = buf[m++];
v[i][1] = buf[m++];
v[i][2] = buf[m++];
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->
unpack_border(n,first,&buf[m]);
}
/* ---------------------------------------------------------------------- */
int AtomVecDipole::unpack_border_hybrid(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
q[i] = buf[m++];
mu[i][0] = buf[m++];
mu[i][1] = buf[m++];
mu[i][2] = buf[m++];
mu[i][3] = buf[m++];
}
return m;
}
/* ----------------------------------------------------------------------
pack all atom quantities for shipping to another proc
xyz must be 1st 3 values, so that comm::exchange can test on them
------------------------------------------------------------------------- */
int AtomVecDipole::pack_exchange(int i, double *buf)
{
int m = 1;
buf[m++] = x[i][0];
buf[m++] = x[i][1];
buf[m++] = x[i][2];
buf[m++] = v[i][0];
buf[m++] = v[i][1];
buf[m++] = v[i][2];
buf[m++] = ubuf(tag[i]).d;
buf[m++] = ubuf(type[i]).d;
buf[m++] = ubuf(mask[i]).d;
buf[m++] = ubuf(image[i]).d;
buf[m++] = q[i];
buf[m++] = mu[i][0];
buf[m++] = mu[i][1];
buf[m++] = mu[i][2];
buf[m++] = mu[i][3];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]);
buf[0] = m;
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecDipole::unpack_exchange(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
int m = 1;
x[nlocal][0] = buf[m++];
x[nlocal][1] = buf[m++];
x[nlocal][2] = buf[m++];
v[nlocal][0] = buf[m++];
v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++];
tag[nlocal] = (tagint) ubuf(buf[m++]).i;
type[nlocal] = (int) ubuf(buf[m++]).i;
mask[nlocal] = (int) ubuf(buf[m++]).i;
image[nlocal] = (imageint) ubuf(buf[m++]).i;
q[nlocal] = buf[m++];
mu[nlocal][0] = buf[m++];
mu[nlocal][1] = buf[m++];
mu[nlocal][2] = buf[m++];
mu[nlocal][3] = buf[m++];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->
unpack_exchange(nlocal,&buf[m]);
atom->nlocal++;
return m;
}
/* ----------------------------------------------------------------------
size of restart data for all atoms owned by this proc
include extra data stored by fixes
------------------------------------------------------------------------- */
int AtomVecDipole::size_restart()
{
int i;
int nlocal = atom->nlocal;
int n = 16 * nlocal;
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
for (i = 0; i < nlocal; i++)
n += modify->fix[atom->extra_restart[iextra]]->size_restart(i);
return n;
}
/* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities
xyz must be 1st 3 values, so that read_restart can test on them
molecular types may be negative, but write as positive
------------------------------------------------------------------------- */
int AtomVecDipole::pack_restart(int i, double *buf)
{
int m = 1;
buf[m++] = x[i][0];
buf[m++] = x[i][1];
buf[m++] = x[i][2];
buf[m++] = ubuf(tag[i]).d;
buf[m++] = ubuf(type[i]).d;
buf[m++] = ubuf(mask[i]).d;
buf[m++] = ubuf(image[i]).d;
buf[m++] = v[i][0];
buf[m++] = v[i][1];
buf[m++] = v[i][2];
buf[m++] = q[i];
buf[m++] = mu[i][0];
buf[m++] = mu[i][1];
buf[m++] = mu[i][2];
buf[m++] = mu[i][3];
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
buf[0] = m;
return m;
}
/* ----------------------------------------------------------------------
unpack data for one atom from restart file including extra quantities
------------------------------------------------------------------------- */
int AtomVecDipole::unpack_restart(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) {
grow(0);
if (atom->nextra_store)
memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra");
}
int m = 1;
x[nlocal][0] = buf[m++];
x[nlocal][1] = buf[m++];
x[nlocal][2] = buf[m++];
tag[nlocal] = (tagint) ubuf(buf[m++]).i;
type[nlocal] = (int) ubuf(buf[m++]).i;
mask[nlocal] = (int) ubuf(buf[m++]).i;
image[nlocal] = (imageint) ubuf(buf[m++]).i;
v[nlocal][0] = buf[m++];
v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++];
q[nlocal] = buf[m++];
mu[nlocal][0] = buf[m++];
mu[nlocal][1] = buf[m++];
mu[nlocal][2] = buf[m++];
mu[nlocal][3] = buf[m++];
double **extra = atom->extra;
if (atom->nextra_store) {
int size = static_cast<int> (buf[0]) - m;
for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++];
}
atom->nlocal++;
return m;
}
/* ----------------------------------------------------------------------
create one atom of itype at coord
set other values to defaults
------------------------------------------------------------------------- */
void AtomVecDipole::create_atom(int itype, double *coord)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
tag[nlocal] = 0;
type[nlocal] = itype;
x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2];
mask[nlocal] = 1;
image[nlocal] = ((imageint) IMGMAX << IMG2BITS) |
((imageint) IMGMAX << IMGBITS) | IMGMAX;
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
q[nlocal] = 0.0;
mu[nlocal][0] = 0.0;
mu[nlocal][1] = 0.0;
mu[nlocal][2] = 0.0;
mu[nlocal][3] = 0.0;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack one line from Atoms section of data file
initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecDipole::data_atom(double *coord, imageint imagetmp, char **values)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
tag[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp);
type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp);
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
error->one(FLERR,"Invalid atom type in Atoms section of data file");
q[nlocal] = utils::numeric(FLERR,values[2],true,lmp);
x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2];
mu[nlocal][0] = utils::numeric(FLERR,values[6],true,lmp);
mu[nlocal][1] = utils::numeric(FLERR,values[7],true,lmp);
mu[nlocal][2] = utils::numeric(FLERR,values[8],true,lmp);
mu[nlocal][3] = sqrt(mu[nlocal][0]*mu[nlocal][0] +
mu[nlocal][1]*mu[nlocal][1] +
mu[nlocal][2]*mu[nlocal][2]);
image[nlocal] = imagetmp;
mask[nlocal] = 1;
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */
int AtomVecDipole::data_atom_hybrid(int nlocal, char **values)
{
q[nlocal] = utils::numeric(FLERR,values[0],true,lmp);
mu[nlocal][0] = utils::numeric(FLERR,values[1],true,lmp);
mu[nlocal][1] = utils::numeric(FLERR,values[2],true,lmp);
mu[nlocal][2] = utils::numeric(FLERR,values[3],true,lmp);
mu[nlocal][3] = sqrt(mu[nlocal][0]*mu[nlocal][0] +
mu[nlocal][1]*mu[nlocal][1] +
mu[nlocal][2]*mu[nlocal][2]);
return 4;
}
/* ----------------------------------------------------------------------
pack atom info for data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecDipole::pack_data(double **buf)
{
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
buf[i][0] = ubuf(tag[i]).d;
buf[i][1] = ubuf(type[i]).d;
buf[i][2] = q[i];
buf[i][3] = x[i][0];
buf[i][4] = x[i][1];
buf[i][5] = x[i][2];
buf[i][6] = mu[i][0];
buf[i][7] = mu[i][1];
buf[i][8] = mu[i][2];
buf[i][9] = ubuf((image[i] & IMGMASK) - IMGMAX).d;
buf[i][10] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d;
buf[i][11] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d;
}
}
/* ----------------------------------------------------------------------
pack hybrid atom info for data file
------------------------------------------------------------------------- */
int AtomVecDipole::pack_data_hybrid(int i, double *buf)
{
buf[0] = q[i];
buf[1] = mu[i][0];
buf[2] = mu[i][1];
buf[3] = mu[i][2];
return 4;
}
/* ----------------------------------------------------------------------
write atom info to data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecDipole::write_data(FILE *fp, int n, double **buf)
{
for (int i = 0; i < n; i++)
fprintf(fp,TAGINT_FORMAT \
" %d %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e "
"%-1.16e %d %d %d\n",
(tagint) ubuf(buf[i][0]).i,(int) ubuf(buf[i][1]).i,
buf[i][2],buf[i][3],buf[i][4],
buf[i][5],buf[i][6],buf[i][7],buf[i][8],
(int) ubuf(buf[i][9]).i,(int) ubuf(buf[i][10]).i,
(int) ubuf(buf[i][11]).i);
}
/* ----------------------------------------------------------------------
write hybrid atom info to data file
------------------------------------------------------------------------- */
int AtomVecDipole::write_data_hybrid(FILE *fp, double *buf)
{
fprintf(fp," %-1.16e %-1.16e %-1.16e %-1.16e",buf[0],buf[1],buf[2],buf[3]);
return 4;
}
/* ----------------------------------------------------------------------
return # of bytes of allocated memory
------------------------------------------------------------------------- */
bigint AtomVecDipole::memory_usage()
{
bigint bytes = 0;
if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax);
if (atom->memcheck("type")) bytes += memory->usage(type,nmax);
if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax);
if (atom->memcheck("image")) bytes += memory->usage(image,nmax);
if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3);
if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3);
if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3);
if (atom->memcheck("q")) bytes += memory->usage(q,nmax);
if (atom->memcheck("mu")) bytes += memory->usage(mu,nmax,4);
return bytes;
double *mu_one = mu[ilocal];
mu_one[3] =
sqrt(mu_one[0]*mu_one[0] + mu_one[1]*mu_one[1] + mu_one[2]*mu_one[2]);
}

View File

@ -27,43 +27,12 @@ namespace LAMMPS_NS {
class AtomVecDipole : public AtomVec {
public:
AtomVecDipole(class LAMMPS *);
void grow(int);
void grow_reset();
void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *);
int pack_comm_hybrid(int, int *, double *);
void unpack_comm(int, int, double *);
void unpack_comm_vel(int, int, double *);
int unpack_comm_hybrid(int, int, double *);
int pack_reverse(int, int, double *);
void unpack_reverse(int, int *, double *);
int pack_border(int, int *, double *, int, int *);
int pack_border_vel(int, int *, double *, int, int *);
int pack_border_hybrid(int, int *, double *);
void unpack_border(int, int, double *);
void unpack_border_vel(int, int, double *);
int unpack_border_hybrid(int, int, double *);
int pack_exchange(int, double *);
int unpack_exchange(double *);
int size_restart();
int pack_restart(int, double *);
int unpack_restart(double *);
void create_atom(int, double *);
void data_atom(double *, imageint, char **);
int data_atom_hybrid(int, char **);
void pack_data(double **);
int pack_data_hybrid(int, double *);
void write_data(FILE *, int, double **);
int write_data_hybrid(FILE *, double *);
bigint memory_usage();
void grow_pointers();
void data_atom_post(int);
private:
tagint *tag;
int *type,*mask;
imageint *image;
double **x,**v,**f;
double *q,**mu;
double **mu;
};
}
@ -73,13 +42,4 @@ class AtomVecDipole : public AtomVec {
/* ERROR/WARNING messages:
E: Per-processor system is too big
The number of owned atoms plus ghost atoms on a single
processor must fit in 32-bit integer.
E: Invalid atom type in Atoms section of data file
Atom types must range from 1 to specified # of types.
*/

View File

@ -40,6 +40,7 @@ using namespace MathConst;
enum{ATOM,MOLECULE};
enum{ONE,RANGE,POLY};
enum{CONSTANT,EQUAL}; // same as FixGravity
#define EPSILON 0.001
#define SMALL 1.0e-10
@ -318,6 +319,10 @@ void FixPour::init()
if (ifix == -1)
error->all(FLERR,"No fix gravity defined for fix pour");
int varflag = ((FixGravity *) modify->fix[ifix])->varflag;
if (varflag != CONSTANT)
error->all(FLERR,"Fix gravity for fix pour must be constant");
double xgrav = ((FixGravity *) modify->fix[ifix])->xgrav;
double ygrav = ((FixGravity *) modify->fix[ifix])->ygrav;
double zgrav = ((FixGravity *) modify->fix[ifix])->zgrav;

View File

@ -237,7 +237,7 @@ void AtomKokkos::grow(unsigned int mask){
sync(Device, mask);
modified(Device, mask);
memoryKK->grow_kokkos(k_special,special,nmax,maxspecial,"atom:special");
avec->grow_reset();
avec->grow_pointers();
sync(Host, mask);
}
}

View File

@ -98,7 +98,7 @@ void AtomVecAngleKokkos::grow(int n)
memoryKK->grow_kokkos(atomKK->k_angle_atom3,atomKK->angle_atom3,nmax,atomKK->angle_per_atom,
"atom:angle_atom3");
grow_reset();
grow_pointers();
atomKK->sync(Host,ALL_MASK);
if (atom->nextra_grow)
@ -110,7 +110,7 @@ void AtomVecAngleKokkos::grow(int n)
reset local array ptrs
------------------------------------------------------------------------- */
void AtomVecAngleKokkos::grow_reset()
void AtomVecAngleKokkos::grow_pointers()
{
tag = atomKK->tag;
d_tag = atomKK->k_tag.d_view;

View File

@ -58,7 +58,7 @@ class AtomVecAngleKokkos : public AtomVecKokkos {
int write_data_hybrid(FILE *, double *);
bigint memory_usage();
void grow_reset();
void grow_pointers();
int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist,
const int & iswap,
const DAT::tdual_xfloat_2d &buf,

View File

@ -74,7 +74,7 @@ void AtomVecAtomicKokkos::grow(int n)
memoryKK->grow_kokkos(atomKK->k_v,atomKK->v,nmax,"atom:v");
memoryKK->grow_kokkos(atomKK->k_f,atomKK->f,nmax,"atom:f");
grow_reset();
grow_pointers();
atomKK->sync(Host,ALL_MASK);
if (atom->nextra_grow)
@ -86,7 +86,7 @@ void AtomVecAtomicKokkos::grow(int n)
reset local array ptrs
------------------------------------------------------------------------- */
void AtomVecAtomicKokkos::grow_reset()
void AtomVecAtomicKokkos::grow_pointers()
{
tag = atomKK->tag;
d_tag = atomKK->k_tag.d_view;

View File

@ -48,7 +48,7 @@ class AtomVecAtomicKokkos : public AtomVecKokkos {
void write_data(FILE *, int, double **);
bigint memory_usage();
void grow_reset();
void grow_pointers();
int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist,
DAT::tdual_xfloat_2d buf,int iswap,
int pbc_flag, int *pbc, ExecutionSpace space);

View File

@ -84,7 +84,7 @@ void AtomVecBondKokkos::grow(int n)
memoryKK->grow_kokkos(atomKK->k_bond_type,atomKK->bond_type,nmax,atomKK->bond_per_atom,"atom:bond_type");
memoryKK->grow_kokkos(atomKK->k_bond_atom,atomKK->bond_atom,nmax,atomKK->bond_per_atom,"atom:bond_atom");
grow_reset();
grow_pointers();
atomKK->sync(Host,ALL_MASK);
if (atom->nextra_grow)
@ -96,7 +96,7 @@ void AtomVecBondKokkos::grow(int n)
reset local array ptrs
------------------------------------------------------------------------- */
void AtomVecBondKokkos::grow_reset()
void AtomVecBondKokkos::grow_pointers()
{
tag = atomKK->tag;
d_tag = atomKK->k_tag.d_view;

View File

@ -52,7 +52,7 @@ class AtomVecBondKokkos : public AtomVecKokkos {
int write_data_hybrid(FILE *, double *);
bigint memory_usage();
void grow_reset();
void grow_pointers();
int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist,
DAT::tdual_xfloat_2d buf,int iswap,
int pbc_flag, int *pbc, ExecutionSpace space);

View File

@ -79,7 +79,7 @@ void AtomVecChargeKokkos::grow(int n)
memoryKK->grow_kokkos(atomKK->k_q,atomKK->q,nmax,"atom:q");
grow_reset();
grow_pointers();
atomKK->sync(Host,ALL_MASK);
if (atom->nextra_grow)
@ -91,7 +91,7 @@ void AtomVecChargeKokkos::grow(int n)
reset local array ptrs
------------------------------------------------------------------------- */
void AtomVecChargeKokkos::grow_reset()
void AtomVecChargeKokkos::grow_pointers()
{
tag = atomKK->tag;
d_tag = atomKK->k_tag.d_view;

View File

@ -53,7 +53,7 @@ class AtomVecChargeKokkos : public AtomVecKokkos {
int write_data_hybrid(FILE *, double *);
bigint memory_usage();
void grow_reset();
void grow_pointers();
int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist,
DAT::tdual_xfloat_2d buf,int iswap,
int pbc_flag, int *pbc, ExecutionSpace space);

View File

@ -93,7 +93,7 @@ void AtomVecDPDKokkos::grow(int n)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
grow_reset();
grow_pointers();
atomKK->sync(Host,ALL_MASK);
}
@ -101,7 +101,7 @@ void AtomVecDPDKokkos::grow(int n)
reset local array ptrs
------------------------------------------------------------------------- */
void AtomVecDPDKokkos::grow_reset()
void AtomVecDPDKokkos::grow_pointers()
{
tag = atomKK->tag;
d_tag = atomKK->k_tag.d_view;

View File

@ -61,7 +61,7 @@ class AtomVecDPDKokkos : public AtomVecKokkos {
int write_data_hybrid(FILE *, double *);
bigint memory_usage();
void grow_reset();
void grow_pointers();
int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist,
const int & iswap,
const DAT::tdual_xfloat_2d &buf,

View File

@ -123,7 +123,7 @@ void AtomVecFullKokkos::grow(int n)
memoryKK->grow_kokkos(atomKK->k_improper_atom4,atomKK->improper_atom4,nmax,
atomKK->improper_per_atom,"atom:improper_atom4");
grow_reset();
grow_pointers();
atomKK->sync(Host,ALL_MASK);
if (atom->nextra_grow)
@ -135,7 +135,7 @@ void AtomVecFullKokkos::grow(int n)
reset local array ptrs
------------------------------------------------------------------------- */
void AtomVecFullKokkos::grow_reset()
void AtomVecFullKokkos::grow_pointers()
{
tag = atomKK->tag;
d_tag = atomKK->k_tag.d_view;

View File

@ -52,7 +52,7 @@ class AtomVecFullKokkos : public AtomVecKokkos {
int write_data_hybrid(FILE *, double *);
bigint memory_usage();
void grow_reset();
void grow_pointers();
int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist,
DAT::tdual_xfloat_2d buf,int iswap,
int pbc_flag, int *pbc, ExecutionSpace space);

View File

@ -163,7 +163,7 @@ void AtomVecHybridKokkos::grow(int n)
// for sub-styles, do this in case
// multiple sub-style reallocs of same array occurred
grow_reset();
grow_pointers();
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
@ -174,7 +174,7 @@ void AtomVecHybridKokkos::grow(int n)
reset local array ptrs
------------------------------------------------------------------------- */
void AtomVecHybridKokkos::grow_reset()
void AtomVecHybridKokkos::grow_pointers()
{
tag = atomKK->tag;
d_tag = atomKK->k_tag.d_view;
@ -216,7 +216,7 @@ void AtomVecHybridKokkos::grow_reset()
d_angmom = atomKK->k_angmom.d_view;
h_angmom = atomKK->k_angmom.h_view;
for (int k = 0; k < nstyles; k++) styles[k]->grow_reset();
for (int k = 0; k < nstyles; k++) styles[k]->grow_pointers();
}
/* ----------------------------------------------------------------------

View File

@ -36,7 +36,7 @@ class AtomVecHybridKokkos : public AtomVecKokkos {
void process_args(int, char **);
void init();
void grow(int);
void grow_reset();
void grow_pointers();
void copy(int, int, int);
void clear_bonus();
void force_clear(int, size_t);

View File

@ -16,6 +16,7 @@
#include "comm_kokkos.h"
#include "domain.h"
#include "atom_masks.h"
#include "utils.h"
using namespace LAMMPS_NS;
@ -992,3 +993,49 @@ void AtomVecKokkos::unpack_reverse(int n, int *list, double *buf)
if(n > 0)
modified(Host,F_MASK);
}
/* ----------------------------------------------------------------------
* unpack one line from Velocities section of data file
* ------------------------------------------------------------------------- */
void AtomVecKokkos::data_vel(int m, char **values)
{
double **v = atom->v;
v[m][0] = utils::numeric(FLERR,values[0],true,lmp);
v[m][1] = utils::numeric(FLERR,values[1],true,lmp);
v[m][2] = utils::numeric(FLERR,values[2],true,lmp);
modified(Host,V_MASK);
}
/* ----------------------------------------------------------------------
* pack velocity info for data file
* ------------------------------------------------------------------------- */
void AtomVecKokkos::pack_vel(double **buf)
{
double **v = atom->v;
tagint *tag = atom->tag;
int nlocal = atom->nlocal;
sync(Host,V_MASK|TAG_MASK);
for (int i = 0; i < nlocal; i++) {
buf[i][0] = ubuf(tag[i]).d;
buf[i][1] = v[i][0];
buf[i][2] = v[i][1];
buf[i][3] = v[i][2];
}
}
/* ----------------------------------------------------------------------
* write velocity info to data file
* ------------------------------------------------------------------------- */
void AtomVecKokkos::write_vel(FILE *fp, int n, double **buf)
{
for (int i = 0; i < n; i++)
fprintf(fp,TAGINT_FORMAT " %-1.16e %-1.16e %-1.16e\n",
(tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3]);
}

View File

@ -41,6 +41,9 @@ class AtomVecKokkos : public AtomVec {
virtual void unpack_comm_vel(int, int, double *);
virtual int pack_reverse(int, int, double *);
virtual void unpack_reverse(int, int *, double *);
virtual void data_vel(int, char **);
virtual void pack_vel(double **);
virtual void write_vel(FILE *, int, double **);
virtual void sync(ExecutionSpace space, unsigned int mask) = 0;
virtual void modified(ExecutionSpace space, unsigned int mask) = 0;

View File

@ -121,7 +121,7 @@ void AtomVecMolecularKokkos::grow(int n)
memoryKK->grow_kokkos(atomKK->k_improper_atom4,atomKK->improper_atom4,nmax,
atomKK->improper_per_atom,"atom:improper_atom4");
grow_reset();
grow_pointers();
atomKK->sync(Host,ALL_MASK);
if (atom->nextra_grow)
@ -133,7 +133,7 @@ void AtomVecMolecularKokkos::grow(int n)
reset local array ptrs
------------------------------------------------------------------------- */
void AtomVecMolecularKokkos::grow_reset()
void AtomVecMolecularKokkos::grow_pointers()
{
tag = atomKK->tag;
d_tag = atomKK->k_tag.d_view;

View File

@ -58,7 +58,7 @@ class AtomVecMolecularKokkos : public AtomVecKokkos {
int write_data_hybrid(FILE *, double *);
bigint memory_usage();
void grow_reset();
void grow_pointers();
int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist,
const int & iswap,
const DAT::tdual_xfloat_2d &buf,

View File

@ -119,7 +119,7 @@ void AtomVecSphereKokkos::grow(int n)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
grow_reset();
grow_pointers();
atomKK->sync(Host,ALL_MASK);
}
@ -127,7 +127,7 @@ void AtomVecSphereKokkos::grow(int n)
reset local array ptrs
------------------------------------------------------------------------- */
void AtomVecSphereKokkos::grow_reset()
void AtomVecSphereKokkos::grow_pointers()
{
tag = atomKK->tag;
d_tag = atomKK->k_tag.d_view;

View File

@ -33,7 +33,7 @@ class AtomVecSphereKokkos : public AtomVecKokkos {
~AtomVecSphereKokkos() {}
void init();
void grow(int);
void grow_reset();
void grow_pointers();
void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *);

File diff suppressed because it is too large Load Diff

View File

@ -27,50 +27,22 @@ namespace LAMMPS_NS {
class AtomVecAngle : public AtomVec {
public:
AtomVecAngle(class LAMMPS *);
virtual ~AtomVecAngle() {}
void grow(int);
void grow_reset();
void copy(int, int, int);
virtual int pack_comm(int, int *, double *, int, int *);
virtual int pack_comm_vel(int, int *, double *, int, int *);
virtual void unpack_comm(int, int, double *);
virtual void unpack_comm_vel(int, int, double *);
int pack_reverse(int, int, double *);
void unpack_reverse(int, int *, double *);
virtual int pack_border(int, int *, double *, int, int *);
virtual int pack_border_vel(int, int *, double *, int, int *);
int pack_border_hybrid(int, int *, double *);
virtual void unpack_border(int, int, double *);
virtual void unpack_border_vel(int, int, double *);
int unpack_border_hybrid(int, int, double *);
virtual int pack_exchange(int, double *);
virtual int unpack_exchange(double *);
int size_restart();
int pack_restart(int, double *);
int unpack_restart(double *);
void create_atom(int, double *);
void data_atom(double *, imageint, char **);
int data_atom_hybrid(int, char **);
void pack_data(double **);
int pack_data_hybrid(int, double *);
void write_data(FILE *, int, double **);
int write_data_hybrid(FILE *, double *);
bigint memory_usage();
~AtomVecAngle();
protected:
tagint *tag;
int *type,*mask;
imageint *image;
double **x,**v,**f;
tagint *molecule;
void grow_pointers();
void pack_restart_pre(int);
void pack_restart_post(int);
void unpack_restart_init(int);
void data_atom_post(int);
private:
int *num_bond,*num_angle;
int **bond_type,**angle_type;
int **nspecial;
tagint **special;
int *num_bond;
int **bond_type;
tagint **bond_atom;
int *num_angle;
int **angle_type;
tagint **angle_atom1,**angle_atom2,**angle_atom3;
int any_bond_negative,any_angle_negative;
int bond_per_atom,angle_per_atom;
int *bond_negative,*angle_negative;
};
}
@ -80,13 +52,4 @@ class AtomVecAngle : public AtomVec {
/* ERROR/WARNING messages:
E: Per-processor system is too big
The number of owned atoms plus ghost atoms on a single
processor must fit in 32-bit integer.
E: Invalid atom type in Atoms section of data file
Atom types must range from 1 to specified # of types.
*/

View File

@ -13,13 +13,6 @@
#include "atom_vec_bond.h"
#include "atom.h"
#include "comm.h"
#include "domain.h"
#include "modify.h"
#include "fix.h"
#include "memory.h"
#include "error.h"
#include "utils.h"
using namespace LAMMPS_NS;
@ -31,829 +24,114 @@ AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp)
bonds_allow = 1;
mass_type = 1;
comm_x_only = comm_f_only = 1;
size_forward = 3;
size_reverse = 3;
size_border = 7;
size_velocity = 3;
size_data_atom = 6;
size_data_vel = 4;
xcol_data = 4;
atom->molecule_flag = 1;
}
/* ----------------------------------------------------------------------
grow atom arrays
n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n
------------------------------------------------------------------------- */
// strings with peratom variables to include in each AtomVec method
// strings cannot contain fields in corresponding AtomVec default strings
// order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file
void AtomVecBond::grow(int n)
{
if (n == 0) grow_nmax();
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one(FLERR,"Per-processor system is too big");
fields_grow = (char *)
"molecule num_bond bond_type bond_atom nspecial special";
fields_copy = (char *)
"molecule num_bond bond_type bond_atom nspecial special";
fields_comm = (char *) "";
fields_comm_vel = (char *) "";
fields_reverse = (char *) "";
fields_border = (char *) "molecule";
fields_border_vel = (char *) "molecule";
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";
tag = memory->grow(atom->tag,nmax,"atom:tag");
type = memory->grow(atom->type,nmax,"atom:type");
mask = memory->grow(atom->mask,nmax,"atom:mask");
image = memory->grow(atom->image,nmax,"atom:image");
x = memory->grow(atom->x,nmax,3,"atom:x");
v = memory->grow(atom->v,nmax,3,"atom:v");
f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f");
setup_fields();
molecule = memory->grow(atom->molecule,nmax,"atom:molecule");
nspecial = memory->grow(atom->nspecial,nmax,3,"atom:nspecial");
special = memory->grow(atom->special,nmax,atom->maxspecial,"atom:special");
num_bond = memory->grow(atom->num_bond,nmax,"atom:num_bond");
bond_type = memory->grow(atom->bond_type,nmax,atom->bond_per_atom,
"atom:bond_type");
bond_atom = memory->grow(atom->bond_atom,nmax,atom->bond_per_atom,
"atom:bond_atom");
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
}
/* ----------------------------------------------------------------------
reset local array ptrs
------------------------------------------------------------------------- */
void AtomVecBond::grow_reset()
{
tag = atom->tag; type = atom->type;
mask = atom->mask; image = atom->image;
x = atom->x; v = atom->v; f = atom->f;
molecule = atom->molecule;
nspecial = atom->nspecial; special = atom->special;
num_bond = atom->num_bond; bond_type = atom->bond_type;
bond_atom = atom->bond_atom;
}
/* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecBond::copy(int i, int j, int delflag)
{
int k;
tag[j] = tag[i];
type[j] = type[i];
mask[j] = mask[i];
image[j] = image[i];
x[j][0] = x[i][0];
x[j][1] = x[i][1];
x[j][2] = x[i][2];
v[j][0] = v[i][0];
v[j][1] = v[i][1];
v[j][2] = v[i][2];
molecule[j] = molecule[i];
num_bond[j] = num_bond[i];
for (k = 0; k < num_bond[j]; k++) {
bond_type[j][k] = bond_type[i][k];
bond_atom[j][k] = bond_atom[i][k];
}
nspecial[j][0] = nspecial[i][0];
nspecial[j][1] = nspecial[i][1];
nspecial[j][2] = nspecial[i][2];
for (k = 0; k < nspecial[j][2]; k++) special[j][k] = special[i][k];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag);
bond_per_atom = 0;
bond_negative = NULL;
}
/* ---------------------------------------------------------------------- */
int AtomVecBond::pack_comm(int n, int *list, double *buf,
int pbc_flag, int *pbc)
AtomVecBond::~AtomVecBond()
{
int i,j,m;
double dx,dy,dz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz;
dy = pbc[1]*domain->yprd + pbc[3]*domain->yz;
dz = pbc[2]*domain->zprd;
}
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
}
}
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecBond::pack_comm_vel(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz,dvx,dvy,dvz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz;
dy = pbc[1]*domain->yprd + pbc[3]*domain->yz;
dz = pbc[2]*domain->zprd;
}
if (!deform_vremap) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4];
dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3];
dvz = pbc[2]*h_rate[2];
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
if (mask[i] & deform_groupbit) {
buf[m++] = v[j][0] + dvx;
buf[m++] = v[j][1] + dvy;
buf[m++] = v[j][2] + dvz;
} else {
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
}
}
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecBond::unpack_comm(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
}
}
/* ---------------------------------------------------------------------- */
void AtomVecBond::unpack_comm_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
v[i][0] = buf[m++];
v[i][1] = buf[m++];
v[i][2] = buf[m++];
}
}
/* ---------------------------------------------------------------------- */
int AtomVecBond::pack_reverse(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
buf[m++] = f[i][0];
buf[m++] = f[i][1];
buf[m++] = f[i][2];
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecBond::unpack_reverse(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
f[j][0] += buf[m++];
f[j][1] += buf[m++];
f[j][2] += buf[m++];
}
}
/* ---------------------------------------------------------------------- */
int AtomVecBond::pack_border(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = ubuf(molecule[j]).d;
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0];
dy = pbc[1];
dz = pbc[2];
}
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = ubuf(molecule[j]).d;
}
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]);
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecBond::pack_border_vel(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz,dvx,dvy,dvz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = ubuf(molecule[j]).d;
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0];
dy = pbc[1];
dz = pbc[2];
}
if (!deform_vremap) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = ubuf(molecule[j]).d;
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4];
dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3];
dvz = pbc[2]*h_rate[2];
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = ubuf(molecule[j]).d;
if (mask[i] & deform_groupbit) {
buf[m++] = v[j][0] + dvx;
buf[m++] = v[j][1] + dvy;
buf[m++] = v[j][2] + dvz;
} else {
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
}
}
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]);
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecBond::pack_border_hybrid(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = ubuf(molecule[j]).d;
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecBond::unpack_border(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
if (i == nmax) grow(0);
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
tag[i] = (tagint) ubuf(buf[m++]).i;
type[i] = (int) ubuf(buf[m++]).i;
mask[i] = (int) ubuf(buf[m++]).i;
molecule[i] = (tagint) ubuf(buf[m++]).i;
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->
unpack_border(n,first,&buf[m]);
}
/* ---------------------------------------------------------------------- */
void AtomVecBond::unpack_border_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
if (i == nmax) grow(0);
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
tag[i] = (tagint) ubuf(buf[m++]).i;
type[i] = (int) ubuf(buf[m++]).i;
mask[i] = (int) ubuf(buf[m++]).i;
molecule[i] = (tagint) ubuf(buf[m++]).i;
v[i][0] = buf[m++];
v[i][1] = buf[m++];
v[i][2] = buf[m++];
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->
unpack_border(n,first,&buf[m]);
}
/* ---------------------------------------------------------------------- */
int AtomVecBond::unpack_border_hybrid(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++)
molecule[i] = (tagint) ubuf(buf[m++]).i;
return m;
delete [] bond_negative;
}
/* ----------------------------------------------------------------------
pack data for atom I for sending to another proc
xyz must be 1st 3 values, so comm::exchange() can test on them
set local copies of all grow ptrs used by this class, except defaults
needed in replicate when 2 atom classes exist and it calls pack_restart()
------------------------------------------------------------------------- */
int AtomVecBond::pack_exchange(int i, double *buf)
void AtomVecBond::grow_pointers()
{
int k;
num_bond = atom->num_bond;
bond_type = atom->bond_type;
nspecial = atom->nspecial;
}
int m = 1;
buf[m++] = x[i][0];
buf[m++] = x[i][1];
buf[m++] = x[i][2];
buf[m++] = v[i][0];
buf[m++] = v[i][1];
buf[m++] = v[i][2];
buf[m++] = ubuf(tag[i]).d;
buf[m++] = ubuf(type[i]).d;
buf[m++] = ubuf(mask[i]).d;
buf[m++] = ubuf(image[i]).d;
/* ----------------------------------------------------------------------
modify values for AtomVec::pack_restart() to pack
------------------------------------------------------------------------- */
buf[m++] = ubuf(molecule[i]).d;
void AtomVecBond::pack_restart_pre(int ilocal)
{
// insure bond_negative vector is needed length
buf[m++] = ubuf(num_bond[i]).d;
for (k = 0; k < num_bond[i]; k++) {
buf[m++] = ubuf(bond_type[i][k]).d;
buf[m++] = ubuf(bond_atom[i][k]).d;
if (bond_per_atom < atom->bond_per_atom) {
delete [] bond_negative;
bond_per_atom = atom->bond_per_atom;
bond_negative = new int[bond_per_atom];
}
buf[m++] = ubuf(nspecial[i][0]).d;
buf[m++] = ubuf(nspecial[i][1]).d;
buf[m++] = ubuf(nspecial[i][2]).d;
for (k = 0; k < nspecial[i][2]; k++) buf[m++] = ubuf(special[i][k]).d;
// flip any negative types to positive and flag which ones
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]);
buf[0] = m;
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecBond::unpack_exchange(double *buf)
{
int k;
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
int m = 1;
x[nlocal][0] = buf[m++];
x[nlocal][1] = buf[m++];
x[nlocal][2] = buf[m++];
v[nlocal][0] = buf[m++];
v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++];
tag[nlocal] = (tagint) ubuf(buf[m++]).i;
type[nlocal] = (int) ubuf(buf[m++]).i;
mask[nlocal] = (int) ubuf(buf[m++]).i;
image[nlocal] = (imageint) ubuf(buf[m++]).i;
molecule[nlocal] = (tagint) ubuf(buf[m++]).i;
num_bond[nlocal] = (int) ubuf(buf[m++]).i;
for (k = 0; k < num_bond[nlocal]; k++) {
bond_type[nlocal][k] = (int) ubuf(buf[m++]).i;
bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i;
}
nspecial[nlocal][0] = (int) ubuf(buf[m++]).i;
nspecial[nlocal][1] = (int) ubuf(buf[m++]).i;
nspecial[nlocal][2] = (int) ubuf(buf[m++]).i;
for (k = 0; k < nspecial[nlocal][2]; k++)
special[nlocal][k] = (tagint) ubuf(buf[m++]).i;
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->
unpack_exchange(nlocal,&buf[m]);
atom->nlocal++;
return m;
}
/* ----------------------------------------------------------------------
size of restart data for all atoms owned by this proc
include extra data stored by fixes
------------------------------------------------------------------------- */
int AtomVecBond::size_restart()
{
int i;
int nlocal = atom->nlocal;
int n = 0;
for (i = 0; i < nlocal; i++)
n += 13 + 2*num_bond[i];
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
for (i = 0; i < nlocal; i++)
n += modify->fix[atom->extra_restart[iextra]]->size_restart(i);
return n;
}
/* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities
xyz must be 1st 3 values, so that read_restart can test on them
molecular types may be negative, but write as positive
------------------------------------------------------------------------- */
int AtomVecBond::pack_restart(int i, double *buf)
{
int k;
int m = 1;
buf[m++] = x[i][0];
buf[m++] = x[i][1];
buf[m++] = x[i][2];
buf[m++] = ubuf(tag[i]).d;
buf[m++] = ubuf(type[i]).d;
buf[m++] = ubuf(mask[i]).d;
buf[m++] = ubuf(image[i]).d;
buf[m++] = v[i][0];
buf[m++] = v[i][1];
buf[m++] = v[i][2];
buf[m++] = ubuf(molecule[i]).d;
buf[m++] = ubuf(num_bond[i]).d;
for (k = 0; k < num_bond[i]; k++) {
buf[m++] = ubuf(MAX(bond_type[i][k],-bond_type[i][k])).d;
buf[m++] = ubuf(bond_atom[i][k]).d;
}
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
buf[0] = m;
return m;
}
/* ----------------------------------------------------------------------
unpack data for one atom from restart file including extra quantities
------------------------------------------------------------------------- */
int AtomVecBond::unpack_restart(double *buf)
{
int k;
int nlocal = atom->nlocal;
if (nlocal == nmax) {
grow(0);
if (atom->nextra_store)
memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra");
}
int m = 1;
x[nlocal][0] = buf[m++];
x[nlocal][1] = buf[m++];
x[nlocal][2] = buf[m++];
tag[nlocal] = (tagint) ubuf(buf[m++]).i;
type[nlocal] = (int) ubuf(buf[m++]).i;
mask[nlocal] = (int) ubuf(buf[m++]).i;
image[nlocal] = (imageint) ubuf(buf[m++]).i;
v[nlocal][0] = buf[m++];
v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++];
molecule[nlocal] = (tagint) ubuf(buf[m++]).i;
num_bond[nlocal] = (int) ubuf(buf[m++]).i;
for (k = 0; k < num_bond[nlocal]; k++) {
bond_type[nlocal][k] = (int) ubuf(buf[m++]).i;
bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i;
}
nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0;
double **extra = atom->extra;
if (atom->nextra_store) {
int size = static_cast<int> (buf[0]) - m;
for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++];
}
atom->nlocal++;
return m;
}
/* ----------------------------------------------------------------------
create one atom of itype at coord
set other values to defaults
------------------------------------------------------------------------- */
void AtomVecBond::create_atom(int itype, double *coord)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
tag[nlocal] = 0;
type[nlocal] = itype;
x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2];
mask[nlocal] = 1;
image[nlocal] = ((imageint) IMGMAX << IMG2BITS) |
((imageint) IMGMAX << IMGBITS) | IMGMAX;
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
molecule[nlocal] = 0;
num_bond[nlocal] = 0;
nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack one line from Atoms section of data file
initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecBond::data_atom(double *coord, imageint imagetmp, char **values)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
tag[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp);
molecule[nlocal] = utils::tnumeric(FLERR,values[1],true,lmp);
type[nlocal] = utils::inumeric(FLERR,values[2],true,lmp);
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
error->one(FLERR,"Invalid atom type in Atoms section of data file");
x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2];
image[nlocal] = imagetmp;
mask[nlocal] = 1;
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
num_bond[nlocal] = 0;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */
int AtomVecBond::data_atom_hybrid(int nlocal, char **values)
{
molecule[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp);
num_bond[nlocal] = 0;
return 1;
}
/* ----------------------------------------------------------------------
pack atom info for data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecBond::pack_data(double **buf)
{
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
buf[i][0] = ubuf(tag[i]).d;
buf[i][1] = ubuf(molecule[i]).d;
buf[i][2] = ubuf(type[i]).d;
buf[i][3] = x[i][0];
buf[i][4] = x[i][1];
buf[i][5] = x[i][2];
buf[i][6] = ubuf((image[i] & IMGMASK) - IMGMAX).d;
buf[i][7] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d;
buf[i][8] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d;
any_bond_negative = 0;
for (int m = 0; m < num_bond[ilocal]; m++) {
if (bond_type[ilocal][m] < 0) {
bond_negative[m] = 1;
bond_type[ilocal][m] = -bond_type[ilocal][m];
any_bond_negative = 1;
} else bond_negative[m] = 0;
}
}
/* ----------------------------------------------------------------------
pack hybrid atom info for data file
unmodify values packed by AtomVec::pack_restart()
------------------------------------------------------------------------- */
int AtomVecBond::pack_data_hybrid(int i, double *buf)
void AtomVecBond::pack_restart_post(int ilocal)
{
buf[0] = ubuf(molecule[i]).d;
return 1;
// restore the flagged types to their negative values
if (any_bond_negative) {
for (int m = 0; m < num_bond[ilocal]; m++)
if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m];
}
}
/* ----------------------------------------------------------------------
write atom info to data file including 3 image flags
initialize other atom quantities after AtomVec::unpack_restart()
------------------------------------------------------------------------- */
void AtomVecBond::write_data(FILE *fp, int n, double **buf)
void AtomVecBond::unpack_restart_init(int ilocal)
{
for (int i = 0; i < n; i++)
fprintf(fp,TAGINT_FORMAT " " TAGINT_FORMAT
" %d %-1.16e %-1.16e %-1.16e %d %d %d\n",
(tagint) ubuf(buf[i][0]).i,(tagint) ubuf(buf[i][1]).i,
(int) ubuf(buf[i][2]).i,
buf[i][3],buf[i][4],buf[i][5],
(int) ubuf(buf[i][6]).i,(int) ubuf(buf[i][7]).i,
(int) ubuf(buf[i][8]).i);
nspecial[ilocal][0] = 0;
nspecial[ilocal][1] = 0;
nspecial[ilocal][2] = 0;
}
/* ----------------------------------------------------------------------
write hybrid atom info to data file
modify what AtomVec::data_atom() just unpacked
or initialize other atom quantities
------------------------------------------------------------------------- */
int AtomVecBond::write_data_hybrid(FILE *fp, double *buf)
void AtomVecBond::data_atom_post(int ilocal)
{
fprintf(fp," " TAGINT_FORMAT,(tagint) ubuf(buf[0]).i);
return 1;
}
/* ----------------------------------------------------------------------
return # of bytes of allocated memory
------------------------------------------------------------------------- */
bigint AtomVecBond::memory_usage()
{
bigint bytes = 0;
if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax);
if (atom->memcheck("type")) bytes += memory->usage(type,nmax);
if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax);
if (atom->memcheck("image")) bytes += memory->usage(image,nmax);
if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3);
if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3);
if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3);
if (atom->memcheck("molecule")) bytes += memory->usage(molecule,nmax);
if (atom->memcheck("nspecial")) bytes += memory->usage(nspecial,nmax,3);
if (atom->memcheck("special"))
bytes += memory->usage(special,nmax,atom->maxspecial);
if (atom->memcheck("num_bond")) bytes += memory->usage(num_bond,nmax);
if (atom->memcheck("bond_type"))
bytes += memory->usage(bond_type,nmax,atom->bond_per_atom);
if (atom->memcheck("bond_atom"))
bytes += memory->usage(bond_atom,nmax,atom->bond_per_atom);
return bytes;
num_bond[ilocal] = 0;
nspecial[ilocal][0] = 0;
nspecial[ilocal][1] = 0;
nspecial[ilocal][2] = 0;
}

View File

@ -27,46 +27,22 @@ namespace LAMMPS_NS {
class AtomVecBond : public AtomVec {
public:
AtomVecBond(class LAMMPS *);
void grow(int);
void grow_reset();
void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *);
void unpack_comm(int, int, double *);
void unpack_comm_vel(int, int, double *);
int pack_reverse(int, int, double *);
void unpack_reverse(int, int *, double *);
int pack_border(int, int *, double *, int, int *);
int pack_border_vel(int, int *, double *, int, int *);
int pack_border_hybrid(int, int *, double *);
void unpack_border(int, int, double *);
void unpack_border_vel(int, int, double *);
int unpack_border_hybrid(int, int, double *);
int pack_exchange(int, double *);
int unpack_exchange(double *);
int size_restart();
int pack_restart(int, double *);
int unpack_restart(double *);
void create_atom(int, double *);
void data_atom(double *, imageint, char **);
int data_atom_hybrid(int, char **);
void pack_data(double **);
int pack_data_hybrid(int, double *);
void write_data(FILE *, int, double **);
int write_data_hybrid(FILE *, double *);
bigint memory_usage();
~AtomVecBond();
void grow_pointers();
void pack_restart_pre(int);
void pack_restart_post(int);
void unpack_restart_init(int);
void data_atom_post(int);
private:
tagint *tag;
int *type,*mask;
imageint *image;
double **x,**v,**f;
tagint *molecule;
int **nspecial;
tagint **special;
int *num_bond;
int **bond_type;
tagint **bond_atom;
int **nspecial;
int any_bond_negative;
int bond_per_atom;
int *bond_negative;
};
}
@ -76,13 +52,4 @@ class AtomVecBond : public AtomVec {
/* ERROR/WARNING messages:
E: Per-processor system is too big
The number of owned atoms plus ghost atoms on a single
processor must fit in 32-bit integer.
E: Invalid atom type in Atoms section of data file
Atom types must range from 1 to specified # of types.
*/

File diff suppressed because it is too large Load Diff

View File

@ -27,57 +27,23 @@ namespace LAMMPS_NS {
class AtomVecFull : public AtomVec {
public:
AtomVecFull(class LAMMPS *);
virtual ~AtomVecFull() {}
void grow(int);
void grow_reset();
void copy(int, int, int);
virtual int pack_comm(int, int *, double *, int, int *);
virtual int pack_comm_vel(int, int *, double *, int, int *);
virtual void unpack_comm(int, int, double *);
virtual void unpack_comm_vel(int, int, double *);
int pack_reverse(int, int, double *);
void unpack_reverse(int, int *, double *);
virtual int pack_border(int, int *, double *, int, int *);
virtual int pack_border_vel(int, int *, double *, int, int *);
int pack_border_hybrid(int, int *, double *);
virtual void unpack_border(int, int, double *);
virtual void unpack_border_vel(int, int, double *);
int unpack_border_hybrid(int, int, double *);
virtual int pack_exchange(int, double *);
virtual int unpack_exchange(double *);
int size_restart();
int pack_restart(int, double *);
int unpack_restart(double *);
void create_atom(int, double *);
void data_atom(double *, imageint, char **);
int data_atom_hybrid(int, char **);
void pack_data(double **);
int pack_data_hybrid(int, double *);
void write_data(FILE *, int, double **);
int write_data_hybrid(FILE *, double *);
bigint memory_usage();
~AtomVecFull();
protected:
tagint *tag;
int *type,*mask;
imageint *image;
double **x,**v,**f;
double *q;
tagint *molecule;
void grow_pointers();
void pack_restart_pre(int);
void pack_restart_post(int);
void unpack_restart_init(int);
void data_atom_post(int);
private:
int *num_bond,*num_angle,*num_dihedral,*num_improper;
int **bond_type,**angle_type,**dihedral_type,**improper_type;
int **nspecial;
tagint **special;
int *num_bond;
int **bond_type;
tagint **bond_atom;
int *num_angle;
int **angle_type;
tagint **angle_atom1,**angle_atom2,**angle_atom3;
int *num_dihedral;
int **dihedral_type;
tagint **dihedral_atom1,**dihedral_atom2,**dihedral_atom3,**dihedral_atom4;
int *num_improper;
int **improper_type;
tagint **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4;
int any_bond_negative,any_angle_negative,
any_dihedral_negative,any_improper_negative;
int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom;
int *bond_negative,*angle_negative,*dihedral_negative,*improper_negative;
};
}
@ -87,13 +53,4 @@ class AtomVecFull : public AtomVec {
/* ERROR/WARNING messages:
E: Per-processor system is too big
The number of owned atoms plus ghost atoms on a single
processor must fit in 32-bit integer.
E: Invalid atom type in Atoms section of data file
Atom types must range from 1 to specified # of types.
*/

File diff suppressed because it is too large Load Diff

View File

@ -27,55 +27,23 @@ namespace LAMMPS_NS {
class AtomVecMolecular : public AtomVec {
public:
AtomVecMolecular(class LAMMPS *);
void grow(int);
void grow_reset();
void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *);
void unpack_comm(int, int, double *);
void unpack_comm_vel(int, int, double *);
int pack_reverse(int, int, double *);
void unpack_reverse(int, int *, double *);
int pack_border(int, int *, double *, int, int *);
int pack_border_vel(int, int *, double *, int, int *);
int pack_border_hybrid(int, int *, double *);
void unpack_border(int, int, double *);
void unpack_border_vel(int, int, double *);
int unpack_border_hybrid(int, int, double *);
int pack_exchange(int, double *);
int unpack_exchange(double *);
int size_restart();
int pack_restart(int, double *);
int unpack_restart(double *);
void create_atom(int, double *);
void data_atom(double *, imageint, char **);
int data_atom_hybrid(int, char **);
void pack_data(double **);
int pack_data_hybrid(int, double *);
void write_data(FILE *, int, double **);
int write_data_hybrid(FILE *, double *);
bigint memory_usage();
~AtomVecMolecular();
void grow_pointers();
void pack_restart_pre(int);
void pack_restart_post(int);
void unpack_restart_init(int);
void data_atom_post(int);
private:
tagint *tag;
int *type,*mask;
imageint *image;
double **x,**v,**f;
tagint *molecule;
int *num_bond,*num_angle,*num_dihedral,*num_improper;
int **bond_type,**angle_type,**dihedral_type,**improper_type;
int **nspecial;
tagint **special;
int *num_bond;
int **bond_type;
tagint **bond_atom;
int *num_angle;
int **angle_type;
tagint **angle_atom1,**angle_atom2,**angle_atom3;
int *num_dihedral;
int **dihedral_type;
tagint **dihedral_atom1,**dihedral_atom2,**dihedral_atom3,**dihedral_atom4;
int *num_improper;
int **improper_type;
tagint **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4;
int any_bond_negative,any_angle_negative,
any_dihedral_negative,any_improper_negative;
int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom;
int *bond_negative,*angle_negative,*dihedral_negative,*improper_negative;
};
}
@ -85,13 +53,4 @@ class AtomVecMolecular : public AtomVec {
/* ERROR/WARNING messages:
E: Per-processor system is too big
The number of owned atoms plus ghost atoms on a single
processor must fit in 32-bit integer.
E: Invalid atom type in Atoms section of data file
Atom types must range from 1 to specified # of types.
*/

View File

@ -31,16 +31,27 @@ AtomVecTemplate::AtomVecTemplate(LAMMPS *lmp) : AtomVec(lmp)
molecular = 2;
mass_type = 1;
comm_x_only = comm_f_only = 1;
size_forward = 3;
size_reverse = 3;
size_border = 9;
size_velocity = 3;
size_data_atom = 8;
size_data_vel = 4;
xcol_data = 6;
atom->molecule_flag = 1;
// strings with peratom variables to include in each AtomVec method
// strings cannot contain fields in corresponding AtomVec default strings
// order of fields in the string does not matter
// except fields_data_atom and fields_data_vel which must match data file
fields_grow = (char *) "molecule molindex molatom";
fields_copy = (char *) "molecule molindex molatom";
fields_comm = (char *) "";
fields_comm_vel = (char *) "";
fields_reverse = (char *) "";
fields_border = (char *) "molecule molindex molatom";
fields_border_vel = (char *) "molecule molindex molatom";
fields_exchange = (char *) "molecule molindex molatom";
fields_restart = (char *) "molecule molindex molatom";
fields_create = (char *) "molecule molindex molatom";
fields_data_atom = (char *) "id molecule molindex molatom type x";
fields_data_vel = (char *) "";
setup_fields();
}
/* ----------------------------------------------------------------------
@ -86,785 +97,38 @@ void AtomVecTemplate::process_args(int narg, char **arg)
}
/* ----------------------------------------------------------------------
grow atom arrays
n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n
set local copies of all grow ptrs used by this class, except defaults
needed in replicate when 2 atom classes exist and it calls pack_restart()
------------------------------------------------------------------------- */
void AtomVecTemplate::grow(int n)
void AtomVecTemplate::grow_pointers()
{
if (n == 0) grow_nmax();
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one(FLERR,"Per-processor system is too big");
tag = memory->grow(atom->tag,nmax,"atom:tag");
type = memory->grow(atom->type,nmax,"atom:type");
mask = memory->grow(atom->mask,nmax,"atom:mask");
image = memory->grow(atom->image,nmax,"atom:image");
x = memory->grow(atom->x,nmax,3,"atom:x");
v = memory->grow(atom->v,nmax,3,"atom:v");
f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f");
molecule = memory->grow(atom->molecule,nmax,"atom:molecule");
molindex = memory->grow(atom->molindex,nmax,"atom:molindex");
molatom = memory->grow(atom->molatom,nmax,"atom:molatom");
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
molindex = atom->molindex;
molatom = atom->molatom;
}
/* ----------------------------------------------------------------------
reset local array ptrs
initialize non-zero atom quantities
------------------------------------------------------------------------- */
void AtomVecTemplate::grow_reset()
void AtomVecTemplate::create_atom_post(int ilocal)
{
tag = atom->tag; type = atom->type;
mask = atom->mask; image = atom->image;
x = atom->x; v = atom->v; f = atom->f;
molecule = atom->molecule;
molindex = atom->molindex; molatom = atom->molatom;
molindex[ilocal] = -1;
molatom[ilocal] = -1;
}
/* ----------------------------------------------------------------------
copy atom I info to atom J
modify what AtomVec::data_atom() just unpacked
or initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecTemplate::copy(int i, int j, int delflag)
void AtomVecTemplate::data_atom_post(int ilocal)
{
tag[j] = tag[i];
type[j] = type[i];
mask[j] = mask[i];
image[j] = image[i];
x[j][0] = x[i][0];
x[j][1] = x[i][1];
x[j][2] = x[i][2];
v[j][0] = v[i][0];
v[j][1] = v[i][1];
v[j][2] = v[i][2];
int molindex_one = molindex[ilocal];
int molatom_one = molatom[ilocal];
molecule[j] = molecule[i];
molindex[j] = molindex[i];
molatom[j] = molatom[i];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag);
}
/* ---------------------------------------------------------------------- */
int AtomVecTemplate::pack_comm(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz;
dy = pbc[1]*domain->yprd + pbc[3]*domain->yz;
dz = pbc[2]*domain->zprd;
}
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
}
}
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecTemplate::pack_comm_vel(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz,dvx,dvy,dvz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz;
dy = pbc[1]*domain->yprd + pbc[3]*domain->yz;
dz = pbc[2]*domain->zprd;
}
if (!deform_vremap) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4];
dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3];
dvz = pbc[2]*h_rate[2];
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
if (mask[i] & deform_groupbit) {
buf[m++] = v[j][0] + dvx;
buf[m++] = v[j][1] + dvy;
buf[m++] = v[j][2] + dvz;
} else {
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
}
}
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecTemplate::unpack_comm(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
}
}
/* ---------------------------------------------------------------------- */
void AtomVecTemplate::unpack_comm_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
v[i][0] = buf[m++];
v[i][1] = buf[m++];
v[i][2] = buf[m++];
}
}
/* ---------------------------------------------------------------------- */
int AtomVecTemplate::pack_reverse(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
buf[m++] = f[i][0];
buf[m++] = f[i][1];
buf[m++] = f[i][2];
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecTemplate::unpack_reverse(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
f[j][0] += buf[m++];
f[j][1] += buf[m++];
f[j][2] += buf[m++];
}
}
/* ---------------------------------------------------------------------- */
int AtomVecTemplate::pack_border(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = ubuf(molecule[j]).d;
buf[m++] = ubuf(molindex[j]).d;
buf[m++] = ubuf(molatom[j]).d;
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0];
dy = pbc[1];
dz = pbc[2];
}
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = ubuf(molecule[j]).d;
buf[m++] = ubuf(molindex[j]).d;
buf[m++] = ubuf(molatom[j]).d;
}
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]);
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecTemplate::pack_border_vel(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz,dvx,dvy,dvz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = ubuf(molecule[j]).d;
buf[m++] = ubuf(molindex[j]).d;
buf[m++] = ubuf(molatom[j]).d;
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0];
dy = pbc[1];
dz = pbc[2];
}
if (!deform_vremap) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = ubuf(molecule[j]).d;
buf[m++] = ubuf(molindex[j]).d;
buf[m++] = ubuf(molatom[j]).d;
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4];
dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3];
dvz = pbc[2]*h_rate[2];
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = ubuf(molecule[j]).d;
buf[m++] = ubuf(molindex[j]).d;
buf[m++] = ubuf(molatom[j]).d;
if (mask[i] & deform_groupbit) {
buf[m++] = v[j][0] + dvx;
buf[m++] = v[j][1] + dvy;
buf[m++] = v[j][2] + dvz;
} else {
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
}
}
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]);
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecTemplate::pack_border_hybrid(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = ubuf(molecule[j]).d;
buf[m++] = ubuf(molindex[j]).d;
buf[m++] = ubuf(molatom[j]).d;
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecTemplate::unpack_border(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
if (i == nmax) grow(0);
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
tag[i] = (tagint) ubuf(buf[m++]).i;
type[i] = (int) ubuf(buf[m++]).i;
mask[i] = (int) ubuf(buf[m++]).i;
molecule[i] = (tagint) ubuf(buf[m++]).i;
molindex[i] = (int) ubuf(buf[m++]).i;
molatom[i] = (int) ubuf(buf[m++]).i;
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->
unpack_border(n,first,&buf[m]);
}
/* ---------------------------------------------------------------------- */
void AtomVecTemplate::unpack_border_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
if (i == nmax) grow(0);
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
tag[i] = (tagint) ubuf(buf[m++]).i;
type[i] = (int) ubuf(buf[m++]).i;
mask[i] = (int) ubuf(buf[m++]).i;
molecule[i] = (tagint) ubuf(buf[m++]).i;
molindex[i] = (int) ubuf(buf[m++]).i;
molatom[i] = (int) ubuf(buf[m++]).i;
v[i][0] = buf[m++];
v[i][1] = buf[m++];
v[i][2] = buf[m++];
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->
unpack_border(n,first,&buf[m]);
}
/* ---------------------------------------------------------------------- */
int AtomVecTemplate::unpack_border_hybrid(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
molecule[i] = (tagint) ubuf(buf[m++]).i;
molindex[i] = (int) ubuf(buf[m++]).i;
molatom[i] = (int) ubuf(buf[m++]).i;
}
return m;
}
/* ----------------------------------------------------------------------
pack data for atom I for sending to another proc
xyz must be 1st 3 values, so comm::exchange() can test on them
------------------------------------------------------------------------- */
int AtomVecTemplate::pack_exchange(int i, double *buf)
{
int m = 1;
buf[m++] = x[i][0];
buf[m++] = x[i][1];
buf[m++] = x[i][2];
buf[m++] = v[i][0];
buf[m++] = v[i][1];
buf[m++] = v[i][2];
buf[m++] = ubuf(tag[i]).d;
buf[m++] = ubuf(type[i]).d;
buf[m++] = ubuf(mask[i]).d;
buf[m++] = ubuf(image[i]).d;
buf[m++] = ubuf(molecule[i]).d;
buf[m++] = ubuf(molindex[i]).d;
buf[m++] = ubuf(molatom[i]).d;
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]);
buf[0] = m;
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecTemplate::unpack_exchange(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
int m = 1;
x[nlocal][0] = buf[m++];
x[nlocal][1] = buf[m++];
x[nlocal][2] = buf[m++];
v[nlocal][0] = buf[m++];
v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++];
tag[nlocal] = (tagint) ubuf(buf[m++]).i;
type[nlocal] = (int) ubuf(buf[m++]).i;
mask[nlocal] = (int) ubuf(buf[m++]).i;
image[nlocal] = (imageint) ubuf(buf[m++]).i;
molecule[nlocal] = (tagint) ubuf(buf[m++]).i;
molindex[nlocal] = (int) ubuf(buf[m++]).i;
molatom[nlocal] = (int) ubuf(buf[m++]).i;
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->
unpack_exchange(nlocal,&buf[m]);
atom->nlocal++;
return m;
}
/* ----------------------------------------------------------------------
size of restart data for all atoms owned by this proc
include extra data stored by fixes
------------------------------------------------------------------------- */
int AtomVecTemplate::size_restart()
{
int i;
int nlocal = atom->nlocal;
int n = 14 * nlocal;
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
for (i = 0; i < nlocal; i++)
n += modify->fix[atom->extra_restart[iextra]]->size_restart(i);
return n;
}
/* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities
xyz must be 1st 3 values, so that read_restart can test on them
molecular types may be negative, but write as positive
------------------------------------------------------------------------- */
int AtomVecTemplate::pack_restart(int i, double *buf)
{
int m = 1;
buf[m++] = x[i][0];
buf[m++] = x[i][1];
buf[m++] = x[i][2];
buf[m++] = ubuf(tag[i]).d;
buf[m++] = ubuf(type[i]).d;
buf[m++] = ubuf(mask[i]).d;
buf[m++] = ubuf(image[i]).d;
buf[m++] = v[i][0];
buf[m++] = v[i][1];
buf[m++] = v[i][2];
buf[m++] = ubuf(molecule[i]).d;
buf[m++] = ubuf(molindex[i]).d;
buf[m++] = ubuf(molatom[i]).d;
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
buf[0] = m;
return m;
}
/* ----------------------------------------------------------------------
unpack data for one atom from restart file including extra quantities
------------------------------------------------------------------------- */
int AtomVecTemplate::unpack_restart(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) {
grow(0);
if (atom->nextra_store)
memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra");
}
int m = 1;
x[nlocal][0] = buf[m++];
x[nlocal][1] = buf[m++];
x[nlocal][2] = buf[m++];
tag[nlocal] = (tagint) ubuf(buf[m++]).i;
type[nlocal] = (int) ubuf(buf[m++]).i;
mask[nlocal] = (int) ubuf(buf[m++]).i;
image[nlocal] = (imageint) ubuf(buf[m++]).i;
v[nlocal][0] = buf[m++];
v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++];
molecule[nlocal] = (tagint) ubuf(buf[m++]).i;
molindex[nlocal] = (int) ubuf(buf[m++]).i;
molatom[nlocal] = (int) ubuf(buf[m++]).i;
double **extra = atom->extra;
if (atom->nextra_store) {
int size = static_cast<int> (buf[0]) - m;
for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++];
}
atom->nlocal++;
return m;
}
/* ----------------------------------------------------------------------
create one atom of itype at coord
set other values to defaults
------------------------------------------------------------------------- */
void AtomVecTemplate::create_atom(int itype, double *coord)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
tag[nlocal] = 0;
type[nlocal] = itype;
x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2];
mask[nlocal] = 1;
image[nlocal] = ((imageint) IMGMAX << IMG2BITS) |
((imageint) IMGMAX << IMGBITS) | IMGMAX;
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
molecule[nlocal] = 0;
molindex[nlocal] = -1;
molatom[nlocal] = -1;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack one line from Atoms section of data file
initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecTemplate::data_atom(double *coord, imageint imagetmp, char **values)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
tag[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp);
if (tag[nlocal] <= 0)
error->one(FLERR,"Invalid atom ID in Atoms section of data file");
molecule[nlocal] = utils::tnumeric(FLERR,values[1],true,lmp);
molindex[nlocal] = utils::inumeric(FLERR,values[2],true,lmp) - 1;
molatom[nlocal] = utils::inumeric(FLERR,values[3],true,lmp) - 1;
if (molindex[nlocal] < 0 || molindex[nlocal] >= nset)
if (molindex_one < 0 || molindex_one >= nset)
error->one(FLERR,"Invalid template index in Atoms section of data file");
if (molatom[nlocal] < 0 ||
molatom[nlocal] >= onemols[molindex[nlocal]]->natoms)
if (molatom_one < 0 || molatom_one >= onemols[molindex_one]->natoms)
error->one(FLERR,"Invalid template atom in Atoms section of data file");
type[nlocal] = utils::inumeric(FLERR,values[4],true,lmp);
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
error->one(FLERR,"Invalid atom type in Atoms section of data file");
x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2];
image[nlocal] = imagetmp;
mask[nlocal] = 1;
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */
int AtomVecTemplate::data_atom_hybrid(int nlocal, char **values)
{
molecule[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp);
molindex[nlocal] = utils::inumeric(FLERR,values[1],true,lmp) - 1;
molatom[nlocal] = utils::inumeric(FLERR,values[2],true,lmp) - 1;
return 3;
}
/* ----------------------------------------------------------------------
pack atom info for data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecTemplate::pack_data(double **buf)
{
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
buf[i][0] = ubuf(tag[i]).d;
buf[i][1] = ubuf(molecule[i]).d;
buf[i][2] = ubuf(molindex[i]+1).d;
buf[i][3] = ubuf(molatom[i]+1).d;
buf[i][4] = ubuf(type[i]).d;
buf[i][5] = x[i][0];
buf[i][6] = x[i][1];
buf[i][7] = x[i][2];
buf[i][8] = ubuf((image[i] & IMGMASK) - IMGMAX).d;
buf[i][9] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d;
buf[i][10] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d;
}
}
/* ----------------------------------------------------------------------
pack hybrid atom info for data file
------------------------------------------------------------------------- */
int AtomVecTemplate::pack_data_hybrid(int i, double *buf)
{
buf[0] = ubuf(molecule[i]).d;
buf[1] = ubuf(molindex[i]+1).d;
buf[2] = ubuf(molatom[i]+1).d;
return 3;
}
/* ----------------------------------------------------------------------
write atom info to data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecTemplate::write_data(FILE *fp, int n, double **buf)
{
for (int i = 0; i < n; i++)
fprintf(fp,TAGINT_FORMAT " " TAGINT_FORMAT
" %d %d %d %-1.16e %-1.16e %-1.16e %d %d %d\n",
(tagint) ubuf(buf[i][0]).i,(tagint) ubuf(buf[i][1]).i,
(int) ubuf(buf[i][2]).i,(int) ubuf(buf[i][3]).i,
(int) ubuf(buf[i][4]).i,
buf[i][5],buf[i][6],buf[i][7],
(int) ubuf(buf[i][8]).i,(int) ubuf(buf[i][9]).i,
(int) ubuf(buf[i][10]).i);
}
/* ----------------------------------------------------------------------
write hybrid atom info to data file
------------------------------------------------------------------------- */
int AtomVecTemplate::write_data_hybrid(FILE *fp, double *buf)
{
fprintf(fp," " TAGINT_FORMAT " %d %d",
(tagint) ubuf(buf[0]).i,(int) ubuf(buf[1]).i,(int) ubuf(buf[2]).i);
return 3;
}
/* ----------------------------------------------------------------------
return # of bytes of allocated memory
------------------------------------------------------------------------- */
bigint AtomVecTemplate::memory_usage()
{
bigint bytes = 0;
if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax);
if (atom->memcheck("type")) bytes += memory->usage(type,nmax);
if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax);
if (atom->memcheck("image")) bytes += memory->usage(image,nmax);
if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3);
if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3);
if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3);
if (atom->memcheck("molecule")) bytes += memory->usage(molecule,nmax);
if (atom->memcheck("molindex")) bytes += memory->usage(molindex,nmax);
if (atom->memcheck("molatom")) bytes += memory->usage(molatom,nmax);
return bytes;
}

View File

@ -27,43 +27,13 @@ namespace LAMMPS_NS {
class AtomVecTemplate : public AtomVec {
public:
AtomVecTemplate(class LAMMPS *);
virtual ~AtomVecTemplate() {}
void process_args(int, char **);
void grow(int);
void grow_reset();
void copy(int, int, int);
virtual int pack_comm(int, int *, double *, int, int *);
virtual int pack_comm_vel(int, int *, double *, int, int *);
virtual void unpack_comm(int, int, double *);
virtual void unpack_comm_vel(int, int, double *);
int pack_reverse(int, int, double *);
void unpack_reverse(int, int *, double *);
virtual int pack_border(int, int *, double *, int, int *);
virtual int pack_border_vel(int, int *, double *, int, int *);
int pack_border_hybrid(int, int *, double *);
virtual void unpack_border(int, int, double *);
virtual void unpack_border_vel(int, int, double *);
int unpack_border_hybrid(int, int, double *);
virtual int pack_exchange(int, double *);
virtual int unpack_exchange(double *);
int size_restart();
int pack_restart(int, double *);
int unpack_restart(double *);
void create_atom(int, double *);
void data_atom(double *, tagint, char **);
int data_atom_hybrid(int, char **);
void pack_data(double **);
int pack_data_hybrid(int, double *);
void write_data(FILE *, int, double **);
int write_data_hybrid(FILE *, double *);
bigint memory_usage();
protected:
tagint *tag;
int *type,*mask;
tagint *image;
double **x,**v,**f;
tagint *molecule;
void grow_pointers();
void process_args(int, char **);
void create_atom_post(int);
void data_atom_post(int);
private:
int *molindex,*molatom;
};
@ -88,15 +58,6 @@ E: Atom style template molecule must have atom types
The defined molecule(s) does not specify atom types.
E: Per-processor system is too big
The number of owned atoms plus ghost atoms on a single
processor must fit in 32-bit integer.
E: Invalid atom ID in Atoms section of data file
Atom IDs must be positive integers.
E: Invalid template index in Atoms section of data file
The template indices must be between 1 to N, where N is the number of
@ -107,8 +68,4 @@ E: Invalid template atom in Atoms section of data file
The atom indices must be between 1 to N, where N is the number of
atoms in the template molecule the atom belongs to.
E: Invalid atom type in Atoms section of data file
Atom types must range from 1 to specified # of types.
*/

View File

@ -19,14 +19,9 @@
#include <cfloat>
#include <cstring>
#include "atom.h"
#include "comm.h"
#include "domain.h"
#include "modify.h"
#include "fix.h"
#include "citeme.h"
#include "memory.h"
#include "error.h"
#include "utils.h"
using namespace LAMMPS_NS;
@ -49,859 +44,72 @@ AtomVecPeri::AtomVecPeri(LAMMPS *lmp) : AtomVec(lmp)
molecular = 0;
comm_x_only = 0;
comm_f_only = 1;
size_forward = 4;
size_reverse = 3;
size_border = 12;
size_velocity = 3;
size_data_atom = 7;
size_data_vel = 4;
xcol_data = 5;
atom->rmass_flag = 1;
atom->peri_flag = 1;
atom->vfrac_flag = atom->rmass_flag = 1;
atom->vfrac_flag = 1;
// strings with peratom variables to include in each AtomVec method
// strings cannot contain fields in corresponding AtomVec default strings
// order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "rmass vfrac s0 x0";
fields_copy = (char *) "rmass vfrac s0 x0";
fields_comm = (char *) "s0";
fields_comm_vel = (char *) "s0";
fields_reverse = (char *) "";
fields_border = (char *) "rmass vfrac s0 x0";
fields_border_vel = (char *) "rmass vfrac s0 x0";
fields_exchange = (char *) "rmass vfrac s0 x0";
fields_restart = (char *) "rmass vfrac s0 x0";
fields_create = (char *) "rmass vfrac s0 x0";
fields_data_atom = (char *) "id type vfrac rmass x";
fields_data_vel = (char *) "id v omega";
setup_fields();
}
/* ----------------------------------------------------------------------
grow atom arrays
n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n
set local copies of all grow ptrs used by this class, except defaults
needed in replicate when 2 atom classes exist and it calls pack_restart()
------------------------------------------------------------------------- */
void AtomVecPeri::grow(int n)
void AtomVecPeri::grow_pointers()
{
if (n == 0) grow_nmax();
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one(FLERR,"Per-processor system is too big");
tag = memory->grow(atom->tag,nmax,"atom:tag");
type = memory->grow(atom->type,nmax,"atom:type");
mask = memory->grow(atom->mask,nmax,"atom:mask");
image = memory->grow(atom->image,nmax,"atom:image");
x = memory->grow(atom->x,nmax,3,"atom:x");
v = memory->grow(atom->v,nmax,3,"atom:v");
f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f");
vfrac = memory->grow(atom->vfrac,nmax,"atom:vfrac");
rmass = memory->grow(atom->rmass,nmax,"atom:rmass");
s0 = memory->grow(atom->s0,nmax,"atom:s0");
x0 = memory->grow(atom->x0,nmax,3,"atom:x0");
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
rmass = atom->rmass;
vfrac = atom->vfrac;
s0 = atom->s0;
x0 = atom->x0;
}
/* ----------------------------------------------------------------------
reset local array ptrs
initialize non-zero atom quantities
------------------------------------------------------------------------- */
void AtomVecPeri::grow_reset()
void AtomVecPeri::create_atom_post(int ilocal)
{
tag = atom->tag; type = atom->type;
mask = atom->mask; image = atom->image;
x = atom->x; v = atom->v; f = atom->f;
vfrac = atom->vfrac; rmass = atom->rmass;
s0 = atom->s0; x0 = atom->x0;
vfrac[ilocal] = 1.0;
rmass[ilocal] = 1.0;
s0[ilocal] = DBL_MAX;
x0[ilocal][0] = x[ilocal][0];
x0[ilocal][1] = x[ilocal][1];
x0[ilocal][2] = x[ilocal][2];
}
/* ----------------------------------------------------------------------
copy atom I info to atom J
modify what AtomVec::data_atom() just unpacked
or initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecPeri::copy(int i, int j, int delflag)
void AtomVecPeri::data_atom_post(int ilocal)
{
tag[j] = tag[i];
type[j] = type[i];
mask[j] = mask[i];
image[j] = image[i];
x[j][0] = x[i][0];
x[j][1] = x[i][1];
x[j][2] = x[i][2];
v[j][0] = v[i][0];
v[j][1] = v[i][1];
v[j][2] = v[i][2];
s0[ilocal] = DBL_MAX;
x0[ilocal][0] = x[ilocal][0];
x0[ilocal][1] = x[ilocal][1];
x0[ilocal][2] = x[ilocal][2];
vfrac[j] = vfrac[i];
rmass[j] = rmass[i];
s0[j] = s0[i];
x0[j][0] = x0[i][0];
x0[j][1] = x0[i][1];
x0[j][2] = x0[i][2];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag);
}
/* ---------------------------------------------------------------------- */
int AtomVecPeri::pack_comm(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = s0[j];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz;
dy = pbc[1]*domain->yprd + pbc[3]*domain->yz;
dz = pbc[2]*domain->zprd;
}
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = s0[j];
}
}
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecPeri::pack_comm_vel(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz,dvx,dvy,dvz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = s0[j];
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz;
dy = pbc[1]*domain->yprd + pbc[3]*domain->yz;
dz = pbc[2]*domain->zprd;
}
if (!deform_vremap) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = s0[j];
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4];
dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3];
dvz = pbc[2]*h_rate[2];
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = s0[j];
if (mask[i] & deform_groupbit) {
buf[m++] = v[j][0] + dvx;
buf[m++] = v[j][1] + dvy;
buf[m++] = v[j][2] + dvz;
} else {
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
}
}
}
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecPeri::pack_comm_hybrid(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = s0[j];
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecPeri::unpack_comm(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
s0[i] = buf[m++];
}
}
/* ---------------------------------------------------------------------- */
void AtomVecPeri::unpack_comm_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
s0[i] = buf[m++];
v[i][0] = buf[m++];
v[i][1] = buf[m++];
v[i][2] = buf[m++];
}
}
/* ---------------------------------------------------------------------- */
int AtomVecPeri::unpack_comm_hybrid(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++)
s0[i] = buf[m++];
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecPeri::pack_reverse(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
buf[m++] = f[i][0];
buf[m++] = f[i][1];
buf[m++] = f[i][2];
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecPeri::unpack_reverse(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
f[j][0] += buf[m++];
f[j][1] += buf[m++];
f[j][2] += buf[m++];
}
}
/* ---------------------------------------------------------------------- */
int AtomVecPeri::pack_border(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = vfrac[j];
buf[m++] = rmass[j];
buf[m++] = s0[j];
buf[m++] = x0[j][0];
buf[m++] = x0[j][1];
buf[m++] = x0[j][2];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0];
dy = pbc[1];
dz = pbc[2];
}
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = vfrac[j];
buf[m++] = rmass[j];
buf[m++] = s0[j];
buf[m++] = x0[j][0];
buf[m++] = x0[j][1];
buf[m++] = x0[j][2];
}
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]);
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecPeri::pack_border_vel(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz,dvx,dvy,dvz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = vfrac[j];
buf[m++] = rmass[j];
buf[m++] = s0[j];
buf[m++] = x0[j][0];
buf[m++] = x0[j][1];
buf[m++] = x0[j][2];
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0];
dy = pbc[1];
dz = pbc[2];
}
if (!deform_vremap) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = vfrac[j];
buf[m++] = rmass[j];
buf[m++] = s0[j];
buf[m++] = x0[j][0];
buf[m++] = x0[j][1];
buf[m++] = x0[j][2];
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4];
dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3];
dvz = pbc[2]*h_rate[2];
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = vfrac[j];
buf[m++] = rmass[j];
buf[m++] = s0[j];
buf[m++] = x0[j][0];
buf[m++] = x0[j][1];
buf[m++] = x0[j][2];
if (mask[i] & deform_groupbit) {
buf[m++] = v[j][0] + dvx;
buf[m++] = v[j][1] + dvy;
buf[m++] = v[j][2] + dvz;
} else {
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
}
}
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]);
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecPeri::pack_border_hybrid(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = vfrac[j];
buf[m++] = rmass[j];
buf[m++] = s0[j];
buf[m++] = x0[j][0];
buf[m++] = x0[j][1];
buf[m++] = x0[j][2];
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecPeri::unpack_border(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
if (i == nmax) grow(0);
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
tag[i] = (tagint) ubuf(buf[m++]).i;
type[i] = (int) ubuf(buf[m++]).i;
mask[i] = (int) ubuf(buf[m++]).i;
vfrac[i] = buf[m++];
rmass[i] = buf[m++];
s0[i] = buf[m++];
x0[i][0] = buf[m++];
x0[i][1] = buf[m++];
x0[i][2] = buf[m++];
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->
unpack_border(n,first,&buf[m]);
}
/* ---------------------------------------------------------------------- */
void AtomVecPeri::unpack_border_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
if (i == nmax) grow(0);
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
tag[i] = (tagint) ubuf(buf[m++]).i;
type[i] = (int) ubuf(buf[m++]).i;
mask[i] = (int) ubuf(buf[m++]).i;
vfrac[i] = buf[m++];
rmass[i] = buf[m++];
s0[i] = buf[m++];
x0[i][0] = buf[m++];
x0[i][1] = buf[m++];
x0[i][2] = buf[m++];
v[i][0] = buf[m++];
v[i][1] = buf[m++];
v[i][2] = buf[m++];
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->
unpack_border(n,first,&buf[m]);
}
/* ---------------------------------------------------------------------- */
int AtomVecPeri::unpack_border_hybrid(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
vfrac[i] = buf[m++];
rmass[i] = buf[m++];
s0[i] = buf[m++];
x0[i][0] = buf[m++];
x0[i][1] = buf[m++];
x0[i][2] = buf[m++];
}
return m;
}
/* ----------------------------------------------------------------------
pack data for atom I for sending to another proc
xyz must be 1st 3 values, so comm::exchange() can test on them
------------------------------------------------------------------------- */
int AtomVecPeri::pack_exchange(int i, double *buf)
{
int m = 1;
buf[m++] = x[i][0];
buf[m++] = x[i][1];
buf[m++] = x[i][2];
buf[m++] = v[i][0];
buf[m++] = v[i][1];
buf[m++] = v[i][2];
buf[m++] = ubuf(tag[i]).d;
buf[m++] = ubuf(type[i]).d;
buf[m++] = ubuf(mask[i]).d;
buf[m++] = ubuf(image[i]).d;
buf[m++] = vfrac[i];
buf[m++] = rmass[i];
buf[m++] = s0[i];
buf[m++] = x0[i][0];
buf[m++] = x0[i][1];
buf[m++] = x0[i][2];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]);
buf[0] = m;
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecPeri::unpack_exchange(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
int m = 1;
x[nlocal][0] = buf[m++];
x[nlocal][1] = buf[m++];
x[nlocal][2] = buf[m++];
v[nlocal][0] = buf[m++];
v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++];
tag[nlocal] = (tagint) ubuf(buf[m++]).i;
type[nlocal] = (int) ubuf(buf[m++]).i;
mask[nlocal] = (int) ubuf(buf[m++]).i;
image[nlocal] = (imageint) ubuf(buf[m++]).i;
vfrac[nlocal] = buf[m++];
rmass[nlocal] = buf[m++];
s0[nlocal] = buf[m++];
x0[nlocal][0] = buf[m++];
x0[nlocal][1] = buf[m++];
x0[nlocal][2] = buf[m++];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->
unpack_exchange(nlocal,&buf[m]);
atom->nlocal++;
return m;
}
/* ----------------------------------------------------------------------
size of restart data for all atoms owned by this proc
include extra data stored by fixes
------------------------------------------------------------------------- */
int AtomVecPeri::size_restart()
{
int i;
int nlocal = atom->nlocal;
int n = 17 * nlocal;
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
for (i = 0; i < nlocal; i++)
n += modify->fix[atom->extra_restart[iextra]]->size_restart(i);
return n;
}
/* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities
xyz must be 1st 3 values, so that read_restart can test on them
molecular types may be negative, but write as positive
------------------------------------------------------------------------- */
int AtomVecPeri::pack_restart(int i, double *buf)
{
int m = 1;
buf[m++] = x[i][0];
buf[m++] = x[i][1];
buf[m++] = x[i][2];
buf[m++] = ubuf(tag[i]).d;
buf[m++] = ubuf(type[i]).d;
buf[m++] = ubuf(mask[i]).d;
buf[m++] = ubuf(image[i]).d;
buf[m++] = v[i][0];
buf[m++] = v[i][1];
buf[m++] = v[i][2];
buf[m++] = vfrac[i];
buf[m++] = rmass[i];
buf[m++] = s0[i];
buf[m++] = x0[i][0];
buf[m++] = x0[i][1];
buf[m++] = x0[i][2];
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
buf[0] = m;
return m;
}
/* ----------------------------------------------------------------------
unpack data for one atom from restart file including extra quantities
------------------------------------------------------------------------- */
int AtomVecPeri::unpack_restart(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) {
grow(0);
if (atom->nextra_store)
memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra");
}
int m = 1;
x[nlocal][0] = buf[m++];
x[nlocal][1] = buf[m++];
x[nlocal][2] = buf[m++];
tag[nlocal] = (tagint) ubuf(buf[m++]).i;
type[nlocal] = (int) ubuf(buf[m++]).i;
mask[nlocal] = (int) ubuf(buf[m++]).i;
image[nlocal] = (imageint) ubuf(buf[m++]).i;
v[nlocal][0] = buf[m++];
v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++];
vfrac[nlocal] = buf[m++];
rmass[nlocal] = buf[m++];
s0[nlocal] = buf[m++];
x0[nlocal][0] = buf[m++];
x0[nlocal][1] = buf[m++];
x0[nlocal][2] = buf[m++];
double **extra = atom->extra;
if (atom->nextra_store) {
int size = static_cast<int> (buf[0]) - m;
for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++];
}
atom->nlocal++;
return m;
}
/* ----------------------------------------------------------------------
create one atom of itype at coord
set other values to defaults
------------------------------------------------------------------------- */
void AtomVecPeri::create_atom(int itype, double *coord)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
tag[nlocal] = 0;
type[nlocal] = itype;
x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2];
mask[nlocal] = 1;
image[nlocal] = ((imageint) IMGMAX << IMG2BITS) |
((imageint) IMGMAX << IMGBITS) | IMGMAX;
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
vfrac[nlocal] = 1.0;
rmass[nlocal] = 1.0;
s0[nlocal] = DBL_MAX;
x0[nlocal][0] = coord[0];
x0[nlocal][1] = coord[1];
x0[nlocal][2] = coord[2];
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack one line from Atoms section of data file
initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecPeri::data_atom(double *coord, imageint imagetmp, char **values)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
tag[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp);
type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp);
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
error->one(FLERR,"Invalid atom type in Atoms section of data file");
vfrac[nlocal] = utils::numeric(FLERR,values[2],true,lmp);
rmass[nlocal] = utils::numeric(FLERR,values[3],true,lmp);
if (rmass[nlocal] <= 0.0) error->one(FLERR,"Invalid mass value");
x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2];
image[nlocal] = imagetmp;
mask[nlocal] = 1;
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
s0[nlocal] = DBL_MAX;
x0[nlocal][0] = coord[0];
x0[nlocal][1] = coord[1];
x0[nlocal][2] = coord[2];
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */
int AtomVecPeri::data_atom_hybrid(int nlocal, char **values)
{
vfrac[nlocal] = utils::numeric(FLERR,values[0],true,lmp);
rmass[nlocal] = utils::numeric(FLERR,values[1],true,lmp);
if (rmass[nlocal] <= 0.0) error->one(FLERR,"Invalid mass value");
s0[nlocal] = DBL_MAX;
x0[nlocal][0] = x[nlocal][0];
x0[nlocal][1] = x[nlocal][1];
x0[nlocal][2] = x[nlocal][2];
return 2;
}
/* ----------------------------------------------------------------------
pack atom info for data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecPeri::pack_data(double **buf)
{
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
buf[i][0] = ubuf(tag[i]).d;
buf[i][1] = ubuf(type[i]).d;
buf[i][2] = vfrac[i];
buf[i][3] = rmass[i];
buf[i][4] = x[i][0];
buf[i][5] = x[i][1];
buf[i][6] = x[i][2];
buf[i][7] = ubuf((image[i] & IMGMASK) - IMGMAX).d;
buf[i][8] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d;
buf[i][9] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d;
}
}
/* ----------------------------------------------------------------------
pack hybrid atom info for data file
------------------------------------------------------------------------- */
int AtomVecPeri::pack_data_hybrid(int i, double *buf)
{
buf[0] = vfrac[i];
buf[1] = rmass[i];
return 2;
}
/* ----------------------------------------------------------------------
write atom info to data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecPeri::write_data(FILE *fp, int n, double **buf)
{
for (int i = 0; i < n; i++)
fprintf(fp,TAGINT_FORMAT
" %d %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d\n",
(tagint) ubuf(buf[i][0]).i,(int) ubuf(buf[i][1]).i,
buf[i][2],buf[i][3],buf[i][4],buf[i][5],buf[i][6],
(int) ubuf(buf[i][7]).i,(int) ubuf(buf[i][8]).i,
(int) ubuf(buf[i][9]).i);
}
/* ----------------------------------------------------------------------
write hybrid atom info to data file
------------------------------------------------------------------------- */
int AtomVecPeri::write_data_hybrid(FILE *fp, double *buf)
{
fprintf(fp," %-1.16e %-1.16e",buf[0],buf[1]);
return 2;
if (rmass[ilocal] <= 0.0)
error->one(FLERR,"Invalid mass in Atoms section of data file");
}
/* ----------------------------------------------------------------------
@ -942,27 +150,3 @@ void AtomVecPeri::pack_property_atom(int index, double *buf,
}
}
}
/* ----------------------------------------------------------------------
return # of bytes of allocated memory
------------------------------------------------------------------------- */
bigint AtomVecPeri::memory_usage()
{
bigint bytes = 0;
if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax);
if (atom->memcheck("type")) bytes += memory->usage(type,nmax);
if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax);
if (atom->memcheck("image")) bytes += memory->usage(image,nmax);
if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3);
if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3);
if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3);
if (atom->memcheck("vfrac")) bytes += memory->usage(vfrac,nmax);
if (atom->memcheck("rmass")) bytes += memory->usage(rmass,nmax);
if (atom->memcheck("s0")) bytes += memory->usage(s0,nmax);
if (atom->memcheck("x0")) bytes += memory->usage(x0,nmax,3);
return bytes;
}

View File

@ -27,45 +27,17 @@ namespace LAMMPS_NS {
class AtomVecPeri : public AtomVec {
public:
AtomVecPeri(class LAMMPS *);
void grow(int);
void grow_reset();
void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *);
int pack_comm_hybrid(int, int *, double *);
void unpack_comm(int, int, double *);
void unpack_comm_vel(int, int, double *);
int unpack_comm_hybrid(int, int, double *);
int pack_reverse(int, int, double *);
void unpack_reverse(int, int *, double *);
int pack_border(int, int *, double *, int, int *);
int pack_border_vel(int, int *, double *, int, int *);
int pack_border_hybrid(int, int *, double *);
void unpack_border(int, int, double *);
void unpack_border_vel(int, int, double *);
int unpack_border_hybrid(int, int, double *);
int pack_exchange(int, double *);
int unpack_exchange(double *);
int size_restart();
int pack_restart(int, double *);
int unpack_restart(double *);
void create_atom(int, double *);
void data_atom(double *, imageint, char **);
int data_atom_hybrid(int, char **);
void pack_data(double **);
int pack_data_hybrid(int, double *);
void write_data(FILE *, int, double **);
int write_data_hybrid(FILE *, double *);
void grow_pointers();
void create_atom_post(int);
void data_atom_post(int);
int property_atom(char *);
void pack_property_atom(int, double *, int, int);
bigint memory_usage();
private:
tagint *tag;
int *type,*mask;
imageint *image;
double **x,**v,**f;
double *vfrac,*rmass,*s0,**x0;
double *rmass,*vfrac,*s0;
double **x0;
};
}
@ -75,17 +47,4 @@ class AtomVecPeri : public AtomVec {
/* ERROR/WARNING messages:
E: Per-processor system is too big
The number of owned atoms plus ghost atoms on a single
processor must fit in 32-bit integer.
E: Invalid atom type in Atoms section of data file
Atom types must range from 1 to specified # of types.
E: Invalid mass value
Self-explanatory.
*/

View File

@ -49,6 +49,19 @@ packages_ntopo.h
# other auto-generated files
lmpinstalledpkgs.h
lmpgitversion.h
# renamed on 8 May 2020
fix_meso.cpp
fix_meso.h
fix_meso_stationary.cpp
fix_meso_stationary.h
atom_vec_meso.cpp
atom_vec_meso.h
compute_meso_e_atom.cpp
compute_meso_e_atom.h
compute_meso_rho_atom.cpp
compute_meso_rho_atom.h
compute_meso_t_atom.cpp
compute_meso_t_atom.h
# removed on 15 March 2019
fix_wall_gran_omp.h
fix_wall_gran_omp.cpp

View File

@ -27,13 +27,6 @@
#include <cmath>
#include <cstring>
#include "atom.h"
#include "comm.h"
#include "domain.h"
#include "error.h"
#include "fix.h"
#include "memory.h"
#include "modify.h"
#include "utils.h"
using namespace LAMMPS_NS;
@ -45,918 +38,65 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp)
mass_type = 1;
forceclearflag = 1;
comm_x_only = 0;
comm_f_only = 0;
size_forward = 7;
size_reverse = 9;
size_border = 10;
size_velocity = 3;
size_data_atom = 9;
size_data_vel = 4;
xcol_data = 4;
atom->sp_flag = 1;
// strings with peratom variables to include in each AtomVec method
// strings cannot contain fields in corresponding AtomVec default strings
// order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "sp fm fm_long";
fields_copy = (char *) "sp";
fields_comm = (char *) "sp";
fields_comm_vel = (char *) "sp";
fields_reverse = (char *) "fm fm_long";
fields_border = (char *) "sp";
fields_border_vel = (char *) "sp";
fields_exchange = (char *) "sp";
fields_restart = (char *) "sp";
fields_create = (char *) "sp";
fields_data_atom = (char *) "id type x sp";
fields_data_vel = (char *) "id v omega";
setup_fields();
}
/* ----------------------------------------------------------------------
grow atom arrays
n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n
set local copies of all grow ptrs used by this class, except defaults
needed in replicate when 2 atom classes exist and it calls pack_restart()
------------------------------------------------------------------------- */
void AtomVecSpin::grow(int n)
void AtomVecSpin::grow_pointers()
{
if (n == 0) grow_nmax();
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one(FLERR,"Per-processor system is too big");
tag = memory->grow(atom->tag,nmax,"atom:tag");
type = memory->grow(atom->type,nmax,"atom:type");
mask = memory->grow(atom->mask,nmax,"atom:mask");
image = memory->grow(atom->image,nmax,"atom:image");
// allocating mech. quantities
x = memory->grow(atom->x,nmax,3,"atom:x");
v = memory->grow(atom->v,nmax,3,"atom:v");
f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f");
// allocating mag. quantities
sp = memory->grow(atom->sp,nmax,4,"atom:sp");
fm = memory->grow(atom->fm,nmax*comm->nthreads,3,"atom:fm");
fm_long = memory->grow(atom->fm_long,nmax*comm->nthreads,3,"atom:fm_long");
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
sp = atom->sp;
fm = atom->fm;
fm_long = atom->fm_long;
}
/* ----------------------------------------------------------------------
reset local array ptrs
clear extra forces starting at atom N
nbytes = # of bytes to clear for a per-atom vector
include f b/c this is invoked from within SPIN pair styles
------------------------------------------------------------------------- */
void AtomVecSpin::grow_reset()
void AtomVecSpin::force_clear(int n, size_t nbytes)
{
tag = atom->tag; type = atom->type;
mask = atom->mask; image = atom->image;
x = atom->x; v = atom->v; f = atom->f;
sp = atom->sp; fm = atom->fm; fm_long = atom->fm_long;
memset(&f[n][0],0,3*nbytes);
memset(&fm[n][0],0,3*nbytes);
memset(&fm_long[n][0],0,3*nbytes);
}
/* ----------------------------------------------------------------------
copy atom I info to atom J
modify what AtomVec::data_atom() just unpacked
or initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecSpin::copy(int i, int j, int delflag)
void AtomVecSpin::data_atom_post(int ilocal)
{
tag[j] = tag[i];
type[j] = type[i];
mask[j] = mask[i];
image[j] = image[i];
x[j][0] = x[i][0];
x[j][1] = x[i][1];
x[j][2] = x[i][2];
v[j][0] = v[i][0];
v[j][1] = v[i][1];
v[j][2] = v[i][2];
sp[j][0] = sp[i][0];
sp[j][1] = sp[i][1];
sp[j][2] = sp[i][2];
sp[j][3] = sp[i][3];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag);
double *sp_one = sp[ilocal];
double norm =
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[1] *= norm;
sp_one[2] *= norm;
}
/* ---------------------------------------------------------------------- */
int AtomVecSpin::pack_comm(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = sp[j][0];
buf[m++] = sp[j][1];
buf[m++] = sp[j][2];
buf[m++] = sp[j][3];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz;
dy = pbc[1]*domain->yprd + pbc[3]*domain->yz;
dz = pbc[2]*domain->zprd;
}
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = sp[j][0];
buf[m++] = sp[j][1];
buf[m++] = sp[j][2];
buf[m++] = sp[j][3];
}
}
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecSpin::pack_comm_vel(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz,dvx,dvy,dvz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = sp[j][0];
buf[m++] = sp[j][1];
buf[m++] = sp[j][2];
buf[m++] = sp[j][3];
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz;
dy = pbc[1]*domain->yprd + pbc[3]*domain->yz;
dz = pbc[2]*domain->zprd;
}
if (!deform_vremap) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = sp[j][0];
buf[m++] = sp[j][1];
buf[m++] = sp[j][2];
buf[m++] = sp[j][3];
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4];
dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3];
dvz = pbc[2]*h_rate[2];
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = sp[j][0];
buf[m++] = sp[j][1];
buf[m++] = sp[j][2];
buf[m++] = sp[j][3];
if (mask[i] & deform_groupbit) {
buf[m++] = v[j][0] + dvx;
buf[m++] = v[j][1] + dvy;
buf[m++] = v[j][2] + dvz;
} else {
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
}
}
}
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecSpin::pack_comm_hybrid(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = sp[j][3];
buf[m++] = sp[j][0];
buf[m++] = sp[j][1];
buf[m++] = sp[j][2];
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecSpin::unpack_comm(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
sp[i][0] = buf[m++];
sp[i][1] = buf[m++];
sp[i][2] = buf[m++];
sp[i][3] = buf[m++];
}
}
/* ---------------------------------------------------------------------- */
void AtomVecSpin::unpack_comm_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
sp[i][0] = buf[m++];
sp[i][1] = buf[m++];
sp[i][2] = buf[m++];
sp[i][3] = buf[m++];
v[i][0] = buf[m++];
v[i][1] = buf[m++];
v[i][2] = buf[m++];
}
}
/* ---------------------------------------------------------------------- */
int AtomVecSpin::unpack_comm_hybrid(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
sp[i][3] = buf[m++];
sp[i][0] = buf[m++];
sp[i][1] = buf[m++];
sp[i][2] = buf[m++];
}
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecSpin::pack_reverse(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
buf[m++] = f[i][0];
buf[m++] = f[i][1];
buf[m++] = f[i][2];
buf[m++] = fm[i][0];
buf[m++] = fm[i][1];
buf[m++] = fm[i][2];
buf[m++] = fm_long[i][0];
buf[m++] = fm_long[i][1];
buf[m++] = fm_long[i][2];
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecSpin::unpack_reverse(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
f[j][0] += buf[m++];
f[j][1] += buf[m++];
f[j][2] += buf[m++];
fm[j][0] += buf[m++];
fm[j][1] += buf[m++];
fm[j][2] += buf[m++];
fm_long[j][0] += buf[m++];
fm_long[j][1] += buf[m++];
fm_long[j][2] += buf[m++];
}
}
/* ---------------------------------------------------------------------- */
int AtomVecSpin::pack_border(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = sp[j][0];
buf[m++] = sp[j][1];
buf[m++] = sp[j][2];
buf[m++] = sp[j][3];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0];
dy = pbc[1];
dz = pbc[2];
}
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = sp[j][0];
buf[m++] = sp[j][1];
buf[m++] = sp[j][2];
buf[m++] = sp[j][3];
}
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]);
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecSpin::pack_border_vel(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz,dvx,dvy,dvz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = sp[j][0];
buf[m++] = sp[j][1];
buf[m++] = sp[j][2];
buf[m++] = sp[j][3];
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0];
dy = pbc[1];
dz = pbc[2];
}
if (!deform_vremap) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = sp[j][0];
buf[m++] = sp[j][1];
buf[m++] = sp[j][2];
buf[m++] = sp[j][3];
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
} else {
dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4];
dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3];
dvz = pbc[2]*h_rate[2];
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = sp[j][0];
buf[m++] = sp[j][1];
buf[m++] = sp[j][2];
buf[m++] = sp[j][3];
if (mask[i] & deform_groupbit) {
buf[m++] = v[j][0] + dvx;
buf[m++] = v[j][1] + dvy;
buf[m++] = v[j][2] + dvz;
} else {
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
}
}
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]);
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecSpin::pack_border_hybrid(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = sp[j][3];
buf[m++] = sp[j][0];
buf[m++] = sp[j][1];
buf[m++] = sp[j][2];
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecSpin::unpack_border(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
if (i == nmax) grow(0);
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
tag[i] = (tagint) ubuf(buf[m++]).i;
type[i] = (int) ubuf(buf[m++]).i;
mask[i] = (int) ubuf(buf[m++]).i;
sp[i][0] = buf[m++];
sp[i][1] = buf[m++];
sp[i][2] = buf[m++];
sp[i][3] = buf[m++];
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->
unpack_border(n,first,&buf[m]);
}
/* ---------------------------------------------------------------------- */
void AtomVecSpin::unpack_border_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
if (i == nmax) grow(0);
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
tag[i] = (tagint) ubuf(buf[m++]).i;
type[i] = (int) ubuf(buf[m++]).i;
mask[i] = (int) ubuf(buf[m++]).i;
sp[i][0] = buf[m++];
sp[i][1] = buf[m++];
sp[i][2] = buf[m++];
sp[i][3] = buf[m++];
v[i][0] = buf[m++];
v[i][1] = buf[m++];
v[i][2] = buf[m++];
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->
unpack_border(n,first,&buf[m]);
}
/* ---------------------------------------------------------------------- */
int AtomVecSpin::unpack_border_hybrid(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
sp[i][3] = buf[m++];
sp[i][0] = buf[m++];
sp[i][1] = buf[m++];
sp[i][2] = buf[m++];
}
return m;
}
/* ----------------------------------------------------------------------
pack all atom quantities for shipping to another proc
xyz must be 1st 3 values, so that comm::exchange can test on them
------------------------------------------------------------------------- */
int AtomVecSpin::pack_exchange(int i, double *buf)
{
int m = 1;
buf[m++] = x[i][0];
buf[m++] = x[i][1];
buf[m++] = x[i][2];
buf[m++] = v[i][0];
buf[m++] = v[i][1];
buf[m++] = v[i][2];
buf[m++] = ubuf(tag[i]).d;
buf[m++] = ubuf(type[i]).d;
buf[m++] = ubuf(mask[i]).d;
buf[m++] = ubuf(image[i]).d;
buf[m++] = sp[i][0];
buf[m++] = sp[i][1];
buf[m++] = sp[i][2];
buf[m++] = sp[i][3];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]);
buf[0] = m;
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecSpin::unpack_exchange(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
int m = 1;
x[nlocal][0] = buf[m++];
x[nlocal][1] = buf[m++];
x[nlocal][2] = buf[m++];
v[nlocal][0] = buf[m++];
v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++];
tag[nlocal] = (tagint) ubuf(buf[m++]).i;
type[nlocal] = (int) ubuf(buf[m++]).i;
mask[nlocal] = (int) ubuf(buf[m++]).i;
image[nlocal] = (imageint) ubuf(buf[m++]).i;
sp[nlocal][0] = buf[m++];
sp[nlocal][1] = buf[m++];
sp[nlocal][2] = buf[m++];
sp[nlocal][3] = buf[m++];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->
unpack_exchange(nlocal,&buf[m]);
atom->nlocal++;
return m;
}
/* ----------------------------------------------------------------------
size of restart data for all atoms owned by this proc
include extra data stored by fixes
------------------------------------------------------------------------- */
int AtomVecSpin::size_restart()
{
int i;
int nlocal = atom->nlocal;
int n = 15 * nlocal;
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
for (i = 0; i < nlocal; i++)
n += modify->fix[atom->extra_restart[iextra]]->size_restart(i);
return n;
}
/* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities
xyz must be 1st 3 values, so that read_restart can test on them
molecular types may be negative, but write as positive
------------------------------------------------------------------------- */
int AtomVecSpin::pack_restart(int i, double *buf)
{
int m = 1;
buf[m++] = x[i][0];
buf[m++] = x[i][1];
buf[m++] = x[i][2];
buf[m++] = ubuf(tag[i]).d;
buf[m++] = ubuf(type[i]).d;
buf[m++] = ubuf(mask[i]).d;
buf[m++] = ubuf(image[i]).d;
buf[m++] = v[i][0];
buf[m++] = v[i][1];
buf[m++] = v[i][2];
buf[m++] = sp[i][0];
buf[m++] = sp[i][1];
buf[m++] = sp[i][2];
buf[m++] = sp[i][3];
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
buf[0] = m;
return m;
}
/* ----------------------------------------------------------------------
unpack data for one atom from restart file including extra quantities
------------------------------------------------------------------------- */
int AtomVecSpin::unpack_restart(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) {
grow(0);
if (atom->nextra_store)
memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra");
}
int m = 1;
x[nlocal][0] = buf[m++];
x[nlocal][1] = buf[m++];
x[nlocal][2] = buf[m++];
tag[nlocal] = (tagint) ubuf(buf[m++]).i;
type[nlocal] = (int) ubuf(buf[m++]).i;
mask[nlocal] = (int) ubuf(buf[m++]).i;
image[nlocal] = (imageint) ubuf(buf[m++]).i;
v[nlocal][0] = buf[m++];
v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++];
sp[nlocal][0] = buf[m++];
sp[nlocal][1] = buf[m++];
sp[nlocal][2] = buf[m++];
sp[nlocal][3] = buf[m++];
double **extra = atom->extra;
if (atom->nextra_store) {
int size = static_cast<int> (buf[0]) - m;
for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++];
}
atom->nlocal++;
return m;
}
/* ----------------------------------------------------------------------
create one atom of itype at coord
set other values to defaults
------------------------------------------------------------------------- */
void AtomVecSpin::create_atom(int itype, double *coord)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
tag[nlocal] = 0;
type[nlocal] = itype;
x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2];
mask[nlocal] = 1;
image[nlocal] = ((imageint) IMGMAX << IMG2BITS) |
((imageint) IMGMAX << IMGBITS) | IMGMAX;
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
sp[nlocal][0] = 0.0;
sp[nlocal][1] = 0.0;
sp[nlocal][2] = 0.0;
sp[nlocal][3] = 0.0;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack one line from Atoms section of data file
initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecSpin::data_atom(double *coord, imageint imagetmp, char **values)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
tag[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp);
type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp);
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
error->one(FLERR,"Invalid atom type in Atoms section of data file");
x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2];
sp[nlocal][3] = utils::numeric(FLERR,values[2],true,lmp);
sp[nlocal][0] = utils::numeric(FLERR,values[6],true,lmp);
sp[nlocal][1] = utils::numeric(FLERR,values[7],true,lmp);
sp[nlocal][2] = utils::numeric(FLERR,values[8],true,lmp);
double inorm = 1.0/sqrt(sp[nlocal][0]*sp[nlocal][0] +
sp[nlocal][1]*sp[nlocal][1] +
sp[nlocal][2]*sp[nlocal][2]);
sp[nlocal][0] *= inorm;
sp[nlocal][1] *= inorm;
sp[nlocal][2] *= inorm;
image[nlocal] = imagetmp;
mask[nlocal] = 1;
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */
int AtomVecSpin::data_atom_hybrid(int nlocal, char **values)
{
sp[nlocal][3] = utils::numeric(FLERR,values[0],true,lmp);
sp[nlocal][0] = utils::numeric(FLERR,values[1],true,lmp);
sp[nlocal][1] = utils::numeric(FLERR,values[2],true,lmp);
sp[nlocal][2] = utils::numeric(FLERR,values[3],true,lmp);
double inorm = 1.0/sqrt(sp[nlocal][0]*sp[nlocal][0] +
sp[nlocal][1]*sp[nlocal][1] +
sp[nlocal][2]*sp[nlocal][2]);
sp[nlocal][0] *= inorm;
sp[nlocal][1] *= inorm;
sp[nlocal][2] *= inorm;
return 4;
}
/* ----------------------------------------------------------------------
pack atom info for data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecSpin::pack_data(double **buf)
{
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
buf[i][0] = ubuf(tag[i]).d;
buf[i][1] = ubuf(type[i]).d;
buf[i][2] = sp[i][3];
buf[i][3] = x[i][0];
buf[i][4] = x[i][1];
buf[i][5] = x[i][2];
buf[i][6] = sp[i][0];
buf[i][7] = sp[i][1];
buf[i][8] = sp[i][2];
buf[i][9] = ubuf((image[i] & IMGMASK) - IMGMAX).d;
buf[i][10] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d;
buf[i][11] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d;
}
}
/* ----------------------------------------------------------------------
pack hybrid atom info for data file
------------------------------------------------------------------------- */
int AtomVecSpin::pack_data_hybrid(int i, double *buf)
{
buf[0] = sp[i][3];
buf[1] = sp[i][0];
buf[2] = sp[i][1];
buf[3] = sp[i][2];
return 4;
}
/* ----------------------------------------------------------------------
write atom info to data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecSpin::write_data(FILE *fp, int n, double **buf)
{
for (int i = 0; i < n; i++)
fprintf(fp,TAGINT_FORMAT \
" %d %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e "
"%-1.16e %d %d %d\n",
(tagint) ubuf(buf[i][0]).i,(int) ubuf(buf[i][1]).i,
buf[i][2],buf[i][3],buf[i][4],
buf[i][5],buf[i][6],buf[i][7],buf[i][8],
(int) ubuf(buf[i][9]).i,(int) ubuf(buf[i][10]).i,
(int) ubuf(buf[i][11]).i);
}
/* ----------------------------------------------------------------------
write hybrid atom info to data file
------------------------------------------------------------------------- */
int AtomVecSpin::write_data_hybrid(FILE *fp, double *buf)
{
fprintf(fp," %-1.16e %-1.16e %-1.16e %-1.16e",buf[0],buf[1],buf[2],buf[3]);
return 4;
}
/* ----------------------------------------------------------------------
return # of bytes of allocated memory
------------------------------------------------------------------------- */
bigint AtomVecSpin::memory_usage()
{
bigint bytes = 0;
if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax);
if (atom->memcheck("type")) bytes += memory->usage(type,nmax);
if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax);
if (atom->memcheck("image")) bytes += memory->usage(image,nmax);
if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3);
if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3);
if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3);
if (atom->memcheck("sp")) bytes += memory->usage(sp,nmax,4);
if (atom->memcheck("fm")) bytes += memory->usage(fm,nmax*comm->nthreads,3);
if (atom->memcheck("fm_long")) bytes += memory->usage(fm_long,nmax*comm->nthreads,3);
return bytes;
}
/* ----------------------------------------------------------------------
clear all forces (mech and mag)
------------------------------------------------------------------------- */
void AtomVecSpin::force_clear(int /*n*/, size_t nbytes)
{
memset(&atom->f[0][0],0,3*nbytes);
memset(&atom->fm[0][0],0,3*nbytes);
memset(&atom->fm_long[0][0],0,3*nbytes);
}

View File

@ -27,53 +27,13 @@ namespace LAMMPS_NS {
class AtomVecSpin : public AtomVec {
public:
AtomVecSpin(class LAMMPS *);
void grow(int);
void grow_reset();
void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *);
int pack_comm_hybrid(int, int *, double *);
void unpack_comm(int, int, double *);
void unpack_comm_vel(int, int, double *);
int unpack_comm_hybrid(int, int, double *);
int pack_reverse(int, int, double *);
void unpack_reverse(int, int *, double *);
int pack_border(int, int *, double *, int, int *);
int pack_border_vel(int, int *, double *, int, int *);
int pack_border_hybrid(int, int *, double *);
void unpack_border(int, int, double *);
void unpack_border_vel(int, int, double *);
int unpack_border_hybrid(int, int, double *);
int pack_exchange(int, double *);
int unpack_exchange(double *);
int size_restart();
int pack_restart(int, double *);
int unpack_restart(double *);
void create_atom(int, double *);
void data_atom(double *, imageint, char **);
int data_atom_hybrid(int, char **);
void pack_data(double **);
int pack_data_hybrid(int, double *);
void write_data(FILE *, int, double **);
int write_data_hybrid(FILE *, double *);
bigint memory_usage();
// clear magnetic and mechanic forces
void grow_pointers();
void force_clear(int, size_t);
void data_atom_post(int);
private:
tagint *tag;
int *type,*mask;
imageint *image;
double **x,**v,**f; // lattice quantities
// spin quantities
double **sp; // sp[i][0-2] direction of the spin i
// sp[i][3] atomic magnetic moment of the spin i
double **fm; // fm[i][0-2] direction of magnetic precession
double **fm_long; // storage of long-range spin prec. components
double **sp,**fm,**fm_long;
};
}
@ -83,13 +43,4 @@ class AtomVecSpin : public AtomVec {
/* ERROR/WARNING messages:
E: Per-processor system is too big
The number of owned atoms plus ghost atoms on a single
processor must fit in 32-bit integer.
E: Invalid atom type in Atoms section of data file
Atom types must range from 1 to specified # of types.
*/

File diff suppressed because it is too large Load Diff

View File

@ -11,11 +11,6 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author: Ilya Valuev (JIHT RAS)
------------------------------------------------------------------------- */
#ifdef ATOM_CLASS
AtomStyle(wavepacket,AtomVecWavepacket)
@ -32,77 +27,17 @@ namespace LAMMPS_NS {
class AtomVecWavepacket : public AtomVec {
public:
AtomVecWavepacket(class LAMMPS *);
~AtomVecWavepacket() {}
void grow(int);
void grow_reset();
void copy(int, int, int);
void grow_pointers();
void force_clear(int, size_t);
int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *);
int pack_comm_hybrid(int, int *, double *);
void unpack_comm(int, int, double *);
void unpack_comm_vel(int, int, double *);
int unpack_comm_hybrid(int, int, double *);
int pack_reverse(int, int, double *);
int pack_reverse_hybrid(int, int, double *);
void unpack_reverse(int, int *, double *);
int unpack_reverse_hybrid(int, int *, double *);
int pack_border(int, int *, double *, int, int *);
int pack_border_vel(int, int *, double *, int, int *);
int pack_border_hybrid(int, int *, double *);
void unpack_border(int, int, double *);
void unpack_border_vel(int, int, double *);
int unpack_border_hybrid(int, int, double *);
int pack_exchange(int, double *);
int unpack_exchange(double *);
int size_restart();
int pack_restart(int, double *);
int unpack_restart(double *);
void create_atom(int, double *);
void data_atom(double *, imageint, char **);
int data_atom_hybrid(int, char **);
void data_vel(int, char **);
int data_vel_hybrid(int, char **);
void pack_data(double **);
int pack_data_hybrid(int, double *);
void write_data(FILE *, int, double **);
int write_data_hybrid(FILE *, double *);
void pack_vel(double **);
int pack_vel_hybrid(int, double *);
void write_vel(FILE *, int, double **);
int write_vel_hybrid(FILE *, double *);
void create_atom_post(int);
void data_atom_post(int);
int property_atom(char *);
void pack_property_atom(int, double *, int, int);
bigint memory_usage();
private:
tagint *tag;
int *type,*mask;
imageint *image;
double **x,**v,**f;
///\en spin: -1 or 1 for electron, 0 for ion (compatible with eff)
private:
int *spin;
///\en charge: must be specified in the corresponding units (-1 for electron in real units, eff compatible)
double *q;
///\en width of the wavepacket (compatible with eff)
double *eradius;
///\en width velocity for the wavepacket (compatible with eff)
double *ervel;
///\en (generalized) force on width (compatible with eff)
double *erforce;
// AWPMD- specific:
///\en electron tag: must be the same for the WPs belonging to the same electron
int *etag;
///\en wavepacket split coefficients: cre, cim, size is 2*N
double *cs;
///\en force on wavepacket split coefficients: re, im, size is 2*N
double *csforce;
///\en (generalized) force on velocity, size is 3*N
double *vforce;
///\en (generalized) force on radius velocity, size is N
double *ervelforce;
double *q,*eradius,*ervel,*erforce;
};
}

View File

@ -74,8 +74,6 @@ void FixNVEAwpmd::init()
void FixNVEAwpmd::initial_integrate(int /* vflag */)
{
// update v,vr and x,radius of atoms in group
double **x = atom->x;
@ -84,7 +82,7 @@ void FixNVEAwpmd::initial_integrate(int /* vflag */)
double *ervel = atom->ervel;
double **f = atom->f;
double *erforce = atom->erforce;
double *vforce=atom->vforce;
double **vforce=atom->vforce;
double *ervelforce=atom->ervelforce;
double *mass = atom->mass;
@ -101,7 +99,7 @@ void FixNVEAwpmd::initial_integrate(int /* vflag */)
double dtfm = dtf / mass[type[i]];
double dtfmr=dtfm;
for(int j=0;j<3;j++){
x[i][j] += dtv*vforce[3*i+j];
x[i][j] += dtv*vforce[i][j];
v[i][j] += dtfm*f[i][j];
}
eradius[i]+= dtv*ervelforce[i];

View File

@ -259,7 +259,7 @@ void PairAWPMDCut::compute(int eflag, int vflag)
Vector_3 xx=Vector_3(x[i][0],x[i][1],x[i][2]);
Vector_3 rv=m*Vector_3(v[i][0],v[i][1],v[i][2]);
double pv=ermscale*m*atom->ervel[i];
Vector_2 cc=Vector_2(atom->cs[2*i],atom->cs[2*i+1]);
Vector_2 cc=Vector_2(atom->cs[i][0],atom->cs[i][1]);
gmap[i]=wpmd->add_split(xx,rv,atom->eradius[i],pv,cc,1.,atom->q[i],i<nlocal ? atom->tag[i] : -atom->tag[i]);
// resetting for the case constraints were applied
v[i][0]=rv[0]/m;
@ -284,7 +284,7 @@ void PairAWPMDCut::compute(int eflag, int vflag)
} else { // electron
int iel=gmap[i];
int s=spin[i] >0 ? 0 : 1;
wpmd->get_wp_force(s,iel,(Vector_3 *)f[i],(Vector_3 *)(atom->vforce+3*i),atom->erforce+i,atom->ervelforce+i,(Vector_2 *)(atom->csforce+2*i));
wpmd->get_wp_force(s,iel,(Vector_3 *)f[i],(Vector_3 *)(atom->vforce[i]),atom->erforce+i,atom->ervelforce+i,(Vector_2 *)(atom->csforce[i]));
}
}
@ -671,11 +671,11 @@ void PairAWPMDCut::min_xf_get(int /* ignore */)
double *eradius = atom->eradius;
double *erforce = atom->erforce;
double **v=atom->v;
double *vforce=atom->vforce;
double **vforce=atom->vforce;
double *ervel=atom->ervel;
double *ervelforce=atom->ervelforce;
double *cs=atom->cs;
double *csforce=atom->csforce;
double **cs=atom->cs;
double **csforce=atom->csforce;
int *spin = atom->spin;
int nlocal = atom->nlocal;
@ -686,14 +686,14 @@ void PairAWPMDCut::min_xf_get(int /* ignore */)
min_varforce[7*i] = eradius[i]*erforce[i];
for(int j=0;j<3;j++){
min_var[7*i+1+3*j] = v[i][j];
min_varforce[7*i+1+3*j] = vforce[3*i+j];
min_varforce[7*i+1+3*j] = vforce[i][j];
}
min_var[7*i+4] = ervel[i];
min_varforce[7*i+4] = ervelforce[i];
min_var[7*i+5] = cs[2*i];
min_varforce[7*i+5] = csforce[2*i];
min_var[7*i+6] = cs[2*i+1];
min_varforce[7*i+6] = csforce[2*i+1];
min_var[7*i+5] = cs[i][0];
min_varforce[7*i+5] = csforce[i][0];
min_var[7*i+6] = cs[i][1];
min_varforce[7*i+6] = csforce[i][1];
} else {
for(int j=0;j<7;j++)
@ -710,7 +710,7 @@ void PairAWPMDCut::min_x_set(int /* ignore */)
double *eradius = atom->eradius;
double **v=atom->v;
double *ervel=atom->ervel;
double *cs=atom->cs;
double **cs=atom->cs;
int *spin = atom->spin;
int nlocal = atom->nlocal;
@ -721,8 +721,8 @@ void PairAWPMDCut::min_x_set(int /* ignore */)
for(int j=0;j<3;j++)
v[i][j]=min_var[7*i+1+3*j];
ervel[i]=min_var[7*i+4];
cs[2*i]=min_var[7*i+5];
cs[2*i+1]=min_var[7*i+6];
cs[i][0]=min_var[7*i+5];
cs[i][1]=min_var[7*i+6];
}
}
}

View File

@ -17,13 +17,7 @@
#include "atom_vec_dpd.h"
#include "atom.h"
#include "comm.h"
#include "domain.h"
#include "modify.h"
#include "fix.h"
#include "memory.h"
#include "error.h"
#include "utils.h"
using namespace LAMMPS_NS;
@ -34,64 +28,37 @@ AtomVecDPD::AtomVecDPD(LAMMPS *lmp) : AtomVec(lmp)
molecular = 0;
mass_type = 1;
comm_x_only = comm_f_only = 0; // we communicate not only x forward but also dpdTheta
size_forward = 7; // 3 + dpdTheta + uCond + uMech + uChem
size_reverse = 3; // 3
size_border = 12; // 6 + dpdTheta + uCond + uMech + uChem + uCG + uCGnew
size_velocity = 3;
size_data_atom = 6; // we read id + type + dpdTheta + x + y + z
size_data_vel = 4;
xcol_data = 4; // 1=id 2=type 3=dpdTheta 4=x
atom->rho_flag = 1;
atom->dpd_flag = 1;
// strings with peratom variables to include in each AtomVec method
// strings cannot contain fields in corresponding AtomVec default strings
// order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *) "rho dpdTheta uCond uMech uChem uCG uCGnew duChem";
fields_copy = (char *) "dpdTheta uCond uMech uChem uCG uCGnew";
fields_comm = (char *) "dpdTheta uCond uMech uChem";
fields_comm_vel = (char *) "dpdTheta uCond uMech uChem";
fields_reverse = (char *) "";
fields_border = (char *) "dpdTheta uCond uMech uChem uCG uCGnew";
fields_border_vel = (char *) "dpdTheta uCond uMech uChem uCG uCGnew";
fields_exchange = (char *) "dpdTheta uCond uMech uChem uCG uCGnew";
fields_restart = (char *) "dpdTheta uCond uMech uChem";
fields_create = (char *) "rho dpdTheta uCond uMech uChem uCG uCGnew duChem";
fields_data_atom = (char *) "id type dpdTheta x";
fields_data_vel = (char *) "id v";
setup_fields();
}
/* ----------------------------------------------------------------------
grow atom arrays
n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n
set local copies of all grow ptrs used by this class, except defaults
needed in replicate when 2 atom classes exist and it calls pack_restart()
------------------------------------------------------------------------- */
void AtomVecDPD::grow(int n)
void AtomVecDPD::grow_pointers()
{
if (n == 0) grow_nmax();
else nmax = n;
atom->nmax = nmax;
if (nmax < 0)
error->one(FLERR,"Per-processor system is too big");
tag = memory->grow(atom->tag,nmax,"atom:tag");
type = memory->grow(atom->type,nmax,"atom:type");
mask = memory->grow(atom->mask,nmax,"atom:mask");
image = memory->grow(atom->image,nmax,"atom:image");
x = memory->grow(atom->x,nmax,3,"atom:x");
v = memory->grow(atom->v,nmax,3,"atom:v");
f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f");
rho = memory->grow(atom->rho, nmax, "atom:rho");
dpdTheta = memory->grow(atom->dpdTheta, nmax, "atom:dpdTheta");
uCond = memory->grow(atom->uCond,nmax,"atom:uCond");
uMech = memory->grow(atom->uMech,nmax,"atom:uMech");
uChem = memory->grow(atom->uChem,nmax,"atom:uChem");
uCG = memory->grow(atom->uCG,nmax,"atom:uCG");
uCGnew = memory->grow(atom->uCGnew,nmax,"atom:uCGnew");
duChem = memory->grow(atom->duChem,nmax,"atom:duChem");
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
}
/* ----------------------------------------------------------------------
reset local array ptrs
------------------------------------------------------------------------- */
void AtomVecDPD::grow_reset()
{
tag = atom->tag; type = atom->type;
mask = atom->mask; image = atom->image;
x = atom->x; v = atom->v; f = atom->f;
rho = atom->rho;
dpdTheta = atom->dpdTheta;
uCond = atom->uCond;
@ -99,839 +66,33 @@ void AtomVecDPD::grow_reset()
uChem = atom->uChem;
uCG = atom->uCG;
uCGnew = atom->uCGnew;
duChem = atom->duChem;
}
/* ----------------------------------------------------------------------
copy atom I info to atom J
initialize other atom quantities after AtomVec::unpack_restart()
------------------------------------------------------------------------- */
void AtomVecDPD::copy(int i, int j, int delflag)
void AtomVecDPD::unpack_restart_init(int ilocal)
{
tag[j] = tag[i];
type[j] = type[i];
mask[j] = mask[i];
image[j] = image[i];
x[j][0] = x[i][0];
x[j][1] = x[i][1];
x[j][2] = x[i][2];
v[j][0] = v[i][0];
v[j][1] = v[i][1];
v[j][2] = v[i][2];
dpdTheta[j] = dpdTheta[i];
uCond[j] = uCond[i];
uMech[j] = uMech[i];
uChem[j] = uChem[i];
uCG[j] = uCG[i];
uCGnew[j] = uCGnew[i];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag);
}
/* ---------------------------------------------------------------------- */
int AtomVecDPD::pack_comm(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = dpdTheta[j];
buf[m++] = uCond[j];
buf[m++] = uMech[j];
buf[m++] = uChem[j];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz;
dy = pbc[1]*domain->yprd + pbc[3]*domain->yz;
dz = pbc[2]*domain->zprd;
}
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = dpdTheta[j];
buf[m++] = uCond[j];
buf[m++] = uMech[j];
buf[m++] = uChem[j];
}
}
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecDPD::pack_comm_vel(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz,dvx,dvy,dvz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
buf[m++] = dpdTheta[j];
buf[m++] = uCond[j];
buf[m++] = uMech[j];
buf[m++] = uChem[j];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz;
dy = pbc[1]*domain->yprd + pbc[3]*domain->yz;
dz = pbc[2]*domain->zprd;
}
if (!deform_vremap) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
buf[m++] = dpdTheta[j];
buf[m++] = uCond[j];
buf[m++] = uMech[j];
buf[m++] = uChem[j];
}
} else {
dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4];
dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3];
dvz = pbc[2]*h_rate[2];
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
if (mask[i] & deform_groupbit) {
buf[m++] = v[j][0] + dvx;
buf[m++] = v[j][1] + dvy;
buf[m++] = v[j][2] + dvz;
} else {
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
buf[m++] = dpdTheta[j];
buf[m++] = uCond[j];
buf[m++] = uMech[j];
buf[m++] = uChem[j];
}
}
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecDPD::unpack_comm(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
dpdTheta[i] = buf[m++];
uCond[i] = buf[m++];
uMech[i] = buf[m++];
uChem[i] = buf[m++];
}
}
/* ---------------------------------------------------------------------- */
void AtomVecDPD::unpack_comm_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
v[i][0] = buf[m++];
v[i][1] = buf[m++];
v[i][2] = buf[m++];
dpdTheta[i] = buf[m++];
uCond[i] = buf[m++];
uMech[i] = buf[m++];
uChem[i] = buf[m++];
}
}
/* ---------------------------------------------------------------------- */
int AtomVecDPD::pack_reverse(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
buf[m++] = f[i][0];
buf[m++] = f[i][1];
buf[m++] = f[i][2];
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecDPD::unpack_reverse(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
f[j][0] += buf[m++];
f[j][1] += buf[m++];
f[j][2] += buf[m++];
}
}
/* ---------------------------------------------------------------------- */
int AtomVecDPD::pack_border(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = dpdTheta[j];
buf[m++] = uCond[j];
buf[m++] = uMech[j];
buf[m++] = uChem[j];
buf[m++] = uCG[j];
buf[m++] = uCGnew[j];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0];
dy = pbc[1];
dz = pbc[2];
}
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = dpdTheta[j];
buf[m++] = uCond[j];
buf[m++] = uMech[j];
buf[m++] = uChem[j];
buf[m++] = uCG[j];
buf[m++] = uCGnew[j];
}
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]);
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecDPD::pack_border_vel(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz,dvx,dvy,dvz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
buf[m++] = dpdTheta[j];
buf[m++] = uCond[j];
buf[m++] = uMech[j];
buf[m++] = uChem[j];
buf[m++] = uCG[j];
buf[m++] = uCGnew[j];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0];
dy = pbc[1];
dz = pbc[2];
}
if (!deform_vremap) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
buf[m++] = dpdTheta[j];
buf[m++] = uCond[j];
buf[m++] = uMech[j];
buf[m++] = uChem[j];
buf[m++] = uCG[j];
buf[m++] = uCGnew[j];
}
} else {
dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4];
dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3];
dvz = pbc[2]*h_rate[2];
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
if (mask[i] & deform_groupbit) {
buf[m++] = v[j][0] + dvx;
buf[m++] = v[j][1] + dvy;
buf[m++] = v[j][2] + dvz;
} else {
buf[m++] = v[j][0];
buf[m++] = v[j][1];
buf[m++] = v[j][2];
}
buf[m++] = dpdTheta[j];
buf[m++] = uCond[j];
buf[m++] = uMech[j];
buf[m++] = uChem[j];
buf[m++] = uCG[j];
buf[m++] = uCGnew[j];
}
}
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]);
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecDPD::pack_comm_hybrid(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = dpdTheta[j];
buf[m++] = uCond[j];
buf[m++] = uMech[j];
buf[m++] = uChem[j];
}
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecDPD::pack_border_hybrid(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = dpdTheta[j];
buf[m++] = uCond[j];
buf[m++] = uMech[j];
buf[m++] = uChem[j];
buf[m++] = uCG[j];
buf[m++] = uCGnew[j];
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecDPD::unpack_border(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
if (i == nmax) grow(0);
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
tag[i] = (tagint) ubuf(buf[m++]).i;
type[i] = (int) ubuf(buf[m++]).i;
mask[i] = (int) ubuf(buf[m++]).i;
dpdTheta[i] = buf[m++];
uCond[i] = buf[m++];
uMech[i] = buf[m++];
uChem[i] = buf[m++];
uCG[i] = buf[m++];
uCGnew[i] = buf[m++];
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->
unpack_border(n,first,&buf[m]);
}
/* ---------------------------------------------------------------------- */
void AtomVecDPD::unpack_border_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
if (i == nmax) grow(0);
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
tag[i] = (tagint) ubuf(buf[m++]).i;
type[i] = (int) ubuf(buf[m++]).i;
mask[i] = (int) ubuf(buf[m++]).i;
v[i][0] = buf[m++];
v[i][1] = buf[m++];
v[i][2] = buf[m++];
dpdTheta[i] = buf[m++];
uCond[i] = buf[m++];
uMech[i] = buf[m++];
uChem[i] = buf[m++];
uCG[i] = buf[m++];
uCGnew[i] = buf[m++];
}
if (atom->nextra_border)
for (int iextra = 0; iextra < atom->nextra_border; iextra++)
m += modify->fix[atom->extra_border[iextra]]->
unpack_border(n,first,&buf[m]);
}
/* ---------------------------------------------------------------------- */
int AtomVecDPD::unpack_comm_hybrid(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
dpdTheta[i] = buf[m++];
uCond[i] = buf[m++];
uMech[i] = buf[m++];
uChem[i] = buf[m++];
}
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecDPD::unpack_border_hybrid(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
dpdTheta[i] = buf[m++];
uCond[i] = buf[m++];
uMech[i] = buf[m++];
uChem[i] = buf[m++];
uCG[i] = buf[m++];
uCGnew[i] = buf[m++];
}
return m;
uCG[ilocal] = 0.0;
uCGnew[ilocal] = 0.0;
}
/* ----------------------------------------------------------------------
pack data for atom I for sending to another proc
xyz must be 1st 3 values, so comm::exchange() can test on them
modify what AtomVec::data_atom() just unpacked
or initialize other atom quantities
------------------------------------------------------------------------- */
int AtomVecDPD::pack_exchange(int i, double *buf)
void AtomVecDPD::data_atom_post(int ilocal)
{
int m = 1;
buf[m++] = x[i][0];
buf[m++] = x[i][1];
buf[m++] = x[i][2];
buf[m++] = v[i][0];
buf[m++] = v[i][1];
buf[m++] = v[i][2];
buf[m++] = ubuf(tag[i]).d;
buf[m++] = ubuf(type[i]).d;
buf[m++] = ubuf(mask[i]).d;
buf[m++] = ubuf(image[i]).d;
buf[m++] = dpdTheta[i];
buf[m++] = uCond[i];
buf[m++] = uMech[i];
buf[m++] = uChem[i];
buf[m++] = uCG[i];
buf[m++] = uCGnew[i];
rho[ilocal] = 0.0;
uCond[ilocal] = 0.0;
uMech[ilocal] = 0.0;
uChem[ilocal] = 0.0;
uCG[ilocal] = 0.0;
uCGnew[ilocal] = 0.0;
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]);
buf[0] = m;
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecDPD::unpack_exchange(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
int m = 1;
x[nlocal][0] = buf[m++];
x[nlocal][1] = buf[m++];
x[nlocal][2] = buf[m++];
v[nlocal][0] = buf[m++];
v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++];
tag[nlocal] = (tagint) ubuf(buf[m++]).i;
type[nlocal] = (int) ubuf(buf[m++]).i;
mask[nlocal] = (int) ubuf(buf[m++]).i;
image[nlocal] = (imageint) ubuf(buf[m++]).i;
dpdTheta[nlocal] = buf[m++];
uCond[nlocal] = buf[m++];
uMech[nlocal] = buf[m++];
uChem[nlocal] = buf[m++];
uCG[nlocal] = buf[m++];
uCGnew[nlocal] = buf[m++];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->
unpack_exchange(nlocal,&buf[m]);
atom->nlocal++;
return m;
}
/* ----------------------------------------------------------------------
size of restart data for all atoms owned by this proc
include extra data stored by fixes
------------------------------------------------------------------------- */
int AtomVecDPD::size_restart()
{
int i;
int nlocal = atom->nlocal;
int n = 15 * nlocal; // 11 + dpdTheta + uCond + uMech + uChem
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
for (i = 0; i < nlocal; i++)
n += modify->fix[atom->extra_restart[iextra]]->size_restart(i);
return n;
}
/* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities
xyz must be 1st 3 values, so that read_restart can test on them
molecular types may be negative, but write as positive
------------------------------------------------------------------------- */
int AtomVecDPD::pack_restart(int i, double *buf)
{
int m = 1;
buf[m++] = x[i][0];
buf[m++] = x[i][1];
buf[m++] = x[i][2];
buf[m++] = ubuf(tag[i]).d;
buf[m++] = ubuf(type[i]).d;
buf[m++] = ubuf(mask[i]).d;
buf[m++] = ubuf(image[i]).d;
buf[m++] = v[i][0];
buf[m++] = v[i][1];
buf[m++] = v[i][2];
buf[m++] = dpdTheta[i];
buf[m++] = uCond[i];
buf[m++] = uMech[i];
buf[m++] = uChem[i];
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
buf[0] = m;
return m;
}
/* ----------------------------------------------------------------------
unpack data for one atom from restart file including extra quantities
------------------------------------------------------------------------- */
int AtomVecDPD::unpack_restart(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) {
grow(0);
if (atom->nextra_store)
memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra");
}
int m = 1;
x[nlocal][0] = buf[m++];
x[nlocal][1] = buf[m++];
x[nlocal][2] = buf[m++];
tag[nlocal] = (tagint) ubuf(buf[m++]).i;
type[nlocal] = (int) ubuf(buf[m++]).i;
mask[nlocal] = (int) ubuf(buf[m++]).i;
image[nlocal] = (imageint) ubuf(buf[m++]).i;
v[nlocal][0] = buf[m++];
v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++];
dpdTheta[nlocal] = buf[m++];
uCond[nlocal] = buf[m++];
uMech[nlocal] = buf[m++];
uChem[nlocal] = buf[m++];
uCG[nlocal] = 0.0;
uCGnew[nlocal] = 0.0;
double **extra = atom->extra;
if (atom->nextra_store) {
int size = static_cast<int> (buf[0]) - m;
for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++];
}
atom->nlocal++;
return m;
}
/* ----------------------------------------------------------------------
create one atom of itype at coord
set other values to defaults
------------------------------------------------------------------------- */
void AtomVecDPD::create_atom(int itype, double *coord)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
tag[nlocal] = 0;
type[nlocal] = itype;
x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2];
mask[nlocal] = 1;
image[nlocal] = ((imageint) IMGMAX << IMG2BITS) |
((imageint) IMGMAX << IMGBITS) | IMGMAX;
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
rho[nlocal] = 0.0;
dpdTheta[nlocal] = 0.0;
uCond[nlocal] = 0.0;
uMech[nlocal] = 0.0;
uChem[nlocal] = 0.0;
uCG[nlocal] = 0.0;
uCGnew[nlocal] = 0.0;
duChem[nlocal] = 0.0;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack one line from Atoms section of data file
initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecDPD::data_atom(double *coord, tagint imagetmp, char **values)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
tag[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp);
type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp);
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
error->one(FLERR,"Invalid atom type in Atoms section of data file");
dpdTheta[nlocal] = utils::numeric(FLERR,values[2],true,lmp);
if (dpdTheta[nlocal] <= 0)
error->one(FLERR,"Internal temperature in Atoms section of date file must be > zero");
x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2];
image[nlocal] = imagetmp;
mask[nlocal] = 1;
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
rho[nlocal] = 0.0;
uCond[nlocal] = 0.0;
uMech[nlocal] = 0.0;
uChem[nlocal] = 0.0;
uCG[nlocal] = 0.0;
uCGnew[nlocal] = 0.0;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */
int AtomVecDPD::data_atom_hybrid(int nlocal, char **values)
{
dpdTheta[nlocal] = utils::numeric(FLERR,values[0],true,lmp);
return 1;
}
/* ----------------------------------------------------------------------
pack atom info for data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecDPD::pack_data(double **buf)
{
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
buf[i][0] = ubuf(tag[i]).d;
buf[i][1] = ubuf(type[i]).d;
buf[i][2] = dpdTheta[i];
buf[i][3] = x[i][0];
buf[i][4] = x[i][1];
buf[i][5] = x[i][2];
buf[i][6] = ubuf((image[i] & IMGMASK) - IMGMAX).d;
buf[i][7] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d;
buf[i][8] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d;
}
}
/* ----------------------------------------------------------------------
pack hybrid atom info for data file
------------------------------------------------------------------------- */
int AtomVecDPD::pack_data_hybrid(int i, double *buf)
{
buf[0] = dpdTheta[i];
return 1;
}
/* ----------------------------------------------------------------------
write atom info to data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecDPD::write_data(FILE *fp, int n, double **buf)
{
for (int i = 0; i < n; i++)
fprintf(fp,TAGINT_FORMAT " %d %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d\n",
(tagint) ubuf(buf[i][0]).i,(int) ubuf(buf[i][1]).i,
buf[i][2],buf[i][3],buf[i][4],buf[i][5],
(int) ubuf(buf[i][6]).i,(int) ubuf(buf[i][7]).i,
(int) ubuf(buf[i][8]).i);
}
/* ----------------------------------------------------------------------
write hybrid atom info to data file
------------------------------------------------------------------------- */
int AtomVecDPD::write_data_hybrid(FILE *fp, double *buf)
{
fprintf(fp," %-1.16e",buf[0]);
return 1;
}
/* ----------------------------------------------------------------------
return # of bytes of allocated memory
------------------------------------------------------------------------- */
bigint AtomVecDPD::memory_usage()
{
bigint bytes = 0;
if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax);
if (atom->memcheck("type")) bytes += memory->usage(type,nmax);
if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax);
if (atom->memcheck("image")) bytes += memory->usage(image,nmax);
if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3);
if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3);
if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3);
if (atom->memcheck("rho")) bytes += memory->usage(rho,nmax);
if (atom->memcheck("dpdTheta")) bytes += memory->usage(dpdTheta,nmax);
if (atom->memcheck("uCond")) bytes += memory->usage(uCond,nmax);
if (atom->memcheck("uMech")) bytes += memory->usage(uMech,nmax);
if (atom->memcheck("uChem")) bytes += memory->usage(uChem,nmax);
if (atom->memcheck("uCG")) bytes += memory->usage(uCG,nmax);
if (atom->memcheck("uCGnew")) bytes += memory->usage(uCGnew,nmax);
if (atom->memcheck("duChem")) bytes += memory->usage(duChem,nmax);
return bytes;
if (dpdTheta[ilocal] <= 0)
error->one(FLERR,"Internal temperature in Atoms section of date file "
"must be > zero");
}

View File

@ -27,46 +27,15 @@ namespace LAMMPS_NS {
class AtomVecDPD : public AtomVec {
public:
AtomVecDPD(class LAMMPS *);
virtual ~AtomVecDPD() {}
void grow(int);
void grow_reset();
void copy(int, int, int);
virtual int pack_comm(int, int *, double *, int, int *);
virtual int pack_comm_vel(int, int *, double *, int, int *);
int pack_comm_hybrid(int, int *, double *);
virtual void unpack_comm(int, int, double *);
virtual void unpack_comm_vel(int, int, double *);
int unpack_comm_hybrid(int, int, double *);
int pack_reverse(int, int, double *);
void unpack_reverse(int, int *, double *);
virtual int pack_border(int, int *, double *, int, int *);
virtual int pack_border_vel(int, int *, double *, int, int *);
int pack_border_hybrid(int, int *, double *);
virtual void unpack_border(int, int, double *);
virtual void unpack_border_vel(int, int, double *);
int unpack_border_hybrid(int, int, double *);
virtual int pack_exchange(int, double *);
virtual int unpack_exchange(double *);
int size_restart();
int pack_restart(int, double *);
int unpack_restart(double *);
void create_atom(int, double *);
void data_atom(double *, imageint, char **);
int data_atom_hybrid(int, char **);
void pack_data(double **);
int pack_data_hybrid(int, double *);
void write_data(FILE *, int, double **);
int write_data_hybrid(FILE *, double *);
bigint memory_usage();
double *uCond,*uMech,*uChem,*uCG,*uCGnew,*rho,*dpdTheta;
double *duChem;
protected:
tagint *tag;
int *type,*mask;
imageint *image;
double **x,**v,**f;
void grow_pointers();
void unpack_restart_init(int);
void data_atom_post(int);
private:
double *rho,*dpdTheta;
double *uCond,*uMech,*uChem;
double *uCG,*uCGnew;
};
}
@ -76,15 +45,6 @@ class AtomVecDPD : public AtomVec {
/* ERROR/WARNING messages:
E: Per-processor system is too big
The number of owned atoms plus ghost atoms on a single
processor must fit in 32-bit integer.
E: Invalid atom type in Atoms section of data file
Atom types must range from 1 to specified # of types.
E: Internal temperature in Atoms section of data file must be > zero
All internal temperatures must be > zero

File diff suppressed because it is too large Load Diff

View File

@ -27,56 +27,17 @@ namespace LAMMPS_NS {
class AtomVecElectron : public AtomVec {
public:
AtomVecElectron(class LAMMPS *);
~AtomVecElectron() {}
void grow(int);
void grow_reset();
void copy(int, int, int);
void grow_pointers();
void force_clear(int, size_t);
int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *);
int pack_comm_hybrid(int, int *, double *);
void unpack_comm(int, int, double *);
void unpack_comm_vel(int, int, double *);
int unpack_comm_hybrid(int, int, double *);
int pack_reverse(int, int, double *);
int pack_reverse_hybrid(int, int, double *);
void unpack_reverse(int, int *, double *);
int unpack_reverse_hybrid(int, int *, double *);
int pack_border(int, int *, double *, int, int *);
int pack_border_vel(int, int *, double *, int, int *);
int pack_border_hybrid(int, int *, double *);
void unpack_border(int, int, double *);
void unpack_border_vel(int, int, double *);
int unpack_border_hybrid(int, int, double *);
int pack_exchange(int, double *);
int unpack_exchange(double *);
int size_restart();
int pack_restart(int, double *);
int unpack_restart(double *);
void create_atom(int, double *);
void data_atom(double *, imageint, char **);
int data_atom_hybrid(int, char **);
void data_vel(int, char **);
int data_vel_hybrid(int, char **);
void pack_data(double **);
int pack_data_hybrid(int, double *);
void write_data(FILE *, int, double **);
int write_data_hybrid(FILE *, double *);
void pack_vel(double **);
int pack_vel_hybrid(int, double *);
void write_vel(FILE *, int, double **);
int write_vel_hybrid(FILE *, double *);
void create_atom_post(int);
void data_atom_post(int);
int property_atom(char *);
void pack_property_atom(int, double *, int, int);
bigint memory_usage();
private:
tagint *tag;
int *type,*mask;
imageint *image;
double **x,**v,**f;
private:
int *spin;
double *q,*eradius,*ervel,*erforce;
double *eradius,*ervel,*erforce;
};
}

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