Merge branch 'develop' into distributed-grids

This commit is contained in:
Axel Kohlmeyer
2022-12-14 18:12:10 -05:00
249 changed files with 11456 additions and 9587 deletions

2
.github/CODEOWNERS vendored
View File

@ -64,6 +64,8 @@ src/MANYBODY/pair_atm.* @sergeylishchuk
src/REPLICA/*_grem.* @dstelter92 src/REPLICA/*_grem.* @dstelter92
src/EXTRA-COMPUTE/compute_stress_mop*.* @RomainVermorel src/EXTRA-COMPUTE/compute_stress_mop*.* @RomainVermorel
src/MISC/*_tracker.* @jtclemm src/MISC/*_tracker.* @jtclemm
src/MC/fix_gcmc.* @athomps
src/MC/fix_sgcmc.* @athomps
# core LAMMPS classes # core LAMMPS classes
src/lammps.* @sjplimp src/lammps.* @sjplimp

View File

@ -668,7 +668,7 @@ endif()
# packages which selectively include variants based on enabled styles # packages which selectively include variants based on enabled styles
# e.g. accelerator packages # e.g. accelerator packages
###################################################################### ######################################################################
foreach(PKG_WITH_INCL CORESHELL DPD-SMOOTH MISC PHONON QEQ OPENMP KOKKOS OPT INTEL GPU) foreach(PKG_WITH_INCL CORESHELL DPD-SMOOTH MC MISC PHONON QEQ OPENMP KOKKOS OPT INTEL GPU)
if(PKG_${PKG_WITH_INCL}) if(PKG_${PKG_WITH_INCL})
include(Packages/${PKG_WITH_INCL}) include(Packages/${PKG_WITH_INCL})
endif() endif()

View File

@ -0,0 +1,9 @@
# fix sgcmc may only be installed if also the EAM pair style from MANYBODY is installed
if(NOT PKG_MANYBODY)
get_property(LAMMPS_FIX_HEADERS GLOBAL PROPERTY FIX)
list(REMOVE_ITEM LAMMPS_FIX_HEADERS ${LAMMPS_SOURCE_DIR}/MC/fix_sgcmc.h)
set_property(GLOBAL PROPERTY FIX "${LAMMPS_FIX_HEADERS}")
get_target_property(LAMMPS_SOURCES lammps SOURCES)
list(REMOVE_ITEM LAMMPS_SOURCES ${LAMMPS_SOURCE_DIR}/MC/fix_sgcmc.cpp)
set_property(TARGET lammps PROPERTY SOURCES "${LAMMPS_SOURCES}")
endif()

View File

@ -36,6 +36,7 @@ This is the list of packages that may require additional steps.
* :ref:`AWPMD <awpmd>` * :ref:`AWPMD <awpmd>`
* :ref:`COLVARS <colvars>` * :ref:`COLVARS <colvars>`
* :ref:`COMPRESS <compress>` * :ref:`COMPRESS <compress>`
* :ref:`ELECTRODE <electrode>`
* :ref:`GPU <gpu>` * :ref:`GPU <gpu>`
* :ref:`H5MD <h5md>` * :ref:`H5MD <h5md>`
* :ref:`INTEL <intel>` * :ref:`INTEL <intel>`

View File

@ -214,6 +214,7 @@ OPT.
* :doc:`saed/vtk <fix_saed_vtk>` * :doc:`saed/vtk <fix_saed_vtk>`
* :doc:`setforce (k) <fix_setforce>` * :doc:`setforce (k) <fix_setforce>`
* :doc:`setforce/spin <fix_setforce>` * :doc:`setforce/spin <fix_setforce>`
* :doc:`sgcmc <fix_sgcmc>`
* :doc:`shake (k) <fix_shake>` * :doc:`shake (k) <fix_shake>`
* :doc:`shardlow (k) <fix_shardlow>` * :doc:`shardlow (k) <fix_shardlow>`
* :doc:`smd <fix_smd>` * :doc:`smd <fix_smd>`

View File

@ -11,6 +11,8 @@ with the direct alternative (if available) and print a warning.
Fix ave/spatial and fix ave/spatial/sphere Fix ave/spatial and fix ave/spatial/sphere
------------------------------------------ ------------------------------------------
.. deprecated:: 11Dec2015
The fixes ave/spatial and ave/spatial/sphere have been removed from LAMMPS The fixes ave/spatial and ave/spatial/sphere have been removed from LAMMPS
since they were superseded by the more general and extensible "chunk since they were superseded by the more general and extensible "chunk
infrastructure". Here the system is partitioned in one of many possible infrastructure". Here the system is partitioned in one of many possible

View File

@ -1486,8 +1486,9 @@ MC package
Several fixes and a pair style that have Monte Carlo (MC) or MC-like Several fixes and a pair style that have Monte Carlo (MC) or MC-like
attributes. These include fixes for creating, breaking, and swapping attributes. These include fixes for creating, breaking, and swapping
bonds, for performing atomic swaps, and performing grand-canonical MC bonds, for performing atomic swaps, and performing grand canonical
(GCMC) or similar processes in conjunction with dynamics. MC (GCMC), semi-grand canonical MC (SGCMC), or similar processes in
conjunction with molecular dynamics (MD).
**Supporting info:** **Supporting info:**
@ -1499,6 +1500,7 @@ bonds, for performing atomic swaps, and performing grand-canonical MC
* :doc:`fix bond/swap <fix_bond_swap>` * :doc:`fix bond/swap <fix_bond_swap>`
* :doc:`fix charge/regulation <fix_charge_regulation>` * :doc:`fix charge/regulation <fix_charge_regulation>`
* :doc:`fix gcmc <fix_gcmc>` * :doc:`fix gcmc <fix_gcmc>`
* :doc:`fix sgcmc <fix_sgcmc>`
* :doc:`fix tfmc <fix_tfmc>` * :doc:`fix tfmc <fix_tfmc>`
* :doc:`fix widom <fix_widom>` * :doc:`fix widom <fix_widom>`
* :doc:`pair_style dsmc <pair_dsmc>` * :doc:`pair_style dsmc <pair_dsmc>`

View File

@ -366,6 +366,7 @@ accelerated styles exist.
* :doc:`saed/vtk <fix_saed_vtk>` - time-average the intensities from :doc:`compute saed <compute_saed>` * :doc:`saed/vtk <fix_saed_vtk>` - time-average the intensities from :doc:`compute saed <compute_saed>`
* :doc:`setforce <fix_setforce>` - set the force on each atom * :doc:`setforce <fix_setforce>` - set the force on each atom
* :doc:`setforce/spin <fix_setforce>` - set magnetic precession vectors on each atom * :doc:`setforce/spin <fix_setforce>` - set magnetic precession vectors on each atom
* :doc:`sgcmc <fix_sgcmc>` - fix for hybrid semi-grand canonical MD/MC simulations
* :doc:`shake <fix_shake>` - SHAKE constraints on bonds and/or angles * :doc:`shake <fix_shake>` - SHAKE constraints on bonds and/or angles
* :doc:`shardlow <fix_shardlow>` - integration of DPD equations of motion using the Shardlow splitting * :doc:`shardlow <fix_shardlow>` - integration of DPD equations of motion using the Shardlow splitting
* :doc:`smd <fix_smd>` - applied a steered MD force to a group * :doc:`smd <fix_smd>` - applied a steered MD force to a group

View File

@ -0,0 +1,9 @@
Fix ave/spatial command
=======================
.. meta::
:http-equiv=Refresh: 5; url='https://docs.lammps.org/Commands_removed.html#fix-ave-spatial-and-fix-ave-spatial-sphere'
.. deprecated:: 11Dec2015
The `fix ave/spatial` command has been superseded by :doc:`fix ave/chunk <fix_ave_chunk>`.

View File

@ -0,0 +1,9 @@
Fix ave/spatial command
=======================
.. meta::
:http-equiv=Refresh: 5; url='https://docs.lammps.org/Commands_removed.html#fix-ave-spatial-and-fix-ave-spatial-sphere'
.. deprecated:: 11Dec2015
The `fix ave/spatial/sphere` command has been superseded by :doc:`fix ave/chunk <fix_ave_chunk>`.

188
doc/src/fix_sgcmc.rst Normal file
View File

@ -0,0 +1,188 @@
.. index:: fix sgcmc
fix sgcmc command
=================
Syntax
""""""
.. parsed-literal::
fix ID group-ID sgcmc every_nsteps swap_fraction temperature deltamu ...
* ID, group-ID are documented in :doc:`fix <fix>` command
* sgcmc = style name of this fix command
* every_nsteps = number of MD steps between MC cycles
* swap_fraction = fraction of a full MC cycle carried out at each call (a value of 1.0 will perform as many trial moves as there are atoms)
* temperature = temperature that enters Boltzmann factor in Metropolis criterion (usually the same as MD temperature)
* deltamu = chemical potential difference(s) (`N-1` values must be provided, with `N` being the number of elements)
* Zero or more keyword/value pairs may be appended to fix definition line:
.. parsed-literal::
keyword = *variance* or *randseed* or *window_moves* or *window_size*
*variance* kappa conc1 [conc2] ... [concN]
kappa = variance constraint parameter
conc1,conc2,... = target concentration(s) in the range 0.0-1.0 (*N-1* values must be provided, with *N* being the number of elements)
*randseed* N
N = seed for pseudo random number generator
*window_moves* N
N = number of times sampling window is moved during one MC cycle
*window_size* frac
frac = size of sampling window (must be between 0.5 and 1.0)
Examples
""""""""
.. code-block:: LAMMPS
fix mc all sgcmc 50 0.1 400.0 -0.55
fix vc all sgcmc 20 0.2 700.0 -0.7 randseed 324234 variance 2000.0 0.05
fix 2 all sgcmc 20 0.1 700.0 -0.7 window_moves 20
Description
"""""""""""
.. versionadded:: TBD
This command allows to carry out parallel hybrid molecular
dynamics/Monte Carlo (MD/MC) simulations using the algorithms described
in :ref:`(Sadigh1) <Sadigh1>`. Simulations can be carried out in either
the semi-grand canonical (SGC) or variance constrained semi-grand
canonical (VC-SGC) ensemble :ref:`(Sadigh2) <Sadigh2>`. Only atom type
swaps are performed by the SGCMC fix. Relaxations are accounted for by
the molecular dynamics integration steps.
This fix can be used with standard multi-element EAM potentials
(:doc:`pair styles eam/alloy or eam/fs <pair_eam>`)
The SGCMC fix can handle Finnis/Sinclair type EAM potentials where
:math:`\rho(r)` is atom-type specific, such that different elements can
contribute differently to the total electron density at an atomic site
depending on the identity of the element at that atomic site.
------------
If this fix is applied, the regular MD simulation will be interrupted in
defined intervals to carry out a fraction of a Monte Carlo (MC)
cycle. The interval is set using the parameter *every_nsteps* which
determines how many MD integrator steps are taken between subsequent
calls to the MC routine.
It is possible to carry out pure lattice MC simulations by setting
*every_nsteps* to 1 and not defining an integration fix such as NVE,
NPT etc. In that case, the particles will not move and only the MC
routine will be called to perform atom type swaps.
The parameter *swap_fraction* determines how many MC trial steps are carried
out every time the MC routine is entered. It is measured in units of full MC
cycles where one full cycle, *swap_fraction=1*, corresponds to as many MC
trial steps as there are atoms.
------------
The parameter *temperature* specifies the temperature that is used
to evaluate the Metropolis acceptance criterion. While it usually
should be set to the same value as the MD temperature there are cases
when it can be useful to use two different values for at least part of
the simulation, e.g., to speed up equilibration at low temperatures.
------------
The parameter *deltamu* is used to set the chemical potential difference
in the SGC MC algorithm (see Eq. 16 in :ref:`Sadigh1 <Sadigh1>`). By
convention it is the difference of the chemical potentials of elements
`B`, `C` ..., with respect to element A. When the simulation includes
`N` elements, `N-1` values must be specified.
------------
The variance-constrained SGC MC algorithm is activated if the keyword
*variance* is used. In that case the fix parameter *deltamu* determines
the effective average constraint in the parallel VC-SGC MC algorithm
(parameter :math:`\delta\mu_0` in Eq. (20) of :ref:`Sadigh1
<Sadigh1>`). The parameter *kappa* specifies the variance constraint
(see Eqs. (20-21) in :ref:`Sadigh1 <Sadigh1>`).
The parameter *conc* sets the target concentration (parameter
:math:`c_0` in Eqs. (20-21) of :ref:`Sadigh1 <Sadigh1>`). The atomic
concentrations refer to components `B`, `C` ..., with `A` being set
automatically. When the simulation includes `N` elements, `N-1`
concentration values must be specified.
------------
There are several technical parameters that can be set via optional flags.
*randseed* is expected to be a positive integer number and is used
to initialize the random number generator on each processor.
*window_size* controls the size of the sampling window in a parallel MC
simulation. The size has to lie between 0.5 and 1.0. Normally, this
parameter should be left unspecified which instructs the code to choose
the optimal window size automatically (see Sect. III.B and Figure 6 in
:ref:`Sadigh1 <Sadigh1>` for details).
The number of times the window is moved during a MC cycle is set using
the parameter *window_moves* (see Sect. III.B in :ref:`Sadigh1
<Sadigh1>` for details).
------------
Restart, fix_modify, output, run start/stop, minimize info
==========================================================
No information about this fix is written to restart files.
The MC routine keeps track of the global concentration(s) as well as the
number of accepted and rejected trial swaps during each MC step. These
values are provided by the sgcmc fix in the form of a global vector that
can be accessed by various :doc:`output commands <Howto_output>`
components of the vector represent the following quantities:
* 1 = The absolute number of accepted trial swaps during the last MC step
* 2 = The absolute number of rejected trial swaps during the last MC step
* 3 = The current global concentration of species *A* (= number of atoms of type 1 / total number of atoms)
* 4 = The current global concentration of species *B* (= number of atoms of type 2 / total number of atoms)
* ...
* N+2: The current global concentration of species *X* (= number of atoms of type *N* / total number of atoms)
Restrictions
============
This fix is part of the MC package. It is only enabled if LAMMPS was
built with that package. See the :doc:`Build package <Build_package>`
page for more info.
At present the fix provides optimized subroutines for EAM type
potentials (see above) that calculate potential energy changes due to
*local* atom type swaps very efficiently. Other potentials are
supported by using the generic potential functions. This, however, will
lead to exceedingly slow simulations since it implies that the
energy of the *entire* system is recomputed at each MC trial step. If
other potentials are to be used it is strongly recommended to modify and
optimize the existing generic potential functions for this purpose.
Also, the generic energy calculation can not be used for parallel
execution i.e. it only works with a single MPI process.
------------
Default
=======
The optional parameters default to the following values:
* *randseed* = 324234
* *window_moves* = 8
* *window_size* = automatic
------------
.. _Sadigh1:
**(Sadigh1)** B. Sadigh, P. Erhart, A. Stukowski, A. Caro, E. Martinez, and L. Zepeda-Ruiz, Phys. Rev. B **85**, 184203 (2012)
.. _Sadigh2:
**(Sadigh2)** B. Sadigh and P. Erhart, Phys. Rev. B **86**, 134204 (2012)

View File

@ -174,11 +174,11 @@ shifted force model described in :ref:`Fennell <Fennell1>`, given by:
E = q_iq_j \left[ \frac{\mbox{erfc} (\alpha r)}{r} - \frac{\mbox{erfc} (\alpha r_c)}{r_c} + E = q_iq_j \left[ \frac{\mbox{erfc} (\alpha r)}{r} - \frac{\mbox{erfc} (\alpha r_c)}{r_c} +
\left( \frac{\mbox{erfc} (\alpha r_c)}{r_c^2} + \frac{2\alpha}{\sqrt{\pi}}\frac{\exp (-\alpha^2 r^2_c)}{r_c} \right)(r-r_c) \right] \qquad r < r_c \left( \frac{\mbox{erfc} (\alpha r_c)}{r_c^2} + \frac{2\alpha}{\sqrt{\pi}}\frac{\exp (-\alpha^2 r^2_c)}{r_c} \right)(r-r_c) \right] \qquad r < r_c
where :math:`\alpha` is the damping parameter and erfc() is the where :math:`\alpha` is the damping parameter and *erfc()* is the
complementary error-function. The potential corrects issues in the complementary error-function. The potential corrects issues in the Wolf
Wolf model (described below) to provide consistent forces and energies model (described below) to provide consistent forces and energies (the
(the Wolf potential is not differentiable at the cutoff) and smooth Wolf potential is not differentiable at the cutoff) and smooth decay to
decay to zero. zero.
---------- ----------
@ -192,30 +192,32 @@ summation method, described in :ref:`Wolf <Wolf1>`, given by:
\frac{1}{2} \sum_{j \neq i} \frac{1}{2} \sum_{j \neq i}
\frac{q_i q_j {\rm erf}(\alpha r_{ij})}{r_{ij}} \qquad r < r_c \frac{q_i q_j {\rm erf}(\alpha r_{ij})}{r_{ij}} \qquad r < r_c
where :math:`\alpha` is the damping parameter, and erc() and erfc() are where :math:`\alpha` is the damping parameter, and *erf()* and *erfc()*
error-function and complementary error-function terms. This potential are error-function and complementary error-function terms. This
is essentially a short-range, spherically-truncated, potential is essentially a short-range, spherically-truncated,
charge-neutralized, shifted, pairwise *1/r* summation. With a charge-neutralized, shifted, pairwise *1/r* summation. With a
manipulation of adding and subtracting a self term (for i = j) to the manipulation of adding and subtracting a self term (for i = j) to the
first and second term on the right-hand-side, respectively, and a first and second term on the right-hand-side, respectively, and a small
small enough :math:`\alpha` damping parameter, the second term shrinks and enough :math:`\alpha` damping parameter, the second term shrinks and the
the potential becomes a rapidly-converging real-space summation. With potential becomes a rapidly-converging real-space summation. With a
a long enough cutoff and small enough :math:`\alpha` parameter, the energy and long enough cutoff and small enough :math:`\alpha` parameter, the energy
forces calculated by the Wolf summation method approach those of the and forces calculated by the Wolf summation method approach those of the
Ewald sum. So it is a means of getting effective long-range Ewald sum. So it is a means of getting effective long-range
interactions with a short-range potential. interactions with a short-range potential.
---------- ----------
Style *coul/streitz* is the Coulomb pair interaction defined as part Style *coul/streitz* is the Coulomb pair interaction defined as part of
of the Streitz-Mintmire potential, as described in :ref:`this paper <Streitz2>`, in which charge distribution about an atom is modeled the Streitz-Mintmire potential, as described in :ref:`this paper
as a Slater 1\ *s* orbital. More details can be found in the referenced <Streitz2>`, in which charge distribution about an atom is modeled as a
Slater 1\ *s* orbital. More details can be found in the referenced
paper. To fully reproduce the published Streitz-Mintmire potential, paper. To fully reproduce the published Streitz-Mintmire potential,
which is a variable charge potential, style *coul/streitz* must be which is a variable charge potential, style *coul/streitz* must be used
used with :doc:`pair_style eam/alloy <pair_eam>` (or some other with :doc:`pair_style eam/alloy <pair_eam>` (or some other short-range
short-range potential that has been parameterized appropriately) via potential that has been parameterized appropriately) via the
the :doc:`pair_style hybrid/overlay <pair_hybrid>` command. Likewise, :doc:`pair_style hybrid/overlay <pair_hybrid>` command. Likewise,
charge equilibration must be performed via the :doc:`fix qeq/slater <fix_qeq>` command. For example: charge equilibration must be performed via the :doc:`fix qeq/slater
<fix_qeq>` command. For example:
.. code-block:: LAMMPS .. code-block:: LAMMPS

View File

@ -174,8 +174,8 @@ the specified attribute.
Restrictions Restrictions
"""""""""""" """"""""""""
This fix is part of the MISC package. It is only enabled if LAMMPS This pair style is part of the MISC package. It is only enabled if
was built with that package. See the :doc:`Build package LAMMPS was built with that package. See the :doc:`Build package
<Build_package>` page for more info. <Build_package>` page for more info.
This pair style is currently incompatible with granular pair styles This pair style is currently incompatible with granular pair styles

View File

@ -696,6 +696,7 @@ delocalized
Delong Delong
delr delr
deltaHf deltaHf
deltamu
dem dem
Dendrimer Dendrimer
dendritic dendritic
@ -985,7 +986,6 @@ equilization
equipartitioning equipartitioning
eradius eradius
erate erate
erc
Ercolessi Ercolessi
Erdmann Erdmann
erf erf
@ -2513,6 +2513,7 @@ Nstart
nstats nstats
Nstep Nstep
Nsteps Nsteps
nsteps
nsteplast nsteplast
Nstop Nstop
nsub nsub
@ -3233,6 +3234,7 @@ setvel
sfftw sfftw
sfree sfree
Sg Sg
sgcmc
Shan Shan
Shanno Shanno
Shapeev Shapeev

File diff suppressed because it is too large Load Diff

48
examples/mc/in.sgcmc.eam Normal file
View File

@ -0,0 +1,48 @@
# general variables
variable temperature equal 700
variable size equal 20
# variables for 'fix sgcmc'
variable nsteps_mc equal 100
variable swap_fraction equal 0.2
variable temperature_mc equal ${temperature}
variable deltamu equal -0.70
variable target_concentration equal 0.02
variable kappa equal 1e3
# general settings
units metal
atom_style atomic
# set up structure
boundary p p p
lattice bcc 2.88
region box block 0 ${size} 0 ${size} 0 ${size}
create_box 2 box
create_atoms 1 box
reset_timestep 0
timestep 0.0025
# set up interaction
pair_style eam/fs
pair_coeff * * FeCu.pasianot.eamfs Fe Cu
# initialize velocities
variable double_temp equal ${temperature}*2
velocity all create ${double_temp} 428459 dist gaussian
# what and how to run
fix integrate all npt &
temp ${temperature} ${temperature} 1.7 &
aniso 0.0 0.0 1.5
fix mc all sgcmc ${nsteps_mc} ${swap_fraction} ${temperature_mc} ${deltamu} &
randseed 324234 &
variance ${kappa} ${target_concentration}
# set up output
thermo 100
thermo_style custom step temp atoms pe press &
lx ly lz f_mc[1] f_mc[2] f_mc[3] f_mc[4]
#dump 1 all custom 200 mc.*.dump id type x y z
run 2000

View File

@ -0,0 +1,143 @@
LAMMPS (3 Nov 2022)
using 1 OpenMP thread(s) per MPI task
# general variables
variable temperature equal 700
variable size equal 20
# variables for 'fix sgcmc'
variable nsteps_mc equal 100
variable swap_fraction equal 0.2
variable temperature_mc equal ${temperature}
variable temperature_mc equal 700
variable deltamu equal -0.70
variable target_concentration equal 0.02
variable kappa equal 1e3
# general settings
units metal
atom_style atomic
# set up structure
boundary p p p
lattice bcc 2.88
Lattice spacing in x,y,z = 2.88 2.88 2.88
region box block 0 ${size} 0 ${size} 0 ${size}
region box block 0 20 0 ${size} 0 ${size}
region box block 0 20 0 20 0 ${size}
region box block 0 20 0 20 0 20
create_box 2 box
Created orthogonal box = (0 0 0) to (57.6 57.6 57.6)
1 by 1 by 1 MPI processor grid
create_atoms 1 box
Created 16000 atoms
using lattice units in orthogonal box = (0 0 0) to (57.6 57.6 57.6)
create_atoms CPU = 0.001 seconds
reset_timestep 0
timestep 0.0025
# set up interaction
pair_style eam/fs
pair_coeff * * FeCu.pasianot.eamfs Fe Cu
# initialize velocities
variable double_temp equal ${temperature}*2
variable double_temp equal 700*2
velocity all create ${double_temp} 428459 dist gaussian
velocity all create 1400 428459 dist gaussian
# what and how to run
fix integrate all npt temp ${temperature} ${temperature} 1.7 aniso 0.0 0.0 1.5
fix integrate all npt temp 700 ${temperature} 1.7 aniso 0.0 0.0 1.5
fix integrate all npt temp 700 700 1.7 aniso 0.0 0.0 1.5
fix mc all sgcmc ${nsteps_mc} ${swap_fraction} ${temperature_mc} ${deltamu} randseed 324234 variance ${kappa} ${target_concentration}
fix mc all sgcmc 100 ${swap_fraction} ${temperature_mc} ${deltamu} randseed 324234 variance ${kappa} ${target_concentration}
fix mc all sgcmc 100 0.2 ${temperature_mc} ${deltamu} randseed 324234 variance ${kappa} ${target_concentration}
fix mc all sgcmc 100 0.2 700 ${deltamu} randseed 324234 variance ${kappa} ${target_concentration}
fix mc all sgcmc 100 0.2 700 -0.7 randseed 324234 variance ${kappa} ${target_concentration}
fix mc all sgcmc 100 0.2 700 -0.7 randseed 324234 variance 1000 ${target_concentration}
fix mc all sgcmc 100 0.2 700 -0.7 randseed 324234 variance 1000 0.02
SGC - Number of MD timesteps: 100
SGC - Fraction of swap atoms: 0.2
SGC - Temperature: %f
SGC - Chemical potential of species 2: -0.7
SGC - Random number seed: 324234
SGC - Kappa: 1000
SGC - Target concentration of species 2: 0.02
SGC - Target concentration of species 1: 0.98
# set up output
thermo 100
thermo_style custom step temp atoms pe press lx ly lz f_mc[1] f_mc[2] f_mc[3] f_mc[4]
#dump 1 all custom 200 mc.*.dump id type x y z
run 2000
SGC - Interaction radius: 5.50679
Neighbor list info ...
update: every = 1 steps, delay = 0 steps, check = yes
max neighbors/atom: 2000, page size: 100000
master list distance cutoff = 7.50679
ghost atom cutoff = 7.50679
binsize = 3.753395, bins = 16 16 16
2 neighbor lists, perpetual/occasional/extra = 2 0 0
(1) pair eam/fs, perpetual, half/full from (2)
attributes: half, newton on
pair build: halffull/newton
stencil: none
bin: none
(2) fix sgcmc, perpetual
attributes: full, newton on
pair build: full/bin/atomonly
stencil: full/bin/3d
bin: standard
Per MPI rank memory allocation (min/avg/max) = 25.06 | 25.06 | 25.06 Mbytes
Step Temp Atoms PotEng Press Lx Ly Lz f_mc[1] f_mc[2] f_mc[3] f_mc[4]
0 1400 16000 -65889.786 -28854.541 57.6 57.6 57.6 0 0 1 0
100 734.32713 16000 -64514.143 5439.4277 57.327173 57.322333 57.318848 12 3188 0.99925 0.00075
200 678.63428 16000 -64386.224 -920.7819 57.423954 57.409111 57.412727 22 3178 0.997875 0.002125
300 683.24749 16000 -64370.598 -1609.0429 57.427441 57.424568 57.426831 20 3180 0.996625 0.003375
400 689.28007 16000 -64359.115 2489.3933 57.376537 57.379856 57.372895 27 3173 0.9949375 0.0050625
500 693.85333 16000 -64337.222 -1935.9815 57.435754 57.43493 57.427453 18 3182 0.9938125 0.0061875
600 693.52855 16000 -64314.465 380.8264 57.410314 57.397604 57.408337 21 3179 0.9925 0.0075
700 690.62721 16000 -64284.369 208.21986 57.412407 57.407285 57.410684 31 3169 0.9905625 0.0094375
800 687.08129 16000 -64244.443 -936.31731 57.425765 57.438983 57.421321 31 3169 0.988625 0.011375
900 696.07347 16000 -64230.523 932.65537 57.414588 57.413865 57.402817 27 3173 0.9869375 0.0130625
1000 691.70667 16000 -64194.151 -690.02055 57.429033 57.420053 57.443245 23 3177 0.9855 0.0145
1100 691.21797 16000 -64169.016 -86.623524 57.42147 57.424262 57.436841 35 3165 0.9833125 0.0166875
1200 691.27155 16000 -64134.443 411.68129 57.425111 57.432481 57.4118 42 3158 0.9806875 0.0193125
1300 693.76194 16000 -64098.615 -943.9013 57.446704 57.448382 57.440727 64 3136 0.9800625 0.0199375
1400 691.16411 16000 -64080.423 1248.7921 57.417118 57.409651 57.435099 104 3096 0.9799375 0.0200625
1500 694.49681 16000 -64084.428 -179.5269 57.440533 57.432581 57.434409 68 3132 0.9799375 0.0200625
1600 697.58329 16000 -64089.682 -761.14401 57.450616 57.450654 57.422293 97 3103 0.98 0.02
1700 697.57549 16000 -64090.2 1370.3938 57.399319 57.423969 57.426788 85 3115 0.9801875 0.0198125
1800 694.18435 16000 -64083.812 -1381.5398 57.446114 57.438096 57.475109 84 3116 0.9799375 0.0200625
1900 702.82577 16000 -64096.005 918.83968 57.452789 57.404638 57.408161 70 3130 0.9799375 0.0200625
2000 696.02963 16000 -64080.059 276.99031 57.443085 57.452012 57.403928 81 3119 0.980125 0.019875
Loop time of 48.793 on 1 procs for 2000 steps with 16000 atoms
Performance: 8.854 ns/day, 2.711 hours/ns, 40.989 timesteps/s, 655.831 katom-step/s
99.8% CPU use with 1 MPI tasks x 1 OpenMP threads
MPI task timing breakdown:
Section | min time | avg time | max time |%varavg| %total
---------------------------------------------------------------
Pair | 47.46 | 47.46 | 47.46 | 0.0 | 97.27
Neigh | 0 | 0 | 0 | 0.0 | 0.00
Comm | 0.13269 | 0.13269 | 0.13269 | 0.0 | 0.27
Output | 0.0011432 | 0.0011432 | 0.0011432 | 0.0 | 0.00
Modify | 1.0996 | 1.0996 | 1.0996 | 0.0 | 2.25
Other | | 0.0993 | | | 0.20
Nlocal: 16000 ave 16000 max 16000 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost: 17201 ave 17201 max 17201 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs: 1.344e+06 ave 1.344e+06 max 1.344e+06 min
Histogram: 1 0 0 0 0 0 0 0 0 0
FullNghs: 2.688e+06 ave 2.688e+06 max 2.688e+06 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Total # of neighbors = 2688000
Ave neighs/atom = 168
Neighbor list builds = 0
Dangerous builds = 0
Total wall time: 0:00:48

View File

@ -0,0 +1,143 @@
LAMMPS (3 Nov 2022)
using 1 OpenMP thread(s) per MPI task
# general variables
variable temperature equal 700
variable size equal 20
# variables for 'fix sgcmc'
variable nsteps_mc equal 100
variable swap_fraction equal 0.2
variable temperature_mc equal ${temperature}
variable temperature_mc equal 700
variable deltamu equal -0.70
variable target_concentration equal 0.02
variable kappa equal 1e3
# general settings
units metal
atom_style atomic
# set up structure
boundary p p p
lattice bcc 2.88
Lattice spacing in x,y,z = 2.88 2.88 2.88
region box block 0 ${size} 0 ${size} 0 ${size}
region box block 0 20 0 ${size} 0 ${size}
region box block 0 20 0 20 0 ${size}
region box block 0 20 0 20 0 20
create_box 2 box
Created orthogonal box = (0 0 0) to (57.6 57.6 57.6)
1 by 2 by 2 MPI processor grid
create_atoms 1 box
Created 16000 atoms
using lattice units in orthogonal box = (0 0 0) to (57.6 57.6 57.6)
create_atoms CPU = 0.001 seconds
reset_timestep 0
timestep 0.0025
# set up interaction
pair_style eam/fs
pair_coeff * * FeCu.pasianot.eamfs Fe Cu
# initialize velocities
variable double_temp equal ${temperature}*2
variable double_temp equal 700*2
velocity all create ${double_temp} 428459 dist gaussian
velocity all create 1400 428459 dist gaussian
# what and how to run
fix integrate all npt temp ${temperature} ${temperature} 1.7 aniso 0.0 0.0 1.5
fix integrate all npt temp 700 ${temperature} 1.7 aniso 0.0 0.0 1.5
fix integrate all npt temp 700 700 1.7 aniso 0.0 0.0 1.5
fix mc all sgcmc ${nsteps_mc} ${swap_fraction} ${temperature_mc} ${deltamu} randseed 324234 variance ${kappa} ${target_concentration}
fix mc all sgcmc 100 ${swap_fraction} ${temperature_mc} ${deltamu} randseed 324234 variance ${kappa} ${target_concentration}
fix mc all sgcmc 100 0.2 ${temperature_mc} ${deltamu} randseed 324234 variance ${kappa} ${target_concentration}
fix mc all sgcmc 100 0.2 700 ${deltamu} randseed 324234 variance ${kappa} ${target_concentration}
fix mc all sgcmc 100 0.2 700 -0.7 randseed 324234 variance ${kappa} ${target_concentration}
fix mc all sgcmc 100 0.2 700 -0.7 randseed 324234 variance 1000 ${target_concentration}
fix mc all sgcmc 100 0.2 700 -0.7 randseed 324234 variance 1000 0.02
SGC - Number of MD timesteps: 100
SGC - Fraction of swap atoms: 0.2
SGC - Temperature: %f
SGC - Chemical potential of species 2: -0.7
SGC - Random number seed: 324234
SGC - Kappa: 1000
SGC - Target concentration of species 2: 0.02
SGC - Target concentration of species 1: 0.98
# set up output
thermo 100
thermo_style custom step temp atoms pe press lx ly lz f_mc[1] f_mc[2] f_mc[3] f_mc[4]
#dump 1 all custom 200 mc.*.dump id type x y z
run 2000
SGC - Interaction radius: 5.50679
Neighbor list info ...
update: every = 1 steps, delay = 0 steps, check = yes
max neighbors/atom: 2000, page size: 100000
master list distance cutoff = 7.50679
ghost atom cutoff = 7.50679
binsize = 3.753395, bins = 16 16 16
2 neighbor lists, perpetual/occasional/extra = 2 0 0
(1) pair eam/fs, perpetual, half/full from (2)
attributes: half, newton on
pair build: halffull/newton
stencil: none
bin: none
(2) fix sgcmc, perpetual
attributes: full, newton on
pair build: full/bin/atomonly
stencil: full/bin/3d
bin: standard
Per MPI rank memory allocation (min/avg/max) = 7.809 | 7.809 | 7.809 Mbytes
Step Temp Atoms PotEng Press Lx Ly Lz f_mc[1] f_mc[2] f_mc[3] f_mc[4]
0 1400 16000 -65889.786 -28854.541 57.6 57.6 57.6 0 0 1 0
100 741.39222 16000 -64528.923 5317.2919 57.324639 57.32318 57.314928 19 3181 0.9988125 0.0011875
200 691.21024 16000 -64405.429 -1238.5107 57.421346 57.415516 57.412006 16 3184 0.9978125 0.0021875
300 686.85178 16000 -64377.312 -1816.799 57.424469 57.424335 57.425065 25 3175 0.996375 0.003625
400 690.93203 16000 -64358.609 2211.7763 57.376246 57.38185 57.381742 16 3184 0.995375 0.004625
500 696.77972 16000 -64350.3 -1583.8383 57.432929 57.426928 57.425935 22 3178 0.994125 0.005875
600 694.13567 16000 -64320.831 144.2514 57.420097 57.403531 57.401394 19 3181 0.9930625 0.0069375
700 691.79625 16000 -64295.155 384.47869 57.410637 57.412957 57.40707 25 3175 0.991625 0.008375
800 692.12887 16000 -64270.053 -764.91901 57.415576 57.43037 57.428708 21 3179 0.9903125 0.0096875
900 693.26555 16000 -64249.904 666.65335 57.408245 57.407059 57.417437 34 3166 0.9885625 0.0114375
1000 697.97016 16000 -64230.234 -562.91022 57.432317 57.424316 57.423668 28 3172 0.9868125 0.0131875
1100 686.52149 16000 -64177.536 -267.21801 57.429 57.434594 57.419878 35 3165 0.984875 0.015125
1200 691.55047 16000 -64156.268 810.17844 57.422282 57.413529 57.422883 37 3163 0.9828125 0.0171875
1300 691.91944 16000 -64124.602 -1012.7184 57.441793 57.433848 57.446947 32 3168 0.9810625 0.0189375
1400 701.78807 16000 -64116.475 180.93518 57.425156 57.438679 57.419575 76 3124 0.9799375 0.0200625
1500 692.75501 16000 -64080.481 176.96902 57.429275 57.442405 57.426519 81 3119 0.980125 0.019875
1600 694.11818 16000 -64083.435 -785.49617 57.442143 57.432114 57.458304 86 3114 0.98 0.02
1700 697.72576 16000 -64088.874 1227.5194 57.423225 57.408678 57.427056 75 3125 0.9800625 0.0199375
1800 697.24171 16000 -64086.742 -1166.4832 57.447168 57.47416 57.425229 67 3133 0.98025 0.01975
1900 699.53558 16000 -64092.97 214.99908 57.425459 57.437864 57.431139 86 3114 0.98025 0.01975
2000 699.00277 16000 -64089.117 978.69672 57.429266 57.39107 57.448289 81 3119 0.9798125 0.0201875
Loop time of 15.2907 on 4 procs for 2000 steps with 16000 atoms
Performance: 28.252 ns/day, 0.849 hours/ns, 130.798 timesteps/s, 2.093 Matom-step/s
99.0% CPU use with 4 MPI tasks x 1 OpenMP threads
MPI task timing breakdown:
Section | min time | avg time | max time |%varavg| %total
---------------------------------------------------------------
Pair | 14.31 | 14.404 | 14.479 | 1.6 | 94.20
Neigh | 0.090756 | 0.091006 | 0.091258 | 0.1 | 0.60
Comm | 0.27623 | 0.35113 | 0.44457 | 10.4 | 2.30
Output | 0.0006002 | 0.0013338 | 0.0035331 | 3.5 | 0.01
Modify | 0.38023 | 0.38128 | 0.38228 | 0.2 | 2.49
Other | | 0.06148 | | | 0.40
Nlocal: 4000 ave 4017 max 3970 min
Histogram: 1 0 0 0 0 0 1 0 1 1
Nghost: 8274.75 ave 8305 max 8257 min
Histogram: 1 1 0 1 0 0 0 0 0 1
Neighs: 311257 ave 313506 max 308273 min
Histogram: 1 0 0 0 0 1 0 1 0 1
FullNghs: 622514 ave 626251 max 616896 min
Histogram: 1 0 0 0 0 0 1 1 0 1
Total # of neighbors = 2490056
Ave neighs/atom = 155.6285
Neighbor list builds = 6
Dangerous builds = 0
Total wall time: 0:00:15

2
src/.gitignore vendored
View File

@ -920,6 +920,8 @@
/fix_rigid_nvt_small.h /fix_rigid_nvt_small.h
/fix_rigid_small.cpp /fix_rigid_small.cpp
/fix_rigid_small.h /fix_rigid_small.h
/fix_sgcmc.cpp
/fix_sgcmc.h
/fix_shake.cpp /fix_shake.cpp
/fix_shake.h /fix_shake.h
/fix_shardlow.cpp /fix_shardlow.cpp

View File

@ -15,7 +15,6 @@
#include "pair_amoeba.h" #include "pair_amoeba.h"
#include "atom.h" #include "atom.h"
#include "memory.h"
#include "neigh_list.h" #include "neigh_list.h"
#include <cmath> #include <cmath>

View File

@ -22,7 +22,9 @@
#include "memory.h" #include "memory.h"
#include "neighbor.h" #include "neighbor.h"
#include "remap_wrap.h" #include "remap_wrap.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;

View File

@ -18,10 +18,8 @@
#include "atom.h" #include "atom.h"
#include "comm.h" #include "comm.h"
#include "domain.h" #include "domain.h"
#include "fft3d_wrap.h"
#include "math_const.h" #include "math_const.h"
#include "math_special.h" #include "math_special.h"
#include "memory.h"
#include "neigh_list.h" #include "neigh_list.h"
#include <cmath> #include <cmath>

View File

@ -17,14 +17,11 @@
#include "comm.h" #include "comm.h"
#include "domain.h" #include "domain.h"
#include "error.h" #include "error.h"
#include "force.h"
#include "memory.h" #include "memory.h"
#include "utils.h"
#include "tokenizer.h" #include "tokenizer.h"
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
#include <cctype>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;

View File

@ -19,16 +19,13 @@
#include "comm.h" #include "comm.h"
#include "domain.h" #include "domain.h"
#include "error.h" #include "error.h"
#include "fft3d_wrap.h"
#include "fix_store_peratom.h" #include "fix_store_peratom.h"
#include "math_const.h" #include "math_const.h"
#include "math_special.h" #include "math_special.h"
#include "memory.h"
#include "my_page.h" #include "my_page.h"
#include "neigh_list.h" #include "neigh_list.h"
#include <cmath> #include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;

View File

@ -18,14 +18,11 @@
#include "atom.h" #include "atom.h"
#include "comm.h" #include "comm.h"
#include "domain.h" #include "domain.h"
#include "fft3d_wrap.h"
#include "math_const.h" #include "math_const.h"
#include "math_special.h" #include "math_special.h"
#include "memory.h"
#include "neigh_list.h" #include "neigh_list.h"
#include <cmath> #include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;

View File

@ -18,10 +18,8 @@
#include "atom.h" #include "atom.h"
#include "comm.h" #include "comm.h"
#include "domain.h" #include "domain.h"
#include "fft3d_wrap.h"
#include "math_const.h" #include "math_const.h"
#include "math_special.h" #include "math_special.h"
#include "memory.h"
#include "neigh_list.h" #include "neigh_list.h"
#include <cmath> #include <cmath>

View File

@ -16,7 +16,6 @@
#include "atom.h" #include "atom.h"
#include "comm.h" #include "comm.h"
#include "memory.h"
#include "neigh_list.h" #include "neigh_list.h"
#include <cmath> #include <cmath>

View File

@ -15,7 +15,6 @@
#include "pair_amoeba.h" #include "pair_amoeba.h"
#include "atom.h" #include "atom.h"
#include "comm.h"
#include "domain.h" #include "domain.h"
#include "error.h" #include "error.h"
#include "fix_store_peratom.h" #include "fix_store_peratom.h"

View File

@ -24,7 +24,7 @@ AtomStyle(amoeba,AtomVecAmoeba);
namespace LAMMPS_NS { namespace LAMMPS_NS {
class AtomVecAmoeba : public AtomVec { class AtomVecAmoeba : virtual public AtomVec {
public: public:
AtomVecAmoeba(class LAMMPS *); AtomVecAmoeba(class LAMMPS *);
~AtomVecAmoeba() override; ~AtomVecAmoeba() override;

View File

@ -119,7 +119,7 @@ class FixAmoebaBiTorsion : public Fix {
void chkttor(int, int, int, double &, double &, double &); void chkttor(int, int, int, double &, double &, double &);
void bcuint1(double *, double *, double *, double *, double, double, double, double, double, void bcuint1(double *, double *, double *, double *, double, double, double, double, double,
double, double &, double &, double &); double, double &, double &, double &);
void bcucof(double *, double *, double *, double *, double, double, double[][4]); void bcucof(double *, double *, double *, double *, double, double, double[4][4]);
}; };
} // namespace LAMMPS_NS } // namespace LAMMPS_NS
#endif #endif

View File

@ -22,7 +22,6 @@
#include "memory.h" #include "memory.h"
#include "neighbor.h" #include "neighbor.h"
#include "pair.h" #include "pair.h"
#include "update.h"
#include <cmath> #include <cmath>

View File

@ -19,7 +19,6 @@
#include "comm.h" #include "comm.h"
#include "domain.h" #include "domain.h"
#include "error.h" #include "error.h"
#include "fft3d_wrap.h"
#include "fix.h" #include "fix.h"
#include "fix_store_peratom.h" #include "fix_store_peratom.h"
#include "force.h" #include "force.h"
@ -29,14 +28,11 @@
#include "modify.h" #include "modify.h"
#include "my_page.h" #include "my_page.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neigh_request.h"
#include "neighbor.h" #include "neighbor.h"
#include "update.h" #include "update.h"
#include "utils.h"
#include <cstdlib> #include <cmath>
#include <cstring> #include <cstring>
#include <cctype>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;

View File

@ -256,7 +256,7 @@ void PairYLZ::coeff(int narg, char **arg)
void PairYLZ::init_style() void PairYLZ::init_style()
{ {
avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); avec = dynamic_cast<AtomVecEllipsoid *>(atom->style_match("ellipsoid"));
if (!avec) error->all(FLERR, "Pair style ylz requires atom style ellipsoid"); if (!avec) error->all(FLERR, "Pair style ylz requires atom style ellipsoid");
neighbor->request(this, instance_me); neighbor->request(this, instance_me);

View File

@ -24,7 +24,7 @@ AtomStyle(wavepacket,AtomVecWavepacket);
namespace LAMMPS_NS { namespace LAMMPS_NS {
class AtomVecWavepacket : public AtomVec { class AtomVecWavepacket : virtual public AtomVec {
public: public:
AtomVecWavepacket(class LAMMPS *); AtomVecWavepacket(class LAMMPS *);

View File

@ -20,7 +20,6 @@
#include "fix_adapt.h" #include "fix_adapt.h"
#include "math_const.h" #include "math_const.h"
#include "modify.h" #include "modify.h"
#include "utils.h"
#include <cstring> #include <cstring>

View File

@ -24,7 +24,7 @@ AtomStyle(bpm/sphere,AtomVecBPMSphere);
namespace LAMMPS_NS { namespace LAMMPS_NS {
class AtomVecBPMSphere : public AtomVec { class AtomVecBPMSphere : virtual public AtomVec {
public: public:
AtomVecBPMSphere(class LAMMPS *); AtomVecBPMSphere(class LAMMPS *);
void process_args(int, char **) override; void process_args(int, char **) override;

View File

@ -25,7 +25,8 @@
#include "modify.h" #include "modify.h"
#include "update.h" #include "update.h"
#include <vector> #include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;

View File

@ -16,8 +16,6 @@
#include "bond.h" #include "bond.h"
#include <vector>
namespace LAMMPS_NS { namespace LAMMPS_NS {
class BondBPM : public Bond { class BondBPM : public Bond {

View File

@ -19,13 +19,13 @@
#include "error.h" #include "error.h"
#include "fix_bond_history.h" #include "fix_bond_history.h"
#include "force.h" #include "force.h"
#include "math_const.h"
#include "math_extra.h" #include "math_extra.h"
#include "memory.h" #include "memory.h"
#include "modify.h" #include "modify.h"
#include "neighbor.h" #include "neighbor.h"
#include <cmath> #include <cmath>
#include <cstring>
#define EPSILON 1e-10 #define EPSILON 1e-10

View File

@ -23,6 +23,9 @@
#include "modify.h" #include "modify.h"
#include "neighbor.h" #include "neighbor.h"
#include <cmath>
#include <cstring>
#define EPSILON 1e-10 #define EPSILON 1e-10
using namespace LAMMPS_NS; using namespace LAMMPS_NS;

View File

@ -15,12 +15,8 @@
#include "atom.h" #include "atom.h"
#include "comm.h" #include "comm.h"
#include "error.h"
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
#include "update.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -29,7 +25,7 @@ using namespace LAMMPS_NS;
ComputeNBondAtom::ComputeNBondAtom(LAMMPS *_lmp, int narg, char **arg) : ComputeNBondAtom::ComputeNBondAtom(LAMMPS *_lmp, int narg, char **arg) :
Compute(_lmp, narg, arg), nbond(nullptr) Compute(_lmp, narg, arg), nbond(nullptr)
{ {
if (narg < 3) error->all(FLERR, "Illegal compute nbond/atom command"); if (narg < 3) utils::missing_cmd_args(FLERR, "compute nbond/atom", error);
peratom_flag = 1; peratom_flag = 1;
size_peratom_cols = 0; size_peratom_cols = 0;

View File

@ -14,13 +14,10 @@
#include "fix_nve_bpm_sphere.h" #include "fix_nve_bpm_sphere.h"
#include "atom.h" #include "atom.h"
#include "atom_vec.h"
#include "domain.h" #include "domain.h"
#include "error.h" #include "error.h"
#include "force.h"
#include "math_extra.h" #include "math_extra.h"
#include <cmath>
#include <cstring> #include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;

View File

@ -19,7 +19,8 @@
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neighbor.h"
#include <cmath>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;

View File

@ -27,6 +27,8 @@
#include "math_extra.h" #include "math_extra.h"
#include "random_mars.h" #include "random_mars.h"
#include <cmath>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;

View File

@ -24,7 +24,7 @@ AtomStyle(oxdna,AtomVecOxdna);
namespace LAMMPS_NS { namespace LAMMPS_NS {
class AtomVecOxdna : public AtomVec { class AtomVecOxdna : virtual public AtomVec {
public: public:
AtomVecOxdna(class LAMMPS *); AtomVecOxdna(class LAMMPS *);

View File

@ -92,7 +92,6 @@ void PairBrownian::compute(int eflag, int vflag)
double prethermostat; double prethermostat;
double xl[3], a_sq, a_sh, a_pu, Fbmag; double xl[3], a_sq, a_sh, a_pu, Fbmag;
double p1[3], p2[3], p3[3]; double p1[3], p2[3], p3[3];
int overlaps = 0;
// This section of code adjusts R0/RT0/RS0 if necessary due to changes // This section of code adjusts R0/RT0/RS0 if necessary due to changes
// in the volume fraction as a result of fix deform or moving walls // in the volume fraction as a result of fix deform or moving walls
@ -187,10 +186,6 @@ void PairBrownian::compute(int eflag, int vflag)
h_sep = r - 2.0 * radi; h_sep = r - 2.0 * radi;
// check for overlaps
if (h_sep < 0.0) overlaps++;
// if less than minimum gap, use minimum gap instead // if less than minimum gap, use minimum gap instead
if (r < cut_inner[itype][jtype]) h_sep = cut_inner[itype][jtype] - 2.0 * radi; if (r < cut_inner[itype][jtype]) h_sep = cut_inner[itype][jtype] - 2.0 * radi;
@ -336,9 +331,6 @@ void PairBrownian::compute(int eflag, int vflag)
} }
} }
int print_overlaps = 0;
if (print_overlaps && overlaps) printf("Number of overlaps=%d\n", overlaps);
if (vflag_fdotr) virial_fdotr_compute(); if (vflag_fdotr) virial_fdotr_compute();
} }

View File

@ -72,7 +72,6 @@ void PairBrownianPoly::compute(int eflag, int vflag)
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
double vxmu2f = force->vxmu2f; double vxmu2f = force->vxmu2f;
int overlaps = 0;
double randr; double randr;
double prethermostat; double prethermostat;
double xl[3],a_sq,a_sh,a_pu,Fbmag; double xl[3],a_sq,a_sh,a_pu,Fbmag;
@ -176,10 +175,6 @@ void PairBrownianPoly::compute(int eflag, int vflag)
h_sep = r - radi-radj; h_sep = r - radi-radj;
// check for overlaps
if (h_sep < 0.0) overlaps++;
// if less than minimum gap, use minimum gap instead // if less than minimum gap, use minimum gap instead
if (r < cut_inner[itype][jtype]) if (r < cut_inner[itype][jtype])

View File

@ -31,9 +31,6 @@
#include "modify.h" #include "modify.h"
#include "update.h" #include "update.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -24,7 +24,7 @@ AtomStyle(dielectric,AtomVecDielectric);
namespace LAMMPS_NS { namespace LAMMPS_NS {
class AtomVecDielectric : public AtomVec { class AtomVecDielectric : virtual public AtomVec {
friend class PairLJCutCoulDebyeDielectric; friend class PairLJCutCoulDebyeDielectric;
friend class PairLJLongCoulLongDielectric; friend class PairLJLongCoulLongDielectric;

View File

@ -20,7 +20,6 @@
#include "atom.h" #include "atom.h"
#include "atom_vec_dielectric.h" #include "atom_vec_dielectric.h"
#include "comm.h"
#include "domain.h" #include "domain.h"
#include "error.h" #include "error.h"
#include "grid3d.h" #include "grid3d.h"

View File

@ -20,10 +20,8 @@
#include "atom.h" #include "atom.h"
#include "atom_vec_dielectric.h" #include "atom_vec_dielectric.h"
#include "comm.h"
#include "domain.h" #include "domain.h"
#include "error.h" #include "error.h"
#include "force.h"
#include "grid3d.h" #include "grid3d.h"
#include "math_const.h" #include "math_const.h"
#include "math_special.h" #include "math_special.h"

View File

@ -18,7 +18,6 @@
#include "pppm_disp_dielectric.h" #include "pppm_disp_dielectric.h"
#include "angle.h"
#include "atom.h" #include "atom.h"
#include "atom_vec_dielectric.h" #include "atom_vec_dielectric.h"
#include "domain.h" #include "domain.h"

View File

@ -407,7 +407,6 @@ void FixSAEDVTK::invoke_vector(bigint ntimestep)
// Finding the intersection of the reciprical space and Ewald sphere // Finding the intersection of the reciprical space and Ewald sphere
int NROW1 = 0; int NROW1 = 0;
int NROW2 = 0;
double dinv2 = 0.0; double dinv2 = 0.0;
double r = 0.0; double r = 0.0;
double K[3]; double K[3];
@ -425,11 +424,9 @@ void FixSAEDVTK::invoke_vector(bigint ntimestep)
fprintf(fp,"%g\n",vector_total[NROW1]/norm); fprintf(fp,"%g\n",vector_total[NROW1]/norm);
fflush(fp); fflush(fp);
NROW1++; NROW1++;
NROW2++;
} else { } else {
fprintf(fp,"%d\n",-1); fprintf(fp,"%d\n",-1);
fflush(fp); fflush(fp);
NROW2++;
} }
} }
} }
@ -449,17 +446,14 @@ void FixSAEDVTK::invoke_vector(bigint ntimestep)
if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) )) { if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) )) {
fprintf(fp,"%g\n",vector_total[NROW1]/norm); fprintf(fp,"%g\n",vector_total[NROW1]/norm);
fflush(fp); fflush(fp);
NROW2++;
NROW1++; NROW1++;
} else { } else {
fprintf(fp,"%d\n",-1); fprintf(fp,"%d\n",-1);
fflush(fp); fflush(fp);
NROW2++;
} }
} else { } else {
fprintf(fp,"%d\n",-1); fprintf(fp,"%d\n",-1);
fflush(fp); fflush(fp);
NROW2++;
} }
} }
} }

View File

@ -24,7 +24,7 @@ AtomStyle(dipole,AtomVecDipole);
namespace LAMMPS_NS { namespace LAMMPS_NS {
class AtomVecDipole : public AtomVec { class AtomVecDipole : virtual public AtomVec {
public: public:
AtomVecDipole(class LAMMPS *); AtomVecDipole(class LAMMPS *);

View File

@ -24,7 +24,7 @@ AtomStyle(edpd,AtomVecEDPD);
namespace LAMMPS_NS { namespace LAMMPS_NS {
class AtomVecEDPD : public AtomVec { class AtomVecEDPD : virtual public AtomVec {
public: public:
AtomVecEDPD(class LAMMPS *); AtomVecEDPD(class LAMMPS *);
void init() override; void init() override;

View File

@ -24,7 +24,7 @@ AtomStyle(mdpd,AtomVecMDPD);
namespace LAMMPS_NS { namespace LAMMPS_NS {
class AtomVecMDPD : public AtomVec { class AtomVecMDPD : virtual public AtomVec {
public: public:
AtomVecMDPD(class LAMMPS *); AtomVecMDPD(class LAMMPS *);
void init() override; void init() override;

View File

@ -24,7 +24,7 @@ AtomStyle(tdpd,AtomVecTDPD);
namespace LAMMPS_NS { namespace LAMMPS_NS {
class AtomVecTDPD : public AtomVec { class AtomVecTDPD : virtual public AtomVec {
public: public:
AtomVecTDPD(class LAMMPS *); AtomVecTDPD(class LAMMPS *);
void process_args(int, char **) override; void process_args(int, char **) override;

View File

@ -24,7 +24,7 @@ AtomStyle(dpd,AtomVecDPD);
namespace LAMMPS_NS { namespace LAMMPS_NS {
class AtomVecDPD : public AtomVec { class AtomVecDPD : virtual public AtomVec {
public: public:
AtomVecDPD(class LAMMPS *); AtomVecDPD(class LAMMPS *);
@ -32,7 +32,7 @@ class AtomVecDPD : public AtomVec {
void unpack_restart_init(int) override; void unpack_restart_init(int) override;
void data_atom_post(int) override; void data_atom_post(int) override;
private: protected:
double *rho, *dpdTheta; double *rho, *dpdTheta;
double *uCond, *uMech, *uChem; double *uCond, *uMech, *uChem;
double *uCG, *uCGnew; double *uCG, *uCGnew;

View File

@ -390,7 +390,6 @@ void FixRX::initSparse()
int mxprod = 0; int mxprod = 0;
int mxreac = 0; int mxreac = 0;
int mxspec = 0; int mxspec = 0;
int nIntegral = 0;
for (int i = 0; i < nreactions; ++i) { for (int i = 0; i < nreactions; ++i) {
int nreac_i = 0, nprod_i = 0; int nreac_i = 0, nprod_i = 0;
std::string pstr, rstr; std::string pstr, rstr;
@ -430,7 +429,6 @@ void FixRX::initSparse()
mxreac = std::max( mxreac, nreac_i ); mxreac = std::max( mxreac, nreac_i );
mxprod = std::max( mxprod, nprod_i ); mxprod = std::max( mxprod, nprod_i );
mxspec = std::max( mxspec, nreac_i + nprod_i ); mxspec = std::max( mxspec, nreac_i + nprod_i );
if (allAreIntegral) nIntegral++;
} }
if (comm->me == 0 && Verbosity > 1) { if (comm->me == 0 && Verbosity > 1) {

View File

@ -20,6 +20,8 @@
#include "atom.h" #include "atom.h"
#include "citeme.h" #include "citeme.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
static const char cite_user_eff_package[] = static const char cite_user_eff_package[] =

View File

@ -24,7 +24,7 @@ AtomStyle(electron,AtomVecElectron);
namespace LAMMPS_NS { namespace LAMMPS_NS {
class AtomVecElectron : public AtomVec { class AtomVecElectron : virtual public AtomVec {
public: public:
AtomVecElectron(class LAMMPS *); AtomVecElectron(class LAMMPS *);

View File

@ -141,12 +141,6 @@ double ComputeTempRegionEff::compute_scalar()
if (dof < 0.0 && tarray_all[0] > 0.0) if (dof < 0.0 && tarray_all[0] > 0.0)
error->all(FLERR, "Temperature compute degrees of freedom < 0"); error->all(FLERR, "Temperature compute degrees of freedom < 0");
int one = 0;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2])) {
if (abs(spin[i]) == 1) one++;
}
if (dof > 0.0) if (dof > 0.0)
scalar = force->mvv2e * tarray_all[1] / (dof * force->boltz); scalar = force->mvv2e * tarray_all[1] / (dof * force->boltz);
else else

View File

@ -29,6 +29,9 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "pair.h" #include "pair.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;

View File

@ -29,6 +29,9 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "pair.h" #include "pair.h"
#include <cmath>
#include <exception>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;

View File

@ -18,6 +18,7 @@
#include "ewald_electrode.h" #include "ewald_electrode.h"
#include "atom.h" #include "atom.h"
#include "boundary_correction.h"
#include "comm.h" #include "comm.h"
#include "domain.h" #include "domain.h"
#include "error.h" #include "error.h"
@ -32,7 +33,6 @@
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include <limits>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;

View File

@ -20,7 +20,6 @@
#include "atom.h" #include "atom.h"
#include "citeme.h" #include "citeme.h"
#include "comm.h" #include "comm.h"
#include "compute.h"
#include "domain.h" #include "domain.h"
#include "electrode_accel_interface.h" #include "electrode_accel_interface.h"
#include "electrode_math.h" #include "electrode_math.h"
@ -37,12 +36,15 @@
#include "neigh_request.h" #include "neigh_request.h"
#include "neighbor.h" #include "neighbor.h"
#include "pair.h" #include "pair.h"
#include "pointers.h"
#include "text_file_reader.h" #include "text_file_reader.h"
#include "variable.h" #include "variable.h"
#include <algorithm>
#include <cassert> #include <cassert>
#include <numeric> #include <cmath>
#include <cstring>
#include <exception>
#include <utility>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -867,7 +869,7 @@ void FixElectrodeConp::update_charges()
accel_interface->intel_pack_buffers(); accel_interface->intel_pack_buffers();
} }
std::vector<double> FixElectrodeConp::ele_ele_interaction(std::vector<double> q_local) std::vector<double> FixElectrodeConp::ele_ele_interaction(const std::vector<double>& q_local)
{ {
assert(q_local.size() == nlocalele); assert(q_local.size() == nlocalele);
assert(algo == Algo::CG || algo == Algo::MATRIX_CG); assert(algo == Algo::CG || algo == Algo::MATRIX_CG);
@ -1415,14 +1417,13 @@ void FixElectrodeConp::gather_list_iele()
} }
taglist_local.clear(); taglist_local.clear();
iele_to_group_local.clear(); iele_to_group_local.clear();
for (int i = 0, iele = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) { if (mask[i] & groupbit) {
tagint const t = tag[i]; tagint const t = tag[i];
if (matrix_algo) list_iele.push_back(tag_to_iele[t]); if (matrix_algo) list_iele.push_back(tag_to_iele[t]);
taglist_local.push_back(t); taglist_local.push_back(t);
for (int g = 0; g < num_of_groups; g++) for (int g = 0; g < num_of_groups; g++)
if (mask[i] & group_bits[g]) iele_to_group_local.push_back(g); if (mask[i] & group_bits[g]) iele_to_group_local.push_back(g);
iele++;
} }
} }
nlocalele = static_cast<int>(taglist_local.size()); // just for safety nlocalele = static_cast<int>(taglist_local.size()); // just for safety

View File

@ -26,15 +26,19 @@ FixStyle(electrode/conp, FixElectrodeConp);
#ifndef LMP_FIX_ELECTRODE_CONP_H #ifndef LMP_FIX_ELECTRODE_CONP_H
#define LMP_FIX_ELECTRODE_CONP_H #define LMP_FIX_ELECTRODE_CONP_H
#include "electrode_accel_interface.h"
#include "fix.h" #include "fix.h"
#include <algorithm>
#include <map> #include <map>
#include <memory> #include <memory>
#include <unordered_map> #include <unordered_map>
namespace LAMMPS_NS { namespace LAMMPS_NS {
// forward decls
class ElectrodeAccelInterface;
class ElectrodeVector;
class NeighList;
class Pair;
class FixElectrodeConp : public Fix { class FixElectrodeConp : public Fix {
@ -75,7 +79,7 @@ class FixElectrodeConp : public Fix {
virtual std::vector<double> constraint_projection(std::vector<double>); virtual std::vector<double> constraint_projection(std::vector<double>);
virtual std::vector<double> constraint_correction(std::vector<double>); virtual std::vector<double> constraint_correction(std::vector<double>);
virtual void compute_macro_matrices(); virtual void compute_macro_matrices();
std::vector<double> ele_ele_interaction(std::vector<double>); std::vector<double> ele_ele_interaction(const std::vector<double> &);
std::vector<double> group_psi; std::vector<double> group_psi;
std::vector<int> group_bits; std::vector<int> group_bits;
std::vector<int> groups; std::vector<int> groups;
@ -102,7 +106,7 @@ class FixElectrodeConp : public Fix {
private: private:
std::string output_file_inv, output_file_mat, output_file_vec; std::string output_file_inv, output_file_mat, output_file_vec;
std::string input_file_inv, input_file_mat; std::string input_file_inv, input_file_mat;
class ElectrodeVector *elyt_vector, *elec_vector; ElectrodeVector *elyt_vector, *elec_vector;
double **capacitance, **elastance; double **capacitance, **elastance;
bool read_inv, read_mat, write_inv, write_mat, write_vec; bool read_inv, read_mat, write_inv, write_mat, write_vec;
bool matrix_algo, need_array_compute, need_elec_vector; bool matrix_algo, need_array_compute, need_elec_vector;
@ -121,8 +125,8 @@ class FixElectrodeConp : public Fix {
void compute_sd_vectors(); void compute_sd_vectors();
void compute_sd_vectors_ffield(); void compute_sd_vectors_ffield();
int groupnum_from_name(char *); int groupnum_from_name(char *);
class Pair *pair; Pair *pair;
class NeighList *mat_neighlist, *vec_neighlist; NeighList *mat_neighlist, *vec_neighlist;
std::vector<int> etypes; std::vector<int> etypes;
int mat_request, vec_request; int mat_request, vec_request;
void request_etypes_neighlists(); void request_etypes_neighlists();

View File

@ -20,12 +20,13 @@
#include "atom.h" #include "atom.h"
#include "error.h" #include "error.h"
#include "fix_electrode_conp.h" #include "fix_electrode_conp.h"
#include "force.h"
#include "input.h" #include "input.h"
#include "random_mars.h" #include "random_mars.h"
#include "update.h" #include "update.h"
#include "variable.h" #include "variable.h"
#include <cmath>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define NUM_GROUPS 2 #define NUM_GROUPS 2

View File

@ -18,12 +18,12 @@
#include "slab_2d.h" #include "slab_2d.h"
#include "atom.h" #include "atom.h"
#include "comm.h"
#include "domain.h" #include "domain.h"
#include "force.h" #include "force.h"
#include "kspace.h" #include "kspace.h"
#include "math_const.h" #include "math_const.h"
#include "memory.h"
#include <cmath>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;

View File

@ -18,12 +18,13 @@
#include "slab_dipole.h" #include "slab_dipole.h"
#include "atom.h" #include "atom.h"
#include "comm.h"
#include "domain.h" #include "domain.h"
#include "force.h" #include "force.h"
#include "kspace.h" #include "kspace.h"
#include "math_const.h" #include "math_const.h"
#include <cmath>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;

View File

@ -19,7 +19,6 @@
#include "atom.h" #include "atom.h"
#include "comm.h" #include "comm.h"
#include "domain.h"
#include "force.h" #include "force.h"
#include "math_const.h" #include "math_const.h"

View File

@ -31,7 +31,6 @@
#include "update.h" #include "update.h"
#include <cmath> #include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;

View File

@ -33,10 +33,8 @@
#include "modify.h" #include "modify.h"
#include "molecule.h" #include "molecule.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neigh_request.h"
#include "neighbor.h" #include "neighbor.h"
#include "pair.h" #include "pair.h"
#include "universe.h"
#include "update.h" #include "update.h"
#include <cmath> #include <cmath>

View File

@ -20,7 +20,6 @@
#include "error.h" #include "error.h"
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
#include "modify.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neighbor.h" #include "neighbor.h"
#include "pair.h" #include "pair.h"

View File

@ -21,7 +21,6 @@
#include "math_const.h" #include "math_const.h"
#include "math_special.h" #include "math_special.h"
#include "memory.h" #include "memory.h"
#include "modify.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neighbor.h" #include "neighbor.h"
#include "pair.h" #include "pair.h"
@ -29,7 +28,6 @@
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
#include <mpi.h>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;

View File

@ -19,19 +19,15 @@
#include "domain.h" #include "domain.h"
#include "error.h" #include "error.h"
#include "force.h" #include "force.h"
#include "lattice.h"
#include "math_const.h" #include "math_const.h"
#include "math_special.h" #include "math_special.h"
#include "memory.h" #include "memory.h"
#include "modify.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neigh_request.h"
#include "neighbor.h" #include "neighbor.h"
#include "pair.h" #include "pair.h"
#include "update.h" #include "update.h"
#include <cmath> #include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;

View File

@ -20,6 +20,8 @@
#include "thermo.h" #include "thermo.h"
#include "update.h" #include "update.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -36,7 +36,6 @@
#include "update.h" #include "update.h"
#include "variable.h" #include "variable.h"
#include <cmath>
#include <cstring> #include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;

View File

@ -14,11 +14,9 @@
#include "fix_viscous_sphere.h" #include "fix_viscous_sphere.h"
#include "atom.h" #include "atom.h"
#include "comm.h"
#include "error.h" #include "error.h"
#include "input.h" #include "input.h"
#include "memory.h" #include "memory.h"
#include "modify.h"
#include "respa.h" #include "respa.h"
#include "update.h" #include "update.h"
#include "variable.h" #include "variable.h"

View File

@ -25,7 +25,6 @@
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
#include "neighbor.h" #include "neighbor.h"
#include "domain.h"
#include <cmath> #include <cmath>

View File

@ -30,7 +30,6 @@
#include "kspace.h" #include "kspace.h"
#include "memory.h" #include "memory.h"
#include "modify.h" #include "modify.h"
#include "neighbor.h"
#include "pair.h" #include "pair.h"
#include "timer.h" #include "timer.h"
#include "update.h" #include "update.h"

View File

@ -120,8 +120,8 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) :
// If ngpu is 0, autoset ngpu to the number of devices per node matching // If ngpu is 0, autoset ngpu to the number of devices per node matching
// best device // best device
int ngpu = atoi(arg[3]); int ngpu = utils::inumeric(FLERR, arg[3], false, lmp);
if (ngpu < 0) error->all(FLERR,"Illegal package gpu command"); if (ngpu < 0) error->all(FLERR,"Illegal number of GPUs ({}) in package gpu command", ngpu);
// Negative value indicate GPU package should find the best device ID // Negative value indicate GPU package should find the best device ID
int first_gpu_id = -1; int first_gpu_id = -1;

View File

@ -25,8 +25,6 @@
#include "neighbor.h" #include "neighbor.h"
#include "update.h" #include "update.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -27,7 +27,6 @@
#include "memory.h" #include "memory.h"
#include "modify.h" #include "modify.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neigh_request.h"
#include "neighbor.h" #include "neighbor.h"
#include "update.h" #include "update.h"

View File

@ -32,7 +32,6 @@
#include "memory.h" #include "memory.h"
#include "modify.h" #include "modify.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neigh_request.h"
#include "neighbor.h" #include "neighbor.h"
#include "update.h" #include "update.h"

View File

@ -28,7 +28,6 @@
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neigh_request.h"
#include "neighbor.h" #include "neighbor.h"
#include "potential_file_reader.h" #include "potential_file_reader.h"

View File

@ -22,15 +22,12 @@
#include "atom.h" #include "atom.h"
#include "citeme.h" #include "citeme.h"
#include "comm.h"
#include "error.h" #include "error.h"
#include "force.h" #include "force.h"
#include "interlayer_taper.h" #include "interlayer_taper.h"
#include "memory.h" #include "memory.h"
#include "my_page.h" #include "my_page.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neigh_request.h"
#include "neighbor.h"
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>

View File

@ -26,8 +26,6 @@
#include "force.h" #include "force.h"
#include "interlayer_taper.h" #include "interlayer_taper.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neigh_request.h"
#include "neighbor.h"
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>

View File

@ -155,11 +155,9 @@ void KimParam::command(int narg, char **arg)
std::string kim_param_get_set(arg[0]); std::string kim_param_get_set(arg[0]);
if ((kim_param_get_set != "get") && (kim_param_get_set != "set")) { if ((kim_param_get_set != "get") && (kim_param_get_set != "set"))
std::string msg("Incorrect arguments in 'kim param' command.\n"); error->all(FLERR, "Incorrect arguments in 'kim param' command.\n"
msg += "'kim param get/set' is mandatory"; "'kim param get/set' is mandatory");
error->all(FLERR, msg);
}
int const ifix = modify->find_fix("KIM_MODEL_STORE"); int const ifix = modify->find_fix("KIM_MODEL_STORE");
if (ifix >= 0) { if (ifix >= 0) {
@ -170,8 +168,7 @@ void KimParam::command(int narg, char **arg)
fix_store->getptr("simulator_model")); fix_store->getptr("simulator_model"));
if (simulatorModel) if (simulatorModel)
error->all(FLERR, error->all(FLERR, "'kim param' can only be used with a KIM Portable Model");
"'kim param' can only be used with a KIM Portable Model");
} }
input->write_echo(fmt::format("#=== BEGIN kim param {} ===================" input->write_echo(fmt::format("#=== BEGIN kim param {} ==================="
@ -196,13 +193,10 @@ void KimParam::command(int narg, char **arg)
} else } else
error->all(FLERR, "Pair style is defined, but there is " error->all(FLERR, "Pair style is defined, but there is "
"no match for kim style in lammps"); "no match for kim style in lammps");
} else { } else
auto msg = fmt::format("Illegal 'kim param {0}' command.\nTo {0} the new " error->all(FLERR, "Illegal 'kim param {0}' command.\nTo {0} the new parameter values, "
"parameter values, pair style must be assigned.\n" "pair style must be assigned.\nMust use 'kim interactions' or 'pair_style kim' "
"Must use 'kim interactions' or 'pair_style kim' "
"before 'kim param {0}'", kim_param_get_set); "before 'kim param {0}'", kim_param_get_set);
error->all(FLERR, msg);
}
// Get the number of mutable parameters in the kim model // Get the number of mutable parameters in the kim model
int numberOfParameters(0); int numberOfParameters(0);
@ -243,12 +237,9 @@ void KimParam::command(int narg, char **arg)
if (paramname == str_name_str) break; if (paramname == str_name_str) break;
} }
if (param_index >= numberOfParameters) { if (param_index >= numberOfParameters)
auto msg = fmt::format("Wrong argument in 'kim param get' command.\n" error->all(FLERR, "Wrong argument in 'kim param get' command.\n"
"This Model does not have the requested '{}' " "This Model does not have the requested '{}' parameter", paramname);
"parameter", paramname);
error->all(FLERR, msg);
}
// Get the index_range for the requested parameter // Get the index_range for the requested parameter
int nlbound(0); int nlbound(0);
@ -259,12 +250,9 @@ void KimParam::command(int narg, char **arg)
// Check to see if the indices range contains // Check to see if the indices range contains
// only integer numbers and/or range : // only integer numbers and/or range :
if (argtostr.find_first_not_of("0123456789:") != std::string::npos) { if (argtostr.find_first_not_of("0123456789:") != std::string::npos)
auto msg = fmt::format("Illegal index_range.\nExpected integer " error->all(FLERR, "Illegal index_range.\nExpected integer parameter(s) instead "
"parameter(s) instead of '{}' in " "of '{}' in index_range", argtostr);
"index_range", argtostr);
error->all(FLERR, msg);
}
std::string::size_type npos = argtostr.find(':'); std::string::size_type npos = argtostr.find(':');
if (npos != std::string::npos) { if (npos != std::string::npos) {
@ -273,30 +261,20 @@ void KimParam::command(int narg, char **arg)
nlbound = atoi(words[0].c_str()); nlbound = atoi(words[0].c_str());
nubound = atoi(words[1].c_str()); nubound = atoi(words[1].c_str());
if (nubound < 1 || nubound > extent || if ((nubound < 1) || (nubound > extent) || (nlbound < 1) || (nlbound > nubound))
nlbound < 1 || nlbound > nubound) { error->all(FLERR, "Illegal index_range '{}-{}' for '{}' parameter with the "
auto msg = fmt::format("Illegal index_range '{}-{}' for '{}' " "extent of '{}'",nlbound, nubound, paramname, extent);
"parameter with the extent of '{}'",
nlbound, nubound, paramname, extent);
error->all(FLERR, msg);
}
} else { } else {
nlbound = atoi(argtostr.c_str()); nlbound = atoi(argtostr.c_str());
if (nlbound < 1 || nlbound > extent) { if (nlbound < 1 || nlbound > extent)
auto msg = fmt::format("Illegal index '{}' for '{}' parameter " error->all(FLERR, "Illegal index '{}' for '{}' parameter with the extent of '{}'",
"with the extent of '{}'", nlbound, nlbound, paramname, extent);
paramname, extent);
error->all(FLERR, msg);
}
nubound = nlbound; nubound = nlbound;
} }
} else { } else
std::string msg("Wrong number of arguments in 'kim param get' "); error->all(FLERR, "Wrong number of arguments in 'kim param get' command.\n"
msg += "command.\nIndex range after parameter name is mandatory"; "Index range after parameter name is mandatory");
error->all(FLERR, msg);
}
int const nvars = nubound - nlbound + 1; int const nvars = nubound - nlbound + 1;
std::vector<std::string> varsname; std::vector<std::string> varsname;
@ -304,15 +282,11 @@ void KimParam::command(int narg, char **arg)
if (i < narg) { if (i < narg) {
// Get the variable/variable_base name // Get the variable/variable_base name
varname = std::string(arg[i++]); varname = std::string(arg[i++]);
if ((varname == "split") || if ((varname == "split") || (varname == "list") || (varname == "explicit"))
(varname == "list") || error->all(FLERR, "Illegal variable name '{}' in 'kim param get'", varname);
(varname == "explicit")) } else
error->all(FLERR, "Illegal variable name in 'kim param get'"); error->all(FLERR, "Wrong number of arguments in 'kim param get' command.\n"
} else { "The LAMMPS variable name is mandatory");
std::string msg("Wrong number of arguments in 'kim param get' ");
msg += "command.\nThe LAMMPS variable name is mandatory";
error->all(FLERR, msg);
}
// indicator flag for list request // indicator flag for list request
bool list_requested(false); bool list_requested(false);
@ -337,28 +311,22 @@ void KimParam::command(int narg, char **arg)
--i; --i;
for (int j = 0; j < nvars; ++j, ++i) { for (int j = 0; j < nvars; ++j, ++i) {
varsname[j] = std::string(arg[i]); varsname[j] = std::string(arg[i]);
if (varsname[j] == "split" || varsname[j] == "list" || if (varsname[j] == "split" || varsname[j] == "list" || varsname[j] == "explicit")
varsname[j] == "explicit") error->all(FLERR, "Illegal variable name '{}' in 'kim param get'", varsname[j]);
error->all(FLERR, "Illegal variable name in 'kim param get'");
} }
if (i < narg) { if (i < narg) {
formatarg = std::string(arg[i]); formatarg = std::string(arg[i]);
if (formatarg == "explicit") ++i; if (formatarg == "explicit") ++i;
} }
} else { } else {
auto msg = error->all(FLERR, "Wrong number of arguments in 'kim param get' command.\n"
fmt::format("Wrong number of arguments in 'kim param get' " "The LAMMPS '{}' variable names or '{} split' is mandatory",
"command.\nThe LAMMPS '{}' variable names or " nvars, varname);
"'{} split' is mandatory", nvars, varname);
error->all(FLERR, msg);
}
} else {
auto msg =
fmt::format("Wrong number of arguments in 'kim param get' "
"command.\nThe LAMMPS '{}' variable names or "
"'{} split/list' is mandatory", nvars, varname);
error->all(FLERR, msg);
} }
} else
error->all(FLERR, "Wrong number of arguments in 'kim param get' command.\n"
"The LAMMPS '{}' variable names or '{} split/list' is mandatory",
nvars, varname);
} else { } else {
varsname.resize(1); varsname.resize(1);
if (i < narg) { if (i < narg) {

View File

@ -483,15 +483,13 @@ void PairKIM::coeff(int narg, char **arg)
nlbound = atoi(words[0].c_str()); nlbound = atoi(words[0].c_str());
nubound = atoi(words[1].c_str()); nubound = atoi(words[1].c_str());
if (nubound < 1 || nubound > extent || if ((nubound < 1) || (nubound > extent) || (nlbound < 1) || (nlbound > nubound))
nlbound < 1 || nlbound > nubound) error->all(FLERR,"Illegal index_range '{}-{}' for '{}' parameter with the extent of '{}'",
error->all(FLERR,"Illegal index_range '{}-{}' for '{}' "
"parameter with the extent of '{}'",
nlbound, nubound, paramname, extent); nlbound, nubound, paramname, extent);
} else { } else {
nlbound = atoi(argtostr.c_str()); nlbound = atoi(argtostr.c_str());
if (nlbound < 1 || nlbound > extent) if ((nlbound < 1) || (nlbound > extent))
error->all(FLERR,"Illegal index '{}' for '{}' parameter with the extent of '{}'", error->all(FLERR,"Illegal index '{}' for '{}' parameter with the extent of '{}'",
nlbound, paramname, extent); nlbound, paramname, extent);
@ -1081,8 +1079,7 @@ void PairKIM::set_kim_model_has_flags()
KIM_ComputeArguments_GetArgumentSupportStatus( KIM_ComputeArguments_GetArgumentSupportStatus(
pargs, computeArgumentName, &supportStatus); pargs, computeArgumentName, &supportStatus);
if (KIM_ComputeArgumentName_Equal(computeArgumentName, if (KIM_ComputeArgumentName_Equal(computeArgumentName, KIM_COMPUTE_ARGUMENT_NAME_partialEnergy))
KIM_COMPUTE_ARGUMENT_NAME_partialEnergy))
kim_model_support_for_energy = supportStatus; kim_model_support_for_energy = supportStatus;
else if (KIM_ComputeArgumentName_Equal( else if (KIM_ComputeArgumentName_Equal(
computeArgumentName, KIM_COMPUTE_ARGUMENT_NAME_partialForces)) computeArgumentName, KIM_COMPUTE_ARGUMENT_NAME_partialForces))
@ -1095,17 +1092,14 @@ void PairKIM::set_kim_model_has_flags()
computeArgumentName, computeArgumentName,
KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial)) KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial))
kim_model_support_for_particleVirial = supportStatus; kim_model_support_for_particleVirial = supportStatus;
else if (KIM_SupportStatus_Equal(supportStatus, else if (KIM_SupportStatus_Equal(supportStatus, KIM_SUPPORT_STATUS_required)) {
KIM_SUPPORT_STATUS_required)) { error->all(FLERR, "KIM Model requires unsupported compute argument: {}",
std::string msg("KIM Model requires unsupported compute argument: "); KIM_ComputeArgumentName_ToString(computeArgumentName));
msg += KIM_ComputeArgumentName_ToString(computeArgumentName);
error->all(FLERR,msg);
} }
} }
if (comm->me == 0) { if (comm->me == 0) {
if (KIM_SupportStatus_Equal(kim_model_support_for_energy, if (KIM_SupportStatus_Equal(kim_model_support_for_energy, KIM_SUPPORT_STATUS_notSupported))
KIM_SUPPORT_STATUS_notSupported))
error->warning(FLERR,"KIM Model does not provide 'partialEnergy'; Potential energy will be zero"); error->warning(FLERR,"KIM Model does not provide 'partialEnergy'; Potential energy will be zero");
if (KIM_SupportStatus_Equal(kim_model_support_for_forces, if (KIM_SupportStatus_Equal(kim_model_support_for_forces,

View File

@ -64,8 +64,8 @@ action atom_vec_bond_kokkos.cpp atom_vec_bond.cpp
action atom_vec_bond_kokkos.h atom_vec_bond.h action atom_vec_bond_kokkos.h atom_vec_bond.h
action atom_vec_charge_kokkos.cpp action atom_vec_charge_kokkos.cpp
action atom_vec_charge_kokkos.h action atom_vec_charge_kokkos.h
action atom_vec_spin_kokkos.cpp action atom_vec_spin_kokkos.cpp atom_vec_spin.cpp
action atom_vec_spin_kokkos.h action atom_vec_spin_kokkos.h atom_vec_spin.h
action atom_vec_dpd_kokkos.cpp atom_vec_dpd.cpp action atom_vec_dpd_kokkos.cpp atom_vec_dpd.cpp
action atom_vec_dpd_kokkos.h atom_vec_dpd.h action atom_vec_dpd_kokkos.h atom_vec_dpd.h
action atom_vec_full_kokkos.cpp atom_vec_full.cpp action atom_vec_full_kokkos.cpp atom_vec_full.cpp

View File

@ -104,23 +104,23 @@ AtomKokkos::~AtomKokkos()
void AtomKokkos::sync(const ExecutionSpace space, unsigned int mask) void AtomKokkos::sync(const ExecutionSpace space, unsigned int mask)
{ {
if (space == Device && lmp->kokkos->auto_sync) ((AtomVecKokkos *) avec)->modified(Host, mask); if (space == Device && lmp->kokkos->auto_sync) avecKK->modified(Host, mask);
((AtomVecKokkos *) avec)->sync(space, mask); avecKK->sync(space, mask);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AtomKokkos::modified(const ExecutionSpace space, unsigned int mask) void AtomKokkos::modified(const ExecutionSpace space, unsigned int mask)
{ {
((AtomVecKokkos *) avec)->modified(space, mask); avecKK->modified(space, mask);
if (space == Device && lmp->kokkos->auto_sync) ((AtomVecKokkos *) avec)->sync(Host, mask); if (space == Device && lmp->kokkos->auto_sync) avecKK->sync(Host, mask);
} }
void AtomKokkos::sync_overlapping_device(const ExecutionSpace space, unsigned int mask) void AtomKokkos::sync_overlapping_device(const ExecutionSpace space, unsigned int mask)
{ {
((AtomVecKokkos *) avec)->sync_overlapping_device(space, mask); avecKK->sync_overlapping_device(space, mask);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -380,5 +380,8 @@ AtomVec *AtomKokkos::new_avec(const std::string &style, int trysuffix, int &sfla
{ {
AtomVec *avec = Atom::new_avec(style, trysuffix, sflag); AtomVec *avec = Atom::new_avec(style, trysuffix, sflag);
if (!avec->kokkosable) error->all(FLERR, "KOKKOS package requires a kokkos enabled atom_style"); if (!avec->kokkosable) error->all(FLERR, "KOKKOS package requires a kokkos enabled atom_style");
avecKK = dynamic_cast<AtomVecKokkos*>(avec);
return avec; return avec;
} }

View File

@ -78,6 +78,8 @@ class AtomKokkos : public Atom {
DAT::tdual_int_scalar k_error_flag; DAT::tdual_int_scalar k_error_flag;
dual_hash_type k_map_hash; dual_hash_type k_map_hash;
class AtomVecKokkos* avecKK;
// map lookup function inlined for efficiency // map lookup function inlined for efficiency
// return -1 if no map defined // return -1 if no map defined

View File

@ -27,27 +27,10 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecAngleKokkos::AtomVecAngleKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) AtomVecAngleKokkos::AtomVecAngleKokkos(LAMMPS *lmp) : AtomVec(lmp),
AtomVecKokkos(lmp), AtomVecAngle(lmp)
{ {
molecular = Atom::MOLECULAR;
bonds_allow = angles_allow = 1;
mass_type = PER_TYPE;
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;
k_count = DAT::tdual_int_1d("atom::k_count",1);
atomKK = (AtomKokkos *) atom;
commKK = (CommKokkos *) comm;
buffer = nullptr;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -172,52 +155,6 @@ void AtomVecAngleKokkos::grow_pointers()
h_angle_atom3 = atomKK->k_angle_atom3.h_view; h_angle_atom3 = atomKK->k_angle_atom3.h_view;
} }
/* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecAngleKokkos::copy(int i, int j, int delflag)
{
int k;
h_tag[j] = h_tag[i];
h_type[j] = h_type[i];
mask[j] = mask[i];
h_image[j] = h_image[i];
h_x(j,0) = h_x(i,0);
h_x(j,1) = h_x(i,1);
h_x(j,2) = h_x(i,2);
h_v(j,0) = h_v(i,0);
h_v(j,1) = h_v(i,1);
h_v(j,2) = h_v(i,2);
h_molecule(j) = h_molecule(i);
h_num_bond(j) = h_num_bond(i);
for (k = 0; k < h_num_bond(j); k++) {
h_bond_type(j,k) = h_bond_type(i,k);
h_bond_atom(j,k) = h_bond_atom(i,k);
}
h_nspecial(j,0) = h_nspecial(i,0);
h_nspecial(j,1) = h_nspecial(i,1);
h_nspecial(j,2) = h_nspecial(i,2);
for (k = 0; k < h_nspecial(j,2); k++)
h_special(j,k) = h_special(i,k);
h_num_angle(j) = h_num_angle(i);
for (k = 0; k < h_num_angle(j); k++) {
h_angle_type(j,k) = h_angle_type(i,k);
h_angle_atom1(j,k) = h_angle_atom1(i,k);
h_angle_atom2(j,k) = h_angle_atom2(i,k);
h_angle_atom3(j,k) = h_angle_atom3(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);
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
template<class DeviceType,int PBC_FLAG,int TRICLINIC> template<class DeviceType,int PBC_FLAG,int TRICLINIC>
@ -508,171 +445,6 @@ void AtomVecAngleKokkos::unpack_comm_kokkos(const int &n, const int &first,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int AtomVecAngleKokkos::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++] = h_x(j,0);
buf[m++] = h_x(j,1);
buf[m++] = h_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++] = h_x(j,0) + dx;
buf[m++] = h_x(j,1) + dy;
buf[m++] = h_x(j,2) + dz;
}
}
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecAngleKokkos::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++] = h_x(j,0);
buf[m++] = h_x(j,1);
buf[m++] = h_x(j,2);
buf[m++] = h_v(j,0);
buf[m++] = h_v(j,1);
buf[m++] = h_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++] = h_x(j,0) + dx;
buf[m++] = h_x(j,1) + dy;
buf[m++] = h_x(j,2) + dz;
buf[m++] = h_v(j,0);
buf[m++] = h_v(j,1);
buf[m++] = h_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++] = h_x(j,0) + dx;
buf[m++] = h_x(j,1) + dy;
buf[m++] = h_x(j,2) + dz;
if (mask[i] & deform_groupbit) {
buf[m++] = h_v(j,0) + dvx;
buf[m++] = h_v(j,1) + dvy;
buf[m++] = h_v(j,2) + dvz;
} else {
buf[m++] = h_v(j,0);
buf[m++] = h_v(j,1);
buf[m++] = h_v(j,2);
}
}
}
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecAngleKokkos::unpack_comm(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
h_x(i,0) = buf[m++];
h_x(i,1) = buf[m++];
h_x(i,2) = buf[m++];
}
}
/* ---------------------------------------------------------------------- */
void AtomVecAngleKokkos::unpack_comm_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
h_x(i,0) = buf[m++];
h_x(i,1) = buf[m++];
h_x(i,2) = buf[m++];
h_v(i,0) = buf[m++];
h_v(i,1) = buf[m++];
h_v(i,2) = buf[m++];
}
}
/* ---------------------------------------------------------------------- */
int AtomVecAngleKokkos::pack_reverse(int n, int first, double *buf)
{
if (n > 0)
atomKK->sync(Host,F_MASK);
int m = 0;
const int last = first + n;
for (int i = first; i < last; i++) {
buf[m++] = h_f(i,0);
buf[m++] = h_f(i,1);
buf[m++] = h_f(i,2);
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecAngleKokkos::unpack_reverse(int n, int *list, double *buf)
{
if (n > 0)
atomKK->modified(Host,F_MASK);
int m = 0;
for (int i = 0; i < n; i++) {
const int j = list[i];
h_f(j,0) += buf[m++];
h_f(j,1) += buf[m++];
h_f(j,2) += buf[m++];
}
}
/* ---------------------------------------------------------------------- */
template<class DeviceType,int PBC_FLAG> template<class DeviceType,int PBC_FLAG>
struct AtomVecAngleKokkos_PackBorder { struct AtomVecAngleKokkos_PackBorder {
typedef DeviceType device_type; typedef DeviceType device_type;
@ -774,149 +546,6 @@ int AtomVecAngleKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int AtomVecAngleKokkos::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++] = h_x(j,0);
buf[m++] = h_x(j,1);
buf[m++] = h_x(j,2);
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = ubuf(h_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++] = h_x(j,0) + dx;
buf[m++] = h_x(j,1) + dy;
buf[m++] = h_x(j,2) + dz;
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = ubuf(h_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 AtomVecAngleKokkos::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++] = h_x(j,0);
buf[m++] = h_x(j,1);
buf[m++] = h_x(j,2);
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = ubuf(h_molecule(j)).d;
buf[m++] = h_v(j,0);
buf[m++] = h_v(j,1);
buf[m++] = h_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++] = h_x(j,0) + dx;
buf[m++] = h_x(j,1) + dy;
buf[m++] = h_x(j,2) + dz;
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = ubuf(h_molecule(j)).d;
buf[m++] = h_v(j,0);
buf[m++] = h_v(j,1);
buf[m++] = h_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++] = h_x(j,0) + dx;
buf[m++] = h_x(j,1) + dy;
buf[m++] = h_x(j,2) + dz;
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = ubuf(h_molecule(j)).d;
if (mask[i] & deform_groupbit) {
buf[m++] = h_v(j,0) + dvx;
buf[m++] = h_v(j,1) + dvy;
buf[m++] = h_v(j,2) + dvz;
} else {
buf[m++] = h_v(j,0);
buf[m++] = h_v(j,1);
buf[m++] = h_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 AtomVecAngleKokkos::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++] = h_molecule(j);
}
return m;
}
/* ---------------------------------------------------------------------- */
template<class DeviceType> template<class DeviceType>
struct AtomVecAngleKokkos_UnpackBorder { struct AtomVecAngleKokkos_UnpackBorder {
typedef DeviceType device_type; typedef DeviceType device_type;
@ -977,78 +606,6 @@ void AtomVecAngleKokkos::unpack_border_kokkos(const int &n, const int &first,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AtomVecAngleKokkos::unpack_border(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
while (last > nmax) grow(0);
for (i = first; i < last; i++) {
h_x(i,0) = buf[m++];
h_x(i,1) = buf[m++];
h_x(i,2) = buf[m++];
h_tag(i) = (tagint) ubuf(buf[m++]).i;
h_type(i) = (int) ubuf(buf[m++]).i;
h_mask(i) = (int) ubuf(buf[m++]).i;
h_molecule(i) = (tagint) ubuf(buf[m++]).i;
}
atomKK->modified(Host,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK);
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 AtomVecAngleKokkos::unpack_border_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
while (last > nmax) grow(0);
for (i = first; i < last; i++) {
h_x(i,0) = buf[m++];
h_x(i,1) = buf[m++];
h_x(i,2) = buf[m++];
h_tag(i) = (tagint) ubuf(buf[m++]).i;
h_type(i) = (int) ubuf(buf[m++]).i;
h_mask(i) = (int) ubuf(buf[m++]).i;
h_molecule(i) = (tagint) ubuf(buf[m++]).i;
h_v(i,0) = buf[m++];
h_v(i,1) = buf[m++];
h_v(i,2) = buf[m++];
}
atomKK->modified(Host,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK|V_MASK);
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 AtomVecAngleKokkos::unpack_border_hybrid(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++)
h_molecule(i) = (tagint) ubuf(buf[m++]).i;
return m;
}
/* ---------------------------------------------------------------------- */
template<class DeviceType> template<class DeviceType>
struct AtomVecAngleKokkos_PackExchangeFunctor { struct AtomVecAngleKokkos_PackExchangeFunctor {
typedef DeviceType device_type; typedef DeviceType device_type;
@ -1245,50 +802,6 @@ int AtomVecAngleKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int AtomVecAngleKokkos::pack_exchange(int i, double *buf)
{
int k;
int m = 1;
buf[m++] = h_x(i,0);
buf[m++] = h_x(i,1);
buf[m++] = h_x(i,2);
buf[m++] = h_v(i,0);
buf[m++] = h_v(i,1);
buf[m++] = h_v(i,2);
buf[m++] = ubuf(h_tag(i)).d;
buf[m++] = ubuf(h_type(i)).d;
buf[m++] = ubuf(h_mask(i)).d;
buf[m++] = ubuf(h_image(i)).d;
buf[m++] = ubuf(h_molecule(i)).d;
buf[m++] = ubuf(h_num_bond(i)).d;
for (k = 0; k < h_num_bond(i); k++) {
buf[m++] = ubuf(h_bond_type(i,k)).d;
buf[m++] = ubuf(h_bond_atom(i,k)).d;
}
buf[m++] = ubuf(h_num_angle(i)).d;
for (k = 0; k < h_num_angle(i); k++) {
buf[m++] = ubuf(h_angle_type(i,k)).d;
buf[m++] = ubuf(h_angle_atom1(i,k)).d;
buf[m++] = ubuf(h_angle_atom2(i,k)).d;
buf[m++] = ubuf(h_angle_atom3(i,k)).d;
}
buf[m++] = ubuf(h_nspecial(i,0)).d;
buf[m++] = ubuf(h_nspecial(i,1)).d;
buf[m++] = ubuf(h_nspecial(i,2)).d;
for (k = 0; k < h_nspecial(i,2); k++)
buf[m++] = ubuf(h_special(i,k)).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;
}
/* ---------------------------------------------------------------------- */
template<class DeviceType> template<class DeviceType>
struct AtomVecAngleKokkos_UnpackExchangeFunctor { struct AtomVecAngleKokkos_UnpackExchangeFunctor {
typedef DeviceType device_type; typedef DeviceType device_type;
@ -1416,361 +929,6 @@ int AtomVecAngleKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int n
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int AtomVecAngleKokkos::unpack_exchange(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
atomKK->modified(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK |
MASK_MASK | IMAGE_MASK | MOLECULE_MASK | BOND_MASK |
ANGLE_MASK | SPECIAL_MASK);
int k;
int m = 1;
h_x(nlocal,0) = buf[m++];
h_x(nlocal,1) = buf[m++];
h_x(nlocal,2) = buf[m++];
h_v(nlocal,0) = buf[m++];
h_v(nlocal,1) = buf[m++];
h_v(nlocal,2) = buf[m++];
h_tag(nlocal) = (tagint) ubuf(buf[m++]).i;
h_type(nlocal) = (int) ubuf(buf[m++]).i;
h_mask(nlocal) = (int) ubuf(buf[m++]).i;
h_image(nlocal) = (imageint) ubuf(buf[m++]).i;
h_molecule(nlocal) = (tagint) ubuf(buf[m++]).i;
h_num_bond(nlocal) = (int) ubuf(buf[m++]).i;
for (k = 0; k < h_num_bond(nlocal); k++) {
h_bond_type(nlocal,k) = (int) ubuf(buf[m++]).i;
h_bond_atom(nlocal,k) = (tagint) ubuf(buf[m++]).i;
}
h_num_angle(nlocal) = (int) ubuf(buf[m++]).i;
for (k = 0; k < h_num_angle(nlocal); k++) {
h_angle_type(nlocal,k) = (int) ubuf(buf[m++]).i;
h_angle_atom1(nlocal,k) = (tagint) ubuf(buf[m++]).i;
h_angle_atom2(nlocal,k) = (tagint) ubuf(buf[m++]).i;
h_angle_atom3(nlocal,k) = (tagint) ubuf(buf[m++]).i;
}
h_nspecial(nlocal,0) = (int) ubuf(buf[m++]).i;
h_nspecial(nlocal,1) = (int) ubuf(buf[m++]).i;
h_nspecial(nlocal,2) = (int) ubuf(buf[m++]).i;
for (k = 0; k < h_nspecial(nlocal,2); k++)
h_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 AtomVecAngleKokkos::size_restart()
{
int i;
int nlocal = atom->nlocal;
int n = 0;
for (i = 0; i < nlocal; i++)
n += 14 + 2*h_num_bond(i) + 4*h_num_angle(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 AtomVecAngleKokkos::pack_restart(int i, double *buf)
{
atomKK->sync(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK |
MASK_MASK | IMAGE_MASK | MOLECULE_MASK | BOND_MASK |
ANGLE_MASK | SPECIAL_MASK);
int m = 1;
buf[m++] = h_x(i,0);
buf[m++] = h_x(i,1);
buf[m++] = h_x(i,2);
buf[m++] = ubuf(h_tag(i)).d;
buf[m++] = ubuf(h_type(i)).d;
buf[m++] = ubuf(h_mask(i)).d;
buf[m++] = ubuf(h_image(i)).d;
buf[m++] = h_v(i,0);
buf[m++] = h_v(i,1);
buf[m++] = h_v(i,2);
buf[m++] = ubuf(h_molecule(i)).d;
buf[m++] = ubuf(h_num_bond(i)).d;
for (int k = 0; k < h_num_bond(i); k++) {
buf[m++] = ubuf(MAX(h_bond_type(i,k),-h_bond_type(i,k))).d;
buf[m++] = ubuf(h_bond_atom(i,k)).d;
}
buf[m++] = ubuf(h_num_angle(i)).d;
for (int k = 0; k < h_num_angle(i); k++) {
buf[m++] = ubuf(MAX(h_angle_type(i,k),-h_angle_type(i,k))).d;
buf[m++] = ubuf(h_angle_atom1(i,k)).d;
buf[m++] = ubuf(h_angle_atom2(i,k)).d;
buf[m++] = ubuf(h_angle_atom3(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 AtomVecAngleKokkos::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");
}
atomKK->modified(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK |
MASK_MASK | IMAGE_MASK | MOLECULE_MASK | BOND_MASK |
ANGLE_MASK | SPECIAL_MASK);
int m = 1;
h_x(nlocal,0) = buf[m++];
h_x(nlocal,1) = buf[m++];
h_x(nlocal,2) = buf[m++];
h_tag(nlocal) = (tagint) ubuf(buf[m++]).i;
h_type(nlocal) = (int) ubuf(buf[m++]).i;
h_mask(nlocal) = (int) ubuf(buf[m++]).i;
h_image(nlocal) = (imageint) ubuf(buf[m++]).i;
h_v(nlocal,0) = buf[m++];
h_v(nlocal,1) = buf[m++];
h_v(nlocal,2) = buf[m++];
h_molecule(nlocal) = (tagint) ubuf(buf[m++]).i;
h_num_bond(nlocal) = (int) ubuf(buf[m++]).i;
for (k = 0; k < h_num_bond(nlocal); k++) {
h_bond_type(nlocal,k) = (int) ubuf(buf[m++]).i;
h_bond_atom(nlocal,k) = (tagint) ubuf(buf[m++]).i;
}
h_num_angle(nlocal) = (int) ubuf(buf[m++]).i;
for (k = 0; k < h_num_angle(nlocal); k++) {
h_angle_type(nlocal,k) = (int) ubuf(buf[m++]).i;
h_angle_atom1(nlocal,k) = (tagint) ubuf(buf[m++]).i;
h_angle_atom2(nlocal,k) = (tagint) ubuf(buf[m++]).i;
h_angle_atom3(nlocal,k) = (tagint) ubuf(buf[m++]).i;
}
h_nspecial(nlocal,0) = h_nspecial(nlocal,1) = h_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 AtomVecAngleKokkos::create_atom(int itype, double *coord)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) {
atomKK->modified(Host,ALL_MASK);
grow(0);
}
atomKK->modified(Host,ALL_MASK);
tag[nlocal] = 0;
type[nlocal] = itype;
h_x(nlocal,0) = coord[0];
h_x(nlocal,1) = coord[1];
h_x(nlocal,2) = coord[2];
h_mask(nlocal) = 1;
h_image(nlocal) = ((imageint) IMGMAX << IMG2BITS) |
((imageint) IMGMAX << IMGBITS) | IMGMAX;
h_v(nlocal,0) = 0.0;
h_v(nlocal,1) = 0.0;
h_v(nlocal,2) = 0.0;
h_molecule(nlocal) = 0;
h_num_bond(nlocal) = 0;
h_num_angle(nlocal) = 0;
h_nspecial(nlocal,0) = h_nspecial(nlocal,1) = h_nspecial(nlocal,2) = 0;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack one line from Atoms section of data file
initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecAngleKokkos::data_atom(double *coord, imageint imagetmp,
const std::vector<std::string> &values, std::string &extract)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
atomKK->modified(Host,ALL_MASK);
h_tag(nlocal) = utils::inumeric(FLERR,values[0],true,lmp);
h_molecule(nlocal) = utils::inumeric(FLERR,values[1],true,lmp);
h_type(nlocal) = utils::inumeric(FLERR,values[2],true,lmp);
extract = values[2];
if (h_type(nlocal) <= 0 || h_type(nlocal) > atom->ntypes)
error->one(FLERR,"Invalid atom type in Atoms section of data file");
h_x(nlocal,0) = coord[0];
h_x(nlocal,1) = coord[1];
h_x(nlocal,2) = coord[2];
h_image(nlocal) = imagetmp;
h_mask(nlocal) = 1;
h_v(nlocal,0) = 0.0;
h_v(nlocal,1) = 0.0;
h_v(nlocal,2) = 0.0;
h_num_bond(nlocal) = 0;
h_num_angle(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 AtomVecAngleKokkos::data_atom_hybrid(int nlocal, const std::vector<std::string> &values,
int offset)
{
h_molecule(nlocal) = utils::inumeric(FLERR,values[offset],true,lmp);
h_num_bond(nlocal) = 0;
h_num_angle(nlocal) = 0;
return 1;
}
/* ----------------------------------------------------------------------
pack atom info for data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecAngleKokkos::pack_data(double **buf)
{
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
buf[i][0] = h_tag(i);
buf[i][1] = h_molecule(i);
buf[i][2] = h_type(i);
buf[i][3] = h_x(i,0);
buf[i][4] = h_x(i,1);
buf[i][5] = h_x(i,2);
buf[i][6] = (h_image[i] & IMGMASK) - IMGMAX;
buf[i][7] = (h_image[i] >> IMGBITS & IMGMASK) - IMGMAX;
buf[i][8] = (h_image[i] >> IMG2BITS) - IMGMAX;
}
}
/* ----------------------------------------------------------------------
pack hybrid atom info for data file
------------------------------------------------------------------------- */
int AtomVecAngleKokkos::pack_data_hybrid(int i, double *buf)
{
buf[0] = h_molecule(i);
return 1;
}
/* ----------------------------------------------------------------------
write atom info to data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecAngleKokkos::write_data(FILE *fp, int n, double **buf)
{
for (int i = 0; i < n; i++)
fprintf(fp,"%d %d %d %-1.16e %-1.16e %-1.16e %d %d %d\n",
(int) buf[i][0],(int) buf[i][1], (int) buf[i][2],
buf[i][3],buf[i][4],buf[i][5],
(int) buf[i][6],(int) buf[i][7],(int) buf[i][8]);
}
/* ----------------------------------------------------------------------
write hybrid atom info to data file
------------------------------------------------------------------------- */
int AtomVecAngleKokkos::write_data_hybrid(FILE *fp, double *buf)
{
fprintf(fp," " TAGINT_FORMAT, (tagint) (buf[0]));
return 1;
}
/* ----------------------------------------------------------------------
return # of bytes of allocated memory
------------------------------------------------------------------------- */
double AtomVecAngleKokkos::memory_usage()
{
double 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*commKK->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);
if (atom->memcheck("num_angle")) bytes += memory->usage(num_angle,nmax);
if (atom->memcheck("angle_type"))
bytes += memory->usage(angle_type,nmax,atom->angle_per_atom);
if (atom->memcheck("angle_atom1"))
bytes += memory->usage(angle_atom1,nmax,atom->angle_per_atom);
if (atom->memcheck("angle_atom2"))
bytes += memory->usage(angle_atom2,nmax,atom->angle_per_atom);
if (atom->memcheck("angle_atom3"))
bytes += memory->usage(angle_atom3,nmax,atom->angle_per_atom);
return bytes;
}
/* ---------------------------------------------------------------------- */
void AtomVecAngleKokkos::sync(ExecutionSpace space, unsigned int mask) void AtomVecAngleKokkos::sync(ExecutionSpace space, unsigned int mask)
{ {
if (space == Device) { if (space == Device) {
@ -1826,6 +984,8 @@ void AtomVecAngleKokkos::sync(ExecutionSpace space, unsigned int mask)
} }
} }
/* ---------------------------------------------------------------------- */
void AtomVecAngleKokkos::sync_overlapping_device(ExecutionSpace space, unsigned int mask) void AtomVecAngleKokkos::sync_overlapping_device(ExecutionSpace space, unsigned int mask)
{ {
if (space == Device) { if (space == Device) {
@ -1973,4 +1133,3 @@ void AtomVecAngleKokkos::modified(ExecutionSpace space, unsigned int mask)
} }
} }
} }

View File

@ -24,41 +24,15 @@ AtomStyle(angle/kk/host,AtomVecAngleKokkos);
#define LMP_ATOM_VEC_ANGLE_KOKKOS_H #define LMP_ATOM_VEC_ANGLE_KOKKOS_H
#include "atom_vec_kokkos.h" #include "atom_vec_kokkos.h"
#include "atom_vec_angle.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
class AtomVecAngleKokkos : public AtomVecKokkos { class AtomVecAngleKokkos : public AtomVecKokkos, public AtomVecAngle {
public: public:
AtomVecAngleKokkos(class LAMMPS *); AtomVecAngleKokkos(class LAMMPS *);
void grow(int) override; void grow(int) override;
void copy(int, int, int) override;
int pack_comm(int, int *, double *, int, int *) override;
int pack_comm_vel(int, int *, double *, int, int *) override;
void unpack_comm(int, int, double *) override;
void unpack_comm_vel(int, int, double *) override;
int pack_reverse(int, int, double *) override;
void unpack_reverse(int, int *, double *) override;
int pack_border(int, int *, double *, int, int *) override;
int pack_border_vel(int, int *, double *, int, int *) override;
int pack_border_hybrid(int, int *, double *) override;
void unpack_border(int, int, double *) override;
void unpack_border_vel(int, int, double *) override;
int unpack_border_hybrid(int, int, double *) override;
int pack_exchange(int, double *) override;
int unpack_exchange(double *) override;
int size_restart() override;
int pack_restart(int, double *) override;
int unpack_restart(double *) override;
void create_atom(int, double *) override;
void data_atom(double *, imageint, const std::vector<std::string> &, std::string &) override;
int data_atom_hybrid(int, const std::vector<std::string> &, int) override;
void pack_data(double **) override;
int pack_data_hybrid(int, double *) override;
void write_data(FILE *, int, double **) override;
int write_data_hybrid(FILE *, double *) override;
double memory_usage() override;
void grow_pointers() override; void grow_pointers() override;
int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist, int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist,
const int & iswap, const int & iswap,
@ -89,21 +63,9 @@ class AtomVecAngleKokkos : public AtomVecKokkos {
void sync_overlapping_device(ExecutionSpace space, unsigned int mask) override; void sync_overlapping_device(ExecutionSpace space, unsigned int mask) override;
protected: protected:
tagint *tag;
int *type,*mask;
imageint *image;
double **x,**v,**f;
tagint *molecule; tagint *molecule;
int **nspecial;
tagint **special; tagint **special;
int *num_bond;
int **bond_type;
tagint **bond_atom; tagint **bond_atom;
int *num_angle;
int **angle_type;
tagint **angle_atom1,**angle_atom2,**angle_atom3; tagint **angle_atom1,**angle_atom2,**angle_atom3;
DAT::t_tagint_1d d_tag; DAT::t_tagint_1d d_tag;
@ -142,13 +104,9 @@ class AtomVecAngleKokkos : public AtomVecKokkos {
HAT::t_int_1d h_num_angle; HAT::t_int_1d h_num_angle;
HAT::t_int_2d h_angle_type; HAT::t_int_2d h_angle_type;
HAT::t_tagint_2d h_angle_atom1,h_angle_atom2,h_angle_atom3; HAT::t_tagint_2d h_angle_atom1,h_angle_atom2,h_angle_atom3;
DAT::tdual_int_1d k_count;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -27,23 +27,10 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecAtomicKokkos::AtomVecAtomicKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) AtomVecAtomicKokkos::AtomVecAtomicKokkos(LAMMPS *lmp) : AtomVec(lmp),
AtomVecKokkos(lmp), AtomVecAtomic(lmp)
{ {
molecular = Atom::ATOMIC;
mass_type = PER_TYPE;
comm_x_only = comm_f_only = 1;
size_forward = 3;
size_reverse = 3;
size_border = 6;
size_velocity = 3;
size_data_atom = 5;
size_data_vel = 4;
xcol_data = 3;
k_count = DAT::tdual_int_1d("atom::k_count",1);
atomKK = (AtomKokkos *) atom;
commKK = (CommKokkos *) comm;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -113,28 +100,6 @@ void AtomVecAtomicKokkos::grow_pointers()
h_f = atomKK->k_f.h_view; h_f = atomKK->k_f.h_view;
} }
/* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecAtomicKokkos::copy(int i, int j, int delflag)
{
h_tag[j] = h_tag[i];
h_type[j] = h_type[i];
mask[j] = mask[i];
h_image[j] = h_image[i];
h_x(j,0) = h_x(i,0);
h_x(j,1) = h_x(i,1);
h_x(j,2) = h_x(i,2);
h_v(j,0) = h_v(i,0);
h_v(j,1) = h_v(i,1);
h_v(j,2) = h_v(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);
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
template<class DeviceType,int PBC_FLAG> template<class DeviceType,int PBC_FLAG>
@ -232,130 +197,6 @@ int AtomVecAtomicKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int AtomVecAtomicKokkos::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++] = h_x(j,0);
buf[m++] = h_x(j,1);
buf[m++] = h_x(j,2);
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(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++] = h_x(j,0) + dx;
buf[m++] = h_x(j,1) + dy;
buf[m++] = h_x(j,2) + dz;
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(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 AtomVecAtomicKokkos::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++] = h_x(j,0);
buf[m++] = h_x(j,1);
buf[m++] = h_x(j,2);
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = h_v(j,0);
buf[m++] = h_v(j,1);
buf[m++] = h_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++] = h_x(j,0) + dx;
buf[m++] = h_x(j,1) + dy;
buf[m++] = h_x(j,2) + dz;
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = h_v(j,0);
buf[m++] = h_v(j,1);
buf[m++] = h_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++] = h_x(j,0) + dx;
buf[m++] = h_x(j,1) + dy;
buf[m++] = h_x(j,2) + dz;
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
if (mask[i] & deform_groupbit) {
buf[m++] = h_v(j,0) + dvx;
buf[m++] = h_v(j,1) + dvy;
buf[m++] = h_v(j,2) + dvz;
} else {
buf[m++] = h_v(j,0);
buf[m++] = h_v(j,1);
buf[m++] = h_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;
}
/* ---------------------------------------------------------------------- */
template<class DeviceType> template<class DeviceType>
struct AtomVecAtomicKokkos_UnpackBorder { struct AtomVecAtomicKokkos_UnpackBorder {
typedef DeviceType device_type; typedef DeviceType device_type;
@ -408,63 +249,6 @@ void AtomVecAtomicKokkos::unpack_border_kokkos(const int &n, const int &first,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AtomVecAtomicKokkos::unpack_border(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
while (last > nmax) grow(0);
for (i = first; i < last; i++) {
h_x(i,0) = buf[m++];
h_x(i,1) = buf[m++];
h_x(i,2) = buf[m++];
h_tag(i) = (tagint) ubuf(buf[m++]).i;
h_type(i) = (int) ubuf(buf[m++]).i;
h_mask(i) = (int) ubuf(buf[m++]).i;
}
atomKK->modified(Host,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK);
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 AtomVecAtomicKokkos::unpack_border_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
while (last > nmax) grow(0);
for (i = first; i < last; i++) {
h_x(i,0) = buf[m++];
h_x(i,1) = buf[m++];
h_x(i,2) = buf[m++];
h_tag(i) = (tagint) ubuf(buf[m++]).i;
h_type(i) = (int) ubuf(buf[m++]).i;
h_mask(i) = (int) ubuf(buf[m++]).i;
h_v(i,0) = buf[m++];
h_v(i,1) = buf[m++];
h_v(i,2) = buf[m++];
}
atomKK->modified(Host,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|V_MASK);
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]);
}
/* ---------------------------------------------------------------------- */
template<class DeviceType> template<class DeviceType>
struct AtomVecAtomicKokkos_PackExchangeFunctor { struct AtomVecAtomicKokkos_PackExchangeFunctor {
typedef DeviceType device_type; typedef DeviceType device_type;
@ -568,30 +352,6 @@ int AtomVecAtomicKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int AtomVecAtomicKokkos::pack_exchange(int i, double *buf)
{
int m = 1;
buf[m++] = h_x(i,0);
buf[m++] = h_x(i,1);
buf[m++] = h_x(i,2);
buf[m++] = h_v(i,0);
buf[m++] = h_v(i,1);
buf[m++] = h_v(i,2);
buf[m++] = ubuf(h_tag(i)).d;
buf[m++] = ubuf(h_type(i)).d;
buf[m++] = ubuf(h_mask(i)).d;
buf[m++] = ubuf(h_image(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;
}
/* ---------------------------------------------------------------------- */
template<class DeviceType> template<class DeviceType>
struct AtomVecAtomicKokkos_UnpackExchangeFunctor { struct AtomVecAtomicKokkos_UnpackExchangeFunctor {
typedef DeviceType device_type; typedef DeviceType device_type;
@ -671,238 +431,6 @@ int AtomVecAtomicKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int AtomVecAtomicKokkos::unpack_exchange(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
atomKK->modified(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK |
MASK_MASK | IMAGE_MASK);
int m = 1;
h_x(nlocal,0) = buf[m++];
h_x(nlocal,1) = buf[m++];
h_x(nlocal,2) = buf[m++];
h_v(nlocal,0) = buf[m++];
h_v(nlocal,1) = buf[m++];
h_v(nlocal,2) = buf[m++];
h_tag(nlocal) = (tagint) ubuf(buf[m++]).i;
h_type(nlocal) = (int) ubuf(buf[m++]).i;
h_mask(nlocal) = (int) ubuf(buf[m++]).i;
h_image(nlocal) = (imageint) 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 AtomVecAtomicKokkos::size_restart()
{
int i;
int nlocal = atom->nlocal;
int n = 11 * 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 AtomVecAtomicKokkos::pack_restart(int i, double *buf)
{
atomKK->sync(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK |
MASK_MASK | IMAGE_MASK );
int m = 1;
buf[m++] = h_x(i,0);
buf[m++] = h_x(i,1);
buf[m++] = h_x(i,2);
buf[m++] = ubuf(h_tag(i)).d;
buf[m++] = ubuf(h_type(i)).d;
buf[m++] = ubuf(h_mask(i)).d;
buf[m++] = ubuf(h_image(i)).d;
buf[m++] = h_v(i,0);
buf[m++] = h_v(i,1);
buf[m++] = h_v(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 AtomVecAtomicKokkos::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");
}
atomKK->modified(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK |
MASK_MASK | IMAGE_MASK );
int m = 1;
h_x(nlocal,0) = buf[m++];
h_x(nlocal,1) = buf[m++];
h_x(nlocal,2) = buf[m++];
h_tag(nlocal) = (tagint) ubuf(buf[m++]).i;
h_type(nlocal) = (int) ubuf(buf[m++]).i;
h_mask(nlocal) = (int) ubuf(buf[m++]).i;
h_image(nlocal) = (imageint) ubuf(buf[m++]).i;
h_v(nlocal,0) = buf[m++];
h_v(nlocal,1) = buf[m++];
h_v(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 AtomVecAtomicKokkos::create_atom(int itype, double *coord)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) {
//if(nlocal>2) printf("typeA: %i %i\n",type[0],type[1]);
atomKK->modified(Host,ALL_MASK);
grow(0);
//if(nlocal>2) printf("typeB: %i %i\n",type[0],type[1]);
}
atomKK->modified(Host,ALL_MASK);
tag[nlocal] = 0;
type[nlocal] = itype;
h_x(nlocal,0) = coord[0];
h_x(nlocal,1) = coord[1];
h_x(nlocal,2) = coord[2];
h_mask[nlocal] = 1;
h_image[nlocal] = ((tagint) IMGMAX << IMG2BITS) |
((tagint) IMGMAX << IMGBITS) | IMGMAX;
h_v(nlocal,0) = 0.0;
h_v(nlocal,1) = 0.0;
h_v(nlocal,2) = 0.0;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack one line from Atoms section of data file
initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecAtomicKokkos::data_atom(double *coord, imageint imagetmp,
const std::vector<std::string> &values, std::string &extract)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
h_tag[nlocal] = utils::inumeric(FLERR,values[0],true,lmp);
h_type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp);
extract = values[1];
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
error->one(FLERR,"Invalid atom type in Atoms section of data file");
h_x(nlocal,0) = coord[0];
h_x(nlocal,1) = coord[1];
h_x(nlocal,2) = coord[2];
h_image[nlocal] = imagetmp;
h_mask[nlocal] = 1;
h_v(nlocal,0) = 0.0;
h_v(nlocal,1) = 0.0;
h_v(nlocal,2) = 0.0;
atomKK->modified(Host,ALL_MASK);
atom->nlocal++;
}
/* ----------------------------------------------------------------------
pack atom info for data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecAtomicKokkos::pack_data(double **buf)
{
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
buf[i][0] = h_tag[i];
buf[i][1] = h_type[i];
buf[i][2] = h_x(i,0);
buf[i][3] = h_x(i,1);
buf[i][4] = h_x(i,2);
buf[i][5] = (h_image[i] & IMGMASK) - IMGMAX;
buf[i][6] = (h_image[i] >> IMGBITS & IMGMASK) - IMGMAX;
buf[i][7] = (h_image[i] >> IMG2BITS) - IMGMAX;
}
}
/* ----------------------------------------------------------------------
write atom info to data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecAtomicKokkos::write_data(FILE *fp, int n, double **buf)
{
for (int i = 0; i < n; i++)
fprintf(fp,"%d %d %-1.16e %-1.16e %-1.16e %d %d %d\n",
(int) buf[i][0],(int) buf[i][1],buf[i][2],buf[i][3],buf[i][4],
(int) buf[i][5],(int) buf[i][6],(int) buf[i][7]);
}
/* ----------------------------------------------------------------------
return # of bytes of allocated memory
------------------------------------------------------------------------- */
double AtomVecAtomicKokkos::memory_usage()
{
double 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*commKK->nthreads,3);
return bytes;
}
/* ---------------------------------------------------------------------- */
void AtomVecAtomicKokkos::sync(ExecutionSpace space, unsigned int mask) void AtomVecAtomicKokkos::sync(ExecutionSpace space, unsigned int mask)
{ {
if (space == Device) { if (space == Device) {
@ -983,4 +511,3 @@ void AtomVecAtomicKokkos::modified(ExecutionSpace space, unsigned int mask)
if (mask & IMAGE_MASK) atomKK->k_image.modify<LMPHostType>(); if (mask & IMAGE_MASK) atomKK->k_image.modify<LMPHostType>();
} }
} }

View File

@ -24,31 +24,16 @@ AtomStyle(atomic/kk/host,AtomVecAtomicKokkos);
#define LMP_ATOM_VEC_ATOMIC_KOKKOS_H #define LMP_ATOM_VEC_ATOMIC_KOKKOS_H
#include "atom_vec_kokkos.h" #include "atom_vec_kokkos.h"
#include "atom_vec_atomic.h"
#include "kokkos_type.h" #include "kokkos_type.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
class AtomVecAtomicKokkos : public AtomVecKokkos { class AtomVecAtomicKokkos : public AtomVecKokkos, public AtomVecAtomic {
public: public:
AtomVecAtomicKokkos(class LAMMPS *); AtomVecAtomicKokkos(class LAMMPS *);
void grow(int) override; void grow(int) override;
void copy(int, int, int) override;
int pack_border(int, int *, double *, int, int *) override;
int pack_border_vel(int, int *, double *, int, int *) override;
void unpack_border(int, int, double *) override;
void unpack_border_vel(int, int, double *) override;
int pack_exchange(int, double *) override;
int unpack_exchange(double *) override;
int size_restart() override;
int pack_restart(int, double *) override;
int unpack_restart(double *) override;
void create_atom(int, double *) override;
void data_atom(double *, imageint, const std::vector<std::string> &, std::string &) override;
void pack_data(double **) override;
void write_data(FILE *, int, double **) override;
double memory_usage() override;
void grow_pointers() override; void grow_pointers() override;
int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist,
DAT::tdual_xfloat_2d buf,int iswap, DAT::tdual_xfloat_2d buf,int iswap,
@ -70,11 +55,6 @@ class AtomVecAtomicKokkos : public AtomVecKokkos {
void sync_overlapping_device(ExecutionSpace space, unsigned int mask) override; void sync_overlapping_device(ExecutionSpace space, unsigned int mask) override;
protected: protected:
tagint *tag;
imageint *image;
int *type,*mask;
double **x,**v,**f;
DAT::t_tagint_1d d_tag; DAT::t_tagint_1d d_tag;
HAT::t_tagint_1d h_tag; HAT::t_tagint_1d h_tag;
DAT::t_imageint_1d d_image; DAT::t_imageint_1d d_image;
@ -85,8 +65,6 @@ class AtomVecAtomicKokkos : public AtomVecKokkos {
DAT::t_x_array d_x; DAT::t_x_array d_x;
DAT::t_v_array d_v; DAT::t_v_array d_v;
DAT::t_f_array d_f; DAT::t_f_array d_f;
DAT::tdual_int_1d k_count;
}; };
} }

View File

@ -27,26 +27,10 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecBondKokkos::AtomVecBondKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) AtomVecBondKokkos::AtomVecBondKokkos(LAMMPS *lmp) : AtomVec(lmp),
AtomVecKokkos(lmp), AtomVecBond(lmp)
{ {
molecular = Atom::MOLECULAR;
bonds_allow = 1;
mass_type = PER_TYPE;
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;
k_count = DAT::tdual_int_1d("atom::k_count",1);
atomKK = (AtomKokkos *) atom;
commKK = (CommKokkos *) comm;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -142,43 +126,6 @@ void AtomVecBondKokkos::grow_pointers()
h_bond_atom = atomKK->k_bond_atom.h_view; h_bond_atom = atomKK->k_bond_atom.h_view;
} }
/* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecBondKokkos::copy(int i, int j, int delflag)
{
int k;
h_tag[j] = h_tag[i];
h_type[j] = h_type[i];
mask[j] = mask[i];
h_image[j] = h_image[i];
h_x(j,0) = h_x(i,0);
h_x(j,1) = h_x(i,1);
h_x(j,2) = h_x(i,2);
h_v(j,0) = h_v(i,0);
h_v(j,1) = h_v(i,1);
h_v(j,2) = h_v(i,2);
h_molecule(j) = h_molecule(i);
h_num_bond(j) = h_num_bond(i);
for (k = 0; k < h_num_bond(j); k++) {
h_bond_type(j,k) = h_bond_type(i,k);
h_bond_atom(j,k) = h_bond_atom(i,k);
}
h_nspecial(j,0) = h_nspecial(i,0);
h_nspecial(j,1) = h_nspecial(i,1);
h_nspecial(j,2) = h_nspecial(i,2);
for (k = 0; k < h_nspecial(j,2); k++) h_special(j,k) = h_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);
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
template<class DeviceType,int PBC_FLAG> template<class DeviceType,int PBC_FLAG>
@ -282,149 +229,6 @@ int AtomVecBondKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int AtomVecBondKokkos::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++] = h_x(j,0);
buf[m++] = h_x(j,1);
buf[m++] = h_x(j,2);
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = ubuf(h_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++] = h_x(j,0) + dx;
buf[m++] = h_x(j,1) + dy;
buf[m++] = h_x(j,2) + dz;
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = ubuf(h_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 AtomVecBondKokkos::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++] = h_x(j,0);
buf[m++] = h_x(j,1);
buf[m++] = h_x(j,2);
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = ubuf(h_molecule(j)).d;
buf[m++] = h_v(j,0);
buf[m++] = h_v(j,1);
buf[m++] = h_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++] = h_x(j,0) + dx;
buf[m++] = h_x(j,1) + dy;
buf[m++] = h_x(j,2) + dz;
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = ubuf(h_molecule(j)).d;
buf[m++] = h_v(j,0);
buf[m++] = h_v(j,1);
buf[m++] = h_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++] = h_x(j,0) + dx;
buf[m++] = h_x(j,1) + dy;
buf[m++] = h_x(j,2) + dz;
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = ubuf(h_molecule(j)).d;
if (mask[i] & deform_groupbit) {
buf[m++] = h_v(j,0) + dvx;
buf[m++] = h_v(j,1) + dvy;
buf[m++] = h_v(j,2) + dvz;
} else {
buf[m++] = h_v(j,0);
buf[m++] = h_v(j,1);
buf[m++] = h_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 AtomVecBondKokkos::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++] = h_molecule(j);
}
return m;
}
/* ---------------------------------------------------------------------- */
template<class DeviceType> template<class DeviceType>
struct AtomVecBondKokkos_UnpackBorder { struct AtomVecBondKokkos_UnpackBorder {
typedef DeviceType device_type; typedef DeviceType device_type;
@ -485,78 +289,6 @@ void AtomVecBondKokkos::unpack_border_kokkos(const int &n, const int &first,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AtomVecBondKokkos::unpack_border(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
while (last > nmax) grow(0);
for (i = first; i < last; i++) {
h_x(i,0) = buf[m++];
h_x(i,1) = buf[m++];
h_x(i,2) = buf[m++];
h_tag(i) = (tagint) ubuf(buf[m++]).i;
h_type(i) = (int) ubuf(buf[m++]).i;
h_mask(i) = (int) ubuf(buf[m++]).i;
h_molecule(i) = (tagint) ubuf(buf[m++]).i;
}
atomKK->modified(Host,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK);
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 AtomVecBondKokkos::unpack_border_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
while (last > nmax) grow(0);
for (i = first; i < last; i++) {
h_x(i,0) = buf[m++];
h_x(i,1) = buf[m++];
h_x(i,2) = buf[m++];
h_tag(i) = (tagint) ubuf(buf[m++]).i;
h_type(i) = (int) ubuf(buf[m++]).i;
h_mask(i) = (int) ubuf(buf[m++]).i;
h_molecule(i) = (tagint) ubuf(buf[m++]).i;
h_v(i,0) = buf[m++];
h_v(i,1) = buf[m++];
h_v(i,2) = buf[m++];
}
atomKK->modified(Host,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK|V_MASK);
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 AtomVecBondKokkos::unpack_border_hybrid(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++)
h_molecule(i) = (tagint) ubuf(buf[m++]).i;
return m;
}
/* ---------------------------------------------------------------------- */
template<class DeviceType> template<class DeviceType>
struct AtomVecBondKokkos_PackExchangeFunctor { struct AtomVecBondKokkos_PackExchangeFunctor {
typedef DeviceType device_type; typedef DeviceType device_type;
@ -721,43 +453,6 @@ int AtomVecBondKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int AtomVecBondKokkos::pack_exchange(int i, double *buf)
{
int k;
int m = 1;
buf[m++] = h_x(i,0);
buf[m++] = h_x(i,1);
buf[m++] = h_x(i,2);
buf[m++] = h_v(i,0);
buf[m++] = h_v(i,1);
buf[m++] = h_v(i,2);
buf[m++] = ubuf(h_tag(i)).d;
buf[m++] = ubuf(h_type(i)).d;
buf[m++] = ubuf(h_mask(i)).d;
buf[m++] = ubuf(h_image(i)).d;
buf[m++] = ubuf(h_molecule(i)).d;
buf[m++] = ubuf(h_num_bond(i)).d;
for (k = 0; k < h_num_bond(i); k++) {
buf[m++] = ubuf(h_bond_type(i,k)).d;
buf[m++] = ubuf(h_bond_atom(i,k)).d;
}
buf[m++] = ubuf(h_nspecial(i,0)).d;
buf[m++] = ubuf(h_nspecial(i,1)).d;
buf[m++] = ubuf(h_nspecial(i,2)).d;
for (k = 0; k < h_nspecial(i,2); k++)
buf[m++] = ubuf(h_special(i,k)).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;
}
/* ---------------------------------------------------------------------- */
template<class DeviceType> template<class DeviceType>
struct AtomVecBondKokkos_UnpackExchangeFunctor { struct AtomVecBondKokkos_UnpackExchangeFunctor {
typedef DeviceType device_type; typedef DeviceType device_type;
@ -870,321 +565,6 @@ int AtomVecBondKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int nr
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int AtomVecBondKokkos::unpack_exchange(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
atomKK->modified(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK |
MASK_MASK | IMAGE_MASK | MOLECULE_MASK | BOND_MASK | SPECIAL_MASK);
int k;
int m = 1;
h_x(nlocal,0) = buf[m++];
h_x(nlocal,1) = buf[m++];
h_x(nlocal,2) = buf[m++];
h_v(nlocal,0) = buf[m++];
h_v(nlocal,1) = buf[m++];
h_v(nlocal,2) = buf[m++];
h_tag(nlocal) = (tagint) ubuf(buf[m++]).i;
h_type(nlocal) = (int) ubuf(buf[m++]).i;
h_mask(nlocal) = (int) ubuf(buf[m++]).i;
h_image(nlocal) = (imageint) ubuf(buf[m++]).i;
h_molecule(nlocal) = (tagint) ubuf(buf[m++]).i;
h_num_bond(nlocal) = (int) ubuf(buf[m++]).i;
for (k = 0; k < h_num_bond(nlocal); k++) {
h_bond_type(nlocal,k) = (int) ubuf(buf[m++]).i;
h_bond_atom(nlocal,k) = (tagint) ubuf(buf[m++]).i;
}
h_nspecial(nlocal,0) = (int) ubuf(buf[m++]).i;
h_nspecial(nlocal,1) = (int) ubuf(buf[m++]).i;
h_nspecial(nlocal,2) = (int) ubuf(buf[m++]).i;
for (k = 0; k < h_nspecial(nlocal,2); k++)
h_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 AtomVecBondKokkos::size_restart()
{
int i;
int nlocal = atom->nlocal;
int n = 0;
for (i = 0; i < nlocal; i++)
n += 13 + 2*h_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 AtomVecBondKokkos::pack_restart(int i, double *buf)
{
atomKK->sync(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK |
MASK_MASK | IMAGE_MASK | MOLECULE_MASK | BOND_MASK | SPECIAL_MASK);
int m = 1;
buf[m++] = h_x(i,0);
buf[m++] = h_x(i,1);
buf[m++] = h_x(i,2);
buf[m++] = ubuf(h_tag(i)).d;
buf[m++] = ubuf(h_type(i)).d;
buf[m++] = ubuf(h_mask(i)).d;
buf[m++] = ubuf(h_image(i)).d;
buf[m++] = h_v(i,0);
buf[m++] = h_v(i,1);
buf[m++] = h_v(i,2);
buf[m++] = ubuf(h_molecule(i)).d;
buf[m++] = ubuf(h_num_bond(i)).d;
for (int k = 0; k < h_num_bond(i); k++) {
buf[m++] = ubuf(MAX(h_bond_type(i,k),-h_bond_type(i,k))).d;
buf[m++] = ubuf(h_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 AtomVecBondKokkos::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");
}
atomKK->modified(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK |
MASK_MASK | IMAGE_MASK | MOLECULE_MASK | BOND_MASK | SPECIAL_MASK);
int m = 1;
h_x(nlocal,0) = buf[m++];
h_x(nlocal,1) = buf[m++];
h_x(nlocal,2) = buf[m++];
h_tag(nlocal) = (tagint) ubuf(buf[m++]).i;
h_type(nlocal) = (int) ubuf(buf[m++]).i;
h_mask(nlocal) = (int) ubuf(buf[m++]).i;
h_image(nlocal) = (imageint) ubuf(buf[m++]).i;
h_v(nlocal,0) = buf[m++];
h_v(nlocal,1) = buf[m++];
h_v(nlocal,2) = buf[m++];
h_molecule(nlocal) = (tagint) ubuf(buf[m++]).i;
h_num_bond(nlocal) = (int) ubuf(buf[m++]).i;
for (k = 0; k < h_num_bond(nlocal); k++) {
h_bond_type(nlocal,k) = (int) ubuf(buf[m++]).i;
h_bond_atom(nlocal,k) = (tagint) ubuf(buf[m++]).i;
}
h_nspecial(nlocal,0) = h_nspecial(nlocal,1) = h_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 AtomVecBondKokkos::create_atom(int itype, double *coord)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) {
atomKK->modified(Host,ALL_MASK);
grow(0);
}
atomKK->modified(Host,ALL_MASK);
tag[nlocal] = 0;
type[nlocal] = itype;
h_x(nlocal,0) = coord[0];
h_x(nlocal,1) = coord[1];
h_x(nlocal,2) = coord[2];
h_mask(nlocal) = 1;
h_image(nlocal) = ((imageint) IMGMAX << IMG2BITS) |
((imageint) IMGMAX << IMGBITS) | IMGMAX;
h_v(nlocal,0) = 0.0;
h_v(nlocal,1) = 0.0;
h_v(nlocal,2) = 0.0;
h_molecule(nlocal) = 0;
h_num_bond(nlocal) = 0;
h_nspecial(nlocal,0) = h_nspecial(nlocal,1) = h_nspecial(nlocal,2) = 0;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack one line from Atoms section of data file
initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecBondKokkos::data_atom(double *coord, imageint imagetmp,
const std::vector<std::string> &values, std::string &extract)
{
int nlocal = atomKK->nlocal;
if (nlocal == nmax) grow(0);
atomKK->modified(Host,ALL_MASK);
h_tag(nlocal) = utils::inumeric(FLERR,values[0],true,lmp);
h_molecule(nlocal) = utils::inumeric(FLERR,values[1],true,lmp);
h_type(nlocal) = utils::inumeric(FLERR,values[2],true,lmp);
extract = values[2];
if (h_type(nlocal) <= 0 || h_type(nlocal) > atom->ntypes)
error->one(FLERR,"Invalid atom type in Atoms section of data file");
h_x(nlocal,0) = coord[0];
h_x(nlocal,1) = coord[1];
h_x(nlocal,2) = coord[2];
h_image(nlocal) = imagetmp;
h_mask(nlocal) = 1;
h_v(nlocal,0) = 0.0;
h_v(nlocal,1) = 0.0;
h_v(nlocal,2) = 0.0;
h_num_bond(nlocal) = 0;
atomKK->nlocal++;
}
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */
int AtomVecBondKokkos::data_atom_hybrid(int nlocal, const std::vector<std::string> &values,
int offset)
{
h_molecule(nlocal) = utils::inumeric(FLERR,values[offset],true,lmp);
h_num_bond(nlocal) = 0;
return 1;
}
/* ----------------------------------------------------------------------
pack atom info for data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecBondKokkos::pack_data(double **buf)
{
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
buf[i][0] = h_tag(i);
buf[i][1] = h_molecule(i);
buf[i][2] = h_type(i);
buf[i][3] = h_x(i,0);
buf[i][4] = h_x(i,1);
buf[i][5] = h_x(i,2);
buf[i][6] = (h_image[i] & IMGMASK) - IMGMAX;
buf[i][7] = (h_image[i] >> IMGBITS & IMGMASK) - IMGMAX;
buf[i][8] = (h_image[i] >> IMG2BITS) - IMGMAX;
}
}
/* ----------------------------------------------------------------------
pack hybrid atom info for data file
------------------------------------------------------------------------- */
int AtomVecBondKokkos::pack_data_hybrid(int i, double *buf)
{
buf[0] = h_molecule(i);
return 1;
}
/* ----------------------------------------------------------------------
write atom info to data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecBondKokkos::write_data(FILE *fp, int n, double **buf)
{
for (int i = 0; i < n; i++)
fprintf(fp,"%d %d %d %-1.16e %-1.16e %-1.16e %d %d %d\n",
(int) buf[i][0],(int) buf[i][1], (int) buf[i][2],
buf[i][3],buf[i][4],buf[i][5],
(int) buf[i][6],(int) buf[i][7],(int) buf[i][8]);
}
/* ----------------------------------------------------------------------
write hybrid atom info to data file
------------------------------------------------------------------------- */
int AtomVecBondKokkos::write_data_hybrid(FILE *fp, double *buf)
{
fprintf(fp," " TAGINT_FORMAT, (tagint) (buf[0]));
return 1;
}
/* ----------------------------------------------------------------------
return # of bytes of allocated memory
------------------------------------------------------------------------- */
double AtomVecBondKokkos::memory_usage()
{
double 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*commKK->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;
}
/* ---------------------------------------------------------------------- */
void AtomVecBondKokkos::sync(ExecutionSpace space, unsigned int mask) void AtomVecBondKokkos::sync(ExecutionSpace space, unsigned int mask)
{ {
if (space == Device) { if (space == Device) {
@ -1337,4 +717,3 @@ void AtomVecBondKokkos::modified(ExecutionSpace space, unsigned int mask)
} }
} }
} }

View File

@ -24,35 +24,15 @@ AtomStyle(bond/kk/host,AtomVecBondKokkos);
#define LMP_ATOM_VEC_BOND_KOKKOS_H #define LMP_ATOM_VEC_BOND_KOKKOS_H
#include "atom_vec_kokkos.h" #include "atom_vec_kokkos.h"
#include "atom_vec_bond.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
class AtomVecBondKokkos : public AtomVecKokkos { class AtomVecBondKokkos : public AtomVecKokkos, public AtomVecBond {
public: public:
AtomVecBondKokkos(class LAMMPS *); AtomVecBondKokkos(class LAMMPS *);
void grow(int) override; void grow(int) override;
void copy(int, int, int) override;
int pack_border(int, int *, double *, int, int *) override;
int pack_border_vel(int, int *, double *, int, int *) override;
int pack_border_hybrid(int, int *, double *) override;
void unpack_border(int, int, double *) override;
void unpack_border_vel(int, int, double *) override;
int unpack_border_hybrid(int, int, double *) override;
int pack_exchange(int, double *) override;
int unpack_exchange(double *) override;
int size_restart() override;
int pack_restart(int, double *) override;
int unpack_restart(double *) override;
void create_atom(int, double *) override;
void data_atom(double *, imageint, const std::vector<std::string> &, std::string &) override;
int data_atom_hybrid(int, const std::vector<std::string> &, int) override;
void pack_data(double **) override;
int pack_data_hybrid(int, double *) override;
void write_data(FILE *, int, double **) override;
int write_data_hybrid(FILE *, double *) override;
double memory_usage() override;
void grow_pointers() override; void grow_pointers() override;
int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist,
DAT::tdual_xfloat_2d buf,int iswap, DAT::tdual_xfloat_2d buf,int iswap,
@ -73,18 +53,9 @@ class AtomVecBondKokkos : public AtomVecKokkos {
void modified(ExecutionSpace space, unsigned int mask) override; void modified(ExecutionSpace space, unsigned int mask) override;
void sync_overlapping_device(ExecutionSpace space, unsigned int mask) override; void sync_overlapping_device(ExecutionSpace space, unsigned int mask) override;
protected: private:
tagint *tag;
int *type,*mask;
imageint *image;
double **x,**v,**f;
tagint *molecule; tagint *molecule;
int **nspecial;
tagint **special; tagint **special;
int *num_bond;
int **bond_type;
tagint **bond_atom; tagint **bond_atom;
DAT::t_tagint_1d d_tag; DAT::t_tagint_1d d_tag;
@ -112,9 +83,6 @@ class AtomVecBondKokkos : public AtomVecKokkos {
HAT::t_int_1d h_num_bond; HAT::t_int_1d h_num_bond;
HAT::t_int_2d h_bond_type; HAT::t_int_2d h_bond_type;
HAT::t_tagint_2d h_bond_atom; HAT::t_tagint_2d h_bond_atom;
DAT::tdual_int_1d k_count;
}; };
} }

View File

@ -27,25 +27,9 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecChargeKokkos::AtomVecChargeKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) AtomVecChargeKokkos::AtomVecChargeKokkos(LAMMPS *lmp) : AtomVec(lmp),
AtomVecKokkos(lmp), AtomVecCharge(lmp)
{ {
molecular = Atom::ATOMIC;
mass_type = PER_TYPE;
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->q_flag = 1;
k_count = DAT::tdual_int_1d("atom::k_count",1);
atomKK = (AtomKokkos *) atom;
commKK = (CommKokkos *) comm;
} }
@ -123,30 +107,6 @@ void AtomVecChargeKokkos::grow_pointers()
} }
/* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecChargeKokkos::copy(int i, int j, int delflag)
{
h_tag[j] = h_tag[i];
h_type[j] = h_type[i];
mask[j] = mask[i];
h_image[j] = h_image[i];
h_x(j,0) = h_x(i,0);
h_x(j,1) = h_x(i,1);
h_x(j,2) = h_x(i,2);
h_v(j,0) = h_v(i,0);
h_v(j,1) = h_v(i,1);
h_v(j,2) = h_v(i,2);
h_q[j] = h_q[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);
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
template<class DeviceType,int PBC_FLAG,int TRICLINIC> template<class DeviceType,int PBC_FLAG,int TRICLINIC>
@ -297,150 +257,6 @@ int AtomVecChargeKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist,
return n*size_border; return n*size_border;
} }
/* ---------------------------------------------------------------------- */
int AtomVecChargeKokkos::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++] = h_x(j,0);
buf[m++] = h_x(j,1);
buf[m++] = h_x(j,2);
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = h_q(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++] = h_x(j,0) + dx;
buf[m++] = h_x(j,1) + dy;
buf[m++] = h_x(j,2) + dz;
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = h_q(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 AtomVecChargeKokkos::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++] = h_x(j,0);
buf[m++] = h_x(j,1);
buf[m++] = h_x(j,2);
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = h_q[j];
buf[m++] = h_v(j,0);
buf[m++] = h_v(j,1);
buf[m++] = h_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++] = h_x(j,0) + dx;
buf[m++] = h_x(j,1) + dy;
buf[m++] = h_x(j,2) + dz;
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = h_q[j];
buf[m++] = h_v(j,0);
buf[m++] = h_v(j,1);
buf[m++] = h_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++] = h_x(j,0) + dx;
buf[m++] = h_x(j,1) + dy;
buf[m++] = h_x(j,2) + dz;
buf[m++] = ubuf(h_tag(j)).d;
buf[m++] = ubuf(h_type(j)).d;
buf[m++] = ubuf(h_mask(j)).d;
buf[m++] = h_q[j];
if (mask[i] & deform_groupbit) {
buf[m++] = h_v(j,0) + dvx;
buf[m++] = h_v(j,1) + dvy;
buf[m++] = h_v(j,2) + dvz;
} else {
buf[m++] = h_v(j,0);
buf[m++] = h_v(j,1);
buf[m++] = h_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 AtomVecChargeKokkos::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++] = h_q[j];
}
return m;
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
template<class DeviceType> template<class DeviceType>
@ -500,78 +316,6 @@ void AtomVecChargeKokkos::unpack_border_kokkos(const int &n, const int &first,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AtomVecChargeKokkos::unpack_border(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
while (last > nmax) grow(0);
for (i = first; i < last; i++) {
h_x(i,0) = buf[m++];
h_x(i,1) = buf[m++];
h_x(i,2) = buf[m++];
h_tag(i) = (tagint) ubuf(buf[m++]).i;
h_type(i) = (int) ubuf(buf[m++]).i;
h_mask(i) = (int) ubuf(buf[m++]).i;
h_q[i] = buf[m++];
}
atomKK->modified(Host,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|Q_MASK);
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 AtomVecChargeKokkos::unpack_border_vel(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
while (last > nmax) grow(0);
for (i = first; i < last; i++) {
h_x(i,0) = buf[m++];
h_x(i,1) = buf[m++];
h_x(i,2) = buf[m++];
h_tag(i) = (tagint) ubuf(buf[m++]).i;
h_type(i) = (int) ubuf(buf[m++]).i;
h_mask(i) = (int) ubuf(buf[m++]).i;
h_q[i] = buf[m++];
h_v(i,0) = buf[m++];
h_v(i,1) = buf[m++];
h_v(i,2) = buf[m++];
}
atomKK->modified(Host,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|Q_MASK|V_MASK);
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 AtomVecChargeKokkos::unpack_border_hybrid(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++)
h_q[i] = buf[m++];
return m;
}
/* ---------------------------------------------------------------------- */
template<class DeviceType> template<class DeviceType>
struct AtomVecChargeKokkos_PackExchangeFunctor { struct AtomVecChargeKokkos_PackExchangeFunctor {
typedef DeviceType device_type; typedef DeviceType device_type;
@ -688,31 +432,6 @@ int AtomVecChargeKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int AtomVecChargeKokkos::pack_exchange(int i, double *buf)
{
int m = 1;
buf[m++] = h_x(i,0);
buf[m++] = h_x(i,1);
buf[m++] = h_x(i,2);
buf[m++] = h_v(i,0);
buf[m++] = h_v(i,1);
buf[m++] = h_v(i,2);
buf[m++] = ubuf(h_tag(i)).d;
buf[m++] = ubuf(h_type(i)).d;
buf[m++] = ubuf(h_mask(i)).d;
buf[m++] = ubuf(h_image(i)).d;
buf[m++] = h_q[i];
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;
}
/* ---------------------------------------------------------------------- */
template<class DeviceType> template<class DeviceType>
struct AtomVecChargeKokkos_UnpackExchangeFunctor { struct AtomVecChargeKokkos_UnpackExchangeFunctor {
typedef DeviceType device_type; typedef DeviceType device_type;
@ -797,281 +516,6 @@ int AtomVecChargeKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int AtomVecChargeKokkos::unpack_exchange(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
atomKK->modified(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK |
MASK_MASK | IMAGE_MASK | Q_MASK);
int m = 1;
h_x(nlocal,0) = buf[m++];
h_x(nlocal,1) = buf[m++];
h_x(nlocal,2) = buf[m++];
h_v(nlocal,0) = buf[m++];
h_v(nlocal,1) = buf[m++];
h_v(nlocal,2) = buf[m++];
h_tag(nlocal) = (tagint) ubuf(buf[m++]).i;
h_type(nlocal) = (int) ubuf(buf[m++]).i;
h_mask(nlocal) = (int) ubuf(buf[m++]).i;
h_image(nlocal) = (imageint) ubuf(buf[m++]).i;
h_q[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 AtomVecChargeKokkos::size_restart()
{
int i;
int nlocal = atom->nlocal;
int n = 12 * 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 AtomVecChargeKokkos::pack_restart(int i, double *buf)
{
atomKK->sync(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK |
MASK_MASK | IMAGE_MASK | Q_MASK);
int m = 1;
buf[m++] = h_x(i,0);
buf[m++] = h_x(i,1);
buf[m++] = h_x(i,2);
buf[m++] = ubuf(h_tag(i)).d;
buf[m++] = ubuf(h_type(i)).d;
buf[m++] = ubuf(h_mask(i)).d;
buf[m++] = ubuf(h_image(i)).d;
buf[m++] = h_v(i,0);
buf[m++] = h_v(i,1);
buf[m++] = h_v(i,2);
buf[m++] = h_q[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 AtomVecChargeKokkos::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");
}
atomKK->modified(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK |
MASK_MASK | IMAGE_MASK | Q_MASK);
int m = 1;
h_x(nlocal,0) = buf[m++];
h_x(nlocal,1) = buf[m++];
h_x(nlocal,2) = buf[m++];
h_tag(nlocal) = (tagint) ubuf(buf[m++]).i;
h_type(nlocal) = (int) ubuf(buf[m++]).i;
h_mask(nlocal) = (int) ubuf(buf[m++]).i;
h_image(nlocal) = (imageint) ubuf(buf[m++]).i;
h_v(nlocal,0) = buf[m++];
h_v(nlocal,1) = buf[m++];
h_v(nlocal,2) = buf[m++];
h_q[nlocal] = 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 AtomVecChargeKokkos::create_atom(int itype, double *coord)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) {
atomKK->modified(Host,ALL_MASK);
grow(0);
}
atomKK->sync(Host,ALL_MASK);
atomKK->modified(Host,ALL_MASK);
tag[nlocal] = 0;
type[nlocal] = itype;
h_x(nlocal,0) = coord[0];
h_x(nlocal,1) = coord[1];
h_x(nlocal,2) = coord[2];
h_mask[nlocal] = 1;
h_image[nlocal] = ((imageint) IMGMAX << IMG2BITS) |
((imageint) IMGMAX << IMGBITS) | IMGMAX;
h_v(nlocal,0) = 0.0;
h_v(nlocal,1) = 0.0;
h_v(nlocal,2) = 0.0;
h_q[nlocal] = 0.0;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack one line from Atoms section of data file
initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecChargeKokkos::data_atom(double *coord, imageint imagetmp,
const std::vector<std::string> &values, std::string &extract)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
h_tag[nlocal] = utils::inumeric(FLERR,values[0],true,lmp);
h_type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp);
extract = values[1];
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
error->one(FLERR,"Invalid atom type in Atoms section of data file");
h_q[nlocal] = utils::numeric(FLERR,values[2],true,lmp);
h_x(nlocal,0) = coord[0];
h_x(nlocal,1) = coord[1];
h_x(nlocal,2) = coord[2];
h_image[nlocal] = imagetmp;
h_mask[nlocal] = 1;
h_v(nlocal,0) = 0.0;
h_v(nlocal,1) = 0.0;
h_v(nlocal,2) = 0.0;
atomKK->modified(Host,ALL_MASK);
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */
int AtomVecChargeKokkos::data_atom_hybrid(int nlocal, const std::vector<std::string> &values,
int offset)
{
h_q[nlocal] = utils::numeric(FLERR,values[offset],true,lmp);
return 1;
}
/* ----------------------------------------------------------------------
pack atom info for data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecChargeKokkos::pack_data(double **buf)
{
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
buf[i][0] = h_tag[i];
buf[i][1] = h_type[i];
buf[i][2] = h_q[i];
buf[i][3] = h_x(i,0);
buf[i][4] = h_x(i,1);
buf[i][5] = h_x(i,2);
buf[i][6] = (h_image[i] & IMGMASK) - IMGMAX;
buf[i][7] = (h_image[i] >> IMGBITS & IMGMASK) - IMGMAX;
buf[i][8] = (h_image[i] >> IMG2BITS) - IMGMAX;
}
}
/* ----------------------------------------------------------------------
pack hybrid atom info for data file
------------------------------------------------------------------------- */
int AtomVecChargeKokkos::pack_data_hybrid(int i, double *buf)
{
buf[0] = h_q[i];
return 1;
}
/* ----------------------------------------------------------------------
write atom info to data file including 3 image flags
------------------------------------------------------------------------- */
void AtomVecChargeKokkos::write_data(FILE *fp, int n, double **buf)
{
for (int i = 0; i < n; i++)
fprintf(fp,"%d %d %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d\n",
(int) buf[i][0],(int) buf[i][1],buf[i][2],buf[i][3],buf[i][4],buf[i][5],
(int) buf[i][6],(int) buf[i][7],(int) buf[i][8]);
}
/* ----------------------------------------------------------------------
write hybrid atom info to data file
------------------------------------------------------------------------- */
int AtomVecChargeKokkos::write_data_hybrid(FILE *fp, double *buf)
{
fprintf(fp," %-1.16e",buf[0]);
return 1;
}
/* ----------------------------------------------------------------------
return # of bytes of allocated memory
------------------------------------------------------------------------- */
double AtomVecChargeKokkos::memory_usage()
{
double 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*commKK->nthreads,3);
if (atom->memcheck("q")) bytes += memory->usage(q,nmax);
return bytes;
}
/* ---------------------------------------------------------------------- */
void AtomVecChargeKokkos::sync(ExecutionSpace space, unsigned int mask) void AtomVecChargeKokkos::sync(ExecutionSpace space, unsigned int mask)
{ {
if (space == Device) { if (space == Device) {
@ -1120,6 +564,8 @@ void AtomVecChargeKokkos::modified(ExecutionSpace space, unsigned int mask)
} }
} }
/* ---------------------------------------------------------------------- */
void AtomVecChargeKokkos::sync_overlapping_device(ExecutionSpace space, unsigned int mask) void AtomVecChargeKokkos::sync_overlapping_device(ExecutionSpace space, unsigned int mask)
{ {
if (space == Device) { if (space == Device) {
@ -1158,4 +604,3 @@ void AtomVecChargeKokkos::sync_overlapping_device(ExecutionSpace space, unsigned
perform_async_copy<DAT::tdual_float_1d>(atomKK->k_q,space); perform_async_copy<DAT::tdual_float_1d>(atomKK->k_q,space);
} }
} }

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